| 2434 | } |
| 2435 | |
| 2436 | void CServer::CacheServerInfoSixup(CCache *pCache, bool SendClients, int MaxConsideredClients) |
| 2437 | { |
| 2438 | pCache->Clear(); |
| 2439 | |
| 2440 | CPacker Packer; |
| 2441 | Packer.Reset(); |
| 2442 | |
| 2443 | // Could be moved to a separate function and cached |
| 2444 | // count the players |
| 2445 | int PlayerCount = 0, ClientCount = 0, ClientCountAll = 0; |
| 2446 | for(int i = 0; i < MAX_CLIENTS; i++) |
| 2447 | { |
| 2448 | if(m_aClients[i].IncludedInServerInfo()) |
| 2449 | { |
| 2450 | ClientCountAll++; |
| 2451 | if(i < MaxConsideredClients) |
| 2452 | { |
| 2453 | if(GameServer()->IsClientPlayer(i)) |
| 2454 | PlayerCount++; |
| 2455 | |
| 2456 | ClientCount++; |
| 2457 | } |
| 2458 | } |
| 2459 | } |
| 2460 | |
| 2461 | char aVersion[32]; |
| 2462 | str_format(aVersion, sizeof(aVersion), "0.7↔%s", GameServer()->Version()); |
| 2463 | Packer.AddString(aVersion, 32); |
| 2464 | if(!SendClients || ClientCountAll == ClientCount) |
| 2465 | { |
| 2466 | Packer.AddString(Config()->m_SvName, 64); |
| 2467 | } |
| 2468 | else |
| 2469 | { |
| 2470 | char aName[64]; |
| 2471 | str_format(aName, sizeof(aName), "%s [%d/%d]", Config()->m_SvName, ClientCountAll, m_NetServer.MaxClients() - Config()->m_SvReservedSlots); |
| 2472 | Packer.AddString(aName, 64); |
| 2473 | } |
| 2474 | Packer.AddString(Config()->m_SvHostname, 128); |
| 2475 | Packer.AddString(GameServer()->Map()->BaseName(), 32); |
| 2476 | |
| 2477 | // gametype |
| 2478 | Packer.AddString(GameServer()->GameType(), 16); |
| 2479 | |
| 2480 | // flags |
| 2481 | int Flags = SERVER_FLAG_TIMESCORE; |
| 2482 | if(Config()->m_Password[0]) // password set |
| 2483 | Flags |= SERVER_FLAG_PASSWORD; |
| 2484 | Packer.AddInt(Flags); |
| 2485 | |
| 2486 | int MaxClients = m_NetServer.MaxClients(); |
| 2487 | Packer.AddInt(Config()->m_SvSkillLevel); // server skill level |
| 2488 | Packer.AddInt(PlayerCount); // num players |
| 2489 | Packer.AddInt(maximum(MaxClients - maximum(Config()->m_SvSpectatorSlots, Config()->m_SvReservedSlots), PlayerCount)); // max players |
| 2490 | Packer.AddInt(ClientCount); // num clients |
| 2491 | Packer.AddInt(maximum(MaxClients - Config()->m_SvReservedSlots, ClientCount)); // max clients |
| 2492 | |
| 2493 | if(SendClients) |
nothing calls this directly
no test coverage detected