Skip to content

Commit

Permalink
Merge branch 'main' into buttonwatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Vauff authored Dec 5, 2024
2 parents 87b605c + 85af0af commit f7324c6
Show file tree
Hide file tree
Showing 9 changed files with 438 additions and 159 deletions.
2 changes: 1 addition & 1 deletion cfg/cs2fixes/cs2fixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cs2f_rtv_success_ratio 0.6 // Ratio needed to pass RTV
cs2f_rtv_endround 0 // Whether to immediately end the round when RTV succeeds

// Map vote settings
cs2f_vote_maps_cooldown 10 // Number of maps to wait until a map can be voted / nominated again i.e. cooldown.
cs2f_vote_maps_cooldown 10 // Default number of maps to wait until a map can be voted / nominated again i.e. cooldown.
cs2f_vote_max_nominations 10 // Number of nominations to include per vote, out of a maximum of 10.

// User preferences settings
Expand Down
7 changes: 7 additions & 0 deletions configs/maplist.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@
{
"workshop_id" "123"
"enabled" "1"
"min_players" "30"
"cooldown" "2"
}
"ze_my_second_ze_map"
{
"workshop_id" "456"
"enabled" "1"
"min_players" "5"
"max_players" "10"
"cooldown" "3"
}
"ze_my_third_ze_map"
{
"workshop_id" "789"
"enabled" "1"
"max_players" "20"
"cooldown" "1"
}
}
23 changes: 17 additions & 6 deletions src/adminsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ CON_COMMAND_CHAT_FLAGS(map, "<mapname> - Change map", ADMFLAG_CHANGEMAP)
for (int i = 0; sMapName[i]; i++)
{
// Injection prevention, because we may pass user input to ServerCommand
if (sMapName[i] == ';')
if (sMapName[i] == ';' || sMapName[i] == '|')
return;

sMapName[i] = tolower(sMapName[i]);
Expand All @@ -602,16 +602,27 @@ CON_COMMAND_CHAT_FLAGS(map, "<mapname> - Change map", ADMFLAG_CHANGEMAP)
if (!g_pEngineServer2->IsMapValid(pszMapName))
{
std::string sCommand;
std::vector<int> foundIndexes = g_pMapVoteSystem->GetMapIndexesFromSubstring(pszMapName);

// Check if input is numeric (workshop ID)
// Not safe to expose until crashing on failed workshop addon downloads is fixed
/*if (V_StringToUint64(pszMapName, 0) != 0)
// Not safe to expose to all admins until crashing on failed workshop addon downloads is fixed
if ((!player || player->GetZEPlayer()->IsAdminFlagSet(ADMFLAG_RCON)) && V_StringToUint64(pszMapName, 0) != 0)
{
sCommand = "host_workshop_map " + sMapName;
}*/
if (g_bVoteManagerEnable && g_pMapVoteSystem->GetMapIndexFromSubstring(pszMapName) != -1)
}
else if (g_bVoteManagerEnable && foundIndexes.size() > 0)
{
sCommand = "host_workshop_map " + std::to_string(g_pMapVoteSystem->GetMapWorkshopId(g_pMapVoteSystem->GetMapIndexFromSubstring(pszMapName)));
if (foundIndexes.size() > 1)
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Multiple maps matched \x06%s\x01, try being more specific:", pszMapName);

for (int i = 0; i < foundIndexes.size() && i < 5; i++)
ClientPrint(player, HUD_PRINTTALK, "- %s", g_pMapVoteSystem->GetMapName(foundIndexes[i]));

return;
}

sCommand = "host_workshop_map " + std::to_string(g_pMapVoteSystem->GetMapWorkshopId(foundIndexes[0]));
}
else
{
Expand Down
17 changes: 1 addition & 16 deletions src/leader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,6 @@ FAKE_INT_CVAR(cs2f_leader_max_glows, "Max amount of glows set by leaders (doesn'
FAKE_INT_CVAR(cs2f_leader_max_tracers, "Max amount of tracers set by leaders (doesn't impact admins)", g_iMaxTracers, 3, false)
FAKE_INT_CVAR(cs2f_leader_max_beacons, "Max amount of beacons set by leaders (doesn't impact admins)", g_iMaxBeacons, 3, false)

int Leader_GetNeededLeaderVoteCount()
{
int iOnlinePlayers = 0;

for (int i = 0; i < gpGlobals->maxClients; i++)
{
ZEPlayer* pPlayer = g_playerManager->GetPlayer(i);

if (pPlayer && !pPlayer->IsFakeClient())
iOnlinePlayers++;
}

return (int)(iOnlinePlayers * g_flLeaderVoteRatio) + 1;
}

bool Leader_SetNewLeader(ZEPlayer* zpLeader, std::string strColor = "")
{
CCSPlayerController* pLeader = CCSPlayerController::FromSlot(zpLeader->GetPlayerSlot());
Expand Down Expand Up @@ -587,7 +572,7 @@ CON_COMMAND_CHAT(vl, "<name> - Vote for a player to become a leader")
}

int iLeaderVoteCount = pPlayerTarget->GetLeaderVoteCount();
int iNeededLeaderVoteCount = Leader_GetNeededLeaderVoteCount();
int iNeededLeaderVoteCount = (int)(g_playerManager->GetOnlinePlayerCount(false) * g_flLeaderVoteRatio) + 1;;

pPlayer->SetLeaderVoteTime(gpGlobals->curtime);

Expand Down
Loading

0 comments on commit f7324c6

Please sign in to comment.