70 { |
70 { |
71 // Say goodbye to remote |
71 // Say goodbye to remote |
72 Bytestream packet; |
72 Bytestream packet; |
73 packet.write_byte (CLRC_DISCONNECT); |
73 packet.write_byte (CLRC_DISCONNECT); |
74 this->send (packet); |
74 this->send (packet); |
75 m_interface->print ("Disconnected from %1\n", m_address.to_string (IP_WITH_PORT)); |
75 m_interface->print ("Disconnected from %s\n", m_address.to_string (IP_WITH_PORT).chars()); |
76 m_interface->update_statusbar(); |
76 m_interface->update_statusbar(); |
77 } |
77 } |
78 |
78 |
79 m_state = RCON_DISCONNECTED; |
79 m_state = RCON_DISCONNECTED; |
80 } |
80 } |
190 break; |
190 break; |
191 |
191 |
192 case SVRC_TOOMANYTABCOMPLETES: |
192 case SVRC_TOOMANYTABCOMPLETES: |
193 { |
193 { |
194 unsigned int numCompletions = packet.read_short(); |
194 unsigned int numCompletions = packet.read_short(); |
195 m_interface->print ("%1 completions for '%2'.\n", |
195 m_interface->print ("%d completions for '%s'.\n", |
196 int (numCompletions), m_lastTabComplete); |
196 int (numCompletions), m_lastTabComplete.chars()); |
197 } |
197 } |
198 break; |
198 break; |
199 |
199 |
200 case SVRC_TABCOMPLETE: |
200 case SVRC_TABCOMPLETE: |
201 { |
201 { |
208 { |
208 { |
209 m_interface->tab_complete (m_lastTabComplete, completes[0]); |
209 m_interface->tab_complete (m_lastTabComplete, completes[0]); |
210 } |
210 } |
211 else if (not completes.is_empty()) |
211 else if (not completes.is_empty()) |
212 { |
212 { |
213 m_interface->print ("Completions for '%1':\n", m_lastTabComplete); |
213 m_interface->print ("Completions for '%s':\n", m_lastTabComplete.chars()); |
214 |
214 |
215 for (int i = 0; i < completes.size(); i += 8) |
215 for (int i = 0; i < completes.size(); i += 8) |
216 { |
216 { |
217 Range<int> spliceRange (i, min (i + 8, completes.size() - 1)); |
217 Range<int> spliceRange (i, min (i + 8, completes.size() - 1)); |
218 StringList splice (completes.splice (spliceRange)); |
218 StringList splice (completes.splice (spliceRange)); |
219 m_interface->print ("- %1\n", splice.join (", ")); |
219 m_interface->print ("- %s\n", splice.join (", ").chars()); |
220 } |
220 } |
221 } |
221 } |
222 } |
222 } |
223 break; |
223 break; |
224 } |
224 } |
225 } |
225 } |
226 } |
226 } |
227 catch (std::exception& e) |
227 catch (std::exception& e) |
228 { |
228 { |
229 m_interface->print_warning ("Couldn't process packet: %1\n", e.what()); |
229 m_interface->print_warning ("Couldn't process packet: %s\n", e.what()); |
230 } |
230 } |
231 } |
231 } |
232 |
232 |
233 void RCONSession::process_server_updates (Bytestream& packet) |
233 void RCONSession::process_server_updates (Bytestream& packet) |
234 { |
234 { |
272 |
272 |
273 // ------------------------------------------------------------------------------------------------- |
273 // ------------------------------------------------------------------------------------------------- |
274 // |
274 // |
275 void RCONSession::send_hello() |
275 void RCONSession::send_hello() |
276 { |
276 { |
277 m_interface->print ("Connecting to %1...\n", m_address.to_string (IP_WITH_PORT)); |
277 m_interface->print ("Connecting to %s...\n", m_address.to_string (IP_WITH_PORT).chars()); |
278 Bytestream packet; |
278 Bytestream packet; |
279 packet.write_byte (CLRC_BEGINCONNECTION); |
279 packet.write_byte (CLRC_BEGINCONNECTION); |
280 packet.write_byte (RCON_PROTOCOL_VERSION); |
280 packet.write_byte (RCON_PROTOCOL_VERSION); |
281 send (packet); |
281 send (packet); |
282 bump_last_ping(); |
282 bump_last_ping(); |