Added more missing svn:keywords properties to some files (this should be the last of them before I never have to do this again)

Moved sm_memtable files in sqlite extension to sdk directory (to be consistent with topmenus)
Some extension source files had an incorrect extension name in their headers

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402037
This commit is contained in:
Scott Ehlert 2008-04-11 17:16:36 +00:00
parent 0c5e4b5a2f
commit c473d75d3d
61 changed files with 3599 additions and 3443 deletions

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SDKTools Extension * SourceMod Counter-Strike:Source Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SDKTools Extension * SourceMod Counter-Strike:Source Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,155 +1,155 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SQLite Extension * SourceMod Regular Expressions Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * 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 * the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation. * Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
* *
* As a special exception, AlliedModders LLC gives you permission to link the * 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 * 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 * "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 * by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants * all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id$ * Version: $Id$
*/ */
#include "pcre.h" #include "pcre.h"
#include "CRegEx.h" #include "CRegEx.h"
#include <sh_string.h> #include <sh_string.h>
#include "extension.h" #include "extension.h"
RegEx::RegEx() RegEx::RegEx()
{ {
mErrorOffset = 0; mErrorOffset = 0;
mError = NULL; mError = NULL;
re = NULL; re = NULL;
mFree = true; mFree = true;
subject = NULL; subject = NULL;
mSubStrings = 0; mSubStrings = 0;
} }
void RegEx::Clear () void RegEx::Clear ()
{ {
mErrorOffset = 0; mErrorOffset = 0;
mError = NULL; mError = NULL;
if (re) if (re)
pcre_free(re); pcre_free(re);
re = NULL; re = NULL;
mFree = true; mFree = true;
if (subject) if (subject)
delete [] subject; delete [] subject;
subject = NULL; subject = NULL;
mSubStrings = 0; mSubStrings = 0;
} }
RegEx::~RegEx() RegEx::~RegEx()
{ {
Clear(); Clear();
} }
bool RegEx::isFree(bool set, bool val) bool RegEx::isFree(bool set, bool val)
{ {
if (set) if (set)
{ {
mFree = val; mFree = val;
return true; return true;
} else { } else {
return mFree; return mFree;
} }
} }
int RegEx::Compile(const char *pattern, int iFlags) int RegEx::Compile(const char *pattern, int iFlags)
{ {
if (!mFree) if (!mFree)
Clear(); Clear();
re = pcre_compile(pattern, iFlags, &mError, &mErrorOffset, NULL); re = pcre_compile(pattern, iFlags, &mError, &mErrorOffset, NULL);
if (re == NULL) if (re == NULL)
{ {
return 0; return 0;
} }
mFree = false; mFree = false;
return 1; return 1;
} }
int RegEx::Match(const char *str) int RegEx::Match(const char *str)
{ {
int rc = 0; int rc = 0;
if (mFree || re == NULL) if (mFree || re == NULL)
return -1; return -1;
this->ClearMatch(); this->ClearMatch();
//save str //save str
subject = new char[strlen(str)+1]; subject = new char[strlen(str)+1];
strcpy(subject, str); strcpy(subject, str);
rc = pcre_exec(re, NULL, subject, (int)strlen(subject), 0, 0, ovector, 30); rc = pcre_exec(re, NULL, subject, (int)strlen(subject), 0, 0, ovector, 30);
if (rc < 0) if (rc < 0)
{ {
if (rc == PCRE_ERROR_NOMATCH) if (rc == PCRE_ERROR_NOMATCH)
{ {
return 0; return 0;
} else { } else {
mErrorOffset = rc; mErrorOffset = rc;
return -1; return -1;
} }
} }
mSubStrings = rc; mSubStrings = rc;
return 1; return 1;
} }
void RegEx::ClearMatch() void RegEx::ClearMatch()
{ {
// Clears match results // Clears match results
mErrorOffset = 0; mErrorOffset = 0;
mError = NULL; mError = NULL;
if (subject) if (subject)
delete [] subject; delete [] subject;
subject = NULL; subject = NULL;
mSubStrings = 0; mSubStrings = 0;
} }
const char *RegEx::GetSubstring(int s, char buffer[], int max) const char *RegEx::GetSubstring(int s, char buffer[], int max)
{ {
int i = 0; int i = 0;
if (s >= mSubStrings || s < 0) if (s >= mSubStrings || s < 0)
return NULL; return NULL;
char *substr_a = subject + ovector[2*s]; char *substr_a = subject + ovector[2*s];
int substr_l = ovector[2*s+1] - ovector[2*s]; int substr_l = ovector[2*s+1] - ovector[2*s];
for (i = 0; i<substr_l; i++) for (i = 0; i<substr_l; i++)
{ {
if (i >= max) if (i >= max)
break; break;
buffer[i] = substr_a[i]; buffer[i] = substr_a[i];
} }
buffer[i] = '\0'; buffer[i] = '\0';
return buffer; return buffer;
} }

View File

@ -1,59 +1,59 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SQLite Extension * SourceMod Regular Expressions Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * 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 * the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation. * Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
* *
* As a special exception, AlliedModders LLC gives you permission to link the * 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 * 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 * "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 * by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants * all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id$ * Version: $Id$
*/ */
#ifndef _INCLUDE_CREGEX_H #ifndef _INCLUDE_CREGEX_H
#define _INCLUDE_CREGEX_H #define _INCLUDE_CREGEX_H
class RegEx class RegEx
{ {
public: public:
RegEx(); RegEx();
~RegEx(); ~RegEx();
bool isFree(bool set=false, bool val=false); bool isFree(bool set=false, bool val=false);
void Clear(); void Clear();
int Compile(const char *pattern, int iFlags); int Compile(const char *pattern, int iFlags);
int Match(const char *str); int Match(const char *str);
void ClearMatch(); void ClearMatch();
const char *GetSubstring(int s, char buffer[], int max); const char *GetSubstring(int s, char buffer[], int max);
public: public:
int mErrorOffset; int mErrorOffset;
const char *mError; const char *mError;
int mSubStrings; int mSubStrings;
private: private:
pcre *re; pcre *re;
bool mFree; bool mFree;
int ovector[30]; int ovector[30];
char *subject; char *subject;
}; };
#endif //_INCLUDE_CREGEX_H #endif //_INCLUDE_CREGEX_H

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod Regular Expressions Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
@ -38,7 +38,7 @@ using namespace SourceHook;
/** /**
* @file extension.cpp * @file extension.cpp
* @brief Implement extension code here. * @brief Implement Regex extension code here.
*/ */
RegexExtension g_RegexExtension; /**< Global singleton for extension's main interface */ RegexExtension g_RegexExtension; /**< Global singleton for extension's main interface */

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod Regular Expressions Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
@ -34,7 +34,7 @@
/** /**
* @file extension.h * @file extension.h
* @brief Sample extension code header. * @brief Regex extension code header.
*/ */
#include "smsdk_ext.h" #include "smsdk_ext.h"

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod Regular Expressions Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SQLite Extension * SourceMod Regular Expressions Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SQLite Extension * SourceMod Regular Expressions Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SDKTools Extension * SourceMod SDKTools Extension
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under

View File

@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SDKTools Extension * SourceMod SDKTools Extension
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under

View File

@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SDKTools Extension * SourceMod SDKTools Extension
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under

View File

@ -2,7 +2,7 @@
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SDKTools Extension * SourceMod SDKTools Extension
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under

View File

@ -17,7 +17,7 @@ PROJECT = dbi.sqlite
#Uncomment for Metamod: Source enabled extension #Uncomment for Metamod: Source enabled extension
#USEMETA = true #USEMETA = true
OBJECTS = sdk/smsdk_ext.cpp extension.cpp sm_memtable.cpp \ OBJECTS = sdk/smsdk_ext.cpp sdk/sm_memtable.cpp extension.cpp \
driver/SqDatabase.cpp driver/SqDriver.cpp driver/SqQuery.cpp \ driver/SqDatabase.cpp driver/SqDriver.cpp driver/SqQuery.cpp \
driver/SqResults.cpp driver/SqResults.cpp

View File

@ -189,10 +189,6 @@
RelativePath="..\extension.cpp" RelativePath="..\extension.cpp"
> >
</File> </File>
<File
RelativePath="..\sm_memtable.cpp"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
@ -203,10 +199,6 @@
RelativePath="..\extension.h" RelativePath="..\extension.h"
> >
</File> </File>
<File
RelativePath="..\sm_memtable.h"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Resource Files" Name="Resource Files"
@ -226,6 +218,14 @@
Name="SourceMod SDK" Name="SourceMod SDK"
UniqueIdentifier="{31958233-BB2D-4e41-A8F9-CE8A4684F436}" UniqueIdentifier="{31958233-BB2D-4e41-A8F9-CE8A4684F436}"
> >
<File
RelativePath="..\sdk\sm_memtable.cpp"
>
</File>
<File
RelativePath="..\sdk\sm_memtable.h"
>
</File>
<File <File
RelativePath="..\sdk\smsdk_config.h" RelativePath="..\sdk\smsdk_config.h"
> >

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod TF2 Extension * SourceMod Team Fortress 2 Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod TF2 Extension * SourceMod Team Fortress 2 Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SDKTools Extension * SourceMod Team Fortress 2 Extension
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Team Fortress 2 Extension * SourceMod Base Extension Code
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Team Fortress 2 Extension * SourceMod Base Extension Code
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SDKTools Extension * SourceMod Team Fortress 2 Extension
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under

View File

@ -1,8 +1,8 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SDKTools Extension * SourceMod Team Fortress 2 Extension
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * This program is free software; you can redistribute it and/or modify it under

View File

@ -17,8 +17,8 @@ PROJECT = topmenus
#Uncomment for Metamod: Source enabled extension #Uncomment for Metamod: Source enabled extension
#USEMETA = true #USEMETA = true
OBJECTS = sdk/smsdk_ext.cpp extension.cpp TopMenuManager.cpp TopMenu.cpp \ OBJECTS = sdk/smsdk_ext.cpp sdk/sm_memtable.cpp extension.cpp TopMenuManager.cpp \
sdk/sm_memtable.cpp smn_topmenus.cpp TopMenu.cpp smn_topmenus.cpp
############################################## ##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###

File diff suppressed because it is too large Load Diff

View File

