| 146 | |
| 147 | |
| 148 | BZAdminClient::ServerCode BZAdminClient::checkMessage() { |
| 149 | uint16_t code, len; |
| 150 | char inbuf[MaxPacketLen]; |
| 151 | std::string dstName, srcName; |
| 152 | int i = 0; |
| 153 | PlayerIdMap::iterator iter; |
| 154 | |
| 155 | sLink.flush(); |
| 156 | // read until we have a package, or until we have waited 100 ms |
| 157 | if (sLink.read(code, len, inbuf, 100) == 1) { |
| 158 | lastMessage.first = ""; |
| 159 | lastMessage.second = Default; |
| 160 | void* vbuf = inbuf; |
| 161 | PlayerId p; |
| 162 | PlayerIdMap::const_iterator it; |
| 163 | std::string victimName, killerName; |
| 164 | Address a; |
| 165 | if ((messageMask.find(code) != messageMask.end()) && |
| 166 | (code == MsgSetVar || code == MsgRemovePlayer || |
| 167 | code == MsgAddPlayer || code == MsgAdminInfo || |
| 168 | code == MsgPlayerInfo || (*(messageMask.find(code))).second)) |
| 169 | switch (code) { |
| 170 | |
| 171 | case MsgNewRabbit: |
| 172 | vbuf = nboUnpackUInt8(vbuf, p); |
| 173 | if (p != NoPlayer) |
| 174 | lastMessage.first = std::string("*** '") + players[p].name + |
| 175 | "' is now the rabbit."; |
| 176 | break; |
| 177 | |
| 178 | case MsgPause: |
| 179 | uint8_t pauseCode; |
| 180 | vbuf = nboUnpackUInt8(vbuf, p); |
| 181 | vbuf = nboUnpackUInt8(vbuf, pauseCode); |
| 182 | switch (pauseCode) { |
| 183 | case PauseCodeEnable: { |
| 184 | lastMessage.first = "*** '" + players[p].name + "': paused"; |
| 185 | break; |
| 186 | } |
| 187 | case PauseCodeDisable: { |
| 188 | lastMessage.first = "*** '" + players[p].name + "': resumed"; |
| 189 | break; |
| 190 | } |
| 191 | default: { |
| 192 | break; // bzadmin clients should not receive |
| 193 | // PauseCodeAcknowlege or PauseCodeCancel |
| 194 | } |
| 195 | } |
| 196 | break; |
| 197 | |
| 198 | case MsgAlive: |
| 199 | vbuf = nboUnpackUInt8(vbuf, p); |
| 200 | lastMessage.first = std::string("*** '") + players[p].name + |
| 201 | "' has respawned."; |
| 202 | break; |
| 203 | |
| 204 | case MsgLagPing: |
| 205 | lastMessage.first = "*** Received lag ping from server."; |
nothing calls this directly
no test coverage detected