]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/server.h
crafting system!
[dragonfireclient.git] / src / server.h
index c20189eb106003f8e703fce2b6e2c92e4a281fab..d002d9f4c9cf1afb390cc5828dd2eac0023002f4 100644 (file)
@@ -29,14 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "common_irrlicht.h"
 #include <string>
 #include "utility.h"
-
-#ifdef _WIN32
-       #include <windows.h>
-       #define sleep_ms(x) Sleep(x)
-#else
-       #include <unistd.h>
-       #define sleep_ms(x) usleep(x*1000)
-#endif
+#include "porting.h"
 
 struct QueuedBlockEmerge
 {
@@ -265,9 +258,11 @@ class RemoteClient
        void GetNextBlocks(Server *server, float dtime,
                        core::array<PrioritySortedBlockTransfer> &dest);
 
-       // Connection and environment should be locked when this is called
-       // steps() objects of blocks not found in active_blocks, then
-       // adds those blocks to active_blocks
+       /*
+               Connection and environment should be locked when this is called.
+               steps() objects of blocks not found in active_blocks, then
+               adds those blocks to active_blocks
+       */
        void SendObjectData(
                        Server *server,
                        float dtime,
@@ -281,14 +276,6 @@ class RemoteClient
        void SetBlockNotSent(v3s16 p);
        void SetBlocksNotSent(core::map<v3s16, MapBlock*> &blocks);
 
-       //void BlockEmerged();
-
-       /*bool IsSendingBlock(v3s16 p)
-       {
-               JMutexAutoLock lock(m_blocks_sending_mutex);
-               return (m_blocks_sending.find(p) != NULL);
-       }*/
-
        s32 SendingCount()
        {
                JMutexAutoLock lock(m_blocks_sending_mutex);
@@ -404,6 +391,18 @@ class Server : public con::PeerHandler
        //void SendSectorMeta(u16 peer_id, core::list<v2s16> ps, u8 ver);
 
        core::list<PlayerInfo> getPlayerInfo();
+
+       u32 getDayNightRatio()
+       {
+               s32 d = 8;
+               s32 t = (((m_time_of_day.get() + 24000/d/2)%24000)/(24000/d));
+               if(t == d/4 || t == (d-d/4))
+                       return 600;
+               else if(t < d/4 || t > (d-d/4))
+                       return 300;
+               else
+                       return 1000;
+       }
        
 private:
 
@@ -457,6 +456,12 @@ class Server : public con::PeerHandler
        
        // Nodes that are destinations of flowing liquid at the moment
        core::map<v3s16, u8> m_flow_active_nodes;
+
+       // 0-23999
+       MutexedVariable<u32> m_time_of_day;
+       // Used to buffer dtime for adding to m_time_of_day
+       float m_time_counter;
+       float m_time_of_day_send_timer;
        
        friend class EmergeThread;
        friend class RemoteClient;