Skip to content

Commit

Permalink
Merge pull request #443 from KZGlobalTeam/dev
Browse files Browse the repository at this point in the history
3.5.2
  • Loading branch information
zealain authored Jan 10, 2023
2 parents 4952b0a + 3286584 commit d894aaf
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 153 deletions.
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/gokz-core/timer/timer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool TimerStart(int client, int course, bool allowMidair = false, bool playSound
|| !IsPlayerValidMoveType(client)
|| !allowMidair && (!Movement_GetOnGround(client) || JustLanded(client))
|| allowMidair && !Movement_GetOnGround(client) && (!GOKZ_GetValidJump(client) || GOKZ_GetHitPerf(client))
|| (GOKZ_GetTimerRunning(client) && GOKZ_GetCourse(client) != course))
|| (GOKZ_GetTimerRunning(client) && GOKZ_GetCourse(client) != course && GetVirtualStartCourse(client) != course))
{
return false;
}
Expand Down
5 changes: 5 additions & 0 deletions addons/sourcemod/scripting/gokz-core/timer/virtual_buttons.sp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ bool GetHasVirtualEndButton(int client)
return hasVirtualEndButton[client];
}

int GetVirtualStartCourse(int client)
{
return virtualStartCourse[client];
}

bool ToggleVirtualButtonsLock(int client)
{
virtualButtonsLocked[client] = !virtualButtonsLocked[client];
Expand Down
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/gokz-localranks/db/sql.sp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ ALTER TABLE Maps \
char sqlite_maps_insertranked[] = "\
INSERT OR IGNORE INTO Maps \
(InRankedPool, Name) \
VALUES %s";
VALUES (%d, '%s')";

char sqlite_maps_updateranked[] = "\
UPDATE OR IGNORE Maps \
SET InRankedPool=%d \
WHERE Name IN (%s)";
WHERE Name = '%s'";

char mysql_maps_upsertranked[] = "\
INSERT INTO Maps (InRankedPool, Name) \
VALUES %s \
VALUES (%d, '%s') \
ON DUPLICATE KEY UPDATE \
InRankedPool=VALUES(InRankedPool)";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,95 +7,76 @@

void DB_UpdateRankedMapPool(int client)
{
Handle file = OpenFile(LR_CFG_MAP_POOL, "r");
File file = OpenFile(LR_CFG_MAP_POOL, "r");
if (file == null)
{
LogError("Failed to load file: \"%s\".", LR_CFG_MAP_POOL);
LogError("Failed to load file: '%s'.", LR_CFG_MAP_POOL);
if (IsValidClient(client))
{
// TODO Translation phrases?
GOKZ_PrintToChat(client, true, "{grey}There was a problem opening file '%s'.", LR_CFG_MAP_POOL);
GOKZ_PrintToChat(client, true, "%t", "Ranked Map Pool - Error");
}
return;
}

char map[33];
ArrayList maps = new ArrayList(33, 0);
char map[256];
int mapsCount = 0;

Transaction txn = new Transaction();

// Reset all maps to be unranked
txn.AddQuery(sql_maps_reset_mappool);

// Insert/Update maps in gokz-localranks-mappool.cfg to be ranked
while (ReadFileLine(file, map, sizeof(map)))
while (file.ReadLine(map, sizeof(map)))
{
TrimString(map);
String_ToLower(map, map, sizeof(map));

// Ignore blank lines and comments
if (map[0] == '\0' || map[0] == ';' || (map[0] == '/' && map[1] == '/'))
{
continue;
}
String_ToLower(map, map, sizeof(map));
maps.PushString(map);
}
delete file;

if (maps.Length == 0)
{
if (client == 0)
{
PrintToServer("No maps found in file '%s'.", LR_CFG_MAP_POOL);
}
else
mapsCount++;

switch (g_DBType)
{
// TODO Translation phrases?
GOKZ_PrintToChat(client, true, "{darkred}No maps found in file '%s'.", LR_CFG_MAP_POOL);
GOKZ_PlayErrorSound(client);
}
return;
}
case DatabaseType_SQLite:
{
char updateQuery[512];
gH_DB.Format(updateQuery, sizeof(updateQuery), sqlite_maps_updateranked, 1, map);

// Create VALUES e.g. (1,'kz_map1'),(1,'kz_map2')
int valuesSize = maps.Length * 40;
char[] values = new char[valuesSize];
maps.GetString(0, map, sizeof(map));
FormatEx(values, valuesSize, "(1,'%s')", map);
for (int i = 1; i < maps.Length; i++)
{
maps.GetString(i, map, sizeof(map));
Format(values, valuesSize, "%s,(1,'%s')", values, map);
}
char insertQuery[512];
gH_DB.Format(insertQuery, sizeof(insertQuery), sqlite_maps_insertranked, 1, map);

// Create query
int querySize = valuesSize + 128;
char[] query = new char[querySize];
txn.AddQuery(updateQuery);
txn.AddQuery(insertQuery);
}
case DatabaseType_MySQL:
{
char query[512];
gH_DB.Format(query, sizeof(query), mysql_maps_upsertranked, 1, map);

Transaction txn = SQL_CreateTransaction();
// Reset all maps to be unranked
txn.AddQuery(sql_maps_reset_mappool);
txn.AddQuery(query);
}
}
}

