mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
remove points_calced_from since it should only update on wr now so it's unnecessary
This commit is contained in:
parent
b3b7de37e2
commit
7a11acf2e6
@ -45,6 +45,7 @@ enum
|
||||
Migration_Lowercase_stagetimeswr, // 20
|
||||
Migration_Lowercase_startpositions,
|
||||
Migration_AddPlayertimesPointsCalcedFrom, // points calculated from wr float added to playertimes
|
||||
Migration_RemovePlayertimesPointsCalcedFrom, // lol
|
||||
// TODO: Add alter tables playertimes modify column blah after blah
|
||||
MIGRATIONS_END
|
||||
};
|
||||
@ -167,14 +168,14 @@ public void SQL_CreateTables(Database2 hSQL, const char[] prefix, bool mysql)
|
||||
if (gB_MySQL)
|
||||
{
|
||||
FormatEx(sQuery, sizeof(sQuery),
|
||||
"CREATE TABLE IF NOT EXISTS `%splayertimes` (`id` INT NOT NULL AUTO_INCREMENT, `style` TINYINT NOT NULL DEFAULT 0, `track` TINYINT NOT NULL DEFAULT 0, `time` FLOAT NOT NULL, `auth` INT NOT NULL, `map` VARCHAR(255) NOT NULL, `points` FLOAT NOT NULL DEFAULT 0, `points_calced_from` FLOAT NOT NULL DEFAULT 0, `exact_time_int` INT DEFAULT 0, `jumps` INT, `date` INT, `strafes` INT, `sync` FLOAT, `perfs` FLOAT DEFAULT 0, `completions` SMALLINT DEFAULT 1, PRIMARY KEY (`id`), INDEX `map` (`map`, `style`, `track`, `time`), INDEX `auth` (`auth`, `date`, `points`), INDEX `time` (`time`), INDEX `map2` (`map`)) ENGINE=INNODB;",
|
||||
"CREATE TABLE IF NOT EXISTS `%splayertimes` (`id` INT NOT NULL AUTO_INCREMENT, `style` TINYINT NOT NULL DEFAULT 0, `track` TINYINT NOT NULL DEFAULT 0, `time` FLOAT NOT NULL, `auth` INT NOT NULL, `map` VARCHAR(255) NOT NULL, `points` FLOAT NOT NULL DEFAULT 0, `exact_time_int` INT DEFAULT 0, `jumps` INT, `date` INT, `strafes` INT, `sync` FLOAT, `perfs` FLOAT DEFAULT 0, `completions` SMALLINT DEFAULT 1, PRIMARY KEY (`id`), INDEX `map` (`map`, `style`, `track`, `time`), INDEX `auth` (`auth`, `date`, `points`), INDEX `time` (`time`), INDEX `map2` (`map`)) ENGINE=INNODB;",
|
||||
gS_SQLPrefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
// id style track time auth map points points_calced_from exact_time_int
|
||||
// id style track time auth map points exact_time_int
|
||||
FormatEx(sQuery, sizeof(sQuery),
|
||||
"CREATE TABLE IF NOT EXISTS `%splayertimes` (`id` INTEGER PRIMARY KEY, `style` TINYINT NOT NULL DEFAULT 0, `track` TINYINT NOT NULL DEFAULT 0, `time` FLOAT NOT NULL, `auth` INT NOT NULL, `map` VARCHAR(255) NOT NULL, `points` FLOAT NOT NULL DEFAULT 0, `points_calced_from` FLOAT NOT NULL DEFAULT 0, `exact_time_int` INT DEFAULT 0, `jumps` INT, `date` INT, `strafes` INT, `sync` FLOAT, `perfs` FLOAT DEFAULT 0, `completions` SMALLINT DEFAULT 1);",
|
||||
"CREATE TABLE IF NOT EXISTS `%splayertimes` (`id` INTEGER PRIMARY KEY, `style` TINYINT NOT NULL DEFAULT 0, `track` TINYINT NOT NULL DEFAULT 0, `time` FLOAT NOT NULL, `auth` INT NOT NULL, `map` VARCHAR(255) NOT NULL, `points` FLOAT NOT NULL DEFAULT 0, `exact_time_int` INT DEFAULT 0, `jumps` INT, `date` INT, `strafes` INT, `sync` FLOAT, `perfs` FLOAT DEFAULT 0, `completions` SMALLINT DEFAULT 1);",
|
||||
gS_SQLPrefix);
|
||||
}
|
||||
|
||||
@ -302,6 +303,7 @@ void ApplyMigration(int migration)
|
||||
case Migration_Lowercase_stagetimeswr: ApplyMigration_LowercaseMaps("stagetimewrs", migration);
|
||||
case Migration_Lowercase_startpositions: ApplyMigration_LowercaseMaps("startpositions", migration);
|
||||
case Migration_AddPlayertimesPointsCalcedFrom: ApplyMigration_AddPlayertimesPointsCalcedFrom();
|
||||
case Migration_RemovePlayertimesPointsCalcedFrom: ApplyMigration_RemovePlayertimesPointsCalcedFrom();
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,9 +394,20 @@ void ApplyMigration_LowercaseMaps(const char[] table, int migration)
|
||||
|
||||
void ApplyMigration_AddPlayertimesPointsCalcedFrom()
|
||||
{
|
||||
#if 0
|
||||
char sQuery[192];
|
||||
FormatEx(sQuery, 192, "ALTER TABLE `%splayertimes` ADD COLUMN `points_calced_from` FLOAT NOT NULL DEFAULT 0 %s;", gS_SQLPrefix, gB_MySQL ? "AFTER `points`" : "");
|
||||
gH_SQL.Query2(SQL_TableMigrationSingleQuery_Callback, sQuery, Migration_AddPlayertimesPointsCalcedFrom, DBPrio_High);
|
||||
#else
|
||||
SQL_TableMigrationSingleQuery_Callback(null, null, "", Migration_AddPlayertimesPointsCalcedFrom);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ApplyMigration_RemovePlayertimesPointsCalcedFrom()
|
||||
{
|
||||
char sQuery[192];
|
||||
FormatEx(sQuery, 192, "ALTER TABLE `%splayertimes` DROP COLUMN `points_calced_from`;", gS_SQLPrefix);
|
||||
gH_SQL.Query2(SQL_TableMigrationSingleQuery_Callback, sQuery, Migration_RemovePlayertimesPointsCalcedFrom, DBPrio_High);
|
||||
}
|
||||
|
||||
public void SQL_TableMigrationSingleQuery_Callback(Database db, DBResultSet results, const char[] error, any data)
|
||||
|
||||
@ -758,7 +758,7 @@ void FormatRecalculate(bool bUseCurrentMap, int track, int style, char[] sQuery,
|
||||
if (Shavit_GetStyleSettingBool(style, "unranked") || fMultiplier == 0.0)
|
||||
{
|
||||
FormatEx(sQuery, sQueryLen,
|
||||
"UPDATE %splayertimes SET points = 0, points_calced_from = 0 WHERE style = %d AND track %c 0 %s%s%s;",
|
||||
"UPDATE %splayertimes SET points = 0 WHERE style = %d AND track %c 0 %s%s%s;",
|
||||
gS_MySQLPrefix,
|
||||
style,
|
||||
(track > 0) ? '>' : '=',
|
||||
@ -781,18 +781,13 @@ void FormatRecalculate(bool bUseCurrentMap, int track, int style, char[] sQuery,
|
||||
|
||||
FormatEx(sQuery, sQueryLen,
|
||||
"UPDATE %splayertimes PT " ...
|
||||
"SET PT.points_calced_from = %f, " ...
|
||||
" PT.points = " ...
|
||||
" %f " ...
|
||||
" * (%f / PT.time) " ...
|
||||
"WHERE PT.style = %d AND PT.track = 0 AND PT.map = '%s' AND PT.points_calced_from != %f;",
|
||||
"SET PT.points = %f * (%f / PT.time) " ...
|
||||
"WHERE PT.style = %d AND PT.track = 0 AND PT.map = '%s';",
|
||||
gS_MySQLPrefix,
|
||||
fWR,
|
||||
(((gCV_PointsPerTier.FloatValue * fTier) * 1.5) + (fWR / 15.0)) * fMultiplier,
|
||||
fWR,
|
||||
style,
|
||||
gS_Map,
|
||||
fWR
|
||||
gS_Map
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -800,8 +795,8 @@ void FormatRecalculate(bool bUseCurrentMap, int track, int style, char[] sQuery,
|
||||
FormatEx(sQuery, sQueryLen,
|
||||
"UPDATE %splayertimes PT " ...
|
||||
"INNER JOIN %swrs WR ON " ...
|
||||
" PT.track = WR.track AND PT.style = WR.style AND PT.map = WR.map AND PT.points_calced_from != WR.time " ...
|
||||
"SET PT.points_calced_from = WR.time, " ...
|
||||
" PT.track = WR.track AND PT.style = WR.style AND PT.map = WR.map " ...
|
||||
"SET " ...
|
||||
" PT.points = "...
|
||||
" (%f + (WR.time / 15.0)) " ...
|
||||
" * (WR.time / PT.time) " ...
|
||||
@ -828,10 +823,10 @@ void FormatRecalculate(bool bUseCurrentMap, int track, int style, char[] sQuery,
|
||||
FormatEx(sQuery, sQueryLen,
|
||||
"UPDATE %splayertimes PT " ...
|
||||
"INNER JOIN %swrs WR ON " ...
|
||||
" PT.track %c 0 AND PT.track = WR.track AND PT.style = %d AND PT.style = WR.style %s AND PT.map = WR.map AND PT.points_calced_from != WR.time " ...
|
||||
" PT.track %c 0 AND PT.track = WR.track AND PT.style = %d AND PT.style = WR.style %s AND PT.map = WR.map " ...
|
||||
"INNER JOIN %smaptiers MT ON " ...
|
||||
" PT.map = MT.map " ...
|
||||
"SET PT.points_calced_from = WR.time, " ...
|
||||
"SET " ...
|
||||
" PT.points = "...
|
||||
" (((%f * %s) * 1.5) + (WR.time / 15.0)) " ...
|
||||
" * (WR.time / PT.time) " ...
|
||||
@ -857,7 +852,7 @@ public Action Command_RecalcAll(int client, int args)
|
||||
Transaction2 trans = new Transaction2();
|
||||
char sQuery[1024];
|
||||
|
||||
FormatEx(sQuery, sizeof(sQuery), "UPDATE %splayertimes SET points = 0, points_calced_from = 0;", gS_MySQLPrefix);
|
||||
FormatEx(sQuery, sizeof(sQuery), "UPDATE %splayertimes SET points = 0;", gS_MySQLPrefix);
|
||||
trans.AddQuery2(sQuery);
|
||||
FormatEx(sQuery, sizeof(sQuery), "UPDATE %susers SET points = 0;", gS_MySQLPrefix);
|
||||
trans.AddQuery2(sQuery);
|
||||
@ -903,7 +898,7 @@ void RecalculateSpecificMap(const char[] map, int serial)
|
||||
char sQuery[1024];
|
||||
|
||||
// Only maintrack times because bonus times aren't tiered.
|
||||
FormatEx(sQuery, sizeof(sQuery), "UPDATE %splayertimes SET points = 0, points_calced_from = 0 WHERE map = '%s' AND track = 0;", gS_MySQLPrefix, map);
|
||||
FormatEx(sQuery, sizeof(sQuery), "UPDATE %splayertimes SET points = 0 WHERE map = '%s' AND track = 0;", gS_MySQLPrefix, map);
|
||||
trans.AddQuery2(sQuery);
|
||||
|
||||
for(int i = 0; i < gI_Styles; i++)
|
||||
@ -927,7 +922,7 @@ void ReallyRecalculateCurrentMap()
|
||||
Transaction2 trans = new Transaction2();
|
||||
char sQuery[1024];
|
||||
|
||||
FormatEx(sQuery, sizeof(sQuery), "UPDATE %splayertimes SET points = 0, points_calced_from = 0 WHERE map = '%s';", gS_MySQLPrefix, gS_Map);
|
||||
FormatEx(sQuery, sizeof(sQuery), "UPDATE %splayertimes SET points = 0 WHERE map = '%s';", gS_MySQLPrefix, gS_Map);
|
||||
trans.AddQuery2(sQuery);
|
||||
|
||||
for (int i = 0; i < gI_Styles; i++)
|
||||
|
||||
@ -2680,8 +2680,8 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
|
||||
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "FirstCompletion", LANG_SERVER, gS_ChatStrings.sVariable2, client, gS_ChatStrings.sText, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, gS_ChatStrings.sVariable, iRank, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText);
|
||||
|
||||
FormatEx(sQuery, sizeof(sQuery),
|
||||
"INSERT INTO %splayertimes (auth, map, time, jumps, date, style, strafes, sync, points, track, perfs, exact_time_int, points_calced_from) VALUES (%d, '%s', %f, %d, %d, %d, %d, %.2f, %f, %d, %.2f, %d, %f);",
|
||||
gS_MySQLPrefix, iSteamID, gS_Map, time, jumps, timestamp, style, strafes, sync, fPoints, track, perfs, view_as<int>(time), gF_WRTime[style][track]);
|
||||
"INSERT INTO %splayertimes (auth, map, time, jumps, date, style, strafes, sync, points, track, perfs, exact_time_int) VALUES (%d, '%s', %f, %d, %d, %d, %d, %.2f, %f, %d, %.2f, %d);",
|
||||
gS_MySQLPrefix, iSteamID, gS_Map, time, jumps, timestamp, style, strafes, sync, fPoints, track, perfs, view_as<int>(time));
|
||||
}
|
||||
else // update
|
||||
{
|
||||
@ -2689,8 +2689,8 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
|
||||
gS_ChatStrings.sVariable, sTrack, gS_ChatStrings.sText, "NotFirstCompletion", LANG_SERVER, gS_ChatStrings.sVariable2, client, gS_ChatStrings.sText, gS_ChatStrings.sStyle, gS_StyleStrings[style].sStyleName, gS_ChatStrings.sText, gS_ChatStrings.sVariable2, sTime, gS_ChatStrings.sText, gS_ChatStrings.sVariable, iRank, gS_ChatStrings.sText, jumps, strafes, sSync, gS_ChatStrings.sText, gS_ChatStrings.sWarning, sDifference);
|
||||
|
||||
FormatEx(sQuery, sizeof(sQuery),
|
||||
"UPDATE %splayertimes SET time = %f, jumps = %d, date = %d, strafes = %d, sync = %.02f, points = %f, perfs = %.2f, exact_time_int = %d, points_calced_from = %f, completions = completions + 1 WHERE map = '%s' AND auth = %d AND style = %d AND track = %d;",
|
||||
gS_MySQLPrefix, time, jumps, timestamp, strafes, sync, fPoints, perfs, view_as<int>(time), gF_WRTime[style][track], gS_Map, iSteamID, style, track);
|
||||
"UPDATE %splayertimes SET time = %f, jumps = %d, date = %d, strafes = %d, sync = %.02f, points = %f, perfs = %.2f, exact_time_int = %d, completions = completions + 1 WHERE map = '%s' AND auth = %d AND style = %d AND track = %d;",
|
||||
gS_MySQLPrefix, time, jumps, timestamp, strafes, sync, fPoints, perfs, view_as<int>(time), gS_Map, iSteamID, style, track);
|
||||
}
|
||||
|
||||
gH_SQL.Query2(SQL_OnFinish_Callback, sQuery, GetClientSerial(client), DBPrio_High);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user