Skip to content

Commit ab95217

Browse files
committed
fix downcast
1 parent 92839a8 commit ab95217

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/bzflag/playing.cxx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,11 +3511,20 @@ static void handlePlayerMessage(uint16_t code, uint16_t,
35113511
{
35123512
ShotUpdate shot;
35133513
msg = shot.unpack(msg);
3514-
Player* tank = lookupPlayer(shot.player);
3514+
PlayerId playerId = shot.player;
3515+
Player* tank = lookupPlayer(playerId);
35153516
if (!tank || tank == myTank) break;
3516-
RemotePlayer* remoteTank = (RemotePlayer*)tank;
3517-
RemoteShotPath* shotPath =
3518-
(RemoteShotPath*)remoteTank->getShot(shot.id);
3517+
RemoteShotPath* shotPath;
3518+
if (playerId == ServerPlayer)
3519+
{
3520+
WorldPlayer* remotePlayer = static_cast<WorldPlayer*>(tank);
3521+
shotPath = (RemoteShotPath*)remotePlayer->getShot(shot.id);
3522+
}
3523+
else
3524+
{
3525+
RemotePlayer* remoteTank = (RemotePlayer*)tank;
3526+
shotPath = (RemoteShotPath*)remoteTank->getShot(shot.id);
3527+
}
35193528
if (shotPath) shotPath->update(shot, code, msg);
35203529
PlayerId targetId;
35213530
msg = nboUnpackUByte(msg, targetId);

0 commit comments

Comments
 (0)