Update include to fix warnings and errors related to transitional syntax. Use transitional syntax

This commit is contained in:
Dr!fter 2015-03-26 16:51:15 -04:00
parent 881a839896
commit 9b43516dee

View File

@ -2,6 +2,7 @@
#endinput #endinput
#endif #endif
#define _dhooks_included #define _dhooks_included
enum ObjectValueType enum ObjectValueType
{ {
ObjectValueType_Int = 0, ObjectValueType_Int = 0,
@ -18,11 +19,13 @@ enum ObjectValueType
ObjectValueType_CharPtr, ObjectValueType_CharPtr,
ObjectValueType_String ObjectValueType_String
}; };
enum ListenType enum ListenType
{ {
ListenType_Created, ListenType_Created,
ListenType_Deleted ListenType_Deleted
}; };
enum ReturnType enum ReturnType
{ {
ReturnType_Unknown, ReturnType_Unknown,
@ -38,6 +41,7 @@ enum ReturnType
ReturnType_CBaseEntity, ReturnType_CBaseEntity,
ReturnType_Edict ReturnType_Edict
}; };
enum HookParamType enum HookParamType
{ {
HookParamType_Unknown, HookParamType_Unknown,
@ -53,18 +57,21 @@ enum HookParamType
HookParamType_Edict, HookParamType_Edict,
HookParamType_Object HookParamType_Object
}; };
enum ThisPointerType enum ThisPointerType
{ {
ThisPointer_Ignore, ThisPointer_Ignore,
ThisPointer_CBaseEntity, ThisPointer_CBaseEntity,
ThisPointer_Address ThisPointer_Address
}; };
enum HookType enum HookType
{ {
HookType_Entity, HookType_Entity,
HookType_GameRules, HookType_GameRules,
HookType_Raw HookType_Raw
}; };
enum MRESReturn enum MRESReturn
{ {
MRES_ChangedHandled = -2, // Use changed values and return MRES_Handled MRES_ChangedHandled = -2, // Use changed values and return MRES_Handled
@ -74,63 +81,68 @@ enum MRESReturn
MRES_Override, // call real function, but use my return value MRES_Override, // call real function, but use my return value
MRES_Supercede // skip real function; use my return value MRES_Supercede // skip real function; use my return value
}; };
enum DHookPassFlag enum DHookPassFlag
{ {
DHookPass_ByVal = (1<<0), DHookPass_ByVal = (1<<0),
DHookPass_ByRef = (1<<1) DHookPass_ByRef = (1<<1)
}; };
funcenum ListenCB
typeset ListenCB
{ {
//Deleted //Deleted
public (entity), function void (int entity);
//Created //Created
public (entity, const String:classname[]) function void (int entity, const char[] classname);
}
funcenum DHookRemovalCB
{
public (hookid)
}; };
funcenum DHookCallback
typeset DHookRemovalCB
{
function void (int hookid);
};
typeset DHookCallback
{ {
//Function Example: void Ham::Test() with this pointer ignore //Function Example: void Ham::Test() with this pointer ignore
MRESReturn:public(), function MRESReturn ();
//Function Example: void Ham::Test() with this pointer passed //Function Example: void Ham::Test() with this pointer passed
MRESReturn:public(this), function MRESReturn (int pThis);
//Function Example: void Ham::Test(int cake) with this pointer ignore //Function Example: void Ham::Test(int cake) with this pointer ignore
MRESReturn:public(Handle:hParams), function MRESReturn (Handle hParams);
//Function Example: void Ham::Test(int cake) with this pointer passed //Function Example: void Ham::Test(int cake) with this pointer passed
MRESReturn:public(this, Handle:hParams), function MRESReturn (int pThis, Handle hParams);
//Function Example: int Ham::Test() with this pointer ignore //Function Example: int Ham::Test() with this pointer ignore
MRESReturn:public(Handle:hReturn), function MRESReturn (Handle hReturn);
//Function Example: int Ham::Test() with this pointer passed //Function Example: int Ham::Test() with this pointer passed
MRESReturn:public(this, Handle:hReturn), function MRESReturn (int pThis, Handle hReturn);
//Function Example: int Ham::Test(int cake) with this pointer ignore //Function Example: int Ham::Test(int cake) with this pointer ignore
MRESReturn:public(Handle:hReturn, Handle:hParams), function MRESReturn (Handle hReturn, Handle hParams);
//Function Example: int Ham::Test(int cake) with this pointer passed //Function Example: int Ham::Test(int cake) with this pointer passed
MRESReturn:public(this, Handle:hReturn, Handle:hParams), function MRESReturn (int pThis, Handle hReturn, Handle hParams);
//Address NOW //Address NOW
//Function Example: void Ham::Test() with this pointer passed //Function Example: void Ham::Test() with this pointer passed
MRESReturn:public(Address:this), function MRESReturn (Address pThis);
//Function Example: void Ham::Test(int cake) with this pointer passed //Function Example: void Ham::Test(int cake) with this pointer passed
MRESReturn:public(Address:this, Handle:hParams), function MRESReturn (Address pThis, Handle hParams);
//Function Example: int Ham::Test() with this pointer passed //Function Example: int Ham::Test() with this pointer passed
MRESReturn:public(Address:this, Handle:hReturn), function MRESReturn (Address pThis, Handle hReturn);
//Function Example: int Ham::Test(int cake) with this pointer passed //Function Example: int Ham::Test(int cake) with this pointer passed
MRESReturn:public(Address:this, Handle:hReturn, Handle:hParams) function MRESReturn (Address pThis, Handle hReturn, Handle hParams);
}; };
/* Adds an entity listener hook /* Adds an entity listener hook
* *
* @param type Type of listener to add * @param type Type of listener to add
@ -138,7 +150,7 @@ funcenum DHookCallback
* *
* @noreturn * @noreturn
*/ */
native DHookAddEntityListener(ListenType:type, ListenCB:callback); native void DHookAddEntityListener(ListenType type, ListenCB callback);
/* Removes an entity listener hook /* Removes an entity listener hook
* *
@ -147,7 +159,7 @@ native DHookAddEntityListener(ListenType:type, ListenCB:callback);
* *
* @return True if one was removed false otherwise. * @return True if one was removed false otherwise.
*/ */
native bool:DHookRemoveEntityListener(ListenType:type, ListenCB:callback); native bool DHookRemoveEntityListener(ListenType type, ListenCB callback);
/* Creates a hook /* Creates a hook
* *
@ -159,7 +171,7 @@ native bool:DHookRemoveEntityListener(ListenType:type, ListenCB:callback);
* *
* @return Returns setup handle for the hook or INVALID_HANDLE. * @return Returns setup handle for the hook or INVALID_HANDLE.
*/ */
native Handle:DHookCreate(offset, HookType:hooktype, ReturnType:returntype, ThisPointerType:thistype, DHookCallback:callback); native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback);
/* Adds param to a hook setup /* Adds param to a hook setup
* *
@ -171,7 +183,7 @@ native Handle:DHookCreate(offset, HookType:hooktype, ReturnType:returntype, This
* @error Invalid setup handle or too many params added (request upping the max in thread) * @error Invalid setup handle or too many params added (request upping the max in thread)
* @noreturn * @noreturn
*/ */
native DHookAddParam(Handle:setup, HookParamType:type, size=-1, DHookPassFlag:flag=DHookPass_ByVal); native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal);
//native DHookAddParam(Handle:setup, HookParamType:type); //native DHookAddParam(Handle:setup, HookParamType:type);
/* Hook entity /* Hook entity
@ -184,7 +196,7 @@ native DHookAddParam(Handle:setup, HookParamType:type, size=-1, DHookPassFlag:fl
* @error Invalid setup handle, invalid entity or invalid hook type. * @error Invalid setup handle, invalid entity or invalid hook type.
* @return -1 on fail a hookid on success * @return -1 on fail a hookid on success
*/ */
native DHookEntity(Handle:setup, bool:post, entity, DHookRemovalCB:removalcb=DHookRemovalCB:-1); native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION);
/* Hook gamerules /* Hook gamerules
* *
@ -195,7 +207,7 @@ native DHookEntity(Handle:setup, bool:post, entity, DHookRemovalCB:removalcb=DHo
* @error Invalid setup handle, failing to get gamerules pointer or invalid hook type. * @error Invalid setup handle, failing to get gamerules pointer or invalid hook type.
* @return -1 on fail a hookid on success * @return -1 on fail a hookid on success
*/ */
native DHookGamerules(Handle:setup, bool:post, DHookRemovalCB:removalcb=DHookRemovalCB:-1); native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION);
/* Hook a raw pointer /* Hook a raw pointer
* *
@ -207,7 +219,7 @@ native DHookGamerules(Handle:setup, bool:post, DHookRemovalCB:removalcb=DHookRem
* @error Invalid setup handle, invalid address or invalid hook type. * @error Invalid setup handle, invalid address or invalid hook type.
* @return -1 on fail a hookid on success * @return -1 on fail a hookid on success
*/ */
native DHookRaw(Handle:setup, bool:post, Address:addr, DHookRemovalCB:removalcb=DHookRemovalCB:-1); native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION);
/* Remove hook by hook id /* Remove hook by hook id
* *
@ -216,7 +228,7 @@ native DHookRaw(Handle:setup, bool:post, Address:addr, DHookRemovalCB:removalcb=
* @return true on success false otherwise * @return true on success false otherwise
* @note This will not fire the removal callback! * @note This will not fire the removal callback!
*/ */
native bool:DHookRemoveHookID(hookid); native bool DHookRemoveHookID(int hookid);
/* Get param value (Only use for: int, entity, bool or float param types) /* Get param value (Only use for: int, entity, bool or float param types)
* *
@ -226,7 +238,7 @@ native bool:DHookRemoveHookID(hookid);
* @error Invalid handle. Invalid param number. Invalid param type. * @error Invalid handle. Invalid param number. Invalid param type.
* @return value if num greater than 0. If 0 returns paramcount. * @return value if num greater than 0. If 0 returns paramcount.
*/ */
native any:DHookGetParam(Handle:hParams, num); native any DHookGetParam(Handle hParams, int num);
/* Get vector param value /* Get vector param value
* *
@ -237,7 +249,7 @@ native any:DHookGetParam(Handle:hParams, num);
* @error Invalid handle. Invalid param number. Invalid param type. * @error Invalid handle. Invalid param number. Invalid param type.
* @noreturn * @noreturn
*/ */
native DHookGetParamVector(Handle:hParams, num, Float:vec[3]); native void DHookGetParamVector(Handle hParams, int num, float vec[3]);
/* Get string param value /* Get string param value
* *
@ -247,9 +259,9 @@ native DHookGetParamVector(Handle:hParams, num, Float:vec[3]);
* @param size Buffer size * @param size Buffer size
* *
* @error Invalid handle. Invalid param number. Invalid param type. * @error Invalid handle. Invalid param number. Invalid param type.
* @return value if num greater than 0. * @noreturn
*/ */
native DHookGetParamString(Handle:hParams, num, String:buffer[], size); native void DHookGetParamString(Handle hParams, int num, char[] buffer, int size);
/* Set param value (Only use for: int, entity, bool or float param types) /* Set param value (Only use for: int, entity, bool or float param types)
* *
@ -260,7 +272,7 @@ native DHookGetParamString(Handle:hParams, num, String:buffer[], size);
* @error Invalid handle. Invalid param number. Invalid param type. * @error Invalid handle. Invalid param number. Invalid param type.
* @noreturn * @noreturn
*/ */
native DHookSetParam(Handle:hParams, num, any:value); native void DHookSetParam(Handle hParams, int num, any value);
/* Set vector param value /* Set vector param value
* *
@ -271,7 +283,7 @@ native DHookSetParam(Handle:hParams, num, any:value);
* @error Invalid handle. Invalid param number. Invalid param type. * @error Invalid handle. Invalid param number. Invalid param type.
* @noreturn * @noreturn
*/ */
native DHookSetParamVector(Handle:hParams, num, Float:vec[3]); native void DHookSetParamVector(Handle hParams, int num, float vec[3]);
/* Set string param value /* Set string param value
* *
@ -282,7 +294,7 @@ native DHookSetParamVector(Handle:hParams, num, Float:vec[3]);
* @error Invalid handle. Invalid param number. Invalid param type. * @error Invalid handle. Invalid param number. Invalid param type.
* @noreturn * @noreturn
*/ */
native DHookSetParamString(Handle:hParams, num, String:value[]); native void DHookSetParamString(Handle hParams, int num, char[] value);
/* Get return value (Only use for: int, entity, bool or float return types) /* Get return value (Only use for: int, entity, bool or float return types)
* *
@ -291,7 +303,7 @@ native DHookSetParamString(Handle:hParams, num, String:value[]);
* @error Invalid Handle, invalid type. * @error Invalid Handle, invalid type.
* @return Returns default value if prehook returns actual value if post hook. * @return Returns default value if prehook returns actual value if post hook.
*/ */
native any:DHookGetReturn(Handle:hReturn); native any DHookGetReturn(Handle hReturn);
/* Get return vector value /* Get return vector value
* *
@ -301,7 +313,7 @@ native any:DHookGetReturn(Handle:hReturn);
* @error Invalid Handle, invalid type. * @error Invalid Handle, invalid type.
* @noreturn * @noreturn
*/ */
native DHookGetReturnVector(Handle:hReturn, Float:vec[3]); native void DHookGetReturnVector(Handle hReturn, float vec[3]);
/* Get return string value /* Get return string value
* *
@ -312,7 +324,7 @@ native DHookGetReturnVector(Handle:hReturn, Float:vec[3]);
* @error Invalid Handle, invalid type. * @error Invalid Handle, invalid type.
* @noreturn * @noreturn
*/ */
native DHookGetReturnString(Handle:hReturn, String:buffer[], size); native void DHookGetReturnString(Handle hReturn, char[] buffer, int size);
/* Set return value (Only use for: int, entity, bool or float return types) /* Set return value (Only use for: int, entity, bool or float return types)
* *
@ -322,7 +334,7 @@ native DHookGetReturnString(Handle:hReturn, String:buffer[], size);
* @error Invalid Handle, invalid type. * @error Invalid Handle, invalid type.
* @noreturn * @noreturn
*/ */
native DHookSetReturn(Handle:hReturn, any:value); native void DHookSetReturn(Handle hReturn, any value);
/* Set return vector value /* Set return vector value
* *
@ -332,7 +344,7 @@ native DHookSetReturn(Handle:hReturn, any:value);
* @error Invalid Handle, invalid type. * @error Invalid Handle, invalid type.
* @noreturn * @noreturn
*/ */
native DHookSetReturnVector(Handle:hReturn, Float:vec[3]); native void DHookSetReturnVector(Handle hReturn, float vec[3]);
/* Set return string value /* Set return string value
* *
@ -342,24 +354,26 @@ native DHookSetReturnVector(Handle:hReturn, Float:vec[3]);
* @error Invalid Handle, invalid type. * @error Invalid Handle, invalid type.
* @noreturn * @noreturn
*/ */
native DHookSetReturnString(Handle:hReturn, String:value[]); native void DHookSetReturnString(Handle hReturn, char[] value);
//WE SHOULD WRAP THESE AROUND STOCKS FOR NON PTR AS WE SUPPORT BOTH WITH THESE NATIVE'S
/* Gets an objects variable value /* Gets an objects variable value
* *
* @param hParams Handle to params structure * @param hParams Handle to params structure
* @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1. 0 Will return the number of params stored) * @param num Param number to get.
* @param offset Offset within the object to the var to get. * @param offset Offset within the object to the var to get.
* @param type Type of var it is * @param type Type of var it is
* *
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @return Value of the objects var. If EHANDLE type or entity returns entity index. * @return Value of the objects var. If EHANDLE type or entity returns entity index.
*/ */
native any:DHookGetParamObjectPtrVar(Handle:hParams, num, offset, ObjectValueType:type); native any DHookGetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type);
/* Sets an objects variable value /* Sets an objects variable value
* *
* @param hParams Handle to params structure * @param hParams Handle to params structure
* @param num Param number to set. (Example if the function has 2 params and you need the value of the first param num would be 1. 0 Will return the number of params stored) * @param num Param number to set.
* @param offset Offset within the object to the var to set. * @param offset Offset within the object to the var to set.
* @param type Type of var it is * @param type Type of var it is
* @param value The value to set the var to. * @param value The value to set the var to.
@ -367,25 +381,25 @@ native any:DHookGetParamObjectPtrVar(Handle:hParams, num, offset, ObjectValueTyp
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @noreturn * @noreturn
*/ */
native DHookSetParamObjectPtrVar(Handle:hParams, num, offset, ObjectValueType:type, any:value); native void DHookSetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type, any value);
/* Gets an objects vector variable value /* Gets an objects vector variable value
* *
* @param hParams Handle to params structure * @param hParams Handle to params structure
* @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1. 0 Will return the number of params stored) * @param num Param number to get.
* @param offset Offset within the object to the var to get. * @param offset Offset within the object to the var to get.
* @param type Type of var it is * @param type Type of var it is
* @param buffer Buffer to store the result vector * @param buffer Buffer to store the result vector
* *
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @return Value of the objects var. * @noreturn
*/ */
native DHookGetParamObjectPtrVarVector(Handle:hParams, num, offset, ObjectValueType:type, Float:buffer[3]); native void DHookGetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float buffer[3]);
/* Sets an objects vector variable value /* Sets an objects vector variable value
* *
* @param hParams Handle to params structure * @param hParams Handle to params structure
* @param num Param number to set. (Example if the function has 2 params and you need the value of the first param num would be 1. 0 Will return the number of params stored) * @param num Param number to set.
* @param offset Offset within the object to the var to set. * @param offset Offset within the object to the var to set.
* @param type Type of var it is * @param type Type of var it is
* @param value The value to set the vector var to. * @param value The value to set the vector var to.
@ -393,12 +407,21 @@ native DHookGetParamObjectPtrVarVector(Handle:hParams, num, offset, ObjectValueT
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type. * @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @noreturn * @noreturn
*/ */
native DHookSetParamObjectPtrVarVector(Handle:hParams, num, offset, ObjectValueType:type, Float:value[3]); native void DHookSetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float value[3]);
/* Gets an objects string variable value
//ADD DOCS OR ELSE *
//WE SHOULD WRAP THESE AROUND STOCKS FOR NON PTR AS WE SUPPORT BOTH WITH THIS NATIVE * @param hParams Handle to params structure
native DHookGetParamObjectPtrString(Handle:hParams, num, offset, ObjectValueType:type, String:buffer[], size); * @param num Param number to get.
* @param offset Offset within the object to the var to get.
* @param type Type of var it is
* @param buffer Buffer to store the result vector
* @param size Size of the buffer
*
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @noreturn
*/
native void DHookGetParamObjectPtrString(Handle hParams, int num, int offset, ObjectValueType type, char[] buffer, int size);
/* Checks if a pointer param is null /* Checks if a pointer param is null
* *
@ -408,9 +431,9 @@ native DHookGetParamObjectPtrString(Handle:hParams, num, offset, ObjectValueType
* @error Non pointer param * @error Non pointer param
* @return True if null false otherwise. * @return True if null false otherwise.
*/ */
native bool:DHookIsNullParam(Handle:hParams, num); native bool DHookIsNullParam(Handle hParams, int num);
public Extension:__ext_dhooks = public Extension __ext_dhooks =
{ {
name = "dhooks", name = "dhooks",
file = "dhooks.ext", file = "dhooks.ext",