mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-30 15:52:09 +00:00
- Added AActor::SetFriendPlayer() to make setting FriendPlayer cleaner to read when doing it with
a player_t pointer. SVN r3681 (trunk)
This commit is contained in:
parent
2c6763d750
commit
086d0a797e
8 changed files with 28 additions and 49 deletions
|
@ -768,6 +768,8 @@ public:
|
|||
return bloodcls;
|
||||
}
|
||||
|
||||
inline void SetFriendPlayer(player_t *player);
|
||||
|
||||
bool IsVisibleToPlayer() const;
|
||||
|
||||
// Calculate amount of missile damage
|
||||
|
|
|
@ -424,6 +424,18 @@ FArchive &operator<< (FArchive &arc, player_t *&p);
|
|||
|
||||
void P_CheckPlayerSprites();
|
||||
|
||||
inline void AActor::SetFriendPlayer(player_t *player)
|
||||
{
|
||||
if (player == NULL)
|
||||
{
|
||||
FriendPlayer = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FriendPlayer = int(player - players) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define CROUCHSPEED (FRACUNIT/12)
|
||||
|
||||
|
|
|
@ -72,10 +72,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Summon)
|
|||
mo->tracer = self->tracer; // Pointer to master
|
||||
AInventory *power = Spawn<APowerMinotaur> (0, 0, 0, NO_REPLACE);
|
||||
power->CallTryPickup (self->tracer);
|
||||
if (self->tracer->player != NULL)
|
||||
{
|
||||
mo->FriendPlayer = int(self->tracer->player - players + 1);
|
||||
}
|
||||
mo->SetFriendPlayer(self->tracer->player);
|
||||
}
|
||||
|
||||
// Make smoke puff
|
||||
|
|
|
@ -100,7 +100,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon)
|
|||
{
|
||||
rebel->Translation = owner->Translation;
|
||||
}
|
||||
rebel->FriendPlayer = owner->player != NULL ? BYTE(owner->player - players + 1) : 0;
|
||||
rebel->SetFriendPlayer(owner->player);
|
||||
// Set the rebel's target to whatever last hurt the player, so long as it's not
|
||||
// one of the player's other rebels.
|
||||
if (owner->target != NULL && !rebel->IsFriend (owner->target))
|
||||
|
|
|
@ -532,13 +532,9 @@ AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target)
|
|||
{
|
||||
other->FriendPlayer = source->FriendPlayer;
|
||||
}
|
||||
else if (target->player != NULL)
|
||||
{
|
||||
other->FriendPlayer = int(target->player - players) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
other->FriendPlayer = 0;
|
||||
other->SetFriendPlayer(target->player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -925,7 +921,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1)
|
|||
}
|
||||
if (spot != NULL)
|
||||
{
|
||||
spot->FriendPlayer = int(player-players)+1;
|
||||
spot->SetFriendPlayer(player);
|
||||
spot->target = self;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2656,7 +2656,7 @@ int DoSetMaster (AActor *self, AActor *master)
|
|||
self->master = NULL;
|
||||
level.total_monsters -= self->CountsAsKill();
|
||||
self->flags|=MF_FRIENDLY;
|
||||
self->FriendPlayer = int(master->player-players+1);
|
||||
self->SetFriendPlayer(master->player);
|
||||
|
||||
AActor * attacker=master->player->attacker;
|
||||
if (attacker)
|
||||
|
|
|
@ -5387,14 +5387,7 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z,
|
|||
|
||||
if (th->flags4 & MF4_SPECTRAL)
|
||||
{
|
||||
if (owner->player != NULL)
|
||||
{
|
||||
th->FriendPlayer = int(owner->player - players) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
th->FriendPlayer = 0;
|
||||
}
|
||||
th->SetFriendPlayer(owner->player);
|
||||
}
|
||||
|
||||
return (!checkspawn || P_CheckMissileSpawn (th)) ? th : NULL;
|
||||
|
@ -5424,14 +5417,7 @@ AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const
|
|||
|
||||
if (th->flags4 & MF4_SPECTRAL)
|
||||
{
|
||||
if (owner->player != NULL)
|
||||
{
|
||||
th->FriendPlayer = int(owner->player - players) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
th->FriendPlayer = 0;
|
||||
}
|
||||
th->SetFriendPlayer(owner->player);
|
||||
}
|
||||
|
||||
P_CheckMissileSpawn(th);
|
||||
|
@ -5520,14 +5506,7 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z,
|
|||
|
||||
if (mo->flags4 & MF4_SPECTRAL)
|
||||
{
|
||||
if (owner->player != NULL)
|
||||
{
|
||||
mo->FriendPlayer = int(owner->player - players) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mo->FriendPlayer = 0;
|
||||
}
|
||||
mo->SetFriendPlayer(owner->player);
|
||||
}
|
||||
|
||||
return (!checkspawn || P_CheckMissileSpawn(mo)) ? mo : NULL;
|
||||
|
@ -5642,14 +5621,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z,
|
|||
|
||||
if (MissileActor->flags4 & MF4_SPECTRAL)
|
||||
{
|
||||
if (source->player != NULL)
|
||||
{
|
||||
MissileActor->FriendPlayer = int(source->player - players) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
MissileActor->FriendPlayer = 0;
|
||||
}
|
||||
MissileActor->SetFriendPlayer(source->player);
|
||||
}
|
||||
if (P_CheckMissileSpawn (MissileActor))
|
||||
{
|
||||
|
|
|
@ -963,11 +963,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile)
|
|||
missile->tracer=self->target;
|
||||
}
|
||||
// we must redo the spectral check here because the owner is set after spawning so the FriendPlayer value may be wrong
|
||||
if (missile->flags4&MF4_SPECTRAL)
|
||||
if (missile->flags4 & MF4_SPECTRAL)
|
||||
{
|
||||
if (missile->target != NULL && missile->target->player != NULL)
|
||||
if (missile->target != NULL)
|
||||
{
|
||||
missile->FriendPlayer = int(missile->target->player - players) + 1;
|
||||
missile->SetFriendPlayer(missile->target->player);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1737,8 +1737,8 @@ static bool InitSpawnedItem(AActor *self, AActor *mo, int flags)
|
|||
else if (originator->player)
|
||||
{
|
||||
// A player always spawns a monster friendly to him
|
||||
mo->flags|=MF_FRIENDLY;
|
||||
mo->FriendPlayer = int(originator->player-players+1);
|
||||
mo->flags |= MF_FRIENDLY;
|
||||
mo->SetFriendPlayer(originator->player);
|
||||
|
||||
AActor * attacker=originator->player->attacker;
|
||||
if (attacker)
|
||||
|
|
Loading…
Reference in a new issue