From e94274a543179c9e5b3b60ca9222e969750fb0c9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 21 Oct 2020 10:48:38 +0200 Subject: [PATCH] - holoduke_on is now a pointer as well. --- source/games/duke/src/actors.cpp | 4 ++-- source/games/duke/src/gameexec.cpp | 8 ++++---- source/games/duke/src/input.cpp | 8 +++++--- source/games/duke/src/player.cpp | 2 +- source/games/duke/src/player_d.cpp | 4 ++-- source/games/duke/src/premap.cpp | 4 ++-- source/games/duke/src/sbar.cpp | 2 +- source/games/duke/src/types.h | 4 ++-- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 5772b4a8d..41bb35b40 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -493,7 +493,7 @@ void moveplayers(void) //Players } else { - if (p->holoduke_on == -1) + if (p->holoduke_on == nullptr) { deletesprite(i); continue; @@ -4974,7 +4974,7 @@ void alterang(int a, int g_i, int g_p) g_sp->ang = WindDir; else if (a & seekplayer) { - j = !isRR()? ps[g_p].holoduke_on : -1; + j = !isRR()? ps[g_p].holoduke_on->GetIndex() : -1; // NOTE: looks like 'owner' is set to target sprite ID... diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 5a8d3f943..5c6a5f5e1 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -732,8 +732,8 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPl break; case PLAYER_HOLODUKE_ON: - if (bSet) ps[iPlayer].holoduke_on = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].holoduke_on, sActor, sPlayer); + if (bSet) ps[iPlayer].holoduke_on = ScriptIndexToActor(lValue); + else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].holoduke_on), sActor, sPlayer); break; case PLAYER_PYCOUNT: @@ -1454,9 +1454,9 @@ static bool ifcansee(int g_i, int g_p) // select sprite for monster to target // if holoduke is on, let them target holoduke first. // - if (ps[g_p].holoduke_on >= 0 && !isRR()) + if (ps[g_p].holoduke_on != nullptr && !isRR()) { - s = &sprite[ps[g_p].holoduke_on]; + s = &ps[g_p].holoduke_on->s; j = cansee(g_sp->x, g_sp->y, g_sp->z - (krand() & ((32 << 8) - 1)), g_sp->sectnum, s->x, s->y, s->z, s->sectnum); diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 02ba7784a..e9127f5c6 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -37,6 +37,7 @@ source as it is released. #include "global.h" #include "gamecontrol.h" #include "v_video.h" +#include "dukeactor.h" BEGIN_DUKE_NS @@ -276,18 +277,19 @@ void hud_input(int snum) { if (!isRR()) { - if (p->holoduke_on == -1) + if (p->holoduke_on == nullptr) { if (p->holoduke_amount > 0) { p->inven_icon = 3; - p->holoduke_on = i = + i = EGS(p->cursectnum, p->posx, p->posy, p->posz + (30 << 8), TILE_APLAYER, -64, 0, 0, p->angle.ang.asbuild(), 0, 0, -1, 10); hittype[i].temp_data[3] = hittype[i].temp_data[4] = 0; + p->holoduke_on = &hittype[i]; sprite[i].yvel = snum; sprite[i].extra = 0; FTA(QUOTE_HOLODUKE_ON, p); @@ -299,7 +301,7 @@ void hud_input(int snum) else { S_PlayActorSound(TELEPORTER, p->holoduke_on); - p->holoduke_on = -1; + p->holoduke_on = nullptr; FTA(QUOTE_HOLODUKE_OFF, p); } } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index dcccf3587..1c998b9d6 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -594,7 +594,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) p->dead_flag = (512 - ((krand() & 1) << 10) + (krand() & 255) - 512) & 2047; p->jetpack_on = 0; - p->holoduke_on = -1; + p->holoduke_on = nullptr; if (!isRR())S_StopSound(DUKE_JETPACK_IDLE, pi); S_StopSound(-1, pi, CHAN_VOICE); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index c616df289..2f572e257 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1465,13 +1465,13 @@ int doincrements_d(struct player_struct* p) } } - if (p->holoduke_on >= 0) + if (p->holoduke_on != nullptr) { p->holoduke_amount--; if (p->holoduke_amount <= 0) { S_PlayActorSound(TELEPORTER, p->i); - p->holoduke_on = -1; + p->holoduke_on = nullptr; checkavailinven(p); } } diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 0cb9738c6..0396a1da8 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -136,7 +136,7 @@ void resetplayerstats(int snum) } p->heat_on = 0; p->jetpack_on = 0; - p->holoduke_on = -1; + p->holoduke_on = nullptr; p->angle.olook_ang = p->angle.look_ang = buildlook(512 - ((currentLevel->levelNumber & 1) << 10)); p->angle.orotscrnang = p->angle.rotscrnang = buildlook(0); @@ -320,7 +320,7 @@ void resetinventory(int snum) p->jetpack_on = 0; p->jetpack_amount = 0; p->shield_amount = max_armour_amount; - p->holoduke_on = -1; + p->holoduke_on = nullptr; p->holoduke_amount = 0; p->firstaid_amount = 0; p->steroids_amount = 0; diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index 9c9bb2930..5a7b1ff28 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -98,7 +98,7 @@ std::pair DDukeCommonStatusBar::ontext(struct player_s switch (p->inven_icon) { case ICON_HOLODUKE: - onstate = p->holoduke_on; + onstate = p->holoduke_on != nullptr; break; case ICON_JETPACK: onstate = p->jetpack_on; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index e6bca36c6..ec2d3d108 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -208,14 +208,14 @@ struct player_struct short cheat_phase; short dummyplayersprite, extra_extra8, quick_kick, last_quick_kick; short heat_amount, timebeforeexit, customexitsound; - DDukeActor* actorsqu, *on_crane;//, *wackedbyactor, *holoduke_on, *somethingonplayer; + DDukeActor* actorsqu, *on_crane, *holoduke_on;//, *wackedbyactor, *somethingonplayer; short weaprecs[256], weapreccnt; unsigned int interface_toggle_flag; short dead_flag, show_empty_weapon; // JBF 20031220: added orotscrnang short scuba_amount, jetpack_amount, steroids_amount, shield_amount; - short holoduke_on, pycount, frag_ps; + short pycount, frag_ps; short transporter_hold, last_full_weapon, footprintshade, boot_amount; unsigned char on_warping_sector, footprintcount;