| 451 | } |
| 452 | |
| 453 | void CStatboard::FormatStats(char *pDest, size_t DestSize) |
| 454 | { |
| 455 | // server stats |
| 456 | CServerInfo CurrentServerInfo; |
| 457 | Client()->GetServerInfo(&CurrentServerInfo); |
| 458 | char aServerStats[1024]; |
| 459 | str_format(aServerStats, sizeof(aServerStats), "Servername,Game-type,Map\n%s,%s,%s", ReplaceCommata(CurrentServerInfo.m_aName).c_str(), ReplaceCommata(CurrentServerInfo.m_aGameType).c_str(), ReplaceCommata(CurrentServerInfo.m_aMap).c_str()); |
| 460 | |
| 461 | // player stats |
| 462 | |
| 463 | // sort players |
| 464 | const CNetObj_PlayerInfo *apPlayers[MAX_CLIENTS] = {nullptr}; |
| 465 | int NumPlayers = 0; |
| 466 | |
| 467 | // sort red or dm players by score |
| 468 | for(const auto *pInfo : GameClient()->m_Snap.m_apInfoByScore) |
| 469 | { |
| 470 | if(!pInfo || !GameClient()->m_aStats[pInfo->m_ClientId].IsActive() || GameClient()->m_aClients[pInfo->m_ClientId].m_Team != TEAM_RED) |
| 471 | continue; |
| 472 | apPlayers[NumPlayers] = pInfo; |
| 473 | NumPlayers++; |
| 474 | } |
| 475 | |
| 476 | // sort blue players by score after |
| 477 | if(GameClient()->IsTeamPlay()) |
| 478 | { |
| 479 | for(const auto *pInfo : GameClient()->m_Snap.m_apInfoByScore) |
| 480 | { |
| 481 | if(!pInfo || !GameClient()->m_aStats[pInfo->m_ClientId].IsActive() || GameClient()->m_aClients[pInfo->m_ClientId].m_Team != TEAM_BLUE) |
| 482 | continue; |
| 483 | apPlayers[NumPlayers] = pInfo; |
| 484 | NumPlayers++; |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | char aPlayerStats[1024 * VANILLA_MAX_CLIENTS] = "Local-player,Team,Name,Clan,Score,Frags,Deaths,Suicides,F/D-ratio,Net,FPM,Spree,Best,Hammer-F/D,Gun-F/D,Shotgun-F/D,Grenade-F/D,Laser-F/D,Ninja-F/D,GameWithFlags,Flag-grabs,Flag-captures\n"; |
| 489 | for(int i = 0; i < NumPlayers; i++) |
| 490 | { |
| 491 | const CNetObj_PlayerInfo *pInfo = apPlayers[i]; |
| 492 | const CGameClient::CClientStats *pStats = &GameClient()->m_aStats[pInfo->m_ClientId]; |
| 493 | |
| 494 | // Pre-formatting |
| 495 | |
| 496 | // Weapons frags/deaths |
| 497 | char aWeaponFD[64 * NUM_WEAPONS]; |
| 498 | for(int j = 0; j < NUM_WEAPONS; j++) |
| 499 | { |
| 500 | if(j == 0) |
| 501 | str_format(aWeaponFD, sizeof(aWeaponFD), "%d/%d", pStats->m_aFragsWith[j], pStats->m_aDeathsFrom[j]); |
| 502 | else |
| 503 | str_format(aWeaponFD, sizeof(aWeaponFD), "%s,%d/%d", aWeaponFD, pStats->m_aFragsWith[j], pStats->m_aDeathsFrom[j]); |
| 504 | } |
| 505 | |
| 506 | // Frag/Death ratio |
| 507 | float KillRatio = 0.0f; |
| 508 | if(pStats->m_Deaths != 0) |
| 509 | KillRatio = (float)(pStats->m_Frags) / pStats->m_Deaths; |
| 510 |
nothing calls this directly
no test coverage detected