adds maps to the casualpool from the playtime frontend based on best average population gains on maps
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
#include <sdktools>
|
||||
#include <cstrike>
|
||||
#include <multicolors>
|
||||
#include <ripext>
|
||||
#include <nominations_extended>
|
||||
#include <rockthevote_extended>
|
||||
#include <leader>
|
||||
@@ -120,6 +121,8 @@ Handle g_VoteTimer = INVALID_HANDLE;
|
||||
Handle g_RetryTimer = INVALID_HANDLE;
|
||||
Handle g_WarningTimer = INVALID_HANDLE;
|
||||
|
||||
Handle g_hTopImpactMaps = INVALID_HANDLE;
|
||||
|
||||
/* Data Handles */
|
||||
Handle g_MapList = INVALID_HANDLE;
|
||||
Handle g_NominateList[MAXPLAYERS + 1];
|
||||
@@ -137,6 +140,7 @@ bool g_WaitingForVote;
|
||||
bool g_MapVoteCompleted;
|
||||
bool g_ChangeMapInProgress;
|
||||
bool g_HasIntermissionStarted = false;
|
||||
bool g_bCasualPoolFromImpactPlayTime = true;
|
||||
|
||||
int g_iNextmapState = 0; //0 = nothing. 1 = rtv succesfull. 2 = admin used setnextmap. 3 = did not extend or used all extends.
|
||||
int g_mapFileSerial = -1;
|
||||
@@ -254,6 +258,7 @@ public void OnPluginStart()
|
||||
g_CooldownList = new StringMap();
|
||||
g_NextMapList = CreateArray(arraySize);
|
||||
g_OfficialList = CreateArray(arraySize);
|
||||
g_hTopImpactMaps = CreateArray(arraySize);
|
||||
|
||||
for (int i = 0; i <= MaxClients; i++)
|
||||
{
|
||||
@@ -284,10 +289,15 @@ public void OnPluginStart()
|
||||
|
||||
|
||||
ConVar cvar2;
|
||||
HookConVarChange((cvar2 = CreateConVar("mce_randomized_maps_from_casual_pool", "2", "f we have space left over for randomized maps at the mapvote. how many should be prioritized from the casual pool?")), Cvar_mapsFromCasualPool);
|
||||
HookConVarChange((cvar2 = CreateConVar("mce_randomized_maps_from_casual_pool", "2", "do we have space left over for randomized maps at the mapvote. how many should be prioritized from the casual pool?")), Cvar_mapsFromCasualPool);
|
||||
g_iMapsFromCasualPool = cvar2.IntValue;
|
||||
delete cvar2;
|
||||
|
||||
ConVar cvar2_;
|
||||
HookConVarChange((cvar2_ = CreateConVar("mce_casual_pool_impact_enabled", "1", "Do we fetch maps to the casual pool from the playtime frontend impact rate?")), Cvar_casual_pool_impact_enabled);
|
||||
g_bCasualPoolFromImpactPlayTime = cvar2_.BoolValue;
|
||||
delete cvar2_;
|
||||
|
||||
ConVar cvar1;
|
||||
HookConVarChange((cvar1 = CreateConVar("mce_skip_map_restrictions_player_count", "15", "Amount of players required for any restrictions are enabled.")), Cvar_playerActiveRequired);
|
||||
g_iSkipAllRestrictions = cvar1.IntValue;
|
||||
@@ -438,6 +448,11 @@ public void Cvar_mapsFromCasualPool(ConVar convar, const char[] oldValue, const
|
||||
g_iMapsFromCasualPool = convar.IntValue;
|
||||
}
|
||||
|
||||
public void Cvar_casual_pool_impact_enabled(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_bCasualPoolFromImpactPlayTime = convar.BoolValue;
|
||||
}
|
||||
|
||||
public void Cvar_playerActiveRequired(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_iSkipAllRestrictions = convar.IntValue;
|
||||
@@ -554,6 +569,47 @@ public void OnMapStart()
|
||||
return;
|
||||
}
|
||||
g_Config.Rewind();
|
||||
|
||||
char sRequest[256];
|
||||
FormatEx(sRequest, sizeof(sRequest), "https://playtime-sessions.unloze.com/api/maps/impact?sortBy=impact&direction=desc&offset=0");
|
||||
HTTPRequest hRequest = new HTTPRequest(sRequest);
|
||||
hRequest.Get(OnTransferComplete, _);
|
||||
}
|
||||
|
||||
public void OnTransferComplete(HTTPResponse response, any s)
|
||||
{
|
||||
if (response.Status != HTTPStatus_OK || response.Data == null)
|
||||
{
|
||||
LogError("Request-Error: %d", response.Status);
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject root = view_as<JSONObject>(response.Data);
|
||||
JSONArray maps = view_as<JSONArray>(root.Get("maps"));
|
||||
|
||||
if (maps == null)
|
||||
{
|
||||
delete root;
|
||||
return;
|
||||
}
|
||||
ClearArray(g_hTopImpactMaps);
|
||||
|
||||
int count = maps.Length;
|
||||
char mapName[PLATFORM_MAX_PATH];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
JSONObject entry = view_as<JSONObject>(maps.Get(i));
|
||||
if (entry == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entry.GetString("map_name", mapName, sizeof(mapName));
|
||||
PushArrayString(g_hTopImpactMaps, mapName);
|
||||
delete entry;
|
||||
}
|
||||
|
||||
delete root;
|
||||
delete maps;
|
||||
}
|
||||
|
||||
public void OnConfigsExecuted()
|
||||
@@ -3424,6 +3480,11 @@ stock int FindIntInArray(int[] array, int size, int value)
|
||||
return -1;
|
||||
}
|
||||
|
||||
stock bool IsMapInTopImpactList(const char[] map)
|
||||
{
|
||||
return g_hTopImpactMaps != INVALID_HANDLE && FindStringInArray(g_hTopImpactMaps, map) != -1;
|
||||
}
|
||||
|
||||
stock bool InternalGetCasualPool(const char[] map)
|
||||
{
|
||||
int CasualPool = 0;
|
||||
@@ -3433,6 +3494,11 @@ stock bool InternalGetCasualPool(const char[] map)
|
||||
g_Config.Rewind();
|
||||
}
|
||||
|
||||
if (g_bCasualPoolFromImpactPlayTime && IsMapInTopImpactList(map))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return view_as<bool>(CasualPool);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user