From d388a94f3620d569a91d65339f93f5c77ca9baa7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 24 May 2014 20:35:00 -0700 Subject: [PATCH] report missing itemtype before crashing --- src/kernel/save.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 570b3f16f..29c073154 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -400,24 +400,27 @@ void create_backup(char *file) void read_items(struct storage *store, item ** ilist) { - for (;;) { - char ibuf[32]; - const item_type *itype; - int i; - READ_STR(store, ibuf, sizeof(ibuf)); - if (!strcmp("end", ibuf)) - break; - itype = it_find(ibuf); - READ_INT(store, &i); - if (i <= 0) { - log_error("data contains an entry with %d %s\n", i, itype->rtype->_name[1]); - } else { - assert(itype != NULL); - if (itype != NULL) { - i_change(ilist, itype, i); - } + for (;;) { + char ibuf[32]; + const item_type *itype; + int i; + READ_STR(store, ibuf, sizeof(ibuf)); + if (!strcmp("end", ibuf)) { + break; + } + itype = it_find(ibuf); + READ_INT(store, &i); + if (i <= 0) { + log_error("data contains an entry with %d %s\n", i, itype->rtype->_name[1]); + } else { + if (itype != NULL) { + i_change(ilist, itype, i); + } else { + log_error("data contains unknown item type %s.\n", ibuf); + } + assert(itype != NULL); + } } - } } static void read_alliances(struct storage *store)