Header file tweaking; mainly for speed

nephele-craftmethods
Perttu Ahola 11 years ago
parent b60b58b627
commit 9e46cbf7ea
  1. 2
      src/CMakeLists.txt
  2. 14
      src/camera.cpp
  3. 3
      src/camera.h
  4. 14
      src/client.cpp
  5. 21
      src/common_irrlicht.h
  6. 9
      src/content_mapblock.cpp
  7. 21
      src/content_mapnode.cpp
  8. 146
      src/defaultsettings.cpp
  9. 28
      src/defaultsettings.h
  10. 9
      src/environment.cpp
  11. 50
      src/game.cpp
  12. 5
      src/guiInventoryMenu.cpp
  13. 34
      src/guiKeyChangeMenu.cpp
  14. 6
      src/guiMainMenu.cpp
  15. 5
      src/guiMessageMenu.cpp
  16. 5
      src/guiPasswordChange.cpp
  17. 5
      src/guiPauseMenu.cpp
  18. 5
      src/guiTextInputMenu.cpp
  19. 3
      src/keycode.cpp
  20. 72
      src/main.cpp
  21. 108
      src/main.h
  22. 124
      src/mainmenumanager.h
  23. 18
      src/map.cpp
  24. 7
      src/mapblock_mesh.cpp
  25. 39
      src/mapblockobject.h
  26. 12
      src/mapnode.cpp
  27. 69
      src/mapnode.h
  28. 13
      src/player.cpp
  29. 115
      src/server.cpp
  30. 7
      src/server.h
  31. 3
      src/servercommand.cpp
  32. 26
      src/servermain.cpp
  33. 583
      src/settings.h
  34. 1
      src/test.cpp
  35. 6
      src/tile.cpp
  36. 2
      src/utility.cpp
  37. 554
      src/utility.h

