From 6ae3aa283195879bb38ee5656911274283c734da Mon Sep 17 00:00:00 2001 From: terminx Date: Mon, 3 Sep 2007 01:12:05 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@572 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/src/engine.c | 173 +++++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 67 deletions(-) diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c index 495954b1b..988d3dfb5 100644 --- a/polymer/build/src/engine.c +++ b/polymer/build/src/engine.c @@ -7301,9 +7301,9 @@ long saveboard(char *filename, long *daposx, long *daposy, long *daposz, { short fil, i, j, numsprites, ts; long tl; - sectortype tsect[MAXSECTORS]; - walltype twall[MAXWALLS]; - spritetype tspri[MAXSPRITES]; + sectortype *tsect = NULL; + walltype *twall = NULL; + spritetype *tspri = NULL; sectortype *sec; walltype *wal; spritetype *spri; @@ -7335,75 +7335,114 @@ long saveboard(char *filename, long *daposx, long *daposy, long *daposz, ts = B_LITTLE16(*dacursectnum); Bwrite(fil,&ts,2); ts = B_LITTLE16(numsectors); Bwrite(fil,&ts,2); - for (i=0; iwallptr = B_LITTLE16(sec->wallptr); - sec->wallnum = B_LITTLE16(sec->wallnum); - sec->ceilingz = B_LITTLE32(sec->ceilingz); - sec->floorz = B_LITTLE32(sec->floorz); - sec->ceilingstat = B_LITTLE16(sec->ceilingstat); - sec->floorstat = B_LITTLE16(sec->floorstat); - sec->ceilingpicnum = B_LITTLE16(sec->ceilingpicnum); - sec->ceilingheinum = B_LITTLE16(sec->ceilingheinum); - sec->floorpicnum = B_LITTLE16(sec->floorpicnum); - sec->floorheinum = B_LITTLE16(sec->floorheinum); - sec->lotag = B_LITTLE16(sec->lotag); - sec->hitag = B_LITTLE16(sec->hitag); - sec->extra = B_LITTLE16(sec->extra); - } - Bwrite(fil,&tsect[0],sizeof(sectortype) * numsectors); - - ts = B_LITTLE16(numwalls); Bwrite(fil,&ts,2); - for (i=0; ix = B_LITTLE32(wal->x); - wal->y = B_LITTLE32(wal->y); - wal->point2 = B_LITTLE16(wal->point2); - wal->nextwall = B_LITTLE16(wal->nextwall); - wal->nextsector = B_LITTLE16(wal->nextsector); - wal->cstat = B_LITTLE16(wal->cstat); - wal->picnum = B_LITTLE16(wal->picnum); - wal->overpicnum = B_LITTLE16(wal->overpicnum); - wal->lotag = B_LITTLE16(wal->lotag); - wal->hitag = B_LITTLE16(wal->hitag); - wal->extra = B_LITTLE16(wal->extra); - } - - Bwrite(fil,&twall[0],sizeof(walltype) * numwalls); - - ts = B_LITTLE16(numsprites); Bwrite(fil,&ts,2); - - for (j=0;jx = B_LITTLE32(spri->x); - spri->y = B_LITTLE32(spri->y); - spri->z = B_LITTLE32(spri->z); - spri->cstat = B_LITTLE16(spri->cstat); - spri->picnum = B_LITTLE16(spri->picnum); - spri->sectnum = B_LITTLE16(spri->sectnum); - spri->statnum = B_LITTLE16(spri->statnum); - spri->ang = B_LITTLE16(spri->ang); - spri->owner = B_LITTLE16(spri->owner); - spri->xvel = B_LITTLE16(spri->xvel); - spri->yvel = B_LITTLE16(spri->yvel); - spri->zvel = B_LITTLE16(spri->zvel); - spri->lotag = B_LITTLE16(spri->lotag); - spri->hitag = B_LITTLE16(spri->hitag); - spri->extra = B_LITTLE16(spri->extra); - } - } + tsect = (sectortype *)Bmalloc(sizeof(sectortype) * numsectors); - Bwrite(fil,&tspri[0],sizeof(spritetype) * numsprites); + if (tsect == NULL) + break; + + Bmemcpy(&tsect[0], §or[0], sizeof(sectortype) * numsectors); + + for (i=0; iwallptr = B_LITTLE16(sec->wallptr); + sec->wallnum = B_LITTLE16(sec->wallnum); + sec->ceilingz = B_LITTLE32(sec->ceilingz); + sec->floorz = B_LITTLE32(sec->floorz); + sec->ceilingstat = B_LITTLE16(sec->ceilingstat); + sec->floorstat = B_LITTLE16(sec->floorstat); + sec->ceilingpicnum = B_LITTLE16(sec->ceilingpicnum); + sec->ceilingheinum = B_LITTLE16(sec->ceilingheinum); + sec->floorpicnum = B_LITTLE16(sec->floorpicnum); + sec->floorheinum = B_LITTLE16(sec->floorheinum); + sec->lotag = B_LITTLE16(sec->lotag); + sec->hitag = B_LITTLE16(sec->hitag); + sec->extra = B_LITTLE16(sec->extra); + } + + Bwrite(fil,&tsect[0],sizeof(sectortype) * numsectors); + Bfree(tsect); + + ts = B_LITTLE16(numwalls); Bwrite(fil,&ts,2); + + twall = (walltype *)Bmalloc(sizeof(walltype) * numwalls); + + if (twall == NULL) + break; + + Bmemcpy(&twall[0], &wall[0], sizeof(walltype) * numwalls); + + for (i=0; ix = B_LITTLE32(wal->x); + wal->y = B_LITTLE32(wal->y); + wal->point2 = B_LITTLE16(wal->point2); + wal->nextwall = B_LITTLE16(wal->nextwall); + wal->nextsector = B_LITTLE16(wal->nextsector); + wal->cstat = B_LITTLE16(wal->cstat); + wal->picnum = B_LITTLE16(wal->picnum); + wal->overpicnum = B_LITTLE16(wal->overpicnum); + wal->lotag = B_LITTLE16(wal->lotag); + wal->hitag = B_LITTLE16(wal->hitag); + wal->extra = B_LITTLE16(wal->extra); + } + + Bwrite(fil,&twall[0],sizeof(walltype) * numwalls); + Bfree(twall); + + ts = B_LITTLE16(numsprites); Bwrite(fil,&ts,2); + + tspri = (spritetype *)Bmalloc(sizeof(spritetype) * numsprites); + + if (tspri == NULL) + break; + + Bmemcpy(&tspri[0], &sprite[0], sizeof(spritetype) * numsprites); + + for (j=0;jx = B_LITTLE32(spri->x); + spri->y = B_LITTLE32(spri->y); + spri->z = B_LITTLE32(spri->z); + spri->cstat = B_LITTLE16(spri->cstat); + spri->picnum = B_LITTLE16(spri->picnum); + spri->sectnum = B_LITTLE16(spri->sectnum); + spri->statnum = B_LITTLE16(spri->statnum); + spri->ang = B_LITTLE16(spri->ang); + spri->owner = B_LITTLE16(spri->owner); + spri->xvel = B_LITTLE16(spri->xvel); + spri->yvel = B_LITTLE16(spri->yvel); + spri->zvel = B_LITTLE16(spri->zvel); + spri->lotag = B_LITTLE16(spri->lotag); + spri->hitag = B_LITTLE16(spri->hitag); + spri->extra = B_LITTLE16(spri->extra); + } + } + + Bwrite(fil,&tspri[0],sizeof(spritetype) * numsprites); + Bfree(tspri); + + Bclose(fil); + return(0); + } Bclose(fil); - return(0); + + if (tsect != NULL) + Bfree(tsect); + + if (twall != NULL) + Bfree(twall); + + if (tspri != NULL) + Bfree(tspri); + + return(-1); }