X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fserver.h;h=e9477ba53395a8ca9728d3a55a5015849375282f;hb=ffb1128951638fb462fe1e24aa2963aab6246b07;hp=79cdf052d6fd04052242e8cce58794c3f6249d1a;hpb=c707e00195f1035ae535f3fc8697af42e73190c0;p=dragonfireclient.git diff --git a/src/server.h b/src/server.h index 79cdf052d..e9477ba53 100644 --- a/src/server.h +++ b/src/server.h @@ -1,3 +1,22 @@ +/* +Minetest-c55 +Copyright (C) 2010 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +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 */ @@ -9,15 +28,20 @@ #include "environment.h" #include "common_irrlicht.h" #include +#include "utility.h" +#include "porting.h" +#include "map.h" +#include "inventory.h" -#ifdef _WIN32 - #include - #define sleep_ms(x) Sleep(x) -#else - #include - #define sleep_ms(x) usleep(x*1000) -#endif +/* + Some random functions +*/ +v3f findSpawnPos(ServerMap &map); +/* + A structure containing the data needed for queueing the fetching + of blocks. +*/ struct QueuedBlockEmerge { v3s16 pos; @@ -53,6 +77,8 @@ class BlockEmergeQueue */ void addBlock(u16 peer_id, v3s16 pos, u8 flags) { + DSTACK(__FUNCTION_NAME); + JMutexAutoLock lock(m_mutex); if(peer_id != 0) @@ -125,44 +151,6 @@ class BlockEmergeQueue JMutex m_mutex; }; -class SimpleThread : public JThread -{ - bool run; - JMutex run_mutex; - -public: - - SimpleThread(): - JThread(), - run(true) - { - run_mutex.Init(); - } - - virtual ~SimpleThread() - {} - - virtual void * Thread() = 0; - - bool getRun() - { - JMutexAutoLock lock(run_mutex); - return run; - } - void setRun(bool a_run) - { - JMutexAutoLock lock(run_mutex); - run = a_run; - } - - void stop() - { - setRun(false); - while(IsRunning()) - sleep_ms(100); - } -}; - class Server; class ServerThread : public SimpleThread @@ -254,16 +242,16 @@ class RemoteClient u8 pending_serialization_version; RemoteClient(): - m_time_from_building(0.0) - //m_num_blocks_in_emerge_queue(0) + m_time_from_building(9999), + m_excess_gotblocks(0) { peer_id = 0; serialization_version = SER_FMT_VER_INVALID; pending_serialization_version = SER_FMT_VER_INVALID; m_nearest_unsent_d = 0; - - m_blocks_sent_mutex.Init(); - m_blocks_sending_mutex.Init(); + m_nearest_unsent_reset_timer = 0.0; + m_nothing_to_send_counter = 0; + m_nothing_to_send_pause_timer = 0; } ~RemoteClient() { @@ -277,9 +265,11 @@ class RemoteClient void GetNextBlocks(Server *server, float dtime, core::array &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, @@ -293,17 +283,8 @@ class RemoteClient void SetBlockNotSent(v3s16 p); void SetBlocksNotSent(core::map &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); return m_blocks_sending.size(); } @@ -314,36 +295,31 @@ class RemoteClient void PrintInfo(std::ostream &o) { - JMutexAutoLock l2(m_blocks_sent_mutex); - JMutexAutoLock l3(m_blocks_sending_mutex); o<<"RemoteClient "<