Migrate DBI to the 1.7 transitional syntax

This commit is contained in:
shavitush 2016-05-21 06:43:52 +03:00
parent 862b6d7d5d
commit 61fd0f6e03
6 changed files with 136 additions and 121 deletions

View File

@ -53,8 +53,8 @@ shavit-core - no other plugin will work without it.
shavit-zones - wouldn't really call it required but it's actually needed to get your timer to start/finish.
# Todo for 1.5b release
- [x] Migrate every menu to the new syntax.
- [ ] Migrate DBI to the new syntax.
- [x] Migrate every menu to the 1.7 transitional syntax.
- [x] Migrate DBI to the 1.7 transitional syntax.
~ shavit-core:
- [x] Fix chat colors for CS:S.

View File

@ -689,6 +689,7 @@ public void OnClientPutInServer(int client)
int iLength = ((strlen(sName) * 2) + 1);
char[] sEscapedName = new char[iLength]; // dynamic arrays! I love you, SourcePawn 1.7!
SQL_EscapeString(gH_SQL, sName, sEscapedName, iLength);
gH_SQL.Escape(sName, sEscapedName, iLength);
char[] sIP = new char[32];
GetClientIP(client, sIP, 32);
@ -707,10 +708,9 @@ public void OnClientPutInServer(int client)
gH_SQL.Query(SQL_InsertUser_Callback, sQuery, GetClientSerial(client));
}
public void SQL_InsertUser_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_InsertUser_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
int client = GetClientFromSerial(data);
@ -739,15 +739,13 @@ public void SQL_DBConnect()
{
char[] sError = new char[255];
if(!(gH_SQL = SQL_Connect("shavit", true, sError, 255)))
if(!(gH_SQL = SQL_Connect("shavit", true, sError, 255))) // can't be asynced as we have modules that require this database connection instantly
{
SetFailState("Timer startup failed. Reason: %s", sError);
}
// let's not mess with shit and make it non-English characters work properly before we do any stupid crap rite?
SQL_LockDatabase(gH_SQL);
SQL_FastQuery(gH_SQL, "SET NAMES 'utf8';");
SQL_UnlockDatabase(gH_SQL);
// support unicode names
gH_SQL.SetCharset("utf8");
char[] sQuery = new char[256];
FormatEx(sQuery, 256, "CREATE TABLE IF NOT EXISTS `%susers` (`auth` VARCHAR(32) NOT NULL, `name` VARCHAR(32), `country` VARCHAR(45), `ip` VARCHAR(32), PRIMARY KEY (`auth`));", gS_MySQLPrefix);
@ -762,9 +760,9 @@ public void SQL_DBConnect()
}
}
public void SQL_CreateTable_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_CreateTable_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer error! Users' data table creation failed. Reason: %s", error);

View File

