X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fmapnode.h;h=f19885d87614f6e38e04254ce59bf06c2a94b3d2;hb=fa427d641b687dd8585adced708510b94588cf51;hp=a95497ef5c3c50e3202838299146d46c28e6e89c;hpb=fd845f27f5b3e3c6587c472be76235567a7b934d;p=oweals%2Fminetest.git diff --git a/src/mapnode.h b/src/mapnode.h index a95497ef5..f19885d87 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -1,6 +1,6 @@ /* -Minetest-c55 -Copyright (C) 2010-2011 celeron55, Perttu Ahola +Minetest +Copyright (C) 2010-2013 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irr_v3d.h" #include "irr_aabb3d.h" #include "light.h" +#include #include class INodeDefManager; @@ -35,19 +36,23 @@ class INodeDefManager; - Tile = TileSpec at some side of a node of some content type */ typedef u16 content_t; -#define MAX_CONTENT 0xfff /* - Ignored node. + The maximum node ID that can be registered by mods. This must + be significantly lower than the maximum content_t value, so that + there is enough room for dummy node IDs, which are created when + a MapBlock containing unknown node names is loaded from disk. +*/ +#define MAX_REGISTERED_CONTENT 0x7fffU - Anything that stores MapNodes doesn't have to preserve parameters - associated with this material. - - Doesn't create faces with anything and is considered being - out-of-map in the game map. +/* + A solid walkable node with the texture unknown_node.png. + + For example, used on the client to display unregistered node IDs + (instead of expanding the vector of node definitions each time + such a node is received). */ -#define CONTENT_IGNORE 127 -#define CONTENT_IGNORE_DEFAULT_PARAM 0 +#define CONTENT_UNKNOWN 125 /* The common material through which the player can walk and which @@ -55,22 +60,54 @@ typedef u16 content_t; */ #define CONTENT_AIR 126 +/* + Ignored node. + + Unloaded chunks are considered to consist of this. Several other + methods return this when an error occurs. Also, during + map generation this means the node has not been set yet. + + Doesn't create faces with anything and is considered being + out-of-map in the game map. +*/ +#define CONTENT_IGNORE 127 + enum LightBank { LIGHTBANK_DAY, LIGHTBANK_NIGHT }; +/* + Simple rotation enum. +*/ +enum Rotation { + ROTATE_0, + ROTATE_90, + ROTATE_180, + ROTATE_270, + ROTATE_RAND, +}; + /* Masks for MapNode.param2 of flowing liquids */ #define LIQUID_LEVEL_MASK 0x07 #define LIQUID_FLOW_DOWN_MASK 0x08 +//#define LIQUID_LEVEL_MASK 0x3f // better finite water +//#define LIQUID_FLOW_DOWN_MASK 0x40 // not used when finite water + /* maximum amount of liquid in a block */ #define LIQUID_LEVEL_MAX LIQUID_LEVEL_MASK #define LIQUID_LEVEL_SOURCE (LIQUID_LEVEL_MAX+1) +#define LIQUID_INFINITY_MASK 0x80 //0b10000000 + +// mask for param2, now as for liquid +#define LEVELED_MASK 0x3F +#define LEVELED_MAX LEVELED_MASK + /* This is the stuff what the whole world consists of. */ @@ -163,9 +200,21 @@ struct MapNode return blend_light(daylight_factor, lightday, lightnight); } + // 0.0 <= daylight_factor <= 1.0 + // 0 <= return value <= LIGHT_SUN + u8 getLightBlendF1(float daylight_factor, INodeDefManager *nodemgr) const + { + u8 lightday = 0; + u8 lightnight = 0; + getLightBanks(lightday, lightnight, nodemgr); + return blend_light_f1(daylight_factor, lightday, lightnight); + } + u8 getFaceDir(INodeDefManager *nodemgr) const; u8 getWallMounted(INodeDefManager *nodemgr) const; v3s16 getWallMountedDir(INodeDefManager *nodemgr) const; + + void rotateAlongYAxis(INodeDefManager *nodemgr, Rotation rot); /* Gets list of node boxes (used for rendering (NDT_NODEBOX) @@ -178,6 +227,13 @@ struct MapNode */ std::vector getSelectionBoxes(INodeDefManager *nodemgr) const; + /* Liquid helpers */ + u8 getMaxLevel(INodeDefManager *nodemgr) const; + u8 getLevel(INodeDefManager *nodemgr) const; + u8 setLevel(INodeDefManager *nodemgr, s8 level = 1); + u8 addLevel(INodeDefManager *nodemgr, s8 add = 1); + void freezeMelt(INodeDefManager *nodemgr); + /* Serialization functions */