Skip to content

Commit

Permalink
Maybe fix motion prediction failure after long sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarcho committed Mar 22, 2023
1 parent d95d19a commit cfc8e8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/d2dx/UnitMotionPredictor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ Offset UnitMotionPredictor::GetOffset(

for (int32_t i = 0; i < _unitsCount; ++i)
{
if (_unitIdAndTypes.items[i].unitId == (uint16_t)unitId &&
_unitIdAndTypes.items[i].unitType == (uint16_t)unitType)
if (_unitIdAndTypes.items[i].unitId == unitId &&
_unitIdAndTypes.items[i].unitType == (uint32_t)unitType)
{
_unitMotions.items[i].lastUsedFrame = _frame;
unitIndex = i;
Expand All @@ -182,8 +182,8 @@ Offset UnitMotionPredictor::GetOffset(
if (_unitsCount < (int32_t)_unitIdAndTypes.capacity)
{
unitIndex = _unitsCount++;
_unitIdAndTypes.items[unitIndex].unitId = (uint16_t)unitId;
_unitIdAndTypes.items[unitIndex].unitType = (uint16_t)unitType;
_unitIdAndTypes.items[unitIndex].unitId = unitId;
_unitIdAndTypes.items[unitIndex].unitType = (uint32_t)unitType;
_unitMotions.items[unitIndex] = { };
_unitMotions.items[unitIndex].lastUsedFrame = _frame;
}
Expand Down Expand Up @@ -212,8 +212,8 @@ void UnitMotionPredictor::SetUnitScreenPos(

for (int32_t unitIndex = 0; unitIndex < _unitsCount; ++unitIndex)
{
if (_unitIdAndTypes.items[unitIndex].unitId == (uint16_t)unitId &&
_unitIdAndTypes.items[unitIndex].unitType == (uint16_t)unitType)
if (_unitIdAndTypes.items[unitIndex].unitId == unitId &&
_unitIdAndTypes.items[unitIndex].unitType == (uint32_t)unitType)
{
_unitScreenPositions.items[unitIndex] = { x, y };
break;
Expand Down
4 changes: 2 additions & 2 deletions src/d2dx/UnitMotionPredictor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ namespace d2dx
private:
struct UnitIdAndType final
{
uint16_t unitType = 0;
uint16_t unitId = 0;
uint32_t unitType = 0;
uint32_t unitId = 0;
};

struct UnitMotion final
Expand Down

0 comments on commit cfc8e8b

Please sign in to comment.