Skip to content

Commit

Permalink
console: use the new string functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Aug 30, 2024
1 parent 13b8d3d commit dd1c277
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 140 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- fixed cameras with glide values sometimes moving in the wrong direction (#1451, regression from 4.3)
- fixed `/give` console command giving duplicate items under some circumstances (#1463, regression from 3.0)
- fixed `/give` console command confusing logging around mismatched items (#1463, regression from 3.0)
- fixed `/flip` console command misreporting an already enabled flipmap as off (regression from 4.0)
- fixed console commands causing improper ring shutdown with selected inventory item (#1460, regression from 3.0)
- improved logs module names readability
- improved crash debug information on Windows
Expand Down
5 changes: 4 additions & 1 deletion src/game/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <libtrx/log.h>

#include <SDL2/SDL_keycode.h>
#include <assert.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -74,7 +75,7 @@ static COMMAND_RESULT Console_Eval(const char *const cmdline)
const CONSOLE_COMMAND *matching_cmd = NULL;

for (CONSOLE_COMMAND *cur_cmd = &g_ConsoleCommands[0];
cur_cmd->proc != NULL; cur_cmd++) {
cur_cmd->prefix != NULL; cur_cmd++) {
if (strstr(cmdline, cur_cmd->prefix) != cmdline) {
continue;
}
Expand All @@ -96,7 +97,9 @@ static COMMAND_RESULT Console_Eval(const char *const cmdline)
return CR_BAD_INVOCATION;
}

assert(matching_cmd->proc != NULL);
const COMMAND_RESULT result = matching_cmd->proc(args);

switch (result) {
case CR_BAD_INVOCATION:
Console_Log(GS(OSD_COMMAND_BAD_INVOCATION), cmdline);
Expand Down
Loading

0 comments on commit dd1c277

Please sign in to comment.