mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 22:52:25 +01:00
Do not expose CONTENT_* stuff in content_mapnode.h and use a name converter wrapper in old code
This commit is contained in:
parent
c0f6395cf0
commit
df8346ef4d
@ -900,16 +900,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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
|
||||
|
@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "content_mapnode.h"
|
||||
#include "player.h"
|
||||
#include "mapnode.h" // For content_t
|
||||
#include "gamedef.h"
|
||||
|
||||
/*
|
||||
items: actually *items[9]
|
||||
@ -29,20 +30,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
*/
|
||||
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);
|
||||
@ -60,24 +63,24 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,16 +91,16 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
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))
|
||||
@ -109,9 +112,9 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
// 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))
|
||||
@ -137,9 +140,9 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
// 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))
|
||||
@ -151,7 +154,7 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
// 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))
|
||||
@ -163,7 +166,7 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
// 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))
|
||||
@ -187,9 +190,9 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
// 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))
|
||||
@ -201,9 +204,9 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
// 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))
|
||||
@ -229,8 +232,8 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
// 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))
|
||||
{
|
||||
@ -241,8 +244,8 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
// 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))
|
||||
{
|
||||
@ -276,59 +279,59 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,20 +349,20 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,7 +375,7 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,16 +388,16 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
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);
|
||||
@ -416,18 +419,18 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,7 +446,7 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -466,6 +469,8 @@ InventoryItem *craft_get_result(InventoryItem **items, IGameDef *gamedef)
|
||||
|
||||
void craft_set_creative_inventory(Player *player, IGameDef *gamedef)
|
||||
{
|
||||
INodeDefManager *ndef = gamedef->ndef();
|
||||
|
||||
player->resetInventory();
|
||||
|
||||
// Give some good tools
|
||||
@ -496,29 +501,29 @@ void craft_set_creative_inventory(Player *player, IGameDef *gamedef)
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
@ -535,18 +540,18 @@ void craft_set_creative_inventory(Player *player, IGameDef *gamedef)
|
||||
}
|
||||
|
||||
#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);
|
||||
@ -564,13 +569,15 @@ void craft_set_creative_inventory(Player *player, IGameDef *gamedef)
|
||||
|
||||
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);
|
||||
}
|
||||
@ -585,22 +592,22 @@ void craft_give_initial_stuff(Player *player, IGameDef *gamedef)
|
||||
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);
|
||||
}
|
||||
@ -628,7 +635,7 @@ void craft_give_initial_stuff(Player *player, IGameDef *gamedef)
|
||||
}*/
|
||||
/*// 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);
|
||||
}*/
|
||||
|
@ -25,6 +25,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "nodedef.h"
|
||||
#include "utility.h"
|
||||
#include "nameidmapping.h"
|
||||
#include <map>
|
||||
|
||||
/*
|
||||
Legacy node definitions
|
||||
*/
|
||||
|
||||
#define WATER_ALPHA 160
|
||||
|
||||
@ -91,6 +96,54 @@ void setGlassLikeMaterialProperties(MaterialProperties &mprop, float toughness)
|
||||
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.
|
||||
@ -202,7 +255,87 @@ void content_mapnode_get_name_id_mapping(NameIdMapping *nimap)
|
||||
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;
|
||||
|
@ -21,20 +21,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#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.
|
||||
|
||||
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.
|
||||
|
||||
Server only calls this once with tsrc=NULL.
|
||||
Legacy node definitions
|
||||
*/
|
||||
|
||||
class IWritableNodeDefManager;
|
||||
|
||||
// Initialize default (legacy) node definitions
|
||||
void content_mapnode_init(IWritableNodeDefManager *nodemgr);
|
||||
|
||||
// Backwards compatibility for non-extended content types in v19
|
||||
@ -42,67 +36,15 @@ extern content_t trans_table_19[21][2];
|
||||
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
|
||||
|
||||
|
@ -19,10 +19,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
#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
|
||||
*/
|
||||
@ -38,7 +42,7 @@ SignNodeMetadata::SignNodeMetadata(IGameDef *gamedef, std::string text):
|
||||
}
|
||||
u16 SignNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_SIGN_WALL;
|
||||
return NODEMETA_SIGN;
|
||||
}
|
||||
NodeMetadata* SignNodeMetadata::create(std::istream &is, IGameDef *gamedef)
|
||||
{
|
||||
@ -79,7 +83,7 @@ ChestNodeMetadata::~ChestNodeMetadata()
|
||||
}
|
||||
u16 ChestNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_CHEST;
|
||||
return NODEMETA_CHEST;
|
||||
}
|
||||
NodeMetadata* ChestNodeMetadata::create(std::istream &is, IGameDef *gamedef)
|
||||
{
|
||||
@ -142,7 +146,7 @@ LockingChestNodeMetadata::~LockingChestNodeMetadata()
|
||||
}
|
||||
u16 LockingChestNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_LOCKABLE_CHEST;
|
||||
return NODEMETA_LOCKABLE_CHEST;
|
||||
}
|
||||
NodeMetadata* LockingChestNodeMetadata::create(std::istream &is, IGameDef *gamedef)
|
||||
{
|
||||
@ -215,7 +219,7 @@ FurnaceNodeMetadata::~FurnaceNodeMetadata()
|
||||
}
|
||||
u16 FurnaceNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_FURNACE;
|
||||
return NODEMETA_FURNACE;
|
||||
}
|
||||
NodeMetadata* FurnaceNodeMetadata::clone(IGameDef *gamedef)
|
||||
{
|
||||
|
@ -637,7 +637,7 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime)
|
||||
#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)
|
||||
{
|
||||
@ -645,7 +645,7 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime)
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -803,9 +803,9 @@ void ServerEnvironment::step(float dtime)
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1008,7 +1008,7 @@ void ServerEnvironment::step(float dtime)
|
||||
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)
|
||||
{
|
||||
@ -1017,7 +1017,7 @@ void ServerEnvironment::step(float dtime)
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1025,14 +1025,14 @@ void ServerEnvironment::step(float dtime)
|
||||
/*
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1040,8 +1040,8 @@ void ServerEnvironment::step(float dtime)
|
||||
/*
|
||||
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)
|
||||
{
|
||||
@ -1049,7 +1049,7 @@ void ServerEnvironment::step(float dtime)
|
||||
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);
|
||||
@ -1061,8 +1061,8 @@ void ServerEnvironment::step(float dtime)
|
||||
/*
|
||||
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)
|
||||
{
|
||||
@ -1106,7 +1106,7 @@ void ServerEnvironment::step(float dtime)
|
||||
/*
|
||||
Make trees from saplings!
|
||||
*/
|
||||
if(n.getContent() == CONTENT_SAPLING)
|
||||
if(n.getContent() == LEGN(m_gamedef->ndef(), "CONTENT_SAPLING"))
|
||||
{
|
||||
if(myrand()%50 == 0)
|
||||
{
|
||||
@ -1119,7 +1119,8 @@ void ServerEnvironment::step(float dtime)
|
||||
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
|
||||
@ -2126,9 +2127,9 @@ void ClientEnvironment::step(float dtime)
|
||||
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)
|
||||
|
@ -2058,7 +2058,7 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos)
|
||||
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
|
||||
|
@ -275,7 +275,6 @@ bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources,
|
||||
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;
|
||||
@ -331,26 +330,6 @@ bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources,
|
||||
}
|
||||
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;
|
||||
|
||||
|
240
src/mapgen.cpp
240
src/mapgen.cpp
@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
#include "mapgen.h"
|
||||
#include "voxel.h"
|
||||
#include "content_mapnode.h"
|
||||
#include "noise.h"
|
||||
#include "mapblock.h"
|
||||
#include "map.h"
|
||||
@ -27,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
//#include "serverobject.h"
|
||||
#include "content_sao.h"
|
||||
#include "nodedef.h"
|
||||
#include "content_mapnode.h" // For content_mapnode_get_new_name
|
||||
|
||||
namespace mapgen
|
||||
{
|
||||
@ -68,8 +68,8 @@ static s16 find_ground_level_clever(VoxelManipulator &vmanip, v2s16 p2d)
|
||||
{
|
||||
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);
|
||||
@ -81,11 +81,12 @@ static s16 find_ground_level_clever(VoxelManipulator &vmanip, v2s16 p2d)
|
||||
}
|
||||
#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;
|
||||
@ -160,10 +161,11 @@ void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0, bool is_apple_tree)
|
||||
}
|
||||
}
|
||||
|
||||
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++)
|
||||
@ -246,9 +248,10 @@ static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0)
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -260,9 +263,10 @@ void make_papyrus(VoxelManipulator &vmanip, v3s16 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;
|
||||
@ -277,7 +281,7 @@ void make_cactus(VoxelManipulator &vmanip, v3s16 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);
|
||||
|
||||
@ -358,7 +362,7 @@ static void make_randomstone(VoxelManipulator &vmanip, v3s16 p0)
|
||||
#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);
|
||||
|
||||
@ -448,7 +452,8 @@ static void make_largestone(VoxelManipulator &vmanip, v3s16 p0)
|
||||
#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++)
|
||||
@ -461,7 +466,7 @@ static void make_room1(VoxelManipulator &vmanip, v3s16 roomsize, v3s16 roomplace
|
||||
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);
|
||||
@ -470,7 +475,7 @@ static void make_room1(VoxelManipulator &vmanip, v3s16 roomsize, v3s16 roomplace
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -485,7 +490,7 @@ static void make_room1(VoxelManipulator &vmanip, v3s16 roomsize, v3s16 roomplace
|
||||
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);
|
||||
@ -494,7 +499,7 @@ static void make_room1(VoxelManipulator &vmanip, v3s16 roomsize, v3s16 roomplace
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -509,7 +514,7 @@ static void make_room1(VoxelManipulator &vmanip, v3s16 roomsize, v3s16 roomplace
|
||||
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);
|
||||
@ -518,7 +523,7 @@ static void make_room1(VoxelManipulator &vmanip, v3s16 roomsize, v3s16 roomplace
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,17 +559,19 @@ static void make_fill(VoxelManipulator &vmanip, v3s16 place, v3s16 size,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
@ -615,9 +622,9 @@ static v3s16 random_turn(PseudoRandom &random, v3s16 olddir)
|
||||
|
||||
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;
|
||||
@ -651,7 +658,7 @@ static void make_corridor(VoxelManipulator &vmanip, v3s16 doorplace,
|
||||
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),
|
||||
@ -660,8 +667,8 @@ static void make_corridor(VoxelManipulator &vmanip, v3s16 doorplace,
|
||||
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);*/
|
||||
}
|
||||
@ -700,10 +707,12 @@ class RoomWalker
|
||||
{
|
||||
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();
|
||||
}
|
||||
@ -737,9 +746,9 @@ public:
|
||||
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;
|
||||
@ -753,25 +762,25 @@ public:
|
||||
*/
|
||||
// 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();
|
||||
@ -857,9 +866,11 @@ private:
|
||||
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;
|
||||
@ -916,12 +927,12 @@ static void make_dungeon1(VoxelManipulator &vmanip, PseudoRandom &random)
|
||||
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)
|
||||
@ -946,7 +957,7 @@ static void make_dungeon1(VoxelManipulator &vmanip, PseudoRandom &random)
|
||||
}
|
||||
|
||||
// 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);
|
||||
@ -955,7 +966,7 @@ static void make_dungeon1(VoxelManipulator &vmanip, PseudoRandom &random)
|
||||
|
||||
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;
|
||||
@ -964,7 +975,7 @@ static void make_dungeon1(VoxelManipulator &vmanip, PseudoRandom &random)
|
||||
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));
|
||||
@ -976,7 +987,7 @@ static void make_dungeon1(VoxelManipulator &vmanip, PseudoRandom &random)
|
||||
|
||||
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;
|
||||
@ -984,7 +995,8 @@ static void make_dungeon1(VoxelManipulator &vmanip, PseudoRandom &random)
|
||||
}
|
||||
}
|
||||
|
||||
static void make_nc(VoxelManipulator &vmanip, PseudoRandom &random)
|
||||
static void make_nc(VoxelManipulator &vmanip, PseudoRandom &random,
|
||||
INodeDefManager *ndef)
|
||||
{
|
||||
v3s16 dir;
|
||||
u8 facedir_i = 0;
|
||||
@ -1009,12 +1021,12 @@ static void make_nc(VoxelManipulator &vmanip, PseudoRandom &random)
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1417,9 +1429,9 @@ void add_random_objects(MapBlock *block)
|
||||
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;
|
||||
@ -1479,7 +1491,9 @@ void make_block(BlockMakeData *data)
|
||||
}
|
||||
|
||||
assert(data->vmanip);
|
||||
assert(data->nodemgr);
|
||||
assert(data->nodedef);
|
||||
|
||||
INodeDefManager *ndef = data->nodedef;
|
||||
|
||||
v3s16 blockpos = data->blockpos;
|
||||
|
||||
@ -1541,7 +1555,7 @@ void make_block(BlockMakeData *data)
|
||||
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);
|
||||
}
|
||||
@ -1653,14 +1667,14 @@ void make_block(BlockMakeData *data)
|
||||
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);
|
||||
@ -1689,9 +1703,9 @@ void make_block(BlockMakeData *data)
|
||||
{
|
||||
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"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1709,22 +1723,22 @@ void make_block(BlockMakeData *data)
|
||||
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)
|
||||
{
|
||||
@ -1767,9 +1781,9 @@ void make_block(BlockMakeData *data)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1793,9 +1807,9 @@ void make_block(BlockMakeData *data)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1816,24 +1830,24 @@ void make_block(BlockMakeData *data)
|
||||
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++)
|
||||
@ -1880,7 +1894,7 @@ void make_block(BlockMakeData *data)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -1890,7 +1904,7 @@ void make_block(BlockMakeData *data)
|
||||
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++)
|
||||
@ -1911,17 +1925,17 @@ void make_block(BlockMakeData *data)
|
||||
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);
|
||||
}
|
||||
@ -1936,7 +1950,7 @@ void make_block(BlockMakeData *data)
|
||||
PseudoRandom ncrandom(blockseed+9324342);
|
||||
if(ncrandom.range(0, 1000) == 0 && blockpos.Y <= -3)
|
||||
{
|
||||
make_nc(vmanip, ncrandom);
|
||||
make_nc(vmanip, ncrandom, ndef);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1958,7 +1972,7 @@ void make_block(BlockMakeData *data)
|
||||
{
|
||||
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);
|
||||
@ -1970,7 +1984,7 @@ void make_block(BlockMakeData *data)
|
||||
// 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);
|
||||
@ -2013,16 +2027,16 @@ void make_block(BlockMakeData *data)
|
||||
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
|
||||
@ -2043,23 +2057,23 @@ void make_block(BlockMakeData *data)
|
||||
((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++;
|
||||
@ -2113,7 +2127,7 @@ void make_block(BlockMakeData *data)
|
||||
{
|
||||
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;
|
||||
@ -2127,17 +2141,17 @@ void make_block(BlockMakeData *data)
|
||||
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)
|
||||
@ -2150,16 +2164,16 @@ void make_block(BlockMakeData *data)
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2188,8 +2202,8 @@ void make_block(BlockMakeData *data)
|
||||
{
|
||||
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;
|
||||
@ -2205,10 +2219,10 @@ void make_block(BlockMakeData *data)
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2236,7 +2250,7 @@ void make_block(BlockMakeData *data)
|
||||
/*{
|
||||
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
|
||||
@ -2271,7 +2285,7 @@ void make_block(BlockMakeData *data)
|
||||
/*{
|
||||
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
|
||||
@ -2288,7 +2302,7 @@ BlockMakeData::BlockMakeData():
|
||||
no_op(false),
|
||||
vmanip(NULL),
|
||||
seed(0),
|
||||
nodemgr(NULL)
|
||||
nodedef(NULL)
|
||||
{}
|
||||
|
||||
BlockMakeData::~BlockMakeData()
|
||||
|
@ -43,7 +43,8 @@ namespace mapgen
|
||||
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
|
||||
@ -59,7 +60,7 @@ namespace mapgen
|
||||
u64 seed;
|
||||
v3s16 blockpos;
|
||||
UniqueQueue<v3s16> transforming_liquid;
|
||||
INodeDefManager *nodemgr; // Destructor deletes
|
||||
INodeDefManager *nodedef; // Destructor deletes
|
||||
|
||||
BlockMakeData();
|
||||
~BlockMakeData();
|
||||
|
@ -45,7 +45,6 @@ TODO:
|
||||
- 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
|
||||
|
@ -987,7 +987,7 @@ Server::Server(
|
||||
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),
|
||||
@ -1013,10 +1013,10 @@ Server::Server(
|
||||
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");
|
||||
@ -1146,7 +1146,7 @@ Server::~Server()
|
||||
delete m_env;
|
||||
|
||||
delete m_toolmgr;
|
||||
delete m_nodemgr;
|
||||
delete m_nodedef;
|
||||
|
||||
// Deinitialize scripting
|
||||
infostream<<"Server: Deinitializing scripting"<<std::endl;
|
||||
@ -2143,7 +2143,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
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);
|
||||
@ -2530,14 +2530,14 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 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"
|
||||
@ -2633,7 +2633,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
ToolDiggingProperties tp =
|
||||
m_toolmgr->getDiggingProperties(toolname);
|
||||
DiggingProperties prop =
|
||||
getDiggingProperties(material, &tp, m_nodemgr);
|
||||
getDiggingProperties(material, &tp, m_nodedef);
|
||||
|
||||
if(prop.diggable == false)
|
||||
{
|
||||
@ -2663,7 +2663,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
// 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);
|
||||
@ -2689,8 +2689,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
// 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)
|
||||
{
|
||||
@ -2766,7 +2766,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
<<" 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.
|
||||
@ -2804,11 +2804,11 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
<<" 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;
|
||||
@ -2879,7 +2879,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
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++)
|
||||
@ -3036,7 +3036,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
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);
|
||||
@ -3162,7 +3162,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
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;
|
||||
@ -3180,7 +3180,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
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;
|
||||
@ -4422,7 +4422,7 @@ IToolDefManager* Server::getToolDefManager()
|
||||
}
|
||||
INodeDefManager* Server::getNodeDefManager()
|
||||
{
|
||||
return m_nodemgr;
|
||||
return m_nodedef;
|
||||
}
|
||||
ITextureSource* Server::getTextureSource()
|
||||
{
|
||||
@ -4430,7 +4430,7 @@ ITextureSource* Server::getTextureSource()
|
||||
}
|
||||
u16 Server::allocateUnknownNodeId(const std::string &name)
|
||||
{
|
||||
return m_nodemgr->allocateDummy(name);
|
||||
return m_nodedef->allocateDummy(name);
|
||||
}
|
||||
|
||||
IWritableToolDefManager* Server::getWritableToolDefManager()
|
||||
@ -4439,7 +4439,7 @@ IWritableToolDefManager* Server::getWritableToolDefManager()
|
||||
}
|
||||
IWritableNodeDefManager* Server::getWritableNodeDefManager()
|
||||
{
|
||||
return m_nodemgr;
|
||||
return m_nodedef;
|
||||
}
|
||||
|
||||
v3f findSpawnPos(ServerMap &map)
|
||||
|
@ -633,7 +633,7 @@ private:
|
||||
IWritableToolDefManager *m_toolmgr;
|
||||
|
||||
// Node definition manager
|
||||
IWritableNodeDefManager *m_nodemgr;
|
||||
IWritableNodeDefManager *m_nodedef;
|
||||
|
||||
/*
|
||||
Threads
|
||||
|
@ -229,7 +229,7 @@ struct TestMapNode
|
||||
// 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);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user