@ -1,181 +1,181 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * 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 * the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation. * Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
* *
* As a special exception, AlliedModders LLC gives you permission to link the * 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 * 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 * "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 * by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants * all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id$ * Version: $Id$
*/ */
#ifndef _INCLUDE_SOURCEMOD_TOP_MENU_H_ #ifndef _INCLUDE_SOURCEMOD_TOP_MENU_H_
#define _INCLUDE_SOURCEMOD_TOP_MENU_H_ #define _INCLUDE_SOURCEMOD_TOP_MENU_H_
#include <sh_list.h> #include <sh_list.h>
#include <sh_vector.h> #include <sh_vector.h>
#include <sm_trie_tpl.h> #include <sm_trie_tpl.h>
#include <ITopMenus.h> #include <ITopMenus.h>
#include "smsdk_ext.h" #include "smsdk_ext.h"
#include "sm_memtable.h" #include "sm_memtable.h"
using namespace SourceHook; using namespace SourceHook;
using namespace SourceMod; using namespace SourceMod;
struct config_category_t struct config_category_t
{ {
int name; int name;
CVector<int> commands; CVector<int> commands;
}; };
struct config_root_t struct config_root_t
{ {
config_root_t() : strings(1024) config_root_t() : strings(1024)
{ {
} }
BaseStringTable strings; BaseStringTable strings;
CVector<config_category_t *> cats; CVector<config_category_t *> cats;
}; };
struct topmenu_object_t struct topmenu_object_t
{ {
char name[64]; /** Name */ char name[64]; /** Name */
char cmdname[64]; /** Command name */ char cmdname[64]; /** Command name */
FlagBits flags; /** Admin flags */ FlagBits flags; /** Admin flags */
ITopMenuObjectCallbacks *callbacks; /** Callbacks */ ITopMenuObjectCallbacks *callbacks; /** Callbacks */
IdentityToken_t *owner; /** Owner */ IdentityToken_t *owner; /** Owner */
unsigned int object_id; /** Object ID */ unsigned int object_id; /** Object ID */
topmenu_object_t *parent; /** Parent, if any */ topmenu_object_t *parent; /** Parent, if any */
TopMenuObjectType type; /** Object Type */ TopMenuObjectType type; /** Object Type */
bool is_free; /** Free or not? */ bool is_free; /** Free or not? */
char info[255]; /** Info string */ char info[255]; /** Info string */
}; };
struct topmenu_category_t struct topmenu_category_t
{ {
CVector<topmenu_object_t *> obj_list; /** Full object list */ CVector<topmenu_object_t *> obj_list; /** Full object list */
CVector<topmenu_object_t *> sorted; /** Sorted items */ CVector<topmenu_object_t *> sorted; /** Sorted items */
CVector<topmenu_object_t *> unsorted; /** Unsorted items */ CVector<topmenu_object_t *> unsorted; /** Unsorted items */
topmenu_object_t *obj; /** Bound object */ topmenu_object_t *obj; /** Bound object */
unsigned int serial; /** Serial number */ unsigned int serial; /** Serial number */
bool reorder; /** Whether ordering needs updating */ bool reorder; /** Whether ordering needs updating */
}; };
struct topmenu_player_category_t struct topmenu_player_category_t
{ {
IBaseMenu *menu; /** menu pointer */ IBaseMenu *menu; /** menu pointer */
unsigned int serial; /** last known serial */ unsigned int serial; /** last known serial */
}; };
struct topmenu_player_t struct topmenu_player_t
{ {
int user_id; /** userid on server */ int user_id; /** userid on server */
unsigned int menu_serial; /** menu serial no */ unsigned int menu_serial; /** menu serial no */
IBaseMenu *root; /** root menu display */ IBaseMenu *root; /** root menu display */
topmenu_player_category_t *cats; /** category display */ topmenu_player_category_t *cats; /** category display */
unsigned int cat_count; /** number of categories */ unsigned int cat_count; /** number of categories */
unsigned int last_category; /** last category they selected */ unsigned int last_category; /** last category they selected */
unsigned int last_position; /** last position in that category */ unsigned int last_position; /** last position in that category */
unsigned int last_root_pos; /** last page in the root menu */ unsigned int last_root_pos; /** last page in the root menu */
}; };
class TopMenu : class TopMenu :
public ITopMenu, public ITopMenu,
public IMenuHandler, public IMenuHandler,
public ITextListener_SMC public ITextListener_SMC
{ {
friend class TopMenuManager; friend class TopMenuManager;
public: public:
TopMenu(ITopMenuObjectCallbacks *callbacks); TopMenu(ITopMenuObjectCallbacks *callbacks);
~TopMenu(); ~TopMenu();
public: //ITopMenu public: //ITopMenu
virtual unsigned int AddToMenu(const char *name, virtual unsigned int AddToMenu(const char *name,
TopMenuObjectType type, TopMenuObjectType type,
ITopMenuObjectCallbacks *callbacks, ITopMenuObjectCallbacks *callbacks,
IdentityToken_t *owner, IdentityToken_t *owner,
const char *cmdname, const char *cmdname,
FlagBits flags, FlagBits flags,
unsigned int parent); unsigned int parent);
unsigned int AddToMenu2(const char *name, unsigned int AddToMenu2(const char *name,
TopMenuObjectType type, TopMenuObjectType type,
ITopMenuObjectCallbacks *callbacks, ITopMenuObjectCallbacks *callbacks,
IdentityToken_t *owner, IdentityToken_t *owner,
const char *cmdname, const char *cmdname,
FlagBits flags, FlagBits flags,
unsigned int parent, unsigned int parent,
const char *info_string); const char *info_string);
virtual void RemoveFromMenu(unsigned int object_id); virtual void RemoveFromMenu(unsigned int object_id);
virtual bool DisplayMenu(int client, virtual bool DisplayMenu(int client,
unsigned int hold_time, unsigned int hold_time,
TopMenuPosition position); TopMenuPosition position);
virtual bool LoadConfiguration(const char *file, char *error, size_t maxlength); virtual bool LoadConfiguration(const char *file, char *error, size_t maxlength);
virtual unsigned int FindCategory(const char *name); virtual unsigned int FindCategory(const char *name);
const char *GetObjectInfoString(unsigned int object_id); const char *GetObjectInfoString(unsigned int object_id);
const char *GetObjectName(unsigned int object_id); const char *GetObjectName(unsigned int object_id);
public: //IMenuHandler public: //IMenuHandler
virtual void OnMenuSelect2(IBaseMenu *menu, int client, unsigned int item, unsigned int item_on_page); virtual void OnMenuSelect2(IBaseMenu *menu, int client, unsigned int item, unsigned int item_on_page);
virtual void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style); virtual void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
virtual unsigned int OnMenuDisplayItem(IBaseMenu *menu, virtual unsigned int OnMenuDisplayItem(IBaseMenu *menu,
int client, int client,
IMenuPanel *panel, IMenuPanel *panel,
unsigned int item, unsigned int item,
const ItemDrawInfo &dr); const ItemDrawInfo &dr);
virtual void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason); virtual void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason);
public: //ITextListener_SMC public: //ITextListener_SMC
void ReadSMC_ParseStart(); void ReadSMC_ParseStart();
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name); SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value); SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
SMCResult ReadSMC_LeavingSection(const SMCStates *states); SMCResult ReadSMC_LeavingSection(const SMCStates *states);
public: public:
unsigned int CalcMemUsage(); unsigned int CalcMemUsage();
private: private:
void SortCategoriesIfNeeded(); void SortCategoriesIfNeeded();
void SortCategoryIfNeeded(unsigned int category); void SortCategoryIfNeeded(unsigned int category);
private: private:
bool DisplayCategory(int client, unsigned int category, unsigned int hold_time, bool last_position); bool DisplayCategory(int client, unsigned int category, unsigned int hold_time, bool last_position);
void CreatePlayers(int max_clients); void CreatePlayers(int max_clients);
void UpdateClientRoot(int client, IGamePlayer *pGamePlayer=NULL); void UpdateClientRoot(int client, IGamePlayer *pGamePlayer=NULL);
void UpdateClientCategory(int client, unsigned int category); void UpdateClientCategory(int client, unsigned int category);
void TearDownClient(topmenu_player_t *player); void TearDownClient(topmenu_player_t *player);
private: private:
void OnClientConnected(int client); void OnClientConnected(int client);
void OnClientDisconnected(int client); void OnClientDisconnected(int client);
void OnServerActivated(int max_clients); void OnServerActivated(int max_clients);
bool OnIdentityRemoval(IdentityToken_t *owner); bool OnIdentityRemoval(IdentityToken_t *owner);
private: private:
config_root_t m_Config; /* Configuration from file */ config_root_t m_Config; /* Configuration from file */
topmenu_player_t *m_clients; /* Client array */ topmenu_player_t *m_clients; /* Client array */
CVector<unsigned int> m_SortedCats; /* Sorted categories */ CVector<unsigned int> m_SortedCats; /* Sorted categories */
CVector<unsigned int> m_UnsortedCats; /* Un-sorted categories */ CVector<unsigned int> m_UnsortedCats; /* Un-sorted categories */
CVector<topmenu_category_t *> m_Categories; /* Category array */ CVector<topmenu_category_t *> m_Categories; /* Category array */
CVector<topmenu_object_t *> m_Objects; /* Object array */ CVector<topmenu_object_t *> m_Objects; /* Object array */
KTrie<topmenu_object_t *> m_ObjLookup; /* Object lookup trie */ KTrie<topmenu_object_t *> m_ObjLookup; /* Object lookup trie */
unsigned int m_SerialNo; /* Serial number for updating */ unsigned int m_SerialNo; /* Serial number for updating */
ITopMenuObjectCallbacks *m_pTitle; /* Title callbacks */ ITopMenuObjectCallbacks *m_pTitle; /* Title callbacks */
int m_max_clients; /* Maximum number of clients */ int m_max_clients; /* Maximum number of clients */
bool m_bCatsNeedResort; /* True if categories need a resort */ bool m_bCatsNeedResort; /* True if categories need a resort */
}; };
unsigned int strncopy(char *dest, const char *src, size_t count); unsigned int strncopy(char *dest, const char *src, size_t count);
#endif //_INCLUDE_SOURCEMOD_TOP_MENU_H_ #endif //_INCLUDE_SOURCEMOD_TOP_MENU_H_

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,388 +1,388 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * 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 * the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation. * Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
* *
* As a special exception, AlliedModders LLC gives you permission to link the * 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 * 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 * "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 * by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants * all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id$ * Version: $Id$
*/ */
#include "extension.h" #include "extension.h"
#include "TopMenuManager.h" #include "TopMenuManager.h"
#include "TopMenu.h" #include "TopMenu.h"
HandleType_t hTopMenuType; HandleType_t hTopMenuType;
class TopMenuHandle : public IHandleTypeDispatch class TopMenuHandle : public IHandleTypeDispatch
{ {
public: public:
void OnHandleDestroy(HandleType_t type, void *object) void OnHandleDestroy(HandleType_t type, void *object)
{ {
ITopMenu *pTopMenu = (ITopMenu *)object; ITopMenu *pTopMenu = (ITopMenu *)object;
g_TopMenus.DestroyTopMenu(pTopMenu); g_TopMenus.DestroyTopMenu(pTopMenu);
} }
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize) bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize)
{ {
*pSize = ((TopMenu *)object)->CalcMemUsage(); *pSize = ((TopMenu *)object)->CalcMemUsage();
return true; return true;
} }
} s_TopMenuHandle; } s_TopMenuHandle;
void Initialize_Natives() void Initialize_Natives()
{ {
hTopMenuType = handlesys->CreateType("ITopMenu", hTopMenuType = handlesys->CreateType("ITopMenu",
&s_TopMenuHandle, &s_TopMenuHandle,
0, 0,
NULL, NULL,
NULL, NULL,
myself->GetIdentity(), myself->GetIdentity(),
NULL); NULL);
} }
void Shutdown_Natives() void Shutdown_Natives()
{ {
handlesys->RemoveType(hTopMenuType, myself->GetIdentity()); handlesys->RemoveType(hTopMenuType, myself->GetIdentity());
} }
enum TopMenuAction enum TopMenuAction
{ {
TopMenuAction_DisplayOption = 0, TopMenuAction_DisplayOption = 0,
TopMenuAction_DisplayTitle = 1, TopMenuAction_DisplayTitle = 1,
TopMenuAction_SelectOption = 2, TopMenuAction_SelectOption = 2,
TopMenuAction_DrawOption = 3, TopMenuAction_DrawOption = 3,
TopMenuAction_RemoveObject = 4, TopMenuAction_RemoveObject = 4,
}; };
class TopMenuCallbacks : public ITopMenuObjectCallbacks class TopMenuCallbacks : public ITopMenuObjectCallbacks
{ {
public: public:
TopMenuCallbacks(IPluginFunction *pFunction) : m_pFunction(pFunction) TopMenuCallbacks(IPluginFunction *pFunction) : m_pFunction(pFunction)
{ {
} }
unsigned int OnTopMenuDrawOption(ITopMenu *menu, unsigned int OnTopMenuDrawOption(ITopMenu *menu,
int client, int client,
unsigned int object_id) unsigned int object_id)
{ {
char buffer[2] = {ITEMDRAW_DEFAULT, 0x0}; char buffer[2] = {ITEMDRAW_DEFAULT, 0x0};
m_pFunction->PushCell(m_hMenuHandle); m_pFunction->PushCell(m_hMenuHandle);
m_pFunction->PushCell(TopMenuAction_DrawOption); m_pFunction->PushCell(TopMenuAction_DrawOption);
m_pFunction->PushCell(object_id); m_pFunction->PushCell(object_id);
m_pFunction->PushCell(client); m_pFunction->PushCell(client);
m_pFunction->PushStringEx(buffer, sizeof(buffer), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); m_pFunction->PushStringEx(buffer, sizeof(buffer), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
m_pFunction->PushCell(sizeof(buffer)); m_pFunction->PushCell(sizeof(buffer));
m_pFunction->Execute(NULL); m_pFunction->Execute(NULL);
return (unsigned int)buffer[0]; return (unsigned int)buffer[0];
} }
void OnTopMenuDisplayOption(ITopMenu *menu, void OnTopMenuDisplayOption(ITopMenu *menu,
int client, int client,
unsigned int object_id, unsigned int object_id,
char buffer[], char buffer[],
size_t maxlength) size_t maxlength)
{ {
m_pFunction->PushCell(m_hMenuHandle); m_pFunction->PushCell(m_hMenuHandle);
m_pFunction->PushCell(TopMenuAction_DisplayOption); m_pFunction->PushCell(TopMenuAction_DisplayOption);
m_pFunction->PushCell(object_id); m_pFunction->PushCell(object_id);
m_pFunction->PushCell(client); m_pFunction->PushCell(client);
m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK); m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK);
m_pFunction->PushCell(maxlength); m_pFunction->PushCell(maxlength);
m_pFunction->Execute(NULL); m_pFunction->Execute(NULL);
} }
void OnTopMenuDisplayTitle(ITopMenu *menu, void OnTopMenuDisplayTitle(ITopMenu *menu,
int client, int client,
unsigned int object_id, unsigned int object_id,
char buffer[], char buffer[],
size_t maxlength) size_t maxlength)
{ {
m_pFunction->PushCell(m_hMenuHandle); m_pFunction->PushCell(m_hMenuHandle);
m_pFunction->PushCell(TopMenuAction_DisplayTitle); m_pFunction->PushCell(TopMenuAction_DisplayTitle);
m_pFunction->PushCell(object_id); m_pFunction->PushCell(object_id);
m_pFunction->PushCell(client); m_pFunction->PushCell(client);
m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK); m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK);
m_pFunction->PushCell(maxlength); m_pFunction->PushCell(maxlength);
m_pFunction->Execute(NULL); m_pFunction->Execute(NULL);
} }
void OnTopMenuSelectOption(ITopMenu *menu, void OnTopMenuSelectOption(ITopMenu *menu,
int client, int client,
unsigned int object_id) unsigned int object_id)
{ {
unsigned int old_reply = playerhelpers->SetReplyTo(SM_REPLY_CHAT); unsigned int old_reply = playerhelpers->SetReplyTo(SM_REPLY_CHAT);
m_pFunction->PushCell(m_hMenuHandle); m_pFunction->PushCell(m_hMenuHandle);
m_pFunction->PushCell(TopMenuAction_SelectOption); m_pFunction->PushCell(TopMenuAction_SelectOption);
m_pFunction->PushCell(object_id); m_pFunction->PushCell(object_id);
m_pFunction->PushCell(client); m_pFunction->PushCell(client);
m_pFunction->PushString(""); m_pFunction->PushString("");
m_pFunction->PushCell(0); m_pFunction->PushCell(0);
m_pFunction->Execute(NULL); m_pFunction->Execute(NULL);
playerhelpers->SetReplyTo(old_reply); playerhelpers->SetReplyTo(old_reply);
} }
void OnTopMenuObjectRemoved(ITopMenu *menu, unsigned int object_id) void OnTopMenuObjectRemoved(ITopMenu *menu, unsigned int object_id)
{ {
m_pFunction->PushCell(m_hMenuHandle); m_pFunction->PushCell(m_hMenuHandle);
m_pFunction->PushCell(TopMenuAction_RemoveObject); m_pFunction->PushCell(TopMenuAction_RemoveObject);
m_pFunction->PushCell(object_id); m_pFunction->PushCell(object_id);
m_pFunction->PushCell(0); m_pFunction->PushCell(0);
m_pFunction->PushString(""); m_pFunction->PushString("");
m_pFunction->PushCell(0); m_pFunction->PushCell(0);
m_pFunction->Execute(NULL); m_pFunction->Execute(NULL);
delete this; delete this;
} }
Handle_t m_hMenuHandle; Handle_t m_hMenuHandle;
IPluginFunction *m_pFunction; IPluginFunction *m_pFunction;
}; };
static cell_t CreateTopMenu(IPluginContext *pContext, const cell_t *params) static cell_t CreateTopMenu(IPluginContext *pContext, const cell_t *params)
{ {
IPluginFunction *func = pContext->GetFunctionById(params[1]); IPluginFunction *func = pContext->GetFunctionById(params[1]);
if (func == NULL) if (func == NULL)
{ {
return pContext ->ThrowNativeError("Invalid function specified"); return pContext ->ThrowNativeError("Invalid function specified");
} }
TopMenuCallbacks *cb = new TopMenuCallbacks(func); TopMenuCallbacks *cb = new TopMenuCallbacks(func);
ITopMenu *pMenu = g_TopMenus.CreateTopMenu(cb); ITopMenu *pMenu = g_TopMenus.CreateTopMenu(cb);
if (!pMenu) if (!pMenu)
{ {
delete cb; delete cb;
return BAD_HANDLE; return BAD_HANDLE;
} }
Handle_t hndl = handlesys->CreateHandle(hTopMenuType, Handle_t hndl = handlesys->CreateHandle(hTopMenuType,
pMenu, pMenu,
pContext->GetIdentity(), pContext->GetIdentity(),
myself->GetIdentity(), myself->GetIdentity(),
NULL); NULL);
if (hndl == 0) if (hndl == 0)
{ {
g_TopMenus.DestroyTopMenu(pMenu); g_TopMenus.DestroyTopMenu(pMenu);
return BAD_HANDLE; return BAD_HANDLE;
} }
cb->m_hMenuHandle = hndl; cb->m_hMenuHandle = hndl;
return hndl; return hndl;
} }
static cell_t LoadTopMenuConfig(IPluginContext *pContext, const cell_t *params) static cell_t LoadTopMenuConfig(IPluginContext *pContext, const cell_t *params)
{ {
HandleError err; HandleError err;
ITopMenu *pMenu; ITopMenu *pMenu;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity()); HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu)) if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
} }
char *file, *err_buf; char *file, *err_buf;
pContext->LocalToString(params[2], &file); pContext->LocalToString(params[2], &file);
pContext->LocalToString(params[3], &err_buf); pContext->LocalToString(params[3], &err_buf);
char path[PLATFORM_MAX_PATH]; char path[PLATFORM_MAX_PATH];
g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file); g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file);
return pMenu->LoadConfiguration(path, err_buf, params[4]) ? 1 : 0; return pMenu->LoadConfiguration(path, err_buf, params[4]) ? 1 : 0;
} }
static cell_t AddToTopMenu(IPluginContext *pContext, const cell_t *params) static cell_t AddToTopMenu(IPluginContext *pContext, const cell_t *params)
{ {
HandleError err; HandleError err;
ITopMenu *pMenu; ITopMenu *pMenu;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity()); HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu)) if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
} }
IPluginFunction *func = pContext->GetFunctionById(params[4]); IPluginFunction *func = pContext->GetFunctionById(params[4]);
if (func == NULL) if (func == NULL)
{ {
return pContext ->ThrowNativeError("Invalid function specified"); return pContext ->ThrowNativeError("Invalid function specified");
} }
TopMenuCallbacks *cb = new TopMenuCallbacks(func); TopMenuCallbacks *cb = new TopMenuCallbacks(func);
char *name, *cmdname, *info_string = NULL; char *name, *cmdname, *info_string = NULL;
pContext->LocalToString(params[2], &name); pContext->LocalToString(params[2], &name);
pContext->LocalToString(params[6], &cmdname); pContext->LocalToString(params[6], &cmdname);
if (params[0] >= 8) if (params[0] >= 8)
{ {
pContext->LocalToString(params[8], &info_string); pContext->LocalToString(params[8], &info_string);
} }
TopMenuObjectType obj_type = (TopMenuObjectType)params[3]; TopMenuObjectType obj_type = (TopMenuObjectType)params[3];
unsigned int object_id; unsigned int object_id;
if ((object_id = pMenu->AddToMenu2(name, if ((object_id = pMenu->AddToMenu2(name,
obj_type, obj_type,
cb, cb,
pContext->GetIdentity(), pContext->GetIdentity(),
cmdname, cmdname,
params[7], params[7],
params[5], params[5],
info_string)) == 0) info_string)) == 0)
{ {
delete cb; delete cb;
return 0; return 0;
} }
cb->m_hMenuHandle = params[1]; cb->m_hMenuHandle = params[1];
return object_id; return object_id;
} }
static cell_t RemoveFromTopMenu(IPluginContext *pContext, const cell_t *params) static cell_t RemoveFromTopMenu(IPluginContext *pContext, const cell_t *params)
{ {
HandleError err; HandleError err;
ITopMenu *pMenu; ITopMenu *pMenu;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity()); HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu)) if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
} }
pMenu->RemoveFromMenu(params[2]); pMenu->RemoveFromMenu(params[2]);
return 1; return 1;
} }
static cell_t FindTopMenuCategory(IPluginContext *pContext, const cell_t *params) static cell_t FindTopMenuCategory(IPluginContext *pContext, const cell_t *params)
{ {
HandleError err; HandleError err;
ITopMenu *pMenu; ITopMenu *pMenu;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity()); HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu)) if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
} }
char *name; char *name;
pContext->LocalToString(params[2], &name); pContext->LocalToString(params[2], &name);
return pMenu->FindCategory(name); return pMenu->FindCategory(name);
} }
static cell_t DisplayTopMenu(IPluginContext *pContext, const cell_t *params) static cell_t DisplayTopMenu(IPluginContext *pContext, const cell_t *params)
{ {
HandleError err; HandleError err;
ITopMenu *pMenu; ITopMenu *pMenu;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity()); HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu)) if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
} }
int client = params[2]; int client = params[2];
IGamePlayer *player = playerhelpers->GetGamePlayer(client); IGamePlayer *player = playerhelpers->GetGamePlayer(client);
if (!player) if (!player)
{ {
return pContext->ThrowNativeError("Invalid client index %d", client); return pContext->ThrowNativeError("Invalid client index %d", client);
} }
else if (!player->IsInGame()) else if (!player->IsInGame())
{ {
return pContext->ThrowNativeError("Client %d is not in game", client); return pContext->ThrowNativeError("Client %d is not in game", client);
} }
return pMenu->DisplayMenu(client, 0, (TopMenuPosition)params[3]); return pMenu->DisplayMenu(client, 0, (TopMenuPosition)params[3]);
} }
static cell_t GetTopMenuInfoString(IPluginContext *pContext, const cell_t *params) static cell_t GetTopMenuInfoString(IPluginContext *pContext, const cell_t *params)
{ {
HandleError err; HandleError err;
ITopMenu *pMenu; ITopMenu *pMenu;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity()); HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu)) if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
} }
const char *str; const char *str;
if ((str = pMenu->GetObjectInfoString(params[2])) == NULL) if ((str = pMenu->GetObjectInfoString(params[2])) == NULL)
{ {
return pContext->ThrowNativeError("Invalid menu object %d", params[2]); return pContext->ThrowNativeError("Invalid menu object %d", params[2]);
} }
char *buffer; char *buffer;
pContext->LocalToString(params[3], &buffer); pContext->LocalToString(params[3], &buffer);
return strncopy(buffer, str, params[4]); return strncopy(buffer, str, params[4]);
} }
static cell_t GetTopMenuName(IPluginContext *pContext, const cell_t *params) static cell_t GetTopMenuName(IPluginContext *pContext, const cell_t *params)
{ {
HandleError err; HandleError err;
ITopMenu *pMenu; ITopMenu *pMenu;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity()); HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu)) if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
} }
const char *str; const char *str;
if ((str = pMenu->GetObjectName(params[2])) == NULL) if ((str = pMenu->GetObjectName(params[2])) == NULL)
{ {
return pContext->ThrowNativeError("Invalid menu object %d", params[2]); return pContext->ThrowNativeError("Invalid menu object %d", params[2]);
} }
char *buffer; char *buffer;
pContext->LocalToString(params[3], &buffer); pContext->LocalToString(params[3], &buffer);
return strncopy(buffer, str, params[4]); return strncopy(buffer, str, params[4]);
} }
sp_nativeinfo_t g_TopMenuNatives[] = sp_nativeinfo_t g_TopMenuNatives[] =
{ {
{"AddToTopMenu", AddToTopMenu}, {"AddToTopMenu", AddToTopMenu},
{"CreateTopMenu", CreateTopMenu}, {"CreateTopMenu", CreateTopMenu},
{"DisplayTopMenu", DisplayTopMenu}, {"DisplayTopMenu", DisplayTopMenu},
{"LoadTopMenuConfig", LoadTopMenuConfig}, {"LoadTopMenuConfig", LoadTopMenuConfig},
{"RemoveFromTopMenu", RemoveFromTopMenu}, {"RemoveFromTopMenu", RemoveFromTopMenu},
{"FindTopMenuCategory", FindTopMenuCategory}, {"FindTopMenuCategory", FindTopMenuCategory},
{"GetTopMenuInfoString", GetTopMenuInfoString}, {"GetTopMenuInfoString", GetTopMenuInfoString},
{"GetTopMenuObjName", GetTopMenuName}, {"GetTopMenuObjName", GetTopMenuName},
{NULL, NULL}, {NULL, NULL},
}; };

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Sample Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SQLite Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -1,7 +1,7 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod SQLite Extension * SourceMod TopMenus Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
PrepareBan(client, target, time, const String:reason[]) PrepareBan(client, target, time, const String:reason[])

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
enum CommType enum CommType

