mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-05-02 02:23:56 +00:00
Fix player count showing 0 after returning from a race
When exiting a race, LegoRace::Create stashes the UserActor and sets it to NULL. The destructor restores it, but runs later than OnWorldEnabled, so NotifyPlayerCountChanged sees a NULL UserActor and doesn't count the local player. Fall back to GameState::GetActorId() which is restored earlier (in LegoRace::Enable(FALSE)).
This commit is contained in:
parent
e0a1ac781f
commit
dd56e6c686
@ -641,12 +641,18 @@ void NetworkManager::NotifyPlayerCountChanged()
|
||||
if (m_inIsleWorld) {
|
||||
count = 0;
|
||||
|
||||
// Only count the local player if they have a valid actor
|
||||
// (players who enter Isle without selecting a save have no actor).
|
||||
// Only count the local player if they have a valid actor.
|
||||
// UserActor() can be temporarily NULL during world transitions
|
||||
// (e.g. returning from a race, where LegoRace stashes the actor
|
||||
// and only restores it in its destructor). Fall back to the
|
||||
// GameState actorId which is restored earlier.
|
||||
LegoPathActor* userActor = UserActor();
|
||||
if (userActor && IsValidActorId(static_cast<LegoActor*>(userActor)->GetActorId())) {
|
||||
count = 1;
|
||||
}
|
||||
else if (IsValidActorId(GameState()->GetActorId())) {
|
||||
count = 1;
|
||||
}
|
||||
|
||||
for (auto& [peerId, player] : m_remotePlayers) {
|
||||
if (player->GetWorldId() == (int8_t) LegoOmni::e_act1) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user