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

@ -117,6 +117,7 @@ LOCAL_SRC_FILES := \
jni/src/cavegen.cpp \ jni/src/cavegen.cpp \
jni/src/chat.cpp \ jni/src/chat.cpp \
jni/src/client.cpp \ jni/src/client.cpp \
jni/src/clientenvironment.cpp \
jni/src/clientiface.cpp \ jni/src/clientiface.cpp \
jni/src/clientmap.cpp \ jni/src/clientmap.cpp \
jni/src/clientmedia.cpp \ jni/src/clientmedia.cpp \
@ -210,6 +211,7 @@ LOCAL_SRC_FILES := \
jni/src/rollback_interface.cpp \ jni/src/rollback_interface.cpp \
jni/src/serialization.cpp \ jni/src/serialization.cpp \
jni/src/server.cpp \ jni/src/server.cpp \
jni/src/serverenvironment.cpp \
jni/src/serverlist.cpp \ jni/src/serverlist.cpp \
jni/src/serverobject.cpp \ jni/src/serverobject.cpp \
jni/src/shader.cpp \ jni/src/shader.cpp \

@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h" #include "settings.h"
#include "wieldmesh.h" #include "wieldmesh.h"
#include "noise.h" // easeCurve #include "noise.h" // easeCurve
#include "gamedef.h"
#include "sound.h" #include "sound.h"
#include "event.h" #include "event.h"
#include "profiler.h" #include "profiler.h"
@ -41,7 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h" #include "nodedef.h"
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
IGameDef *gamedef): Client *client):
m_playernode(NULL), m_playernode(NULL),
m_headnode(NULL), m_headnode(NULL),
m_cameranode(NULL), m_cameranode(NULL),
@ -50,7 +49,7 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
m_wieldnode(NULL), m_wieldnode(NULL),
m_draw_control(draw_control), m_draw_control(draw_control),
m_gamedef(gamedef), m_client(client),
m_camera_position(0,0,0), m_camera_position(0,0,0),
m_camera_direction(0,0,0), m_camera_direction(0,0,0),
@ -88,7 +87,7 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
m_wieldmgr = smgr->createNewSceneManager(); m_wieldmgr = smgr->createNewSceneManager();
m_wieldmgr->addCameraSceneNode(); m_wieldmgr->addCameraSceneNode();
m_wieldnode = new WieldMeshSceneNode(m_wieldmgr->getRootSceneNode(), m_wieldmgr, -1, false); m_wieldnode = new WieldMeshSceneNode(m_wieldmgr->getRootSceneNode(), m_wieldmgr, -1, false);
m_wieldnode->setItem(ItemStack(), m_gamedef); m_wieldnode->setItem(ItemStack(), m_client);
m_wieldnode->drop(); // m_wieldmgr grabbed it m_wieldnode->drop(); // m_wieldmgr grabbed it
/* TODO: Add a callback function so these can be updated when a setting /* TODO: Add a callback function so these can be updated when a setting
@ -151,7 +150,7 @@ void Camera::step(f32 dtime)
m_wield_change_timer = MYMIN(m_wield_change_timer + dtime, 0.125); m_wield_change_timer = MYMIN(m_wield_change_timer + dtime, 0.125);
if (m_wield_change_timer >= 0 && was_under_zero) if (m_wield_change_timer >= 0 && was_under_zero)
m_wieldnode->setItem(m_wield_item_next, m_gamedef); m_wieldnode->setItem(m_wield_item_next, m_client);
if (m_view_bobbing_state != 0) if (m_view_bobbing_state != 0)
{ {
@ -189,7 +188,7 @@ void Camera::step(f32 dtime)
(was > 0.5f && m_view_bobbing_anim <= 0.5f)); (was > 0.5f && m_view_bobbing_anim <= 0.5f));
if(step) { if(step) {
MtEvent *e = new SimpleTriggerEvent("ViewBobbingStep"); MtEvent *e = new SimpleTriggerEvent("ViewBobbingStep");
m_gamedef->event()->put(e); m_client->event()->put(e);
} }
} }
} }
@ -210,10 +209,10 @@ void Camera::step(f32 dtime)
if(m_digging_button == 0) if(m_digging_button == 0)
{ {
MtEvent *e = new SimpleTriggerEvent("CameraPunchLeft"); MtEvent *e = new SimpleTriggerEvent("CameraPunchLeft");
m_gamedef->event()->put(e); m_client->event()->put(e);
} else if(m_digging_button == 1) { } else if(m_digging_button == 1) {
MtEvent *e = new SimpleTriggerEvent("CameraPunchRight"); MtEvent *e = new SimpleTriggerEvent("CameraPunchRight");
m_gamedef->event()->put(e); m_client->event()->put(e);
} }
} }
} }
@ -352,7 +351,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
my_cp.Y = m_camera_position.Y + (m_camera_direction.Y*-i); my_cp.Y = m_camera_position.Y + (m_camera_direction.Y*-i);
// Prevent camera positioned inside nodes // Prevent camera positioned inside nodes
INodeDefManager *nodemgr = m_gamedef->ndef(); INodeDefManager *nodemgr = m_client->ndef();
MapNode n = c_env.getClientMap().getNodeNoEx(floatToInt(my_cp, BS)); MapNode n = c_env.getClientMap().getNodeNoEx(floatToInt(my_cp, BS));
const ContentFeatures& features = nodemgr->get(n); const ContentFeatures& features = nodemgr->get(n);
if(features.walkable) if(features.walkable)
@ -390,7 +389,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
// Get FOV // Get FOV
f32 fov_degrees; f32 fov_degrees;
if (player->getPlayerControl().zoom && m_gamedef->checkLocalPrivilege("zoom")) { if (player->getPlayerControl().zoom && m_client->checkLocalPrivilege("zoom")) {
fov_degrees = m_cache_zoom_fov; fov_degrees = m_cache_zoom_fov;
} else { } else {
fov_degrees = m_cache_fov; fov_degrees = m_cache_fov;
@ -468,7 +467,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
const bool climbing = movement_Y && player->is_climbing; const bool climbing = movement_Y && player->is_climbing;
if ((walking || swimming || climbing) && if ((walking || swimming || climbing) &&
m_cache_view_bobbing && m_cache_view_bobbing &&
(!g_settings->getBool("free_move") || !m_gamedef->checkLocalPrivilege("fly"))) (!g_settings->getBool("free_move") || !m_client->checkLocalPrivilege("fly")))
{ {
// Start animation // Start animation
m_view_bobbing_state = 1; m_view_bobbing_state = 1;

@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class LocalPlayer; class LocalPlayer;
struct MapDrawControl; struct MapDrawControl;
class IGameDef; class Client;
class WieldMeshSceneNode; class WieldMeshSceneNode;
struct Nametag { struct Nametag {
@ -61,7 +61,7 @@ class Camera
{ {
public: public:
Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
IGameDef *gamedef); Client *client);
~Camera(); ~Camera();
// Get player scene node. // Get player scene node.
@ -189,7 +189,7 @@ private:
// draw control // draw control
MapDrawControl& m_draw_control; MapDrawControl& m_draw_control;
IGameDef *m_gamedef; Client *m_client;
video::IVideoDriver *m_driver; video::IVideoDriver *m_driver;
// Absolute camera position // Absolute camera position

@ -221,7 +221,7 @@ Client::Client(
m_event(event), m_event(event),
m_mesh_update_thread(), m_mesh_update_thread(),
m_env( m_env(
new ClientMap(this, this, control, new ClientMap(this, control,
device->getSceneManager()->getRootSceneNode(), device->getSceneManager()->getRootSceneNode(),
device->getSceneManager(), 666), device->getSceneManager(), 666),
device->getSceneManager(), device->getSceneManager(),

@ -34,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "localplayer.h" #include "localplayer.h"
#include "hud.h" #include "hud.h"
#include "particles.h" #include "particles.h"
#include "network/networkpacket.h"
struct MeshMakeData; struct MeshMakeData;
class MapBlockMesh; class MapBlockMesh;
@ -51,6 +50,7 @@ class Database;
class Mapper; class Mapper;
struct MinimapMapblock; struct MinimapMapblock;
class Camera; class Camera;
class NetworkPacket;
struct QueuedMeshUpdate struct QueuedMeshUpdate
{ {
@ -402,9 +402,6 @@ public:
void ProcessData(NetworkPacket *pkt); void ProcessData(NetworkPacket *pkt);
// Returns true if something was received
bool AsyncProcessPacket();
bool AsyncProcessData();
void Send(NetworkPacket* pkt); void Send(NetworkPacket* pkt);
void interact(u8 action, const PointedThing& pointed); void interact(u8 action, const PointedThing& pointed);
@ -422,8 +419,9 @@ public:
void sendRespawn(); void sendRespawn();
void sendReady(); void sendReady();
ClientEnvironment& getEnv() ClientEnvironment& getEnv() { return m_env; }
{ return m_env; } ITextureSource *tsrc() { return getTextureSource(); }
ISoundManager *sound() { return getSoundManager(); }
// Causes urgent mesh updates (unlike Map::add/removeNodeWithEvent) // Causes urgent mesh updates (unlike Map::add/removeNodeWithEvent)
void removeNode(v3s16 p); void removeNode(v3s16 p);
@ -521,14 +519,15 @@ public:
virtual IItemDefManager* getItemDefManager(); virtual IItemDefManager* getItemDefManager();
virtual INodeDefManager* getNodeDefManager(); virtual INodeDefManager* getNodeDefManager();
virtual ICraftDefManager* getCraftDefManager(); virtual ICraftDefManager* getCraftDefManager();
virtual ITextureSource* getTextureSource(); ITextureSource* getTextureSource();
virtual IShaderSource* getShaderSource(); virtual IShaderSource* getShaderSource();
virtual scene::ISceneManager* getSceneManager(); IShaderSource *shsrc() { return getShaderSource(); }
scene::ISceneManager* getSceneManager();
virtual u16 allocateUnknownNodeId(const std::string &name); virtual u16 allocateUnknownNodeId(const std::string &name);
virtual ISoundManager* getSoundManager(); virtual ISoundManager* getSoundManager();
virtual MtEventManager* getEventManager(); virtual MtEventManager* getEventManager();
virtual ParticleManager* getParticleManager(); virtual ParticleManager* getParticleManager();
virtual bool checkLocalPrivilege(const std::string &priv) bool checkLocalPrivilege(const std::string &priv)
{ return checkPrivilege(priv); } { return checkPrivilege(priv); }
virtual scene::IAnimatedMesh* getMesh(const std::string &filename); virtual scene::IAnimatedMesh* getMesh(const std::string &filename);

@ -34,13 +34,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
ClientEnvironment::ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr, ClientEnvironment::ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr,
ITextureSource *texturesource, IGameDef *gamedef, ITextureSource *texturesource, Client *client,
IrrlichtDevice *irr): IrrlichtDevice *irr):
m_map(map), m_map(map),
m_local_player(NULL), m_local_player(NULL),
m_smgr(smgr), m_smgr(smgr),
m_texturesource(texturesource), m_texturesource(texturesource),
m_gamedef(gamedef), m_client(client),
m_irr(irr) m_irr(irr)
{ {
char zero = 0; char zero = 0;
@ -94,7 +94,7 @@ void ClientEnvironment::step(float dtime)
stepTimeOfDay(dtime); stepTimeOfDay(dtime);
// Get some settings // Get some settings
bool fly_allowed = m_gamedef->checkLocalPrivilege("fly"); bool fly_allowed = m_client->checkLocalPrivilege("fly");
bool free_move = fly_allowed && g_settings->getBool("free_move"); bool free_move = fly_allowed && g_settings->getBool("free_move");
// Get local player // Get local player
@ -223,7 +223,7 @@ void ClientEnvironment::step(float dtime)
f32 post_factor = 1; // 1 hp per node/s f32 post_factor = 1; // 1 hp per node/s
if(info.type == COLLISION_NODE) if(info.type == COLLISION_NODE)
{ {
const ContentFeatures &f = m_gamedef->ndef()-> const ContentFeatures &f = m_client->ndef()->
get(m_map->getNodeNoEx(info.node_p)); get(m_map->getNodeNoEx(info.node_p));
// Determine fall damage multiplier // Determine fall damage multiplier
int addp = itemgroup_get(f.groups, "fall_damage_add_percent"); int addp = itemgroup_get(f.groups, "fall_damage_add_percent");
@ -237,7 +237,7 @@ void ClientEnvironment::step(float dtime)
if(damage != 0){ if(damage != 0){
damageLocalPlayer(damage, true); damageLocalPlayer(damage, true);
MtEvent *e = new SimpleTriggerEvent("PlayerFallingDamage"); MtEvent *e = new SimpleTriggerEvent("PlayerFallingDamage");
m_gamedef->event()->put(e); m_client->event()->put(e);
} }
} }
} }
@ -259,11 +259,11 @@ void ClientEnvironment::step(float dtime)
u32 damage_per_second = 0; u32 damage_per_second = 0;
damage_per_second = MYMAX(damage_per_second, damage_per_second = MYMAX(damage_per_second,
m_gamedef->ndef()->get(n1).damage_per_second); m_client->ndef()->get(n1).damage_per_second);
damage_per_second = MYMAX(damage_per_second, damage_per_second = MYMAX(damage_per_second,
m_gamedef->ndef()->get(n2).damage_per_second); m_client->ndef()->get(n2).damage_per_second);
damage_per_second = MYMAX(damage_per_second, damage_per_second = MYMAX(damage_per_second,
m_gamedef->ndef()->get(n3).damage_per_second); m_client->ndef()->get(n3).damage_per_second);
if(damage_per_second != 0) if(damage_per_second != 0)
{ {
@ -272,7 +272,7 @@ void ClientEnvironment::step(float dtime)
} }
// Protocol v29 make this behaviour obsolete // Protocol v29 make this behaviour obsolete
if (((Client*) getGameDef())->getProtoVersion() < 29) { if (getGameDef()->getProtoVersion() < 29) {
/* /*
Drowning Drowning
*/ */
@ -282,7 +282,7 @@ void ClientEnvironment::step(float dtime)
// head // head
v3s16 p = floatToInt(pf + v3f(0, BS * 1.6, 0), BS); v3s16 p = floatToInt(pf + v3f(0, BS * 1.6, 0), BS);
MapNode n = m_map->getNodeNoEx(p); MapNode n = m_map->getNodeNoEx(p);
ContentFeatures c = m_gamedef->ndef()->get(n); ContentFeatures c = m_client->ndef()->get(n);
u8 drowning_damage = c.drowning; u8 drowning_damage = c.drowning;
if (drowning_damage > 0 && lplayer->hp > 0) { if (drowning_damage > 0 && lplayer->hp > 0) {
u16 breath = lplayer->getBreath(); u16 breath = lplayer->getBreath();
@ -306,7 +306,7 @@ void ClientEnvironment::step(float dtime)
// head // head
v3s16 p = floatToInt(pf + v3f(0, BS * 1.6, 0), BS); v3s16 p = floatToInt(pf + v3f(0, BS * 1.6, 0), BS);
MapNode n = m_map->getNodeNoEx(p); MapNode n = m_map->getNodeNoEx(p);
ContentFeatures c = m_gamedef->ndef()->get(n); ContentFeatures c = m_client->ndef()->get(n);
if (!lplayer->hp) { if (!lplayer->hp) {
lplayer->setBreath(11); lplayer->setBreath(11);
} else if (c.drowning == 0) { } else if (c.drowning == 0) {
@ -332,7 +332,7 @@ void ClientEnvironment::step(float dtime)
v3s16 p = lplayer->getLightPosition(); v3s16 p = lplayer->getLightPosition();
node_at_lplayer = m_map->getNodeNoEx(p); node_at_lplayer = m_map->getNodeNoEx(p);
u16 light = getInteriorLight(node_at_lplayer, 0, m_gamedef->ndef()); u16 light = getInteriorLight(node_at_lplayer, 0, m_client->ndef());
u8 day = light & 0xff; u8 day = light & 0xff;
u8 night = (light >> 8) & 0xff; u8 night = (light >> 8) & 0xff;
finalColorBlend(lplayer->light_color, day, night, day_night_ratio); finalColorBlend(lplayer->light_color, day, night, day_night_ratio);
@ -360,7 +360,7 @@ void ClientEnvironment::step(float dtime)
v3s16 p = obj->getLightPosition(); v3s16 p = obj->getLightPosition();
MapNode n = m_map->getNodeNoEx(p, &pos_ok); MapNode n = m_map->getNodeNoEx(p, &pos_ok);
if (pos_ok) if (pos_ok)
light = n.getLightBlend(day_night_ratio, m_gamedef->ndef()); light = n.getLightBlend(day_night_ratio, m_client->ndef());
else else
light = blend_light(day_night_ratio, LIGHT_SUN, 0); light = blend_light(day_night_ratio, LIGHT_SUN, 0);
@ -467,7 +467,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
v3s16 p = object->getLightPosition(); v3s16 p = object->getLightPosition();
MapNode n = m_map->getNodeNoEx(p, &pos_ok); MapNode n = m_map->getNodeNoEx(p, &pos_ok);
if (pos_ok) if (pos_ok)
light = n.getLightBlend(getDayNightRatio(), m_gamedef->ndef()); light = n.getLightBlend(getDayNightRatio(), m_client->ndef());
else else
light = blend_light(getDayNightRatio(), LIGHT_SUN, 0); light = blend_light(getDayNightRatio(), LIGHT_SUN, 0);
@ -480,7 +480,7 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
const std::string &init_data) const std::string &init_data)
{ {
ClientActiveObject* obj = ClientActiveObject* obj =
ClientActiveObject::create((ActiveObjectType) type, m_gamedef, this); ClientActiveObject::create((ActiveObjectType) type, m_client, this);
if(obj == NULL) if(obj == NULL)
{ {
infostream<<"ClientEnvironment::addActiveObject(): " infostream<<"ClientEnvironment::addActiveObject(): "

@ -30,6 +30,7 @@ class ClientMap;
class ClientActiveObject; class ClientActiveObject;
class GenericCAO; class GenericCAO;
class LocalPlayer; class LocalPlayer;
struct PointedThing;
/* /*
The client-side environment. The client-side environment.
@ -66,15 +67,14 @@ class ClientEnvironment : public Environment
{ {
public: public:
ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr, ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr,
ITextureSource *texturesource, IGameDef *gamedef, ITextureSource *texturesource, Client *client,
IrrlichtDevice *device); IrrlichtDevice *device);
~ClientEnvironment(); ~ClientEnvironment();
Map & getMap(); Map & getMap();
ClientMap & getClientMap(); ClientMap & getClientMap();
IGameDef *getGameDef() Client *getGameDef() { return m_client; }
{ return m_gamedef; }
void step(f32 dtime); void step(f32 dtime);
@ -175,7 +175,7 @@ private:
LocalPlayer *m_local_player; LocalPlayer *m_local_player;
scene::ISceneManager *m_smgr; scene::ISceneManager *m_smgr;
ITextureSource *m_texturesource; ITextureSource *m_texturesource;
IGameDef *m_gamedef; Client *m_client;
IrrlichtDevice *m_irr; IrrlichtDevice *m_irr;
UNORDERED_MAP<u16, ClientActiveObject*> m_active_objects; UNORDERED_MAP<u16, ClientActiveObject*> m_active_objects;
std::vector<ClientSimpleObject*> m_simple_objects; std::vector<ClientSimpleObject*> m_simple_objects;

@ -35,13 +35,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
ClientMap::ClientMap( ClientMap::ClientMap(
Client *client, Client *client,
IGameDef *gamedef,
MapDrawControl &control, MapDrawControl &control,
scene::ISceneNode* parent, scene::ISceneNode* parent,
scene::ISceneManager* mgr, scene::ISceneManager* mgr,
s32 id s32 id
): ):
Map(dout_client, gamedef), Map(dout_client, client),
scene::ISceneNode(parent, mgr, id), scene::ISceneNode(parent, mgr, id),
m_client(client), m_client(client),
m_control(control), m_control(control),
@ -140,7 +139,7 @@ static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step, float stepfac,
return false; return false;
} }
void ClientMap::getBlocksInViewRange(v3s16 cam_pos_nodes, void ClientMap::getBlocksInViewRange(v3s16 cam_pos_nodes,
v3s16 *p_blocks_min, v3s16 *p_blocks_max) v3s16 *p_blocks_min, v3s16 *p_blocks_max)
{ {
v3s16 box_nodes_d = m_control.wanted_range * v3s16(1, 1, 1); v3s16 box_nodes_d = m_control.wanted_range * v3s16(1, 1, 1);
@ -766,7 +765,7 @@ void ClientMap::renderPostFx(CameraMode cam_mode)
const ContentFeatures& features = m_nodedef->get(n); const ContentFeatures& features = m_nodedef->get(n);
video::SColor post_effect_color = features.post_effect_color; video::SColor post_effect_color = features.post_effect_color;
if(features.solidness == 2 && !(g_settings->getBool("noclip") && if(features.solidness == 2 && !(g_settings->getBool("noclip") &&
m_gamedef->checkLocalPrivilege("noclip")) && m_client->checkLocalPrivilege("noclip")) &&
cam_mode == CAMERA_MODE_FIRST) cam_mode == CAMERA_MODE_FIRST)
{ {
post_effect_color = video::SColor(255, 0, 0, 0); post_effect_color = video::SColor(255, 0, 0, 0);

@ -59,7 +59,7 @@ class ITextureSource;
/* /*
ClientMap ClientMap
This is the only map class that is able to render itself on screen. This is the only map class that is able to render itself on screen.
*/ */
@ -68,7 +68,6 @@ class ClientMap : public Map, public scene::ISceneNode
public: public:
ClientMap( ClientMap(
Client *client, Client *client,
IGameDef *gamedef,
MapDrawControl &control, MapDrawControl &control,
scene::ISceneNode* parent, scene::ISceneNode* parent,
scene::ISceneManager* mgr, scene::ISceneManager* mgr,
@ -114,13 +113,13 @@ public:
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
renderMap(driver, SceneManager->getSceneNodeRenderPass()); renderMap(driver, SceneManager->getSceneNodeRenderPass());
} }
virtual const aabb3f &getBoundingBox() const virtual const aabb3f &getBoundingBox() const
{ {
return m_box; return m_box;
} }
void getBlocksInViewRange(v3s16 cam_pos_nodes, void getBlocksInViewRange(v3s16 cam_pos_nodes,
v3s16 *p_blocks_min, v3s16 *p_blocks_max); v3s16 *p_blocks_min, v3s16 *p_blocks_max);
void updateDrawList(video::IVideoDriver* driver); void updateDrawList(video::IVideoDriver* driver);
void renderMap(video::IVideoDriver* driver, s32 pass); void renderMap(video::IVideoDriver* driver, s32 pass);
@ -132,20 +131,14 @@ public:
// For debug printing // For debug printing
virtual void PrintInfo(std::ostream &out); virtual void PrintInfo(std::ostream &out);
// Check if sector was drawn on last render()
bool sectorWasDrawn(v2s16 p)
{
return (m_last_drawn_sectors.find(p) != m_last_drawn_sectors.end());
}
const MapDrawControl & getControl() const { return m_control; } const MapDrawControl & getControl() const { return m_control; }
f32 getCameraFov() const { return m_camera_fov; } f32 getCameraFov() const { return m_camera_fov; }
private: private:
Client *m_client; Client *m_client;
aabb3f m_box; aabb3f m_box;
MapDrawControl &m_control; MapDrawControl &m_control;
v3f m_camera_position; v3f m_camera_position;
@ -154,7 +147,7 @@ private:
v3s16 m_camera_offset; v3s16 m_camera_offset;
std::map<v3s16, MapBlock*> m_drawlist; std::map<v3s16, MapBlock*> m_drawlist;
std::set<v2s16> m_last_drawn_sectors; std::set<v2s16> m_last_drawn_sectors;
bool m_cache_trilinear_filter; bool m_cache_trilinear_filter;

@ -20,16 +20,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "clientobject.h" #include "clientobject.h"
#include "debug.h" #include "debug.h"
#include "porting.h" #include "porting.h"
#include "constants.h"
/* /*
ClientActiveObject ClientActiveObject
*/ */
ClientActiveObject::ClientActiveObject(u16 id, IGameDef *gamedef, ClientActiveObject::ClientActiveObject(u16 id, Client *client,
ClientEnvironment *env): ClientEnvironment *env):
ActiveObject(id), ActiveObject(id),
m_gamedef(gamedef), m_client(client),
m_env(env) m_env(env)
{ {
} }
@ -40,7 +39,7 @@ ClientActiveObject::~ClientActiveObject()
} }
ClientActiveObject* ClientActiveObject::create(ActiveObjectType type, ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,
IGameDef *gamedef, ClientEnvironment *env) Client *client, ClientEnvironment *env)
{ {
// Find factory function // Find factory function
UNORDERED_MAP<u16, Factory>::iterator n = m_types.find(type); UNORDERED_MAP<u16, Factory>::iterator n = m_types.find(type);
@ -52,7 +51,7 @@ ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,
} }
Factory f = n->second; Factory f = n->second;
ClientActiveObject *object = (*f)(gamedef, env); ClientActiveObject *object = (*f)(client, env);
return object; return object;
} }

@ -25,20 +25,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <map> #include <map>
#include "util/cpp11_container.h" #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 ClientEnvironment;
class ITextureSource; class ITextureSource;
class Client;
class IGameDef; class IGameDef;
class LocalPlayer; class LocalPlayer;
struct ItemStack; struct ItemStack;
@ -47,7 +36,7 @@ class WieldMeshSceneNode;
class ClientActiveObject : public ActiveObject class ClientActiveObject : public ActiveObject
{ {
public: public:
ClientActiveObject(u16 id, IGameDef *gamedef, ClientEnvironment *env); ClientActiveObject(u16 id, Client *client, ClientEnvironment *env);
virtual ~ClientActiveObject(); virtual ~ClientActiveObject();
virtual void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, virtual void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
@ -89,7 +78,7 @@ public:
virtual void initialize(const std::string &data){} virtual void initialize(const std::string &data){}
// Create a certain type of ClientActiveObject // Create a certain type of ClientActiveObject
static ClientActiveObject* create(ActiveObjectType type, IGameDef *gamedef, static ClientActiveObject* create(ActiveObjectType type, Client *client,
ClientEnvironment *env); ClientEnvironment *env);
// If returns true, punch will not be sent to the server // If returns true, punch will not be sent to the server
@ -99,9 +88,9 @@ public:
protected: protected:
// Used for creating objects based on type // 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); static void registerType(u16 type, Factory f);
IGameDef *m_gamedef; Client *m_client;
ClientEnvironment *m_env; ClientEnvironment *m_env;
private: private:
// Used for creating objects based on type // Used for creating objects based on type

@ -22,9 +22,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h" #include "map.h"
#include "nodedef.h" #include "nodedef.h"
#include "gamedef.h" #include "gamedef.h"
#ifndef SERVER
#include "clientenvironment.h" #include "clientenvironment.h"
#endif
#include "serverenvironment.h" #include "serverenvironment.h"
#include "serverobject.h" #include "serverobject.h"
#include "util/timetaker.h"
#include "profiler.h" #include "profiler.h"
// float error is 10 - 9.96875 = 0.03125 // float error is 10 - 9.96875 = 0.03125

@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "collision.h" #include "collision.h"
#include "settings.h" #include "settings.h"
#include "serialization.h" // For decompressZlib #include "serialization.h" // For decompressZlib
#include "gamedef.h"
#include "clientobject.h" #include "clientobject.h"
#include "mesh.h" #include "mesh.h"
#include "itemdef.h" #include "itemdef.h"
@ -139,7 +138,7 @@ static void setBillboardTextureMatrix(scene::IBillboardSceneNode *bill,
class TestCAO : public ClientActiveObject class TestCAO : public ClientActiveObject
{ {
public: public:
TestCAO(IGameDef *gamedef, ClientEnvironment *env); TestCAO(Client *client, ClientEnvironment *env);
virtual ~TestCAO(); virtual ~TestCAO();
ActiveObjectType getType() const ActiveObjectType getType() const
@ -147,7 +146,7 @@ public:
return ACTIVEOBJECT_TYPE_TEST; return ACTIVEOBJECT_TYPE_TEST;
} }
static ClientActiveObject* create(IGameDef *gamedef, ClientEnvironment *env); static ClientActiveObject* create(Client *client, ClientEnvironment *env);
void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
IrrlichtDevice *irr); IrrlichtDevice *irr);
@ -169,8 +168,8 @@ private:
// Prototype // Prototype
TestCAO proto_TestCAO(NULL, NULL); TestCAO proto_TestCAO(NULL, NULL);
TestCAO::TestCAO(IGameDef *gamedef, ClientEnvironment *env): TestCAO::TestCAO(Client *client, ClientEnvironment *env):
ClientActiveObject(0, gamedef, env), ClientActiveObject(0, client, env),
m_node(NULL), m_node(NULL),
m_position(v3f(0,10*BS,0)) m_position(v3f(0,10*BS,0))
{ {
@ -181,9 +180,9 @@ TestCAO::~TestCAO()
{ {
} }
ClientActiveObject* TestCAO::create(IGameDef *gamedef, ClientEnvironment *env) ClientActiveObject* TestCAO::create(Client *client, ClientEnvironment *env)
{ {
return new TestCAO(gamedef, env); return new TestCAO(client, env);
} }
void TestCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, void TestCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
@ -283,7 +282,7 @@ void TestCAO::processMessage(const std::string &data)
class ItemCAO : public ClientActiveObject class ItemCAO : public ClientActiveObject
{ {
public: public:
ItemCAO(IGameDef *gamedef, ClientEnvironment *env); ItemCAO(Client *client, ClientEnvironment *env);
virtual ~ItemCAO(); virtual ~ItemCAO();
ActiveObjectType getType() const ActiveObjectType getType() const
@ -291,7 +290,7 @@ public:
return ACTIVEOBJECT_TYPE_ITEM; return ACTIVEOBJECT_TYPE_ITEM;
} }
static ClientActiveObject* create(IGameDef *gamedef, ClientEnvironment *env); static ClientActiveObject* create(Client *client, ClientEnvironment *env);
void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
IrrlichtDevice *irr); IrrlichtDevice *irr);
@ -331,13 +330,13 @@ private:
// Prototype // Prototype
ItemCAO proto_ItemCAO(NULL, NULL); ItemCAO proto_ItemCAO(NULL, NULL);
ItemCAO::ItemCAO(IGameDef *gamedef, ClientEnvironment *env): ItemCAO::ItemCAO(Client *client, ClientEnvironment *env):
ClientActiveObject(0, gamedef, env), ClientActiveObject(0, client, env),
m_selection_box(-BS/3.,0.0,-BS/3., BS/3.,BS*2./3.,BS/3.), m_selection_box(-BS/3.,0.0,-BS/3., BS/3.,BS*2./3.,BS/3.),
m_node(NULL), m_node(NULL),
m_position(v3f(0,10*BS,0)) m_position(v3f(0,10*BS,0))
{ {
if(!gamedef && !env) if(!client && !env)
{ {
ClientActiveObject::registerType(getType(), create); ClientActiveObject::registerType(getType(), create);
} }
@ -347,9 +346,9 @@ ItemCAO::~ItemCAO()
{ {
} }
ClientActiveObject* ItemCAO::create(IGameDef *gamedef, ClientEnvironment *env) ClientActiveObject* ItemCAO::create(Client *client, ClientEnvironment *env)
{ {
return new ItemCAO(gamedef, env); return new ItemCAO(client, env);
} }
void ItemCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, void ItemCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
@ -433,7 +432,7 @@ void ItemCAO::updateNodePos()
void ItemCAO::updateInfoText() void ItemCAO::updateInfoText()
{ {
try{ try{
IItemDefManager *idef = m_gamedef->idef(); IItemDefManager *idef = m_client->idef();
ItemStack item; ItemStack item;
item.deSerialize(m_itemstring, idef); item.deSerialize(m_itemstring, idef);
if(item.isKnown(idef)) if(item.isKnown(idef))
@ -458,10 +457,10 @@ void ItemCAO::updateTexture()
std::istringstream is(m_itemstring, std::ios_base::binary); std::istringstream is(m_itemstring, std::ios_base::binary);
video::ITexture *texture = NULL; video::ITexture *texture = NULL;
try{ try{
IItemDefManager *idef = m_gamedef->idef(); IItemDefManager *idef = m_client->idef();
ItemStack item; ItemStack item;
item.deSerialize(is, idef); item.deSerialize(is, idef);
texture = idef->getInventoryTexture(item.getDefinition(idef).name, m_gamedef); texture = idef->getInventoryTexture(item.getDefinition(idef).name, m_client);
} }
catch(SerializationError &e) catch(SerializationError &e)
{ {
@ -538,15 +537,15 @@ void ItemCAO::initialize(const std::string &data)
#include "genericobject.h" #include "genericobject.h"
GenericCAO::GenericCAO(IGameDef *gamedef, ClientEnvironment *env): GenericCAO::GenericCAO(Client *client, ClientEnvironment *env):
ClientActiveObject(0, gamedef, env), ClientActiveObject(0, client, env),
// //
m_is_player(false), m_is_player(false),
m_is_local_player(false), m_is_local_player(false),
// //
m_smgr(NULL), m_smgr(NULL),
m_irr(NULL), m_irr(NULL),
m_gamedef(NULL), m_client(NULL),
m_selection_box(-BS/3.,-BS/3.,-BS/3., BS/3.,BS/3.,BS/3.), m_selection_box(-BS/3.,-BS/3.,-BS/3., BS/3.,BS/3.,BS/3.),
m_meshnode(NULL), m_meshnode(NULL),
m_animated_meshnode(NULL), m_animated_meshnode(NULL),
@ -581,10 +580,10 @@ GenericCAO::GenericCAO(IGameDef *gamedef, ClientEnvironment *env):
m_last_light(255), m_last_light(255),
m_is_visible(false) m_is_visible(false)
{ {
if (gamedef == NULL) { if (client == NULL) {
ClientActiveObject::registerType(getType(), create); ClientActiveObject::registerType(getType(), create);
} else { } else {
m_gamedef = gamedef; m_client = client;
} }
} }
@ -793,7 +792,7 @@ void GenericCAO::removeFromScene(bool permanent)
} }
if (m_nametag) { if (m_nametag) {
m_gamedef->getCamera()->removeNametag(m_nametag); m_client->getCamera()->removeNametag(m_nametag);
m_nametag = NULL; m_nametag = NULL;
} }
} }
@ -906,7 +905,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
} }
else if(m_prop.visual == "mesh") { else if(m_prop.visual == "mesh") {
infostream<<"GenericCAO::addToScene(): mesh"<<std::endl; infostream<<"GenericCAO::addToScene(): mesh"<<std::endl;
scene::IAnimatedMesh *mesh = m_gamedef->getMesh(m_prop.mesh); scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh);
if(mesh) if(mesh)
{ {
m_animated_meshnode = smgr->addAnimatedMeshSceneNode(mesh, NULL); m_animated_meshnode = smgr->addAnimatedMeshSceneNode(mesh, NULL);
@ -937,12 +936,12 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
infostream<<"textures: "<<m_prop.textures.size()<<std::endl; infostream<<"textures: "<<m_prop.textures.size()<<std::endl;
if(m_prop.textures.size() >= 1){ if(m_prop.textures.size() >= 1){
infostream<<"textures[0]: "<<m_prop.textures[0]<<std::endl; infostream<<"textures[0]: "<<m_prop.textures[0]<<std::endl;
IItemDefManager *idef = m_gamedef->idef(); IItemDefManager *idef = m_client->idef();
ItemStack item(m_prop.textures[0], 1, 0, "", idef); ItemStack item(m_prop.textures[0], 1, 0, "", idef);
m_wield_meshnode = new WieldMeshSceneNode( m_wield_meshnode = new WieldMeshSceneNode(
smgr->getRootSceneNode(), smgr, -1); smgr->getRootSceneNode(), smgr, -1);
m_wield_meshnode->setItem(item, m_gamedef); m_wield_meshnode->setItem(item, m_client);
m_wield_meshnode->setScale(v3f(m_prop.visual_size.X/2, m_wield_meshnode->setScale(v3f(m_prop.visual_size.X/2,
m_prop.visual_size.Y/2, m_prop.visual_size.Y/2,
@ -959,7 +958,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
scene::ISceneNode *node = getSceneNode(); scene::ISceneNode *node = getSceneNode();
if (node && m_prop.nametag != "" && !m_is_local_player) { if (node && m_prop.nametag != "" && !m_is_local_player) {
// Add nametag // Add nametag
m_nametag = m_gamedef->getCamera()->addNametag(node, m_nametag = m_client->getCamera()->addNametag(node,
m_prop.nametag, m_prop.nametag_color); m_prop.nametag, m_prop.nametag_color);
} }
@ -1058,11 +1057,11 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
// increase speed if using fast or flying fast // increase speed if using fast or flying fast
if((g_settings->getBool("fast_move") && if((g_settings->getBool("fast_move") &&
m_gamedef->checkLocalPrivilege("fast")) && m_client->checkLocalPrivilege("fast")) &&
(controls.aux1 || (controls.aux1 ||
(!player->touching_ground && (!player->touching_ground &&
g_settings->getBool("free_move") && g_settings->getBool("free_move") &&
m_gamedef->checkLocalPrivilege("fly")))) m_client->checkLocalPrivilege("fly"))))
new_speed *= 1.5; new_speed *= 1.5;
// slowdown speed if sneeking // slowdown speed if sneeking
if(controls.sneak && walking) if(controls.sneak && walking)
@ -1129,7 +1128,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
} }
removeFromScene(false); removeFromScene(false);
addToScene(m_smgr, m_gamedef->tsrc(), m_irr); addToScene(m_smgr, m_client->tsrc(), m_irr);
// Attachments, part 2: Now that the parent has been refreshed, put its attachments back // Attachments, part 2: Now that the parent has been refreshed, put its attachments back
for (std::vector<u16>::size_type i = 0; i < m_children.size(); i++) { for (std::vector<u16>::size_type i = 0; i < m_children.size(); i++) {
@ -1199,12 +1198,12 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
m_step_distance_counter = 0; m_step_distance_counter = 0;
if(!m_is_local_player && m_prop.makes_footstep_sound) if(!m_is_local_player && m_prop.makes_footstep_sound)
{ {
INodeDefManager *ndef = m_gamedef->ndef(); INodeDefManager *ndef = m_client->ndef();
v3s16 p = floatToInt(getPosition() + v3f(0, v3s16 p = floatToInt(getPosition() + v3f(0,
(m_prop.collisionbox.MinEdge.Y-0.5)*BS, 0), BS); (m_prop.collisionbox.MinEdge.Y-0.5)*BS, 0), BS);
MapNode n = m_env->getMap().getNodeNoEx(p); MapNode n = m_env->getMap().getNodeNoEx(p);
SimpleSoundSpec spec = ndef->get(n).sound_footstep; SimpleSoundSpec spec = ndef->get(n).sound_footstep;
m_gamedef->sound()->playSoundAt(spec, false, getPosition()); m_client->sound()->playSoundAt(spec, false, getPosition());
} }
} }
} }
@ -1305,7 +1304,7 @@ void GenericCAO::updateTexturePos()
void GenericCAO::updateTextures(const std::string &mod) void GenericCAO::updateTextures(const std::string &mod)
{ {
ITextureSource *tsrc = m_gamedef->tsrc(); ITextureSource *tsrc = m_client->tsrc();
bool use_trilinear_filter = g_settings->getBool("trilinear_filter"); bool use_trilinear_filter = g_settings->getBool("trilinear_filter");
bool use_bilinear_filter = g_settings->getBool("bilinear_filter"); bool use_bilinear_filter = g_settings->getBool("bilinear_filter");
@ -1778,7 +1777,7 @@ bool GenericCAO::directReportPunch(v3f dir, const ItemStack *punchitem,
{ {
assert(punchitem); // pre-condition assert(punchitem); // pre-condition
const ToolCapabilities *toolcap = const ToolCapabilities *toolcap =
&punchitem->getToolCapabilities(m_gamedef->idef()); &punchitem->getToolCapabilities(m_client->idef());
PunchDamageResult result = getPunchDamage( PunchDamageResult result = getPunchDamage(
m_armor_groups, m_armor_groups,
toolcap, toolcap,

@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemgroup.h" #include "itemgroup.h"
class Camera; class Camera;
class Client;
struct Nametag; struct Nametag;
/* /*
@ -68,7 +69,7 @@ private:
// //
scene::ISceneManager *m_smgr; scene::ISceneManager *m_smgr;
IrrlichtDevice *m_irr; IrrlichtDevice *m_irr;
IGameDef *m_gamedef; Client *m_client;
aabb3f m_selection_box; aabb3f m_selection_box;
scene::IMeshSceneNode *m_meshnode; scene::IMeshSceneNode *m_meshnode;
scene::IAnimatedMeshSceneNode *m_animated_meshnode; scene::IAnimatedMeshSceneNode *m_animated_meshnode;
@ -109,13 +110,13 @@ private:
std::vector<u16> m_children; std::vector<u16> m_children;
public: public:
GenericCAO(IGameDef *gamedef, ClientEnvironment *env); GenericCAO(Client *client, ClientEnvironment *env);
~GenericCAO(); ~GenericCAO();
static ClientActiveObject* create(IGameDef *gamedef, ClientEnvironment *env) static ClientActiveObject* create(Client *client, ClientEnvironment *env)
{ {
return new GenericCAO(gamedef, env); return new GenericCAO(client, env);
} }
inline ActiveObjectType getType() const inline ActiveObjectType getType() const

@ -21,20 +21,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IBillboardSceneNode.h> #include <IBillboardSceneNode.h>
#include "client/tile.h" #include "client/tile.h"
#include "clientenvironment.h" #include "clientenvironment.h"
#include "gamedef.h" #include "client.h"
#include "map.h" #include "map.h"
/*
static void setBillboardTextureMatrix(scene::IBillboardSceneNode *bill,
float txs, float tys, int col, int row)
{
video::SMaterial& material = bill->getMaterial(0);
core::matrix4& matrix = material.getTextureMatrix(0);
matrix.setTextureTranslate(txs*col, tys*row);
matrix.setTextureScale(txs, tys);
}
*/
class SmokePuffCSO: public ClientSimpleObject class SmokePuffCSO: public ClientSimpleObject
{ {
float m_age; float m_age;

@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/tile.h" #include "client/tile.h"
#include "mesh.h" #include "mesh.h"
#include <IMeshManipulator.h> #include <IMeshManipulator.h>
#include "gamedef.h" #include "client.h"
#include "log.h" #include "log.h"
#include "noise.h" #include "noise.h"
@ -188,8 +188,8 @@ static inline int NeighborToIndex(const v3s16 &pos)
void mapblock_mesh_generate_special(MeshMakeData *data, void mapblock_mesh_generate_special(MeshMakeData *data,
MeshCollector &collector) MeshCollector &collector)
{ {
INodeDefManager *nodedef = data->m_gamedef->ndef(); INodeDefManager *nodedef = data->m_client->ndef();
scene::ISceneManager* smgr = data->m_gamedef->getSceneManager(); scene::ISceneManager* smgr = data->m_client->getSceneManager();
scene::IMeshManipulator* meshmanip = smgr->getMeshManipulator(); scene::IMeshManipulator* meshmanip = smgr->getMeshManipulator();
// 0ms // 0ms

@ -273,7 +273,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
v3f p_pos = m_base_position; v3f p_pos = m_base_position;
v3f p_velocity = m_velocity; v3f p_velocity = m_velocity;
v3f p_acceleration = m_acceleration; v3f p_acceleration = m_acceleration;
moveresult = collisionMoveSimple(m_env,m_env->getGameDef(), moveresult = collisionMoveSimple(m_env, m_env->getGameDef(),
pos_max_d, box, m_prop.stepheight, dtime, pos_max_d, box, m_prop.stepheight, dtime,
&p_pos, &p_velocity, p_acceleration, &p_pos, &p_velocity, p_acceleration,
this, m_prop.collideWithObjects); this, m_prop.collideWithObjects);
@ -945,7 +945,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
// get head position // get head position
v3s16 p = floatToInt(m_base_position + v3f(0, BS * 1.6, 0), BS); v3s16 p = floatToInt(m_base_position + v3f(0, BS * 1.6, 0), BS);
MapNode n = m_env->getMap().getNodeNoEx(p); MapNode n = m_env->getMap().getNodeNoEx(p);
const ContentFeatures &c = ((Server*) m_env->getGameDef())->ndef()->get(n); const ContentFeatures &c = m_env->getGameDef()->ndef()->get(n);
// If node generates drown // If node generates drown
if (c.drowning > 0) { if (c.drowning > 0) {
if (m_hp > 0 && m_breath > 0) if (m_hp > 0 && m_breath > 0)
@ -954,7 +954,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
// No more breath, damage player // No more breath, damage player
if (m_breath == 0) { if (m_breath == 0) {
setHP(m_hp - c.drowning); setHP(m_hp - c.drowning);
((Server*) m_env->getGameDef())->SendPlayerHPOrDie(this); m_env->getGameDef()->SendPlayerHPOrDie(this);
} }
} }
} }
@ -963,7 +963,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
// get head position // get head position
v3s16 p = floatToInt(m_base_position + v3f(0, BS * 1.6, 0), BS); v3s16 p = floatToInt(m_base_position + v3f(0, BS * 1.6, 0), BS);
MapNode n = m_env->getMap().getNodeNoEx(p); MapNode n = m_env->getMap().getNodeNoEx(p);
const ContentFeatures &c = ((Server*) m_env->getGameDef())->ndef()->get(n); const ContentFeatures &c = m_env->getGameDef()->ndef()->get(n);
// If player is alive & no drowning, breath // If player is alive & no drowning, breath
if (m_hp > 0 && c.drowning == 0) if (m_hp > 0 && c.drowning == 0)
setBreath(m_breath + 1); setBreath(m_breath + 1);
@ -985,7 +985,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
m_attachment_position = v3f(0,0,0); m_attachment_position = v3f(0,0,0);
m_attachment_rotation = v3f(0,0,0); m_attachment_rotation = v3f(0,0,0);
setBasePosition(m_last_good_position); setBasePosition(m_last_good_position);
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id); m_env->getGameDef()->SendMovePlayer(m_peer_id);
} }
//dstream<<"PlayerSAO::step: dtime: "<<dtime<<std::endl; //dstream<<"PlayerSAO::step: dtime: "<<dtime<<std::endl;
@ -1107,7 +1107,7 @@ void PlayerSAO::setPos(const v3f &pos)
setBasePosition(pos); setBasePosition(pos);
// Movement caused by this command is always valid // Movement caused by this command is always valid
m_last_good_position = pos; m_last_good_position = pos;
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id); m_env->getGameDef()->SendMovePlayer(m_peer_id);
} }
void PlayerSAO::moveTo(v3f pos, bool continuous) void PlayerSAO::moveTo(v3f pos, bool continuous)
@ -1118,7 +1118,7 @@ void PlayerSAO::moveTo(v3f pos, bool continuous)
setBasePosition(pos); setBasePosition(pos);
// Movement caused by this command is always valid // Movement caused by this command is always valid
m_last_good_position = pos; m_last_good_position = pos;
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id); m_env->getGameDef()->SendMovePlayer(m_peer_id);
} }
void PlayerSAO::setYaw(const float yaw) void PlayerSAO::setYaw(const float yaw)
@ -1148,7 +1148,7 @@ void PlayerSAO::setWantedRange(const s16 range)
void PlayerSAO::setYawAndSend(const float yaw) void PlayerSAO::setYawAndSend(const float yaw)
{ {
setYaw(yaw); setYaw(yaw);
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id); m_env->getGameDef()->SendMovePlayer(m_peer_id);
} }
void PlayerSAO::setPitch(const float pitch) void PlayerSAO::setPitch(const float pitch)
@ -1162,7 +1162,7 @@ void PlayerSAO::setPitch(const float pitch)
void PlayerSAO::setPitchAndSend(const float pitch) void PlayerSAO::setPitchAndSend(const float pitch)
{ {
setPitch(pitch); setPitch(pitch);
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id); m_env->getGameDef()->SendMovePlayer(m_peer_id);
} }
int PlayerSAO::punch(v3f dir, int PlayerSAO::punch(v3f dir,
@ -1273,7 +1273,7 @@ void PlayerSAO::setBreath(const u16 breath, bool send)
m_breath = MYMIN(breath, PLAYER_MAX_BREATH); m_breath = MYMIN(breath, PLAYER_MAX_BREATH);
if (send) if (send)
((Server *) m_env->getGameDef())->SendPlayerBreath(this); m_env->getGameDef()->SendPlayerBreath(this);
} }
void PlayerSAO::setArmorGroups(const ItemGroupList &armor_groups) void PlayerSAO::setArmorGroups(const ItemGroupList &armor_groups)

@ -89,13 +89,13 @@ private:
//// EmergeManager //// EmergeManager
//// ////
EmergeManager::EmergeManager(IGameDef *gamedef) EmergeManager::EmergeManager(Server *server)
{ {
this->ndef = gamedef->getNodeDefManager(); this->ndef = server->getNodeDefManager();
this->biomemgr = new BiomeManager(gamedef); this->biomemgr = new BiomeManager(server);
this->oremgr = new OreManager(gamedef); this->oremgr = new OreManager(server);
this->decomgr = new DecorationManager(gamedef); this->decomgr = new DecorationManager(server);
this->schemmgr = new SchematicManager(gamedef); this->schemmgr = new SchematicManager(server);
this->gen_notify_on = 0; this->gen_notify_on = 0;
// Note that accesses to this variable are not synchronized. // Note that accesses to this variable are not synchronized.
@ -128,7 +128,7 @@ EmergeManager::EmergeManager(IGameDef *gamedef)
m_qlimit_generate = 1; m_qlimit_generate = 1;
for (s16 i = 0; i < nthreads; i++) for (s16 i = 0; i < nthreads; i++)
m_threads.push_back(new EmergeThread((Server *)gamedef, i)); m_threads.push_back(new EmergeThread(server, i));
infostream << "EmergeManager: using " << nthreads << " threads" << std::endl; infostream << "EmergeManager: using " << nthreads << " threads" << std::endl;
} }

@ -42,6 +42,7 @@ class BiomeManager;
class OreManager; class OreManager;
class DecorationManager; class DecorationManager;
class SchematicManager; class SchematicManager;
class Server;
// Structure containing inputs/outputs for chunk generation // Structure containing inputs/outputs for chunk generation
struct BlockMakeData { struct BlockMakeData {
@ -115,7 +116,7 @@ public:
SchematicManager *schemmgr; SchematicManager *schemmgr;
// Methods // Methods
EmergeManager(IGameDef *gamedef); EmergeManager(Server *server);
~EmergeManager(); ~EmergeManager();
bool initMapgens(MapgenParams *mgparams); bool initMapgens(MapgenParams *mgparams);

@ -42,13 +42,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "threading/atomic.h" #include "threading/atomic.h"
#include "network/networkprotocol.h" // for AccessDeniedCode #include "network/networkprotocol.h" // for AccessDeniedCode
class ITextureSource;
class IGameDef;
class Map;
class GameScripting;
class Player;
class PointedThing;
class Environment class Environment
{ {
public: public:

@ -916,16 +916,14 @@ bool nodePlacementPrediction(Client &client,
} }
static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec, static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
InventoryManager *invmgr, IGameDef *gamedef, Client *client, IrrlichtDevice *device, JoystickController *joystick,
IWritableTextureSource *tsrc, IrrlichtDevice *device, IFormSource *fs_src, TextDest *txt_dest)
JoystickController *joystick,
IFormSource *fs_src, TextDest *txt_dest, Client *client)
{ {
if (*cur_formspec == 0) { if (*cur_formspec == 0) {
*cur_formspec = new GUIFormSpecMenu(device, joystick, *cur_formspec = new GUIFormSpecMenu(device, joystick,
guiroot, -1, &g_menumgr, invmgr, gamedef, tsrc, guiroot, -1, &g_menumgr, client, client->getTextureSource(),
fs_src, txt_dest, client); fs_src, txt_dest);
(*cur_formspec)->doPause = false; (*cur_formspec)->doPause = false;
/* /*
@ -950,9 +948,9 @@ static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
#endif #endif
static void show_deathscreen(GUIFormSpecMenu **cur_formspec, static void show_deathscreen(GUIFormSpecMenu **cur_formspec,
InventoryManager *invmgr, IGameDef *gamedef, Client *client,
IWritableTextureSource *tsrc, IrrlichtDevice *device, IWritableTextureSource *tsrc, IrrlichtDevice *device,
JoystickController *joystick, Client *client) JoystickController *joystick)
{ {
std::string formspec = std::string formspec =
std::string(FORMSPEC_VERSION_STRING) + std::string(FORMSPEC_VERSION_STRING) +
@ -968,13 +966,12 @@ static void show_deathscreen(GUIFormSpecMenu **cur_formspec,
FormspecFormSource *fs_src = new FormspecFormSource(formspec); FormspecFormSource *fs_src = new FormspecFormSource(formspec);
LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_DEATH_SCREEN", client); LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_DEATH_SCREEN", client);
create_formspec_menu(cur_formspec, invmgr, gamedef, tsrc, device, create_formspec_menu(cur_formspec, client, device, joystick, fs_src, txt_dst);
joystick, fs_src, txt_dst, NULL);
} }
/******************************************************************************/ /******************************************************************************/
static void show_pause_menu(GUIFormSpecMenu **cur_formspec, static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
InventoryManager *invmgr, IGameDef *gamedef, Client *client,
IWritableTextureSource *tsrc, IrrlichtDevice *device, IWritableTextureSource *tsrc, IrrlichtDevice *device,
JoystickController *joystick, bool singleplayermode) JoystickController *joystick, bool singleplayermode)
{ {
@ -1041,8 +1038,7 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
FormspecFormSource *fs_src = new FormspecFormSource(os.str()); FormspecFormSource *fs_src = new FormspecFormSource(os.str());
LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_PAUSE_MENU"); LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_PAUSE_MENU");
create_formspec_menu(cur_formspec, invmgr, gamedef, tsrc, device, create_formspec_menu(cur_formspec, client, device, joystick, fs_src, txt_dst);
joystick, fs_src, txt_dst, NULL);
std::string con("btn_continue"); std::string con("btn_continue");
(*cur_formspec)->setFocus(con); (*cur_formspec)->setFocus(con);
(*cur_formspec)->doPause = true; (*cur_formspec)->doPause = true;
@ -1534,7 +1530,6 @@ private:
bool *kill; bool *kill;
std::string *error_message; std::string *error_message;
bool *reconnect_requested; bool *reconnect_requested;
IGameDef *gamedef; // Convenience (same as *client)
scene::ISceneNode *skybox; scene::ISceneNode *skybox;
bool random_input; bool random_input;
@ -2011,7 +2006,7 @@ bool Game::createClient(const std::string &playername,
/* Camera /* Camera
*/ */
camera = new Camera(smgr, *draw_control, gamedef); camera = new Camera(smgr, *draw_control, client);
if (!camera || !camera->successfullyCreated(*error_message)) if (!camera || !camera->successfullyCreated(*error_message))
return false; return false;
client->setCamera(camera); client->setCamera(camera);
@ -2068,7 +2063,7 @@ bool Game::createClient(const std::string &playername,
player->hurt_tilt_timer = 0; player->hurt_tilt_timer = 0;
player->hurt_tilt_strength = 0; player->hurt_tilt_strength = 0;
hud = new Hud(driver, smgr, guienv, gamedef, player, local_inventory); hud = new Hud(driver, smgr, guienv, client, player, local_inventory);
if (!hud) { if (!hud) {
*error_message = "Memory error: could not create HUD"; *error_message = "Memory error: could not create HUD";
@ -2198,8 +2193,6 @@ bool Game::connectToServer(const std::string &playername,
if (!client) if (!client)
return false; return false;
gamedef = client; // Client acts as our GameDef
infostream << "Connecting to server at "; infostream << "Connecting to server at ";
connect_address.print(&infostream); connect_address.print(&infostream);
infostream << std::endl; infostream << std::endl;
@ -2445,7 +2438,7 @@ inline bool Game::handleCallbacks()
void Game::processQueues() void Game::processQueues()
{ {
texture_src->processQueue(); texture_src->processQueue();
itemdef_manager->processQueue(gamedef); itemdef_manager->processQueue(client);
shader_src->processQueue(); shader_src->processQueue();
} }
@ -2617,7 +2610,7 @@ void Game::processKeyInput(VolatileRunFlags *flags,
openInventory(); openInventory();
} else if (wasKeyDown(KeyType::ESC) || input->wasKeyDown(CancelKey)) { } else if (wasKeyDown(KeyType::ESC) || input->wasKeyDown(CancelKey)) {
if (!gui_chat_console->isOpenInhibited()) { if (!gui_chat_console->isOpenInhibited()) {
show_pause_menu(&current_formspec, client, gamedef, show_pause_menu(&current_formspec, client,
texture_src, device, &input->joystick, texture_src, device, &input->joystick,
simple_singleplayer_mode); simple_singleplayer_mode);
} }
@ -2769,8 +2762,7 @@ void Game::openInventory()
PlayerInventoryFormSource *fs_src = new PlayerInventoryFormSource(client); PlayerInventoryFormSource *fs_src = new PlayerInventoryFormSource(client);
TextDest *txt_dst = new TextDestPlayerInventory(client); TextDest *txt_dst = new TextDestPlayerInventory(client);
create_formspec_menu(&current_formspec, client, gamedef, texture_src, create_formspec_menu(&current_formspec, client, device, &input->joystick, fs_src, txt_dst);
device, &input->joystick, fs_src, txt_dst, client);
cur_formname = ""; cur_formname = "";
InventoryLocation inventoryloc; InventoryLocation inventoryloc;
@ -3245,13 +3237,13 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
rangelim(event.player_damage.amount / 4, 1.0, 4.0); rangelim(event.player_damage.amount / 4, 1.0, 4.0);
MtEvent *e = new SimpleTriggerEvent("PlayerDamage"); MtEvent *e = new SimpleTriggerEvent("PlayerDamage");
gamedef->event()->put(e); client->event()->put(e);
} else if (event.type == CE_PLAYER_FORCE_MOVE) { } else if (event.type == CE_PLAYER_FORCE_MOVE) {
cam->camera_yaw = event.player_force_move.yaw; cam->camera_yaw = event.player_force_move.yaw;
cam->camera_pitch = event.player_force_move.pitch; cam->camera_pitch = event.player_force_move.pitch;
} else if (event.type == CE_DEATHSCREEN) { } else if (event.type == CE_DEATHSCREEN) {
show_deathscreen(&current_formspec, client, gamedef, texture_src, show_deathscreen(&current_formspec, client, texture_src,
device, &input->joystick, client); device, &input->joystick);
chat_backend->addMessage(L"", L"You died."); chat_backend->addMessage(L"", L"You died.");
@ -3271,9 +3263,8 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
TextDestPlayerInventory *txt_dst = TextDestPlayerInventory *txt_dst =
new TextDestPlayerInventory(client, *(event.show_formspec.formname)); new TextDestPlayerInventory(client, *(event.show_formspec.formname));
create_formspec_menu(&current_formspec, client, gamedef, create_formspec_menu(&current_formspec, client, device, &input->joystick,
texture_src, device, &input->joystick, fs_src, txt_dst);
fs_src, txt_dst, client);
cur_formname = *(event.show_formspec.formname); cur_formname = *(event.show_formspec.formname);
} }
@ -3282,7 +3273,7 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
} else if ((event.type == CE_SPAWN_PARTICLE) || } else if ((event.type == CE_SPAWN_PARTICLE) ||
(event.type == CE_ADD_PARTICLESPAWNER) || (event.type == CE_ADD_PARTICLESPAWNER) ||
(event.type == CE_DELETE_PARTICLESPAWNER)) { (event.type == CE_DELETE_PARTICLESPAWNER)) {
client->getParticleManager()->handleParticleEvent(&event, gamedef, client->getParticleManager()->handleParticleEvent(&event, client,
smgr, player); smgr, player);
} else if (event.type == CE_HUDADD) { } else if (event.type == CE_HUDADD) {
u32 id = event.hudadd.id; u32 id = event.hudadd.id;
@ -3840,8 +3831,8 @@ void Game::handlePointingAtNode(GameRunData *runData,
&client->getEnv().getClientMap(), nodepos); &client->getEnv().getClientMap(), nodepos);
TextDest *txt_dst = new TextDestNodeMetadata(nodepos, client); TextDest *txt_dst = new TextDestNodeMetadata(nodepos, client);
create_formspec_menu(&current_formspec, client, gamedef, create_formspec_menu(&current_formspec, client,
texture_src, device, &input->joystick, fs_src, txt_dst, client); device, &input->joystick, fs_src, txt_dst);
cur_formname = ""; cur_formname = "";
current_formspec->setFormSpec(meta->getString("formspec"), inventoryloc); current_formspec->setFormSpec(meta->getString("formspec"), inventoryloc);
@ -3972,7 +3963,7 @@ void Game::handleDigging(GameRunData *runData,
if (m_cache_enable_particles) { if (m_cache_enable_particles) {
const ContentFeatures &features = const ContentFeatures &features =
client->getNodeDefManager()->get(n); client->getNodeDefManager()->get(n);
client->getParticleManager()->addPunchingParticles(gamedef, smgr, client->getParticleManager()->addPunchingParticles(client, smgr,
player, nodepos, features.tiles); player, nodepos, features.tiles);
} }
} }
@ -4019,7 +4010,7 @@ void Game::handleDigging(GameRunData *runData,
if (m_cache_enable_particles) { if (m_cache_enable_particles) {
const ContentFeatures &features = const ContentFeatures &features =
client->getNodeDefManager()->get(wasnode); client->getNodeDefManager()->get(wasnode);
client->getParticleManager()->addDiggingParticles(gamedef, smgr, client->getParticleManager()->addDiggingParticles(client, smgr,
player, nodepos, features.tiles); player, nodepos, features.tiles);
} }
@ -4043,7 +4034,7 @@ void Game::handleDigging(GameRunData *runData,
// Send event to trigger sound // Send event to trigger sound
MtEvent *e = new NodeDugEvent(nodepos, wasnode); MtEvent *e = new NodeDugEvent(nodepos, wasnode);
gamedef->event()->put(e); client->event()->put(e);
} }
if (runData->dig_time_complete < 100000.0) { if (runData->dig_time_complete < 100000.0) {

@ -53,47 +53,22 @@ public:
virtual INodeDefManager* getNodeDefManager()=0; virtual INodeDefManager* getNodeDefManager()=0;
virtual ICraftDefManager* getCraftDefManager()=0; virtual ICraftDefManager* getCraftDefManager()=0;
// This is always thread-safe, but referencing the irrlicht texture
// pointers in other threads than main thread will make things explode.
virtual ITextureSource* getTextureSource()=0;
virtual IShaderSource* getShaderSource()=0;
// Used for keeping track of names/ids of unknown nodes // Used for keeping track of names/ids of unknown nodes
virtual u16 allocateUnknownNodeId(const std::string &name)=0; virtual u16 allocateUnknownNodeId(const std::string &name)=0;
// Only usable on the client
virtual ISoundManager* getSoundManager()=0;
virtual MtEventManager* getEventManager()=0; virtual MtEventManager* getEventManager()=0;
virtual scene::IAnimatedMesh* getMesh(const std::string &filename)
{ return NULL; }
virtual scene::ISceneManager* getSceneManager()=0;
virtual Camera* getCamera()
{ return NULL; }
virtual void setCamera(Camera *camera) {}
// Only usable on the server, and NOT thread-safe. It is usable from the // Only usable on the server, and NOT thread-safe. It is usable from the
// environment thread. // environment thread.
virtual IRollbackManager* getRollbackManager(){return NULL;} virtual IRollbackManager* getRollbackManager() { return NULL; }
// Only usable on the server. Thread safe if not written while running threads.
virtual EmergeManager *getEmergeManager() { return NULL; }
// Used on the client
virtual bool checkLocalPrivilege(const std::string &priv)
{ return false; }
// Shorthands // Shorthands
IItemDefManager *idef() { return getItemDefManager(); } IItemDefManager *idef() { return getItemDefManager(); }
INodeDefManager *ndef() { return getNodeDefManager(); } INodeDefManager *ndef() { return getNodeDefManager(); }
ICraftDefManager *cdef() { return getCraftDefManager(); } ICraftDefManager *cdef() { return getCraftDefManager(); }
ITextureSource *tsrc() { return getTextureSource(); }
ISoundManager *sound() { return getSoundManager(); }
IShaderSource *shsrc() { return getShaderSource(); }
MtEventManager *event() { return getEventManager(); } MtEventManager *event() { return getEventManager(); }
IRollbackManager *rollback() { return getRollbackManager();} IRollbackManager *rollback() { return getRollbackManager();}
EmergeManager *emerge() { return getEmergeManager(); }
}; };
#endif #endif

@ -194,11 +194,9 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
-1, -1,
m_menumanager, m_menumanager,
NULL /* &client */, NULL /* &client */,
NULL /* gamedef */,
m_texture_source, m_texture_source,
m_formspecgui, m_formspecgui,
m_buttonhandler, m_buttonhandler,
NULL,
false); false);
m_menu->allowClose(false); m_menu->allowClose(false);

@ -81,13 +81,12 @@ static unsigned int font_line_height(gui::IGUIFont *font)
GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev, GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
JoystickController *joystick, JoystickController *joystick,
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr,
InventoryManager *invmgr, IGameDef *gamedef, Client *client,
ISimpleTextureSource *tsrc, IFormSource* fsrc, TextDest* tdst, ISimpleTextureSource *tsrc, IFormSource* fsrc, TextDest* tdst,
Client* client, bool remap_dbl_click) : bool remap_dbl_click) :
GUIModalMenu(dev->getGUIEnvironment(), parent, id, menumgr), GUIModalMenu(dev->getGUIEnvironment(), parent, id, menumgr),
m_device(dev), m_device(dev),
m_invmgr(invmgr), m_invmgr(client),
m_gamedef(gamedef),
m_tsrc(tsrc), m_tsrc(tsrc),
m_client(client), m_client(client),
m_selected_item(NULL), m_selected_item(NULL),
@ -307,8 +306,8 @@ void GUIFormSpecMenu::parseContainerEnd(parserData* data)
void GUIFormSpecMenu::parseList(parserData* data,std::string element) void GUIFormSpecMenu::parseList(parserData* data,std::string element)
{ {
if (m_gamedef == 0) { if (m_client == 0) {
warningstream<<"invalid use of 'list' with m_gamedef==0"<<std::endl; warningstream<<"invalid use of 'list' with m_client==0"<<std::endl;
return; return;
} }
@ -362,8 +361,8 @@ void GUIFormSpecMenu::parseList(parserData* data,std::string element)
void GUIFormSpecMenu::parseListRing(parserData* data, std::string element) void GUIFormSpecMenu::parseListRing(parserData* data, std::string element)
{ {
if (m_gamedef == 0) { if (m_client == 0) {
errorstream << "WARNING: invalid use of 'listring' with m_gamedef==0" << std::endl; errorstream << "WARNING: invalid use of 'listring' with m_client==0" << std::endl;
return; return;
} }
@ -1486,8 +1485,8 @@ void GUIFormSpecMenu::parseTabHeader(parserData* data,std::string element)
void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element) void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
{ {
if (m_gamedef == 0) { if (m_client == 0) {
warningstream << "invalid use of item_image_button with m_gamedef==0" warningstream << "invalid use of item_image_button with m_client==0"
<< std::endl; << std::endl;
return; return;
} }
@ -1521,7 +1520,7 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
if(!data->explicit_size) if(!data->explicit_size)
warningstream<<"invalid use of item_image_button without a size[] element"<<std::endl; warningstream<<"invalid use of item_image_button without a size[] element"<<std::endl;
IItemDefManager *idef = m_gamedef->idef(); IItemDefManager *idef = m_client->idef();
ItemStack item; ItemStack item;
item.deSerialize(item_name, idef); item.deSerialize(item_name, idef);
@ -2297,14 +2296,14 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase,
if(!item.empty()) if(!item.empty())
{ {
drawItemStack(driver, m_font, item, drawItemStack(driver, m_font, item,
rect, &AbsoluteClippingRect, m_gamedef, rect, &AbsoluteClippingRect, m_client,
rotation_kind); rotation_kind);
} }
// Draw tooltip // Draw tooltip
std::wstring tooltip_text = L""; std::wstring tooltip_text = L"";
if (hovering && !m_selected_item) { if (hovering && !m_selected_item) {
tooltip_text = utf8_to_wide(item.getDefinition(m_gamedef->idef()).description); tooltip_text = utf8_to_wide(item.getDefinition(m_client->idef()).description);
} }
if (tooltip_text != L"") { if (tooltip_text != L"") {
std::vector<std::wstring> tt_rows = str_split(tooltip_text, L'\n'); std::vector<std::wstring> tt_rows = str_split(tooltip_text, L'\n');
@ -2349,7 +2348,7 @@ void GUIFormSpecMenu::drawSelectedItem()
if (!m_selected_item) { if (!m_selected_item) {
drawItemStack(driver, m_font, ItemStack(), drawItemStack(driver, m_font, ItemStack(),
core::rect<s32>(v2s32(0, 0), v2s32(0, 0)), core::rect<s32>(v2s32(0, 0), v2s32(0, 0)),
NULL, m_gamedef, IT_ROT_DRAGGED); NULL, m_client, IT_ROT_DRAGGED);
return; return;
} }
@ -2363,7 +2362,7 @@ void GUIFormSpecMenu::drawSelectedItem()
core::rect<s32> imgrect(0,0,imgsize.X,imgsize.Y); core::rect<s32> imgrect(0,0,imgsize.X,imgsize.Y);
core::rect<s32> rect = imgrect + (m_pointer - imgrect.getCenter()); core::rect<s32> rect = imgrect + (m_pointer - imgrect.getCenter());
rect.constrainTo(driver->getViewPort()); rect.constrainTo(driver->getViewPort());
drawItemStack(driver, m_font, stack, rect, NULL, m_gamedef, IT_ROT_DRAGGED); drawItemStack(driver, m_font, stack, rect, NULL, m_client, IT_ROT_DRAGGED);
} }
void GUIFormSpecMenu::drawMenu() void GUIFormSpecMenu::drawMenu()
@ -2488,11 +2487,11 @@ void GUIFormSpecMenu::drawMenu()
*/ */
for(u32 i=0; i<m_itemimages.size(); i++) for(u32 i=0; i<m_itemimages.size(); i++)
{ {
if (m_gamedef == 0) if (m_client == 0)
break; break;
const ImageDrawSpec &spec = m_itemimages[i]; const ImageDrawSpec &spec = m_itemimages[i];
IItemDefManager *idef = m_gamedef->idef(); IItemDefManager *idef = m_client->idef();
ItemStack item; ItemStack item;
item.deSerialize(spec.item_name, idef); item.deSerialize(spec.item_name, idef);
core::rect<s32> imgrect(0, 0, spec.geom.X, spec.geom.Y); core::rect<s32> imgrect(0, 0, spec.geom.X, spec.geom.Y);
@ -2509,7 +2508,7 @@ void GUIFormSpecMenu::drawMenu()
#endif #endif
} }
drawItemStack(driver, m_font, item, rect, &AbsoluteClippingRect, drawItemStack(driver, m_font, item, rect, &AbsoluteClippingRect,
m_gamedef, IT_ROT_NONE); m_client, IT_ROT_NONE);
} }
/* /*
@ -2527,7 +2526,7 @@ void GUIFormSpecMenu::drawMenu()
if (!item_hovered) { if (!item_hovered) {
drawItemStack(driver, m_font, ItemStack(), drawItemStack(driver, m_font, ItemStack(),
core::rect<s32>(v2s32(0, 0), v2s32(0, 0)), core::rect<s32>(v2s32(0, 0), v2s32(0, 0)),
NULL, m_gamedef, IT_ROT_HOVERED); NULL, m_client, IT_ROT_HOVERED);
} }
/* TODO find way to show tooltips on touchscreen */ /* TODO find way to show tooltips on touchscreen */
@ -3470,7 +3469,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
// Check how many items can be moved // Check how many items can be moved
move_amount = stack_from.count = MYMIN(move_amount, stack_from.count); move_amount = stack_from.count = MYMIN(move_amount, stack_from.count);
ItemStack leftover = stack_to.addItem(stack_from, m_gamedef->idef()); ItemStack leftover = stack_to.addItem(stack_from, m_client->idef());
// If source stack cannot be added to destination stack at all, // If source stack cannot be added to destination stack at all,
// they are swapped // they are swapped
if ((leftover.count == stack_from.count) && if ((leftover.count == stack_from.count) &&

@ -34,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h" #include "util/string.h"
#include "util/enriched_string.h" #include "util/enriched_string.h"
class IGameDef;
class InventoryManager; class InventoryManager;
class ISimpleTextureSource; class ISimpleTextureSource;
class Client; class Client;
@ -289,12 +288,10 @@ public:
JoystickController *joystick, JoystickController *joystick,
gui::IGUIElement* parent, s32 id, gui::IGUIElement* parent, s32 id,
IMenuManager *menumgr, IMenuManager *menumgr,
InventoryManager *invmgr, Client *client,
IGameDef *gamedef,
ISimpleTextureSource *tsrc, ISimpleTextureSource *tsrc,
IFormSource* fs_src, IFormSource* fs_src,
TextDest* txt_dst, TextDest* txt_dst,
Client* client,
bool remap_dbl_click = true); bool remap_dbl_click = true);
~GUIFormSpecMenu(); ~GUIFormSpecMenu();
@ -384,7 +381,6 @@ protected:
irr::IrrlichtDevice* m_device; irr::IrrlichtDevice* m_device;
InventoryManager *m_invmgr; InventoryManager *m_invmgr;
IGameDef *m_gamedef;
ISimpleTextureSource *m_tsrc; ISimpleTextureSource *m_tsrc;
Client *m_client; Client *m_client;

@ -22,10 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "hud.h" #include "hud.h"
#include "settings.h" #include "settings.h"
#include "util/numeric.h" #include "util/numeric.h"
#include "util/string.h"
#include "log.h" #include "log.h"
#include "gamedef.h" #include "client.h"
#include "itemdef.h"
#include "inventory.h" #include "inventory.h"
#include "client/tile.h" #include "client/tile.h"
#include "localplayer.h" #include "localplayer.h"
@ -41,13 +39,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif #endif
Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr, Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
gui::IGUIEnvironment* guienv, IGameDef *gamedef, LocalPlayer *player, gui::IGUIEnvironment* guienv, Client *client, LocalPlayer *player,
Inventory *inventory) Inventory *inventory)
{ {
this->driver = driver; this->driver = driver;
this->smgr = smgr; this->smgr = smgr;
this->guienv = guienv; this->guienv = guienv;
this->gamedef = gamedef; this->client = client;
this->player = player; this->player = player;
this->inventory = inventory; this->inventory = inventory;
@ -61,7 +59,7 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
for (unsigned int i = 0; i < 4; i++) for (unsigned int i = 0; i < 4; i++)
hbar_colors[i] = video::SColor(255, 255, 255, 255); hbar_colors[i] = video::SColor(255, 255, 255, 255);
tsrc = gamedef->getTextureSource(); tsrc = client->getTextureSource();
v3f crosshair_color = g_settings->getV3F("crosshair_color"); v3f crosshair_color = g_settings->getV3F("crosshair_color");
u32 cross_r = rangelim(myround(crosshair_color.X), 0, 255); u32 cross_r = rangelim(myround(crosshair_color.X), 0, 255);
@ -92,7 +90,7 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
m_selection_material.Lighting = false; m_selection_material.Lighting = false;
if (g_settings->getBool("enable_shaders")) { if (g_settings->getBool("enable_shaders")) {
IShaderSource *shdrsrc = gamedef->getShaderSource(); IShaderSource *shdrsrc = client->getShaderSource();
u16 shader_id = shdrsrc->getShader( u16 shader_id = shdrsrc->getShader(
mode == "halo" ? "selection_shader" : "default_shader", 1, 1); mode == "halo" ? "selection_shader" : "default_shader", 1, 1);
m_selection_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material; m_selection_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material;
@ -193,7 +191,7 @@ void Hud::drawItem(const ItemStack &item, const core::rect<s32>& rect,
if (!use_hotbar_image) if (!use_hotbar_image)
driver->draw2DRectangle(bgcolor2, rect, NULL); driver->draw2DRectangle(bgcolor2, rect, NULL);
drawItemStack(driver, g_fontengine->getFont(), item, rect, NULL, drawItemStack(driver, g_fontengine->getFont(), item, rect, NULL,
gamedef, selected ? IT_ROT_SELECTED : IT_ROT_NONE); client, selected ? IT_ROT_SELECTED : IT_ROT_NONE);
} }
//NOTE: selectitem = 0 -> no selected; selectitem 1-based //NOTE: selectitem = 0 -> no selected; selectitem 1-based
@ -629,7 +627,7 @@ void drawItemStack(video::IVideoDriver *driver,
const ItemStack &item, const ItemStack &item,
const core::rect<s32> &rect, const core::rect<s32> &rect,
const core::rect<s32> *clip, const core::rect<s32> *clip,
IGameDef *gamedef, Client *client,
ItemRotationKind rotation_kind) ItemRotationKind rotation_kind)
{ {
static MeshTimeInfo rotation_time_infos[IT_ROT_NONE]; static MeshTimeInfo rotation_time_infos[IT_ROT_NONE];
@ -643,8 +641,8 @@ void drawItemStack(video::IVideoDriver *driver,
return; return;
} }
const ItemDefinition &def = item.getDefinition(gamedef->idef()); const ItemDefinition &def = item.getDefinition(client->idef());
scene::IMesh* mesh = gamedef->idef()->getWieldMesh(def.name, gamedef); scene::IMesh* mesh = client->idef()->getWieldMesh(def.name, client);
if (mesh) { if (mesh) {
driver->clearZBuffer(); driver->clearZBuffer();

@ -95,7 +95,7 @@ struct HudElement {
#include <IGUIFont.h> #include <IGUIFont.h>
#include "irr_aabb3d.h" #include "irr_aabb3d.h"
class IGameDef; class Client;
class ITextureSource; class ITextureSource;
class Inventory; class Inventory;
class InventoryList; class InventoryList;
@ -107,7 +107,7 @@ public:
video::IVideoDriver *driver; video::IVideoDriver *driver;
scene::ISceneManager* smgr; scene::ISceneManager* smgr;
gui::IGUIEnvironment *guienv; gui::IGUIEnvironment *guienv;
IGameDef *gamedef; Client *client;
LocalPlayer *player; LocalPlayer *player;
Inventory *inventory; Inventory *inventory;
ITextureSource *tsrc; ITextureSource *tsrc;
@ -121,7 +121,7 @@ public:
bool use_hotbar_selected_image; bool use_hotbar_selected_image;
Hud(video::IVideoDriver *driver,scene::ISceneManager* smgr, Hud(video::IVideoDriver *driver,scene::ISceneManager* smgr,
gui::IGUIEnvironment* guienv, IGameDef *gamedef, LocalPlayer *player, gui::IGUIEnvironment* guienv, Client *client, LocalPlayer *player,
Inventory *inventory); Inventory *inventory);
~Hud(); ~Hud();
@ -190,7 +190,7 @@ void drawItemStack(video::IVideoDriver *driver,
const ItemStack &item, const ItemStack &item,
const core::rect<s32> &rect, const core::rect<s32> &rect,
const core::rect<s32> *clip, const core::rect<s32> *clip,
IGameDef *gamedef, Client *client,
ItemRotationKind rotation_kind); ItemRotationKind rotation_kind);
#endif #endif

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

@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemgroup.h" #include "itemgroup.h"
#include "sound.h" #include "sound.h"
class IGameDef; class IGameDef;
class Client;
struct ToolCapabilities; struct ToolCapabilities;
/* /*
@ -107,10 +108,10 @@ public:
#ifndef SERVER #ifndef SERVER
// Get item inventory texture // Get item inventory texture
virtual video::ITexture* getInventoryTexture(const std::string &name, virtual video::ITexture* getInventoryTexture(const std::string &name,
IGameDef *gamedef) const=0; Client *client) const=0;
// Get item wield mesh // Get item wield mesh
virtual scene::IMesh* getWieldMesh(const std::string &name, virtual scene::IMesh* getWieldMesh(const std::string &name,
IGameDef *gamedef) const=0; Client *client) const=0;
#endif #endif
virtual void serialize(std::ostream &os, u16 protocol_version)=0; virtual void serialize(std::ostream &os, u16 protocol_version)=0;
@ -133,10 +134,10 @@ public:
#ifndef SERVER #ifndef SERVER
// Get item inventory texture // Get item inventory texture
virtual video::ITexture* getInventoryTexture(const std::string &name, virtual video::ITexture* getInventoryTexture(const std::string &name,
IGameDef *gamedef) const=0; Client *client) const=0;
// Get item wield mesh // Get item wield mesh
virtual scene::IMesh* getWieldMesh(const std::string &name, virtual scene::IMesh* getWieldMesh(const std::string &name,
IGameDef *gamedef) const=0; Client *client) const=0;
#endif #endif
// Remove all registered item and node definitions and aliases // Remove all registered item and node definitions and aliases

@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "event.h" #include "event.h"
#include "collision.h" #include "collision.h"
#include "gamedef.h"
#include "nodedef.h" #include "nodedef.h"
#include "settings.h" #include "settings.h"
#include "environment.h" #include "environment.h"
@ -32,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
LocalPlayer LocalPlayer
*/ */
LocalPlayer::LocalPlayer(Client *gamedef, const char *name): LocalPlayer::LocalPlayer(Client *client, const char *name):
Player(name, gamedef->idef()), Player(name, client->idef()),
parent(0), parent(0),
hp(PLAYER_MAX_HP), hp(PLAYER_MAX_HP),
got_teleported(false), got_teleported(false),
@ -79,7 +78,7 @@ LocalPlayer::LocalPlayer(Client *gamedef, const char *name):
camera_barely_in_ceiling(false), camera_barely_in_ceiling(false),
m_collisionbox(-BS * 0.30, 0.0, -BS * 0.30, BS * 0.30, BS * 1.75, BS * 0.30), m_collisionbox(-BS * 0.30, 0.0, -BS * 0.30, BS * 0.30, BS * 1.75, BS * 0.30),
m_cao(NULL), m_cao(NULL),
m_gamedef(gamedef) m_client(client)
{ {
// Initialize hp to 0, so that no hearts will be shown if server // Initialize hp to 0, so that no hearts will be shown if server
// doesn't support health points // doesn't support health points
@ -96,7 +95,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
std::vector<CollisionInfo> *collision_info) std::vector<CollisionInfo> *collision_info)
{ {
Map *map = &env->getMap(); Map *map = &env->getMap();
INodeDefManager *nodemgr = m_gamedef->ndef(); INodeDefManager *nodemgr = m_client->ndef();
v3f position = getPosition(); v3f position = getPosition();
@ -109,8 +108,8 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
} }
// Skip collision detection if noclip mode is used // Skip collision detection if noclip mode is used
bool fly_allowed = m_gamedef->checkLocalPrivilege("fly"); bool fly_allowed = m_client->checkLocalPrivilege("fly");
bool noclip = m_gamedef->checkLocalPrivilege("noclip") && bool noclip = m_client->checkLocalPrivilege("noclip") &&
g_settings->getBool("noclip"); g_settings->getBool("noclip");
bool free_move = noclip && fly_allowed && g_settings->getBool("free_move"); bool free_move = noclip && fly_allowed && g_settings->getBool("free_move");
if (free_move) { if (free_move) {
@ -241,7 +240,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
v3f accel_f = v3f(0,0,0); v3f accel_f = v3f(0,0,0);
collisionMoveResult result = collisionMoveSimple(env, m_gamedef, collisionMoveResult result = collisionMoveSimple(env, m_client,
pos_max_d, m_collisionbox, player_stepheight, dtime, pos_max_d, m_collisionbox, player_stepheight, dtime,
&position, &m_speed, accel_f); &position, &m_speed, accel_f);
@ -376,7 +375,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
if(!result.standing_on_object && !touching_ground_was && touching_ground) { if(!result.standing_on_object && !touching_ground_was && touching_ground) {
MtEvent *e = new SimpleTriggerEvent("PlayerRegainGround"); MtEvent *e = new SimpleTriggerEvent("PlayerRegainGround");
m_gamedef->event()->put(e); m_client->event()->put(e);
// Set camera impact value to be used for view bobbing // Set camera impact value to be used for view bobbing
camera_impact = getSpeed().Y * -1; camera_impact = getSpeed().Y * -1;
@ -448,8 +447,8 @@ void LocalPlayer::applyControl(float dtime)
v3f speedH = v3f(0,0,0); // Horizontal (X, Z) v3f speedH = v3f(0,0,0); // Horizontal (X, Z)
v3f speedV = v3f(0,0,0); // Vertical (Y) v3f speedV = v3f(0,0,0); // Vertical (Y)
bool fly_allowed = m_gamedef->checkLocalPrivilege("fly"); bool fly_allowed = m_client->checkLocalPrivilege("fly");
bool fast_allowed = m_gamedef->checkLocalPrivilege("fast"); bool fast_allowed = m_client->checkLocalPrivilege("fast");
bool free_move = fly_allowed && g_settings->getBool("free_move"); bool free_move = fly_allowed && g_settings->getBool("free_move");
bool fast_move = fast_allowed && g_settings->getBool("fast_move"); bool fast_move = fast_allowed && g_settings->getBool("fast_move");
@ -599,7 +598,7 @@ void LocalPlayer::applyControl(float dtime)
setSpeed(speedJ); setSpeed(speedJ);
MtEvent *e = new SimpleTriggerEvent("PlayerJump"); MtEvent *e = new SimpleTriggerEvent("PlayerJump");
m_gamedef->event()->put(e); m_client->event()->put(e);
} }
} }
else if(in_liquid) else if(in_liquid)

@ -35,7 +35,7 @@ enum LocalPlayerAnimations {NO_ANIM, WALK_ANIM, DIG_ANIM, WD_ANIM}; // no local
class LocalPlayer : public Player class LocalPlayer : public Player
{ {
public: public:
LocalPlayer(Client *gamedef, const char *name); LocalPlayer(Client *client, const char *name);
virtual ~LocalPlayer(); virtual ~LocalPlayer();
ClientActiveObject *parent; ClientActiveObject *parent;
@ -162,7 +162,7 @@ private:
aabb3f m_collisionbox; aabb3f m_collisionbox;
GenericCAO* m_cao; GenericCAO* m_cao;
Client *m_gamedef; Client *m_client;
}; };
#endif #endif

@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h" #include "map.h"
#include "profiler.h" #include "profiler.h"
#include "nodedef.h" #include "nodedef.h"
#include "gamedef.h"
#include "mesh.h" #include "mesh.h"
#include "minimap.h" #include "minimap.h"
#include "content_mapblock.h" #include "content_mapblock.h"
@ -43,14 +42,14 @@ static void applyFacesShading(video::SColor &color, const float factor)
MeshMakeData MeshMakeData
*/ */
MeshMakeData::MeshMakeData(IGameDef *gamedef, bool use_shaders, MeshMakeData::MeshMakeData(Client *client, bool use_shaders,
bool use_tangent_vertices): bool use_tangent_vertices):
m_vmanip(), m_vmanip(),
m_blockpos(-1337,-1337,-1337), m_blockpos(-1337,-1337,-1337),
m_crack_pos_relative(-1337, -1337, -1337), m_crack_pos_relative(-1337, -1337, -1337),
m_smooth_lighting(false), m_smooth_lighting(false),
m_show_hud(false), m_show_hud(false),
m_gamedef(gamedef), m_client(client),
m_use_shaders(use_shaders), m_use_shaders(use_shaders),
m_use_tangent_vertices(use_tangent_vertices) m_use_tangent_vertices(use_tangent_vertices)
{} {}
@ -233,7 +232,7 @@ static u16 getSmoothLightCombined(v3s16 p, MeshMakeData *data)
v3s16(1,1,1), v3s16(1,1,1),
}; };
INodeDefManager *ndef = data->m_gamedef->ndef(); INodeDefManager *ndef = data->m_client->ndef();
u16 ambient_occlusion = 0; u16 ambient_occlusion = 0;
u16 light_count = 0; u16 light_count = 0;
@ -664,7 +663,7 @@ static u8 face_contents(content_t m1, content_t m2, bool *equivalent,
*/ */
TileSpec getNodeTileN(MapNode mn, v3s16 p, u8 tileindex, MeshMakeData *data) TileSpec getNodeTileN(MapNode mn, v3s16 p, u8 tileindex, MeshMakeData *data)
{ {
INodeDefManager *ndef = data->m_gamedef->ndef(); INodeDefManager *ndef = data->m_client->ndef();
TileSpec spec = ndef->get(mn).tiles[tileindex]; TileSpec spec = ndef->get(mn).tiles[tileindex];
// Apply temporary crack // Apply temporary crack
if (p == data->m_crack_pos_relative) if (p == data->m_crack_pos_relative)
@ -677,7 +676,7 @@ TileSpec getNodeTileN(MapNode mn, v3s16 p, u8 tileindex, MeshMakeData *data)
*/ */
TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 dir, MeshMakeData *data) TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 dir, MeshMakeData *data)
{ {
INodeDefManager *ndef = data->m_gamedef->ndef(); INodeDefManager *ndef = data->m_client->ndef();
// Direction must be (1,0,0), (-1,0,0), (0,1,0), (0,-1,0), // Direction must be (1,0,0), (-1,0,0), (0,1,0), (0,-1,0),
// (0,0,1), (0,0,-1) or (0,0,0) // (0,0,1), (0,0,-1) or (0,0,0)
@ -734,7 +733,7 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 dir, MeshMakeData *data)
u16 tile_index=facedir*16 + dir_i; u16 tile_index=facedir*16 + dir_i;
TileSpec spec = getNodeTileN(mn, p, dir_to_tile[tile_index], data); TileSpec spec = getNodeTileN(mn, p, dir_to_tile[tile_index], data);
spec.rotation=dir_to_tile[tile_index + 1]; spec.rotation=dir_to_tile[tile_index + 1];
spec.texture = data->m_gamedef->tsrc()->getTexture(spec.texture_id); spec.texture = data->m_client->tsrc()->getTexture(spec.texture_id);
return spec; return spec;
} }
@ -753,7 +752,7 @@ static void getTileInfo(
) )
{ {
VoxelManipulator &vmanip = data->m_vmanip; VoxelManipulator &vmanip = data->m_vmanip;
INodeDefManager *ndef = data->m_gamedef->ndef(); INodeDefManager *ndef = data->m_client->ndef();
v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE; v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
MapNode &n0 = vmanip.getNodeRefUnsafe(blockpos_nodes + p); MapNode &n0 = vmanip.getNodeRefUnsafe(blockpos_nodes + p);
@ -1020,10 +1019,10 @@ static void updateAllFastFaceRows(MeshMakeData *data,
MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
m_mesh(new scene::SMesh()), m_mesh(new scene::SMesh()),
m_minimap_mapblock(NULL), m_minimap_mapblock(NULL),
m_gamedef(data->m_gamedef), m_client(data->m_client),
m_driver(m_gamedef->tsrc()->getDevice()->getVideoDriver()), m_driver(m_client->tsrc()->getDevice()->getVideoDriver()),
m_tsrc(m_gamedef->getTextureSource()), m_tsrc(m_client->getTextureSource()),
m_shdrsrc(m_gamedef->getShaderSource()), m_shdrsrc(m_client->getShaderSource()),
m_animation_force_timer(0), // force initial animation m_animation_force_timer(0), // force initial animation
m_last_crack(-1), m_last_crack(-1),
m_crack_materials(), m_crack_materials(),
@ -1243,7 +1242,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
if (m_use_tangent_vertices) { if (m_use_tangent_vertices) {
scene::IMeshManipulator* meshmanip = scene::IMeshManipulator* meshmanip =
m_gamedef->getSceneManager()->getMeshManipulator(); m_client->getSceneManager()->getMeshManipulator();
meshmanip->recalculateTangents(m_mesh, true, false, false); meshmanip->recalculateTangents(m_mesh, true, false, false);
} }

@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/cpp11_container.h" #include "util/cpp11_container.h"
#include <map> #include <map>
class IGameDef; class Client;
class IShaderSource; class IShaderSource;
/* /*
@ -45,11 +45,11 @@ struct MeshMakeData
bool m_smooth_lighting; bool m_smooth_lighting;
bool m_show_hud; bool m_show_hud;
IGameDef *m_gamedef; Client *m_client;
bool m_use_shaders; bool m_use_shaders;
bool m_use_tangent_vertices; bool m_use_tangent_vertices;
MeshMakeData(IGameDef *gamedef, bool use_shaders, MeshMakeData(Client *client, bool use_shaders,
bool use_tangent_vertices = false); bool use_tangent_vertices = false);
/* /*
@ -128,7 +128,7 @@ public:
private: private:
scene::IMesh *m_mesh; scene::IMesh *m_mesh;
MinimapMapblock *m_minimap_mapblock; MinimapMapblock *m_minimap_mapblock;
IGameDef *m_gamedef; Client *m_client;
video::IVideoDriver *m_driver; video::IVideoDriver *m_driver;
ITextureSource *m_tsrc; ITextureSource *m_tsrc;
IShaderSource *m_shdrsrc; IShaderSource *m_shdrsrc;

@ -20,10 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mg_biome.h" #include "mg_biome.h"
#include "mg_decoration.h" #include "mg_decoration.h"
#include "emerge.h" #include "emerge.h"
#include "gamedef.h" #include "server.h"
#include "nodedef.h" #include "nodedef.h"
#include "map.h" //for MMVManip #include "map.h" //for MMVManip
#include "log.h"
#include "util/numeric.h" #include "util/numeric.h"
#include "util/mathconstants.h" #include "util/mathconstants.h"
#include "porting.h" #include "porting.h"
@ -33,10 +32,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
BiomeManager::BiomeManager(IGameDef *gamedef) : BiomeManager::BiomeManager(Server *server) :
ObjDefManager(gamedef, OBJDEF_BIOME) ObjDefManager(server, OBJDEF_BIOME)
{ {
m_gamedef = gamedef; m_server = server;
// Create default biome to be used in case none exist // Create default biome to be used in case none exist
Biome *b = new Biome; Biome *b = new Biome;
@ -73,7 +72,7 @@ BiomeManager::~BiomeManager()
void BiomeManager::clear() void BiomeManager::clear()
{ {
EmergeManager *emerge = m_gamedef->getEmergeManager(); EmergeManager *emerge = m_server->getEmergeManager();
// Remove all dangling references in Decorations // Remove all dangling references in Decorations
DecorationManager *decomgr = emerge->decomgr; DecorationManager *decomgr = emerge->decomgr;

@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h" #include "nodedef.h"
#include "noise.h" #include "noise.h"
class Server;
class Settings; class Settings;
class BiomeManager; class BiomeManager;
@ -186,7 +187,7 @@ private:
class BiomeManager : public ObjDefManager { class BiomeManager : public ObjDefManager {
public: public:
BiomeManager(IGameDef *gamedef); BiomeManager(Server *server);
virtual ~BiomeManager(); virtual ~BiomeManager();
const char *getObjectTitle() const const char *getObjectTitle() const
@ -223,7 +224,7 @@ public:
virtual void clear(); virtual void clear();
private: private:
IGameDef *m_gamedef; Server *m_server;
}; };

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <fstream> #include <fstream>
#include <typeinfo> #include <typeinfo>
#include "mg_schematic.h" #include "mg_schematic.h"
#include "gamedef.h" #include "server.h"
#include "mapgen.h" #include "mapgen.h"
#include "emerge.h" #include "emerge.h"
#include "map.h" #include "map.h"
@ -34,16 +34,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SchematicManager::SchematicManager(IGameDef *gamedef) : SchematicManager::SchematicManager(Server *server) :
ObjDefManager(gamedef, OBJDEF_SCHEMATIC) ObjDefManager(server, OBJDEF_SCHEMATIC)
{ {
m_gamedef = gamedef; m_server = server;
} }
void SchematicManager::clear() void SchematicManager::clear()
{ {
EmergeManager *emerge = m_gamedef->getEmergeManager(); EmergeManager *emerge = m_server->getEmergeManager();
// Remove all dangling references in Decorations // Remove all dangling references in Decorations
DecorationManager *decomgr = emerge->decomgr; DecorationManager *decomgr = emerge->decomgr;

@ -29,7 +29,7 @@ class Mapgen;
class MMVManip; class MMVManip;
class PseudoRandom; class PseudoRandom;
class NodeResolver; class NodeResolver;
class IGameDef; class Server;
/* /*
Minetest Schematic File Format Minetest Schematic File Format
@ -123,7 +123,7 @@ public:
class SchematicManager : public ObjDefManager { class SchematicManager : public ObjDefManager {
public: public:
SchematicManager(IGameDef *gamedef); SchematicManager(Server *server);
virtual ~SchematicManager() {} virtual ~SchematicManager() {}
virtual void clear(); virtual void clear();
@ -139,7 +139,7 @@ public:
} }
private: private:
IGameDef *m_gamedef; Server *m_server;
}; };
void generate_nodelist_and_update_ids(MapNode *nodes, size_t nodecount, void generate_nodelist_and_update_ids(MapNode *nodes, size_t nodecount,

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SERVER #ifndef SERVER
#include "client/tile.h" #include "client/tile.h"
#include "mesh.h" #include "mesh.h"
#include "client.h"
#include <IMeshManipulator.h> #include <IMeshManipulator.h>
#endif #endif
#include "log.h" #include "log.h"
@ -572,8 +573,7 @@ void ContentFeatures::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
#ifndef SERVER #ifndef SERVER
void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc, void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
scene::ISceneManager *smgr, scene::IMeshManipulator *meshmanip, scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings)
IGameDef *gamedef, const TextureSettings &tsettings)
{ {
// minimap pixel color - the average color of a texture // minimap pixel color - the average color of a texture
if (tsettings.enable_minimap && tiledef[0].name != "") if (tsettings.enable_minimap && tiledef[0].name != "")
@ -709,7 +709,7 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
if ((drawtype == NDT_MESH) && (mesh != "")) { if ((drawtype == NDT_MESH) && (mesh != "")) {
// Meshnode drawtype // Meshnode drawtype
// Read the mesh and apply scale // Read the mesh and apply scale
mesh_ptr[0] = gamedef->getMesh(mesh); mesh_ptr[0] = client->getMesh(mesh);
if (mesh_ptr[0]){ if (mesh_ptr[0]){
v3f scale = v3f(1.0, 1.0, 1.0) * BS * visual_scale; v3f scale = v3f(1.0, 1.0, 1.0) * BS * visual_scale;
scaleMesh(mesh_ptr[0], scale); scaleMesh(mesh_ptr[0], scale);
@ -1316,9 +1316,11 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
#ifndef SERVER #ifndef SERVER
infostream << "CNodeDefManager::updateTextures(): Updating " infostream << "CNodeDefManager::updateTextures(): Updating "
"textures in node definitions" << std::endl; "textures in node definitions" << std::endl;
ITextureSource *tsrc = gamedef->tsrc();
IShaderSource *shdsrc = gamedef->getShaderSource(); Client *client = (Client *)gamedef;
scene::ISceneManager* smgr = gamedef->getSceneManager(); ITextureSource *tsrc = client->tsrc();
IShaderSource *shdsrc = client->getShaderSource();
scene::ISceneManager* smgr = client->getSceneManager();
scene::IMeshManipulator* meshmanip = smgr->getMeshManipulator(); scene::IMeshManipulator* meshmanip = smgr->getMeshManipulator();
TextureSettings tsettings; TextureSettings tsettings;
tsettings.readSettings(); tsettings.readSettings();
@ -1326,7 +1328,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
u32 size = m_content_features.size(); u32 size = m_content_features.size();
for (u32 i = 0; i < size; i++) { for (u32 i = 0; i < size; i++) {
m_content_features[i].updateTextures(tsrc, shdsrc, smgr, meshmanip, gamedef, tsettings); m_content_features[i].updateTextures(tsrc, shdsrc, meshmanip, client, tsettings);
progress_callback(progress_callback_args, i, size); progress_callback(progress_callback_args, i, size);
} }
#endif #endif

@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SERVER #ifndef SERVER
#include "client/tile.h" #include "client/tile.h"
#include "shader.h" #include "shader.h"
class Client;
#endif #endif
#include "itemgroup.h" #include "itemgroup.h"
#include "sound.h" // SimpleSoundSpec #include "sound.h" // SimpleSoundSpec
@ -322,8 +323,7 @@ struct ContentFeatures
u32 shader_id, bool use_normal_texture, bool backface_culling, u32 shader_id, bool use_normal_texture, bool backface_culling,
u8 alpha, u8 material_type); u8 alpha, u8 material_type);
void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc, void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
scene::ISceneManager *smgr, scene::IMeshManipulator *meshmanip, scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings);
IGameDef *gamedef, const TextureSettings &tsettings);
#endif #endif
}; };

@ -18,11 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "particles.h" #include "particles.h"
#include "constants.h" #include "client.h"
#include "debug.h"
#include "settings.h"
#include "client/tile.h"
#include "gamedef.h"
#include "collision.h" #include "collision.h"
#include <stdlib.h> #include <stdlib.h>
#include "util/numeric.h" #include "util/numeric.h"
@ -452,7 +448,7 @@ void ParticleManager::clearAll ()
} }
} }
void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef, void ParticleManager::handleParticleEvent(ClientEvent *event, Client *client,
scene::ISceneManager* smgr, LocalPlayer *player) scene::ISceneManager* smgr, LocalPlayer *player)
{ {
switch (event->type) { switch (event->type) {
@ -477,9 +473,9 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef,
} }
video::ITexture *texture = video::ITexture *texture =
gamedef->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture)); client->tsrc()->getTextureForMesh(*(event->add_particlespawner.texture));
ParticleSpawner* toadd = new ParticleSpawner(gamedef, smgr, player, ParticleSpawner* toadd = new ParticleSpawner(client, smgr, player,
event->add_particlespawner.amount, event->add_particlespawner.amount,
event->add_particlespawner.spawntime, event->add_particlespawner.spawntime,
*event->add_particlespawner.minpos, *event->add_particlespawner.minpos,
@ -520,9 +516,9 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef,
} }
case CE_SPAWN_PARTICLE: { case CE_SPAWN_PARTICLE: {
video::ITexture *texture = video::ITexture *texture =
gamedef->tsrc()->getTextureForMesh(*(event->spawn_particle.texture)); client->tsrc()->getTextureForMesh(*(event->spawn_particle.texture));
Particle* toadd = new Particle(gamedef, smgr, player, m_env, Particle* toadd = new Particle(client, smgr, player, m_env,
*event->spawn_particle.pos, *event->spawn_particle.pos,
*event->spawn_particle.vel, *event->spawn_particle.vel,
*event->spawn_particle.acc, *event->spawn_particle.acc,

@ -170,7 +170,7 @@ public:
void step (float dtime); void step (float dtime);
void handleParticleEvent(ClientEvent *event,IGameDef *gamedef, void handleParticleEvent(ClientEvent *event, Client *client,
scene::ISceneManager* smgr, LocalPlayer *player); scene::ISceneManager* smgr, LocalPlayer *player);
void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr, void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,

@ -24,12 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "pathfinder.h" #include "pathfinder.h"
#include "serverenvironment.h" #include "serverenvironment.h"
#include "gamedef.h" #include "server.h"
#include "nodedef.h" #include "nodedef.h"
#include "map.h"
#include "log.h"
#include "irr_aabb3d.h"
#include "util/basic_macros.h"
//#define PATHFINDER_DEBUG //#define PATHFINDER_DEBUG
//#define PATHFINDER_CALC_TIME //#define PATHFINDER_CALC_TIME

@ -20,14 +20,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "lua_api/l_nodemeta.h" #include "lua_api/l_nodemeta.h"
#include "lua_api/l_internal.h" #include "lua_api/l_internal.h"
#include "lua_api/l_inventory.h" #include "lua_api/l_inventory.h"
#include "common/c_converter.h"
#include "common/c_content.h" #include "common/c_content.h"
#include "serverenvironment.h" #include "serverenvironment.h"
#include "map.h" #include "map.h"
#include "gamedef.h" #include "server.h"
#include "nodemetadata.h"
/* /*
NodeMetaRef NodeMetaRef

@ -50,7 +50,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_abm.h" #include "content_abm.h"
#include "content_sao.h" #include "content_sao.h"
#include "mods.h" #include "mods.h"
#include "sound.h" // dummySoundManager
#include "event_manager.h" #include "event_manager.h"
#include "serverlist.h" #include "serverlist.h"
#include "util/string.h" #include "util/string.h"
@ -3310,29 +3309,12 @@ ICraftDefManager *Server::getCraftDefManager()
{ {
return m_craftdef; return m_craftdef;
} }
ITextureSource *Server::getTextureSource()
{
return NULL;
}
IShaderSource *Server::getShaderSource()
{
return NULL;
}
scene::ISceneManager *Server::getSceneManager()
{
return NULL;
}
u16 Server::allocateUnknownNodeId(const std::string &name) u16 Server::allocateUnknownNodeId(const std::string &name)
{ {
return m_nodedef->allocateDummy(name); return m_nodedef->allocateDummy(name);
} }
ISoundManager *Server::getSoundManager()
{
return &dummySoundManager;
}
MtEventManager *Server::getEventManager() MtEventManager *Server::getEventManager()
{ {
return m_event; return m_event;

@ -283,13 +283,9 @@ public:
virtual IItemDefManager* getItemDefManager(); virtual IItemDefManager* getItemDefManager();
virtual INodeDefManager* getNodeDefManager(); virtual INodeDefManager* getNodeDefManager();
virtual ICraftDefManager* getCraftDefManager(); virtual ICraftDefManager* getCraftDefManager();
virtual ITextureSource* getTextureSource();
virtual IShaderSource* getShaderSource();
virtual u16 allocateUnknownNodeId(const std::string &name); virtual u16 allocateUnknownNodeId(const std::string &name);
virtual ISoundManager* getSoundManager();
virtual MtEventManager* getEventManager(); virtual MtEventManager* getEventManager();
virtual scene::ISceneManager* getSceneManager(); IRollbackManager *getRollbackManager() { return m_rollback; }
virtual IRollbackManager *getRollbackManager() { return m_rollback; }
virtual EmergeManager *getEmergeManager() { return m_emerge; } virtual EmergeManager *getEmergeManager() { return m_emerge; }
IWritableItemDefManager* getWritableItemDefManager(); IWritableItemDefManager* getWritableItemDefManager();

@ -352,11 +352,11 @@ void ActiveBlockList::update(std::vector<v3s16> &active_positions,
*/ */
ServerEnvironment::ServerEnvironment(ServerMap *map, ServerEnvironment::ServerEnvironment(ServerMap *map,
GameScripting *scriptIface, IGameDef *gamedef, GameScripting *scriptIface, Server *server,
const std::string &path_world) : const std::string &path_world) :
m_map(map), m_map(map),
m_script(scriptIface), m_script(scriptIface),
m_gamedef(gamedef), m_server(server),
m_path_world(path_world), m_path_world(path_world),
m_send_recommended_timer(0), m_send_recommended_timer(0),
m_active_block_interval_overload_skip(0), m_active_block_interval_overload_skip(0),
@ -487,7 +487,7 @@ void ServerEnvironment::kickAllPlayers(AccessDeniedCode reason,
for (std::vector<RemotePlayer *>::iterator it = m_players.begin(); for (std::vector<RemotePlayer *>::iterator it = m_players.begin();
it != m_players.end(); ++it) { it != m_players.end(); ++it) {
RemotePlayer *player = dynamic_cast<RemotePlayer *>(*it); RemotePlayer *player = dynamic_cast<RemotePlayer *>(*it);
((Server*)m_gamedef)->DenyAccessVerCompliant(player->peer_id, m_server->DenyAccessVerCompliant(player->peer_id,
player->protocol_version, reason, str_reason, reconnect); player->protocol_version, reason, str_reason, reconnect);
} }
} }
@ -501,7 +501,7 @@ void ServerEnvironment::saveLoadedPlayers()
it != m_players.end(); it != m_players.end();
++it) { ++it) {
if ((*it)->checkModified()) { if ((*it)->checkModified()) {
(*it)->save(players_path, m_gamedef); (*it)->save(players_path, m_server);
} }
} }
} }
@ -511,7 +511,7 @@ void ServerEnvironment::savePlayer(RemotePlayer *player)
std::string players_path = m_path_world + DIR_DELIM "players"; std::string players_path = m_path_world + DIR_DELIM "players";
fs::CreateDir(players_path); fs::CreateDir(players_path);
player->save(players_path, m_gamedef); player->save(players_path, m_server);
} }
RemotePlayer *ServerEnvironment::loadPlayer(const std::string &playername, PlayerSAO *sao) RemotePlayer *ServerEnvironment::loadPlayer(const std::string &playername, PlayerSAO *sao)
@ -523,7 +523,7 @@ RemotePlayer *ServerEnvironment::loadPlayer(const std::string &playername, Playe
RemotePlayer *player = getPlayer(playername.c_str()); RemotePlayer *player = getPlayer(playername.c_str());
if (!player) { if (!player) {
player = new RemotePlayer("", m_gamedef->idef()); player = new RemotePlayer("", m_server->idef());
newplayer = true; newplayer = true;
} }
@ -632,7 +632,7 @@ void ServerEnvironment::loadMeta()
} catch (SettingNotFoundException &e) { } catch (SettingNotFoundException &e) {
// No problem, this is expected. Just continue with an empty string // No problem, this is expected. Just continue with an empty string
} }
m_lbm_mgr.loadIntroductionTimes(lbm_introduction_times, m_gamedef, m_game_time); m_lbm_mgr.loadIntroductionTimes(lbm_introduction_times, m_server, m_game_time);
m_day_count = args.exists("day_count") ? m_day_count = args.exists("day_count") ?
args.getU64("day_count") : 0; args.getU64("day_count") : 0;
@ -640,7 +640,7 @@ void ServerEnvironment::loadMeta()
void ServerEnvironment::loadDefaultMeta() void ServerEnvironment::loadDefaultMeta()
{ {
m_lbm_mgr.loadIntroductionTimes("", m_gamedef, m_game_time); m_lbm_mgr.loadIntroductionTimes("", m_server, m_game_time);
} }
struct ActiveABM struct ActiveABM
@ -902,7 +902,7 @@ void ServerEnvironment::addLoadingBlockModifierDef(LoadingBlockModifierDef *lbm)
bool ServerEnvironment::setNode(v3s16 p, const MapNode &n) bool ServerEnvironment::setNode(v3s16 p, const MapNode &n)
{ {
INodeDefManager *ndef = m_gamedef->ndef(); INodeDefManager *ndef = m_server->ndef();
MapNode n_old = m_map->getNodeNoEx(p); MapNode n_old = m_map->getNodeNoEx(p);
// Call destructor // Call destructor
@ -929,7 +929,7 @@ bool ServerEnvironment::setNode(v3s16 p, const MapNode &n)
bool ServerEnvironment::removeNode(v3s16 p) bool ServerEnvironment::removeNode(v3s16 p)
{ {
INodeDefManager *ndef = m_gamedef->ndef(); INodeDefManager *ndef = m_server->ndef();
MapNode n_old = m_map->getNodeNoEx(p); MapNode n_old = m_map->getNodeNoEx(p);
// Call destructor // Call destructor

@ -29,6 +29,8 @@ class PlayerSAO;
class ServerEnvironment; class ServerEnvironment;
class ActiveBlockModifier; class ActiveBlockModifier;
class ServerActiveObject; class ServerActiveObject;
class Server;
class GameScripting;
/* /*
{Active, Loading} block modifier interface. {Active, Loading} block modifier interface.
@ -190,7 +192,7 @@ class ServerEnvironment : public Environment
{ {
public: public:
ServerEnvironment(ServerMap *map, GameScripting *scriptIface, ServerEnvironment(ServerMap *map, GameScripting *scriptIface,
IGameDef *gamedef, const std::string &path_world); Server *server, const std::string &path_world);
~ServerEnvironment(); ~ServerEnvironment();
Map & getMap(); Map & getMap();
@ -201,8 +203,8 @@ public:
GameScripting* getScriptIface() GameScripting* getScriptIface()
{ return m_script; } { return m_script; }
IGameDef *getGameDef() Server *getGameDef()
{ return m_gamedef; } { return m_server; }
float getSendRecommendedInterval() float getSendRecommendedInterval()
{ return m_recommended_send_interval; } { return m_recommended_send_interval; }
@ -377,8 +379,8 @@ private:
ServerMap *m_map; ServerMap *m_map;
// Lua state // Lua state
GameScripting* m_script; GameScripting* m_script;
// Game definition // Server definition
IGameDef *m_gamedef; Server *m_server;
// World path // World path
const std::string m_path_world; const std::string m_path_world;
// Active object list // Active object list

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h" #include "settings.h"
#include "wieldmesh.h" #include "wieldmesh.h"
#include "inventory.h" #include "inventory.h"
#include "gamedef.h" #include "client.h"
#include "itemdef.h" #include "itemdef.h"
#include "nodedef.h" #include "nodedef.h"
#include "mesh.h" #include "mesh.h"
@ -283,7 +283,7 @@ void WieldMeshSceneNode::setExtruded(const std::string &imagename,
video::SMaterial &material = m_meshnode->getMaterial(0); video::SMaterial &material = m_meshnode->getMaterial(0);
material.setTexture(0, tsrc->getTextureForMesh(imagename)); material.setTexture(0, tsrc->getTextureForMesh(imagename));
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE; material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE; material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
material.MaterialType = m_material_type; material.MaterialType = m_material_type;
material.setFlag(video::EMF_BACK_FACE_CULLING, true); material.setFlag(video::EMF_BACK_FACE_CULLING, true);
// Enable bi/trilinear filtering only for high resolution textures // Enable bi/trilinear filtering only for high resolution textures
@ -304,12 +304,12 @@ void WieldMeshSceneNode::setExtruded(const std::string &imagename,
} }
} }
void WieldMeshSceneNode::setItem(const ItemStack &item, IGameDef *gamedef) void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
{ {
ITextureSource *tsrc = gamedef->getTextureSource(); ITextureSource *tsrc = client->getTextureSource();
IItemDefManager *idef = gamedef->getItemDefManager(); IItemDefManager *idef = client->getItemDefManager();
IShaderSource *shdrsrc = gamedef->getShaderSource(); IShaderSource *shdrsrc = client->getShaderSource();
INodeDefManager *ndef = gamedef->getNodeDefManager(); INodeDefManager *ndef = client->getNodeDefManager();
const ItemDefinition &def = item.getDefinition(idef); const ItemDefinition &def = item.getDefinition(idef);
const ContentFeatures &f = ndef->get(def.name); const ContentFeatures &f = ndef->get(def.name);
content_t id = ndef->getId(def.name); content_t id = ndef->getId(def.name);
@ -341,7 +341,7 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, IGameDef *gamedef)
} else if (f.drawtype == NDT_NORMAL || f.drawtype == NDT_ALLFACES) { } else if (f.drawtype == NDT_NORMAL || f.drawtype == NDT_ALLFACES) {
setCube(f.tiles, def.wield_scale, tsrc); setCube(f.tiles, def.wield_scale, tsrc);
} else { } else {
MeshMakeData mesh_make_data(gamedef, false); MeshMakeData mesh_make_data(client, false);
MapNode mesh_make_node(id, 255, 0); MapNode mesh_make_node(id, 255, 0);
mesh_make_data.fillSingleNode(&mesh_make_node); mesh_make_data.fillSingleNode(&mesh_make_node);
MapBlockMesh mapblock_mesh(&mesh_make_data, v3s16(0, 0, 0)); MapBlockMesh mapblock_mesh(&mesh_make_data, v3s16(0, 0, 0));
@ -435,11 +435,11 @@ void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh)
m_meshnode->setVisible(true); m_meshnode->setVisible(true);
} }
scene::IMesh *getItemMesh(IGameDef *gamedef, const ItemStack &item) scene::IMesh *getItemMesh(Client *client, const ItemStack &item)
{ {
ITextureSource *tsrc = gamedef->getTextureSource(); ITextureSource *tsrc = client->getTextureSource();
IItemDefManager *idef = gamedef->getItemDefManager(); IItemDefManager *idef = client->getItemDefManager();
INodeDefManager *ndef = gamedef->getNodeDefManager(); INodeDefManager *ndef = client->getNodeDefManager();
const ItemDefinition &def = item.getDefinition(idef); const ItemDefinition &def = item.getDefinition(idef);
const ContentFeatures &f = ndef->get(def.name); const ContentFeatures &f = ndef->get(def.name);
content_t id = ndef->getId(def.name); content_t id = ndef->getId(def.name);
@ -470,7 +470,7 @@ scene::IMesh *getItemMesh(IGameDef *gamedef, const ItemStack &item)
mesh = cloneMesh(g_extrusion_mesh_cache->createCube()); mesh = cloneMesh(g_extrusion_mesh_cache->createCube());
scaleMesh(mesh, v3f(1.2, 1.2, 1.2)); scaleMesh(mesh, v3f(1.2, 1.2, 1.2));
} else { } else {
MeshMakeData mesh_make_data(gamedef, false); MeshMakeData mesh_make_data(client, false);
MapNode mesh_make_node(id, 255, 0); MapNode mesh_make_node(id, 255, 0);
mesh_make_data.fillSingleNode(&mesh_make_node); mesh_make_data.fillSingleNode(&mesh_make_node);
MapBlockMesh mapblock_mesh(&mesh_make_data, v3s16(0, 0, 0)); MapBlockMesh mapblock_mesh(&mesh_make_data, v3s16(0, 0, 0));

@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <string> #include <string>
struct ItemStack; struct ItemStack;
class IGameDef; class Client;
class ITextureSource; class ITextureSource;
struct TileSpec; struct TileSpec;
@ -42,7 +42,7 @@ public:
v3f wield_scale, ITextureSource *tsrc); v3f wield_scale, ITextureSource *tsrc);
void setExtruded(const std::string &imagename, void setExtruded(const std::string &imagename,
v3f wield_scale, ITextureSource *tsrc, u8 num_frames); v3f wield_scale, ITextureSource *tsrc, u8 num_frames);
void setItem(const ItemStack &item, IGameDef *gamedef); void setItem(const ItemStack &item, Client *client);
// Sets the vertex color of the wield mesh. // Sets the vertex color of the wield mesh.
// Must only be used if the constructor was called with lighting = false // Must only be used if the constructor was called with lighting = false
@ -77,7 +77,7 @@ private:
aabb3f m_bounding_box; aabb3f m_bounding_box;
}; };
scene::IMesh *getItemMesh(IGameDef *gamedef, const ItemStack &item); scene::IMesh *getItemMesh(Client *client, const ItemStack &item);
scene::IMesh *getExtrudedMesh(ITextureSource *tsrc, scene::IMesh *getExtrudedMesh(ITextureSource *tsrc,
const std::string &imagename); const std::string &imagename);