mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-27 09:20:51 +00:00
- JSON serializer for actor.
Also cleaned up use of gAffectedSectors and gAffectedXWalls. These are merely needed as local worker variables, not as global persistent status.
This commit is contained in:
parent
2c1b53ad1c
commit
dced173cda
10 changed files with 54 additions and 69 deletions
|
@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "automap.h"
|
||||
#include "pragmas.h"
|
||||
#include "mmulti.h"
|
||||
#include "savegamehelp.h"
|
||||
#include "common_game.h"
|
||||
|
||||
#include "actor.h"
|
||||
|
@ -2337,8 +2338,6 @@ const EXPLOSION explodeInfo[] = {
|
|||
},
|
||||
};
|
||||
|
||||
short gAffectedSectors[kMaxSectors];
|
||||
short gAffectedXWalls[kMaxXWalls];
|
||||
static const short gPlayerGibThingComments[] = {
|
||||
734, 735, 736, 737, 738, 739, 740, 741, 3038, 3049
|
||||
};
|
||||
|
@ -2347,8 +2346,8 @@ static const short gPlayerGibThingComments[] = {
|
|||
int gPostCount = 0;
|
||||
|
||||
struct POSTPONE {
|
||||
short TotalKills;
|
||||
short at2;
|
||||
short sprite;
|
||||
short status;
|
||||
};
|
||||
|
||||
POSTPONE gPost[kMaxSprites];
|
||||
|
@ -2673,9 +2672,7 @@ void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7,
|
|||
UNREFERENCED_PARAMETER(a13);
|
||||
uint8_t va0[(kMaxSectors+7)>>3];
|
||||
int nOwner = actSpriteIdToOwnerId(nSprite);
|
||||
gAffectedSectors[0] = 0;
|
||||
gAffectedXWalls[0] = 0;
|
||||
GetClosestSpriteSectors(nSector, x, y, nDist, gAffectedSectors, va0, gAffectedXWalls);
|
||||
GetClosestSpriteSectors(nSector, x, y, nDist, va0);
|
||||
nDist <<= 4;
|
||||
if (a10 & 2)
|
||||
{
|
||||
|
@ -5681,8 +5678,6 @@ void actProcessSprites(void)
|
|||
int y = pSprite->y;
|
||||
int z = pSprite->z;
|
||||
int nSector = pSprite->sectnum;
|
||||
gAffectedSectors[0] = -1;
|
||||
gAffectedXWalls[0] = -1;
|
||||
int radius = pExplodeInfo->radius;
|
||||
|
||||
#ifdef NOONE_EXTENSIONS
|
||||
|
@ -5692,7 +5687,8 @@ void actProcessSprites(void)
|
|||
radius = pXSprite->data4;
|
||||
#endif
|
||||
|
||||
GetClosestSpriteSectors(nSector, x, y, radius, gAffectedSectors, v24c, gAffectedXWalls);
|
||||
short gAffectedXWalls[kMaxXWalls];
|
||||
GetClosestSpriteSectors(nSector, x, y, radius, v24c, gAffectedXWalls);
|
||||
|
||||
for (int i = 0; i < kMaxXWalls; i++)
|
||||
{
|
||||
|
@ -6878,7 +6874,7 @@ void actPostSprite(int nSprite, int nStatus)
|
|||
if (sprite[nSprite].flags&32)
|
||||
{
|
||||
for (n = 0; n < gPostCount; n++)
|
||||
if (gPost[n].TotalKills == nSprite)
|
||||
if (gPost[n].sprite == nSprite)
|
||||
break;
|
||||
assert(n < gPostCount);
|
||||
}
|
||||
|
@ -6888,8 +6884,8 @@ void actPostSprite(int nSprite, int nStatus)
|
|||
sprite[nSprite].flags |= 32;
|
||||
gPostCount++;
|
||||
}
|
||||
gPost[n].TotalKills = nSprite;
|
||||
gPost[n].at2 = nStatus;
|
||||
gPost[n].sprite = nSprite;
|
||||
gPost[n].status = nStatus;
|
||||
}
|
||||
|
||||
void actPostProcess(void)
|
||||
|
@ -6897,10 +6893,10 @@ void actPostProcess(void)
|
|||
for (int i = 0; i < gPostCount; i++)
|
||||
{
|
||||
POSTPONE *pPost = &gPost[i];
|
||||
int nSprite = pPost->TotalKills;
|
||||
int nSprite = pPost->sprite;
|
||||
spritetype *pSprite = &sprite[nSprite];
|
||||
pSprite->flags &= ~32;
|
||||
int nStatus = pPost->at2;
|
||||
int nStatus = pPost->status;
|
||||
if (nStatus == kStatFree)
|
||||
{
|
||||
evKill(nSprite, 3);
|
||||
|
@ -6941,41 +6937,41 @@ void MakeSplash(spritetype *pSprite, XSPRITE *pXSprite)
|
|||
}
|
||||
}
|
||||
|
||||
class ActorLoadSave : public LoadSave
|
||||
{
|
||||
virtual void Load(void);
|
||||
virtual void Save(void);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void ActorLoadSave::Load(void)
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, POSTPONE& w, POSTPONE* def)
|
||||
{
|
||||
Read(&gVectorData[VECTOR_TYPE_20].maxDist, sizeof(gVectorData[VECTOR_TYPE_20].maxDist)); // The code messes around with this field so better save it.
|
||||
Read(gSpriteHit, sizeof(gSpriteHit));
|
||||
Read(gAffectedSectors, sizeof(gAffectedSectors));
|
||||
Read(gAffectedXWalls, sizeof(gAffectedXWalls));
|
||||
Read(&gPostCount, sizeof(gPostCount));
|
||||
Read(gPost, sizeof(gPost));
|
||||
if (gGameOptions.nMonsterSettings != 0) {
|
||||
for (int i = 0; i < kDudeMax - kDudeBase; i++)
|
||||
for (int j = 0; j < 7; j++)
|
||||
dudeInfo[i].at70[j] = mulscale8(DudeDifficulty[gGameOptions.nDifficulty], dudeInfo[i].startDamage[j]);
|
||||
}
|
||||
if (arc.BeginObject(keyname))
|
||||
{
|
||||
arc("sprite", w.sprite)
|
||||
("status", w.status)
|
||||
.EndObject();
|
||||
}
|
||||
return arc;
|
||||
}
|
||||
|
||||
void ActorLoadSave::Save(void)
|
||||
void SerializeActor(FSerializer& arc)
|
||||
{
|
||||
Write(&gVectorData[VECTOR_TYPE_20].maxDist, sizeof(gVectorData[VECTOR_TYPE_20].maxDist));
|
||||
Write(gSpriteHit, sizeof(gSpriteHit));
|
||||
Write(gAffectedSectors, sizeof(gAffectedSectors));
|
||||
Write(gAffectedXWalls, sizeof(gAffectedXWalls));
|
||||
Write(&gPostCount, sizeof(gPostCount));
|
||||
Write(gPost, sizeof(gPost));
|
||||
if (arc.BeginObject("actor"))
|
||||
{
|
||||
arc("maxdist20", gVectorData[VECTOR_TYPE_20].maxDist) // The code messes around with this field so better save it.
|
||||
.SparseArray("spritehit", gSpriteHit, kMaxSprites, activeSprites)
|
||||
("postcount", gPostCount)
|
||||
.Array("post", gPost, gPostCount)
|
||||
.EndObject();
|
||||
|
||||
if (arc.isReading() && gGameOptions.nMonsterSettings != 0)
|
||||
{
|
||||
for (int i = 0; i < kDudeMax - kDudeBase; i++)
|
||||
for (int j = 0; j < 7; j++)
|
||||
dudeInfo[i].at70[j] = mulscale8(DudeDifficulty[gGameOptions.nDifficulty], dudeInfo[i].startDamage[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ActorLoadSaveConstruct(void)
|
||||
{
|
||||
new ActorLoadSave();
|
||||
}
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -176,8 +176,6 @@ extern const THINGINFO thingInfo[];
|
|||
extern VECTORDATA gVectorData[];
|
||||
|
||||
const int gDudeDrag = 0x2a00;
|
||||
extern short gAffectedSectors[kMaxSectors];
|
||||
extern short gAffectedXWalls[kMaxXWalls];
|
||||
|
||||
template<typename T> bool IsPlayerSprite(T const * const pSprite)
|
||||
{
|
||||
|
|
|
@ -1415,9 +1415,7 @@ void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite)
|
|||
if (pXSprite->state)
|
||||
{
|
||||
uint8_t va4[(kMaxSectors+7)>>3];
|
||||
gAffectedSectors[0] = 0;
|
||||
gAffectedXWalls[0] = 0;
|
||||
GetClosestSpriteSectors(pSprite->sectnum, pSprite->x, pSprite->y, 400, gAffectedSectors, va4, gAffectedXWalls);
|
||||
GetClosestSpriteSectors(pSprite->sectnum, pSprite->x, pSprite->y, 400, va4);
|
||||
|
||||
int nSprite2;
|
||||
StatIterator it(kStatDude);
|
||||
|
|
|
@ -107,9 +107,7 @@ void StompSeqCallback(int, int nXSprite)
|
|||
int nSector = pSprite->sectnum;
|
||||
int v1c = 5+2*gGameOptions.nDifficulty;
|
||||
int v10 = 25+30*gGameOptions.nDifficulty;
|
||||
gAffectedSectors[0] = -1;
|
||||
gAffectedXWalls[0] = -1;
|
||||
GetClosestSpriteSectors(nSector, x, y, vc, gAffectedSectors, vb8, gAffectedXWalls);
|
||||
GetClosestSpriteSectors(nSector, x, y, vc, vb8);
|
||||
char v4 = 0;
|
||||
int v34 = -1;
|
||||
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
||||
|
|
|
@ -832,10 +832,10 @@ int GetClosestSectors(int nSector, int x, int y, int nDist, short *pSectors, cha
|
|||
return n;
|
||||
}
|
||||
|
||||
int GetClosestSpriteSectors(int nSector, int x, int y, int nDist, short *pSectors, uint8_t *pSectBit, short *a8)
|
||||
int GetClosestSpriteSectors(int nSector, int x, int y, int nDist, uint8_t *pSectBit, short *walls)
|
||||
{
|
||||
static short pSectors[kMaxSectors];
|
||||
uint8_t sectbits[(kMaxSectors+7)>>3];
|
||||
assert(pSectors != NULL);
|
||||
memset(sectbits, 0, sizeof(sectbits));
|
||||
pSectors[0] = nSector;
|
||||
SetBitString(sectbits, nSector);
|
||||
|
@ -865,21 +865,17 @@ int GetClosestSpriteSectors(int nSector, int x, int y, int nDist, short *pSector
|
|||
if (pSectBit)
|
||||
SetBitString(pSectBit, nNextSector);
|
||||
pSectors[n++] = nNextSector;
|
||||
if (a8 && pWall->extra > 0)
|
||||
if (walls && pWall->extra > 0)
|
||||
{
|
||||
XWALL *pXWall = &xwall[pWall->extra];
|
||||
if (pXWall->triggerVector && !pXWall->isTriggered && !pXWall->state)
|
||||
a8[m++] = j;
|
||||
walls[m++] = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
pSectors[n] = -1;
|
||||
if (a8)
|
||||
{
|
||||
a8[m] = -1;
|
||||
}
|
||||
walls[m] = -1;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ void GetZRangeAtXYZ(int x, int y, int z, int nSector, int *ceilZ, int *ceilHit,
|
|||
int GetDistToLine(int x1, int y1, int x2, int y2, int x3, int y3);
|
||||
unsigned int ClipMove(int *x, int *y, int *z, int *nSector, int xv, int yv, int wd, int cd, int fd, unsigned int nMask);
|
||||
int GetClosestSectors(int nSector, int x, int y, int nDist, short *pSectors, char *pSectBit);
|
||||
int GetClosestSpriteSectors(int nSector, int x, int y, int nDist, short *pSectors, uint8_t *pSectBit, short *a8);
|
||||
int GetClosestSpriteSectors(int nSector, int x, int y, int nDist, uint8_t *pSectBit, short *affx = nullptr);
|
||||
int picWidth(short nPic, short repeat);
|
||||
int picHeight(short nPic, short repeat);
|
||||
|
||||
|
|
|
@ -736,7 +736,6 @@ void LoadSaveSetup(void)
|
|||
{
|
||||
new MyLoadSave();
|
||||
|
||||
ActorLoadSaveConstruct();
|
||||
AILoadSaveConstruct();
|
||||
EndGameLoadSaveConstruct();
|
||||
LevelsLoadSaveConstruct();
|
||||
|
@ -754,6 +753,7 @@ void SerializeEvents(FSerializer& arc);
|
|||
void SerializeSequences(FSerializer& arc);
|
||||
void SerializeWarp(FSerializer& arc);
|
||||
void SerializeTriggers(FSerializer& arc);
|
||||
void SerializeActor(FSerializer& arc);
|
||||
|
||||
void GameInterface::SerializeGameState(FSerializer& arc)
|
||||
{
|
||||
|
@ -770,6 +770,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
|||
SerializeSequences(arc);
|
||||
SerializeWarp(arc);
|
||||
SerializeTriggers(arc);
|
||||
SerializeActor(arc);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2532,9 +2532,7 @@ void teslaHit(spritetype *pMissile, int a2)
|
|||
int nDist = 300;
|
||||
int nSector = pMissile->sectnum;
|
||||
int nOwner = actSpriteOwnerToSpriteId(pMissile);
|
||||
gAffectedSectors[0] = -1;
|
||||
gAffectedXWalls[0] = -1;
|
||||
GetClosestSpriteSectors(nSector, x, y, nDist, gAffectedSectors, va4, gAffectedXWalls);
|
||||
GetClosestSpriteSectors(nSector, x, y, nDist, va4);
|
||||
char v4 = 1;
|
||||
int v24 = -1;
|
||||
actHitcodeToData(a2, &gHitInfo, &v24, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "resourcefile.h"
|
||||
#include "build.h"
|
||||
|
||||
extern FixedBitArray<MAXSPRITES> activeSprites;
|
||||
|
||||
bool OpenSaveGameForWrite(const char *fname, const char *name);
|
||||
bool OpenSaveGameForRead(const char *name);
|
||||
|
|
|
@ -32,9 +32,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
|||
#include "gamestate.h"
|
||||
#include "dukeactor.h"
|
||||
|
||||
extern FixedBitArray<MAXSPRITES> activeSprites;
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue