Skip to content

Commit 8e96e1c

Browse files
committed
Add forced respawn char handover after 5 seconds
Add debug logging why deferred results might not always work (needs loglevel verbose) Add debug logging for respawn system nullptr investigation (needs loglevel verbose)
1 parent c88e40f commit 8e96e1c

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/Scripts/Game/EPF_DeferredApplyResult.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class EPF_DeferredApplyResult
2121
//------------------------------------------------------------------------------------------------
2222
static void AddPending(notnull EPF_EntitySaveData saveData, string awaitIdentifier)
2323
{
24+
Print(string.Format("EPF_DeferredApplyResult.AddPending(%1, %2)", saveData, awaitIdentifier), LogLevel.VERBOSE);
25+
2426
EPF_PendingIdentifierHolder data = s_mPendingIdentifiers.Get(saveData);
2527
if (!data)
2628
{
@@ -35,6 +37,8 @@ class EPF_DeferredApplyResult
3537
//------------------------------------------------------------------------------------------------
3638
static void AddPending(notnull EPF_ComponentSaveData componentSaveData, string awaitIdentifier)
3739
{
40+
Print(string.Format("EPF_DeferredApplyResult.AddPending(%1, %2)", componentSaveData, awaitIdentifier), LogLevel.VERBOSE);
41+
3842
EPF_PendingComponentIdentifierHolder data = s_mPendingComponentIdentifiers.Get(componentSaveData);
3943
if (!data)
4044
{
@@ -49,6 +53,8 @@ class EPF_DeferredApplyResult
4953
//------------------------------------------------------------------------------------------------
5054
static void SetFinished(notnull EPF_EntitySaveData saveData, string awaitIdentifier)
5155
{
56+
Print(string.Format("EPF_DeferredApplyResult.SetFinished(%1, %2)", saveData, awaitIdentifier), LogLevel.VERBOSE);
57+
5258
EPF_PendingIdentifierHolder data = s_mPendingIdentifiers.Get(saveData);
5359
if (!data)
5460
return;
@@ -62,6 +68,8 @@ class EPF_DeferredApplyResult
6268
//------------------------------------------------------------------------------------------------
6369
static void SetFinished(notnull EPF_ComponentSaveData componentSaveData, string awaitIdentifier)
6470
{
71+
Print(string.Format("EPF_DeferredApplyResult.SetFinished(%1, %2)", componentSaveData, awaitIdentifier), LogLevel.VERBOSE);
72+
6573
EPF_PendingComponentIdentifierHolder data = s_mPendingComponentIdentifiers.Get(componentSaveData);
6674
if (!data)
6775
return;

src/Scripts/Game/RespawnSystem/EPF_RespawnHandlerComponent.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,17 @@ class EPF_RespawnHandlerComponent : SCR_RespawnHandlerComponent
135135
iterCopy.Copy(m_sEnqueuedPlayers);
136136
foreach (int playerId : iterCopy)
137137
{
138-
if (m_pRespawnSystem.IsReadyForSpawn(playerId))
139-
m_pPlayerManager.GetPlayerController(playerId).RequestRespawn();
138+
if (!m_pRespawnSystem.IsReadyForSpawn(playerId))
139+
continue;
140+
141+
PlayerController playerController = m_pPlayerManager.GetPlayerController(playerId);
142+
if (!playerController)
143+
{
144+
Print("Failed to get player controller for playerId: " + playerId, LogLevel.VERBOSE);
145+
continue;
146+
}
147+
148+
playerController.RequestRespawn();
140149
}
141150
}
142151

src/Scripts/Game/RespawnSystem/EPF_RespawnSytemComponent.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class EPF_RespawnSytemComponent : SCR_RespawnSystemComponent
3232
m_mLoadingCharacters.Set(playerEntity, playerId);
3333

3434
persistenceComponent.GetOnAfterLoadEvent().Insert(OnCharacterLoaded);
35+
36+
// TODO: Remove hard loading time limit when we know all spawn block bugs are fixed.
37+
GetGame().GetCallqueue().CallLater(OnCharacterLoaded, 5000, false, persistenceComponent, saveData);
38+
3539
if (persistenceComponent.Load(saveData))
3640
return;
3741

@@ -79,13 +83,19 @@ class EPF_RespawnSytemComponent : SCR_RespawnSystemComponent
7983
//------------------------------------------------------------------------------------------------
8084
protected void OnCharacterLoaded(EPF_PersistenceComponent persistenceComponent, EPF_EntitySaveData saveData)
8185
{
82-
// We only want to know this once
83-
persistenceComponent.GetOnAfterLoadEvent().Remove(OnCharacterLoaded);
86+
if (!persistenceComponent || !saveData)
87+
return;
8488

8589
GenericEntity playerEntity = GenericEntity.Cast(persistenceComponent.GetOwner());
86-
int playerId = m_mLoadingCharacters.Get(playerEntity);
90+
int playerId;
91+
if (!m_mLoadingCharacters.Find(playerEntity, playerId))
92+
return; // Already processed before the hard loading limit callqueue invoke
93+
8794
m_mLoadingCharacters.Remove(playerEntity);
8895

96+
// We only want to know this once
97+
persistenceComponent.GetOnAfterLoadEvent().Remove(OnCharacterLoaded);
98+
8999
EPF_PersistenceManager persistenceManager = EPF_PersistenceManager.GetInstance();
90100
SCR_CharacterInventoryStorageComponent inventoryStorage = EPF_Component<SCR_CharacterInventoryStorageComponent>.Find(playerEntity);
91101
if (inventoryStorage)

0 commit comments

Comments
 (0)