@ -95,7 +95,6 @@ set(common_SRCS
content_inventory.cpp
content_nodemeta.cpp
content_craft.cpp
content_mapblock.cpp
content_mapnode.cpp
auth.cpp
collision.cpp
@ -138,6 +137,7 @@ endif()
# Client sources
set(minetest_SRCS
${common_SRCS}
content_mapblock.cpp
content_cao.cpp
mapblock_mesh.cpp
farmesh.cpp

@ -25,6 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "player.h"
#include "tile.h"
#include <cmath>
#include <SAnimatedMesh.h>
#include "settings.h"
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
m_smgr(smgr),
@ -299,8 +301,8 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
v3f speed = player->getSpeed();
if ((hypot(speed.X, speed.Z) > BS) &&
(player->touching_ground) &&
(g_settings.getBool("view_bobbing") == true) &&
(g_settings.getBool("free_move") == false))
(g_settings->getBool("view_bobbing") == true) &&
(g_settings->getBool("free_move") == false))
{
// Start animation
m_view_bobbing_state = 1;
@ -427,18 +429,18 @@ void Camera::updateViewingRange(f32 frametime_in)
void Camera::updateSettings()
{
m_viewing_range_min = g_settings.getS16("viewing_range_nodes_min");
m_viewing_range_min = g_settings->getS16("viewing_range_nodes_min");
m_viewing_range_min = MYMAX(5.0, m_viewing_range_min);
m_viewing_range_max = g_settings.getS16("viewing_range_nodes_max");
m_viewing_range_max = g_settings->getS16("viewing_range_nodes_max");
m_viewing_range_max = MYMAX(m_viewing_range_min, m_viewing_range_max);
f32 fov_degrees = g_settings.getFloat("fov");
f32 fov_degrees = g_settings->getFloat("fov");
fov_degrees = MYMAX(fov_degrees, 10.0);
fov_degrees = MYMIN(fov_degrees, 170.0);
m_fov_y = fov_degrees * PI / 180.0;
f32 wanted_fps = g_settings.getFloat("wanted_fps");
f32 wanted_fps = g_settings->getFloat("wanted_fps");
wanted_fps = MYMAX(wanted_fps, 1.0);
m_wanted_frametime = 1.0 / wanted_fps;
}

@ -24,6 +24,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "inventory.h"
#include "tile.h"
#include "utility.h"
#include <ICameraSceneNode.h>
#include <IMeshCache.h>
#include <IAnimatedMesh.h>
class LocalPlayer;
class MapDrawControl;

@ -28,6 +28,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapsector.h"
#include "mapblock_mesh.h"
#include "mapblock.h"
#include "settings.h"
#include "profiler.h"
/*
QueuedMeshUpdate
@ -151,7 +153,7 @@ void * MeshUpdateThread::Thread()
continue;
}
ScopeProfiler sp(&g_profiler, "mesh make");
ScopeProfiler sp(g_profiler, "mesh make");
scene::SMesh *mesh_new = NULL;
mesh_new = makeMapBlockMesh(q->data);
@ -327,7 +329,7 @@ void Client::step(float dtime)
core::list<v3s16> deleted_blocks;
float delete_unused_sectors_timeout =
g_settings.getFloat("client_delete_unused_sectors_timeout");
g_settings->getFloat("client_delete_unused_sectors_timeout");
// Delete sector blocks
/*u32 num = m_env.getMap().unloadUnusedData
@ -449,10 +451,10 @@ void Client::step(float dtime)
const float map_timer_and_unload_dtime = 5.25;
if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime))
{
ScopeProfiler sp(&g_profiler, "Client: map timer and unload");
ScopeProfiler sp(g_profiler, "Client: map timer and unload");
core::list<v3s16> deleted_blocks;
m_env.getMap().timerUpdate(map_timer_and_unload_dtime,
g_settings.getFloat("client_unload_unused_data_timeout"),
g_settings->getFloat("client_unload_unused_data_timeout"),
&deleted_blocks);
/*if(deleted_blocks.size() > 0)
@ -1403,7 +1405,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
}
else if(command == TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD)
{
//if(g_settings.getBool("enable_experimental"))
//if(g_settings->getBool("enable_experimental"))
{
/*
u16 command
@ -1462,7 +1464,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
}
else if(command == TOCLIENT_ACTIVE_OBJECT_MESSAGES)
{
//if(g_settings.getBool("enable_experimental"))
//if(g_settings->getBool("enable_experimental"))
{
/*
u16 command

@ -23,7 +23,26 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define endSceneX(d){d->draw2DLine(v2s32(0,0),v2s32(1,0),\
video::SColor(255,30,30,30));d->endScene();}
#include <irrlicht.h>
#include <irrTypes.h>
#include <vector2d.h>
#include <vector3d.h>
#include <irrMap.h>
#include <irrList.h>
#include <irrArray.h>
#include <aabbox3d.h>
#ifndef SERVER
#include <SColor.h>
#include <IMesh.h>
#include <IImage.h>
#include <IrrlichtDevice.h>
#include <IMeshSceneNode.h>
#include <SMesh.h>
#include <ISceneManager.h>
#include <IMeshBuffer.h>
#include <SMeshBuffer.h>
#include <IGUIElement.h>
#include <IGUIEnvironment.h>
#endif
using namespace irr;
typedef core::vector3df v3f;
typedef core::vector3d<s16> v3s16;

@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "main.h" // For g_settings and g_texturesource
#include "mineral.h"
#include "mapblock_mesh.h" // For MapBlock_LightColor()
#include "settings.h"
#ifndef SERVER
// Create a cuboid.
@ -128,10 +129,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
/*
Some settings
*/
bool new_style_water = g_settings.getBool("new_style_water");
bool new_style_leaves = g_settings.getBool("new_style_leaves");
//bool smooth_lighting = g_settings.getBool("smooth_lighting");
bool invisible_stone = g_settings.getBool("invisible_stone");
bool new_style_water = g_settings->getBool("new_style_water");
bool new_style_leaves = g_settings->getBool("new_style_leaves");
//bool smooth_lighting = g_settings->getBool("smooth_lighting");
bool invisible_stone = g_settings->getBool("invisible_stone");
float node_liquid_level = 1.0;
if(new_style_water)

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_mapnode.h"
#include "mapnode.h"
#include "content_nodemeta.h"
#include "settings.h"
#define WATER_ALPHA 160
@ -103,9 +104,9 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version)
void content_mapnode_init()
{
// Read some settings
bool new_style_water = g_settings.getBool("new_style_water");
bool new_style_leaves = g_settings.getBool("new_style_leaves");
bool invisible_stone = g_settings.getBool("invisible_stone");
bool new_style_water = g_settings->getBool("new_style_water");
bool new_style_leaves = g_settings->getBool("new_style_leaves");
bool invisible_stone = g_settings->getBool("invisible_stone");
content_t i;
ContentFeatures *f = NULL;
@ -390,6 +391,7 @@ void content_mapnode_init()
f->liquid_alternative_flowing = CONTENT_WATER;
f->liquid_alternative_source = CONTENT_WATERSOURCE;
f->liquid_viscosity = WATER_VISC;
#ifndef SERVER
f->vertex_alpha = WATER_ALPHA;
f->post_effect_color = video::SColor(64, 100, 100, 200);
if(f->special_material == NULL && g_texturesource)
@ -406,6 +408,7 @@ void content_mapnode_init()
f->special_material->setTexture(0, pa_water1->atlas);
f->special_atlas = pa_water1;
}
#endif
i = CONTENT_WATERSOURCE;
f = &content_features(i);
@ -418,7 +421,7 @@ void content_mapnode_init()
else // old style
{
f->solidness = 1;
#ifndef SERVER
TileSpec t;
if(g_texturesource)
t.texture = g_texturesource->getTexture("water.png");
@ -427,6 +430,7 @@ void content_mapnode_init()
t.material_type = MATERIAL_ALPHA_VERTEX;
t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
f->setAllTiles(t);
#endif
}
f->param_type = CPT_LIGHT;
f->light_propagates = true;
@ -439,6 +443,7 @@ void content_mapnode_init()
f->liquid_alternative_flowing = CONTENT_WATER;
f->liquid_alternative_source = CONTENT_WATERSOURCE;
f->liquid_viscosity = WATER_VISC;
#ifndef SERVER
f->vertex_alpha = WATER_ALPHA;
f->post_effect_color = video::SColor(64, 100, 100, 200);
if(f->special_material == NULL && g_texturesource)
@ -455,6 +460,7 @@ void content_mapnode_init()
f->special_material->setTexture(0, pa_water1->atlas);
f->special_atlas = pa_water1;
}
#endif
i = CONTENT_LAVA;
f = &content_features(i);
@ -473,6 +479,7 @@ void content_mapnode_init()
f->liquid_alternative_source = CONTENT_LAVASOURCE;
f->liquid_viscosity = LAVA_VISC;
f->damage_per_second = 4*2;
#ifndef SERVER
f->post_effect_color = video::SColor(192, 255, 64, 0);
if(f->special_material == NULL && g_texturesource)
{
@ -489,6 +496,7 @@ void content_mapnode_init()
f->special_material->setTexture(0, pa_lava1->atlas);
f->special_atlas = pa_lava1;
}
#endif
i = CONTENT_LAVASOURCE;
f = &content_features(i);
@ -500,7 +508,7 @@ void content_mapnode_init()
else // old style
{
f->solidness = 2;
#ifndef SERVER
TileSpec t;
if(g_texturesource)
t.texture = g_texturesource->getTexture("lava.png");
@ -509,6 +517,7 @@ void content_mapnode_init()
//t.material_type = MATERIAL_ALPHA_VERTEX;
//t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
f->setAllTiles(t);
#endif
}
f->param_type = CPT_LIGHT;
f->light_propagates = false;
@ -523,6 +532,7 @@ void content_mapnode_init()
f->liquid_alternative_source = CONTENT_LAVASOURCE;
f->liquid_viscosity = LAVA_VISC;
f->damage_per_second = 4*2;
#ifndef SERVER
f->post_effect_color = video::SColor(192, 255, 64, 0);
if(f->special_material == NULL && g_texturesource)
{
@ -539,6 +549,7 @@ void content_mapnode_init()
f->special_material->setTexture(0, pa_lava1->atlas);
f->special_atlas = pa_lava1;
}
#endif
i = CONTENT_TORCH;
f = &content_features(i);

