From d7604a3160b2086c9122643f009ae839949a9976 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 17 Oct 2020 10:44:00 +0200 Subject: [PATCH] - made on_crane a pointer as well. --- source/games/duke/src/actors.cpp | 12 ++++++------ source/games/duke/src/animatesprites_d.cpp | 2 +- source/games/duke/src/animatesprites_r.cpp | 2 +- source/games/duke/src/gameexec.cpp | 6 +++--- source/games/duke/src/input.cpp | 6 +++--- source/games/duke/src/player_d.cpp | 2 +- source/games/duke/src/player_r.cpp | 2 +- source/games/duke/src/prediction.cpp | 2 +- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/types.h | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index d76583755..5772b4a8d 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -369,7 +369,7 @@ void movedummyplayers(void) auto hti = &hittype[i]; p = sprite[spri->owner].yvel; - if ((!isRR() && ps[p].on_crane >= 0) || sector[ps[p].cursectnum].lotag != 1 || sprite[ps[p].i].extra <= 0) + if ((!isRR() && ps[p].on_crane != nullptr) || sector[ps[p].cursectnum].lotag != 1 || sprite[ps[p].i].extra <= 0) { ps[p].dummyplayersprite = -1; deletesprite(i); @@ -715,8 +715,8 @@ void movecrane(int i, int crane) { auto p = findplayer(s, &x); S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].i); - if (ps[p].on_crane == i) - ps[p].on_crane = -1; + if (ps[p].on_crane == &hittype[i]) + ps[p].on_crane = nullptr; } t[0]++; s->owner = -1; @@ -733,7 +733,7 @@ void movecrane(int i, int crane) if (p >= 0 && ps[p].on_ground) { s->owner = -2; - ps[p].on_crane = i; + ps[p].on_crane = &hittype[i]; S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].i); ps[p].angle.addadjustment(s->ang + 1024); } @@ -802,8 +802,8 @@ void movecrane(int i, int crane) if (j >= 0) { if (s->owner == -2) - if (ps[p].on_crane == i) - ps[p].on_crane = -1; + if (ps[p].on_crane == &hittype[i]) + ps[p].on_crane = nullptr; s->owner = -1; s->picnum = crane; return; diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 287107b7a..431af1b5a 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -403,7 +403,7 @@ void animatesprites_d(int x, int y, int a, int smoothratio) goto PALONLY; } - if (ps[p].on_crane == -1 && (sector[s->sectnum].lotag & 0x7ff) != 1) + if (ps[p].on_crane == nullptr && (sector[s->sectnum].lotag & 0x7ff) != 1) { l = s->z - hittype[ps[p].i].floorz + (3 << 8); if (l > 1024 && s->yrepeat > 32 && s->extra > 0) diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index ea0659b65..74cad6842 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -454,7 +454,7 @@ void animatesprites_r(int x, int y, int a, int smoothratio) goto PALONLY; } - if (ps[p].on_crane == -1 && (sector[s->sectnum].lotag & 0x7ff) != 1) + if (ps[p].on_crane == nullptr && (sector[s->sectnum].lotag & 0x7ff) != 1) { l = s->z - hittype[ps[p].i].floorz + (3 << 8); if (l > 1024 && s->yrepeat > 32 && s->extra > 0) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 6add937e6..5a8d3f943 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -607,8 +607,8 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, int sActor, int sPl break; case PLAYER_ON_CRANE: - if (bSet) ps[iPlayer].on_crane = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].on_crane, sActor, sPlayer); + if (bSet) ps[iPlayer].on_crane = ScriptIndexToActor(lValue); + else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].on_crane), sActor, sPlayer); break; case PLAYER_I: // This is dangerous!!! @@ -2259,7 +2259,7 @@ int ParseState::parse(void) ps[g_p].last_extra = g_sp->extra = max_player_health; ps[g_p].wantweaponfire = -1; ps[g_p].horizon.ohoriz = ps[g_p].horizon.horiz = q16horiz(0); - ps[g_p].on_crane = -1; + ps[g_p].on_crane = nullptr; ps[g_p].frag_ps = g_p; ps[g_p].horizon.ohorizoff = ps[g_p].horizon.horizoff = q16horiz(0); ps[g_p].opyoff = 0; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 1aa64a3b7..02ba7784a 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -477,7 +477,7 @@ void hud_input(int snum) } } - if (PlayerInput(snum, SB_TURNAROUND) && p->angle.spin.asbam() == 0 && p->on_crane < 0) + if (PlayerInput(snum, SB_TURNAROUND) && p->angle.spin.asbam() == 0 && p->on_crane == nullptr) { SetGameVarID(g_iReturnVarID, 0, -1, snum); OnEvent(EVENT_TURNAROUND, -1, snum, -1); @@ -827,7 +827,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle) } else { - if (p->on_crane < 0) + if (p->on_crane == nullptr) { if (!vehicle) { @@ -843,7 +843,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle) loc.svel = input.svel = 0; } - if (p->on_crane < 0 && p->newowner == -1) + if (p->on_crane == nullptr && p->newowner == -1) { // input.avel already added to loc in processMovement() loc.avel = clamp(loc.avel, -MAXANGVEL, MAXANGVEL); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index ee3b42faa..c616df289 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2844,7 +2844,7 @@ void processinput_d(int snum) checklook(snum,actions); - if (p->on_crane >= 0) + if (p->on_crane != nullptr) goto HORIZONLY; playerweaponsway(p, s); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 99594643e..05cae826d 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3701,7 +3701,7 @@ void processinput_r(int snum) checklook(snum, actions); - if (p->on_crane >= 0) + if (p->on_crane != nullptr) goto HORIZONLY; playerweaponsway(p, s); diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index 0f3297a88..7829a1da9 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -212,7 +212,7 @@ void fakedomovethings(void) doubvel = TICSPERFRAME; - if(p->on_crane >= 0) goto FAKEHORIZONLY; + if(p->on_crane != nullptr) goto FAKEHORIZONLY; if(p->angle.spin.asbam() < 0) myang += 128; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 0b25c2810..0cb9738c6 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -152,7 +152,7 @@ void resetplayerstats(int snum) p->somethingonplayer =-1; p->angle.spin = bamlook(0); - p->on_crane = -1; + p->on_crane = nullptr; if(p->curr_weapon == PISTOL_WEAPON) p->okickback_pic = p->kickback_pic = isRR()? 22 : 5; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index d7314aa8a..e6bca36c6 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -203,12 +203,12 @@ struct player_struct short jumping_counter, airleft, knee_incs, access_incs; short ftq, access_wallnum, access_spritenum; short got_access, weapon_ang, firstaid_amount; - short somethingonplayer, on_crane, i, one_parallax_sectnum; + short somethingonplayer, 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, *on_crane;//, *wackedbyactor, *holoduke_on, *somethingonplayer; short weaprecs[256], weapreccnt; unsigned int interface_toggle_flag;