#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
{
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,
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);
//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:
// 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;