@ -17,92 +17,90 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "utility.h"
#include "settings.h"
extern Settings g_settings;
void set_default_settings()
void set_default_settings(Settings *settings)
{
// Client and server
g_settings.setDefault("port", "");
g_settings.setDefault("name", "");
g_settings.setDefault("footprints", "false");
settings->setDefault("port", "");
settings->setDefault("name", "");
settings->setDefault("footprints", "false");
// Client stuff
g_settings.setDefault("keymap_forward", "KEY_KEY_W");
g_settings.setDefault("keymap_backward", "KEY_KEY_S");
g_settings.setDefault("keymap_left", "KEY_KEY_A");
g_settings.setDefault("keymap_right", "KEY_KEY_D");
g_settings.setDefault("keymap_jump", "KEY_SPACE");
g_settings.setDefault("keymap_sneak", "KEY_LSHIFT");
g_settings.setDefault("keymap_inventory", "KEY_KEY_I");
g_settings.setDefault("keymap_chat", "KEY_KEY_T");
g_settings.setDefault("keymap_cmd", "/");
g_settings.setDefault("keymap_rangeselect", "KEY_KEY_R");
g_settings.setDefault("keymap_freemove", "KEY_KEY_K");
g_settings.setDefault("keymap_fastmove", "KEY_KEY_J");
g_settings.setDefault("keymap_frametime_graph", "KEY_F1");
g_settings.setDefault("keymap_screenshot", "KEY_F12");
settings->setDefault("keymap_forward", "KEY_KEY_W");
settings->setDefault("keymap_backward", "KEY_KEY_S");
settings->setDefault("keymap_left", "KEY_KEY_A");
settings->setDefault("keymap_right", "KEY_KEY_D");
settings->setDefault("keymap_jump", "KEY_SPACE");
settings->setDefault("keymap_sneak", "KEY_LSHIFT");
settings->setDefault("keymap_inventory", "KEY_KEY_I");
settings->setDefault("keymap_chat", "KEY_KEY_T");
settings->setDefault("keymap_cmd", "/");
settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
settings->setDefault("keymap_freemove", "KEY_KEY_K");
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
settings->setDefault("keymap_frametime_graph", "KEY_F1");
settings->setDefault("keymap_screenshot", "KEY_F12");
// Some (temporary) keys for debugging
g_settings.setDefault("keymap_special1", "KEY_KEY_E");
g_settings.setDefault("keymap_print_debug_stacks", "KEY_KEY_P");
settings->setDefault("keymap_special1", "KEY_KEY_E");
settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P");
g_settings.setDefault("wanted_fps", "30");
g_settings.setDefault("fps_max", "60");
g_settings.setDefault("viewing_range_nodes_max", "300");
g_settings.setDefault("viewing_range_nodes_min", "15");
g_settings.setDefault("screenW", "800");
g_settings.setDefault("screenH", "600");
g_settings.setDefault("address", "");
g_settings.setDefault("random_input", "false");
g_settings.setDefault("client_unload_unused_data_timeout", "600");
g_settings.setDefault("enable_fog", "true");
g_settings.setDefault("fov", "72");
g_settings.setDefault("view_bobbing", "true");
g_settings.setDefault("new_style_water", "false");
g_settings.setDefault("new_style_leaves", "true");
g_settings.setDefault("smooth_lighting", "true");
g_settings.setDefault("frametime_graph", "false");
g_settings.setDefault("enable_texture_atlas", "true");
g_settings.setDefault("texture_path", "");
g_settings.setDefault("video_driver", "opengl");
g_settings.setDefault("free_move", "false");
g_settings.setDefault("continuous_forward", "false");
g_settings.setDefault("fast_move", "false");
g_settings.setDefault("invert_mouse", "false");
g_settings.setDefault("enable_farmesh", "false");
g_settings.setDefault("enable_clouds", "true");
g_settings.setDefault("invisible_stone", "false");
g_settings.setDefault("screenshot_path", ".");
settings->setDefault("wanted_fps", "30");
settings->setDefault("fps_max", "60");
settings->setDefault("viewing_range_nodes_max", "300");
settings->setDefault("viewing_range_nodes_min", "15");
settings->setDefault("screenW", "800");
settings->setDefault("screenH", "600");
settings->setDefault("address", "");
settings->setDefault("random_input", "false");
settings->setDefault("client_unload_unused_data_timeout", "600");
settings->setDefault("enable_fog", "true");
settings->setDefault("fov", "72");
settings->setDefault("view_bobbing", "true");
settings->setDefault("new_style_water", "false");
settings->setDefault("new_style_leaves", "true");
settings->setDefault("smooth_lighting", "true");
settings->setDefault("frametime_graph", "false");
settings->setDefault("enable_texture_atlas", "true");
settings->setDefault("texture_path", "");
settings->setDefault("video_driver", "opengl");
settings->setDefault("free_move", "false");
settings->setDefault("continuous_forward", "false");
settings->setDefault("fast_move", "false");
settings->setDefault("invert_mouse", "false");
settings->setDefault("enable_farmesh", "false");
settings->setDefault("enable_clouds", "true");
settings->setDefault("invisible_stone", "false");
settings->setDefault("screenshot_path", ".");
// Server stuff
g_settings.setDefault("motd", "");
g_settings.setDefault("max_users", "20");
g_settings.setDefault("enable_experimental", "false");
g_settings.setDefault("creative_mode", "false");
g_settings.setDefault("enable_damage", "true");
g_settings.setDefault("give_initial_stuff", "false");
g_settings.setDefault("default_password", "");
g_settings.setDefault("default_privs", "build, shout");
g_settings.setDefault("profiler_print_interval", "0");
g_settings.setDefault("enable_mapgen_debug_info", "false");
g_settings.setDefault("fixed_map_seed", "");
settings->setDefault("motd", "");
settings->setDefault("max_users", "20");
settings->setDefault("enable_experimental", "false");
settings->setDefault("creative_mode", "false");
settings->setDefault("enable_damage", "true");
settings->setDefault("give_initial_stuff", "false");
settings->setDefault("default_password", "");
settings->setDefault("default_privs", "build, shout");
settings->setDefault("profiler_print_interval", "0");
settings->setDefault("enable_mapgen_debug_info", "false");
settings->setDefault("fixed_map_seed", "");
g_settings.setDefault("objectdata_interval", "0.2");
g_settings.setDefault("active_object_range", "2");
//g_settings.setDefault("max_simultaneous_block_sends_per_client", "1");
settings->setDefault("objectdata_interval", "0.2");
settings->setDefault("active_object_range", "2");
//settings->setDefault("max_simultaneous_block_sends_per_client", "1");
// This causes frametime jitter on client side, or does it?
g_settings.setDefault("max_simultaneous_block_sends_per_client", "2");
g_settings.setDefault("max_simultaneous_block_sends_server_total", "8");
g_settings.setDefault("max_block_send_distance", "8");
g_settings.setDefault("max_block_generate_distance", "8");
g_settings.setDefault("time_send_interval", "20");
g_settings.setDefault("time_speed", "96");
g_settings.setDefault("server_unload_unused_data_timeout", "60");
g_settings.setDefault("server_map_save_interval", "60");
g_settings.setDefault("full_block_send_enable_min_time_from_building", "2.0");
//g_settings.setDefault("dungeon_rarity", "0.025");
settings->setDefault("max_simultaneous_block_sends_per_client", "2");
settings->setDefault("max_simultaneous_block_sends_server_total", "8");
settings->setDefault("max_block_send_distance", "8");
settings->setDefault("max_block_generate_distance", "8");
settings->setDefault("time_send_interval", "20");
settings->setDefault("time_speed", "96");
settings->setDefault("server_unload_unused_data_timeout", "60");
settings->setDefault("server_map_save_interval", "60");
settings->setDefault("full_block_send_enable_min_time_from_building", "2.0");
//settings->setDefault("dungeon_rarity", "0.025");
}

