#include "network/networkexceptions.h"
#if USE_SOUND
-#include "sound_openal.h"
+ #include "sound_openal.h"
#endif
#ifdef __ANDROID__
-#include "porting.h"
+ #include "porting.h"
#endif
/* mainmenumanager.h
#endif
}
+
bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
{
/* This function is called when a client must be started.
* - Singleplayer (address but map provided)
* - Join server (no map but address provided)
* - Local server (for main menu only)
- */
+ */
init_args(start_data, cmd_args);
This changes the minimum allowed number of vertices in a VBO.
Default is 500.
*/
- // driver->setMinHardwareBufferVertexCount(50);
+ //driver->setMinHardwareBufferVertexCount(50);
// Create game callback for menus
g_gamecallback = new MainGameCallback();
init_input();
- RenderingEngine::get_scene_manager()->getParameters()->setAttribute(
- scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
+ RenderingEngine::get_scene_manager()->getParameters()->
+ setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
guienv = RenderingEngine::get_gui_env();
skin = RenderingEngine::get_gui_env()->getSkin();
g_fontengine = new FontEngine(g_settings, guienv);
FATAL_ERROR_IF(g_fontengine == NULL, "Font engine creation failed.");
-#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || \
- IRRLICHT_VERSION_MAJOR >= 2
+#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
// Irrlicht 1.8 input colours
skin->setColor(gui::EGDC_EDITABLE, video::SColor(255, 128, 128, 128));
skin->setColor(gui::EGDC_FOCUSED_EDITABLE, video::SColor(255, 96, 134, 49));
// Create the menu clouds
if (!g_menucloudsmgr)
- g_menucloudsmgr = RenderingEngine::get_scene_manager()
- ->createNewSceneManager();
+ g_menucloudsmgr = RenderingEngine::get_scene_manager()->createNewSceneManager();
if (!g_menuclouds)
g_menuclouds = new Clouds(g_menucloudsmgr, -1, rand());
g_menuclouds->setHeight(100.0f);
g_menuclouds->update(v3f(0, 0, 0), video::SColor(255, 240, 240, 255));
- scene::ICameraSceneNode *camera;
+ scene::ICameraSceneNode* camera;
camera = g_menucloudsmgr->addCameraSceneNode(NULL, v3f(0, 0, 0), v3f(0, 60, 100));
camera->setFarValue(10000);
bool retval = true;
bool *kill = porting::signal_handler_killstatus();
- while (RenderingEngine::run() && !*kill && !g_gamecallback->shutdown_requested) {
+ while (RenderingEngine::run() && !*kill &&
+ !g_gamecallback->shutdown_requested) {
// Set the window caption
const wchar_t *text = wgettext("Main Menu");
- RenderingEngine::get_raw_device()->setWindowCaption(
- (utf8_to_wide(PROJECT_NAME_C) + L" " +
- utf8_to_wide(g_version_hash) + L" [" +
- text + L"]")
- .c_str());
+ RenderingEngine::get_raw_device()->
+ setWindowCaption((utf8_to_wide(PROJECT_NAME_C) +
+ L" " + utf8_to_wide(g_version_hash) +
+ L" [" + text + L"]").c_str());
delete[] text;
- try { // This is used for catching disconnects
+ try { // This is used for catching disconnects
RenderingEngine::get_gui_env()->clear();
custom gui elements directly on the screen.
Otherwise they won't be automatically drawn.
*/
- guiroot = RenderingEngine::get_gui_env()->addStaticText(
- L"", core::rect<s32>(0, 0, 10000, 10000));
+ guiroot = RenderingEngine::get_gui_env()->addStaticText(L"",
+ core::rect<s32>(0, 0, 10000, 10000));
- bool game_has_run = launch_game(error_message,
- reconnect_requested, start_data, cmd_args);
+ bool game_has_run = launch_game(error_message, reconnect_requested,
+ start_data, cmd_args);
// Reset the reconnect_requested flag
reconnect_requested = false;
// Break out of menu-game loop to shut down cleanly
if (!RenderingEngine::get_raw_device()->run() || *kill) {
if (!g_settings_path.empty())
- g_settings->updateConfigFile(
- g_settings_path.c_str());
+ g_settings->updateConfigFile(g_settings_path.c_str());
break;
}
RenderingEngine::get_video_driver()->setTextureCreationFlag(
- video::ETCF_CREATE_MIP_MAPS,
- g_settings->getBool("mip_map"));
+ video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map"));
#ifdef HAVE_TOUCHSCREENGUI
- receiver->m_touchscreengui = new TouchScreenGUI(
- RenderingEngine::get_raw_device(), receiver);
+ receiver->m_touchscreengui = new TouchScreenGUI(RenderingEngine::get_raw_device(), receiver);
g_touchscreengui = receiver->m_touchscreengui;
#endif
- the_game(kill, input, start_data, error_message, chat_backend,
- &reconnect_requested);
+ the_game(
+ kill,
+ input,
+ start_data,
+ error_message,
+ chat_backend,
+ &reconnect_requested
+ );
RenderingEngine::get_scene_manager()->clear();
#ifdef HAVE_TOUCHSCREENGUI
receiver->m_touchscreengui = NULL;
#endif
- } // try
+ } //try
catch (con::PeerNotFoundException &e) {
error_message = gettext("Connection error (timed out?)");
errorstream << error_message << std::endl;
// If no main menu, show error and exit
if (skip_main_menu) {
if (!error_message.empty()) {
- verbosestream << "error_message = " << error_message
- << std::endl;
+ verbosestream << "error_message = "
+ << error_message << std::endl;
retval = false;
}
break;
// Join a remote server
start_data.address = cmd_args.get("address");
start_data.world_path.clear();
+ start_data.name = g_settings->get("name");
}
if (!start_data.world_path.empty()) {
// Start a singleplayer instance
start_data.address = "";
}
- start_data.name = g_settings->get("name");
if (cmd_args.exists("name"))
start_data.name = cmd_args.get("name");
list_video_modes = cmd_args.getFlag("videomodes");
- random_input = g_settings->getBool("random_input") ||
- cmd_args.getFlag("random-input");
+ random_input = g_settings->getBool("random_input")
+ || cmd_args.getFlag("random-input");
}
bool ClientLauncher::init_engine()
}
input->joystick.onJoystickConnect(joystick_infos);
} else {
- errorstream << "Could not activate joystick support."
- << std::endl;
+ errorstream << "Could not activate joystick support." << std::endl;
}
}
}
-bool ClientLauncher::launch_game(std::string &error_message, bool reconnect_requested,
- GameStartData &start_data, const Settings &cmd_args)
+bool ClientLauncher::launch_game(std::string &error_message,
+ bool reconnect_requested, GameStartData &start_data,
+ const Settings &cmd_args)
{
// Prepare and check the start data to launch a game
std::string error_message_lua = error_message;
getline(passfile, start_data.password);
} else {
error_message = gettext("Provided password file "
- "failed to open: ") +
- cmd_args.get("password-file");
+ "failed to open: ")
+ + cmd_args.get("password-file");
errorstream << error_message << std::endl;
return false;
}
spec.gameid = getWorldGameId(spec.path, true);
spec.name = _("[--world parameter]");
- if (spec.gameid.empty()) { // Create new
+ if (spec.gameid.empty()) { // Create new
spec.gameid = g_settings->get("default_game");
spec.name += " [new]";
}
/* Show the GUI menu
*/
std::string server_name, server_description;
- start_data.local_server = false;
if (!skip_main_menu) {
// Initialize menu data
// TODO: Re-use existing structs (GameStartData)
MainMenuData menudata;
- menudata.address = start_data.address;
- menudata.name = start_data.name;
- menudata.password = start_data.password;
- menudata.port = itos(start_data.socket_port);
- menudata.script_data.errormessage = error_message_lua;
+ menudata.address = start_data.address;
+ menudata.name = start_data.name;
+ menudata.password = start_data.password;
+ menudata.port = itos(start_data.socket_port);
+ menudata.script_data.errormessage = error_message_lua;
menudata.script_data.reconnect_requested = reconnect_requested;
main_menu(&menudata);
return false;
if (!menudata.script_data.errormessage.empty()) {
- /* The calling function will pass this back into this function
- * upon the next iteration (if any) causing it to be displayed by
- * the GUI
+ /* The calling function will pass this back into this function upon the
+ * next iteration (if any) causing it to be displayed by the GUI
*/
error_message = menudata.script_data.errormessage;
return false;
server_description = menudata.serverdescription;
start_data.local_server = !menudata.simple_singleplayer_mode &&
- start_data.address.empty();
+ start_data.address.empty();
+ } else {
+ start_data.local_server = !start_data.world_path.empty() &&
+ start_data.address.empty() && !start_data.name.empty();
}
if (!RenderingEngine::run())
g_settings->set("name", start_data.name);
if (!start_data.address.empty()) {
ServerListSpec server;
- server["name"] = server_name;
- server["address"] = start_data.address;
- server["port"] = itos(start_data.socket_port);
+ server["name"] = server_name;
+ server["address"] = start_data.address;
+ server["port"] = itos(start_data.socket_port);
server["description"] = server_description;
ServerList::insert(server);
}
}
auto &worldspec = start_data.world_spec;
- infostream << "Selected world: " << worldspec.name << " [" << worldspec.path
- << "]" << std::endl;
+ infostream << "Selected world: " << worldspec.name
+ << " [" << worldspec.path << "]" << std::endl;
if (start_data.address.empty()) {
// For singleplayer and local server
if (worldspec.path.empty()) {
error_message = gettext("No world selected and no address "
- "provided. Nothing to do.");
+ "provided. Nothing to do.");
errorstream << error_message << std::endl;
return false;
}
if (!fs::PathExists(worldspec.path)) {
- error_message = gettext("Provided world path doesn't exist: ") +
- worldspec.path;
+ error_message = gettext("Provided world path doesn't exist: ")
+ + worldspec.path;
errorstream << error_message << std::endl;
return false;
}
// Load gamespec for required game
start_data.game_spec = findWorldSubgame(worldspec.path);
if (!start_data.game_spec.isValid()) {
- error_message = gettext("Could not find or load game \"") +
- worldspec.gameid + "\"";
+ error_message = gettext("Could not find or load game \"")
+ + worldspec.gameid + "\"";
errorstream << error_message << std::endl;
return false;
}
for (u32 i = 0; i < ii; i++) {
tempstring2 += "asd";
}
- for (u32 i = 0; i < ii + 1; i++) {
+ for (u32 i = 0; i < ii+1; i++) {
tempstring += "asd";
if (tempstring == tempstring2)
break;
}
infostream << "All of the following tests should take around 100ms each."
- << std::endl;
+ << std::endl;
{
TimeTaker timer("Testing floating-point conversion speed");
const s16 ii = 300;
for (s16 y = 0; y < ii; y++) {
for (s16 x = 0; x < ii; x++) {
- map1[v2s16(x, y)] = tempf;
+ map1[v2s16(x, y)] = tempf;
tempf += 1;
}
}
}
}
// Do at least 10ms
- while (timer.getTimerTime() < 10);
+ while(timer.getTimerTime() < 10);
u32 dtime = timer.stop();
u32 per_ms = n / dtime;