Skip to content

Commit

Permalink
Add PlayerSpawned() event (ZDoom#1118)
Browse files Browse the repository at this point in the history
* Add PlayerSpawned() event

* add playerspawned to DStaticEventHandler

* Define PlyerSpawned() correctly
  • Loading branch information
caligari87 authored and emawind84 committed Jan 30, 2024
1 parent f5ec1a2 commit ac88dc1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,11 @@ void EventManager::PlayerEntered(int num, bool fromhub)
handler->PlayerEntered(num, fromhub);
}

void E_PlayerSpawned(int num)
void EventManager::PlayerSpawned(int num)
{
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
if (ShouldCallStatic(true)) staticEventManager.PlayerSpawned(num);

for (DStaticEventHandler* handler = FirstEventHandler; handler; handler = handler->next)
handler->PlayerSpawned(num);
}

Expand Down
2 changes: 2 additions & 0 deletions src/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ struct EventManager
void RenderUnderlay(EHudState state);
// this executes when a player enters the level (once). PlayerEnter+inhub = RETURN
void PlayerEntered(int num, bool fromhub);
// this executes at the same time as ENTER scripts
void PlayerSpawned(int num);
// this executes when a player respawns. includes resurrect cheat.
void PlayerRespawned(int num);
// this executes when a player dies (partially duplicating worldthingdied, but whatever)
Expand Down
2 changes: 1 addition & 1 deletion src/p_mobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5280,7 +5280,7 @@ AActor *FLevelLocals::SpawnPlayer (FPlayerStart *mthing, int playernum, int flag
if (state == PST_ENTER || (state == PST_LIVE && !savegamerestore))
{
Behaviors.StartTypedScripts (SCRIPT_Enter, p->mo, true);
E_PlayerSpawned(PlayerNum(p));
localEventManager->PlayerSpawned(PlayerNum(p));
}
else if (state == PST_REBORN)
{
Expand Down

0 comments on commit ac88dc1

Please sign in to comment.