From 48d15c23c65ed184a5223ab335b7641f8cbda526 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 24 Feb 2011 20:40:27 +0000 Subject: [PATCH] Mapster32 cleanup. The biggest visible change should be the more robust editing near the limits (still not perfect though). git-svn-id: https://svn.eduke32.com/eduke32@1801 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 5 +- polymer/eduke32/build/include/editor.h | 12 +- polymer/eduke32/build/src/build.c | 2094 ++++++++++++------------ polymer/eduke32/build/src/engine.c | 15 +- polymer/eduke32/source/astub.c | 91 +- polymer/eduke32/source/mapster32.h | 1 - 6 files changed, 1132 insertions(+), 1086 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index d5737579e..16738b481 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -29,6 +29,9 @@ extern "C" { #define MAXWALLSB ((MAXWALLS>>2)+(MAXWALLS>>3)) #define MAXSPRITES MAXSPRITESV8 +// additional space beyond wall, in walltypes: +#define M32_FIXME_WALLS 1024 + #define MAXTILES 15360 #define MAXVOXELS 4096 #define MAXSTATUS 1024 @@ -465,7 +468,7 @@ void setview(int32_t x1, int32_t y1, int32_t x2, int32_t y2); void setaspect(int32_t daxrange, int32_t daaspect); void flushperms(void); -void plotlines2d(int32_t *xx, int32_t *yy, int32_t numpoints, char col) ATTRIBUTE((nonnull(1,2))); +void plotlines2d(const int32_t *xx, const int32_t *yy, int32_t numpoints, char col) ATTRIBUTE((nonnull(1,2))); void plotpixel(int32_t x, int32_t y, char col); char getpixel(int32_t x, int32_t y); diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index 58615d4b7..3079295bb 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -40,7 +40,9 @@ extern int32_t qsetmode; extern int16_t searchsector, searchwall, searchstat; extern int16_t searchbottomwall; extern int32_t zmode, kensplayerheight; -extern int16_t defaultspritecstat; + +#define DEFAULT_SPRITE_CSTAT 0 +//extern int16_t defaultspritecstat; extern int32_t temppicnum, tempcstat, templotag, temphitag, tempextra; extern uint32_t temppal, tempvis, tempxrepeat, tempyrepeat; @@ -149,11 +151,15 @@ extern int32_t lastpm16time; extern char lastpm16buf[156]; +void DoSpriteOrnament(int32_t i); + void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y); int32_t getpointhighlight(int32_t xplc, int32_t yplc, int32_t point); void update_highlight(); void update_highlightsector(); +extern uint8_t hlsectorbitmap[MAXSECTORS>>3]; + #ifdef _WIN32 #define DEFAULT_GAME_EXEC "eduke32.exe" #define DEFAULT_GAME_LOCAL_EXEC "eduke32.exe" @@ -222,4 +228,8 @@ extern int32_t scripthistend; Itervar < endwall; \ Itervar++ +#define BTAG_MAX 65535 +#define BZ_MAX 8388608 + + #endif diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index df646745d..b56c06bfe 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -99,7 +99,7 @@ extern int32_t cachesize, artsize; static int16_t oldmousebstatus = 0; char game_executable[BMAX_PATH] = DEFAULT_GAME_LOCAL_EXEC; int32_t zlock = 0x7fffffff, zmode = 0, whitecol, kensplayerheight = 32; -int16_t defaultspritecstat = 0; +//int16_t defaultspritecstat = 0; int16_t localartfreq[MAXTILES]; int16_t localartlookup[MAXTILES], localartlookupnum; @@ -220,7 +220,7 @@ static int32_t deletesector(int16_t sucksect); void fixrepeats(int16_t i); static int16_t loopinside(int32_t x, int32_t y, int16_t startwall); int32_t fillsector(int16_t sectnum, char fillcolor); -int16_t whitelinescan(int16_t dalinehighlight); +static int16_t whitelinescan(int16_t dalinehighlight); void printcoords16(int32_t posxe, int32_t posye, int16_t ange); static void copysector(int16_t soursector, int16_t destsector, int16_t deststartwall, char copystat, const int16_t *oldtonewsect); int32_t drawtilescreen(int32_t pictopleft, int32_t picbox); @@ -238,6 +238,9 @@ int32_t gettile(int32_t tilenum); static int32_t menuselect(void); static int32_t menuselect_auto(int32_t); //PK +static int32_t insert_sprite_common(int32_t sucksect, int32_t dax, int32_t day); +static void correct_ornamented_sprite(int32_t i, int32_t hitw); + static int32_t getfilenames(const char *path, const char *kind); static void clearfilenames(void); void loadmhk(int32_t domessage); @@ -716,7 +719,6 @@ void editinput(void) int32_t mousz, bstatus; int32_t i, j, k, /*cnt,*/ tempint=0, doubvel/*, changedir, wallfind[2], daz[2]*/; int32_t /*dashade[2],*/ goalz, xvect, yvect,/*PK*/ zvect, hiz, loz; - hitdata_t hitinfo; int32_t dax, day, hihit, lohit; // 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 @@ -1053,9 +1055,11 @@ void editinput(void) if (keystatus[0x1f]) //S (insert sprite) (3D) { + hitdata_t hitinfo; + dax = 16384; - day = divscale14(searchx-(xdim>>1),xdim>>1); - rotatepoint(0,0,dax,day,ang,&dax,&day); + day = divscale14(searchx-(xdim>>1), xdim>>1); + rotatepoint(0,0, dax,day, ang, &dax,&day); hitscan((const vec3_t *)&pos,cursectnum, //Start position dax,day,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang @@ -1068,108 +1072,83 @@ void editinput(void) if (gridlock && grid > 0) { if (searchstat == 0 || searchstat == 4) - hitinfo.pos.z = (hitinfo.pos.z&0xfffffc00); + hitinfo.pos.z &= 0xfffffc00; else locktogrid(&dax, &day); } - i = insertsprite(hitinfo.hitsect,0); - sprite[i].x = dax, sprite[i].y = day; - sprite[i].cstat = defaultspritecstat; - sprite[i].shade = 0; - sprite[i].pal = 0; - sprite[i].xrepeat = 64, sprite[i].yrepeat = 64; - sprite[i].xoffset = 0, sprite[i].yoffset = 0; - sprite[i].ang = 1536; - sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0; - sprite[i].owner = -1; - sprite[i].clipdist = 32; - sprite[i].lotag = 0; - sprite[i].hitag = 0; - sprite[i].extra = -1; + i = insert_sprite_common(hitinfo.hitsect, dax, day); - Bmemset(localartfreq, 0, sizeof(localartfreq)); - for (k=0; k localartfreq[j]) - j = k; - - if (localartfreq[j] > 0) - sprite[i].picnum = j; + if (i < 0) + message("Couldn't insert sprite."); else - sprite[i].picnum = 0; - - if (somethingintab == 3) { - sprite[i].picnum = temppicnum; - if ((tilesizx[temppicnum] <= 0) || (tilesizy[temppicnum] <= 0)) + int32_t cz, fz; + + if (somethingintab == 3) { - j = 0; - for (k=0; k 0) && (tilesizy[k] > 0)) - { - j = k; - break; - } - sprite[i].picnum = j; + sprite[i].picnum = temppicnum; + if (tilesizx[temppicnum] <= 0 || tilesizy[temppicnum] <= 0) + { + j = 0; + for (k=0; k 0 && tilesizy[k] > 0) + { + j = k; + break; + } + sprite[i].picnum = j; + } + + sprite[i].shade = tempshade; + sprite[i].pal = temppal; + sprite[i].xrepeat = max(tempxrepeat, 1); + sprite[i].yrepeat = max(tempyrepeat, 1); + sprite[i].cstat = tempcstat; } - sprite[i].shade = tempshade; - sprite[i].pal = temppal; - sprite[i].xrepeat = max(tempxrepeat, 1); - sprite[i].yrepeat = max(tempyrepeat, 1); - sprite[i].cstat = tempcstat; - } + cz = getceilzofslope(hitinfo.hitsect, hitinfo.pos.x, hitinfo.pos.y); + fz = getflorzofslope(hitinfo.hitsect, hitinfo.pos.x, hitinfo.pos.y); - j = ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if ((sprite[i].cstat&128) == 0) - sprite[i].z = min(max(hitinfo.pos.z, - getceilzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)+(j<<1)), - getflorzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)); - else - sprite[i].z = min(max(hitinfo.pos.z, - getceilzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)+j), - getflorzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)-j); + j = (tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1; + if ((sprite[i].cstat&128) == 0) + bclamp(&sprite[i].z, cz+(j<<1), fz); + else + bclamp(&sprite[i].z, cz+j, fz-j); - if (searchstat == 0 || searchstat == 4) - { - sprite[i].cstat = (sprite[i].cstat&~48)|(16+64); - if (hitinfo.hitwall >= 0) - sprite[i].ang = (getangle(POINT2(hitinfo.hitwall).x-wall[hitinfo.hitwall].x, - POINT2(hitinfo.hitwall).y-wall[hitinfo.hitwall].y)+512)&2047; - //Make sure sprite's in right sector - if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) + if (searchstat == 0 || searchstat == 4) { - j = wall[hitinfo.hitwall].point2; - sprite[i].x -= ksgn(wall[j].y-wall[hitinfo.hitwall].y); - sprite[i].y += ksgn(wall[j].x-wall[hitinfo.hitwall].x); + sprite[i].cstat &= ~48; + sprite[i].cstat |= (16+64); + + correct_ornamented_sprite(i, hitinfo.hitwall); } + else + sprite[i].cstat |= (tilesizy[sprite[i].picnum]>=32); + + updatenumsprites(); + asksave = 1; + + VM_OnEvent(EVENT_INSERTSPRITE3D, i); } - else - sprite[i].cstat |= (tilesizy[sprite[i].picnum]>=32); - - updatenumsprites(); - asksave = 1; - - VM_OnEvent(EVENT_INSERTSPRITE3D, i); } keystatus[0x1f] = 0; } - /* if (keystatus[0xd3] > 0) - { - if (searchstat == 3) - { - deletesprite(searchwall); - updatenumsprites(); - asksave = 1; - } - keystatus[0xd3] = 0; - }*/ + +#if 0 + if (keystatus[0xd3] > 0) + { + if (searchstat == 3) + { + deletesprite(searchwall); + updatenumsprites(); + asksave = 1; + } + keystatus[0xd3] = 0; + } +#endif if (keystatus[0x3f]||keystatus[0x40]) //F5,F6 { @@ -1597,6 +1576,41 @@ static void duplicate_selected_sprites() } } +static void correct_ornamented_sprite(int32_t i, int32_t hitw) +{ + int32_t j; + + if (hitw >= 0) + sprite[i].ang = (getangle(POINT2(hitw).x-wall[hitw].x, + POINT2(hitw).y-wall[hitw].y)+512)&2047; + + //Make sure sprite's in right sector + if (inside(sprite[i].x, sprite[i].y, sprite[i].sectnum) == 0) + { + j = wall[hitw].point2; + sprite[i].x -= ksgn(wall[j].y-wall[hitw].y); + sprite[i].y += ksgn(wall[j].x-wall[hitw].x); + } +} + +void DoSpriteOrnament(int32_t i) +{ + hitdata_t hitinfo; + + hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum, + sintable[(sprite[i].ang+1536)&2047], + sintable[(sprite[i].ang+1024)&2047], + 0, + &hitinfo,CLIPMASK1); + + sprite[i].x = hitinfo.pos.x; + sprite[i].y = hitinfo.pos.y; + sprite[i].z = hitinfo.pos.z; + changespritesect(i, hitinfo.hitsect); + + correct_ornamented_sprite(i, hitinfo.hitsect); +} + void update_highlight() { int32_t i; @@ -1660,7 +1674,136 @@ void m32_setkeyfilter(int32_t on) after_handleevents_hook = 0; } -static int32_t ask_if_sure(const char *query, int32_t quit_is_yes); +// Get average point of sectors +static void get_sectors_center(const int16_t *sectors, int32_t numsecs, int32_t *cx, int32_t *cy) +{ + int32_t i, j, k=0, dax = 0, day = 0; + int32_t startwall, endwall; + + for (i=0; i 0) + { + dax /= k; + day /= k; + } + + *cx = dax; + *cy = day; +} + +static int32_t insert_sprite_common(int32_t sucksect, int32_t dax, int32_t day) +{ + int32_t i, j, k; + + i = insertsprite(sucksect,0); + if (i < 0) + return -1; + + sprite[i].x = dax, sprite[i].y = day; + sprite[i].cstat = DEFAULT_SPRITE_CSTAT; + sprite[i].shade = 0; + sprite[i].pal = 0; + sprite[i].xrepeat = 64, sprite[i].yrepeat = 64; + sprite[i].xoffset = 0, sprite[i].yoffset = 0; + sprite[i].ang = 1536; + sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0; + sprite[i].owner = -1; + sprite[i].clipdist = 32; + sprite[i].lotag = 0; + sprite[i].hitag = 0; + sprite[i].extra = -1; + + Bmemset(localartfreq, 0, sizeof(localartfreq)); + for (k=0; k localartfreq[j]) + j = k; + + if (localartfreq[j] > 0) + sprite[i].picnum = j; + else + sprite[i].picnum = 0; + + return i; +} + + +static void fade_screen() +{ + char blackcol=editorcolors[0], greycol=whitecol-25, *cp; + int32_t i; + + begindrawing(); + cp = (char *)frameplace; + for (i=0; i=0 ? &wall[src] : &nullwall; + + dstwal->cstat = srcwal->cstat; + dstwal->shade = srcwal->shade; + dstwal->yrepeat = srcwal->yrepeat; + fixrepeats(dst); + dstwal->picnum = srcwal->picnum; + dstwal->overpicnum = srcwal->overpicnum; + + dstwal->pal = srcwal->pal; + dstwal->xrepeat = srcwal->xrepeat; + dstwal->yrepeat = srcwal->yrepeat; + dstwal->xpanning = srcwal->xpanning; + dstwal->ypanning = srcwal->ypanning; + dstwal->lotag = 0; //srcwal->lotag; + dstwal->hitag = 0; //srcwal->hitag; + dstwal->extra = -1; //srcwal->extra; +} + +// helpers for often needed ops: +static void copyloop1(int16_t *danumwalls, int32_t *m) +{ + Bmemcpy(&wall[*danumwalls], &wall[*m], sizeof(walltype)); + wall[*danumwalls].point2 = *danumwalls+1; + (*danumwalls)++; + *m = wall[*m].point2; +} + +static void updatesprite1(int16_t j) +{ + int32_t tempint; + + setsprite(j, (vec3_t *)&sprite[j]); + + tempint = (tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2; + if (sprite[j].sectnum>=0) + { + sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); + sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)); + } +} + +static int32_t ask_if_sure(const char *query, uint32_t flags); void overheadeditor(void) { @@ -1670,8 +1813,8 @@ void overheadeditor(void) int32_t startwall=0, endwall, dax, day, x1, y1, x2, y2, x3, y3, x4, y4; int32_t highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect; int16_t pag, suckwall=0, sucksect, split=0, bad, goodtogo; - int16_t splitsect=0, danumwalls, secondstartwall, joinsector[2], joinsectnum; - int16_t splitstartwall=0, splitendwall, loopnum; + int16_t splitsect=0, joinsector[2]; + int16_t splitstartwall=0, loopnum; int32_t mousx, mousy, bstatus; int32_t centerx, centery, circlerad; int16_t circlepoints, circleang1, circleang2, circleangdir; @@ -1679,7 +1822,6 @@ void overheadeditor(void) int16_t cursectorhighlight, sectorhighlightstat; walltype *wal; int32_t prefixarg = 0; - hitdata_t hitinfo; int32_t resetsynctics = 0, lasttick=getticks(), waitdelay=totalclock, lastdraw=getticks(); int32_t tsign; @@ -1702,16 +1844,18 @@ void overheadeditor(void) CLEARLINES2D(0, ydim, 0); ydim16 = ydim; -// drawline16(0,ydim-STATUS2DSIZ2,xdim-1,ydim-STATUS2DSIZ2,editorcolors[1]); - /* drawline16(0,ydim-1,xdim-1,ydim-1,1); - drawline16(0,ydim-STATUS2DSIZ,0,ydim-1,1); - drawline16(xdim-1,ydim-STATUS2DSIZ,xdim-1,ydim-1,1); - drawline16(0,ydim-STATUS2DSIZ+24,xdim-1,ydim-STATUS2DSIZ+24,1); - drawline16(192-24,ydim-STATUS2DSIZ,192-24,ydim-STATUS2DSIZ+24,1); */ +#if 0 + drawline16(0,ydim-STATUS2DSIZ2,xdim-1,ydim-STATUS2DSIZ2,editorcolors[1]); + drawline16(0,ydim-1,xdim-1,ydim-1,1); + drawline16(0,ydim-STATUS2DSIZ,0,ydim-1,1); + drawline16(xdim-1,ydim-STATUS2DSIZ,xdim-1,ydim-1,1); + drawline16(0,ydim-STATUS2DSIZ+24,xdim-1,ydim-STATUS2DSIZ+24,1); + drawline16(192-24,ydim-STATUS2DSIZ,192-24,ydim-STATUS2DSIZ+24,1); - // printmessage16("Version: "VERSION); -// drawline16(0,ydim-1-20,xdim-1,ydim-1-20,1); -// drawline16(256,ydim-1-20,256,ydim-1,1); + printmessage16("Version: "VERSION); + drawline16(0,ydim-1-20,xdim-1,ydim-1-20,1); + drawline16(256,ydim-1-20,256,ydim-1,1); +#endif ydim16 = ydim-STATUS2DSIZ2; enddrawing(); //}}} @@ -1854,7 +1998,8 @@ void overheadeditor(void) tempint = numwalls; numwalls = newnumwalls; - if (numwalls < 0) numwalls = tempint; + if (numwalls < 0) + numwalls = tempint; if ((getticks() - lastdraw) >= 5 || (vel|angvel|svel) || DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN) || mousx || mousy || bstatus || keystatus[0x10] || keystatus[0x11] @@ -1868,7 +2013,7 @@ void overheadeditor(void) if (graphicsmode && !m32_sideview) { - Bmemset(show2dsector, 255, sizeof(show2dsector)); + Bmemset(show2dsector, 0xff, sizeof(show2dsector)); setview(0, 0, xdim-1, ydim16-1); if (graphicsmode == 2) @@ -1916,39 +2061,29 @@ void overheadeditor(void) { for (i=0; i 0) - { - dax /= sector[i].wallnum; - day /= sector[i].wallnum; - } + get_sectors_center(&secshort, 1, &dax, &day); - if (m32_sideview) - vdisp = getscreenvdisp(getflorzofslope(i,dax,day)-pos.z, zoom); - screencoords(&dax,&day, dax-pos.x,day-pos.y, zoom); - if (m32_sideview) - day += vdisp; + if (m32_sideview) + vdisp = getscreenvdisp(getflorzofslope(i,dax,day)-pos.z, zoom); + screencoords(&dax,&day, dax-pos.x,day-pos.y, zoom); + if (m32_sideview) + day += vdisp; - drawsmalllabel(dabuffer, editorcolors[0], editorcolors[7], dax, day); - } + drawsmalllabel(dabuffer, editorcolors[0], editorcolors[7], dax, day); } } - x3 = divscale14(-halfxdim16,zoom)+pos.x; - y3 = divscale14(-(midydim16-4),zoom)+pos.y; - x4 = divscale14(halfxdim16,zoom)+pos.x; - y4 = divscale14(ydim16-(midydim16-4),zoom)+pos.y; + x3 = pos.x + divscale14(-halfxdim16,zoom); + y3 = pos.y + divscale14(-(midydim16-4),zoom); + x4 = pos.x + divscale14(halfxdim16,zoom); + y4 = pos.y + divscale14(ydim16-(midydim16-4),zoom); if (newnumwalls >= 0) { @@ -1961,7 +2096,8 @@ void overheadeditor(void) i = newnumwalls-1; for (wal=&wall[i]; i>=0; i--,wal--) { - if (zoom < 768 && !(wal->cstat & (1<<14))) continue; + if (zoom < 768 && !(wal->cstat & (1<<14))) + continue; //Get average point of wall dax = (wal->x+wall[wal->point2].x)>>1; @@ -2020,7 +2156,6 @@ void overheadeditor(void) } j--; } - i++; } } @@ -2128,36 +2263,16 @@ void overheadeditor(void) if (keystatus[0x2d] || keystatus[0x15]) // X or Y (2D) { int32_t about_x=keystatus[0x2d]; + int32_t doMirror = eitherALT; // mirror walls and wall/floor sprites if (highlightsectorcnt > 0) { keystatus[0x2d] = keystatus[0x15] = 0; - k = 0; - dax = 0; - day = 0; - - for (i=0; i 0) - { - dax /= k; - day /= k; - } - - k = eitherALT; //ALT-X/Y mirror sector in x/y + get_sectors_center(highlightsector, highlightsectorcnt, &dax, &day); if (gridlock && grid > 0) locktogrid(&dax, &day); - // dax = ((dax+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); - // day = ((day+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); for (i=0; i>1; for (w=1; w<=numtoswap; w++) { - Bmemcpy(&tempwall,&wall[startofloop+w],sizeof(walltype)); - Bmemcpy(&wall[startofloop+w],&wall[endofloop-w+1],sizeof(walltype)); - Bmemcpy(&wall[endofloop-w+1],&tempwall,sizeof(walltype)); + Bmemcpy(&tempwall, &wall[startofloop+w], sizeof(walltype)); + Bmemcpy(&wall[startofloop+w], &wall[endofloop-w+1], sizeof(walltype)); + Bmemcpy(&wall[endofloop-w+1], &tempwall, sizeof(walltype)); } //make point2 point to next wall in loop @@ -2250,7 +2363,7 @@ void overheadeditor(void) sprite[j].ang = (2048-sprite[j].ang)&2047; //flip ang about 512 } - if (k && (sprite[j].cstat & 0x30)) + if (doMirror && (sprite[j].cstat & 0x30)) sprite[j].cstat ^= 4; // mirror sprites about dax/day (don't mirror monsters) j = nextspritesect[j]; @@ -2304,9 +2417,10 @@ void overheadeditor(void) linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight); if (linehighlight >= 0) { - setfirstwall(sectorofwall(linehighlight),linehighlight); + int32_t secti = sectorofwall(linehighlight); + setfirstwall(secti, linehighlight); asksave = 1; - printmessage16("This wall now sector's first wall (sector[].wallptr)"); + printmessage16("This wall now sector %d's first wall (sector[].wallptr)", secti); } } } @@ -2317,28 +2431,7 @@ void overheadeditor(void) if ((pointhighlight&0xc000) == 16384) { asksave = 1; - i = (pointhighlight&16383); - - hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum, - sintable[(sprite[i].ang+2560+1024)&2047], - sintable[(sprite[i].ang+1024)&2047], - 0,&hitinfo,CLIPMASK1); - - sprite[i].x = hitinfo.pos.x; - sprite[i].y = hitinfo.pos.y; - sprite[i].z = hitinfo.pos.z; - changespritesect(i,hitinfo.hitsect); - if (hitinfo.hitwall >= 0) - sprite[i].ang = (getangle(POINT2(hitinfo.hitwall).x - wall[hitinfo.hitwall].x, - POINT2(hitinfo.hitwall).y - wall[hitinfo.hitwall].y)+512)&2047; - - //Make sure sprite's in right sector - if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) - { - j = wall[hitinfo.hitwall].point2; - sprite[i].x -= ksgn(wall[j].y-wall[hitinfo.hitwall].y); - sprite[i].y += ksgn(wall[j].x-wall[hitinfo.hitwall].x); - } + DoSpriteOrnament(pointhighlight&16383); } } @@ -2353,27 +2446,11 @@ void overheadeditor(void) { if (highlightsectorcnt > 0) { - k = 0; - dax = 0; - day = 0; - for (i=0; i 0) - { - dax /= k; - day /= k; - } + int32_t smoothRotation = !eitherSHIFT; - k = eitherSHIFT; + get_sectors_center(highlightsector, highlightsectorcnt, &dax, &day); - if (k == 0) + if (smoothRotation) { if (gridlock && grid > 0) locktogrid(&dax, &day); @@ -2383,7 +2460,7 @@ void overheadeditor(void) { for (WALLS_OF_SECTOR(highlightsector[i], j)) { - if (k == 0) + if (smoothRotation) { x3 = wall[j].x; y3 = wall[j].y; @@ -2394,27 +2471,27 @@ void overheadeditor(void) rotatepoint(dax,day, wall[j].x,wall[j].y, tsign&2047, &wall[j].x,&wall[j].y); } - j = headspritesect[highlightsector[i]]; - while (j != -1) + for (j=headspritesect[highlightsector[i]]; j != -1; j=nextspritesect[j]) { - if (k == 0) + if (smoothRotation) { x3 = sprite[j].x; y3 = sprite[j].y; sprite[j].x = dax + tsign*(day-y3); sprite[j].y = day + tsign*(x3-dax); - sprite[j].ang = ((sprite[j].ang+tsign*512)&2047); + sprite[j].ang = (sprite[j].ang+tsign*512)&2047; } else { - rotatepoint(dax,day, sprite[j].x,sprite[j].y, tsign&2048, &sprite[j].x,&sprite[j].y); - sprite[j].ang = ((sprite[j].ang+tsign)&2047); + rotatepoint(dax,day, sprite[j].x,sprite[j].y, tsign&2047, &sprite[j].x,&sprite[j].y); + sprite[j].ang = (sprite[j].ang+tsign)&2047; } - - j = nextspritesect[j]; } } - if (k == 0) keystatus[0x33] = keystatus[0x34] = 0; + + if (smoothRotation) + keystatus[0x33] = keystatus[0x34] = 0; + mouseb &= ~(16|32); bstatus &= ~(16|32); asksave = 1; @@ -2425,10 +2502,10 @@ void overheadeditor(void) { i = pointhighlight-16384; if (eitherSHIFT) - sprite[i].ang = ((sprite[i].ang-tsign)&2047); + sprite[i].ang = (sprite[i].ang-tsign)&2047; else { - sprite[i].ang = ((sprite[i].ang-128*tsign)&2047); + sprite[i].ang = (sprite[i].ang-128*tsign)&2047; keystatus[0x33] = keystatus[0x34] = 0; } @@ -2551,14 +2628,14 @@ void overheadeditor(void) if (pointhighlight >= 16384) { i = pointhighlight-16384; - Bsprintf(buffer,"Sprite (%d) Hi-tag: ",i); - sprite[i].hitag = getnumber16(buffer,sprite[i].hitag,65536L,0); + Bsprintf(buffer, "Sprite (%d) Hi-tag: ", i); + sprite[i].hitag = getnumber16(buffer, sprite[i].hitag, BTAG_MAX, 0); } else if (linehighlight >= 0) { i = linehighlight; - Bsprintf(buffer,"Wall (%d) Hi-tag: ",i); - wall[i].hitag = getnumber16(buffer,wall[i].hitag,65536L,0); + Bsprintf(buffer, "Wall (%d) Hi-tag: ", i); + wall[i].hitag = getnumber16(buffer, wall[i].hitag, BTAG_MAX, 0); } } else @@ -2566,8 +2643,8 @@ void overheadeditor(void) for (i=0; i= 16384) { i = pointhighlight-16384; - Bsprintf(buffer,"Sprite (%d) Status list: ",i); - changespritestat(i,getnumber16(buffer,sprite[i].statnum,65536L,0)); + Bsprintf(buffer, "Sprite (%d) Status list: ", i); + changespritestat(i, getnumber16(buffer, sprite[i].statnum, 65535, 0)); // clearmidstatbar16(); // showspritedata((int16_t)i); } @@ -2609,14 +2686,14 @@ void overheadeditor(void) { if (highlightcnt == 0) { + int32_t xx[] = { highlightx1, highlightx1, searchx, searchx, highlightx1 }; + int32_t yy[] = { highlighty1, searchy, searchy, highlighty1, highlighty1 }; + highlightx2 = searchx; highlighty2 = searchy; - ydim16 = ydim-STATUS2DSIZ2; - drawline16(highlightx2,highlighty1, highlightx1,highlighty1, editorcolors[5]); - drawline16(highlightx2,highlighty2, highlightx1,highlighty2, editorcolors[5]); - drawline16(highlightx1,highlighty2, highlightx1,highlighty1, editorcolors[5]); - drawline16(highlightx2,highlighty2, highlightx2,highlighty1, editorcolors[5]); + + plotlines2d(xx, yy, 5, editorcolors[5]); } else { @@ -2709,14 +2786,14 @@ void overheadeditor(void) { if (highlightsectorcnt == 0) { - highlightx2 = searchx, highlighty2 = searchy; + int32_t xx[] = { highlightx1, highlightx1, searchx, searchx, highlightx1 }; + int32_t yy[] = { highlighty1, searchy, searchy, highlighty1, highlighty1 }; + + highlightx2 = searchx; + highlighty2 = searchy; ydim16 = ydim-STATUS2DSIZ2; - begindrawing(); //{{{ - drawline16(highlightx2,highlighty1, highlightx1,highlighty1, editorcolors[10]); - drawline16(highlightx2,highlighty2, highlightx1,highlighty2, editorcolors[10]); - drawline16(highlightx1,highlighty2, highlightx1,highlighty1, editorcolors[10]); - drawline16(highlightx2,highlighty2, highlightx2,highlighty1, editorcolors[10]); - enddrawing(); //}}} + + plotlines2d(xx, yy, 5, editorcolors[10]); } else { @@ -2729,7 +2806,7 @@ void overheadeditor(void) { if (wall[j].nextwall >= 0) checksectorpointer(wall[j].nextwall,wall[j].nextsector); - didmakered |= !!checksectorpointer((int16_t)j,highlightsector[i]); + didmakered |= !!checksectorpointer(j, highlightsector[i]); if (!didmakered) { @@ -2742,18 +2819,8 @@ void overheadeditor(void) if (!didmakered && !hadouterpoint && newnumwalls<0) { - char blackcol=editorcolors[0], greycol=whitecol-25, *cp; - // fade the screen to have the user's attention - begindrawing(); - cp = (char *)frameplace; - for (i=0; i= 0) checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j, i); + checksectorpointer(j, i); } } else @@ -2959,11 +3026,19 @@ outtathis: if (((bstatus&1) < (oldmousebstatus&1)) && highlightsectorcnt < 0) //after dragging { int32_t wallsdrawn = newnumwalls-numwalls, runi; + walltype *tmpwall; if (newnumwalls != -1) { + tmpwall = Bmalloc(wallsdrawn * sizeof(walltype)); + if (!tmpwall) + { + wallsdrawn = -1; + goto end_after_dragging; + } + newnumwalls = -1; - Bmemcpy(&wall[MAXWALLS-wallsdrawn],&wall[numwalls],sizeof(walltype) * wallsdrawn); + Bmemcpy(tmpwall, &wall[numwalls], wallsdrawn*sizeof(walltype)); } else wallsdrawn = -1; @@ -2979,35 +3054,12 @@ outtathis: if (j == 0) { for (i=0; i=0) - { - sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); - sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)); - } - } - } + updatesprite1(highlight[i]&16383); } else if ((pointhighlight&0xc000) == 16384) { - j = (pointhighlight&16383); - - setsprite(j,(vec3_t *)&sprite[j]); - - tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2); - - if (sprite[j].sectnum>=0) - { - sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); - sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)); - } + updatesprite1(pointhighlight&16383); } if ((pointhighlight&0xc000) == 0) @@ -3024,25 +3076,25 @@ outtathis: for (runi=0; runi<2; runi++) for (i=numwalls-1; i>=0; i--) //delete points { - if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y) - if (sector[sectorofwall((int16_t)i)].wallnum > 3) - if (sector[sectorofwall(wall[i].point2)].wallnum > 3) - { - int32_t b = (wall[i].nextwall == -1 || - (sector[sectorofwall(wall[i].nextwall)].wallnum > 3 && - sector[sectorofwall(NEXTWALL(i).point2)].wallnum > 3)); - if (runi==0 && !b) - { - printmessage16("Invalid operation, delete or join sector instead."); - goto SKIP; - } - else if (runi==1 && b) - { - deletepoint((int16_t)i); - printmessage16("Point deleted."); - asksave = 1; - } - } + if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y + && sector[sectorofwall(i)].wallnum > 3 + && sector[sectorofwall(wall[i].point2)].wallnum > 3) + { + int32_t b = (wall[i].nextwall == -1 || + (sector[sectorofwall(wall[i].nextwall)].wallnum > 3 && + sector[sectorofwall(NEXTWALL(i).point2)].wallnum > 3)); + if (runi==0 && !b) + { + printmessage16("Invalid operation, delete or join sector instead."); + goto end_after_dragging; + } + else if (runi==1 && b) + { + deletepoint(i); + printmessage16("Point deleted."); + asksave = 1; + } + } } for (i=0; i 0) //drag points { if (highlightsectorcnt > 0) @@ -3203,7 +3257,16 @@ SKIP: else { if ((pointhighlight&0xc000) == 0) + { + if (newnumwalls >= numwalls && + wall[pointhighlight].x==firstx && wall[pointhighlight].y==firsty) + { + printmessage16("Can't drag point where drawing started."); + goto end_point_dragging; + } + dragpoint(pointhighlight,dax,day); + } else if ((pointhighlight&0xc000) == 16384) { int32_t daspr=pointhighlight&16383, osec=sprite[daspr].sectnum; @@ -3236,11 +3299,12 @@ SKIP: } } } - else + else //if ((bstatus&1) == 0) { pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight); sectorhighlightstat = -1; } +end_point_dragging: if (bstatus&(2|4)) // change arrow position { @@ -3436,149 +3500,15 @@ SKIP: if (keystatus[0x24]) // J (join sectors) { - if (joinsector[0] >= 0) + keystatus[0x24] = 0; + + if (newnumwalls >= 0) { - joinsector[1] = -1; - - for (i=0; i= endwall && i != joinsector[0]) - { - _printmessage16("Join non-adjacent sectors? (Y/N)"); - showframe(1); - bflushchars(); ch = 0; - while (keystatus[1] == 0) - { - if (handleevents()) - quitevent = 0; - - idle(); - - ch = bgetchar(); - - if (ch == 'Y' || ch == 'y') - { - joinsector[1] = i; - break; - } - else if (ch == 'N' || ch == 'n' || ch == 13 || ch == ' ') - { - joinsector[1] = joinsector[0]; - break; - } - } - break; - } - else - { - joinsector[1] = i; - break; - } - } - } - - if ((joinsector[1] >= 0) && (joinsector[0] != joinsector[1])) - { - newnumwalls = numwalls; - - for (k=0; k<2; k++) - { - for (WALLS_OF_SECTOR(joinsector[k], j)) - { - if (wall[j].cstat == 255) - continue; - joinsectnum = k; - if (wall[j].nextsector == joinsector[1-joinsectnum]) - { - wall[j].cstat = 255; - continue; - } - - i = j; - m = newnumwalls; - do - { - Bmemcpy(&wall[newnumwalls],&wall[i],sizeof(walltype)); - wall[newnumwalls].point2 = newnumwalls+1; - newnumwalls++; - wall[i].cstat = 255; - - i = wall[i].point2; - if (wall[i].nextsector == joinsector[1-joinsectnum]) - { - i = NEXTWALL(i).point2; - joinsectnum = 1 - joinsectnum; - } - } - while ((wall[i].cstat != 255) && (wall[i].nextsector != joinsector[1-joinsectnum])); - wall[newnumwalls-1].point2 = m; - } - } - - if (newnumwalls > numwalls) - { - Bmemcpy(§or[numsectors],§or[joinsector[0]],sizeof(sectortype)); - sector[numsectors].wallptr = numwalls; - sector[numsectors].wallnum = newnumwalls-numwalls; - - //fix sprites - for (i=0; i<2; i++) - { - j = headspritesect[joinsector[i]]; - while (j != -1) - { - k = nextspritesect[j]; - changespritesect(j,numsectors); - j = k; - } - } - - numsectors++; - - for (i=numwalls; i= 0) - { - NEXTWALL(i).nextwall = i; - NEXTWALL(i).nextsector = numsectors-1; - } - } - - numwalls = newnumwalls; - newnumwalls = -1; - - for (k=0; k<2; k++) - { - for (WALLS_OF_SECTOR(joinsector[k], j)) - { - wall[j].nextwall = -1; - wall[j].nextsector = -1; - } - } - - deletesector((int16_t)joinsector[0]); - if (joinsector[0] < joinsector[1]) - joinsector[1]--; - deletesector((int16_t)joinsector[1]); - printmessage16("Sectors joined."); - } - } - else - printmessage16("No sectors joined."); - - joinsector[0] = -1; + printmessage16("Can't join sectors while editing."); + goto end_join_sectors; } - else + + if (joinsector[0] < 0) { joinsector[0] = -1; for (i=0; i= MAXWALLS + M32_FIXME_WALLS) + { + printmessage16("Joining sectors failed: not enough space beyond wall[]"); + newnumwalls = -1; + + for (i=0; i0 && ((wall[i].cstat & (1<<14))==0) + && (wall[i].nextsector != joinsector[1-joink])); + + wall[newnumwalls-1].point2 = m; + + if (loopnum==0) + { + printmessage16("internal error while joining sectors: infloop!"); + newnumwalls = -1; + } + } + } + + if (newnumwalls > numwalls) + { + Bmemcpy(§or[numsectors], §or[joinsector[0]], sizeof(sectortype)); + sector[numsectors].wallptr = numwalls; + sector[numsectors].wallnum = newnumwalls-numwalls; + + //fix sprites + for (i=0; i<2; i++) + { + j = headspritesect[joinsector[i]]; + while (j != -1) + { + k = nextspritesect[j]; + changespritesect(j, numsectors); + j = k; + } + } + + numsectors++; + + for (i=numwalls; i= 0) + { + NEXTWALL(i).nextwall = i; + NEXTWALL(i).nextsector = numsectors-1; + } + } + + numwalls = newnumwalls; + newnumwalls = -1; + + for (k=0; k<2; k++) + for (WALLS_OF_SECTOR(joinsector[k], j)) + wall[j].nextwall = wall[j].nextsector = -1; + + deletesector(joinsector[0]); + if (joinsector[0] < joinsector[1]) + joinsector[1]--; + deletesector(joinsector[1]); + + printmessage16("Sectors joined."); + } + + joinsector[0] = -1; } - keystatus[0x24] = 0; } +end_join_sectors: // PK for (i=0x02; i<=0x0b; i++) // keys '1' to '0' on the upper row @@ -3602,11 +3682,15 @@ SKIP: if (eitherALT && keystatus[0x1f]) //ALT-S { + keystatus[0x1f] = 0; + if (linehighlight >= 0 && wall[linehighlight].nextwall == -1) { - if ((newnumwalls = whitelinescan(linehighlight)) < numwalls) + newnumwalls = whitelinescan(linehighlight); + if (newnumwalls < numwalls) { printmessage16("Can't make a sector out there."); + newnumwalls = -1; } else if (newnumwalls > MAXWALLS) { @@ -3620,16 +3704,19 @@ SKIP: NEXTWALL(i).nextwall = i; NEXTWALL(i).nextsector = numsectors; } + numwalls = newnumwalls; newnumwalls = -1; numsectors++; + printmessage16("Inner loop made into new sector."); } } - keystatus[0x1f] = 0; } else if (keystatus[0x1f]) //S { + keystatus[0x1f] = 0; + sucksect = -1; for (i=0; i 0) locktogrid(&dax, &day); - i = insertsprite(sucksect,0); - sprite[i].x = dax, sprite[i].y = day; - sprite[i].cstat = defaultspritecstat; - sprite[i].shade = 0; - sprite[i].pal = 0; - sprite[i].xrepeat = 64, sprite[i].yrepeat = 64; - sprite[i].xoffset = 0, sprite[i].yoffset = 0; - sprite[i].ang = 1536; - sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0; - sprite[i].owner = -1; - sprite[i].clipdist = 32; - sprite[i].lotag = 0; - sprite[i].hitag = 0; - sprite[i].extra = -1; + i = insert_sprite_common(sucksect, dax, day); - sprite[i].z = getflorzofslope(sucksect,dax,day); - if ((sprite[i].cstat&128) != 0) - sprite[i].z -= ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - - Bmemset(localartfreq, 0, sizeof(localartfreq)); - for (k=0; k localartfreq[j]) - j = k; - - if (localartfreq[j] > 0) - sprite[i].picnum = j; + if (i < 0) + printmessage16("Couldn't insert sprite."); else - sprite[i].picnum = 0; - + { + sprite[i].z = getflorzofslope(sucksect,dax,day); + if ((sprite[i].cstat&128) != 0) + sprite[i].z -= ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); // PK - if (prefixarg) - { - sprite[i].picnum = prefixarg; - sprite[i].xrepeat = sprite[i].yrepeat = 48; - prefixarg = 0; - } - else if (somethingintab == 3) - { - sprite[i].picnum = temppicnum; - if (tilesizx[temppicnum] <= 0 || tilesizy[temppicnum] <= 0) + if (prefixarg) { - j = 0; - for (k=0; k 0 && tilesizy[k] > 0) - { - j = k; - break; - } - sprite[i].picnum = j; + sprite[i].picnum = prefixarg; + sprite[i].xrepeat = sprite[i].yrepeat = 48; + prefixarg = 0; } - sprite[i].shade = tempshade; - sprite[i].pal = temppal; - sprite[i].xrepeat = max(tempxrepeat, 1); - sprite[i].yrepeat = max(tempyrepeat, 1); - sprite[i].cstat = tempcstat; + else if (somethingintab == 3) + { + sprite[i].picnum = temppicnum; + if (tilesizx[temppicnum] <= 0 || tilesizy[temppicnum] <= 0) + { + j = 0; + for (k=0; k 0 && tilesizy[k] > 0) + { + j = k; + break; + } + sprite[i].picnum = j; + } + sprite[i].shade = tempshade; + sprite[i].pal = temppal; + sprite[i].xrepeat = max(tempxrepeat, 1); + sprite[i].yrepeat = max(tempyrepeat, 1); + sprite[i].cstat = tempcstat; + } + + if (tilesizy[sprite[i].picnum] >= 32) + sprite[i].cstat |= 1; + + printmessage16("Sprite inserted."); + updatenumsprites(); + asksave = 1; + + VM_OnEvent(EVENT_INSERTSPRITE2D, i); } - - if (tilesizy[sprite[i].picnum] >= 32) - sprite[i].cstat |= 1; - - printmessage16("Sprite inserted."); - updatenumsprites(); - asksave = 1; - - VM_OnEvent(EVENT_INSERTSPRITE2D, i); } - - keystatus[0x1f] = 0; } if (keystatus[0x2e]) // C (make circle of points) @@ -3835,28 +3897,14 @@ SKIP: goodtogo = 1; // Checking limits... if (bad > 0) { - if (newnumwalls < numwalls) + if (newnumwalls < numwalls) // starting wall drawing { - // ---why MAXWALLS-2? wall[MAXWALLS-1] would be inserted, but would - // need to draw end of wall trail in wall[MAXWALLS]!--- - - // for MAXWALLS-1 we need extra space at the end of wall[] - if (numwalls >= MAXWALLS-1) - { - goodtogo = 0; - printmessage16("Can't start sector drawing: wall limit reached."); - } } else { //if not back to first point if (firstx != mousxplc || firsty != mousyplc) //nextpoint { - if (newnumwalls>=MAXWALLS) - { - goodtogo = 0; - printmessage16("Inserting another point would exceed wall limit."); - } } //if not split and back to first point @@ -3866,7 +3914,7 @@ SKIP: { /* No problem... */ } else { - if (newnumwalls>=MAXWALLS) // still too optimistic since we can have more than one new red wall + if (newnumwalls > MAXWALLS) { goodtogo = 0; printmessage16("Closing wall drawing would exceed wall limit."); @@ -3881,14 +3929,26 @@ SKIP: { if (newnumwalls < numwalls) // starting wall drawing { + if (numwalls >= MAXWALLS-1) + { + // whatever we do, we will need at least two new walls + printmessage16("Can't start sector drawing: wall limit reached."); + goto end_space_handling; + } + + if (numsectors >= MAXSECTORS) + { + printmessage16("Can't start sector drawing: sector limit reached."); + goto end_space_handling; + } + firstx = mousxplc; firsty = mousyplc; //Make first point newnumwalls = numwalls; suckwall = -1; split = 0; - //clearbufbyte(&wall[newnumwalls],sizeof(walltype),0L); - Bmemset(&wall[newnumwalls],0,sizeof(walltype)); + Bmemset(&wall[newnumwalls], 0, sizeof(walltype)); wall[newnumwalls].extra = -1; wall[newnumwalls].x = mousxplc; @@ -3901,14 +3961,21 @@ SKIP: suckwall = i; wall[newnumwalls].point2 = newnumwalls+1; - printmessage16("Sector drawing started."); newnumwalls++; + + printmessage16("Sector drawing started."); } - else + else // 2nd point and up... { //if not back to first point if (firstx != mousxplc || firsty != mousyplc) //nextpoint { + if (newnumwalls>=MAXWALLS) + { + printmessage16("Inserting another point would exceed wall limit."); + goto end_space_handling; + } + j = 0; for (i=numwalls; i>1; day = (wall[numwalls].y+mousyplc)>>1; for (i=0; i= 0) - if (POINT2(k).x != mousxplc || POINT2(k).y != mousyplc) - if (wall[lastwall(k)].x != mousxplc || wall[lastwall(k)].y != mousyplc) - { - split = 1; - splitsect = i; - splitstartwall = m; - break; - } - } + //check if first point at point of sector + m = -1; + for (WALLS_OF_SECTOR(i, k)) + if (wall[k].x==wall[numwalls].x && wall[k].y==wall[numwalls].y) + { + m = k; + break; + } + + // if the second insertion is not on a neighboring point of the first one... + if (m>=0 && (POINT2(k).x != mousxplc || POINT2(k).y != mousyplc)) + if (wall[lastwall(k)].x != mousxplc || wall[lastwall(k)].y != mousyplc) + { + split = 1; + splitsect = i; + splitstartwall = m; + break; + } + } } //make new point @@ -3954,10 +4023,13 @@ SKIP: { if (wall[i].nextwall >= 0) { + int32_t lastwalx = wall[newnumwalls-1].x; + int32_t lastwaly = wall[newnumwalls-1].y; + if (wall[i].x == mousxplc && wall[i].y == mousyplc) - if (POINT2(i).x == wall[newnumwalls-1].x && POINT2(i).y == wall[newnumwalls-1].y) + if (POINT2(i).x == lastwalx && POINT2(i).y == lastwaly) bad = 1; - if (wall[i].x == wall[newnumwalls-1].x && wall[i].y == wall[newnumwalls-1].y) + if (wall[i].x == lastwalx && wall[i].y == lastwaly) if (POINT2(i).x == mousxplc && POINT2(i).y == mousyplc) bad = 1; } @@ -3965,8 +4037,7 @@ SKIP: if (bad == 0) { - //clearbufbyte(&wall[newnumwalls],sizeof(walltype),0L); - Bmemset(&wall[newnumwalls],0,sizeof(walltype)); + Bmemset(&wall[newnumwalls], 0, sizeof(walltype)); wall[newnumwalls].extra = -1; wall[newnumwalls].x = mousxplc; @@ -3991,6 +4062,8 @@ SKIP: //if not split and back to first point if ((split == 0) && (firstx == mousxplc) && (firsty == mousyplc) && (newnumwalls >= numwalls+3)) { + // newnumwalls is at most MAXWALLS here + wall[newnumwalls-1].point2 = numwalls; if (suckwall == -1) //if no connections to other sectors @@ -3998,7 +4071,16 @@ SKIP: k = -1; for (i=0; i=suckwall; i--) - Bmemcpy(&wall[i+j],&wall[i],sizeof(walltype)); + Bmemcpy(&wall[i+j], &wall[i], sizeof(walltype)); for (i=0; iextra = -1; + + newsec->wallptr = numwalls; + newsec->wallnum = newnumwalls-numwalls; + + newsec->ceilingstat = oldsec->ceilingstat; + newsec->floorstat = oldsec->floorstat; + newsec->ceilingxpanning = oldsec->ceilingxpanning; + newsec->floorxpanning = oldsec->floorxpanning; + newsec->ceilingshade = oldsec->ceilingshade; + newsec->floorshade = oldsec->floorshade; + newsec->ceilingz = oldsec->ceilingz; + newsec->floorz = oldsec->floorz; + newsec->ceilingpicnum = oldsec->ceilingpicnum; + newsec->floorpicnum = oldsec->floorpicnum; +// newsec->ceilingheinum = oldsec->ceilingheinum; +// newsec->floorheinum = oldsec->floorheinum; for (i=numwalls; i MAXWALLS) { - bad = 0; - if (loopnumofsector(splitsect,splitstartwall) != loopnumofsector(splitsect,(int16_t)k)) - bad = 1; + printmessage16("%s would exceed wall limit.", bad==0 ? + "Splitting sector" : "Joining sector loops"); + newnumwalls--; + break; + } - if (numwalls+2*(newnumwalls-numwalls-1) > MAXWALLS) + if (bad == 0) + { + //SPLIT IT! + //Split splitsect given: startwall, + // new points: numwalls to newnumwalls-2 + + splitendwall = k; + newnumwalls--; //first fix up the new walls + for (i=numwalls; inumwalls; j--) - { - Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype)); - wall[danumwalls].nextwall = -1; - wall[danumwalls].nextsector = -1; - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - } - m = splitstartwall; //copy rest of loop next - while (m != splitendwall) - { - Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - m = wall[m].point2; - } - wall[danumwalls-1].point2 = secondstartwall; - - //Add other loops for 2nd sector - loopnum = loopnumofsector(splitsect,splitstartwall); - i = loopnum; - for (j=startwall; j<=endwall; j++) - { - k = loopnumofsector(splitsect,(int16_t)j); - if ((k != i) && (k != loopnum)) - { - i = k; - if (loopinside(wall[j].x,wall[j].y,secondstartwall) == 1) - { - m = j; //copy loop - k = danumwalls; - do - { - Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - m = wall[m].point2; - } - while (m != j); - wall[danumwalls-1].point2 = k; - } - } - } - - //fix all next pointers on old sector line - for (j=numwalls; j= 0) - { - NEXTWALL(j).nextwall = j; - if (j < secondstartwall) - NEXTWALL(j).nextsector = numsectors; - else - NEXTWALL(j).nextsector = numsectors+1; - } - } - //set all next pointers on split - for (j=numwalls; j= 0) - checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j,sectorofwall((int16_t)j)); - } - - //k now safe to use as temp - - for (m=numsectors-2; mnumwalls; j--) - { - Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype)); - wall[danumwalls].nextwall = -1; - wall[danumwalls].nextsector = -1; - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - } - - m = splitstartwall; //copy rest of loop next - do - { - Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - m = wall[m].point2; - } - while (m != splitstartwall); - wall[danumwalls-1].point2 = numwalls; - - //Add other loops to sector - loopnum = loopnumofsector(splitsect,splitstartwall); - i = loopnum; - for (j=startwall; j<=endwall; j++) - { - k = loopnumofsector(splitsect,(int16_t)j); - if ((k != i) && (k != loopnumofsector(splitsect,splitstartwall)) && (k != loopnumofsector(splitsect,splitendwall))) - { - i = k; - m = j; k = danumwalls; //copy loop + m = j; //copy loop + k = danumwalls; do - { - Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - m = wall[m].point2; - } + copyloop1(&danumwalls, &m); while (m != j); wall[danumwalls-1].point2 = k; } } + } - //fix all next pointers on old sector line - for (j=numwalls; jnumwalls; j--) + { + Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype)); + wall[danumwalls].nextwall = -1; + wall[danumwalls].nextsector = -1; + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + } + + m = splitstartwall; //copy rest of loop next + while (m != splitendwall) + copyloop1(&danumwalls, &m); + wall[danumwalls-1].point2 = secondstartwall; + + //Add other loops for 2nd sector + loopnum = loopnumofsector(splitsect,splitstartwall); + i = loopnum; + for (j=startwall; j<=endwall; j++) + { + k = loopnumofsector(splitsect, j); + if ((k != i) && (k != loopnum)) { - if (wall[j].nextwall >= 0) + i = k; + if (loopinside(wall[j].x,wall[j].y,secondstartwall) == 1) { - NEXTWALL(j).nextwall = j; - NEXTWALL(j).nextsector = numsectors; + m = j; k = danumwalls; //copy loop + do + copyloop1(&danumwalls, &m); + while (m != j); + wall[danumwalls-1].point2 = k; } } + } - //copy sector attributes & fix wall pointers - Bmemcpy(§or[numsectors],§or[splitsect],sizeof(sectortype)); - sector[numsectors].wallptr = numwalls; - sector[numsectors].wallnum = danumwalls-numwalls; + //fix all next pointers on old sector line + for (j=numwalls; j= 0) + { + NEXTWALL(j).nextwall = j; + if (j < secondstartwall) + NEXTWALL(j).nextsector = numsectors; + else + NEXTWALL(j).nextsector = numsectors+1; + } + } + //set all next pointers on split + for (j=numwalls; j= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer(j, sectorofwall(j)); + } + + //k now safe to use as temp + + for (m=numsectors-2; m= 0) - checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j,numsectors-1); - } - - newnumwalls = -1; - printmessage16("Loops joined."); - break; } + + printmessage16("Sector split."); } + else + { + //Sector split - actually loop joining + + splitendwall = k; + newnumwalls--; //first fix up the new walls + for (i=numwalls; inumwalls; j--) + { + Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype)); + wall[danumwalls].nextwall = -1; + wall[danumwalls].nextsector = -1; + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + } + + m = splitstartwall; //copy rest of loop next + do + copyloop1(&danumwalls, &m); + while (m != splitstartwall); + wall[danumwalls-1].point2 = numwalls; + + //Add other loops to sector + loopnum = loopnumofsector(splitsect,splitstartwall); + i = loopnum; + for (j=startwall; j<=endwall; j++) + { + k = loopnumofsector(splitsect, j); + if ((k != i) && (k != loopnumofsector(splitsect,splitstartwall)) && (k != loopnumofsector(splitsect,splitendwall))) + { + i = k; + m = j; k = danumwalls; //copy loop + do + copyloop1(&danumwalls, &m); + while (m != j); + wall[danumwalls-1].point2 = k; + } + } + + //fix all next pointers on old sector line + for (j=numwalls; j= 0) + { + NEXTWALL(j).nextwall = j; + NEXTWALL(j).nextsector = numsectors; + } + } + + //copy sector attributes & fix wall pointers + Bmemcpy(§or[numsectors],§or[splitsect],sizeof(sectortype)); + sector[numsectors].wallptr = numwalls; + sector[numsectors].wallnum = danumwalls-numwalls; + + //fix sprites + j = headspritesect[splitsect]; + while (j != -1) + { + k = nextspritesect[j]; + changespritesect(j,numsectors); + j = k; + } + + numsectors++; + + //Back of number of walls of new sector for later + k = danumwalls-numwalls; + + //clear out old sector's next pointers for clean deletesector + numwalls = danumwalls; + for (j=startwall; j<=endwall; j++) + { + wall[j].nextwall = -1; + wall[j].nextsector = -1; + } + deletesector(splitsect); + + //Check pointers + for (j=numwalls-k; j= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer(j, numsectors-1); + } + + printmessage16("Loops joined."); + } + + newnumwalls = -1; + break; + } } } } +end_space_handling: if (keystatus[0x1c]) //Left Enter { keystatus[0x1c] = 0; - if (keystatus[0x2a]&keystatus[0x1d]) + if (keystatus[0x2a] && keystatus[0x1d]) // LCtrl+LShift { printmessage16("CHECKING ALL POINTERS!"); for (i=0; i= numwalls) + if (keystatus[0x0e]) //Backspace { - if (newnumwalls > numwalls+1) - newnumwalls--; - else - newnumwalls = -1; + keystatus[0x0e] = 0; + + if (newnumwalls >= numwalls) + { + backspace_last = 1; + + if (newnumwalls == numwalls+1 || keystatus[0x1d]) // LCtrl: delete all newly drawn walls + newnumwalls = -1; + else + newnumwalls--; + } + else if (backspace_last==0) + { + graphicsmode += (1-2*(DOWN_BK(RUN) || keystatus[0x36]))+3; + graphicsmode %= 3; + printmessage16("2D mode textures %s", + (graphicsmode == 2)?"enabled w/ animation":graphicsmode?"enabled":"disabled"); + } } else - { - graphicsmode += (1-2*(DOWN_BK(RUN) || keystatus[0x36]))+3; - graphicsmode %= 3; - printmessage16("2D mode textures %s", - (graphicsmode == 2)?"enabled w/ animation":graphicsmode?"enabled":"disabled"); - } - + backspace_last = 0; } if (keystatus[0xd3] && eitherCTRL && (numwalls >= 0)) //sector delete @@ -4524,47 +4564,45 @@ SKIP: sucksect = -1; for (i=0; i= 0) - for (j=0; j= 0) + for (j=0; j=0; j--) { - for (j=highlightsectorcnt-1; j>=0; j--) - { - deletesector(highlightsector[j]); - for (k=j-1; k>=0; k--) - if (highlightsector[k] >= highlightsector[j]) - highlightsector[k]--; - } - - newnumwalls = -1; - Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); - highlightsectorcnt = -1; - - Bmemset(show2dwall, 0, sizeof(show2dwall)); - update_highlight(); - - printmessage16("Highlighted sectors deleted."); - k = 1; - break; + deletesector(highlightsector[j]); + for (k=j-1; k>=0; k--) + if (highlightsector[k] >= highlightsector[j]) + highlightsector[k]--; } - if (k == 0) - { - deletesector((int16_t)i); - Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); - highlightsectorcnt = -1; - Bmemset(show2dwall, 0, sizeof(show2dwall)); - update_highlight(); + printmessage16("Highlighted sectors deleted."); + k = 1; + break; + } - printmessage16("Sector deleted."); - } - newnumwalls = -1; - asksave = 1; - break; + if (k == 0) + { + deletesector(i); + printmessage16("Sector deleted."); } + + Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); + highlightsectorcnt = -1; + + Bmemset(show2dwall, 0, sizeof(show2dwall)); + update_highlight(); + + newnumwalls = -1; + asksave = 1; + + break; + } } if (keystatus[0xd3] && (pointhighlight >= 0)) @@ -4602,9 +4640,9 @@ SKIP: printmessage16("Inserting point would exceed wall limit."); else { - getclosestpointonwall(mousxplc,mousyplc,(int32_t)linehighlight,&dax,&day); - adjustmark(&dax,&day,newnumwalls); - insertpoint(linehighlight,dax,day); + getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day); + adjustmark(&dax,&day, newnumwalls); + insertpoint(linehighlight, dax,day); printmessage16("Point inserted."); j = 0; @@ -4612,15 +4650,15 @@ SKIP: for (i=numwalls-1; i>=0; i--) //delete points if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y) { - deletepoint((int16_t)i); + deletepoint(i); j++; } for (i=0; i=4))) SaveBoard(NULL, 0); while (keystatus[1] || keystatus[0x2e]) @@ -5002,6 +5040,7 @@ CANCEL: showframe(1); } } + clearkeys(); m32_setkeyfilter(1); @@ -5017,8 +5056,8 @@ CANCEL: for (WALLS_OF_SECTOR(highlightsector[i], j)) { if (wall[j].nextwall >= 0) - checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j,highlightsector[i]); + checksectorpointer(wall[j].nextwall, wall[j].nextsector); + checksectorpointer(j, highlightsector[i]); } } @@ -5032,7 +5071,7 @@ CANCEL: uninittimer(); uninitsystem(); clearfilenames(); - exit(0); + exit(1); } setbrightness(GAMMA_CALC,0,0); @@ -5047,9 +5086,13 @@ CANCEL: VM_OnEvent(EVENT_ENTER3DMODE, -1); } -static int32_t ask_if_sure(const char *query, int32_t quit_is_yes) +// flags: +// 1: quit_is_yes +// 2: don't clear keys on return +static int32_t ask_if_sure(const char *query, uint32_t flags) { char ch; + int32_t ret=-1; if (!query) _printmessage16("Are you sure?"); @@ -5058,13 +5101,13 @@ static int32_t ask_if_sure(const char *query, int32_t quit_is_yes) showframe(1); bflushchars(); - while ((keystatus[1]|keystatus[0x2e]) == 0) + while ((keystatus[1]|keystatus[0x2e]) == 0 && ret==-1) { if (handleevents()) { if (quitevent) { - if (quit_is_yes) + if (flags&1) return 1; else quitevent = 0; @@ -5075,11 +5118,17 @@ static int32_t ask_if_sure(const char *query, int32_t quit_is_yes) ch = bgetchar(); if (ch == 'y' || ch == 'Y') - return 1; + ret = 1; else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ') - return 0; + ret = 0; } + if ((flags&2)==0) + clearkeys(); + + if (ret >= 0) + return ret; + return 0; } @@ -5149,10 +5198,10 @@ int32_t LoadBoard(const char *filename, uint32_t flags) for (i=0; i= 0) { @@ -5453,14 +5507,14 @@ static void insertpoint(int16_t linehighlight, int32_t dax, int32_t day) for (i=sucksect+1; i= 0) { NEXTWALL(i).nextwall = -1; NEXTWALL(i).nextsector = -1; } - j = endwall-startwall+1; - movewalls(startwall,-j); + movewalls(startwall, -j); for (i=0; i= startwall) wall[i].nextsector--; @@ -5547,8 +5601,8 @@ void fixspritesectors(void) int32_t i, j, dax, day, daz; for (i=numsectors-1; i>=0; i--) - if ((sector[i].wallnum <= 0) || (sector[i].wallptr >= numwalls)) - deletesector((int16_t)i); + if (sector[i].wallnum <= 0 || sector[i].wallptr >= numwalls) + deletesector(i); for (i=0; i= getceilzofslope(j,dax,day)) - if (sprite[i].z-daz <= getflorzofslope(j,dax,day)) - { - changespritesect((int16_t)i,(int16_t)j); - break; - } + if (inside(dax,day, j) == 1 + && sprite[i].z >= getceilzofslope(j,dax,day) + && sprite[i].z-daz <= getflorzofslope(j,dax,day)) + { + changespritesect(i, j); + break; + } } } } @@ -5579,19 +5633,21 @@ static int32_t movewalls(int32_t start, int32_t offs) if (offs < 0) //Delete { for (i=start; i 0) //Insert { for (i=numwalls+offs-1; i>=start+offs; i--) - Bmemcpy(&wall[i],&wall[i-offs],sizeof(walltype)); + Bmemcpy(&wall[i], &wall[i-offs], sizeof(walltype)); } + numwalls += offs; for (i=0; i= start) wall[i].nextwall += offs; if (wall[i].point2 >= start) wall[i].point2 += offs; } + return(0); } @@ -6394,22 +6450,28 @@ int32_t fillsector(int16_t sectnum, char fillcolor) return(0); } -int16_t whitelinescan(int16_t dalinehighlight) +static int16_t whitelinescan(int16_t dalinehighlight) { int32_t i, j, k; - int16_t sucksect, newnumwalls; + int16_t sucksect, tnewnumwalls; sucksect = sectorofwall(dalinehighlight); - Bmemcpy(§or[numsectors],§or[sucksect],sizeof(sectortype)); + if (numsectors >= MAXSECTORS) + return MAXWALLS+1; + + Bmemcpy(§or[numsectors], §or[sucksect], sizeof(sectortype)); sector[numsectors].wallptr = numwalls; sector[numsectors].wallnum = 0; i = dalinehighlight; - newnumwalls = numwalls; + tnewnumwalls = numwalls; do { - j = lastwall((int16_t)i); + if (tnewnumwalls >= MAXWALLS) + return MAXWALLS+1; + + j = lastwall(i); if (wall[j].nextwall >= 0) { j = wall[j].point2; @@ -6424,26 +6486,26 @@ int16_t whitelinescan(int16_t dalinehighlight) } } - Bmemcpy(&wall[newnumwalls],&wall[i],sizeof(walltype)); + Bmemcpy(&wall[tnewnumwalls], &wall[i], sizeof(walltype)); - wall[newnumwalls].nextwall = j; - wall[newnumwalls].nextsector = sectorofwall((int16_t)j); + wall[tnewnumwalls].nextwall = j; + wall[tnewnumwalls].nextsector = sectorofwall(j); - newnumwalls++; + tnewnumwalls++; sector[numsectors].wallnum++; i = j; } while (i != dalinehighlight); - for (i=numwalls; i= 0) + thelastwall = lastwall(tempshort); + if (wall[thelastwall].nextwall >= 0) { - tempshort = wall[lastwall(tempshort)].nextwall; + tempshort = wall[thelastwall].nextwall; wall[tempshort].x = dax; wall[tempshort].y = day; wall[tempshort].cstat |= (1<<14); @@ -11369,7 +11372,7 @@ void plotpixel(int32_t x, int32_t y, char col) enddrawing(); //}}} } -void plotlines2d(int32_t *xx, int32_t *yy, int32_t numpoints, char col) +void plotlines2d(const int32_t *xx, const int32_t *yy, int32_t numpoints, char col) { int32_t i; @@ -11393,8 +11396,10 @@ void plotlines2d(int32_t *xx, int32_t *yy, int32_t numpoints, char col) int32_t odrawlinepat = drawlinepat; drawlinepat = 0xffffffff; + begindrawing(); for (i=0; inext != NULL) { - mapundo_t *next = mapstate->next; - next->prev = NULL; + mapundo_t *cur = mapstate->next; + cur->prev = NULL; - while (next->next) - next = next->next; + while (cur->next) + cur = cur->next; do { - if (next->sectors && (next->prev == NULL || (next->sectcrc != next->prev->sectcrc))) - Bfree(next->sectors); - if (next->walls && (next->prev == NULL || (next->wallcrc != next->prev->wallcrc))) - Bfree(next->walls); - if (next->sprites && (next->prev == NULL || (next->spritecrc != next->prev->spritecrc))) - Bfree(next->sprites); - if (!next->prev) + if (cur->sectors && (cur->prev == NULL || (cur->sectcrc != cur->prev->sectcrc))) + Bfree(cur->sectors); + if (cur->walls && (cur->prev == NULL || (cur->wallcrc != cur->prev->wallcrc))) + Bfree(cur->walls); + if (cur->sprites && (cur->prev == NULL || (cur->spritecrc != cur->prev->spritecrc))) + Bfree(cur->sprites); + if (!cur->prev) { - Bfree(next); + Bfree(cur); break; } - next = next->prev; - Bfree(next->next); + + cur = cur->prev; + Bfree(cur->next); } - while (next); + while (cur); } mapstate->next = (mapundo_t *)Bcalloc(1, sizeof(mapundo_t)); @@ -321,13 +321,7 @@ void create_map_snapshot(void) } fixspritesectors(); - - numsprites = 0; - for (j=MAXSPRITES-1; j>=0; j--) - { - if (sprite[j].statnum != MAXSTATUS) - numsprites++; - } + updatenumsprites(); mapstate->numsectors = numsectors; mapstate->numwalls = numwalls; @@ -347,7 +341,7 @@ void create_map_snapshot(void) } else { - mapstate->sectors = (sectortype *)Bcalloc(1, sizeof(sectortype) * numsectors); + mapstate->sectors = (sectortype *)Bcalloc(1, sizeof(sectortype) * numsectors + QADDNSZ); mapstate->sectsiz = j = qlz_compress(§or[0], (char *)&mapstate->sectors[0], sizeof(sectortype) * numsectors, state_compress); mapstate->sectors = (sectortype *)Brealloc(mapstate->sectors, j); @@ -368,7 +362,7 @@ void create_map_snapshot(void) } else { - mapstate->walls = (walltype *)Bcalloc(1, sizeof(walltype) * numwalls); + mapstate->walls = (walltype *)Bcalloc(1, sizeof(walltype) * numwalls + QADDNSZ); mapstate->wallsiz = j = qlz_compress(&wall[0], (char *)&mapstate->walls[0], sizeof(walltype) * numwalls, state_compress); mapstate->walls = (walltype *)Brealloc(mapstate->walls, j); @@ -403,7 +397,7 @@ void create_map_snapshot(void) } } mapstate->spritesiz = j = qlz_compress(&tspri[0], (char *)&mapstate->sprites[0], - sizeof(spritetype) * numsprites, state_compress); + sizeof(spritetype) * numsprites + QADDNSZ, state_compress); mapstate->sprites = (spritetype *)Brealloc(mapstate->sprites, j); mapstate->spritecrc = tempcrc; Bfree(tspri); @@ -471,6 +465,7 @@ int32_t map_undoredo(int32_t dir) Bmemset(show2dsector, 0, sizeof(show2dsector)); Bmemset(show2dsprite, 0, sizeof(show2dsprite)); Bmemset(show2dwall, 0, sizeof(show2dwall)); + Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); if (mapstate->numsectors) { @@ -495,6 +490,9 @@ int32_t map_undoredo(int32_t dir) if (qsetmode == 200 && rendmode == 4) polymer_loadboard(); #endif + + CheckMapCorruption(4, 0); + return 0; } @@ -3624,13 +3622,13 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i y1=max(y1, 0); y2=min(y2, ydim-1); - // box - { + // box int32_t xx[] = {x1, x1, x2, x2, x1}; int32_t yy[] = {y1, y2, y2, y1, y1}; plotlines2d(xx, yy, 5, iTile==iSelected ? whitecol : markedcol); } + // cross if (marked) { @@ -3918,37 +3916,6 @@ static void getnumberptr256(const char *namestart, void *num, int32_t bytes, int } } -static void DoSpriteOrnament(int32_t i) -{ - int32_t j, hitw; - hitdata_t hitinfo; - - hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum, - sintable[(sprite[i].ang+1536)&2047], - sintable[(sprite[i].ang+1024)&2047], - 0, - &hitinfo,CLIPMASK1); - - sprite[i].x = hitinfo.pos.x; - sprite[i].y = hitinfo.pos.y; - sprite[i].z = hitinfo.pos.z; - changespritesect(i,hitinfo.hitsect); - - hitw = hitinfo.hitwall; - - if (hitw >= 0) - sprite[i].ang = (getangle(POINT2(hitw).x-wall[hitw].x, - POINT2(hitw).y-wall[hitw].y)+512)&2047; - - //Make sure sprite's in right sector - if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) - { - j = wall[hitw].point2; - sprite[i].x -= ksgn(wall[j].y-wall[hitw].y); - sprite[i].y += ksgn(wall[j].x-wall[hitw].x); - } -} - #if 0 int64_t ldistsqr(spritetype *s1,spritetype *s2) { @@ -9223,7 +9190,7 @@ int32_t ExtInit(void) kensplayerheight = 40; //32 zmode = 2; zlock = kensplayerheight<<8; - defaultspritecstat = 0; +// defaultspritecstat = 0; ReadGamePalette(); // InitWater(); diff --git a/polymer/eduke32/source/mapster32.h b/polymer/eduke32/source/mapster32.h index 7695f9c09..48acd9516 100644 --- a/polymer/eduke32/source/mapster32.h +++ b/polymer/eduke32/source/mapster32.h @@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. const char *defsfilename = "duke3d.def"; extern char keystatus[]; -extern int16_t defaultspritecstat; extern int32_t horiz, qsetmode; extern vec3_t pos; extern int16_t ang, cursectnum;