X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fservermain.cpp;h=6eb45ea22a647def391a456f077f986c1a56bfdd;hb=c391bcee1698beabaec76ed13361d2930cb22f94;hp=5edc8ac7c0794c16c1efea2161936572649448bc;hpb=5a36956f75959887f75fda90c39d56181cd1f196;p=dragonfireclient.git diff --git a/src/servermain.cpp b/src/servermain.cpp index 5edc8ac7c..6eb45ea22 100644 --- a/src/servermain.cpp +++ b/src/servermain.cpp @@ -20,18 +20,18 @@ with this program; if not, write to the Free Software Foundation, Inc., /* =============================== NOTES ============================== -TODO: Move the default settings into some separate file */ #ifndef SERVER #ifdef _WIN32 + #pragma error ("For a server build, SERVER must be defined globally") #else #error "For a server build, SERVER must be defined globally" #endif #endif -#ifdef UNITTEST_DISABLE +#ifdef NDEBUG #ifdef _WIN32 #pragma message ("Disabling unit tests") #else @@ -49,15 +49,6 @@ TODO: Move the default settings into some separate file #pragma comment(lib, "zlibwapi.lib") #endif -#ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN - #include - #define sleep_ms(x) Sleep(x) -#else - #include - #define sleep_ms(x) usleep(x*1000) -#endif - #include #include #include @@ -75,9 +66,9 @@ TODO: Move the default settings into some separate file #include "constants.h" #include "strfnd.h" #include "porting.h" - -// Dummy variable -IrrlichtDevice *g_device = NULL; +#include "materials.h" +#include "config.h" +#include "mineral.h" /* Settings. @@ -88,6 +79,12 @@ Settings g_settings; extern void set_default_settings(); +// Global profiler +Profiler g_profiler; + +// A dummy thing +ITextureSource *g_texturesource = NULL; + /* Debug streams */ @@ -104,27 +101,29 @@ std::ostream *derr_server_ptr = &dstream; std::ostream *dout_client_ptr = &dstream; std::ostream *derr_client_ptr = &dstream; - /* - Timestamp stuff + gettime.h implementation */ -JMutex g_timestamp_mutex; - -std::string getTimestamp() +u32 getTimeMs() { - if(g_timestamp_mutex.IsInitialized()==false) - return ""; - JMutexAutoLock lock(g_timestamp_mutex); - time_t t = time(NULL); - struct tm *tm = localtime(&t); - char cs[20]; - strftime(cs, 20, "%H:%M:%S", tm); - return cs; + /* + Use imprecise system calls directly (from porting.h) + */ + return porting::getTimeMs(); } int main(int argc, char *argv[]) { + /* + Initialization + */ + + // Set locale. This is for forcing '.' as the decimal point. + std::locale::global(std::locale("C")); + // This enables printing all characters in bitmap font + setlocale(LC_CTYPE, "en_US"); + /* Low-level initialization */ @@ -134,13 +133,36 @@ int main(int argc, char *argv[]) disable_stderr = true; #endif + porting::signal_handler_init(); + bool &kill = *porting::signal_handler_killstatus(); + + // Initialize porting::path_data and porting::path_userdata + porting::initializePaths(); + // Initialize debug streams - debugstreams_init(disable_stderr, DEBUGFILE); +#ifdef RUN_IN_PLACE + std::string debugfile = DEBUGFILE; +#else + std::string debugfile = porting::path_userdata+"/"+DEBUGFILE; +#endif + debugstreams_init(disable_stderr, debugfile.c_str()); // Initialize debug stacks debug_stacks_init(); DSTACK(__FUNCTION_NAME); + // Init material properties table + //initializeMaterialProperties(); + + // Debug handler + BEGIN_DEBUG_EXCEPTION_HANDLER + + // Print startup message + dstream< filenames; + filenames.push_back(porting::path_userdata + "/minetest.conf"); +#ifdef RUN_IN_PLACE + filenames.push_back(porting::path_userdata + "/../minetest.conf"); +#endif - for(u32 i=0; i<2; i++) + for(u32 i=0; i__| \\___ >____ > |__| "< list = server.getPlayerInfo(); - core::list::Iterator i; - static u32 sum_old = 0; - u32 sum = PIChecksum(list); - if(sum != sum_old) - { - std::cout<PrintLine(&std::cout); - } - } - sum_old = sum; - } - } - - /* - Update configuration file - */ - if(configpath != "") - { - g_settings.updateConfigFile(configpath.c_str()); - } - + // Run server + dedicated_server_loop(server, kill); + } //try catch(con::PeerNotFoundException &e) { dstream<