1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-11-04 16:35:03 -05:00

Clean mapnode.h and fix other files accordingly

This commit is contained in:
Perttu Ahola 2011-11-15 21:00:39 +02:00
parent 6da8cb00e2
commit ba762bcd49
15 changed files with 101 additions and 104 deletions

View File

@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct MeshMakeData;
class IGameDef;
class IWritableTextureSource;
class IWritableToolDefManager;
class IWritableNodeDefManager;

View File

@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "environment.h"
#include "settings.h"
#include <ICameraSceneNode.h>
#include "serialization.h" // For decompressZlib
core::map<u16, ClientActiveObject::Factory> ClientActiveObject::m_types;

View File

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapnode.h"
#include "content_nodemeta.h"
#include "nodedef.h"
#include "utility.h"
#define WATER_ALPHA 160

View File

@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "inventory.h"
#include "content_mapnode.h"
#include "log.h"
#include "utility.h"
/*
SignNodeMetadata

View File

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "main.h" // For g_profiler
#include "profiler.h"
#include "serialization.h" // For compressZlib
core::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types;

View File

@ -23,13 +23,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "farmesh.h"
#include "constants.h"
#include "debug.h"
#include "noise.h"
#include "map.h"
#include "client.h"
#include "tile.h" // ITextureSource
#include "mapgen.h"
#include "mapgen.h" // Shouldn't really be done this way
FarMesh::FarMesh(
scene::ISceneNode* parent,
@ -47,7 +49,7 @@ FarMesh::FarMesh(
{
dstream<<__FUNCTION_NAME<<std::endl;
video::IVideoDriver* driver = mgr->getVideoDriver();
//video::IVideoDriver* driver = mgr->getVideoDriver();
m_materials[0].setFlag(video::EMF_LIGHTING, false);
m_materials[0].setFlag(video::EMF_BACK_FACE_CULLING, true);
@ -62,8 +64,7 @@ FarMesh::FarMesh(
m_materials[1].setFlag(video::EMF_BACK_FACE_CULLING, false);
m_materials[1].setFlag(video::EMF_BILINEAR_FILTER, false);
m_materials[1].setFlag(video::EMF_FOG_ENABLE, false);
m_materials[1].setTexture
(0, driver->getTexture(getTexturePath("treeprop.png").c_str()));
m_materials[1].setTexture(0, client->tsrc()->getTextureRaw("treeprop.png"));
m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
m_materials[1].setFlag(video::EMF_FOG_ENABLE, true);

View File

@ -800,6 +800,28 @@ static std::string describeC(const struct InventoryContext *c)
return std::string("current_player=") + c->current_player->getName();
}
IMoveAction::IMoveAction(std::istream &is)
{
std::string ts;
std::getline(is, ts, ' ');
count = stoi(ts);
std::getline(is, from_inv, ' ');
std::getline(is, from_list, ' ');
std::getline(is, ts, ' ');
from_i = stoi(ts);
std::getline(is, to_inv, ' ');
std::getline(is, to_list, ' ');
std::getline(is, ts, ' ');
to_i = stoi(ts);
}
void IMoveAction::apply(InventoryContext *c, InventoryManager *mgr)
{
Inventory *inv_from = mgr->getInventory(c, from_inv);

View File

@ -520,27 +520,8 @@ struct IMoveAction : public InventoryAction
from_i = -1;
to_i = -1;
}
IMoveAction(std::istream &is)
{
std::string ts;
std::getline(is, ts, ' ');
count = stoi(ts);
std::getline(is, from_inv, ' ');
std::getline(is, from_list, ' ');
std::getline(is, ts, ' ');
from_i = stoi(ts);
std::getline(is, to_inv, ' ');
std::getline(is, to_list, ' ');
std::getline(is, ts, ' ');
to_i = stoi(ts);
}
IMoveAction(std::istream &is);
u16 getType() const
{

View File

@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblock_nodemod.h"
#include "constants.h"
#include "voxel.h"
#include "utility.h" // Needed for UniqueQueue, a member of Map
extern "C" {
#include "sqlite3.h"

View File

@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "tile.h"
#include "gamedef.h"
#include "content_mapblock.h"
#include "mineral.h" // For mineral_block_texture
void MeshMakeData::fill(u32 daynight_ratio, MapBlock *block)
{
@ -249,6 +250,61 @@ static void makeFastFace(TileSpec tile, u8 li0, u8 li1, u8 li2, u8 li3, v3f p,
dest.push_back(face);
}
static TileSpec getTile(const MapNode &node, v3s16 dir,
ITextureSource *tsrc, INodeDefManager *nodemgr)
{
const ContentFeatures &f = nodemgr->get(node);
if(f.param_type == CPT_FACEDIR_SIMPLE)
dir = facedir_rotate(node.param1, dir);
TileSpec spec;
s32 dir_i = -1;
if(dir == v3s16(0,0,0))
dir_i = -1;
else if(dir == v3s16(0,1,0))
dir_i = 0;
else if(dir == v3s16(0,-1,0))
dir_i = 1;
else if(dir == v3s16(1,0,0))
dir_i = 2;
else if(dir == v3s16(-1,0,0))
dir_i = 3;
else if(dir == v3s16(0,0,1))
dir_i = 4;
else if(dir == v3s16(0,0,-1))
dir_i = 5;
if(dir_i == -1)
// Non-directional
spec = f.tiles[0];
else
spec = f.tiles[dir_i];
/*
If it contains some mineral, change texture id
*/
if(f.param_type == CPT_MINERAL && tsrc)
{
u8 mineral = node.getMineral(nodemgr);
std::string mineral_texture_name = mineral_block_texture(mineral);
if(mineral_texture_name != "")
{
u32 orig_id = spec.texture.id;
std::string texture_name = tsrc->getTextureName(orig_id);
//texture_name += "^blit:";
texture_name += "^";
texture_name += mineral_texture_name;
u32 new_id = tsrc->getTextureId(texture_name);
spec.texture = tsrc->getTexture(new_id);
}
}
return spec;
}
/*
Gets node tile from any place relative to block.
Returns TILE_NODE if doesn't exist or should not be drawn.
@ -257,7 +313,7 @@ static TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir,
NodeModMap &temp_mods, ITextureSource *tsrc, INodeDefManager *ndef)
{
TileSpec spec;
spec = mn.getTile(face_dir, tsrc, ndef);
spec = getTile(mn, face_dir, tsrc, ndef);
/*
Check temporary modifications on this node
@ -274,7 +330,7 @@ static TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir,
if(mod.type == NODEMOD_CHANGECONTENT)
{
MapNode mn2(mod.param);
spec = mn2.getTile(face_dir, tsrc, ndef);
spec = getTile(mn2, face_dir, tsrc, ndef);
}
if(mod.type == NODEMOD_CRACK)
{

View File

@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "main.h" // For g_settings
#include "nodedef.h"
#include "content_mapnode.h" // For mapnode_translate_*_internal
#include "serialization.h" // For ser_ver_supported
#ifndef SERVER
/*
@ -208,61 +209,6 @@ u8 MapNode::getLightBanksWithSource(INodeDefManager *nodemgr) const
return (lightday&0x0f) | ((lightnight<<4)&0xf0);
}
#ifndef SERVER
TileSpec MapNode::getTile(v3s16 dir, ITextureSource *tsrc,
INodeDefManager *nodemgr) const
{
if(nodemgr->get(*this).param_type == CPT_FACEDIR_SIMPLE)
dir = facedir_rotate(param1, dir);
TileSpec spec;
s32 dir_i = -1;
if(dir == v3s16(0,0,0))
dir_i = -1;
else if(dir == v3s16(0,1,0))
dir_i = 0;
else if(dir == v3s16(0,-1,0))
dir_i = 1;
else if(dir == v3s16(1,0,0))
dir_i = 2;
else if(dir == v3s16(-1,0,0))
dir_i = 3;
else if(dir == v3s16(0,0,1))
dir_i = 4;
else if(dir == v3s16(0,0,-1))
dir_i = 5;
if(dir_i == -1)
// Non-directional
spec = nodemgr->get(*this).tiles[0];
else
spec = nodemgr->get(*this).tiles[dir_i];
/*
If it contains some mineral, change texture id
*/
if(nodemgr->get(*this).param_type == CPT_MINERAL && tsrc)
{
u8 mineral = getMineral(nodemgr);
std::string mineral_texture_name = mineral_block_texture(mineral);
if(mineral_texture_name != "")
{
u32 orig_id = spec.texture.id;
std::string texture_name = tsrc->getTextureName(orig_id);
//texture_name += "^blit:";
texture_name += "^";
texture_name += mineral_texture_name;
u32 new_id = tsrc->getTextureId(texture_name);
spec.texture = tsrc->getTexture(new_id);
}
}
return spec;
}
#endif
u8 MapNode::getMineral(INodeDefManager *nodemgr) const
{
if(nodemgr->get(*this).param_type == CPT_MINERAL)

View File

@ -20,14 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef MAPNODE_HEADER
#define MAPNODE_HEADER
#include <iostream>
#include "irrlichttypes.h"
#include "light.h"
#include "exceptions.h"
#include "serialization.h"
#ifndef SERVER
#include "tile.h"
#endif
class INodeDefManager;
@ -215,18 +209,6 @@ struct MapNode
return mix;
}*/
// In mapnode.cpp
#ifndef SERVER
/*
Get tile of a face of the node.
dir: direction of face
Returns: TileSpec. Can contain miscellaneous texture coordinates,
which must be obeyed so that the texture atlas can be used.
*/
TileSpec getTile(v3s16 dir, ITextureSource *tsrc,
INodeDefManager *nodemgr) const;
#endif
/*
Gets mineral content of node, if there is any.
MINERAL_NONE if doesn't contain or isn't able to contain mineral.

View File

@ -108,6 +108,11 @@ void Player::accelerate(v3f target_speed, f32 max_increase)
#endif
}
v3s16 Player::getLightPosition() const
{
return floatToInt(m_position + v3f(0,BS+BS/2,0), BS);
}
void Player::serialize(std::ostream &os)
{
// Utilize a Settings object for storing values

View File

@ -62,10 +62,7 @@ public:
return m_position;
}
v3s16 getLightPosition() const
{
return floatToInt(m_position + v3f(0,BS+BS/2,0), BS);
}
v3s16 getLightPosition() const;
v3f getEyeOffset()
{

View File

@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "auth.h"
#include "ban.h"
#include "gamedef.h"
#include "serialization.h" // For SER_FMT_VER_INVALID
struct LuaState;
typedef struct lua_State lua_State;
class IWritableToolDefManager;