summaryrefslogtreecommitdiff
path: root/src/client/clientlauncher.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-15 20:30:30 +0200
committerGitHub <noreply@github.com>2017-08-15 20:30:30 +0200
commit9dd0f952e09471f15f59a98c1ae650d99499cd77 (patch)
treeef600d29b8b753353657ac6740d47208dd0e5d09 /src/client/clientlauncher.cpp
parent64c7a689ad8a596f6b72afe200d9ced20cdd9630 (diff)
downloadminetest-9dd0f952e09471f15f59a98c1ae650d99499cd77.tar.gz
minetest-9dd0f952e09471f15f59a98c1ae650d99499cd77.tar.bz2
minetest-9dd0f952e09471f15f59a98c1ae650d99499cd77.zip
Modernize client code (#6250)
* Various code style fixes * Use range based for loops * Use empty instead of empty objects * Use C++11 default keyword for trivial constructors and destructors * Drop some useless casts * Use emplace_back instead of push_back to improve performance of some vectors push
Diffstat (limited to 'src/client/clientlauncher.cpp')
-rw-r--r--src/client/clientlauncher.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp
index a5c1784aa..644adbbf9 100644
--- a/src/client/clientlauncher.cpp
+++ b/src/client/clientlauncher.cpp
@@ -132,8 +132,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
g_menuclouds->setHeight(100.0f);
g_menuclouds->update(v3f(0, 0, 0), video::SColor(255, 200, 200, 255));
scene::ICameraSceneNode* camera;
- camera = g_menucloudsmgr->addCameraSceneNode(0,
- v3f(0, 0, 0), v3f(0, 60, 100));
+ camera = g_menucloudsmgr->addCameraSceneNode(NULL, v3f(0, 0, 0), v3f(0, 60, 100));
camera->setFarValue(10000);
/*
@@ -192,13 +191,13 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
if (!game_has_run) {
if (skip_main_menu)
break;
- else
- continue;
+
+ continue;
}
// Break out of menu-game loop to shut down cleanly
if (!RenderingEngine::get_raw_device()->run() || *kill) {
- if (g_settings_path != "")
+ if (!g_settings_path.empty())
g_settings->updateConfigFile(g_settings_path.c_str());
break;
}
@@ -285,7 +284,7 @@ void ClientLauncher::init_args(GameParams &game_params, const Settings &cmd_args
* supplied on the command line
*/
address = g_settings->get("address");
- if (game_params.world_path != "" && !skip_main_menu)
+ if (!game_params.world_path.empty() && !skip_main_menu)
address = "";
else if (cmd_args.exists("address"))
address = cmd_args.get("address");
@@ -355,11 +354,11 @@ bool ClientLauncher::launch_game(std::string &error_message,
menudata.password = cmd_args.get("password");
// If a world was commanded, append and select it
- if (game_params.world_path != "") {
+ if (!game_params.world_path.empty()) {
worldspec.gameid = getWorldGameId(game_params.world_path, true);
worldspec.name = _("[--world parameter]");
- if (worldspec.gameid == "") { // Create new
+ if (worldspec.gameid.empty()) { // Create new
worldspec.gameid = g_settings->get("default_game");
worldspec.name += " [new]";
}
@@ -400,7 +399,7 @@ bool ClientLauncher::launch_game(std::string &error_message,
return false;
}
- if (menudata.name == "" && !simple_singleplayer_mode) {
+ if (menudata.name.empty() && !simple_singleplayer_mode) {
error_message = gettext("Please choose a name!");
errorstream << error_message << std::endl;
return false;
@@ -416,14 +415,14 @@ bool ClientLauncher::launch_game(std::string &error_message,
// If using simple singleplayer mode, override
if (simple_singleplayer_mode) {
- assert(skip_main_menu == false);
+ assert(!skip_main_menu);
current_playername = "singleplayer";
current_password = "";
current_address = "";
current_port = myrand_range(49152, 65535);
} else {
g_settings->set("name", playername);
- if (address != "") {
+ if (!address.empty()) {
ServerListSpec server;
server["name"] = menudata.servername;
server["address"] = menudata.address;
@@ -436,8 +435,8 @@ bool ClientLauncher::launch_game(std::string &error_message,
infostream << "Selected world: " << worldspec.name
<< " [" << worldspec.path << "]" << std::endl;
- if (current_address == "") { // If local game
- if (worldspec.path == "") {
+ if (current_address.empty()) { // If local game
+ if (worldspec.path.empty()) {
error_message = gettext("No world selected and no address "
"provided. Nothing to do.");
errorstream << error_message << std::endl;
@@ -488,7 +487,7 @@ void ClientLauncher::main_menu(MainMenuData *menudata)
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
infostream << "Waiting for other menus" << std::endl;
- while (RenderingEngine::get_raw_device()->run() && *kill == false) {
+ while (RenderingEngine::get_raw_device()->run() && !*kill) {
if (!isMenuActive())
break;
driver->beginScene(true, true, video::SColor(255, 128, 128, 128));