Core/Commands: Refactored chat command script hook, fixes a crash when building with gcc 5
Closes #15616 Closes #15740 (cherry picked from commit 2d942ddcc528cc9fe718ebbd5903318fcbdab817) Conflicts: src/server/game/Chat/Chat.cpp src/server/scripts/Commands/cs_battlenet_account.cpp src/server/scripts/Commands/cs_cast.cpp src/server/scripts/Commands/cs_debug.cpp src/server/scripts/Commands/cs_go.cpp src/server/scripts/Commands/cs_misc.cpp src/server/scripts/Commands/cs_mmaps.cpp src/server/scripts/Commands/cs_npc.cpp src/server/scripts/Commands/cs_reload.cpp src/server/scripts/Commands/cs_ticket.cpp
This commit is contained in:
1 parent
1a5b0067a3
commit
af41a70fe8
47 files changed
+760
-1004
No files matched your search
@@ -36,9 +36,9 @@
|
||||
|
||||
char* command_finder(const char* text, int state)
|
||||
{
|
||||
static int idx, len;
|
||||
static size_t idx, len;
|
||||
const char* ret;
|
||||
ChatCommand* cmd = ChatHandler::getCommandTable();
|
||||
std::vector<ChatCommand> const& cmd = ChatHandler::getCommandTable();
|
||||
|
||||
if (!state)
|
||||
{
|
||||
@@ -46,20 +46,19 @@ char* command_finder(const char* text, int state)
|
||||
len = strlen(text);
|
||||
}
|
||||
|
||||
while ((ret = cmd[idx].Name))
|
||||
while (idx < cmd.size())
|
||||
{
|
||||
ret = cmd[idx].Name;
|
||||
if (!cmd[idx].AllowConsole)
|
||||
{
|
||||
idx++;
|
||||
++idx;
|
||||
continue;
|
||||
}
|
||||
|
||||
idx++;
|
||||
++idx;
|
||||
//printf("Checking %s \n", cmd[idx].Name);
|
||||
if (strncmp(ret, text, len) == 0)
|
||||
return strdup(ret);
|
||||
if (cmd[idx].Name == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
return ((char*)NULL);
|
||||
|
||||
Reference in new issue
Block a user