View File

@ -1,75 +1,75 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod Basecommands Plugin * SourceMod Basecommands Plugin
* Provides cancelvote functionality. * Provides cancelvote functionality.
* *
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it under * 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 * the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation. * Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
* *
* As a special exception, AlliedModders LLC gives you permission to link the * 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 * 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 * "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 * by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants * all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
PerformCancelVote(client) PerformCancelVote(client)
{ {
if (!IsVoteInProgress()) if (!IsVoteInProgress())
{ {
ReplyToCommand(client, "[SM] %t", "Vote Not In Progress"); ReplyToCommand(client, "[SM] %t", "Vote Not In Progress");
return; return;
} }
ShowActivity2(client, "[SM] ", "%t", "Cancelled Vote"); ShowActivity2(client, "[SM] ", "%t", "Cancelled Vote");
CancelVote(); CancelVote();
} }
public AdminMenu_CancelVote(Handle:topmenu, public AdminMenu_CancelVote(Handle:topmenu,
TopMenuAction:action, TopMenuAction:action,
TopMenuObject:object_id, TopMenuObject:object_id,
param, param,
String:buffer[], String:buffer[],
maxlength) maxlength)
{ {
if (action == TopMenuAction_DisplayOption) if (action == TopMenuAction_DisplayOption)
{ {
Format(buffer, maxlength, "%T", "Cancel vote", param); Format(buffer, maxlength, "%T", "Cancel vote", param);
} }
else if (action == TopMenuAction_SelectOption) else if (action == TopMenuAction_SelectOption)
{ {
PerformCancelVote(param); PerformCancelVote(param);
RedisplayAdminMenu(topmenu, param); RedisplayAdminMenu(topmenu, param);
} }
else if (action == TopMenuAction_DrawOption) else if (action == TopMenuAction_DrawOption)
{ {
buffer[0] = IsVoteInProgress() ? ITEMDRAW_DEFAULT : ITEMDRAW_IGNORE; buffer[0] = IsVoteInProgress() ? ITEMDRAW_DEFAULT : ITEMDRAW_IGNORE;
} }
} }
public Action:Command_CancelVote(client, args) public Action:Command_CancelVote(client, args)
{ {
PerformCancelVote(client); PerformCancelVote(client);
return Plugin_Handled; return Plugin_Handled;
} }

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
new Handle:g_ConfigMenu = INVALID_HANDLE; new Handle:g_ConfigMenu = INVALID_HANDLE;

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
public MenuHandler_ChangeMap(Handle:menu, MenuAction:action, param1, param2) public MenuHandler_ChangeMap(Handle:menu, MenuAction:action, param1, param2)

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
PerformWho(client, target, ReplySource:reply, bool:is_admin) PerformWho(client, target, ReplySource:reply, bool:is_admin)

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
DisplayVoteBanMenu(client, target) DisplayVoteBanMenu(client, target)

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
new Handle:g_MapList = INVALID_HANDLE; new Handle:g_MapList = INVALID_HANDLE;

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
DisplayVoteAllTalkMenu(client) DisplayVoteAllTalkMenu(client)

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
DisplayVoteBurnMenu(client, target, String:name[]) DisplayVoteBurnMenu(client, target, String:name[])

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */
DisplayVoteFFMenu(client) DisplayVoteFFMenu(client)

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */

View File

@ -28,7 +28,7 @@
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $ * Version: $Id$
*/ */

View File

