From 8e7449e09253e138716d8dbad6a2ab5c6e089e28 Mon Sep 17 00:00:00 2001 From: Ner'zhul Date: Mon, 9 Jan 2017 20:39:22 +0100 Subject: Environment & IGameDef code refactoring (#4985) * Environment code refactoring * Cleanup includes & class declarations in client & server environment to improve build speed * ServerEnvironment::m_gamedef is now a pointer to Server instead of IGameDef, permitting to cleanup many casts. * Cleanup IGameDef * Move ITextureSource* IGameDef::getTextureSource() to Client only. * Also move ITextureSource *IGameDef::tsrc() helper * drop getShaderSource, getSceneManager, getSoundManager & getCamera abstract call * drop unused emerge() call * cleanup server unused functions (mentionned before) * Drop one unused parameter from ContentFeatures::updateTextures * move checkLocalPrivilege to Client * Remove some unnecessary casts * create_formspec_menu: remove IWritableTextureSource pointer, as client already knows it * Fix some comments * Change required IGameDef to Server/Client pointers * Previous change that game.cpp sometimes calls functions with Client + InventoryManager + IGameDef in same functions but it's the same objects * Remove duplicate Client pointer in GUIFormSpecMenu::GUIFormSpecMenu * drop ClientMap::sectorWasDrawn which is unused --- src/clientobject.h | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/clientobject.h') diff --git a/src/clientobject.h b/src/clientobject.h index 83931e438..f0bde0adc 100644 --- a/src/clientobject.h +++ b/src/clientobject.h @@ -25,20 +25,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include "util/cpp11_container.h" -/* - -Some planning -------------- - -* Client receives a network packet with information of added objects - in it -* Client supplies the information to its ClientEnvironment -* The environment adds the specified objects to itself - -*/ - class ClientEnvironment; class ITextureSource; +class Client; class IGameDef; class LocalPlayer; struct ItemStack; @@ -47,7 +36,7 @@ class WieldMeshSceneNode; class ClientActiveObject : public ActiveObject { public: - ClientActiveObject(u16 id, IGameDef *gamedef, ClientEnvironment *env); + ClientActiveObject(u16 id, Client *client, ClientEnvironment *env); virtual ~ClientActiveObject(); virtual void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, @@ -89,7 +78,7 @@ public: virtual void initialize(const std::string &data){} // Create a certain type of ClientActiveObject - static ClientActiveObject* create(ActiveObjectType type, IGameDef *gamedef, + static ClientActiveObject* create(ActiveObjectType type, Client *client, ClientEnvironment *env); // If returns true, punch will not be sent to the server @@ -99,9 +88,9 @@ public: protected: // Used for creating objects based on type - typedef ClientActiveObject* (*Factory)(IGameDef *gamedef, ClientEnvironment *env); + typedef ClientActiveObject* (*Factory)(Client *client, ClientEnvironment *env); static void registerType(u16 type, Factory f); - IGameDef *m_gamedef; + Client *m_client; ClientEnvironment *m_env; private: // Used for creating objects based on type -- cgit v1.2.3 From 66479394037baa941cb06d75d3afc79ff4c717a2 Mon Sep 17 00:00:00 2001 From: Rogier Date: Tue, 10 Jan 2017 04:39:45 +0900 Subject: Performance fix + SAO factorization Original credits goes to @Rogier-5 * Merge common attributes between LuaEntitySAO & PlayerSAO to UnitSAO * Make some functions const * Improve some lists performance by returning const ref Signed-off-by: Loic Blot --- src/activeobject.h | 6 +-- src/clientobject.h | 4 +- src/content_cao.cpp | 6 +-- src/content_cao.h | 2 +- src/content_sao.cpp | 85 ++++++++++++++++++---------------------- src/content_sao.h | 87 ++++++++++++++++------------------------- src/script/lua_api/l_object.cpp | 7 ++-- src/serverobject.h | 8 ++-- 8 files changed, 88 insertions(+), 117 deletions(-) (limited to 'src/clientobject.h') diff --git a/src/activeobject.h b/src/activeobject.h index 48f078d3f..fe6c08514 100644 --- a/src/activeobject.h +++ b/src/activeobject.h @@ -64,7 +64,7 @@ public: m_id(id) { } - + u16 getId() { return m_id; @@ -76,8 +76,8 @@ public: } virtual ActiveObjectType getType() const = 0; - virtual bool getCollisionBox(aabb3f *toset) = 0; - virtual bool collideWithObjects() = 0; + virtual bool getCollisionBox(aabb3f *toset) const = 0; + virtual bool collideWithObjects() const = 0; protected: u16 m_id; // 0 is invalid, "no id" }; diff --git a/src/clientobject.h b/src/clientobject.h index f0bde0adc..1db5bcf24 100644 --- a/src/clientobject.h +++ b/src/clientobject.h @@ -47,8 +47,8 @@ public: virtual void updateLightNoCheck(u8 light_at_pos){} virtual v3s16 getLightPosition(){return v3s16(0,0,0);} virtual aabb3f *getSelectionBox() { return NULL; } - virtual bool getCollisionBox(aabb3f *toset){return false;} - virtual bool collideWithObjects(){return false;} + virtual bool getCollisionBox(aabb3f *toset) const { return false; } + virtual bool collideWithObjects() const { return false; } virtual v3f getPosition(){return v3f(0,0,0);} virtual float getYaw() const {return 0;} virtual scene::ISceneNode *getSceneNode(){return NULL;} diff --git a/src/content_cao.cpp b/src/content_cao.cpp index a4c0bf14d..5ddbd27c9 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -159,7 +159,7 @@ public: void processMessage(const std::string &data); - bool getCollisionBox(aabb3f *toset) { return false; } + bool getCollisionBox(aabb3f *toset) const { return false; } private: scene::IMeshSceneNode *m_node; v3f m_position; @@ -316,7 +316,7 @@ public: std::string infoText() {return m_infotext;} - bool getCollisionBox(aabb3f *toset) { return false; } + bool getCollisionBox(aabb3f *toset) const { return false; } private: aabb3f m_selection_box; scene::IMeshSceneNode *m_node; @@ -587,7 +587,7 @@ GenericCAO::GenericCAO(Client *client, ClientEnvironment *env): } } -bool GenericCAO::getCollisionBox(aabb3f *toset) +bool GenericCAO::getCollisionBox(aabb3f *toset) const { if (m_prop.physical) { diff --git a/src/content_cao.h b/src/content_cao.h index 96a160055..19fecdde5 100644 --- a/src/content_cao.h +++ b/src/content_cao.h @@ -130,7 +130,7 @@ public: ClientActiveObject *getParent(); - bool getCollisionBox(aabb3f *toset); + bool getCollisionBox(aabb3f *toset) const; bool collideWithObjects(); diff --git a/src/content_sao.cpp b/src/content_sao.cpp index dd8bdc592..c403a3673 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -19,11 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "content_sao.h" #include "util/serialize.h" -#include "util/mathconstants.h" #include "collision.h" #include "environment.h" -#include "settings.h" -#include "serialization.h" // For compressZlib #include "tool.h" // For ToolCapabilities #include "gamedef.h" #include "nodedef.h" @@ -31,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "server.h" #include "scripting_game.h" #include "genericobject.h" -#include "log.h" std::map ServerActiveObject::m_types; @@ -94,13 +90,8 @@ public: } } - bool getCollisionBox(aabb3f *toset) { - return false; - } - - bool collideWithObjects() { - return false; - } + bool getCollisionBox(aabb3f *toset) const { return false; } + bool collideWithObjects() const { return false; } private: float m_timer1; @@ -110,6 +101,28 @@ private: // Prototype (registers item for deserialization) TestSAO proto_TestSAO(NULL, v3f(0,0,0)); +/* + UnitSAO + */ + +UnitSAO::UnitSAO(ServerEnvironment *env, v3f pos): + ServerActiveObject(env, pos), + m_hp(-1), + m_yaw(0), + m_properties_sent(true), + m_armor_groups_sent(false), + m_animation_range(0,0), + m_animation_speed(0), + m_animation_blend(0), + m_animation_loop(true), + m_animation_sent(false), + m_bone_position_sent(false), + m_attachment_parent_id(0), + m_attachment_sent(false) +{ + // Initialize something to armor groups + m_armor_groups["fleshy"] = 100; +} /* LuaEntitySAO */ @@ -125,29 +138,17 @@ LuaEntitySAO::LuaEntitySAO(ServerEnvironment *env, v3f pos, m_registered(false), m_velocity(0,0,0), m_acceleration(0,0,0), - m_properties_sent(true), m_last_sent_yaw(0), m_last_sent_position(0,0,0), m_last_sent_velocity(0,0,0), m_last_sent_position_timer(0), - m_last_sent_move_precision(0), - m_armor_groups_sent(false), - m_animation_speed(0), - m_animation_blend(0), - m_animation_loop(true), - m_animation_sent(false), - m_bone_position_sent(false), - m_attachment_parent_id(0), - m_attachment_sent(false) + m_last_sent_move_precision(0) { // Only register type if no environment supplied if(env == NULL){ ServerActiveObject::registerType(getType(), create); return; } - - // Initialize something to armor groups - m_armor_groups["fleshy"] = 100; } LuaEntitySAO::~LuaEntitySAO() @@ -565,7 +566,7 @@ void LuaEntitySAO::setArmorGroups(const ItemGroupList &armor_groups) m_armor_groups_sent = false; } -ItemGroupList LuaEntitySAO::getArmorGroups() +const ItemGroupList &LuaEntitySAO::getArmorGroups() { return m_armor_groups; } @@ -635,7 +636,7 @@ void LuaEntitySAO::removeAttachmentChild(int child_id) m_attachment_child_ids.erase(child_id); } -UNORDERED_SET LuaEntitySAO::getAttachmentChildIds() +const UNORDERED_SET &LuaEntitySAO::getAttachmentChildIds() { return m_attachment_child_ids; } @@ -732,7 +733,8 @@ void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end) m_messages_out.push(aom); } -bool LuaEntitySAO::getCollisionBox(aabb3f *toset) { +bool LuaEntitySAO::getCollisionBox(aabb3f *toset) const +{ if (m_prop.physical) { //update collision box @@ -748,7 +750,8 @@ bool LuaEntitySAO::getCollisionBox(aabb3f *toset) { return false; } -bool LuaEntitySAO::collideWithObjects(){ +bool LuaEntitySAO::collideWithObjects() const +{ return m_prop.collideWithObjects; } @@ -770,16 +773,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, u16 peer_id_, bool is_singleplayer m_nocheat_dig_time(0), m_wield_index(0), m_position_not_sent(false), - m_armor_groups_sent(false), - m_properties_sent(true), m_is_singleplayer(is_singleplayer), - m_animation_speed(0), - m_animation_blend(0), - m_animation_loop(true), - m_animation_sent(false), - m_bone_position_sent(false), - m_attachment_parent_id(0), - m_attachment_sent(false), m_breath(PLAYER_MAX_BREATH), m_pitch(0), m_fov(0), @@ -793,7 +787,6 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, u16 peer_id_, bool is_singleplayer m_physics_override_sent(false) { assert(m_peer_id != 0); // pre-condition - m_armor_groups["fleshy"] = 100; m_prop.hp_max = PLAYER_MAX_HP; m_prop.physical = false; @@ -828,6 +821,11 @@ void PlayerSAO::initialize(RemotePlayer *player, const std::set &pr m_inventory = &m_player->inventory; } +v3f PlayerSAO::getEyeOffset() const +{ + return v3f(0, BS * 1.625f, 0); +} + std::string PlayerSAO::getDescription() { return std::string("player ") + m_player->getName(); @@ -1282,7 +1280,7 @@ void PlayerSAO::setArmorGroups(const ItemGroupList &armor_groups) m_armor_groups_sent = false; } -ItemGroupList PlayerSAO::getArmorGroups() +const ItemGroupList &PlayerSAO::getArmorGroups() { return m_armor_groups; } @@ -1354,7 +1352,7 @@ void PlayerSAO::removeAttachmentChild(int child_id) m_attachment_child_ids.erase(child_id); } -UNORDERED_SET PlayerSAO::getAttachmentChildIds() +const UNORDERED_SET &PlayerSAO::getAttachmentChildIds() { return m_attachment_child_ids; } @@ -1512,15 +1510,10 @@ bool PlayerSAO::checkMovementCheat() return cheated; } -bool PlayerSAO::getCollisionBox(aabb3f *toset) +bool PlayerSAO::getCollisionBox(aabb3f *toset) const { *toset = aabb3f(-BS * 0.30, 0.0, -BS * 0.30, BS * 0.30, BS * 1.75, BS * 0.30); toset->MinEdge += m_base_position; toset->MaxEdge += m_base_position; return true; } - -bool PlayerSAO::collideWithObjects() -{ - return true; -} diff --git a/src/content_sao.h b/src/content_sao.h index 9c66068b3..d5e9b2cbf 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -24,14 +24,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serverobject.h" #include "itemgroup.h" #include "object_properties.h" -#include "constants.h" class UnitSAO: public ServerActiveObject { public: - UnitSAO(ServerEnvironment *env, v3f pos): - ServerActiveObject(env, pos), - m_hp(-1), m_yaw(0) {} + UnitSAO(ServerEnvironment *env, v3f pos); virtual ~UnitSAO() {} virtual void setYaw(const float yaw) { m_yaw = yaw; } @@ -46,6 +43,29 @@ public: protected: s16 m_hp; float m_yaw; + + bool m_properties_sent; + struct ObjectProperties m_prop; + + ItemGroupList m_armor_groups; + bool m_armor_groups_sent; + + v2f m_animation_range; + float m_animation_speed; + float m_animation_blend; + bool m_animation_loop; + bool m_animation_sent; + + // Stores position and rotation for each bone name + UNORDERED_MAP > m_bone_position; + bool m_bone_position_sent; + + int m_attachment_parent_id; + UNORDERED_SET m_attachment_child_ids; + std::string m_attachment_bone; + v3f m_attachment_position; + v3f m_attachment_rotation; + bool m_attachment_sent; }; /* @@ -81,7 +101,7 @@ public: void setHP(s16 hp); s16 getHP() const; void setArmorGroups(const ItemGroupList &armor_groups); - ItemGroupList getArmorGroups(); + const ItemGroupList &getArmorGroups(); void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop); void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop); void setBonePosition(const std::string &bone, v3f position, v3f rotation); @@ -90,7 +110,7 @@ public: void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation); void addAttachmentChild(int child_id); void removeAttachmentChild(int child_id); - UNORDERED_SET getAttachmentChildIds(); + const UNORDERED_SET &getAttachmentChildIds(); ObjectProperties* accessObjectProperties(); void notifyObjectPropertiesModified(); /* LuaEntitySAO-specific */ @@ -103,8 +123,8 @@ public: void setSprite(v2s16 p, int num_frames, float framelength, bool select_horiz_by_yawpitch); std::string getName(); - bool getCollisionBox(aabb3f *toset); - bool collideWithObjects(); + bool getCollisionBox(aabb3f *toset) const; + bool collideWithObjects() const; private: std::string getPropertyPacket(); void sendPosition(bool do_interpolate, bool is_movement_end); @@ -112,36 +132,15 @@ private: std::string m_init_name; std::string m_init_state; bool m_registered; - struct ObjectProperties m_prop; v3f m_velocity; v3f m_acceleration; - ItemGroupList m_armor_groups; - - bool m_properties_sent; float m_last_sent_yaw; v3f m_last_sent_position; v3f m_last_sent_velocity; float m_last_sent_position_timer; float m_last_sent_move_precision; - bool m_armor_groups_sent; - - v2f m_animation_range; - float m_animation_speed; - float m_animation_blend; - bool m_animation_loop; - bool m_animation_sent; - - UNORDERED_MAP > m_bone_position; - bool m_bone_position_sent; - - int m_attachment_parent_id; - UNORDERED_SET m_attachment_child_ids; - std::string m_attachment_bone; - v3f m_attachment_position; - v3f m_attachment_rotation; - bool m_attachment_sent; }; /* @@ -235,7 +234,7 @@ public: u16 getBreath() const { return m_breath; } void setBreath(const u16 breath, bool send = true); void setArmorGroups(const ItemGroupList &armor_groups); - ItemGroupList getArmorGroups(); + const ItemGroupList &getArmorGroups(); void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop); void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop); void setBonePosition(const std::string &bone, v3f position, v3f rotation); @@ -244,7 +243,7 @@ public: void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation); void addAttachmentChild(int child_id); void removeAttachmentChild(int child_id); - UNORDERED_SET getAttachmentChildIds(); + const UNORDERED_SET &getAttachmentChildIds(); ObjectProperties* accessObjectProperties(); void notifyObjectPropertiesModified(); @@ -315,13 +314,13 @@ public: m_is_singleplayer = is_singleplayer; } - bool getCollisionBox(aabb3f *toset); - bool collideWithObjects(); + bool getCollisionBox(aabb3f *toset) const; + bool collideWithObjects() const { return true; } void initialize(RemotePlayer *player, const std::set &privs); v3f getEyePosition() const { return m_base_position + getEyeOffset(); } - v3f getEyeOffset() const { return v3f(0, BS * 1.625f, 0); } + v3f getEyeOffset() const; private: std::string getPropertyPacket(); @@ -346,31 +345,11 @@ private: int m_wield_index; bool m_position_not_sent; - ItemGroupList m_armor_groups; - bool m_armor_groups_sent; - bool m_properties_sent; - struct ObjectProperties m_prop; // Cached privileges for enforcement std::set m_privs; bool m_is_singleplayer; - v2f m_animation_range; - float m_animation_speed; - float m_animation_blend; - bool m_animation_loop; - bool m_animation_sent; - - // Stores position and rotation for each bone name - UNORDERED_MAP > m_bone_position; - bool m_bone_position_sent; - - int m_attachment_parent_id; - UNORDERED_SET m_attachment_child_ids; - std::string m_attachment_bone; - v3f m_attachment_position; - v3f m_attachment_rotation; - bool m_attachment_sent; u16 m_breath; f32 m_pitch; f32 m_fov; diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index cfdceb28e..84d14d521 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -137,8 +137,8 @@ int ObjectRef::l_remove(lua_State *L) if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER) return 0; - UNORDERED_SET child_ids = co->getAttachmentChildIds(); - UNORDERED_SET::iterator it; + const UNORDERED_SET &child_ids = co->getAttachmentChildIds(); + UNORDERED_SET::const_iterator it; for (it = child_ids.begin(); it != child_ids.end(); ++it) { // Child can be NULL if it was deleted earlier if (ServerActiveObject *child = env->getActiveObject(*it)) @@ -396,8 +396,7 @@ int ObjectRef::l_get_armor_groups(lua_State *L) if (co == NULL) return 0; // Do it - ItemGroupList groups = co->getArmorGroups(); - push_groups(L, groups); + push_groups(L, co->getArmorGroups()); return 1; } diff --git a/src/serverobject.h b/src/serverobject.h index 9884eb0a1..9e8b5a779 100644 --- a/src/serverobject.h +++ b/src/serverobject.h @@ -146,8 +146,8 @@ public: virtual void setArmorGroups(const ItemGroupList &armor_groups) {} - virtual ItemGroupList getArmorGroups() - { return ItemGroupList(); } + virtual const ItemGroupList &getArmorGroups() + { static const ItemGroupList rv; return rv; } virtual void setPhysicsOverride(float physics_override_speed, float physics_override_jump, float physics_override_gravity) {} virtual void setAnimation(v2f frames, float frame_speed, float frame_blend, bool frame_loop) @@ -166,8 +166,8 @@ public: {} virtual void removeAttachmentChild(int child_id) {} - virtual UNORDERED_SET getAttachmentChildIds() - { return UNORDERED_SET(); } + virtual const UNORDERED_SET &getAttachmentChildIds() + { static const UNORDERED_SET rv; return rv; } virtual ObjectProperties* accessObjectProperties() { return NULL; } virtual void notifyObjectPropertiesModified() -- cgit v1.2.3 From ce9802266ef1def339ec2e119c59090d0fd07c90 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Sat, 20 May 2017 08:15:56 +0200 Subject: Various code cleanup & little performance improvement on HTTP download (#5772) * Disable or remove unused enum members/functions * Tiny code style fixes * Make some functions const * Replace ClientMediaDownloader std::unordered_map with std::map --- src/activeobject.h | 6 +++--- src/camera.h | 20 ++------------------ src/chat.cpp | 5 ----- src/chat.h | 5 +---- src/client.cpp | 2 +- src/client.h | 3 +-- src/clientiface.cpp | 2 +- src/clientiface.h | 3 +-- src/clientmedia.cpp | 2 +- src/clientmedia.h | 3 ++- src/clientobject.h | 15 +++++---------- src/content_cao.cpp | 15 --------------- src/content_cao.h | 11 ----------- src/nodedef.cpp | 8 -------- src/nodedef.h | 3 --- 15 files changed, 18 insertions(+), 85 deletions(-) (limited to 'src/clientobject.h') diff --git a/src/activeobject.h b/src/activeobject.h index 71b9df514..f349ddef3 100644 --- a/src/activeobject.h +++ b/src/activeobject.h @@ -28,9 +28,9 @@ enum ActiveObjectType { ACTIVEOBJECT_TYPE_TEST = 1, // Deprecated stuff ACTIVEOBJECT_TYPE_ITEM = 2, - ACTIVEOBJECT_TYPE_RAT = 3, - ACTIVEOBJECT_TYPE_OERKKI1 = 4, - ACTIVEOBJECT_TYPE_FIREFLY = 5, +// ACTIVEOBJECT_TYPE_RAT = 3, +// ACTIVEOBJECT_TYPE_OERKKI1 = 4, +// ACTIVEOBJECT_TYPE_FIREFLY = 5, ACTIVEOBJECT_TYPE_MOBV2 = 6, // End deprecated stuff ACTIVEOBJECT_TYPE_LUAENTITY = 7, diff --git a/src/camera.h b/src/camera.h index ca2e4ddcc..1e4800cba 100644 --- a/src/camera.h +++ b/src/camera.h @@ -64,22 +64,6 @@ public: Client *client); ~Camera(); - // Get player scene node. - // This node is positioned at the player's torso (without any view bobbing), - // as given by Player::m_position. Yaw is applied but not pitch. - inline scene::ISceneNode* getPlayerNode() const - { - return m_playernode; - } - - // Get head scene node. - // It has the eye transformation and pitch applied, - // but no view bobbing. - inline scene::ISceneNode* getHeadNode() const - { - return m_headnode; - } - // Get camera scene node. // It has the eye transformation, pitch and view bobbing applied. inline scene::ICameraSceneNode* getCameraNode() const @@ -160,13 +144,13 @@ public: else m_camera_mode = CAMERA_MODE_FIRST; } - + // Set the current camera mode inline void setCameraMode(CameraMode mode) { m_camera_mode = mode; } - + //read the current camera mode inline CameraMode getCameraMode() { diff --git a/src/chat.cpp b/src/chat.cpp index de7483e22..f070e6e7b 100644 --- a/src/chat.cpp +++ b/src/chat.cpp @@ -77,11 +77,6 @@ u32 ChatBuffer::getLineCount() const return m_unformatted.size(); } -u32 ChatBuffer::getScrollback() const -{ - return m_scrollback; -} - const ChatLine& ChatBuffer::getLine(u32 index) const { assert(index < getLineCount()); // pre-condition diff --git a/src/chat.h b/src/chat.h index 5de676a2e..b7c6b74b9 100644 --- a/src/chat.h +++ b/src/chat.h @@ -86,8 +86,6 @@ public: // Get number of lines currently in buffer. u32 getLineCount() const; - // Get scrollback size, maximum number of lines in buffer. - u32 getScrollback() const; // Get reference to i-th chat line. const ChatLine& getLine(u32 index) const; @@ -162,8 +160,7 @@ public: std::wstring getLine() const { return m_line; } // Get section of line that is currently selected - std::wstring getSelection() const - { return m_line.substr(m_cursor, m_cursor_len); } + std::wstring getSelection() const { return m_line.substr(m_cursor, m_cursor_len); } // Clear the current line void clear(); diff --git a/src/client.cpp b/src/client.cpp index 5f2d2d9d2..a36f5413f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1723,7 +1723,7 @@ float Client::getRTT() float Client::getCurRate() { - return ( m_con.getLocalStat(con::CUR_INC_RATE) + + return (m_con.getLocalStat(con::CUR_INC_RATE) + m_con.getLocalStat(con::CUR_DL_RATE)); } diff --git a/src/client.h b/src/client.h index 11b670977..cc0d4699d 100644 --- a/src/client.h +++ b/src/client.h @@ -467,8 +467,7 @@ public: Minimap* getMinimap() { return m_minimap; } void setCamera(Camera* camera) { m_camera = camera; } - Camera* getCamera () - { return m_camera; } + Camera* getCamera () { return m_camera; } bool shouldShowMinimap() const; diff --git a/src/clientiface.cpp b/src/clientiface.cpp index 78339055f..356281ca6 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -590,7 +590,7 @@ void RemoteClient::notifyEvent(ClientStateEvent event) } } -u32 RemoteClient::uptime() +u32 RemoteClient::uptime() const { return porting::getTime(PRECISION_SECONDS) - m_connection_time; } diff --git a/src/clientiface.h b/src/clientiface.h index 49101fbc1..a219ed5fc 100644 --- a/src/clientiface.h +++ b/src/clientiface.h @@ -345,7 +345,7 @@ public: { serialization_version = m_pending_serialization_version; } /* get uptime */ - u32 uptime(); + u32 uptime() const; /* set version information */ void setVersionInfo(u8 major, u8 minor, u8 patch, const std::string &full) @@ -360,7 +360,6 @@ public: u8 getMajor() const { return m_version_major; } u8 getMinor() const { return m_version_minor; } u8 getPatch() const { return m_version_patch; } - std::string getVersion() const { return m_full_version; } private: // Version is stored in here after INIT before INIT2 u8 m_pending_serialization_version; diff --git a/src/clientmedia.cpp b/src/clientmedia.cpp index 14a38ca66..9c1e430df 100644 --- a/src/clientmedia.cpp +++ b/src/clientmedia.cpp @@ -348,7 +348,7 @@ void ClientMediaDownloader::remoteMediaReceived( std::string name; { - std::map::iterator it = + UNORDERED_MAP::iterator it = m_remote_file_transfers.find(fetch_result.request_id); assert(it != m_remote_file_transfers.end()); name = it->second; diff --git a/src/clientmedia.h b/src/clientmedia.h index e292be5ea..3c96dfe8a 100644 --- a/src/clientmedia.h +++ b/src/clientmedia.h @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include "util/cpp11_container.h" class Client; struct HTTPFetchResult; @@ -137,7 +138,7 @@ private: s32 m_httpfetch_active; s32 m_httpfetch_active_limit; s32 m_outstanding_hash_sets; - std::map m_remote_file_transfers; + UNORDERED_MAP m_remote_file_transfers; // All files up to this name have either been received from a // remote server or failed on all remote servers, so those files diff --git a/src/clientobject.h b/src/clientobject.h index 1db5bcf24..aa0ec9c56 100644 --- a/src/clientobject.h +++ b/src/clientobject.h @@ -49,18 +49,13 @@ public: virtual aabb3f *getSelectionBox() { return NULL; } virtual bool getCollisionBox(aabb3f *toset) const { return false; } virtual bool collideWithObjects() const { return false; } - virtual v3f getPosition(){return v3f(0,0,0);} - virtual float getYaw() const {return 0;} - virtual scene::ISceneNode *getSceneNode(){return NULL;} - virtual scene::IMeshSceneNode *getMeshSceneNode(){return NULL;} - virtual scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode(){return NULL;} - virtual WieldMeshSceneNode *getWieldMeshSceneNode(){return NULL;} - virtual scene::IBillboardSceneNode *getSpriteSceneNode(){return NULL;} - virtual bool isPlayer() const {return false;} + virtual v3f getPosition(){ return v3f(0,0,0); } + virtual float getYaw() const { return 0; } + virtual scene::ISceneNode *getSceneNode() { return NULL; } + virtual scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode() { return NULL; } virtual bool isLocalPlayer() const {return false;} - virtual void setAttachments(){} + virtual void setAttachments() {} virtual bool doShowSelectionBox(){return true;} - virtual void updateCameraOffset(v3s16 camera_offset){}; // Step object in time virtual void step(float dtime, ClientEnvironment *env){} diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 4dde2bb7b..5690ecf1e 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -706,26 +706,11 @@ scene::ISceneNode* GenericCAO::getSceneNode() return NULL; } -scene::IMeshSceneNode* GenericCAO::getMeshSceneNode() -{ - return m_meshnode; -} - scene::IAnimatedMeshSceneNode* GenericCAO::getAnimatedMeshSceneNode() { return m_animated_meshnode; } -WieldMeshSceneNode* GenericCAO::getWieldMeshSceneNode() -{ - return m_wield_meshnode; -} - -scene::IBillboardSceneNode* GenericCAO::getSpriteSceneNode() -{ - return m_spritenode; -} - void GenericCAO::setChildrenVisible(bool toset) { for (std::vector::size_type i = 0; i < m_children.size(); i++) { diff --git a/src/content_cao.h b/src/content_cao.h index 3be753529..412cdff12 100644 --- a/src/content_cao.h +++ b/src/content_cao.h @@ -146,19 +146,8 @@ public: scene::ISceneNode *getSceneNode(); - scene::IMeshSceneNode *getMeshSceneNode(); - scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode(); - WieldMeshSceneNode *getWieldMeshSceneNode(); - - scene::IBillboardSceneNode *getSpriteSceneNode(); - - inline bool isPlayer() const - { - return m_is_player; - } - inline bool isLocalPlayer() const { return m_is_local_player; diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 2ac59f8ae..98b34ea9e 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -881,7 +881,6 @@ public: void serialize(std::ostream &os, u16 protocol_version) const; void deSerialize(std::istream &is); - inline virtual bool getNodeRegistrationStatus() const; inline virtual void setNodeRegistrationStatus(bool completed); virtual void pendNodeResolve(NodeResolver *nr); @@ -1805,13 +1804,6 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version) } } - -inline bool CNodeDefManager::getNodeRegistrationStatus() const -{ - return m_node_registration_complete; -} - - inline void CNodeDefManager::setNodeRegistrationStatus(bool completed) { m_node_registration_complete = completed; diff --git a/src/nodedef.h b/src/nodedef.h index 07a962ed0..4669df7f0 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -432,8 +432,6 @@ public: virtual void serialize(std::ostream &os, u16 protocol_version) const=0; - virtual bool getNodeRegistrationStatus() const=0; - virtual void pendNodeResolve(NodeResolver *nr)=0; virtual bool cancelNodeResolveCallback(NodeResolver *nr)=0; virtual bool nodeboxConnects(const MapNode from, const MapNode to, u8 connect_face)=0; @@ -491,7 +489,6 @@ public: virtual void serialize(std::ostream &os, u16 protocol_version) const=0; virtual void deSerialize(std::istream &is)=0; - virtual bool getNodeRegistrationStatus() const=0; virtual void setNodeRegistrationStatus(bool completed)=0; virtual void pendNodeResolve(NodeResolver *nr)=0; -- cgit v1.2.3