delete file;

switch (g_DBType)
if (mapsCount == 0)
{
case DatabaseType_SQLite:
{
// Create list of maps e.g. 'kz_map1','kz_map2'
int mapListSize = maps.Length * 36;
char[] mapList = new char[mapListSize];
maps.GetString(0, map, sizeof(map));
FormatEx(mapList, mapListSize, "'%s'", map);
for (int i = 1; i < maps.Length; i++)
{
maps.GetString(i, map, sizeof(map));
Format(mapList, mapListSize, "%s,'%s'", mapList, map);
}
LogError("No maps found in file: '%s'.", LR_CFG_MAP_POOL);

// UPDATE OR IGNORE
FormatEx(query, querySize, sqlite_maps_updateranked, 1, mapList);
txn.AddQuery(query);
// INSERT OR IGNORE
FormatEx(query, querySize, sqlite_maps_insertranked, values);
txn.AddQuery(query);
}
case DatabaseType_MySQL:
if (IsValidClient(client))
{
FormatEx(query, querySize, mysql_maps_upsertranked, values);
txn.AddQuery(query);
GOKZ_PrintToChat(client, true, "%t", "Ranked Map Pool - No Maps In File");
GOKZ_PlayErrorSound(client);
}

delete txn;
return;
}

// Pass client user ID (or -1) as data
Expand All @@ -105,9 +86,7 @@ void DB_UpdateRankedMapPool(int client)
data = GetClientUserId(client);
}

SQL_ExecuteTransaction(gH_DB, txn, DB_TxnSuccess_UpdateRankedMapPool, DB_TxnFailure_Generic, data, DBPrio_Low);

delete maps;
gH_DB.Execute(txn, DB_TxnSuccess_UpdateRankedMapPool, DB_TxnFailure_Generic, data);
}

public void DB_TxnSuccess_UpdateRankedMapPool(Handle db, int userid, int numQueries, Handle[] results, any[] queryData)
Expand All @@ -116,8 +95,7 @@ public void DB_TxnSuccess_UpdateRankedMapPool(Handle db, int userid, int numQuer
if (IsValidClient(client))
{
LogMessage("The ranked map pool was updated by %L.", client);
// TODO Translation phrases?
GOKZ_PrintToChat(client, true, "{grey}The ranked map pool was updated.");
GOKZ_PrintToChat(client, true, "%t", "Ranked Map Pool - Success");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/gokz-mode-kztimer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Plugin myinfo =

#define UPDATER_URL GOKZ_UPDATER_BASE_URL..."gokz-mode-kztimer.txt"

#define MODE_VERSION 214
#define MODE_VERSION 215
#define DUCK_SPEED_NORMAL 8.0
#define PRE_VELMOD_MAX 1.104 // Calculated 276/250
#define PERF_SPEED_CAP 380.0
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/gokz-mode-simplekz.sp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Plugin myinfo =

#define UPDATER_URL GOKZ_UPDATER_BASE_URL..."gokz-mode-simplekz.txt"

#define MODE_VERSION 18
#define MODE_VERSION 19
#define PS_MAX_REWARD_TURN_RATE 0.703125 // Degrees per tick (90 degrees per second)
#define PS_MAX_TURN_RATE_DECREMENT 0.015625 // Degrees per tick (2 degrees per second)
#define PS_SPEED_MAX 26.54321 // Units
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/gokz-mode-vanilla.sp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Plugin myinfo =

#define UPDATER_URL GOKZ_UPDATER_BASE_URL..."gokz-mode-vanilla.txt"

#define MODE_VERSION 14
#define MODE_VERSION 15

float gF_ModeCVarValues[MODECVAR_COUNT] =
{
Expand Down
Loading

0 comments on commit d894aaf

Please sign in to comment.