diff --git a/src/environment.cpp b/src/environment.cpp index 4b785998b..21a6258b7 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -434,6 +434,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir) //infostream<<"Found matching player, overwriting."<checkModified()) { // Open file and serialize std::ofstream os(path.c_str(), std::ios_base::binary); @@ -444,6 +445,8 @@ void ServerEnvironment::serializePlayers(const std::string &savedir) } player->serialize(os); saved_players.insert(player); + } else { + saved_players.insert(player); } } diff --git a/src/inventory.cpp b/src/inventory.cpp index d6815d329..928021c2f 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -562,6 +562,26 @@ InventoryList & InventoryList::operator = (const InventoryList &other) return *this; } +bool InventoryList::operator == (const InventoryList &other) +{ + if(m_size != other.m_size) + return false; + if(m_width != other.m_width) + return false; + if(m_name != other.m_name) + return false; + for(u32 i=0; iidef()) { updateName(""); inventory.clear(); @@ -53,6 +58,7 @@ Player::Player(IGameDef *gamedef): craft->setWidth(3); inventory.addList("craftpreview", 1); inventory.addList("craftresult", 1); + m_last_inventory = inventory; // Can be redefined via Lua inventory_formspec = "size[8,7.5]" @@ -224,6 +230,9 @@ void Player::deSerialize(std::istream &is, std::string playername) inventory.getList("craftresult")->changeItem(0, ItemStack()); } } + + // Set m_last_* + checkModified(); } /* diff --git a/src/player.h b/src/player.h index 89e4667c4..60645a60f 100644 --- a/src/player.h +++ b/src/player.h @@ -199,6 +199,23 @@ public: void serialize(std::ostream &os); void deSerialize(std::istream &is, std::string playername); + bool checkModified() + { + if(m_last_hp != hp || m_last_pitch != m_pitch || + m_last_pos != m_position || m_last_yaw != m_yaw || + !(inventory == m_last_inventory)) + { + m_last_hp = hp; + m_last_pitch = m_pitch; + m_last_pos = m_position; + m_last_yaw = m_yaw; + m_last_inventory = inventory; + return true; + } else { + return false; + } + } + bool touching_ground; // This oscillates so that the player jumps a bit above the surface bool in_liquid; @@ -262,6 +279,12 @@ protected: v3f m_speed; v3f m_position; core::aabbox3d m_collisionbox; + + f32 m_last_pitch; + f32 m_last_yaw; + v3f m_last_pos; + u16 m_last_hp; + Inventory m_last_inventory; };