133 int header = packet.read_byte(); |
133 int header = packet.read_byte(); |
134 |
134 |
135 switch (ServerResponse (header)) |
135 switch (ServerResponse (header)) |
136 { |
136 { |
137 case SVRC_OLDPROTOCOL: |
137 case SVRC_OLDPROTOCOL: |
138 m_interface->print_error ("Your RCON client is using outdated protocol.\n"); |
138 m_interface->printError ("Your RCON client is using outdated protocol.\n"); |
139 m_state = RCON_DISCONNECTED; |
139 m_state = RCON_DISCONNECTED; |
140 break; |
140 break; |
141 |
141 |
142 case SVRC_BANNED: |
142 case SVRC_BANNED: |
143 m_interface->print_error ("You have been banned from the server.\n"); |
143 m_interface->printError ("You have been banned from the server.\n"); |
144 m_state = RCON_DISCONNECTED; |
144 m_state = RCON_DISCONNECTED; |
145 break; |
145 break; |
146 |
146 |
147 case SVRC_SALT: |
147 case SVRC_SALT: |
148 m_salt = packet.read_string(); |
148 m_salt = packet.read_string(); |
149 m_state = RCON_AUTHENTICATING; |
149 m_state = RCON_AUTHENTICATING; |
150 send_password(); |
150 send_password(); |
151 break; |
151 break; |
152 |
152 |
153 case SVRC_INVALIDPASSWORD: |
153 case SVRC_INVALIDPASSWORD: |
154 m_interface->print_error ("Login failed.\n"); |
154 m_interface->printError ("Login failed.\n"); |
155 m_state = RCON_DISCONNECTED; |
155 m_state = RCON_DISCONNECTED; |
156 break; |
156 break; |
157 |
157 |
158 case SVRC_MESSAGE: |
158 case SVRC_MESSAGE: |
159 { |
159 { |
160 String message = packet.read_string(); |
160 String message = packet.read_string(); |
161 message.normalize(); |
161 message.normalize(); |
162 m_interface->print_text ("%s\n", message.chars()); |
162 m_interface->printText ("%s\n", message.chars()); |
163 } |
163 } |
164 break; |
164 break; |
165 |
165 |
166 case SVRC_LOGGEDIN: |
166 case SVRC_LOGGEDIN: |
167 m_interface->print ("Login successful!\n"); |
167 m_interface->print ("Login successful!\n"); |
168 m_serverProtocol = packet.read_byte(); |
168 m_serverProtocol = packet.read_byte(); |
169 m_hostname = packet.read_string(); |
169 m_hostname = packet.read_string(); |
170 m_interface->set_title (m_hostname); |
170 m_interface->setTitle (m_hostname); |
171 m_state = RCON_CONNECTED; |
171 m_state = RCON_CONNECTED; |
172 |
172 |
173 for (int i = packet.read_byte(); i > 0; --i) |
173 for (int i = packet.read_byte(); i > 0; --i) |
174 process_server_updates (packet); |
174 process_server_updates (packet); |
175 |
175 |
205 for (String& completion : completes) |
205 for (String& completion : completes) |
206 completion = packet.read_string(); |
206 completion = packet.read_string(); |
207 |
207 |
208 if (completes.size() == 1) |
208 if (completes.size() == 1) |
209 { |
209 { |
210 m_interface->tab_complete (m_lastTabComplete, completes[0]); |
210 m_interface->tabComplete (m_lastTabComplete, completes[0]); |
211 } |
211 } |
212 else if (not completes.is_empty()) |
212 else if (not completes.is_empty()) |
213 { |
213 { |
214 m_interface->print ("Completions for '%s':\n", m_lastTabComplete.chars()); |
214 m_interface->print ("Completions for '%s':\n", m_lastTabComplete.chars()); |
215 |
215 |
242 StringList players; |
242 StringList players; |
243 |
243 |
244 for (int i = packet.read_byte(); i > 0; --i) |
244 for (int i = packet.read_byte(); i > 0; --i) |
245 players.append (packet.read_string()); |
245 players.append (packet.read_string()); |
246 |
246 |
247 m_interface->set_player_names (players); |
247 m_interface->setPlayerNames (players); |
248 } |
248 } |
249 break; |
249 break; |
250 |
250 |
251 case SVRCU_ADMINCOUNT: |
251 case SVRCU_ADMINCOUNT: |
252 m_numAdmins = packet.read_byte(); |
252 m_numAdmins = packet.read_byte(); |
253 m_interface->update_statusbar(); |
253 m_interface->updateStatusBar(); |
254 break; |
254 break; |
255 |
255 |
256 case SVRCU_MAP: |
256 case SVRCU_MAP: |
257 m_level = packet.read_string(); |
257 m_level = packet.read_string(); |
258 m_interface->update_statusbar(); |
258 m_interface->updateStatusBar(); |
259 break; |
259 break; |
260 |
260 |
261 default: |
261 default: |
262 m_interface->print_warning ("Unknown server update type: %d\n", header); |
262 m_interface->printWarning ("Unknown server update type: %d\n", header); |
263 break; |
263 break; |
264 } |
264 } |
265 } |
265 } |
266 |
266 |
267 // ------------------------------------------------------------------------------------------------- |
267 // ------------------------------------------------------------------------------------------------- |