Skip to content

Commit 2f56a00

Browse files
red-001nerzhul
authored andcommittedJan 16, 2017
Remove client-side chat prediction. (#5055)
Network lag isn't really a big issue with chat and chat prediction makes writing mods harder.
1 parent d2f5732 commit 2f56a00

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed
 

Diff for: ‎builtin/game/features.lua

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ core.features = {
1010
texture_names_parens = true,
1111
area_store_custom_ids = true,
1212
add_entity_with_staticdata = true,
13+
no_chat_message_prediction = true,
1314
}
1415

1516
function core.has_feature(arg)

Diff for: ‎src/client.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -1563,10 +1563,13 @@ void Client::typeChatMessage(const std::wstring &message)
15631563
}
15641564
else
15651565
{
1566-
LocalPlayer *player = m_env.getLocalPlayer();
1567-
assert(player != NULL);
1568-
std::wstring name = narrow_to_wide(player->getName());
1569-
m_chat_queue.push((std::wstring)L"<" + name + L"> " + message);
1566+
// compatibility code
1567+
if (m_proto_ver < 29) {
1568+
LocalPlayer *player = m_env.getLocalPlayer();
1569+
assert(player != NULL);
1570+
std::wstring name = narrow_to_wide(player->getName());
1571+
m_chat_queue.push((std::wstring)L"<" + name + L"> " + message);
1572+
}
15701573
}
15711574
}
15721575

Diff for: ‎src/network/networkprotocol.h

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
142142
Server doesn't accept TOSERVER_BREATH anymore
143143
serialization of TileAnimation params changed
144144
TAT_SHEET_2D
145+
Removed client-sided chat perdiction
145146
*/
146147

147148
#define LATEST_PROTOCOL_VERSION 29

Diff for: ‎src/server.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -2826,7 +2826,15 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
28262826

28272827
std::vector<u16> clients = m_clients.getClientIDs();
28282828

2829+
/*
2830+
Send the message back to the inital sender
2831+
if they are using protocol version >= 29
2832+
*/
2833+
28292834
u16 peer_id_to_avoid_sending = (player ? player->peer_id : PEER_ID_INEXISTENT);
2835+
if (player->protocol_version >= 29)
2836+
peer_id_to_avoid_sending = PEER_ID_INEXISTENT;
2837+
28302838
for (u16 i = 0; i < clients.size(); i++) {
28312839
u16 cid = clients[i];
28322840
if (cid != peer_id_to_avoid_sending)

0 commit comments

Comments
 (0)