block = new MapBlock(&m_env.getMap(), p, this);
block->deSerialize(istr, ser_version);
sector->insertBlock(block);
-
- //DEBUG
- /*NodeMod mod;
- mod.type = NODEMOD_CHANGECONTENT;
- mod.param = CONTENT_MESE;
- block->setTempMod(v3s16(8,10,8), mod);
- block->setTempMod(v3s16(8,9,8), mod);
- block->setTempMod(v3s16(8,8,8), mod);
- block->setTempMod(v3s16(8,7,8), mod);
- block->setTempMod(v3s16(8,6,8), mod);*/
}
#if 0
#include "content_mapnode.h"
#include "player.h"
#include "mapnode.h" // For content_t
+#include "gamedef.h"
/*
items: actually *items[9]
*/
InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
{
+ INodeDefManager *ndef = gamedef->ndef();
+
// Wood
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_TREE);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_TREE"));
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_WOOD, 4);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_WOOD"), 4);
}
}
// Stick
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
if(checkItemCombination(items, specs))
{
return new CraftItem(gamedef, "Stick", 4);
specs[8] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_FENCE, 2);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_FENCE"), 2);
}
}
// Sign
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[4] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[5] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
{
//return new MapBlockObjectItem(gamedef, "Sign");
- return new MaterialItem(gamedef, CONTENT_SIGN_WALL, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_SIGN_WALL"), 1);
}
}
specs[3] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_TORCH, 4);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 4);
}
}
// Wooden pick
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
// Stone pick
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
// Mese pick
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_MESE);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_MESE);
- specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_MESE);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_MESE"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_MESE"));
+ specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_MESE"));
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
// Wooden shovel
{
ItemSpec specs[9];
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
// Stone shovel
{
ItemSpec specs[9];
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
// Wooden axe
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
// Stone axe
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
specs[4] = ItemSpec(ITEM_CRAFT, "Stick");
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
// Wooden sword
{
ItemSpec specs[9];
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[4] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
{
// Stone sword
{
ItemSpec specs[9];
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[4] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
specs[7] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
{
specs[8] = ItemSpec(ITEM_CRAFT, "steel_ingot");
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_RAIL, 15);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_RAIL"), 15);
}
}
// Chest
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[5] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[6] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[7] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[8] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_CHEST, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_CHEST"), 1);
}
}
// Locking Chest
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
specs[4] = ItemSpec(ITEM_CRAFT, "steel_ingot");
- specs[5] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[6] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[7] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[8] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_LOCKABLE_CHEST, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_LOCKABLE_CHEST"), 1);
}
}
// Furnace
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[5] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[6] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[7] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
- specs[8] = ItemSpec(ITEM_MATERIAL, CONTENT_COBBLE);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
+ specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_COBBLE"));
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_FURNACE, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_FURNACE"), 1);
}
}
specs[8] = ItemSpec(ITEM_CRAFT, "steel_ingot");
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_STEEL, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_STEEL"), 1);
}
}
// Sandstone
{
ItemSpec specs[9];
- specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_SAND);
- specs[4] = ItemSpec(ITEM_MATERIAL, CONTENT_SAND);
- specs[6] = ItemSpec(ITEM_MATERIAL, CONTENT_SAND);
- specs[7] = ItemSpec(ITEM_MATERIAL, CONTENT_SAND);
+ specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
+ specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
+ specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
+ specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_SAND"));
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_SANDSTONE, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_SANDSTONE"), 1);
}
}
specs[7] = ItemSpec(ITEM_CRAFT, "lump_of_clay");
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_CLAY, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_CLAY"), 1);
}
}
specs[7] = ItemSpec(ITEM_CRAFT, "clay_brick");
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_BRICK, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_BRICK"), 1);
}
}
// Paper
{
ItemSpec specs[9];
- specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_PAPYRUS);
- specs[4] = ItemSpec(ITEM_MATERIAL, CONTENT_PAPYRUS);
- specs[5] = ItemSpec(ITEM_MATERIAL, CONTENT_PAPYRUS);
+ specs[3] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_PAPYRUS"));
+ specs[4] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_PAPYRUS"));
+ specs[5] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_PAPYRUS"));
if(checkItemCombination(items, specs))
{
return new CraftItem(gamedef, "paper", 1);
// Book shelf
{
ItemSpec specs[9];
- specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[0] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[1] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[2] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
specs[3] = ItemSpec(ITEM_CRAFT, "book");
specs[4] = ItemSpec(ITEM_CRAFT, "book");
specs[5] = ItemSpec(ITEM_CRAFT, "book");
- specs[6] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[7] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
- specs[8] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD);
+ specs[6] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[7] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
+ specs[8] = ItemSpec(ITEM_MATERIAL, LEGN(ndef, "CONTENT_WOOD"));
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_BOOKSHELF, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_BOOKSHELF"), 1);
}
}
specs[8] = ItemSpec(ITEM_CRAFT, "Stick");
if(checkItemCombination(items, specs))
{
- return new MaterialItem(gamedef, CONTENT_LADDER, 1);
+ return new MaterialItem(gamedef, LEGN(ndef, "CONTENT_LADDER"), 1);
}
}
void craft_set_creative_inventory(Player *player, IGameDef *gamedef)
{
+ INodeDefManager *ndef = gamedef->ndef();
+
player->resetInventory();
// Give some good tools
// CONTENT_IGNORE-terminated list
content_t material_items[] = {
- CONTENT_TORCH,
- CONTENT_COBBLE,
- CONTENT_MUD,
- CONTENT_STONE,
- CONTENT_SAND,
- CONTENT_SANDSTONE,
- CONTENT_CLAY,
- CONTENT_BRICK,
- CONTENT_TREE,
- CONTENT_LEAVES,
- CONTENT_CACTUS,
- CONTENT_PAPYRUS,
- CONTENT_BOOKSHELF,
- CONTENT_GLASS,
- CONTENT_FENCE,
- CONTENT_RAIL,
- CONTENT_MESE,
- CONTENT_WATERSOURCE,
- CONTENT_CLOUD,
- CONTENT_CHEST,
- CONTENT_FURNACE,
- CONTENT_SIGN_WALL,
- CONTENT_LAVASOURCE,
+ LEGN(ndef, "CONTENT_TORCH"),
+ LEGN(ndef, "CONTENT_COBBLE"),
+ LEGN(ndef, "CONTENT_MUD"),
+ LEGN(ndef, "CONTENT_STONE"),
+ LEGN(ndef, "CONTENT_SAND"),
+ LEGN(ndef, "CONTENT_SANDSTONE"),
+ LEGN(ndef, "CONTENT_CLAY"),
+ LEGN(ndef, "CONTENT_BRICK"),
+ LEGN(ndef, "CONTENT_TREE"),
+ LEGN(ndef, "CONTENT_LEAVES"),
+ LEGN(ndef, "CONTENT_CACTUS"),
+ LEGN(ndef, "CONTENT_PAPYRUS"),
+ LEGN(ndef, "CONTENT_BOOKSHELF"),
+ LEGN(ndef, "CONTENT_GLASS"),
+ LEGN(ndef, "CONTENT_FENCE"),
+ LEGN(ndef, "CONTENT_RAIL"),
+ LEGN(ndef, "CONTENT_MESE"),
+ LEGN(ndef, "CONTENT_WATERSOURCE"),
+ LEGN(ndef, "CONTENT_CLOUD"),
+ LEGN(ndef, "CONTENT_CHEST"),
+ LEGN(ndef, "CONTENT_FURNACE"),
+ LEGN(ndef, "CONTENT_SIGN_WALL"),
+ LEGN(ndef, "CONTENT_LAVASOURCE"),
CONTENT_IGNORE
};
}
#if 0
- assert(USEFUL_CONTENT_COUNT <= PLAYER_INVENTORY_SIZE);
+ assert(USEFUL_LEGN(ndef, "CONTENT_COUNT") <= PLAYER_INVENTORY_SIZE);
// add torch first
- InventoryItem *item = new MaterialItem(gamedef, CONTENT_TORCH, 1);
+ InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 1);
player->inventory.addItem("main", item);
// Then others
- for(u16 i=0; i<USEFUL_CONTENT_COUNT; i++)
+ for(u16 i=0; i<USEFUL_LEGN(ndef, "CONTENT_COUNT"); i++)
{
// Skip some materials
- if(i == CONTENT_WATER || i == CONTENT_TORCH
- || i == CONTENT_COALSTONE)
+ if(i == LEGN(ndef, "CONTENT_WATER") || i == LEGN(ndef, "CONTENT_TORCH")
+ || i == LEGN(ndef, "CONTENT_COALSTONE"))
continue;
InventoryItem *item = new MaterialItem(gamedef, i, 1);
void craft_give_initial_stuff(Player *player, IGameDef *gamedef)
{
+ INodeDefManager *ndef = gamedef->ndef();
+
{
InventoryItem *item = new ToolItem(gamedef, "SteelPick", 0);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
{
- InventoryItem *item = new MaterialItem(gamedef, CONTENT_TORCH, 99);
+ InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TORCH"), 99);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
assert(r == NULL);
}
{
- InventoryItem *item = new MaterialItem(gamedef, CONTENT_COBBLE, 99);
+ InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_COBBLE"), 99);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
/*{
- InventoryItem *item = new MaterialItem(gamedef, CONTENT_MESE, 6);
+ InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_MESE"), 6);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
{
- InventoryItem *item = new MaterialItem(gamedef, CONTENT_COALSTONE, 6);
+ InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_COALSTONE"), 6);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
{
- InventoryItem *item = new MaterialItem(gamedef, CONTENT_WOOD, 6);
+ InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_WOOD"), 6);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
}*/
/*// Give some other stuff
{
- InventoryItem *item = new MaterialItem(gamedef, CONTENT_TREE, 999);
+ InventoryItem *item = new MaterialItem(gamedef, LEGN(ndef, "CONTENT_TREE"), 999);
bool r = player->inventory.addItem("main", item);
assert(r == true);
}*/
#include "nodedef.h"
#include "utility.h"
#include "nameidmapping.h"
+#include <map>
+
+/*
+ Legacy node definitions
+*/
#define WATER_ALPHA 160
mprop.cuttability = -1.0;
}
+/*
+ Legacy node content type IDs
+ Ranges:
+ 0x000...0x07f (0...127): param2 is fully usable
+ 126 and 127 are reserved (CONTENT_AIR and CONTENT_IGNORE).
+ 0x800...0xfff (2048...4095): higher 4 bytes of param2 are not usable
+*/
+#define CONTENT_STONE 0
+#define CONTENT_WATER 2
+#define CONTENT_TORCH 3
+#define CONTENT_WATERSOURCE 9
+#define CONTENT_SIGN_WALL 14
+#define CONTENT_CHEST 15
+#define CONTENT_FURNACE 16
+#define CONTENT_LOCKABLE_CHEST 17
+#define CONTENT_FENCE 21
+#define CONTENT_RAIL 30
+#define CONTENT_LADDER 31
+#define CONTENT_LAVA 32
+#define CONTENT_LAVASOURCE 33
+#define CONTENT_GRASS 0x800 //1
+#define CONTENT_TREE 0x801 //4
+#define CONTENT_LEAVES 0x802 //5
+#define CONTENT_GRASS_FOOTSTEPS 0x803 //6
+#define CONTENT_MESE 0x804 //7
+#define CONTENT_MUD 0x805 //8
+#define CONTENT_CLOUD 0x806 //10
+#define CONTENT_COALSTONE 0x807 //11
+#define CONTENT_WOOD 0x808 //12
+#define CONTENT_SAND 0x809 //13
+#define CONTENT_COBBLE 0x80a //18
+#define CONTENT_STEEL 0x80b //19
+#define CONTENT_GLASS 0x80c //20
+#define CONTENT_MOSSYCOBBLE 0x80d //22
+#define CONTENT_GRAVEL 0x80e //23
+#define CONTENT_SANDSTONE 0x80f //24
+#define CONTENT_CACTUS 0x810 //25
+#define CONTENT_BRICK 0x811 //26
+#define CONTENT_CLAY 0x812 //27
+#define CONTENT_PAPYRUS 0x813 //28
+#define CONTENT_BOOKSHELF 0x814 //29
+#define CONTENT_JUNGLETREE 0x815
+#define CONTENT_JUNGLEGRASS 0x816
+#define CONTENT_NC 0x817
+#define CONTENT_NC_RB 0x818
+#define CONTENT_APPLE 0x819
+#define CONTENT_SAPLING 0x820
+
/*
A conversion table for backwards compatibility.
Maps <=v19 content types to current ones.
nimap->set(CONTENT_AIR, "air");
}
-// See header for description
+class NewNameGetter
+{
+public:
+ NewNameGetter()
+ {
+ old_to_new["CONTENT_STONE"] = "";
+ old_to_new["CONTENT_WATER"] = "";
+ old_to_new["CONTENT_TORCH"] = "";
+ old_to_new["CONTENT_WATERSOURCE"] = "";
+ old_to_new["CONTENT_SIGN_WALL"] = "";
+ old_to_new["CONTENT_CHEST"] = "";
+ old_to_new["CONTENT_FURNACE"] = "";
+ old_to_new["CONTENT_LOCKABLE_CHEST"] = "";
+ old_to_new["CONTENT_FENCE"] = "";
+ old_to_new["CONTENT_RAIL"] = "";
+ old_to_new["CONTENT_LADDER"] = "";
+ old_to_new["CONTENT_LAVA"] = "";
+ old_to_new["CONTENT_LAVASOURCE"] = "";
+ old_to_new["CONTENT_GRASS"] = "";
+ old_to_new["CONTENT_TREE"] = "";
+ old_to_new["CONTENT_LEAVES"] = "";
+ old_to_new["CONTENT_GRASS_FOOTSTEPS"] = "";
+ old_to_new["CONTENT_MESE"] = "";
+ old_to_new["CONTENT_MUD"] = "";
+ old_to_new["CONTENT_CLOUD"] = "";
+ old_to_new["CONTENT_COALSTONE"] = "";
+ old_to_new["CONTENT_WOOD"] = "";
+ old_to_new["CONTENT_SAND"] = "";
+ old_to_new["CONTENT_COBBLE"] = "";
+ old_to_new["CONTENT_STEEL"] = "";
+ old_to_new["CONTENT_GLASS"] = "";
+ old_to_new["CONTENT_MOSSYCOBBLE"] = "";
+ old_to_new["CONTENT_GRAVEL"] = "";
+ old_to_new["CONTENT_SANDSTONE"] = "";
+ old_to_new["CONTENT_CACTUS"] = "";
+ old_to_new["CONTENT_BRICK"] = "";
+ old_to_new["CONTENT_CLAY"] = "";
+ old_to_new["CONTENT_PAPYRUS"] = "";
+ old_to_new["CONTENT_BOOKSHELF"] = "";
+ old_to_new["CONTENT_JUNGLETREE"] = "";
+ old_to_new["CONTENT_JUNGLEGRASS"] = "";
+ old_to_new["CONTENT_NC"] = "";
+ old_to_new["CONTENT_NC_RB"] = "";
+ old_to_new["CONTENT_APPLE"] = "";
+ old_to_new["CONTENT_SAPLING"] = "";
+ // Just in case
+ old_to_new["CONTENT_IGNORE"] = "ignore";
+ old_to_new["CONTENT_AIR"] = "air";
+ }
+ std::string get(const std::string &old)
+ {
+ std::map<std::string, std::string>::const_iterator i;
+ i = old_to_new.find(old);
+ if(i == old_to_new.end())
+ return "";
+ return i->second;
+ }
+private:
+ std::map<std::string, std::string> old_to_new;
+};
+
+NewNameGetter newnamegetter;
+
+std::string content_mapnode_get_new_name(const std::string &oldname)
+{
+ return newnamegetter.get(oldname);
+}
+
+content_t legacy_get_id(const std::string &oldname, INodeDefManager *ndef)
+{
+ std::string newname = content_mapnode_get_new_name(oldname);
+ if(newname == "")
+ return CONTENT_IGNORE;
+ content_t id;
+ bool found = ndef->getId(newname, id);
+ if(!found)
+ return CONTENT_IGNORE;
+ return id;
+}
+
+// Initialize default (legacy) node definitions
void content_mapnode_init(IWritableNodeDefManager *nodemgr)
{
content_t i;
#define CONTENT_MAPNODE_HEADER
#include "mapnode.h"
-class IWritableNodeDefManager;
/*
- Initialize default node definitions
-
- This accesses tsrc; if it is non-NULL, textures are set
- for the nodes.
+ Legacy node definitions
+*/
- Client first calls this with tsrc=NULL to run some
- unit tests and stuff, then it runs this again with tsrc
- defined to get the textures.
+class IWritableNodeDefManager;
- Server only calls this once with tsrc=NULL.
-*/
+// Initialize default (legacy) node definitions
void content_mapnode_init(IWritableNodeDefManager *nodemgr);
// Backwards compatibility for non-extended content types in v19
MapNode mapnode_translate_from_internal(MapNode n_from, u8 version);
MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
-// Get legacy node name mapping
+// Get legacy node name mapping for loading old blocks
class NameIdMapping;
void content_mapnode_get_name_id_mapping(NameIdMapping *nimap);
-/*
- Node content type IDs
- Ranges:
-*/
-
-// 0x000...0x07f (0...127): param2 is fully usable
-// 126 and 127 are reserved.
-// Use these sparingly, only when the extra space in param2 might be needed.
-// Add a space when there is unused space between numbers.
-#define CONTENT_STONE 0
-
-#define CONTENT_WATER 2
-#define CONTENT_TORCH 3
-
-#define CONTENT_WATERSOURCE 9
-
-#define CONTENT_SIGN_WALL 14
-#define CONTENT_CHEST 15
-#define CONTENT_FURNACE 16
-#define CONTENT_LOCKABLE_CHEST 17
-
-#define CONTENT_FENCE 21
-
-#define CONTENT_RAIL 30
-#define CONTENT_LADDER 31
-#define CONTENT_LAVA 32
-#define CONTENT_LAVASOURCE 33
-
-// 0x800...0xfff (2048...4095): higher 4 bytes of param2 are not usable
-#define CONTENT_GRASS 0x800 //1
-#define CONTENT_TREE 0x801 //4
-#define CONTENT_LEAVES 0x802 //5
-#define CONTENT_GRASS_FOOTSTEPS 0x803 //6
-#define CONTENT_MESE 0x804 //7
-#define CONTENT_MUD 0x805 //8
-// Pretty much useless, clouds won't be drawn this way
-#define CONTENT_CLOUD 0x806 //10
-#define CONTENT_COALSTONE 0x807 //11
-#define CONTENT_WOOD 0x808 //12
-#define CONTENT_SAND 0x809 //13
-#define CONTENT_COBBLE 0x80a //18
-#define CONTENT_STEEL 0x80b //19
-#define CONTENT_GLASS 0x80c //20
-#define CONTENT_MOSSYCOBBLE 0x80d //22
-#define CONTENT_GRAVEL 0x80e //23
-#define CONTENT_SANDSTONE 0x80f //24
-#define CONTENT_CACTUS 0x810 //25
-#define CONTENT_BRICK 0x811 //26
-#define CONTENT_CLAY 0x812 //27
-#define CONTENT_PAPYRUS 0x813 //28
-#define CONTENT_BOOKSHELF 0x814 //29
-#define CONTENT_JUNGLETREE 0x815
-#define CONTENT_JUNGLEGRASS 0x816
-#define CONTENT_NC 0x817
-#define CONTENT_NC_RB 0x818
-#define CONTENT_APPLE 0x819
-#define CONTENT_SAPLING 0x820
+// Convert "CONTENT_STONE"-style names to dynamic ids
+std::string content_mapnode_get_new_name(const std::string &oldname);
+class INodeDefManager;
+content_t legacy_get_id(const std::string &oldname, INodeDefManager *ndef);
+#define LEGN(ndef, oldname) legacy_get_id(oldname, ndef)
#endif
#include "content_nodemeta.h"
#include "inventory.h"
-#include "content_mapnode.h"
#include "log.h"
#include "utility.h"
+#define NODEMETA_SIGN 14
+#define NODEMETA_CHEST 15
+#define NODEMETA_LOCKABLE_CHEST 17
+#define NODEMETA_FURNACE 16
+
/*
SignNodeMetadata
*/
}
u16 SignNodeMetadata::typeId() const
{
- return CONTENT_SIGN_WALL;
+ return NODEMETA_SIGN;
}
NodeMetadata* SignNodeMetadata::create(std::istream &is, IGameDef *gamedef)
{
}
u16 ChestNodeMetadata::typeId() const
{
- return CONTENT_CHEST;
+ return NODEMETA_CHEST;
}
NodeMetadata* ChestNodeMetadata::create(std::istream &is, IGameDef *gamedef)
{
}
u16 LockingChestNodeMetadata::typeId() const
{
- return CONTENT_LOCKABLE_CHEST;
+ return NODEMETA_LOCKABLE_CHEST;
}
NodeMetadata* LockingChestNodeMetadata::create(std::istream &is, IGameDef *gamedef)
{
}
u16 FurnaceNodeMetadata::typeId() const
{
- return CONTENT_FURNACE;
+ return NODEMETA_FURNACE;
}
NodeMetadata* FurnaceNodeMetadata::clone(IGameDef *gamedef)
{
#if 1
// Test something:
// Convert all mud under proper day lighting to grass
- if(n.getContent() == CONTENT_MUD)
+ if(n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_MUD"))
{
if(dtime_s > 300)
{
if(m_gamedef->ndef()->get(n_top).air_equivalent &&
n_top.getLight(LIGHTBANK_DAY, m_gamedef->ndef()) >= 13)
{
- n.setContent(CONTENT_GRASS);
+ n.setContent(LEGN(m_gamedef->ndef(), "CONTENT_GRASS"));
m_map->addNodeWithEvent(p, n);
}
}
v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0), BS);
try{
MapNode n = m_map->getNode(bottompos);
- if(n.getContent() == CONTENT_GRASS)
+ if(n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_GRASS"))
{
- n.setContent(CONTENT_GRASS_FOOTSTEPS);
+ n.setContent(LEGN(m_gamedef->ndef(), "CONTENT_GRASS_FOOTSTEPS"));
m_map->setNode(bottompos, n);
}
}
Test something:
Convert mud under proper lighting to grass
*/
- if(n.getContent() == CONTENT_MUD)
+ if(n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_MUD"))
{
if(myrand()%20 == 0)
{
n_top.getLightBlend(getDayNightRatio(),
m_gamedef->ndef()) >= 13)
{
- n.setContent(CONTENT_GRASS);
+ n.setContent(LEGN(m_gamedef->ndef(), "CONTENT_GRASS"));
m_map->addNodeWithEvent(p, n);
}
}
/*
Convert grass into mud if under something else than air
*/
- if(n.getContent() == CONTENT_GRASS)
+ if(n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_GRASS"))
{
//if(myrand()%20 == 0)
{
MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0));
if(m_gamedef->ndef()->get(n_top).air_equivalent == false)
{
- n.setContent(CONTENT_MUD);
+ n.setContent(LEGN(m_gamedef->ndef(), "CONTENT_MUD"));
m_map->addNodeWithEvent(p, n);
}
}
/*
Rats spawn around regular trees
*/
- if(n.getContent() == CONTENT_TREE ||
- n.getContent() == CONTENT_JUNGLETREE)
+ if(n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_TREE") ||
+ n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_JUNGLETREE"))
{
if(myrand()%200 == 0 && active_object_count_wider == 0)
{
0, myrand_range(-2, 2));
MapNode n1 = m_map->getNodeNoEx(p1);
MapNode n1b = m_map->getNodeNoEx(p1+v3s16(0,-1,0));
- if(n1b.getContent() == CONTENT_GRASS &&
+ if(n1b.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_GRASS") &&
n1.getContent() == CONTENT_AIR)
{
v3f pos = intToFloat(p1, BS);
/*
Fun things spawn in caves and dungeons
*/
- if(n.getContent() == CONTENT_STONE ||
- n.getContent() == CONTENT_MOSSYCOBBLE)
+ if(n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_STONE") ||
+ n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_MOSSYCOBBLE"))
{
if(myrand()%200 == 0 && active_object_count_wider == 0)
{
/*
Make trees from saplings!
*/
- if(n.getContent() == CONTENT_SAPLING)
+ if(n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_SAPLING"))
{
if(myrand()%50 == 0)
{
v3s16 tree_blockp = getNodeBlockPos(tree_p);
vmanip.initialEmerge(tree_blockp - v3s16(1,1,1), tree_blockp + v3s16(1,1,1));
bool is_apple_tree = myrand()%4 == 0;
- mapgen::make_tree(vmanip, tree_p, is_apple_tree);
+ mapgen::make_tree(vmanip, tree_p, is_apple_tree,
+ m_gamedef->ndef());
vmanip.blitBackAll(&modified_blocks);
// update lighting
v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0), BS);
try{
MapNode n = m_map->getNode(bottompos);
- if(n.getContent() == CONTENT_GRASS)
+ if(n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_GRASS"))
{
- n.setContent(CONTENT_GRASS_FOOTSTEPS);
+ n.setContent(LEGN(m_gamedef->ndef(), "CONTENT_GRASS_FOOTSTEPS"));
m_map->setNode(bottompos, n);
// Update mesh on client
if(m_map->mapType() == MAPTYPE_CLIENT)
data->no_op = false;
data->seed = m_seed;
data->blockpos = blockpos;
- data->nodemgr = m_gamedef->ndef();
+ data->nodedef = m_gamedef->ndef();
/*
Create the whole area of this and the neighboring blocks
else
{
MapNode n = getNode(v3s16(x, MAP_BLOCKSIZE-1, z));
- //if(n.getContent() == CONTENT_WATER || n.getContent() == CONTENT_WATERSOURCE)
if(m_gamedef->ndef()->get(n).sunlight_propagates == false)
{
no_sunlight = true;
}
else if(nodemgr->get(n).light_propagates == false)
{
- /*// DEPRECATED TODO: REMOVE
- if(grow_grass)
- {
- bool upper_is_air = false;
- try
- {
- if(getNodeParent(pos+v3s16(0,1,0)).getContent() == CONTENT_AIR)
- upper_is_air = true;
- }
- catch(InvalidPositionException &e)
- {
- }
- // Turn mud into grass
- if(upper_is_air && n.getContent() == CONTENT_MUD
- && current_light == LIGHT_SUN)
- {
- n.d = CONTENT_GRASS;
- }
- }*/
-
// A solid object is on the way.
stopped_to_solid_object = true;
#include "mapgen.h"
#include "voxel.h"
-#include "content_mapnode.h"
#include "noise.h"
#include "mapblock.h"
#include "map.h"
//#include "serverobject.h"
#include "content_sao.h"
#include "nodedef.h"
+#include "content_mapnode.h" // For content_mapnode_get_new_name
namespace mapgen
{
{
MapNode &n = vmanip.m_data[i];
if(content_walkable(n.d)
- && n.getContent() != CONTENT_TREE
- && n.getContent() != CONTENT_LEAVES)
+ && n.getContent() != LEGN(ndef, "CONTENT_TREE")
+ && n.getContent() != LEGN(ndef, "CONTENT_LEAVES"))
break;
vmanip.m_area.add_y(em, i, -1);
}
#endif
-void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0, bool is_apple_tree)
+void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
+ bool is_apple_tree, INodeDefManager *ndef)
{
- MapNode treenode(CONTENT_TREE);
- MapNode leavesnode(CONTENT_LEAVES);
- MapNode applenode(CONTENT_APPLE);
+ MapNode treenode(LEGN(ndef, "CONTENT_TREE"));
+ MapNode leavesnode(LEGN(ndef, "CONTENT_LEAVES"));
+ MapNode applenode(LEGN(ndef, "CONTENT_APPLE"));
s16 trunk_h = myrand_range(4, 5);
v3s16 p1 = p0;
}
}
-static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0)
+static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
+ INodeDefManager *ndef)
{
- MapNode treenode(CONTENT_JUNGLETREE);
- MapNode leavesnode(CONTENT_LEAVES);
+ MapNode treenode(LEGN(ndef, "CONTENT_JUNGLETREE"));
+ MapNode leavesnode(LEGN(ndef, "CONTENT_LEAVES"));
for(s16 x=-1; x<=1; x++)
for(s16 z=-1; z<=1; z++)
}
}
-void make_papyrus(VoxelManipulator &vmanip, v3s16 p0)
+void make_papyrus(VoxelManipulator &vmanip, v3s16 p0,
+ INodeDefManager *ndef)
{
- MapNode papyrusnode(CONTENT_PAPYRUS);
+ MapNode papyrusnode(LEGN(ndef, "CONTENT_PAPYRUS"));
s16 trunk_h = myrand_range(2, 3);
v3s16 p1 = p0;
}
}
-void make_cactus(VoxelManipulator &vmanip, v3s16 p0)
+void make_cactus(VoxelManipulator &vmanip, v3s16 p0,
+ INodeDefManager *ndef)
{
- MapNode cactusnode(CONTENT_CACTUS);
+ MapNode cactusnode(LEGN(ndef, "CONTENT_CACTUS"));
s16 trunk_h = 3;
v3s16 p1 = p0;
#if 0
static void make_randomstone(VoxelManipulator &vmanip, v3s16 p0)
{
- MapNode stonenode(CONTENT_STONE);
+ MapNode stonenode(LEGN(ndef, "CONTENT_STONE"));
s16 size = myrand_range(3, 6);
#if 0
static void make_largestone(VoxelManipulator &vmanip, v3s16 p0)
{
- MapNode stonenode(CONTENT_STONE);
+ MapNode stonenode(LEGN(ndef, "CONTENT_STONE"));
s16 size = myrand_range(8, 16);
#define VMANIP_FLAG_DUNGEON_UNTOUCHABLE (\
VMANIP_FLAG_DUNGEON_INSIDE|VMANIP_FLAG_DUNGEON_PRESERVE)
-static void make_room1(VoxelManipulator &vmanip, v3s16 roomsize, v3s16 roomplace)
+static void make_room1(VoxelManipulator &vmanip, v3s16 roomsize, v3s16 roomplace,
+ INodeDefManager *ndef)
{
// Make +-X walls
for(s16 z=0; z<roomsize.Z; z++)
u32 vi = vmanip.m_area.index(p);
if(vmanip.m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vmanip.m_data[vi] = MapNode(CONTENT_COBBLE);
+ vmanip.m_data[vi] = MapNode(LEGN(ndef, "CONTENT_COBBLE"));
}
{
v3s16 p = roomplace + v3s16(roomsize.X-1,y,z);
u32 vi = vmanip.m_area.index(p);
if(vmanip.m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vmanip.m_data[vi] = MapNode(CONTENT_COBBLE);
+ vmanip.m_data[vi] = MapNode(LEGN(ndef, "CONTENT_COBBLE"));
}
}
u32 vi = vmanip.m_area.index(p);
if(vmanip.m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vmanip.m_data[vi] = MapNode(CONTENT_COBBLE);
+ vmanip.m_data[vi] = MapNode(LEGN(ndef, "CONTENT_COBBLE"));
}
{
v3s16 p = roomplace + v3s16(x,y,roomsize.Z-1);
u32 vi = vmanip.m_area.index(p);
if(vmanip.m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vmanip.m_data[vi] = MapNode(CONTENT_COBBLE);
+ vmanip.m_data[vi] = MapNode(LEGN(ndef, "CONTENT_COBBLE"));
}
}
u32 vi = vmanip.m_area.index(p);
if(vmanip.m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vmanip.m_data[vi] = MapNode(CONTENT_COBBLE);
+ vmanip.m_data[vi] = MapNode(LEGN(ndef, "CONTENT_COBBLE"));
}
{
v3s16 p = roomplace + v3s16(x,roomsize.Y-1,z);
u32 vi = vmanip.m_area.index(p);
if(vmanip.m_flags[vi] & VMANIP_FLAG_DUNGEON_UNTOUCHABLE)
continue;
- vmanip.m_data[vi] = MapNode(CONTENT_COBBLE);
+ vmanip.m_data[vi] = MapNode(LEGN(ndef, "CONTENT_COBBLE"));
}
}
}
}
-static void make_hole1(VoxelManipulator &vmanip, v3s16 place)
+static void make_hole1(VoxelManipulator &vmanip, v3s16 place,
+ INodeDefManager *ndef)
{
make_fill(vmanip, place, v3s16(1,2,1), 0, MapNode(CONTENT_AIR),
VMANIP_FLAG_DUNGEON_INSIDE);
}
-static void make_door1(VoxelManipulator &vmanip, v3s16 doorplace, v3s16 doordir)
+static void make_door1(VoxelManipulator &vmanip, v3s16 doorplace, v3s16 doordir,
+ INodeDefManager *ndef)
{
- make_hole1(vmanip, doorplace);
+ make_hole1(vmanip, doorplace, ndef);
// Place torch (for testing)
- //vmanip.m_data[vmanip.m_area.index(doorplace)] = MapNode(CONTENT_TORCH);
+ //vmanip.m_data[vmanip.m_area.index(doorplace)] = MapNode(LEGN(ndef, "CONTENT_TORCH"));
}
static v3s16 rand_ortho_dir(PseudoRandom &random)
static void make_corridor(VoxelManipulator &vmanip, v3s16 doorplace,
v3s16 doordir, v3s16 &result_place, v3s16 &result_dir,
- PseudoRandom &random)
+ PseudoRandom &random, INodeDefManager *ndef)
{
- make_hole1(vmanip, doorplace);
+ make_hole1(vmanip, doorplace, ndef);
v3s16 p0 = doorplace;
v3s16 dir = doordir;
u32 length;
if(make_stairs)
{
make_fill(vmanip, p+v3s16(-1,-1,-1), v3s16(3,5,3),
- VMANIP_FLAG_DUNGEON_UNTOUCHABLE, MapNode(CONTENT_COBBLE), 0);
+ VMANIP_FLAG_DUNGEON_UNTOUCHABLE, MapNode(LEGN(ndef, "CONTENT_COBBLE")), 0);
make_fill(vmanip, p, v3s16(1,2,1), 0, MapNode(CONTENT_AIR),
VMANIP_FLAG_DUNGEON_INSIDE);
make_fill(vmanip, p-dir, v3s16(1,2,1), 0, MapNode(CONTENT_AIR),
else
{
make_fill(vmanip, p+v3s16(-1,-1,-1), v3s16(3,4,3),
- VMANIP_FLAG_DUNGEON_UNTOUCHABLE, MapNode(CONTENT_COBBLE), 0);
- make_hole1(vmanip, p);
+ VMANIP_FLAG_DUNGEON_UNTOUCHABLE, MapNode(LEGN(ndef, "CONTENT_COBBLE")), 0);
+ make_hole1(vmanip, p, ndef);
/*make_fill(vmanip, p, v3s16(1,2,1), 0, MapNode(CONTENT_AIR),
VMANIP_FLAG_DUNGEON_INSIDE);*/
}
{
public:
- RoomWalker(VoxelManipulator &vmanip_, v3s16 pos, PseudoRandom &random):
+ RoomWalker(VoxelManipulator &vmanip_, v3s16 pos, PseudoRandom &random,
+ INodeDefManager *ndef):
vmanip(vmanip_),
m_pos(pos),
- m_random(random)
+ m_random(random),
+ m_ndef(ndef)
{
randomizeDir();
}
continue;
}
if(vmanip.getNodeNoExNoEmerge(p).getContent()
- == CONTENT_COBBLE
+ == LEGN(m_ndef, "CONTENT_COBBLE")
&& vmanip.getNodeNoExNoEmerge(p1).getContent()
- == CONTENT_COBBLE)
+ == LEGN(m_ndef, "CONTENT_COBBLE"))
{
// Found wall, this is a good place!
result_place = p;
*/
// Jump one up if the actual space is there
if(vmanip.getNodeNoExNoEmerge(p+v3s16(0,0,0)).getContent()
- == CONTENT_COBBLE
+ == LEGN(m_ndef, "CONTENT_COBBLE")
&& vmanip.getNodeNoExNoEmerge(p+v3s16(0,1,0)).getContent()
- == CONTENT_AIR
+ == LEGN(m_ndef, "CONTENT_AIR")
&& vmanip.getNodeNoExNoEmerge(p+v3s16(0,2,0)).getContent()
- == CONTENT_AIR)
+ == LEGN(m_ndef, "CONTENT_AIR"))
p += v3s16(0,1,0);
// Jump one down if the actual space is there
if(vmanip.getNodeNoExNoEmerge(p+v3s16(0,1,0)).getContent()
- == CONTENT_COBBLE
+ == LEGN(m_ndef, "CONTENT_COBBLE")
&& vmanip.getNodeNoExNoEmerge(p+v3s16(0,0,0)).getContent()
- == CONTENT_AIR
+ == LEGN(m_ndef, "CONTENT_AIR")
&& vmanip.getNodeNoExNoEmerge(p+v3s16(0,-1,0)).getContent()
- == CONTENT_AIR)
+ == LEGN(m_ndef, "CONTENT_AIR"))
p += v3s16(0,-1,0);
// Check if walking is now possible
if(vmanip.getNodeNoExNoEmerge(p).getContent()
- != CONTENT_AIR
+ != LEGN(m_ndef, "CONTENT_AIR")
|| vmanip.getNodeNoExNoEmerge(p+v3s16(0,1,0)).getContent()
- != CONTENT_AIR)
+ != LEGN(m_ndef, "CONTENT_AIR"))
{
// Cannot continue walking here
randomizeDir();
v3s16 m_pos;
v3s16 m_dir;
PseudoRandom &m_random;
+ INodeDefManager *m_ndef;
};
-static void make_dungeon1(VoxelManipulator &vmanip, PseudoRandom &random)
+static void make_dungeon1(VoxelManipulator &vmanip, PseudoRandom &random,
+ INodeDefManager *ndef)
{
v3s16 areasize = vmanip.m_area.getExtent();
v3s16 roomsize;
for(u32 i=0; i<room_count; i++)
{
// Make a room to the determined place
- make_room1(vmanip, roomsize, roomplace);
+ make_room1(vmanip, roomsize, roomplace, ndef);
v3s16 room_center = roomplace + v3s16(roomsize.X/2,1,roomsize.Z/2);
// Place torch at room center (for testing)
- //vmanip.m_data[vmanip.m_area.index(room_center)] = MapNode(CONTENT_TORCH);
+ //vmanip.m_data[vmanip.m_area.index(room_center)] = MapNode(LEGN(ndef, "CONTENT_TORCH"));
// Quit if last room
if(i == room_count-1)
}
// Create walker and find a place for a door
- RoomWalker walker(vmanip, walker_start_place, random);
+ RoomWalker walker(vmanip, walker_start_place, random, ndef);
v3s16 doorplace;
v3s16 doordir;
bool r = walker.findPlaceForDoor(doorplace, doordir);
if(random.range(0,1)==0)
// Make the door
- make_door1(vmanip, doorplace, doordir);
+ make_door1(vmanip, doorplace, doordir, ndef);
else
// Don't actually make a door
doorplace -= doordir;
v3s16 corridor_end;
v3s16 corridor_end_dir;
make_corridor(vmanip, doorplace, doordir, corridor_end,
- corridor_end_dir, random);
+ corridor_end_dir, random, ndef);
// Find a place for a random sized room
roomsize = v3s16(random.range(4,8),random.range(4,6),random.range(4,8));
if(random.range(0,1)==0)
// Make the door
- make_door1(vmanip, doorplace, doordir);
+ make_door1(vmanip, doorplace, doordir, ndef);
else
// Don't actually make a door
roomplace -= doordir;
}
}
-static void make_nc(VoxelManipulator &vmanip, PseudoRandom &random)
+static void make_nc(VoxelManipulator &vmanip, PseudoRandom &random,
+ INodeDefManager *ndef)
{
v3s16 dir;
u8 facedir_i = 0;
16+random.range(0,15),
16+random.range(0,15),
16+random.range(0,15));
- vmanip.m_data[vmanip.m_area.index(p)] = MapNode(CONTENT_NC, facedir_i);
+ vmanip.m_data[vmanip.m_area.index(p)] = MapNode(LEGN(ndef, "CONTENT_NC"), facedir_i);
u32 length = random.range(3,15);
for(u32 j=0; j<length; j++)
{
p -= dir;
- vmanip.m_data[vmanip.m_area.index(p)] = MapNode(CONTENT_NC_RB);
+ vmanip.m_data[vmanip.m_area.index(p)] = MapNode(LEGN(ndef, "CONTENT_NC_RB"));
}
}
MapNode n = block->getNodeNoEx(p);
if(n.getContent() == CONTENT_IGNORE)
continue;
- if(data->nodemgr->get(n)->liquid_type != LIQUID_NONE)
+ if(data->nodedef->get(n)->liquid_type != LIQUID_NONE)
continue;
- if(data->nodemgr->get(n)->walkable)
+ if(data->nodedef->get(n)->walkable)
{
last_node_walkable = true;
continue;
}
assert(data->vmanip);
- assert(data->nodemgr);
+ assert(data->nodedef);
+
+ INodeDefManager *ndef = data->nodedef;
v3s16 blockpos = data->blockpos;
if(vmanip.m_data[i].getContent() == CONTENT_IGNORE)
{
if(y <= WATER_LEVEL)
- vmanip.m_data[i] = MapNode(CONTENT_WATERSOURCE);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_WATERSOURCE"));
else
vmanip.m_data[i] = MapNode(CONTENT_AIR);
}
v3s16(x,y,z), data->seed) == false)
{
if(y <= WATER_LEVEL)
- vmanip.m_data[i] = MapNode(CONTENT_WATERSOURCE);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_WATERSOURCE"));
else
vmanip.m_data[i] = MapNode(CONTENT_AIR);
}
else if(noisebuf_cave.get(x,y,z) > CAVE_NOISE_THRESHOLD)
vmanip.m_data[i] = MapNode(CONTENT_AIR);
else
- vmanip.m_data[i] = MapNode(CONTENT_STONE);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_STONE"));
}
data->vmanip->m_area.add_y(em, i, 1);
{
v3s16 p = v3s16(x,y,z) + g_27dirs[i];
u32 vi = vmanip.m_area.index(p);
- if(vmanip.m_data[vi].getContent() == CONTENT_STONE)
+ if(vmanip.m_data[vi].getContent() == LEGN(ndef, "CONTENT_STONE"))
if(mineralrandom.next()%8 == 0)
- vmanip.m_data[vi] = MapNode(CONTENT_MESE);
+ vmanip.m_data[vi] = MapNode(LEGN(ndef, "CONTENT_MESE"));
}
}
s16 y = mineralrandom.range(node_min.Y+1, node_max.Y-1);
s16 z = mineralrandom.range(node_min.Z+1, node_max.Z-1);
- u8 base_content = CONTENT_STONE;
+ u8 base_content = LEGN(ndef, "CONTENT_STONE");
MapNode new_content(CONTENT_IGNORE);
u32 sparseness = 6;
if(noisebuf_ground_crumbleness.get(x,y+5,z) < -0.1)
{
- new_content = MapNode(CONTENT_STONE, MINERAL_COAL);
+ new_content = MapNode(LEGN(ndef, "CONTENT_STONE"), MINERAL_COAL);
}
else
{
if(noisebuf_ground_wetness.get(x,y+5,z) > 0.0)
- new_content = MapNode(CONTENT_STONE, MINERAL_IRON);
+ new_content = MapNode(LEGN(ndef, "CONTENT_STONE"), MINERAL_IRON);
/*if(noisebuf_ground_wetness.get(x,y,z) > 0.0)
- vmanip.m_data[i] = MapNode(CONTENT_MUD);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_MUD"));
else
- vmanip.m_data[i] = MapNode(CONTENT_SAND);*/
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_SAND"));*/
}
/*else if(noisebuf_ground_crumbleness.get(x,y,z) > 0.1)
{
{
v3s16 p = v3s16(x,y,z) + g_27dirs[i];
u32 vi = vmanip.m_area.index(p);
- if(vmanip.m_data[vi].getContent() == CONTENT_STONE)
+ if(vmanip.m_data[vi].getContent() == LEGN(ndef, "CONTENT_STONE"))
if(mineralrandom.next()%8 == 0)
- vmanip.m_data[vi] = MapNode(CONTENT_STONE, MINERAL_COAL);
+ vmanip.m_data[vi] = MapNode(LEGN(ndef, "CONTENT_STONE"), MINERAL_COAL);
}
}
}
{
v3s16 p = v3s16(x,y,z) + g_27dirs[i];
u32 vi = vmanip.m_area.index(p);
- if(vmanip.m_data[vi].getContent() == CONTENT_STONE)
+ if(vmanip.m_data[vi].getContent() == LEGN(ndef, "CONTENT_STONE"))
if(mineralrandom.next()%8 == 0)
- vmanip.m_data[vi] = MapNode(CONTENT_STONE, MINERAL_IRON);
+ vmanip.m_data[vi] = MapNode(LEGN(ndef, "CONTENT_STONE"), MINERAL_IRON);
}
}
}
u32 i = vmanip.m_area.index(v3s16(p2d.X, node_max.Y, p2d.Y));
for(s16 y=node_max.Y; y>=node_min.Y; y--)
{
- if(vmanip.m_data[i].getContent() == CONTENT_STONE)
+ if(vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_STONE"))
{
if(noisebuf_ground_crumbleness.get(x,y,z) > 1.3)
{
if(noisebuf_ground_wetness.get(x,y,z) > 0.0)
- vmanip.m_data[i] = MapNode(CONTENT_MUD);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_MUD"));
else
- vmanip.m_data[i] = MapNode(CONTENT_SAND);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_SAND"));
}
else if(noisebuf_ground_crumbleness.get(x,y,z) > 0.7)
{
if(noisebuf_ground_wetness.get(x,y,z) < -0.6)
- vmanip.m_data[i] = MapNode(CONTENT_GRAVEL);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_GRAVEL"));
}
else if(noisebuf_ground_crumbleness.get(x,y,z) <
-3.0 + MYMIN(0.1 * sqrt((float)MYMAX(0, -y)), 1.5))
{
- vmanip.m_data[i] = MapNode(CONTENT_LAVASOURCE);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_LAVASOURCE"));
for(s16 x1=-1; x1<=1; x1++)
for(s16 y1=-1; y1<=1; y1++)
for(s16 z1=-1; z1<=1; z1++)
{
if(vmanip.m_data[i].getContent() == CONTENT_AIR)
vmanip.m_flags[i] |= VMANIP_FLAG_DUNGEON_PRESERVE;
- else if(vmanip.m_data[i].getContent() == CONTENT_WATERSOURCE)
+ else if(vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_WATERSOURCE"))
vmanip.m_flags[i] |= VMANIP_FLAG_DUNGEON_PRESERVE;
data->vmanip->m_area.add_y(em, i, -1);
}
PseudoRandom random(blockseed+2);
// Add it
- make_dungeon1(vmanip, random);
+ make_dungeon1(vmanip, random, ndef);
// Convert some cobble to mossy cobble
for(s16 x=full_node_min.X; x<=full_node_max.X; x++)
double d = noise3d_perlin((float)x/2.5,
(float)y/2.5,(float)z/2.5,
blockseed, 2, 1.4);
- if(vmanip.m_data[i].getContent() == CONTENT_COBBLE)
+ if(vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_COBBLE"))
{
if(d < wetness/3.0)
{
- vmanip.m_data[i].setContent(CONTENT_MOSSYCOBBLE);
+ vmanip.m_data[i].setContent(LEGN(ndef, "CONTENT_MOSSYCOBBLE"));
}
}
/*else if(vmanip.m_flags[i] & VMANIP_FLAG_DUNGEON_INSIDE)
{
if(wetness > 1.2)
- vmanip.m_data[i].setContent(CONTENT_MUD);
+ vmanip.m_data[i].setContent(LEGN(ndef, "CONTENT_MUD"));
}*/
data->vmanip->m_area.add_y(em, i, -1);
}
PseudoRandom ncrandom(blockseed+9324342);
if(ncrandom.range(0, 1000) == 0 && blockpos.Y <= -3)
{
- make_nc(vmanip, ncrandom);
+ make_nc(vmanip, ncrandom, ndef);
}
}
{
if(water_found == false)
{
- if(vmanip.m_data[i].getContent() == CONTENT_WATERSOURCE)
+ if(vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_WATERSOURCE"))
{
v3s16 p = v3s16(p2d.X, y, p2d.Y);
data->transforming_liquid.push_back(p);
// This can be done because water_found can only
// turn to true and end up here after going through
// a single block.
- if(vmanip.m_data[i+1].getContent() != CONTENT_WATERSOURCE)
+ if(vmanip.m_data[i+1].getContent() != LEGN(ndef, "CONTENT_WATERSOURCE"))
{
v3s16 p = v3s16(p2d.X, y+1, p2d.Y);
data->transforming_liquid.push_back(p);
u32 i = vmanip.m_area.index(v3s16(p2d.X, start_y, p2d.Y));
for(s16 y=start_y; y>=node_min.Y-3; y--)
{
- if(vmanip.m_data[i].getContent() == CONTENT_WATERSOURCE)
+ if(vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_WATERSOURCE"))
water_detected = true;
if(vmanip.m_data[i].getContent() == CONTENT_AIR)
air_detected = true;
- if((vmanip.m_data[i].getContent() == CONTENT_STONE
- || vmanip.m_data[i].getContent() == CONTENT_GRASS
- || vmanip.m_data[i].getContent() == CONTENT_MUD
- || vmanip.m_data[i].getContent() == CONTENT_SAND
- || vmanip.m_data[i].getContent() == CONTENT_GRAVEL
+ if((vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_STONE")
+ || vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_GRASS")
+ || vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_MUD")
+ || vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_SAND")
+ || vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_GRAVEL")
) && (air_detected || water_detected))
{
if(current_depth == 0 && y <= WATER_LEVEL+2
((claynoise > 0) && (claynoise < 0.12) && (current_depth == 1))
);
if (have_clay)
- vmanip.m_data[i] = MapNode(CONTENT_CLAY);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_CLAY"));
else
- vmanip.m_data[i] = MapNode(CONTENT_SAND);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_SAND"));
}
#if 1
else if(current_depth==0 && !water_detected
&& y >= WATER_LEVEL && air_detected)
- vmanip.m_data[i] = MapNode(CONTENT_GRASS);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_GRASS"));
#endif
else
- vmanip.m_data[i] = MapNode(CONTENT_MUD);
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_MUD"));
}
else
{
- if(vmanip.m_data[i].getContent() == CONTENT_MUD
- || vmanip.m_data[i].getContent() == CONTENT_GRASS)
- vmanip.m_data[i] = MapNode(CONTENT_STONE);
+ if(vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_MUD")
+ || vmanip.m_data[i].getContent() == LEGN(ndef, "CONTENT_GRASS"))
+ vmanip.m_data[i] = MapNode(LEGN(ndef, "CONTENT_STONE"));
}
current_depth++;
{
u32 i = data->vmanip->m_area.index(p);
MapNode *n = &data->vmanip->m_data[i];
- if(n->getContent() != CONTENT_AIR && n->getContent() != CONTENT_WATERSOURCE && n->getContent() != CONTENT_IGNORE)
+ if(n->getContent() != CONTENT_AIR && n->getContent() != LEGN(ndef, "CONTENT_WATERSOURCE") && n->getContent() != CONTENT_IGNORE)
{
found = true;
break;
u32 i = data->vmanip->m_area.index(p);
MapNode *n = &data->vmanip->m_data[i];
- if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS && n->getContent() != CONTENT_SAND)
+ if(n->getContent() != LEGN(ndef, "CONTENT_MUD") && n->getContent() != LEGN(ndef, "CONTENT_GRASS") && n->getContent() != LEGN(ndef, "CONTENT_SAND"))
continue;
// Papyrus grows only on mud and in water
- if(n->getContent() == CONTENT_MUD && y <= WATER_LEVEL)
+ if(n->getContent() == LEGN(ndef, "CONTENT_MUD") && y <= WATER_LEVEL)
{
p.Y++;
- make_papyrus(vmanip, p);
+ make_papyrus(vmanip, p, ndef);
}
// Trees grow only on mud and grass, on land
- else if((n->getContent() == CONTENT_MUD || n->getContent() == CONTENT_GRASS) && y > WATER_LEVEL + 2)
+ else if((n->getContent() == LEGN(ndef, "CONTENT_MUD") || n->getContent() == LEGN(ndef, "CONTENT_GRASS")) && y > WATER_LEVEL + 2)
{
p.Y++;
//if(surface_humidity_2d(data->seed, v2s16(x, y)) < 0.5)
is_apple_tree = noise2d_perlin(
0.5+(float)p.X/100, 0.5+(float)p.Z/100,
data->seed+342902, 3, 0.45) > 0.2;
- make_tree(vmanip, p, is_apple_tree);
+ make_tree(vmanip, p, is_apple_tree, ndef);
}
else
- make_jungletree(vmanip, p);
+ make_jungletree(vmanip, p, ndef);
}
// Cactii grow only on sand, on land
- else if(n->getContent() == CONTENT_SAND && y > WATER_LEVEL + 2)
+ else if(n->getContent() == LEGN(ndef, "CONTENT_SAND") && y > WATER_LEVEL + 2)
{
p.Y++;
- make_cactus(vmanip, p);
+ make_cactus(vmanip, p, ndef);
}
}
}
{
u32 i = data->vmanip->m_area.index(p);
MapNode *n = &data->vmanip->m_data[i];
- if(data->nodemgr->get(*n).is_ground_content
- || n->getContent() == CONTENT_JUNGLETREE)
+ if(data->nodedef->get(*n).is_ground_content
+ || n->getContent() == LEGN(ndef, "CONTENT_JUNGLETREE"))
{
found = true;
break;
continue;
/*p.Y--;
if(vmanip.m_area.contains(p))
- vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_MUD;
+ vmanip.m_data[vmanip.m_area.index(p)] = LEGN(ndef, "CONTENT_MUD");
p.Y++;*/
if(vmanip.m_area.contains(p))
- vmanip.m_data[vmanip.m_area.index(p)] = CONTENT_JUNGLEGRASS;
+ vmanip.m_data[vmanip.m_area.index(p)] = LEGN(ndef, "CONTENT_JUNGLEGNRASS");
}
}
/*{
u32 i = data->vmanip->m_area.index(v3s16(p));
MapNode *n = &data->vmanip->m_data[i];
- if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS)
+ if(n->getContent() != LEGN(ndef, "CONTENT_MUD") && n->getContent() != LEGN(ndef, "CONTENT_GRASS"))
continue;
}*/
// Will be placed one higher
/*{
u32 i = data->vmanip->m_area.index(v3s16(p));
MapNode *n = &data->vmanip->m_data[i];
- if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS)
+ if(n->getContent() != LEGN(ndef, "CONTENT_MUD") && n->getContent() != LEGN(ndef, "CONTENT_GRASS"))
continue;
}*/
// Will be placed one lower
no_op(false),
vmanip(NULL),
seed(0),
- nodemgr(NULL)
+ nodedef(NULL)
{}
BlockMakeData::~BlockMakeData()
void add_random_objects(MapBlock *block);
// Add a tree
- void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0, bool is_apple_tree);
+ void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
+ bool is_apple_tree, INodeDefManager *ndef);
/*
These are used by FarMesh
u64 seed;
v3s16 blockpos;
UniqueQueue<v3s16> transforming_liquid;
- INodeDefManager *nodemgr; // Destructor deletes
+ INodeDefManager *nodedef; // Destructor deletes
BlockMakeData();
~BlockMakeData();
- Object visual client-side stuff
- Blink effect
- Spritesheets and animation
-- Named node types and dynamic id allocation per MapBlock
- LuaNodeMetadata
blockdef.has_metadata = true/false
- Stores an inventory and stuff in a Settings object
m_banmanager(mapsavedir+DIR_DELIM+"ipban.txt"),
m_lua(NULL),
m_toolmgr(createToolDefManager()),
- m_nodemgr(createNodeDefManager()),
+ m_nodedef(createNodeDefManager()),
m_thread(this),
m_emergethread(this),
m_time_counter(0),
JMutexAutoLock envlock(m_env_mutex);
JMutexAutoLock conlock(m_con_mutex);
- infostream<<"m_nodemgr="<<m_nodemgr<<std::endl;
+ infostream<<"m_nodedef="<<m_nodedef<<std::endl;
// Initialize default node definitions
- content_mapnode_init(m_nodemgr);
+ content_mapnode_init(m_nodedef);
// Add default global mod path
m_modspaths.push_back(porting::path_data + DIR_DELIM + "mods");
delete m_env;
delete m_toolmgr;
- delete m_nodemgr;
+ delete m_nodedef;
// Deinitialize scripting
infostream<<"Server: Deinitializing scripting"<<std::endl;
SendToolDef(m_con, peer_id, m_toolmgr);
// Send node definitions
- SendNodeDef(m_con, peer_id, m_nodemgr);
+ SendNodeDef(m_con, peer_id, m_nodedef);
// Send textures
SendTextures(peer_id);
{
MapNode n = m_env->getMap().getNode(p_under);
// Get mineral
- mineral = n.getMineral(m_nodemgr);
+ mineral = n.getMineral(m_nodedef);
// Get material at position
material = n.getContent();
// If not yet cancelled
if(cannot_remove_node == false)
{
// If it's not diggable, do nothing
- if(m_nodemgr->get(material).diggable == false)
+ if(m_nodedef->get(material).diggable == false)
{
infostream<<"Server: Not finishing digging: "
<<"Node not diggable"
ToolDiggingProperties tp =
m_toolmgr->getDiggingProperties(toolname);
DiggingProperties prop =
- getDiggingProperties(material, &tp, m_nodemgr);
+ getDiggingProperties(material, &tp, m_nodedef);
if(prop.diggable == false)
{
// If not mineral
if(item == NULL)
{
- const std::string &dug_s = m_nodemgr->get(material).dug_item;
+ const std::string &dug_s = m_nodedef->get(material).dug_item;
if(dug_s != "")
{
std::istringstream is(dug_s, std::ios::binary);
// If not mineral
if(item == NULL)
{
- const std::string &extra_dug_s = m_nodemgr->get(material).extra_dug_item;
- s32 extra_rarity = m_nodemgr->get(material).extra_dug_item_rarity;
+ const std::string &extra_dug_s = m_nodedef->get(material).extra_dug_item;
+ s32 extra_rarity = m_nodedef->get(material).extra_dug_item_rarity;
if(extra_dug_s != "" && extra_rarity != 0
&& myrand() % extra_rarity == 0)
{
<<" because privileges are "<<getPlayerPrivs(player)
<<std::endl;
- if(m_nodemgr->get(n2).buildable_to == false
+ if(m_nodedef->get(n2).buildable_to == false
|| no_enough_privs)
{
// Client probably has wrong data.
<<" at "<<PP(p_under)<<std::endl;
// Calculate direction for wall mounted stuff
- if(m_nodemgr->get(n).wall_mounted)
+ if(m_nodedef->get(n).wall_mounted)
n.param2 = packDir(p_under - p_over);
// Calculate the direction for furnaces and chests and stuff
- if(m_nodemgr->get(n).param_type == CPT_FACEDIR_SIMPLE)
+ if(m_nodedef->get(n).param_type == CPT_FACEDIR_SIMPLE)
{
v3f playerpos = player->getPosition();
v3f blockpos = intToFloat(p_over, BS) - playerpos;
Calculate special events
*/
- /*if(n.d == CONTENT_MESE)
+ /*if(n.d == LEGN(m_nodedef, "CONTENT_MESE"))
{
u32 count = 0;
for(s16 z=-1; z<=1; z++)
NodeMetadata *meta = m_env->getMap().getNodeMetadata(p);
if(!meta)
return;
- if(meta->typeId() != CONTENT_SIGN_WALL)
+ if(meta->typeId() != LEGN(m_nodedef, "CONTENT_SIGN_WALL"))
return;
SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
signmeta->setText(text);
p.Y = stoi(fn.next(","));
p.Z = stoi(fn.next(","));
NodeMetadata *meta = m_env->getMap().getNodeMetadata(p);
- if(meta && meta->typeId() == CONTENT_LOCKABLE_CHEST) {
+ if(meta && meta->typeId() == LEGN(m_nodedef, "CONTENT_LOCKABLE_CHEST")) {
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
if (lcm->getOwner() != player->getName())
return;
p.Y = stoi(fn.next(","));
p.Z = stoi(fn.next(","));
NodeMetadata *meta = m_env->getMap().getNodeMetadata(p);
- if(meta && meta->typeId() == CONTENT_LOCKABLE_CHEST) {
+ if(meta && meta->typeId() == LEGN(m_nodedef, "CONTENT_LOCKABLE_CHEST")) {
LockingChestNodeMetadata *lcm = (LockingChestNodeMetadata*)meta;
if (lcm->getOwner() != player->getName())
return;
}
INodeDefManager* Server::getNodeDefManager()
{
- return m_nodemgr;
+ return m_nodedef;
}
ITextureSource* Server::getTextureSource()
{
}
u16 Server::allocateUnknownNodeId(const std::string &name)
{
- return m_nodemgr->allocateDummy(name);
+ return m_nodedef->allocateDummy(name);
}
IWritableToolDefManager* Server::getWritableToolDefManager()
}
IWritableNodeDefManager* Server::getWritableNodeDefManager()
{
- return m_nodemgr;
+ return m_nodedef;
}
v3f findSpawnPos(ServerMap &map)
IWritableToolDefManager *m_toolmgr;
// Node definition manager
- IWritableNodeDefManager *m_nodemgr;
+ IWritableNodeDefManager *m_nodedef;
/*
Threads
// Transparency
n.setContent(CONTENT_AIR);
assert(nodedef->get(n).light_propagates == true);
- n.setContent(CONTENT_STONE);
+ n.setContent(LEGN(nodedef, "CONTENT_STONE"));
assert(nodedef->get(n).light_propagates == false);
}
};