File diff r25977:e1f4fbb88a36 → r25978:1911877bcb73
src/network/network.cpp
Show inline comments
 
@@ -214,13 +214,13 @@ bool NetworkCompanyIsPassworded(CompanyI
 
	return HasBit(_network_company_passworded, company_id);
 
}
 

	
 
/* This puts a text-message to the console, or in the future, the chat-box,
 
 *  (to keep it all a bit more general)
 
 * If 'self_send' is true, this is the client who is sending the message */
 
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str, int64 data)
 
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str, int64 data, const std::string &data_str)
 
{
 
	StringID strid;
 
	switch (action) {
 
		case NETWORK_ACTION_SERVER_MESSAGE:
 
			/* Ignore invalid messages */
 
			strid = STR_NETWORK_SERVER_MESSAGE;
 
@@ -245,30 +245,32 @@ void NetworkTextMessage(NetworkAction ac
 
		case NETWORK_ACTION_LEAVE:          strid = STR_NETWORK_MESSAGE_CLIENT_LEFT; break;
 
		case NETWORK_ACTION_NAME_CHANGE:    strid = STR_NETWORK_MESSAGE_NAME_CHANGE; break;
 
		case NETWORK_ACTION_GIVE_MONEY:     strid = STR_NETWORK_MESSAGE_GIVE_MONEY; break;
 
		case NETWORK_ACTION_CHAT_COMPANY:   strid = self_send ? STR_NETWORK_CHAT_TO_COMPANY : STR_NETWORK_CHAT_COMPANY; break;
 
		case NETWORK_ACTION_CHAT_CLIENT:    strid = self_send ? STR_NETWORK_CHAT_TO_CLIENT  : STR_NETWORK_CHAT_CLIENT;  break;
 
		case NETWORK_ACTION_KICKED:         strid = STR_NETWORK_MESSAGE_KICKED; break;
 
		case NETWORK_ACTION_EXTERNAL_CHAT:  strid = STR_NETWORK_CHAT_EXTERNAL; break;
 
		default:                            strid = STR_NETWORK_CHAT_ALL; break;
 
	}
 

	
 
	char message[1024];
 
	SetDParamStr(0, name);
 
	SetDParamStr(1, str);
 
	SetDParam(2, data);
 
	SetDParamStr(3, data_str);
 

	
 
	/* All of these strings start with "***". These characters are interpreted as both left-to-right and
 
	 * right-to-left characters depending on the context. As the next text might be an user's name, the
 
	 * user name's characters will influence the direction of the "***" instead of the language setting
 
	 * of the game. Manually set the direction of the "***" by inserting a text-direction marker. */
 
	char *msg_ptr = message + Utf8Encode(message, _current_text_dir == TD_LTR ? CHAR_TD_LRM : CHAR_TD_RLM);
 
	GetString(msg_ptr, strid, lastof(message));
 

	
 
	Debug(desync, 1, "msg: {:08x}; {:02x}; {}", _date, _date_fract, message);
 
	IConsolePrint(colour, message);
 
	NetworkAddChatMessage((TextColour)colour, _settings_client.gui.network_chat_timeout, message);
 
	NetworkAddChatMessage(colour, _settings_client.gui.network_chat_timeout, message);
 
}
 

	
 
/* Calculate the frame-lag of a client */
 
uint NetworkCalculateLag(const NetworkClientSocket *cs)
 
{
 
	int lag = cs->last_frame_server - cs->last_frame;