#ifndef MAPNODE_HEADER
#define MAPNODE_HEADER
-#include <iostream>
-#include "common_irrlicht.h"
+#include "irrlichttypes.h"
#include "light.h"
-#include "exceptions.h"
-#include "serialization.h"
-#include "materials.h"
-#ifndef SERVER
-#include "tile.h"
-#endif
+
+class INodeDefManager;
/*
Naming scheme:
*/
#define CONTENT_AIR 126
+#ifndef SERVER
/*
Nodes make a face if contents differ and solidness differs.
Return value:
2: Face uses m2's content
equivalent: Whether the blocks share the same face (eg. water and glass)
*/
-u8 face_contents(content_t m1, content_t m2, bool *equivalent);
+u8 face_contents(content_t m1, content_t m2, bool *equivalent,
+ INodeDefManager *nodemgr);
+#endif
/*
Packs directions like (1,0,0), (1,-1,0) in six bits.
// because this needs to override part of param2
setContent(content);
}
+
+ // Create directly from a nodename
+ // If name is unknown, sets CONTENT_IGNORE
+ MapNode(INodeDefManager *ndef, const std::string &name,
+ u8 a_param1=0, u8 a_param2=0);
bool operator==(const MapNode &other)
{
}
// To be used everywhere
- content_t getContent()
+ content_t getContent() const
{
if(param0 < 0x80)
return param0;
param2 |= (c&0x0f)<<4;
}
}
+ u8 getParam1() const
+ {
+ return param1;
+ }
+ void setParam1(u8 p)
+ {
+ param1 = p;
+ }
+ u8 getParam2() const
+ {
+ if(param0 < 0x80)
+ return param2;
+ else
+ return param2 & 0x0f;
+ }
+ void setParam2(u8 p)
+ {
+ if(param0 < 0x80)
+ param2 = p;
+ else{
+ param2 &= 0xf0;
+ param2 |= (p&0x0f);
+ }
+ }
- /*
- These four are DEPRECATED I guess. -c55
- */
- bool light_propagates();
- bool sunlight_propagates();
- u8 solidness();
- u8 light_source();
-
- void setLight(enum LightBank bank, u8 a_light);
- u8 getLight(enum LightBank bank);
- u8 getLightBanksWithSource();
+ void setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr);
+ u8 getLight(enum LightBank bank, INodeDefManager *nodemgr) const;
+ u8 getLightBanksWithSource(INodeDefManager *nodemgr) const;
// 0 <= daylight_factor <= 1000
// 0 <= return value <= LIGHT_SUN
- u8 getLightBlend(u32 daylight_factor)
+ u8 getLightBlend(u32 daylight_factor, INodeDefManager *nodemgr) const
{
- u8 l = ((daylight_factor * getLight(LIGHTBANK_DAY)
- + (1000-daylight_factor) * getLight(LIGHTBANK_NIGHT))
+ u8 l = ((daylight_factor * getLight(LIGHTBANK_DAY, nodemgr)
+ + (1000-daylight_factor) * getLight(LIGHTBANK_NIGHT, nodemgr))
)/1000;
u8 max = LIGHT_MAX;
- if(getLight(LIGHTBANK_DAY) == LIGHT_SUN)
+ if(getLight(LIGHTBANK_DAY, nodemgr) == LIGHT_SUN)
max = LIGHT_SUN;
if(l > max)
l = max;
}
/*// 0 <= daylight_factor <= 1000
// 0 <= return value <= 255
- u8 getLightBlend(u32 daylight_factor)
+ u8 getLightBlend(u32 daylight_factor, INodeDefManager *nodemgr)
{
- u8 daylight = decode_light(getLight(LIGHTBANK_DAY));
- u8 nightlight = decode_light(getLight(LIGHTBANK_NIGHT));
+ u8 daylight = decode_light(getLight(LIGHTBANK_DAY, nodemgr));
+ u8 nightlight = decode_light(getLight(LIGHTBANK_NIGHT, nodemgr));
u8 mix = ((daylight_factor * daylight
+ (1000-daylight_factor) * nightlight)
)/1000;
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);
-#endif
-
/*
Gets mineral content of node, if there is any.
MINERAL_NONE if doesn't contain or isn't able to contain mineral.
*/
- u8 getMineral();
+ u8 getMineral(INodeDefManager *nodemgr) const;
/*
Serialization functions
returns encoded light value.
*/
u8 getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2,
- v3s16 face_dir);
+ v3s16 face_dir, INodeDefManager *nodemgr);
#endif