From e04184b673654b776de2965d7a5fe1dbd19e4ee9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 13 Dec 2007 16:19:49 +0000 Subject: [PATCH] asserts --- src/common/gamecode/creport.c | 5 ++++- src/common/kernel/curse.c | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index f2665e5a5..9388456aa 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -431,11 +431,12 @@ cr_regions(variant var, char * buffer, const void * userdata) { faction * f = (faction*)userdata; const arg_regions * rdata = (const arg_regions *)var.v; - char * wp = buffer; if (rdata!=NULL && rdata->nregions>0) { region * r = rdata->regions[0]; int i, z = r->planep?r->planep->id:0; + char * wp = buffer; + wp += sprintf(wp, "\"%d %d %d", region_x(r, f), region_y(r, f), z); for (i=1;i!=rdata->nregions;++i) { r = rdata->regions[i]; @@ -443,6 +444,8 @@ cr_regions(variant var, char * buffer, const void * userdata) wp += sprintf(wp, ", %d %d %d", region_x(r, f), region_y(r, f), z); } strcat(wp, "\""); + } else { + strcpy(buffer, "\"\""); } return 0; } diff --git a/src/common/kernel/curse.c b/src/common/kernel/curse.c index d046da564..c1b3376e1 100644 --- a/src/common/kernel/curse.c +++ b/src/common/kernel/curse.c @@ -198,7 +198,7 @@ curse_read(attrib * a, FILE * f) /* beim Einlesen sind noch nicht alle units da, muss also * zwischengespeichert werden. */ - if (mageid.i == -1){ + if (mageid.i < 0) { c->magician = (unit *)NULL; } else { ur_add(mageid, (void**)&c->magician, resolve_unit); @@ -230,8 +230,9 @@ curse_write(const attrib * a, FILE * f) /* copied from c_clearflag */ flags = (c->flags & ~CURSE_ISNEW) | (c->type->flags & CURSE_ISNEW); - if (c->magician) { + if (c->magician && c->magician->number) { mage_no = c->magician->no; + assert(mage_no>0); } else { mage_no = -1; }