X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fservermain.cpp;h=64853604b1a8ec64c11de1411005e66dec95a43f;hb=8492796a5c45787810aad7fe08fc63cadc0c96b5;hp=0c2faa7ec9285546401d636a3037a96111ab6095;hpb=b94a00786454968a1cc309b01180292b114da4bd;p=oweals%2Fminetest.git diff --git a/src/servermain.cpp b/src/servermain.cpp index 0c2faa7ec..64853604b 100644 --- a/src/servermain.cpp +++ b/src/servermain.cpp @@ -25,12 +25,13 @@ with this program; if not, write to the Free Software Foundation, Inc., #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 @@ -65,16 +66,27 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "constants.h" #include "strfnd.h" #include "porting.h" -//#include "irrlichtwrapper.h" +#include "materials.h" +#include "config.h" +#include "mineral.h" +#include "filesys.h" +#include "defaultsettings.h" +#include "settings.h" +#include "profiler.h" +#include "log.h" +#include "nodedef.h" // For init_contentfeatures +#include "content_mapnode.h" // For content_mapnode_init /* Settings. These are loaded from the config file. */ +Settings main_settings; +Settings *g_settings = &main_settings; -Settings g_settings; - -extern void set_default_settings(); +// Global profiler +Profiler main_profiler; +Profiler *g_profiler = &main_profiler; /* Debug streams @@ -82,16 +94,15 @@ extern void set_default_settings(); // Connection std::ostream *dout_con_ptr = &dummyout; -std::ostream *derr_con_ptr = &dstream_no_stderr; +std::ostream *derr_con_ptr = &verbosestream; // Server -std::ostream *dout_server_ptr = &dstream; -std::ostream *derr_server_ptr = &dstream; +std::ostream *dout_server_ptr = &infostream; +std::ostream *derr_server_ptr = &errorstream; // Client -std::ostream *dout_client_ptr = &dstream; -std::ostream *derr_client_ptr = &dstream; - +std::ostream *dout_client_ptr = &infostream; +std::ostream *derr_client_ptr = &errorstream; /* gettime.h implementation @@ -105,8 +116,42 @@ u32 getTimeMs() return porting::getTimeMs(); } +class StderrLogOutput: public ILogOutput +{ +public: + /* line: Full line with timestamp, level and thread */ + void printLog(const std::string &line) + { + std::cerr<readConfigFile(cmd_args.get("config").c_str()); if(r == false) { - dstream<<"Could not read configuration from \"" + errorstream<<"Could not read configuration from \"" < filenames; + filenames.push_back(porting::path_userdata + + DIR_DELIM + "minetest.conf"); +#ifdef RUN_IN_PLACE + filenames.push_back(porting::path_userdata + + DIR_DELIM + ".." + DIR_DELIM + "minetest.conf"); +#endif - for(u32 i=0; i<2; i++) + for(u32 i=0; ireadConfigFile(filenames[i].c_str()); if(r) { configpath = filenames[i]; @@ -236,6 +298,11 @@ int main(int argc, char *argv[]) // Initialize random seed srand(time(0)); + mysrand(time(0)); + + // Initialize stuff + + init_mineral(); /* Run unit tests @@ -245,18 +312,6 @@ int main(int argc, char *argv[]) { run_tests(); } - - // Read map parameters from settings - - HMParams hm_params; - hm_params.blocksize = g_settings.getU16("heightmap_blocksize"); - hm_params.randmax = g_settings.get("height_randmax"); - hm_params.randfactor = g_settings.get("height_randfactor"); - hm_params.base = g_settings.get("height_base"); - - MapParams map_params; - map_params.plants_amount = g_settings.getFloat("plants_amount"); - map_params.ravines_amount = g_settings.getFloat("ravines_amount"); /* Check parameters @@ -277,13 +332,13 @@ int main(int argc, char *argv[]) // Port? u16 port = 30000; - if(cmd_args.exists("port")) + if(cmd_args.exists("port") && cmd_args.getU16("port") != 0) { port = cmd_args.getU16("port"); } - else if(g_settings.exists("port")) + else if(g_settings->exists("port") && g_settings->getU16("port") != 0) { - port = g_settings.getU16("port"); + port = g_settings->getU16("port"); } else { @@ -291,62 +346,27 @@ int main(int argc, char *argv[]) <exists("map-dir")) + map_dir = g_settings->get("map-dir"); - std::cout< 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; - } - } - + // Run server + dedicated_server_loop(server, kill); + } //try catch(con::PeerNotFoundException &e) { - dstream<