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/clientobject.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/clientobject.h') 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;} -- cgit v1.2.3 From ce9802266ef1def339ec2e119c59090d0fd07c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= 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/clientobject.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/clientobject.h') 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){} -- cgit v1.2.3