X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fservermain.cpp;h=64853604b1a8ec64c11de1411005e66dec95a43f;hb=8492796a5c45787810aad7fe08fc63cadc0c96b5;hp=d5be5b8acebe0ad355c75d0bc1408334e533ccd3;hpb=c914cbb0a081b30b28271618bbaa8e987a108ae7;p=oweals%2Fminetest.git diff --git a/src/servermain.cpp b/src/servermain.cpp index d5be5b8ac..64853604b 100644 --- a/src/servermain.cpp +++ b/src/servermain.cpp @@ -68,15 +68,25 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "porting.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 @@ -84,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 @@ -107,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 + "/minetest.conf"); + filenames.push_back(porting::path_userdata + + DIR_DELIM + "minetest.conf"); #ifdef RUN_IN_PLACE - filenames.push_back(porting::path_userdata + "/../minetest.conf"); + filenames.push_back(porting::path_userdata + + DIR_DELIM + ".." + DIR_DELIM + "minetest.conf"); #endif for(u32 i=0; ireadConfigFile(filenames[i].c_str()); if(r) { configpath = filenames[i]; @@ -247,6 +300,10 @@ int main(int argc, char *argv[]) srand(time(0)); mysrand(time(0)); + // Initialize stuff + + init_mineral(); + /* Run unit tests */ @@ -255,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 @@ -291,9 +336,9 @@ int main(int argc, char *argv[]) { port = cmd_args.getU16("port"); } - else if(g_settings.exists("port") && g_settings.getU16("port") != 0) + else if(g_settings->exists("port") && g_settings->getU16("port") != 0) { - port = g_settings.getU16("port"); + port = g_settings->getU16("port"); } else { @@ -302,26 +347,26 @@ int main(int argc, char *argv[]) } // Figure out path to map - std::string map_dir = porting::path_userdata+"/map"; + std::string map_dir = porting::path_userdata+DIR_DELIM+"world"; if(cmd_args.exists("map-dir")) map_dir = cmd_args.get("map-dir"); - else if(g_settings.exists("map-dir")) - map_dir = g_settings.get("map-dir"); + else if(g_settings->exists("map-dir")) + map_dir = g_settings->get("map-dir"); // Create server - Server server(map_dir.c_str(), hm_params, map_params); + Server server(map_dir.c_str(), configpath); server.start(port); - + // Run server - dedicated_server_loop(server); + dedicated_server_loop(server, kill); } //try catch(con::PeerNotFoundException &e) { - dstream<