X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fservermain.cpp;h=64853604b1a8ec64c11de1411005e66dec95a43f;hb=8492796a5c45787810aad7fe08fc63cadc0c96b5;hp=f83e2ae76da8cefe6ff953a0fdbf361fdd99b128;hpb=7cfb71385d00d1cbbbfd9c76f6c01adafa9e648a;p=oweals%2Fminetest.git diff --git a/src/servermain.cpp b/src/servermain.cpp index f83e2ae76..64853604b 100644 --- a/src/servermain.cpp +++ b/src/servermain.cpp @@ -69,21 +69,24 @@ with this program; if not, write to the Free Software Foundation, Inc., #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 g_settings; - -extern void set_default_settings(); +Settings main_settings; +Settings *g_settings = &main_settings; // Global profiler -Profiler g_profiler; - -// A dummy thing -ITextureSource *g_texturesource = NULL; +Profiler main_profiler; +Profiler *g_profiler = &main_profiler; /* Debug streams @@ -91,15 +94,15 @@ ITextureSource *g_texturesource = NULL; // 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 @@ -113,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]; @@ -258,7 +302,6 @@ int main(int argc, char *argv[]) // Initialize stuff - init_mapnode(); init_mineral(); /* @@ -293,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 { @@ -304,14 +347,14 @@ int main(int argc, char *argv[]) } // Figure out path to map - std::string map_dir = porting::path_userdata+"/world"; + 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()); + Server server(map_dir.c_str(), configpath); server.start(port); // Run server @@ -320,10 +363,10 @@ int main(int argc, char *argv[]) } //try catch(con::PeerNotFoundException &e) { - dstream<