1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

RemotePlayer/LocalPlayer Player base class proper separation (code cleanup) (patch 3 of X)

* remove IGameDef from Player class, only LocalPlayer has it now
* move many attributes/functions only used by LocalPlayer from Player to LocalPlayer
* move many attributes/functions only used by RemotePlayer from Player to RemotePlayer
* make some functions const
* hudGetHotbarSelectedImage now returns const ref
* RemotePlayer getHotbarSelectedImage now returns const ref
* various code style fixes
This commit is contained in:
Loic Blot 2016-10-08 17:56:38 +02:00 committed by Ner'zhul
parent edba6e50d9
commit 7bbd716426
9 changed files with 255 additions and 292 deletions

View file

@ -26,16 +26,29 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "environment.h"
#include "map.h"
#include "util/numeric.h"
#include "client.h"
/*
LocalPlayer
*/
LocalPlayer::LocalPlayer(IGameDef *gamedef, const char *name):
Player(gamedef, name),
LocalPlayer::LocalPlayer(Client *gamedef, const char *name):
Player(name, gamedef->idef()),
parent(0),
got_teleported(false),
isAttached(false),
touching_ground(false),
in_liquid(false),
in_liquid_stable(false),
liquid_viscosity(0),
is_climbing(false),
swimming_vertical(false),
// Movement overrides are multipliers and must be 1 by default
physics_override_speed(1.0f),
physics_override_jump(1.0f),
physics_override_gravity(1.0f),
physics_override_sneak(true),
physics_override_sneak_glitch(true),
overridePosition(v3f(0,0,0)),
last_position(v3f(0,0,0)),
last_speed(v3f(0,0,0)),
@ -47,6 +60,8 @@ LocalPlayer::LocalPlayer(IGameDef *gamedef, const char *name):
hotbar_image(""),
hotbar_selected_image(""),
light_color(255,255,255,255),
hurt_tilt_timer(0.0f),
hurt_tilt_strength(0.0f),
m_sneak_node(32767,32767,32767),
m_sneak_node_exists(false),
m_need_to_get_new_sneak_node(true),
@ -54,7 +69,8 @@ LocalPlayer::LocalPlayer(IGameDef *gamedef, const char *name):
m_old_node_below(32767,32767,32767),
m_old_node_below_type("air"),
m_can_jump(false),
m_cao(NULL)
m_cao(NULL),
m_gamedef(gamedef)
{
// Initialize hp to 0, so that no hearts will be shown if server
// doesn't support health points