mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-30 10:40:39 +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 "automap.h"
|
||||||
#include "pragmas.h"
|
#include "pragmas.h"
|
||||||
#include "mmulti.h"
|
#include "mmulti.h"
|
||||||
|
#include "savegamehelp.h"
|
||||||
#include "common_game.h"
|
#include "common_game.h"
|
||||||
|
|
||||||
#include "actor.h"
|
#include "actor.h"
|
||||||
|
@ -2337,8 +2338,6 @@ const EXPLOSION explodeInfo[] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
short gAffectedSectors[kMaxSectors];
|
|
||||||
short gAffectedXWalls[kMaxXWalls];
|
|
||||||
static const short gPlayerGibThingComments[] = {
|
static const short gPlayerGibThingComments[] = {
|
||||||
734, 735, 736, 737, 738, 739, 740, 741, 3038, 3049
|
734, 735, 736, 737, 738, 739, 740, 741, 3038, 3049
|
||||||
};
|
};
|
||||||
|
@ -2347,8 +2346,8 @@ static const short gPlayerGibThingComments[] = {
|
||||||
int gPostCount = 0;
|
int gPostCount = 0;
|
||||||
|
|
||||||
struct POSTPONE {
|
struct POSTPONE {
|
||||||
short TotalKills;
|
short sprite;
|
||||||
short at2;
|
short status;
|
||||||
};
|
};
|
||||||
|
|
||||||
POSTPONE gPost[kMaxSprites];
|
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);
|
UNREFERENCED_PARAMETER(a13);
|
||||||
uint8_t va0[(kMaxSectors+7)>>3];
|
uint8_t va0[(kMaxSectors+7)>>3];
|
||||||
int nOwner = actSpriteIdToOwnerId(nSprite);
|
int nOwner = actSpriteIdToOwnerId(nSprite);
|
||||||
gAffectedSectors[0] = 0;
|
GetClosestSpriteSectors(nSector, x, y, nDist, va0);
|
||||||
gAffectedXWalls[0] = 0;
|
|
||||||
GetClosestSpriteSectors(nSector, x, y, nDist, gAffectedSectors, va0, gAffectedXWalls);
|
|
||||||
nDist <<= 4;
|
nDist <<= 4;
|
||||||
if (a10 & 2)
|
if (a10 & 2)
|
||||||
{
|
{
|
||||||
|
@ -5681,8 +5678,6 @@ void actProcessSprites(void)
|
||||||
int y = pSprite->y;
|
int y = pSprite->y;
|
||||||
int z = pSprite->z;
|
int z = pSprite->z;
|
||||||
int nSector = pSprite->sectnum;
|
int nSector = pSprite->sectnum;
|
||||||
gAffectedSectors[0] = -1;
|
|
||||||
gAffectedXWalls[0] = -1;
|
|
||||||
int radius = pExplodeInfo->radius;
|
int radius = pExplodeInfo->radius;
|
||||||
|
|
||||||
#ifdef NOONE_EXTENSIONS
|
#ifdef NOONE_EXTENSIONS
|
||||||
|
@ -5692,7 +5687,8 @@ void actProcessSprites(void)
|
||||||
radius = pXSprite->data4;
|
radius = pXSprite->data4;
|
||||||
#endif
|
#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++)
|
for (int i = 0; i < kMaxXWalls; i++)
|
||||||
{
|
{
|
||||||
|
@ -6878,7 +6874,7 @@ void actPostSprite(int nSprite, int nStatus)
|
||||||
if (sprite[nSprite].flags&32)
|
if (sprite[nSprite].flags&32)
|
||||||
{
|
{
|
||||||
for (n = 0; n < gPostCount; n++)
|
for (n = 0; n < gPostCount; n++)
|
||||||
if (gPost[n].TotalKills == nSprite)
|
if (gPost[n].sprite == nSprite)
|
||||||
break;
|
break;
|
||||||
assert(n < gPostCount);
|
assert(n < gPostCount);
|
||||||
}
|
}
|
||||||
|
@ -6888,8 +6884,8 @@ void actPostSprite(int nSprite, int nStatus)
|
||||||
sprite[nSprite].flags |= 32;
|
sprite[nSprite].flags |= 32;
|
||||||
gPostCount++;
|
gPostCount++;
|
||||||
}
|
}
|
||||||
gPost[n].TotalKills = nSprite;
|
gPost[n].sprite = nSprite;
|
||||||
gPost[n].at2 = nStatus;
|
gPost[n].status = nStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void actPostProcess(void)
|
void actPostProcess(void)
|
||||||
|
@ -6897,10 +6893,10 @@ void actPostProcess(void)
|
||||||
for (int i = 0; i < gPostCount; i++)
|
for (int i = 0; i < gPostCount; i++)
|
||||||
{
|
{
|
||||||
POSTPONE *pPost = &gPost[i];
|
POSTPONE *pPost = &gPost[i];
|
||||||
int nSprite = pPost->TotalKills;
|
int nSprite = pPost->sprite;
|
||||||
spritetype *pSprite = &sprite[nSprite];
|
spritetype *pSprite = &sprite[nSprite];
|
||||||
pSprite->flags &= ~32;
|
pSprite->flags &= ~32;
|
||||||
int nStatus = pPost->at2;
|
int nStatus = pPost->status;
|
||||||
if (nStatus == kStatFree)
|
if (nStatus == kStatFree)
|
||||||
{
|
{
|
||||||
evKill(nSprite, 3);
|
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.
|
if (arc.BeginObject(keyname))
|
||||||
Read(gSpriteHit, sizeof(gSpriteHit));
|
{
|
||||||
Read(gAffectedSectors, sizeof(gAffectedSectors));
|
arc("sprite", w.sprite)
|
||||||
Read(gAffectedXWalls, sizeof(gAffectedXWalls));
|
("status", w.status)
|
||||||
Read(&gPostCount, sizeof(gPostCount));
|
.EndObject();
|
||||||
Read(gPost, sizeof(gPost));
|
}
|
||||||
if (gGameOptions.nMonsterSettings != 0) {
|
return arc;
|
||||||
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 ActorLoadSave::Save(void)
|
void SerializeActor(FSerializer& arc)
|
||||||
{
|
{
|
||||||
Write(&gVectorData[VECTOR_TYPE_20].maxDist, sizeof(gVectorData[VECTOR_TYPE_20].maxDist));
|
if (arc.BeginObject("actor"))
|
||||||
Write(gSpriteHit, sizeof(gSpriteHit));
|
{
|
||||||
Write(gAffectedSectors, sizeof(gAffectedSectors));
|
arc("maxdist20", gVectorData[VECTOR_TYPE_20].maxDist) // The code messes around with this field so better save it.
|
||||||
Write(gAffectedXWalls, sizeof(gAffectedXWalls));
|
.SparseArray("spritehit", gSpriteHit, kMaxSprites, activeSprites)
|
||||||
Write(&gPostCount, sizeof(gPostCount));
|
("postcount", gPostCount)
|
||||||
Write(gPost, sizeof(gPost));
|
.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
|
END_BLD_NS
|
||||||
|
|
|
@ -176,8 +176,6 @@ extern const THINGINFO thingInfo[];
|
||||||
extern VECTORDATA gVectorData[];
|
extern VECTORDATA gVectorData[];
|
||||||
|
|
||||||
const int gDudeDrag = 0x2a00;
|
const int gDudeDrag = 0x2a00;
|
||||||
extern short gAffectedSectors[kMaxSectors];
|
|
||||||
extern short gAffectedXWalls[kMaxXWalls];
|
|
||||||
|
|
||||||
template<typename T> bool IsPlayerSprite(T const * const pSprite)
|
template<typename T> bool IsPlayerSprite(T const * const pSprite)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1415,9 +1415,7 @@ void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite)
|
||||||
if (pXSprite->state)
|
if (pXSprite->state)
|
||||||
{
|
{
|
||||||
uint8_t va4[(kMaxSectors+7)>>3];
|
uint8_t va4[(kMaxSectors+7)>>3];
|
||||||
gAffectedSectors[0] = 0;
|
GetClosestSpriteSectors(pSprite->sectnum, pSprite->x, pSprite->y, 400, va4);
|
||||||
gAffectedXWalls[0] = 0;
|
|
||||||
GetClosestSpriteSectors(pSprite->sectnum, pSprite->x, pSprite->y, 400, gAffectedSectors, va4, gAffectedXWalls);
|
|
||||||
|
|
||||||
int nSprite2;
|
int nSprite2;
|
||||||
StatIterator it(kStatDude);
|
StatIterator it(kStatDude);
|
||||||
|
|
|
@ -107,9 +107,7 @@ void StompSeqCallback(int, int nXSprite)
|
||||||
int nSector = pSprite->sectnum;
|
int nSector = pSprite->sectnum;
|
||||||
int v1c = 5+2*gGameOptions.nDifficulty;
|
int v1c = 5+2*gGameOptions.nDifficulty;
|
||||||
int v10 = 25+30*gGameOptions.nDifficulty;
|
int v10 = 25+30*gGameOptions.nDifficulty;
|
||||||
gAffectedSectors[0] = -1;
|
GetClosestSpriteSectors(nSector, x, y, vc, vb8);
|
||||||
gAffectedXWalls[0] = -1;
|
|
||||||
GetClosestSpriteSectors(nSector, x, y, vc, gAffectedSectors, vb8, gAffectedXWalls);
|
|
||||||
char v4 = 0;
|
char v4 = 0;
|
||||||
int v34 = -1;
|
int v34 = -1;
|
||||||
int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0);
|
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;
|
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];
|
uint8_t sectbits[(kMaxSectors+7)>>3];
|
||||||
assert(pSectors != NULL);
|
|
||||||
memset(sectbits, 0, sizeof(sectbits));
|
memset(sectbits, 0, sizeof(sectbits));
|
||||||
pSectors[0] = nSector;
|
pSectors[0] = nSector;
|
||||||
SetBitString(sectbits, nSector);
|
SetBitString(sectbits, nSector);
|
||||||
|
@ -865,21 +865,17 @@ int GetClosestSpriteSectors(int nSector, int x, int y, int nDist, short *pSector
|
||||||
if (pSectBit)
|
if (pSectBit)
|
||||||
SetBitString(pSectBit, nNextSector);
|
SetBitString(pSectBit, nNextSector);
|
||||||
pSectors[n++] = nNextSector;
|
pSectors[n++] = nNextSector;
|
||||||
if (a8 && pWall->extra > 0)
|
if (walls && pWall->extra > 0)
|
||||||
{
|
{
|
||||||
XWALL *pXWall = &xwall[pWall->extra];
|
XWALL *pXWall = &xwall[pWall->extra];
|
||||||
if (pXWall->triggerVector && !pXWall->isTriggered && !pXWall->state)
|
if (pXWall->triggerVector && !pXWall->isTriggered && !pXWall->state)
|
||||||
a8[m++] = j;
|
walls[m++] = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
pSectors[n] = -1;
|
walls[m] = -1;
|
||||||
if (a8)
|
|
||||||
{
|
|
||||||
a8[m] = -1;
|
|
||||||
}
|
|
||||||
return n;
|
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);
|
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);
|
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 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 picWidth(short nPic, short repeat);
|
||||||
int picHeight(short nPic, short repeat);
|
int picHeight(short nPic, short repeat);
|
||||||
|
|
||||||
|
|
|
@ -736,7 +736,6 @@ void LoadSaveSetup(void)
|
||||||
{
|
{
|
||||||
new MyLoadSave();
|
new MyLoadSave();
|
||||||
|
|
||||||
ActorLoadSaveConstruct();
|
|
||||||
AILoadSaveConstruct();
|
AILoadSaveConstruct();
|
||||||
EndGameLoadSaveConstruct();
|
EndGameLoadSaveConstruct();
|
||||||
LevelsLoadSaveConstruct();
|
LevelsLoadSaveConstruct();
|
||||||
|
@ -754,6 +753,7 @@ void SerializeEvents(FSerializer& arc);
|
||||||
void SerializeSequences(FSerializer& arc);
|
void SerializeSequences(FSerializer& arc);
|
||||||
void SerializeWarp(FSerializer& arc);
|
void SerializeWarp(FSerializer& arc);
|
||||||
void SerializeTriggers(FSerializer& arc);
|
void SerializeTriggers(FSerializer& arc);
|
||||||
|
void SerializeActor(FSerializer& arc);
|
||||||
|
|
||||||
void GameInterface::SerializeGameState(FSerializer& arc)
|
void GameInterface::SerializeGameState(FSerializer& arc)
|
||||||
{
|
{
|
||||||
|
@ -770,6 +770,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
||||||
SerializeSequences(arc);
|
SerializeSequences(arc);
|
||||||
SerializeWarp(arc);
|
SerializeWarp(arc);
|
||||||
SerializeTriggers(arc);
|
SerializeTriggers(arc);
|
||||||
|
SerializeActor(arc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2532,9 +2532,7 @@ void teslaHit(spritetype *pMissile, int a2)
|
||||||
int nDist = 300;
|
int nDist = 300;
|
||||||
int nSector = pMissile->sectnum;
|
int nSector = pMissile->sectnum;
|
||||||
int nOwner = actSpriteOwnerToSpriteId(pMissile);
|
int nOwner = actSpriteOwnerToSpriteId(pMissile);
|
||||||
gAffectedSectors[0] = -1;
|
GetClosestSpriteSectors(nSector, x, y, nDist, va4);
|
||||||
gAffectedXWalls[0] = -1;
|
|
||||||
GetClosestSpriteSectors(nSector, x, y, nDist, gAffectedSectors, va4, gAffectedXWalls);
|
|
||||||
char v4 = 1;
|
char v4 = 1;
|
||||||
int v24 = -1;
|
int v24 = -1;
|
||||||
actHitcodeToData(a2, &gHitInfo, &v24, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
actHitcodeToData(a2, &gHitInfo, &v24, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "resourcefile.h"
|
#include "resourcefile.h"
|
||||||
|
#include "build.h"
|
||||||
|
|
||||||
|
extern FixedBitArray<MAXSPRITES> activeSprites;
|
||||||
|
|
||||||
bool OpenSaveGameForWrite(const char *fname, const char *name);
|
bool OpenSaveGameForWrite(const char *fname, const char *name);
|
||||||
bool OpenSaveGameForRead(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 "gamestate.h"
|
||||||
#include "dukeactor.h"
|
#include "dukeactor.h"
|
||||||
|
|
||||||
extern FixedBitArray<MAXSPRITES> activeSprites;
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue