diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 1ced2f54..8109d90c 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -725,7 +725,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType const auto isPlayer = m_Parent->IsPlayer(); - GameMessages::SendDie(m_Parent, source, source, true, killType, deathType, 0, 0, 0, isPlayer, false, 1); + GameMessages::SendDie(m_Parent, source, source, true, killType, deathType, 0, 0, 0, isPlayer, false); //NANI?! if (!isPlayer) { diff --git a/dGame/dComponents/QuickBuildComponent.cpp b/dGame/dComponents/QuickBuildComponent.cpp index 03f6bd2e..496fbe7a 100644 --- a/dGame/dComponents/QuickBuildComponent.cpp +++ b/dGame/dComponents/QuickBuildComponent.cpp @@ -41,7 +41,7 @@ QuickBuildComponent::QuickBuildComponent(Entity* parent, uint32_t id) : Activity SetPostImaginationCost(rebCompData[0].post_imagination_cost); SetTimeBeforeSmash(rebCompData[0].time_before_smash); const auto compTime = m_Parent->GetVar(u"compTime"); - if (compTime > 0) SetCompleteTime(compTime); + if (m_Parent->HasVar(u"compTime") && compTime > 0) SetCompleteTime(compTime); } std::u16string checkPreconditions = m_Parent->GetVar(u"CheckPrecondition"); @@ -118,8 +118,6 @@ void QuickBuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIni } void QuickBuildComponent::Update(float deltaTime) { - m_Activator = GetActivator(); - switch (m_State) { case eQuickBuildState::OPEN: { SpawnActivator(); @@ -141,9 +139,7 @@ void QuickBuildComponent::Update(float deltaTime) { if (m_TimerIncomplete >= m_TimeBeforeSmash) { ClearActivityPlayerData(); - GameMessages::SendDie(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); - ResetQuickBuild(false); } } @@ -179,7 +175,6 @@ void QuickBuildComponent::Update(float deltaTime) { if (!builder) { ResetQuickBuild(false); - return; } @@ -206,6 +201,7 @@ void QuickBuildComponent::Update(float deltaTime) { break; } } + Game::entityManager->SerializeEntity(builder); if (m_Timer >= m_CompleteTime && m_DrainedImagination >= m_TakeImagination) { CompleteQuickBuild(builder); @@ -226,9 +222,7 @@ void QuickBuildComponent::Update(float deltaTime) { if (m_TimerIncomplete >= m_TimeBeforeSmash) { ClearActivityPlayerData(); - GameMessages::SendDie(m_Parent, LWOOBJID_EMPTY, LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true); - ResetQuickBuild(false); } } @@ -273,11 +267,8 @@ void QuickBuildComponent::SpawnActivator() { void QuickBuildComponent::DespawnActivator() { if (m_Activator) { Game::entityManager->DestructEntity(m_Activator); - m_Activator->ScheduleKillAfterUpdate(); - m_Activator = nullptr; - m_ActivatorId = LWOOBJID_EMPTY; } } diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index ef1d0f32..b65d0e38 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -300,7 +300,7 @@ void RacingControlComponent::OnRequestDie(Entity* player) { if (!racingPlayer.noSmashOnReload) { racingPlayer.smashedTimes++; GameMessages::SendDie(vehicle, vehicle->GetObjectID(), LWOOBJID_EMPTY, true, - eKillType::VIOLENT, u"", 0, 0, 90.0f, false, true, 0); + eKillType::VIOLENT, u"", 0, 0, 90.0f, false, true); auto* destroyableComponent = vehicle->GetComponent(); uint32_t respawnImagination = 0; @@ -769,7 +769,7 @@ void RacingControlComponent::Update(float deltaTime) { if (vehiclePosition.y < -500) { GameMessages::SendDie(vehicle, m_Parent->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, - true, false, 0); + true, false); OnRequestDie(playerEntity); diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 973467d0..f496dfa6 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -814,7 +814,7 @@ void GameMessages::SendTerminateInteraction(const LWOOBJID& objectID, eTerminate SEND_PACKET_BROADCAST; } -void GameMessages::SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, bool bDieAccepted, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot, float coinSpawnTime) { +void GameMessages::SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, bool bDieAccepted, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot) { CBITSTREAM; CMSGHEADER; @@ -825,9 +825,6 @@ void GameMessages::SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOB bitStream.Write(bClientDeath); bitStream.Write(bSpawnLoot); - //bitStream.Write(coinSpawnTime != -1.0f); - //if (coinSpawnTime != -1.0f) bitStream.Write(coinSpawnTime); - uint32_t deathTypeLength = deathType.size(); bitStream.Write(deathTypeLength); for (uint32_t k = 0; k < deathTypeLength; k++) { @@ -4050,7 +4047,6 @@ void GameMessages::HandleRacingClientReady(RakNet::BitStream* inStream, Entity* void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { bool bClientDeath; - bool bSpawnLoot; std::u16string deathType; float directionRelativeAngleXZ; float directionRelativeAngleY; @@ -4058,17 +4054,14 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, eKillType killType = eKillType::VIOLENT; LWOOBJID killerID; LWOOBJID lootOwnerID = LWOOBJID_EMPTY; + uint32_t deathTypeLength = 0; bClientDeath = inStream->ReadBit(); - bSpawnLoot = inStream->ReadBit(); - - uint32_t deathTypeLength = 0; inStream->Read(deathTypeLength); for (size_t i = 0; i < deathTypeLength; i++) { char16_t character; inStream->Read(character); - deathType.push_back(character); } @@ -4076,39 +4069,25 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, inStream->Read(directionRelativeAngleY); inStream->Read(directionRelativeForce); - if (inStream->ReadBit()) { - inStream->Read(killType); - } - + if (inStream->ReadBit()) inStream->Read(killType); inStream->Read(killerID); - - if (inStream->ReadBit()) { - inStream->Read(lootOwnerID); - } + inStream->Read(lootOwnerID); auto* zoneController = Game::zoneManager->GetZoneControlObject(); - auto* racingControlComponent = zoneController->GetComponent(); LOG("Got die request: %i", entity->GetLOT()); - if (racingControlComponent != nullptr) { + if (racingControlComponent) { auto* possessableComponent = entity->GetComponent(); - - if (possessableComponent != nullptr) { + if (possessableComponent) { entity = Game::entityManager->GetEntity(possessableComponent->GetPossessor()); - - if (entity == nullptr) { - return; - } + if (!entity) return; } - racingControlComponent->OnRequestDie(entity); } else { auto* destroyableComponent = entity->GetComponent(); - if (!destroyableComponent) return; - destroyableComponent->Smash(killerID, killType, deathType); } } @@ -5236,45 +5215,6 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent } } -void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity) { - LWOOBJID killerID; - LWOOBJID lootOwnerID; - bool bDieAccepted = false; - eKillType killType; - std::u16string deathType; - float directionRelative_AngleY; - float directionRelative_AngleXZ; - float directionRelative_Force; - bool bClientDeath = false; - bool bSpawnLoot = true; - float coinSpawnTime = -1.0f; - - inStream->Read(bClientDeath); - inStream->Read(bDieAccepted); - inStream->Read(bSpawnLoot); - - bool coinSpawnTimeIsDefault{}; - inStream->Read(coinSpawnTimeIsDefault); - if (coinSpawnTimeIsDefault != 0) inStream->Read(coinSpawnTime); - - /*uint32_t deathTypeLength = deathType.size(); - inStream->Read(deathTypeLength); - for (uint32_t k = 0; k < deathTypeLength; k++) { - inStream->Read(deathType[k]); - }*/ - - inStream->Read(directionRelative_AngleXZ); - inStream->Read(directionRelative_AngleY); - inStream->Read(directionRelative_Force); - - bool killTypeIsDefault{}; - inStream->Read(killTypeIsDefault); - if (killTypeIsDefault != 0) inStream->Read(killType); - - inStream->Read(lootOwnerID); - inStream->Read(killerID); -} - void GameMessages::HandleEquipItem(RakNet::BitStream* inStream, Entity* entity) { bool immediate; LWOOBJID objectID; diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index 08c90bc3..3d5d7501 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -105,7 +105,7 @@ namespace GameMessages { void AddActivityOwner(Entity* entity, LWOOBJID& ownerID); void SendTerminateInteraction(const LWOOBJID& objectID, eTerminateType type, const LWOOBJID& terminator); - void SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, bool bDieAccepted, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot, float coinSpawnTime); + void SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOBJID& lootOwnerID, bool bDieAccepted, eKillType killType, std::u16string deathType, float directionRelative_AngleY, float directionRelative_AngleXZ, float directionRelative_Force, bool bClientDeath, bool bSpawnLoot); void SendSetInventorySize(Entity* entity, int invType, int size); @@ -612,7 +612,6 @@ namespace GameMessages { void HandleHasBeenCollected(RakNet::BitStream* inStream, Entity* entity); void HandleNotifyServerLevelProcessingComplete(RakNet::BitStream* inStream, Entity* entity); void HandlePickupCurrency(RakNet::BitStream* inStream, Entity* entity); - void HandleRequestDie(RakNet::BitStream* inStream, Entity* entity); void HandleEquipItem(RakNet::BitStream* inStream, Entity* entity); void HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity); void HandleRemoveItemFromInventory(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); diff --git a/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp b/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp index 48d1b255..03386ac2 100644 --- a/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp +++ b/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp @@ -55,7 +55,7 @@ void RaceMaelstromGeiser::OnProximityUpdate(Entity* self, Entity* entering, std: } - GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false, 0); + GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false); auto* zoneController = Game::zoneManager->GetZoneControlObject(); diff --git a/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp b/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp index 90333063..220814b9 100644 --- a/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp +++ b/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp @@ -40,7 +40,7 @@ void ActVehicleDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { } - GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false, 0); + GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false); auto* zoneController = Game::zoneManager->GetZoneControlObject();