diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2016-10-08 12:21:41 +0200 |
---|---|---|
committer | Ner'zhul <nerzhul@users.noreply.github.com> | 2016-10-08 15:57:50 +0200 |
commit | 656faf7373587bc59b47986a28dbd2fce4c45474 (patch) | |
tree | 0d2414db105bfeaa1112576725da61bfdfc1edec /src/network | |
parent | 9393e4a0a8e32905d32a9dc58131218aee318686 (diff) | |
download | minetest-656faf7373587bc59b47986a28dbd2fce4c45474.tar.gz minetest-656faf7373587bc59b47986a28dbd2fce4c45474.tar.bz2 minetest-656faf7373587bc59b47986a28dbd2fce4c45474.zip |
Player/LocalPlayer/RemotePlayer inheritance cleanup (part 2 on X)
* Server/Client Environments now have an helper to cast Player object in the right type to use it
* Server: use RemotePlayer everywhere and remove previous added casts
* Client: use LocalPlayer where needed
* Environment: remove unused functions (getPlayers(), getRandomConnectedPlayer(), getNearestConnectedPlayer())
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/serverpackethandler.cpp | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index 3fba7f720..6ef768295 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -800,8 +800,7 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt) pitch = modulo360f(pitch); yaw = modulo360f(yaw); - RemotePlayer *player = - dynamic_cast<RemotePlayer *>(m_env->getPlayer(pkt->getPeerId())); + RemotePlayer *player = m_env->getPlayer(pkt->getPeerId()); if (player == NULL) { errorstream << "Server::ProcessData(): Canceling: " "No player for peer_id=" << pkt->getPeerId() @@ -880,8 +879,7 @@ void Server::handleCommand_DeletedBlocks(NetworkPacket* pkt) void Server::handleCommand_InventoryAction(NetworkPacket* pkt) { - RemotePlayer *player = - dynamic_cast<RemotePlayer *>(m_env->getPlayer(pkt->getPeerId())); + RemotePlayer *player = m_env->getPlayer(pkt->getPeerId()); if (player == NULL) { errorstream << "Server::ProcessData(): Canceling: " @@ -1081,8 +1079,7 @@ void Server::handleCommand_Damage(NetworkPacket* pkt) *pkt >> damage; - RemotePlayer *player = - dynamic_cast<RemotePlayer *>(m_env->getPlayer(pkt->getPeerId())); + RemotePlayer *player = m_env->getPlayer(pkt->getPeerId()); if (player == NULL) { errorstream << "Server::ProcessData(): Canceling: " @@ -1117,8 +1114,7 @@ void Server::handleCommand_Breath(NetworkPacket* pkt) *pkt >> breath; - RemotePlayer *player = - dynamic_cast<RemotePlayer *>(m_env->getPlayer(pkt->getPeerId())); + RemotePlayer *player = m_env->getPlayer(pkt->getPeerId()); if (player == NULL) { errorstream << "Server::ProcessData(): Canceling: " @@ -1231,8 +1227,7 @@ void Server::handleCommand_PlayerItem(NetworkPacket* pkt) if (pkt->getSize() < 2) return; - RemotePlayer *player = - dynamic_cast<RemotePlayer *>(m_env->getPlayer(pkt->getPeerId())); + RemotePlayer *player = m_env->getPlayer(pkt->getPeerId()); if (player == NULL) { errorstream << "Server::ProcessData(): Canceling: " @@ -1308,8 +1303,7 @@ void Server::handleCommand_Interact(NetworkPacket* pkt) verbosestream << "TOSERVER_INTERACT: action=" << (int)action << ", item=" << item_i << ", pointed=" << pointed.dump() << std::endl; - RemotePlayer *player = - dynamic_cast<RemotePlayer *>(m_env->getPlayer(pkt->getPeerId())); + RemotePlayer *player = m_env->getPlayer(pkt->getPeerId()); if (player == NULL) { errorstream << "Server::ProcessData(): Canceling: " @@ -1730,8 +1724,7 @@ void Server::handleCommand_NodeMetaFields(NetworkPacket* pkt) fields[fieldname] = pkt->readLongString(); } - RemotePlayer *player = - dynamic_cast<RemotePlayer *>(m_env->getPlayer(pkt->getPeerId())); + RemotePlayer *player = m_env->getPlayer(pkt->getPeerId()); if (player == NULL) { errorstream << "Server::ProcessData(): Canceling: " @@ -1782,8 +1775,7 @@ void Server::handleCommand_InventoryFields(NetworkPacket* pkt) fields[fieldname] = pkt->readLongString(); } - RemotePlayer *player = - dynamic_cast<RemotePlayer *>(m_env->getPlayer(pkt->getPeerId())); + RemotePlayer *player = m_env->getPlayer(pkt->getPeerId()); if (player == NULL) { errorstream << "Server::ProcessData(): Canceling: " |