diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 8b72a80c..8c454b9b 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -82,6 +82,7 @@ #include "CollectibleComponent.h" #include "ItemComponent.h" #include "GhostComponent.h" +#include "Recorder.h" // Table includes #include "CDComponentsRegistryTable.h" @@ -2142,4 +2143,18 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) { Game::entityManager->QueueGhostUpdate(GetObjectID()); if (updateChar) Game::entityManager->SerializeEntity(this); + + auto* recorder = Cinema::Recording::Recorder::GetRecorder(GetObjectID()); + + if (recorder != nullptr) { + recorder->AddRecord(new Cinema::Recording::MovementRecord( + update.position, + update.rotation, + update.velocity, + update.angularVelocity, + update.onGround, + update.velocity != NiPoint3::ZERO, + update.angularVelocity != NiPoint3::ZERO + )); + } } diff --git a/dGame/dCinema/CMakeLists.txt b/dGame/dCinema/CMakeLists.txt index 0d6c0afb..c6d2c0d1 100644 --- a/dGame/dCinema/CMakeLists.txt +++ b/dGame/dCinema/CMakeLists.txt @@ -1,5 +1,11 @@ set(DGAME_DCINEMA_SOURCES "Recorder.cpp" "Prefab.cpp" "Scene.cpp" - "Play.cpp" - PARENT_SCOPE) + "Play.cpp") + +add_library(dCinema STATIC ${DGAME_DCINEMA_SOURCES}) +target_precompile_headers(dCinema REUSE_FROM dGameBase) +target_link_libraries(dCinema + PUBLIC dPhysics dDatabase + INTERFACE dUtilities dCommon dBehaviors dChatFilter dMission dInventory dComponents +) diff --git a/dGame/dCinema/Prefab.cpp b/dGame/dCinema/Prefab.cpp index 151eb37b..5e30a7b7 100644 --- a/dGame/dCinema/Prefab.cpp +++ b/dGame/dCinema/Prefab.cpp @@ -2,7 +2,7 @@ #include "tinyxml2.h" -#include "../../dWorldServer/ObjectIDManager.h" +#include "ObjectIDManager.h" #include "EntityManager.h" #include "EntityInfo.h" #include "RenderComponent.h" diff --git a/dGame/dCinema/Recorder.cpp b/dGame/dCinema/Recorder.cpp index 314c4e50..1b304209 100644 --- a/dGame/dCinema/Recorder.cpp +++ b/dGame/dCinema/Recorder.cpp @@ -3,7 +3,7 @@ #include "ControllablePhysicsComponent.h" #include "GameMessages.h" #include "InventoryComponent.h" -#include "../dWorldServer/ObjectIDManager.h" +#include "ObjectIDManager.h" #include "ChatPackets.h" #include "EntityManager.h" #include "EntityInfo.h" @@ -679,7 +679,7 @@ EquipRecord::EquipRecord(LOT item) { void EquipRecord::Act(Entity* actor) { auto* inventoryComponent = actor->GetComponent(); - const LWOOBJID id = ObjectIDManager::Instance()->GenerateObjectID(); + const LWOOBJID id = ObjectIDManager::GenerateObjectID(); const auto& info = Inventory::FindItemComponent(item); diff --git a/dGame/dCinema/Scene.cpp b/dGame/dCinema/Scene.cpp index 76fa3842..3df4a8ef 100644 --- a/dGame/dCinema/Scene.cpp +++ b/dGame/dCinema/Scene.cpp @@ -9,6 +9,7 @@ #include "EntityInfo.h" #include "MissionComponent.h" #include "dConfig.h" +#include "PlayerManager.h" using namespace Cinema; @@ -153,7 +154,7 @@ void Cinema::Scene::CheckForShowings() { // I don't care Game::entityManager->GetZoneControlEntity()->AddCallbackTimer(1.0f, [this]() { - for (auto* player : Player::GetAllPlayers()) { + for (auto* player : PlayerManager::GetAllPlayers()) { if (m_Audience.find(player->GetObjectID()) != m_Audience.end()) { continue; } diff --git a/dGame/dUtilities/CMakeLists.txt b/dGame/dUtilities/CMakeLists.txt index 31d9bfc2..bf4f4ed7 100644 --- a/dGame/dUtilities/CMakeLists.txt +++ b/dGame/dUtilities/CMakeLists.txt @@ -7,7 +7,7 @@ set(DGAME_DUTILITIES_SOURCES "BrickDatabase.cpp" "Preconditions.cpp" "SlashCommandHandler.cpp" "ServerPreconditions.cpp" - "VanityUtilities.cpp" PARENT_SCOPE) + "VanityUtilities.cpp") add_library(dUtilities STATIC ${DGAME_DUTILITIES_SOURCES}) target_precompile_headers(dUtilities REUSE_FROM dGameBase) diff --git a/dNet/ClientPackets.cpp b/dNet/ClientPackets.cpp index 94fec684..a6b9f8c6 100644 --- a/dNet/ClientPackets.cpp +++ b/dNet/ClientPackets.cpp @@ -5,25 +5,6 @@ #include "ClientPackets.h" #include "dCommonVars.h" -#include "BitStream.h" -#include "dChatFilter.h" -#include "WorldPackets.h" -#include "ChatPackets.h" -#include "dServer.h" -#include "GameMessages.h" -#include "dZoneManager.h" -#include "Player.h" -#include "Zone.h" -#include "PossessorComponent.h" -#include "PossessableComponent.h" -#include "VehiclePhysicsComponent.h" -#include "dConfig.h" -#include "CharacterComponent.h" -#include "Database.h" -#include "eGameMasterLevel.h" -#include "eReplicaComponentType.h" -#include "CheatDetection.h" -#include "Recorder.h" #include "PositionUpdate.h" ChatMessage ClientPackets::HandleChatMessage(Packet* packet) { @@ -42,16 +23,6 @@ ChatMessage ClientPackets::HandleChatMessage(Packet* packet) { message.message.push_back(character); } - std::string sMessage = GeneralUtils::UTF16ToWTF8(message); - LOG("%s: %s", playerName.c_str(), sMessage.c_str()); - ChatPackets::SendChatMessage(sysAddr, chatChannel, playerName, user->GetLoggedInChar(), isMythran, message); - - auto* recorder = Cinema::Recording::Recorder::GetRecorder(user->GetLoggedInChar()); - - if (recorder != nullptr) { - recorder->AddRecord(new Cinema::Recording::SpeakRecord(sMessage)); - } - return message; } @@ -110,127 +81,6 @@ PositionUpdate ClientPackets::HandleClientPositionUpdate(Packet* packet) { inStream.Read(update.remoteInputInfo.m_IsModified); } - bool updateChar = true; - - if (possessorComponent != nullptr) { - auto* possassableEntity = Game::entityManager->GetEntity(possessorComponent->GetPossessable()); - - if (possassableEntity != nullptr) { - auto* possessableComponent = possassableEntity->GetComponent(); - if (possessableComponent) { - // While possessing something, only update char if we are attached to the thing we are possessing - if (possessableComponent->GetPossessionType() != ePossessionType::ATTACHED_VISIBLE) updateChar = false; - } - - auto* vehiclePhysicsComponent = possassableEntity->GetComponent(); - if (vehiclePhysicsComponent != nullptr) { - vehiclePhysicsComponent->SetPosition(position); - vehiclePhysicsComponent->SetRotation(rotation); - vehiclePhysicsComponent->SetIsOnGround(onGround); - vehiclePhysicsComponent->SetIsOnRail(onRail); - vehiclePhysicsComponent->SetVelocity(velocity); - vehiclePhysicsComponent->SetDirtyVelocity(velocityFlag); - vehiclePhysicsComponent->SetAngularVelocity(angVelocity); - vehiclePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag); - vehiclePhysicsComponent->SetRemoteInputInfo(remoteInput); - } else { - // Need to get the mount's controllable physics - auto* controllablePhysicsComponent = possassableEntity->GetComponent(); - if (!controllablePhysicsComponent) return; - controllablePhysicsComponent->SetPosition(position); - controllablePhysicsComponent->SetRotation(rotation); - controllablePhysicsComponent->SetIsOnGround(onGround); - controllablePhysicsComponent->SetIsOnRail(onRail); - controllablePhysicsComponent->SetVelocity(velocity); - controllablePhysicsComponent->SetDirtyVelocity(velocityFlag); - controllablePhysicsComponent->SetAngularVelocity(angVelocity); - controllablePhysicsComponent->SetDirtyAngularVelocity(angVelocityFlag); - } - Game::entityManager->SerializeEntity(possassableEntity); - } - } - - if (!updateChar) { - velocity = NiPoint3::ZERO; - angVelocity = NiPoint3::ZERO; - } - - - - // Handle statistics - auto* characterComponent = entity->GetComponent(); - if (characterComponent != nullptr) { - characterComponent->TrackPositionUpdate(position); - } - - comp->SetPosition(position); - comp->SetRotation(rotation); - comp->SetIsOnGround(onGround); - comp->SetIsOnRail(onRail); - comp->SetVelocity(velocity); - comp->SetDirtyVelocity(velocityFlag); - comp->SetAngularVelocity(angVelocity); - comp->SetDirtyAngularVelocity(angVelocityFlag); - - auto* recorder = Cinema::Recording::Recorder::GetRecorder(entity->GetObjectID()); - - if (recorder != nullptr) { - recorder->AddRecord(new Cinema::Recording::MovementRecord( - position, - rotation, - velocity, - angVelocity, - onGround, - velocityFlag, - angVelocityFlag - )); - } - - auto* player = static_cast(entity); - player->SetGhostReferencePoint(position); - Game::entityManager->QueueGhostUpdate(player->GetObjectID()); - - if (updateChar) Game::entityManager->SerializeEntity(entity); - - //TODO: add moving platform stuffs - /*bool movingPlatformFlag; - inStream.Read(movingPlatformFlag); - if (movingPlatformFlag) { - LWOOBJID objectID; - NiPoint3 niData2; - - inStream.Read(objectID); - inStream.Read(niData2.x); - inStream.Read(niData2.y); - inStream.Read(niData2.z); - - - - bool niData3Flag; - inStream.Read(niData3Flag); - if (niData3Flag) { - NiPoint3 niData3; - inStream.Read(niData3.x); - inStream.Read(niData3.y); - inStream.Read(niData3.z); - - controllablePhysics->GetLocationData()->GetMovingPlatformData()->SetData3(niData3); - } - }*/ - - /* - for (int i = 0; i < Game::server->GetReplicaManager()->GetParticipantCount(); ++i) - { - const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(i); - - if (entity->GetSystemAddress() == player) - { - continue; - } - - Game::entityManager->SerializeEntity(entity, player); - } - */ return update; } diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index 81ae7bf6..8f2aedc9 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -1309,6 +1309,12 @@ void HandlePacket(Packet* packet) { std::string sMessage = GeneralUtils::UTF16ToWTF8(chatMessage.message); LOG("%s: %s", playerName.c_str(), sMessage.c_str()); ChatPackets::SendChatMessage(packet->systemAddress, chatMessage.chatChannel, playerName, user->GetLoggedInChar(), isMythran, chatMessage.message); + + auto* recorder = Cinema::Recording::Recorder::GetRecorder(user->GetLoggedInChar()); + + if (recorder != nullptr) { + recorder->AddRecord(new Cinema::Recording::SpeakRecord(sMessage)); + } } break;