- some smaller changes.

This commit is contained in:
Christoph Oelckers 2021-10-22 00:08:40 +02:00
parent ee03eb1b3d
commit 3a5ea07951
9 changed files with 53 additions and 57 deletions

View file

@ -174,7 +174,7 @@ void DoClockBeep()
ExhumedStatIterator it(407); ExhumedStatIterator it(407);
while (auto i = it.Next()) while (auto i = it.Next())
{ {
PlayFX2(StaticSound[kSound74], i->GetSpriteIndex()); PlayFX2(StaticSound[kSound74], i);
} }
} }
@ -641,7 +641,7 @@ void SerializeState(FSerializer& arc)
("bsnakecam", bSnakeCam) ("bsnakecam", bSnakeCam)
("slipmode", bSlipMode) ("slipmode", bSlipMode)
("PlayClock", PlayClock) ("PlayClock", PlayClock)
("spiritsprite", nSpiritSprite) ("spiritsprite", pSpiritSprite)
.EndObject(); .EndObject();
} }
} }

View file

@ -114,7 +114,7 @@ extern short nEnergyTowers;
extern short nEnergyChan; extern short nEnergyChan;
extern short nSpiritSprite; extern DExhumedActor* pSpiritSprite;
extern short bInDemo; extern short bInDemo;

View file

