Skip to content

Commit

Permalink
Send all item metadata when local map saving is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
LizzyFleckenstein03 committed Mar 5, 2021
1 parent 1f4d8d8 commit 2329236
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/client/client.cpp
Expand Up @@ -1008,14 +1008,15 @@ AuthMechanism Client::choseAuthMech(const u32 mechs)

void Client::sendInit(const std::string &playerName)
{
NetworkPacket pkt(TOSERVER_INIT, 1 + 2 + 2 + (1 + playerName.size()));
NetworkPacket pkt(TOSERVER_INIT, 1 + 2 + 2 + (1 + playerName.size()) + 1);

// we don't support network compression yet
u16 supp_comp_modes = NETPROTO_COMPRESSION_NONE;

pkt << (u8) SER_FMT_VER_HIGHEST_READ << (u16) supp_comp_modes;
pkt << (u16) CLIENT_PROTOCOL_VERSION_MIN << (u16) CLIENT_PROTOCOL_VERSION_MAX;
pkt << playerName;
pkt << (u8) (m_localdb ? 1 : 0);

Send(&pkt);
}
Expand Down
2 changes: 2 additions & 0 deletions src/clientiface.h
Expand Up @@ -233,6 +233,8 @@ class RemoteClient
//
u16 net_proto_version = 0;

u8 mapsaving_enabled = 0;

/* Authentication information */
std::string enc_pwd = "";
bool create_player_on_auth_success = false;
Expand Down
7 changes: 7 additions & 0 deletions src/network/serverpackethandler.cpp
Expand Up @@ -100,10 +100,17 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
u16 min_net_proto_version = 0;
u16 max_net_proto_version;
std::string playerName;
u8 mapsaving_enabled = 0;

*pkt >> client_max >> supp_compr_modes >> min_net_proto_version
>> max_net_proto_version >> playerName;

try {
*pkt >> mapsaving_enabled;
} catch (PacketError &e) {};

client->mapsaving_enabled = mapsaving_enabled;

u8 our_max = SER_FMT_VER_HIGHEST_READ;
// Use the highest version supported by both
u8 depl_serial_v = std::min(client_max, our_max);
Expand Down
4 changes: 2 additions & 2 deletions src/server.cpp
Expand Up @@ -1471,7 +1471,7 @@ void Server::SendInventory(PlayerSAO *sao, bool incremental)
NetworkPacket pkt(TOCLIENT_INVENTORY, 0, sao->getPeerID());

std::ostringstream os(std::ios::binary);
sao->getInventory()->serialize(os, incremental, g_settings->getBool("send_all_item_metadata"));
sao->getInventory()->serialize(os, incremental, g_settings->getBool("send_all_item_metadata") || getClient(sao->getPeerID(), CS_InitDone)->mapsaving_enabled);
sao->getInventory()->setModified(false);
player->setModified(true);

Expand Down Expand Up @@ -2335,7 +2335,7 @@ void Server::SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver,
*/
thread_local const int net_compression_level = rangelim(g_settings->getS16("map_compression_level_net"), -1, 9);
std::ostringstream os(std::ios_base::binary);
block->serialize(os, ver, false, net_compression_level, g_settings->getBool("send_all_item_metadata"));
block->serialize(os, ver, false, net_compression_level, g_settings->getBool("send_all_item_metadata") || getClient(peer_id)->mapsaving_enabled);
block->serializeNetworkSpecific(os);
std::string s = os.str();

Expand Down

0 comments on commit 2329236

Please sign in to comment.