aboutsummaryrefslogtreecommitdiff
path: root/src/environment.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/environment.h')
-rw-r--r--src/environment.h57
1 files changed, 26 insertions, 31 deletions
diff --git a/src/environment.h b/src/environment.h
index c6786faed..4bee40e57 100644
--- a/src/environment.h
+++ b/src/environment.h
@@ -54,6 +54,7 @@ class ClientMap;
class GameScripting;
class Player;
class RemotePlayer;
+class PlayerSAO;
class Environment
{
@@ -72,15 +73,6 @@ public:
virtual Map & getMap() = 0;
- virtual void addPlayer(Player *player);
- void removePlayer(Player *player);
- Player * getPlayer(u16 peer_id);
- Player * getPlayer(const char *name);
- Player * getRandomConnectedPlayer();
- Player * getNearestConnectedPlayer(v3f pos);
- std::vector<Player*> getPlayers();
- std::vector<Player*> getPlayers(bool ignore_disconnected);
-
u32 getDayNightRatio();
// 0-23999
@@ -91,7 +83,6 @@ public:
void stepTimeOfDay(float dtime);
void setTimeOfDaySpeed(float speed);
- float getTimeOfDaySpeed();
void setDayNightRatioOverride(bool enable, u32 value);
@@ -101,9 +92,6 @@ public:
u32 m_added_objects;
protected:
- // 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;
/*
@@ -300,6 +288,8 @@ enum ClearObjectsMode {
This is not thread-safe. Server uses an environment mutex.
*/
+typedef UNORDERED_MAP<u16, ServerActiveObject *> ActiveObjectMap;
+
class ServerEnvironment : public Environment
{
public:
@@ -326,7 +316,9 @@ public:
// Save players
void saveLoadedPlayers();
void savePlayer(RemotePlayer *player);
- Player *loadPlayer(const std::string &playername);
+ RemotePlayer *loadPlayer(const std::string &playername, PlayerSAO *sao);
+ void addPlayer(RemotePlayer *player);
+ void removePlayer(RemotePlayer *player);
/*
Save and load time of day and game timer
@@ -338,7 +330,8 @@ public:
void loadDefaultMeta();
u32 addParticleSpawner(float exptime);
- void deleteParticleSpawner(u32 id);
+ u32 addParticleSpawner(float exptime, u16 attached_id);
+ void deleteParticleSpawner(u32 id, bool remove_from_object = true);
/*
External ActiveObject interface
@@ -370,7 +363,7 @@ public:
Find out what new objects have been added to
inside a radius around a position
*/
- void getAddedActiveObjects(Player *player, s16 radius,
+ void getAddedActiveObjects(PlayerSAO *playersao, s16 radius,
s16 player_radius,
std::set<u16> &current_objects,
std::queue<u16> &added_objects);
@@ -379,7 +372,7 @@ public:
Find out what new objects have been removed from
inside a radius around a position
*/
- void getRemovedActiveObjects(Player* player, s16 radius,
+ void getRemovedActiveObjects(PlayerSAO *playersao, s16 radius,
s16 player_radius,
std::set<u16> &current_objects,
std::queue<u16> &removed_objects);
@@ -438,6 +431,8 @@ public:
void setStaticForActiveObjectsInBlock(v3s16 blockpos,
bool static_exists, v3s16 static_block=v3s16(0,0,0));
+ RemotePlayer *getPlayer(const u16 peer_id);
+ RemotePlayer *getPlayer(const char* name);
private:
/*
@@ -491,7 +486,7 @@ private:
// World path
const std::string m_path_world;
// Active object list
- std::map<u16, ServerActiveObject*> m_active_objects;
+ ActiveObjectMap m_active_objects;
// Outgoing network message buffer for active objects
std::queue<ActiveObjectMessage> m_active_object_messages;
// Some timers
@@ -520,9 +515,13 @@ 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;
- std::map<u32, float> m_particle_spawners;
+ UNORDERED_MAP<u32, float> m_particle_spawners;
+ UNORDERED_MAP<u32, u16> m_particle_spawner_attachments;
};
#ifndef SERVER
@@ -579,8 +578,8 @@ public:
void step(f32 dtime);
- virtual void addPlayer(Player *player);
- LocalPlayer * getLocalPlayer();
+ virtual void setLocalPlayer(LocalPlayer *player);
+ LocalPlayer *getLocalPlayer() { return m_local_player; }
/*
ClientSimpleObjects
@@ -630,24 +629,20 @@ 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()
- { return m_camera_offset; }
-
+ v3s16 getCameraOffset() const { return m_camera_offset; }
private:
ClientMap *m_map;
+ LocalPlayer *m_local_player;
scene::ISceneManager *m_smgr;
ITextureSource *m_texturesource;
IGameDef *m_gamedef;
IrrlichtDevice *m_irr;
- std::map<u16, ClientActiveObject*> m_active_objects;
+ UNORDERED_MAP<u16, ClientActiveObject*> m_active_objects;
std::vector<ClientSimpleObject*> m_simple_objects;
std::queue<ClientEnvEvent> m_client_event_queue;
IntervalLimiter m_active_object_light_update_interval;