@ -252,7 +252,7 @@ void ResetSwordSeqs()
WeaponInfo[kWeaponSword].b[3] = 7; WeaponInfo[kWeaponSword].b[3] = 7;
} }
int CheckCloseRange(short nPlayer, int *x, int *y, int *z, short *nSector) Collision CheckCloseRange(short nPlayer, int *x, int *y, int *z, short *nSector)
{ {
short hitSect, hitWall, hitSprite; short hitSect, hitWall, hitSprite;
int hitX, hitY, hitZ; int hitX, hitY, hitZ;
@ -285,9 +285,10 @@ int CheckCloseRange(short nPlayer, int *x, int *y, int *z, short *nSector)
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__); DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
sqrtNum = INT_MAX; sqrtNum = INT_MAX;
} }
Collision c(0);
if (ksqrt(sqrtNum) >= ecx) if (ksqrt(sqrtNum) >= ecx)
return 0; return c;
*x = hitX; *x = hitX;
*y = hitY; *y = hitY;
@ -295,13 +296,13 @@ int CheckCloseRange(short nPlayer, int *x, int *y, int *z, short *nSector)
*nSector = hitSect; *nSector = hitSect;
if (hitSprite > -1) { if (hitSprite > -1) {
return hitSprite | 0xC000; c.setSprite(&exhumedActors[hitSprite]);
} }
if (hitWall > -1) { if (hitWall > -1) {
return hitWall | 0x8000; c.setWall(hitWall);
} }
return 0; return c;
} }
void CheckClip(short nPlayer) void CheckClip(short nPlayer)
@ -727,9 +728,9 @@ loc_flag:
var_28 = 9; var_28 = 9;
} }
int cRange = CheckCloseRange(nPlayer, &theX, &theY, &theZ, &nSectorB); auto cRange = CheckCloseRange(nPlayer, &theX, &theY, &theZ, &nSectorB);
if (cRange) if (cRange.type != kHitNone)
{ {
short nDamage = BulletInfo[kWeaponSword].nDamage; short nDamage = BulletInfo[kWeaponSword].nDamage;
@ -737,17 +738,16 @@ loc_flag:
nDamage *= 2; nDamage *= 2;
} }
if ((cRange & 0xC000) >= 0x8000) //if (cRange.type != kHitNone)
{ {
if ((cRange & 0xC000) == 0x8000) // hit wall if (cRange.type == kHitWall)
{ {
// loc_2730E: // loc_2730E:
var_28 += 2; var_28 += 2;
} }
else if ((cRange & 0xC000) == 0xC000) // hit sprite else if (cRange.type == kHitSprite)
{ {
//short nSprite2 = cRange & 0x3FFF; auto pActor2 = cRange.actor;
auto pActor2 = &exhumedActors[cRange & 0x3FFF];
auto pSprite2 = &pActor2->s(); auto pSprite2 = &pActor2->s();
if (pSprite2->cstat & 0x50) if (pSprite2->cstat & 0x50)

View file

@ -88,7 +88,7 @@ uint8_t LoadLevel(MapRecord* map)
nCreaturesKilled = 0; nCreaturesKilled = 0;
nCreaturesTotal = 0; nCreaturesTotal = 0;
nFreeze = 0; nFreeze = 0;
nSpiritSprite = -1; pSpiritSprite = nullptr;
PlayClock = 0; PlayClock = 0;
memset(Counters, 0, sizeof(Counters)); memset(Counters, 0, sizeof(Counters));
@ -319,9 +319,8 @@ void InitSectFlag()
} }
} }
void ProcessSpriteTag(short nSprite, short nLotag, short nHitag) void ProcessSpriteTag(DExhumedActor* pActor, short nLotag, short nHitag)
{ {
auto pActor = &exhumedActors[nSprite];
auto pSprite = &pActor->s(); auto pSprite = &pActor->s();
int nChannel = runlist_AllocChannel(nHitag % 1000); int nChannel = runlist_AllocChannel(nHitag % 1000);
@ -776,7 +775,7 @@ void ProcessSpriteTag(short nSprite, short nLotag, short nHitag)
} }
case kTagRamses: // Ramses head case kTagRamses: // Ramses head
{ {
nSpiritSprite = nSprite; pSpiritSprite = pActor;
pSprite->cstat |= 0x8000; pSprite->cstat |= 0x8000;
return; return;
} }
@ -812,7 +811,7 @@ void ExamineSprites()
pSprite->lotag = 0; pSprite->lotag = 0;
pSprite->hitag = 0; pSprite->hitag = 0;
ProcessSpriteTag(ac->GetSpriteIndex(), lotag, hitag); ProcessSpriteTag(ac, lotag, hitag);
} }
else else
{ {

View file

@ -630,7 +630,7 @@ int CheckSectorSprites(short nSector, int nVal)
b = 1; b = 1;
runlist_DamageEnemy(pActor->GetSpriteIndex(), -1, 5); runlist_DamageEnemy(pActor, nullptr, 5);
if (pSprite->statnum == 100 && PlayerList[GetPlayerFromActor(pActor)].nHealth <= 0) if (pSprite->statnum == 100 && PlayerList[GetPlayerFromActor(pActor)].nHealth <= 0)
{ {

View file

@ -943,7 +943,7 @@ void AIPlayer::Tick(RunListEvent* ev)
{ {
if (nTotalPlayers <= 1) if (nTotalPlayers <= 1)
{ {
auto ang = GetAngleToSprite(pPlayerActor, &exhumedActors[nSpiritSprite]) & kAngleMask; auto ang = GetAngleToSprite(pPlayerActor, pSpiritSprite) & kAngleMask;
PlayerList[nPlayer].angle.settarget(ang, true); PlayerList[nPlayer].angle.settarget(ang, true);
pPlayerSprite->ang = ang; pPlayerSprite->ang = ang;
@ -1085,7 +1085,7 @@ void AIPlayer::Tick(RunListEvent* ev)
{ {
if (PlayerList[nPlayer].nPlayerPushSect > -1) if (PlayerList[nPlayer].nPlayerPushSect > -1)
{ {
StopSpriteSound(sBlockInfo[sector[PlayerList[nPlayer].nPlayerPushSect].extra].nSprite); StopActorSound(&exhumedActors[sBlockInfo[sector[PlayerList[nPlayer].nPlayerPushSect].extra].nSprite]);
} }
PlayerList[nPlayer].nPlayerPushSound = -1; PlayerList[nPlayer].nPlayerPushSound = -1;

View file

@ -57,7 +57,7 @@ short word_964EC = 10;
short nSpiritRepeatX; short nSpiritRepeatX;
short nSpiritRepeatY; short nSpiritRepeatY;
short nSpiritSprite; DExhumedActor* pSpiritSprite;
short nPixelsToShow; short nPixelsToShow;
short nTalkTime = 0; short nTalkTime = 0;
@ -65,18 +65,19 @@ short nTalkTime = 0;
void InitSpiritHead() void InitSpiritHead()
{ {
nPixels = 0; nPixels = 0;
auto pSpiritSprite = &sprite[nSpiritSprite]; auto pSpiritSpr = &pSpiritSprite->s();
nSpiritRepeatX = pSpiritSprite->xrepeat; nSpiritRepeatX = pSpiritSpr->xrepeat;
nSpiritRepeatY = pSpiritSprite->yrepeat; nSpiritRepeatY = pSpiritSpr->yrepeat;
tileLoad(kTileRamsesNormal); // Ramses Normal Head tileLoad(kTileRamsesNormal); // Ramses Normal Head
for (int i = 0; i < kMaxSprites; i++) ExhumedSpriteIterator it;
while (auto act = it.Next())
{ {
if (sprite[i].statnum) if (act->s().statnum)
{ {
sprite[i].cstat |= 0x8000; act->s().cstat |= 0x8000;
} }
} }
@ -116,16 +117,16 @@ void InitSpiritHead()
} }
pSpiritSprite->yrepeat = 140; pSpiritSpr->yrepeat = 140;
pSpiritSprite->xrepeat = 140; pSpiritSpr->xrepeat = 140;
pSpiritSprite->picnum = kTileRamsesWorkTile; pSpiritSpr->picnum = kTileRamsesWorkTile;
nHeadStage = 0; nHeadStage = 0;
// work tile is twice as big as the normal head size // work tile is twice as big as the normal head size
Worktile = TileFiles.tileCreate(kTileRamsesWorkTile, kSpiritY * 2, kSpiritX * 2); Worktile = TileFiles.tileCreate(kTileRamsesWorkTile, kSpiritY * 2, kSpiritX * 2);
pSpiritSprite->cstat &= 0x7FFF; pSpiritSpr->cstat &= 0x7FFF;
nHeadTimeStart = PlayClock; nHeadTimeStart = PlayClock;
@ -197,7 +198,7 @@ void CopyHeadToWorkTile(short nTile)
void DoSpiritHead() void DoSpiritHead()
{ {
static short dimSectCount = 0; static short dimSectCount = 0;
auto pSpiritSprite = &sprite[nSpiritSprite]; auto pSpiritSpr = &pSpiritSprite->s();
sPlayerInput[0].actions |= SB_CENTERVIEW; sPlayerInput[0].actions |= SB_CENTERVIEW;
TileFiles.InvalidateTile(kTileRamsesWorkTile); TileFiles.InvalidateTile(kTileRamsesWorkTile);
@ -297,11 +298,11 @@ void DoSpiritHead()
case 1: case 1:
case 2: case 2:
UpdateSwirlies(); UpdateSwirlies();
if (pSpiritSprite->shade > -127) if (pSpiritSpr->shade > -127)
pSpiritSprite->shade--; pSpiritSpr->shade--;
if (--dimSectCount < 0) if (--dimSectCount < 0)
{ {
DimSector(pSpiritSprite->sectnum); DimSector(pSpiritSpr->sectnum);
dimSectCount = 5; dimSectCount = 5;
} }
@ -381,17 +382,17 @@ void DoSpiritHead()
if (nHeadStage == 1) if (nHeadStage == 1)
{ {
if (pSpiritSprite->xrepeat > nSpiritRepeatX) if (pSpiritSpr->xrepeat > nSpiritRepeatX)
{ {
pSpiritSprite->xrepeat -= 2; pSpiritSpr->xrepeat -= 2;
if (pSpiritSprite->xrepeat < nSpiritRepeatX) if (pSpiritSpr->xrepeat < nSpiritRepeatX)
pSpiritSprite->xrepeat = (uint8_t)nSpiritRepeatX; pSpiritSpr->xrepeat = (uint8_t)nSpiritRepeatX;
} }
if (pSpiritSprite->yrepeat > nSpiritRepeatY) if (pSpiritSpr->yrepeat > nSpiritRepeatY)
{ {
pSpiritSprite->yrepeat -= 2; pSpiritSpr->yrepeat -= 2;
if (pSpiritSprite->yrepeat < nSpiritRepeatY) if (pSpiritSpr->yrepeat < nSpiritRepeatY)
pSpiritSprite->yrepeat = (uint8_t)nSpiritRepeatY; pSpiritSpr->yrepeat = (uint8_t)nSpiritRepeatY;
} }
int nCount = 0; int nCount = 0;
@ -427,9 +428,9 @@ void DoSpiritHead()
if (nCount < (15 * nPixels) / 16) { if (nCount < (15 * nPixels) / 16) {
SoundBigEntrance(); SoundBigEntrance();
AddGlow(pSpiritSprite->sectnum, 20); AddGlow(pSpiritSpr->sectnum, 20);
AddFlash(pSpiritSprite->sectnum, pSpiritSprite->x, pSpiritSprite->y, AddFlash(pSpiritSpr->sectnum, pSpiritSpr->x, pSpiritSpr->y,
pSpiritSprite->z, 128); pSpiritSpr->z, 128);
nHeadStage = 3; nHeadStage = 3;
TintPalette(255, 255, 255); TintPalette(255, 255, 255);
CopyHeadToWorkTile(kTileRamsesNormal); CopyHeadToWorkTile(kTileRamsesNormal);

View file

@ -771,10 +771,10 @@ void UpdateCreepySounds()
// //
//========================================================================== //==========================================================================
void StopSpriteSound(short nSprite) void StopActorSound(DExhumedActor *pActor)
{ {
if (nSprite >= 0 && nSprite < MAXSPRITES) if (pActor)
soundEngine->StopSound(SOURCE_Actor, &sprite[nSprite], -1); soundEngine->StopSound(SOURCE_Actor, &pActor->s(), -1);
} }
void StopAllSounds(void) void StopAllSounds(void)

View file

@ -147,11 +147,7 @@ inline void D3PlayFX(unsigned short nSound, DExhumedActor* actor, short flags =
PlayFX2(nSound, actor->GetSpriteIndex(), 0, CHANF_NONE, flags); PlayFX2(nSound, actor->GetSpriteIndex(), 0, CHANF_NONE, flags);
} }
void StopSpriteSound(short nSprite); void StopActorSound(DExhumedActor* actor);
inline void StopActorSound(DExhumedActor* actor)
{
if (actor) StopSpriteSound(actor->GetSpriteIndex());
}
void StartSwirlies(); void StartSwirlies();
void UpdateSwirlies(); void UpdateSwirlies();