139 } |
139 } |
140 |
140 |
141 // This puts a text-message to the console, or in the future, the chat-box, |
141 // This puts a text-message to the console, or in the future, the chat-box, |
142 // (to keep it all a bit more general) |
142 // (to keep it all a bit more general) |
143 // If 'self_send' is true, this is the client who is sending the message |
143 // If 'self_send' is true, this is the client who is sending the message |
144 void CDECL NetworkTextMessage(NetworkAction action, uint16 color, bool self_send, const char *name, const char *str, ...) |
144 void CDECL NetworkTextMessage(NetworkAction action, ConsoleColour color, bool self_send, const char *name, const char *str, ...) |
145 { |
145 { |
146 char buf[1024]; |
146 char buf[1024]; |
147 va_list va; |
147 va_list va; |
148 const int duration = 10; // Game days the messages stay visible |
148 const int duration = 10; // Game days the messages stay visible |
149 char message[1024]; |
149 char message[1024]; |
153 vsnprintf(buf, lengthof(buf), str, va); |
153 vsnprintf(buf, lengthof(buf), str, va); |
154 va_end(va); |
154 va_end(va); |
155 |
155 |
156 switch (action) { |
156 switch (action) { |
157 case NETWORK_ACTION_SERVER_MESSAGE: |
157 case NETWORK_ACTION_SERVER_MESSAGE: |
158 color = 1; |
158 color = CC_DEFAULT; |
159 snprintf(message, sizeof(message), "*** %s", buf); |
159 snprintf(message, sizeof(message), "*** %s", buf); |
160 break; |
160 break; |
161 case NETWORK_ACTION_JOIN: |
161 case NETWORK_ACTION_JOIN: |
162 color = 1; |
162 color = CC_DEFAULT; |
163 GetString(temp, STR_NETWORK_CLIENT_JOINED, lastof(temp)); |
163 GetString(temp, STR_NETWORK_CLIENT_JOINED, lastof(temp)); |
164 snprintf(message, sizeof(message), "*** %s %s", name, temp); |
164 snprintf(message, sizeof(message), "*** %s %s", name, temp); |
165 break; |
165 break; |
166 case NETWORK_ACTION_LEAVE: |
166 case NETWORK_ACTION_LEAVE: |
167 color = 1; |
167 color = CC_DEFAULT; |
168 GetString(temp, STR_NETWORK_ERR_LEFT, lastof(temp)); |
168 GetString(temp, STR_NETWORK_ERR_LEFT, lastof(temp)); |
169 snprintf(message, sizeof(message), "*** %s %s (%s)", name, temp, buf); |
169 snprintf(message, sizeof(message), "*** %s %s (%s)", name, temp, buf); |
170 break; |
170 break; |
171 case NETWORK_ACTION_GIVE_MONEY: |
171 case NETWORK_ACTION_GIVE_MONEY: |
172 if (self_send) { |
172 if (self_send) { |
649 |
649 |
650 NetworkGetClientName(client_name, sizeof(client_name), cs); |
650 NetworkGetClientName(client_name, sizeof(client_name), cs); |
651 |
651 |
652 GetNetworkErrorMsg(str, errorno, lastof(str)); |
652 GetNetworkErrorMsg(str, errorno, lastof(str)); |
653 |
653 |
654 NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str); |
654 NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "%s", str); |
655 |
655 |
656 // Inform other clients of this... strange leaving ;) |
656 // Inform other clients of this... strange leaving ;) |
657 FOR_ALL_CLIENTS(new_cs) { |
657 FOR_ALL_CLIENTS(new_cs) { |
658 if (new_cs->status > STATUS_AUTH && cs != new_cs) { |
658 if (new_cs->status > STATUS_AUTH && cs != new_cs) { |
659 SEND_COMMAND(PACKET_SERVER_ERROR_QUIT)(new_cs, cs->index, errorno); |
659 SEND_COMMAND(PACKET_SERVER_ERROR_QUIT)(new_cs, cs->index, errorno); |