summaryrefslogtreecommitdiff
path: root/src/environment.h
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2016-10-08 23:13:38 +0200
committerNer'zhul <nerzhul@users.noreply.github.com>2016-10-09 15:17:10 +0200
commit70f104be076321330a0827010704761a040d8ec7 (patch)
treee6d297b317cb37f85f51f65164bf0537ee8586d1 /src/environment.h
parentb3fc133442724cc2785d0c7e2beea2d782d8a087 (diff)
downloadminetest-70f104be076321330a0827010704761a040d8ec7.tar.gz
minetest-70f104be076321330a0827010704761a040d8ec7.tar.bz2
minetest-70f104be076321330a0827010704761a040d8ec7.zip
Environment cleanup
* Move client list to ServerEnvironment and use RemotePlayer members instead of Player * ClientEnvironment only use setLocalPlayer to specify the current player * Remove ClientEnvironment dead code on player list (in fact other players are CAO not Player objects) * Drop LocalPlayer::getPlayer(xxx) functions which aren't used. * Improve a little bit performance by using const ref list for ClientEnvironment::getPlayerNames() & Client::getConnectedPlayerNames() * Drop isLocal() function from (Local)Player which is not needed anymore because of previous changes This change permits to cleanup shared client list which is very old code. ClientEnvironment doesn't use player list anymore, it only contains the local player, as addPlayer is only called from Client constructor client side. Clients are only CAO on client side, this cleanup permit to remove confusion about player list.
Diffstat (limited to 'src/environment.h')
-rw-r--r--src/environment.h32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/environment.h b/src/environment.h
index f19708ad7..83ad69562 100644
--- a/src/environment.h
+++ b/src/environment.h
@@ -72,9 +72,6 @@ public:
virtual Map & getMap() = 0;
- virtual void addPlayer(Player *player);
- void removePlayer(Player *player);
-
u32 getDayNightRatio();
// 0-23999
@@ -94,12 +91,6 @@ public:
u32 m_added_objects;
protected:
- Player *getPlayer(u16 peer_id);
- Player *getPlayer(const char *name);
-
- // peer_ids in here should be unique, except that there may be many 0s
- std::vector<Player*> m_players;
-
GenericAtomic<float> m_time_of_day_speed;
/*
@@ -325,6 +316,8 @@ public:
void saveLoadedPlayers();
void savePlayer(RemotePlayer *player);
RemotePlayer *loadPlayer(const std::string &playername);
+ void addPlayer(RemotePlayer *player);
+ void removePlayer(RemotePlayer *player);
/*
Save and load time of day and game timer
@@ -520,6 +513,9 @@ private:
// Can raise to high values like 15s with eg. map generation mods.
float m_max_lag_estimate;
+ // peer_ids in here should be unique, except that there may be many 0s
+ std::vector<RemotePlayer*> m_players;
+
// Particles
IntervalLimiter m_particle_management_interval;
UNORDERED_MAP<u32, float> m_particle_spawners;
@@ -579,8 +575,8 @@ public:
void step(f32 dtime);
- virtual void addPlayer(LocalPlayer *player);
- LocalPlayer * getLocalPlayer();
+ virtual void setLocalPlayer(LocalPlayer *player);
+ LocalPlayer *getLocalPlayer() { return m_local_player; }
/*
ClientSimpleObjects
@@ -630,21 +626,15 @@ public:
u16 attachement_parent_ids[USHRT_MAX + 1];
- std::list<std::string> getPlayerNames()
- { return m_player_names; }
- void addPlayerName(std::string name)
- { m_player_names.push_back(name); }
- void removePlayerName(std::string name)
- { m_player_names.remove(name); }
+ const std::list<std::string> &getPlayerNames() { return m_player_names; }
+ void addPlayerName(const std::string &name) { m_player_names.push_back(name); }
+ void removePlayerName(const std::string &name) { m_player_names.remove(name); }
void updateCameraOffset(v3s16 camera_offset)
{ m_camera_offset = camera_offset; }
v3s16 getCameraOffset() const { return m_camera_offset; }
-
- LocalPlayer *getPlayer(const u16 peer_id);
- LocalPlayer *getPlayer(const char* name);
-
private:
ClientMap *m_map;
+ LocalPlayer *m_local_player;
scene::ISceneManager *m_smgr;
ITextureSource *m_texturesource;
IGameDef *m_gamedef;