mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-06 10:44:08 +00:00
chore: Simplify and move Player functionality to relevant component (#1408)
* Moving and organizing Player code - Move code to CharacterComponent - Remove extraneous interfaces - Simplify some code greatly - Change some types to return and take in const ref (only structs larger than 8 bytes benefit from this change.) - Update code to use CharacterComponent for sending to zone instead of Player*. * Moving and organizing Player code - Move code to CharacterComponent - Remove extraneous interfaces - Simplify some code greatly - Change some types to return and take in const ref (only structs larger than 8 bytes benefit from this change.) - Update code to use CharacterComponent for sending to zone instead of Player*. - Remove static storage container (static containers can be destroyed before exit/terminate handler executes) * remove player cast * Remove extra includes
This commit is contained in:
@@ -71,10 +71,8 @@ void RacingControlComponent::OnPlayerLoaded(Entity* player) {
|
||||
|
||||
// If the race has already started, send the player back to the main world.
|
||||
if (m_Loaded || !vehicle) {
|
||||
auto* playerInstance = dynamic_cast<Player*>(player);
|
||||
if (playerInstance) {
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
}
|
||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,10 +103,11 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
|
||||
if (item == nullptr) {
|
||||
LOG("Failed to find item");
|
||||
auto* playerInstance = dynamic_cast<Player*>(player);
|
||||
if (playerInstance) {
|
||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||
|
||||
if (characterComponent) {
|
||||
m_LoadedPlayers--;
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
characterComponent->SendToZone(m_MainWorld);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -427,9 +426,9 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
|
||||
m_Parent->GetObjectID(), 3, 0, LWOOBJID_EMPTY, u"",
|
||||
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
auto* playerInstance = dynamic_cast<Player*>(player);
|
||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
||||
|
||||
vehicle->Kill();
|
||||
}
|
||||
@@ -561,9 +560,9 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* playerInstance = dynamic_cast<Player*>(playerEntity);
|
||||
auto* characterComponent = playerEntity->GetComponent<CharacterComponent>();
|
||||
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
||||
}
|
||||
|
||||
m_LobbyPlayers.clear();
|
||||
@@ -623,9 +622,9 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* playerInstance = dynamic_cast<Player*>(playerEntity);
|
||||
auto* characterComponent = playerEntity->GetComponent<CharacterComponent>();
|
||||
|
||||
playerInstance->SendToZone(m_MainWorld);
|
||||
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
||||
}
|
||||
|
||||
return;
|
||||
|
Reference in New Issue
Block a user