From 0c9153396c3507addf22a67d52270f7979666e1e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 16 Jul 2020 19:41:45 +0200 Subject: [PATCH] Bug 2683: fix buildings with size 0 Fixing the symptoms, not the cause, becasue I don't know how this happened. --- src/kernel/save.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/kernel/save.c b/src/kernel/save.c index b401256ae..c720441c0 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1251,6 +1251,7 @@ void write_building(gamedata *data, const building *b) write_building_reference(b, store); WRITE_STR(store, b->name); WRITE_STR(store, b->display ? b->display : ""); + assert(b->size > 0); WRITE_INT(store, b->size); WRITE_TOK(store, b->type->_name); write_attribs(store, b->attribs, b); @@ -1276,6 +1277,10 @@ struct building *read_building(gamedata *data) { } b->display = str_strdup(name); READ_INT(store, &b->size); + if (b->size < 1) { + log_warning("trim building %s had size %d", itoa36(b->no), b->size); + b->size = 1; + } READ_STR(store, name, sizeof(name)); b->type = bt_find(name); if (!b->type) {