]> git.lizzy.rs Git - minetest.git/blobdiff - src/server.h
Exposing the zoom key to Lua API (#9903)
[minetest.git] / src / server.h
index 71059dd307c6b89cc1a967aefcff9022093f5d55..f44716531f2d3c6cf49576f6ee2f64ed8bc42ac7 100644 (file)
@@ -27,7 +27,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "content/mods.h"
 #include "inventorymanager.h"
 #include "content/subgames.h"
-#include "tileanimation.h" // struct TileAnimationParams
+#include "tileanimation.h" // TileAnimationParams
+#include "particles.h" // ParticleParams
 #include "network/peerhandler.h"
 #include "network/address.h"
 #include "util/numeric.h"
@@ -68,6 +69,7 @@ struct MoonParams;
 struct StarParams;
 class ServerThread;
 class ServerModManager;
+class ServerInventoryManager;
 
 enum ClientDeletionReason {
        CDR_LEAVE,
@@ -116,7 +118,7 @@ struct ServerPlayingSound
 };
 
 class Server : public con::PeerHandler, public MapEventReceiver,
-               public InventoryManager, public IGameDef
+               public IGameDef
 {
 public:
        /*
@@ -134,7 +136,6 @@ class Server : public con::PeerHandler, public MapEventReceiver,
        ~Server();
        DISABLE_CLASS_COPY(Server);
 
-       void init();
        void start();
        void stop();
        // This is mainly a way to pass the time to the server.
@@ -196,12 +197,6 @@ class Server : public con::PeerHandler, public MapEventReceiver,
        */
        void onMapEditEvent(const MapEditEvent &event);
 
-       /*
-               Shall be called with the environment and the connection locked.
-       */
-       Inventory* getInventory(const InventoryLocation &loc);
-       void setInventoryModified(const InventoryLocation &loc);
-
        // Connection must be locked when called
        std::wstring getStatusString();
        inline double getUptime() const { return m_uptime_counter->get(); }
@@ -232,31 +227,19 @@ class Server : public con::PeerHandler, public MapEventReceiver,
 
        void notifyPlayer(const char *name, const std::wstring &msg);
        void notifyPlayers(const std::wstring &msg);
+
        void spawnParticle(const std::string &playername,
-               v3f pos, v3f velocity, v3f acceleration,
-               float expirationtime, float size,
-               bool collisiondetection, bool collision_removal, bool object_collision,
-               bool vertical, const std::string &texture,
-               const struct TileAnimationParams &animation, u8 glow);
-
-       u32 addParticleSpawner(u16 amount, float spawntime,
-               v3f minpos, v3f maxpos,
-               v3f minvel, v3f maxvel,
-               v3f minacc, v3f maxacc,
-               float minexptime, float maxexptime,
-               float minsize, float maxsize,
-               bool collisiondetection, bool collision_removal, bool object_collision,
-               ServerActiveObject *attached,
-               bool vertical, const std::string &texture,
-               const std::string &playername, const struct TileAnimationParams &animation,
-               u8 glow);
+               const ParticleParameters &p);
+
+       u32 addParticleSpawner(const ParticleSpawnerParameters &p,
+               ServerActiveObject *attached, const std::string &playername);
 
        void deleteParticleSpawner(const std::string &playername, u32 id);
 
-       // Creates or resets inventory
-       Inventory *createDetachedInventory(const std::string &name,
-                       const std::string &player = "");
-       bool removeDetachedInventory(const std::string &name);
+       bool dynamicAddMedia(const std::string &filepath);
+
+       ServerInventoryManager *getInventoryMgr() const { return m_inventory_mgr.get(); }
+       void sendDetachedInventory(Inventory *inventory, const std::string &name, session_t peer_id);
 
        // Envlock and conlock should be locked when using scriptapi
        ServerScripting *getScriptIface(){ return m_script; }
@@ -318,7 +301,7 @@ class Server : public con::PeerHandler, public MapEventReceiver,
 
        void setClouds(RemotePlayer *player, const CloudParams &params);
 
-       bool overrideDayNightRatio(RemotePlayer *player, bool do_override, float brightness);
+       void overrideDayNightRatio(RemotePlayer *player, bool do_override, float brightness);
 
        /* con::PeerHandler implementation. */
        void peerAdded(con::Peer *peer);
@@ -389,6 +372,8 @@ class Server : public con::PeerHandler, public MapEventReceiver,
                        float m_timer = 0.0f;
        };
 
