From 29b08b2115214e9a0fd8299de935007e874a5ea8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Oct 2020 06:34:25 +0100 Subject: [PATCH] - access_spritenum --- source/games/duke/src/gameexec.cpp | 4 ++-- source/games/duke/src/hudweapon_d.cpp | 4 ++-- source/games/duke/src/player_d.cpp | 20 +++++++++++--------- source/games/duke/src/player_r.cpp | 14 +++++++------- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/sectors_d.cpp | 3 ++- source/games/duke/src/sectors_r.cpp | 3 ++- source/games/duke/src/types.h | 4 ++-- 8 files changed, 29 insertions(+), 25 deletions(-) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 4460e1da6..284d59e8c 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -578,8 +578,8 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_ACCESS_SPRITENUM: - if (bSet) ps[iPlayer].access_spritenum = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].access_spritenum, sActor, sPlayer); + if (bSet) ps[iPlayer].access_spritenum = ScriptIndexToActor(lValue); + else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].access_spritenum), sActor, sPlayer); break; case PLAYER_KICKBACK_PIC: diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index daa2db245..090a25efc 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -247,8 +247,8 @@ int animateaccess(int gs,int snum,double hard_landing,double look_anghalf,double looking_arc = access_y[ps[snum].access_incs] + (fabs(look_anghalf) / 4.5); looking_arc -= hard_landing * 8.; - if(ps[snum].access_spritenum >= 0) - p = sprite[ps[snum].access_spritenum].pal; + if(ps[snum].access_spritenum != nullptr) + p = ps[snum].access_spritenum->s.pal; else p = 0; if((ps[snum].access_incs-3) > 0 && (ps[snum].access_incs-3)>>3) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 01d3fcfe3..097e03a1c 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1291,10 +1291,10 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum if (j == HANDBOMB_WEAPON && p->ammo_amount[HANDBOMB_WEAPON] == 0) { - StatIterator it(STAT_ACTOR); - while ((k = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_ACTOR); + while (auto act = it.Next()) { - if (sprite[k].picnum == HEAVYHBOMB && sprite[k].owner == p->i) + if (act->s.picnum == HEAVYHBOMB && act->GetOwner() == p->GetActor()) { p->gotweapon.Set(HANDBOMB_WEAPON); j = HANDREMOTE_WEAPON; @@ -1515,16 +1515,16 @@ int doincrements_d(struct player_struct* p) p->access_incs = 12; if (p->access_incs == 12) { - if (p->access_spritenum >= 0) + if (p->access_spritenum != nullptr) { - fi.checkhitswitch(snum, p->access_spritenum, 1); - switch (sprite[p->access_spritenum].pal) + fi.checkhitswitch(snum, p->access_spritenum->GetIndex(), 1); + switch (p->access_spritenum->s.pal) { case 0:p->got_access &= (0xffff - 0x1); break; case 21:p->got_access &= (0xffff - 0x2); break; case 23:p->got_access &= (0xffff - 0x4); break; } - p->access_spritenum = -1; + p->access_spritenum = nullptr; } else { @@ -2613,7 +2613,8 @@ static void processweapon(int snum, ESyncBits actions, int psect) { auto p = &ps[snum]; int pi = p->i; - auto s = &sprite[pi]; + auto pact = p->GetActor(); + auto s = &pact->s; int shrunk = (s->yrepeat < 32); // Set maximum for pistol slightly higher if playing with `cl_showmagamount 1`. @@ -2721,7 +2722,8 @@ void processinput_d(int snum) p = &ps[snum]; pi = p->i; - s = &sprite[pi]; + auto pact = p->GetActor(); + s = &pact->s; p->horizon.resetadjustment(); p->angle.resetadjustment(); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 42317e578..cea98b49a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1054,10 +1054,10 @@ void selectweapon_r(int snum, int weap) if (j == DYNAMITE_WEAPON && p->ammo_amount[DYNAMITE_WEAPON] == 0) { - StatIterator it(STAT_ACTOR); - while ((k = it.NextIndex()) >= 0) + DukeStatIterator it(STAT_ACTOR); + while (auto act = it.Next()) { - if (sprite[k].picnum == HEAVYHBOMB && sprite[k].owner == p->i) + if (act->s.picnum == HEAVYHBOMB && act->GetOwner() == p->GetActor()) { p->gotweapon.Set(DYNAMITE_WEAPON); j = THROWINGDYNAMITE_WEAPON; @@ -1367,16 +1367,16 @@ int doincrements_r(struct player_struct* p) p->access_incs = 12; if (p->access_incs == 12) { - if (p->access_spritenum >= 0) + if (p->access_spritenum != nullptr) { - fi.checkhitswitch(snum, p->access_spritenum, 1); - switch (sprite[p->access_spritenum].pal) + fi.checkhitswitch(snum, p->access_spritenum->GetIndex(), 1); + switch (p->access_spritenum->s.pal) { case 0:p->keys[1] = 1; break; case 21:p->keys[2] = 1; break; case 23:p->keys[3] = 1; break; } - p->access_spritenum = -1; + p->access_spritenum = nullptr; } else { diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index c2ac4d863..36e506081 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -121,7 +121,7 @@ void resetplayerstats(int snum) p->airleft = 15*26; p->rapid_fire_hold = 0; p->toggle_key_flag = 0; - p->access_spritenum = -1; + p->access_spritenum = nullptr; if(ud.multimode > 1 && ud.coop != 1 ) p->got_access = 7; else p->got_access = 0; diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 0a918a3b7..d41ad0023 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -233,6 +233,7 @@ bool checkhitswitch_d(int snum, int w, int switchtype) correctdips = 1; numdips = 0; + auto act = &hittype[w]; if (switchtype == SWITCH_SPRITE) // A wall sprite { lotag = sprite[w].lotag; @@ -309,7 +310,7 @@ bool checkhitswitch_d(int snum, int w, int switchtype) if (switchtype == SWITCH_WALL) ps[snum].access_wallnum = w; else - ps[snum].access_spritenum = w; + ps[snum].access_spritenum = act; } return 0; diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 3da8c3bf3..513413b78 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -353,6 +353,7 @@ bool checkhitswitch_r(int snum, int w, int switchtype) correctdips = 1; numdips = 0; + auto act = &hittype[w]; if (switchtype == 1) // A wall sprite { lotag = sprite[w].lotag; if (lotag == 0) return 0; @@ -423,7 +424,7 @@ bool checkhitswitch_r(int snum, int w, int switchtype) if (switchtype == 0) ps[snum].access_wallnum = w; else - ps[snum].access_spritenum = w; + ps[snum].access_spritenum = act; } return 0; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 584511a3e..b89a9e1e3 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -204,14 +204,14 @@ struct player_struct short curr_weapon, last_weapon, tipincs, wantweaponfire; short holoduke_amount, newowner, hurt_delay, hbomb_hold_delay; short jumping_counter, airleft, knee_incs, access_incs; - short ftq, access_wallnum, access_spritenum; + short ftq, access_wallnum; short got_access, weapon_ang, firstaid_amount; short i, one_parallax_sectnum; short over_shoulder_on, fist_incs; short cheat_phase; short dummyplayersprite, extra_extra8, quick_kick, last_quick_kick; short heat_amount, timebeforeexit, customexitsound; - DDukeActor* actorsqu, *wackedbyactor, *on_crane, *holoduke_on, *somethingonplayer; + DDukeActor* actorsqu, *wackedbyactor, *on_crane, *holoduke_on, *somethingonplayer, *access_spritenum; short weaprecs[256], weapreccnt; unsigned int interface_toggle_flag;