From: Christian Heller Date: Mon, 14 Apr 2014 04:09:12 +0000 (+0200) Subject: Server: Check against setting map object id of 0 in config file reading. X-Git-Tag: tce~767 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/conditions?a=commitdiff_plain;h=12239c92a51581d5bf621992f3f3ef9de6b76e59;p=plomrogue Server: Check against setting map object id of 0 in config file reading. --- diff --git a/README b/README index 90fd601..2770f53 100644 --- a/README +++ b/README @@ -111,12 +111,12 @@ NAME move EFFORT 5 A line of "ACTION" followed by a number starts an action definition block and -sets the action's id for internal use to 1. The number after "EFFORT" determines -how many turns this action takes for the actor performing it. The string after -"NAME" names the action. Furthermore, if it is one of "move", "pick_up", "drop" -or "use", it matches internal functions described by these strings to this -action. All other names (including "wait") currently are matched to a do-nothing -wait function. +sets the action's id (must be > 0) for internal use to 1. The number after +"EFFORT" determines how many turns this action takes for the actor performing +it. The string after "NAME" names the action. Furthermore, if it is one of +"move", "pick_up", "drop" or "use", it matches internal functions described by +these strings to this action. All other names (including "wait") currently are +matched to a do-nothing wait function. Here's a typical map object type definition block: diff --git a/src/server/configfile.c b/src/server/configfile.c index aad3b74..5376502 100644 --- a/src/server/configfile.c +++ b/src/server/configfile.c @@ -142,17 +142,21 @@ static void tokens_into_entries(char * token0, char * token1) if (token0) { parsetest_too_many_values(); - if (!( start_entry(token0, token1, str_act, &action_flags, - sizeof(struct MapObjAct),(struct EntryHead**) &moa, - (struct EntryHead *) world.map_obj_acts) - || start_entry(token0, token1, str_obj, &object_flags, - sizeof(struct MapObjDef),(struct EntryHead**) &mod, - (struct EntryHead *) world.map_obj_defs) - || start_map(token0, str_map, &map_flags) - || set_player_type(token0, str_player, token1) - || set_members(token0, token1, &object_flags, &action_flags, - &map_flags, (struct MapObjDef *)mod, - (struct MapObjAct *) moa))) + if (start_entry(token0, token1, str_act, &action_flags, + sizeof(struct MapObjAct), (struct EntryHead**) &moa, + (struct EntryHead *) world.map_obj_acts)) + { + err_line(0 == atoi(token1), "Value must not be 0."); + } + else if (!( start_entry(token0, token1, str_obj, &object_flags, + sizeof(struct MapObjDef), + (struct EntryHead**) &mod, + (struct EntryHead *) world.map_obj_defs) + || start_map(token0, str_map, &map_flags) + || set_player_type(token0, str_player, token1) + || set_members(token0, token1, &object_flags, &action_flags, + &map_flags, (struct MapObjDef *)mod, + (struct MapObjAct *) moa))) { parse_unknown_arg(); } @@ -237,7 +241,7 @@ static void test_corpse_ids() -static uint8_t set_map_members(char * token0, char * token1, uint8_t * map_flags) +static uint8_t set_map_members(char * token0, char * token1,uint8_t * map_flags) { if ( parse_val(token0, token1, "HEIGHT", map_flags, HEIGHT_SET, 'i', (char *) &world.map.size.y)