Skip to content

Commit 9f0c2ec

Browse files
authored
chore(Misc) update module (#12)
1 parent 9e2cf42 commit 9f0c2ec

File tree

7 files changed

+32
-19
lines changed

7 files changed

+32
-19
lines changed

.gitattributes

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@
3232
## For documentation
3333

3434
# Documents
35-
*.doc diff=astextplain
36-
*.DOC diff=astextplain
35+
*.doc diff=astextplain
36+
*.DOC diff=astextplain
3737
*.docx diff=astextplain
3838
*.DOCX diff=astextplain
3939
*.dot diff=astextplain
4040
*.DOT diff=astextplain
4141
*.pdf diff=astextplain
42-
*.PDF diff=astextplain
43-
*.rtf diff=astextplain
44-
*.RTF diff=astextplain
42+
*.PDF diff=astextplain
43+
*.rtf diff=astextplain
44+
*.RTF diff=astextplain
4545

4646
## DOCUMENTATION
4747
*.markdown text

.github/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- Latest build status with azerothcore:
66

7-
[![Build Status](https://github.com/pangolp/mod-recruit-friend/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/pangolp/mod-recruit-friend)
7+
[![Build Status](https://github.com/pangolp/mod-recruit-friend/actions/workflows/core-build.yml/badge.svg)](https://github.com/pangolp/mod-recruit-friend/actions)
88

99
[English](README.md) | [Español](README_ES.md)
1010

.github/README_ES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- Último estado de compilación con azerothcore:
66

7-
[![Build Status](https://github.com/pangolp/mod-recruit-friend/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/pangolp/mod-recruit-friend)
7+
[![Build Status](https://github.com/pangolp/mod-recruit-friend/actions/workflows/core-build.yml/badge.svg)](https://github.com/pangolp/mod-recruit-friend/actions)
88

99
## Nota importante
1010

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SET @ENTRY:=35457;
22
DELETE FROM `acore_string` WHERE `entry` IN (@ENTRY+0, @ENTRY+1);
33
INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES
4-
(@ENTRY+0, '[Recruit Friend] You must wait for %u sec. to use this command again.', '', '', '', '', '', '[Reclutar Amigo] Debes esperar %u seg para utilizar este comando nuevamente.', '[Reclutar Amigo] Debes esperar %u seg para utilizar este comando nuevamente.', ''),
4+
(@ENTRY+0, '[Recruit Friend] You must wait for {} sec. to use this command again.', '', '', '', '', '', '[Reclutar Amigo] Debes esperar {} seg para utilizar este comando nuevamente.', '[Reclutar Amigo] Debes esperar {} seg para utilizar este comando nuevamente.', ''),
55
(@ENTRY+1, '[Recruit Friend] You haven\'t recruited anyone. Use the .recruit add command to do this.', '', '', '', '', '', '[Recruit Friend] No has reclutado a nadie. Utiliza el comando .recruit add para hacerlo.', '[Recruit Friend] No has reclutado a nadie. Utiliza el comando .recruit add para hacerlo.', '');
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
SET @ENTRY:=35456;
22
DELETE FROM `acore_string` WHERE `entry`=@ENTRY+0;
33
INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES
4-
(@ENTRY+0, '[Recruit Friend] Recruited character: %s', '', '', '', '', '', '[Recruit Friend] Personaje reclutado: %s', '[Recruit Friend] Personaje reclutado: %s', '');
4+
(@ENTRY+0, '[Recruit Friend] Recruited character: {}', '', '', '', '', '', '[Recruit Friend] Personaje reclutado: {}', '[Recruit Friend] Personaje reclutado: {}', '');
File renamed without changes.

src/RecruitCommand.cpp renamed to src/recruit_commands.cpp

+23-10
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
enum RecruitFriendTexts
1616
{
17-
HELLO_RECRUIT_FRIEND = 35450,
18-
RECRUIT_FRIEND_DISABLE,
19-
RECRUIT_FRIEND_ALREADY_HAVE_RECRUITED,
20-
RECRUIT_FRIEND_SUCCESS,
21-
RECRUIT_FRIEND_RESET_SUCCESS,
22-
RECRUIT_FRIEND_TARGET_ONESELF,
23-
RECRUIT_FRIEND_NAMES,
24-
RECRUIT_FRIEND_COOLDOWN,
25-
RECRUIT_VIEW_EMPTY
17+
HELLO_RECRUIT_FRIEND = 35450,
18+
RECRUIT_FRIEND_DISABLE = 35451,
19+
RECRUIT_FRIEND_ALREADY_HAVE_RECRUITED = 35452,
20+
RECRUIT_FRIEND_SUCCESS = 35453,
21+
RECRUIT_FRIEND_RESET_SUCCESS = 35454,
22+
RECRUIT_FRIEND_TARGET_ONESELF = 35455,
23+
RECRUIT_FRIEND_NAMES = 35456,
24+
RECRUIT_FRIEND_COOLDOWN = 35457,
25+
RECRUIT_VIEW_EMPTY = 35458
2626
};
2727

2828
struct RecruitFriendStruct
@@ -51,16 +51,22 @@ class RecruitFriendAnnouncer : public PlayerScript
5151
void registerQuery(ChatHandler* handler, const char* commandType)
5252
{
5353
uint32 myAccountId = handler->GetSession()->GetAccountId();
54+
5455
std::string accountName;
56+
5557
AccountMgr::GetName(myAccountId, accountName);
58+
5659
std::string characterName = handler->GetSession()->GetPlayerName();
60+
5761
std::string ipAccount = handler->GetSession()->GetRemoteAddress();
62+
5863
QueryResult info = LoginDatabase.Query("INSERT INTO `recruit_info` (`accountId`, `accountName`, `characterName`, `ip`, `command`) VALUES ({}, '{}', '{}', '{}', '{}')", myAccountId, accountName.c_str(), characterName.c_str(), ipAccount.c_str(), commandType);
5964
}
6065

61-
void waitToUseCommand(ChatHandler* handler, uint32 myAccountId)
66+
static void waitToUseCommand(ChatHandler* handler, uint32 myAccountId)
6267
{
6368
std::time_t currentTime = std::time(0);
69+
6470
uint32 delta = std::difftime(currentTime, recruitFriend.commandCooldown[myAccountId]);
6571

6672
if (delta <= (uint32)recruitFriend.cooldownValue / 1000)
@@ -76,6 +82,7 @@ void waitToUseCommand(ChatHandler* handler, uint32 myAccountId)
7682
static void getTargetAccountIdByName(std::string& name, uint32& accountId)
7783
{
7884
QueryResult result = CharacterDatabase.Query("SELECT `account` FROM `characters` WHERE `name`='{}'", name);
85+
7986
accountId = (*result)[0].Get<int32>();
8087
}
8188

@@ -146,6 +153,7 @@ class RecruitCommandscript : public CommandScript
146153
if (recruitFriend.cooldownEnabled)
147154
{
148155
waitToUseCommand(handler, myAccountId);
156+
149157
if (!recruitFriend.commandCooldown[myAccountId])
150158
recruitFriend.commandCooldown[myAccountId] = std::time(0);
151159
else
@@ -163,6 +171,7 @@ class RecruitCommandscript : public CommandScript
163171
else if (targetAccountId != myAccountId)
164172
{
165173
result = LoginDatabase.Query("UPDATE `account` SET `recruiter`={} WHERE `id`={}", targetAccountId, myAccountId);
174+
166175
ChatHandler(handler->GetSession()).SendSysMessage(RECRUIT_FRIEND_SUCCESS);
167176
}
168177
else
@@ -185,14 +194,17 @@ class RecruitCommandscript : public CommandScript
185194
if (recruitFriend.cooldownEnabled)
186195
{
187196
waitToUseCommand(handler, myAccountId);
197+
188198
if (!recruitFriend.commandCooldown[myAccountId])
189199
recruitFriend.commandCooldown[myAccountId] = std::time(0);
190200
else
191201
return true;
192202
}
193203

194204
registerQuery(handler, "reset");
205+
195206
QueryResult result = LoginDatabase.Query("UPDATE `account` SET `recruiter`=0 WHERE `id`={}", myAccountId);
207+
196208
ChatHandler(handler->GetSession()).SendSysMessage(RECRUIT_FRIEND_RESET_SUCCESS);
197209

198210
return true;
@@ -211,6 +223,7 @@ class RecruitCommandscript : public CommandScript
211223
if (recruitFriend.cooldownEnabled)
212224
{
213225
waitToUseCommand(handler, myAccountId);
226+
214227
if (!recruitFriend.commandCooldown[myAccountId])
215228
recruitFriend.commandCooldown[myAccountId] = std::time(0);
216229
else

0 commit comments

Comments
 (0)