aboutsummaryrefslogtreecommitdiff
path: root/src/network/serverpackethandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/serverpackethandler.cpp')
-rw-r--r--src/network/serverpackethandler.cpp55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index 554025747..5e70b4c6c 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -809,13 +809,6 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
return;
}
- // If player is dead we don't care of this packet
- if (player->isDead()) {
- verbosestream << "TOSERVER_PLAYERPOS: " << player->getName()
- << " is dead. Ignoring packet";
- return;
- }
-
PlayerSAO *playersao = player->getPlayerSAO();
if (playersao == NULL) {
errorstream << "Server::ProcessData(): Canceling: "
@@ -825,10 +818,17 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
return;
}
- player->setPosition(position);
+ // If player is dead we don't care of this packet
+ if (playersao->isDead()) {
+ verbosestream << "TOSERVER_PLAYERPOS: " << player->getName()
+ << " is dead. Ignoring packet";
+ return;
+ }
+
+ playersao->setBasePosition(position);
player->setSpeed(speed);
- player->setPitch(pitch);
- player->setYaw(yaw);
+ playersao->setPitch(pitch, false);
+ playersao->setYaw(yaw, false);
player->keyPressed = keyPressed;
player->control.up = (keyPressed & 1);
player->control.down = (keyPressed & 2);
@@ -1100,7 +1100,7 @@ void Server::handleCommand_Damage(NetworkPacket* pkt)
if (g_settings->getBool("enable_damage")) {
actionstream << player->getName() << " damaged by "
- << (int)damage << " hp at " << PP(player->getPosition() / BS)
+ << (int)damage << " hp at " << PP(playersao->getBasePosition() / BS)
<< std::endl;
playersao->setHP(playersao->getHP() - damage);
@@ -1124,16 +1124,6 @@ void Server::handleCommand_Breath(NetworkPacket* pkt)
return;
}
- /*
- * If player is dead, we don't need to update the breath
- * He is dead !
- */
- if (player->isDead()) {
- verbosestream << "TOSERVER_BREATH: " << player->getName()
- << " is dead. Ignoring packet";
- return;
- }
-
PlayerSAO *playersao = player->getPlayerSAO();
if (playersao == NULL) {
@@ -1144,6 +1134,16 @@ void Server::handleCommand_Breath(NetworkPacket* pkt)
return;
}
+ /*
+ * If player is dead, we don't need to update the breath
+ * He is dead !
+ */
+ if (playersao->isDead()) {
+ verbosestream << "TOSERVER_BREATH: " << player->getName()
+ << " is dead. Ignoring packet";
+ return;
+ }
+
playersao->setBreath(breath);
SendPlayerBreath(pkt->getPeerId());
}
@@ -1264,13 +1264,16 @@ void Server::handleCommand_Respawn(NetworkPacket* pkt)
return;
}
- if (!player->isDead())
+ PlayerSAO *playersao = player->getPlayerSAO();
+ assert(playersao);
+
+ if (!playersao->isDead())
return;
RespawnPlayer(pkt->getPeerId());
actionstream << player->getName() << " respawns at "
- << PP(player->getPosition()/BS) << std::endl;
+ << PP(playersao->getBasePosition() / BS) << std::endl;
// ActiveObject is added to environment in AsyncRunStep after
// the previous addition has been successfully removed
@@ -1322,9 +1325,9 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
return;
}
- if (player->isDead()) {
+ if (playersao->isDead()) {
verbosestream << "TOSERVER_INTERACT: " << player->getName()
- << " is dead. Ignoring packet";
+ << " is dead. Ignoring packet";
return;
}
@@ -1455,7 +1458,7 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
ToolCapabilities toolcap =
punchitem.getToolCapabilities(m_itemdef);
v3f dir = (pointed_object->getBasePosition() -
- (player->getPosition() + player->getEyeOffset())
+ (playersao->getBasePosition() + playersao->getEyeOffset())
).normalize();
float time_from_last_punch =
playersao->resetTimeFromLastPunch();