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

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
This commit is contained in:
Ner'zhul 2017-01-09 20:39:22 +01:00 committed by GitHub
parent 11df7e886a
commit 8e7449e092
49 changed files with 301 additions and 409 deletions

View file

@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemdef.h"
#include "gamedef.h"
#include "nodedef.h"
#include "tool.h"
#include "inventory.h"
@ -29,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mesh.h"
#include "wieldmesh.h"
#include "client/tile.h"
#include "client.h"
#endif
#include "log.h"
#include "settings.h"
@ -317,7 +317,7 @@ public:
#ifndef SERVER
public:
ClientCached* createClientCachedDirect(const std::string &name,
IGameDef *gamedef) const
Client *client) const
{
infostream<<"Lazily creating item texture and mesh for \""
<<name<<"\""<<std::endl;
@ -331,7 +331,7 @@ public:
if(cc)
return cc;
ITextureSource *tsrc = gamedef->getTextureSource();
ITextureSource *tsrc = client->getTextureSource();
const ItemDefinition &def = get(name);
// Create new ClientCached
@ -345,7 +345,7 @@ public:
ItemStack item = ItemStack();
item.name = def.name;
scene::IMesh *mesh = getItemMesh(gamedef, item);
scene::IMesh *mesh = getItemMesh(client, item);
cc->wield_mesh = mesh;
// Put in cache
@ -354,7 +354,7 @@ public:
return cc;
}
ClientCached* getClientCached(const std::string &name,
IGameDef *gamedef) const
Client *client) const
{
ClientCached *cc = NULL;
m_clientcached.get(name, &cc);
@ -363,7 +363,7 @@ public:
if(thr_is_current_thread(m_main_thread))
{
return createClientCachedDirect(name, gamedef);
return createClientCachedDirect(name, client);
}
else
{
@ -392,18 +392,18 @@ public:
}
// Get item inventory texture
virtual video::ITexture* getInventoryTexture(const std::string &name,
IGameDef *gamedef) const
Client *client) const
{
ClientCached *cc = getClientCached(name, gamedef);
ClientCached *cc = getClientCached(name, client);
if(!cc)
return NULL;
return cc->inventory_texture;
}
// Get item wield mesh
virtual scene::IMesh* getWieldMesh(const std::string &name,
IGameDef *gamedef) const
Client *client) const
{
ClientCached *cc = getClientCached(name, gamedef);
ClientCached *cc = getClientCached(name, client);
if(!cc)
return NULL;
return cc->wield_mesh;
@ -543,7 +543,7 @@ public:
request = m_get_clientcached_queue.pop();
m_get_clientcached_queue.pushResult(request,
createClientCachedDirect(request.key, gamedef));
createClientCachedDirect(request.key, (Client *)gamedef));
}
#endif
}