From b5b159f45b834c8f71c61057c1289d3abcaeb2ae Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Sep 2022 16:41:17 +0200 Subject: [PATCH] - unlimited and floatified the movesector position array. --- source/games/duke/src/actors.cpp | 2 +- source/games/duke/src/funct.h | 1 - source/games/duke/src/global.cpp | 3 +-- source/games/duke/src/global.h | 3 +-- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/savegame.cpp | 5 ++--- source/games/duke/src/spawn.cpp | 10 ++-------- 7 files changed, 8 insertions(+), 18 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 60e50e32e..63388ed9a 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -280,7 +280,7 @@ void movesector(DDukeActor* const actor, int msindex, DAngle rotation) for(auto& wal : wallsofsector(actor->sector())) { - auto t = rotatepoint({ 0, 0 }, { msx[msindex] * inttoworld, msy[msindex] * inttoworld }, rotation); + auto t = rotatepoint({ 0, 0 }, mspos[msindex], rotation); dragpoint(&wal, actor->spr.pos.XY() + t); msindex++; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 83f964881..5404b4330 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -31,7 +31,6 @@ void movefta(); void clearcameras(int i, player_struct* p); void RANDOMSCRAP(DDukeActor* i); -void ms(DDukeActor* i); void movecrane(DDukeActor* i, int crane); void movefountain(DDukeActor* i, int fountain); void moveflammable(DDukeActor* i, int pool); diff --git a/source/games/duke/src/global.cpp b/source/games/duke/src/global.cpp index 3864b21d2..bea2f7b79 100644 --- a/source/games/duke/src/global.cpp +++ b/source/games/duke/src/global.cpp @@ -83,8 +83,7 @@ int actor_tog; // cheat helper int playerswhenstarted; // why is this needed? int show_shareware; // display only. int rtsplaying; // RTS playback state -int tempwallptr; // msx/y index. -int msx[MAXANIMPOINTS], msy[MAXANIMPOINTS]; +TArray mspos; TArray cranes; bool sound445done; // used in checksectors_r. This was local state inside a function, but this must be maintained globally and serialized diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 9fae17355..63d57707a 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -62,7 +62,6 @@ extern int screenpeek; // Variables that must be saved extern int rtsplaying; -extern int tempwallptr; extern bool sound445done; extern player_struct ps[MAXPLAYERS]; @@ -123,7 +122,7 @@ extern int geocnt; extern short ambientlotag[64]; extern short ambienthitag[64]; extern unsigned ambientfx; -extern int msx[MAXANIMPOINTS], msy[MAXANIMPOINTS]; // todo: unlimit +extern TArray mspos; extern TArray cranes; extern int WindTime, WindDir; extern short fakebubba_spawn, mamaspawn_count, banjosound; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index e535d5b4a..381944c21 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -453,7 +453,7 @@ void resetprestat(int snum,int g) randomseed = 17L; paused = 0; ud.cameraactor =nullptr; - tempwallptr = 0; + mspos.Clear(); cranes.Clear(); camsprite =nullptr; earthquaketime = 0; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index b0f9bcf7a..096717a70 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -372,7 +372,7 @@ void GameInterface::SerializeGameState(FSerializer& arc) ("bomb_tag", ud.bomb_tag) ("rtsplaying", rtsplaying) - ("tempwallptr", tempwallptr) + //("tempwallptr", tempwallptr) ("cranes", cranes) ("sound445done", sound445done) .Array("players", ps, ud.multimode) @@ -425,8 +425,7 @@ void GameInterface::SerializeGameState(FSerializer& arc) ("ambientfx", ambientfx) .Array("ambientlotag", ambientlotag, ambientfx) .Array("ambienthitag", ambienthitag, ambientfx) - .Array("msx", msx, MAXANIMPOINTS) - .Array("msy", msy, MAXANIMPOINTS) + ("mspos", mspos) ("windtime", WindTime) ("winddir", WindDir) ("fakebubba_spawn", fakebubba_spawn) diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 9921f35cf..56e2f9906 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -955,16 +955,10 @@ void spawneffector(DDukeActor* actor, TArray* actors) } } - actor->temp_data[1] = tempwallptr; + actor->temp_data[1] = mspos.Size(); for (auto& wal : wallsofsector(sectp)) { - msx[tempwallptr] = wal.wall_int_pos().X - actor->int_pos().X; - msy[tempwallptr] = wal.wall_int_pos().Y - actor->int_pos().Y; - tempwallptr++; - if (tempwallptr > 2047) - { - I_Error("Too many moving sectors at (%d,%d).\n", int(wal.pos.X), int(wal.pos.Y)); - } + mspos.Push(wal.pos - actor->spr.pos); } if (actor->spr.lotag == SE_30_TWO_WAY_TRAIN || actor->spr.lotag == SE_6_SUBWAY || actor->spr.lotag == SE_14_SUBWAY_CAR || actor->spr.lotag == SE_5_BOSS) {