mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-14 11:50:49 +00:00
- Exhumed: Anims and Player.
This commit is contained in:
parent
531d7c96b4
commit
262af72235
4 changed files with 141 additions and 89 deletions
|
@ -31,10 +31,14 @@ struct Anim
|
||||||
short field_2;
|
short field_2;
|
||||||
short field_4;
|
short field_4;
|
||||||
short nSprite;
|
short nSprite;
|
||||||
|
|
||||||
|
short AnimRunRec;
|
||||||
|
uint8_t AnimFlags;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Anim AnimList[];
|
enum { kMaxAnims = 400 };
|
||||||
extern uint8_t AnimFlags[];
|
extern FreeListArray<Anim, kMaxAnims> AnimList;
|
||||||
|
|
||||||
void InitAnims();
|
void InitAnims();
|
||||||
void DestroyAnim(int nAnim);
|
void DestroyAnim(int nAnim);
|
||||||
|
|
|
@ -25,37 +25,42 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
BEGIN_PS_NS
|
BEGIN_PS_NS
|
||||||
|
|
||||||
enum { kMaxAnims = 400 };
|
|
||||||
|
|
||||||
short nMagicSeq = -1;
|
short nMagicSeq = -1;
|
||||||
short nPreMagicSeq = -1;
|
short nPreMagicSeq = -1;
|
||||||
short nSavePointSeq = -1;
|
short nSavePointSeq = -1;
|
||||||
short nAnimsFree = 0;
|
FreeListArray<Anim, kMaxAnims> AnimList;
|
||||||
|
|
||||||
short AnimRunRec[kMaxAnims];
|
|
||||||
short AnimsFree[kMaxAnims];
|
|
||||||
Anim AnimList[kMaxAnims];
|
|
||||||
uint8_t AnimFlags[kMaxAnims];
|
|
||||||
|
|
||||||
static SavegameHelper sghanims("anims",
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, Anim& w, Anim* def)
|
||||||
SV(nMagicSeq),
|
{
|
||||||
SV(nPreMagicSeq),
|
if (arc.BeginObject(keyname))
|
||||||
SV(nSavePointSeq),
|
{
|
||||||
SV(nAnimsFree),
|
arc("seq", w.nSeq)
|
||||||
SA(AnimRunRec),
|
("val1", w.field_2)
|
||||||
SA(AnimsFree),
|
("val2", w.field_4)
|
||||||
SA(AnimList),
|
("sprite", w.nSprite)
|
||||||
SA(AnimFlags),
|
("runrec", w.AnimRunRec)
|
||||||
nullptr);
|
("flags", w.AnimFlags)
|
||||||
|
.EndObject();
|
||||||
|
}
|
||||||
|
return arc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerializeAnim(FSerializer& arc)
|
||||||
|
{
|
||||||
|
if (arc.BeginObject("anims"))
|
||||||
|
{
|
||||||
|
arc("magic", nMagicSeq)
|
||||||
|
("premagic", nPreMagicSeq)
|
||||||
|
("savepoint", nSavePointSeq)
|
||||||
|
("list", AnimList)
|
||||||
|
.EndObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InitAnims()
|
void InitAnims()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < kMaxAnims; i++) {
|
AnimList.Clear();
|
||||||
AnimsFree[i] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
nAnimsFree = kMaxAnims;
|
|
||||||
|
|
||||||
nMagicSeq = SeqOffsets[kSeqItems] + 21;
|
nMagicSeq = SeqOffsets[kSeqItems] + 21;
|
||||||
nPreMagicSeq = SeqOffsets[kSeqMagic2];
|
nPreMagicSeq = SeqOffsets[kSeqMagic2];
|
||||||
nSavePointSeq = SeqOffsets[kSeqItems] + 12;
|
nSavePointSeq = SeqOffsets[kSeqItems] + 12;
|
||||||
|
@ -68,25 +73,21 @@ void DestroyAnim(int nAnim)
|
||||||
if (nSprite >= 0)
|
if (nSprite >= 0)
|
||||||
{
|
{
|
||||||
StopSpriteSound(nSprite);
|
StopSpriteSound(nSprite);
|
||||||
runlist_SubRunRec(AnimRunRec[nAnim]);
|
runlist_SubRunRec(AnimList[nAnim].AnimRunRec);
|
||||||
runlist_DoSubRunRec(sprite[nSprite].extra);
|
runlist_DoSubRunRec(sprite[nSprite].extra);
|
||||||
runlist_FreeRun(sprite[nSprite].lotag - 1);
|
runlist_FreeRun(sprite[nSprite].lotag - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimsFree[nAnimsFree] = nAnim;
|
AnimList.Release(nAnim);
|
||||||
nAnimsFree++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int BuildAnim(int nSprite, int val, int val2, int x, int y, int z, int nSector, int nRepeat, int nFlag)
|
int BuildAnim(int nSprite, int val, int val2, int x, int y, int z, int nSector, int nRepeat, int nFlag)
|
||||||
{
|
{
|
||||||
if (!nAnimsFree) {
|
int nAnim = AnimList.Get();
|
||||||
|
if (nAnim < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
nAnimsFree--;
|
|
||||||
|
|
||||||
short nAnim = AnimsFree[nAnimsFree];
|
|
||||||
|
|
||||||
if (nSprite == -1) {
|
if (nSprite == -1) {
|
||||||
nSprite = insertsprite(nSector, 500);
|
nSprite = insertsprite(nSector, 500);
|
||||||
}
|
}
|
||||||
|
@ -127,9 +128,9 @@ int BuildAnim(int nSprite, int val, int val2, int x, int y, int z, int nSector,
|
||||||
sprite[nSprite].owner = -1;
|
sprite[nSprite].owner = -1;
|
||||||
sprite[nSprite].extra = runlist_AddRunRec(sprite[nSprite].lotag - 1, nAnim | 0x100000);
|
sprite[nSprite].extra = runlist_AddRunRec(sprite[nSprite].lotag - 1, nAnim | 0x100000);
|
||||||
|
|
||||||
AnimRunRec[nAnim] = runlist_AddRunRec(NewRun, nAnim | 0x100000);
|
AnimList[nAnim].AnimRunRec = runlist_AddRunRec(NewRun, nAnim | 0x100000);
|
||||||
AnimList[nAnim].nSprite = nSprite;
|
AnimList[nAnim].nSprite = nSprite;
|
||||||
AnimFlags[nAnim] = nFlag;
|
AnimList[nAnim].AnimFlags = nFlag;
|
||||||
AnimList[nAnim].field_2 = 0;
|
AnimList[nAnim].field_2 = 0;
|
||||||
AnimList[nAnim].nSeq = SeqOffsets[val] + val2;
|
AnimList[nAnim].nSeq = SeqOffsets[val] + val2;
|
||||||
AnimList[nAnim].field_4 = 256;
|
AnimList[nAnim].field_4 = 256;
|
||||||
|
@ -236,7 +237,7 @@ void FuncAnim(int a, int, int nRun)
|
||||||
AnimList[nAnim].field_2++;
|
AnimList[nAnim].field_2++;
|
||||||
if (AnimList[nAnim].field_2 >= SeqSize[nSeq])
|
if (AnimList[nAnim].field_2 >= SeqSize[nSeq])
|
||||||
{
|
{
|
||||||
if (AnimFlags[nAnim] & 0x10)
|
if (AnimList[nAnim].AnimFlags & 0x10)
|
||||||
{
|
{
|
||||||
AnimList[nAnim].field_2 = 0;
|
AnimList[nAnim].field_2 = 0;
|
||||||
}
|
}
|
||||||
|
@ -245,14 +246,14 @@ void FuncAnim(int a, int, int nRun)
|
||||||
AnimList[nAnim].field_2 = 0;
|
AnimList[nAnim].field_2 = 0;
|
||||||
AnimList[nAnim].nSeq = nMagicSeq;
|
AnimList[nAnim].nSeq = nMagicSeq;
|
||||||
short nAnimSprite = AnimList[nAnim].nSprite;
|
short nAnimSprite = AnimList[nAnim].nSprite;
|
||||||
AnimFlags[nAnim] |= 0x10;
|
AnimList[nAnim].AnimFlags |= 0x10;
|
||||||
sprite[nAnimSprite].cstat |= 2;
|
sprite[nAnimSprite].cstat |= 2;
|
||||||
}
|
}
|
||||||
else if (nSeq == nSavePointSeq)
|
else if (nSeq == nSavePointSeq)
|
||||||
{
|
{
|
||||||
AnimList[nAnim].field_2 = 0;
|
AnimList[nAnim].field_2 = 0;
|
||||||
AnimList[nAnim].nSeq++;
|
AnimList[nAnim].nSeq++;
|
||||||
AnimFlags[nAnim] |= 0x10;
|
AnimList[nAnim].AnimFlags |= 0x10;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,12 +90,10 @@ short nPlayerScore[kMaxPlayers];
|
||||||
short nPlayerColor[kMaxPlayers];
|
short nPlayerColor[kMaxPlayers];
|
||||||
int nPlayerDY[kMaxPlayers];
|
int nPlayerDY[kMaxPlayers];
|
||||||
int nPlayerDX[kMaxPlayers];
|
int nPlayerDX[kMaxPlayers];
|
||||||
char playerNames[kMaxPlayers][11];
|
|
||||||
short nPistolClip[kMaxPlayers];
|
short nPistolClip[kMaxPlayers];
|
||||||
int nXDamage[kMaxPlayers];
|
int nXDamage[kMaxPlayers];
|
||||||
int nYDamage[kMaxPlayers];
|
int nYDamage[kMaxPlayers];
|
||||||
short nDoppleSprite[kMaxPlayers];
|
short nDoppleSprite[kMaxPlayers];
|
||||||
short namelen[kMaxPlayers];
|
|
||||||
short nPlayerOldWeapon[kMaxPlayers];
|
short nPlayerOldWeapon[kMaxPlayers];
|
||||||
short nPlayerClip[kMaxPlayers];
|
short nPlayerClip[kMaxPlayers];
|
||||||
short nPlayerPushSound[kMaxPlayers];
|
short nPlayerPushSound[kMaxPlayers];
|
||||||
|
@ -461,9 +459,6 @@ void RestartPlayer(short nPlayer)
|
||||||
RestoreGreenPal();
|
RestoreGreenPal();
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(playerNames[nPlayer], "JOE%d", nPlayer);
|
|
||||||
namelen[nPlayer] = strlen(playerNames[nPlayer]);
|
|
||||||
|
|
||||||
ototalvel[nPlayer] = totalvel[nPlayer] = 0;
|
ototalvel[nPlayer] = totalvel[nPlayer] = 0;
|
||||||
|
|
||||||
memset(&sPlayerInput[nPlayer], 0, sizeof(PlayerInput));
|
memset(&sPlayerInput[nPlayer], 0, sizeof(PlayerInput));
|
||||||
|
@ -2418,7 +2413,7 @@ do_default_b:
|
||||||
{
|
{
|
||||||
short nAnim = sprite[nValB].owner;
|
short nAnim = sprite[nValB].owner;
|
||||||
AnimList[nAnim].nSeq++;
|
AnimList[nAnim].nSeq++;
|
||||||
AnimFlags[nAnim] &= 0xEF;
|
AnimList[nAnim].AnimFlags &= 0xEF;
|
||||||
AnimList[nAnim].field_2 = 0;
|
AnimList[nAnim].field_2 = 0;
|
||||||
|
|
||||||
changespritestat(nValB, 899);
|
changespritestat(nValB, 899);
|
||||||
|
@ -2809,50 +2804,98 @@ loc_1BD2E:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SavegameHelper sghplayer("player",
|
|
||||||
SV(lPlayerXVel),
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, Player& w, Player* def)
|
||||||
SV(lPlayerYVel),
|
{
|
||||||
SV(obobangle),
|
if (arc.BeginObject(keyname))
|
||||||
SV(bobangle),
|
{
|
||||||
SV(nStandHeight),
|
arc("health", w.nHealth)
|
||||||
SV(PlayerCount),
|
("at2", w.field_2)
|
||||||
SV(nNetStartSprites),
|
("action", w.nAction)
|
||||||
SV(nCurStartSprite),
|
("sprite", w.nSprite)
|
||||||
SV(nLocalPlayer),
|
("mummy", w.bIsMummified)
|
||||||
SA(nBreathTimer),
|
("invincible", w.invincibility)
|
||||||
SA(nPlayerSwear),
|
("air", w.nAir)
|
||||||
SA(nPlayerPushSect),
|
("seq", w.nSeq)
|
||||||
SA(nDeathType),
|
("maskamount", w.nMaskAmount)
|
||||||
SA(nPlayerScore),
|
("keys", w.keys)
|
||||||
SA(nPlayerColor),
|
("magic", w.nMagic)
|
||||||
SA(nPlayerDY),
|
.Array("items", w.items, countof(w.items))
|
||||||
SA(nPlayerDX),
|
.Array("ammo", w.nAmmo, countof(w.nAmmo))
|
||||||
SA(playerNames),
|
("weapon", w.nCurrentWeapon)
|
||||||
SA(nPistolClip),
|
("isfiring", w.bIsFiring)
|
||||||
SA(nXDamage),
|
("field3f", w.field_3FOUR)
|
||||||
SA(nYDamage),
|
("field38", w.field_38)
|
||||||
SA(nDoppleSprite),
|
("field3a", w.field_3A)
|
||||||
SA(namelen),
|
("field3c", w.field_3C)
|
||||||
SA(nPlayerOldWeapon),
|
("seq", w.nSeq)
|
||||||
SA(nPlayerClip),
|
("horizon", w.horizon)
|
||||||
SA(nPlayerPushSound),
|
("angle", w.angle)
|
||||||
SA(nTauntTimer),
|
.EndObject();
|
||||||
SA(nPlayerTorch),
|
}
|
||||||
SA(nPlayerWeapons),
|
return arc;
|
||||||
SA(nPlayerLives),
|
}
|
||||||
SA(nPlayerItem),
|
|
||||||
SA(PlayerList),
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerSave& w, PlayerSave* def)
|
||||||
SA(nPlayerInvisible),
|
{
|
||||||
SA(nPlayerDouble),
|
if (arc.BeginObject(keyname))
|
||||||
SA(nPlayerViewSect),
|
{
|
||||||
SA(nPlayerFloorSprite),
|
arc("x", w.x)
|
||||||
SA(sPlayerSave),
|
("y", w.y)
|
||||||
SA(totalvel),
|
("z", w.z)
|
||||||
SA(eyelevel),
|
("sector", w.nSector)
|
||||||
SA(nNetStartSprite),
|
("angle", w.nAngle)
|
||||||
SA(nPlayerGrenade),
|
.EndObject();
|
||||||
SA(nGrenadePlayer),
|
}
|
||||||
SA(word_D282A),
|
return arc;
|
||||||
nullptr);
|
}
|
||||||
|
|
||||||
|
void SerializePlayer(FSerializer& arc)
|
||||||
|
{
|
||||||
|
if (arc.BeginObject("player"))
|
||||||
|
{
|
||||||
|
arc("lxvel", lPlayerXVel)
|
||||||
|
("lyvel", lPlayerYVel)
|
||||||
|
("bobangle", bobangle)
|
||||||
|
("standheight", nStandHeight)
|
||||||
|
("playercount", PlayerCount)
|
||||||
|
("netstartsprites", nNetStartSprites)
|
||||||
|
("localplayer", nLocalPlayer)
|
||||||
|
.Array("grenadeplayer", nGrenadePlayer, countof(nGrenadePlayer))
|
||||||
|
.Array("curstartsprite", nNetStartSprite, PlayerCount)
|
||||||
|
.Array("breathtimer", nBreathTimer, PlayerCount)
|
||||||
|
.Array("playerswear", nPlayerSwear, PlayerCount)
|
||||||
|
.Array("pushsect", nPlayerPushSect, PlayerCount)
|
||||||
|
.Array("deathtype", nDeathType, PlayerCount)
|
||||||
|
.Array("score", nPlayerScore, PlayerCount)
|
||||||
|
.Array("color", nPlayerColor, PlayerCount)
|
||||||
|
.Array("dx", nPlayerDX, PlayerCount)
|
||||||
|
.Array("dy", nPlayerDY, PlayerCount)
|
||||||
|
.Array("pistolclip", nPistolClip, PlayerCount)
|
||||||
|
.Array("xdamage", nXDamage, PlayerCount)
|
||||||
|
.Array("ydamage", nYDamage, PlayerCount)
|
||||||
|
.Array("dopplesprite", nDoppleSprite, PlayerCount)
|
||||||
|
.Array("oldweapon", nPlayerOldWeapon, PlayerCount)
|
||||||
|
.Array("clip", nPlayerClip, PlayerCount)
|
||||||
|
.Array("pushsound", nPlayerPushSound, PlayerCount)
|
||||||
|
.Array("taunttimer", nTauntTimer, PlayerCount)
|
||||||
|
.Array("torch", nPlayerTorch, PlayerCount)
|
||||||
|
.Array("weapons", nPlayerWeapons, PlayerCount)
|
||||||
|
.Array("lives", nPlayerLives, PlayerCount)
|
||||||
|
.Array("item", nPlayerItem, PlayerCount)
|
||||||
|
.Array("list", PlayerList, PlayerCount)
|
||||||
|
.Array("invisible", nPlayerInvisible, PlayerCount)
|
||||||
|
.Array("double", nPlayerDouble, PlayerCount)
|
||||||
|
.Array("viewsect", nPlayerViewSect, PlayerCount)
|
||||||
|
.Array("floorspr", nPlayerFloorSprite, PlayerCount)
|
||||||
|
.Array("save", sPlayerSave, PlayerCount)
|
||||||
|
.Array("totalvel", totalvel, PlayerCount)
|
||||||
|
.Array("eyelevel", eyelevel, PlayerCount)
|
||||||
|
.Array("netstartsprite", nNetStartSprite, PlayerCount)
|
||||||
|
.Array("grenade", nPlayerGrenade, PlayerCount)
|
||||||
|
.Array("d282a", word_D282A, PlayerCount)
|
||||||
|
.EndObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
END_PS_NS
|
END_PS_NS
|
||||||
|
|
|
@ -29,6 +29,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
BEGIN_PS_NS
|
BEGIN_PS_NS
|
||||||
|
|
||||||
|
void SerializeAnim(FSerializer& arc);
|
||||||
|
void SerializePlayer(FSerializer& arc);
|
||||||
void SerializeRa(FSerializer& arc);
|
void SerializeRa(FSerializer& arc);
|
||||||
void SerializeRand(FSerializer& arc);
|
void SerializeRand(FSerializer& arc);
|
||||||
void SerializeRunList(FSerializer& arc);
|
void SerializeRunList(FSerializer& arc);
|
||||||
|
@ -67,6 +69,8 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
||||||
{
|
{
|
||||||
if (arc.BeginObject("exhumed"))
|
if (arc.BeginObject("exhumed"))
|
||||||
{
|
{
|
||||||
|
SerializeAnim(arc);
|
||||||
|
SerializePlayer(arc);
|
||||||
SerializeRa(arc);
|
SerializeRa(arc);
|
||||||
SerializeRand(arc);
|
SerializeRand(arc);
|
||||||
SerializeRunList(arc);
|
SerializeRunList(arc);
|
||||||
|
|
Loading…
Reference in a new issue