X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fclient%2Fcommand_db.c;h=e9478c60d284f805843a2a307033d25eae87a3cd;hb=8226d2e4e1aaaeb3b843b4eb9a178d71cc7896e1;hp=846f87ff579483e55ff355d6fb78213f0c57b644;hpb=21cac2d976f806643aee1471bcee7b38597ac121;p=plomrogue diff --git a/src/client/command_db.c b/src/client/command_db.c index 846f87f..e9478c6 100644 --- a/src/client/command_db.c +++ b/src/client/command_db.c @@ -4,7 +4,7 @@ #include /* uint8_t, uint32_t */ #include /* FILE */ #include /* free() */ -#include /* memcpy(), strlen(), strtok(), strcmp() */ +#include /* memcpy(), strlen(), strtok() */ #include "../common/readwrite.h" /* try_fopen(), try_fclose(), try_fgets() * textfile_sizes() */ @@ -14,36 +14,21 @@ -/* Build string pointed to by "ch_ptr" from next token delimited by "delim". */ -static void copy_tokenized_string(char ** ch_ptr, char * delim); +/* Point "ch_ptr" to next strtok() string in "line" delimited by "delim".*/ +static void copy_tokenized_string(char * line, char ** ch_ptr, char * delim); -static void copy_tokenized_string(char ** ch_ptr, char * delim) +static void copy_tokenized_string(char * line, char ** ch_ptr, char * delim) { char * f_name = "copy_tokenized_string()"; - char * dsc_ptr = strtok(NULL, delim); + char * dsc_ptr = strtok(line, delim); * ch_ptr = try_malloc(strlen(dsc_ptr) + 1, f_name); memcpy(* ch_ptr, dsc_ptr, strlen(dsc_ptr) + 1); } -extern uint8_t get_command_id(char * dsc_short) -{ - struct Command * cmd_ptr = world.cmd_db.cmds; - while (1) - { - if (0 == strcmp(dsc_short, cmd_ptr->dsc_short)) - { - return cmd_ptr->id; - } - cmd_ptr = &cmd_ptr[1]; - } -} - - - extern char * get_command_longdsc(char * dsc_short) { struct Command * cmd_ptr = world.cmd_db.cmds; @@ -75,9 +60,8 @@ extern void init_command_db() { break; } - world.cmd_db.cmds[i].id = atoi(strtok(line, " ")); - copy_tokenized_string(&world.cmd_db.cmds[i].dsc_short, " "); - copy_tokenized_string(&world.cmd_db.cmds[i].dsc_long, "\n"); + copy_tokenized_string(line, &world.cmd_db.cmds[i].dsc_short, " "); + copy_tokenized_string(NULL, &world.cmd_db.cmds[i].dsc_long, "\n"); i++; } try_fclose(file, f_name);