The server is telling me about a player in the game Client only
| 2510 | // The server is telling me about a player in the game |
| 2511 | // Client only |
| 2512 | void MultiDoPlayer(uint8_t *data) { |
| 2513 | int count = 0; |
| 2514 | char ship_name[PAGENAME_LEN]; |
| 2515 | |
| 2516 | mprintf(0, "Got player packet!\n"); |
| 2517 | |
| 2518 | // Skip header stuff |
| 2519 | SKIP_HEADER(data, &count); |
| 2520 | |
| 2521 | // Get slotnumber |
| 2522 | uint8_t slot = MultiGetByte(data, &count); |
| 2523 | |
| 2524 | // Reset some local stuff for this player |
| 2525 | if (slot != Player_num) { |
| 2526 | InitPlayerNewShip(slot, INVRESET_ALL); |
| 2527 | InitPlayerNewGame(slot); |
| 2528 | PlayerStopSounds(slot); |
| 2529 | ResetPlayerObject(slot); |
| 2530 | InitPlayerNewLevel(slot); |
| 2531 | } |
| 2532 | |
| 2533 | // Get name |
| 2534 | uint8_t len = MultiGetByte(data, &count); |
| 2535 | memcpy(Players[slot].callsign, &data[count], len); |
| 2536 | count += len; |
| 2537 | |
| 2538 | // Get ship name |
| 2539 | len = MultiGetByte(data, &count); |
| 2540 | memcpy(ship_name, &data[count], len); |
| 2541 | count += len; |
| 2542 | |
| 2543 | int ship_index = FindShipName(ship_name); |
| 2544 | if (ship_index < 0) { |
| 2545 | ship_index = 0; // Should we bail out here? |
| 2546 | } |
| 2547 | |
| 2548 | PlayerChangeShip(slot, ship_index); |
| 2549 | |
| 2550 | // Get various flags |
| 2551 | if (slot != Player_num) { |
| 2552 | Players[slot].flags = MultiGetInt(data, &count); |
| 2553 | Players[slot].weapon_flags = MultiGetInt(data, &count); |
| 2554 | } else { |
| 2555 | // Skip my own data |
| 2556 | MultiGetInt(data, &count); |
| 2557 | MultiGetInt(data, &count); |
| 2558 | } |
| 2559 | |
| 2560 | NetPlayers[slot].flags = MultiGetInt(data, &count); |
| 2561 | float shields = MultiGetFloat(data, &count); |
| 2562 | |
| 2563 | // Get object number, just to verify |
| 2564 | int objnum = MultiGetShort(data, &count); |
| 2565 | |
| 2566 | // Make sure we have the right object number |
| 2567 | if (objnum != Players[slot].objnum) { |
| 2568 | BailOnMultiplayer(NULL); |
| 2569 | return; |
no test coverage detected