some fiddling with initial and creative inventory items

This commit is contained in:
darkrose 2014-03-23 12:57:30 +10:00
parent 937d864bd0
commit 0579a92d81
2 changed files with 39 additions and 65 deletions

View File

@ -621,52 +621,22 @@ void giveCreative(Player *player)
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
/*
Give materials
*/
// CONTENT_IGNORE-terminated list
content_t material_items[] = {
CONTENT_CREATIVE_CHEST,
CONTENT_TORCH,
CONTENT_ROUGHSTONE,
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_COTTON,
CONTENT_CHEST,
CONTENT_FURNACE,
CONTENT_SIGN,
CONTENT_LAVASOURCE,
CONTENT_WOOD,
CONTENT_LADDER,
CONTENT_IGNORE
};
content_t *mip = material_items;
for(u16 i=0; i<PLAYER_INVENTORY_SIZE; i++)
// The much needed creative chest
{
if(*mip == CONTENT_IGNORE)
break;
InventoryItem *item = new MaterialItem(*mip, 1);
player->inventory.addItem("main", item);
mip++;
InventoryItem *item = new MaterialItem(CONTENT_CREATIVE_CHEST, 1);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
// and some basics
{
InventoryItem *item = new MaterialItem(CONTENT_TORCH, 1);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
{
InventoryItem *item = new MaterialItem(CONTENT_ROUGHSTONEBRICK, 1);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}
}
@ -698,7 +668,7 @@ void giveInitial(Player *player)
assert(r == NULL);
}
{
InventoryItem *item = new MaterialItem(CONTENT_ROUGHSTONE, 99);
InventoryItem *item = new MaterialItem(CONTENT_ROUGHSTONEBRICK, 99);
void* r = player->inventory.addItem("main", item);
assert(r == NULL);
}

View File

@ -3746,20 +3746,22 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|| item->getContent() == CONTENT_TOOLITEM_TINBUCKET_WATER
) {
if (ilist != NULL) {
std::string dug_s = std::string("ToolItem ");
if (item->getContent() == CONTENT_TOOLITEM_WBUCKET_WATER) {
dug_s += "WBucket 1";
}else if (item->getContent() == CONTENT_TOOLITEM_TINBUCKET_WATER) {
dug_s += "TinBucket 1";
}else{
dug_s += "SteelBucket 1";
if (g_settings->getBool("creative_mode") == false) {
std::string dug_s = std::string("ToolItem ");
if (item->getContent() == CONTENT_TOOLITEM_WBUCKET_WATER) {
dug_s += "WBucket 1";
}else if (item->getContent() == CONTENT_TOOLITEM_TINBUCKET_WATER) {
dug_s += "TinBucket 1";
}else{
dug_s += "SteelBucket 1";
}
std::istringstream is(dug_s, std::ios::binary);
InventoryItem *item = InventoryItem::deSerialize(is);
ilist->changeItem(item_i,item);
UpdateCrafting(player->peer_id);
SendInventory(player->peer_id);
n.setContent(CONTENT_WATERSOURCE);
}
std::istringstream is(dug_s, std::ios::binary);
InventoryItem *item = InventoryItem::deSerialize(is);
ilist->changeItem(item_i,item);
UpdateCrafting(player->peer_id);
SendInventory(player->peer_id);
n.setContent(CONTENT_WATERSOURCE);
core::list<u16> far_players;
sendAddNode(p_over, n, 0, &far_players, 30);
@ -3792,12 +3794,14 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
}else if (item->getContent() == CONTENT_TOOLITEM_STEELBUCKET_LAVA) {
if (ilist != NULL) {
if (g_settings->getBool("enable_lavabuckets")) {
std::string dug_s = std::string("ToolItem SteelBucket 1");
std::istringstream is(dug_s, std::ios::binary);
InventoryItem *item = InventoryItem::deSerialize(is);
ilist->changeItem(item_i,item);
UpdateCrafting(player->peer_id);
SendInventory(player->peer_id);
if (g_settings->getBool("creative_mode") == false) {
std::string dug_s = std::string("ToolItem SteelBucket 1");
std::istringstream is(dug_s, std::ios::binary);
InventoryItem *item = InventoryItem::deSerialize(is);
ilist->changeItem(item_i,item);
UpdateCrafting(player->peer_id);
SendInventory(player->peer_id);
}
n.setContent(CONTENT_LAVASOURCE);
core::list<u16> far_players;
sendAddNode(p_over, n, 0, &far_players, 30);