Browse Source

When player position desyncs ensure position.old is also updated

pull/5993/head
obligaron 3 years ago committed by Anders Jenbo
parent
commit
e1cdec438e
  1. 2
      Source/multi.cpp
  2. 11
      Source/player.cpp

2
Source/multi.cpp

@ -657,6 +657,7 @@ void multi_process_network_packets()
player.position.future = syncPosition;
if (player.isWalking())
player.position.temp = syncPosition;
SetPlayerOld(player);
dPlayer[player.position.tile.x][player.position.tile.y] = playerId + 1;
}
if (player.position.future.WalkingDistance(player.position.tile) > 1) {
@ -668,6 +669,7 @@ void multi_process_network_packets()
} else {
player.position.tile = syncPosition;
player.position.future = syncPosition;
SetPlayerOld(player);
}
}
}

11
Source/player.cpp

@ -2588,6 +2588,7 @@ void InitPlayer(Player &player, bool firstTime)
}
player.position.future = player.position.tile;
SetPlayerOld(player);
player.walkpath[0] = WALK_NONE;
player.destAction = ACTION_NONE;
@ -2701,6 +2702,16 @@ void FixPlrWalkTags(const Player &player)
dPlayer[searchTile.x][searchTile.y] = 0;
}
}
#ifdef _DEBUG
// Checks that FixPlrWalkTags really removes player from all dPlayer tiles
// FixPlrWalkTags could fail if player.position.old is not updated correctly
for (int y = 0; y < MAXDUNY; y++) {
for (int x = 0; x < MAXDUNX; x++) {
assert(PlayerAtPosition({ x, y }) != &player);
}
}
#endif
}
void StartPlrHit(Player &player, int dam, bool forcehit)

Loading…
Cancel
Save