#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
#include "constants.h"
#include "strfnd.h"
#include "porting.h"
-//#include "irrlichtwrapper.h"
+#include "materials.h"
+#include "config.h"
/*
Settings.
DSTACK(__FUNCTION_NAME);
+ porting::initializePaths();
+
initializeMaterialProperties();
+ BEGIN_DEBUG_EXCEPTION_HANDLER
+
+ // Print startup message
+ dstream<<DTIME<<"minetest-c55"
+ " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
+ <<", "<<BUILD_INFO
+ <<std::endl;
+
try
{
// Initialize default settings
set_default_settings();
- // Print startup message
- dstream<<DTIME<<"minetest-c55 server"
- " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
- <<", ENABLE_TESTS="<<ENABLE_TESTS
- <<std::endl;
-
// Set locale. This is for forcing '.' as the decimal point.
std::locale::global(std::locale("C"));
// This enables printing all characters in bitmap font
}
else
{
- const char *filenames[2] =
- {
- "../minetest.conf",
- "../../minetest.conf"
- };
+ core::array<std::string> 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<filenames.size(); i++)
{
- bool r = g_settings.readConfigFile(filenames[i]);
+ bool r = g_settings.readConfigFile(filenames[i].c_str());
if(r)
{
configpath = filenames[i];
// Initialize random seed
srand(time(0));
+ mysrand(time(0));
/*
Run unit tests
std::cout<<std::endl;
// Figure out path to map
- std::string map_dir = "../map";
+ std::string map_dir = porting::path_userdata+"/map";
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");
Server server(map_dir.c_str(), hm_params, map_params);
server.start(port);
{
dstream<<DTIME<<"Connection timed out."<<std::endl;
}
-#if CATCH_UNHANDLED_EXCEPTIONS
- /*
- This is what has to be done in every thread to get suitable debug info
- */
- catch(std::exception &e)
- {
- dstream<<std::endl<<DTIME<<"An unhandled exception occurred: "
- <<e.what()<<std::endl;
- assert(0);
- }
-#endif
+
+ END_DEBUG_EXCEPTION_HANDLER
debugstreams_deinit();