@ -167,7 +167,7 @@ public Action ShowStyleMenu(int client)
{
continue;
}
char[] sInfo = new char[32];
FormatEx(sInfo, 32, "mapsdone;%d", i);
@ -269,9 +269,9 @@ public void ShowMaps(int client)
gH_SQL.Query(ShowMapsCallback, sQuery, GetClientSerial(client), DBPrio_High);
}
public void ShowMapsCallback(Handle owner, Handle hndl, const char[] error, any data)
public void ShowMapsCallback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (ShowMaps SELECT) SQL query failed. Reason: %s", error);
@ -285,7 +285,7 @@ public void ShowMapsCallback(Handle owner, Handle hndl, const char[] error, any
return;
}
int rows = SQL_GetRowCount(hndl);
int rows = results.RowCount;
char[] sTitle = new char[64];
@ -302,10 +302,10 @@ public void ShowMapsCallback(Handle owner, Handle hndl, const char[] error, any
Menu m = new Menu(MenuHandler_ShowMaps);
m.SetTitle(sTitle);
while(SQL_FetchRow(hndl))
while(results.FetchRow())
{
char[] sMap = new char[128];
SQL_FetchString(hndl, 0, sMap, 128);
results.FetchString(0, sMap, 128);
char[] sRecordID = new char[16];
@ -313,15 +313,15 @@ public void ShowMapsCallback(Handle owner, Handle hndl, const char[] error, any
if(gI_MapType[client] == MAPSDONE)
{
float time = SQL_FetchFloat(hndl, 1);
int jumps = SQL_FetchInt(hndl, 2);
float time = results.FetchFloat(1);
int jumps = results.FetchInt(2);
char[] sTime = new char[32];
FormatSeconds(time, sTime, 32);
FormatEx(sDisplay, 192, "%s - %s (%d jumps)", sMap, sTime, jumps);
int recordid = SQL_FetchInt(hndl, 3);
int recordid = results.FetchInt(3);
IntToString(recordid, sRecordID, 16);
}
@ -377,9 +377,9 @@ public int MenuHandler_ShowMaps(Menu m, MenuAction action, int param1, int param
return 0;
}
public void SQL_SubMenu_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_SubMenu_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (STATS SUBMENU) SQL query failed. Reason: %s", error);
@ -399,13 +399,13 @@ public void SQL_SubMenu_Callback(Handle owner, Handle hndl, const char[] error,
char[] sAuthID = new char[32];
char[] sMap = new char[256];
if(SQL_FetchRow(hndl))
if(results.FetchRow())
{
// 0 - name
SQL_FetchString(hndl, 0, sName, MAX_NAME_LENGTH);
results.FetchString(0, sName, MAX_NAME_LENGTH);
// 1 - time
float fTime = SQL_FetchFloat(hndl, 1);
float fTime = results.FetchFloat(1);
char[] sTime = new char[16];
FormatSeconds(fTime, sTime, 16);
@ -414,26 +414,26 @@ public void SQL_SubMenu_Callback(Handle owner, Handle hndl, const char[] error,
m.AddItem("-1", sDisplay);
// 2 - jumps
int iJumps = SQL_FetchInt(hndl, 2);
int iJumps = results.FetchInt(2);
FormatEx(sDisplay, 128, "Jumps: %d", iJumps);
m.AddItem("-1", sDisplay);
// 3 - style
int iStyle = SQL_FetchInt(hndl, 3);
int iStyle = results.FetchInt(3);
FormatEx(sDisplay, 128, "Style: %s", gS_BhopStyles[iStyle]);
m.AddItem("-1", sDisplay);
// 4 - steamid3
SQL_FetchString(hndl, 4, sAuthID, 32);
results.FetchString(4, sAuthID, 32);
// 5 - date
char[] sDate = new char[32];
SQL_FetchString(hndl, 5, sDate, 32);
results.FetchString(5, sDate, 32);
FormatEx(sDisplay, 128, "Date: %s", sDate);
m.AddItem("-1", sDisplay);
// 6 - map
SQL_FetchString(hndl, 6, sMap, 256);
results.FetchString(6, sMap, 256);
}
char[] sFormattedTitle = new char[256];

View File

@ -79,7 +79,7 @@ public void OnPluginStart()
gCV_DefaultLimit = CreateConVar("shavit_timelimit_default", "60.0", "Default timelimit to use in case there isn't an average.", FCVAR_PLUGIN, true, 10.0);
gCV_MinimumTimes = CreateConVar("shavit_timelimit_minimumtimes", "5", "Minimum amount of times required to calculate an average.", FCVAR_PLUGIN, true, 5.0);
gCV_PlayerAmount = CreateConVar("shavit_timelimit_playertime", "25", "Limited amount of times to grab from the database to calculate an average.\nSet to 0 to have it \"unlimited\".", FCVAR_PLUGIN);
gCV_Style = CreateConVar("shavit_timelimit_style", "1", "If set to 1, calculate an average only from times that the \"forwards\" style was used to set.", FCVAR_PLUGIN, true, 0.0, true, 1.0);
gCV_Style = CreateConVar("shavit_timelimit_style", "1", "If set to 1, calculate an average only from times that the first (default: forwards) style was used to set.", FCVAR_PLUGIN, true, 0.0, true, 1.0);
AutoExecConfig();
}
@ -141,24 +141,24 @@ public void StartCalculating()
}
}
public void SQL_GetMapTimes(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_GetMapTimes(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (TIMELIMIT time selection) SQL query failed. Reason: %s", error);
return;
}
int iRows = SQL_GetRowCount(hndl);
int iRows = results.RowCount;
if(iRows >= gCV_MinimumTimes.IntValue)
{
float fTotal = 0.0;
while(SQL_FetchRow(hndl))
while(results.FetchRow())
{
fTotal += SQL_FetchFloat(hndl, 0);
fTotal += results.FetchFloat(0);
#if defined DEBUG
PrintToServer("total: %.02f", fTotal);

View File

@ -267,9 +267,9 @@ public void UpdateClientCache(int client)
gH_SQL.Query(SQL_UpdateCache_Callback, sQuery, GetClientSerial(client), DBPrio_High);
}
public void SQL_UpdateCache_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_UpdateCache_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (PB cache update) SQL query failed. Reason: %s", error);
@ -283,9 +283,16 @@ public void SQL_UpdateCache_Callback(Handle owner, Handle hndl, const char[] err
return;
}
while(SQL_FetchRow(hndl))
while(results.FetchRow())
{
gF_PlayerRecord[client][SQL_FetchInt(hndl, 1)] = SQL_FetchFloat(hndl, 0);
int style = results.FetchInt(1);
if(style >= MAX_STYLES || style < 0)
{
continue;
}
gF_PlayerRecord[client][style] = results.FetchFloat(0);
}
}
@ -299,9 +306,9 @@ public void UpdateWRCache()
gH_SQL.Query(SQL_UpdateWRCache_Callback, sQuery, 0, DBPrio_High);
}
public void SQL_UpdateWRCache_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_UpdateWRCache_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (WR cache update) SQL query failed. Reason: %s", error);
@ -322,18 +329,19 @@ public void SQL_UpdateWRCache_Callback(Handle owner, Handle hndl, const char[] e
}
// setup cache again, dynamically and not hardcoded
while(SQL_FetchRow(hndl))
while(results.FetchRow())
{
int style = SQL_FetchInt(hndl, 0);
int style = results.FetchInt(0);
if(style >= MAX_STYLES || style < 0)
{
continue;
}
gI_WRRecordID[style] = SQL_FetchInt(hndl, 1);
gF_WRTime[style] = SQL_FetchFloat(hndl, 2);
SQL_FetchString(hndl, 3, gS_WRName[style], MAX_NAME_LENGTH);
gI_WRRecordID[style] = results.FetchInt(1);
gF_WRTime[style] = results.FetchFloat(2);
results.FetchString(3, gS_WRName[style], MAX_NAME_LENGTH);
}
}
@ -498,14 +506,14 @@ public void OpenDelete(int client, BhopStyle style)
gH_SQL.Query(SQL_OpenDelete_Callback, sQuery, datapack, DBPrio_High);
}
public void SQL_OpenDelete_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_OpenDelete_Callback(Database db, DBResultSet results, const char[] error, any data)
{
ResetPack(data);
int client = GetClientFromSerial(ReadPackCell(data));
BhopStyle style = ReadPackCell(data);
delete view_as<DataPack>(data);
if(hndl == null)
if(results == null)
{
LogError("Timer (WR OpenDelete) SQL query failed. Reason: %s", error);
@ -525,26 +533,26 @@ public void SQL_OpenDelete_Callback(Handle owner, Handle hndl, const char[] erro
int iCount = 0;
while(SQL_FetchRow(hndl))
while(results.FetchRow())
{
iCount++;
// 0 - record id, for statistic purposes.
int id = SQL_FetchInt(hndl, 0);
int id = results.FetchInt(0);
char[] sID = new char[8];
IntToString(id, sID, 8);
// 1 - player name
char[] sName = new char[MAX_NAME_LENGTH];
SQL_FetchString(hndl, 1, sName, MAX_NAME_LENGTH);
results.FetchString(1, sName, MAX_NAME_LENGTH);
// 2 - time
float fTime = SQL_FetchFloat(hndl, 2);
float fTime = results.FetchFloat(2);
char[] sTime = new char[16];
FormatSeconds(fTime, sTime, 16);
// 3 - jumps
int iJumps = SQL_FetchInt(hndl, 3);
int iJumps = results.FetchInt(3);
char[] sDisplay = new char[128];
FormatEx(sDisplay, 128, "#%d - %s - %s (%d Jumps)", iCount, sName, sTime, iJumps);
@ -629,9 +637,9 @@ public int DeleteConfirm_Handler(Menu m, MenuAction action, int param1, int para
return 0;
}
public void DeleteConfirm_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void DeleteConfirm_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (WR DeleteConfirm) SQL query failed. Reason: %s", error);
@ -655,9 +663,9 @@ public void DeleteConfirm_Callback(Handle owner, Handle hndl, const char[] error
Shavit_PrintToChat(client, "Deleted record.");
}
public void DeleteAll_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void DeleteAll_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (WR DeleteAll) SQL query failed. Reason: %s", error);
@ -768,14 +776,14 @@ public void StartWRMenu(int client, const char[] map, int style)
dp.WriteString(map);
char[] sQuery = new char[512];
FormatEx(sQuery, 512, "SELECT p.id, u.name, p.time, p.jumps, p.auth, (SELECT COUNT(*) FROM %splayertimes WHERE map = '%s' AND style = %d) AS records FROM %splayertimes p JOIN %susers u ON p.auth = u.auth WHERE map = '%s' AND style = %d ORDER BY time ASC LIMIT %d;", gS_MySQLPrefix, map, style, gS_MySQLPrefix, gS_MySQLPrefix, map, style, gCV_RecordsLimit.IntValue);
FormatEx(sQuery, 512, "SELECT p.id, u.name, p.time, p.jumps, p.auth, (SELECT COUNT(*) FROM %splayertimes WHERE map = '%s' AND style = %d) AS records FROM %splayertimes p JOIN %susers u ON p.auth = u.auth WHERE map = '%s' AND style = %d ORDER BY time ASC;", gS_MySQLPrefix, map, style, gS_MySQLPrefix, gS_MySQLPrefix, map, style);
gH_SQL.Query(SQL_WR_Callback, sQuery, dp, DBPrio_High);
return;
}
public void SQL_WR_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_WR_Callback(Database db, DBResultSet results, const char[] error, any data)
{
ResetPack(data);
@ -786,7 +794,7 @@ public void SQL_WR_Callback(Handle owner, Handle hndl, const char[] error, any d
delete view_as<DataPack>(data);
if(hndl == null)
if(results == null)
{
LogError("Timer (WR SELECT) SQL query failed. Reason: %s", error);
@ -810,26 +818,29 @@ public void SQL_WR_Callback(Handle owner, Handle hndl, const char[] error, any d
int iRecords = 0;
while(SQL_FetchRow(hndl))
while(results.FetchRow())
{
iCount++;
if(++iCount > gCV_RecordsLimit.IntValue)
{
break;
}
// 0 - record id, for statistic purposes.
int id = SQL_FetchInt(hndl, 0);
int id = results.FetchInt(0);
char[] sID = new char[8];
IntToString(id, sID, 8);
// 1 - player name
char[] sName = new char[MAX_NAME_LENGTH];
SQL_FetchString(hndl, 1, sName, MAX_NAME_LENGTH);
results.FetchString(1, sName, MAX_NAME_LENGTH);
// 2 - time
float fTime = SQL_FetchFloat(hndl, 2);
float fTime = results.FetchFloat(2);
char[] sTime = new char[16];
FormatSeconds(fTime, sTime, 16);
// 3 - jumps
int iJumps = SQL_FetchInt(hndl, 3);
int iJumps = results.FetchInt(3);
// add item to m
char[] sDisplay = new char[128];
@ -838,7 +849,7 @@ public void SQL_WR_Callback(Handle owner, Handle hndl, const char[] error, any d
// check if record exists in the map's top X
char[] sQueryAuth = new char[32];
SQL_FetchString(hndl, 4, sQueryAuth, 32);
results.FetchString(4, sQueryAuth, 32);
if(StrEqual(sQueryAuth, sAuth))
{
@ -848,7 +859,7 @@ public void SQL_WR_Callback(Handle owner, Handle hndl, const char[] error, any d
// fetch amount of records
if(iRecords == 0)
{
iRecords = SQL_FetchInt(hndl, 5);
iRecords = results.FetchInt(5);
}
}
@ -920,9 +931,9 @@ public void OpenSubMenu(int client, int id)
gH_SQL.Query(SQL_SubMenu_Callback, sQuery, GetClientSerial(client));
}
public void SQL_SubMenu_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_SubMenu_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (WR SUBMENU) SQL query failed. Reason: %s", error);
@ -941,13 +952,13 @@ public void SQL_SubMenu_Callback(Handle owner, Handle hndl, const char[] error,
char[] sName = new char[MAX_NAME_LENGTH];
char[] sAuthID = new char[32];
if(SQL_FetchRow(hndl))
if(results.FetchRow())
{
// 0 - name
SQL_FetchString(hndl, 0, sName, MAX_NAME_LENGTH);
results.FetchString(0, sName, MAX_NAME_LENGTH);
// 1 - time
float fTime = SQL_FetchFloat(hndl, 1);
float fTime = results.FetchFloat(1);
char[] sTime = new char[16];
FormatSeconds(fTime, sTime, 16);
@ -956,21 +967,21 @@ public void SQL_SubMenu_Callback(Handle owner, Handle hndl, const char[] error,
m.AddItem("-1", sDisplay);
// 2 - jumps
int iJumps = SQL_FetchInt(hndl, 2);
int iJumps = results.FetchInt(2);
FormatEx(sDisplay, 128, "Jumps: %d", iJumps);
m.AddItem("-1", sDisplay);
// 3 - style
int iStyle = SQL_FetchInt(hndl, 3);
int iStyle = results.FetchInt(3);
FormatEx(sDisplay, 128, "Style: %s", gS_BhopStyles[iStyle]);
m.AddItem("-1", sDisplay);
// 4 - steamid3
SQL_FetchString(hndl, 4, sAuthID, 32);
results.FetchString(4, sAuthID, 32);
// 5 - date
char[] sDate = new char[32];
SQL_FetchString(hndl, 5, sDate, 32);
results.FetchString(5, sDate, 32);
FormatEx(sDisplay, 128, "Date: %s", sDate);
m.AddItem("-1", sDisplay);
}
@ -1019,9 +1030,9 @@ public void SQL_DBConnect()
}
}
public void SQL_CreateTable_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_CreateTable_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (WR module) error! Users' times table creation failed. Reason: %s", error);
@ -1158,9 +1169,9 @@ public void Shavit_OnFinish(int client, BhopStyle style, float time, int jumps)
}
}
public void SQL_OnFinish_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_OnFinish_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (WR OnFinish) SQL query failed. Reason: %s", error);

View File

@ -418,9 +418,9 @@ public void RefreshZones()
}
}
public void SQL_RefreshZones_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_RefreshZones_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (zone refresh) SQL query failed. Reason: %s", error);
@ -429,20 +429,20 @@ public void SQL_RefreshZones_Callback(Handle owner, Handle hndl, const char[] er
int iFreestyleRow = 0;
while(SQL_FetchRow(hndl))
while(results.FetchRow())
{
MapZones type = view_as<MapZones>(SQL_FetchInt(hndl, 0));
MapZones type = view_as<MapZones>(results.FetchInt(0));
if(type == Zone_Freestyle || type == Zone_NoVelLimit)
{
gV_FreestyleZones[iFreestyleRow][0][0] = SQL_FetchFloat(hndl, 1);
gV_FreestyleZones[iFreestyleRow][0][1] = SQL_FetchFloat(hndl, 2);
gV_FreestyleZones[iFreestyleRow][0][2] = SQL_FetchFloat(hndl, 3);
gV_FreestyleZones[iFreestyleRow][1][0] = SQL_FetchFloat(hndl, 4);
gV_FreestyleZones[iFreestyleRow][1][1] = SQL_FetchFloat(hndl, 5);
gV_FreestyleZones[iFreestyleRow][1][2] = SQL_FetchFloat(hndl, 6);
gV_FreestyleZones[iFreestyleRow][0][0] = results.FetchFloat(1);
gV_FreestyleZones[iFreestyleRow][0][1] = results.FetchFloat(2);
gV_FreestyleZones[iFreestyleRow][0][2] = results.FetchFloat(3);
gV_FreestyleZones[iFreestyleRow][1][0] = results.FetchFloat(4);
gV_FreestyleZones[iFreestyleRow][1][1] = results.FetchFloat(5);
gV_FreestyleZones[iFreestyleRow][1][2] = results.FetchFloat(6);
float ang = SQL_FetchFloat(hndl, 7);
float ang = results.FetchFloat(7);
float radian = DegToRad(ang);
gF_FreeStyleConstSin[iFreestyleRow] = Sine(radian);
gF_FreeStyleConstCos[iFreestyleRow] = Cosine(radian);
@ -451,24 +451,29 @@ public void SQL_RefreshZones_Callback(Handle owner, Handle hndl, const char[] er
gF_FreeStyleMinusConstSin[iFreestyleRow] = Sine(radian);
gF_FreeStyleMinusConstCos[iFreestyleRow] = Cosine(radian);
gV_FreeStyleZonesFixes[iFreestyleRow][0][0] = SQL_FetchFloat(hndl, 8);
gV_FreeStyleZonesFixes[iFreestyleRow][0][1] = SQL_FetchFloat(hndl, 9);
gV_FreeStyleZonesFixes[iFreestyleRow][1][0] = SQL_FetchFloat(hndl, 10);
gV_FreeStyleZonesFixes[iFreestyleRow][1][1] = SQL_FetchFloat(hndl, 11);
gV_FreeStyleZonesFixes[iFreestyleRow][0][0] = results.FetchFloat(8);
gV_FreeStyleZonesFixes[iFreestyleRow][0][1] = results.FetchFloat(9);
gV_FreeStyleZonesFixes[iFreestyleRow][1][0] = results.FetchFloat(10);
gV_FreeStyleZonesFixes[iFreestyleRow][1][1] = results.FetchFloat(11);
iFreestyleRow++;
}
else
{
gV_MapZones[type][0][0] = SQL_FetchFloat(hndl, 1);
gV_MapZones[type][0][1] = SQL_FetchFloat(hndl, 2);
gV_MapZones[type][0][2] = SQL_FetchFloat(hndl, 3);
gV_MapZones[type][1][0] = SQL_FetchFloat(hndl, 4);
gV_MapZones[type][1][1] = SQL_FetchFloat(hndl, 5);
gV_MapZones[type][1][2] = SQL_FetchFloat(hndl, 6);
if(view_as<int>(type) >= MAX_ZONES || view_as<int>(type) < 0)
{
continue;
}
float ang = SQL_FetchFloat(hndl, 7);
gV_MapZones[type][0][0] = results.FetchFloat(1);
gV_MapZones[type][0][1] = results.FetchFloat(2);
gV_MapZones[type][0][2] = results.FetchFloat(3);
gV_MapZones[type][1][0] = results.FetchFloat(4);
gV_MapZones[type][1][1] = results.FetchFloat(5);
gV_MapZones[type][1][2] = results.FetchFloat(6);
float ang = results.FetchFloat(7);
float radian = DegToRad(ang);
gF_ConstSin[type] = Sine(radian);
gF_ConstCos[type] = Cosine(radian);
@ -477,10 +482,10 @@ public void SQL_RefreshZones_Callback(Handle owner, Handle hndl, const char[] er
gF_MinusConstSin[type] = Sine(radian);
gF_MinusConstCos[type] = Cosine(radian);
gV_MapZonesFixes[type][0][0] = SQL_FetchFloat(hndl, 8);
gV_MapZonesFixes[type][0][1] = SQL_FetchFloat(hndl, 9);
gV_MapZonesFixes[type][1][0] = SQL_FetchFloat(hndl, 10);
gV_MapZonesFixes[type][1][1] = SQL_FetchFloat(hndl, 11);
gV_MapZonesFixes[type][0][0] = results.FetchFloat(8);
gV_MapZonesFixes[type][0][1] = results.FetchFloat(9);
gV_MapZonesFixes[type][1][0] = results.FetchFloat(10);
gV_MapZonesFixes[type][1][1] = results.FetchFloat(11);
}
}
}
@ -633,7 +638,7 @@ public int DeleteZone_MenuHandler(Menu menu, MenuAction action, int param1, int
return 0;
}
public void SQL_DeleteZone_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_DeleteZone_Callback(Database db, DBResultSet results, const char[] error, any data)
{
ResetPack(data);
int client = GetClientFromSerial(ReadPackCell(data));
@ -641,7 +646,7 @@ public void SQL_DeleteZone_Callback(Handle owner, Handle hndl, const char[] erro
delete view_as<DataPack>(data);
if(hndl == null)
if(results == null)
{
LogError("Timer (single zone delete) SQL query failed. Reason: %s", error);
@ -715,9 +720,9 @@ public int DeleteAllZones_MenuHandler(Menu menu, MenuAction action, int param1,
}
}
public void SQL_DeleteAllZones_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_DeleteAllZones_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (single zone delete) SQL query failed. Reason: %s", error);
@ -1314,9 +1319,9 @@ public void InsertZone(int client)
Reset(client);
}
public void SQL_InsertZone_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_InsertZone_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (zone insert) SQL query failed. Reason: %s", error);
@ -1739,9 +1744,9 @@ public void SQL_DBConnect()
}
}
public void SQL_CreateTable_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_CreateTable_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (zones module) error! Map zones' table creation failed. Reason: %s", error);
@ -1757,9 +1762,10 @@ public void SQL_CreateTable_Callback(Handle owner, Handle hndl, const char[] err
RefreshZones();
}
public void SQL_CheckRotation_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_CheckRotation_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
// rot_ang and the new stuff are missing. this is for people that update [shavit] from an older version
if(results == null)
{
char[] sQuery = new char[256];
FormatEx(sQuery, 256, "ALTER TABLE `%smapzones` ADD (`rot_ang` FLOAT NOT NULL default 0, `fix1_x` FLOAT NOT NULL default 0, `fix1_y` FLOAT NOT NULL default 0, `fix2_x` FLOAT NOT NULL default 0, `fix2_y` FLOAT NOT NULL default 0);", gS_MySQLPrefix);
@ -1768,9 +1774,9 @@ public void SQL_CheckRotation_Callback(Handle owner, Handle hndl, const char[] e
}
}
public void SQL_AlterTable_Callback(Handle owner, Handle hndl, const char[] error, any data)
public void SQL_AlterTable_Callback(Database db, DBResultSet results, const char[] error, any data)
{
if(hndl == null)
if(results == null)
{
LogError("Timer (zones module) error! Map zones' table alteration failed. Reason: %s", error);