Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5529,12 +5529,12 @@ Bool Pathfinder::adjustDestination(Object *obj, const LocomotorSet& locomotorSet
Bool center;
getRadiusAndCenter(obj, iRadius, center);
ICoord2D cell;
Coord3D adjustDest = *dest;
Coord3D cellDest = *dest;
if (!center) {
adjustDest.x += PATHFIND_CELL_SIZE_F/2;
adjustDest.y += PATHFIND_CELL_SIZE_F/2;
cellDest.x += PATHFIND_CELL_SIZE_F/2;
cellDest.y += PATHFIND_CELL_SIZE_F/2;
}
worldToCell( &adjustDest, &cell );
worldToCell( &cellDest, &cell );
PathfindLayerEnum layer = TheTerrainLogic->getLayerForDestination(dest);
if (groupDest) {
layer = TheTerrainLogic->getLayerForDestination(groupDest);
Expand All @@ -5543,9 +5543,24 @@ Bool Pathfinder::adjustDestination(Object *obj, const LocomotorSet& locomotorSet
Int i = cell.x;
Int j = cell.y;
// Check the center cell
if (checkForAdjust(obj, locomotorSet, isHuman, i,j, layer, iRadius, center, dest, groupDest)) {
#if RETAIL_COMPATIBLE_PATHFINDING
if (checkForAdjust(obj, locomotorSet, isHuman, i, j, layer, iRadius, center, dest, groupDest)) {
return true;
}
#else
Coord3D adjustDest = *dest;
if (checkForAdjust(obj, locomotorSet, isHuman, i, j, layer, iRadius, center, &adjustDest, groupDest)) {
// TheSuperHackers @bugfix stephanmeesters 15/06/2026 Destination adjustment always snaps to the nearest grid cell
// even when no adjustment is necessary because there are no obstructions. For single units this adjustment
// can be skipped in order to provide more accurate movement, which is especially noticeable for chinooks.
const Bool singleUnit = obj && obj->getGroup() && obj->getGroup()->getCount() == 1;
const Bool useExactDestination = isHuman && singleUnit;
if (!useExactDestination) {
*dest = adjustDest;
}
return true;
}
#endif

// TheSuperHackers @info Expanding counter-clockwise spiral search around center cell C. Each full lap walks right->up->left->down.
// After every pair of directions (right+up, then left+down) length of the segment grows by 1.
Expand Down
21 changes: 18 additions & 3 deletions Core/GameEngine/Source/GameNetwork/NetCommandList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ void NetCommandList::reset() {
m_lastMessageInserted = nullptr;
}

static bool isCommandIdNewer(UnsignedShort newVal, UnsignedShort oldVal)
{
#if RETAIL_COMPATIBLE_NETWORKING
return newVal > oldVal;
#else
// TheSuperHackers @bugfix Caball009 14/06/2026 Ensure messages are sorted
// chronologically by including a command id overflow check.
const UnsignedShort diff = newVal - oldVal;
return diff != 0 && diff < 0x8000;
#endif
}

/**
* Insert sorts msg. Assumes that all the previous message inserts were done using this function.
* The message is sorted in based first on command type, then player id, and then command id.
Expand Down Expand Up @@ -151,10 +163,10 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) {
NetCommandRef *theNext = m_lastMessageInserted->getNext();
if ((m_lastMessageInserted->getCommand()->getNetCommandType() == msg->getCommand()->getNetCommandType()) &&
(m_lastMessageInserted->getCommand()->getPlayerID() == msg->getCommand()->getPlayerID()) &&
(m_lastMessageInserted->getCommand()->getID() < msg->getCommand()->getID()) &&
isCommandIdNewer(msg->getCommand()->getID(), m_lastMessageInserted->getCommand()->getID()) &&
((theNext == nullptr) || ((theNext->getCommand()->getNetCommandType() > msg->getCommand()->getNetCommandType()) ||
(theNext->getCommand()->getPlayerID() > msg->getCommand()->getPlayerID()) ||
(theNext->getCommand()->getID() > msg->getCommand()->getID())))) {
isCommandIdNewer(theNext->getCommand()->getID(), msg->getCommand()->getID())))) {

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

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

Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/GameNetwork/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include "GameClient/MessageBox.h"


#if defined(DEBUG_CRC)
#if defined(DEBUG_CRC) && !RETAIL_COMPATIBLE_NETWORKING
Int NET_CRC_INTERVAL = 1;
#else
Int NET_CRC_INTERVAL = 100;
Expand Down
8 changes: 4 additions & 4 deletions Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ UnsignedInt ResolveIP(AsciiString host)
/**
* Returns the next network command ID.
*/
UnsignedShort GenerateNextCommandID() {
static UnsignedShort commandID = 64000;
++commandID;
return commandID;
static UnsignedShort s_commandID = 0;
UnsignedShort GenerateNextCommandID()
{
return s_commandID++;
}

/**
Expand Down
Loading
Loading