From 16557ff1bbd665875db290d406422a70eaafa68a Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 13 Mar 2011 11:59:32 +0000 Subject: [PATCH] fixes: various ones accumulated in the forum (falling into infinity, stuck in doors), crash in polymer mouse picker when in void space, creation of surplus loops on sector split when sector has weird geometry. addition: disable sprite sectnum checking with m32script expert mode enabled. git-svn-id: https://svn.eduke32.com/eduke32@1843 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 2 + polymer/eduke32/build/include/editor.h | 2 + polymer/eduke32/build/include/m32script.h | 1 - polymer/eduke32/build/src/build.c | 741 +++++++++++----------- polymer/eduke32/build/src/engine.c | 45 +- polymer/eduke32/build/src/polymer.c | 98 +-- polymer/eduke32/source/astub.c | 7 +- 7 files changed, 457 insertions(+), 439 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 37a53cd9e..a5f2e8338 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -69,7 +69,9 @@ extern "C" { #define YAX_SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (§or[Sect].floor##Fld) : (§or[Sect].ceiling##Fld))) int16_t yax_getbunch(int16_t i, int16_t cf); +void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb); void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum); +void yax_setbunches(int16_t i, int16_t cb, int16_t fb); #define CLIPMASK0 (((1L)<<16)+1L) diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index c9658b804..d0b7ba8ae 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -123,6 +123,8 @@ extern int32_t corruptlevel, numcorruptthings, corruptthings[MAXCORRUPTTHINGS]; extern int32_t autocorruptcheck; extern int32_t CheckMapCorruption(int32_t printfromlev, uint64_t tryfixing); +extern int32_t m32_script_expertmode; // if true, make read-only vars writable + extern void showsectordata(int16_t sectnum, int16_t small); extern void showwalldata(int16_t wallnum, int16_t small); extern void showspritedata(int16_t spritenum, int16_t small); diff --git a/polymer/eduke32/build/include/m32script.h b/polymer/eduke32/build/include/m32script.h index 37d02a49d..213578438 100644 --- a/polymer/eduke32/build/include/m32script.h +++ b/polymer/eduke32/build/include/m32script.h @@ -172,7 +172,6 @@ extern uint32_t m32_drawlinepat; extern int32_t g_iReturnVar; extern int32_t m32_sortvar1, m32_sortvar2; -extern int32_t m32_script_expertmode; // if true, make read-only vars writable //extern int32_t g_numRealPalettes; //extern int32_t g_scriptDebug; diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 6a7b85376..416a1894a 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -133,7 +133,7 @@ uint32_t temppal, tempvis, tempxrepeat, tempyrepeat; int32_t tempshade, tempxvel, tempyvel, tempzvel; char somethingintab = 255; -int32_t mlook = 0,mskip=0; +int32_t mlook = 0, mskip=0; int32_t revertCTRL=0,scrollamount=3; int32_t unrealedlook=1, quickmapcycling=1; //PK @@ -150,6 +150,8 @@ static int32_t currentlist=0; //static int32_t repeatcountx, repeatcounty; static int32_t fillist[640]; +// used for fillsector and point selection in side-view mode: +static int32_t tempxyar[MAXWALLS][2]; static int32_t mousx, mousy; int16_t prefixtiles[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; @@ -222,7 +224,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); -static int16_t whitelinescan(int16_t dalinehighlight); +static int16_t whitelinescan(int16_t sucksect, 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); @@ -307,20 +309,11 @@ static int32_t osdcmd_vidmode(const osdfuncparm_t *parm) ydim2d = ydim; begindrawing(); //{{{ - CLEARLINES2D(0, ydim16, 0); - - ydim16 = ydim; -// drawline16(0,ydim-STATUS2DSIZ,xdim-1,ydim-STATUS2DSIZ,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); - drawline16(0,ydim-1-20,xdim-1,ydim-1-20,1); - drawline16(256,ydim-1-20,256,ydim-1,1); */ - ydim16 = ydim-STATUS2DSIZ2; enddrawing(); //}}} + + ydim16 = ydim-STATUS2DSIZ2; + return OSDCMD_OK; } @@ -372,6 +365,32 @@ static void M32_drawdebug(void) } #endif +#ifdef YAX_ENABLE +static void yax_resetbunchnums(void) +{ + int32_t i; + + for (i=0; i 0) pos.x--; -// if (keystatus[0x3c] > 0) pos.x++; -// if (keystatus[0x3d] > 0) pos.y--; -// if (keystatus[0x3e] > 0) pos.y++; -// if (keystatus[0x43] > 0) ang--; -// if (keystatus[0x44] > 0) ang++; - if (keystatus[0x43]) // F9 { if (mhk) @@ -932,6 +936,7 @@ void editinput(void) getzrange(&pos,cursectnum, &hiz,&hihit, &loz,&lohit, 128,CLIPMASK0); + oposz = pos.z; if (zmode == 0) { goalz = loz-(kensplayerheight<<8); //playerheight pixels above floor @@ -1029,7 +1034,16 @@ void editinput(void) hvel = 0; } - updatesectorz(pos.x,pos.y,pos.z, &cursectnum); + { + int16_t ocursectnum = cursectnum; + updatesectorz(pos.x,pos.y,pos.z, &cursectnum); + if (cursectnum<0) + { + if (zmode != 2) + pos.z = oposz; // don't allow to fall into infinity when in void space + cursectnum = ocursectnum; + } + } searchit = 2; if (searchstat >= 0) @@ -1525,8 +1539,11 @@ static void duplicate_selected_sectors() } // displace walls of new sectors by a small amount - dx = 512; //((maxx-minx)+255)&~255; - dy = -256; //((maxy-miny)+255)&~255; + if (grid>0 && grid<9) + dx = max(2048>>grid, 128); + else + dx = 512; + dy = -dx; if (maxx+dx >= editorgridextent) dx*=-1; if (minx+dx <= -editorgridextent) dx*=-1; if (maxy+dy >= editorgridextent) dy*=-1; @@ -1816,15 +1833,25 @@ static void copy_some_wall_members(int16_t dst, int16_t src) } // helpers for often needed ops: -static int32_t copyloop1(int16_t *danumwalls, int32_t *m) +static int32_t do_while_copyloop1(int16_t startwall, int16_t endwall, + int16_t *danumwalls, int16_t lastpoint2) { - if (*danumwalls >= MAXWALLS + M32_FIXME_WALLS) - return 1; + int32_t m = startwall; - Bmemcpy(&wall[*danumwalls], &wall[*m], sizeof(walltype)); - wall[*danumwalls].point2 = *danumwalls+1; - (*danumwalls)++; - *m = wall[*m].point2; + do + { + if (*danumwalls >= MAXWALLS + M32_FIXME_WALLS) + return 1; + + Bmemcpy(&wall[*danumwalls], &wall[m], sizeof(walltype)); + wall[*danumwalls].point2 = *danumwalls+1; + (*danumwalls)++; + m = wall[m].point2; + } + while (m != endwall); + + if (lastpoint2 >= 0) + wall[(*danumwalls)-1].point2 = lastpoint2; return 0; } @@ -1846,7 +1873,9 @@ static void updatesprite1(int16_t i) } static int32_t ask_if_sure(const char *query, uint32_t flags); +#ifdef YAX_ENABLE static int32_t ask_above_or_below(); +#endif // returns: // 0: continue @@ -1977,6 +2006,25 @@ static int32_t backup_drawn_walls(int32_t restore) return 0; } +#define GETWALCOORD(w) (*(int64_t *)&wall[*(const int32_t *)(w)].x) +static int32_t compare_wall_coords(const void *w1, const void *w2) +{ + if (GETWALCOORD(w1) == GETWALCOORD(w2)) + return 0; + if (GETWALCOORD(w1) > GETWALCOORD(w2)) + return 1; + return -1; +} +#undef GETWALCOORD + +#define RESET_EDITOR_VARS() do { \ + sectorhighlightstat = -1; \ + newnumwalls = -1; \ + joinsector[0] = -1; \ + circlewall = -1; \ + circlepoints = 7; \ + } while (0) + void overheadeditor(void) { char buffer[80], *dabuffer, ch; @@ -2012,26 +2060,11 @@ void overheadeditor(void) oposz = pos.z; begindrawing(); //{{{ - CLEARLINES2D(0, ydim, 0); - - ydim16 = ydim; -#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); -#endif - ydim16 = ydim-STATUS2DSIZ2; - enddrawing(); //}}} + ydim16 = ydim-STATUS2DSIZ2; + pag = 0; cursectorhighlight = -1; lastpm16time = -1; @@ -2043,11 +2076,7 @@ void overheadeditor(void) Bmemset(show2dwall, 0, sizeof(show2dwall)); //Clear all highlights Bmemset(show2dsprite, 0, sizeof(show2dsprite)); - sectorhighlightstat = -1; - newnumwalls = -1; - joinsector[0] = -1; - circlewall = -1; - circlepoints = 7; + RESET_EDITOR_VARS(); bstatus = 0; while ((keystatus[buildkeys[BK_MODE2D_3D]]>>1) == 0) @@ -2111,15 +2140,6 @@ void overheadeditor(void) bclamp(&searchx, 8, xdim-8-1); bclamp(&searchy, 8, ydim-8-1); - /* - if (keystatus[0x3b] > 0) pos.x--, keystatus[0x3b] = 0; - if (keystatus[0x3c] > 0) pos.x++, keystatus[0x3c] = 0; - if (keystatus[0x3d] > 0) pos.y--, keystatus[0x3d] = 0; - if (keystatus[0x3e] > 0) pos.y++, keystatus[0x3e] = 0; - if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0; - if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; - */ - mainloop_move(); getpoint(searchx,searchy,&mousxplc,&mousyplc); @@ -2644,9 +2664,6 @@ void overheadeditor(void) mouseb &= ~(16|32); bstatus &= ~(16|32); - -// clearmidstatbar16(); -// showspritedata((int16_t)pointhighlight-16384); } } } @@ -2664,38 +2681,16 @@ void overheadeditor(void) #if 1 if (keystatus[0x3f]) //F5 { -// keystatus[0x3f] = 0; - - ydim16 = STATUS2DSIZ; - ExtShowSectorData((int16_t)0); - ydim16 = ydim-STATUS2DSIZ2; + ExtShowSectorData(0); } if (keystatus[0x40]) //F6 { -// keystatus[0x40] = 0; - if (pointhighlight >= 16384) - { - i = pointhighlight-16384; - - ydim16 = STATUS2DSIZ; - ExtShowSpriteData((int16_t)i); - ydim16 = ydim-STATUS2DSIZ2; - } + ExtShowSpriteData(pointhighlight-16384); else if (linehighlight >= 0) - { - i = linehighlight; - - ydim16 = STATUS2DSIZ; - ExtShowWallData((int16_t)i); - ydim16 = ydim-STATUS2DSIZ2; - } + ExtShowWallData(linehighlight); else - { - ydim16 = STATUS2DSIZ; - ExtShowWallData((int16_t)0); - ydim16 = ydim-STATUS2DSIZ2; - } + ExtShowWallData(0); } if (keystatus[0x41]) //F7 { @@ -2704,9 +2699,7 @@ void overheadeditor(void) for (i=0; i= 16384) - { - i = pointhighlight-16384; - - ydim16 = STATUS2DSIZ; - ExtEditSpriteData((int16_t)i); - ydim16 = ydim-STATUS2DSIZ2; - } + ExtEditSpriteData(pointhighlight-16384); else if (linehighlight >= 0) - { - i = linehighlight; - - ydim16 = STATUS2DSIZ; - ExtEditWallData((int16_t)i); - ydim16 = ydim-STATUS2DSIZ2; - } + ExtEditWallData(linehighlight); } #endif @@ -2810,12 +2791,10 @@ void overheadeditor(void) i = pointhighlight-16384; Bsprintf(buffer, "Sprite (%d) Status list: ", i); changespritestat(i, getnumber16(buffer, sprite[i].statnum, MAXSTATUS-1, 0)); -// clearmidstatbar16(); -// showspritedata((int16_t)i); - // printmessage16(""); } } - else if (highlightsectorcnt > 0 && newnumwalls < 0&&0) +#ifdef YAX_ENABLE + else if (highlightsectorcnt > 0 && newnumwalls < 0) { ////////// YAX ////////// static const char *cfs[2] = {"ceiling", "floor"}; @@ -2916,8 +2895,11 @@ void overheadeditor(void) Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); update_highlightsector(); + + message("Extended %ss of highlighted sectors, created new bunch %d", cfs[cf], k); end_yax: ; } +#endif } if (highlightsectorcnt < 0) @@ -3025,30 +3007,48 @@ end_yax: ; } } - if (m32_sideview && !onlySprites) + if (m32_sideview && numwalls>0 && !onlySprites) { + int64_t curcoord; + int32_t begwall=0, mustselect=0; + // also select walls that would be dragged but // maybe were missed -#if 1 + for (i=0; i>3]&(1<<(i&7))) + tempxyar[i][0] = i; + qsort(tempxyar, numwalls, sizeof(tempxyar[0]), compare_wall_coords); + + i = 0; + k = tempxyar[i][0]; // the actual wallnum... + curcoord = *(int64_t *)&wall[k].x; + while (i>3]&(1<<(k&7))); + i++; + if (i==numwalls || ((k=tempxyar[i][0]), (*(int64_t *)&wall[k].x != curcoord))) { - //N^2...ugh - for (j=0; j>3] |= (1<<(j&7)); + if (mustselect) + { + // select all from begwall to i-1 + for (j=begwall; j>3] |= (1<<(tempxyar[j][0]&7)); + } + + mustselect = 0; + } + + if (i==numwalls) + break; + + begwall = i; + curcoord = *(int64_t *)&wall[tempxyar[i][0]].x; } -#else - for (i=0; i>3]&(1<<(i&7))) - dragpoint(i, wall[i].x, wall[i].y); - for (i=0; i>3] |= (1<<(i&7)); - wall[i].cstat &= ~(1<<14); - } -#endif + } } for (i=0; i0) -// printmessage16("Total selected sectors: %d", highlightsectorcnt); } } } @@ -3698,7 +3695,7 @@ end_point_dragging: _printmessage16("Sideview angle: %d", (int32_t)m32_sideang); } - if (m32_sideview && (keystatus[0x2a] || (bstatus&(16|32)))) // LShift + if (m32_sideview && (eitherSHIFT || (bstatus&(16|32)))) { if ((DOWN_BK(MOVEUP) || (bstatus&16)) && m32_sideelev < 512) { @@ -3948,7 +3945,7 @@ end_join_sectors: if (linehighlight >= 0 && wall[linehighlight].nextwall == -1) { - newnumwalls = whitelinescan(linehighlight); + newnumwalls = whitelinescan(sectorofwall(linehighlight), linehighlight); if (newnumwalls < numwalls) { printmessage16("Can't make a sector out there."); @@ -4334,12 +4331,14 @@ check_next_sector: ; sector[numsectors].wallptr = numwalls; sector[numsectors].wallnum = newnumwalls-numwalls; - sector[numsectors].ceilingz = (-32<<8); + sector[numsectors].ceilingz = -(32<<8); sector[numsectors].floorz = (32<<8); for (i=numwalls; i=0 || fbunch>=0); +#endif + j = newnumwalls-numwalls; +#ifdef YAX_ENABLE + newnumwalls2 = newnumwalls + j; + if (extendedSector) + { + if ((cbunch>=0 && (sector[k].ceilingstat&2)) + || (fbunch>=0 && (sector[k].floorstat&2))) + { + message("Sloped extended sectors cannot be subdivided."); + newnumwalls--; + goto end_space_handling; + } + + if (newnumwalls + j > MAXWALLS || numsectors+1 > MAXSECTORS) + { + message("Automatically adding inner sector to new extended sector would exceed limits!"); + newnumwalls--; + goto end_space_handling; + } + } +#endif if (clockdir(numwalls) == 0) flipwalls(numwalls,newnumwalls); - j = newnumwalls-numwalls; - sector[k].wallnum += j; for (i=k+1; i=suckwall; i--) - Bmemcpy(&wall[i+j], &wall[i], sizeof(walltype)); - for (i=0; i 0) //sector delete { +#ifdef YAX_ENABLE + int16_t cb, fb; +#endif keystatus[0xd3] = 0; sucksect = -1; @@ -4757,14 +4781,23 @@ end_space_handling: { if (inside_editor(&pos, searchx,searchy, zoom, mousxplc,mousyplc,i) != 1) continue; - +#ifdef YAX_ENABLE + // used as a bunch bitmap here + Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); +#endif k = 0; if (highlightsectorcnt >= 0) + { for (j=0; j=0; j--) { +#ifdef YAX_ENABLE + yax_getbunches(highlightsector[j], &cb, &fb); + if (cb>=0) hlsectorbitmap[cb>>3] |= (1<<(cb&7)); + if (fb>=0) hlsectorbitmap[fb>>3] |= (1<<(fb&7)); +#endif deletesector(highlightsector[j]); for (k=j-1; k>=0; k--) if (highlightsector[k] >= highlightsector[j]) @@ -4775,13 +4808,29 @@ end_space_handling: k = 1; break; } + } if (k == 0) { +#ifdef YAX_ENABLE + yax_getbunches(i, &cb, &fb); + if (cb>=0) hlsectorbitmap[cb>>3] |= (1<<(cb&7)); + if (fb>=0) hlsectorbitmap[fb>>3] |= (1<<(fb&7)); +#endif deletesector(i); printmessage16("Sector deleted."); } +#ifdef YAX_ENABLE + for (j=0; j>3] & (1<<(cb&7))) + yax_setbunch(j, YAX_CEILING, -1); + if (hlsectorbitmap[fb>>3] & (1<<(fb&7))) + yax_setbunch(j, YAX_FLOOR, -1); + } +#endif Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); highlightsectorcnt = -1; @@ -4831,36 +4880,16 @@ end_space_handling: { getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day); adjustmark(&dax,&day, newnumwalls); - insertpoint(linehighlight, dax,day); - printmessage16("Point inserted."); - - j = 0; - //Check to see if point was inserted over another point - for (i=numwalls-1; i>=0; i--) //delete points - if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y) - { - deletepoint(i); - j++; - } - for (i=0; i>1); - // day = ((wall[linehighlight].y + POINT2(linehighlight).y)>>1); - // if ((dax != wall[linehighlight].x) || (day != wall[linehighlight].y)) - // if ((dax != POINT2(linehighlight).x) || (day != POINT2(linehighlight).y)) - // { - // insertpoint(linehighlight,dax,day); - // printmessage16("Point inserted at midpoint."); - // } - //} } backup_drawn_walls(1); @@ -4917,10 +4946,7 @@ nextmap: if (LoadBoard(NULL, 4)) goto nextmap; - sectorhighlightstat = -1; - joinsector[0] = -1; - circlewall = -1; - circlepoints = 7; + RESET_EDITOR_VARS(); oposz = pos.z; } showframe(1); @@ -4992,21 +5018,10 @@ CANCEL: for (i=0; i= numwalls) deletesector(i); + if (m32_script_expertmode) + return; + for (i=0; i> 2, 0x08080808l); - CLEARLINES2D(ydim-y+25, STATUS2DSIZ+2-(25<<1), 0); - -// drawline16(0,ydim-STATUS2DSIZ,0,ydim-1,editorcolors[7]); -// drawline16base(xdim,ydim, -1,-STATUS2DSIZ, -1,-1, editorcolors[7]); - - ydim16 = ydim-STATUS2DSIZ2; enddrawing(); } @@ -5989,70 +5988,82 @@ static int32_t numloopsofsector(int16_t sectnum) } #endif +static int32_t getnumber_internal1(char ch, const char *buffer, int32_t *danumptr, int32_t *oldnum, int32_t maxnumber, char sign) +{ + int32_t danum = *danumptr; + + if (ch >= '0' && ch <= '9') + { + int64_t nbig; + if (danum >= 0) + { + nbig = ((int64_t)danum*10)+(ch-'0'); + if (nbig <= (int64_t)maxnumber) danum = nbig; + } + else if (sign) // this extra check isn't hurting anything + { + nbig = ((int64_t)danum*10)-(ch-'0'); + if (nbig >= (int64_t)(-maxnumber)) danum = nbig; + } + } + else if (ch == 8 || ch == 127) // backspace + { + danum /= 10; + } + else if (ch == 13) + { + *oldnum = danum; + asksave = 1; + printmessage16("%s", buffer); + return 1; + } + else if (ch == '-' && sign) // negate + { + danum = -danum; + } + + *danumptr = danum; + return 0; +} + int32_t _getnumber16(const char *namestart, int32_t num, int32_t maxnumber, char sign, void *(func)(int32_t)) { char buffer[80], ch; int32_t n, danum, oldnum; - danum = (int32_t)num; + danum = num; oldnum = danum; + bflushchars(); while (keystatus[0x1] == 0) { if (handleevents()) - { - if (quitevent) quitevent = 0; - } - idle(); + quitevent = 0; + idle(); ch = bgetchar(); - Bsprintf(buffer,"%s^011%d",namestart,danum); + Bsprintf(buffer,"%s^011%d", namestart, danum); n = Bstrlen(buffer); if (totalclock & 32) Bstrcat(buffer,"_ "); _printmessage16("%s", buffer); if (func != NULL) { - Bsprintf(buffer,"^011%s",(char *)func((int32_t)danum)); + Bsprintf(buffer, "^011%s", (char *)func(danum)); // printext16(200L-24, ydim-STATUS2DSIZ+20L, editorcolors[9], editorcolors[0], buffer, 0); printext16(n<<3, ydim-STATUS2DSIZ+128, editorcolors[9], -1, buffer,0); } showframe(1); - if (ch >= '0' && ch <= '9') - { - int64_t nbig; - if (danum >= 0) - { - nbig = ((int64_t)danum*10)+(ch-'0'); - if (nbig <= (int64_t)maxnumber) danum = nbig; - } - else if (sign) // this extra check isn't hurting anything - { - nbig = ((int64_t)danum*10)-(ch-'0'); - if (nbig >= (int64_t)-maxnumber) danum = nbig; - } - } - else if (ch == 8 || ch == 127) // backspace - { - danum /= 10; - } - else if (ch == 13) - { - oldnum = danum; - asksave = 1; - printmessage16("%s", buffer); + if (getnumber_internal1(ch, buffer, &danum, &oldnum, maxnumber, sign)) break; - } - else if (ch == '-' && sign) // negate - { - danum = -danum; - } } + clearkeys(); - return(oldnum); + + return oldnum; } int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, char sign, void *(func)(int32_t)) @@ -6062,6 +6073,7 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha danum = num; oldnum = danum; + bflushchars(); while (keystatus[0x1] == 0) { @@ -6083,9 +6095,8 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha #endif ch = bgetchar(); - - if (keystatus[0x1]) break; - + if (keystatus[0x1]) + break; clearkeys(); mouseb = 0; @@ -6099,46 +6110,21 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha printmessage256(0, 0, buffer); if (func != NULL) { - Bsprintf(buffer,"%s",(char *)func((int32_t)danum)); + Bsprintf(buffer, "%s", (char *)func(danum)); printmessage256(0, 9, buffer); } showframe(1); - if (ch >= '0' && ch <= '9') - { - int64_t nbig; - if (danum >= 0) - { - nbig = ((int64_t)danum*10)+(ch-'0'); - if (nbig <= (int64_t)maxnumber) danum = nbig; - } - else if (sign) - { - nbig = ((int64_t)danum*10)-(ch-'0'); - if (nbig >= (int64_t)-maxnumber) danum = nbig; - } - } - else if (ch == 8 || ch == 127) // backspace - { - danum /= 10; - } - else if (ch == 13) - { - oldnum = danum; - asksave = 1; + if (getnumber_internal1(ch, buffer, &danum, &oldnum, maxnumber, sign)) break; - } - else if (ch == '-' && sign) // negate - { - danum = -danum; - } } + clearkeys(); lockclock = totalclock; //Reset timing - return(oldnum); + return oldnum; } // querystr: e.g. "Name: ", must be !=NULL @@ -6606,8 +6592,6 @@ static int32_t menuselect(void) return(-1); } -static int32_t fillsectorxy[MAXWALLS][2]; - int32_t fillsector(int16_t sectnum, char fillcolor) { int32_t x1, x2, y1, y2, sy, y; @@ -6638,8 +6622,8 @@ int32_t fillsector(int16_t sectnum, char fillcolor) if (m32_sideview) { - fillsectorxy[z][0] = x1; - fillsectorxy[z][1] = y1; + tempxyar[z][0] = x1; + tempxyar[z][1] = y1; } miny = min(miny, y1); @@ -6659,10 +6643,10 @@ int32_t fillsector(int16_t sectnum, char fillcolor) { if (m32_sideview) { - x1 = fillsectorxy[z][0]; - y1 = fillsectorxy[z][1]; - x2 = fillsectorxy[wall[z].point2][0]; - y2 = fillsectorxy[wall[z].point2][1]; + x1 = tempxyar[z][0]; + y1 = tempxyar[z][1]; + x2 = tempxyar[wall[z].point2][0]; + y2 = tempxyar[wall[z].point2][1]; if (y1 > y2) { @@ -6729,12 +6713,10 @@ int32_t fillsector(int16_t sectnum, char fillcolor) return(0); } -static int16_t whitelinescan(int16_t dalinehighlight) +static int16_t whitelinescan(int16_t sucksect, int16_t dalinehighlight) { int32_t i, j, k; - int16_t sucksect, tnewnumwalls; - - sucksect = sectorofwall(dalinehighlight); + int16_t tnewnumwalls; if (numsectors >= MAXSECTORS) return MAXWALLS+1; @@ -7305,10 +7287,9 @@ void _printmessage16(const char *fmt, ...) clearministatbar16(); -// ybase = (overridepm16y >= 0) ? ydim-overridepm16y : ydim-STATUS2DSIZ+128-8; ybase = ydim-STATUS2DSIZ+128-8; - printext16(/*(overridepm16y >= 0) ? 200L-24 :*/ 8, ybase+8, whitecol, -1, snotbuf, 0); + printext16(8, ybase+8, whitecol, -1, snotbuf, 0); } void printmessage256(int32_t x, int32_t y, const char *name) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index d189955b9..d5de12c3a 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -173,24 +173,45 @@ static int16_t maphacklight[PR_MAXLIGHTS]; inline int32_t getscreenvdisp(int32_t bz, int32_t zoome); void screencoords(int32_t *xres, int32_t *yres, int32_t x, int32_t y, int32_t zoome); +int16_t editstatus = 0; + ////////// YAX ////////// -#define YAX_BUNCHNUM(Sect, Cf) (*(int16_t *)(§or[Sect].ceilingxpanning + 6*Cf)) +#ifdef YAX_ENABLE +// all references to floor/ceiling bunchnums should be through the +// get/set functions! + +// game-time YAX data structures +static int16_t yax_bunchnum[MAXSECTORS][2]; + +#define YAX_BUNCHNUM(Sect, Cf) (*(int16_t *)(§or[Sect].ceilingxpanning + 6*Cf)) int16_t yax_getbunch(int16_t i, int16_t cf) { + if (editstatus==0) + return yax_bunchnum[i][cf]; + if (((*(§or[i].ceilingstat + cf))&YAX_BIT)==0) return -1; return YAX_BUNCHNUM(i, cf); } +void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb) +{ + *cb = yax_getbunch(i, YAX_CEILING); + *fb = yax_getbunch(i, YAX_FLOOR); +} + void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum) { - if (i<0) + if (editstatus==0) + yax_bunchnum[i][cf] = bunchnum; + + if (bunchnum<0) { *(§or[i].ceilingstat + cf) &= ~YAX_BIT; - YAX_BUNCHNUM(i, cf) = 0; +// YAX_BUNCHNUM(i, cf) = 0; return; } @@ -198,6 +219,15 @@ void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum) YAX_BUNCHNUM(i, cf) = bunchnum; } +void yax_setbunches(int16_t i, int16_t cb, int16_t fb) +{ + yax_setbunch(i, YAX_CEILING, cb); + yax_setbunch(i, YAX_FLOOR, fb); +} + +#undef YAX_BUNCHNUM + +#endif ////////// editor side view ////////// int32_t m32_sideview = 0; @@ -1147,7 +1177,7 @@ static char tablesloaded = 0; int32_t pageoffset, ydim16, qsetmode = 0; int32_t startposx, startposy, startposz; int16_t startang, startsectnum; -int16_t pointhighlight, linehighlight, highlightcnt; +int16_t pointhighlight=-1, linehighlight=-1, highlightcnt=0; int32_t lastx[MAXYDIM]; char *transluc = NULL, paletteloaded = 0; @@ -1196,7 +1226,6 @@ char vgapal16[4*256] = 63,63,63,00 }; -int16_t editstatus = 0; int16_t searchit; int32_t searchx = -1, searchy; //search input int16_t searchsector, searchwall, searchstat; //search output @@ -6215,7 +6244,7 @@ int32_t preinitengine(void) { dynarray[0].size += M32_FIXME_SECTORS*sizeof(sectortype); // join sectors needs a temp. sector dynarray[1].size += M32_FIXME_WALLS*sizeof(walltype); - Bprintf("FIXME: Allocating additional space beyond wall[] for editor bugs.\n"); +// Bprintf("FIXME: Allocating additional space beyond wall[] for editor bugs.\n"); } for (i=0; i<(signed)(sizeof(dynarray)/sizeof(dynarray[0])); i++) @@ -6318,10 +6347,6 @@ int32_t initengine(void) clearbuf(&show2dwall[0],(int32_t)((MAXWALLS+3)>>5),0L); automapping = 0; - pointhighlight = -1; - linehighlight = -1; - highlightcnt = 0; - totalclock = 0; visibility = 512; parallaxvisibility = 512; diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 7a2c49781..df609ec2d 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -1148,54 +1148,62 @@ void polymer_editorpick(void) scrvxz[0] = x-scrx; scrvxz[1] = z-scrz; - if (searchstat==1) - pl = &prsectors[searchsector]->ceil.plane[0]; - else - pl = &prsectors[searchsector]->floor.plane[0]; - - t = dot3f(pl,scrv); - svcoeff = -(dot3f(pl,scr)+pl[3])/t; - - // point on plane (x and z) - p[0] = scrx + svcoeff*scrv[0]; - p[1] = scrz + svcoeff*scrv[2]; - - for (k=0; kceil.plane[0]); + else + pl = &(prsectors[searchsector]->floor.plane[0]); - searchwall = sector[searchsector].wallptr + bestk; + t = dot3f(pl,scrv); + svcoeff = -(dot3f(pl,scr)+pl[3])/t; + + // point on plane (x and z) + p[0] = scrx + svcoeff*scrv[0]; + p[1] = scrz + svcoeff*scrv[2]; + + for (k=0; k= 0; i--) { if (s_TileGroups[i].pIds != NULL) @@ -9310,6 +9310,7 @@ void ExtUnInit(void) } for (i = numhelppages-1; i >= 0; i--) Bfree(helppage[i]); if (helppage) Bfree(helppage); +#endif } void ExtPreCheckKeys(void) // just before drawrooms