+       void init();
+
        void SendMovement(session_t peer_id);
        void SendHP(session_t peer_id, u16 hp);
        void SendBreath(session_t peer_id, u16 breath);
@@ -452,35 +437,22 @@ class Server : public con::PeerHandler, public MapEventReceiver,
        // Sends blocks to clients (locks env and con on its own)
        void SendBlocks(float dtime);
 
+       bool addMediaFile(const std::string &filename, const std::string &filepath,
+                       std::string *filedata = nullptr, std::string *digest = nullptr);
        void fillMediaCache();
        void sendMediaAnnouncement(session_t peer_id, const std::string &lang_code);
        void sendRequestedMedia(session_t peer_id,
                        const std::vector<std::string> &tosend);
 
-       void sendDetachedInventory(const std::string &name, session_t peer_id);
-
        // Adds a ParticleSpawner on peer with peer_id (PEER_ID_INEXISTENT == all)
        void SendAddParticleSpawner(session_t peer_id, u16 protocol_version,
-               u16 amount, float spawntime,
-               v3f minpos, v3f maxpos,
-               v3f minvel, v3f maxvel,
-               v3f minacc, v3f maxacc,
-               float minexptime, float maxexptime,
-               float minsize, float maxsize,
-               bool collisiondetection, bool collision_removal, bool object_collision,
-               u16 attached_id,
-               bool vertical, const std::string &texture, u32 id,
-               const struct TileAnimationParams &animation, u8 glow);
+               const ParticleSpawnerParameters &p, u16 attached_id, u32 id);
 
        void SendDeleteParticleSpawner(session_t peer_id, u32 id);
 
        // Spawns particle on peer with peer_id (PEER_ID_INEXISTENT == all)
        void SendSpawnParticle(session_t peer_id, u16 protocol_version,
-               v3f pos, v3f velocity, v3f acceleration,
-               float expirationtime, float size,
-               bool collisiondetection, bool collision_removal, bool object_collision,
-               bool vertical, const std::string &texture,
-               const struct TileAnimationParams &animation, u8 glow);
+               const ParticleParameters &p);
 
        void SendActiveObjectRemoveAdd(RemoteClient *client, PlayerSAO *playersao);
        void SendActiveObjectMessages(session_t peer_id, const std::string &datas,
@@ -656,14 +628,6 @@ class Server : public con::PeerHandler, public MapEventReceiver,
        s32 m_next_sound_id = 0; // positive values only
        s32 nextSoundId();
 
-       /*
-               Detached inventories (behind m_env_mutex)
-       */
-       // key = name
-       std::map<std::string, Inventory*> m_detached_inventories;
-       // value = "" (visible to all players) or player name
-       std::map<std::string, std::string> m_detached_inventories_player;
-
        std::unordered_map<std::string, ModMetadata *> m_mod_storages;
        float m_mod_storage_save_timer = 10.0f;
 
@@ -674,6 +638,9 @@ class Server : public con::PeerHandler, public MapEventReceiver,
        // ModChannel manager
        std::unique_ptr<ModChannelMgr> m_modchannel_mgr;
 
+       // Inventory manager
+       std::unique_ptr<ServerInventoryManager> m_inventory_mgr;
+
        // Global server metrics backend
        std::unique_ptr<MetricsBackend> m_metrics_backend;