X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fcommand_db.c;h=ba33e912dc9df39d8b11fe26626e949f2194354c;hb=c1a7e6cdb13cd7d883424afdf0fe08e9a10fbc28;hp=cbf6959e87322ff24a9a2d7e392160482450332f;hpb=58f0067336c9239750009b3f35d18031bec8f7b5;p=plomrogue diff --git a/src/command_db.c b/src/command_db.c index cbf6959..ba33e91 100644 --- a/src/command_db.c +++ b/src/command_db.c @@ -25,6 +25,41 @@ static void copy_tokenized_string(struct World * world, +extern uint8_t is_command_id_shortdsc(struct World * world, + uint8_t id, char * shortdsc) +{ + struct Command * cmd_ptr = world->cmd_db->cmds; + while (1) + { + if (id == cmd_ptr->id) + { + if (strcmp(shortdsc, cmd_ptr->dsc_short)) + { + return 0; + } + return 1; + } + cmd_ptr = &cmd_ptr[1]; + } +} + + + +extern uint8_t get_command_id(struct World * world, 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(struct World * world, char * dsc_short) { struct Command * cmd_ptr = world->cmd_db->cmds; @@ -60,6 +95,7 @@ extern void init_command_db(struct World * world) copy_tokenized_string(world, &cmds[i].dsc_long, "\n", err); i++; } + free(line); world->cmd_db = malloc(sizeof(struct CommandDB)); world->cmd_db->cmds = cmds; world->cmd_db->n = lines;