Codestyle cleanup (main.cpp)
This commit is contained in:
parent
32ab6c2a32
commit
a7d49da217
186
src/main.cpp
186
src/main.cpp
@ -252,14 +252,12 @@ public:
|
|||||||
/*
|
/*
|
||||||
React to nothing here if a menu is active
|
React to nothing here if a menu is active
|
||||||
*/
|
*/
|
||||||
if(noMenuActive() == false)
|
if (noMenuActive() == false) {
|
||||||
{
|
|
||||||
return g_menumgr.preprocessEvent(event);
|
return g_menumgr.preprocessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember whether each key is down or up
|
// Remember whether each key is down or up
|
||||||
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
|
if (event.EventType == irr::EET_KEY_INPUT_EVENT) {
|
||||||
{
|
|
||||||
if (event.KeyInput.PressedDown) {
|
if (event.KeyInput.PressedDown) {
|
||||||
keyIsDown.set(event.KeyInput);
|
keyIsDown.set(event.KeyInput);
|
||||||
keyWasDown.set(event.KeyInput);
|
keyWasDown.set(event.KeyInput);
|
||||||
@ -268,44 +266,34 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
|
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT) {
|
||||||
{
|
if (noMenuActive() == false) {
|
||||||
if(noMenuActive() == false)
|
|
||||||
{
|
|
||||||
left_active = false;
|
left_active = false;
|
||||||
middle_active = false;
|
middle_active = false;
|
||||||
right_active = false;
|
right_active = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
left_active = event.MouseInput.isLeftPressed();
|
left_active = event.MouseInput.isLeftPressed();
|
||||||
middle_active = event.MouseInput.isMiddlePressed();
|
middle_active = event.MouseInput.isMiddlePressed();
|
||||||
right_active = event.MouseInput.isRightPressed();
|
right_active = event.MouseInput.isRightPressed();
|
||||||
|
|
||||||
if(event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
|
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {
|
||||||
{
|
|
||||||
leftclicked = true;
|
leftclicked = true;
|
||||||
}
|
}
|
||||||
if(event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN)
|
if (event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN) {
|
||||||
{
|
|
||||||
rightclicked = true;
|
rightclicked = true;
|
||||||
}
|
}
|
||||||
if(event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
|
if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) {
|
||||||
{
|
|
||||||
leftreleased = true;
|
leftreleased = true;
|
||||||
}
|
}
|
||||||
if(event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP)
|
if (event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP) {
|
||||||
{
|
|
||||||
rightreleased = true;
|
rightreleased = true;
|
||||||
}
|
}
|
||||||
if(event.MouseInput.Event == EMIE_MOUSE_WHEEL)
|
if (event.MouseInput.Event == EMIE_MOUSE_WHEEL) {
|
||||||
{
|
|
||||||
mouse_wheel += event.MouseInput.Wheel;
|
mouse_wheel += event.MouseInput.Wheel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(event.EventType == irr::EET_LOG_TEXT_EVENT)
|
if (event.EventType == irr::EET_LOG_TEXT_EVENT) {
|
||||||
{
|
|
||||||
dstream << "Irrlicht log: " << event.LogEvent.Text << std::endl;
|
dstream << "Irrlicht log: " << event.LogEvent.Text << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -544,8 +532,7 @@ public:
|
|||||||
{
|
{
|
||||||
static float counter1 = 0;
|
static float counter1 = 0;
|
||||||
counter1 -= dtime;
|
counter1 -= dtime;
|
||||||
if(counter1 < 0.0)
|
if (counter1 < 0.0) {
|
||||||
{
|
|
||||||
counter1 = 0.1 * Rand(1, 40);
|
counter1 = 0.1 * Rand(1, 40);
|
||||||
keydown.toggle(getKeySetting("keymap_jump"));
|
keydown.toggle(getKeySetting("keymap_jump"));
|
||||||
}
|
}
|
||||||
@ -553,8 +540,7 @@ public:
|
|||||||
{
|
{
|
||||||
static float counter1 = 0;
|
static float counter1 = 0;
|
||||||
counter1 -= dtime;
|
counter1 -= dtime;
|
||||||
if(counter1 < 0.0)
|
if (counter1 < 0.0) {
|
||||||
{
|
|
||||||
counter1 = 0.1 * Rand(1, 40);
|
counter1 = 0.1 * Rand(1, 40);
|
||||||
keydown.toggle(getKeySetting("keymap_special1"));
|
keydown.toggle(getKeySetting("keymap_special1"));
|
||||||
}
|
}
|
||||||
@ -562,8 +548,7 @@ public:
|
|||||||
{
|
{
|
||||||
static float counter1 = 0;
|
static float counter1 = 0;
|
||||||
counter1 -= dtime;
|
counter1 -= dtime;
|
||||||
if(counter1 < 0.0)
|
if (counter1 < 0.0) {
|
||||||
{
|
|
||||||
counter1 = 0.1 * Rand(1, 40);
|
counter1 = 0.1 * Rand(1, 40);
|
||||||
keydown.toggle(getKeySetting("keymap_forward"));
|
keydown.toggle(getKeySetting("keymap_forward"));
|
||||||
}
|
}
|
||||||
@ -571,8 +556,7 @@ public:
|
|||||||
{
|
{
|
||||||
static float counter1 = 0;
|
static float counter1 = 0;
|
||||||
counter1 -= dtime;
|
counter1 -= dtime;
|
||||||
if(counter1 < 0.0)
|
if (counter1 < 0.0) {
|
||||||
{
|
|
||||||
counter1 = 0.1 * Rand(1, 40);
|
counter1 = 0.1 * Rand(1, 40);
|
||||||
keydown.toggle(getKeySetting("keymap_left"));
|
keydown.toggle(getKeySetting("keymap_left"));
|
||||||
}
|
}
|
||||||
@ -580,8 +564,7 @@ public:
|
|||||||
{
|
{
|
||||||
static float counter1 = 0;
|
static float counter1 = 0;
|
||||||
counter1 -= dtime;
|
counter1 -= dtime;
|
||||||
if(counter1 < 0.0)
|
if (counter1 < 0.0) {
|
||||||
{
|
|
||||||
counter1 = 0.1 * Rand(1, 20);
|
counter1 = 0.1 * Rand(1, 20);
|
||||||
mousespeed = v2s32(Rand(-20, 20), Rand(-15, 20));
|
mousespeed = v2s32(Rand(-20, 20), Rand(-15, 20));
|
||||||
}
|
}
|
||||||
@ -589,8 +572,7 @@ public:
|
|||||||
{
|
{
|
||||||
static float counter1 = 0;
|
static float counter1 = 0;
|
||||||
counter1 -= dtime;
|
counter1 -= dtime;
|
||||||
if(counter1 < 0.0)
|
if (counter1 < 0.0) {
|
||||||
{
|
|
||||||
counter1 = 0.1 * Rand(1, 30);
|
counter1 = 0.1 * Rand(1, 30);
|
||||||
leftdown = !leftdown;
|
leftdown = !leftdown;
|
||||||
if (leftdown)
|
if (leftdown)
|
||||||
@ -602,8 +584,7 @@ public:
|
|||||||
{
|
{
|
||||||
static float counter1 = 0;
|
static float counter1 = 0;
|
||||||
counter1 -= dtime;
|
counter1 -= dtime;
|
||||||
if(counter1 < 0.0)
|
if (counter1 < 0.0) {
|
||||||
{
|
|
||||||
counter1 = 0.1 * Rand(1, 15);
|
counter1 = 0.1 * Rand(1, 15);
|
||||||
rightdown = !rightdown;
|
rightdown = !rightdown;
|
||||||
if (rightdown)
|
if (rightdown)
|
||||||
@ -648,8 +629,7 @@ void SpeedTests()
|
|||||||
infostream << "The following test should take around 20ms." << std::endl;
|
infostream << "The following test should take around 20ms." << std::endl;
|
||||||
TimeTaker timer("Testing std::string speed");
|
TimeTaker timer("Testing std::string speed");
|
||||||
const u32 jj = 10000;
|
const u32 jj = 10000;
|
||||||
for(u32 j=0; j<jj; j++)
|
for(u32 j = 0; j < jj; j++) {
|
||||||
{
|
|
||||||
tempstring = "";
|
tempstring = "";
|
||||||
tempstring2 = "";
|
tempstring2 = "";
|
||||||
const u32 ii = 10;
|
const u32 ii = 10;
|
||||||
@ -725,13 +705,11 @@ void SpeedTests()
|
|||||||
|
|
||||||
u32 dtime = timer.stop();
|
u32 dtime = timer.stop();
|
||||||
u32 per_ms = n / dtime;
|
u32 per_ms = n / dtime;
|
||||||
infostream<<"Done. "<<dtime<<"ms, "
|
infostream << "Done. " << dtime << "ms, " << per_ms << "/ms" << std::endl;
|
||||||
<<per_ms<<"/ms"<<std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_worldspecs(const std::vector<WorldSpec> &worldspecs,
|
static void print_worldspecs(const std::vector<WorldSpec> &worldspecs, std::ostream &os)
|
||||||
std::ostream &os)
|
|
||||||
{
|
{
|
||||||
for(u32 i = 0; i < worldspecs.size(); i++) {
|
for(u32 i = 0; i < worldspecs.size(); i++) {
|
||||||
std::string name = worldspecs[i].name;
|
std::string name = worldspecs[i].name;
|
||||||
@ -817,18 +795,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
bool ret = cmd_args.parseCommandLine(argc, argv, allowed_options);
|
bool ret = cmd_args.parseCommandLine(argc, argv, allowed_options);
|
||||||
|
|
||||||
if(ret == false || cmd_args.getFlag("help") || cmd_args.exists("nonopt1"))
|
if (ret == false || cmd_args.getFlag("help") || cmd_args.exists("nonopt1")) {
|
||||||
{
|
|
||||||
dstream << _("Allowed options:") << std::endl;
|
dstream << _("Allowed options:") << std::endl;
|
||||||
for(std::map<std::string, ValueSpec>::iterator
|
for(std::map<std::string, ValueSpec>::iterator
|
||||||
i = allowed_options.begin();
|
i = allowed_options.begin();
|
||||||
i != allowed_options.end(); ++i)
|
i != allowed_options.end(); ++i) {
|
||||||
{
|
|
||||||
std::ostringstream os1(std::ios::binary);
|
std::ostringstream os1(std::ios::binary);
|
||||||
os1 << " --"<<i->first;
|
os1 << " --"<<i->first;
|
||||||
if(i->second.type == VALUETYPE_FLAG)
|
if (i->second.type == VALUETYPE_FLAG) {
|
||||||
{}
|
} else
|
||||||
else
|
|
||||||
os1 << _(" <value>");
|
os1 << _(" <value>");
|
||||||
dstream << padStringRight(os1.str(), 24);
|
dstream << padStringRight(os1.str(), 24);
|
||||||
|
|
||||||
@ -840,8 +815,7 @@ int main(int argc, char *argv[])
|
|||||||
return cmd_args.getFlag("help") ? 0 : 1;
|
return cmd_args.getFlag("help") ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmd_args.getFlag("version"))
|
if (cmd_args.getFlag("version")) {
|
||||||
{
|
|
||||||
#ifdef SERVER
|
#ifdef SERVER
|
||||||
dstream << "minetestserver " << minetest_version_hash << std::endl;
|
dstream << "minetestserver " << minetest_version_hash << std::endl;
|
||||||
#else
|
#else
|
||||||
@ -895,8 +869,7 @@ int main(int argc, char *argv[])
|
|||||||
BEGIN_DEBUG_EXCEPTION_HANDLER
|
BEGIN_DEBUG_EXCEPTION_HANDLER
|
||||||
|
|
||||||
// List gameids if requested
|
// List gameids if requested
|
||||||
if(cmd_args.exists("gameid") && cmd_args.get("gameid") == "list")
|
if (cmd_args.exists("gameid") && cmd_args.get("gameid") == "list") {
|
||||||
{
|
|
||||||
std::set<std::string> gameids = getAvailableGameIds();
|
std::set<std::string> gameids = getAvailableGameIds();
|
||||||
for(std::set<std::string>::const_iterator i = gameids.begin();
|
for(std::set<std::string>::const_iterator i = gameids.begin();
|
||||||
i != gameids.end(); i++)
|
i != gameids.end(); i++)
|
||||||
@ -913,10 +886,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print startup message
|
// Print startup message
|
||||||
infostream<<PROJECT_NAME<<
|
infostream<<PROJECT_NAME << " "<< _("with") << " SER_FMT_VER_HIGHEST_READ="
|
||||||
" "<<_("with")<<" SER_FMT_VER_HIGHEST_READ="<<(int)SER_FMT_VER_HIGHEST_READ
|
<< (int)SER_FMT_VER_HIGHEST_READ << ", " << minetest_build_info << std::endl;
|
||||||
<<", "<<minetest_build_info
|
|
||||||
<<std::endl;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Basic initialization
|
Basic initialization
|
||||||
@ -936,19 +907,15 @@ int main(int argc, char *argv[])
|
|||||||
// Path of configuration file in use
|
// Path of configuration file in use
|
||||||
g_settings_path = "";
|
g_settings_path = "";
|
||||||
|
|
||||||
if(cmd_args.exists("config"))
|
if (cmd_args.exists("config")) {
|
||||||
{
|
|
||||||
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
|
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
|
||||||
if(r == false)
|
if (r == false) {
|
||||||
{
|
|
||||||
errorstream << "Could not read configuration from \""
|
errorstream << "Could not read configuration from \""
|
||||||
<< cmd_args.get("config") << "\"" << std::endl;
|
<< cmd_args.get("config") << "\"" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
g_settings_path = cmd_args.get("config");
|
g_settings_path = cmd_args.get("config");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
std::vector<std::string> filenames;
|
std::vector<std::string> filenames;
|
||||||
filenames.push_back(porting::path_user +
|
filenames.push_back(porting::path_user +
|
||||||
DIR_DELIM + "minetest.conf");
|
DIR_DELIM + "minetest.conf");
|
||||||
@ -962,11 +929,9 @@ int main(int argc, char *argv[])
|
|||||||
DIR_DELIM + ".." + DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
|
DIR_DELIM + ".." + DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(u32 i=0; i<filenames.size(); i++)
|
for(u32 i = 0; i < filenames.size(); i++) {
|
||||||
{
|
|
||||||
bool r = g_settings->readConfigFile(filenames[i].c_str());
|
bool r = g_settings->readConfigFile(filenames[i].c_str());
|
||||||
if(r)
|
if (r) {
|
||||||
{
|
|
||||||
g_settings_path = filenames[i];
|
g_settings_path = filenames[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -993,7 +958,8 @@ int main(int argc, char *argv[])
|
|||||||
if (loglevel == 0) //no logging
|
if (loglevel == 0) //no logging
|
||||||
logfile = "";
|
logfile = "";
|
||||||
else if (loglevel > 0 && loglevel <= LMT_NUM_VALUES)
|
else if (loglevel > 0 && loglevel <= LMT_NUM_VALUES)
|
||||||
log_add_output_maxlev(&main_dstream_no_stderr_log_out, (LogMessageLevel)(loglevel - 1));
|
log_add_output_maxlev(&main_dstream_no_stderr_log_out,
|
||||||
|
(LogMessageLevel)(loglevel - 1));
|
||||||
|
|
||||||
if (logfile != "")
|
if (logfile != "")
|
||||||
debugstreams_init(false, logfile.c_str());
|
debugstreams_init(false, logfile.c_str());
|
||||||
@ -1014,14 +980,15 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ((ENABLE_TESTS && cmd_args.getFlag("disable-unittests") == false)
|
if ((ENABLE_TESTS && cmd_args.getFlag("disable-unittests") == false)
|
||||||
|| cmd_args.getFlag("enable-unittests") == true)
|
|| cmd_args.getFlag("enable-unittests") == true) {
|
||||||
{
|
|
||||||
run_tests();
|
run_tests();
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
init_gettext((porting::path_share + DIR_DELIM + "locale").c_str(),g_settings->get("language"),argc,argv);
|
init_gettext((porting::path_share + DIR_DELIM + "locale").c_str(),
|
||||||
|
g_settings->get("language"), argc, argv);
|
||||||
#else
|
#else
|
||||||
init_gettext((porting::path_share + DIR_DELIM + "locale").c_str(),g_settings->get("language"));
|
init_gettext((porting::path_share + DIR_DELIM + "locale").c_str(),
|
||||||
|
g_settings->get("language"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1060,8 +1027,8 @@ int main(int argc, char *argv[])
|
|||||||
commanded_world.substr(commanded_world.size() - worldmt.size())
|
commanded_world.substr(commanded_world.size() - worldmt.size())
|
||||||
== worldmt) {
|
== worldmt) {
|
||||||
dstream << _("Supplied world.mt file - stripping it off.") << std::endl;
|
dstream << _("Supplied world.mt file - stripping it off.") << std::endl;
|
||||||
commanded_world = commanded_world.substr(
|
commanded_world = commanded_world.substr(0,
|
||||||
0, commanded_world.size()-worldmt.size());
|
commanded_world.size() - worldmt.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1128,10 +1095,7 @@ int main(int argc, char *argv[])
|
|||||||
world_path = commanded_world;
|
world_path = commanded_world;
|
||||||
infostream << "Using commanded world path [" << world_path << "]"
|
infostream << "Using commanded world path [" << world_path << "]"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
} else { // No world was specified; try to select it automatically
|
||||||
// No world was specified; try to select it automatically
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Get information about available worlds
|
// Get information about available worlds
|
||||||
std::vector<WorldSpec> worldspecs = getAvailableWorlds();
|
std::vector<WorldSpec> worldspecs = getAvailableWorlds();
|
||||||
// If a world name was specified, select it
|
// If a world name was specified, select it
|
||||||
@ -1183,22 +1147,16 @@ int main(int argc, char *argv[])
|
|||||||
SubgameSpec gamespec;
|
SubgameSpec gamespec;
|
||||||
verbosestream << _("Determining gameid/gamespec") << std::endl;
|
verbosestream << _("Determining gameid/gamespec") << std::endl;
|
||||||
// If world doesn't exist
|
// If world doesn't exist
|
||||||
if(!getWorldExists(world_path))
|
if (!getWorldExists(world_path)) {
|
||||||
{
|
|
||||||
// Try to take gamespec from command line
|
// Try to take gamespec from command line
|
||||||
if (commanded_gamespec.isValid()) {
|
if (commanded_gamespec.isValid()) {
|
||||||
gamespec = commanded_gamespec;
|
gamespec = commanded_gamespec;
|
||||||
infostream << "Using commanded gameid [" << gamespec.id << "]" << std::endl;
|
infostream << "Using commanded gameid [" << gamespec.id << "]" << std::endl;
|
||||||
}
|
} else { // Otherwise we will be using "minetest"
|
||||||
// Otherwise we will be using "minetest"
|
|
||||||
else{
|
|
||||||
gamespec = findSubgame(g_settings->get("default_game"));
|
gamespec = findSubgame(g_settings->get("default_game"));
|
||||||
infostream << "Using default gameid [" << gamespec.id << "]" << std::endl;
|
infostream << "Using default gameid [" << gamespec.id << "]" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
} else { // World exists
|
||||||
// World exists
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string world_gameid = getWorldGameId(world_path, is_legacy_world);
|
std::string world_gameid = getWorldGameId(world_path, is_legacy_world);
|
||||||
// If commanded to use a gameid, do so
|
// If commanded to use a gameid, do so
|
||||||
if (commanded_gamespec.isValid()) {
|
if (commanded_gamespec.isValid()) {
|
||||||
@ -1250,7 +1208,8 @@ int main(int argc, char *argv[])
|
|||||||
if (cmd_args.exists("migrate")) {
|
if (cmd_args.exists("migrate")) {
|
||||||
std::string migrate_to = cmd_args.get("migrate");
|
std::string migrate_to = cmd_args.get("migrate");
|
||||||
Settings world_mt;
|
Settings world_mt;
|
||||||
bool success = world_mt.readConfigFile((world_path + DIR_DELIM + "world.mt").c_str());
|
bool success = world_mt.readConfigFile((world_path + DIR_DELIM
|
||||||
|
+ "world.mt").c_str());
|
||||||
if (!success) {
|
if (!success) {
|
||||||
errorstream << "Cannot read world.mt" << std::endl;
|
errorstream << "Cannot read world.mt" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
@ -1263,7 +1222,8 @@ int main(int argc, char *argv[])
|
|||||||
std::string backend = world_mt.get("backend");
|
std::string backend = world_mt.get("backend");
|
||||||
Database *new_db;
|
Database *new_db;
|
||||||
if (backend == migrate_to) {
|
if (backend == migrate_to) {
|
||||||
errorstream << "Cannot migrate: new backend is same as the old one" << std::endl;
|
errorstream << "Cannot migrate: new backend is same"
|
||||||
|
<<" as the old one" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (migrate_to == "sqlite3")
|
if (migrate_to == "sqlite3")
|
||||||
@ -1277,7 +1237,8 @@ int main(int argc, char *argv[])
|
|||||||
new_db = new Database_Redis(&(ServerMap&)server.getMap(), world_path);
|
new_db = new Database_Redis(&(ServerMap&)server.getMap(), world_path);
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
errorstream << "Migration to " << migrate_to << " is not supported" << std::endl;
|
errorstream << "Migration to " << migrate_to
|
||||||
|
<< " is not supported" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1286,7 +1247,7 @@ int main(int argc, char *argv[])
|
|||||||
old_map.listAllLoadableBlocks(blocks);
|
old_map.listAllLoadableBlocks(blocks);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
new_db->beginSave();
|
new_db->beginSave();
|
||||||
for (std::list<v3s16>::iterator i = blocks.begin(); i != blocks.end(); ++i) {
|
for (std::list<v3s16>::iterator i = blocks.begin(); i != blocks.end(); i++) {
|
||||||
MapBlock *block = old_map.loadBlock(*i);
|
MapBlock *block = old_map.loadBlock(*i);
|
||||||
new_db->saveBlock(block);
|
new_db->saveBlock(block);
|
||||||
MapSector *sector = old_map.getSectorNoGenerate(v2s16(i->X, i->Z));
|
MapSector *sector = old_map.getSectorNoGenerate(v2s16(i->X, i->Z));
|
||||||
@ -1377,10 +1338,9 @@ int main(int argc, char *argv[])
|
|||||||
else if (driverstring == "ogles2")
|
else if (driverstring == "ogles2")
|
||||||
driverType = video::EDT_OGLES2;
|
driverType = video::EDT_OGLES2;
|
||||||
#endif
|
#endif
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
errorstream << "WARNING: Invalid video_driver specified; defaulting "
|
errorstream << "WARNING: Invalid video_driver specified; defaulting "
|
||||||
"to opengl"<<std::endl;
|
<< "to opengl" << std::endl;
|
||||||
driverType = video::EDT_OPENGL;
|
driverType = video::EDT_OPENGL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1537,7 +1497,8 @@ int main(int argc, char *argv[])
|
|||||||
font_path = g_settings->get(fallback + "font_path");
|
font_path = g_settings->get(fallback + "font_path");
|
||||||
u32 font_shadow = g_settings->getU16(fallback + "font_shadow");
|
u32 font_shadow = g_settings->getU16(fallback + "font_shadow");
|
||||||
u32 font_shadow_alpha = g_settings->getU16(fallback + "font_shadow_alpha");
|
u32 font_shadow_alpha = g_settings->getU16(fallback + "font_shadow_alpha");
|
||||||
font = gui::CGUITTFont::createTTFont(guienv, font_path.c_str(), font_size, true, true, font_shadow, font_shadow_alpha);
|
font = gui::CGUITTFont::createTTFont(guienv, font_path.c_str(), font_size,
|
||||||
|
true, true, font_shadow, font_shadow_alpha);
|
||||||
} else {
|
} else {
|
||||||
font = guienv->getFont(font_path.c_str());
|
font = guienv->getFont(font_path.c_str());
|
||||||
}
|
}
|
||||||
@ -1548,7 +1509,7 @@ int main(int argc, char *argv[])
|
|||||||
skin->setFont(font);
|
skin->setFont(font);
|
||||||
else
|
else
|
||||||
errorstream << "WARNING: Font file was not found."
|
errorstream << "WARNING: Font file was not found."
|
||||||
" Using default font."<<std::endl;
|
<< " Using default font." << std::endl;
|
||||||
// If font was not found, this will get us one
|
// If font was not found, this will get us one
|
||||||
font = skin->getFont();
|
font = skin->getFont();
|
||||||
assert(font);
|
assert(font);
|
||||||
@ -1556,10 +1517,7 @@ int main(int argc, char *argv[])
|
|||||||
u32 text_height = font->getDimension(L"Hello, world!").Height;
|
u32 text_height = font->getDimension(L"Hello, world!").Height;
|
||||||
infostream << "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_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
|
||||||
//skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(0,0,0,0));
|
|
||||||
//skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(0,0,0,0));
|
|
||||||
skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 0, 0, 0));
|
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));
|
skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0));
|
||||||
skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 100, 50));
|
skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 100, 50));
|
||||||
@ -1644,8 +1602,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Loop quits when menu returns proper parameters.
|
Loop quits when menu returns proper parameters.
|
||||||
*/
|
*/
|
||||||
while(kill == false)
|
while (kill == false) {
|
||||||
{
|
|
||||||
// If skip_main_menu, only go through here once
|
// If skip_main_menu, only go through here once
|
||||||
if (skip_main_menu && !first_loop) {
|
if (skip_main_menu && !first_loop) {
|
||||||
kill = true;
|
kill = true;
|
||||||
@ -1687,13 +1644,11 @@ int main(int argc, char *argv[])
|
|||||||
//TODO find within worldspecs and set config
|
//TODO find within worldspecs and set config
|
||||||
}
|
}
|
||||||
|
|
||||||
if(skip_main_menu == false)
|
if (skip_main_menu == false) {
|
||||||
{
|
|
||||||
video::IVideoDriver* driver = device->getVideoDriver();
|
video::IVideoDriver* driver = device->getVideoDriver();
|
||||||
|
|
||||||
infostream << "Waiting for other menus" << std::endl;
|
infostream << "Waiting for other menus" << std::endl;
|
||||||
while(device->run() && kill == false)
|
while (device->run() && kill == false) {
|
||||||
{
|
|
||||||
if (noMenuActive())
|
if (noMenuActive())
|
||||||
break;
|
break;
|
||||||
driver->beginScene(true, true,
|
driver->beginScene(true, true,
|
||||||
@ -1706,7 +1661,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
infostream << "Waited for other menus" << std::endl;
|
infostream << "Waited for other menus" << std::endl;
|
||||||
|
|
||||||
GUIEngine* temp = new GUIEngine(device, guiroot, &g_menumgr,smgr,&menudata,kill);
|
GUIEngine* temp = new GUIEngine(device, guiroot,
|
||||||
|
&g_menumgr, smgr, &menudata, kill);
|
||||||
|
|
||||||
delete temp;
|
delete temp;
|
||||||
//once finished you'll never end up here
|
//once finished you'll never end up here
|
||||||
@ -1759,9 +1715,7 @@ int main(int argc, char *argv[])
|
|||||||
current_password = "";
|
current_password = "";
|
||||||
current_address = "";
|
current_address = "";
|
||||||
current_port = myrand_range(49152, 65535);
|
current_port = myrand_range(49152, 65535);
|
||||||
}
|
} else if (address != "") {
|
||||||
else if (address != "")
|
|
||||||
{
|
|
||||||
ServerListSpec server;
|
ServerListSpec server;
|
||||||
server["name"] = menudata.servername;
|
server["name"] = menudata.servername;
|
||||||
server["address"] = menudata.address;
|
server["address"] = menudata.address;
|
||||||
@ -1779,8 +1733,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If local game
|
// If local game
|
||||||
if(current_address == "")
|
if (current_address == "") {
|
||||||
{
|
|
||||||
if (menudata.selected_world == -1) {
|
if (menudata.selected_world == -1) {
|
||||||
error_message = wgettext("No world selected and no address "
|
error_message = wgettext("No world selected and no address "
|
||||||
"provided. Nothing to do.");
|
"provided. Nothing to do.");
|
||||||
@ -1819,8 +1772,7 @@ int main(int argc, char *argv[])
|
|||||||
// Break out of menu-game loop to shut down cleanly
|
// Break out of menu-game loop to shut down cleanly
|
||||||
if (device->run() == false || kill == true) {
|
if (device->run() == false || kill == true) {
|
||||||
if (g_settings_path != "") {
|
if (g_settings_path != "") {
|
||||||
g_settings->updateConfigFile(
|
g_settings->updateConfigFile(g_settings_path.c_str());
|
||||||
g_settings_path.c_str());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1864,8 +1816,7 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// If no main menu, show error and exit
|
// If no main menu, show error and exit
|
||||||
if(skip_main_menu)
|
if (skip_main_menu) {
|
||||||
{
|
|
||||||
if (error_message != L"") {
|
if (error_message != L"") {
|
||||||
verbosestream << "error_message = "
|
verbosestream << "error_message = "
|
||||||
<< wide_to_narrow(error_message) << std::endl;
|
<< wide_to_narrow(error_message) << std::endl;
|
||||||
@ -1920,6 +1871,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
debugstreams_deinit();
|
debugstreams_deinit();
|
||||||
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user