From 0138f7e333a4ef23cb697f9da0840aeaa4b42b7c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 14 Nov 2021 21:15:51 +0100 Subject: [PATCH] - some smaller stuff. # Conflicts: # source/games/whaven/src/input.cpp --- source/games/whaven/src/ai.cpp | 6 +++--- source/games/whaven/src/ai.h | 4 ++-- source/games/whaven/src/aigonzo.cpp | 19 ++++++++++--------- source/games/whaven/src/animatesprites.cpp | 3 ++- source/games/whaven/src/input.cpp | 22 +++++++++++----------- source/games/whaven/src/whobj.cpp | 10 +++++----- 6 files changed, 33 insertions(+), 31 deletions(-) diff --git a/source/games/whaven/src/ai.cpp b/source/games/whaven/src/ai.cpp index 62287081c..c32ff9990 100644 --- a/source/games/whaven/src/ai.cpp +++ b/source/games/whaven/src/ai.cpp @@ -268,7 +268,7 @@ void aiProcess() { } else if (moveStat.type != kHitNone) { if (moveStat.type == kHitWall) { // hit a wall - actoruse(i); + actoruse(actor); } SetNewStatus(actor, FINDME); } @@ -1203,8 +1203,8 @@ PLAYER* aiGetPlayerTarget(DWHActor* actor) { return &player[pnum]; } -boolean actoruse(short i) { - SPRITE& spr = sprite[i]; +boolean actoruse(DWHActor* actor) { + SPRITE& spr = actor->s(); Neartag nearTag; neartag(spr.x, spr.y, spr.z, spr.sectnum, spr.ang, nearTag, 1024, 3); diff --git a/source/games/whaven/src/ai.h b/source/games/whaven/src/ai.h index 95d436836..811b0cba2 100644 --- a/source/games/whaven/src/ai.h +++ b/source/games/whaven/src/ai.h @@ -136,7 +136,7 @@ extern int checksight_ang; boolean checksight(PLAYER& plr, DWHActor* actor); void monsterweapon(DWHActor*); PLAYER* aiGetPlayerTarget(DWHActor*); -boolean actoruse(short i); +boolean actoruse(DWHActor* i); void initAI(); void aiInit(); @@ -163,7 +163,7 @@ void premapSkeleton(DWHActor* actor); void premapSkully(DWHActor* actor); void premapSpider(DWHActor* actor); void premapWillow(DWHActor* actor); -void deaddude(short sn); +void deaddude(DWHActor* sn); inline int findplayer() { diff --git a/source/games/whaven/src/aigonzo.cpp b/source/games/whaven/src/aigonzo.cpp index 0d874741f..5616f3fac 100644 --- a/source/games/whaven/src/aigonzo.cpp +++ b/source/games/whaven/src/aigonzo.cpp @@ -616,9 +616,9 @@ void gonzoProcess(PLAYER& plr) } } -static short searchpatrol(SPRITE& spr) { +static DWHActor* searchpatrol(SPRITE& spr) { int mindist = 0x7fffffff; - short target = -1; + DWHActor* target = nullptr; WHStatIterator it(ATTACK2); while (auto itActor = it.Next()) @@ -629,7 +629,7 @@ static short searchpatrol(SPRITE& spr) { int dist = abs(tspr.x - spr.x) + abs(tspr.y - spr.y); if (dist < mindist) { mindist = dist; - target = j; + target = itActor; } } @@ -640,9 +640,9 @@ static boolean patrolprocess(PLAYER& plr, DWHActor* actor) { SPRITE& spr = actor->s(); - short target = searchpatrol(spr); - if (target != -1) { - SPRITE& tspr = sprite[target]; + auto target = searchpatrol(spr); + if (target != nullptr) { + SPRITE& tspr = target->s(); if (cansee(tspr.x, tspr.y, tspr.z, tspr.sectnum, spr.x, spr.y, spr.z - (tileHeight(spr.picnum) << 7), spr.sectnum)) { spr.ang = getangle(tspr.x - spr.x, tspr.y - spr.y); @@ -650,7 +650,7 @@ static boolean patrolprocess(PLAYER& plr, DWHActor* actor) } } - return target != -1; + return target != nullptr; } static void gonzopike(DWHActor* actor, PLAYER& plr) { @@ -787,8 +787,9 @@ void premapGonzo(DWHActor* actor) { } } -void deaddude(short sn) { - auto& spr = sprite[sn]; +void deaddude(DWHActor* actor) +{ + auto& spr = actor->s(); auto spawnedactor = InsertActor(spr.sectnum, DEAD); auto& spawned = spawnedactor->s(); diff --git a/source/games/whaven/src/animatesprites.cpp b/source/games/whaven/src/animatesprites.cpp index 7f5412fd4..56fcd5cf6 100644 --- a/source/games/whaven/src/animatesprites.cpp +++ b/source/games/whaven/src/animatesprites.cpp @@ -9,6 +9,7 @@ void analyzesprites(PLAYER& plr, int dasmoothratio,tspritetype* tsprite, int& sp tspritelistcnt = spritesortcnt; for (int i = spritesortcnt - 1; i >= 0; i--) { SPRITE& tspr = tsprite[i]; + auto tactor = &whActors[tspr.owner]; if (plr.nightglowtime <= 0) { if(((tspr.detail != GONZOTYPE && tspr.picnum != GONZOGSHDEAD) || tspr.shade != 31) && tspr.statnum != EVILSPIRIT) @@ -23,7 +24,7 @@ void analyzesprites(PLAYER& plr, int dasmoothratio,tspritetype* tsprite, int& sp tspr.ang = tspr.interpolatedang(dasmoothratio); } - switch (sprite[tspr.owner].detail) { + switch (tactor->s().detail) { case GRONTYPE: if (tspr.picnum == GRONHAL || tspr.picnum == GRONSW || tspr.picnum == GRONSWATTACK || tspr.picnum == GRONMU) { diff --git a/source/games/whaven/src/input.cpp b/source/games/whaven/src/input.cpp index cba3fefeb..1816b29e4 100644 --- a/source/games/whaven/src/input.cpp +++ b/source/games/whaven/src/input.cpp @@ -202,7 +202,7 @@ void processinput(int num) { int oldposx, oldposy; int dist; int feetoffground; - short onsprite = -1; + DWHActor* onsprite = nullptr; PLAYER& plr = player[num]; oldposx = plr.x; @@ -253,10 +253,10 @@ void processinput(int num) { if (lohit.type == kHitSprite) { auto& spr = lohit.actor->s(); if ((spr.z - plr.z) <= (getPlayerHeight() << 8)) - onsprite = lohit.actor->GetSpriteIndex(); + onsprite = lohit.actor; } else - onsprite = -1; + onsprite = nullptr; feetoffground = (plr.sector != -1) ? (plr.Sector()->floorz - plr.z) : 0; @@ -479,16 +479,16 @@ void processinput(int num) { if (abs(plr.plInput.svel) > gi->playerKeyMove() || abs(plr.plInput.fvel) > gi->playerKeyMove()) { dist >>= 2; - if (dist > 0 && feetoffground <= (plr.height << 8) || onsprite != -1) { + if (dist > 0 && feetoffground <= (plr.height << 8) || onsprite != nullptr) { oldhoriz = ((dist * bsinf(PlayClock << 5)) * (1. / 524288.)) * (1. / 4.); plr.horizon.addadjustment(oldhoriz); } else oldhoriz = 0; - if (onsprite != -1 && dist > 50 && lopoint == 1 && justplayed == 0) { + if (onsprite != nullptr && dist > 50 && lopoint == 1 && justplayed == 0) { - switch (sprite[onsprite].picnum) { + switch (onsprite->s().picnum) { case WALLARROW: case OPENCHEST: case GIFTBOX: @@ -527,9 +527,9 @@ void processinput(int num) { break; case SPIDER: // STOMP - spritesound(S_DEADSTEP, &whActors[onsprite]); + spritesound(S_DEADSTEP, onsprite); justplayed = 1; - newstatus(onsprite, DIE); + SetNewStatus(onsprite, DIE); break; case FREDDEAD: @@ -552,11 +552,11 @@ void processinput(int num) { break; } - if (sprite[onsprite].picnum == RAT) + if (onsprite->s().picnum == RAT) { - spritesound(S_RATS1 + (krand() % 2), &whActors[onsprite]); + spritesound(S_RATS1 + (krand() % 2), onsprite); justplayed = 1; - deletesprite(onsprite); + DeleteActor(onsprite); } } diff --git a/source/games/whaven/src/whobj.cpp b/source/games/whaven/src/whobj.cpp index dc6c69615..6a721e3ae 100644 --- a/source/games/whaven/src/whobj.cpp +++ b/source/games/whaven/src/whobj.cpp @@ -1167,7 +1167,7 @@ void newstatus(short sn, int seq) { ChangeActorStat(actor, DEAD); if (spr.pal == 4) { ChangeActorStat(actor, SHADE); - deaddude(sn); + deaddude(actor); } else { ChangeActorStat(actor, DEAD); if (spr.shade < 25) @@ -1183,7 +1183,7 @@ void newstatus(short sn, int seq) { spr.cstat &= ~3; if (spr.pal == 4) { ChangeActorStat(actor, SHADE); - deaddude(sn); + deaddude(actor); } else { ChangeActorStat(actor, DEAD); monsterweapon(actor); @@ -1198,7 +1198,7 @@ void newstatus(short sn, int seq) { spr.cstat &= ~3; if (spr.pal == 4) { ChangeActorStat(actor, SHADE); - deaddude(sn); + deaddude(actor); } else { ChangeActorStat(actor, DEAD); monsterweapon(actor); @@ -1213,7 +1213,7 @@ void newstatus(short sn, int seq) { spr.cstat &= ~3; if (spr.pal == 4) { ChangeActorStat(actor, SHADE); - deaddude(sn); + deaddude(actor); } else { ChangeActorStat(actor, DEAD); monsterweapon(actor); @@ -1240,7 +1240,7 @@ void newstatus(short sn, int seq) { else spr.cstat &= ~1; if (spr.pal == 4) { ChangeActorStat(actor, SHADE); - deaddude(sn); + deaddude(actor); } else { ChangeActorStat(actor, DEAD); monsterweapon(actor);