From 288991ef49dd915278b31c343a2f4426a3bf269c Mon Sep 17 00:00:00 2001 From: TAHuntling <38479763+TAHuntling@users.noreply.github.com> Date: Sun, 8 Oct 2023 19:38:48 -0500 Subject: [PATCH] fix: Players are able to join a race without having a race car (#1149) * Fixed Scrapped Racecar Stuck Issue Changed RacingControlComponent to boot players back to the hub world when trying to race after dismantling a vehicle. * Modified OnPlayerLoaded to fix Vehicle Inventory issue * Change 3 --------- Co-authored-by: David Markowitz --- dGame/dComponents/RacingControlComponent.cpp | 29 +++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index 7a4d98ea..12f4201a 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -61,23 +61,27 @@ RacingControlComponent::RacingControlComponent(Entity* parent) RacingControlComponent::~RacingControlComponent() {} void RacingControlComponent::OnPlayerLoaded(Entity* player) { - // If the race has already started, send the player back to the main world. - if (m_Loaded) { - auto* playerInstance = dynamic_cast(player); - - playerInstance->SendToZone(m_MainWorld); - + auto* inventoryComponent = player->GetComponent(); + if (!inventoryComponent) { return; } - const auto objectID = player->GetObjectID(); + auto* vehicle = inventoryComponent->FindItemByLot(8092); + + // If the race has already started, send the player back to the main world. + if (m_Loaded || !vehicle) { + auto* playerInstance = dynamic_cast(player); + if(playerInstance){ + playerInstance->SendToZone(m_MainWorld); + } + return; + } m_LoadedPlayers++; Game::logger->Log("RacingControlComponent", "Loading player %i", m_LoadedPlayers); - - m_LobbyPlayers.push_back(objectID); + m_LobbyPlayers.push_back(player->GetObjectID()); } void RacingControlComponent::LoadPlayerVehicle(Entity* player, @@ -100,8 +104,13 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player, if (item == nullptr) { Game::logger->Log("RacingControlComponent", "Failed to find item"); - + auto* playerInstance = dynamic_cast(player); + if(playerInstance){ + m_LoadedPlayers--; + playerInstance->SendToZone(m_MainWorld); + } return; + } // Calculate the vehicle's starting position.