| 2622 | } |
| 2623 | |
| 2624 | void CServer::UpdateRegisterServerInfo() |
| 2625 | { |
| 2626 | // count the players |
| 2627 | int PlayerCount = 0, ClientCount = 0; |
| 2628 | for(int i = 0; i < MAX_CLIENTS; i++) |
| 2629 | { |
| 2630 | if(m_aClients[i].IncludedInServerInfo()) |
| 2631 | { |
| 2632 | if(GameServer()->IsClientPlayer(i)) |
| 2633 | PlayerCount++; |
| 2634 | |
| 2635 | ClientCount++; |
| 2636 | } |
| 2637 | } |
| 2638 | |
| 2639 | int MaxPlayers = maximum(m_NetServer.MaxClients() - maximum(g_Config.m_SvSpectatorSlots, g_Config.m_SvReservedSlots), PlayerCount); |
| 2640 | int MaxClients = maximum(m_NetServer.MaxClients() - g_Config.m_SvReservedSlots, ClientCount); |
| 2641 | char aMapSha256[SHA256_MAXSTRSIZE]; |
| 2642 | |
| 2643 | sha256_str(m_aCurrentMapSha256[MAP_TYPE_SIX], aMapSha256, sizeof(aMapSha256)); |
| 2644 | |
| 2645 | CJsonStringWriter JsonWriter; |
| 2646 | |
| 2647 | JsonWriter.BeginObject(); |
| 2648 | JsonWriter.WriteAttribute("max_clients"); |
| 2649 | JsonWriter.WriteIntValue(MaxClients); |
| 2650 | |
| 2651 | JsonWriter.WriteAttribute("max_players"); |
| 2652 | JsonWriter.WriteIntValue(MaxPlayers); |
| 2653 | |
| 2654 | JsonWriter.WriteAttribute("passworded"); |
| 2655 | JsonWriter.WriteBoolValue(g_Config.m_Password[0]); |
| 2656 | |
| 2657 | JsonWriter.WriteAttribute("game_type"); |
| 2658 | JsonWriter.WriteStrValue(GameServer()->GameType()); |
| 2659 | |
| 2660 | if(g_Config.m_SvRegisterCommunityToken[0]) |
| 2661 | { |
| 2662 | if(g_Config.m_SvFlag != -1) |
| 2663 | { |
| 2664 | JsonWriter.WriteAttribute("country"); |
| 2665 | JsonWriter.WriteIntValue(g_Config.m_SvFlag); // ISO 3166-1 numeric |
| 2666 | } |
| 2667 | } |
| 2668 | |
| 2669 | JsonWriter.WriteAttribute("name"); |
| 2670 | JsonWriter.WriteStrValue(g_Config.m_SvName); |
| 2671 | |
| 2672 | JsonWriter.WriteAttribute("map"); |
| 2673 | JsonWriter.BeginObject(); |
| 2674 | JsonWriter.WriteAttribute("name"); |
| 2675 | JsonWriter.WriteStrValue(GameServer()->Map()->BaseName()); |
| 2676 | JsonWriter.WriteAttribute("sha256"); |
| 2677 | JsonWriter.WriteStrValue(aMapSha256); |
| 2678 | JsonWriter.WriteAttribute("size"); |
| 2679 | JsonWriter.WriteIntValue(m_aCurrentMapSize[MAP_TYPE_SIX]); |
| 2680 | if(m_aMapDownloadUrl[0]) |
| 2681 | { |
nothing calls this directly
no test coverage detected