Fix compilation for shavit-misc

This commit is contained in:
shavitush 2016-09-10 16:48:54 +03:00
parent 04c50793f1
commit 4387e63baf
3 changed files with 37 additions and 11 deletions

View File

@ -652,18 +652,24 @@ native void Shavit_OpenStatsMenu(int client, const char[] authid);
native int Shavit_GetWRCount(int client);
/**
* Saves the style settings on an `any` reference.
* Saves the style settings on `any` references.
*
* @noreturn
* @param style Style index.
* @param StyleSettings Reference to the settings array.
* @return SP_ERROR_NONE on success, anything else on failure.
*/
native void Shavit_GetStyleSettings(any StyleSettings[STYLE_LIMIT][STYLESETTINGS_SIZE]);
native int Shavit_GetStyleSettings(BhopStyle style, any StyleSettings[STYLESETTINGS_SIZE]);
/**
* Saves the style related strings on a string reference.
* Saves the style related strings on string references.
*
* @noreturn
* @param style Style index.
* @param stringtype String type to grab.
* @param StyleStrings Reference to the string buffer.
* @param size Max length for the buffer.
* @return SP_ERROR_NONE on success, anything else on failure.
*/
native void Shavit_GetStyleStrings(char StyleStrings[STYLE_LIMIT][STYLESTRINGS_SIZE][128]);
native int Shavit_GetStyleStrings(BhopStyle style, int stringtype, char[] StyleStrings, int size);
/**
* Use this native when printing anything in chat if it's related to the timer.

View File

@ -145,6 +145,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Shavit_GetStrafeCount", Native_GetStrafeCount);
CreateNative("Shavit_GetSync", Native_GetSync);
CreateNative("Shavit_GetStyleSettings", Native_GetStyleSettings);
CreateNative("Shavit_GetStyleStrings", Native_GetStyleStrings);
// registers library, check "bool LibraryExists(const char[] name)" in order to use with other plugins
RegPluginLibrary("shavit");
@ -768,7 +769,12 @@ public int Native_GetSync(Handle handler, int numParams)
public int Native_GetStyleSettings(Handle handler, int numParams)
{
return view_as<int>(2);
return SetNativeArray(2, gA_StyleSettings[GetNativeCell(1)], STYLESETTINGS_SIZE);
}
public int Native_GetStyleStrings(Handle handler, int numParams)
{
return SetNativeString(4, gS_StyleStrings[GetNativeCell(1)][GetNativeCell(2)], GetNativeCell(3));
}
public void StartTimer(int client)

View File

@ -32,6 +32,7 @@
#pragma newdecls required
#pragma semicolon 1
#pragma dynamic 131072
// game specific
EngineVersion gEV_Type = Engine_Unknown;
int gI_Ammo = -1;
@ -93,6 +94,10 @@ Handle gH_GetPlayerMaxSpeed = null;
// modules
bool gB_Rankings = false;
// timer settings
char gS_StyleStrings[STYLE_LIMIT][STYLESTRINGS_SIZE][128];
any gA_StyleSettings[STYLE_LIMIT][STYLESETTINGS_SIZE];
public Plugin myinfo =
{
name = "[shavit] Miscellaneous",
@ -242,6 +247,15 @@ public void OnPluginStart()
}
}
public void Shavit_OnStyleConfigLoaded(int styles)
{
for(int i = 0; i < styles; i++)
{
Shavit_GetStyleSettings(view_as<BhopStyle>(i), gA_StyleSettings[i]);
Shavit_GetStyleStrings(view_as<BhopStyle>(i), sStyleName, gS_StyleStrings[i][sStyleName], 128);
}
}
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
gI_GodMode = gCV_GodMode.IntValue;
@ -395,7 +409,7 @@ public MRESReturn DHook_GetMaxPlayerSpeed(int pThis, Handle hReturn)
return MRES_Ignored;
}
DHookSetReturn(hReturn, ((gI_StyleProperties[Shavit_GetBhopStyle(pThis)] & STYLE_260PRESTRAFE) > 0)? 260.00:250.00);
DHookSetReturn(hReturn, gA_StyleSettings[Shavit_GetBhopStyle(pThis)][fRunspeed]);
return MRES_Override;
}
@ -466,7 +480,7 @@ public Action OnPlayerRunCmd(int client, int &buttons)
}
// prespeed
if((gI_StyleProperties[Shavit_GetBhopStyle(client)] & STYLE_PRESPEED) == 0 && bInStart)
if(!gA_StyleSettings[Shavit_GetBhopStyle(client)][bPrespeed] && bInStart)
{
if((gI_PreSpeed == 2 || gI_PreSpeed == 3) && (gI_LastFlags[client] & FL_ONGROUND) > 0 && (GetEntityFlags(client) & FL_ONGROUND) > 0 && (buttons & IN_JUMP) > 0)
{
@ -987,8 +1001,8 @@ public Action Command_Specs(int client, int args)
public void Shavit_OnWorldRecord(int client, BhopStyle style, float time, int jumps)
{
char[] sUpperCase = new char[32];
strcopy(sUpperCase, 32, gS_BhopStyles[view_as<int>(style)]);
char[] sUpperCase = new char[64];
strcopy(sUpperCase, 64, gS_StyleStrings[style][sStyleName]);
for(int i = 0; i < strlen(sUpperCase); i++)
{