Skip to content

Commit

Permalink
C++11 patchset 9: move hardcoded init parameters to class definitions…
Browse files Browse the repository at this point in the history
… (part 1) (#5984)

* C++11 patchset 9: move hardcoded init parameters to class definitions

C++11 introduced the possibility to define the default values directly in class definitions, do it on current code

Also remove some unused attributes

* CollisionInfo::bouncy
* collisionMoveResult::collides_xy
* collisionMoveResult::standing_on_unloaded
* Clouds::speed

* More constructor cleanups + some variables removal

* remove only write guiFormSpecMenu::m_old_tooltip
* move header included inside defintions in genericobject.h
* remove some unused since years exception classes
* remove unused & empty debug_stacks_init
* remove unused & empty content_nodemeta_serialize_legacy
* remove forgotten useless bool (bouncy) in collision.cpp code
  • Loading branch information
nerzhul committed Jun 16, 2017
1 parent 49d6e5f commit 76be103
Show file tree
Hide file tree
Showing 50 changed files with 331 additions and 751 deletions.
9 changes: 3 additions & 6 deletions src/ban.cpp
Expand Up @@ -28,14 +28,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"

BanManager::BanManager(const std::string &banfilepath):
m_banfilepath(banfilepath),
m_modified(false)
m_banfilepath(banfilepath)
{
try{
try {
load();
}
catch(SerializationError &e)
{
} catch(SerializationError &e) {
warningstream<<"BanManager: creating "
<<m_banfilepath<<std::endl;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ban.h
Expand Up @@ -44,9 +44,9 @@ class BanManager

private:
std::mutex m_mutex;
std::string m_banfilepath;
std::string m_banfilepath = "";
StringMap m_ips;
bool m_modified;
bool m_modified = false;
};

#endif
30 changes: 1 addition & 29 deletions src/camera.cpp
Expand Up @@ -41,36 +41,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,

Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
Client *client):
m_playernode(NULL),
m_headnode(NULL),
m_cameranode(NULL),

m_wieldmgr(NULL),
m_wieldnode(NULL),

m_draw_control(draw_control),
m_client(client),

m_camera_position(0,0,0),
m_camera_direction(0,0,0),
m_camera_offset(0,0,0),

m_aspect(1.0),
m_fov_x(1.0),
m_fov_y(1.0),

m_view_bobbing_anim(0),
m_view_bobbing_state(0),
m_view_bobbing_speed(0),
m_view_bobbing_fall(0),

m_digging_anim(0),
m_digging_button(-1),

m_wield_change_timer(0.125),
m_wield_item_next(),

m_camera_mode(CAMERA_MODE_FIRST)
m_client(client)
{
//dstream<<FUNCTION_NAME<<std::endl;

Expand Down
32 changes: 16 additions & 16 deletions src/camera.h
Expand Up @@ -168,12 +168,12 @@ class Camera

private:
// Nodes
scene::ISceneNode* m_playernode;
scene::ISceneNode* m_headnode;
scene::ICameraSceneNode* m_cameranode;
scene::ISceneNode *m_playernode = nullptr;
scene::ISceneNode *m_headnode = nullptr;
scene::ICameraSceneNode *m_cameranode = nullptr;

scene::ISceneManager* m_wieldmgr;
WieldMeshSceneNode* m_wieldnode;
scene::ISceneManager *m_wieldmgr = nullptr;
WieldMeshSceneNode *m_wieldnode = nullptr;

// draw control
MapDrawControl& m_draw_control;
Expand All @@ -189,33 +189,33 @@ class Camera
v3s16 m_camera_offset;

// Field of view and aspect ratio stuff
f32 m_aspect;
f32 m_fov_x;
f32 m_fov_y;
f32 m_aspect = 1.0f;
f32 m_fov_x = 1.0f;
f32 m_fov_y = 1.0f;

// View bobbing animation frame (0 <= m_view_bobbing_anim < 1)
f32 m_view_bobbing_anim;
f32 m_view_bobbing_anim = 0.0f;
// If 0, view bobbing is off (e.g. player is standing).
// If 1, view bobbing is on (player is walking).
// If 2, view bobbing is getting switched off.
s32 m_view_bobbing_state;
s32 m_view_bobbing_state = 0;
// Speed of view bobbing animation
f32 m_view_bobbing_speed;
f32 m_view_bobbing_speed = 0.0f;
// Fall view bobbing
f32 m_view_bobbing_fall;
f32 m_view_bobbing_fall = 0.0f;

// Digging animation frame (0 <= m_digging_anim < 1)
f32 m_digging_anim;
f32 m_digging_anim = 0.0f;
// If -1, no digging animation
// If 0, left-click digging animation
// If 1, right-click digging animation
s32 m_digging_button;
s32 m_digging_button = -1;

// Animation when changing wielded item
f32 m_wield_change_timer;
f32 m_wield_change_timer = 0.125f;
ItemStack m_wield_item_next;

CameraMode m_camera_mode;
CameraMode m_camera_mode = CAMERA_MODE_FIRST;

f32 m_cache_fall_bobbing_amount;
f32 m_cache_view_bobbing_amount;
Expand Down
19 changes: 2 additions & 17 deletions src/chat.cpp
Expand Up @@ -27,13 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/numeric.h"

ChatBuffer::ChatBuffer(u32 scrollback):
m_scrollback(scrollback),
m_unformatted(),
m_cols(0),
m_rows(0),
m_scroll(0),
m_formatted(),
m_empty_formatted_line()
m_scrollback(scrollback)
{
if (m_scrollback == 0)
m_scrollback = 1;
Expand Down Expand Up @@ -383,16 +377,7 @@ s32 ChatBuffer::getBottomScrollPos() const

ChatPrompt::ChatPrompt(const std::wstring &prompt, u32 history_limit):
m_prompt(prompt),
m_line(L""),
m_history(),
m_history_index(0),
m_history_limit(history_limit),
m_cols(0),
m_view(0),
m_cursor(0),
m_cursor_len(0),
m_nick_completion_start(0),
m_nick_completion_end(0)
m_history_limit(history_limit)
{
}

Expand Down
28 changes: 13 additions & 15 deletions src/chat.h
Expand Up @@ -32,21 +32,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct ChatLine
{
// age in seconds
f32 age;
f32 age = 0.0f;
// name of sending player, or empty if sent by server
EnrichedString name;
// message text
EnrichedString text;

ChatLine(const std::wstring &a_name, const std::wstring &a_text):
age(0.0),
name(a_name),
text(a_text)
{
}

ChatLine(const EnrichedString &a_name, const EnrichedString &a_text):
age(0.0),
name(a_name),
text(a_text)
{
Expand Down Expand Up @@ -132,11 +130,11 @@ class ChatBuffer
std::vector<ChatLine> m_unformatted;

// Number of character columns in console
u32 m_cols;
u32 m_cols = 0;
// Number of character rows in console
u32 m_rows;
u32 m_rows = 0;
// Scroll position (console's top line index into m_formatted)
s32 m_scroll;
s32 m_scroll = 0;
// Array of formatted lines
std::vector<ChatFormattedLine> m_formatted;
// Empty formatted line, for error returns
Expand Down Expand Up @@ -225,29 +223,29 @@ class ChatPrompt

private:
// Prompt prefix
std::wstring m_prompt;
std::wstring m_prompt = L"";
// Currently edited line
std::wstring m_line;
std::wstring m_line = L"";
// History buffer
std::vector<std::wstring> m_history;
// History index (0 <= m_history_index <= m_history.size())
u32 m_history_index;
u32 m_history_index = 0;
// Maximum number of history entries
u32 m_history_limit;

// Number of columns excluding columns reserved for the prompt
s32 m_cols;
s32 m_cols = 0;
// Start of visible portion (index into m_line)
s32 m_view;
s32 m_view = 0;
// Cursor (index into m_line)
s32 m_cursor;
s32 m_cursor = 0;
// Cursor length (length of selected portion of line)
s32 m_cursor_len;
s32 m_cursor_len = 0;

// Last nick completion start (index into m_line)
s32 m_nick_completion_start;
s32 m_nick_completion_start = 0;
// Last nick completion start (index into m_line)
s32 m_nick_completion_end;
s32 m_nick_completion_end = 0;
};

class ChatBackend
Expand Down
34 changes: 1 addition & 33 deletions src/client.cpp
Expand Up @@ -69,11 +69,6 @@ Client::Client(
bool ipv6,
GameUIFlags *game_ui_flags
):
m_packetcounter_timer(0.0),
m_connection_reinit_timer(0.1),
m_avg_rtt_timer(0.0),
m_playerpos_send_timer(0.0),
m_ignore_damage_timer(0.0),
m_tsrc(tsrc),
m_shsrc(shsrc),
m_itemdef(itemdef),
Expand All @@ -92,40 +87,13 @@ Client::Client(
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, ipv6, this),
m_address_name(address_name),
m_device(device),
m_camera(NULL),
m_minimap(NULL),
m_minimap_disabled_by_server(false),
m_server_ser_ver(SER_FMT_VER_INVALID),
m_proto_ver(0),
m_playeritem(0),
m_inventory_updated(false),
m_inventory_from_server(NULL),
m_inventory_from_server_age(0.0),
m_animation_time(0),
m_crack_level(-1),
m_crack_pos(0,0,0),
m_last_chat_message_sent(time(NULL)),
m_chat_message_allowance(5.0f),
m_map_seed(0),
m_password(password),
m_chosen_auth_mech(AUTH_MECHANISM_NONE),
m_auth_data(NULL),
m_access_denied(false),
m_access_denied_reconnect(false),
m_itemdef_received(false),
m_nodedef_received(false),
m_media_downloader(new ClientMediaDownloader()),
m_time_of_day_set(false),
m_last_time_of_day_f(-1),
m_time_of_day_update_timer(0),
m_recommended_send_interval(0.1),
m_removed_sounds_check_timer(0),
m_state(LC_Created),
m_localdb(NULL),
m_script(NULL),
m_mod_storage_save_timer(10.0f),
m_game_ui_flags(game_ui_flags),
m_shutdown(false)
m_game_ui_flags(game_ui_flags)
{
// Add local player
m_env.setLocalPlayer(new LocalPlayer(this, playername));
Expand Down

0 comments on commit 76be103

Please sign in to comment.