furhter updates for the casuapool in regards to the new playtime frontned updates
This commit is contained in:
@@ -149,8 +149,11 @@ int g_iDontCooldownMap;
|
|||||||
int g_iImpactMapsToCasualPool;
|
int g_iImpactMapsToCasualPool;
|
||||||
int g_iMapsFromCasualPool;
|
int g_iMapsFromCasualPool;
|
||||||
int g_iImpactExtraCooldownTime;
|
int g_iImpactExtraCooldownTime;
|
||||||
|
int g_iImpactExtraCooldownMaxHours;
|
||||||
|
int g_iImpactSeed;
|
||||||
|
|
||||||
float g_avg_net_change;
|
//"penalty" from the playtime frontend: max(0, -impact_score) * P(effect < 0). 0 for maps that do not hurt population.
|
||||||
|
float g_fImpactPenalty;
|
||||||
|
|
||||||
int g_iInterval;
|
int g_iInterval;
|
||||||
char player_mapvote[MAXPLAYERS + 1][PLATFORM_MAX_PATH];
|
char player_mapvote[MAXPLAYERS + 1][PLATFORM_MAX_PATH];
|
||||||
@@ -303,10 +306,15 @@ public void OnPluginStart()
|
|||||||
delete cvar2_;
|
delete cvar2_;
|
||||||
|
|
||||||
ConVar cvar2_1;
|
ConVar cvar2_1;
|
||||||
HookConVarChange((cvar2_1 = CreateConVar("mce_impact_extra_cooldown_addition", "100", "How much additional cooldowntime do we apply for negative impact rate. 0 disables the feature.")), Cvar_impact_extra_cooldown);
|
HookConVarChange((cvar2_1 = CreateConVar("mce_impact_extra_cooldown_addition", "100", "Extra cooldown hours per point of impact penalty from the playtime frontend. 0 disables the feature.")), Cvar_impact_extra_cooldown);
|
||||||
g_iImpactExtraCooldownTime = cvar2_1.IntValue;
|
g_iImpactExtraCooldownTime = cvar2_1.IntValue;
|
||||||
delete cvar2_1;
|
delete cvar2_1;
|
||||||
|
|
||||||
|
ConVar cvar2_2;
|
||||||
|
HookConVarChange((cvar2_2 = CreateConVar("mce_impact_extra_cooldown_max_hours", "240", "Maximum extra cooldown hours from the impact penalty. 0 = no cap.")), Cvar_impact_extra_cooldown_max);
|
||||||
|
g_iImpactExtraCooldownMaxHours = cvar2_2.IntValue;
|
||||||
|
delete cvar2_2;
|
||||||
|
|
||||||
ConVar cvar1;
|
ConVar cvar1;
|
||||||
HookConVarChange((cvar1 = CreateConVar("mce_skip_map_restrictions_player_count", "10", "Amount of players required for any restrictions are enabled.")), Cvar_playerActiveRequired);
|
HookConVarChange((cvar1 = CreateConVar("mce_skip_map_restrictions_player_count", "10", "Amount of players required for any restrictions are enabled.")), Cvar_playerActiveRequired);
|
||||||
g_iSkipAllRestrictions = cvar1.IntValue;
|
g_iSkipAllRestrictions = cvar1.IntValue;
|
||||||
@@ -468,6 +476,11 @@ public void Cvar_impact_extra_cooldown(ConVar convar, const char[] oldValue, con
|
|||||||
g_iImpactExtraCooldownTime = convar.IntValue;
|
g_iImpactExtraCooldownTime = convar.IntValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Cvar_impact_extra_cooldown_max(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||||
|
{
|
||||||
|
g_iImpactExtraCooldownMaxHours = convar.IntValue;
|
||||||
|
}
|
||||||
|
|
||||||
public void Cvar_casual_pool_impact_enabled(ConVar convar, const char[] oldValue, const char[] newValue)
|
public void Cvar_casual_pool_impact_enabled(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||||
{
|
{
|
||||||
g_bCasualPoolFromImpactPlayTime = convar.BoolValue;
|
g_bCasualPoolFromImpactPlayTime = convar.BoolValue;
|
||||||
@@ -596,11 +609,16 @@ public void OnMapStart()
|
|||||||
}
|
}
|
||||||
g_Config.Rewind();
|
g_Config.Rewind();
|
||||||
ClearArray(g_hTopImpactMaps);
|
ClearArray(g_hTopImpactMaps);
|
||||||
FillMapsByImpact(0);
|
//new Thompson-sampling draw every map: proven maps show up reliably, uncertain maps still get a chance.
|
||||||
|
//the frontend picks the seed from the map that is running (its map_id), so the website shows the same list.
|
||||||
|
//we wait a bit so the playtime plugin has written this map into the map history first.
|
||||||
|
//-1 = let the frontend choose, the seed it returns on the first page is used for all following pages.
|
||||||
|
g_iImpactSeed = -1;
|
||||||
|
CreateTimer(15.0, Timer_FillMapsByImpact, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||||
|
|
||||||
char currentmap[256];
|
char currentmap[256];
|
||||||
GetCurrentMap(currentmap, PLATFORM_MAX_PATH);
|
GetCurrentMap(currentmap, PLATFORM_MAX_PATH);
|
||||||
g_avg_net_change = 0.0;
|
g_fImpactPenalty = 0.0;
|
||||||
GetMapsImpact(currentmap);
|
GetMapsImpact(currentmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,10 +630,23 @@ public void GetMapsImpact(char[] currentmap)
|
|||||||
hRequest.Get(OnTransferComplete1, _);
|
hRequest.Get(OnTransferComplete1, _);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action Timer_FillMapsByImpact(Handle timer)
|
||||||
|
{
|
||||||
|
FillMapsByImpact(0);
|
||||||
|
return Plugin_Stop;
|
||||||
|
}
|
||||||
|
|
||||||
public void FillMapsByImpact(int offset)
|
public void FillMapsByImpact(int offset)
|
||||||
{
|
{
|
||||||
char sRequest[256];
|
char sRequest[256];
|
||||||
FormatEx(sRequest, sizeof(sRequest), "https://playtime-sessions.unloze.com/api/maps/impact?sortBy=impact&direction=desc&offset=%i", offset);
|
if (g_iImpactSeed < 0)
|
||||||
|
{
|
||||||
|
FormatEx(sRequest, sizeof(sRequest), "https://playtime-sessions.unloze.com/api/maps/impact?sortBy=thompson&direction=desc&offset=%i", offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FormatEx(sRequest, sizeof(sRequest), "https://playtime-sessions.unloze.com/api/maps/impact?sortBy=thompson&direction=desc&seed=%i&offset=%i", g_iImpactSeed, offset);
|
||||||
|
}
|
||||||
HTTPRequest hRequest = new HTTPRequest(sRequest);
|
HTTPRequest hRequest = new HTTPRequest(sRequest);
|
||||||
hRequest.Get(OnTransferComplete, offset);
|
hRequest.Get(OnTransferComplete, offset);
|
||||||
}
|
}
|
||||||
@@ -636,6 +667,11 @@ public void OnTransferComplete(HTTPResponse response, int offset)
|
|||||||
delete root;
|
delete root;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool hasMore = root.GetBool("hasMore");
|
||||||
|
if (g_iImpactSeed < 0 && root.HasKey("seed"))
|
||||||
|
{
|
||||||
|
g_iImpactSeed = root.GetInt("seed"); //keep paging through the same draw
|
||||||
|
}
|
||||||
|
|
||||||
Handle tempMaps = CloneArray(g_MapList);
|
Handle tempMaps = CloneArray(g_MapList);
|
||||||
|
|
||||||
@@ -672,7 +708,8 @@ public void OnTransferComplete(HTTPResponse response, int offset)
|
|||||||
delete root;
|
delete root;
|
||||||
delete maps;
|
delete maps;
|
||||||
|
|
||||||
if (GetArraySize(g_hTopImpactMaps) < g_iImpactMapsToCasualPool)
|
//pages are always 50 results. stop when the frontend says there are no more, otherwise this would request forever.
|
||||||
|
if (GetArraySize(g_hTopImpactMaps) < g_iImpactMapsToCasualPool && hasMore)
|
||||||
{
|
{
|
||||||
FillMapsByImpact(offset + 50); //did not get enough maps from the public maplist, set offset to pick the next.
|
FillMapsByImpact(offset + 50); //did not get enough maps from the public maplist, set offset to pick the next.
|
||||||
}
|
}
|
||||||
@@ -697,7 +734,7 @@ public void OnTransferComplete1(HTTPResponse response, any i)
|
|||||||
JSONObject entry = view_as<JSONObject>(maps.Get(0));
|
JSONObject entry = view_as<JSONObject>(maps.Get(0));
|
||||||
if (entry != null)
|
if (entry != null)
|
||||||
{
|
{
|
||||||
g_avg_net_change = entry.GetFloat("avg_net_change");
|
g_fImpactPenalty = entry.GetFloat("penalty");
|
||||||
}
|
}
|
||||||
delete entry;
|
delete entry;
|
||||||
delete root;
|
delete root;
|
||||||
@@ -3350,11 +3387,15 @@ public int additionalCooldownHoursCurrentMap()
|
|||||||
{
|
{
|
||||||
int Cooldown = 0;
|
int Cooldown = 0;
|
||||||
//0 == g_iImpactExtraCooldownTime means feature was disabled, so not adding any extra cooldown hours.
|
//0 == g_iImpactExtraCooldownTime means feature was disabled, so not adding any extra cooldown hours.
|
||||||
// g_avg_net_change < 0 means the map on average has a negative impact on player population
|
//g_fImpactPenalty > 0 means the frontend is fairly confident the map loses players compared to what the
|
||||||
if (g_avg_net_change < 0 && g_iImpactExtraCooldownTime > 0)
|
//server normally does at that time and population. It is already scaled by that confidence.
|
||||||
|
if (g_fImpactPenalty > 0.0 && g_iImpactExtraCooldownTime > 0)
|
||||||
{
|
{
|
||||||
//map has a negative impact on population and should be punished by additioanl g_iImpactExtraCooldownTime hours.
|
int extraCooldownHours = RoundToFloor(g_fImpactPenalty * g_iImpactExtraCooldownTime);
|
||||||
int extraCooldownHours = RoundToFloor((g_avg_net_change * -1) * g_iImpactExtraCooldownTime);
|
if (g_iImpactExtraCooldownMaxHours > 0 && extraCooldownHours > g_iImpactExtraCooldownMaxHours)
|
||||||
|
{
|
||||||
|
extraCooldownHours = g_iImpactExtraCooldownMaxHours;
|
||||||
|
}
|
||||||
Cooldown += extraCooldownHours * 60 * 60; //Hours -> minutes -> seconds
|
Cooldown += extraCooldownHours * 60 * 60; //Hours -> minutes -> seconds
|
||||||
}
|
}
|
||||||
return Cooldown;
|
return Cooldown;
|
||||||
|
|||||||
Reference in New Issue
Block a user