- added a ClearCounters function to AActor that handles everything necessary to un-count an item that is not supposed to be counted but has some of the COUNT* flags set.

- merged all places where secrets are credited into one common function.
- added the Doom64 COUNTSECRET actor flag.
- fixed: AInventory::CreateCopy did not clear the COUNTITEM flag.
- fixed: Dropping an item did not increase the item count but the dropped item could still have the COUNTITEM flag. Now this flag gets cleared when the item gets picked up so that dropped items don't count a second time.

SVN r2826 (trunk)
This commit is contained in:
Christoph Oelckers 2010-09-19 00:06:45 +00:00
commit df138fe4f9
20 changed files with 137 additions and 100 deletions

View file

@ -258,9 +258,18 @@ void AActor::Serialize (FArchive &arc)
<< args[0] << args[1] << args[2] << args[3] << args[4]
<< goal
<< waterlevel
<< MinMissileChance
<< SpawnFlags
<< Inventory
<< MinMissileChance;
if (SaveVersion >= 2826)
{
arc << SpawnFlags;
}
else
{
WORD w;
arc << w;
SpawnFlags = w;
}
arc << Inventory
<< InventoryID
<< id
<< FloatBobPhase
@ -728,6 +737,7 @@ AInventory *AActor::DropInventory (AInventory *item)
drop->vely = vely + 5 * finesine[an];
drop->velz = velz + FRACUNIT;
drop->flags &= ~MF_NOGRAVITY; // Don't float
drop->ClearCounters(); // do not count for statistics again
return drop;
}
@ -2458,7 +2468,7 @@ void P_NightmareRespawn (AActor *mobj)
if (!P_TestMobjLocation (mo))
{
//[GrafZahl] MF_COUNTKILL still needs to be checked here.
if (mo->CountsAsKill()) level.total_monsters--;
mo->ClearCounters();
mo->Destroy ();
return; // no respawn
}
@ -3626,6 +3636,11 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t
{
level.total_items++;
}
// And for secrets
if (actor->flags5 & MF5_COUNTSECRET)
{
level.total_secrets++;
}
if (screen != NULL)
{
screen->StateChanged(actor);
@ -3695,6 +3710,11 @@ void AActor::HandleSpawnFlags ()
{
RenderStyle = STYLE_None;
}
if (SpawnFlags & MTF_SECRET)
{
//Printf("Secret %s in sector %i!\n", GetTag(), Sector->sectornum);
flags5 |= MF5_COUNTSECRET;
}
}
void AActor::BeginPlay ()
@ -4969,11 +4989,7 @@ bool P_CheckMissileSpawn (AActor* th)
if (th->BlockingMobj == NULL || !(th->flags2 & MF2_RIP) || (th->BlockingMobj->flags5 & MF5_DONTRIP))
{
// If this is a monster spawned by A_CustomMissile subtract it from the counter.
if (th->CountsAsKill())
{
th->flags&=~MF_COUNTKILL;
level.total_monsters--;
}
th->ClearCounters();
// [RH] Don't explode missiles that spawn on top of horizon lines
if (th->BlockingLine != NULL && th->BlockingLine->special == Line_Horizon)
{
@ -5602,6 +5618,28 @@ const char *AActor::GetTag(const char *def) const
}
void AActor::ClearCounters()
{
if (CountsAsKill())
{
level.total_monsters--;
flags &= ~MF_COUNTKILL;
}
// Same, for items
if (flags & MF_COUNTITEM)
{
level.total_items--;
flags &= ~MF_COUNTITEM;
}
// And finally for secrets
if (flags5 & MF5_COUNTSECRET)
{
level.total_secrets--;
flags5 &= ~MF5_COUNTSECRET;
}
}
//----------------------------------------------------------------------------
//
// DropItem handling