From 635b53f78f36000956003dfe4d716b56ba9c47ed Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Oct 2020 07:21:33 +0100 Subject: [PATCH] - RR-movement + dummyplayersprite --- source/games/duke/src/actors.cpp | 2 +- source/games/duke/src/actors_d.cpp | 4 +-- source/games/duke/src/gameexec.cpp | 4 +-- source/games/duke/src/player_d.cpp | 6 ++--- source/games/duke/src/player_r.cpp | 43 +++++++++++++++--------------- source/games/duke/src/premap.cpp | 2 +- source/games/duke/src/types.h | 4 +-- 7 files changed, 31 insertions(+), 34 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 63218bd20..364558374 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -371,7 +371,7 @@ void movedummyplayers(void) if ((!isRR() && ps[p].on_crane != nullptr) || sector[ps[p].cursectnum].lotag != 1 || ps->GetActor()->s.extra <= 0) { - ps[p].dummyplayersprite = -1; + ps[p].dummyplayersprite = nullptr; deletesprite(act); continue; } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index a7cbd08c0..5b25fdafc 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1768,7 +1768,7 @@ static void weaponcommon_d(DDukeActor* proj) { auto s = &proj->s; if (s->picnum == COOLEXPLOSION1) - if (!S_CheckSoundPlaying(proj->GetIndex(), WIERDSHOT_FLY)) + if (!S_CheckActorSoundPlaying(proj, WIERDSHOT_FLY)) S_PlayActorSound(WIERDSHOT_FLY, proj); int p = -1; @@ -3598,7 +3598,7 @@ static void handle_se28(DDukeActor* actor) x = ldist(psa, act2); if (x < 768) { - if (S_CheckSoundPlaying(psa->GetIndex(), DUKE_LONGTERM_PAIN) < 1) + if (S_CheckActorSoundPlaying(psa, DUKE_LONGTERM_PAIN) < 1) S_PlayActorSound(DUKE_LONGTERM_PAIN, psa); S_PlayActorSound(SHORT_CIRCUIT, psa); psa->s.extra -= 8 + (krand() & 7); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 4f874c26a..11eb5021b 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -648,8 +648,8 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_DUMMYPLAYERSPRITE: - if (bSet) ps[iPlayer].dummyplayersprite = lValue; - else SetGameVarID((int)lVar2, ps[iPlayer].dummyplayersprite, sActor, sPlayer); + if (bSet) ps[iPlayer].dummyplayersprite = ScriptIndexToActor(lValue); + else SetGameVarID((int)lVar2, ActorToScriptIndex(ps[iPlayer].dummyplayersprite), sActor, sPlayer); break; case PLAYER_EXTRA_EXTRA8: diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 948aaa1da..2890c0cf5 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1746,9 +1746,8 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int { if (p->on_ground == 1) { - if (p->dummyplayersprite == -1) - p->dummyplayersprite = - fi.spawn(pact->GetIndex(), PLAYERONWATER); + if (p->dummyplayersprite == nullptr) + p->dummyplayersprite = spawn(pact, PLAYERONWATER); p->footprintcount = 6; if (sector[p->cursectnum].floorpicnum == FLOORSLIME) @@ -1907,7 +1906,6 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int static void underwater(int snum, ESyncBits actions, int psect, int fz, int cz) { - int j; auto p = &ps[snum]; auto pact = p->GetActor(); int psectlotag = sector[psect].lotag; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index cea98b49a..c370f7bcd 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2157,8 +2157,8 @@ static void onBoat(int snum, ESyncBits &actions) static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int shrunk, int truefdist, int psectlotag) { auto p = &ps[snum]; - auto pi = p->i; - auto s = &sprite[pi]; + auto pact = p->GetActor(); + auto s = &pact->s; if (p->airleft != 15 * 26) p->airleft = 15 * 26; //Aprox twenty seconds. @@ -2182,9 +2182,8 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int { if (p->on_ground == 1) { - if (p->dummyplayersprite == -1) - p->dummyplayersprite = - fi.spawn(pi, PLAYERONWATER); + if (p->dummyplayersprite == nullptr) + p->dummyplayersprite = spawn(pact, PLAYERONWATER); p->footprintcount = 6; if (sector[p->cursectnum].floorpicnum == FLOORSLIME) @@ -2226,15 +2225,15 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int p->moto_bump_fast = 1; p->poszv -= gc * (p->MotoSpeed >> 4); p->MotoOnGround = 0; - if (S_CheckActorSoundPlaying(pi, 188)) - S_StopSound(188, pi); - S_PlayActorSound(189, pi); + if (S_CheckActorSoundPlaying(pact, 188)) + S_StopSound(188, pact); + S_PlayActorSound(189, pact); } else { p->poszv += gc - 80 + (120 - p->MotoSpeed); - if (!S_CheckActorSoundPlaying(pi, 189) && !S_CheckActorSoundPlaying(pi, 190)) - S_PlayActorSound(190, pi); + if (!S_CheckActorSoundPlaying(pact, 189) && !S_CheckActorSoundPlaying(pact, 190)) + S_PlayActorSound(190, pact); } } else @@ -2244,13 +2243,13 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int if (p->poszv > 2400 && p->falling_counter < 255) { p->falling_counter++; - if (p->falling_counter == 38 && !S_CheckActorSoundPlaying(pi, DUKE_SCREAM)) - S_PlayActorSound(DUKE_SCREAM, pi); + if (p->falling_counter == 38 && !S_CheckActorSoundPlaying(pact, DUKE_SCREAM)) + S_PlayActorSound(DUKE_SCREAM, pact); } if ((p->posz + p->poszv) >= (fz - (i << 8))) // hit the ground { - S_StopSound(DUKE_SCREAM, pi); + S_StopSound(DUKE_SCREAM, pact); if (sector[p->cursectnum].lotag != 1) { if (isRRRA()) p->MotoOnGround = 1; @@ -2263,12 +2262,12 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int s->extra -= j - (krand() & 3); if (s->extra <= 0) { - S_PlayActorSound(SQUISHED, pi); + S_PlayActorSound(SQUISHED, pact); } else { - S_PlayActorSound(DUKE_LAND, pi); - S_PlayActorSound(DUKE_LAND_HURT, pi); + S_PlayActorSound(DUKE_LAND, pact); + S_PlayActorSound(DUKE_LAND_HURT, pact); } SetPlayerPal(p, PalEntry(32, 16, 0, 0)); @@ -2277,16 +2276,16 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int { if (p->OnMotorcycle) { - if (S_CheckActorSoundPlaying(pi, 190)) - S_StopSound(pi, 190); - S_PlayActorSound(191, pi); + if (S_CheckActorSoundPlaying(pact, 190)) + S_StopSound(190, pact); + S_PlayActorSound(191, pact); p->TurbCount = 12; } - else S_PlayActorSound(DUKE_LAND, pi); + else S_PlayActorSound(DUKE_LAND, pact); } else if (p->poszv > 1024 && p->OnMotorcycle) { - S_PlayActorSound(DUKE_LAND, pi); + S_PlayActorSound(DUKE_LAND, pact); p->TurbCount = 12; } } @@ -2297,7 +2296,7 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int else { p->falling_counter = 0; - S_StopSound(-1, pi, CHAN_VOICE); + S_StopSound(-1, pact, CHAN_VOICE); if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->poszv > (6144 >> 1)) p->hard_landing = p->poszv >> 10; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 36e506081..805c6d172 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -101,7 +101,7 @@ void resetplayerstats(int snum) // p->select_dir = 0; p->extra_extra8 = 0; p->show_empty_weapon= 0; - p->dummyplayersprite=-1; + p->dummyplayersprite=nullptr; p->crack_time = 0; p->hbomb_hold_delay = 0; p->transporter_hold = 0; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index b89a9e1e3..c6d0ae4c7 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -209,9 +209,9 @@ struct player_struct short i, one_parallax_sectnum; short over_shoulder_on, fist_incs; short cheat_phase; - short dummyplayersprite, extra_extra8, quick_kick, last_quick_kick; + short extra_extra8, quick_kick, last_quick_kick; short heat_amount, timebeforeexit, customexitsound; - DDukeActor* actorsqu, *wackedbyactor, *on_crane, *holoduke_on, *somethingonplayer, *access_spritenum; + DDukeActor* actorsqu, *wackedbyactor, *on_crane, *holoduke_on, *somethingonplayer, *access_spritenum, *dummyplayersprite; short weaprecs[256], weapreccnt; unsigned int interface_toggle_flag;