@ -1,325 +1,325 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This file is part of the SourceMod/SourcePawn SDK. * This file is part of the SourceMod/SourcePawn SDK.
* *
* This program is free software; you can redistribute it and/or modify it under * 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 * the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation. * Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
* *
* As a special exception, AlliedModders LLC gives you permission to link the * 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 * 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 * "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 * by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants * all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id$ * Version: $Id$
*/ */
#if defined _bitbuffer_included #if defined _bitbuffer_included
#endinput #endinput
#endif #endif
#define _bitbuffer_included #define _bitbuffer_included
/** /**
* Writes a single bit to a writable bitbuffer (bf_write). * Writes a single bit to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param bit Bit to write (true for 1, false for 0). * @param bit Bit to write (true for 1, false for 0).
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteBool(Handle:bf, bool:bit); native BfWriteBool(Handle:bf, bool:bit);
/** /**
* Writes a byte to a writable bitbuffer (bf_write). * Writes a byte to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param byte Byte to write (value will be written as 8bit). * @param byte Byte to write (value will be written as 8bit).
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteByte(Handle:bf, byte); native BfWriteByte(Handle:bf, byte);
/** /**
* Writes a byte to a writable bitbuffer (bf_write). * Writes a byte to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param chr Character to write. * @param chr Character to write.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteChar(Handle:bf, chr); native BfWriteChar(Handle:bf, chr);
/** /**
* Writes a 16bit integer to a writable bitbuffer (bf_write). * Writes a 16bit integer to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param num Integer to write (value will be written as 16bit). * @param num Integer to write (value will be written as 16bit).
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteShort(Handle:bf, num); native BfWriteShort(Handle:bf, num);
/** /**
* Writes a 16bit unsigned integer to a writable bitbuffer (bf_write). * Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param num Integer to write (value will be written as 16bit). * @param num Integer to write (value will be written as 16bit).
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteWord(Handle:bf, num); native BfWriteWord(Handle:bf, num);
/** /**
* Writes a normal integer to a writable bitbuffer (bf_write). * Writes a normal integer to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param num Integer to write (value will be written as 32bit). * @param num Integer to write (value will be written as 32bit).
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteNum(Handle:bf, num); native BfWriteNum(Handle:bf, num);
/** /**
* Writes a floating point number to a writable bitbuffer (bf_write). * Writes a floating point number to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param num Number to write. * @param num Number to write.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteFloat(Handle:bf, Float:num); native BfWriteFloat(Handle:bf, Float:num);
/** /**
* Writes a string to a writable bitbuffer (bf_write). * Writes a string to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param string Text string to write. * @param string Text string to write.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteString(Handle:bf, const String:string[]); native BfWriteString(Handle:bf, const String:string[]);
/** /**
* Writes an entity to a writable bitbuffer (bf_write). * Writes an entity to a writable bitbuffer (bf_write).
* @note This is a wrapper around BfWriteShort(). * @note This is a wrapper around BfWriteShort().
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param ent Entity index to write. * @param ent Entity index to write.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle, or invalid entity. * @error Invalid or incorrect Handle, or invalid entity.
*/ */
native BfWriteEntity(Handle:bf, ent); native BfWriteEntity(Handle:bf, ent);
/** /**
* Writes a bit angle to a writable bitbuffer (bf_write). * Writes a bit angle to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param angle Angle to write. * @param angle Angle to write.
* @param numBits Optional number of bits to use. * @param numBits Optional number of bits to use.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteAngle(Handle:bf, Float:angle, numBits=8); native BfWriteAngle(Handle:bf, Float:angle, numBits=8);
/** /**
* Writes a coordinate to a writable bitbuffer (bf_write). * Writes a coordinate to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param coord Coordinate to write. * @param coord Coordinate to write.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteCoord(Handle:bf, Float:coord); native BfWriteCoord(Handle:bf, Float:coord);
/** /**
* Writes a 3D vector of coordinates to a writable bitbuffer (bf_write). * Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param coord Coordinate array to write. * @param coord Coordinate array to write.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteVecCoord(Handle:bf, Float:coord[3]); native BfWriteVecCoord(Handle:bf, Float:coord[3]);
/** /**
* Writes a 3D normal vector to a writable bitbuffer (bf_write). * Writes a 3D normal vector to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param vec Vector to write. * @param vec Vector to write.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteVecNormal(Handle:bf, Float:vec[3]); native BfWriteVecNormal(Handle:bf, Float:vec[3]);
/** /**
* Writes a 3D angle vector to a writable bitbuffer (bf_write). * Writes a 3D angle vector to a writable bitbuffer (bf_write).
* *
* @param bf bf_write handle to write to. * @param bf bf_write handle to write to.
* @param angles Angle vector to write. * @param angles Angle vector to write.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfWriteAngles(Handle:bf, Float:angles[3]); native BfWriteAngles(Handle:bf, Float:angles[3]);
/** /**
* Reads a single bit from a readable bitbuffer (bf_read). * Reads a single bit from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Bit value read. * @return Bit value read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native bool:BfReadBool(Handle:bf); native bool:BfReadBool(Handle:bf);
/** /**
* Reads a byte from a readable bitbuffer (bf_read). * Reads a byte from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Byte value read (read as 8bit). * @return Byte value read (read as 8bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadByte(Handle:bf); native BfReadByte(Handle:bf);
/** /**
* Reads a character from a readable bitbuffer (bf_read). * Reads a character from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Character value read. * @return Character value read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadChar(Handle:bf); native BfReadChar(Handle:bf);
/** /**
* Reads a 16bit integer from a readable bitbuffer (bf_read). * Reads a 16bit integer from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Integer value read (read as 16bit). * @return Integer value read (read as 16bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadShort(Handle:bf); native BfReadShort(Handle:bf);
/** /**
* Reads a 16bit unsigned integer from a readable bitbuffer (bf_read). * Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Integer value read (read as 16bit). * @return Integer value read (read as 16bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadWord(Handle:bf); native BfReadWord(Handle:bf);
/** /**
* Reads a normal integer to a readable bitbuffer (bf_read). * Reads a normal integer to a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Integer value read (read as 32bit). * @return Integer value read (read as 32bit).
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadNum(Handle:bf); native BfReadNum(Handle:bf);
/** /**
* Reads a floating point number from a readable bitbuffer (bf_read). * Reads a floating point number from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Floating point value read. * @return Floating point value read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native Float:BfReadFloat(Handle:bf); native Float:BfReadFloat(Handle:bf);
/** /**
* Reads a string from a readable bitbuffer (bf_read). * Reads a string from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param buffer Destination string buffer. * @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer. * @param maxlength Maximum length of output string buffer.
* @param line If true the buffer will be copied until it reaches a '\n' or a null terminator. * @param line If true the buffer will be copied until it reaches a '\n' or a null terminator.
* @return Number of bytes written to the buffer. If the bitbuffer stream overflowed, * @return Number of bytes written to the buffer. If the bitbuffer stream overflowed,
* that is, had no terminator before the end of the stream, then a negative * that is, had no terminator before the end of the stream, then a negative
* number will be returned equal to the number of characters written to the * number will be returned equal to the number of characters written to the
* buffer minus 1. The buffer will be null terminated regardless of the * buffer minus 1. The buffer will be null terminated regardless of the
* return value. * return value.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false); native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
/** /**
* Reads an entity from a readable bitbuffer (bf_read). * Reads an entity from a readable bitbuffer (bf_read).
* @note This is a wrapper around BfReadShort(). * @note This is a wrapper around BfReadShort().
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Entity index read. * @return Entity index read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadEntity(Handle:bf); native BfReadEntity(Handle:bf);
/** /**
* Reads a bit angle from a readable bitbuffer (bf_read). * Reads a bit angle from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param numBits Optional number of bits to use. * @param numBits Optional number of bits to use.
* @return Angle read. * @return Angle read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native Float:BfReadAngle(Handle:bf, numBits=8); native Float:BfReadAngle(Handle:bf, numBits=8);
/** /**
* Reads a coordinate from a readable bitbuffer (bf_read). * Reads a coordinate from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Coordinate read. * @return Coordinate read.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native Float:BfReadCoord(Handle:bf); native Float:BfReadCoord(Handle:bf);
/** /**
* Reads a 3D vector of coordinates from a readable bitbuffer (bf_read). * Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param coord Destination coordinate array. * @param coord Destination coordinate array.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadVecCoord(Handle:bf, Float:coord[3]); native BfReadVecCoord(Handle:bf, Float:coord[3]);
/** /**
* Reads a 3D normal vector from a readable bitbuffer (bf_read). * Reads a 3D normal vector from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param vec Destination vector array. * @param vec Destination vector array.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadVecNormal(Handle:bf, Float:vec[3]); native BfReadVecNormal(Handle:bf, Float:vec[3]);
/** /**
* Reads a 3D angle vector from a readable bitbuffer (bf_read). * Reads a 3D angle vector from a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @param angles Destination angle vector. * @param angles Destination angle vector.
* @noreturn * @noreturn
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfReadAngles(Handle:bf, Float:angles[3]); native BfReadAngles(Handle:bf, Float:angles[3]);
/** /**
* Returns the number of bytes left in a readable bitbuffer (bf_read). * Returns the number of bytes left in a readable bitbuffer (bf_read).
* *
* @param bf bf_read handle to read from. * @param bf bf_read handle to read from.
* @return Number of bytes left unread. * @return Number of bytes left unread.
* @error Invalid or incorrect Handle. * @error Invalid or incorrect Handle.
*/ */
native BfGetNumBytesLeft(Handle:bf); native BfGetNumBytesLeft(Handle:bf);

View File

