Skip to content

Commit 613a7af

Browse files
authored
Merge pull request #170 from fbraz3/thesuperhackers-sync-06-19-2026
merge: sync thesuperhackers upstream (06-19-2026)
2 parents 2737e4d + c63ea1c commit 613a7af

29 files changed

Lines changed: 488 additions & 610 deletions

File tree

Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5529,12 +5529,12 @@ Bool Pathfinder::adjustDestination(Object *obj, const LocomotorSet& locomotorSet
55295529
Bool center;
55305530
getRadiusAndCenter(obj, iRadius, center);
55315531
ICoord2D cell;
5532-
Coord3D adjustDest = *dest;
5532+
Coord3D cellDest = *dest;
55335533
if (!center) {
5534-
adjustDest.x += PATHFIND_CELL_SIZE_F/2;
5535-
adjustDest.y += PATHFIND_CELL_SIZE_F/2;
5534+
cellDest.x += PATHFIND_CELL_SIZE_F/2;
5535+
cellDest.y += PATHFIND_CELL_SIZE_F/2;
55365536
}
5537-
worldToCell( &adjustDest, &cell );
5537+
worldToCell( &cellDest, &cell );
55385538
PathfindLayerEnum layer = TheTerrainLogic->getLayerForDestination(dest);
55395539
if (groupDest) {
55405540
layer = TheTerrainLogic->getLayerForDestination(groupDest);
@@ -5543,9 +5543,24 @@ Bool Pathfinder::adjustDestination(Object *obj, const LocomotorSet& locomotorSet
55435543
Int i = cell.x;
55445544
Int j = cell.y;
55455545
// Check the center cell
5546-
if (checkForAdjust(obj, locomotorSet, isHuman, i,j, layer, iRadius, center, dest, groupDest)) {
5546+
#if RETAIL_COMPATIBLE_PATHFINDING
5547+
if (checkForAdjust(obj, locomotorSet, isHuman, i, j, layer, iRadius, center, dest, groupDest)) {
5548+
return true;
5549+
}
5550+
#else
5551+
Coord3D adjustDest = *dest;
5552+
if (checkForAdjust(obj, locomotorSet, isHuman, i, j, layer, iRadius, center, &adjustDest, groupDest)) {
5553+
// TheSuperHackers @bugfix stephanmeesters 15/06/2026 Destination adjustment always snaps to the nearest grid cell
5554+
// even when no adjustment is necessary because there are no obstructions. For single units this adjustment
5555+
// can be skipped in order to provide more accurate movement, which is especially noticeable for chinooks.
5556+
const Bool singleUnit = obj && obj->getGroup() && obj->getGroup()->getCount() == 1;
5557+
const Bool useExactDestination = isHuman && singleUnit;
5558+
if (!useExactDestination) {
5559+
*dest = adjustDest;
5560+
}
55475561
return true;
55485562
}
5563+
#endif
55495564

55505565
// TheSuperHackers @info Expanding counter-clockwise spiral search around center cell C. Each full lap walks right->up->left->down.
55515566
// After every pair of directions (right+up, then left+down) length of the segment grows by 1.

Core/GameEngine/Source/GameNetwork/NetCommandList.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ void NetCommandList::reset() {
122122
m_lastMessageInserted = nullptr;
123123
}
124124

125+
static bool isCommandIdNewer(UnsignedShort newVal, UnsignedShort oldVal)
126+
{
127+
#if RETAIL_COMPATIBLE_NETWORKING
128+
return newVal > oldVal;
129+
#else
130+
// TheSuperHackers @bugfix Caball009 14/06/2026 Ensure messages are sorted
131+
// chronologically by including a command id overflow check.
132+
const UnsignedShort diff = newVal - oldVal;
133+
return diff != 0 && diff < 0x8000;
134+
#endif
135+
}
136+
125137
/**
126138
* Insert sorts msg. Assumes that all the previous message inserts were done using this function.
127139
* The message is sorted in based first on command type, then player id, and then command id.
@@ -151,10 +163,10 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) {
151163
NetCommandRef *theNext = m_lastMessageInserted->getNext();
152164
if ((m_lastMessageInserted->getCommand()->getNetCommandType() == msg->getCommand()->getNetCommandType()) &&
153165
(m_lastMessageInserted->getCommand()->getPlayerID() == msg->getCommand()->getPlayerID()) &&
154-
(m_lastMessageInserted->getCommand()->getID() < msg->getCommand()->getID()) &&
166+
isCommandIdNewer(msg->getCommand()->getID(), m_lastMessageInserted->getCommand()->getID()) &&
155167
((theNext == nullptr) || ((theNext->getCommand()->getNetCommandType() > msg->getCommand()->getNetCommandType()) ||
156168
(theNext->getCommand()->getPlayerID() > msg->getCommand()->getPlayerID()) ||
157-
(theNext->getCommand()->getID() > msg->getCommand()->getID())))) {
169+
isCommandIdNewer(theNext->getCommand()->getID(), msg->getCommand()->getID())))) {
158170

159171
// Make sure this command isn't already in the list.
160172
if (isEqualCommandMsg(m_lastMessageInserted->getCommand(), msg->getCommand())) {
@@ -275,7 +287,10 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) {
275287

276288
// Find the position within the player's section based on the command ID.
277289
// If the command type doesn't require a command ID, sort by whatever it should be sorted by.
278-
while ((tempmsg != nullptr) && (msg->getCommand()->getNetCommandType() == tempmsg->getCommand()->getNetCommandType()) && (msg->getCommand()->getPlayerID() == tempmsg->getCommand()->getPlayerID()) && (msg->getCommand()->getSortNumber() > tempmsg->getCommand()->getSortNumber())) {
290+
while (tempmsg != nullptr
291+
&& msg->getCommand()->getNetCommandType() == tempmsg->getCommand()->getNetCommandType()
292+
&& msg->getCommand()->getPlayerID() == tempmsg->getCommand()->getPlayerID()
293+
&& isCommandIdNewer(msg->getCommand()->getSortNumber(), tempmsg->getCommand()->getSortNumber())) {
279294
tempmsg = tempmsg->getNext();
280295
}
281296

Core/GameEngine/Source/GameNetwork/Network.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#include "GameClient/MessageBox.h"
5454

5555

56-
#if defined(DEBUG_CRC)
56+
#if defined(DEBUG_CRC) && !RETAIL_COMPATIBLE_NETWORKING
5757
Int NET_CRC_INTERVAL = 1;
5858
#else
5959
Int NET_CRC_INTERVAL = 100;

Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ UnsignedInt ResolveIP(AsciiString host)
110110
/**
111111
* Returns the next network command ID.
112112
*/
113-
UnsignedShort GenerateNextCommandID() {
114-
static UnsignedShort commandID = 64000;
115-
++commandID;
116-
return commandID;
113+
static UnsignedShort s_commandID = 0;
114+
UnsignedShort GenerateNextCommandID()
115+
{
116+
return s_commandID++;
117117
}
118118

119119
/**

0 commit comments

Comments
 (0)