1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Add core.remove_detached_inventory (#7684)

Breaks backwards compatibility for good
Bump protocol version
This commit is contained in:
SmallJoker 2018-10-10 20:48:58 +02:00 committed by GitHub
parent d6f2a1c4b8
commit 0a5e77132a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 101 additions and 35 deletions

View file

@ -843,21 +843,32 @@ void Client::handleCommand_InventoryFormSpec(NetworkPacket* pkt)
void Client::handleCommand_DetachedInventory(NetworkPacket* pkt)
{
std::string datastring(pkt->getString(0), pkt->getSize());
std::istringstream is(datastring, std::ios_base::binary);
std::string name = deSerializeString(is);
std::string name;
bool keep_inv = true;
*pkt >> name >> keep_inv;
infostream << "Client: Detached inventory update: \"" << name
<< "\"" << std::endl;
<< "\", mode=" << (keep_inv ? "update" : "remove") << std::endl;
Inventory *inv = NULL;
if (m_detached_inventories.count(name) > 0)
inv = m_detached_inventories[name];
else {
const auto &inv_it = m_detached_inventories.find(name);
if (!keep_inv) {
if (inv_it != m_detached_inventories.end()) {
delete inv_it->second;
m_detached_inventories.erase(inv_it);
}
return;
}
Inventory *inv = nullptr;
if (inv_it == m_detached_inventories.end()) {
inv = new Inventory(m_itemdef);
m_detached_inventories[name] = inv;
} else {
inv = inv_it->second;
}
std::string contents;
*pkt >> contents;
std::istringstream is(contents, std::ios::binary);
inv->deSerialize(is);
}

View file

@ -188,19 +188,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Nodebox version 5
Add disconnected nodeboxes
Add TOCLIENT_FORMSPEC_PREPEND
PROTOCOL VERSION 37:
Redo detached inventory sending
*/
#define LATEST_PROTOCOL_VERSION 36
#define LATEST_PROTOCOL_VERSION 37
#define LATEST_PROTOCOL_VERSION_STRING TOSTRING(LATEST_PROTOCOL_VERSION)
// Server's supported network protocol range
#define SERVER_PROTOCOL_VERSION_MIN 36
#define SERVER_PROTOCOL_VERSION_MIN 37
#define SERVER_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
// Client's supported network protocol range
// The minimal version depends on whether
// send_pre_v25_init is enabled or not
#define CLIENT_PROTOCOL_VERSION_MIN 36
#define CLIENT_PROTOCOL_VERSION_MIN 37
#define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
// Constant that differentiates the protocol from random data and other protocols