Skip to content

Commit

Permalink
Fixed DOOM: Dynamically spawned BOSSTARGETs (e.g., using the spawnmob…
Browse files Browse the repository at this point in the history
…j ccmd) only worked as expected if the player saved the game and then loaded it (at which point the target would be added to list of known boss brain targets).

Fixed DOOM: Upon loading a saved game duplicate BOSSTARGETs would be spawned. Note that this would have no visible effect on gameplay.
  • Loading branch information
danij-deng committed Apr 20, 2010
1 parent 877643e commit a8dafdc
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 57 deletions.
5 changes: 0 additions & 5 deletions doomsday/plugins/common/src/p_mapsetup.c
Expand Up @@ -680,11 +680,6 @@ int P_SetupMapWorker(void* ptr)

P_LoadMapObjs();

#if __JDOOM__
if(gameMode == commercial)
P_SpawnBrainTargets();
#endif

#if __JHERETIC__
if(maceSpotCount)
{
Expand Down
5 changes: 1 addition & 4 deletions doomsday/plugins/common/src/p_saveg.c
Expand Up @@ -4344,7 +4344,7 @@ static void P_ArchiveBrain(void)

static void P_UnArchiveBrain(void)
{
int i;
int i;

if(hdr.version < 3)
return; // No brain data before version 3.
Expand All @@ -4356,9 +4356,6 @@ static void P_UnArchiveBrain(void)
brainTargets[i] = (mobj_t*) (int) SV_ReadShort();
brainTargets[i] = SV_GetArchiveThing((int) brainTargets[i], NULL);
}

if(gameMode == commercial)
P_SpawnBrainTargets();
}
#endif

Expand Down
2 changes: 0 additions & 2 deletions doomsday/plugins/jdoom/include/p_enemy.h
Expand Up @@ -47,8 +47,6 @@ extern int numBrainTargetsAlloc;

extern boolean bossKilled;

void P_SpawnBrainTargets(void);

void P_NoiseAlert(mobj_t *target, mobj_t *emmiter);
int P_Massacre(void);

Expand Down
44 changes: 0 additions & 44 deletions doomsday/plugins/jdoom/src/p_enemy.c
Expand Up @@ -555,50 +555,6 @@ int P_Massacre(void)
return count;
}

static boolean findBrainTarget(thinker_t* th, void* context)
{
mobj_t* mo = (mobj_t *) th;

if(mo->type == MT_BOSSTARGET)
{
if(numBrainTargets >= numBrainTargetsAlloc)
{
// Do we need to alloc more targets?
if(numBrainTargets == numBrainTargetsAlloc)
{
numBrainTargetsAlloc *= 2;
brainTargets =
Z_Realloc(brainTargets,
numBrainTargetsAlloc * sizeof(*brainTargets),
PU_MAP);
}
else
{
numBrainTargetsAlloc = 32;
brainTargets =
Z_Malloc(numBrainTargetsAlloc * sizeof(*brainTargets),
PU_MAP, NULL);
}
}

brainTargets[numBrainTargets++] = mo;
}

return true; // Continue iteration.
}

/**
* Initialize boss brain targets at map startup, rather than at boss
* wakeup, to prevent savegame-related crashes.
*
* \todo Does not belong in this file, find it a better home.
*/
void P_SpawnBrainTargets(void)
{
// Find all the target spots.
DD_IterateThinkers(P_MobjThinker, findBrainTarget, NULL);
}

typedef struct {
mobjtype_t type;
size_t count;
Expand Down
20 changes: 20 additions & 0 deletions doomsday/plugins/jdoom/src/p_mobj.c
Expand Up @@ -946,6 +946,26 @@ mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z,
}
}

if(type == MT_BOSSTARGET)
{
if(numBrainTargets >= numBrainTargetsAlloc)
{
// Do we need to alloc more targets?
if(numBrainTargets == numBrainTargetsAlloc)
{
numBrainTargetsAlloc *= 2;
brainTargets = Z_Realloc(brainTargets, numBrainTargetsAlloc * sizeof(*brainTargets), PU_MAP);
}
else
{
numBrainTargetsAlloc = 32;
brainTargets = Z_Malloc(numBrainTargetsAlloc * sizeof(*brainTargets), PU_MAP, NULL);
}
}

brainTargets[numBrainTargets++] = mo;
}

// Copy spawn attributes to the new mobj.
mo->spawnSpot.pos[VX] = x;
mo->spawnSpot.pos[VY] = y;
Expand Down
2 changes: 0 additions & 2 deletions doomsday/plugins/jdoom64/include/p_enemy.h
Expand Up @@ -34,8 +34,6 @@

extern boolean bossKilled;

void P_SpawnBrainTargets(void);

void P_NoiseAlert(mobj_t *target, mobj_t *emmiter);
int P_Massacre(void);

Expand Down

0 comments on commit a8dafdc

Please sign in to comment.