aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/android/jni/Android.mk2
-rw-r--r--src/camera.cpp21
-rw-r--r--src/camera.h6
-rw-r--r--src/client.cpp2
-rw-r--r--src/client.h17
-rw-r--r--src/clientenvironment.cpp30
-rw-r--r--src/clientenvironment.h8
-rw-r--r--src/clientmap.cpp7
-rw-r--r--src/clientmap.h21
-rw-r--r--src/clientobject.cpp9
-rw-r--r--src/clientobject.h21
-rw-r--r--src/collision.cpp3
-rw-r--r--src/content_cao.cpp67
-rw-r--r--src/content_cao.h9
-rw-r--r--src/content_cso.cpp13
-rw-r--r--src/content_mapblock.cpp6
-rw-r--r--src/content_sao.cpp20
-rw-r--r--src/emerge.cpp14
-rw-r--r--src/emerge.h3
-rw-r--r--src/environment.h7
-rw-r--r--src/game.cpp59
-rw-r--r--src/gamedef.h29
-rw-r--r--src/guiEngine.cpp2
-rw-r--r--src/guiFormSpecMenu.cpp39
-rw-r--r--src/guiFormSpecMenu.h6
-rw-r--r--src/hud.cpp20
-rw-r--r--src/hud.h8
-rw-r--r--src/itemdef.cpp22
-rw-r--r--src/itemdef.h9
-rw-r--r--src/localplayer.cpp23
-rw-r--r--src/localplayer.h4
-rw-r--r--src/mapblock_mesh.cpp25
-rw-r--r--src/mapblock_mesh.h8
-rw-r--r--src/mg_biome.cpp11
-rw-r--r--src/mg_biome.h5
-rw-r--r--src/mg_schematic.cpp10
-rw-r--r--src/mg_schematic.h6
-rw-r--r--src/nodedef.cpp16
-rw-r--r--src/nodedef.h4
-rw-r--r--src/particles.cpp16
-rw-r--r--src/particles.h2
-rw-r--r--src/pathfinder.cpp6
-rw-r--r--src/script/lua_api/l_nodemeta.cpp6
-rw-r--r--src/server.cpp18
-rw-r--r--src/server.h6
-rw-r--r--src/serverenvironment.cpp20
-rw-r--r--src/serverenvironment.h12
-rw-r--r--src/wieldmesh.cpp26
-rw-r--r--src/wieldmesh.h6
49 files changed, 301 insertions, 409 deletions
diff --git a/build/android/jni/Android.mk b/build/android/jni/Android.mk
index 2567457b9..3be856770 100644
--- a/build/android/jni/Android.mk
+++ b/build/android/jni/Android.mk
@@ -117,6 +117,7 @@ LOCAL_SRC_FILES := \
jni/src/cavegen.cpp \
jni/src/chat.cpp \
jni/src/client.cpp \
+ jni/src/clientenvironment.cpp \
jni/src/clientiface.cpp \
jni/src/clientmap.cpp \
jni/src/clientmedia.cpp \
@@ -210,6 +211,7 @@ LOCAL_SRC_FILES := \
jni/src/rollback_interface.cpp \
jni/src/serialization.cpp \
jni/src/server.cpp \
+ jni/src/serverenvironment.cpp \
jni/src/serverlist.cpp \
jni/src/serverobject.cpp \
jni/src/shader.cpp \
diff --git a/src/camera.cpp b/src/camera.cpp
index 43980db1c..4768e8778 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "wieldmesh.h"
#include "noise.h" // easeCurve
-#include "gamedef.h"
#include "sound.h"
#include "event.h"
#include "profiler.h"
@@ -41,7 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h"
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
- IGameDef *gamedef):
+ Client *client):
m_playernode(NULL),
m_headnode(NULL),
m_cameranode(NULL),
@@ -50,7 +49,7 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
m_wieldnode(NULL),
m_draw_control(draw_control),
- m_gamedef(gamedef),
+ m_client(client),
m_camera_position(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->addCameraSceneNode();
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
/* 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);
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)
{
@@ -189,7 +188,7 @@ void Camera::step(f32 dtime)
(was > 0.5f && m_view_bobbing_anim <= 0.5f));
if(step) {
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)
{
MtEvent *e = new SimpleTriggerEvent("CameraPunchLeft");
- m_gamedef->event()->put(e);
+ m_client->event()->put(e);
} else if(m_digging_button == 1) {
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);
// 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));
const ContentFeatures& features = nodemgr->get(n);
if(features.walkable)
@@ -390,7 +389,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
// Get FOV
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;
} else {
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;
if ((walking || swimming || climbing) &&
m_cache_view_bobbing &&
- (!g_settings->getBool("free_move") || !m_gamedef->checkLocalPrivilege("fly")))
+ (!g_settings->getBool("free_move") || !m_client->checkLocalPrivilege("fly")))
{
// Start animation
m_view_bobbing_state = 1;
diff --git a/src/camera.h b/src/camera.h
index cb0e9686d..b5be26718 100644
--- a/src/camera.h
+++ b/src/camera.h
@@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class LocalPlayer;
struct MapDrawControl;
-class IGameDef;
+class Client;
class WieldMeshSceneNode;
struct Nametag {
@@ -61,7 +61,7 @@ class Camera
{
public:
Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
- IGameDef *gamedef);
+ Client *client);
~Camera();
// Get player scene node.
@@ -189,7 +189,7 @@ private:
// draw control
MapDrawControl& m_draw_control;
- IGameDef *m_gamedef;
+ Client *m_client;
video::IVideoDriver *m_driver;
// Absolute camera position
diff --git a/src/client.cpp b/src/client.cpp
index 693a90604..c2471dbd7 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -221,7 +221,7 @@ Client::Client(
m_event(event),
m_mesh_update_thread(),
m_env(
- new ClientMap(this, this, control,
+ new ClientMap(this, control,
device->getSceneManager()->getRootSceneNode(),
device->getSceneManager(), 666),
device->getSceneManager(),
diff --git a/src/client.h b/src/client.h
index 9a09704a6..df3e7e605 100644
--- a/src/client.h
+++ b/src/client.h
@@ -34,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "localplayer.h"
#include "hud.h"
#include "particles.h"
-#include "network/networkpacket.h"
struct MeshMakeData;
class MapBlockMesh;
@@ -51,6 +50,7 @@ class Database;
class Mapper;
struct MinimapMapblock;
class Camera;
+class NetworkPacket;
struct QueuedMeshUpdate
{
@@ -402,9 +402,6 @@ public:
void ProcessData(NetworkPacket *pkt);
- // Returns true if something was received
- bool AsyncProcessPacket();
- bool AsyncProcessData();
void Send(NetworkPacket* pkt);
void interact(u8 action, const PointedThing& pointed);
@@ -422,8 +419,9 @@ public:
void sendRespawn();
void sendReady();
- ClientEnvironment& getEnv()
- { return m_env; }
+ ClientEnvironment& getEnv() { return m_env; }
+ ITextureSource *tsrc() { return getTextureSource(); }
+ ISoundManager *sound() { return getSoundManager(); }
// Causes urgent mesh updates (unlike Map::add/removeNodeWithEvent)
void removeNode(v3s16 p);
@@ -521,14 +519,15 @@ public:
virtual IItemDefManager* getItemDefManager();
virtual INodeDefManager* getNodeDefManager();
virtual ICraftDefManager* getCraftDefManager();
- virtual ITextureSource* getTextureSource();
+ ITextureSource* getTextureSource();
virtual IShaderSource* getShaderSource();
- virtual scene::ISceneManager* getSceneManager();
+ IShaderSource *shsrc() { return getShaderSource(); }
+ scene::ISceneManager* getSceneManager();
virtual u16 allocateUnknownNodeId(const std::string &name);
virtual ISoundManager* getSoundManager();
virtual MtEventManager* getEventManager();
virtual ParticleManager* getParticleManager();
- virtual bool checkLocalPrivilege(const std::string &priv)
+ bool checkLocalPrivilege(const std::string &priv)
{ return checkPrivilege(priv); }
virtual scene::IAnimatedMesh* getMesh(const std::string &filename);
diff --git a/src/clientenvironment.cpp b/src/clientenvironment.cpp
index e831de109..65646c6b4 100644
--- a/src/clientenvironment.cpp
+++ b/src/clientenvironment.cpp
@@ -34,13 +34,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
ClientEnvironment::ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr,
- ITextureSource *texturesource, IGameDef *gamedef,
+ ITextureSource *texturesource, Client *client,
IrrlichtDevice *irr):
m_map(map),
m_local_player(NULL),
m_smgr(smgr),
m_texturesource(texturesource),
- m_gamedef(gamedef),
+ m_client(client),
m_irr(irr)
{
char zero = 0;
@@ -94,7 +94,7 @@ void ClientEnvironment::step(float dtime)
stepTimeOfDay(dtime);
// 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");
// Get local player
@@ -223,7 +223,7 @@ void ClientEnvironment::step(float dtime)
f32 post_factor = 1; // 1 hp per node/s
if(info.type == COLLISION_NODE)
{
- const ContentFeatures &f = m_gamedef->ndef()->
+ const ContentFeatures &f = m_client->ndef()->
get(m_map->getNodeNoEx(info.node_p));
// Determine fall damage multiplier
int addp = itemgroup_get(f.groups, "fall_damage_add_percent");
@@ -237,7 +237,7 @@ void ClientEnvironment::step(float dtime)
if(damage != 0){
damageLocalPlayer(damage, true);
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;
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,
- m_gamedef->ndef()->get(n2).damage_per_second);
+ m_client->ndef()->get(n2).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)
{
@@ -272,7 +272,7 @@ void ClientEnvironment::step(float dtime)
}
// Protocol v29 make this behaviour obsolete
- if (((Client*) getGameDef())->getProtoVersion() < 29) {
+ if (getGameDef()->getProtoVersion() < 29) {
/*
Drowning
*/
@@ -282,7 +282,7 @@ void ClientEnvironment::step(float dtime)
// head
v3s16 p = floatToInt(pf + v3f(0, BS * 1.6, 0), BS);
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;
if (drowning_damage > 0 && lplayer->hp > 0) {
u16 breath = lplayer->getBreath();
@@ -306,7 +306,7 @@ void ClientEnvironment::step(float dtime)
// head
v3s16 p = floatToInt(pf + v3f(0, BS * 1.6, 0), BS);
MapNode n = m_map->getNodeNoEx(p);
- ContentFeatures c = m_gamedef->ndef()->get(n);
+ ContentFeatures c = m_client->ndef()->get(n);
if (!lplayer->hp) {
lplayer->setBreath(11);
} else if (c.drowning == 0) {
@@ -332,7 +332,7 @@ void ClientEnvironment::step(float dtime)
v3s16 p = lplayer->getLightPosition();
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 night = (light >> 8) & 0xff;
finalColorBlend(lplayer->light_color, day, night, day_night_ratio);
@@ -360,7 +360,7 @@ void ClientEnvironment::step(float dtime)
v3s16 p = obj->getLightPosition();
MapNode n = m_map->getNodeNoEx(p, &pos_ok);
if (pos_ok)
- light = n.getLightBlend(day_night_ratio, m_gamedef->ndef());
+ light = n.getLightBlend(day_night_ratio, m_client->ndef());
else
light = blend_light(day_night_ratio, LIGHT_SUN, 0);
@@ -467,7 +467,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
v3s16 p = object->getLightPosition();
MapNode n = m_map->getNodeNoEx(p, &pos_ok);
if (pos_ok)
- light = n.getLightBlend(getDayNightRatio(), m_gamedef->ndef());
+ light = n.getLightBlend(getDayNightRatio(), m_client->ndef());
else
light = blend_light(getDayNightRatio(), LIGHT_SUN, 0);
@@ -480,7 +480,7 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
const std::string &init_data)
{
ClientActiveObject* obj =
- ClientActiveObject::create((ActiveObjectType) type, m_gamedef, this);
+ ClientActiveObject::create((ActiveObjectType) type, m_client, this);
if(obj == NULL)
{
infostream<<"ClientEnvironment::addActiveObject(): "
diff --git a/src/clientenvironment.h b/src/clientenvironment.h
index e6292b5b7..b30a7a6d7 100644
--- a/src/clientenvironment.h
+++ b/src/clientenvironment.h
@@ -30,6 +30,7 @@ class ClientMap;
class ClientActiveObject;
class GenericCAO;
class LocalPlayer;
+struct PointedThing;
/*
The client-side environment.
@@ -66,15 +67,14 @@ class ClientEnvironment : public Environment
{
public:
ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr,
- ITextureSource *texturesource, IGameDef *gamedef,
+ ITextureSource *texturesource, Client *client,
IrrlichtDevice *device);
~ClientEnvironment();
Map & getMap();
ClientMap & getClientMap();
- IGameDef *getGameDef()
- { return m_gamedef; }
+ Client *getGameDef() { return m_client; }
void step(f32 dtime);
@@ -175,7 +175,7 @@ private:
LocalPlayer *m_local_player;
scene::ISceneManager *m_smgr;
ITextureSource *m_texturesource;
- IGameDef *m_gamedef;
+ Client *m_client;
IrrlichtDevice *m_irr;
UNORDERED_MAP<u16, ClientActiveObject*> m_active_objects;
std::vector<ClientSimpleObject*> m_simple_objects;
diff --git a/src/clientmap.cpp b/src/clientmap.cpp
index 542eb03e8..7e688daad 100644
--- a/src/clientmap.cpp
+++ b/src/clientmap.cpp
@@ -35,13 +35,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
ClientMap::ClientMap(
Client *client,
- IGameDef *gamedef,
MapDrawControl &control,
scene::ISceneNode* parent,
scene::ISceneManager* mgr,
s32 id
):
- Map(dout_client, gamedef),
+ Map(dout_client, client),
scene::ISceneNode(parent, mgr, id),
m_client(client),
m_control(control),
@@ -140,7 +139,7 @@ static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step, float stepfac,
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 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);
video::SColor post_effect_color = features.post_effect_color;
if(features.solidness == 2 && !(g_settings->getBool("noclip") &&
- m_gamedef->checkLocalPrivilege("noclip")) &&
+ m_client->checkLocalPrivilege("noclip")) &&
cam_mode == CAMERA_MODE_FIRST)
{
post_effect_color = video::SColor(255, 0, 0, 0);
diff --git a/src/clientmap.h b/src/clientmap.h
index cb686ff33..84228f4ca 100644
--- a/src/clientmap.h
+++ b/src/clientmap.h
@@ -59,7 +59,7 @@ class ITextureSource;
/*
ClientMap
-
+
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:
ClientMap(
Client *client,
- IGameDef *gamedef,
MapDrawControl &control,
scene::ISceneNode* parent,
scene::ISceneManager* mgr,
@@ -114,13 +113,13 @@ public:
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
renderMap(driver, SceneManager->getSceneNodeRenderPass());
}
-
+
virtual const aabb3f &getBoundingBox() const
{
return m_box;
}
-
- void getBlocksInViewRange(v3s16 cam_pos_nodes,
+
+ void getBlocksInViewRange(v3s16 cam_pos_nodes,
v3s16 *p_blocks_min, v3s16 *p_blocks_max);
void updateDrawList(video::IVideoDriver* driver);
void renderMap(video::IVideoDriver* driver, s32 pass);
@@ -132,20 +131,14 @@ public:
// For debug printing
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; }
f32 getCameraFov() const { return m_camera_fov; }
private:
Client *m_client;
-
+
aabb3f m_box;
-
+
MapDrawControl &m_control;
v3f m_camera_position;
@@ -154,7 +147,7 @@ private:
v3s16 m_camera_offset;
std::map<v3s16, MapBlock*> m_drawlist;
-
+
std::set<v2s16> m_last_drawn_sectors;
bool m_cache_trilinear_filter;
diff --git a/src/clientobject.cpp b/src/clientobject.cpp
index ff3f47187..89a0474a4 100644
--- a/src/clientobject.cpp
+++ b/src/clientobject.cpp
@@ -20,16 +20,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "clientobject.h"
#include "debug.h"
#include "porting.h"
-#include "constants.h"
/*
ClientActiveObject
*/
-ClientActiveObject::ClientActiveObject(u16 id, IGameDef *gamedef,
+ClientActiveObject::ClientActiveObject(u16 id, Client *client,
ClientEnvironment *env):
ActiveObject(id),
- m_gamedef(gamedef),
+ m_client(client),
m_env(env)
{
}
@@ -40,7 +39,7 @@ ClientActiveObject::~ClientActiveObject()
}
ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,
- IGameDef *gamedef, ClientEnvironment *env)
+ Client *client, ClientEnvironment *env)
{
// Find factory function
UNORDERED_MAP<u16, Factory>::iterator n = m_types.find(type);
@@ -52,7 +51,7 @@ ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,
}
Factory f = n->second;
- ClientActiveObject *object = (*f)(gamedef, env);
+ ClientActiveObject *object = (*f)(client, env);
return object;
}
diff --git a/src/clientobject.h b/src/clientobject.h
index 83931e438..f0bde0adc 100644
--- a/src/clientobject.h
+++ b/src/clientobject.h
@@ -25,20 +25,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <map>
#include "util/cpp11_container.h"
-/*
-
-Some planning
--------------
-
-* Client receives a network packet with information of added objects
- in it
-* Client supplies the information to its ClientEnvironment
-* The environment adds the specified objects to itself
-
-*/
-
class ClientEnvironment;
class ITextureSource;
+class Client;
class IGameDef;
class LocalPlayer;
struct ItemStack;
@@ -47,7 +36,7 @@ class WieldMeshSceneNode;
class ClientActiveObject : public ActiveObject
{
public:
- ClientActiveObject(u16 id, IGameDef *gamedef, ClientEnvironment *env);
+ ClientActiveObject(u16 id, Client *client, ClientEnvironment *env);
virtual ~ClientActiveObject();
virtual void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
@@ -89,7 +78,7 @@ public:
virtual void initialize(const std::string &data){}
// Create a certain type of ClientActiveObject
- static ClientActiveObject* create(ActiveObjectType type, IGameDef *gamedef,
+ static ClientActiveObject* create(ActiveObjectType type, Client *client,
ClientEnvironment *env);
// If returns true, punch will not be sent to the server
@@ -99,9 +88,9 @@ public:
protected:
// Used for creating objects based on type
- typedef ClientActiveObject* (*Factory)(IGameDef *gamedef, ClientEnvironment *env);
+ typedef ClientActiveObject* (*Factory)(Client *client, ClientEnvironment *env);
static void registerType(u16 type, Factory f);
- IGameDef *m_gamedef;
+ Client *m_client;
ClientEnvironment *m_env;
private:
// Used for creating objects based on type
diff --git a/src/collision.cpp b/src/collision.cpp
index 595fa8059..c0891c152 100644
--- a/src/collision.cpp
+++ b/src/collision.cpp
@@ -22,9 +22,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h"
#include "nodedef.h"
#include "gamedef.h"
+#ifndef SERVER
#include "clientenvironment.h"
+#endif
#include "serverenvironment.h"
#include "serverobject.h"
+#include "util/timetaker.h"
#include "profiler.h"
// float error is 10 - 9.96875 = 0.03125
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index a02d5168e..a4c0bf14d 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "collision.h"
#include "settings.h"
#include "serialization.h" // For decompressZlib
-#include "gamedef.h"
#include "clientobject.h"
#include "mesh.h"
#include "itemdef.h"
@@ -139,7 +138,7 @@ static void setBillboardTextureMatrix(scene::IBillboardSceneNode *bill,
class TestCAO : public ClientActiveObject
{
public:
- TestCAO(IGameDef *gamedef, ClientEnvironment *env);
+ TestCAO(Client *client, ClientEnvironment *env);
virtual ~TestCAO();
ActiveObjectType getType() const
@@ -147,7 +146,7 @@ public:
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,
IrrlichtDevice *irr);
@@ -169,8 +168,8 @@ private:
// Prototype
TestCAO proto_TestCAO(NULL, NULL);
-TestCAO::TestCAO(IGameDef *gamedef, ClientEnvironment *env):
- ClientActiveObject(0, gamedef, env),
+TestCAO::TestCAO(Client *client, ClientEnvironment *env):
+ ClientActiveObject(0, client, env),
m_node(NULL),
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,
@@ -283,7 +282,7 @@ void TestCAO::processMessage(const std::string &data)
class ItemCAO : public ClientActiveObject
{
public:
- ItemCAO(IGameDef *gamedef, ClientEnvironment *env);
+ ItemCAO(Client *client, ClientEnvironment *env);
virtual ~ItemCAO();
ActiveObjectType getType() const
@@ -291,7 +290,7 @@ public:
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,
IrrlichtDevice *irr);
@@ -331,13 +330,13 @@ private:
// Prototype
ItemCAO proto_ItemCAO(NULL, NULL);
-ItemCAO::ItemCAO(IGameDef *gamedef, ClientEnvironment *env):
- ClientActiveObject(0, gamedef, env),
+ItemCAO::ItemCAO(Client *client, ClientEnvironment *env):
+ ClientActiveObject(0, client, env),
m_selection_box(-BS/3.,0.0,-BS/3., BS/3.,BS*2./3.,BS/3.),
m_node(NULL),
m_position(v3f(0,10*BS,0))
{
- if(!gamedef && !env)
+ if(!client && !env)
{
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,
@@ -433,7 +432,7 @@ void ItemCAO::updateNodePos()
void ItemCAO::updateInfoText()
{
try{
- IItemDefManager *idef = m_gamedef->idef();
+ IItemDefManager *idef = m_client->idef();
ItemStack item;
item.deSerialize(m_itemstring, idef);
if(item.isKnown(idef))
@@ -458,10 +457,10 @@ void ItemCAO::updateTexture()
std::istringstream is(m_itemstring, std::ios_base::binary);
video::ITexture *texture = NULL;
try{
- IItemDefManager *idef = m_gamedef->idef();
+ IItemDefManager *idef = m_client->idef();
ItemStack item;
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)
{
@@ -538,15 +537,15 @@ void ItemCAO::initialize(const std::string &data)
#include "genericobject.h"
-GenericCAO::GenericCAO(IGameDef *gamedef, ClientEnvironment *env):
- ClientActiveObject(0, gamedef, env),
+GenericCAO::GenericCAO(Client *client, ClientEnvironment *env):
+ ClientActiveObject(0, client, env),
//
m_is_player(false),
m_is_local_player(false),
//
m_smgr(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_meshnode(NULL),
m_animated_meshnode(NULL),
@@ -581,10 +580,10 @@ GenericCAO::GenericCAO(IGameDef *gamedef, ClientEnvironment *env):
m_last_light(255),
m_is_visible(false)
{
- if (gamedef == NULL) {
+ if (client == NULL) {
ClientActiveObject::registerType(getType(), create);
} else {
- m_gamedef = gamedef;
+ m_client = client;
}
}
@@ -793,7 +792,7 @@ void GenericCAO::removeFromScene(bool permanent)
}
if (m_nametag) {
- m_gamedef->getCamera()->removeNametag(m_nametag);
+ m_client->getCamera()->removeNametag(m_nametag);
m_nametag = NULL;
}
}
@@ -906,7 +905,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
}
else if(m_prop.visual == "mesh") {
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)
{
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;
if(m_prop.textures.size() >= 1){
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);
m_wield_meshnode = new WieldMeshSceneNode(
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_prop.visual_size.Y/2,
@@ -959,7 +958,7 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
scene::ISceneNode *node = getSceneNode();
if (node && m_prop.nametag != "" && !m_is_local_player) {
// Add nametag
- m_nametag = m_gamedef->getCamera()->addNametag(node,
+ m_nametag = m_client->getCamera()->addNametag(node,
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
if((g_settings->getBool("fast_move") &&
- m_gamedef->checkLocalPrivilege("fast")) &&
+ m_client->checkLocalPrivilege("fast")) &&
(controls.aux1 ||
(!player->touching_ground &&
g_settings->getBool("free_move") &&
- m_gamedef->checkLocalPrivilege("fly"))))
+ m_client->checkLocalPrivilege("fly"))))
new_speed *= 1.5;
// slowdown speed if sneeking
if(controls.sneak && walking)
@@ -1129,7 +1128,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
}
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
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;
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,
(m_prop.collisionbox.MinEdge.Y-0.5)*BS, 0), BS);
MapNode n = m_env->getMap().getNodeNoEx(p);
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)
{
- ITextureSource *tsrc = m_gamedef->tsrc();
+ ITextureSource *tsrc = m_client->tsrc();
bool use_trilinear_filter = g_settings->getBool("trilinear_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
const ToolCapabilities *toolcap =
- &punchitem->getToolCapabilities(m_gamedef->idef());
+ &punchitem->getToolCapabilities(m_client->idef());
PunchDamageResult result = getPunchDamage(
m_armor_groups,
toolcap,
diff --git a/src/content_cao.h b/src/content_cao.h
index a158e8296..96a160055 100644
--- a/src/content_cao.h
+++ b/src/content_cao.h
@@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemgroup.h"
class Camera;
+class Client;
struct Nametag;
/*
@@ -68,7 +69,7 @@ private:
//
scene::ISceneManager *m_smgr;
IrrlichtDevice *m_irr;
- IGameDef *m_gamedef;
+ Client *m_client;
aabb3f m_selection_box;
scene::IMeshSceneNode *m_meshnode;
scene::IAnimatedMeshSceneNode *m_animated_meshnode;
@@ -109,13 +110,13 @@ private:
std::vector<u16> m_children;
public:
- GenericCAO(IGameDef *gamedef, ClientEnvironment *env);
+ GenericCAO(Client *client, ClientEnvironment *env);
~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
diff --git a/src/content_cso.cpp b/src/content_cso.cpp
index c0407f460..aca71212b 100644
--- a/src/content_cso.cpp
+++ b/src/content_cso.cpp
@@ -21,20 +21,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IBillboardSceneNode.h>
#include "client/tile.h"
#include "clientenvironment.h"
-#include "gamedef.h"
+#include "client.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
{
float m_age;
diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp
index 8ce0f1e0a..a7134590b 100644
--- a/src/content_mapblock.cpp
+++ b/src/content_mapblock.cpp
@@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/tile.h"
#include "mesh.h"
#include <IMeshManipulator.h>
-#include "gamedef.h"
+#include "client.h"
#include "log.h"
#include "noise.h"
@@ -188,8 +188,8 @@ static inline int NeighborToIndex(const v3s16 &pos)
void mapblock_mesh_generate_special(MeshMakeData *data,
MeshCollector &collector)
{
- INodeDefManager *nodedef = data->m_gamedef->ndef();
- scene::ISceneManager* smgr = data->m_gamedef->getSceneManager();
+ INodeDefManager *nodedef = data->m_client->ndef();
+ scene::ISceneManager* smgr = data->m_client->getSceneManager();
scene::IMeshManipulator* meshmanip = smgr->getMeshManipulator();
// 0ms
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index f866d4372..dd8bdc592 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -273,7 +273,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
v3f p_pos = m_base_position;
v3f p_velocity = m_velocity;
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,
&p_pos, &p_velocity, p_acceleration,
this, m_prop.collideWithObjects);
@@ -945,7 +945,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
// get head position
v3s16 p = floatToInt(m_base_position + v3f(0, BS * 1.6, 0), BS);
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 (c.drowning > 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
if (m_breath == 0) {
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
v3s16 p = floatToInt(m_base_position + v3f(0, BS * 1.6, 0), BS);
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 (m_hp > 0 && c.drowning == 0)
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_rotation = v3f(0,0,0);
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;
@@ -1107,7 +1107,7 @@ void PlayerSAO::setPos(const v3f &pos)
setBasePosition(pos);
// Movement caused by this command is always valid
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)
@@ -1118,7 +1118,7 @@ void PlayerSAO::moveTo(v3f pos, bool continuous)
setBasePosition(pos);
// Movement caused by this command is always valid
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)
@@ -1148,7 +1148,7 @@ void PlayerSAO::setWantedRange(const s16 range)
void PlayerSAO::setYawAndSend(const float yaw)
{
setYaw(yaw);
- ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
+ m_env->getGameDef()->SendMovePlayer(m_peer_id);
}
void PlayerSAO::setPitch(const float pitch)
@@ -1162,7 +1162,7 @@ void PlayerSAO::setPitch(const float pitch)
void PlayerSAO::setPitchAndSend(const float pitch)
{
setPitch(pitch);
- ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
+ m_env->getGameDef()->SendMovePlayer(m_peer_id);
}
int PlayerSAO::punch(v3f dir,
@@ -1273,7 +1273,7 @@ void PlayerSAO::setBreath(const u16 breath, bool send)
m_breath = MYMIN(breath, PLAYER_MAX_BREATH);
if (send)
- ((Server *) m_env->getGameDef())->SendPlayerBreath(this);
+ m_env->getGameDef()->SendPlayerBreath(this);
}
void PlayerSAO::setArmorGroups(const ItemGroupList &armor_groups)
diff --git a/src/emerge.cpp b/src/emerge.cpp
index 25b2e924b..3f0a46010 100644
--- a/src/emerge.cpp
+++ b/src/emerge.cpp
@@ -89,13 +89,13 @@ private:
//// EmergeManager
////
-EmergeManager::EmergeManager(IGameDef *gamedef)
+EmergeManager::EmergeManager(Server *server)
{
- this->ndef = gamedef->getNodeDefManager();
- this->biomemgr = new BiomeManager(gamedef);
- this->oremgr = new OreManager(gamedef);
- this->decomgr = new DecorationManager(gamedef);
- this->schemmgr = new SchematicManager(gamedef);
+ this->ndef = server->getNodeDefManager();
+ this->biomemgr = new BiomeManager(server);
+ this->oremgr = new OreManager(server);
+ this->decomgr = new DecorationManager(server);
+ this->schemmgr = new SchematicManager(server);
this->gen_notify_on = 0;
// Note that accesses to this variable are not synchronized.
@@ -128,7 +128,7 @@ EmergeManager::EmergeManager(IGameDef *gamedef)
m_qlimit_generate = 1;
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;
}
diff --git a/src/emerge.h b/src/emerge.h
index 71ad97da3..76653e6cd 100644
--- a/src/emerge.h
+++ b/src/emerge.h
@@ -42,6 +42,7 @@ class BiomeManager;
class OreManager;
class DecorationManager;
class SchematicManager;
+class Server;
// Structure containing inputs/outputs for chunk generation
struct BlockMakeData {
@@ -115,7 +116,7 @@ public:
SchematicManager *schemmgr;
// Methods
- EmergeManager(IGameDef *gamedef);
+ EmergeManager(Server *server);
~EmergeManager();
bool initMapgens(MapgenParams *mgparams);
diff --git a/src/environment.h b/src/environment.h
index 14a18421b..0cc3222f9 100644
--- a/src/environment.h
+++ b/src/environment.h
@@ -42,13 +42,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "threading/atomic.h"
#include "network/networkprotocol.h" // for AccessDeniedCode
-class ITextureSource;
-class IGameDef;
-class Map;
-class GameScripting;
-class Player;
-class PointedThing;
-
class Environment
{
public:
diff --git a/src/game.cpp b/src/game.cpp
index cfa6234ff..1070cb1b2 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -916,16 +916,14 @@ bool nodePlacementPrediction(Client &client,
}
static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
- InventoryManager *invmgr, IGameDef *gamedef,
- IWritableTextureSource *tsrc, IrrlichtDevice *device,
- JoystickController *joystick,
- IFormSource *fs_src, TextDest *txt_dest, Client *client)
+ Client *client, IrrlichtDevice *device, JoystickController *joystick,
+ IFormSource *fs_src, TextDest *txt_dest)
{
if (*cur_formspec == 0) {
*cur_formspec = new GUIFormSpecMenu(device, joystick,
- guiroot, -1, &g_menumgr, invmgr, gamedef, tsrc,
- fs_src, txt_dest, client);
+ guiroot, -1, &g_menumgr, client, client->getTextureSource(),
+ fs_src, txt_dest);
(*cur_formspec)->doPause = false;
/*
@@ -950,9 +948,9 @@ static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
#endif
static void show_deathscreen(GUIFormSpecMenu **cur_formspec,
- InventoryManager *invmgr, IGameDef *gamedef,
+ Client *client,
IWritableTextureSource *tsrc, IrrlichtDevice *device,
- JoystickController *joystick, Client *client)
+ JoystickController *joystick)
{
std::string formspec =
std::string(FORMSPEC_VERSION_STRING) +
@@ -968,13 +966,12 @@ static void show_deathscreen(GUIFormSpecMenu **cur_formspec,
FormspecFormSource *fs_src = new FormspecFormSource(formspec);
LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_DEATH_SCREEN", client);
- create_formspec_menu(cur_formspec, invmgr, gamedef, tsrc, device,
- joystick, fs_src, txt_dst, NULL);
+ create_formspec_menu(cur_formspec, client, device, joystick, fs_src, txt_dst);
}
/******************************************************************************/
static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
- InventoryManager *invmgr, IGameDef *gamedef,
+ Client *client,
IWritableTextureSource *tsrc, IrrlichtDevice *device,
JoystickController *joystick, bool singleplayermode)
{
@@ -1041,8 +1038,7 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
FormspecFormSource *fs_src = new FormspecFormSource(os.str());
LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_PAUSE_MENU");
- create_formspec_menu(cur_formspec, invmgr, gamedef, tsrc, device,
- joystick, fs_src, txt_dst, NULL);
+ create_formspec_menu(cur_formspec, client, device, joystick, fs_src, txt_dst);
std::string con("btn_continue");
(*cur_formspec)->setFocus(con);
(*cur_formspec)->doPause = true;
@@ -1534,7 +1530,6 @@ private:
bool *kill;
std::string *error_message;
bool *reconnect_requested;
- IGameDef *gamedef; // Convenience (same as *client)
scene::ISceneNode *skybox;
bool random_input;
@@ -2011,7 +2006,7 @@ bool Game::createClient(const std::string &playername,
/* Camera
*/
- camera = new Camera(smgr, *draw_control, gamedef);
+ camera = new Camera(smgr, *draw_control, client);
if (!camera || !camera->successfullyCreated(*error_message))
return false;
client->setCamera(camera);
@@ -2068,7 +2063,7 @@ bool Game::createClient(const std::string &playername,
player->hurt_tilt_timer = 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) {
*error_message = "Memory error: could not create HUD";
@@ -2198,8 +2193,6 @@ bool Game::connectToServer(const std::string &playername,
if (!client)
return false;
- gamedef = client; // Client acts as our GameDef
-
infostream << "Connecting to server at ";
connect_address.print(&infostream);
infostream << std::endl;
@@ -2445,7 +2438,7 @@ inline bool Game::handleCallbacks()
void Game::processQueues()
{
texture_src->processQueue();
- itemdef_manager->processQueue(gamedef);
+ itemdef_manager->processQueue(client);
shader_src->processQueue();
}
@@ -2617,7 +2610,7 @@ void Game::processKeyInput(VolatileRunFlags *flags,
openInventory();
} else if (wasKeyDown(KeyType::ESC) || input->wasKeyDown(CancelKey)) {
if (!gui_chat_console->isOpenInhibited()) {
- show_pause_menu(&current_formspec, client, gamedef,
+ show_pause_menu(&current_formspec, client,
texture_src, device, &input->joystick,
simple_singleplayer_mode);
}
@@ -2769,8 +2762,7 @@ void Game::openInventory()
PlayerInventoryFormSource *fs_src = new PlayerInventoryFormSource(client);
TextDest *txt_dst = new TextDestPlayerInventory(client);
- create_formspec_menu(&current_formspec, client, gamedef, texture_src,
- device, &input->joystick, fs_src, txt_dst, client);
+ create_formspec_menu(&current_formspec, client, device, &input->joystick, fs_src, txt_dst);
cur_formname = "";
InventoryLocation inventoryloc;
@@ -3245,13 +3237,13 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
rangelim(event.player_damage.amount / 4, 1.0, 4.0);
MtEvent *e = new SimpleTriggerEvent("PlayerDamage");
- gamedef->event()->put(e);
+ client->event()->put(e);
} else if (event.type == CE_PLAYER_FORCE_MOVE) {
cam->camera_yaw = event.player_force_move.yaw;
cam->camera_pitch = event.player_force_move.pitch;
} else if (event.type == CE_DEATHSCREEN) {
- show_deathscreen(&current_formspec, client, gamedef, texture_src,
- device, &input->joystick, client);
+ show_deathscreen(&current_formspec, client, texture_src,
+ device, &input->joystick);
chat_backend->addMessage(L"", L"You died.");
@@ -3271,9 +3263,8 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash)
TextDestPlayerInventory *txt_dst =
new TextDestPlayerInventory(client, *(event.show_formspec.formname));
- create_formspec_menu(&current_formspec, client, gamedef,
- texture_src, device, &input->joystick,
- fs_src, txt_dst, client);
+ create_formspec_menu(&current_formspec, client, device, &input->joystick,
+ fs_src, txt_dst);
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) ||
(event.type == CE_ADD_PARTICLESPAWNER) ||
(event.type == CE_DELETE_PARTICLESPAWNER)) {
- client->getParticleManager()->handleParticleEvent(&event, gamedef,
+ client->getParticleManager()->handleParticleEvent(&event, client,
smgr, player);
} else if (event.type == CE_HUDADD) {
u32 id = event.hudadd.id;
@@ -3840,8 +3831,8 @@ void Game::handlePointingAtNode(GameRunData *runData,
&client->getEnv().getClientMap(), nodepos);
TextDest *txt_dst = new TextDestNodeMetadata(nodepos, client);
- create_formspec_menu(&current_formspec, client, gamedef,
- texture_src, device, &input->joystick, fs_src, txt_dst, client);
+ create_formspec_menu(&current_formspec, client,
+ device, &input->joystick, fs_src, txt_dst);
cur_formname = "";
current_formspec->setFormSpec(meta->getString("formspec"), inventoryloc);
@@ -3972,7 +3963,7 @@ void Game::handleDigging(GameRunData *runData,
if (m_cache_enable_particles) {
const ContentFeatures &features =
client->getNodeDefManager()->get(n);
- client->getParticleManager()->addPunchingParticles(gamedef, smgr,
+ client->getParticleManager()->addPunchingParticles(client, smgr,
player, nodepos, features.tiles);
}
}
@@ -4019,7 +4010,7 @@ void Game::handleDigging(GameRunData *runData,
if (m_cache_enable_particles) {
const ContentFeatures &features =
client->getNodeDefManager()->get(wasnode);
- client->getParticleManager()->addDiggingParticles(gamedef, smgr,
+ client->getParticleManager()->addDiggingParticles(client, smgr,
player, nodepos, features.tiles);
}
@@ -4043,7 +4034,7 @@ void Game::handleDigging(GameRunData *runData,
// Send event to trigger sound
MtEvent *e = new NodeDugEvent(nodepos, wasnode);
- gamedef->event()->put(e);
+ client->event()->put(e);
}
if (runData->dig_time_complete < 100000.0) {
diff --git a/src/gamedef.h b/src/gamedef.h
index 7e3da4cac..cb624bd6a 100644
--- a/src/gamedef.h
+++ b/src/gamedef.h
@@ -53,47 +53,22 @@ public:
virtual INodeDefManager* getNodeDefManager()=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
virtual u16 allocateUnknownNodeId(const std::string &name)=0;
- // Only usable on the client
- virtual ISoundManager* getSoundManager()=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
// environment thread.
- 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; }
+ virtual IRollbackManager* getRollbackManager() { return NULL; }
// Shorthands
IItemDefManager *idef() { return getItemDefManager(); }
INodeDefManager *ndef() { return getNodeDefManager(); }
ICraftDefManager *cdef() { return getCraftDefManager(); }
- ITextureSource *tsrc() { return getTextureSource(); }
- ISoundManager *sound() { return getSoundManager(); }
- IShaderSource *shsrc() { return getShaderSource(); }
+
MtEventManager *event() { return getEventManager(); }
IRollbackManager *rollback() { return getRollbackManager();}
- EmergeManager *emerge() { return getEmergeManager(); }
};
#endif
diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp
index a3c35f68d..6d66ed08d 100644
--- a/src/guiEngine.cpp
+++ b/src/guiEngine.cpp
@@ -194,11 +194,9 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
-1,
m_menumanager,
NULL /* &client */,
- NULL /* gamedef */,
m_texture_source,
m_formspecgui,
m_buttonhandler,
- NULL,
false);
m_menu->allowClose(false);
diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp
index bfc7a9b79..45b0e9c11 100644
--- a/src/guiFormSpecMenu.cpp
+++ b/src/guiFormSpecMenu.cpp
@@ -81,13 +81,12 @@ static unsigned int font_line_height(gui::IGUIFont *font)
GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
JoystickController *joystick,
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr,
- InventoryManager *invmgr, IGameDef *gamedef,
+ Client *client,
ISimpleTextureSource *tsrc, IFormSource* fsrc, TextDest* tdst,
- Client* client, bool remap_dbl_click) :
+ bool remap_dbl_click) :
GUIModalMenu(dev->getGUIEnvironment(), parent, id, menumgr),
m_device(dev),
- m_invmgr(invmgr),
- m_gamedef(gamedef),
+ m_invmgr(client),
m_tsrc(tsrc),
m_client(client),
m_selected_item(NULL),
@@ -307,8 +306,8 @@ void GUIFormSpecMenu::parseContainerEnd(parserData* data)
void GUIFormSpecMenu::parseList(parserData* data,std::string element)
{
- if (m_gamedef == 0) {
- warningstream<<"invalid use of 'list' with m_gamedef==0"<<std::endl;
+ if (m_client == 0) {
+ warningstream<<"invalid use of 'list' with m_client==0"<<std::endl;
return;
}
@@ -362,8 +361,8 @@ void GUIFormSpecMenu::parseList(parserData* data,std::string element)
void GUIFormSpecMenu::parseListRing(parserData* data, std::string element)
{
- if (m_gamedef == 0) {
- errorstream << "WARNING: invalid use of 'listring' with m_gamedef==0" << std::endl;
+ if (m_client == 0) {
+ errorstream << "WARNING: invalid use of 'listring' with m_client==0" << std::endl;
return;
}
@@ -1486,8 +1485,8 @@ void GUIFormSpecMenu::parseTabHeader(parserData* data,std::string element)
void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
{
- if (m_gamedef == 0) {
- warningstream << "invalid use of item_image_button with m_gamedef==0"
+ if (m_client == 0) {
+ warningstream << "invalid use of item_image_button with m_client==0"
<< std::endl;
return;
}
@@ -1521,7 +1520,7 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data,std::string element)
if(!data->explicit_size)
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;
item.deSerialize(item_name, idef);
@@ -2297,14 +2296,14 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase,
if(!item.empty())
{
drawItemStack(driver, m_font, item,
- rect, &AbsoluteClippingRect, m_gamedef,
+ rect, &AbsoluteClippingRect, m_client,
rotation_kind);
}
// Draw tooltip
std::wstring tooltip_text = L"";
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"") {
std::vector<std::wstring> tt_rows = str_split(tooltip_text, L'\n');
@@ -2349,7 +2348,7 @@ void GUIFormSpecMenu::drawSelectedItem()
if (!m_selected_item) {
drawItemStack(driver, m_font, ItemStack(),
core::rect<s32>(v2s32(0, 0), v2s32(0, 0)),
- NULL, m_gamedef, IT_ROT_DRAGGED);
+ NULL, m_client, IT_ROT_DRAGGED);
return;
}
@@ -2363,7 +2362,7 @@ void GUIFormSpecMenu::drawSelectedItem()
core::rect<s32> imgrect(0,0,imgsize.X,imgsize.Y);
core::rect<s32> rect = imgrect + (m_pointer - imgrect.getCenter());
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()
@@ -2488,11 +2487,11 @@ void GUIFormSpecMenu::drawMenu()
*/
for(u32 i=0; i<m_itemimages.size(); i++)
{
- if (m_gamedef == 0)
+ if (m_client == 0)
break;
const ImageDrawSpec &spec = m_itemimages[i];
- IItemDefManager *idef = m_gamedef->idef();
+ IItemDefManager *idef = m_client->idef();
ItemStack item;
item.deSerialize(spec.item_name, idef);
core::rect<s32> imgrect(0, 0, spec.geom.X, spec.geom.Y);
@@ -2509,7 +2508,7 @@ void GUIFormSpecMenu::drawMenu()
#endif
}
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) {
drawItemStack(driver, m_font, ItemStack(),
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 */
@@ -3470,7 +3469,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
// Check how many items can be moved
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,
// they are swapped
if ((leftover.count == stack_from.count) &&
diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h
index 95df11e6a..94b52e6f0 100644
--- a/src/guiFormSpecMenu.h
+++ b/src/guiFormSpecMenu.h
@@ -34,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h"
#include "util/enriched_string.h"
-class IGameDef;
class InventoryManager;
class ISimpleTextureSource;
class Client;
@@ -289,12 +288,10 @@ public:
JoystickController *joystick,
gui::IGUIElement* parent, s32 id,
IMenuManager *menumgr,
- InventoryManager *invmgr,
- IGameDef *gamedef,
+ Client *client,
ISimpleTextureSource *tsrc,
IFormSource* fs_src,
TextDest* txt_dst,
- Client* client,
bool remap_dbl_click = true);
~GUIFormSpecMenu();
@@ -384,7 +381,6 @@ protected:
irr::IrrlichtDevice* m_device;
InventoryManager *m_invmgr;
- IGameDef *m_gamedef;
ISimpleTextureSource *m_tsrc;
Client *m_client;
diff --git a/src/hud.cpp b/src/hud.cpp
index 43d957380..a602125e3 100644
--- a/src/hud.cpp
+++ b/src/hud.cpp
@@ -22,10 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "hud.h"
#include "settings.h"
#include "util/numeric.h"
-#include "util/string.h"
#include "log.h"
-#include "gamedef.h"
-#include "itemdef.h"
+#include "client.h"
#include "inventory.h"
#include "client/tile.h"
#include "localplayer.h"
@@ -41,13 +39,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif
Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
- gui::IGUIEnvironment* guienv, IGameDef *gamedef, LocalPlayer *player,
+ gui::IGUIEnvironment* guienv, Client *client, LocalPlayer *player,
Inventory *inventory)
{
this->driver = driver;
this->smgr = smgr;
this->guienv = guienv;
- this->gamedef = gamedef;
+ this->client = client;
this->player = player;
this->inventory = inventory;
@@ -61,7 +59,7 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
for (unsigned int i = 0; i < 4; i++)
hbar_colors[i] = video::SColor(255, 255, 255, 255);
- tsrc = gamedef->getTextureSource();
+ tsrc = client->getTextureSource();
v3f crosshair_color = g_settings->getV3F("crosshair_color");
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;
if (g_settings->getBool("enable_shaders")) {
- IShaderSource *shdrsrc = gamedef->getShaderSource();
+ IShaderSource *shdrsrc = client->getShaderSource();
u16 shader_id = shdrsrc->getShader(
mode == "halo" ? "selection_shader" : "default_shader", 1, 1);
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)
driver->draw2DRectangle(bgcolor2, 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
@@ -629,7 +627,7 @@ void drawItemStack(video::IVideoDriver *driver,
const ItemStack &item,
const core::rect<s32> &rect,
const core::rect<s32> *clip,
- IGameDef *gamedef,
+ Client *client,
ItemRotationKind rotation_kind)
{
static MeshTimeInfo rotation_time_infos[IT_ROT_NONE];
@@ -643,8 +641,8 @@ void drawItemStack(video::IVideoDriver *driver,
return;
}
- const ItemDefinition &def = item.getDefinition(gamedef->idef());
- scene::IMesh* mesh = gamedef->idef()->getWieldMesh(def.name, gamedef);
+ const ItemDefinition &def = item.getDefinition(client->idef());
+ scene::IMesh* mesh = client->idef()->getWieldMesh(def.name, client);
if (mesh) {
driver->clearZBuffer();
diff --git a/src/hud.h b/src/hud.h
index a4d7990e9..efa0c3648 100644
--- a/src/hud.h
+++ b/src/hud.h
@@ -95,7 +95,7 @@ struct HudElement {
#include <IGUIFont.h>
#include "irr_aabb3d.h"
-class IGameDef;
+class Client;
class ITextureSource;
class Inventory;
class InventoryList;
@@ -107,7 +107,7 @@ public:
video::IVideoDriver *driver;
scene::ISceneManager* smgr;
gui::IGUIEnvironment *guienv;
- IGameDef *gamedef;
+ Client *client;
LocalPlayer *player;
Inventory *inventory;
ITextureSource *tsrc;
@@ -121,7 +121,7 @@ public:
bool use_hotbar_selected_image;
Hud(video::IVideoDriver *driver,scene::ISceneManager* smgr,
- gui::IGUIEnvironment* guienv, IGameDef *gamedef, LocalPlayer *player,
+ gui::IGUIEnvironment* guienv, Client *client, LocalPlayer *player,
Inventory *inventory);
~Hud();
@@ -190,7 +190,7 @@ void drawItemStack(video::IVideoDriver *driver,
const ItemStack &item,
const core::rect<s32> &rect,
const core::rect<s32> *clip,
- IGameDef *gamedef,
+ Client *client,
ItemRotationKind rotation_kind);
#endif
diff --git a/src/itemdef.cpp b/src/itemdef.cpp
index 1aa6331dc..5ba9d8f9a 100644
--- a/src/itemdef.cpp
+++ b/src/itemdef.cpp
@@ -20,7 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemdef.h"
-#include "gamedef.h"
#include "nodedef.h"
#include "tool.h"
#include "inventory.h"
@@ -29,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mesh.h"
#include "wieldmesh.h"
#include "client/tile.h"
+#include "client.h"
#endif
#include "log.h"
#include "settings.h"
@@ -317,7 +317,7 @@ public:
#ifndef SERVER
public:
ClientCached* createClientCachedDirect(const std::string &name,
- IGameDef *gamedef) const
+ Client *client) const
{
infostream<<"Lazily creating item texture and mesh for \""
<<name<<"\""<<std::endl;
@@ -331,7 +331,7 @@ public:
if(cc)
return cc;
- ITextureSource *tsrc = gamedef->getTextureSource();
+ ITextureSource *tsrc = client->getTextureSource();
const ItemDefinition &def = get(name);
// Create new ClientCached
@@ -345,7 +345,7 @@ public:
ItemStack item = ItemStack();
item.name = def.name;
- scene::IMesh *mesh = getItemMesh(gamedef, item);
+ scene::IMesh *mesh = getItemMesh(client, item);
cc->wield_mesh = mesh;
// Put in cache
@@ -354,7 +354,7 @@ public:
return cc;
}
ClientCached* getClientCached(const std::string &name,
- IGameDef *gamedef) const
+ Client *client) const
{
ClientCached *cc = NULL;
m_clientcached.get(name, &cc);
@@ -363,7 +363,7 @@ public:
if(thr_is_current_thread(m_main_thread))
{
- return createClientCachedDirect(name, gamedef);
+ return createClientCachedDirect(name, client);
}
else
{
@@ -392,18 +392,18 @@ public:
}
// Get item inventory texture
virtual video::ITexture* getInventoryTexture(const std::string &name,
- IGameDef *gamedef) const
+ Client *client) const
{
- ClientCached *cc = getClientCached(name, gamedef);
+ ClientCached *cc = getClientCached(name, client);
if(!cc)
return NULL;
return cc->inventory_texture;
}
// Get item wield mesh
virtual scene::IMesh* getWieldMesh(const std::string &name,
- IGameDef *gamedef) const
+ Client *client) const
{
- ClientCached *cc = getClientCached(name, gamedef);
+ ClientCached *cc = getClientCached(name, client);
if(!cc)
return NULL;
return cc->wield_mesh;
@@ -543,7 +543,7 @@ public:
request = m_get_clientcached_queue.pop();
m_get_clientcached_queue.pushResult(request,
- createClientCachedDirect(request.key, gamedef));
+ createClientCachedDirect(request.key, (Client *)gamedef));
}
#endif
}
diff --git a/src/itemdef.h b/src/itemdef.h
index dcb98e8a9..2ade6116a 100644
--- a/src/itemdef.h
+++ b/src/itemdef.h
@@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemgroup.h"
#include "sound.h"
class IGameDef;
+class Client;
struct ToolCapabilities;
/*
@@ -107,10 +108,10 @@ public:
#ifndef SERVER
// Get item inventory texture
virtual video::ITexture* getInventoryTexture(const std::string &name,
- IGameDef *gamedef) const=0;
+ Client *client) const=0;
// Get item wield mesh
virtual scene::IMesh* getWieldMesh(const std::string &name,
- IGameDef *gamedef) const=0;
+ Client *client) const=0;
#endif
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
@@ -133,10 +134,10 @@ public:
#ifndef SERVER
// Get item inventory texture
virtual video::ITexture* getInventoryTexture(const std::string &name,
- IGameDef *gamedef) const=0;
+ Client *client) const=0;
// Get item wield mesh
virtual scene::IMesh* getWieldMesh(const std::string &name,
- IGameDef *gamedef) const=0;
+ Client *client) const=0;
#endif
// Remove all registered item and node definitions and aliases
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 4d0ca0600..b859c6455 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "event.h"
#include "collision.h"
-#include "gamedef.h"
#include "nodedef.h"
#include "settings.h"
#include "environment.h"
@@ -32,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
LocalPlayer
*/
-LocalPlayer::LocalPlayer(Client *gamedef, const char *name):
- Player(name, gamedef->idef()),
+LocalPlayer::LocalPlayer(Client *client, const char *name):
+ Player(name, client->idef()),
parent(0),
hp(PLAYER_MAX_HP),
got_teleported(false),
@@ -79,7 +78,7 @@ LocalPlayer::LocalPlayer(Client *gamedef, const char *name):
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_cao(NULL),
- m_gamedef(gamedef)
+ m_client(client)
{
// Initialize hp to 0, so that no hearts will be shown if server
// 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)
{
Map *map = &env->getMap();
- INodeDefManager *nodemgr = m_gamedef->ndef();
+ INodeDefManager *nodemgr = m_client->ndef();
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
- bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
- bool noclip = m_gamedef->checkLocalPrivilege("noclip") &&
+ bool fly_allowed = m_client->checkLocalPrivilege("fly");
+ bool noclip = m_client->checkLocalPrivilege("noclip") &&
g_settings->getBool("noclip");
bool free_move = noclip && fly_allowed && g_settings->getBool("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);
- collisionMoveResult result = collisionMoveSimple(env, m_gamedef,
+ collisionMoveResult result = collisionMoveSimple(env, m_client,
pos_max_d, m_collisionbox, player_stepheight, dtime,
&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) {
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
camera_impact = getSpeed().Y * -1;
@@ -448,8 +447,8 @@ void LocalPlayer::applyControl(float dtime)
v3f speedH = v3f(0,0,0); // Horizontal (X, Z)
v3f speedV = v3f(0,0,0); // Vertical (Y)
- bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
- bool fast_allowed = m_gamedef->checkLocalPrivilege("fast");
+ bool fly_allowed = m_client->checkLocalPrivilege("fly");
+ bool fast_allowed = m_client->checkLocalPrivilege("fast");
bool free_move = fly_allowed && g_settings->getBool("free_move");
bool fast_move = fast_allowed && g_settings->getBool("fast_move");
@@ -599,7 +598,7 @@ void LocalPlayer::applyControl(float dtime)
setSpeed(speedJ);
MtEvent *e = new SimpleTriggerEvent("PlayerJump");
- m_gamedef->event()->put(e);
+ m_client->event()->put(e);
}
}
else if(in_liquid)
diff --git a/src/localplayer.h b/src/localplayer.h
index 7a1cb7466..cbdcb9867 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -35,7 +35,7 @@ enum LocalPlayerAnimations {NO_ANIM, WALK_ANIM, DIG_ANIM, WD_ANIM}; // no local
class LocalPlayer : public Player
{
public:
- LocalPlayer(Client *gamedef, const char *name);
+ LocalPlayer(Client *client, const char *name);
virtual ~LocalPlayer();
ClientActiveObject *parent;
@@ -162,7 +162,7 @@ private:
aabb3f m_collisionbox;
GenericCAO* m_cao;
- Client *m_gamedef;
+ Client *m_client;
};
#endif
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index 977eabb6e..143adb410 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h"
#include "profiler.h"
#include "nodedef.h"
-#include "gamedef.h"
#include "mesh.h"
#include "minimap.h"
#include "content_mapblock.h"
@@ -43,14 +42,14 @@ static void applyFacesShading(video::SColor &color, const float factor)
MeshMakeData
*/
-MeshMakeData::MeshMakeData(IGameDef *gamedef, bool use_shaders,
+MeshMakeData::MeshMakeData(Client *client, bool use_shaders,
bool use_tangent_vertices):
m_vmanip(),
m_blockpos(-1337,-1337,-1337),
m_crack_pos_relative(-1337, -1337, -1337),
m_smooth_lighting(false),
m_show_hud(false),
- m_gamedef(gamedef),
+ m_client(client),
m_use_shaders(use_shaders),
m_use_tangent_vertices(use_tangent_vertices)
{}
@@ -233,7 +232,7 @@ static u16 getSmoothLightCombined(v3s16 p, MeshMakeData *data)
v3s16(1,1,1),
};
- INodeDefManager *ndef = data->m_gamedef->ndef();
+ INodeDefManager *ndef = data->m_client->ndef();
u16 ambient_occlusion = 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)
{
- INodeDefManager *ndef = data->m_gamedef->ndef();
+ INodeDefManager *ndef = data->m_client->ndef();
TileSpec spec = ndef->get(mn).tiles[tileindex];
// Apply temporary crack
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)
{
- 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),
// (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;
TileSpec spec = getNodeTileN(mn, p, dir_to_tile[tile_index], data);
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;
}
@@ -753,7 +752,7 @@ static void getTileInfo(
)
{
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;
MapNode &n0 = vmanip.getNodeRefUnsafe(blockpos_nodes + p);
@@ -1020,10 +1019,10 @@ static void updateAllFastFaceRows(MeshMakeData *data,
MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
m_mesh(new scene::SMesh()),
m_minimap_mapblock(NULL),
- m_gamedef(data->m_gamedef),
- m_driver(m_gamedef->tsrc()->getDevice()->getVideoDriver()),
- m_tsrc(m_gamedef->getTextureSource()),
- m_shdrsrc(m_gamedef->getShaderSource()),
+ m_client(data->m_client),
+ m_driver(m_client->tsrc()->getDevice()->getVideoDriver()),
+ m_tsrc(m_client->getTextureSource()),
+ m_shdrsrc(m_client->getShaderSource()),
m_animation_force_timer(0), // force initial animation
m_last_crack(-1),
m_crack_materials(),
@@ -1243,7 +1242,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
if (m_use_tangent_vertices) {
scene::IMeshManipulator* meshmanip =
- m_gamedef->getSceneManager()->getMeshManipulator();
+ m_client->getSceneManager()->getMeshManipulator();
meshmanip->recalculateTangents(m_mesh, true, false, false);
}
diff --git a/src/mapblock_mesh.h b/src/mapblock_mesh.h
index 8376468da..5adb7df3f 100644
--- a/src/mapblock_mesh.h
+++ b/src/mapblock_mesh.h
@@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/cpp11_container.h"
#include <map>
-class IGameDef;
+class Client;
class IShaderSource;
/*
@@ -45,11 +45,11 @@ struct MeshMakeData
bool m_smooth_lighting;
bool m_show_hud;
- IGameDef *m_gamedef;
+ Client *m_client;
bool m_use_shaders;
bool m_use_tangent_vertices;
- MeshMakeData(IGameDef *gamedef, bool use_shaders,
+ MeshMakeData(Client *client, bool use_shaders,
bool use_tangent_vertices = false);
/*
@@ -128,7 +128,7 @@ public:
private:
scene::IMesh *m_mesh;
MinimapMapblock *m_minimap_mapblock;
- IGameDef *m_gamedef;
+ Client *m_client;
video::IVideoDriver *m_driver;
ITextureSource *m_tsrc;
IShaderSource *m_shdrsrc;
diff --git a/src/mg_biome.cpp b/src/mg_biome.cpp
index 78034bf6c..d564e9415 100644
--- a/src/mg_biome.cpp
+++ b/src/mg_biome.cpp
@@ -20,10 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mg_biome.h"
#include "mg_decoration.h"
#include "emerge.h"
-#include "gamedef.h"
+#include "server.h"
#include "nodedef.h"
#include "map.h" //for MMVManip
-#include "log.h"
#include "util/numeric.h"
#include "util/mathconstants.h"
#include "porting.h"
@@ -33,10 +32,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
///////////////////////////////////////////////////////////////////////////////
-BiomeManager::BiomeManager(IGameDef *gamedef) :
- ObjDefManager(gamedef, OBJDEF_BIOME)
+BiomeManager::BiomeManager(Server *server) :
+ ObjDefManager(server, OBJDEF_BIOME)
{
- m_gamedef = gamedef;
+ m_server = server;
// Create default biome to be used in case none exist
Biome *b = new Biome;
@@ -73,7 +72,7 @@ BiomeManager::~BiomeManager()
void BiomeManager::clear()
{
- EmergeManager *emerge = m_gamedef->getEmergeManager();
+ EmergeManager *emerge = m_server->getEmergeManager();
// Remove all dangling references in Decorations
DecorationManager *decomgr = emerge->decomgr;
diff --git a/src/mg_biome.h b/src/mg_biome.h
index a10193bc3..15088f7dd 100644
--- a/src/mg_biome.h
+++ b/src/mg_biome.h
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h"
#include "noise.h"
+class Server;
class Settings;
class BiomeManager;
@@ -186,7 +187,7 @@ private:
class BiomeManager : public ObjDefManager {
public:
- BiomeManager(IGameDef *gamedef);
+ BiomeManager(Server *server);
virtual ~BiomeManager();
const char *getObjectTitle() const
@@ -223,7 +224,7 @@ public:
virtual void clear();
private:
- IGameDef *m_gamedef;
+ Server *m_server;
};
diff --git a/src/mg_schematic.cpp b/src/mg_schematic.cpp
index e028215dc..3d08d86fa 100644
--- a/src/mg_schematic.cpp
+++ b/src/mg_schematic.cpp
@@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <fstream>
#include <typeinfo>
#include "mg_schematic.h"
-#include "gamedef.h"
+#include "server.h"
#include "mapgen.h"
#include "emerge.h"
#include "map.h"
@@ -34,16 +34,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
///////////////////////////////////////////////////////////////////////////////
-SchematicManager::SchematicManager(IGameDef *gamedef) :
- ObjDefManager(gamedef, OBJDEF_SCHEMATIC)
+SchematicManager::SchematicManager(Server *server) :
+ ObjDefManager(server, OBJDEF_SCHEMATIC)
{
- m_gamedef = gamedef;
+ m_server = server;
}
void SchematicManager::clear()
{
- EmergeManager *emerge = m_gamedef->getEmergeManager();
+ EmergeManager *emerge = m_server->getEmergeManager();
// Remove all dangling references in Decorations
DecorationManager *decomgr = emerge->decomgr;
diff --git a/src/mg_schematic.h b/src/mg_schematic.h
index da8859540..1d46e6ac4 100644
--- a/src/mg_schematic.h
+++ b/src/mg_schematic.h
@@ -29,7 +29,7 @@ class Mapgen;
class MMVManip;
class PseudoRandom;
class NodeResolver;
-class IGameDef;
+class Server;
/*
Minetest Schematic File Format
@@ -123,7 +123,7 @@ public:
class SchematicManager : public ObjDefManager {
public:
- SchematicManager(IGameDef *gamedef);
+ SchematicManager(Server *server);
virtual ~SchematicManager() {}
virtual void clear();
@@ -139,7 +139,7 @@ public:
}
private:
- IGameDef *m_gamedef;
+ Server *m_server;
};
void generate_nodelist_and_update_ids(MapNode *nodes, size_t nodecount,
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index dbbdf95d2..b7d023897 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SERVER
#include "client/tile.h"
#include "mesh.h"
+#include "client.h"
#include <IMeshManipulator.h>
#endif
#include "log.h"
@@ -572,8 +573,7 @@ void ContentFeatures::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
#ifndef SERVER
void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
- scene::ISceneManager *smgr, scene::IMeshManipulator *meshmanip,
- IGameDef *gamedef, const TextureSettings &tsettings)
+ scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings)
{
// minimap pixel color - the average color of a texture
if (tsettings.enable_minimap && tiledef[0].name != "")
@@ -709,7 +709,7 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
if ((drawtype == NDT_MESH) && (mesh != "")) {
// Meshnode drawtype
// Read the mesh and apply scale
- mesh_ptr[0] = gamedef->getMesh(mesh);
+ mesh_ptr[0] = client->getMesh(mesh);
if (mesh_ptr[0]){
v3f scale = v3f(1.0, 1.0, 1.0) * BS * visual_scale;
scaleMesh(mesh_ptr[0], scale);
@@ -1316,9 +1316,11 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
#ifndef SERVER
infostream << "CNodeDefManager::updateTextures(): Updating "
"textures in node definitions" << std::endl;
- ITextureSource *tsrc = gamedef->tsrc();
- IShaderSource *shdsrc = gamedef->getShaderSource();
- scene::ISceneManager* smgr = gamedef->getSceneManager();
+
+ Client *client = (Client *)gamedef;
+ ITextureSource *tsrc = client->tsrc();
+ IShaderSource *shdsrc = client->getShaderSource();
+ scene::ISceneManager* smgr = client->getSceneManager();
scene::IMeshManipulator* meshmanip = smgr->getMeshManipulator();
TextureSettings tsettings;
tsettings.readSettings();
@@ -1326,7 +1328,7 @@ void CNodeDefManager::updateTextures(IGameDef *gamedef,
u32 size = m_content_features.size();
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);
}
#endif
diff --git a/src/nodedef.h b/src/nodedef.h
index 284c4a198..183b95d87 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SERVER
#include "client/tile.h"
#include "shader.h"
+class Client;
#endif
#include "itemgroup.h"
#include "sound.h" // SimpleSoundSpec
@@ -322,8 +323,7 @@ struct ContentFeatures
u32 shader_id, bool use_normal_texture, bool backface_culling,
u8 alpha, u8 material_type);
void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
- scene::ISceneManager *smgr, scene::IMeshManipulator *meshmanip,
- IGameDef *gamedef, const TextureSettings &tsettings);
+ scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings);
#endif
};
diff --git a/src/particles.cpp b/src/particles.cpp
index 97f42e2c4..d9eb3cfa5 100644
--- a/src/particles.cpp
+++ b/src/particles.cpp
@@ -18,11 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "particles.h"
-#include "constants.h"
-#include "debug.h"
-#include "settings.h"
-#include "client/tile.h"
-#include "gamedef.h"
+#include "client.h"
#include "collision.h"
#include <stdlib.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)
{
switch (event->type) {
@@ -477,9 +473,9 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef,
}
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.spawntime,
*event->add_particlespawner.minpos,
@@ -520,9 +516,9 @@ void ParticleManager::handleParticleEvent(ClientEvent *event, IGameDef *gamedef,
}
case CE_SPAWN_PARTICLE: {
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.vel,
*event->spawn_particle.acc,
diff --git a/src/particles.h b/src/particles.h
index eb8c6665d..00cb2c08e 100644
--- a/src/particles.h
+++ b/src/particles.h
@@ -170,7 +170,7 @@ public:
void step (float dtime);
- void handleParticleEvent(ClientEvent *event,IGameDef *gamedef,
+ void handleParticleEvent(ClientEvent *event, Client *client,
scene::ISceneManager* smgr, LocalPlayer *player);
void addDiggingParticles(IGameDef* gamedef, scene::ISceneManager* smgr,
diff --git a/src/pathfinder.cpp b/src/pathfinder.cpp
index 84aa9252c..b240ec21f 100644
--- a/src/pathfinder.cpp
+++ b/src/pathfinder.cpp
@@ -24,12 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "pathfinder.h"
#include "serverenvironment.h"
-#include "gamedef.h"
+#include "server.h"
#include "nodedef.h"
-#include "map.h"
-#include "log.h"
-#include "irr_aabb3d.h"
-#include "util/basic_macros.h"
//#define PATHFINDER_DEBUG
//#define PATHFINDER_CALC_TIME
diff --git a/src/script/lua_api/l_nodemeta.cpp b/src/script/lua_api/l_nodemeta.cpp
index 3cdd3cbfe..3d03c0c41 100644
--- a/src/script/lua_api/l_nodemeta.cpp
+++ b/src/script/lua_api/l_nodemeta.cpp
@@ -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_internal.h"
#include "lua_api/l_inventory.h"
-#include "common/c_converter.h"
#include "common/c_content.h"
#include "serverenvironment.h"
#include "map.h"
-#include "gamedef.h"
-#include "nodemetadata.h"
-
-
+#include "server.h"
/*
NodeMetaRef
diff --git a/src/server.cpp b/src/server.cpp
index 60dbef0d2..7380d37c2 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -50,7 +50,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_abm.h"
#include "content_sao.h"
#include "mods.h"
-#include "sound.h" // dummySoundManager
#include "event_manager.h"
#include "serverlist.h"
#include "util/string.h"
@@ -3310,29 +3309,12 @@ ICraftDefManager *Server::getCraftDefManager()
{
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)
{
return m_nodedef->allocateDummy(name);
}
-ISoundManager *Server::getSoundManager()
-{
- return &dummySoundManager;
-}
-
MtEventManager *Server::getEventManager()
{
return m_event;
diff --git a/src/server.h b/src/server.h
index fe7b50b77..a86f75f1d 100644
--- a/src/server.h
+++ b/src/server.h
@@ -283,13 +283,9 @@ public:
virtual IItemDefManager* getItemDefManager();
virtual INodeDefManager* getNodeDefManager();
virtual ICraftDefManager* getCraftDefManager();
- virtual ITextureSource* getTextureSource();
- virtual IShaderSource* getShaderSource();
virtual u16 allocateUnknownNodeId(const std::string &name);
- virtual ISoundManager* getSoundManager();
virtual MtEventManager* getEventManager();
- virtual scene::ISceneManager* getSceneManager();
- virtual IRollbackManager *getRollbackManager() { return m_rollback; }
+ IRollbackManager *getRollbackManager() { return m_rollback; }
virtual EmergeManager *getEmergeManager() { return m_emerge; }
IWritableItemDefManager* getWritableItemDefManager();
diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp
index c9fa64ec5..e1962bcff 100644
--- a/src/serverenvironment.cpp
+++ b/src/serverenvironment.cpp
@@ -352,11 +352,11 @@ void ActiveBlockList::update(std::vector<v3s16> &active_positions,
*/
ServerEnvironment::ServerEnvironment(ServerMap *map,
- GameScripting *scriptIface, IGameDef *gamedef,
+ GameScripting *scriptIface, Server *server,
const std::string &path_world) :
m_map(map),
m_script(scriptIface),
- m_gamedef(gamedef),
+ m_server(server),
m_path_world(path_world),
m_send_recommended_timer(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();
it != m_players.end(); ++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);
}
}
@@ -501,7 +501,7 @@ void ServerEnvironment::saveLoadedPlayers()
it != m_players.end();
++it) {
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";
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)
@@ -523,7 +523,7 @@ RemotePlayer *ServerEnvironment::loadPlayer(const std::string &playername, Playe
RemotePlayer *player = getPlayer(playername.c_str());
if (!player) {
- player = new RemotePlayer("", m_gamedef->idef());
+ player = new RemotePlayer("", m_server->idef());
newplayer = true;
}
@@ -632,7 +632,7 @@ void ServerEnvironment::loadMeta()
} catch (SettingNotFoundException &e) {
// 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") ?
args.getU64("day_count") : 0;
@@ -640,7 +640,7 @@ void ServerEnvironment::loadMeta()
void ServerEnvironment::loadDefaultMeta()
{
- m_lbm_mgr.loadIntroductionTimes("", m_gamedef, m_game_time);
+ m_lbm_mgr.loadIntroductionTimes("", m_server, m_game_time);
}
struct ActiveABM
@@ -902,7 +902,7 @@ void ServerEnvironment::addLoadingBlockModifierDef(LoadingBlockModifierDef *lbm)
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);
// Call destructor
@@ -929,7 +929,7 @@ bool ServerEnvironment::setNode(v3s16 p, const MapNode &n)
bool ServerEnvironment::removeNode(v3s16 p)
{
- INodeDefManager *ndef = m_gamedef->ndef();
+ INodeDefManager *ndef = m_server->ndef();
MapNode n_old = m_map->getNodeNoEx(p);
// Call destructor
diff --git a/src/serverenvironment.h b/src/serverenvironment.h
index 20a783ea5..d71d29a9c 100644
--- a/src/serverenvironment.h
+++ b/src/serverenvironment.h
@@ -29,6 +29,8 @@ class PlayerSAO;
class ServerEnvironment;
class ActiveBlockModifier;
class ServerActiveObject;
+class Server;
+class GameScripting;
/*
{Active, Loading} block modifier interface.
@@ -190,7 +192,7 @@ class ServerEnvironment : public Environment
{
public:
ServerEnvironment(ServerMap *map, GameScripting *scriptIface,
- IGameDef *gamedef, const std::string &path_world);
+ Server *server, const std::string &path_world);
~ServerEnvironment();
Map & getMap();
@@ -201,8 +203,8 @@ public:
GameScripting* getScriptIface()
{ return m_script; }
- IGameDef *getGameDef()
- { return m_gamedef; }
+ Server *getGameDef()
+ { return m_server; }
float getSendRecommendedInterval()
{ return m_recommended_send_interval; }
@@ -377,8 +379,8 @@ private:
ServerMap *m_map;
// Lua state
GameScripting* m_script;
- // Game definition
- IGameDef *m_gamedef;
+ // Server definition
+ Server *m_server;
// World path
const std::string m_path_world;
// Active object list
diff --git a/src/wieldmesh.cpp b/src/wieldmesh.cpp
index 9c4d5b642..c305238fe 100644
--- a/src/wieldmesh.cpp
+++ b/src/wieldmesh.cpp
@@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "wieldmesh.h"
#include "inventory.h"
-#include "gamedef.h"
+#include "client.h"
#include "itemdef.h"
#include "nodedef.h"
#include "mesh.h"
@@ -283,7 +283,7 @@ void WieldMeshSceneNode::setExtruded(const std::string &imagename,
video::SMaterial &material = m_meshnode->getMaterial(0);
material.setTexture(0, tsrc->getTextureForMesh(imagename));
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.setFlag(video::EMF_BACK_FACE_CULLING, true);
// 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();
- IItemDefManager *idef = gamedef->getItemDefManager();
- IShaderSource *shdrsrc = gamedef->getShaderSource();
- INodeDefManager *ndef = gamedef->getNodeDefManager();
+ ITextureSource *tsrc = client->getTextureSource();
+ IItemDefManager *idef = client->getItemDefManager();
+ IShaderSource *shdrsrc = client->getShaderSource();
+ INodeDefManager *ndef = client->getNodeDefManager();
const ItemDefinition &def = item.getDefinition(idef);
const ContentFeatures &f = ndef->get(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) {
setCube(f.tiles, def.wield_scale, tsrc);
} else {
- MeshMakeData mesh_make_data(gamedef, false);
+ MeshMakeData mesh_make_data(client, false);
MapNode mesh_make_node(id, 255, 0);
mesh_make_data.fillSingleNode(&mesh_make_node);
MapBlockMesh mapblock_mesh(&mesh_make_data, v3s16(0, 0, 0));
@@ -435,11 +435,11 @@ void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh)
m_meshnode->setVisible(true);
}
-scene::IMesh *getItemMesh(IGameDef *gamedef, const ItemStack &item)
+scene::IMesh *getItemMesh(Client *client, const ItemStack &item)
{
- ITextureSource *tsrc = gamedef->getTextureSource();
- IItemDefManager *idef = gamedef->getItemDefManager();
- INodeDefManager *ndef = gamedef->getNodeDefManager();
+ ITextureSource *tsrc = client->getTextureSource();
+ IItemDefManager *idef = client->getItemDefManager();
+ INodeDefManager *ndef = client->getNodeDefManager();
const ItemDefinition &def = item.getDefinition(idef);
const ContentFeatures &f = ndef->get(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());
scaleMesh(mesh, v3f(1.2, 1.2, 1.2));
} else {
- MeshMakeData mesh_make_data(gamedef, false);
+ MeshMakeData mesh_make_data(client, false);
MapNode mesh_make_node(id, 255, 0);
mesh_make_data.fillSingleNode(&mesh_make_node);
MapBlockMesh mapblock_mesh(&mesh_make_data, v3s16(0, 0, 0));
diff --git a/src/wieldmesh.h b/src/wieldmesh.h
index 0b3136bc1..0162c5e5a 100644
--- a/src/wieldmesh.h
+++ b/src/wieldmesh.h
@@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <string>
struct ItemStack;
-class IGameDef;
+class Client;
class ITextureSource;
struct TileSpec;
@@ -42,7 +42,7 @@ public:
v3f wield_scale, ITextureSource *tsrc);
void setExtruded(const std::string &imagename,
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.
// Must only be used if the constructor was called with lighting = false
@@ -77,7 +77,7 @@ private:
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,
const std::string &imagename);