jit refactoring branch
--HG-- branch : refac-jit extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/refac-jit%402369
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_ADT_FACTORY_H_
|
||||
#define _INCLUDE_SOURCEMOD_ADT_FACTORY_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
|
||||
#define SMINTERFACE_ADTFACTORY_NAME "IADTFactory"
|
||||
#define SMINTERFACE_ADTFACTORY_VERSION 2
|
||||
|
||||
/**
|
||||
* @file IADTFactory.h
|
||||
* @brief Creates abstract data types.
|
||||
*/
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief A "Trie" data type.
|
||||
*/
|
||||
class IBasicTrie
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Inserts a key/value pair.
|
||||
*
|
||||
* @param key Key string (null terminated).
|
||||
* @param value Value pointer (may be anything).
|
||||
* @return True on success, false if key already exists.
|
||||
*/
|
||||
virtual bool Insert(const char *key, void *value) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the value of a key.
|
||||
*
|
||||
* @param key Key string (null terminated).
|
||||
* @param value Optional pointer to store value pointer.
|
||||
* @return True on success, false if key was not found.
|
||||
*/
|
||||
virtual bool Retrieve(const char *key, void **value) =0;
|
||||
|
||||
/**
|
||||
* @brief Deletes a key.
|
||||
*
|
||||
* @param key Key string (null terminated).
|
||||
* @return True on success, false if key was not found.
|
||||
*/
|
||||
virtual bool Delete(const char *key) =0;
|
||||
|
||||
/**
|
||||
* @brief Flushes the entire trie of all keys.
|
||||
*/
|
||||
virtual void Clear() =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys the IBasicTrie object and frees all associated
|
||||
* memory.
|
||||
*/
|
||||
virtual void Destroy() =0;
|
||||
|
||||
/**
|
||||
* @brief Inserts a key/value pair, replacing an old inserted
|
||||
* value if it already exists.
|
||||
*
|
||||
* @param key Key string (null terminated).
|
||||
* @param value Value pointer (may be anything).
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool Replace(const char *key, void *value) =0;
|
||||
};
|
||||
|
||||
class IADTFactory : public SMInterface
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a basic Trie object.
|
||||
*
|
||||
* @return A new IBasicTrie object which must be destroyed
|
||||
* via IBasicTrie::Destroy().
|
||||
*/
|
||||
virtual IBasicTrie *CreateBasicTrie() =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_ADT_FACTORY_H_
|
||||
@@ -0,0 +1,724 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
|
||||
#define _INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
|
||||
#define SMINTERFACE_ADMINSYS_NAME "IAdminSys"
|
||||
#define SMINTERFACE_ADMINSYS_VERSION 5
|
||||
|
||||
/**
|
||||
* @file IAdminSystem.h
|
||||
* @brief Defines the interface to manage the Admin Users/Groups and Override caches.
|
||||
*
|
||||
* The administration system is more of a volatile cache than a system. It is designed to be
|
||||
* temporary rather than permanent, in order to compensate for more storage methods. For example,
|
||||
* a flat file might be read into the cache all at once. But a MySQL-based system might only cache
|
||||
* admin permissions when that specific admin connects.
|
||||
*
|
||||
* The override cache is the simplest to explain. Any time an override is added, any existing
|
||||
* and all future commands will gain a new access level set by the override. If unset, the default
|
||||
* access level is restored. This cache is dynamically changeable.
|
||||
*
|
||||
* The group cache contains, for each group:
|
||||
* 1] A set of inherent flags - fully readable/writable.
|
||||
* 2] An immunity table - insertion and retrieval only.
|
||||
* 3] An override table - insertion and retrieval only.
|
||||
* Individual groups can be invalidated entirely. It should be considered an expensive
|
||||
* operation, since each admin needs to be patched up to not reference the group.
|
||||
*
|
||||
* For more information, see the SourceMod Development wiki.
|
||||
*/
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Access levels (flags) for admins.
|
||||
*/
|
||||
enum AdminFlag
|
||||
{
|
||||
Admin_Reservation = 0, /**< Reserved slot */
|
||||
Admin_Generic, /**< Generic admin abilities */
|
||||
Admin_Kick, /**< Kick another user */
|
||||
Admin_Ban, /**< Ban another user */
|
||||
Admin_Unban, /**< Unban another user */
|
||||
Admin_Slay, /**< Slay/kill/damage another user */
|
||||
Admin_Changemap, /**< Change the map */
|
||||
Admin_Convars, /**< Change basic convars */
|
||||
Admin_Config, /**< Change configuration */
|
||||
Admin_Chat, /**< Special chat privileges */
|
||||
Admin_Vote, /**< Special vote privileges */
|
||||
Admin_Password, /**< Set a server password */
|
||||
Admin_RCON, /**< Use RCON */
|
||||
Admin_Cheats, /**< Change sv_cheats and use its commands */
|
||||
Admin_Root, /**< All access by default */
|
||||
Admin_Custom1, /**< First custom flag type */
|
||||
Admin_Custom2, /**< Second custom flag type */
|
||||
Admin_Custom3, /**< Third custom flag type */
|
||||
Admin_Custom4, /**< Fourth custom flag type */
|
||||
Admin_Custom5, /**< Fifth custom flag type */
|
||||
Admin_Custom6, /**< Sixth custom flag type */
|
||||
/* --- */
|
||||
AdminFlags_TOTAL,
|
||||
};
|
||||
|
||||
#define ADMFLAG_RESERVATION (1<<0) /**< Convenience macro for Admin_Reservation as a FlagBit */
|
||||
#define ADMFLAG_GENERIC (1<<1) /**< Convenience macro for Admin_Generic as a FlagBit */
|
||||
#define ADMFLAG_KICK (1<<2) /**< Convenience macro for Admin_Kick as a FlagBit */
|
||||
#define ADMFLAG_BAN (1<<3) /**< Convenience macro for Admin_Ban as a FlagBit */
|
||||
#define ADMFLAG_UNBAN (1<<4) /**< Convenience macro for Admin_Unban as a FlagBit */
|
||||
#define ADMFLAG_SLAY (1<<5) /**< Convenience macro for Admin_Slay as a FlagBit */
|
||||
#define ADMFLAG_CHANGEMAP (1<<6) /**< Convenience macro for Admin_Changemap as a FlagBit */
|
||||
#define ADMFLAG_CONVARS (1<<7) /**< Convenience macro for Admin_Convars as a FlagBit */
|
||||
#define ADMFLAG_CONFIG (1<<8) /**< Convenience macro for Admin_Config as a FlagBit */
|
||||
#define ADMFLAG_CHAT (1<<9) /**< Convenience macro for Admin_Chat as a FlagBit */
|
||||
#define ADMFLAG_VOTE (1<<10) /**< Convenience macro for Admin_Vote as a FlagBit */
|
||||
#define ADMFLAG_PASSWORD (1<<11) /**< Convenience macro for Admin_Password as a FlagBit */
|
||||
#define ADMFLAG_RCON (1<<12) /**< Convenience macro for Admin_RCON as a FlagBit */
|
||||
#define ADMFLAG_CHEATS (1<<13) /**< Convenience macro for Admin_Cheats as a FlagBit */
|
||||
#define ADMFLAG_ROOT (1<<14) /**< Convenience macro for Admin_Root as a FlagBit */
|
||||
#define ADMFLAG_CUSTOM1 (1<<15) /**< Convenience macro for Admin_Custom1 as a FlagBit */
|
||||
#define ADMFLAG_CUSTOM2 (1<<16) /**< Convenience macro for Admin_Custom2 as a FlagBit */
|
||||
#define ADMFLAG_CUSTOM3 (1<<17) /**< Convenience macro for Admin_Custom3 as a FlagBit */
|
||||
#define ADMFLAG_CUSTOM4 (1<<18) /**< Convenience macro for Admin_Custom4 as a FlagBit */
|
||||
#define ADMFLAG_CUSTOM5 (1<<19) /**< Convenience macro for Admin_Custom5 as a FlagBit */
|
||||
#define ADMFLAG_CUSTOM6 (1<<20) /**< Convenience macro for Admin_Custom6 as a FlagBit */
|
||||
|
||||
/**
|
||||
* @brief Specifies which type of command to override (command or command group).
|
||||
*/
|
||||
enum OverrideType
|
||||
{
|
||||
Override_Command = 1, /**< Command */
|
||||
Override_CommandGroup, /**< Command group */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Specifies how a command is overridden for a user group.
|
||||
*/
|
||||
enum OverrideRule
|
||||
{
|
||||
Command_Deny = 0, /**< Deny access */
|
||||
Command_Allow = 1, /**< Allow access */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief DEPRECATED. Specifies a generic immunity type.
|
||||
*/
|
||||
enum ImmunityType
|
||||
{
|
||||
Immunity_Default = 1, /**< Immunity value of 1 */
|
||||
Immunity_Global, /**< Immunity value of 2 */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Defines user access modes.
|
||||
*/
|
||||
enum AccessMode
|
||||
{
|
||||
Access_Real, /**< Access the user has inherently */
|
||||
Access_Effective, /**< Access the user has from their groups */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Represents an index to one group.
|
||||
*/
|
||||
typedef int GroupId;
|
||||
|
||||
/**
|
||||
* @brief Represents an index to one user entry.
|
||||
*/
|
||||
typedef int AdminId;
|
||||
|
||||
/**
|
||||
* @brief Represents an invalid/nonexistent group or an erroneous operation.
|
||||
*/
|
||||
#define INVALID_GROUP_ID -1
|
||||
|
||||
/**
|
||||
* @brief Represents an invalid/nonexistent user or an erroneous operation.
|
||||
*/
|
||||
#define INVALID_ADMIN_ID -1
|
||||
|
||||
/**
|
||||
* @brief Represents the various cache regions.
|
||||
*/
|
||||
enum AdminCachePart
|
||||
{
|
||||
AdminCache_Overrides = 0, /**< Global overrides */
|
||||
AdminCache_Groups = 1, /**< All groups (automatically invalidates admins too) */
|
||||
AdminCache_Admins = 2, /**< All admins */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Provides callbacks for admin cache operations.
|
||||
*/
|
||||
class IAdminListener
|
||||
{
|
||||
public:
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_ADMINSYS_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Called when the admin cache needs to be rebuilt.
|
||||
*
|
||||
* @param auto_rebuild True if this is being called because of a group rebuild.
|
||||
*/
|
||||
virtual void OnRebuildAdminCache(bool auto_rebuild) =0;
|
||||
|
||||
/**
|
||||
* @brief Called when the group cache needs to be rebuilt.
|
||||
*/
|
||||
virtual void OnRebuildGroupCache() =0;
|
||||
|
||||
/**
|
||||
* @brief Called when the global override cache needs to be rebuilt.
|
||||
*/
|
||||
virtual void OnRebuildOverrideCache() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Admin permission levels.
|
||||
*/
|
||||
typedef unsigned int FlagBits;
|
||||
|
||||
/**
|
||||
* @brief Provides functions for manipulating the admin options cache.
|
||||
*/
|
||||
class IAdminSystem : public SMInterface
|
||||
{
|
||||
public:
|
||||
const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_ADMINSYS_NAME;
|
||||
}
|
||||
unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_ADMINSYS_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Adds a global command flag override. Any command registered with this name
|
||||
* will assume the new flag. This is applied retroactively as well.
|
||||
*
|
||||
* @param cmd String containing command name (case sensitive).
|
||||
* @param type Override type (specific command or group).
|
||||
* @param flags New admin flag.
|
||||
*/
|
||||
virtual void AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a command override.
|
||||
*
|
||||
* @param cmd String containing command name (case sensitive).
|
||||
* @param type Override type (specific command or group).
|
||||
* @param pFlags Optional pointer to the set flag.
|
||||
* @return True if there is an override, false otherwise.
|
||||
*/
|
||||
virtual bool GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags) =0;
|
||||
|
||||
/**
|
||||
* @brief Unsets a command override.
|
||||
*
|
||||
* @param cmd String containing command name (case sensitive).
|
||||
* @param type Override type (specific command or group).
|
||||
*/
|
||||
virtual void UnsetCommandOverride(const char *cmd, OverrideType type) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a new group. Name must be unique.
|
||||
*
|
||||
* @param group_name String containing the group name.
|
||||
* @return A new group id, INVALID_GROUP_ID if it already exists.
|
||||
*/
|
||||
virtual GroupId AddGroup(const char *group_name) =0;
|
||||
|
||||
/**
|
||||
* @brief Finds a group by name.
|
||||
*
|
||||
* @param group_name String containing the group name.
|
||||
* @return A group id, or INVALID_GROUP_ID if not found.
|
||||
*/
|
||||
virtual GroupId FindGroupByName(const char *group_name) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds or removes a flag from a group's flag set.
|
||||
* Note: These are called "add flags" because they add to a user's flags.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @param flag Admin flag to toggle.
|
||||
* @param enabled True to set the flag, false to unset/disable.
|
||||
*/
|
||||
virtual void SetGroupAddFlag(GroupId id, AdminFlag flag, bool enabled) =0;
|
||||
|
||||
/**
|
||||
* @brief Gets the set value of an add flag on a group's flag set.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @param flag Admin flag to retrieve.
|
||||
* @return True if enabled, false otherwise,
|
||||
*/
|
||||
virtual bool GetGroupAddFlag(GroupId id, AdminFlag flag) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns an array of flag bits that are added to a user from their group.
|
||||
* Note: These are called "add flags" because they add to a user's flags.
|
||||
*
|
||||
* @param id GroupId of the group.
|
||||
* @return Bit string containing the bits of each flag.
|
||||
*/
|
||||
virtual FlagBits GetGroupAddFlags(GroupId id) =0;
|
||||
|
||||
/**
|
||||
* @brief DEPRECATED. Sets a group's immunity level using backwards
|
||||
* compatible types.
|
||||
*
|
||||
* If the new level being set is lower than the group's actual immunity
|
||||
* level, no operation takes place.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @param type Immunity type which will be converted to a
|
||||
* numerical level.
|
||||
* @param enabled True to set the level. False sets the
|
||||
* group's immunity value to 0.
|
||||
*/
|
||||
virtual void SetGroupGenericImmunity(GroupId id, ImmunityType type, bool enabled) =0;
|
||||
|
||||
/**
|
||||
* @brief DEPRECATED. Returns whether a group has an immunity level
|
||||
* using backwards compatible types.
|
||||
*
|
||||
* This simply checks whether the group's immunity value is greater
|
||||
* than or equal to the new-style value for the old type.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @param type Generic immunity type.
|
||||
* @return True if the group has this immunity, false
|
||||
* otherwise.
|
||||
*/
|
||||
virtual bool GetGroupGenericImmunity(GroupId id, ImmunityType type) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds immunity to a specific group.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @param other_id Group id to receive immunity to.
|
||||
*/
|
||||
virtual void AddGroupImmunity(GroupId id, GroupId other_id) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of specific group immunities.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @return Number of group immunities.
|
||||
*/
|
||||
virtual unsigned int GetGroupImmunityCount(GroupId id) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a group that this group is immune to given an index.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @param number Index from 0 to N-1, from GetGroupImmunities().
|
||||
* @return GroupId that this group is immune to.
|
||||
*/
|
||||
virtual GroupId GetGroupImmunity(GroupId id, unsigned int number) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a group-specific override type.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @param name String containing command name (case sensitive).
|
||||
* @param type Override type (specific command or group).
|
||||
* @param rule Override allow/deny setting.
|
||||
*/
|
||||
virtual void AddGroupCommandOverride(GroupId id,
|
||||
const char *name,
|
||||
OverrideType type,
|
||||
OverrideRule rule) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves a group-specific command override.
|
||||
*
|
||||
* @param id Group id.
|
||||
* @param name String containing command name (case sensitive).
|
||||
* @param type Override type (specific command or group).
|
||||
* @param pRule Optional pointer to store allow/deny setting.
|
||||
* @return True if an override exists, false otherwise.
|
||||
*/
|
||||
virtual bool GetGroupCommandOverride(GroupId id,
|
||||
const char *name,
|
||||
OverrideType type,
|
||||
OverrideRule *pRule) =0;
|
||||
|
||||
/**
|
||||
* @brief Tells the admin system to dump a portion of the cache.
|
||||
* This calls into plugin forwards to rebuild the cache.
|
||||
*
|
||||
* @param part Portion of the cache to dump.
|
||||
* @param rebuild If true, the rebuild forwards/events will fire.
|
||||
*/
|
||||
virtual void DumpAdminCache(AdminCachePart part, bool rebuild) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds an admin interface listener.
|
||||
*
|
||||
* @param pListener Pointer to an IAdminListener to add.
|
||||
*/
|
||||
virtual void AddAdminListener(IAdminListener *pListener) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes an admin interface listener.
|
||||
*
|
||||
* @param pListener Pointer to an IAdminListener to remove.
|
||||
*/
|
||||
virtual void RemoveAdminListener(IAdminListener *pListener) =0;
|
||||
|
||||
/**
|
||||
* @brief Registers an authentication identity type.
|
||||
* Note: Default types are "steam," "name," and "ip."
|
||||
*
|
||||
* @param name String containing the type name.
|
||||
*/
|
||||
virtual void RegisterAuthIdentType(const char *name) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a new user entry.
|
||||
*
|
||||
* @param name Name for this entry (does not have to be unique).
|
||||
* Specify NULL for an anonymous admin.
|
||||
* @return A new AdminId index.
|
||||
*/
|
||||
virtual AdminId CreateAdmin(const char *name) =0;
|
||||
|
||||
/**
|
||||
* @brief Gets an admin's user name.
|
||||
*
|
||||
* @param id AdminId index for this admin.
|
||||
* @return A string containing the admin's name, or NULL
|
||||
* if the admin was created anonymously.
|
||||
*/
|
||||
virtual const char *GetAdminName(AdminId id) =0;
|
||||
|
||||
/**
|
||||
* @brief Binds a user entry to a particular auth method.
|
||||
* This bind must be unique.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @param auth Auth method to use.
|
||||
* @param ident Identity string to bind to.
|
||||
* @return True on success, false if auth method was not found,
|
||||
* id was invalid, or ident was already taken.
|
||||
*/
|
||||
virtual bool BindAdminIdentity(AdminId id, const char *auth, const char *ident) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets whether or not a flag is enabled on an admin.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @param flag Admin flag to use.
|
||||
* @param enabled True to enable, false to disable.
|
||||
*/
|
||||
virtual void SetAdminFlag(AdminId id, AdminFlag flag, bool enabled) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether or not a flag is enabled on an admin.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @param flag Admin flag to use.
|
||||
* @param mode Access mode to check.
|
||||
* @return True if enabled, false otherwise.
|
||||
*/
|
||||
virtual bool GetAdminFlag(AdminId id, AdminFlag flag, AccessMode mode) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the bitstring of access flags on an admin.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @param mode Access mode to use.
|
||||
* @return A bit string containing which flags are enabled.
|
||||
*/
|
||||
virtual FlagBits GetAdminFlags(AdminId id, AccessMode mode) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the bitstring of access flags on an admin.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @param mode Access mode to use (real affects both).
|
||||
* @param bits Bitstring to set.
|
||||
*/
|
||||
virtual void SetAdminFlags(AdminId id, AccessMode mode, FlagBits bits) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a group to an admin's inherited group list.
|
||||
* Any flags the group has will be added to the admin's effective flags.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @param gid GroupId index of the group.
|
||||
* @return True on success, false on invalid input or duplicate membership.
|
||||
*/
|
||||
virtual bool AdminInheritGroup(AdminId id, GroupId gid) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of groups this admin is a member of.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @return Number of groups this admin is a member of.
|
||||
*/
|
||||
virtual unsigned int GetAdminGroupCount(AdminId id) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns group information from an admin.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @param index Group number to retrieve, from 0 to N-1, where N
|
||||
* is the value of GetAdminGroupCount(id).
|
||||
* @param name Optional pointer to store the group's name.
|
||||
* @return A GroupId index and a name pointer, or
|
||||
* INVALID_GROUP_ID and NULL if an error occurred.
|
||||
*/
|
||||
virtual GroupId GetAdminGroup(AdminId id, unsigned int index, const char **name) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets a password on an admin.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @param password String containing the password.
|
||||
*/
|
||||
virtual void SetAdminPassword(AdminId id, const char *password) =0;
|
||||
|
||||
/**
|
||||
* @brief Gets an admin's password.
|
||||
*
|
||||
* @param id AdminId index of the admin.
|
||||
* @return Password of the admin, or NULL if none.
|
||||
*/
|
||||
virtual const char *GetAdminPassword(AdminId id) =0;
|
||||
|
||||
/**
|
||||
* @brief Attempts to find an admin by an auth method and an identity.
|
||||
*
|
||||
* @param auth Auth method to try.
|
||||
* @param identity Identity string to look up.
|
||||
* @return An AdminId index if found, INVALID_ADMIN_ID otherwise.
|
||||
*/
|
||||
virtual AdminId FindAdminByIdentity(const char *auth, const char *identity) =0;
|
||||
|
||||
/**
|
||||
* @brief Invalidates an admin from the cache so its resources can be re-used.
|
||||
*
|
||||
* @param id AdminId index to invalidate.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool InvalidateAdmin(AdminId id) =0;
|
||||
|
||||
/**
|
||||
* @brief Converts a flag bit string to a bit array.
|
||||
*
|
||||
* @param bits Bit string containing the flags.
|
||||
* @param array Array to write the flags to. Enabled flags will be 'true'.
|
||||
* @param maxSize Maximum number of flags the array can store.
|
||||
* @return Number of flags written.
|
||||
*/
|
||||
virtual unsigned int FlagBitsToBitArray(FlagBits bits, bool array[], unsigned int maxSize) =0;
|
||||
|
||||
/**
|
||||
* @brief Converts a flag array to a bit string.
|
||||
*
|
||||
* @param array Array containing true or false for each AdminFlag.
|
||||
* @param maxSize Maximum size of the flag array.
|
||||
* @return A bit string composed of the array bits.
|
||||
*/
|
||||
virtual FlagBits FlagBitArrayToBits(const bool array[], unsigned int maxSize) =0;
|
||||
|
||||
/**
|
||||
* @brief Converts an array of flags to bits.
|
||||
*
|
||||
* @param array Array containing flags that are enabled.
|
||||
* @param numFlags Number of flags in the array.
|
||||
* @return A bit string composed of the array flags.
|
||||
*/
|
||||
virtual FlagBits FlagArrayToBits(const AdminFlag array[], unsigned int numFlags) =0;
|
||||
|
||||
/**
|
||||
* @brief Converts a bit string to an array of flags.
|
||||
*
|
||||
* @param bits Bit string containing the flags.
|
||||
* @param array Output array to write flags.
|
||||
* @param maxSize Maximum size of the flag array.
|
||||
* @return Number of flags written.
|
||||
*/
|
||||
virtual unsigned int FlagBitsToArray(FlagBits bits, AdminFlag array[], unsigned int maxSize) =0;
|
||||
|
||||
/**
|
||||
* @brief Checks whether a user has access to a given set of flag bits.
|
||||
* Note: This is a wrapper around GetAdminFlags().
|
||||
*
|
||||
* @param id AdminId index of admin.
|
||||
* @param bits Bitstring containing the permissions to check.
|
||||
* @return True if user has permission, false otherwise.
|
||||
*/
|
||||
virtual bool CheckAdminFlags(AdminId id, FlagBits bits) =0;
|
||||
|
||||
/**
|
||||
* @brief Checks whether an AdminId can target another AdminId.
|
||||
*
|
||||
* The hueristics for this check are as follows:
|
||||
* 0. If the targeting AdminId is INVALID_ADMIN_ID, targeting fails.
|
||||
* 1. If the targeted AdminId is INVALID_ADMIN_ID, targeting succeeds.
|
||||
* 2. If the targeted AdminId is the same as the targeting AdminId,
|
||||
* (self) targeting succeeds.
|
||||
* 3. If the targeting admin is root, targeting succeeds.
|
||||
* 4. If the targeted admin has access higher (as interpreted by
|
||||
* (sm_immunity_mode) than the targeting admin, then targeting fails.
|
||||
* 5. If the targeted admin has specific immunity from the
|
||||
* targeting admin via group immunities, targeting fails.
|
||||
* 6. Targeting succeeds.
|
||||
*
|
||||
* @param id AdminId index of admin doing the targeting. Can be INVALID_ADMIN_ID.
|
||||
* @param target AdminId index of the target admin. Can be INVALID_ADMIN_ID.
|
||||
* @return True if this admin has permission to target the other admin.
|
||||
*/
|
||||
virtual bool CanAdminTarget(AdminId id, AdminId target) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a flag from a named string.
|
||||
*
|
||||
* @param flagname Case sensitive flag name string (like "kick").
|
||||
* @param pAdmFlag Pointer to store the found admin flag in.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool FindFlag(const char *flagname, AdminFlag *pAdmFlag) =0;
|
||||
|
||||
/**
|
||||
* @brief Reads a single character as a flag.
|
||||
*
|
||||
* @param c Flag character.
|
||||
* @param pAdmFlag Pointer to store the admin flag.
|
||||
* @return True on success, false if invalid.
|
||||
*/
|
||||
virtual bool FindFlag(char c, AdminFlag *pAdmFlag) =0;
|
||||
|
||||
/**
|
||||
* @brief Reads a string of flag letters and returns its access value.
|
||||
*
|
||||
* @param flags Flag string.
|
||||
* @param end Pointer to store the last value read. On success,
|
||||
* this will store a pointer to the null terminator.
|
||||
* @return FlagBits value of the flags.
|
||||
*/
|
||||
virtual FlagBits ReadFlagString(const char *flags, const char **end) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a "serial number" for an AdminId. If the serial
|
||||
* number has changed for a given AdminId, it means the permissions
|
||||
* have changed.
|
||||
*
|
||||
* @param id AdminId value.
|
||||
* @return Serial number, or 0 on failure.
|
||||
*/
|
||||
virtual unsigned int GetAdminSerialChange(AdminId id) =0;
|
||||
|
||||
/**
|
||||
* @brief Checks whether an admin can use the given command name.
|
||||
*
|
||||
* If the command does not exist, this will return true.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param cmd Command name.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool CanAdminUseCommand(int client, const char *cmd) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the name of a group.
|
||||
*
|
||||
* @param gid Group Id.
|
||||
* @return Group name, or NULL on failure.
|
||||
*/
|
||||
virtual const char *GetGroupName(GroupId gid) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the immunity level of a group.
|
||||
*
|
||||
* @param gid Group Id.
|
||||
* @param level Immunity level value.
|
||||
* @return Old immunity level.
|
||||
*/
|
||||
virtual unsigned int SetGroupImmunityLevel(GroupId gid, unsigned int level) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the immunity level of a group.
|
||||
*
|
||||
* @param gid Group Id.
|
||||
* @return Immunity level value.
|
||||
*/
|
||||
virtual unsigned int GetGroupImmunityLevel(GroupId gid) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the immunity level of an admin.
|
||||
*
|
||||
* @param id Admin Id.
|
||||
* @param level Immunity level value.
|
||||
* @return Old immunity level.
|
||||
*/
|
||||
virtual unsigned int SetAdminImmunityLevel(AdminId id, unsigned int level) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the immunity level of an admin.
|
||||
*
|
||||
* @param id Admin Id.
|
||||
* @return Immunity level value.
|
||||
*/
|
||||
virtual unsigned int GetAdminImmunityLevel(AdminId id) =0;
|
||||
|
||||
/**
|
||||
* @brief Computers access to an override.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param cmd Override name.
|
||||
* @param flags Default flags.
|
||||
* @param override_only If false, if a command matches the override,
|
||||
* then its flags will override the default.
|
||||
* @return True if the client has access, false otherwise.
|
||||
*/
|
||||
virtual bool CheckAccess(int client,
|
||||
const char *cmd,
|
||||
FlagBits flags,
|
||||
bool override_only) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
|
||||
|
||||
@@ -0,0 +1,882 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_INTERFACE_DBDRIVER_H_
|
||||
#define _INCLUDE_SOURCEMOD_INTERFACE_DBDRIVER_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IHandleSys.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* @file IDBDriver.h
|
||||
* @brief Defines interfaces for interacting with relational databases.
|
||||
*/
|
||||
|
||||
#define SMINTERFACE_DBI_NAME "IDBI"
|
||||
#define SMINTERFACE_DBI_VERSION 7
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Describes a database field value.
|
||||
*/
|
||||
enum DBResult
|
||||
{
|
||||
DBVal_Error = 0, /**< Column number/field is invalid */
|
||||
DBVal_TypeMismatch = 1, /**< You cannot retrieve this data with this type */
|
||||
DBVal_Null = 2, /**< Field has no data (NULL) */
|
||||
DBVal_Data = 3, /**< Field has data */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes a primitive database type.
|
||||
*/
|
||||
enum DBType
|
||||
{
|
||||
DBType_Unknown = 0, /**< Type could not be inferred */
|
||||
DBType_String, /**< NULL-terminated string (variable length) */
|
||||
DBType_Blob, /**< Raw binary data (variable length) */
|
||||
DBType_Integer, /**< 4-byte signed integer */
|
||||
DBType_Float, /**< 4-byte floating point */
|
||||
DBType_NULL, /**< NULL (no data) */
|
||||
/* --------- */
|
||||
DBTypes_TOTAL, /**< Total number of database types known */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Represents a one database result row.
|
||||
*
|
||||
* Note that type mismatches will only occur when type safety is being
|
||||
* enforced. So far this is only the case for prepared statements in
|
||||
* MySQL and SQLite.
|
||||
*
|
||||
* Also, it is worth noting that retrieving as raw data will never cause a
|
||||
* type mismatch.
|
||||
*/
|
||||
class IResultRow
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Retrieves a database field result as a string.
|
||||
*
|
||||
* For NULL values, the resulting string pointer will be non-NULL but
|
||||
* empty. The pointer returned will become invalid after advancing to
|
||||
* the next row.
|
||||
*
|
||||
* @param columnId Column to use, starting from 0.
|
||||
* @param pString Pointer to store a pointer to the string.
|
||||
* @param length Optional pointer to store the string length.
|
||||
* @return A DBResult return code.
|
||||
*/
|
||||
virtual DBResult GetString(unsigned int columnId, const char **pString, size_t *length) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves a database field result as a string, using a
|
||||
* user-supplied buffer. If the field is NULL, an empty string
|
||||
* will be copied.
|
||||
*
|
||||
* @param columnId Column to use, starting from 0.
|
||||
* @param buffer Buffer to store string in.
|
||||
* @param maxlength Maximum length of the buffer.
|
||||
* @param written Optional pointer to store the number of bytes
|
||||
* written, excluding the null terminator.
|
||||
* @return A DBResult return code.
|
||||
*/
|
||||
virtual DBResult CopyString(unsigned int columnId,
|
||||
char *buffer,
|
||||
size_t maxlength,
|
||||
size_t *written) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves a database field result as a float.
|
||||
*
|
||||
* For NULL entries, the returned float value will be 0.0.
|
||||
*
|
||||
* @param columnId Column to use, starting from 0.
|
||||
* @param pFloat Pointer to a floating point number to set.
|
||||
* @return A DBResult return code.
|
||||
*/
|
||||
virtual DBResult GetFloat(unsigned int columnId, float *pFloat) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves a database field result as an integer.
|
||||
*
|
||||
* For NULL entries, the returned integer value will be 0.
|
||||
*
|
||||
* @param columnId Column to use, starting from 0.
|
||||
* @param pInt Pointer to an integer number to set.
|
||||
* @return A DBResult return code.
|
||||
*/
|
||||
virtual DBResult GetInt(unsigned int columnId, int *pInt) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether or not a field is NULL.
|
||||
*
|
||||
* @param columnId Column to use, starting from 0.
|
||||
* @return True if field is NULL, false otherwise.
|
||||
*/
|
||||
virtual bool IsNull(unsigned int columnId) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the size of a field (text/raw/blob) in bytes.
|
||||
* For strings, this returned size will not include the null
|
||||
* terminator.
|
||||
*
|
||||
* When used on fields that are not of variable length,
|
||||
* the size returned will be the number of bytes required
|
||||
* to store the internal data. Note that the data size
|
||||
* will correspond to the ACTUAL data type, not the
|
||||
* COLUMN type.
|
||||
*
|
||||
* @param columnId Column to use, starting from 0.
|
||||
* @return Number of bytes required to store
|
||||
* the data, or 0 on failure.
|
||||
*/
|
||||
virtual size_t GetDataSize(unsigned int columnId) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves field data as a raw bitstream. The pointer returned
|
||||
* will become invalid after advancing to the next row.
|
||||
*
|
||||
* @param columnId Column to use, starting from 0.
|
||||
* @param pData Pointer to store the raw bit stream. If the
|
||||
* data is NULL, a NULL pointer will be returned.
|
||||
* @param length Pointer to store the data length.
|
||||
* @return A DBResult return code.
|
||||
*/
|
||||
virtual DBResult GetBlob(unsigned int columnId, const void **pData, size_t *length) =0;
|
||||
|
||||
/**
|
||||
* @brief Copies field data as a raw bitstream.
|
||||
*
|
||||
* @param columnId Column to use, starting from 0.
|
||||
* @param buffer Pointer to copy the data to. If the data is
|
||||
* NULL, no data will be copied.
|
||||
* @param maxlength Maximum length of the buffer.
|
||||
* @param written Optional pointer to store the number of bytes
|
||||
* written.
|
||||
* @return A DBResult return code.
|
||||
*/
|
||||
virtual DBResult CopyBlob(unsigned int columnId, void *buffer, size_t maxlength, size_t *written) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes a set of database results.
|
||||
*/
|
||||
class IResultSet
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the number of rows in the set.
|
||||
*
|
||||
* @return Number of rows in the set.
|
||||
*/
|
||||
virtual unsigned int GetRowCount() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of fields in the set.
|
||||
*
|
||||
* @return Number of fields in the set.
|
||||
*/
|
||||
virtual unsigned int GetFieldCount() =0;
|
||||
|
||||
/**
|
||||
* @brief Converts a column number to a column name.
|
||||
*
|
||||
* @param columnId Column to use, starting from 0.
|
||||
* @return Pointer to column name, or NULL if not found.
|
||||
*/
|
||||
virtual const char *FieldNumToName(unsigned int columnId) =0;
|
||||
|
||||
/**
|
||||
* @brief Converts a column name to a column id.
|
||||
*
|
||||
* @param name Column name (case sensitive).
|
||||
* @param columnId Pointer to store the column id. If the
|
||||
* name is not found, the value will be
|
||||
* undefined.
|
||||
* @return True on success, false if not found.
|
||||
*/
|
||||
virtual bool FieldNameToNum(const char *name, unsigned int *columnId) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns if there is still data in the result set.
|
||||
*
|
||||
* @return False if there is more data to be read,
|
||||
* true, otherwise.
|
||||
*/
|
||||
virtual bool MoreRows() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to the current row and advances
|
||||
* the internal row pointer/counter to the next row available.
|
||||
*
|
||||
* @return IResultRow pointer to the current row,
|
||||
* or NULL if there is no more data.
|
||||
*/
|
||||
virtual IResultRow *FetchRow() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to the current row.
|
||||
*
|
||||
* @return IResultRow pointer to the current row,
|
||||
* or NULL if the current row is invalid.
|
||||
*/
|
||||
virtual IResultRow *CurrentRow() =0;
|
||||
|
||||
/**
|
||||
* @brief Rewinds back to the beginning of the row iteration.
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool Rewind() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a field's type as it should be interpreted
|
||||
* by the user.
|
||||
*
|
||||
* @param field Field number (starting from 0).
|
||||
* @return A DBType value.
|
||||
*/
|
||||
virtual DBType GetFieldType(unsigned int field) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a field's type as it will be interpreted
|
||||
* by the GetDataSize() function. For example, MySQL
|
||||
* for non-prepared queries will store all results as
|
||||
* strings internally.
|
||||
*
|
||||
* @param field Field number (starting from 0).
|
||||
* @return A DBType value.
|
||||
*/
|
||||
virtual DBType GetFieldDataType(unsigned int field) =0;
|
||||
};
|
||||
|
||||
class IDBDriver;
|
||||
|
||||
class IQuery
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns a pointer to the current result set, if any.
|
||||
*
|
||||
* @return An IResultSet pointer on success,
|
||||
* NULL if no result set exists.
|
||||
*/
|
||||
virtual IResultSet *GetResultSet() =0;
|
||||
|
||||
/**
|
||||
* @brief Advances to the next result set if one exists. This
|
||||
* is for checking for MORE result sets, and should not be used
|
||||
* on the first result set.
|
||||
*
|
||||
* Multiple results only happen in certain cases, such as CALLing
|
||||
* stored procedure that have a SELECTs, where MySQL will return
|
||||
* both the CALL status and one or more SELECT result sets. If
|
||||
* you do not process these results, they will be automatically
|
||||
* processed for you. However, the behaviour of creating a new
|
||||
* query from the same connection while results are left
|
||||
* unprocessed is undefined, and may result in a dropped
|
||||
* connection. Therefore, process all extra results or destroy the
|
||||
* IQuery pointer before starting a new query.
|
||||
*
|
||||
* Again, this only happens in very specific cases, so there is
|
||||
* no need to call this for normal queries.
|
||||
*
|
||||
* After calling this function, GetResultSet() must be called
|
||||
* again to return the result set. The previous result set
|
||||
* is automatically destroyed and will be unusable.
|
||||
*
|
||||
* @return True if another result set is
|
||||
* available, false otherwise.
|
||||
*/
|
||||
virtual bool FetchMoreResults() =0;
|
||||
|
||||
/**
|
||||
* @brief Frees resources created by this query.
|
||||
*/
|
||||
virtual void Destroy() =0;
|
||||
};
|
||||
|
||||
class IPreparedQuery : public IQuery
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Binds an integer parameter.
|
||||
*
|
||||
* @param param Parameter index, starting from 0.
|
||||
* @param num Number to bind as a value.
|
||||
* @param signd True to write as signed, false to write as
|
||||
* unsigned.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool BindParamInt(unsigned int param, int num, bool signd=true) =0;
|
||||
|
||||
/**
|
||||
* @brief Binds a float parameter.
|
||||
*
|
||||
* @param param Parameter index, starting from 0.
|
||||
* @param f Float to bind as a value.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool BindParamFloat(unsigned int param, float f) =0;
|
||||
|
||||
/**
|
||||
* @brief Binds an SQL NULL type as a parameter.
|
||||
*
|
||||
* @param param Parameter index, starting from 0.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool BindParamNull(unsigned int param) =0;
|
||||
|
||||
/**
|
||||
* @brief Binds a string as a parameter.
|
||||
*
|
||||
* @param param Parameter index, starting from 0.
|
||||
* @param text Pointer to a null-terminated string.
|
||||
* @param copy If true, the pointer is assumed to be
|
||||
* volatile and a temporary copy may be
|
||||
* made for safety.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool BindParamString(unsigned int param, const char *text, bool copy) =0;
|
||||
|
||||
/**
|
||||
* @brief Binds a blob of raw data as a parameter.
|
||||
*
|
||||
* @param param Parameter index, starting from 0.
|
||||
* @param data Pointer to a blob of memory.
|
||||
* @param length Number of bytes to copy.
|
||||
* @param copy If true, the pointer is assumed to be
|
||||
* volatile and a temporary copy may be
|
||||
* made for safety.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool BindParamBlob(unsigned int param,
|
||||
const void *data,
|
||||
size_t length,
|
||||
bool copy) =0;
|
||||
|
||||
/**
|
||||
* @brief Executes the query with the currently bound parameters.
|
||||
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool Execute() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the last error message from this statement.
|
||||
*
|
||||
* @param errCode Optional pointer to store the driver-specific
|
||||
* error code.
|
||||
* @return Error message string.
|
||||
*/
|
||||
virtual const char *GetError(int *errCode=NULL) =0;
|
||||
|
||||
/**
|
||||
* @brief Number of rows affected by the last execute.
|
||||
*
|
||||
* @return Number of rows affected by the last execute.
|
||||
*/
|
||||
virtual unsigned int GetAffectedRows() =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the last insert ID on this database connection.
|
||||
*
|
||||
* @return Row insertion ID of the last execute, if any.
|
||||
*/
|
||||
virtual unsigned int GetInsertID() =0;
|
||||
};
|
||||
|
||||
class IDBDriver;
|
||||
|
||||
/**
|
||||
* @brief Encapsulates a database connection.
|
||||
*/
|
||||
class IDatabase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Disconnects the database and frees its associated memory.
|
||||
* Note that the actual object will not be freed until all open
|
||||
* references have been closed.
|
||||
*
|
||||
* It is guaranteed that an IDatabase pointer won't be destroyed until
|
||||
* all open IQuery or IPreparedQuery pointers are closed.
|
||||
*
|
||||
* This function is thread safe.
|
||||
*
|
||||
* @return True if object was destroyed, false if
|
||||
* references are remaining.
|
||||
*/
|
||||
virtual bool Close() =0;
|
||||
|
||||
/**
|
||||
* @brief Error code and string returned by the last operation on this
|
||||
* connection.
|
||||
*
|
||||
* This function is not thread safe and must be included in any locks.
|
||||
*
|
||||
* @param errorCode Optional pointer to retrieve an error code.
|
||||
* @return Error string pointer (empty if none).
|
||||
*/
|
||||
virtual const char *GetError(int *errorCode=NULL) =0;
|
||||
|
||||
/**
|
||||
* @brief Prepares and executes a query in one step, and discards
|
||||
* any return data.
|
||||
*
|
||||
* This function is not thread safe and must be included in any locks.
|
||||
*
|
||||
* @param query Query string.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool DoSimpleQuery(const char *query) =0;
|
||||
|
||||
/**
|
||||
* @brief Prepares and executes a query in one step, and returns
|
||||
* the resultant data set.
|
||||
*
|
||||
* Note: If a query contains more than one result set, each
|
||||
* result set must be processed before a new query is started.
|
||||
*
|
||||
* This function is not thread safe and must be included in any locks.
|
||||
*
|
||||
* @param query Query string.
|
||||
* @return IQuery pointer on success, NULL otherwise.
|
||||
*/
|
||||
virtual IQuery *DoQuery(const char *query) =0;
|
||||
|
||||
/**
|
||||
* @brief Prepares a query statement for multiple executions and/or
|
||||
* binding marked parameters (? in MySQL/sqLite, $n in PostgreSQL).
|
||||
*
|
||||
* This function is not thread safe and must be included in any locks.
|
||||
*
|
||||
* @param query Query string.
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum length of the error buffer.
|
||||
* @param errCode Optional pointer to store a driver-specific error code.
|
||||
* @return IPreparedQuery pointer on success, NULL
|
||||
* otherwise.
|
||||
*/
|
||||
virtual IPreparedQuery *PrepareQuery(const char *query, char *error, size_t maxlength, int *errCode=NULL) =0;
|
||||
|
||||
/**
|
||||
* Quotes a string for insertion into a query.
|
||||
*
|
||||
* @param str Source string.
|
||||
* @param buffer Buffer to store new string (should not overlap source string).
|
||||
* @param maxlen Maximum length of the output buffer.
|
||||
* @param newSize Pointer to store the output size.
|
||||
* @return True on success, false if the output buffer is not big enough.
|
||||
* If not big enough, the required buffer size is passed through
|
||||
* newSize.
|
||||
*/
|
||||
virtual bool QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newSize) =0;
|
||||
|
||||
/**
|
||||
* @brief Number of rows affected by the last execute.
|
||||
*
|
||||
* This function is not thread safe and must be included in any locks.
|
||||
*
|
||||
* @return Number of rows affected by the last execute.
|
||||
*/
|
||||
virtual unsigned int GetAffectedRows() =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the last insert ID on this database connection.
|
||||
*
|
||||
* This function is not thread safe and must be included in any locks.
|
||||
*
|
||||
* @return Row insertion ID of the last execute, if any.
|
||||
*/
|
||||
virtual unsigned int GetInsertID() =0;
|
||||
|
||||
/**
|
||||
* @brief Locks the database for an atomic query+retrieval operation.
|
||||
*
|
||||
* @return True on success, false if not supported.
|
||||
*/
|
||||
virtual bool LockForFullAtomicOperation() =0;
|
||||
|
||||
/**
|
||||
* @brief Unlocks a locked atomic fetch.
|
||||
*/
|
||||
virtual void UnlockFromFullAtomicOperation() =0;
|
||||
|
||||
/**
|
||||
* @brief Increases the reference count on the database.
|
||||
*
|
||||
* This function is thread safe.
|
||||
*/
|
||||
virtual void IncReferenceCount() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the parent driver.
|
||||
*
|
||||
* This function is thread safe.
|
||||
*/
|
||||
virtual IDBDriver *GetDriver() =0;
|
||||
|
||||
/**
|
||||
* @brief Prepares and executes a binary query in one step, and discards
|
||||
* any return data.
|
||||
*
|
||||
* This function is not thread safe and must be included in any locks.
|
||||
*
|
||||
* @param query Query string.
|
||||
* @param length Length of query string.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool DoSimpleQueryEx(const char *query, size_t len) =0;
|
||||
|
||||
/**
|
||||
* @brief Prepares and executes a binary query in one step, and returns
|
||||
* the resultant data set.
|
||||
*
|
||||
* Note: If a query contains more than one result set, each
|
||||
* result set must be processed before a new query is started.
|
||||
*
|
||||
* This function is not thread safe and must be included in any locks.
|
||||
*
|
||||
* @param query Query string.
|
||||
* @return IQuery pointer on success, NULL otherwise.
|
||||
*/
|
||||
virtual IQuery *DoQueryEx(const char *query, size_t len) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes database connection info.
|
||||
*/
|
||||
struct DatabaseInfo
|
||||
{
|
||||
DatabaseInfo()
|
||||
{
|
||||
dbiVersion = SMINTERFACE_DBI_VERSION;
|
||||
port = 0;
|
||||
maxTimeout = 0;
|
||||
}
|
||||
unsigned int dbiVersion; /**< DBI Version for backwards compatibility */
|
||||
const char *host; /**< Host string */
|
||||
const char *database; /**< Database name string */
|
||||
const char *user; /**< User to authenticate as */
|
||||
const char *pass; /**< Password to authenticate with */
|
||||
const char *driver; /**< Driver to use */
|
||||
unsigned int port; /**< Port to use, 0=default */
|
||||
unsigned int maxTimeout; /**< Maximum timeout, 0=default */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes an SQL driver.
|
||||
*/
|
||||
class IDBDriver
|
||||
{
|
||||
public:
|
||||
virtual unsigned int GetDBIVersion()
|
||||
{
|
||||
return SMINTERFACE_DBI_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Initiates a database connection.
|
||||
*
|
||||
* Note: Persistent connections should never be created from a thread.
|
||||
*
|
||||
* @param info Database connection info pointer.
|
||||
* @param persistent If true, a previous persistent connection will
|
||||
* be re-used if possible.
|
||||
* @param error Buffer to store error message.
|
||||
* @param maxlength Maximum size of the error buffer.
|
||||
* @return A new IDatabase pointer, or NULL on failure.
|
||||
*/
|
||||
virtual IDatabase *Connect(const DatabaseInfo *info, bool persistent, char *error, size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a case insensitive database identifier string.
|
||||
*
|
||||
* @return String containing an identifier.
|
||||
*/
|
||||
virtual const char *GetIdentifier() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a case sensitive implementation name.
|
||||
*
|
||||
* @return String containing an implementation name.
|
||||
*/
|
||||
virtual const char *GetProductName() =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves a Handle_t handle of the IDBDriver type.
|
||||
*
|
||||
* @return A Handle_t handle.
|
||||
*/
|
||||
virtual Handle_t GetHandle() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the driver's controlling identity (must be the same
|
||||
* as from IExtension::GetIdentity).
|
||||
*
|
||||
* @return An IdentityToken_t identity.
|
||||
*/
|
||||
virtual IdentityToken_t *GetIdentity() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the driver is thread safe.
|
||||
*
|
||||
* @return True if thread safe, false otherwise.
|
||||
*/
|
||||
virtual bool IsThreadSafe() =0;
|
||||
|
||||
/**
|
||||
* @brief Initializes thread safety for the calling thread.
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool InitializeThreadSafety() =0;
|
||||
|
||||
/**
|
||||
* @brief Shuts down thread safety for the calling thread.
|
||||
*/
|
||||
virtual void ShutdownThreadSafety() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Priority queue level.
|
||||
*/
|
||||
enum PrioQueueLevel
|
||||
{
|
||||
PrioQueue_High, /**< High priority */
|
||||
PrioQueue_Normal, /**< Normal priority */
|
||||
PrioQueue_Low /**< Low priority */
|
||||
};
|
||||
|
||||
/**
|
||||
* Specification for a threaded database operation.
|
||||
*/
|
||||
class IDBThreadOperation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Must return the driver this operation is using, or
|
||||
* NULL if not using any driver. This is not never inside
|
||||
* the thread.
|
||||
*
|
||||
* @return IDBDriver pointer.
|
||||
*/
|
||||
virtual IDBDriver *GetDriver() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return the object owning this threaded operation.
|
||||
* This is never called inside the thread.
|
||||
*
|
||||
* @return IdentityToken_t pointer.
|
||||
*/
|
||||
virtual IdentityToken_t *GetOwner() =0;
|
||||
|
||||
/**
|
||||
* @brief Called inside the thread; this is where any blocking
|
||||
* or threaded operations must occur.
|
||||
*/
|
||||
virtual void RunThreadPart() =0;
|
||||
|
||||
/**
|
||||
* @brief Called in a server frame after the thread operation
|
||||
* has completed. This is the non-threaded completion callback,
|
||||
* which although optional, is useful for pumping results back
|
||||
* to normal game API.
|
||||
*/
|
||||
virtual void RunThinkPart() =0;
|
||||
|
||||
/**
|
||||
* @brief If RunThinkPart() is not called, this will be called
|
||||
* instead. Note that RunThreadPart() is ALWAYS called regardless,
|
||||
* and this is only called when Core requests that the operation
|
||||
* be scrapped (for example, the database driver might be unloading).
|
||||
*/
|
||||
virtual void CancelThinkPart() =0;
|
||||
|
||||
/**
|
||||
* @brief Called when the operation is finalized and any resources
|
||||
* can be released.
|
||||
*/
|
||||
virtual void Destroy() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Database-related Handle types.
|
||||
*/
|
||||
enum DBHandleType
|
||||
{
|
||||
DBHandle_Driver = 0, /**< Driver Handle */
|
||||
DBHandle_Database = 1, /**< Database Handle */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes the DBI manager.
|
||||
*/
|
||||
class IDBManager : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName() =0;
|
||||
virtual unsigned int GetInterfaceVersion() =0;
|
||||
public:
|
||||
/**
|
||||
* @brief Adds a driver to the DBI system. Not thread safe.
|
||||
*
|
||||
* @param pDriver Database driver.
|
||||
*/
|
||||
virtual void AddDriver(IDBDriver *pDriver) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes a driver from the DBI system. Not thread safe.
|
||||
*
|
||||
* @param pDriver Database driver.
|
||||
*/
|
||||
virtual void RemoveDriver(IDBDriver *pDriver) =0;
|
||||
|
||||
/**
|
||||
* @brief Searches for database info by name. Both the return pointer
|
||||
* and all pointers contained therein should be considered volatile.
|
||||
*
|
||||
* @param name Named database info.
|
||||
* @return DatabaseInfo pointer.
|
||||
*/
|
||||
virtual const DatabaseInfo *FindDatabaseConf(const char *name) =0;
|
||||
|
||||
/**
|
||||
* @brief Tries to connect to a named database. Not thread safe.
|
||||
*
|
||||
* @param name Named database info.
|
||||
* @param pdr Pointer to store the IDBDriver pointer in.
|
||||
* If driver is not found, NULL will be stored.
|
||||
* @param pdb Pointer to store the IDatabase pointer in.
|
||||
* If connection fails, NULL will be stored.
|
||||
* @param persistent If true, the dbmanager will attempt to PConnect
|
||||
* instead of connect.
|
||||
* @param error Error buffer to store a driver's error message.
|
||||
* @param maxlength Maximum length of the error buffer.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool Connect(const char *name,
|
||||
IDBDriver **pdr,
|
||||
IDatabase **pdb,
|
||||
bool persistent,
|
||||
char *error,
|
||||
size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of drivers loaded. Not thread safe.
|
||||
*
|
||||
* @return Number of drivers loaded.
|
||||
*/
|
||||
virtual unsigned int GetDriverCount() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a driver by index. Not thread safe.
|
||||
*
|
||||
* @param index Driver index, starting from 0.
|
||||
* @return IDBDriver pointer for the given index.
|
||||
*/
|
||||
virtual IDBDriver *GetDriver(unsigned int index) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a Handle_t of the IDBDriver type. Not thread safe.
|
||||
*
|
||||
* @param type A DBHandleType value.
|
||||
* @param ptr A pointer corrresponding to a DBHandleType
|
||||
* object.
|
||||
* @param pToken Identity pointer of the owning identity.
|
||||
* @return A new Handle_t handle, or 0 on failure.
|
||||
*/
|
||||
virtual Handle_t CreateHandle(DBHandleType type, void *ptr, IdentityToken_t *pToken) =0;
|
||||
|
||||
/**
|
||||
* @brief Reads an IDBDriver pointer from an IDBDriver handle. Not
|
||||
* thread safe.
|
||||
*
|
||||
* @param hndl Handle_t handle to read.
|
||||
* @param type A DBHandleType value.
|
||||
* @param ptr Pointer to store the object pointer.
|
||||
* @return HandleError value.
|
||||
*/
|
||||
virtual HandleError ReadHandle(Handle_t hndl, DBHandleType type, void **ptr) =0;
|
||||
|
||||
/**
|
||||
* @brief Releases an IDBDriver handle.
|
||||
*
|
||||
* @param hndl Handle_t handle to release.
|
||||
* @param type A DBHandleType value.
|
||||
* @param token Identity pointer of the owning identity.
|
||||
* @return HandleError value.
|
||||
*/
|
||||
virtual HandleError ReleaseHandle(Handle_t hndl, DBHandleType type, IdentityToken_t *token) =0;
|
||||
|
||||
/**
|
||||
* @brief Given a driver name, attempts to find it. If it is not found, SourceMod
|
||||
* will attempt to load it. This function is not thread safe.
|
||||
*
|
||||
* @param driver Driver identifier name.
|
||||
* @return IDBDriver pointer on success, NULL otherwise.
|
||||
*/
|
||||
virtual IDBDriver *FindOrLoadDriver(const char *driver) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the default driver, or NULL if none is set. This
|
||||
* function is not thread safe.
|
||||
*
|
||||
* @return IDBDriver pointer on success, NULL otherwise.
|
||||
*/
|
||||
virtual IDBDriver *GetDefaultDriver() =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a threaded database operation to the priority queue.
|
||||
* This function is not thread safe.
|
||||
*
|
||||
* @param op Instance of an IDBThreadOperation.
|
||||
* @param prio Priority level to run at.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool AddToThreadQueue(IDBThreadOperation *op, PrioQueueLevel prio) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a dependency from one extension to the owner of a driver.
|
||||
*
|
||||
* @param myself Extension that is using the IDBDriver.
|
||||
* @param driver Driver that is being used.
|
||||
*/
|
||||
virtual void AddDependency(IExtension *myself, IDBDriver *driver) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_INTERFACE_DBDRIVER_H_
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_INTERFACE_DATAPACK_H_
|
||||
#define _INCLUDE_SOURCEMOD_INTERFACE_DATAPACK_H_
|
||||
|
||||
#include <sp_vm_api.h>
|
||||
|
||||
/**
|
||||
* @file IDataPack.h
|
||||
* @brief Contains functions for packing data abstractly to/from plugins. The wrappers
|
||||
* for creating these are contained in ISourceMod.h
|
||||
*/
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Specifies a data pack that can only be read.
|
||||
*/
|
||||
class IDataReader
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Resets the position in the data stream to the beginning.
|
||||
*/
|
||||
virtual void Reset() const =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the current stream position.
|
||||
*
|
||||
* @return Index into the stream.
|
||||
*/
|
||||
virtual size_t GetPosition() const =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the current stream position.
|
||||
*
|
||||
* @param pos Index to set the stream at.
|
||||
* @return True if succeeded, false if out of bounds.
|
||||
*/
|
||||
virtual bool SetPosition(size_t pos) const =0;
|
||||
|
||||
/**
|
||||
* @brief Reads one cell from the data stream.
|
||||
*
|
||||
* @return A cell read from the current position.
|
||||
*/
|
||||
virtual cell_t ReadCell() const =0;
|
||||
|
||||
/**
|
||||
* @brief Reads one float from the data stream.
|
||||
*
|
||||
* @return A float read from the current position.
|
||||
*/
|
||||
virtual float ReadFloat() const =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether or not a specified number of bytes from the current stream
|
||||
* position to the end can be read.
|
||||
*
|
||||
* @param bytes Number of bytes to simulate reading.
|
||||
* @return True if can be read, false otherwise.
|
||||
*/
|
||||
virtual bool IsReadable(size_t bytes) const =0;
|
||||
|
||||
/**
|
||||
* @brief Reads a string from the data stream.
|
||||
*
|
||||
* @param len Optional pointer to store the string length.
|
||||
* @return Pointer to the string, or NULL if out of bounds.
|
||||
*/
|
||||
virtual const char *ReadString(size_t *len) const =0;
|
||||
|
||||
/**
|
||||
* @brief Reads the current position as a generic address.
|
||||
*
|
||||
* @return Pointer to the memory.
|
||||
*/
|
||||
virtual void *GetMemory() const =0;
|
||||
|
||||
/**
|
||||
* @brief Reads the current position as a generic data type.
|
||||
*
|
||||
* @param size Optional pointer to store the size of the data type.
|
||||
* @return Pointer to the data, or NULL if out of bounds.
|
||||
*/
|
||||
virtual void *ReadMemory(size_t *size) const =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Specifies a data pack that can only be written.
|
||||
*/
|
||||
class IDataPack : public IDataReader
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Resets the used size of the stream back to zero.
|
||||
*/
|
||||
virtual void ResetSize() =0;
|
||||
|
||||
/**
|
||||
* @brief Packs one cell into the data stream.
|
||||
*
|
||||
* @param cell Cell value to write.
|
||||
*/
|
||||
virtual void PackCell(cell_t cell) =0;
|
||||
|
||||
/**
|
||||
* @brief Packs one float into the data stream.
|
||||
*
|
||||
* @param val Float value to write.
|
||||
*/
|
||||
virtual void PackFloat(float val) =0;
|
||||
|
||||
/**
|
||||
* @brief Packs one string into the data stream.
|
||||
* The length is recorded as well for buffer overrun protection.
|
||||
*
|
||||
* @param string String to write.
|
||||
*/
|
||||
virtual void PackString(const char *string) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a generic block of memory in the stream.
|
||||
*
|
||||
* Note that the pointer it returns can be invalidated on further
|
||||
* writing, since the stream size may grow. You may need to double back
|
||||
* and fetch the pointer again.
|
||||
*
|
||||
* @param size Size of the memory to create in the stream.
|
||||
* @param addr Optional pointer to store the relocated memory address.
|
||||
* @return Current position of the stream beforehand.
|
||||
*/
|
||||
virtual size_t CreateMemory(size_t size, void **addr) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_INTERFACE_DATAPACK_H_
|
||||
@@ -0,0 +1,439 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
|
||||
#define _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <ILibrarySys.h>
|
||||
|
||||
/**
|
||||
* @file IExtensionSys.h
|
||||
* @brief Defines the interface for loading/unloading/managing extensions.
|
||||
*/
|
||||
|
||||
struct edict_t;
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class IExtensionInterface;
|
||||
typedef void * ITERATOR; /**< Generic pointer for dependency iterators */
|
||||
|
||||
/**
|
||||
* @brief Encapsulates an IExtensionInterface and its dependencies.
|
||||
*/
|
||||
class IExtension
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns whether or not the extension is properly loaded.
|
||||
*/
|
||||
virtual bool IsLoaded() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the extension's API interface
|
||||
*
|
||||
* @return An IExtensionInterface pointer.
|
||||
*/
|
||||
virtual IExtensionInterface *GetAPI() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the filename of the extension, relative to the
|
||||
* extension folder. If the extension is an "external" extension,
|
||||
* the file path is specified by the extension itself, and may be
|
||||
* arbitrary (not real).
|
||||
*
|
||||
* @return A string containing the extension file name.
|
||||
*/
|
||||
virtual const char *GetFilename() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the extension's identity token.
|
||||
*
|
||||
* @return An IdentityToken_t pointer.
|
||||
*/
|
||||
virtual IdentityToken_t *GetIdentity() =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the extension dependency list for this extension.
|
||||
*
|
||||
* @param pOwner Optional pointer to store the first interface's owner.
|
||||
* @param pInterface Optional pointer to store the first interface.
|
||||
* @return An ITERATOR pointer for the results, or NULL if no results at all.
|
||||
*/
|
||||
virtual ITERATOR *FindFirstDependency(IExtension **pOwner, SMInterface **pInterface) =0;
|
||||
|
||||
/**
|
||||
* @brief Finds the next dependency in the dependency list.
|
||||
*
|
||||
* @param iter Pointer to iterator from FindFirstDependency.
|
||||
* @param pOwner Optional pointer to store the interface's owner.
|
||||
* @param pInterface Optional pointer to store the interface.
|
||||
* @return True if there are more results after this, false otherwise.
|
||||
*/
|
||||
virtual bool FindNextDependency(ITERATOR *iter, IExtension **pOwner, SMInterface **pInterface) =0;
|
||||
|
||||
/**
|
||||
* @brief Frees an ITERATOR handle from FindFirstDependency.
|
||||
*
|
||||
* @param iter Pointer to iterator to free.
|
||||
*/
|
||||
virtual void FreeDependencyIterator(ITERATOR *iter) =0;
|
||||
|
||||
/**
|
||||
* @brief Queries the extension to see its run state.
|
||||
*
|
||||
* @param error Error buffer (may be NULL).
|
||||
* @param maxlength Maximum length of buffer.
|
||||
* @return True if extension is okay, false if not okay.
|
||||
*/
|
||||
virtual bool IsRunning(char *error, size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the extension is local (from the extensions
|
||||
* folder), or is from an external source (such as Metamod:Source).
|
||||
*
|
||||
* @return True if from an external source,
|
||||
* false if local to SourceMod.
|
||||
*/
|
||||
virtual bool IsExternal() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Version code of the IExtensionInterface API itself.
|
||||
*
|
||||
* Note: This is bumped when IShareSys is changed, because IShareSys
|
||||
* itself is not versioned.
|
||||
*/
|
||||
#define SMINTERFACE_EXTENSIONAPI_VERSION 4
|
||||
|
||||
/**
|
||||
* @brief The interface an extension must expose.
|
||||
*/
|
||||
class IExtensionInterface
|
||||
{
|
||||
public:
|
||||
/** Returns the interface API version */
|
||||
virtual unsigned int GetExtensionVersion()
|
||||
{
|
||||
return SMINTERFACE_EXTENSIONAPI_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Called when the extension is loaded.
|
||||
*
|
||||
* @param me Pointer back to extension.
|
||||
* @param sys Pointer to interface sharing system of SourceMod.
|
||||
* @param error Error buffer to print back to, if any.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @param late If this extension was loaded "late" (i.e. manually).
|
||||
* @return True if load should continue, false otherwise.
|
||||
*/
|
||||
virtual bool OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late) =0;
|
||||
|
||||
/**
|
||||
* @brief Called when the extension is about to be unloaded.
|
||||
*/
|
||||
virtual void OnExtensionUnload() =0;
|
||||
|
||||
/**
|
||||
* @brief Called when all extensions are loaded (loading cycle is done).
|
||||
* If loaded late, this will be called right after OnExtensionLoad().
|
||||
*/
|
||||
virtual void OnExtensionsAllLoaded() =0;
|
||||
|
||||
/**
|
||||
* @brief Called when your pause state is about to change.
|
||||
*
|
||||
* @param pause True if pausing, false if unpausing.
|
||||
*/
|
||||
virtual void OnExtensionPauseChange(bool pause) =0;
|
||||
|
||||
/**
|
||||
* @brief Asks the extension whether it's safe to remove an external
|
||||
* interface it's using. If it's not safe, return false, and the
|
||||
* extension will be unloaded afterwards.
|
||||
*
|
||||
* NOTE: It is important to also hook NotifyInterfaceDrop() in order to clean
|
||||
* up resources.
|
||||
*
|
||||
* @param pInterface Pointer to interface being dropped. This
|
||||
* pointer may be opaque, and it should not
|
||||
* be queried using SMInterface functions unless
|
||||
* it can be verified to match an existing
|
||||
* pointer of known type.
|
||||
* @return True to continue, false to unload this
|
||||
* extension afterwards.
|
||||
*/
|
||||
virtual bool QueryInterfaceDrop(SMInterface *pInterface)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Notifies the extension that an external interface it uses is being removed.
|
||||
*
|
||||
* @param pInterface Pointer to interface being dropped. This
|
||||
* pointer may be opaque, and it should not
|
||||
* be queried using SMInterface functions unless
|
||||
* it can be verified to match an existing
|
||||
*/
|
||||
virtual void NotifyInterfaceDrop(SMInterface *pInterface)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return false to tell Core that your extension should be considered unusable.
|
||||
*
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Size of error buffer.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool QueryRunning(char *error, size_t maxlength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief For extensions loaded through SourceMod, this should return true
|
||||
* if the extension needs to attach to Metamod:Source. If the extension
|
||||
* is loaded through Metamod:Source, and uses SourceMod optionally, it must
|
||||
* return false.
|
||||
*
|
||||
* @return True if Metamod:Source is needed.
|
||||
*/
|
||||
virtual bool IsMetamodExtension() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return a string containing the extension's short name.
|
||||
*
|
||||
* @return String containing extension name.
|
||||
*/
|
||||
virtual const char *GetExtensionName() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return a string containing the extension's URL.
|
||||
*
|
||||
* @return String containing extension URL.
|
||||
*/
|
||||
virtual const char *GetExtensionURL() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return a string containing a short identifier tag.
|
||||
*
|
||||
* @return String containing extension tag.
|
||||
*/
|
||||
virtual const char *GetExtensionTag() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return a string containing a short author identifier.
|
||||
*
|
||||
* @return String containing extension author.
|
||||
*/
|
||||
virtual const char *GetExtensionAuthor() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return a string containing version information.
|
||||
*
|
||||
* Any version string format can be used, however, SourceMod
|
||||
* makes a special guarantee version numbers in the form of
|
||||
* A.B.C.D will always be fully displayed, where:
|
||||
*
|
||||
* A is a major version number of at most one digit.
|
||||
* B is a minor version number of at most two digits.
|
||||
* C is a minor version number of at most two digits.
|
||||
* D is a build number of at most 5 digits.
|
||||
*
|
||||
* Thus, thirteen characters of display is guaranteed.
|
||||
*
|
||||
* @return String containing extension version.
|
||||
*/
|
||||
virtual const char *GetExtensionVerString() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return a string containing description text.
|
||||
*
|
||||
* The description text may be longer than the other identifiers,
|
||||
* as it is only displayed when viewing one extension at a time.
|
||||
* However, it should not have newlines, or any other characters
|
||||
* which would otherwise disrupt the display pattern.
|
||||
*
|
||||
* @return String containing extension description.
|
||||
*/
|
||||
virtual const char *GetExtensionDescription() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return a string containing the compilation date.
|
||||
*
|
||||
* @return String containing the compilation date.
|
||||
*/
|
||||
virtual const char *GetExtensionDateString() =0;
|
||||
|
||||
/**
|
||||
* @brief Called on server activation before plugins receive the OnServerLoad forward.
|
||||
*
|
||||
* @param pEdictList Edicts list.
|
||||
* @param edictCount Number of edicts in the list.
|
||||
* @param clientMax Maximum number of clients allowed in the server.
|
||||
*/
|
||||
virtual void OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Returned via OnMetamodQuery() to get an IExtensionManager pointer.
|
||||
*/
|
||||
#define SOURCEMOD_INTERFACE_EXTENSIONS "SM_ExtensionManager"
|
||||
|
||||
/**
|
||||
* @brief Fired through OnMetamodQuery() to notify plugins that SourceMod is
|
||||
* loaded.
|
||||
*
|
||||
* Plugins should not return an interface pointer or IFACE_OK, instead,
|
||||
* they should attach as needed by searching for SOURCEMOD_INTERFACE_EXTENSIONS.
|
||||
*
|
||||
* This may be fired more than once; if already attached, an extension should
|
||||
* not attempt to re-attach. The purpose of this is to notify Metamod:Source
|
||||
* plugins which load after SourceMod loads.
|
||||
*/
|
||||
#define SOURCEMOD_NOTICE_EXTENSIONS "SM_ExtensionsAttachable"
|
||||
|
||||
#define SMINTERFACE_EXTENSIONMANAGER_NAME "IExtensionManager"
|
||||
#define SMINTERFACE_EXTENSIONMANAGER_VERSION 2
|
||||
|
||||
/**
|
||||
* @brief Manages the loading/unloading of extensions.
|
||||
*/
|
||||
class IExtensionManager : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_EXTENSIONMANAGER_NAME;
|
||||
}
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_EXTENSIONMANAGER_VERSION;
|
||||
}
|
||||
virtual bool IsVersionCompatible(unsigned int version)
|
||||
{
|
||||
if (version < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return SMInterface::IsVersionCompatible(version);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Loads a extension into the extension system.
|
||||
*
|
||||
* @param path Path to extension file, relative to the
|
||||
* extensions folder.
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum error buffer length.
|
||||
* @return New IExtension on success, NULL on failure.
|
||||
* If NULL is returned, the error buffer will be
|
||||
* filled with a null-terminated string.
|
||||
*/
|
||||
virtual IExtension *LoadExtension(const char *path,
|
||||
char *error,
|
||||
size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Loads an extension into the extension system, directly,
|
||||
* as an external extension.
|
||||
*
|
||||
* The extension receives all normal callbacks. However, it is
|
||||
* never opened via LoadLibrary/dlopen or closed via FreeLibrary
|
||||
* or dlclose.
|
||||
*
|
||||
* @param pInterface Pointer to an IExtensionInterface instance.
|
||||
* @param filepath Relative path to the extension's file, from
|
||||
* mod folder.
|
||||
* @param filename Name to use to uniquely identify the extension.
|
||||
* The name should be generic, without any
|
||||
* platform-specific suffices. For example,
|
||||
* sdktools.ext instead of sdktools.ext.so.
|
||||
* This filename is used to detect if the
|
||||
* extension is already loaded, and to verify
|
||||
* plugins that require the same extension.
|
||||
* @param error Buffer to store error message.
|
||||
* @param maxlength Maximum size of the error buffer.
|
||||
* @return IExtension pointer on success, NULL on failure.
|
||||
* If NULL is returned, the error buffer will be
|
||||
* filled with a null-terminated string.
|
||||
*/
|
||||
virtual IExtension *LoadExternal(IExtensionInterface *pInterface,
|
||||
const char *filepath,
|
||||
const char *filename,
|
||||
char *error,
|
||||
size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Attempts to unload an extension. External extensions must
|
||||
* call this before unloading.
|
||||
*
|
||||
* @param pExt IExtension pointer.
|
||||
* @return True if successful, false otherwise.
|
||||
*/
|
||||
virtual bool UnloadExtension(IExtension *pExt) =0;
|
||||
};
|
||||
|
||||
#define SM_IFACEPAIR(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
|
||||
|
||||
#define SM_FIND_IFACE_OR_FAIL(prefix, variable, errbuf, errsize) \
|
||||
if (!sharesys->RequestInterface(SM_IFACEPAIR(prefix), myself, (SMInterface **)&variable)) \
|
||||
{ \
|
||||
if (errbuf) \
|
||||
{ \
|
||||
size_t len = snprintf(errbuf, \
|
||||
errsize, \
|
||||
"Could not find interface: %s (version: %d)", \
|
||||
SM_IFACEPAIR(prefix)); \
|
||||
if (len >= errsize) \
|
||||
{ \
|
||||
errbuf[errsize - 1] = '\0'; \
|
||||
} \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#define SM_FIND_IFACE(prefix, variable) \
|
||||
sharesys->RequestInterface(SM_IFACEPAIR(prefix), myself, (SMInterface **)&variable);
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_FORWARDINTERFACE_H_
|
||||
#define _INCLUDE_SOURCEMOD_FORWARDINTERFACE_H_
|
||||
|
||||
/**
|
||||
* @file IForwardSys.h
|
||||
* @brief Defines the interface for managing collections ("forwards") of plugin calls.
|
||||
*
|
||||
* The Forward System is responsible for managing automated collections of IPluginFunctions.
|
||||
* It thus provides wrappers to calling many functions at once. There are two types of such
|
||||
* wrappers: Managed and Unmanaged. Confusingly, these terms refer to whether the user manages
|
||||
* the forwards, not Core. Managed forwards are completely managed by the user, and are custom
|
||||
* editable collections. Unmanaged forwards are the opposite, and will only work on a single global
|
||||
* function name in all plugins.
|
||||
*/
|
||||
|
||||
#include <IPluginSys.h>
|
||||
#include <sp_vm_api.h>
|
||||
|
||||
using namespace SourcePawn;
|
||||
|
||||
#define SMINTERFACE_FORWARDMANAGER_NAME "IForwardManager"
|
||||
#define SMINTERFACE_FORWARDMANAGER_VERSION 2
|
||||
|
||||
/*
|
||||
* There is some very important documentation at the bottom of this file.
|
||||
* Readers interested in knowing more about the forward system, scrolling down is a must!
|
||||
*/
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Defines the event hook result types plugins can return.
|
||||
*/
|
||||
enum ResultType
|
||||
{
|
||||
Pl_Continue = 0, /**< No result */
|
||||
Pl_Changed = 1, /**< Inputs or outputs have been overridden with new values */
|
||||
Pl_Handled = 3, /**< Result was handled, stop at the end */
|
||||
Pl_Stop = 4, /**< Result was handled, stop now */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Defines how a forward iterates through plugin functions.
|
||||
*/
|
||||
enum ExecType
|
||||
{
|
||||
ET_Ignore = 0, /**< Ignore all return values, return 0 */
|
||||
ET_Single = 1, /**< Only return the last exec, ignore all others */
|
||||
ET_Event = 2, /**< Acts as an event with the ResultTypes above, no mid-Stops allowed, returns highest */
|
||||
ET_Hook = 3, /**< Acts as a hook with the ResultTypes above, mid-Stops allowed, returns highest */
|
||||
ET_Custom = 4, /**< Ignored or handled by an IForwardFilter */
|
||||
};
|
||||
|
||||
class IForward;
|
||||
|
||||
/**
|
||||
* @brief Allows interception of how the Forward System executes functions.
|
||||
*/
|
||||
class IForwardFilter
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Called when an error occurs executing a plugin.
|
||||
*
|
||||
* @param fwd IForward pointer.
|
||||
* @param func IPluginFunction pointer to the failed function.
|
||||
* @param err Error code.
|
||||
* @return True to handle, false to pass to global error reporter.
|
||||
*/
|
||||
virtual bool OnErrorReport(IForward *fwd,
|
||||
IPluginFunction *func,
|
||||
int err)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called after each function return during execution.
|
||||
* NOTE: Only used for ET_Custom.
|
||||
*
|
||||
* @param fwd IForward pointer.
|
||||
* @param func IPluginFunction pointer to the executed function.
|
||||
* @param retval Pointer to current return value (can be modified).
|
||||
* @return ResultType denoting the next action to take.
|
||||
*/
|
||||
virtual ResultType OnFunctionReturn(IForward *fwd,
|
||||
IPluginFunction *func,
|
||||
cell_t *retval)
|
||||
{
|
||||
return Pl_Continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when execution begins.
|
||||
*/
|
||||
virtual void OnExecuteBegin()
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Called when execution ends.
|
||||
*
|
||||
* @param final_ret Final return value (modifiable).
|
||||
* @param success Number of successful execs.
|
||||
* @param failed Number of failed execs.
|
||||
*/
|
||||
virtual void OnExecuteEnd(cell_t *final_ret, unsigned int success, unsigned int failed)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Unmanaged Forward, abstracts calling multiple functions as "forwards," or collections of functions.
|
||||
*
|
||||
* Parameters should be pushed in forward order, unlike the virtual machine/IPluginContext order.
|
||||
* Some functions are repeated in here because their documentation differs from their IPluginFunction equivalents.
|
||||
* Missing are the Push functions, whose only doc change is that they throw SP_ERROR_PARAM on type mismatches.
|
||||
*/
|
||||
class IForward : public ICallable
|
||||
{
|
||||
public:
|
||||
/** Virtual Destructor */
|
||||
virtual ~IForward()
|
||||
{
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the name of the forward.
|
||||
*
|
||||
* @return Forward name.
|
||||
*/
|
||||
virtual const char *GetForwardName() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of functions in this forward.
|
||||
*
|
||||
* @return Number of functions in forward.
|
||||
*/
|
||||
virtual unsigned int GetFunctionCount() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the method of multi-calling this forward has.
|
||||
*
|
||||
* @return ExecType of the forward.
|
||||
*/
|
||||
virtual ExecType GetExecType() =0;
|
||||
|
||||
/**
|
||||
* @brief Executes the forward.
|
||||
*
|
||||
* @param result Optional pointer to store result in.
|
||||
* @param filter Optional pointer to an IForwardFilter.
|
||||
* @return Error code, if any.
|
||||
*/
|
||||
virtual int Execute(cell_t *result, IForwardFilter *filter=NULL) =0;
|
||||
|
||||
/**
|
||||
* @brief Pushes an array of cells onto the current call. Different rules than ICallable.
|
||||
* NOTE: On Execute, the pointer passed will be modified according to the copyback rule.
|
||||
*
|
||||
* @param inarray Array to copy. Cannot be NULL, unlike ICallable's version.
|
||||
* @param cells Number of cells to allocate and optionally read from the input array.
|
||||
* @param flags Whether or not changes should be copied back to the input array.
|
||||
* @return Error code, if any.
|
||||
*/
|
||||
virtual int PushArray(cell_t *inarray, unsigned int cells, int flags=0) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Managed Forward, same as IForward, except the collection can be modified.
|
||||
*/
|
||||
class IChangeableForward : public IForward
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Removes a function from the call list.
|
||||
* NOTE: Only removes one instance.
|
||||
*
|
||||
* @param func Function to remove.
|
||||
* @return Whether or not the function was removed.
|
||||
*/
|
||||
virtual bool RemoveFunction(IPluginFunction *func) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes all instances of a plugin from the call list.
|
||||
*
|
||||
* @param plugin Plugin to remove instances of.
|
||||
* @return Number of functions removed therein.
|
||||
*/
|
||||
virtual unsigned int RemoveFunctionsOfPlugin(IPlugin *plugin) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a function to the call list.
|
||||
* NOTE: Cannot be used during an incomplete call.
|
||||
* NOTE: If used during a call, function is temporarily queued until calls are over.
|
||||
* NOTE: Adding multiple copies of the same function is illegal.
|
||||
*
|
||||
* @param func Function to add.
|
||||
* @return True on success, otherwise false.
|
||||
*/
|
||||
virtual bool AddFunction(IPluginFunction *func) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a function to the call list.
|
||||
* NOTE: Cannot be used during an incomplete call.
|
||||
* NOTE: If used during a call, function is temporarily queued until calls are over.
|
||||
*
|
||||
* @param ctx Context to use as a look-up.
|
||||
* @param index Function id to add.
|
||||
* @return True on success, otherwise false.
|
||||
*/
|
||||
virtual bool AddFunction(IPluginContext *ctx, funcid_t index) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes a function from the call list.
|
||||
* NOTE: Only removes one instance.
|
||||
*
|
||||
* @param ctx Context to use as a look-up.
|
||||
* @param index Function id to add.
|
||||
* @return Whether or not the function was removed.
|
||||
*/
|
||||
virtual bool RemoveFunction(IPluginContext *ctx, funcid_t index) =0;
|
||||
};
|
||||
|
||||
#define SP_PARAMTYPE_ANY 0
|
||||
#define SP_PARAMFLAG_BYREF (1<<0)
|
||||
#define SP_PARAMTYPE_CELL (1<<1)
|
||||
#define SP_PARAMTYPE_FLOAT (2<<1)
|
||||
#define SP_PARAMTYPE_STRING (3<<1)|SP_PARAMFLAG_BYREF
|
||||
#define SP_PARAMTYPE_ARRAY (4<<1)|SP_PARAMFLAG_BYREF
|
||||
#define SP_PARAMTYPE_VARARG (5<<1)
|
||||
|
||||
/**
|
||||
* @brief Describes the various ways to pass parameters to plugins.
|
||||
*/
|
||||
enum ParamType
|
||||
{
|
||||
Param_Any = SP_PARAMTYPE_ANY, /**< Any data type can be pushed */
|
||||
Param_Cell = SP_PARAMTYPE_CELL, /**< Only basic cells can be pushed */
|
||||
Param_Float = SP_PARAMTYPE_FLOAT, /**< Only floats can be pushed */
|
||||
Param_String = SP_PARAMTYPE_STRING, /**< Only strings can be pushed */
|
||||
Param_Array = SP_PARAMTYPE_ARRAY, /**< Only arrays can be pushed */
|
||||
Param_VarArgs = SP_PARAMTYPE_VARARG, /**< Same as "..." in plugins, anything can be pushed, but it will always be byref */
|
||||
Param_CellByRef = SP_PARAMTYPE_CELL|SP_PARAMFLAG_BYREF, /**< Only a cell by reference can be pushed */
|
||||
Param_FloatByRef = SP_PARAMTYPE_FLOAT|SP_PARAMFLAG_BYREF, /**< Only a float by reference can be pushed */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Provides functions for creating/destroying managed and unmanaged forwards.
|
||||
*/
|
||||
class IForwardManager : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_FORWARDMANAGER_NAME;
|
||||
}
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_FORWARDMANAGER_VERSION;
|
||||
}
|
||||
virtual bool IsVersionCompatible(unsigned int version)
|
||||
{
|
||||
if (version < 2 || version > GetInterfaceVersion())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a managed forward. This forward exists globally.
|
||||
* The name used to create the forward is used as its public function in all target plugins.
|
||||
* As new non-private plugins become loaded or unloaded, they will be automatically added
|
||||
* or removed. This is ideal for global, static forwards that are never changed.
|
||||
*
|
||||
* @param name Name of public function to use in forward.
|
||||
* @param et Execution type to be used.
|
||||
* @param num_params Number of parameter this function will have.
|
||||
* NOTE: For varargs, this should include the vararg parameter.
|
||||
* @param types Array of type information about each parameter. If NULL, types
|
||||
* are read off the vararg stream.
|
||||
* @param ... If types is NULL, num_params ParamTypes should be pushed.
|
||||
* @return A new IForward on success, NULL if type combination is impossible.
|
||||
*/
|
||||
virtual IForward *CreateForward(const char *name,
|
||||
ExecType et,
|
||||
unsigned int num_params,
|
||||
const ParamType *types,
|
||||
...) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates an unmanaged forward. This forward exists privately.
|
||||
* Unlike managed forwards, no functions are ever added by the Manager.
|
||||
* However, functions will be removed automatically if their parent plugin is unloaded.
|
||||
*
|
||||
* @param name Name of forward (unused except for lookup, can be NULL for anonymous).
|
||||
* @param et Execution type to be used.
|
||||
* @param num_params Number of parameter this function will have.
|
||||
* NOTE: For varargs, this should include the vararg parameter.
|
||||
* @param types Array of type information about each parameter. If NULL, types
|
||||
* are read off the vararg stream.
|
||||
* @param ... If types is NULL, num_params ParamTypes should be pushed.
|
||||
* @return A new IChangeableForward on success, NULL if type combination is impossible.
|
||||
*/
|
||||
virtual IChangeableForward *CreateForwardEx(const char *name,
|
||||
ExecType et,
|
||||
int num_params,
|
||||
const ParamType *types,
|
||||
...) =0;
|
||||
|
||||
/**
|
||||
* @brief Finds a forward by name. Does not return anonymous forwards (named NULL or "").
|
||||
*
|
||||
* @param name Name of forward.
|
||||
* @param ifchng Optionally store either NULL or an IChangeableForward pointer
|
||||
* depending on type of forward.
|
||||
* @return IForward pointer, or NULL if none found matching the name.
|
||||
*/
|
||||
virtual IForward *FindForward(const char *name, IChangeableForward **ifchng) =0;
|
||||
|
||||
/**
|
||||
* @brief Frees and destroys a forward object.
|
||||
*
|
||||
* @param forward An IForward created by CreateForward() or CreateForwardEx().
|
||||
*/
|
||||
virtual void ReleaseForward(IForward *forward) =0;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* In the AMX Mod X model of forwarding, each forward contained a list of pairs, each pair containing
|
||||
* a function ID and an AMX structure. The forward structure itself did very little but hold parameter types.
|
||||
* An execution call worked like this:
|
||||
* - executeForward() took in a function id and a list of parameters
|
||||
* - for each contained plugin:
|
||||
* - the list of parameters was preprocessed and pushed
|
||||
* - the call was made
|
||||
* - the list was freed and copybacks were made
|
||||
* - return
|
||||
*
|
||||
* The advantages to this is that the system is very easy to implement, and it's fast. The disadvantage is
|
||||
* varargs tend to be very unforgiving and inflexible, and thus weird problems arose with casting. You also
|
||||
* lose flexibility, type checking, and the ability to reasonably use variable arguments lists in the VM.
|
||||
*
|
||||
* SourceMod replaces this forward system with a far more advanced, but a bit bulkier one. The idea is that
|
||||
* each plugin has a table of functions, and each function is an ICallable object. As well as being an ICallable,
|
||||
* each function is an IPluginFunction. An ICallable simply describes the process of adding parameters to a
|
||||
* function call. An IPluginFunction describes the process of actually calling a function and performing allocation,
|
||||
* copybacks, and deallocations.
|
||||
*
|
||||
* A very powerful forward system emerges: a Forward is just a collection of IPluginFunctions. Thus, the same
|
||||
* API can be easily wrapped around a simple list, and it will look transparent to the user.
|
||||
* Advantages:
|
||||
* 1) "SP Forwards" from AMX Mod X are simply IPluginFunctions without a collection.
|
||||
* 2) Forwards are function based, rather than plugin based, and are thus far more flexible at runtime..
|
||||
* 3) [2] Individual functions can be paused and more than one function from the same plugin can be hooked.
|
||||
* 4) [2] One hook type that used to map to many SP Forwards can now be centralized as one Forward.
|
||||
* This helps alleviate messes like Fakemeta.
|
||||
* 5) Parameter pushing is type-checked and allows for variable arguments.
|
||||
*
|
||||
* Note that while #2,3,4 could be added to AMX Mod X, the real binding property is #1, which makes the system
|
||||
* object oriented, rather than AMX Mod X, which hides the objects behind static functions. It is entirely a design
|
||||
* issue, rather than a usability one. The interesting part is when it gets to implementation, which has to cache
|
||||
* parameter pushing until execution. Without this, multiple function calls can be started across one plugin, which
|
||||
* will result in heap corruption given SourcePawn's implementation.
|
||||
*
|
||||
* Observe the new calling process:
|
||||
* - Each parameter is pushed into a local cache using the ICallable interface.
|
||||
* - For each function in the collection:
|
||||
* - Each parameter is decoded and -pushed into the function.
|
||||
* - The call is made.
|
||||
* - Return
|
||||
*
|
||||
* Astute readers will note the (minor) problems:
|
||||
* 1) More memory is used. Specifically, rather than N params of memory, you now have N params * M plugins.
|
||||
* This is because, again, parameters are cached both per-function and per-forward.
|
||||
* 2) There are slightly more calls going around: one extra call for each parameter, since each push is manual.
|
||||
*
|
||||
* HISTORICAL NOTES:
|
||||
* There used to be a # about copy backs.
|
||||
* Note that originally, the Forward implementation was a thin wrapper around IForwards. It did not cache pushes,
|
||||
* and instead immediately fired them to each internal plugin. This was to allow users to know that pointers would
|
||||
* be immediately resolved. Unfortunately, this became extremely burdensome on the API and exposed many problems,
|
||||
* the major (and breaking) one was that two separate Function objects cannot be in a calling process on the same
|
||||
* plugin at once. (:TODO: perhaps prevent that in the IPlugin object?) This is because heap functions lose their order
|
||||
* and become impossible to re-arrange without some global heap tracking mechanism. It also made iterative copy backs
|
||||
* for arrays/references overwhelmingly complex, since each plugin had to have its memory back-patched for each copy.
|
||||
* Therefore, this was scrapped for cached parameters (current implementation), which is the implementation AMX Mod X
|
||||
* uses. It is both faster and works better.
|
||||
*/
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_FORWARDINTERFACE_H_
|
||||
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
|
||||
#define _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IHandleSys.h>
|
||||
|
||||
/**
|
||||
* @file IGameConfigs.h
|
||||
* @brief Abstracts game private data configuration.
|
||||
*/
|
||||
|
||||
#define SMINTERFACE_GAMECONFIG_NAME "IGameConfigManager"
|
||||
#define SMINTERFACE_GAMECONFIG_VERSION 3
|
||||
|
||||
class SendProp;
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Describes a game private data config file
|
||||
*/
|
||||
class IGameConfig
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns an offset value.
|
||||
*
|
||||
* @param key Key to retrieve from the offset section.
|
||||
* @param value Pointer to store the offset value in.
|
||||
* @return True if found, false otherwise.
|
||||
*/
|
||||
virtual bool GetOffset(const char *key, int *value) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns information about a dynamic offset.
|
||||
*
|
||||
* @param key Key to retrieve from the property section.
|
||||
* @return A SendProp pointer, or NULL if not found.
|
||||
*/
|
||||
virtual SendProp *GetSendProp(const char *key) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the value of a key from the "Keys" section.
|
||||
*
|
||||
* @param key Key to retrieve from the Keys section.
|
||||
* @return String containing the value, or NULL if not found.
|
||||
*/
|
||||
virtual const char *GetKeyValue(const char *key) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves a cached memory signature.
|
||||
*
|
||||
* @param key Name of the signature.
|
||||
* @param addr Pointer to store the memory address in.
|
||||
* @return True if the key was found, false otherwise.
|
||||
* Note that true is a valid return even if the
|
||||
* address is NULL.
|
||||
*/
|
||||
virtual bool GetMemSig(const char *key, void **addr) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Manages game config files
|
||||
*/
|
||||
class IGameConfigManager : public SMInterface
|
||||
{
|
||||
public:
|
||||
const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_GAMECONFIG_NAME;
|
||||
}
|
||||
unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_GAMECONFIG_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Loads or finds an already loaded game config file.
|
||||
*
|
||||
* @param file File to load. The path must be relative to the
|
||||
* 'gamedata' folder and the extension should be
|
||||
* omitted.
|
||||
* @param pConfig Pointer to store the game config pointer. Pointer
|
||||
* will be valid even on failure.
|
||||
* @param error Optional error message buffer.
|
||||
* @param maxlength Maximum length of the error buffer.
|
||||
* @return True on success, false if the file failed.
|
||||
*/
|
||||
virtual bool LoadGameConfigFile(const char *file,
|
||||
IGameConfig **pConfig,
|
||||
char *error,
|
||||
size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Closes an IGameConfig pointer. Since a file can be loaded
|
||||
* more than once, the file will not actually be removed from memory
|
||||
* until it is closed once for each call to LoadGameConfigfile().
|
||||
*
|
||||
* @param cfg Pointer to the IGameConfig to close.
|
||||
*/
|
||||
virtual void CloseGameConfigFile(IGameConfig *cfg) =0;
|
||||
|
||||
/**
|
||||
* @brief Reads an GameConfig Handle.
|
||||
*
|
||||
* @param hndl Handle to read.
|
||||
* @param ident Identity of the owner (can be NULL).
|
||||
* @param err Optional error buffer.
|
||||
* @return IGameConfig pointer on success, NULL otherwise.
|
||||
*/
|
||||
virtual IGameConfig *ReadHandle(Handle_t hndl,
|
||||
IdentityToken_t *ident,
|
||||
HandleError *err) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_GAMEHELPERS_H_
|
||||
#define _INCLUDE_SOURCEMOD_GAMEHELPERS_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
|
||||
/**
|
||||
* @file IGameHelpers.h
|
||||
* @brief Provides Source helper functions.
|
||||
*/
|
||||
|
||||
#define SMINTERFACE_GAMEHELPERS_NAME "IGameHelpers"
|
||||
#define SMINTERFACE_GAMEHELPERS_VERSION 2
|
||||
|
||||
class CBaseEntity;
|
||||
class SendProp;
|
||||
class ServerClass;
|
||||
struct edict_t;
|
||||
struct datamap_t;
|
||||
struct typedescription_t;
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Maps the heirarchy of a SendProp.
|
||||
*/
|
||||
struct sm_sendprop_info_t
|
||||
{
|
||||
SendProp *prop; /**< Property instance. */
|
||||
unsigned int actual_offset; /**< Actual computed offset. */
|
||||
};
|
||||
|
||||
class IGameHelpers : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_GAMEHELPERS_NAME;
|
||||
}
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_GAMEHELPERS_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Deprecated; use FindSendPropInfo() instead.
|
||||
*
|
||||
* @param classname Do not use.
|
||||
* @param offset Do not use.
|
||||
* @return Do not use.
|
||||
*/
|
||||
virtual SendProp *FindInSendTable(const char *classname, const char *offset) =0;
|
||||
|
||||
/**
|
||||
* @brief Finds a named server class.
|
||||
*
|
||||
* @return ServerClass pointer on success, NULL on failure.
|
||||
*/
|
||||
virtual ServerClass *FindServerClass(const char *classname) =0;
|
||||
|
||||
/**
|
||||
* @brief Finds a datamap_t definition.
|
||||
*
|
||||
* @param pMap datamap_t pointer.
|
||||
* @param offset Property name.
|
||||
* @return typedescription_t pointer on success, NULL
|
||||
* on failure.
|
||||
*/
|
||||
virtual typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves an entity's datamap_t pointer.
|
||||
*
|
||||
* @param pEntity CBaseEntity entity.
|
||||
* @return datamap_t pointer, or NULL on failure.
|
||||
*/
|
||||
virtual datamap_t *GetDataMap(CBaseEntity *pEntity) =0;
|
||||
|
||||
/**
|
||||
* @brief Marks an edict as state changed for an offset.
|
||||
*
|
||||
* @param pEdict Edict pointer.
|
||||
* @param offset Offset index.
|
||||
*/
|
||||
virtual void SetEdictStateChanged(edict_t *pEdict, unsigned short offset) =0;
|
||||
|
||||
/**
|
||||
* @brief Sends a text message to a client.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param dest Destination on the HUD.
|
||||
* @param msg Message to send.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool TextMsg(int client, int dest, const char *msg) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the server ls a LAN server.
|
||||
*
|
||||
* @return True if LAN server, false otherwise.
|
||||
*/
|
||||
virtual bool IsLANServer() =0;
|
||||
|
||||
/**
|
||||
* @brief Finds a send property in a named ServerClass.
|
||||
*
|
||||
* This version, unlike FindInSendTable(), correctly deduces the
|
||||
* offsets of nested tables.
|
||||
*
|
||||
* @param classname ServerClass name (such as CBasePlayer).
|
||||
* @param offset Offset name (such as m_iAmmo).
|
||||
* @param info Buffer to store sm_sendprop_info_t data.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool FindSendPropInfo(const char *classname,
|
||||
const char *offset,
|
||||
sm_sendprop_info_t *info) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_GAMEHELPERS_H_
|
||||
@@ -0,0 +1,363 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_HANDLESYSTEM_INTERFACE_H_
|
||||
#define _INCLUDE_SOURCEMOD_HANDLESYSTEM_INTERFACE_H_
|
||||
|
||||
/**
|
||||
* @file IHandleSys.h
|
||||
* @brief Defines the interface for creating, reading, and removing Handles.
|
||||
*
|
||||
* The Handle system abstracts generic pointers into typed objects represented by
|
||||
* 32bit codes. This is extremely useful for verifying data integrity and cross-platform
|
||||
* support in SourcePawn scripts. When a Plugin unloads, all its Handles are freed, ensuring
|
||||
* that no memory leaks are present, They have reference counts and thus can be duplicated,
|
||||
* or cloned, and are safe to pass between Plugins even if one is unloaded.
|
||||
*
|
||||
* Handles are created with a given type (custom types may be created). They can have
|
||||
* per-Identity permissions for deletion, reading, and cloning. They also support generic
|
||||
* operations. For example, deleting a Handle will call that type's destructor on the generic
|
||||
* pointer, making cleanup easier for users and eliminating memory leaks.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <sp_vm_types.h>
|
||||
|
||||
#define SMINTERFACE_HANDLESYSTEM_NAME "IHandleSys"
|
||||
#define SMINTERFACE_HANDLESYSTEM_VERSION 3
|
||||
|
||||
/** Specifies no Identity */
|
||||
#define DEFAULT_IDENTITY NULL
|
||||
/** Specifies no Type. This is invalid for everything but reading a Handle. */
|
||||
#define NO_HANDLE_TYPE 0
|
||||
/** Specifies an invalid/NULL Handle */
|
||||
#define BAD_HANDLE 0
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Represents a Handle Type ID.
|
||||
*/
|
||||
typedef unsigned int HandleType_t;
|
||||
|
||||
/**
|
||||
* @brief Represents a Handle ID.
|
||||
*/
|
||||
typedef unsigned int Handle_t;
|
||||
|
||||
|
||||
/*
|
||||
* About type checking:
|
||||
* Types can be inherited - a Parent type ("Supertype") can have child types.
|
||||
* When accessing handles, type checking is done. This table shows how this is resolved:
|
||||
*
|
||||
* HANDLE CHECK -> RESULT
|
||||
* ------ ----- ------
|
||||
* Parent Parent Success
|
||||
* Parent Child Fail
|
||||
* Child Parent Success
|
||||
* Child Child Success
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Lists the possible handle error codes.
|
||||
*/
|
||||
enum HandleError
|
||||
{
|
||||
HandleError_None = 0, /**< No error */
|
||||
HandleError_Changed, /**< The handle has been freed and reassigned */
|
||||
HandleError_Type, /**< The handle has a different type registered */
|
||||
HandleError_Freed, /**< The handle has been freed */
|
||||
HandleError_Index, /**< generic internal indexing error */
|
||||
HandleError_Access, /**< No access permitted to free this handle */
|
||||
HandleError_Limit, /**< The limited number of handles has been reached */
|
||||
HandleError_Identity, /**< The identity token was not usable */
|
||||
HandleError_Owner, /**< Owners do not match for this operation */
|
||||
HandleError_Version, /**< Unrecognized security structure version */
|
||||
HandleError_Parameter, /**< An invalid parameter was passed */
|
||||
HandleError_NoInherit, /**< This type cannot be inherited */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Lists access rights specific to a type.
|
||||
*/
|
||||
enum HTypeAccessRight
|
||||
{
|
||||
HTypeAccess_Create = 0, /**< Handles of this type can be created (DEFAULT=false) */
|
||||
HTypeAccess_Inherit, /**< Sub-types can inherit this type (DEFAULT=false) */
|
||||
/* -------------- */
|
||||
HTypeAccess_TOTAL, /**< Total number of type access rights */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Lists access rights specific to a Handle.
|
||||
*
|
||||
* These rights are exclusive. For example, you do not need "read" access to delete or clone.
|
||||
*/
|
||||
enum HandleAccessRight
|
||||
{
|
||||
HandleAccess_Read, /**< Can be read (DEFAULT=ident only) */
|
||||
HandleAccess_Delete, /**< Can be deleted (DEFAULT=owner only) */
|
||||
HandleAccess_Clone, /**< Can be cloned (DEFAULT=any) */
|
||||
/* ------------- */
|
||||
HandleAccess_TOTAL, /**< Total number of access rights */
|
||||
};
|
||||
|
||||
/** Access is restricted to the identity */
|
||||
#define HANDLE_RESTRICT_IDENTITY (1<<0)
|
||||
/** Access is restricted to the owner */
|
||||
#define HANDLE_RESTRICT_OWNER (1<<1)
|
||||
|
||||
/**
|
||||
* @brief This is used to define per-type access rights.
|
||||
*/
|
||||
struct TypeAccess
|
||||
{
|
||||
/** Constructor */
|
||||
TypeAccess()
|
||||
{
|
||||
hsVersion = SMINTERFACE_HANDLESYSTEM_VERSION;
|
||||
}
|
||||
unsigned int hsVersion; /**< Handle API version */
|
||||
IdentityToken_t *ident; /**< Identity owning this type */
|
||||
bool access[HTypeAccess_TOTAL]; /**< Access array */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This is used to define per-Handle access rights.
|
||||
*/
|
||||
struct HandleAccess
|
||||
{
|
||||
/** Constructor */
|
||||
HandleAccess()
|
||||
{
|
||||
hsVersion = SMINTERFACE_HANDLESYSTEM_VERSION;
|
||||
}
|
||||
unsigned int hsVersion; /**< Handle API version */
|
||||
unsigned int access[HandleAccess_TOTAL]; /**< Access array */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This pair of tokens is used for identification.
|
||||
*/
|
||||
struct HandleSecurity
|
||||
{
|
||||
HandleSecurity()
|
||||
{
|
||||
}
|
||||
HandleSecurity(IdentityToken_t *owner, IdentityToken_t *identity)
|
||||
: pOwner(owner), pIdentity(identity)
|
||||
{
|
||||
}
|
||||
IdentityToken_t *pOwner; /**< Owner of the Handle */
|
||||
IdentityToken_t *pIdentity; /**< Owner of the Type */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Hooks type-specific Handle operations.
|
||||
*/
|
||||
class IHandleTypeDispatch
|
||||
{
|
||||
public:
|
||||
/** Returns the Handle API version */
|
||||
virtual unsigned int GetDispatchVersion()
|
||||
{
|
||||
return SMINTERFACE_HANDLESYSTEM_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Called when destroying a handle. Must be implemented.
|
||||
*
|
||||
* @param type Handle type.
|
||||
* @param object Handle internal object.
|
||||
*/
|
||||
virtual void OnHandleDestroy(HandleType_t type, void *object) =0;
|
||||
|
||||
/**
|
||||
* @brief Called to get the size of a handle's memory usage in bytes.
|
||||
* Implementation is optional.
|
||||
*
|
||||
* @param type Handle type.
|
||||
* @param object Handle internal object.
|
||||
* @param pSize Pointer to store the approximate memory usage in bytes.
|
||||
* @return True on success, false if not implemented.
|
||||
*/
|
||||
virtual bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Provides functions for managing Handles.
|
||||
*/
|
||||
class IHandleSys : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_HANDLESYSTEM_VERSION;
|
||||
}
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_HANDLESYSTEM_NAME;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a new Handle type.
|
||||
* NOTE: Currently, a child type may not have its own children.
|
||||
* NOTE: Handle names must be unique if not private.
|
||||
*
|
||||
* @param name Name of handle type (NULL or "" to be anonymous)
|
||||
* @param dispatch Pointer to a valid IHandleTypeDispatch object.
|
||||
* @param parent Parent handle to inherit from, 0 for none.
|
||||
* @param typeAccess Pointer to a TypeAccess object, NULL to use default
|
||||
* or inherited permissions. Pointer can be temporary.
|
||||
* @param hndlAccess Pointer to a HandleAccess object to define default
|
||||
* default permissions on each Handle. NULL to use default
|
||||
* permissions.
|
||||
* @param ident Security token for any permissions. If typeAccess is NULL, this
|
||||
* becomes the owning identity.
|
||||
* @param err Optional pointer to store an error code.
|
||||
* @return A new HandleType_t unique ID, or 0 on failure.
|
||||
*/
|
||||
virtual HandleType_t CreateType(const char *name,
|
||||
IHandleTypeDispatch *dispatch,
|
||||
HandleType_t parent,
|
||||
const TypeAccess *typeAccess,
|
||||
const HandleAccess *hndlAccess,
|
||||
IdentityToken_t *ident,
|
||||
HandleError *err) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes a handle type.
|
||||
* NOTE: This removes all child types.
|
||||
*
|
||||
* @param type Type chain to remove.
|
||||
* @param ident Identity token. Removal fails if the token does not match.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool RemoveType(HandleType_t type, IdentityToken_t *ident) =0;
|
||||
|
||||
/**
|
||||
* @brief Finds a handle type by name.
|
||||
*
|
||||
* @param name Name of handle type to find (anonymous not allowed).
|
||||
* @param type Address to store found handle in (if not found, undefined).
|
||||
* @return True if found, false otherwise.
|
||||
*/
|
||||
virtual bool FindHandleType(const char *name, HandleType_t *type) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a new handle.
|
||||
*
|
||||
* @param type Type to use on the handle.
|
||||
* @param object Object to bind to the handle.
|
||||
* @param owner Owner of the new Handle (may be NULL).
|
||||
* @param ident Identity for type access if needed (may be NULL).
|
||||
* @param err Optional pointer to store an error code.
|
||||
* @return A new Handle_t, or 0 on failure.
|
||||
*/
|
||||
virtual Handle_t CreateHandle(HandleType_t type,
|
||||
void *object,
|
||||
IdentityToken_t *owner,
|
||||
IdentityToken_t *ident,
|
||||
HandleError *err) =0;
|
||||
|
||||
/**
|
||||
* @brief Frees the memory associated with a handle and calls any destructors.
|
||||
* NOTE: This function will decrement the internal reference counter. It will
|
||||
* only perform any further action if the counter hits 0.
|
||||
*
|
||||
* @param handle Handle_t identifier to destroy.
|
||||
* @param pSecurity Security information struct (may be NULL).
|
||||
* @return A HandleError error code.
|
||||
*/
|
||||
virtual HandleError FreeHandle(Handle_t handle, const HandleSecurity *pSecurity) =0;
|
||||
|
||||
/**
|
||||
* @brief Clones a handle by adding to its internal reference count. Its data,
|
||||
* type, and security permissions remain the same.
|
||||
*
|
||||
* @param handle Handle to duplicate. Any non-free handle target is valid.
|
||||
* @param newhandle Stores the duplicated handle in the pointer (must not be NULL).
|
||||
* @param newOwner New owner of cloned handle.
|
||||
* @param pSecurity Security information struct (may be NULL).
|
||||
* @return A HandleError error code.
|
||||
*/
|
||||
virtual HandleError CloneHandle(Handle_t handle,
|
||||
Handle_t *newhandle,
|
||||
IdentityToken_t *newOwner,
|
||||
const HandleSecurity *pSecurity) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the contents of a handle.
|
||||
*
|
||||
* @param handle Handle_t from which to retrieve contents.
|
||||
* @param type Expected type to read as. 0 ignores typing rules.
|
||||
* @param pSecurity Security information struct (may be NULL).
|
||||
* @param object Optional address to store object in.
|
||||
* @return HandleError error code.
|
||||
*/
|
||||
virtual HandleError ReadHandle(Handle_t handle,
|
||||
HandleType_t type,
|
||||
const HandleSecurity *pSecurity,
|
||||
void **object) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets access permissions on one or more structures.
|
||||
*
|
||||
* @param pTypeAccess Optional TypeAccess buffer to initialize with the default values.
|
||||
* @param pHandleAccess Optional HandleAccess buffer to initialize with the default values.
|
||||
* @return True on success, false if version is unsupported.
|
||||
*/
|
||||
virtual bool InitAccessDefaults(TypeAccess *pTypeAccess, HandleAccess *pHandleAccess) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a new handle.
|
||||
*
|
||||
* @param type Type to use on the handle.
|
||||
* @param object Object to bind to the handle.
|
||||
* @param pSec Security pointer; pOwner is written as the owner,
|
||||
* pIdent is used as the parent identity for authorization.
|
||||
* @param pAccess Access right descriptor for the Handle; NULL for type defaults.
|
||||
* @param err Optional pointer to store an error code.
|
||||
* @return A new Handle_t, or 0 on failure.
|
||||
*/
|
||||
virtual Handle_t CreateHandleEx(HandleType_t type,
|
||||
void *object,
|
||||
const HandleSecurity *pSec,
|
||||
const HandleAccess *pAccess,
|
||||
HandleError *err) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_HANDLESYSTEM_INTERFACE_H_
|
||||
@@ -0,0 +1,229 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
|
||||
#define _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
|
||||
|
||||
/**
|
||||
* @file ILibrarySys.h
|
||||
* @brief Defines platform-dependent operations, such as opening libraries and files.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <time.h>
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
#define SMINTERFACE_LIBRARYSYS_NAME "ILibrarySys"
|
||||
#define SMINTERFACE_LIBRARYSYS_VERSION 4
|
||||
|
||||
enum FileTimeType
|
||||
{
|
||||
FileTime_LastAccess = 0, /* Last access (not available on FAT) */
|
||||
FileTime_Created = 1, /* Creation (not available on FAT) */
|
||||
FileTime_LastChange = 2, /* Last modification */
|
||||
};
|
||||
|
||||
class ILibrary
|
||||
{
|
||||
public:
|
||||
/** Virtual destructor (calls CloseLibrary) */
|
||||
virtual ~ILibrary()
|
||||
{
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief Closes dynamic library and invalidates pointer.
|
||||
*/
|
||||
virtual void CloseLibrary() =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves a symbol pointer from the dynamic library.
|
||||
*
|
||||
* @param symname Symbol name.
|
||||
* @return Symbol pointer, NULL if not found.
|
||||
*/
|
||||
virtual void *GetSymbolAddress(const char *symname) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Directory browsing abstraction.
|
||||
*/
|
||||
class IDirectory
|
||||
{
|
||||
public:
|
||||
/** Virtual destructor */
|
||||
virtual ~IDirectory()
|
||||
{
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Returns true if there are more files to read, false otherwise.
|
||||
*/
|
||||
virtual bool MoreFiles() =0;
|
||||
|
||||
/**
|
||||
* @brief Advances to the next entry in the stream.
|
||||
*/
|
||||
virtual void NextEntry() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the name of the current entry.
|
||||
*/
|
||||
virtual const char *GetEntryName() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the current entry is a directory.
|
||||
*/
|
||||
virtual bool IsEntryDirectory() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the current entry is a file.
|
||||
*/
|
||||
virtual bool IsEntryFile() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns true if the current entry is valid
|
||||
* (Used similarly to MoreFiles).
|
||||
*/
|
||||
virtual bool IsEntryValid() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Contains various operating system specific code.
|
||||
*/
|
||||
class ILibrarySys : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_LIBRARYSYS_NAME;
|
||||
}
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_LIBRARYSYS_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Opens a dynamic library file.
|
||||
*
|
||||
* @param path Path to library file (.dll/.so).
|
||||
* @param error Buffer for any error message (may be NULL).
|
||||
* @param maxlength Maximum length of error buffer.
|
||||
* @return Pointer to an ILibrary, NULL if failed.
|
||||
*/
|
||||
virtual ILibrary *OpenLibrary(const char *path, char *error, size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Opens a directory for reading.
|
||||
*
|
||||
* @param path Path to directory.
|
||||
* @return Pointer to an IDirectory, NULL if failed.
|
||||
*/
|
||||
virtual IDirectory *OpenDirectory(const char *path) =0;
|
||||
|
||||
/**
|
||||
* @brief Closes a directory and frees its handle.
|
||||
*
|
||||
* @param dir Pointer to IDirectory.
|
||||
*/
|
||||
virtual void CloseDirectory(IDirectory *dir) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns true if a path exists.
|
||||
*/
|
||||
virtual bool PathExists(const char *path) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns true if the path is a normal file.
|
||||
*/
|
||||
virtual bool IsPathFile(const char *path) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns true if the path is a normal directory.
|
||||
*/
|
||||
virtual bool IsPathDirectory(const char *path) =0;
|
||||
|
||||
/**
|
||||
* @brief Gets a platform-specific error message.
|
||||
* This should only be called when an ILibrary function fails.
|
||||
* Win32 equivalent: GetLastError() + FormatMessage()
|
||||
* POSIX equivalent: errno + strerror()
|
||||
*
|
||||
* @param error Error message buffer.
|
||||
* @param maxlength Maximum length of error buffer.
|
||||
*/
|
||||
virtual void GetPlatformError(char *error, size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Formats a string similar to snprintf(), except
|
||||
* corrects all non-platform compatible path separators to be
|
||||
* the correct platform character.
|
||||
*
|
||||
* @param buffer Output buffer pointer.
|
||||
* @param maxlength Output buffer size.
|
||||
* @param pathfmt Format string of path.
|
||||
* @param ... Format string arguments.
|
||||
*/
|
||||
virtual size_t PathFormat(char *buffer, size_t maxlength, const char *pathfmt, ...) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to the extension in a filename.
|
||||
*
|
||||
* @param filename Name of file from which the extension should be extracted.
|
||||
* @return Pointer to file extension.
|
||||
*/
|
||||
virtual const char *GetFileExtension(const char *filename) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a directory.
|
||||
*
|
||||
* @param path Full, absolute path of the directory to create.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool CreateFolder(const char *path) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the requested timestamp of a file.
|
||||
*
|
||||
* NOTE: On FAT file systems, the access and creation times
|
||||
* may not be valid.
|
||||
*
|
||||
* @param path Path to file.
|
||||
* @param type FileTimeType of time value to request.
|
||||
* @param pTime Pointer to store time.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool FileTime(const char *path, FileTimeType type, time_t *pTime) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_INTERFACE_BINARYUTILS_H_
|
||||
#define _INCLUDE_SOURCEMOD_INTERFACE_BINARYUTILS_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
|
||||
#define SMINTERFACE_MEMORYUTILS_NAME "IMemoryUtils"
|
||||
#define SMINTERFACE_MEMORYUTILS_VERSION 1
|
||||
|
||||
/**
|
||||
* @file IMemoryUtils.h
|
||||
* @brief Interface for finding patterns in memory.
|
||||
*/
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class IMemoryUtils : public SMInterface
|
||||
{
|
||||
public:
|
||||
const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_MEMORYUTILS_NAME;
|
||||
}
|
||||
unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_MEMORYUTILS_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Searches for a pattern of bytes within the memory of a dynamic library.
|
||||
*
|
||||
* @param libPtr Pointer to any chunk of memory that resides in the dynamic library.
|
||||
* @param pattern Pattern of bytes to search for. 0x2A can be used as a wildcard.
|
||||
* @param len Size of the pattern in bytes.
|
||||
* @return Pointer to pattern found in memory, NULL if not found.
|
||||
*/
|
||||
virtual void *FindPattern(const void *libPtr, const char *pattern, size_t len) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_INTERFACE_MEMORYUTILS_H_
|
||||
@@ -0,0 +1,920 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_MENU_SYSTEM_H_
|
||||
#define _INCLUDE_SOURCEMOD_MENU_SYSTEM_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IHandleSys.h>
|
||||
|
||||
#define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
|
||||
#define SMINTERFACE_MENUMANAGER_VERSION 15
|
||||
|
||||
/**
|
||||
* @file IMenuManager.h
|
||||
* @brief Abstracts on-screen menus for clients.
|
||||
*/
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Used to determine how an item selection is interpreted.
|
||||
*/
|
||||
enum ItemSelection
|
||||
{
|
||||
ItemSel_None, /**< Invalid selection */
|
||||
ItemSel_Back, /**< Go back one page (really "Previous") */
|
||||
ItemSel_Next, /**< Go forward one page */
|
||||
ItemSel_Exit, /**< Menu was exited */
|
||||
ItemSel_Item, /**< Valid item selection */
|
||||
ItemSel_ExitBack, /**< Sends MenuEnd_ExitBack */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Used to determine which order to search for items in.
|
||||
*/
|
||||
enum ItemOrder
|
||||
{
|
||||
ItemOrder_Ascending, /**< Items should be drawn ascendingly */
|
||||
ItemOrder_Descending, /**< Items should be drawn descendingly */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Pairs an item type with an item menu position.
|
||||
*/
|
||||
struct menu_slots_t
|
||||
{
|
||||
ItemSelection type; /**< Item selection type */
|
||||
unsigned int item; /**< Item position, if applicable */
|
||||
};
|
||||
|
||||
class IBaseMenu;
|
||||
class IMenuPanel;
|
||||
class IMenuHandler;
|
||||
|
||||
/**
|
||||
* @brief Describes menu display information.
|
||||
*/
|
||||
struct menu_states_t
|
||||
{
|
||||
unsigned int apiVers; /**< Must be filled with the API version */
|
||||
IBaseMenu *menu; /**< Menu pointer, or NULL if there is only a display */
|
||||
IMenuHandler *mh; /**< Menu callbacks handler */
|
||||
unsigned int firstItem; /**< MENU ONLY: First item displayed on the last page */
|
||||
unsigned int lastItem; /**< MENU ONLY: Last item displayed on the last page */
|
||||
unsigned int item_on_page; /**< MENU ONLY: First item on page */
|
||||
menu_slots_t slots[11]; /**< MENU ONLY: Item selection table (first index is 1) */
|
||||
};
|
||||
|
||||
#define ITEMDRAW_DEFAULT (0) /**< Item should be drawn normally */
|
||||
#define ITEMDRAW_DISABLED (1<<0) /**< Item is drawn but not selectable */
|
||||
#define ITEMDRAW_RAWLINE (1<<1) /**< Item should be a raw line, without a slot */
|
||||
#define ITEMDRAW_NOTEXT (1<<2) /**< No text should be drawn */
|
||||
#define ITEMDRAW_SPACER (1<<3) /**< Item should be drawn as a spacer, if possible */
|
||||
#define ITEMDRAW_IGNORE ((1<<1)|(1<<2)) /**< Item should be completely ignored (rawline + notext) */
|
||||
#define ITEMDRAW_CONTROL (1<<4) /**< Item is control text (back/next/exit) */
|
||||
|
||||
/**
|
||||
* @brief Information about item drawing.
|
||||
*/
|
||||
struct ItemDrawInfo
|
||||
{
|
||||
ItemDrawInfo(const char *DISPLAY=NULL, unsigned int STYLE=ITEMDRAW_DEFAULT,
|
||||
unsigned int FLAGS=0, const char *HELPTEXT=NULL)
|
||||
: display(DISPLAY), style(STYLE)
|
||||
{
|
||||
}
|
||||
const char *display; /**< Display text (NULL for none) */
|
||||
unsigned int style; /**< ITEMDRAW style flags */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Contains information about a vote result.
|
||||
*/
|
||||
struct menu_vote_result_t
|
||||
{
|
||||
unsigned int num_clients; /**< Number of clients the menu was displayed to */
|
||||
unsigned int num_votes; /**< Number of votes received */
|
||||
struct menu_client_vote_t
|
||||
{
|
||||
int client; /**< Client index */
|
||||
int item; /**< Item # (or -1 for none) */
|
||||
} *client_list; /**< Array of size num_clients */
|
||||
unsigned int num_items; /**< Number of items voted for */
|
||||
struct menu_item_vote_t
|
||||
{
|
||||
unsigned int item; /**< Item index */
|
||||
unsigned int count; /**< Number of votes */
|
||||
} *item_list; /**< Array of size num_items, sorted by count,
|
||||
descending */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Reasons for a menu dying.
|
||||
*/
|
||||
enum MenuCancelReason
|
||||
{
|
||||
MenuCancel_Disconnected = -1, /**< Client dropped from the server */
|
||||
MenuCancel_Interrupted = -2, /**< Client was interrupted with another menu */
|
||||
MenuCancel_Exit = -3, /**< Client selected "exit" on a paginated menu */
|
||||
MenuCancel_NoDisplay = -4, /**< Menu could not be displayed to the client */
|
||||
MenuCancel_Timeout = -5, /**< Menu timed out */
|
||||
MenuCancel_ExitBack = -6, /**< Client selected "exit back" on a paginated menu */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Reasons a menu ended.
|
||||
*/
|
||||
enum MenuEndReason
|
||||
{
|
||||
MenuEnd_Selected = 0, /**< Menu item was selected */
|
||||
MenuEnd_VotingDone = -1, /**< Voting finished */
|
||||
MenuEnd_VotingCancelled = -2, /**< Voting was cancelled */
|
||||
MenuEnd_Cancelled = -3, /**< Menu was uncleanly cancelled */
|
||||
MenuEnd_Exit = -4, /**< Menu was cleanly exited via "exit" */
|
||||
MenuEnd_ExitBack = -5, /**< Menu was cleanly exited via "back" */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Reasons a vote can be cancelled.
|
||||
*/
|
||||
enum VoteCancelReason
|
||||
{
|
||||
VoteCancel_Generic = -1, /**< Vote was generically cancelled. */
|
||||
VoteCancel_NoVotes = -2, /**< Vote did not receive any votes. */
|
||||
};
|
||||
|
||||
#define MENU_NO_PAGINATION 0 /**< Menu should not be paginated (10 items max) */
|
||||
#define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */
|
||||
|
||||
#define MENUFLAG_BUTTON_EXIT (1<<0) /**< Menu has an "exit" button */
|
||||
#define MENUFLAG_BUTTON_EXITBACK (1<<1) /**< Menu has an "exit back" button */
|
||||
#define MENUFLAG_NO_SOUND (1<<2) /**< Menu will not have any select sounds */
|
||||
|
||||
/**
|
||||
* @brief Extended menu options.
|
||||
*/
|
||||
enum MenuOption
|
||||
{
|
||||
MenuOption_IntroMessage, /**< CONST CHAR *: Valve menus only; defaults to:
|
||||
"You have a menu, hit ESC"
|
||||
*/
|
||||
MenuOption_IntroColor, /**< INT[4]: Valve menus only; specifies the intro message colour
|
||||
using R,G,B,A (defaults to 255,0,0,255)
|
||||
*/
|
||||
MenuOption_Priority, /**< INT *: Valve menus only; priority (less is higher) */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes the menu a player is viewing.
|
||||
*/
|
||||
enum MenuSource
|
||||
{
|
||||
MenuSource_None = 0, /**< No menu is being displayed */
|
||||
MenuSource_External = 1, /**< External menu, no pointer */
|
||||
MenuSource_BaseMenu = 2, /**< An IBaseMenu pointer. */
|
||||
MenuSource_Display = 3, /**< IMenuPanel source, no pointer */
|
||||
};
|
||||
|
||||
class IMenuStyle;
|
||||
|
||||
/**
|
||||
* @brief Sets how a raw menu should be drawn.
|
||||
*/
|
||||
class IMenuPanel
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the parent IMenuStyle pointer.
|
||||
*
|
||||
* @return IMenuStyle pointer which created
|
||||
* this object.
|
||||
*/
|
||||
virtual IMenuStyle *GetParentStyle() =0;
|
||||
|
||||
/**
|
||||
* @brief Resets/clears the cached display text.
|
||||
*/
|
||||
virtual void Reset() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets how the title should be drawn.
|
||||
*
|
||||
* @param text Text string to display for the title.
|
||||
* @param onlyIfEmpty Only sets the title if one does not already
|
||||
* exist.
|
||||
*/
|
||||
virtual void DrawTitle(const char *text, bool onlyIfEmpty=false) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds an item to the menu and returns the position (1-10).
|
||||
*
|
||||
* Note: Item will fail to draw if there are too many items,
|
||||
* or the item is not drawable (for example, invisible).
|
||||
*
|
||||
* @return Item draw position, or 0 on failure.
|
||||
*/
|
||||
virtual unsigned int DrawItem(const ItemDrawInfo &item) =0;
|
||||
|
||||
/**
|
||||
* @brief Draws a raw line of text, if supported. The line does not
|
||||
* need to be newline terminated.
|
||||
*
|
||||
* @return True on success, false if not supported.
|
||||
*/
|
||||
virtual bool DrawRawLine(const char *rawline) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets an extended menu option.
|
||||
*
|
||||
* @param option Option type.
|
||||
* @param valuePtr Pointer of the type expected by the option.
|
||||
* @return True on success, false if option or value is not supported.
|
||||
*/
|
||||
virtual bool SetExtOption(MenuOption option, const void *valuePtr) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the display is capable of rendering an item
|
||||
* with the given flags.
|
||||
*
|
||||
* @param drawFlags ITEMDRAW flags.
|
||||
* @return True if renderable, false otherwise.
|
||||
*/
|
||||
virtual bool CanDrawItem(unsigned int drawFlags) =0;
|
||||
|
||||
/**
|
||||
* @brief Sends the menu display to a client.
|
||||
*
|
||||
* @param client Client index to display to.
|
||||
* @param handler Menu handler to use.
|
||||
* @param time Time to hold menu for.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool SendDisplay(int client, IMenuHandler *handler, unsigned int time) =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys the display object.
|
||||
*/
|
||||
virtual void DeleteThis() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the selectable key map. Returns false if the function
|
||||
* is not supported.
|
||||
*
|
||||
* @param keymap A bit string where each bit N-1 specifies
|
||||
* that key N is selectable (key 0 is bit 9).
|
||||
* If the selectable key map is 0, it will be
|
||||
* automatically set to allow 0.
|
||||
* @return True on success, false if not supported.
|
||||
*/
|
||||
virtual bool SetSelectableKeys(unsigned int keymap) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the current key position.
|
||||
*
|
||||
* @return Current key position starting at 1.
|
||||
*/
|
||||
virtual unsigned int GetCurrentKey() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the next key position. This cannot be used
|
||||
* to traverse backwards.
|
||||
*
|
||||
* @param key Key that is greater or equal to
|
||||
* GetCurrentKey().
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool SetCurrentKey(unsigned int key) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of characters that can be added to the
|
||||
* menu. The internal buffer is truncated if overflowed; this is for
|
||||
* manual truncation/wrapping purposes.
|
||||
*
|
||||
* @return Number of bytes available. If the result is
|
||||
* -1, then the panel has no text limit.
|
||||
*/
|
||||
virtual int GetAmountRemaining() =0;
|
||||
|
||||
/**
|
||||
* @brief For the Handle system, returns approximate memory usage.
|
||||
*
|
||||
* @return Approximate number of bytes being used.
|
||||
*/
|
||||
virtual unsigned int GetApproxMemUsage() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes a "MenuStyle" system which manages
|
||||
* menu drawing and construction.
|
||||
*/
|
||||
class IMenuStyle
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the style API version.
|
||||
*
|
||||
* @return API version.
|
||||
*/
|
||||
virtual unsigned int GetStyleAPIVersion()
|
||||
{
|
||||
return SMINTERFACE_MENUMANAGER_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the name of the menu style.
|
||||
*
|
||||
* @return String containing the style name.
|
||||
*/
|
||||
virtual const char *GetStyleName() =0;
|
||||
|
||||
/**
|
||||
* @brief Creates an IMenuPanel object.
|
||||
*
|
||||
* Note: the object should be freed using ::DeleteThis.
|
||||
*
|
||||
* @return IMenuPanel object.
|
||||
*/
|
||||
virtual IMenuPanel *CreatePanel() =0;
|
||||
|
||||
/**
|
||||
* @brief Creates an IBaseMenu object of this style.
|
||||
*
|
||||
* Note: the object should be freed using IBaseMenu::Destroy.
|
||||
*
|
||||
* @param handler IMenuHandler pointer.
|
||||
* @param pOwner Optional IdentityToken_t owner for handle
|
||||
* creation.
|
||||
* @return An IBaseMenu pointer.
|
||||
*/
|
||||
virtual IBaseMenu *CreateMenu(IMenuHandler *handler, IdentityToken_t *pOwner=NULL) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the maximum number of items per page.
|
||||
*
|
||||
* Menu implementations must return >= 2. Styles with only 1 or 0
|
||||
* items per page are not valid.
|
||||
*
|
||||
* @return Number of items per page.
|
||||
*/
|
||||
virtual unsigned int GetMaxPageItems() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether or not a client is viewing a menu.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param object Optional pointer to retrieve menu object,
|
||||
* if any.
|
||||
* @return MenuSource value.
|
||||
*/
|
||||
virtual MenuSource GetClientMenu(int client, void **object) =0;
|
||||
|
||||
/**
|
||||
* @brief Cancels a client's menu.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param autoIgnore If true, no menus can be created during
|
||||
* the cancellation process.
|
||||
* @return True if a menu was cancelled, false otherwise.
|
||||
*/
|
||||
virtual bool CancelClientMenu(int client, bool autoIgnore=false) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a Handle the IMenuStyle object.
|
||||
*
|
||||
* @return Handle_t pointing to this object.
|
||||
*/
|
||||
virtual Handle_t GetHandle() =0;
|
||||
|
||||
/**
|
||||
* @brief For the Handle system, returns approximate memory usage.
|
||||
*
|
||||
* @return Approximate number of bytes being used.
|
||||
*/
|
||||
virtual unsigned int GetApproxMemUsage() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief High-level interface for building menus.
|
||||
*/
|
||||
class IBaseMenu
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Appends an item to the end of a menu.
|
||||
*
|
||||
* @param info Item information string.
|
||||
* @param draw Default drawing information.
|
||||
* @return True on success, false on item limit reached.
|
||||
*/
|
||||
virtual bool AppendItem(const char *info, const ItemDrawInfo &draw) =0;
|
||||
|
||||
/**
|
||||
* @brief Inserts an item into the menu before a certain position;
|
||||
* the new item will be at the given position and all next items
|
||||
* pushed forward.
|
||||
*
|
||||
* @param position Position, starting from 0.
|
||||
* @param info Item information string.
|
||||
* @param draw Default item draw info.
|
||||
* @return True on success, false on invalid menu position
|
||||
*/
|
||||
virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes an item from the menu.
|
||||
*
|
||||
* @param position Position, starting from 0.
|
||||
* @return True on success, false on invalid menu position.
|
||||
*/
|
||||
virtual bool RemoveItem(unsigned int position) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes all items from the menu.
|
||||
*/
|
||||
virtual void RemoveAllItems() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns an item's info.
|
||||
*
|
||||
* @param position Position, starting from 0.
|
||||
* @param draw Optional pointer to store a draw information.
|
||||
* @return Info string pointer, or NULL if position was invalid.
|
||||
*/
|
||||
virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of items.
|
||||
*
|
||||
* @return Number of items in the menu.
|
||||
*/
|
||||
virtual unsigned int GetItemCount() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the menu's pagination,.
|
||||
*
|
||||
* If pagination is set to MENU_NO_PAGINATION, and the previous
|
||||
* pagination was not MENU_NO_PAGINATION, then the MENUFLAG_BUTTON_EXIT
|
||||
* is unset. It can be re-applied if desired.
|
||||
*
|
||||
* @param itemsPerPage Number of items per page, or MENU_NO_PAGINATION.
|
||||
* @return True on success, false if itemsPerPage is too
|
||||
* large.
|
||||
*/
|
||||
virtual bool SetPagination(unsigned int itemsPerPage) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns an item's pagination.
|
||||
*
|
||||
* @return Pagination setting.
|
||||
*/
|
||||
virtual unsigned int GetPagination() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the menu style.
|
||||
*
|
||||
* @return Menu style.
|
||||
*/
|
||||
virtual IMenuStyle *GetDrawStyle() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the menu's display title/message.
|
||||
*
|
||||
* @param message Message (format options allowed).
|
||||
*/
|
||||
virtual void SetDefaultTitle(const char *message) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the menu's display/title message.
|
||||
*
|
||||
* @return Message string.
|
||||
*/
|
||||
virtual const char *GetDefaultTitle() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets an extended menu option.
|
||||
*
|
||||
* @param option Option type.
|
||||
* @param valuePtr Pointer of the type expected by the option.
|
||||
* @return True on success, false if option or value is not supported.
|
||||
*/
|
||||
virtual bool SetExtOption(MenuOption option, const void *valuePtr) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a new IMenuPanel object using extended options specific
|
||||
* to the IMenuStyle parent. Titles, items, etc, are not copied.
|
||||
*
|
||||
* Note: The object should be freed with IMenuPanel::DeleteThis.
|
||||
*
|
||||
* @return IMenuPanel pointer.
|
||||
*/
|
||||
virtual IMenuPanel *CreatePanel() =0;
|
||||
|
||||
/**
|
||||
* @brief Sends the menu to a client.
|
||||
*
|
||||
* @param client Client index to display to.
|
||||
* @param time Time to hold menu for.
|
||||
* @param alt_handler Alternate IMenuHandler.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL) =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys the menu and frees all associated resources.
|
||||
*
|
||||
* @param releaseHandle If true, the Handle will be released
|
||||
* in the destructor. This should be set
|
||||
* to true except for IHandleTypeDispatch
|
||||
* destructors.
|
||||
*/
|
||||
virtual void Destroy(bool releaseHandle=true) =0;
|
||||
|
||||
/**
|
||||
* @brief Cancels the menu on all client's displays. While the menu is
|
||||
* being cancelled, the menu may not be re-displayed to any clients.
|
||||
* If a vote menu is currently active, it will be cancelled as well.
|
||||
*
|
||||
* @return Number of menus cancelled.
|
||||
*/
|
||||
virtual void Cancel() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the menu's Handle. The Handle is automatically
|
||||
* removed when the menu is destroyed.
|
||||
*
|
||||
* @return Handle_t handle value.
|
||||
*/
|
||||
virtual Handle_t GetHandle() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns menu option flags.
|
||||
*
|
||||
* @return Menu option flags.
|
||||
*/
|
||||
virtual unsigned int GetMenuOptionFlags() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets menu option flags.
|
||||
*
|
||||
* @param flags Menu option flags.
|
||||
*/
|
||||
virtual void SetMenuOptionFlags(unsigned int flags) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the menu's handler.
|
||||
*
|
||||
* @return IMenuHandler of the menu.
|
||||
*/
|
||||
virtual IMenuHandler *GetHandler() =0;
|
||||
|
||||
/**
|
||||
* @brief Sends the menu to a client, starting from the given item number.
|
||||
*
|
||||
* Note: this API call was added in v13.
|
||||
*
|
||||
* @param client Client index to display to.
|
||||
* @param time Time to hold menu for.
|
||||
* @param start_item Starting item to draw.
|
||||
* @param alt_handler Alternate IMenuHandler.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool DisplayAtItem(int client,
|
||||
unsigned int time,
|
||||
unsigned int start_item,
|
||||
IMenuHandler *alt_handler=NULL) =0;
|
||||
|
||||
/**
|
||||
* @brief For the Handle system, returns approximate memory usage.
|
||||
*
|
||||
* @return Approximate number of bytes being used.
|
||||
*/
|
||||
virtual unsigned int GetApproxMemUsage() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Contains callbacks for menu actions.
|
||||
*/
|
||||
class IMenuHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the menu api verison.
|
||||
*
|
||||
* @return Menu API version.
|
||||
*/
|
||||
virtual unsigned int GetMenuAPIVersion2()
|
||||
{
|
||||
return SMINTERFACE_MENUMANAGER_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A display/selection cycle has started.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
*/
|
||||
virtual void OnMenuStart(IBaseMenu *menu)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called before a menu is being displayed. This is where
|
||||
* you can set an alternate title on the menu.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
* @param client Client index.
|
||||
* @param display IMenuPanel pointer.
|
||||
*/
|
||||
virtual void OnMenuDisplay(IBaseMenu *menu, int client, IMenuPanel *display)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when an item is selected.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
* @param client Client that selected the item.
|
||||
* @param item Item number.
|
||||
*/
|
||||
virtual void OnMenuSelect(IBaseMenu *menu, int client, unsigned int item)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief An active menu display was dropped from a client.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
* @param client Client that had the menu.
|
||||
* @param reason Menu cancellation reason.
|
||||
*/
|
||||
virtual void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A display/selection cycle has ended.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
* @param reason MenuEndReason reason.
|
||||
*/
|
||||
virtual void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when the menu object is destroyed.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
*/
|
||||
virtual void OnMenuDestroy(IBaseMenu *menu)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when requesting how to render an item.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
* @param client Client index receiving the menu.
|
||||
* @param item Item number in the menu.
|
||||
* @param style ITEMSTYLE flags, by reference for modification.
|
||||
*/
|
||||
virtual void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when drawing item text.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
* @param client Client index receiving the menu.
|
||||
* @param panel Panel being used to draw the menu.
|
||||
* @param item Item number in the menu.
|
||||
* @param dr Item draw information.
|
||||
* @return 0 to let the render algorithm decide how to draw, otherwise,
|
||||
* the return value from panel->DrawItem should be returned.
|
||||
*/
|
||||
virtual unsigned int OnMenuDisplayItem(IBaseMenu *menu,
|
||||
int client,
|
||||
IMenuPanel *panel,
|
||||
unsigned int item,
|
||||
const ItemDrawInfo &dr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a vote has been started and displayed to
|
||||
* clients. This is called after OnMenuStart() and OnMenuDisplay(),
|
||||
* but before OnMenuSelect().
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
*/
|
||||
virtual void OnMenuVoteStart(IBaseMenu *menu)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a vote ends. This is automatically called by the
|
||||
* wrapper, and never needs to called from a style implementation.
|
||||
*
|
||||
* This function does not replace OnMenuEnd(), nor does it have the
|
||||
* same meaning as OnMenuEnd(), meaning you should not destroy a menu
|
||||
* while it is in this function.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
* @param results Menu vote results.
|
||||
*/
|
||||
virtual void OnMenuVoteResults(IBaseMenu *menu, const menu_vote_result_t *results)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a vote is cancelled. If this is called, then
|
||||
* OnMenuVoteResults() will not be called. In both cases, OnMenuEnd will
|
||||
* always be called.
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
* @param reason VoteCancelReason reason.
|
||||
*/
|
||||
virtual void OnMenuVoteCancel(IBaseMenu *menu, VoteCancelReason reason)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Call to set private handler stuff.
|
||||
*
|
||||
* @param option Option name.
|
||||
* @param data Private data.
|
||||
* @return True if set, false if invalid or unrecognized.
|
||||
*/
|
||||
virtual bool OnSetHandlerOption(const char *option, const void *data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when an item is selected.
|
||||
*
|
||||
* Note: This callback was added in v13. It is called after OnMenuSelect().
|
||||
*
|
||||
* @param menu Menu pointer.
|
||||
* @param client Client that selected the item.
|
||||
* @param item Item number.
|
||||
* @param item_on_page The first item on the page the player was last
|
||||
* viewing.
|
||||
*/
|
||||
virtual void OnMenuSelect2(IBaseMenu *menu,
|
||||
int client,
|
||||
unsigned int item,
|
||||
unsigned int item_on_page)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Manages menu creation and displaying.
|
||||
*/
|
||||
class IMenuManager : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_MENUMANAGER_NAME;
|
||||
}
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_MENUMANAGER_VERSION;
|
||||
}
|
||||
virtual bool IsVersionCompatible(unsigned int version)
|
||||
{
|
||||
if (version < 11 || version > GetInterfaceVersion())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Finds a style by name.
|
||||
*
|
||||
* @param name Name of the style (case insensitive).
|
||||
* @return IMenuStyle pointer, or NULL if not found.
|
||||
*/
|
||||
virtual IMenuStyle *FindStyleByName(const char *name) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the default draw style Core is using.
|
||||
*
|
||||
* @return Menu style pointer.
|
||||
*/
|
||||
virtual IMenuStyle *GetDefaultStyle() =0;
|
||||
|
||||
/**
|
||||
* @brief Given a set of menu states, converts it to an IMenuPanel object.
|
||||
*
|
||||
* The state parameter is both INPUT and OUTPUT.
|
||||
* INPUT: menu, mh, firstItem, lastItem
|
||||
* OUTPUT: display, firstItem, lastItem, slots
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param states Menu states.
|
||||
* @param order Order to search for items.
|
||||
* @return IMenuPanel pointer, or NULL if no items could be
|
||||
* found in the IBaseMenu pointer, or NULL if any
|
||||
* other error occurred. Any valid pointer must
|
||||
* be freed using IMenuPanel::DeleteThis.
|
||||
*/
|
||||
virtual IMenuPanel *RenderMenu(int client, menu_states_t &states, ItemOrder order) =0;
|
||||
|
||||
/**
|
||||
* @brief Cancels a menu. Calls IBaseMenu::Cancel() after doing some preparatory
|
||||
* work. This should always be used instead of directly calling Cancel().
|
||||
*
|
||||
* @param menu IBaseMenu pointer.
|
||||
*/
|
||||
virtual void CancelMenu(IBaseMenu *menu) =0;
|
||||
|
||||
/**
|
||||
* @brief Displays a menu as a vote.
|
||||
*
|
||||
* @param menu IBaseMenu pointer.
|
||||
* @param num_clients Number of clients to display to.
|
||||
* @param clients Client index array.
|
||||
* @param max_time Maximum time to hold menu for.
|
||||
* @param flags Vote flags (currently unused).
|
||||
* @return True on success, false if a vote is in progress.
|
||||
*/
|
||||
virtual bool StartVote(IBaseMenu *menu,
|
||||
unsigned int num_clients,
|
||||
int clients[],
|
||||
unsigned int max_time,
|
||||
unsigned int flags=0) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether or not a vote is in progress.
|
||||
*
|
||||
* @return True if a vote is in progress, false otherwise.
|
||||
*/
|
||||
virtual bool IsVoteInProgress() =0;
|
||||
|
||||
/**
|
||||
* @brief Cancels the vote in progress. This calls IBaseMenu::Cancel().
|
||||
*/
|
||||
virtual void CancelVoting() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the remaining vote delay from the last menu. This delay is
|
||||
* a suggestion for all public votes, and is not enforced.
|
||||
*
|
||||
* @return Number of seconds to wait.
|
||||
*/
|
||||
virtual unsigned int GetRemainingVoteDelay() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether a client is in the "allowed to vote" pool determined
|
||||
* by the initial call to StartVote().
|
||||
*
|
||||
* @param client Client index.
|
||||
* @return True if client is allowed to vote, false on failure.
|
||||
*/
|
||||
virtual bool IsClientInVotePool(int client) =0;
|
||||
|
||||
/**
|
||||
* @brief Redraws the current vote menu to a client in the voting pool.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @return True on success, false if client is not allowed to vote.
|
||||
*/
|
||||
virtual bool RedrawClientVoteMenu(int client) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_MENU_SYSTEM_H_
|
||||
@@ -0,0 +1,478 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_INTERFACE_IPLAYERHELPERS_H_
|
||||
#define _INCLUDE_SOURCEMOD_INTERFACE_IPLAYERHELPERS_H_
|
||||
|
||||
/**
|
||||
* @file IPlayerHelpers.h
|
||||
* @brief Defines basic helper functions for Half-Life 2 clients
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IAdminSystem.h>
|
||||
|
||||
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
|
||||
#define SMINTERFACE_PLAYERMANAGER_VERSION 7
|
||||
|
||||
struct edict_t;
|
||||
class IPlayerInfo;
|
||||
|
||||
#define SM_REPLY_CONSOLE 0 /**< Reply to console. */
|
||||
#define SM_REPLY_CHAT 1 /**< Reply to chat. */
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Abstracts some Half-Life 2 and SourceMod properties about clients.
|
||||
*/
|
||||
class IGamePlayer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the player's name.
|
||||
*
|
||||
* @return String containing the player's name,
|
||||
* or NULL if unavailable.
|
||||
*/
|
||||
virtual const char *GetName() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the player's IP address.
|
||||
*
|
||||
* @return String containing the player's IP address,
|
||||
* or NULL if unavailable.
|
||||
*/
|
||||
virtual const char *GetIPAddress() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the player's authentication string.
|
||||
*
|
||||
* @return String containing the player's auth string.
|
||||
* May be NULL if unavailable.
|
||||
*/
|
||||
virtual const char *GetAuthString() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the player's edict_t structure.
|
||||
*
|
||||
* @return edict_t pointer, or NULL if unavailable.
|
||||
*/
|
||||
virtual edict_t *GetEdict() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the player is in game (putinserver).
|
||||
*
|
||||
* @return True if in game, false otherwise.
|
||||
*/
|
||||
virtual bool IsInGame() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the player is connected.
|
||||
*
|
||||
* Note: If this returns true, all above functions except for
|
||||
* GetAuthString() should return non-NULL results.
|
||||
*
|
||||
* @return True if connected, false otherwise.
|
||||
*/
|
||||
virtual bool IsConnected() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the player is a fake client.
|
||||
*
|
||||
* @return True if a fake client, false otherwise.
|
||||
*/
|
||||
virtual bool IsFakeClient() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the client's AdminId, if any.
|
||||
*
|
||||
* @return AdminId, or INVALID_ADMIN_ID if none.
|
||||
*/
|
||||
virtual AdminId GetAdminId() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the client's AdminId.
|
||||
*
|
||||
* @param id AdminId to set.
|
||||
* @param temp If true, the id will be invalidated on disconnect.
|
||||
*/
|
||||
virtual void SetAdminId(AdminId id, bool temp) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the client's userid.
|
||||
*
|
||||
* @return Userid.
|
||||
*/
|
||||
virtual int GetUserId() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the client's language id.
|
||||
*
|
||||
* @return Language id.
|
||||
*/
|
||||
virtual unsigned int GetLanguageId() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a player's IPlayerInfo object, if any.
|
||||
*
|
||||
* @return IPlayerInfo pointer, or NULL if none.
|
||||
*/
|
||||
virtual IPlayerInfo *GetPlayerInfo() =0;
|
||||
|
||||
/**
|
||||
* @brief Runs through Core's admin authorization checks. If the
|
||||
* client is already an admin, no checks are performed.
|
||||
*
|
||||
* Note that this function operates solely against the in-memory admin
|
||||
* cache. It will check steamids, IPs, names, and verify a password
|
||||
* if one exists. To implement other authentication schemes, simply
|
||||
* don't call this function and use IGamePlayer::SetAdminId() instead.
|
||||
*
|
||||
* @return True if access changed, false otherwise.
|
||||
*/
|
||||
virtual bool RunAdminCacheChecks() =0;
|
||||
|
||||
/**
|
||||
* @brief Notifies all listeners that the client has completed
|
||||
* all of your post-connection (in-game, auth, admin) checks.
|
||||
*
|
||||
* If you returned "false" from OnClientPreAdminCheck(), you must
|
||||
* ALWAYS manually invoke this function, even if RunAdminCacheChecks()
|
||||
* failed or you did not assign an AdminId. Failure to call this
|
||||
* function could result in plugins (such as reservedslots) not
|
||||
* working properly.
|
||||
*
|
||||
* If you are implementing asynchronous fetches, and the client
|
||||
* disconnects during your fetching process, you should make sure to
|
||||
* recognize that case and not call this function. That is, do not
|
||||
* call this function on mismatched PreCheck calls, or on disconnected
|
||||
* clients. A good way to check this is to pass userids around, which
|
||||
* are unique per client connection.
|
||||
*
|
||||
* Calling this has no effect if it has already been called on the
|
||||
* given client (thus it is safe for multiple asynchronous plugins to
|
||||
* call it at various times).
|
||||
*/
|
||||
virtual void NotifyPostAdminChecks() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Provides callbacks for important client events.
|
||||
*/
|
||||
class IClientListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the current client listener version.
|
||||
*
|
||||
* @return Client listener version.
|
||||
*/
|
||||
virtual unsigned int GetClientListenerVersion()
|
||||
{
|
||||
return SMINTERFACE_PLAYERMANAGER_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Called when a client requests connection.
|
||||
*
|
||||
* @param client Index of the client.
|
||||
* @param error Error buffer for a disconnect reason.
|
||||
* @param maxlength Maximum length of error buffer.
|
||||
* @return True to allow client, false to reject.
|
||||
*/
|
||||
virtual bool InterceptClientConnect(int client, char *error, size_t maxlength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a client has connected.
|
||||
*
|
||||
* @param client Index of the client.
|
||||
*/
|
||||
virtual void OnClientConnected(int client)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a client is put in server.
|
||||
*
|
||||
* @param client Index of the client.
|
||||
*/
|
||||
virtual void OnClientPutInServer(int client)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a client is disconnecting (not fully disconnected yet).
|
||||
*
|
||||
* @param client Index of the client.
|
||||
*/
|
||||
virtual void OnClientDisconnecting(int client)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a client has fully disconnected.
|
||||
*
|
||||
* @param client Index of the client.
|
||||
*/
|
||||
virtual void OnClientDisconnected(int client)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a client has received authorization.
|
||||
*
|
||||
* @param client Index of the client.
|
||||
* @param authstring Authorization string.
|
||||
*/
|
||||
virtual void OnClientAuthorized(int client, const char *authstring)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when the server is activated.
|
||||
*/
|
||||
virtual void OnServerActivated(int max_clients)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called once a client is authorized and fully in-game, but
|
||||
* before admin checks are done. This can be used to override the
|
||||
* default admin checks for a client.
|
||||
*
|
||||
* By default, this function allows the authentication process to
|
||||
* continue as normal. If you need to delay the cache searching
|
||||
* process in order to get asynchronous data, then return false here.
|
||||
*
|
||||
* If you return false, you must call IPlayerManager::NotifyPostAdminCheck
|
||||
* for the same client, or else the OnClientPostAdminCheck callback will
|
||||
* never be called.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @return True to continue normally, false to override
|
||||
* the authentication process.
|
||||
*/
|
||||
virtual bool OnClientPreAdminCheck(int client)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called once a client is authorized and fully in-game, and
|
||||
* after all post-connection authorizations have been passed. If the
|
||||
* client does not have an AdminId by this stage, it means that no
|
||||
* admin entry was in the cache that matched, and the user could not
|
||||
* be authenticated as an admin.
|
||||
*
|
||||
* @param client Client index.
|
||||
*/
|
||||
virtual void OnClientPostAdminCheck(int client)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#define COMMAND_FILTER_ALIVE (1<<0) /**< Only allow alive players */
|
||||
#define COMMAND_FILTER_DEAD (1<<1) /**< Only filter dead players */
|
||||
#define COMMAND_FILTER_CONNECTED (1<<2) /**< Allow players not fully in-game */
|
||||
#define COMMAND_FILTER_NO_IMMUNITY (1<<3) /**< Ignore immunity rules */
|
||||
#define COMMAND_FILTER_NO_MULTI (1<<4) /**< Do not allow multiple target patterns */
|
||||
#define COMMAND_FILTER_NO_BOTS (1<<5) /**< Do not allow bots to be targetted */
|
||||
|
||||
#define COMMAND_TARGET_VALID 1 /**< Client passed the filter */
|
||||
#define COMMAND_TARGET_NONE 0 /**< No target was found */
|
||||
#define COMMAND_TARGET_NOT_ALIVE -1 /**< Single client is not alive */
|
||||
#define COMMAND_TARGET_NOT_DEAD -2 /**< Single client is not dead */
|
||||
#define COMMAND_TARGET_NOT_IN_GAME -3 /**< Single client is not in game */
|
||||
#define COMMAND_TARGET_IMMUNE -4 /**< Single client is immune */
|
||||
#define COMMAND_TARGET_EMPTY_FILTER -5 /**< A multi-filter (such as @all) had no targets */
|
||||
#define COMMAND_TARGET_NOT_HUMAN -6 /**< Target was not human */
|
||||
#define COMMAND_TARGET_AMBIGUOUS -7 /**< Partial name had too many targets */
|
||||
|
||||
#define COMMAND_TARGETNAME_RAW 0 /**< Target name is a raw string */
|
||||
#define COMMAND_TARGETNAME_ML 1 /**< Target name is a multi-lingual phrase */
|
||||
|
||||
/**
|
||||
* @brief Holds the many command target info parameters.
|
||||
*/
|
||||
struct cmd_target_info_t
|
||||
{
|
||||
const char *pattern; /**< IN: Target pattern string. */
|
||||
int admin; /**< IN: Client admin index, or 0 if server .*/
|
||||
cell_t *targets; /**< IN: Array to store targets. */
|
||||
cell_t max_targets; /**< IN: Max targets (always >= 1) */
|
||||
int flags; /**< IN: COMMAND_FILTER flags. */
|
||||
char *target_name; /**< OUT: Buffer to store target name. */
|
||||
size_t target_name_maxlength; /**< IN: Maximum length of the target name buffer. */
|
||||
int target_name_style; /**< OUT: Target name style (COMMAND_TARGETNAME) */
|
||||
int reason; /**< OUT: COMMAND_TARGET reason. */
|
||||
unsigned int num_targets; /**< OUT: Number of targets. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Intercepts a command target operation.
|
||||
*/
|
||||
class ICommandTargetProcessor
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Must process the command target and return a COMMAND_TARGET value.
|
||||
*
|
||||
* @param info Struct containing command target information.
|
||||
* Any members labelled OUT must be filled if processing
|
||||
* is to be completed (i.e. true returned).
|
||||
* @return True to end processing, false to let Core continue.
|
||||
*/
|
||||
virtual bool ProcessCommandTarget(cmd_target_info_t *info) =0;
|
||||
};
|
||||
|
||||
class IPlayerManager : public SMInterface
|
||||
{
|
||||
public:
|
||||
const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_PLAYERMANAGER_NAME;
|
||||
}
|
||||
unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_PLAYERMANAGER_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Adds a client listener.
|
||||
*
|
||||
* @param listener Pointer to an IClientListener.
|
||||
*/
|
||||
virtual void AddClientListener(IClientListener *listener) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes a client listener.
|
||||
*
|
||||
* @param listener Pointer to an IClientListener.
|
||||
*/
|
||||
virtual void RemoveClientListener(IClientListener *listener) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves an IGamePlayer object by its client index.
|
||||
*
|
||||
* Note: This will return a valid object for any player, connected or not.
|
||||
* Note: Client indexes start at 1, not 0.
|
||||
*
|
||||
* @param client Index of the client.
|
||||
* @return An IGamePlayer pointer, or NULL if out of range.
|
||||
*/
|
||||
virtual IGamePlayer *GetGamePlayer(int client) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves an IGamePlayer object by its edict_t pointer.
|
||||
*
|
||||
* @param pEdict Index of the client
|
||||
* @return An IGamePlayer pointer, or NULL if out of range.
|
||||
*/
|
||||
virtual IGamePlayer *GetGamePlayer(edict_t *pEdict) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the maximum number of clients.
|
||||
*
|
||||
* Note: this will not work until the server is activated.
|
||||
*
|
||||
* @return Maximum number of clients.
|
||||
*/
|
||||
virtual int GetMaxClients() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of players currently connected.
|
||||
*
|
||||
* @return Current number of connected clients.
|
||||
*/
|
||||
virtual int GetNumPlayers() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the client index by its userid.
|
||||
*
|
||||
* @param userid Userid of the client.
|
||||
* @return Client index, or 0 if invalid userid passed.
|
||||
*/
|
||||
virtual int GetClientOfUserId(int userid) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether or not the server is activated.
|
||||
*
|
||||
* @return True if ServerActivate() has been called
|
||||
* at least once, false otherwise.
|
||||
*/
|
||||
virtual bool IsServerActivated() =0;
|
||||
|
||||
/**
|
||||
* @brief Gets SourceMod's reply source.
|
||||
*
|
||||
* @return ReplyTo source.
|
||||
*/
|
||||
virtual unsigned int GetReplyTo() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets SourceMod's reply source.
|
||||
*
|
||||
* @param reply Reply source.
|
||||
* @return Old reply source.
|
||||
*/
|
||||
virtual unsigned int SetReplyTo(unsigned int reply) =0;
|
||||
|
||||
/**
|
||||
* @brief Tests if a player meets command filtering rules.
|
||||
*
|
||||
* @param pAdmin IGamePlayer of the admin, or NULL if the server.
|
||||
* @param pTarget IGamePlayer of the player being targeted.
|
||||
* @param flags COMMAND_FILTER flags.
|
||||
* @return COMMAND_TARGET value.
|
||||
*/
|
||||
virtual int FilterCommandTarget(IGamePlayer *pAdmin, IGamePlayer *pTarget, int flags) =0;
|
||||
|
||||
/**
|
||||
* @brief Registers a command target processor.
|
||||
*
|
||||
* @param pHandler Pointer to an ICommandTargetProcessor instance.
|
||||
*/
|
||||
virtual void RegisterCommandTargetProcessor(ICommandTargetProcessor *pHandler) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes a command target processor.
|
||||
*
|
||||
* @param pHandler Pointer to an ICommandTargetProcessor instance.
|
||||
*/
|
||||
virtual void UnregisterCommandTargetProcessor(ICommandTargetProcessor *pHandler) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_INTERFACE_IPLAYERHELPERS_H_
|
||||
@@ -0,0 +1,352 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
|
||||
#define _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
|
||||
|
||||
/**
|
||||
* @file IPluginSys.h
|
||||
* @brief Defines the interface for the Plugin System, which manages loaded plugins.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <sp_vm_api.h>
|
||||
|
||||
#define SMINTERFACE_PLUGINSYSTEM_NAME "IPluginManager"
|
||||
#define SMINTERFACE_PLUGINSYSTEM_VERSION 2
|
||||
|
||||
/** Context user slot 3 is used Core for holding an IPluginContext pointer. */
|
||||
#define SM_CONTEXTVAR_USER 3
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class IPlugin;
|
||||
|
||||
/**
|
||||
* @brief Encapsulates plugin public information exposed through "myinfo."
|
||||
*/
|
||||
typedef struct sm_plugininfo_s
|
||||
{
|
||||
const char *name; /**< Plugin name */
|
||||
const char *author; /**< Plugin author */
|
||||
const char *description; /**< Plugin description */
|
||||
const char *version; /**< Plugin version string */
|
||||
const char *url; /**< Plugin URL */
|
||||
} sm_plugininfo_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Describes the usability status of a plugin.
|
||||
*/
|
||||
enum PluginStatus
|
||||
{
|
||||
Plugin_Running=0, /**< Plugin is running */
|
||||
/* All states below are unexecutable */
|
||||
Plugin_Paused, /**< Plugin is loaded but paused */
|
||||
Plugin_Error, /**< Plugin is loaded but errored/locked */
|
||||
/* All states below do not have all natives */
|
||||
Plugin_Loaded, /**< Plugin has passed loading and can be finalized */
|
||||
Plugin_Failed, /**< Plugin has a fatal failure */
|
||||
Plugin_Created, /**< Plugin is created but not initialized */
|
||||
Plugin_Uncompiled, /**< Plugin is not yet compiled by the JIT */
|
||||
Plugin_BadLoad, /**< Plugin failed to load */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Describes the object lifetime of a plugin.
|
||||
*/
|
||||
enum PluginType
|
||||
{
|
||||
PluginType_Private, /**< Plugin is privately managed and receives no forwards */
|
||||
PluginType_MapUpdated, /**< Plugin will never be unloaded unless for updates on mapchange */
|
||||
PluginType_MapOnly, /**< Plugin will be removed at mapchange */
|
||||
PluginType_Global, /**< Plugin will never be unloaded or updated */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Encapsulates a run-time plugin as maintained by SourceMod.
|
||||
*/
|
||||
class IPlugin
|
||||
{
|
||||
public:
|
||||
/** Virtual destructor */
|
||||
virtual ~IPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the lifetime of a plugin.
|
||||
*/
|
||||
virtual PluginType GetType() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the current API context being used in the plugin.
|
||||
*
|
||||
* @return Pointer to an IPluginContext, or NULL if not loaded.
|
||||
*/
|
||||
virtual SourcePawn::IPluginContext *GetBaseContext() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the context structure being used in the plugin.
|
||||
*
|
||||
* @return Pointer to an sp_context_t, or NULL if not loaded.
|
||||
*/
|
||||
virtual sp_context_t *GetContext() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the plugin file structure.
|
||||
*
|
||||
* @return Pointer to an sp_plugin_t, or NULL if not loaded.
|
||||
*/
|
||||
virtual const sp_plugin_t *GetPluginStructure() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns information about the plugin by reference.
|
||||
*
|
||||
* @return Pointer to a sm_plugininfo_t object, NULL if plugin is not loaded.
|
||||
*/
|
||||
virtual const sm_plugininfo_t *GetPublicInfo() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the plugin filename (relative to plugins dir).
|
||||
*/
|
||||
virtual const char *GetFilename() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns true if a plugin is in debug mode, false otherwise.
|
||||
*/
|
||||
virtual bool IsDebugging() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the plugin status.
|
||||
*/
|
||||
virtual PluginStatus GetStatus() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets whether the plugin is paused or not.
|
||||
*
|
||||
* @return True on successful state change, false otherwise.
|
||||
*/
|
||||
virtual bool SetPauseState(bool paused) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the unique serial number of a plugin.
|
||||
*/
|
||||
virtual unsigned int GetSerial() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a plugin's identity token.
|
||||
*/
|
||||
virtual IdentityToken_t *GetIdentity() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets a property on this plugin. This is used for per-plugin
|
||||
* data from extensions or other parts of core. The property's value must
|
||||
* be manually destructed when the plugin is destroyed.
|
||||
*
|
||||
* @param prop String containing name of the property.
|
||||
* @param ptr Generic pointer to set.
|
||||
* @return True on success, false if the property is already set.
|
||||
*/
|
||||
virtual bool SetProperty(const char *prop, void *ptr) =0;
|
||||
|
||||
/**
|
||||
* @brief Gets a property from a plugin.
|
||||
*
|
||||
* @param prop String containing the property's name.
|
||||
* @param ptr Optional pointer to the generic pointer.
|
||||
* @param remove Optional boolean value; if true, property is removed
|
||||
* (so it can be set again).
|
||||
* @return True if the property existed, false otherwise.
|
||||
*/
|
||||
virtual bool GetProperty(const char *prop, void **ptr, bool remove=false) =0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Iterates over a list of plugins.
|
||||
*/
|
||||
class IPluginIterator
|
||||
{
|
||||
public:
|
||||
/** Virtual destructor */
|
||||
virtual ~IPluginIterator()
|
||||
{
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief Returns true if there are more plugins in the iterator.
|
||||
*/
|
||||
virtual bool MorePlugins() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the plugin at the current iterator position.
|
||||
*/
|
||||
virtual IPlugin *GetPlugin() =0;
|
||||
|
||||
/**
|
||||
* @brief Advances to the next plugin in the iterator.
|
||||
*/
|
||||
virtual void NextPlugin() =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys the iterator object.
|
||||
* Note: You may use 'delete' in lieu of this function.
|
||||
*/
|
||||
virtual void Release() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Listens for plugin-oriented events.
|
||||
*/
|
||||
class IPluginsListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Called when a plugin is created/mapped into memory.
|
||||
*/
|
||||
virtual void OnPluginCreated(IPlugin *plugin)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a plugin is fully loaded successfully.
|
||||
*/
|
||||
virtual void OnPluginLoaded(IPlugin *plugin)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a plugin is paused or unpaused.
|
||||
*/
|
||||
virtual void OnPluginPauseChange(IPlugin *plugin, bool paused)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a plugin is unloaded (only if fully loaded).
|
||||
*/
|
||||
virtual void OnPluginUnloaded(IPlugin *plugin)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a plugin is destroyed.
|
||||
* NOTE: Always called if Created, even if load failed.
|
||||
*/
|
||||
virtual void OnPluginDestroyed(IPlugin *plugin)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Manages the runtime loading and unloading of plugins.
|
||||
*/
|
||||
class IPluginManager : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_PLUGINSYSTEM_NAME;
|
||||
}
|
||||
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_PLUGINSYSTEM_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Attempts to load a plugin.
|
||||
*
|
||||
* @param path Path and filename of plugin, relative to plugins folder.
|
||||
* @param debug Whether or not to default the plugin into debug mode.
|
||||
* @param type Lifetime of the plugin.
|
||||
* @param error Buffer to hold any error message.
|
||||
* @param maxlength Maximum length of error message buffer.
|
||||
* @param wasloaded Stores if the plugin is already loaded.
|
||||
* @return A new plugin pointer on success, false otherwise.
|
||||
*/
|
||||
virtual IPlugin *LoadPlugin(const char *path,
|
||||
bool debug,
|
||||
PluginType type,
|
||||
char error[],
|
||||
size_t maxlength,
|
||||
bool *wasloaded) =0;
|
||||
|
||||
/**
|
||||
* @brief Attempts to unload a plugin.
|
||||
*
|
||||
* @param plugin Pointer to the plugin handle.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool UnloadPlugin(IPlugin *plugin) =0;
|
||||
|
||||
/**
|
||||
* @brief Finds a plugin by its context.
|
||||
* Note: This function should be considered O(1).
|
||||
*
|
||||
* @param ctx Pointer to an sp_context_t.
|
||||
* @return Pointer to a matching IPlugin, or NULL if none found.
|
||||
*/
|
||||
virtual IPlugin *FindPluginByContext(const sp_context_t *ctx) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of plugins (both failed and loaded).
|
||||
*
|
||||
* @return The number of internally cached plugins.
|
||||
*/
|
||||
virtual unsigned int GetPluginCount() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer that can be used to iterate through plugins.
|
||||
* Note: This pointer must be freed using EITHER delete OR IPluginIterator::Release().
|
||||
*/
|
||||
virtual IPluginIterator *GetPluginIterator() =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a plugin manager listener.
|
||||
*
|
||||
* @param listener Pointer to a listener.
|
||||
*/
|
||||
virtual void AddPluginsListener(IPluginsListener *listener) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes a plugin listener.
|
||||
*
|
||||
* @param listener Pointer to a listener.
|
||||
*/
|
||||
virtual void RemovePluginsListener(IPluginsListener *listener) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
|
||||
#define _INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
|
||||
|
||||
/**
|
||||
* @file IRootConsoleMenu.h
|
||||
* @brief Defines the interface for adding options to the "sm" console command.
|
||||
*
|
||||
* You must be using the compat_wrappers.h header file to use this on
|
||||
* Original/Episode1 builds.
|
||||
*/
|
||||
|
||||
#define SMINTERFACE_ROOTCONSOLE_NAME "IRootConsole"
|
||||
#define SMINTERFACE_ROOTCONSOLE_VERSION 1
|
||||
|
||||
class CCommand;
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Handles a root console menu action.
|
||||
*/
|
||||
class IRootConsoleCommand
|
||||
{
|
||||
public:
|
||||
virtual void OnRootConsoleCommand(const char *cmdname, const CCommand &command) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Manages the root console menu - the "sm" command for servers.
|
||||
*/
|
||||
class IRootConsole : public SMInterface
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Adds a root console command handler. The command must be unique.
|
||||
*
|
||||
* @param cmd String containing the console command.
|
||||
* @param text Description text.
|
||||
* @param pHandler An IRootConsoleCommand pointer to handle the command.
|
||||
* @return True on success, false on too many commands or duplicate command.
|
||||
*/
|
||||
virtual bool AddRootConsoleCommand(const char *cmd, const char *text, IRootConsoleCommand *pHandler) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes a root console command handler.
|
||||
*
|
||||
* @param cmd String containing the console command.
|
||||
* @param pHandler An IRootConsoleCommand pointer for verification.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool RemoveRootConsoleCommand(const char *cmd, IRootConsoleCommand *pHandler) =0;
|
||||
|
||||
/**
|
||||
* @brief Prints text back to the console.
|
||||
*
|
||||
* @param fmt Format of string.
|
||||
* @param ... Format arguments.
|
||||
*/
|
||||
virtual void ConsolePrint(const char *fmt, ...) =0;
|
||||
|
||||
/**
|
||||
* @brief Draws a generic command/description pair.
|
||||
* NOTE: The pair is currently four spaces indented and 16-N spaces of separation,
|
||||
* N being the length of the command name. This is subject to change in case we
|
||||
* account for Valve's font choices.
|
||||
*
|
||||
* @param cmd String containing the command option.
|
||||
* @param text String containing the command description.
|
||||
*/
|
||||
virtual void DrawGenericOption(const char *cmd, const char *text) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_ROOT_CONSOLE_MENU_H_
|
||||
@@ -0,0 +1,227 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
|
||||
#define _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
|
||||
|
||||
/**
|
||||
* @file IShareSys.h
|
||||
* @brief Defines the Share System, responsible for shared resources and dependencies.
|
||||
*
|
||||
* The Share System also manages the Identity_t data type, although this is internally
|
||||
* implemented with the Handle System.
|
||||
*/
|
||||
|
||||
#include <sp_vm_types.h>
|
||||
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class IExtension;
|
||||
struct IdentityToken_t;
|
||||
|
||||
/** Forward declaration from IHandleSys.h */
|
||||
typedef unsigned int HandleType_t;
|
||||
|
||||
/** Forward declaration from IHandleSys.h */
|
||||
typedef HandleType_t IdentityType_t;
|
||||
|
||||
/**
|
||||
* @brief Defines the base functionality required by a shared interface.
|
||||
*/
|
||||
class SMInterface
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Must return an integer defining the interface's version.
|
||||
*/
|
||||
virtual unsigned int GetInterfaceVersion() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return a string defining the interface's unique name.
|
||||
*/
|
||||
virtual const char *GetInterfaceName() =0;
|
||||
|
||||
/**
|
||||
* @brief Must return whether the requested version number is backwards compatible.
|
||||
* Note: This can be overridden for breaking changes or custom versioning.
|
||||
*
|
||||
* @param version Version number to compare against.
|
||||
* @return True if compatible, false otherwise.
|
||||
*/
|
||||
virtual bool IsVersionCompatible(unsigned int version)
|
||||
{
|
||||
if (version > GetInterfaceVersion())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Tracks dependencies and fires dependency listeners.
|
||||
*/
|
||||
class IShareSys
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Adds an interface to the global interface system.
|
||||
*
|
||||
* @param myself Object adding this interface, in order to track dependencies.
|
||||
* @param iface Interface pointer (must be unique).
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool AddInterface(IExtension *myself, SMInterface *iface) =0;
|
||||
|
||||
/**
|
||||
* @brief Requests an interface from the global interface system.
|
||||
* If found, the interface's internal reference count will be increased.
|
||||
*
|
||||
* @param iface_name Interface name.
|
||||
* @param iface_vers Interface version to attempt to match.
|
||||
* @param myself Object requesting this interface, in order to track dependencies.
|
||||
* @param pIface Pointer to store the return value in.
|
||||
*/
|
||||
virtual bool RequestInterface(const char *iface_name,
|
||||
unsigned int iface_vers,
|
||||
IExtension *myself,
|
||||
SMInterface **pIface) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a list of natives to the global native pool, to be
|
||||
* bound on plugin load.
|
||||
*
|
||||
* Adding natives does not bind them to any loaded plugins; the
|
||||
* plugins must be reloaded for new natives to take effect.
|
||||
*
|
||||
* @param myself Identity token of parent object.
|
||||
* @param natives Array of natives to add. The last entry in
|
||||
* the array must be filled with NULLs to
|
||||
* terminate the array. The array must be static
|
||||
* as Core will cache the pointer for the
|
||||
* lifetime of the extension.
|
||||
*/
|
||||
virtual void AddNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a new identity type.
|
||||
* NOTE: Module authors should never need to use this. Due to the current implementation,
|
||||
* there is a hardcoded limit of 15 types. Core uses up a few, so think carefully!
|
||||
*
|
||||
* @param name String containing type name. Must not be empty or NULL.
|
||||
* @return A new HandleType_t identifier, or 0 on failure.
|
||||
*/
|
||||
virtual IdentityType_t CreateIdentType(const char *name) =0;
|
||||
|
||||
/**
|
||||
* @brief Finds an identity type by name.
|
||||
* DEFAULT IDENTITY TYPES:
|
||||
* "PLUGIN" - An IPlugin object.
|
||||
* "MODULE" - An IModule object.
|
||||
* "CORE" - An SMGlobalClass or other singleton.
|
||||
*
|
||||
* @param name String containing type name to search for.
|
||||
* @return A HandleType_t identifier if found, 0 otherwise.
|
||||
*/
|
||||
virtual IdentityType_t FindIdentType(const char *name) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a new identity token. This token is guaranteed to be
|
||||
* unique amongst all other open identities.
|
||||
*
|
||||
* @param type Identity type.
|
||||
* @param ptr Private data pointer (cannot be NULL).
|
||||
* @return A new IdentityToken_t pointer, or NULL on failure.
|
||||
*/
|
||||
virtual IdentityToken_t *CreateIdentity(IdentityType_t type, void *ptr) =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys an identity type. Note that this will delete any identities
|
||||
* that are under this type.
|
||||
*
|
||||
* @param type Identity type.
|
||||
*/
|
||||
virtual void DestroyIdentType(IdentityType_t type) =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys an identity token. Any handles being owned by this token, or
|
||||
* any handles being
|
||||
*
|
||||
* @param identity Identity to remove.
|
||||
*/
|
||||
virtual void DestroyIdentity(IdentityToken_t *identity) =0;
|
||||
|
||||
/**
|
||||
* @brief Requires an extension. This tells SourceMod that without this extension,
|
||||
* your extension should not be loaded. The name should not include the ".dll" or
|
||||
* the ".so" part of the file name.
|
||||
*
|
||||
* @param myself IExtension pointer to yourself.
|
||||
* @param filename File of extension to require.
|
||||
* @param require Whether or not this extension is a required dependency.
|
||||
* @param autoload Whether or not to autoload this extension.
|
||||
*/
|
||||
virtual void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload) =0;
|
||||
|
||||
/**
|
||||
* @brief Registers a library name to an extension.
|
||||
*
|
||||
* @param myself Extension to register library to.
|
||||
* @param name Library name.
|
||||
*/
|
||||
virtual void RegisterLibrary(IExtension *myself, const char *name) =0;
|
||||
|
||||
/**
|
||||
* @brief Adds natives that will override Core natives when called.
|
||||
*
|
||||
* A Core version of each native must exist. If one does not, then
|
||||
* Core will simply ignore that entry. No more than one override
|
||||
* can exist on a given native.
|
||||
*
|
||||
* Override natives represent a weak coupling. If the extension is
|
||||
* unloaded, the native will be re-bound to the Core version. If
|
||||
* the extension is loaded after plugins are loaded, the override
|
||||
* will not take effect until those plugins are reloaded.
|
||||
*
|
||||
* @param myself Identity token of parent object.
|
||||
* @param natives Array of natives to add. The last entry in
|
||||
* the array must be filled with NULLs to
|
||||
* terminate the array. The array must be static
|
||||
* as Core will cache the pointer for the
|
||||
* lifetime of the extension.
|
||||
*/
|
||||
virtual void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
|
||||
@@ -0,0 +1,254 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
|
||||
#define _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
|
||||
|
||||
/**
|
||||
* @file ISourceMod.h
|
||||
* @brief Defines miscellaneous helper functions useful to extensions.
|
||||
*/
|
||||
|
||||
#include <IHandleSys.h>
|
||||
#include <sp_vm_api.h>
|
||||
#include <IDataPack.h>
|
||||
#include <time.h>
|
||||
|
||||
#define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
|
||||
#define SMINTERFACE_SOURCEMOD_VERSION 7
|
||||
|
||||
/**
|
||||
* @brief Forward declaration of the KeyValues class.
|
||||
*/
|
||||
class KeyValues;
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Describes various ways of formatting a base path.
|
||||
*/
|
||||
enum PathType
|
||||
{
|
||||
Path_None = 0, /**< No base path */
|
||||
Path_Game, /**< Base path is absolute mod folder */
|
||||
Path_SM, /**< Base path is absolute to SourceMod */
|
||||
Path_SM_Rel, /**< Base path is relative to SourceMod */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Called when a game frame is fired.
|
||||
*
|
||||
* @param simulating Whether or not the game is ticking.
|
||||
*/
|
||||
typedef void (*GAME_FRAME_HOOK)(bool simulating);
|
||||
|
||||
/**
|
||||
* @brief Contains miscellaneous helper functions.
|
||||
*/
|
||||
class ISourceMod : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_SOURCEMOD_NAME;
|
||||
}
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_SOURCEMOD_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the full path to the game directory.
|
||||
*
|
||||
* @return A string containing the full game path.
|
||||
*/
|
||||
virtual const char *GetGamePath() const =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the full path to the SourceMod directory.
|
||||
*
|
||||
* @return A string containing the full SourceMod path.
|
||||
*/
|
||||
virtual const char *GetSourceModPath() const =0;
|
||||
|
||||
/**
|
||||
* @brief Builds a platform path for a specific target base path.
|
||||
*
|
||||
* If the path starts with the string "file://" and the PathType is
|
||||
* not relative, then the "file://" portion is stripped off, and the
|
||||
* rest of the path is used without any modification (except for
|
||||
* correcting slashes). This can be used to override the path
|
||||
* builder to supply alternate absolute paths. Examples:
|
||||
*
|
||||
* file://C:/Temp/file.txt
|
||||
* file:///tmp/file.txt
|
||||
*
|
||||
* @param type Type of path to use as a base.
|
||||
* @param buffer Buffer to write to.
|
||||
* @param maxlength Size of buffer.
|
||||
* @param format Format string.
|
||||
* @param ... Format arguments.
|
||||
* @return Number of bytes written.
|
||||
*/
|
||||
virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...) =0;
|
||||
|
||||
/**
|
||||
* @brief Logs a message to the SourceMod logs.
|
||||
*
|
||||
* @param pExt Extension calling this function.
|
||||
* @param format Message format.
|
||||
* @param ... Message format parameters.
|
||||
*/
|
||||
virtual void LogMessage(IExtension *pExt, const char *format, ...) =0;
|
||||
|
||||
/**
|
||||
* @brief Logs a message to the SourceMod error logs.
|
||||
*
|
||||
* @param pExt Extension calling this function.
|
||||
* @param format Message format.
|
||||
* @param ... Message format parameters.
|
||||
*/
|
||||
virtual void LogError(IExtension *pExt, const char *format, ...) =0;
|
||||
|
||||
/**
|
||||
* @brief Formats a string from a native.
|
||||
*
|
||||
* @param buffer Buffer to store message.
|
||||
* @param maxlength Maximum length of buffer (including null terminator).
|
||||
* @param pContext Pointer to the plugin's context.
|
||||
* @param params Parameter array that was passed to the native.
|
||||
* @param param Parameter index where format string and variable arguments begin.
|
||||
* Note: parameter indexes start at 1.
|
||||
* @return Number of bytes written, not including the null terminator.
|
||||
*/
|
||||
virtual size_t FormatString(char *buffer,
|
||||
size_t maxlength,
|
||||
SourcePawn::IPluginContext *pContext,
|
||||
const cell_t *params,
|
||||
unsigned int param) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a data pack object.
|
||||
*
|
||||
* @return A new IDataPack object.
|
||||
*/
|
||||
virtual IDataPack *CreateDataPack() =0;
|
||||
|
||||
/**
|
||||
* @brief Releases a data pack's resources so it can be re-used.
|
||||
*
|
||||
* @param pack An IDataPack object to release.
|
||||
*/
|
||||
virtual void FreeDataPack(IDataPack *pack) =0;
|
||||
|
||||
/**
|
||||
* @brief Not implemented, do not use.
|
||||
*
|
||||
* @param readonly Ignored
|
||||
* @return 0
|
||||
*/
|
||||
virtual HandleType_t GetDataPackHandleType(bool readonly=false) =0;
|
||||
|
||||
/**
|
||||
* @brief Retrieves a KeyValues pointer from a handle.
|
||||
*
|
||||
* @param hndl Handle_t from which to retrieve contents.
|
||||
* @param err Optional address to store a possible handle error.
|
||||
* @param root If true it will return the root KeyValues pointer for the whole structure.
|
||||
*
|
||||
* @return The KeyValues pointer, or NULL for any error encountered.
|
||||
*/
|
||||
virtual KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the name of the game directory.
|
||||
*
|
||||
* @return A string containing the name of the game directory.
|
||||
*/
|
||||
virtual const char *GetGameFolderName() const =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the scripting engine interface.
|
||||
*
|
||||
* @return A pointer to the scripting engine interface.
|
||||
*/
|
||||
virtual SourcePawn::ISourcePawnEngine *GetScriptingEngine() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the JIT interface.
|
||||
*
|
||||
* @return A pointer to the JIT interface.
|
||||
*/
|
||||
virtual SourcePawn::IVirtualMachine *GetScriptingVM() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the adjusted server time.
|
||||
*
|
||||
* @return Adjusted server time.
|
||||
*/
|
||||
virtual time_t GetAdjustedTime() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the global client SourceMod will use for assisted
|
||||
* translations (that is, %t).
|
||||
*
|
||||
* @param index Client index.
|
||||
* @deprecated Use ITranslator::GetGlobalTarget() instead.
|
||||
* @return Old global client value.
|
||||
*/
|
||||
virtual unsigned int SetGlobalTarget(unsigned int index) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the global client SourceMod is currently using
|
||||
* for assisted translations (that is, %t).
|
||||
*
|
||||
* @deprecated Use ITranslator::GetGlobalTarget() instead.
|
||||
* @return Global client value.
|
||||
*/
|
||||
virtual unsigned int GetGlobalTarget() const =0;
|
||||
|
||||
/**
|
||||
* @brief Adds a function to be called each game frame.
|
||||
*
|
||||
* @param hook Hook function.
|
||||
*/
|
||||
virtual void AddGameFrameHook(GAME_FRAME_HOOK hook) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes one game frame hook matching the given function.
|
||||
*
|
||||
* @param hook Hook function.
|
||||
*/
|
||||
virtual void RemoveGameFrameHook(GAME_FRAME_HOOK hook) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
|
||||
@@ -0,0 +1,432 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
|
||||
#define _INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
|
||||
|
||||
/**
|
||||
* @file ITextParsers.h
|
||||
* @brief Defines various text/file parsing functions, as well as UTF-8 support code.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
|
||||
#define SMINTERFACE_TEXTPARSERS_NAME "ITextParsers"
|
||||
#define SMINTERFACE_TEXTPARSERS_VERSION 3
|
||||
|
||||
/**
|
||||
* The INI file format is defined as:
|
||||
* WHITESPACE: 0x20, \n, \t, \r
|
||||
* IDENTIFIER: A-Z a-z 0-9 _ - , + . $ ? /
|
||||
* STRING: Any set of symbols
|
||||
*
|
||||
* Basic syntax is comprised of SECTIONs.
|
||||
* A SECTION is defined as:
|
||||
* [SECTIONNAME]
|
||||
* OPTION
|
||||
* OPTION
|
||||
* OPTION...
|
||||
*
|
||||
* SECTIONNAME is an IDENTIFIER.
|
||||
* OPTION can be repeated any number of times, once per line.
|
||||
* OPTION is defined as one of:
|
||||
* KEY = "VALUE"
|
||||
* KEY = VALUE
|
||||
* KEY
|
||||
* Where KEY is an IDENTIFIER and VALUE is a STRING.
|
||||
*
|
||||
* WHITESPACE should always be omitted.
|
||||
* COMMENTS should be stripped, and are defined as text occurring in:
|
||||
* ;<TEXT>
|
||||
*
|
||||
* Example file below. Note that
|
||||
* The second line is technically invalid. The event handler
|
||||
* must decide whether this should be allowed.
|
||||
* --FILE BELOW--
|
||||
* [gaben]
|
||||
* hi = clams
|
||||
* bye = "NO CLAMS"
|
||||
*
|
||||
* [valve]
|
||||
* cannot
|
||||
* maintain
|
||||
* products
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Contains parse events for INI files.
|
||||
*/
|
||||
class ITextListener_INI
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns version number.
|
||||
*/
|
||||
virtual unsigned int GetTextParserVersion1()
|
||||
{
|
||||
return SMINTERFACE_TEXTPARSERS_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Called when a new section is encountered in an INI file.
|
||||
*
|
||||
* @param section Name of section in between the [ and ] characters.
|
||||
* @param invalid_tokens True if invalid tokens were detected in the name.
|
||||
* @param close_bracket True if a closing bracket was detected, false otherwise.
|
||||
* @param extra_tokens True if extra tokens were detected on the line.
|
||||
* @param curtok Contains current token in the line where the section name starts.
|
||||
* You can add to this offset when failing to point to a token.
|
||||
* @return True to keep parsing, false otherwise.
|
||||
*/
|
||||
virtual bool ReadINI_NewSection(const char *section,
|
||||
bool invalid_tokens,
|
||||
bool close_bracket,
|
||||
bool extra_tokens,
|
||||
unsigned int *curtok)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when encountering a key/value pair in an INI file.
|
||||
*
|
||||
* @param key Name of key.
|
||||
* @param value String containing value (with quotes stripped, if any).
|
||||
* @param invalid_tokens Whether or not the key contained invalid tokens.
|
||||
* @param equal_token There was an '=' sign present (in case the value is missing).
|
||||
* @param quotes Whether value was enclosed in quotes.
|
||||
* @param curtok Contains the token index of the start of the value string.
|
||||
* This can be changed when returning false.
|
||||
* @return True to keep parsing, false otherwise.
|
||||
*/
|
||||
virtual bool ReadINI_KeyValue(const char *key,
|
||||
const char *value,
|
||||
bool invalid_tokens,
|
||||
bool equal_token,
|
||||
bool quotes,
|
||||
unsigned int *curtok)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called after a line has been preprocessed, if it has text.
|
||||
*
|
||||
* @param line Contents of line.
|
||||
* @param curtok Pointer to optionally store failed position in string.
|
||||
* @return True to keep parsing, false otherwise.
|
||||
*/
|
||||
virtual bool ReadINI_RawLine(const char *line, unsigned int *curtok)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* :TODO: write this in CFG (context free grammar) format so it makes sense
|
||||
*
|
||||
* The SMC file format is defined as:
|
||||
* WHITESPACE: 0x20, \n, \t, \r
|
||||
* IDENTIFIER: Any ASCII character EXCLUDING ", {, }, ;, //, / *, or WHITESPACE.
|
||||
* STRING: Any set of symbols enclosed in quotes.
|
||||
* Note: if a STRING does not have quotes, it is parsed as an IDENTIFIER.
|
||||
*
|
||||
* Basic syntax is comprised of SECTIONBLOCKs.
|
||||
* A SECTIONBLOCK defined as:
|
||||
*
|
||||
* SECTIONNAME
|
||||
* {
|
||||
* OPTION
|
||||
* }
|
||||
*
|
||||
* OPTION can be repeated any number of times inside a SECTIONBLOCK.
|
||||
* A new line will terminate an OPTION, but there can be more than one OPTION per line.
|
||||
* OPTION is defined any of:
|
||||
* "KEY" "VALUE"
|
||||
* SECTIONBLOCK
|
||||
*
|
||||
* SECTIONNAME, KEY, VALUE, and SINGLEKEY are strings
|
||||
* SECTIONNAME cannot have trailing characters if quoted, but the quotes can be optionally removed.
|
||||
* If SECTIONNAME is not enclosed in quotes, the entire sectionname string is used (minus surrounding whitespace).
|
||||
* If KEY is not enclosed in quotes, the key is terminated at first whitespace.
|
||||
* If VALUE is not properly enclosed in quotes, the entire value string is used (minus surrounding whitespace).
|
||||
* The VALUE may have inner quotes, but the key string may not.
|
||||
*
|
||||
* For an example, see configs/permissions.cfg
|
||||
*
|
||||
* WHITESPACE should be ignored.
|
||||
* Comments are text occurring inside the following tokens, and should be stripped
|
||||
* unless they are inside literal strings:
|
||||
* ;<TEXT>
|
||||
* //<TEXT>
|
||||
* / *<TEXT> */
|
||||
|
||||
/**
|
||||
* @brief Lists actions to take when an SMC parse hook is done.
|
||||
*/
|
||||
enum SMCResult
|
||||
{
|
||||
SMCResult_Continue, /**< Continue parsing */
|
||||
SMCResult_Halt, /**< Stop parsing here */
|
||||
SMCResult_HaltFail /**< Stop parsing and return SMCError_Custom */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Lists error codes possible from parsing an SMC file.
|
||||
*/
|
||||
enum SMCError
|
||||
{
|
||||
SMCError_Okay = 0, /**< No error */
|
||||
SMCError_StreamOpen, /**< Stream failed to open */
|
||||
SMCError_StreamError, /**< The stream died... somehow */
|
||||
SMCError_Custom, /**< A custom handler threw an error */
|
||||
SMCError_InvalidSection1, /**< A section was declared without quotes, and had extra tokens */
|
||||
SMCError_InvalidSection2, /**< A section was declared without any header */
|
||||
SMCError_InvalidSection3, /**< A section ending was declared with too many unknown tokens */
|
||||
SMCError_InvalidSection4, /**< A section ending has no matching beginning */
|
||||
SMCError_InvalidSection5, /**< A section beginning has no matching ending */
|
||||
SMCError_InvalidTokens, /**< There were too many unidentifiable strings on one line */
|
||||
SMCError_TokenOverflow, /**< The token buffer overflowed */
|
||||
SMCError_InvalidProperty1, /**< A property was declared outside of any section */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief States for line/column
|
||||
*/
|
||||
struct SMCStates
|
||||
{
|
||||
unsigned int line; /**< Current line */
|
||||
unsigned int col; /**< Current col */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes the events available for reading an SMC stream.
|
||||
*/
|
||||
class ITextListener_SMC
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns version number.
|
||||
*/
|
||||
virtual unsigned int GetTextParserVersion2()
|
||||
{
|
||||
return SMINTERFACE_TEXTPARSERS_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Called when starting parsing.
|
||||
*/
|
||||
virtual void ReadSMC_ParseStart()
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Called when ending parsing.
|
||||
*
|
||||
* @param halted True if abnormally halted, false otherwise.
|
||||
* @param failed True if parsing failed, false otherwise.
|
||||
*/
|
||||
virtual void ReadSMC_ParseEnd(bool halted, bool failed)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when entering a new section
|
||||
*
|
||||
* @param states Parsing states.
|
||||
* @param name Name of section, with the colon omitted.
|
||||
* @return SMCResult directive.
|
||||
*/
|
||||
virtual SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name)
|
||||
{
|
||||
return SMCResult_Continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when encountering a key/value pair in a section.
|
||||
*
|
||||
* @param states Parsing states.
|
||||
* @param key Key string.
|
||||
* @param value Value string. If no quotes were specified, this will be NULL,
|
||||
* and key will contain the entire string.
|
||||
* @return SMCResult directive.
|
||||
*/
|
||||
virtual SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value)
|
||||
{
|
||||
return SMCResult_Continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when leaving the current section.
|
||||
*
|
||||
* @param states Parsing states.
|
||||
* @return SMCResult directive.
|
||||
*/
|
||||
virtual SMCResult ReadSMC_LeavingSection(const SMCStates *states)
|
||||
{
|
||||
return SMCResult_Continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called after an input line has been preprocessed.
|
||||
*
|
||||
* @param states Parsing states.
|
||||
* @param line Contents of the line, null terminated at the position
|
||||
* of the newline character (thus, no newline will exist).
|
||||
* @return SMCResult directive.
|
||||
*/
|
||||
virtual SMCResult ReadSMC_RawLine(const SMCStates *states, const char *line)
|
||||
{
|
||||
return SMCResult_Continue;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Contains various text stream parsing functions.
|
||||
*/
|
||||
class ITextParsers : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_TEXTPARSERS_NAME;
|
||||
}
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_TEXTPARSERS_VERSION;
|
||||
}
|
||||
virtual bool IsVersionCompatible(unsigned int version)
|
||||
{
|
||||
if (version < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return SMInterface::IsVersionCompatible(version);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Parses an INI-format file.
|
||||
*
|
||||
* @param file Path to file.
|
||||
* @param ini_listener Event handler for reading file.
|
||||
* @param line If non-NULL, will contain last line parsed (0 if file could not be opened).
|
||||
* @param col If non-NULL, will contain last column parsed (undefined if file could not be opened).
|
||||
* @return True if parsing succeeded, false if file couldn't be opened or there was a syntax error.
|
||||
*/
|
||||
virtual bool ParseFile_INI(const char *file,
|
||||
ITextListener_INI *ini_listener,
|
||||
unsigned int *line,
|
||||
unsigned int *col) =0;
|
||||
|
||||
/**
|
||||
* @brief Parses an SMC-format text file.
|
||||
* Note that the parser makes every effort to obey broken syntax.
|
||||
* For example, if an open brace is missing, but the section name has a colon,
|
||||
* it will let you know. It is up to the event handlers to decide whether to be strict or not.
|
||||
*
|
||||
* @param file Path to file.
|
||||
* @param smc_listener Event handler for reading file.
|
||||
* @param states Optional pointer to store last known states.
|
||||
* @return An SMCError result code.
|
||||
*/
|
||||
virtual SMCError ParseFile_SMC(const char *file,
|
||||
ITextListener_SMC *smc_listener,
|
||||
SMCStates *states) =0;
|
||||
|
||||
/**
|
||||
* @brief Converts an SMCError to a string.
|
||||
*
|
||||
* @param err SMCError.
|
||||
* @return String error message, or NULL if none.
|
||||
*/
|
||||
virtual const char *GetSMCErrorString(SMCError err) =0;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the number of bytes that a multi-byte character contains in a UTF-8 stream.
|
||||
* If the current character is not multi-byte, the function returns 1.
|
||||
*
|
||||
* @param stream Pointer to multi-byte ANSI character string.
|
||||
* @return Number of bytes in current character.
|
||||
*/
|
||||
virtual unsigned int GetUTF8CharBytes(const char *stream) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns whether the first multi-byte character in the given stream
|
||||
* is a whitespace character.
|
||||
*
|
||||
* @param stream Pointer to multi-byte character string.
|
||||
* @return True if first character is whitespace, false otherwise.
|
||||
*/
|
||||
virtual bool IsWhitespace(const char *stream) =0;
|
||||
|
||||
/**
|
||||
* @brief Same as ParseFile_SMC, but with an extended error buffer.
|
||||
*
|
||||
* @param file Path to file.
|
||||
* @param smc_listener Event handler for reading file.
|
||||
* @param states Optional pointer to store last known states.
|
||||
* @param buffer Error message buffer.
|
||||
* @param maxsize Maximum size of the error buffer.
|
||||
*/
|
||||
virtual SMCError ParseSMCFile(const char *file,
|
||||
ITextListener_SMC *smc_listener,
|
||||
SMCStates *states,
|
||||
char *buffer,
|
||||
size_t maxsize) =0;
|
||||
};
|
||||
|
||||
inline unsigned int _GetUTF8CharBytes(const char *stream)
|
||||
{
|
||||
unsigned char c = *(unsigned char *)stream;
|
||||
if (c & (1<<7))
|
||||
{
|
||||
if (c & (1<<5))
|
||||
{
|
||||
if (c & (1<<4))
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
extern SourceMod::ITextParsers *textparsers;
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_TEXTPARSERS_INTERFACE_H_
|
||||
|
||||
@@ -0,0 +1,455 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_THREADER_H
|
||||
#define _INCLUDE_SOURCEMOD_THREADER_H
|
||||
|
||||
/**
|
||||
* @file IThreader.h
|
||||
* @brief Contains platform independent routines for threading.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
|
||||
#define SMINTERFACE_THREADER_NAME "IThreader"
|
||||
#define SMINTERFACE_THREADER_VERSION 2
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Thread creation flags
|
||||
*/
|
||||
enum ThreadFlags
|
||||
{
|
||||
Thread_Default = 0,
|
||||
/**
|
||||
* @brief Auto-release handle on finish
|
||||
*
|
||||
* You are not guaranteed the handle for this is valid after
|
||||
* calling MakeThread(), so never use it until OnTerminate is called.
|
||||
*/
|
||||
Thread_AutoRelease = 1,
|
||||
/**
|
||||
* @brief Thread is created "suspended", meaning it is inactive until unpaused.
|
||||
*/
|
||||
Thread_CreateSuspended = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Specifies thread priority levels.
|
||||
*/
|
||||
enum ThreadPriority
|
||||
{
|
||||
ThreadPrio_Minimum = -8,
|
||||
ThreadPrio_Low = -3,
|
||||
ThreadPrio_Normal = 0,
|
||||
ThreadPrio_High = 3,
|
||||
ThreadPrio_Maximum = 8,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The current state of a thread.
|
||||
*/
|
||||
enum ThreadState
|
||||
{
|
||||
Thread_Running = 0,
|
||||
Thread_Paused = 1,
|
||||
Thread_Done = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Thread-specific parameters.
|
||||
*/
|
||||
struct ThreadParams
|
||||
{
|
||||
/** Constructor */
|
||||
ThreadParams() :
|
||||
flags(Thread_Default),
|
||||
prio(ThreadPrio_Normal)
|
||||
{
|
||||
};
|
||||
ThreadFlags flags; /**< Flags to set on the thread */
|
||||
ThreadPriority prio; /**< Priority to set on the thread */
|
||||
};
|
||||
|
||||
class IThreadCreator;
|
||||
|
||||
/**
|
||||
* @brief Describes a handle to a thread.
|
||||
*/
|
||||
class IThreadHandle
|
||||
{
|
||||
public:
|
||||
/** Virtual destructor */
|
||||
virtual ~IThreadHandle() { };
|
||||
public:
|
||||
/**
|
||||
* @brief Pauses parent thread until this thread completes.
|
||||
*
|
||||
* @return True if successful, false otherwise.
|
||||
*/
|
||||
virtual bool WaitForThread() =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys the thread handle. This will not necessarily cancel the thread.
|
||||
*/
|
||||
virtual void DestroyThis() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the parent threader.
|
||||
*
|
||||
* @return IThreadCreator that created this thread.
|
||||
*/
|
||||
virtual IThreadCreator *Parent() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the thread states.
|
||||
*
|
||||
* @param ptparams Pointer to a ThreadParams buffer.
|
||||
*/
|
||||
virtual void GetParams(ThreadParams *ptparams) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the thread priority.
|
||||
*
|
||||
* @return Thread priority.
|
||||
*/
|
||||
virtual ThreadPriority GetPriority() =0;
|
||||
|
||||
/**
|
||||
* @brief Sets thread priority.
|
||||
* NOTE: On Linux, this always returns false.
|
||||
*
|
||||
* @param prio Thread priority to set.
|
||||
* @return True if successful, false otherwise.
|
||||
*/
|
||||
virtual bool SetPriority(ThreadPriority prio) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the thread state.
|
||||
*
|
||||
* @return Current thread state.
|
||||
*/
|
||||
virtual ThreadState GetState() =0;
|
||||
|
||||
/**
|
||||
* @brief Attempts to unpause a paused thread.
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool Unpause() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Handles a single thread's execution.
|
||||
*/
|
||||
class IThread
|
||||
{
|
||||
public:
|
||||
/** Virtual destructor */
|
||||
virtual ~IThread() { };
|
||||
public:
|
||||
/**
|
||||
* @brief Called when the thread runs (in its own thread).
|
||||
*
|
||||
* @param pHandle Pointer to the thread's handle.
|
||||
*/
|
||||
virtual void RunThread(IThreadHandle *pHandle) =0;
|
||||
|
||||
/**
|
||||
* @brief Called when the thread terminates. This occurs inside the thread as well.
|
||||
*
|
||||
* @param pHandle Pointer to the thread's handle.
|
||||
* @param cancel True if the thread did not finish, false otherwise.
|
||||
*/
|
||||
virtual void OnTerminate(IThreadHandle *pHandle, bool cancel) =0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Describes a thread creator
|
||||
*/
|
||||
class IThreadCreator
|
||||
{
|
||||
public:
|
||||
/** Virtual Destructor */
|
||||
virtual ~IThreadCreator() { };
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a basic thread.
|
||||
*
|
||||
* @param pThread IThread pointer for callbacks.
|
||||
*/
|
||||
virtual void MakeThread(IThread *pThread) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a thread with specific options.
|
||||
*
|
||||
* @param pThread IThread pointer for callbacks.
|
||||
* @param flags Flags for the thread.
|
||||
* @return IThreadHandle pointer (must be released).
|
||||
*/
|
||||
virtual IThreadHandle *MakeThread(IThread *pThread, ThreadFlags flags) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a thread with specific options.
|
||||
*
|
||||
* @param pThread IThread pointer for callbacks.
|
||||
* @param params Extended options for the thread.
|
||||
* @return IThreadHandle pointer (must be released).
|
||||
*/
|
||||
virtual IThreadHandle *MakeThread(IThread *pThread, const ThreadParams *params) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the priority bounds.
|
||||
* Note: On Linux, the min and max are both Thread_Normal.
|
||||
*
|
||||
* @param max Stores the maximum priority level.
|
||||
* @param min Stores the minimum priority level.
|
||||
*/
|
||||
virtual void GetPriorityBounds(ThreadPriority &max, ThreadPriority &min) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes a simple locking mutex.
|
||||
*/
|
||||
class IMutex
|
||||
{
|
||||
public:
|
||||
/** Virtual Destructor */
|
||||
virtual ~IMutex() { };
|
||||
public:
|
||||
/**
|
||||
* @brief Attempts to lock, but returns instantly.
|
||||
*
|
||||
* @return True if lock was obtained, false otherwise.
|
||||
*/
|
||||
virtual bool TryLock() =0;
|
||||
|
||||
/**
|
||||
* @brief Attempts to lock by waiting for release.
|
||||
*/
|
||||
virtual void Lock() =0;
|
||||
|
||||
/**
|
||||
* @brief Unlocks the mutex.
|
||||
*/
|
||||
virtual void Unlock() =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys the mutex handle.
|
||||
*/
|
||||
virtual void DestroyThis() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes a simple "condition variable"/signal lock.
|
||||
*/
|
||||
class IEventSignal
|
||||
{
|
||||
public:
|
||||
/** Virtual Destructor */
|
||||
virtual ~IEventSignal() { };
|
||||
public:
|
||||
/**
|
||||
* @brief Waits for a signal.
|
||||
*/
|
||||
virtual void Wait() =0;
|
||||
|
||||
/**
|
||||
* @brief Triggers the signal and resets the signal after triggering.
|
||||
*/
|
||||
virtual void Signal() =0;
|
||||
|
||||
/**
|
||||
* @brief Frees the signal handle.
|
||||
*/
|
||||
virtual void DestroyThis() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes possible worker states
|
||||
*/
|
||||
enum WorkerState
|
||||
{
|
||||
Worker_Invalid = -3,
|
||||
Worker_Stopped = -2,
|
||||
Worker_Paused = -1,
|
||||
Worker_Running,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This is a "worker pool." A single thread places tasks in a queue.
|
||||
* Each IThread is then a task, rather than its own separate thread.
|
||||
*/
|
||||
class IThreadWorker : public IThreadCreator
|
||||
{
|
||||
public:
|
||||
/** Virtual Destructor */
|
||||
virtual ~IThreadWorker()
|
||||
{
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief Runs one "frame" of the worker.
|
||||
*
|
||||
* @return Number of tasks processed.
|
||||
*/
|
||||
virtual unsigned int RunFrame() =0;
|
||||
public:
|
||||
/**
|
||||
* @brief Pauses the worker.
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool Pause() =0;
|
||||
|
||||
/**
|
||||
* @brief Unpauses the worker.
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool Unpause() =0;
|
||||
|
||||
/**
|
||||
* @brief Starts the worker thread.
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool Start() =0;
|
||||
|
||||
/**
|
||||
* @brief Stops the worker thread.
|
||||
*
|
||||
* @param flush If true, all remaining tasks will be cancelled.
|
||||
* Otherwise, the threader will wait until the queue is empty.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool Stop(bool flush) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the status of the worker.
|
||||
*
|
||||
* @param numThreads Pointer to store number of threads in the queue.
|
||||
* @return State of the worker.
|
||||
*/
|
||||
virtual WorkerState GetStatus(unsigned int *numThreads) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes thread worker callbacks.
|
||||
*/
|
||||
class IThreadWorkerCallbacks
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Called when the worker thread is initialized.
|
||||
*
|
||||
* @param pWorker Pointer to the worker.
|
||||
*/
|
||||
virtual void OnWorkerStart(IThreadWorker *pWorker)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when the worker thread is cleaning up.
|
||||
*
|
||||
* @param pWorker Pointer to the worker.
|
||||
*/
|
||||
virtual void OnWorkerStop(IThreadWorker *pWorker)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes a threading system
|
||||
*/
|
||||
class IThreader : public SMInterface, public IThreadCreator
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_THREADER_NAME;
|
||||
}
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_THREADER_VERSION;
|
||||
}
|
||||
virtual bool IsVersionCompatible(unsigned int version)
|
||||
{
|
||||
if (version < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return SMInterface::IsVersionCompatible(version);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a mutex (mutual exclusion lock).
|
||||
*
|
||||
* @return A new IMutex pointer (must be destroyed).
|
||||
*/
|
||||
virtual IMutex *MakeMutex() =0;
|
||||
|
||||
/**
|
||||
* @brief Sleeps the calling thread for a number of milliseconds.
|
||||
*
|
||||
* @param ms Millisecond count to sleep.
|
||||
*/
|
||||
virtual void ThreadSleep(unsigned int ms) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a non-signalled event.
|
||||
*
|
||||
* @return A new IEventSignal pointer (must be destroyed).
|
||||
*/
|
||||
virtual IEventSignal *MakeEventSignal() =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a thread worker.
|
||||
*
|
||||
* @param hooks Optional pointer to callback interface.
|
||||
* @param threaded If true, the worker will be threaded.
|
||||
* If false, the worker will require manual frame execution.
|
||||
* @return A new IThreadWorker pointer (must be destroyed).
|
||||
*/
|
||||
virtual IThreadWorker *MakeWorker(IThreadWorkerCallbacks *hooks, bool threaded) =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys an IThreadWorker pointer.
|
||||
*
|
||||
* @param pWorker IThreadWorker pointer to destroy.
|
||||
*/
|
||||
virtual void DestroyWorker(IThreadWorker *pWorker) =0;
|
||||
};
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_THREADER_H
|
||||
@@ -0,0 +1,209 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_TIMER_SYSTEM_H_
|
||||
#define _INCLUDE_SOURCEMOD_TIMER_SYSTEM_H_
|
||||
|
||||
/**
|
||||
* @file ITimerSystem.h
|
||||
* @brief Contains functions for creating and managing timers.
|
||||
*/
|
||||
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IForwardSys.h>
|
||||
|
||||
#define SMINTERFACE_TIMERSYS_NAME "ITimerSys"
|
||||
#define SMINTERFACE_TIMERSYS_VERSION 3
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
class ITimer;
|
||||
|
||||
/**
|
||||
* @brief Interface for map timers.
|
||||
*/
|
||||
class IMapTimer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Returns the current map time limit in seconds.
|
||||
*
|
||||
* @return Time limit, in seconds, or
|
||||
* 0 if there is no limit.
|
||||
*/
|
||||
virtual int GetMapTimeLimit() =0;
|
||||
|
||||
/**
|
||||
* Extends the map limit (either positively or negatively) in seconds.
|
||||
*
|
||||
* @param extra_time Time to extend map by. If 0, the map will
|
||||
* be set to have no time limit.
|
||||
*/
|
||||
virtual void ExtendMapTimeLimit(int extra_time) =0;
|
||||
|
||||
/**
|
||||
* Tells the map timer whether it is being used or not.
|
||||
*
|
||||
* Map timers are automatically enabled when they are set, and
|
||||
* automatically disabled if being un-set.
|
||||
*
|
||||
* @param enabled True if enabling, false if disabling.
|
||||
*/
|
||||
virtual void SetMapTimerStatus(bool enabled) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Event callbacks for when a timer is executed.
|
||||
*/
|
||||
class ITimedEvent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Called when a timer is executed.
|
||||
*
|
||||
* @param pTimer Pointer to the timer instance.
|
||||
* @param pData Private pointer passed from host.
|
||||
* @return Pl_Stop to stop timer, Pl_Continue to continue.
|
||||
*/
|
||||
virtual ResultType OnTimer(ITimer *pTimer, void *pData) =0;
|
||||
|
||||
/**
|
||||
* @brief Called when the timer has been killed.
|
||||
*
|
||||
* @param pTimer Pointer to the timer instance.
|
||||
* @param pData Private data pointer passed from host.
|
||||
*/
|
||||
virtual void OnTimerEnd(ITimer *pTimer, void *pData) =0;
|
||||
};
|
||||
|
||||
#define TIMER_FLAG_REPEAT (1<<0) /**< Timer will repeat until stopped */
|
||||
#define TIMER_FLAG_NO_MAPCHANGE (1<<1) /**< Timer will not carry over mapchanges */
|
||||
|
||||
class ITimerSystem : public SMInterface
|
||||
{
|
||||
public:
|
||||
const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_TIMERSYS_NAME;
|
||||
}
|
||||
unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_TIMERSYS_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a timed event.
|
||||
*
|
||||
* @param pCallbacks Pointer to ITimedEvent callbacks.
|
||||
* @param fInterval Interval, in seconds, of the timed event to occur.
|
||||
* The smallest allowed interval is 0.1 seconds.
|
||||
* @param pData Private data to pass on to the timer.
|
||||
* @param flags Extra flags to pass on to the timer.
|
||||
* @return An ITimer pointer on success, NULL on
|
||||
* failure.
|
||||
*/
|
||||
virtual ITimer *CreateTimer(ITimedEvent *pCallbacks,
|
||||
float fInterval,
|
||||
void *pData,
|
||||
int flags) =0;
|
||||
|
||||
/**
|
||||
* @brief Kills a timer.
|
||||
*
|
||||
* @param pTimer Pointer to the ITimer structure.
|
||||
* @return
|
||||
*/
|
||||
virtual void KillTimer(ITimer *pTimer) =0;
|
||||
|
||||
/**
|
||||
* @brief Arbitrarily fires a timer. If the timer is not a repeating
|
||||
* timer, this will also kill the timer.
|
||||
*
|
||||
* @param pTimer Pointer to the ITimer structure.
|
||||
* @param delayExec If true, and the timer is repeating, the
|
||||
* next execution will be delayed by its
|
||||
* interval.
|
||||
* @return
|
||||
*/
|
||||
virtual void FireTimerOnce(ITimer *pTimer, bool delayExec=false) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the interface for dealing with map time limits.
|
||||
*
|
||||
* @param pMapTimer Map timer interface pointer.
|
||||
* @return Old pointer.
|
||||
*/
|
||||
virtual IMapTimer *SetMapTimer(IMapTimer *pTimer) =0;
|
||||
|
||||
/**
|
||||
* @brief Notification that the map's time left has changed
|
||||
* via a change in the time limit or a change in the game rules (
|
||||
* such as mp_restartgame).
|
||||
*/
|
||||
virtual void MapTimeLeftChanged() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the current universal tick time. This
|
||||
* replacement for gpGlobals->curtime and engine->Time() correctly
|
||||
* keeps track of ticks.
|
||||
*
|
||||
* During simulation, it is incremented by the difference between
|
||||
* gpGlobals->curtime and the last simulated tick. Otherwise,
|
||||
* it is incremented by the interval per tick.
|
||||
*
|
||||
* It is not reset past map changes.
|
||||
*
|
||||
* @return Universal ticked time.
|
||||
*/
|
||||
virtual float GetTickedTime() =0;
|
||||
|
||||
/**
|
||||
* @brief Notification that the "starting point" in the game has has
|
||||
* changed. This does not invoke MapTimeLeftChanged() automatically.
|
||||
*
|
||||
* @param offset Optional offset to add to the new time.
|
||||
*/
|
||||
virtual void NotifyOfGameStart(float offset = 0.0f) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the time left in the map.
|
||||
*
|
||||
* @param pTime Pointer to store time left, in seconds.
|
||||
* If there is no time limit, the number will
|
||||
* be below 0.
|
||||
* @return True on success, false if no support.
|
||||
*/
|
||||
virtual bool GetMapTimeLeft(float *pTime) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_TIMER_SYSTEM_H_
|
||||
@@ -0,0 +1,329 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_TRANSLATOR_INTERFACE_H_
|
||||
#define _INCLUDE_SOURCEMOD_TRANSLATOR_INTERFACE_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
|
||||
#define SMINTERFACE_TRANSLATOR_NAME "ITranslator"
|
||||
#define SMINTERFACE_TRANSLATOR_VERSION 1
|
||||
|
||||
/**
|
||||
* @file ITranslator.h
|
||||
* @brief Defines interfaces related to translation files.
|
||||
*/
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief SourceMod hardcodes the English language (default) to ID 0.
|
||||
* This cannot be changed and languages.cfg should never have it as anything
|
||||
* other than the first index.
|
||||
*/
|
||||
#define SOURCEMOD_LANGUAGE_ENGLISH 0
|
||||
|
||||
/**
|
||||
* @brief For %T formats, specifies that the language should be that of the
|
||||
* server and not a specific client.
|
||||
*/
|
||||
#define SOURCEMOD_SERVER_LANGUAGE 0
|
||||
|
||||
/**
|
||||
* @brief Translation error codes.
|
||||
*/
|
||||
enum TransError
|
||||
{
|
||||
Trans_Okay = 0, /**< Translation succeeded. */
|
||||
Trans_BadLanguage = 1, /**< Bad language ID. */
|
||||
Trans_BadPhrase = 2, /**< Phrase not found. */
|
||||
Trans_BadPhraseLanguage = 3, /**< Phrase not found in the given language. */
|
||||
Trans_BadPhraseFile = 4, /**< Phrase file was unreadable. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Contains information about a translation phrase.
|
||||
*/
|
||||
struct Translation
|
||||
{
|
||||
const char *szPhrase; /**< Translated phrase. */
|
||||
unsigned int fmt_count; /**< Number of format parameters. */
|
||||
int *fmt_order; /**< Array of size fmt_count where each
|
||||
element is the numerical order of
|
||||
parameter insertion, starting from
|
||||
0.
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Represents a phrase file from SourceMod's "translations" folder.
|
||||
*/
|
||||
class IPhraseFile
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Attempts to find a translation phrase in a phrase file.
|
||||
*
|
||||
* @param szPhrase String containing the phrase name.
|
||||
* @param lang_id Language ID.
|
||||
* @param pTrans Buffer to store translation info.
|
||||
* @return Translation error code indicating success
|
||||
* (pTrans is filled) or failure (pTrans
|
||||
* contents is undefined).
|
||||
*/
|
||||
virtual TransError GetTranslation(
|
||||
const char *szPhrase,
|
||||
unsigned int lang_id,
|
||||
Translation *pTrans) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the file name of this translation file.
|
||||
*
|
||||
* @return File name.
|
||||
*/
|
||||
virtual const char *GetFilename() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a collection of phrase files.
|
||||
*/
|
||||
class IPhraseCollection
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Adds a phrase file to the collection, using a cached one
|
||||
* if already found. The return value is provided for informational
|
||||
* purposes and does not need to be saved. The life time of the
|
||||
* return pointer is equal to the life time of the collection.
|
||||
*
|
||||
* This function will internally ignore dupliate additions but still
|
||||
* return a valid pointer.
|
||||
*
|
||||
* @param filename File name, without the ".txt" extension, of
|
||||
* the phrase file in the translations folder.
|
||||
* @return An IPhraseFile pointer, even if the file does
|
||||
* not exist.
|
||||
*/
|
||||
virtual IPhraseFile *AddPhraseFile(const char *filename) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of contained phrase files.
|
||||
*
|
||||
* @return Number of contained phrase files.
|
||||
*/
|
||||
virtual unsigned int GetFileCount() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the pointer to a contained phrase file.
|
||||
*
|
||||
* @param file File index, from 0 to GetFileCount()-1.
|
||||
* @return IPhraseFile pointer, or NULL if out of
|
||||
* range.
|
||||
*/
|
||||
virtual IPhraseFile *GetFile(unsigned int file) =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys the phrase collection, freeing all internal
|
||||
* resources and invalidating the object.
|
||||
*/
|
||||
virtual void Destroy() =0;
|
||||
|
||||
/**
|
||||
* @brief Attempts a translation across a given language. All
|
||||
* contained files are searched for an appropriate match; the
|
||||
* first valid match is returned.
|
||||
*
|
||||
* @param key String containing the phrase name.
|
||||
* @param langid Language ID to translate to.
|
||||
* @param pTrans Translation buffer.
|
||||
* @return Translation error code; on success,
|
||||
* pTrans is valid. On failure, the
|
||||
* contents of pTrans is undefined.
|
||||
*/
|
||||
virtual TransError FindTranslation(
|
||||
const char *key,
|
||||
unsigned int langid,
|
||||
Translation *pTrans) =0;
|
||||
|
||||
/**
|
||||
* @brief Formats a phrase given a parameter stack. The parameter
|
||||
* stack size must exactly match the expected parameter count. If
|
||||
* this count is too small or too large, the format fails.
|
||||
*
|
||||
* @param buffer Buffer to store formatted text.
|
||||
* @param maxlength Maximum length of the buffer.
|
||||
* @param format String containing format information.
|
||||
* This is equivalent to SourceMod's Format()
|
||||
* native, and sub-translations are acceptable.
|
||||
* @param params An array of pointers to each parameter.
|
||||
* Integer parameters must have a pointer to the integer.
|
||||
* Float parameters must have a pointer to a float.
|
||||
* String parameters must be a string pointer.
|
||||
* Char parameters must be a pointer to a char.
|
||||
* Translation parameters fill multiple indexes in the
|
||||
* array. For %T translations, the expected stack is:
|
||||
* [phrase string pointer] [int target id pointer] [...]
|
||||
* Where [...] is the required parameters for the translation,
|
||||
* in the order expected by the phrase, not the phrase's
|
||||
* translation. For example, say the format is:
|
||||
* "%d %T" and the phrase's format is {1:s,2:f}, then the
|
||||
* parameter stack should be:
|
||||
* int *, const char *, int *, const char *, float *
|
||||
* The %t modifier is the same except the target id pointer
|
||||
* would be removed:
|
||||
* int *, const char *, const char *, float *
|
||||
* @param numparams Number of parameters in the params array.
|
||||
* @param pOutLength Optional pointer filled with output length on success.
|
||||
* @param pFailPhrase Optional pointer; on failure, is filled with NULL if the
|
||||
* failure was not due to a failed translation phrase.
|
||||
* Otherwise, it is filled with the given phrase name pointer
|
||||
* from the parameter stack. Undefined on success.
|
||||
* @return True on success. False if the parameter stack was not
|
||||
* exactly the right length, or if a translation phrase
|
||||
* could not be found.
|
||||
*/
|
||||
virtual bool FormatString(
|
||||
char *buffer,
|
||||
size_t maxlength,
|
||||
const char *format,
|
||||
void **params,
|
||||
unsigned int numparams,
|
||||
size_t *pOutLength,
|
||||
const char **pFailPhrase) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Provides functions for translation.
|
||||
*/
|
||||
class ITranslator : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName() =0;
|
||||
virtual unsigned int GetInterfaceVersion() =0;
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a new phrase collection object.
|
||||
*
|
||||
* @return A new phrase collection object, which must be
|
||||
* destroyed via IPhraseCollection::Destroy() when
|
||||
* no longer needed.
|
||||
*/
|
||||
virtual IPhraseCollection *CreatePhraseCollection() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the server language.
|
||||
*
|
||||
* @return Server language index.
|
||||
*/
|
||||
virtual unsigned int GetServerLanguage() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a client's language.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @return Client language index, or server's if client's is
|
||||
* not known.
|
||||
*/
|
||||
virtual unsigned int GetClientLanguage(int client) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets the global client SourceMod will use for assisted
|
||||
* translations (that is, %t).
|
||||
*
|
||||
* @param index Client index (0 for server).
|
||||
* @return Old global client value.
|
||||
*/
|
||||
virtual int SetGlobalTarget(int index) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the global client SourceMod is currently using
|
||||
* for assisted translations (that is, %t).
|
||||
*
|
||||
* @return Global client index (0 for server).
|
||||
*/
|
||||
virtual int GetGlobalTarget() const =0;
|
||||
|
||||
/**
|
||||
* @brief Formats a phrase given a parameter stack. The parameter
|
||||
* stack size must exactly match the expected parameter count. If
|
||||
* this count is too small or too large, the format fails.
|
||||
*
|
||||
* Note: This is the same as IPhraseCollection::FormatString(), except
|
||||
* that the IPhraseCollection parameter is explicit instead of implicit.
|
||||
*
|
||||
* @param buffer Buffer to store formatted text.
|
||||
* @param maxlength Maximum length of the buffer.
|
||||
* @param format String containing format information.
|
||||
* This is equivalent to SourceMod's Format()
|
||||
* native, and sub-translations are acceptable.
|
||||
* @param pPhrases Optional phrase collection pointer to search for
|
||||
* phrases.
|
||||
* @param params An array of pointers to each parameter.
|
||||
* Integer parameters must have a pointer to the integer.
|
||||
* Float parameters must have a pointer to a float.
|
||||
* String parameters must be a string pointer.
|
||||
* Char parameters must be a pointer to a char.
|
||||
* Translation parameters fill multiple indexes in the
|
||||
* array. For %T translations, the expected stack is:
|
||||
* [phrase string pointer] [int target id pointer] [...]
|
||||
* Where [...] is the required parameters for the translation,
|
||||
* in the order expected by the phrase, not the phrase's
|
||||
* translation. For example, say the format is:
|
||||
* "%d %T" and the phrase's format is {1:s,2:f}, then the
|
||||
* parameter stack should be:
|
||||
* int *, const char *, int *, const char *, float *
|
||||
* The %t modifier is the same except the target id pointer
|
||||
* would be removed:
|
||||
* int *, const char *, const char *, float *
|
||||
* @param numparams Number of parameters in the params array.
|
||||
* @param pOutLength Optional pointer filled with output length on success.
|
||||
* @param pFailPhrase Optional pointer; on failure, is filled with NULL if the
|
||||
* failure was not due to a failed translation phrase.
|
||||
* Otherwise, it is filled with the given phrase name pointer
|
||||
* from the parameter stack. Undefined on success.
|
||||
* @return True on success. False if the parameter stack was not
|
||||
* exactly the right length, or if a translation phrase
|
||||
* could not be found.
|
||||
*/
|
||||
virtual bool FormatString(
|
||||
char *buffer,
|
||||
size_t maxlength,
|
||||
const char *format,
|
||||
IPhraseCollection *pPhrases,
|
||||
void **params,
|
||||
unsigned int numparams,
|
||||
size_t *pOutLength,
|
||||
const char **pFailPhrase) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_TRANSLATOR_INTERFACE_H_
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_INTERFACE_USERMESSAGES_H_
|
||||
#define _INCLUDE_SOURCEMOD_INTERFACE_USERMESSAGES_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <sp_vm_api.h>
|
||||
#include <IForwardSys.h>
|
||||
#include <bitbuf.h>
|
||||
#include <irecipientfilter.h>
|
||||
|
||||
/**
|
||||
* @file IUserMessages.h
|
||||
* @brief Contains functions for advanced usermessage hooking.
|
||||
*/
|
||||
|
||||
#define SMINTERFACE_USERMSGS_NAME "IUserMessages"
|
||||
#define SMINTERFACE_USERMSGS_VERSION 1
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Listens to user messages sent from the server.
|
||||
*/
|
||||
class IUserMessageListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Called when a hooked user message is being sent
|
||||
* and all interceptions have finished.
|
||||
*
|
||||
* @param msg_id Message Id.
|
||||
* @param bf bf_write structure containing written bytes.
|
||||
* @param pFilter Recipient filter.
|
||||
*/
|
||||
virtual void OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a hooked user message is intercepted.
|
||||
*
|
||||
* @param msg_id Message Id.
|
||||
* @param bf bf_write structure containing written bytes.
|
||||
* @param pFilter Recipient filter.
|
||||
* @return Pl_Continue to allow message, Pl_Stop or Pl_Handled to scrap it.
|
||||
*/
|
||||
virtual ResultType InterceptUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
|
||||
{
|
||||
return Pl_Continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a hooked user message is sent, regardless of the hook type.
|
||||
* @param msg_id Message Id.
|
||||
*/
|
||||
virtual void OnUserMessageSent(int msg_id)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#define USERMSG_RELIABLE (1<<2) /**< Message will be set to reliable */
|
||||
#define USERMSG_INITMSG (1<<3) /**< Message will be considered to be an initmsg */
|
||||
#define USERMSG_BLOCKHOOKS (1<<7) /**< Prevents the message from triggering SourceMod and Metamod hooks */
|
||||
|
||||
/**
|
||||
* @brief Contains functions for hooking user messages.
|
||||
*/
|
||||
class IUserMessages : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_USERMSGS_VERSION;
|
||||
}
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_USERMSGS_NAME;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Finds a message id by name.
|
||||
*
|
||||
* @param msg Case-sensitive string containing the message.
|
||||
* @return A message index, or -1 on failure.
|
||||
*/
|
||||
virtual int GetMessageIndex(const char *msg) =0;
|
||||
|
||||
/**
|
||||
* @brief Sets a hook on a user message.
|
||||
*
|
||||
* @param msg_id Message Id.
|
||||
* @param pListener Pointer to an IUserMessageListener.
|
||||
* @param intercept If true, message will be intercepted rather than merely hooked.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool HookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false) =0;
|
||||
|
||||
/**
|
||||
* @brief Unhooks a user message.
|
||||
*
|
||||
* @param msg_id Message Id.
|
||||
* @param pListener Pointer to an IUserMessageListener.
|
||||
* @param intercept If true, removed message will from interception pool rather than normal hook pool.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool UnhookUserMessage(int msg_id, IUserMessageListener *pListener, bool intercept=false) =0;
|
||||
|
||||
/**
|
||||
* @brief Wrapper around UserMessageBegin for more options.
|
||||
*
|
||||
* @param msg_id Message Id.
|
||||
* @param players Array containing player indexes.
|
||||
* @param playersNum Number of players in the array.
|
||||
* @param flags Flags to use for sending the message.
|
||||
* @return bf_write structure to write message with, or NULL on failure.
|
||||
*/
|
||||
virtual bf_write *StartMessage(int msg_id, const cell_t players[], unsigned int playersNum, int flags) =0;
|
||||
|
||||
/**
|
||||
* @brief Wrapper around UserMessageEnd for use with StartMessage().
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
virtual bool EndMessage() =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_INTERFACE_USERMESSAGES_H_
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_
|
||||
#define _INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_
|
||||
|
||||
#if defined ORANGEBOX_BUILD
|
||||
#define CONVAR_REGISTER(object) ConVar_Register(0, object)
|
||||
|
||||
inline bool IsFlagSet(ConCommandBase *cmd, int flag)
|
||||
{
|
||||
return cmd->IsFlagSet(flag);
|
||||
}
|
||||
inline void InsertServerCommand(const char *buf)
|
||||
{
|
||||
engine->InsertServerCommand(buf);
|
||||
}
|
||||
#else
|
||||
class CCommand
|
||||
{
|
||||
public:
|
||||
inline const char *ArgS() const
|
||||
{
|
||||
return engine->Cmd_Args();
|
||||
}
|
||||
inline int ArgC() const
|
||||
{
|
||||
return engine->Cmd_Argc();
|
||||
}
|
||||
inline const char *Arg(int index) const
|
||||
{
|
||||
return engine->Cmd_Argv(index);
|
||||
}
|
||||
};
|
||||
|
||||
inline bool IsFlagSet(ConCommandBase *cmd, int flag)
|
||||
{
|
||||
return cmd->IsBitSet(flag);
|
||||
}
|
||||
inline void InsertServerCommand(const char *buf)
|
||||
{
|
||||
engine->InsertServerCommand(buf);
|
||||
}
|
||||
|
||||
#define CVAR_INTERFACE_VERSION VENGINE_CVAR_INTERFACE_VERSION
|
||||
|
||||
#define CONVAR_REGISTER(object) ConCommandBaseMgr::OneTimeInit(object)
|
||||
typedef FnChangeCallback FnChangeCallback_t;
|
||||
#endif //ORANGEBOX_BUILD
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_COMPAT_WRAPPERS_H_
|
||||
@@ -0,0 +1,262 @@
|
||||
# Doxyfile 1.5.1-p1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = "SourceMod SDK"
|
||||
PROJECT_NUMBER = 376
|
||||
OUTPUT_DIRECTORY = c:\temp\sm-dox
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = YES
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH = r:\sourcemod\
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 10
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
HIDE_UNDOC_MEMBERS = YES
|
||||
HIDE_UNDOC_CLASSES = YES
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = NO
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = r:\sourcemod\trunk\public
|
||||
FILE_PATTERNS = *.c \
|
||||
*.cc \
|
||||
*.cxx \
|
||||
*.cpp \
|
||||
*.c++ \
|
||||
*.d \
|
||||
*.java \
|
||||
*.ii \
|
||||
*.ixx \
|
||||
*.ipp \
|
||||
*.i++ \
|
||||
*.inl \
|
||||
*.h \
|
||||
*.hh \
|
||||
*.hxx \
|
||||
*.hpp \
|
||||
*.h++ \
|
||||
*.idl \
|
||||
*.odl \
|
||||
*.cs \
|
||||
*.php \
|
||||
*.php3 \
|
||||
*.inc \
|
||||
*.m \
|
||||
*.mm \
|
||||
*.dox \
|
||||
*.py
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = NO
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = YES
|
||||
CHM_FILE = SourceMod-SDK.chm
|
||||
HHC_LOCATION = C:/temp/sm-dox/html/index.hhc
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = YES
|
||||
TOC_EXPAND = YES
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = YES
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = SOURCEMOD_BUILD \
|
||||
SMEXT_CONF_METAMOD
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = NO
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = YES
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH = "C:/Program Files/ATT/Graphviz/bin"
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = YES
|
||||
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod BinTools Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SMEXT_BINTOOLS_H_
|
||||
#define _INCLUDE_SMEXT_BINTOOLS_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
|
||||
#define SMINTERFACE_BINTOOLS_NAME "IBinTools"
|
||||
#define SMINTERFACE_BINTOOLS_VERSION 2
|
||||
|
||||
/**
|
||||
* @brief Function calling encoding utilities
|
||||
* @file IBinTools.h
|
||||
*/
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Supported calling conventions
|
||||
*/
|
||||
enum CallConvention
|
||||
{
|
||||
CallConv_ThisCall, /**< This call (object pointer required) */
|
||||
CallConv_Cdecl, /**< Standard C call */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Describes how a parameter should be passed
|
||||
*/
|
||||
enum PassType
|
||||
{
|
||||
PassType_Basic, /**< Plain old register data (pointers, integers) */
|
||||
PassType_Float, /**< Floating point data */
|
||||
PassType_Object, /**< Object or structure */
|
||||
};
|
||||
|
||||
#define PASSFLAG_BYVAL (1<<0) /**< Passing by value */
|
||||
#define PASSFLAG_BYREF (1<<1) /**< Passing by reference */
|
||||
#define PASSFLAG_ODTOR (1<<2) /**< Object has a destructor */
|
||||
#define PASSFLAG_OCTOR (1<<3) /**< Object has a constructor */
|
||||
#define PASSFLAG_OASSIGNOP (1<<4) /**< Object has an assignment operator */
|
||||
|
||||
/**
|
||||
* @brief Parameter passing information
|
||||
*/
|
||||
struct PassInfo
|
||||
{
|
||||
PassType type; /**< PassType value */
|
||||
unsigned int flags; /**< Pass/return flags */
|
||||
size_t size; /**< Size of the data being passed */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Parameter encoding information
|
||||
*/
|
||||
struct PassEncode
|
||||
{
|
||||
PassInfo info; /**< Parameter information */
|
||||
size_t offset; /**< Offset into the virtual stack */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Wraps a C/C++ call.
|
||||
*/
|
||||
class ICallWrapper
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Returns the calling convention.
|
||||
*
|
||||
* @return CallConvention value.
|
||||
*/
|
||||
virtual CallConvention GetCallConvention() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns parameter info.
|
||||
*
|
||||
* @param num Parameter number to get (starting from 0).
|
||||
* @return A PassInfo pointer.
|
||||
*/
|
||||
virtual const PassEncode *GetParamInfo(unsigned int num) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns return type info.
|
||||
*
|
||||
* @return A PassInfo pointer.
|
||||
*/
|
||||
virtual const PassInfo *GetReturnInfo() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of parameters.
|
||||
*
|
||||
* @return Number of parameters.
|
||||
*/
|
||||
virtual unsigned int GetParamCount() =0;
|
||||
|
||||
/**
|
||||
* @brief Execute the contained function.
|
||||
*
|
||||
* @param vParamStack A blob of memory containing stack data.
|
||||
* @param retBuffer Buffer to store return value.
|
||||
*/
|
||||
virtual void Execute(void *vParamStack, void *retBuffer) =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys all resources used by this object.
|
||||
*/
|
||||
virtual void Destroy() =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Binary tools interface.
|
||||
*/
|
||||
class IBinTools : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName()
|
||||
{
|
||||
return SMINTERFACE_BINTOOLS_NAME;
|
||||
}
|
||||
virtual unsigned int GetInterfaceVersion()
|
||||
{
|
||||
return SMINTERFACE_BINTOOLS_VERSION;
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a call decoder.
|
||||
*
|
||||
* Note: CallConv_ThisCall requires an implicit first parameter
|
||||
* of PassType_Basic / PASSFLAG_BYVAL / sizeof(void *). However,
|
||||
* this should only be given to the Execute() function, and never
|
||||
* listed in the paramInfo array.
|
||||
*
|
||||
* @param address Address to use as a call.
|
||||
* @param cv Calling convention.
|
||||
* @param retInfo Return type information, or NULL for void.
|
||||
* @param paramInfo Array of parameters.
|
||||
* @param numParams Number of parameters in the array.
|
||||
* @return A new ICallWrapper function.
|
||||
*/
|
||||
virtual ICallWrapper *CreateCall(void *address,
|
||||
CallConvention cv,
|
||||
const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[],
|
||||
unsigned int numParams) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates a vtable call decoder.
|
||||
*
|
||||
* Note: CallConv_ThisCall requires an implicit first parameter
|
||||
* of PassType_Basic / PASSFLAG_BYVAL / sizeof(void *). However,
|
||||
* this should only be given to the Execute() function, and never
|
||||
* listed in the paramInfo array.
|
||||
*
|
||||
* @param vtblIdx Index into the virtual table.
|
||||
* @param vtblOffs Offset of the virtual table.
|
||||
* @param thisOffs Offset of the this pointer of the virtual table.
|
||||
* @param retInfo Return type information, or NULL for void.
|
||||
* @param paramInfo Array of parameters.
|
||||
* @param numParams Number of parameters in the array.
|
||||
* @return A new ICallWrapper function.
|
||||
*/
|
||||
virtual ICallWrapper *CreateVCall(unsigned int vtblIdx,
|
||||
unsigned int vtblOffs,
|
||||
unsigned int thisOffs,
|
||||
const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[],
|
||||
unsigned int numParams) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SMEXT_BINTOOLS_H_
|
||||
@@ -0,0 +1,317 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_MAIN_MENU_INTERFACE_H_
|
||||
#define _INCLUDE_SOURCEMOD_MAIN_MENU_INTERFACE_H_
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <ILibrarySys.h>
|
||||
#include <IAdminSystem.h>
|
||||
#include <IMenuManager.h>
|
||||
|
||||
/**
|
||||
* @file ITopMenus.h
|
||||
* @brief Interface header for creating and managing top-level menus.
|
||||
*/
|
||||
|
||||
#define SMINTERFACE_TOPMENUS_NAME "ITopMenus"
|
||||
#define SMINTERFACE_TOPMENUS_VERSION 4
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
/**
|
||||
* @brief Top menu object types.
|
||||
*/
|
||||
enum TopMenuObjectType
|
||||
{
|
||||
TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */
|
||||
TopMenuObject_Item = 1 /**< Item on a sub-menu */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Top menu starting positions for display.
|
||||
*/
|
||||
enum TopMenuPosition
|
||||
{
|
||||
TopMenuPosition_Start = 0, /**< Start/root of the menu */
|
||||
TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */
|
||||
TopMenuPosition_LastCategory = 3, /**< Last position in their last category */
|
||||
};
|
||||
|
||||
class ITopMenu;
|
||||
|
||||
/**
|
||||
* @brief Top Menu callbacks for rendering/drawing.
|
||||
*/
|
||||
class ITopMenuObjectCallbacks
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Must return the topmenu API version.
|
||||
*
|
||||
* @return Top Menu API version.
|
||||
*/
|
||||
virtual unsigned int GetTopMenuAPIVersion1()
|
||||
{
|
||||
return SMINTERFACE_TOPMENUS_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Requests how the given item should be drawn for a client.
|
||||
*
|
||||
* Unlike the other callbacks, this is only called in determining
|
||||
* whether to enable, disable, or ignore an item on a client's menu.
|
||||
*
|
||||
* @param menu A pointer to the parent ITopMenu.
|
||||
* @param client Client index.
|
||||
* @param object_id Object ID returned from ITopMenu::AddToMenu().
|
||||
* @return ITEMDRAW flags to disable or not draw the
|
||||
* option for this operation.
|
||||
*/
|
||||
virtual unsigned int OnTopMenuDrawOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id)
|
||||
{
|
||||
return ITEMDRAW_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Requests how the given item should be displayed for a client.
|
||||
*
|
||||
* This can be called either while drawing a menu or to decide how to
|
||||
* sort a menu for a player.
|
||||
*
|
||||
* @param menu A pointer to the parent ITopMenu.
|
||||
* @param client Client index.
|
||||
* @param object_id Object ID returned from ITopMenu::AddToMenu().
|
||||
* @param buffer Buffer to store rendered text.
|
||||
* @param maxlength Maximum length of the rendering buffer.
|
||||
*/
|
||||
virtual void OnTopMenuDisplayOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id,
|
||||
char buffer[],
|
||||
size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Requests how the given item's title should be displayed for
|
||||
* a client. This is called on any object_id that is a category.
|
||||
*
|
||||
* @param menu A pointer to the parent ITopMenu.
|
||||
* @param client Client index.
|
||||
* @param object_id Object ID returned from ITopMenu::AddToMenu(),
|
||||
* or 0 if the title is the root menu title.
|
||||
* @param buffer Buffer to store rendered text.
|
||||
* @param maxlength Maximum length of the rendering buffer.
|
||||
*/
|
||||
virtual void OnTopMenuDisplayTitle(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id,
|
||||
char buffer[],
|
||||
size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Notifies the listener that the menu option has been selected.
|
||||
*
|
||||
* @param menu A pointer to the parent ITopMenu.
|
||||
* @param client Client index.
|
||||
* @param object_id Object ID returned from ITopMenu::AddToMenu().
|
||||
*/
|
||||
virtual void OnTopMenuSelectOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id) =0;
|
||||
|
||||
/**
|
||||
* @brief Notified when the given item is removed.
|
||||
*
|
||||
* @param menu A pointer to the parent ITopMenu.
|
||||
* @param object_id Object ID returned from ITopMenu::AddToMenu(),
|
||||
* or 0 if the title callbacks are being removed.
|
||||
*/
|
||||
virtual void OnTopMenuObjectRemoved(ITopMenu *menu, unsigned int object_id) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief "Top menu" interface, for managing top-level categorized menus.
|
||||
*/
|
||||
class ITopMenu
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Creates and adds an object type type to the top menu.
|
||||
*
|
||||
* @param name Unique, string name to give the object.
|
||||
* @param type Object type.
|
||||
* @param callbacks ITopMenuObjectCallbacks pointer.
|
||||
* @param owner IdentityToken_t owner of the object.
|
||||
* @param cmdname Command name used for override access checks.
|
||||
* If NULL or empty, access will not be Checked.
|
||||
* @param flags Default flag(s) to use for access checks.
|
||||
* @param parent Parent object, or 0 if none.
|
||||
* Currently, categories cannot have a parent,
|
||||
* and items must have a category parent.
|
||||
* @return An object ID, or 0 on failure.
|
||||
*/
|
||||
virtual unsigned int AddToMenu(const char *name,
|
||||
TopMenuObjectType type,
|
||||
ITopMenuObjectCallbacks *callbacks,
|
||||
IdentityToken_t *owner,
|
||||
const char *cmdname,
|
||||
FlagBits flags,
|
||||
unsigned int parent) =0;
|
||||
|
||||
/**
|
||||
* @brief Removes an object from a menu. If the object has any
|
||||
* children, those will be removed.
|
||||
*
|
||||
* @param object_id Object ID returned from AddToMenu.
|
||||
*/
|
||||
virtual void RemoveFromMenu(unsigned int object_id) =0;
|
||||
|
||||
/**
|
||||
* @brief Sends the main menu to a given client.
|
||||
*
|
||||
* Once the menu is drawn to a client, the drawing order is cached.
|
||||
* If text on the menu is rendered differently for the client's next
|
||||
* viewing, the text will render properly, but its order will not
|
||||
* change. The menu is sorted by its configuration. Remaining items
|
||||
* are sorted in alphabetical order using the initial display text.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param hold_time Time to hold the menu on the screen for.
|
||||
* @param position TopMenuPosition enumeration value.
|
||||
* @return True on success, false if nothing displayed.
|
||||
*/
|
||||
virtual bool DisplayMenu(int client, unsigned int hold_time, TopMenuPosition position) =0;
|
||||
|
||||
/**
|
||||
* @brief Loads a configuration file for organizing the menu. This
|
||||
* forces all known categories to be re-sorted.
|
||||
*
|
||||
* Only one configuration can be active at a time. Loading a new one
|
||||
* will cause the old sorting to disappear.
|
||||
*
|
||||
* @param file File path.
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum length of the error buffer.
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool LoadConfiguration(const char *file, char *error, size_t maxlength) =0;
|
||||
|
||||
/**
|
||||
* @brief Finds a category's ID by name.
|
||||
*
|
||||
* @param name Category's name.
|
||||
* @return Object ID of the category, or 0 if none.
|
||||
*/
|
||||
virtual unsigned int FindCategory(const char *name) =0;
|
||||
|
||||
/**
|
||||
* @brief Creates and adds an object type type to the top menu.
|
||||
*
|
||||
* @param name Unique, string name to give the object.
|
||||
* @param type Object type.
|
||||
* @param callbacks ITopMenuObjectCallbacks pointer.
|
||||
* @param owner IdentityToken_t owner of the object.
|
||||
* @param cmdname Command name used for override access checks.
|
||||
* If NULL or empty, access will not be Checked.
|
||||
* @param flags Default flag(s) to use for access checks.
|
||||
* @param parent Parent object, or 0 if none.
|
||||
* Currently, categories cannot have a parent,
|
||||
* and items must have a category parent.
|
||||
* @param info_string Optional info string to attach to the object.
|
||||
* Only 255 bytes of the string (including null
|
||||
* terminator) will be stored.
|
||||
* @return An object ID, or 0 on failure.
|
||||
*/
|
||||
virtual unsigned int AddToMenu2(const char *name,
|
||||
TopMenuObjectType type,
|
||||
ITopMenuObjectCallbacks *callbacks,
|
||||
IdentityToken_t *owner,
|
||||
const char *cmdname,
|
||||
FlagBits flags,
|
||||
unsigned int parent,
|
||||
const char *info_string) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns an object's info string.
|
||||
*
|
||||
* @param object_id Object ID.
|
||||
* @return Object's info string, or NULL if none.
|
||||
*/
|
||||
virtual const char *GetObjectInfoString(unsigned int object_id) =0;
|
||||
|
||||
/**
|
||||
* @brief Returns an object's name string.
|
||||
*
|
||||
* @param object_id Object ID.
|
||||
* @return Object's name string, or NULL if none.
|
||||
*/
|
||||
virtual const char *GetObjectName(unsigned int object_id) =0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Top menu manager.
|
||||
*/
|
||||
class ITopMenuManager : public SMInterface
|
||||
{
|
||||
public:
|
||||
virtual const char *GetInterfaceName() =0;
|
||||
virtual unsigned int GetInterfaceVersion() =0;
|
||||
virtual bool IsVersionCompatible(unsigned int version)
|
||||
{
|
||||
if (version < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return SMInterface::IsVersionCompatible(version);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Creates a new top-level menu.
|
||||
*
|
||||
* @param callbacks Callbacks for the title text.
|
||||
* The object_id for the title will always be 0.
|
||||
* @return A new ITopMenu pointer.
|
||||
*/
|
||||
virtual ITopMenu *CreateTopMenu(ITopMenuObjectCallbacks *callbacks) =0;
|
||||
|
||||
/**
|
||||
* @brief Destroys a top-level menu.
|
||||
*
|
||||
* @param topmenu Pointer to an ITopMenu.
|
||||
*/
|
||||
virtual void DestroyTopMenu(ITopMenu *topmenu) =0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_MAIN_MENU_INTERFACE_H_
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourcePawn JIT SDK
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEPAWN_JIT_HELPERS_H_
|
||||
#define _INCLUDE_SOURCEPAWN_JIT_HELPERS_H_
|
||||
|
||||
#include <sp_vm_types.h>
|
||||
#include <sp_vm_api.h>
|
||||
|
||||
#if defined HAVE_STDINT_H && !defined WIN32
|
||||
#include <stdint.h>
|
||||
typedef int8_t jit_int8_t;
|
||||
typedef uint8_t jit_uint8_t;
|
||||
typedef int32_t jit_int32_t;
|
||||
typedef uint32_t jit_uint32_t;
|
||||
typedef int64_t jit_int64_t;
|
||||
typedef uint64_t jit_uint64_t;
|
||||
#elif defined WIN32
|
||||
typedef __int8 jit_int8_t;
|
||||
typedef unsigned __int8 jit_uint8_t;
|
||||
typedef __int32 jit_int32_t;
|
||||
typedef unsigned __int32 jit_uint32_t;
|
||||
typedef __int64 jit_int64_t;
|
||||
typedef unsigned __int64 jit_uint64_t;
|
||||
#endif
|
||||
|
||||
typedef char * jitcode_t;
|
||||
typedef unsigned int jitoffs_t;
|
||||
typedef signed int jitrel_t;
|
||||
|
||||
class JitWriter
|
||||
{
|
||||
public:
|
||||
inline cell_t read_cell()
|
||||
{
|
||||
cell_t val = *(inptr);
|
||||
inptr++;
|
||||
return val;
|
||||
}
|
||||
inline cell_t *read_cellptr()
|
||||
{
|
||||
cell_t *val = *(cell_t **)(inptr);
|
||||
inptr++;
|
||||
return val;
|
||||
}
|
||||
inline void write_ubyte(jit_uint8_t c)
|
||||
{
|
||||
if (outbase)
|
||||
{
|
||||
*outptr = c;
|
||||
}
|
||||
outptr++;
|
||||
}
|
||||
inline void write_ushort(unsigned short c)
|
||||
{
|
||||
if (outbase)
|
||||
{
|
||||
*(unsigned short *)outptr = c;
|
||||
}
|
||||
outptr += sizeof(unsigned short);
|
||||
}
|
||||
inline void write_byte(jit_int8_t c)
|
||||
{
|
||||
if (outbase)
|
||||
{
|
||||
*outptr = c;
|
||||
}
|
||||
outptr++;
|
||||
}
|
||||
inline void write_int32(jit_int32_t c)
|
||||
{
|
||||
if (outbase)
|
||||
{
|
||||
*(jit_int32_t *)outptr = c;
|
||||
}
|
||||
outptr += sizeof(jit_int32_t);
|
||||
}
|
||||
inline void write_uint32(jit_uint32_t c)
|
||||
{
|
||||
if (outbase)
|
||||
{
|
||||
*(jit_uint32_t *)outptr = c;
|
||||
}
|
||||
outptr += sizeof(jit_uint32_t);
|
||||
}
|
||||
inline jitoffs_t get_outputpos()
|
||||
{
|
||||
return (outptr - outbase);
|
||||
}
|
||||
inline void set_outputpos(jitoffs_t offs)
|
||||
{
|
||||
outptr = outbase + offs;
|
||||
}
|
||||
inline jitoffs_t get_inputpos()
|
||||
{
|
||||
return (jitoffs_t)((char *)inptr - (char *)inbase);
|
||||
}
|
||||
public:
|
||||
cell_t *inptr; /* input pointer */
|
||||
cell_t *inbase; /* input base */
|
||||
jitcode_t outbase; /* output pointer */
|
||||
jitcode_t outptr; /* output base */
|
||||
SourcePawn::ICompilation *data; /* compiler live info */
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_SOURCEPAWN_JIT_HELPERS_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,39 @@
|
||||
SOURCEMOD LICENSE INFORMATION
|
||||
VERSION: JUNE-13-2008
|
||||
-----------------------------
|
||||
|
||||
SourceMod is licensed under the GNU General Public License, version 3.
|
||||
|
||||
As a special exception, AlliedModders LLC gives you permission to link the code
|
||||
of this program (as well as its derivative works) to "Half-Life 2," the "Source
|
||||
Engine," the "SourcePawn JIT," and any Game MODs that run on software by the
|
||||
Valve Corporation. You must obey the GNU General Public License in all
|
||||
respects for all other code used. Additionally, AlliedModders LLC grants this
|
||||
exception to all derivative works.
|
||||
|
||||
As an additional special exception to the GNU General Public License 3.0,
|
||||
AlliedModders LLC permits dual-licensing of DERIVATIVE WORKS ONLY (that is,
|
||||
SourcePawn/SourceMod Plugins and SourceMod Extensions, or any software built
|
||||
from the SourceMod SDK or header files) under the GNU General Public License
|
||||
version 2 "or any higher version." As such, you may choose for your derivative
|
||||
work(s) to be compatible with the GNU General Public License version 2 as long
|
||||
as it is also compatible with the GNU General Public License version 3, via the
|
||||
"or any higher version" clause. This is intended for compatibility with other
|
||||
software.
|
||||
|
||||
As a final exception to the above, any derivative works created prior to this
|
||||
date (July 31, 2007) may be exclusively licensed under the GNU General Public
|
||||
License version 2 (without an "or any higher version" clause) if and only if
|
||||
the work was already GNU General Public License 2.0 exclusive. This clause is
|
||||
provided for backwards compatibility only.
|
||||
|
||||
A copy of the JIT License is available in JIT.txt.
|
||||
A copy of the GNU General Public License 2.0 is available in GPLv2.txt.
|
||||
A copy of the GNU General Public License 3.0 is available in GPLv3.txt.
|
||||
|
||||
SourcePawn is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
|
||||
SourceMod is Copyright (C) 2006-2008 AlliedModders LLC. All rights reserved.
|
||||
Pawn and SMALL are Copyright (C) 1997-2008 ITB CompuPhase.
|
||||
Source is Copyright (C) Valve Corporation.
|
||||
All trademarks are property of their respective owners in the US and other
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_METAMOD_WRAPPERS_H_
|
||||
#define _INCLUDE_METAMOD_WRAPPERS_H_
|
||||
|
||||
/* Get iface wrappers */
|
||||
#define GetEngineFactory engineFactory
|
||||
#define GetServerFactory serverFactory
|
||||
#define GetPhysicsFactory physicsFactory
|
||||
#define GetFileSystemFactory fileSystemFactory
|
||||
|
||||
#define GetCGlobals pGlobals
|
||||
|
||||
#define UnregisterConCommandBase UnregisterConCmdBase
|
||||
|
||||
/* Valve interface wrappers */
|
||||
#define CVAR_INTERFACE_VERSION VENGINE_CVAR_INTERFACE_VERSION
|
||||
|
||||
#define METAMOD_PLAPI_NAME PLAPI_NAME
|
||||
|
||||
#endif //_INCLUDE_METAMOD_WRAPPERS_H_
|
||||
@@ -0,0 +1,108 @@
|
||||
# (C)2004-2008 SourceMod Development Team
|
||||
# Makefile written by David "BAILOPAN" Anderson
|
||||
|
||||
SMSDK = ..
|
||||
SRCDS_BASE = ~/srcds
|
||||
HL2SDK_ORIG = ../../../hl2sdk
|
||||
HL2SDK_OB = ../../../hl2sdk-ob
|
||||
SOURCEMM14 = ../../../sourcemm-1.4
|
||||
SOURCEMM16 = ../../../sourcemm-1.6
|
||||
|
||||
#####################################
|
||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||
#####################################
|
||||
|
||||
PROJECT = stub_mm
|
||||
|
||||
OBJECTS = stub_mm.cpp sm_ext.cpp sm_sdk_config.cpp stub_util.cpp
|
||||
|
||||
##############################################
|
||||
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
||||
##############################################
|
||||
|
||||
C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
|
||||
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
|
||||
C_GCC4_FLAGS = -fvisibility=hidden
|
||||
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
|
||||
CPP = gcc-4.1
|
||||
|
||||
override ENGSET = false
|
||||
ifeq "$(ENGINE)" "original"
|
||||
HL2SDK = $(HL2SDK_ORIG)
|
||||
HL2PUB = $(HL2SDK_ORIG)/public
|
||||
HL2LIB = $(HL2SDK_ORIG)/linux_sdk
|
||||
METAMOD = $(SOURCEMM14)
|
||||
INCLUDE += -I$(HL2SDK)/public/dlls
|
||||
SRCDS = $(SRCDS_BASE)
|
||||
override ENGSET = true
|
||||
endif
|
||||
ifeq "$(ENGINE)" "orangebox"
|
||||
HL2SDK = $(HL2SDK_OB)
|
||||
HL2PUB = $(HL2SDK_OB)/public
|
||||
HL2LIB = $(HL2SDK_OB)/linux_sdk
|
||||
CFLAGS += -DORANGEBOX_BUILD
|
||||
METAMOD = $(SOURCEMM16)
|
||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
||||
SRCDS = $(SRCDS_BASE)/orangebox
|
||||
override ENGSET = true
|
||||
endif
|
||||
|
||||
LINK = vstdlib_i486.so tier0_i486.so -static-libgcc
|
||||
|
||||
INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
|
||||
-I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK) -I$(SMSDK)/jit \
|
||||
-I$(SMSDK)/jit/x86 -I$(SMSDK)/extensions -I$(SMSDK)/sourcepawn
|
||||
|
||||
CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
|
||||
-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -mfpmath=sse \
|
||||
-msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32
|
||||
CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
|
||||
|
||||
################################################
|
||||
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
|
||||
################################################
|
||||
|
||||
ifeq "$(DEBUG)" "true"
|
||||
BIN_DIR = Debug.$(ENGINE)
|
||||
CFLAGS += $(C_DEBUG_FLAGS)
|
||||
else
|
||||
BIN_DIR = Release.$(ENGINE)
|
||||
CFLAGS += $(C_OPT_FLAGS)
|
||||
endif
|
||||
|
||||
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
|
||||
ifeq "$(GCC_VERSION)" "4"
|
||||
CFLAGS += $(C_GCC4_FLAGS)
|
||||
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
||||
endif
|
||||
|
||||
BINARY = $(PROJECT)_i486.so
|
||||
|
||||
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
||||
|
||||
$(BIN_DIR)/%.o: %.cpp
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||
|
||||
all: check
|
||||
mkdir -p $(BIN_DIR)
|
||||
ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so;
|
||||
ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so;
|
||||
$(MAKE) -f Makefile mms_ext
|
||||
|
||||
check:
|
||||
if [ "$(ENGSET)" == "false" ]; then \
|
||||
echo "You must supply ENGINE=orangebox or ENGINE=original"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
mms_ext: check $(OBJ_LINUX)
|
||||
$(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
|
||||
|
||||
debug:
|
||||
$(MAKE) -f Makefile all DEBUG=true
|
||||
|
||||
default: all
|
||||
|
||||
clean: check
|
||||
rm -rf $(BIN_DIR)/*.o
|
||||
rm -rf $(BIN_DIR)/$(BINARY)
|
||||
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "stub_mm.h"
|
||||
#include "stub_util.h"
|
||||
#include "sm_ext.h"
|
||||
|
||||
MyExtension g_SMExt;
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength)
|
||||
{
|
||||
if ((smexts = (IExtensionManager *)g_SMAPI->MetaFactory(
|
||||
SOURCEMOD_INTERFACE_EXTENSIONS,
|
||||
NULL,
|
||||
NULL))
|
||||
== NULL)
|
||||
{
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, SOURCEMOD_INTERFACE_EXTENSIONS " interface not found");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This could be more dynamic */
|
||||
char path[256];
|
||||
g_SMAPI->PathFormat(path,
|
||||
sizeof(path),
|
||||
"addons/myplugin/bin/myplugin%s",
|
||||
#if defined __linux__
|
||||
"_i486.so"
|
||||
#else
|
||||
".dll"
|
||||
#endif
|
||||
);
|
||||
|
||||
if ((myself = smexts->LoadExternal(&g_SMExt,
|
||||
path,
|
||||
"myplugin_mm.ext",
|
||||
error,
|
||||
maxlength))
|
||||
== NULL)
|
||||
{
|
||||
SM_UnsetInterfaces();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnloadExtension()
|
||||
{
|
||||
smexts->UnloadExtension(myself);
|
||||
}
|
||||
|
||||
bool MyExtension::OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late)
|
||||
{
|
||||
sharesys = sys;
|
||||
myself = me;
|
||||
|
||||
/* Get the default interfaces from our configured SDK header */
|
||||
if (!SM_AcquireInterfaces(error, maxlength))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionUnload()
|
||||
{
|
||||
/* Clean up any resources here, and more importantly, make sure
|
||||
* any listeners/hooks into SourceMod are totally removed, as well
|
||||
* as data structures like handle types and forwards.
|
||||
*/
|
||||
|
||||
//...
|
||||
|
||||
/* Make sure our pointers get NULL'd just in case */
|
||||
SM_UnsetInterfaces();
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionsAllLoaded()
|
||||
{
|
||||
/* Called once all extensions are marked as loaded.
|
||||
* This always called, and always called only once.
|
||||
*/
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionPauseChange(bool pause)
|
||||
{
|
||||
}
|
||||
|
||||
bool MyExtension::QueryRunning(char *error, size_t maxlength)
|
||||
{
|
||||
/* if something is required that can't be determined during the initial
|
||||
* load process, print a message here will show a helpful message to
|
||||
* users when they view the extension's info.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyExtension::IsMetamodExtension()
|
||||
{
|
||||
/* Must return false! */
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionName()
|
||||
{
|
||||
return mmsplugin->GetName();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionURL()
|
||||
{
|
||||
return mmsplugin->GetURL();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionTag()
|
||||
{
|
||||
return mmsplugin->GetLogTag();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionAuthor()
|
||||
{
|
||||
return mmsplugin->GetAuthor();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionVerString()
|
||||
{
|
||||
return mmsplugin->GetVersion();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDescription()
|
||||
{
|
||||
return mmsplugin->GetDescription();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDateString()
|
||||
{
|
||||
return mmsplugin->GetDate();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
#define _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
class MyExtension : public IExtensionInterface
|
||||
{
|
||||
public:
|
||||
virtual bool OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late);
|
||||
virtual void OnExtensionUnload();
|
||||
virtual void OnExtensionsAllLoaded();
|
||||
virtual void OnExtensionPauseChange(bool pause);
|
||||
virtual bool QueryRunning(char *error, size_t maxlength);
|
||||
virtual bool IsMetamodExtension();
|
||||
virtual const char *GetExtensionName();
|
||||
virtual const char *GetExtensionURL();
|
||||
virtual const char *GetExtensionTag();
|
||||
virtual const char *GetExtensionAuthor();
|
||||
virtual const char *GetExtensionVerString();
|
||||
virtual const char *GetExtensionDescription();
|
||||
virtual const char *GetExtensionDateString();
|
||||
};
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength);
|
||||
void SM_UnloadExtension();
|
||||
|
||||
extern IShareSys *sharesys;
|
||||
extern IExtension *myself;
|
||||
extern MyExtension g_SMExt;
|
||||
|
||||
#endif //_INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength)
|
||||
{
|
||||
SM_FIND_IFACE_OR_FAIL(SOURCEMOD, sm_main, error, maxlength);
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SM_FIND_IFACE_OR_FAIL(FORWARDMANAGER, sm_forwards, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SM_FIND_IFACE_OR_FAIL(HANDLESYSTEM, sm_handlesys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(PLAYERMANAGER, sm_players, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SM_FIND_IFACE_OR_FAIL(DBI, sm_dbi, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SM_FIND_IFACE_OR_FAIL(GAMECONFIG, sm_gameconfs, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SM_FIND_IFACE_OR_FAIL(MEMORYUTILS, sm_memutils, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(GAMEHELPERS, sm_gamehelpers, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SM_FIND_IFACE_OR_FAIL(TIMERSYS, sm_timersys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SM_FIND_IFACE_OR_FAIL(THREADER, sm_threader, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SM_FIND_IFACE_OR_FAIL(LIBRARYSYS, sm_libsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(PLUGINSYSTEM, sm_plsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SM_FIND_IFACE_OR_FAIL(MENUMANAGER, sm_menus, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(ADMINSYS, sm_adminsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SM_FIND_IFACE_OR_FAIL(TEXTPARSERS, sm_text, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
SM_FIND_IFACE_OR_FAIL(TRANSLATOR, sm_translator, error, maxlength);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnsetInterfaces()
|
||||
{
|
||||
myself = NULL;
|
||||
smexts = NULL;
|
||||
sharesys = NULL;
|
||||
sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
sm_text = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
sm_translator = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
IExtension *myself = NULL;
|
||||
IExtensionManager *smexts = NULL;
|
||||
IShareSys *sharesys = NULL;
|
||||
SourceMod::ISourceMod *sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SourceMod::IForwardManager *sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SourceMod::IHandleSys *sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SourceMod::IPlayerManager *sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SourceMod::IDBManager *sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SourceMod::IGameConfigManager *sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SourceMod::IMemoryUtils *sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SourceMod::IGameHelpers *sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SourceMod::ITimerSystem *sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SourceMod::IThreader *sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SourceMod::ILibrarySys *sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SourceMod::IPluginManager *sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SourceMod::IMenuManager *sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SourceMod::IAdminSystem *sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SourceMod::ITextParsers *sm_text = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
SourceMod::ITranslator *sm_translator = NULL;
|
||||
#endif
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
#define _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* @brief Acquires the interfaces enabled at the bottom of this header.
|
||||
*
|
||||
* @param error Buffer to store error message.
|
||||
* @param maxlength Maximum size of the error buffer.
|
||||
* @return True on success, false on failure.
|
||||
* On failure, a null-terminated string will be stored
|
||||
* in the error buffer, if the buffer is non-NULL and
|
||||
* greater than 0 bytes in size.
|
||||
*/
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength);
|
||||
|
||||
/**
|
||||
* @brief Sets each acquired interface to NULL.
|
||||
*/
|
||||
void SM_UnsetInterfaces();
|
||||
|
||||
/**
|
||||
* Enable interfaces you want to use here by uncommenting lines.
|
||||
* These interfaces are all part of SourceMod's core.
|
||||
*/
|
||||
//#define SMEXT_ENABLE_FORWARDSYS
|
||||
//#define SMEXT_ENABLE_HANDLESYS
|
||||
//#define SMEXT_ENABLE_PLAYERHELPERS
|
||||
//#define SMEXT_ENABLE_DBMANAGER
|
||||
//#define SMEXT_ENABLE_GAMECONF
|
||||
//#define SMEXT_ENABLE_MEMUTILS
|
||||
//#define SMEXT_ENABLE_GAMEHELPERS
|
||||
//#define SMEXT_ENABLE_TIMERSYS
|
||||
//#define SMEXT_ENABLE_THREADER
|
||||
//#define SMEXT_ENABLE_LIBSYS
|
||||
//#define SMEXT_ENABLE_MENUS
|
||||
//#define SMEXT_ENABLE_ADTFACTORY
|
||||
//#define SMEXT_ENABLE_PLUGINSYS
|
||||
//#define SMEXT_ENABLE_ADMINSYS
|
||||
//#define SMEXT_ENABLE_TEXTPARSERS
|
||||
//#define SMEXT_ENABLE_TRANSLATOR
|
||||
|
||||
|
||||
/**
|
||||
* There is no need to edit below.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IExtensionSys.h>
|
||||
extern SourceMod::IExtension *myself;
|
||||
extern SourceMod::IExtensionManager *smexts;
|
||||
extern SourceMod::IShareSys *sharesys;
|
||||
|
||||
#include <ISourceMod.h>
|
||||
extern SourceMod::ISourceMod *sm_main;
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
#include <IForwardSys.h>
|
||||
extern SourceMod::IForwardManager *sm_forwards;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
#include <IHandleSys.h>
|
||||
extern SourceMod::IHandleSys *sm_handlesys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
#include <IPlayerHelpers.h>
|
||||
extern SourceMod::IPlayerManager *sm_players;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
#include <IDBDriver.h>
|
||||
extern SourceMod::IDBManager *sm_dbi;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
#include <IGameConfigs.h>
|
||||
extern SourceMod::IGameConfigManager *sm_gameconfs;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
#include <IMemoryUtils.h>
|
||||
extern SourceMod::IMemoryUtils *sm_memutils;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
#include <IGameHelpers.h>
|
||||
extern SourceMod::IGameHelpers *sm_gamehelpers;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
#include <ITimerSystem.h>
|
||||
extern SourceMod::ITimerSystem *sm_timersys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
#include <IThreader.h>
|
||||
extern SourceMod::IThreader *sm_threader;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
#include <ILibrarySys.h>
|
||||
extern SourceMod::ILibrarySys *sm_libsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
#include <IPluginSys.h>
|
||||
extern SourceMod::IPluginManager *sm_plsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
#include <IMenuManager.h>
|
||||
extern SourceMod::IMenuManager *sm_menus;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
#include <IAdminSystem.h>
|
||||
extern SourceMod::IAdminSystem *sm_adminsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
#include <ITextParsers.h>
|
||||
extern SourceMod::ITextParsers *sm_text;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
#include <ITranslator.h>
|
||||
extern SourceMod::ITranslator *sm_translator;
|
||||
#endif
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ======================================================
|
||||
* Metamod:Source Stub Plugin
|
||||
* Written by AlliedModders LLC.
|
||||
* ======================================================
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "stub_mm.h"
|
||||
#include "stub_util.h"
|
||||
#include "sm_ext.h"
|
||||
|
||||
SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
|
||||
|
||||
StubPlugin g_StubPlugin;
|
||||
IVEngineServer *engine = NULL;
|
||||
IServerGameDLL *server = NULL;
|
||||
ISmmPlugin *mmsplugin = &g_StubPlugin;
|
||||
|
||||
PLUGIN_EXPOSE(StubPlugin, g_StubPlugin);
|
||||
bool StubPlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||
{
|
||||
PLUGIN_SAVEVARS();
|
||||
|
||||
#if defined METAMOD_PLAPI_VERSION
|
||||
GET_V_IFACE_ANY(GetServerFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
|
||||
GET_V_IFACE_ANY(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
||||
#else
|
||||
GET_V_IFACE_ANY(serverFactory, server, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
|
||||
GET_V_IFACE_ANY(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
||||
#endif
|
||||
|
||||
SH_ADD_HOOK_STATICFUNC(IServerGameDLL, ServerActivate, server, Hook_ServerActivate, true);
|
||||
|
||||
ismm->AddListener(this, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StubPlugin::Unload(char *error, size_t maxlen)
|
||||
{
|
||||
SM_UnloadExtension();
|
||||
|
||||
SH_REMOVE_HOOK_STATICFUNC(IServerGameDLL, ServerActivate, server, Hook_ServerActivate, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Hook_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
||||
{
|
||||
META_LOG(g_PLAPI, "ServerActivate() called: edictCount = %d, clientMax = %d", edictCount, clientMax);
|
||||
}
|
||||
|
||||
void *StubPlugin::OnMetamodQuery(const char *iface, int *ret)
|
||||
{
|
||||
if (strcmp(iface, SOURCEMOD_NOTICE_EXTENSIONS) == 0)
|
||||
{
|
||||
BindToSourcemod();
|
||||
}
|
||||
|
||||
if (ret != NULL)
|
||||
{
|
||||
*ret = IFACE_OK;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void StubPlugin::AllPluginsLoaded()
|
||||
{
|
||||
BindToSourcemod();
|
||||
}
|
||||
|
||||
void StubPlugin::BindToSourcemod()
|
||||
{
|
||||
char error[256];
|
||||
|
||||
if (!SM_LoadExtension(error, sizeof(error)))
|
||||
{
|
||||
char message[512];
|
||||
UTIL_Format(message, sizeof(message), "Could not load as a SourceMod extension: %s\n", error);
|
||||
engine->LogPrint(message);
|
||||
}
|
||||
}
|
||||
|
||||
bool StubPlugin::Pause(char *error, size_t maxlen)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StubPlugin::Unpause(char *error, size_t maxlen)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *StubPlugin::GetLicense()
|
||||
{
|
||||
return "Public Domain";
|
||||
}
|
||||
|
||||
const char *StubPlugin::GetVersion()
|
||||
{
|
||||
return "1.0.0.0";
|
||||
}
|
||||
|
||||
const char *StubPlugin::GetDate()
|
||||
{
|
||||
return __DATE__;
|
||||
}
|
||||
|
||||
const char *StubPlugin::GetLogTag()
|
||||
{
|
||||
return "STUB";
|
||||
}
|
||||
|
||||
const char *StubPlugin::GetAuthor()
|
||||
{
|
||||
return "AlliedModders LLC";
|
||||
}
|
||||
|
||||
const char *StubPlugin::GetDescription()
|
||||
{
|
||||
return "Sample empty plugin";
|
||||
}
|
||||
|
||||
const char *StubPlugin::GetName()
|
||||
{
|
||||
return "Stub Plugin";
|
||||
}
|
||||
|
||||
const char *StubPlugin::GetURL()
|
||||
{
|
||||
return "http://www.sourcemm.net/";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ======================================================
|
||||
* Metamod:Source Stub Plugin
|
||||
* Written by AlliedModders LLC.
|
||||
* ======================================================
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
#define _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
|
||||
#include <ISmmPlugin.h>
|
||||
|
||||
class StubPlugin :
|
||||
public ISmmPlugin,
|
||||
public IMetamodListener
|
||||
{
|
||||
public:
|
||||
bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
|
||||
bool Unload(char *error, size_t maxlen);
|
||||
bool Pause(char *error, size_t maxlen);
|
||||
bool Unpause(char *error, size_t maxlen);
|
||||
void AllPluginsLoaded();
|
||||
const char *GetAuthor();
|
||||
const char *GetName();
|
||||
const char *GetDescription();
|
||||
const char *GetURL();
|
||||
const char *GetLicense();
|
||||
const char *GetVersion();
|
||||
const char *GetDate();
|
||||
const char *GetLogTag();
|
||||
public: //IMetamodListener
|
||||
void *OnMetamodQuery(const char *iface, int *ret);
|
||||
private:
|
||||
void BindToSourcemod();
|
||||
};
|
||||
|
||||
void Hook_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
||||
|
||||
extern StubPlugin g_StubPlugin;
|
||||
extern ISmmPlugin *mmsplugin;
|
||||
|
||||
PLUGIN_GLOBALVARS();
|
||||
|
||||
#endif //_INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ======================================================
|
||||
* Metamod:Source Stub Plugin
|
||||
* Written by AlliedModders LLC.
|
||||
* ======================================================
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "stub_util.h"
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (len >= maxlength)
|
||||
{
|
||||
len = maxlength - 1;
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ======================================================
|
||||
* Metamod:Source Stub Plugin
|
||||
* Written by AlliedModders LLC.
|
||||
* ======================================================
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
#define _INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* This is a platform-safe function which fixes weird idiosyncracies
|
||||
* in the null-termination and return value of snprintf(). It guarantees
|
||||
* the terminator on overflow cases, and never returns -1 or a value
|
||||
* not equal to the number of non-terminating bytes written.
|
||||
*/
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||
|
||||
#endif //_INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
# (C)2004-2008 SourceMod Development Team
|
||||
# Makefile written by David "BAILOPAN" Anderson
|
||||
|
||||
SMSDK = ../..
|
||||
SRCDS_BASE = ~/srcds
|
||||
HL2SDK_ORIG = ../../../hl2sdk
|
||||
HL2SDK_OB = ../../../hl2sdk-ob
|
||||
SOURCEMM14 = ../../../sourcemm-1.4
|
||||
SOURCEMM16 = ../../../sourcemm-1.6
|
||||
|
||||
#####################################
|
||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||
#####################################
|
||||
|
||||
PROJECT = sample
|
||||
|
||||
#Uncomment for Metamod: Source enabled extension
|
||||
#USEMETA = true
|
||||
|
||||
OBJECTS = sdk/smsdk_ext.cpp extension.cpp
|
||||
|
||||
##############################################
|
||||
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
||||
##############################################
|
||||
|
||||
C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
|
||||
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
|
||||
C_GCC4_FLAGS = -fvisibility=hidden
|
||||
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
|
||||
CPP = gcc-4.1
|
||||
|
||||
override ENGSET = false
|
||||
ifeq "$(ENGINE)" "original"
|
||||
HL2SDK = $(HL2SDK_ORIG)
|
||||
HL2PUB = $(HL2SDK_ORIG)/public
|
||||
HL2LIB = $(HL2SDK_ORIG)/linux_sdk
|
||||
METAMOD = $(SOURCEMM14)
|
||||
INCLUDE += -I$(HL2SDK)/public/dlls
|
||||
SRCDS = $(SRCDS_BASE)
|
||||
override ENGSET = true
|
||||
endif
|
||||
ifeq "$(ENGINE)" "orangebox"
|
||||
HL2SDK = $(HL2SDK_OB)
|
||||
HL2PUB = $(HL2SDK_OB)/public
|
||||
HL2LIB = $(HL2SDK_OB)/linux_sdk
|
||||
CFLAGS += -DORANGEBOX_BUILD
|
||||
METAMOD = $(SOURCEMM16)
|
||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
||||
SRCDS = $(SRCDS_BASE)/orangebox
|
||||
override ENGSET = true
|
||||
endif
|
||||
|
||||
ifeq "$(USEMETA)" "true"
|
||||
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
|
||||
|
||||
LINK += $(LINK_HL2)
|
||||
|
||||
INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
|
||||
-I$(METAMOD) -I$(METAMOD)/sourcehook -I$(METAMOD)/sourcemm -I$(SMSDK)/public \
|
||||
-I$(SMSDK)/public/sourcepawn
|
||||
else
|
||||
INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn
|
||||
endif
|
||||
|
||||
LINK += -static-libgcc
|
||||
|
||||
CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
|
||||
-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \
|
||||
-Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32
|
||||
CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
|
||||
|
||||
################################################
|
||||
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
|
||||
################################################
|
||||
|
||||
ifeq "$(DEBUG)" "true"
|
||||
BIN_DIR = Debug
|
||||
CFLAGS += $(C_DEBUG_FLAGS)
|
||||
else
|
||||
BIN_DIR = Release
|
||||
CFLAGS += $(C_OPT_FLAGS)
|
||||
endif
|
||||
|
||||
ifeq "$(USEMETA)" "true"
|
||||
BIN_DIR := $(BIN_DIR).$(ENGINE)
|
||||
endif
|
||||
|
||||
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
|
||||
ifeq "$(GCC_VERSION)" "4"
|
||||
CFLAGS += $(C_GCC4_FLAGS)
|
||||
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
||||
endif
|
||||
|
||||
BINARY = $(PROJECT).ext.so
|
||||
|
||||
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
||||
|
||||
$(BIN_DIR)/%.o: %.cpp
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||
|
||||
all: check
|
||||
mkdir -p $(BIN_DIR)/sdk
|
||||
if [ "$(USEMETA)" == "true" ]; then \
|
||||
ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \
|
||||
ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \
|
||||
fi
|
||||
$(MAKE) -f Makefile extension
|
||||
|
||||
check:
|
||||
if [ "$(USEMETA)" == "true" ] && [ "$(ENGSET)" == "false" ]; then \
|
||||
echo "You must supply ENGINE=orangebox or ENGINE=original"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
extension: check $(OBJ_LINUX)
|
||||
$(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
|
||||
|
||||
debug:
|
||||
$(MAKE) -f Makefile all DEBUG=true
|
||||
|
||||
default: all
|
||||
|
||||
clean: check
|
||||
rm -rf $(BIN_DIR)/*.o
|
||||
rm -rf $(BIN_DIR)/sdk/*.o
|
||||
rm -rf $(BIN_DIR)/$(BINARY)
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "extension.h"
|
||||
|
||||
/**
|
||||
* @file extension.cpp
|
||||
* @brief Implement extension code here.
|
||||
*/
|
||||
|
||||
Sample g_Sample; /**< Global singleton for extension's main interface */
|
||||
|
||||
SMEXT_LINK(&g_Sample);
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||
#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||
|
||||
/**
|
||||
* @file extension.h
|
||||
* @brief Sample extension code header.
|
||||
*/
|
||||
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Sample implementation of the SDK Extension.
|
||||
* Note: Uncomment one of the pre-defined virtual functions in order to use it.
|
||||
*/
|
||||
class Sample : public SDKExtension
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief This is called after the initial loading sequence has been processed.
|
||||
*
|
||||
* @param error Error message buffer.
|
||||
* @param maxlength Size of error message buffer.
|
||||
* @param late Whether or not the module was loaded after map load.
|
||||
* @return True to succeed loading, false to fail.
|
||||
*/
|
||||
//virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
|
||||
|
||||
/**
|
||||
* @brief This is called right before the extension is unloaded.
|
||||
*/
|
||||
//virtual void SDK_OnUnload();
|
||||
|
||||
/**
|
||||
* @brief This is called once all known extensions have been loaded.
|
||||
* Note: It is is a good idea to add natives here, if any are provided.
|
||||
*/
|
||||
//virtual void SDK_OnAllLoaded();
|
||||
|
||||
/**
|
||||
* @brief Called when the pause state is changed.
|
||||
*/
|
||||
//virtual void SDK_OnPauseChange(bool paused);
|
||||
|
||||
/**
|
||||
* @brief this is called when Core wants to know if your extension is working.
|
||||
*
|
||||
* @param error Error message buffer.
|
||||
* @param maxlength Size of error message buffer.
|
||||
* @return True if working, false otherwise.
|
||||
*/
|
||||
//virtual bool QueryRunning(char *error, size_t maxlength);
|
||||
public:
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
/**
|
||||
* @brief Called when Metamod is attached, before the extension version is called.
|
||||
*
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @param late Whether or not Metamod considers this a late load.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
//virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
|
||||
|
||||
/**
|
||||
* @brief Called when Metamod is detaching, after the extension version is called.
|
||||
* NOTE: By default this is blocked unless sent from SourceMod.
|
||||
*
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
|
||||
|
||||
/**
|
||||
* @brief Called when Metamod's pause state is changing.
|
||||
* NOTE: By default this is blocked unless sent from SourceMod.
|
||||
*
|
||||
* @param paused Pause state being set.
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk", "sdk.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug - Episode 1|Win32 = Debug - Episode 1|Win32
|
||||
Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32
|
||||
Debug - Orange Box|Win32 = Debug - Orange Box|Win32
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release - Episode 1|Win32 = Release - Episode 1|Win32
|
||||
Release - Old Metamod|Win32 = Release - Old Metamod|Win32
|
||||
Release - Orange Box|Win32 = Release - Orange Box|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,718 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="sdk"
|
||||
ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
|
||||
RootNamespace="sdk"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..;..\..\sourcepawn"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
EnableEnhancedInstructionSet="1"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\sample.ext.dll"
|
||||
LinkIncremental="2"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..;..\..\sourcepawn"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD"
|
||||
RuntimeLibrary="0"
|
||||
EnableEnhancedInstructionSet="1"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\sample.ext.dll"
|
||||
LinkIncremental="1"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug - Old Metamod|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..;..\..\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
EnableEnhancedInstructionSet="1"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib""
|
||||
OutputFile="$(OutDir)\sample.ext.dll"
|
||||
LinkIncremental="2"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release - Old Metamod|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..;..\..\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(SOURCEMM14)";"$(SOURCEMM14)\sourcemm";"$(SOURCEMM14)\sourcehook""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
|
||||
RuntimeLibrary="0"
|
||||
EnableEnhancedInstructionSet="1"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib""
|
||||
OutputFile="$(OutDir)\sample.ext.dll"
|
||||
LinkIncremental="1"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug - Orange Box|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..;..\..\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
EnableEnhancedInstructionSet="1"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies=""$(HL2SDKOB)\lib\public\tier0.lib" "$(HL2SDKOB)\lib\public\tier1.lib" "$(HL2SDKOB)\lib\public\vstdlib.lib""
|
||||
OutputFile="$(OutDir)\sample.ext.dll"
|
||||
LinkIncremental="2"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release - Orange Box|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..;..\..\sourcepawn;"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;ORANGEBOX_BUILD"
|
||||
RuntimeLibrary="0"
|
||||
EnableEnhancedInstructionSet="1"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies=""$(HL2SDKOB)\lib\public\tier0.lib" "$(HL2SDKOB)\lib\public\tier1.lib" "$(HL2SDKOB)\lib\public\vstdlib.lib""
|
||||
OutputFile="$(OutDir)\sample.ext.dll"
|
||||
LinkIncremental="1"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug - Episode 1|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..;..\..\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
EnableEnhancedInstructionSet="1"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib""
|
||||
OutputFile="$(OutDir)\sample.ext.dll"
|
||||
LinkIncremental="2"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMT"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release - Episode 1|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..;..\..\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(SOURCEMM16)";"$(SOURCEMM16)\sourcemm";"$(SOURCEMM16)\sourcehook""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
|
||||
RuntimeLibrary="0"
|
||||
EnableEnhancedInstructionSet="1"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies=""$(HL2SDK)\lib\public\tier0.lib" "$(HL2SDK)\lib\public\tier1.lib" "$(HL2SDK)\lib\public\vstdlib.lib""
|
||||
OutputFile="$(OutDir)\sample.ext.dll"
|
||||
LinkIncremental="1"
|
||||
IgnoreDefaultLibraryNames="LIBC;LIBCD;LIBCMTD"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\extension.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\extension.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="SourceMod SDK"
|
||||
UniqueIdentifier="{31958233-BB2D-4e41-A8F9-CE8A4684F436}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\sdk\smsdk_config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sdk\smsdk_ext.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sdk\smsdk_ext.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
||||
#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
||||
|
||||
/**
|
||||
* @file smsdk_config.h
|
||||
* @brief Contains macros for configuring basic extension information.
|
||||
*/
|
||||
|
||||
/* Basic information exposed publicly */
|
||||
#define SMEXT_CONF_NAME "Sample Extension"
|
||||
#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers"
|
||||
#define SMEXT_CONF_VERSION "0.0.0.0"
|
||||
#define SMEXT_CONF_AUTHOR "AlliedModders"
|
||||
#define SMEXT_CONF_URL "http://www.sourcemod.net/"
|
||||
#define SMEXT_CONF_LOGTAG "SAMPLE"
|
||||
#define SMEXT_CONF_LICENSE "GPL"
|
||||
#define SMEXT_CONF_DATESTRING __DATE__
|
||||
|
||||
/**
|
||||
* @brief Exposes plugin's main interface.
|
||||
*/
|
||||
#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
|
||||
|
||||
/**
|
||||
* @brief Sets whether or not this plugin required Metamod.
|
||||
* NOTE: Uncomment to enable, comment to disable.
|
||||
*/
|
||||
//#define SMEXT_CONF_METAMOD
|
||||
|
||||
/** Enable interfaces you want to use here by uncommenting lines */
|
||||
//#define SMEXT_ENABLE_FORWARDSYS
|
||||
//#define SMEXT_ENABLE_HANDLESYS
|
||||
//#define SMEXT_ENABLE_PLAYERHELPERS
|
||||
//#define SMEXT_ENABLE_DBMANAGER
|
||||
//#define SMEXT_ENABLE_GAMECONF
|
||||
//#define SMEXT_ENABLE_MEMUTILS
|
||||
//#define SMEXT_ENABLE_GAMEHELPERS
|
||||
//#define SMEXT_ENABLE_TIMERSYS
|
||||
//#define SMEXT_ENABLE_THREADER
|
||||
//#define SMEXT_ENABLE_LIBSYS
|
||||
//#define SMEXT_ENABLE_MENUS
|
||||
//#define SMEXT_ENABLE_ADTFACTORY
|
||||
//#define SMEXT_ENABLE_PLUGINSYS
|
||||
//#define SMEXT_ENABLE_ADMINSYS
|
||||
//#define SMEXT_ENABLE_TEXTPARSERS
|
||||
//#define SMEXT_ENABLE_USERMSGS
|
||||
//#define SMEXT_ENABLE_TRANSLATOR
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
||||
@@ -0,0 +1,461 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Base Extension Code
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
/**
|
||||
* @file smsdk_ext.cpp
|
||||
* @brief Contains wrappers for making Extensions easier to write.
|
||||
*/
|
||||
|
||||
IExtension *myself = NULL; /**< Ourself */
|
||||
IShareSys *g_pShareSys = NULL; /**< Share system */
|
||||
IShareSys *sharesys = NULL; /**< Share system */
|
||||
ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
|
||||
ISourceMod *smutils = NULL; /**< SourceMod helpers */
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
IForwardManager *g_pForwards = NULL; /**< Forward system */
|
||||
IForwardManager *forwards = NULL; /**< Forward system */
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
IHandleSys *g_pHandleSys = NULL; /**< Handle system */
|
||||
IHandleSys *handlesys = NULL; /**< Handle system */
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
IPlayerManager *playerhelpers = NULL; /**< Player helpers */
|
||||
#endif //SMEXT_ENABLE_PLAYERHELPERS
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
IDBManager *dbi = NULL; /**< DB Manager */
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
IGameConfigManager *gameconfs = NULL; /**< Game config manager */
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
IMemoryUtils *memutils = NULL;
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
IGameHelpers *gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
ITimerSystem *timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADTFACTORY
|
||||
IADTFactory *adtfactory = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
IThreader *threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
ILibrarySys *libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SourceMod::IPluginManager *plsys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
IMenuManager *menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
IAdminSystem *adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
ITextParsers *textparsers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
IUserMessages *usermsgs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
ITranslator *translator = NULL;
|
||||
#endif
|
||||
|
||||
/** Exports the main interface */
|
||||
PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
|
||||
{
|
||||
return g_pExtensionIface;
|
||||
}
|
||||
|
||||
SDKExtension::SDKExtension()
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_SourceMMLoaded = false;
|
||||
m_WeAreUnloaded = false;
|
||||
m_WeGotPauseChange = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
|
||||
{
|
||||
g_pShareSys = sharesys = sys;
|
||||
myself = me;
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeAreUnloaded = true;
|
||||
|
||||
if (!m_SourceMMLoaded)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlength, "Metamod attach failed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
SM_GET_IFACE(SOURCEMOD, g_pSM);
|
||||
smutils = g_pSM;
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
|
||||
handlesys = g_pHandleSys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
|
||||
forwards = g_pForwards;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SM_GET_IFACE(DBI, dbi);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SM_GET_IFACE(GAMECONFIG, gameconfs);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SM_GET_IFACE(MEMORYUTILS, memutils);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SM_GET_IFACE(GAMEHELPERS, gamehelpers);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SM_GET_IFACE(TIMERSYS, timersys);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADTFACTORY
|
||||
SM_GET_IFACE(ADTFACTORY, adtfactory);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SM_GET_IFACE(THREADER, threader);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SM_GET_IFACE(LIBRARYSYS, libsys);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SM_GET_IFACE(PLUGINSYSTEM, plsys);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SM_GET_IFACE(MENUMANAGER, menus);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SM_GET_IFACE(ADMINSYS, adminsys);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SM_GET_IFACE(TEXTPARSERS, textparsers);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
SM_GET_IFACE(USERMSGS, usermsgs);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
SM_GET_IFACE(TRANSLATOR, translator);
|
||||
#endif
|
||||
|
||||
if (SDK_OnLoad(error, maxlength, late))
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeAreUnloaded = true;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SDKExtension::IsMetamodExtension()
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SDKExtension::OnExtensionPauseChange(bool state)
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeGotPauseChange = true;
|
||||
#endif
|
||||
SDK_OnPauseChange(state);
|
||||
}
|
||||
|
||||
void SDKExtension::OnExtensionsAllLoaded()
|
||||
{
|
||||
SDK_OnAllLoaded();
|
||||
}
|
||||
|
||||
void SDKExtension::OnExtensionUnload()
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeAreUnloaded = true;
|
||||
#endif
|
||||
SDK_OnUnload();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionAuthor()
|
||||
{
|
||||
return SMEXT_CONF_AUTHOR;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionDateString()
|
||||
{
|
||||
return SMEXT_CONF_DATESTRING;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionDescription()
|
||||
{
|
||||
return SMEXT_CONF_DESCRIPTION;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionVerString()
|
||||
{
|
||||
return SMEXT_CONF_VERSION;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionName()
|
||||
{
|
||||
return SMEXT_CONF_NAME;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionTag()
|
||||
{
|
||||
return SMEXT_CONF_LOGTAG;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionURL()
|
||||
{
|
||||
return SMEXT_CONF_URL;
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnUnload()
|
||||
{
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnPauseChange(bool paused)
|
||||
{
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnAllLoaded()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
|
||||
PluginId g_PLID = 0; /**< Metamod plugin ID */
|
||||
ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
|
||||
SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
|
||||
ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
|
||||
|
||||
IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
|
||||
IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
|
||||
|
||||
/** Exposes the extension to Metamod */
|
||||
SMM_API void *PL_EXPOSURE(const char *name, int *code)
|
||||
{
|
||||
#if defined METAMOD_PLAPI_VERSION
|
||||
if (name && !strcmp(name, METAMOD_PLAPI_NAME))
|
||||
#else
|
||||
if (name && !strcmp(name, PLAPI_NAME))
|
||||
#endif
|
||||
{
|
||||
if (code)
|
||||
{
|
||||
*code = IFACE_OK;
|
||||
}
|
||||
return static_cast<void *>(g_pExtensionIface);
|
||||
}
|
||||
|
||||
if (code)
|
||||
{
|
||||
*code = IFACE_FAILED;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||
{
|
||||
PLUGIN_SAVEVARS();
|
||||
|
||||
#if !defined METAMOD_PLAPI_VERSION
|
||||
GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
|
||||
GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
||||
#else
|
||||
GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
|
||||
GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
||||
#endif
|
||||
|
||||
m_SourceMMLoaded = true;
|
||||
|
||||
return SDK_OnMetamodLoad(ismm, error, maxlen, late);
|
||||
}
|
||||
|
||||
bool SDKExtension::Unload(char *error, size_t maxlen)
|
||||
{
|
||||
if (!m_WeAreUnloaded)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return SDK_OnMetamodUnload(error, maxlen);
|
||||
}
|
||||
|
||||
bool SDKExtension::Pause(char *error, size_t maxlen)
|
||||
{
|
||||
if (!m_WeGotPauseChange)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlen, "This extension must be paused by SourceMod.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_WeGotPauseChange = false;
|
||||
|
||||
return SDK_OnMetamodPauseChange(true, error, maxlen);
|
||||
}
|
||||
|
||||
bool SDKExtension::Unpause(char *error, size_t maxlen)
|
||||
{
|
||||
if (!m_WeGotPauseChange)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_WeGotPauseChange = false;
|
||||
|
||||
return SDK_OnMetamodPauseChange(false, error, maxlen);
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetAuthor()
|
||||
{
|
||||
return GetExtensionAuthor();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetDate()
|
||||
{
|
||||
return GetExtensionDateString();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetDescription()
|
||||
{
|
||||
return GetExtensionDescription();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetLicense()
|
||||
{
|
||||
return SMEXT_CONF_LICENSE;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetLogTag()
|
||||
{
|
||||
return GetExtensionTag();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetName()
|
||||
{
|
||||
return GetExtensionName();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetURL()
|
||||
{
|
||||
return GetExtensionURL();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetVersion()
|
||||
{
|
||||
return GetExtensionVerString();
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Overload a few things to prevent libstdc++ linking */
|
||||
#if defined __linux__
|
||||
extern "C" void __cxa_pure_virtual(void)
|
||||
{
|
||||
}
|
||||
|
||||
void *operator new(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *operator new[](size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void * ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,333 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Base Extension Code
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
|
||||
#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
|
||||
|
||||
/**
|
||||
* @file smsdk_ext.h
|
||||
* @brief Contains wrappers for making Extensions easier to write.
|
||||
*/
|
||||
|
||||
#include "smsdk_config.h"
|
||||
#include <IExtensionSys.h>
|
||||
#include <IHandleSys.h>
|
||||
#include <sp_vm_api.h>
|
||||
#include <sm_platform.h>
|
||||
#include <ISourceMod.h>
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
#include <IForwardSys.h>
|
||||
#endif //SMEXT_ENABLE_FORWARDSYS
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
#include <IPlayerHelpers.h>
|
||||
#endif //SMEXT_ENABLE_PlAYERHELPERS
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
#include <IDBDriver.h>
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
#include <IGameConfigs.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
#include <IMemoryUtils.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
#include <IGameHelpers.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
#include <ITimerSystem.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADTFACTORY
|
||||
#include <IADTFactory.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
#include <IThreader.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
#include <ILibrarySys.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
#include <IPluginSys.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
#include <IMenuManager.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
#include <IAdminSystem.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
#include <ITextParsers.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
#include <IUserMessages.h>
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
#include <ITranslator.h>
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
#include <ISmmPlugin.h>
|
||||
#include <eiface.h>
|
||||
#endif
|
||||
|
||||
using namespace SourceMod;
|
||||
using namespace SourcePawn;
|
||||
|
||||
class SDKExtension :
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
public ISmmPlugin,
|
||||
#endif
|
||||
public IExtensionInterface
|
||||
{
|
||||
public:
|
||||
/** Constructor */
|
||||
SDKExtension();
|
||||
public:
|
||||
/**
|
||||
* @brief This is called after the initial loading sequence has been processed.
|
||||
*
|
||||
* @param error Error message buffer.
|
||||
* @param maxlength Size of error message buffer.
|
||||
* @param late Whether or not the module was loaded after map load.
|
||||
* @return True to succeed loading, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
|
||||
|
||||
/**
|
||||
* @brief This is called right before the extension is unloaded.
|
||||
*/
|
||||
virtual void SDK_OnUnload();
|
||||
|
||||
/**
|
||||
* @brief This is called once all known extensions have been loaded.
|
||||
*/
|
||||
virtual void SDK_OnAllLoaded();
|
||||
|
||||
/**
|
||||
* @brief Called when the pause state is changed.
|
||||
*/
|
||||
virtual void SDK_OnPauseChange(bool paused);
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
/**
|
||||
* @brief Called when Metamod is attached, before the extension version is called.
|
||||
*
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @param late Whether or not Metamod considers this a late load.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
|
||||
|
||||
/**
|
||||
* @brief Called when Metamod is detaching, after the extension version is called.
|
||||
* NOTE: By default this is blocked unless sent from SourceMod.
|
||||
*
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
|
||||
|
||||
/**
|
||||
* @brief Called when Metamod's pause state is changing.
|
||||
* NOTE: By default this is blocked unless sent from SourceMod.
|
||||
*
|
||||
* @param paused Pause state being set.
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
|
||||
#endif
|
||||
|
||||
public: //IExtensionInterface
|
||||
virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
|
||||
virtual void OnExtensionUnload();
|
||||
virtual void OnExtensionsAllLoaded();
|
||||
|
||||
/** Returns whether or not this is a Metamod-based extension */
|
||||
virtual bool IsMetamodExtension();
|
||||
|
||||
/**
|
||||
* @brief Called when the pause state changes.
|
||||
*
|
||||
* @param state True if being paused, false if being unpaused.
|
||||
*/
|
||||
virtual void OnExtensionPauseChange(bool state);
|
||||
|
||||
/** Returns name */
|
||||
virtual const char *GetExtensionName();
|
||||
/** Returns URL */
|
||||
virtual const char *GetExtensionURL();
|
||||
/** Returns log tag */
|
||||
virtual const char *GetExtensionTag();
|
||||
/** Returns author */
|
||||
virtual const char *GetExtensionAuthor();
|
||||
/** Returns version string */
|
||||
virtual const char *GetExtensionVerString();
|
||||
/** Returns description string */
|
||||
virtual const char *GetExtensionDescription();
|
||||
/** Returns date string */
|
||||
virtual const char *GetExtensionDateString();
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
public: //ISmmPlugin
|
||||
/** Called when the extension is attached to Metamod. */
|
||||
virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
|
||||
/** Returns the author to MM */
|
||||
virtual const char *GetAuthor();
|
||||
/** Returns the name to MM */
|
||||
virtual const char *GetName();
|
||||
/** Returns the description to MM */
|
||||
virtual const char *GetDescription();
|
||||
/** Returns the URL to MM */
|
||||
virtual const char *GetURL();
|
||||
/** Returns the license to MM */
|
||||
virtual const char *GetLicense();
|
||||
/** Returns the version string to MM */
|
||||
virtual const char *GetVersion();
|
||||
/** Returns the date string to MM */
|
||||
virtual const char *GetDate();
|
||||
/** Returns the logtag to MM */
|
||||
virtual const char *GetLogTag();
|
||||
/** Called on unload */
|
||||
virtual bool Unload(char *error, size_t maxlength);
|
||||
/** Called on pause */
|
||||
virtual bool Pause(char *error, size_t maxlength);
|
||||
/** Called on unpause */
|
||||
virtual bool Unpause(char *error, size_t maxlength);
|
||||
private:
|
||||
bool m_SourceMMLoaded;
|
||||
bool m_WeAreUnloaded;
|
||||
bool m_WeGotPauseChange;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern SDKExtension *g_pExtensionIface;
|
||||
extern IExtension *myself;
|
||||
|
||||
extern IShareSys *g_pShareSys;
|
||||
extern IShareSys *sharesys; /* Note: Newer name */
|
||||
extern ISourceMod *g_pSM;
|
||||
extern ISourceMod *smutils; /* Note: Newer name */
|
||||
|
||||
/* Optional interfaces are below */
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
extern IForwardManager *g_pForwards;
|
||||
extern IForwardManager *forwards; /* Note: Newer name */
|
||||
#endif //SMEXT_ENABLE_FORWARDSYS
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
extern IHandleSys *g_pHandleSys;
|
||||
extern IHandleSys *handlesys; /* Note: Newer name */
|
||||
#endif //SMEXT_ENABLE_HANDLESYS
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
extern IPlayerManager *playerhelpers;
|
||||
#endif //SMEXT_ENABLE_PLAYERHELPERS
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
extern IDBManager *dbi;
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
extern IGameConfigManager *gameconfs;
|
||||
#endif //SMEXT_ENABLE_DBMANAGER
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
extern IMemoryUtils *memutils;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
extern IGameHelpers *gamehelpers;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
extern ITimerSystem *timersys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADTFACTORY
|
||||
extern IADTFactory *adtfactory;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
extern IThreader *threader;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
extern ILibrarySys *libsys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
extern SourceMod::IPluginManager *plsys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
extern IMenuManager *menus;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
extern IAdminSystem *adminsys;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_USERMSGS
|
||||
extern IUserMessages *usermsgs;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TRANSLATOR
|
||||
extern ITranslator *translator;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
PLUGIN_GLOBALVARS();
|
||||
extern IVEngineServer *engine;
|
||||
extern IServerGameDLL *gamedll;
|
||||
#endif
|
||||
|
||||
/** Creates a SourceMod interface macro pair */
|
||||
#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
|
||||
/** Automates retrieving SourceMod interfaces */
|
||||
#define SM_GET_IFACE(prefix, addr) \
|
||||
if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
|
||||
{ \
|
||||
if (error != NULL && maxlength) \
|
||||
{ \
|
||||
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
||||
if (len >= maxlength) \
|
||||
{ \
|
||||
error[maxlength - 1] = '\0'; \
|
||||
} \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
|
||||
#define SM_GET_LATE_IFACE(prefix, addr) \
|
||||
g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
|
||||
/** Validates a SourceMod interface pointer */
|
||||
#define SM_CHECK_IFACE(prefix, addr) \
|
||||
if (!addr) \
|
||||
{ \
|
||||
if (error != NULL && maxlength) \
|
||||
{ \
|
||||
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
||||
if (len >= maxlength) \
|
||||
{ \
|
||||
error[maxlength - 1] = '\0'; \
|
||||
} \
|
||||
} \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_PLATFORM_H_
|
||||
#define _INCLUDE_SOURCEMOD_PLATFORM_H_
|
||||
|
||||
/**
|
||||
* @file sm_platform.h
|
||||
* @brief Contains platform-specific macros for abstraction.
|
||||
*/
|
||||
|
||||
#if defined WIN32 || defined WIN64
|
||||
#define PLATFORM_WINDOWS
|
||||
#if !defined WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#if !defined snprintf
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#if !defined stat
|
||||
#define stat _stat
|
||||
#endif
|
||||
#define strcasecmp strcmpi
|
||||
#define strncasecmp strnicmp
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#define PLATFORM_LIB_EXT "dll"
|
||||
#define PLATFORM_MAX_PATH MAX_PATH
|
||||
#define PLATFORM_SEP_CHAR '\\'
|
||||
#define PLATFORM_SEP_ALTCHAR '/'
|
||||
#define PLATFORM_EXTERN_C extern "C" __declspec(dllexport)
|
||||
#if defined _MSC_VER && _MSC_VER >= 1400
|
||||
#define SUBPLATFORM_SECURECRT
|
||||
#endif
|
||||
#elif defined __linux__
|
||||
#define PLATFORM_LINUX
|
||||
#define PLATFORM_POSIX
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/stat.h>
|
||||
#define PLATFORM_MAX_PATH PATH_MAX
|
||||
#define PLATFORM_LIB_EXT "so"
|
||||
#define PLATFORM_SEP_CHAR '/'
|
||||
#define PLATFORM_SEP_ALTCHAR '\\'
|
||||
#define PLATFORM_EXTERN_C extern "C" __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#if !defined SOURCEMOD_BUILD
|
||||
#define SOURCEMOD_BUILD
|
||||
#endif
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_PLATFORM_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,227 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourcePawn
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SPFILE_HEADERS_H
|
||||
#define _INCLUDE_SPFILE_HEADERS_H
|
||||
|
||||
/**
|
||||
* @file sp_file_headers.h
|
||||
* @brief Defines the structure present in a SourcePawn compiled binary.
|
||||
*
|
||||
* Note: These structures should be 1-byte packed to match the file format.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#if defined __GNUC__ || defined HAVE_STDINT_
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#if !defined HAVE_STDINT_H
|
||||
typedef unsigned __int64 uint64_t; /**< 64bit unsigned integer */
|
||||
typedef __int64 int64_t; /**< 64bit signed integer */
|
||||
typedef unsigned __int32 uint32_t; /**< 32bit unsigned integer */
|
||||
typedef __int32 int32_t; /**< 32bit signed integer */
|
||||
typedef unsigned __int16 uint16_t; /**< 16bit unsigned integer */
|
||||
typedef __int16 int16_t; /**< 16bit signed integer */
|
||||
typedef unsigned __int8 uint8_t; /**< 8bit unsigned integer */
|
||||
typedef __int8 int8_t; /**< 8bit signed integer */
|
||||
#define HAVE_STDINT_H
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SPFILE_MAGIC 0x53504646 /**< Source Pawn File Format (SPFF) */
|
||||
#define SPFILE_VERSION 0x0101 /**< Uncompressed bytecode */
|
||||
|
||||
//:TODO: better compiler/nix support
|
||||
#if defined __linux__
|
||||
#pragma pack(1) /* structures must be packed (byte-aligned) */
|
||||
#else
|
||||
#pragma pack(push)
|
||||
#pragma pack(1) /* structures must be packed (byte-aligned) */
|
||||
#endif
|
||||
|
||||
#define SPFILE_COMPRESSION_NONE 0 /**< No compression in file */
|
||||
#define SPFILE_COMPRESSION_GZ 1 /**< GZ compression */
|
||||
|
||||
/**
|
||||
* @brief File section header format.
|
||||
*/
|
||||
typedef struct sp_file_section_s
|
||||
{
|
||||
uint32_t nameoffs; /**< Relative offset into global string table */
|
||||
uint32_t dataoffs; /**< Offset into the data section of the file */
|
||||
uint32_t size; /**< Size of the section's entry in the data section */
|
||||
} sp_file_section_t;
|
||||
|
||||
/**
|
||||
* @brief File header format. If compression is 0, then disksize may be 0
|
||||
* to mean that only the imagesize is needed.
|
||||
*/
|
||||
typedef struct sp_file_hdr_s
|
||||
{
|
||||
uint32_t magic; /**< Magic number */
|
||||
uint16_t version; /**< Version code */
|
||||
uint8_t compression;/**< Compression algorithm */
|
||||
uint32_t disksize; /**< Size on disk */
|
||||
uint32_t imagesize; /**< Size in memory */
|
||||
uint8_t sections; /**< Number of sections */
|
||||
uint32_t stringtab; /**< Offset to string table */
|
||||
uint32_t dataoffs; /**< Offset to file proper (any compression starts here) */
|
||||
} sp_file_hdr_t;
|
||||
|
||||
#define SP_FLAG_DEBUG (1<<0) /**< Debug information is present in the file */
|
||||
|
||||
/**
|
||||
* @brief File-encoded format of the ".code" section.
|
||||
*/
|
||||
typedef struct sp_file_code_s
|
||||
{
|
||||
uint32_t codesize; /**< Codesize in bytes */
|
||||
uint8_t cellsize; /**< Cellsize in bytes */
|
||||
uint8_t codeversion; /**< Version of opcodes supported */
|
||||
uint16_t flags; /**< Flags */
|
||||
uint32_t main; /**< Address to "main," if any */
|
||||
uint32_t code; /**< Relative offset to code */
|
||||
} sp_file_code_t;
|
||||
|
||||
/**
|
||||
* @brief File-encoded format of the ".data" section.
|
||||
*/
|
||||
typedef struct sp_file_data_s
|
||||
{
|
||||
uint32_t datasize; /**< Size of data section in memory */
|
||||
uint32_t memsize; /**< Total mem required (includes data) */
|
||||
uint32_t data; /**< File offset to data (helper) */
|
||||
} sp_file_data_t;
|
||||
|
||||
/**
|
||||
* @brief File-encoded format of the ".publics" section.
|
||||
*/
|
||||
typedef struct sp_file_publics_s
|
||||
{
|
||||
uint32_t address; /**< Address relative to code section */
|
||||
uint32_t name; /**< Index into nametable */
|
||||
} sp_file_publics_t;
|
||||
|
||||
/**
|
||||
* @brief File-encoded format of the ".natives" section.
|
||||
*/
|
||||
typedef struct sp_file_natives_s
|
||||
{
|
||||
uint32_t name; /**< Index into nametable */
|
||||
} sp_file_natives_t;
|
||||
|
||||
/**
|
||||
* @brief File-encoded format of the ".pubvars" section.
|
||||
*/
|
||||
typedef struct sp_file_pubvars_s
|
||||
{
|
||||
uint32_t address; /**< Address relative to the DAT section */
|
||||
uint32_t name; /**< Index into nametable */
|
||||
} sp_file_pubvars_t;
|
||||
|
||||
/**
|
||||
* @brief File-encoded tag info.
|
||||
*/
|
||||
typedef struct sp_file_tag_s
|
||||
{
|
||||
uint32_t tag_id; /**< Tag ID from compiler */
|
||||
uint32_t name; /**< Index into nametable */
|
||||
} sp_file_tag_t;
|
||||
|
||||
#if defined __linux__
|
||||
#pragma pack() /* reset default packing */
|
||||
#else
|
||||
#pragma pack(pop) /* reset previous packing */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief File-encoded debug information table.
|
||||
*/
|
||||
typedef struct sp_fdbg_info_s
|
||||
{
|
||||
uint32_t num_files; /**< number of files */
|
||||
uint32_t num_lines; /**< number of lines */
|
||||
uint32_t num_syms; /**< number of symbols */
|
||||
uint32_t num_arrays; /**< number of symbols which are arrays */
|
||||
} sp_fdbg_info_t;
|
||||
|
||||
/**
|
||||
* @brief File-encoded debug file table.
|
||||
*/
|
||||
typedef struct sp_fdbg_file_s
|
||||
{
|
||||
uint32_t addr; /**< Address into code */
|
||||
uint32_t name; /**< Offset into debug nametable */
|
||||
} sp_fdbg_file_t;
|
||||
|
||||
/**
|
||||
* @brief File-encoded debug line table.
|
||||
*/
|
||||
typedef struct sp_fdbg_line_s
|
||||
{
|
||||
uint32_t addr; /**< Address into code */
|
||||
uint32_t line; /**< Line number */
|
||||
} sp_fdbg_line_t;
|
||||
|
||||
#define SP_SYM_VARIABLE 1 /**< Cell that has an address and that can be fetched directly (lvalue) */
|
||||
#define SP_SYM_REFERENCE 2 /**< VARIABLE, but must be dereferenced */
|
||||
#define SP_SYM_ARRAY 3 /**< Symbol is an array */
|
||||
#define SP_SYM_REFARRAY 4 /**< An array passed by reference (i.e. a pointer) */
|
||||
#define SP_SYM_FUNCTION 9 /**< Symbol is a function */
|
||||
|
||||
/**
|
||||
* @brief File-encoded debug symbol information.
|
||||
*/
|
||||
typedef struct sp_fdbg_symbol_s
|
||||
{
|
||||
int32_t addr; /**< Address rel to DAT or stack frame */
|
||||
int16_t tagid; /**< Tag id */
|
||||
uint32_t codestart; /**< Start scope validity in code */
|
||||
uint32_t codeend; /**< End scope validity in code */
|
||||
uint8_t ident; /**< Variable type */
|
||||
uint8_t vclass; /**< Scope class (local vs global) */
|
||||
uint16_t dimcount; /**< Dimension count (for arrays) */
|
||||
uint32_t name; /**< Offset into debug nametable */
|
||||
} sp_fdbg_symbol_t;
|
||||
|
||||
/**
|
||||
* @brief File-encoded debug symbol array dimension info.
|
||||
*/
|
||||
typedef struct sp_fdbg_arraydim_s
|
||||
{
|
||||
int16_t tagid; /**< Tag id */
|
||||
uint32_t size; /**< Size of dimension */
|
||||
} sp_fdbg_arraydim_t;
|
||||
|
||||
/** Typedef for .names table */
|
||||
typedef char * sp_file_nametab_t;
|
||||
|
||||
#endif //_INCLUDE_SPFILE_HEADERS_H
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourcePawn
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
|
||||
#define _INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
|
||||
|
||||
/**
|
||||
* @file sp_typeutil.h
|
||||
* @brief Defines type utility functions.
|
||||
*/
|
||||
|
||||
#include "sp_vm_types.h"
|
||||
|
||||
/**
|
||||
* @brief Reinterpret-casts a float to a cell (requires -fno-strict-aliasing for GCC).
|
||||
*
|
||||
* @param val Float value.
|
||||
* @return Cell typed version.
|
||||
*/
|
||||
inline cell_t sp_ftoc(float val)
|
||||
{
|
||||
return *(cell_t *)&val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reinterpret-casts a cell to a float (requires -fno-strict-aliasing for GCC).
|
||||
*
|
||||
* @param val Cell-packed float value.
|
||||
* @return Float typed version.
|
||||
*/
|
||||
inline float sp_ctof(cell_t val)
|
||||
{
|
||||
return *(float *)&val;
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourcePawn
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEPAWN_VM_BASE_H_
|
||||
#define _INCLUDE_SOURCEPAWN_VM_BASE_H_
|
||||
|
||||
/**
|
||||
* @file sp_vm_base.h
|
||||
* @brief Contains JIT export/linkage macros.
|
||||
*/
|
||||
|
||||
#include <sp_vm_api.h>
|
||||
|
||||
/* :TODO: rename this to sp_vm_linkage.h */
|
||||
|
||||
#if defined WIN32
|
||||
#define EXPORT_LINK extern "C" __declspec(dllexport)
|
||||
#elif defined __GNUC__
|
||||
#define EXPORT_LINK extern "C" __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
/** No longer used */
|
||||
typedef SourcePawn::IVirtualMachine *(*SP_GETVM_FUNC)(SourcePawn::ISourcePawnEngine *);
|
||||
|
||||
#endif //_INCLUDE_SOURCEPAWN_VM_BASE_H_
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourcePawn
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEPAWN_VM_TYPES_H
|
||||
#define _INCLUDE_SOURCEPAWN_VM_TYPES_H
|
||||
|
||||
/**
|
||||
* @file sp_vm_types.h
|
||||
* @brief Contains all run-time SourcePawn structures.
|
||||
*/
|
||||
|
||||
#include "sp_file_headers.h"
|
||||
|
||||
typedef uint32_t ucell_t; /**< Unsigned 32bit integer */
|
||||
typedef int32_t cell_t; /**< Basic 32bit signed integer type for plugins */
|
||||
typedef uint32_t funcid_t; /**< Function index code */
|
||||
|
||||
#include "sp_typeutil.h"
|
||||
|
||||
#define SP_MAX_EXEC_PARAMS 32 /**< Maximum number of parameters in a function */
|
||||
|
||||
#define SP_JITCONF_DEBUG "debug" /**< Configuration option for debugging. */
|
||||
#define SP_JITCONF_PROFILE "profile" /**< Configuration option for profiling. */
|
||||
|
||||
#define SP_PROF_NATIVES (1<<0) /**< Profile natives. */
|
||||
#define SP_PROF_CALLBACKS (1<<1) /**< Profile callbacks. */
|
||||
#define SP_PROF_FUNCTIONS (1<<2) /**< Profile functions. */
|
||||
|
||||
/**
|
||||
* @brief Error codes for SourcePawn routines.
|
||||
*/
|
||||
#define SP_ERROR_NONE 0 /**< No error occurred */
|
||||
#define SP_ERROR_FILE_FORMAT 1 /**< File format unrecognized */
|
||||
#define SP_ERROR_DECOMPRESSOR 2 /**< A decompressor was not found */
|
||||
#define SP_ERROR_HEAPLOW 3 /**< Not enough space left on the heap */
|
||||
#define SP_ERROR_PARAM 4 /**< Invalid parameter or parameter type */
|
||||
#define SP_ERROR_INVALID_ADDRESS 5 /**< A memory address was not valid */
|
||||
#define SP_ERROR_NOT_FOUND 6 /**< The object in question was not found */
|
||||
#define SP_ERROR_INDEX 7 /**< Invalid index parameter */
|
||||
#define SP_ERROR_STACKLOW 8 /**< Not enough space left on the stack */
|
||||
#define SP_ERROR_NOTDEBUGGING 9 /**< Debug mode was not on or debug section not found */
|
||||
#define SP_ERROR_INVALID_INSTRUCTION 10 /**< Invalid instruction was encountered */
|
||||
#define SP_ERROR_MEMACCESS 11 /**< Invalid memory access */
|
||||
#define SP_ERROR_STACKMIN 12 /**< Stack went beyond its minimum value */
|
||||
#define SP_ERROR_HEAPMIN 13 /**< Heap went beyond its minimum value */
|
||||
#define SP_ERROR_DIVIDE_BY_ZERO 14 /**< Division by zero */
|
||||
#define SP_ERROR_ARRAY_BOUNDS 15 /**< Array index is out of bounds */
|
||||
#define SP_ERROR_INSTRUCTION_PARAM 16 /**< Instruction had an invalid parameter */
|
||||
#define SP_ERROR_STACKLEAK 17 /**< A native leaked an item on the stack */
|
||||
#define SP_ERROR_HEAPLEAK 18 /**< A native leaked an item on the heap */
|
||||
#define SP_ERROR_ARRAY_TOO_BIG 19 /**< A dynamic array is too big */
|
||||
#define SP_ERROR_TRACKER_BOUNDS 20 /**< Tracker stack is out of bounds */
|
||||
#define SP_ERROR_INVALID_NATIVE 21 /**< Native was pending or invalid */
|
||||
#define SP_ERROR_PARAMS_MAX 22 /**< Maximum number of parameters reached */
|
||||
#define SP_ERROR_NATIVE 23 /**< Error originates from a native */
|
||||
#define SP_ERROR_NOT_RUNNABLE 24 /**< Function or plugin is not runnable */
|
||||
#define SP_ERROR_ABORTED 25 /**< Function call was aborted */
|
||||
//Hey you! Update the string table if you add to the end of me! */
|
||||
|
||||
/**********************************************
|
||||
*** The following structures are reference structures.
|
||||
*** They are not essential to the API, but are used
|
||||
*** to hold the back end database format of the plugin
|
||||
*** binary.
|
||||
**********************************************/
|
||||
|
||||
/**
|
||||
* @brief Information about the core plugin tables. These may or may not be present!
|
||||
*/
|
||||
typedef struct sp_plugin_infotab_s
|
||||
{
|
||||
const char *stringbase; /**< base of string table */
|
||||
uint32_t publics_num; /**< number of publics */
|
||||
sp_file_publics_t *publics; /**< public table */
|
||||
uint32_t natives_num; /**< number of natives */
|
||||
sp_file_natives_t *natives; /**< native table */
|
||||
uint32_t pubvars_num; /**< number of pubvars */
|
||||
sp_file_pubvars_t *pubvars; /**< pubvars table */
|
||||
} sp_plugin_infotab_t;
|
||||
|
||||
/**
|
||||
* @brief Information about the plugin's debug tables. These are all present if one is present.
|
||||
*/
|
||||
typedef struct sp_plugin_debug_s
|
||||
{
|
||||
const char *stringbase; /**< base of string table */
|
||||
uint32_t files_num; /**< number of files */
|
||||
sp_fdbg_file_t *files; /**< files table */
|
||||
uint32_t lines_num; /**< number of lines */
|
||||
sp_fdbg_line_t *lines; /**< lines table */
|
||||
uint32_t syms_num; /**< number of symbols */
|
||||
sp_fdbg_symbol_t *symbols; /**< symbol table */
|
||||
} sp_plugin_debug_t;
|
||||
|
||||
#define SP_FA_SELF_EXTERNAL (1<<0) /**< Allocation of structure is external */
|
||||
#define SP_FA_BASE_EXTERNAL (1<<1) /**< Allocation of base is external */
|
||||
|
||||
/**
|
||||
* @brief The rebased memory format of a plugin. This differs from the on-disk structure
|
||||
* to ensure that the format is properly read.
|
||||
*/
|
||||
typedef struct sp_plugin_s
|
||||
{
|
||||
uint8_t *base; /**< Base of memory for this plugin. */
|
||||
uint8_t *pcode; /**< P-Code of plugin */
|
||||
uint32_t pcode_size; /**< Size of p-code */
|
||||
uint8_t *data; /**< Data/memory layout */
|
||||
uint32_t data_size; /**< Size of data */
|
||||
uint32_t memory; /**< Required memory space */
|
||||
uint16_t flags; /**< Code flags */
|
||||
uint32_t allocflags; /**< Allocation flags */
|
||||
sp_plugin_infotab_t info; /**< Base info table */
|
||||
sp_plugin_debug_t debug; /**< Debug info table */
|
||||
} sp_plugin_t;
|
||||
|
||||
|
||||
namespace SourcePawn
|
||||
{
|
||||
class IPluginContext;
|
||||
class IVirtualMachine;
|
||||
class IProfiler;
|
||||
};
|
||||
|
||||
struct sp_context_s;
|
||||
|
||||
/**
|
||||
* @brief Native callback prototype, passed a context and a parameter stack (0=count, 1+=args).
|
||||
* A cell must be returned.
|
||||
*/
|
||||
typedef cell_t (*SPVM_NATIVE_FUNC)(SourcePawn::IPluginContext *, const cell_t *);
|
||||
|
||||
/**
|
||||
* @brief Fake native callback prototype, passed a context, parameter stack, and private data.
|
||||
* A cell must be returned.
|
||||
*/
|
||||
typedef cell_t (*SPVM_FAKENATIVE_FUNC)(SourcePawn::IPluginContext *, const cell_t *, void *);
|
||||
|
||||
/**********************************************
|
||||
*** The following structures are bound to the VM/JIT.
|
||||
*** Changing them will result in necessary recompilation.
|
||||
**********************************************/
|
||||
|
||||
/**
|
||||
* @brief Offsets and names to a public function.
|
||||
*/
|
||||
typedef struct sp_public_s
|
||||
{
|
||||
funcid_t funcid; /**< Encoded function id */
|
||||
uint32_t code_offs; /**< Relocated code offset */
|
||||
const char *name; /**< Name of function */
|
||||
} sp_public_t;
|
||||
|
||||
/**
|
||||
* @brief Offsets and names to public variables.
|
||||
*
|
||||
* The offset is relocated and the name by default points back to the sp_plugin_infotab_t structure.
|
||||
*/
|
||||
typedef struct sp_pubvar_s
|
||||
{
|
||||
cell_t *offs; /**< Pointer to data */
|
||||
const char *name; /**< Name */
|
||||
} sp_pubvar_t;
|
||||
|
||||
#define SP_NATIVE_UNBOUND (0) /**< Native is undefined */
|
||||
#define SP_NATIVE_BOUND (1) /**< Native is bound */
|
||||
|
||||
#define SP_NTVFLAG_OPTIONAL (1<<0) /**< Native is optional */
|
||||
|
||||
/**
|
||||
* @brief Native lookup table, by default names point back to the sp_plugin_infotab_t structure.
|
||||
*/
|
||||
typedef struct sp_native_s
|
||||
{
|
||||
SPVM_NATIVE_FUNC pfn; /**< Function pointer */
|
||||
const char * name; /**< Name of function */
|
||||
uint32_t status; /**< Status flags */
|
||||
uint32_t flags; /**< Native flags */
|
||||
void * user; /**< Host-specific data */
|
||||
} sp_native_t;
|
||||
|
||||
/**
|
||||
* @brief Used for setting natives from modules/host apps.
|
||||
*/
|
||||
typedef struct sp_nativeinfo_s
|
||||
{
|
||||
const char *name; /**< Name of the native */
|
||||
SPVM_NATIVE_FUNC func; /**< Address of native implementation */
|
||||
} sp_nativeinfo_t;
|
||||
|
||||
/**
|
||||
* @brief Run-time debug file table
|
||||
*/
|
||||
typedef struct sp_debug_file_s
|
||||
{
|
||||
uint32_t addr; /**< Address into code */
|
||||
const char * name; /**< Name of file */
|
||||
} sp_debug_file_t;
|
||||
|
||||
/**
|
||||
* @brief Contains run-time debug line table.
|
||||
*/
|
||||
typedef struct sp_debug_line_s
|
||||
{
|
||||
uint32_t addr; /**< Address into code */
|
||||
uint32_t line; /**< Line number */
|
||||
} sp_debug_line_t;
|
||||
|
||||
/**
|
||||
* @brief These structures are equivalent.
|
||||
*/
|
||||
typedef sp_fdbg_arraydim_t sp_debug_arraydim_t;
|
||||
|
||||
/**
|
||||
* @brief The majority of this struct is already located in the parent
|
||||
* block. Thus, only the relocated portions are required.
|
||||
*/
|
||||
typedef struct sp_debug_symbol_s
|
||||
{
|
||||
uint32_t codestart; /**< Relocated code address */
|
||||
uint32_t codeend; /**< Relocated code end address */
|
||||
const char * name; /**< Relocated name */
|
||||
sp_debug_arraydim_t *dims; /**< Relocated dimension struct, if any */
|
||||
sp_fdbg_symbol_t *sym; /**< Pointer to original symbol */
|
||||
} sp_debug_symbol_t;
|
||||
|
||||
/**
|
||||
* Breaks into a debugger
|
||||
* Params:
|
||||
* [0] - plugin context
|
||||
* [1] - frm
|
||||
* [2] - cip
|
||||
*/
|
||||
typedef int (*SPVM_DEBUGBREAK)(struct sp_context_s *, uint32_t, uint32_t);
|
||||
|
||||
#define SPFLAG_PLUGIN_DEBUG (1<<0) /**< plugin is in debug mode */
|
||||
#define SPFLAG_PLUGIN_PAUSED (1<<1) /**< plugin is "paused" (blocked from executing) */
|
||||
|
||||
/**
|
||||
* @brief This is the heart of the VM. It contains all of the runtime
|
||||
* information about a plugin context. Note that user[0..3] can be used for any user based pointers.
|
||||
* However, vm[0..3] should not be touched, as it is reserved for the VM.
|
||||
*/
|
||||
typedef struct sp_context_s
|
||||
{
|
||||
void *codebase; /**< Base of generated code and memory */
|
||||
sp_plugin_t *plugin; /**< Pointer back to parent information */
|
||||
SourcePawn::IPluginContext *context; /**< Pointer to IPluginContext */
|
||||
SourcePawn::IVirtualMachine *vmbase; /**< Pointer to IVirtualMachine */
|
||||
void *user[4]; /**< User specific pointers */
|
||||
void *vm[4]; /**< VM specific pointers */
|
||||
uint32_t flags; /**< Compilation flags */
|
||||
SPVM_DEBUGBREAK dbreak; /**< Debug break function */
|
||||
uint8_t *memory; /**< Data chunk */
|
||||
ucell_t mem_size; /**< Total memory size; */
|
||||
cell_t data_size; /**< Data chunk size, always starts at 0 */
|
||||
cell_t heap_base; /**< Where the heap starts */
|
||||
cell_t hp; /**< Heap pointer */
|
||||
cell_t sp; /**< Stack pointer */
|
||||
cell_t frm; /**< Frame pointer */
|
||||
uint32_t pushcount; /**< Push count */
|
||||
int32_t n_err; /**< Error code set by a native */
|
||||
uint32_t n_idx; /**< Current native index being executed */
|
||||
sp_public_t *publics; /**< Public functions table */
|
||||
sp_pubvar_t *pubvars; /**< Public variables table */
|
||||
sp_native_t *natives; /**< Natives table */
|
||||
sp_debug_file_t *files; /**< Files */
|
||||
sp_debug_line_t *lines; /**< Lines */
|
||||
sp_debug_symbol_t *symbols; /**< Symbols */
|
||||
SourcePawn::IProfiler *profiler; /**< Pointer to IProfiler */
|
||||
uint32_t prof_flags; /**< Profiling flags */
|
||||
} sp_context_t;
|
||||
|
||||
#endif //_INCLUDE_SOURCEPAWN_VM_TYPES_H
|
||||
Reference in New Issue
Block a user