remove stylesettings_t and break 3rd party plugins

This commit is contained in:
rtldg 2021-04-08 21:19:18 +00:00
parent 6e410dedb7
commit cb39acc33b
6 changed files with 7 additions and 248 deletions

View File

@ -62,7 +62,6 @@ enum //ReplayStatus
enum //ReplayBotType
{
Replay_Central,
Replay_Legacy, // TODO: REMOVE
Replay_Looping, // these are the ones that loop styles, tracks, and (eventually) stages...
Replay_Dynamic, // these are bots that spawn on !replay when the central bot is taken
Replay_Prop, // A prop entity that is being used as a replay...
@ -156,49 +155,6 @@ enum struct stylestrings_t
char sStylePermission[64];
}
//TODO:REMOVE IN 3.0
enum struct stylesettings_t
{
bool bAutobhop;
bool bEasybhop;
int iPrespeed;
float fVelocityLimit;
bool bEnableBunnyhopping;
float fAiraccelerate;
float fRunspeed;
float fGravityMultiplier;
float fSpeedMultiplier;
float fTimescale;
float fVelocity;
float fBonusVelocity;
float fMinVelocity;
bool bBlockW;
bool bBlockA;
bool bBlockS;
bool bBlockD;
bool bBlockUse;
int iForceHSW;
int iBlockPLeft;
int iBlockPRight;
int iBlockPStrafe;
bool bUnranked;
bool bNoReplay;
bool bSync;
bool bStrafeCountW;
bool bStrafeCountA;
bool bStrafeCountS;
bool bStrafeCountD;
float fRankingMultiplier;
int iSpecial;
int iOrdering;
bool bInaccessible;
int iEnabled;
bool bKZCheckpoints;
bool bForceKeysOnGround;
float fJumpMultiplier;
float fJumpBonus;
}
enum struct chatstrings_t
{
char sPrefix[64];
@ -550,11 +506,10 @@ stock int GetSpectatorTarget(int client, int fallback = -1)
* @param status The player's timer status.
* @param track The player's timer track.
* @param style The player's bhop style.
* @param stylesettings A stylesettings_t struct that contains the player's bhop style's settings.
* @param mouse Mouse direction (x, y).
* @return Plugin_Continue to let shavit-core keep doing what it does, Plugin_Changed to pass different values.
*/
forward Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, stylesettings_t stylesettings, int mouse[2]);
forward Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, int mouse[2]);
/**
* Called just before shavit-core adds time to a player's timer.
@ -564,10 +519,9 @@ forward Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
* @param client Client index.
* @param snapshot A snapshot with the player's current timer. You cannot manipulate it here.
* @param time The time to be added to the player's timer.
* @param stylesettings A stylesettings_t struct that contains the player's bhop style's settings.
* @noreturn
*/
forward void Shavit_OnTimeIncrement(int client, timer_snapshot_t snapshot, float &time, stylesettings_t stylesettings);
forward void Shavit_OnTimeIncrement(int client, timer_snapshot_t snapshot, float &time);
/**
* Called just before shavit-core adds time to a player's timer.
@ -577,10 +531,9 @@ forward void Shavit_OnTimeIncrement(int client, timer_snapshot_t snapshot, float
* @param client Client index.
* @param snapshot A snapshot with the player's current timer. Read above in shavit.inc for more information.
* @param time The time to be added to the player's timer.
* @param stylesettings A stylesettings_t struct that contains the player's bhop style's settings.
* @noreturn
*/
forward void Shavit_OnTimeIncrementPost(int client, float time, stylesettings_t stylesettings);
forward void Shavit_OnTimeIncrementPost(int client, float time);
/**
* Called when a player's timer starts.
@ -1065,23 +1018,6 @@ forward void Shavit_OnProcessMovement(int client);
*/
forward void Shavit_OnProcessMovementPost(int client);
/**
* Returns the game type the server is running.
*
* @return Game type. (See "enum ServerGame")
*/
#pragma deprecated Use GetEngineVersion() instead.
native EngineVersion Shavit_GetGameType();
/**
* Returns the database handle the timer is using.
*
* @param hSQL Handle to store the database on.
* @noreturn
*/
#pragma deprecated Use Shavit_GetDatabase() instead.
native void Shavit_GetDB(Database &hSQL);
/**
* Returns bhoptimer's database handle.
* Call within Shavit_OnDatabaseLoaded. Safety is not guaranteed anywhere else!
@ -1197,19 +1133,6 @@ native bool Shavit_ChangeClientStyle(int client, int style, bool force = false,
*/
native void Shavit_FinishMap(int client, int track);
/**
* Stores the player's timer stats on variables
*
* @param client Client index.
* @param time Time passed since the player started.
* @param jumps How many times the player jumped since he started.
* @param style Style, check "enum BhopStyle"
* @param started Timer started?
* @noreturn
*/
#pragma deprecated Use different natives or Shavit_SaveSnapshot instead.
native void Shavit_GetTimer(int client, float &time, int &jumps, int &style, bool &started);
/**
* Retrieve a client's current time.
*
@ -1286,17 +1209,6 @@ native float Shavit_GetPerfectJumps(int client);
*/
native float Shavit_GetSync(int client);
/**
* Saves the WR time for the current map on a variable.
*
* @param style Style to get the WR for.
* @param time Reference to the time variable. 0.0 will be returned if no records.
* @param track Timer track.
* @noreturn
*/
#pragma deprecated Use Shavit_GetWorldRecord() instead.
native void Shavit_GetWRTime(int style, float &time, int track);
/**
* Retrieves the world record for the given style/track.
*
@ -1335,18 +1247,6 @@ native void Shavit_GetWRRecordID(int style, int &recordid, int track);
*/
native void Shavit_GetWRName(int style, char[] wrname, int wrmaxlength, int track);
/**
* Saves the player's personal best time on a variable.
*
* @param client Client index.
* @param style Style to get the PB for.
* @param time Reference to the time variable. 0.0 will be returned if no personal record.
* @param track Timer track.
* @noreturn
*/
#pragma deprecated Use Shavit_GetClientPB() instead.
native void Shavit_GetPlayerPB(int client, int style, float &time, int track);
/**
* Retrieves the best time of a player.
*
@ -1833,17 +1733,6 @@ native bool Shavit_SetStyleSettingBool(int style, const char[] key, bool value,
*/
native bool Shavit_SetStyleSettingInt(int style, const char[] key, int value, bool replace = true);
/**
* Saves the style settings on `any` references.
*
* @param style Style index.
* @param StyleSettings Reference to the settings array.
* @param size Size of the StyleSettings buffer, e.g sizeof(stylesettings_t)
* @return SP_ERROR_NONE on success, anything else on failure.
*/
#pragma deprecated Use different natives or Shavit_GetStyleSetting instead.
native int Shavit_GetStyleSettings(int style, any[] StyleSettings, int size = sizeof(stylesettings_t));
/**
* Saves the style related strings on string references.
*
@ -2423,13 +2312,11 @@ public void __pl_shavit_SetNTVOptional()
MarkNativeAsOptional("Shavit_GetClientTime");
MarkNativeAsOptional("Shavit_GetClientTrack");
MarkNativeAsOptional("Shavit_GetDatabase");
MarkNativeAsOptional("Shavit_GetDB");
MarkNativeAsOptional("Shavit_GetHUDSettings");
MarkNativeAsOptional("Shavit_GetMapTier");
MarkNativeAsOptional("Shavit_GetMapTiers");
MarkNativeAsOptional("Shavit_GetOrderedStyles");
MarkNativeAsOptional("Shavit_GetPerfectJumps");
MarkNativeAsOptional("Shavit_GetPlayerPB");
MarkNativeAsOptional("Shavit_GetPoints");
MarkNativeAsOptional("Shavit_GetRank");
MarkNativeAsOptional("Shavit_GetRankedPlayers");
@ -2457,13 +2344,11 @@ public void __pl_shavit_SetNTVOptional()
MarkNativeAsOptional("Shavit_GetStyleSettingInt");
MarkNativeAsOptional("Shavit_GetStyleSettingFloat");
MarkNativeAsOptional("Shavit_HasStyleSetting");
MarkNativeAsOptional("Shavit_GetStyleSettings");
MarkNativeAsOptional("Shavit_GetStyleStrings");
MarkNativeAsOptional("Shavit_GetSync");
MarkNativeAsOptional("Shavit_GetTimeOffset");
MarkNativeAsOptional("Shavit_GetDistanceOffset");
MarkNativeAsOptional("Shavit_GetTimeForRank");
MarkNativeAsOptional("Shavit_GetTimer");
MarkNativeAsOptional("Shavit_GetTimerStatus");
MarkNativeAsOptional("Shavit_GetWorldRecord");
MarkNativeAsOptional("Shavit_GetWRCount");
@ -2471,7 +2356,6 @@ public void __pl_shavit_SetNTVOptional()
MarkNativeAsOptional("Shavit_GetWRHolderRank");
MarkNativeAsOptional("Shavit_GetWRName");
MarkNativeAsOptional("Shavit_GetWRRecordID");
MarkNativeAsOptional("Shavit_GetWRTime");
MarkNativeAsOptional("Shavit_GetZoneData");
MarkNativeAsOptional("Shavit_GetZoneFlags");
MarkNativeAsOptional("Shavit_HasStyleAccess");

View File

@ -162,7 +162,6 @@ ConVar sv_enablebunnyhopping = null;
bool gB_Registered = false;
int gI_Styles = 0;
int gI_OrderedStyles[STYLE_LIMIT];
stylesettings_t gA_StyleSettings[STYLE_LIMIT];
StringMap gSM_StyleKeys[STYLE_LIMIT];
int gI_CurrentParserIndex = 0;
@ -207,8 +206,6 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Shavit_GetClientTime", Native_GetClientTime);
CreateNative("Shavit_GetClientTrack", Native_GetClientTrack);
CreateNative("Shavit_GetDatabase", Native_GetDatabase);
CreateNative("Shavit_GetDB", Native_GetDB);
CreateNative("Shavit_GetGameType", Native_GetGameType);
CreateNative("Shavit_GetOrderedStyles", Native_GetOrderedStyles);
CreateNative("Shavit_GetPerfectJumps", Native_GetPerfectJumps);
CreateNative("Shavit_GetStrafeCount", Native_GetStrafeCount);
@ -218,12 +215,10 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Shavit_GetStyleSettingBool", Native_GetStyleSettingBool);
CreateNative("Shavit_GetStyleSettingFloat", Native_GetStyleSettingFloat);
CreateNative("Shavit_HasStyleSetting", Native_HasStyleSetting);
CreateNative("Shavit_GetStyleSettings", Native_GetStyleSettings);
CreateNative("Shavit_GetStyleStrings", Native_GetStyleStrings);
CreateNative("Shavit_GetSync", Native_GetSync);
CreateNative("Shavit_GetTimeOffset", Native_GetTimeOffset);
CreateNative("Shavit_GetDistanceOffset", Native_GetTimeOffsetDistance);
CreateNative("Shavit_GetTimer", Native_GetTimer);
CreateNative("Shavit_GetTimerStatus", Native_GetTimerStatus);
CreateNative("Shavit_HasStyleAccess", Native_HasStyleAccess);
CreateNative("Shavit_IsKZMap", Native_IsKZMap);
@ -1448,11 +1443,6 @@ public void Player_Death(Event event, const char[] name, bool dontBroadcast)
StopTimer(client);
}
public int Native_GetGameType(Handle handler, int numParams)
{
return view_as<int>(gEV_Type);
}
public int Native_GetOrderedStyles(Handle handler, int numParams)
{
return SetNativeArray(1, gI_OrderedStyles, GetNativeCell(2));
@ -1463,23 +1453,6 @@ public int Native_GetDatabase(Handle handler, int numParams)
return view_as<int>(CloneHandle(gH_SQL, handler));
}
public int Native_GetDB(Handle handler, int numParams)
{
SetNativeCellRef(1, gH_SQL);
}
public int Native_GetTimer(Handle handler, int numParams)
{
// 1 - client
int client = GetNativeCell(1);
// 2 - time
SetNativeCellRef(2, gA_Timers[client].fTimer);
SetNativeCellRef(3, gA_Timers[client].iJumps);
SetNativeCellRef(4, gA_Timers[client].iStyle);
SetNativeCellRef(5, gA_Timers[client].bEnabled);
}
public int Native_GetClientTime(Handle handler, int numParams)
{
return view_as<int>(gA_Timers[GetNativeCell(1)].fTimer);
@ -1899,19 +1872,6 @@ public int Native_GetStyleCount(Handle handler, int numParams)
return (gI_Styles > 0)? gI_Styles:-1;
}
public int Native_GetStyleSettings(Handle handler, int numParams)
{
LogError("Shavit_GetStyleSettings is deprecated and will be removed in 3.0. Use Shavit_GetStyleSetting instead");
if(GetNativeCell(3) != sizeof(stylesettings_t))
{
return ThrowNativeError(200, "stylesettings_t does not match latest(got %i expected %i). Please update your includes and recompile your plugins",
GetNativeCell(3), sizeof(stylesettings_t));
}
return SetNativeArray(2, gA_StyleSettings[GetNativeCell(1)], sizeof(stylesettings_t));
}
public int Native_GetStyleStrings(Handle handler, int numParams)
{
int style = GetNativeCell(1);
@ -2582,75 +2542,6 @@ bool LoadStyles()
parser.ParseFile(sPath);
delete parser;
// TODO: REMOVE IN 3.0
// These are being left in as a backwards compatibility for the forwards using the style settings struct.
// Forwards seem to be fairly safe but will eventually be deprecated in favor of removing enum struct api usage.
KeyValues kv = new KeyValues("shavit-styles");
if(!kv.ImportFromFile(sPath) || !kv.GotoFirstSubKey())
{
delete kv;
return false;
}
int i = 0;
do
{
gA_StyleSettings[i].bAutobhop = view_as<bool>(kv.GetNum("autobhop", 1));
gA_StyleSettings[i].bEasybhop = view_as<bool>(kv.GetNum("easybhop", 1));
gA_StyleSettings[i].iPrespeed = view_as<bool>(kv.GetNum("prespeed", 0));
gA_StyleSettings[i].fVelocityLimit = kv.GetFloat("velocity_limit", 0.0);
gA_StyleSettings[i].fAiraccelerate = kv.GetFloat("airaccelerate", 1000.0);
gA_StyleSettings[i].bEnableBunnyhopping = view_as<bool>(kv.GetNum("bunnyhopping", 1));
gA_StyleSettings[i].fRunspeed = kv.GetFloat("runspeed", 260.00);
gA_StyleSettings[i].fGravityMultiplier = kv.GetFloat("gravity", 1.0);
gA_StyleSettings[i].fSpeedMultiplier = kv.GetFloat("speed", 1.0);
gA_StyleSettings[i].fTimescale = view_as<bool>(kv.GetNum("halftime", 0))? 0.5:kv.GetFloat("timescale", 1.0); // backwards compat for old halftime settig
gA_StyleSettings[i].fVelocity = kv.GetFloat("velocity", 1.0);
gA_StyleSettings[i].fBonusVelocity = kv.GetFloat("bonus_velocity", 0.0);
gA_StyleSettings[i].fMinVelocity = kv.GetFloat("min_velocity", 0.0);
gA_StyleSettings[i].fJumpMultiplier = kv.GetFloat("jump_multiplier", 0.0);
gA_StyleSettings[i].fJumpBonus = kv.GetFloat("jump_bonus", 0.0);
gA_StyleSettings[i].bBlockW = view_as<bool>(kv.GetNum("block_w", 0));
gA_StyleSettings[i].bBlockA = view_as<bool>(kv.GetNum("block_a", 0));
gA_StyleSettings[i].bBlockS = view_as<bool>(kv.GetNum("block_s", 0));
gA_StyleSettings[i].bBlockD = view_as<bool>(kv.GetNum("block_d", 0));
gA_StyleSettings[i].bBlockUse = view_as<bool>(kv.GetNum("block_use", 0));
gA_StyleSettings[i].iForceHSW = kv.GetNum("force_hsw", 0);
gA_StyleSettings[i].iBlockPLeft = kv.GetNum("block_pleft", 0);
gA_StyleSettings[i].iBlockPRight = kv.GetNum("block_pright", 0);
gA_StyleSettings[i].iBlockPStrafe = kv.GetNum("block_pstrafe", 0);
gA_StyleSettings[i].bUnranked = view_as<bool>(kv.GetNum("unranked", 0));
gA_StyleSettings[i].bNoReplay = view_as<bool>(kv.GetNum("noreplay", 0));
gA_StyleSettings[i].bSync = view_as<bool>(kv.GetNum("sync", 1));
gA_StyleSettings[i].bStrafeCountW = view_as<bool>(kv.GetNum("strafe_count_w", false));
gA_StyleSettings[i].bStrafeCountA = view_as<bool>(kv.GetNum("strafe_count_a", true));
gA_StyleSettings[i].bStrafeCountS = view_as<bool>(kv.GetNum("strafe_count_s", false));
gA_StyleSettings[i].bStrafeCountD = view_as<bool>(kv.GetNum("strafe_count_d", true));
gA_StyleSettings[i].fRankingMultiplier = kv.GetFloat("rankingmultiplier", 1.00);
gA_StyleSettings[i].iSpecial = kv.GetNum("special", 0);
gA_StyleSettings[i].iOrdering = kv.GetNum("ordering", i);
gA_StyleSettings[i].bInaccessible = view_as<bool>(kv.GetNum("inaccessible", false));
gA_StyleSettings[i].iEnabled = kv.GetNum("enabled", 1);
gA_StyleSettings[i].bKZCheckpoints = view_as<bool>(kv.GetNum("kzcheckpoints", 0));
gA_StyleSettings[i].bForceKeysOnGround = view_as<bool>(kv.GetNum("force_groundkeys", 0));
// if this style is disabled, we will force certain settings
if(gA_StyleSettings[i].iEnabled <= 0)
{
gA_StyleSettings[i].bNoReplay = true;
gA_StyleSettings[i].fRankingMultiplier = 0.0;
gA_StyleSettings[i].bInaccessible = true;
}
}
while(kv.GotoNextKey());
delete kv;
gB_Registered = true;
SortCustom1D(gI_OrderedStyles, gI_Styles, SortAscending_StyleOrder);
@ -2779,7 +2670,7 @@ public SMCResult OnStyleLeaveSection(SMCParser smc)
char sName[64];
gSM_StyleKeys[gI_CurrentParserIndex].GetString("name", sName, 64);
if(!gB_Registered && strlen(sStyleCommand) > 0 && !gA_StyleSettings[gI_CurrentParserIndex].bInaccessible)
if(!gB_Registered && strlen(sStyleCommand) > 0 && !GetStyleSettingBool(gI_CurrentParserIndex, "inaccessible"))
{
char sStyleCommands[32][32];
int iCommands = ExplodeString(sStyleCommand, ";", sStyleCommands, 32, 32, false);
@ -3480,9 +3371,6 @@ public MRESReturn DHook_ProcessMovementPost(Handle hParams)
Call_PushCell(client);
Call_PushArray(snapshot, sizeof(timer_snapshot_t));
Call_PushCellRef(time);
//TODO:REMOVE IN 3.0
Call_PushArray(gA_StyleSettings[gA_Timers[client].iStyle], sizeof(stylesettings_t));
// Call_PushArray(NULL_VECTOR, sizeof(NULL_VECTOR));
Call_Finish();
gA_Timers[client].fTimer += time;
@ -3490,9 +3378,6 @@ public MRESReturn DHook_ProcessMovementPost(Handle hParams)
Call_StartForward(gH_Forwards_OnTimerIncrementPost);
Call_PushCell(client);
Call_PushCell(time);
//TODO:REMOVE IN 3.0
// Call_PushArray(NULL_VECTOR, sizeof(NULL_VECTOR));
Call_PushArray(gA_StyleSettings[gA_Timers[client].iStyle], sizeof(stylesettings_t));
Call_Finish();
return MRES_Ignored;
@ -3626,9 +3511,6 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
Call_PushCell(GetTimerStatus(client));
Call_PushCell(gA_Timers[client].iTrack);
Call_PushCell(gA_Timers[client].iStyle);
//TODO:REMOVE IN 3.0
Call_PushArray(gA_StyleSettings[gA_Timers[client].iStyle], sizeof(stylesettings_t));
// Call_PushArray(NULL_VECTOR, sizeof(NULL_VECTOR));
Call_PushArrayEx(mouse, 2, SM_PARAM_COPYBACK);
Call_Finish(result);

View File

@ -400,7 +400,7 @@ void MakeAngleDiff(int client, float newAngle)
gF_AngleDiff[client] = fAngleDiff - 360.0 * RoundToFloor((fAngleDiff + 180.0) / 360.0);
}
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, stylesettings_t stylsettings)
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style)
{
gI_Buttons[client] = buttons;
MakeAngleDiff(client, angles[1]);

View File

@ -1090,7 +1090,7 @@ void RemoveRagdoll(int client)
}
}
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, stylesettings_t stylesettings)
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style)
{
bool bNoclip = (GetEntityMoveType(client) == MOVETYPE_NOCLIP);
bool bInStart = Shavit_InsideZone(client, Zone_Start, track);

View File

@ -102,7 +102,6 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
// natives
CreateNative("Shavit_GetClientPB", Native_GetClientPB);
CreateNative("Shavit_SetClientPB", Native_SetClientPB);
CreateNative("Shavit_GetPlayerPB", Native_GetPlayerPB);
CreateNative("Shavit_GetClientCompletions", Native_GetClientCompletions);
CreateNative("Shavit_GetRankForTime", Native_GetRankForTime);
CreateNative("Shavit_GetRecordAmount", Native_GetRecordAmount);
@ -110,7 +109,6 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Shavit_GetWorldRecord", Native_GetWorldRecord);
CreateNative("Shavit_GetWRName", Native_GetWRName);
CreateNative("Shavit_GetWRRecordID", Native_GetWRRecordID);
CreateNative("Shavit_GetWRTime", Native_GetWRTime);
CreateNative("Shavit_ReloadLeaderboards", Native_ReloadLeaderboards);
CreateNative("Shavit_WR_DeleteMap", Native_WR_DeleteMap);
CreateNative("Shavit_DeleteWR", Native_DeleteWR);
@ -565,11 +563,6 @@ public int Native_GetWorldRecord(Handle handler, int numParams)
return view_as<int>(gF_WRTime[GetNativeCell(1)][GetNativeCell(2)]);
}
public int Native_GetWRTime(Handle handler, int numParams)
{
SetNativeCellRef(2, gF_WRTime[GetNativeCell(1)][GetNativeCell(3)]);
}
public int Native_ReloadLeaderboards(Handle handler, int numParams)
{
//UpdateLeaderboards(); // Called by UpdateWRCache->SQL_UpdateWRCache_Callback

View File

@ -2356,7 +2356,7 @@ public bool TraceFilter_World(int entity, int contentsMask)
return (entity == 0);
}
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, stylesettings_t stylesettings)
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style)
{
if(gI_MapStep[client] > 0 && gI_MapStep[client] != 3)
{