sources/network/rconsession.cpp

changeset 70
0e947b487b18
parent 58
d175243ad169
child 71
4f7c2c944637
equal deleted inserted replaced
69:eb4c25284a19 70:0e947b487b18
106 int header = packet.read_byte(); 106 int header = packet.read_byte();
107 107
108 switch (ServerResponse (header)) 108 switch (ServerResponse (header))
109 { 109 {
110 case SVRC_OLDPROTOCOL: 110 case SVRC_OLDPROTOCOL:
111 print ("Your RCON client is using outdated protocol.\n"); 111 print_error ("Your RCON client is using outdated protocol.\n");
112 m_state = RCON_DISCONNECTED; 112 m_state = RCON_DISCONNECTED;
113 break; 113 break;
114 114
115 case SVRC_BANNED: 115 case SVRC_BANNED:
116 print ("You have been banned from the server.\n"); 116 print_error ("You have been banned from the server.\n");
117 m_state = RCON_DISCONNECTED; 117 m_state = RCON_DISCONNECTED;
118 break; 118 break;
119 119
120 case SVRC_SALT: 120 case SVRC_SALT:
121 m_salt = packet.read_string(); 121 m_salt = packet.read_string();
122 m_state = RCON_AUTHENTICATING; 122 m_state = RCON_AUTHENTICATING;
123 send_password(); 123 send_password();
124 break; 124 break;
125 125
126 case SVRC_INVALIDPASSWORD: 126 case SVRC_INVALIDPASSWORD:
127 print ("Password incorrect.\n"); 127 print_error ("Login failed.\n");
128 m_state = RCON_DISCONNECTED; 128 m_state = RCON_DISCONNECTED;
129 break; 129 break;
130 130
131 case SVRC_MESSAGE: 131 case SVRC_MESSAGE:
132 { 132 {
164 } 164 }
165 } 165 }
166 } 166 }
167 catch (std::exception& e) 167 catch (std::exception& e)
168 { 168 {
169 print ("error while reading packet: %1\n", e.what()); 169 print_warning ("Couldn't process packet: %1\n", e.what());
170 } 170 }
171 } 171 }
172 172
173 METHOD 173 METHOD
174 RCONSession::process_server_updates (Bytestream& packet) -> void 174 RCONSession::process_server_updates (Bytestream& packet) -> void
175 { 175 {
176 switch (RCONUpdateType (packet.read_byte())) 176 int header = packet.read_byte();
177
178 switch (RCONUpdateType (header))
177 { 179 {
178 case SVRCU_PLAYERDATA: 180 case SVRCU_PLAYERDATA:
179 { 181 {
180 StringList players; 182 StringList players;
181 183
182 for (int i = packet.read_byte(); i > 0; --i) 184 for (int i = packet.read_byte(); i > 0; --i)
183 players << packet.read_string(); 185 players.append (packet.read_string());
184 186
185 Interface::set_player_names (players); 187 Interface::set_player_names (players);
186 } 188 }
187 break; 189 break;
188 190
192 break; 194 break;
193 195
194 case SVRCU_MAP: 196 case SVRCU_MAP:
195 m_level = packet.read_string(); 197 m_level = packet.read_string();
196 Interface::update_statusbar(); 198 Interface::update_statusbar();
199 break;
200
201 default:
202 print_warning ("Unknown server update type: %d\n", header);
197 break; 203 break;
198 } 204 }
199 } 205 }
200 206
201 // ------------------------------------------------------------------------------------------------- 207 // -------------------------------------------------------------------------------------------------

mercurial