mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 06:41:59 +00:00
- Blood: use a TArray for gPost and store actors as pointers.
This also does not need to be serialized because it gets cleared at the end of each game tick and will always be empty when saving is done.
This commit is contained in:
parent
4526f4149b
commit
6db18e61d9
2 changed files with 52 additions and 53 deletions
|
@ -2324,14 +2324,13 @@ const int DudeDifficulty[5] = {
|
||||||
512, 384, 256, 208, 160
|
512, 384, 256, 208, 160
|
||||||
};
|
};
|
||||||
|
|
||||||
int gPostCount = 0;
|
struct POSTPONE
|
||||||
|
{
|
||||||
struct POSTPONE {
|
DBloodActor* sprite;
|
||||||
short sprite;
|
int status;
|
||||||
short status;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
POSTPONE gPost[kMaxSprites];
|
TArray<POSTPONE> gPost;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -7264,59 +7263,59 @@ void DudeToGibCallback2(int, DBloodActor* actor)
|
||||||
pXSprite->state = 1;
|
pXSprite->state = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void actPostSprite(int nSprite, int nStatus)
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void actPostSprite(DBloodActor* actor, int nStatus)
|
||||||
{
|
{
|
||||||
int n;
|
|
||||||
assert(gPostCount < kMaxSprites);
|
|
||||||
assert(nSprite < kMaxSprites && sprite[nSprite].statnum < kMaxStatus);
|
|
||||||
assert(nStatus >= 0 && nStatus <= kStatFree);
|
assert(nStatus >= 0 && nStatus <= kStatFree);
|
||||||
if (sprite[nSprite].flags&32)
|
auto sp = &actor->s();
|
||||||
|
if (sp->flags & 32)
|
||||||
{
|
{
|
||||||
for (n = 0; n < gPostCount; n++)
|
for (auto& post : gPost)
|
||||||
if (gPost[n].sprite == nSprite)
|
if (post.sprite == actor)
|
||||||
break;
|
{
|
||||||
assert(n < gPostCount);
|
post.status = nStatus;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
n = gPostCount;
|
sp->flags |= 32;
|
||||||
sprite[nSprite].flags |= 32;
|
gPost.Push({ actor, nStatus });
|
||||||
gPostCount++;
|
|
||||||
}
|
}
|
||||||
gPost[n].sprite = nSprite;
|
|
||||||
gPost[n].status = nStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
void actPostSprite(DBloodActor* actor, int status)
|
|
||||||
{
|
|
||||||
actPostSprite(actor->s().index, status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void actPostProcess(void)
|
void actPostProcess(void)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < gPostCount; i++)
|
for (auto& p : gPost)
|
||||||
{
|
{
|
||||||
POSTPONE *pPost = &gPost[i];
|
p.sprite->s().flags &= ~32;
|
||||||
int nSprite = pPost->sprite;
|
int nStatus = p.status;
|
||||||
spritetype *pSprite = &sprite[nSprite];
|
|
||||||
pSprite->flags &= ~32;
|
|
||||||
int nStatus = pPost->status;
|
|
||||||
if (nStatus == kStatFree)
|
if (nStatus == kStatFree)
|
||||||
{
|
{
|
||||||
if (pSprite->statnum != kStatFree)
|
if (p.sprite->s().statnum != kStatFree)
|
||||||
{
|
{
|
||||||
evKill(nSprite, 3);
|
evKill(p.sprite);
|
||||||
if (sprite[nSprite].extra > 0)
|
if (p.sprite->hasX()) seqKill(p.sprite);
|
||||||
seqKill(3, pSprite->extra);
|
DeleteSprite(p.sprite->s().index);
|
||||||
DeleteSprite(nSprite);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ChangeSpriteStat(nSprite, nStatus);
|
ChangeSpriteStat(p.sprite->s().index, nStatus);
|
||||||
}
|
}
|
||||||
gPostCount = 0;
|
gPost.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void MakeSplash(DBloodActor* actor)
|
void MakeSplash(DBloodActor* actor)
|
||||||
{
|
{
|
||||||
auto pXSprite = &actor->x();
|
auto pXSprite = &actor->x();
|
||||||
|
@ -7351,17 +7350,6 @@ void MakeSplash(DBloodActor* actor)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, POSTPONE& w, POSTPONE* def)
|
|
||||||
{
|
|
||||||
if (arc.BeginObject(keyname))
|
|
||||||
{
|
|
||||||
arc("sprite", w.sprite)
|
|
||||||
("status", w.status)
|
|
||||||
.EndObject();
|
|
||||||
}
|
|
||||||
return arc;
|
|
||||||
}
|
|
||||||
|
|
||||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, SPRITEHIT& w, SPRITEHIT* def)
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, SPRITEHIT& w, SPRITEHIT* def)
|
||||||
{
|
{
|
||||||
int empty = 0;
|
int empty = 0;
|
||||||
|
@ -7382,8 +7370,6 @@ void SerializeActor(FSerializer& arc)
|
||||||
{
|
{
|
||||||
arc("maxdist20", gVectorData[kVectorTchernobogBurn].maxDist) // The code messes around with this field so better save it.
|
arc("maxdist20", gVectorData[kVectorTchernobogBurn].maxDist) // The code messes around with this field so better save it.
|
||||||
.SparseArray("spritehit", gSpriteHit, kMaxSprites, activeXSprites)
|
.SparseArray("spritehit", gSpriteHit, kMaxSprites, activeXSprites)
|
||||||
("postcount", gPostCount)
|
|
||||||
.Array("post", gPost, gPostCount)
|
|
||||||
.EndObject();
|
.EndObject();
|
||||||
|
|
||||||
if (arc.isReading() && gGameOptions.nMonsterSettings != 0)
|
if (arc.isReading() && gGameOptions.nMonsterSettings != 0)
|
||||||
|
@ -7416,5 +7402,10 @@ int actDamageSprite(int nSource, spritetype* pSprite, DAMAGE_TYPE damageType, in
|
||||||
return actDamageSprite(nSource == -1 ? nullptr : &bloodActors[nSource], &bloodActors[pSprite->index], damageType, damage);
|
return actDamageSprite(nSource == -1 ? nullptr : &bloodActors[nSource], &bloodActors[pSprite->index], damageType, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void actPostSprite(int nSprite, int nStatus)
|
||||||
|
{
|
||||||
|
actPostSprite(&bloodActors[nSprite], nStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
END_BLD_NS
|
END_BLD_NS
|
||||||
|
|
|
@ -283,4 +283,12 @@ inline void viewBackupSpriteLoc(DBloodActor* actor)
|
||||||
viewBackupSpriteLoc(actor->s().index, &actor->s());
|
viewBackupSpriteLoc(actor->s().index, &actor->s());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline FSerializer& Serialize(FSerializer& arc, const char* keyname, DBloodActor*& w, DBloodActor** def)
|
||||||
|
{
|
||||||
|
int index = w? int(w - bloodActors) : -1;
|
||||||
|
Serialize(arc, keyname, index, nullptr);
|
||||||
|
if (arc.isReading()) w = index == -1? nullptr : &bloodActors[index];
|
||||||
|
return arc;
|
||||||
|
}
|
||||||
|
|
||||||
END_BLD_NS
|
END_BLD_NS
|
||||||
|
|
Loading…
Reference in a new issue