mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-18 14:41:40 +00:00
- changed most places where a player index is calculated by subtracting the player array's base access.
This commit is contained in:
parent
d358e401ee
commit
202f3d7d80
10 changed files with 27 additions and 25 deletions
|
@ -270,7 +270,7 @@ int FParser::T_GetPlayerNum(const svalue_t &arg)
|
|||
//script_error("mobj not a player!\n");
|
||||
return -1;
|
||||
}
|
||||
playernum = int(arg.value.mobj->player - players);
|
||||
playernum = Level->PlayerNum(arg.value.mobj->player);
|
||||
}
|
||||
else
|
||||
playernum = intvalue(arg);
|
||||
|
@ -734,7 +734,7 @@ void FParser::SF_PlayerName(void)
|
|||
{
|
||||
player_t *pl=NULL;
|
||||
if (Script->trigger) pl = Script->trigger->player;
|
||||
if(pl) plnum = int(pl - players);
|
||||
if(pl) plnum = Level->PlayerNum(pl);
|
||||
else plnum=-1;
|
||||
}
|
||||
else
|
||||
|
@ -765,7 +765,7 @@ void FParser::SF_PlayerObj(void)
|
|||
{
|
||||
player_t *pl=NULL;
|
||||
if (Script->trigger) pl = Script->trigger->player;
|
||||
if(pl) plnum = int(pl - players);
|
||||
if(pl) plnum = Level->PlayerNum(pl);
|
||||
else plnum=-1;
|
||||
}
|
||||
else
|
||||
|
@ -805,7 +805,7 @@ void FParser::SF_Player(void)
|
|||
|
||||
if(mo && mo->player) // haleyjd: added mo->player
|
||||
{
|
||||
t_return.value.i = (int)(mo->player - players);
|
||||
t_return.value.i = Level->PlayerNum(mo->player);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -675,9 +675,9 @@ void FLevelLocals::ChangeLevel(const char *levelname, int position, int flags, i
|
|||
|
||||
for(int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (playeringame[i])
|
||||
if (PlayerInGame(i))
|
||||
{
|
||||
player_t *player = &players[i];
|
||||
player_t *player = Players[i];
|
||||
|
||||
// Un-crouch all players here.
|
||||
player->Uncrouch();
|
||||
|
|
|
@ -9648,7 +9648,7 @@ scriptwait:
|
|||
}
|
||||
else
|
||||
{
|
||||
PushToStack (int(activator->player - players));
|
||||
PushToStack (Level->PlayerNum(activator->player));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -10351,7 +10351,7 @@ static void addDefered (level_info_t *i, acsdefered_t::EType type, int script, c
|
|||
}
|
||||
if (who != NULL && who->player != NULL)
|
||||
{
|
||||
def.playernum = int(who->player - players);
|
||||
def.playernum = who->Level->PlayerNum(who->player);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -746,10 +746,10 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang
|
|||
// anyone else talk to the NPC.
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (!playeringame[i] || pc->player == &players[i])
|
||||
if (!Level->PlayerInGame(i) || pc->player == Level->Players[i])
|
||||
continue;
|
||||
|
||||
if (npc == players[i].ConversationNPC)
|
||||
if (npc == Level->Players[i]->ConversationNPC)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -401,7 +401,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
|
|||
// fair to count them toward a player's score.
|
||||
if (player && Level->maptime)
|
||||
{
|
||||
source->player->frags[player - players]++;
|
||||
source->player->frags[Level->PlayerNum(player)]++;
|
||||
if (player == source->player) // [RH] Cumulative frag count
|
||||
{
|
||||
char buff[256];
|
||||
|
@ -560,7 +560,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
|
|||
ClientObituary (this, inflictor, source, dmgflags, MeansOfDeath);
|
||||
|
||||
// [ZZ] fire player death hook
|
||||
E_PlayerDied(int(player - players));
|
||||
E_PlayerDied(Level->PlayerNum(player));
|
||||
|
||||
// Death script execution, care of Skull Tag
|
||||
Level->Behaviors.StartTypedScripts (SCRIPT_Death, this, true);
|
||||
|
@ -593,7 +593,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
|
|||
// count environment kills against you
|
||||
if (!source)
|
||||
{
|
||||
player->frags[player - players]++;
|
||||
player->frags[Level->PlayerNum(player)]++;
|
||||
player->fragcount--; // [RH] Cumulative frag count
|
||||
}
|
||||
|
||||
|
|
|
@ -384,7 +384,7 @@ void AActor::PostSerialize()
|
|||
AddToHash();
|
||||
if (player)
|
||||
{
|
||||
if (playeringame[player - players] &&
|
||||
if (Level->PlayerInGame(player) &&
|
||||
player->cls != NULL &&
|
||||
!(flags4 & MF4_NOSKIN) &&
|
||||
state->sprite == GetDefaultByType(player->cls)->SpawnState->sprite)
|
||||
|
@ -489,7 +489,7 @@ int AActor::GetTics(FState * newstate)
|
|||
bool AActor::SetState (FState *newstate, bool nofunction)
|
||||
{
|
||||
if (debugfile && player && (player->cheats & CF_PREDICTING))
|
||||
fprintf (debugfile, "for pl %td: SetState while predicting!\n", player-players);
|
||||
fprintf (debugfile, "for pl %d: SetState while predicting!\n", Level->PlayerNum(player));
|
||||
do
|
||||
{
|
||||
if (newstate == NULL)
|
||||
|
@ -5155,7 +5155,7 @@ AActor *FLevelLocals::SpawnPlayer (FPlayerStart *mthing, int playernum, int flag
|
|||
|
||||
DObject::StaticPointerSubstitution (oldactor, p->mo);
|
||||
|
||||
E_PlayerRespawned(int(p - players));
|
||||
E_PlayerRespawned(PlayerNum(p));
|
||||
Behaviors.StartTypedScripts (SCRIPT_Respawn, p->mo, true);
|
||||
}
|
||||
}
|
||||
|
@ -6765,7 +6765,7 @@ int AActor::GetTeam()
|
|||
// Check for monsters that belong to a player on the team but aren't part of the team themselves.
|
||||
if (myTeam == TEAM_NONE && FriendPlayer != 0)
|
||||
{
|
||||
myTeam = players[FriendPlayer - 1].userinfo.GetTeam();
|
||||
myTeam = Level->Players[FriendPlayer - 1]->userinfo.GetTeam();
|
||||
}
|
||||
return myTeam;
|
||||
|
||||
|
|
|
@ -588,13 +588,13 @@ void P_SerializePlayers(FLevelLocals *Level, FSerializer &arc, bool skipload)
|
|||
// Record each player's name, followed by their data.
|
||||
for (i = 0; i < MAXPLAYERS; ++i)
|
||||
{
|
||||
if (playeringame[i])
|
||||
if (Level->PlayerInGame(i))
|
||||
{
|
||||
if (arc.BeginObject(nullptr))
|
||||
{
|
||||
const char *n = players[i].userinfo.GetName();
|
||||
const char *n = Level->Players[i]->userinfo.GetName();
|
||||
arc.StringPtr("playername", n);
|
||||
players[i].Serialize(arc);
|
||||
Level->Players[i]->Serialize(arc);
|
||||
arc.EndObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -676,9 +676,10 @@ bool player_t::Resurrect()
|
|||
mo->special1 = 0; // required for the Hexen fighter's fist attack.
|
||||
// This gets set by AActor::Die as flag for the wimpy death and must be reset here.
|
||||
mo->SetState(mo->SpawnState);
|
||||
int pnum = mo->Level->PlayerNum(this);
|
||||
if (!(mo->flags2 & MF2_DONTTRANSLATE))
|
||||
{
|
||||
mo->Translation = TRANSLATION(TRANSLATION_Players, uint8_t(this - players));
|
||||
mo->Translation = TRANSLATION(TRANSLATION_Players, uint8_t(pnum));
|
||||
}
|
||||
if (ReadyWeapon != nullptr)
|
||||
{
|
||||
|
@ -693,7 +694,7 @@ bool player_t::Resurrect()
|
|||
|
||||
// player is now alive.
|
||||
// fire E_PlayerRespawned and start the ACS SCRIPT_Respawn.
|
||||
E_PlayerRespawned(int(this - players));
|
||||
E_PlayerRespawned(pnum);
|
||||
//
|
||||
mo->Level->Behaviors.StartTypedScripts(SCRIPT_Respawn, mo, true);
|
||||
return true;
|
||||
|
@ -1124,7 +1125,7 @@ void P_CheckMusicChange(player_t *player)
|
|||
S_ChangeMusic("*");
|
||||
}
|
||||
}
|
||||
DPrintf(DMSG_NOTIFY, "MUSINFO change for player %d to %d\n", (int)(player - players), player->MUSINFOactor->args[0]);
|
||||
DPrintf(DMSG_NOTIFY, "MUSINFO change for player %d to %d\n", (int)player->mo->Level->PlayerNum(player), player->MUSINFOactor->args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "vm.h"
|
||||
#include "d_player.h"
|
||||
#include "hw_postprocessshader.h"
|
||||
#include "g_levellocals.h"
|
||||
|
||||
TArray<PostProcessShader> PostProcessShaders;
|
||||
|
||||
|
@ -32,7 +33,7 @@ static bool IsConsolePlayer(player_t *player)
|
|||
AActor *activator = player ? player->mo : nullptr;
|
||||
if (activator == nullptr || activator->player == nullptr)
|
||||
return false;
|
||||
return int(activator->player - players) == consoleplayer;
|
||||
return activator->player == activator->Level->GetConsolePlayer();
|
||||
}
|
||||
|
||||
static void ShaderSetEnabled(player_t *player, const FString &shaderName, bool value)
|
||||
|
|
|
@ -566,7 +566,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, RestoreDamage, RestoreDamage)
|
|||
|
||||
static int PlayerNumber(AActor *self)
|
||||
{
|
||||
return self->player ? int(self->player - players) : 0;
|
||||
return self->player ? self->Level->PlayerNum(self->player) : 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, PlayerNumber, PlayerNumber)
|
||||
|
|
Loading…
Reference in a new issue