From: Christian Heller Date: Thu, 24 Jul 2014 01:16:35 +0000 (+0200) Subject: Server: Fix buggy initialization of new thing types. X-Git-Tag: tce~695 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%22https:/validator.w3.org/index.html?a=commitdiff_plain;h=f2b4faf81054dacf93af35b5ff1fd14d3c966a55;p=plomrogue Server: Fix buggy initialization of new thing types. --- diff --git a/src/server/god_commands.c b/src/server/god_commands.c index eee8b11..02c091a 100644 --- a/src/server/god_commands.c +++ b/src/server/god_commands.c @@ -157,7 +157,7 @@ static uint8_t parse_thingaction_manipulation(char * tok0, char * tok1) } } } - else if (parse_val(tok0, tok1, s[S_CMD_THINGACTION], '8', (char *) &id)) + else if (parse_val(tok0, tok1, s[S_CMD_THINGACTION], 'i', (char *) &id)) { ta = get_thing_action(id); if (!ta) @@ -286,7 +286,7 @@ static uint8_t parse_thing_manipulation(char * tok0, char * tok1) return 1; } uint8_t id; - if ( parse_thing_type(tok0, tok1, t) + if ( parse_thing_type(tok0, tok1, t) || parse_thing_command(tok0, tok1, t) || parse_val(tok0,tok1, s[S_CMD_T_ARGUMENT], '8', (char *)&t->arg) || parse_val(tok0,tok1, s[S_CMD_T_PROGRESS], '8', (char *)&t->progress) diff --git a/src/server/things.c b/src/server/things.c index 4097f61..4a5a490 100644 --- a/src/server/things.c +++ b/src/server/things.c @@ -31,8 +31,8 @@ struct NextAndId /* To linked list of NextAndId structs (or rather structs whose start region is * compatible to it) starting at "start", add newly allocated element of * "n_size" and an ID that is either "id" or, if "id" is <= UINT8_MAX and >= - * "id_start", get lowest ID for new thing ("struct_id"==0), thing type - * ("struct_id"==1) or thing action ("struct_id"==2). + * "id_start", get lowest ID >= "start_id" and <= UINT8_MAX for new thing + * ("struct_id"=0), thing type ("struct_id"=1) or thing action ("struct_id"=2). */ static struct NextAndId * add_to_struct_list(size_t n_size, uint8_t start_id, int16_t id, uint8_t struct_id, @@ -99,6 +99,7 @@ extern struct ThingType * add_thing_type(int16_t id) &world.thing_types); set_cleanup_flag(CLEANUP_THING_TYPES); tt->name = strdup("(none)"); + tt->corpse_id = tt->id; return tt; } diff --git a/src/server/things.h b/src/server/things.h index 599d877..d5ef508 100644 --- a/src/server/things.h +++ b/src/server/things.h @@ -55,14 +55,14 @@ struct ThingAction */ extern struct ThingAction * add_thing_action(uint8_t id); -/* Add thing type of "id", with .corpse_id defaulting to "id" to - * world.thing_types, .name to "(none)" and the remaining values to 0. If "id" - * is not >= 0 and <= UINT8_MAX, use lowest unused id. Return thing type. +/* Add thing type of "id" to world.thing_types, with .corpse_id defaulting to + * the new thing type's .id, .name to "(none)" and the remaining values to 0. If + * "id" is not >= 0 and <= UINT8_MAX, use lowest unused id. Return thing type. */ extern struct ThingType * add_thing_type(int16_t id); -/* Add thing of "id" and "type" on position of "y"/x" to world.things.If "id" is - * not >= 0 and <= UINT8_MAX, use lowest unused id. Return thing. +/* Add thing of "id" and "type" on position of "y"/x" to world.things. If "id" + * is not >= 0 and <= UINT8_MAX, use lowest unused id. Return thing. */ extern struct Thing * add_thing(int16_t id, uint8_t type, uint8_t y, uint8_t x);