Skip to content

Add mappool #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cfg/sourcemod/pugsetup/all.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// add all maps on the server here
1 change: 1 addition & 0 deletions cfg/sourcemod/pugsetup/competitive.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// add competitive maps here
1 change: 1 addition & 0 deletions cfg/sourcemod/pugsetup/fun.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// add fun maps for casual games here
4 changes: 2 additions & 2 deletions scripting/pugsetup.sp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public void OnPluginStart() {
"sm_pugsetup_force_defaults", "0",
"Whether the default setup options are forced as the setup options (note that admins can override them still).");
g_InstantRunoffVotingCvar = CreateConVar(
"sm_pugsetup_instant_runoff_voting", "1",
"sm_pugsetup_instant_runoff_voting", "0",
"If set, map votes will run instant-runoff style where each client selects their top 3 maps in preference order.");
g_KnifeConfigCvar = CreateConVar(
"sm_pugsetup_knife_cfg", "sourcemod/pugsetup/knife.cfg",
Expand Down Expand Up @@ -2236,4 +2236,4 @@ stock bool PermissionFromString(const char[] permissionString, Permission& p,
}

return true;
}
}
46 changes: 46 additions & 0 deletions scripting/pugsetup/mapvote.sp
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
#define RANDOM_MAP_VOTE "-1" // must be in invalid index for array indexing

char mapGroups[][] = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned previously, I disagree with placing these in a different directory.

I also disagree with breaking backwards compatibility for existing users populating a different map config file.

"competitive.txt", "fun.txt", "maps.txt"
};

/**
* Map voting functions
*/
public void CreateMapVote() {
StartMappoolVote();
}
static void StartMappoolVote() {
Menu menu = new Menu(MappoolVoteHandler);
menu.SetTitle("%T", "VoteMenuTitle", LANG_SERVER);
menu.ExitButton = false;
for (int i = 0; i < sizeof(mapGroups); i++) {
char text[64], id[4];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this use the AddMenuInt helper function used elsewhere in the plugin?

Format(text, 64, mapGroups[i]);
Format(id, 4, "%i", i);
ReplaceString(text, 64, ".txt", "", false);
AddMenuItem(menu, id, text);
}
VoteMenuToAll(menu, g_MapVoteTimeCvar.IntValue);
}
public int MappoolVoteHandler(Menu menu, MenuAction action, int param1, int param2) {
if (action == MenuAction_VoteEnd) {
int winner = GetMenuInt(menu, param1);

ServerCommand("sm_pugsetup_maplist %s", mapGroups[winner]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make sense to override the value here. It doesn't make sense to even have the cvar if the plugin will just override it before it gets used.


char text[PLATFORM_MAX_PATH];
Format(text, 64, mapGroups[winner]);
ReplaceString(text, 64, ".txt", "", false);

PrintCenterTextAll("%t","MapVoteWinnerHintText", text);

CreateTimer(0.5, Timer_Continue, _, TIMER_FLAG_NO_MAPCHANGE);

} else if (action == MenuAction_End) {
CloseHandle(menu);
}
return 0;
}
public Action Timer_Continue(Handle timer)
{
CreateMappoolVote();
}
public void CreateMappoolVote() {
if (g_ExcludedMaps.IntValue > 0 && g_MapList.Length > g_PastMaps.Length) {
SetupMapVotePool(true);
} else {
Expand All @@ -22,6 +65,7 @@ public void CreateMapVote() {
}

static void StartMapVote() {
FillMapList(g_MapListCvar, g_MapVotePool);
Menu menu = new Menu(MapVoteHandler);
menu.SetTitle("%T", "VoteMenuTitle", LANG_SERVER);
menu.ExitButton = false;
Expand All @@ -39,6 +83,8 @@ static void StartMapVote() {
}

for (int i = 0; i < g_MapVotePool.Length; i++) {
char mapName[64];
g_MapVotePool.GetString(i, mapName, sizeof(mapName));
AddMapIndexToMenu(menu, g_MapVotePool, i);
}

Expand Down