X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fmain.cpp;h=9d336825ec3a25b69b59b3d11b9a7be92cf43bf3;hb=58e6d25e033c76dc91aaac18fdeda92ac23fe0e1;hp=1caa918b85448d948f9116c133cc6348465ad7df;hpb=1cc40c0a7c260f0562572bc99f39a666a12f1b09;p=oweals%2Fminetest.git diff --git a/src/main.cpp b/src/main.cpp index 1caa918b8..9d336825e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -79,6 +79,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "httpfetch.h" #include "guiEngine.h" #include "mapsector.h" +#include "player.h" #include "database-sqlite3.h" #ifdef USE_LEVELDB @@ -381,8 +382,6 @@ public: #endif private: - IrrlichtDevice *m_device; - // The current state of keys KeyList keyIsDown; // Whether a key has been pressed or not @@ -1298,9 +1297,13 @@ int main(int argc, char *argv[]) new_db->beginSave(); for (std::list::iterator i = blocks.begin(); i != blocks.end(); i++) { MapBlock *block = old_map.loadBlock(*i); - new_db->saveBlock(block); - MapSector *sector = old_map.getSectorNoGenerate(v2s16(i->X, i->Z)); - sector->deleteBlock(block); + if (!block) { + errorstream << "Failed to load block " << PP(*i) << ", skipping it."; + } else { + old_map.saveBlock(block, new_db); + MapSector *sector = old_map.getSectorNoGenerate(v2s16(i->X, i->Z)); + sector->deleteBlock(block); + } ++count; if (count % 500 == 0) actionstream << "Migrated " << count << " blocks " @@ -1362,41 +1365,43 @@ int main(int argc, char *argv[]) u16 fsaa = g_settings->getU16("fsaa"); // Determine driver - - video::E_DRIVER_TYPE driverType; - - std::string driverstring = g_settings->get("video_driver"); - - if (driverstring == "null") - driverType = video::EDT_NULL; - else if (driverstring == "software") - driverType = video::EDT_SOFTWARE; - else if (driverstring == "burningsvideo") - driverType = video::EDT_BURNINGSVIDEO; - else if (driverstring == "direct3d8") - driverType = video::EDT_DIRECT3D8; - else if (driverstring == "direct3d9") - driverType = video::EDT_DIRECT3D9; - else if (driverstring == "opengl") - driverType = video::EDT_OPENGL; + video::E_DRIVER_TYPE driverType = video::EDT_OPENGL; + static const char* driverids[] = { + "null", + "software", + "burningsvideo", + "direct3d8", + "direct3d9", + "opengl" #ifdef _IRR_COMPILE_WITH_OGLES1_ - else if (driverstring == "ogles1") - driverType = video::EDT_OGLES1; + ,"ogles1" #endif #ifdef _IRR_COMPILE_WITH_OGLES2_ - else if (driverstring == "ogles2") - driverType = video::EDT_OGLES2; + ,"ogles2" #endif - else { - errorstream << "WARNING: Invalid video_driver specified; defaulting " - << "to opengl" << std::endl; - driverType = video::EDT_OPENGL; + ,"invalid" + }; + + std::string driverstring = g_settings->get("video_driver"); + for (unsigned int i = 0; + i < (sizeof(driverids)/sizeof(driverids[0])); + i++) + { + if (strcasecmp(driverstring.c_str(), driverids[i]) == 0) { + driverType = (video::E_DRIVER_TYPE) i; + break; + } + + if (strcasecmp("invalid", driverids[i]) == 0) { + errorstream << "WARNING: Invalid video_driver specified; defaulting " + << "to opengl" << std::endl; + break; + } } /* List video modes if requested */ - MyEventReceiver* receiver = new MyEventReceiver(); if (cmd_args.getFlag("videomodes")) { @@ -1841,6 +1846,13 @@ int main(int argc, char *argv[]) break; } + if (current_playername.length() > PLAYERNAME_SIZE-1) { + error_message = wgettext("Player name too long."); + playername = current_playername.substr(0,PLAYERNAME_SIZE-1); + g_settings->set("name", playername); + continue; + } + /* Run game */ @@ -1949,4 +1961,3 @@ int main(int argc, char *argv[]) } //END -