mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
Fix offset bug and add GetStageZone native (#948)
* fix bug and add GetStageZone native * Update Native Now preloads stage zone data on map start.
This commit is contained in:
parent
08050e23ac
commit
35878fc81d
@ -1034,6 +1034,15 @@ native int Shavit_GetBhopStyle(int client);
|
||||
*/
|
||||
native TimerStatus Shavit_GetTimerStatus(int client);
|
||||
|
||||
/**
|
||||
* Retrieve the zone ID for a given stage number.
|
||||
* Will return exception if stagenumber doesn't have a zone.
|
||||
*
|
||||
* @param client Stage number.
|
||||
* @return Zone ID of stage.
|
||||
*/
|
||||
native int Shavit_GetStageZone(int stage);
|
||||
|
||||
/**
|
||||
* Retrieve the amount of strafes done since the timer started.
|
||||
* Will return 0 if timer isn't running.
|
||||
@ -1920,6 +1929,7 @@ public void __pl_shavit_SetNTVOptional()
|
||||
MarkNativeAsOptional("Shavit_GetReplayName");
|
||||
MarkNativeAsOptional("Shavit_GetReplayStatus");
|
||||
MarkNativeAsOptional("Shavit_GetReplayTime");
|
||||
MarkNativeAsOptional("Shavit_GetStageZone");
|
||||
MarkNativeAsOptional("Shavit_GetStrafeCount");
|
||||
MarkNativeAsOptional("Shavit_GetStyleCount");
|
||||
MarkNativeAsOptional("Shavit_GetStyleSettings");
|
||||
|
||||
@ -111,6 +111,7 @@ float gF_PauseVelocity[MAXPLAYERS+1][3];
|
||||
// used for offsets
|
||||
float gF_SmallestDist[MAXPLAYERS + 1];
|
||||
float gF_Origin[MAXPLAYERS + 1][2][3];
|
||||
float gF_Fraction[MAXPLAYERS + 1];
|
||||
|
||||
// cookies
|
||||
Handle gH_StyleCookie = null;
|
||||
@ -3013,13 +3014,7 @@ void CalculateTickIntervalOffset(int client, int zonetype)
|
||||
TR_EnumerateEntitiesHull(gF_Origin[client][0], localOrigin, mins, maxs, PARTITION_TRIGGER_EDICTS, TREnumTrigger, client);
|
||||
}
|
||||
|
||||
float speed = GetVectorLength(vel);
|
||||
float offset = 0.0;
|
||||
if(speed != 0.0)
|
||||
{
|
||||
offset = gF_SmallestDist[client] / speed;
|
||||
}
|
||||
|
||||
float offset = gF_Fraction[client] * GetTickInterval();
|
||||
|
||||
gA_Timers[client].fTimeOffset[zonetype] = offset;
|
||||
gA_Timers[client].fDistanceOffset[zonetype] = gF_SmallestDist[client];
|
||||
@ -3056,6 +3051,7 @@ bool TREnumTrigger(int entity, int client) {
|
||||
|
||||
float distance = GetVectorDistance(start, end);
|
||||
gF_SmallestDist[client] = distance;
|
||||
gF_Fraction[client] = TR_GetFraction();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -124,6 +124,7 @@ float gV_MapZones[MAX_ZONES][2][3];
|
||||
float gV_MapZones_Visual[MAX_ZONES][8][3];
|
||||
float gV_Destinations[MAX_ZONES][3];
|
||||
float gV_ZoneCenter[MAX_ZONES][3];
|
||||
int gI_StageZoneID[MAX_ZONES];
|
||||
int gI_EntityZone[4096];
|
||||
bool gB_ZonesCreated = false;
|
||||
|
||||
@ -181,6 +182,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
||||
// zone natives
|
||||
CreateNative("Shavit_GetZoneData", Native_GetZoneData);
|
||||
CreateNative("Shavit_GetZoneFlags", Native_GetZoneFlags);
|
||||
CreateNative("Shavit_GetStageZone", Native_GetStageZone);
|
||||
CreateNative("Shavit_InsideZone", Native_InsideZone);
|
||||
CreateNative("Shavit_InsideZoneGetID", Native_InsideZoneGetID);
|
||||
CreateNative("Shavit_IsClientCreatingZone", Native_IsClientCreatingZone);
|
||||
@ -487,6 +489,13 @@ public int Native_InsideZoneGetID(Handle handler, int numParams)
|
||||
return false;
|
||||
}
|
||||
|
||||
public int Native_GetStageZone(Handle handler, int numParams)
|
||||
{
|
||||
int iStageNumber = GetNativeCell(1);
|
||||
|
||||
return gI_StageZoneID[iStageNumber];
|
||||
}
|
||||
|
||||
public int Native_Zones_DeleteMap(Handle handler, int numParams)
|
||||
{
|
||||
char sMap[160];
|
||||
@ -662,7 +671,8 @@ public void OnMapStart()
|
||||
ReloadPrebuiltZones();
|
||||
UnloadZones(0);
|
||||
RefreshZones();
|
||||
|
||||
LoadStageZones();
|
||||
|
||||
LoadZoneSettings();
|
||||
|
||||
if(gEV_Type == Engine_TF2)
|
||||
@ -688,6 +698,30 @@ public void OnMapStart()
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadStageZones()
|
||||
{
|
||||
char sQuery[256];
|
||||
FormatEx(sQuery, 256, "SELECT id, data FROM mapzones WHERE type = %i and map = '%s'", Zone_Stage, gS_Map);
|
||||
PrintToChatAll("%s", sQuery);
|
||||
gH_SQL.Query(SQL_GetStageZone_Callback, sQuery,0, DBPrio_High);
|
||||
}
|
||||
|
||||
public void SQL_GetStageZone_Callback(Database db, DBResultSet results, const char[] error, any data)
|
||||
{
|
||||
if(results == null)
|
||||
{
|
||||
LogError("Timer (zones GetStageZone) SQL query failed. Reason: %s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
while(results.FetchRow())
|
||||
{
|
||||
int iZoneID = results.FetchInt(0);
|
||||
int iStageNumber = results.FetchInt(1);
|
||||
gI_StageZoneID[iStageNumber] = iZoneID;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMapEnd()
|
||||
{
|
||||
delete gH_DrawEverything;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user