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:
parent
0c5e4b5a2f
commit
c473d75d3d
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SDKTools Extension
|
||||
* SourceMod Counter-Strike:Source Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SDKTools Extension
|
||||
* SourceMod Counter-Strike:Source Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,155 +1,155 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SQLite Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "pcre.h"
|
||||
#include "CRegEx.h"
|
||||
#include <sh_string.h>
|
||||
#include "extension.h"
|
||||
|
||||
RegEx::RegEx()
|
||||
{
|
||||
mErrorOffset = 0;
|
||||
mError = NULL;
|
||||
re = NULL;
|
||||
mFree = true;
|
||||
subject = NULL;
|
||||
mSubStrings = 0;
|
||||
}
|
||||
|
||||
void RegEx::Clear ()
|
||||
{
|
||||
mErrorOffset = 0;
|
||||
mError = NULL;
|
||||
if (re)
|
||||
pcre_free(re);
|
||||
re = NULL;
|
||||
mFree = true;
|
||||
if (subject)
|
||||
delete [] subject;
|
||||
subject = NULL;
|
||||
mSubStrings = 0;
|
||||
}
|
||||
|
||||
RegEx::~RegEx()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
bool RegEx::isFree(bool set, bool val)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
mFree = val;
|
||||
return true;
|
||||
} else {
|
||||
return mFree;
|
||||
}
|
||||
}
|
||||
|
||||
int RegEx::Compile(const char *pattern, int iFlags)
|
||||
{
|
||||
if (!mFree)
|
||||
Clear();
|
||||
|
||||
re = pcre_compile(pattern, iFlags, &mError, &mErrorOffset, NULL);
|
||||
|
||||
if (re == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
mFree = false;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RegEx::Match(const char *str)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (mFree || re == NULL)
|
||||
return -1;
|
||||
|
||||
this->ClearMatch();
|
||||
|
||||
//save str
|
||||
subject = new char[strlen(str)+1];
|
||||
strcpy(subject, str);
|
||||
|
||||
rc = pcre_exec(re, NULL, subject, (int)strlen(subject), 0, 0, ovector, 30);
|
||||
|
||||
if (rc < 0)
|
||||
{
|
||||
if (rc == PCRE_ERROR_NOMATCH)
|
||||
{
|
||||
return 0;
|
||||
} else {
|
||||
mErrorOffset = rc;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
mSubStrings = rc;
|
||||
|
||||
return 1;
|
||||
}
|
||||
void RegEx::ClearMatch()
|
||||
{
|
||||
// Clears match results
|
||||
mErrorOffset = 0;
|
||||
mError = NULL;
|
||||
if (subject)
|
||||
delete [] subject;
|
||||
subject = NULL;
|
||||
mSubStrings = 0;
|
||||
}
|
||||
|
||||
const char *RegEx::GetSubstring(int s, char buffer[], int max)
|
||||
{
|
||||
int i = 0;
|
||||
if (s >= mSubStrings || s < 0)
|
||||
return NULL;
|
||||
|
||||
char *substr_a = subject + ovector[2*s];
|
||||
int substr_l = ovector[2*s+1] - ovector[2*s];
|
||||
|
||||
for (i = 0; i<substr_l; i++)
|
||||
{
|
||||
if (i >= max)
|
||||
break;
|
||||
buffer[i] = substr_a[i];
|
||||
}
|
||||
|
||||
buffer[i] = '\0';
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Regular Expressions Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "pcre.h"
|
||||
#include "CRegEx.h"
|
||||
#include <sh_string.h>
|
||||
#include "extension.h"
|
||||
|
||||
RegEx::RegEx()
|
||||
{
|
||||
mErrorOffset = 0;
|
||||
mError = NULL;
|
||||
re = NULL;
|
||||
mFree = true;
|
||||
subject = NULL;
|
||||
mSubStrings = 0;
|
||||
}
|
||||
|
||||
void RegEx::Clear ()
|
||||
{
|
||||
mErrorOffset = 0;
|
||||
mError = NULL;
|
||||
if (re)
|
||||
pcre_free(re);
|
||||
re = NULL;
|
||||
mFree = true;
|
||||
if (subject)
|
||||
delete [] subject;
|
||||
subject = NULL;
|
||||
mSubStrings = 0;
|
||||
}
|
||||
|
||||
RegEx::~RegEx()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
bool RegEx::isFree(bool set, bool val)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
mFree = val;
|
||||
return true;
|
||||
} else {
|
||||
return mFree;
|
||||
}
|
||||
}
|
||||
|
||||
int RegEx::Compile(const char *pattern, int iFlags)
|
||||
{
|
||||
if (!mFree)
|
||||
Clear();
|
||||
|
||||
re = pcre_compile(pattern, iFlags, &mError, &mErrorOffset, NULL);
|
||||
|
||||
if (re == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
mFree = false;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RegEx::Match(const char *str)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (mFree || re == NULL)
|
||||
return -1;
|
||||
|
||||
this->ClearMatch();
|
||||
|
||||
//save str
|
||||
subject = new char[strlen(str)+1];
|
||||
strcpy(subject, str);
|
||||
|
||||
rc = pcre_exec(re, NULL, subject, (int)strlen(subject), 0, 0, ovector, 30);
|
||||
|
||||
if (rc < 0)
|
||||
{
|
||||
if (rc == PCRE_ERROR_NOMATCH)
|
||||
{
|
||||
return 0;
|
||||
} else {
|
||||
mErrorOffset = rc;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
mSubStrings = rc;
|
||||
|
||||
return 1;
|
||||
}
|
||||
void RegEx::ClearMatch()
|
||||
{
|
||||
// Clears match results
|
||||
mErrorOffset = 0;
|
||||
mError = NULL;
|
||||
if (subject)
|
||||
delete [] subject;
|
||||
subject = NULL;
|
||||
mSubStrings = 0;
|
||||
}
|
||||
|
||||
const char *RegEx::GetSubstring(int s, char buffer[], int max)
|
||||
{
|
||||
int i = 0;
|
||||
if (s >= mSubStrings || s < 0)
|
||||
return NULL;
|
||||
|
||||
char *substr_a = subject + ovector[2*s];
|
||||
int substr_l = ovector[2*s+1] - ovector[2*s];
|
||||
|
||||
for (i = 0; i<substr_l; i++)
|
||||
{
|
||||
if (i >= max)
|
||||
break;
|
||||
buffer[i] = substr_a[i];
|
||||
}
|
||||
|
||||
buffer[i] = '\0';
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -1,59 +1,59 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SQLite Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_CREGEX_H
|
||||
#define _INCLUDE_CREGEX_H
|
||||
|
||||
class RegEx
|
||||
{
|
||||
public:
|
||||
RegEx();
|
||||
~RegEx();
|
||||
bool isFree(bool set=false, bool val=false);
|
||||
void Clear();
|
||||
|
||||
int Compile(const char *pattern, int iFlags);
|
||||
int Match(const char *str);
|
||||
void ClearMatch();
|
||||
const char *GetSubstring(int s, char buffer[], int max);
|
||||
public:
|
||||
int mErrorOffset;
|
||||
const char *mError;
|
||||
int mSubStrings;
|
||||
private:
|
||||
pcre *re;
|
||||
bool mFree;
|
||||
int ovector[30];
|
||||
char *subject;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_CREGEX_H
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Regular Expressions Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_CREGEX_H
|
||||
#define _INCLUDE_CREGEX_H
|
||||
|
||||
class RegEx
|
||||
{
|
||||
public:
|
||||
RegEx();
|
||||
~RegEx();
|
||||
bool isFree(bool set=false, bool val=false);
|
||||
void Clear();
|
||||
|
||||
int Compile(const char *pattern, int iFlags);
|
||||
int Match(const char *str);
|
||||
void ClearMatch();
|
||||
const char *GetSubstring(int s, char buffer[], int max);
|
||||
public:
|
||||
int mErrorOffset;
|
||||
const char *mError;
|
||||
int mSubStrings;
|
||||
private:
|
||||
pcre *re;
|
||||
bool mFree;
|
||||
int ovector[30];
|
||||
char *subject;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_CREGEX_H
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* SourceMod Regular Expressions Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
@ -38,7 +38,7 @@ using namespace SourceHook;
|
||||
|
||||
/**
|
||||
* @file extension.cpp
|
||||
* @brief Implement extension code here.
|
||||
* @brief Implement Regex extension code here.
|
||||
*/
|
||||
|
||||
RegexExtension g_RegexExtension; /**< Global singleton for extension's main interface */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* SourceMod Regular Expressions Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
/**
|
||||
* @file extension.h
|
||||
* @brief Sample extension code header.
|
||||
* @brief Regex extension code header.
|
||||
*/
|
||||
|
||||
#include "smsdk_ext.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* SourceMod Regular Expressions Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SQLite Extension
|
||||
* SourceMod Regular Expressions Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SQLite Extension
|
||||
* SourceMod Regular Expressions Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -2,7 +2,7 @@
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* 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
|
||||
|
@ -17,7 +17,7 @@ PROJECT = dbi.sqlite
|
||||
#Uncomment for Metamod: Source enabled extension
|
||||
#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/SqResults.cpp
|
||||
|
||||
|
@ -189,10 +189,6 @@
|
||||
RelativePath="..\extension.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sm_memtable.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@ -203,10 +199,6 @@
|
||||
RelativePath="..\extension.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sm_memtable.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
@ -226,6 +218,14 @@
|
||||
Name="SourceMod SDK"
|
||||
UniqueIdentifier="{31958233-BB2D-4e41-A8F9-CE8A4684F436}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\sdk\sm_memtable.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sdk\sm_memtable.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sdk\smsdk_config.h"
|
||||
>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod TF2 Extension
|
||||
* SourceMod Team Fortress 2 Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod TF2 Extension
|
||||
* SourceMod Team Fortress 2 Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SDKTools Extension
|
||||
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
||||
* SourceMod Team Fortress 2 Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Team Fortress 2 Extension
|
||||
* SourceMod Base Extension Code
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Team Fortress 2 Extension
|
||||
* SourceMod Base Extension Code
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SDKTools Extension
|
||||
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
||||
* SourceMod Team Fortress 2 Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SDKTools Extension
|
||||
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
||||
* SourceMod Team Fortress 2 Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
|
@ -17,8 +17,8 @@ PROJECT = topmenus
|
||||
#Uncomment for Metamod: Source enabled extension
|
||||
#USEMETA = true
|
||||
|
||||
OBJECTS = sdk/smsdk_ext.cpp extension.cpp TopMenuManager.cpp TopMenu.cpp \
|
||||
sdk/sm_memtable.cpp smn_topmenus.cpp
|
||||
OBJECTS = sdk/smsdk_ext.cpp sdk/sm_memtable.cpp extension.cpp TopMenuManager.cpp \
|
||||
TopMenu.cpp smn_topmenus.cpp
|
||||
|
||||
##############################################
|
||||
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,181 +1,181 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_TOP_MENU_H_
|
||||
#define _INCLUDE_SOURCEMOD_TOP_MENU_H_
|
||||
|
||||
#include <sh_list.h>
|
||||
#include <sh_vector.h>
|
||||
#include <sm_trie_tpl.h>
|
||||
#include <ITopMenus.h>
|
||||
#include "smsdk_ext.h"
|
||||
#include "sm_memtable.h"
|
||||
|
||||
using namespace SourceHook;
|
||||
using namespace SourceMod;
|
||||
|
||||
struct config_category_t
|
||||
{
|
||||
int name;
|
||||
CVector<int> commands;
|
||||
};
|
||||
|
||||
struct config_root_t
|
||||
{
|
||||
config_root_t() : strings(1024)
|
||||
{
|
||||
}
|
||||
BaseStringTable strings;
|
||||
CVector<config_category_t *> cats;
|
||||
};
|
||||
|
||||
struct topmenu_object_t
|
||||
{
|
||||
char name[64]; /** Name */
|
||||
char cmdname[64]; /** Command name */
|
||||
FlagBits flags; /** Admin flags */
|
||||
ITopMenuObjectCallbacks *callbacks; /** Callbacks */
|
||||
IdentityToken_t *owner; /** Owner */
|
||||
unsigned int object_id; /** Object ID */
|
||||
topmenu_object_t *parent; /** Parent, if any */
|
||||
TopMenuObjectType type; /** Object Type */
|
||||
bool is_free; /** Free or not? */
|
||||
char info[255]; /** Info string */
|
||||
};
|
||||
|
||||
struct topmenu_category_t
|
||||
{
|
||||
CVector<topmenu_object_t *> obj_list; /** Full object list */
|
||||
CVector<topmenu_object_t *> sorted; /** Sorted items */
|
||||
CVector<topmenu_object_t *> unsorted; /** Unsorted items */
|
||||
topmenu_object_t *obj; /** Bound object */
|
||||
unsigned int serial; /** Serial number */
|
||||
bool reorder; /** Whether ordering needs updating */
|
||||
};
|
||||
|
||||
struct topmenu_player_category_t
|
||||
{
|
||||
IBaseMenu *menu; /** menu pointer */
|
||||
unsigned int serial; /** last known serial */
|
||||
};
|
||||
|
||||
struct topmenu_player_t
|
||||
{
|
||||
int user_id; /** userid on server */
|
||||
unsigned int menu_serial; /** menu serial no */
|
||||
IBaseMenu *root; /** root menu display */
|
||||
topmenu_player_category_t *cats; /** category display */
|
||||
unsigned int cat_count; /** number of categories */
|
||||
unsigned int last_category; /** last category they selected */
|
||||
unsigned int last_position; /** last position in that category */
|
||||
unsigned int last_root_pos; /** last page in the root menu */
|
||||
};
|
||||
|
||||
class TopMenu :
|
||||
public ITopMenu,
|
||||
public IMenuHandler,
|
||||
public ITextListener_SMC
|
||||
{
|
||||
friend class TopMenuManager;
|
||||
public:
|
||||
TopMenu(ITopMenuObjectCallbacks *callbacks);
|
||||
~TopMenu();
|
||||
public: //ITopMenu
|
||||
virtual unsigned int AddToMenu(const char *name,
|
||||
TopMenuObjectType type,
|
||||
ITopMenuObjectCallbacks *callbacks,
|
||||
IdentityToken_t *owner,
|
||||
const char *cmdname,
|
||||
FlagBits flags,
|
||||
unsigned int parent);
|
||||
unsigned int AddToMenu2(const char *name,
|
||||
TopMenuObjectType type,
|
||||
ITopMenuObjectCallbacks *callbacks,
|
||||
IdentityToken_t *owner,
|
||||
const char *cmdname,
|
||||
FlagBits flags,
|
||||
unsigned int parent,
|
||||
const char *info_string);
|
||||
virtual void RemoveFromMenu(unsigned int object_id);
|
||||
virtual bool DisplayMenu(int client,
|
||||
unsigned int hold_time,
|
||||
TopMenuPosition position);
|
||||
virtual bool LoadConfiguration(const char *file, char *error, size_t maxlength);
|
||||
virtual unsigned int FindCategory(const char *name);
|
||||
const char *GetObjectInfoString(unsigned int object_id);
|
||||
const char *GetObjectName(unsigned int object_id);
|
||||
public: //IMenuHandler
|
||||
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 unsigned int OnMenuDisplayItem(IBaseMenu *menu,
|
||||
int client,
|
||||
IMenuPanel *panel,
|
||||
unsigned int item,
|
||||
const ItemDrawInfo &dr);
|
||||
virtual void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason);
|
||||
public: //ITextListener_SMC
|
||||
void ReadSMC_ParseStart();
|
||||
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
|
||||
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
|
||||
SMCResult ReadSMC_LeavingSection(const SMCStates *states);
|
||||
public:
|
||||
unsigned int CalcMemUsage();
|
||||
private:
|
||||
void SortCategoriesIfNeeded();
|
||||
void SortCategoryIfNeeded(unsigned int category);
|
||||
private:
|
||||
bool DisplayCategory(int client, unsigned int category, unsigned int hold_time, bool last_position);
|
||||
void CreatePlayers(int max_clients);
|
||||
void UpdateClientRoot(int client, IGamePlayer *pGamePlayer=NULL);
|
||||
void UpdateClientCategory(int client, unsigned int category);
|
||||
void TearDownClient(topmenu_player_t *player);
|
||||
private:
|
||||
void OnClientConnected(int client);
|
||||
void OnClientDisconnected(int client);
|
||||
void OnServerActivated(int max_clients);
|
||||
bool OnIdentityRemoval(IdentityToken_t *owner);
|
||||
private:
|
||||
config_root_t m_Config; /* Configuration from file */
|
||||
topmenu_player_t *m_clients; /* Client array */
|
||||
CVector<unsigned int> m_SortedCats; /* Sorted categories */
|
||||
CVector<unsigned int> m_UnsortedCats; /* Un-sorted categories */
|
||||
CVector<topmenu_category_t *> m_Categories; /* Category array */
|
||||
CVector<topmenu_object_t *> m_Objects; /* Object array */
|
||||
KTrie<topmenu_object_t *> m_ObjLookup; /* Object lookup trie */
|
||||
unsigned int m_SerialNo; /* Serial number for updating */
|
||||
ITopMenuObjectCallbacks *m_pTitle; /* Title callbacks */
|
||||
int m_max_clients; /* Maximum number of clients */
|
||||
bool m_bCatsNeedResort; /* True if categories need a resort */
|
||||
};
|
||||
|
||||
unsigned int strncopy(char *dest, const char *src, size_t count);
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_TOP_MENU_H_
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_TOP_MENU_H_
|
||||
#define _INCLUDE_SOURCEMOD_TOP_MENU_H_
|
||||
|
||||
#include <sh_list.h>
|
||||
#include <sh_vector.h>
|
||||
#include <sm_trie_tpl.h>
|
||||
#include <ITopMenus.h>
|
||||
#include "smsdk_ext.h"
|
||||
#include "sm_memtable.h"
|
||||
|
||||
using namespace SourceHook;
|
||||
using namespace SourceMod;
|
||||
|
||||
struct config_category_t
|
||||
{
|
||||
int name;
|
||||
CVector<int> commands;
|
||||
};
|
||||
|
||||
struct config_root_t
|
||||
{
|
||||
config_root_t() : strings(1024)
|
||||
{
|
||||
}
|
||||
BaseStringTable strings;
|
||||
CVector<config_category_t *> cats;
|
||||
};
|
||||
|
||||
struct topmenu_object_t
|
||||
{
|
||||
char name[64]; /** Name */
|
||||
char cmdname[64]; /** Command name */
|
||||
FlagBits flags; /** Admin flags */
|
||||
ITopMenuObjectCallbacks *callbacks; /** Callbacks */
|
||||
IdentityToken_t *owner; /** Owner */
|
||||
unsigned int object_id; /** Object ID */
|
||||
topmenu_object_t *parent; /** Parent, if any */
|
||||
TopMenuObjectType type; /** Object Type */
|
||||
bool is_free; /** Free or not? */
|
||||
char info[255]; /** Info string */
|
||||
};
|
||||
|
||||
struct topmenu_category_t
|
||||
{
|
||||
CVector<topmenu_object_t *> obj_list; /** Full object list */
|
||||
CVector<topmenu_object_t *> sorted; /** Sorted items */
|
||||
CVector<topmenu_object_t *> unsorted; /** Unsorted items */
|
||||
topmenu_object_t *obj; /** Bound object */
|
||||
unsigned int serial; /** Serial number */
|
||||
bool reorder; /** Whether ordering needs updating */
|
||||
};
|
||||
|
||||
struct topmenu_player_category_t
|
||||
{
|
||||
IBaseMenu *menu; /** menu pointer */
|
||||
unsigned int serial; /** last known serial */
|
||||
};
|
||||
|
||||
struct topmenu_player_t
|
||||
{
|
||||
int user_id; /** userid on server */
|
||||
unsigned int menu_serial; /** menu serial no */
|
||||
IBaseMenu *root; /** root menu display */
|
||||
topmenu_player_category_t *cats; /** category display */
|
||||
unsigned int cat_count; /** number of categories */
|
||||
unsigned int last_category; /** last category they selected */
|
||||
unsigned int last_position; /** last position in that category */
|
||||
unsigned int last_root_pos; /** last page in the root menu */
|
||||
};
|
||||
|
||||
class TopMenu :
|
||||
public ITopMenu,
|
||||
public IMenuHandler,
|
||||
public ITextListener_SMC
|
||||
{
|
||||
friend class TopMenuManager;
|
||||
public:
|
||||
TopMenu(ITopMenuObjectCallbacks *callbacks);
|
||||
~TopMenu();
|
||||
public: //ITopMenu
|
||||
virtual unsigned int AddToMenu(const char *name,
|
||||
TopMenuObjectType type,
|
||||
ITopMenuObjectCallbacks *callbacks,
|
||||
IdentityToken_t *owner,
|
||||
const char *cmdname,
|
||||
FlagBits flags,
|
||||
unsigned int parent);
|
||||
unsigned int AddToMenu2(const char *name,
|
||||
TopMenuObjectType type,
|
||||
ITopMenuObjectCallbacks *callbacks,
|
||||
IdentityToken_t *owner,
|
||||
const char *cmdname,
|
||||
FlagBits flags,
|
||||
unsigned int parent,
|
||||
const char *info_string);
|
||||
virtual void RemoveFromMenu(unsigned int object_id);
|
||||
virtual bool DisplayMenu(int client,
|
||||
unsigned int hold_time,
|
||||
TopMenuPosition position);
|
||||
virtual bool LoadConfiguration(const char *file, char *error, size_t maxlength);
|
||||
virtual unsigned int FindCategory(const char *name);
|
||||
const char *GetObjectInfoString(unsigned int object_id);
|
||||
const char *GetObjectName(unsigned int object_id);
|
||||
public: //IMenuHandler
|
||||
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 unsigned int OnMenuDisplayItem(IBaseMenu *menu,
|
||||
int client,
|
||||
IMenuPanel *panel,
|
||||
unsigned int item,
|
||||
const ItemDrawInfo &dr);
|
||||
virtual void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason);
|
||||
public: //ITextListener_SMC
|
||||
void ReadSMC_ParseStart();
|
||||
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
|
||||
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
|
||||
SMCResult ReadSMC_LeavingSection(const SMCStates *states);
|
||||
public:
|
||||
unsigned int CalcMemUsage();
|
||||
private:
|
||||
void SortCategoriesIfNeeded();
|
||||
void SortCategoryIfNeeded(unsigned int category);
|
||||
private:
|
||||
bool DisplayCategory(int client, unsigned int category, unsigned int hold_time, bool last_position);
|
||||
void CreatePlayers(int max_clients);
|
||||
void UpdateClientRoot(int client, IGamePlayer *pGamePlayer=NULL);
|
||||
void UpdateClientCategory(int client, unsigned int category);
|
||||
void TearDownClient(topmenu_player_t *player);
|
||||
private:
|
||||
void OnClientConnected(int client);
|
||||
void OnClientDisconnected(int client);
|
||||
void OnServerActivated(int max_clients);
|
||||
bool OnIdentityRemoval(IdentityToken_t *owner);
|
||||
private:
|
||||
config_root_t m_Config; /* Configuration from file */
|
||||
topmenu_player_t *m_clients; /* Client array */
|
||||
CVector<unsigned int> m_SortedCats; /* Sorted categories */
|
||||
CVector<unsigned int> m_UnsortedCats; /* Un-sorted categories */
|
||||
CVector<topmenu_category_t *> m_Categories; /* Category array */
|
||||
CVector<topmenu_object_t *> m_Objects; /* Object array */
|
||||
KTrie<topmenu_object_t *> m_ObjLookup; /* Object lookup trie */
|
||||
unsigned int m_SerialNo; /* Serial number for updating */
|
||||
ITopMenuObjectCallbacks *m_pTitle; /* Title callbacks */
|
||||
int m_max_clients; /* Maximum number of clients */
|
||||
bool m_bCatsNeedResort; /* True if categories need a resort */
|
||||
};
|
||||
|
||||
unsigned int strncopy(char *dest, const char *src, size_t count);
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_TOP_MENU_H_
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,388 +1,388 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "extension.h"
|
||||
#include "TopMenuManager.h"
|
||||
#include "TopMenu.h"
|
||||
|
||||
HandleType_t hTopMenuType;
|
||||
|
||||
class TopMenuHandle : public IHandleTypeDispatch
|
||||
{
|
||||
public:
|
||||
void OnHandleDestroy(HandleType_t type, void *object)
|
||||
{
|
||||
ITopMenu *pTopMenu = (ITopMenu *)object;
|
||||
g_TopMenus.DestroyTopMenu(pTopMenu);
|
||||
}
|
||||
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize)
|
||||
{
|
||||
*pSize = ((TopMenu *)object)->CalcMemUsage();
|
||||
return true;
|
||||
}
|
||||
} s_TopMenuHandle;
|
||||
|
||||
void Initialize_Natives()
|
||||
{
|
||||
hTopMenuType = handlesys->CreateType("ITopMenu",
|
||||
&s_TopMenuHandle,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
myself->GetIdentity(),
|
||||
NULL);
|
||||
}
|
||||
|
||||
void Shutdown_Natives()
|
||||
{
|
||||
handlesys->RemoveType(hTopMenuType, myself->GetIdentity());
|
||||
}
|
||||
|
||||
enum TopMenuAction
|
||||
{
|
||||
TopMenuAction_DisplayOption = 0,
|
||||
TopMenuAction_DisplayTitle = 1,
|
||||
TopMenuAction_SelectOption = 2,
|
||||
TopMenuAction_DrawOption = 3,
|
||||
TopMenuAction_RemoveObject = 4,
|
||||
};
|
||||
|
||||
class TopMenuCallbacks : public ITopMenuObjectCallbacks
|
||||
{
|
||||
public:
|
||||
TopMenuCallbacks(IPluginFunction *pFunction) : m_pFunction(pFunction)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int OnTopMenuDrawOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id)
|
||||
{
|
||||
char buffer[2] = {ITEMDRAW_DEFAULT, 0x0};
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_DrawOption);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushStringEx(buffer, sizeof(buffer), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
|
||||
m_pFunction->PushCell(sizeof(buffer));
|
||||
m_pFunction->Execute(NULL);
|
||||
return (unsigned int)buffer[0];
|
||||
}
|
||||
|
||||
void OnTopMenuDisplayOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id,
|
||||
char buffer[],
|
||||
size_t maxlength)
|
||||
{
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_DisplayOption);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK);
|
||||
m_pFunction->PushCell(maxlength);
|
||||
m_pFunction->Execute(NULL);
|
||||
}
|
||||
|
||||
void OnTopMenuDisplayTitle(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id,
|
||||
char buffer[],
|
||||
size_t maxlength)
|
||||
{
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_DisplayTitle);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK);
|
||||
m_pFunction->PushCell(maxlength);
|
||||
m_pFunction->Execute(NULL);
|
||||
}
|
||||
|
||||
void OnTopMenuSelectOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id)
|
||||
{
|
||||
unsigned int old_reply = playerhelpers->SetReplyTo(SM_REPLY_CHAT);
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_SelectOption);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushString("");
|
||||
m_pFunction->PushCell(0);
|
||||
m_pFunction->Execute(NULL);
|
||||
playerhelpers->SetReplyTo(old_reply);
|
||||
}
|
||||
|
||||
void OnTopMenuObjectRemoved(ITopMenu *menu, unsigned int object_id)
|
||||
{
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_RemoveObject);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(0);
|
||||
m_pFunction->PushString("");
|
||||
m_pFunction->PushCell(0);
|
||||
m_pFunction->Execute(NULL);
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
Handle_t m_hMenuHandle;
|
||||
IPluginFunction *m_pFunction;
|
||||
};
|
||||
|
||||
static cell_t CreateTopMenu(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IPluginFunction *func = pContext->GetFunctionById(params[1]);
|
||||
if (func == NULL)
|
||||
{
|
||||
return pContext ->ThrowNativeError("Invalid function specified");
|
||||
}
|
||||
|
||||
TopMenuCallbacks *cb = new TopMenuCallbacks(func);
|
||||
|
||||
ITopMenu *pMenu = g_TopMenus.CreateTopMenu(cb);
|
||||
|
||||
if (!pMenu)
|
||||
{
|
||||
delete cb;
|
||||
return BAD_HANDLE;
|
||||
}
|
||||
|
||||
Handle_t hndl = handlesys->CreateHandle(hTopMenuType,
|
||||
pMenu,
|
||||
pContext->GetIdentity(),
|
||||
myself->GetIdentity(),
|
||||
NULL);
|
||||
if (hndl == 0)
|
||||
{
|
||||
g_TopMenus.DestroyTopMenu(pMenu);
|
||||
return BAD_HANDLE;
|
||||
}
|
||||
|
||||
cb->m_hMenuHandle = hndl;
|
||||
|
||||
return hndl;
|
||||
}
|
||||
|
||||
static cell_t LoadTopMenuConfig(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
char *file, *err_buf;
|
||||
pContext->LocalToString(params[2], &file);
|
||||
pContext->LocalToString(params[3], &err_buf);
|
||||
|
||||
char path[PLATFORM_MAX_PATH];
|
||||
g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file);
|
||||
|
||||
return pMenu->LoadConfiguration(path, err_buf, params[4]) ? 1 : 0;
|
||||
}
|
||||
|
||||
static cell_t AddToTopMenu(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
IPluginFunction *func = pContext->GetFunctionById(params[4]);
|
||||
if (func == NULL)
|
||||
{
|
||||
return pContext ->ThrowNativeError("Invalid function specified");
|
||||
}
|
||||
|
||||
TopMenuCallbacks *cb = new TopMenuCallbacks(func);
|
||||
|
||||
char *name, *cmdname, *info_string = NULL;
|
||||
pContext->LocalToString(params[2], &name);
|
||||
pContext->LocalToString(params[6], &cmdname);
|
||||
|
||||
if (params[0] >= 8)
|
||||
{
|
||||
pContext->LocalToString(params[8], &info_string);
|
||||
}
|
||||
|
||||
TopMenuObjectType obj_type = (TopMenuObjectType)params[3];
|
||||
|
||||
unsigned int object_id;
|
||||
if ((object_id = pMenu->AddToMenu2(name,
|
||||
obj_type,
|
||||
cb,
|
||||
pContext->GetIdentity(),
|
||||
cmdname,
|
||||
params[7],
|
||||
params[5],
|
||||
info_string)) == 0)
|
||||
{
|
||||
delete cb;
|
||||
return 0;
|
||||
}
|
||||
|
||||
cb->m_hMenuHandle = params[1];
|
||||
|
||||
return object_id;
|
||||
}
|
||||
|
||||
static cell_t RemoveFromTopMenu(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
pMenu->RemoveFromMenu(params[2]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t FindTopMenuCategory(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
char *name;
|
||||
pContext->LocalToString(params[2], &name);
|
||||
|
||||
return pMenu->FindCategory(name);
|
||||
}
|
||||
|
||||
static cell_t DisplayTopMenu(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
int client = params[2];
|
||||
IGamePlayer *player = playerhelpers->GetGamePlayer(client);
|
||||
if (!player)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid client index %d", client);
|
||||
}
|
||||
else if (!player->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||
}
|
||||
|
||||
return pMenu->DisplayMenu(client, 0, (TopMenuPosition)params[3]);
|
||||
}
|
||||
|
||||
static cell_t GetTopMenuInfoString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
const char *str;
|
||||
if ((str = pMenu->GetObjectInfoString(params[2])) == NULL)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid menu object %d", params[2]);
|
||||
}
|
||||
|
||||
char *buffer;
|
||||
pContext->LocalToString(params[3], &buffer);
|
||||
|
||||
return strncopy(buffer, str, params[4]);
|
||||
}
|
||||
|
||||
static cell_t GetTopMenuName(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
const char *str;
|
||||
if ((str = pMenu->GetObjectName(params[2])) == NULL)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid menu object %d", params[2]);
|
||||
}
|
||||
|
||||
char *buffer;
|
||||
pContext->LocalToString(params[3], &buffer);
|
||||
|
||||
return strncopy(buffer, str, params[4]);
|
||||
}
|
||||
|
||||
sp_nativeinfo_t g_TopMenuNatives[] =
|
||||
{
|
||||
{"AddToTopMenu", AddToTopMenu},
|
||||
{"CreateTopMenu", CreateTopMenu},
|
||||
{"DisplayTopMenu", DisplayTopMenu},
|
||||
{"LoadTopMenuConfig", LoadTopMenuConfig},
|
||||
{"RemoveFromTopMenu", RemoveFromTopMenu},
|
||||
{"FindTopMenuCategory", FindTopMenuCategory},
|
||||
{"GetTopMenuInfoString", GetTopMenuInfoString},
|
||||
{"GetTopMenuObjName", GetTopMenuName},
|
||||
{NULL, NULL},
|
||||
};
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "extension.h"
|
||||
#include "TopMenuManager.h"
|
||||
#include "TopMenu.h"
|
||||
|
||||
HandleType_t hTopMenuType;
|
||||
|
||||
class TopMenuHandle : public IHandleTypeDispatch
|
||||
{
|
||||
public:
|
||||
void OnHandleDestroy(HandleType_t type, void *object)
|
||||
{
|
||||
ITopMenu *pTopMenu = (ITopMenu *)object;
|
||||
g_TopMenus.DestroyTopMenu(pTopMenu);
|
||||
}
|
||||
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize)
|
||||
{
|
||||
*pSize = ((TopMenu *)object)->CalcMemUsage();
|
||||
return true;
|
||||
}
|
||||
} s_TopMenuHandle;
|
||||
|
||||
void Initialize_Natives()
|
||||
{
|
||||
hTopMenuType = handlesys->CreateType("ITopMenu",
|
||||
&s_TopMenuHandle,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
myself->GetIdentity(),
|
||||
NULL);
|
||||
}
|
||||
|
||||
void Shutdown_Natives()
|
||||
{
|
||||
handlesys->RemoveType(hTopMenuType, myself->GetIdentity());
|
||||
}
|
||||
|
||||
enum TopMenuAction
|
||||
{
|
||||
TopMenuAction_DisplayOption = 0,
|
||||
TopMenuAction_DisplayTitle = 1,
|
||||
TopMenuAction_SelectOption = 2,
|
||||
TopMenuAction_DrawOption = 3,
|
||||
TopMenuAction_RemoveObject = 4,
|
||||
};
|
||||
|
||||
class TopMenuCallbacks : public ITopMenuObjectCallbacks
|
||||
{
|
||||
public:
|
||||
TopMenuCallbacks(IPluginFunction *pFunction) : m_pFunction(pFunction)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int OnTopMenuDrawOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id)
|
||||
{
|
||||
char buffer[2] = {ITEMDRAW_DEFAULT, 0x0};
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_DrawOption);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushStringEx(buffer, sizeof(buffer), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
|
||||
m_pFunction->PushCell(sizeof(buffer));
|
||||
m_pFunction->Execute(NULL);
|
||||
return (unsigned int)buffer[0];
|
||||
}
|
||||
|
||||
void OnTopMenuDisplayOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id,
|
||||
char buffer[],
|
||||
size_t maxlength)
|
||||
{
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_DisplayOption);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK);
|
||||
m_pFunction->PushCell(maxlength);
|
||||
m_pFunction->Execute(NULL);
|
||||
}
|
||||
|
||||
void OnTopMenuDisplayTitle(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id,
|
||||
char buffer[],
|
||||
size_t maxlength)
|
||||
{
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_DisplayTitle);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK);
|
||||
m_pFunction->PushCell(maxlength);
|
||||
m_pFunction->Execute(NULL);
|
||||
}
|
||||
|
||||
void OnTopMenuSelectOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id)
|
||||
{
|
||||
unsigned int old_reply = playerhelpers->SetReplyTo(SM_REPLY_CHAT);
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_SelectOption);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushString("");
|
||||
m_pFunction->PushCell(0);
|
||||
m_pFunction->Execute(NULL);
|
||||
playerhelpers->SetReplyTo(old_reply);
|
||||
}
|
||||
|
||||
void OnTopMenuObjectRemoved(ITopMenu *menu, unsigned int object_id)
|
||||
{
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_RemoveObject);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(0);
|
||||
m_pFunction->PushString("");
|
||||
m_pFunction->PushCell(0);
|
||||
m_pFunction->Execute(NULL);
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
Handle_t m_hMenuHandle;
|
||||
IPluginFunction *m_pFunction;
|
||||
};
|
||||
|
||||
static cell_t CreateTopMenu(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IPluginFunction *func = pContext->GetFunctionById(params[1]);
|
||||
if (func == NULL)
|
||||
{
|
||||
return pContext ->ThrowNativeError("Invalid function specified");
|
||||
}
|
||||
|
||||
TopMenuCallbacks *cb = new TopMenuCallbacks(func);
|
||||
|
||||
ITopMenu *pMenu = g_TopMenus.CreateTopMenu(cb);
|
||||
|
||||
if (!pMenu)
|
||||
{
|
||||
delete cb;
|
||||
return BAD_HANDLE;
|
||||
}
|
||||
|
||||
Handle_t hndl = handlesys->CreateHandle(hTopMenuType,
|
||||
pMenu,
|
||||
pContext->GetIdentity(),
|
||||
myself->GetIdentity(),
|
||||
NULL);
|
||||
if (hndl == 0)
|
||||
{
|
||||
g_TopMenus.DestroyTopMenu(pMenu);
|
||||
return BAD_HANDLE;
|
||||
}
|
||||
|
||||
cb->m_hMenuHandle = hndl;
|
||||
|
||||
return hndl;
|
||||
}
|
||||
|
||||
static cell_t LoadTopMenuConfig(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
char *file, *err_buf;
|
||||
pContext->LocalToString(params[2], &file);
|
||||
pContext->LocalToString(params[3], &err_buf);
|
||||
|
||||
char path[PLATFORM_MAX_PATH];
|
||||
g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file);
|
||||
|
||||
return pMenu->LoadConfiguration(path, err_buf, params[4]) ? 1 : 0;
|
||||
}
|
||||
|
||||
static cell_t AddToTopMenu(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
IPluginFunction *func = pContext->GetFunctionById(params[4]);
|
||||
if (func == NULL)
|
||||
{
|
||||
return pContext ->ThrowNativeError("Invalid function specified");
|
||||
}
|
||||
|
||||
TopMenuCallbacks *cb = new TopMenuCallbacks(func);
|
||||
|
||||
char *name, *cmdname, *info_string = NULL;
|
||||
pContext->LocalToString(params[2], &name);
|
||||
pContext->LocalToString(params[6], &cmdname);
|
||||
|
||||
if (params[0] >= 8)
|
||||
{
|
||||
pContext->LocalToString(params[8], &info_string);
|
||||
}
|
||||
|
||||
TopMenuObjectType obj_type = (TopMenuObjectType)params[3];
|
||||
|
||||
unsigned int object_id;
|
||||
if ((object_id = pMenu->AddToMenu2(name,
|
||||
obj_type,
|
||||
cb,
|
||||
pContext->GetIdentity(),
|
||||
cmdname,
|
||||
params[7],
|
||||
params[5],
|
||||
info_string)) == 0)
|
||||
{
|
||||
delete cb;
|
||||
return 0;
|
||||
}
|
||||
|
||||
cb->m_hMenuHandle = params[1];
|
||||
|
||||
return object_id;
|
||||
}
|
||||
|
||||
static cell_t RemoveFromTopMenu(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
pMenu->RemoveFromMenu(params[2]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t FindTopMenuCategory(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
char *name;
|
||||
pContext->LocalToString(params[2], &name);
|
||||
|
||||
return pMenu->FindCategory(name);
|
||||
}
|
||||
|
||||
static cell_t DisplayTopMenu(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
int client = params[2];
|
||||
IGamePlayer *player = playerhelpers->GetGamePlayer(client);
|
||||
if (!player)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid client index %d", client);
|
||||
}
|
||||
else if (!player->IsInGame())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not in game", client);
|
||||
}
|
||||
|
||||
return pMenu->DisplayMenu(client, 0, (TopMenuPosition)params[3]);
|
||||
}
|
||||
|
||||
static cell_t GetTopMenuInfoString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
const char *str;
|
||||
if ((str = pMenu->GetObjectInfoString(params[2])) == NULL)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid menu object %d", params[2]);
|
||||
}
|
||||
|
||||
char *buffer;
|
||||
pContext->LocalToString(params[3], &buffer);
|
||||
|
||||
return strncopy(buffer, str, params[4]);
|
||||
}
|
||||
|
||||
static cell_t GetTopMenuName(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
HandleError err;
|
||||
ITopMenu *pMenu;
|
||||
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
|
||||
|
||||
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
|
||||
!= HandleError_None)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
|
||||
}
|
||||
|
||||
const char *str;
|
||||
if ((str = pMenu->GetObjectName(params[2])) == NULL)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid menu object %d", params[2]);
|
||||
}
|
||||
|
||||
char *buffer;
|
||||
pContext->LocalToString(params[3], &buffer);
|
||||
|
||||
return strncopy(buffer, str, params[4]);
|
||||
}
|
||||
|
||||
sp_nativeinfo_t g_TopMenuNatives[] =
|
||||
{
|
||||
{"AddToTopMenu", AddToTopMenu},
|
||||
{"CreateTopMenu", CreateTopMenu},
|
||||
{"DisplayTopMenu", DisplayTopMenu},
|
||||
{"LoadTopMenuConfig", LoadTopMenuConfig},
|
||||
{"RemoveFromTopMenu", RemoveFromTopMenu},
|
||||
{"FindTopMenuCategory", FindTopMenuCategory},
|
||||
{"GetTopMenuInfoString", GetTopMenuInfoString},
|
||||
{"GetTopMenuObjName", GetTopMenuName},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Sample Extension
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SQLite Extension
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod SQLite Extension
|
||||
* SourceMod TopMenus Extension
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* 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[])
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
enum CommType
|
||||
|
@ -1,75 +1,75 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Basecommands Plugin
|
||||
* Provides cancelvote functionality.
|
||||
*
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $
|
||||
*/
|
||||
|
||||
PerformCancelVote(client)
|
||||
{
|
||||
if (!IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote Not In Progress");
|
||||
return;
|
||||
}
|
||||
|
||||
ShowActivity2(client, "[SM] ", "%t", "Cancelled Vote");
|
||||
|
||||
CancelVote();
|
||||
}
|
||||
|
||||
public AdminMenu_CancelVote(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Cancel vote", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
PerformCancelVote(param);
|
||||
RedisplayAdminMenu(topmenu, param);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_DEFAULT : ITEMDRAW_IGNORE;
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_CancelVote(client, args)
|
||||
{
|
||||
PerformCancelVote(client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Basecommands Plugin
|
||||
* Provides cancelvote functionality.
|
||||
*
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
PerformCancelVote(client)
|
||||
{
|
||||
if (!IsVoteInProgress())
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Vote Not In Progress");
|
||||
return;
|
||||
}
|
||||
|
||||
ShowActivity2(client, "[SM] ", "%t", "Cancelled Vote");
|
||||
|
||||
CancelVote();
|
||||
}
|
||||
|
||||
public AdminMenu_CancelVote(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength)
|
||||
{
|
||||
if (action == TopMenuAction_DisplayOption)
|
||||
{
|
||||
Format(buffer, maxlength, "%T", "Cancel vote", param);
|
||||
}
|
||||
else if (action == TopMenuAction_SelectOption)
|
||||
{
|
||||
PerformCancelVote(param);
|
||||
RedisplayAdminMenu(topmenu, param);
|
||||
}
|
||||
else if (action == TopMenuAction_DrawOption)
|
||||
{
|
||||
buffer[0] = IsVoteInProgress() ? ITEMDRAW_DEFAULT : ITEMDRAW_IGNORE;
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_CancelVote(client, args)
|
||||
{
|
||||
PerformCancelVote(client);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* 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;
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* 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)
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* 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)
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* 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)
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* 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;
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
DisplayVoteAllTalkMenu(client)
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* 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[])
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
DisplayVoteFFMenu(client)
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
|
||||
|
@ -1,325 +1,325 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#if defined _bitbuffer_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _bitbuffer_included
|
||||
|
||||
/**
|
||||
* Writes a single bit to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param bit Bit to write (true for 1, false for 0).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteBool(Handle:bf, bool:bit);
|
||||
|
||||
/**
|
||||
* Writes a byte to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param byte Byte to write (value will be written as 8bit).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteByte(Handle:bf, byte);
|
||||
|
||||
/**
|
||||
* Writes a byte to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param chr Character to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteChar(Handle:bf, chr);
|
||||
|
||||
/**
|
||||
* Writes a 16bit integer to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param num Integer to write (value will be written as 16bit).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteShort(Handle:bf, num);
|
||||
|
||||
/**
|
||||
* Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param num Integer to write (value will be written as 16bit).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteWord(Handle:bf, num);
|
||||
|
||||
/**
|
||||
* Writes a normal integer to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param num Integer to write (value will be written as 32bit).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteNum(Handle:bf, num);
|
||||
|
||||
/**
|
||||
* Writes a floating point number to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param num Number to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteFloat(Handle:bf, Float:num);
|
||||
|
||||
/**
|
||||
* Writes a string to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param string Text string to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteString(Handle:bf, const String:string[]);
|
||||
|
||||
/**
|
||||
* Writes an entity to a writable bitbuffer (bf_write).
|
||||
* @note This is a wrapper around BfWriteShort().
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param ent Entity index to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle, or invalid entity.
|
||||
*/
|
||||
native BfWriteEntity(Handle:bf, ent);
|
||||
|
||||
/**
|
||||
* Writes a bit angle to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param angle Angle to write.
|
||||
* @param numBits Optional number of bits to use.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteAngle(Handle:bf, Float:angle, numBits=8);
|
||||
|
||||
/**
|
||||
* Writes a coordinate to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param coord Coordinate to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteCoord(Handle:bf, Float:coord);
|
||||
|
||||
/**
|
||||
* Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param coord Coordinate array to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteVecCoord(Handle:bf, Float:coord[3]);
|
||||
|
||||
/**
|
||||
* Writes a 3D normal vector to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param vec Vector to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteVecNormal(Handle:bf, Float:vec[3]);
|
||||
|
||||
/**
|
||||
* Writes a 3D angle vector to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param angles Angle vector to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteAngles(Handle:bf, Float:angles[3]);
|
||||
|
||||
/**
|
||||
* Reads a single bit from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Bit value read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native bool:BfReadBool(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a byte from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Byte value read (read as 8bit).
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadByte(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a character from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Character value read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadChar(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a 16bit integer from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Integer value read (read as 16bit).
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadShort(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Integer value read (read as 16bit).
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadWord(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a normal integer to a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Integer value read (read as 32bit).
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadNum(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a floating point number from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Floating point value read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native Float:BfReadFloat(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a string from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param buffer Destination 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.
|
||||
* @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
|
||||
* 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
|
||||
* return value.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
|
||||
|
||||
/**
|
||||
* Reads an entity from a readable bitbuffer (bf_read).
|
||||
* @note This is a wrapper around BfReadShort().
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Entity index read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadEntity(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a bit angle from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param numBits Optional number of bits to use.
|
||||
* @return Angle read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native Float:BfReadAngle(Handle:bf, numBits=8);
|
||||
|
||||
/**
|
||||
* Reads a coordinate from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Coordinate read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native Float:BfReadCoord(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param coord Destination coordinate array.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadVecCoord(Handle:bf, Float:coord[3]);
|
||||
|
||||
/**
|
||||
* Reads a 3D normal vector from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param vec Destination vector array.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadVecNormal(Handle:bf, Float:vec[3]);
|
||||
|
||||
/**
|
||||
* Reads a 3D angle vector from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param angles Destination angle vector.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadAngles(Handle:bf, Float:angles[3]);
|
||||
|
||||
/**
|
||||
* Returns the number of bytes left in a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Number of bytes left unread.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfGetNumBytesLeft(Handle:bf);
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#if defined _bitbuffer_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _bitbuffer_included
|
||||
|
||||
/**
|
||||
* Writes a single bit to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param bit Bit to write (true for 1, false for 0).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteBool(Handle:bf, bool:bit);
|
||||
|
||||
/**
|
||||
* Writes a byte to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param byte Byte to write (value will be written as 8bit).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteByte(Handle:bf, byte);
|
||||
|
||||
/**
|
||||
* Writes a byte to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param chr Character to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteChar(Handle:bf, chr);
|
||||
|
||||
/**
|
||||
* Writes a 16bit integer to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param num Integer to write (value will be written as 16bit).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteShort(Handle:bf, num);
|
||||
|
||||
/**
|
||||
* Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param num Integer to write (value will be written as 16bit).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteWord(Handle:bf, num);
|
||||
|
||||
/**
|
||||
* Writes a normal integer to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param num Integer to write (value will be written as 32bit).
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteNum(Handle:bf, num);
|
||||
|
||||
/**
|
||||
* Writes a floating point number to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param num Number to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteFloat(Handle:bf, Float:num);
|
||||
|
||||
/**
|
||||
* Writes a string to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param string Text string to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteString(Handle:bf, const String:string[]);
|
||||
|
||||
/**
|
||||
* Writes an entity to a writable bitbuffer (bf_write).
|
||||
* @note This is a wrapper around BfWriteShort().
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param ent Entity index to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle, or invalid entity.
|
||||
*/
|
||||
native BfWriteEntity(Handle:bf, ent);
|
||||
|
||||
/**
|
||||
* Writes a bit angle to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param angle Angle to write.
|
||||
* @param numBits Optional number of bits to use.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteAngle(Handle:bf, Float:angle, numBits=8);
|
||||
|
||||
/**
|
||||
* Writes a coordinate to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param coord Coordinate to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteCoord(Handle:bf, Float:coord);
|
||||
|
||||
/**
|
||||
* Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param coord Coordinate array to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteVecCoord(Handle:bf, Float:coord[3]);
|
||||
|
||||
/**
|
||||
* Writes a 3D normal vector to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param vec Vector to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteVecNormal(Handle:bf, Float:vec[3]);
|
||||
|
||||
/**
|
||||
* Writes a 3D angle vector to a writable bitbuffer (bf_write).
|
||||
*
|
||||
* @param bf bf_write handle to write to.
|
||||
* @param angles Angle vector to write.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfWriteAngles(Handle:bf, Float:angles[3]);
|
||||
|
||||
/**
|
||||
* Reads a single bit from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Bit value read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native bool:BfReadBool(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a byte from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Byte value read (read as 8bit).
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadByte(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a character from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Character value read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadChar(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a 16bit integer from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Integer value read (read as 16bit).
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadShort(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Integer value read (read as 16bit).
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadWord(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a normal integer to a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Integer value read (read as 32bit).
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadNum(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a floating point number from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Floating point value read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native Float:BfReadFloat(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a string from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param buffer Destination 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.
|
||||
* @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
|
||||
* 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
|
||||
* return value.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
|
||||
|
||||
/**
|
||||
* Reads an entity from a readable bitbuffer (bf_read).
|
||||
* @note This is a wrapper around BfReadShort().
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Entity index read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadEntity(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a bit angle from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param numBits Optional number of bits to use.
|
||||
* @return Angle read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native Float:BfReadAngle(Handle:bf, numBits=8);
|
||||
|
||||
/**
|
||||
* Reads a coordinate from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Coordinate read.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native Float:BfReadCoord(Handle:bf);
|
||||
|
||||
/**
|
||||
* Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param coord Destination coordinate array.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadVecCoord(Handle:bf, Float:coord[3]);
|
||||
|
||||
/**
|
||||
* Reads a 3D normal vector from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param vec Destination vector array.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadVecNormal(Handle:bf, Float:vec[3]);
|
||||
|
||||
/**
|
||||
* Reads a 3D angle vector from a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @param angles Destination angle vector.
|
||||
* @noreturn
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfReadAngles(Handle:bf, Float:angles[3]);
|
||||
|
||||
/**
|
||||
* Returns the number of bytes left in a readable bitbuffer (bf_read).
|
||||
*
|
||||
* @param bf bf_read handle to read from.
|
||||
* @return Number of bytes left unread.
|
||||
* @error Invalid or incorrect Handle.
|
||||
*/
|
||||
native BfGetNumBytesLeft(Handle:bf);
|
||||
|
@ -1,272 +1,272 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#if defined _sdktools_trace_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _sdktools_trace_included
|
||||
|
||||
#define CONTENTS_EMPTY 0 /**< No contents. */
|
||||
#define CONTENTS_SOLID 0x1 /**< an eye is never valid in a solid . */
|
||||
#define CONTENTS_WINDOW 0x2 /**< translucent, but not watery (glass). */
|
||||
#define CONTENTS_AUX 0x4
|
||||
#define CONTENTS_GRATE 0x8 /**< alpha-tested "grate" textures. Bullets/sight pass through, but solids don't. */
|
||||
#define CONTENTS_SLIME 0x10
|
||||
#define CONTENTS_WATER 0x20
|
||||
#define CONTENTS_MIST 0x40
|
||||
#define CONTENTS_OPAQUE 0x80 /**< things that cannot be seen through (may be non-solid though). */
|
||||
#define LAST_VISIBLE_CONTENTS 0x80
|
||||
#define ALL_VISIBLE_CONTENTS (LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1))
|
||||
#define CONTENTS_TESTFOGVOLUME 0x100
|
||||
#define CONTENTS_UNUSED5 0x200
|
||||
#define CONTENTS_UNUSED6 0x4000
|
||||
#define CONTENTS_TEAM1 0x800 /**< per team contents used to differentiate collisions. */
|
||||
#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_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_PLAYERCLIP 0x10000
|
||||
#define CONTENTS_MONSTERCLIP 0x20000
|
||||
|
||||
/**
|
||||
* @section currents can be added to any other contents, and may be mixed
|
||||
*/
|
||||
#define CONTENTS_CURRENT_0 0x40000
|
||||
#define CONTENTS_CURRENT_90 0x80000
|
||||
#define CONTENTS_CURRENT_180 0x100000
|
||||
#define CONTENTS_CURRENT_270 0x200000
|
||||
#define CONTENTS_CURRENT_UP 0x400000
|
||||
#define CONTENTS_CURRENT_DOWN 0x800000
|
||||
|
||||
/**
|
||||
* @endsection
|
||||
*/
|
||||
|
||||
#define CONTENTS_ORIGIN 0x1000000 /**< removed before bsping an entity. */
|
||||
#define CONTENTS_MONSTER 0x2000000 /**< should never be on a brush, only in game. */
|
||||
#define CONTENTS_DEBRIS 0x4000000
|
||||
#define CONTENTS_DETAIL 0x8000000 /**< brushes to be added after vis leafs. */
|
||||
#define CONTENTS_TRANSLUCENT 0x10000000 /**< auto set if any surface has trans. */
|
||||
#define CONTENTS_LADDER 0x20000000
|
||||
#define CONTENTS_HITBOX 0x40000000 /**< use accurate hitboxes on trace. */
|
||||
|
||||
/**
|
||||
* @section Trace masks.
|
||||
*/
|
||||
#define MASK_ALL (0xFFFFFFFF)
|
||||
#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_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_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_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_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_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_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_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 */
|
||||
|
||||
/**
|
||||
* @endsection
|
||||
*/
|
||||
|
||||
enum RayType
|
||||
{
|
||||
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. */
|
||||
};
|
||||
|
||||
funcenum TraceEntityFilter
|
||||
{
|
||||
/**
|
||||
* Called on entity filtering.
|
||||
*
|
||||
* @param entity Entity index.
|
||||
* @param contentsMask Contents Mask.
|
||||
* @return True to allow the current entity to be hit, otherwise false.
|
||||
*/
|
||||
bool:public(entity, contentsMask),
|
||||
|
||||
/**
|
||||
* Called on entity filtering.
|
||||
*
|
||||
* @param entity Entity index.
|
||||
* @param contentsMask Contents Mask.
|
||||
* @param data Data value, if used.
|
||||
* @return True to allow the current entity to be hit, otherwise false.
|
||||
*/
|
||||
bool:public(entity, contentsMask, any:data),
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the contents mask and the entity index at the given position.
|
||||
*
|
||||
* @param pos World position to test.
|
||||
* @param entindex Entity index found at the given position (by reference).
|
||||
* @return Contents mask.
|
||||
*/
|
||||
native TR_GetPointContents(const Float:pos[3], &entindex=-1);
|
||||
|
||||
/**
|
||||
* Get the point contents testing only the given entity index.
|
||||
*
|
||||
* @param entindex Entity index to test.
|
||||
* @param pos World position.
|
||||
* @return Contents mask.
|
||||
*/
|
||||
native TR_GetPointContentsEnt(entindex, const Float:pos[3]);
|
||||
|
||||
/**
|
||||
* Starts up a new trace ray using a global trace result.
|
||||
*
|
||||
* @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 flags Trace flags.
|
||||
* @param rtype Method to calculate the ray direction.
|
||||
* @noreturn
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is
|
||||
* currently not allowed and may not work.
|
||||
*
|
||||
* @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 flags Trace flags.
|
||||
* @param rtype Method to calculate the ray direction.
|
||||
* @param filter Function to use as a filter.
|
||||
* @param data Arbitrary data value to pass through to the filter function.
|
||||
* @noreturn
|
||||
*/
|
||||
native TR_TraceRayFilter(const Float:pos[3],
|
||||
const Float:vec[3],
|
||||
flags,
|
||||
RayType:rtype,
|
||||
TraceEntityFilter:filter,
|
||||
any:data=0);
|
||||
|
||||
/**
|
||||
* Starts up a new trace ray using a new trace result.
|
||||
*
|
||||
* @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 flags Trace flags.
|
||||
* @param rtype Method to calculate the ray direction.
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* currently not allowed and may not work.
|
||||
*
|
||||
* @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 flags Trace flags.
|
||||
* @param rtype Method to calculate the ray direction.
|
||||
* @param filter Function to use as a filter.
|
||||
* @param data Arbitrary data value to pass through to the filter function.
|
||||
* @return Ray trace handle, which must be closed via CloseHandle().
|
||||
*/
|
||||
native Handle:TR_TraceRayFilterEx(const Float:pos[3],
|
||||
const Float:vec[3],
|
||||
flags,
|
||||
RayType:rtype,
|
||||
TraceEntityFilter:filter,
|
||||
any:data=0);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return Time fraction value of the trace.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native Float:TR_GetFraction(Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* Returns the collision position of a trace result.
|
||||
*
|
||||
* @param pos Vector buffer to store data in.
|
||||
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
|
||||
* @noreturn
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native TR_GetEndPosition(Float:pos[3], Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* Returns the entity index that collided with the trace.
|
||||
*
|
||||
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
|
||||
* @return Entity index or -1 for no collision.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native TR_GetEntityIndex(Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return True if any collision found, otherwise false.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native bool:TR_DidHit(Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return Body hit group.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native TR_GetHitGroup(Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* 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 normal Vector buffer to store the vector normal to the collision plane
|
||||
* @noreturn
|
||||
* @error Invalid Handle
|
||||
*/
|
||||
native TR_GetPlaneNormal(Handle:hndl, Float:normal[3]);
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#if defined _sdktools_trace_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _sdktools_trace_included
|
||||
|
||||
#define CONTENTS_EMPTY 0 /**< No contents. */
|
||||
#define CONTENTS_SOLID 0x1 /**< an eye is never valid in a solid . */
|
||||
#define CONTENTS_WINDOW 0x2 /**< translucent, but not watery (glass). */
|
||||
#define CONTENTS_AUX 0x4
|
||||
#define CONTENTS_GRATE 0x8 /**< alpha-tested "grate" textures. Bullets/sight pass through, but solids don't. */
|
||||
#define CONTENTS_SLIME 0x10
|
||||
#define CONTENTS_WATER 0x20
|
||||
#define CONTENTS_MIST 0x40
|
||||
#define CONTENTS_OPAQUE 0x80 /**< things that cannot be seen through (may be non-solid though). */
|
||||
#define LAST_VISIBLE_CONTENTS 0x80
|
||||
#define ALL_VISIBLE_CONTENTS (LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1))
|
||||
#define CONTENTS_TESTFOGVOLUME 0x100
|
||||
#define CONTENTS_UNUSED5 0x200
|
||||
#define CONTENTS_UNUSED6 0x4000
|
||||
#define CONTENTS_TEAM1 0x800 /**< per team contents used to differentiate collisions. */
|
||||
#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_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_PLAYERCLIP 0x10000
|
||||
#define CONTENTS_MONSTERCLIP 0x20000
|
||||
|
||||
/**
|
||||
* @section currents can be added to any other contents, and may be mixed
|
||||
*/
|
||||
#define CONTENTS_CURRENT_0 0x40000
|
||||
#define CONTENTS_CURRENT_90 0x80000
|
||||
#define CONTENTS_CURRENT_180 0x100000
|
||||
#define CONTENTS_CURRENT_270 0x200000
|
||||
#define CONTENTS_CURRENT_UP 0x400000
|
||||
#define CONTENTS_CURRENT_DOWN 0x800000
|
||||
|
||||
/**
|
||||
* @endsection
|
||||
*/
|
||||
|
||||
#define CONTENTS_ORIGIN 0x1000000 /**< removed before bsping an entity. */
|
||||
#define CONTENTS_MONSTER 0x2000000 /**< should never be on a brush, only in game. */
|
||||
#define CONTENTS_DEBRIS 0x4000000
|
||||
#define CONTENTS_DETAIL 0x8000000 /**< brushes to be added after vis leafs. */
|
||||
#define CONTENTS_TRANSLUCENT 0x10000000 /**< auto set if any surface has trans. */
|
||||
#define CONTENTS_LADDER 0x20000000
|
||||
#define CONTENTS_HITBOX 0x40000000 /**< use accurate hitboxes on trace. */
|
||||
|
||||
/**
|
||||
* @section Trace masks.
|
||||
*/
|
||||
#define MASK_ALL (0xFFFFFFFF)
|
||||
#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_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_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_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_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_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_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_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 */
|
||||
|
||||
/**
|
||||
* @endsection
|
||||
*/
|
||||
|
||||
enum RayType
|
||||
{
|
||||
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. */
|
||||
};
|
||||
|
||||
funcenum TraceEntityFilter
|
||||
{
|
||||
/**
|
||||
* Called on entity filtering.
|
||||
*
|
||||
* @param entity Entity index.
|
||||
* @param contentsMask Contents Mask.
|
||||
* @return True to allow the current entity to be hit, otherwise false.
|
||||
*/
|
||||
bool:public(entity, contentsMask),
|
||||
|
||||
/**
|
||||
* Called on entity filtering.
|
||||
*
|
||||
* @param entity Entity index.
|
||||
* @param contentsMask Contents Mask.
|
||||
* @param data Data value, if used.
|
||||
* @return True to allow the current entity to be hit, otherwise false.
|
||||
*/
|
||||
bool:public(entity, contentsMask, any:data),
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the contents mask and the entity index at the given position.
|
||||
*
|
||||
* @param pos World position to test.
|
||||
* @param entindex Entity index found at the given position (by reference).
|
||||
* @return Contents mask.
|
||||
*/
|
||||
native TR_GetPointContents(const Float:pos[3], &entindex=-1);
|
||||
|
||||
/**
|
||||
* Get the point contents testing only the given entity index.
|
||||
*
|
||||
* @param entindex Entity index to test.
|
||||
* @param pos World position.
|
||||
* @return Contents mask.
|
||||
*/
|
||||
native TR_GetPointContentsEnt(entindex, const Float:pos[3]);
|
||||
|
||||
/**
|
||||
* Starts up a new trace ray using a global trace result.
|
||||
*
|
||||
* @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 flags Trace flags.
|
||||
* @param rtype Method to calculate the ray direction.
|
||||
* @noreturn
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is
|
||||
* currently not allowed and may not work.
|
||||
*
|
||||
* @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 flags Trace flags.
|
||||
* @param rtype Method to calculate the ray direction.
|
||||
* @param filter Function to use as a filter.
|
||||
* @param data Arbitrary data value to pass through to the filter function.
|
||||
* @noreturn
|
||||
*/
|
||||
native TR_TraceRayFilter(const Float:pos[3],
|
||||
const Float:vec[3],
|
||||
flags,
|
||||
RayType:rtype,
|
||||
TraceEntityFilter:filter,
|
||||
any:data=0);
|
||||
|
||||
/**
|
||||
* Starts up a new trace ray using a new trace result.
|
||||
*
|
||||
* @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 flags Trace flags.
|
||||
* @param rtype Method to calculate the ray direction.
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* currently not allowed and may not work.
|
||||
*
|
||||
* @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 flags Trace flags.
|
||||
* @param rtype Method to calculate the ray direction.
|
||||
* @param filter Function to use as a filter.
|
||||
* @param data Arbitrary data value to pass through to the filter function.
|
||||
* @return Ray trace handle, which must be closed via CloseHandle().
|
||||
*/
|
||||
native Handle:TR_TraceRayFilterEx(const Float:pos[3],
|
||||
const Float:vec[3],
|
||||
flags,
|
||||
RayType:rtype,
|
||||
TraceEntityFilter:filter,
|
||||
any:data=0);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return Time fraction value of the trace.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native Float:TR_GetFraction(Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* Returns the collision position of a trace result.
|
||||
*
|
||||
* @param pos Vector buffer to store data in.
|
||||
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
|
||||
* @noreturn
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native TR_GetEndPosition(Float:pos[3], Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* Returns the entity index that collided with the trace.
|
||||
*
|
||||
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
|
||||
* @return Entity index or -1 for no collision.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native TR_GetEntityIndex(Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return True if any collision found, otherwise false.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native bool:TR_DidHit(Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return Body hit group.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native TR_GetHitGroup(Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* 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 normal Vector buffer to store the vector normal to the collision plane
|
||||
* @noreturn
|
||||
* @error Invalid Handle
|
||||
*/
|
||||
native TR_GetPlaneNormal(Handle:hndl, Float:normal[3]);
|
||||
|
||||
|
@ -1,290 +1,290 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#if defined _topmenus_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _topmenus_included
|
||||
|
||||
#include <menus>
|
||||
|
||||
/**
|
||||
* Actions a top menu will take on an object.
|
||||
*/
|
||||
enum TopMenuAction
|
||||
{
|
||||
/**
|
||||
* An option is being drawn for a menu (or for sorting purposes).
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID, client index.
|
||||
* OUTPUT: Buffer for rendering, maxlength of buffer.
|
||||
*/
|
||||
TopMenuAction_DisplayOption = 0,
|
||||
|
||||
/**
|
||||
* The title of a menu is being drawn for a given object.
|
||||
*
|
||||
* Note: The Object ID will be INVALID_TOPMENUOBJECT if drawing the
|
||||
* root title. Otherwise, the Object ID is a category.
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID, client index.
|
||||
* OUTPUT: Buffer for rendering, maxlength of buffer.
|
||||
*/
|
||||
TopMenuAction_DisplayTitle = 1,
|
||||
|
||||
/**
|
||||
* A menu option has been selected.
|
||||
*
|
||||
* The Object ID will always be an item (not a category).
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID, client index.
|
||||
*/
|
||||
TopMenuAction_SelectOption = 2,
|
||||
|
||||
/**
|
||||
* A menu option is being drawn and its flags can be overridden.
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID, client index.
|
||||
* OUTPUT: The first byte of the 'buffer' string should be set
|
||||
* to the desired flags. By default, it will contain
|
||||
* ITEMDRAW_DEFAULT.
|
||||
*/
|
||||
TopMenuAction_DrawOption = 3,
|
||||
|
||||
/**
|
||||
* Called when an object is being removed from the menu.
|
||||
* This can be used to clean up data stored in the info string.
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID.
|
||||
*/
|
||||
TopMenuAction_RemoveObject = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* Top menu object types.
|
||||
*/
|
||||
enum TopMenuObjectType
|
||||
{
|
||||
TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */
|
||||
TopMenuObject_Item = 1 /**< Item on a sub-menu */
|
||||
};
|
||||
|
||||
/**
|
||||
* Top menu starting positions for display.
|
||||
*/
|
||||
enum TopMenuPosition
|
||||
{
|
||||
TopMenuPosition_Start = 0, /**< Start/root of the menu */
|
||||
TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */
|
||||
TopMenuPosition_LastCategory = 3, /**< Last position in their last category */
|
||||
};
|
||||
|
||||
/**
|
||||
* Top menu object tag for type checking.
|
||||
*/
|
||||
enum TopMenuObject
|
||||
{
|
||||
INVALID_TOPMENUOBJECT = 0,
|
||||
}
|
||||
|
||||
/**
|
||||
* TopMenu callback prototype.
|
||||
*
|
||||
* @param topmenu Handle to the TopMenu.
|
||||
* @param action TopMenuAction being performed.
|
||||
* @param object_id The object ID (if used).
|
||||
* @param param Extra parameter (if used).
|
||||
* @param buffer Output buffer (if used).
|
||||
* @param maxlength Output buffer (if used).
|
||||
* @noreturn
|
||||
*/
|
||||
functag TopMenuHandler public(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength);
|
||||
|
||||
/**
|
||||
* Creates a TopMenu.
|
||||
*
|
||||
* @param handler Handler to use for drawing the root title.
|
||||
* @return A new TopMenu Handle, or INVALID_HANDLE on failure.
|
||||
*/
|
||||
native Handle:CreateTopMenu(TopMenuHandler:handler);
|
||||
|
||||
/**
|
||||
* Re-sorts the items in a TopMenu via a configuration file.
|
||||
*
|
||||
* The format of the configuration file should be a Valve Key-Values
|
||||
* formatted file that SourceMod can parse. There should be one root
|
||||
* section, and one sub-section for each category. Each sub-section's
|
||||
* name should match the category name.
|
||||
*
|
||||
* Each sub-section may only contain key/value pairs in the form of:
|
||||
* key: "item"
|
||||
* value: Name of the item as passed to AddToTopMenu().
|
||||
*
|
||||
* 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
|
||||
* per-player based on how the handler function renders for that player.
|
||||
* These items appear after the configuration sorted items.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param file File path.
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of the error buffer.
|
||||
* Error buffer will be filled with a
|
||||
* zero-terminated string if false is
|
||||
* returned.
|
||||
* @return True on success, false on failure.
|
||||
* @error Invalid TopMenu Handle.
|
||||
*/
|
||||
native bool:LoadTopMenuConfig(Handle:topmenu, const String:file[], String:error[], maxlength);
|
||||
|
||||
/**
|
||||
* Adds an object to a TopMenu.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param name Object name (MUST be unique).
|
||||
* @param type Object type.
|
||||
* @param handler Handler for object.
|
||||
* @param cmdname Command name (for access overrides).
|
||||
* @param flags Default access flags.
|
||||
* @param parent Parent object ID, or INVALID_TOPMENUOBJECT for none.
|
||||
* Items must have a category parent.
|
||||
* Categories must not have a parent.
|
||||
* @param info_string Arbitrary storage (max 255 bytes).
|
||||
* @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on
|
||||
* failure.
|
||||
* @error Invalid TopMenu Handle.
|
||||
*/
|
||||
native TopMenuObject:AddToTopMenu(Handle:topmenu,
|
||||
const String:name[],
|
||||
TopMenuObjectType:type,
|
||||
TopMenuHandler:handler,
|
||||
TopMenuObject:parent,
|
||||
const String:cmdname[]="",
|
||||
flags=0,
|
||||
const String:info_string[]="");
|
||||
|
||||
/**
|
||||
* Retrieves the info string of a top menu item.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param object TopMenuObject ID.
|
||||
* @param buffer Buffer to store info string.
|
||||
* @param maxlength Maximum size of info string.
|
||||
* @return Number of bytes written, not including the
|
||||
* null terminator.
|
||||
* @error Invalid TopMenu Handle or TopMenuObject ID.
|
||||
*/
|
||||
native GetTopMenuInfoString(Handle:topmenu, TopMenuObject:parent, String:buffer[], maxlength);
|
||||
|
||||
/**
|
||||
* Retrieves the name string of a top menu item.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param object TopMenuObject ID.
|
||||
* @param buffer Buffer to store info string.
|
||||
* @param maxlength Maximum size of info string.
|
||||
* @return Number of bytes written, not including the
|
||||
* null terminator.
|
||||
* @error Invalid TopMenu Handle or TopMenuObject ID.
|
||||
*/
|
||||
native GetTopMenuObjName(Handle:topmenu, TopMenuObject:object, String:buffer[], maxlength);
|
||||
|
||||
/**
|
||||
* Removes an object from a TopMenu.
|
||||
*
|
||||
* Plugins' objects are automatically removed all TopMenus when the given
|
||||
* plugin unloads or pauses. In the case of unpausing, all items are restored.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param object TopMenuObject ID.
|
||||
* @noreturn
|
||||
* @error Invalid TopMenu Handle.
|
||||
*/
|
||||
native RemoveFromTopMenu(Handle:topmenu, TopMenuObject:object);
|
||||
|
||||
/**
|
||||
* Displays a TopMenu to a client.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param client Client index.
|
||||
* @param position Position to display from.
|
||||
* @return True on success, false on failure.
|
||||
* @error Invalid TopMenu Handle or client not in game.
|
||||
*/
|
||||
native bool:DisplayTopMenu(Handle:topmenu, client, TopMenuPosition:position);
|
||||
|
||||
/**
|
||||
* Finds a category's object ID in a TopMenu.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param name Object's unique name.
|
||||
* @return TopMenuObject ID on success, or
|
||||
* INVALID_TOPMENUOBJECT on failure.
|
||||
* @error Invalid TopMenu Handle.
|
||||
*/
|
||||
native TopMenuObject:FindTopMenuCategory(Handle:topmenu, const String:name[]);
|
||||
|
||||
/**
|
||||
* Do not edit below this line!
|
||||
*/
|
||||
public Extension:__ext_topmenus =
|
||||
{
|
||||
name = "TopMenus",
|
||||
file = "topmenus.ext",
|
||||
#if defined AUTOLOAD_EXTENSIONS
|
||||
autoload = 1,
|
||||
#else
|
||||
autoload = 0,
|
||||
#endif
|
||||
#if defined REQUIRE_EXTENSIONS
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_EXTENSIONS
|
||||
public __ext_topmenus_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("CreateTopMenu");
|
||||
MarkNativeAsOptional("LoadTopMenuConfig");
|
||||
MarkNativeAsOptional("AddToTopMenu");
|
||||
MarkNativeAsOptional("RemoveFromTopMenu");
|
||||
MarkNativeAsOptional("DisplayTopMenu");
|
||||
MarkNativeAsOptional("FindTopMenuCategory");
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#if defined _topmenus_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _topmenus_included
|
||||
|
||||
#include <menus>
|
||||
|
||||
/**
|
||||
* Actions a top menu will take on an object.
|
||||
*/
|
||||
enum TopMenuAction
|
||||
{
|
||||
/**
|
||||
* An option is being drawn for a menu (or for sorting purposes).
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID, client index.
|
||||
* OUTPUT: Buffer for rendering, maxlength of buffer.
|
||||
*/
|
||||
TopMenuAction_DisplayOption = 0,
|
||||
|
||||
/**
|
||||
* The title of a menu is being drawn for a given object.
|
||||
*
|
||||
* Note: The Object ID will be INVALID_TOPMENUOBJECT if drawing the
|
||||
* root title. Otherwise, the Object ID is a category.
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID, client index.
|
||||
* OUTPUT: Buffer for rendering, maxlength of buffer.
|
||||
*/
|
||||
TopMenuAction_DisplayTitle = 1,
|
||||
|
||||
/**
|
||||
* A menu option has been selected.
|
||||
*
|
||||
* The Object ID will always be an item (not a category).
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID, client index.
|
||||
*/
|
||||
TopMenuAction_SelectOption = 2,
|
||||
|
||||
/**
|
||||
* A menu option is being drawn and its flags can be overridden.
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID, client index.
|
||||
* OUTPUT: The first byte of the 'buffer' string should be set
|
||||
* to the desired flags. By default, it will contain
|
||||
* ITEMDRAW_DEFAULT.
|
||||
*/
|
||||
TopMenuAction_DrawOption = 3,
|
||||
|
||||
/**
|
||||
* Called when an object is being removed from the menu.
|
||||
* This can be used to clean up data stored in the info string.
|
||||
*
|
||||
* INPUT : TopMenu Handle, object ID.
|
||||
*/
|
||||
TopMenuAction_RemoveObject = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* Top menu object types.
|
||||
*/
|
||||
enum TopMenuObjectType
|
||||
{
|
||||
TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */
|
||||
TopMenuObject_Item = 1 /**< Item on a sub-menu */
|
||||
};
|
||||
|
||||
/**
|
||||
* Top menu starting positions for display.
|
||||
*/
|
||||
enum TopMenuPosition
|
||||
{
|
||||
TopMenuPosition_Start = 0, /**< Start/root of the menu */
|
||||
TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */
|
||||
TopMenuPosition_LastCategory = 3, /**< Last position in their last category */
|
||||
};
|
||||
|
||||
/**
|
||||
* Top menu object tag for type checking.
|
||||
*/
|
||||
enum TopMenuObject
|
||||
{
|
||||
INVALID_TOPMENUOBJECT = 0,
|
||||
}
|
||||
|
||||
/**
|
||||
* TopMenu callback prototype.
|
||||
*
|
||||
* @param topmenu Handle to the TopMenu.
|
||||
* @param action TopMenuAction being performed.
|
||||
* @param object_id The object ID (if used).
|
||||
* @param param Extra parameter (if used).
|
||||
* @param buffer Output buffer (if used).
|
||||
* @param maxlength Output buffer (if used).
|
||||
* @noreturn
|
||||
*/
|
||||
functag TopMenuHandler public(Handle:topmenu,
|
||||
TopMenuAction:action,
|
||||
TopMenuObject:object_id,
|
||||
param,
|
||||
String:buffer[],
|
||||
maxlength);
|
||||
|
||||
/**
|
||||
* Creates a TopMenu.
|
||||
*
|
||||
* @param handler Handler to use for drawing the root title.
|
||||
* @return A new TopMenu Handle, or INVALID_HANDLE on failure.
|
||||
*/
|
||||
native Handle:CreateTopMenu(TopMenuHandler:handler);
|
||||
|
||||
/**
|
||||
* Re-sorts the items in a TopMenu via a configuration file.
|
||||
*
|
||||
* The format of the configuration file should be a Valve Key-Values
|
||||
* formatted file that SourceMod can parse. There should be one root
|
||||
* section, and one sub-section for each category. Each sub-section's
|
||||
* name should match the category name.
|
||||
*
|
||||
* Each sub-section may only contain key/value pairs in the form of:
|
||||
* key: "item"
|
||||
* value: Name of the item as passed to AddToTopMenu().
|
||||
*
|
||||
* 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
|
||||
* per-player based on how the handler function renders for that player.
|
||||
* These items appear after the configuration sorted items.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param file File path.
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of the error buffer.
|
||||
* Error buffer will be filled with a
|
||||
* zero-terminated string if false is
|
||||
* returned.
|
||||
* @return True on success, false on failure.
|
||||
* @error Invalid TopMenu Handle.
|
||||
*/
|
||||
native bool:LoadTopMenuConfig(Handle:topmenu, const String:file[], String:error[], maxlength);
|
||||
|
||||
/**
|
||||
* Adds an object to a TopMenu.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param name Object name (MUST be unique).
|
||||
* @param type Object type.
|
||||
* @param handler Handler for object.
|
||||
* @param cmdname Command name (for access overrides).
|
||||
* @param flags Default access flags.
|
||||
* @param parent Parent object ID, or INVALID_TOPMENUOBJECT for none.
|
||||
* Items must have a category parent.
|
||||
* Categories must not have a parent.
|
||||
* @param info_string Arbitrary storage (max 255 bytes).
|
||||
* @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on
|
||||
* failure.
|
||||
* @error Invalid TopMenu Handle.
|
||||
*/
|
||||
native TopMenuObject:AddToTopMenu(Handle:topmenu,
|
||||
const String:name[],
|
||||
TopMenuObjectType:type,
|
||||
TopMenuHandler:handler,
|
||||
TopMenuObject:parent,
|
||||
const String:cmdname[]="",
|
||||
flags=0,
|
||||
const String:info_string[]="");
|
||||
|
||||
/**
|
||||
* Retrieves the info string of a top menu item.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param object TopMenuObject ID.
|
||||
* @param buffer Buffer to store info string.
|
||||
* @param maxlength Maximum size of info string.
|
||||
* @return Number of bytes written, not including the
|
||||
* null terminator.
|
||||
* @error Invalid TopMenu Handle or TopMenuObject ID.
|
||||
*/
|
||||
native GetTopMenuInfoString(Handle:topmenu, TopMenuObject:parent, String:buffer[], maxlength);
|
||||
|
||||
/**
|
||||
* Retrieves the name string of a top menu item.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param object TopMenuObject ID.
|
||||
* @param buffer Buffer to store info string.
|
||||
* @param maxlength Maximum size of info string.
|
||||
* @return Number of bytes written, not including the
|
||||
* null terminator.
|
||||
* @error Invalid TopMenu Handle or TopMenuObject ID.
|
||||
*/
|
||||
native GetTopMenuObjName(Handle:topmenu, TopMenuObject:object, String:buffer[], maxlength);
|
||||
|
||||
/**
|
||||
* Removes an object from a TopMenu.
|
||||
*
|
||||
* Plugins' objects are automatically removed all TopMenus when the given
|
||||
* plugin unloads or pauses. In the case of unpausing, all items are restored.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param object TopMenuObject ID.
|
||||
* @noreturn
|
||||
* @error Invalid TopMenu Handle.
|
||||
*/
|
||||
native RemoveFromTopMenu(Handle:topmenu, TopMenuObject:object);
|
||||
|
||||
/**
|
||||
* Displays a TopMenu to a client.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param client Client index.
|
||||
* @param position Position to display from.
|
||||
* @return True on success, false on failure.
|
||||
* @error Invalid TopMenu Handle or client not in game.
|
||||
*/
|
||||
native bool:DisplayTopMenu(Handle:topmenu, client, TopMenuPosition:position);
|
||||
|
||||
/**
|
||||
* Finds a category's object ID in a TopMenu.
|
||||
*
|
||||
* @param topmenu TopMenu Handle.
|
||||
* @param name Object's unique name.
|
||||
* @return TopMenuObject ID on success, or
|
||||
* INVALID_TOPMENUOBJECT on failure.
|
||||
* @error Invalid TopMenu Handle.
|
||||
*/
|
||||
native TopMenuObject:FindTopMenuCategory(Handle:topmenu, const String:name[]);
|
||||
|
||||
/**
|
||||
* Do not edit below this line!
|
||||
*/
|
||||
public Extension:__ext_topmenus =
|
||||
{
|
||||
name = "TopMenus",
|
||||
file = "topmenus.ext",
|
||||
#if defined AUTOLOAD_EXTENSIONS
|
||||
autoload = 1,
|
||||
#else
|
||||
autoload = 0,
|
||||
#endif
|
||||
#if defined REQUIRE_EXTENSIONS
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_EXTENSIONS
|
||||
public __ext_topmenus_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("CreateTopMenu");
|
||||
MarkNativeAsOptional("LoadTopMenuConfig");
|
||||
MarkNativeAsOptional("AddToTopMenu");
|
||||
MarkNativeAsOptional("RemoveFromTopMenu");
|
||||
MarkNativeAsOptional("DisplayTopMenu");
|
||||
MarkNativeAsOptional("FindTopMenuCategory");
|
||||
}
|
||||
#endif
|
||||
|
@ -1,145 +1,176 @@
|
||||
#include <stdio.h>
|
||||
#include "stub_mm.h"
|
||||
#include "stub_util.h"
|
||||
#include "sm_ext.h"
|
||||
|
||||
MyExtension g_SMExt;
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength)
|
||||
{
|
||||
if ((smexts = (IExtensionManager *)g_SMAPI->MetaFactory(
|
||||
SOURCEMOD_INTERFACE_EXTENSIONS,
|
||||
NULL,
|
||||
NULL))
|
||||
== NULL)
|
||||
{
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, SOURCEMOD_INTERFACE_EXTENSIONS " interface not found");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This could be more dynamic */
|
||||
char path[256];
|
||||
g_SMAPI->PathFormat(path,
|
||||
sizeof(path),
|
||||
"addons/myplugin/bin/myplugin%s",
|
||||
#if defined __linux__
|
||||
"_i486.so"
|
||||
#else
|
||||
".dll"
|
||||
#endif
|
||||
);
|
||||
|
||||
if ((myself = smexts->LoadExternal(&g_SMExt,
|
||||
path,
|
||||
"myplugin_mm.ext",
|
||||
error,
|
||||
maxlength))
|
||||
== NULL)
|
||||
{
|
||||
SM_UnsetInterfaces();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnloadExtension()
|
||||
{
|
||||
smexts->UnloadExtension(myself);
|
||||
}
|
||||
|
||||
bool MyExtension::OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late)
|
||||
{
|
||||
sharesys = sys;
|
||||
myself = me;
|
||||
|
||||
/* Get the default interfaces from our configured SDK header */
|
||||
if (!SM_AcquireInterfaces(error, maxlength))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionUnload()
|
||||
{
|
||||
/* Clean up any resources here, and more importantly, make sure
|
||||
* any listeners/hooks into SourceMod are totally removed, as well
|
||||
* as data structures like handle types and forwards.
|
||||
*/
|
||||
|
||||
//...
|
||||
|
||||
/* Make sure our pointers get NULL'd just in case */
|
||||
SM_UnsetInterfaces();
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionsAllLoaded()
|
||||
{
|
||||
/* Called once all extensions are marked as loaded.
|
||||
* This always called, and always called only once.
|
||||
*/
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionPauseChange(bool pause)
|
||||
{
|
||||
}
|
||||
|
||||
bool MyExtension::QueryRunning(char *error, size_t maxlength)
|
||||
{
|
||||
/* if something is required that can't be determined during the initial
|
||||
* load process, print a message here will show a helpful message to
|
||||
* users when they view the extension's info.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyExtension::IsMetamodExtension()
|
||||
{
|
||||
/* Must return false! */
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionName()
|
||||
{
|
||||
return mmsplugin->GetName();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionURL()
|
||||
{
|
||||
return mmsplugin->GetURL();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionTag()
|
||||
{
|
||||
return mmsplugin->GetLogTag();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionAuthor()
|
||||
{
|
||||
return mmsplugin->GetAuthor();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionVerString()
|
||||
{
|
||||
return mmsplugin->GetVersion();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDescription()
|
||||
{
|
||||
return mmsplugin->GetDescription();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDateString()
|
||||
{
|
||||
return mmsplugin->GetDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "stub_mm.h"
|
||||
#include "stub_util.h"
|
||||
#include "sm_ext.h"
|
||||
|
||||
MyExtension g_SMExt;
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength)
|
||||
{
|
||||
if ((smexts = (IExtensionManager *)g_SMAPI->MetaFactory(
|
||||
SOURCEMOD_INTERFACE_EXTENSIONS,
|
||||
NULL,
|
||||
NULL))
|
||||
== NULL)
|
||||
{
|
||||
if (error && maxlength)
|
||||
{
|
||||
UTIL_Format(error, maxlength, SOURCEMOD_INTERFACE_EXTENSIONS " interface not found");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This could be more dynamic */
|
||||
char path[256];
|
||||
g_SMAPI->PathFormat(path,
|
||||
sizeof(path),
|
||||
"addons/myplugin/bin/myplugin%s",
|
||||
#if defined __linux__
|
||||
"_i486.so"
|
||||
#else
|
||||
".dll"
|
||||
#endif
|
||||
);
|
||||
|
||||
if ((myself = smexts->LoadExternal(&g_SMExt,
|
||||
path,
|
||||
"myplugin_mm.ext",
|
||||
error,
|
||||
maxlength))
|
||||
== NULL)
|
||||
{
|
||||
SM_UnsetInterfaces();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnloadExtension()
|
||||
{
|
||||
smexts->UnloadExtension(myself);
|
||||
}
|
||||
|
||||
bool MyExtension::OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late)
|
||||
{
|
||||
sharesys = sys;
|
||||
myself = me;
|
||||
|
||||
/* Get the default interfaces from our configured SDK header */
|
||||
if (!SM_AcquireInterfaces(error, maxlength))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionUnload()
|
||||
{
|
||||
/* Clean up any resources here, and more importantly, make sure
|
||||
* any listeners/hooks into SourceMod are totally removed, as well
|
||||
* as data structures like handle types and forwards.
|
||||
*/
|
||||
|
||||
//...
|
||||
|
||||
/* Make sure our pointers get NULL'd just in case */
|
||||
SM_UnsetInterfaces();
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionsAllLoaded()
|
||||
{
|
||||
/* Called once all extensions are marked as loaded.
|
||||
* This always called, and always called only once.
|
||||
*/
|
||||
}
|
||||
|
||||
void MyExtension::OnExtensionPauseChange(bool pause)
|
||||
{
|
||||
}
|
||||
|
||||
bool MyExtension::QueryRunning(char *error, size_t maxlength)
|
||||
{
|
||||
/* if something is required that can't be determined during the initial
|
||||
* load process, print a message here will show a helpful message to
|
||||
* users when they view the extension's info.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyExtension::IsMetamodExtension()
|
||||
{
|
||||
/* Must return false! */
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionName()
|
||||
{
|
||||
return mmsplugin->GetName();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionURL()
|
||||
{
|
||||
return mmsplugin->GetURL();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionTag()
|
||||
{
|
||||
return mmsplugin->GetLogTag();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionAuthor()
|
||||
{
|
||||
return mmsplugin->GetAuthor();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionVerString()
|
||||
{
|
||||
return mmsplugin->GetVersion();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDescription()
|
||||
{
|
||||
return mmsplugin->GetDescription();
|
||||
}
|
||||
|
||||
const char *MyExtension::GetExtensionDateString()
|
||||
{
|
||||
return mmsplugin->GetDate();
|
||||
}
|
||||
|
||||
|
@ -1,38 +1,69 @@
|
||||
#ifndef _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
#define _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
class MyExtension : public IExtensionInterface
|
||||
{
|
||||
public:
|
||||
virtual bool OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late);
|
||||
virtual void OnExtensionUnload();
|
||||
virtual void OnExtensionsAllLoaded();
|
||||
virtual void OnExtensionPauseChange(bool pause);
|
||||
virtual bool QueryRunning(char *error, size_t maxlength);
|
||||
virtual bool IsMetamodExtension();
|
||||
virtual const char *GetExtensionName();
|
||||
virtual const char *GetExtensionURL();
|
||||
virtual const char *GetExtensionTag();
|
||||
virtual const char *GetExtensionAuthor();
|
||||
virtual const char *GetExtensionVerString();
|
||||
virtual const char *GetExtensionDescription();
|
||||
virtual const char *GetExtensionDateString();
|
||||
};
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength);
|
||||
void SM_UnloadExtension();
|
||||
|
||||
extern IShareSys *sharesys;
|
||||
extern IExtension *myself;
|
||||
extern MyExtension g_SMExt;
|
||||
|
||||
#endif //_INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
#define _INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
class MyExtension : public IExtensionInterface
|
||||
{
|
||||
public:
|
||||
virtual bool OnExtensionLoad(IExtension *me,
|
||||
IShareSys *sys,
|
||||
char *error,
|
||||
size_t maxlength,
|
||||
bool late);
|
||||
virtual void OnExtensionUnload();
|
||||
virtual void OnExtensionsAllLoaded();
|
||||
virtual void OnExtensionPauseChange(bool pause);
|
||||
virtual bool QueryRunning(char *error, size_t maxlength);
|
||||
virtual bool IsMetamodExtension();
|
||||
virtual const char *GetExtensionName();
|
||||
virtual const char *GetExtensionURL();
|
||||
virtual const char *GetExtensionTag();
|
||||
virtual const char *GetExtensionAuthor();
|
||||
virtual const char *GetExtensionVerString();
|
||||
virtual const char *GetExtensionDescription();
|
||||
virtual const char *GetExtensionDateString();
|
||||
};
|
||||
|
||||
bool SM_LoadExtension(char *error, size_t maxlength);
|
||||
void SM_UnloadExtension();
|
||||
|
||||
extern IShareSys *sharesys;
|
||||
extern IExtension *myself;
|
||||
extern MyExtension g_SMExt;
|
||||
|
||||
#endif //_INCLUDE_SAMPLE_MMS_SOURCEMOD_EXTENSION_
|
||||
|
||||
|
@ -1,151 +1,182 @@
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength)
|
||||
{
|
||||
SM_FIND_IFACE_OR_FAIL(SOURCEMOD, sm_main, error, maxlength);
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SM_FIND_IFACE_OR_FAIL(FORWARDMANAGER, sm_forwards, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SM_FIND_IFACE_OR_FAIL(HANDLESYSTEM, sm_handlesys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(PLAYERMANAGER, sm_players, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SM_FIND_IFACE_OR_FAIL(DBI, sm_dbi, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SM_FIND_IFACE_OR_FAIL(GAMECONFIG, sm_gameconfs, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SM_FIND_IFACE_OR_FAIL(MEMORYUTILS, sm_memutils, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(GAMEHELPERS, sm_gamehelpers, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SM_FIND_IFACE_OR_FAIL(TIMERSYS, sm_timersys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SM_FIND_IFACE_OR_FAIL(THREADER, sm_threader, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SM_FIND_IFACE_OR_FAIL(LIBRARYSYS, sm_libsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(PLUGINSYSTEM, sm_plsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SM_FIND_IFACE_OR_FAIL(MENUMANAGER, sm_menus, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(ADMINSYS, sm_adminsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SM_FIND_IFACE_OR_FAIL(TEXTPARSERS, sm_text, error, maxlength);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnsetInterfaces()
|
||||
{
|
||||
myself = NULL;
|
||||
smexts = NULL;
|
||||
sharesys = NULL;
|
||||
sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
sm_text = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
IExtension *myself = NULL;
|
||||
IExtensionManager *smexts = NULL;
|
||||
IShareSys *sharesys = NULL;
|
||||
SourceMod::ISourceMod *sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SourceMod::IForwardManager *sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SourceMod::IHandleSys *sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SourceMod::IPlayerManager *sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SourceMod::IDBManager *sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SourceMod::IGameConfigManager *sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SourceMod::IMemoryUtils *sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SourceMod::IGameHelpers *sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SourceMod::ITimerSystem *sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SourceMod::IThreader *sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SourceMod::ILibrarySys *sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SourceMod::IPluginManager *sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SourceMod::IMenuManager *sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SourceMod::IAdminSystem *sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SourceMod::ITextParsers *sm_text = NULL;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "sm_sdk_config.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength)
|
||||
{
|
||||
SM_FIND_IFACE_OR_FAIL(SOURCEMOD, sm_main, error, maxlength);
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SM_FIND_IFACE_OR_FAIL(FORWARDMANAGER, sm_forwards, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SM_FIND_IFACE_OR_FAIL(HANDLESYSTEM, sm_handlesys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(PLAYERMANAGER, sm_players, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SM_FIND_IFACE_OR_FAIL(DBI, sm_dbi, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SM_FIND_IFACE_OR_FAIL(GAMECONFIG, sm_gameconfs, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SM_FIND_IFACE_OR_FAIL(MEMORYUTILS, sm_memutils, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SM_FIND_IFACE_OR_FAIL(GAMEHELPERS, sm_gamehelpers, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SM_FIND_IFACE_OR_FAIL(TIMERSYS, sm_timersys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SM_FIND_IFACE_OR_FAIL(THREADER, sm_threader, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SM_FIND_IFACE_OR_FAIL(LIBRARYSYS, sm_libsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(PLUGINSYSTEM, sm_plsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SM_FIND_IFACE_OR_FAIL(MENUMANAGER, sm_menus, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SM_FIND_IFACE_OR_FAIL(ADMINSYS, sm_adminsys, error, maxlength);
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SM_FIND_IFACE_OR_FAIL(TEXTPARSERS, sm_text, error, maxlength);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SM_UnsetInterfaces()
|
||||
{
|
||||
myself = NULL;
|
||||
smexts = NULL;
|
||||
sharesys = NULL;
|
||||
sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
sm_text = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
IExtension *myself = NULL;
|
||||
IExtensionManager *smexts = NULL;
|
||||
IShareSys *sharesys = NULL;
|
||||
SourceMod::ISourceMod *sm_main = NULL;
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
SourceMod::IForwardManager *sm_forwards = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
SourceMod::IHandleSys *sm_handlesys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
SourceMod::IPlayerManager *sm_players = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
SourceMod::IDBManager *sm_dbi = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
SourceMod::IGameConfigManager *sm_gameconfs = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
SourceMod::IMemoryUtils *sm_memutils = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
SourceMod::IGameHelpers *sm_gamehelpers = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
SourceMod::ITimerSystem *sm_timersys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
SourceMod::IThreader *sm_threader = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
SourceMod::ILibrarySys *sm_libsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
SourceMod::IPluginManager *sm_plsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
SourceMod::IMenuManager *sm_menus = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
SourceMod::IAdminSystem *sm_adminsys = NULL;
|
||||
#endif
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
SourceMod::ITextParsers *sm_text = NULL;
|
||||
#endif
|
||||
|
||||
|
@ -1,128 +1,159 @@
|
||||
#ifndef _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
#define _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* @brief Acquires the interfaces enabled at the bottom of this header.
|
||||
*
|
||||
* @param error Buffer to store error message.
|
||||
* @param maxlength Maximum size of the error buffer.
|
||||
* @return True on success, false on failure.
|
||||
* On failure, a null-terminated string will be stored
|
||||
* in the error buffer, if the buffer is non-NULL and
|
||||
* greater than 0 bytes in size.
|
||||
*/
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength);
|
||||
|
||||
/**
|
||||
* @brief Sets each acquired interface to NULL.
|
||||
*/
|
||||
void SM_UnsetInterfaces();
|
||||
|
||||
/**
|
||||
* Enable interfaces you want to use here by uncommenting lines.
|
||||
* These interfaces are all part of SourceMod's core.
|
||||
*/
|
||||
//#define SMEXT_ENABLE_FORWARDSYS
|
||||
//#define SMEXT_ENABLE_HANDLESYS
|
||||
//#define SMEXT_ENABLE_PLAYERHELPERS
|
||||
//#define SMEXT_ENABLE_DBMANAGER
|
||||
//#define SMEXT_ENABLE_GAMECONF
|
||||
//#define SMEXT_ENABLE_MEMUTILS
|
||||
//#define SMEXT_ENABLE_GAMEHELPERS
|
||||
//#define SMEXT_ENABLE_TIMERSYS
|
||||
//#define SMEXT_ENABLE_THREADER
|
||||
//#define SMEXT_ENABLE_LIBSYS
|
||||
//#define SMEXT_ENABLE_MENUS
|
||||
//#define SMEXT_ENABLE_ADTFACTORY
|
||||
//#define SMEXT_ENABLE_PLUGINSYS
|
||||
//#define SMEXT_ENABLE_ADMINSYS
|
||||
//#define SMEXT_ENABLE_TEXTPARSERS
|
||||
|
||||
|
||||
/**
|
||||
* There is no need to edit below.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IExtensionSys.h>
|
||||
extern SourceMod::IExtension *myself;
|
||||
extern SourceMod::IExtensionManager *smexts;
|
||||
extern SourceMod::IShareSys *sharesys;
|
||||
|
||||
#include <ISourceMod.h>
|
||||
extern SourceMod::ISourceMod *sm_main;
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
#include <IForwardSys.h>
|
||||
extern SourceMod::IForwardManager *sm_forwards;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
#include <IHandleSys.h>
|
||||
extern SourceMod::IHandleSys *sm_handlesys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
#include <IPlayerHelpers.h>
|
||||
extern SourceMod::IPlayerManager *sm_players;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
#include <IDBDriver.h>
|
||||
extern SourceMod::IDBManager *sm_dbi;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
#include <IGameConfigs.h>
|
||||
extern SourceMod::IGameConfigManager *sm_gameconfs;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
#include <IMemoryUtils.h>
|
||||
extern SourceMod::IMemoryUtils *sm_memutils;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
#include <IGameHelpers.h>
|
||||
extern SourceMod::IGameHelpers *sm_gamehelpers;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
#include <ITimerSystem.h>
|
||||
extern SourceMod::ITimerSystem *sm_timersys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
#include <IThreader.h>
|
||||
extern SourceMod::IThreader *sm_threader;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
#include <ILibrarySys.h>
|
||||
extern SourceMod::ILibrarySys *sm_libsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
#include <IPluginSys.h>
|
||||
extern SourceMod::IPluginManager *sm_plsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
#include <IMenuManager.h>
|
||||
extern SourceMod::IMenuManager *sm_menus;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
#include <IAdminSystem.h>
|
||||
extern SourceMod::IAdminSystem *sm_adminsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
#include <ITextParsers.h>
|
||||
extern SourceMod::ITextParsers *sm_text;
|
||||
#endif
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod Extension Code for Metamod:Source
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
#define _INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* @brief Acquires the interfaces enabled at the bottom of this header.
|
||||
*
|
||||
* @param error Buffer to store error message.
|
||||
* @param maxlength Maximum size of the error buffer.
|
||||
* @return True on success, false on failure.
|
||||
* On failure, a null-terminated string will be stored
|
||||
* in the error buffer, if the buffer is non-NULL and
|
||||
* greater than 0 bytes in size.
|
||||
*/
|
||||
bool SM_AcquireInterfaces(char *error, size_t maxlength);
|
||||
|
||||
/**
|
||||
* @brief Sets each acquired interface to NULL.
|
||||
*/
|
||||
void SM_UnsetInterfaces();
|
||||
|
||||
/**
|
||||
* Enable interfaces you want to use here by uncommenting lines.
|
||||
* These interfaces are all part of SourceMod's core.
|
||||
*/
|
||||
//#define SMEXT_ENABLE_FORWARDSYS
|
||||
//#define SMEXT_ENABLE_HANDLESYS
|
||||
//#define SMEXT_ENABLE_PLAYERHELPERS
|
||||
//#define SMEXT_ENABLE_DBMANAGER
|
||||
//#define SMEXT_ENABLE_GAMECONF
|
||||
//#define SMEXT_ENABLE_MEMUTILS
|
||||
//#define SMEXT_ENABLE_GAMEHELPERS
|
||||
//#define SMEXT_ENABLE_TIMERSYS
|
||||
//#define SMEXT_ENABLE_THREADER
|
||||
//#define SMEXT_ENABLE_LIBSYS
|
||||
//#define SMEXT_ENABLE_MENUS
|
||||
//#define SMEXT_ENABLE_ADTFACTORY
|
||||
//#define SMEXT_ENABLE_PLUGINSYS
|
||||
//#define SMEXT_ENABLE_ADMINSYS
|
||||
//#define SMEXT_ENABLE_TEXTPARSERS
|
||||
|
||||
|
||||
/**
|
||||
* There is no need to edit below.
|
||||
*/
|
||||
|
||||
#include <IShareSys.h>
|
||||
#include <IExtensionSys.h>
|
||||
extern SourceMod::IExtension *myself;
|
||||
extern SourceMod::IExtensionManager *smexts;
|
||||
extern SourceMod::IShareSys *sharesys;
|
||||
|
||||
#include <ISourceMod.h>
|
||||
extern SourceMod::ISourceMod *sm_main;
|
||||
|
||||
#if defined SMEXT_ENABLE_FORWARDSYS
|
||||
#include <IForwardSys.h>
|
||||
extern SourceMod::IForwardManager *sm_forwards;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_HANDLESYS
|
||||
#include <IHandleSys.h>
|
||||
extern SourceMod::IHandleSys *sm_handlesys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLAYERHELPERS
|
||||
#include <IPlayerHelpers.h>
|
||||
extern SourceMod::IPlayerManager *sm_players;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_DBMANAGER
|
||||
#include <IDBDriver.h>
|
||||
extern SourceMod::IDBManager *sm_dbi;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMECONF
|
||||
#include <IGameConfigs.h>
|
||||
extern SourceMod::IGameConfigManager *sm_gameconfs;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MEMUTILS
|
||||
#include <IMemoryUtils.h>
|
||||
extern SourceMod::IMemoryUtils *sm_memutils;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_GAMEHELPERS
|
||||
#include <IGameHelpers.h>
|
||||
extern SourceMod::IGameHelpers *sm_gamehelpers;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TIMERSYS
|
||||
#include <ITimerSystem.h>
|
||||
extern SourceMod::ITimerSystem *sm_timersys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_THREADER
|
||||
#include <IThreader.h>
|
||||
extern SourceMod::IThreader *sm_threader;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_LIBSYS
|
||||
#include <ILibrarySys.h>
|
||||
extern SourceMod::ILibrarySys *sm_libsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_PLUGINSYS
|
||||
#include <IPluginSys.h>
|
||||
extern SourceMod::IPluginManager *sm_plsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_MENUS
|
||||
#include <IMenuManager.h>
|
||||
extern SourceMod::IMenuManager *sm_menus;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_ADMINSYS
|
||||
#include <IAdminSystem.h>
|
||||
extern SourceMod::IAdminSystem *sm_adminsys;
|
||||
#endif
|
||||
|
||||
#if defined SMEXT_ENABLE_TEXTPARSERS
|
||||
#include <ITextParsers.h>
|
||||
extern SourceMod::ITextParsers *sm_text;
|
||||
#endif
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_CONFIG_H_
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id: stub_mm.cpp 534 2007-10-30 18:22:12Z dvander $
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
* 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_
|
||||
|
@ -1,22 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "stub_util.h"
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (len >= maxlength)
|
||||
{
|
||||
len = maxlength - 1;
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ======================================================
|
||||
* Metamod:Source Stub Plugin
|
||||
* Written by AlliedModders LLC.
|
||||
* ======================================================
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "stub_util.h"
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (len >= maxlength)
|
||||
{
|
||||
len = maxlength - 1;
|
||||
buffer[len] = '\0';
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,15 +1,31 @@
|
||||
#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_
|
||||
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ======================================================
|
||||
* Metamod:Source Stub Plugin
|
||||
* Written by AlliedModders LLC.
|
||||
* ======================================================
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from
|
||||
* the use of this software.
|
||||
*
|
||||
* This stub plugin is public domain.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
#define _INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* This is a platform-safe function which fixes weird idiosyncracies
|
||||
* in the null-termination and return value of snprintf(). It guarantees
|
||||
* the terminator on overflow cases, and never returns -1 or a value
|
||||
* not equal to the number of non-terminating bytes written.
|
||||
*/
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||
|
||||
#endif //_INCLUDE_STUB_UTIL_FUNCTIONS_H_
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user