diff options
| author | Franklin Wei <git@fwei.tk> | 2015-05-24 18:34:58 -0400 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2015-05-24 18:34:58 -0400 |
| commit | b307e719416e39ed525a1c51d7df61ae55b35eec (patch) | |
| tree | 8fbe59320bd0a32f6cc5155ad9a75aa2ed8b33a1 /src | |
| parent | 058c0f9bce6401112f37463cd8d9f10df5c7d004 (diff) | |
| download | market-sim-b307e719416e39ed525a1c51d7df61ae55b35eec.zip market-sim-b307e719416e39ed525a1c51d7df61ae55b35eec.tar.gz market-sim-b307e719416e39ed525a1c51d7df61ae55b35eec.tar.bz2 market-sim-b307e719416e39ed525a1c51d7df61ae55b35eec.tar.xz | |
polish some stuff
Diffstat (limited to 'src')
| -rw-r--r-- | src/menu.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -26,6 +26,15 @@ void do_menu(struct player_t *player, const struct command_t *commands, uint len } } + /* look for a number and see if it corresponds to a valid command */ + ulong n = strtol(cmdbuf, NULL, 10); + if(0 < n && n <= len) + { + /* in range, execute */ + best_command = n - 1; + goto exec_cmd; + } + /* now look for a partial match */ for(uint i = 0; i < len; ++i) { @@ -66,6 +75,10 @@ exec_cmd: commands[best_command].handler(player); output("\n"); } + else + { + output("Unrecognized command: '%s'\n", cmdbuf); + } free(cmdbuf); } |