diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index 08e28c2dd..a97a66a3e 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -5,6 +5,7 @@ set( PCH_SOURCES src/actors_d.cpp src/actors_lava.cpp src/bowling.cpp + src/gamedef.cpp src/zz_actors.cpp src/sectors.cpp src/sectors_d.cpp diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index a546498c5..944d8f47a 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1577,7 +1577,7 @@ bool queball(int i, int pocket, int queball, int stripeball) if (x < 1596) { - // if(s->pal == 12) + // if(s->pal == 12) { j = getincangle(ps[p].getang(), getangle(s->x - ps[p].posx, s->y - ps[p].posy)); if (j > -64 && j < 64 && PlayerInput(p, SK_OPEN)) @@ -3174,7 +3174,7 @@ void handle_se30(int i, int JIBS6) l = nextspritesect[j]; if (sprite[j].statnum == 1 && badguy(&sprite[j]) && sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS) { - // if(sprite[j].sectnum != s->sectnum) + // if(sprite[j].sectnum != s->sectnum) { short k = sprite[j].sectnum; updatesector(sprite[j].x, sprite[j].y, &k); @@ -3289,18 +3289,18 @@ void handle_se03(int i) if (t[4] == 0) return; int x, p = findplayer(s, &x); - // if(t[5] > 0) { t[5]--; break; } + // if(t[5] > 0) { t[5]--; break; } if ((global_random / (sh + 1) & 31) < 4 && !t[2]) { - // t[5] = 4+(global_random&7); + // t[5] = 4+(global_random&7); sc->ceilingpal = s->owner >> 8; sc->floorpal = s->owner & 0xff; t[0] = s->shade + (global_random & 15); } else { - // t[5] = 4+(global_random&3); + // t[5] = 4+(global_random&3); sc->ceilingpal = s->pal; sc->floorpal = s->pal; t[0] = t[3]; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index e6c20807e..df3c59565 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1932,7 +1932,7 @@ void movetransports_d(void) switch (sprite[j].statnum) { - case STAT_PLAYER: // Player + case STAT_PLAYER: // Player if (sprite[j].owner != -1) { @@ -2009,7 +2009,7 @@ void movetransports_d(void) k = 0; if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].posz > (sector[sect].floorz - (16 << 8)) && (PlayerInput(p, SK_CROUCH) || ps[p].poszv > 2048)) - // if( onfloorz && sectlotag == 1 && ps[p].posz > (sector[sect].floorz-(6<<8)) ) + // if( onfloorz && sectlotag == 1 && ps[p].posz > (sector[sect].floorz-(6<<8)) ) { k = 1; if (screenpeek == p) @@ -2029,7 +2029,7 @@ void movetransports_d(void) if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].posz < (sector[sect].ceilingz + (6 << 8))) { k = 1; - // if( sprite[j].extra <= 0) break; + // if( sprite[j].extra <= 0) break; if (screenpeek == p) { FX_StopAllSounds(); @@ -2137,8 +2137,8 @@ void movetransports_d(void) break; case WATERBUBBLE: - // if( rnd(192) && sprite[j].picnum == WATERBUBBLE) - // break; + // if( rnd(192) && sprite[j].picnum == WATERBUBBLE) + // break; if (sectlotag > 0) { @@ -2470,8 +2470,8 @@ static void greenslime(int i) s->cstat &= 65535 - 8; s->picnum = GREENSLIME + 4; - // if(s->yrepeat > 62) - // guts(s,JIBS6,5,myconnectindex); + // if(s->yrepeat > 62) + // guts(s,JIBS6,5,myconnectindex); if (s->xrepeat > 32) s->xrepeat -= krand() & 7; if (s->yrepeat > 16) s->yrepeat -= krand() & 7; @@ -3453,7 +3453,7 @@ void moveeffectors_d(void) //STATNUM 3 if ((sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (hittype[j].temp_data[0] == t[0])) { sprite[j].xvel = s->xvel; - // if( t[4] == 1 ) + // if( t[4] == 1 ) { if (hittype[j].temp_data[5] == 0) hittype[j].temp_data[5] = dist(&sprite[j], s); diff --git a/source/games/duke/src/actors_lava.cpp b/source/games/duke/src/actors_lava.cpp index e18172b81..989be676d 100644 --- a/source/games/duke/src/actors_lava.cpp +++ b/source/games/duke/src/actors_lava.cpp @@ -72,105 +72,105 @@ static int windertime; void lava_cleararrays() { - jaildoorcnt = 0; - minecartcnt = 0; - torchcnt = 0; - lightnincnt = 0; + jaildoorcnt = 0; + minecartcnt = 0; + torchcnt = 0; + lightnincnt = 0; } void lava_serialize(FSerializer& arc) { - arc("torchcnt", torchcnt) - ("jaildoorcnt", jaildoorcnt) - ("minecartcnt", minecartcnt) - ("lightnincnt", lightnincnt); + arc("torchcnt", torchcnt) + ("jaildoorcnt", jaildoorcnt) + ("minecartcnt", minecartcnt) + ("lightnincnt", lightnincnt); - if (torchcnt) - arc.Array("torchsector", torchsector, torchcnt) - .Array("torchsectorshade", torchsectorshade, torchcnt) - .Array("torchtype", torchtype, torchcnt); + if (torchcnt) + arc.Array("torchsector", torchsector, torchcnt) + .Array("torchsectorshade", torchsectorshade, torchcnt) + .Array("torchtype", torchtype, torchcnt); - if (jaildoorcnt) - arc.Array("jaildoorsound", jaildoorsound, jaildoorcnt) - .Array("jaildoordrag", jaildoordrag, jaildoorcnt) - .Array("jaildoorspeed", jaildoorspeed, jaildoorcnt) - .Array("jaildoorsecthtag", jaildoorsecthtag, jaildoorcnt) - .Array("jaildoordist", jaildoordist, jaildoorcnt) - .Array("jaildoordir", jaildoordir, jaildoorcnt) - .Array("jaildooropen", jaildooropen, jaildoorcnt) - .Array("jaildoorsect", jaildoorsect, jaildoorcnt); + if (jaildoorcnt) + arc.Array("jaildoorsound", jaildoorsound, jaildoorcnt) + .Array("jaildoordrag", jaildoordrag, jaildoorcnt) + .Array("jaildoorspeed", jaildoorspeed, jaildoorcnt) + .Array("jaildoorsecthtag", jaildoorsecthtag, jaildoorcnt) + .Array("jaildoordist", jaildoordist, jaildoorcnt) + .Array("jaildoordir", jaildoordir, jaildoorcnt) + .Array("jaildooropen", jaildooropen, jaildoorcnt) + .Array("jaildoorsect", jaildoorsect, jaildoorcnt); - if (minecartcnt) - arc.Array("minecartdir", minecartdir, minecartcnt) - .Array("minecartspeed", minecartspeed, minecartcnt) - .Array("minecartchildsect", minecartchildsect, minecartcnt) - .Array("minecartsound", minecartsound, minecartcnt) - .Array("minecartdist", minecartdist, minecartcnt) - .Array("minecartdrag", minecartdrag, minecartcnt) - .Array("minecartopen", minecartopen, minecartcnt) - .Array("minecartsect", minecartsect, minecartcnt); + if (minecartcnt) + arc.Array("minecartdir", minecartdir, minecartcnt) + .Array("minecartspeed", minecartspeed, minecartcnt) + .Array("minecartchildsect", minecartchildsect, minecartcnt) + .Array("minecartsound", minecartsound, minecartcnt) + .Array("minecartdist", minecartdist, minecartcnt) + .Array("minecartdrag", minecartdrag, minecartcnt) + .Array("minecartopen", minecartopen, minecartcnt) + .Array("minecartsect", minecartsect, minecartcnt); - if (lightnincnt) - arc.Array("lightninsector", lightninsector, lightnincnt) - .Array("lightninsectorshade", lightninsectorshade, lightnincnt); + if (lightnincnt) + arc.Array("lightninsector", lightninsector, lightnincnt) + .Array("lightninsectorshade", lightninsectorshade, lightnincnt); - arc("brightness", brightness) - ("thunderflash", thunderflash) - ("thundertime", thundertime) - ("winderflash", winderflash) - ("windertime", windertime); + arc("brightness", brightness) + ("thunderflash", thunderflash) + ("thundertime", thundertime) + ("winderflash", winderflash) + ("windertime", windertime); } void addtorch(int i) { - if (torchcnt >= 64) - I_Error("Too many torch effects"); + if (torchcnt >= 64) + I_Error("Too many torch effects"); - torchsector[torchcnt] = sprite[i].sectnum; - torchsectorshade[torchcnt] = sector[sprite[i].sectnum].floorshade; - torchtype[torchcnt] = sprite[i].lotag; - torchcnt++; + torchsector[torchcnt] = sprite[i].sectnum; + torchsectorshade[torchcnt] = sector[sprite[i].sectnum].floorshade; + torchtype[torchcnt] = sprite[i].lotag; + torchcnt++; } void addlightning(int i) { - if (lightnincnt >= 64) - I_Error("Too many lightnin effects"); + if (lightnincnt >= 64) + I_Error("Too many lightnin effects"); - lightninsector[lightnincnt] = sprite[i].sectnum; - lightninsectorshade[lightnincnt] = sector[sprite[i].sectnum].floorshade; - lightnincnt++; + lightninsector[lightnincnt] = sprite[i].sectnum; + lightninsectorshade[lightnincnt] = sector[sprite[i].sectnum].floorshade; + lightnincnt++; } void addjaildoor(int p1, int p2, int iht, int jlt, int p3, int j) { - if (jaildoorcnt >= 32) - I_Error("Too many jaildoor sectors"); + if (jaildoorcnt >= 32) + I_Error("Too many jaildoor sectors"); - jaildoordist[jaildoorcnt] = p1; - jaildoorspeed[jaildoorcnt] = p2; - jaildoorsecthtag[jaildoorcnt] = iht; - jaildoorsect[jaildoorcnt] = j; - jaildoordrag[jaildoorcnt] = 0; - jaildooropen[jaildoorcnt] = 0; - jaildoordir[jaildoorcnt] = jlt; - jaildoorsound[jaildoorcnt] = p3; - jaildoorcnt++; + jaildoordist[jaildoorcnt] = p1; + jaildoorspeed[jaildoorcnt] = p2; + jaildoorsecthtag[jaildoorcnt] = iht; + jaildoorsect[jaildoorcnt] = j; + jaildoordrag[jaildoorcnt] = 0; + jaildooropen[jaildoorcnt] = 0; + jaildoordir[jaildoorcnt] = jlt; + jaildoorsound[jaildoorcnt] = p3; + jaildoorcnt++; } void addminecart(int p1, int p2, int i, int iht, int p3, int childsectnum) { - if (minecartcnt >= 16) - G_GameExit("\nToo many minecart sectors"); - minecartdist[minecartcnt] = p1; - minecartspeed[minecartcnt] = p2; - minecartsect[minecartcnt] = i; - minecartdir[minecartcnt] = sector[i].hitag; - minecartdrag[minecartcnt] = p1; - minecartopen[minecartcnt] = 1; - minecartsound[minecartcnt] = p3; - minecartchildsect[minecartcnt] = childsectnum; - minecartcnt++; + if (minecartcnt >= 16) + G_GameExit("\nToo many minecart sectors"); + minecartdist[minecartcnt] = p1; + minecartspeed[minecartcnt] = p2; + minecartsect[minecartcnt] = i; + minecartdir[minecartcnt] = sector[i].hitag; + minecartdrag[minecartcnt] = p1; + minecartopen[minecartcnt] = 1; + minecartsound[minecartcnt] = p3; + minecartchildsect[minecartcnt] = childsectnum; + minecartcnt++; } //--------------------------------------------------------------------------- @@ -181,57 +181,57 @@ void addminecart(int p1, int p2, int i, int iht, int p3, int childsectnum) void dotorch(void) { - int ds; - short j; - short startwall, endwall; - char shade; - ds = krand()&8; - for (int i = 0; i < torchcnt; i++) - { - shade = torchsectorshade[i] - ds; - switch (torchtype[i]) - { - case 0: - sector[torchsector[i]].floorshade = shade; - sector[torchsector[i]].ceilingshade = shade; - break; - case 1: - sector[torchsector[i]].ceilingshade = shade; - break; - case 2: - sector[torchsector[i]].floorshade = shade; - break; - case 4: - sector[torchsector[i]].ceilingshade = shade; - break; - case 5: - sector[torchsector[i]].floorshade = shade; - break; - } - startwall = sector[torchsector[i]].wallptr; - endwall = startwall + sector[torchsector[i]].wallnum; - for (j = startwall; j < endwall; j++) - { - if (wall[j].lotag != 1) - { - switch (torchtype[i]) - { - case 0: - wall[j].shade = shade; - break; - case 1: - wall[j].shade = shade; - break; - case 2: - wall[j].shade = shade; - break; - case 3: - wall[j].shade = shade; - break; - } - } - } - } + int ds; + short j; + short startwall, endwall; + char shade; + ds = krand()&8; + for (int i = 0; i < torchcnt; i++) + { + shade = torchsectorshade[i] - ds; + switch (torchtype[i]) + { + case 0: + sector[torchsector[i]].floorshade = shade; + sector[torchsector[i]].ceilingshade = shade; + break; + case 1: + sector[torchsector[i]].ceilingshade = shade; + break; + case 2: + sector[torchsector[i]].floorshade = shade; + break; + case 4: + sector[torchsector[i]].ceilingshade = shade; + break; + case 5: + sector[torchsector[i]].floorshade = shade; + break; + } + startwall = sector[torchsector[i]].wallptr; + endwall = startwall + sector[torchsector[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + if (wall[j].lotag != 1) + { + switch (torchtype[i]) + { + case 0: + wall[j].shade = shade; + break; + case 1: + wall[j].shade = shade; + break; + case 2: + wall[j].shade = shade; + break; + case 3: + wall[j].shade = shade; + break; + } + } + } + } } //--------------------------------------------------------------------------- @@ -242,123 +242,123 @@ void dotorch(void) void dojaildoor(void) { - int j; - int startwall, endwall; - int x, y; - int speed; - for (int i = 0; i < jaildoorcnt; i++) - { - if (numplayers > 2) - speed = jaildoorspeed[i]; - else - speed = jaildoorspeed[i]; - if (speed < 2) - speed = 2; - if (jaildooropen[i] == 1) - { - jaildoordrag[i] -= speed; - if (jaildoordrag[i] <= 0) - { - jaildoordrag[i] = 0; - jaildooropen[i] = 2; - switch (jaildoordir[i]) - { - case 10: - jaildoordir[i] = 30; - break; - case 20: - jaildoordir[i] = 40; - break; - case 30: - jaildoordir[i] = 10; - break; - case 40: - jaildoordir[i] = 20; - break; - } - } - else - { - startwall = sector[jaildoorsect[i]].wallptr; - endwall = startwall + sector[jaildoorsect[i]].wallnum; - for (j = startwall; j < endwall; j++) - { - switch (jaildoordir[i]) - { - case 10: - x = wall[j].x; - y = wall[j].y + speed; - break; - case 20: - x = wall[j].x - speed; - y = wall[j].y; - break; - case 30: - x = wall[j].x; - y = wall[j].y - speed; - break; - case 40: - x = wall[j].x + speed; - y = wall[j].y; - break; - } - dragpoint(j,x,y); - } - } - } - if (jaildooropen[i] == 3) - { - jaildoordrag[i] -= speed; - if (jaildoordrag[i] <= 0) - { - jaildoordrag[i] = 0; - jaildooropen[i] = 0; - switch (jaildoordir[i]) - { - case 10: - jaildoordir[i] = 30; - break; - case 20: - jaildoordir[i] = 40; - break; - case 30: - jaildoordir[i] = 10; - break; - case 40: - jaildoordir[i] = 20; - break; - } - } - else - { - startwall = sector[jaildoorsect[i]].wallptr; - endwall = startwall + sector[jaildoorsect[i]].wallnum; - for (j = startwall; j < endwall; j++) - { - switch (jaildoordir[i]) - { - case 10: - x = wall[j].x; - y = wall[j].y + speed; - break; - case 20: - x = wall[j].x - speed; - y = wall[j].y; - break; - case 30: - x = wall[j].x; - y = wall[j].y - speed; - break; - case 40: - x = wall[j].x + speed; - y = wall[j].y; - break; - } - dragpoint(j,x,y); - } - } - } - } + int j; + int startwall, endwall; + int x, y; + int speed; + for (int i = 0; i < jaildoorcnt; i++) + { + if (numplayers > 2) + speed = jaildoorspeed[i]; + else + speed = jaildoorspeed[i]; + if (speed < 2) + speed = 2; + if (jaildooropen[i] == 1) + { + jaildoordrag[i] -= speed; + if (jaildoordrag[i] <= 0) + { + jaildoordrag[i] = 0; + jaildooropen[i] = 2; + switch (jaildoordir[i]) + { + case 10: + jaildoordir[i] = 30; + break; + case 20: + jaildoordir[i] = 40; + break; + case 30: + jaildoordir[i] = 10; + break; + case 40: + jaildoordir[i] = 20; + break; + } + } + else + { + startwall = sector[jaildoorsect[i]].wallptr; + endwall = startwall + sector[jaildoorsect[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + switch (jaildoordir[i]) + { + case 10: + x = wall[j].x; + y = wall[j].y + speed; + break; + case 20: + x = wall[j].x - speed; + y = wall[j].y; + break; + case 30: + x = wall[j].x; + y = wall[j].y - speed; + break; + case 40: + x = wall[j].x + speed; + y = wall[j].y; + break; + } + dragpoint(j,x,y); + } + } + } + if (jaildooropen[i] == 3) + { + jaildoordrag[i] -= speed; + if (jaildoordrag[i] <= 0) + { + jaildoordrag[i] = 0; + jaildooropen[i] = 0; + switch (jaildoordir[i]) + { + case 10: + jaildoordir[i] = 30; + break; + case 20: + jaildoordir[i] = 40; + break; + case 30: + jaildoordir[i] = 10; + break; + case 40: + jaildoordir[i] = 20; + break; + } + } + else + { + startwall = sector[jaildoorsect[i]].wallptr; + endwall = startwall + sector[jaildoorsect[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + switch (jaildoordir[i]) + { + case 10: + x = wall[j].x; + y = wall[j].y + speed; + break; + case 20: + x = wall[j].x - speed; + y = wall[j].y; + break; + case 30: + x = wall[j].x; + y = wall[j].y - speed; + break; + case 40: + x = wall[j].x + speed; + y = wall[j].y; + break; + } + dragpoint(j,x,y); + } + } + } + } } //--------------------------------------------------------------------------- @@ -369,295 +369,295 @@ void dojaildoor(void) void moveminecart(void) { - short i; - short j; - short csect; - short startwall; - short endwall; - int speed; - int y; - int x; - short nextj; - int cx; - int cy; - int max_x; - int min_y; - int max_y; - int min_x; - for (i = 0; i < minecartcnt; i++) - { - speed = minecartspeed[i]; - if (speed < 2) - speed = 2; + short i; + short j; + short csect; + short startwall; + short endwall; + int speed; + int y; + int x; + short nextj; + int cx; + int cy; + int max_x; + int min_y; + int max_y; + int min_x; + for (i = 0; i < minecartcnt; i++) + { + speed = minecartspeed[i]; + if (speed < 2) + speed = 2; - if (minecartopen[i] == 1) - { - minecartdrag[i] -= speed; - if (minecartdrag[i] <= 0) - { - minecartdrag[i] = minecartdist[i]; - minecartopen[i] = 2; - switch (minecartdir[i]) - { - case 10: - minecartdir[i] = 30; - break; - case 20: - minecartdir[i] = 40; - break; - case 30: - minecartdir[i] = 10; - break; - case 40: - minecartdir[i] = 20; - break; - } - } - else - { - startwall = sector[minecartsect[i]].wallptr; - endwall = startwall + sector[minecartsect[i]].wallnum; - for (j = startwall; j < endwall; j++) - { - switch (minecartdir[i]) - { - case 10: - x = wall[j].x; - y = wall[j].y + speed; - break; - case 20: - x = wall[j].x - speed; - y = wall[j].y; - break; - case 30: - x = wall[j].x; - y = wall[j].y - speed; - break; - case 40: - x = wall[j].x + speed; - y = wall[j].y; - break; - } - dragpoint(j,x,y); - } - } - } - if (minecartopen[i] == 2) - { - minecartdrag[i] -= speed; - if (minecartdrag[i] <= 0) - { - minecartdrag[i] = minecartdist[i]; - minecartopen[i] = 1; - switch (minecartdir[i]) - { - case 10: - minecartdir[i] = 30; - break; - case 20: - minecartdir[i] = 40; - break; - case 30: - minecartdir[i] = 10; - break; - case 40: - minecartdir[i] = 20; - break; - } - } - else - { - startwall = sector[minecartsect[i]].wallptr; - endwall = startwall + sector[minecartsect[i]].wallnum; - for (j = startwall; j < endwall; j++) - { - switch (minecartdir[i]) - { - case 10: - x = wall[j].x; - y = wall[j].y + speed; - break; - case 20: - x = wall[j].x - speed; - y = wall[j].y; - break; - case 30: - x = wall[j].x; - y = wall[j].y - speed; - break; - case 40: - x = wall[j].x + speed; - y = wall[j].y; - break; - } - dragpoint(j,x,y); - } - } - } - csect = minecartchildsect[i]; - startwall = sector[csect].wallptr; - endwall = startwall + sector[csect].wallnum; - max_x = max_y = -0x20000; - min_x = min_y = 0x20000; - for (j = startwall; j < endwall; j++) - { - x = wall[j].x; - y = wall[j].y; - if (x > max_x) - max_x = x; - if (y > max_y) - max_y = y; - if (x < min_x) - min_x = x; - if (y < min_y) - min_y = y; - } - cx = (max_x + min_x) >> 1; - cy = (max_y + min_y) >> 1; - j = headspritesect[csect]; - while (j != -1) - { - nextj = nextspritesect[j]; - if (badguy(&sprite[j])) - setsprite(j,cx,cy,sprite[j].z); - j = nextj; - } - } + if (minecartopen[i] == 1) + { + minecartdrag[i] -= speed; + if (minecartdrag[i] <= 0) + { + minecartdrag[i] = minecartdist[i]; + minecartopen[i] = 2; + switch (minecartdir[i]) + { + case 10: + minecartdir[i] = 30; + break; + case 20: + minecartdir[i] = 40; + break; + case 30: + minecartdir[i] = 10; + break; + case 40: + minecartdir[i] = 20; + break; + } + } + else + { + startwall = sector[minecartsect[i]].wallptr; + endwall = startwall + sector[minecartsect[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + switch (minecartdir[i]) + { + case 10: + x = wall[j].x; + y = wall[j].y + speed; + break; + case 20: + x = wall[j].x - speed; + y = wall[j].y; + break; + case 30: + x = wall[j].x; + y = wall[j].y - speed; + break; + case 40: + x = wall[j].x + speed; + y = wall[j].y; + break; + } + dragpoint(j,x,y); + } + } + } + if (minecartopen[i] == 2) + { + minecartdrag[i] -= speed; + if (minecartdrag[i] <= 0) + { + minecartdrag[i] = minecartdist[i]; + minecartopen[i] = 1; + switch (minecartdir[i]) + { + case 10: + minecartdir[i] = 30; + break; + case 20: + minecartdir[i] = 40; + break; + case 30: + minecartdir[i] = 10; + break; + case 40: + minecartdir[i] = 20; + break; + } + } + else + { + startwall = sector[minecartsect[i]].wallptr; + endwall = startwall + sector[minecartsect[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + switch (minecartdir[i]) + { + case 10: + x = wall[j].x; + y = wall[j].y + speed; + break; + case 20: + x = wall[j].x - speed; + y = wall[j].y; + break; + case 30: + x = wall[j].x; + y = wall[j].y - speed; + break; + case 40: + x = wall[j].x + speed; + y = wall[j].y; + break; + } + dragpoint(j,x,y); + } + } + } + csect = minecartchildsect[i]; + startwall = sector[csect].wallptr; + endwall = startwall + sector[csect].wallnum; + max_x = max_y = -0x20000; + min_x = min_y = 0x20000; + for (j = startwall; j < endwall; j++) + { + x = wall[j].x; + y = wall[j].y; + if (x > max_x) + max_x = x; + if (y > max_y) + max_y = y; + if (x < min_x) + min_x = x; + if (y < min_y) + min_y = y; + } + cx = (max_x + min_x) >> 1; + cy = (max_y + min_y) >> 1; + j = headspritesect[csect]; + while (j != -1) + { + nextj = nextspritesect[j]; + if (badguy(&sprite[j])) + setsprite(j,cx,cy,sprite[j].z); + j = nextj; + } + } } void operatejaildoors(int hitag) { - for (int i = 0; i < jaildoorcnt; i++) - { - if (jaildoorsecthtag[i] == hitag) - { - if (jaildooropen[i] == 0) - { - jaildooropen[i] = 1; - jaildoordrag[i] = jaildoordist[i]; - if (!isRRRA() || jaildoorsound[i] != 0) - spritesound(jaildoorsound[i], ps[screenpeek].i); - } - if (jaildooropen[i] == 2) - { - jaildooropen[i] = 3; - jaildoordrag[i] = jaildoordist[i]; - if (!isRRRA() || jaildoorsound[i] != 0) - spritesound(jaildoorsound[i], ps[screenpeek].i); - } - } - } + for (int i = 0; i < jaildoorcnt; i++) + { + if (jaildoorsecthtag[i] == hitag) + { + if (jaildooropen[i] == 0) + { + jaildooropen[i] = 1; + jaildoordrag[i] = jaildoordist[i]; + if (!isRRRA() || jaildoorsound[i] != 0) + spritesound(jaildoorsound[i], ps[screenpeek].i); + } + if (jaildooropen[i] == 2) + { + jaildooropen[i] = 3; + jaildoordrag[i] = jaildoordist[i]; + if (!isRRRA() || jaildoorsound[i] != 0) + spritesound(jaildoorsound[i], ps[screenpeek].i); + } + } + } } void thunder(void) { - struct player_struct* p; - int r1, r2; - short startwall, endwall, i, j; - unsigned char shade; + struct player_struct* p; + int r1, r2; + short startwall, endwall, i, j; + unsigned char shade; - p = &ps[screenpeek]; + p = &ps[screenpeek]; - if (!thunderflash) - { - if ((gotpic[RRTILE2577 >> 3] & (1 << (RRTILE2577 & 7))) > 0) - { - gotpic[RRTILE2577 >> 3] &= ~(1 << (RRTILE2577 & 7)); - g_visibility = 256; // this is an engine variable - if (krand() > 65000) - { - thunderflash = 1; - thundertime = 256; - sound(351 + (rand() % 3)); - } - } - else - { - g_visibility = p->visibility; - brightness = ud.brightness >> 2; - } - } - else - { - thundertime -= 4; - if (thundertime < 0) - { - thunderflash = 0; - brightness = ud.brightness >> 2; - videoSetBrightness(brightness); - g_visibility = p->visibility; - } - } - if (!winderflash) - { - if ((gotpic[RRTILE2562 >> 3] & (1 << (RRTILE2562 & 7))) > 0) - { - gotpic[RRTILE2562 >> 3] &= ~(1 << (RRTILE2562 & 7)); - if (krand() > 65000) - { - winderflash = 1; - windertime = 128; - sound(351 + (rand() % 3)); - } - } - } - else - { - windertime -= 4; - if (windertime < 0) - { - winderflash = 0; - for (i = 0; i < lightnincnt; i++) - { - startwall = sector[lightninsector[i]].wallptr; - endwall = startwall + sector[lightninsector[i]].wallnum; - sector[lightninsector[i]].floorshade = lightninsectorshade[i]; - sector[lightninsector[i]].ceilingshade = lightninsectorshade[i]; - for (j = startwall; j < endwall; j++) - wall[j].shade = lightninsectorshade[i]; - } - } - } - if (thunderflash == 1) - { - r1 = krand() & 4; - brightness += r1; - switch (r1) - { - case 0: - g_visibility = 2048; - break; - case 1: - g_visibility = 1024; - break; - case 2: - g_visibility = 512; - break; - case 3: - g_visibility = 256; - break; - default: - g_visibility = 4096; - break; - } - if (brightness > 8) - brightness = 0; - videoSetBrightness(brightness); - } - if (winderflash == 1) - { - r2 = krand() & 8; - shade = torchsectorshade[i] + r2; - for (i = 0; i < lightnincnt; i++) - { - startwall = sector[lightninsector[i]].wallptr; - endwall = startwall + sector[lightninsector[i]].wallnum; - sector[lightninsector[i]].floorshade = lightninsectorshade[i] - shade; - sector[lightninsector[i]].ceilingshade = lightninsectorshade[i] - shade; - for (j = startwall; j < endwall; j++) - wall[j].shade = lightninsectorshade[i] - shade; - } - } + if (!thunderflash) + { + if ((gotpic[RRTILE2577 >> 3] & (1 << (RRTILE2577 & 7))) > 0) + { + gotpic[RRTILE2577 >> 3] &= ~(1 << (RRTILE2577 & 7)); + g_visibility = 256; // this is an engine variable + if (krand() > 65000) + { + thunderflash = 1; + thundertime = 256; + sound(351 + (rand() % 3)); + } + } + else + { + g_visibility = p->visibility; + brightness = ud.brightness >> 2; + } + } + else + { + thundertime -= 4; + if (thundertime < 0) + { + thunderflash = 0; + brightness = ud.brightness >> 2; + videoSetBrightness(brightness); + g_visibility = p->visibility; + } + } + if (!winderflash) + { + if ((gotpic[RRTILE2562 >> 3] & (1 << (RRTILE2562 & 7))) > 0) + { + gotpic[RRTILE2562 >> 3] &= ~(1 << (RRTILE2562 & 7)); + if (krand() > 65000) + { + winderflash = 1; + windertime = 128; + sound(351 + (rand() % 3)); + } + } + } + else + { + windertime -= 4; + if (windertime < 0) + { + winderflash = 0; + for (i = 0; i < lightnincnt; i++) + { + startwall = sector[lightninsector[i]].wallptr; + endwall = startwall + sector[lightninsector[i]].wallnum; + sector[lightninsector[i]].floorshade = lightninsectorshade[i]; + sector[lightninsector[i]].ceilingshade = lightninsectorshade[i]; + for (j = startwall; j < endwall; j++) + wall[j].shade = lightninsectorshade[i]; + } + } + } + if (thunderflash == 1) + { + r1 = krand() & 4; + brightness += r1; + switch (r1) + { + case 0: + g_visibility = 2048; + break; + case 1: + g_visibility = 1024; + break; + case 2: + g_visibility = 512; + break; + case 3: + g_visibility = 256; + break; + default: + g_visibility = 4096; + break; + } + if (brightness > 8) + brightness = 0; + videoSetBrightness(brightness); + } + if (winderflash == 1) + { + r2 = krand() & 8; + shade = torchsectorshade[i] + r2; + for (i = 0; i < lightnincnt; i++) + { + startwall = sector[lightninsector[i]].wallptr; + endwall = startwall + sector[lightninsector[i]].wallnum; + sector[lightninsector[i]].floorshade = lightninsectorshade[i] - shade; + sector[lightninsector[i]].ceilingshade = lightninsectorshade[i] - shade; + for (j = startwall; j < endwall; j++) + wall[j].shade = lightninsectorshade[i] - shade; + } + } } END_DUKE_NS diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 7023a788f..5740752d9 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -171,17 +171,17 @@ void addweapon_r(struct player_struct* p, int weapon) case SLINGBLADE_WEAPON: if (!isRRRA()) break; case KNEE_WEAPON: - case DYNAMITE_WEAPON: + case DYNAMITE_WEAPON: case TRIPBOMB_WEAPON: case HANDREMOTE_WEAPON: break; - case SHOTGUN_WEAPON: + case SHOTGUN_WEAPON: spritesound(SHOTGUN_COCK, p->i); break; - case PISTOL_WEAPON: + case PISTOL_WEAPON: spritesound(INSERT_CLIP, p->i); break; - default: + default: spritesound(EJECT_CLIP, p->i); break; } @@ -1691,7 +1691,7 @@ void movetransports_r(void) switch (sprite[j].statnum) { - case STAT_PLAYER: // Player + case STAT_PLAYER: // Player if (sprite[j].owner != -1) { @@ -2978,12 +2978,12 @@ static int henstand(int i) void moveactors_r(void) { - int x, nexti; - int j, sect, p; - spritetype *s; - - dojaildoor(); - moveminecart(); + int x, nexti; + int j, sect, p; + spritetype *s; + + dojaildoor(); + moveminecart(); if (isRRRA()) { @@ -2991,176 +2991,176 @@ void moveactors_r(void) } rr_specialstats(); - for (int i = headspritestat[STAT_ACTOR]; i >= 0; i = nexti) - { - nexti = nextspritestat[i]; + for (int i = headspritestat[STAT_ACTOR]; i >= 0; i = nexti) + { + nexti = nextspritestat[i]; bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites. - s = &sprite[i]; + s = &sprite[i]; - sect = s->sectnum; + sect = s->sectnum; - if( s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS) + if( s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS) { deletesprite(i); continue; } - auto t = &hittype[i].temp_data[0]; + auto t = &hittype[i].temp_data[0]; - hittype[i].bposx = s->x; - hittype[i].bposy = s->y; - hittype[i].bposz = s->z; + hittype[i].bposx = s->x; + hittype[i].bposy = s->y; + hittype[i].bposz = s->z; - switch(s->picnum) - { - case RESPAWNMARKERRED: - case RESPAWNMARKERYELLOW: - case RESPAWNMARKERGREEN: + switch(s->picnum) + { + case RESPAWNMARKERRED: + case RESPAWNMARKERYELLOW: + case RESPAWNMARKERGREEN: if (!respawnmarker(i, RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue; break; - case RAT: + case RAT: if (!rat(i, !isRRRA())) continue; - break; - case RRTILE3190: - case RRTILE3191: - case RRTILE3192: - if (!chickenplant) + break; + case RRTILE3190: + case RRTILE3191: + case RRTILE3192: + if (!chickenplant) { deletesprite(i); continue; } - if (sector[sprite[i].sectnum].lotag == 903) - makeitfall(i); - j = movesprite(i, - (s->xvel*sintable[(s->ang+512)&2047])>>14, - (s->xvel*sintable[s->ang&2047])>>14, - s->zvel,CLIPMASK0); - switch (sector[sprite[i].sectnum].lotag) - { - case 901: - sprite[i].picnum = RRTILE3191; - break; - case 902: - sprite[i].picnum = RRTILE3192; - break; - case 903: - if (sprite[i].z >= sector[sprite[i].sectnum].floorz - (8<<8)) + if (sector[sprite[i].sectnum].lotag == 903) + makeitfall(i); + j = movesprite(i, + (s->xvel*sintable[(s->ang+512)&2047])>>14, + (s->xvel*sintable[s->ang&2047])>>14, + s->zvel,CLIPMASK0); + switch (sector[sprite[i].sectnum].lotag) + { + case 901: + sprite[i].picnum = RRTILE3191; + break; + case 902: + sprite[i].picnum = RRTILE3192; + break; + case 903: + if (sprite[i].z >= sector[sprite[i].sectnum].floorz - (8<<8)) { deletesprite(i); continue; } - break; - case 904: + break; + case 904: deletesprite(i); continue; - break; - } + break; + } if ((j & 32768) == 32768) { deletesprite(i); continue; } - break; + break; - case RRTILE3120: - case RRTILE3122: - case RRTILE3123: - case RRTILE3124: - if (!chickenplant) + case RRTILE3120: + case RRTILE3122: + case RRTILE3123: + case RRTILE3124: + if (!chickenplant) { deletesprite(i); continue; } - makeitfall(i); - j = movesprite(i, - (s->xvel*(sintable[(s->ang+512)&2047]))>>14, - (s->xvel*(sintable[s->ang&2047]))>>14, - s->zvel,CLIPMASK0); + makeitfall(i); + j = movesprite(i, + (s->xvel*(sintable[(s->ang+512)&2047]))>>14, + (s->xvel*(sintable[s->ang&2047]))>>14, + s->zvel,CLIPMASK0); if ((j & 32768) == 32768) { deletesprite(i); continue; } - if (sector[s->sectnum].lotag == 903) - { - if (sprite[i].z >= sector[sprite[i].sectnum].floorz - (4<<8)) + if (sector[s->sectnum].lotag == 903) + { + if (sprite[i].z >= sector[sprite[i].sectnum].floorz - (4<<8)) { deletesprite(i); continue; } - } - else if (sector[s->sectnum].lotag == 904) + } + else if (sector[s->sectnum].lotag == 904) { deletesprite(i); continue; } - break; + break; - case RRTILE3132: - if (!chickenplant) + case RRTILE3132: + if (!chickenplant) { deletesprite(i); continue; } - makeitfall(i); - j = movesprite(i, - (s->xvel*sintable[(s->ang+512)&2047])>>14, - (s->xvel*sintable[s->ang&2047])>>14, - s->zvel,CLIPMASK0); - if (s->z >= sector[s->sectnum].floorz - (8<<8)) - { - if (sector[s->sectnum].lotag == 1) - { - j = spawn(i,WATERSPLASH2); - sprite[j].z = sector[sprite[j].sectnum].floorz; - } + makeitfall(i); + j = movesprite(i, + (s->xvel*sintable[(s->ang+512)&2047])>>14, + (s->xvel*sintable[s->ang&2047])>>14, + s->zvel,CLIPMASK0); + if (s->z >= sector[s->sectnum].floorz - (8<<8)) + { + if (sector[s->sectnum].lotag == 1) + { + j = spawn(i,WATERSPLASH2); + sprite[j].z = sector[sprite[j].sectnum].floorz; + } deletesprite(i); continue; - } - break; - case BOWLINGBALL: - if (s->xvel) - { - if(!S_CheckSoundPlaying(356)) - spritesound(356,i); - } - else - { - spawn(i,BOWLINGBALLSPRITE); + } + break; + case BOWLINGBALL: + if (s->xvel) + { + if(!S_CheckSoundPlaying(356)) + spritesound(356,i); + } + else + { + spawn(i,BOWLINGBALLSPRITE); deletesprite(i); continue; - } - if (sector[s->sectnum].lotag == 900) - { - S_StopEnvSound(356, -1); - } - case RRTILE3440: - case RRTILE3440+1: - case HENSTAND: - case HENSTAND+1: + } + if (sector[s->sectnum].lotag == 900) + { + S_StopEnvSound(356, -1); + } + case RRTILE3440: + case RRTILE3440+1: + case HENSTAND: + case HENSTAND+1: { int todo = henstand(i); if (todo == 2) deleteafterexecute = true; if (todo == 1) continue; - break; + break; } - case QUEBALL: - case STRIPEBALL: + case QUEBALL: + case STRIPEBALL: if (!queball(i, POCKET, QUEBALL, STRIPEBALL)) continue; - break; - case FORCESPHERE: + break; + case FORCESPHERE: forcesphere(i, FORCESPHERE); - continue; + continue; - case RECON: - case UFO1_RR: - case UFO2: - case UFO3: - case UFO4: - case UFO5: + case RECON: + case UFO1_RR: + case UFO2: + case UFO3: + case UFO4: + case UFO5: recon(i, EXPLOSION2, FIRELASER, -1, -1, 457, 8, [](int i) ->int { auto s = &sprite[i]; @@ -3178,30 +3178,30 @@ void moveactors_r(void) return BILLYRAY; else return -1; }); - continue; + continue; - case OOZ: + case OOZ: ooz(i); - continue; + continue; - case EMPTYBIKE: - if (!isRRRA()) break; - makeitfall(i); - getglobalz(i); - if (sector[sect].lotag == 1) - { - setsprite(i,s->x,s->y,hittype[i].floorz+(16<<8)); - } - break; - - case EMPTYBOAT: + case EMPTYBIKE: if (!isRRRA()) break; makeitfall(i); - getglobalz(i); - break; + getglobalz(i); + if (sector[sect].lotag == 1) + { + setsprite(i,s->x,s->y,hittype[i].floorz+(16<<8)); + } + break; - case TRIPBOMBSPRITE: - if (!isRRRA() || (sector[sect].lotag != 1 && sector[sect].lotag != 160)) + case EMPTYBOAT: + if (!isRRRA()) break; + makeitfall(i); + getglobalz(i); + break; + + case TRIPBOMBSPRITE: + if (!isRRRA() || (sector[sect].lotag != 1 && sector[sect].lotag != 160)) if (s->xvel) { j = movesprite(i, @@ -3210,47 +3210,47 @@ void moveactors_r(void) s->zvel,CLIPMASK0); s->xvel--; } - break; + break; case CHEERBOMB: if (!isRRRA()) break; case MORTER: - case HEAVYHBOMB: + case HEAVYHBOMB: heavyhbomb(i); - continue; - - case REACTORBURNT: - case REACTOR2BURNT: - continue; + continue; + + case REACTORBURNT: + case REACTOR2BURNT: + continue; - case REACTOR: - case REACTOR2: + case REACTOR: + case REACTOR2: reactor(i, REACTOR, REACTOR2, REACTOR2BURNT, REACTOR2BURNT); - continue; + continue; - case RR_CAMERA1: + case RR_CAMERA1: camera(i); - continue; - } + continue; + } // #ifndef VOLOMEONE - if( ud.multimode < 2 && badguy(s) ) - { - if( actor_tog == 1) - { - s->cstat = (short)32768; - continue; - } - else if(actor_tog == 2) s->cstat = 257; - } + if( ud.multimode < 2 && badguy(s) ) + { + if( actor_tog == 1) + { + s->cstat = (short)32768; + continue; + } + else if(actor_tog == 2) s->cstat = 257; + } // #endif - p = findplayer(s,&x); + p = findplayer(s,&x); - execute(i,p,x); + execute(i,p,x); if (deleteafterexecute) deletesprite(i); - } + } } @@ -3617,7 +3617,7 @@ void moveeffectors_r(void) //STATNUM 3 if ((sprite[j].lotag == 14) && (sh == sprite[j].hitag) && (hittype[j].temp_data[0] == t[0])) { sprite[j].xvel = s->xvel; - // if( t[4] == 1 ) + // if( t[4] == 1 ) { if (hittype[j].temp_data[5] == 0) hittype[j].temp_data[5] = dist(&sprite[j], s); diff --git a/source/games/duke/src/bowling.cpp b/source/games/duke/src/bowling.cpp index 38ea2915e..392699518 100644 --- a/source/games/duke/src/bowling.cpp +++ b/source/games/duke/src/bowling.cpp @@ -37,304 +37,304 @@ short pinsectorresetdown(short sect); void ballreturn(short spr) { - short j, i, nexti, nextj; - i = headspritestat[105]; - while (i >= 0) - { - nexti = nextspritestat[i]; - if (sprite[i].picnum == RRTILE281) - if (sprite[spr].sectnum == sprite[i].sectnum) - { - j = headspritestat[105]; - while (j >= 0) - { - nextj = nextspritestat[j]; - if (sprite[j].picnum == RRTILE282) - if (sprite[i].hitag == sprite[j].hitag) - spawn(j, BOWLINGBALLSPRITE); - if (sprite[j].picnum == RRTILE280) - if (sprite[i].hitag == sprite[j].hitag) - if (sprite[j].lotag == 0) - { - sprite[j].lotag = 100; - sprite[j].extra++; - pinsectorresetdown(sprite[j].sectnum); - } - j = nextj; - } - } + short j, i, nexti, nextj; + i = headspritestat[105]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].picnum == RRTILE281) + if (sprite[spr].sectnum == sprite[i].sectnum) + { + j = headspritestat[105]; + while (j >= 0) + { + nextj = nextspritestat[j]; + if (sprite[j].picnum == RRTILE282) + if (sprite[i].hitag == sprite[j].hitag) + spawn(j, BOWLINGBALLSPRITE); + if (sprite[j].picnum == RRTILE280) + if (sprite[i].hitag == sprite[j].hitag) + if (sprite[j].lotag == 0) + { + sprite[j].lotag = 100; + sprite[j].extra++; + pinsectorresetdown(sprite[j].sectnum); + } + j = nextj; + } + } - i = nexti; - } + i = nexti; + } } short pinsectorresetdown(short sect) { - int vel, j; - - j = getanimationgoal(§or[sect].ceilingz); + int vel, j; + + j = getanimationgoal(§or[sect].ceilingz); - if (j == -1) - { - j = sector[sect].floorz; - vel = 64; - setanimation(sect,§or[sect].ceilingz,j,vel); - return 1; - } - return 0; + if (j == -1) + { + j = sector[sect].floorz; + vel = 64; + setanimation(sect,§or[sect].ceilingz,j,vel); + return 1; + } + return 0; } short pinsectorresetup(short sect) { - int vel, j; - - j = getanimationgoal(§or[sect].ceilingz); + int vel, j; + + j = getanimationgoal(§or[sect].ceilingz); - if (j == -1) - { - j = sector[nextsectorneighborz(sect,sector[sect].ceilingz,-1,-1)].ceilingz; - vel = 64; - setanimation(sect,§or[sect].ceilingz,j,vel); - return 1; - } - return 0; + if (j == -1) + { + j = sector[nextsectorneighborz(sect,sector[sect].ceilingz,-1,-1)].ceilingz; + vel = 64; + setanimation(sect,§or[sect].ceilingz,j,vel); + return 1; + } + return 0; } short checkpins(short sect) { - short i, pin; - int x, y; - short pins[10]; - short nexti, tag; - - pin = 0; - for(i=0;i<10;i++) pins[i] = 0; + short i, pin; + int x, y; + short pins[10]; + short nexti, tag; + + pin = 0; + for(i=0;i<10;i++) pins[i] = 0; - i = headspritesect[sect]; + i = headspritesect[sect]; - while (i >= 0) - { - nexti = nextspritesect[i]; + while (i >= 0) + { + nexti = nextspritesect[i]; - if (sprite[i].picnum == RRTILE3440) - { - pin++; - pins[sprite[i].lotag] = 1; - } - if (sprite[i].picnum == RRTILE280) - { - tag = sprite[i].hitag; - } + if (sprite[i].picnum == RRTILE3440) + { + pin++; + pins[sprite[i].lotag] = 1; + } + if (sprite[i].picnum == RRTILE280) + { + tag = sprite[i].hitag; + } - i = nexti; - } + i = nexti; + } - if (tag) - { - tag += 2024; - tileCopySection(2024,0,0,128,64,tag,0,0); - for(i=0;i<10;i++) - { - if (pins[i] == 1) - { - switch (i) - { - case 0: - x = 64; - y = 48; - break; - case 1: - x = 56; - y = 40; - break; - case 2: - x = 72; - y = 40; - break; - case 3: - x = 48; - y = 32; - break; - case 4: - x = 64; - y = 32; - break; - case 5: - x = 80; - y = 32; - break; - case 6: - x = 40; - y = 24; - break; - case 7: - x = 56; - y = 24; - break; - case 8: - x = 72; - y = 24; - break; - case 9: - x = 88; - y = 24; - break; - } - tileCopySection(2023,0,0,8,8,tag,x-4,y-10); - } - } - } + if (tag) + { + tag += 2024; + tileCopySection(2024,0,0,128,64,tag,0,0); + for(i=0;i<10;i++) + { + if (pins[i] == 1) + { + switch (i) + { + case 0: + x = 64; + y = 48; + break; + case 1: + x = 56; + y = 40; + break; + case 2: + x = 72; + y = 40; + break; + case 3: + x = 48; + y = 32; + break; + case 4: + x = 64; + y = 32; + break; + case 5: + x = 80; + y = 32; + break; + case 6: + x = 40; + y = 24; + break; + case 7: + x = 56; + y = 24; + break; + case 8: + x = 72; + y = 24; + break; + case 9: + x = 88; + y = 24; + break; + } + tileCopySection(2023,0,0,8,8,tag,x-4,y-10); + } + } + } - return pin; + return pin; } void resetpins(short sect) { - short i, j, nexti, tag; - int x, y; - i = headspritesect[sect]; - while (i >= 0) - { - nexti = headspritesect[i]; - if (sprite[i].picnum == 3440) - deletesprite(i); - i = nexti; - } - i = headspritesect[sect]; - while (i >= 0) - { - nexti = nextspritesect[i]; - if (sprite[i].picnum == 283) - { - j = spawn(i,3440); - sprite[j].lotag = sprite[i].lotag; - if (sprite[j].lotag == 3 || sprite[j].lotag == 5) - { - sprite[j].clipdist = (1+(krand()%1))*16+32; - } - else - { - sprite[j].clipdist = (1+(krand()%1))*16+32; - } - sprite[j].ang -= ((krand()&32)-(krand()&64))&2047; - } - if (sprite[i].picnum == 280) - tag = sprite[i].hitag; - i = nexti; - } - if (tag) - { - tag += LANEPICS+1; - tileCopySection(LANEPICS+1,0,0,128,64,tag,0,0); - for(i=0;i<10;i++) - { - switch (i) - { - case 0: - x = 64; - y = 48; - break; - case 1: - x = 56; - y = 40; - break; - case 2: - x = 72; - y = 40; - break; - case 3: - x = 48; - y = 32; - break; - case 4: - x = 64; - y = 32; - break; - case 5: - x = 80; - y = 32; - break; - case 6: - x = 40; - y = 24; - break; - case 7: - x = 56; - y = 24; - break; - case 8: - x = 72; - y = 24; - break; - case 9: - x = 88; - y = 24; - break; - } - tileCopySection(LANEPICS,0,0,8,8,tag,x-4,y-10); - } - } + short i, j, nexti, tag; + int x, y; + i = headspritesect[sect]; + while (i >= 0) + { + nexti = headspritesect[i]; + if (sprite[i].picnum == 3440) + deletesprite(i); + i = nexti; + } + i = headspritesect[sect]; + while (i >= 0) + { + nexti = nextspritesect[i]; + if (sprite[i].picnum == 283) + { + j = spawn(i,3440); + sprite[j].lotag = sprite[i].lotag; + if (sprite[j].lotag == 3 || sprite[j].lotag == 5) + { + sprite[j].clipdist = (1+(krand()%1))*16+32; + } + else + { + sprite[j].clipdist = (1+(krand()%1))*16+32; + } + sprite[j].ang -= ((krand()&32)-(krand()&64))&2047; + } + if (sprite[i].picnum == 280) + tag = sprite[i].hitag; + i = nexti; + } + if (tag) + { + tag += LANEPICS+1; + tileCopySection(LANEPICS+1,0,0,128,64,tag,0,0); + for(i=0;i<10;i++) + { + switch (i) + { + case 0: + x = 64; + y = 48; + break; + case 1: + x = 56; + y = 40; + break; + case 2: + x = 72; + y = 40; + break; + case 3: + x = 48; + y = 32; + break; + case 4: + x = 64; + y = 32; + break; + case 5: + x = 80; + y = 32; + break; + case 6: + x = 40; + y = 24; + break; + case 7: + x = 56; + y = 24; + break; + case 8: + x = 72; + y = 24; + break; + case 9: + x = 88; + y = 24; + break; + } + tileCopySection(LANEPICS,0,0,8,8,tag,x-4,y-10); + } + } } void resetlanepics(void) { - int x, y; - short i; - short tag, pic; - for(tag=0;tag<4;tag++) - { - pic = tag + 1; - if (pic == 0) continue; - pic += LANEPICS+1; - tileCopySection(LANEPICS+1,0,0,128,64, pic,0,0); - for(i=0;i<10;i++) - { - switch (i) - { - case 0: - x = 64; - y = 48; - break; - case 1: - x = 56; - y = 40; - break; - case 2: - x = 72; - y = 40; - break; - case 3: - x = 48; - y = 32; - break; - case 4: - x = 64; - y = 32; - break; - case 5: - x = 80; - y = 32; - break; - case 6: - x = 40; - y = 24; - break; - case 7: - x = 56; - y = 24; - break; - case 8: - x = 72; - y = 24; - break; - case 9: - x = 88; - y = 24; - break; - } - tileCopySection(LANEPICS,0,0,8,8,pic,x-4,y-10); - } - } + int x, y; + short i; + short tag, pic; + for(tag=0;tag<4;tag++) + { + pic = tag + 1; + if (pic == 0) continue; + pic += LANEPICS+1; + tileCopySection(LANEPICS+1,0,0,128,64, pic,0,0); + for(i=0;i<10;i++) + { + switch (i) + { + case 0: + x = 64; + y = 48; + break; + case 1: + x = 56; + y = 40; + break; + case 2: + x = 72; + y = 40; + break; + case 3: + x = 48; + y = 32; + break; + case 4: + x = 64; + y = 32; + break; + case 5: + x = 80; + y = 32; + break; + case 6: + x = 40; + y = 24; + break; + case 7: + x = 56; + y = 24; + break; + case 8: + x = 72; + y = 24; + break; + case 9: + x = 88; + y = 24; + break; + } + tileCopySection(LANEPICS,0,0,8,8,pic,x-4,y-10); + } + } } END_DUKE_NS diff --git a/source/games/duke/src/concmd.h b/source/games/duke/src/concmd.h new file mode 100644 index 000000000..f488902c5 --- /dev/null +++ b/source/games/duke/src/concmd.h @@ -0,0 +1,19 @@ +#pragma once + +struct sprite_type; +BEGIN_DUKE_NS + +#define cmd(a) concmd_ ## a, +#define cmdx(a, b) concmd_ ## a, +#define cmda(a,b) + +enum EConCommands +{ +#include "condef.h" +}; + +#undef cmd +#undef cmdx +#undef cmda + +END_DUKE_NS diff --git a/source/games/duke/src/condef.h b/source/games/duke/src/condef.h new file mode 100644 index 000000000..074d542c4 --- /dev/null +++ b/source/games/duke/src/condef.h @@ -0,0 +1,176 @@ +cmd(definelevelname) // 0 +cmd(actor) // 1 +cmd(addammo) // 2 +cmd(ifrnd) // 3 +cmd(enda) // 4 +cmd(ifcansee) // 5 +cmd(ifhitweapon) // 6 +cmd(action) // 7 +cmd(ifpdistl) // 8 +cmd(ifpdistg) // 9 +cmd(else) // 10 +cmd(strength) // 11 +cmd(break) // 12 +cmd(shoot) // 13 +cmd(palfrom) // 14 +cmd(sound) // 15 +cmd(fall) // 16 +cmd(state) // 17 +cmd(ends) // 18 +cmd(define) // 19 +cmdx(comment, "//") // 20 +cmd(ifai) // 21 +cmd(killit) // 22 +cmd(addweapon) // 23 +cmd(ai) // 24 +cmd(addphealth) // 25 +cmd(ifdead) // 26 +cmd(ifsquished) // 27 +cmd(sizeto) // 28 +cmdx(leftbrace, "{") // 29 +cmdx(rightbrace, "}") // 30 +cmd(spawn) // 31 +cmd(move) // 32 +cmd(ifwasweapon) // 33 +cmd(ifaction) // 34 +cmd(ifactioncount) // 35 +cmd(resetactioncount) // 36 +cmd(debris) // 37 +cmd(pstomp) // 38 +cmdx(blockcomment, "/*") // 39 +cmd(cstat) // 40 +cmd(ifmove) // 41 +cmd(resetplayer) // 42 +cmd(ifonwater) // 43 +cmd(ifinwater) // 44 +cmd(ifcanshoottarget) // 45 +cmd(ifcount) // 46 +cmd(resetcount) // 47 +cmd(addinventory) // 48 +cmd(ifactornotstayput) // 49 +cmd(hitradius) // 50 +cmd(ifp) // 51 +cmd(count) // 52 +cmd(ifactor) // 53 +cmd(music) // 54 +cmd(include) // 55 +cmd(ifstrength) // 56 +cmd(definesound) // 57 +cmd(guts) // 58 +cmd(ifspawnedby) // 59 +cmd(gamestartup) // 60 +cmd(wackplayer) // 61 +cmd(ifgapzl) // 62 +cmd(ifhitspace) // 63 +cmd(ifoutside) // 64 +cmd(ifmultiplayer) // 65 +cmd(operate) // 66 +cmd(ifinspace) // 67 +cmd(debug) // 68 +cmd(endofgame) // 69 +cmd(ifbulletnear) // 70 +cmd(ifrespawn) // 71 +cmd(iffloordistl) // 72 +cmd(ifceilingdistl) // 73 +cmd(spritepal) // 74 +cmd(ifpinventory) // 75 +cmd(betaname) // 76 +cmd(cactor) // 77 +cmd(ifphealthl) // 78 +cmd(definequote) // 79 +cmd(quote) // 80 +cmd(ifinouterspace) // 81 +cmd(ifnotmoving) // 82 +cmd(respawnhitag) // 83 +cmd(tip) // 84 +cmd(ifspritepal) // 85 +cmd(money) // 86 +cmda(feathers, money) // RR alias +cmd(soundonce) // 87 +cmd(addkills) // 88 +cmd(stopsound) // 89 +cmd(ifawayfromwall) // 90 +cmd(ifcanseetarget) // 91 +cmd(globalsound) // 92 +cmd(lotsofglass) // 93 +cmd(ifgotweaponce) // 94 +cmd(getlastpal) // 95 +cmd(pkick) // 96 +cmd(mikesnd) // 97 +cmd(useractor) // 98 +cmd(sizeat) // 99 +cmd(addstrength) // 100 +cmd(cstator) // 101 +cmd(mail) // 102 +cmd(paper) // 103 +cmd(tossweapon) // 104 +cmd(sleeptime) // 105 +cmd(nullop) // 106 +cmd(definevolumename) // 107 +cmd(defineskillname) // 108 +cmd(ifnosounds) // 109 +cmd(clipdist) // 110 +cmd(ifangdiffl) // 111 + +cmd(ifplaybackon) // World Tour 112 + +// WW2GI +cmd(gamevar) // 112 +cmd(ifvarl) // 113 +cmd(ifvarg) // 114 +cmd(setvarvar) // 115 +cmd(setvar) // 116 +cmd(addvarvar) // 117 +cmd(addvar) // 118 +cmd(ifvarvarl) // 119 +cmd(ifvarvarg) // 120 +cmd(addlogvar) // 121 +cmd(addlog) // 122 +cmd(onevent) // 123 +cmd(endevent) // 124 +cmd(ifvare) // 125 +cmd(ifvarvare) // 126 + +// RR +cmd(ifnocover) // 110 +cmd(ifhittruck) // 111 +cmd(iftipcow) // 112 +cmd(isdrunk) // 113 +cmd(iseat) // 114 +cmd(destroyit) // 115 +cmd(larrybird) // 116 +cmd(strafeleft) // 117 +cmd(straferight) // 118 +cmd(ifactorhealthg) // 119 +cmd(ifactorhealthl) // 120 +cmd(slapplayer) // 121 +cmd(ifpdrunk) // 122 +cmd(tearitup) // 123 +cmd(smackbubba) // 124 +cmd(soundtagonce) // 125 +cmd(soundtag) // 126 +cmd(ifsoundid) // 127 +cmd(ifsounddist) // 128 +cmd(ifonmud) // 129 +cmd(ifcoop) // 130 + +// RRRA +cmd(ifmotofast) // 131 +cmd(ifwind) // 132 +cmd(smacksprite) // 133 +cmd(ifonmoto) // 134 +cmd(ifonboat) // 135 +cmd(fakebubba) // 136 +cmd(mamatrigger) // 137 +cmd(mamaspawn) // 138 +cmd(mamaquake) // 139 +cmd(mamaend) // 141 +cmd(newpic) // 142 +cmd(garybanjo) // 143 +cmd(motoloopsnd) // 144 +cmd(ifsizedown) // 145 +cmd(rndmove) // 146 + +// RR Deer Huntin'. These are merely here for reference because the game is not supported. +// cmd(iffindnewspot) +// cmd(ifpupwind) diff --git a/source/games/duke/src/gamedef.cpp b/source/games/duke/src/gamedef.cpp new file mode 100644 index 000000000..7dc1baf41 --- /dev/null +++ b/source/games/duke/src/gamedef.cpp @@ -0,0 +1,166 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +EDuke enhancements integrated: 04/13/2003 - Matt Saettler + +Note: This source file IS NOT USED in EDuke source. It has been split +into many sub-files. + +*/ +//------------------------------------------------------------------------- + +#include "ns.h" +#include +#include "concmd.h" +#include "cmdlib.h" + +BEGIN_DUKE_NS + +// parser state: todo: turn into a class +char* textptr; +int32_t line_count; + +//--------------------------------------------------------------------------- +// +// synthesize the instruction list +// +//--------------------------------------------------------------------------- + +#define cmd(a) { #a, concmd_ ## a }, +#define cmdx(a, b) { b, concmd_ ## a }, +#define cmda(a,b) { #a, concmd_ ## b }, + +struct ConCommand +{ + char cmd[20]; // the longest instruction name is 'ifactornotstayput' at 17 characters so if this changes this field must be enlarged. + int instr; +}; + +static ConCommand cmdList[] = +{ +#include "condef.h" +}; + +#undef cmd +#undef cmdx +#undef cmda + +static int cmdCmp(const void *a, const void *b) +{ + auto A = (ConCommand*)a; + auto B = (ConCommand*)b; + return strcmp(A->cmd, B->cmd); +} + +void SortCommands() +{ + qsort(cmdList, countof(cmdList), sizeof(ConCommand), cmdCmp); +} + +//--------------------------------------------------------------------------- +// +// binary search for keyword +// +//--------------------------------------------------------------------------- + +int getkeyword(const char* text) +{ + ptrdiff_t min = 0; + ptrdiff_t max = countof(cmdList) - 1; + + while (min <= max) + { + int mid = (min + max) >> 1; + const int comp = strcmp(text, cmdList[mid].cmd); + + if (comp == 0) + { + return cmdList[mid].instr; + } + else if (comp > 0) + { + min = mid + 1; + } + else + { + max = mid - 1; + } + } + return -1; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void skiptoendofline() +{ + while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) + textptr++; +} + +void skipwhitespace() +{ + while (*textptr == ' ' || *textptr == '\t' || *textptr == '\r' || *textptr == '\n') + { + if (*textptr == '\n') line_count++; + textptr++; + } +} + +void skipblockcomment() +{ + while (*textptr != '*' && textptr[1] != '/') + { + if (*textptr == '\n') line_count++; + if (*textptr == 0) return; // reached the end of the file + textptr++; + } +} + +bool skipcomments() +{ + while (true) + { + skipwhitespace(); + if (*textptr == '/' && textptr[1] == '/') + { + skiptoendofline(); + continue; + } + if (*textptr == '/' && textptr[1] == '*') + { + skipblockcomment(); + continue; + } + // stop if we got something else + break; + } + return *textptr != 0; +} + + +END_DUKE_NS diff --git a/source/games/duke/src/gamedef.h b/source/games/duke/src/gamedef.h index 457c87010..2886dfc4f 100644 --- a/source/games/duke/src/gamedef.h +++ b/source/games/duke/src/gamedef.h @@ -55,7 +55,7 @@ enum do \ { \ C_ReportError(-1); \ - Printf("%s:%d: error: " Text "\n", g_scriptFileName, g_lineNumber, ##__VA_ARGS__); \ + Printf("%s:%d: error: " Text "\n", g_scriptFileName, line_count, ##__VA_ARGS__); \ g_errorCnt++; \ } while (0) @@ -63,7 +63,7 @@ enum do \ { \ C_ReportError(-1); \ - Printf("%s:%d: warning: " Text "\n", g_scriptFileName, g_lineNumber, ##__VA_ARGS__); \ + Printf("%s:%d: warning: " Text "\n", g_scriptFileName, line_count, ##__VA_ARGS__); \ g_warningCnt++; \ } while (0) @@ -91,7 +91,7 @@ extern const uint32_t CheatFunctionFlags[]; extern const uint8_t CheatFunctionIDs[]; extern int32_t g_errorCnt; -extern int32_t g_lineNumber; +extern int32_t line_count; extern int32_t g_scriptVersion; extern int32_t g_totalLines; extern int32_t g_warningCnt; @@ -177,8 +177,19 @@ enum ScriptError_t WARNING_DUPLICATEDEFINITION, WARNING_LABELSONLY, WARNING_VARMASKSKEYWORD, + + ERROR_COULDNOTFIND, + ERROR_NOTAGAMEDEF, + ERROR_NOENDSWITCH }; +enum +{ +}; + + +#include "concmd.h" + enum ScriptKeywords_t { CON_ELSE, // 0 diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 733243cd1..64c98ac49 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -72,57 +72,57 @@ void checksectors_r(int snum); bool isadoorwall(int dapic) { - return isRR() ? isadoorwall_r(dapic) : isadoorwall_d(dapic); + return isRR() ? isadoorwall_r(dapic) : isadoorwall_d(dapic); } void animatewalls() { - if (isRR()) animatewalls_r(); else animatewalls_d(); + if (isRR()) animatewalls_r(); else animatewalls_d(); } void operaterespawns(int low) { - if (isRR()) operaterespawns_r(low); else operaterespawns_d(low); + if (isRR()) operaterespawns_r(low); else operaterespawns_d(low); } void operateforcefields(int s, int low) { - if (isRR()) operateforcefields_r(s, low); else operateforcefields_d(s, low); + if (isRR()) operateforcefields_r(s, low); else operateforcefields_d(s, low); } bool checkhitswitch(int snum, int w, int switchtype) { - return isRR() ? checkhitswitch_r(snum, w, switchtype) : checkhitswitch_d(snum, w, switchtype); + return isRR() ? checkhitswitch_r(snum, w, switchtype) : checkhitswitch_d(snum, w, switchtype); } void activatebysector(int sect, int j) { - if (isRR()) activatebysector_r(sect, j); else activatebysector_d(sect, j); + if (isRR()) activatebysector_r(sect, j); else activatebysector_d(sect, j); } void checkhitwall(int spr, int dawallnum, int x, int y, int z, int atwith) { - if (isRR()) checkhitwall_r(spr, dawallnum, x, y, z, atwith); else checkhitwall_d(spr, dawallnum, x, y, z, atwith); + if (isRR()) checkhitwall_r(spr, dawallnum, x, y, z, atwith); else checkhitwall_d(spr, dawallnum, x, y, z, atwith); } void checkplayerhurt(struct player_struct* p, int j) { - if (isRR()) checkplayerhurt_r(p, j); else checkplayerhurt_d(p, j); + if (isRR()) checkplayerhurt_r(p, j); else checkplayerhurt_d(p, j); } bool checkhitceiling(int sn) { - return isRR() ? checkhitceiling_r(sn) : checkhitceiling_d(sn); + return isRR() ? checkhitceiling_r(sn) : checkhitceiling_d(sn); } void checkhitsprite(int i, int sn) { - if (isRR()) checkhitsprite_r(i, sn); else checkhitsprite_d(i, sn); + if (isRR()) checkhitsprite_r(i, sn); else checkhitsprite_d(i, sn); } void checksectors(int low) { - if (isRR()) checksectors_r(low); else checksectors_d(low); + if (isRR()) checksectors_r(low); else checksectors_d(low); } @@ -135,50 +135,50 @@ static bool haltsoundhack; int callsound(int sn, int whatsprite) { - if (!isRRRA() && haltsoundhack) - { - haltsoundhack = 0; - return -1; - } + if (!isRRRA() && haltsoundhack) + { + haltsoundhack = 0; + return -1; + } - int i = headspritesect[sn]; - while (i >= 0) - { - if (sprite[i].picnum == MUSICANDSFX && sprite[i].lotag < 1000) - { - if (whatsprite == -1) whatsprite = i; + int i = headspritesect[sn]; + while (i >= 0) + { + if (sprite[i].picnum == MUSICANDSFX && sprite[i].lotag < 1000) + { + if (whatsprite == -1) whatsprite = i; - int snum = sprite[i].lotag; - auto flags = S_GetUserFlags(snum); - if (hittype[i].temp_data[0] == 0) - { - if ((flags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL) - { - if (snum) - { - if (sprite[i].hitag && snum != sprite[i].hitag) - S_StopEnvSound(sprite[i].hitag, hittype[i].temp_data[5]); // changed to only stop the sound on the same actor, not all of them. - spritesound(snum, whatsprite); - hittype[i].temp_data[5] = whatsprite; - } + int snum = sprite[i].lotag; + auto flags = S_GetUserFlags(snum); + if (hittype[i].temp_data[0] == 0) + { + if ((flags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL) + { + if (snum) + { + if (sprite[i].hitag && snum != sprite[i].hitag) + S_StopEnvSound(sprite[i].hitag, hittype[i].temp_data[5]); // changed to only stop the sound on the same actor, not all of them. + spritesound(snum, whatsprite); + hittype[i].temp_data[5] = whatsprite; + } - if ((sector[sprite[i].sectnum].lotag & 0xff) != ST_22_SPLITTING_DOOR) - hittype[i].temp_data[0] = 1; - } - } - else if (S_IsSoundValid(sprite[i].hitag)) - { - if ((flags & SF_LOOP) || (sprite[i].hitag && sprite[i].hitag != sprite[i].lotag)) - S_StopEnvSound(sprite[i].lotag, hittype[i].temp_data[5]); // changed to only stop the sound on the same actor, not all of them. - if (sprite[i].hitag) spritesound(sprite[i].hitag, whatsprite); - hittype[i].temp_data[0] = 0; - hittype[i].temp_data[5] = whatsprite; - } - return sprite[i].lotag; - } - i = nextspritesect[i]; - } - return -1; + if ((sector[sprite[i].sectnum].lotag & 0xff) != ST_22_SPLITTING_DOOR) + hittype[i].temp_data[0] = 1; + } + } + else if (S_IsSoundValid(sprite[i].hitag)) + { + if ((flags & SF_LOOP) || (sprite[i].hitag && sprite[i].hitag != sprite[i].lotag)) + S_StopEnvSound(sprite[i].lotag, hittype[i].temp_data[5]); // changed to only stop the sound on the same actor, not all of them. + if (sprite[i].hitag) spritesound(sprite[i].hitag, whatsprite); + hittype[i].temp_data[0] = 0; + hittype[i].temp_data[5] = whatsprite; + } + return sprite[i].lotag; + } + i = nextspritesect[i]; + } + return -1; } @@ -190,47 +190,47 @@ int callsound(int sn, int whatsprite) int check_activator_motion(int lotag) { - int i, j; - spritetype* s; + int i, j; + spritetype* s; - i = headspritestat[STAT_ACTIVATOR]; - while (i >= 0) - { - if (sprite[i].lotag == lotag) - { - s = &sprite[i]; + i = headspritestat[STAT_ACTIVATOR]; + while (i >= 0) + { + if (sprite[i].lotag == lotag) + { + s = &sprite[i]; - for (j = animatecnt - 1; j >= 0; j--) - if (s->sectnum == animatesect[j]) - return(1); + for (j = animatecnt - 1; j >= 0; j--) + if (s->sectnum == animatesect[j]) + return(1); - j = headspritestat[STAT_EFFECTOR]; - while (j >= 0) - { - if (s->sectnum == sprite[j].sectnum) - switch (sprite[j].lotag) - { - case SE_11_SWINGING_DOOR: - case SE_30_TWO_WAY_TRAIN: - if (hittype[j].temp_data[4]) - return(1); - break; - case SE_18_INCREMENTAL_SECTOR_RISE_FALL: - if (isRRRA()) break; - case SE_20_STRETCH_BRIDGE: - case SE_31_FLOOR_RISE_FALL: - case SE_32_CEILING_RISE_FALL: - if (hittype[j].temp_data[0]) - return(1); - break; - } + j = headspritestat[STAT_EFFECTOR]; + while (j >= 0) + { + if (s->sectnum == sprite[j].sectnum) + switch (sprite[j].lotag) + { + case SE_11_SWINGING_DOOR: + case SE_30_TWO_WAY_TRAIN: + if (hittype[j].temp_data[4]) + return(1); + break; + case SE_18_INCREMENTAL_SECTOR_RISE_FALL: + if (isRRRA()) break; + case SE_20_STRETCH_BRIDGE: + case SE_31_FLOOR_RISE_FALL: + case SE_32_CEILING_RISE_FALL: + if (hittype[j].temp_data[0]) + return(1); + break; + } - j = nextspritestat[j]; - } - } - i = nextspritestat[i]; - } - return(0); + j = nextspritestat[j]; + } + } + i = nextspritestat[i]; + } + return(0); } //--------------------------------------------------------------------------- @@ -241,19 +241,19 @@ int check_activator_motion(int lotag) bool isanunderoperator(int lotag) { - switch (lotag & 0xff) - { - case ST_15_WARP_ELEVATOR: - case ST_16_PLATFORM_DOWN: - case ST_17_PLATFORM_UP: - case ST_18_ELEVATOR_DOWN: - case ST_19_ELEVATOR_UP: - case ST_26_SPLITTING_ST_DOOR: - return true; - case ST_22_SPLITTING_DOOR: - return !isRR(); - } - return false; + switch (lotag & 0xff) + { + case ST_15_WARP_ELEVATOR: + case ST_16_PLATFORM_DOWN: + case ST_17_PLATFORM_UP: + case ST_18_ELEVATOR_DOWN: + case ST_19_ELEVATOR_UP: + case ST_26_SPLITTING_ST_DOOR: + return true; + case ST_22_SPLITTING_DOOR: + return !isRR(); + } + return false; } //--------------------------------------------------------------------------- @@ -264,26 +264,26 @@ bool isanunderoperator(int lotag) bool isanearoperator(int lotag) { - switch (lotag & 0xff) - { - case ST_9_SLIDING_ST_DOOR: - case ST_15_WARP_ELEVATOR: - case ST_16_PLATFORM_DOWN: - case ST_17_PLATFORM_UP: - case ST_18_ELEVATOR_DOWN: - case ST_19_ELEVATOR_UP: - case ST_20_CEILING_DOOR: - case ST_21_FLOOR_DOOR: - case ST_22_SPLITTING_DOOR: - case ST_23_SWINGING_DOOR: - case ST_25_SLIDING_DOOR: - case ST_26_SPLITTING_ST_DOOR: - case ST_29_TEETH_DOOR: - return true; - case 41: - return isRR(); - } - return false; + switch (lotag & 0xff) + { + case ST_9_SLIDING_ST_DOOR: + case ST_15_WARP_ELEVATOR: + case ST_16_PLATFORM_DOWN: + case ST_17_PLATFORM_UP: + case ST_18_ELEVATOR_DOWN: + case ST_19_ELEVATOR_UP: + case ST_20_CEILING_DOOR: + case ST_21_FLOOR_DOOR: + case ST_22_SPLITTING_DOOR: + case ST_23_SWINGING_DOOR: + case ST_25_SLIDING_DOOR: + case ST_26_SPLITTING_ST_DOOR: + case ST_29_TEETH_DOOR: + return true; + case 41: + return isRR(); + } + return false; } //--------------------------------------------------------------------------- @@ -294,30 +294,30 @@ bool isanearoperator(int lotag) int findplayer(const spritetype* s, int* d) { - short j, closest_player; - int x, closest; + short j, closest_player; + int x, closest; - if (ud.multimode < 2) - { - if (d) *d = abs(ps[myconnectindex].oposx - s->x) + abs(ps[myconnectindex].oposy - s->y) + ((abs(ps[myconnectindex].oposz - s->z + (28 << 8))) >> 4); - return myconnectindex; - } + if (ud.multimode < 2) + { + if (d) *d = abs(ps[myconnectindex].oposx - s->x) + abs(ps[myconnectindex].oposy - s->y) + ((abs(ps[myconnectindex].oposz - s->z + (28 << 8))) >> 4); + return myconnectindex; + } - closest = 0x7fffffff; - closest_player = 0; + closest = 0x7fffffff; + closest_player = 0; - for (j = connecthead; j >= 0; j = connectpoint2[j]) - { - x = abs(ps[j].oposx - s->x) + abs(ps[j].oposy - s->y) + ((abs(ps[j].oposz - s->z + (28 << 8))) >> 4); - if (x < closest && sprite[ps[j].i].extra > 0) - { - closest_player = j; - closest = x; - } - } + for (j = connecthead; j >= 0; j = connectpoint2[j]) + { + x = abs(ps[j].oposx - s->x) + abs(ps[j].oposy - s->y) + ((abs(ps[j].oposz - s->z + (28 << 8))) >> 4); + if (x < closest && sprite[ps[j].i].extra > 0) + { + closest_player = j; + closest = x; + } + } - if (d) *d = closest; - return closest_player; + if (d) *d = closest; + return closest_player; } //--------------------------------------------------------------------------- @@ -328,26 +328,26 @@ int findplayer(const spritetype* s, int* d) int findotherplayer(int p, int* d) { - short j, closest_player; - int x, closest; + short j, closest_player; + int x, closest; - closest = 0x7fffffff; - closest_player = p; + closest = 0x7fffffff; + closest_player = p; - for (j = connecthead; j >= 0; j = connectpoint2[j]) - if (p != j && sprite[ps[j].i].extra > 0) - { - x = abs(ps[j].oposx - ps[p].posx) + abs(ps[j].oposy - ps[p].posy) + (abs(ps[j].oposz - ps[p].posz) >> 4); + for (j = connecthead; j >= 0; j = connectpoint2[j]) + if (p != j && sprite[ps[j].i].extra > 0) + { + x = abs(ps[j].oposx - ps[p].posx) + abs(ps[j].oposy - ps[p].posy) + (abs(ps[j].oposz - ps[p].posz) >> 4); - if (x < closest) - { - closest_player = j; - closest = x; - } - } + if (x < closest) + { + closest_player = j; + closest = x; + } + } - *d = closest; - return closest_player; + *d = closest; + return closest_player; } //--------------------------------------------------------------------------- @@ -358,66 +358,66 @@ int findotherplayer(int p, int* d) void doanimations(void) { - int i, j, a, p, v, dasect; + int i, j, a, p, v, dasect; - for (i = animatecnt - 1; i >= 0; i--) - { - a = *animateptr[i]; - v = animatevel[i] * TICSPERFRAME; - dasect = animatesect[i]; + for (i = animatecnt - 1; i >= 0; i--) + { + a = *animateptr[i]; + v = animatevel[i] * TICSPERFRAME; + dasect = animatesect[i]; - if (a == animategoal[i]) - { - stopinterpolation(animateptr[i]); + if (a == animategoal[i]) + { + stopinterpolation(animateptr[i]); - animatecnt--; - animateptr[i] = animateptr[animatecnt]; - animategoal[i] = animategoal[animatecnt]; - animatevel[i] = animatevel[animatecnt]; - animatesect[i] = animatesect[animatecnt]; - if (sector[animatesect[i]].lotag == ST_18_ELEVATOR_DOWN || sector[animatesect[i]].lotag == ST_19_ELEVATOR_UP) - if (animateptr[i] == §or[animatesect[i]].ceilingz) - continue; + animatecnt--; + animateptr[i] = animateptr[animatecnt]; + animategoal[i] = animategoal[animatecnt]; + animatevel[i] = animatevel[animatecnt]; + animatesect[i] = animatesect[animatecnt]; + if (sector[animatesect[i]].lotag == ST_18_ELEVATOR_DOWN || sector[animatesect[i]].lotag == ST_19_ELEVATOR_UP) + if (animateptr[i] == §or[animatesect[i]].ceilingz) + continue; - if ((sector[dasect].lotag & 0xff) != ST_22_SPLITTING_DOOR) - callsound(dasect, -1); + if ((sector[dasect].lotag & 0xff) != ST_22_SPLITTING_DOOR) + callsound(dasect, -1); - continue; - } + continue; + } - if (v > 0) { a = min(a + v, animategoal[i]); } - else { a = max(a + v, animategoal[i]); } + if (v > 0) { a = min(a + v, animategoal[i]); } + else { a = max(a + v, animategoal[i]); } - if (animateptr[i] == §or[animatesect[i]].floorz) - { - for (p = connecthead; p >= 0; p = connectpoint2[p]) - if (ps[p].cursectnum == dasect) - if ((sector[dasect].floorz - ps[p].posz) < (64 << 8)) - if (sprite[ps[p].i].owner >= 0) - { - ps[p].posz += v; - ps[p].poszv = 0; + if (animateptr[i] == §or[animatesect[i]].floorz) + { + for (p = connecthead; p >= 0; p = connectpoint2[p]) + if (ps[p].cursectnum == dasect) + if ((sector[dasect].floorz - ps[p].posz) < (64 << 8)) + if (sprite[ps[p].i].owner >= 0) + { + ps[p].posz += v; + ps[p].poszv = 0; #if 0 - if (p == myconnectindex) - { - myz += v; - myzvel = 0; - myzbak[((movefifoplc - 1) & (MOVEFIFOSIZ - 1))] = ps[p].posz; - } + if (p == myconnectindex) + { + myz += v; + myzvel = 0; + myzbak[((movefifoplc - 1) & (MOVEFIFOSIZ - 1))] = ps[p].posz; + } #endif - } + } - for (j = headspritesect[dasect]; j >= 0; j = nextspritesect[j]) - if (sprite[j].statnum != STAT_EFFECTOR) - { - hittype[j].bposz = sprite[j].z; - sprite[j].z += v; - hittype[j].floorz = sector[dasect].floorz + v; - } - } + for (j = headspritesect[dasect]; j >= 0; j = nextspritesect[j]) + if (sprite[j].statnum != STAT_EFFECTOR) + { + hittype[j].bposz = sprite[j].z; + sprite[j].z += v; + hittype[j].floorz = sector[dasect].floorz + v; + } + } - *animateptr[i] = a; - } + *animateptr[i] = a; + } } //--------------------------------------------------------------------------- @@ -428,16 +428,16 @@ void doanimations(void) int getanimationgoal(const int* animptr) { - int i, j; + int i, j; - j = -1; - for (i = animatecnt - 1; i >= 0; i--) - if (animptr == (int*)animateptr[i]) - { - j = i; - break; - } - return(j); + j = -1; + for (i = animatecnt - 1; i >= 0; i--) + if (animptr == (int*)animateptr[i]) + { + j = i; + break; + } + return(j); } //--------------------------------------------------------------------------- @@ -448,32 +448,32 @@ int getanimationgoal(const int* animptr) int setanimation(short animsect, int* animptr, int thegoal, int thevel) { - int i, j; + int i, j; - if (animatecnt >= MAXANIMATES - 1) - return(-1); + if (animatecnt >= MAXANIMATES - 1) + return(-1); - j = animatecnt; - for (i = 0; i < animatecnt; i++) - if (animptr == animateptr[i]) - { - j = i; - break; - } + j = animatecnt; + for (i = 0; i < animatecnt; i++) + if (animptr == animateptr[i]) + { + j = i; + break; + } - animatesect[j] = animsect; - animateptr[j] = animptr; - animategoal[j] = thegoal; - if (thegoal >= *animptr) - animatevel[j] = thevel; - else - animatevel[j] = -thevel; + animatesect[j] = animsect; + animateptr[j] = animptr; + animategoal[j] = thegoal; + if (thegoal >= *animptr) + animatevel[j] = thevel; + else + animatevel[j] = -thevel; - if (j == animatecnt) animatecnt++; + if (j == animatecnt) animatecnt++; - setinterpolation(animptr); + setinterpolation(animptr); - return(j); + return(j); } @@ -485,48 +485,48 @@ int setanimation(short animsect, int* animptr, int thegoal, int thevel) bool activatewarpelevators(int s, int d) //Parm = sectoreffectornum { - short i, sn; + short i, sn; - sn = sprite[s].sectnum; + sn = sprite[s].sectnum; - // See if the sector exists + // See if the sector exists - i = headspritestat[3]; - while (i >= 0) - { - if (sprite[i].lotag == SE_17_WARP_ELEVATOR || (isRRRA() && sprite[i].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL)) - if (sprite[i].hitag == sprite[s].hitag) - if ((abs(sector[sn].floorz - hittype[s].temp_data[2]) > sprite[i].yvel) || - (sector[sprite[i].sectnum].hitag == (sector[sn].hitag - d))) - break; - i = nextspritestat[i]; - } + i = headspritestat[3]; + while (i >= 0) + { + if (sprite[i].lotag == SE_17_WARP_ELEVATOR || (isRRRA() && sprite[i].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL)) + if (sprite[i].hitag == sprite[s].hitag) + if ((abs(sector[sn].floorz - hittype[s].temp_data[2]) > sprite[i].yvel) || + (sector[sprite[i].sectnum].hitag == (sector[sn].hitag - d))) + break; + i = nextspritestat[i]; + } - if (i == -1) - { - d = 0; - return 1; // No find - } - else - { - if (d == 0) - spritesound(ELEVATOR_OFF, s); - else spritesound(ELEVATOR_ON, s); - } + if (i == -1) + { + d = 0; + return 1; // No find + } + else + { + if (d == 0) + spritesound(ELEVATOR_OFF, s); + else spritesound(ELEVATOR_ON, s); + } - i = headspritestat[3]; - while (i >= 0) - { - if (sprite[i].lotag == SE_17_WARP_ELEVATOR || (isRRRA() && sprite[i].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL)) - if (sprite[i].hitag == sprite[s].hitag) - { - hittype[i].temp_data[0] = d; - hittype[i].temp_data[1] = d; //Make all check warp - } - i = nextspritestat[i]; - } - return 0; + i = headspritestat[3]; + while (i >= 0) + { + if (sprite[i].lotag == SE_17_WARP_ELEVATOR || (isRRRA() && sprite[i].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL)) + if (sprite[i].hitag == sprite[s].hitag) + { + hittype[i].temp_data[0] = d; + hittype[i].temp_data[1] = d; //Make all check warp + } + i = nextspritestat[i]; + } + return 0; } //--------------------------------------------------------------------------- @@ -537,453 +537,453 @@ bool activatewarpelevators(int s, int d) //Parm = sectoreffectornum void operatesectors(int sn, int ii) { - int j=0, l, q, startwall, endwall; - int i; - char sect_error; - sectortype* sptr; - - sect_error = 0; - sptr = §or[sn]; - - switch (sptr->lotag & (0xffff - 49152)) - { - - case 41: - if (isRR()) operatejaildoors(sptr->hitag); - break; - - case 7: - if (!isRR()) break; - startwall = sptr->wallptr; - endwall = startwall + sptr->wallnum; - for (j = startwall; j < endwall; j++) - { - setanimation(sn, &wall[j].x, wall[j].x + 1024, 4); - setanimation(sn, &wall[wall[j].nextwall].x, wall[wall[j].nextwall].x + 1024, 4); - } - break; - - case ST_30_ROTATE_RISE_BRIDGE: - j = sector[sn].hitag; - if (hittype[j].tempang == 0 || - hittype[j].tempang == 256) - callsound(sn, ii); - if (sprite[j].extra == 1) - sprite[j].extra = 3; - else sprite[j].extra = 1; - break; - - case ST_31_TWO_WAY_TRAIN: - - j = sector[sn].hitag; - if (hittype[j].temp_data[4] == 0) - hittype[j].temp_data[4] = 1; - - callsound(sn, ii); - break; - - case ST_26_SPLITTING_ST_DOOR: //The split doors - i = getanimationgoal(&sptr->ceilingz); - if (i == -1) //if the door has stopped - { - haltsoundhack = 1; - sptr->lotag &= 0xff00; - sptr->lotag |= ST_22_SPLITTING_DOOR; - operatesectors(sn, ii); - sptr->lotag &= 0xff00; - sptr->lotag |= ST_9_SLIDING_ST_DOOR; - operatesectors(sn, ii); - sptr->lotag &= 0xff00; - sptr->lotag |= ST_26_SPLITTING_ST_DOOR; - } - return; - - case ST_9_SLIDING_ST_DOOR: - { - int dax, day, dax2, day2, sp; - int wallfind[2]; - - startwall = sptr->wallptr; - endwall = startwall + sptr->wallnum - 1; - - sp = sptr->extra >> 4; - - //first find center point by averaging all points - dax = 0L, day = 0L; - for (i = startwall; i <= endwall; i++) - { - dax += wall[i].x; - day += wall[i].y; - } - dax /= (endwall - startwall + 1); - day /= (endwall - startwall + 1); - - //find any points with either same x or same y coordinate - // as center (dax, day) - should be 2 points found. - wallfind[0] = -1; - wallfind[1] = -1; - for (i = startwall; i <= endwall; i++) - if ((wall[i].x == dax) || (wall[i].y == day)) - { - if (wallfind[0] == -1) - wallfind[0] = i; - else wallfind[1] = i; - } - - for (j = 0; j < 2; j++) - { - if ((wall[wallfind[j]].x == dax) && (wall[wallfind[j]].y == day)) - { - //find what direction door should open by averaging the - // 2 neighboring points of wallfind[0] & wallfind[1]. - i = wallfind[j] - 1; if (i < startwall) i = endwall; - dax2 = ((wall[i].x + wall[wall[wallfind[j]].point2].x) >> 1) - wall[wallfind[j]].x; - day2 = ((wall[i].y + wall[wall[wallfind[j]].point2].y) >> 1) - wall[wallfind[j]].y; - if (dax2 != 0) - { - dax2 = wall[wall[wall[wallfind[j]].point2].point2].x; - dax2 -= wall[wall[wallfind[j]].point2].x; - setanimation(sn, &wall[wallfind[j]].x, wall[wallfind[j]].x + dax2, sp); - setanimation(sn, &wall[i].x, wall[i].x + dax2, sp); - setanimation(sn, &wall[wall[wallfind[j]].point2].x, wall[wall[wallfind[j]].point2].x + dax2, sp); - callsound(sn, ii); - } - else if (day2 != 0) - { - day2 = wall[wall[wall[wallfind[j]].point2].point2].y; - day2 -= wall[wall[wallfind[j]].point2].y; - setanimation(sn, &wall[wallfind[j]].y, wall[wallfind[j]].y + day2, sp); - setanimation(sn, &wall[i].y, wall[i].y + day2, sp); - setanimation(sn, &wall[wall[wallfind[j]].point2].y, wall[wall[wallfind[j]].point2].y + day2, sp); - callsound(sn, ii); - } - } - else - { - i = wallfind[j] - 1; if (i < startwall) i = endwall; - dax2 = ((wall[i].x + wall[wall[wallfind[j]].point2].x) >> 1) - wall[wallfind[j]].x; - day2 = ((wall[i].y + wall[wall[wallfind[j]].point2].y) >> 1) - wall[wallfind[j]].y; - if (dax2 != 0) - { - setanimation(sn, &wall[wallfind[j]].x, dax, sp); - setanimation(sn, &wall[i].x, dax + dax2, sp); - setanimation(sn, &wall[wall[wallfind[j]].point2].x, dax + dax2, sp); - callsound(sn, ii); - } - else if (day2 != 0) - { - setanimation(sn, &wall[wallfind[j]].y, day, sp); - setanimation(sn, &wall[i].y, day + day2, sp); - setanimation(sn, &wall[wall[wallfind[j]].point2].y, day + day2, sp); - callsound(sn, ii); - } - } - } - - } - return; - - case ST_15_WARP_ELEVATOR://Warping elevators - - if (sprite[ii].picnum != APLAYER) return; - // if(ps[sprite[ii].yvel].select_dir == 1) return; - - i = headspritesect[sn]; - while (i >= 0) - { - if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 17) break; - i = nextspritesect[i]; - } - - if (sprite[ii].sectnum == sn) - { - if (activatewarpelevators(i, -1)) - activatewarpelevators(i, 1); - else if (activatewarpelevators(i, 1)) - activatewarpelevators(i, -1); - return; - } - else - { - if (sptr->floorz > sprite[i].z) - activatewarpelevators(i, -1); - else - activatewarpelevators(i, 1); - } - - return; - - case ST_16_PLATFORM_DOWN: - case ST_17_PLATFORM_UP: - - i = getanimationgoal(&sptr->floorz); - - if (i == -1) - { - i = nextsectorneighborz(sn, sptr->floorz, 1, 1); - if (i == -1) - { - i = nextsectorneighborz(sn, sptr->floorz, 1, -1); - if (i == -1) return; - j = sector[i].floorz; - setanimation(sn, &sptr->floorz, j, sptr->extra); - } - else - { - j = sector[i].floorz; - setanimation(sn, &sptr->floorz, j, sptr->extra); - } - callsound(sn, ii); - } - - return; - - case ST_18_ELEVATOR_DOWN: - case ST_19_ELEVATOR_UP: - - i = getanimationgoal(&sptr->floorz); - - if (i == -1) - { - i = nextsectorneighborz(sn, sptr->floorz, 1, -1); - if (i == -1) i = nextsectorneighborz(sn, sptr->floorz, 1, 1); - if (i == -1) return; - j = sector[i].floorz; - q = sptr->extra; - l = sptr->ceilingz - sptr->floorz; - setanimation(sn, &sptr->floorz, j, q); - setanimation(sn, &sptr->ceilingz, j + l, q); - callsound(sn, ii); - } - return; - - case ST_29_TEETH_DOOR: - - if (sptr->lotag & 0x8000) - j = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz; - else - j = sector[nextsectorneighborz(sn, sptr->ceilingz, -1, -1)].ceilingz; - - i = headspritestat[3]; //Effectors - while (i >= 0) - { - if ((sprite[i].lotag == 22) && - (sprite[i].hitag == sptr->hitag)) - { - sector[sprite[i].sectnum].extra = -sector[sprite[i].sectnum].extra; - - hittype[i].temp_data[0] = sn; - hittype[i].temp_data[1] = 1; - } - i = nextspritestat[i]; - } - - sptr->lotag ^= 0x8000; - - setanimation(sn, &sptr->ceilingz, j, sptr->extra); - - callsound(sn, ii); - - return; - - case ST_20_CEILING_DOOR: - REDODOOR: - - if (sptr->lotag & 0x8000) - { - i = headspritesect[sn]; - while (i >= 0) - { - if (sprite[i].statnum == 3 && sprite[i].lotag == 9) - { - j = sprite[i].z; - break; - } - i = nextspritesect[i]; - } - if (i == -1) - j = sptr->floorz; - } - else - { - j = nextsectorneighborz(sn, sptr->ceilingz, -1, -1); - - if (j >= 0) j = sector[j].ceilingz; - else - { - sptr->lotag |= 32768; - goto REDODOOR; - } - } - - sptr->lotag ^= 0x8000; - - setanimation(sn, &sptr->ceilingz, j, sptr->extra); - callsound(sn, ii); - - return; - - case ST_21_FLOOR_DOOR: - i = getanimationgoal(&sptr->floorz); - if (i >= 0) - { - if (animategoal[sn] == sptr->ceilingz) - animategoal[i] = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz; - else animategoal[i] = sptr->ceilingz; - j = animategoal[i]; - } - else - { - if (sptr->ceilingz == sptr->floorz) - j = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz; - else j = sptr->ceilingz; - - sptr->lotag ^= 0x8000; - - if (setanimation(sn, &sptr->floorz, j, sptr->extra) >= 0) - callsound(sn, ii); - } - return; - - case ST_22_SPLITTING_DOOR: - - if ((sptr->lotag & 0x8000)) - { - q = (sptr->ceilingz + sptr->floorz) >> 1; - j = setanimation(sn, &sptr->floorz, q, sptr->extra); - j = setanimation(sn, &sptr->ceilingz, q, sptr->extra); - } - else - { - q = sector[nextsectorneighborz(sn, sptr->floorz, 1, 1)].floorz; - j = setanimation(sn, &sptr->floorz, q, sptr->extra); - q = sector[nextsectorneighborz(sn, sptr->ceilingz, -1, -1)].ceilingz; - j = setanimation(sn, &sptr->ceilingz, q, sptr->extra); - } - - sptr->lotag ^= 0x8000; - - callsound(sn, ii); - - return; - - case ST_23_SWINGING_DOOR: //Swingdoor - - j = -1; - q = 0; - - i = headspritestat[3]; - while (i >= 0) - { - if (sprite[i].lotag == 11 && sprite[i].sectnum == sn && !hittype[i].temp_data[4]) - { - j = i; - break; - } - i = nextspritestat[i]; - } - - l = sector[sprite[i].sectnum].lotag & 0x8000; - - if (j >= 0) - { - i = headspritestat[3]; - while (i >= 0) - { - if (l == (sector[sprite[i].sectnum].lotag & 0x8000) && sprite[i].lotag == 11 && sprite[j].hitag == sprite[i].hitag && !hittype[i].temp_data[4]) - { - if (sector[sprite[i].sectnum].lotag & 0x8000) sector[sprite[i].sectnum].lotag &= 0x7fff; - else sector[sprite[i].sectnum].lotag |= 0x8000; - hittype[i].temp_data[4] = 1; - hittype[i].temp_data[3] = -hittype[i].temp_data[3]; - if (q == 0) - { - callsound(sn, i); - q = 1; - } - } - i = nextspritestat[i]; - } - } - return; - - case ST_25_SLIDING_DOOR: //Subway type sliding doors - - j = headspritestat[3]; - while (j >= 0)//Find the sprite - { - if ((sprite[j].lotag) == 15 && sprite[j].sectnum == sn) - break; //Found the sectoreffector. - j = nextspritestat[j]; - } - - if (j < 0) - return; - - i = headspritestat[3]; - while (i >= 0) - { - if (sprite[i].hitag == sprite[j].hitag) - { - if (sprite[i].lotag == 15) - { - sector[sprite[i].sectnum].lotag ^= 0x8000; // Toggle the open or close - sprite[i].ang += 1024; - if (hittype[i].temp_data[4]) callsound(sprite[i].sectnum, i); - callsound(sprite[i].sectnum, i); - if (sector[sprite[i].sectnum].lotag & 0x8000) hittype[i].temp_data[4] = 1; - else hittype[i].temp_data[4] = 2; - } - } - i = nextspritestat[i]; - } - return; - - case ST_27_STRETCH_BRIDGE: //Extended bridge - - j = headspritestat[3]; - while (j >= 0) - { - if ((sprite[j].lotag & 0xff) == 20 && sprite[j].sectnum == sn) //Bridge - { - - sector[sn].lotag ^= 0x8000; - if (sector[sn].lotag & 0x8000) //OPENING - hittype[j].temp_data[0] = 1; - else hittype[j].temp_data[0] = 2; - callsound(sn, ii); - break; - } - j = nextspritestat[j]; - } - return; - - - case ST_28_DROP_FLOOR: - //activate the rest of them - - j = headspritesect[sn]; - while (j >= 0) - { - if (sprite[j].statnum == 3 && (sprite[j].lotag & 0xff) == 21) - break; //Found it - j = nextspritesect[j]; - } - - j = sprite[j].hitag; - - l = headspritestat[3]; - while (l >= 0) - { - if ((sprite[l].lotag & 0xff) == 21 && !hittype[l].temp_data[0] && - (sprite[l].hitag) == j) - hittype[l].temp_data[0] = 1; - l = nextspritestat[l]; - } - callsound(sn, ii); - - return; - } + int j=0, l, q, startwall, endwall; + int i; + char sect_error; + sectortype* sptr; + + sect_error = 0; + sptr = §or[sn]; + + switch (sptr->lotag & (0xffff - 49152)) + { + + case 41: + if (isRR()) operatejaildoors(sptr->hitag); + break; + + case 7: + if (!isRR()) break; + startwall = sptr->wallptr; + endwall = startwall + sptr->wallnum; + for (j = startwall; j < endwall; j++) + { + setanimation(sn, &wall[j].x, wall[j].x + 1024, 4); + setanimation(sn, &wall[wall[j].nextwall].x, wall[wall[j].nextwall].x + 1024, 4); + } + break; + + case ST_30_ROTATE_RISE_BRIDGE: + j = sector[sn].hitag; + if (hittype[j].tempang == 0 || + hittype[j].tempang == 256) + callsound(sn, ii); + if (sprite[j].extra == 1) + sprite[j].extra = 3; + else sprite[j].extra = 1; + break; + + case ST_31_TWO_WAY_TRAIN: + + j = sector[sn].hitag; + if (hittype[j].temp_data[4] == 0) + hittype[j].temp_data[4] = 1; + + callsound(sn, ii); + break; + + case ST_26_SPLITTING_ST_DOOR: //The split doors + i = getanimationgoal(&sptr->ceilingz); + if (i == -1) //if the door has stopped + { + haltsoundhack = 1; + sptr->lotag &= 0xff00; + sptr->lotag |= ST_22_SPLITTING_DOOR; + operatesectors(sn, ii); + sptr->lotag &= 0xff00; + sptr->lotag |= ST_9_SLIDING_ST_DOOR; + operatesectors(sn, ii); + sptr->lotag &= 0xff00; + sptr->lotag |= ST_26_SPLITTING_ST_DOOR; + } + return; + + case ST_9_SLIDING_ST_DOOR: + { + int dax, day, dax2, day2, sp; + int wallfind[2]; + + startwall = sptr->wallptr; + endwall = startwall + sptr->wallnum - 1; + + sp = sptr->extra >> 4; + + //first find center point by averaging all points + dax = 0L, day = 0L; + for (i = startwall; i <= endwall; i++) + { + dax += wall[i].x; + day += wall[i].y; + } + dax /= (endwall - startwall + 1); + day /= (endwall - startwall + 1); + + //find any points with either same x or same y coordinate + // as center (dax, day) - should be 2 points found. + wallfind[0] = -1; + wallfind[1] = -1; + for (i = startwall; i <= endwall; i++) + if ((wall[i].x == dax) || (wall[i].y == day)) + { + if (wallfind[0] == -1) + wallfind[0] = i; + else wallfind[1] = i; + } + + for (j = 0; j < 2; j++) + { + if ((wall[wallfind[j]].x == dax) && (wall[wallfind[j]].y == day)) + { + //find what direction door should open by averaging the + // 2 neighboring points of wallfind[0] & wallfind[1]. + i = wallfind[j] - 1; if (i < startwall) i = endwall; + dax2 = ((wall[i].x + wall[wall[wallfind[j]].point2].x) >> 1) - wall[wallfind[j]].x; + day2 = ((wall[i].y + wall[wall[wallfind[j]].point2].y) >> 1) - wall[wallfind[j]].y; + if (dax2 != 0) + { + dax2 = wall[wall[wall[wallfind[j]].point2].point2].x; + dax2 -= wall[wall[wallfind[j]].point2].x; + setanimation(sn, &wall[wallfind[j]].x, wall[wallfind[j]].x + dax2, sp); + setanimation(sn, &wall[i].x, wall[i].x + dax2, sp); + setanimation(sn, &wall[wall[wallfind[j]].point2].x, wall[wall[wallfind[j]].point2].x + dax2, sp); + callsound(sn, ii); + } + else if (day2 != 0) + { + day2 = wall[wall[wall[wallfind[j]].point2].point2].y; + day2 -= wall[wall[wallfind[j]].point2].y; + setanimation(sn, &wall[wallfind[j]].y, wall[wallfind[j]].y + day2, sp); + setanimation(sn, &wall[i].y, wall[i].y + day2, sp); + setanimation(sn, &wall[wall[wallfind[j]].point2].y, wall[wall[wallfind[j]].point2].y + day2, sp); + callsound(sn, ii); + } + } + else + { + i = wallfind[j] - 1; if (i < startwall) i = endwall; + dax2 = ((wall[i].x + wall[wall[wallfind[j]].point2].x) >> 1) - wall[wallfind[j]].x; + day2 = ((wall[i].y + wall[wall[wallfind[j]].point2].y) >> 1) - wall[wallfind[j]].y; + if (dax2 != 0) + { + setanimation(sn, &wall[wallfind[j]].x, dax, sp); + setanimation(sn, &wall[i].x, dax + dax2, sp); + setanimation(sn, &wall[wall[wallfind[j]].point2].x, dax + dax2, sp); + callsound(sn, ii); + } + else if (day2 != 0) + { + setanimation(sn, &wall[wallfind[j]].y, day, sp); + setanimation(sn, &wall[i].y, day + day2, sp); + setanimation(sn, &wall[wall[wallfind[j]].point2].y, day + day2, sp); + callsound(sn, ii); + } + } + } + + } + return; + + case ST_15_WARP_ELEVATOR://Warping elevators + + if (sprite[ii].picnum != APLAYER) return; + // if(ps[sprite[ii].yvel].select_dir == 1) return; + + i = headspritesect[sn]; + while (i >= 0) + { + if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 17) break; + i = nextspritesect[i]; + } + + if (sprite[ii].sectnum == sn) + { + if (activatewarpelevators(i, -1)) + activatewarpelevators(i, 1); + else if (activatewarpelevators(i, 1)) + activatewarpelevators(i, -1); + return; + } + else + { + if (sptr->floorz > sprite[i].z) + activatewarpelevators(i, -1); + else + activatewarpelevators(i, 1); + } + + return; + + case ST_16_PLATFORM_DOWN: + case ST_17_PLATFORM_UP: + + i = getanimationgoal(&sptr->floorz); + + if (i == -1) + { + i = nextsectorneighborz(sn, sptr->floorz, 1, 1); + if (i == -1) + { + i = nextsectorneighborz(sn, sptr->floorz, 1, -1); + if (i == -1) return; + j = sector[i].floorz; + setanimation(sn, &sptr->floorz, j, sptr->extra); + } + else + { + j = sector[i].floorz; + setanimation(sn, &sptr->floorz, j, sptr->extra); + } + callsound(sn, ii); + } + + return; + + case ST_18_ELEVATOR_DOWN: + case ST_19_ELEVATOR_UP: + + i = getanimationgoal(&sptr->floorz); + + if (i == -1) + { + i = nextsectorneighborz(sn, sptr->floorz, 1, -1); + if (i == -1) i = nextsectorneighborz(sn, sptr->floorz, 1, 1); + if (i == -1) return; + j = sector[i].floorz; + q = sptr->extra; + l = sptr->ceilingz - sptr->floorz; + setanimation(sn, &sptr->floorz, j, q); + setanimation(sn, &sptr->ceilingz, j + l, q); + callsound(sn, ii); + } + return; + + case ST_29_TEETH_DOOR: + + if (sptr->lotag & 0x8000) + j = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz; + else + j = sector[nextsectorneighborz(sn, sptr->ceilingz, -1, -1)].ceilingz; + + i = headspritestat[3]; //Effectors + while (i >= 0) + { + if ((sprite[i].lotag == 22) && + (sprite[i].hitag == sptr->hitag)) + { + sector[sprite[i].sectnum].extra = -sector[sprite[i].sectnum].extra; + + hittype[i].temp_data[0] = sn; + hittype[i].temp_data[1] = 1; + } + i = nextspritestat[i]; + } + + sptr->lotag ^= 0x8000; + + setanimation(sn, &sptr->ceilingz, j, sptr->extra); + + callsound(sn, ii); + + return; + + case ST_20_CEILING_DOOR: + REDODOOR: + + if (sptr->lotag & 0x8000) + { + i = headspritesect[sn]; + while (i >= 0) + { + if (sprite[i].statnum == 3 && sprite[i].lotag == 9) + { + j = sprite[i].z; + break; + } + i = nextspritesect[i]; + } + if (i == -1) + j = sptr->floorz; + } + else + { + j = nextsectorneighborz(sn, sptr->ceilingz, -1, -1); + + if (j >= 0) j = sector[j].ceilingz; + else + { + sptr->lotag |= 32768; + goto REDODOOR; + } + } + + sptr->lotag ^= 0x8000; + + setanimation(sn, &sptr->ceilingz, j, sptr->extra); + callsound(sn, ii); + + return; + + case ST_21_FLOOR_DOOR: + i = getanimationgoal(&sptr->floorz); + if (i >= 0) + { + if (animategoal[sn] == sptr->ceilingz) + animategoal[i] = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz; + else animategoal[i] = sptr->ceilingz; + j = animategoal[i]; + } + else + { + if (sptr->ceilingz == sptr->floorz) + j = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz; + else j = sptr->ceilingz; + + sptr->lotag ^= 0x8000; + + if (setanimation(sn, &sptr->floorz, j, sptr->extra) >= 0) + callsound(sn, ii); + } + return; + + case ST_22_SPLITTING_DOOR: + + if ((sptr->lotag & 0x8000)) + { + q = (sptr->ceilingz + sptr->floorz) >> 1; + j = setanimation(sn, &sptr->floorz, q, sptr->extra); + j = setanimation(sn, &sptr->ceilingz, q, sptr->extra); + } + else + { + q = sector[nextsectorneighborz(sn, sptr->floorz, 1, 1)].floorz; + j = setanimation(sn, &sptr->floorz, q, sptr->extra); + q = sector[nextsectorneighborz(sn, sptr->ceilingz, -1, -1)].ceilingz; + j = setanimation(sn, &sptr->ceilingz, q, sptr->extra); + } + + sptr->lotag ^= 0x8000; + + callsound(sn, ii); + + return; + + case ST_23_SWINGING_DOOR: //Swingdoor + + j = -1; + q = 0; + + i = headspritestat[3]; + while (i >= 0) + { + if (sprite[i].lotag == 11 && sprite[i].sectnum == sn && !hittype[i].temp_data[4]) + { + j = i; + break; + } + i = nextspritestat[i]; + } + + l = sector[sprite[i].sectnum].lotag & 0x8000; + + if (j >= 0) + { + i = headspritestat[3]; + while (i >= 0) + { + if (l == (sector[sprite[i].sectnum].lotag & 0x8000) && sprite[i].lotag == 11 && sprite[j].hitag == sprite[i].hitag && !hittype[i].temp_data[4]) + { + if (sector[sprite[i].sectnum].lotag & 0x8000) sector[sprite[i].sectnum].lotag &= 0x7fff; + else sector[sprite[i].sectnum].lotag |= 0x8000; + hittype[i].temp_data[4] = 1; + hittype[i].temp_data[3] = -hittype[i].temp_data[3]; + if (q == 0) + { + callsound(sn, i); + q = 1; + } + } + i = nextspritestat[i]; + } + } + return; + + case ST_25_SLIDING_DOOR: //Subway type sliding doors + + j = headspritestat[3]; + while (j >= 0)//Find the sprite + { + if ((sprite[j].lotag) == 15 && sprite[j].sectnum == sn) + break; //Found the sectoreffector. + j = nextspritestat[j]; + } + + if (j < 0) + return; + + i = headspritestat[3]; + while (i >= 0) + { + if (sprite[i].hitag == sprite[j].hitag) + { + if (sprite[i].lotag == 15) + { + sector[sprite[i].sectnum].lotag ^= 0x8000; // Toggle the open or close + sprite[i].ang += 1024; + if (hittype[i].temp_data[4]) callsound(sprite[i].sectnum, i); + callsound(sprite[i].sectnum, i); + if (sector[sprite[i].sectnum].lotag & 0x8000) hittype[i].temp_data[4] = 1; + else hittype[i].temp_data[4] = 2; + } + } + i = nextspritestat[i]; + } + return; + + case ST_27_STRETCH_BRIDGE: //Extended bridge + + j = headspritestat[3]; + while (j >= 0) + { + if ((sprite[j].lotag & 0xff) == 20 && sprite[j].sectnum == sn) //Bridge + { + + sector[sn].lotag ^= 0x8000; + if (sector[sn].lotag & 0x8000) //OPENING + hittype[j].temp_data[0] = 1; + else hittype[j].temp_data[0] = 2; + callsound(sn, ii); + break; + } + j = nextspritestat[j]; + } + return; + + + case ST_28_DROP_FLOOR: + //activate the rest of them + + j = headspritesect[sn]; + while (j >= 0) + { + if (sprite[j].statnum == 3 && (sprite[j].lotag & 0xff) == 21) + break; //Found it + j = nextspritesect[j]; + } + + j = sprite[j].hitag; + + l = headspritestat[3]; + while (l >= 0) + { + if ((sprite[l].lotag & 0xff) == 21 && !hittype[l].temp_data[0] && + (sprite[l].hitag) == j) + hittype[l].temp_data[0] = 1; + l = nextspritestat[l]; + } + callsound(sn, ii); + + return; + } } @@ -995,94 +995,94 @@ void operatesectors(int sn, int ii) void operateactivators(int low, int snum) { - int i, j, k; - short * p; - walltype* wal; + int i, j, k; + short * p; + walltype* wal; - for (i = numcyclers - 1; i >= 0; i--) - { - p = &cyclers[i][0]; + for (i = numcyclers - 1; i >= 0; i--) + { + p = &cyclers[i][0]; - if (p[4] == low) - { - p[5] = !p[5]; + if (p[4] == low) + { + p[5] = !p[5]; - sector[p[0]].floorshade = sector[p[0]].ceilingshade = p[3]; - wal = &wall[sector[p[0]].wallptr]; - for (j = sector[p[0]].wallnum; j > 0; j--, wal++) - wal->shade = p[3]; - } - } + sector[p[0]].floorshade = sector[p[0]].ceilingshade = p[3]; + wal = &wall[sector[p[0]].wallptr]; + for (j = sector[p[0]].wallnum; j > 0; j--, wal++) + wal->shade = p[3]; + } + } - i = headspritestat[8]; - k = -1; - while (i >= 0) - { - if (sprite[i].lotag == low) - { - if (sprite[i].picnum == ACTIVATORLOCKED) - { - sector[sprite[i].sectnum].lotag ^= 16384; + i = headspritestat[8]; + k = -1; + while (i >= 0) + { + if (sprite[i].lotag == low) + { + if (sprite[i].picnum == ACTIVATORLOCKED) + { + sector[sprite[i].sectnum].lotag ^= 16384; - if (snum >= 0) - { - if (sector[sprite[i].sectnum].lotag & 16384) - FTA(4, &ps[snum]); - else FTA(8, &ps[snum]); - } - } - else - { - switch (sprite[i].hitag) - { - case 0: - break; - case 1: - if (sector[sprite[i].sectnum].floorz != sector[sprite[i].sectnum].ceilingz) - { - i = nextspritestat[i]; - continue; - } - break; - case 2: - if (sector[sprite[i].sectnum].floorz == sector[sprite[i].sectnum].ceilingz) - { - i = nextspritestat[i]; - continue; - } - break; - } + if (snum >= 0) + { + if (sector[sprite[i].sectnum].lotag & 16384) + FTA(4, &ps[snum]); + else FTA(8, &ps[snum]); + } + } + else + { + switch (sprite[i].hitag) + { + case 0: + break; + case 1: + if (sector[sprite[i].sectnum].floorz != sector[sprite[i].sectnum].ceilingz) + { + i = nextspritestat[i]; + continue; + } + break; + case 2: + if (sector[sprite[i].sectnum].floorz == sector[sprite[i].sectnum].ceilingz) + { + i = nextspritestat[i]; + continue; + } + break; + } - if (sector[sprite[i].sectnum].lotag < 3) - { - j = headspritesect[sprite[i].sectnum]; - while (j >= 0) - { - if (sprite[j].statnum == 3) switch (sprite[j].lotag) - { - case SE_18_INCREMENTAL_SECTOR_RISE_FALL: - if (isRRRA()) break; - case SE_36_PROJ_SHOOTER: - case SE_31_FLOOR_RISE_FALL: - case SE_32_CEILING_RISE_FALL: - hittype[j].temp_data[0] = 1 - hittype[j].temp_data[0]; - callsound(sprite[i].sectnum, j); - break; - } - j = nextspritesect[j]; - } - } + if (sector[sprite[i].sectnum].lotag < 3) + { + j = headspritesect[sprite[i].sectnum]; + while (j >= 0) + { + if (sprite[j].statnum == 3) switch (sprite[j].lotag) + { + case SE_18_INCREMENTAL_SECTOR_RISE_FALL: + if (isRRRA()) break; + case SE_36_PROJ_SHOOTER: + case SE_31_FLOOR_RISE_FALL: + case SE_32_CEILING_RISE_FALL: + hittype[j].temp_data[0] = 1 - hittype[j].temp_data[0]; + callsound(sprite[i].sectnum, j); + break; + } + j = nextspritesect[j]; + } + } - if (k == -1 && (sector[sprite[i].sectnum].lotag & 0xff) == 22) - k = callsound(sprite[i].sectnum, i); + if (k == -1 && (sector[sprite[i].sectnum].lotag & 0xff) == 22) + k = callsound(sprite[i].sectnum, i); - operatesectors(sprite[i].sectnum, i); - } - } - i = nextspritestat[i]; - } + operatesectors(sprite[i].sectnum, i); + } + } + i = nextspritestat[i]; + } - operaterespawns(low); + operaterespawns(low); } //--------------------------------------------------------------------------- @@ -1093,15 +1093,15 @@ void operateactivators(int low, int snum) void operatemasterswitches(int low) { - short i; + short i; - i = headspritestat[6]; - while (i >= 0) - { - if (sprite[i].picnum == MASTERSWITCH && sprite[i].lotag == low && sprite[i].yvel == 0) - sprite[i].yvel = 1; - i = nextspritestat[i]; - } + i = headspritestat[6]; + while (i >= 0) + { + if (sprite[i].picnum == MASTERSWITCH && sprite[i].lotag == low && sprite[i].yvel == 0) + sprite[i].yvel = 1; + i = nextspritestat[i]; + } } //--------------------------------------------------------------------------- @@ -1112,29 +1112,29 @@ void operatemasterswitches(int low) void operateforcefields_common(int s, int low, const std::initializer_list &tiles) { - int i, p; + int i, p; - for (p = numanimwalls; p >= 0; p--) - { - i = animwall[p].wallnum; + for (p = numanimwalls; p >= 0; p--) + { + i = animwall[p].wallnum; - if (low == wall[i].lotag || low == -1) - if (isIn(wall[i].overpicnum, tiles)) - { - animwall[p].tag = 0; + if (low == wall[i].lotag || low == -1) + if (isIn(wall[i].overpicnum, tiles)) + { + animwall[p].tag = 0; - if (wall[i].cstat) - { - wall[i].cstat = 0; + if (wall[i].cstat) + { + wall[i].cstat = 0; - if (s >= 0 && sprite[s].picnum == SECTOREFFECTOR && - sprite[s].lotag == 30) - wall[i].lotag = 0; - } - else - wall[i].cstat = 85; - } - } + if (s >= 0 && sprite[s].picnum == SECTOREFFECTOR && + sprite[s].lotag == 30) + wall[i].lotag = 0; + } + else + wall[i].cstat = 85; + } + } } //--------------------------------------------------------------------------- @@ -1145,10 +1145,10 @@ void operateforcefields_common(int s, int low, const std::initializer_list void breakwall(short newpn, short spr, short dawallnum) { - wall[dawallnum].picnum = newpn; - spritesound(VENT_BUST, spr); - spritesound(GLASS_HEAVYBREAK, spr); - lotsofglass(spr, dawallnum, 10); + wall[dawallnum].picnum = newpn; + spritesound(VENT_BUST, spr); + spritesound(GLASS_HEAVYBREAK, spr); + lotsofglass(spr, dawallnum, 10); } //--------------------------------------------------------------------------- @@ -1159,28 +1159,28 @@ void breakwall(short newpn, short spr, short dawallnum) void allignwarpelevators(void) { - short i, j; + short i, j; - i = headspritestat[STAT_EFFECTOR]; - while (i >= 0) - { - if (sprite[i].lotag == SE_17_WARP_ELEVATOR && sprite[i].shade > 16) - { - j = headspritestat[STAT_EFFECTOR]; - while (j >= 0) - { - if ((sprite[j].lotag) == SE_17_WARP_ELEVATOR && i != j && - (sprite[i].hitag) == (sprite[j].hitag)) - { - sector[sprite[j].sectnum].floorz = sector[sprite[i].sectnum].floorz; - sector[sprite[j].sectnum].ceilingz = sector[sprite[i].sectnum].ceilingz; - } + i = headspritestat[STAT_EFFECTOR]; + while (i >= 0) + { + if (sprite[i].lotag == SE_17_WARP_ELEVATOR && sprite[i].shade > 16) + { + j = headspritestat[STAT_EFFECTOR]; + while (j >= 0) + { + if ((sprite[j].lotag) == SE_17_WARP_ELEVATOR && i != j && + (sprite[i].hitag) == (sprite[j].hitag)) + { + sector[sprite[j].sectnum].floorz = sector[sprite[i].sectnum].floorz; + sector[sprite[j].sectnum].ceilingz = sector[sprite[i].sectnum].ceilingz; + } - j = nextspritestat[j]; - } - } - i = nextspritestat[i]; - } + j = nextspritestat[j]; + } + } + i = nextspritestat[i]; + } } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 18a398edb..167233caf 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -47,33 +47,33 @@ BEGIN_DUKE_NS bool isadoorwall_d(int dapic) { - switch(dapic) - { - case DOORTILE1: - case DOORTILE2: - case DOORTILE3: - case DOORTILE4: - case DOORTILE5: - case DOORTILE6: - case DOORTILE7: - case DOORTILE8: - case DOORTILE9: - case DOORTILE10: - case DOORTILE11: - case DOORTILE12: - case DOORTILE14: - case DOORTILE15: - case DOORTILE16: - case DOORTILE17: - case DOORTILE18: - case DOORTILE19: - case DOORTILE20: - case DOORTILE21: - case DOORTILE22: - case DOORTILE23: - return 1; - } - return 0; + switch(dapic) + { + case DOORTILE1: + case DOORTILE2: + case DOORTILE3: + case DOORTILE4: + case DOORTILE5: + case DOORTILE6: + case DOORTILE7: + case DOORTILE8: + case DOORTILE9: + case DOORTILE10: + case DOORTILE11: + case DOORTILE12: + case DOORTILE14: + case DOORTILE15: + case DOORTILE16: + case DOORTILE17: + case DOORTILE18: + case DOORTILE19: + case DOORTILE20: + case DOORTILE21: + case DOORTILE22: + case DOORTILE23: + return 1; + } + return 0; } //--------------------------------------------------------------------------- @@ -84,96 +84,96 @@ bool isadoorwall_d(int dapic) void animatewalls_d(void) { - int i, j, p, t; + int i, j, p, t; - for (p = 0; p < numanimwalls; p++) - { - i = animwall[p].wallnum; - j = wall[i].picnum; + for (p = 0; p < numanimwalls; p++) + { + i = animwall[p].wallnum; + j = wall[i].picnum; - switch (j) - { - case SCREENBREAK1: - case SCREENBREAK2: - case SCREENBREAK3: - case SCREENBREAK4: - case SCREENBREAK5: + switch (j) + { + case SCREENBREAK1: + case SCREENBREAK2: + case SCREENBREAK3: + case SCREENBREAK4: + case SCREENBREAK5: - case SCREENBREAK9: - case SCREENBREAK10: - case SCREENBREAK11: - case SCREENBREAK12: - case SCREENBREAK13: - case SCREENBREAK14: - case SCREENBREAK15: - case SCREENBREAK16: - case SCREENBREAK17: - case SCREENBREAK18: - case SCREENBREAK19: + case SCREENBREAK9: + case SCREENBREAK10: + case SCREENBREAK11: + case SCREENBREAK12: + case SCREENBREAK13: + case SCREENBREAK14: + case SCREENBREAK15: + case SCREENBREAK16: + case SCREENBREAK17: + case SCREENBREAK18: + case SCREENBREAK19: - if ((krand() & 255) < 16) - { - animwall[p].tag = wall[i].picnum; - wall[i].picnum = SCREENBREAK6; - } + if ((krand() & 255) < 16) + { + animwall[p].tag = wall[i].picnum; + wall[i].picnum = SCREENBREAK6; + } - continue; + continue; - case SCREENBREAK6: - case SCREENBREAK7: - case SCREENBREAK8: + case SCREENBREAK6: + case SCREENBREAK7: + case SCREENBREAK8: - if (animwall[p].tag >= 0 && wall[i].extra != FEMPIC2 && wall[i].extra != FEMPIC3) - wall[i].picnum = animwall[p].tag; - else - { - wall[i].picnum++; - if (wall[i].picnum == (SCREENBREAK6 + 3)) - wall[i].picnum = SCREENBREAK6; - } - continue; + if (animwall[p].tag >= 0 && wall[i].extra != FEMPIC2 && wall[i].extra != FEMPIC3) + wall[i].picnum = animwall[p].tag; + else + { + wall[i].picnum++; + if (wall[i].picnum == (SCREENBREAK6 + 3)) + wall[i].picnum = SCREENBREAK6; + } + continue; - } + } - if (wall[i].cstat & 16) - switch (wall[i].overpicnum) - { - case W_FORCEFIELD: - case W_FORCEFIELD + 1: - case W_FORCEFIELD + 2: + if (wall[i].cstat & 16) + switch (wall[i].overpicnum) + { + case W_FORCEFIELD: + case W_FORCEFIELD + 1: + case W_FORCEFIELD + 2: - t = animwall[p].tag; + t = animwall[p].tag; - if (wall[i].cstat & 254) - { - wall[i].xpanning -= t >> 10; // sintable[(t+512)&2047]>>12; - wall[i].ypanning -= t >> 10; // sintable[t&2047]>>12; + if (wall[i].cstat & 254) + { + wall[i].xpanning -= t >> 10; // sintable[(t+512)&2047]>>12; + wall[i].ypanning -= t >> 10; // sintable[t&2047]>>12; - if (wall[i].extra == 1) - { - wall[i].extra = 0; - animwall[p].tag = 0; - } - else - animwall[p].tag += 128; + if (wall[i].extra == 1) + { + wall[i].extra = 0; + animwall[p].tag = 0; + } + else + animwall[p].tag += 128; - if (animwall[p].tag < (128 << 4)) - { - if (animwall[p].tag & 128) - wall[i].overpicnum = W_FORCEFIELD; - else wall[i].overpicnum = W_FORCEFIELD + 1; - } - else - { - if ((krand() & 255) < 32) - animwall[p].tag = 128 << (krand() & 3); - else wall[i].overpicnum = W_FORCEFIELD + 1; - } - } + if (animwall[p].tag < (128 << 4)) + { + if (animwall[p].tag & 128) + wall[i].overpicnum = W_FORCEFIELD; + else wall[i].overpicnum = W_FORCEFIELD + 1; + } + else + { + if ((krand() & 255) < 32) + animwall[p].tag = 128 << (krand() & 3); + else wall[i].overpicnum = W_FORCEFIELD + 1; + } + } - break; - } - } + break; + } + } } //--------------------------------------------------------------------------- @@ -184,25 +184,25 @@ void animatewalls_d(void) void operaterespawns_d(int low) { - short i, j, nexti; + short i, j, nexti; - i = headspritestat[11]; - while (i >= 0) - { - nexti = nextspritestat[i]; - if (sprite[i].lotag == low) switch (sprite[i].picnum) - { - case RESPAWN: - if (badguypic(sprite[i].hitag) && ud.monsters_off) break; + i = headspritestat[11]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].lotag == low) switch (sprite[i].picnum) + { + case RESPAWN: + if (badguypic(sprite[i].hitag) && ud.monsters_off) break; - j = spawn(i, TRANSPORTERSTAR); - sprite[j].z -= (32 << 8); + j = spawn(i, TRANSPORTERSTAR); + sprite[j].z -= (32 << 8); - sprite[i].extra = 66 - 12; // Just a way to killit - break; - } - i = nexti; - } + sprite[i].extra = 66 - 12; // Just a way to killit + break; + } + i = nexti; + } } //--------------------------------------------------------------------------- @@ -213,7 +213,7 @@ void operaterespawns_d(int low) void operateforcefields_d(int s, int low) { - operateforcefields_common(s, low, { W_FORCEFIELD, W_FORCEFIELD + 1, W_FORCEFIELD + 2, BIGFORCE }); + operateforcefields_common(s, low, { W_FORCEFIELD, W_FORCEFIELD + 1, W_FORCEFIELD + 2, BIGFORCE }); } //--------------------------------------------------------------------------- @@ -224,49 +224,49 @@ void operateforcefields_d(int s, int low) bool checkhitswitch_d(int snum, int w, int switchtype) { - uint8_t switchpal; - int i, x, lotag, hitag, picnum, correctdips, numdips; - int sx, sy; + uint8_t switchpal; + int i, x, lotag, hitag, picnum, correctdips, numdips; + int sx, sy; - if (w < 0) return 0; - correctdips = 1; - numdips = 0; + if (w < 0) return 0; + correctdips = 1; + numdips = 0; - if (switchtype == SWITCH_SPRITE) // A wall sprite - { - lotag = sprite[w].lotag; + if (switchtype == SWITCH_SPRITE) // A wall sprite + { + lotag = sprite[w].lotag; if (lotag == 0) return 0; - hitag = sprite[w].hitag; - sx = sprite[w].x; - sy = sprite[w].y; - picnum = sprite[w].picnum; - switchpal = sprite[w].pal; - } - else - { - lotag = wall[w].lotag; + hitag = sprite[w].hitag; + sx = sprite[w].x; + sy = sprite[w].y; + picnum = sprite[w].picnum; + switchpal = sprite[w].pal; + } + else + { + lotag = wall[w].lotag; if (lotag == 0) return 0; - hitag = wall[w].hitag; - sx = wall[w].x; - sy = wall[w].y; - picnum = wall[w].picnum; - switchpal = wall[w].pal; - } + hitag = wall[w].hitag; + sx = wall[w].x; + sy = wall[w].y; + picnum = wall[w].picnum; + switchpal = wall[w].pal; + } - switch (picnum) - { - case DIPSWITCH: - case DIPSWITCH + 1: - case TECHSWITCH: - case TECHSWITCH + 1: - case ALIENSWITCH: - case ALIENSWITCH + 1: - break; + switch (picnum) + { + case DIPSWITCH: + case DIPSWITCH + 1: + case TECHSWITCH: + case TECHSWITCH + 1: + case ALIENSWITCH: + case ALIENSWITCH + 1: + break; case DEVELOPERCOMMENTARY + 1: //Twentieth Anniversary World Tour if (switchtype == 1) { sprite[w].picnum--; - StopCommentary(); + StopCommentary(); return true; } return false; @@ -278,344 +278,344 @@ bool checkhitswitch_d(int snum, int w, int switchtype) return true; } return false; - case ACCESSSWITCH: - case ACCESSSWITCH2: - if (ps[snum].access_incs == 0) - { - if (switchpal == 0) - { - if ((ps[snum].got_access & 1)) - ps[snum].access_incs = 1; - else FTA(70, &ps[snum]); - } + case ACCESSSWITCH: + case ACCESSSWITCH2: + if (ps[snum].access_incs == 0) + { + if (switchpal == 0) + { + if ((ps[snum].got_access & 1)) + ps[snum].access_incs = 1; + else FTA(70, &ps[snum]); + } - else if (switchpal == 21) - { - if (ps[snum].got_access & 2) - ps[snum].access_incs = 1; - else FTA(71, &ps[snum]); - } + else if (switchpal == 21) + { + if (ps[snum].got_access & 2) + ps[snum].access_incs = 1; + else FTA(71, &ps[snum]); + } - else if (switchpal == 23) - { - if (ps[snum].got_access & 4) - ps[snum].access_incs = 1; - else FTA(72, &ps[snum]); - } + else if (switchpal == 23) + { + if (ps[snum].got_access & 4) + ps[snum].access_incs = 1; + else FTA(72, &ps[snum]); + } - if (ps[snum].access_incs == 1) - { - if (switchtype == SWITCH_WALL) - ps[snum].access_wallnum = w; - else - ps[snum].access_spritenum = w; - } + if (ps[snum].access_incs == 1) + { + if (switchtype == SWITCH_WALL) + ps[snum].access_wallnum = w; + else + ps[snum].access_spritenum = w; + } - return 0; - } - case DIPSWITCH2: - case DIPSWITCH2 + 1: - case DIPSWITCH3: - case DIPSWITCH3 + 1: - case MULTISWITCH: - case MULTISWITCH + 1: - case MULTISWITCH + 2: - case MULTISWITCH + 3: - case PULLSWITCH: - case PULLSWITCH + 1: - case HANDSWITCH: - case HANDSWITCH + 1: - case SLOTDOOR: - case SLOTDOOR + 1: - case LIGHTSWITCH: - case LIGHTSWITCH + 1: - case SPACELIGHTSWITCH: - case SPACELIGHTSWITCH + 1: - case SPACEDOORSWITCH: - case SPACEDOORSWITCH + 1: - case FRANKENSTINESWITCH: - case FRANKENSTINESWITCH + 1: - case LIGHTSWITCH2: - case LIGHTSWITCH2 + 1: - case POWERSWITCH1: - case POWERSWITCH1 + 1: - case LOCKSWITCH1: - case LOCKSWITCH1 + 1: - case POWERSWITCH2: - case POWERSWITCH2 + 1: - if (check_activator_motion(lotag)) return 0; - break; - default: - if (isadoorwall(picnum) == 0) return 0; - break; - } + return 0; + } + case DIPSWITCH2: + case DIPSWITCH2 + 1: + case DIPSWITCH3: + case DIPSWITCH3 + 1: + case MULTISWITCH: + case MULTISWITCH + 1: + case MULTISWITCH + 2: + case MULTISWITCH + 3: + case PULLSWITCH: + case PULLSWITCH + 1: + case HANDSWITCH: + case HANDSWITCH + 1: + case SLOTDOOR: + case SLOTDOOR + 1: + case LIGHTSWITCH: + case LIGHTSWITCH + 1: + case SPACELIGHTSWITCH: + case SPACELIGHTSWITCH + 1: + case SPACEDOORSWITCH: + case SPACEDOORSWITCH + 1: + case FRANKENSTINESWITCH: + case FRANKENSTINESWITCH + 1: + case LIGHTSWITCH2: + case LIGHTSWITCH2 + 1: + case POWERSWITCH1: + case POWERSWITCH1 + 1: + case LOCKSWITCH1: + case LOCKSWITCH1 + 1: + case POWERSWITCH2: + case POWERSWITCH2 + 1: + if (check_activator_motion(lotag)) return 0; + break; + default: + if (isadoorwall(picnum) == 0) return 0; + break; + } - i = headspritestat[0]; - while (i >= 0) - { - if (lotag == sprite[i].lotag) switch (sprite[i].picnum) - { - case DIPSWITCH: - case TECHSWITCH: - case ALIENSWITCH: - if (switchtype == SWITCH_SPRITE && w == i) sprite[i].picnum++; - else if (sprite[i].hitag == 0) correctdips++; - numdips++; - break; - case TECHSWITCH + 1: - case DIPSWITCH + 1: - case ALIENSWITCH + 1: - if (switchtype == SWITCH_SPRITE && w == i) sprite[i].picnum--; - else if (sprite[i].hitag == 1) correctdips++; - numdips++; - break; - case MULTISWITCH: - case MULTISWITCH + 1: - case MULTISWITCH + 2: - case MULTISWITCH + 3: - sprite[i].picnum++; - if (sprite[i].picnum > (MULTISWITCH + 3)) - sprite[i].picnum = MULTISWITCH; - break; - case ACCESSSWITCH: - case ACCESSSWITCH2: - case SLOTDOOR: - case LIGHTSWITCH: - case SPACELIGHTSWITCH: - case SPACEDOORSWITCH: - case FRANKENSTINESWITCH: - case LIGHTSWITCH2: - case POWERSWITCH1: - case LOCKSWITCH1: - case POWERSWITCH2: - case HANDSWITCH: - case PULLSWITCH: - case DIPSWITCH2: - case DIPSWITCH3: - sprite[i].picnum++; - break; - case PULLSWITCH + 1: - case HANDSWITCH + 1: - case LIGHTSWITCH2 + 1: - case POWERSWITCH1 + 1: - case LOCKSWITCH1 + 1: - case POWERSWITCH2 + 1: - case SLOTDOOR + 1: - case LIGHTSWITCH + 1: - case SPACELIGHTSWITCH + 1: - case SPACEDOORSWITCH + 1: - case FRANKENSTINESWITCH + 1: - case DIPSWITCH2 + 1: - case DIPSWITCH3 + 1: - sprite[i].picnum--; - break; - } - i = nextspritestat[i]; - } + i = headspritestat[0]; + while (i >= 0) + { + if (lotag == sprite[i].lotag) switch (sprite[i].picnum) + { + case DIPSWITCH: + case TECHSWITCH: + case ALIENSWITCH: + if (switchtype == SWITCH_SPRITE && w == i) sprite[i].picnum++; + else if (sprite[i].hitag == 0) correctdips++; + numdips++; + break; + case TECHSWITCH + 1: + case DIPSWITCH + 1: + case ALIENSWITCH + 1: + if (switchtype == SWITCH_SPRITE && w == i) sprite[i].picnum--; + else if (sprite[i].hitag == 1) correctdips++; + numdips++; + break; + case MULTISWITCH: + case MULTISWITCH + 1: + case MULTISWITCH + 2: + case MULTISWITCH + 3: + sprite[i].picnum++; + if (sprite[i].picnum > (MULTISWITCH + 3)) + sprite[i].picnum = MULTISWITCH; + break; + case ACCESSSWITCH: + case ACCESSSWITCH2: + case SLOTDOOR: + case LIGHTSWITCH: + case SPACELIGHTSWITCH: + case SPACEDOORSWITCH: + case FRANKENSTINESWITCH: + case LIGHTSWITCH2: + case POWERSWITCH1: + case LOCKSWITCH1: + case POWERSWITCH2: + case HANDSWITCH: + case PULLSWITCH: + case DIPSWITCH2: + case DIPSWITCH3: + sprite[i].picnum++; + break; + case PULLSWITCH + 1: + case HANDSWITCH + 1: + case LIGHTSWITCH2 + 1: + case POWERSWITCH1 + 1: + case LOCKSWITCH1 + 1: + case POWERSWITCH2 + 1: + case SLOTDOOR + 1: + case LIGHTSWITCH + 1: + case SPACELIGHTSWITCH + 1: + case SPACEDOORSWITCH + 1: + case FRANKENSTINESWITCH + 1: + case DIPSWITCH2 + 1: + case DIPSWITCH3 + 1: + sprite[i].picnum--; + break; + } + i = nextspritestat[i]; + } - for (i = 0; i < numwalls; i++) - { - x = i; - if (lotag == wall[x].lotag) - switch (wall[x].picnum) - { - case DIPSWITCH: - case TECHSWITCH: - case ALIENSWITCH: - if (switchtype == SWITCH_WALL && i == w) wall[x].picnum++; - else if (wall[x].hitag == 0) correctdips++; - numdips++; - break; - case DIPSWITCH + 1: - case TECHSWITCH + 1: - case ALIENSWITCH + 1: - if (switchtype == SWITCH_WALL && i == w) wall[x].picnum--; - else if (wall[x].hitag == 1) correctdips++; - numdips++; - break; - case MULTISWITCH: - case MULTISWITCH + 1: - case MULTISWITCH + 2: - case MULTISWITCH + 3: - wall[x].picnum++; - if (wall[x].picnum > (MULTISWITCH + 3)) - wall[x].picnum = MULTISWITCH; - break; - case ACCESSSWITCH: - case ACCESSSWITCH2: - case SLOTDOOR: - case LIGHTSWITCH: - case SPACELIGHTSWITCH: - case SPACEDOORSWITCH: - case LIGHTSWITCH2: - case POWERSWITCH1: - case LOCKSWITCH1: - case POWERSWITCH2: - case PULLSWITCH: - case HANDSWITCH: - case DIPSWITCH2: - case DIPSWITCH3: - wall[x].picnum++; - break; - case HANDSWITCH + 1: - case PULLSWITCH + 1: - case LIGHTSWITCH2 + 1: - case POWERSWITCH1 + 1: - case LOCKSWITCH1 + 1: - case POWERSWITCH2 + 1: - case SLOTDOOR + 1: - case LIGHTSWITCH + 1: - case SPACELIGHTSWITCH + 1: - case SPACEDOORSWITCH + 1: - case DIPSWITCH2 + 1: - case DIPSWITCH3 + 1: - wall[x].picnum--; - break; - } - } + for (i = 0; i < numwalls; i++) + { + x = i; + if (lotag == wall[x].lotag) + switch (wall[x].picnum) + { + case DIPSWITCH: + case TECHSWITCH: + case ALIENSWITCH: + if (switchtype == SWITCH_WALL && i == w) wall[x].picnum++; + else if (wall[x].hitag == 0) correctdips++; + numdips++; + break; + case DIPSWITCH + 1: + case TECHSWITCH + 1: + case ALIENSWITCH + 1: + if (switchtype == SWITCH_WALL && i == w) wall[x].picnum--; + else if (wall[x].hitag == 1) correctdips++; + numdips++; + break; + case MULTISWITCH: + case MULTISWITCH + 1: + case MULTISWITCH + 2: + case MULTISWITCH + 3: + wall[x].picnum++; + if (wall[x].picnum > (MULTISWITCH + 3)) + wall[x].picnum = MULTISWITCH; + break; + case ACCESSSWITCH: + case ACCESSSWITCH2: + case SLOTDOOR: + case LIGHTSWITCH: + case SPACELIGHTSWITCH: + case SPACEDOORSWITCH: + case LIGHTSWITCH2: + case POWERSWITCH1: + case LOCKSWITCH1: + case POWERSWITCH2: + case PULLSWITCH: + case HANDSWITCH: + case DIPSWITCH2: + case DIPSWITCH3: + wall[x].picnum++; + break; + case HANDSWITCH + 1: + case PULLSWITCH + 1: + case LIGHTSWITCH2 + 1: + case POWERSWITCH1 + 1: + case LOCKSWITCH1 + 1: + case POWERSWITCH2 + 1: + case SLOTDOOR + 1: + case LIGHTSWITCH + 1: + case SPACELIGHTSWITCH + 1: + case SPACEDOORSWITCH + 1: + case DIPSWITCH2 + 1: + case DIPSWITCH3 + 1: + wall[x].picnum--; + break; + } + } - if (lotag == (short)65535) - { - ps[myconnectindex].gm = MODE_EOL; - if (ud.from_bonus) - { - ud.level_number = ud.from_bonus; - ud.m_level_number = ud.level_number; - ud.from_bonus = 0; - } - else - { - // fixme: This needs to be taken from the level definitions. - ud.level_number = (++ud.level_number < MAXLEVELS) ? ud.level_number : 0; - ud.m_level_number = ud.level_number; - } - return 1; - } + if (lotag == (short)65535) + { + ps[myconnectindex].gm = MODE_EOL; + if (ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + // fixme: This needs to be taken from the level definitions. + ud.level_number = (++ud.level_number < MAXLEVELS) ? ud.level_number : 0; + ud.m_level_number = ud.level_number; + } + return 1; + } - vec3_t v = { sx, sy, ps[snum].posz }; - switch (picnum) - { - default: - if (isadoorwall(picnum) == 0) break; - case DIPSWITCH: - case DIPSWITCH + 1: - case TECHSWITCH: - case TECHSWITCH + 1: - case ALIENSWITCH: - case ALIENSWITCH + 1: - if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || - picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || - picnum == TECHSWITCH || picnum == TECHSWITCH + 1) - { - if (picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1) - { - if (switchtype == SWITCH_SPRITE) - S_PlaySound3D(ALIEN_SWITCH1, w, &v); - else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].i, &v); - } - else - { - if (switchtype == SWITCH_SPRITE) - S_PlaySound3D(SWITCH_ON, w, &v); - else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); - } - if (numdips != correctdips) break; - S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].i, &v); - } - case DIPSWITCH2: - case DIPSWITCH2 + 1: - case DIPSWITCH3: - case DIPSWITCH3 + 1: - case MULTISWITCH: - case MULTISWITCH + 1: - case MULTISWITCH + 2: - case MULTISWITCH + 3: - case ACCESSSWITCH: - case ACCESSSWITCH2: - case SLOTDOOR: - case SLOTDOOR + 1: - case LIGHTSWITCH: - case LIGHTSWITCH + 1: - case SPACELIGHTSWITCH: - case SPACELIGHTSWITCH + 1: - case SPACEDOORSWITCH: - case SPACEDOORSWITCH + 1: - case FRANKENSTINESWITCH: - case FRANKENSTINESWITCH + 1: - case LIGHTSWITCH2: - case LIGHTSWITCH2 + 1: - case POWERSWITCH1: - case POWERSWITCH1 + 1: - case LOCKSWITCH1: - case LOCKSWITCH1 + 1: - case POWERSWITCH2: - case POWERSWITCH2 + 1: - case HANDSWITCH: - case HANDSWITCH + 1: - case PULLSWITCH: - case PULLSWITCH + 1: + vec3_t v = { sx, sy, ps[snum].posz }; + switch (picnum) + { + default: + if (isadoorwall(picnum) == 0) break; + case DIPSWITCH: + case DIPSWITCH + 1: + case TECHSWITCH: + case TECHSWITCH + 1: + case ALIENSWITCH: + case ALIENSWITCH + 1: + if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || + picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || + picnum == TECHSWITCH || picnum == TECHSWITCH + 1) + { + if (picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1) + { + if (switchtype == SWITCH_SPRITE) + S_PlaySound3D(ALIEN_SWITCH1, w, &v); + else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].i, &v); + } + else + { + if (switchtype == SWITCH_SPRITE) + S_PlaySound3D(SWITCH_ON, w, &v); + else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); + } + if (numdips != correctdips) break; + S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].i, &v); + } + case DIPSWITCH2: + case DIPSWITCH2 + 1: + case DIPSWITCH3: + case DIPSWITCH3 + 1: + case MULTISWITCH: + case MULTISWITCH + 1: + case MULTISWITCH + 2: + case MULTISWITCH + 3: + case ACCESSSWITCH: + case ACCESSSWITCH2: + case SLOTDOOR: + case SLOTDOOR + 1: + case LIGHTSWITCH: + case LIGHTSWITCH + 1: + case SPACELIGHTSWITCH: + case SPACELIGHTSWITCH + 1: + case SPACEDOORSWITCH: + case SPACEDOORSWITCH + 1: + case FRANKENSTINESWITCH: + case FRANKENSTINESWITCH + 1: + case LIGHTSWITCH2: + case LIGHTSWITCH2 + 1: + case POWERSWITCH1: + case POWERSWITCH1 + 1: + case LOCKSWITCH1: + case LOCKSWITCH1 + 1: + case POWERSWITCH2: + case POWERSWITCH2 + 1: + case HANDSWITCH: + case HANDSWITCH + 1: + case PULLSWITCH: + case PULLSWITCH + 1: - if (picnum == MULTISWITCH || picnum == (MULTISWITCH + 1) || - picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3)) - lotag += picnum - MULTISWITCH; + if (picnum == MULTISWITCH || picnum == (MULTISWITCH + 1) || + picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3)) + lotag += picnum - MULTISWITCH; - x = headspritestat[3]; - while (x >= 0) - { - if (((sprite[x].hitag) == lotag)) - { - switch (sprite[x].lotag) - { - case SE_12_LIGHT_SWITCH: - sector[sprite[x].sectnum].floorpal = 0; - hittype[x].temp_data[0]++; - if (hittype[x].temp_data[0] == 2) - hittype[x].temp_data[0]++; + x = headspritestat[3]; + while (x >= 0) + { + if (((sprite[x].hitag) == lotag)) + { + switch (sprite[x].lotag) + { + case SE_12_LIGHT_SWITCH: + sector[sprite[x].sectnum].floorpal = 0; + hittype[x].temp_data[0]++; + if (hittype[x].temp_data[0] == 2) + hittype[x].temp_data[0]++; - break; - case SE_24_CONVEYOR: - case SE_34: - case SE_25_PISTON: - hittype[x].temp_data[4] = !hittype[x].temp_data[4]; - if (hittype[x].temp_data[4]) - FTA(15, &ps[snum]); - else FTA(2, &ps[snum]); - break; - case SE_21_DROP_FLOOR: - FTA(2, &ps[screenpeek]); - break; - } - } - x = nextspritestat[x]; - } + break; + case SE_24_CONVEYOR: + case SE_34: + case SE_25_PISTON: + hittype[x].temp_data[4] = !hittype[x].temp_data[4]; + if (hittype[x].temp_data[4]) + FTA(15, &ps[snum]); + else FTA(2, &ps[snum]); + break; + case SE_21_DROP_FLOOR: + FTA(2, &ps[screenpeek]); + break; + } + } + x = nextspritestat[x]; + } - operateactivators(lotag, snum); - operateforcefields(ps[snum].i, lotag); - operatemasterswitches(lotag); + operateactivators(lotag, snum); + operateforcefields(ps[snum].i, lotag); + operatemasterswitches(lotag); - if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || - picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || - picnum == TECHSWITCH || picnum == TECHSWITCH + 1) return 1; + if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || + picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || + picnum == TECHSWITCH || picnum == TECHSWITCH + 1) return 1; - if (hitag == 0 && isadoorwall(picnum) == 0) - { - if (switchtype == SWITCH_SPRITE) - S_PlaySound3D(SWITCH_ON, w, &v); - else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); - } - else if (hitag != 0) - { - auto flags = S_GetUserFlags(hitag); + if (hitag == 0 && isadoorwall(picnum) == 0) + { + if (switchtype == SWITCH_SPRITE) + S_PlaySound3D(SWITCH_ON, w, &v); + else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); + } + else if (hitag != 0) + { + auto flags = S_GetUserFlags(hitag); - if (switchtype == SWITCH_SPRITE && (flags & SF_TALK) == 0) - S_PlaySound3D(hitag, w, &v); - else - A_PlaySound(hitag, ps[snum].i); - } + if (switchtype == SWITCH_SPRITE && (flags & SF_TALK) == 0) + S_PlaySound3D(hitag, w, &v); + else + A_PlaySound(hitag, ps[snum].i); + } - return 1; - } - return 0; + return 1; + } + return 0; } //--------------------------------------------------------------------------- @@ -626,24 +626,24 @@ bool checkhitswitch_d(int snum, int w, int switchtype) void activatebysector_d(int sect, int j) { - short i, didit; + short i, didit; - didit = 0; + didit = 0; - i = headspritesect[sect]; - while (i >= 0) - { - if (sprite[i].picnum == ACTIVATOR) - { - operateactivators(sprite[i].lotag, -1); - didit = 1; - // return; - } - i = nextspritesect[i]; - } + i = headspritesect[sect]; + while (i >= 0) + { + if (sprite[i].picnum == ACTIVATOR) + { + operateactivators(sprite[i].lotag, -1); + didit = 1; + // return; + } + i = nextspritesect[i]; + } - if (didit == 0) - operatesectors(sect, j); + if (didit == 0) + operatesectors(sect, j); } //--------------------------------------------------------------------------- @@ -654,240 +654,240 @@ void activatebysector_d(int sect, int j) void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith) { - short j, i, sn = -1, darkestwall; - walltype* wal; + short j, i, sn = -1, darkestwall; + walltype* wal; - wal = &wall[dawallnum]; + wal = &wall[dawallnum]; - if (wal->overpicnum == MIRROR) - { - switch (atwith) - { - case HEAVYHBOMB: - case RADIUSEXPLOSION: - case RPG: - case HYDRENT: - case SEENINE: - case OOZFILTER: - case EXPLODINGBARREL: - lotsofglass(spr, dawallnum, 70); - wal->cstat &= ~16; - wal->overpicnum = MIRRORBROKE; - spritesound(GLASS_HEAVYBREAK, spr); - return; - } - } + if (wal->overpicnum == MIRROR) + { + switch (atwith) + { + case HEAVYHBOMB: + case RADIUSEXPLOSION: + case RPG: + case HYDRENT: + case SEENINE: + case OOZFILTER: + case EXPLODINGBARREL: + lotsofglass(spr, dawallnum, 70); + wal->cstat &= ~16; + wal->overpicnum = MIRRORBROKE; + spritesound(GLASS_HEAVYBREAK, spr); + return; + } + } - if (((wal->cstat & 16) || wal->overpicnum == BIGFORCE) && wal->nextsector >= 0) - if (sector[wal->nextsector].floorz > z) - if (sector[wal->nextsector].floorz - sector[wal->nextsector].ceilingz) - switch (wal->overpicnum) - { - case W_FORCEFIELD: - case W_FORCEFIELD + 1: - case W_FORCEFIELD + 2: - wal->extra = 1; // tell the forces to animate - case BIGFORCE: - updatesector(x, y, &sn); - if (sn < 0) return; + if (((wal->cstat & 16) || wal->overpicnum == BIGFORCE) && wal->nextsector >= 0) + if (sector[wal->nextsector].floorz > z) + if (sector[wal->nextsector].floorz - sector[wal->nextsector].ceilingz) + switch (wal->overpicnum) + { + case W_FORCEFIELD: + case W_FORCEFIELD + 1: + case W_FORCEFIELD + 2: + wal->extra = 1; // tell the forces to animate + case BIGFORCE: + updatesector(x, y, &sn); + if (sn < 0) return; - if (atwith == -1) - i = EGS(sn, x, y, z, FORCERIPPLE, -127, 8, 8, 0, 0, 0, spr, 5); - else - { - if (atwith == CHAINGUN) - i = EGS(sn, x, y, z, FORCERIPPLE, -127, 16 + sprite[spr].xrepeat, 16 + sprite[spr].yrepeat, 0, 0, 0, spr, 5); - else i = EGS(sn, x, y, z, FORCERIPPLE, -127, 32, 32, 0, 0, 0, spr, 5); - } + if (atwith == -1) + i = EGS(sn, x, y, z, FORCERIPPLE, -127, 8, 8, 0, 0, 0, spr, 5); + else + { + if (atwith == CHAINGUN) + i = EGS(sn, x, y, z, FORCERIPPLE, -127, 16 + sprite[spr].xrepeat, 16 + sprite[spr].yrepeat, 0, 0, 0, spr, 5); + else i = EGS(sn, x, y, z, FORCERIPPLE, -127, 32, 32, 0, 0, 0, spr, 5); + } - sprite[i].cstat |= 18 + 128; - sprite[i].ang = getangle(wal->x - wall[wal->point2].x, - wal->y - wall[wal->point2].y) - 512; + sprite[i].cstat |= 18 + 128; + sprite[i].ang = getangle(wal->x - wall[wal->point2].x, + wal->y - wall[wal->point2].y) - 512; - spritesound(SOMETHINGHITFORCE, i); + spritesound(SOMETHINGHITFORCE, i); - return; + return; - case FANSPRITE: - wal->overpicnum = FANSPRITEBROKE; - wal->cstat &= 65535 - 65; - if (wal->nextwall >= 0) - { - wall[wal->nextwall].overpicnum = FANSPRITEBROKE; - wall[wal->nextwall].cstat &= 65535 - 65; - } - spritesound(VENT_BUST, spr); - spritesound(GLASS_BREAKING, spr); - return; + case FANSPRITE: + wal->overpicnum = FANSPRITEBROKE; + wal->cstat &= 65535 - 65; + if (wal->nextwall >= 0) + { + wall[wal->nextwall].overpicnum = FANSPRITEBROKE; + wall[wal->nextwall].cstat &= 65535 - 65; + } + spritesound(VENT_BUST, spr); + spritesound(GLASS_BREAKING, spr); + return; - case GLASS: - updatesector(x, y, &sn); if (sn < 0) return; - wal->overpicnum = GLASS2; - lotsofglass(spr, dawallnum, 10); - wal->cstat = 0; + case GLASS: + updatesector(x, y, &sn); if (sn < 0) return; + wal->overpicnum = GLASS2; + lotsofglass(spr, dawallnum, 10); + wal->cstat = 0; - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat = 0; + if (wal->nextwall >= 0) + wall[wal->nextwall].cstat = 0; - i = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].getang(), 0, 0, spr, 3); - sprite[i].lotag = 128; hittype[i].temp_data[1] = 5; hittype[i].temp_data[2] = dawallnum; - spritesound(GLASS_BREAKING, i); - return; - case STAINGLASS1: - updatesector(x, y, &sn); if (sn < 0) return; - lotsofcolourglass(spr, dawallnum, 80); - wal->cstat = 0; - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat = 0; - spritesound(VENT_BUST, spr); - spritesound(GLASS_BREAKING, spr); - return; - } + i = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].getang(), 0, 0, spr, 3); + sprite[i].lotag = 128; hittype[i].temp_data[1] = 5; hittype[i].temp_data[2] = dawallnum; + spritesound(GLASS_BREAKING, i); + return; + case STAINGLASS1: + updatesector(x, y, &sn); if (sn < 0) return; + lotsofcolourglass(spr, dawallnum, 80); + wal->cstat = 0; + if (wal->nextwall >= 0) + wall[wal->nextwall].cstat = 0; + spritesound(VENT_BUST, spr); + spritesound(GLASS_BREAKING, spr); + return; + } - switch (wal->picnum) - { - case COLAMACHINE: - case VENDMACHINE: - breakwall(wal->picnum + 2, spr, dawallnum); - spritesound(VENT_BUST, spr); - return; + switch (wal->picnum) + { + case COLAMACHINE: + case VENDMACHINE: + breakwall(wal->picnum + 2, spr, dawallnum); + spritesound(VENT_BUST, spr); + return; - case OJ: - case FEMPIC2: - case FEMPIC3: + case OJ: + case FEMPIC2: + case FEMPIC3: - case SCREENBREAK6: - case SCREENBREAK7: - case SCREENBREAK8: + case SCREENBREAK6: + case SCREENBREAK7: + case SCREENBREAK8: - case SCREENBREAK1: - case SCREENBREAK2: - case SCREENBREAK3: - case SCREENBREAK4: - case SCREENBREAK5: + case SCREENBREAK1: + case SCREENBREAK2: + case SCREENBREAK3: + case SCREENBREAK4: + case SCREENBREAK5: - case SCREENBREAK9: - case SCREENBREAK10: - case SCREENBREAK11: - case SCREENBREAK12: - case SCREENBREAK13: - case SCREENBREAK14: - case SCREENBREAK15: - case SCREENBREAK16: - case SCREENBREAK17: - case SCREENBREAK18: - case SCREENBREAK19: - case BORNTOBEWILDSCREEN: + case SCREENBREAK9: + case SCREENBREAK10: + case SCREENBREAK11: + case SCREENBREAK12: + case SCREENBREAK13: + case SCREENBREAK14: + case SCREENBREAK15: + case SCREENBREAK16: + case SCREENBREAK17: + case SCREENBREAK18: + case SCREENBREAK19: + case BORNTOBEWILDSCREEN: - lotsofglass(spr, dawallnum, 30); - wal->picnum = W_SCREENBREAK + (krand() % 3); - spritesound(GLASS_HEAVYBREAK, spr); - return; + lotsofglass(spr, dawallnum, 30); + wal->picnum = W_SCREENBREAK + (krand() % 3); + spritesound(GLASS_HEAVYBREAK, spr); + return; - case W_TECHWALL5: - case W_TECHWALL6: - case W_TECHWALL7: - case W_TECHWALL8: - case W_TECHWALL9: - breakwall(wal->picnum + 1, spr, dawallnum); - return; - case W_MILKSHELF: - breakwall(W_MILKSHELFBROKE, spr, dawallnum); - return; + case W_TECHWALL5: + case W_TECHWALL6: + case W_TECHWALL7: + case W_TECHWALL8: + case W_TECHWALL9: + breakwall(wal->picnum + 1, spr, dawallnum); + return; + case W_MILKSHELF: + breakwall(W_MILKSHELFBROKE, spr, dawallnum); + return; - case W_TECHWALL10: - breakwall(W_HITTECHWALL10, spr, dawallnum); - return; + case W_TECHWALL10: + breakwall(W_HITTECHWALL10, spr, dawallnum); + return; - case W_TECHWALL1: - case W_TECHWALL11: - case W_TECHWALL12: - case W_TECHWALL13: - case W_TECHWALL14: - breakwall(W_HITTECHWALL1, spr, dawallnum); - return; + case W_TECHWALL1: + case W_TECHWALL11: + case W_TECHWALL12: + case W_TECHWALL13: + case W_TECHWALL14: + breakwall(W_HITTECHWALL1, spr, dawallnum); + return; - case W_TECHWALL15: - breakwall(W_HITTECHWALL15, spr, dawallnum); - return; + case W_TECHWALL15: + breakwall(W_HITTECHWALL15, spr, dawallnum); + return; - case W_TECHWALL16: - breakwall(W_HITTECHWALL16, spr, dawallnum); - return; + case W_TECHWALL16: + breakwall(W_HITTECHWALL16, spr, dawallnum); + return; - case W_TECHWALL2: - breakwall(W_HITTECHWALL2, spr, dawallnum); - return; + case W_TECHWALL2: + breakwall(W_HITTECHWALL2, spr, dawallnum); + return; - case W_TECHWALL3: - breakwall(W_HITTECHWALL3, spr, dawallnum); - return; + case W_TECHWALL3: + breakwall(W_HITTECHWALL3, spr, dawallnum); + return; - case W_TECHWALL4: - breakwall(W_HITTECHWALL4, spr, dawallnum); - return; + case W_TECHWALL4: + breakwall(W_HITTECHWALL4, spr, dawallnum); + return; - case ATM: - wal->picnum = ATMBROKE; - lotsofmoney(&sprite[spr], 1 + (krand() & 7)); - spritesound(GLASS_HEAVYBREAK, spr); - break; + case ATM: + wal->picnum = ATMBROKE; + lotsofmoney(&sprite[spr], 1 + (krand() & 7)); + spritesound(GLASS_HEAVYBREAK, spr); + break; - case WALLLIGHT1: - case WALLLIGHT2: - case WALLLIGHT3: - case WALLLIGHT4: - case TECHLIGHT2: - case TECHLIGHT4: + case WALLLIGHT1: + case WALLLIGHT2: + case WALLLIGHT3: + case WALLLIGHT4: + case TECHLIGHT2: + case TECHLIGHT4: - if (rnd(128)) - spritesound(GLASS_HEAVYBREAK, spr); - else spritesound(GLASS_BREAKING, spr); - lotsofglass(spr, dawallnum, 30); + if (rnd(128)) + spritesound(GLASS_HEAVYBREAK, spr); + else spritesound(GLASS_BREAKING, spr); + lotsofglass(spr, dawallnum, 30); - if (wal->picnum == WALLLIGHT1) - wal->picnum = WALLLIGHTBUST1; + if (wal->picnum == WALLLIGHT1) + wal->picnum = WALLLIGHTBUST1; - if (wal->picnum == WALLLIGHT2) - wal->picnum = WALLLIGHTBUST2; + if (wal->picnum == WALLLIGHT2) + wal->picnum = WALLLIGHTBUST2; - if (wal->picnum == WALLLIGHT3) - wal->picnum = WALLLIGHTBUST3; + if (wal->picnum == WALLLIGHT3) + wal->picnum = WALLLIGHTBUST3; - if (wal->picnum == WALLLIGHT4) - wal->picnum = WALLLIGHTBUST4; + if (wal->picnum == WALLLIGHT4) + wal->picnum = WALLLIGHTBUST4; - if (wal->picnum == TECHLIGHT2) - wal->picnum = TECHLIGHTBUST2; + if (wal->picnum == TECHLIGHT2) + wal->picnum = TECHLIGHTBUST2; - if (wal->picnum == TECHLIGHT4) - wal->picnum = TECHLIGHTBUST4; + if (wal->picnum == TECHLIGHT4) + wal->picnum = TECHLIGHTBUST4; - if (!wal->lotag) return; + if (!wal->lotag) return; - sn = wal->nextsector; - if (sn < 0) return; - darkestwall = 0; + sn = wal->nextsector; + if (sn < 0) return; + darkestwall = 0; - wal = &wall[sector[sn].wallptr]; - for (i = sector[sn].wallnum; i > 0; i--, wal++) - if (wal->shade > darkestwall) - darkestwall = wal->shade; + wal = &wall[sector[sn].wallptr]; + for (i = sector[sn].wallnum; i > 0; i--, wal++) + if (wal->shade > darkestwall) + darkestwall = wal->shade; - j = krand() & 1; - i = headspritestat[3]; - while (i >= 0) - { - if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3) - { - hittype[i].temp_data[2] = j; - hittype[i].temp_data[3] = darkestwall; - hittype[i].temp_data[4] = 1; - } - i = nextspritestat[i]; - } - break; - } + j = krand() & 1; + i = headspritestat[3]; + while (i >= 0) + { + if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3) + { + hittype[i].temp_data[2] = j; + hittype[i].temp_data[3] = darkestwall; + hittype[i].temp_data[4] = 1; + } + i = nextspritestat[i]; + } + break; + } } //--------------------------------------------------------------------------- @@ -898,59 +898,59 @@ void checkhitwall_d(int spr, int dawallnum, int x, int y, int z, int atwith) void checkplayerhurt_d(struct player_struct* p, int j) { - if ((j & 49152) == 49152) - { - j &= (MAXSPRITES - 1); + if ((j & 49152) == 49152) + { + j &= (MAXSPRITES - 1); - switch (sprite[j].picnum) - { - case CACTUS: - if (p->hurt_delay < 8) - { - sprite[p->i].extra -= 5; - p->hurt_delay = 16; - SetPlayerPal(p, PalEntry(32, 32, 0, 0)); - spritesound(DUKE_LONGTERM_PAIN, p->i); - } - break; - } - return; - } + switch (sprite[j].picnum) + { + case CACTUS: + if (p->hurt_delay < 8) + { + sprite[p->i].extra -= 5; + p->hurt_delay = 16; + SetPlayerPal(p, PalEntry(32, 32, 0, 0)); + spritesound(DUKE_LONGTERM_PAIN, p->i); + } + break; + } + return; + } - if ((j & 49152) != 32768) return; - j &= (MAXWALLS - 1); + if ((j & 49152) != 32768) return; + j &= (MAXWALLS - 1); - if (p->hurt_delay > 0) p->hurt_delay--; - else if (wall[j].cstat & 85) switch (wall[j].overpicnum) - { - case W_FORCEFIELD: - case W_FORCEFIELD + 1: - case W_FORCEFIELD + 2: - sprite[p->i].extra -= 5; + if (p->hurt_delay > 0) p->hurt_delay--; + else if (wall[j].cstat & 85) switch (wall[j].overpicnum) + { + case W_FORCEFIELD: + case W_FORCEFIELD + 1: + case W_FORCEFIELD + 2: + sprite[p->i].extra -= 5; - p->hurt_delay = 16; - SetPlayerPal(p, PalEntry(32, 32, 0, 0)); + p->hurt_delay = 16; + SetPlayerPal(p, PalEntry(32, 32, 0, 0)); - p->posxv = -(sintable[(p->getang() + 512) & 2047] << 8); - p->posyv = -(sintable[(p->getang()) & 2047] << 8); - spritesound(DUKE_LONGTERM_PAIN, p->i); + p->posxv = -(sintable[(p->getang() + 512) & 2047] << 8); + p->posyv = -(sintable[(p->getang()) & 2047] << 8); + spritesound(DUKE_LONGTERM_PAIN, p->i); - checkhitwall(p->i, j, - p->posx + (sintable[(p->getang() + 512) & 2047] >> 9), - p->posy + (sintable[p->getang() & 2047] >> 9), - p->posz, -1); + checkhitwall(p->i, j, + p->posx + (sintable[(p->getang() + 512) & 2047] >> 9), + p->posy + (sintable[p->getang() & 2047] >> 9), + p->posz, -1); - break; + break; - case BIGFORCE: - p->hurt_delay = 26; - checkhitwall(p->i, j, - p->posx + (sintable[(p->getang() + 512) & 2047] >> 9), - p->posy + (sintable[p->getang() & 2047] >> 9), - p->posz, -1); - break; + case BIGFORCE: + p->hurt_delay = 26; + checkhitwall(p->i, j, + p->posx + (sintable[(p->getang() + 512) & 2047] >> 9), + p->posy + (sintable[p->getang() & 2047] >> 9), + p->posz, -1); + break; - } + } } //--------------------------------------------------------------------------- @@ -961,75 +961,75 @@ void checkplayerhurt_d(struct player_struct* p, int j) bool checkhitceiling_d(int sn) { - int i, j; + int i, j; - switch (sector[sn].ceilingpicnum) - { - case WALLLIGHT1: - case WALLLIGHT2: - case WALLLIGHT3: - case WALLLIGHT4: - case TECHLIGHT2: - case TECHLIGHT4: + switch (sector[sn].ceilingpicnum) + { + case WALLLIGHT1: + case WALLLIGHT2: + case WALLLIGHT3: + case WALLLIGHT4: + case TECHLIGHT2: + case TECHLIGHT4: - ceilingglass(ps[myconnectindex].i, sn, 10); - spritesound(GLASS_BREAKING, ps[screenpeek].i); + ceilingglass(ps[myconnectindex].i, sn, 10); + spritesound(GLASS_BREAKING, ps[screenpeek].i); - if (sector[sn].ceilingpicnum == WALLLIGHT1) - sector[sn].ceilingpicnum = WALLLIGHTBUST1; + if (sector[sn].ceilingpicnum == WALLLIGHT1) + sector[sn].ceilingpicnum = WALLLIGHTBUST1; - if (sector[sn].ceilingpicnum == WALLLIGHT2) - sector[sn].ceilingpicnum = WALLLIGHTBUST2; + if (sector[sn].ceilingpicnum == WALLLIGHT2) + sector[sn].ceilingpicnum = WALLLIGHTBUST2; - if (sector[sn].ceilingpicnum == WALLLIGHT3) - sector[sn].ceilingpicnum = WALLLIGHTBUST3; + if (sector[sn].ceilingpicnum == WALLLIGHT3) + sector[sn].ceilingpicnum = WALLLIGHTBUST3; - if (sector[sn].ceilingpicnum == WALLLIGHT4) - sector[sn].ceilingpicnum = WALLLIGHTBUST4; + if (sector[sn].ceilingpicnum == WALLLIGHT4) + sector[sn].ceilingpicnum = WALLLIGHTBUST4; - if (sector[sn].ceilingpicnum == TECHLIGHT2) - sector[sn].ceilingpicnum = TECHLIGHTBUST2; + if (sector[sn].ceilingpicnum == TECHLIGHT2) + sector[sn].ceilingpicnum = TECHLIGHTBUST2; - if (sector[sn].ceilingpicnum == TECHLIGHT4) - sector[sn].ceilingpicnum = TECHLIGHTBUST4; + if (sector[sn].ceilingpicnum == TECHLIGHT4) + sector[sn].ceilingpicnum = TECHLIGHTBUST4; - if (!sector[sn].hitag) - { - i = headspritesect[sn]; - while (i >= 0) - { - if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 12) - { - j = headspritestat[3]; - while (j >= 0) - { - if (sprite[j].hitag == sprite[i].hitag) - hittype[j].temp_data[3] = 1; - j = nextspritestat[j]; - } - break; - } - i = nextspritesect[i]; - } - } + if (!sector[sn].hitag) + { + i = headspritesect[sn]; + while (i >= 0) + { + if (sprite[i].picnum == SECTOREFFECTOR && sprite[i].lotag == 12) + { + j = headspritestat[3]; + while (j >= 0) + { + if (sprite[j].hitag == sprite[i].hitag) + hittype[j].temp_data[3] = 1; + j = nextspritestat[j]; + } + break; + } + i = nextspritesect[i]; + } + } - i = headspritestat[3]; - j = krand() & 1; - while (i >= 0) - { - if (sprite[i].hitag == (sector[sn].hitag) && sprite[i].lotag == 3) - { - hittype[i].temp_data[2] = j; - hittype[i].temp_data[4] = 1; - } - i = nextspritestat[i]; - } + i = headspritestat[3]; + j = krand() & 1; + while (i >= 0) + { + if (sprite[i].hitag == (sector[sn].hitag) && sprite[i].lotag == 3) + { + hittype[i].temp_data[2] = j; + hittype[i].temp_data[4] = 1; + } + i = nextspritestat[i]; + } - return 1; - } + return 1; + } - return 0; + return 0; } //--------------------------------------------------------------------------- @@ -1040,437 +1040,437 @@ bool checkhitceiling_d(int sn) void checkhitsprite_d(int i, int sn) { - int j, k, p; - spritetype* s; + int j, k, p; + spritetype* s; - i &= (MAXSPRITES - 1); + i &= (MAXSPRITES - 1); - switch (sprite[i].picnum) - { - case OCEANSPRITE1: - case OCEANSPRITE2: - case OCEANSPRITE3: - case OCEANSPRITE4: - case OCEANSPRITE5: - spawn(i, SMALLSMOKE); - deletesprite(i); - break; - case QUEBALL: - case STRIPEBALL: - if (sprite[sn].picnum == QUEBALL || sprite[sn].picnum == STRIPEBALL) - { - sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); - sprite[sn].ang -= (sprite[i].ang << 1) + 1024; - sprite[i].ang = getangle(sprite[i].x - sprite[sn].x, sprite[i].y - sprite[sn].y) - 512; - if (S_CheckSoundPlaying(POOLBALLHIT) < 2) - spritesound(POOLBALLHIT, i); - } - else - { - if (krand() & 3) - { - sprite[i].xvel = 164; - sprite[i].ang = sprite[sn].ang; - } - else - { - lotsofglass(i, -1, 3); - deletesprite(i); - } - } - break; - case TREE1: - case TREE2: - case TIRE: - case CONE: - case BOX: - switch (sprite[sn].picnum) - { - case RADIUSEXPLOSION: - case RPG: - case FIRELASER: - case HYDRENT: - case HEAVYHBOMB: - if (hittype[i].temp_data[0] == 0) - { - sprite[i].cstat &= ~257; - hittype[i].temp_data[0] = 1; - spawn(i, BURNING); - } - break; - } - break; - case CACTUS: - // case CACTUSBROKE: - switch (sprite[sn].picnum) - { - case RADIUSEXPLOSION: - case RPG: - case FIRELASER: - case HYDRENT: - case HEAVYHBOMB: - for (k = 0; k < 64; k++) - { - j = EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z - (krand() % (48 << 8)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (sprite[i].zvel >> 2), i, 5); - sprite[j].pal = 8; - } + switch (sprite[i].picnum) + { + case OCEANSPRITE1: + case OCEANSPRITE2: + case OCEANSPRITE3: + case OCEANSPRITE4: + case OCEANSPRITE5: + spawn(i, SMALLSMOKE); + deletesprite(i); + break; + case QUEBALL: + case STRIPEBALL: + if (sprite[sn].picnum == QUEBALL || sprite[sn].picnum == STRIPEBALL) + { + sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); + sprite[sn].ang -= (sprite[i].ang << 1) + 1024; + sprite[i].ang = getangle(sprite[i].x - sprite[sn].x, sprite[i].y - sprite[sn].y) - 512; + if (S_CheckSoundPlaying(POOLBALLHIT) < 2) + spritesound(POOLBALLHIT, i); + } + else + { + if (krand() & 3) + { + sprite[i].xvel = 164; + sprite[i].ang = sprite[sn].ang; + } + else + { + lotsofglass(i, -1, 3); + deletesprite(i); + } + } + break; + case TREE1: + case TREE2: + case TIRE: + case CONE: + case BOX: + switch (sprite[sn].picnum) + { + case RADIUSEXPLOSION: + case RPG: + case FIRELASER: + case HYDRENT: + case HEAVYHBOMB: + if (hittype[i].temp_data[0] == 0) + { + sprite[i].cstat &= ~257; + hittype[i].temp_data[0] = 1; + spawn(i, BURNING); + } + break; + } + break; + case CACTUS: + // case CACTUSBROKE: + switch (sprite[sn].picnum) + { + case RADIUSEXPLOSION: + case RPG: + case FIRELASER: + case HYDRENT: + case HEAVYHBOMB: + for (k = 0; k < 64; k++) + { + j = EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z - (krand() % (48 << 8)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (sprite[i].zvel >> 2), i, 5); + sprite[j].pal = 8; + } - if (sprite[i].picnum == CACTUS) - sprite[i].picnum = CACTUSBROKE; - sprite[i].cstat &= ~257; - // else deletesprite(i); - break; - } - break; + if (sprite[i].picnum == CACTUS) + sprite[i].picnum = CACTUSBROKE; + sprite[i].cstat &= ~257; + // else deletesprite(i); + break; + } + break; - case HANGLIGHT: - case GENERICPOLE2: - for (k = 0; k < 6; k++) - EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z - (8 << 8), SCRAP1 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (sprite[i].zvel >> 2), i, 5); - spritesound(GLASS_HEAVYBREAK, i); - deletesprite(i); - break; + case HANGLIGHT: + case GENERICPOLE2: + for (k = 0; k < 6; k++) + EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z - (8 << 8), SCRAP1 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (sprite[i].zvel >> 2), i, 5); + spritesound(GLASS_HEAVYBREAK, i); + deletesprite(i); + break; - case FANSPRITE: - sprite[i].picnum = FANSPRITEBROKE; - sprite[i].cstat &= (65535 - 257); - if (sector[sprite[i].sectnum].floorpicnum == FANSHADOW) - sector[sprite[i].sectnum].floorpicnum = FANSHADOWBROKE; + case FANSPRITE: + sprite[i].picnum = FANSPRITEBROKE; + sprite[i].cstat &= (65535 - 257); + if (sector[sprite[i].sectnum].floorpicnum == FANSHADOW) + sector[sprite[i].sectnum].floorpicnum = FANSHADOWBROKE; - spritesound(GLASS_HEAVYBREAK, i); - s = &sprite[i]; - for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); + spritesound(GLASS_HEAVYBREAK, i); + s = &sprite[i]; + for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); - break; - case WATERFOUNTAIN: - case WATERFOUNTAIN + 1: - case WATERFOUNTAIN + 2: - case WATERFOUNTAIN + 3: - sprite[i].picnum = WATERFOUNTAINBROKE; - spawn(i, TOILETWATER); - break; - case SATELITE: - case FUELPOD: - case SOLARPANNEL: - case ANTENNA: - if (sprite[sn].extra != G_DefaultActorHealth(SHOTSPARK1)) // TRANSITIONAL - fix after getting rid of EDUKE cruft - { - for (j = 0; j < 15; j++) - EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sector[sprite[i].sectnum].floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, - krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, i, 5); - spawn(i, EXPLOSION2); - deletesprite(i); - } - break; - case BOTTLE1: - case BOTTLE2: - case BOTTLE3: - case BOTTLE4: - case BOTTLE5: - case BOTTLE6: - case BOTTLE8: - case BOTTLE10: - case BOTTLE11: - case BOTTLE12: - case BOTTLE13: - case BOTTLE14: - case BOTTLE15: - case BOTTLE16: - case BOTTLE17: - case BOTTLE18: - case BOTTLE19: - case WATERFOUNTAINBROKE: - case DOMELITE: - case SUSHIPLATE1: - case SUSHIPLATE2: - case SUSHIPLATE3: - case SUSHIPLATE4: - case SUSHIPLATE5: - case WAITTOBESEATED: - case VASE: - case STATUEFLASH: - case STATUE: - if (sprite[i].picnum == BOTTLE10) - lotsofmoney(&sprite[i], 4 + (krand() & 3)); - else if (sprite[i].picnum == STATUE || sprite[i].picnum == STATUEFLASH) - { - lotsofcolourglass(i, -1, 40); - spritesound(GLASS_HEAVYBREAK, i); - } - else if (sprite[i].picnum == VASE) - lotsofglass(i, -1, 40); + break; + case WATERFOUNTAIN: + case WATERFOUNTAIN + 1: + case WATERFOUNTAIN + 2: + case WATERFOUNTAIN + 3: + sprite[i].picnum = WATERFOUNTAINBROKE; + spawn(i, TOILETWATER); + break; + case SATELITE: + case FUELPOD: + case SOLARPANNEL: + case ANTENNA: + if (sprite[sn].extra != G_DefaultActorHealth(SHOTSPARK1)) // TRANSITIONAL - fix after getting rid of EDUKE cruft + { + for (j = 0; j < 15; j++) + EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sector[sprite[i].sectnum].floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, + krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, i, 5); + spawn(i, EXPLOSION2); + deletesprite(i); + } + break; + case BOTTLE1: + case BOTTLE2: + case BOTTLE3: + case BOTTLE4: + case BOTTLE5: + case BOTTLE6: + case BOTTLE8: + case BOTTLE10: + case BOTTLE11: + case BOTTLE12: + case BOTTLE13: + case BOTTLE14: + case BOTTLE15: + case BOTTLE16: + case BOTTLE17: + case BOTTLE18: + case BOTTLE19: + case WATERFOUNTAINBROKE: + case DOMELITE: + case SUSHIPLATE1: + case SUSHIPLATE2: + case SUSHIPLATE3: + case SUSHIPLATE4: + case SUSHIPLATE5: + case WAITTOBESEATED: + case VASE: + case STATUEFLASH: + case STATUE: + if (sprite[i].picnum == BOTTLE10) + lotsofmoney(&sprite[i], 4 + (krand() & 3)); + else if (sprite[i].picnum == STATUE || sprite[i].picnum == STATUEFLASH) + { + lotsofcolourglass(i, -1, 40); + spritesound(GLASS_HEAVYBREAK, i); + } + else if (sprite[i].picnum == VASE) + lotsofglass(i, -1, 40); - spritesound(GLASS_BREAKING, i); - sprite[i].ang = krand() & 2047; - lotsofglass(i, -1, 8); - deletesprite(i); - break; - case FETUS: - sprite[i].picnum = FETUSBROKE; - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - break; - case FETUSBROKE: - for (j = 0; j < 48; j++) - { - shoot(i, BLOODSPLAT1); - sprite[i].ang += 333; - } - spritesound(GLASS_HEAVYBREAK, i); - spritesound(SQUISHED, i); - case BOTTLE7: - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - deletesprite(i); - break; - case HYDROPLANT: - sprite[i].picnum = BROKEHYDROPLANT; - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - break; + spritesound(GLASS_BREAKING, i); + sprite[i].ang = krand() & 2047; + lotsofglass(i, -1, 8); + deletesprite(i); + break; + case FETUS: + sprite[i].picnum = FETUSBROKE; + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + break; + case FETUSBROKE: + for (j = 0; j < 48; j++) + { + shoot(i, BLOODSPLAT1); + sprite[i].ang += 333; + } + spritesound(GLASS_HEAVYBREAK, i); + spritesound(SQUISHED, i); + case BOTTLE7: + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + deletesprite(i); + break; + case HYDROPLANT: + sprite[i].picnum = BROKEHYDROPLANT; + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + break; - case FORCESPHERE: - sprite[i].xrepeat = 0; - hittype[sprite[i].owner].temp_data[0] = 32; - hittype[sprite[i].owner].temp_data[1] = !hittype[sprite[i].owner].temp_data[1]; - hittype[sprite[i].owner].temp_data[2] ++; - spawn(i, EXPLOSION2); - break; + case FORCESPHERE: + sprite[i].xrepeat = 0; + hittype[sprite[i].owner].temp_data[0] = 32; + hittype[sprite[i].owner].temp_data[1] = !hittype[sprite[i].owner].temp_data[1]; + hittype[sprite[i].owner].temp_data[2] ++; + spawn(i, EXPLOSION2); + break; - case BROKEHYDROPLANT: - if (sprite[i].cstat & 1) - { - spritesound(GLASS_BREAKING, i); - sprite[i].z += 16 << 8; - sprite[i].cstat = 0; - lotsofglass(i, -1, 5); - } - break; + case BROKEHYDROPLANT: + if (sprite[i].cstat & 1) + { + spritesound(GLASS_BREAKING, i); + sprite[i].z += 16 << 8; + sprite[i].cstat = 0; + lotsofglass(i, -1, 5); + } + break; - case TOILET: - sprite[i].picnum = TOILETBROKE; - sprite[i].cstat |= (krand() & 1) << 2; - sprite[i].cstat &= ~257; - spawn(i, TOILETWATER); - spritesound(GLASS_BREAKING, i); - break; + case TOILET: + sprite[i].picnum = TOILETBROKE; + sprite[i].cstat |= (krand() & 1) << 2; + sprite[i].cstat &= ~257; + spawn(i, TOILETWATER); + spritesound(GLASS_BREAKING, i); + break; - case STALL: - sprite[i].picnum = STALLBROKE; - sprite[i].cstat |= (krand() & 1) << 2; - sprite[i].cstat &= ~257; - spawn(i, TOILETWATER); - spritesound(GLASS_HEAVYBREAK, i); - break; + case STALL: + sprite[i].picnum = STALLBROKE; + sprite[i].cstat |= (krand() & 1) << 2; + sprite[i].cstat &= ~257; + spawn(i, TOILETWATER); + spritesound(GLASS_HEAVYBREAK, i); + break; - case HYDRENT: - sprite[i].picnum = BROKEFIREHYDRENT; - spawn(i, TOILETWATER); + case HYDRENT: + sprite[i].picnum = BROKEFIREHYDRENT; + spawn(i, TOILETWATER); - // for(k=0;k<5;k++) - // { - // j = EGS(sprite[i].sectnum,sprite[i].x,sprite[i].y,sprite[i].z-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5); - // sprite[j].pal = 2; - // } - spritesound(GLASS_HEAVYBREAK, i); - break; + // for(k=0;k<5;k++) + // { + // j = EGS(sprite[i].sectnum,sprite[i].x,sprite[i].y,sprite[i].z-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5); + // sprite[j].pal = 2; + // } + spritesound(GLASS_HEAVYBREAK, i); + break; - case GRATE1: - sprite[i].picnum = BGRATE1; - sprite[i].cstat &= (65535 - 256 - 1); - spritesound(VENT_BUST, i); - break; + case GRATE1: + sprite[i].picnum = BGRATE1; + sprite[i].cstat &= (65535 - 256 - 1); + spritesound(VENT_BUST, i); + break; - case CIRCLEPANNEL: - sprite[i].picnum = CIRCLEPANNELBROKE; - sprite[i].cstat &= (65535 - 256 - 1); - spritesound(VENT_BUST, i); - break; - case PANNEL1: - case PANNEL2: - sprite[i].picnum = BPANNEL1; - sprite[i].cstat &= (65535 - 256 - 1); - spritesound(VENT_BUST, i); - break; - case PANNEL3: - sprite[i].picnum = BPANNEL3; - sprite[i].cstat &= (65535 - 256 - 1); - spritesound(VENT_BUST, i); - break; - case PIPE1: - case PIPE2: - case PIPE3: - case PIPE4: - case PIPE5: - case PIPE6: - switch (sprite[i].picnum) - { - case PIPE1:sprite[i].picnum = PIPE1B; break; - case PIPE2:sprite[i].picnum = PIPE2B; break; - case PIPE3:sprite[i].picnum = PIPE3B; break; - case PIPE4:sprite[i].picnum = PIPE4B; break; - case PIPE5:sprite[i].picnum = PIPE5B; break; - case PIPE6:sprite[i].picnum = PIPE6B; break; - } + case CIRCLEPANNEL: + sprite[i].picnum = CIRCLEPANNELBROKE; + sprite[i].cstat &= (65535 - 256 - 1); + spritesound(VENT_BUST, i); + break; + case PANNEL1: + case PANNEL2: + sprite[i].picnum = BPANNEL1; + sprite[i].cstat &= (65535 - 256 - 1); + spritesound(VENT_BUST, i); + break; + case PANNEL3: + sprite[i].picnum = BPANNEL3; + sprite[i].cstat &= (65535 - 256 - 1); + spritesound(VENT_BUST, i); + break; + case PIPE1: + case PIPE2: + case PIPE3: + case PIPE4: + case PIPE5: + case PIPE6: + switch (sprite[i].picnum) + { + case PIPE1:sprite[i].picnum = PIPE1B; break; + case PIPE2:sprite[i].picnum = PIPE2B; break; + case PIPE3:sprite[i].picnum = PIPE3B; break; + case PIPE4:sprite[i].picnum = PIPE4B; break; + case PIPE5:sprite[i].picnum = PIPE5B; break; + case PIPE6:sprite[i].picnum = PIPE6B; break; + } - j = spawn(i, STEAM); - sprite[j].z = sector[sprite[i].sectnum].floorz - (32 << 8); - break; + j = spawn(i, STEAM); + sprite[j].z = sector[sprite[i].sectnum].floorz - (32 << 8); + break; - case MONK: - case LUKE: - case INDY: - case JURYGUY: - spritesound(sprite[i].lotag, i); - spawn(i, sprite[i].hitag); - case SPACEMARINE: - sprite[i].extra -= sprite[sn].extra; - if (sprite[i].extra > 0) break; - sprite[i].ang = krand() & 2047; - shoot(i, BLOODSPLAT1); - sprite[i].ang = krand() & 2047; - shoot(i, BLOODSPLAT2); - sprite[i].ang = krand() & 2047; - shoot(i, BLOODSPLAT3); - sprite[i].ang = krand() & 2047; - shoot(i, BLOODSPLAT4); - sprite[i].ang = krand() & 2047; - shoot(i, BLOODSPLAT1); - sprite[i].ang = krand() & 2047; - shoot(i, BLOODSPLAT2); - sprite[i].ang = krand() & 2047; - shoot(i, BLOODSPLAT3); - sprite[i].ang = krand() & 2047; - shoot(i, BLOODSPLAT4); - guts(&sprite[i], JIBS1, 1, myconnectindex); - guts(&sprite[i], JIBS2, 2, myconnectindex); - guts(&sprite[i], JIBS3, 3, myconnectindex); - guts(&sprite[i], JIBS4, 4, myconnectindex); - guts(&sprite[i], JIBS5, 1, myconnectindex); - guts(&sprite[i], JIBS3, 6, myconnectindex); - sound(SQUISHED); - deletesprite(i); - break; - case CHAIR1: - case CHAIR2: - sprite[i].picnum = BROKENCHAIR; - sprite[i].cstat = 0; - break; - case CHAIR3: - case MOVIECAMERA: - case SCALE: - case VACUUM: - case CAMERALIGHT: - case IVUNIT: - case POT1: - case POT2: - case POT3: - case TRIPODCAMERA: - spritesound(GLASS_HEAVYBREAK, i); - s = &sprite[i]; - for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); - deletesprite(i); - break; - case PLAYERONWATER: - i = sprite[i].owner; - default: - if ((sprite[i].cstat & 16) && sprite[i].hitag == 0 && sprite[i].lotag == 0 && sprite[i].statnum == 0) - break; + case MONK: + case LUKE: + case INDY: + case JURYGUY: + spritesound(sprite[i].lotag, i); + spawn(i, sprite[i].hitag); + case SPACEMARINE: + sprite[i].extra -= sprite[sn].extra; + if (sprite[i].extra > 0) break; + sprite[i].ang = krand() & 2047; + shoot(i, BLOODSPLAT1); + sprite[i].ang = krand() & 2047; + shoot(i, BLOODSPLAT2); + sprite[i].ang = krand() & 2047; + shoot(i, BLOODSPLAT3); + sprite[i].ang = krand() & 2047; + shoot(i, BLOODSPLAT4); + sprite[i].ang = krand() & 2047; + shoot(i, BLOODSPLAT1); + sprite[i].ang = krand() & 2047; + shoot(i, BLOODSPLAT2); + sprite[i].ang = krand() & 2047; + shoot(i, BLOODSPLAT3); + sprite[i].ang = krand() & 2047; + shoot(i, BLOODSPLAT4); + guts(&sprite[i], JIBS1, 1, myconnectindex); + guts(&sprite[i], JIBS2, 2, myconnectindex); + guts(&sprite[i], JIBS3, 3, myconnectindex); + guts(&sprite[i], JIBS4, 4, myconnectindex); + guts(&sprite[i], JIBS5, 1, myconnectindex); + guts(&sprite[i], JIBS3, 6, myconnectindex); + sound(SQUISHED); + deletesprite(i); + break; + case CHAIR1: + case CHAIR2: + sprite[i].picnum = BROKENCHAIR; + sprite[i].cstat = 0; + break; + case CHAIR3: + case MOVIECAMERA: + case SCALE: + case VACUUM: + case CAMERALIGHT: + case IVUNIT: + case POT1: + case POT2: + case POT3: + case TRIPODCAMERA: + spritesound(GLASS_HEAVYBREAK, i); + s = &sprite[i]; + for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); + deletesprite(i); + break; + case PLAYERONWATER: + i = sprite[i].owner; + default: + if ((sprite[i].cstat & 16) && sprite[i].hitag == 0 && sprite[i].lotag == 0 && sprite[i].statnum == 0) + break; - if ((sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i) && sprite[i].statnum != 4) - { - if (badguy(&sprite[i]) == 1) - { - if (sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; + if ((sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i) && sprite[i].statnum != 4) + { + if (badguy(&sprite[i]) == 1) + { + if (sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; - if ((sprite[i].picnum != DRONE) && (sprite[i].picnum != ROTATEGUN) && (sprite[i].picnum != COMMANDER) && (sprite[i].picnum < GREENSLIME || sprite[i].picnum > GREENSLIME + 7)) - if (sprite[sn].picnum != FREEZEBLAST) - //if (actortype[sprite[i].picnum] == 0) //TRANSITIONAL. Cannot be done right with EDuke mess backing the engine. - { - j = spawn(sn, JIBS6); - if (sprite[sn].pal == 6) - sprite[j].pal = 6; - sprite[j].z += (4 << 8); - sprite[j].xvel = 16; - sprite[j].xrepeat = sprite[j].yrepeat = 24; - sprite[j].ang += 32 - (krand() & 63); - } + if ((sprite[i].picnum != DRONE) && (sprite[i].picnum != ROTATEGUN) && (sprite[i].picnum != COMMANDER) && (sprite[i].picnum < GREENSLIME || sprite[i].picnum > GREENSLIME + 7)) + if (sprite[sn].picnum != FREEZEBLAST) + //if (actortype[sprite[i].picnum] == 0) //TRANSITIONAL. Cannot be done right with EDuke mess backing the engine. + { + j = spawn(sn, JIBS6); + if (sprite[sn].pal == 6) + sprite[j].pal = 6; + sprite[j].z += (4 << 8); + sprite[j].xvel = 16; + sprite[j].xrepeat = sprite[j].yrepeat = 24; + sprite[j].ang += 32 - (krand() & 63); + } - j = sprite[sn].owner; + j = sprite[sn].owner; - if (j >= 0 && sprite[j].picnum == APLAYER && sprite[i].picnum != ROTATEGUN && sprite[i].picnum != DRONE) - if (ps[sprite[j].yvel].curr_weapon == SHOTGUN_WEAPON) - { - shoot(i, BLOODSPLAT3); - shoot(i, BLOODSPLAT1); - shoot(i, BLOODSPLAT2); - shoot(i, BLOODSPLAT4); - } + if (j >= 0 && sprite[j].picnum == APLAYER && sprite[i].picnum != ROTATEGUN && sprite[i].picnum != DRONE) + if (ps[sprite[j].yvel].curr_weapon == SHOTGUN_WEAPON) + { + shoot(i, BLOODSPLAT3); + shoot(i, BLOODSPLAT1); + shoot(i, BLOODSPLAT2); + shoot(i, BLOODSPLAT4); + } - if (sprite[i].picnum != TANK && sprite[i].picnum != BOSS1 && sprite[i].picnum != BOSS4 && sprite[i].picnum != BOSS2 && sprite[i].picnum != BOSS3 && sprite[i].picnum != RECON && sprite[i].picnum != ROTATEGUN) - { - if ((sprite[i].cstat & 48) == 0) - sprite[i].ang = (sprite[sn].ang + 1024) & 2047; - sprite[i].xvel = -(sprite[sn].extra << 2); - short j = sprite[i].sectnum; - pushmove(&sprite[i].x, &sprite[i].y, &sprite[i].z, &j, 128L, (4L << 8), (4L << 8), CLIPMASK0); - if (j != sprite[i].sectnum && j >= 0 && j < MAXSECTORS) - changespritesect(i, j); - } + if (sprite[i].picnum != TANK && sprite[i].picnum != BOSS1 && sprite[i].picnum != BOSS4 && sprite[i].picnum != BOSS2 && sprite[i].picnum != BOSS3 && sprite[i].picnum != RECON && sprite[i].picnum != ROTATEGUN) + { + if ((sprite[i].cstat & 48) == 0) + sprite[i].ang = (sprite[sn].ang + 1024) & 2047; + sprite[i].xvel = -(sprite[sn].extra << 2); + short j = sprite[i].sectnum; + pushmove(&sprite[i].x, &sprite[i].y, &sprite[i].z, &j, 128L, (4L << 8), (4L << 8), CLIPMASK0); + if (j != sprite[i].sectnum && j >= 0 && j < MAXSECTORS) + changespritesect(i, j); + } - if (sprite[i].statnum == 2) - { - changespritestat(i, 1); - hittype[i].timetosleep = SLEEPTIME; - } - if ((sprite[i].xrepeat < 24 || sprite[i].picnum == SHARK) && sprite[sn].picnum == SHRINKSPARK) return; - } + if (sprite[i].statnum == 2) + { + changespritestat(i, 1); + hittype[i].timetosleep = SLEEPTIME; + } + if ((sprite[i].xrepeat < 24 || sprite[i].picnum == SHARK) && sprite[sn].picnum == SHRINKSPARK) return; + } - if (sprite[i].statnum != 2) - { - if (sprite[sn].picnum == FREEZEBLAST && ((sprite[i].picnum == APLAYER && sprite[i].pal == 1) || (freezerhurtowner == 0 && sprite[sn].owner == i))) - return; + if (sprite[i].statnum != 2) + { + if (sprite[sn].picnum == FREEZEBLAST && ((sprite[i].picnum == APLAYER && sprite[i].pal == 1) || (freezerhurtowner == 0 && sprite[sn].owner == i))) + return; - hittype[i].picnum = sprite[sn].picnum; - hittype[i].extra += sprite[sn].extra; - hittype[i].ang = sprite[sn].ang; - hittype[i].owner = sprite[sn].owner; - } + hittype[i].picnum = sprite[sn].picnum; + hittype[i].extra += sprite[sn].extra; + hittype[i].ang = sprite[sn].ang; + hittype[i].owner = sprite[sn].owner; + } - if (sprite[i].statnum == 10) - { - p = sprite[i].yvel; - if (ps[p].newowner >= 0) - { - ps[p].newowner = -1; - ps[p].posx = ps[p].oposx; - ps[p].posy = ps[p].oposy; - ps[p].posz = ps[p].oposz; - ps[p].q16ang = ps[p].oq16ang; + if (sprite[i].statnum == 10) + { + p = sprite[i].yvel; + if (ps[p].newowner >= 0) + { + ps[p].newowner = -1; + ps[p].posx = ps[p].oposx; + ps[p].posy = ps[p].oposy; + ps[p].posz = ps[p].oposz; + ps[p].q16ang = ps[p].oq16ang; - updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); - setpal(&ps[p]); + updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); + setpal(&ps[p]); - j = headspritestat[1]; - while (j >= 0) - { - if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0; - j = nextspritestat[j]; - } - } + j = headspritestat[1]; + while (j >= 0) + { + if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0; + j = nextspritestat[j]; + } + } - if (sprite[i].xrepeat < 24 && sprite[sn].picnum == SHRINKSPARK) - return; + if (sprite[i].xrepeat < 24 && sprite[sn].picnum == SHRINKSPARK) + return; - if (sprite[hittype[i].owner].picnum != APLAYER) - if (ud.player_skill >= 3) - sprite[sn].extra += (sprite[sn].extra >> 1); - } + if (sprite[hittype[i].owner].picnum != APLAYER) + if (ud.player_skill >= 3) + sprite[sn].extra += (sprite[sn].extra >> 1); + } - } - break; - } + } + break; + } } //--------------------------------------------------------------------------- @@ -1481,332 +1481,332 @@ void checkhitsprite_d(int i, int sn) void checksectors_d(int snum) { - int i = -1, oldz; - struct player_struct* p; - int j, hitscanwall; - short neartagsector, neartagwall, neartagsprite; - int neartaghitdist; + int i = -1, oldz; + struct player_struct* p; + int j, hitscanwall; + short neartagsector, neartagwall, neartagsprite; + int neartaghitdist; - p = &ps[snum]; + p = &ps[snum]; - switch (sector[p->cursectnum].lotag) - { + switch (sector[p->cursectnum].lotag) + { - case 32767: - sector[p->cursectnum].lotag = 0; - FTA(9, p); - p->secret_rooms++; - return; - case -1: - for (i = connecthead; i >= 0; i = connectpoint2[i]) - ps[i].gm = MODE_EOL; - sector[p->cursectnum].lotag = 0; - if (ud.from_bonus) - { - ud.level_number = ud.from_bonus; - ud.m_level_number = ud.level_number; - ud.from_bonus = 0; - } - else - { - ud.level_number++; - if ((ud.volume_number && ud.level_number > 10) || ud.level_number > 5) - ud.level_number = 0; - ud.m_level_number = ud.level_number; - } - return; - case -2: - sector[p->cursectnum].lotag = 0; - p->timebeforeexit = 26 * 8; - p->customexitsound = sector[p->cursectnum].hitag; - return; - default: - if (sector[p->cursectnum].lotag >= 10000 && sector[p->cursectnum].lotag < 16383) - { - if (snum == screenpeek || ud.coop == 1) - spritesound(sector[p->cursectnum].lotag - 10000, p->i); - sector[p->cursectnum].lotag = 0; - } - break; + case 32767: + sector[p->cursectnum].lotag = 0; + FTA(9, p); + p->secret_rooms++; + return; + case -1: + for (i = connecthead; i >= 0; i = connectpoint2[i]) + ps[i].gm = MODE_EOL; + sector[p->cursectnum].lotag = 0; + if (ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + ud.level_number++; + if ((ud.volume_number && ud.level_number > 10) || ud.level_number > 5) + ud.level_number = 0; + ud.m_level_number = ud.level_number; + } + return; + case -2: + sector[p->cursectnum].lotag = 0; + p->timebeforeexit = 26 * 8; + p->customexitsound = sector[p->cursectnum].hitag; + return; + default: + if (sector[p->cursectnum].lotag >= 10000 && sector[p->cursectnum].lotag < 16383) + { + if (snum == screenpeek || ud.coop == 1) + spritesound(sector[p->cursectnum].lotag - 10000, p->i); + sector[p->cursectnum].lotag = 0; + } + break; - } + } - //After this point the the player effects the map with space + //After this point the the player effects the map with space - if (p->gm & MODE_TYPE || sprite[p->i].extra <= 0) return; + if (p->gm & MODE_TYPE || sprite[p->i].extra <= 0) return; - if (ud.cashman && PlayerInput(snum, SK_OPEN)) - lotsofmoney(&sprite[p->i], 2); + if (ud.cashman && PlayerInput(snum, SK_OPEN)) + lotsofmoney(&sprite[p->i], 2); - if (p->newowner >= 0) - { - if (abs(PlayerInputSideVel(snum)) > 768 || abs(PlayerInputForwardVel(snum)) > 768) - { - i = -1; - goto CLEARCAMERAS; - } - } + if (p->newowner >= 0) + { + if (abs(PlayerInputSideVel(snum)) > 768 || abs(PlayerInputForwardVel(snum)) > 768) + { + i = -1; + goto CLEARCAMERAS; + } + } - if (!(PlayerInput(snum, SK_OPEN)) && !PlayerInput(snum, SK_ESCAPE)) - p->toggle_key_flag = 0; + if (!(PlayerInput(snum, SK_OPEN)) && !PlayerInput(snum, SK_ESCAPE)) + p->toggle_key_flag = 0; - else if (!p->toggle_key_flag) - { + else if (!p->toggle_key_flag) + { - if (PlayerInput(snum, SK_ESCAPE)) - { - if (p->newowner >= 0) - { - i = -1; - goto CLEARCAMERAS; - } - return; - } + if (PlayerInput(snum, SK_ESCAPE)) + { + if (p->newowner >= 0) + { + i = -1; + goto CLEARCAMERAS; + } + return; + } - neartagsprite = -1; - p->toggle_key_flag = 1; - hitscanwall = -1; + neartagsprite = -1; + p->toggle_key_flag = 1; + hitscanwall = -1; - i = hitawall(p, &hitscanwall); + i = hitawall(p, &hitscanwall); - if (i < 1280 && hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR) - if (wall[hitscanwall].lotag > 0 && S_CheckSoundPlaying(wall[hitscanwall].lotag) == 0 && snum == screenpeek) - { - spritesound(wall[hitscanwall].lotag, p->i); - return; - } + if (i < 1280 && hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR) + if (wall[hitscanwall].lotag > 0 && S_CheckSoundPlaying(wall[hitscanwall].lotag) == 0 && snum == screenpeek) + { + spritesound(wall[hitscanwall].lotag, p->i); + return; + } - if (hitscanwall >= 0 && (wall[hitscanwall].cstat & 16)) - if (wall[hitscanwall].lotag) - return; + if (hitscanwall >= 0 && (wall[hitscanwall].cstat & 16)) + if (wall[hitscanwall].lotag) + return; - if (p->newowner >= 0) - neartag(p->oposx, p->oposy, p->oposz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); - else - { - neartag(p->posx, p->posy, p->posz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); - if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - neartag(p->posx, p->posy, p->posz + (8 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); - if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - neartag(p->posx, p->posy, p->posz + (16 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); - if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - { - neartag(p->posx, p->posy, p->posz + (16 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); - if (neartagsprite >= 0) - { - switch (sprite[neartagsprite].picnum) - { - case FEM1: - case FEM2: - case FEM3: - case FEM4: - case FEM5: - case FEM6: - case FEM7: - case FEM8: - case FEM9: - case FEM10: - case PODFEM1: - case NAKED1: - case STATUE: - case TOUGHGAL: - return; - } - } + if (p->newowner >= 0) + neartag(p->oposx, p->oposy, p->oposz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + else + { + neartag(p->posx, p->posy, p->posz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + neartag(p->posx, p->posy, p->posz + (8 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + neartag(p->posx, p->posy, p->posz + (16 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + { + neartag(p->posx, p->posy, p->posz + (16 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); + if (neartagsprite >= 0) + { + switch (sprite[neartagsprite].picnum) + { + case FEM1: + case FEM2: + case FEM3: + case FEM4: + case FEM5: + case FEM6: + case FEM7: + case FEM8: + case FEM9: + case FEM10: + case PODFEM1: + case NAKED1: + case STATUE: + case TOUGHGAL: + return; + } + } - neartagsprite = -1; - neartagwall = -1; - neartagsector = -1; - } - } + neartagsprite = -1; + neartagwall = -1; + neartagsector = -1; + } + } - if (p->newowner == -1 && neartagsprite == -1 && neartagsector == -1 && neartagwall == -1) - if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) - neartagsector = sprite[p->i].sectnum; + if (p->newowner == -1 && neartagsprite == -1 && neartagsector == -1 && neartagwall == -1) + if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) + neartagsector = sprite[p->i].sectnum; - if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384)) - return; + if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384)) + return; - if (neartagsprite == -1 && neartagwall == -1) - if (sector[p->cursectnum].lotag == 2) - { - oldz = hitasprite(p->i, &neartagsprite); - if (oldz > 1280) neartagsprite = -1; - } + if (neartagsprite == -1 && neartagwall == -1) + if (sector[p->cursectnum].lotag == 2) + { + oldz = hitasprite(p->i, &neartagsprite); + if (oldz > 1280) neartagsprite = -1; + } - if (neartagsprite >= 0) - { - if (checkhitswitch(snum, neartagsprite, 1)) return; + if (neartagsprite >= 0) + { + if (checkhitswitch(snum, neartagsprite, 1)) return; - switch (sprite[neartagsprite].picnum) - { - case TOILET: - case STALL: - if (p->last_pissed_time == 0) - { - if (ud.lockout == 0) spritesound(DUKE_URINATE, p->i); + switch (sprite[neartagsprite].picnum) + { + case TOILET: + case STALL: + if (p->last_pissed_time == 0) + { + if (ud.lockout == 0) spritesound(DUKE_URINATE, p->i); - p->last_pissed_time = 26 * 220; - p->transporter_hold = 29 * 2; - if (p->holster_weapon == 0) - { - p->holster_weapon = 1; - p->weapon_pos = -1; - } - if (sprite[p->i].extra <= (p->max_player_health - (p->max_player_health / 10))) - { - sprite[p->i].extra += p->max_player_health / 10; - p->last_extra = sprite[p->i].extra; - } - else if (sprite[p->i].extra < p->max_player_health) - sprite[p->i].extra = p->max_player_health; - } - else if (S_CheckSoundPlaying(FLUSH_TOILET) == 0) - spritesound(FLUSH_TOILET, p->i); - return; + p->last_pissed_time = 26 * 220; + p->transporter_hold = 29 * 2; + if (p->holster_weapon == 0) + { + p->holster_weapon = 1; + p->weapon_pos = -1; + } + if (sprite[p->i].extra <= (p->max_player_health - (p->max_player_health / 10))) + { + sprite[p->i].extra += p->max_player_health / 10; + p->last_extra = sprite[p->i].extra; + } + else if (sprite[p->i].extra < p->max_player_health) + sprite[p->i].extra = p->max_player_health; + } + else if (S_CheckSoundPlaying(FLUSH_TOILET) == 0) + spritesound(FLUSH_TOILET, p->i); + return; - case NUKEBUTTON: + case NUKEBUTTON: - hitawall(p, &j); - if (j >= 0 && wall[j].overpicnum == 0) - if (hittype[neartagsprite].temp_data[0] == 0) - { - hittype[neartagsprite].temp_data[0] = 1; - sprite[neartagsprite].owner = p->i; - p->buttonpalette = sprite[neartagsprite].pal; - if (p->buttonpalette) - ud.secretlevel = sprite[neartagsprite].lotag; - else ud.secretlevel = 0; - } - return; - case WATERFOUNTAIN: - if (hittype[neartagsprite].temp_data[0] != 1) - { - hittype[neartagsprite].temp_data[0] = 1; - sprite[neartagsprite].owner = p->i; + hitawall(p, &j); + if (j >= 0 && wall[j].overpicnum == 0) + if (hittype[neartagsprite].temp_data[0] == 0) + { + hittype[neartagsprite].temp_data[0] = 1; + sprite[neartagsprite].owner = p->i; + p->buttonpalette = sprite[neartagsprite].pal; + if (p->buttonpalette) + ud.secretlevel = sprite[neartagsprite].lotag; + else ud.secretlevel = 0; + } + return; + case WATERFOUNTAIN: + if (hittype[neartagsprite].temp_data[0] != 1) + { + hittype[neartagsprite].temp_data[0] = 1; + sprite[neartagsprite].owner = p->i; - if (sprite[p->i].extra < p->max_player_health) - { - sprite[p->i].extra++; - spritesound(DUKE_DRINKING, p->i); - } - } - return; - case PLUG: - spritesound(SHORT_CIRCUIT, p->i); - sprite[p->i].extra -= 2 + (krand() & 3); - SetPlayerPal(p, PalEntry(32, 48, 48, 64)); - break; - case VIEWSCREEN: - case VIEWSCREEN2: - { - i = headspritestat[1]; + if (sprite[p->i].extra < p->max_player_health) + { + sprite[p->i].extra++; + spritesound(DUKE_DRINKING, p->i); + } + } + return; + case PLUG: + spritesound(SHORT_CIRCUIT, p->i); + sprite[p->i].extra -= 2 + (krand() & 3); + SetPlayerPal(p, PalEntry(32, 48, 48, 64)); + break; + case VIEWSCREEN: + case VIEWSCREEN2: + { + i = headspritestat[1]; - while (i >= 0) - { - if (sprite[i].picnum == CAMERA1 && sprite[i].yvel == 0 && sprite[neartagsprite].hitag == sprite[i].lotag) - { - sprite[i].yvel = 1; //Using this camera - spritesound(MONITOR_ACTIVE, neartagsprite); + while (i >= 0) + { + if (sprite[i].picnum == CAMERA1 && sprite[i].yvel == 0 && sprite[neartagsprite].hitag == sprite[i].lotag) + { + sprite[i].yvel = 1; //Using this camera + spritesound(MONITOR_ACTIVE, neartagsprite); - sprite[neartagsprite].owner = i; - sprite[neartagsprite].yvel = 1; + sprite[neartagsprite].owner = i; + sprite[neartagsprite].yvel = 1; - j = p->cursectnum; - p->cursectnum = sprite[i].sectnum; - setpal(p); - p->cursectnum = j; + j = p->cursectnum; + p->cursectnum = sprite[i].sectnum; + setpal(p); + p->cursectnum = j; - // parallaxtype = 2; - p->newowner = i; - return; - } - i = nextspritestat[i]; - } - } + // parallaxtype = 2; + p->newowner = i; + return; + } + i = nextspritestat[i]; + } + } - CLEARCAMERAS: + CLEARCAMERAS: - if (i < 0) - { - p->posx = p->oposx; - p->posy = p->oposy; - p->posz = p->oposz; - p->q16ang = p->oq16ang; - p->newowner = -1; + if (i < 0) + { + p->posx = p->oposx; + p->posy = p->oposy; + p->posz = p->oposz; + p->q16ang = p->oq16ang; + p->newowner = -1; - updatesector(p->posx, p->posy, &p->cursectnum); - setpal(p); + updatesector(p->posx, p->posy, &p->cursectnum); + setpal(p); - i = headspritestat[1]; - while (i >= 0) - { - if (sprite[i].picnum == CAMERA1) sprite[i].yvel = 0; - i = nextspritestat[i]; - } - } - else if (p->newowner >= 0) - p->newowner = -1; + i = headspritestat[1]; + while (i >= 0) + { + if (sprite[i].picnum == CAMERA1) sprite[i].yvel = 0; + i = nextspritestat[i]; + } + } + else if (p->newowner >= 0) + p->newowner = -1; - return; - } - } + return; + } + } - if (!PlayerInput(snum, SK_OPEN)) return; - else if (p->newowner >= 0) { i = -1; goto CLEARCAMERAS; } + if (!PlayerInput(snum, SK_OPEN)) return; + else if (p->newowner >= 0) { i = -1; goto CLEARCAMERAS; } - if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) - if (abs(hits(p->i)) < 512) - { - if ((krand() & 255) < 16) - spritesound(DUKE_SEARCH2, p->i); - else spritesound(DUKE_SEARCH, p->i); - return; - } + if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) + if (abs(hits(p->i)) < 512) + { + if ((krand() & 255) < 16) + spritesound(DUKE_SEARCH2, p->i); + else spritesound(DUKE_SEARCH, p->i); + return; + } - if (neartagwall >= 0) - { - if (wall[neartagwall].lotag > 0 && isadoorwall(wall[neartagwall].picnum)) - { - if (hitscanwall == neartagwall || hitscanwall == -1) - checkhitswitch(snum, neartagwall, 0); - return; - } - else if (p->newowner >= 0) - { - i = -1; - goto CLEARCAMERAS; - } - } + if (neartagwall >= 0) + { + if (wall[neartagwall].lotag > 0 && isadoorwall(wall[neartagwall].picnum)) + { + if (hitscanwall == neartagwall || hitscanwall == -1) + checkhitswitch(snum, neartagwall, 0); + return; + } + else if (p->newowner >= 0) + { + i = -1; + goto CLEARCAMERAS; + } + } - if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384) == 0 && isanearoperator(sector[neartagsector].lotag)) - { - i = headspritesect[neartagsector]; - while (i >= 0) - { - if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) - return; - i = nextspritesect[i]; - } - operatesectors(neartagsector, p->i); - } - else if ((sector[sprite[p->i].sectnum].lotag & 16384) == 0) - { - if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) - { - i = headspritesect[sprite[p->i].sectnum]; - while (i >= 0) - { - if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return; - i = nextspritesect[i]; - } - operatesectors(sprite[p->i].sectnum, p->i); - } - else checkhitswitch(snum, neartagwall, 0); - } - } + if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384) == 0 && isanearoperator(sector[neartagsector].lotag)) + { + i = headspritesect[neartagsector]; + while (i >= 0) + { + if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) + return; + i = nextspritesect[i]; + } + operatesectors(neartagsector, p->i); + } + else if ((sector[sprite[p->i].sectnum].lotag & 16384) == 0) + { + if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) + { + i = headspritesect[sprite[p->i].sectnum]; + while (i >= 0) + { + if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return; + i = nextspritesect[i]; + } + operatesectors(sprite[p->i].sectnum, p->i); + } + else checkhitswitch(snum, neartagwall, 0); + } + } } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 227a54171..e1a1d3b35 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -41,149 +41,149 @@ BEGIN_DUKE_NS bool isadoorwall_r(int dapic) { - switch(dapic) - { - case DOORTILE1: - case DOORTILE2: - case DOORTILE3: - case DOORTILE4: - case DOORTILE5: - case DOORTILE6: - case DOORTILE7: - case DOORTILE8: - case DOORTILE9: - case DOORTILE10: - case DOORTILE11: - case DOORTILE12: - case DOORTILE14: - case DOORTILE15: - case DOORTILE16: - case DOORTILE17: - case DOORTILE18: - case DOORTILE19: - case DOORTILE20: - case DOORTILE21: - case DOORTILE22: - case RRTILE1856: - case RRTILE1877: - return 1; - } - return 0; + switch(dapic) + { + case DOORTILE1: + case DOORTILE2: + case DOORTILE3: + case DOORTILE4: + case DOORTILE5: + case DOORTILE6: + case DOORTILE7: + case DOORTILE8: + case DOORTILE9: + case DOORTILE10: + case DOORTILE11: + case DOORTILE12: + case DOORTILE14: + case DOORTILE15: + case DOORTILE16: + case DOORTILE17: + case DOORTILE18: + case DOORTILE19: + case DOORTILE20: + case DOORTILE21: + case DOORTILE22: + case RRTILE1856: + case RRTILE1877: + return 1; + } + return 0; } bool isablockdoor(int dapic) { - switch (dapic) - { - case RRTILE1792: - case RRTILE1801: - case RRTILE1805: - case RRTILE1807: - case RRTILE1808: - case RRTILE1812: - case RRTILE1821: - case RRTILE1826: - case RRTILE1850: - case RRTILE1851: - case RRTILE1856: - case RRTILE1877: - case RRTILE1938: - case RRTILE1942: - case RRTILE1944: - case RRTILE1945: - case RRTILE1951: - case RRTILE1961: - case RRTILE1964: - case RRTILE1985: - case RRTILE1995: - case RRTILE2022: - case RRTILE2052: - case RRTILE2053: - case RRTILE2060: - case RRTILE2074: - case RRTILE2132: - case RRTILE2136: - case RRTILE2139: - case RRTILE2150: - case RRTILE2178: - case RRTILE2186: - case RRTILE2319: - case RRTILE2321: - case RRTILE2326: - case RRTILE2329: - case RRTILE2578: - case RRTILE2581: - case RRTILE2610: - case RRTILE2613: - case RRTILE2621: - case RRTILE2622: - case RRTILE2676: - case RRTILE2732: - case RRTILE2831: - case RRTILE2832: - case RRTILE2842: - case RRTILE2940: - case RRTILE2970: - case RRTILE3083: - case RRTILE3100: - case RRTILE3155: - case RRTILE3195: - case RRTILE3232: - case RRTILE3600: - case RRTILE3631: - case RRTILE3635: - case RRTILE3637: - case RRTILE3643+2: - case RRTILE3643+3: - case RRTILE3647: - case RRTILE3652: - case RRTILE3653: - case RRTILE3671: - case RRTILE3673: - case RRTILE3684: - case RRTILE3708: - case RRTILE3714: - case RRTILE3716: - case RRTILE3723: - case RRTILE3725: - case RRTILE3737: - case RRTILE3754: - case RRTILE3762: - case RRTILE3763: - case RRTILE3764: - case RRTILE3765: - case RRTILE3767: - case RRTILE3793: - case RRTILE3814: - case RRTILE3815: - case RRTILE3819: - case RRTILE3827: - case RRTILE3837: + switch (dapic) + { + case RRTILE1792: + case RRTILE1801: + case RRTILE1805: + case RRTILE1807: + case RRTILE1808: + case RRTILE1812: + case RRTILE1821: + case RRTILE1826: + case RRTILE1850: + case RRTILE1851: + case RRTILE1856: + case RRTILE1877: + case RRTILE1938: + case RRTILE1942: + case RRTILE1944: + case RRTILE1945: + case RRTILE1951: + case RRTILE1961: + case RRTILE1964: + case RRTILE1985: + case RRTILE1995: + case RRTILE2022: + case RRTILE2052: + case RRTILE2053: + case RRTILE2060: + case RRTILE2074: + case RRTILE2132: + case RRTILE2136: + case RRTILE2139: + case RRTILE2150: + case RRTILE2178: + case RRTILE2186: + case RRTILE2319: + case RRTILE2321: + case RRTILE2326: + case RRTILE2329: + case RRTILE2578: + case RRTILE2581: + case RRTILE2610: + case RRTILE2613: + case RRTILE2621: + case RRTILE2622: + case RRTILE2676: + case RRTILE2732: + case RRTILE2831: + case RRTILE2832: + case RRTILE2842: + case RRTILE2940: + case RRTILE2970: + case RRTILE3083: + case RRTILE3100: + case RRTILE3155: + case RRTILE3195: + case RRTILE3232: + case RRTILE3600: + case RRTILE3631: + case RRTILE3635: + case RRTILE3637: + case RRTILE3643+2: + case RRTILE3643+3: + case RRTILE3647: + case RRTILE3652: + case RRTILE3653: + case RRTILE3671: + case RRTILE3673: + case RRTILE3684: + case RRTILE3708: + case RRTILE3714: + case RRTILE3716: + case RRTILE3723: + case RRTILE3725: + case RRTILE3737: + case RRTILE3754: + case RRTILE3762: + case RRTILE3763: + case RRTILE3764: + case RRTILE3765: + case RRTILE3767: + case RRTILE3793: + case RRTILE3814: + case RRTILE3815: + case RRTILE3819: + case RRTILE3827: + case RRTILE3837: return true; - case RRTILE1996: - case RRTILE2382: - case RRTILE2961: - case RRTILE3804: - case RRTILE7430: - case RRTILE7467: - case RRTILE7469: - case RRTILE7470: - case RRTILE7475: - case RRTILE7566: - case RRTILE7576: - case RRTILE7716: - case RRTILE8063: - case RRTILE8067: - case RRTILE8076: - case RRTILE8106: - case RRTILE8379: - case RRTILE8380: - case RRTILE8565: - case RRTILE8605: - return isRRRA(); - } - return false; + case RRTILE1996: + case RRTILE2382: + case RRTILE2961: + case RRTILE3804: + case RRTILE7430: + case RRTILE7467: + case RRTILE7469: + case RRTILE7470: + case RRTILE7475: + case RRTILE7566: + case RRTILE7576: + case RRTILE7716: + case RRTILE8063: + case RRTILE8067: + case RRTILE8076: + case RRTILE8106: + case RRTILE8379: + case RRTILE8380: + case RRTILE8565: + case RRTILE8605: + return isRRRA(); + } + return false; } //--------------------------------------------------------------------------- @@ -194,101 +194,101 @@ bool isablockdoor(int dapic) void animatewalls_r(void) { - int i, j, p, t; + int i, j, p, t; - if (isRRRA() &&ps[screenpeek].sea_sick_stat == 1) - { - for (i = 0; i < MAXWALLS; i++) - { - if (wall[i].picnum == RRTILE7873) - wall[i].xpanning += 6; - else if (wall[i].picnum == RRTILE7870) - wall[i].xpanning += 6; - } - } + if (isRRRA() &&ps[screenpeek].sea_sick_stat == 1) + { + for (i = 0; i < MAXWALLS; i++) + { + if (wall[i].picnum == RRTILE7873) + wall[i].xpanning += 6; + else if (wall[i].picnum == RRTILE7870) + wall[i].xpanning += 6; + } + } - for (p = 0; p < numanimwalls; p++) - { - i = animwall[p].wallnum; - j = wall[i].picnum; + for (p = 0; p < numanimwalls; p++) + { + i = animwall[p].wallnum; + j = wall[i].picnum; - switch (j) - { - case SCREENBREAK1: - case SCREENBREAK2: - case SCREENBREAK3: - case SCREENBREAK4: - case SCREENBREAK5: + switch (j) + { + case SCREENBREAK1: + case SCREENBREAK2: + case SCREENBREAK3: + case SCREENBREAK4: + case SCREENBREAK5: - case SCREENBREAK9: - case SCREENBREAK10: - case SCREENBREAK11: - case SCREENBREAK12: - case SCREENBREAK13: + case SCREENBREAK9: + case SCREENBREAK10: + case SCREENBREAK11: + case SCREENBREAK12: + case SCREENBREAK13: - if ((krand() & 255) < 16) - { - animwall[p].tag = wall[i].picnum; - wall[i].picnum = SCREENBREAK6; - } + if ((krand() & 255) < 16) + { + animwall[p].tag = wall[i].picnum; + wall[i].picnum = SCREENBREAK6; + } - continue; + continue; - case SCREENBREAK6: - case SCREENBREAK7: - case SCREENBREAK8: + case SCREENBREAK6: + case SCREENBREAK7: + case SCREENBREAK8: - if (animwall[p].tag >= 0) - wall[i].picnum = animwall[p].tag; - else - { - wall[i].picnum++; - if (wall[i].picnum == (SCREENBREAK6 + 3)) - wall[i].picnum = SCREENBREAK6; - } - continue; + if (animwall[p].tag >= 0) + wall[i].picnum = animwall[p].tag; + else + { + wall[i].picnum++; + if (wall[i].picnum == (SCREENBREAK6 + 3)) + wall[i].picnum = SCREENBREAK6; + } + continue; - } + } - if (wall[i].cstat & 16) - switch (wall[i].overpicnum) - { - case W_FORCEFIELD: - case W_FORCEFIELD + 1: - case W_FORCEFIELD + 2: + if (wall[i].cstat & 16) + switch (wall[i].overpicnum) + { + case W_FORCEFIELD: + case W_FORCEFIELD + 1: + case W_FORCEFIELD + 2: - t = animwall[p].tag; + t = animwall[p].tag; - if (wall[i].cstat & 254) - { - wall[i].xpanning -= t >> 10; // sintable[(t+512)&2047]>>12; - wall[i].ypanning -= t >> 10; // sintable[t&2047]>>12; + if (wall[i].cstat & 254) + { + wall[i].xpanning -= t >> 10; // sintable[(t+512)&2047]>>12; + wall[i].ypanning -= t >> 10; // sintable[t&2047]>>12; - if (wall[i].extra == 1) - { - wall[i].extra = 0; - animwall[p].tag = 0; - } - else - animwall[p].tag += 128; + if (wall[i].extra == 1) + { + wall[i].extra = 0; + animwall[p].tag = 0; + } + else + animwall[p].tag += 128; - if (animwall[p].tag < (128 << 4)) - { - if (animwall[p].tag & 128) - wall[i].overpicnum = W_FORCEFIELD; - else wall[i].overpicnum = W_FORCEFIELD + 1; - } - else - { - if ((krand() & 255) < 32) - animwall[p].tag = 128 << (krand() & 3); - else wall[i].overpicnum = W_FORCEFIELD + 1; - } - } + if (animwall[p].tag < (128 << 4)) + { + if (animwall[p].tag & 128) + wall[i].overpicnum = W_FORCEFIELD; + else wall[i].overpicnum = W_FORCEFIELD + 1; + } + else + { + if ((krand() & 255) < 32) + animwall[p].tag = 128 << (krand() & 3); + else wall[i].overpicnum = W_FORCEFIELD + 1; + } + } - break; - } - } + break; + } + } } //--------------------------------------------------------------------------- @@ -299,30 +299,30 @@ void animatewalls_r(void) void operaterespawns_r(int low) { - short i, j, nexti; + short i, j, nexti; - i = headspritestat[11]; - while (i >= 0) - { - nexti = nextspritestat[i]; - if (sprite[i].lotag == low) switch (sprite[i].picnum) - { - case RESPAWN: - if (badguypic(sprite[i].hitag) && ud.monsters_off) break; + i = headspritestat[11]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].lotag == low) switch (sprite[i].picnum) + { + case RESPAWN: + if (badguypic(sprite[i].hitag) && ud.monsters_off) break; - j = spawn(i, TRANSPORTERSTAR); - sprite[j].z -= (32 << 8); + j = spawn(i, TRANSPORTERSTAR); + sprite[j].z -= (32 << 8); - sprite[i].extra = 66 - 12; // Just a way to killit - break; - case RRTILE7424: - if (isRRRA() && !ud.monsters_off) - changespritestat(i, 119); - break; + sprite[i].extra = 66 - 12; // Just a way to killit + break; + case RRTILE7424: + if (isRRRA() && !ud.monsters_off) + changespritestat(i, 119); + break; - } - i = nexti; - } + } + i = nexti; + } } //--------------------------------------------------------------------------- @@ -333,7 +333,7 @@ void operaterespawns_r(int low) void operateforcefields_r(int s, int low) { - operateforcefields_common(s, low, { BIGFORCE }); + operateforcefields_common(s, low, { BIGFORCE }); } //--------------------------------------------------------------------------- @@ -344,559 +344,559 @@ void operateforcefields_r(int s, int low) bool checkhitswitch_r(int snum, int w, int switchtype) { - char switchpal; - short i, x, lotag, hitag, picnum, correctdips, numdips; - int sx, sy; + char switchpal; + short i, x, lotag, hitag, picnum, correctdips, numdips; + int sx, sy; - if (w < 0) return 0; - correctdips = 1; - numdips = 0; + if (w < 0) return 0; + correctdips = 1; + numdips = 0; - if (switchtype == 1) // A wall sprite - { - lotag = sprite[w].lotag; if (lotag == 0) return 0; - hitag = sprite[w].hitag; - sx = sprite[w].x; - sy = sprite[w].y; - picnum = sprite[w].picnum; - switchpal = sprite[w].pal; - } - else - { - lotag = wall[w].lotag; if (lotag == 0) return 0; - hitag = wall[w].hitag; - sx = wall[w].x; - sy = wall[w].y; - picnum = wall[w].picnum; - switchpal = wall[w].pal; - } + if (switchtype == 1) // A wall sprite + { + lotag = sprite[w].lotag; if (lotag == 0) return 0; + hitag = sprite[w].hitag; + sx = sprite[w].x; + sy = sprite[w].y; + picnum = sprite[w].picnum; + switchpal = sprite[w].pal; + } + else + { + lotag = wall[w].lotag; if (lotag == 0) return 0; + hitag = wall[w].hitag; + sx = wall[w].x; + sy = wall[w].y; + picnum = wall[w].picnum; + switchpal = wall[w].pal; + } - switch (picnum) - { - case DIPSWITCH: - case DIPSWITCH + 1: - case TECHSWITCH: - case TECHSWITCH + 1: - case ALIENSWITCH: - case ALIENSWITCH + 1: - break; - case ACCESSSWITCH: - case ACCESSSWITCH2: - if (ps[snum].access_incs == 0) - { - if (switchpal == 0) - { - if (ps[snum].keys[1]) - ps[snum].access_incs = 1; - else - { - FTA(70, &ps[snum]); - if (isRRRA()) spritesound(99, w); - } - } + switch (picnum) + { + case DIPSWITCH: + case DIPSWITCH + 1: + case TECHSWITCH: + case TECHSWITCH + 1: + case ALIENSWITCH: + case ALIENSWITCH + 1: + break; + case ACCESSSWITCH: + case ACCESSSWITCH2: + if (ps[snum].access_incs == 0) + { + if (switchpal == 0) + { + if (ps[snum].keys[1]) + ps[snum].access_incs = 1; + else + { + FTA(70, &ps[snum]); + if (isRRRA()) spritesound(99, w); + } + } - else if (switchpal == 21) - { - if (ps[snum].keys[2]) - ps[snum].access_incs = 1; - else - { - FTA(71, &ps[snum]); - if (isRRRA()) spritesound(99, w); - } - } + else if (switchpal == 21) + { + if (ps[snum].keys[2]) + ps[snum].access_incs = 1; + else + { + FTA(71, &ps[snum]); + if (isRRRA()) spritesound(99, w); + } + } - else if (switchpal == 23) - { - if (ps[snum].keys[3]) - ps[snum].access_incs = 1; - else - { - FTA(72, &ps[snum]); - if (isRRRA()) spritesound(99, w); - } - } + else if (switchpal == 23) + { + if (ps[snum].keys[3]) + ps[snum].access_incs = 1; + else + { + FTA(72, &ps[snum]); + if (isRRRA()) spritesound(99, w); + } + } - if (ps[snum].access_incs == 1) - { - if (switchtype == 0) - ps[snum].access_wallnum = w; - else - ps[snum].access_spritenum = w; - } + if (ps[snum].access_incs == 1) + { + if (switchtype == 0) + ps[snum].access_wallnum = w; + else + ps[snum].access_spritenum = w; + } - return 0; - } - case MULTISWITCH2: - case MULTISWITCH2 + 1: - case MULTISWITCH2 + 2: - case MULTISWITCH2 + 3: - case RRTILE8464: - case RRTILE8660: - if (isRRRA()) break; - case DIPSWITCH2: - case DIPSWITCH2 + 1: - case DIPSWITCH3: - case DIPSWITCH3 + 1: - case MULTISWITCH: - case MULTISWITCH + 1: - case MULTISWITCH + 2: - case MULTISWITCH + 3: - case PULLSWITCH: - case PULLSWITCH + 1: - case HANDSWITCH: - case HANDSWITCH + 1: - case SLOTDOOR: - case SLOTDOOR + 1: - case LIGHTSWITCH: - case LIGHTSWITCH + 1: - case SPACELIGHTSWITCH: - case SPACELIGHTSWITCH + 1: - case SPACEDOORSWITCH: - case SPACEDOORSWITCH + 1: - case FRANKENSTINESWITCH: - case FRANKENSTINESWITCH + 1: - case LIGHTSWITCH2: - case LIGHTSWITCH2 + 1: - case POWERSWITCH1: - case POWERSWITCH1 + 1: - case LOCKSWITCH1: - case LOCKSWITCH1 + 1: - case POWERSWITCH2: - case POWERSWITCH2 + 1: - case NUKEBUTTON: - case NUKEBUTTON + 1: - case RRTILE2214: - case RRTILE2697: - case RRTILE2697 + 1: - case RRTILE2707: - case RRTILE2707 + 1: - if (check_activator_motion(lotag)) return 0; - break; - default: - if (isadoorwall(picnum) == 0) return 0; - break; - } + return 0; + } + case MULTISWITCH2: + case MULTISWITCH2 + 1: + case MULTISWITCH2 + 2: + case MULTISWITCH2 + 3: + case RRTILE8464: + case RRTILE8660: + if (isRRRA()) break; + case DIPSWITCH2: + case DIPSWITCH2 + 1: + case DIPSWITCH3: + case DIPSWITCH3 + 1: + case MULTISWITCH: + case MULTISWITCH + 1: + case MULTISWITCH + 2: + case MULTISWITCH + 3: + case PULLSWITCH: + case PULLSWITCH + 1: + case HANDSWITCH: + case HANDSWITCH + 1: + case SLOTDOOR: + case SLOTDOOR + 1: + case LIGHTSWITCH: + case LIGHTSWITCH + 1: + case SPACELIGHTSWITCH: + case SPACELIGHTSWITCH + 1: + case SPACEDOORSWITCH: + case SPACEDOORSWITCH + 1: + case FRANKENSTINESWITCH: + case FRANKENSTINESWITCH + 1: + case LIGHTSWITCH2: + case LIGHTSWITCH2 + 1: + case POWERSWITCH1: + case POWERSWITCH1 + 1: + case LOCKSWITCH1: + case LOCKSWITCH1 + 1: + case POWERSWITCH2: + case POWERSWITCH2 + 1: + case NUKEBUTTON: + case NUKEBUTTON + 1: + case RRTILE2214: + case RRTILE2697: + case RRTILE2697 + 1: + case RRTILE2707: + case RRTILE2707 + 1: + if (check_activator_motion(lotag)) return 0; + break; + default: + if (isadoorwall(picnum) == 0) return 0; + break; + } - i = headspritestat[0]; - while (i >= 0) - { - if (lotag == sprite[i].lotag) switch (sprite[i].picnum) - { - case DIPSWITCH: - case TECHSWITCH: - case ALIENSWITCH: - if (switchtype == 1 && w == i) sprite[i].picnum++; - else if (sprite[i].hitag == 0) correctdips++; - numdips++; - break; - case TECHSWITCH + 1: - case DIPSWITCH + 1: - case ALIENSWITCH + 1: - if (switchtype == 1 && w == i) sprite[i].picnum--; - else if (sprite[i].hitag == 1) correctdips++; - numdips++; - break; - case MULTISWITCH: - case MULTISWITCH + 1: - case MULTISWITCH + 2: - case MULTISWITCH + 3: - sprite[i].picnum++; - if (sprite[i].picnum > (MULTISWITCH + 3)) - sprite[i].picnum = MULTISWITCH; - break; - case MULTISWITCH2: - case MULTISWITCH2 + 1: - case MULTISWITCH2 + 2: - case MULTISWITCH2 + 3: - if (!isRRRA()) break; - sprite[i].picnum++; - if (sprite[i].picnum > (MULTISWITCH2 + 3)) - sprite[i].picnum = MULTISWITCH2; - break; + i = headspritestat[0]; + while (i >= 0) + { + if (lotag == sprite[i].lotag) switch (sprite[i].picnum) + { + case DIPSWITCH: + case TECHSWITCH: + case ALIENSWITCH: + if (switchtype == 1 && w == i) sprite[i].picnum++; + else if (sprite[i].hitag == 0) correctdips++; + numdips++; + break; + case TECHSWITCH + 1: + case DIPSWITCH + 1: + case ALIENSWITCH + 1: + if (switchtype == 1 && w == i) sprite[i].picnum--; + else if (sprite[i].hitag == 1) correctdips++; + numdips++; + break; + case MULTISWITCH: + case MULTISWITCH + 1: + case MULTISWITCH + 2: + case MULTISWITCH + 3: + sprite[i].picnum++; + if (sprite[i].picnum > (MULTISWITCH + 3)) + sprite[i].picnum = MULTISWITCH; + break; + case MULTISWITCH2: + case MULTISWITCH2 + 1: + case MULTISWITCH2 + 2: + case MULTISWITCH2 + 3: + if (!isRRRA()) break; + sprite[i].picnum++; + if (sprite[i].picnum > (MULTISWITCH2 + 3)) + sprite[i].picnum = MULTISWITCH2; + break; - case RRTILE2214: - if (ud.level_number > 6) - ud.level_number = 0; - sprite[i].picnum++; - break; - case RRTILE8660: - if (!isRRRA()) break; - case ACCESSSWITCH: - case ACCESSSWITCH2: - case SLOTDOOR: - case LIGHTSWITCH: - case SPACELIGHTSWITCH: - case SPACEDOORSWITCH: - case FRANKENSTINESWITCH: - case LIGHTSWITCH2: - case POWERSWITCH1: - case LOCKSWITCH1: - case POWERSWITCH2: - case HANDSWITCH: - case PULLSWITCH: - case DIPSWITCH2: - case DIPSWITCH3: - case NUKEBUTTON: - case RRTILE2697: - case RRTILE2707: - if (sprite[i].picnum == DIPSWITCH3) - if (sprite[i].hitag == 999) - { - short j, nextj; - j = headspritestat[107]; - while (j >= 0) - { - nextj = nextspritestat[j]; - if (sprite[j].picnum == RRTILE3410) - { - sprite[j].picnum++; - sprite[j].hitag = 100; - sprite[j].extra = 0; - spritesound(474, j); - } - else if (sprite[j].picnum == RRTILE295) - deletesprite(j); - j = nextj; - } - sprite[i].picnum++; - break; - } - if (sprite[i].picnum == NUKEBUTTON) - chickenplant = 0; - if (sprite[i].picnum == RRTILE8660) - { - BellTime = 132; - word_119BE0 = i; - } - sprite[i].picnum++; - break; - case PULLSWITCH + 1: - case HANDSWITCH + 1: - case LIGHTSWITCH2 + 1: - case POWERSWITCH1 + 1: - case LOCKSWITCH1 + 1: - case POWERSWITCH2 + 1: - case SLOTDOOR + 1: - case LIGHTSWITCH + 1: - case SPACELIGHTSWITCH + 1: - case SPACEDOORSWITCH + 1: - case FRANKENSTINESWITCH + 1: - case DIPSWITCH2 + 1: - case DIPSWITCH3 + 1: - case NUKEBUTTON + 1: - case RRTILE2697 + 1: - case RRTILE2707 + 1: - if (sprite[i].picnum == NUKEBUTTON + 1) - chickenplant = 1; - if (sprite[i].hitag != 999) - sprite[i].picnum--; - break; - } - i = nextspritestat[i]; - } + case RRTILE2214: + if (ud.level_number > 6) + ud.level_number = 0; + sprite[i].picnum++; + break; + case RRTILE8660: + if (!isRRRA()) break; + case ACCESSSWITCH: + case ACCESSSWITCH2: + case SLOTDOOR: + case LIGHTSWITCH: + case SPACELIGHTSWITCH: + case SPACEDOORSWITCH: + case FRANKENSTINESWITCH: + case LIGHTSWITCH2: + case POWERSWITCH1: + case LOCKSWITCH1: + case POWERSWITCH2: + case HANDSWITCH: + case PULLSWITCH: + case DIPSWITCH2: + case DIPSWITCH3: + case NUKEBUTTON: + case RRTILE2697: + case RRTILE2707: + if (sprite[i].picnum == DIPSWITCH3) + if (sprite[i].hitag == 999) + { + short j, nextj; + j = headspritestat[107]; + while (j >= 0) + { + nextj = nextspritestat[j]; + if (sprite[j].picnum == RRTILE3410) + { + sprite[j].picnum++; + sprite[j].hitag = 100; + sprite[j].extra = 0; + spritesound(474, j); + } + else if (sprite[j].picnum == RRTILE295) + deletesprite(j); + j = nextj; + } + sprite[i].picnum++; + break; + } + if (sprite[i].picnum == NUKEBUTTON) + chickenplant = 0; + if (sprite[i].picnum == RRTILE8660) + { + BellTime = 132; + word_119BE0 = i; + } + sprite[i].picnum++; + break; + case PULLSWITCH + 1: + case HANDSWITCH + 1: + case LIGHTSWITCH2 + 1: + case POWERSWITCH1 + 1: + case LOCKSWITCH1 + 1: + case POWERSWITCH2 + 1: + case SLOTDOOR + 1: + case LIGHTSWITCH + 1: + case SPACELIGHTSWITCH + 1: + case SPACEDOORSWITCH + 1: + case FRANKENSTINESWITCH + 1: + case DIPSWITCH2 + 1: + case DIPSWITCH3 + 1: + case NUKEBUTTON + 1: + case RRTILE2697 + 1: + case RRTILE2707 + 1: + if (sprite[i].picnum == NUKEBUTTON + 1) + chickenplant = 1; + if (sprite[i].hitag != 999) + sprite[i].picnum--; + break; + } + i = nextspritestat[i]; + } - for (i = 0; i < numwalls; i++) - { - x = i; - if (lotag == wall[x].lotag) - switch (wall[x].picnum) - { - case DIPSWITCH: - case TECHSWITCH: - case ALIENSWITCH: - if (switchtype == 0 && i == w) wall[x].picnum++; - else if (wall[x].hitag == 0) correctdips++; - numdips++; - break; - case DIPSWITCH + 1: - case TECHSWITCH + 1: - case ALIENSWITCH + 1: - if (switchtype == 0 && i == w) wall[x].picnum--; - else if (wall[x].hitag == 1) correctdips++; - numdips++; - break; - case MULTISWITCH: - case MULTISWITCH + 1: - case MULTISWITCH + 2: - case MULTISWITCH + 3: - wall[x].picnum++; - if (wall[x].picnum > (MULTISWITCH + 3)) - wall[x].picnum = MULTISWITCH; - break; - case MULTISWITCH2: - case MULTISWITCH2 + 1: - case MULTISWITCH2 + 2: - case MULTISWITCH2 + 3: - if (!isRRRA()) break; - wall[x].picnum++; - if (wall[x].picnum > (MULTISWITCH2 + 3)) - wall[x].picnum = MULTISWITCH2; - break; - case RRTILE8660: - if (!isRRRA()) break; - case ACCESSSWITCH: - case ACCESSSWITCH2: - case SLOTDOOR: - case LIGHTSWITCH: - case SPACELIGHTSWITCH: - case SPACEDOORSWITCH: - case LIGHTSWITCH2: - case POWERSWITCH1: - case LOCKSWITCH1: - case POWERSWITCH2: - case PULLSWITCH: - case HANDSWITCH: - case DIPSWITCH2: - case DIPSWITCH3: - case RRTILE2697: - case RRTILE2707: - wall[x].picnum++; - break; - case HANDSWITCH + 1: - case PULLSWITCH + 1: - case LIGHTSWITCH2 + 1: - case POWERSWITCH1 + 1: - case LOCKSWITCH1 + 1: - case POWERSWITCH2 + 1: - case SLOTDOOR + 1: - case LIGHTSWITCH + 1: - case SPACELIGHTSWITCH + 1: - case SPACEDOORSWITCH + 1: - case DIPSWITCH2 + 1: - case DIPSWITCH3 + 1: - case RRTILE2697 + 1: - case RRTILE2707 + 1: - wall[x].picnum--; - break; - } - } + for (i = 0; i < numwalls; i++) + { + x = i; + if (lotag == wall[x].lotag) + switch (wall[x].picnum) + { + case DIPSWITCH: + case TECHSWITCH: + case ALIENSWITCH: + if (switchtype == 0 && i == w) wall[x].picnum++; + else if (wall[x].hitag == 0) correctdips++; + numdips++; + break; + case DIPSWITCH + 1: + case TECHSWITCH + 1: + case ALIENSWITCH + 1: + if (switchtype == 0 && i == w) wall[x].picnum--; + else if (wall[x].hitag == 1) correctdips++; + numdips++; + break; + case MULTISWITCH: + case MULTISWITCH + 1: + case MULTISWITCH + 2: + case MULTISWITCH + 3: + wall[x].picnum++; + if (wall[x].picnum > (MULTISWITCH + 3)) + wall[x].picnum = MULTISWITCH; + break; + case MULTISWITCH2: + case MULTISWITCH2 + 1: + case MULTISWITCH2 + 2: + case MULTISWITCH2 + 3: + if (!isRRRA()) break; + wall[x].picnum++; + if (wall[x].picnum > (MULTISWITCH2 + 3)) + wall[x].picnum = MULTISWITCH2; + break; + case RRTILE8660: + if (!isRRRA()) break; + case ACCESSSWITCH: + case ACCESSSWITCH2: + case SLOTDOOR: + case LIGHTSWITCH: + case SPACELIGHTSWITCH: + case SPACEDOORSWITCH: + case LIGHTSWITCH2: + case POWERSWITCH1: + case LOCKSWITCH1: + case POWERSWITCH2: + case PULLSWITCH: + case HANDSWITCH: + case DIPSWITCH2: + case DIPSWITCH3: + case RRTILE2697: + case RRTILE2707: + wall[x].picnum++; + break; + case HANDSWITCH + 1: + case PULLSWITCH + 1: + case LIGHTSWITCH2 + 1: + case POWERSWITCH1 + 1: + case LOCKSWITCH1 + 1: + case POWERSWITCH2 + 1: + case SLOTDOOR + 1: + case LIGHTSWITCH + 1: + case SPACELIGHTSWITCH + 1: + case SPACEDOORSWITCH + 1: + case DIPSWITCH2 + 1: + case DIPSWITCH3 + 1: + case RRTILE2697 + 1: + case RRTILE2707 + 1: + wall[x].picnum--; + break; + } + } - if (lotag == (short)65535) - { - ps[myconnectindex].gm = MODE_EOL; - if (ud.from_bonus) - { - ud.level_number = ud.from_bonus; - ud.m_level_number = ud.level_number; - ud.from_bonus = 0; - } - else - { - // fixme: This needs to be taken from the level definitions. - if (isRRRA() && ud.level_number == 6 && ud.volume_number == 0) - RRRA_EndEpisode = 1; // hack to force advancing to episode 2. - ud.level_number = (++ud.level_number < MAXLEVELS) ? ud.level_number : 0; - ud.m_level_number = ud.level_number; - } - } + if (lotag == (short)65535) + { + ps[myconnectindex].gm = MODE_EOL; + if (ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + // fixme: This needs to be taken from the level definitions. + if (isRRRA() && ud.level_number == 6 && ud.volume_number == 0) + RRRA_EndEpisode = 1; // hack to force advancing to episode 2. + ud.level_number = (++ud.level_number < MAXLEVELS) ? ud.level_number : 0; + ud.m_level_number = ud.level_number; + } + } - vec3_t v = { sx, sy, ps[snum].posz }; - switch (picnum) - { - default: - if (isadoorwall(picnum) == 0) break; - case DIPSWITCH: - case DIPSWITCH + 1: - case TECHSWITCH: - case TECHSWITCH + 1: - case ALIENSWITCH: - case ALIENSWITCH + 1: - if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || - picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || - picnum == TECHSWITCH || picnum == TECHSWITCH + 1) - { - if (picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1) - { - if (switchtype == SWITCH_SPRITE) - S_PlaySound3D(ALIEN_SWITCH1, w, &v); - else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].i, &v); - } - else - { - if (switchtype == SWITCH_SPRITE) - S_PlaySound3D(SWITCH_ON, w, &v); - else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); - } - if (numdips != correctdips) break; - S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].i, &v); - } - case MULTISWITCH2: - case MULTISWITCH2 + 1: - case MULTISWITCH2 + 2: - case MULTISWITCH2 + 3: - case RRTILE8464: - case RRTILE8660: - if (!isRRRA()) break; - case DIPSWITCH2: - case DIPSWITCH2 + 1: - case DIPSWITCH3: - case DIPSWITCH3 + 1: - case MULTISWITCH: - case MULTISWITCH + 1: - case MULTISWITCH + 2: - case MULTISWITCH + 3: - case ACCESSSWITCH: - case ACCESSSWITCH2: - case SLOTDOOR: - case SLOTDOOR + 1: - case LIGHTSWITCH: - case LIGHTSWITCH + 1: - case SPACELIGHTSWITCH: - case SPACELIGHTSWITCH + 1: - case SPACEDOORSWITCH: - case SPACEDOORSWITCH + 1: - case FRANKENSTINESWITCH: - case FRANKENSTINESWITCH + 1: - case LIGHTSWITCH2: - case LIGHTSWITCH2 + 1: - case POWERSWITCH1: - case POWERSWITCH1 + 1: - case LOCKSWITCH1: - case LOCKSWITCH1 + 1: - case POWERSWITCH2: - case POWERSWITCH2 + 1: - case HANDSWITCH: - case HANDSWITCH + 1: - case PULLSWITCH: - case PULLSWITCH + 1: - case RRTILE2697: - case RRTILE2697 + 1: - case RRTILE2707: - case RRTILE2707 + 1: - if (isRRRA()) - { - if (picnum == RRTILE8660) - { - BellTime = 132; - word_119BE0 = w; - sprite[w].picnum++; - } - else if (picnum == RRTILE8464) - { - sprite[w].picnum = sprite[w].picnum + 1; - if (hitag == 10001) - { - if (ps[snum].SeaSick == 0) - ps[snum].SeaSick = 350; - operateactivators(668, ps[snum].i); - operatemasterswitches(668); - spritesound(328, ps[snum].i); - return 1; - } - } - else if (hitag == 10000) - { - if (picnum == MULTISWITCH || picnum == (MULTISWITCH + 1) || - picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3) || - picnum == MULTISWITCH2 || picnum == (MULTISWITCH2 + 1) || - picnum == (MULTISWITCH2 + 2) || picnum == (MULTISWITCH2 + 3)) - { - int var6c[3], var54, j; - short jpn, jht; - var54 = 0; - S_PlaySound3D(SWITCH_ON, w, &v); - for (j = 0; j < MAXSPRITES; j++) - { - jpn = sprite[j].picnum; - jht = sprite[j].hitag; - if ((jpn == MULTISWITCH || jpn == MULTISWITCH2) && jht == 10000) - { - if (var54 < 3) - { - var6c[var54] = j; - var54++; - } - } - } - if (var54 == 3) - { - S_PlaySound3D(78, w, &v); - for (j = 0; j < var54; j++) - { - sprite[var6c[j]].hitag = 0; - if (picnum >= MULTISWITCH2) - sprite[var6c[j]].picnum = MULTISWITCH2 + 3; - else - sprite[var6c[j]].picnum = MULTISWITCH + 3; - checkhitswitch_r(snum, var6c[j], 1); - } - } - return 1; - } - } - } - if (picnum == MULTISWITCH || picnum == (MULTISWITCH + 1) || - picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3)) - lotag += picnum - MULTISWITCH; - if (isRRRA()) - { - if (picnum == MULTISWITCH2 || picnum == (MULTISWITCH2 + 1) || - picnum == (MULTISWITCH2 + 2) || picnum == (MULTISWITCH2 + 3)) - lotag += picnum - MULTISWITCH2; - } + vec3_t v = { sx, sy, ps[snum].posz }; + switch (picnum) + { + default: + if (isadoorwall(picnum) == 0) break; + case DIPSWITCH: + case DIPSWITCH + 1: + case TECHSWITCH: + case TECHSWITCH + 1: + case ALIENSWITCH: + case ALIENSWITCH + 1: + if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || + picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || + picnum == TECHSWITCH || picnum == TECHSWITCH + 1) + { + if (picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1) + { + if (switchtype == SWITCH_SPRITE) + S_PlaySound3D(ALIEN_SWITCH1, w, &v); + else S_PlaySound3D(ALIEN_SWITCH1, ps[snum].i, &v); + } + else + { + if (switchtype == SWITCH_SPRITE) + S_PlaySound3D(SWITCH_ON, w, &v); + else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); + } + if (numdips != correctdips) break; + S_PlaySound3D(END_OF_LEVEL_WARN, ps[snum].i, &v); + } + case MULTISWITCH2: + case MULTISWITCH2 + 1: + case MULTISWITCH2 + 2: + case MULTISWITCH2 + 3: + case RRTILE8464: + case RRTILE8660: + if (!isRRRA()) break; + case DIPSWITCH2: + case DIPSWITCH2 + 1: + case DIPSWITCH3: + case DIPSWITCH3 + 1: + case MULTISWITCH: + case MULTISWITCH + 1: + case MULTISWITCH + 2: + case MULTISWITCH + 3: + case ACCESSSWITCH: + case ACCESSSWITCH2: + case SLOTDOOR: + case SLOTDOOR + 1: + case LIGHTSWITCH: + case LIGHTSWITCH + 1: + case SPACELIGHTSWITCH: + case SPACELIGHTSWITCH + 1: + case SPACEDOORSWITCH: + case SPACEDOORSWITCH + 1: + case FRANKENSTINESWITCH: + case FRANKENSTINESWITCH + 1: + case LIGHTSWITCH2: + case LIGHTSWITCH2 + 1: + case POWERSWITCH1: + case POWERSWITCH1 + 1: + case LOCKSWITCH1: + case LOCKSWITCH1 + 1: + case POWERSWITCH2: + case POWERSWITCH2 + 1: + case HANDSWITCH: + case HANDSWITCH + 1: + case PULLSWITCH: + case PULLSWITCH + 1: + case RRTILE2697: + case RRTILE2697 + 1: + case RRTILE2707: + case RRTILE2707 + 1: + if (isRRRA()) + { + if (picnum == RRTILE8660) + { + BellTime = 132; + word_119BE0 = w; + sprite[w].picnum++; + } + else if (picnum == RRTILE8464) + { + sprite[w].picnum = sprite[w].picnum + 1; + if (hitag == 10001) + { + if (ps[snum].SeaSick == 0) + ps[snum].SeaSick = 350; + operateactivators(668, ps[snum].i); + operatemasterswitches(668); + spritesound(328, ps[snum].i); + return 1; + } + } + else if (hitag == 10000) + { + if (picnum == MULTISWITCH || picnum == (MULTISWITCH + 1) || + picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3) || + picnum == MULTISWITCH2 || picnum == (MULTISWITCH2 + 1) || + picnum == (MULTISWITCH2 + 2) || picnum == (MULTISWITCH2 + 3)) + { + int var6c[3], var54, j; + short jpn, jht; + var54 = 0; + S_PlaySound3D(SWITCH_ON, w, &v); + for (j = 0; j < MAXSPRITES; j++) + { + jpn = sprite[j].picnum; + jht = sprite[j].hitag; + if ((jpn == MULTISWITCH || jpn == MULTISWITCH2) && jht == 10000) + { + if (var54 < 3) + { + var6c[var54] = j; + var54++; + } + } + } + if (var54 == 3) + { + S_PlaySound3D(78, w, &v); + for (j = 0; j < var54; j++) + { + sprite[var6c[j]].hitag = 0; + if (picnum >= MULTISWITCH2) + sprite[var6c[j]].picnum = MULTISWITCH2 + 3; + else + sprite[var6c[j]].picnum = MULTISWITCH + 3; + checkhitswitch_r(snum, var6c[j], 1); + } + } + return 1; + } + } + } + if (picnum == MULTISWITCH || picnum == (MULTISWITCH + 1) || + picnum == (MULTISWITCH + 2) || picnum == (MULTISWITCH + 3)) + lotag += picnum - MULTISWITCH; + if (isRRRA()) + { + if (picnum == MULTISWITCH2 || picnum == (MULTISWITCH2 + 1) || + picnum == (MULTISWITCH2 + 2) || picnum == (MULTISWITCH2 + 3)) + lotag += picnum - MULTISWITCH2; + } - x = headspritestat[3]; - while (x >= 0) - { - if (((sprite[x].hitag) == lotag)) - { - switch (sprite[x].lotag) - { - case 46: - case 47: - case 48: - if (!isRRRA()) break; - case 12: - sector[sprite[x].sectnum].floorpal = 0; - hittype[x].temp_data[0]++; - if (hittype[x].temp_data[0] == 2) - hittype[x].temp_data[0]++; + x = headspritestat[3]; + while (x >= 0) + { + if (((sprite[x].hitag) == lotag)) + { + switch (sprite[x].lotag) + { + case 46: + case 47: + case 48: + if (!isRRRA()) break; + case 12: + sector[sprite[x].sectnum].floorpal = 0; + hittype[x].temp_data[0]++; + if (hittype[x].temp_data[0] == 2) + hittype[x].temp_data[0]++; - break; - case 24: - case 34: - case 25: - hittype[x].temp_data[4] = !hittype[x].temp_data[4]; - if (hittype[x].temp_data[4]) - FTA(15, &ps[snum]); - else FTA(2, &ps[snum]); - break; - case 21: - FTA(2, &ps[screenpeek]); - break; - } - } - x = nextspritestat[x]; - } + break; + case 24: + case 34: + case 25: + hittype[x].temp_data[4] = !hittype[x].temp_data[4]; + if (hittype[x].temp_data[4]) + FTA(15, &ps[snum]); + else FTA(2, &ps[snum]); + break; + case 21: + FTA(2, &ps[screenpeek]); + break; + } + } + x = nextspritestat[x]; + } - operateactivators(lotag, snum); - operateforcefields(ps[snum].i, lotag); - operatemasterswitches(lotag); + operateactivators(lotag, snum); + operateforcefields(ps[snum].i, lotag); + operatemasterswitches(lotag); - if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || - picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || - picnum == TECHSWITCH || picnum == TECHSWITCH + 1) return 1; + if (picnum == DIPSWITCH || picnum == DIPSWITCH + 1 || + picnum == ALIENSWITCH || picnum == ALIENSWITCH + 1 || + picnum == TECHSWITCH || picnum == TECHSWITCH + 1) return 1; - if (hitag == 0 && isadoorwall(picnum) == 0) - { - if (switchtype == SWITCH_SPRITE) - S_PlaySound3D(SWITCH_ON, w, &v); - else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); - } - else if (hitag != 0) - { - auto flags = S_GetUserFlags(hitag); + if (hitag == 0 && isadoorwall(picnum) == 0) + { + if (switchtype == SWITCH_SPRITE) + S_PlaySound3D(SWITCH_ON, w, &v); + else S_PlaySound3D(SWITCH_ON, ps[snum].i, &v); + } + else if (hitag != 0) + { + auto flags = S_GetUserFlags(hitag); - if (switchtype == SWITCH_SPRITE && (flags & SF_TALK) == 0) - S_PlaySound3D(hitag, w, &v); - else - A_PlaySound(hitag, ps[snum].i); - } + if (switchtype == SWITCH_SPRITE && (flags & SF_TALK) == 0) + S_PlaySound3D(hitag, w, &v); + else + A_PlaySound(hitag, ps[snum].i); + } - return 1; - } - return 0; + return 1; + } + return 0; } //--------------------------------------------------------------------------- @@ -907,21 +907,21 @@ bool checkhitswitch_r(int snum, int w, int switchtype) void activatebysector_r(int sect, int j) { - short i; + short i; - i = headspritesect[sect]; - while (i >= 0) - { - if (sprite[i].picnum == ACTIVATOR) - { - operateactivators(sprite[i].lotag, -1); - // return; - } - i = nextspritesect[i]; - } + i = headspritesect[sect]; + while (i >= 0) + { + if (sprite[i].picnum == ACTIVATOR) + { + operateactivators(sprite[i].lotag, -1); + // return; + } + i = nextspritesect[i]; + } - if (sector[sect].lotag != 22) - operatesectors(sect, j); + if (sector[sect].lotag != 22) + operatesectors(sect, j); } @@ -933,392 +933,392 @@ void activatebysector_r(int sect, int j) void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith) { - short j, i, sn = -1, darkestwall; - walltype* wal; - spritetype* s; + short j, i, sn = -1, darkestwall; + walltype* wal; + spritetype* s; - wal = &wall[dawallnum]; + wal = &wall[dawallnum]; - if (wal->overpicnum == MIRROR) - { - switch (atwith) - { - case RPG2: - if (!isRRRA()) break; - case HEAVYHBOMB: - case RADIUSEXPLOSION: - case RPG: - case HYDRENT: - case SEENINE: - case OOZFILTER: - case EXPLODINGBARREL: - lotsofglass(spr, dawallnum, 70); - wal->cstat &= ~16; - wal->overpicnum = MIRRORBROKE; - spritesound(GLASS_HEAVYBREAK, spr); - return; - } - } + if (wal->overpicnum == MIRROR) + { + switch (atwith) + { + case RPG2: + if (!isRRRA()) break; + case HEAVYHBOMB: + case RADIUSEXPLOSION: + case RPG: + case HYDRENT: + case SEENINE: + case OOZFILTER: + case EXPLODINGBARREL: + lotsofglass(spr, dawallnum, 70); + wal->cstat &= ~16; + wal->overpicnum = MIRRORBROKE; + spritesound(GLASS_HEAVYBREAK, spr); + return; + } + } - if (((wal->cstat & 16) || wal->overpicnum == BIGFORCE) && wal->nextsector >= 0) - if (sector[wal->nextsector].floorz > z) - if (sector[wal->nextsector].floorz - sector[wal->nextsector].ceilingz) - switch (wal->overpicnum) - { - case FANSPRITE: - wal->overpicnum = FANSPRITEBROKE; - wal->cstat &= 65535 - 65; - if (wal->nextwall >= 0) - { - wall[wal->nextwall].overpicnum = FANSPRITEBROKE; - wall[wal->nextwall].cstat &= 65535 - 65; - } - spritesound(VENT_BUST, spr); - spritesound(GLASS_BREAKING, spr); - return; + if (((wal->cstat & 16) || wal->overpicnum == BIGFORCE) && wal->nextsector >= 0) + if (sector[wal->nextsector].floorz > z) + if (sector[wal->nextsector].floorz - sector[wal->nextsector].ceilingz) + switch (wal->overpicnum) + { + case FANSPRITE: + wal->overpicnum = FANSPRITEBROKE; + wal->cstat &= 65535 - 65; + if (wal->nextwall >= 0) + { + wall[wal->nextwall].overpicnum = FANSPRITEBROKE; + wall[wal->nextwall].cstat &= 65535 - 65; + } + spritesound(VENT_BUST, spr); + spritesound(GLASS_BREAKING, spr); + return; - case RRTILE1973: - updatesector(x, y, &sn); if (sn < 0) return; - wal->overpicnum = GLASS2; - lotsofpopcorn(spr, dawallnum, 64); - wal->cstat = 0; + case RRTILE1973: + updatesector(x, y, &sn); if (sn < 0) return; + wal->overpicnum = GLASS2; + lotsofpopcorn(spr, dawallnum, 64); + wal->cstat = 0; - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat = 0; + if (wal->nextwall >= 0) + wall[wal->nextwall].cstat = 0; - i = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].getang(), 0, 0, spr, 3); - sprite[i].lotag = 128; hittype[i].temp_data[1] = 2; hittype[i].temp_data[2] = dawallnum; - spritesound(GLASS_BREAKING, i); - return; + i = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].getang(), 0, 0, spr, 3); + sprite[i].lotag = 128; hittype[i].temp_data[1] = 2; hittype[i].temp_data[2] = dawallnum; + spritesound(GLASS_BREAKING, i); + return; - case GLASS: - updatesector(x, y, &sn); if (sn < 0) return; - wal->overpicnum = GLASS2; - lotsofglass(spr, dawallnum, 10); - wal->cstat = 0; + case GLASS: + updatesector(x, y, &sn); if (sn < 0) return; + wal->overpicnum = GLASS2; + lotsofglass(spr, dawallnum, 10); + wal->cstat = 0; - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat = 0; + if (wal->nextwall >= 0) + wall[wal->nextwall].cstat = 0; - i = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].getang(), 0, 0, spr, 3); - sprite[i].lotag = 128; hittype[i].temp_data[1] = 2; hittype[i].temp_data[2] = dawallnum; - spritesound(GLASS_BREAKING, i); - return; - case STAINGLASS1: - updatesector(x, y, &sn); if (sn < 0) return; - lotsofcolourglass(spr, dawallnum, 80); - wal->cstat = 0; - if (wal->nextwall >= 0) - wall[wal->nextwall].cstat = 0; - spritesound(VENT_BUST, spr); - spritesound(GLASS_BREAKING, spr); - return; - } + i = EGS(sn, x, y, z, SECTOREFFECTOR, 0, 0, 0, ps[0].getang(), 0, 0, spr, 3); + sprite[i].lotag = 128; hittype[i].temp_data[1] = 2; hittype[i].temp_data[2] = dawallnum; + spritesound(GLASS_BREAKING, i); + return; + case STAINGLASS1: + updatesector(x, y, &sn); if (sn < 0) return; + lotsofcolourglass(spr, dawallnum, 80); + wal->cstat = 0; + if (wal->nextwall >= 0) + wall[wal->nextwall].cstat = 0; + spritesound(VENT_BUST, spr); + spritesound(GLASS_BREAKING, spr); + return; + } - switch (wal->picnum) - { - case RRTILE8464: - if (isRRRA()) break; - break; - case RRTILE3643: - case RRTILE3643 + 1: - case RRTILE3643 + 2: - case RRTILE3643 + 3: - { - short sect; - short unk = 0; - short jj; - short nextjj; - short startwall, endwall; - sect = wall[wal->nextwall].nextsector; - jj = headspritesect[sect]; - while (jj != -1) - { - nextjj = nextspritesect[jj]; - s = &sprite[jj]; - if (s->lotag == 6) - { - for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); - g_spriteExtra[jj]++; // TRANSITIONAL move to sprite or actor - if (g_spriteExtra[jj] == 25) - { - startwall = sector[s->sectnum].wallptr; - endwall = startwall + sector[s->sectnum].wallnum; - for (i = startwall; i < endwall; i++) - sector[wall[i].nextsector].lotag = 0; - sector[s->sectnum].lotag = 0; - stopsound(sprite[jj].lotag); - spritesound(400, jj); - deletesprite(jj); - } - } - jj = nextjj; - } - return; - } - case RRTILE7555: - if (!isRRRA()) break; - wal->picnum = SBMOVE; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7441: - if (!isRRRA()) break; - wal->picnum = RRTILE5016; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7559: - if (!isRRRA()) break; - wal->picnum = RRTILE5017; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7433: - if (!isRRRA()) break; - wal->picnum = RRTILE5018; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7557: - if (!isRRRA()) break; - wal->picnum = RRTILE5019; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7553: - if (!isRRRA()) break; - wal->picnum = RRTILE5020; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7552: - if (!isRRRA()) break; - wal->picnum = RRTILE5021; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7568: - if (!isRRRA()) break; - wal->picnum = RRTILE5022; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7540: - if (!isRRRA()) break; - wal->picnum = RRTILE5023; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7558: - if (!isRRRA()) break; - wal->picnum = RRTILE5024; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7554: - if (!isRRRA()) break; - wal->picnum = RRTILE5025; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7579: - if (!isRRRA()) break; - wal->picnum = RRTILE5026; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7561: - if (!isRRRA()) break; - wal->picnum = RRTILE5027; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7580: - if (!isRRRA()) break; - wal->picnum = RRTILE5037; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE8227: - if (!isRRRA()) break; - wal->picnum = RRTILE5070; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE8503: - if (!isRRRA()) break; - wal->picnum = RRTILE5079; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE8567: - case RRTILE8568: - case RRTILE8569: - case RRTILE8570: - case RRTILE8571: - if (!isRRRA()) break; - wal->picnum = RRTILE5082; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE7859: - if (!isRRRA()) break; - wal->picnum = RRTILE5081; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE8496: - if (!isRRRA()) break; - wal->picnum = RRTILE5061; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE8617: - if (!isRRRA()) break; - if (numplayers < 2) - { - wal->picnum = RRTILE8618; - spritesound(47, spr); - } - return; - case RRTILE8620: - if (!isRRRA()) break; - wal->picnum = RRTILE8621; - spritesound(47, spr); - return; - case RRTILE8622: - if (!isRRRA()) break; - wal->picnum = RRTILE8623; - spritesound(495, spr); - return; - case RRTILE7657: - if (!isRRRA()) break; - wal->picnum = RRTILE7659; - spritesound(GLASS_HEAVYBREAK, spr); - return; - case RRTILE8497: - if (!isRRRA()) break; - wal->picnum = RRTILE5076; - spritesound(495, spr); - return; - case RRTILE7533: - if (!isRRRA()) break; - wal->picnum = RRTILE5035; - spritesound(495, spr); - return; + switch (wal->picnum) + { + case RRTILE8464: + if (isRRRA()) break; + break; + case RRTILE3643: + case RRTILE3643 + 1: + case RRTILE3643 + 2: + case RRTILE3643 + 3: + { + short sect; + short unk = 0; + short jj; + short nextjj; + short startwall, endwall; + sect = wall[wal->nextwall].nextsector; + jj = headspritesect[sect]; + while (jj != -1) + { + nextjj = nextspritesect[jj]; + s = &sprite[jj]; + if (s->lotag == 6) + { + for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); + g_spriteExtra[jj]++; // TRANSITIONAL move to sprite or actor + if (g_spriteExtra[jj] == 25) + { + startwall = sector[s->sectnum].wallptr; + endwall = startwall + sector[s->sectnum].wallnum; + for (i = startwall; i < endwall; i++) + sector[wall[i].nextsector].lotag = 0; + sector[s->sectnum].lotag = 0; + stopsound(sprite[jj].lotag); + spritesound(400, jj); + deletesprite(jj); + } + } + jj = nextjj; + } + return; + } + case RRTILE7555: + if (!isRRRA()) break; + wal->picnum = SBMOVE; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7441: + if (!isRRRA()) break; + wal->picnum = RRTILE5016; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7559: + if (!isRRRA()) break; + wal->picnum = RRTILE5017; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7433: + if (!isRRRA()) break; + wal->picnum = RRTILE5018; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7557: + if (!isRRRA()) break; + wal->picnum = RRTILE5019; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7553: + if (!isRRRA()) break; + wal->picnum = RRTILE5020; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7552: + if (!isRRRA()) break; + wal->picnum = RRTILE5021; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7568: + if (!isRRRA()) break; + wal->picnum = RRTILE5022; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7540: + if (!isRRRA()) break; + wal->picnum = RRTILE5023; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7558: + if (!isRRRA()) break; + wal->picnum = RRTILE5024; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7554: + if (!isRRRA()) break; + wal->picnum = RRTILE5025; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7579: + if (!isRRRA()) break; + wal->picnum = RRTILE5026; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7561: + if (!isRRRA()) break; + wal->picnum = RRTILE5027; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7580: + if (!isRRRA()) break; + wal->picnum = RRTILE5037; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE8227: + if (!isRRRA()) break; + wal->picnum = RRTILE5070; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE8503: + if (!isRRRA()) break; + wal->picnum = RRTILE5079; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE8567: + case RRTILE8568: + case RRTILE8569: + case RRTILE8570: + case RRTILE8571: + if (!isRRRA()) break; + wal->picnum = RRTILE5082; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE7859: + if (!isRRRA()) break; + wal->picnum = RRTILE5081; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE8496: + if (!isRRRA()) break; + wal->picnum = RRTILE5061; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE8617: + if (!isRRRA()) break; + if (numplayers < 2) + { + wal->picnum = RRTILE8618; + spritesound(47, spr); + } + return; + case RRTILE8620: + if (!isRRRA()) break; + wal->picnum = RRTILE8621; + spritesound(47, spr); + return; + case RRTILE8622: + if (!isRRRA()) break; + wal->picnum = RRTILE8623; + spritesound(495, spr); + return; + case RRTILE7657: + if (!isRRRA()) break; + wal->picnum = RRTILE7659; + spritesound(GLASS_HEAVYBREAK, spr); + return; + case RRTILE8497: + if (!isRRRA()) break; + wal->picnum = RRTILE5076; + spritesound(495, spr); + return; + case RRTILE7533: + if (!isRRRA()) break; + wal->picnum = RRTILE5035; + spritesound(495, spr); + return; - case COLAMACHINE: - case VENDMACHINE: - breakwall(wal->picnum + 2, spr, dawallnum); - spritesound(GLASS_BREAKING, spr); - return; + case COLAMACHINE: + case VENDMACHINE: + breakwall(wal->picnum + 2, spr, dawallnum); + spritesound(GLASS_BREAKING, spr); + return; - case OJ: + case OJ: - case SCREENBREAK6: - case SCREENBREAK7: - case SCREENBREAK8: + case SCREENBREAK6: + case SCREENBREAK7: + case SCREENBREAK8: - lotsofglass(spr, dawallnum, 30); - wal->picnum = W_SCREENBREAK + (krand() % (isRRRA() ? 2 : 3)); - spritesound(GLASS_HEAVYBREAK, spr); - return; + lotsofglass(spr, dawallnum, 30); + wal->picnum = W_SCREENBREAK + (krand() % (isRRRA() ? 2 : 3)); + spritesound(GLASS_HEAVYBREAK, spr); + return; - case ATM: - wal->picnum = ATMBROKE; - lotsofmoney(&sprite[spr], 1 + (krand() & 7)); - spritesound(GLASS_HEAVYBREAK, spr); - break; + case ATM: + wal->picnum = ATMBROKE; + lotsofmoney(&sprite[spr], 1 + (krand() & 7)); + spritesound(GLASS_HEAVYBREAK, spr); + break; - case WALLLIGHT1: - case WALLLIGHT3: - case WALLLIGHT4: - case TECHLIGHT2: - case TECHLIGHT4: - case RRTILE1814: - case RRTILE1939: - case RRTILE1986: - case RRTILE1988: - case RRTILE2123: - case RRTILE2125: - case RRTILE2636: - case RRTILE2878: - case RRTILE2898: - case RRTILE3200: - case RRTILE3202: - case RRTILE3204: - case RRTILE3206: - case RRTILE3208: + case WALLLIGHT1: + case WALLLIGHT3: + case WALLLIGHT4: + case TECHLIGHT2: + case TECHLIGHT4: + case RRTILE1814: + case RRTILE1939: + case RRTILE1986: + case RRTILE1988: + case RRTILE2123: + case RRTILE2125: + case RRTILE2636: + case RRTILE2878: + case RRTILE2898: + case RRTILE3200: + case RRTILE3202: + case RRTILE3204: + case RRTILE3206: + case RRTILE3208: - if (rnd(128)) - spritesound(GLASS_HEAVYBREAK, spr); - else spritesound(GLASS_BREAKING, spr); - lotsofglass(spr, dawallnum, 30); + if (rnd(128)) + spritesound(GLASS_HEAVYBREAK, spr); + else spritesound(GLASS_BREAKING, spr); + lotsofglass(spr, dawallnum, 30); - if (wal->picnum == RRTILE1814) - wal->picnum = RRTILE1817; + if (wal->picnum == RRTILE1814) + wal->picnum = RRTILE1817; - if (wal->picnum == RRTILE1986) - wal->picnum = RRTILE1987; + if (wal->picnum == RRTILE1986) + wal->picnum = RRTILE1987; - if (wal->picnum == RRTILE1939) - wal->picnum = RRTILE2004; + if (wal->picnum == RRTILE1939) + wal->picnum = RRTILE2004; - if (wal->picnum == RRTILE1988) - wal->picnum = RRTILE2005; + if (wal->picnum == RRTILE1988) + wal->picnum = RRTILE2005; - if (wal->picnum == RRTILE2898) - wal->picnum = RRTILE2899; + if (wal->picnum == RRTILE2898) + wal->picnum = RRTILE2899; - if (wal->picnum == RRTILE2878) - wal->picnum = RRTILE2879; + if (wal->picnum == RRTILE2878) + wal->picnum = RRTILE2879; - if (wal->picnum == RRTILE2123) - wal->picnum = RRTILE2124; + if (wal->picnum == RRTILE2123) + wal->picnum = RRTILE2124; - if (wal->picnum == RRTILE2125) - wal->picnum = RRTILE2126; + if (wal->picnum == RRTILE2125) + wal->picnum = RRTILE2126; - if (wal->picnum == RRTILE3200) - wal->picnum = RRTILE3201; + if (wal->picnum == RRTILE3200) + wal->picnum = RRTILE3201; - if (wal->picnum == RRTILE3202) - wal->picnum = RRTILE3203; + if (wal->picnum == RRTILE3202) + wal->picnum = RRTILE3203; - if (wal->picnum == RRTILE3204) - wal->picnum = RRTILE3205; + if (wal->picnum == RRTILE3204) + wal->picnum = RRTILE3205; - if (wal->picnum == RRTILE3206) - wal->picnum = RRTILE3207; + if (wal->picnum == RRTILE3206) + wal->picnum = RRTILE3207; - if (wal->picnum == RRTILE3208) - wal->picnum = RRTILE3209; + if (wal->picnum == RRTILE3208) + wal->picnum = RRTILE3209; - if (wal->picnum == RRTILE2636) - wal->picnum = RRTILE2637; + if (wal->picnum == RRTILE2636) + wal->picnum = RRTILE2637; - if (wal->picnum == WALLLIGHT1) - wal->picnum = WALLLIGHTBUST1; + if (wal->picnum == WALLLIGHT1) + wal->picnum = WALLLIGHTBUST1; - if (wal->picnum == WALLLIGHT3) - wal->picnum = WALLLIGHTBUST3; + if (wal->picnum == WALLLIGHT3) + wal->picnum = WALLLIGHTBUST3; - if (wal->picnum == WALLLIGHT4) - wal->picnum = WALLLIGHTBUST4; + if (wal->picnum == WALLLIGHT4) + wal->picnum = WALLLIGHTBUST4; - if (wal->picnum == TECHLIGHT2) - wal->picnum = TECHLIGHTBUST2; + if (wal->picnum == TECHLIGHT2) + wal->picnum = TECHLIGHTBUST2; - if (wal->picnum == TECHLIGHT4) - wal->picnum = TECHLIGHTBUST4; + if (wal->picnum == TECHLIGHT4) + wal->picnum = TECHLIGHTBUST4; - if (!wal->lotag) return; + if (!wal->lotag) return; - sn = wal->nextsector; - if (sn < 0) return; - darkestwall = 0; + sn = wal->nextsector; + if (sn < 0) return; + darkestwall = 0; - wal = &wall[sector[sn].wallptr]; - for (i = sector[sn].wallnum; i > 0; i--, wal++) - if (wal->shade > darkestwall) - darkestwall = wal->shade; + wal = &wall[sector[sn].wallptr]; + for (i = sector[sn].wallnum; i > 0; i--, wal++) + if (wal->shade > darkestwall) + darkestwall = wal->shade; - j = krand() & 1; - i = headspritestat[3]; - while (i >= 0) - { - if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3) - { - hittype[i].temp_data[2] = j; - hittype[i].temp_data[3] = darkestwall; - hittype[i].temp_data[4] = 1; - } - i = nextspritestat[i]; - } - break; - } + j = krand() & 1; + i = headspritestat[3]; + while (i >= 0) + { + if (sprite[i].hitag == wall[dawallnum].lotag && sprite[i].lotag == 3) + { + hittype[i].temp_data[2] = j; + hittype[i].temp_data[3] = darkestwall; + hittype[i].temp_data[4] = 1; + } + i = nextspritestat[i]; + } + break; + } } //--------------------------------------------------------------------------- @@ -1329,55 +1329,55 @@ void checkhitwall_r(int spr, int dawallnum, int x, int y, int z, int atwith) void checkplayerhurt_r(struct player_struct* p, int j) { - if ((j & 49152) == 49152) - { - j &= (MAXSPRITES - 1); + if ((j & 49152) == 49152) + { + j &= (MAXSPRITES - 1); - switch (sprite[j].picnum) - { - case RRTILE2430: - case RRTILE2431: - case RRTILE2432: - case RRTILE2443: - case RRTILE2446: - case RRTILE2451: - case RRTILE2455: - if (isRRRA() && p->hurt_delay2 < 8) - { - sprite[p->i].extra -= 2; - p->hurt_delay2 = 16; - SetPlayerPal(p, PalEntry(32, 32, 0, 0)); - spritesound(DUKE_LONGTERM_PAIN, p->i); - } - break; - case CACTUS: - if (!isRRRA() && p->hurt_delay < 8) - { - sprite[p->i].extra -= 5; - p->hurt_delay = 16; - SetPlayerPal(p, PalEntry(32, 32, 0, 0)); - spritesound(DUKE_LONGTERM_PAIN, p->i); - } - break; - } - return; - } + switch (sprite[j].picnum) + { + case RRTILE2430: + case RRTILE2431: + case RRTILE2432: + case RRTILE2443: + case RRTILE2446: + case RRTILE2451: + case RRTILE2455: + if (isRRRA() && p->hurt_delay2 < 8) + { + sprite[p->i].extra -= 2; + p->hurt_delay2 = 16; + SetPlayerPal(p, PalEntry(32, 32, 0, 0)); + spritesound(DUKE_LONGTERM_PAIN, p->i); + } + break; + case CACTUS: + if (!isRRRA() && p->hurt_delay < 8) + { + sprite[p->i].extra -= 5; + p->hurt_delay = 16; + SetPlayerPal(p, PalEntry(32, 32, 0, 0)); + spritesound(DUKE_LONGTERM_PAIN, p->i); + } + break; + } + return; + } - if ((j & 49152) != 32768) return; - j &= (MAXWALLS - 1); + if ((j & 49152) != 32768) return; + j &= (MAXWALLS - 1); - if (p->hurt_delay > 0) p->hurt_delay--; - else if (wall[j].cstat & 85) switch (wall[j].overpicnum) - { - case BIGFORCE: - p->hurt_delay = 26; - checkhitwall(p->i, j, - p->posx + (sintable[(p->getang() + 512) & 2047] >> 9), - p->posy + (sintable[p->getang() & 2047] >> 9), - p->posz, -1); - break; + if (p->hurt_delay > 0) p->hurt_delay--; + else if (wall[j].cstat & 85) switch (wall[j].overpicnum) + { + case BIGFORCE: + p->hurt_delay = 26; + checkhitwall(p->i, j, + p->posx + (sintable[(p->getang() + 512) & 2047] >> 9), + p->posy + (sintable[p->getang() & 2047] >> 9), + p->posz, -1); + break; - } + } } //--------------------------------------------------------------------------- @@ -1388,100 +1388,100 @@ void checkplayerhurt_r(struct player_struct* p, int j) bool checkhitceiling_r(int sn) { - short i, j; + short i, j; - switch (sector[sn].ceilingpicnum) - { - case WALLLIGHT1: - case WALLLIGHT3: - case WALLLIGHT4: - case TECHLIGHT2: - case TECHLIGHT4: - case RRTILE1939: - case RRTILE1986: - case RRTILE1988: - case RRTILE2123: - case RRTILE2125: - case RRTILE2878: - case RRTILE2898: + switch (sector[sn].ceilingpicnum) + { + case WALLLIGHT1: + case WALLLIGHT3: + case WALLLIGHT4: + case TECHLIGHT2: + case TECHLIGHT4: + case RRTILE1939: + case RRTILE1986: + case RRTILE1988: + case RRTILE2123: + case RRTILE2125: + case RRTILE2878: + case RRTILE2898: - ceilingglass(ps[myconnectindex].i, sn, 10); - spritesound(GLASS_BREAKING, ps[screenpeek].i); + ceilingglass(ps[myconnectindex].i, sn, 10); + spritesound(GLASS_BREAKING, ps[screenpeek].i); - if (sector[sn].ceilingpicnum == WALLLIGHT1) - sector[sn].ceilingpicnum = WALLLIGHTBUST1; + if (sector[sn].ceilingpicnum == WALLLIGHT1) + sector[sn].ceilingpicnum = WALLLIGHTBUST1; - if (sector[sn].ceilingpicnum == WALLLIGHT3) - sector[sn].ceilingpicnum = WALLLIGHTBUST3; + if (sector[sn].ceilingpicnum == WALLLIGHT3) + sector[sn].ceilingpicnum = WALLLIGHTBUST3; - if (sector[sn].ceilingpicnum == WALLLIGHT4) - sector[sn].ceilingpicnum = WALLLIGHTBUST4; + if (sector[sn].ceilingpicnum == WALLLIGHT4) + sector[sn].ceilingpicnum = WALLLIGHTBUST4; - if (sector[sn].ceilingpicnum == TECHLIGHT2) - sector[sn].ceilingpicnum = TECHLIGHTBUST2; + if (sector[sn].ceilingpicnum == TECHLIGHT2) + sector[sn].ceilingpicnum = TECHLIGHTBUST2; - if (sector[sn].ceilingpicnum == TECHLIGHT4) - sector[sn].ceilingpicnum = TECHLIGHTBUST4; + if (sector[sn].ceilingpicnum == TECHLIGHT4) + sector[sn].ceilingpicnum = TECHLIGHTBUST4; - if (sector[sn].ceilingpicnum == RRTILE1986) - sector[sn].ceilingpicnum = RRTILE1987; + if (sector[sn].ceilingpicnum == RRTILE1986) + sector[sn].ceilingpicnum = RRTILE1987; - if (sector[sn].ceilingpicnum == RRTILE1939) - sector[sn].ceilingpicnum = RRTILE2004; + if (sector[sn].ceilingpicnum == RRTILE1939) + sector[sn].ceilingpicnum = RRTILE2004; - if (sector[sn].ceilingpicnum == RRTILE1988) - sector[sn].ceilingpicnum = RRTILE2005; + if (sector[sn].ceilingpicnum == RRTILE1988) + sector[sn].ceilingpicnum = RRTILE2005; - if (sector[sn].ceilingpicnum == RRTILE2898) - sector[sn].ceilingpicnum = RRTILE2899; + if (sector[sn].ceilingpicnum == RRTILE2898) + sector[sn].ceilingpicnum = RRTILE2899; - if (sector[sn].ceilingpicnum == RRTILE2878) - sector[sn].ceilingpicnum = RRTILE2879; + if (sector[sn].ceilingpicnum == RRTILE2878) + sector[sn].ceilingpicnum = RRTILE2879; - if (sector[sn].ceilingpicnum == RRTILE2123) - sector[sn].ceilingpicnum = RRTILE2124; + if (sector[sn].ceilingpicnum == RRTILE2123) + sector[sn].ceilingpicnum = RRTILE2124; - if (sector[sn].ceilingpicnum == RRTILE2125) - sector[sn].ceilingpicnum = RRTILE2126; + if (sector[sn].ceilingpicnum == RRTILE2125) + sector[sn].ceilingpicnum = RRTILE2126; - if (!sector[sn].hitag) - { - i = headspritesect[sn]; - while (i >= 0) - { - if (sprite[i].picnum == SECTOREFFECTOR && (sprite[i].lotag == 12 || (isRRRA() && (sprite[i].lotag == 47 || sprite[i].lotag == 48)))) - { - j = headspritestat[3]; - while (j >= 0) - { - if (sprite[j].hitag == sprite[i].hitag) - hittype[j].temp_data[3] = 1; - j = nextspritestat[j]; - } - break; - } - i = nextspritesect[i]; - } - } + if (!sector[sn].hitag) + { + i = headspritesect[sn]; + while (i >= 0) + { + if (sprite[i].picnum == SECTOREFFECTOR && (sprite[i].lotag == 12 || (isRRRA() && (sprite[i].lotag == 47 || sprite[i].lotag == 48)))) + { + j = headspritestat[3]; + while (j >= 0) + { + if (sprite[j].hitag == sprite[i].hitag) + hittype[j].temp_data[3] = 1; + j = nextspritestat[j]; + } + break; + } + i = nextspritesect[i]; + } + } - i = headspritestat[3]; - j = krand() & 1; - while (i >= 0) - { - if (sprite[i].hitag == (sector[sn].hitag) && sprite[i].lotag == 3) - { - hittype[i].temp_data[2] = j; - hittype[i].temp_data[4] = 1; - } - i = nextspritestat[i]; - } + i = headspritestat[3]; + j = krand() & 1; + while (i >= 0) + { + if (sprite[i].hitag == (sector[sn].hitag) && sprite[i].lotag == 3) + { + hittype[i].temp_data[2] = j; + hittype[i].temp_data[4] = 1; + } + i = nextspritestat[i]; + } - return 1; - } + return 1; + } - return 0; + return 0; } //--------------------------------------------------------------------------- @@ -1492,897 +1492,897 @@ bool checkhitceiling_r(int sn) void checkhitsprite_r(int i, int sn) { - int j, k, p; - spritetype* s; + int j, k, p; + spritetype* s; - i &= (MAXSPRITES - 1); + i &= (MAXSPRITES - 1); - if (isRRRA()) switch (sprite[i].picnum) - { - case RRTILE8464: - break; - case RRTILE8487: - case RRTILE8489: - spritesound(471, i); - sprite[i].picnum++; - break; - case RRTILE7638: - case RRTILE7644: - case RRTILE7646: - case RRTILE7650: - case RRTILE7653: - case RRTILE7655: - case RRTILE7691: - case RRTILE7876: - case RRTILE7881: - case RRTILE7883: - sprite[i].picnum++; - spritesound(VENT_BUST, i); - break; - case RRTILE7879: - sprite[i].picnum++; - spritesound(495, i); - hitradius(i, 10, 0, 0, 1, 1); - break; - case RRTILE7648: - case RRTILE7694: - case RRTILE7700: - case RRTILE7702: - case RRTILE7711: - sprite[i].picnum++; - spritesound(47, i); - break; - case RRTILE7636: - sprite[i].picnum += 3; - spritesound(VENT_BUST, i); - break; - case RRTILE7875: - sprite[i].picnum += 3; - spritesound(VENT_BUST, i); - break; - case RRTILE7640: - sprite[i].picnum += 2; - spritesound(VENT_BUST, i); - break; - case RRTILE7595: - case RRTILE7704: - sprite[i].picnum = RRTILE7705; - spritesound(495, i); - break; - case RRTILE8579: - sprite[i].picnum = RRTILE5014; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7441: - sprite[i].picnum = RRTILE5016; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7534: - sprite[i].picnum = RRTILE5029; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7545: - sprite[i].picnum = RRTILE5030; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7547: - sprite[i].picnum = RRTILE5031; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7574: - sprite[i].picnum = RRTILE5032; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7575: - sprite[i].picnum = RRTILE5033; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7578: - sprite[i].picnum = RRTILE5034; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7478: - sprite[i].picnum = RRTILE5035; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8525: - sprite[i].picnum = RRTILE5036; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8537: - sprite[i].picnum = RRTILE5062; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8215: - sprite[i].picnum = RRTILE5064; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8216: - sprite[i].picnum = RRTILE5065; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8217: - sprite[i].picnum = RRTILE5066; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8218: - sprite[i].picnum = RRTILE5067; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8220: - sprite[i].picnum = RRTILE5068; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8221: - sprite[i].picnum = RRTILE5069; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8312: - sprite[i].picnum = RRTILE5071; - spritesound(472, i); - break; - case RRTILE8395: - sprite[i].picnum = RRTILE5072; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8423: - sprite[i].picnum = RRTILE5073; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE3462: - sprite[i].picnum = RRTILE5074; - spritesound(GLASS_HEAVYBREAK, i); - break; - case UWHIP: - sprite[i].picnum = RRTILE5075; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8608: - sprite[i].picnum = RRTILE5083; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8609: - sprite[i].picnum = RRTILE5084; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8567: - case RRTILE8568: - case RRTILE8569: - case RRTILE8570: - case RRTILE8571: - sprite[i].picnum = RRTILE5082; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8640: - sprite[i].picnum = RRTILE5085; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8611: - sprite[i].picnum = RRTILE5086; - spritesound(GLASS_HEAVYBREAK, i); - break; - case TECHLIGHTBUST2: - sprite[i].picnum = TECHLIGHTBUST4; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8497: - sprite[i].picnum = RRTILE5076; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8162: - case RRTILE8163: - case RRTILE8164: - case RRTILE8165: - case RRTILE8166: - case RRTILE8167: - case RRTILE8168: - changespritestat(i, 5); - sprite[i].picnum = RRTILE5063; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8589: - case RRTILE8590: - case RRTILE8591: - case RRTILE8592: - case RRTILE8593: - case RRTILE8594: - case RRTILE8595: - changespritestat(i, 5); - sprite[i].picnum = RRTILE8588; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE3497: - sprite[i].picnum = RRTILE5076; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE3498: - sprite[i].picnum = RRTILE5077; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE3499: - sprite[i].picnum = RRTILE5078; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8503: - sprite[i].picnum = RRTILE5079; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7901: - sprite[i].picnum = RRTILE5080; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7696: - sprite[i].picnum = RRTILE7697; - spritesound(DUKE_SHUCKS, i); - break; - case RRTILE7806: - sprite[i].picnum = RRTILE5043; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7885: - case RRTILE7890: - sprite[i].picnum = RRTILE5045; - spritesound(495, i); - hitradius(i, 10, 0, 0, 1, 1); - break; - case RRTILE7886: - sprite[i].picnum = RRTILE5046; - spritesound(495, i); - hitradius(i, 10, 0, 0, 1, 1); - break; - case RRTILE7887: - sprite[i].picnum = RRTILE5044; - spritesound(GLASS_HEAVYBREAK, i); - hitradius(i, 10, 0, 0, 1, 1); - break; - case RRTILE7900: - sprite[i].picnum = RRTILE5047; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7906: - sprite[i].picnum = RRTILE5048; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7912: - case RRTILE7913: - sprite[i].picnum = RRTILE5049; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8047: - sprite[i].picnum = RRTILE5050; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8596: - sprite[i].picnum = RRTILE8598; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8059: - sprite[i].picnum = RRTILE5051; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8060: - sprite[i].picnum = RRTILE5052; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8222: - sprite[i].picnum = RRTILE5053; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8223: - sprite[i].picnum = RRTILE5054; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8224: - sprite[i].picnum = RRTILE5055; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8370: - sprite[i].picnum = RRTILE5056; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8371: - sprite[i].picnum = RRTILE5057; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8372: - sprite[i].picnum = RRTILE5058; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8373: - sprite[i].picnum = RRTILE5059; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8396: - sprite[i].picnum = RRTILE5038; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8397: - sprite[i].picnum = RRTILE5039; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8398: - sprite[i].picnum = RRTILE5040; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8399: - sprite[i].picnum = RRTILE5041; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8385: - sprite[i].picnum = RRTILE8386; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8387: - sprite[i].picnum = RRTILE8388; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8389: - sprite[i].picnum = RRTILE8390; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8391: - sprite[i].picnum = RRTILE8392; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE7553: - sprite[i].picnum = RRTILE5035; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8475: - sprite[i].picnum = RRTILE5075; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8498: - sprite[i].picnum = RRTILE5077; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8499: - sprite[i].picnum = RRTILE5078; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE2445: - sprite[i].picnum = RRTILE2450; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE2123: - sprite[i].picnum = RRTILE2124; - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - break; - case RRTILE3773: - sprite[i].picnum = RRTILE8651; - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - break; - case RRTILE7533: - sprite[i].picnum = RRTILE5035; - spritesound(495, i); - hitradius(i, 10, 0, 0, 1, 1); - break; - case RRTILE8394: - sprite[i].picnum = RRTILE5072; - spritesound(495, i); - break; - case RRTILE8461: - case RRTILE8462: - sprite[i].picnum = RRTILE5074; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8679: - sprite[i].picnum = RRTILE8680; - spritesound(DUKE_SHUCKS, i); - hitradius(i, 10, 0, 0, 1, 1); - if (sprite[i].lotag != 0) - { - short j; - for (j = 0; j < MAXSPRITES; j++) - { - if (sprite[j].picnum == RRTILE8679 && sprite[j].pal == 4) - { - if (sprite[j].lotag == sprite[i].lotag) - sprite[j].picnum = RRTILE8680; - } - } - } - break; - case RRTILE3584: - sprite[i].picnum = RRTILE8681; - spritesound(495, i); - hitradius(i, 250, 0, 0, 1, 1); - break; - case RRTILE8682: - sprite[i].picnum = RRTILE8683; - spritesound(GLASS_HEAVYBREAK, i); - break; - case RRTILE8099: - if (sprite[i].lotag == 5) - { - short j; - sprite[i].lotag = 0; - sprite[i].picnum = RRTILE5087; - spritesound(340, i); - for (j = 0; j < MAXSPRITES; j++) - { - if (sprite[j].picnum == RRTILE8094) - sprite[j].picnum = RRTILE5088; - } - } - break; - case RRTILE2431: - if (sprite[i].pal != 4) - { - sprite[i].picnum = RRTILE2451; - if (sprite[i].lotag != 0) - { - short j; - for (j = 0; j < MAXSPRITES; j++) - { - if (sprite[j].picnum == RRTILE2431 && sprite[j].pal == 4) - { - if (sprite[i].lotag == sprite[j].lotag) - sprite[j].picnum = RRTILE2451; - } - } - } - } - break; - case RRTILE2443: - if (sprite[i].pal != 19) - sprite[i].picnum = RRTILE2455; - break; - case RRTILE2455: - spritesound(SQUISHED, i); - guts(&sprite[i], RRTILE2465, 3, myconnectindex); - deletesprite(i); - break; - case RRTILE2451: - if (sprite[i].pal != 4) - { - spritesound(SQUISHED, i); - if (sprite[i].lotag != 0) - { - short j; - for (j = 0; j < MAXSPRITES; j++) - { - if (sprite[j].picnum == RRTILE2451 && sprite[j].pal == 4) - { - if (sprite[i].lotag == sprite[j].lotag) - { - guts(&sprite[i], RRTILE2460, 12, myconnectindex); - guts(&sprite[i], RRTILE2465, 3, myconnectindex); - sprite[j].xrepeat = 0; - sprite[j].yrepeat = 0; - sprite[i].xrepeat = 0; - sprite[i].yrepeat = 0; - } - } - } - } - else - { - guts(&sprite[i], RRTILE2460, 12, myconnectindex); - guts(&sprite[i], RRTILE2465, 3, myconnectindex); - sprite[i].xrepeat = 0; - sprite[i].yrepeat = 0; - } - } - break; - case RRTILE2437: - spritesound(439, i); - break; - } + if (isRRRA()) switch (sprite[i].picnum) + { + case RRTILE8464: + break; + case RRTILE8487: + case RRTILE8489: + spritesound(471, i); + sprite[i].picnum++; + break; + case RRTILE7638: + case RRTILE7644: + case RRTILE7646: + case RRTILE7650: + case RRTILE7653: + case RRTILE7655: + case RRTILE7691: + case RRTILE7876: + case RRTILE7881: + case RRTILE7883: + sprite[i].picnum++; + spritesound(VENT_BUST, i); + break; + case RRTILE7879: + sprite[i].picnum++; + spritesound(495, i); + hitradius(i, 10, 0, 0, 1, 1); + break; + case RRTILE7648: + case RRTILE7694: + case RRTILE7700: + case RRTILE7702: + case RRTILE7711: + sprite[i].picnum++; + spritesound(47, i); + break; + case RRTILE7636: + sprite[i].picnum += 3; + spritesound(VENT_BUST, i); + break; + case RRTILE7875: + sprite[i].picnum += 3; + spritesound(VENT_BUST, i); + break; + case RRTILE7640: + sprite[i].picnum += 2; + spritesound(VENT_BUST, i); + break; + case RRTILE7595: + case RRTILE7704: + sprite[i].picnum = RRTILE7705; + spritesound(495, i); + break; + case RRTILE8579: + sprite[i].picnum = RRTILE5014; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7441: + sprite[i].picnum = RRTILE5016; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7534: + sprite[i].picnum = RRTILE5029; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7545: + sprite[i].picnum = RRTILE5030; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7547: + sprite[i].picnum = RRTILE5031; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7574: + sprite[i].picnum = RRTILE5032; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7575: + sprite[i].picnum = RRTILE5033; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7578: + sprite[i].picnum = RRTILE5034; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7478: + sprite[i].picnum = RRTILE5035; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8525: + sprite[i].picnum = RRTILE5036; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8537: + sprite[i].picnum = RRTILE5062; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8215: + sprite[i].picnum = RRTILE5064; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8216: + sprite[i].picnum = RRTILE5065; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8217: + sprite[i].picnum = RRTILE5066; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8218: + sprite[i].picnum = RRTILE5067; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8220: + sprite[i].picnum = RRTILE5068; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8221: + sprite[i].picnum = RRTILE5069; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8312: + sprite[i].picnum = RRTILE5071; + spritesound(472, i); + break; + case RRTILE8395: + sprite[i].picnum = RRTILE5072; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8423: + sprite[i].picnum = RRTILE5073; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE3462: + sprite[i].picnum = RRTILE5074; + spritesound(GLASS_HEAVYBREAK, i); + break; + case UWHIP: + sprite[i].picnum = RRTILE5075; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8608: + sprite[i].picnum = RRTILE5083; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8609: + sprite[i].picnum = RRTILE5084; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8567: + case RRTILE8568: + case RRTILE8569: + case RRTILE8570: + case RRTILE8571: + sprite[i].picnum = RRTILE5082; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8640: + sprite[i].picnum = RRTILE5085; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8611: + sprite[i].picnum = RRTILE5086; + spritesound(GLASS_HEAVYBREAK, i); + break; + case TECHLIGHTBUST2: + sprite[i].picnum = TECHLIGHTBUST4; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8497: + sprite[i].picnum = RRTILE5076; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8162: + case RRTILE8163: + case RRTILE8164: + case RRTILE8165: + case RRTILE8166: + case RRTILE8167: + case RRTILE8168: + changespritestat(i, 5); + sprite[i].picnum = RRTILE5063; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8589: + case RRTILE8590: + case RRTILE8591: + case RRTILE8592: + case RRTILE8593: + case RRTILE8594: + case RRTILE8595: + changespritestat(i, 5); + sprite[i].picnum = RRTILE8588; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE3497: + sprite[i].picnum = RRTILE5076; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE3498: + sprite[i].picnum = RRTILE5077; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE3499: + sprite[i].picnum = RRTILE5078; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8503: + sprite[i].picnum = RRTILE5079; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7901: + sprite[i].picnum = RRTILE5080; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7696: + sprite[i].picnum = RRTILE7697; + spritesound(DUKE_SHUCKS, i); + break; + case RRTILE7806: + sprite[i].picnum = RRTILE5043; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7885: + case RRTILE7890: + sprite[i].picnum = RRTILE5045; + spritesound(495, i); + hitradius(i, 10, 0, 0, 1, 1); + break; + case RRTILE7886: + sprite[i].picnum = RRTILE5046; + spritesound(495, i); + hitradius(i, 10, 0, 0, 1, 1); + break; + case RRTILE7887: + sprite[i].picnum = RRTILE5044; + spritesound(GLASS_HEAVYBREAK, i); + hitradius(i, 10, 0, 0, 1, 1); + break; + case RRTILE7900: + sprite[i].picnum = RRTILE5047; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7906: + sprite[i].picnum = RRTILE5048; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7912: + case RRTILE7913: + sprite[i].picnum = RRTILE5049; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8047: + sprite[i].picnum = RRTILE5050; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8596: + sprite[i].picnum = RRTILE8598; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8059: + sprite[i].picnum = RRTILE5051; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8060: + sprite[i].picnum = RRTILE5052; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8222: + sprite[i].picnum = RRTILE5053; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8223: + sprite[i].picnum = RRTILE5054; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8224: + sprite[i].picnum = RRTILE5055; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8370: + sprite[i].picnum = RRTILE5056; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8371: + sprite[i].picnum = RRTILE5057; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8372: + sprite[i].picnum = RRTILE5058; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8373: + sprite[i].picnum = RRTILE5059; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8396: + sprite[i].picnum = RRTILE5038; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8397: + sprite[i].picnum = RRTILE5039; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8398: + sprite[i].picnum = RRTILE5040; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8399: + sprite[i].picnum = RRTILE5041; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8385: + sprite[i].picnum = RRTILE8386; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8387: + sprite[i].picnum = RRTILE8388; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8389: + sprite[i].picnum = RRTILE8390; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8391: + sprite[i].picnum = RRTILE8392; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE7553: + sprite[i].picnum = RRTILE5035; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8475: + sprite[i].picnum = RRTILE5075; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8498: + sprite[i].picnum = RRTILE5077; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8499: + sprite[i].picnum = RRTILE5078; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE2445: + sprite[i].picnum = RRTILE2450; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE2123: + sprite[i].picnum = RRTILE2124; + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + break; + case RRTILE3773: + sprite[i].picnum = RRTILE8651; + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + break; + case RRTILE7533: + sprite[i].picnum = RRTILE5035; + spritesound(495, i); + hitradius(i, 10, 0, 0, 1, 1); + break; + case RRTILE8394: + sprite[i].picnum = RRTILE5072; + spritesound(495, i); + break; + case RRTILE8461: + case RRTILE8462: + sprite[i].picnum = RRTILE5074; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8679: + sprite[i].picnum = RRTILE8680; + spritesound(DUKE_SHUCKS, i); + hitradius(i, 10, 0, 0, 1, 1); + if (sprite[i].lotag != 0) + { + short j; + for (j = 0; j < MAXSPRITES; j++) + { + if (sprite[j].picnum == RRTILE8679 && sprite[j].pal == 4) + { + if (sprite[j].lotag == sprite[i].lotag) + sprite[j].picnum = RRTILE8680; + } + } + } + break; + case RRTILE3584: + sprite[i].picnum = RRTILE8681; + spritesound(495, i); + hitradius(i, 250, 0, 0, 1, 1); + break; + case RRTILE8682: + sprite[i].picnum = RRTILE8683; + spritesound(GLASS_HEAVYBREAK, i); + break; + case RRTILE8099: + if (sprite[i].lotag == 5) + { + short j; + sprite[i].lotag = 0; + sprite[i].picnum = RRTILE5087; + spritesound(340, i); + for (j = 0; j < MAXSPRITES; j++) + { + if (sprite[j].picnum == RRTILE8094) + sprite[j].picnum = RRTILE5088; + } + } + break; + case RRTILE2431: + if (sprite[i].pal != 4) + { + sprite[i].picnum = RRTILE2451; + if (sprite[i].lotag != 0) + { + short j; + for (j = 0; j < MAXSPRITES; j++) + { + if (sprite[j].picnum == RRTILE2431 && sprite[j].pal == 4) + { + if (sprite[i].lotag == sprite[j].lotag) + sprite[j].picnum = RRTILE2451; + } + } + } + } + break; + case RRTILE2443: + if (sprite[i].pal != 19) + sprite[i].picnum = RRTILE2455; + break; + case RRTILE2455: + spritesound(SQUISHED, i); + guts(&sprite[i], RRTILE2465, 3, myconnectindex); + deletesprite(i); + break; + case RRTILE2451: + if (sprite[i].pal != 4) + { + spritesound(SQUISHED, i); + if (sprite[i].lotag != 0) + { + short j; + for (j = 0; j < MAXSPRITES; j++) + { + if (sprite[j].picnum == RRTILE2451 && sprite[j].pal == 4) + { + if (sprite[i].lotag == sprite[j].lotag) + { + guts(&sprite[i], RRTILE2460, 12, myconnectindex); + guts(&sprite[i], RRTILE2465, 3, myconnectindex); + sprite[j].xrepeat = 0; + sprite[j].yrepeat = 0; + sprite[i].xrepeat = 0; + sprite[i].yrepeat = 0; + } + } + } + } + else + { + guts(&sprite[i], RRTILE2460, 12, myconnectindex); + guts(&sprite[i], RRTILE2465, 3, myconnectindex); + sprite[i].xrepeat = 0; + sprite[i].yrepeat = 0; + } + } + break; + case RRTILE2437: + spritesound(439, i); + break; + } - switch (sprite[i].picnum) - { - case RRTILE3114: - sprite[i].picnum = RRTILE3117; - break; - case RRTILE2876: - sprite[i].picnum = RRTILE2990; - break; - case RRTILE3152: - sprite[i].picnum = RRTILE3218; - break; - case RRTILE3153: - sprite[i].picnum = RRTILE3219; - break; - case RRTILE2030: - sprite[i].picnum = RRTILE2034; - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - break; - case RRTILE2893: - case RRTILE2915: - case RRTILE3115: - case RRTILE3171: - switch (sprite[i].picnum) - { - case RRTILE2915: - sprite[i].picnum = RRTILE2977; - break; - case RRTILE2893: - sprite[i].picnum = RRTILE2978; - break; - case RRTILE3115: - sprite[i].picnum = RRTILE3116; - break; - case RRTILE3171: - sprite[i].picnum = RRTILE3216; - break; - } - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - break; - case RRTILE2156: - case RRTILE2158: - case RRTILE2160: - case RRTILE2175: - sprite[i].picnum++; - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - break; - case RRTILE2137: - case RRTILE2151: - case RRTILE2152: - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - sprite[i].picnum++; - for (k = 0; k < 6; k++) - EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z - (8 << 8), SCRAP6 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (sprite[i].zvel >> 2), i, 5); - break; - case BOWLINGBALL: - sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); - sprite[sn].ang -= (krand() & 16); - spritesound(355, i); - break; + switch (sprite[i].picnum) + { + case RRTILE3114: + sprite[i].picnum = RRTILE3117; + break; + case RRTILE2876: + sprite[i].picnum = RRTILE2990; + break; + case RRTILE3152: + sprite[i].picnum = RRTILE3218; + break; + case RRTILE3153: + sprite[i].picnum = RRTILE3219; + break; + case RRTILE2030: + sprite[i].picnum = RRTILE2034; + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + break; + case RRTILE2893: + case RRTILE2915: + case RRTILE3115: + case RRTILE3171: + switch (sprite[i].picnum) + { + case RRTILE2915: + sprite[i].picnum = RRTILE2977; + break; + case RRTILE2893: + sprite[i].picnum = RRTILE2978; + break; + case RRTILE3115: + sprite[i].picnum = RRTILE3116; + break; + case RRTILE3171: + sprite[i].picnum = RRTILE3216; + break; + } + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + break; + case RRTILE2156: + case RRTILE2158: + case RRTILE2160: + case RRTILE2175: + sprite[i].picnum++; + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + break; + case RRTILE2137: + case RRTILE2151: + case RRTILE2152: + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + sprite[i].picnum++; + for (k = 0; k < 6; k++) + EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z - (8 << 8), SCRAP6 + (krand() & 15), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (sprite[i].zvel >> 2), i, 5); + break; + case BOWLINGBALL: + sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); + sprite[sn].ang -= (krand() & 16); + spritesound(355, i); + break; - case STRIPEBALL: - case QUEBALL: - case RRTILE3440: - case RRTILE3440 + 1: - case HENSTAND: - case HENSTAND + 1: - if (sprite[sn].picnum == QUEBALL || sprite[sn].picnum == STRIPEBALL) - { - sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); - sprite[sn].ang -= (sprite[i].ang << 1) + 1024; - sprite[i].ang = getangle(sprite[i].x - sprite[sn].x, sprite[i].y - sprite[sn].y) - 512; - if (S_CheckSoundPlaying(POOLBALLHIT) < 2) - spritesound(POOLBALLHIT, i); - } - else if (sprite[sn].picnum == RRTILE3440 || sprite[sn].picnum == RRTILE3440 + 1) - { - sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); - sprite[sn].ang -= ((sprite[i].ang << 1) + krand()) & 64; - sprite[i].ang = (sprite[i].ang + krand()) & 16; - spritesound(355, i); - } - else if (sprite[sn].picnum == HENSTAND || sprite[sn].picnum == HENSTAND + 1) - { - sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); - sprite[sn].ang -= ((sprite[i].ang << 1) + krand()) & 16; - sprite[i].ang = (sprite[i].ang + krand()) & 16; - spritesound(355, i); - } - else - { - if (krand() & 3) - { - sprite[i].xvel = 164; - sprite[i].ang = sprite[sn].ang; - } - } - break; + case STRIPEBALL: + case QUEBALL: + case RRTILE3440: + case RRTILE3440 + 1: + case HENSTAND: + case HENSTAND + 1: + if (sprite[sn].picnum == QUEBALL || sprite[sn].picnum == STRIPEBALL) + { + sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); + sprite[sn].ang -= (sprite[i].ang << 1) + 1024; + sprite[i].ang = getangle(sprite[i].x - sprite[sn].x, sprite[i].y - sprite[sn].y) - 512; + if (S_CheckSoundPlaying(POOLBALLHIT) < 2) + spritesound(POOLBALLHIT, i); + } + else if (sprite[sn].picnum == RRTILE3440 || sprite[sn].picnum == RRTILE3440 + 1) + { + sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); + sprite[sn].ang -= ((sprite[i].ang << 1) + krand()) & 64; + sprite[i].ang = (sprite[i].ang + krand()) & 16; + spritesound(355, i); + } + else if (sprite[sn].picnum == HENSTAND || sprite[sn].picnum == HENSTAND + 1) + { + sprite[sn].xvel = (sprite[i].xvel >> 1) + (sprite[i].xvel >> 2); + sprite[sn].ang -= ((sprite[i].ang << 1) + krand()) & 16; + sprite[i].ang = (sprite[i].ang + krand()) & 16; + spritesound(355, i); + } + else + { + if (krand() & 3) + { + sprite[i].xvel = 164; + sprite[i].ang = sprite[sn].ang; + } + } + break; - case TREE1: - case TREE2: - case TIRE: - case BOX: - switch (sprite[sn].picnum) - { - case RPG2: - if (!isRRRA()) break; - case RADIUSEXPLOSION: - case RPG: - case FIRELASER: - case HYDRENT: - case HEAVYHBOMB: - case TRIPBOMBSPRITE: - case COOLEXPLOSION1: - case OWHIP: - case UWHIP: - if (hittype[i].temp_data[0] == 0) - { - sprite[i].cstat &= ~257; - hittype[i].temp_data[0] = 1; - spawn(i, BURNING); - } - break; - } - break; + case TREE1: + case TREE2: + case TIRE: + case BOX: + switch (sprite[sn].picnum) + { + case RPG2: + if (!isRRRA()) break; + case RADIUSEXPLOSION: + case RPG: + case FIRELASER: + case HYDRENT: + case HEAVYHBOMB: + case TRIPBOMBSPRITE: + case COOLEXPLOSION1: + case OWHIP: + case UWHIP: + if (hittype[i].temp_data[0] == 0) + { + sprite[i].cstat &= ~257; + hittype[i].temp_data[0] = 1; + spawn(i, BURNING); + } + break; + } + break; - case CACTUS: - // case CACTUSBROKE: - switch (sprite[sn].picnum) - { - case RPG2: - if (!isRRRA()) break; - case RADIUSEXPLOSION: - case RPG: - case FIRELASER: - case HYDRENT: - case HEAVYHBOMB: - case TRIPBOMBSPRITE: - case COOLEXPLOSION1: - case OWHIP: - case UWHIP: - for (k = 0; k < 64; k++) - { - j = EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z - (krand() % (48 << 8)), SCRAP6 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (sprite[i].zvel >> 2), i, 5); - sprite[j].pal = 8; - } + case CACTUS: + // case CACTUSBROKE: + switch (sprite[sn].picnum) + { + case RPG2: + if (!isRRRA()) break; + case RADIUSEXPLOSION: + case RPG: + case FIRELASER: + case HYDRENT: + case HEAVYHBOMB: + case TRIPBOMBSPRITE: + case COOLEXPLOSION1: + case OWHIP: + case UWHIP: + for (k = 0; k < 64; k++) + { + j = EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z - (krand() % (48 << 8)), SCRAP6 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (sprite[i].zvel >> 2), i, 5); + sprite[j].pal = 8; + } - if (sprite[i].picnum == CACTUS) - sprite[i].picnum = CACTUSBROKE; - sprite[i].cstat &= ~257; - // else deletesprite(i); - break; - } - break; + if (sprite[i].picnum == CACTUS) + sprite[i].picnum = CACTUSBROKE; + sprite[i].cstat &= ~257; + // else deletesprite(i); + break; + } + break; - case FANSPRITE: - sprite[i].picnum = FANSPRITEBROKE; - sprite[i].cstat &= (65535 - 257); - spritesound(GLASS_HEAVYBREAK, i); - s = &sprite[i]; - for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); + case FANSPRITE: + sprite[i].picnum = FANSPRITEBROKE; + sprite[i].cstat &= (65535 - 257); + spritesound(GLASS_HEAVYBREAK, i); + s = &sprite[i]; + for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); - break; - case WATERFOUNTAIN: - case WATERFOUNTAIN + 1: - case WATERFOUNTAIN + 2: - case WATERFOUNTAIN + 3: - spawn(i, TOILETWATER); - break; - case SATELITE: - case FUELPOD: - case SOLARPANNEL: - case ANTENNA: - if (sprite[sn].extra != G_DefaultActorHealth(SHOTSPARK1)) // TRANSITIONAL - fix after getting rid of EDUKE cruft - { - for (j = 0; j < 15; j++) - EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sector[sprite[i].sectnum].floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, - krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, i, 5); - spawn(i, EXPLOSION2); - deletesprite(i); - } - break; - case RRTILE1824: - if (!isRRRA()) break; - case BOTTLE1: - case BOTTLE2: - case BOTTLE3: - case BOTTLE4: - case BOTTLE5: - case BOTTLE6: - case BOTTLE8: - case BOTTLE10: - case BOTTLE11: - case BOTTLE12: - case BOTTLE13: - case BOTTLE14: - case BOTTLE15: - case BOTTLE16: - case BOTTLE17: - case BOTTLE18: - case BOTTLE19: - case DOMELITE: - case SUSHIPLATE1: - case SUSHIPLATE2: - case SUSHIPLATE3: - case SUSHIPLATE4: - case SUSHIPLATE5: - case WAITTOBESEATED: - case VASE: - case STATUEFLASH: - case STATUE: - if (sprite[i].picnum == BOTTLE10) - lotsofmoney(&sprite[i], 4 + (krand() & 3)); - else if (sprite[i].picnum == STATUE || sprite[i].picnum == STATUEFLASH) - { - lotsofcolourglass(i, -1, 40); - spritesound(GLASS_HEAVYBREAK, i); - } - else if (sprite[i].picnum == VASE) - lotsofglass(i, -1, 40); + break; + case WATERFOUNTAIN: + case WATERFOUNTAIN + 1: + case WATERFOUNTAIN + 2: + case WATERFOUNTAIN + 3: + spawn(i, TOILETWATER); + break; + case SATELITE: + case FUELPOD: + case SOLARPANNEL: + case ANTENNA: + if (sprite[sn].extra != G_DefaultActorHealth(SHOTSPARK1)) // TRANSITIONAL - fix after getting rid of EDUKE cruft + { + for (j = 0; j < 15; j++) + EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sector[sprite[i].sectnum].floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, + krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, i, 5); + spawn(i, EXPLOSION2); + deletesprite(i); + } + break; + case RRTILE1824: + if (!isRRRA()) break; + case BOTTLE1: + case BOTTLE2: + case BOTTLE3: + case BOTTLE4: + case BOTTLE5: + case BOTTLE6: + case BOTTLE8: + case BOTTLE10: + case BOTTLE11: + case BOTTLE12: + case BOTTLE13: + case BOTTLE14: + case BOTTLE15: + case BOTTLE16: + case BOTTLE17: + case BOTTLE18: + case BOTTLE19: + case DOMELITE: + case SUSHIPLATE1: + case SUSHIPLATE2: + case SUSHIPLATE3: + case SUSHIPLATE4: + case SUSHIPLATE5: + case WAITTOBESEATED: + case VASE: + case STATUEFLASH: + case STATUE: + if (sprite[i].picnum == BOTTLE10) + lotsofmoney(&sprite[i], 4 + (krand() & 3)); + else if (sprite[i].picnum == STATUE || sprite[i].picnum == STATUEFLASH) + { + lotsofcolourglass(i, -1, 40); + spritesound(GLASS_HEAVYBREAK, i); + } + else if (sprite[i].picnum == VASE) + lotsofglass(i, -1, 40); - spritesound(GLASS_BREAKING, i); - sprite[i].ang = krand() & 2047; - lotsofglass(i, -1, 8); - deletesprite(i); - break; - case RRTILE2654: - case RRTILE2656: - case RRTILE3172: - if (!isRRRA()) break; - case BOTTLE7: - spritesound(GLASS_BREAKING, i); - lotsofglass(i, -1, 10); - deletesprite(i); - break; - case FORCESPHERE: - sprite[i].xrepeat = 0; - hittype[sprite[i].owner].temp_data[0] = 32; - hittype[sprite[i].owner].temp_data[1] = !hittype[sprite[i].owner].temp_data[1]; - hittype[sprite[i].owner].temp_data[2] ++; - spawn(i, EXPLOSION2); - break; - case TOILET: - sprite[i].picnum = TOILETBROKE; - sprite[i].cstat |= (krand() & 1) << 2; - sprite[i].cstat &= ~257; - spawn(i, TOILETWATER); - spritesound(GLASS_BREAKING, i); - break; + spritesound(GLASS_BREAKING, i); + sprite[i].ang = krand() & 2047; + lotsofglass(i, -1, 8); + deletesprite(i); + break; + case RRTILE2654: + case RRTILE2656: + case RRTILE3172: + if (!isRRRA()) break; + case BOTTLE7: + spritesound(GLASS_BREAKING, i); + lotsofglass(i, -1, 10); + deletesprite(i); + break; + case FORCESPHERE: + sprite[i].xrepeat = 0; + hittype[sprite[i].owner].temp_data[0] = 32; + hittype[sprite[i].owner].temp_data[1] = !hittype[sprite[i].owner].temp_data[1]; + hittype[sprite[i].owner].temp_data[2] ++; + spawn(i, EXPLOSION2); + break; + case TOILET: + sprite[i].picnum = TOILETBROKE; + sprite[i].cstat |= (krand() & 1) << 2; + sprite[i].cstat &= ~257; + spawn(i, TOILETWATER); + spritesound(GLASS_BREAKING, i); + break; - case STALL: - sprite[i].picnum = STALLBROKE; - sprite[i].cstat |= (krand() & 1) << 2; - sprite[i].cstat &= ~257; - spawn(i, TOILETWATER); - spritesound(GLASS_HEAVYBREAK, i); - break; + case STALL: + sprite[i].picnum = STALLBROKE; + sprite[i].cstat |= (krand() & 1) << 2; + sprite[i].cstat &= ~257; + spawn(i, TOILETWATER); + spritesound(GLASS_HEAVYBREAK, i); + break; - case HYDRENT: - sprite[i].picnum = BROKEFIREHYDRENT; - spawn(i, TOILETWATER); + case HYDRENT: + sprite[i].picnum = BROKEFIREHYDRENT; + spawn(i, TOILETWATER); - // for(k=0;k<5;k++) - // { - // j = EGS(sprite[i].sectnum,sprite[i].x,sprite[i].y,sprite[i].z-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5); - // sprite[j].pal = 2; - // } - spritesound(GLASS_HEAVYBREAK, i); - break; + // for(k=0;k<5;k++) + // { + // j = EGS(sprite[i].sectnum,sprite[i].x,sprite[i].y,sprite[i].z-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5); + // sprite[j].pal = 2; + // } + spritesound(GLASS_HEAVYBREAK, i); + break; - case GRATE1: - sprite[i].picnum = BGRATE1; - sprite[i].cstat &= (65535 - 256 - 1); - spritesound(VENT_BUST, i); - break; + case GRATE1: + sprite[i].picnum = BGRATE1; + sprite[i].cstat &= (65535 - 256 - 1); + spritesound(VENT_BUST, i); + break; - case CIRCLEPANNEL: - sprite[i].picnum = CIRCLEPANNELBROKE; - sprite[i].cstat &= (65535 - 256 - 1); - spritesound(VENT_BUST, i); - break; + case CIRCLEPANNEL: + sprite[i].picnum = CIRCLEPANNELBROKE; + sprite[i].cstat &= (65535 - 256 - 1); + spritesound(VENT_BUST, i); + break; - case PIPE1: - case PIPE2: - case PIPE3: - case PIPE4: - case PIPE5: - case PIPE6: - switch (sprite[i].picnum) - { - case PIPE1:sprite[i].picnum = PIPE1B; break; - case PIPE2:sprite[i].picnum = PIPE2B; break; - case PIPE3:sprite[i].picnum = PIPE3B; break; - case PIPE4:sprite[i].picnum = PIPE4B; break; - case PIPE5:sprite[i].picnum = PIPE5B; break; - case PIPE6:sprite[i].picnum = PIPE6B; break; - } + case PIPE1: + case PIPE2: + case PIPE3: + case PIPE4: + case PIPE5: + case PIPE6: + switch (sprite[i].picnum) + { + case PIPE1:sprite[i].picnum = PIPE1B; break; + case PIPE2:sprite[i].picnum = PIPE2B; break; + case PIPE3:sprite[i].picnum = PIPE3B; break; + case PIPE4:sprite[i].picnum = PIPE4B; break; + case PIPE5:sprite[i].picnum = PIPE5B; break; + case PIPE6:sprite[i].picnum = PIPE6B; break; + } - j = spawn(i, STEAM); - sprite[j].z = sector[sprite[i].sectnum].floorz - (32 << 8); - break; + j = spawn(i, STEAM); + sprite[j].z = sector[sprite[i].sectnum].floorz - (32 << 8); + break; - case CHAIR1: - case CHAIR2: - sprite[i].picnum = BROKENCHAIR; - sprite[i].cstat = 0; - break; - case CHAIR3: - case MOVIECAMERA: - case SCALE: - case VACUUM: - case CAMERALIGHT: - case IVUNIT: - case POT1: - case POT2: - case POT3: - spritesound(GLASS_HEAVYBREAK, i); - s = &sprite[i]; - for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); - deletesprite(i); - break; - case PLAYERONWATER: - i = sprite[i].owner; - default: - if ((sprite[i].cstat & 16) && sprite[i].hitag == 0 && sprite[i].lotag == 0 && sprite[i].statnum == 0) - break; + case CHAIR1: + case CHAIR2: + sprite[i].picnum = BROKENCHAIR; + sprite[i].cstat = 0; + break; + case CHAIR3: + case MOVIECAMERA: + case SCALE: + case VACUUM: + case CAMERALIGHT: + case IVUNIT: + case POT1: + case POT2: + case POT3: + spritesound(GLASS_HEAVYBREAK, i); + s = &sprite[i]; + for (j = 0; j < 16; j++) RANDOMSCRAP(s, i); + deletesprite(i); + break; + case PLAYERONWATER: + i = sprite[i].owner; + default: + if ((sprite[i].cstat & 16) && sprite[i].hitag == 0 && sprite[i].lotag == 0 && sprite[i].statnum == 0) + break; - if ((sprite[sn].picnum == SHRINKSPARK || sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i) && sprite[i].statnum != 4) - { - if (badguy(&sprite[i]) == 1) - { - if (sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; - else if (isRRRA() && sprite[sn].picnum == RPG2) sprite[sn].extra <<= 1; + if ((sprite[sn].picnum == SHRINKSPARK || sprite[sn].picnum == FREEZEBLAST || sprite[sn].owner != i) && sprite[i].statnum != 4) + { + if (badguy(&sprite[i]) == 1) + { + if (sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; + else if (isRRRA() && sprite[sn].picnum == RPG2) sprite[sn].extra <<= 1; - if ((sprite[i].picnum != DRONE)) - if (sprite[sn].picnum != FREEZEBLAST) - //if (actortype[sprite[i].picnum] == 0) //TRANSITIONAL. Cannot be done right with EDuke mess backing the engine. - { - j = spawn(sn, JIBS6); - if (sprite[sn].pal == 6) - sprite[j].pal = 6; - sprite[j].z += (4 << 8); - sprite[j].xvel = 16; - sprite[j].xrepeat = sprite[j].yrepeat = 24; - sprite[j].ang += 32 - (krand() & 63); - } + if ((sprite[i].picnum != DRONE)) + if (sprite[sn].picnum != FREEZEBLAST) + //if (actortype[sprite[i].picnum] == 0) //TRANSITIONAL. Cannot be done right with EDuke mess backing the engine. + { + j = spawn(sn, JIBS6); + if (sprite[sn].pal == 6) + sprite[j].pal = 6; + sprite[j].z += (4 << 8); + sprite[j].xvel = 16; + sprite[j].xrepeat = sprite[j].yrepeat = 24; + sprite[j].ang += 32 - (krand() & 63); + } - j = sprite[sn].owner; + j = sprite[sn].owner; - if (j >= 0 && sprite[j].picnum == APLAYER && sprite[i].picnum != DRONE) - if (ps[sprite[j].yvel].curr_weapon == SHOTGUN_WEAPON) - { - shoot(i, BLOODSPLAT3); - shoot(i, BLOODSPLAT1); - shoot(i, BLOODSPLAT2); - shoot(i, BLOODSPLAT4); - } + if (j >= 0 && sprite[j].picnum == APLAYER && sprite[i].picnum != DRONE) + if (ps[sprite[j].yvel].curr_weapon == SHOTGUN_WEAPON) + { + shoot(i, BLOODSPLAT3); + shoot(i, BLOODSPLAT1); + shoot(i, BLOODSPLAT2); + shoot(i, BLOODSPLAT4); + } - if (sprite[i].statnum == 2) - { - changespritestat(i, 1); - hittype[i].timetosleep = SLEEPTIME; - } - } + if (sprite[i].statnum == 2) + { + changespritestat(i, 1); + hittype[i].timetosleep = SLEEPTIME; + } + } - if (sprite[i].statnum != 2) - { - if (sprite[sn].picnum == FREEZEBLAST && ((sprite[i].picnum == APLAYER && sprite[i].pal == 1) || (freezerhurtowner == 0 && sprite[sn].owner == i))) - return; + if (sprite[i].statnum != 2) + { + if (sprite[sn].picnum == FREEZEBLAST && ((sprite[i].picnum == APLAYER && sprite[i].pal == 1) || (freezerhurtowner == 0 && sprite[sn].owner == i))) + return; - hittype[i].picnum = sprite[sn].picnum; - hittype[i].extra += sprite[sn].extra; - if (sprite[i].picnum != COW) - hittype[i].ang = sprite[sn].ang; - hittype[i].owner = sprite[sn].owner; - } + hittype[i].picnum = sprite[sn].picnum; + hittype[i].extra += sprite[sn].extra; + if (sprite[i].picnum != COW) + hittype[i].ang = sprite[sn].ang; + hittype[i].owner = sprite[sn].owner; + } - if (sprite[i].statnum == 10) - { - p = sprite[i].yvel; - if (ps[p].newowner >= 0) - { - ps[p].newowner = -1; - ps[p].posx = ps[p].oposx; - ps[p].posy = ps[p].oposy; - ps[p].posz = ps[p].oposz; - ps[p].q16ang = ps[p].oq16ang; + if (sprite[i].statnum == 10) + { + p = sprite[i].yvel; + if (ps[p].newowner >= 0) + { + ps[p].newowner = -1; + ps[p].posx = ps[p].oposx; + ps[p].posy = ps[p].oposy; + ps[p].posz = ps[p].oposz; + ps[p].q16ang = ps[p].oq16ang; - updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); - setpal(&ps[p]); + updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); + setpal(&ps[p]); - j = headspritestat[1]; - while (j >= 0) - { - if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0; - j = nextspritestat[j]; - } - } + j = headspritestat[1]; + while (j >= 0) + { + if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0; + j = nextspritestat[j]; + } + } - if (sprite[hittype[i].owner].picnum != APLAYER) - if (ud.player_skill >= 3) - sprite[sn].extra += (sprite[sn].extra >> 1); - } + if (sprite[hittype[i].owner].picnum != APLAYER) + if (ud.player_skill >= 3) + sprite[sn].extra += (sprite[sn].extra >> 1); + } - } - break; - } + } + break; + } } //--------------------------------------------------------------------------- @@ -2393,358 +2393,358 @@ void checkhitsprite_r(int i, int sn) void checksectors_r(int snum) { - int i = -1, oldz; - struct player_struct* p; - int hitscanwall; - short neartagsector, neartagwall, neartagsprite; - int neartaghitdist; + int i = -1, oldz; + struct player_struct* p; + int hitscanwall; + short neartagsector, neartagwall, neartagsprite; + int neartaghitdist; - p = &ps[snum]; + p = &ps[snum]; - switch (sector[p->cursectnum].lotag) - { + switch (sector[p->cursectnum].lotag) + { - case 32767: - sector[p->cursectnum].lotag = 0; - FTA(9, p); - p->secret_rooms++; - return; - case -1: - for (i = connecthead; i >= 0; i = connectpoint2[i]) - ps[i].gm = MODE_EOL; - sector[p->cursectnum].lotag = 0; - if (!isRRRA() || !RRRA_ExitedLevel) - { - if (ud.from_bonus) - { - ud.level_number = ud.from_bonus; - ud.m_level_number = ud.level_number; - ud.from_bonus = 0; - } - else - { - if (isRRRA() && ud.level_number == 6 && ud.volume_number == 0) - RRRA_EndEpisode = 1; - ud.level_number++; - if (ud.level_number > 6) - ud.level_number = 0; - ud.m_level_number = ud.level_number; - } - RRRA_ExitedLevel = 1; - } - return; - case -2: - sector[p->cursectnum].lotag = 0; - p->timebeforeexit = 26 * 8; - p->customexitsound = sector[p->cursectnum].hitag; - return; - default: - if (sector[p->cursectnum].lotag >= 10000) - { - if (snum == screenpeek || ud.coop == 1) - spritesound(sector[p->cursectnum].lotag - 10000, p->i); - sector[p->cursectnum].lotag = 0; - } - break; + case 32767: + sector[p->cursectnum].lotag = 0; + FTA(9, p); + p->secret_rooms++; + return; + case -1: + for (i = connecthead; i >= 0; i = connectpoint2[i]) + ps[i].gm = MODE_EOL; + sector[p->cursectnum].lotag = 0; + if (!isRRRA() || !RRRA_ExitedLevel) + { + if (ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + if (isRRRA() && ud.level_number == 6 && ud.volume_number == 0) + RRRA_EndEpisode = 1; + ud.level_number++; + if (ud.level_number > 6) + ud.level_number = 0; + ud.m_level_number = ud.level_number; + } + RRRA_ExitedLevel = 1; + } + return; + case -2: + sector[p->cursectnum].lotag = 0; + p->timebeforeexit = 26 * 8; + p->customexitsound = sector[p->cursectnum].hitag; + return; + default: + if (sector[p->cursectnum].lotag >= 10000) + { + if (snum == screenpeek || ud.coop == 1) + spritesound(sector[p->cursectnum].lotag - 10000, p->i); + sector[p->cursectnum].lotag = 0; + } + break; - } + } - //After this point the the player effects the map with space + //After this point the the player effects the map with space - if (p->gm & MODE_TYPE || sprite[p->i].extra <= 0) return; + if (p->gm & MODE_TYPE || sprite[p->i].extra <= 0) return; - if (ud.cashman && PlayerInput(snum, SK_OPEN)) - lotsofmoney(&sprite[p->i], 2); + if (ud.cashman && PlayerInput(snum, SK_OPEN)) + lotsofmoney(&sprite[p->i], 2); - if (!(PlayerInput(snum, SK_OPEN)) && !PlayerInput(snum, SK_ESCAPE)) - p->toggle_key_flag = 0; + if (!(PlayerInput(snum, SK_OPEN)) && !PlayerInput(snum, SK_ESCAPE)) + p->toggle_key_flag = 0; - else if (!p->toggle_key_flag) - { - neartagsprite = -1; - p->toggle_key_flag = 1; - hitscanwall = -1; + else if (!p->toggle_key_flag) + { + neartagsprite = -1; + p->toggle_key_flag = 1; + hitscanwall = -1; - hitawall(p, &hitscanwall); + hitawall(p, &hitscanwall); - if (isRRRA()) - { - if (hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR && snum == screenpeek) - if (numplayers == 1) - { - if (A_CheckSoundPlaying(p->i, 27) == 0 && A_CheckSoundPlaying(p->i, 28) == 0 && A_CheckSoundPlaying(p->i, 29) == 0 - && A_CheckSoundPlaying(p->i, 257) == 0 && A_CheckSoundPlaying(p->i, 258) == 0) - { - short snd = krand() % 5; - if (snd == 0) - spritesound(27, p->i); - else if (snd == 1) - spritesound(28, p->i); - else if (snd == 2) - spritesound(29, p->i); - else if (snd == 3) - spritesound(257, p->i); - else if (snd == 4) - spritesound(258, p->i); - } - return; - } - } - else - { - if (hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR) - if (wall[hitscanwall].lotag > 0 && A_CheckSoundPlaying(p->i, wall[hitscanwall].lotag) == 0 && snum == screenpeek) - { - spritesound(wall[hitscanwall].lotag, p->i); - return; - } - } + if (isRRRA()) + { + if (hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR && snum == screenpeek) + if (numplayers == 1) + { + if (A_CheckSoundPlaying(p->i, 27) == 0 && A_CheckSoundPlaying(p->i, 28) == 0 && A_CheckSoundPlaying(p->i, 29) == 0 + && A_CheckSoundPlaying(p->i, 257) == 0 && A_CheckSoundPlaying(p->i, 258) == 0) + { + short snd = krand() % 5; + if (snd == 0) + spritesound(27, p->i); + else if (snd == 1) + spritesound(28, p->i); + else if (snd == 2) + spritesound(29, p->i); + else if (snd == 3) + spritesound(257, p->i); + else if (snd == 4) + spritesound(258, p->i); + } + return; + } + } + else + { + if (hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR) + if (wall[hitscanwall].lotag > 0 && A_CheckSoundPlaying(p->i, wall[hitscanwall].lotag) == 0 && snum == screenpeek) + { + spritesound(wall[hitscanwall].lotag, p->i); + return; + } + } - if (hitscanwall >= 0 && (wall[hitscanwall].cstat & 16)) - if (wall[hitscanwall].lotag) - return; + if (hitscanwall >= 0 && (wall[hitscanwall].cstat & 16)) + if (wall[hitscanwall].lotag) + return; - if (isRRRA()) - { - if (p->OnMotorcycle) - { - if (p->MotoSpeed < 20) - { - OffMotorcycle(p); - return; - } - return; - } - if (p->OnBoat) - { - if (p->MotoSpeed < 20) - { - OffBoat(p); - return; - } - return; - } - neartag(p->posx, p->posy, p->posz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); - } + if (isRRRA()) + { + if (p->OnMotorcycle) + { + if (p->MotoSpeed < 20) + { + OffMotorcycle(p); + return; + } + return; + } + if (p->OnBoat) + { + if (p->MotoSpeed < 20) + { + OffBoat(p); + return; + } + return; + } + neartag(p->posx, p->posy, p->posz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); + } - if (p->newowner >= 0) - neartag(p->oposx, p->oposy, p->oposz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); - else - { - neartag(p->posx, p->posy, p->posz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); - if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - neartag(p->posx, p->posy, p->posz + (8 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); - if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - neartag(p->posx, p->posy, p->posz + (16 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); - if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - { - neartag(p->posx, p->posy, p->posz + (16 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); - if (neartagsprite >= 0) - { - switch (sprite[neartagsprite].picnum) - { - case FEM10: - case NAKED1: - case STATUE: - case TOUGHGAL: - return; - case COW: - g_spriteExtra[neartagsprite] = 1; // TRANSITIONAL move to sprite or actor - return; - } - } + if (p->newowner >= 0) + neartag(p->oposx, p->oposy, p->oposz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + else + { + neartag(p->posx, p->posy, p->posz, sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + neartag(p->posx, p->posy, p->posz + (8 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + neartag(p->posx, p->posy, p->posz + (16 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 1); + if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + { + neartag(p->posx, p->posy, p->posz + (16 << 8), sprite[p->i].sectnum, p->getoang(), &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1280L, 3); + if (neartagsprite >= 0) + { + switch (sprite[neartagsprite].picnum) + { + case FEM10: + case NAKED1: + case STATUE: + case TOUGHGAL: + return; + case COW: + g_spriteExtra[neartagsprite] = 1; // TRANSITIONAL move to sprite or actor + return; + } + } - neartagsprite = -1; - neartagwall = -1; - neartagsector = -1; - } - } + neartagsprite = -1; + neartagwall = -1; + neartagsector = -1; + } + } - if (p->newowner == -1 && neartagsprite == -1 && neartagsector == -1 && neartagwall == -1) - if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) - neartagsector = sprite[p->i].sectnum; + if (p->newowner == -1 && neartagsprite == -1 && neartagsector == -1 && neartagwall == -1) + if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) + neartagsector = sprite[p->i].sectnum; - if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384)) - return; + if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384)) + return; - if (neartagsprite == -1 && neartagwall == -1) - if (sector[p->cursectnum].lotag == 2) - { - oldz = hitasprite(p->i, &neartagsprite); - if (oldz > 1280) neartagsprite = -1; - } + if (neartagsprite == -1 && neartagwall == -1) + if (sector[p->cursectnum].lotag == 2) + { + oldz = hitasprite(p->i, &neartagsprite); + if (oldz > 1280) neartagsprite = -1; + } - if (neartagsprite >= 0) - { - if (checkhitswitch(snum, neartagsprite, 1)) return; + if (neartagsprite >= 0) + { + if (checkhitswitch(snum, neartagsprite, 1)) return; - switch (sprite[neartagsprite].picnum) - { - case RRTILE8448: - if (!isRRRA()) return; - if (!A_CheckSoundPlaying(neartagsprite, 340)) - A_PlaySound(340, neartagsprite); - return; - case RRTILE8704: - if (!isRRRA()) return; - if (numplayers == 1) - { - static bool alreadydone; // what is this supposed to do? Looks broken. - // This is from RedneckGDX - the version in RR Reconstruction looked like broken nonsense. - if (S_CheckSoundPlaying(neartagsprite, 445) || alreadydone != 0) - { - if (!S_CheckSoundPlaying(neartagsprite, 445) && !S_CheckSoundPlaying(neartagsprite, 446) && !S_CheckSoundPlaying(neartagsprite, 447) && alreadydone != 0) - { - if ((krand() % 2) == 1) - spritesound(446, neartagsprite); - else - spritesound(447, neartagsprite); - } - } - else - { - spritesound(445, neartagsprite); - alreadydone = 1; - } - } - return; - case EMPTYBIKE: - if (!isRRRA()) return; - OnMotorcycle(p, neartagsprite); - return; - case EMPTYBOAT: - if (!isRRRA()) return; - OnBoat(p, neartagsprite); - return; - case RRTILE8164: - case RRTILE8165: - case RRTILE8166: - case RRTILE8167: - case RRTILE8168: - case RRTILE8591: - case RRTILE8592: - case RRTILE8593: - case RRTILE8594: - case RRTILE8595: - if (!isRRRA()) return; - sprite[neartagsprite].extra = 60; - spritesound(235, neartagsprite); - return; + switch (sprite[neartagsprite].picnum) + { + case RRTILE8448: + if (!isRRRA()) return; + if (!A_CheckSoundPlaying(neartagsprite, 340)) + A_PlaySound(340, neartagsprite); + return; + case RRTILE8704: + if (!isRRRA()) return; + if (numplayers == 1) + { + static bool alreadydone; // what is this supposed to do? Looks broken. + // This is from RedneckGDX - the version in RR Reconstruction looked like broken nonsense. + if (S_CheckSoundPlaying(neartagsprite, 445) || alreadydone != 0) + { + if (!S_CheckSoundPlaying(neartagsprite, 445) && !S_CheckSoundPlaying(neartagsprite, 446) && !S_CheckSoundPlaying(neartagsprite, 447) && alreadydone != 0) + { + if ((krand() % 2) == 1) + spritesound(446, neartagsprite); + else + spritesound(447, neartagsprite); + } + } + else + { + spritesound(445, neartagsprite); + alreadydone = 1; + } + } + return; + case EMPTYBIKE: + if (!isRRRA()) return; + OnMotorcycle(p, neartagsprite); + return; + case EMPTYBOAT: + if (!isRRRA()) return; + OnBoat(p, neartagsprite); + return; + case RRTILE8164: + case RRTILE8165: + case RRTILE8166: + case RRTILE8167: + case RRTILE8168: + case RRTILE8591: + case RRTILE8592: + case RRTILE8593: + case RRTILE8594: + case RRTILE8595: + if (!isRRRA()) return; + sprite[neartagsprite].extra = 60; + spritesound(235, neartagsprite); + return; - case TOILET: - case STALL: - case RRTILE2121: - case RRTILE2122: - if (p->last_pissed_time == 0) - { - if (ud.lockout == 0) spritesound(435, p->i); + case TOILET: + case STALL: + case RRTILE2121: + case RRTILE2122: + if (p->last_pissed_time == 0) + { + if (ud.lockout == 0) spritesound(435, p->i); - p->last_pissed_time = 26 * 220; - p->transporter_hold = 29 * 2; - if (p->holster_weapon == 0) - { - p->holster_weapon = 1; - p->weapon_pos = -1; - } - if (sprite[p->i].extra <= (p->max_player_health - (p->max_player_health / 10))) - { - sprite[p->i].extra += p->max_player_health / 10; - p->last_extra = sprite[p->i].extra; - } - else if (sprite[p->i].extra < p->max_player_health) - sprite[p->i].extra = p->max_player_health; - } - else if (A_CheckSoundPlaying(p->i, DUKE_GRUNT) == 0) - spritesound(DUKE_GRUNT, p->i); - return; - case WATERFOUNTAIN: - if (hittype[neartagsprite].temp_data[0] != 1) - { - hittype[neartagsprite].temp_data[0] = 1; - sprite[neartagsprite].owner = p->i; + p->last_pissed_time = 26 * 220; + p->transporter_hold = 29 * 2; + if (p->holster_weapon == 0) + { + p->holster_weapon = 1; + p->weapon_pos = -1; + } + if (sprite[p->i].extra <= (p->max_player_health - (p->max_player_health / 10))) + { + sprite[p->i].extra += p->max_player_health / 10; + p->last_extra = sprite[p->i].extra; + } + else if (sprite[p->i].extra < p->max_player_health) + sprite[p->i].extra = p->max_player_health; + } + else if (A_CheckSoundPlaying(p->i, DUKE_GRUNT) == 0) + spritesound(DUKE_GRUNT, p->i); + return; + case WATERFOUNTAIN: + if (hittype[neartagsprite].temp_data[0] != 1) + { + hittype[neartagsprite].temp_data[0] = 1; + sprite[neartagsprite].owner = p->i; - if (sprite[p->i].extra < p->max_player_health) - { - sprite[p->i].extra++; - spritesound(DUKE_DRINKING, p->i); - } - } - return; - case PLUG: - spritesound(SHORT_CIRCUIT, p->i); - sprite[p->i].extra -= 2 + (krand() & 3); - SetPlayerPal(p, PalEntry(32, 48, 48, 64)); - break; - } - } + if (sprite[p->i].extra < p->max_player_health) + { + sprite[p->i].extra++; + spritesound(DUKE_DRINKING, p->i); + } + } + return; + case PLUG: + spritesound(SHORT_CIRCUIT, p->i); + sprite[p->i].extra -= 2 + (krand() & 3); + SetPlayerPal(p, PalEntry(32, 48, 48, 64)); + break; + } + } - if (!PlayerInput(snum, SK_OPEN)) return; + if (!PlayerInput(snum, SK_OPEN)) return; - if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) - if (abs(hits(p->i)) < 512) - { - if ((krand() & 255) < 16) - spritesound(DUKE_SEARCH2, p->i); - else spritesound(DUKE_SEARCH, p->i); - return; - } + if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) + if (abs(hits(p->i)) < 512) + { + if ((krand() & 255) < 16) + spritesound(DUKE_SEARCH2, p->i); + else spritesound(DUKE_SEARCH, p->i); + return; + } - if (neartagwall >= 0) - { - if (wall[neartagwall].lotag > 0 && isadoorwall(wall[neartagwall].picnum)) - { - if (hitscanwall == neartagwall || hitscanwall == -1) - checkhitswitch(snum, neartagwall, 0); - return; - } - } + if (neartagwall >= 0) + { + if (wall[neartagwall].lotag > 0 && isadoorwall(wall[neartagwall].picnum)) + { + if (hitscanwall == neartagwall || hitscanwall == -1) + checkhitswitch(snum, neartagwall, 0); + return; + } + } - if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384) == 0 && isanearoperator(sector[neartagsector].lotag)) - { - short unk = 0; - i = headspritesect[neartagsector]; - while (i >= 0) - { - if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) - return; - i = nextspritesect[i]; - } - if (haskey(neartagsector, snum)) - operatesectors(neartagsector, p->i); - else - { - if (g_spriteExtra[neartagsprite] > 3) // TRANSITIONAL move to sprite or actor - spritesound(99, p->i); - else - spritesound(419, p->i); - FTA(41, p); - } - } - else if ((sector[sprite[p->i].sectnum].lotag & 16384) == 0) - { - if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) - { - i = headspritesect[sprite[p->i].sectnum]; - while (i >= 0) - { - if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return; - i = nextspritesect[i]; - } - if (haskey(neartagsector, snum)) - operatesectors(sprite[p->i].sectnum, p->i); - else - { - if (g_spriteExtra[neartagsprite] > 3) // TRANSITIONAL move to sprite or actor - spritesound(99, p->i); - else - spritesound(419, p->i); - FTA(41, p); - } - } - else checkhitswitch(snum, neartagwall, 0); - } - } + if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384) == 0 && isanearoperator(sector[neartagsector].lotag)) + { + short unk = 0; + i = headspritesect[neartagsector]; + while (i >= 0) + { + if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) + return; + i = nextspritesect[i]; + } + if (haskey(neartagsector, snum)) + operatesectors(neartagsector, p->i); + else + { + if (g_spriteExtra[neartagsprite] > 3) // TRANSITIONAL move to sprite or actor + spritesound(99, p->i); + else + spritesound(419, p->i); + FTA(41, p); + } + } + else if ((sector[sprite[p->i].sectnum].lotag & 16384) == 0) + { + if (isanunderoperator(sector[sprite[p->i].sectnum].lotag)) + { + i = headspritesect[sprite[p->i].sectnum]; + while (i >= 0) + { + if (sprite[i].picnum == ACTIVATOR || sprite[i].picnum == MASTERSWITCH) return; + i = nextspritesect[i]; + } + if (haskey(neartagsector, snum)) + operatesectors(sprite[p->i].sectnum, p->i); + else + { + if (g_spriteExtra[neartagsprite] > 3) // TRANSITIONAL move to sprite or actor + spritesound(99, p->i); + else + spritesound(419, p->i); + FTA(41, p); + } + } + else checkhitswitch(snum, neartagwall, 0); + } + } } //--------------------------------------------------------------------------- @@ -2755,114 +2755,114 @@ void checksectors_r(int snum) void dofurniture(int wl, int sect, int snum) { - int startwall; - int endwall; - int i; - int var_C; - int x; - int y; - int min_x; - int min_y; - int max_x; - int max_y; - int ins; - int var_cx; + int startwall; + int endwall; + int i; + int var_C; + int x; + int y; + int min_x; + int min_y; + int max_x; + int max_y; + int ins; + int var_cx; - startwall = sector[wall[wl].nextsector].wallptr;; - endwall = startwall + sector[wall[wl].nextsector].wallnum; - var_C = 1; - max_x = max_y = -0x20000; - min_x = min_y = 0x20000; - var_cx = sector[sect].hitag; - if (var_cx > 16) - var_cx = 16; - else if (var_cx == 0) - var_cx = 4; - for (i = startwall; i < endwall; i++) - { - x = wall[i].x; - y = wall[i].y; - if (x > max_x) - max_x = x; - if (y > max_y) - max_y = y; - if (x < min_x) - min_x = x; - if (y < min_y) - min_y = y; - } - max_x += var_cx + 1; - max_y += var_cx + 1; - min_x -= var_cx + 1; - min_y -= var_cx + 1; - ins = inside(max_x, max_y, sect); - if (!ins) - var_C = 0; - ins = inside(max_x, min_y, sect); - if (!ins) - var_C = 0; - ins = inside(min_x, min_y, sect); - if (!ins) - var_C = 0; - ins = inside(min_x, max_y, sect); - if (!ins) - var_C = 0; - if (var_C) - { - if (A_CheckSoundPlaying(ps[snum].i, 389) == 0) - spritesound(389, ps[snum].i); - for (i = startwall; i < endwall; i++) - { - x = wall[i].x; - y = wall[i].y; - switch (wall[wl].lotag) - { - case 42: - y = wall[i].y + var_cx; - dragpoint(i, x, y); - break; - case 41: - x = wall[i].x - var_cx; - dragpoint(i, x, y); - break; - case 40: - y = wall[i].y - var_cx; - dragpoint(i, x, y); - break; - case 43: - x = wall[i].x + var_cx; - dragpoint(i, x, y); - break; - } - } - } - else - { - for (i = startwall; i < endwall; i++) - { - x = wall[i].x; - y = wall[i].y; - switch (wall[wl].lotag) - { - case 42: - y = wall[i].y - (var_cx - 2); - dragpoint(i, x, y); - break; - case 41: - x = wall[i].x + (var_cx - 2); - dragpoint(i, x, y); - break; - case 40: - y = wall[i].y + (var_cx - 2); - dragpoint(i, x, y); - break; - case 43: - x = wall[i].x - (var_cx - 2); - dragpoint(i, x, y); - break; - } - } - } + startwall = sector[wall[wl].nextsector].wallptr;; + endwall = startwall + sector[wall[wl].nextsector].wallnum; + var_C = 1; + max_x = max_y = -0x20000; + min_x = min_y = 0x20000; + var_cx = sector[sect].hitag; + if (var_cx > 16) + var_cx = 16; + else if (var_cx == 0) + var_cx = 4; + for (i = startwall; i < endwall; i++) + { + x = wall[i].x; + y = wall[i].y; + if (x > max_x) + max_x = x; + if (y > max_y) + max_y = y; + if (x < min_x) + min_x = x; + if (y < min_y) + min_y = y; + } + max_x += var_cx + 1; + max_y += var_cx + 1; + min_x -= var_cx + 1; + min_y -= var_cx + 1; + ins = inside(max_x, max_y, sect); + if (!ins) + var_C = 0; + ins = inside(max_x, min_y, sect); + if (!ins) + var_C = 0; + ins = inside(min_x, min_y, sect); + if (!ins) + var_C = 0; + ins = inside(min_x, max_y, sect); + if (!ins) + var_C = 0; + if (var_C) + { + if (A_CheckSoundPlaying(ps[snum].i, 389) == 0) + spritesound(389, ps[snum].i); + for (i = startwall; i < endwall; i++) + { + x = wall[i].x; + y = wall[i].y; + switch (wall[wl].lotag) + { + case 42: + y = wall[i].y + var_cx; + dragpoint(i, x, y); + break; + case 41: + x = wall[i].x - var_cx; + dragpoint(i, x, y); + break; + case 40: + y = wall[i].y - var_cx; + dragpoint(i, x, y); + break; + case 43: + x = wall[i].x + var_cx; + dragpoint(i, x, y); + break; + } + } + } + else + { + for (i = startwall; i < endwall; i++) + { + x = wall[i].x; + y = wall[i].y; + switch (wall[wl].lotag) + { + case 42: + y = wall[i].y - (var_cx - 2); + dragpoint(i, x, y); + break; + case 41: + x = wall[i].x + (var_cx - 2); + dragpoint(i, x, y); + break; + case 40: + y = wall[i].y + (var_cx - 2); + dragpoint(i, x, y); + break; + case 43: + x = wall[i].x - (var_cx - 2); + dragpoint(i, x, y); + break; + } + } + } } END_DUKE_NS diff --git a/source/games/duke/src/zz_gamedef.cpp b/source/games/duke/src/zz_gamedef.cpp index 4646d3d8d..7d59b162a 100644 --- a/source/games/duke/src/zz_gamedef.cpp +++ b/source/games/duke/src/zz_gamedef.cpp @@ -22,7 +22,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! -#include "duke3d.h" +#include "concmd.h" + +#include "duke3d_ed.h" #include "namesdyn.h" #include "gamedef.h" #include "gameexec.h" @@ -41,13 +43,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS -#define LINE_NUMBER (g_lineNumber << 12) + +void SortCommands(); +int getkeyword(const char* text); +void skiptoendofline(); +void skipwhitespace(); +void skipblockcomment(); +bool skipcomments(); + + +#define LINE_NUMBER (line_count << 12) int32_t g_scriptVersion = 14; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files char g_scriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling -int32_t g_totalLines, g_lineNumber; +int32_t g_totalLines; uint32_t g_scriptcrc; char g_szBuf[1024]; @@ -66,7 +77,7 @@ static int32_t C_SetScriptSize(int32_t size); static intptr_t apScriptGameEventEnd[MAXEVENTS]; static intptr_t g_parsingActorPtr; static intptr_t g_scriptEventOffset; -static char *textptr; +extern char *textptr; int32_t g_errorCnt,g_warningCnt; @@ -96,185 +107,13 @@ static char *C_GetLabelType(int32_t type) return Xstrdup(x); } -static tokenmap_t const vm_keywords[] = -{ - { "action", CON_ACTION }, - { "actor", CON_ACTOR }, - { "addammo", CON_ADDAMMO }, - { "addinventory", CON_ADDINVENTORY }, - { "addkills", CON_ADDKILLS }, - { "addlog", CON_ADDLOGVAR }, - { "addlogvar", CON_ADDLOGVAR }, - { "addphealth", CON_ADDPHEALTH }, - { "addstrength", CON_ADDSTRENGTH }, - { "addvar", CON_ADDVAR }, - { "addvarvar", CON_ADDVARVAR }, - { "addweapon", CON_ADDWEAPON }, - { "ai", CON_AI }, - { "betaname", CON_BETANAME }, - { "break", CON_BREAK }, - { "cactor", CON_CACTOR }, - { "clipdist", CON_CLIPDIST }, - { "count", CON_COUNT }, - { "cstat", CON_CSTAT }, - { "cstator", CON_CSTATOR }, - { "debris", CON_DEBRIS }, - { "debug", CON_DEBUG }, - { "define", CON_DEFINE }, - { "definelevelname", CON_DEFINELEVELNAME }, - { "definequote", CON_DEFINEQUOTE }, - { "defineskillname", CON_DEFINESKILLNAME }, - { "definesound", CON_DEFINESOUND }, - { "definevolumename", CON_DEFINEVOLUMENAME }, - { "deploybias", CON_DEPLOYBIAS }, - { "destroyit", CON_DESTROYIT }, - { "else", CON_ELSE }, - { "enda", CON_ENDA }, - { "endevent", CON_ENDEVENT }, - { "endofgame", CON_ENDOFGAME }, - { "ends", CON_ENDS }, - { "fakebubba", CON_FAKEBUBBA }, - { "fall", CON_FALL }, - { "feathers", CON_MAIL }, - { "gamestartup", CON_GAMESTARTUP }, - { "gamevar", CON_GAMEVAR }, - { "garybanjo", CON_GARYBANJO }, - { "getlastpal", CON_GETLASTPAL }, - { "globalsound", CON_GLOBALSOUND }, - { "guts", CON_GUTS }, - { "hitradius", CON_HITRADIUS }, - { "ifaction", CON_IFACTION }, - { "ifactioncount", CON_IFACTIONCOUNT }, - { "ifactor", CON_IFACTOR }, - { "ifactorhealthg", CON_IFACTORHEALTHG }, - { "ifactorhealthl", CON_IFACTORHEALTHL }, - { "ifactornotstayput", CON_IFACTORNOTSTAYPUT }, - { "ifai", CON_IFAI }, - { "ifangdiffl", CON_IFANGDIFFL }, - { "ifawayfromwall", CON_IFAWAYFROMWALL }, - { "ifbulletnear", CON_IFBULLETNEAR }, - { "ifcansee", CON_IFCANSEE }, - { "ifcanseetarget", CON_IFCANSEETARGET }, - { "ifcanshoottarget", CON_IFCANSHOOTTARGET }, - { "ifceilingdistl", CON_IFCEILINGDISTL }, - { "ifcount", CON_IFCOUNT }, - { "ifdead", CON_IFDEAD }, - { "iffindnewspot", CON_IFFINDNEWSPOT }, - { "iffloordistl", CON_IFFLOORDISTL }, - { "ifgapzl", CON_IFGAPZL }, - { "ifgotweaponce", CON_IFGOTWEAPONCE }, - { "ifhitspace", CON_IFHITSPACE }, - { "ifhittruck", CON_IFHITTRUCK }, - { "ifhitweapon", CON_IFHITWEAPON }, - { "ifinouterspace", CON_IFINOUTERSPACE }, - { "ifinspace", CON_IFINSPACE }, - { "ifinwater", CON_IFINWATER }, - { "ifmotofast", CON_IFMOTOFAST }, - { "ifmove", CON_IFMOVE }, - { "ifmultiplayer", CON_IFMULTIPLAYER }, - { "ifnocover", CON_IFNOCOVER }, - { "ifnosounds", CON_IFNOSOUNDS }, - { "ifnotmoving", CON_IFNOTMOVING }, - { "ifcoop", CON_IFCOOP }, - { "ifonboat", CON_IFONBOAT }, - { "ifonmoto", CON_IFONMOTO }, - { "ifonmud", CON_IFONMUD }, - { "ifonwater", CON_IFONWATER }, - { "ifoutside", CON_IFOUTSIDE }, - { "ifp", CON_IFP }, - { "ifpdistg", CON_IFPDISTG }, - { "ifpdistl", CON_IFPDISTL }, - { "ifpdrunk", CON_IFPDRUNK }, - { "ifphealthl", CON_IFPHEALTHL }, - { "ifpinventory", CON_IFPINVENTORY }, - { "ifrespawn", CON_IFRESPAWN }, - { "ifrnd", CON_IFRND }, - { "ifsizedown", CON_IFSIZEDOWN }, - { "ifsounddist", CON_IFSOUNDDIST }, - { "ifsoundid", CON_IFSOUNDID }, - { "ifspawnedby", CON_IFSPAWNEDBY }, - { "ifspritepal", CON_IFSPRITEPAL }, - { "ifsquished", CON_IFSQUISHED }, - { "ifstrength", CON_IFSTRENGTH }, - { "iftipcow", CON_IFTIPCOW }, - { "ifpupwind", CON_IFPUPWIND }, - { "ifvare", CON_IFVARE }, - { "ifvarg", CON_IFVARG }, - { "ifvarl", CON_IFVARL }, - { "ifvarvare", CON_IFVARVARE }, - { "ifvarvarg", CON_IFVARVARG }, - { "ifvarvarl", CON_IFVARVARL }, - { "ifwasweapon", CON_IFWASWEAPON }, - { "ifwind", CON_IFWIND }, - { "include", CON_INCLUDE }, - { "isdrunk", CON_ISDRUNK }, - { "iseat", CON_ISEAT }, - { "killit", CON_KILLIT }, - { "larrybird", CON_LARRYBIRD }, - { "leavedroppings", CON_LEAVEDROPPINGS }, - { "leavetrax", CON_LEAVETRAX }, - { "lotsofglass", CON_LOTSOFGLASS }, - { "mail", CON_MAIL }, - { "mamaend", CON_MAMAEND }, - { "mamaquake", CON_MAMAQUAKE }, - { "mamaspawn", CON_MAMASPAWN }, - { "mamatrigger", CON_MAMATRIGGER }, - { "mikesnd", CON_MIKESND }, - { "money", CON_MONEY }, - { "motoloopsnd", CON_MOTOLOOPSND }, - { "move", CON_MOVE }, - { "music", CON_MUSIC }, - { "newpic", CON_NEWPIC }, - { "nullop", CON_NULLOP }, - { "onevent", CON_ONEVENT }, - { "operate", CON_OPERATE }, - { "palfrom", CON_PALFROM }, - { "paper", CON_PAPER }, - { "pkick", CON_PKICK }, - { "pstomp", CON_PSTOMP }, - { "quote", CON_QUOTE }, - { "resetactioncount", CON_RESETACTIONCOUNT }, - { "resetcount", CON_RESETCOUNT }, - { "resetplayer", CON_RESETPLAYER }, - { "respawnhitag", CON_RESPAWNHITAG }, - { "rndmove", CON_RNDMOVE }, - { "setvar", CON_SETVAR }, - { "setvarvar", CON_SETVARVAR }, - { "sizeat", CON_SIZEAT }, - { "sizeto", CON_SIZETO }, - { "slapplayer", CON_SLAPPLAYER }, - { "sleeptime", CON_SLEEPTIME }, - { "shoot", CON_SHOOT }, - { "smackbubba", CON_SMACKBUBBA }, - { "smacksprite", CON_SMACKSPRITE }, - { "sound", CON_SOUND }, - { "soundonce", CON_SOUNDONCE }, - { "soundtag", CON_SOUNDTAG }, - { "soundtagonce", CON_SOUNDTAGONCE }, - { "spawn", CON_SPAWN }, - { "spritepal", CON_SPRITEPAL }, - { "state", CON_STATE }, - { "stopsound", CON_STOPSOUND }, - { "strafeleft", CON_STRAFELEFT }, - { "straferight", CON_STRAFERIGHT }, - { "strength", CON_STRENGTH }, - { "tearitup", CON_TEARITUP }, - { "tip", CON_TIP }, - { "tossweapon", CON_TOSSWEAPON }, - { "useractor", CON_USERACTOR }, - { "wackplayer", CON_WACKPLAYER }, - { "{", CON_LEFTBRACE }, - { "}", CON_RIGHTBRACE }, -}; - static const vec2_t varvartable[] = { - { CON_IFVARVARE, CON_IFVARE }, - { CON_IFVARVARG, CON_IFVARG }, - { CON_IFVARVARL, CON_IFVARL }, - - { CON_ADDVARVAR, CON_ADDVAR }, - { CON_SETVARVAR, CON_SETVAR }, + { concmd_ifvarvare, concmd_ifvare }, + { concmd_ifvarvarg, concmd_ifvarg }, + { concmd_ifvarvarl, concmd_ifvarl }, + { concmd_addvarvar, concmd_addvar }, + { concmd_setvarvar, concmd_setvar }, }; static inthashtable_t h_varvar = { NULL, INTHASH_SIZE(ARRAY_SIZE(varvartable)) }; @@ -285,11 +124,7 @@ static inthashtable_t *const inttables[] = { char const * VM_GetKeywordForID(int32_t id) { - // could be better but this is only called for diagnostics, ayy lmao - for (tokenmap_t const & keyword : vm_keywords) - if (keyword.val == id) - return keyword.token; - + // do not really need this for now... return ""; } @@ -301,20 +136,19 @@ char *bitptr; // pointer to bitmap of which bytecode positions contain pointers hashtable_t h_gamevars = { MAXGAMEVARS >> 1, NULL }; hashtable_t h_labels = { 11264>>1, NULL }; -static hashtable_t h_keywords = { CON_END>>1, NULL };; - static hashtable_t * const tables[] = { - &h_labels, &h_keywords, &h_gamevars + &h_labels, &h_gamevars }; static hashtable_t * const tables_free [] = { - &h_labels, &h_keywords + &h_labels }; #define STRUCT_HASH_SETUP(table, labels) do { for (i=0; labels[i].lId >= 0; i++) hash_add(&table, labels[i].name, i, 0); } while (0) void C_InitHashes() { + SortCommands(); for (auto table : tables) hash_init(table); @@ -326,9 +160,6 @@ void C_InitHashes() //inithashnames(); initsoundhashnames(); - - for (tokenmap_t const & keyword : vm_keywords) - hash_add(&h_keywords, keyword.token, keyword.val, 0); } #undef STRUCT_HASH_SETUP @@ -410,13 +241,7 @@ static int32_t C_SetScriptSize(int32_t newsize) static inline int32_t ispecial(const char c) { return (c == ' ' || c == 0x0d || c == '(' || c == ')' || - c == ',' || c == ';' || (c == 0x0a /*&& ++g_lineNumber*/)); -} - -static inline void C_NextLine(void) -{ - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - textptr++; + c == ',' || c == ';' || (c == 0x0a /*&& ++line_count*/)); } static inline void C_SkipSpace(void) @@ -435,7 +260,7 @@ static int32_t C_SkipComments(void) switch (*textptr) { case '\n': - g_lineNumber++; + line_count++; fallthrough__; case ' ': case '\t': @@ -448,17 +273,17 @@ static int32_t C_SkipComments(void) { case '/': // C++ style comment if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) - Printf("%s:%d: debug: got comment.\n",g_scriptFileName,g_lineNumber); - C_NextLine(); + Printf("%s:%d: debug: got comment.\n",g_scriptFileName,line_count); + skiptoendofline(); g_gotComment = 1; continue; case '*': // beginning of a C style comment if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) - Printf("%s:%d: debug: got start of comment block.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: debug: got start of comment block.\n",g_scriptFileName,line_count); do { if (*textptr == '\n') - g_lineNumber++; + line_count++; textptr++; } while (*textptr && (textptr[0] != '*' || textptr[1] != '/')); @@ -466,24 +291,24 @@ static int32_t C_SkipComments(void) if (EDUKE32_PREDICT_FALSE(!*textptr)) { if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) - Printf("%s:%d: debug: EOF in comment!\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: debug: EOF in comment!\n",g_scriptFileName,line_count); C_ReportError(-1); - Printf("%s:%d: error: found `/*' with no `*/'.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: found `/*' with no `*/'.\n",g_scriptFileName,line_count); g_parsingActorPtr = g_processingState = g_numBraces = 0; g_errorCnt++; continue; } if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) - Printf("%s:%d: debug: got end of comment block.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: debug: got end of comment block.\n",g_scriptFileName,line_count); textptr+=2; g_gotComment = 1; continue; default: C_ReportError(-1); - Printf("%s:%d: error: malformed comment.\n", g_scriptFileName, g_lineNumber); - C_NextLine(); + Printf("%s:%d: error: malformed comment.\n", g_scriptFileName, line_count); + skiptoendofline(); g_errorCnt++; continue; } @@ -547,7 +372,7 @@ static void C_GetNextLabelName(void) label[(g_labelCnt<<6)+i] = 0; if (!(g_errorCnt|g_warningCnt) && g_scriptDebug > 1) - Printf("%s:%d: debug: label `%s'.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); + Printf("%s:%d: debug: label `%s'.\n",g_scriptFileName,line_count,label+(g_labelCnt<<6)); } static inline void scriptWriteValue(int32_t const value) @@ -593,7 +418,7 @@ static int32_t C_GetKeyword(void) tempbuf[i++] = *(temptextptr++); tempbuf[i] = 0; - return hash_find(&h_keywords,tempbuf); + return getkeyword(tempbuf); } static int32_t C_GetNextKeyword(void) //Returns its code # @@ -613,16 +438,16 @@ static int32_t C_GetNextKeyword(void) //Returns its code # } tempbuf[l] = 0; - if (EDUKE32_PREDICT_TRUE((i = hash_find(&h_keywords,tempbuf)) >= 0)) + if ((i=getkeyword(tempbuf)) >= 0) { - if (i == CON_LEFTBRACE || i == CON_RIGHTBRACE || i == CON_NULLOP) + if (i == concmd_leftbrace || i == concmd_rightbrace || i == concmd_nullop) scriptWriteValue(i | (VM_IFELSE_MAGIC<<12)); else scriptWriteValue(i | LINE_NUMBER); textptr += l; if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) - Printf("%s:%d: debug: keyword `%s'.\n", g_scriptFileName, g_lineNumber, tempbuf); + Printf("%s:%d: debug: keyword `%s'.\n", g_scriptFileName, line_count, tempbuf); return i; } @@ -632,7 +457,7 @@ static int32_t C_GetNextKeyword(void) //Returns its code # if (EDUKE32_PREDICT_FALSE((tempbuf[0] == '{' || tempbuf[0] == '}') && tempbuf[1] != 0)) { C_ReportError(-1); - Printf("%s:%d: error: expected whitespace between `%c' and `%s'.\n",g_scriptFileName,g_lineNumber,tempbuf[0],tempbuf+1); + Printf("%s:%d: error: expected whitespace between `%c' and `%s'.\n",g_scriptFileName,line_count,tempbuf[0],tempbuf+1); } else C_ReportError(ERROR_EXPECTEDKEYWORD); @@ -655,7 +480,7 @@ static int32_t parse_decimal_number(void) // (textptr) // is implementation-defined (C99 6.3.1.3) but GCC does the 'expected' thing. #if 0 Printf("%s:%d: warning: number greater than INT32_MAX converted to a negative one.\n", - g_szScriptFileName,g_lineNumber); + g_szScriptFileName,line_count); g_numCompilerWarnings++; #endif } @@ -664,7 +489,7 @@ static int32_t parse_decimal_number(void) // (textptr) // out of range, this is arguably worse Printf("%s:%d: warning: number out of the range of a 32-bit integer encountered.\n", - g_scriptFileName,g_lineNumber); + g_scriptFileName,line_count); g_warningCnt++; } @@ -678,7 +503,7 @@ static int32_t parse_hex_constant(const char *hexnum) if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX)) { - Printf(g_scriptFileName, ":", g_lineNumber, ": warning: number 0x", hex(x), " truncated to 32 bits.\n"); + Printf(g_scriptFileName, ":", line_count, ": warning: number 0x", hex(x), " truncated to 32 bits.\n"); g_warningCnt++; } @@ -704,7 +529,7 @@ static void C_GetNextVarType(int32_t type) scriptWriteValue(parse_decimal_number()); if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) - Printf("%s:%d: debug: constant %ld in place of gamevar.\n", g_scriptFileName, g_lineNumber, (long)(g_scriptPtr[-1])); + Printf("%s:%d: debug: constant %ld in place of gamevar.\n", g_scriptFileName, line_count, (long)(g_scriptPtr[-1])); #if 1 while (!ispecial(*textptr) && *textptr != ']') textptr++; #else @@ -723,7 +548,7 @@ static void C_GetNextVarType(int32_t type) } if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) - Printf("%s:%d: debug: flagging gamevar as negative.\n", g_scriptFileName, g_lineNumber); //,Batol(textptr)); + Printf("%s:%d: debug: flagging gamevar as negative.\n", g_scriptFileName, line_count); //,Batol(textptr)); flags = GV_FLAG_NEGATIVE; textptr++; @@ -731,7 +556,7 @@ static void C_GetNextVarType(int32_t type) C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,LAST_LABEL)>=0)) + if (getkeyword(LAST_LABEL)>=0) { g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); @@ -752,7 +577,7 @@ static void C_GetNextVarType(int32_t type) if (EDUKE32_PREDICT_TRUE(id>=0 && labeltype[id] & LABEL_DEFINE)) { if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) - Printf("%s:%d: debug: label `%s' in place of gamevar.\n",g_scriptFileName,g_lineNumber,label+(id<<6)); + Printf("%s:%d: debug: label `%s' in place of gamevar.\n",g_scriptFileName,line_count,label+(id<<6)); scriptWriteValue(GV_FLAG_CONSTANT); scriptWriteValue(labelcode[id]); @@ -779,7 +604,7 @@ static void C_GetNextVarType(int32_t type) } if (g_scriptDebug > 1 && !g_errorCnt && !g_warningCnt) - Printf("%s:%d: debug: gamevar `%s'.\n",g_scriptFileName,g_lineNumber,LAST_LABEL); + Printf("%s:%d: debug: gamevar `%s'.\n",g_scriptFileName,line_count,LAST_LABEL); scriptWriteValue(id|flags); } @@ -816,11 +641,11 @@ static int32_t C_GetNextValue(int32_t type) } tempbuf[l] = 0; - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,tempbuf /*label+(g_numLabels<<6)*/)>=0)) + if (getkeyword(tempbuf) >= 0) { g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); - textptr+=l; + return -1; } int32_t i = hash_find(&h_labels,tempbuf); @@ -832,7 +657,7 @@ static int32_t C_GetNextValue(int32_t type) if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) { char *gl = C_GetLabelType(labeltype[i]); - Printf("%s:%d: debug: %s label `%s'.\n",g_scriptFileName,g_lineNumber,gl,label+(i<<6)); + Printf("%s:%d: debug: %s label `%s'.\n",g_scriptFileName,line_count,gl,label+(i<<6)); Xfree(gl); } @@ -849,7 +674,7 @@ static int32_t C_GetNextValue(int32_t type) char *el = C_GetLabelType(type); char *gl = C_GetLabelType(labeltype[i]); C_ReportError(-1); - Printf("%s:%d: warning: expected %s, found %s.\n",g_scriptFileName,g_lineNumber,el,gl); + Printf("%s:%d: warning: expected %s, found %s.\n",g_scriptFileName,line_count,el,gl); g_warningCnt++; Xfree(el); Xfree(gl); @@ -882,7 +707,7 @@ static int32_t C_GetNextValue(int32_t type) if (EDUKE32_PREDICT_FALSE(!isdigit(textptr[i--]))) { C_ReportError(-1); - Printf("%s:%d: warning: invalid character `%c' in definition!\n",g_scriptFileName,g_lineNumber,textptr[i+1]); + Printf("%s:%d: warning: invalid character `%c' in definition!\n",g_scriptFileName,line_count,textptr[i+1]); g_warningCnt++; break; } @@ -898,7 +723,7 @@ static int32_t C_GetNextValue(int32_t type) if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) Printf("%s:%d: debug: constant %ld.\n", - g_scriptFileName,g_lineNumber,(long)*g_scriptPtr); + g_scriptFileName,line_count,(long)*g_scriptPtr); g_scriptPtr++; @@ -911,15 +736,15 @@ static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr) { switch (C_GetKeyword()) { - case CON_RIGHTBRACE: - case CON_ENDA: - case CON_ENDS: - case CON_ELSE: + case concmd_rightbrace: + case concmd_enda: + case concmd_ends: + case concmd_else: g_scriptPtr = lastScriptPtr + &apScript[0]; g_skipBranch = 1; C_ReportError(-1); g_warningCnt++; - Printf("%s:%d: warning: malformed `%s' branch\n",g_scriptFileName,g_lineNumber, + Printf("%s:%d: warning: malformed `%s' branch\n",g_scriptFileName,line_count, VM_GetKeywordForID(*(g_scriptPtr) & VM_INSTMASK)); return 1; } @@ -929,15 +754,15 @@ static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr) static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr) { // ifrnd and the others actually do something when the condition is executed - if ((Bstrncmp(VM_GetKeywordForID(tw), "if", 2) && tw != CON_ELSE) || - tw == CON_IFRND || tw == CON_IFHITWEAPON || tw == CON_IFCANSEE || tw == CON_IFCANSEETARGET || - tw == CON_IFPDISTL || tw == CON_IFPDISTG || tw == CON_IFGOTWEAPONCE) + if ((Bstrncmp(VM_GetKeywordForID(tw), "if", 2) && tw != concmd_else) || + tw == concmd_ifrnd || tw == concmd_ifhitweapon || tw == concmd_ifcansee || tw == concmd_ifcanseetarget || + tw == concmd_ifpdistl || tw == concmd_ifpdistg || tw == concmd_ifgotweaponce) { g_skipBranch = 0; return 0; } - if ((*(g_scriptPtr) & VM_INSTMASK) != CON_NULLOP || *(g_scriptPtr)>>12 != IFELSE_MAGIC) + if ((*(g_scriptPtr) & VM_INSTMASK) != concmd_nullop || *(g_scriptPtr)>>12 != IFELSE_MAGIC) g_skipBranch = 0; if (EDUKE32_PREDICT_FALSE(g_skipBranch)) @@ -945,9 +770,9 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr) C_ReportError(-1); g_warningCnt++; g_scriptPtr = lastScriptPtr + &apScript[0]; - Printf("%s:%d: warning: empty `%s' branch\n",g_scriptFileName,g_lineNumber, + Printf("%s:%d: warning: empty `%s' branch\n",g_scriptFileName,line_count, VM_GetKeywordForID(*(g_scriptPtr) & VM_INSTMASK)); - *(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12)); + *(g_scriptPtr) = (concmd_nullop + (IFELSE_MAGIC<<12)); return 1; } return 0; @@ -960,7 +785,7 @@ static void C_Include(const char *confile) if (!fp.isOpen()) { g_errorCnt++; - Printf("%s:%d: error: could not find file `%s'.\n",g_scriptFileName,g_lineNumber,confile); + Printf("%s:%d: error: could not find file `%s'.\n",g_scriptFileName,line_count,confile); return; } @@ -984,8 +809,8 @@ static void C_Include(const char *confile) Bstrcpy(parentScriptFileName, g_scriptFileName); Bstrcpy(g_scriptFileName, confile); - int32_t temp_ScriptLineNumber = g_lineNumber; - g_lineNumber = 1; + int32_t temp_ScriptLineNumber = line_count; + line_count = 1; int32_t temp_ifelse_check = g_checkingIfElse; g_checkingIfElse = 0; @@ -997,8 +822,8 @@ static void C_Include(const char *confile) Bstrcpy(g_scriptFileName, parentScriptFileName); - g_totalLines += g_lineNumber; - g_lineNumber = temp_ScriptLineNumber; + g_totalLines += line_count; + line_count = temp_ScriptLineNumber; g_checkingIfElse = temp_ifelse_check; textptr = origtptr; @@ -1116,22 +941,6 @@ static inline void C_FinishBitOr(int32_t value) *g_scriptPtr++ = value; } -static void scriptUpdateOpcodeForVariableType(intptr_t *ins) -{ - int opcode = -1; - - if (opcode != -1) - { - if (g_scriptDebug > 1 && !g_errorCnt && !g_warningCnt) - { - Printf("%s:%d: %s -> %s for var %s\n", g_scriptFileName, g_lineNumber, - VM_GetKeywordForID(*ins & VM_INSTMASK), VM_GetKeywordForID(opcode), aGameVars[ins[1] & (MAXGAMEVARS-1)].szLabel); - } - - scriptWriteAtOffset(opcode | LINE_NUMBER, ins); - } -} - static int32_t C_ParseCommand(int32_t loop) { int32_t i, j=0, k=0, tw; @@ -1151,7 +960,7 @@ static int32_t C_ParseCommand(int32_t loop) case -1: case -2: return 1; //End - case CON_STATE: + case concmd_state: if (!g_parsingActorPtr && g_processingState == 0) { C_GetNextLabelName(); @@ -1162,7 +971,7 @@ static int32_t C_ParseCommand(int32_t loop) g_processingState = 1; Bsprintf(g_szCurrentBlockName,"%s",label+(g_labelCnt<<6)); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) + if (getkeyword(label + (g_labelCnt << 6)) >= 0) { g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); @@ -1179,7 +988,7 @@ static int32_t C_ParseCommand(int32_t loop) if (EDUKE32_PREDICT_FALSE((j = hash_find(&h_labels,label+(g_labelCnt<<6))) < 0)) { C_ReportError(-1); - Printf("%s:%d: error: state `%s' not found.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); + Printf("%s:%d: error: state `%s' not found.\n",g_scriptFileName,line_count,label+(g_labelCnt<<6)); g_errorCnt++; g_scriptPtr++; continue; @@ -1189,16 +998,16 @@ static int32_t C_ParseCommand(int32_t loop) { char *gl = (char *) C_GetLabelType(labeltype[j]); C_ReportError(-1); - Printf("%s:%d: warning: expected state, found %s.\n", g_scriptFileName, g_lineNumber, gl); + Printf("%s:%d: warning: expected state, found %s.\n", g_scriptFileName, line_count, gl); g_warningCnt++; Xfree(gl); - *(g_scriptPtr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions + *(g_scriptPtr-1) = concmd_nullop; // get rid of the state, leaving a nullop to satisfy if conditions BITPTR_CLEAR(g_scriptPtr-apScript-1); continue; // valid label name, but wrong type } if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) - Printf("%s:%d: debug: state label `%s'.\n", g_scriptFileName, g_lineNumber, label+(j<<6)); + Printf("%s:%d: debug: state label `%s'.\n", g_scriptFileName, line_count, label+(j<<6)); *g_scriptPtr = (intptr_t) (apScript+labelcode[j]); // 'state' type labels are always script addresses, as far as I can see @@ -1207,11 +1016,11 @@ static int32_t C_ParseCommand(int32_t loop) g_scriptPtr++; continue; - case CON_ENDS: + case concmd_ends: if (EDUKE32_PREDICT_FALSE(g_processingState == 0)) { C_ReportError(-1); - Printf("%s:%d: error: found `ends' without open `state'.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: found `ends' without open `state'.\n",g_scriptFileName,line_count); g_errorCnt++; } // else @@ -1232,7 +1041,7 @@ static int32_t C_ParseCommand(int32_t loop) } continue; - case CON_GAMEVAR: + case concmd_gamevar: { // syntax: gamevar // defines var1 and sets initial value. @@ -1243,7 +1052,7 @@ static int32_t C_ParseCommand(int32_t loop) { g_errorCnt++; C_ReportError(ERROR_SYNTAXERROR); - C_NextLine(); + skiptoendofline(); continue; } @@ -1251,11 +1060,11 @@ static int32_t C_ParseCommand(int32_t loop) C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords, LAST_LABEL)>=0)) + if (getkeyword(label + (g_labelCnt << 6)) >= 0) { - g_warningCnt++; + g_errorCnt++; C_ReportError(WARNING_VARMASKSKEYWORD); - hash_delete(&h_keywords, LAST_LABEL); + continue; } int32_t defaultValue = 0; @@ -1286,11 +1095,11 @@ static int32_t C_ParseCommand(int32_t loop) continue; } - case CON_DEFINE: + case concmd_define: { C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) + if (getkeyword(label + (g_labelCnt << 6)) >= 0) { g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); @@ -1308,7 +1117,7 @@ static int32_t C_ParseCommand(int32_t loop) { g_warningCnt++; Printf("%s:%d: warning: ignored redefinition of `%s' to %d (old: %d).\n",g_scriptFileName, - g_lineNumber,label+(g_labelCnt<<6), (int32_t)(*(g_scriptPtr-1)), labelcode[i]); + line_count,label+(g_labelCnt<<6), (int32_t)(*(g_scriptPtr-1)), labelcode[i]); } } else @@ -1323,7 +1132,7 @@ static int32_t C_ParseCommand(int32_t loop) continue; } - case CON_PALFROM: + case concmd_palfrom: for (j=3; j>=0; j--) { if (C_GetKeyword() == -1) @@ -1339,7 +1148,7 @@ static int32_t C_ParseCommand(int32_t loop) } continue; - case CON_MOVE: + case concmd_move: if (g_parsingActorPtr || g_processingState) { if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1))) @@ -1347,7 +1156,7 @@ static int32_t C_ParseCommand(int32_t loop) C_ReportError(-1); BITPTR_CLEAR(g_scriptPtr-apScript-1); *(g_scriptPtr-1) = 0; - Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_count); g_warningCnt++; } @@ -1363,7 +1172,7 @@ static int32_t C_ParseCommand(int32_t loop) C_GetNextLabelName(); // Check to see it's already defined - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) + if (getkeyword(label + (g_labelCnt << 6)) >= 0) { g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); @@ -1373,7 +1182,7 @@ static int32_t C_ParseCommand(int32_t loop) if (EDUKE32_PREDICT_FALSE((i = hash_find(&h_labels,label+(g_labelCnt<<6))) >= 0)) { g_warningCnt++; - Printf("%s:%d: warning: duplicate move `%s' ignored.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); + Printf("%s:%d: warning: duplicate move `%s' ignored.\n",g_scriptFileName,line_count,label+(g_labelCnt<<6)); } else { @@ -1397,7 +1206,7 @@ static int32_t C_ParseCommand(int32_t loop) } continue; - case CON_MUSIC: + case concmd_music: { // NOTE: this doesn't get stored in the PCode... @@ -1416,7 +1225,7 @@ static int32_t C_ParseCommand(int32_t loop) g_errorCnt++; C_ReportError(-1); Printf("%s:%d: error: volume number must be between 0 and MAXVOLUMES+1=%d.\n", - g_scriptFileName, g_lineNumber, MAXVOLUMES+1); + g_scriptFileName, line_count, MAXVOLUMES+1); continue; } @@ -1447,7 +1256,7 @@ static int32_t C_ParseCommand(int32_t loop) } continue; - case CON_INCLUDE: + case concmd_include: g_scriptPtr--; C_SkipComments(); @@ -1468,7 +1277,7 @@ static int32_t C_ParseCommand(int32_t loop) C_Include(tempbuf); continue; - case CON_AI: + case concmd_ai: if (g_parsingActorPtr || g_processingState) { C_GetNextValue(LABEL_AI); @@ -1478,7 +1287,7 @@ static int32_t C_ParseCommand(int32_t loop) g_scriptPtr--; C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) + if (getkeyword(label + (g_labelCnt << 6)) >= 0) { g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); @@ -1489,7 +1298,7 @@ static int32_t C_ParseCommand(int32_t loop) if (EDUKE32_PREDICT_FALSE(i>=0)) { g_warningCnt++; - Printf("%s:%d: warning: duplicate ai `%s' ignored.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); + Printf("%s:%d: warning: duplicate ai `%s' ignored.\n",g_scriptFileName,line_count,label+(g_labelCnt<<6)); } else { @@ -1511,7 +1320,7 @@ static int32_t C_ParseCommand(int32_t loop) C_ReportError(-1); BITPTR_CLEAR(g_scriptPtr-apScript-1); *(g_scriptPtr-1) = 0; - Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_count); g_warningCnt++; } @@ -1537,7 +1346,7 @@ static int32_t C_ParseCommand(int32_t loop) } continue; - case CON_ACTION: + case concmd_action: if (g_parsingActorPtr || g_processingState) { C_GetNextValue(LABEL_ACTION); @@ -1548,7 +1357,7 @@ static int32_t C_ParseCommand(int32_t loop) C_GetNextLabelName(); // Check to see it's already defined - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) + if (getkeyword(label + (g_labelCnt << 6)) >= 0) { g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); @@ -1559,7 +1368,7 @@ static int32_t C_ParseCommand(int32_t loop) if (EDUKE32_PREDICT_FALSE(i>=0)) { g_warningCnt++; - Printf("%s:%d: warning: duplicate action `%s' ignored.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); + Printf("%s:%d: warning: duplicate action `%s' ignored.\n",g_scriptFileName,line_count,label+(g_labelCnt<<6)); } else { @@ -1582,8 +1391,8 @@ static int32_t C_ParseCommand(int32_t loop) } continue; - case CON_ACTOR: - case CON_USERACTOR: + case concmd_actor: + case concmd_useractor: if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr)) { C_ReportError(ERROR_FOUNDWITHIN); @@ -1594,7 +1403,7 @@ static int32_t C_ParseCommand(int32_t loop) g_scriptPtr--; g_parsingActorPtr = g_scriptPtr - apScript; - if (tw == CON_USERACTOR) + if (tw == concmd_useractor) { C_GetNextValue(LABEL_DEFINE); g_scriptPtr--; @@ -1615,7 +1424,7 @@ static int32_t C_ParseCommand(int32_t loop) if (j != -1) labeltype[j] |= LABEL_ACTOR; - if (tw == CON_USERACTOR) + if (tw == concmd_useractor) { j = *g_scriptPtr; @@ -1624,7 +1433,7 @@ static int32_t C_ParseCommand(int32_t loop) C_ReportError(-1); Printf("%s:%d: warning: invalid useractor type. Must be 0, 1, 2" " (notenemy, enemy, enemystayput).\n", - g_scriptFileName,g_lineNumber); + g_scriptFileName,line_count); g_warningCnt++; j = 0; } @@ -1642,7 +1451,7 @@ static int32_t C_ParseCommand(int32_t loop) g_tile[*g_scriptPtr].execPtr = apScript + g_parsingActorPtr; - if (tw == CON_USERACTOR) + if (tw == concmd_useractor) { if (j & 1) g_tile[*g_scriptPtr].flags |= SFLAG_BADGUY; @@ -1691,7 +1500,7 @@ static int32_t C_ParseCommand(int32_t loop) C_ReportError(-1); BITPTR_CLEAR(g_scriptPtr-apScript-1); *(g_scriptPtr-1) = 0; - Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_count); g_warningCnt++; } break; @@ -1705,7 +1514,7 @@ static int32_t C_ParseCommand(int32_t loop) g_checkingIfElse = 0; continue; - case CON_ONEVENT: + case concmd_onevent: if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr)) { C_ReportError(ERROR_FOUNDWITHIN); @@ -1734,7 +1543,7 @@ static int32_t C_ParseCommand(int32_t loop) //AddLog(g_szBuf); if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXEVENTS-1)) { - Printf("%s:%d: error: invalid event ID.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: invalid event ID.\n",g_scriptFileName,line_count); g_errorCnt++; continue; } @@ -1745,14 +1554,14 @@ static int32_t C_ParseCommand(int32_t loop) continue; - case CON_CSTAT: + case concmd_cstat: C_GetNextValue(LABEL_DEFINE); if (EDUKE32_PREDICT_FALSE(*(g_scriptPtr-1) == 32767)) { *(g_scriptPtr-1) = 32768; C_ReportError(-1); - Printf("%s:%d: warning: tried to set cstat 32767, using 32768 instead.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: warning: tried to set cstat 32767, using 32768 instead.\n",g_scriptFileName,line_count); g_warningCnt++; } else if (EDUKE32_PREDICT_FALSE((*(g_scriptPtr-1) & 48) == 48)) @@ -1760,55 +1569,55 @@ static int32_t C_ParseCommand(int32_t loop) i = *(g_scriptPtr-1); *(g_scriptPtr-1) ^= 48; C_ReportError(-1); - Printf("%s:%d: warning: tried to set cstat %d, using %d instead.\n",g_scriptFileName,g_lineNumber,i,(int32_t)(*(g_scriptPtr-1))); + Printf("%s:%d: warning: tried to set cstat %d, using %d instead.\n",g_scriptFileName,line_count,i,(int32_t)(*(g_scriptPtr-1))); g_warningCnt++; } continue; - case CON_HITRADIUS: + case concmd_hitradius: C_GetNextValue(LABEL_DEFINE); C_GetNextValue(LABEL_DEFINE); C_GetNextValue(LABEL_DEFINE); fallthrough__; - case CON_ADDAMMO: - case CON_ADDWEAPON: - case CON_SIZETO: - case CON_SIZEAT: - case CON_DEBRIS: - case CON_ADDINVENTORY: - case CON_GUTS: + case concmd_addammo: + case concmd_addweapon: + case concmd_sizeto: + case concmd_sizeat: + case concmd_debris: + case concmd_addinventory: + case concmd_guts: C_GetNextValue(LABEL_DEFINE); fallthrough__; - case CON_STRENGTH: - case CON_SHOOT: - case CON_ADDPHEALTH: - case CON_SPAWN: - case CON_COUNT: - case CON_ENDOFGAME: - case CON_SPRITEPAL: - case CON_CACTOR: - case CON_MONEY: - case CON_ADDKILLS: - case CON_DEBUG: - case CON_ADDSTRENGTH: - case CON_CSTATOR: - case CON_MAIL: - case CON_PAPER: - case CON_SLEEPTIME: - case CON_CLIPDIST: - case CON_ISDRUNK: - case CON_ISEAT: - case CON_NEWPIC: - case CON_LOTSOFGLASS: - case CON_QUOTE: - case CON_SOUND: - case CON_GLOBALSOUND: - case CON_SOUNDONCE: - case CON_STOPSOUND: + case concmd_strength: + case concmd_shoot: + case concmd_addphealth: + case concmd_spawn: + case concmd_count: + case concmd_endofgame: + case concmd_spritepal: + case concmd_cactor: + case concmd_money: + case concmd_addkills: + case concmd_debug: + case concmd_addstrength: + case concmd_cstator: + case concmd_mail: + case concmd_paper: + case concmd_sleeptime: + case concmd_clipdist: + case concmd_isdrunk: + case concmd_iseat: + case concmd_newpic: + case concmd_lotsofglass: + case concmd_quote: + case concmd_sound: + case concmd_globalsound: + case concmd_soundonce: + case concmd_stopsound: C_GetNextValue(LABEL_DEFINE); continue; - case CON_ELSE: + case concmd_else: { if (EDUKE32_PREDICT_FALSE(!g_checkingIfElse)) { @@ -1817,9 +1626,9 @@ static int32_t C_ParseCommand(int32_t loop) g_warningCnt++; C_ReportError(-1); - Printf("%s:%d: warning: found `else' with no `if'.\n", g_scriptFileName, g_lineNumber); + Printf("%s:%d: warning: found `else' with no `if'.\n", g_scriptFileName, line_count); - if (C_GetKeyword() == CON_LEFTBRACE) + if (C_GetKeyword() == concmd_leftbrace) { C_GetNextKeyword(); g_numBraces++; @@ -1857,30 +1666,28 @@ static int32_t C_ParseCommand(int32_t loop) continue; } - case CON_ADDLOGVAR: + case concmd_addlogvar: g_labelsOnly = 1; C_GetNextVar(); g_labelsOnly = 0; continue; - case CON_ADDVAR: - case CON_SETVAR: -setvar: + case concmd_setvar: + case concmd_addvar: + setvar: { auto ins = &g_scriptPtr[-1]; C_GetNextVarType(GAMEVAR_READONLY); C_GetNextValue(LABEL_DEFINE); - // replace instructions with special versions for specific var types - scriptUpdateOpcodeForVariableType(ins); continue; } - case CON_ADDVARVAR: - case CON_SETVARVAR: + case concmd_setvarvar: + case concmd_addvarvar: { //setvarvar: auto ins = &g_scriptPtr[-1]; auto tptr = textptr; - int const lnum = g_lineNumber; + int const lnum = line_count; C_GetNextVarType(GAMEVAR_READONLY); C_GetNextVar(); @@ -1891,7 +1698,7 @@ setvar: { if (g_scriptDebug > 1 && !g_errorCnt && !g_warningCnt) { - Printf("%s:%d: %s -> %s\n", g_scriptFileName, g_lineNumber, + Printf("%s:%d: %s -> %s\n", g_scriptFileName, line_count, VM_GetKeywordForID(*ins & VM_INSTMASK), VM_GetKeywordForID(opcode)); } @@ -1899,21 +1706,21 @@ setvar: scriptWriteAtOffset(opcode | LINE_NUMBER, ins); g_scriptPtr = &ins[1]; textptr = tptr; - g_lineNumber = lnum; + line_count = lnum; goto setvar; } continue; } - case CON_IFVARVARE: - case CON_IFVARVARG: - case CON_IFVARVARL: + case concmd_ifvarvarg: + case concmd_ifvarvarl: + case concmd_ifvarvare: { auto const ins = &g_scriptPtr[-1]; auto const lastScriptPtr = &g_scriptPtr[-1] - apScript; auto const lasttextptr = textptr; - int const lnum = g_lineNumber; + int const lnum = line_count; g_skipBranch = false; @@ -1929,7 +1736,7 @@ setvar: { if (g_scriptDebug > 1 && !g_errorCnt && !g_warningCnt) { - Printf("%s:%d: replacing %s with %s\n", g_scriptFileName, g_lineNumber, + Printf("%s:%d: replacing %s with %s\n", g_scriptFileName, line_count, VM_GetKeywordForID(*ins & VM_INSTMASK), VM_GetKeywordForID(opcode)); } @@ -1937,7 +1744,7 @@ setvar: tw = opcode; g_scriptPtr = &ins[1]; textptr = lasttextptr; - g_lineNumber = lnum; + line_count = lnum; goto ifvar; } } @@ -1958,9 +1765,9 @@ setvar: continue; } - case CON_IFVARE: - case CON_IFVARG: - case CON_IFVARL: + case concmd_ifvarl: + case concmd_ifvarg: + case concmd_ifvare: { ifvar: auto const ins = &g_scriptPtr[-1]; @@ -1974,7 +1781,7 @@ ifvar: if (C_CheckMalformedBranch(lastScriptPtr)) continue; - scriptUpdateOpcodeForVariableType(ins); + // scriptUpdateOpcodeForVariableType(ins); auto const offset = g_scriptPtr - apScript; g_scriptPtr++; //Leave a spot for the fail location @@ -1989,37 +1796,37 @@ ifvar: j = C_GetKeyword(); - if (j == CON_ELSE) + if (j == concmd_else) g_checkingIfElse++; continue; } - case CON_IFRND: - case CON_IFPDISTL: - case CON_IFPDISTG: - case CON_IFWASWEAPON: - case CON_IFACTIONCOUNT: - case CON_IFCOUNT: - case CON_IFACTOR: - case CON_IFSTRENGTH: - case CON_IFSPAWNEDBY: - case CON_IFGAPZL: - case CON_IFFLOORDISTL: - case CON_IFCEILINGDISTL: - case CON_IFPHEALTHL: - case CON_IFSPRITEPAL: - case CON_IFGOTWEAPONCE: - case CON_IFANGDIFFL: - case CON_IFACTORHEALTHG: - case CON_IFACTORHEALTHL: - case CON_IFSOUNDID: - case CON_IFSOUNDDIST: - case CON_IFAI: - case CON_IFACTION: - case CON_IFMOVE: - case CON_IFP: - case CON_IFPINVENTORY: + case concmd_ifrnd: + case concmd_ifpdistl: + case concmd_ifpdistg: + case concmd_ifwasweapon: + case concmd_ifactioncount: + case concmd_ifcount: + case concmd_ifactor: + case concmd_ifstrength: + case concmd_ifspawnedby: + case concmd_ifgapzl: + case concmd_iffloordistl: + case concmd_ifceilingdistl: + case concmd_ifphealthl: + case concmd_ifspritepal: + case concmd_ifgotweaponce: + case concmd_ifangdiffl: + case concmd_ifactorhealthg: + case concmd_ifactorhealthl: + case concmd_ifsoundid: + case concmd_ifsounddist: + case concmd_ifai: + case concmd_ifaction: + case concmd_ifmove: + case concmd_ifp: + case concmd_ifpinventory: { intptr_t offset; intptr_t lastScriptPtr = (g_scriptPtr-&apScript[0]-1); @@ -2028,26 +1835,26 @@ ifvar: switch (tw) { - case CON_IFAI: + case concmd_ifai: C_GetNextValue(LABEL_AI); break; - case CON_IFACTION: + case concmd_ifaction: C_GetNextValue(LABEL_ACTION); break; - case CON_IFMOVE: + case concmd_ifmove: if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1))) { C_ReportError(-1); *(g_scriptPtr-1) = 0; - Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_count); g_warningCnt++; } break; - case CON_IFPINVENTORY: + case concmd_ifpinventory: C_GetNextValue(LABEL_DEFINE); C_GetNextValue(LABEL_DEFINE); break; - case CON_IFP: + case concmd_ifp: j = 0; do C_BitOrNextValue(&j); @@ -2078,43 +1885,45 @@ ifvar: j = C_GetKeyword(); - if (j == CON_ELSE || j == CON_LEFTBRACE) + if (j == concmd_else || j == concmd_leftbrace) g_checkingIfElse++; continue; } - case CON_IFONWATER: - case CON_IFINWATER: - case CON_IFACTORNOTSTAYPUT: - case CON_IFCANSEE: - case CON_IFHITWEAPON: - case CON_IFSQUISHED: - case CON_IFDEAD: - case CON_IFCANSHOOTTARGET: - case CON_IFHITSPACE: - case CON_IFOUTSIDE: - case CON_IFMULTIPLAYER: - case CON_IFINSPACE: - case CON_IFBULLETNEAR: - case CON_IFRESPAWN: - case CON_IFINOUTERSPACE: - case CON_IFNOTMOVING: - case CON_IFAWAYFROMWALL: - case CON_IFCANSEETARGET: - case CON_IFNOSOUNDS: - case CON_IFNOCOVER: - case CON_IFHITTRUCK: - case CON_IFTIPCOW: - case CON_IFONMUD: - case CON_IFCOOP: - case CON_IFMOTOFAST: - case CON_IFWIND: - case CON_IFONMOTO: - case CON_IFONBOAT: - case CON_IFSIZEDOWN: - case CON_IFFINDNEWSPOT: - case CON_IFPUPWIND: + case concmd_ifonwater: + case concmd_ifinwater: + case concmd_ifactornotstayput: + case concmd_ifcansee: + case concmd_ifhitweapon: + case concmd_ifsquished: + case concmd_ifdead: + case concmd_ifcanshoottarget: + case concmd_ifhitspace: + case concmd_ifoutside: + case concmd_ifmultiplayer: + case concmd_ifinspace: + case concmd_ifbulletnear: + case concmd_ifrespawn: + case concmd_ifinouterspace: + case concmd_ifnotmoving: + case concmd_ifawayfromwall: + case concmd_ifcanseetarget: + case concmd_ifnosounds: + case concmd_ifnocover: + case concmd_ifhittruck: + case concmd_iftipcow: + case concmd_ifonmud: + case concmd_ifcoop: + case concmd_ifmotofast: + case concmd_ifwind: + case concmd_ifonmoto: + case concmd_ifonboat: + case concmd_ifsizedown: + case concmd_ifplaybackon: + // case concmd_iffindnewspot: + // case concmd_ifpupwind: + { intptr_t offset; intptr_t lastScriptPtr = (g_scriptPtr-&apScript[0]-1); @@ -2140,13 +1949,13 @@ ifvar: j = C_GetKeyword(); - if (j == CON_ELSE || j == CON_LEFTBRACE) + if (j == concmd_else || j == concmd_leftbrace) g_checkingIfElse++; continue; } - case CON_LEFTBRACE: + case concmd_leftbrace: if (EDUKE32_PREDICT_FALSE(!(g_processingState || g_parsingActorPtr || g_scriptEventOffset))) { g_errorCnt++; @@ -2157,23 +1966,23 @@ ifvar: C_ParseCommand(1); continue; - case CON_RIGHTBRACE: + case concmd_rightbrace: g_numBraces--; if ((*(g_scriptPtr-2)>>12) == (IFELSE_MAGIC) && - ((*(g_scriptPtr-2) & VM_INSTMASK) == CON_LEFTBRACE)) // rewrite "{ }" into "nullop" + ((*(g_scriptPtr-2) & VM_INSTMASK) == concmd_leftbrace)) // rewrite "{ }" into "nullop" { - // Printf("%s:%d: rewriting empty braces '{ }' as 'nullop' from right\n",g_szScriptFileName,g_lineNumber); - *(g_scriptPtr-2) = CON_NULLOP + (IFELSE_MAGIC<<12); + // Printf("%s:%d: rewriting empty braces '{ }' as 'nullop' from right\n",g_szScriptFileName,line_count); + *(g_scriptPtr-2) = concmd_nullop + (IFELSE_MAGIC<<12); g_scriptPtr -= 2; - if (C_GetKeyword() != CON_ELSE && (*(g_scriptPtr-2) & VM_INSTMASK) != CON_ELSE) + if (C_GetKeyword() != concmd_else && (*(g_scriptPtr-2) & VM_INSTMASK) != concmd_else) g_skipBranch = 1; else g_skipBranch = 0; j = C_GetKeyword(); - if (g_checkingIfElse && j != CON_ELSE) + if (g_checkingIfElse && j != concmd_else) g_checkingIfElse--; return 1; @@ -2182,22 +1991,22 @@ ifvar: if (EDUKE32_PREDICT_FALSE(g_numBraces < 0)) { C_ReportError(-1); - Printf("%s:%d: error: found more `}' than `{'.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: found more `}' than `{'.\n",g_scriptFileName,line_count); g_errorCnt++; } - if (g_checkingIfElse && j != CON_ELSE) + if (g_checkingIfElse && j != concmd_else) g_checkingIfElse--; return 1; - case CON_BETANAME: + case concmd_betaname: g_scriptPtr--; j = 0; - C_NextLine(); + skiptoendofline(); continue; - case CON_DEFINEVOLUMENAME: + case concmd_definevolumename: g_scriptPtr--; C_GetNextValue(LABEL_DEFINE); @@ -2209,9 +2018,9 @@ ifvar: if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXVOLUMES-1)) { Printf("%s:%d: error: volume number exceeds maximum volume count.\n", - g_scriptFileName,g_lineNumber); + g_scriptFileName,line_count); g_errorCnt++; - C_NextLine(); + skiptoendofline(); continue; } @@ -2221,7 +2030,7 @@ ifvar: g_volumeCnt = j+1; continue; - case CON_DEFINESKILLNAME: + case concmd_defineskillname: g_scriptPtr--; C_GetNextValue(LABEL_DEFINE); @@ -2233,9 +2042,9 @@ ifvar: if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSKILLS)) { Printf("%s:%d: error: skill number exceeds maximum skill count %d.\n", - g_scriptFileName,g_lineNumber, MAXSKILLS); + g_scriptFileName,line_count, MAXSKILLS); g_errorCnt++; - C_NextLine(); + skiptoendofline(); continue; } @@ -2250,7 +2059,7 @@ ifvar: continue; - case CON_DEFINELEVELNAME: + case concmd_definelevelname: g_scriptPtr--; C_GetNextValue(LABEL_DEFINE); g_scriptPtr--; @@ -2262,16 +2071,16 @@ ifvar: if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXVOLUMES-1)) { - Printf("%s:%d: error: volume number exceeds maximum volume count.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: volume number exceeds maximum volume count.\n",g_scriptFileName,line_count); g_errorCnt++; - C_NextLine(); + skiptoendofline(); continue; } if (EDUKE32_PREDICT_FALSE((unsigned)k > MAXLEVELS-1)) { - Printf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",g_scriptFileName,line_count); g_errorCnt++; - C_NextLine(); + skiptoendofline(); continue; } @@ -2285,7 +2094,7 @@ ifvar: textptr++,i++; if (EDUKE32_PREDICT_FALSE(i >= BMAX_PATH)) { - Printf("%s:%d: error: level file name exceeds limit of %d characters.\n",g_scriptFileName,g_lineNumber,BMAX_PATH); + Printf("%s:%d: error: level file name exceeds limit of %d characters.\n",g_scriptFileName,line_count,BMAX_PATH); g_errorCnt++; C_SkipSpace(); break; @@ -2325,9 +2134,9 @@ ifvar: if (EDUKE32_PREDICT_FALSE(i >= 32)) { Printf("%s:%d: warning: truncating level name to %d characters.\n", - g_scriptFileName,g_lineNumber,32); + g_scriptFileName,line_count,32); g_warningCnt++; - C_NextLine(); + skiptoendofline(); break; } } @@ -2338,7 +2147,7 @@ ifvar: continue; - case CON_DEFINEQUOTE: + case concmd_definequote: { g_scriptPtr--; @@ -2348,7 +2157,7 @@ ifvar: if (EDUKE32_PREDICT_FALSE((unsigned)k >= MAXQUOTES)) { - Printf("%s:%d: error: quote number exceeds limit of %d.\n",g_scriptFileName,g_lineNumber,MAXQUOTES); + Printf("%s:%d: error: quote number exceeds limit of %d.\n",g_scriptFileName,line_count,MAXQUOTES); g_errorCnt++; } else @@ -2372,7 +2181,7 @@ ifvar: quoteMgr.InitializeQuote(k, buffer.Data(), true); continue; } - case CON_DEFINESOUND: + case concmd_definesound: { int ps, pe, vo, pr, m; @@ -2386,13 +2195,13 @@ ifvar: k = g_scriptPtr[-1]; if ((unsigned)k >= MAXSOUNDS - 1) { - Printf("%s:%d: error: sound index exceeds limit of %d.\n", g_scriptFileName, g_lineNumber, MAXSOUNDS - 1); + Printf("%s:%d: error: sound index exceeds limit of %d.\n", g_scriptFileName, line_count, MAXSOUNDS - 1); g_errorCnt++; k = MAXSOUNDS - 1; } /*else if (g_sounds[k].filename != NULL) { - Printf("%s:%d: warning: sound %d already defined (%s)\n", g_scriptFileName, g_lineNumber, k, g_sounds[k].filename); + Printf("%s:%d: warning: sound %d already defined (%s)\n", g_scriptFileName, line_count, k, g_sounds[k].filename); g_warningCnt++; }*/ @@ -2436,12 +2245,12 @@ ifvar: continue; } - case CON_ENDEVENT: + case concmd_endevent: if (EDUKE32_PREDICT_FALSE(!g_scriptEventOffset)) { C_ReportError(-1); - Printf("%s:%d: error: found `endevent' without open `onevent'.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: found `endevent' without open `onevent'.\n",g_scriptFileName,line_count); g_errorCnt++; } if (EDUKE32_PREDICT_FALSE(g_numBraces != 0)) @@ -2455,11 +2264,11 @@ ifvar: Bsprintf(g_szCurrentBlockName,"(none)"); continue; - case CON_ENDA: + case concmd_enda: if (EDUKE32_PREDICT_FALSE(!g_parsingActorPtr || g_scriptEventOffset)) { C_ReportError(-1); - Printf("%s:%d: error: found `enda' without open `actor'.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: found `enda' without open `actor'.\n",g_scriptFileName,line_count); g_errorCnt++; g_scriptEventOffset = 0; } @@ -2472,59 +2281,59 @@ ifvar: Bsprintf(g_szCurrentBlockName,"(none)"); continue; - case CON_BREAK: + case concmd_break: continue; - case CON_FALL: - case CON_TIP: + case concmd_fall: + case concmd_tip: // case 21: - case CON_KILLIT: - case CON_RESETACTIONCOUNT: - case CON_PSTOMP: - case CON_RESETPLAYER: - case CON_RESETCOUNT: - case CON_WACKPLAYER: - case CON_OPERATE: - case CON_RESPAWNHITAG: - case CON_GETLASTPAL: - case CON_PKICK: - case CON_MIKESND: - case CON_TOSSWEAPON: - case CON_DESTROYIT: - case CON_LARRYBIRD: - case CON_STRAFELEFT: - case CON_STRAFERIGHT: - case CON_SLAPPLAYER: - case CON_TEARITUP: - case CON_SMACKBUBBA: - case CON_SOUNDTAGONCE: - case CON_SOUNDTAG: - case CON_SMACKSPRITE: - case CON_FAKEBUBBA: - case CON_MAMATRIGGER: - case CON_MAMASPAWN: - case CON_MAMAQUAKE: - case CON_MAMAEND: - case CON_GARYBANJO: - case CON_MOTOLOOPSND: - case CON_RNDMOVE: - case CON_LEAVETRAX: - case CON_LEAVEDROPPINGS: - case CON_DEPLOYBIAS: + case concmd_killit: + case concmd_resetactioncount: + case concmd_pstomp: + case concmd_resetplayer: + case concmd_resetcount: + case concmd_wackplayer: + case concmd_operate: + case concmd_respawnhitag: + case concmd_getlastpal: + case concmd_pkick: + case concmd_mikesnd: + case concmd_tossweapon: + case concmd_destroyit: + case concmd_larrybird: + case concmd_strafeleft: + case concmd_straferight: + case concmd_slapplayer: + case concmd_tearitup: + case concmd_smackbubba: + case concmd_soundtagonce: + case concmd_soundtag: + case concmd_smacksprite: + case concmd_fakebubba: + case concmd_mamatrigger: + case concmd_mamaspawn: + case concmd_mamaquake: + case concmd_mamaend: + case concmd_garybanjo: + case concmd_motoloopsnd: + case concmd_rndmove: + //case CON_LEAVETRAX: + //case CON_LEAVEDROPPINGS: + //case CON_DEPLOYBIAS: continue; - case CON_NULLOP: - if (EDUKE32_PREDICT_FALSE(C_GetKeyword() != CON_ELSE)) + case concmd_nullop: + if (EDUKE32_PREDICT_FALSE(C_GetKeyword() != concmd_else)) { C_ReportError(-1); g_warningCnt++; - Printf("%s:%d: warning: `nullop' found without `else'\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: warning: `nullop' found without `else'\n",g_scriptFileName,line_count); g_scriptPtr--; g_skipBranch = 1; } continue; - case CON_GAMESTARTUP: + case concmd_gamestartup: { int32_t params[34]; @@ -2683,7 +2492,7 @@ void C_Compile(const char *fileName) g_scriptPtr = apScript + 3; // move permits constants 0 and 1; moveptr[1] would be script[2] (reachable?) g_warningCnt = 0; g_errorCnt = 0; - g_lineNumber = 1; + line_count = 1; g_totalLines = 0; Bstrcpy(g_scriptFileName, fileName); @@ -2712,7 +2521,7 @@ void C_Compile(const char *fileName) G_GameExit(buf); } - g_totalLines += g_lineNumber; + g_totalLines += line_count; C_SetScriptSize(g_scriptPtr-apScript+8); @@ -2743,49 +2552,49 @@ void C_ReportError(int32_t iError) switch (iError) { case ERROR_CLOSEBRACKET: - Printf("%s:%d: error: found more `}' than `{' before `%s'.\n",g_scriptFileName,g_lineNumber,tempbuf); + Printf("%s:%d: error: found more `}' than `{' before `%s'.\n",g_scriptFileName,line_count,tempbuf); break; case ERROR_EXCEEDSMAXTILES: - Printf("%s:%d: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",g_scriptFileName,g_lineNumber,tempbuf,MAXTILES-1); + Printf("%s:%d: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",g_scriptFileName,line_count,tempbuf,MAXTILES-1); break; case ERROR_EXPECTEDKEYWORD: - Printf("%s:%d: error: expected a keyword but found `%s'.\n",g_scriptFileName,g_lineNumber,tempbuf); + Printf("%s:%d: error: expected a keyword but found `%s'.\n",g_scriptFileName,line_count,tempbuf); break; case ERROR_FOUNDWITHIN: - Printf("%s:%d: error: found `%s' within %s.\n",g_scriptFileName,g_lineNumber,tempbuf,g_parsingActorPtr?"an actor":"a state"); + Printf("%s:%d: error: found `%s' within %s.\n",g_scriptFileName,line_count,tempbuf,g_parsingActorPtr?"an actor":"a state"); break; case ERROR_ISAKEYWORD: - Printf("%s:%d: error: symbol `%s' is a keyword.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); + Printf("%s:%d: error: symbol `%s' is a keyword.\n",g_scriptFileName,line_count,label+(g_labelCnt<<6)); break; case ERROR_OPENBRACKET: - Printf("%s:%d: error: found more `{' than `}' before `%s'.\n",g_scriptFileName,g_lineNumber,tempbuf); + Printf("%s:%d: error: found more `{' than `}' before `%s'.\n",g_scriptFileName,line_count,tempbuf); break; case ERROR_NOTAGAMEVAR: - Printf("%s:%d: error: symbol `%s' is not a variable.\n",g_scriptFileName,g_lineNumber,LAST_LABEL); + Printf("%s:%d: error: symbol `%s' is not a variable.\n",g_scriptFileName,line_count,LAST_LABEL); break; case ERROR_PARAMUNDEFINED: - Printf("%s:%d: error: parameter `%s' is undefined.\n",g_scriptFileName,g_lineNumber,tempbuf); + Printf("%s:%d: error: parameter `%s' is undefined.\n",g_scriptFileName,line_count,tempbuf); break; case ERROR_SYNTAXERROR: - Printf("%s:%d: error: syntax error.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: syntax error.\n",g_scriptFileName,line_count); break; case ERROR_VARREADONLY: - Printf("%s:%d: error: variable `%s' is read-only.\n",g_scriptFileName,g_lineNumber,LAST_LABEL); + Printf("%s:%d: error: variable `%s' is read-only.\n",g_scriptFileName,line_count,LAST_LABEL); break; case ERROR_VARTYPEMISMATCH: - Printf("%s:%d: error: variable `%s' is of the wrong type.\n",g_scriptFileName,g_lineNumber,LAST_LABEL); + Printf("%s:%d: error: variable `%s' is of the wrong type.\n",g_scriptFileName,line_count,LAST_LABEL); break; case WARNING_BADGAMEVAR: - Printf("%s:%d: warning: variable `%s' should be either per-player OR per-actor, not both.\n",g_scriptFileName,g_lineNumber,LAST_LABEL); + Printf("%s:%d: warning: variable `%s' should be either per-player OR per-actor, not both.\n",g_scriptFileName,line_count,LAST_LABEL); break; case WARNING_DUPLICATEDEFINITION: - Printf("%s:%d: warning: duplicate definition `%s' ignored.\n",g_scriptFileName,g_lineNumber,LAST_LABEL); + Printf("%s:%d: warning: duplicate definition `%s' ignored.\n",g_scriptFileName,line_count,LAST_LABEL); break; case WARNING_LABELSONLY: - Printf("%s:%d: warning: expected a label, found a constant.\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: warning: expected a label, found a constant.\n",g_scriptFileName,line_count); break; case WARNING_VARMASKSKEYWORD: - Printf("%s:%d: warning: variable `%s' masks keyword.\n", g_scriptFileName, g_lineNumber, LAST_LABEL); + Printf("%s:%d: warning: variable `%s' masks keyword.\n", g_scriptFileName, line_count, LAST_LABEL); break; } } diff --git a/source/games/duke/src/zz_gameexec.cpp b/source/games/duke/src/zz_gameexec.cpp index f688545d7..7640d35e6 100644 --- a/source/games/duke/src/zz_gameexec.cpp +++ b/source/games/duke/src/zz_gameexec.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! +#include "concmd.h" #include "compat.h" #include "duke3d.h" @@ -77,7 +78,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop); #define VM_CONDITIONAL(xxx) \ { \ - if ((xxx) || ((insptr = (intptr_t *)*(insptr + 1)) && (((*insptr) & VM_INSTMASK) == CON_ELSE))) \ + if ((xxx) || ((insptr = (intptr_t *)*(insptr + 1)) && (((*insptr) & VM_INSTMASK) == concmd_else))) \ { \ insptr += 2; \ VM_Execute(0); \ @@ -1245,22 +1246,22 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) g_errorLineNum = tw >> 12; g_tw = tw &= VM_INSTMASK; - if (tw == CON_LEFTBRACE) + if (tw == concmd_leftbrace) { insptr++, loop++; continue; } - else if (tw == CON_RIGHTBRACE) + else if (tw == concmd_rightbrace) { insptr++, loop--; continue; } - else if (tw == CON_ELSE) + else if (tw == concmd_else) { insptr = (intptr_t *)*(insptr + 1); continue; } - else if (tw == CON_STATE) + else if (tw == concmd_state) { intptr_t const *const tempscrptr = insptr + 2; insptr = (intptr_t *)*(insptr + 1); @@ -1271,14 +1272,14 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) switch (tw) { - case CON_ENDA: - case CON_BREAK: - case CON_ENDS: - case CON_ENDEVENT: return; + case concmd_enda: + case concmd_break: + case concmd_ends: + case concmd_endevent: return; - case CON_IFRND: VM_CONDITIONAL(rnd(*(++insptr))); continue; + case concmd_ifrnd: VM_CONDITIONAL(rnd(*(++insptr))); continue; - case CON_IFCANSHOOTTARGET: + case concmd_ifcanshoottarget: { if (vm.playerDist > 1024) { @@ -1338,7 +1339,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_IFCANSEETARGET: + case concmd_ifcanseetarget: tw = cansee(vm.pSprite->x, vm.pSprite->y, vm.pSprite->z - ((krand2() & 41) << 8), vm.pSprite->sectnum, pPlayer->pos.x, pPlayer->pos.y, pPlayer->pos.z /*-((krand2()&41)<<8)*/, sprite[pPlayer->i].sectnum); VM_CONDITIONAL(tw); @@ -1346,7 +1347,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) vm.pActor->timetosleep = SLEEPTIME; continue; - case CON_IFNOCOVER: + case concmd_ifnocover: tw = cansee(vm.pSprite->x, vm.pSprite->y, vm.pSprite->z, vm.pSprite->sectnum, pPlayer->pos.x, pPlayer->pos.y, pPlayer->pos.z, sprite[pPlayer->i].sectnum); VM_CONDITIONAL(tw); @@ -1354,9 +1355,9 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) vm.pActor->timetosleep = SLEEPTIME; continue; - case CON_IFACTORNOTSTAYPUT: VM_CONDITIONAL(vm.pActor->actorstayput == -1); continue; + case concmd_ifactornotstayput: VM_CONDITIONAL(vm.pActor->actorstayput == -1); continue; - case CON_IFCANSEE: + case concmd_ifcansee: { uspritetype *pSprite = (uspritetype *)&sprite[pPlayer->i]; @@ -1417,7 +1418,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; } - case CON_IFHITWEAPON: + case concmd_ifhitweapon: if (DEER) { VM_CONDITIONAL(ghtrophy_isakill(vm.spriteNum)); @@ -1428,11 +1429,11 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_IFSQUISHED: VM_CONDITIONAL(VM_CheckSquished()); continue; + case concmd_ifsquished: VM_CONDITIONAL(VM_CheckSquished()); continue; - case CON_IFDEAD: VM_CONDITIONAL(vm.pSprite->extra - (vm.pSprite->picnum == TILE_APLAYER) < 0); continue; + case concmd_ifdead: VM_CONDITIONAL(vm.pSprite->extra - (vm.pSprite->picnum == TILE_APLAYER) < 0); continue; - case CON_AI: + case concmd_ai: insptr++; // Following changed to use pointersizes AC_AI_ID(vm.pData) = *insptr++; // Ai @@ -1449,37 +1450,37 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) vm.pSprite->ang = krand2() & 2047; continue; - case CON_ACTION: + case concmd_action: insptr++; AC_ACTION_COUNT(vm.pData) = 0; AC_CURFRAME(vm.pData) = 0; AC_ACTION_ID(vm.pData) = *insptr++; continue; - case CON_IFPDISTL: + case concmd_ifpdistl: insptr++; VM_CONDITIONAL(!(DEER && sub_535EC()) && vm.playerDist < *(insptr)); if (vm.playerDist > MAXSLEEPDIST && vm.pActor->timetosleep == 0) vm.pActor->timetosleep = SLEEPTIME; continue; - case CON_IFPDISTG: + case concmd_ifpdistg: VM_CONDITIONAL(vm.playerDist > *(++insptr)); if (vm.playerDist > MAXSLEEPDIST && vm.pActor->timetosleep == 0) vm.pActor->timetosleep = SLEEPTIME; continue; - case CON_ADDSTRENGTH: + case concmd_addstrength: insptr++; vm.pSprite->extra += *insptr++; continue; - case CON_STRENGTH: + case concmd_strength: insptr++; vm.pSprite->extra = *insptr++; continue; - case CON_SMACKSPRITE: + case concmd_smacksprite: insptr++; if (krand2()&1) vm.pSprite->ang = (vm.pSprite->ang-(512+(krand2()&511)))&2047; @@ -1487,7 +1488,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) vm.pSprite->ang = (vm.pSprite->ang+(512+(krand2()&511)))&2047; continue; - case CON_FAKEBUBBA: + case concmd_fakebubba: insptr++; switch (++g_fakeBubbaCnt) { @@ -1507,18 +1508,18 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_RNDMOVE: + case concmd_rndmove: insptr++; vm.pSprite->ang = krand2()&2047; vm.pSprite->xvel = 25; continue; - case CON_MAMATRIGGER: + case concmd_mamatrigger: insptr++; operateactivators(667, vm.playerNum); continue; - case CON_MAMASPAWN: + case concmd_mamaspawn: insptr++; if (g_mamaSpawnCnt) { @@ -1527,7 +1528,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_MAMAQUAKE: + case concmd_mamaquake: insptr++; if (vm.pSprite->pal == 31) g_earthquakeTime = 4; @@ -1535,7 +1536,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) g_earthquakeTime = 6; continue; - case CON_GARYBANJO: + case concmd_garybanjo: insptr++; if (g_banjoSong == 0) { @@ -1554,15 +1555,15 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) A_PlaySound(g_banjoSong, vm.spriteNum); } else if (!S_CheckSoundPlaying(vm.spriteNum, g_banjoSong)) - A_PlaySound(g_banjoSong, vm.spriteNum); + A_PlaySound(g_banjoSong, vm.spriteNum, CHAN_WEAPON); continue; - case CON_MOTOLOOPSND: + case concmd_motoloopsnd: insptr++; if (!S_CheckSoundPlaying(vm.spriteNum, 411)) A_PlaySound(411, vm.spriteNum); continue; - case CON_IFGOTWEAPONCE: + case concmd_ifgotweaponce: insptr++; if ((g_gametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY) && (g_netServer || ud.multimode > 1)) @@ -1587,7 +1588,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) VM_CONDITIONAL(0); continue; - case CON_GETLASTPAL: + case concmd_getlastpal: insptr++; if (vm.pSprite->picnum == TILE_APLAYER) vm.pSprite->pal = g_player[P_GetP(vm.pSprite)].ps->palookup; @@ -1596,13 +1597,13 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) vm.pActor->tempang = 0; continue; - case CON_TOSSWEAPON: + case concmd_tossweapon: insptr++; // NOTE: assumes that current actor is TILE_APLAYER P_DropWeapon(P_GetP(vm.pSprite)); continue; - case CON_MIKESND: + case concmd_mikesnd: insptr++; if (EDUKE32_PREDICT_FALSE(((unsigned)vm.pSprite->yvel >= MAXSOUNDS))) { @@ -1610,10 +1611,10 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; } if (!S_CheckSoundPlaying(vm.spriteNum, vm.pSprite->yvel)) - A_PlaySound(vm.pSprite->yvel, vm.spriteNum); + A_PlaySound(vm.pSprite->yvel, vm.spriteNum, CHAN_VOICE); continue; - case CON_PKICK: + case concmd_pkick: insptr++; if ((g_netServer || ud.multimode > 1) && vm.pSprite->picnum == TILE_APLAYER) @@ -1625,7 +1626,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) pPlayer->quick_kick = 14; continue; - case CON_SIZETO: + case concmd_sizeto: insptr++; tw = (*insptr++ - vm.pSprite->xrepeat) << 1; @@ -1643,13 +1644,13 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; - case CON_SIZEAT: + case concmd_sizeat: insptr++; vm.pSprite->xrepeat = (uint8_t)*insptr++; vm.pSprite->yrepeat = (uint8_t)*insptr++; continue; - case CON_SHOOT: + case concmd_shoot: insptr++; if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= (unsigned)numsectors)) { @@ -1659,12 +1660,12 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) A_Shoot(vm.spriteNum, *insptr++); continue; - case CON_IFSOUNDID: + case concmd_ifsoundid: insptr++; VM_CONDITIONAL((int16_t)*insptr == g_ambientLotag[vm.pSprite->ang]); continue; - case CON_IFSOUNDDIST: + case concmd_ifsounddist: insptr++; if (*insptr == 0) { @@ -1681,18 +1682,18 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; - case CON_SOUNDTAG: + case concmd_soundtag: insptr++; A_PlaySound(g_ambientLotag[vm.pSprite->ang], vm.spriteNum); continue; - case CON_SOUNDTAGONCE: + case concmd_soundtagonce: insptr++; if (!S_CheckSoundPlaying(vm.spriteNum, g_ambientLotag[vm.pSprite->ang])) A_PlaySound(g_ambientLotag[vm.pSprite->ang], vm.spriteNum); continue; - case CON_SOUNDONCE: + case concmd_soundonce: if (EDUKE32_PREDICT_FALSE((unsigned)*(++insptr) >= MAXSOUNDS)) { CON_ERRPRINTF("invalid sound %d\n", (int32_t)*insptr++); @@ -1704,7 +1705,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; - case CON_STOPSOUND: + case concmd_stopsound: if (EDUKE32_PREDICT_FALSE((unsigned)*(++insptr) >= MAXSOUNDS)) { CON_ERRPRINTF("invalid sound %d\n", (int32_t)*insptr); @@ -1716,7 +1717,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) insptr++; continue; - case CON_GLOBALSOUND: + case concmd_globalsound: if (EDUKE32_PREDICT_FALSE((unsigned)*(++insptr) >= MAXSOUNDS)) { CON_ERRPRINTF("invalid sound %d\n", (int32_t)*insptr); @@ -1732,7 +1733,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) insptr++; continue; - case CON_SMACKBUBBA: + case concmd_smackbubba: insptr++; if (!RRRA || vm.pSprite->pal != 105) { @@ -1744,27 +1745,29 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_DEPLOYBIAS: +#if 0 // RRDH only + case concmd_deploybias: insptr++; ghdeploy_bias(vm.spriteNum); continue; +#endif - case CON_MAMAEND: + case concmd_mamaend: insptr++; g_player[myconnectindex].ps->level_end_timer = 150; continue; - case CON_IFACTORHEALTHG: + case concmd_ifactorhealthg: insptr++; VM_CONDITIONAL(vm.pSprite->extra > (int16_t)*insptr); continue; - case CON_IFACTORHEALTHL: + case concmd_ifactorhealthl: insptr++; VM_CONDITIONAL(vm.pSprite->extra < (int16_t)*insptr); continue; - case CON_SOUND: + case concmd_sound: if (EDUKE32_PREDICT_FALSE((unsigned)*(++insptr) >= MAXSOUNDS)) { CON_ERRPRINTF("invalid sound %d\n", (int32_t)*insptr); @@ -1774,12 +1777,12 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) A_PlaySound(*insptr++, vm.spriteNum); continue; - case CON_TIP: + case concmd_tip: insptr++; pPlayer->tipincs = GAMETICSPERSEC; continue; - case CON_IFTIPCOW: + case concmd_iftipcow: if (g_spriteExtra[vm.spriteNum] == 1) { g_spriteExtra[vm.spriteNum]++; @@ -1789,7 +1792,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) VM_CONDITIONAL(0); continue; - case CON_IFHITTRUCK: + case concmd_ifhittruck: if (g_spriteExtra[vm.spriteNum] == 1) { g_spriteExtra[vm.spriteNum]++; @@ -1799,16 +1802,18 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) VM_CONDITIONAL(0); continue; - case CON_IFFINDNEWSPOT: +#if 0 // RRDH only + case concmd_iffindnewspot: VM_CONDITIONAL(ghcons_findnewspot(vm.spriteNum)); continue; - case CON_LEAVEDROPPINGS: + case concmd_leavedroppings: insptr++; ghtrax_leavedroppings(vm.spriteNum); continue; +#endif - case CON_TEARITUP: + case concmd_tearitup: insptr++; for (bssize_t SPRITES_OF_SECT(vm.pSprite->sectnum, spriteNum)) { @@ -1820,14 +1825,14 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_FALL: + case concmd_fall: insptr++; VM_Fall(vm.spriteNum, vm.pSprite); continue; - case CON_NULLOP: insptr++; continue; + case concmd_nullop: insptr++; continue; - case CON_ADDAMMO: + case concmd_addammo: insptr++; { int const weaponNum = *insptr++; @@ -1838,27 +1843,27 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; } - case CON_MONEY: + case concmd_money: insptr++; A_SpawnMultiple(vm.spriteNum, TILE_MONEY, *insptr++); continue; - case CON_MAIL: + case concmd_mail: insptr++; A_SpawnMultiple(vm.spriteNum, RR ? TILE_MONEY : TILE_MAIL, *insptr++); continue; - case CON_SLEEPTIME: + case concmd_sleeptime: insptr++; vm.pActor->timetosleep = (int16_t)*insptr++; continue; - case CON_PAPER: + case concmd_paper: insptr++; A_SpawnMultiple(vm.spriteNum, RR ? TILE_MONEY : TILE_PAPER, *insptr++); continue; - case CON_ADDKILLS: + case concmd_addkills: if (DEER) { // no op @@ -1879,17 +1884,17 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) vm.pActor->actorstayput = -1; continue; - case CON_LOTSOFGLASS: + case concmd_lotsofglass: insptr++; A_SpawnGlass(vm.spriteNum, *insptr++); continue; - case CON_KILLIT: + case concmd_killit: insptr++; vm.flags |= VM_KILL; return; - case CON_ADDWEAPON: + case concmd_addweapon: insptr++; { int const weaponNum = *insptr++; @@ -1897,19 +1902,19 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; } - case CON_DEBUG: + case concmd_debug: insptr++; buildprint(*insptr++, "\n"); continue; - case CON_ENDOFGAME: + case concmd_endofgame: insptr++; pPlayer->timebeforeexit = *insptr++; pPlayer->customexitsound = -1; ud.eog = 1; continue; - case CON_ISDRUNK: + case concmd_isdrunk: insptr++; { pPlayer->drink_amt += *insptr; @@ -1946,7 +1951,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) insptr++; continue; - case CON_STRAFELEFT: + case concmd_strafeleft: insptr++; { vec3_t const vect = { sintable[(vm.pSprite->ang+1024)&2047]>>10, sintable[(vm.pSprite->ang+512)&2047]>>10, vm.pSprite->zvel }; @@ -1954,7 +1959,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_STRAFERIGHT: + case concmd_straferight: insptr++; { vec3_t const vect = { sintable[(vm.pSprite->ang-0)&2047]>>10, sintable[(vm.pSprite->ang-512)&2047]>>10, vm.pSprite->zvel }; @@ -1962,18 +1967,20 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_LARRYBIRD: + case concmd_larrybird: insptr++; pPlayer->pos.z = sector[sprite[pPlayer->i].sectnum].ceilingz; sprite[pPlayer->i].z = pPlayer->pos.z; continue; - case CON_LEAVETRAX: +#if 0 // RRDH only + case concmd_leavetrax: insptr++; ghtrax_leavetrax(vm.spriteNum); continue; +#endif - case CON_DESTROYIT: + case concmd_destroyit: insptr++; { int16_t hitag, lotag, spr, jj, k, nextk; @@ -2065,7 +2072,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_ISEAT: + case concmd_iseat: insptr++; { @@ -2121,7 +2128,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) insptr++; continue; - case CON_ADDPHEALTH: + case concmd_addphealth: insptr++; { @@ -2172,7 +2179,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) insptr++; continue; - case CON_MOVE: + case concmd_move: insptr++; AC_COUNT(vm.pData) = 0; AC_MOVE_ID(vm.pData) = *insptr++; @@ -2181,7 +2188,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) vm.pSprite->ang = krand2() & 2047; continue; - case CON_SPAWN: + case concmd_spawn: insptr++; if ((unsigned)vm.pSprite->sectnum >= MAXSECTORS) { @@ -2192,33 +2199,33 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) A_Spawn(vm.spriteNum, *insptr++); continue; - case CON_IFWASWEAPON: - case CON_IFSPAWNEDBY: + case concmd_ifwasweapon: + case concmd_ifspawnedby: insptr++; VM_CONDITIONAL(vm.pActor->picnum == *insptr); continue; - case CON_IFAI: + case concmd_ifai: insptr++; VM_CONDITIONAL(AC_AI_ID(vm.pData) == *insptr); continue; - case CON_IFACTION: + case concmd_ifaction: insptr++; VM_CONDITIONAL(AC_ACTION_ID(vm.pData) == *insptr); continue; - case CON_IFACTIONCOUNT: + case concmd_ifactioncount: insptr++; VM_CONDITIONAL(AC_ACTION_COUNT(vm.pData) >= *insptr); continue; - case CON_RESETACTIONCOUNT: + case concmd_resetactioncount: insptr++; AC_ACTION_COUNT(vm.pData) = 0; continue; - case CON_DEBRIS: + case concmd_debris: insptr++; { int debrisTile = *insptr++; @@ -2241,51 +2248,51 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_COUNT: + case concmd_count: insptr++; AC_COUNT(vm.pData) = (int16_t)*insptr++; continue; - case CON_CSTATOR: + case concmd_cstator: insptr++; vm.pSprite->cstat |= (int16_t)*insptr++; continue; - case CON_CLIPDIST: + case concmd_clipdist: insptr++; vm.pSprite->clipdist = (int16_t)*insptr++; continue; - case CON_CSTAT: + case concmd_cstat: insptr++; vm.pSprite->cstat = (int16_t)*insptr++; continue; - case CON_NEWPIC: + case concmd_newpic: insptr++; vm.pSprite->picnum = (int16_t)*insptr++; continue; - case CON_IFMOVE: + case concmd_ifmove: insptr++; VM_CONDITIONAL(AC_MOVE_ID(vm.pData) == *insptr); continue; - case CON_RESETPLAYER: + case concmd_resetplayer: insptr++; vm.flags = VM_ResetPlayer(vm.playerNum, vm.flags); continue; - case CON_IFCOOP: + case concmd_ifcoop: VM_CONDITIONAL(GTFLAGS(GAMETYPE_COOP) || numplayers > 2); continue; - case CON_IFONMUD: + case concmd_ifonmud: VM_CONDITIONAL(sector[vm.pSprite->sectnum].floorpicnum == TILE_RRTILE3073 && klabs(vm.pSprite->z - sector[vm.pSprite->sectnum].floorz) < ZOFFSET5); continue; - case CON_IFONWATER: + case concmd_ifonwater: if (DEER) { VM_CONDITIONAL(sector[vm.pSprite->sectnum].hitag == 2003); @@ -2295,33 +2302,34 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) && klabs(vm.pSprite->z - sector[vm.pSprite->sectnum].floorz) < ZOFFSET5); continue; - case CON_IFMOTOFAST: + case concmd_ifmotofast: VM_CONDITIONAL(pPlayer->MotoSpeed > 60); continue; - case CON_IFONMOTO: + case concmd_ifonmoto: VM_CONDITIONAL(pPlayer->OnMotorcycle == 1); continue; - case CON_IFONBOAT: + case concmd_ifonboat: VM_CONDITIONAL(pPlayer->OnBoat == 1); continue; - case CON_IFSIZEDOWN: + case concmd_ifsizedown: vm.pSprite->xrepeat--; vm.pSprite->yrepeat--; VM_CONDITIONAL(vm.pSprite->xrepeat <= 5); continue; - case CON_IFWIND: + case concmd_ifwind: VM_CONDITIONAL(g_windTime > 0); continue; - - case CON_IFPUPWIND: +#if 0 // RRDH only + case concmd_ifpupwind: VM_CONDITIONAL(ghtrax_isplrupwind(vm.spriteNum, vm.playerNum)); continue; +#endif - case CON_IFINWATER: + case concmd_ifinwater: if (DEER) { VM_CONDITIONAL(sector[vm.pSprite->sectnum].hitag == 2003 && klabs(vm.pSprite->z - sector[vm.pSprite->sectnum].floorz) < ZOFFSET5); @@ -2330,22 +2338,22 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) VM_CONDITIONAL(sector[vm.pSprite->sectnum].lotag == ST_2_UNDERWATER); continue; - case CON_IFCOUNT: + case concmd_ifcount: insptr++; VM_CONDITIONAL(AC_COUNT(vm.pData) >= *insptr); continue; - case CON_IFACTOR: + case concmd_ifactor: insptr++; VM_CONDITIONAL(vm.pSprite->picnum == *insptr); continue; - case CON_RESETCOUNT: + case concmd_resetcount: insptr++; AC_COUNT(vm.pData) = 0; continue; - case CON_ADDINVENTORY: + case concmd_addinventory: insptr += 2; VM_AddInventory(pPlayer, *(insptr - 1), *insptr); @@ -2353,12 +2361,12 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) insptr++; continue; - case CON_HITRADIUS: + case concmd_hitradius: A_RadiusDamage(vm.spriteNum, *(insptr + 1), *(insptr + 2), *(insptr + 3), *(insptr + 4), *(insptr + 5)); insptr += 6; continue; - case CON_IFP: + case concmd_ifp: { int const moveFlags = *(++insptr); int nResult = 0; @@ -2399,24 +2407,24 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_IFSTRENGTH: + case concmd_ifstrength: insptr++; VM_CONDITIONAL(vm.pSprite->extra <= *insptr); continue; - case CON_GUTS: + case concmd_guts: A_DoGuts(vm.spriteNum, *(insptr + 1), *(insptr + 2)); insptr += 3; continue; - case CON_SLAPPLAYER: + case concmd_slapplayer: insptr++; P_ForceAngle(pPlayer); pPlayer->vel.x -= sintable[(fix16_to_int(pPlayer->q16ang)+512)&2047]<<7; pPlayer->vel.y -= sintable[fix16_to_int(pPlayer->q16ang)&2047]<<7; continue; - case CON_WACKPLAYER: + case concmd_wackplayer: insptr++; if (RR) { @@ -2429,14 +2437,14 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) P_ForceAngle(pPlayer); continue; - case CON_IFGAPZL: + case concmd_ifgapzl: insptr++; VM_CONDITIONAL(((vm.pActor->floorz - vm.pActor->ceilingz) >> 8) < *insptr); continue; - case CON_IFHITSPACE: VM_CONDITIONAL(TEST_SYNC_KEY(g_player[vm.playerNum].input->bits, SK_OPEN)); continue; + case concmd_ifhitspace: VM_CONDITIONAL(TEST_SYNC_KEY(g_player[vm.playerNum].input->bits, SK_OPEN)); continue; - case CON_IFOUTSIDE: + case concmd_ifoutside: if (DEER) { VM_CONDITIONAL(sector[vm.pSprite->sectnum].hitag = 2000); @@ -2445,9 +2453,9 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) VM_CONDITIONAL(sector[vm.pSprite->sectnum].ceilingstat & 1); continue; - case CON_IFMULTIPLAYER: VM_CONDITIONAL((g_netServer || g_netClient || ud.multimode > 1)); continue; + case concmd_ifmultiplayer: VM_CONDITIONAL((g_netServer || g_netClient || ud.multimode > 1)); continue; - case CON_OPERATE: + case concmd_operate: insptr++; if (sector[vm.pSprite->sectnum].lotag == 0) { @@ -2473,23 +2481,23 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_IFINSPACE: VM_CONDITIONAL(G_CheckForSpaceCeiling(vm.pSprite->sectnum)); continue; + case concmd_ifinspace: VM_CONDITIONAL(G_CheckForSpaceCeiling(vm.pSprite->sectnum)); continue; - case CON_SPRITEPAL: + case concmd_spritepal: insptr++; if (vm.pSprite->picnum != TILE_APLAYER) vm.pActor->tempang = vm.pSprite->pal; vm.pSprite->pal = *insptr++; continue; - case CON_CACTOR: + case concmd_cactor: insptr++; vm.pSprite->picnum = *insptr++; continue; - case CON_IFBULLETNEAR: VM_CONDITIONAL(A_Dodge(vm.pSprite) == 1); continue; + case concmd_ifbulletnear: VM_CONDITIONAL(A_Dodge(vm.pSprite) == 1); continue; - case CON_IFRESPAWN: + case concmd_ifrespawn: if (A_CheckEnemySprite(vm.pSprite)) VM_CONDITIONAL(ud.respawn_monsters) else if (A_CheckInventorySprite(vm.pSprite)) @@ -2498,17 +2506,17 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) VM_CONDITIONAL(ud.respawn_items) continue; - case CON_IFFLOORDISTL: + case concmd_iffloordistl: insptr++; VM_CONDITIONAL((vm.pActor->floorz - vm.pSprite->z) <= ((*insptr) << 8)); continue; - case CON_IFCEILINGDISTL: + case concmd_ifceilingdistl: insptr++; VM_CONDITIONAL((vm.pSprite->z - vm.pActor->ceilingz) <= ((*insptr) << 8)); continue; - case CON_PALFROM: + case concmd_palfrom: insptr++; if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= (unsigned)g_mostConcurrentPlayers)) { @@ -2523,12 +2531,12 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_IFPHEALTHL: + case concmd_ifphealthl: insptr++; VM_CONDITIONAL(sprite[pPlayer->i].extra < *insptr); continue; - case CON_IFPINVENTORY: + case concmd_ifpinventory: insptr++; switch (*insptr++) @@ -2570,7 +2578,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) VM_CONDITIONAL(tw); continue; - case CON_PSTOMP: + case concmd_pstomp: insptr++; if (pPlayer->knee_incs == 0 && sprite[pPlayer->i].xrepeat >= (RR ? 9 : 40)) if (cansee(vm.pSprite->x, vm.pSprite->y, vm.pSprite->z - ZOFFSET6, vm.pSprite->sectnum, pPlayer->pos.x, pPlayer->pos.y, @@ -2584,7 +2592,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_IFAWAYFROMWALL: + case concmd_ifawayfromwall: { int16_t otherSectnum = vm.pSprite->sectnum; tw = 0; @@ -2613,7 +2621,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_QUOTE: + case concmd_quote: insptr++; if (EDUKE32_PREDICT_FALSE((unsigned)(*insptr) >= MAXQUOTES)) @@ -2633,11 +2641,11 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) P_DoQuote(*(insptr++) | MAXQUOTES, pPlayer); continue; - case CON_IFINOUTERSPACE: VM_CONDITIONAL(G_CheckForSpaceFloor(vm.pSprite->sectnum)); continue; + case concmd_ifinouterspace: VM_CONDITIONAL(G_CheckForSpaceFloor(vm.pSprite->sectnum)); continue; - case CON_IFNOTMOVING: VM_CONDITIONAL((vm.pActor->movflag & 49152) > 16384); continue; + case concmd_ifnotmoving: VM_CONDITIONAL((vm.pActor->movflag & 49152) > 16384); continue; - case CON_RESPAWNHITAG: + case concmd_respawnhitag: insptr++; switch (DYNAMICTILEMAP(vm.pSprite->picnum)) { @@ -2666,33 +2674,33 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_IFSPRITEPAL: + case concmd_ifspritepal: insptr++; VM_CONDITIONAL(vm.pSprite->pal == *insptr); continue; - case CON_IFANGDIFFL: + case concmd_ifangdiffl: insptr++; tw = klabs(G_GetAngleDelta(fix16_to_int(pPlayer->q16ang), vm.pSprite->ang)); VM_CONDITIONAL(tw <= *insptr); continue; - case CON_IFNOSOUNDS: VM_CONDITIONAL(!A_CheckAnySoundPlaying(vm.spriteNum)); continue; + case concmd_ifnosounds: VM_CONDITIONAL(!A_CheckAnySoundPlaying(vm.spriteNum)); continue; - case CON_IFVARG: + case concmd_ifvarg: insptr++; tw = Gv_GetVar(*insptr++); VM_CONDITIONAL(tw > *insptr); continue; - case CON_IFVARL: + case concmd_ifvarl: insptr++; tw = Gv_GetVar(*insptr++); VM_CONDITIONAL(tw < *insptr); continue; - case CON_SETVARVAR: + case concmd_setvarvar: insptr++; { tw = *insptr++; @@ -2705,23 +2713,23 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } continue; - case CON_SETVAR: + case concmd_setvar: Gv_SetVar(insptr[1], insptr[2]); insptr += 3; continue; - case CON_ADDVARVAR: + case concmd_addvarvar: insptr++; tw = *insptr++; Gv_AddVar(tw, Gv_GetVar(*insptr++)); continue; - case CON_ADDVAR: + case concmd_addvar: Gv_AddVar(insptr[1], insptr[2]); insptr += 3; continue; - case CON_IFVARVARL: + case concmd_ifvarvarl: insptr++; tw = Gv_GetVar(*insptr++); tw = (tw < Gv_GetVar(*insptr++)); @@ -2729,7 +2737,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) VM_CONDITIONAL(tw); continue; - case CON_IFVARVARG: + case concmd_ifvarvarg: insptr++; tw = Gv_GetVar(*insptr++); tw = (tw > Gv_GetVar(*insptr++)); @@ -2737,7 +2745,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) VM_CONDITIONAL(tw); continue; - case CON_ADDLOGVAR: + case concmd_addlogvar: insptr++; { int32_t m = 1; @@ -2787,13 +2795,13 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) continue; } - case CON_IFVARE: + case concmd_ifvare: insptr++; tw = Gv_GetVar(*insptr++); VM_CONDITIONAL(tw == *insptr); continue; - case CON_IFVARVARE: + case concmd_ifvarvare: insptr++; tw = Gv_GetVar(*insptr++); tw = (tw == Gv_GetVar(*insptr++)); diff --git a/source/games/duke/src/zz_gamevars.cpp b/source/games/duke/src/zz_gamevars.cpp index bc0e8f569..518529be1 100644 --- a/source/games/duke/src/zz_gamevars.cpp +++ b/source/games/duke/src/zz_gamevars.cpp @@ -275,7 +275,7 @@ void Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) { g_errorCnt++; C_ReportError(-1); - Printf("%s:%d: error: too many gamevars!\n",g_scriptFileName,g_lineNumber); + Printf("%s:%d: error: too many gamevars!\n",g_scriptFileName,line_count); return; } @@ -283,7 +283,7 @@ void Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) { g_errorCnt++; C_ReportError(-1); - Printf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",g_scriptFileName,g_lineNumber,pszLabel, MAXVARLABEL); + Printf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",g_scriptFileName,line_count,pszLabel, MAXVARLABEL); return; } @@ -295,7 +295,7 @@ void Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) if (EDUKE32_PREDICT_FALSE(aGameVars[gV].flags & (GAMEVAR_PTR_MASK))) { C_ReportError(-1); - Printf("%s:%d: warning: cannot redefine internal gamevar `%s'.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); + Printf("%s:%d: warning: cannot redefine internal gamevar `%s'.\n",g_scriptFileName,line_count,label+(g_labelCnt<<6)); return; } else if (EDUKE32_PREDICT_FALSE(!(aGameVars[gV].flags & GAMEVAR_SYSTEM)))