Skip to content

Commit

Permalink
Add the ability to force map sides when skipping plugin veto.
Browse files Browse the repository at this point in the history
  • Loading branch information
splewis committed Jun 14, 2016
1 parent 2be5326 commit ca761d6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
46 changes: 39 additions & 7 deletions scripting/get5/matchconfig.sp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ stock bool LoadMatchConfig(const char[] config, bool restoreBackup=false) {
g_MapPoolList.GetString(i, mapName, sizeof(mapName));
g_MapsToPlay.PushString(mapName);

if (g_MatchSideType == MatchSideType_Standard) {
g_MapSides.Push(SideChoice_KnifeRound);
} else if (g_MatchSideType == MatchSideType_AlwaysKnife) {
g_MapSides.Push(SideChoice_KnifeRound);
} else if (g_MatchSideType == MatchSideType_NeverKnife) {
g_MapSides.Push(SideChoice_Team1CT);
// Push a map side if one hasn't been set yet.
if (g_MapSides.Length < g_MapsToPlay.Length) {
if (g_MatchSideType == MatchSideType_Standard) {
g_MapSides.Push(SideChoice_KnifeRound);
} else if (g_MatchSideType == MatchSideType_AlwaysKnife) {
g_MapSides.Push(SideChoice_KnifeRound);
} else if (g_MatchSideType == MatchSideType_NeverKnife) {
g_MapSides.Push(SideChoice_Team1CT);
}
}
}

Expand Down Expand Up @@ -254,7 +257,6 @@ public void WriteMatchToKv(KeyValues kv) {
kv.SetString(map, "x");
}
kv.GoBack();
// TODO: this should also put the maplist in

kv.JumpToKey("team1", true);
AddTeamBackupData(kv, MatchTeam_Team1);
Expand Down Expand Up @@ -335,6 +337,20 @@ static bool LoadMatchFromKv(KeyValues kv) {
LoadDefaultMapList(g_MapPoolList);
}

if (g_SkipVeto) {
if (kv.JumpToKey("map_sides")) {
if (kv.GotoFirstSubKey(false)) {
do {
char buffer[64];
kv.GetSectionName(buffer, sizeof(buffer));
g_MapSides.Push(SideTypeFromString(buffer));
} while (kv.GotoNextKey(false));
kv.GoBack();
}
kv.GoBack();
}
}

if (kv.JumpToKey("cvars")) {
if (kv.GotoFirstSubKey(false)) {
char name[MAX_CVAR_LENGTH];
Expand Down Expand Up @@ -401,6 +417,18 @@ static bool LoadMatchFromJson(Handle json) {
LoadDefaultMapList(g_MapPoolList);
}

if (g_SkipVeto) {
Handle array = json_object_get(json, "map_sides");
if (array != INVALID_HANDLE) {
for (int i = 0; i < json_array_size(array); i++) {
char buffer[64];
json_array_get_string(array, i, buffer, sizeof(buffer));
g_MapSides.Push(SideTypeFromString(buffer));
}
CloseHandle(array);
}
}

Handle cvars = json_object_get(json, "cvars");
if (cvars != INVALID_HANDLE) {
char cvarName[MAX_CVAR_LENGTH];
Expand Down Expand Up @@ -876,3 +904,7 @@ public void CheckTeamNameStatus(MatchTeam team) {
colorTag, g_TeamNames[team]);
}
}

public void ReadTeamSides() {

}
17 changes: 17 additions & 0 deletions scripting/get5/util.sp
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,20 @@ stock bool HelpfulAttack(int attacker, int victim) {
int vteam = GetClientTeam(victim); // Get the victim's team
return ateam != vteam && attacker != victim;
}

stock SideChoice SideTypeFromString(const char[] input) {
if (StrEqual(input, "team1_ct", false)) {
return SideChoice_Team1CT;
} else if (StrEqual(input, "team1_t", false)) {
return SideChoice_Team1T;
} else if (StrEqual(input, "team2_ct", false)) {
return SideChoice_Team1T;
} else if (StrEqual(input, "team2_t", false)) {
return SideChoice_Team1CT;
} else if (StrEqual(input, "knife", false)) {
return SideChoice_KnifeRound;
} else {
LogError("Invalid side choice \"%s\", falling back to knife round", input);
return SideChoice_KnifeRound;
}
}

0 comments on commit ca761d6

Please sign in to comment.