From 367afadf39f9eda874f6dbb11989bf0401377c7d Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 2 May 2011 16:58:11 +0000 Subject: [PATCH] tweak point deleting for less checksectorpointer calls git-svn-id: https://svn.eduke32.com/eduke32@1875 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/build.c | 156 ++++++++++++++++++++--------- polymer/eduke32/build/src/engine.c | 37 +++++-- polymer/eduke32/source/astub.c | 58 +++++++++-- 3 files changed, 191 insertions(+), 60 deletions(-) diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 66cb7e718..6235f56e3 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -200,7 +200,7 @@ void keytimerstuff(void); static int32_t clockdir(int16_t wallstart); static void flipwalls(int16_t numwalls, int16_t newnumwalls); static void insertpoint(int16_t linehighlight, int32_t dax, int32_t day); -static void deletepoint(int16_t point); +static const char *deletepoint(int16_t point, int32_t runi); 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); @@ -341,19 +341,27 @@ static void M32_drawdebug(void) #endif #ifdef YAX_ENABLE +static void yax_fixreverselinks(int16_t oldwall, int16_t newwall) +{ + int32_t cf, ynw; + for (cf=0; cf<2; cf++) + { + ynw = yax_getnextwall(oldwall, cf); + if (ynw >= 0) + yax_setnextwall(ynw, !cf, newwall); + } +} + static void yax_tweakwalls(int16_t start, int16_t offs) { - int32_t i, nw; + int32_t i, nw, cf; for (i=0; i= start) - yax_setnextwall(i, YAX_CEILING, nw+offs); - - nw = yax_getnextwall(i, YAX_FLOOR); - if (nw >= start) - yax_setnextwall(i, YAX_FLOOR, nw+offs); - } + for (cf=0; cf<2; cf++) + { + nw = yax_getnextwall(i, cf); + if (nw >= start) + yax_setnextwall(i, cf, nw+offs); + } } static void yax_resetbunchnums(void) @@ -3547,6 +3555,7 @@ end_yax: ; if (((bstatus&1) < (oldmousebstatus&1)) && highlightsectorcnt < 0) //after dragging { int32_t runi, numdelpoints=0; + const char *errmsg; if (backup_drawn_walls(0)) goto end_after_dragging; @@ -3582,47 +3591,51 @@ end_yax: ; day = sprite[pointhighlight&16383].y; } - for (runi=0; runi<2; runi++) + for (runi=0; runi<3; runi++) for (i=numwalls-1; i>=0; i--) //delete points { + if (runi==0) + wall[i].cstat &= ~(1<<14); + if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y && sector[sectorofwall(i)].wallnum > 3) { - int32_t b = (wall[i].nextwall == -1 || - sector[sectorofwall(wall[i].nextwall)].wallnum > 3); - if (runi==0 && !b) + errmsg = deletepoint(i, runi); + if (errmsg) { - printmessage16("Invalid operation, delete or join sector instead."); + message("%s", errmsg); goto end_after_dragging; } - else if (runi==1 && b) - { - deletepoint(i); + else if (runi==2) numdelpoints++; - } } } if (numdelpoints) { if (numdelpoints > 1) - printmessage16("Deleted %d points.", numdelpoints); + message("Deleted %d points.", numdelpoints); else printmessage16("Point deleted."); asksave = 1; } - - for (i=0; i=0 || fb0>=0 || cb1>=0 || fb0>=0) + if (cb0>=0 || fb0>=0 || cb1>=0 || fb1>=0) { - printmessage16("Joining non-adjacent extended sectors not allowed!"); + message("Joining non-adjacent extended sectors not allowed!"); joinsector[0] = joinsector[1] = -1; goto end_join_sectors; } #endif { - fade_editor_screen(-1); + fillsector(i, editorcolors[9]); + fillsector(joinsector[0], editorcolors[9]); + fade_editor_screen(editorcolors[9]); if (!ask_if_sure("Join non-adjacent sectors? (Y/N)", 0)) joinsector[1] = joinsector[0]; @@ -4072,7 +4092,7 @@ end_point_dragging: #ifdef YAX_ENABLE if (cb0!=cb1 || fb0!=fb1) { - printmessage16("Joining of extended sectors with different bunches not allowed!"); + message("Joining of extended sectors with different bunches not allowed!"); joinsector[0] = joinsector[1] = -1; goto end_join_sectors; } @@ -4127,6 +4147,9 @@ end_point_dragging: } Bmemcpy(&wall[newnumwalls], &wall[i], sizeof(walltype)); +#ifdef YAX_ENABLE + yax_fixreverselinks(newnumwalls, newnumwalls); +#endif wall[newnumwalls].point2 = newnumwalls+1; newnumwalls++; @@ -4148,7 +4171,7 @@ end_point_dragging: if (loopnum==0) { - printmessage16("internal error while joining sectors: infloop!"); + message("internal error while joining sectors: infloop!"); newnumwalls = -1; } } @@ -4255,11 +4278,14 @@ end_join_sectors: sucksect = -1; for (i=0; i= 0) { @@ -4710,6 +4736,15 @@ check_next_sector: ; if (clockdir(numwalls) == 1) flipwalls(numwalls,newnumwalls); + for (i=numwalls; i 0) + { + // if new red line, prefer the other-side wall as base + suckwall = wall[i].nextwall; + } + } sucksect = sectorofwall(suckwall); if (numsectors != sucksect) @@ -4725,12 +4760,6 @@ check_next_sector: ; sector[numsectors].floorstat &= ~2; sector[numsectors].ceilingheinum = sector[numsectors].floorheinum = 0; sector[numsectors].ceilingpal = sector[numsectors].floorpal = 0; - - for (i=numwalls; i= 0) { NEXTWALL(j).nextwall = j; @@ -6080,6 +6116,8 @@ static int32_t adjustmark(int32_t *xplc, int32_t *yplc, int16_t danumwalls) for (i=0; i= 0 && sector[i].wallnum <= 3) + return "Invalid operation, delete or join sector instead."; + + return NULL; + } + else if (runi==1) + { + i = wall[point].nextwall; + if (i >= 0) + { + NEXTWALL(i).nextwall = NEXTWALL(i).nextsector = -1; + wall[i].nextwall = wall[i].nextsector = -1; + } + + return NULL; + } sucksect = sectorofwall(point); @@ -6240,9 +6302,9 @@ static void deletepoint(int16_t point) sector[i].wallptr--; j = lastwall(point); - k = wall[point].point2; - wall[j].point2 = k; + wall[j].point2 = wall[point].point2; +#if 0 if (wall[j].nextwall >= 0) { NEXTWALL(j).nextwall = -1; @@ -6253,10 +6315,12 @@ static void deletepoint(int16_t point) NEXTWALL(point).nextwall = -1; NEXTWALL(point).nextsector = -1; } - +#endif movewalls(point, -1); - checksectorpointer(j, sucksect); +// checksectorpointer(j, sucksect); + + return NULL; } static int32_t deletesector(int16_t sucksect) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index c35ce9c53..1267e0f0d 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -535,8 +535,8 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn } } - if (allgotsector[k>>3]&(1<<(k&7))) - continue; +// if (allgotsector[k>>3]&(1<<(k&7))) +// continue; drawrooms(globalposx,globalposy,globalposz,globalang,horiz,k+MAXSECTORS); // +MAXSECTORS: force ExtAnalyzeSprites(); @@ -1170,6 +1170,9 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum) for (j=0; j=0 && wall[k].nextwall != i) @@ -3928,7 +3928,27 @@ static void drawalls(int32_t bunch) if (gotswall == 0) { gotswall = 1; prepwall(z,wal); } wallscan(x1,x2,uplc,dplc,swall,lwall); - +#ifdef YAX_ENABLE + if ((wal->cstat&YAX_NEXTWALLBIT(YAX_FLOOR)) && globalposz > sec->floorz) + { + for (x=x1; x<=x2; x++) + if (dplc[x] > umost[x] && umost[x] <= dmost[x]) + { + umost[x] = dplc[x]; + if (umost[x] > dmost[x]) numhits--; + } + } + else if ((wal->cstat&YAX_NEXTWALLBIT(YAX_CEILING)) && globalposz < sec->ceilingz) + { + for (x=x1; x<=x2; x++) + if (uplc[x] < dmost[x] && umost[x] <= dmost[x]) + { + dmost[x] = uplc[x]; + if (umost[x] > dmost[x]) numhits--; + } + } + else +#endif for (x=x1; x<=x2; x++) if (umost[x] <= dmost[x]) { umost[x] = 1; dmost[x] = 0; numhits--; } @@ -7170,7 +7190,8 @@ int32_t wallvisible(int32_t x, int32_t y, int16_t wallnum) return (1); return (0); } -/* + +#if 0 // returns the intersection point between two lines _point2d intersection(_equation eq1, _equation eq2) { @@ -7236,7 +7257,7 @@ static inline void drawmaskleaf(_maskleaf* wall) //OSD_Printf("Drawing mask %i\n", wall->index); drawmaskwall(wall->index); } -*/ +#endif static inline int32_t sameside(_equation *eq, _point2d *p1, _point2d *p2) { diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 1779dcafe..058850908 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -7398,6 +7398,7 @@ static void Keys2d(void) tcursectornum = -1; for (i=0; i0) + if (/*!m32_sideview &&*/ numyaxbunches>0) { int32_t zsign=0, bestzdiff=INT32_MAX, hiz=0, loz=0, bottomp=0; @@ -7513,8 +7514,13 @@ static void Keys2d(void) bestzdiff = j; } - if (zsign==1 && bestzdiff==INT_MAX) - bottomp=1, bestzdiff = (hiz+1024 - pos.z); + if (bestzdiff==INT_MAX) + { + if (zsign == 1) + bottomp=1, bestzdiff = (hiz+(1024<<4) - pos.z); + else + bestzdiff = pos.z - loz; + } if (bestzdiff != INT32_MAX) { @@ -7824,14 +7830,14 @@ static void Keys2d(void) j = 0; x = wall[sector[i].wallptr].x; y = wall[sector[i].wallptr].y; - z = pos.z; + z = sector[i].floorz; break; case CORRUPT_WALL: i = k&(MAXWALLS-1); j = 1; x = wall[i].x; y = wall[i].y; - z = pos.z; + z = sector[sectorofwall(i)].floorz; break; case CORRUPT_SPRITE: i = k&(MAXSPRITES-1); @@ -7855,6 +7861,9 @@ static void Keys2d(void) pos.x = x; pos.y = y; pos.z = z; +#ifdef YAX_ENABLE + yax_updategrays(pos.z); +#endif } else x=editorgridextent+1; @@ -8010,6 +8019,7 @@ static void Keys2d(void) break; pos.x = wall[sector[j].wallptr].x; pos.y = wall[sector[j].wallptr].y; + pos.z = sector[j].floorz; printmessage16("Current pos now on sector %d's first wall-point", j); } break; @@ -8021,6 +8031,7 @@ static void Keys2d(void) break; pos.x = wall[j].x; pos.y = wall[j].y; + pos.z = sector[sectorofwall(j)].floorz; printmessage16("Current pos now on wall %d's point", j); } break; @@ -8030,6 +8041,7 @@ static void Keys2d(void) break; pos.x = sprite[j].x; pos.y = sprite[j].y; + pos.z = sprite[j].z; printmessage16("Current pos now on sprite %d", j); break; @@ -8039,6 +8051,9 @@ static void Keys2d(void) printmessage16("Current pos now (%d, %d)", pos.x, pos.y); break; } +#ifdef YAX_ENABLE + yax_updategrays(pos.z); +#endif } }// end key2d @@ -10980,7 +10995,38 @@ int32_t CheckMapCorruption(int32_t printfromlev, uint64_t tryfixing) if (nw>=w0 && nw<=endwall) CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTWALL is its own sector's wall", j); - +#ifdef YAX_ENABLE + { + int32_t cf, ynw, jp2, ynwp2; + for (cf=0; cf<1; cf++) + { + ynw = yax_getnextwall(j, cf); + if (ynw >= 0) + { + if (ynw >= numwalls) + CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL %d's YAX-NEXTWALL(%d)=%d out of range: numwalls=%d", + j, cf, ynw, numwalls); + else + { + if (j == ynw) + CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL %d's YAX-NEXTWALL(%d) is itself", + j, cf); + else if (wall[j].x != wall[ynw].x || wall[j].y != wall[ynw].y) + CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL %d's and its YAX-NEXTWALL(%d)=%d's coordinates not equal", + j, cf, ynw); + else + { + jp2 = wall[j].point2; + ynwp2 = wall[ynw].point2; + if (wall[jp2].x != wall[ynwp2].x || wall[jp2].y != wall[ynwp2].y) + CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL %d's and its YAX-NEXTWALL(%d)=%d's p2-coordinates not equal", + j, cf, ynw); + } + } + } + } + } +#endif if (ns == i) { if (!bad)