mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
64c7a689ad
commit
9dd0f952e0
9 changed files with 104 additions and 113 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue