From c1716f19e7307b3d6f5ead8476e4216b4516a876 Mon Sep 17 00:00:00 2001 From: mallory-scotton Date: Mon, 10 Nov 2025 12:04:46 +0100 Subject: [PATCH 1/5] update: format BeginPlay method for improved readability --- Games/RType/Source/GameMode.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Games/RType/Source/GameMode.cpp b/Games/RType/Source/GameMode.cpp index 0151f99f..5fb7ea17 100644 --- a/Games/RType/Source/GameMode.cpp +++ b/Games/RType/Source/GameMode.cpp @@ -23,7 +23,13 @@ RTypeGameMode::RTypeGameMode(void) } /////////////////////////////////////////////////////////////////////////////// -void RTypeGameMode::BeginPlay(void) { Super::BeginPlay(); } +void RTypeGameMode::BeginPlay(void) +{ + Super::BeginPlay(); + Audio::PlaySoundFromPak( + "Assets/Audios/Music/M_02_Opening.wav", 0.5f, true + ); +} /////////////////////////////////////////////////////////////////////////////// void RTypeGameMode::Tick(Float32 deltaTime) { Super::Tick(deltaTime); } From 85f665f2b93cb651f6cc09dfbda319f96bd07112 Mon Sep 17 00:00:00 2001 From: mallory-scotton Date: Mon, 10 Nov 2025 12:47:49 +0100 Subject: [PATCH 2/5] update: refactor connection timeout handling and improve RPC management --- .../Source/Engine/Network/FNetworkServer.cpp | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Engine/Source/Engine/Network/FNetworkServer.cpp b/Engine/Source/Engine/Network/FNetworkServer.cpp index a6cff04e..5618a845 100644 --- a/Engine/Source/Engine/Network/FNetworkServer.cpp +++ b/Engine/Source/Engine/Network/FNetworkServer.cpp @@ -283,10 +283,8 @@ void FNetworkServer::CheckConnectionTimeouts(const TimePoint& now) SendPacket(disconnectPacket, endpoint); // Emit event - EmitEvent( - Events::ClientDisconnected{ clientID, - EDisconnectionReason::Timeout } - ); + EmitEvent(Events::ClientDisconnected{ + clientID, EDisconnectionReason::Timeout }); // Remove connection m_connections.erase(it); @@ -337,6 +335,17 @@ void FNetworkServer::HandleDisconnectPacket( FLogger::SetNamespace("Network"); FLogger::Info("Client ID: {} disconnected", clientID); + + { + // Add a new RPC deferred call to destroy the client entity + Packets::RemoteProcedureCall rpc( + "DestroyClient", ERPCType::Server, UUID::World, clientID + ); + + // Add parameters to the RPC + std::lock_guard lock(m_rpcQueueMutex); + m_deferredRPCs.push({ rpc, endpoint }); + } } } @@ -378,8 +387,7 @@ void FNetworkServer::HandleConnectPacket( if (packet.gameName != m_settings->game.title || packet.gameVersion != m_settings->game.version) { - FLogger::Warn( - "[SERVER] Rejecting connection - Game/Version mismatch!" + FLogger::Warn("[SERVER] Rejecting connection - Game/Version mismatch!" ); Packets::ConnectResponse response; @@ -598,8 +606,8 @@ void FNetworkServer::Cleanup(void) } /////////////////////////////////////////////////////////////////////////////// -FConnectionInformation* - FNetworkServer::GetClientInformation(UInt32 clientID) const +FConnectionInformation* FNetworkServer::GetClientInformation(UInt32 clientID +) const { std::lock_guard lock(m_connectionsMutex); auto it = m_clientIDToEndpoint.find(clientID); From b02b9c5ca0a7e30a79d401a7fd29129ef038bce3 Mon Sep 17 00:00:00 2001 From: mallory-scotton Date: Mon, 10 Nov 2025 12:47:53 +0100 Subject: [PATCH 3/5] update: add DestroyClient RPC functionality to manage client destruction --- Engine/Source/Engine/Runtime/World/UWorld.cpp | 32 ++++++++++++++++++- Engine/Source/Engine/Runtime/World/UWorld.hpp | 9 ++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Engine/Source/Engine/Runtime/World/UWorld.cpp b/Engine/Source/Engine/Runtime/World/UWorld.cpp index d43d4a0e..4e3b026e 100644 --- a/Engine/Source/Engine/Runtime/World/UWorld.cpp +++ b/Engine/Source/Engine/Runtime/World/UWorld.cpp @@ -68,6 +68,12 @@ UWorld::UWorld(const FString& name) ERPCType::Client, std::bind(&UWorld::RPC_SyncSnapshot, this, std::placeholders::_1) ) + , DestroyClientRPC( + *this, + "DestroyClient", + ERPCType::Server, + std::bind(&UWorld::RPC_DestroyClient, this, std::placeholders::_1) + ) { #if TKD_ENGINE_SERVER SetNetRole(ENetRole::Authority); @@ -446,12 +452,36 @@ void UWorld::RPC_DestroyActor(const UUID& actorID) m_actors.begin(), m_actors.end(), [&actorID](const std::shared_ptr& actor) - { return actor && actor->GetNetworkID() == actorID; } + { return actor && actor->GetUUID() == actorID; } ); if (it != m_actors.end()) { (*it)->MarkForDeletion(); } } +/////////////////////////////////////////////////////////////////////////////// +void UWorld::RPC_DestroyClient(UInt32 owningClientID) +{ + std::vector actorsToDestroy; + + // Find and destroy all actors owned by the specified client + for (const auto& actor: m_actors) + { + if (actor && actor->GetOwningClientID() == owningClientID) + { + actorsToDestroy.push_back(actor->GetUUID()); + actor->MarkForDeletion(); + } + } + + // Send DestroyActorRPC for each actor to all clients + for (const auto& actorID: actorsToDestroy) + { + this->DestroyActorRPC.SetRPCType(ERPCType::Multicast); + this->DestroyActorRPC(actorID); + this->DestroyActorRPC.SetRPCType(ERPCType::Client); + } +} + /////////////////////////////////////////////////////////////////////////////// void UWorld::RPC_SpawnPlayer( UInt32 owningClientID, const UUID& playerID, const FTransform& transform diff --git a/Engine/Source/Engine/Runtime/World/UWorld.hpp b/Engine/Source/Engine/Runtime/World/UWorld.hpp index dbaaa839..930b2bfe 100644 --- a/Engine/Source/Engine/Runtime/World/UWorld.hpp +++ b/Engine/Source/Engine/Runtime/World/UWorld.hpp @@ -73,6 +73,7 @@ class UWorld UFunction SpawnClientRPC; UFunction SpawnPlayerRPC; UFunction> SyncSnapshotRPC; + UFunction DestroyClientRPC; public: /////////////////////////////////////////////////////////////////////////// @@ -138,6 +139,14 @@ class UWorld /////////////////////////////////////////////////////////////////////////// void RPC_SyncSnapshot(const std::vector& snapshot); + /////////////////////////////////////////////////////////////////////////// + /// \brief Destroy client RPC handler + /// + /// \param owningClientID The ID of the client to destroy + /// + /////////////////////////////////////////////////////////////////////////// + void RPC_DestroyClient(UInt32 owningClientID); + public: /////////////////////////////////////////////////////////////////////////// /// \brief Spawn an actor of type T in the world From 59cbb4c7f0c1f887422410e4f8b7406a5f005d3e Mon Sep 17 00:00:00 2001 From: mallory-scotton Date: Mon, 10 Nov 2025 12:56:08 +0100 Subject: [PATCH 4/5] update: remove debug output statements from FragmentManager methods --- Engine/Source/Engine/Network/FFragmentManager.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Engine/Source/Engine/Network/FFragmentManager.cpp b/Engine/Source/Engine/Network/FFragmentManager.cpp index e2dc9e04..8e54dbeb 100644 --- a/Engine/Source/Engine/Network/FFragmentManager.cpp +++ b/Engine/Source/Engine/Network/FFragmentManager.cpp @@ -55,7 +55,6 @@ void FragmentManager::DestroyFragments(void) { if (m_fragmentsToDelete.empty()) { return; } - std::cout << "[manager] we deleting and shit" << std::endl; m_fragments.erase( std::remove_if( m_fragments.begin(), @@ -109,7 +108,6 @@ void FragmentManager::MergeFragments( completeData.end(), chunk.data.begin(), chunk.data.end() ); } - std::cout << "[manager] its processing time little one" << std::endl; // Process the reassembled packet through the normal packet pipeline networkBase->ProcessReceivedData( completeData.data(), completeData.size(), entry.sender @@ -127,9 +125,9 @@ Bool FragmentManager::IsFragmentComplete(const FragmentEntry& entry) const } /////////////////////////////////////////////////////////////////////////////// -std::vector> FragmentManager::FragmentPacket( - const std::vector& serializedData -) const +std::vector> + FragmentManager::FragmentPacket(const std::vector& serializedData + ) const { std::vector> chunks; @@ -164,8 +162,8 @@ FragmentEntry* FragmentManager::FindFragmentEntry(const UUID& fragmentID) } /////////////////////////////////////////////////////////////////////////////// -const FragmentEntry* - FragmentManager::FindFragmentEntry(const UUID& fragmentID) const +const FragmentEntry* FragmentManager::FindFragmentEntry(const UUID& fragmentID +) const { for (const auto& entry: m_fragments) { @@ -192,7 +190,6 @@ UUID FragmentManager::SendFullTransmission( ) { if (!networkBase) { return UUID::Nil; } - std::cout << "[MANAGER] we out here and shit" << std::endl; // Create new fragment entry FragmentEntry entry; entry.id = UUID::V4(); // Generate unique ID @@ -211,7 +208,6 @@ UUID FragmentManager::SendFullTransmission( (static_cast(uuidData[1]) << 16) | (static_cast(uuidData[2]) << 8) | static_cast(uuidData[3]); - std::cout << "[MANAGER] id created" << std::endl; // Create chunk entries and send them for (SizeT i = 0; i < chunks.size(); ++i) From be3924286351bb46e8b784e10011eb82f7349c28 Mon Sep 17 00:00:00 2001 From: mallory-scotton Date: Mon, 10 Nov 2025 13:25:02 +0100 Subject: [PATCH 5/5] fix: correct variable type declaration for m_forwardSpeed in SimulateMovement method --- Games/RType/Source/Core/AI/AI_Player.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Games/RType/Source/Core/AI/AI_Player.cpp b/Games/RType/Source/Core/AI/AI_Player.cpp index 57aa2159..25c03ae4 100644 --- a/Games/RType/Source/Core/AI/AI_Player.cpp +++ b/Games/RType/Source/Core/AI/AI_Player.cpp @@ -97,10 +97,7 @@ void AI_Player::Tick(Float32 deltaTime) ); } } - else - { - velocity = FVector2f::Zero; - } + else { velocity = FVector2f::Zero; } m_lastPosition = currentPosition; } @@ -141,7 +138,7 @@ FTransform AI_Player::SimulateMovement( // Determine the Y direction needed to reach the targetY FVector3 currentPosition = startTransform.GetPosition(); Float32 directionY = 0.0f; - _Float32 m_forwardSpeed = -1.0f; + Float32 m_forwardSpeed = -1.0f; if (targetY > currentPosition.y + 1.0f) {