@ -1,272 +1,272 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This file is part of the SourceMod/SourcePawn SDK. * This file is part of the SourceMod/SourcePawn SDK.
* *
* This program is free software; you can redistribute it and/or modify it under * 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 * the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation. * Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
* *
* As a special exception, AlliedModders LLC gives you permission to link the * 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 * 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 * "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 * by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants * all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id$ * Version: $Id$
*/ */
#if defined _sdktools_trace_included #if defined _sdktools_trace_included
#endinput #endinput
#endif #endif
#define _sdktools_trace_included #define _sdktools_trace_included
#define CONTENTS_EMPTY 0 /**< No contents. */ #define CONTENTS_EMPTY 0 /**< No contents. */
#define CONTENTS_SOLID 0x1 /**< an eye is never valid in a solid . */ #define CONTENTS_SOLID 0x1 /**< an eye is never valid in a solid . */
#define CONTENTS_WINDOW 0x2 /**< translucent, but not watery (glass). */ #define CONTENTS_WINDOW 0x2 /**< translucent, but not watery (glass). */
#define CONTENTS_AUX 0x4 #define CONTENTS_AUX 0x4
#define CONTENTS_GRATE 0x8 /**< alpha-tested "grate" textures. Bullets/sight pass through, but solids don't. */ #define CONTENTS_GRATE 0x8 /**< alpha-tested "grate" textures. Bullets/sight pass through, but solids don't. */
#define CONTENTS_SLIME 0x10 #define CONTENTS_SLIME 0x10
#define CONTENTS_WATER 0x20 #define CONTENTS_WATER 0x20
#define CONTENTS_MIST 0x40 #define CONTENTS_MIST 0x40
#define CONTENTS_OPAQUE 0x80 /**< things that cannot be seen through (may be non-solid though). */ #define CONTENTS_OPAQUE 0x80 /**< things that cannot be seen through (may be non-solid though). */
#define LAST_VISIBLE_CONTENTS 0x80 #define LAST_VISIBLE_CONTENTS 0x80
#define ALL_VISIBLE_CONTENTS (LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1)) #define ALL_VISIBLE_CONTENTS (LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1))
#define CONTENTS_TESTFOGVOLUME 0x100 #define CONTENTS_TESTFOGVOLUME 0x100
#define CONTENTS_UNUSED5 0x200 #define CONTENTS_UNUSED5 0x200
#define CONTENTS_UNUSED6 0x4000 #define CONTENTS_UNUSED6 0x4000
#define CONTENTS_TEAM1 0x800 /**< per team contents used to differentiate collisions. */ #define CONTENTS_TEAM1 0x800 /**< per team contents used to differentiate collisions. */
#define CONTENTS_TEAM2 0x1000 /**< between players and objects on different teams. */ #define CONTENTS_TEAM2 0x1000 /**< between players and objects on different teams. */
#define CONTENTS_IGNORE_NODRAW_OPAQUE 0x2000 /**< ignore CONTENTS_OPAQUE on surfaces that have SURF_NODRAW. */ #define CONTENTS_IGNORE_NODRAW_OPAQUE 0x2000 /**< ignore CONTENTS_OPAQUE on surfaces that have SURF_NODRAW. */
#define CONTENTS_MOVEABLE 0x4000 /**< hits entities which are MOVETYPE_PUSH (doors, plats, etc) */ #define CONTENTS_MOVEABLE 0x4000 /**< hits entities which are MOVETYPE_PUSH (doors, plats, etc) */
#define CONTENTS_AREAPORTAL 0x8000 /**< remaining contents are non-visible, and don't eat brushes. */ #define CONTENTS_AREAPORTAL 0x8000 /**< remaining contents are non-visible, and don't eat brushes. */
#define CONTENTS_PLAYERCLIP 0x10000 #define CONTENTS_PLAYERCLIP 0x10000
#define CONTENTS_MONSTERCLIP 0x20000 #define CONTENTS_MONSTERCLIP 0x20000
/** /**
* @section currents can be added to any other contents, and may be mixed * @section currents can be added to any other contents, and may be mixed
*/ */
#define CONTENTS_CURRENT_0 0x40000 #define CONTENTS_CURRENT_0 0x40000
#define CONTENTS_CURRENT_90 0x80000 #define CONTENTS_CURRENT_90 0x80000
#define CONTENTS_CURRENT_180 0x100000 #define CONTENTS_CURRENT_180 0x100000
#define CONTENTS_CURRENT_270 0x200000 #define CONTENTS_CURRENT_270 0x200000
#define CONTENTS_CURRENT_UP 0x400000 #define CONTENTS_CURRENT_UP 0x400000
#define CONTENTS_CURRENT_DOWN 0x800000 #define CONTENTS_CURRENT_DOWN 0x800000
/** /**
* @endsection * @endsection
*/ */
#define CONTENTS_ORIGIN 0x1000000 /**< removed before bsping an entity. */ #define CONTENTS_ORIGIN 0x1000000 /**< removed before bsping an entity. */
#define CONTENTS_MONSTER 0x2000000 /**< should never be on a brush, only in game. */ #define CONTENTS_MONSTER 0x2000000 /**< should never be on a brush, only in game. */
#define CONTENTS_DEBRIS 0x4000000 #define CONTENTS_DEBRIS 0x4000000
#define CONTENTS_DETAIL 0x8000000 /**< brushes to be added after vis leafs. */ #define CONTENTS_DETAIL 0x8000000 /**< brushes to be added after vis leafs. */
#define CONTENTS_TRANSLUCENT 0x10000000 /**< auto set if any surface has trans. */ #define CONTENTS_TRANSLUCENT 0x10000000 /**< auto set if any surface has trans. */
#define CONTENTS_LADDER 0x20000000 #define CONTENTS_LADDER 0x20000000
#define CONTENTS_HITBOX 0x40000000 /**< use accurate hitboxes on trace. */ #define CONTENTS_HITBOX 0x40000000 /**< use accurate hitboxes on trace. */
/** /**
* @section Trace masks. * @section Trace masks.
*/ */
#define MASK_ALL (0xFFFFFFFF) #define MASK_ALL (0xFFFFFFFF)
#define MASK_SOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) /**< everything that is normally solid */ #define MASK_SOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) /**< everything that is normally solid */
#define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) /**< everything that blocks player movement */ #define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) /**< everything that blocks player movement */
#define MASK_NPCSOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) /**< blocks npc movement */ #define MASK_NPCSOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) /**< blocks npc movement */
#define MASK_WATER (CONTENTS_WATER|CONTENTS_MOVEABLE|CONTENTS_SLIME) /**< water physics in these contents */ #define MASK_WATER (CONTENTS_WATER|CONTENTS_MOVEABLE|CONTENTS_SLIME) /**< water physics in these contents */
#define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_OPAQUE) /**< everything that blocks line of sight for AI, lighting, etc */ #define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_OPAQUE) /**< everything that blocks line of sight for AI, lighting, etc */
#define MASK_OPAQUE_AND_NPCS (MASK_OPAQUE|CONTENTS_MONSTER) /**< everything that blocks line of sight for AI, lighting, etc, but with monsters added. */ #define MASK_OPAQUE_AND_NPCS (MASK_OPAQUE|CONTENTS_MONSTER) /**< everything that blocks line of sight for AI, lighting, etc, but with monsters added. */
#define MASK_VISIBLE (MASK_OPAQUE|CONTENTS_IGNORE_NODRAW_OPAQUE) /**< everything that blocks line of sight for players */ #define MASK_VISIBLE (MASK_OPAQUE|CONTENTS_IGNORE_NODRAW_OPAQUE) /**< everything that blocks line of sight for players */
#define MASK_VISIBLE_AND_NPCS (MASK_OPAQUE_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE) /**< everything that blocks line of sight for players, but with monsters added. */ #define MASK_VISIBLE_AND_NPCS (MASK_OPAQUE_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE) /**< everything that blocks line of sight for players, but with monsters added. */
#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX) /**< bullets see these as solid */ #define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX) /**< bullets see these as solid */
#define MASK_SHOT_HULL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE) /**< non-raycasted weapons see this as solid (includes grates) */ #define MASK_SHOT_HULL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE) /**< non-raycasted weapons see this as solid (includes grates) */
#define MASK_SHOT_PORTAL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW) /**< hits solids (not grates) and passes through everything else */ #define MASK_SHOT_PORTAL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW) /**< hits solids (not grates) and passes through everything else */
#define MASK_SOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_GRATE) /**< everything normally solid, except monsters (world+brush only) */ #define MASK_SOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_GRATE) /**< everything normally solid, except monsters (world+brush only) */
#define MASK_PLAYERSOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_PLAYERCLIP|CONTENTS_GRATE) /**< everything normally solid for player movement, except monsters (world+brush only) */ #define MASK_PLAYERSOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_PLAYERCLIP|CONTENTS_GRATE) /**< everything normally solid for player movement, except monsters (world+brush only) */
#define MASK_NPCSOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) /**< everything normally solid for npc movement, except monsters (world+brush only) */ #define MASK_NPCSOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) /**< everything normally solid for npc movement, except monsters (world+brush only) */
#define MASK_NPCWORLDSTATIC (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) /**< just the world, used for route rebuilding */ #define MASK_NPCWORLDSTATIC (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) /**< just the world, used for route rebuilding */
#define MASK_SPLITAREAPORTAL (CONTENTS_WATER|CONTENTS_SLIME) /**< These are things that can split areaportals */ #define MASK_SPLITAREAPORTAL (CONTENTS_WATER|CONTENTS_SLIME) /**< These are things that can split areaportals */
/** /**
* @endsection * @endsection
*/ */
enum RayType enum RayType
{ {
RayType_EndPoint, /**< The trace ray will go from the start position to the end position. */ RayType_EndPoint, /**< The trace ray will go from the start position to the end position. */
RayType_Infinite /**< The trace ray will go from the start position to infinity using a direction vector. */ RayType_Infinite /**< The trace ray will go from the start position to infinity using a direction vector. */
}; };
funcenum TraceEntityFilter funcenum TraceEntityFilter
{ {
/** /**
* Called on entity filtering. * Called on entity filtering.
* *
* @param entity Entity index. * @param entity Entity index.
* @param contentsMask Contents Mask. * @param contentsMask Contents Mask.
* @return True to allow the current entity to be hit, otherwise false. * @return True to allow the current entity to be hit, otherwise false.
*/ */
bool:public(entity, contentsMask), bool:public(entity, contentsMask),
/** /**
* Called on entity filtering. * Called on entity filtering.
* *
* @param entity Entity index. * @param entity Entity index.
* @param contentsMask Contents Mask. * @param contentsMask Contents Mask.
* @param data Data value, if used. * @param data Data value, if used.
* @return True to allow the current entity to be hit, otherwise false. * @return True to allow the current entity to be hit, otherwise false.
*/ */
bool:public(entity, contentsMask, any:data), bool:public(entity, contentsMask, any:data),
}; };
/** /**
* Get the contents mask and the entity index at the given position. * Get the contents mask and the entity index at the given position.
* *
* @param pos World position to test. * @param pos World position to test.
* @param entindex Entity index found at the given position (by reference). * @param entindex Entity index found at the given position (by reference).
* @return Contents mask. * @return Contents mask.
*/ */
native TR_GetPointContents(const Float:pos[3], &entindex=-1); native TR_GetPointContents(const Float:pos[3], &entindex=-1);
/** /**
* Get the point contents testing only the given entity index. * Get the point contents testing only the given entity index.
* *
* @param entindex Entity index to test. * @param entindex Entity index to test.
* @param pos World position. * @param pos World position.
* @return Contents mask. * @return Contents mask.
*/ */
native TR_GetPointContentsEnt(entindex, const Float:pos[3]); native TR_GetPointContentsEnt(entindex, const Float:pos[3]);
/** /**
* Starts up a new trace ray using a global trace result. * Starts up a new trace ray using a global trace result.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending point, or the direction angle. * @param vec Depending on RayType, it will be used as the ending point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @noreturn * @noreturn
*/ */
native TR_TraceRay(const Float:pos[3], const Float:vec[3], flags, RayType:rtype); native TR_TraceRay(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
/** /**
* Starts up a new trace ray using a global trace result and a customized trace ray filter. * Starts up a new trace ray using a global trace result and a customized trace ray filter.
* *
* Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is * Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is
* currently not allowed and may not work. * currently not allowed and may not work.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending point, or the direction angle. * @param vec Depending on RayType, it will be used as the ending point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @param filter Function to use as a filter. * @param filter Function to use as a filter.
* @param data Arbitrary data value to pass through to the filter function. * @param data Arbitrary data value to pass through to the filter function.
* @noreturn * @noreturn
*/ */
native TR_TraceRayFilter(const Float:pos[3], native TR_TraceRayFilter(const Float:pos[3],
const Float:vec[3], const Float:vec[3],
flags, flags,
RayType:rtype, RayType:rtype,
TraceEntityFilter:filter, TraceEntityFilter:filter,
any:data=0); any:data=0);
/** /**
* Starts up a new trace ray using a new trace result. * Starts up a new trace ray using a new trace result.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending point, or the direction angle. * @param vec Depending on RayType, it will be used as the ending point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @return Ray trace handle, which must be closed via CloseHandle(). * @return Ray trace handle, which must be closed via CloseHandle().
*/ */
native Handle:TR_TraceRayEx(const Float:pos[3], const Float:vec[3], flags, RayType:rtype); native Handle:TR_TraceRayEx(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
/** /**
* Starts up a new trace ray using a new trace result and a customized trace ray filter. * Starts up a new trace ray using a new trace result and a customized trace ray filter.
* *
* Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is * Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is
* currently not allowed and may not work. * currently not allowed and may not work.
* *
* @param pos Starting position of the ray. * @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending point, or the direction angle. * @param vec Depending on RayType, it will be used as the ending point, or the direction angle.
* @param flags Trace flags. * @param flags Trace flags.
* @param rtype Method to calculate the ray direction. * @param rtype Method to calculate the ray direction.
* @param filter Function to use as a filter. * @param filter Function to use as a filter.
* @param data Arbitrary data value to pass through to the filter function. * @param data Arbitrary data value to pass through to the filter function.
* @return Ray trace handle, which must be closed via CloseHandle(). * @return Ray trace handle, which must be closed via CloseHandle().
*/ */
native Handle:TR_TraceRayFilterEx(const Float:pos[3], native Handle:TR_TraceRayFilterEx(const Float:pos[3],
const Float:vec[3], const Float:vec[3],
flags, flags,
RayType:rtype, RayType:rtype,
TraceEntityFilter:filter, TraceEntityFilter:filter,
any:data=0); any:data=0);
/** /**
* Returns the time fraction from a trace result (1.0 means no collision). * Returns the time fraction from a trace result (1.0 means no collision).
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Time fraction value of the trace. * @return Time fraction value of the trace.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native Float:TR_GetFraction(Handle:hndl=INVALID_HANDLE); native Float:TR_GetFraction(Handle:hndl=INVALID_HANDLE);
/** /**
* Returns the collision position of a trace result. * Returns the collision position of a trace result.
* *
* @param pos Vector buffer to store data in. * @param pos Vector buffer to store data in.
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @noreturn * @noreturn
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native TR_GetEndPosition(Float:pos[3], Handle:hndl=INVALID_HANDLE); native TR_GetEndPosition(Float:pos[3], Handle:hndl=INVALID_HANDLE);
/** /**
* Returns the entity index that collided with the trace. * Returns the entity index that collided with the trace.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Entity index or -1 for no collision. * @return Entity index or -1 for no collision.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native TR_GetEntityIndex(Handle:hndl=INVALID_HANDLE); native TR_GetEntityIndex(Handle:hndl=INVALID_HANDLE);
/** /**
* Returns if there was any kind of collision along the trace ray. * Returns if there was any kind of collision along the trace ray.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return True if any collision found, otherwise false. * @return True if any collision found, otherwise false.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native bool:TR_DidHit(Handle:hndl=INVALID_HANDLE); native bool:TR_DidHit(Handle:hndl=INVALID_HANDLE);
/** /**
* Returns in which body hit group the trace collided if any. * Returns in which body hit group the trace collided if any.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @return Body hit group. * @return Body hit group.
* @error Invalid Handle. * @error Invalid Handle.
*/ */
native TR_GetHitGroup(Handle:hndl=INVALID_HANDLE); native TR_GetHitGroup(Handle:hndl=INVALID_HANDLE);
/** /**
* Find the normal vector to the collison plane of a trace. * Find the normal vector to the collison plane of a trace.
* *
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result. * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @param normal Vector buffer to store the vector normal to the collision plane * @param normal Vector buffer to store the vector normal to the collision plane
* @noreturn * @noreturn
* @error Invalid Handle * @error Invalid Handle
*/ */
native TR_GetPlaneNormal(Handle:hndl, Float:normal[3]); native TR_GetPlaneNormal(Handle:hndl, Float:normal[3]);

View File

@ -1,290 +1,290 @@
/** /**
* vim: set ts=4 : * vim: set ts=4 :
* ============================================================================= * =============================================================================
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* ============================================================================= * =============================================================================
* *
* This file is part of the SourceMod/SourcePawn SDK. * This file is part of the SourceMod/SourcePawn SDK.
* *
* This program is free software; you can redistribute it and/or modify it under * 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 * the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation. * Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
* *
* As a special exception, AlliedModders LLC gives you permission to link the * 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 * 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 * "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 * by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants * all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further * this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>. * or <http://www.sourcemod.net/license.php>.
* *
* Version: $Id$ * Version: $Id$
*/ */
#if defined _topmenus_included #if defined _topmenus_included
#endinput #endinput
#endif #endif
#define _topmenus_included #define _topmenus_included
#include <menus> #include <menus>
/** /**
* Actions a top menu will take on an object. * Actions a top menu will take on an object.
*/ */
enum TopMenuAction enum TopMenuAction
{ {
/** /**
* An option is being drawn for a menu (or for sorting purposes). * An option is being drawn for a menu (or for sorting purposes).
* *
* INPUT : TopMenu Handle, object ID, client index. * INPUT : TopMenu Handle, object ID, client index.
* OUTPUT: Buffer for rendering, maxlength of buffer. * OUTPUT: Buffer for rendering, maxlength of buffer.
*/ */
TopMenuAction_DisplayOption = 0, TopMenuAction_DisplayOption = 0,
/** /**
* The title of a menu is being drawn for a given object. * The title of a menu is being drawn for a given object.
* *
* Note: The Object ID will be INVALID_TOPMENUOBJECT if drawing the * Note: The Object ID will be INVALID_TOPMENUOBJECT if drawing the
* root title. Otherwise, the Object ID is a category. * root title. Otherwise, the Object ID is a category.
* *
* INPUT : TopMenu Handle, object ID, client index. * INPUT : TopMenu Handle, object ID, client index.
* OUTPUT: Buffer for rendering, maxlength of buffer. * OUTPUT: Buffer for rendering, maxlength of buffer.
*/ */
TopMenuAction_DisplayTitle = 1, TopMenuAction_DisplayTitle = 1,
/** /**
* A menu option has been selected. * A menu option has been selected.
* *
* The Object ID will always be an item (not a category). * The Object ID will always be an item (not a category).
* *
* INPUT : TopMenu Handle, object ID, client index. * INPUT : TopMenu Handle, object ID, client index.
*/ */
TopMenuAction_SelectOption = 2, TopMenuAction_SelectOption = 2,
/** /**
* A menu option is being drawn and its flags can be overridden. * A menu option is being drawn and its flags can be overridden.
* *
* INPUT : TopMenu Handle, object ID, client index. * INPUT : TopMenu Handle, object ID, client index.
* OUTPUT: The first byte of the 'buffer' string should be set * OUTPUT: The first byte of the 'buffer' string should be set
* to the desired flags. By default, it will contain * to the desired flags. By default, it will contain
* ITEMDRAW_DEFAULT. * ITEMDRAW_DEFAULT.
*/ */
TopMenuAction_DrawOption = 3, TopMenuAction_DrawOption = 3,
/** /**
* Called when an object is being removed from the menu. * Called when an object is being removed from the menu.
* This can be used to clean up data stored in the info string. * This can be used to clean up data stored in the info string.
* *
* INPUT : TopMenu Handle, object ID. * INPUT : TopMenu Handle, object ID.
*/ */
TopMenuAction_RemoveObject = 4, TopMenuAction_RemoveObject = 4,
}; };
/** /**
* Top menu object types. * Top menu object types.
*/ */
enum TopMenuObjectType enum TopMenuObjectType
{ {
TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */ TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */
TopMenuObject_Item = 1 /**< Item on a sub-menu */ TopMenuObject_Item = 1 /**< Item on a sub-menu */
}; };
/** /**
* Top menu starting positions for display. * Top menu starting positions for display.
*/ */
enum TopMenuPosition enum TopMenuPosition
{ {
TopMenuPosition_Start = 0, /**< Start/root of the menu */ TopMenuPosition_Start = 0, /**< Start/root of the menu */
TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */ TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */
TopMenuPosition_LastCategory = 3, /**< Last position in their last category */ TopMenuPosition_LastCategory = 3, /**< Last position in their last category */
}; };
/** /**
* Top menu object tag for type checking. * Top menu object tag for type checking.
*/ */
enum TopMenuObject enum TopMenuObject
{ {
INVALID_TOPMENUOBJECT = 0, INVALID_TOPMENUOBJECT = 0,
} }
/** /**
* TopMenu callback prototype. * TopMenu callback prototype.
* *
* @param topmenu Handle to the TopMenu. * @param topmenu Handle to the TopMenu.
* @param action TopMenuAction being performed. * @param action TopMenuAction being performed.
* @param object_id The object ID (if used). * @param object_id The object ID (if used).
* @param param Extra parameter (if used). * @param param Extra parameter (if used).
* @param buffer Output buffer (if used). * @param buffer Output buffer (if used).
* @param maxlength Output buffer (if used). * @param maxlength Output buffer (if used).
* @noreturn * @noreturn
*/ */
functag TopMenuHandler public(Handle:topmenu, functag TopMenuHandler public(Handle:topmenu,
TopMenuAction:action, TopMenuAction:action,
TopMenuObject:object_id, TopMenuObject:object_id,
param, param,
String:buffer[], String:buffer[],
maxlength); maxlength);
/** /**
* Creates a TopMenu. * Creates a TopMenu.
* *
* @param handler Handler to use for drawing the root title. * @param handler Handler to use for drawing the root title.
* @return A new TopMenu Handle, or INVALID_HANDLE on failure. * @return A new TopMenu Handle, or INVALID_HANDLE on failure.
*/ */
native Handle:CreateTopMenu(TopMenuHandler:handler); native Handle:CreateTopMenu(TopMenuHandler:handler);
/** /**
* Re-sorts the items in a TopMenu via a configuration file. * Re-sorts the items in a TopMenu via a configuration file.
* *
* The format of the configuration file should be a Valve Key-Values * The format of the configuration file should be a Valve Key-Values
* formatted file that SourceMod can parse. There should be one root * formatted file that SourceMod can parse. There should be one root
* section, and one sub-section for each category. Each sub-section's * section, and one sub-section for each category. Each sub-section's
* name should match the category name. * name should match the category name.
* *
* Each sub-section may only contain key/value pairs in the form of: * Each sub-section may only contain key/value pairs in the form of:
* key: "item" * key: "item"
* value: Name of the item as passed to AddToTopMenu(). * value: Name of the item as passed to AddToTopMenu().
* *
* The TopMenu will draw items in the order declared in the configuration * The TopMenu will draw items in the order declared in the configuration
* file. If items do not appear in the configuration file, they are sorted * file. If items do not appear in the configuration file, they are sorted
* per-player based on how the handler function renders for that player. * per-player based on how the handler function renders for that player.
* These items appear after the configuration sorted items. * These items appear after the configuration sorted items.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param file File path. * @param file File path.
* @param error Error buffer. * @param error Error buffer.
* @param maxlength Maximum size of the error buffer. * @param maxlength Maximum size of the error buffer.
* Error buffer will be filled with a * Error buffer will be filled with a
* zero-terminated string if false is * zero-terminated string if false is
* returned. * returned.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid TopMenu Handle. * @error Invalid TopMenu Handle.
*/ */
native bool:LoadTopMenuConfig(Handle:topmenu, const String:file[], String:error[], maxlength); native bool:LoadTopMenuConfig(Handle:topmenu, const String:file[], String:error[], maxlength);
/** /**
* Adds an object to a TopMenu. * Adds an object to a TopMenu.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param name Object name (MUST be unique). * @param name Object name (MUST be unique).
* @param type Object type. * @param type Object type.
* @param handler Handler for object. * @param handler Handler for object.
* @param cmdname Command name (for access overrides). * @param cmdname Command name (for access overrides).
* @param flags Default access flags. * @param flags Default access flags.
* @param parent Parent object ID, or INVALID_TOPMENUOBJECT for none. * @param parent Parent object ID, or INVALID_TOPMENUOBJECT for none.
* Items must have a category parent. * Items must have a category parent.
* Categories must not have a parent. * Categories must not have a parent.
* @param info_string Arbitrary storage (max 255 bytes). * @param info_string Arbitrary storage (max 255 bytes).
* @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on * @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on
* failure. * failure.
* @error Invalid TopMenu Handle. * @error Invalid TopMenu Handle.
*/ */
native TopMenuObject:AddToTopMenu(Handle:topmenu, native TopMenuObject:AddToTopMenu(Handle:topmenu,
const String:name[], const String:name[],
TopMenuObjectType:type, TopMenuObjectType:type,
TopMenuHandler:handler, TopMenuHandler:handler,
TopMenuObject:parent, TopMenuObject:parent,
const String:cmdname[]="", const String:cmdname[]="",
flags=0, flags=0,
const String:info_string[]=""); const String:info_string[]="");
/** /**
* Retrieves the info string of a top menu item. * Retrieves the info string of a top menu item.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param object TopMenuObject ID. * @param object TopMenuObject ID.
* @param buffer Buffer to store info string. * @param buffer Buffer to store info string.
* @param maxlength Maximum size of info string. * @param maxlength Maximum size of info string.
* @return Number of bytes written, not including the * @return Number of bytes written, not including the
* null terminator. * null terminator.
* @error Invalid TopMenu Handle or TopMenuObject ID. * @error Invalid TopMenu Handle or TopMenuObject ID.
*/ */
native GetTopMenuInfoString(Handle:topmenu, TopMenuObject:parent, String:buffer[], maxlength); native GetTopMenuInfoString(Handle:topmenu, TopMenuObject:parent, String:buffer[], maxlength);
/** /**
* Retrieves the name string of a top menu item. * Retrieves the name string of a top menu item.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param object TopMenuObject ID. * @param object TopMenuObject ID.
* @param buffer Buffer to store info string. * @param buffer Buffer to store info string.
* @param maxlength Maximum size of info string. * @param maxlength Maximum size of info string.
* @return Number of bytes written, not including the * @return Number of bytes written, not including the
* null terminator. * null terminator.
* @error Invalid TopMenu Handle or TopMenuObject ID. * @error Invalid TopMenu Handle or TopMenuObject ID.
*/ */
native GetTopMenuObjName(Handle:topmenu, TopMenuObject:object, String:buffer[], maxlength); native GetTopMenuObjName(Handle:topmenu, TopMenuObject:object, String:buffer[], maxlength);
/** /**
* Removes an object from a TopMenu. * Removes an object from a TopMenu.
* *
* Plugins' objects are automatically removed all TopMenus when the given * Plugins' objects are automatically removed all TopMenus when the given
* plugin unloads or pauses. In the case of unpausing, all items are restored. * plugin unloads or pauses. In the case of unpausing, all items are restored.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param object TopMenuObject ID. * @param object TopMenuObject ID.
* @noreturn * @noreturn
* @error Invalid TopMenu Handle. * @error Invalid TopMenu Handle.
*/ */
native RemoveFromTopMenu(Handle:topmenu, TopMenuObject:object); native RemoveFromTopMenu(Handle:topmenu, TopMenuObject:object);
/** /**
* Displays a TopMenu to a client. * Displays a TopMenu to a client.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param client Client index. * @param client Client index.
* @param position Position to display from. * @param position Position to display from.
* @return True on success, false on failure. * @return True on success, false on failure.
* @error Invalid TopMenu Handle or client not in game. * @error Invalid TopMenu Handle or client not in game.
*/ */
native bool:DisplayTopMenu(Handle:topmenu, client, TopMenuPosition:position); native bool:DisplayTopMenu(Handle:topmenu, client, TopMenuPosition:position);
/** /**
* Finds a category's object ID in a TopMenu. * Finds a category's object ID in a TopMenu.
* *
* @param topmenu TopMenu Handle. * @param topmenu TopMenu Handle.
* @param name Object's unique name. * @param name Object's unique name.
* @return TopMenuObject ID on success, or * @return TopMenuObject ID on success, or
* INVALID_TOPMENUOBJECT on failure. * INVALID_TOPMENUOBJECT on failure.
* @error Invalid TopMenu Handle. * @error Invalid TopMenu Handle.
*/ */
native TopMenuObject:FindTopMenuCategory(Handle:topmenu, const String:name[]); native TopMenuObject:FindTopMenuCategory(Handle:topmenu, const String:name[]);
/** /**
* Do not edit below this line! * Do not edit below this line!
*/ */
public Extension:__ext_topmenus = public Extension:__ext_topmenus =
{ {
name = "TopMenus", name = "TopMenus",
file = "topmenus.ext", file = "topmenus.ext",
#if defined AUTOLOAD_EXTENSIONS #if defined AUTOLOAD_EXTENSIONS
autoload = 1, autoload = 1,
#else #else
autoload = 0, autoload = 0,
#endif #endif
#if defined REQUIRE_EXTENSIONS #if defined REQUIRE_EXTENSIONS
required = 1, required = 1,
#else #else
required = 0, required = 0,
#endif #endif
}; };
#if !defined REQUIRE_EXTENSIONS #if !defined REQUIRE_EXTENSIONS
public __ext_topmenus_SetNTVOptional() public __ext_topmenus_SetNTVOptional()
{ {
MarkNativeAsOptional("CreateTopMenu"); MarkNativeAsOptional("CreateTopMenu");
MarkNativeAsOptional("LoadTopMenuConfig"); MarkNativeAsOptional("LoadTopMenuConfig");
MarkNativeAsOptional("AddToTopMenu"); MarkNativeAsOptional("AddToTopMenu");
MarkNativeAsOptional("RemoveFromTopMenu"); MarkNativeAsOptional("RemoveFromTopMenu");
MarkNativeAsOptional("DisplayTopMenu"); MarkNativeAsOptional("DisplayTopMenu");
MarkNativeAsOptional("FindTopMenuCategory"); MarkNativeAsOptional("FindTopMenuCategory");
} }
#endif #endif

View File

@ -1,145 +1,176 @@
#include <stdio.h> /**
#include "stub_mm.h" * vim: set ts=4 :
#include "stub_util.h" * =============================================================================
#include "sm_ext.h" * SourceMod Extension Code for Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
MyExtension g_SMExt; * =============================================================================
*
bool SM_LoadExtension(char *error, size_t maxlength) * 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
if ((smexts = (IExtensionManager *)g_SMAPI->MetaFactory( * Free Software Foundation.
SOURCEMOD_INTERFACE_EXTENSIONS, *
NULL, * This program is distributed in the hope that it will be useful, but WITHOUT
NULL)) * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
== NULL) * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
{ * details.
if (error && maxlength) *
{ * You should have received a copy of the GNU General Public License along with
UTIL_Format(error, maxlength, SOURCEMOD_INTERFACE_EXTENSIONS " interface not found"); * this program. If not, see <http://www.gnu.org/licenses/>.
} *
return false; * 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
/* This could be more dynamic */ * by the Valve Corporation. You must obey the GNU General Public License in
char path[256]; * all respects for all other code used. Additionally, AlliedModders LLC grants
g_SMAPI->PathFormat(path, * this exception to all derivative works. AlliedModders LLC defines further
sizeof(path), * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
"addons/myplugin/bin/myplugin%s", * or <http://www.sourcemod.net/license.php>.
#if defined __linux__ *
"_i486.so" * Version: $Id$
#else */
".dll"
#endif #include <stdio.h>
); #include "stub_mm.h"
#include "stub_util.h"
if ((myself = smexts->LoadExternal(&g_SMExt, #include "sm_ext.h"
path,
"myplugin_mm.ext", MyExtension g_SMExt;
error,
maxlength)) bool SM_LoadExtension(char *error, size_t maxlength)
== NULL) {
{ if ((smexts = (IExtensionManager *)g_SMAPI->MetaFactory(
SM_UnsetInterfaces(); SOURCEMOD_INTERFACE_EXTENSIONS,
return false; NULL,
} NULL))
== NULL)
return true; {
} if (error && maxlength)
{
void SM_UnloadExtension() UTIL_Format(error, maxlength, SOURCEMOD_INTERFACE_EXTENSIONS " interface not found");
{ }
smexts->UnloadExtension(myself); return false;
} }
bool MyExtension::OnExtensionLoad(IExtension *me, /* This could be more dynamic */
IShareSys *sys, char path[256];
char *error, g_SMAPI->PathFormat(path,
size_t maxlength, sizeof(path),
bool late) "addons/myplugin/bin/myplugin%s",
{ #if defined __linux__
sharesys = sys; "_i486.so"
myself = me; #else
".dll"
/* Get the default interfaces from our configured SDK header */ #endif
if (!SM_AcquireInterfaces(error, maxlength)) );
{
return false; if ((myself = smexts->LoadExternal(&g_SMExt,
} path,
"myplugin_mm.ext",
return true; error,
} maxlength))
== NULL)
void MyExtension::OnExtensionUnload() {
{ SM_UnsetInterfaces();
/* Clean up any resources here, and more importantly, make sure return false;
* any listeners/hooks into SourceMod are totally removed, as well }
* as data structures like handle types and forwards.
*/ return true;
}
//...
void SM_UnloadExtension()
/* Make sure our pointers get NULL'd just in case */ {
SM_UnsetInterfaces(); smexts->UnloadExtension(myself);
} }
void MyExtension::OnExtensionsAllLoaded() bool MyExtension::OnExtensionLoad(IExtension *me,
{ IShareSys *sys,
/* Called once all extensions are marked as loaded. char *error,
* This always called, and always called only once. size_t maxlength,
*/ bool late)
} {
sharesys = sys;
void MyExtension::OnExtensionPauseChange(bool pause) myself = me;
{
} /* Get the default interfaces from our configured SDK header */
if (!SM_AcquireInterfaces(error, maxlength))
bool MyExtension::QueryRunning(char *error, size_t maxlength) {
{ return false;
/* 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;
*/ }
return true;
} void MyExtension::OnExtensionUnload()
{
bool MyExtension::IsMetamodExtension() /* Clean up any resources here, and more importantly, make sure
{ * any listeners/hooks into SourceMod are totally removed, as well
/* Must return false! */ * as data structures like handle types and forwards.
return false; */
}
//...
const char *MyExtension::GetExtensionName()
{ /* Make sure our pointers get NULL'd just in case */
return mmsplugin->GetName(); SM_UnsetInterfaces();
} }
const char *MyExtension::GetExtensionURL() void MyExtension::OnExtensionsAllLoaded()
{ {
return mmsplugin->GetURL(); /* Called once all extensions are marked as loaded.
} * This always called, and always called only once.
*/
const char *MyExtension::GetExtensionTag() }
{
return mmsplugin->GetLogTag(); void MyExtension::OnExtensionPauseChange(bool pause)
} {
}
const char *MyExtension::GetExtensionAuthor()
{ bool MyExtension::QueryRunning(char *error, size_t maxlength)
return mmsplugin->GetAuthor(); {
} /* if something is required that can't be determined during the initial
* load process, print a message here will show a helpful message to
const char *MyExtension::GetExtensionVerString() * users when they view the extension's info.
{ */
return mmsplugin->GetVersion(); return true;
} }
const char *MyExtension::GetExtensionDescription() bool MyExtension::IsMetamodExtension()
{ {
return mmsplugin->GetDescription(); /* Must return false! */
} return false;
}
const char *MyExtension::GetExtensionDateString()
{ const char *MyExtension::GetExtensionName()
return mmsplugin->GetDate(); {
} 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();
}

View File

@ -1,38 +1,69 @@
#ifndef _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_ /**
#define _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_ * vim: set ts=4 :
* =============================================================================
#include "sm_sdk_config.h" * SourceMod Extension Code for Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
using namespace SourceMod; * =============================================================================
*
class MyExtension : public IExtensionInterface * 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
public: * Free Software Foundation.
virtual bool OnExtensionLoad(IExtension *me, *
IShareSys *sys, * This program is distributed in the hope that it will be useful, but WITHOUT
char *error, * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
size_t maxlength, * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
bool late); * details.
virtual void OnExtensionUnload(); *
virtual void OnExtensionsAllLoaded(); * You should have received a copy of the GNU General Public License along with
virtual void OnExtensionPauseChange(bool pause); * this program. If not, see <http://www.gnu.org/licenses/>.
virtual bool QueryRunning(char *error, size_t maxlength); *
virtual bool IsMetamodExtension(); * As a special exception, AlliedModders LLC gives you permission to link the
virtual const char *GetExtensionName(); * code of this program (as well as its derivative works) to "Half-Life 2," the
virtual const char *GetExtensionURL(); * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
virtual const char *GetExtensionTag(); * by the Valve Corporation. You must obey the GNU General Public License in
virtual const char *GetExtensionAuthor(); * all respects for all other code used. Additionally, AlliedModders LLC grants
virtual const char *GetExtensionVerString(); * this exception to all derivative works. AlliedModders LLC defines further
virtual const char *GetExtensionDescription(); * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
virtual const char *GetExtensionDateString(); * or <http://www.sourcemod.net/license.php>.
}; *
* Version: $Id$
bool SM_LoadExtension(char *error, size_t maxlength); */
void SM_UnloadExtension();
#ifndef _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
extern IShareSys *sharesys; #define _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
extern IExtension *myself;
extern MyExtension g_SMExt; #include "sm_sdk_config.h"
#endif //_INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_ 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_

View File

@ -1,151 +1,182 @@
#include "sm_sdk_config.h" /**
* vim: set ts=4 :
using namespace SourceMod; * =============================================================================
* SourceMod Extension Code for Metamod:Source
bool SM_AcquireInterfaces(char *error, size_t maxlength) * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
{ * =============================================================================
SM_FIND_IFACE_OR_FAIL(SOURCEMOD, sm_main, error, maxlength); *
* This program is free software; you can redistribute it and/or modify it under
#if defined SMEXT_ENABLE_FORWARDSYS * the terms of the GNU General Public License, version 3.0, as published by the
SM_FIND_IFACE_OR_FAIL(FORWARDMANAGER, sm_forwards, error, maxlength); * Free Software Foundation.
#endif *
#if defined SMEXT_ENABLE_HANDLESYS * This program is distributed in the hope that it will be useful, but WITHOUT
SM_FIND_IFACE_OR_FAIL(HANDLESYSTEM, sm_handlesys, error, maxlength); * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#endif * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
#if defined SMEXT_ENABLE_PLAYERHELPERS * details.
SM_FIND_IFACE_OR_FAIL(PLAYERMANAGER, sm_players, error, maxlength); *
#endif * You should have received a copy of the GNU General Public License along with
#if defined SMEXT_ENABLE_DBMANAGER * this program. If not, see <http://www.gnu.org/licenses/>.
SM_FIND_IFACE_OR_FAIL(DBI, sm_dbi, error, maxlength); *
#endif * As a special exception, AlliedModders LLC gives you permission to link the
#if defined SMEXT_ENABLE_GAMECONF * code of this program (as well as its derivative works) to "Half-Life 2," the
SM_FIND_IFACE_OR_FAIL(GAMECONFIG, sm_gameconfs, error, maxlength); * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
#endif * by the Valve Corporation. You must obey the GNU General Public License in
#if defined SMEXT_ENABLE_MEMUTILS * all respects for all other code used. Additionally, AlliedModders LLC grants
SM_FIND_IFACE_OR_FAIL(MEMORYUTILS, sm_memutils, error, maxlength); * this exception to all derivative works. AlliedModders LLC defines further
#endif * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
#if defined SMEXT_ENABLE_GAMEHELPERS * or <http://www.sourcemod.net/license.php>.
SM_FIND_IFACE_OR_FAIL(GAMEHELPERS, sm_gamehelpers, error, maxlength); *
#endif * Version: $Id$
#if defined SMEXT_ENABLE_TIMERSYS */
SM_FIND_IFACE_OR_FAIL(TIMERSYS, sm_timersys, error, maxlength);
#endif #include "sm_sdk_config.h"
#if defined SMEXT_ENABLE_THREADER
SM_FIND_IFACE_OR_FAIL(THREADER, sm_threader, error, maxlength); using namespace SourceMod;
#endif
#if defined SMEXT_ENABLE_LIBSYS bool SM_AcquireInterfaces(char *error, size_t maxlength)
SM_FIND_IFACE_OR_FAIL(LIBRARYSYS, sm_libsys, error, maxlength); {
#endif SM_FIND_IFACE_OR_FAIL(SOURCEMOD, sm_main, error, maxlength);
#if defined SMEXT_ENABLE_PLUGINSYS
SM_FIND_IFACE_OR_FAIL(PLUGINSYSTEM, sm_plsys, error, maxlength); #if defined SMEXT_ENABLE_FORWARDSYS
#endif SM_FIND_IFACE_OR_FAIL(FORWARDMANAGER, sm_forwards, error, maxlength);
#if defined SMEXT_ENABLE_MENUS #endif
SM_FIND_IFACE_OR_FAIL(MENUMANAGER, sm_menus, error, maxlength); #if defined SMEXT_ENABLE_HANDLESYS
#endif SM_FIND_IFACE_OR_FAIL(HANDLESYSTEM, sm_handlesys, error, maxlength);
#if defined SMEXT_ENABLE_ADMINSYS #endif
SM_FIND_IFACE_OR_FAIL(ADMINSYS, sm_adminsys, error, maxlength); #if defined SMEXT_ENABLE_PLAYERHELPERS
#endif SM_FIND_IFACE_OR_FAIL(PLAYERMANAGER, sm_players, error, maxlength);
#if defined SMEXT_ENABLE_TEXTPARSERS #endif
SM_FIND_IFACE_OR_FAIL(TEXTPARSERS, sm_text, error, maxlength); #if defined SMEXT_ENABLE_DBMANAGER
#endif SM_FIND_IFACE_OR_FAIL(DBI, sm_dbi, error, maxlength);
#endif
return true; #if defined SMEXT_ENABLE_GAMECONF
} SM_FIND_IFACE_OR_FAIL(GAMECONFIG, sm_gameconfs, error, maxlength);
#endif
void SM_UnsetInterfaces() #if defined SMEXT_ENABLE_MEMUTILS
{ SM_FIND_IFACE_OR_FAIL(MEMORYUTILS, sm_memutils, error, maxlength);
myself = NULL; #endif
smexts = NULL; #if defined SMEXT_ENABLE_GAMEHELPERS
sharesys = NULL; SM_FIND_IFACE_OR_FAIL(GAMEHELPERS, sm_gamehelpers, error, maxlength);
sm_main = NULL; #endif
#if defined SMEXT_ENABLE_FORWARDSYS #if defined SMEXT_ENABLE_TIMERSYS
sm_forwards = NULL; SM_FIND_IFACE_OR_FAIL(TIMERSYS, sm_timersys, error, maxlength);
#endif #endif
#if defined SMEXT_ENABLE_HANDLESYS #if defined SMEXT_ENABLE_THREADER
sm_handlesys = NULL; SM_FIND_IFACE_OR_FAIL(THREADER, sm_threader, error, maxlength);
#endif #endif
#if defined SMEXT_ENABLE_PLAYERHELPERS #if defined SMEXT_ENABLE_LIBSYS
sm_players = NULL; SM_FIND_IFACE_OR_FAIL(LIBRARYSYS, sm_libsys, error, maxlength);
#endif #endif
#if defined SMEXT_ENABLE_DBMANAGER #if defined SMEXT_ENABLE_PLUGINSYS
sm_dbi = NULL; SM_FIND_IFACE_OR_FAIL(PLUGINSYSTEM, sm_plsys, error, maxlength);
#endif #endif
#if defined SMEXT_ENABLE_GAMECONF #if defined SMEXT_ENABLE_MENUS
sm_gameconfs = NULL; SM_FIND_IFACE_OR_FAIL(MENUMANAGER, sm_menus, error, maxlength);
#endif #endif
#if defined SMEXT_ENABLE_MEMUTILS #if defined SMEXT_ENABLE_ADMINSYS
sm_memutils = NULL; SM_FIND_IFACE_OR_FAIL(ADMINSYS, sm_adminsys, error, maxlength);
#endif #endif
#if defined SMEXT_ENABLE_GAMEHELPERS #if defined SMEXT_ENABLE_TEXTPARSERS
sm_gamehelpers = NULL; SM_FIND_IFACE_OR_FAIL(TEXTPARSERS, sm_text, error, maxlength);
#endif #endif
#if defined SMEXT_ENABLE_TIMERSYS
sm_timersys = NULL; return true;
#endif }
#if defined SMEXT_ENABLE_THREADER
sm_threader = NULL; void SM_UnsetInterfaces()
#endif {
#if defined SMEXT_ENABLE_LIBSYS myself = NULL;
sm_libsys = NULL; smexts = NULL;
#endif sharesys = NULL;
#if defined SMEXT_ENABLE_PLUGINSYS sm_main = NULL;
sm_plsys = NULL; #if defined SMEXT_ENABLE_FORWARDSYS
#endif sm_forwards = NULL;
#if defined SMEXT_ENABLE_MENUS #endif
sm_menus = NULL; #if defined SMEXT_ENABLE_HANDLESYS
#endif sm_handlesys = NULL;
#if defined SMEXT_ENABLE_ADMINSYS #endif
sm_adminsys = NULL; #if defined SMEXT_ENABLE_PLAYERHELPERS
#endif sm_players = NULL;
#if defined SMEXT_ENABLE_TEXTPARSERS #endif
sm_text = NULL; #if defined SMEXT_ENABLE_DBMANAGER
#endif sm_dbi = NULL;
} #endif
#if defined SMEXT_ENABLE_GAMECONF
IExtension *myself = NULL; sm_gameconfs = NULL;
IExtensionManager *smexts = NULL; #endif
IShareSys *sharesys = NULL; #if defined SMEXT_ENABLE_MEMUTILS
SourceMod::ISourceMod *sm_main = NULL; sm_memutils = NULL;
#if defined SMEXT_ENABLE_FORWARDSYS #endif
SourceMod::IForwardManager *sm_forwards = NULL; #if defined SMEXT_ENABLE_GAMEHELPERS
#endif sm_gamehelpers = NULL;
#if defined SMEXT_ENABLE_HANDLESYS #endif
SourceMod::IHandleSys *sm_handlesys = NULL; #if defined SMEXT_ENABLE_TIMERSYS
#endif sm_timersys = NULL;
#if defined SMEXT_ENABLE_PLAYERHELPERS #endif
SourceMod::IPlayerManager *sm_players = NULL; #if defined SMEXT_ENABLE_THREADER
#endif sm_threader = NULL;
#if defined SMEXT_ENABLE_DBMANAGER #endif
SourceMod::IDBManager *sm_dbi = NULL; #if defined SMEXT_ENABLE_LIBSYS
#endif sm_libsys = NULL;
#if defined SMEXT_ENABLE_GAMECONF #endif
SourceMod::IGameConfigManager *sm_gameconfs = NULL; #if defined SMEXT_ENABLE_PLUGINSYS
#endif sm_plsys = NULL;
#if defined SMEXT_ENABLE_MEMUTILS #endif
SourceMod::IMemoryUtils *sm_memutils = NULL; #if defined SMEXT_ENABLE_MENUS
#endif sm_menus = NULL;
#if defined SMEXT_ENABLE_GAMEHELPERS #endif
SourceMod::IGameHelpers *sm_gamehelpers = NULL; #if defined SMEXT_ENABLE_ADMINSYS
#endif sm_adminsys = NULL;
#if defined SMEXT_ENABLE_TIMERSYS #endif
SourceMod::ITimerSystem *sm_timersys = NULL; #if defined SMEXT_ENABLE_TEXTPARSERS
#endif sm_text = NULL;
#if defined SMEXT_ENABLE_THREADER #endif
SourceMod::IThreader *sm_threader = NULL; }
#endif
#if defined SMEXT_ENABLE_LIBSYS IExtension *myself = NULL;
SourceMod::ILibrarySys *sm_libsys = NULL; IExtensionManager *smexts = NULL;
#endif IShareSys *sharesys = NULL;
#if defined SMEXT_ENABLE_PLUGINSYS SourceMod::ISourceMod *sm_main = NULL;
SourceMod::IPluginManager *sm_plsys = NULL; #if defined SMEXT_ENABLE_FORWARDSYS
#endif SourceMod::IForwardManager *sm_forwards = NULL;
#if defined SMEXT_ENABLE_MENUS #endif
SourceMod::IMenuManager *sm_menus = NULL; #if defined SMEXT_ENABLE_HANDLESYS
#endif SourceMod::IHandleSys *sm_handlesys = NULL;
#if defined SMEXT_ENABLE_ADMINSYS #endif
SourceMod::IAdminSystem *sm_adminsys = NULL; #if defined SMEXT_ENABLE_PLAYERHELPERS
#endif SourceMod::IPlayerManager *sm_players = NULL;
#if defined SMEXT_ENABLE_TEXTPARSERS #endif
SourceMod::ITextParsers *sm_text = NULL; #if defined SMEXT_ENABLE_DBMANAGER
#endif 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

View File

@ -1,128 +1,159 @@
#ifndef _INCLUDE_SOURCEMOD_CONFIG_H_ /**
#define _INCLUDE_SOURCEMOD_CONFIG_H_ * vim: set ts=4 :
* =============================================================================
#include <stdio.h> * SourceMod Extension Code for Metamod:Source
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
/** * =============================================================================
* @brief Acquires the interfaces enabled at the bottom of this header. *
* * This program is free software; you can redistribute it and/or modify it under
* @param error Buffer to store error message. * the terms of the GNU General Public License, version 3.0, as published by the
* @param maxlength Maximum size of the error buffer. * Free Software Foundation.
* @return True on success, false on failure. *
* On failure, a null-terminated string will be stored * This program is distributed in the hope that it will be useful, but WITHOUT
* in the error buffer, if the buffer is non-NULL and * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* greater than 0 bytes in size. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
*/ * details.
bool SM_AcquireInterfaces(char *error, size_t maxlength); *
* You should have received a copy of the GNU General Public License along with
/** * this program. If not, see <http://www.gnu.org/licenses/>.
* @brief Sets each acquired interface to NULL. *
*/ * As a special exception, AlliedModders LLC gives you permission to link the
void SM_UnsetInterfaces(); * 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
* Enable interfaces you want to use here by uncommenting lines. * all respects for all other code used. Additionally, AlliedModders LLC grants
* These interfaces are all part of SourceMod's core. * this exception to all derivative works. AlliedModders LLC defines further
*/ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
//#define SMEXT_ENABLE_FORWARDSYS * or <http://www.sourcemod.net/license.php>.
//#define SMEXT_ENABLE_HANDLESYS *
//#define SMEXT_ENABLE_PLAYERHELPERS * Version: $Id$
//#define SMEXT_ENABLE_DBMANAGER */
//#define SMEXT_ENABLE_GAMECONF
//#define SMEXT_ENABLE_MEMUTILS #ifndef _INCLUDE_SOURCEMOD_CONFIG_H_
//#define SMEXT_ENABLE_GAMEHELPERS #define _INCLUDE_SOURCEMOD_CONFIG_H_
//#define SMEXT_ENABLE_TIMERSYS
//#define SMEXT_ENABLE_THREADER #include <stdio.h>
//#define SMEXT_ENABLE_LIBSYS
//#define SMEXT_ENABLE_MENUS /**
//#define SMEXT_ENABLE_ADTFACTORY * @brief Acquires the interfaces enabled at the bottom of this header.
//#define SMEXT_ENABLE_PLUGINSYS *
//#define SMEXT_ENABLE_ADMINSYS * @param error Buffer to store error message.
//#define SMEXT_ENABLE_TEXTPARSERS * @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
* There is no need to edit below. * greater than 0 bytes in size.
*/ */
bool SM_AcquireInterfaces(char *error, size_t maxlength);
#include <IShareSys.h>
#include <IExtensionSys.h> /**
extern SourceMod::IExtension *myself; * @brief Sets each acquired interface to NULL.
extern SourceMod::IExtensionManager *smexts; */
extern SourceMod::IShareSys *sharesys; void SM_UnsetInterfaces();
#include <ISourceMod.h> /**
extern SourceMod::ISourceMod *sm_main; * Enable interfaces you want to use here by uncommenting lines.
* These interfaces are all part of SourceMod's core.
#if defined SMEXT_ENABLE_FORWARDSYS */
#include <IForwardSys.h> //#define SMEXT_ENABLE_FORWARDSYS
extern SourceMod::IForwardManager *sm_forwards; //#define SMEXT_ENABLE_HANDLESYS
#endif //#define SMEXT_ENABLE_PLAYERHELPERS
//#define SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_HANDLESYS //#define SMEXT_ENABLE_GAMECONF
#include <IHandleSys.h> //#define SMEXT_ENABLE_MEMUTILS
extern SourceMod::IHandleSys *sm_handlesys; //#define SMEXT_ENABLE_GAMEHELPERS
#endif //#define SMEXT_ENABLE_TIMERSYS
//#define SMEXT_ENABLE_THREADER
#if defined SMEXT_ENABLE_PLAYERHELPERS //#define SMEXT_ENABLE_LIBSYS
#include <IPlayerHelpers.h> //#define SMEXT_ENABLE_MENUS
extern SourceMod::IPlayerManager *sm_players; //#define SMEXT_ENABLE_ADTFACTORY
#endif //#define SMEXT_ENABLE_PLUGINSYS
//#define SMEXT_ENABLE_ADMINSYS
#if defined SMEXT_ENABLE_DBMANAGER //#define SMEXT_ENABLE_TEXTPARSERS
#include <IDBDriver.h>
extern SourceMod::IDBManager *sm_dbi;
#endif /**
* There is no need to edit below.
#if defined SMEXT_ENABLE_GAMECONF */
#include <IGameConfigs.h>
extern SourceMod::IGameConfigManager *sm_gameconfs; #include <IShareSys.h>
#endif #include <IExtensionSys.h>
extern SourceMod::IExtension *myself;
#if defined SMEXT_ENABLE_MEMUTILS extern SourceMod::IExtensionManager *smexts;
#include <IMemoryUtils.h> extern SourceMod::IShareSys *sharesys;
extern SourceMod::IMemoryUtils *sm_memutils;
#endif #include <ISourceMod.h>
extern SourceMod::ISourceMod *sm_main;
#if defined SMEXT_ENABLE_GAMEHELPERS
#include <IGameHelpers.h> #if defined SMEXT_ENABLE_FORWARDSYS
extern SourceMod::IGameHelpers *sm_gamehelpers; #include <IForwardSys.h>
#endif extern SourceMod::IForwardManager *sm_forwards;
#endif
#if defined SMEXT_ENABLE_TIMERSYS
#include <ITimerSystem.h> #if defined SMEXT_ENABLE_HANDLESYS
extern SourceMod::ITimerSystem *sm_timersys; #include <IHandleSys.h>
#endif extern SourceMod::IHandleSys *sm_handlesys;
#endif
#if defined SMEXT_ENABLE_THREADER
#include <IThreader.h> #if defined SMEXT_ENABLE_PLAYERHELPERS
extern SourceMod::IThreader *sm_threader; #include <IPlayerHelpers.h>
#endif extern SourceMod::IPlayerManager *sm_players;
#endif
#if defined SMEXT_ENABLE_LIBSYS
#include <ILibrarySys.h> #if defined SMEXT_ENABLE_DBMANAGER
extern SourceMod::ILibrarySys *sm_libsys; #include <IDBDriver.h>
#endif extern SourceMod::IDBManager *sm_dbi;
#endif
#if defined SMEXT_ENABLE_PLUGINSYS
#include <IPluginSys.h> #if defined SMEXT_ENABLE_GAMECONF
extern SourceMod::IPluginManager *sm_plsys; #include <IGameConfigs.h>
#endif extern SourceMod::IGameConfigManager *sm_gameconfs;
#endif
#if defined SMEXT_ENABLE_MENUS
#include <IMenuManager.h> #if defined SMEXT_ENABLE_MEMUTILS
extern SourceMod::IMenuManager *sm_menus; #include <IMemoryUtils.h>
#endif extern SourceMod::IMemoryUtils *sm_memutils;
#endif
#if defined SMEXT_ENABLE_ADMINSYS
#include <IAdminSystem.h> #if defined SMEXT_ENABLE_GAMEHELPERS
extern SourceMod::IAdminSystem *sm_adminsys; #include <IGameHelpers.h>
#endif extern SourceMod::IGameHelpers *sm_gamehelpers;
#endif
#if defined SMEXT_ENABLE_TEXTPARSERS
#include <ITextParsers.h> #if defined SMEXT_ENABLE_TIMERSYS
extern SourceMod::ITextParsers *sm_text; #include <ITimerSystem.h>
#endif extern SourceMod::ITimerSystem *sm_timersys;
#endif
#endif //_INCLUDE_SOURCEMOD_CONFIG_H_
#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
#endif //_INCLUDE_SOURCEMOD_CONFIG_H_

View File

@ -11,7 +11,7 @@
* *
* This stub plugin is public domain. * This stub plugin is public domain.
* *
* Version: $Id: stub_mm.cpp 534 2007-10-30 18:22:12Z dvander $ * Version: $Id$
*/ */
#include <stdio.h> #include <stdio.h>

View File

@ -11,7 +11,7 @@
* *
* This stub plugin is public domain. * This stub plugin is public domain.
* *
* Version: $Id: stub_mm.h 463 2007-10-06 17:01:51Z dvander $ * Version: $Id$
*/ */
#ifndef _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_ #ifndef _INCLUDE_METAMOD_SOURCE_STUB_PLUGIN_H_

View File

@ -1,22 +1,38 @@
#include <stdio.h> /**
#include <stdarg.h> * vim: set ts=4 :
#include "stub_util.h" * ======================================================
* Metamod:Source Stub Plugin
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...) * Written by AlliedModders LLC.
{ * ======================================================
va_list ap; *
* This software is provided 'as-is', without any express or implied warranty.
va_start(ap, fmt); * In no event will the authors be held liable for any damages arising from
size_t len = vsnprintf(buffer, maxlength, fmt, ap); * the use of this software.
va_end(ap); *
* This stub plugin is public domain.
if (len >= maxlength) *
{ * Version: $Id$
len = maxlength - 1; */
buffer[len] = '\0';
} #include <stdio.h>
#include <stdarg.h>
return len; #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;
}

View File

@ -1,15 +1,31 @@
#ifndef _INCLUDE_STUB_UTIL_FUNCTIONS_H_ /**
#define _INCLUDE_STUB_UTIL_FUNCTIONS_H_ * vim: set ts=4 :
* ======================================================
#include <stddef.h> * Metamod:Source Stub Plugin
* Written by AlliedModders LLC.
/** * ======================================================
* This is a platform-safe function which fixes weird idiosyncracies *
* in the null-termination and return value of snprintf(). It guarantees * This software is provided 'as-is', without any express or implied warranty.
* the terminator on overflow cases, and never returns -1 or a value * In no event will the authors be held liable for any damages arising from
* not equal to the number of non-terminating bytes written. * the use of this software.
*/ *
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...); * This stub plugin is public domain.
*
#endif //_INCLUDE_STUB_UTIL_FUNCTIONS_H_ * 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_