diff options
| author | Shauren <shauren.trinity@gmail.com> | 2015-10-22 20:26:56 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2015-10-22 20:26:56 +0200 |
| commit | 2d942ddcc528cc9fe718ebbd5903318fcbdab817 (patch) | |
| tree | 51eefc279aa09d6a8e6aa28abd0f1b0324e96cca /src/server/worldserver/CommandLine | |
| parent | 935c93e099f534f701ff8787204ce19be2ed2df2 (diff) | |
Core/Commands: Refactored chat command script hook, fixes a crash when building with gcc 5
Closes #15616
Closes #15740
Diffstat (limited to 'src/server/worldserver/CommandLine')
| -rw-r--r-- | src/server/worldserver/CommandLine/CliRunnable.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index 6e961922b0e..ff55a181f71 100644 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -41,9 +41,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) { @@ -51,20 +51,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); |
