mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-11 04:51:13 +00:00
Add PlayerSpawned() event (#1118)
* Add PlayerSpawned() event * add playerspawned to DStaticEventHandler * Define PlyerSpawned() correctly # Conflicts: # src/events.cpp # src/events.h # src/p_mobj.cpp
This commit is contained in:
parent
debd2efefa
commit
13f4636387
4 changed files with 32 additions and 0 deletions
|
@ -449,6 +449,12 @@ void E_PlayerEntered(int num, bool fromhub)
|
|||
handler->PlayerEntered(num, fromhub);
|
||||
}
|
||||
|
||||
void E_PlayerSpawned(int num)
|
||||
{
|
||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||
handler->PlayerSpawned(num);
|
||||
}
|
||||
|
||||
void E_PlayerRespawned(int num)
|
||||
{
|
||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||
|
@ -1024,6 +1030,18 @@ void DStaticEventHandler::PlayerEntered(int num, bool fromhub)
|
|||
}
|
||||
}
|
||||
|
||||
void DStaticEventHandler::PlayerSpawned(int num)
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, PlayerSpawned)
|
||||
{
|
||||
// don't create excessive DObjects if not going to be processed anyway
|
||||
if (isEmpty(func)) return;
|
||||
FPlayerEvent e = { num, false };
|
||||
VMValue params[2] = { (DStaticEventHandler*)this, &e };
|
||||
VMCall(func, params, 2, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DStaticEventHandler::PlayerRespawned(int num)
|
||||
{
|
||||
IFVIRTUAL(DStaticEventHandler, PlayerRespawned)
|
||||
|
|
|
@ -70,6 +70,8 @@ void E_RenderOverlay(EHudState state);
|
|||
void E_RenderUnderlay(EHudState state);
|
||||
// this executes when a player enters the level (once). PlayerEnter+inhub = RETURN
|
||||
void E_PlayerEntered(int num, bool fromhub);
|
||||
// this executes at the same time as ENTER scripts
|
||||
void E_PlayerSpawned(int num);
|
||||
// this executes when a player respawns. includes resurrect cheat.
|
||||
void E_PlayerRespawned(int num);
|
||||
// this executes when a player dies (partially duplicating worldthingdied, but whatever)
|
||||
|
@ -177,6 +179,7 @@ public:
|
|||
|
||||
//
|
||||
void PlayerEntered(int num, bool fromhub);
|
||||
void PlayerSpawned(int num);
|
||||
void PlayerRespawned(int num);
|
||||
void PlayerDied(int num);
|
||||
void PlayerDisconnected(int num);
|
||||
|
|
|
@ -5047,6 +5047,15 @@ void PlayerSpawnPickClass (int playernum)
|
|||
}
|
||||
}
|
||||
|
||||
int PlayerNum(player_t *player)
|
||||
{
|
||||
for (int i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (player == &players[i]) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
|
||||
{
|
||||
player_t *p;
|
||||
|
@ -5264,6 +5273,7 @@ AActor *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
|
|||
if (state == PST_ENTER || (state == PST_LIVE && !savegamerestore))
|
||||
{
|
||||
FBehavior::StaticStartTypedScripts (SCRIPT_Enter, p->mo, true);
|
||||
E_PlayerSpawned(PlayerNum(p));
|
||||
}
|
||||
else if (state == PST_REBORN)
|
||||
{
|
||||
|
|
|
@ -345,6 +345,7 @@ class StaticEventHandler : Object native play version("2.4")
|
|||
|
||||
//
|
||||
virtual void PlayerEntered(PlayerEvent e) {}
|
||||
virtual void PlayerSpawned(PlayerEvent e) {}
|
||||
virtual void PlayerRespawned(PlayerEvent e) {}
|
||||
virtual void PlayerDied(PlayerEvent e) {}
|
||||
virtual void PlayerDisconnected(PlayerEvent e) {}
|
||||
|
|
Loading…
Reference in a new issue