Skip to content

Commit

Permalink
Fixed defect 215.
Browse files Browse the repository at this point in the history
  • Loading branch information
klei1984 committed Mar 3, 2024
1 parent 826bfcd commit d48bf1a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
4 changes: 0 additions & 4 deletions src/access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1996,10 +1996,6 @@ void Access_ProcessGroupAirPath(UnitInfo* unit) {
} else {
unit->BlockedOnPathRequest(false);

if (Remote_IsNetworkGame) {
Remote_SendNetPacket_41(unit);
}

unit->ClearUnitList();
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/pathrequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 0 additions & 4 deletions src/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
7 changes: 5 additions & 2 deletions src/remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>(REMOTE_PACKET_41);
packet << static_cast<uint16_t>(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);
Expand Down
2 changes: 1 addition & 1 deletion src/remote.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion src/unitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/unitinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class UnitInfo : public FileObject {
void Attack(int32_t grid_x, int32_t grid_y);
SmartPointer<UnitInfo> 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();
Expand Down

0 comments on commit d48bf1a

Please sign in to comment.