From 225a2a39da88cbd738f9fcd303a281a6a0b66fee Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 30 Dec 2021 23:04:58 +1100 Subject: [PATCH] - Duke: Replace `player_struct` `noise_*` variables with a vector. --- source/games/duke/src/noise.cpp | 8 ++++---- source/games/duke/src/player.cpp | 4 ++-- source/games/duke/src/premap.cpp | 8 ++++---- source/games/duke/src/savegame.cpp | 4 ++-- source/games/duke/src/types.h | 3 ++- wadsrc/static/zscript/games/duke/dukegame.zs | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/source/games/duke/src/noise.cpp b/source/games/duke/src/noise.cpp index 7031a6e30..568db99c6 100644 --- a/source/games/duke/src/noise.cpp +++ b/source/games/duke/src/noise.cpp @@ -35,8 +35,8 @@ int madenoise(int snum) player_struct *p; p = &ps[snum]; p->donoise = 1; - p->noise_x = p->pos.X; - p->noise_y = p->pos.Y; + p->noise.X = p->pos.X; + p->noise.Y = p->pos.Y; return 1; } @@ -52,8 +52,8 @@ int wakeup(DDukeActor* actor, int snum) radius = p->noise_radius; - if (p->noise_x - radius < actor->spr.pos.X && p->noise_x + radius > actor->spr.pos.X - && p->noise_y - radius < actor->spr.pos.Y && p->noise_y + radius > actor->spr.pos.Y) + if (p->noise.X - radius < actor->spr.pos.X && p->noise.X + radius > actor->spr.pos.X + && p->noise.Y - radius < actor->spr.pos.Y && p->noise.Y + radius > actor->spr.pos.Y) return 1; return 0; } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index b1e1b3a7c..980e31e5f 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -1176,8 +1176,8 @@ DEFINE_FIELD_X(DukePlayer, player_struct, actors_killed) DEFINE_FIELD_X(DukePlayer, player_struct, resurrected) DEFINE_FIELD_X(DukePlayer, player_struct, stairs) DEFINE_FIELD_X(DukePlayer, player_struct, detonate_count) -DEFINE_FIELD_X(DukePlayer, player_struct, noise_x) -DEFINE_FIELD_X(DukePlayer, player_struct, noise_y) +//DEFINE_FIELD_X(DukePlayer, player_struct, noise.X) +//DEFINE_FIELD_X(DukePlayer, player_struct, noise.Y) DEFINE_FIELD_X(DukePlayer, player_struct, noise_radius) DEFINE_FIELD_X(DukePlayer, player_struct, drink_timer) DEFINE_FIELD_X(DukePlayer, player_struct, eat_timer) diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index c8dbe59ab..256a2e8ab 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -170,8 +170,8 @@ void resetplayerstats(int snum) p->fist_incs = 0; p->knee_incs = 0; p->stairs = 0; - p->noise_x = 0; - p->noise_y = 0; + p->noise.X = 0; + p->noise.Y = 0; p->donoise = 0; p->noise_radius = 0; if (isRR() && ud.multimode > 1 && ud.coop != 1) @@ -442,8 +442,8 @@ void resetprestat(int snum,int g) p->stairs = 0; //if (!isRRRA()) p->fogtype = 0; - p->noise_x = 131072; - p->noise_y = 131072; + p->noise.X = 131072; + p->noise.Y = 131072; p->donoise = 0; p->noise_radius = 0; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 42d1a0ac1..72d433e9e 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -227,8 +227,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, // RR from here on ("stairs", w.stairs) ("detonate_count", w.detonate_count) - ("noise_x", w.noise_x) - ("noise_y", w.noise_y) + ("noise.X", w.noise.X) + ("noise.Y", w.noise.Y) ("noise_radius", w.noise_radius) ("drink_timer", w.drink_timer) ("eat_timer", w.eat_timer) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index d3000fd62..f691c8cd9 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -263,7 +263,8 @@ struct player_struct // Items were reordered by size. int stairs; int detonate_count; // at57e - int noise_x, noise_y, noise_radius; // at286, at28a, at290 + vec2_t noise; + int noise_radius; // at286, at28a, at290 int drink_timer; // at58e int eat_timer; // at592 int SlotWin; diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index 11cfd872d..6577f6e18 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -209,7 +209,7 @@ struct DukePlayer // Items were reordered by size. native int stairs; native int detonate_count; // at57e - native int noise_x, noise_y, noise_radius; // at286, at28a, at290 + native int noise_radius; // at286, at28a, at290 native int drink_timer; // at58e native int eat_timer; // at592 native int SlotWin;