| 1332 | |
| 1333 | |
| 1334 | void handleAllow(void* msg) { |
| 1335 | PlayerId id; |
| 1336 | LocalPlayer* localtank = NULL; |
| 1337 | msg = nboUnpackUInt8(msg, id); |
| 1338 | |
| 1339 | uint8_t allow; |
| 1340 | nboUnpackUInt8(msg, allow); |
| 1341 | |
| 1342 | Player* tank = NULL; |
| 1343 | if (myTank && myTank->getId() == id) { |
| 1344 | tank = localtank = myTank; |
| 1345 | } |
| 1346 | else { |
| 1347 | #ifdef ROBOT |
| 1348 | for (int i = 0; i < MAX_ROBOTS; i++) { |
| 1349 | if (robots[i] && robots[i]->getId() == id) { |
| 1350 | tank = localtank = robots[i]; |
| 1351 | } |
| 1352 | } |
| 1353 | #endif |
| 1354 | if (!tank) { |
| 1355 | tank = lookupPlayer(id); |
| 1356 | } |
| 1357 | } |
| 1358 | if (!tank) { return; } |
| 1359 | |
| 1360 | if (localtank) { |
| 1361 | localtank->setDesiredSpeed(0.0); |
| 1362 | localtank->setDesiredAngVel(0.0); |
| 1363 | // drop any team flag we may have, as would happen if we paused |
| 1364 | const FlagType* flagd = localtank->getFlagType(); |
| 1365 | if (flagd->flagTeam != NoTeam) { |
| 1366 | serverLink->sendDropFlag(localtank->getPosition()); |
| 1367 | localtank->setShotType(StandardShot); |
| 1368 | } |
| 1369 | } |
| 1370 | |
| 1371 | tank->setAllow(allow); |
| 1372 | |
| 1373 | if (!BZDBCache::forbidDebug) { |
| 1374 | const unsigned char moveBits = AllowMoveForward | |
| 1375 | AllowMoveBackward | |
| 1376 | AllowTurnLeft | |
| 1377 | AllowTurnRight; |
| 1378 | debugf(3, "%s: %s", tank->getCallSign(), |
| 1379 | ((allow & moveBits) == moveBits) ? "Movement allowed" |
| 1380 | : "Movement restricted"); |
| 1381 | debugf(3, "%s: %s", tank->getCallSign(), |
| 1382 | (allow & AllowShoot) ? "Shooting allowed" |
| 1383 | : "Shooting forbidden"); |
| 1384 | debugf(3, "%s: %s", tank->getCallSign(), |
| 1385 | (allow & AllowJump) ? "Jumping allowed" |
| 1386 | : "Jumping forbidden"); |
| 1387 | } |
| 1388 | } |
| 1389 | |
| 1390 | |
| 1391 | void handleDropFlag(void* msg) { |
no test coverage detected