X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fmain.cpp;h=02cae0317858310073f7aed49e4186b583403ba0;hb=b65a5aceb0d6552d8ba4878bed5326c614dd3046;hp=3bc7ca5f6a7cd126be56823582c91d17a562f75f;hpb=501034a792d08263bcab22fe0b50271192b2fe0f;p=dragonfireclient.git diff --git a/src/main.cpp b/src/main.cpp index 3bc7ca5f6..02cae0317 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -72,6 +72,12 @@ Other things to note: variable and fix them (result of getContent() must be stored in content_t, which is 16-bit) +NOTE: Seeds in 1260:6c77e7dbfd29: +5721858502589302589: + Spawns you on a small sand island with a surface dungeon +2983455799928051958: + Enormous jungle + a surface dungeon at ~(250,0,0) + Old, wild and random suggestions that probably won't be done: ------------------------------------------------------------- @@ -361,6 +367,9 @@ 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: ------------------------ @@ -402,10 +411,13 @@ Doing currently: //#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup") #endif +#include "irrlicht.h" // createDevice + +#include "main.h" +#include "mainmenumanager.h" #include #include #include -#include "main.h" #include "common_irrlicht.h" #include "debug.h" #include "test.h" @@ -422,8 +434,11 @@ Doing currently: #include "game.h" #include "keycode.h" #include "tile.h" - +#include "defaultsettings.h" #include "gettext.h" +#include "settings.h" +#include "profiler.h" +#include "log.h" // This makes textures ITextureSource *g_texturesource = NULL; @@ -432,25 +447,23 @@ ITextureSource *g_texturesource = NULL; Settings. These are loaded from the config file. */ - -Settings g_settings; -// This is located in defaultsettings.cpp -extern void set_default_settings(); +Settings main_settings; +Settings *g_settings = &main_settings; // Global profiler -Profiler g_profiler; +Profiler main_profiler; +Profiler *g_profiler = &main_profiler; /* Random stuff */ /* - GUI Stuff + mainmenumanager.h */ gui::IGUIEnvironment* guienv = NULL; gui::IGUIStaticText *guiroot = NULL; - MainMenuManager g_menumgr; bool noMenuActive() @@ -459,7 +472,6 @@ bool noMenuActive() } // Passed to menus to allow disconnecting and exiting - MainGameCallback *g_gamecallback = NULL; /* @@ -468,19 +480,15 @@ MainGameCallback *g_gamecallback = NULL; // 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; // 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 @@ -554,10 +562,12 @@ class MyEventReceiver : public IEventReceiver // Remember whether each key is down or up if(event.EventType == irr::EET_KEY_INPUT_EVENT) { - keyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown; - - if(event.KeyInput.PressedDown) - keyWasDown[event.KeyInput.Key] = true; + if(event.KeyInput.PressedDown) { + keyIsDown.set(event.KeyInput); + keyWasDown.set(event.KeyInput); + } else { + keyIsDown.unset(event.KeyInput); + } } if(event.EventType == irr::EET_MOUSE_INPUT_EVENT) @@ -570,7 +580,6 @@ class MyEventReceiver : public IEventReceiver } else { - //dstream<<"MyEventReceiver: mouse input"<IsKeyDown(keyCode); } - virtual bool wasKeyDown(EKEY_CODE keyCode) + virtual bool wasKeyDown(const KeyPress &keyCode) { return m_receiver->WasKeyDown(keyCode); } @@ -763,14 +770,13 @@ class RandomInputHandler : public InputHandler rightclicked = false; leftreleased = false; rightreleased = false; - for(u32 i=0; ireadConfigFile(cmd_args.get("config").c_str()); if(r == false) { - dstream<<"Could not read configuration from \"" + errorstream<<"Could not read configuration from \"" <readConfigFile(filenames[i].c_str()); if(r) { configpath = filenames[i]; @@ -1273,8 +1302,8 @@ int main(int argc, char *argv[]) u16 port = 30000; if(cmd_args.exists("port")) port = cmd_args.getU16("port"); - else if(g_settings.exists("port")) - port = g_settings.getU16("port"); + else if(g_settings->exists("port")) + port = g_settings->getU16("port"); if(port == 0) port = 30000; @@ -1282,8 +1311,8 @@ int main(int argc, char *argv[]) std::string map_dir = porting::path_userdata+"/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"); // Run dedicated server if asked to if(cmd_args.getFlag("server")) @@ -1294,7 +1323,7 @@ int main(int argc, char *argv[]) g_timegetter = new SimpleTimeGetter(); // Create server - Server server(map_dir.c_str()); + Server server(map_dir.c_str(), configpath); server.start(port); // Run server @@ -1317,10 +1346,10 @@ int main(int argc, char *argv[]) } else { - address = g_settings.get("address"); + address = g_settings->get("address"); } - std::string playername = g_settings.get("name"); + std::string playername = g_settings->get("name"); /* Device initialization @@ -1329,14 +1358,14 @@ int main(int argc, char *argv[]) // Resolution selection bool fullscreen = false; - u16 screenW = g_settings.getU16("screenW"); - u16 screenH = g_settings.getU16("screenH"); + u16 screenW = g_settings->getU16("screenW"); + u16 screenH = g_settings->getU16("screenH"); // Determine driver video::E_DRIVER_TYPE driverType; - std::string driverstring = g_settings.get("video_driver"); + std::string driverstring = g_settings->get("video_driver"); if(driverstring == "null") driverType = video::EDT_NULL; @@ -1352,7 +1381,7 @@ int main(int argc, char *argv[]) driverType = video::EDT_OPENGL; else { - dstream<<"WARNING: Invalid video_driver specified; defaulting " + errorstream<<"WARNING: Invalid video_driver specified; defaulting " "to opengl"<setWindowCaption(L"Minetest [Main Menu]"); @@ -1398,7 +1424,7 @@ int main(int argc, char *argv[]) device->setResizable(true); - bool random_input = g_settings.getBool("random_input") + bool random_input = g_settings->getBool("random_input") || cmd_args.getFlag("random-input"); InputHandler *input = NULL; if(random_input) @@ -1426,14 +1452,14 @@ int main(int argc, char *argv[]) if(font) skin->setFont(font); else - dstream<<"WARNING: Font file was not found." + errorstream<<"WARNING: Font file was not found." " Using default font."<getFont(); assert(font); u32 text_height = font->getDimension(L"Hello, world!").Height; - dstream<<"text_height="<getBool("new_style_leaves"); + menudata.smooth_lighting = g_settings->getBool("smooth_lighting"); + menudata.creative_mode = g_settings->getBool("creative_mode"); + menudata.enable_damage = g_settings->getBool("enable_damage"); GUIMainMenu *menu = new GUIMainMenu(guienv, guiroot, -1, @@ -1521,7 +1547,7 @@ int main(int argc, char *argv[]) if(error_message != L"") { - dstream<<"WARNING: error_message = " + errorstream<<"error_message = " <getVideoDriver(); - dstream<<"Created main menu"<run() && kill == false) { @@ -1558,7 +1584,7 @@ int main(int argc, char *argv[]) if(device->run() == false || kill == true) break; - dstream<<"Dropping main menu"<drop(); @@ -1575,14 +1601,16 @@ int main(int argc, char *argv[]) password = translatePassword(playername, menudata.password); + //infostream<<"Main: password hash: '"<set("new_style_leaves", itos(menudata.fancy_trees)); + g_settings->set("smooth_lighting", itos(menudata.smooth_lighting)); + g_settings->set("creative_mode", itos(menudata.creative_mode)); + g_settings->set("enable_damage", itos(menudata.enable_damage)); // NOTE: These are now checked server side; no need to do it // here, so let's not do it here. @@ -1601,12 +1629,12 @@ int main(int argc, char *argv[]) }*/ // Save settings - g_settings.set("name", playername); - g_settings.set("address", address); - g_settings.set("port", itos(port)); + g_settings->set("name", playername); + g_settings->set("address", address); + g_settings->set("port", itos(port)); // Update configuration file if(configpath != "") - g_settings.updateConfigFile(configpath.c_str()); + g_settings->updateConfigFile(configpath.c_str()); // Continue to game break; @@ -1633,18 +1661,19 @@ int main(int argc, char *argv[]) password, address, port, - error_message + error_message, + configpath ); } //try catch(con::PeerNotFoundException &e) { - dstream<drop(); - END_DEBUG_EXCEPTION_HANDLER + END_DEBUG_EXCEPTION_HANDLER(errorstream) debugstreams_deinit();