@ -0,0 +1,28 @@
/*
Minetest-c55
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef DEFAULTSETTINGS_HEADER
#define DEFAULTSETTINGS_HEADER
class Settings;
void set_default_settings(Settings *settings);
#endif

@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serverobject.h"
#include "content_sao.h"
#include "mapgen.h"
#include "settings.h"
Environment::Environment():
m_time_of_day(9000)
@ -649,7 +650,7 @@ void ServerEnvironment::step(float dtime)
//TimeTaker timer("ServerEnv step");
// Get some settings
bool footprints = g_settings.getBool("footprints");
bool footprints = g_settings->getBool("footprints");
/*
Increment game time
@ -1013,7 +1014,7 @@ void ServerEnvironment::step(float dtime)
removeRemovedObjects();
}
if(g_settings.getBool("enable_experimental"))
if(g_settings->getBool("enable_experimental"))
{
/*
@ -1541,8 +1542,8 @@ void ClientEnvironment::step(float dtime)
DSTACK(__FUNCTION_NAME);
// Get some settings
bool free_move = g_settings.getBool("free_move");
bool footprints = g_settings.getBool("footprints");
bool free_move = g_settings->getBool("free_move");
bool footprints = g_settings->getBool("footprints");
// Get local player
LocalPlayer *lplayer = getLocalPlayer();

@ -17,8 +17,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "common_irrlicht.h"
#include "game.h"
#include "common_irrlicht.h"
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "client.h"
#include "server.h"
#include "guiPauseMenu.h"
@ -31,6 +36,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "camera.h"
#include "farmesh.h"
#include "mapblock.h"
#include "settings.h"
#include "profiler.h"
#include "mainmenumanager.h"
/*
TODO: Move content-aware stuff to separate file by adding properties
@ -583,7 +591,7 @@ void update_skybox(video::IVideoDriver* driver,
}
/*// Disable skybox if FarMesh is enabled
if(g_settings.getBool("enable_farmesh"))
if(g_settings->getBool("enable_farmesh"))
return;*/
if(brightness >= 0.5)
@ -825,7 +833,7 @@ void the_game(
float cloud_height = BS*100;
Clouds *clouds = NULL;
if(g_settings.getBool("enable_clouds"))
if(g_settings->getBool("enable_clouds"))
{
clouds = new Clouds(smgr->getRootSceneNode(), smgr, -1,
cloud_height, time(0));
@ -836,7 +844,7 @@ void the_game(
*/
FarMesh *farmesh = NULL;
if(g_settings.getBool("enable_farmesh"))
if(g_settings->getBool("enable_farmesh"))
{
farmesh = new FarMesh(smgr->getRootSceneNode(), smgr, -1, client.getMapSeed(), &client);
}
@ -919,7 +927,7 @@ void the_game(
float damage_flash_timer = 0;
s16 farmesh_range = 20*MAP_BLOCKSIZE;
bool invert_mouse = g_settings.getBool("invert_mouse");
bool invert_mouse = g_settings->getBool("invert_mouse");
/*
Main loop
@ -1020,7 +1028,7 @@ void the_game(
*/
{
float fps_max = g_settings.getFloat("fps_max");
float fps_max = g_settings->getFloat("fps_max");
u32 frametime_min = 1000./fps_max;
if(busytime_u32 < frametime_min)
@ -1133,14 +1141,14 @@ void the_game(
Profiler
*/
float profiler_print_interval =
g_settings.getFloat("profiler_print_interval");
g_settings->getFloat("profiler_print_interval");
if(profiler_print_interval != 0)
{
if(m_profiler_interval.step(0.030, profiler_print_interval))
{
dstream<<"Profiler:"<<std::endl;
g_profiler.print(dstream);
g_profiler.clear();
g_profiler->print(dstream);
g_profiler->clear();
}
}
@ -1215,40 +1223,40 @@ void the_game(
}
else if(input->wasKeyDown(getKeySetting("keymap_freemove")))
{
if(g_settings.getBool("free_move"))
if(g_settings->getBool("free_move"))
{
g_settings.set("free_move","false");
g_settings->set("free_move","false");
chat_lines.push_back(ChatLine(L"free_move disabled"));
}
else
{
g_settings.set("free_move","true");
g_settings->set("free_move","true");
chat_lines.push_back(ChatLine(L"free_move enabled"));
}
}
else if(input->wasKeyDown(getKeySetting("keymap_fastmove")))
{
if(g_settings.getBool("fast_move"))
if(g_settings->getBool("fast_move"))
{
g_settings.set("fast_move","false");
g_settings->set("fast_move","false");
chat_lines.push_back(ChatLine(L"fast_move disabled"));
}
else
{
g_settings.set("fast_move","true");
g_settings->set("fast_move","true");
chat_lines.push_back(ChatLine(L"fast_move enabled"));
}
}
else if(input->wasKeyDown(getKeySetting("keymap_frametime_graph")))
{
if(g_settings.getBool("frametime_graph"))
if(g_settings->getBool("frametime_graph"))
{
g_settings.set("frametime_graph","false");
g_settings->set("frametime_graph","false");
chat_lines.push_back(ChatLine(L"frametime_graph disabled"));
}
else
{
g_settings.set("frametime_graph","true");
g_settings->set("frametime_graph","true");
chat_lines.push_back(ChatLine(L"frametime_graph enabled"));
}
}
@ -1258,7 +1266,7 @@ void the_game(
if (image) {
irr::c8 filename[256];
snprintf(filename, 256, "%s/screenshot_%u.png",
g_settings.get("screenshot_path").c_str(),
g_settings->get("screenshot_path").c_str(),
device->getTimer()->getRealTime());
if (driver->writeImageToFile(image, filename)) {
std::wstringstream sstr;
@ -1907,7 +1915,7 @@ void the_game(
Fog
*/
if(g_settings.getBool("enable_fog") == true)
if(g_settings->getBool("enable_fog") == true)
{
f32 range;
if(farmesh)
@ -2180,7 +2188,7 @@ void the_game(
/*
Frametime log
*/
if(g_settings.getBool("frametime_graph") == true)
if(g_settings->getBool("frametime_graph") == true)
{
s32 x = 10;
for(core::list<float>::Iterator

@ -22,6 +22,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "constants.h"
#include "keycode.h"
#include "strfnd.h"
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
void drawInventoryItem(video::IVideoDriver *driver,
gui::IGUIFont *font,

@ -24,6 +24,12 @@
#include "serialization.h"
#include "main.h"
#include <string>
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "settings.h"
GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) :
@ -340,20 +346,20 @@ void GUIKeyChangeMenu::drawMenu()
bool GUIKeyChangeMenu::acceptInput()
{
g_settings.set("keymap_forward", key_forward.sym());
g_settings.set("keymap_backward", key_backward.sym());
g_settings.set("keymap_left", key_left.sym());
g_settings.set("keymap_right", key_right.sym());
g_settings.set("keymap_jump", key_jump.sym());
g_settings.set("keymap_sneak", key_sneak.sym());
g_settings.set("keymap_inventory", key_inventory.sym());
g_settings.set("keymap_chat", key_chat.sym());
g_settings.set("keymap_cmd", key_cmd.sym());
g_settings.set("keymap_rangeselect", key_range.sym());
g_settings.set("keymap_freemove", key_fly.sym());
g_settings.set("keymap_fastmove", key_fast.sym());
g_settings.set("keymap_special1", key_use.sym());
g_settings.set("keymap_print_debug_stacks", key_dump.sym());
g_settings->set("keymap_forward", key_forward.sym());
g_settings->set("keymap_backward", key_backward.sym());
g_settings->set("keymap_left", key_left.sym());
g_settings->set("keymap_right", key_right.sym());
g_settings->set("keymap_jump", key_jump.sym());
g_settings->set("keymap_sneak", key_sneak.sym());
g_settings->set("keymap_inventory", key_inventory.sym());
g_settings->set("keymap_chat", key_chat.sym());
g_settings->set("keymap_cmd", key_cmd.sym());
g_settings->set("keymap_rangeselect", key_range.sym());
g_settings->set("keymap_freemove", key_fly.sym());
g_settings->set("keymap_fastmove", key_fast.sym());
g_settings->set("keymap_special1", key_use.sym());
g_settings->set("keymap_print_debug_stacks", key_dump.sym());
clearKeyCache();
return true;
}

@ -22,7 +22,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "debug.h"
#include "serialization.h"
#include <string>
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "gettext.h"

@ -21,6 +21,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "debug.h"
#include "serialization.h"
#include <string>
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "gettext.h"

@ -20,6 +20,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "debug.h"
#include "serialization.h"
#include <string>
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "gettext.h"

@ -23,6 +23,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h"
#include "config.h"
#include "main.h"
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "gettext.h"

@ -21,6 +21,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "debug.h"
#include "serialization.h"
#include <string>
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "gettext.h"

@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "keycode.h"
#include "main.h" // For g_settings
#include "exceptions.h"
#include "settings.h"
class UnknownKeycode : public BaseException
{
@ -334,7 +335,7 @@ KeyPress getKeySetting(const char *settingname)
if(n)
return n->getValue();
g_key_setting_cache.insert(settingname,
g_settings.get(settingname).c_str());
g_settings->get(settingname).c_str());
return g_key_setting_cache.find(settingname)->getValue();
}

@ -411,10 +411,13 @@ Doing currently:
//#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
#include "irrlicht.h" // createDevice
#include "main.h"
#include "mainmenumanager.h"
#include <iostream>
#include <fstream>
#include <locale.h>
#include "main.h"
#include "common_irrlicht.h"
#include "debug.h"
#include "test.h"
@ -431,8 +434,10 @@ Doing currently:
#include "game.h"
#include "keycode.h"
#include "tile.h"
#include "defaultsettings.h"
#include "gettext.h"
#include "settings.h"
#include "profiler.h"
// This makes textures
ITextureSource *g_texturesource = NULL;
@ -441,25 +446,23 @@ ITextureSource *g_texturesource = NULL;
Settings.
These are loaded from the config file.
*/
Settings g_settings;
// This is located in defaultsettings.cpp
extern void set_default_settings();
Settings main_settings;
Settings *g_settings = &main_settings;
// Global profiler
Profiler g_profiler;
Profiler main_profiler;
Profiler *g_profiler = &main_profiler;
/*
Random stuff
*/
/*
GUI Stuff
mainmenumanager.h
*/
gui::IGUIEnvironment* guienv = NULL;
gui::IGUIStaticText *guiroot = NULL;
MainMenuManager g_menumgr;
bool noMenuActive()
@ -468,7 +471,6 @@ bool noMenuActive()
}
// Passed to menus to allow disconnecting and exiting
MainGameCallback *g_gamecallback = NULL;
/*
@ -1190,7 +1192,7 @@ int main(int argc, char *argv[])
*/
// Initialize default settings
set_default_settings();
set_default_settings(g_settings);
// Initialize sockets
sockets_init();
@ -1205,7 +1207,7 @@ int main(int argc, char *argv[])
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)
{
dstream<<"Could not read configuration from \""
@ -1224,7 +1226,7 @@ int main(int argc, char *argv[])
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)
{
configpath = filenames[i];
@ -1275,8 +1277,8 @@ int main(int argc, char *argv[])
u16 port = 30000;
if(cmd_args.exists("port"))
port = cmd_args.getU16("port");
else if(g_settings.exists("port"))
port = g_settings.getU16("port");
else if(g_settings->exists("port"))
port = g_settings->getU16("port");
if(port == 0)
port = 30000;
@ -1284,8 +1286,8 @@ int main(int argc, char *argv[])
std::string map_dir = porting::path_userdata+"/world";
if(cmd_args.exists("map-dir"))
map_dir = cmd_args.get("map-dir");
else if(g_settings.exists("map-dir"))
map_dir = g_settings.get("map-dir");
else if(g_settings->exists("map-dir"))
map_dir = g_settings->get("map-dir");
// Run dedicated server if asked to
if(cmd_args.getFlag("server"))
@ -1319,10 +1321,10 @@ int main(int argc, char *argv[])
}
else
{
address = g_settings.get("address");
address = g_settings->get("address");
}
std::string playername = g_settings.get("name");
std::string playername = g_settings->get("name");
/*
Device initialization
@ -1331,14 +1333,14 @@ int main(int argc, char *argv[])
// Resolution selection
bool fullscreen = false;
u16 screenW = g_settings.getU16("screenW");
u16 screenH = g_settings.getU16("screenH");
u16 screenW = g_settings->getU16("screenW");
u16 screenH = g_settings->getU16("screenH");
// Determine driver
video::E_DRIVER_TYPE driverType;
std::string driverstring = g_settings.get("video_driver");
std::string driverstring = g_settings->get("video_driver");
if(driverstring == "null")
driverType = video::EDT_NULL;
@ -1397,7 +1399,7 @@ int main(int argc, char *argv[])
device->setResizable(true);
bool random_input = g_settings.getBool("random_input")
bool random_input = g_settings->getBool("random_input")
|| cmd_args.getFlag("random-input");
InputHandler *input = NULL;
if(random_input)
@ -1508,10 +1510,10 @@ int main(int argc, char *argv[])
menudata.address = narrow_to_wide(address);
menudata.name = narrow_to_wide(playername);
menudata.port = narrow_to_wide(itos(port));
menudata.fancy_trees = g_settings.getBool("new_style_leaves");
menudata.smooth_lighting = g_settings.getBool("smooth_lighting");
menudata.creative_mode = g_settings.getBool("creative_mode");
menudata.enable_damage = g_settings.getBool("enable_damage");
menudata.fancy_trees = g_settings->getBool("new_style_leaves");
menudata.smooth_lighting = g_settings->getBool("smooth_lighting");
menudata.creative_mode = g_settings->getBool("creative_mode");
menudata.enable_damage = g_settings->getBool("enable_damage");
GUIMainMenu *menu =
new GUIMainMenu(guienv, guiroot, -1,
@ -1580,10 +1582,10 @@ int main(int argc, char *argv[])
int newport = stoi(wide_to_narrow(menudata.port));
if(newport != 0)
port = newport;
g_settings.set("new_style_leaves", itos(menudata.fancy_trees));
g_settings.set("smooth_lighting", itos(menudata.smooth_lighting));
g_settings.set("creative_mode", itos(menudata.creative_mode));
g_settings.set("enable_damage", itos(menudata.enable_damage));
g_settings->set("new_style_leaves", itos(menudata.fancy_trees));
g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
g_settings->set("creative_mode", itos(menudata.creative_mode));
g_settings->set("enable_damage", itos(menudata.enable_damage));
// NOTE: These are now checked server side; no need to do it
// here, so let's not do it here.
@ -1602,12 +1604,12 @@ int main(int argc, char *argv[])
}*/
// Save settings
g_settings.set("name", playername);
g_settings.set("address", address);
g_settings.set("port", itos(port));
g_settings->set("name", playername);
g_settings->set("address", address);
g_settings->set("port", itos(port));
// Update configuration file
if(configpath != "")
g_settings.updateConfigFile(configpath.c_str());
g_settings->updateConfigFile(configpath.c_str());
// Continue to game
break;

@ -21,16 +21,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MAIN_HEADER
// Settings
#include "utility.h"
extern Settings g_settings;
class Settings;
extern Settings *g_settings;
// This makes and maps textures
class ITextureSource;
extern ITextureSource *g_texturesource;
// Global profiler
#include "profiler.h"
extern Profiler g_profiler;
class Profiler;
extern Profiler *g_profiler;
// Debug streams
@ -50,105 +50,5 @@ extern std::ostream *derr_server_ptr;
#define dout_server (*dout_server_ptr)
#define derr_server (*derr_server_ptr)
/*
All kinds of stuff that needs to be exposed from main.cpp
*/
#include "modalMenu.h"
#include "guiPauseMenu.h" //For IGameCallback
extern gui::IGUIEnvironment* guienv;
extern gui::IGUIStaticText *guiroot;
// Handler for the modal menus
class MainMenuManager : public IMenuManager
{
public:
virtual void createdMenu(GUIModalMenu *menu)
{
for(core::list<GUIModalMenu*>::Iterator
i = m_stack.begin();
i != m_stack.end(); i++)
{
assert(*i != menu);
}
if(m_stack.size() != 0)
(*m_stack.getLast())->setVisible(false);
m_stack.push_back(menu