Fix duplicate init else player, duplicate model

This commit is contained in:
HungDK
2025-11-05 16:38:23 +07:00
parent 19b42000a0
commit 691b27b69f
@@ -312,12 +312,23 @@ namespace PerfectWorld.Scripts.Managers
// Has player been in active player table ?
EC_ElsePlayer pPlayer = GetElsePlayer(info.cid);
if (pPlayer)
if (pPlayer != null)
{
// This player has existed in player table, call special initial function
// TODO: fix after pPlayer init
pPlayer.Init(roleInfo, info);
return pPlayer;
// Check if the GameObject is still valid (not destroyed)
if (pPlayer.gameObject != null)
{
// This player has existed in player table, call special initial function
pPlayer.Init(roleInfo, info);
return pPlayer;
}
else
{
// GameObject was destroyed but entry still exists in table - clean it up
lock (m_csPlayerTab)
{
m_PlayerTab.Remove(info.cid);
}
}
}
// Create a new player