aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2016-10-08 17:56:38 +0200
committerNer'zhul <nerzhul@users.noreply.github.com>2016-10-08 22:27:44 +0200
commit7bbd716426bf989bf071e2322a9b797cc5f78acb (patch)
tree0c626a1cb5dd84a04c5963c020c0c9d29863e770 /src/server.cpp
parentedba6e50d9c9c0a7120c251bed36a87b51f4c826 (diff)
downloadminetest-7bbd716426bf989bf071e2322a9b797cc5f78acb.tar.gz
minetest-7bbd716426bf989bf071e2322a9b797cc5f78acb.tar.bz2
minetest-7bbd716426bf989bf071e2322a9b797cc5f78acb.zip
RemotePlayer/LocalPlayer Player base class proper separation (code cleanup) (patch 3 of X)
* remove IGameDef from Player class, only LocalPlayer has it now * move many attributes/functions only used by LocalPlayer from Player to LocalPlayer * move many attributes/functions only used by RemotePlayer from Player to RemotePlayer * make some functions const * hudGetHotbarSelectedImage now returns const ref * RemotePlayer getHotbarSelectedImage now returns const ref * various code style fixes
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/server.cpp b/src/server.cpp
index edd97e225..71e71f43e 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1108,7 +1108,7 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
SendPlayerBreath(peer_id);
// Show death screen if necessary
- if(player->isDead())
+ if (player->isDead())
SendDeathscreen(peer_id, false, v3f(0,0,0));
// Note things in chat if not in simple singleplayer mode
@@ -3080,14 +3080,6 @@ void Server::hudSetHotbarSelectedImage(RemotePlayer *player, std::string name)
SendHUDSetParam(player->peer_id, HUD_PARAM_HOTBAR_SELECTED_IMAGE, name);
}
-std::string Server::hudGetHotbarSelectedImage(RemotePlayer *player)
-{
- if (!player)
- return "";
-
- return player->getHotbarSelectedImage();
-}
-
bool Server::setLocalPlayerAnimations(RemotePlayer *player,
v2s32 animation_frames[4], f32 frame_speed)
{
@@ -3408,11 +3400,10 @@ PlayerSAO* Server::emergePlayer(const char *name, u16 peer_id, u16 proto_version
/*
Try to get an existing player
*/
- RemotePlayer *player = static_cast<RemotePlayer*>(m_env->getPlayer(name));
+ RemotePlayer *player = m_env->getPlayer(name);
// If player is already connected, cancel
- if(player != NULL && player->peer_id != 0)
- {
+ if (player != NULL && player->peer_id != 0) {
infostream<<"emergePlayer(): Player already connected"<<std::endl;
return NULL;
}
@@ -3420,8 +3411,7 @@ PlayerSAO* Server::emergePlayer(const char *name, u16 peer_id, u16 proto_version
/*
If player with the wanted peer_id already exists, cancel.
*/
- if(m_env->getPlayer(peer_id) != NULL)
- {
+ if (m_env->getPlayer(peer_id) != NULL) {
infostream<<"emergePlayer(): Player with wrong name but same"
" peer_id already exists"<<std::endl;
return NULL;
@@ -3429,13 +3419,13 @@ PlayerSAO* Server::emergePlayer(const char *name, u16 peer_id, u16 proto_version
// Load player if it isn't already loaded
if (!player) {
- player = static_cast<RemotePlayer*>(m_env->loadPlayer(name));
+ player = m_env->loadPlayer(name);
}
// Create player if it doesn't exist
if (!player) {
newplayer = true;
- player = new RemotePlayer(this, name);
+ player = new RemotePlayer(name, this->idef());
// Set player position
infostream<<"Server: Finding spawn place for player \""
<<name<<"\""<<std::endl;