Skip to content

Commit

Permalink
Change ContentFeatures array to a vector
Browse files Browse the repository at this point in the history
  • Loading branch information
kahrl committed Jul 14, 2013
1 parent 9733dd5 commit 112dbba
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 113 deletions.
4 changes: 2 additions & 2 deletions src/inventory.cpp
Expand Up @@ -175,7 +175,7 @@ void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
// Convert old materials
if(material <= 0xff)
material = content_translate_from_19_to_internal(material);
if(material > MAX_CONTENT)
if(material > 0xfff)
throw SerializationError("Too large material number");
// Convert old id to name
NameIdMapping legacy_nimap;
Expand All @@ -194,7 +194,7 @@ void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
is>>material;
u16 materialcount;
is>>materialcount;
if(material > MAX_CONTENT)
if(material > 0xfff)
throw SerializationError("Too large material number");
// Convert old id to name
NameIdMapping legacy_nimap;
Expand Down
4 changes: 3 additions & 1 deletion src/itemdef.cpp
Expand Up @@ -519,7 +519,8 @@ class CItemDefManager: public IWritableItemDefManager

// Add the four builtin items:
// "" is the hand
// "unknown" is returned whenever an undefined item is accessed
// "unknown" is returned whenever an undefined item
// is accessed (is also the unknown node)
// "air" is the air node
// "ignore" is the ignore node

Expand All @@ -530,6 +531,7 @@ class CItemDefManager: public IWritableItemDefManager
m_item_definitions.insert(std::make_pair("", hand_def));

ItemDefinition* unknown_def = new ItemDefinition;
unknown_def->type = ITEM_NODE;
unknown_def->name = "unknown";
m_item_definitions.insert(std::make_pair("unknown", unknown_def));

Expand Down
34 changes: 25 additions & 9 deletions src/mapnode.h
Expand Up @@ -35,26 +35,42 @@ 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 0xfffU

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
is transparent to light
*/
#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,
Expand Down

0 comments on commit 112dbba

Please sign in to comment.