- Blood: JSON serializer for triggers

Also renaming members of struct BUSY.
This commit is contained in:
Christoph Oelckers 2020-11-21 20:25:06 +01:00
parent f73ca55c79
commit b2a7a0635b
6 changed files with 47 additions and 45 deletions

View file

@ -51,7 +51,7 @@ static void aiPodChase(spritetype *, XSPRITE *);
AISTATE podIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
AISTATE podMove = { kAiStateMove, 7, -1, 3600, NULL, aiMoveTurn, aiPodMove, &podSearch };
AISTATE podSearch = { kAiStateSearch, 0, -1, 3600, NULL, aiMoveTurn, aiPodSearch, &podSearch };
AISTATE podStartChase = { kAiStateChase, 8, dword_279B34, 600, NULL, NULL, NULL, &podChase };
AISTATE podStartChase = { kAiStateChase, 8, nPodStartChaseClient, 600, NULL, NULL, NULL, &podChase };
AISTATE podRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &podChase };
AISTATE podChase = { kAiStateChase, 6, -1, 0, NULL, aiMoveTurn, aiPodChase, NULL };
AISTATE tentacleIdle = { kAiStateIdle, 0, -1, 0, NULL, NULL, aiThinkTarget, NULL };
@ -61,7 +61,7 @@ AISTATE tentacle13A6E0 = { kAiStateOther, 8, dword_279B40, 0, NULL, NULL, NULL,
AISTATE tentacle13A6FC = { kAiStateOther, -1, -1, 0, NULL, NULL, NULL, &tentacleIdle };
AISTATE tentacleMove = { kAiStateOther, 8, -1, 3600, NULL, aiMoveTurn, aiPodMove, &tentacleSearch };
AISTATE tentacleSearch = { kAiStateOther, 0, -1, 3600, NULL, aiMoveTurn, aiPodSearch, NULL };
AISTATE tentacleStartChase = { kAiStateOther, 6, dword_279B38, 120, NULL, NULL, NULL, &tentacleChase };
AISTATE tentacleStartChase = { kAiStateOther, 6, nTentacleStartSearchClient, 120, NULL, NULL, NULL, &tentacleChase };
AISTATE tentacleRecoil = { kAiStateRecoil, 5, -1, 0, NULL, NULL, NULL, &tentacleChase };
AISTATE tentacleChase = { kAiStateChase, 6, -1, 0, NULL, aiMoveTurn, aiPodChase, NULL };

View file

@ -727,7 +727,6 @@ void LevelsLoadSaveConstruct(void);
void MessagesLoadSaveConstruct(void);
void MirrorLoadSaveConstruct(void);
void PlayerLoadSaveConstruct(void);
void TriggersLoadSaveConstruct(void);
void ViewLoadSaveConstruct(void);
#ifdef NOONE_EXTENSIONS
void NNLoadSaveConstruct(void);
@ -744,7 +743,6 @@ void LoadSaveSetup(void)
MessagesLoadSaveConstruct();
MirrorLoadSaveConstruct();
PlayerLoadSaveConstruct();
TriggersLoadSaveConstruct();
ViewLoadSaveConstruct();
#ifdef NOONE_EXTENSIONS
NNLoadSaveConstruct();
@ -755,6 +753,7 @@ void LoadSaveSetup(void)
void SerializeEvents(FSerializer& arc);
void SerializeSequences(FSerializer& arc);
void SerializeWarp(FSerializer& arc);
void SerializeTriggers(FSerializer& arc);
void GameInterface::SerializeGameState(FSerializer& arc)
{
@ -770,6 +769,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
SerializeEvents(arc);
SerializeSequences(arc);
SerializeWarp(arc);
SerializeTriggers(arc);
}

View file

@ -96,8 +96,8 @@ enum
nJumpClient,
nHoundBiteClient,
nHoundBurnClient,
dword_279B34,
dword_279B38,
nPodStartChaseClient,
nTentacleStartSearchClient,
dword_279B3C,
dword_279B40,
nRatBiteClient,

View file

@ -167,10 +167,10 @@ enum BUSYID {
};
struct BUSY {
int TotalKills;
int Kills;
int at8;
BUSYID atc;
int index;
int delta;
int busy;
int type;
};
BUSY gBusy[128];
@ -181,19 +181,19 @@ void AddBusy(int a1, BUSYID a2, int nDelta)
int i;
for (i = 0; i < gBusyCount; i++)
{
if (gBusy[i].TotalKills == a1 && gBusy[i].atc == a2)
if (gBusy[i].index == a1 && gBusy[i].type == a2)
break;
}
if (i == gBusyCount)
{
if (gBusyCount == 128)
return;
gBusy[i].TotalKills = a1;
gBusy[i].atc = a2;
gBusy[i].at8 = nDelta > 0 ? 0 : 65536;
gBusy[i].index = a1;
gBusy[i].type = a2;
gBusy[i].busy = nDelta > 0 ? 0 : 65536;
gBusyCount++;
}
gBusy[i].Kills = nDelta;
gBusy[i].delta = nDelta;
}
void ReverseBusy(int a1, BUSYID a2)
@ -201,9 +201,9 @@ void ReverseBusy(int a1, BUSYID a2)
int i;
for (i = 0; i < gBusyCount; i++)
{
if (gBusy[i].TotalKills == a1 && gBusy[i].atc == a2)
if (gBusy[i].index == a1 && gBusy[i].type == a2)
{
gBusy[i].Kills = -gBusy[i].Kills;
gBusy[i].delta = -gBusy[i].delta;
break;
}
}
@ -2005,16 +2005,16 @@ void trProcessBusy(void)
memset(velCeil, 0, sizeof(velCeil));
for (int i = gBusyCount-1; i >= 0; i--)
{
int oldBusy = gBusy[i].at8;
gBusy[i].at8 = ClipRange(oldBusy+gBusy[i].Kills*4, 0, 65536);
int nStatus = gBusyProc[gBusy[i].atc](gBusy[i].TotalKills, gBusy[i].at8);
int oldBusy = gBusy[i].busy;
gBusy[i].busy = ClipRange(oldBusy+gBusy[i].delta*4, 0, 65536);
int nStatus = gBusyProc[gBusy[i].type](gBusy[i].index, gBusy[i].busy);
switch (nStatus) {
case 1:
gBusy[i].at8 = oldBusy;
gBusy[i].busy = oldBusy;
break;
case 2:
gBusy[i].at8 = oldBusy;
gBusy[i].Kills = -gBusy[i].Kills;
gBusy[i].busy = oldBusy;
gBusy[i].delta = -gBusy[i].delta;
break;
case 3:
gBusy[i] = gBusy[--gBusyCount];
@ -2317,30 +2317,35 @@ void MGunOpenSeqCallback(int, int nXSprite)
seqSpawn(39, 3, nXSprite, nMGunFireClient);
}
class TriggersLoadSave : public LoadSave
{
public:
virtual void Load();
virtual void Save();
};
void TriggersLoadSave::Load()
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
FSerializer& Serialize(FSerializer& arc, const char* keyname, BUSY& w, BUSY* def)
{
Read(&gBusyCount, sizeof(gBusyCount));
Read(gBusy, sizeof(gBusy));
Read(basePath, sizeof(basePath));
if (arc.BeginObject(keyname))
{
arc("index", w.index)
("type", w.type)
("delta", w.delta)
("busy", w.busy)
.EndObject();
}
return arc;
}
void TriggersLoadSave::Save()
void SerializeTriggers(FSerializer& arc)
{
Write(&gBusyCount, sizeof(gBusyCount));
Write(gBusy, sizeof(gBusy));
Write(basePath, sizeof(basePath));
}
void TriggersLoadSaveConstruct(void)
{
new TriggersLoadSave();
if (arc.BeginObject("triggers"))
{
arc("busycount", gBusyCount)
.Array("busy", gBusy, gBusyCount)
.Array("basepath", basePath, numsectors)
.EndObject();
}
}
END_BLD_NS

View file

@ -66,8 +66,6 @@ struct zdemoheader_s {
};
class FArchive;
// When transmitted, the above message is preceded by a uint8_t
// indicating which fields are actually present in the message.
enum

View file

@ -9,4 +9,3 @@ struct ticcmd_t
uint16_t consistency; // checks for net game
};
FArchive &operator<< (FArchive &arc, ticcmd_t &cmd);