- Exhumed: did the same for the fish, changed some disassembly names and removed unused fields from enemy structs.

This commit is contained in:
Christoph Oelckers 2020-11-29 20:16:58 +01:00
parent e81dbbdc93
commit b669e5405d
4 changed files with 88 additions and 93 deletions

View file

@ -32,9 +32,7 @@ struct Anubis
short nAction; short nAction;
short nSprite; short nSprite;
short nTarget; short nTarget;
short f; short nCount;
short g;
short h;
}; };
static TArray<Anubis> AnubisList; static TArray<Anubis> AnubisList;
@ -67,9 +65,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, Anubis& w, Anubis*
("action", w.nAction) ("action", w.nAction)
("sprite", w.nSprite) ("sprite", w.nSprite)
("target", w.nTarget) ("target", w.nTarget)
("f", w.f) ("count", w.nCount)
("g", w.g)
("h", w.h)
.EndObject(); .EndObject();
} }
return arc; return arc;
@ -151,7 +147,7 @@ int BuildAnubis(int nSprite, int x, int y, int z, int nSector, int nAngle, uint8
ap->nFrame = 0; ap->nFrame = 0;
ap->nSprite = nSprite; ap->nSprite = nSprite;
ap->nTarget = -1; ap->nTarget = -1;
ap->g = 0; ap->nCount = 0;
sp->owner = runlist_AddRunRec(sp->lotag - 1, nAnubis | 0x90000); sp->owner = runlist_AddRunRec(sp->lotag - 1, nAnubis | 0x90000);
@ -276,13 +272,13 @@ void FuncAnubis(int a, int nDamage, int nRun)
default: default:
{ {
if (ap->g) if (ap->nCount)
{ {
ap->g--; ap->nCount--;
} }
else else
{ {
ap->g = 60; ap->nCount = 60;
if (nTarget > -1) // NOTE: nTarget can be -1. this check wasn't in original code. TODO: demo compatiblity? if (nTarget > -1) // NOTE: nTarget can be -1. this check wasn't in original code. TODO: demo compatiblity?
{ {
@ -308,7 +304,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
if (nTarget == -1) if (nTarget == -1)
{ {
ap->nAction = 0; ap->nAction = 0;
ap->g = 50; ap->nCount = 50;
} }
else else
{ {
@ -405,7 +401,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
{ {
ap->nAction = 0; ap->nAction = 0;
ap->nFrame = 0; ap->nFrame = 0;
ap->g = 100; ap->nCount = 100;
ap->nTarget = -1; ap->nTarget = -1;
sp->xvel = 0; sp->xvel = 0;

View file

@ -25,14 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS BEGIN_PS_NS
enum
{
kMaxFishes = 128,
kMaxChunks = 128
};
short FishCount = 0;
static actionSeq FishSeq[] = { static actionSeq FishSeq[] = {
{8, 0}, {8, 0},
{8, 0}, {8, 0},
@ -46,9 +38,6 @@ static actionSeq FishSeq[] = {
{39, 1} {39, 1}
}; };
short nChunksFree;
int nFreeChunk[kMaxChunks] = { 0 };
struct Fish struct Fish
{ {
@ -57,59 +46,72 @@ struct Fish
short nAction; short nAction;
short nSprite; short nSprite;
short nTarget; short nTarget;
short field_A; short nCount;
short field_C;
short nRun; short nRun;
}; };
struct Chunk struct Chunk
{ {
short nSprite; short nSprite;
short field_2; short nIndex;
short field_4; short nSeqIndex;
short field_6;
}; };
Fish FishList[kMaxFishes]; TArray<Fish> FishList;
Chunk FishChunk[kMaxChunks]; TArray<Chunk> FishChunk;
static SavegameHelper sghfish("fish", FSerializer& Serialize(FSerializer& arc, const char* keyname, Fish& w, Fish* def)
SV(FishCount), {
SV(nChunksFree), if (arc.BeginObject(keyname))
SA(nFreeChunk), {
SA(FishList), arc("health", w.nHealth)
SA(FishChunk), ("frame", w.nFrame)
nullptr); ("action", w.nAction)
("sprite", w.nSprite)
("target", w.nTarget)
("run", w.nRun)
("count", w.nCount)
.EndObject();
}
return arc;
}
FSerializer& Serialize(FSerializer& arc, const char* keyname, Chunk& w, Chunk* def)
{
if (arc.BeginObject(keyname))
{
arc ("sprite", w.nSprite)
("index", w.nIndex)
("seqindex", w.nSeqIndex)
.EndObject();
}
return arc;
}
void SerializeFish(FSerializer& arc)
{
arc("fish", FishList)
("fishchunk", FishChunk);
}
void InitFishes() void InitFishes()
{ {
FishCount = 0; FishList.Clear();
nChunksFree = kMaxChunks; FishChunk.Clear();
for (int i = 0; i < kMaxChunks; i++) {
nFreeChunk[i] = i;
}
} }
int BuildFishLimb(short nFish, short edx) int BuildFishLimb(short nFish, short edx)
{ {
if (nChunksFree <= 0) {
return -1;
}
short nSprite = FishList[nFish].nSprite; short nSprite = FishList[nFish].nSprite;
nChunksFree--; int nFree = FishChunk.Reserve(1);
int nFree = nFreeChunk[nChunksFree];
int nSprite2 = insertsprite(sprite[nSprite].sectnum, 99); int nSprite2 = insertsprite(sprite[nSprite].sectnum, 99);
assert(nSprite2 >= 0 && nSprite2 < kMaxSprites); assert(nSprite2 >= 0 && nSprite2 < kMaxSprites);
FishChunk[nFree].nSprite = nSprite2; FishChunk[nFree].nSprite = nSprite2;
FishChunk[nFree].field_4 = edx + 40; FishChunk[nFree].nSeqIndex = edx + 40;
FishChunk[nFree].field_2 = RandomSize(3) % SeqSize[SeqOffsets[kSeqFish] + edx + 40]; FishChunk[nFree].nIndex = RandomSize(3) % SeqSize[SeqOffsets[kSeqFish] + edx + 40];
sprite[nSprite2].x = sprite[nSprite].x; sprite[nSprite2].x = sprite[nSprite].x;
sprite[nSprite2].y = sprite[nSprite].y; sprite[nSprite2].y = sprite[nSprite].y;
@ -125,7 +127,7 @@ int BuildFishLimb(short nFish, short edx)
sprite[nSprite2].yoffset = 0; sprite[nSprite2].yoffset = 0;
sprite[nSprite2].zvel = (-(RandomByte() + 512)) * 2; sprite[nSprite2].zvel = (-(RandomByte() + 512)) * 2;
seq_GetSeqPicnum(kSeqFish, FishChunk[nFree].field_4, 0); seq_GetSeqPicnum(kSeqFish, FishChunk[nFree].nSeqIndex, 0);
sprite[nSprite2].picnum = edx; sprite[nSprite2].picnum = edx;
sprite[nSprite2].lotag = runlist_HeadRun() + 1; sprite[nSprite2].lotag = runlist_HeadRun() + 1;
@ -151,7 +153,7 @@ void FuncFishLimb(int a, int, int nRun)
short nSprite = FishChunk[nFish].nSprite; short nSprite = FishChunk[nFish].nSprite;
assert(nSprite >= 0 && nSprite < kMaxSprites); assert(nSprite >= 0 && nSprite < kMaxSprites);
int nSeq = SeqOffsets[kSeqFish] + FishChunk[nFish].field_4; int nSeq = SeqOffsets[kSeqFish] + FishChunk[nFish].nSeqIndex;
int nMessage = a & kMessageMask; int nMessage = a & kMessageMask;
@ -159,15 +161,15 @@ void FuncFishLimb(int a, int, int nRun)
{ {
case 0x20000: case 0x20000:
{ {
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, FishChunk[nFish].field_2); sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, FishChunk[nFish].nIndex);
Gravity(nSprite); Gravity(nSprite);
FishChunk[nFish].field_2++; FishChunk[nFish].nIndex++;
if (FishChunk[nFish].field_2 >= SeqSize[nSeq]) if (FishChunk[nFish].nIndex >= SeqSize[nSeq])
{ {
FishChunk[nFish].field_2 = 0; FishChunk[nFish].nIndex = 0;
if (RandomBit()) { if (RandomBit()) {
BuildBlood(sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum); BuildBlood(sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum);
} }
@ -208,7 +210,7 @@ void FuncFishLimb(int a, int, int nRun)
case 0x90000: case 0x90000:
{ {
seq_PlotSequence(a & 0xFFFF, nSeq, FishChunk[nFish].field_2, 1); seq_PlotSequence(a & 0xFFFF, nSeq, FishChunk[nFish].nIndex, 1);
return; return;
} }
} }
@ -216,12 +218,7 @@ void FuncFishLimb(int a, int, int nRun)
int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle) int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
{ {
short nFish = FishCount; int nFish = FishList.Reserve(1);
FishCount++;
if (nFish >= kMaxFishes) {
return -1;
}
if (nSprite == -1) if (nSprite == -1)
{ {
@ -264,7 +261,7 @@ int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
FishList[nFish].nHealth = 200; FishList[nFish].nHealth = 200;
FishList[nFish].nSprite = nSprite; FishList[nFish].nSprite = nSprite;
FishList[nFish].nTarget = -1; FishList[nFish].nTarget = -1;
FishList[nFish].field_C = 60; FishList[nFish].nCount = 60;
FishList[nFish].nFrame = 0; FishList[nFish].nFrame = 0;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nFish | 0x120000); sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nFish | 0x120000);
@ -315,7 +312,7 @@ void DestroyFish(short nFish)
void FuncFish(int a, int nDamage, int nRun) void FuncFish(int a, int nDamage, int nRun)
{ {
short nFish = RunData[nRun].nVal; short nFish = RunData[nRun].nVal;
assert(nFish >= 0 && nFish < kMaxFishes); assert(nFish >= 0 && nFish < (int)FishList.Size());
short nSprite = FishList[nFish].nSprite; short nSprite = FishList[nFish].nSprite;
short nAction = FishList[nFish].nAction; short nAction = FishList[nFish].nAction;
@ -349,7 +346,7 @@ void FuncFish(int a, int nDamage, int nRun)
return; return;
} }
FishList[nFish].field_C = 10; FishList[nFish].nCount = 10;
} }
// fall through // fall through
fallthrough__; fallthrough__;
@ -396,7 +393,7 @@ void FuncFish(int a, int nDamage, int nRun)
FishList[nFish].nAction = 4; FishList[nFish].nAction = 4;
FishList[nFish].nFrame = 0; FishList[nFish].nFrame = 0;
FishList[nFish].field_C += 10; FishList[nFish].nCount += 10;
} }
return; return;
@ -429,8 +426,8 @@ void FuncFish(int a, int nDamage, int nRun)
case 0: case 0:
{ {
FishList[nFish].field_C--; FishList[nFish].nCount--;
if (FishList[nFish].field_C <= 0) if (FishList[nFish].nCount <= 0)
{ {
nTarget = FindPlayer(nSprite, 60); nTarget = FindPlayer(nSprite, 60);
if (nTarget >= 0) if (nTarget >= 0)
@ -442,7 +439,7 @@ void FuncFish(int a, int nDamage, int nRun)
int nAngle = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].z - sprite[nSprite].z); int nAngle = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].z - sprite[nSprite].z);
sprite[nSprite].zvel = bsin(nAngle, -5); sprite[nSprite].zvel = bsin(nAngle, -5);
FishList[nFish].field_C = RandomSize(6) + 90; FishList[nFish].nCount = RandomSize(6) + 90;
} }
else else
{ {
@ -459,8 +456,8 @@ void FuncFish(int a, int nDamage, int nRun)
case 2: case 2:
case 3: case 3:
{ {
FishList[nFish].field_C--; FishList[nFish].nCount--;
if (FishList[nFish].field_C <= 0) if (FishList[nFish].nCount <= 0)
{ {
IdleFish(nFish, 0); IdleFish(nFish, 0);
return; return;

View file

@ -52,8 +52,8 @@ struct Lion
short nAction; short nAction;
short nSprite; short nSprite;
short nTarget; short nTarget;
short _f; short nIndex;
short _g; short nCount;
}; };
Lion LionList[kMaxLions]; Lion LionList[kMaxLions];
@ -121,8 +121,8 @@ int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
LionList[nLion].nFrame = 0; LionList[nLion].nFrame = 0;
LionList[nLion].nSprite = nSprite; LionList[nLion].nSprite = nSprite;
LionList[nLion].nTarget = -1; LionList[nLion].nTarget = -1;
LionList[nLion]._g = 0; LionList[nLion].nCount = 0;
LionList[nLion]._f = nLion; LionList[nLion].nIndex = nLion;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nLion | 0x130000); sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nLion | 0x130000);
@ -220,7 +220,7 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
LionList[nLion].nAction = 5; LionList[nLion].nAction = 5;
LionList[nLion]._g = RandomSize(3); LionList[nLion].nCount = RandomSize(3);
sprite[nSprite].ang = (sprite[nSprite].ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8); // NOTE: no angle mask in original code sprite[nSprite].ang = (sprite[nSprite].ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8); // NOTE: no angle mask in original code
} }
else else
@ -271,7 +271,7 @@ void FuncLion(int a, int nDamage, int nRun)
case 0: case 0:
case 1: case 1:
{ {
if ((LionList[nLion]._f & 0x1F) == (totalmoves & 0x1F)) if ((LionList[nLion].nIndex & 0x1F) == (totalmoves & 0x1F))
{ {
if (nTarget < 0) if (nTarget < 0)
{ {
@ -292,8 +292,8 @@ void FuncLion(int a, int nDamage, int nRun)
if (nAction) if (nAction)
{ {
LionList[nLion]._g--; LionList[nLion].nCount--;
if (LionList[nLion]._g <= 0) if (LionList[nLion].nCount <= 0)
{ {
if (RandomBit()) if (RandomBit())
{ {
@ -307,7 +307,7 @@ void FuncLion(int a, int nDamage, int nRun)
sprite[nSprite].yvel = 0; sprite[nSprite].yvel = 0;
} }
LionList[nLion]._g = 100; LionList[nLion].nCount = 100;
} }
} }
@ -316,7 +316,7 @@ void FuncLion(int a, int nDamage, int nRun)
case 2: case 2:
{ {
if ((totalmoves & 0x1F) == (LionList[nLion]._f & 0x1F)) if ((totalmoves & 0x1F) == (LionList[nLion].nIndex & 0x1F))
{ {
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
@ -388,7 +388,7 @@ void FuncLion(int a, int nDamage, int nRun)
if (nTarget == -1) if (nTarget == -1)
{ {
LionList[nLion].nAction = 1; LionList[nLion].nAction = 1;
LionList[nLion]._g = 50; LionList[nLion].nCount = 50;
} }
else else
{ {
@ -424,11 +424,11 @@ void FuncLion(int a, int nDamage, int nRun)
case 5: // Jump away when damaged case 5: // Jump away when damaged
{ {
LionList[nLion]._g--; LionList[nLion].nCount--;
if (LionList[nLion]._g <= 0) if (LionList[nLion].nCount <= 0)
{ {
sprite[nSprite].zvel = -4000; sprite[nSprite].zvel = -4000;
LionList[nLion]._g = 0; LionList[nLion].nCount = 0;
int x = sprite[nSprite].x; int x = sprite[nSprite].x;
int y = sprite[nSprite].y; int y = sprite[nSprite].y;
@ -492,7 +492,7 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
LionList[nLion].nAction = 7; LionList[nLion].nAction = 7;
sprite[nSprite].ang = (GetWallNormal(nMov & 0x3FFF) + 1024) & kAngleMask; sprite[nSprite].ang = (GetWallNormal(nMov & 0x3FFF) + 1024) & kAngleMask;
LionList[nLion]._g = RandomSize(4); LionList[nLion].nCount = RandomSize(4);
return; return;
} }
else if ((nMov & 0xC000) == 0xC000) else if ((nMov & 0xC000) == 0xC000)
@ -521,11 +521,11 @@ void FuncLion(int a, int nDamage, int nRun)
case 7: case 7:
{ {
LionList[nLion]._g--; LionList[nLion].nCount--;
if (LionList[nLion]._g <= 0) if (LionList[nLion].nCount <= 0)
{ {
LionList[nLion]._g = 0; LionList[nLion].nCount = 0;
if (nTarget > -1) if (nTarget > -1)
{ {
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
@ -588,7 +588,7 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
LionList[nLion].nAction = 1; LionList[nLion].nAction = 1;
LionList[nLion].nFrame = 0; LionList[nLion].nFrame = 0;
LionList[nLion]._g = 100; LionList[nLion].nCount = 100;
LionList[nLion].nTarget = -1; LionList[nLion].nTarget = -1;
sprite[nSprite].xvel = 0; sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0; sprite[nSprite].yvel = 0;

View file

@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS BEGIN_PS_NS
void SerializeAnubis(FSerializer& arc); void SerializeAnubis(FSerializer& arc);
void SerializeFish(FSerializer& arc);
void SerializeSpider(FSerializer& arc); void SerializeSpider(FSerializer& arc);
@ -48,6 +49,7 @@ bool GameInterface::SaveGame()
void GameInterface::SerializeGameState(FSerializer& arc) void GameInterface::SerializeGameState(FSerializer& arc)
{ {
SerializeAnubis(arc); SerializeAnubis(arc);
SerializeFish(arc);
SerializeSpider(arc); SerializeSpider(arc);
} }