X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=src%2Fserver%2Fthings.c;h=9425f9cc3c315c5362733f93d13d9dbc984ce7a5;hb=02faa5bf7e77b6bbf111819164f9a15e3792215a;hp=e0aa674851fcb2527fe74e70df448c9eca52167c;hpb=1452d43c6d7c89219cda91362da53ac8e4acb887;p=plomrogue diff --git a/src/server/things.c b/src/server/things.c index e0aa674..9425f9c 100644 --- a/src/server/things.c +++ b/src/server/things.c @@ -5,9 +5,10 @@ #include /* uint8_t, uint16_t, UINT8_MAX, UINT16_MAX */ #include /* free() */ #include /* memset(), strlen() */ -#include "../common/rexit.h" /* exit_err() */ +#include "../common/rexit.h" /* exit_err(), exit_trouble() */ #include "../common/try_malloc.h" /* try_malloc() */ #include "../common/yx_uint8.h" /* yx_uint8 */ +#include "hardcoded_strings.h" /* s */ #include "map.h" /* is_passable() */ #include "rrand.h" /* rrand() */ #include "world.h" /* global world */ @@ -186,12 +187,15 @@ extern struct Thing * get_player() extern struct ThingType * get_thing_type(uint8_t id) { + char * f_name = "get_thing_type()"; struct ThingType * tt = world.thing_types; for (; NULL != tt && id != tt->id; tt = tt->next); char * err_intro = "Requested thing type of unused ID "; - char err[strlen(err_intro) + 3 + 1 + 1]; - sprintf(err, "%s%d.", err_intro, id); + uint16_t size = strlen(err_intro) + 3 + 1 + 1; + char * err = try_malloc(size, f_name); + exit_trouble(sprintf(err,"%s%d.",err_intro,id) < 0,f_name,s[S_FCN_SPRINTF]); exit_err(NULL == tt, err); + free(err); return tt; }