Skip to content

Commit

Permalink
Merge pull request #185 from powerlord/tr-event
Browse files Browse the repository at this point in the history
Update events.inc to Transitional syntax.
  • Loading branch information
dvander committed Nov 8, 2014
2 parents 17b9ee9 + 9175c08 commit cd0ac3a
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions plugins/include/events.inc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ union EventHook
* @param dontBroadcast True if event was not broadcast to clients, false otherwise.
* @return Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
*/
function Action (Handle event, const char[] name, bool dontBroadcast);
function Action (Event event, const char[] name, bool dontBroadcast);
/**
* Called when a game event is fired.
*
Expand All @@ -69,7 +69,7 @@ union EventHook
* @param dontBroadcast True if event was not broadcast to clients, false otherwise.
* @noreturn
*/
function void (Handle event, const char[] name, bool dontBroadcast);
function void (Event event, const char[] name, bool dontBroadcast);
};

/**
Expand All @@ -81,7 +81,7 @@ union EventHook
* @noreturn
* @error Invalid event name or invalid callback function.
*/
native HookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
native void HookEvent(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post);

/**
* Creates a hook for when a game event is fired.
Expand All @@ -92,7 +92,7 @@ native HookEvent(const String:name[], EventHook:callback, EventHookMode:mode=Eve
* @return True if event exists and was hooked successfully, false otherwise.
* @error Invalid callback function.
*/
native bool:HookEventEx(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
native bool HookEventEx(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post);

/**
* Removes a hook for when a game event is fired.
Expand All @@ -103,7 +103,7 @@ native bool:HookEventEx(const String:name[], EventHook:callback, EventHookMode:m
* @noreturn
* @error Invalid callback function or no active hook for specified event.
*/
native UnhookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
native void UnhookEvent(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post);

/**
* Creates a game event to be fired later.
Expand All @@ -117,7 +117,7 @@ native UnhookEvent(const String:name[], EventHook:callback, EventHookMode:mode=E
* @return Handle to event. INVALID_HANDLE is returned if the event doesn't exist or isn't
being hooked (unless force is true).
*/
native Handle:CreateEvent(const String:name[], bool:force=false);
native Event CreateEvent(const char[] name, bool force=false);

/**
* Fires a game event.
Expand All @@ -129,7 +129,7 @@ native Handle:CreateEvent(const String:name[], bool:force=false);
* @noreturn
* @error Invalid or corrupt Handle.
*/
native FireEvent(Handle:event, bool:dontBroadcast=false);
native void FireEvent(Handle event, bool dontBroadcast=false);

/**
* Cancels a previously created game event that has not been fired.
Expand All @@ -138,7 +138,7 @@ native FireEvent(Handle:event, bool:dontBroadcast=false);
* @noreturn
* @error Invalid or corrupt Handle.
*/
native CancelCreatedEvent(Handle:event);
native void CancelCreatedEvent(Handle event);

/**
* Returns the boolean value of a game event's key.
Expand All @@ -149,7 +149,7 @@ native CancelCreatedEvent(Handle:event);
* @return The boolean value of the specfied event key.
* @error Invalid or corrupt Handle.
*/
native bool:GetEventBool(Handle:event, const String:key[], bool:defValue=false);
native bool GetEventBool(Handle event, const char[] key, bool defValue=false);

/**
* Sets the boolean value of a game event's key.
Expand All @@ -160,7 +160,7 @@ native bool:GetEventBool(Handle:event, const String:key[], bool:defValue=false);
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetEventBool(Handle:event, const String:key[], bool:value);
native void SetEventBool(Handle event, const char[] key, bool value);

/**
* Returns the integer value of a game event's key.
Expand All @@ -171,7 +171,7 @@ native SetEventBool(Handle:event, const String:key[], bool:value);
* @return The integer value of the specfied event key.
* @error Invalid or corrupt Handle.
*/
native GetEventInt(Handle:event, const String:key[], defValue=0);
native int GetEventInt(Handle event, const char[] key, int defValue=0);

/**
* Sets the integer value of a game event's key.
Expand All @@ -187,7 +187,7 @@ native GetEventInt(Handle:event, const String:key[], defValue=0);
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetEventInt(Handle:event, const String:key[], value);
native void SetEventInt(Handle event, const char[] key, int value);

/**
* Returns the floating point value of a game event's key.
Expand All @@ -198,7 +198,7 @@ native SetEventInt(Handle:event, const String:key[], value);
* @return The floating point value of the specfied event key.
* @error Invalid or corrupt Handle.
*/
native Float:GetEventFloat(Handle:event, const String:key[], Float:defValue=0.0);
native float GetEventFloat(Handle event, const char[] key, float defValue=0.0);

/**
* Sets the floating point value of a game event's key.
Expand All @@ -209,7 +209,7 @@ native Float:GetEventFloat(Handle:event, const String:key[], Float:defValue=0.0)
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetEventFloat(Handle:event, const String:key[], Float:value);
native void SetEventFloat(Handle event, const char[] key, float value);

/**
* Retrieves the string value of a game event's key.
Expand All @@ -222,7 +222,7 @@ native SetEventFloat(Handle:event, const String:key[], Float:value);
* @noreturn
* @error Invalid or corrupt Handle.
*/
native GetEventString(Handle:event, const String:key[], String:value[], maxlength, const String:defvalue[]="");
native void GetEventString(Handle event, const char[] key, char[] value, int maxlength, const char[] defvalue="");

/**
* Sets the string value of a game event's key.
Expand All @@ -233,7 +233,7 @@ native GetEventString(Handle:event, const String:key[], String:value[], maxlengt
* @noreturn
* @error Invalid or corrupt Handle.
*/
native SetEventString(Handle:event, const String:key[], const String:value[]);
native void SetEventString(Handle event, const char[] key, const char[] value);

/**
* Retrieves the name of a game event.
Expand All @@ -244,7 +244,7 @@ native SetEventString(Handle:event, const String:key[], const String:value[]);
* @noreturn
* @error Invalid or corrupt Handle.
*/
native GetEventName(Handle:event, String:name[], maxlength);
native void GetEventName(Handle event, char[] name, int maxlength);

/**
* Sets whether an event's broadcasting will be disabled or not.
Expand All @@ -257,5 +257,20 @@ native GetEventName(Handle:event, String:name[], maxlength);
* @noreturn
* @error Invalid Handle.
*/
native SetEventBroadcast(Handle:event, bool:dontBroadcast);
native void SetEventBroadcast(Handle event, bool dontBroadcast);

methodmap Event < Handle {
public Event() = CreateEvent;
public Fire() = FireEvent;
public Cancel() = CancelCreatedEvent;
public GetBool() = GetEventBool;
public SetBool() = SetEventBool;
public GetInt() = GetEventInt;
public SetInt() = SetEventInt;
public GetFloat() = GetEventFloat;
public SetFloat() = SetEventFloat;
public GetString() = GetEventString;
public SetString() = SetEventString;
public GetName() = GetEventName;
public SetBroadcast() = SetEventBroadcast;
}

0 comments on commit cd0ac3a

Please sign in to comment.