From d48bf1a38671b153dfeb171f3209e67c6b12a3b8 Mon Sep 17 00:00:00 2001 From: klei1984 <53688147+klei1984@users.noreply.github.com> Date: Sun, 3 Mar 2024 11:08:37 +0100 Subject: [PATCH] Fixed defect 215. --- src/access.cpp | 4 ---- src/pathrequest.cpp | 4 ---- src/paths.cpp | 4 ---- src/remote.cpp | 7 +++++-- src/remote.hpp | 2 +- src/unitinfo.cpp | 8 +++++++- src/unitinfo.hpp | 2 +- 7 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/access.cpp b/src/access.cpp index 818780d0..5d6f4ab1 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -1996,10 +1996,6 @@ void Access_ProcessGroupAirPath(UnitInfo* unit) { } else { unit->BlockedOnPathRequest(false); - if (Remote_IsNetworkGame) { - Remote_SendNetPacket_41(unit); - } - unit->ClearUnitList(); } } diff --git a/src/pathrequest.cpp b/src/pathrequest.cpp index 585d007c..7ff70095 100644 --- a/src/pathrequest.cpp +++ b/src/pathrequest.cpp @@ -172,10 +172,6 @@ void PathRequest::Finish(GroundPath* path) { client->BlockedOnPathRequest(false); - if (Remote_IsNetworkGame) { - Remote_SendNetPacket_41(&*client); - } - if (client->GetUnitList() && unit1_order_state == ORDER_STATE_NEW_ORDER) { client->ClearUnitList(); } diff --git a/src/paths.cpp b/src/paths.cpp index 194fe734..03f21406 100644 --- a/src/paths.cpp +++ b/src/paths.cpp @@ -1052,10 +1052,6 @@ bool Paths_RequestPath(UnitInfo* unit, int32_t mode) { } else { unit->BlockedOnPathRequest(false); - if (Remote_IsNetworkGame) { - Remote_SendNetPacket_41(unit); - } - result = false; } diff --git a/src/remote.cpp b/src/remote.cpp index 34ffee96..9d919c2c 100644 --- a/src/remote.cpp +++ b/src/remote.cpp @@ -2884,24 +2884,27 @@ void Remote_ReceiveNetPacket_40(NetPacket& packet) { Remote_UnpauseGameEvent = true; } -void Remote_SendNetPacket_41(UnitInfo* unit) { +void Remote_SendNetPacket_41(UnitInfo* unit, bool mode) { NetPacket packet; packet << static_cast(REMOTE_PACKET_41); packet << static_cast(unit->GetId()); + packet << mode; Remote_TransmitPacket(packet, REMOTE_MULTICAST); } void Remote_ReceiveNetPacket_41(NetPacket& packet) { uint16_t entity_id; + bool mode; packet >> entity_id; + packet >> mode; UnitInfo* unit = Hash_UnitHash[entity_id]; if (unit) { - unit->BlockedOnPathRequest(false); + unit->BlockedOnPathRequest(mode, true); } else { Remote_NetErrorUnknownUnit(entity_id); diff --git a/src/remote.hpp b/src/remote.hpp index 8bfab43a..dc068ad8 100644 --- a/src/remote.hpp +++ b/src/remote.hpp @@ -125,7 +125,7 @@ void Remote_SendNetPacket_35(); void Remote_SendNetPacket_36(); void Remote_SendNetPacket_37(); void Remote_SendNetPacket_38(UnitInfo* unit); -void Remote_SendNetPacket_41(UnitInfo* unit); +void Remote_SendNetPacket_41(UnitInfo* unit, bool mode); void Remote_SendNetPacket_43(UnitInfo* unit, const char* name); void Remote_SendNetPacket_44(NetAddress& address); void Remote_SendNetPacket_46(uint16_t team, bool state, uint32_t counter); diff --git a/src/unitinfo.cpp b/src/unitinfo.cpp index 945875f2..44fa5df5 100644 --- a/src/unitinfo.cpp +++ b/src/unitinfo.cpp @@ -3939,7 +3939,7 @@ int32_t UnitInfo::GetExperience() { return result; } -void UnitInfo::BlockedOnPathRequest(bool mode) { +void UnitInfo::BlockedOnPathRequest(bool mode, bool skip_notification) { path = nullptr; if (orders != ORDER_MOVE_TO_ATTACK || state == ORDER_STATE_NEW_ORDER) { @@ -3953,6 +3953,12 @@ void UnitInfo::BlockedOnPathRequest(bool mode) { } MoveFinished(mode); + + if (Remote_IsNetworkGame) { + if (!skip_notification) { + Remote_SendNetPacket_41(this, mode); + } + } } void UnitInfo::MoveFinished(bool mode) { diff --git a/src/unitinfo.hpp b/src/unitinfo.hpp index dc7cf92f..45e38d34 100644 --- a/src/unitinfo.hpp +++ b/src/unitinfo.hpp @@ -148,7 +148,7 @@ class UnitInfo : public FileObject { void Attack(int32_t grid_x, int32_t grid_y); SmartPointer MakeCopy(); void MoveFinished(bool mode = true); - void BlockedOnPathRequest(bool mode = true); + void BlockedOnPathRequest(bool mode = true, bool skip_notification = false); void RestoreOrders(); void FollowUnit(); void InitStealthStatus();