From 8972dbe5da56fef4864ba534aeaa04a73d48b33f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 18 Nov 2021 20:55:22 +0100 Subject: [PATCH] - actorstayput --- source/games/duke/src/actors.cpp | 2 +- source/games/duke/src/actors_d.cpp | 2 +- source/games/duke/src/actors_r.cpp | 2 +- source/games/duke/src/gameexec.cpp | 10 +++------- source/games/duke/src/spawn.cpp | 6 +++--- source/games/duke/src/spawn_d.cpp | 4 ++-- source/games/duke/src/spawn_r.cpp | 2 +- source/games/duke/src/types.h | 7 ++++--- 8 files changed, 16 insertions(+), 19 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 35e8fc89d..a77569ba7 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -3169,7 +3169,7 @@ void handle_se30(DDukeActor *actor, int JIBS6) { if (a2->s->statnum == 1 && badguy(a2) && a2->s->picnum != SECTOREFFECTOR && a2->s->picnum != LOCATORS) { - // if(a2->s.sectnum != s->sectnum) + // if(a2->s->sectnum != s->sectnum) { int k = a2->s->sectnum; updatesector(a2->s->x, a2->s->y, &k); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 90744a7aa..d7540953e 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -567,7 +567,7 @@ int movesprite_ex_d(DDukeActor* actor, int xchange, int ychange, int zchange, un // conditional code from hell... if (dasectnum < 0 || (dasectnum >= 0 && - ((actor->actorstayput >= 0 && actor->actorstayput != dasectnum) || + ((actor->actorstayput != nullptr && actor->actorstayput != dasectp) || ((spri->picnum == BOSS2) && spri->pal == 0 && dasectp->lotag != 3) || ((spri->picnum == BOSS1 || spri->picnum == BOSS2) && dasectp->lotag == ST_1_ABOVE_WATER) || (dasectp->lotag == ST_1_ABOVE_WATER && (spri->picnum == LIZMAN || (spri->picnum == LIZTROOP && spri->zvel == 0))) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 20d143b3d..51f3a0b6b 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -402,7 +402,7 @@ int movesprite_ex_r(DDukeActor* actor, int xchange, int ychange, int zchange, un clipmove_ex(&pos, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), clipdist, (4 << 8), (4 << 8), cliptype, result); } - if (dasectnum < 0 || (dasectnum >= 0 && actor->actorstayput >= 0 && actor->actorstayput != dasectnum)) + if (dasectnum < 0 || (dasectnum >= 0 && actor->actorstayput != nullptr && actor->actorstayput != dasectp)) { if (dasectp->lotag == ST_1_ABOVE_WATER) spri->ang = (krand() & 2047); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index cd7c34b40..0fdba3475 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1271,10 +1271,6 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, if (bSet) act->tempang = lValue; else SetGameVarID(lVar2, act->tempang, sActor, sPlayer); break; - case ACTOR_HTACTORSTAYPUT: - if (bSet) act->actorstayput = lValue; - else SetGameVarID(lVar2, act->actorstayput, sActor, sPlayer); - break; case ACTOR_HTDISPICNUM: if (bSet) act->dispicnum = lValue; else SetGameVarID(lVar2, act->dispicnum, sActor, sPlayer); @@ -1525,7 +1521,7 @@ int ParseState::parse(void) break; case concmd_ifactornotstayput: - parseifelse(g_ac->actorstayput == -1); + parseifelse(g_ac->actorstayput == nullptr); break; case concmd_ifcansee: parseifelse(ifcansee(g_ac, g_p)); @@ -1890,7 +1886,7 @@ int ParseState::parse(void) } } else ps[g_p].actors_killed += *insptr; - g_ac->actorstayput = -1; + g_ac->actorstayput = nullptr; insptr++; break; case concmd_lotsofglass: @@ -2256,7 +2252,7 @@ int ParseState::parse(void) g_ac->cgg = 0; g_ac->movflag = 0; g_ac->tempang = 0; - g_ac->actorstayput = -1; + g_ac->actorstayput = nullptr; g_ac->dispicnum = 0; g_ac->SetHitOwner(ps[g_p].GetActor()); g_ac->temp_data[4] = 0; diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index b6e63bbaf..c3c0fb538 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -84,7 +84,7 @@ DDukeActor* EGS(sectortype* whatsectp, int s_x, int s_y, int s_z, int s_pn, int8 act->lastvy = 0; act->timetosleep = 0; - act->actorstayput = -1; + act->actorstayput = nullptr; act->extra = -1; act->cgg = 0; act->movflag = 0; @@ -173,7 +173,7 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_listlastvx = 0; act->lastvy = 0; - act->actorstayput = -1; + act->actorstayput = nullptr; t[0] = t[1] = t[2] = t[3] = t[4] = t[5] = 0; act->temp_actor = nullptr; @@ -262,7 +262,7 @@ void spawninitdefault(DDukeActor* actj, DDukeActor *act) makeitfall(act); if (actorflag(act, SFLAG_BADGUYSTAYPUT)) - act->actorstayput = sp->sectnum; + act->actorstayput = sp->sector(); if (!isRR() || actorflag(act, SFLAG_KILLCOUNT)) // Duke is just like Doom - Bad guys always count as kill. ps[myconnectindex].max_actors_killed++; diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 02e76b5a4..e7d18f4d4 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -63,7 +63,7 @@ int spawn_d(int j, int pn) case BOSS2STAYPUT: case BOSS3STAYPUT: case BOSS5STAYPUT: - act->actorstayput = sp->sectnum; + act->actorstayput = sp->sector(); [[fallthrough]]; case FIREFLY: case BOSS5: @@ -792,7 +792,7 @@ int spawn_d(int j, int pn) case PIGCOPDIVE: case COMMANDERSTAYPUT: case BOSS4STAYPUT: - act->actorstayput = sp->sectnum; + act->actorstayput = sp->sector(); [[fallthrough]]; case BOSS1: case BOSS2: diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 29f4c5b36..3b9e67e49 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -793,7 +793,7 @@ int spawn_r(int j, int pn) case MINIONSTAYPUT: case COOTSTAYPUT: rrra_stayput: - act->actorstayput = sp->sectnum; + act->actorstayput = sp->sector(); [[fallthrough]]; case BOULDER: case BOULDER1: diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index b564d7720..e9ef122f4 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -26,7 +26,7 @@ struct DDukeActor uint8_t spriteextra; // moved here for easier maintenance. This was originally a hacked in field in the sprite structure called 'filler'. short owner; // todo: make a pointer. short picnum, ang, extra, movflag; - short tempang, actorstayput, dispicnum; + short tempang, dispicnum; short timetosleep; int floorz, ceilingz, lastvx, lastvy, aflags; union @@ -37,7 +37,7 @@ struct DDukeActor int temp_data[6]; // Some SE's stored indices in temp_data. For purposes of clarity avoid that. These variables are meant to store these elements now walltype* temp_walls[2]; // SE20 + SE128 - sectortype* temp_sect; + sectortype* temp_sect, *actorstayput; DDukeActor* temp_actor, *seek_actor; spritetype* s; // direct reference to the corresponding sprite. @@ -49,8 +49,9 @@ struct DDukeActor DDukeActor& operator=(const DDukeActor& other) = delete; void clear() { + actorstayput = nullptr; cgg = spriteextra = 0; - picnum = ang = extra = owner = movflag = tempang = actorstayput = dispicnum = timetosleep = 0; + picnum = ang = extra = owner = movflag = tempang = dispicnum = timetosleep = 0; floorz = ceilingz = lastvx = lastvy = aflags = saved_ammo = 0; memset(temp_data, 0, sizeof(temp_data)); }