utility.h: Change Buffer's interface to be more compatible with SharedBuffer's interf...
[oweals/minetest.git] / src / server.h
index 791ecdec770009dcd9ead6b2347709efdd284399..b238bec26e86029b191c03101ce776808d4fb6f0 100644 (file)
@@ -17,10 +17,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-/*
-(c) 2010 Perttu Ahola <celeron55@gmail.com>
-*/
-
 #ifndef SERVER_HEADER
 #define SERVER_HEADER
 
@@ -28,11 +24,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "environment.h"
 #include "common_irrlicht.h"
 #include <string>
-#include "utility.h"
 #include "porting.h"
 #include "map.h"
 #include "inventory.h"
 #include "auth.h"
+#include "ban.h"
 
 /*
        Some random functions
@@ -239,6 +235,8 @@ public:
        u16 peer_id;
        // The serialization version to use with the client
        u8 serialization_version;
+       //
+       u16 net_proto_version;
        // Version is stored in here after INIT before INIT2
        u8 pending_serialization_version;
 
@@ -248,6 +246,7 @@ public:
        {
                peer_id = 0;
                serialization_version = SER_FMT_VER_INVALID;
+               net_proto_version = 0;
                pending_serialization_version = SER_FMT_VER_INVALID;
                m_nearest_unsent_d = 0;
                m_nearest_unsent_reset_timer = 0.0;
@@ -368,7 +367,8 @@ public:
        */
 
        Server(
-               std::string mapsavedir
+               std::string mapsavedir,
+               std::string configpath
        );
        ~Server();
        void start(unsigned short port);
@@ -447,6 +447,35 @@ public:
                        dstream<<"WARNING: Auth not found for "<<name<<std::endl;
                }
        }
+       
+       // Saves g_settings to configpath given at initialization
+       void saveConfig();
+
+       void setIpBanned(const std::string &ip, const std::string &name)
+       {
+               m_banmanager.add(ip, name);
+               return;
+       }
+
+       void unsetIpBanned(const std::string &ip_or_name)
+       {
+               m_banmanager.remove(ip_or_name);
+               return;
+       }
+
+       std::string getBanDescription(const std::string &ip_or_name)
+       {
+               return m_banmanager.getBanDescription(ip_or_name);
+       }
+
+       Address getPeerAddress(u16 peer_id)
+       {
+               return m_con.GetPeerAddress(peer_id);
+       }
+       
+       // Envlock and conlock should be locked when calling this
+       void notifyPlayer(const char *name, const std::wstring msg);
+       void notifyPlayers(const std::wstring msg);
 
 private:
 
@@ -463,6 +492,8 @@ private:
        static void SendHP(con::Connection &con, u16 peer_id, u8 hp);
        static void SendAccessDenied(con::Connection &con, u16 peer_id,
                        const std::wstring &reason);
+       static void SendDeathscreen(con::Connection &con, u16 peer_id,
+                       bool set_camera_point_target, v3f camera_point_target);
        
        /*
                Non-static send methods
@@ -472,6 +503,10 @@ private:
        void SendObjectData(float dtime);
        void SendPlayerInfos();
        void SendInventory(u16 peer_id);
+       // send wielded item info about player to all
+       void SendWieldedItem(const Player *player);
+       // send wielded item info about all players to all players
+       void SendPlayerItems();
        void SendChatMessage(u16 peer_id, const std::wstring &message);
        void BroadcastChatMessage(const std::wstring &message);
        void SendPlayerHP(Player *player);
@@ -497,6 +532,9 @@ private:
                Something random
        */
        
+       void HandlePlayerHP(Player *player, s16 damage);
+       void RespawnPlayer(Player *player);
+       
        void UpdateCrafting(u16 peer_id);
        
        // When called, connection mutex should be locked
@@ -538,6 +576,7 @@ private:
        float m_objectdata_timer;
        float m_emergethread_trigger_timer;
        float m_savemap_timer;
+       IntervalLimiter m_map_timer_and_unload_interval;
        
        // NOTE: If connection and environment are both to be locked,
        // environment shall be locked first.
@@ -554,6 +593,9 @@ private:
 
        // User authentication
        AuthManager m_authmanager;
+
+       // Bann checking
+       BanManager m_banmanager;
        
        /*
                Threads
@@ -609,6 +651,9 @@ private:
        // Map directory
        std::string m_mapsavedir;
 
+       // Configuration path ("" = no configuration file)
+       std::string m_configpath;
+
        bool m_shutdown_requested;
        
        /*