-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add mappool #415
base: master
Are you sure you want to change the base?
Add mappool #415
Changes from 4 commits
f849747
395a1d8
6eba6b9
c4487c6
5ef9afb
ad95ffb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// add all maps on the server here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// add competitive maps here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// add fun maps for casual games here |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,53 @@ | ||
#define RANDOM_MAP_VOTE "-1" // must be in invalid index for array indexing | ||
|
||
char mapGroups[][] = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", "all.txt" | ||
}; | ||
|
||
/** | ||
* Map voting functions | ||
*/ | ||
public void CreateMapVote() { | ||
StartMapVote2(); | ||
} | ||
static void StartMapVote2() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a poor name for this function. Can you use a more descriptive name? |
||
Menu menu = new Menu(MapVoteHandler2); | ||
menu.SetTitle("%T", "VoteMenuTitle", LANG_SERVER); | ||
menu.ExitButton = false; | ||
for (int i = 0; i < sizeof(mapGroups); i++) { | ||
char text[64], id[4]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this use the |
||
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 MapVoteHandler2(Menu menu, MenuAction action, int param1, int param2) { | ||
if (action == MenuAction_VoteEnd) { | ||
int winner = GetMenuInt(menu, param1); | ||
|
||
ServerCommand("sm_pugsetup_maplist %s", mapGroups[winner]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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[64]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
Format(text, 64, mapGroups[winner]); | ||
ReplaceString(text, 64, ".txt", "", false); | ||
|
||
PrintCenterTextAll("Winner is %s", text); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This text should use a translation string. |
||
|
||
CreateTimer(0.5, Timer_Continue, _, TIMER_FLAG_NO_MAPCHANGE); | ||
|
||
} else if (action == MenuAction_End) { | ||
CloseHandle(menu); | ||
} | ||
return 0; | ||
} | ||
public Action Timer_Continue(Handle timer) | ||
{ | ||
CreateMapVote2(); | ||
return Plugin_Handled; | ||
} | ||
public void CreateMapVote2() { | ||
if (g_ExcludedMaps.IntValue > 0 && g_MapList.Length > g_PastMaps.Length) { | ||
SetupMapVotePool(true); | ||
} else { | ||
|
@@ -22,6 +66,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; | ||
|
@@ -39,6 +84,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); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ public int Native_SetupGame(Handle plugin, int numParams) { | |
} | ||
|
||
SetupFinished(); | ||
return 1; | ||
} | ||
|
||
public int Native_GetSetupOptions(Handle plugin, int numParams) { | ||
|
@@ -88,6 +89,7 @@ public int Native_GetSetupOptions(Handle plugin, int numParams) { | |
SetNativeCellRef(4, g_RecordGameOption); | ||
SetNativeCellRef(5, g_DoKnifeRound); | ||
SetNativeCellRef(6, g_AutoLive); | ||
return 1; | ||
} | ||
|
||
public int Native_SetSetupOptions(Handle plugin, int numParams) { | ||
|
@@ -97,6 +99,7 @@ public int Native_SetSetupOptions(Handle plugin, int numParams) { | |
g_RecordGameOption = GetNativeCell(4); | ||
g_DoKnifeRound = GetNativeCell(5); | ||
g_AutoLive = GetNativeCell(6); | ||
return 1; | ||
} | ||
|
||
public int Native_ReadyPlayer(Handle plugin, int numParams) { | ||
|
@@ -218,6 +221,7 @@ public int Native_SetLeader(Handle plugin, int numParams) { | |
PugSetup_MessageToAll("%t", "NewLeader", client); | ||
g_Leader = client; | ||
} | ||
return 1; | ||
} | ||
|
||
public int Native_GetLeader(Handle plugin, int numParams) { | ||
|
@@ -277,6 +281,7 @@ public int Native_SetCaptain(Handle plugin, int numParams) { | |
PugSetup_MessageToAll("%t", "CaptMessage", captainNumber, buffer); | ||
} | ||
} | ||
return 1; | ||
} | ||
|
||
public int Native_GetCaptain(Handle plugin, int numParams) { | ||
|
@@ -294,7 +299,7 @@ public int Native_GetCaptain(Handle plugin, int numParams) { | |
public int Native_Message(Handle plugin, int numParams) { | ||
int client = GetNativeCell(1); | ||
if (client != 0 && (!IsClientConnected(client) || !IsClientInGame(client))) | ||
return; | ||
return 0; | ||
|
||
char buffer[1024]; | ||
int bytesWritten = 0; | ||
|
@@ -317,6 +322,7 @@ public int Native_Message(Handle plugin, int numParams) { | |
Colorize(finalMsg, sizeof(finalMsg)); | ||
PrintToChat(client, finalMsg); | ||
} | ||
return 1; | ||
} | ||
|
||
public int Native_MessageToAll(Handle plugin, int numParams) { | ||
|
@@ -346,6 +352,7 @@ public int Native_MessageToAll(Handle plugin, int numParams) { | |
PrintToConsole(i, finalMsg); | ||
} | ||
} | ||
return 1; | ||
} | ||
|
||
public int Native_GetPugMaxPlayers(Handle plugin, int numParams) { | ||
|
@@ -397,7 +404,7 @@ public int Native_HasPermissions(Handle plugin, int numParams) { | |
return isAdmin; | ||
else if (p == Permission_Leader) | ||
return isLeader || isAdmin; | ||
else if (p == Permission_Captains) | ||
else if (p == Permission_Captains && UsingCaptains()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change seems potentially problematic. If a permission has |
||
return isCapt || isLeader || isAdmin; | ||
else if (p == Permission_All) | ||
return true; | ||
|
@@ -426,6 +433,8 @@ public int Native_SetRandomCaptains(Handle plugin, int numParams) { | |
|
||
if (IsPlayer(c2)) | ||
PugSetup_SetCaptain(2, c2, true); | ||
|
||
return 1; | ||
} | ||
|
||
public int Native_AddChatAlias(Handle plugin, int numParams) { | ||
|
@@ -445,6 +454,7 @@ public int Native_AddChatAlias(Handle plugin, int numParams) { | |
g_ChatAliasesCommands.PushString(command); | ||
g_ChatAliasesModes.Push(mode); | ||
} | ||
return 1; | ||
} | ||
|
||
public int Native_GiveSetupMenu(Handle plugin, int numParams) { | ||
|
@@ -459,12 +469,14 @@ public int Native_GiveSetupMenu(Handle plugin, int numParams) { | |
} | ||
|
||
SetupMenu(client, displayOnly, menuPosition); | ||
return 1; | ||
} | ||
|
||
public int Native_GiveMapChangeMenu(Handle plugin, int numParams) { | ||
int client = GetNativeCell(1); | ||
CHECK_CLIENT(client); | ||
ChangeMapMenu(client); | ||
return 1; | ||
} | ||
|
||
public int Native_IsValidCommand(Handle plugin, int numParams) { | ||
|
@@ -501,7 +513,19 @@ public int Native_SetTeamBalancer(Handle plugin, int numParams) { | |
bool override = GetNativeCell(2); | ||
if (!PugSetup_IsTeamBalancerAvaliable() || override) { | ||
g_BalancerFunctionPlugin = plugin; | ||
//ArrayList players = new ArrayList(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be removed. |
||
g_BalancerFunction = view_as<TeamBalancerFunction>(GetNativeFunction(1)); | ||
for (int i = 1; i <= MaxClients; i++) { | ||
if (IsPlayer(i)) { | ||
if (PugSetup_IsReady(i)) | ||
players.Push(i); | ||
} | ||
} | ||
Call_StartFunction(g_BalancerFunctionPlugin, g_BalancerFunction); | ||
Call_PushCell(players); | ||
Call_Finish(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this changing? It seems incorrect to invoke this function since the native could be called far before the match is ready. |
||
delete players; | ||
|
||
return true; | ||
} | ||
return false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will break the automated compilation test since this file won't be available: https://github.com/splewis/csgo-pug-setup/blob/master/.travis.yml
I would revert this, unless there's a reliable location to get the include from (i.e., undo ca76885)