- Exhumed: same procedure for the Lion.

This commit is contained in:
Christoph Oelckers 2020-11-29 20:26:54 +01:00
parent b669e5405d
commit bd3efcb6c4
2 changed files with 29 additions and 21 deletions

View file

@ -25,11 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS BEGIN_PS_NS
enum { kMaxLions = 40 };
short LionCount = -1;
short MoveHook[kMaxLions];
static actionSeq LionSeq[] = { static actionSeq LionSeq[] = {
{54, 1}, {54, 1},
{18, 0}, {18, 0},
@ -54,30 +49,41 @@ struct Lion
short nTarget; short nTarget;
short nIndex; short nIndex;
short nCount; short nCount;
short nRun;
}; };
Lion LionList[kMaxLions]; TArray<Lion> LionList;
static SavegameHelper sghlion("lion", FSerializer& Serialize(FSerializer& arc, const char* keyname, Lion& w, Lion* def)
SV(LionCount), {
SA(MoveHook), if (arc.BeginObject(keyname))
SA(LionList), {
nullptr); arc("health", w.nHealth)
("frame", w.nFrame)
("action", w.nAction)
("sprite", w.nSprite)
("target", w.nTarget)
("index", w.nIndex)
("count", w.nCount)
("run", w.nRun)
.EndObject();
}
return arc;
}
void SerializeLion(FSerializer& arc)
{
arc("lion", LionList);
}
void InitLion() void InitLion()
{ {
LionCount = kMaxLions; LionList.Clear();
} }
int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle) int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
{ {
LionCount--; auto nLion = LionList.Reserve(1);
short nLion = LionCount;
if (LionCount < 0) {
return -1;
}
if (nSprite == -1) if (nSprite == -1)
{ {
@ -126,7 +132,7 @@ int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nLion | 0x130000); sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nLion | 0x130000);
MoveHook[nLion] = runlist_AddRunRec(NewRun, nLion | 0x130000); LionList[nLion].nRun = runlist_AddRunRec(NewRun, nLion | 0x130000);
nCreaturesTotal++; nCreaturesTotal++;
@ -136,7 +142,7 @@ int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
void FuncLion(int a, int nDamage, int nRun) void FuncLion(int a, int nDamage, int nRun)
{ {
short nLion = RunData[nRun].nVal; short nLion = RunData[nRun].nVal;
assert(nLion >= 0 && nLion < kMaxLions); assert(nLion >= 0 && nLion < (int)LionList.Size());
short nSprite = LionList[nLion].nSprite; short nSprite = LionList[nLion].nSprite;
short nAction = LionList[nLion].nAction; short nAction = LionList[nLion].nAction;
@ -574,7 +580,7 @@ void FuncLion(int a, int nDamage, int nRun)
if (bVal) if (bVal)
{ {
runlist_SubRunRec(sprite[nSprite].owner); runlist_SubRunRec(sprite[nSprite].owner);
runlist_SubRunRec(MoveHook[nLion]); runlist_SubRunRec(LionList[nLion].nRun);
sprite[nSprite].cstat = 0x8000; sprite[nSprite].cstat = 0x8000;
} }
return; return;

View file

@ -31,6 +31,7 @@ BEGIN_PS_NS
void SerializeAnubis(FSerializer& arc); void SerializeAnubis(FSerializer& arc);
void SerializeFish(FSerializer& arc); void SerializeFish(FSerializer& arc);
void SerializeLion(FSerializer& arc);
void SerializeSpider(FSerializer& arc); void SerializeSpider(FSerializer& arc);
@ -50,6 +51,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
{ {
SerializeAnubis(arc); SerializeAnubis(arc);
SerializeFish(arc); SerializeFish(arc);
SerializeLion(arc);
SerializeSpider(arc); SerializeSpider(arc);
} }