Remove client-side chat prediction. (#5055)

Network lag isn't really a big issue with chat and chat prediction makes writing mods harder.
This commit is contained in:
red-001 2017-01-16 23:09:47 +00:00 committed by Loïc Blot
parent d2f5732f89
commit 2f56a00d9e
4 changed files with 17 additions and 4 deletions

@ -10,6 +10,7 @@ core.features = {
texture_names_parens = true, texture_names_parens = true,
area_store_custom_ids = true, area_store_custom_ids = true,
add_entity_with_staticdata = true, add_entity_with_staticdata = true,
no_chat_message_prediction = true,
} }
function core.has_feature(arg) function core.has_feature(arg)

@ -1563,12 +1563,15 @@ void Client::typeChatMessage(const std::wstring &message)
} }
else else
{ {
// compatibility code
if (m_proto_ver < 29) {
LocalPlayer *player = m_env.getLocalPlayer(); LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL); assert(player != NULL);
std::wstring name = narrow_to_wide(player->getName()); std::wstring name = narrow_to_wide(player->getName());
m_chat_queue.push((std::wstring)L"<" + name + L"> " + message); m_chat_queue.push((std::wstring)L"<" + name + L"> " + message);
} }
} }
}
void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server, bool urgent) void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server, bool urgent)
{ {

@ -142,6 +142,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Server doesn't accept TOSERVER_BREATH anymore Server doesn't accept TOSERVER_BREATH anymore
serialization of TileAnimation params changed serialization of TileAnimation params changed
TAT_SHEET_2D TAT_SHEET_2D
Removed client-sided chat perdiction
*/ */
#define LATEST_PROTOCOL_VERSION 29 #define LATEST_PROTOCOL_VERSION 29

@ -2826,7 +2826,15 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
std::vector<u16> clients = m_clients.getClientIDs(); std::vector<u16> clients = m_clients.getClientIDs();
/*
Send the message back to the inital sender
if they are using protocol version >= 29
*/
u16 peer_id_to_avoid_sending = (player ? player->peer_id : PEER_ID_INEXISTENT); u16 peer_id_to_avoid_sending = (player ? player->peer_id : PEER_ID_INEXISTENT);
if (player->protocol_version >= 29)
peer_id_to_avoid_sending = PEER_ID_INEXISTENT;
for (u16 i = 0; i < clients.size(); i++) { for (u16 i = 0; i < clients.size(); i++) {
u16 cid = clients[i]; u16 cid = clients[i];
if (cid != peer_id_to_avoid_sending) if (cid != peer_id_to_avoid_sending)