diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-07-30 23:33:57 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-07-30 23:33:57 +0300 |
commit | 8e1eacf3a87a0cee39c8c27c3846828c12e73f9d (patch) | |
tree | 0863d9782fa44d73ae25867aba1edacae6f15252 | |
parent | 4ccc99b291d7aa9ccb3e3c56f9d63bf30e02b0b9 (diff) | |
download | minetest-8e1eacf3a87a0cee39c8c27c3846828c12e73f9d.tar.gz minetest-8e1eacf3a87a0cee39c8c27c3846828c12e73f9d.tar.bz2 minetest-8e1eacf3a87a0cee39c8c27c3846828c12e73f9d.zip |
Fixed handling of inventory in creative mode (normal inventory is not trashed anymore), fixed mese pick speed, added some forgotten stuff
-rw-r--r-- | data/cooked_rat.png | bin | 0 -> 239 bytes | |||
-rw-r--r-- | data/nc_back.png | bin | 0 -> 303 bytes | |||
-rw-r--r-- | data/nc_front.png | bin | 0 -> 410 bytes | |||
-rw-r--r-- | data/nc_rb.png | bin | 0 -> 203 bytes | |||
-rw-r--r-- | data/nc_side.png | bin | 0 -> 260 bytes | |||
-rw-r--r-- | data/scorched_stuff.png | bin | 0 -> 233 bytes | |||
-rw-r--r-- | src/content_mapnode.cpp | 19 | ||||
-rw-r--r-- | src/content_mapnode.h | 2 | ||||
-rw-r--r-- | src/mapgen.cpp | 45 | ||||
-rw-r--r-- | src/mapnode.h | 3 | ||||
-rw-r--r-- | src/player.cpp | 11 | ||||
-rw-r--r-- | src/player.h | 2 | ||||
-rw-r--r-- | src/server.cpp | 10 |
13 files changed, 89 insertions, 3 deletions
diff --git a/data/cooked_rat.png b/data/cooked_rat.png Binary files differnew file mode 100644 index 000000000..daad3be0d --- /dev/null +++ b/data/cooked_rat.png diff --git a/data/nc_back.png b/data/nc_back.png Binary files differnew file mode 100644 index 000000000..f09f41658 --- /dev/null +++ b/data/nc_back.png diff --git a/data/nc_front.png b/data/nc_front.png Binary files differnew file mode 100644 index 000000000..cad9edab1 --- /dev/null +++ b/data/nc_front.png diff --git a/data/nc_rb.png b/data/nc_rb.png Binary files differnew file mode 100644 index 000000000..7ebc9930d --- /dev/null +++ b/data/nc_rb.png diff --git a/data/nc_side.png b/data/nc_side.png Binary files differnew file mode 100644 index 000000000..f954045fb --- /dev/null +++ b/data/nc_side.png diff --git a/data/scorched_stuff.png b/data/scorched_stuff.png Binary files differnew file mode 100644 index 000000000..9ced2fbe8 --- /dev/null +++ b/data/scorched_stuff.png diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index db036ebd9..b6b7a6e53 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -474,13 +474,30 @@ void content_mapnode_init() f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; setStoneLikeDiggingProperties(f->digging_properties, 5.0); + i = CONTENT_NC; + f = &content_features(i); + f->param_type = CPT_FACEDIR_SIMPLE; + f->setAllTextures("nc_side.png"); + f->setTexture(5, "nc_front.png"); // Z- + f->setTexture(4, "nc_back.png"); // Z+ + f->setInventoryTexture("nc_front.png"); + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + setStoneLikeDiggingProperties(f->digging_properties, 3.0); + + i = CONTENT_NC_RB; + f = &content_features(i); + f->setAllTextures("nc_rb.png"); + f->setInventoryTexture("nc_rb.png"); + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + setStoneLikeDiggingProperties(f->digging_properties, 3.0); + // NOTE: Remember to add frequently used stuff to the texture atlas in tile.cpp /* Add MesePick to everything */ - for(u16 i=0; i<256; i++) + for(u16 i=0; i<=MAX_CONTENT; i++) { content_features(i).digging_properties.set("MesePick", DiggingProperties(true, 0.0, 65535./1337)); diff --git a/src/content_mapnode.h b/src/content_mapnode.h index 5fdbf45f3..7be26518f 100644 --- a/src/content_mapnode.h +++ b/src/content_mapnode.h @@ -70,6 +70,8 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version); #define CONTENT_BOOKSHELF 0x814 //29 #define CONTENT_JUNGLETREE 0x815 #define CONTENT_JUNGLEGRASS 0x816 +#define CONTENT_NC 0x817 +#define CONTENT_NC_RB 0x818 #endif diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 0ba7f91ab..5dec7d843 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -976,6 +976,40 @@ static void make_dungeon1(VoxelManipulator &vmanip, PseudoRandom &random) } } +static void make_nc(VoxelManipulator &vmanip, PseudoRandom &random) +{ + v3s16 dir; + u8 facedir_i = 0; + s32 r = random.range(0, 3); + if(r == 0){ + dir = v3s16( 1, 0, 0); + facedir_i = 3; + } + if(r == 1){ + dir = v3s16(-1, 0, 0); + facedir_i = 1; + } + if(r == 2){ + dir = v3s16( 0, 0, 1); + facedir_i = 2; + } + if(r == 3){ + dir = v3s16( 0, 0,-1); + facedir_i = 0; + } + v3s16 p = vmanip.m_area.MinEdge + v3s16( + 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); + 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); + } +} + /* Noise functions. Make sure seed is mangled differently in each one. */ @@ -1871,6 +1905,17 @@ void make_block(BlockMakeData *data) } } } + + /* + Add NC + */ + { + PseudoRandom ncrandom(blockseed+9324342); + if(ncrandom.range(0, 1000) == 0 && blockpos.Y <= -3) + { + make_nc(vmanip, ncrandom); + } + } /* Add top and bottom side of water to transforming_liquid queue diff --git a/src/mapnode.h b/src/mapnode.h index 956de6852..aeb72c97a 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -391,6 +391,9 @@ inline v3s16 unpackDir(u8 b) facedir: CPT_FACEDIR_SIMPLE param1 value dir: The face for which stuff is wanted return value: The face from which the stuff is actually found + + NOTE: Currently this uses 2 bits for Z-,X-,Z+,X+, should there be Y+ + and Y- too? */ v3s16 facedir_rotate(u8 facedir, v3s16 dir); diff --git a/src/player.cpp b/src/player.cpp index d52d6b88f..c43276ef1 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -29,6 +29,7 @@ Player::Player(): in_water(false), in_water_stable(false), swimming_up(false), + inventory_backup(NULL), craftresult_is_preview(true), hp(20), peer_id(PEER_ID_INEXISTENT), @@ -43,6 +44,7 @@ Player::Player(): Player::~Player() { + delete inventory_backup; } void Player::resetInventory() @@ -106,8 +108,13 @@ void Player::serialize(std::ostream &os) args.writeLines(os); os<<"PlayerArgsEnd\n"; - - inventory.serialize(os); + + // If actual inventory is backed up due to creative mode, save it + // instead of the dummy creative mode inventory + if(inventory_backup) + inventory_backup->serialize(os); + else + inventory.serialize(os); } void Player::deSerialize(std::istream &is) diff --git a/src/player.h b/src/player.h index a7a2433ce..29460e1e1 100644 --- a/src/player.h +++ b/src/player.h @@ -121,6 +121,8 @@ public: bool swimming_up; Inventory inventory; + // Actual inventory is backed up here when creative mode is used + Inventory *inventory_backup; bool craftresult_is_preview; diff --git a/src/server.cpp b/src/server.cpp index 07f9875c4..503d60b84 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4130,6 +4130,11 @@ Player *Server::emergePlayer(const char *name, const char *password, u16 peer_id // Reset inventory to creative if in creative mode if(g_settings.getBool("creative_mode")) { + // Warning: double code below + // Backup actual inventory + player->inventory_backup = new Inventory(); + *(player->inventory_backup) = player->inventory; + // Set creative inventory craft_set_creative_inventory(player); } @@ -4183,6 +4188,11 @@ Player *Server::emergePlayer(const char *name, const char *password, u16 peer_id if(g_settings.getBool("creative_mode")) { + // Warning: double code above + // Backup actual inventory + player->inventory_backup = new Inventory(); + *(player->inventory_backup) = player->inventory; + // Set creative inventory craft_set_creative_inventory(player); } else if(g_settings.getBool("give_initial_stuff")) |