add shavit_rankings_new_db_connection, shavit_stats_new_db_connection, and shavit_wr_new_db_connection

This commit is contained in:
rtldg 2021-10-17 04:45:37 +00:00
parent df2e9c402d
commit cb8c7e8d56
3 changed files with 11 additions and 4 deletions

View File

@ -90,6 +90,7 @@ Convar gCV_MVPRankOnes_Slow = null;
Convar gCV_MVPRankOnes = null; Convar gCV_MVPRankOnes = null;
Convar gCV_MVPRankOnes_Main = null; Convar gCV_MVPRankOnes_Main = null;
Convar gCV_DefaultTier = null; Convar gCV_DefaultTier = null;
Convar gCV_NewDBConnection = null;
ranking_t gA_Rankings[MAXPLAYERS+1]; ranking_t gA_Rankings[MAXPLAYERS+1];
@ -175,6 +176,7 @@ public void OnPluginStart()
gCV_MVPRankOnes = new Convar("shavit_rankings_mvprankones", "2", "Set the players' amount of MVPs to the amount of #1 times they have.\n0 - Disabled\n1 - Enabled, for all styles.\n2 - Enabled, for default style only.\n(CS:S/CS:GO only)", 0, true, 0.0, true, 2.0); gCV_MVPRankOnes = new Convar("shavit_rankings_mvprankones", "2", "Set the players' amount of MVPs to the amount of #1 times they have.\n0 - Disabled\n1 - Enabled, for all styles.\n2 - Enabled, for default style only.\n(CS:S/CS:GO only)", 0, true, 0.0, true, 2.0);
gCV_MVPRankOnes_Main = new Convar("shavit_rankings_mvprankones_maintrack", "1", "If set to 0, all tracks will be counted for the MVP stars.\nOtherwise, only the main track will be checked.\n\nRequires \"shavit_stats_mvprankones\" set to 1 or above.\n(CS:S/CS:GO only)", 0, true, 0.0, true, 1.0); gCV_MVPRankOnes_Main = new Convar("shavit_rankings_mvprankones_maintrack", "1", "If set to 0, all tracks will be counted for the MVP stars.\nOtherwise, only the main track will be checked.\n\nRequires \"shavit_stats_mvprankones\" set to 1 or above.\n(CS:S/CS:GO only)", 0, true, 0.0, true, 1.0);
gCV_DefaultTier = new Convar("shavit_rankings_default_tier", "1", "Sets the default tier for new maps added.", 0, true, 0.0, true, 10.0); gCV_DefaultTier = new Convar("shavit_rankings_default_tier", "1", "Sets the default tier for new maps added.", 0, true, 0.0, true, 10.0);
gCV_NewDBConnection = new Convar("shavit_rankings_new_db_connection", "0", "Use a new DB connection for rankings. This should help with point-recalculation blocking other queries from running.\nYou probably don't need to use this unless you have a DB with hundreds of thousands of player times.\n0 - Reuses shavit-core DB connection.\n1 - Creates a new DB connection.\n2 - Creates two new DB connections", 0, true, 0.0, true, 2.0);
Convar.AutoExecConfig(); Convar.AutoExecConfig();
@ -231,8 +233,8 @@ public void OnLibraryRemoved(const char[] name)
public void Shavit_OnDatabaseLoaded() public void Shavit_OnDatabaseLoaded()
{ {
GetTimerSQLPrefix(gS_MySQLPrefix, 32); GetTimerSQLPrefix(gS_MySQLPrefix, 32);
gH_SQL = GetTimerDatabaseHandle2(false); gH_SQL = (gCV_NewDBConnection.IntValue > 0) ? GetTimerDatabaseHandle2(false) : view_as<Database2>(Shavit_GetDatabase());
gH_SQL_b = true ? GetTimerDatabaseHandle2(false) : gH_SQL; gH_SQL_b = (gCV_NewDBConnection.IntValue > 1) ? GetTimerDatabaseHandle2(false) : gH_SQL;
if(!IsMySQLDatabase(gH_SQL)) if(!IsMySQLDatabase(gH_SQL))
{ {

View File

@ -71,6 +71,7 @@ stylestrings_t gS_StyleStrings[STYLE_LIMIT];
chatstrings_t gS_ChatStrings; chatstrings_t gS_ChatStrings;
Convar gCV_SavePlaytime = null; Convar gCV_SavePlaytime = null;
Convar gCV_NewDBConnection = null;
public Plugin myinfo = public Plugin myinfo =
{ {
@ -119,6 +120,8 @@ public void OnPluginStart()
LoadTranslations("shavit-stats.phrases"); LoadTranslations("shavit-stats.phrases");
gCV_SavePlaytime = new Convar("shavit_stats_saveplaytime", "1", "Whether to save a player's playtime (total & per-style).", 0, true, 0.0, true, 1.0); gCV_SavePlaytime = new Convar("shavit_stats_saveplaytime", "1", "Whether to save a player's playtime (total & per-style).", 0, true, 0.0, true, 1.0);
gCV_NewDBConnection = new Convar("shavit_stats_new_db_connection", "0", "Use a new DB connection for rankings. This should help with point-recalculation blocking other queries from running.\nYou probably don't need to use this unless you have a DB with hundreds of thousands of player times.\n0 - Reuses shavit-core DB connection.\n1 - Creates a new DB connection.", 0, true, 0.0, true, 1.0);
Convar.AutoExecConfig(); Convar.AutoExecConfig();
gB_Rankings = LibraryExists("shavit-rankings"); gB_Rankings = LibraryExists("shavit-rankings");
@ -144,7 +147,7 @@ public void OnPluginStart()
public void Shavit_OnDatabaseLoaded() public void Shavit_OnDatabaseLoaded()
{ {
GetTimerSQLPrefix(gS_MySQLPrefix, 32); GetTimerSQLPrefix(gS_MySQLPrefix, 32);
gH_SQL = GetTimerDatabaseHandle2(false); gH_SQL = gCV_NewDBConnection.BoolValue ? GetTimerDatabaseHandle2(false) : view_as<Database2>(Shavit_GetDatabase());
char sQuery[512]; char sQuery[512];
FormatEx(sQuery, sizeof(sQuery), FormatEx(sQuery, sizeof(sQuery),

View File

@ -92,6 +92,7 @@ char gS_MySQLPrefix[32];
// cvars // cvars
Convar gCV_RecordsLimit = null; Convar gCV_RecordsLimit = null;
Convar gCV_RecentLimit = null; Convar gCV_RecentLimit = null;
Convar gCV_NewDBConnection = null;
// timer settings // timer settings
int gI_Styles = 0; int gI_Styles = 0;
@ -184,6 +185,7 @@ public void OnPluginStart()
// cvars // cvars
gCV_RecordsLimit = new Convar("shavit_wr_recordlimit", "50", "Limit of records shown in the WR menu.\nAdvised to not set above 1,000 because scrolling through so many pages is useless.\n(And can also cause the command to take long time to run)", 0, true, 1.0); gCV_RecordsLimit = new Convar("shavit_wr_recordlimit", "50", "Limit of records shown in the WR menu.\nAdvised to not set above 1,000 because scrolling through so many pages is useless.\n(And can also cause the command to take long time to run)", 0, true, 1.0);
gCV_RecentLimit = new Convar("shavit_wr_recentlimit", "50", "Limit of records shown in the RR menu.", 0, true, 1.0); gCV_RecentLimit = new Convar("shavit_wr_recentlimit", "50", "Limit of records shown in the RR menu.", 0, true, 1.0);
gCV_NewDBConnection = new Convar("shavit_wr_new_db_connection", "0", "Use a new DB connection for rankings. This should help with point-recalculation blocking other queries from running.\nYou probably don't need to use this unless you have a DB with hundreds of thousands of player times.\n0 - Reuses shavit-core DB connection.\n1 - Creates a new DB connection.", 0, true, 0.0, true, 1.0);
Convar.AutoExecConfig(); Convar.AutoExecConfig();
@ -2280,7 +2282,7 @@ public int SubMenu_Handler(Menu menu, MenuAction action, int param1, int param2)
public void Shavit_OnDatabaseLoaded() public void Shavit_OnDatabaseLoaded()
{ {
GetTimerSQLPrefix(gS_MySQLPrefix, 32); GetTimerSQLPrefix(gS_MySQLPrefix, 32);
gH_SQL = GetTimerDatabaseHandle2(false); gH_SQL = gCV_NewDBConnection.BoolValue ? GetTimerDatabaseHandle2(false) : view_as<Database2>(Shavit_GetDatabase());
gB_MySQL = IsMySQLDatabase(gH_SQL); gB_MySQL = IsMySQLDatabase(gH_SQL);
char sQuery[1024]; char sQuery[1024];