mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 13:00:43 +00:00
- Blood: cleanup and simplification of SEQ code.
* removed all the large instance arrays. None of this is really necessary, all we need is a single dynamic array with only the active sequences that can expand as needed. * added JSON serialization. With the above change this part now becomes trivial. * renamed all 'atxx' variables in this code.
This commit is contained in:
parent
4aa06ff702
commit
8bfc6d98d4
5 changed files with 685 additions and 673 deletions
|
@ -2488,10 +2488,10 @@ void actInit(bool bSaveLoad) {
|
|||
break;
|
||||
case kThingBloodChunks: {
|
||||
SEQINST *pInst = GetInstance(3, pSprite->extra);
|
||||
if (pInst && pInst->at13) {
|
||||
auto seq = getSequence(pInst->at8);
|
||||
if (pInst) {
|
||||
auto seq = getSequence(pInst->nSeqID);
|
||||
if (!seq) break;
|
||||
seqSpawn(pInst->at8, 3, pSprite->extra);
|
||||
seqSpawn(pInst->nSeqID, 3, pSprite->extra);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1460,9 +1460,9 @@ int getDispersionModifier(spritetype* pSprite, int minDisp, int maxDisp)
|
|||
int disp = 1;
|
||||
if (pSeq != nullptr)
|
||||
{
|
||||
int nFrames = pSeq->nFrames; int ticks = pSeq->at8; int shots = 0;
|
||||
int nFrames = pSeq->nFrames; int ticks = pSeq->ticksPerFrame; int shots = 0;
|
||||
for (int i = 0; i <= pSeq->nFrames; i++) {
|
||||
if (pSeq->frames[i].at5_5) shots++;
|
||||
if (pSeq->frames[i].trigger) shots++;
|
||||
}
|
||||
|
||||
disp = (((shots * 1000) / nFrames) / ticks) * 20;
|
||||
|
@ -2040,7 +2040,7 @@ bool genDudePrepare(spritetype* pSprite, int propId) {
|
|||
{
|
||||
pExtra->forcePunch = true; // required for those who don't have fire trigger in punch seq and for default animation
|
||||
for (int i = 0; i < pSeq->nFrames; i++) {
|
||||
if (!pSeq->frames[i].at5_5) continue;
|
||||
if (!pSeq->frames[i].trigger) continue;
|
||||
pExtra->forcePunch = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -476,14 +476,6 @@ void LoadSave::Write(const void *pData, int nSize)
|
|||
|
||||
bool GameInterface::LoadGame()
|
||||
{
|
||||
sndKillAllSounds();
|
||||
sfxKillAllSounds();
|
||||
ambKillAll();
|
||||
seqKillAll();
|
||||
if (gamestate != GS_LEVEL)
|
||||
{
|
||||
memset(xsprite, 0, sizeof(xsprite));
|
||||
}
|
||||
LoadSave::hLFile = ReadSavegameChunk("snapshot.bld");
|
||||
if (!LoadSave::hLFile.isOpen())
|
||||
return false;
|
||||
|
@ -735,7 +727,6 @@ void LevelsLoadSaveConstruct(void);
|
|||
void MessagesLoadSaveConstruct(void);
|
||||
void MirrorLoadSaveConstruct(void);
|
||||
void PlayerLoadSaveConstruct(void);
|
||||
void SeqLoadSaveConstruct(void);
|
||||
void TriggersLoadSaveConstruct(void);
|
||||
void ViewLoadSaveConstruct(void);
|
||||
void WarpLoadSaveConstruct(void);
|
||||
|
@ -754,7 +745,6 @@ void LoadSaveSetup(void)
|
|||
MessagesLoadSaveConstruct();
|
||||
MirrorLoadSaveConstruct();
|
||||
PlayerLoadSaveConstruct();
|
||||
SeqLoadSaveConstruct();
|
||||
TriggersLoadSaveConstruct();
|
||||
ViewLoadSaveConstruct();
|
||||
WarpLoadSaveConstruct();
|
||||
|
@ -765,10 +755,21 @@ void LoadSaveSetup(void)
|
|||
|
||||
|
||||
void SerializeEvents(FSerializer& arc);
|
||||
void SerializeSequences(FSerializer& arc);
|
||||
|
||||
void GameInterface::SerializeGameState(FSerializer& arc)
|
||||
{
|
||||
sndKillAllSounds();
|
||||
sfxKillAllSounds();
|
||||
ambKillAll();
|
||||
seqKillAll();
|
||||
if (gamestate != GS_LEVEL)
|
||||
{
|
||||
memset(xsprite, 0, sizeof(xsprite));
|
||||
}
|
||||
|
||||
SerializeEvents(arc);
|
||||
SerializeSequences(arc);
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,68 +26,80 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
BEGIN_BLD_NS
|
||||
|
||||
|
||||
struct SEQFRAME {
|
||||
unsigned int tile : 12;
|
||||
unsigned int at1_4 : 1; // transparent
|
||||
unsigned int at1_5 : 1; // transparent
|
||||
unsigned int at1_6 : 1; // blockable
|
||||
unsigned int at1_7 : 1; // hittable
|
||||
unsigned int at2_0 : 8; // xrepeat
|
||||
unsigned int at3_0 : 8; // yrepeat
|
||||
signed int at4_0 : 8; // shade
|
||||
unsigned int at5_0 : 5; // palette
|
||||
unsigned int at5_5 : 1; //
|
||||
unsigned int at5_6 : 1; //
|
||||
unsigned int at5_7 : 1; //
|
||||
unsigned int at6_0 : 1; //
|
||||
unsigned int at6_1 : 1; //
|
||||
unsigned int at6_2 : 1; // invisible
|
||||
unsigned int at6_3 : 1; //
|
||||
unsigned int at6_4 : 1; //
|
||||
unsigned int tile2 : 4;
|
||||
unsigned soundRange : 4; // (by NoOne) random sound range relative to global SEQ sound
|
||||
unsigned surfaceSound : 1; // (by NoOne) trigger surface sound when moving / touching
|
||||
unsigned reserved : 2;
|
||||
struct SEQFRAME
|
||||
{
|
||||
unsigned int tile : 12;
|
||||
unsigned int transparent : 1;
|
||||
unsigned int transparent2 : 1;
|
||||
unsigned int blockable : 1;
|
||||
unsigned int hittable : 1;
|
||||
unsigned int xrepeat : 8;
|
||||
unsigned int yrepeat : 8;
|
||||
signed int shade : 8;
|
||||
unsigned int palette : 5;
|
||||
unsigned int trigger : 1;
|
||||
unsigned int smoke : 1;
|
||||
unsigned int aiming : 1;
|
||||
unsigned int pushable : 1;
|
||||
unsigned int playsound : 1;
|
||||
unsigned int invisible : 1;// invisible
|
||||
unsigned int flipx : 1;
|
||||
unsigned int flipy : 1;
|
||||
unsigned int tile2 : 4;
|
||||
unsigned soundRange : 4; // (by NoOne) random sound range relative to global SEQ sound
|
||||
unsigned surfaceSound : 1; // (by NoOne) trigger surface sound when moving / touching
|
||||
unsigned reserved : 2;
|
||||
};
|
||||
|
||||
struct Seq {
|
||||
char signature[4];
|
||||
short version;
|
||||
short nFrames; // at6
|
||||
short at8;
|
||||
short ata;
|
||||
int atc;
|
||||
SEQFRAME frames[1];
|
||||
void Preload(void);
|
||||
void Precache(HitList &);
|
||||
char signature[4];
|
||||
short version;
|
||||
short nFrames;
|
||||
short ticksPerFrame;
|
||||
short soundId;
|
||||
int flags;
|
||||
SEQFRAME frames[1];
|
||||
void Preload(void);
|
||||
void Precache(HitList&);
|
||||
|
||||
bool isLooping()
|
||||
{
|
||||
return (flags & 1) != 0;
|
||||
}
|
||||
|
||||
bool isRemovable()
|
||||
{
|
||||
return (flags & 2) != 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct ACTIVE
|
||||
{
|
||||
unsigned char type;
|
||||
unsigned short xindex;
|
||||
unsigned char type;
|
||||
unsigned short xindex;
|
||||
};
|
||||
|
||||
struct SEQINST
|
||||
{
|
||||
Seq *pSequence;
|
||||
int at8;
|
||||
int atc;
|
||||
short at10;
|
||||
unsigned char frameIndex;
|
||||
char at13;
|
||||
void Update(ACTIVE *pActive);
|
||||
Seq* pSequence;
|
||||
int index, type;
|
||||
|
||||
int nSeqID;
|
||||
int callback;
|
||||
short timeCounter;
|
||||
unsigned char frameIndex;
|
||||
void Update();
|
||||
};
|
||||
|
||||
inline int seqGetTile(SEQFRAME* pFrame)
|
||||
{
|
||||
return pFrame->tile+(pFrame->tile2<<12);
|
||||
return pFrame->tile + (pFrame->tile2 << 12);
|
||||
}
|
||||
|
||||
int seqRegisterClient(void(*pClient)(int, int));
|
||||
void seqPrecacheId(int id, HitList &hits);
|
||||
SEQINST * GetInstance(int a1, int a2);
|
||||
void UnlockInstance(SEQINST *pInst);
|
||||
void seqPrecacheId(int id, HitList& hits);
|
||||
SEQINST* GetInstance(int a1, int a2);
|
||||
void UnlockInstance(SEQINST* pInst);
|
||||
void seqSpawn(int a1, int a2, int a3, int a4 = -1);
|
||||
void seqKill(int a1, int a2);
|
||||
void seqKillAll(void);
|
||||
|
|
Loading…
Reference in a new issue