Sends the Player records info to the given client
| 494 | |
| 495 | // Sends the Player records info to the given client |
| 496 | void PRec_SendPRecToPlayer(int pnum) { |
| 497 | if (basethis->GetLocalRole() != LR_SERVER) |
| 498 | return; |
| 499 | |
| 500 | uint8_t data[MAX_GAME_DATA_SIZE]; |
| 501 | int callsignlen, totalsize, totalcount; |
| 502 | totalsize = totalcount = 0; |
| 503 | int pinfo_size, count; |
| 504 | |
| 505 | for (int i = 0; i < MAX_PLAYER_RECORDS; i++) { |
| 506 | if (Player_records[i].state != STATE_EMPTY) { |
| 507 | callsignlen = strlen(Player_records[i].callsign); |
| 508 | |
| 509 | if (Player_records[i].pinfo) |
| 510 | pinfo_size = Player_records[i].pinfo->GetSizeOfData(); |
| 511 | else |
| 512 | pinfo_size = 0; |
| 513 | |
| 514 | uint8_t tracker_len = 0; |
| 515 | |
| 516 | if (Player_records[i].tracker_id) { |
| 517 | tracker_len = strlen(Player_records[i].tracker_id); |
| 518 | } |
| 519 | |
| 520 | count = 0; |
| 521 | basethis->StartPacket(data, SPID_PRECORD, &count); |
| 522 | |
| 523 | MultiAddByte(i, data, &count); // pack byte (record num) |
| 524 | MultiAddByte(Player_records[i].state, data, &count); // pack byte (state) |
| 525 | MultiAddByte(callsignlen, data, &count); // pack byte (strlen(callsign)) |
| 526 | memcpy(&data[count], Player_records[i].callsign, callsignlen); |
| 527 | count += callsignlen; // pack bytes (callsign) |
| 528 | MultiPackNetworkAddress(&Player_records[i].net_addr, data, &count); // pack bytes (network_address) |
| 529 | MultiAddByte(Player_records[i].pnum, data, &count); // pack byte (pnum) |
| 530 | MultiAddByte((Player_records[i].team == -1) ? 255 : Player_records[i].team, data, &count); // pack byte (team) |
| 531 | |
| 532 | if (basethis->IsMasterTrackerGame()) { |
| 533 | MultiAddByte(1, data, &count); |
| 534 | MultiAddByte(tracker_len, data, &count); // pack byte (tracker len) |
| 535 | if (tracker_len) { |
| 536 | memcpy(&data[count], Player_records[i].tracker_id, tracker_len); |
| 537 | count += tracker_len; // pack bytes (tracker_id) |
| 538 | } |
| 539 | } else { |
| 540 | MultiAddByte(0, data, &count); |
| 541 | } |
| 542 | |
| 543 | MultiAddFloat(Player_records[i].disconnect_time, data, &count); // pack float (disconnect_time/start_time) |
| 544 | MultiAddFloat(Player_records[i].total_time_in_game, data, &count); // pack float (total time in game) |
| 545 | |
| 546 | MultiPackDStats(&Player_records[i].dstats, data, &count); // pack bytes (dstats) |
| 547 | |
| 548 | MultiAddByte((Player_records[i].user_info_size > 0) ? 1 : 0, data, &count); // pack byte (there is user info) |
| 549 | if (Player_records[i].user_info_size > 0) // if(user_info_size>0) |
| 550 | { |
| 551 | if (Player_record_pack_cb) { |
| 552 | count += (*Player_record_pack_cb)(Player_records[i].user_info, &data[count]); |
| 553 | } else { |
no test coverage detected