TODO: Merge bahamada's audio stuff (clean patch available)
-TODO: Move content_features to mapnode_content_features.{h,cpp} or so
-
-TODO: Fix item use() stuff; dropping a stack of cooked rats and eating
- it gives 3 hearts and consumes all the rats.
-
Making it more portable:
------------------------
*/
#ifdef NDEBUG
- #ifdef _WIN32
+ /*#ifdef _WIN32
#pragma message ("Disabling unit tests")
#else
#warning "Disabling unit tests"
- #endif
+ #endif*/
// Disable unit tests
#define ENABLE_TESTS 0
#else
#include "gettext.h"
#include "settings.h"
#include "profiler.h"
-
-// This makes textures
-ITextureSource *g_texturesource = NULL;
+#include "log.h"
+#include "nodedef.h" // For init_contentfeatures
+#include "content_mapnode.h" // For content_mapnode_init
/*
Settings.
// Connection
std::ostream *dout_con_ptr = &dummyout;
-std::ostream *derr_con_ptr = &dstream_no_stderr;
-//std::ostream *dout_con_ptr = &dstream_no_stderr;
-//std::ostream *derr_con_ptr = &dstream_no_stderr;
-//std::ostream *dout_con_ptr = &dstream;
-//std::ostream *derr_con_ptr = &dstream;
+std::ostream *derr_con_ptr = &verbosestream;
+//std::ostream *dout_con_ptr = &infostream;
+//std::ostream *derr_con_ptr = &errorstream;
// 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
}
else
{
- //dstream<<"MyEventReceiver: mouse input"<<std::endl;
left_active = event.MouseInput.isLeftPressed();
middle_active = event.MouseInput.isMiddlePressed();
right_active = event.MouseInput.isRightPressed();
u32 dtime = timer.stop();
u32 per_ms = n / dtime;
- std::cout<<"Done. "<<dtime<<"ms, "
+ dstream<<"Done. "<<dtime<<"ms, "
<<per_ms<<"/ms"<<std::endl;
}
}
}
}
+class StderrLogOutput: public ILogOutput
+{
+public:
+ /* line: Full line with timestamp, level and thread */
+ void printLog(const std::string &line)
+ {
+ std::cerr<<line<<std::endl;
+ }
+} main_stderr_log_out;
+
+class DstreamNoStderrLogOutput: public ILogOutput
+{
+public:
+ /* line: Full line with timestamp, level and thread */
+ void printLog(const std::string &line)
+ {
+ dstream_no_stderr<<line<<std::endl;
+ }
+} main_dstream_no_stderr_log_out;
+
int main(int argc, char *argv[])
{
/*
Initialization
*/
+ log_add_output_maxlev(&main_stderr_log_out, LMT_ACTION);
+ log_add_output_all_levs(&main_dstream_no_stderr_log_out);
+
+ log_register_thread("main");
+
// Set locale. This is for forcing '.' as the decimal point.
std::locale::global(std::locale("C"));
// This enables printing all characters in bitmap font
allowed_options.insert("dstream-on-stderr", ValueSpec(VALUETYPE_FLAG));
#endif
allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG));
+ allowed_options.insert("info-on-stderr", ValueSpec(VALUETYPE_FLAG));
Settings cmd_args;
if(cmd_args.getFlag("dstream-on-stderr") == false)
disable_stderr = true;
#endif
+
+ if(cmd_args.getFlag("info-on-stderr"))
+ log_add_output(&main_stderr_log_out, LMT_INFO);
porting::signal_handler_init();
bool &kill = *porting::signal_handler_killstatus();
// Create user data directory
fs::CreateDir(porting::path_userdata);
- init_gettext((porting::path_data+"/../locale").c_str());
+ init_gettext((porting::path_data+DIR_DELIM+".."+DIR_DELIM+"locale").c_str());
// Initialize debug streams
#ifdef RUN_IN_PLACE
std::string debugfile = DEBUGFILE;
#else
- std::string debugfile = porting::path_userdata+"/"+DEBUGFILE;
+ std::string debugfile = porting::path_userdata+DIR_DELIM+DEBUGFILE;
#endif
debugstreams_init(disable_stderr, debugfile.c_str());
// Initialize debug stacks
BEGIN_DEBUG_EXCEPTION_HANDLER
// Print startup message
- dstream<<DTIME<<PROJECT_NAME
+ actionstream<<PROJECT_NAME<<
" with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
<<", "<<BUILD_INFO
<<std::endl;
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
if(r == false)
{
- dstream<<"Could not read configuration from \""
+ errorstream<<"Could not read configuration from \""
<<cmd_args.get("config")<<"\""<<std::endl;
return 1;
}
else
{
core::array<std::string> 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; i<filenames.size(); i++)
These are needed for unit tests at least.
*/
- // Initial call with g_texturesource not set.
- init_mapnode();
+ // Must be called before texturesource is created
+ // (for texture atlas making)
+ init_mineral();
/*
Run unit tests
port = 30000;
// Map directory
- 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"))
driverType = video::EDT_OPENGL;
else
{
- dstream<<"WARNING: Invalid video_driver specified; defaulting "
+ errorstream<<"WARNING: Invalid video_driver specified; defaulting "
"to opengl"<<std::endl;
driverType = video::EDT_OPENGL;
}
if (device == 0)
return 1; // could not create selected driver.
+ /*
+ Continue initialization
+ */
+
+ video::IVideoDriver* driver = device->getVideoDriver();
+
+ // Disable mipmaps (because some of them look ugly)
+ driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
+
+ /*
+ This changes the minimum allowed number of vertices in a VBO.
+ Default is 500.
+ */
+ //driver->setMinHardwareBufferVertexCount(50);
+
// Set the window caption
device->setWindowCaption(L"Minetest [Main Menu]");
// Create game callback for menus
g_gamecallback = new MainGameCallback(device);
- // Create texture source
- g_texturesource = new TextureSource(device);
-
/*
Speed tests (done after irrlicht is loaded to get timer)
*/
else
input = new RealInputHandler(device, &receiver);
- /*
- Continue initialization
- */
-
- //video::IVideoDriver* driver = device->getVideoDriver();
-
- /*
- This changes the minimum allowed number of vertices in a VBO.
- Default is 500.
- */
- //driver->setMinHardwareBufferVertexCount(50);
-
scene::ISceneManager* smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
if(font)
skin->setFont(font);
else
- dstream<<"WARNING: Font file was not found."
+ errorstream<<"WARNING: Font file was not found."
" Using default font."<<std::endl;
// If font was not found, this will get us one
font = skin->getFont();
assert(font);
u32 text_height = font->getDimension(L"Hello, world!").Height;
- dstream<<"text_height="<<text_height<<std::endl;
+ infostream<<"text_height="<<text_height<<std::endl;
//skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,0,0,0));
skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,255,255,255));
skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255,0,0,0));
skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255,0,0,0));
- /*
- Preload some textures and stuff
- */
-
- init_mapnode(); // Second call with g_texturesource set
- init_mineral();
-
/*
GUI stuff
*/
menudata.port = narrow_to_wide(itos(port));
menudata.fancy_trees = g_settings->getBool("new_style_leaves");
menudata.smooth_lighting = g_settings->getBool("smooth_lighting");
+ menudata.clouds_3d = g_settings->getBool("enable_3d_clouds");
+ menudata.opaque_water = g_settings->getBool("opaque_water");
menudata.creative_mode = g_settings->getBool("creative_mode");
menudata.enable_damage = g_settings->getBool("enable_damage");
if(error_message != L"")
{
- dstream<<"WARNING: error_message = "
+ errorstream<<"error_message = "
<<wide_to_narrow(error_message)<<std::endl;
GUIMessageMenu *menu2 =
video::IVideoDriver* driver = device->getVideoDriver();
- dstream<<"Created main menu"<<std::endl;
+ infostream<<"Created main menu"<<std::endl;
while(device->run() && kill == false)
{
if(device->run() == false || kill == true)
break;
- dstream<<"Dropping main menu"<<std::endl;
+ infostream<<"Dropping main menu"<<std::endl;
menu->drop();
password = translatePassword(playername, menudata.password);
- //dstream<<"Main: password hash: '"<<password<<"'"<<std::endl;
+ //infostream<<"Main: password hash: '"<<password<<"'"<<std::endl;
address = wide_to_narrow(menudata.address);
int newport = stoi(wide_to_narrow(menudata.port));
port = newport;
g_settings->set("new_style_leaves", itos(menudata.fancy_trees));
g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
+ g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d));
+ g_settings->set("opaque_water", itos(menudata.opaque_water));
g_settings->set("creative_mode", itos(menudata.creative_mode));
g_settings->set("enable_damage", itos(menudata.enable_damage));
if(device->run() == false)
break;
- // Initialize mapnode again to enable changed graphics settings
- init_mapnode();
-
/*
Run game
*/
} //try
catch(con::PeerNotFoundException &e)
{
- dstream<<DTIME<<"Connection error (timed out?)"<<std::endl;
+ errorstream<<"Connection error (timed out?)"<<std::endl;
error_message = L"Connection error (timed out?)";
}
catch(SocketException &e)
{
- dstream<<DTIME<<"Socket error (port already in use?)"<<std::endl;
+ errorstream<<"Socket error (port already in use?)"<<std::endl;
error_message = L"Socket error (port already in use?)";
}
#ifdef NDEBUG
std::string narrow_message = "Some exception, what()=\"";
narrow_message += e.what();
narrow_message += "\"";
- dstream<<DTIME<<narrow_message<<std::endl;
+ errorstream<<narrow_message<<std::endl;
error_message = narrow_to_wide(narrow_message);
}
#endif
*/
device->drop();
- END_DEBUG_EXCEPTION_HANDLER
+ END_DEBUG_EXCEPTION_HANDLER(errorstream)
debugstreams_deinit();