Compare commits
235 Commits
amxmodx-1.
...
amxmodx-1.
Author | SHA1 | Date | |
---|---|---|---|
5f34f1baaa | |||
dc5e458d9e | |||
4feaa1449f | |||
25002f559a | |||
41f38424ee | |||
862ee2029a | |||
cd30fb0c1c | |||
59ad6c49e3 | |||
2d255829a6 | |||
be762580b7 | |||
ae8bf10746 | |||
324f4c58a8 | |||
a816767abb | |||
164a47bde4 | |||
545769e241 | |||
dcf39196d5 | |||
58dd553d00 | |||
f64ca6a827 | |||
ebd4974c75 | |||
4b1769f457 | |||
f58c0f4508 | |||
4d7bdcde47 | |||
c7a620424e | |||
24260137ec | |||
315e69797d | |||
dddc693369 | |||
13e654aafe | |||
f02c73f94c | |||
92f79ffe88 | |||
db33e50f92 | |||
2ad557024e | |||
ddf3b6df32 | |||
12bf140931 | |||
0d65bb64f9 | |||
c6e265b414 | |||
9ba597b5c1 | |||
b6a4514bd0 | |||
a6daebe7d4 | |||
471ba0adbf | |||
7225aa3cc0 | |||
88b833f879 | |||
6f8816c13f | |||
95ccd6078c | |||
2e5c71f771 | |||
eeb77395cd | |||
e3afe22a48 | |||
73d70aff29 | |||
120c849e4b | |||
138b732e75 | |||
760e29e531 | |||
401ee3c97f | |||
6e52ce7678 | |||
89aab62549 | |||
468d99ff70 | |||
2d787f43de | |||
f0c5e44985 | |||
76760b221d | |||
612a86dbef | |||
369ece2d56 | |||
cc37f479aa | |||
deaaf20713 | |||
e566413224 | |||
368856f122 | |||
52cc204787 | |||
52b1d67ca2 | |||
16ad8739e7 | |||
e67457440d | |||
fc955009da | |||
0dc2ba85e8 | |||
de65e65854 | |||
d95f2cba37 | |||
e2a521583a | |||
f8aac5e88d | |||
4738c92b8e | |||
7ce59966fc | |||
afa1337e62 | |||
cc34f468f0 | |||
3f9598fcbb | |||
97b5391118 | |||
227c13d12c | |||
729932476b | |||
7c21deb0f2 | |||
80048eba61 | |||
0552e5ef58 | |||
ce881a7d30 | |||
80dd7f034d | |||
5fac746feb | |||
67f012b74a | |||
5705e69abb | |||
bece1e6d0c | |||
f2527ecc86 | |||
66b95f64a5 | |||
af79fe8e20 | |||
d3e2bad4e7 | |||
6bebf37f1a | |||
2f27b7da8d | |||
824caab2c5 | |||
a105bc7402 | |||
81ab33d794 | |||
e90364c17b | |||
ac4014ff5a | |||
ad634924fa | |||
2d5f9ba181 | |||
aa0e4e121e | |||
f8227a09b4 | |||
46130a6754 | |||
58c006a9c8 | |||
ea1d72401c | |||
fdbe0e2064 | |||
e239801671 | |||
4be88a5015 | |||
ee02d0b13d | |||
2ec084ffa3 | |||
6636c20336 | |||
27c80b00f8 | |||
6bcb72952c | |||
8c17be27dd | |||
0232b0abee | |||
12fd7a9f0d | |||
71c6e70706 | |||
c5cc94ba98 | |||
8220cc4c01 | |||
57ce74c4c7 | |||
5d6c72bf42 | |||
63b2bbc67e | |||
12f628e3d7 | |||
cd8d800eb7 | |||
160ab3572b | |||
dc57ef1e0c | |||
ca1544564c | |||
462916d00f | |||
e15761b79a | |||
270d898f82 | |||
2a2d5697b8 | |||
b17f277a1b | |||
c15ed5741a | |||
9e035dc744 | |||
ac279b37e4 | |||
974fdc950e | |||
8bb01423b9 | |||
401a23a298 | |||
7ac9ed4b80 | |||
6fdcd8ffae | |||
d50a6302e0 | |||
5fd891bc32 | |||
864f7c268e | |||
4770f28a18 | |||
51a4e2bf4e | |||
c213c771d2 | |||
0176d3a2ae | |||
92653ceebc | |||
c9051ad364 | |||
94d350118d | |||
2e22dde409 | |||
4dad81af30 | |||
b271b01b13 | |||
a17b879380 | |||
ea05af9fe8 | |||
d661196429 | |||
1114443a43 | |||
d802a3c961 | |||
e2226ae809 | |||
fd8a27013b | |||
b12224eabd | |||
c30c3cf35c | |||
f828cde999 | |||
d05c381789 | |||
245054cf48 | |||
da82ce757f | |||
4d74743138 | |||
c1db39d086 | |||
d516824936 | |||
10328f5f81 | |||
d4f09aac74 | |||
8f97ed7934 | |||
1fcf7628a3 | |||
bdd740f8ab | |||
82fed37247 | |||
5b208eb9f5 | |||
9be88ffa42 | |||
f54d112bbb | |||
96c4d33da4 | |||
bad4c02647 | |||
70140ffc8f | |||
53e6bb6b50 | |||
4cb7986426 | |||
18ba13be84 | |||
dd371c4dbe | |||
7ea47c5a96 | |||
5693d2629e | |||
24d9e3266e | |||
b3b3ce4c2d | |||
5882802a3e | |||
94e19aae0c | |||
7d51404aeb | |||
1cdb12c4e4 | |||
e9993cce25 | |||
80bd845182 | |||
f986202b06 | |||
a4168a2096 | |||
3e85589930 | |||
b5a57da29c | |||
58fec512e5 | |||
a6ca045086 | |||
e401231d25 | |||
9ddc24898f | |||
f5350c0e0e | |||
fa64bef511 | |||
29bfd81b36 | |||
2d2506f1c4 | |||
f334fec0a3 | |||
03b6d3e77d | |||
661f6c9851 | |||
593e013572 | |||
b04498cddb | |||
8648bf32a3 | |||
1768ae4b23 | |||
80e6d31998 | |||
381e331dda | |||
13c65f006b | |||
4e8eff3e04 | |||
572ad38366 | |||
b2ade117ec | |||
9eb36bd2bb | |||
85b7ac740b | |||
98d3fb79d7 | |||
bf092b4f95 | |||
a4a9613f5b | |||
ad86bf636f | |||
d0b5886d7d | |||
aa75a143fc | |||
7144f5c794 | |||
befb651268 | |||
c8fdea6216 | |||
4a6a16c627 |
@ -35,7 +35,9 @@
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class CmdMngr
|
// class CmdMngr
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
CmdMngr::CmdMngr() {
|
|
||||||
|
CmdMngr::CmdMngr()
|
||||||
|
{
|
||||||
memset(sortedlists, 0, sizeof(sortedlists));
|
memset(sortedlists, 0, sizeof(sortedlists));
|
||||||
srvcmdlist = 0;
|
srvcmdlist = 0;
|
||||||
clcmdlist = 0;
|
clcmdlist = 0;
|
||||||
@ -49,10 +51,9 @@ CmdMngr::CmdMngr() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CmdMngr::Command::Command( CPluginMngr::CPlugin* pplugin,const char* pcmd,
|
CmdMngr::Command::Command(CPluginMngr::CPlugin* pplugin, const char* pcmd, const char* pinfo, int pflags,
|
||||||
const char* pinfo , int pflags , int pfunc,
|
int pfunc, bool pviewable, CmdMngr* pparent) : commandline(pcmd), info(pinfo)
|
||||||
bool pviewable, CmdMngr* pparent ) : commandline(pcmd) , info(pinfo) {
|
{
|
||||||
|
|
||||||
char szCmd[64], szArg[64];
|
char szCmd[64], szArg[64];
|
||||||
*szCmd = 0; *szArg = 0;
|
*szCmd = 0; *szArg = 0;
|
||||||
sscanf(pcmd, "%s %s", szCmd, szArg);
|
sscanf(pcmd, "%s %s", szCmd, szArg);
|
||||||
@ -78,17 +79,21 @@ CmdMngr::Command* CmdMngr::registerCommand( CPluginMngr::CPlugin* plugin , int
|
|||||||
Command* b = new Command(plugin, cmd, info, level, func, listable, this);
|
Command* b = new Command(plugin, cmd, info, level, func, listable, this);
|
||||||
if (b == 0) return 0;
|
if (b == 0) return 0;
|
||||||
setCmdLink(&sortedlists[0], b);
|
setCmdLink(&sortedlists[0], b);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
CmdMngr::Command* CmdMngr::getCmd(long int id, int type, int access)
|
CmdMngr::Command* CmdMngr::getCmd(long int id, int type, int access)
|
||||||
{
|
{
|
||||||
//if (id >= 1024 || id < 0) return (Command*)id;
|
//if (id >= 1024 || id < 0) return (Command*)id;
|
||||||
if ( id < 0 ){
|
if (id < 0)
|
||||||
for (CmdMngr::iterator a = begin( type ); a ; ++a){
|
{
|
||||||
|
for (CmdMngr::iterator a = begin(type); a ; ++a)
|
||||||
|
{
|
||||||
if ((*a).id == id)
|
if ((*a).id == id)
|
||||||
return &(*a);
|
return &(*a);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,9 +103,7 @@ CmdMngr::Command* CmdMngr::getCmd( long int id ,int type, int access )
|
|||||||
buf_cmdaccess = access;
|
buf_cmdaccess = access;
|
||||||
buf_cmdtype = type;
|
buf_cmdtype = type;
|
||||||
buf_cmdid = id;
|
buf_cmdid = id;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int a = id;
|
int a = id;
|
||||||
id -= buf_cmdid;
|
id -= buf_cmdid;
|
||||||
buf_cmdid = a;
|
buf_cmdid = a;
|
||||||
@ -108,17 +111,11 @@ CmdMngr::Command* CmdMngr::getCmd( long int id ,int type, int access )
|
|||||||
|
|
||||||
while (buf_cmdptr)
|
while (buf_cmdptr)
|
||||||
{
|
{
|
||||||
|
if ((*buf_cmdptr).gotAccess(access) && (*buf_cmdptr).getPlugin()->isExecutable((*buf_cmdptr).getFunction()) && (*buf_cmdptr).isViewable())
|
||||||
if ( (*buf_cmdptr).gotAccess( access ) &&
|
|
||||||
(*buf_cmdptr).getPlugin()->isExecutable( (*buf_cmdptr).getFunction() )
|
|
||||||
&& (*buf_cmdptr).isViewable() )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (id-- == 0)
|
if (id-- == 0)
|
||||||
return &(*buf_cmdptr);
|
return &(*buf_cmdptr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
++buf_cmdptr;
|
++buf_cmdptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,10 +135,7 @@ int CmdMngr::getCmdNum( int type, int access )
|
|||||||
|
|
||||||
while (a)
|
while (a)
|
||||||
{
|
{
|
||||||
|
if ((*a).gotAccess(access) && (*a).getPlugin()->isExecutable((*a).getFunction()) && (*a).isViewable())
|
||||||
if ( (*a).gotAccess( access ) &&
|
|
||||||
(*a).getPlugin()->isExecutable( (*a).getFunction() )
|
|
||||||
&& (*a).isViewable() )
|
|
||||||
++buf_num;
|
++buf_num;
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
@ -169,20 +163,18 @@ void CmdMngr::setCmdLink( CmdLink** a , Command* c, bool sorted )
|
|||||||
|
|
||||||
np->next = *a;
|
np->next = *a;
|
||||||
*a = np;
|
*a = np;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
while (*a) a = &(*a)->next;
|
while (*a) a = &(*a)->next;
|
||||||
*a = np;
|
*a = np;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdMngr::clearCmdLink(CmdLink** phead, bool pclear)
|
void CmdMngr::clearCmdLink(CmdLink** phead, bool pclear)
|
||||||
{
|
{
|
||||||
while( *phead ){
|
while (*phead)
|
||||||
|
{
|
||||||
CmdLink* pp = (*phead)->next;
|
CmdLink* pp = (*phead)->next;
|
||||||
|
|
||||||
if (pclear) delete (*phead)->cmd;
|
if (pclear) delete (*phead)->cmd;
|
||||||
delete *phead;
|
delete *phead;
|
||||||
*phead = pp;
|
*phead = pp;
|
||||||
@ -191,39 +183,51 @@ void CmdMngr::clearCmdLink( CmdLink** phead, bool pclear )
|
|||||||
|
|
||||||
void CmdMngr::Command::setCmdType(int a)
|
void CmdMngr::Command::setCmdType(int a)
|
||||||
{
|
{
|
||||||
switch(a){
|
switch (a)
|
||||||
|
{
|
||||||
case CMD_ConsoleCommand: cmdtype |= 3; break;
|
case CMD_ConsoleCommand: cmdtype |= 3; break;
|
||||||
case CMD_ClientCommand: cmdtype |= 1; break;
|
case CMD_ClientCommand: cmdtype |= 1; break;
|
||||||
case CMD_ServerCommand: cmdtype |= 2; break;
|
case CMD_ServerCommand: cmdtype |= 2; break;
|
||||||
}
|
}
|
||||||
if ( cmdtype & 1 ) { // ClientCommand
|
|
||||||
|
if (cmdtype & 1) // ClientCommand
|
||||||
|
{
|
||||||
parent->setCmdLink(&parent->sortedlists[1], this);
|
parent->setCmdLink(&parent->sortedlists[1], this);
|
||||||
|
|
||||||
if (!parent->registerCmdPrefix(this))
|
if (!parent->registerCmdPrefix(this))
|
||||||
parent->setCmdLink(&parent->clcmdlist, this, false);
|
parent->setCmdLink(&parent->clcmdlist, this, false);
|
||||||
}
|
}
|
||||||
if ( cmdtype & 2 ) { // ServerCommand
|
|
||||||
|
if (cmdtype & 2) // ServerCommand
|
||||||
|
{
|
||||||
parent->setCmdLink(&parent->sortedlists[2], this);
|
parent->setCmdLink(&parent->sortedlists[2], this);
|
||||||
parent->setCmdLink(&parent->srvcmdlist, this, false);
|
parent->setCmdLink(&parent->srvcmdlist, this, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CmdMngr::Command::getCmdType() const {
|
const char* CmdMngr::Command::getCmdType() const
|
||||||
switch( cmdtype ){
|
{
|
||||||
|
switch (cmdtype)
|
||||||
|
{
|
||||||
case 1: return "client";
|
case 1: return "client";
|
||||||
case 2: return "server";
|
case 2: return "server";
|
||||||
case 3: return "console";
|
case 3: return "console";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CmdMngr::registerCmdPrefix(Command* cc)
|
bool CmdMngr::registerCmdPrefix(Command* cc)
|
||||||
{
|
{
|
||||||
CmdPrefix** b = findPrefix(cc->getCommand());
|
CmdPrefix** b = findPrefix(cc->getCommand());
|
||||||
if (*b){
|
|
||||||
|
if (*b)
|
||||||
|
{
|
||||||
setCmdLink(&(*b)->list, cc, false);
|
setCmdLink(&(*b)->list, cc, false);
|
||||||
cc->prefix = (*b)->name.size();
|
cc->prefix = (*b)->name.size();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,22 +235,29 @@ void CmdMngr::registerPrefix( const char* nn )
|
|||||||
{
|
{
|
||||||
if (*nn == 0) return;
|
if (*nn == 0) return;
|
||||||
CmdPrefix** b = findPrefix(nn);
|
CmdPrefix** b = findPrefix(nn);
|
||||||
|
|
||||||
if (*b) return;
|
if (*b) return;
|
||||||
*b = new CmdPrefix(nn, this);
|
*b = new CmdPrefix(nn, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CmdMngr::CmdPrefix** CmdMngr::findPrefix( const char* nn ){
|
CmdMngr::CmdPrefix** CmdMngr::findPrefix(const char* nn)
|
||||||
|
{
|
||||||
CmdPrefix** aa = &prefixHead;
|
CmdPrefix** aa = &prefixHead;
|
||||||
while(*aa){
|
|
||||||
|
while (*aa)
|
||||||
|
{
|
||||||
if (!strncmp((*aa)->name.c_str(), nn, (*aa)->name.size()))
|
if (!strncmp((*aa)->name.c_str(), nn, (*aa)->name.size()))
|
||||||
break;
|
break;
|
||||||
aa = &(*aa)->next;
|
aa = &(*aa)->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return aa;
|
return aa;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdMngr::clearPrefix(){
|
void CmdMngr::clearPrefix()
|
||||||
while(prefixHead){
|
{
|
||||||
|
while (prefixHead)
|
||||||
|
{
|
||||||
CmdPrefix* a = prefixHead->next;
|
CmdPrefix* a = prefixHead->next;
|
||||||
delete prefixHead;
|
delete prefixHead;
|
||||||
prefixHead = a;
|
prefixHead = a;
|
||||||
@ -264,7 +275,8 @@ void CmdMngr::clear()
|
|||||||
clearBufforedInfo();
|
clearBufforedInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdMngr::clearBufforedInfo() {
|
void CmdMngr::clearBufforedInfo()
|
||||||
|
{
|
||||||
buf_type = -1;
|
buf_type = -1;
|
||||||
buf_access = 0;
|
buf_access = 0;
|
||||||
buf_id = -1;
|
buf_id = -1;
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
// class CmdMngr
|
// class CmdMngr
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
CMD_ConsoleCommand,
|
CMD_ConsoleCommand,
|
||||||
CMD_ClientCommand,
|
CMD_ClientCommand,
|
||||||
CMD_ServerCommand
|
CMD_ServerCommand
|
||||||
@ -48,14 +49,17 @@ public:
|
|||||||
class Command;
|
class Command;
|
||||||
friend class Command;
|
friend class Command;
|
||||||
|
|
||||||
class Command {
|
class Command
|
||||||
|
{
|
||||||
friend class CmdMngr;
|
friend class CmdMngr;
|
||||||
|
|
||||||
CPluginMngr::CPlugin* plugin;
|
CPluginMngr::CPlugin* plugin;
|
||||||
CmdMngr* parent;
|
CmdMngr* parent;
|
||||||
String command;
|
String command;
|
||||||
String argument;
|
String argument;
|
||||||
String commandline;
|
String commandline;
|
||||||
String info;
|
String info;
|
||||||
|
|
||||||
bool listable;
|
bool listable;
|
||||||
int function;
|
int function;
|
||||||
int flags;
|
int flags;
|
||||||
@ -63,10 +67,10 @@ public:
|
|||||||
int cmdtype;
|
int cmdtype;
|
||||||
int prefix;
|
int prefix;
|
||||||
static int uniqueid;
|
static int uniqueid;
|
||||||
|
|
||||||
Command(CPluginMngr::CPlugin* pplugin, const char* pcmd, const char* pinfo, int pflags, int pfunc, bool pviewable, CmdMngr* pparent);
|
Command(CPluginMngr::CPlugin* pplugin, const char* pcmd, const char* pinfo, int pflags, int pfunc, bool pviewable, CmdMngr* pparent);
|
||||||
~Command();
|
~Command();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline const char* getCommand() { return command.c_str(); }
|
inline const char* getCommand() { return command.c_str(); }
|
||||||
inline const char* getArgument() { return argument.c_str(); }
|
inline const char* getArgument() { return argument.c_str(); }
|
||||||
inline const char* getCmdInfo() { return info.c_str(); }
|
inline const char* getCmdInfo() { return info.c_str(); }
|
||||||
@ -79,17 +83,17 @@ public:
|
|||||||
inline bool isViewable() const { return listable; }
|
inline bool isViewable() const { return listable; }
|
||||||
inline int getFlags() const { return flags; }
|
inline int getFlags() const { return flags; }
|
||||||
inline long int getId() const { return (long int)id; }
|
inline long int getId() const { return (long int)id; }
|
||||||
|
|
||||||
const char* getCmdType() const;
|
const char* getCmdType() const;
|
||||||
void setCmdType(int a);
|
void setCmdType(int a);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct CmdPrefix;
|
struct CmdPrefix;
|
||||||
friend struct CmdPrefix;
|
friend struct CmdPrefix;
|
||||||
|
|
||||||
struct CmdLink {
|
struct CmdLink
|
||||||
|
{
|
||||||
Command* cmd;
|
Command* cmd;
|
||||||
CmdLink* next;
|
CmdLink* next;
|
||||||
CmdLink(Command* c): cmd(c), next(0) {}
|
CmdLink(Command* c): cmd(c), next(0) {}
|
||||||
@ -99,7 +103,8 @@ private:
|
|||||||
CmdLink* srvcmdlist;
|
CmdLink* srvcmdlist;
|
||||||
CmdLink* clcmdlist;
|
CmdLink* clcmdlist;
|
||||||
|
|
||||||
struct CmdPrefix {
|
struct CmdPrefix
|
||||||
|
{
|
||||||
String name;
|
String name;
|
||||||
CmdMngr* parent;
|
CmdMngr* parent;
|
||||||
CmdLink* list;
|
CmdLink* list;
|
||||||
@ -122,13 +127,16 @@ public:
|
|||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
void registerPrefix(const char* nn);
|
void registerPrefix(const char* nn);
|
||||||
|
|
||||||
Command* registerCommand(CPluginMngr::CPlugin* plugin, int func, char* cmd, char* info, int level, bool listable);
|
Command* registerCommand(CPluginMngr::CPlugin* plugin, int func, char* cmd, char* info, int level, bool listable);
|
||||||
Command* getCmd(long int id, int type, int access);
|
Command* getCmd(long int id, int type, int access);
|
||||||
int getCmdNum(int type, int access);
|
int getCmdNum(int type, int access);
|
||||||
|
|
||||||
void clearBufforedInfo();
|
void clearBufforedInfo();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
class iterator {
|
class iterator
|
||||||
|
{
|
||||||
CmdLink *a;
|
CmdLink *a;
|
||||||
public:
|
public:
|
||||||
iterator(CmdLink*aa = 0) : a(aa) {}
|
iterator(CmdLink*aa = 0) : a(aa) {}
|
||||||
@ -138,28 +146,30 @@ public:
|
|||||||
operator bool () const { return a ? true : false; }
|
operator bool () const { return a ? true : false; }
|
||||||
Command& operator*() { return *a->cmd; }
|
Command& operator*() { return *a->cmd; }
|
||||||
};
|
};
|
||||||
inline iterator clcmdprefixbegin(const char* nn){
|
|
||||||
|
inline iterator clcmdprefixbegin(const char* nn)
|
||||||
|
{
|
||||||
CmdPrefix* a = *findPrefix(nn);
|
CmdPrefix* a = *findPrefix(nn);
|
||||||
return iterator(a ? a->list : 0);
|
return iterator(a ? a->list : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline iterator clcmdbegin() const { return iterator(clcmdlist); }
|
inline iterator clcmdbegin() const { return iterator(clcmdlist); }
|
||||||
inline iterator srvcmdbegin() const { return iterator(srvcmdlist); }
|
inline iterator srvcmdbegin() const { return iterator(srvcmdlist); }
|
||||||
inline iterator begin(int type) const { return iterator(sortedlists[type]); }
|
inline iterator begin(int type) const { return iterator(sortedlists[type]); }
|
||||||
inline iterator end() const { return iterator(0); }
|
inline iterator end() const { return iterator(0); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int buf_cmdid;
|
int buf_cmdid;
|
||||||
int buf_cmdtype;
|
int buf_cmdtype;
|
||||||
int buf_cmdaccess;
|
int buf_cmdaccess;
|
||||||
|
|
||||||
iterator buf_cmdptr;
|
iterator buf_cmdptr;
|
||||||
|
|
||||||
int buf_id;
|
int buf_id;
|
||||||
int buf_type;
|
int buf_type;
|
||||||
int buf_access;
|
int buf_access;
|
||||||
int buf_num;
|
int buf_num;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif //COMMANDS_H
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ EventsMngr::ClEvent::ClEvent(CPluginMngr::CPlugin* plugin, int func, int flags)
|
|||||||
m_FlagWorld = (flags & 1) ? true : false; // flag a
|
m_FlagWorld = (flags & 1) ? true : false; // flag a
|
||||||
m_FlagPlayer = (flags & 2) ? true : false; // flag b
|
m_FlagPlayer = (flags & 2) ? true : false; // flag b
|
||||||
m_FlagOnce = (flags & 4) ? true : false; // flag c
|
m_FlagOnce = (flags & 4) ? true : false; // flag c
|
||||||
|
|
||||||
if (flags & 24)
|
if (flags & 24)
|
||||||
{
|
{
|
||||||
m_FlagAlive = (flags & 16) ? true : false; // flag e
|
m_FlagAlive = (flags & 16) ? true : false; // flag e
|
||||||
@ -64,12 +65,14 @@ EventsMngr::ClEvent::~ClEvent()
|
|||||||
{
|
{
|
||||||
cond_t *tmp1 = m_Conditions;
|
cond_t *tmp1 = m_Conditions;
|
||||||
cond_t *tmp2 = NULL;
|
cond_t *tmp2 = NULL;
|
||||||
|
|
||||||
while (tmp1)
|
while (tmp1)
|
||||||
{
|
{
|
||||||
tmp2 = tmp1->next;
|
tmp2 = tmp1->next;
|
||||||
delete tmp1;
|
delete tmp1;
|
||||||
tmp1 = tmp2;
|
tmp1 = tmp2;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Conditions = NULL;
|
m_Conditions = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,14 +85,17 @@ void EventsMngr::NextParam()
|
|||||||
|
|
||||||
MsgDataEntry *tmp = NULL;
|
MsgDataEntry *tmp = NULL;
|
||||||
int tmpSize = 0;
|
int tmpSize = 0;
|
||||||
|
|
||||||
if (m_ParseVault)
|
if (m_ParseVault)
|
||||||
{
|
{
|
||||||
// copy to tmp
|
// copy to tmp
|
||||||
tmp = new MsgDataEntry[m_ParseVaultSize];
|
tmp = new MsgDataEntry[m_ParseVaultSize];
|
||||||
|
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
{
|
{
|
||||||
return; // :TODO: Error report !!
|
return; // :TODO: Error report !!
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(tmp, m_ParseVault, m_ParseVaultSize * sizeof(MsgDataEntry));
|
memcpy(tmp, m_ParseVault, m_ParseVaultSize * sizeof(MsgDataEntry));
|
||||||
tmpSize = m_ParseVaultSize;
|
tmpSize = m_ParseVaultSize;
|
||||||
delete [] m_ParseVault;
|
delete [] m_ParseVault;
|
||||||
@ -102,6 +108,7 @@ void EventsMngr::NextParam()
|
|||||||
m_ParseVaultSize = INITIAL_PARSEVAULT_SIZE;
|
m_ParseVaultSize = INITIAL_PARSEVAULT_SIZE;
|
||||||
|
|
||||||
m_ParseVault = new MsgDataEntry[m_ParseVaultSize];
|
m_ParseVault = new MsgDataEntry[m_ParseVaultSize];
|
||||||
|
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
memcpy(m_ParseVault, tmp, tmpSize * sizeof(MsgDataEntry));
|
memcpy(m_ParseVault, tmp, tmpSize * sizeof(MsgDataEntry));
|
||||||
@ -128,7 +135,6 @@ EventsMngr::~EventsMngr()
|
|||||||
clearEvents();
|
clearEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CPluginMngr::CPlugin * EventsMngr::ClEvent::getPlugin()
|
CPluginMngr::CPlugin * EventsMngr::ClEvent::getPlugin()
|
||||||
{
|
{
|
||||||
return m_Plugin;
|
return m_Plugin;
|
||||||
@ -170,7 +176,7 @@ void EventsMngr::ClEvent::registerFilter(char *filter)
|
|||||||
|
|
||||||
// rest of line
|
// rest of line
|
||||||
tmpCond->sValue.assign(value);
|
tmpCond->sValue.assign(value);
|
||||||
tmpCond->fValue = atof(value);
|
tmpCond->fValue = static_cast<float>(atof(value));
|
||||||
tmpCond->iValue = atoi(value);
|
tmpCond->iValue = atoi(value);
|
||||||
|
|
||||||
tmpCond->next = NULL;
|
tmpCond->next = NULL;
|
||||||
@ -178,10 +184,11 @@ void EventsMngr::ClEvent::registerFilter(char *filter)
|
|||||||
if (m_Conditions)
|
if (m_Conditions)
|
||||||
{
|
{
|
||||||
cond_t *tmp = m_Conditions;
|
cond_t *tmp = m_Conditions;
|
||||||
|
|
||||||
while (tmp->next)
|
while (tmp->next)
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
tmp->next = tmpCond;
|
|
||||||
|
|
||||||
|
tmp->next = tmpCond;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_Conditions = tmpCond;
|
m_Conditions = tmpCond;
|
||||||
@ -194,6 +201,7 @@ EventsMngr::ClEvent* EventsMngr::registerEvent(CPluginMngr::CPlugin* plugin, int
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ClEvent *event = new ClEvent(plugin, func, flags);
|
ClEvent *event = new ClEvent(plugin, func, flags);
|
||||||
|
|
||||||
if (!event)
|
if (!event)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -221,7 +229,6 @@ void EventsMngr::parserInit(int msg_type, float* timer, CPlayer* pPlayer, int in
|
|||||||
if ((*iter).m_Done)
|
if ((*iter).m_Done)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
if (!(*iter).m_Plugin->isExecutable((*iter).m_Func))
|
if (!(*iter).m_Plugin->isExecutable((*iter).m_Func))
|
||||||
{
|
{
|
||||||
(*iter).m_Done = true;
|
(*iter).m_Done = true;
|
||||||
@ -247,6 +254,7 @@ void EventsMngr::parserInit(int msg_type, float* timer, CPlayer* pPlayer, int in
|
|||||||
(*iter).m_Done = true;
|
(*iter).m_Done = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ParseNotDone = true;
|
m_ParseNotDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,6 +265,7 @@ void EventsMngr::parserInit(int msg_type, float* timer, CPlayer* pPlayer, int in
|
|||||||
m_ParseVault[0].type = MSG_INTEGER;
|
m_ParseVault[0].type = MSG_INTEGER;
|
||||||
m_ParseVault[0].iValue = index;
|
m_ParseVault[0].iValue = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ParseFun = &m_Events[msg_type];
|
m_ParseFun = &m_Events[msg_type];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +275,6 @@ void EventsMngr::parseValue(int iValue)
|
|||||||
if (!m_ParseNotDone || !m_ParseFun)
|
if (!m_ParseNotDone || !m_ParseFun)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
// grow if needed
|
// grow if needed
|
||||||
++m_ParsePos;
|
++m_ParsePos;
|
||||||
NextParam();
|
NextParam();
|
||||||
@ -284,6 +292,7 @@ void EventsMngr::parseValue(int iValue)
|
|||||||
// loop through conditions
|
// loop through conditions
|
||||||
bool execute = false;
|
bool execute = false;
|
||||||
bool anyConditions = false;
|
bool anyConditions = false;
|
||||||
|
|
||||||
for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next)
|
for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next)
|
||||||
{
|
{
|
||||||
if (condIter->paramId == m_ParsePos)
|
if (condIter->paramId == m_ParsePos)
|
||||||
@ -301,6 +310,7 @@ void EventsMngr::parseValue(int iValue)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anyConditions && !execute)
|
if (anyConditions && !execute)
|
||||||
(*iter).m_Done = true; // don't execute
|
(*iter).m_Done = true; // don't execute
|
||||||
}
|
}
|
||||||
@ -312,7 +322,6 @@ void EventsMngr::parseValue(float fValue)
|
|||||||
if (!m_ParseNotDone || !m_ParseFun)
|
if (!m_ParseNotDone || !m_ParseFun)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
// grow if needed
|
// grow if needed
|
||||||
++m_ParsePos;
|
++m_ParsePos;
|
||||||
NextParam();
|
NextParam();
|
||||||
@ -330,6 +339,7 @@ void EventsMngr::parseValue(float fValue)
|
|||||||
// loop through conditions
|
// loop through conditions
|
||||||
bool execute = false;
|
bool execute = false;
|
||||||
bool anyConditions = false;
|
bool anyConditions = false;
|
||||||
|
|
||||||
for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next)
|
for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next)
|
||||||
{
|
{
|
||||||
if (condIter->paramId == m_ParsePos)
|
if (condIter->paramId == m_ParsePos)
|
||||||
@ -342,10 +352,12 @@ void EventsMngr::parseValue(float fValue)
|
|||||||
case '<': if (fValue < condIter->fValue) execute = true; break;
|
case '<': if (fValue < condIter->fValue) execute = true; break;
|
||||||
case '>': if (fValue > condIter->fValue) execute = true; break;
|
case '>': if (fValue > condIter->fValue) execute = true; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execute)
|
if (execute)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anyConditions && !execute)
|
if (anyConditions && !execute)
|
||||||
(*iter).m_Done = true; // don't execute
|
(*iter).m_Done = true; // don't execute
|
||||||
}
|
}
|
||||||
@ -374,6 +386,7 @@ void EventsMngr::parseValue(const char *sz)
|
|||||||
// loop through conditions
|
// loop through conditions
|
||||||
bool execute = false;
|
bool execute = false;
|
||||||
bool anyConditions = false;
|
bool anyConditions = false;
|
||||||
|
|
||||||
for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next)
|
for (ClEvent::cond_t *condIter = (*iter).m_Conditions; condIter; condIter = condIter->next)
|
||||||
{
|
{
|
||||||
if (condIter->paramId == m_ParsePos)
|
if (condIter->paramId == m_ParsePos)
|
||||||
@ -385,10 +398,12 @@ void EventsMngr::parseValue(const char *sz)
|
|||||||
case '!': if (strcmp(sz, condIter->sValue.c_str())) execute = true; break;
|
case '!': if (strcmp(sz, condIter->sValue.c_str())) execute = true; break;
|
||||||
case '&': if (strstr(sz, condIter->sValue.c_str())) execute = true; break;
|
case '&': if (strstr(sz, condIter->sValue.c_str())) execute = true; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execute)
|
if (execute)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anyConditions && !execute)
|
if (anyConditions && !execute)
|
||||||
(*iter).m_Done = true; // don't execute
|
(*iter).m_Done = true; // don't execute
|
||||||
}
|
}
|
||||||
@ -408,6 +423,7 @@ void EventsMngr::executeEvents()
|
|||||||
(*iter).m_Done = false;
|
(*iter).m_Done = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*iter).m_Stamp = (float)*m_Timer;
|
(*iter).m_Stamp = (float)*m_Timer;
|
||||||
executeForwards((*iter).m_Func, m_ParseVault ? m_ParseVault[0].iValue : 0);
|
executeForwards((*iter).m_Func, m_ParseVault ? m_ParseVault[0].iValue : 0);
|
||||||
}
|
}
|
||||||
@ -465,9 +481,9 @@ float EventsMngr::getArgFloat(int a) const
|
|||||||
switch (m_ParseVault[a].type)
|
switch (m_ParseVault[a].type)
|
||||||
{
|
{
|
||||||
case MSG_INTEGER:
|
case MSG_INTEGER:
|
||||||
return m_ParseVault[a].iValue;
|
return static_cast<float>(m_ParseVault[a].iValue);
|
||||||
case MSG_STRING:
|
case MSG_STRING:
|
||||||
return atof(m_ParseVault[a].sValue);
|
return static_cast<float>(atof(m_ParseVault[a].sValue));
|
||||||
default:
|
default:
|
||||||
return m_ParseVault[a].fValue;
|
return m_ParseVault[a].fValue;
|
||||||
}
|
}
|
||||||
@ -479,6 +495,7 @@ void EventsMngr::clearEvents(void)
|
|||||||
{
|
{
|
||||||
m_Events[i].clear();
|
m_Events[i].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete parsevault
|
// delete parsevault
|
||||||
if (m_ParseVault)
|
if (m_ParseVault)
|
||||||
{
|
{
|
||||||
@ -506,6 +523,7 @@ int EventsMngr::getEventId(const char* msg)
|
|||||||
|
|
||||||
// if msg is a number, return it
|
// if msg is a number, return it
|
||||||
int pos = atoi(msg);
|
int pos = atoi(msg);
|
||||||
|
|
||||||
if (pos != 0)
|
if (pos != 0)
|
||||||
return pos;
|
return pos;
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
|
|
||||||
#define MAX_AMX_REG_MSG MAX_REG_MSGS + 16
|
#define MAX_AMX_REG_MSG MAX_REG_MSGS + 16
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
CS_DEATHMSG = MAX_REG_MSGS,
|
CS_DEATHMSG = MAX_REG_MSGS,
|
||||||
// CS_ROUNDEND,
|
// CS_ROUNDEND,
|
||||||
// CS_ROUNDSTART,
|
// CS_ROUNDSTART,
|
||||||
@ -116,6 +117,7 @@ private:
|
|||||||
const char* sValue;
|
const char* sValue;
|
||||||
MsgParamType type;
|
MsgParamType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
MsgDataEntry *m_ParseVault;
|
MsgDataEntry *m_ParseVault;
|
||||||
int m_ParseVaultSize;
|
int m_ParseVaultSize;
|
||||||
void NextParam(); // make sure a new parameter can be added
|
void NextParam(); // make sure a new parameter can be added
|
||||||
@ -140,11 +142,13 @@ public:
|
|||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
ClEvent* registerEvent(CPluginMngr::CPlugin* plugin, int func, int flags, int msgid);
|
ClEvent* registerEvent(CPluginMngr::CPlugin* plugin, int func, int flags, int msgid);
|
||||||
|
|
||||||
void parserInit(int msg_type, float* timer, CPlayer* pPlayer, int index);
|
void parserInit(int msg_type, float* timer, CPlayer* pPlayer, int index);
|
||||||
void parseValue(int iValue);
|
void parseValue(int iValue);
|
||||||
void parseValue(float fValue);
|
void parseValue(float fValue);
|
||||||
void parseValue(const char *sz);
|
void parseValue(const char *sz);
|
||||||
void executeEvents();
|
void executeEvents();
|
||||||
|
|
||||||
int getArgNum() const; //{ return (parsePos + 1); }
|
int getArgNum() const; //{ return (parsePos + 1); }
|
||||||
const char* getArgString(int a) const;
|
const char* getArgString(int a) const;
|
||||||
int getArgInteger(int a) const;
|
int getArgInteger(int a) const;
|
||||||
@ -154,6 +158,4 @@ public:
|
|||||||
int getCurrentMsgType();
|
int getCurrentMsgType();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifdef __CEVENTS_H__
|
#endif //__CEVENTS_H__
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class File
|
// class File
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
File::File(const char* n, const char* m)
|
File::File(const char* n, const char* m)
|
||||||
{
|
{
|
||||||
fp = fopen(n, m);
|
fp = fopen(n, m);
|
||||||
@ -70,7 +71,6 @@ File& operator<<( File& f, int n )
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
File& operator<<(File& f, const char& c)
|
File& operator<<(File& f, const char& c)
|
||||||
{
|
{
|
||||||
if (f) fputc(c, f.fp);
|
if (f) fputc(c, f.fp);
|
||||||
@ -96,6 +96,7 @@ int File::getline( char* buf, int sz )
|
|||||||
{
|
{
|
||||||
int a = sz;
|
int a = sz;
|
||||||
char *origBuf = buf;
|
char *origBuf = buf;
|
||||||
|
|
||||||
if (*this)
|
if (*this)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
@ -123,4 +124,3 @@ File& File::skipWs( )
|
|||||||
ungetc(c, fp);
|
ungetc(c, fp);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,16 +43,17 @@ class File
|
|||||||
public:
|
public:
|
||||||
File(const char* n, const char* m);
|
File(const char* n, const char* m);
|
||||||
~File();
|
~File();
|
||||||
|
|
||||||
operator bool () const;
|
operator bool () const;
|
||||||
|
|
||||||
friend File& operator<<(File& f, const String& n);
|
friend File& operator<<(File& f, const String& n);
|
||||||
friend File& operator<<(File& f, const char* n);
|
friend File& operator<<(File& f, const char* n);
|
||||||
friend File& operator<<(File& f, const char& c);
|
friend File& operator<<(File& f, const char& c);
|
||||||
friend File& operator<<(File& f, int n);
|
friend File& operator<<(File& f, int n);
|
||||||
friend File& operator>>(File& f, String& n);
|
friend File& operator>>(File& f, String& n);
|
||||||
friend File& operator>>(File& f, char* n);
|
friend File& operator>>(File& f, char* n);
|
||||||
|
|
||||||
int getline(char* buf, int sz);
|
int getline(char* buf, int sz);
|
||||||
|
|
||||||
File& skipWs();
|
File& skipWs();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,19 +30,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
|
#include "debugger.h"
|
||||||
void AMXAPI amxx_InvalidateTrace(AMX *amx);
|
|
||||||
|
|
||||||
CForward::CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam *paramTypes)
|
CForward::CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam *paramTypes)
|
||||||
{
|
{
|
||||||
m_FuncName = name;
|
m_FuncName = name;
|
||||||
m_ExecType = et;
|
m_ExecType = et;
|
||||||
m_NumParams = numParams;
|
m_NumParams = numParams;
|
||||||
|
|
||||||
memcpy((void *)m_ParamTypes, paramTypes, numParams * sizeof(ForwardParam));
|
memcpy((void *)m_ParamTypes, paramTypes, numParams * sizeof(ForwardParam));
|
||||||
|
|
||||||
// find funcs
|
// find funcs
|
||||||
int func;
|
int func;
|
||||||
AMXForward *tmp = NULL;
|
AMXForward *tmp = NULL;
|
||||||
m_Funcs.clear();
|
m_Funcs.clear();
|
||||||
|
|
||||||
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
|
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
|
||||||
{
|
{
|
||||||
if ((*iter).isValid() && amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE)
|
if ((*iter).isValid() && amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE)
|
||||||
@ -74,67 +76,73 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
{
|
{
|
||||||
// Get debug info
|
// Get debug info
|
||||||
AMX *amx = (*iter).pPlugin->getAMX();
|
AMX *amx = (*iter).pPlugin->getAMX();
|
||||||
AMX_DBGINFO *pInfo = (AMX_DBGINFO *)(amx->userdata[2]);
|
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
|
||||||
if (pInfo)
|
|
||||||
pInfo->error = AMX_ERR_NONE;
|
if (pDebugger)
|
||||||
|
pDebugger->BeginExec();
|
||||||
|
|
||||||
// handle strings & arrays
|
// handle strings & arrays
|
||||||
int i, ax = 0;
|
int i, ax = 0;
|
||||||
|
|
||||||
for (i = 0; i < m_NumParams; ++i)
|
for (i = 0; i < m_NumParams; ++i)
|
||||||
{
|
{
|
||||||
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot(iter->pPlugin->getAMX(),
|
amx_Allot(iter->pPlugin->getAMX(), (m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i])) + 1 : STRINGEX_MAXLENGTH, &realParams[i], &tmp);
|
||||||
(m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i]))+1 : STRINGEX_MAXLENGTH,
|
|
||||||
&realParams[i], &tmp);
|
|
||||||
amx_SetStringOld(tmp, (const char *)(params[i]), 0, 0);
|
amx_SetStringOld(tmp, (const char *)(params[i]), 0, 0);
|
||||||
physAddrs[i] = tmp;
|
physAddrs[i] = tmp;
|
||||||
}
|
}
|
||||||
else if (m_ParamTypes[i] == FP_ARRAY)
|
else if (m_ParamTypes[i] == FP_ARRAY)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot(amx, preparedArrays[params[i]].size,
|
amx_Allot(amx, preparedArrays[params[i]].size, &realParams[i], &tmp);
|
||||||
&realParams[i], &tmp);
|
|
||||||
physAddrs[i] = tmp;
|
physAddrs[i] = tmp;
|
||||||
|
|
||||||
if (preparedArrays[params[i]].type == Type_Cell)
|
if (preparedArrays[params[i]].type == Type_Cell)
|
||||||
{
|
{
|
||||||
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||||
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
realParams[i] = params[i];
|
realParams[i] = params[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Push the parameters in reverse order. Weird, unfriendly part of Small 3.0!
|
//Push the parameters in reverse order. Weird, unfriendly part of Small 3.0!
|
||||||
for (i = m_NumParams-1; i >= 0; i--)
|
for (i = m_NumParams-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
amx_Push(amx, realParams[i]);
|
amx_Push(amx, realParams[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
cell retVal;
|
cell retVal;
|
||||||
int err = amx_Exec(amx, &retVal, iter->func);
|
int err = amx_Exec(amx, &retVal, iter->func);
|
||||||
|
|
||||||
// log runtime error, if any
|
// log runtime error, if any
|
||||||
if (err != AMX_ERR_NONE)
|
if (err != AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
//Did something else set an error?
|
//Did something else set an error?
|
||||||
if (pInfo && pInfo->error != AMX_ERR_NONE)
|
if (pDebugger && pDebugger->ErrorExists())
|
||||||
{
|
{
|
||||||
//we don't care, something else logged the error.
|
//we don't care, something else logged the error.
|
||||||
} else {
|
}
|
||||||
|
else if (err != -1)
|
||||||
|
{
|
||||||
//nothing logged the error so spit it out anyway
|
//nothing logged the error so spit it out anyway
|
||||||
LogError(amx, err, "");
|
LogError(amx, err, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
amxx_InvalidateTrace(amx);
|
|
||||||
amx->error = AMX_ERR_NONE;
|
amx->error = AMX_ERR_NONE;
|
||||||
|
|
||||||
|
if (pDebugger)
|
||||||
|
pDebugger->EndExec();
|
||||||
|
|
||||||
// cleanup strings & arrays
|
// cleanup strings & arrays
|
||||||
for (i = 0; i < m_NumParams; ++i)
|
for (i = 0; i < m_NumParams; ++i)
|
||||||
{
|
{
|
||||||
@ -157,10 +165,9 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
if (preparedArrays[params[i]].type == Type_Cell)
|
if (preparedArrays[params[i]].type == Type_Cell)
|
||||||
{
|
{
|
||||||
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||||
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
||||||
}
|
}
|
||||||
@ -190,6 +197,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return globRetVal;
|
return globRetVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,62 +237,66 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
if (!pPlugin->isExecutable(m_Func))
|
if (!pPlugin->isExecutable(m_Func))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
AMX_DBGINFO *pInfo = (AMX_DBGINFO *)(m_Amx->userdata[2]);
|
Debugger *pDebugger = (Debugger *)m_Amx->userdata[UD_DEBUGGER];
|
||||||
if (pInfo)
|
if (pDebugger)
|
||||||
pInfo->error = AMX_ERR_NONE;
|
pDebugger->BeginExec();
|
||||||
|
|
||||||
// handle strings & arrays
|
// handle strings & arrays
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < m_NumParams; ++i)
|
for (i = 0; i < m_NumParams; ++i)
|
||||||
{
|
{
|
||||||
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot(m_Amx,
|
amx_Allot(m_Amx, (m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i])) + 1 : STRINGEX_MAXLENGTH, &realParams[i], &tmp);
|
||||||
(m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i]))+1 : STRINGEX_MAXLENGTH,
|
|
||||||
&realParams[i], &tmp);
|
|
||||||
amx_SetStringOld(tmp, (const char *)(params[i]), 0, 0);
|
amx_SetStringOld(tmp, (const char *)(params[i]), 0, 0);
|
||||||
physAddrs[i] = tmp;
|
physAddrs[i] = tmp;
|
||||||
}
|
}
|
||||||
else if (m_ParamTypes[i] == FP_ARRAY)
|
else if (m_ParamTypes[i] == FP_ARRAY)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot(m_Amx, preparedArrays[params[i]].size,
|
amx_Allot(m_Amx, preparedArrays[params[i]].size, &realParams[i], &tmp);
|
||||||
&realParams[i], &tmp);
|
|
||||||
physAddrs[i] = tmp;
|
physAddrs[i] = tmp;
|
||||||
|
|
||||||
if (preparedArrays[params[i]].type == Type_Cell)
|
if (preparedArrays[params[i]].type == Type_Cell)
|
||||||
{
|
{
|
||||||
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
memcpy(tmp, preparedArrays[params[i]].ptr, preparedArrays[params[i]].size * sizeof(cell));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||||
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
*tmp++ = (static_cast<cell>(*data++)) & 0xFF;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
realParams[i] = params[i];
|
realParams[i] = params[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = m_NumParams - 1; i >= 0; i--)
|
for (i = m_NumParams - 1; i >= 0; i--)
|
||||||
amx_Push(m_Amx, realParams[i]);
|
amx_Push(m_Amx, realParams[i]);
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
cell retVal;
|
cell retVal;
|
||||||
int err = amx_Exec(m_Amx, &retVal, m_Func);
|
int err = amx_Exec(m_Amx, &retVal, m_Func);
|
||||||
|
|
||||||
if (err != AMX_ERR_NONE)
|
if (err != AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
//Did something else set an error?
|
//Did something else set an error?
|
||||||
if (pInfo && pInfo->error != AMX_ERR_NONE)
|
if (pDebugger && pDebugger->ErrorExists())
|
||||||
{
|
{
|
||||||
//we don't care, something else logged the error.
|
//we don't care, something else logged the error.
|
||||||
} else {
|
}
|
||||||
|
else if (err != -1)
|
||||||
|
{
|
||||||
//nothing logged the error so spit it out anyway
|
//nothing logged the error so spit it out anyway
|
||||||
LogError(m_Amx, err, "");
|
LogError(m_Amx, err, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
amxx_InvalidateTrace(m_Amx);
|
|
||||||
|
if (pDebugger)
|
||||||
|
pDebugger->EndExec();
|
||||||
|
|
||||||
m_Amx->error = AMX_ERR_NONE;
|
m_Amx->error = AMX_ERR_NONE;
|
||||||
|
|
||||||
// cleanup strings & arrays
|
// cleanup strings & arrays
|
||||||
@ -309,10 +321,9 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
if (preparedArrays[params[i]].type == Type_Cell)
|
if (preparedArrays[params[i]].type == Type_Cell)
|
||||||
{
|
{
|
||||||
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
memcpy(preparedArrays[params[i]].ptr, tmp, preparedArrays[params[i]].size * sizeof(cell));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
char *data = (char*)preparedArrays[params[i]].ptr;
|
char *data = (char*)preparedArrays[params[i]].ptr;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||||
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
||||||
}
|
}
|
||||||
@ -328,9 +339,12 @@ int CForwardMngr::registerForward(const char *funcName, ForwardExecType et, int
|
|||||||
{
|
{
|
||||||
int retVal = m_Forwards.size() << 1;
|
int retVal = m_Forwards.size() << 1;
|
||||||
CForward *tmp = new CForward(funcName, et, numParams, paramTypes);
|
CForward *tmp = new CForward(funcName, et, numParams, paramTypes);
|
||||||
|
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return -1; // should be invalid
|
return -1; // should be invalid
|
||||||
|
|
||||||
m_Forwards.push_back(tmp);
|
m_Forwards.push_back(tmp);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,22 +352,26 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For
|
|||||||
{
|
{
|
||||||
int retVal = -1;
|
int retVal = -1;
|
||||||
CSPForward *pForward;
|
CSPForward *pForward;
|
||||||
|
|
||||||
if (!m_FreeSPForwards.empty())
|
if (!m_FreeSPForwards.empty())
|
||||||
{
|
{
|
||||||
retVal = m_FreeSPForwards.front();
|
retVal = m_FreeSPForwards.front();
|
||||||
pForward = m_SPForwards[retVal >> 1];
|
pForward = m_SPForwards[retVal >> 1];
|
||||||
pForward->Set(func, amx, numParams, paramTypes);
|
pForward->Set(func, amx, numParams, paramTypes);
|
||||||
|
|
||||||
if (pForward->getFuncsNum() == 0)
|
if (pForward->getFuncsNum() == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
m_FreeSPForwards.pop();
|
m_FreeSPForwards.pop();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
retVal = (m_SPForwards.size() << 1) | 1;
|
retVal = (m_SPForwards.size() << 1) | 1;
|
||||||
pForward = new CSPForward();
|
pForward = new CSPForward();
|
||||||
|
|
||||||
if (!pForward)
|
if (!pForward)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pForward->Set(func, amx, numParams, paramTypes);
|
pForward->Set(func, amx, numParams, paramTypes);
|
||||||
|
|
||||||
if (pForward->getFuncsNum() == 0)
|
if (pForward->getFuncsNum() == 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@ -362,6 +380,7 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For
|
|||||||
|
|
||||||
m_SPForwards.push_back(pForward);
|
m_SPForwards.push_back(pForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,56 +388,58 @@ int CForwardMngr::registerSPForward(const char *funcName, AMX *amx, int numParam
|
|||||||
{
|
{
|
||||||
int retVal = (m_SPForwards.size() << 1) | 1;
|
int retVal = (m_SPForwards.size() << 1) | 1;
|
||||||
CSPForward *pForward;
|
CSPForward *pForward;
|
||||||
|
|
||||||
if (!m_FreeSPForwards.empty())
|
if (!m_FreeSPForwards.empty())
|
||||||
{
|
{
|
||||||
retVal = m_FreeSPForwards.front();
|
retVal = m_FreeSPForwards.front();
|
||||||
pForward = m_SPForwards[retVal>>1]; // >>1 because unregisterSPForward pushes the id which contains the sp flag
|
pForward = m_SPForwards[retVal>>1]; // >>1 because unregisterSPForward pushes the id which contains the sp flag
|
||||||
pForward->Set(funcName, amx, numParams, paramTypes);
|
pForward->Set(funcName, amx, numParams, paramTypes);
|
||||||
|
|
||||||
if (pForward->getFuncsNum() == 0)
|
if (pForward->getFuncsNum() == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
m_FreeSPForwards.pop();
|
m_FreeSPForwards.pop();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pForward = new CSPForward();
|
pForward = new CSPForward();
|
||||||
|
|
||||||
if (!pForward)
|
if (!pForward)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pForward->Set(funcName, amx, numParams, paramTypes);
|
pForward->Set(funcName, amx, numParams, paramTypes);
|
||||||
|
|
||||||
if (pForward->getFuncsNum() == 0)
|
if (pForward->getFuncsNum() == 0)
|
||||||
{
|
{
|
||||||
delete pForward;
|
delete pForward;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_SPForwards.push_back(pForward);
|
m_SPForwards.push_back(pForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CForwardMngr::isIdValid(int id) const
|
bool CForwardMngr::isIdValid(int id) const
|
||||||
{
|
{
|
||||||
return (id >= 0) && ((id & 1) ?
|
return (id >= 0) && ((id & 1) ? (static_cast<size_t>(id >> 1) < m_SPForwards.size()) : (static_cast<size_t>(id >> 1) < m_Forwards.size()));
|
||||||
(static_cast<size_t>(id >> 1) < m_SPForwards.size()) :
|
|
||||||
(static_cast<size_t>(id >> 1) < m_Forwards.size()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cell CForwardMngr::executeForwards(int id, cell *params)
|
cell CForwardMngr::executeForwards(int id, cell *params)
|
||||||
{
|
{
|
||||||
int retVal = (id & 1) ? m_SPForwards[id >> 1]->execute(params, m_TmpArrays) :
|
int retVal = (id & 1) ? m_SPForwards[id >> 1]->execute(params, m_TmpArrays) : m_Forwards[id >> 1]->execute(params, m_TmpArrays);
|
||||||
m_Forwards[id >> 1]->execute(params, m_TmpArrays);
|
|
||||||
m_TmpArraysNum = 0;
|
m_TmpArraysNum = 0;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CForwardMngr::getParamsNum(int id) const
|
int CForwardMngr::getParamsNum(int id) const
|
||||||
{
|
{
|
||||||
return (id & 1) ? m_SPForwards[id >> 1]->getParamsNum() :
|
return (id & 1) ? m_SPForwards[id >> 1]->getParamsNum() : m_Forwards[id >> 1]->getParamsNum();
|
||||||
m_Forwards[id >> 1]->getParamsNum();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ForwardParam CForwardMngr::getParamType(int id, int paramNum) const
|
ForwardParam CForwardMngr::getParamType(int id, int paramNum) const
|
||||||
{
|
{
|
||||||
return (id & 1) ? m_SPForwards[id >> 1]->getParamType(paramNum) :
|
return (id & 1) ? m_SPForwards[id >> 1]->getParamType(paramNum) : m_Forwards[id >> 1]->getParamType(paramNum);
|
||||||
m_Forwards[id >> 1]->getParamType(paramNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CForwardMngr::clear()
|
void CForwardMngr::clear()
|
||||||
@ -427,7 +448,9 @@ void CForwardMngr::clear()
|
|||||||
{
|
{
|
||||||
delete *iter;
|
delete *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPForwardVec::iterator spIter;
|
SPForwardVec::iterator spIter;
|
||||||
|
|
||||||
for (spIter = m_SPForwards.begin(); spIter != m_SPForwards.end(); ++spIter)
|
for (spIter = m_SPForwards.begin(); spIter != m_SPForwards.end(); ++spIter)
|
||||||
{
|
{
|
||||||
delete (*spIter);
|
delete (*spIter);
|
||||||
@ -435,8 +458,10 @@ void CForwardMngr::clear()
|
|||||||
|
|
||||||
m_Forwards.clear();
|
m_Forwards.clear();
|
||||||
m_SPForwards.clear();
|
m_SPForwards.clear();
|
||||||
|
|
||||||
while (!m_FreeSPForwards.empty())
|
while (!m_FreeSPForwards.empty())
|
||||||
m_FreeSPForwards.pop();
|
m_FreeSPForwards.pop();
|
||||||
|
|
||||||
m_TmpArraysNum = 0;
|
m_TmpArraysNum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,70 +477,93 @@ void CForwardMngr::unregisterSPForward(int id)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_SPForwards.at(id >> 1)->isFree = true;
|
m_SPForwards.at(id >> 1)->isFree = true;
|
||||||
|
|
||||||
m_FreeSPForwards.push(id);
|
m_FreeSPForwards.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int registerForward(const char *funcName, ForwardExecType et, ...)
|
int registerForward(const char *funcName, ForwardExecType et, ...)
|
||||||
{
|
{
|
||||||
int curParam = 0;
|
int curParam = 0;
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, et);
|
va_start(argptr, et);
|
||||||
|
|
||||||
ForwardParam params[FORWARD_MAX_PARAMS];
|
ForwardParam params[FORWARD_MAX_PARAMS];
|
||||||
ForwardParam tmp;
|
ForwardParam tmp;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (curParam == FORWARD_MAX_PARAMS)
|
if (curParam == FORWARD_MAX_PARAMS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tmp = (ForwardParam)va_arg(argptr, int);
|
tmp = (ForwardParam)va_arg(argptr, int);
|
||||||
|
|
||||||
if (tmp == FP_DONE)
|
if (tmp == FP_DONE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
params[curParam] = tmp;
|
params[curParam] = tmp;
|
||||||
++curParam;
|
++curParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
return g_forwards.registerForward(funcName, et, curParam, params);
|
return g_forwards.registerForward(funcName, et, curParam, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
int registerSPForwardByName(AMX *amx, const char *funcName, ...)
|
int registerSPForwardByName(AMX *amx, const char *funcName, ...)
|
||||||
{
|
{
|
||||||
int curParam = 0;
|
int curParam = 0;
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, funcName);
|
va_start(argptr, funcName);
|
||||||
|
|
||||||
ForwardParam params[FORWARD_MAX_PARAMS];
|
ForwardParam params[FORWARD_MAX_PARAMS];
|
||||||
ForwardParam tmp;
|
ForwardParam tmp;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (curParam == FORWARD_MAX_PARAMS)
|
if (curParam == FORWARD_MAX_PARAMS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tmp = (ForwardParam)va_arg(argptr, int);
|
tmp = (ForwardParam)va_arg(argptr, int);
|
||||||
|
|
||||||
if (tmp == FP_DONE)
|
if (tmp == FP_DONE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
params[curParam] = tmp;
|
params[curParam] = tmp;
|
||||||
++curParam;
|
++curParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
return g_forwards.registerSPForward(funcName, amx, curParam, params);
|
return g_forwards.registerSPForward(funcName, amx, curParam, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
int registerSPForward(AMX *amx, int func, ...)
|
int registerSPForward(AMX *amx, int func, ...)
|
||||||
{
|
{
|
||||||
int curParam = 0;
|
int curParam = 0;
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, func);
|
va_start(argptr, func);
|
||||||
|
|
||||||
ForwardParam params[FORWARD_MAX_PARAMS];
|
ForwardParam params[FORWARD_MAX_PARAMS];
|
||||||
ForwardParam tmp;
|
ForwardParam tmp;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (curParam == FORWARD_MAX_PARAMS)
|
if (curParam == FORWARD_MAX_PARAMS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tmp = (ForwardParam)va_arg(argptr, int);
|
tmp = (ForwardParam)va_arg(argptr, int);
|
||||||
|
|
||||||
if (tmp == FP_DONE)
|
if (tmp == FP_DONE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
params[curParam] = tmp;
|
params[curParam] = tmp;
|
||||||
++curParam;
|
++curParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
return g_forwards.registerSPForward(func, amx, curParam, params);
|
return g_forwards.registerSPForward(func, amx, curParam, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,9 +573,12 @@ cell executeForwards(int id, ...)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
cell params[FORWARD_MAX_PARAMS];
|
cell params[FORWARD_MAX_PARAMS];
|
||||||
|
|
||||||
int paramsNum = g_forwards.getParamsNum(id);
|
int paramsNum = g_forwards.getParamsNum(id);
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, id);
|
va_start(argptr, id);
|
||||||
|
|
||||||
for (int i = 0; i < paramsNum && i < FORWARD_MAX_PARAMS; ++i)
|
for (int i = 0; i < paramsNum && i < FORWARD_MAX_PARAMS; ++i)
|
||||||
{
|
{
|
||||||
if (g_forwards.getParamType(id, i) == FP_FLOAT)
|
if (g_forwards.getParamType(id, i) == FP_FLOAT)
|
||||||
@ -538,7 +589,9 @@ cell executeForwards(int id, ...)
|
|||||||
else
|
else
|
||||||
params[i] = (cell)va_arg(argptr, cell);
|
params[i] = (cell)va_arg(argptr, cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
return g_forwards.executeForwards(id, params);
|
return g_forwards.executeForwards(id, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,10 +602,13 @@ cell CForwardMngr::prepareArray(void *ptr, unsigned int size, ForwardArrayElemTy
|
|||||||
#ifdef MEMORY_TEST
|
#ifdef MEMORY_TEST
|
||||||
m_validateAllAllocUnits();
|
m_validateAllAllocUnits();
|
||||||
#endif // MEMORY_TEST
|
#endif // MEMORY_TEST
|
||||||
|
|
||||||
AMXXLOG_Log("[AMXX] Forwards with more than 32 parameters are not supported (tried to prepare array # %d).", m_TmpArraysNum + 1);
|
AMXXLOG_Log("[AMXX] Forwards with more than 32 parameters are not supported (tried to prepare array # %d).", m_TmpArraysNum + 1);
|
||||||
m_TmpArraysNum = 0;
|
m_TmpArraysNum = 0;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_TmpArrays[m_TmpArraysNum].ptr = ptr;
|
m_TmpArrays[m_TmpArraysNum].ptr = ptr;
|
||||||
m_TmpArrays[m_TmpArraysNum].size = size;
|
m_TmpArrays[m_TmpArraysNum].size = size;
|
||||||
m_TmpArrays[m_TmpArraysNum].type = type;
|
m_TmpArrays[m_TmpArraysNum].type = type;
|
||||||
|
@ -77,7 +77,9 @@ enum ForwardArrayElemType
|
|||||||
struct ForwardPreparedArray
|
struct ForwardPreparedArray
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
ForwardArrayElemType type;
|
ForwardArrayElemType type;
|
||||||
|
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
bool copyBack;
|
bool copyBack;
|
||||||
};
|
};
|
||||||
@ -88,31 +90,39 @@ class CForward
|
|||||||
const char *m_FuncName;
|
const char *m_FuncName;
|
||||||
ForwardExecType m_ExecType;
|
ForwardExecType m_ExecType;
|
||||||
int m_NumParams;
|
int m_NumParams;
|
||||||
|
|
||||||
struct AMXForward
|
struct AMXForward
|
||||||
{
|
{
|
||||||
CPluginMngr::CPlugin *pPlugin;
|
CPluginMngr::CPlugin *pPlugin;
|
||||||
int func;
|
int func;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef CVector<AMXForward> AMXForwardList;
|
typedef CVector<AMXForward> AMXForwardList;
|
||||||
|
|
||||||
AMXForwardList m_Funcs;
|
AMXForwardList m_Funcs;
|
||||||
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam * paramTypes);
|
CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam * paramTypes);
|
||||||
CForward()
|
CForward() {} // leaves everything unitialized'
|
||||||
{ } // leaves everything unitialized'
|
|
||||||
cell execute(cell *params, ForwardPreparedArray *preparedArrays);
|
cell execute(cell *params, ForwardPreparedArray *preparedArrays);
|
||||||
|
|
||||||
int getParamsNum() const
|
int getParamsNum() const
|
||||||
{
|
{
|
||||||
return m_NumParams;
|
return m_NumParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getFuncsNum() const
|
int getFuncsNum() const
|
||||||
{
|
{
|
||||||
return m_Funcs.size();
|
return m_Funcs.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
ForwardParam getParamType(int paramId) const
|
ForwardParam getParamType(int paramId) const
|
||||||
{
|
{
|
||||||
if (paramId < 0 || paramId >= m_NumParams)
|
if (paramId < 0 || paramId >= m_NumParams)
|
||||||
return FP_DONE;
|
return FP_DONE;
|
||||||
|
|
||||||
return m_ParamTypes[paramId];
|
return m_ParamTypes[paramId];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -122,10 +132,13 @@ class CSPForward
|
|||||||
{
|
{
|
||||||
const char *m_FuncName;
|
const char *m_FuncName;
|
||||||
int m_NumParams;
|
int m_NumParams;
|
||||||
|
|
||||||
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
||||||
AMX *m_Amx;
|
AMX *m_Amx;
|
||||||
|
|
||||||
int m_Func;
|
int m_Func;
|
||||||
bool m_HasFunc;
|
bool m_HasFunc;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isFree;
|
bool isFree;
|
||||||
public:
|
public:
|
||||||
@ -134,18 +147,22 @@ public:
|
|||||||
void Set(int func, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
void Set(int func, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
||||||
|
|
||||||
cell execute(cell *params, ForwardPreparedArray *preparedArrays);
|
cell execute(cell *params, ForwardPreparedArray *preparedArrays);
|
||||||
|
|
||||||
int getParamsNum() const
|
int getParamsNum() const
|
||||||
{
|
{
|
||||||
return m_NumParams;
|
return m_NumParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getFuncsNum() const
|
int getFuncsNum() const
|
||||||
{
|
{
|
||||||
return (m_HasFunc) ? 1 : 0;
|
return (m_HasFunc) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ForwardParam getParamType(int paramId) const
|
ForwardParam getParamType(int paramId) const
|
||||||
{
|
{
|
||||||
if (paramId < 0 || paramId >= m_NumParams)
|
if (paramId < 0 || paramId >= m_NumParams)
|
||||||
return FP_DONE;
|
return FP_DONE;
|
||||||
|
|
||||||
return m_ParamTypes[paramId];
|
return m_ParamTypes[paramId];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -167,8 +184,7 @@ public:
|
|||||||
|
|
||||||
CForwardMngr()
|
CForwardMngr()
|
||||||
{ m_TmpArraysNum = 0; }
|
{ m_TmpArraysNum = 0; }
|
||||||
~CForwardMngr()
|
~CForwardMngr() {}
|
||||||
{ }
|
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
// Register normal forward
|
// Register normal forward
|
||||||
@ -176,18 +192,21 @@ public:
|
|||||||
// Register single plugin forward
|
// Register single plugin forward
|
||||||
int registerSPForward(const char *funcName, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
int registerSPForward(const char *funcName, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
||||||
int registerSPForward(int func, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
int registerSPForward(int func, AMX *amx, int numParams, const ForwardParam * paramTypes);
|
||||||
|
|
||||||
// Unregister single plugin forward
|
// Unregister single plugin forward
|
||||||
void unregisterSPForward(int id);
|
void unregisterSPForward(int id);
|
||||||
|
|
||||||
// execute forward
|
// execute forward
|
||||||
cell executeForwards(int id, cell *params);
|
cell executeForwards(int id, cell *params);
|
||||||
void clear(); // delete all forwards
|
void clear(); // delete all forwards
|
||||||
|
|
||||||
bool isIdValid(int id) const; // check whether forward id is valid
|
bool isIdValid(int id) const; // check whether forward id is valid
|
||||||
bool isSPForward(int id) const; // check whether forward is single plugin
|
bool isSPForward(int id) const; // check whether forward is single plugin
|
||||||
int getParamsNum(int id) const; // get num of params of a forward
|
int getParamsNum(int id) const; // get num of params of a forward
|
||||||
int getFuncsNum(int id) const; // get num of found functions of a forward
|
int getFuncsNum(int id) const; // get num of found functions of a forward
|
||||||
|
|
||||||
ForwardParam getParamType(int id, int paramId) const;
|
ForwardParam getParamType(int id, int paramId) const;
|
||||||
cell prepareArray(void *ptr, unsigned int size, ForwardArrayElemType type,
|
cell prepareArray(void *ptr, unsigned int size, ForwardArrayElemType type, bool copyBack); // prepare array
|
||||||
bool copyBack); // prepare array
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// (un)register forward
|
// (un)register forward
|
||||||
@ -202,5 +221,4 @@ cell executeForwards(int id, ...);
|
|||||||
cell prepareCellArray(cell *ptr, unsigned int size, bool copyBack = false);
|
cell prepareCellArray(cell *ptr, unsigned int size, bool copyBack = false);
|
||||||
cell prepareCharArray(char *ptr, unsigned int size, bool copyBack = false);
|
cell prepareCharArray(char *ptr, unsigned int size, bool copyBack = false);
|
||||||
|
|
||||||
#endif
|
#endif //FORWARD_H
|
||||||
|
|
||||||
|
@ -184,6 +184,7 @@ size_t CLangMngr::strip(char *str, char *newstr, bool makelower)
|
|||||||
}
|
}
|
||||||
|
|
||||||
newstr[pos] = 0;
|
newstr[pos] = 0;
|
||||||
|
|
||||||
return ptr - str + 1;
|
return ptr - str + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,6 +306,7 @@ void CLangMngr::CLang::Clear()
|
|||||||
if (m_LookUpTable[i])
|
if (m_LookUpTable[i])
|
||||||
delete m_LookUpTable[i];
|
delete m_LookUpTable[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LookUpTable.clear();
|
m_LookUpTable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,11 +334,13 @@ void CLangMngr::CLang::MergeDefinitions(CQueue<sKeyDef*> &vec)
|
|||||||
{
|
{
|
||||||
const char *def = 0;
|
const char *def = 0;
|
||||||
int key = -1;
|
int key = -1;
|
||||||
|
|
||||||
while (!vec.empty())
|
while (!vec.empty())
|
||||||
{
|
{
|
||||||
key = vec.front()->key;
|
key = vec.front()->key;
|
||||||
def = vec.front()->def->c_str();
|
def = vec.front()->def->c_str();
|
||||||
LangEntry *entry = GetEntry(key);
|
LangEntry *entry = GetEntry(key);
|
||||||
|
|
||||||
if (entry->GetDefHash() != MakeHash(def))
|
if (entry->GetDefHash() != MakeHash(def))
|
||||||
{
|
{
|
||||||
if (entry->GetCache())
|
if (entry->GetCache())
|
||||||
@ -348,6 +352,7 @@ void CLangMngr::CLang::MergeDefinitions(CQueue<sKeyDef*> &vec)
|
|||||||
//AMXXLOG_Log("[AMXX] Language key %s[%s] defined twice", m_LMan->GetKey(key), m_LanguageName);
|
//AMXXLOG_Log("[AMXX] Language key %s[%s] defined twice", m_LMan->GetKey(key), m_LanguageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete vec.front();
|
delete vec.front();
|
||||||
vec.pop();
|
vec.pop();
|
||||||
}
|
}
|
||||||
@ -357,20 +362,22 @@ const char * CLangMngr::CLang::GetDef(const char *key)
|
|||||||
{
|
{
|
||||||
static char nfind[1024] = "ML_NOTFOUND(KEY)";
|
static char nfind[1024] = "ML_NOTFOUND(KEY)";
|
||||||
int ikey = m_LMan->GetKeyEntry(key);
|
int ikey = m_LMan->GetKeyEntry(key);
|
||||||
|
|
||||||
if (ikey == -1)
|
if (ikey == -1)
|
||||||
{
|
{
|
||||||
sprintf(nfind, "ML_NOTFOUND: %s", key);
|
sprintf(nfind, "ML_NOTFOUND: %s", key);
|
||||||
return nfind;
|
return nfind;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_LookUpTable.size(); i++)
|
for (unsigned int i = 0; i < m_LookUpTable.size(); i++)
|
||||||
{
|
{
|
||||||
if (m_LookUpTable[i]->GetKey() == ikey)
|
if (m_LookUpTable[i]->GetKey() == ikey)
|
||||||
return m_LookUpTable[i]->GetDef();
|
return m_LookUpTable[i]->GetDef();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct OffsetPair
|
struct OffsetPair
|
||||||
{
|
{
|
||||||
uint32_t defOffset;
|
uint32_t defOffset;
|
||||||
@ -381,6 +388,7 @@ struct OffsetPair
|
|||||||
bool CLangMngr::CLang::SaveDefinitions(FILE *fp, uint32_t &curOffset)
|
bool CLangMngr::CLang::SaveDefinitions(FILE *fp, uint32_t &curOffset)
|
||||||
{
|
{
|
||||||
unsigned short defLen = 0;
|
unsigned short defLen = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_LookUpTable.size(); i++)
|
for (unsigned int i = 0; i < m_LookUpTable.size(); i++)
|
||||||
{
|
{
|
||||||
defLen = m_LookUpTable[i]->GetDefLength();
|
defLen = m_LookUpTable[i]->GetDefLength();
|
||||||
@ -423,7 +431,6 @@ bool CLangMngr::CLang::Save(FILE *fp, int &defOffset, uint32_t &curOffset)
|
|||||||
// assumes fp is set to the right position
|
// assumes fp is set to the right position
|
||||||
bool CLangMngr::CLang::Load(FILE *fp)
|
bool CLangMngr::CLang::Load(FILE *fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,6 +471,7 @@ int CLangMngr::GetKeyEntry(const char *key)
|
|||||||
for (i = 0; i < KeyList.size(); i++)
|
for (i = 0; i < KeyList.size(); i++)
|
||||||
{
|
{
|
||||||
cmpKey = KeyList[i]->hash;
|
cmpKey = KeyList[i]->hash;
|
||||||
|
|
||||||
if (hKey == cmpKey)
|
if (hKey == cmpKey)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
@ -521,6 +529,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
{
|
{
|
||||||
// number of parameters ( for NEXT_PARAM macro )
|
// number of parameters ( for NEXT_PARAM macro )
|
||||||
int paramCount = *params / sizeof(cell);
|
int paramCount = *params / sizeof(cell);
|
||||||
|
|
||||||
// the output buffer
|
// the output buffer
|
||||||
static char outbuf[4096];
|
static char outbuf[4096];
|
||||||
char *outptr = outbuf;
|
char *outptr = outbuf;
|
||||||
@ -538,6 +547,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
cell *pAmxLangName = get_amxaddr(amx, params[parm++]); // other cases
|
cell *pAmxLangName = get_amxaddr(amx, params[parm++]); // other cases
|
||||||
const char *cpLangName=NULL;
|
const char *cpLangName=NULL;
|
||||||
// Handle player ids (1-32) and server language
|
// Handle player ids (1-32) and server language
|
||||||
|
|
||||||
if (*pAmxLangName == LANG_PLAYER) // LANG_PLAYER
|
if (*pAmxLangName == LANG_PLAYER) // LANG_PLAYER
|
||||||
{
|
{
|
||||||
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
|
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
|
||||||
@ -546,9 +556,13 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
} else {
|
} else {
|
||||||
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang");
|
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang");
|
||||||
}
|
}
|
||||||
} else if (*pAmxLangName == LANG_SERVER) { // LANG_SERVER
|
}
|
||||||
|
else if (*pAmxLangName == LANG_SERVER) // LANG_SERVER
|
||||||
|
{
|
||||||
cpLangName = g_vault.get("server_language");
|
cpLangName = g_vault.get("server_language");
|
||||||
} else if (*pAmxLangName >= 1 && *pAmxLangName <= 32) { // Direct Client Id
|
}
|
||||||
|
else if (*pAmxLangName >= 1 && *pAmxLangName <= 32) // Direct Client Id
|
||||||
|
{
|
||||||
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
|
if ((int)CVAR_GET_FLOAT("amx_client_languages") == 0)
|
||||||
{
|
{
|
||||||
cpLangName = g_vault.get("server_language");
|
cpLangName = g_vault.get("server_language");
|
||||||
@ -559,12 +573,15 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
int tmplen = 0;
|
int tmplen = 0;
|
||||||
cpLangName = get_amxstring(amx, langName, 2, tmplen);
|
cpLangName = get_amxstring(amx, langName, 2, tmplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cpLangName || strlen(cpLangName) < 1)
|
if (!cpLangName || strlen(cpLangName) < 1)
|
||||||
cpLangName = "en";
|
cpLangName = "en";
|
||||||
|
|
||||||
int tmplen = 0;
|
int tmplen = 0;
|
||||||
NEXT_PARAM();
|
NEXT_PARAM();
|
||||||
char *key = get_amxstring(amx, params[parm++], 1, tmplen);
|
char *key = get_amxstring(amx, params[parm++], 1, tmplen);
|
||||||
const char *def = GetDef(cpLangName, key);
|
const char *def = GetDef(cpLangName, key);
|
||||||
|
|
||||||
if (def == NULL)
|
if (def == NULL)
|
||||||
{
|
{
|
||||||
if (*pAmxLangName != LANG_SERVER)
|
if (*pAmxLangName != LANG_SERVER)
|
||||||
@ -583,6 +600,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
def = buf;
|
def = buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*def)
|
while (*def)
|
||||||
{
|
{
|
||||||
if (*def == '%')
|
if (*def == '%')
|
||||||
@ -592,9 +610,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
{
|
{
|
||||||
*outptr++ = '%';
|
*outptr++ = '%';
|
||||||
++def;
|
++def;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
static char format[32];
|
static char format[32];
|
||||||
format[0] = '%';
|
format[0] = '%';
|
||||||
char *ptr = format + 1;
|
char *ptr = format + 1;
|
||||||
@ -604,6 +620,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
ZEROTERM(format);
|
ZEROTERM(format);
|
||||||
|
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
|
||||||
switch (*(ptr - 1))
|
switch (*(ptr - 1))
|
||||||
{
|
{
|
||||||
case 's':
|
case 's':
|
||||||
@ -613,8 +630,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
NEXT_PARAM();
|
NEXT_PARAM();
|
||||||
cell *tmpCell = get_amxaddr(amx, params[parm++]);
|
cell *tmpCell = get_amxaddr(amx, params[parm++]);
|
||||||
while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell)
|
while (tmpPtr-tmpString < sizeof(tmpString) && *tmpCell)
|
||||||
*tmpPtr++ = *tmpCell++;
|
*tmpPtr++ = static_cast<char>(*tmpCell++);
|
||||||
|
|
||||||
*tmpPtr = 0;
|
*tmpPtr = 0;
|
||||||
_snprintf(outptr, sizeof(outbuf)-(outptr-outbuf)-1, format, tmpString);
|
_snprintf(outptr, sizeof(outbuf)-(outptr-outbuf)-1, format, tmpString);
|
||||||
ZEROTERM(outbuf);
|
ZEROTERM(outbuf);
|
||||||
@ -644,12 +660,14 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outptr += strlen(outptr);
|
outptr += strlen(outptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*def == '^')
|
else if (*def == '^')
|
||||||
{
|
{
|
||||||
++def;
|
++def;
|
||||||
|
|
||||||
switch (*def)
|
switch (*def)
|
||||||
{
|
{
|
||||||
case 'n':
|
case 'n':
|
||||||
@ -670,29 +688,28 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
*outptr++ = *def;
|
*outptr++ = *def;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
++def;
|
++def;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
CHECK_OUTPTR(1);
|
CHECK_OUTPTR(1);
|
||||||
*outptr++ = *def++;
|
*outptr++ = *def++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
static char tmpString[4096];
|
static char tmpString[4096];
|
||||||
char *tmpPtr = tmpString;
|
char *tmpPtr = tmpString;
|
||||||
int tmpLen = 0;
|
int tmpLen = 0;
|
||||||
static char format[32] = {'%'};
|
static char format[32] = {'%'};
|
||||||
char *ptr = format + 1;
|
char *ptr = format + 1;
|
||||||
|
|
||||||
if (*src != '%')
|
if (*src != '%')
|
||||||
{
|
{
|
||||||
while (*src != 0 && ptr-format<sizeof(format) && !isalpha(*ptr++ = *src++))
|
while (*src != 0 && ptr-format<sizeof(format) && !isalpha(*ptr++ = static_cast<char>(*src++)))
|
||||||
/*nothing*/;
|
/*nothing*/;
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
ZEROTERM(format);
|
ZEROTERM(format);
|
||||||
--src;
|
--src;
|
||||||
|
|
||||||
switch (*(ptr - 1))
|
switch (*(ptr - 1))
|
||||||
{
|
{
|
||||||
case 's':
|
case 's':
|
||||||
@ -700,7 +717,7 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
NEXT_PARAM();
|
NEXT_PARAM();
|
||||||
cell *tmpCell = get_amxaddr(amx, params[parm++]);
|
cell *tmpCell = get_amxaddr(amx, params[parm++]);
|
||||||
while (tmpPtr-tmpString<sizeof(tmpString) && *tmpCell)
|
while (tmpPtr-tmpString<sizeof(tmpString) && *tmpCell)
|
||||||
*tmpPtr++ = *tmpCell++;
|
*tmpPtr++ = static_cast<char>(*tmpCell++);
|
||||||
*tmpPtr = 0;
|
*tmpPtr = 0;
|
||||||
_snprintf(outptr, sizeof(outbuf)-(outptr-outbuf)-1, format, tmpString);
|
_snprintf(outptr, sizeof(outbuf)-(outptr-outbuf)-1, format, tmpString);
|
||||||
ZEROTERM(outbuf);
|
ZEROTERM(outbuf);
|
||||||
@ -728,23 +745,24 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outptr += strlen(outptr);
|
outptr += strlen(outptr);
|
||||||
} else {
|
} else {
|
||||||
CHECK_OUTPTR(1);
|
CHECK_OUTPTR(1);
|
||||||
*outptr++ = '%';
|
*outptr++ = '%';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
CHECK_OUTPTR(1);
|
CHECK_OUTPTR(1);
|
||||||
*outptr++ = *src;
|
*outptr++ = static_cast<char>(*src);
|
||||||
}
|
}
|
||||||
++src;
|
++src;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = outptr - outbuf;
|
len = outptr - outbuf;
|
||||||
CHECK_OUTPTR(1);
|
CHECK_OUTPTR(1);
|
||||||
*outptr++ = 0;
|
*outptr++ = 0;
|
||||||
|
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,6 +772,7 @@ const char *CLangMngr::Format(const char *fmt, ...)
|
|||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
const char *retVal = FormatString(fmt, ap);
|
const char *retVal = FormatString(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,6 +807,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||||||
const char *pAmxLangName = va_arg(ap, const char*);
|
const char *pAmxLangName = va_arg(ap, const char*);
|
||||||
const char *cpLangName=NULL;
|
const char *cpLangName=NULL;
|
||||||
// Handle player ids (1-32) and server language
|
// Handle player ids (1-32) and server language
|
||||||
|
|
||||||
if (pAmxLangName == (const char *)LANG_PLAYER) // LANG_PLAYER
|
if (pAmxLangName == (const char *)LANG_PLAYER) // LANG_PLAYER
|
||||||
{
|
{
|
||||||
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
|
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
|
||||||
@ -796,9 +816,13 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||||||
} else {
|
} else {
|
||||||
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang");
|
cpLangName = ENTITY_KEYVALUE(GET_PLAYER_POINTER_I(m_CurGlobId)->pEdict, "lang");
|
||||||
}
|
}
|
||||||
} else if (pAmxLangName == (const char *)LANG_SERVER) { // LANG_SERVER
|
}
|
||||||
|
else if (pAmxLangName == (const char *)LANG_SERVER) // LANG_SERVER
|
||||||
|
{
|
||||||
cpLangName = g_vault.get("server_language");
|
cpLangName = g_vault.get("server_language");
|
||||||
} else if (pAmxLangName >= (const char *)1 && pAmxLangName <= (const char *)32) { // Direct Client Id
|
}
|
||||||
|
else if (pAmxLangName >= (const char *)1 && pAmxLangName <= (const char *)32) // Direct Client Id
|
||||||
|
{
|
||||||
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
|
if ((int)CVAR_GET_FLOAT("amx_client_languages"))
|
||||||
{
|
{
|
||||||
cpLangName = g_vault.get("server_language");
|
cpLangName = g_vault.get("server_language");
|
||||||
@ -809,11 +833,14 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||||||
int tmplen = 0;
|
int tmplen = 0;
|
||||||
cpLangName = pAmxLangName;
|
cpLangName = pAmxLangName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cpLangName || strlen(cpLangName) < 1)
|
if (!cpLangName || strlen(cpLangName) < 1)
|
||||||
cpLangName = "en";
|
cpLangName = "en";
|
||||||
|
|
||||||
int tmplen = 0;
|
int tmplen = 0;
|
||||||
const char *key = va_arg(ap, const char *);
|
const char *key = va_arg(ap, const char *);
|
||||||
const char *def = GetDef(cpLangName, key);
|
const char *def = GetDef(cpLangName, key);
|
||||||
|
|
||||||
if (def == NULL)
|
if (def == NULL)
|
||||||
{
|
{
|
||||||
if (pAmxLangName != LANG_SERVER)
|
if (pAmxLangName != LANG_SERVER)
|
||||||
@ -832,6 +859,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||||||
def = buf;
|
def = buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*def)
|
while (*def)
|
||||||
{
|
{
|
||||||
if (*def == '%')
|
if (*def == '%')
|
||||||
@ -847,6 +875,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
vsprintf(outptr, format, ap);
|
vsprintf(outptr, format, ap);
|
||||||
// vsprintf doesnt alter the ap, increment here
|
// vsprintf doesnt alter the ap, increment here
|
||||||
|
|
||||||
switch (*(ptr - 1))
|
switch (*(ptr - 1))
|
||||||
{
|
{
|
||||||
case 'f':
|
case 'f':
|
||||||
@ -862,11 +891,13 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||||||
va_arg(ap, int);
|
va_arg(ap, int);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
outptr += strlen(outptr);
|
outptr += strlen(outptr);
|
||||||
}
|
}
|
||||||
else if (*def == '^')
|
else if (*def == '^')
|
||||||
{
|
{
|
||||||
++def;
|
++def;
|
||||||
|
|
||||||
switch (*def)
|
switch (*def)
|
||||||
{
|
{
|
||||||
case 'n':
|
case 'n':
|
||||||
@ -887,19 +918,17 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||||||
*outptr++ = *def;
|
*outptr++ = *def;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
++def;
|
++def;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
CHECK_OUTPTR(1);
|
CHECK_OUTPTR(1);
|
||||||
*outptr++ = *def++;
|
*outptr++ = *def++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
static char format[32] = {'%'};
|
static char format[32] = {'%'};
|
||||||
char *ptr = format + 1;
|
char *ptr = format + 1;
|
||||||
|
|
||||||
if (*src != '%')
|
if (*src != '%')
|
||||||
{
|
{
|
||||||
while (*src != 0 && ptr-format < sizeof(format) && !isalpha(*ptr++ = *src++))
|
while (*src != 0 && ptr-format < sizeof(format) && !isalpha(*ptr++ = *src++))
|
||||||
@ -909,6 +938,7 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||||||
--src;
|
--src;
|
||||||
vsprintf(outptr, format, ap);
|
vsprintf(outptr, format, ap);
|
||||||
// vsprintf doesnt alter the ap, increment here
|
// vsprintf doesnt alter the ap, increment here
|
||||||
|
|
||||||
switch (*(ptr - 1))
|
switch (*(ptr - 1))
|
||||||
{
|
{
|
||||||
case 'f':
|
case 'f':
|
||||||
@ -924,24 +954,26 @@ char *CLangMngr::FormatString(const char *fmt, va_list &ap)
|
|||||||
va_arg(ap, int);
|
va_arg(ap, int);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
outptr += strlen(outptr);
|
outptr += strlen(outptr);
|
||||||
} else {
|
} else {
|
||||||
CHECK_OUTPTR(1);
|
CHECK_OUTPTR(1);
|
||||||
*outptr++ = '%';
|
*outptr++ = '%';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
CHECK_OUTPTR(1);
|
CHECK_OUTPTR(1);
|
||||||
*outptr++ = *src;
|
*outptr++ = *src;
|
||||||
}
|
}
|
||||||
++src;
|
++src;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_OUTPTR(1);
|
CHECK_OUTPTR(1);
|
||||||
*outptr++ = 0;
|
*outptr++ = 0;
|
||||||
|
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLangMngr::MergeDefinitions(const char *lang, CQueue<sKeyDef*> &tmpVec)
|
void CLangMngr::MergeDefinitions(const char *lang, CQueue<sKeyDef*> &tmpVec)
|
||||||
{
|
{
|
||||||
CLang * language = GetLang(lang);
|
CLang * language = GetLang(lang);
|
||||||
@ -969,6 +1001,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
|
|||||||
AMXXLOG_Log("[AMXX] Failed to open dictionary file: %s", file);
|
AMXXLOG_Log("[AMXX] Failed to open dictionary file: %s", file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MD5 md5;
|
MD5 md5;
|
||||||
md5.update(fp); // closes for us
|
md5.update(fp); // closes for us
|
||||||
md5.finalize();
|
md5.finalize();
|
||||||
@ -1022,6 +1055,9 @@ int CLangMngr::MergeDefinitionFile(const char *file)
|
|||||||
buf.trim();
|
buf.trim();
|
||||||
if (buf[0] == 0)
|
if (buf[0] == 0)
|
||||||
continue;
|
continue;
|
||||||
|
if ((buf[0] == ';') || (buf[0] == '/' && buf[1] == '/'))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (buf[0] == '[' && buf.size() >= 3)
|
if (buf[0] == '[' && buf.size() >= 3)
|
||||||
{
|
{
|
||||||
if (multiline)
|
if (multiline)
|
||||||
@ -1031,10 +1067,12 @@ int CLangMngr::MergeDefinitionFile(const char *file)
|
|||||||
delete tmpEntry;
|
delete tmpEntry;
|
||||||
tmpEntry = 0;
|
tmpEntry = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Defq.empty())
|
if (!Defq.empty())
|
||||||
{
|
{
|
||||||
MergeDefinitions(language, Defq);
|
MergeDefinitions(language, Defq);
|
||||||
}
|
}
|
||||||
|
|
||||||
language[0] = buf[1];
|
language[0] = buf[1];
|
||||||
language[1] = buf[2];
|
language[1] = buf[2];
|
||||||
language[2] = 0;
|
language[2] = 0;
|
||||||
@ -1042,6 +1080,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
|
|||||||
if (!multiline)
|
if (!multiline)
|
||||||
{
|
{
|
||||||
pos = buf.find('=');
|
pos = buf.find('=');
|
||||||
|
|
||||||
if (pos > String::npos)
|
if (pos > String::npos)
|
||||||
{
|
{
|
||||||
tmpEntry = new sKeyDef;
|
tmpEntry = new sKeyDef;
|
||||||
@ -1062,6 +1101,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
|
|||||||
tmpEntry = 0;
|
tmpEntry = 0;
|
||||||
} else {
|
} else {
|
||||||
pos = buf.find(':');
|
pos = buf.find(':');
|
||||||
|
|
||||||
if (pos > String::npos)
|
if (pos > String::npos)
|
||||||
{
|
{
|
||||||
tmpEntry = new sKeyDef;
|
tmpEntry = new sKeyDef;
|
||||||
@ -1092,6 +1132,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
|
|||||||
} // if !multiline
|
} // if !multiline
|
||||||
} //if - main
|
} //if - main
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge last section
|
// merge last section
|
||||||
if (!Defq.empty())
|
if (!Defq.empty())
|
||||||
{
|
{
|
||||||
@ -1136,6 +1177,7 @@ const char *CLangMngr::GetDef(const char *langName, const char *key)
|
|||||||
CLang *lang = GetLangR(langName);
|
CLang *lang = GetLangR(langName);
|
||||||
if (lang)
|
if (lang)
|
||||||
return lang->GetDef(key);
|
return lang->GetDef(key);
|
||||||
|
|
||||||
return "ML_NOTFOUND(LANG)";
|
return "ML_NOTFOUND(LANG)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1264,7 +1306,6 @@ bool CLangMngr::LoadCache(const char *filename)
|
|||||||
fread((void*)&dictCount, sizeof(short), 1, fp);
|
fread((void*)&dictCount, sizeof(short), 1, fp);
|
||||||
md5Pair *p = 0;
|
md5Pair *p = 0;
|
||||||
|
|
||||||
|
|
||||||
for (int i = 1; i <= dictCount; i++)
|
for (int i = 1; i <= dictCount; i++)
|
||||||
{
|
{
|
||||||
fread((void*)&len, sizeof(char), 1, fp);
|
fread((void*)&len, sizeof(char), 1, fp);
|
||||||
@ -1311,6 +1352,7 @@ bool CLangMngr::Load(const char *filename)
|
|||||||
|
|
||||||
uint32_t *LangOffsets = new uint32_t[langCount];
|
uint32_t *LangOffsets = new uint32_t[langCount];
|
||||||
char langname[3];
|
char langname[3];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < langCount; i++)
|
for (unsigned int i = 0; i < langCount; i++)
|
||||||
{
|
{
|
||||||
fread(langname, sizeof(char), 2, fp);
|
fread(langname, sizeof(char), 2, fp);
|
||||||
@ -1324,6 +1366,7 @@ bool CLangMngr::Load(const char *filename)
|
|||||||
keyEntry *e = 0;
|
keyEntry *e = 0;
|
||||||
unsigned char keylen;
|
unsigned char keylen;
|
||||||
uint32_t keyoffset, save;
|
uint32_t keyoffset, save;
|
||||||
|
|
||||||
for (unsigned i = 0; i < keycount; i++)
|
for (unsigned i = 0; i < keycount; i++)
|
||||||
{
|
{
|
||||||
e = new keyEntry;
|
e = new keyEntry;
|
||||||
@ -1347,9 +1390,11 @@ bool CLangMngr::Load(const char *filename)
|
|||||||
uint32_t defhash;
|
uint32_t defhash;
|
||||||
uint32_t defoffset;
|
uint32_t defoffset;
|
||||||
unsigned short deflen;
|
unsigned short deflen;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < langCount; i++)
|
for (unsigned int i = 0; i < langCount; i++)
|
||||||
{
|
{
|
||||||
fread((void*)&numentries, sizeof(uint32_t), 1, fp);
|
fread((void*)&numentries, sizeof(uint32_t), 1, fp);
|
||||||
|
|
||||||
for (unsigned int j = 0; j < numentries; j++)
|
for (unsigned int j = 0; j < numentries; j++)
|
||||||
{
|
{
|
||||||
fread((void *)&keynum, sizeof(uint32_t), 1, fp);
|
fread((void *)&keynum, sizeof(uint32_t), 1, fp);
|
||||||
@ -1383,6 +1428,7 @@ CLangMngr::~CLangMngr()
|
|||||||
void CLangMngr::Clear()
|
void CLangMngr::Clear()
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
|
|
||||||
for (i = 0; i < m_Languages.size(); i++)
|
for (i = 0; i < m_Languages.size(); i++)
|
||||||
{
|
{
|
||||||
if (m_Languages[i])
|
if (m_Languages[i])
|
||||||
@ -1415,6 +1461,7 @@ const char *CLangMngr::GetLangName(int langId)
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
LangVecIter iter;
|
LangVecIter iter;
|
||||||
|
|
||||||
for (iter = m_Languages.begin(); iter != m_Languages.end(); ++iter)
|
for (iter = m_Languages.begin(); iter != m_Languages.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (i == langId)
|
if (i == langId)
|
||||||
@ -1423,6 +1470,7 @@ const char *CLangMngr::GetLangName(int langId)
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1430,6 +1478,7 @@ bool CLangMngr::LangExists(const char *langName)
|
|||||||
{
|
{
|
||||||
char buf[3] = {0};
|
char buf[3] = {0};
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (buf[i] = tolower(*langName++))
|
while (buf[i] = tolower(*langName++))
|
||||||
{
|
{
|
||||||
if (++i == 2)
|
if (++i == 2)
|
||||||
@ -1437,11 +1486,13 @@ bool CLangMngr::LangExists(const char *langName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LangVecIter iter;
|
LangVecIter iter;
|
||||||
|
|
||||||
for (iter = m_Languages.begin(); iter != m_Languages.end(); ++iter)
|
for (iter = m_Languages.begin(); iter != m_Languages.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (strcmp((*iter)->GetName(), buf) == 0)
|
if (strcmp((*iter)->GetName(), buf) == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ struct sKeyDef
|
|||||||
{
|
{
|
||||||
sKeyDef() { key = -1; def = 0; }
|
sKeyDef() { key = -1; def = 0; }
|
||||||
~sKeyDef() { if (def) delete def; }
|
~sKeyDef() { if (def) delete def; }
|
||||||
|
|
||||||
int key;
|
int key;
|
||||||
String *def;
|
String *def;
|
||||||
};
|
};
|
||||||
@ -79,6 +80,7 @@ class CLangMngr
|
|||||||
{
|
{
|
||||||
return strcmp(left.m_LanguageName, right) == 0 ? true : false;
|
return strcmp(left.m_LanguageName, right) == 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get language name
|
// Get language name
|
||||||
const char *GetName() { return m_LanguageName; }
|
const char *GetName() { return m_LanguageName; }
|
||||||
// Save to file
|
// Save to file
|
||||||
@ -91,8 +93,8 @@ class CLangMngr
|
|||||||
int Entries() { return m_LookUpTable.size(); }
|
int Entries() { return m_LookUpTable.size(); }
|
||||||
// Make a hash from a string; convert to lowercase first if needed
|
// Make a hash from a string; convert to lowercase first if needed
|
||||||
static uint32_t MakeHash(const char *src, bool makeLower = false);
|
static uint32_t MakeHash(const char *src, bool makeLower = false);
|
||||||
protected:
|
|
||||||
|
|
||||||
|
protected:
|
||||||
// An entry in the language
|
// An entry in the language
|
||||||
class LangEntry
|
class LangEntry
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class CList
|
// class CList
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
// Linked list
|
// Linked list
|
||||||
template <typename T, typename F = char* >
|
template <typename T, typename F = char* >
|
||||||
class CList
|
class CList
|
||||||
@ -65,8 +66,10 @@ private:
|
|||||||
~CElement()
|
~CElement()
|
||||||
{
|
{
|
||||||
delete m_pObject;
|
delete m_pObject;
|
||||||
|
|
||||||
if (m_pNext)
|
if (m_pNext)
|
||||||
m_pNext->m_pPrev = m_pPrev;
|
m_pNext->m_pPrev = m_pPrev;
|
||||||
|
|
||||||
if (m_pPrev)
|
if (m_pPrev)
|
||||||
m_pPrev->m_pNext = m_pNext;
|
m_pPrev->m_pNext = m_pNext;
|
||||||
}
|
}
|
||||||
@ -110,6 +113,7 @@ public:
|
|||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
friend class CList<T, F>;
|
friend class CList<T, F>;
|
||||||
|
|
||||||
CList<T, F> *m_pList; // The list that created this iterator
|
CList<T, F> *m_pList; // The list that created this iterator
|
||||||
CElement *m_CurPos; // Current position in the list
|
CElement *m_CurPos; // Current position in the list
|
||||||
public:
|
public:
|
||||||
@ -162,6 +166,7 @@ public:
|
|||||||
{
|
{
|
||||||
iterator tmp(*this);
|
iterator tmp(*this);
|
||||||
m_CurPos = m_CurPos->next;
|
m_CurPos = m_CurPos->next;
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,6 +181,7 @@ public:
|
|||||||
{
|
{
|
||||||
return m_pList->remove(*this);
|
return m_pList->remove(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator put(T *obj)
|
iterator put(T *obj)
|
||||||
{
|
{
|
||||||
return m_pList->put(obj, *this);
|
return m_pList->put(obj, *this);
|
||||||
@ -187,6 +193,7 @@ public:
|
|||||||
m_pHead = NULL;
|
m_pHead = NULL;
|
||||||
m_pTail = NULL;
|
m_pTail = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
~CList<T, F>()
|
~CList<T, F>()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
@ -198,12 +205,16 @@ public:
|
|||||||
iterator remove(iterator &where)
|
iterator remove(iterator &where)
|
||||||
{
|
{
|
||||||
iterator tmp(where.GetNext());
|
iterator tmp(where.GetNext());
|
||||||
|
|
||||||
if (where.m_CurPos == m_pHead)
|
if (where.m_CurPos == m_pHead)
|
||||||
m_pHead = where.m_CurPos->GetNext();
|
m_pHead = where.m_CurPos->GetNext();
|
||||||
|
|
||||||
if (where.m_CurPos == m_pTail)
|
if (where.m_CurPos == m_pTail)
|
||||||
m_pTail = where.m_CurPos->GetPrev();
|
m_pTail = where.m_CurPos->GetPrev();
|
||||||
|
|
||||||
delete where.m_CurPos;
|
delete where.m_CurPos;
|
||||||
where = tmp;
|
where = tmp;
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,36 +223,36 @@ public:
|
|||||||
iterator put_back(T *pObj)
|
iterator put_back(T *pObj)
|
||||||
{
|
{
|
||||||
CElement *pTmp = new CElement(pObj);
|
CElement *pTmp = new CElement(pObj);
|
||||||
|
|
||||||
if (!m_pHead)
|
if (!m_pHead)
|
||||||
{
|
{
|
||||||
m_pHead = pTmp;
|
m_pHead = pTmp;
|
||||||
m_pTail = pTmp;
|
m_pTail = pTmp;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pTmp->SetNext(NULL);
|
pTmp->SetNext(NULL);
|
||||||
pTmp->SetPrev(m_pTail);
|
pTmp->SetPrev(m_pTail);
|
||||||
m_pTail->SetNext(pTmp);
|
m_pTail->SetNext(pTmp);
|
||||||
m_pTail = pTmp;
|
m_pTail = pTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iterator(this, pTmp);
|
return iterator(this, pTmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator put_front(T *pObj)
|
iterator put_front(T *pObj)
|
||||||
{
|
{
|
||||||
CElement *pTmp = new CElement(pObj);
|
CElement *pTmp = new CElement(pObj);
|
||||||
|
|
||||||
if (!m_pHead)
|
if (!m_pHead)
|
||||||
{
|
{
|
||||||
m_pHead = pTmp;
|
m_pHead = pTmp;
|
||||||
m_pTail = pTmp;
|
m_pTail = pTmp;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pTmp->SetNext(m_pHead);
|
pTmp->SetNext(m_pHead);
|
||||||
pTmp->SetPrev(NULL);
|
pTmp->SetPrev(NULL);
|
||||||
m_pHead->SetPrev(pTmp);
|
m_pHead->SetPrev(pTmp);
|
||||||
m_pHead = pTmp;
|
m_pHead = pTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iterator(this, pTmp);
|
return iterator(this, pTmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,6 +268,7 @@ public:
|
|||||||
iterator put(T *pObj, iterator &where)
|
iterator put(T *pObj, iterator &where)
|
||||||
{
|
{
|
||||||
CElement *pTmp = new CElement(pObj);
|
CElement *pTmp = new CElement(pObj);
|
||||||
|
|
||||||
if (where.m_CurPos->GetNext())
|
if (where.m_CurPos->GetNext())
|
||||||
where.m_CurPos->GetNext()->SetPrev(pTmp);
|
where.m_CurPos->GetNext()->SetPrev(pTmp);
|
||||||
else // where = tail
|
else // where = tail
|
||||||
@ -266,6 +278,7 @@ public:
|
|||||||
pTmp->SetNext(where.m_CurPos->GetNext());
|
pTmp->SetNext(where.m_CurPos->GetNext());
|
||||||
|
|
||||||
where.m_CurPos->SetNext(pTmp);
|
where.m_CurPos->SetNext(pTmp);
|
||||||
|
|
||||||
return ++where;
|
return ++where;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,6 +302,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,13 +315,15 @@ public:
|
|||||||
{
|
{
|
||||||
iterator iter = begin();
|
iterator iter = begin();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
++i;
|
++i;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif //CLIST_H
|
||||||
|
@ -35,102 +35,149 @@
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class LogEventsMngr
|
// class LogEventsMngr
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
LogEventsMngr::LogEventsMngr() {
|
|
||||||
|
LogEventsMngr::LogEventsMngr()
|
||||||
|
{
|
||||||
logCurrent = logCounter = 0;
|
logCurrent = logCounter = 0;
|
||||||
logcmplist = 0;
|
logcmplist = 0;
|
||||||
arelogevents = false;
|
arelogevents = false;
|
||||||
memset(logevents, 0, sizeof(logevents));
|
memset(logevents, 0, sizeof(logevents));
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEventsMngr::~LogEventsMngr() {
|
LogEventsMngr::~LogEventsMngr()
|
||||||
|
{
|
||||||
clearLogEvents();
|
clearLogEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LogEventsMngr::CLogCmp::compareCondition(const char* string){
|
int LogEventsMngr::CLogCmp::compareCondition(const char* string)
|
||||||
|
{
|
||||||
if (logid == parent->logCounter)
|
if (logid == parent->logCounter)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
logid = parent->logCounter;
|
logid = parent->logCounter;
|
||||||
if ( in ) return result = strstr( string , text.c_str() ) ? 0 : 1;
|
|
||||||
|
if (in)
|
||||||
|
return result = strstr(string, text.c_str()) ? 0 : 1;
|
||||||
|
|
||||||
return result = strcmp(string,text.c_str());
|
return result = strcmp(string,text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEventsMngr::CLogCmp* LogEventsMngr::registerCondition(char* filter){
|
LogEventsMngr::CLogCmp* LogEventsMngr::registerCondition(char* filter)
|
||||||
|
{
|
||||||
char* temp = filter;
|
char* temp = filter;
|
||||||
// expand "1=message"
|
// expand "1=message"
|
||||||
|
|
||||||
while (isdigit(*filter))
|
while (isdigit(*filter))
|
||||||
++filter;
|
++filter;
|
||||||
|
|
||||||
bool in = (*filter=='&');
|
bool in = (*filter=='&');
|
||||||
*filter++ = 0;
|
*filter++ = 0;
|
||||||
int pos = atoi(temp);
|
int pos = atoi(temp);
|
||||||
if ( pos < 0 || pos >= MAX_LOGARGS) pos = 0;
|
|
||||||
|
if (pos < 0 || pos >= MAX_LOGARGS)
|
||||||
|
pos = 0;
|
||||||
|
|
||||||
CLogCmp* c = logcmplist;
|
CLogCmp* c = logcmplist;
|
||||||
while( c ) {
|
|
||||||
|
while (c)
|
||||||
|
{
|
||||||
if ((c->pos == pos) && (c->in == in) && !strcmp(c->text.c_str(), filter))
|
if ((c->pos == pos) && (c->in == in) && !strcmp(c->text.c_str(), filter))
|
||||||
return c;
|
return c;
|
||||||
c = c->next;
|
c = c->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return logcmplist = new CLogCmp(filter, in, pos, logcmplist, this);
|
return logcmplist = new CLogCmp(filter, in, pos, logcmplist, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEventsMngr::CLogEvent::registerFilter( char* filter ){
|
void LogEventsMngr::CLogEvent::registerFilter(char* filter)
|
||||||
|
{
|
||||||
CLogCmp *cmp = parent->registerCondition(filter);
|
CLogCmp *cmp = parent->registerCondition(filter);
|
||||||
if (cmp == 0) return;
|
if (cmp == 0) return;
|
||||||
for(LogCond* c = filters; c ; c = c->next){
|
|
||||||
if ( c->argnum == cmp->pos ){
|
for (LogCond* c = filters; c; c = c->next)
|
||||||
|
{
|
||||||
|
if (c->argnum == cmp->pos)
|
||||||
|
{
|
||||||
c->list = new LogCondEle(cmp, c->list);
|
c->list = new LogCondEle(cmp, c->list);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogCondEle* aa = new LogCondEle(cmp, 0);
|
LogCondEle* aa = new LogCondEle(cmp, 0);
|
||||||
if ( aa == 0 ) return;
|
|
||||||
|
if (aa == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
filters = new LogCond(cmp->pos, aa, filters);
|
filters = new LogCond(cmp->pos, aa, filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEventsMngr::setLogString( char* frmt, va_list& vaptr ) {
|
void LogEventsMngr::setLogString(char* frmt, va_list& vaptr)
|
||||||
|
{
|
||||||
++logCounter;
|
++logCounter;
|
||||||
int len = vsnprintf(logString, 255, frmt, vaptr);
|
int len = vsnprintf(logString, 255, frmt, vaptr);
|
||||||
if ( len == - 1) {
|
|
||||||
|
if (len == - 1)
|
||||||
|
{
|
||||||
len = 255;
|
len = 255;
|
||||||
logString[len] = 0;
|
logString[len] = 0;
|
||||||
}
|
}
|
||||||
if ( len ) logString[--len] = 0;
|
|
||||||
|
if (len)
|
||||||
|
logString[--len] = 0;
|
||||||
|
|
||||||
logArgc = 0;
|
logArgc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEventsMngr::setLogString( char* frmt, ... ) {
|
void LogEventsMngr::setLogString(char* frmt, ...)
|
||||||
|
{
|
||||||
++logCounter;
|
++logCounter;
|
||||||
va_list logArgPtr;
|
va_list logArgPtr;
|
||||||
va_start(logArgPtr, frmt);
|
va_start(logArgPtr, frmt);
|
||||||
int len = vsnprintf(logString, 255, frmt, logArgPtr);
|
int len = vsnprintf(logString, 255, frmt, logArgPtr);
|
||||||
if ( len == - 1) {
|
|
||||||
|
if (len == - 1)
|
||||||
|
{
|
||||||
len = 255;
|
len = 255;
|
||||||
logString[len] = 0;
|
logString[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(logArgPtr);
|
va_end(logArgPtr);
|
||||||
if ( len ) logString[--len] = 0;
|
|
||||||
|
if (len)
|
||||||
|
logString[--len] = 0;
|
||||||
|
|
||||||
logArgc = 0;
|
logArgc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEventsMngr::parseLogString( ) {
|
void LogEventsMngr::parseLogString()
|
||||||
|
{
|
||||||
register const char* b = logString;
|
register const char* b = logString;
|
||||||
register int a;
|
register int a;
|
||||||
while( *b && logArgc < MAX_LOGARGS ){
|
|
||||||
|
while (*b && logArgc < MAX_LOGARGS)
|
||||||
|
{
|
||||||
a = 0;
|
a = 0;
|
||||||
if ( *b == '"' ) {
|
|
||||||
|
if (*b == '"')
|
||||||
|
{
|
||||||
++b;
|
++b;
|
||||||
|
|
||||||
while (*b && *b != '"' && a < 127)
|
while (*b && *b != '"' && a < 127)
|
||||||
logArgs[logArgc][a++] = *b++;
|
logArgs[logArgc][a++] = *b++;
|
||||||
|
|
||||||
logArgs[logArgc++][a] = 0;
|
logArgs[logArgc++][a] = 0;
|
||||||
if (*b) b+=2; // thanks to double terminator
|
if (*b) b+=2; // thanks to double terminator
|
||||||
}
|
}
|
||||||
else if ( *b == '(' ) {
|
else if (*b == '(')
|
||||||
|
{
|
||||||
++b;
|
++b;
|
||||||
|
|
||||||
while (*b && *b != ')' && a < 127)
|
while (*b && *b != ')' && a < 127)
|
||||||
logArgs[logArgc][a++] = *b++;
|
logArgs[logArgc][a++] = *b++;
|
||||||
|
|
||||||
logArgs[logArgc++][a] = 0;
|
logArgs[logArgc++][a] = 0;
|
||||||
if (*b) b+=2;
|
if (*b) b+=2;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
while (*b && *b != '(' && *b != '"' && a < 127)
|
while (*b && *b != '(' && *b != '"' && a < 127)
|
||||||
logArgs[logArgc][a++] = *b++;
|
logArgs[logArgc][a++] = *b++;
|
||||||
if (*b) --a;
|
if (*b) --a;
|
||||||
@ -143,27 +190,37 @@ LogEventsMngr::CLogEvent* LogEventsMngr::registerLogEvent( CPluginMngr::CPlugin*
|
|||||||
{
|
{
|
||||||
if (pos < 1 || pos > MAX_LOGARGS)
|
if (pos < 1 || pos > MAX_LOGARGS)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
arelogevents = true;
|
arelogevents = true;
|
||||||
CLogEvent** d = &logevents[pos];
|
CLogEvent** d = &logevents[pos];
|
||||||
while(*d) d = &(*d)->next;
|
|
||||||
|
while (*d)
|
||||||
|
d = &(*d)->next;
|
||||||
|
|
||||||
return *d = new CLogEvent(plugin, func, this);
|
return *d = new CLogEvent(plugin, func, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEventsMngr::executeLogEvents()
|
void LogEventsMngr::executeLogEvents()
|
||||||
{
|
{
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
for (CLogEvent* a = logevents[logArgc]; a; a = a->next)
|
for (CLogEvent* a = logevents[logArgc]; a; a = a->next)
|
||||||
{
|
{
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
for (CLogEvent::LogCond* b = a->filters; b; b = b->next)
|
for (CLogEvent::LogCond* b = a->filters; b; b = b->next)
|
||||||
{
|
{
|
||||||
valid = false;
|
valid = false;
|
||||||
for( CLogEvent::LogCondEle* c = b->list; c ; c = c->next) {
|
|
||||||
if ( c->cmp->compareCondition( logArgs[b->argnum] ) == 0 ){
|
for (CLogEvent::LogCondEle* c = b->list; c; c = c->next)
|
||||||
|
{
|
||||||
|
if (c->cmp->compareCondition(logArgs[b->argnum]) == 0)
|
||||||
|
{
|
||||||
valid = true;
|
valid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid)
|
if (!valid)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -175,38 +232,49 @@ void LogEventsMngr::executeLogEvents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEventsMngr::clearLogEvents(){
|
void LogEventsMngr::clearLogEvents()
|
||||||
|
{
|
||||||
logCurrent = logCounter = 0;
|
logCurrent = logCounter = 0;
|
||||||
arelogevents = false;
|
arelogevents = false;
|
||||||
for(int i = 0; i < MAX_LOGARGS + 1; ++i){
|
|
||||||
|
for (int i = 0; i < MAX_LOGARGS + 1; ++i)
|
||||||
|
{
|
||||||
CLogEvent **a = &logevents[i];
|
CLogEvent **a = &logevents[i];
|
||||||
while(*a){
|
while (*a)
|
||||||
|
{
|
||||||
CLogEvent* bb = (*a)->next;
|
CLogEvent* bb = (*a)->next;
|
||||||
delete *a;
|
delete *a;
|
||||||
*a = bb;
|
*a = bb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearConditions();
|
clearConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogEventsMngr::clearConditions() {
|
void LogEventsMngr::clearConditions()
|
||||||
while (logcmplist){
|
{
|
||||||
|
while (logcmplist)
|
||||||
|
{
|
||||||
CLogCmp* a = logcmplist->next;
|
CLogCmp* a = logcmplist->next;
|
||||||
delete logcmplist;
|
delete logcmplist;
|
||||||
logcmplist = a;
|
logcmplist = a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEventsMngr::CLogEvent::LogCond::~LogCond() {
|
LogEventsMngr::CLogEvent::LogCond::~LogCond()
|
||||||
while( list ) {
|
{
|
||||||
|
while (list)
|
||||||
|
{
|
||||||
LogCondEle* cc = list->next;
|
LogCondEle* cc = list->next;
|
||||||
delete list;
|
delete list;
|
||||||
list = cc;
|
list = cc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogEventsMngr::CLogEvent::~CLogEvent() {
|
LogEventsMngr::CLogEvent::~CLogEvent()
|
||||||
while( filters ) {
|
{
|
||||||
|
while (filters)
|
||||||
|
{
|
||||||
LogCond* cc = filters->next;
|
LogCond* cc = filters->next;
|
||||||
delete filters;
|
delete filters;
|
||||||
filters = cc;
|
filters = cc;
|
||||||
@ -216,23 +284,35 @@ LogEventsMngr::CLogEvent::~CLogEvent() {
|
|||||||
LogEventsMngr::CLogEvent *LogEventsMngr::getValidLogEvent(CLogEvent * a)
|
LogEventsMngr::CLogEvent *LogEventsMngr::getValidLogEvent(CLogEvent * a)
|
||||||
{
|
{
|
||||||
bool valid;
|
bool valid;
|
||||||
while(a){
|
|
||||||
|
while (a)
|
||||||
|
{
|
||||||
valid = true;
|
valid = true;
|
||||||
for( CLogEvent::LogCond* b = a->filters; b ; b = b->next){
|
|
||||||
|
for (CLogEvent::LogCond* b = a->filters; b; b = b->next)
|
||||||
|
{
|
||||||
valid = false;
|
valid = false;
|
||||||
for( CLogEvent::LogCondEle* c = b->list; c ; c = c->next) {
|
|
||||||
if ( c->cmp->compareCondition( logArgs[b->argnum] ) == 0 ){
|
for (CLogEvent::LogCondEle* c = b->list; c; c = c->next)
|
||||||
|
{
|
||||||
|
if (c->cmp->compareCondition(logArgs[b->argnum]) == 0)
|
||||||
|
{
|
||||||
valid = true;
|
valid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid) break;
|
if (!valid) break;
|
||||||
}
|
}
|
||||||
if (!valid){
|
|
||||||
|
if (!valid)
|
||||||
|
{
|
||||||
a = a->next;
|
a = a->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
// class LogEventsMngr
|
// class LogEventsMngr
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
class LogEventsMngr {
|
class LogEventsMngr
|
||||||
|
{
|
||||||
char logString[256];
|
char logString[256];
|
||||||
char logArgs[MAX_LOGARGS][128];
|
char logArgs[MAX_LOGARGS][128];
|
||||||
int logArgc;
|
int logArgc;
|
||||||
@ -53,7 +53,6 @@ public:
|
|||||||
class CLogCmp;
|
class CLogCmp;
|
||||||
class iterator;
|
class iterator;
|
||||||
class CLogEvent;
|
class CLogEvent;
|
||||||
|
|
||||||
friend class CLogEvent;
|
friend class CLogEvent;
|
||||||
friend class CLogCmp;
|
friend class CLogCmp;
|
||||||
friend class iterator;
|
friend class iterator;
|
||||||
@ -62,50 +61,63 @@ public:
|
|||||||
{
|
{
|
||||||
friend class LogEventsMngr;
|
friend class LogEventsMngr;
|
||||||
friend class CLogEvent;
|
friend class CLogEvent;
|
||||||
|
|
||||||
LogEventsMngr* parent;
|
LogEventsMngr* parent;
|
||||||
String text;
|
String text;
|
||||||
|
|
||||||
int logid;
|
int logid;
|
||||||
int pos;
|
int pos;
|
||||||
int result;
|
int result;
|
||||||
bool in;
|
bool in;
|
||||||
|
|
||||||
CLogCmp *next;
|
CLogCmp *next;
|
||||||
CLogCmp( const char* s, bool r, int p, CLogCmp *n, LogEventsMngr* mg ) : text(s) {
|
|
||||||
|
CLogCmp(const char* s, bool r, int p, CLogCmp *n, LogEventsMngr* mg) : text(s)
|
||||||
|
{
|
||||||
logid = result = 0;
|
logid = result = 0;
|
||||||
pos = p;
|
pos = p;
|
||||||
parent = mg;
|
parent = mg;
|
||||||
in = r;
|
in = r;
|
||||||
next = n;
|
next = n;
|
||||||
}
|
}
|
||||||
public:
|
|
||||||
|
|
||||||
|
public:
|
||||||
int compareCondition(const char* string);
|
int compareCondition(const char* string);
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
CLogCmp *logcmplist;
|
CLogCmp *logcmplist;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class CLogEvent {
|
class CLogEvent
|
||||||
|
{
|
||||||
friend class LogEventsMngr;
|
friend class LogEventsMngr;
|
||||||
friend class iterator;
|
friend class iterator;
|
||||||
struct LogCondEle {
|
|
||||||
|
struct LogCondEle
|
||||||
|
{
|
||||||
CLogCmp *cmp;
|
CLogCmp *cmp;
|
||||||
LogCondEle *next;
|
LogCondEle *next;
|
||||||
LogCondEle(CLogCmp *c, LogCondEle *n): cmp(c), next(n) {}
|
LogCondEle(CLogCmp *c, LogCondEle *n): cmp(c), next(n) {}
|
||||||
};
|
};
|
||||||
struct LogCond {
|
|
||||||
|
struct LogCond
|
||||||
|
{
|
||||||
int argnum;
|
int argnum;
|
||||||
|
|
||||||
LogCondEle *list;
|
LogCondEle *list;
|
||||||
LogCond *next;
|
LogCond *next;
|
||||||
LogCond(int a, LogCondEle* ee, LogCond* n) : argnum(a), list(ee), next(n) {}
|
LogCond(int a, LogCondEle* ee, LogCond* n) : argnum(a), list(ee), next(n) {}
|
||||||
~LogCond();
|
~LogCond();
|
||||||
};
|
};
|
||||||
|
|
||||||
CPluginMngr::CPlugin *plugin;
|
CPluginMngr::CPlugin *plugin;
|
||||||
|
|
||||||
int func;
|
int func;
|
||||||
|
|
||||||
LogCond *filters;
|
LogCond *filters;
|
||||||
LogEventsMngr* parent;
|
LogEventsMngr* parent;
|
||||||
|
|
||||||
CLogEvent *next;
|
CLogEvent *next;
|
||||||
CLogEvent(CPluginMngr::CPlugin *p, int f, LogEventsMngr* ppp) : plugin(p), func(f), filters(0), parent(ppp), next(0) {}
|
CLogEvent(CPluginMngr::CPlugin *p, int f, LogEventsMngr* ppp) : plugin(p), func(f), filters(0), parent(ppp), next(0) {}
|
||||||
~CLogEvent();
|
~CLogEvent();
|
||||||
@ -116,50 +128,51 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
CLogEvent *logevents[MAX_LOGARGS + 1];
|
CLogEvent *logevents[MAX_LOGARGS + 1];
|
||||||
CLogEvent *getValidLogEvent(CLogEvent * a);
|
CLogEvent *getValidLogEvent(CLogEvent * a);
|
||||||
CLogCmp* registerCondition(char* filter);
|
CLogCmp* registerCondition(char* filter);
|
||||||
|
|
||||||
void clearConditions();
|
void clearConditions();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LogEventsMngr();
|
LogEventsMngr();
|
||||||
~LogEventsMngr();
|
~LogEventsMngr();
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
|
|
||||||
CLogEvent* registerLogEvent(CPluginMngr::CPlugin* plugin, int func, int pos);
|
CLogEvent* registerLogEvent(CPluginMngr::CPlugin* plugin, int func, int pos);
|
||||||
inline bool logEventsExist() { return arelogevents; }
|
inline bool logEventsExist() { return arelogevents; }
|
||||||
|
|
||||||
void setLogString(char* frmt, va_list& vaptr);
|
void setLogString(char* frmt, va_list& vaptr);
|
||||||
void setLogString(char* frmt, ...);
|
void setLogString(char* frmt, ...);
|
||||||
void parseLogString();
|
void parseLogString();
|
||||||
void executeLogEvents();
|
void executeLogEvents();
|
||||||
|
|
||||||
inline const char* getLogString() { return logString; }
|
inline const char* getLogString() { return logString; }
|
||||||
inline int getLogArgNum() { return logArgc; }
|
inline int getLogArgNum() { return logArgc; }
|
||||||
inline const char* getLogArg(int i) { return (i < 0 || i >= logArgc) ? "" : logArgs[i]; }
|
inline const char* getLogArg(int i) { return (i < 0 || i >= logArgc) ? "" : logArgs[i]; }
|
||||||
void clearLogEvents();
|
void clearLogEvents();
|
||||||
|
|
||||||
|
class iterator
|
||||||
class iterator {
|
{
|
||||||
CLogEvent* a;
|
CLogEvent* a;
|
||||||
LogEventsMngr* b;
|
LogEventsMngr* b;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline iterator(CLogEvent*aa, LogEventsMngr* bb) : a(aa), b(bb) {}
|
inline iterator(CLogEvent*aa, LogEventsMngr* bb) : a(aa), b(bb) {}
|
||||||
inline iterator& operator++() {
|
|
||||||
|
inline iterator& operator++()
|
||||||
|
{
|
||||||
a = b->getValidLogEvent(a->next);
|
a = b->getValidLogEvent(a->next);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(const iterator& c) const { return a == c.a; }
|
inline bool operator==(const iterator& c) const { return a == c.a; }
|
||||||
inline bool operator!=(const iterator& c) const { return !operator == (c); }
|
inline bool operator!=(const iterator& c) const { return !operator == (c); }
|
||||||
CLogEvent& operator*() { return *a; }
|
CLogEvent& operator*() { return *a; }
|
||||||
operator bool () const { return a ? true : false; }
|
operator bool () const { return a ? true : false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline iterator begin() { return iterator(getValidLogEvent(logevents[logArgc]), this); }
|
inline iterator begin() { return iterator(getValidLogEvent(logevents[logArgc]), this); }
|
||||||
inline iterator end() { return iterator(0, this); }
|
inline iterator end() { return iterator(0, this); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif //LOGEVENTS_H
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class MenuMngr
|
// class MenuMngr
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
MenuMngr::MenuCommand::MenuCommand( CPluginMngr::CPlugin *a, int mi, int k, int f ) {
|
MenuMngr::MenuCommand::MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f)
|
||||||
|
{
|
||||||
plugin = a;
|
plugin = a;
|
||||||
keys = k;
|
keys = k;
|
||||||
menuid = mi;
|
menuid = mi;
|
||||||
@ -50,20 +51,27 @@ MenuMngr::~MenuMngr()
|
|||||||
|
|
||||||
int MenuMngr::findMenuId(const char* name, AMX* amx)
|
int MenuMngr::findMenuId(const char* name, AMX* amx)
|
||||||
{
|
{
|
||||||
for( MenuIdEle* b = headid; b ; b = b->next) {
|
for (MenuIdEle* b = headid; b; b = b->next)
|
||||||
|
{
|
||||||
if ((!amx || !b->amx || amx == b->amx) && strstr(name,b->name.c_str()))
|
if ((!amx || !b->amx || amx == b->amx) && strstr(name,b->name.c_str()))
|
||||||
return b->id;
|
return b->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MenuMngr::registerMenuId(const char* n, AMX* a)
|
int MenuMngr::registerMenuId(const char* n, AMX* a)
|
||||||
{
|
{
|
||||||
int id = findMenuId(n, a);
|
int id = findMenuId(n, a);
|
||||||
if (id) return id;
|
|
||||||
|
if (id)
|
||||||
|
return id;
|
||||||
|
|
||||||
headid = new MenuIdEle(n, a, headid);
|
headid = new MenuIdEle(n, a, headid);
|
||||||
|
|
||||||
if (!headid)
|
if (!headid)
|
||||||
return 0; // :TODO: Better error report
|
return 0; // :TODO: Better error report
|
||||||
|
|
||||||
return headid->id;
|
return headid->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,17 +43,20 @@ class MenuMngr
|
|||||||
String name;
|
String name;
|
||||||
AMX* amx;
|
AMX* amx;
|
||||||
MenuIdEle* next;
|
MenuIdEle* next;
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
static int uniqueid;
|
static int uniqueid;
|
||||||
MenuIdEle( const char* n, AMX* a, MenuIdEle* m ) : name( n ) , amx(a) , next( m ) {
|
|
||||||
|
MenuIdEle(const char* n, AMX* a, MenuIdEle* m) : name(n), amx(a), next(m)
|
||||||
|
{
|
||||||
id = ++uniqueid;
|
id = ++uniqueid;
|
||||||
}
|
}
|
||||||
|
|
||||||
~MenuIdEle() { --uniqueid; }
|
~MenuIdEle() { --uniqueid; }
|
||||||
} *headid;
|
} *headid;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class iterator;
|
class iterator;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
class MenuCommand
|
class MenuCommand
|
||||||
@ -65,6 +68,7 @@ private:
|
|||||||
int menuid;
|
int menuid;
|
||||||
int keys;
|
int keys;
|
||||||
int function;
|
int function;
|
||||||
|
|
||||||
MenuCommand* next;
|
MenuCommand* next;
|
||||||
MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f);
|
MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f);
|
||||||
public:
|
public:
|
||||||
@ -74,19 +78,18 @@ private:
|
|||||||
} *headcmd;
|
} *headcmd;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MenuMngr() { headid = 0; headcmd = 0; }
|
MenuMngr() { headid = 0; headcmd = 0; }
|
||||||
~MenuMngr();
|
~MenuMngr();
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
|
|
||||||
int findMenuId(const char* name, AMX* a = 0);
|
int findMenuId(const char* name, AMX* a = 0);
|
||||||
int registerMenuId(const char* n, AMX* a);
|
int registerMenuId(const char* n, AMX* a);
|
||||||
void registerMenuCmd(CPluginMngr::CPlugin *a, int mi, int k, int f);
|
void registerMenuCmd(CPluginMngr::CPlugin *a, int mi, int k, int f);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
class iterator {
|
class iterator
|
||||||
|
{
|
||||||
MenuCommand* a;
|
MenuCommand* a;
|
||||||
public:
|
public:
|
||||||
iterator(MenuCommand*aa) : a(aa) {}
|
iterator(MenuCommand*aa) : a(aa) {}
|
||||||
@ -96,8 +99,9 @@ public:
|
|||||||
operator bool () const { return a ? true : false; }
|
operator bool () const { return a ? true : false; }
|
||||||
MenuCommand& operator*() { return *a; }
|
MenuCommand& operator*() { return *a; }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline iterator begin() const { return iterator(headcmd); }
|
inline iterator begin() const { return iterator(headcmd); }
|
||||||
inline iterator end() const { return iterator(0); }
|
inline iterator end() const { return iterator(0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif //MENUS_H
|
||||||
|
@ -55,42 +55,59 @@ void CPlayer::Init( edict_t* e , int i )
|
|||||||
team.clear();
|
team.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::Disconnect() {
|
void CPlayer::Disconnect()
|
||||||
|
{
|
||||||
ingame = false;
|
ingame = false;
|
||||||
initialized = false;
|
initialized = false;
|
||||||
authorized = false;
|
authorized = false;
|
||||||
|
|
||||||
|
while (!cvarQueryQueue.empty())
|
||||||
|
{
|
||||||
|
ClientCvarQuery_Info *pQuery = cvarQueryQueue.front();
|
||||||
|
unregisterSPForward(pQuery->resultFwd);
|
||||||
|
|
||||||
|
if (pQuery->params)
|
||||||
|
delete [] pQuery->params;
|
||||||
|
|
||||||
|
delete pQuery;
|
||||||
|
cvarQueryQueue.pop();
|
||||||
|
}
|
||||||
|
|
||||||
bot = 0;
|
bot = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::PutInServer() {
|
void CPlayer::PutInServer()
|
||||||
|
{
|
||||||
playtime = gpGlobals->time;
|
playtime = gpGlobals->time;
|
||||||
ingame = true;
|
ingame = true;
|
||||||
}
|
}
|
||||||
bool CPlayer::Connect(const char* connectname,const char* ipaddress) {
|
|
||||||
|
bool CPlayer::Connect(const char* connectname, const char* ipaddress)
|
||||||
|
{
|
||||||
name.assign(connectname);
|
name.assign(connectname);
|
||||||
ip.assign(ipaddress);
|
ip.assign(ipaddress);
|
||||||
time = gpGlobals->time;
|
time = gpGlobals->time;
|
||||||
bot = IsBot();
|
bot = IsBot();
|
||||||
death_killer = 0;
|
death_killer = 0;
|
||||||
|
|
||||||
memset(flags, 0, sizeof(flags));
|
memset(flags, 0, sizeof(flags));
|
||||||
memset(weapons, 0, sizeof(weapons));
|
memset(weapons, 0, sizeof(weapons));
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
authorized = false;
|
authorized = false;
|
||||||
|
|
||||||
const char* authid = GETPLAYERAUTHID(pEdict);
|
const char* authid = GETPLAYERAUTHID(pEdict);
|
||||||
|
|
||||||
if ( (authid == 0) || (*authid == 0)
|
if ((authid == 0) || (*authid == 0) || (strcmp(authid, "STEAM_ID_PENDING") == 0))
|
||||||
|| (strcmp( authid , "STEAM_ID_PENDING") == 0) )
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class Grenades
|
// class Grenades
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
void Grenades::put(edict_t* grenade, float time, int type, CPlayer* player)
|
void Grenades::put(edict_t* grenade, float time, int type, CPlayer* player)
|
||||||
{
|
{
|
||||||
Obj* a = new Obj;
|
Obj* a = new Obj;
|
||||||
@ -107,30 +124,33 @@ bool Grenades::find( edict_t* enemy, CPlayer** p, int& type )
|
|||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
Obj** a = &head;
|
Obj** a = &head;
|
||||||
while ( *a ){
|
|
||||||
if ( (*a)->time > gpGlobals->time ) {
|
while (*a)
|
||||||
if ( (*a)->grenade == enemy ) {
|
{
|
||||||
|
if ((*a)->time > gpGlobals->time)
|
||||||
|
{
|
||||||
|
if ((*a)->grenade == enemy)
|
||||||
|
{
|
||||||
found = true;
|
found = true;
|
||||||
(*p) = (*a)->player;
|
(*p) = (*a)->player;
|
||||||
type = (*a)->type;
|
type = (*a)->type;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Obj* b = (*a)->next;
|
Obj* b = (*a)->next;
|
||||||
delete *a;
|
delete *a;
|
||||||
*a = b;
|
*a = b;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
a = &(*a)->next;
|
a = &(*a)->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Grenades::clear()
|
void Grenades::clear()
|
||||||
{
|
{
|
||||||
while(head){
|
while (head)
|
||||||
|
{
|
||||||
Obj* a = head->next;
|
Obj* a = head->next;
|
||||||
delete head;
|
delete head;
|
||||||
head = a;
|
head = a;
|
||||||
@ -140,7 +160,9 @@ void Grenades::clear()
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class XVars
|
// class XVars
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
void XVars::clear() {
|
|
||||||
|
void XVars::clear()
|
||||||
|
{
|
||||||
delete[] head;
|
delete[] head;
|
||||||
head = 0;
|
head = 0;
|
||||||
num = 0;
|
num = 0;
|
||||||
@ -149,7 +171,8 @@ void XVars::clear() {
|
|||||||
|
|
||||||
int XVars::put(AMX* p, cell* v)
|
int XVars::put(AMX* p, cell* v)
|
||||||
{
|
{
|
||||||
for(int a = 0; a < num; ++a) {
|
for (int a = 0; a < num; ++a)
|
||||||
|
{
|
||||||
if ((head[a].amx == p) && (head[a].value == v))
|
if ((head[a].amx == p) && (head[a].value == v))
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@ -159,29 +182,38 @@ int XVars::put( AMX* p, cell* v )
|
|||||||
|
|
||||||
head[num].value = v;
|
head[num].value = v;
|
||||||
head[num].amx = p;
|
head[num].amx = p;
|
||||||
|
|
||||||
return num++;
|
return num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int XVars::realloc_array(int nsize)
|
int XVars::realloc_array(int nsize)
|
||||||
{
|
{
|
||||||
XVarEle* me = new XVarEle[nsize];
|
XVarEle* me = new XVarEle[nsize];
|
||||||
if ( me ){
|
|
||||||
|
if (me)
|
||||||
|
{
|
||||||
for (int a = 0 ; a < num; ++a)
|
for (int a = 0 ; a < num; ++a)
|
||||||
me[a] = head[a];
|
me[a] = head[a];
|
||||||
|
|
||||||
delete[] head;
|
delete[] head;
|
||||||
head = me;
|
head = me;
|
||||||
size = nsize;
|
size = nsize;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class TeamIds
|
// class TeamIds
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
TeamIds::TeamIds() { head = 0; newTeam = 0; }
|
TeamIds::TeamIds() { head = 0; newTeam = 0; }
|
||||||
TeamIds::~TeamIds() {
|
|
||||||
while( head ) {
|
TeamIds::~TeamIds()
|
||||||
|
{
|
||||||
|
while (head)
|
||||||
|
{
|
||||||
TeamEle* a = head->next;
|
TeamEle* a = head->next;
|
||||||
delete head;
|
delete head;
|
||||||
head = a;
|
head = a;
|
||||||
@ -191,42 +223,56 @@ TeamIds::~TeamIds() {
|
|||||||
void TeamIds::registerTeam(const char* n, int s)
|
void TeamIds::registerTeam(const char* n, int s)
|
||||||
{
|
{
|
||||||
TeamEle** a = &head;
|
TeamEle** a = &head;
|
||||||
while( *a ){
|
|
||||||
if ( strcmp((*a)->name.c_str(),n) == 0 ){
|
while (*a)
|
||||||
if (s != -1){
|
{
|
||||||
|
if (strcmp((*a)->name.c_str(),n) == 0)
|
||||||
|
{
|
||||||
|
if (s != -1)
|
||||||
|
{
|
||||||
(*a)->id = s;
|
(*a)->id = s;
|
||||||
newTeam &= ~(1<<(*a)->tid);
|
newTeam &= ~(1<<(*a)->tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a = &(*a)->next;
|
a = &(*a)->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
*a = new TeamEle(n, s);
|
*a = new TeamEle(n, s);
|
||||||
if ( *a == 0 ) return;
|
|
||||||
|
if (*a == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
newTeam |= (1<<(*a)->tid);
|
newTeam |= (1<<(*a)->tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TeamIds::findTeamId(const char* n)
|
int TeamIds::findTeamId(const char* n)
|
||||||
{
|
{
|
||||||
TeamEle* a = head;
|
TeamEle* a = head;
|
||||||
while( a ){
|
|
||||||
|
while (a)
|
||||||
|
{
|
||||||
if (!stricmp(a->name.c_str(), n))
|
if (!stricmp(a->name.c_str(), n))
|
||||||
return a->id;
|
return a->id;
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TeamIds::findTeamIdCase(const char* n)
|
int TeamIds::findTeamIdCase(const char* n)
|
||||||
{
|
{
|
||||||
TeamEle* a = head;
|
TeamEle* a = head;
|
||||||
while( a ){
|
|
||||||
|
while (a)
|
||||||
|
{
|
||||||
if (!strcmp(a->name.c_str(), n))
|
if (!strcmp(a->name.c_str(), n))
|
||||||
return a->id;
|
return a->id;
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char TeamIds::TeamEle::uid = 0;
|
char TeamIds::TeamEle::uid = 0;
|
||||||
|
|
||||||
|
@ -37,34 +37,44 @@
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class CCVar
|
// class CCVar
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
class CCVar
|
class CCVar
|
||||||
{
|
{
|
||||||
cvar_t cvar;
|
cvar_t cvar;
|
||||||
String name;
|
String name;
|
||||||
String plugin;
|
String plugin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCVar( const char* pname, const char* pplugin,
|
CCVar(const char* pname, const char* pplugin, int pflags, float pvalue) : name(pname), plugin(pplugin)
|
||||||
int pflags, float pvalue ) : name(pname) , plugin(pplugin ) {
|
{
|
||||||
cvar.name = (char*)name.c_str();
|
cvar.name = (char*)name.c_str();
|
||||||
cvar.flags = pflags;
|
cvar.flags = pflags;
|
||||||
cvar.string = "";
|
cvar.string = "";
|
||||||
cvar.value = pvalue;
|
cvar.value = pvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline cvar_t* getCvar() { return &cvar; }
|
inline cvar_t* getCvar() { return &cvar; }
|
||||||
inline const char* getPluginName() { return plugin.c_str(); }
|
inline const char* getPluginName() { return plugin.c_str(); }
|
||||||
inline const char* getName() { return name.c_str(); }
|
inline const char* getName() { return name.c_str(); }
|
||||||
inline bool operator == (const char* string) { return (strcmp(name.c_str(), string) == 0); }
|
inline bool operator == (const char* string) { return (strcmp(name.c_str(), string) == 0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class CPlayer
|
// class CPlayer
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
|
struct ClientCvarQuery_Info
|
||||||
|
{
|
||||||
|
bool querying; // Are we actually waiting for a response at the moment?
|
||||||
|
String cvarName;
|
||||||
|
int resultFwd;
|
||||||
|
|
||||||
|
int paramLen;
|
||||||
|
cell *params;
|
||||||
|
};
|
||||||
|
|
||||||
class CPlayer
|
class CPlayer
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
edict_t* pEdict;
|
edict_t* pEdict;
|
||||||
|
|
||||||
@ -80,7 +90,8 @@ public:
|
|||||||
float time;
|
float time;
|
||||||
float playtime;
|
float playtime;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
int ammo;
|
int ammo;
|
||||||
int clip;
|
int clip;
|
||||||
} weapons[MAX_WEAPONS];
|
} weapons[MAX_WEAPONS];
|
||||||
@ -106,16 +117,21 @@ public:
|
|||||||
Vector thisTrace;
|
Vector thisTrace;
|
||||||
Vector lastHit;
|
Vector lastHit;
|
||||||
|
|
||||||
|
CQueue<ClientCvarQuery_Info*> cvarQueryQueue;
|
||||||
|
|
||||||
void Init(edict_t* e, int i);
|
void Init(edict_t* e, int i);
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
void PutInServer();
|
void PutInServer();
|
||||||
|
|
||||||
bool Connect(const char* connectname, const char* ipaddress);
|
bool Connect(const char* connectname, const char* ipaddress);
|
||||||
|
|
||||||
inline bool IsBot(){
|
inline bool IsBot()
|
||||||
|
{
|
||||||
return ((pEdict->v.flags & FL_FAKECLIENT) ? true : false);
|
return ((pEdict->v.flags & FL_FAKECLIENT) ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsAlive(){
|
inline bool IsAlive()
|
||||||
|
{
|
||||||
return ((pEdict->v.deadflag == DEAD_NO) && (pEdict->v.health > 0));
|
return ((pEdict->v.deadflag == DEAD_NO) && (pEdict->v.health > 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,10 +154,10 @@ class Grenades
|
|||||||
Obj* next;
|
Obj* next;
|
||||||
} *head;
|
} *head;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Grenades() { head = 0; }
|
Grenades() { head = 0; }
|
||||||
~Grenades() { clear(); }
|
~Grenades() { clear(); }
|
||||||
|
|
||||||
void put(edict_t* grenade, float time, int type, CPlayer* player);
|
void put(edict_t* grenade, float time, int type, CPlayer* player);
|
||||||
bool find(edict_t* enemy, CPlayer** p, int& type);
|
bool find(edict_t* enemy, CPlayer** p, int& type);
|
||||||
void clear();
|
void clear();
|
||||||
@ -150,19 +166,23 @@ public:
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class ForceObject
|
// class ForceObject
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
class ForceObject {
|
|
||||||
|
class ForceObject
|
||||||
|
{
|
||||||
String filename;
|
String filename;
|
||||||
FORCE_TYPE type;
|
FORCE_TYPE type;
|
||||||
Vector mins;
|
Vector mins;
|
||||||
Vector maxs;
|
Vector maxs;
|
||||||
AMX* amx;
|
AMX* amx;
|
||||||
public:
|
public:
|
||||||
ForceObject(const char* n, FORCE_TYPE c,Vector& mi, Vector& ma, AMX* a) :
|
ForceObject(const char* n, FORCE_TYPE c, Vector& mi, Vector& ma, AMX* a) : filename(n), type(c), mins(mi), maxs(ma), amx(a) {}
|
||||||
filename(n) , type(c), mins(mi), maxs(ma), amx(a) {}
|
|
||||||
inline const char* getFilename() { return filename.c_str(); }
|
inline const char* getFilename() { return filename.c_str(); }
|
||||||
inline AMX* getAMX() { return amx; }
|
inline AMX* getAMX() { return amx; }
|
||||||
|
|
||||||
Vector& getMin() { return mins; }
|
Vector& getMin() { return mins; }
|
||||||
Vector& getMax() { return maxs; }
|
Vector& getMax() { return maxs; }
|
||||||
|
|
||||||
inline FORCE_TYPE getForceType() { return type; }
|
inline FORCE_TYPE getForceType() { return type; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -172,30 +192,38 @@ public:
|
|||||||
|
|
||||||
class XVars
|
class XVars
|
||||||
{
|
{
|
||||||
struct XVarEle {
|
struct XVarEle
|
||||||
|
{
|
||||||
AMX* amx;
|
AMX* amx;
|
||||||
cell* value;
|
cell* value;
|
||||||
};
|
};
|
||||||
|
|
||||||
XVarEle* head;
|
XVarEle* head;
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
int realloc_array(int nsize);
|
int realloc_array(int nsize);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XVars() { num = 0; size = 0; head = 0; }
|
XVars() { num = 0; size = 0; head = 0; }
|
||||||
~XVars() { clear(); }
|
~XVars() { clear(); }
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
int put(AMX* a, cell* v);
|
int put(AMX* a, cell* v);
|
||||||
inline cell getValue( int a ) {
|
|
||||||
|
inline cell getValue(int a)
|
||||||
|
{
|
||||||
return (a >= 0 && a < num) ? *(head[a].value) : 0;
|
return (a >= 0 && a < num) ? *(head[a].value) : 0;
|
||||||
}
|
}
|
||||||
inline int setValue( int a, cell v ) {
|
|
||||||
if ( a >= 0 && a < num ){
|
inline int setValue(int a, cell v)
|
||||||
|
{
|
||||||
|
if (a >= 0 && a < num)
|
||||||
|
{
|
||||||
*(head[a].value) = v;
|
*(head[a].value) = v;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -203,6 +231,7 @@ public:
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class CScript
|
// class CScript
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
class CScript
|
class CScript
|
||||||
{
|
{
|
||||||
String filename;
|
String filename;
|
||||||
@ -210,6 +239,7 @@ class CScript
|
|||||||
void* code;
|
void* code;
|
||||||
public:
|
public:
|
||||||
CScript(AMX* aa, void* cc, const char* ff) : filename(ff), amx(aa), code(cc) {}
|
CScript(AMX* aa, void* cc, const char* ff) : filename(ff), amx(aa), code(cc) {}
|
||||||
|
|
||||||
inline AMX* getAMX() { return amx; }
|
inline AMX* getAMX() { return amx; }
|
||||||
inline const char* getName() { return filename.c_str(); }
|
inline const char* getName() { return filename.c_str(); }
|
||||||
inline bool operator==(void* a) { return (amx == (AMX*)a); }
|
inline bool operator==(void* a) { return (amx == (AMX*)a); }
|
||||||
@ -219,17 +249,22 @@ public:
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class TeamIds
|
// class TeamIds
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
class TeamIds
|
class TeamIds
|
||||||
{
|
{
|
||||||
struct TeamEle {
|
struct TeamEle
|
||||||
|
{
|
||||||
String name;
|
String name;
|
||||||
int id;
|
int id;
|
||||||
char tid;
|
char tid;
|
||||||
static char uid;
|
static char uid;
|
||||||
TeamEle* next;
|
TeamEle* next;
|
||||||
TeamEle(const char* n, int& i) : name(n) , id(i) , next(0) {
|
|
||||||
|
TeamEle(const char* n, int& i) : name(n), id(i), next(0)
|
||||||
|
{
|
||||||
tid = uid++;
|
tid = uid++;
|
||||||
};
|
}
|
||||||
|
|
||||||
~TeamEle() { --uid; }
|
~TeamEle() { --uid; }
|
||||||
} *head;
|
} *head;
|
||||||
|
|
||||||
@ -238,15 +273,11 @@ class TeamIds
|
|||||||
public:
|
public:
|
||||||
TeamIds();
|
TeamIds();
|
||||||
~TeamIds();
|
~TeamIds();
|
||||||
|
|
||||||
void registerTeam(const char* n, int s);
|
void registerTeam(const char* n, int s);
|
||||||
int findTeamId(const char* n);
|
int findTeamId(const char* n);
|
||||||
int findTeamIdCase(const char* n);
|
int findTeamIdCase(const char* n);
|
||||||
inline bool isNewTeam() { return newTeam ? true : false; }
|
inline bool isNewTeam() { return newTeam ? true : false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //CMISC_H
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ void CModule::clear(bool clearFilename)
|
|||||||
m_Metamod = false;
|
m_Metamod = false;
|
||||||
m_Handle = NULL;
|
m_Handle = NULL;
|
||||||
m_Status = MODULE_NONE;
|
m_Status = MODULE_NONE;
|
||||||
|
|
||||||
if (clearFilename)
|
if (clearFilename)
|
||||||
m_Filename.assign("unknown");
|
m_Filename.assign("unknown");
|
||||||
|
|
||||||
@ -114,6 +115,7 @@ bool CModule::attachModule()
|
|||||||
|
|
||||||
if (!AttachFunc_New)
|
if (!AttachFunc_New)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
g_ModuleCallReason = ModuleCall_Attach;
|
g_ModuleCallReason = ModuleCall_Attach;
|
||||||
g_CurrentlyCalledModule = this;
|
g_CurrentlyCalledModule = this;
|
||||||
int retVal = (*AttachFunc_New)(Module_ReqFnptr);
|
int retVal = (*AttachFunc_New)(Module_ReqFnptr);
|
||||||
@ -163,6 +165,7 @@ bool CModule::queryModule()
|
|||||||
|
|
||||||
// Try new interface first
|
// Try new interface first
|
||||||
QUERYMOD_NEW queryFunc_New = (QUERYMOD_NEW)DLPROC(m_Handle, "AMXX_Query");
|
QUERYMOD_NEW queryFunc_New = (QUERYMOD_NEW)DLPROC(m_Handle, "AMXX_Query");
|
||||||
|
|
||||||
if (queryFunc_New)
|
if (queryFunc_New)
|
||||||
{
|
{
|
||||||
m_Amxx = true;
|
m_Amxx = true;
|
||||||
@ -172,6 +175,7 @@ bool CModule::queryModule()
|
|||||||
int retVal = (*queryFunc_New)(&ifVers, &m_InfoNew);
|
int retVal = (*queryFunc_New)(&ifVers, &m_InfoNew);
|
||||||
g_CurrentlyCalledModule = NULL;
|
g_CurrentlyCalledModule = NULL;
|
||||||
g_ModuleCallReason = ModuleCall_NotCalled;
|
g_ModuleCallReason = ModuleCall_NotCalled;
|
||||||
|
|
||||||
switch (retVal)
|
switch (retVal)
|
||||||
{
|
{
|
||||||
case AMXX_PARAM:
|
case AMXX_PARAM:
|
||||||
@ -201,9 +205,7 @@ bool CModule::queryModule()
|
|||||||
|
|
||||||
m_Status = MODULE_QUERY;
|
m_Status = MODULE_QUERY;
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Status = MODULE_NOQUERY;
|
m_Status = MODULE_NOQUERY;
|
||||||
m_Amxx = false;
|
m_Amxx = false;
|
||||||
return false;
|
return false;
|
||||||
@ -218,6 +220,7 @@ bool CModule::detachModule()
|
|||||||
if (m_Amxx)
|
if (m_Amxx)
|
||||||
{
|
{
|
||||||
DETACHMOD_NEW detachFunc_New = (DETACHMOD_NEW)DLPROC(m_Handle, "AMXX_Detach");
|
DETACHMOD_NEW detachFunc_New = (DETACHMOD_NEW)DLPROC(m_Handle, "AMXX_Detach");
|
||||||
|
|
||||||
if (detachFunc_New)
|
if (detachFunc_New)
|
||||||
{
|
{
|
||||||
g_ModuleCallReason = ModuleCall_Detach;
|
g_ModuleCallReason = ModuleCall_Detach;
|
||||||
@ -227,14 +230,17 @@ bool CModule::detachModule()
|
|||||||
g_ModuleCallReason = ModuleCall_NotCalled;
|
g_ModuleCallReason = ModuleCall_NotCalled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef FAKEMETA
|
#ifndef FAKEMETA
|
||||||
if (IsMetamod())
|
if (IsMetamod())
|
||||||
{
|
{
|
||||||
UnloadMetamodPlugin(m_Handle);
|
UnloadMetamodPlugin(m_Handle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DLFREE(m_Handle);
|
DLFREE(m_Handle);
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,8 +253,10 @@ void CModule::CallPluginsLoaded()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
PLUGINSLOADED_NEW func = (PLUGINSLOADED_NEW)DLPROC(m_Handle, "AMXX_PluginsLoaded");
|
PLUGINSLOADED_NEW func = (PLUGINSLOADED_NEW)DLPROC(m_Handle, "AMXX_PluginsLoaded");
|
||||||
|
|
||||||
if (!func)
|
if (!func)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
func();
|
func();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,5 +278,6 @@ const char* CModule::getStatus() const
|
|||||||
case MODULE_NOT64BIT: return "not 64bit";
|
case MODULE_NOT64BIT: return "not 64bit";
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
#ifndef CMODULE_H
|
#ifndef CMODULE_H
|
||||||
#define CMODULE_H
|
#define CMODULE_H
|
||||||
|
|
||||||
enum MODULE_STATUS {
|
enum MODULE_STATUS
|
||||||
|
{
|
||||||
MODULE_NONE, // No module loaded
|
MODULE_NONE, // No module loaded
|
||||||
MODULE_QUERY, // Query failed
|
MODULE_QUERY, // Query failed
|
||||||
MODULE_BADLOAD, // Bad file or the module writer messed something up ;]
|
MODULE_BADLOAD, // Bad file or the module writer messed something up ;]
|
||||||
@ -60,7 +61,6 @@ struct amxx_module_info_s
|
|||||||
const char *logtag; //added in version 2
|
const char *logtag; //added in version 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define AMXX_OK 0 /* no error */
|
#define AMXX_OK 0 /* no error */
|
||||||
#define AMXX_IFVERS 1 /* interface version */
|
#define AMXX_IFVERS 1 /* interface version */
|
||||||
#define AMXX_PARAM 2 /* Invalid parameter */
|
#define AMXX_PARAM 2 /* Invalid parameter */
|
||||||
@ -71,8 +71,10 @@ struct amxx_module_info_s
|
|||||||
class CModule
|
class CModule
|
||||||
{
|
{
|
||||||
String m_Filename; // Filename
|
String m_Filename; // Filename
|
||||||
|
|
||||||
bool m_Metamod; // Using metamod?
|
bool m_Metamod; // Using metamod?
|
||||||
bool m_Amxx; // Using new module interface?
|
bool m_Amxx; // Using new module interface?
|
||||||
|
|
||||||
amxx_module_info_s m_InfoNew; // module info (new module interface)
|
amxx_module_info_s m_InfoNew; // module info (new module interface)
|
||||||
DLHANDLE m_Handle; // handle
|
DLHANDLE m_Handle; // handle
|
||||||
MODULE_STATUS m_Status; // status
|
MODULE_STATUS m_Status; // status
|
||||||
@ -84,12 +86,15 @@ public:
|
|||||||
~CModule();
|
~CModule();
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
bool attachModule();
|
bool attachModule();
|
||||||
bool queryModule();
|
bool queryModule();
|
||||||
bool detachModule();
|
bool detachModule();
|
||||||
|
|
||||||
#ifndef FAKEMETA
|
#ifndef FAKEMETA
|
||||||
bool attachMetamod(const char *mmfile, PLUG_LOADTIME now);
|
bool attachMetamod(const char *mmfile, PLUG_LOADTIME now);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* getStatus() const;
|
const char* getStatus() const;
|
||||||
inline const char* getType() const { return m_Amxx ? "amxx" : (m_Metamod ? "amx&mm" : "amx"); }
|
inline const char* getType() const { return m_Amxx ? "amxx" : (m_Metamod ? "amx&mm" : "amx"); }
|
||||||
inline const char* getAuthor() const { return m_InfoNew.author; }
|
inline const char* getAuthor() const { return m_InfoNew.author; }
|
||||||
@ -103,12 +108,10 @@ public:
|
|||||||
inline const char *getMissingFunc() const { return m_MissingFunc; }
|
inline const char *getMissingFunc() const { return m_MissingFunc; }
|
||||||
inline const char *getFilename() { return m_Filename.c_str(); }
|
inline const char *getFilename() { return m_Filename.c_str(); }
|
||||||
inline bool IsMetamod() { return m_Metamod; }
|
inline bool IsMetamod() { return m_Metamod; }
|
||||||
|
|
||||||
void CModule::CallPluginsLoaded();
|
void CModule::CallPluginsLoaded();
|
||||||
|
|
||||||
CList<AMX_NATIVE_INFO*> m_Natives;
|
CList<AMX_NATIVE_INFO*> m_Natives;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif //CMODULE_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,17 +35,24 @@
|
|||||||
#include "CFile.h"
|
#include "CFile.h"
|
||||||
#include "amx.h"
|
#include "amx.h"
|
||||||
#include "natives.h"
|
#include "natives.h"
|
||||||
|
#include "debugger.h"
|
||||||
|
|
||||||
extern const char *no_function;
|
extern const char *no_function;
|
||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::loadPlugin(const char* path, const char* name, char* error, int debug) {
|
CPluginMngr::CPlugin* CPluginMngr::loadPlugin(const char* path, const char* name, char* error, int debug)
|
||||||
|
{
|
||||||
CPlugin** a = &head;
|
CPlugin** a = &head;
|
||||||
while( *a ) a = &(*a)->next;
|
|
||||||
|
while (*a)
|
||||||
|
a = &(*a)->next;
|
||||||
|
|
||||||
*a = new CPlugin(pCounter++, path, name, error, debug);
|
*a = new CPlugin(pCounter++, path, name, error, debug);
|
||||||
|
|
||||||
return (*a);
|
return (*a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::unloadPlugin( CPlugin** a ) {
|
void CPluginMngr::unloadPlugin(CPlugin** a)
|
||||||
|
{
|
||||||
CPlugin* next = (*a)->next;
|
CPlugin* next = (*a)->next;
|
||||||
delete *a;
|
delete *a;
|
||||||
*a = next;
|
*a = next;
|
||||||
@ -56,9 +63,10 @@ void CPluginMngr::Finalize()
|
|||||||
{
|
{
|
||||||
if (m_Finalized)
|
if (m_Finalized)
|
||||||
return;
|
return;
|
||||||
pNatives = BuildNativeTable();
|
|
||||||
|
|
||||||
|
pNatives = BuildNativeTable();
|
||||||
CPlugin *a = head;
|
CPlugin *a = head;
|
||||||
|
|
||||||
while (a)
|
while (a)
|
||||||
{
|
{
|
||||||
if (a->getStatusCode() == ps_running)
|
if (a->getStatusCode() == ps_running)
|
||||||
@ -68,6 +76,7 @@ void CPluginMngr::Finalize()
|
|||||||
}
|
}
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Finalized = true;
|
m_Finalized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,12 +101,16 @@ int CPluginMngr::loadPluginsFromFile( const char* filename )
|
|||||||
while (!feof(fp))
|
while (!feof(fp))
|
||||||
{
|
{
|
||||||
pluginName[0] = '\0';
|
pluginName[0] = '\0';
|
||||||
|
|
||||||
debug[0] = '\0';
|
debug[0] = '\0';
|
||||||
debugFlag = 0;
|
debugFlag = 0;
|
||||||
|
|
||||||
line.clear();
|
line.clear();
|
||||||
line._fread(fp);
|
line._fread(fp);
|
||||||
sscanf(line.c_str(), "%s %s", pluginName, debug);
|
sscanf(line.c_str(), "%s %s", pluginName, debug);
|
||||||
if (!isalnum(*pluginName)) continue;
|
|
||||||
|
if (!isalnum(*pluginName))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (isalnum(*debug) && strcmp(debug, "debug") == 0)
|
if (isalnum(*debug) && strcmp(debug, "debug") == 0)
|
||||||
{
|
{
|
||||||
@ -120,11 +133,15 @@ int CPluginMngr::loadPluginsFromFile( const char* filename )
|
|||||||
return pCounter;
|
return pCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::clear() {
|
void CPluginMngr::clear()
|
||||||
|
{
|
||||||
CPlugin**a = &head;
|
CPlugin**a = &head;
|
||||||
|
|
||||||
while (*a)
|
while (*a)
|
||||||
unloadPlugin(a);
|
unloadPlugin(a);
|
||||||
|
|
||||||
m_Finalized = false;
|
m_Finalized = false;
|
||||||
|
|
||||||
if (pNatives)
|
if (pNatives)
|
||||||
{
|
{
|
||||||
delete [] pNatives;
|
delete [] pNatives;
|
||||||
@ -134,35 +151,51 @@ void CPluginMngr::clear() {
|
|||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::findPluginFast(AMX *amx)
|
CPluginMngr::CPlugin* CPluginMngr::findPluginFast(AMX *amx)
|
||||||
{
|
{
|
||||||
return (CPlugin*)(amx->userdata[3]);
|
return (CPlugin*)(amx->userdata[UD_FINDPLUGIN]);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx) {
|
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx)
|
||||||
|
{
|
||||||
CPlugin*a = head;
|
CPlugin*a = head;
|
||||||
|
|
||||||
while (a && &a->amx != amx)
|
while (a && &a->amx != amx)
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(int index){
|
CPluginMngr::CPlugin* CPluginMngr::findPlugin(int index)
|
||||||
|
{
|
||||||
CPlugin*a = head;
|
CPlugin*a = head;
|
||||||
|
|
||||||
while (a && index--)
|
while (a && index--)
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin* CPluginMngr::findPlugin(const char* name) {
|
CPluginMngr::CPlugin* CPluginMngr::findPlugin(const char* name)
|
||||||
if (!name) return 0;
|
{
|
||||||
|
if (!name)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int len = strlen(name);
|
int len = strlen(name);
|
||||||
if (!len) return 0;
|
|
||||||
|
if (!len)
|
||||||
|
return 0;
|
||||||
|
|
||||||
CPlugin*a = head;
|
CPlugin*a = head;
|
||||||
|
|
||||||
while (a && strncmp(a->name.c_str(), name, len))
|
while (a && strncmp(a->name.c_str(), name, len))
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CPluginMngr::CPlugin::getStatus() const {
|
const char* CPluginMngr::CPlugin::getStatus() const
|
||||||
switch(status){
|
{
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
case ps_running:
|
case ps_running:
|
||||||
{
|
{
|
||||||
if (m_Debug)
|
if (m_Debug)
|
||||||
@ -178,33 +211,41 @@ const char* CPluginMngr::CPlugin::getStatus() const {
|
|||||||
case ps_stopped: return "stopped";
|
case ps_stopped: return "stopped";
|
||||||
case ps_locked: return "locked";
|
case ps_locked: return "locked";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginMngr::CPlugin::CPlugin(int i, const char* p,const char* n, char* e, int d) : name(n), title(n) {
|
CPluginMngr::CPlugin::CPlugin(int i, const char* p, const char* n, char* e, int d) : name(n), title(n)
|
||||||
|
{
|
||||||
const char* unk = "unknown";
|
const char* unk = "unknown";
|
||||||
|
|
||||||
title.assign(unk);
|
title.assign(unk);
|
||||||
author.assign(unk);
|
author.assign(unk);
|
||||||
version.assign(unk);
|
version.assign(unk);
|
||||||
|
|
||||||
char file[256];
|
char file[256];
|
||||||
char* path = build_pathname_r(file, sizeof(file) - 1, "%s/%s", p, n);
|
char* path = build_pathname_r(file, sizeof(file) - 1, "%s/%s", p, n);
|
||||||
code = 0;
|
code = 0;
|
||||||
memset(&amx, 0, sizeof(AMX));
|
memset(&amx, 0, sizeof(AMX));
|
||||||
int err = load_amxscript(&amx, &code, path, e, d);
|
int err = load_amxscript(&amx, &code, path, e, d);
|
||||||
|
|
||||||
if (err == AMX_ERR_NONE)
|
if (err == AMX_ERR_NONE)
|
||||||
{
|
{
|
||||||
status = ps_running;
|
status = ps_running;
|
||||||
} else {
|
} else {
|
||||||
status = ps_bad_load;
|
status = ps_bad_load;
|
||||||
}
|
}
|
||||||
amx.userdata[3] = this;
|
|
||||||
|
amx.userdata[UD_FINDPLUGIN] = this;
|
||||||
paused_fun = 0;
|
paused_fun = 0;
|
||||||
next = 0;
|
next = 0;
|
||||||
id = i;
|
id = i;
|
||||||
|
|
||||||
if (status == ps_running)
|
if (status == ps_running)
|
||||||
{
|
{
|
||||||
m_PauseFwd = registerSPForwardByName(&amx, "plugin_pause");
|
m_PauseFwd = registerSPForwardByName(&amx, "plugin_pause");
|
||||||
m_UnpauseFwd = registerSPForwardByName(&amx, "plugin_unpause");
|
m_UnpauseFwd = registerSPForwardByName(&amx, "plugin_unpause");
|
||||||
|
|
||||||
if (amx.flags & AMX_FLAG_DEBUG)
|
if (amx.flags & AMX_FLAG_DEBUG)
|
||||||
{
|
{
|
||||||
m_Debug = true;
|
m_Debug = true;
|
||||||
@ -219,46 +260,103 @@ CPluginMngr::CPlugin::~CPlugin( )
|
|||||||
unload_amxscript(&amx, &code);
|
unload_amxscript(&amx, &code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AMXAPI native_handler(AMX *amx, int index)
|
||||||
|
{
|
||||||
|
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
||||||
|
|
||||||
|
char name[sNAMEMAX + 1];
|
||||||
|
amx_GetNative(amx, index, name);
|
||||||
|
|
||||||
|
return pHandler->HandleNative(name, index, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL invalid_native(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
//A script has accidentally called an invalid native! give them a
|
||||||
|
// first chance to block the resulting error.
|
||||||
|
|
||||||
|
Handler *pHandler = (Handler *)amx->userdata[UD_HANDLER];
|
||||||
|
|
||||||
|
//this should never happen
|
||||||
|
if (!pHandler)
|
||||||
|
{
|
||||||
|
LogError(amx, AMX_ERR_INVNATIVE, "Invalid native attempt");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//this should never happen because this native won't be called
|
||||||
|
// if the plugin isn't filtering.
|
||||||
|
if (!pHandler->IsNativeFiltering())
|
||||||
|
{
|
||||||
|
LogError(amx, AMX_ERR_INVNATIVE, "Invalid native attempt");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
char name[sNAMEMAX + 1];
|
||||||
|
int native = amx->usertags[UT_NATIVE];
|
||||||
|
int err = amx_GetNative(amx, native, name);
|
||||||
|
|
||||||
|
if (err != AMX_ERR_NONE)
|
||||||
|
name[0] = '\0';
|
||||||
|
|
||||||
|
//1 - because we're trapping usage
|
||||||
|
if (!pHandler->HandleNative(name, native, 1))
|
||||||
|
{
|
||||||
|
LogError(amx, AMX_ERR_INVNATIVE, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Someday maybe allow native filters to write their own return value?
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::Finalize()
|
void CPluginMngr::CPlugin::Finalize()
|
||||||
{
|
{
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
|
|
||||||
int old_status = status;
|
int old_status = status;
|
||||||
|
|
||||||
if (CheckModules(&amx, buffer))
|
if (CheckModules(&amx, buffer))
|
||||||
{
|
{
|
||||||
if (amx_Register(&amx, core_Natives, -1) != AMX_ERR_NONE)
|
if (amx_Register(&amx, core_Natives, -1) != AMX_ERR_NONE)
|
||||||
|
{
|
||||||
|
Handler *pHandler = (Handler *)amx.userdata[UD_HANDLER];
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
if (pHandler->IsNativeFiltering())
|
||||||
|
res = amx_CheckNatives(&amx, native_handler);
|
||||||
|
|
||||||
|
if (!res)
|
||||||
{
|
{
|
||||||
status = ps_bad_load;
|
status = ps_bad_load;
|
||||||
sprintf(buffer, "Plugin uses an unknown function (name \"%s\") - check your modules.ini.", no_function);
|
sprintf(buffer, "Plugin uses an unknown function (name \"%s\") - check your modules.ini.", no_function);
|
||||||
errorMsg.assign(buffer);
|
errorMsg.assign(buffer);
|
||||||
amx.error = AMX_ERR_NOTFOUND;
|
amx.error = AMX_ERR_NOTFOUND;
|
||||||
|
} else {
|
||||||
|
amx_RegisterToAny(&amx, invalid_native);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = ps_bad_load;
|
status = ps_bad_load;
|
||||||
errorMsg.assign(buffer);
|
errorMsg.assign(buffer);
|
||||||
amx.error = AMX_ERR_NOTFOUND;
|
amx.error = AMX_ERR_NOTFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_status != status)
|
if (old_status != status)
|
||||||
{
|
{
|
||||||
AMXXLOG_Log("[AMXX] Plugin \"%s\" failed to load: %s", name.c_str(), errorMsg.c_str());
|
AMXXLOG_Log("[AMXX] Plugin \"%s\" failed to load: %s", name.c_str(), errorMsg.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::pauseFunction( int id ) {
|
void CPluginMngr::CPlugin::pauseFunction(int id)
|
||||||
if (isValid()){
|
{
|
||||||
paused_fun |= (1<<id);
|
|
||||||
g_commands.clearBufforedInfo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::unpauseFunction( int id ) {
|
void CPluginMngr::CPlugin::unpauseFunction(int id)
|
||||||
if (isValid()) {
|
{
|
||||||
paused_fun &= ~(1<<id);
|
|
||||||
g_commands.clearBufforedInfo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginMngr::CPlugin::setStatus( int a ) {
|
void CPluginMngr::CPlugin::setStatus(int a)
|
||||||
|
{
|
||||||
status = a;
|
status = a;
|
||||||
g_commands.clearBufforedInfo(); // ugly way
|
g_commands.clearBufforedInfo(); // ugly way
|
||||||
}
|
}
|
||||||
@ -282,8 +380,8 @@ void CPluginMngr::CPlugin::unpausePlugin()
|
|||||||
if (isValid())
|
if (isValid())
|
||||||
{
|
{
|
||||||
// set status first so the function will be marked executable
|
// set status first so the function will be marked executable
|
||||||
|
|
||||||
setStatus(ps_running);
|
setStatus(ps_running);
|
||||||
|
|
||||||
// call plugin_unpause if provided
|
// call plugin_unpause if provided
|
||||||
if (m_UnpauseFwd != -1)
|
if (m_UnpauseFwd != -1)
|
||||||
executeForwards(m_UnpauseFwd);
|
executeForwards(m_UnpauseFwd);
|
||||||
|
@ -36,18 +36,18 @@
|
|||||||
// class CPluginMngr
|
// class CPluginMngr
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
ps_bad_load,
|
ps_bad_load,
|
||||||
ps_error,
|
ps_error,
|
||||||
ps_paused,
|
|
||||||
ps_running,
|
|
||||||
ps_stopped,
|
|
||||||
ps_locked,
|
ps_locked,
|
||||||
|
ps_paused,
|
||||||
|
ps_stopped,
|
||||||
|
ps_running,
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPluginMngr
|
class CPluginMngr
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class iterator;
|
class iterator;
|
||||||
@ -59,23 +59,25 @@ public:
|
|||||||
|
|
||||||
AMX amx;
|
AMX amx;
|
||||||
void* code;
|
void* code;
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
String version;
|
String version;
|
||||||
String title;
|
String title;
|
||||||
String author;
|
String author;
|
||||||
String errorMsg;
|
String errorMsg;
|
||||||
|
|
||||||
int m_PauseFwd;
|
int m_PauseFwd;
|
||||||
int m_UnpauseFwd;
|
int m_UnpauseFwd;
|
||||||
int paused_fun;
|
int paused_fun;
|
||||||
int status;
|
int status;
|
||||||
CPlugin* next;
|
CPlugin* next;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
CPlugin(int i, const char* p, const char* n, char* e, int d);
|
CPlugin(int i, const char* p, const char* n, char* e, int d);
|
||||||
~CPlugin();
|
~CPlugin();
|
||||||
|
|
||||||
bool m_Debug;
|
bool m_Debug;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline const char* getName() { return name.c_str();}
|
inline const char* getName() { return name.c_str();}
|
||||||
inline const char* getVersion() { return version.c_str();}
|
inline const char* getVersion() { return version.c_str();}
|
||||||
inline const char* getTitle() { return title.c_str();}
|
inline const char* getTitle() { return title.c_str();}
|
||||||
@ -89,16 +91,17 @@ public:
|
|||||||
inline void setAuthor(const char* n) { author.assign(n); }
|
inline void setAuthor(const char* n) { author.assign(n); }
|
||||||
inline void setVersion(const char* n) { version.assign(n); }
|
inline void setVersion(const char* n) { version.assign(n); }
|
||||||
inline void setError(const char* n) { errorMsg.assign(n); }
|
inline void setError(const char* n) { errorMsg.assign(n); }
|
||||||
inline bool isValid() const { return ((status == ps_running) && (status != ps_locked)); }
|
inline bool isValid() const { return (status >= ps_paused); }
|
||||||
inline bool isPaused() const { return ( (status == ps_paused) ); }
|
inline bool isPaused() const { return ((status == ps_paused) || (status == ps_stopped)); }
|
||||||
//inline bool isFunctionPaused( int id ) const { return (paused_fun & (1<<id)) ? true : false; }
|
|
||||||
inline bool isExecutable(int id) const { return (isValid() && !isPaused()); }
|
inline bool isExecutable(int id) const { return (isValid() && !isPaused()); }
|
||||||
|
|
||||||
void Finalize();
|
void Finalize();
|
||||||
void pausePlugin();
|
void pausePlugin();
|
||||||
void unpausePlugin();
|
void unpausePlugin();
|
||||||
void pauseFunction(int id);
|
void pauseFunction(int id);
|
||||||
void unpauseFunction(int id);
|
void unpauseFunction(int id);
|
||||||
void setStatus(int a);
|
void setStatus(int a);
|
||||||
|
|
||||||
const char* getStatus() const;
|
const char* getStatus() const;
|
||||||
inline bool isDebug() const { return m_Debug; }
|
inline bool isDebug() const { return m_Debug; }
|
||||||
};
|
};
|
||||||
@ -106,8 +109,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
CPlugin *head;
|
CPlugin *head;
|
||||||
int pCounter;
|
int pCounter;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CPluginMngr() { head = 0; pCounter = 0; pNatives = NULL; m_Finalized=false;}
|
CPluginMngr() { head = 0; pCounter = 0; pNatives = NULL; m_Finalized=false;}
|
||||||
~CPluginMngr() { clear(); }
|
~CPluginMngr() { clear(); }
|
||||||
@ -120,15 +121,18 @@ public:
|
|||||||
CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug);
|
CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug);
|
||||||
void unloadPlugin(CPlugin** a);
|
void unloadPlugin(CPlugin** a);
|
||||||
int loadPluginsFromFile(const char* filename);
|
int loadPluginsFromFile(const char* filename);
|
||||||
|
|
||||||
CPlugin* findPluginFast(AMX *amx);
|
CPlugin* findPluginFast(AMX *amx);
|
||||||
CPlugin* findPlugin(AMX *amx);
|
CPlugin* findPlugin(AMX *amx);
|
||||||
CPlugin* findPlugin(int index);
|
CPlugin* findPlugin(int index);
|
||||||
CPlugin* findPlugin(const char* name);
|
CPlugin* findPlugin(const char* name);
|
||||||
|
|
||||||
inline int getPluginsNum() const { return pCounter; }
|
inline int getPluginsNum() const { return pCounter; }
|
||||||
void Finalize();
|
void Finalize();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
class iterator {
|
class iterator
|
||||||
|
{
|
||||||
CPlugin *a;
|
CPlugin *a;
|
||||||
public:
|
public:
|
||||||
iterator(CPlugin*aa) : a(aa) {}
|
iterator(CPlugin*aa) : a(aa) {}
|
||||||
@ -138,10 +142,9 @@ public:
|
|||||||
operator bool () const { return a ? true : false; }
|
operator bool () const { return a ? true : false; }
|
||||||
CPlugin& operator*() { return *a; }
|
CPlugin& operator*() { return *a; }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline iterator begin() const { return iterator(head); }
|
inline iterator begin() const { return iterator(head); }
|
||||||
inline iterator end() const { return iterator(0); }
|
inline iterator end() const { return iterator(0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif //PLUGIN_H
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,14 +45,17 @@ public:
|
|||||||
item = i;
|
item = i;
|
||||||
next = n;
|
next = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
CQueueItem *GetNext()
|
CQueueItem *GetNext()
|
||||||
{
|
{
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
T & GetItem()
|
T & GetItem()
|
||||||
{
|
{
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetNext(CQueueItem *n)
|
void SetNext(CQueueItem *n)
|
||||||
{
|
{
|
||||||
next = n;
|
next = n;
|
||||||
@ -119,8 +122,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
CQueueItem *mFirst;
|
CQueueItem *mFirst;
|
||||||
CQueueItem *mLast;
|
CQueueItem *mLast;
|
||||||
|
|
||||||
unsigned int mSize;
|
unsigned int mSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_INCLUDE_CQUEUE_H
|
#endif //_INCLUDE_CQUEUE_H
|
||||||
|
|
||||||
|
@ -43,24 +43,29 @@ public:
|
|||||||
T item;
|
T item;
|
||||||
CStackItem *prev;
|
CStackItem *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CStack()
|
CStack()
|
||||||
{
|
{
|
||||||
mSize = 0;
|
mSize = 0;
|
||||||
mStack = NULL;
|
mStack = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
~CStack()
|
~CStack()
|
||||||
{
|
{
|
||||||
CStackItem *p, *t;
|
CStackItem *p, *t;
|
||||||
p = mStack;
|
p = mStack;
|
||||||
|
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
t = p->prev;
|
t = p->prev;
|
||||||
delete p;
|
delete p;
|
||||||
p = t;
|
p = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
mStack = NULL;
|
mStack = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty()
|
bool empty()
|
||||||
{
|
{
|
||||||
return (mSize == 0);
|
return (mSize == 0);
|
||||||
@ -98,4 +103,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif //_INCLUDE_CQUEUE_H
|
#endif //_INCLUDE_CQUEUE_H
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "CTask.h"
|
#include "CTask.h"
|
||||||
|
|
||||||
/*********************** CTask ***********************/
|
/*********************** CTask ***********************/
|
||||||
|
|
||||||
int CTaskMngr::CTask::getTaskId() const
|
int CTaskMngr::CTask::getTaskId() const
|
||||||
{
|
{
|
||||||
return m_iId;
|
return m_iId;
|
||||||
@ -53,8 +54,17 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags,
|
|||||||
m_iId = iId;
|
m_iId = iId;
|
||||||
m_fBase = fBase;
|
m_fBase = fBase;
|
||||||
|
|
||||||
m_iRepeat = (iFlags & 1) ? iRepeat : 0;
|
if (iFlags & 2)
|
||||||
m_bLoop = (iFlags & 2) ? true : false;
|
{
|
||||||
|
m_bLoop = true;
|
||||||
|
m_iRepeat = -1;
|
||||||
|
}
|
||||||
|
else if (iFlags & 1)
|
||||||
|
{
|
||||||
|
m_bLoop = true;
|
||||||
|
m_iRepeat = iRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
m_bAfterStart = (iFlags & 4) ? true : false;
|
m_bAfterStart = (iFlags & 4) ? true : false;
|
||||||
m_bBeforeEnd = (iFlags & 8) ? true : false;
|
m_bBeforeEnd = (iFlags & 8) ? true : false;
|
||||||
|
|
||||||
@ -118,6 +128,8 @@ void CTaskMngr::CTask::resetNextExecTime(float fCurrentTime)
|
|||||||
void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, float fTimeLeft)
|
void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, float fTimeLeft)
|
||||||
{
|
{
|
||||||
bool execute = false;
|
bool execute = false;
|
||||||
|
bool done = false;
|
||||||
|
|
||||||
if (m_bAfterStart)
|
if (m_bAfterStart)
|
||||||
{
|
{
|
||||||
if (fCurrentTime - fTimeLeft + 1.0f >= m_fBase)
|
if (fCurrentTime - fTimeLeft + 1.0f >= m_fBase)
|
||||||
@ -129,9 +141,14 @@ void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, f
|
|||||||
execute = true;
|
execute = true;
|
||||||
}
|
}
|
||||||
else if (m_fNextExecTime <= fCurrentTime)
|
else if (m_fNextExecTime <= fCurrentTime)
|
||||||
|
{
|
||||||
execute = true;
|
execute = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (execute)
|
if (execute)
|
||||||
|
{
|
||||||
|
//only bother calling if we have something to call
|
||||||
|
if (!(m_bLoop && !m_iRepeat))
|
||||||
{
|
{
|
||||||
if (m_iParamLen) // call with parameters
|
if (m_iParamLen) // call with parameters
|
||||||
{
|
{
|
||||||
@ -140,18 +157,25 @@ void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, f
|
|||||||
} else {
|
} else {
|
||||||
executeForwards(m_iFunc, m_iId);
|
executeForwards(m_iFunc, m_iId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isFree())
|
if (isFree())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// set new exec time OR remove the task if needed
|
// set new exec time OR remove the task if needed
|
||||||
if (m_bLoop || (m_iRepeat-- > 0))
|
if (m_bLoop)
|
||||||
{
|
{
|
||||||
m_fNextExecTime += m_fBase;
|
if (m_iRepeat != -1 && --m_iRepeat <= 0)
|
||||||
|
done = true;
|
||||||
|
} else {
|
||||||
|
done = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (done)
|
||||||
{
|
{
|
||||||
clear(); // hamster
|
clear();
|
||||||
|
} else {
|
||||||
|
m_fNextExecTime += m_fBase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,6 +206,7 @@ CTaskMngr::CTask::~CTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*********************** CTaskMngr ***********************/
|
/*********************** CTaskMngr ***********************/
|
||||||
|
|
||||||
CTaskMngr::CTaskMngr()
|
CTaskMngr::CTaskMngr()
|
||||||
{
|
{
|
||||||
m_pTmr_CurrentTime = NULL;
|
m_pTmr_CurrentTime = NULL;
|
||||||
@ -205,17 +230,18 @@ void CTaskMngr::registerTask(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlag
|
|||||||
{
|
{
|
||||||
// first, search for free tasks
|
// first, search for free tasks
|
||||||
TaskListIter iter = m_Tasks.find(CTaskDescriptor(0, NULL, true));
|
TaskListIter iter = m_Tasks.find(CTaskDescriptor(0, NULL, true));
|
||||||
|
|
||||||
if (iter)
|
if (iter)
|
||||||
{
|
{
|
||||||
// found: reuse it
|
// found: reuse it
|
||||||
iter->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
|
iter->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// not found: make a new one
|
// not found: make a new one
|
||||||
CTask *pTmp = new CTask;
|
CTask *pTmp = new CTask;
|
||||||
|
|
||||||
if (!pTmp)
|
if (!pTmp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pTmp->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
|
pTmp->set(pPlugin, iFunc, iFlags, iId, fBase, iParamsLen, pParams, iRepeat, *m_pTmr_CurrentTime);
|
||||||
m_Tasks.put(pTmp);
|
m_Tasks.put(pTmp);
|
||||||
}
|
}
|
||||||
@ -226,12 +252,14 @@ int CTaskMngr::removeTasks(int iId, AMX *pAmx)
|
|||||||
CTaskDescriptor descriptor(iId, pAmx);
|
CTaskDescriptor descriptor(iId, pAmx);
|
||||||
TaskListIter iter = m_Tasks.find(descriptor);
|
TaskListIter iter = m_Tasks.find(descriptor);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
iter->clear();
|
iter->clear();
|
||||||
++i;
|
++i;
|
||||||
iter = m_Tasks.find(++iter, descriptor);
|
iter = m_Tasks.find(++iter, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +268,7 @@ int CTaskMngr::changeTasks(int iId, AMX *pAmx, float fNewBase)
|
|||||||
CTaskDescriptor descriptor(iId, pAmx);
|
CTaskDescriptor descriptor(iId, pAmx);
|
||||||
TaskListIter iter = m_Tasks.find(descriptor);
|
TaskListIter iter = m_Tasks.find(descriptor);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (iter)
|
while (iter)
|
||||||
{
|
{
|
||||||
iter->changeBase(fNewBase);
|
iter->changeBase(fNewBase);
|
||||||
@ -247,6 +276,7 @@ int CTaskMngr::changeTasks(int iId, AMX *pAmx, float fNewBase)
|
|||||||
++i;
|
++i;
|
||||||
iter = m_Tasks.find(++iter, descriptor);
|
iter = m_Tasks.find(++iter, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,15 +39,18 @@ private:
|
|||||||
class CTask
|
class CTask
|
||||||
{
|
{
|
||||||
// task settings
|
// task settings
|
||||||
|
|
||||||
CPluginMngr::CPlugin *m_pPlugin;
|
CPluginMngr::CPlugin *m_pPlugin;
|
||||||
int m_iId;
|
int m_iId;
|
||||||
int m_iFunc;
|
int m_iFunc;
|
||||||
int m_iRepeat;
|
int m_iRepeat;
|
||||||
|
|
||||||
bool m_bLoop;
|
bool m_bLoop;
|
||||||
bool m_bAfterStart;
|
bool m_bAfterStart;
|
||||||
bool m_bBeforeEnd;
|
bool m_bBeforeEnd;
|
||||||
float m_fBase; // for normal tasks, stores the interval, for the others, stores the amount of time before start / after end
|
float m_fBase; // for normal tasks, stores the interval, for the others, stores the amount of time before start / after end
|
||||||
int m_iParamLen;
|
int m_iParamLen;
|
||||||
|
|
||||||
cell *m_pParams;
|
cell *m_pParams;
|
||||||
bool m_bFree;
|
bool m_bFree;
|
||||||
|
|
||||||
@ -91,16 +94,16 @@ private:
|
|||||||
if (right.m_bFree)
|
if (right.m_bFree)
|
||||||
return left.isFree();
|
return left.isFree();
|
||||||
|
|
||||||
return !left.isFree() &&
|
return !left.isFree() && (right.m_pAmx ? left.getPlugin()->getAMX() == right.m_pAmx : true) && left.getTaskId() == right.m_iId;
|
||||||
(right.m_pAmx ? left.getPlugin()->getAMX() == right.m_pAmx : true) &&
|
|
||||||
left.getTaskId() == right.m_iId;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*** CTaskMngr priv members ***/
|
/*** CTaskMngr priv members ***/
|
||||||
typedef CList<CTask, CTaskDescriptor> TaskList;
|
typedef CList<CTask, CTaskDescriptor> TaskList;
|
||||||
typedef TaskList::iterator TaskListIter;
|
typedef TaskList::iterator TaskListIter;
|
||||||
|
|
||||||
TaskList m_Tasks;
|
TaskList m_Tasks;
|
||||||
|
|
||||||
float *m_pTmr_CurrentTime;
|
float *m_pTmr_CurrentTime;
|
||||||
float *m_pTmr_TimeLimit;
|
float *m_pTmr_TimeLimit;
|
||||||
float *m_pTmr_TimeLeft;
|
float *m_pTmr_TimeLeft;
|
||||||
@ -110,13 +113,13 @@ public:
|
|||||||
|
|
||||||
void registerTimers(float *pCurrentTime, float *pTimeLimit, float *pTimeLeft); // The timers will always point to the right value
|
void registerTimers(float *pCurrentTime, float *pTimeLimit, float *pTimeLeft); // The timers will always point to the right value
|
||||||
void registerTask(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags, int iId, float fBase, int iParamsLen, const cell *pParams, int iRepeat);
|
void registerTask(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags, int iId, float fBase, int iParamsLen, const cell *pParams, int iRepeat);
|
||||||
|
|
||||||
int removeTasks(int iId, AMX *pAmx); // remove all tasks that match the id and amx
|
int removeTasks(int iId, AMX *pAmx); // remove all tasks that match the id and amx
|
||||||
int changeTasks(int iId, AMX *pAmx, float fNewBase); // change all tasks that match the id and amx
|
int changeTasks(int iId, AMX *pAmx, float fNewBase); // change all tasks that match the id and amx
|
||||||
bool taskExists(int iId, AMX *pAmx);
|
bool taskExists(int iId, AMX *pAmx);
|
||||||
|
|
||||||
void startFrame();
|
void startFrame();
|
||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif //CTASK_H
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class Vault
|
// class Vault
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
|
||||||
bool Vault::exists(const char* k)
|
bool Vault::exists(const char* k)
|
||||||
{
|
{
|
||||||
if (*k == 0) return false;
|
if (*k == 0) return false;
|
||||||
@ -65,10 +66,10 @@ void Vault::put( const char* k, const char* v )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
*a = new Obj(k, v);
|
*a = new Obj(k, v);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vault::Obj::Obj( const char* k, const char* v): key(k) , value(v) , next(0) {
|
Vault::Obj::Obj(const char* k, const char* v): key(k), value(v), next(0)
|
||||||
|
{
|
||||||
number = atoi(v);
|
number = atoi(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +137,6 @@ void Vault::setSource( const char* n )
|
|||||||
path.assign(n);
|
path.assign(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Vault::loadVault()
|
bool Vault::loadVault()
|
||||||
{
|
{
|
||||||
if (path.empty()) return false;
|
if (path.empty()) return false;
|
||||||
|
@ -45,6 +45,7 @@ class Vault
|
|||||||
{
|
{
|
||||||
String key;
|
String key;
|
||||||
String value;
|
String value;
|
||||||
|
|
||||||
int number;
|
int number;
|
||||||
Obj *next;
|
Obj *next;
|
||||||
Obj(const char* k, const char* v);
|
Obj(const char* k, const char* v);
|
||||||
@ -62,17 +63,21 @@ public:
|
|||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
bool exists(const char* k);
|
bool exists(const char* k);
|
||||||
|
|
||||||
void put(const char* k, const char* v);
|
void put(const char* k, const char* v);
|
||||||
void remove(const char* k);
|
void remove(const char* k);
|
||||||
|
|
||||||
const char* get(const char* n);
|
const char* get(const char* n);
|
||||||
int get_number(const char* n);
|
int get_number(const char* n);
|
||||||
void setSource(const char* n);
|
void setSource(const char* n);
|
||||||
|
|
||||||
bool loadVault();
|
bool loadVault();
|
||||||
bool saveVault();
|
bool saveVault();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
class iterator
|
||||||
class iterator {
|
{
|
||||||
Obj * a;
|
Obj * a;
|
||||||
public:
|
public:
|
||||||
iterator(Obj* aa) : a(aa) {}
|
iterator(Obj* aa) : a(aa) {}
|
||||||
@ -87,7 +92,4 @@ public:
|
|||||||
inline iterator end() const { return iterator(0); }
|
inline iterator end() const { return iterator(0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif //VAULT_CUSTOM_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,32 +70,58 @@ template <class T> class CVector
|
|||||||
// change size
|
// change size
|
||||||
if (size == m_Size)
|
if (size == m_Size)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!size)
|
||||||
|
{
|
||||||
|
if (m_Data)
|
||||||
|
{
|
||||||
|
delete [] m_Data;
|
||||||
|
m_Data = NULL;
|
||||||
|
m_Size = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
T *newData = new T[size];
|
T *newData = new T[size];
|
||||||
if (!newData)
|
if (!newData)
|
||||||
return false;
|
return false;
|
||||||
if (m_Data)
|
if (m_Data)
|
||||||
{
|
{
|
||||||
size_t end = (m_Size < size) ? (m_Size) : size;
|
size_t end = (m_CurrentUsedSize < size) ? (m_CurrentUsedSize) : size;
|
||||||
for (size_t i=0; i<end; i++)
|
for (size_t i=0; i<end; i++)
|
||||||
newData[i] = m_Data[i];
|
newData[i] = m_Data[i];
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
if (m_Size < size)
|
|
||||||
m_CurrentSize = size;
|
|
||||||
m_Data = newData;
|
m_Data = newData;
|
||||||
m_Size = size;
|
m_Size = size;
|
||||||
|
if (m_CurrentUsedSize > m_Size)
|
||||||
|
m_CurrentUsedSize = m_Size;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeMemIfPossible()
|
void FreeMemIfPossible()
|
||||||
{
|
{
|
||||||
|
if (!m_Data)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!m_CurrentUsedSize)
|
||||||
|
{
|
||||||
|
ChangeSize(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t newSize = m_Size;
|
||||||
|
while (m_CurrentUsedSize <= newSize / 2)
|
||||||
|
newSize /= 2;
|
||||||
|
|
||||||
|
if (newSize != m_Size)
|
||||||
|
ChangeSize(newSize);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
T *m_Data;
|
T *m_Data;
|
||||||
size_t m_Size;
|
size_t m_Size;
|
||||||
size_t m_CurrentUsedSize;
|
size_t m_CurrentUsedSize;
|
||||||
size_t m_CurrentSize;
|
|
||||||
public:
|
public:
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
@ -189,7 +215,7 @@ public:
|
|||||||
|
|
||||||
iterator & operator-=(size_t offset)
|
iterator & operator-=(size_t offset)
|
||||||
{
|
{
|
||||||
m_Ptr += offset;
|
m_Ptr -= offset;
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +229,7 @@ public:
|
|||||||
iterator operator-(size_t offset) const
|
iterator operator-(size_t offset) const
|
||||||
{
|
{
|
||||||
iterator tmp(*this);
|
iterator tmp(*this);
|
||||||
tmp.m_Ptr += offset;
|
tmp.m_Ptr -= offset;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,12 +303,12 @@ public:
|
|||||||
return m_Size;
|
return m_Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator begin()
|
iterator begin() const
|
||||||
{
|
{
|
||||||
return iterator(m_Data);
|
return iterator(m_Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator end()
|
iterator end() const
|
||||||
{
|
{
|
||||||
return iterator(m_Data + m_CurrentUsedSize);
|
return iterator(m_Data + m_CurrentUsedSize);
|
||||||
}
|
}
|
||||||
@ -296,7 +322,9 @@ public:
|
|||||||
|
|
||||||
bool reserve(size_t newSize)
|
bool reserve(size_t newSize)
|
||||||
{
|
{
|
||||||
|
if (newSize > m_Size)
|
||||||
return ChangeSize(newSize);
|
return ChangeSize(newSize);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool push_back(const T & elem)
|
bool push_back(const T & elem)
|
||||||
@ -317,14 +345,15 @@ public:
|
|||||||
--m_CurrentUsedSize;
|
--m_CurrentUsedSize;
|
||||||
if (m_CurrentUsedSize < 0)
|
if (m_CurrentUsedSize < 0)
|
||||||
m_CurrentUsedSize = 0;
|
m_CurrentUsedSize = 0;
|
||||||
// :TODO: free memory sometimes
|
|
||||||
|
FreeMemIfPossible();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool resize(size_t newSize)
|
bool resize(size_t newSize)
|
||||||
{
|
{
|
||||||
if (!ChangeSize(newSize))
|
if (!ChangeSize(newSize))
|
||||||
return false;
|
return false;
|
||||||
FreeMemIfPossible();
|
m_CurrentUsedSize = newSize;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,15 +426,13 @@ public:
|
|||||||
return m_Data[m_CurrentUsedSize - 1];
|
return m_Data[m_CurrentUsedSize - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool insert(iterator where, const T & value)
|
iterator insert(iterator where, const T & value)
|
||||||
{
|
{
|
||||||
// we have to insert before
|
|
||||||
// if it is begin, don't decrement
|
|
||||||
if (where != m_Data)
|
|
||||||
--where;
|
|
||||||
// validate iter
|
// validate iter
|
||||||
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
|
if (where < m_Data || where > (m_Data + m_CurrentUsedSize))
|
||||||
return false;
|
return iterator(0);
|
||||||
|
|
||||||
|
size_t ofs = where - begin();
|
||||||
|
|
||||||
++m_CurrentUsedSize;
|
++m_CurrentUsedSize;
|
||||||
if (!GrowIfNeeded())
|
if (!GrowIfNeeded())
|
||||||
@ -414,34 +441,50 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(where.base() + 1, where.base(), m_CurrentUsedSize - (where - m_Data));
|
where = begin() + ofs;
|
||||||
memcpy(where.base(), &value, sizeof(T));
|
|
||||||
return true;
|
// Move subsequent entries
|
||||||
|
for (T *ptr = m_Data + m_CurrentUsedSize - 2; ptr >= where.base(); --ptr)
|
||||||
|
*(ptr + 1) = *ptr;
|
||||||
|
|
||||||
|
*where.base() = value;
|
||||||
|
|
||||||
|
return where;
|
||||||
}
|
}
|
||||||
|
|
||||||
void erase(iterator where)
|
iterator erase(iterator where)
|
||||||
{
|
{
|
||||||
// validate iter
|
// validate iter
|
||||||
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
|
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
|
||||||
return false;
|
return iterator(0);
|
||||||
|
|
||||||
|
size_t ofs = where - begin();
|
||||||
|
|
||||||
if (m_CurrentUsedSize > 1)
|
if (m_CurrentUsedSize > 1)
|
||||||
{
|
{
|
||||||
// move
|
// move
|
||||||
memmove(where.base(), where.base() + 1, m_CurrentUsedSize - 1);
|
T *theend = m_Data + m_CurrentUsedSize;
|
||||||
|
for (T *ptr = where.base() + 1; ptr < theend; ++ptr)
|
||||||
|
*(ptr - 1) = *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
--m_CurrentUsedSize;
|
--m_CurrentUsedSize;
|
||||||
// :TODO: free memory sometimes
|
|
||||||
|
FreeMemIfPossible();
|
||||||
|
|
||||||
|
return begin() + ofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
m_Size = 0;
|
m_Size = 0;
|
||||||
m_CurrentUsedSize = 0;
|
m_CurrentUsedSize = 0;
|
||||||
|
if (m_Data)
|
||||||
|
{
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
m_Data = NULL;
|
m_Data = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __CVECTOR_H__
|
#endif // __CVECTOR_H__
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -6,7 +6,7 @@ MM_ROOT = ../metamod/metamod
|
|||||||
|
|
||||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||||
|
|
||||||
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
|
OPT_FLAGS = -O2 -funroll-loops -s -pipe
|
||||||
DEBUG_FLAGS = -g -ggdb3
|
DEBUG_FLAGS = -g -ggdb3
|
||||||
CPP = gcc
|
CPP = gcc
|
||||||
NAME = amxmodx_mm
|
NAME = amxmodx_mm
|
||||||
@ -15,7 +15,7 @@ OBJECTS = meta_api.cpp CFile.cpp CVault.cpp vault.cpp float.cpp file.cpp modules
|
|||||||
CMisc.cpp CTask.cpp string.cpp amxmodx.cpp CEvent.cpp CCmd.cpp CLogEvent.cpp \
|
CMisc.cpp CTask.cpp string.cpp amxmodx.cpp CEvent.cpp CCmd.cpp CLogEvent.cpp \
|
||||||
srvcmd.cpp strptime.cpp amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp \
|
srvcmd.cpp strptime.cpp amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp \
|
||||||
amxxfile.cpp CLang.cpp md5.cpp emsg.cpp CForward.cpp CPlugin.cpp CModule.cpp \
|
amxxfile.cpp CLang.cpp md5.cpp emsg.cpp CForward.cpp CPlugin.cpp CModule.cpp \
|
||||||
CMenu.cpp util.cpp amx.cpp amxdbg.cpp natives.cpp newmenus.cpp \
|
CMenu.cpp util.cpp amx.cpp amxdbg.cpp natives.cpp newmenus.cpp debugger.cpp
|
||||||
|
|
||||||
LINK = -lz
|
LINK = -lz
|
||||||
|
|
||||||
@ -31,16 +31,16 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq "$(MMGR)" "true"
|
ifeq "$(MMGR)" "true"
|
||||||
OBJECTS += MMGR/MMGR.CPP
|
OBJECTS += mmgr/mmgr.cpp
|
||||||
|
CFLAGS += -DMEMORY_TEST
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -DLINUX -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H
|
CFLAGS += -DLINUX -DNDEBUG -fPIC -Wno-deprecated -DHAVE_STDINT_H -static-libgcc -fno-rtti -fno-exceptions
|
||||||
|
|
||||||
ifeq "$(AMD64)" "true"
|
ifeq "$(AMD64)" "true"
|
||||||
BINARY = $(NAME)_amd64.so
|
BINARY = $(NAME)_amd64.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
||||||
OBJECTS += JIT/natives-amd64.o
|
OBJECTS += JIT/natives-amd64.o
|
||||||
LINK += -lstdc++
|
|
||||||
else
|
else
|
||||||
BINARY = $(NAME)_i386.so
|
BINARY = $(NAME)_i386.so
|
||||||
OBJECTS += JIT/amxexecn.o JIT/amxjitsn.o JIT/natives-x86.o
|
OBJECTS += JIT/amxexecn.o JIT/amxjitsn.o JIT/natives-x86.o
|
||||||
|
122
amxmodx/amx.cpp
122
amxmodx/amx.cpp
@ -10,7 +10,7 @@
|
|||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 1. The origin of this software must not be misreprfesented; you must not
|
||||||
* claim that you wrote the original software. If you use this software in
|
* claim that you wrote the original software. If you use this software in
|
||||||
* a product, an acknowledgment in the product documentation would be
|
* a product, an acknowledgment in the product documentation would be
|
||||||
* appreciated but is not required.
|
* appreciated but is not required.
|
||||||
@ -425,10 +425,7 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
|
|||||||
AMX_FUNCSTUB *func;
|
AMX_FUNCSTUB *func;
|
||||||
AMX_NATIVE f;
|
AMX_NATIVE f;
|
||||||
|
|
||||||
assert(amx!=NULL);
|
|
||||||
hdr=(AMX_HEADER *)amx->base;
|
hdr=(AMX_HEADER *)amx->base;
|
||||||
assert(hdr!=NULL);
|
|
||||||
assert(hdr->magic==AMX_MAGIC);
|
|
||||||
assert(hdr->natives<=hdr->libraries);
|
assert(hdr->natives<=hdr->libraries);
|
||||||
#if defined AMX_NATIVETABLE
|
#if defined AMX_NATIVETABLE
|
||||||
if (index<NULL) {
|
if (index<NULL) {
|
||||||
@ -444,34 +441,10 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
|
|||||||
#endif
|
#endif
|
||||||
assert(f!=NULL);
|
assert(f!=NULL);
|
||||||
|
|
||||||
/* Now that we have found the function, patch the program so that any
|
/* As of AMX Mod X 1.56, we don't patch sysreq.c to sysreq.d anymore.
|
||||||
* subsequent call will call the function directly (bypassing this
|
* Otherwise, we'd have no way of knowing the last native to be used.
|
||||||
* callback).
|
|
||||||
* This trick cannot work in the JIT, because the program would need to
|
|
||||||
* be re-JIT-compiled after patching a P-code instruction.
|
|
||||||
*/
|
*/
|
||||||
#if defined JIT && !defined NDEBUG
|
amx->usertags[UT_NATIVE] = (long)index;
|
||||||
if ((amx->flags & AMX_FLAG_JITC)!=0)
|
|
||||||
assert(amx->sysreq_d==0);
|
|
||||||
#endif
|
|
||||||
if (amx->sysreq_d!=0) {
|
|
||||||
/* at the point of the call, the CIP pseudo-register points directly
|
|
||||||
* behind the SYSREQ instruction and its parameter.
|
|
||||||
*/
|
|
||||||
unsigned char *code=amx->base+(int)hdr->cod+(int)amx->cip-4;
|
|
||||||
assert(amx->cip >= 4 && amx->cip < (hdr->dat - hdr->cod));
|
|
||||||
assert(sizeof(f)<=sizeof(cell)); /* function pointer must fit in a cell */
|
|
||||||
#if defined __GNUC__ || defined ASM32
|
|
||||||
if (*(cell*)code==index) {
|
|
||||||
#else
|
|
||||||
if (*(cell*)code!=OP_SYSREQ_PRI) {
|
|
||||||
assert(*(cell*)(code-sizeof(cell))==OP_SYSREQ_C);
|
|
||||||
assert(*(cell*)code==index);
|
|
||||||
#endif
|
|
||||||
*(cell*)(code-sizeof(cell))=amx->sysreq_d;
|
|
||||||
*(cell*)code=(cell)f;
|
|
||||||
} /* if */
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
/* Note:
|
/* Note:
|
||||||
* params[0] == number of bytes for the additional parameters passed to the native function
|
* params[0] == number of bytes for the additional parameters passed to the native function
|
||||||
@ -480,7 +453,9 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
amx->error=AMX_ERR_NONE;
|
amx->error=AMX_ERR_NONE;
|
||||||
|
|
||||||
*result = f(amx,params);
|
*result = f(amx,params);
|
||||||
|
|
||||||
return amx->error;
|
return amx->error;
|
||||||
}
|
}
|
||||||
#endif /* defined AMX_INIT */
|
#endif /* defined AMX_INIT */
|
||||||
@ -547,6 +522,7 @@ static int amx_BrowseRelocate(AMX *amx)
|
|||||||
*/
|
*/
|
||||||
if ((amx->flags & AMX_FLAG_JITC)==0 && sizeof(AMX_NATIVE)<=sizeof(cell))
|
if ((amx->flags & AMX_FLAG_JITC)==0 && sizeof(AMX_NATIVE)<=sizeof(cell))
|
||||||
amx->sysreq_d=opcode_list[OP_SYSREQ_D];
|
amx->sysreq_d=opcode_list[OP_SYSREQ_D];
|
||||||
|
amx->userdata[UD_OPCODELIST] = (void *)opcode_list;
|
||||||
#else
|
#else
|
||||||
/* ANSI C
|
/* ANSI C
|
||||||
* to use direct system requests, a function pointer must fit in a cell;
|
* to use direct system requests, a function pointer must fit in a cell;
|
||||||
@ -554,6 +530,7 @@ static int amx_BrowseRelocate(AMX *amx)
|
|||||||
*/
|
*/
|
||||||
if (sizeof(AMX_NATIVE)<=sizeof(cell))
|
if (sizeof(AMX_NATIVE)<=sizeof(cell))
|
||||||
amx->sysreq_d=OP_SYSREQ_D;
|
amx->sysreq_d=OP_SYSREQ_D;
|
||||||
|
amx->userdata[UD_OPCODELIST] = (long)NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* start browsing code */
|
/* start browsing code */
|
||||||
@ -1081,7 +1058,9 @@ int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
|
|||||||
|
|
||||||
/* JIT rulz! (TM) */
|
/* JIT rulz! (TM) */
|
||||||
/* MP: added check for correct compilation */
|
/* MP: added check for correct compilation */
|
||||||
if ((res = asm_runJIT(amx->base, reloc_table, native_code)) != 0) {
|
//Fixed bug (thanks T(+)rget)
|
||||||
|
if ((res = asm_runJIT(amx->base, reloc_table, native_code)) == 0)
|
||||||
|
{
|
||||||
/* update the required memory size (the previous value was a
|
/* update the required memory size (the previous value was a
|
||||||
* conservative estimate, now we know the exact size)
|
* conservative estimate, now we know the exact size)
|
||||||
*/
|
*/
|
||||||
@ -1561,6 +1540,61 @@ static AMX_NATIVE findfunction(const char *name, const AMX_NATIVE_INFO *list, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *no_function;
|
const char *no_function;
|
||||||
|
|
||||||
|
int AMXAPI amx_CheckNatives(AMX *amx, AMX_NATIVE_FILTER nf)
|
||||||
|
{
|
||||||
|
AMX_FUNCSTUB *func;
|
||||||
|
AMX_HEADER *hdr;
|
||||||
|
int i,numnatives,res=0;
|
||||||
|
|
||||||
|
hdr=(AMX_HEADER *)amx->base;
|
||||||
|
assert(hdr!=NULL);
|
||||||
|
assert(hdr->magic==AMX_MAGIC);
|
||||||
|
assert(hdr->natives<=hdr->libraries);
|
||||||
|
numnatives=NUMENTRIES(hdr,natives,libraries);
|
||||||
|
|
||||||
|
func=GETENTRY(hdr,natives,0);
|
||||||
|
for (i=0; i<numnatives; i++) {
|
||||||
|
if (func->address==0) {
|
||||||
|
/* this function is not yet located */
|
||||||
|
res=nf(amx,i);
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
no_function = GETENTRYNAME(hdr,func);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} /* if */
|
||||||
|
func=(AMX_FUNCSTUB*)((unsigned char*)func+hdr->defsize);
|
||||||
|
} /* for */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AMXAPI amx_RegisterToAny(AMX *amx, AMX_NATIVE f)
|
||||||
|
{
|
||||||
|
AMX_FUNCSTUB *func;
|
||||||
|
AMX_HEADER *hdr;
|
||||||
|
int i,numnatives,err;
|
||||||
|
|
||||||
|
hdr=(AMX_HEADER *)amx->base;
|
||||||
|
assert(hdr!=NULL);
|
||||||
|
assert(hdr->magic==AMX_MAGIC);
|
||||||
|
assert(hdr->natives<=hdr->libraries);
|
||||||
|
numnatives=NUMENTRIES(hdr,natives,libraries);
|
||||||
|
|
||||||
|
err=AMX_ERR_NONE;
|
||||||
|
func=GETENTRY(hdr,natives,0);
|
||||||
|
for (i=0; i<numnatives; i++) {
|
||||||
|
if (func->address==0) {
|
||||||
|
/* this function is not yet located */
|
||||||
|
func->address=(ucell)f;
|
||||||
|
} /* if */
|
||||||
|
func=(AMX_FUNCSTUB*)((unsigned char*)func+hdr->defsize);
|
||||||
|
} /* for */
|
||||||
|
if (err==AMX_ERR_NONE)
|
||||||
|
amx->flags|=AMX_FLAG_NTVREG;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *list, int number)
|
int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *list, int number)
|
||||||
{
|
{
|
||||||
AMX_FUNCSTUB *func;
|
AMX_FUNCSTUB *func;
|
||||||
@ -1674,7 +1708,13 @@ int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char
|
|||||||
#define SKIPPARAM(n) ( cip=(cell *)cip+(n) )
|
#define SKIPPARAM(n) ( cip=(cell *)cip+(n) )
|
||||||
#define PUSH(v) ( stk-=sizeof(cell), *(cell *)(data+(int)stk)=v )
|
#define PUSH(v) ( stk-=sizeof(cell), *(cell *)(data+(int)stk)=v )
|
||||||
#define POP(v) ( v=*(cell *)(data+(int)stk), stk+=sizeof(cell) )
|
#define POP(v) ( v=*(cell *)(data+(int)stk), stk+=sizeof(cell) )
|
||||||
#define ABORT(amx,v) { (amx)->stk=reset_stk; (amx)->hea=reset_hea; return v; }
|
#define ABORT(amx,v) { (amx)->stk=reset_stk; \
|
||||||
|
(amx)->hea=reset_hea; \
|
||||||
|
(amx)->cip=(cell)cip; \
|
||||||
|
(amx)->pri=pri; \
|
||||||
|
(amx)->alt=alt; \
|
||||||
|
return v; \
|
||||||
|
}
|
||||||
|
|
||||||
#define CHKMARGIN() if (hea+STKMARGIN>stk) return AMX_ERR_STACKERR
|
#define CHKMARGIN() if (hea+STKMARGIN>stk) return AMX_ERR_STACKERR
|
||||||
#define CHKSTACK() if (stk>amx->stp) return AMX_ERR_STACKLOW
|
#define CHKSTACK() if (stk>amx->stp) return AMX_ERR_STACKLOW
|
||||||
@ -2469,6 +2509,8 @@ static const void * const amx_opcodelist[] = {
|
|||||||
amx->hea=hea;
|
amx->hea=hea;
|
||||||
amx->frm=frm;
|
amx->frm=frm;
|
||||||
amx->stk=stk;
|
amx->stk=stk;
|
||||||
|
amx->pri=pri;
|
||||||
|
amx->alt=alt;
|
||||||
num=amx->callback(amx,pri,&pri,(cell *)(data+(int)stk));
|
num=amx->callback(amx,pri,&pri,(cell *)(data+(int)stk));
|
||||||
if (num!=AMX_ERR_NONE) {
|
if (num!=AMX_ERR_NONE) {
|
||||||
if (num==AMX_ERR_SLEEP) {
|
if (num==AMX_ERR_SLEEP) {
|
||||||
@ -2488,6 +2530,8 @@ static const void * const amx_opcodelist[] = {
|
|||||||
amx->hea=hea;
|
amx->hea=hea;
|
||||||
amx->frm=frm;
|
amx->frm=frm;
|
||||||
amx->stk=stk;
|
amx->stk=stk;
|
||||||
|
amx->pri=pri;
|
||||||
|
amx->alt=alt;
|
||||||
num=amx->callback(amx,offs,&pri,(cell *)(data+(int)stk));
|
num=amx->callback(amx,offs,&pri,(cell *)(data+(int)stk));
|
||||||
if (num!=AMX_ERR_NONE) {
|
if (num!=AMX_ERR_NONE) {
|
||||||
if (num==AMX_ERR_SLEEP) {
|
if (num==AMX_ERR_SLEEP) {
|
||||||
@ -2507,6 +2551,8 @@ static const void * const amx_opcodelist[] = {
|
|||||||
amx->hea=hea;
|
amx->hea=hea;
|
||||||
amx->frm=frm;
|
amx->frm=frm;
|
||||||
amx->stk=stk;
|
amx->stk=stk;
|
||||||
|
amx->pri=pri;
|
||||||
|
amx->alt=alt;
|
||||||
pri=((AMX_NATIVE)offs)(amx,(cell *)(data+(int)stk));
|
pri=((AMX_NATIVE)offs)(amx,(cell *)(data+(int)stk));
|
||||||
if (amx->error!=AMX_ERR_NONE) {
|
if (amx->error!=AMX_ERR_NONE) {
|
||||||
if (amx->error==AMX_ERR_SLEEP) {
|
if (amx->error==AMX_ERR_SLEEP) {
|
||||||
@ -2576,6 +2622,8 @@ static const void * const amx_opcodelist[] = {
|
|||||||
amx->frm=frm;
|
amx->frm=frm;
|
||||||
amx->stk=stk;
|
amx->stk=stk;
|
||||||
amx->hea=hea;
|
amx->hea=hea;
|
||||||
|
amx->pri=pri;
|
||||||
|
amx->alt=alt;
|
||||||
amx->cip=(cell)((unsigned char*)cip-code);
|
amx->cip=(cell)((unsigned char*)cip-code);
|
||||||
num=amx->debug(amx);
|
num=amx->debug(amx);
|
||||||
if (num!=AMX_ERR_NONE) {
|
if (num!=AMX_ERR_NONE) {
|
||||||
@ -3443,6 +3491,8 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
|
|||||||
amx->hea=hea;
|
amx->hea=hea;
|
||||||
amx->frm=frm;
|
amx->frm=frm;
|
||||||
amx->stk=stk;
|
amx->stk=stk;
|
||||||
|
amx->pri=pri;
|
||||||
|
amx->alt=alt;
|
||||||
num=amx->callback(amx,pri,&pri,(cell *)(data+(int)stk));
|
num=amx->callback(amx,pri,&pri,(cell *)(data+(int)stk));
|
||||||
if (num!=AMX_ERR_NONE) {
|
if (num!=AMX_ERR_NONE) {
|
||||||
if (num==AMX_ERR_SLEEP) {
|
if (num==AMX_ERR_SLEEP) {
|
||||||
@ -3462,6 +3512,8 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
|
|||||||
amx->hea=hea;
|
amx->hea=hea;
|
||||||
amx->frm=frm;
|
amx->frm=frm;
|
||||||
amx->stk=stk;
|
amx->stk=stk;
|
||||||
|
amx->pri=pri;
|
||||||
|
amx->alt=alt;
|
||||||
num=amx->callback(amx,offs,&pri,(cell *)(data+(int)stk));
|
num=amx->callback(amx,offs,&pri,(cell *)(data+(int)stk));
|
||||||
if (num!=AMX_ERR_NONE) {
|
if (num!=AMX_ERR_NONE) {
|
||||||
if (num==AMX_ERR_SLEEP) {
|
if (num==AMX_ERR_SLEEP) {
|
||||||
@ -3481,6 +3533,8 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
|
|||||||
amx->hea=hea;
|
amx->hea=hea;
|
||||||
amx->frm=frm;
|
amx->frm=frm;
|
||||||
amx->stk=stk;
|
amx->stk=stk;
|
||||||
|
amx->pri=pri;
|
||||||
|
amx->alt=alt;
|
||||||
pri=((AMX_NATIVE)offs)(amx,(cell *)(data+(int)stk));
|
pri=((AMX_NATIVE)offs)(amx,(cell *)(data+(int)stk));
|
||||||
if (amx->error!=AMX_ERR_NONE) {
|
if (amx->error!=AMX_ERR_NONE) {
|
||||||
if (amx->error==AMX_ERR_SLEEP) {
|
if (amx->error==AMX_ERR_SLEEP) {
|
||||||
@ -3544,6 +3598,8 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
|
|||||||
amx->frm=frm;
|
amx->frm=frm;
|
||||||
amx->stk=stk;
|
amx->stk=stk;
|
||||||
amx->hea=hea;
|
amx->hea=hea;
|
||||||
|
amx->pri=pri;
|
||||||
|
amx->alt=alt;
|
||||||
amx->cip=(cell)((unsigned char*)cip-code);
|
amx->cip=(cell)((unsigned char*)cip-code);
|
||||||
num=amx->debug(amx);
|
num=amx->debug(amx);
|
||||||
if (num!=AMX_ERR_NONE) {
|
if (num!=AMX_ERR_NONE) {
|
||||||
|
@ -166,6 +166,7 @@ typedef cell (AMX_NATIVE_CALL *AMX_NATIVE)(struct tagAMX *amx, cell *params);
|
|||||||
typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index,
|
typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index,
|
||||||
cell *result, cell *params);
|
cell *result, cell *params);
|
||||||
typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx);
|
typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx);
|
||||||
|
typedef int (AMXAPI *AMX_NATIVE_FILTER)(struct tagAMX *amx, int index);
|
||||||
#if !defined _FAR
|
#if !defined _FAR
|
||||||
#define _FAR
|
#define _FAR
|
||||||
#endif
|
#endif
|
||||||
@ -242,6 +243,7 @@ typedef struct tagAMX {
|
|||||||
long usertags[AMX_USERNUM] PACKED;
|
long usertags[AMX_USERNUM] PACKED;
|
||||||
//okay userdata[3] in AMX Mod X is for the CPlugin * pointer
|
//okay userdata[3] in AMX Mod X is for the CPlugin * pointer
|
||||||
//we're also gonna set userdata[2] to a special debug structure
|
//we're also gonna set userdata[2] to a special debug structure
|
||||||
|
//lastly, userdata[1] is for opcode_list from amx_BrowseRelocate
|
||||||
void _FAR *userdata[AMX_USERNUM] PACKED;
|
void _FAR *userdata[AMX_USERNUM] PACKED;
|
||||||
/* native functions can raise an error */
|
/* native functions can raise an error */
|
||||||
int error PACKED;
|
int error PACKED;
|
||||||
@ -300,6 +302,7 @@ enum {
|
|||||||
AMX_ERR_DIVIDE, /* divide by zero */
|
AMX_ERR_DIVIDE, /* divide by zero */
|
||||||
AMX_ERR_SLEEP, /* go into sleepmode - code can be restarted */
|
AMX_ERR_SLEEP, /* go into sleepmode - code can be restarted */
|
||||||
AMX_ERR_INVSTATE, /* invalid state for this access */
|
AMX_ERR_INVSTATE, /* invalid state for this access */
|
||||||
|
AMX_ERR_INVNATIVE, /* invalid native was used */
|
||||||
|
|
||||||
AMX_ERR_MEMORY = 16, /* out of memory */
|
AMX_ERR_MEMORY = 16, /* out of memory */
|
||||||
AMX_ERR_FORMAT, /* invalid file format */
|
AMX_ERR_FORMAT, /* invalid file format */
|
||||||
@ -335,23 +338,11 @@ enum {
|
|||||||
#define AMX_COMPACTMARGIN 64
|
#define AMX_COMPACTMARGIN 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct amx_trace
|
#define UD_FINDPLUGIN 3
|
||||||
{
|
#define UD_DEBUGGER 2
|
||||||
cell frm;
|
#define UD_OPCODELIST 1
|
||||||
amx_trace *prev;
|
#define UD_HANDLER 0
|
||||||
amx_trace *next;
|
#define UT_NATIVE 3
|
||||||
bool used;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct AMX_DBGINFO
|
|
||||||
{
|
|
||||||
void *pDebug; //Pointer to debug data
|
|
||||||
int error; //non-amx_Exec() error setting
|
|
||||||
amx_trace *pTrace; //Pointer to stack trace
|
|
||||||
amx_trace *pTraceFrm;
|
|
||||||
amx_trace *pTraceEnd;
|
|
||||||
cell frm;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* for native functions that use floating point parameters, the following
|
/* for native functions that use floating point parameters, the following
|
||||||
* two macros are convenient for casting a "cell" into a "float" type _without_
|
* two macros are convenient for casting a "cell" into a "float" type _without_
|
||||||
@ -385,6 +376,7 @@ uint32_t * AMXAPI amx_Align32(uint32_t *v);
|
|||||||
#endif
|
#endif
|
||||||
int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
|
int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
|
||||||
int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params);
|
int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params);
|
||||||
|
int AMXAPI amx_CheckNatives(AMX *amx, AMX_NATIVE_FILTER nf);
|
||||||
int AMXAPI amx_Cleanup(AMX *amx);
|
int AMXAPI amx_Cleanup(AMX *amx);
|
||||||
int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data);
|
int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data);
|
||||||
int AMXAPI amx_Exec(AMX *amx, cell *retval, int index);
|
int AMXAPI amx_Exec(AMX *amx, cell *retval, int index);
|
||||||
@ -414,6 +406,7 @@ int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell
|
|||||||
int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar);
|
int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar);
|
||||||
int AMXAPI amx_RaiseError(AMX *amx, int error);
|
int AMXAPI amx_RaiseError(AMX *amx, int error);
|
||||||
int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number);
|
int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number);
|
||||||
|
int AMXAPI amx_RegisterToAny(AMX *amx, AMX_NATIVE f);
|
||||||
int AMXAPI amx_Release(AMX *amx, cell amx_addr);
|
int AMXAPI amx_Release(AMX *amx, cell amx_addr);
|
||||||
int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback);
|
int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback);
|
||||||
int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug);
|
int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug);
|
||||||
|
@ -129,6 +129,28 @@
|
|||||||
jg near err_stack
|
jg near err_stack
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
|
;Normal abort, saves pri/alt
|
||||||
|
%macro _ABORT 1
|
||||||
|
mov ebp,amx
|
||||||
|
mov [ebp+_pri], dword eax ; store values in AMX structure (PRI, ALT)
|
||||||
|
mov [ebp+_alt], dword edx ; store values in AMX structure (PRI, ALT)
|
||||||
|
mov [ebp+_error], dword %1
|
||||||
|
jmp _return
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
;Checked abort, saves nothing and uses a conditional
|
||||||
|
%macro _CHKABORT 1
|
||||||
|
mov ebp,amx
|
||||||
|
mov [ebp+_error], %1
|
||||||
|
cmp %1, AMX_ERR_NONE
|
||||||
|
jne _return
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
;Fast abort, only aborts, nothing else
|
||||||
|
%macro _FASTABORT 0
|
||||||
|
jmp _return
|
||||||
|
%endmacro
|
||||||
|
|
||||||
%macro _CHKHEAP 0
|
%macro _CHKHEAP 0
|
||||||
mov ebp,amx
|
mov ebp,amx
|
||||||
mov ebp,[ebp+_hlw]
|
mov ebp,[ebp+_hlw]
|
||||||
@ -1196,8 +1218,7 @@ OP_HALT:
|
|||||||
mov eax,esi ; EAX=CIP
|
mov eax,esi ; EAX=CIP
|
||||||
sub eax,code
|
sub eax,code
|
||||||
mov [ebp+_cip],eax
|
mov [ebp+_cip],eax
|
||||||
mov eax,ebx ; return the parameter of the HALT opcode
|
_ABORT ebx
|
||||||
jmp _return
|
|
||||||
|
|
||||||
|
|
||||||
OP_BOUNDS:
|
OP_BOUNDS:
|
||||||
@ -1221,6 +1242,7 @@ OP_SYSREQ_PRI:
|
|||||||
mov alt,edx ; save ALT
|
mov alt,edx ; save ALT
|
||||||
|
|
||||||
mov [ebp+_stk],ecx ; store values in AMX structure (STK, HEA, FRM)
|
mov [ebp+_stk],ecx ; store values in AMX structure (STK, HEA, FRM)
|
||||||
|
;we don't save regs since they're useless after this
|
||||||
mov ecx,hea
|
mov ecx,hea
|
||||||
mov ebx,frm
|
mov ebx,frm
|
||||||
mov [ebp+_hea],ecx
|
mov [ebp+_hea],ecx
|
||||||
@ -1251,8 +1273,7 @@ OP_SYSREQ_PRI:
|
|||||||
pop edi ; restore saved registers
|
pop edi ; restore saved registers
|
||||||
pop esi
|
pop esi
|
||||||
pop ebp
|
pop ebp
|
||||||
cmp eax,AMX_ERR_NONE
|
_CHKABORT eax ; if result was invalid, leave
|
||||||
jne near _return ; return error code, if any
|
|
||||||
|
|
||||||
mov eax,pri ; get retval into eax (PRI)
|
mov eax,pri ; get retval into eax (PRI)
|
||||||
mov edx,alt ; restore ALT
|
mov edx,alt ; restore ALT
|
||||||
@ -1293,8 +1314,8 @@ OP_SYSREQ_D: ; (TR)
|
|||||||
pop edi ; restore saved registers
|
pop edi ; restore saved registers
|
||||||
pop esi
|
pop esi
|
||||||
pop ebp
|
pop ebp
|
||||||
cmp DWORD [ebp+_error],AMX_ERR_NONE
|
mov eax,[ebp+_error]
|
||||||
jne near _return ; return error code, if any
|
_CHKABORT eax
|
||||||
|
|
||||||
; function result is in eax (PRI)
|
; function result is in eax (PRI)
|
||||||
mov edx,alt ; restore ALT
|
mov edx,alt ; restore ALT
|
||||||
@ -1416,7 +1437,7 @@ OP_BREAK:
|
|||||||
mov [ebp+_error],eax ; save EAX (error code) before restoring all regs
|
mov [ebp+_error],eax ; save EAX (error code) before restoring all regs
|
||||||
_RESTOREREGS ; abort run, but restore stack first
|
_RESTOREREGS ; abort run, but restore stack first
|
||||||
mov eax,[ebp+_error] ; get error code in EAX back again
|
mov eax,[ebp+_error] ; get error code in EAX back again
|
||||||
jmp _return ; return error code
|
_FASTABORT
|
||||||
break_noabort:
|
break_noabort:
|
||||||
_RESTOREREGS
|
_RESTOREREGS
|
||||||
mov eax,[ebp+_pri] ; restore PRI and ALT
|
mov eax,[ebp+_pri] ; restore PRI and ALT
|
||||||
@ -1425,43 +1446,34 @@ OP_BREAK:
|
|||||||
|
|
||||||
|
|
||||||
OP_INVALID:
|
OP_INVALID:
|
||||||
mov eax,AMX_ERR_INVINSTR
|
_ABORT AMX_ERR_INVINSTR
|
||||||
jmp _return
|
|
||||||
|
|
||||||
err_call:
|
err_call:
|
||||||
mov eax,AMX_ERR_CALLBACK
|
_ABORT AMX_ERR_CALLBACK
|
||||||
jmp _return
|
|
||||||
|
|
||||||
err_stack:
|
err_stack:
|
||||||
mov eax,AMX_ERR_STACKERR
|
_ABORT AMX_ERR_STACKERR
|
||||||
jmp _return
|
|
||||||
|
|
||||||
err_stacklow:
|
err_stacklow:
|
||||||
mov eax,AMX_ERR_STACKLOW
|
_ABORT AMX_ERR_STACKLOW
|
||||||
jmp _return
|
|
||||||
|
|
||||||
err_memaccess:
|
err_memaccess:
|
||||||
mov eax,AMX_ERR_MEMACCESS
|
_ABORT AMX_ERR_MEMACCESS
|
||||||
jmp _return
|
|
||||||
|
|
||||||
err_bounds:
|
err_bounds:
|
||||||
mov eax,AMX_ERR_BOUNDS
|
_ABORT AMX_ERR_BOUNDS
|
||||||
jmp _return
|
|
||||||
|
|
||||||
err_heaplow:
|
err_heaplow:
|
||||||
mov eax,AMX_ERR_HEAPLOW
|
_ABORT AMX_ERR_HEAPLOW
|
||||||
jmp _return
|
|
||||||
|
|
||||||
err_divide:
|
err_divide:
|
||||||
mov eax,AMX_ERR_DIVIDE
|
_ABORT AMX_ERR_DIVIDE
|
||||||
jmp _return
|
|
||||||
|
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
; save a few parameters, mostly for the "sleep"function
|
; save a few parameters, mostly for the "sleep"function
|
||||||
mov ebp,amx ; get amx into ebp
|
mov ebp,amx ; get amx into ebp
|
||||||
mov [ebp+_pri],eax ; store values in AMX structure (PRI, ALT)
|
mov [ebp+_cip],esi ; get corrected cip for amxmodx
|
||||||
mov [ebp+_alt],edx ; store values in AMX structure (PRI, ALT)
|
mov eax,[ebp+_error]; get error code
|
||||||
|
|
||||||
pop esi ; remove FRM from stack
|
pop esi ; remove FRM from stack
|
||||||
|
|
||||||
|
@ -21,17 +21,26 @@
|
|||||||
; step.
|
; step.
|
||||||
|
|
||||||
; NOTE 3:
|
; NOTE 3:
|
||||||
; During execution of the compiled code with amx_exec_jit() the x86 processor's
|
|
||||||
; stack is switched into the data section of the abstract machine. This means
|
|
||||||
; that there should always be enough memory left between HEA and STK to provide
|
|
||||||
; stack space for occurring interrupts! (see the STACKRESERVE variable)
|
|
||||||
|
|
||||||
; NOTE 4:
|
|
||||||
; Although the Pawn compiler doesn't generate the LCTRL, SCTRL and CALL.I
|
; Although the Pawn compiler doesn't generate the LCTRL, SCTRL and CALL.I
|
||||||
; instructions, I have to tell that they don't work as expected in a JIT
|
; instructions, I have to tell that they don't work as expected in a JIT
|
||||||
; compiled program, because there is no easy way of transforming AMX code
|
; compiled program, because there is no easy way of transforming AMX code
|
||||||
; addresses and JIT translated ones. This might be fixed in a future version.
|
; addresses and JIT translated ones. This might be fixed in a future version.
|
||||||
|
|
||||||
|
; NOTE 4:
|
||||||
|
; Stack Pointer issues (by David Anderson)
|
||||||
|
; The JIT was changed recently so it no longer uses ESP as a general purpose
|
||||||
|
; register (GRP), because it can conflict with threading/signal systems which
|
||||||
|
; rely on the stack pointer being in-tact to find thread-ids. My fix for this
|
||||||
|
; was to keep esp safe, but save the stack pointer in 'ecx'. As such, ecx is no
|
||||||
|
; longer the CIP or scratch register, it is the save point for pieces of the AMX
|
||||||
|
; structure on the x86 stack.
|
||||||
|
; This means that the optimization of the JIT has changed, as every amx stack
|
||||||
|
; push call now takes two operations instead of one (same for pop), and pushing
|
||||||
|
; addresses is 4 instructions instead of 1.
|
||||||
|
; As of this moment I don't see a better way around it, but the sacrifice for
|
||||||
|
; having pthread-safe code was deemed to be necessary.
|
||||||
|
|
||||||
|
; NOTE 5:
|
||||||
; NX ("No eXecute") and XD (eXecution Denied) bits
|
; NX ("No eXecute") and XD (eXecution Denied) bits
|
||||||
; (by Thiadmer Riemersma)
|
; (by Thiadmer Riemersma)
|
||||||
;
|
;
|
||||||
@ -65,7 +74,8 @@
|
|||||||
; segment: the JIT-compiler patches P-code parameters into its own code segment
|
; segment: the JIT-compiler patches P-code parameters into its own code segment
|
||||||
; during compilation. This is handled in the support code for amx_InitJIT.
|
; during compilation. This is handled in the support code for amx_InitJIT.
|
||||||
;
|
;
|
||||||
;
|
|
||||||
|
; NOTE 6:
|
||||||
; CALLING CONVENTIONS
|
; CALLING CONVENTIONS
|
||||||
; (by Thiadmer Riemersma)
|
; (by Thiadmer Riemersma)
|
||||||
;
|
;
|
||||||
@ -77,9 +87,16 @@
|
|||||||
; a reserved word on the assembler, I had to choose a different name for the
|
; a reserved word on the assembler, I had to choose a different name for the
|
||||||
; macro, hence STDECL.)
|
; macro, hence STDECL.)
|
||||||
|
|
||||||
|
|
||||||
; Revision History
|
; Revision History
|
||||||
; ----------------
|
; ----------------
|
||||||
; 26 july 2005 by David "BAILOPAN" Anderson
|
; 16 august 2005 by David "BAILOPAN" Anderson (DA)
|
||||||
|
; Changed JIT to not swap stack pointer during execution. This
|
||||||
|
; is playing with fire, especially with pthreads and signals on linux,
|
||||||
|
; where the stack pointer is used to find the current thread id. If
|
||||||
|
; the stack pointer is altered during a thread/signal switch/interrupt
|
||||||
|
; unexpected behaviour can occur (crashes).
|
||||||
|
; 26 july 2005 by David "BAILOPAN" Anderson (DA)
|
||||||
; Fixed a bug where zero casetbl entries would crash the JIT.
|
; Fixed a bug where zero casetbl entries would crash the JIT.
|
||||||
; 17 february 2005 by Thiadmer Riemersms
|
; 17 february 2005 by Thiadmer Riemersms
|
||||||
; Addition of the BREAK opcode, removal of the older debugging opcode
|
; Addition of the BREAK opcode, removal of the older debugging opcode
|
||||||
@ -165,15 +182,6 @@
|
|||||||
;
|
;
|
||||||
%define FORCERELOCATABLE
|
%define FORCERELOCATABLE
|
||||||
|
|
||||||
;
|
|
||||||
; Determines how much memory should be reserved for occurring interrupts.
|
|
||||||
; (If my memory serves me right, DOS4/G(W) provides a stack of 512 bytes
|
|
||||||
; for interrupts that occur in real mode and are promoted to protected mode.)
|
|
||||||
; This value _MUST_ be greater than 64 (for AMX needs) and should be at least
|
|
||||||
; 128 (to serve interrupts).
|
|
||||||
;
|
|
||||||
%define STACKRESERVE 256
|
|
||||||
|
|
||||||
;
|
;
|
||||||
; This variable controls the generation of memory range checks at run-time.
|
; This variable controls the generation of memory range checks at run-time.
|
||||||
; You should set this to 0, only when you are sure that there are no range
|
; You should set this to 0, only when you are sure that there are no range
|
||||||
@ -186,32 +194,49 @@
|
|||||||
%define JIT 1
|
%define JIT 1
|
||||||
%include "amxdefn.asm"
|
%include "amxdefn.asm"
|
||||||
|
|
||||||
; GWMV:
|
;Registers used for JIT during execution:
|
||||||
; Nasm can't do the next as equivalence statements, since the value of
|
; eax - pri
|
||||||
; esi is not determined at compile time
|
; ebx - reloc frame
|
||||||
%define stk [esi+32] ; define some aliases to registers that will
|
; ecx - info params
|
||||||
%define alt [esi+28] ; be stored on the stack when the code is
|
; edx - alt
|
||||||
%define pri [esi+24] ; actually beeing executed
|
; esi - AMX stack
|
||||||
%define code [esi+20]
|
; edi - DAT
|
||||||
%define amx [esi+16]
|
; ebp - scratch
|
||||||
%define retval [esi+12]
|
|
||||||
%define stp [esi+8]
|
;DA:
|
||||||
%define hea [esi+4]
|
; These are still stored in the stack, but the stack pointer
|
||||||
%define frm [esi] ; FRM is NOT stored in ebp, FRM+DAT is being held
|
; holding them is now kept in ecx.
|
||||||
|
%define stk [ecx+32] ; define some aliases to registers that will
|
||||||
|
%define alt [ecx+28] ; be stored on the stack when the code is
|
||||||
|
%define pri [ecx+24] ; actually beeing executed
|
||||||
|
%define code [ecx+20]
|
||||||
|
%define amx [ecx+16]
|
||||||
|
%define retval [ecx+12]
|
||||||
|
%define stp [ecx+8]
|
||||||
|
%define hea [ecx+4]
|
||||||
|
%define frm [ecx] ; FRM is NOT stored in ebp, FRM+DAT is being held
|
||||||
; in ebx instead.
|
; in ebx instead.
|
||||||
|
|
||||||
;
|
;
|
||||||
; #define PUSH(v) ( stk-=sizeof(cell), *(cell *)(data+(int)stk)=v )
|
; #define PUSH(v) ( stk-=sizeof(cell), *(cell *)(data+(int)stk)=v )
|
||||||
;
|
;
|
||||||
%macro _PUSH 1
|
%macro _PUSH 1
|
||||||
push dword %1
|
lea esi,[esi-4]
|
||||||
|
mov dword [esi], %1
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
%macro _PUSHMEM 1
|
||||||
|
lea esi,[esi-4]
|
||||||
|
mov ebp, dword %1
|
||||||
|
mov dword [esi], ebp
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
;
|
;
|
||||||
; #define POP(v) ( v=*(cell *)(data+(int)stk), stk+=sizeof(cell) )
|
; #define POP(v) ( v=*(cell *)(data+(int)stk), stk+=sizeof(cell) )
|
||||||
;
|
;
|
||||||
%macro _POP 1
|
%macro _POP 1
|
||||||
pop dword %1
|
mov %1, dword [esi]
|
||||||
|
lea esi,[esi+4]
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
|
|
||||||
@ -790,7 +815,7 @@ OP_LCTRL:
|
|||||||
jne lctrl_5
|
jne lctrl_5
|
||||||
GO_ON j_lctrl_4, lctrl_5, 8
|
GO_ON j_lctrl_4, lctrl_5, 8
|
||||||
j_lctrl_4:
|
j_lctrl_4:
|
||||||
mov eax,esp ; 4=STK
|
mov eax,esi ; 4=STK
|
||||||
sub eax,edi
|
sub eax,edi
|
||||||
CHECKCODESIZE j_lctrl_4
|
CHECKCODESIZE j_lctrl_4
|
||||||
lctrl_5:
|
lctrl_5:
|
||||||
@ -824,7 +849,7 @@ OP_SCTRL:
|
|||||||
j_sctrl_4:
|
j_sctrl_4:
|
||||||
;mov esp,eax ; 4=STK
|
;mov esp,eax ; 4=STK
|
||||||
;add esp,edi ; relocate stack
|
;add esp,edi ; relocate stack
|
||||||
lea esp,[eax+edi]
|
lea esi,[eax+edi]
|
||||||
CHECKCODESIZE j_sctrl_4
|
CHECKCODESIZE j_sctrl_4
|
||||||
sctrl_5:
|
sctrl_5:
|
||||||
cmp eax,5
|
cmp eax,5
|
||||||
@ -885,14 +910,16 @@ OP_PUSH_ALT:
|
|||||||
|
|
||||||
OP_PUSH_R_PRI:
|
OP_PUSH_R_PRI:
|
||||||
;nop;
|
;nop;
|
||||||
putval j_push_r_pri+1
|
putval j_push_r_pri+2
|
||||||
GO_ON j_push_r_pri, OP_PUSH_C, 8
|
GO_ON j_push_r_pri, OP_PUSH_C, 8
|
||||||
|
|
||||||
j_push_r_pri:
|
j_push_r_pri:
|
||||||
|
push ecx
|
||||||
mov ecx,12345678h
|
mov ecx,12345678h
|
||||||
j_push_loop:
|
j_push_loop:
|
||||||
_PUSH eax
|
_PUSH eax
|
||||||
loop j_push_loop
|
loop j_push_loop
|
||||||
|
pop ecx
|
||||||
;dec ecx
|
;dec ecx
|
||||||
;jnz j_push_loop
|
;jnz j_push_loop
|
||||||
CHECKCODESIZE j_push_r_pri
|
CHECKCODESIZE j_push_r_pri
|
||||||
@ -900,30 +927,33 @@ OP_PUSH_R_PRI:
|
|||||||
;good
|
;good
|
||||||
OP_PUSH_C:
|
OP_PUSH_C:
|
||||||
;nop;
|
;nop;
|
||||||
putval j_push_c+1
|
putval j_push_c_end-4
|
||||||
GO_ON j_push_c, OP_PUSH, 8
|
GO_ON j_push_c, OP_PUSH, 8
|
||||||
|
|
||||||
j_push_c:
|
j_push_c:
|
||||||
_PUSH 12345678h
|
_PUSH 12345678h
|
||||||
|
j_push_c_end:
|
||||||
CHECKCODESIZE j_push_c
|
CHECKCODESIZE j_push_c
|
||||||
|
|
||||||
OP_PUSH:
|
OP_PUSH:
|
||||||
;nop;
|
;nop;
|
||||||
putval j_push+2
|
putval j_push_end-6
|
||||||
GO_ON j_push, OP_PUSH_S, 8
|
GO_ON j_push, OP_PUSH_S, 8
|
||||||
|
|
||||||
j_push:
|
j_push:
|
||||||
_PUSH [edi+12345678h]
|
_PUSHMEM [edi+12345678h]
|
||||||
|
j_push_end:
|
||||||
CHECKCODESIZE j_push
|
CHECKCODESIZE j_push
|
||||||
|
|
||||||
;good
|
;good
|
||||||
OP_PUSH_S:
|
OP_PUSH_S:
|
||||||
;nop;
|
;nop;
|
||||||
putval j_push_s+2
|
putval j_push_s_end-6
|
||||||
GO_ON j_push_s, OP_POP_PRI, 8
|
GO_ON j_push_s, OP_POP_PRI, 8
|
||||||
|
|
||||||
j_push_s:
|
j_push_s:
|
||||||
_PUSH [ebx+12345678h]
|
_PUSHMEM [ebx+12345678h]
|
||||||
|
j_push_s_end:
|
||||||
CHECKCODESIZE j_push_s
|
CHECKCODESIZE j_push_s
|
||||||
|
|
||||||
OP_POP_PRI:
|
OP_POP_PRI:
|
||||||
@ -950,8 +980,8 @@ OP_STACK:
|
|||||||
GO_ON j_stack, OP_HEAP, 8
|
GO_ON j_stack, OP_HEAP, 8
|
||||||
|
|
||||||
j_stack:
|
j_stack:
|
||||||
mov edx,esp
|
mov edx,esi
|
||||||
add esp,12345678h
|
add esi,12345678h
|
||||||
sub edx,edi
|
sub edx,edi
|
||||||
%ifdef DORUNTIMECHECKS
|
%ifdef DORUNTIMECHECKS
|
||||||
call [chk_marginstack]
|
call [chk_marginstack]
|
||||||
@ -979,9 +1009,9 @@ OP_PROC:
|
|||||||
GO_ON j_proc, OP_RET
|
GO_ON j_proc, OP_RET
|
||||||
|
|
||||||
j_proc: ;[STK] = FRM, STK = STK - cell size, FRM = STK
|
j_proc: ;[STK] = FRM, STK = STK - cell size, FRM = STK
|
||||||
_PUSH frm ; push old frame (for RET/RETN)
|
_PUSHMEM frm ; push old frame (for RET/RETN)
|
||||||
mov frm,esp ; get new frame
|
mov frm,esi ; get new frame
|
||||||
mov ebx,esp ; already relocated
|
mov ebx,esi ; already relocated
|
||||||
sub frm,edi ; relocate frame
|
sub frm,edi ; relocate frame
|
||||||
CHECKCODESIZE j_proc
|
CHECKCODESIZE j_proc
|
||||||
|
|
||||||
@ -991,6 +1021,7 @@ OP_RET:
|
|||||||
|
|
||||||
j_ret:
|
j_ret:
|
||||||
_POP ebx ; pop frame
|
_POP ebx ; pop frame
|
||||||
|
lea esi,[esi+4]
|
||||||
mov frm,ebx
|
mov frm,ebx
|
||||||
add ebx,edi
|
add ebx,edi
|
||||||
ret
|
ret
|
||||||
@ -1009,11 +1040,13 @@ OP_RETN:
|
|||||||
;good
|
;good
|
||||||
OP_CALL:
|
OP_CALL:
|
||||||
;nop;
|
;nop;
|
||||||
RELOC 1
|
RELOC j_call_e8-j_call+1
|
||||||
GO_ON j_call, OP_CALL_I, 8
|
GO_ON j_call, OP_CALL_I, 8
|
||||||
|
|
||||||
j_call:
|
j_call:
|
||||||
;call 12345678h ; tasm chokes on this out of a sudden
|
;call 12345678h ; tasm chokes on this out of a sudden
|
||||||
|
_PUSH 0
|
||||||
|
j_call_e8
|
||||||
db 0e8h, 0, 0, 0, 0
|
db 0e8h, 0, 0, 0, 0
|
||||||
CHECKCODESIZE j_call
|
CHECKCODESIZE j_call
|
||||||
|
|
||||||
@ -1022,6 +1055,7 @@ OP_CALL_I:
|
|||||||
GO_ON j_call_i, OP_JUMP
|
GO_ON j_call_i, OP_JUMP
|
||||||
|
|
||||||
j_call_i:
|
j_call_i:
|
||||||
|
_PUSH 0
|
||||||
call eax
|
call eax
|
||||||
CHECKCODESIZE j_call_i
|
CHECKCODESIZE j_call_i
|
||||||
|
|
||||||
@ -1172,24 +1206,30 @@ OP_SHL:
|
|||||||
;nop;
|
;nop;
|
||||||
GO_ON j_shl, OP_SHR
|
GO_ON j_shl, OP_SHR
|
||||||
j_shl:
|
j_shl:
|
||||||
mov ecx,edx ; TODO: save ECX if used as special register
|
push ecx
|
||||||
|
mov ecx,edx
|
||||||
shl eax,cl
|
shl eax,cl
|
||||||
|
pop ecx
|
||||||
CHECKCODESIZE j_shl
|
CHECKCODESIZE j_shl
|
||||||
|
|
||||||
OP_SHR:
|
OP_SHR:
|
||||||
;nop;
|
;nop;
|
||||||
GO_ON j_shr, OP_SSHR
|
GO_ON j_shr, OP_SSHR
|
||||||
j_shr:
|
j_shr:
|
||||||
mov ecx,edx ; TODO: save ECX if used as special register
|
push ecx
|
||||||
|
mov ecx,edx
|
||||||
shr eax,cl
|
shr eax,cl
|
||||||
|
pop ecx
|
||||||
CHECKCODESIZE j_shr
|
CHECKCODESIZE j_shr
|
||||||
|
|
||||||
OP_SSHR:
|
OP_SSHR:
|
||||||
;nop;
|
;nop;
|
||||||
GO_ON j_sshr, OP_SHL_C_PRI
|
GO_ON j_sshr, OP_SHL_C_PRI
|
||||||
j_sshr:
|
j_sshr:
|
||||||
mov ecx,edx ; TODO: save ECX if used as special register
|
push ecx
|
||||||
|
mov ecx,edx
|
||||||
sar eax,cl
|
sar eax,cl
|
||||||
|
pop ecx
|
||||||
CHECKCODESIZE j_sshr
|
CHECKCODESIZE j_sshr
|
||||||
|
|
||||||
OP_SHL_C_PRI:
|
OP_SHL_C_PRI:
|
||||||
@ -1608,29 +1648,35 @@ OP_DEC_I:
|
|||||||
|
|
||||||
OP_MOVS:
|
OP_MOVS:
|
||||||
;nop;
|
;nop;
|
||||||
putval j_movs+1
|
putval j_movs+2
|
||||||
GO_ON j_movs, OP_CMPS, 8
|
GO_ON j_movs, OP_CMPS, 8
|
||||||
j_movs:
|
j_movs:
|
||||||
mov ecx,12345678h ;TODO: save ECX if used as special register
|
push ecx
|
||||||
|
mov ecx,12345678h
|
||||||
call [jit_movs]
|
call [jit_movs]
|
||||||
|
pop ecx
|
||||||
CHECKCODESIZE j_movs
|
CHECKCODESIZE j_movs
|
||||||
|
|
||||||
OP_CMPS:
|
OP_CMPS:
|
||||||
;nop;
|
;nop;
|
||||||
putval j_cmps+1
|
putval j_cmps+2
|
||||||
GO_ON j_cmps, OP_FILL, 8
|
GO_ON j_cmps, OP_FILL, 8
|
||||||
j_cmps:
|
j_cmps:
|
||||||
mov ecx,12345678h ;TODO: save ECX if used as special register
|
push ecx
|
||||||
|
mov ecx,12345678h
|
||||||
call [jit_cmps]
|
call [jit_cmps]
|
||||||
|
pop ecx
|
||||||
CHECKCODESIZE j_cmps
|
CHECKCODESIZE j_cmps
|
||||||
|
|
||||||
OP_FILL:
|
OP_FILL:
|
||||||
;nop;
|
;nop;
|
||||||
putval j_fill+1
|
putval j_fill+2
|
||||||
GO_ON j_fill, OP_HALT, 8
|
GO_ON j_fill, OP_HALT, 8
|
||||||
j_fill:
|
j_fill:
|
||||||
|
push ecx
|
||||||
mov ecx,12345678h ;TODO: save ECX if used as special register
|
mov ecx,12345678h ;TODO: save ECX if used as special register
|
||||||
call [jit_fill]
|
call [jit_fill]
|
||||||
|
pop ecx
|
||||||
CHECKCODESIZE j_fill
|
CHECKCODESIZE j_fill
|
||||||
|
|
||||||
;good
|
;good
|
||||||
@ -1879,7 +1925,7 @@ _amx_exec_jit:
|
|||||||
push dword [eax+20]; store FRM
|
push dword [eax+20]; store FRM
|
||||||
|
|
||||||
mov edx,[eax+4] ; get ALT
|
mov edx,[eax+4] ; get ALT
|
||||||
mov ecx,[eax+8] ; get CIP
|
mov ebp,[eax+8] ; get CIP
|
||||||
mov edi,[eax+12] ; get pointer to data segment
|
mov edi,[eax+12] ; get pointer to data segment
|
||||||
mov esi,[eax+16] ; get STK !!changed, now ECX free as counter!!
|
mov esi,[eax+16] ; get STK !!changed, now ECX free as counter!!
|
||||||
mov ebx,[eax+20] ; get FRM
|
mov ebx,[eax+20] ; get FRM
|
||||||
@ -1887,13 +1933,14 @@ _amx_exec_jit:
|
|||||||
add ebx,edi ; relocate frame
|
add ebx,edi ; relocate frame
|
||||||
|
|
||||||
add esi,edi ; ESP will contain DAT+STK
|
add esi,edi ; ESP will contain DAT+STK
|
||||||
xchg esp,esi ; switch to AMX stack
|
|
||||||
|
|
||||||
add stp,edi ; make STP absolute address for run-time checks
|
add [esp+8],edi ; make STP absolute address for run-time checks
|
||||||
|
|
||||||
_POP ebp ; AMX pseudo-return address, ignored
|
mov dword [esi], 0 ; zero this out, but we need to keep it so
|
||||||
|
; the stack frame is in tact
|
||||||
|
mov ecx,esp ; copy stack pointer
|
||||||
; Call compiled code via CALL NEAR <address>
|
; Call compiled code via CALL NEAR <address>
|
||||||
call ecx
|
call ebp
|
||||||
|
|
||||||
return_to_caller:
|
return_to_caller:
|
||||||
cmp dword retval,0
|
cmp dword retval,0
|
||||||
@ -1906,15 +1953,17 @@ return_to_caller:
|
|||||||
jmp _return
|
jmp _return
|
||||||
|
|
||||||
_return_popstack:
|
_return_popstack:
|
||||||
add esp,4 ; Correct ESP, because we just come from a
|
mov esp,ecx ; get our old stack pointer
|
||||||
; runtime error checking routine.
|
|
||||||
_return:
|
_return:
|
||||||
; store machine state
|
; store machine state
|
||||||
mov ecx,esp ; get STK into ECX
|
push ecx
|
||||||
|
push ecx
|
||||||
mov ebp,amx ; get amx into EBP
|
mov ebp,amx ; get amx into EBP
|
||||||
|
mov ecx,esi ; get STK into ECX
|
||||||
|
|
||||||
sub ecx,edi ; correct STK
|
sub ecx,edi ; correct STK
|
||||||
mov [ebp+_stk],ecx ; store values in AMX structure: STK, ...
|
mov [ebp+_stk],ecx ; store values in AMX structure: STK, ...
|
||||||
|
pop ecx ; get orig value
|
||||||
mov ecx,hea ; ... HEA, ...
|
mov ecx,hea ; ... HEA, ...
|
||||||
mov [ebp+_hea],ecx
|
mov [ebp+_hea],ecx
|
||||||
mov ecx,ebx ; ... and FRM
|
mov ecx,ebx ; ... and FRM
|
||||||
@ -1924,8 +1973,8 @@ _return:
|
|||||||
mov [ebp+_alt],edx ; ... and ALT
|
mov [ebp+_alt],edx ; ... and ALT
|
||||||
|
|
||||||
; return
|
; return
|
||||||
|
pop ecx
|
||||||
sub stp,edi ; make STP relative to DAT again
|
sub stp,edi ; make STP relative to DAT again
|
||||||
xchg esp,esi ; switch back to caller's stack
|
|
||||||
|
|
||||||
add esp,4*9 ; remove temporary data
|
add esp,4*9 ; remove temporary data
|
||||||
|
|
||||||
@ -1946,12 +1995,8 @@ err_stacklow:
|
|||||||
jmp _return_popstack
|
jmp _return_popstack
|
||||||
|
|
||||||
_CHKMARGIN_STACK: ; some run-time check routines
|
_CHKMARGIN_STACK: ; some run-time check routines
|
||||||
cmp esp,stp
|
cmp esi,stp
|
||||||
lea ebp,[esp-STACKRESERVE]
|
|
||||||
jg err_stacklow
|
jg err_stacklow
|
||||||
sub ebp,edi
|
|
||||||
cmp hea,ebp
|
|
||||||
jg err_stack
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
err_heaplow:
|
err_heaplow:
|
||||||
@ -1959,7 +2004,7 @@ err_heaplow:
|
|||||||
jmp _return_popstack
|
jmp _return_popstack
|
||||||
|
|
||||||
_CHKMARGIN_HEAP:
|
_CHKMARGIN_HEAP:
|
||||||
cmp esp,stp
|
cmp esi,stp
|
||||||
jg err_stacklow
|
jg err_stacklow
|
||||||
cmp dword hea,0
|
cmp dword hea,0
|
||||||
jl err_heaplow
|
jl err_heaplow
|
||||||
@ -1975,7 +2020,7 @@ _VERIFYADDRESS_eax: ; used in load.i, store.i & lidx
|
|||||||
cmp eax,hea
|
cmp eax,hea
|
||||||
jb veax1
|
jb veax1
|
||||||
lea ebp,[eax+edi]
|
lea ebp,[eax+edi]
|
||||||
cmp ebp,esp
|
cmp ebp,esi
|
||||||
jb err_memaccess
|
jb err_memaccess
|
||||||
veax1:
|
veax1:
|
||||||
ret
|
ret
|
||||||
@ -1986,7 +2031,7 @@ _VERIFYADDRESS_edx: ; used in load.i, store.i & lidx
|
|||||||
cmp edx,hea
|
cmp edx,hea
|
||||||
jb vedx1
|
jb vedx1
|
||||||
lea ebp,[edx+edi]
|
lea ebp,[edx+edi]
|
||||||
cmp ebp,esp
|
cmp ebp,esi
|
||||||
jb err_memaccess
|
jb err_memaccess
|
||||||
vedx1:
|
vedx1:
|
||||||
ret
|
ret
|
||||||
@ -2018,15 +2063,15 @@ JIT_OP_SDIV:
|
|||||||
|
|
||||||
JIT_OP_RETN:
|
JIT_OP_RETN:
|
||||||
_POP ebx ; pop frame
|
_POP ebx ; pop frame
|
||||||
_POP ecx ; get return address
|
add esi,4 ; get rid of the extra parameter from call
|
||||||
|
|
||||||
mov frm,ebx
|
mov frm,ebx
|
||||||
_POP ebp
|
_POP ebp
|
||||||
|
|
||||||
add ebx,edi
|
add ebx,edi
|
||||||
add esp,ebp ; remove data from stack
|
add esi,ebp ; remove data from stack
|
||||||
|
|
||||||
jmp ecx
|
ret
|
||||||
|
|
||||||
|
|
||||||
JIT_OP_MOVS: ;length of block to copy is already in ECX
|
JIT_OP_MOVS: ;length of block to copy is already in ECX
|
||||||
@ -2092,34 +2137,33 @@ err_divide:
|
|||||||
jmp _return_popstack
|
jmp _return_popstack
|
||||||
|
|
||||||
JIT_OP_SYSREQ:
|
JIT_OP_SYSREQ:
|
||||||
mov ecx,esp ; get STK into ECX
|
push ecx
|
||||||
|
push esi
|
||||||
mov ebp,amx ; get amx into EBP
|
mov ebp,amx ; get amx into EBP
|
||||||
|
|
||||||
sub ecx,edi ; correct STK
|
sub esi,edi ; correct STK
|
||||||
mov alt,edx ; save ALT
|
mov alt,edx ; save ALT
|
||||||
|
|
||||||
mov [ebp+_stk],ecx ; store values in AMX structure: STK,
|
mov [ebp+_stk],esi ; store values in AMX structure: STK,
|
||||||
mov ecx,hea ; HEA,
|
mov esi,hea ; HEA,
|
||||||
mov ebx,frm ; and FRM
|
mov ebx,frm ; and FRM
|
||||||
mov [ebp+_hea],ecx
|
mov [ebp+_hea],esi
|
||||||
mov [ebp+_frm],ebx
|
mov [ebp+_frm],ebx
|
||||||
|
|
||||||
lea ebx,pri ; 3rd param: addr. of retval
|
lea ebx,pri ; 3rd param: addr. of retval
|
||||||
lea ecx,[esp+4] ; 4th param: parameter array
|
|
||||||
|
|
||||||
xchg esp,esi ; switch to caller stack
|
;Our original esi is still pushed!
|
||||||
|
|
||||||
push ecx
|
|
||||||
push ebx
|
push ebx
|
||||||
push eax ; 2nd param: function number
|
push eax ; 2nd param: function number
|
||||||
push ebp ; 1st param: amx
|
push ebp ; 1st param: amx
|
||||||
call [ebp+_callback]
|
call [ebp+_callback]
|
||||||
_DROPARGS 16 ; remove args from stack
|
_DROPARGS 12 ; remove args from stack
|
||||||
|
|
||||||
xchg esp,esi ; switch back to AMX stack
|
pop esi
|
||||||
|
pop ecx
|
||||||
cmp eax,AMX_ERR_NONE
|
cmp eax,AMX_ERR_NONE
|
||||||
jne _return_popstack; return error code, if any
|
jne _return_popstack
|
||||||
|
.continue:
|
||||||
mov eax,pri ; get retval into eax (PRI)
|
mov eax,pri ; get retval into eax (PRI)
|
||||||
mov edx,alt ; restore ALT
|
mov edx,alt ; restore ALT
|
||||||
mov ebx,frm ; restore FRM
|
mov ebx,frm ; restore FRM
|
||||||
@ -2128,25 +2172,25 @@ JIT_OP_SYSREQ:
|
|||||||
|
|
||||||
|
|
||||||
JIT_OP_SYSREQ_D: ; (TR)
|
JIT_OP_SYSREQ_D: ; (TR)
|
||||||
mov ecx,esp ; get STK into ECX
|
push ecx
|
||||||
|
push esi
|
||||||
mov ebp,amx ; get amx into EBP
|
mov ebp,amx ; get amx into EBP
|
||||||
|
|
||||||
sub ecx,edi ; correct STK
|
sub esi,edi ; correct STK
|
||||||
mov alt,edx ; save ALT
|
mov alt,edx ; save ALT
|
||||||
|
|
||||||
mov [ebp+_stk],ecx ; store values in AMX structure: STK,
|
mov [ebp+_stk],esi ; store values in AMX structure: STK,
|
||||||
mov ecx,hea ; HEA,
|
mov esi,hea ; HEA,
|
||||||
mov eax,frm ; and FRM
|
mov eax,frm ; and FRM
|
||||||
mov [ebp+_hea],ecx
|
mov [ebp+_hea],esi
|
||||||
mov [ebp+_frm],eax ; eax & ecx are invalid by now
|
mov [ebp+_frm],eax ; eax & ecx are invalid by now
|
||||||
|
|
||||||
lea edx,[esp+4] ; 2nd param: parameter array
|
;esi is still pushed!
|
||||||
xchg esp,esi ; switch to caller stack
|
|
||||||
push edx
|
|
||||||
push ebp ; 1st param: amx
|
push ebp ; 1st param: amx
|
||||||
call ebx ; direct call
|
call ebx ; direct call
|
||||||
_DROPARGS 8 ; remove args from stack
|
_DROPARGS 8 ; remove args from stack
|
||||||
xchg esp,esi ; switch back to AMX stack
|
|
||||||
|
pop ecx
|
||||||
mov ebp,amx ; get amx into EBP
|
mov ebp,amx ; get amx into EBP
|
||||||
cmp dword [ebp+_error],AMX_ERR_NONE
|
cmp dword [ebp+_error],AMX_ERR_NONE
|
||||||
jne _return_popstack; return error code, if any
|
jne _return_popstack; return error code, if any
|
||||||
@ -2160,25 +2204,27 @@ JIT_OP_SYSREQ_D: ; (TR)
|
|||||||
|
|
||||||
JIT_OP_BREAK:
|
JIT_OP_BREAK:
|
||||||
%ifdef DEBUGSUPPORT
|
%ifdef DEBUGSUPPORT
|
||||||
mov ecx,esp ; get STK into ECX
|
push ecx
|
||||||
|
push esi
|
||||||
mov ebp,amx ; get amx into EBP
|
mov ebp,amx ; get amx into EBP
|
||||||
|
|
||||||
sub ecx,edi ; correct STK
|
sub esi,edi ; correct STK
|
||||||
|
|
||||||
mov [ebp+_pri],eax ; store values in AMX structure: PRI,
|
mov [ebp+_pri],eax ; store values in AMX structure: PRI,
|
||||||
mov [ebp+_alt],edx ; ALT,
|
mov [ebp+_alt],edx ; ALT,
|
||||||
mov [ebp+_stk],ecx ; STK,
|
mov [ebp+_stk],esi ; STK,
|
||||||
mov ecx,hea ; HEA,
|
mov esi,hea ; HEA,
|
||||||
mov ebx,frm ; and FRM
|
mov ebx,frm ; and FRM
|
||||||
mov [ebp+_hea],ecx
|
mov [ebp+_hea],esi
|
||||||
mov [ebp+_frm],ebx ; EBX & ECX are invalid by now
|
mov [ebp+_frm],ebx ; EBX & ECX are invalid by now
|
||||||
;??? storing CIP is not very useful, because the code changed (during JIT compile)
|
;??? storing CIP is not very useful, because the code changed (during JIT compile)
|
||||||
|
|
||||||
xchg esp,esi ; switch to caller stack
|
|
||||||
push ebp ; 1st param: amx
|
push ebp ; 1st param: amx
|
||||||
call [ebp+_debug]
|
call [ebp+_debug]
|
||||||
_DROPARGS 4 ; remove args from stack
|
_DROPARGS 4 ; remove args from stack
|
||||||
xchg esp,esi ; switch back to AMX stack
|
|
||||||
|
pop esi
|
||||||
|
pop ecx
|
||||||
cmp eax,AMX_ERR_NONE
|
cmp eax,AMX_ERR_NONE
|
||||||
jne _return_popstack; return error code, if any
|
jne _return_popstack; return error code, if any
|
||||||
|
|
||||||
@ -2194,6 +2240,7 @@ JIT_OP_BREAK:
|
|||||||
|
|
||||||
JIT_OP_SWITCH:
|
JIT_OP_SWITCH:
|
||||||
pop ebp ; pop return address = table address
|
pop ebp ; pop return address = table address
|
||||||
|
push ecx
|
||||||
mov ecx,[ebp] ; ECX = number of records
|
mov ecx,[ebp] ; ECX = number of records
|
||||||
lea ebp,[ebp+ecx*8+8] ; set pointer _after_ LAST case
|
lea ebp,[ebp+ecx*8+8] ; set pointer _after_ LAST case
|
||||||
;if there are zero cases we should just skip this -- bail
|
;if there are zero cases we should just skip this -- bail
|
||||||
@ -2205,6 +2252,7 @@ JIT_OP_SWITCH:
|
|||||||
sub ebp,8 ; position to preceding case
|
sub ebp,8 ; position to preceding case
|
||||||
loop op_switch_loop ; check next case, or fall through
|
loop op_switch_loop ; check next case, or fall through
|
||||||
op_switch_jump:
|
op_switch_jump:
|
||||||
|
pop ecx
|
||||||
%ifndef FORCERELOCATABLE
|
%ifndef FORCERELOCATABLE
|
||||||
jmp [ebp-4] ; jump to the case instructions
|
jmp [ebp-4] ; jump to the case instructions
|
||||||
%else
|
%else
|
||||||
|
1309
amxmodx/amxmodx.cpp
1309
amxmodx/amxmodx.cpp
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,6 @@
|
|||||||
#ifndef AMXMODX_H
|
#ifndef AMXMODX_H
|
||||||
#define AMXMODX_H
|
#define AMXMODX_H
|
||||||
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -69,18 +68,17 @@
|
|||||||
#include "amxxlog.h"
|
#include "amxxlog.h"
|
||||||
|
|
||||||
#define AMXXLOG_Log g_log.Log
|
#define AMXXLOG_Log g_log.Log
|
||||||
#define AMX_VERSION "1.50"
|
#define AMX_VERSION "1.60"
|
||||||
|
|
||||||
extern AMX_NATIVE_INFO core_Natives[];
|
extern AMX_NATIVE_INFO core_Natives[];
|
||||||
extern AMX_NATIVE_INFO time_Natives[];
|
extern AMX_NATIVE_INFO time_Natives[];
|
||||||
extern AMX_NATIVE_INFO power_Natives[];
|
extern AMX_NATIVE_INFO power_Natives[];
|
||||||
extern AMX_NATIVE_INFO amxmod_Natives[];
|
extern AMX_NATIVE_INFO amxmodx_Natives[];
|
||||||
extern AMX_NATIVE_INFO file_Natives[];
|
extern AMX_NATIVE_INFO file_Natives[];
|
||||||
extern AMX_NATIVE_INFO float_Natives[];
|
extern AMX_NATIVE_INFO float_Natives[];
|
||||||
extern AMX_NATIVE_INFO string_Natives[];
|
extern AMX_NATIVE_INFO string_Natives[];
|
||||||
extern AMX_NATIVE_INFO vault_Natives[];
|
extern AMX_NATIVE_INFO vault_Natives[];
|
||||||
|
|
||||||
|
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
#define DLLOAD(path) (DLHANDLE)LoadLibrary(path)
|
#define DLLOAD(path) (DLHANDLE)LoadLibrary(path)
|
||||||
#define DLPROC(m, func) GetProcAddress(m, func)
|
#define DLPROC(m, func) GetProcAddress(m, func)
|
||||||
@ -110,6 +108,7 @@ typedef void* DLHANDLE;
|
|||||||
|
|
||||||
char* UTIL_SplitHudMessage(register const char *src);
|
char* UTIL_SplitHudMessage(register const char *src);
|
||||||
int UTIL_ReadFlags(const char* c);
|
int UTIL_ReadFlags(const char* c);
|
||||||
|
|
||||||
void UTIL_ClientPrint(edict_t *pEntity, int msg_dest, char *msg);
|
void UTIL_ClientPrint(edict_t *pEntity, int msg_dest, char *msg);
|
||||||
void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1 = NULL, const char *arg2 = NULL);
|
void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1 = NULL, const char *arg2 = NULL);
|
||||||
void UTIL_GetFlags(char* flags, int flag);
|
void UTIL_GetFlags(char* flags, int flag);
|
||||||
@ -117,6 +116,7 @@ void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pM
|
|||||||
void UTIL_IntToString(int value, char *output);
|
void UTIL_IntToString(int value, char *output);
|
||||||
void UTIL_ShowMOTD(edict_t *client, char *motd, int mlen, const char *name);
|
void UTIL_ShowMOTD(edict_t *client, char *motd, int mlen, const char *name);
|
||||||
void UTIL_ShowMenu(edict_t* pEntity, int slots, int time, char *menu, int mlen);
|
void UTIL_ShowMenu(edict_t* pEntity, int slots, int time, char *menu, int mlen);
|
||||||
|
|
||||||
char *UTIL_VarArgs(const char *fmt, ...);
|
char *UTIL_VarArgs(const char *fmt, ...);
|
||||||
|
|
||||||
|
|
||||||
@ -124,16 +124,17 @@ char *UTIL_VarArgs(const char *fmt, ...);
|
|||||||
//#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t))])
|
//#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t))])
|
||||||
#define GET_PLAYER_POINTER_I(i) (&g_players[i])
|
#define GET_PLAYER_POINTER_I(i) (&g_players[i])
|
||||||
|
|
||||||
struct WeaponsVault {
|
struct WeaponsVault
|
||||||
|
{
|
||||||
String fullName;
|
String fullName;
|
||||||
short int iId;
|
short int iId;
|
||||||
short int ammoSlot;
|
short int ammoSlot;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fakecmd_t {
|
struct fakecmd_t
|
||||||
|
{
|
||||||
char args[256];
|
char args[256];
|
||||||
const char *argv[3];
|
const char *argv[3];
|
||||||
//char argv[3][128];
|
|
||||||
int argc;
|
int argc;
|
||||||
bool fake;
|
bool fake;
|
||||||
};
|
};
|
||||||
@ -151,6 +152,7 @@ extern CList<ForceObject> g_forcemodels;
|
|||||||
extern CList<ForceObject> g_forcesounds;
|
extern CList<ForceObject> g_forcesounds;
|
||||||
extern CList<ForceObject> g_forcegeneric;
|
extern CList<ForceObject> g_forcegeneric;
|
||||||
extern CList<CModule, const char *> g_modules;
|
extern CList<CModule, const char *> g_modules;
|
||||||
|
extern CList<CScript, AMX*> g_loadedscripts;
|
||||||
extern CList<CPlayer*> g_auth;
|
extern CList<CPlayer*> g_auth;
|
||||||
extern EventsMngr g_events;
|
extern EventsMngr g_events;
|
||||||
extern Grenades g_grenades;
|
extern Grenades g_grenades;
|
||||||
@ -176,6 +178,7 @@ extern float g_game_restarting;
|
|||||||
extern float g_game_timeleft;
|
extern float g_game_timeleft;
|
||||||
extern float g_task_time;
|
extern float g_task_time;
|
||||||
extern float g_auth_time;
|
extern float g_auth_time;
|
||||||
|
extern bool g_NewDLL_Available;
|
||||||
extern hudtextparms_t g_hudset;
|
extern hudtextparms_t g_hudset;
|
||||||
//extern int g_edict_point;
|
//extern int g_edict_point;
|
||||||
extern int g_players_num;
|
extern int g_players_num;
|
||||||
@ -230,6 +233,7 @@ char *strptime(const char *buf, const char *fmt, struct tm *tm, short addthem);
|
|||||||
int loadModules(const char* filename, PLUG_LOADTIME now);
|
int loadModules(const char* filename, PLUG_LOADTIME now);
|
||||||
void detachModules();
|
void detachModules();
|
||||||
void detachReloadModules();
|
void detachReloadModules();
|
||||||
|
|
||||||
#ifdef FAKEMETA
|
#ifdef FAKEMETA
|
||||||
void attachModules();
|
void attachModules();
|
||||||
#endif
|
#endif
|
||||||
@ -252,11 +256,13 @@ char* format_amxstring(AMX *amx, cell *params, int parm,int& len);
|
|||||||
AMX* get_amxscript(int, void**, const char**);
|
AMX* get_amxscript(int, void**, const char**);
|
||||||
const char* get_amxscriptname(AMX* amx);
|
const char* get_amxscriptname(AMX* amx);
|
||||||
char* get_amxstring(AMX *amx, cell amx_addr, int id, int& len);
|
char* get_amxstring(AMX *amx, cell amx_addr, int id, int& len);
|
||||||
|
|
||||||
int amxstring_len(cell* cstr);
|
int amxstring_len(cell* cstr);
|
||||||
int load_amxscript(AMX* amx, void** program, const char* path, char error[64], int debug);
|
int load_amxscript(AMX* amx, void** program, const char* path, char error[64], int debug);
|
||||||
int set_amxnatives(AMX* amx, char error[64]);
|
int set_amxnatives(AMX* amx, char error[64]);
|
||||||
int set_amxstring(AMX *amx, cell amx_addr, const char *source, int max);
|
int set_amxstring(AMX *amx, cell amx_addr, const char *source, int max);
|
||||||
int unload_amxscript(AMX* amx, void** program);
|
int unload_amxscript(AMX* amx, void** program);
|
||||||
|
|
||||||
void copy_amxmemory(cell* dest, cell* src, int len);
|
void copy_amxmemory(cell* dest, cell* src, int len);
|
||||||
void get_modname(char*);
|
void get_modname(char*);
|
||||||
void print_srvconsole(char *fmt, ...);
|
void print_srvconsole(char *fmt, ...);
|
||||||
@ -279,6 +285,7 @@ enum ModuleCallReason
|
|||||||
extern ModuleCallReason g_ModuleCallReason; // modules.cpp
|
extern ModuleCallReason g_ModuleCallReason; // modules.cpp
|
||||||
extern CModule *g_CurrentlyCalledModule; // modules.cpp
|
extern CModule *g_CurrentlyCalledModule; // modules.cpp
|
||||||
extern const char *g_LastRequestedFunc; // modules.cpp
|
extern const char *g_LastRequestedFunc; // modules.cpp
|
||||||
|
|
||||||
void Module_CacheFunctions();
|
void Module_CacheFunctions();
|
||||||
void Module_UncacheFunctions();
|
void Module_UncacheFunctions();
|
||||||
|
|
||||||
@ -311,4 +318,3 @@ struct func_s
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // AMXMODX_H
|
#endif // AMXMODX_H
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
/**********************
|
/**********************
|
||||||
****** AMXXFILE ******
|
****** AMXXFILE ******
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
#define PACKED __attribute__((packed))
|
#define PACKED __attribute__((packed))
|
||||||
#else
|
#else
|
||||||
@ -73,6 +74,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
{
|
{
|
||||||
m_Bh.plugins = NULL;
|
m_Bh.plugins = NULL;
|
||||||
m_AmxxFile = false;
|
m_AmxxFile = false;
|
||||||
|
|
||||||
if (!filename)
|
if (!filename)
|
||||||
{
|
{
|
||||||
m_Status = Err_InvalidParam;
|
m_Status = Err_InvalidParam;
|
||||||
@ -81,8 +83,8 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
|
|
||||||
m_Status = Err_None;
|
m_Status = Err_None;
|
||||||
m_CellSize = cellsize;
|
m_CellSize = cellsize;
|
||||||
|
|
||||||
m_pFile = fopen(filename, "rb");
|
m_pFile = fopen(filename, "rb");
|
||||||
|
|
||||||
if (!m_pFile)
|
if (!m_pFile)
|
||||||
{
|
{
|
||||||
m_Status = Err_FileOpen;
|
m_Status = Err_FileOpen;
|
||||||
@ -93,27 +95,36 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
DATAREAD(&magic, sizeof(magic), 1);
|
DATAREAD(&magic, sizeof(magic), 1);
|
||||||
|
|
||||||
m_OldFile = false;
|
m_OldFile = false;
|
||||||
if ( magic == 0x524C4542 ) {
|
|
||||||
|
if (magic == 0x524C4542)
|
||||||
|
{
|
||||||
//we have an invalid, old, RLEB file
|
//we have an invalid, old, RLEB file
|
||||||
m_Status = Err_OldFile;
|
m_Status = Err_OldFile;
|
||||||
fclose(m_pFile);
|
fclose(m_pFile);
|
||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if ( magic == MAGIC_HEADER2 ) {
|
}
|
||||||
|
else if (magic == MAGIC_HEADER2)
|
||||||
|
{
|
||||||
DATAREAD(&m_Bh.version, sizeof(int16_t), 1);
|
DATAREAD(&m_Bh.version, sizeof(int16_t), 1);
|
||||||
|
|
||||||
if (m_Bh.version != MAGIC_VERSION)
|
if (m_Bh.version != MAGIC_VERSION)
|
||||||
{
|
{
|
||||||
m_Status = Err_OldFile;
|
m_Status = Err_OldFile;
|
||||||
fclose(m_pFile);
|
fclose(m_pFile);
|
||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_AmxxFile = true;
|
m_AmxxFile = true;
|
||||||
DATAREAD(&m_Bh.numPlugins, sizeof(mint8_t), 1);
|
DATAREAD(&m_Bh.numPlugins, sizeof(mint8_t), 1);
|
||||||
m_Bh.plugins = new PluginEntry[m_Bh.numPlugins];
|
m_Bh.plugins = new PluginEntry[m_Bh.numPlugins];
|
||||||
PluginEntry *pe;
|
PluginEntry *pe;
|
||||||
m_SectionHdrOffset = 0;
|
m_SectionHdrOffset = 0;
|
||||||
m_Entry = -1;
|
m_Entry = -1;
|
||||||
|
|
||||||
for (mint8_t i = 0; i < m_Bh.numPlugins; i++)
|
for (mint8_t i = 0; i < m_Bh.numPlugins; i++)
|
||||||
{
|
{
|
||||||
pe = &(m_Bh.plugins[i]);
|
pe = &(m_Bh.plugins[i]);
|
||||||
@ -123,26 +134,32 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
DATAREAD(&pe->memsize, sizeof(int32_t), 1);
|
DATAREAD(&pe->memsize, sizeof(int32_t), 1);
|
||||||
DATAREAD(&pe->offs, sizeof(int32_t), 1);
|
DATAREAD(&pe->offs, sizeof(int32_t), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (mint8_t i = 0; i < m_Bh.numPlugins; i++)
|
for (mint8_t i = 0; i < m_Bh.numPlugins; i++)
|
||||||
{
|
{
|
||||||
pe = &(m_Bh.plugins[i]);
|
pe = &(m_Bh.plugins[i]);
|
||||||
|
|
||||||
if (pe->cellsize == m_CellSize)
|
if (pe->cellsize == m_CellSize)
|
||||||
{
|
{
|
||||||
m_Entry = i;
|
m_Entry = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Entry == -1)
|
if (m_Entry == -1)
|
||||||
{
|
{
|
||||||
m_Status = Err_SectionNotFound;
|
m_Status = Err_SectionNotFound;
|
||||||
fclose(m_pFile);
|
fclose(m_pFile);
|
||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pe = &(m_Bh.plugins[m_Entry]);
|
pe = &(m_Bh.plugins[m_Entry]);
|
||||||
m_SectionLength = pe->disksize;
|
m_SectionLength = pe->disksize;
|
||||||
} else if (magic == MAGIC_HEADER) {
|
}
|
||||||
|
else if (magic == MAGIC_HEADER)
|
||||||
|
{
|
||||||
// try to find the section
|
// try to find the section
|
||||||
mint8_t numOfPlugins;
|
mint8_t numOfPlugins;
|
||||||
DATAREAD(&numOfPlugins, sizeof(numOfPlugins), 1);
|
DATAREAD(&numOfPlugins, sizeof(numOfPlugins), 1);
|
||||||
@ -151,6 +168,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
|
|
||||||
m_SectionHdrOffset = 0;
|
m_SectionHdrOffset = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (i = 0; i < static_cast<int>(numOfPlugins); ++i)
|
for (i = 0; i < static_cast<int>(numOfPlugins); ++i)
|
||||||
{
|
{
|
||||||
DATAREAD(&entry, sizeof(entry), 1);
|
DATAREAD(&entry, sizeof(entry), 1);
|
||||||
@ -160,6 +178,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_SectionHdrOffset)
|
if (!m_SectionHdrOffset)
|
||||||
{
|
{
|
||||||
m_Status = Err_SectionNotFound;
|
m_Status = Err_SectionNotFound;
|
||||||
@ -175,9 +194,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
TableEntry nextEntry;
|
TableEntry nextEntry;
|
||||||
DATAREAD(&nextEntry, sizeof(nextEntry), 1);
|
DATAREAD(&nextEntry, sizeof(nextEntry), 1);
|
||||||
m_SectionLength = nextEntry.offset - entry.offset;
|
m_SectionLength = nextEntry.offset - entry.offset;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fseek(m_pFile, 0, SEEK_END);
|
fseek(m_pFile, 0, SEEK_END);
|
||||||
m_SectionLength = ftell(m_pFile) - (long)entry.offset;
|
m_SectionLength = ftell(m_pFile) - (long)entry.offset;
|
||||||
}
|
}
|
||||||
@ -187,6 +204,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
rewind(m_pFile);
|
rewind(m_pFile);
|
||||||
fread(&hdr, sizeof(hdr), 1, m_pFile);
|
fread(&hdr, sizeof(hdr), 1, m_pFile);
|
||||||
amx_Align16(&hdr.magic);
|
amx_Align16(&hdr.magic);
|
||||||
|
|
||||||
if (hdr.magic == AMX_MAGIC)
|
if (hdr.magic == AMX_MAGIC)
|
||||||
{
|
{
|
||||||
if (cellsize != 4)
|
if (cellsize != 4)
|
||||||
@ -194,18 +212,19 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
m_Status = Err_SectionNotFound;
|
m_Status = Err_SectionNotFound;
|
||||||
fclose(m_pFile);
|
fclose(m_pFile);
|
||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_OldFile = true;
|
m_OldFile = true;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// no known file format
|
// no known file format
|
||||||
m_Status = Err_FileInvalid;
|
m_Status = Err_FileInvalid;
|
||||||
fclose(m_pFile);
|
fclose(m_pFile);
|
||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,9 +237,10 @@ CAmxxReader::~CAmxxReader()
|
|||||||
fclose(m_pFile);
|
fclose(m_pFile);
|
||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Bh.plugins)
|
if (m_Bh.plugins)
|
||||||
{
|
{
|
||||||
delete m_Bh.plugins;
|
delete [] m_Bh.plugins;
|
||||||
m_Bh.plugins = NULL;
|
m_Bh.plugins = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,11 +276,16 @@ size_t CAmxxReader::GetBufferSize()
|
|||||||
AMX_HEADER hdr;
|
AMX_HEADER hdr;
|
||||||
DATAREAD(&hdr, sizeof(hdr), 1);
|
DATAREAD(&hdr, sizeof(hdr), 1);
|
||||||
fseek(m_pFile, save, SEEK_SET);
|
fseek(m_pFile, save, SEEK_SET);
|
||||||
|
|
||||||
return hdr.stp;
|
return hdr.stp;
|
||||||
} else if (m_AmxxFile) {
|
}
|
||||||
|
else if (m_AmxxFile)
|
||||||
|
{
|
||||||
PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
|
PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
|
||||||
|
|
||||||
if (pe->imagesize > pe->memsize)
|
if (pe->imagesize > pe->memsize)
|
||||||
return pe->imagesize + 1;
|
return pe->imagesize + 1;
|
||||||
|
|
||||||
return pe->memsize + 1;
|
return pe->memsize + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,6 +294,7 @@ size_t CAmxxReader::GetBufferSize()
|
|||||||
TableEntry entry;
|
TableEntry entry;
|
||||||
DATAREAD(&entry, sizeof(entry), 1);
|
DATAREAD(&entry, sizeof(entry), 1);
|
||||||
fseek(m_pFile, save, SEEK_SET);
|
fseek(m_pFile, save, SEEK_SET);
|
||||||
|
|
||||||
return entry.origSize + 1; // +1 : safe
|
return entry.origSize + 1; // +1 : safe
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,22 +324,26 @@ CAmxxReader::Error CAmxxReader::GetSection(void *buffer)
|
|||||||
rewind(m_pFile);
|
rewind(m_pFile);
|
||||||
DATAREAD(buffer, 1, filesize);
|
DATAREAD(buffer, 1, filesize);
|
||||||
m_Status = Err_None;
|
m_Status = Err_None;
|
||||||
|
|
||||||
return m_Status;
|
return m_Status;
|
||||||
} else if (m_AmxxFile) {
|
}
|
||||||
|
else if (m_AmxxFile)
|
||||||
|
{
|
||||||
PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
|
PluginEntry *pe = &(m_Bh.plugins[m_Entry]);
|
||||||
char *tempBuffer = new char[m_SectionLength + 1];
|
char *tempBuffer = new char[m_SectionLength + 1];
|
||||||
fseek(m_pFile, pe->offs, SEEK_SET);
|
fseek(m_pFile, pe->offs, SEEK_SET);
|
||||||
DATAREAD((void *)tempBuffer, 1, m_SectionLength);
|
DATAREAD((void *)tempBuffer, 1, m_SectionLength);
|
||||||
uLongf destLen = GetBufferSize();
|
uLongf destLen = GetBufferSize();
|
||||||
int result = uncompress((Bytef *)buffer, &destLen,
|
int result = uncompress((Bytef *)buffer, &destLen, (Bytef *)tempBuffer, m_SectionLength);
|
||||||
(Bytef *)tempBuffer, m_SectionLength);
|
|
||||||
delete [] tempBuffer;
|
delete [] tempBuffer;
|
||||||
|
|
||||||
if (result != Z_OK)
|
if (result != Z_OK)
|
||||||
{
|
{
|
||||||
AMXXLOG_Log("[AMXX] Zlib error encountered: %d(%d)", result, m_SectionLength);
|
AMXXLOG_Log("[AMXX] Zlib error encountered: %d(%d)", result, m_SectionLength);
|
||||||
m_Status = Err_Decompress;
|
m_Status = Err_Decompress;
|
||||||
return Err_Decompress;
|
return Err_Decompress;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err_None;
|
return Err_None;
|
||||||
} else {
|
} else {
|
||||||
// new file type: go to the section table entry
|
// new file type: go to the section table entry
|
||||||
@ -328,15 +358,17 @@ CAmxxReader::Error CAmxxReader::GetSection(void *buffer)
|
|||||||
//fread(tempBuffer, sizeof(char), m_SectionLength, m_pFile);
|
//fread(tempBuffer, sizeof(char), m_SectionLength, m_pFile);
|
||||||
DATAREAD((void*)tempBuffer, 1, m_SectionLength);
|
DATAREAD((void*)tempBuffer, 1, m_SectionLength);
|
||||||
// decompress
|
// decompress
|
||||||
int result = uncompress((Bytef *)buffer, &destLen,
|
int result = uncompress((Bytef *)buffer, &destLen, (Bytef *)tempBuffer, m_SectionLength);
|
||||||
(Bytef *)tempBuffer, m_SectionLength);
|
|
||||||
delete [] tempBuffer;
|
delete [] tempBuffer;
|
||||||
|
|
||||||
if (result != Z_OK)
|
if (result != Z_OK)
|
||||||
{
|
{
|
||||||
AMXXLOG_Log("[AMXX] Zlib error encountered: %d(%d)", result, m_SectionLength);
|
AMXXLOG_Log("[AMXX] Zlib error encountered: %d(%d)", result, m_SectionLength);
|
||||||
m_Status = Err_Decompress;
|
m_Status = Err_Decompress;
|
||||||
|
|
||||||
return Err_Decompress;
|
return Err_Decompress;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Err_None;
|
return Err_None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,4 +95,3 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // __AMXXFILE_H__
|
#endif // __AMXXFILE_H__
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ void CLog::CloseFile()
|
|||||||
if (!m_LogFile.empty())
|
if (!m_LogFile.empty())
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(m_LogFile.c_str(), "r");
|
FILE *fp = fopen(m_LogFile.c_str(), "r");
|
||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -77,6 +78,7 @@ void CLog::CloseFile()
|
|||||||
fprintf(fp, "L %s: %s\n", date, "Log file closed.");
|
fprintf(fp, "L %s: %s\n", date, "Log file closed.");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LogFile.clear();
|
m_LogFile.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,29 +86,33 @@ void CLog::CloseFile()
|
|||||||
void CLog::CreateNewFile()
|
void CLog::CreateNewFile()
|
||||||
{
|
{
|
||||||
CloseFile();
|
CloseFile();
|
||||||
|
|
||||||
// build filename
|
// build filename
|
||||||
time_t td;
|
time_t td;
|
||||||
time(&td);
|
time(&td);
|
||||||
tm *curTime = localtime(&td);
|
tm *curTime = localtime(&td);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
FILE *pTmpFile = fopen(m_LogFile.c_str(), "r"); // open for reading to check whether the file exists
|
FILE *pTmpFile = fopen(m_LogFile.c_str(), "r"); // open for reading to check whether the file exists
|
||||||
|
|
||||||
if (!pTmpFile)
|
if (!pTmpFile)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fclose(pTmpFile);
|
fclose(pTmpFile);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log logfile start
|
// Log logfile start
|
||||||
FILE *fp = fopen(m_LogFile.c_str(), "w");
|
FILE *fp = fopen(m_LogFile.c_str(), "w");
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
ALERT(at_logged, "[AMXX] Unexpected fatal logging error. AMXX Logging disabled.\n");
|
ALERT(at_logged, "[AMXX] Unexpected fatal logging error. AMXX Logging disabled.\n");
|
||||||
SET_LOCALINFO("amxx_logging", "0");
|
SET_LOCALINFO("amxx_logging", "0");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(fp, "AMX Mod X log file started (file \"%s/L%02d%02d%03d.log\") (version \"%s\")\n", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i, AMX_VERSION);
|
fprintf(fp, "AMX Mod X log file started (file \"%s/L%02d%02d%03d.log\") (version \"%s\")\n", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday, i, AMX_VERSION);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
@ -129,6 +135,7 @@ void CLog::MapChange()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_LogType = atoi(get_localinfo("amxx_logging", "1"));
|
m_LogType = atoi(get_localinfo("amxx_logging", "1"));
|
||||||
|
|
||||||
if (m_LogType < 0 || m_LogType > 3)
|
if (m_LogType < 0 || m_LogType > 3)
|
||||||
{
|
{
|
||||||
SET_LOCALINFO("amxx_logging", "1");
|
SET_LOCALINFO("amxx_logging", "1");
|
||||||
@ -143,7 +150,7 @@ void CLog::MapChange()
|
|||||||
}
|
}
|
||||||
else if (m_LogType == 1)
|
else if (m_LogType == 1)
|
||||||
{
|
{
|
||||||
Log("-------- Mapchange --------");
|
Log("-------- Mapchange to %s --------", STRING(gpGlobals->mapname));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@ -152,6 +159,7 @@ void CLog::MapChange()
|
|||||||
void CLog::Log(const char *fmt, ...)
|
void CLog::Log(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
static char file[256];
|
static char file[256];
|
||||||
|
|
||||||
if (m_LogType == 1 || m_LogType == 2)
|
if (m_LogType == 1 || m_LogType == 2)
|
||||||
{
|
{
|
||||||
// get time
|
// get time
|
||||||
@ -178,6 +186,7 @@ void CLog::Log(const char *fmt, ...)
|
|||||||
{
|
{
|
||||||
CreateNewFile();
|
CreateNewFile();
|
||||||
pF = fopen(m_LogFile.c_str(), "a+");
|
pF = fopen(m_LogFile.c_str(), "a+");
|
||||||
|
|
||||||
if (!pF)
|
if (!pF)
|
||||||
{
|
{
|
||||||
ALERT(at_logged, "[AMXX] Unexpected fatal logging error (couldn't open %s for a+). AMXX Logging disabled for this map.\n", m_LogFile.c_str());
|
ALERT(at_logged, "[AMXX] Unexpected fatal logging error (couldn't open %s for a+). AMXX Logging disabled for this map.\n", m_LogFile.c_str());
|
||||||
@ -185,19 +194,16 @@ void CLog::Log(const char *fmt, ...)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
build_pathname_r(file, sizeof(file)-1, "%s/L%02d%02d.log", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday);
|
build_pathname_r(file, sizeof(file)-1, "%s/L%02d%02d.log", g_log_dir.c_str(), curTime->tm_mon + 1, curTime->tm_mday);
|
||||||
pF = fopen(file, "a+");
|
pF = fopen(file, "a+");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pF)
|
if (pF)
|
||||||
{
|
{
|
||||||
fprintf(pF, "L %s: %s\n", date, msg);
|
fprintf(pF, "L %s: %s\n", date, msg);
|
||||||
fclose(pF);
|
fclose(pF);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ALERT(at_logged, "[AMXX] Unexpected fatal logging error (couldn't open %s for a+). AMXX Logging disabled for this map.\n", file);
|
ALERT(at_logged, "[AMXX] Unexpected fatal logging error (couldn't open %s for a+). AMXX Logging disabled for this map.\n", file);
|
||||||
m_LogType = 0;
|
m_LogType = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -42,6 +42,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
CLog();
|
CLog();
|
||||||
~CLog();
|
~CLog();
|
||||||
|
|
||||||
void CreateNewFile();
|
void CreateNewFile();
|
||||||
void CloseFile();
|
void CloseFile();
|
||||||
void MapChange();
|
void MapChange();
|
||||||
@ -49,4 +50,3 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // __AMXXLOG_H__
|
#endif // __AMXXLOG_H__
|
||||||
|
|
||||||
|
1230
amxmodx/debugger.cpp
Executable file
1230
amxmodx/debugger.cpp
Executable file
File diff suppressed because it is too large
Load Diff
201
amxmodx/debugger.h
Executable file
201
amxmodx/debugger.h
Executable file
@ -0,0 +1,201 @@
|
|||||||
|
/* AMX Mod X
|
||||||
|
*
|
||||||
|
* by the AMX Mod X Development Team
|
||||||
|
* originally developed by OLO
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the author gives permission to
|
||||||
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
|
* you do not wish to do so, delete this exception statement from your
|
||||||
|
* version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INCLUDE_DEBUGGER_H_
|
||||||
|
#define _INCLUDE_DEBUGGER_H_
|
||||||
|
|
||||||
|
#include "CVector.h"
|
||||||
|
#include "amxdbg.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Third revision of the AMX Mod X Plugin Debugger.
|
||||||
|
* This final, object oriented version is safe for multiple calls and lets you
|
||||||
|
* fine-tune error handling.
|
||||||
|
* -BAILOPAN
|
||||||
|
*/
|
||||||
|
class Debugger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class Tracer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
struct trace_info
|
||||||
|
{
|
||||||
|
trace_info() : cip(0), frm(0), used(false), next(NULL), prev(NULL) {};
|
||||||
|
|
||||||
|
cell cip;
|
||||||
|
cell frm;
|
||||||
|
|
||||||
|
trace_info *next;
|
||||||
|
trace_info *prev;
|
||||||
|
|
||||||
|
bool used;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
Tracer() : m_Error(0), m_pStart(NULL), m_pEnd(NULL), m_Reset(true) {};
|
||||||
|
~Tracer();
|
||||||
|
public:
|
||||||
|
void StepI(cell frm, cell cip);
|
||||||
|
void Reset();
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
Debugger::Tracer::trace_info *GetStart() const;
|
||||||
|
Debugger::Tracer::trace_info *GetEnd() const;
|
||||||
|
public:
|
||||||
|
int m_Error;
|
||||||
|
private:
|
||||||
|
trace_info *m_pStart;
|
||||||
|
trace_info *m_pEnd;
|
||||||
|
|
||||||
|
bool m_Reset;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
Debugger(AMX *pAmx, AMX_DBG *pAmxDbg) : m_pAmx(pAmx), m_pAmxDbg(pAmxDbg), m_Top(-1)
|
||||||
|
{
|
||||||
|
_CacheAmxOpcodeList();
|
||||||
|
};
|
||||||
|
~Debugger();
|
||||||
|
public:
|
||||||
|
//Begin a trace for a function
|
||||||
|
void BeginExec();
|
||||||
|
|
||||||
|
//Step through one instruction
|
||||||
|
void StepI();
|
||||||
|
|
||||||
|
//Get/set the last traced error
|
||||||
|
int GetTracedError();
|
||||||
|
void SetTracedError(int error);
|
||||||
|
|
||||||
|
//Get the first trace info of the call stack
|
||||||
|
Debugger::Tracer::trace_info *GetTraceStart() const;
|
||||||
|
|
||||||
|
//Get extra info about the call stack
|
||||||
|
bool GetTraceInfo(Debugger::Tracer::trace_info *pTraceInfo, long &line, const char *&function, const char *&file);
|
||||||
|
|
||||||
|
//Get the next trace in the call stack, NULL if none
|
||||||
|
Debugger::Tracer::trace_info *GetNextTrace(Debugger::Tracer::trace_info *pTraceInfo);
|
||||||
|
|
||||||
|
//Returns true if an error exists
|
||||||
|
bool ErrorExists();
|
||||||
|
|
||||||
|
//Formats the error message into a buffer.
|
||||||
|
//returns length of data copied, or -1 if there is no error.
|
||||||
|
int FormatError(char *buffer, size_t maxLength);
|
||||||
|
|
||||||
|
//End a trace
|
||||||
|
void EndExec();
|
||||||
|
|
||||||
|
//Reset the internal states as if the debugger was inactive
|
||||||
|
void Reset();
|
||||||
|
|
||||||
|
//Destroy internal states for shutdown
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
void DisplayTrace(const char *message);
|
||||||
|
|
||||||
|
AMX *GetAMX() const { return m_pAmx; }
|
||||||
|
public:
|
||||||
|
//generic static opcode breaker
|
||||||
|
static int AMXAPI DebugHook(AMX *amx);
|
||||||
|
|
||||||
|
static void FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLength);
|
||||||
|
static void GenericMessage(AMX *amx, int error);
|
||||||
|
private:
|
||||||
|
void _CacheAmxOpcodeList();
|
||||||
|
|
||||||
|
int _GetOpcodeFromCip(cell cip, cell *&addr);
|
||||||
|
cell _CipAsVa(cell cip);
|
||||||
|
|
||||||
|
const char *_GetFilename();
|
||||||
|
public:
|
||||||
|
AMX *m_pAmx;
|
||||||
|
AMX_DBG *m_pAmxDbg;
|
||||||
|
|
||||||
|
int m_Top;
|
||||||
|
cell *m_pOpcodeList;
|
||||||
|
String m_FileName;
|
||||||
|
|
||||||
|
CVector<Tracer *> m_pCalls;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef Debugger::Tracer::trace_info trace_info_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error handler for plugins
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Handler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Handler(AMX *pAmx) : m_pAmx(pAmx), m_iErrFunc(-1), m_iModFunc(-1), m_iNatFunc(-1), m_Handling(false), m_InNativeFilter(false) {};
|
||||||
|
~Handler() {};
|
||||||
|
public:
|
||||||
|
int SetErrorHandler(const char *function);
|
||||||
|
int SetNativeFilter(const char *function);
|
||||||
|
int SetModuleFilter(const char *function);
|
||||||
|
public:
|
||||||
|
int HandleError(const char *msg);
|
||||||
|
int HandleNative(const char *native, int index, int trap);
|
||||||
|
int HandleModule(const char *module);
|
||||||
|
public:
|
||||||
|
bool IsHandling() const { return m_Handling; }
|
||||||
|
void SetErrorMsg(const char *msg);
|
||||||
|
|
||||||
|
const char *GetLastMsg();
|
||||||
|
trace_info_t *GetTrace() const { return m_pTrace; }
|
||||||
|
const char *GetFmtCache() { return m_FmtCache.c_str(); }
|
||||||
|
|
||||||
|
bool IsNativeFiltering() { return (m_iNatFunc > 0); }
|
||||||
|
bool InNativeFilter() { return m_InNativeFilter; }
|
||||||
|
private:
|
||||||
|
AMX *m_pAmx;
|
||||||
|
|
||||||
|
int m_iErrFunc;
|
||||||
|
int m_iModFunc;
|
||||||
|
int m_iNatFunc;
|
||||||
|
|
||||||
|
bool m_Handling;
|
||||||
|
|
||||||
|
//in the future, make this a stack!
|
||||||
|
bool m_InNativeFilter;
|
||||||
|
|
||||||
|
String m_MsgCache;
|
||||||
|
String m_FmtCache;
|
||||||
|
|
||||||
|
trace_info_t *m_pTrace;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern AMX_NATIVE_INFO g_DebugNatives[];
|
||||||
|
|
||||||
|
#endif //_INCLUDE_DEBUGGER_H_
|
@ -58,7 +58,9 @@ WeaponsVault g_weaponsData[MAX_WEAPONS];
|
|||||||
void Client_VGUIMenu(void* mValue)
|
void Client_VGUIMenu(void* mValue)
|
||||||
{
|
{
|
||||||
if (!mPlayer) return;
|
if (!mPlayer) return;
|
||||||
switch (mState++){
|
|
||||||
|
switch (mState++)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
mPlayer->menu = -(*(int*)mValue);
|
mPlayer->menu = -(*(int*)mValue);
|
||||||
break;
|
break;
|
||||||
@ -70,7 +72,9 @@ void Client_VGUIMenu(void* mValue)
|
|||||||
void Client_ShowMenu(void* mValue)
|
void Client_ShowMenu(void* mValue)
|
||||||
{
|
{
|
||||||
if (!mPlayer) return;
|
if (!mPlayer) return;
|
||||||
switch (mState++){
|
|
||||||
|
switch (mState++)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
mPlayer->keys = *(int*)mValue;
|
mPlayer->keys = *(int*)mValue;
|
||||||
break;
|
break;
|
||||||
@ -83,7 +87,9 @@ void Client_TeamInfo(void* mValue)
|
|||||||
{
|
{
|
||||||
if (mPlayer) return;
|
if (mPlayer) return;
|
||||||
static int index;
|
static int index;
|
||||||
switch (mState++) {
|
|
||||||
|
switch (mState++)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
index = *(int*)mValue;
|
index = *(int*)mValue;
|
||||||
break;
|
break;
|
||||||
@ -98,44 +104,57 @@ void Client_TeamInfo(void* mValue)
|
|||||||
void Client_TextMsg(void* mValue)
|
void Client_TextMsg(void* mValue)
|
||||||
{
|
{
|
||||||
if (mPlayer) return;
|
if (mPlayer) return;
|
||||||
switch (mState++) {
|
|
||||||
case 1:{
|
switch (mState++)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
char * msg = (char*)mValue;
|
char * msg = (char*)mValue;
|
||||||
if (!msg) break;
|
if (!msg) break;
|
||||||
if ( !strncmp("#Game_C", msg , 7) ) {
|
|
||||||
|
if (!strncmp("#Game_C", msg, 7))
|
||||||
|
{
|
||||||
g_game_timeleft = g_game_restarting = gpGlobals->time + 3;
|
g_game_timeleft = g_game_restarting = gpGlobals->time + 3;
|
||||||
//g_endround_time = gpGlobals->time;
|
//g_endround_time = gpGlobals->time;
|
||||||
//g_newround_time = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime") + 3;
|
//g_newround_time = gpGlobals->time + CVAR_GET_FLOAT("mp_freezetime") + 3;
|
||||||
}
|
}
|
||||||
else if (!strncmp("#Game_w", msg , 7) ) {
|
else if (!strncmp("#Game_w", msg, 7))
|
||||||
|
{
|
||||||
g_game_timeleft = -2;
|
g_game_timeleft = -2;
|
||||||
}
|
}
|
||||||
else if ( !strncmp("#game_clan_s", msg , 12) ){
|
else if (!strncmp("#game_clan_s", msg, 12))
|
||||||
|
{
|
||||||
g_game_timeleft = -3;
|
g_game_timeleft = -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:{
|
case 2:
|
||||||
|
{
|
||||||
char * msg = (char*)mValue;
|
char * msg = (char*)mValue;
|
||||||
if (!msg) break;
|
if (!msg) break;
|
||||||
if (g_game_timeleft == -2 ){
|
|
||||||
|
if (g_game_timeleft == -2)
|
||||||
|
{
|
||||||
g_game_timeleft = g_game_restarting = gpGlobals->time + atoi(msg);
|
g_game_timeleft = g_game_restarting = gpGlobals->time + atoi(msg);
|
||||||
//g_newround_time = g_game_timeleft + CVAR_GET_FLOAT("mp_freezetime");
|
//g_newround_time = g_game_timeleft + CVAR_GET_FLOAT("mp_freezetime");
|
||||||
}
|
}
|
||||||
else if (g_game_timeleft == -3)
|
else if (g_game_timeleft == -3)
|
||||||
g_game_restarting = atoi( msg ) * 60;
|
g_game_restarting = atoi(msg) * 60.0f;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3:{
|
case 3:
|
||||||
|
{
|
||||||
char * msg = (char*)mValue;
|
char * msg = (char*)mValue;
|
||||||
if (!msg) break;
|
if (!msg) break;
|
||||||
if (g_game_timeleft != -3) break;
|
if (g_game_timeleft != -3) break;
|
||||||
g_game_restarting += atoi(msg);
|
g_game_restarting += atoi(msg);
|
||||||
g_game_timeleft = g_game_restarting = gpGlobals->time + g_game_restarting;
|
g_game_timeleft = g_game_restarting = gpGlobals->time + g_game_restarting;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client_WeaponList(void* mValue)
|
void Client_WeaponList(void* mValue)
|
||||||
@ -144,7 +163,9 @@ void Client_WeaponList(void* mValue)
|
|||||||
//static int wpnList2;
|
//static int wpnList2;
|
||||||
static int iSlot;
|
static int iSlot;
|
||||||
static const char* wpnName;
|
static const char* wpnName;
|
||||||
switch (mState++) {
|
|
||||||
|
switch (mState++)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
wpnName = (char*)mValue;
|
wpnName = (char*)mValue;
|
||||||
break;
|
break;
|
||||||
@ -153,24 +174,12 @@ void Client_WeaponList(void* mValue)
|
|||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
int iId = *(int*)mValue;
|
int iId = *(int*)mValue;
|
||||||
/*int* blocker;
|
|
||||||
|
|
||||||
int iwpn = iId;
|
|
||||||
|
|
||||||
if (iId > 31) {
|
|
||||||
iwpn -= 31;
|
|
||||||
blocker = &wpnList2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
blocker = &wpnList;*/
|
|
||||||
|
|
||||||
if ((iId < 0 || iId >= MAX_WEAPONS) || (wpnList & (1<<iId)))
|
if ((iId < 0 || iId >= MAX_WEAPONS) || (wpnList & (1<<iId)))
|
||||||
break;
|
break;
|
||||||
wpnList |= (1<<iId);
|
wpnList |= (1<<iId);
|
||||||
g_weaponsData[iId].iId = iId;
|
g_weaponsData[iId].iId = iId;
|
||||||
g_weaponsData[iId].ammoSlot = iSlot;
|
g_weaponsData[iId].ammoSlot = iSlot;
|
||||||
g_weaponsData[iId].fullName.assign(wpnName);
|
g_weaponsData[iId].fullName.assign(wpnName);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +187,9 @@ void Client_CurWeapon(void* mValue)
|
|||||||
{
|
{
|
||||||
static int iState;
|
static int iState;
|
||||||
static int iId;
|
static int iId;
|
||||||
switch (mState++){
|
|
||||||
|
switch (mState++)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
iState = *(int*)mValue;
|
iState = *(int*)mValue;
|
||||||
break;
|
break;
|
||||||
@ -197,9 +208,10 @@ void Client_CurWeapon(void* mValue)
|
|||||||
|
|
||||||
void Client_AmmoX(void* mValue)
|
void Client_AmmoX(void* mValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
static int iAmmo;
|
static int iAmmo;
|
||||||
switch (mState++){
|
|
||||||
|
switch (mState++)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
iAmmo = *(int*)mValue;
|
iAmmo = *(int*)mValue;
|
||||||
break;
|
break;
|
||||||
@ -214,7 +226,9 @@ void Client_AmmoX(void* mValue)
|
|||||||
void Client_AmmoPickup(void* mValue)
|
void Client_AmmoPickup(void* mValue)
|
||||||
{
|
{
|
||||||
static int iSlot;
|
static int iSlot;
|
||||||
switch (mState++){
|
|
||||||
|
switch (mState++)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
iSlot = *(int*)mValue;
|
iSlot = *(int*)mValue;
|
||||||
break;
|
break;
|
||||||
@ -230,7 +244,9 @@ void Client_ScoreInfo(void* mValue)
|
|||||||
{
|
{
|
||||||
static int index;
|
static int index;
|
||||||
static int deaths;
|
static int deaths;
|
||||||
switch (mState++){
|
|
||||||
|
switch (mState++)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
index = *(int*)mValue;
|
index = *(int*)mValue;
|
||||||
break;
|
break;
|
||||||
@ -272,24 +288,21 @@ void Client_DeathMsg(void* mValue)
|
|||||||
static int victim_id;
|
static int victim_id;
|
||||||
static int hs;
|
static int hs;
|
||||||
|
|
||||||
switch (mState++){
|
switch (mState++)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
killer_id = *(int*)mValue;
|
killer_id = *(int*)mValue;
|
||||||
killer = (killer_id > 0 && killer_id < 33) ?
|
killer = (killer_id > 0 && killer_id < 33) ? GET_PLAYER_POINTER_I(killer_id) : 0;
|
||||||
GET_PLAYER_POINTER_I(killer_id) : 0;
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
victim_id = *(int*)mValue;
|
victim_id = *(int*)mValue;
|
||||||
victim = (victim_id > 0 && victim_id < 33) ?
|
victim = (victim_id > 0 && victim_id < 33) ? GET_PLAYER_POINTER_I(victim_id) : 0;
|
||||||
GET_PLAYER_POINTER_I(victim_id) : 0;
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
hs = *(int*)mValue;
|
hs = *(int*)mValue;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
if (!killer || !victim) break;
|
if (!killer || !victim) break;
|
||||||
|
|
||||||
victim->death_killer = killer_id;
|
victim->death_killer = killer_id;
|
||||||
victim->death_weapon.assign((char*)mValue);
|
victim->death_weapon.assign((char*)mValue);
|
||||||
victim->death_headshot = hs;
|
victim->death_headshot = hs;
|
||||||
|
@ -42,7 +42,8 @@ int LoadMetamodPlugin(const char *path, void **handle, PLUG_LOADTIME now);
|
|||||||
// from mplugin.h (metamod)
|
// from mplugin.h (metamod)
|
||||||
// Flags to indicate current "load" state of plugin.
|
// Flags to indicate current "load" state of plugin.
|
||||||
// NOTE: order is important, as greater/less comparisons are made.
|
// NOTE: order is important, as greater/less comparisons are made.
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
PL_EMPTY = 0, // empty slot
|
PL_EMPTY = 0, // empty slot
|
||||||
PL_VALID, // has valid info in it
|
PL_VALID, // has valid info in it
|
||||||
PL_BADFILE, // nonexistent file (open failed),
|
PL_BADFILE, // nonexistent file (open failed),
|
||||||
@ -55,11 +56,10 @@ typedef enum {
|
|||||||
|
|
||||||
// from h_export.h (metamod)
|
// from h_export.h (metamod)
|
||||||
// Our GiveFnptrsToDll, called by engine.
|
// Our GiveFnptrsToDll, called by engine.
|
||||||
typedef void (WINAPI *GIVE_ENGINE_FUNCTIONS_FN) (enginefuncs_t
|
typedef void (WINAPI *GIVE_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, globalvars_t *pGlobals);
|
||||||
*pengfuncsFromEngine, globalvars_t *pGlobals);
|
|
||||||
|
|
||||||
|
|
||||||
// *** CFakeMeta
|
// *** CFakeMeta
|
||||||
|
|
||||||
class CFakeMeta
|
class CFakeMeta
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -100,7 +100,6 @@ public:
|
|||||||
inline void SetStatus(PLUG_STATUS newStatus)
|
inline void SetStatus(PLUG_STATUS newStatus)
|
||||||
{ m_Status = newStatus; }
|
{ m_Status = newStatus; }
|
||||||
|
|
||||||
|
|
||||||
inline plugin_info_t * GetInfo()
|
inline plugin_info_t * GetInfo()
|
||||||
{ return m_Info; }
|
{ return m_Info; }
|
||||||
inline const plugin_info_t * GetInfo() const
|
inline const plugin_info_t * GetInfo() const
|
||||||
@ -232,4 +231,3 @@ extern CFakeMeta g_FakeMeta;
|
|||||||
#endif //FAKEMETA
|
#endif //FAKEMETA
|
||||||
|
|
||||||
#endif // #ifndef __FAKEMETA_H__
|
#endif // #ifndef __FAKEMETA_H__
|
||||||
|
|
||||||
|
272
amxmodx/file.cpp
272
amxmodx/file.cpp
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the
|
* under the terms of the GNU General Public<EFBFBD> License as published by the
|
||||||
* Free Software Foundation; either version 2 of the License, or (at
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
@ -63,11 +63,13 @@ class AutoFilePtr
|
|||||||
public:
|
public:
|
||||||
AutoFilePtr(FILE *fp) : m_FP(fp)
|
AutoFilePtr(FILE *fp) : m_FP(fp)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~AutoFilePtr()
|
~AutoFilePtr()
|
||||||
{
|
{
|
||||||
if (m_FP)
|
if (m_FP)
|
||||||
fclose(m_FP);
|
fclose(m_FP);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator FILE* ()
|
operator FILE* ()
|
||||||
{
|
{
|
||||||
return m_FP;
|
return m_FP;
|
||||||
@ -82,18 +84,24 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
|
|||||||
DIR *dp;
|
DIR *dp;
|
||||||
char* dirname = build_pathname("%s", get_amxstring(amx, params[1], 0, a));
|
char* dirname = build_pathname("%s", get_amxstring(amx, params[1], 0, a));
|
||||||
a = params[2];
|
a = params[2];
|
||||||
|
|
||||||
if ((dp = opendir (dirname)) == NULL)
|
if ((dp = opendir (dirname)) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
seekdir(dp, a);
|
seekdir(dp, a);
|
||||||
if ( (ep = readdir (dp)) != NULL ) {
|
|
||||||
|
if ((ep = readdir (dp)) != NULL)
|
||||||
|
{
|
||||||
cell *length = get_amxaddr(amx, params[5]);
|
cell *length = get_amxaddr(amx, params[5]);
|
||||||
*length = set_amxstring(amx, params[3], ep->d_name, params[4]);
|
*length = set_amxstring(amx, params[3], ep->d_name, params[4]);
|
||||||
a = telldir(dp);
|
a = telldir(dp);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
a = 0;
|
a = 0;
|
||||||
|
|
||||||
closedir (dp);
|
closedir (dp);
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
int tmp;
|
int tmp;
|
||||||
char *dirname = build_pathname("%s/*", get_amxstring(amx, params[1], 0, tmp));
|
char *dirname = build_pathname("%s/*", get_amxstring(amx, params[1], 0, tmp));
|
||||||
@ -101,10 +109,12 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
|
|||||||
|
|
||||||
_finddata_t fd;
|
_finddata_t fd;
|
||||||
intptr_t handle = _findfirst(dirname, &fd);
|
intptr_t handle = _findfirst(dirname, &fd);
|
||||||
|
|
||||||
if (handle < 0)
|
if (handle < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
++tmp;
|
++tmp;
|
||||||
|
|
||||||
for (int i = 0; i < tmp; ++i)
|
for (int i = 0; i < tmp; ++i)
|
||||||
{
|
{
|
||||||
if (_findnext(handle, &fd) < 0)
|
if (_findnext(handle, &fd) < 0)
|
||||||
@ -113,6 +123,7 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// current data in fd
|
// current data in fd
|
||||||
cell *length = get_amxaddr(amx, params[5]); // pointer to the outLen parameter
|
cell *length = get_amxaddr(amx, params[5]); // pointer to the outLen parameter
|
||||||
*length = set_amxstring(amx, params[3], fd.name, params[4]); // set output and outLen parameters
|
*length = set_amxstring(amx, params[3], fd.name, params[4]); // set output and outLen parameters
|
||||||
@ -127,25 +138,37 @@ static cell AMX_NATIVE_CALL read_file(AMX *amx, cell *params) /* 5 param */
|
|||||||
int iLen;
|
int iLen;
|
||||||
char* szFile = get_amxstring(amx, params[1], 0, iLen);
|
char* szFile = get_amxstring(amx, params[1], 0, iLen);
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if ( (fp =fopen(build_pathname("%s",szFile),"r")) == NULL) {
|
|
||||||
|
if ((fp =fopen(build_pathname("%s", szFile), "r")) == NULL)
|
||||||
|
{
|
||||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffor[1024];
|
char buffor[1024];
|
||||||
int i = 0, iLine = params[2];
|
int i = 0, iLine = params[2];
|
||||||
|
|
||||||
while ((i <= iLine) && fgets(buffor, 1023, fp))
|
while ((i <= iLine) && fgets(buffor, 1023, fp))
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (i > iLine){
|
|
||||||
|
if (i > iLine)
|
||||||
|
{
|
||||||
int len = strlen(buffor);
|
int len = strlen(buffor);
|
||||||
|
|
||||||
if (buffor[len - 1] == '\n')
|
if (buffor[len - 1] == '\n')
|
||||||
buffor[--len] = 0;
|
buffor[--len] = 0;
|
||||||
|
|
||||||
if (buffor[len - 1] == '\r')
|
if (buffor[len - 1] == '\r')
|
||||||
buffor[--len] = 0;
|
buffor[--len] = 0;
|
||||||
|
|
||||||
cell *length = get_amxaddr(amx, params[5]);
|
cell *length = get_amxaddr(amx, params[5]);
|
||||||
*length = set_amxstring(amx, params[3], buffor, params[4]);
|
*length = set_amxstring(amx, params[3], buffor, params[4]);
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,28 +181,37 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
|||||||
int iLine = params[3];
|
int iLine = params[3];
|
||||||
|
|
||||||
// apending to the end
|
// apending to the end
|
||||||
if (iLine < 0) {
|
if (iLine < 0)
|
||||||
if ( (pFile = fopen( sFile ,"a")) == NULL ){
|
{
|
||||||
|
if ((pFile = fopen(sFile, "a")) == NULL)
|
||||||
|
{
|
||||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs(sText, pFile);
|
fputs(sText, pFile);
|
||||||
fputc('\n', pFile);
|
fputc('\n', pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// creating a new file with a line in a middle
|
// creating a new file with a line in a middle
|
||||||
if ( (pFile = fopen(sFile,"r")) == NULL ) {
|
if ((pFile = fopen(sFile, "r")) == NULL)
|
||||||
if ( (pFile = fopen(sFile,"w")) == NULL ){
|
{
|
||||||
|
if ((pFile = fopen(sFile, "w")) == NULL)
|
||||||
|
{
|
||||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < iLine; ++i)
|
for (i = 0; i < iLine; ++i)
|
||||||
fputc('\n', pFile);
|
fputc('\n', pFile);
|
||||||
|
|
||||||
fputs(sText, pFile);
|
fputs(sText, pFile);
|
||||||
fputc('\n', pFile);
|
fputc('\n', pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,31 +219,38 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
|||||||
FILE* pTemp;
|
FILE* pTemp;
|
||||||
char buffor[2048];
|
char buffor[2048];
|
||||||
|
|
||||||
if ( (pTemp = tmpfile()) == NULL ){
|
if ((pTemp = tmpfile()) == NULL)
|
||||||
|
{
|
||||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0;;++i){
|
for (i = 0; ; ++i)
|
||||||
if ( i == iLine ){
|
{
|
||||||
|
if (i == iLine)
|
||||||
|
{
|
||||||
fgets(buffor, 2047, pFile);
|
fgets(buffor, 2047, pFile);
|
||||||
fputs(sText, pTemp);
|
fputs(sText, pTemp);
|
||||||
fputc('\n', pTemp);
|
fputc('\n', pTemp);
|
||||||
}
|
}
|
||||||
else if ( fgets(buffor,2047,pFile) ){
|
else if (fgets(buffor, 2047, pFile))
|
||||||
|
{
|
||||||
fputs(buffor, pTemp);
|
fputs(buffor, pTemp);
|
||||||
}
|
}
|
||||||
else if ( i < iLine ) {
|
else if (i < iLine)
|
||||||
|
{
|
||||||
fputc('\n', pTemp);
|
fputc('\n', pTemp);
|
||||||
}
|
}
|
||||||
else break;
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
rewind(pTemp);
|
rewind(pTemp);
|
||||||
|
|
||||||
// now rewrite because file can be now smaller...
|
// now rewrite because file can be now smaller...
|
||||||
if ( (pFile = fopen(sFile,"w")) == NULL ){
|
if ((pFile = fopen(sFile, "w")) == NULL)
|
||||||
|
{
|
||||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -221,6 +260,7 @@ static cell AMX_NATIVE_CALL write_file(AMX *amx, cell *params) /* 3 param */
|
|||||||
|
|
||||||
fclose(pTemp);
|
fclose(pTemp);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,6 +268,7 @@ static cell AMX_NATIVE_CALL delete_file(AMX *amx, cell *params) /* 1 param */
|
|||||||
{
|
{
|
||||||
int iLen;
|
int iLen;
|
||||||
char* sFile = get_amxstring(amx, params[1], 0, iLen);
|
char* sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||||
|
|
||||||
return (unlink(build_pathname("%s", sFile)) ? 0 : 1);
|
return (unlink(build_pathname("%s", sFile)) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,19 +277,26 @@ static cell AMX_NATIVE_CALL file_exists(AMX *amx, cell *params) /* 1 param */
|
|||||||
int iLen;
|
int iLen;
|
||||||
char *sFile = get_amxstring(amx, params[1], 0, iLen);
|
char *sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||||
char *file = build_pathname("%s", sFile);
|
char *file = build_pathname("%s", sFile);
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
DWORD attr = GetFileAttributes(file);
|
DWORD attr = GetFileAttributes(file);
|
||||||
|
|
||||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
if (stat(file, &s) != 0)
|
if (stat(file, &s) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (S_ISDIR(s.st_mode))
|
if (S_ISDIR(s.st_mode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -258,19 +306,26 @@ static cell AMX_NATIVE_CALL dir_exists(AMX *amx, cell *params) /* 1 param */
|
|||||||
int iLen;
|
int iLen;
|
||||||
char *sFile = get_amxstring(amx, params[1], 0, iLen);
|
char *sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||||
char *file = build_pathname("%s", sFile);
|
char *file = build_pathname("%s", sFile);
|
||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
DWORD attr = GetFileAttributes(file);
|
DWORD attr = GetFileAttributes(file);
|
||||||
|
|
||||||
if (attr == INVALID_FILE_ATTRIBUTES)
|
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
if (attr == FILE_ATTRIBUTE_DIRECTORY)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
if (stat(file, &s) != 0)
|
if (stat(file, &s) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (S_ISDIR(s.st_mode))
|
if (S_ISDIR(s.st_mode))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -280,22 +335,24 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
|
|||||||
int iLen;
|
int iLen;
|
||||||
char* sFile = get_amxstring(amx, params[1], 0, iLen);
|
char* sFile = get_amxstring(amx, params[1], 0, iLen);
|
||||||
AutoFilePtr fp(fopen(build_pathname("%s", sFile), "r"));
|
AutoFilePtr fp(fopen(build_pathname("%s", sFile), "r"));
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
if (params[0] < 2 || params[2] == 0)
|
if (params[0] < 2 || params[2] == 0)
|
||||||
{
|
{
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
int size = ftell(fp);
|
int size = ftell(fp);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
else if (params[2] == 1)
|
else if (params[2] == 1)
|
||||||
{
|
{
|
||||||
int a = 0,lines = 0;
|
int a = 0,lines = 0;
|
||||||
|
|
||||||
while (a != EOF)
|
while (a != EOF)
|
||||||
{
|
{
|
||||||
++lines;
|
++lines;
|
||||||
while ( (a = fgetc(fp)) != '\n' && a != EOF )
|
while ((a = fgetc(fp)) != '\n' && a != EOF);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
//int a, b = '\n';
|
//int a, b = '\n';
|
||||||
//while( (a = fgetc(fp)) != EOF ){
|
//while( (a = fgetc(fp)) != EOF ){
|
||||||
@ -307,13 +364,17 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
|
|||||||
// ++lines;
|
// ++lines;
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
else if ( params[2] == 2 ){
|
else if (params[2] == 2)
|
||||||
|
{
|
||||||
fseek(fp, -1, SEEK_END);
|
fseek(fp, -1, SEEK_END);
|
||||||
|
|
||||||
if (fgetc(fp) == '\n')
|
if (fgetc(fp) == '\n')
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +388,9 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
|
|||||||
char *flags = get_amxstring(amx, params[2], 0, len);
|
char *flags = get_amxstring(amx, params[2], 0, len);
|
||||||
|
|
||||||
FILE *fp = fopen(file, flags);
|
FILE *fp = fopen(file, flags);
|
||||||
if (fp == NULL) {
|
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
// Failed
|
// Failed
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -340,6 +403,7 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j == -1)
|
if (j == -1)
|
||||||
{
|
{
|
||||||
FileList.push_back(fp);
|
FileList.push_back(fp);
|
||||||
@ -354,10 +418,14 @@ static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
return fclose(fp);
|
return fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
@ -367,17 +435,24 @@ static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
buffer = new char[params[3]]; // SLOW!!! :TODO: Find a better way (auto pointers?)
|
buffer = new char[params[3]]; // SLOW!!! :TODO: Find a better way (auto pointers?)
|
||||||
fread(buffer, sizeof(char), params[3], fp);
|
fread(buffer, sizeof(char), params[3], fp);
|
||||||
set_amxstring(amx, params[2], buffer, params[3]);
|
set_amxstring(amx, params[2], buffer, params[3]);
|
||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,10 +460,14 @@ static cell AMX_NATIVE_CALL amx_fread(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_fgetc(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgetc(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
return fgetc(fp);
|
return fgetc(fp);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
@ -398,97 +477,128 @@ static cell AMX_NATIVE_CALL amx_fgetc(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_fwrite(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fwrite(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
int len;
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
buf = format_amxstring(amx, params, 2, len);
|
buf = format_amxstring(amx, params, 2, len);
|
||||||
return fwrite(buf, sizeof(char), strlen(buf), fp);
|
return fwrite(buf, sizeof(char), strlen(buf), fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_feof(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_feof(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
if (fp) {
|
|
||||||
if (feof(fp)) {
|
if (fp)
|
||||||
|
{
|
||||||
|
if (feof(fp))
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fseek(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fseek(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp) {
|
if (fp)
|
||||||
|
{
|
||||||
return fseek(fp, (long)params[2], params[3]);
|
return fseek(fp, (long)params[2], params[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fputc(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fputc(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp) {
|
if (fp)
|
||||||
|
{
|
||||||
return fputc(params[2], fp);
|
return fputc(params[2], fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_rewind(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_rewind(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp) {
|
if (fp)
|
||||||
|
{
|
||||||
rewind(fp);
|
rewind(fp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fflush(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fflush(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp) {
|
if (fp)
|
||||||
|
{
|
||||||
return fflush(fp);
|
return fflush(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
int len;
|
||||||
buf = format_amxstring(amx, params, 2, len);
|
buf = format_amxstring(amx, params, 2, len);
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
return fscanf(fp, "%s", buf);
|
return fscanf(fp, "%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,13 +608,17 @@ static cell AMX_NATIVE_CALL amx_fscanf(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_ftell(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_ftell(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
if (fp) {
|
if (fp)
|
||||||
|
{
|
||||||
return ftell(fp);
|
return ftell(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif //UNUSED
|
#endif //UNUSED
|
||||||
@ -514,12 +628,17 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
|
|||||||
int len;
|
int len;
|
||||||
char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
|
char *file = build_pathname("%s", format_amxstring(amx, params, 1, len));
|
||||||
long size;
|
long size;
|
||||||
|
|
||||||
AutoFilePtr fp(fopen(file, "rb"));
|
AutoFilePtr fp(fopen(file, "rb"));
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
size = ftell(fp);
|
size = ftell(fp);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,116 +646,156 @@ static cell AMX_NATIVE_CALL amx_filesize(AMX *amx, cell *params)
|
|||||||
static cell AMX_NATIVE_CALL amx_fgetl(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgetl(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
long t;
|
long t;
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
fread(&t, sizeof(long), 1, fp);
|
fread(&t, sizeof(long), 1, fp);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgeti(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
int t;
|
int t;
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
fread(&t, sizeof(int), 1, fp);
|
fread(&t, sizeof(int), 1, fp);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgets(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
short t;
|
short t;
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
fread(&t, sizeof(short), 1, fp);
|
fread(&t, sizeof(short), 1, fp);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fputs(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fputs(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
short size = params[2];
|
short size = params[2];
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
return fwrite(&size, sizeof(short), 1, fp);
|
return fwrite(&size, sizeof(short), 1, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fputl(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fputl(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
long size = params[2];
|
long size = params[2];
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
return fwrite(&size, sizeof(long), 1, fp);
|
return fwrite(&size, sizeof(long), 1, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fputi(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fputi(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
int size = params[2];
|
int size = params[2];
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
return fwrite(&size, sizeof(int), 1, fp);
|
return fwrite(&size, sizeof(int), 1, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fgetf(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fgetf(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
float t;
|
float t;
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
fread(&t, sizeof(float), 1, fp);
|
fread(&t, sizeof(float), 1, fp);
|
||||||
return *(cell*)&t;
|
return *(cell*)&t;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_fputf(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_fputf(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
unsigned int id = params[1] - 1;
|
unsigned int id = params[1] - 1;
|
||||||
|
|
||||||
if (id >= FileList.size() || FileList.at(id) == NULL)
|
if (id >= FileList.size() || FileList.at(id) == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FILE *fp = FileList.at(id);
|
FILE *fp = FileList.at(id);
|
||||||
|
|
||||||
float size = *(float *)((void *)¶ms[2]);
|
float size = *(float *)((void *)¶ms[2]);
|
||||||
if (fp) {
|
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
return fwrite(&size, sizeof(float), 1, fp);
|
return fwrite(&size, sizeof(float), 1, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif //UNUSED
|
#endif //UNUSED
|
||||||
@ -645,6 +804,7 @@ static cell AMX_NATIVE_CALL amx_build_pathname(AMX *amx, cell *params)
|
|||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *szPath = get_amxstring(amx, params[1], 0, len);
|
char *szPath = get_amxstring(amx, params[1], 0, len);
|
||||||
|
|
||||||
return set_amxstring(amx, params[2], build_pathname("%s", szPath), params[3]);
|
return set_amxstring(amx, params[2], build_pathname("%s", szPath), params[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,24 +815,32 @@ static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params)
|
|||||||
|
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
char *dirname = build_pathname("%s\\*", path);
|
char *dirname = build_pathname("%s\\*", path);
|
||||||
|
|
||||||
WIN32_FIND_DATA fd;
|
WIN32_FIND_DATA fd;
|
||||||
HANDLE hFile = FindFirstFile(dirname, &fd);
|
HANDLE hFile = FindFirstFile(dirname, &fd);
|
||||||
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
||||||
|
|
||||||
return (DWORD)hFile;
|
return (DWORD)hFile;
|
||||||
#else
|
#else
|
||||||
char *dirname = build_pathname("%s", path);
|
char *dirname = build_pathname("%s", path);
|
||||||
DIR *dp = opendir(dirname);
|
DIR *dp = opendir(dirname);
|
||||||
|
|
||||||
if (!dp)
|
if (!dp)
|
||||||
return NULL;
|
return NULL;
|
||||||
struct dirent *ep = readdir(dp);
|
struct dirent *ep = readdir(dp);
|
||||||
|
|
||||||
if (!ep)
|
if (!ep)
|
||||||
{
|
{
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_amxstring(amx, params[2], ep->d_name, params[3]);
|
set_amxstring(amx, params[2], ep->d_name, params[3]);
|
||||||
|
|
||||||
return (cell)dp;
|
return (cell)dp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -681,14 +849,19 @@ static cell AMX_NATIVE_CALL amx_close_dir(AMX *amx, cell *params)
|
|||||||
{
|
{
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
HANDLE hFile = (HANDLE)((DWORD)params[1]);
|
HANDLE hFile = (HANDLE)((DWORD)params[1]);
|
||||||
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
|
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FindClose(hFile);
|
FindClose(hFile);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
DIR *dp = (DIR *)params[1];
|
DIR *dp = (DIR *)params[1];
|
||||||
|
|
||||||
if (!dp)
|
if (!dp)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
@ -698,26 +871,36 @@ static cell AMX_NATIVE_CALL amx_get_dir(AMX *amx, cell *params)
|
|||||||
{
|
{
|
||||||
#if defined WIN32 || defined _WIN32
|
#if defined WIN32 || defined _WIN32
|
||||||
HANDLE hFile = (HANDLE)((DWORD)params[1]);
|
HANDLE hFile = (HANDLE)((DWORD)params[1]);
|
||||||
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
|
if (hFile == INVALID_HANDLE_VALUE || hFile == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
WIN32_FIND_DATA fd;
|
WIN32_FIND_DATA fd;
|
||||||
|
|
||||||
if (!FindNextFile(hFile, &fd))
|
if (!FindNextFile(hFile, &fd))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
DIR *dp = (DIR *)params[1];
|
DIR *dp = (DIR *)params[1];
|
||||||
|
|
||||||
if (!dp)
|
if (!dp)
|
||||||
return 0;
|
return 0;
|
||||||
struct dirent *ep = readdir(dp);
|
struct dirent *ep = readdir(dp);
|
||||||
|
|
||||||
if (!ep)
|
if (!ep)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
set_amxstring(amx, params[2], ep->d_name, params[3]);
|
set_amxstring(amx, params[2], ep->d_name, params[3]);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO file_Natives[] = {
|
AMX_NATIVE_INFO file_Natives[] =
|
||||||
|
{
|
||||||
{"delete_file", delete_file},
|
{"delete_file", delete_file},
|
||||||
{"file_exists", file_exists},
|
{"file_exists", file_exists},
|
||||||
{"file_size", file_size},
|
{"file_size", file_size},
|
||||||
@ -754,8 +937,5 @@ AMX_NATIVE_INFO file_Natives[] = {
|
|||||||
{"open_dir", amx_open_dir},
|
{"open_dir", amx_open_dir},
|
||||||
{"close_dir", amx_close_dir},
|
{"close_dir", amx_close_dir},
|
||||||
{"next_file", amx_get_dir},
|
{"next_file", amx_get_dir},
|
||||||
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -49,5 +49,6 @@
|
|||||||
#define STATIC_MODULE 1
|
#define STATIC_MODULE 1
|
||||||
|
|
||||||
int CheckModules(AMX *amx, char error[128]);
|
int CheckModules(AMX *amx, char error[128]);
|
||||||
|
const char *StrCaseStr(const char *as, const char *bs);
|
||||||
|
|
||||||
#endif // __MODULES_H__
|
#endif // __MODULES_H__
|
||||||
|
@ -42,12 +42,13 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib ..\zlib\zlib.lib"
|
AdditionalDependencies="..\JIT\natives-x86.obj ..\zlib\zlib.lib"
|
||||||
OutputFile="debug/amxmodx_mm.dll"
|
OutputFile="debug/amxmodx_mm.dll"
|
||||||
Version="0.1"
|
Version="0.1"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
AdditionalLibraryDirectories="..\extra\lib_win32"
|
AdditionalLibraryDirectories="..\extra\lib_win32"
|
||||||
|
IgnoreDefaultLibraryNames="MSVCRT"
|
||||||
ModuleDefinitionFile=""
|
ModuleDefinitionFile=""
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
ProgramDatabaseFile=".\debug/amxx_mm.pdb"
|
ProgramDatabaseFile=".\debug/amxx_mm.pdb"
|
||||||
@ -112,11 +113,12 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib ..\zlib\zlib.lib"
|
AdditionalDependencies="odbc32.lib odbccp32.lib ..\zlib\zlib.lib ..\JIT\natives-x86.obj"
|
||||||
OutputFile="release/amxmodx_mm.dll"
|
OutputFile="release/amxmodx_mm.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
AdditionalLibraryDirectories="..\extra\lib_win32"
|
AdditionalLibraryDirectories="..\extra\lib_win32"
|
||||||
|
IgnoreDefaultLibraryNames="LIBC"
|
||||||
ModuleDefinitionFile=""
|
ModuleDefinitionFile=""
|
||||||
ProgramDatabaseFile=".\release/amxx_mm.pdb"
|
ProgramDatabaseFile=".\release/amxx_mm.pdb"
|
||||||
ImportLibrary=".\release/amxx_mm.lib"/>
|
ImportLibrary=".\release/amxx_mm.lib"/>
|
||||||
@ -179,12 +181,13 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib ..\zlib\zlib.lib"
|
AdditionalDependencies="odbc32.lib odbccp32.lib ..\zlib\zlib.lib ..\JIT\natives-x86.obj"
|
||||||
OutputFile="memtestdebug/amxmodx_mm.dll"
|
OutputFile="memtestdebug/amxmodx_mm.dll"
|
||||||
Version="0.1"
|
Version="0.1"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
AdditionalLibraryDirectories="..\extra\lib_win32"
|
AdditionalLibraryDirectories="..\extra\lib_win32"
|
||||||
|
IgnoreDefaultLibraryNames="MSVCRT"
|
||||||
ModuleDefinitionFile=""
|
ModuleDefinitionFile=""
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
ProgramDatabaseFile=".\memtestdebug/amxx_mm.pdb"
|
ProgramDatabaseFile=".\memtestdebug/amxx_mm.pdb"
|
||||||
@ -249,11 +252,12 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="odbc32.lib odbccp32.lib ..\zlib\zlib.lib"
|
AdditionalDependencies="odbc32.lib odbccp32.lib ..\zlib\zlib.lib ..\JIT\natives-x86.obj"
|
||||||
OutputFile="memtestrelease/amxmodx_mm.dll"
|
OutputFile="memtestrelease/amxmodx_mm.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
AdditionalLibraryDirectories="..\extra\lib_win32"
|
AdditionalLibraryDirectories="..\extra\lib_win32"
|
||||||
|
IgnoreDefaultLibraryNames="LIBC"
|
||||||
ModuleDefinitionFile=""
|
ModuleDefinitionFile=""
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
ProgramDatabaseFile=".\memtestrelease/amxx_mm.pdb"
|
ProgramDatabaseFile=".\memtestrelease/amxx_mm.pdb"
|
||||||
@ -371,6 +375,7 @@
|
|||||||
GlobalOptimizations="TRUE"
|
GlobalOptimizations="TRUE"
|
||||||
InlineFunctionExpansion="1"
|
InlineFunctionExpansion="1"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
|
OmitFramePointers="TRUE"
|
||||||
AdditionalIncludeDirectories="..\..\metamod\metamod,..\..\hlsdk\sourcecode\common,..\..\hlsdk\sourcecode\engine,..\..\hlsdk\sourcecode\dlls,..\..\hlsdk\sourcecode\pm_shared,..\extra\include"
|
AdditionalIncludeDirectories="..\..\metamod\metamod,..\..\hlsdk\sourcecode\common,..\..\hlsdk\sourcecode\engine,..\..\hlsdk\sourcecode\dlls,..\..\hlsdk\sourcecode\pm_shared,..\extra\include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;amxmodx_EXPORTS;JIT;ASM32;PAWN_CELL_SIZE=32"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;amxmodx_EXPORTS;JIT;ASM32;PAWN_CELL_SIZE=32"
|
||||||
IgnoreStandardIncludePath="FALSE"
|
IgnoreStandardIncludePath="FALSE"
|
||||||
@ -462,11 +467,12 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/MACHINE:I386"
|
AdditionalOptions="/MACHINE:I386"
|
||||||
AdditionalDependencies="..\zlib\zlib.lib ..\JIT\amxjitsn.obj ..\JIT\amxexecn.obj"
|
AdditionalDependencies="..\zlib\zlib.lib ..\JIT\amxjitsn.obj ..\JIT\amxexecn.obj ..\JIT\natives-x86.obj"
|
||||||
OutputFile="jitmemtestrelease/amxmodx_mm.dll"
|
OutputFile="jitmemtestrelease/amxmodx_mm.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="TRUE"
|
SuppressStartupBanner="TRUE"
|
||||||
AdditionalLibraryDirectories="..\extra\lib_win32"
|
AdditionalLibraryDirectories="..\extra\lib_win32"
|
||||||
|
IgnoreDefaultLibraryNames="MSVCRT"
|
||||||
ModuleDefinitionFile=""
|
ModuleDefinitionFile=""
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
ProgramDatabaseFile=".\jitmemtestrelease/amxx_mm.pdb"
|
ProgramDatabaseFile=".\jitmemtestrelease/amxx_mm.pdb"
|
||||||
@ -634,6 +640,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath="..\CVault.cpp">
|
RelativePath="..\CVault.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\debugger.cpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\emsg.cpp">
|
RelativePath="..\emsg.cpp">
|
||||||
</File>
|
</File>
|
||||||
@ -792,6 +801,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath="..\CVector.h">
|
RelativePath="..\CVector.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\debugger.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\fakemeta.h">
|
RelativePath="..\fakemeta.h">
|
||||||
</File>
|
</File>
|
||||||
@ -837,6 +849,25 @@
|
|||||||
RelativePath="..\version.rc">
|
RelativePath="..\version.rc">
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Assembly"
|
||||||
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath="..\amxdefn.asm">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\amxexecn.asm">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\amxjitsn.asm">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\natives-amd64.asm">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\natives-x86.asm">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
@ -95,4 +95,6 @@ _amxx_DynaCodesize:
|
|||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
section .data
|
||||||
|
|
||||||
GLOBAL_GATE DD 0
|
GLOBAL_GATE DD 0
|
||||||
|
@ -29,13 +29,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
#include <malloc.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "CStack.h"
|
#include "CStack.h"
|
||||||
#include "natives.h"
|
#include "natives.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include "sclinux.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Written by David "BAILOPAN" Anderson
|
//Written by David "BAILOPAN" Anderson
|
||||||
@ -265,8 +266,7 @@ static cell AMX_NATIVE_CALL get_array(AMX *amx, cell *params)
|
|||||||
|
|
||||||
int size = params[3];
|
int size = params[3];
|
||||||
|
|
||||||
while (size-->0)
|
memcpy(dest, source, size * sizeof(cell));
|
||||||
*dest = *source;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -292,8 +292,7 @@ static cell AMX_NATIVE_CALL set_array(AMX *amx, cell *params)
|
|||||||
|
|
||||||
int size = params[3];
|
int size = params[3];
|
||||||
|
|
||||||
while (size-->0)
|
memcpy(dest, source, size * sizeof(cell));
|
||||||
*dest = *source;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -408,7 +407,7 @@ void ClearPluginLibraries()
|
|||||||
|
|
||||||
for (size_t i=0; i<g_RegNatives.size(); i++)
|
for (size_t i=0; i<g_RegNatives.size(); i++)
|
||||||
{
|
{
|
||||||
delete g_RegNatives[i]->pfn;
|
delete [] g_RegNatives[i]->pfn;
|
||||||
delete g_RegNatives[i];
|
delete g_RegNatives[i];
|
||||||
}
|
}
|
||||||
g_RegNatives.clear();
|
g_RegNatives.clear();
|
||||||
@ -423,7 +422,7 @@ AMX_NATIVE_INFO g_NativeNatives[] = {
|
|||||||
{"get_param", get_param},
|
{"get_param", get_param},
|
||||||
{"get_param_byref", get_param_byref},
|
{"get_param_byref", get_param_byref},
|
||||||
{"set_param_byref", set_param_byref},
|
{"set_param_byref", set_param_byref},
|
||||||
{"get_array", set_array},
|
{"get_array", get_array},
|
||||||
{"set_array", set_array},
|
{"set_array", set_array},
|
||||||
//these are dummy functions for floats ;p
|
//these are dummy functions for floats ;p
|
||||||
{"get_param_f", get_param},
|
{"get_param_f", get_param},
|
||||||
|
@ -1,3 +1,33 @@
|
|||||||
|
/* AMX Mod X
|
||||||
|
*
|
||||||
|
* by the AMX Mod X Development Team
|
||||||
|
* originally developed by OLO
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the author gives permission to
|
||||||
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
|
* you do not wish to do so, delete this exception statement from your
|
||||||
|
* version.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
#include "newmenus.h"
|
#include "newmenus.h"
|
||||||
|
|
||||||
@ -7,6 +37,7 @@ void ClearMenus()
|
|||||||
{
|
{
|
||||||
for (size_t i = 0; i < g_NewMenus.size(); i++)
|
for (size_t i = 0; i < g_NewMenus.size(); i++)
|
||||||
delete g_NewMenus[i];
|
delete g_NewMenus[i];
|
||||||
|
|
||||||
g_NewMenus.clear();
|
g_NewMenus.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +52,7 @@ Menu::~Menu()
|
|||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_Items.size(); i++)
|
for (size_t i = 0; i < m_Items.size(); i++)
|
||||||
delete m_Items[i];
|
delete m_Items[i];
|
||||||
|
|
||||||
m_Items.clear();
|
m_Items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,16 +112,21 @@ int Menu::PagekeyToItem(page_t page, item_t key)
|
|||||||
if (page == 0)
|
if (page == 0)
|
||||||
{
|
{
|
||||||
item_t rem = numItems >= 7 ? 7 : numItems;
|
item_t rem = numItems >= 7 ? 7 : numItems;
|
||||||
|
|
||||||
if (key == rem)
|
if (key == rem)
|
||||||
{
|
{
|
||||||
if (pages > 1)
|
if (pages > 1)
|
||||||
return MENU_MORE;
|
return MENU_MORE;
|
||||||
else
|
else
|
||||||
return MENU_EXIT;
|
return MENU_EXIT;
|
||||||
} else if (key == rem+1) {
|
}
|
||||||
|
else if (key == rem + 1)
|
||||||
|
{
|
||||||
return MENU_EXIT;
|
return MENU_EXIT;
|
||||||
}
|
}
|
||||||
} else if (page == pages - 1) {
|
}
|
||||||
|
else if (page == pages - 1)
|
||||||
|
{
|
||||||
//find number of remaining items
|
//find number of remaining items
|
||||||
//for example, 11 items on page 1... means start=7, 11-7=4
|
//for example, 11 items on page 1... means start=7, 11-7=4
|
||||||
item_t rem = numItems - start;
|
item_t rem = numItems - start;
|
||||||
@ -97,14 +134,18 @@ int Menu::PagekeyToItem(page_t page, item_t key)
|
|||||||
if (key == rem)
|
if (key == rem)
|
||||||
{
|
{
|
||||||
return MENU_EXIT;
|
return MENU_EXIT;
|
||||||
} else if (key == rem+1) {
|
}
|
||||||
|
else if (key == rem + 1)
|
||||||
|
{
|
||||||
return MENU_BACK;
|
return MENU_BACK;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (key == 7)
|
if (key == 7)
|
||||||
{
|
{
|
||||||
return MENU_MORE;
|
return MENU_MORE;
|
||||||
} else if (key == 8) {
|
}
|
||||||
|
else if (key == 8)
|
||||||
|
{
|
||||||
return MENU_BACK;
|
return MENU_BACK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,6 +191,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
_snprintf(buffer, sizeof(buffer)-1, "\\y%s %d/%d\n\\w\n", m_Title.c_str(), page + 1, pages);
|
_snprintf(buffer, sizeof(buffer)-1, "\\y%s %d/%d\n\\w\n", m_Title.c_str(), page + 1, pages);
|
||||||
else
|
else
|
||||||
_snprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.c_str(), page + 1, pages);
|
_snprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.c_str(), page + 1, pages);
|
||||||
|
|
||||||
m_Text.append(buffer);
|
m_Text.append(buffer);
|
||||||
|
|
||||||
item_t start = page * 7;
|
item_t start = page * 7;
|
||||||
@ -162,15 +204,19 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
}
|
}
|
||||||
|
|
||||||
menuitem *pItem = NULL;
|
menuitem *pItem = NULL;
|
||||||
|
|
||||||
int option = 0;
|
int option = 0;
|
||||||
keys = 0;
|
keys = 0;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
for (item_t i = start; i < end; i++)
|
for (item_t i = start; i < end; i++)
|
||||||
{
|
{
|
||||||
pItem = m_Items[i];
|
pItem = m_Items[i];
|
||||||
|
|
||||||
if (pItem->access && !(pItem->access & g_players[player].flags[0]))
|
if (pItem->access && !(pItem->access & g_players[player].flags[0]))
|
||||||
enabled = false;
|
enabled = false;
|
||||||
|
|
||||||
if (pItem->handler != -1)
|
if (pItem->handler != -1)
|
||||||
{
|
{
|
||||||
ret = executeForwards(pItem->handler, player, thisId, i);
|
ret = executeForwards(pItem->handler, player, thisId, i);
|
||||||
@ -179,6 +225,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
else if (ret == ITEM_DISABLED)
|
else if (ret == ITEM_DISABLED)
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pItem->pfn)
|
if (pItem->pfn)
|
||||||
{
|
{
|
||||||
ret = (pItem->pfn)(player, thisId, i);
|
ret = (pItem->pfn)(player, thisId, i);
|
||||||
@ -187,6 +234,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
else if (ret == ITEM_DISABLED)
|
else if (ret == ITEM_DISABLED)
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
keys |= (1<<option);
|
keys |= (1<<option);
|
||||||
@ -202,6 +250,7 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
}
|
}
|
||||||
m_Text.append(buffer);
|
m_Text.append(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//now for a weird part >:o
|
//now for a weird part >:o
|
||||||
//this will either be MORE or BACK..
|
//this will either be MORE or BACK..
|
||||||
keys |= (1<<option++);
|
keys |= (1<<option++);
|
||||||
@ -211,7 +260,9 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
|||||||
} else {
|
} else {
|
||||||
_snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", option, "Exit");
|
_snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", option, "Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Text.append(buffer);
|
m_Text.append(buffer);
|
||||||
|
|
||||||
if (pages > 1)
|
if (pages > 1)
|
||||||
{
|
{
|
||||||
keys |= (1<<option++);
|
keys |= (1<<option++);
|
||||||
@ -241,6 +292,7 @@ static cell AMX_NATIVE_CALL menu_create(AMX *amx, cell *params)
|
|||||||
char *handler = get_amxstring(amx, params[2], 1, len);
|
char *handler = get_amxstring(amx, params[2], 1, len);
|
||||||
|
|
||||||
int func = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
int func = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||||
|
|
||||||
if (func == -1)
|
if (func == -1)
|
||||||
{
|
{
|
||||||
LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler);
|
LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler);
|
||||||
@ -363,6 +415,58 @@ static cell AMX_NATIVE_CALL menu_makecallback(AMX *amx, cell *params)
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL menu_item_setname(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
GETMENU(params[1]);
|
||||||
|
|
||||||
|
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
|
||||||
|
|
||||||
|
if (!pItem)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int len;
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
name = get_amxstring(amx, params[3], 0, len);
|
||||||
|
|
||||||
|
pItem->name.assign(name);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL menu_item_setcmd(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
GETMENU(params[1]);
|
||||||
|
|
||||||
|
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
|
||||||
|
|
||||||
|
if (!pItem)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int len;
|
||||||
|
char *cmd;
|
||||||
|
|
||||||
|
cmd = get_amxstring(amx, params[3], 0, len);
|
||||||
|
|
||||||
|
pItem->cmd.assign(cmd);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL menu_item_setcall(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
GETMENU(params[1]);
|
||||||
|
|
||||||
|
menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
|
||||||
|
|
||||||
|
if (!pItem)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
pItem->handler = params[3];
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO g_NewMenuNatives[] =
|
AMX_NATIVE_INFO g_NewMenuNatives[] =
|
||||||
{
|
{
|
||||||
{"menu_create", menu_create},
|
{"menu_create", menu_create},
|
||||||
@ -373,5 +477,8 @@ AMX_NATIVE_INFO g_NewMenuNatives[] =
|
|||||||
{"menu_find_id", menu_find_id},
|
{"menu_find_id", menu_find_id},
|
||||||
{"menu_item_getinfo", menu_item_getinfo},
|
{"menu_item_getinfo", menu_item_getinfo},
|
||||||
{"menu_makecallback", menu_makecallback},
|
{"menu_makecallback", menu_makecallback},
|
||||||
|
{"menu_item_setcall", menu_item_setcall},
|
||||||
|
{"menu_item_setcmd", menu_item_setcmd},
|
||||||
|
{"menu_item_setname", menu_item_setname},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,34 @@
|
|||||||
|
/* AMX Mod X
|
||||||
|
*
|
||||||
|
* by the AMX Mod X Development Team
|
||||||
|
* originally developed by OLO
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the author gives permission to
|
||||||
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
|
* you do not wish to do so, delete this exception statement from your
|
||||||
|
* version.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _INCLUDE_NEWMENUS_H
|
#ifndef _INCLUDE_NEWMENUS_H
|
||||||
#define _INCLUDE_NEWMENUS_H
|
#define _INCLUDE_NEWMENUS_H
|
||||||
|
|
||||||
@ -16,8 +47,10 @@ struct menuitem
|
|||||||
{
|
{
|
||||||
String name;
|
String name;
|
||||||
String cmd;
|
String cmd;
|
||||||
|
|
||||||
int access;
|
int access;
|
||||||
int handler;
|
int handler;
|
||||||
|
|
||||||
MENUITEM_CALLBACK pfn;
|
MENUITEM_CALLBACK pfn;
|
||||||
size_t id;
|
size_t id;
|
||||||
};
|
};
|
||||||
@ -31,18 +64,23 @@ class Menu
|
|||||||
public:
|
public:
|
||||||
Menu(const char *title, int menuId, int thisId);
|
Menu(const char *title, int menuId, int thisId);
|
||||||
~Menu();
|
~Menu();
|
||||||
|
|
||||||
menuitem *GetMenuItem(item_t item);
|
menuitem *GetMenuItem(item_t item);
|
||||||
size_t GetPageCount();
|
size_t GetPageCount();
|
||||||
size_t GetItemCount();
|
size_t GetItemCount();
|
||||||
menuitem *AddItem(const char *name, const char *cmd, int access);
|
menuitem *AddItem(const char *name, const char *cmd, int access);
|
||||||
|
|
||||||
const char *GetTextString(int player, page_t page, int &keys);
|
const char *GetTextString(int player, page_t page, int &keys);
|
||||||
bool Display(int player, page_t page);
|
bool Display(int player, page_t page);
|
||||||
|
|
||||||
int PagekeyToItem(page_t page, item_t key);
|
int PagekeyToItem(page_t page, item_t key);
|
||||||
int GetMenuMenuid();
|
int GetMenuMenuid();
|
||||||
private:
|
private:
|
||||||
CVector<menuitem * > m_Items;
|
CVector<menuitem * > m_Items;
|
||||||
|
|
||||||
String m_Title;
|
String m_Title;
|
||||||
String m_Text;
|
String m_Text;
|
||||||
|
|
||||||
int menuId;
|
int menuId;
|
||||||
int thisId;
|
int thisId;
|
||||||
};
|
};
|
||||||
|
@ -45,8 +45,6 @@
|
|||||||
enginefuncs_t g_engfuncs;
|
enginefuncs_t g_engfuncs;
|
||||||
globalvars_t *gpGlobals;
|
globalvars_t *gpGlobals;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_FUNCTIONS *g_pFunctionTable;
|
DLL_FUNCTIONS *g_pFunctionTable;
|
||||||
DLL_FUNCTIONS *g_pFunctionTable_Post;
|
DLL_FUNCTIONS *g_pFunctionTable_Post;
|
||||||
enginefuncs_t *g_pengfuncsTable;
|
enginefuncs_t *g_pengfuncsTable;
|
||||||
@ -54,7 +52,6 @@ enginefuncs_t *g_pengfuncsTable_Post;
|
|||||||
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
|
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
|
||||||
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
|
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
|
||||||
|
|
||||||
|
|
||||||
// GetEntityAPI2 functions
|
// GetEntityAPI2 functions
|
||||||
static DLL_FUNCTIONS g_EntityAPI_Table =
|
static DLL_FUNCTIONS g_EntityAPI_Table =
|
||||||
{
|
{
|
||||||
@ -2481,9 +2478,11 @@ PFN_IS_PLAYER_CONNECTING g_fn_IsPlayerConnecting;
|
|||||||
PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
||||||
PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||||
PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
PFN_ALLOCATOR g_fn_Allocator;
|
PFN_ALLOCATOR g_fn_Allocator;
|
||||||
PFN_REALLOCATOR g_fn_Reallocator;
|
PFN_REALLOCATOR g_fn_Reallocator;
|
||||||
PFN_DEALLOCATOR g_fn_Deallocator;
|
PFN_DEALLOCATOR g_fn_Deallocator;
|
||||||
|
#endif
|
||||||
PFN_AMX_EXEC g_fn_AmxExec;
|
PFN_AMX_EXEC g_fn_AmxExec;
|
||||||
PFN_AMX_EXECV g_fn_AmxExecv;
|
PFN_AMX_EXECV g_fn_AmxExecv;
|
||||||
PFN_AMX_ALLOT g_fn_AmxAllot;
|
PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||||
@ -2613,10 +2612,12 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||||||
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
|
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
|
||||||
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
|
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
// Memory
|
// Memory
|
||||||
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
|
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
|
||||||
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
||||||
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
||||||
|
#endif
|
||||||
|
|
||||||
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
||||||
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
||||||
@ -2735,6 +2736,8 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
|
|
||||||
/************* MEMORY *************/
|
/************* MEMORY *************/
|
||||||
// undef all defined macros
|
// undef all defined macros
|
||||||
#undef new
|
#undef new
|
||||||
@ -2906,6 +2909,30 @@ void operator delete[](void *reportedAddress)
|
|||||||
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
|
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if !defined NO_ALLOC_OVERRIDES && !defined MEMORY_TEST && !defined WIN32
|
||||||
|
void * ::operator new(size_t size) {
|
||||||
|
return(calloc(1, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void * ::operator new[](size_t size) {
|
||||||
|
return(calloc(1, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ::operator delete(void * ptr) {
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ::operator delete[](void * ptr) {
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
/************* stuff from dlls/util.cpp *************/
|
/************* stuff from dlls/util.cpp *************/
|
||||||
// must come here because cbase.h declares it's own operator new
|
// must come here because cbase.h declares it's own operator new
|
||||||
|
|
||||||
|
@ -46,8 +46,6 @@ struct amxx_module_info_s
|
|||||||
const char *logtag; // added in version 2
|
const char *logtag; // added in version 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// return values from functions called by amxx
|
// return values from functions called by amxx
|
||||||
#define AMXX_OK 0 /* no error */
|
#define AMXX_OK 0 /* no error */
|
||||||
#define AMXX_IFVERS 1 /* interface version */
|
#define AMXX_IFVERS 1 /* interface version */
|
||||||
@ -1981,12 +1979,14 @@ typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
|||||||
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const size_t /*size*/);
|
const unsigned int /*type*/, const size_t /*size*/);
|
||||||
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
|
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
|
||||||
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const void* /*addr*/ );
|
const unsigned int /*type*/, const void* /*addr*/ );
|
||||||
|
#endif
|
||||||
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/);
|
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/);
|
||||||
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
|
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
|
||||||
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
|
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
|
||||||
@ -2048,7 +2048,6 @@ extern PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
|||||||
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||||
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||||
extern PFN_AMX_EXEC g_fn_AmxExec;
|
extern PFN_AMX_EXEC g_fn_AmxExec;
|
||||||
extern PFN_AMX_EXECV g_fn_AmxExecv;
|
|
||||||
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||||
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
||||||
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
||||||
@ -2193,6 +2192,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
|
|||||||
#define MF_RequestFunction g_fn_RequestFunction;
|
#define MF_RequestFunction g_fn_RequestFunction;
|
||||||
#define MF_AmxPush g_fn_AmxPush
|
#define MF_AmxPush g_fn_AmxPush
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
/*** Memory ***/
|
/*** Memory ***/
|
||||||
void *operator new(size_t reportedSize);
|
void *operator new(size_t reportedSize);
|
||||||
void *operator new[](size_t reportedSize);
|
void *operator new[](size_t reportedSize);
|
||||||
@ -2236,4 +2236,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
|
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
|
||||||
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
|
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
|
||||||
|
|
||||||
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -21,6 +21,16 @@
|
|||||||
// metamod plugin?
|
// metamod plugin?
|
||||||
// #define USE_METAMOD
|
// #define USE_METAMOD
|
||||||
|
|
||||||
|
// use memory manager/tester?
|
||||||
|
// note that if you use this, you cannot construct/allocate
|
||||||
|
// anything before the module attached (OnAmxxAttach).
|
||||||
|
// be careful of default constructors using new/malloc!
|
||||||
|
// #define MEMORY_TEST
|
||||||
|
|
||||||
|
// Unless you use STL or exceptions, keep this commented.
|
||||||
|
// It allows you to compile without libstdc++.so as a dependency
|
||||||
|
// #define NO_ALLOC_OVERRIDES
|
||||||
|
|
||||||
// - AMXX Init functions
|
// - AMXX Init functions
|
||||||
// Also consider using FN_META_*
|
// Also consider using FN_META_*
|
||||||
// AMXX query
|
// AMXX query
|
||||||
|
@ -31,34 +31,28 @@
|
|||||||
|
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
|
|
||||||
void amx_command(){
|
void amx_command()
|
||||||
|
{
|
||||||
const char* cmd = CMD_ARGV(1);
|
const char* cmd = CMD_ARGV(1);
|
||||||
|
|
||||||
if (!strcmp(cmd, "plugins") || !strcmp(cmd, "list"))
|
if (!strcmp(cmd, "plugins") || !strcmp(cmd, "list"))
|
||||||
{
|
{
|
||||||
|
|
||||||
print_srvconsole("Currently loaded plugins:\n");
|
print_srvconsole("Currently loaded plugins:\n");
|
||||||
print_srvconsole( " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n",
|
print_srvconsole(" %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n", "name", "version", "author", "file", "status");
|
||||||
"name","version","author","file","status");
|
|
||||||
|
|
||||||
int plugins = 0;
|
int plugins = 0;
|
||||||
int running = 0;
|
int running = 0;
|
||||||
|
|
||||||
|
|
||||||
CPluginMngr::iterator a = g_plugins.begin();
|
CPluginMngr::iterator a = g_plugins.begin();
|
||||||
|
|
||||||
while (a)
|
while (a)
|
||||||
{
|
{
|
||||||
++plugins;
|
++plugins;
|
||||||
|
|
||||||
if ((*a).isValid() && !(*a).isPaused())
|
if ((*a).isValid() && !(*a).isPaused())
|
||||||
++running;
|
++running;
|
||||||
|
|
||||||
print_srvconsole( " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n",
|
print_srvconsole(" [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s\n", plugins, (*a).getTitle(), (*a).getVersion(), (*a).getAuthor(), (*a).getName(), (*a).getStatus());
|
||||||
plugins,(*a).getTitle(),(*a).getVersion(),
|
|
||||||
(*a).getAuthor(), (*a).getName(), (*a).getStatus() );
|
|
||||||
|
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +69,6 @@ void amx_command(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
print_srvconsole("%d plugins, %d running\n", plugins, running);
|
print_srvconsole("%d plugins, %d running\n", plugins, running);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(cmd, "pause") && CMD_ARGC() > 2)
|
else if (!strcmp(cmd, "pause") && CMD_ARGC() > 2)
|
||||||
{
|
{
|
||||||
@ -88,8 +81,8 @@ void amx_command(){
|
|||||||
plugin->pausePlugin();
|
plugin->pausePlugin();
|
||||||
print_srvconsole("Paused plugin \"%s\"\n", plugin->getName());
|
print_srvconsole("Paused plugin \"%s\"\n", plugin->getName());
|
||||||
}
|
}
|
||||||
else print_srvconsole("Couldn't find plugin matching \"%s\"\n",sPlugin);
|
else
|
||||||
|
print_srvconsole("Couldn't find plugin matching \"%s\"\n", sPlugin);
|
||||||
}
|
}
|
||||||
else if (!strcmp(cmd, "unpause") && CMD_ARGC() > 2)
|
else if (!strcmp(cmd, "unpause") && CMD_ARGC() > 2)
|
||||||
{
|
{
|
||||||
@ -97,39 +90,38 @@ void amx_command(){
|
|||||||
|
|
||||||
CPluginMngr::CPlugin *plugin = g_plugins.findPlugin(sPlugin);
|
CPluginMngr::CPlugin *plugin = g_plugins.findPlugin(sPlugin);
|
||||||
|
|
||||||
if ( plugin && plugin->isValid() )
|
if (plugin && plugin->isValid() && plugin->isPaused())
|
||||||
{
|
{
|
||||||
plugin->unpausePlugin();
|
plugin->unpausePlugin();
|
||||||
print_srvconsole("Unpaused plugin \"%s\"\n", plugin->getName());
|
print_srvconsole("Unpaused plugin \"%s\"\n", plugin->getName());
|
||||||
}
|
}
|
||||||
else print_srvconsole("Couldn't find plugin matching \"%s\"\n",sPlugin);
|
else if (!plugin)
|
||||||
|
{
|
||||||
|
print_srvconsole("Couldn't find plugin matching \"%s\"\n", sPlugin);
|
||||||
|
} else {
|
||||||
|
print_srvconsole("Plugin %s can't be unpaused right now.", sPlugin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(cmd, "cvars"))
|
else if (!strcmp(cmd, "cvars"))
|
||||||
{
|
{
|
||||||
print_srvconsole("Registered cvars:\n");
|
print_srvconsole("Registered cvars:\n");
|
||||||
print_srvconsole( " %-24.23s %-24.23s %-16.15s\n",
|
print_srvconsole(" %-24.23s %-24.23s %-16.15s\n", "name", "value", "plugin");
|
||||||
"name","value","plugin");
|
|
||||||
|
|
||||||
int ammount = 0;
|
int ammount = 0;
|
||||||
|
|
||||||
for (CList<CCVar>::iterator a = g_cvars.begin(); a; ++a)
|
for (CList<CCVar>::iterator a = g_cvars.begin(); a; ++a)
|
||||||
{
|
{
|
||||||
print_srvconsole( " [%3d] %-24.23s %-24.23s %-16.15s\n",++ammount,
|
print_srvconsole(" [%3d] %-24.23s %-24.23s %-16.15s\n", ++ammount, (*a).getName(), CVAR_GET_STRING((*a).getName()), (*a).getPluginName());
|
||||||
(*a).getName() ,CVAR_GET_STRING( (*a).getName() ),(*a).getPluginName() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_srvconsole("%d cvars\n", ammount);
|
print_srvconsole("%d cvars\n", ammount);
|
||||||
}
|
}
|
||||||
else if (!strcmp(cmd, "cmds"))
|
else if (!strcmp(cmd, "cmds"))
|
||||||
{
|
{
|
||||||
|
|
||||||
print_srvconsole("Registered commands:\n");
|
print_srvconsole("Registered commands:\n");
|
||||||
print_srvconsole( " %-24.23s %-16.15s %-8.7s %-16.15s\n",
|
print_srvconsole(" %-24.23s %-16.15s %-8.7s %-16.15s\n", "name", "access", "type", "plugin");
|
||||||
"name","access" ,"type" ,"plugin");
|
|
||||||
|
|
||||||
int ammount = 0;
|
int ammount = 0;
|
||||||
|
|
||||||
char access[32];
|
char access[32];
|
||||||
|
|
||||||
CmdMngr::iterator a = g_commands.begin(CMD_ConsoleCommand);
|
CmdMngr::iterator a = g_commands.begin(CMD_ConsoleCommand);
|
||||||
@ -137,8 +129,7 @@ void amx_command(){
|
|||||||
while (a)
|
while (a)
|
||||||
{
|
{
|
||||||
UTIL_GetFlags(access, (*a).getFlags());
|
UTIL_GetFlags(access, (*a).getFlags());
|
||||||
print_srvconsole( " [%3d] %-24.23s %-16.15s %-8.7s %-16.15s\n",
|
print_srvconsole(" [%3d] %-24.23s %-16.15s %-8.7s %-16.15s\n", ++ammount, (*a).getCmdLine(), access, (*a).getCmdType(), (*a).getPlugin()->getName());
|
||||||
++ammount,(*a).getCmdLine() , access , (*a).getCmdType() , (*a).getPlugin()->getName());
|
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +137,6 @@ void amx_command(){
|
|||||||
}
|
}
|
||||||
else if (!strcmp(cmd, "version"))
|
else if (!strcmp(cmd, "version"))
|
||||||
{
|
{
|
||||||
|
|
||||||
print_srvconsole("%s %s\n", Plugin_info.name, Plugin_info.version);
|
print_srvconsole("%s %s\n", Plugin_info.name, Plugin_info.version);
|
||||||
print_srvconsole("Authors: %s (%s)\n", "Felix \"SniperBeamer\" Geyer, David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Jonny \"Got His Gun\" Bergstrom, and Lukasz \"SidLuke\" Wlasinski.", Plugin_info.url);
|
print_srvconsole("Authors: %s (%s)\n", "Felix \"SniperBeamer\" Geyer, David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Jonny \"Got His Gun\" Bergstrom, and Lukasz \"SidLuke\" Wlasinski.", Plugin_info.url);
|
||||||
print_srvconsole("Compiled: %s\n", __DATE__ ", " __TIME__);
|
print_srvconsole("Compiled: %s\n", __DATE__ ", " __TIME__);
|
||||||
@ -163,8 +153,7 @@ void amx_command(){
|
|||||||
else if (!strcmp(cmd, "modules"))
|
else if (!strcmp(cmd, "modules"))
|
||||||
{
|
{
|
||||||
print_srvconsole("Currently loaded modules:\n");
|
print_srvconsole("Currently loaded modules:\n");
|
||||||
print_srvconsole( " %-23.22s %-8.7s %-20.19s %-11.10s\n",
|
print_srvconsole(" %-23.22s %-8.7s %-20.19s %-11.10s\n", "name", "version", "author", "status");
|
||||||
"name", "version", "author", "status");
|
|
||||||
|
|
||||||
int running = 0;
|
int running = 0;
|
||||||
int modules = 0;
|
int modules = 0;
|
||||||
@ -175,17 +164,15 @@ void amx_command(){
|
|||||||
{
|
{
|
||||||
if ((*a).getStatusValue() == MODULE_LOADED)
|
if ((*a).getStatusValue() == MODULE_LOADED)
|
||||||
++running;
|
++running;
|
||||||
|
|
||||||
++modules;
|
++modules;
|
||||||
|
|
||||||
print_srvconsole( " [%2d] %-23.22s %-8.7s %-20.19s %-11.10s\n", modules,
|
print_srvconsole(" [%2d] %-23.22s %-8.7s %-20.19s %-11.10s\n", modules, (*a).getName(), (*a).getVersion(), (*a).getAuthor(), (*a).getStatus());
|
||||||
(*a).getName(), (*a).getVersion(), (*a).getAuthor() , (*a).getStatus() );
|
|
||||||
|
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_srvconsole("%d modules, %d correct\n", modules, running);
|
print_srvconsole("%d modules, %d correct\n", modules, running);
|
||||||
} else if (!strcmp(cmd, "gpl"))
|
}
|
||||||
|
else if (!strcmp(cmd, "gpl"))
|
||||||
{
|
{
|
||||||
print_srvconsole("AMX Mod X\n");
|
print_srvconsole("AMX Mod X\n");
|
||||||
print_srvconsole("\n");
|
print_srvconsole("\n");
|
||||||
@ -242,11 +229,7 @@ void amx_command(){
|
|||||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3A\x78\x78\x24\x40\x4E\x4E\x4D\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x3E\x3E\x3F\x3E\x3E\x3E\x3E\x3B\x3B\x3B\x3A\x3A\x3F\x3E\x3A\x2E\x2E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2E\x45\x4D\x40\x45\x78\x5E\x33\x68\x33\x2B\n");
|
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3A\x78\x78\x24\x40\x4E\x4E\x4D\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5E\x3E\x3E\x3F\x3E\x3E\x3E\x3E\x3B\x3B\x3B\x3A\x3A\x3F\x3E\x3A\x2E\x2E\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2E\x45\x4D\x40\x45\x78\x5E\x33\x68\x33\x2B\n");
|
||||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x24\x48\x45\x48\x78\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x4E\x40\x2B\x66\x33\x78\x20\x20\n");
|
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x24\x48\x45\x48\x78\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x4E\x40\x2B\x66\x33\x78\x20\x20\n");
|
||||||
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x2C\x20\x3A\x20\x20\n");
|
print_srvconsole("\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2B\x2C\x20\x3A\x20\x20\n");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
print_srvconsole("Usage: amxx < command > [ argument ]\n");
|
print_srvconsole("Usage: amxx < command > [ argument ]\n");
|
||||||
print_srvconsole("Commands:\n");
|
print_srvconsole("Commands:\n");
|
||||||
print_srvconsole(" version - display amxx version info\n");
|
print_srvconsole(" version - display amxx version info\n");
|
||||||
@ -257,11 +240,9 @@ void amx_command(){
|
|||||||
print_srvconsole(" cmds - list commands registered by plugins\n");
|
print_srvconsole(" cmds - list commands registered by plugins\n");
|
||||||
print_srvconsole(" pause < plugin > - pause a running plugin\n");
|
print_srvconsole(" pause < plugin > - pause a running plugin\n");
|
||||||
print_srvconsole(" unpause < plugin > - unpause a previously paused plugin\n");
|
print_srvconsole(" unpause < plugin > - unpause a previously paused plugin\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void plugin_srvcmd()
|
void plugin_srvcmd()
|
||||||
{
|
{
|
||||||
cell ret = 0;
|
cell ret = 0;
|
||||||
@ -271,8 +252,7 @@ void plugin_srvcmd()
|
|||||||
|
|
||||||
while (a)
|
while (a)
|
||||||
{
|
{
|
||||||
if ( (*a).matchCommand( cmd ) &&
|
if ((*a).matchCommand(cmd) && (*a).getPlugin()->isExecutable((*a).getFunction()))
|
||||||
(*a).getPlugin()->isExecutable( (*a).getFunction() ) )
|
|
||||||
{
|
{
|
||||||
cell ret = executeForwards((*a).getFunction(), g_srvindex, (*a).getFlags(), (*a).getId());
|
cell ret = executeForwards((*a).getFunction(), g_srvindex, (*a).getFlags(), (*a).getId());
|
||||||
if (ret) break;
|
if (ret) break;
|
||||||
|
@ -38,13 +38,14 @@ const char* stristr(const char* str,const char* substr)
|
|||||||
register char *prevloc = (char *)str;
|
register char *prevloc = (char *)str;
|
||||||
register char *haystack = (char *)str;
|
register char *haystack = (char *)str;
|
||||||
|
|
||||||
while (*haystack) {
|
while (*haystack)
|
||||||
if (tolower(*haystack) == tolower(*needle)) {
|
{
|
||||||
|
if (tolower(*haystack) == tolower(*needle))
|
||||||
|
{
|
||||||
haystack++;
|
haystack++;
|
||||||
if (!*++needle)
|
if (!*++needle)
|
||||||
return prevloc;
|
return prevloc;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
haystack = ++prevloc;
|
haystack = ++prevloc;
|
||||||
needle = (char *)substr;
|
needle = (char *)substr;
|
||||||
}
|
}
|
||||||
@ -77,9 +78,12 @@ int set_amxstring(AMX *amx,cell amx_addr,const char *source,int max)
|
|||||||
{
|
{
|
||||||
cell* dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
|
cell* dest = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
|
||||||
cell* start = dest;
|
cell* start = dest;
|
||||||
|
|
||||||
while (max-- && *source)
|
while (max-- && *source)
|
||||||
*dest++ = (cell)*source++;
|
*dest++ = (cell)*source++;
|
||||||
|
|
||||||
*dest = 0;
|
*dest = 0;
|
||||||
|
|
||||||
return dest - start;
|
return dest - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +93,11 @@ char* get_amxstring(AMX *amx,cell amx_addr,int id, int& len)
|
|||||||
register cell* source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
|
register cell* source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
|
||||||
register char* dest = buffor[id];
|
register char* dest = buffor[id];
|
||||||
char* start = dest;
|
char* start = dest;
|
||||||
while ((*dest++=(char)(*source++)))
|
|
||||||
;
|
while ((*dest++=(char)(*source++)));
|
||||||
|
|
||||||
len = --dest - start;
|
len = --dest - start;
|
||||||
|
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,32 +107,41 @@ void copy_amxmemory(cell* dest,cell* src,int len)
|
|||||||
*dest++=*src++;
|
*dest++=*src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* parse_arg(char** line, int& state)
|
char* parse_arg(char** line, int& state)
|
||||||
{
|
{
|
||||||
static char arg[3072];
|
static char arg[3072];
|
||||||
char* dest = arg;
|
char* dest = arg;
|
||||||
state = 0;
|
state = 0;
|
||||||
while(**line) {
|
|
||||||
if ( isspace(**line) ) {
|
while (**line)
|
||||||
|
{
|
||||||
|
if (isspace(**line))
|
||||||
|
{
|
||||||
if (state == 1)
|
if (state == 1)
|
||||||
break;
|
break;
|
||||||
else if (!state) {
|
else if (!state)
|
||||||
|
{
|
||||||
(*line)++;
|
(*line)++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (state != 2)
|
else if (state != 2)
|
||||||
state = 1;
|
state = 1;
|
||||||
if (**line=='"') {
|
|
||||||
|
if (**line == '"')
|
||||||
|
{
|
||||||
(*line)++;
|
(*line)++;
|
||||||
|
|
||||||
if (state == 2)
|
if (state == 2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
state = 2;
|
state = 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
*dest++ = *(*line)++;
|
*dest++ = *(*line)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*dest = '\0';
|
*dest = '\0';
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
@ -134,30 +149,41 @@ char* parse_arg(char** line,int& state)
|
|||||||
static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
|
static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
|
||||||
{
|
{
|
||||||
static char buffor[3072];
|
static char buffor[3072];
|
||||||
|
|
||||||
cell *a = get_amxaddr(amx, params[1]);
|
cell *a = get_amxaddr(amx, params[1]);
|
||||||
cell *b = get_amxaddr(amx, params[3]);
|
cell *b = get_amxaddr(amx, params[3]);
|
||||||
cell *c = get_amxaddr(amx, params[4]);
|
cell *c = get_amxaddr(amx, params[4]);
|
||||||
|
|
||||||
int iMain = amxstring_len(a);
|
int iMain = amxstring_len(a);
|
||||||
int iWhat = amxstring_len(b);
|
int iWhat = amxstring_len(b);
|
||||||
int iWith = amxstring_len(c);
|
int iWith = amxstring_len(c);
|
||||||
int iPot = iMain + iWith - iWhat;
|
int iPot = iMain + iWith - iWhat;
|
||||||
if (iPot>=params[2]){
|
|
||||||
|
if (iPot >= params[2])
|
||||||
|
{
|
||||||
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *d = buffor;
|
char *d = buffor;
|
||||||
cell *x, *y, *z = a, *l = a;
|
cell *x, *y, *z = a, *l = a;
|
||||||
int p = 0;
|
int p = 0;
|
||||||
while(*a){
|
|
||||||
if (*a==*b){
|
while (*a)
|
||||||
|
{
|
||||||
|
if (*a == *b)
|
||||||
|
{
|
||||||
x = a + 1;
|
x = a + 1;
|
||||||
y = b + 1;
|
y = b + 1;
|
||||||
p = 1;
|
p = 1;
|
||||||
if (!*y) break;
|
if (!*y) break;
|
||||||
while(*x==*y){
|
|
||||||
|
while (*x == *y)
|
||||||
|
{
|
||||||
x++; y++; p++;
|
x++; y++; p++;
|
||||||
if (!*y) break;
|
if (!*y) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*y) break;
|
if (!*y) break;
|
||||||
p = 0;
|
p = 0;
|
||||||
*d++ = (char)*a++;
|
*d++ = (char)*a++;
|
||||||
@ -165,7 +191,9 @@ static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
|
|||||||
}
|
}
|
||||||
*d++ = (char)*a++;
|
*d++ = (char)*a++;
|
||||||
}
|
}
|
||||||
if (p){
|
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
while (*c) *d++ = (char)*c++;
|
while (*c) *d++ = (char)*c++;
|
||||||
a += p;
|
a += p;
|
||||||
while (*a) *d++ = (char)*a++;
|
while (*a) *d++ = (char)*a++;
|
||||||
@ -175,6 +203,7 @@ static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */
|
|||||||
*z = 0;
|
*z = 0;
|
||||||
return (z - l);
|
return (z - l);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,17 +214,20 @@ static cell AMX_NATIVE_CALL contain(AMX *amx, cell *params) /* 2 param */
|
|||||||
register cell *c = b;
|
register cell *c = b;
|
||||||
cell* str = b;
|
cell* str = b;
|
||||||
cell* substr = a;
|
cell* substr = a;
|
||||||
while (*c) {
|
|
||||||
if (*c == *a) {
|
while (*c)
|
||||||
|
{
|
||||||
|
if (*c == *a)
|
||||||
|
{
|
||||||
c++;
|
c++;
|
||||||
if (!*++a)
|
if (!*++a)
|
||||||
return b - str;
|
return b - str;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
c = ++b;
|
c = ++b;
|
||||||
a = substr;
|
a = substr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,17 +238,20 @@ static cell AMX_NATIVE_CALL containi(AMX *amx, cell *params) /* 2 param */
|
|||||||
register cell *c = b;
|
register cell *c = b;
|
||||||
cell* str = b;
|
cell* str = b;
|
||||||
cell* substr = a;
|
cell* substr = a;
|
||||||
while (*c) {
|
|
||||||
if (tolower(*c) == tolower(*a)) {
|
while (*c)
|
||||||
|
{
|
||||||
|
if (tolower(*c) == tolower(*a))
|
||||||
|
{
|
||||||
c++;
|
c++;
|
||||||
if (!*++a)
|
if (!*++a)
|
||||||
return b - str;
|
return b - str;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
c = ++b;
|
c = ++b;
|
||||||
a = substr;
|
a = substr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,6 +265,72 @@ static cell AMX_NATIVE_CALL numtostr(AMX *amx, cell *params) /* 3 param */
|
|||||||
{
|
{
|
||||||
char szTemp[32];
|
char szTemp[32];
|
||||||
sprintf(szTemp, "%d", (int)params[1]);
|
sprintf(szTemp, "%d", (int)params[1]);
|
||||||
|
|
||||||
|
return set_amxstring(amx, params[2], szTemp, params[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL str_to_float(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
cell *str = get_amxaddr(amx, params[1]);
|
||||||
|
|
||||||
|
bool neg = false;
|
||||||
|
unsigned long part1 = 0;
|
||||||
|
|
||||||
|
if (*str == '-')
|
||||||
|
{
|
||||||
|
neg = true;
|
||||||
|
++str;
|
||||||
|
}
|
||||||
|
else if (*str == '+')
|
||||||
|
++str;
|
||||||
|
|
||||||
|
while (*str)
|
||||||
|
{
|
||||||
|
if (*str == '.')
|
||||||
|
{
|
||||||
|
++str;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*str < '0' || *str > '9')
|
||||||
|
{
|
||||||
|
REAL fl = neg ? -static_cast<REAL>(part1) : static_cast<REAL>(part1);
|
||||||
|
return amx_ftoc(fl);
|
||||||
|
}
|
||||||
|
|
||||||
|
part1 *= 10;
|
||||||
|
part1 += *str - '0';
|
||||||
|
|
||||||
|
++str;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long part2 = 0;
|
||||||
|
unsigned long div = 1;
|
||||||
|
|
||||||
|
while (*str)
|
||||||
|
{
|
||||||
|
if (*str < '0' || *str > '9')
|
||||||
|
break;
|
||||||
|
|
||||||
|
part2 *= 10;
|
||||||
|
part2 += *str - '0';
|
||||||
|
div *= 10;
|
||||||
|
++str;
|
||||||
|
}
|
||||||
|
|
||||||
|
REAL fl = static_cast<REAL>(part1) + (static_cast<REAL>(part2) / div);
|
||||||
|
|
||||||
|
if (neg)
|
||||||
|
fl = -fl;
|
||||||
|
|
||||||
|
return amx_ftoc(fl);
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL float_to_str(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
char szTemp[32];
|
||||||
|
sprintf(szTemp, "%f", amx_ctof(params[1]));
|
||||||
|
|
||||||
return set_amxstring(amx, params[2], szTemp, params[3]);
|
return set_amxstring(amx, params[2], szTemp, params[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,17 +340,23 @@ static cell AMX_NATIVE_CALL add(AMX *amx, cell *params) /* 4 param */
|
|||||||
cell *dest = get_amxaddr(amx, params[1]);
|
cell *dest = get_amxaddr(amx, params[1]);
|
||||||
cell *start = dest;
|
cell *start = dest;
|
||||||
int c = params[2], d = params[4];
|
int c = params[2], d = params[4];
|
||||||
|
|
||||||
while (*dest && c--)
|
while (*dest && c--)
|
||||||
++dest;
|
++dest;
|
||||||
if (d){
|
|
||||||
|
if (d)
|
||||||
|
{
|
||||||
while (c-- && d-- && *src)
|
while (c-- && d-- && *src)
|
||||||
*dest++ =* src++;
|
*dest++ =* src++;
|
||||||
*dest = 0;
|
*dest = 0;
|
||||||
|
|
||||||
return (dest - start);
|
return (dest - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (c-- && *src)
|
while (c-- && *src)
|
||||||
*dest++ =* src++;
|
*dest++ =* src++;
|
||||||
*dest = 0;
|
*dest = 0;
|
||||||
|
|
||||||
return (dest-start);
|
return (dest-start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,9 +366,11 @@ static cell AMX_NATIVE_CALL copy(AMX *amx, cell *params) /* 4 param */
|
|||||||
cell *dest = get_amxaddr(amx, params[1]);
|
cell *dest = get_amxaddr(amx, params[1]);
|
||||||
cell *start = dest;
|
cell *start = dest;
|
||||||
int c = params[2];
|
int c = params[2];
|
||||||
|
|
||||||
while (c-- && *src)
|
while (c-- && *src)
|
||||||
*dest++ =* src++;
|
*dest++ =* src++;
|
||||||
*dest = 0;
|
*dest = 0;
|
||||||
|
|
||||||
return (dest - start);
|
return (dest - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,9 +381,11 @@ static cell AMX_NATIVE_CALL copyc(AMX *amx, cell *params) /* 4 param */
|
|||||||
cell *start = dest;
|
cell *start = dest;
|
||||||
int c = params[2];
|
int c = params[2];
|
||||||
cell ch = params[4];
|
cell ch = params[4];
|
||||||
|
|
||||||
while (c-- && *src && *src != ch)
|
while (c-- && *src && *src != ch)
|
||||||
*dest++ =* src++;
|
*dest++ =* src++;
|
||||||
*dest = 0;
|
*dest = 0;
|
||||||
|
|
||||||
return (dest - start);
|
return (dest - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,8 +394,10 @@ static cell AMX_NATIVE_CALL setc(AMX *amx, cell *params) /* 4 param */
|
|||||||
cell *src = get_amxaddr(amx, params[1]);
|
cell *src = get_amxaddr(amx, params[1]);
|
||||||
int c = params[2];
|
int c = params[2];
|
||||||
cell ch = params[3];
|
cell ch = params[3];
|
||||||
|
|
||||||
while (c--)
|
while (c--)
|
||||||
*src++ = ch;
|
*src++ = ch;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,14 +406,19 @@ static cell AMX_NATIVE_CALL equal(AMX *amx, cell *params) /* 3 param */
|
|||||||
cell *a = get_amxaddr(amx, params[1]);
|
cell *a = get_amxaddr(amx, params[1]);
|
||||||
cell *b = get_amxaddr(amx, params[2]);
|
cell *b = get_amxaddr(amx, params[2]);
|
||||||
int c = params[3];
|
int c = params[3];
|
||||||
if (c) {
|
|
||||||
|
if (c)
|
||||||
|
{
|
||||||
while (--c && *a && (*a == *b))
|
while (--c && *a && (*a == *b))
|
||||||
++a, ++b;
|
++a, ++b;
|
||||||
return (*a-*b) ? 0 : 1;
|
return (*a-*b) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
while (!(ret = *a - *b) && *b)
|
while (!(ret = *a - *b) && *b)
|
||||||
++a, ++b;
|
++a, ++b;
|
||||||
|
|
||||||
return ret ? 0 : 1;
|
return ret ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,18 +427,24 @@ static cell AMX_NATIVE_CALL equali(AMX *amx, cell *params) /* 3 param */
|
|||||||
cell *a = get_amxaddr(amx, params[1]);
|
cell *a = get_amxaddr(amx, params[1]);
|
||||||
cell *b = get_amxaddr(amx, params[2]);
|
cell *b = get_amxaddr(amx, params[2]);
|
||||||
int f, l, c = params[3];
|
int f, l, c = params[3];
|
||||||
if (c) {
|
|
||||||
do {
|
if (c)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
f = tolower(*a++);
|
f = tolower(*a++);
|
||||||
l = tolower(*b++);
|
l = tolower(*b++);
|
||||||
}
|
} while (--c && l && f && f == l);
|
||||||
while (--c &&l&&f&& f==l);
|
|
||||||
return (f - l) ? 0 : 1;
|
return (f - l) ? 0 : 1;
|
||||||
}
|
}
|
||||||
do {
|
|
||||||
|
do
|
||||||
|
{
|
||||||
f = tolower(*a++);
|
f = tolower(*a++);
|
||||||
l = tolower(*b++);
|
l = tolower(*b++);
|
||||||
} while (f && f == l);
|
} while (f && f == l);
|
||||||
|
|
||||||
return (f - l) ? 0 : 1;
|
return (f - l) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,13 +460,19 @@ static cell AMX_NATIVE_CALL parse(AMX *amx, cell *params) /* 3 param */
|
|||||||
char* arg, *parse = get_amxstring(amx, params[1], 0, c);
|
char* arg, *parse = get_amxstring(amx, params[1], 0, c);
|
||||||
cell *cptr;
|
cell *cptr;
|
||||||
int state;
|
int state;
|
||||||
while(*parse){
|
|
||||||
|
while (*parse)
|
||||||
|
{
|
||||||
arg = parse_arg(&parse,state);
|
arg = parse_arg(&parse,state);
|
||||||
if (state){
|
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
if (inum <= iarg)
|
if (inum <= iarg)
|
||||||
return ((iarg - 2)>>1);
|
return ((iarg - 2)>>1);
|
||||||
|
|
||||||
cptr = get_amxaddr(amx, params[iarg++]);
|
cptr = get_amxaddr(amx, params[iarg++]);
|
||||||
c = *get_amxaddr(amx, params[iarg++]);
|
c = *get_amxaddr(amx, params[iarg++]);
|
||||||
|
|
||||||
while (c-- && *arg)
|
while (c-- && *arg)
|
||||||
*cptr++ = (cell)*arg++;
|
*cptr++ = (cell)*arg++;
|
||||||
*cptr = 0;
|
*cptr = 0;
|
||||||
@ -356,10 +486,13 @@ static cell AMX_NATIVE_CALL strtolower(AMX *amx, cell *params) /* 1 param */
|
|||||||
{
|
{
|
||||||
cell *cptr = get_amxaddr(amx, params[1]);
|
cell *cptr = get_amxaddr(amx, params[1]);
|
||||||
cell *begin = cptr;
|
cell *begin = cptr;
|
||||||
while(*cptr){
|
|
||||||
|
while (*cptr)
|
||||||
|
{
|
||||||
*cptr = tolower(*cptr);
|
*cptr = tolower(*cptr);
|
||||||
cptr++;
|
cptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cptr - begin;
|
return cptr - begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,10 +500,13 @@ static cell AMX_NATIVE_CALL strtoupper(AMX *amx, cell *params) /* 1 param */
|
|||||||
{
|
{
|
||||||
cell *cptr = get_amxaddr(amx, params[1]);
|
cell *cptr = get_amxaddr(amx, params[1]);
|
||||||
cell *begin = cptr;
|
cell *begin = cptr;
|
||||||
while(*cptr){
|
|
||||||
|
while (*cptr)
|
||||||
|
{
|
||||||
*cptr = toupper(*cptr);
|
*cptr = toupper(*cptr);
|
||||||
cptr++;
|
cptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cptr - begin;
|
return cptr - begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,6 +514,7 @@ int fo_numargs(AMX *amx)
|
|||||||
{
|
{
|
||||||
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
||||||
cell bytes= *(cell *)(data + (int)amx->frm + 2 * sizeof(cell));
|
cell bytes= *(cell *)(data + (int)amx->frm + 2 * sizeof(cell));
|
||||||
|
|
||||||
return (int)(bytes / sizeof(cell));
|
return (int)(bytes / sizeof(cell));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,6 +522,7 @@ int fo_getargnum(AMX *amx, int pos)
|
|||||||
{
|
{
|
||||||
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
||||||
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
||||||
|
|
||||||
return *(cell *)(data + (int)value);
|
return *(cell *)(data + (int)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,6 +531,7 @@ float fo_getargfloat(AMX *amx, int pos)
|
|||||||
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
unsigned char *data = amx->base + (int)((AMX_HEADER *)amx->base)->dat;
|
||||||
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
cell value = *(cell *)(data + (int)amx->frm + (pos + 3) * sizeof(cell));
|
||||||
cell number = *(cell *)(data + (int)value);
|
cell number = *(cell *)(data + (int)value);
|
||||||
|
|
||||||
return *(REAL *)((void *)&number);
|
return *(REAL *)((void *)&number);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,10 +543,12 @@ char* fo_getargstr(AMX *amx, int swap, int pos)
|
|||||||
static char buffer[2][3072];
|
static char buffer[2][3072];
|
||||||
char* b = buffer[swap];
|
char* b = buffer[swap];
|
||||||
int a = 0;
|
int a = 0;
|
||||||
do {
|
|
||||||
|
do
|
||||||
|
{
|
||||||
value = src_value + a++ * sizeof(cell);
|
value = src_value + a++ * sizeof(cell);
|
||||||
value = *(cell *)(data + (int)value);
|
value = *(cell *)(data + (int)value);
|
||||||
*b++ = value;
|
*b++ = static_cast<char>(value);
|
||||||
} while (value);
|
} while (value);
|
||||||
|
|
||||||
return buffer[swap];
|
return buffer[swap];
|
||||||
@ -420,31 +561,42 @@ char* format_arguments(AMX *amx, int parm,int& len)
|
|||||||
char *ptr, *arg, *dest = *buffer;
|
char *ptr, *arg, *dest = *buffer;
|
||||||
char *src = fo_getargstr(amx, 0, parm++);
|
char *src = fo_getargstr(amx, 0, parm++);
|
||||||
int numparam = fo_numargs(amx);
|
int numparam = fo_numargs(amx);
|
||||||
while(*src) {
|
|
||||||
if (*src=='%'&&*(src+1)) {
|
while (*src)
|
||||||
|
{
|
||||||
|
if (*src == '%' && *(src + 1))
|
||||||
|
{
|
||||||
ptr = format;
|
ptr = format;
|
||||||
*ptr++ = *src++;
|
*ptr++ = *src++;
|
||||||
if (*src=='%'){
|
|
||||||
|
if (*src == '%')
|
||||||
|
{
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
while (!isalpha(*ptr++=*src++))
|
|
||||||
;
|
while (!isalpha(*ptr++ = *src++));
|
||||||
|
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
if (numparam < parm) continue;
|
if (numparam < parm) continue;
|
||||||
arg = buffer[1];
|
arg = buffer[1];
|
||||||
switch(*(ptr-1)){
|
|
||||||
|
switch (*(ptr - 1))
|
||||||
|
{
|
||||||
case 's': sprintf(arg, format, fo_getargstr(amx, 1, parm++)); break;
|
case 's': sprintf(arg, format, fo_getargstr(amx, 1, parm++)); break;
|
||||||
case 'f': case 'g': sprintf(arg, format, fo_getargfloat(amx, parm++)); break;
|
case 'f': case 'g': sprintf(arg, format, fo_getargfloat(amx, parm++)); break;
|
||||||
default: sprintf(arg, format, fo_getargnum(amx, parm++));
|
default: sprintf(arg, format, fo_getargnum(amx, parm++));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*arg) *dest++ = *arg++;
|
while (*arg) *dest++ = *arg++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*dest = '\0';
|
*dest = '\0';
|
||||||
len = dest - *buffer;
|
len = dest - *buffer;
|
||||||
|
|
||||||
return *buffer;
|
return *buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,9 +620,10 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
|
|||||||
int leftMax = params[3];
|
int leftMax = params[3];
|
||||||
int rightMax = params[5];
|
int rightMax = params[5];
|
||||||
//token
|
//token
|
||||||
char token = params[6];
|
char token = static_cast<char>(params[6]);
|
||||||
//trim
|
//trim
|
||||||
int trim = params[7];
|
int trim = params[7];
|
||||||
|
|
||||||
for (i = 0; i < (unsigned int)len; i++)
|
for (i = 0; i < (unsigned int)len; i++)
|
||||||
{
|
{
|
||||||
if (trim && !done_flag)
|
if (trim && !done_flag)
|
||||||
@ -481,11 +634,13 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
|
|||||||
done_flag = true;
|
done_flag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!done_flag && string[i] == token)
|
if (!done_flag && string[i] == token)
|
||||||
{
|
{
|
||||||
done_flag = true;
|
done_flag = true;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (done_flag)
|
if (done_flag)
|
||||||
{
|
{
|
||||||
right[right_pos++] = string[i];
|
right[right_pos++] = string[i];
|
||||||
@ -493,12 +648,14 @@ static cell AMX_NATIVE_CALL amx_strtok(AMX *amx, cell *params)
|
|||||||
left[left_pos++] = string[i];
|
left[left_pos++] = string[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
right[right_pos] = 0;
|
right[right_pos] = 0;
|
||||||
left[left_pos] = 0;
|
left[left_pos] = 0;
|
||||||
set_amxstring(amx, params[2], left, leftMax);
|
set_amxstring(amx, params[2], left, leftMax);
|
||||||
set_amxstring(amx, params[4], right, rightMax);
|
set_amxstring(amx, params[4], right, rightMax);
|
||||||
delete [] left;
|
delete [] left;
|
||||||
delete [] right;
|
delete [] right;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,36 +678,53 @@ static cell AMX_NATIVE_CALL strbreak(AMX *amx, cell *params) /* 5 param */
|
|||||||
int LeftMax = params[3];
|
int LeftMax = params[3];
|
||||||
int RightMax = params[5];
|
int RightMax = params[5];
|
||||||
|
|
||||||
for (i=0; i<(unsigned int)l; i++) {
|
for (i = 0; i < (unsigned int)l; i++)
|
||||||
if (string[i] == '"' && !quote_flag) {
|
{
|
||||||
|
if (string[i] == '"' && !quote_flag)
|
||||||
|
{
|
||||||
quote_flag = true;
|
quote_flag = true;
|
||||||
} else if (string[i] == '"' && quote_flag) {
|
}
|
||||||
|
else if (string[i] == '"' && quote_flag)
|
||||||
|
{
|
||||||
quote_flag = false;
|
quote_flag = false;
|
||||||
}
|
}
|
||||||
if (isspace(string[i]) && !quote_flag && !done_flag) {
|
|
||||||
|
if (isspace(string[i]) && !quote_flag && !done_flag)
|
||||||
|
{
|
||||||
done_flag = true;
|
done_flag = true;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (!done_flag && string[i]!='"') {
|
|
||||||
if (left_pos < LeftMax) {
|
if (!done_flag && string[i]!='"')
|
||||||
|
{
|
||||||
|
if (left_pos < LeftMax)
|
||||||
|
{
|
||||||
left[left_pos] = string[i];
|
left[left_pos] = string[i];
|
||||||
if (left[left_pos] == '\'') {
|
|
||||||
|
if (left[left_pos] == '\'')
|
||||||
|
{
|
||||||
left[left_pos] = hold;
|
left[left_pos] = hold;
|
||||||
}
|
}
|
||||||
|
|
||||||
left_pos++;
|
left_pos++;
|
||||||
} else {
|
} else {
|
||||||
done_flag = true;
|
done_flag = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (right_pos < RightMax && string[i]!='"') {
|
if (right_pos < RightMax && string[i]!='"')
|
||||||
|
{
|
||||||
right[right_pos] = string[i];
|
right[right_pos] = string[i];
|
||||||
if (right[right_pos] == '\'') {
|
|
||||||
|
if (right[right_pos] == '\'')
|
||||||
|
{
|
||||||
right[right_pos] = hold;
|
right[right_pos] = hold;
|
||||||
}
|
}
|
||||||
|
|
||||||
right_pos++;
|
right_pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
left[left_pos] = '\0';
|
left[left_pos] = '\0';
|
||||||
right[right_pos] = '\0';
|
right[right_pos] = '\0';
|
||||||
set_amxstring(amx, params[2], left, params[3]);
|
set_amxstring(amx, params[2], left, params[3]);
|
||||||
@ -565,11 +739,15 @@ static cell AMX_NATIVE_CALL format_args(AMX *amx, cell *params)
|
|||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int pos = params[3];
|
int pos = params[3];
|
||||||
if (pos < 0){
|
|
||||||
|
if (pos < 0)
|
||||||
|
{
|
||||||
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
amx_RaiseError(amx, AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* string = format_arguments(amx, pos, len); // indexed from 0
|
char* string = format_arguments(amx, pos, len); // indexed from 0
|
||||||
|
|
||||||
return set_amxstring(amx, params[1], string, params[2]);
|
return set_amxstring(amx, params[1], string, params[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,9 +775,11 @@ static cell AMX_NATIVE_CALL amx_ucfirst(AMX *amx, cell *params)
|
|||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
cell *str = get_amxaddr(amx, params[1]);
|
cell *str = get_amxaddr(amx, params[1]);
|
||||||
|
|
||||||
if (!isalpha((char)str[0]) || !(str[0] & (1<<5)))
|
if (!isalpha((char)str[0]) || !(str[0] & (1<<5)))
|
||||||
return 0;
|
return 0;
|
||||||
str[0] &= ~(1<<5);
|
str[0] &= ~(1<<5);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,40 +793,19 @@ static cell AMX_NATIVE_CALL amx_strlen(AMX *amx, cell *params)
|
|||||||
|
|
||||||
static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL amx_trim(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
cell *asdf = get_amxaddr(amx, params[1]);
|
int len;
|
||||||
cell *cptr = asdf;
|
char *str = get_amxstring(amx, params[1], 0, len);
|
||||||
int len = 0;
|
|
||||||
while (*cptr++) len++;
|
|
||||||
int flag = 0, incr = 0;
|
|
||||||
register int i = 0;
|
|
||||||
for (i=len-1; i>=0; i--)
|
|
||||||
{
|
|
||||||
if (!isspace(asdf[i]))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
asdf[i] = 0;
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0; i<len; i++)
|
String toTrim;
|
||||||
{
|
|
||||||
if (isspace(asdf[i]) && !flag)
|
|
||||||
{
|
|
||||||
incr++;
|
|
||||||
if (incr+i<len)
|
|
||||||
asdf[i] = asdf[incr+i];
|
|
||||||
} else {
|
|
||||||
if (!flag)
|
|
||||||
flag = 1;
|
|
||||||
if (incr)
|
|
||||||
asdf[i] = asdf[incr+i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
asdf[len] = 0;
|
|
||||||
|
|
||||||
return incr;
|
toTrim.assign(str);
|
||||||
|
toTrim.trim();
|
||||||
|
|
||||||
|
len -= toTrim.size();
|
||||||
|
|
||||||
|
set_amxstring(amx, params[1], toTrim.c_str(), toTrim.size());
|
||||||
|
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL n_strcat(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL n_strcat(AMX *amx, cell *params)
|
||||||
@ -656,13 +815,16 @@ static cell AMX_NATIVE_CALL n_strcat(AMX *amx,cell *params)
|
|||||||
cdest = get_amxaddr(amx, params[1]);
|
cdest = get_amxaddr(amx, params[1]);
|
||||||
csrc = get_amxaddr(amx, params[2]);
|
csrc = get_amxaddr(amx, params[2]);
|
||||||
int num = params[3];
|
int num = params[3];
|
||||||
|
|
||||||
while (*cdest && num)
|
while (*cdest && num)
|
||||||
{
|
{
|
||||||
cdest++;
|
cdest++;
|
||||||
num--;
|
num--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!num)
|
if (!num)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while (*csrc && num)
|
while (*csrc && num)
|
||||||
{
|
{
|
||||||
*cdest++ = *csrc++;
|
*cdest++ = *csrc++;
|
||||||
@ -694,6 +856,7 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
|
|||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
bool igcase = params[3] ? true : false;
|
bool igcase = params[3] ? true : false;
|
||||||
|
|
||||||
if (igcase)
|
if (igcase)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
@ -707,8 +870,10 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
|
|||||||
str[i] &= ~(1<<5);
|
str[i] &= ~(1<<5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params[4] > len)
|
if (params[4] > len)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char *pos = &(str[params[4]]);
|
char *pos = &(str[params[4]]);
|
||||||
char *find = strstr(str, sub);
|
char *find = strstr(str, sub);
|
||||||
|
|
||||||
@ -718,7 +883,8 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
|
|||||||
return (find - str);
|
return (find - str);
|
||||||
}
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO string_Natives[] = {
|
AMX_NATIVE_INFO string_Natives[] =
|
||||||
|
{
|
||||||
{"add", add},
|
{"add", add},
|
||||||
{"contain", contain},
|
{"contain", contain},
|
||||||
{"containi", containi},
|
{"containi", containi},
|
||||||
@ -749,6 +915,7 @@ AMX_NATIVE_INFO string_Natives[] = {
|
|||||||
{"strcat", n_strcat},
|
{"strcat", n_strcat},
|
||||||
{"strfind", n_strfind},
|
{"strfind", n_strfind},
|
||||||
{"strcmp", n_strcmp},
|
{"strcmp", n_strcmp},
|
||||||
|
{"str_to_float", str_to_float},
|
||||||
|
{"float_to_str", float_to_str},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -52,16 +51,21 @@ char *UTIL_VarArgs(const char *fmt, ...)
|
|||||||
int UTIL_ReadFlags(const char* c)
|
int UTIL_ReadFlags(const char* c)
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
while (*c) flags |= ( 1 << ( *c++ - 'a' ) );
|
|
||||||
|
while (*c)
|
||||||
|
flags |= (1<<(*c++ - 'a'));
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UTIL_GetFlags(char* f, int a)
|
void UTIL_GetFlags(char* f, int a)
|
||||||
{
|
{
|
||||||
for(int i='a';i<='z';++i){
|
for (int i = 'a'; i <= 'z'; ++i)
|
||||||
|
{
|
||||||
if (a & 1) *f++ = i;
|
if (a & 1) *f++ = i;
|
||||||
a >>= 1;
|
a >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*f = 0;
|
*f = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,12 +79,14 @@ void UTIL_ShowMenu( edict_t* pEdict, int slots, int time, char *menu, int mlen )
|
|||||||
if (!gmsgShowMenu)
|
if (!gmsgShowMenu)
|
||||||
return; // some games don't support ShowMenu (Firearms)
|
return; // some games don't support ShowMenu (Firearms)
|
||||||
|
|
||||||
while ( *n ) {
|
while (*n)
|
||||||
|
{
|
||||||
a = mlen;
|
a = mlen;
|
||||||
if (a > 175) a = 175;
|
if (a > 175) a = 175;
|
||||||
mlen -= a;
|
mlen -= a;
|
||||||
c = *(n+=a);
|
c = *(n+=a);
|
||||||
*n = 0;
|
*n = 0;
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pEdict);
|
MESSAGE_BEGIN(MSG_ONE, gmsgShowMenu, NULL, pEdict);
|
||||||
WRITE_SHORT(slots);
|
WRITE_SHORT(slots);
|
||||||
WRITE_CHAR(time);
|
WRITE_CHAR(time);
|
||||||
@ -109,12 +115,14 @@ void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
|
|||||||
char c = 0;
|
char c = 0;
|
||||||
int a;
|
int a;
|
||||||
|
|
||||||
while ( *n ) {
|
while (*n)
|
||||||
|
{
|
||||||
a = mlen;
|
a = mlen;
|
||||||
if (a > 175) a = 175;
|
if (a > 175) a = 175;
|
||||||
mlen -= a;
|
mlen -= a;
|
||||||
c = *(n += a);
|
c = *(n += a);
|
||||||
*n = 0;
|
*n = 0;
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgMOTD, NULL, client);
|
MESSAGE_BEGIN(MSG_ONE, gmsgMOTD, NULL, client);
|
||||||
WRITE_BYTE(c ? FALSE : TRUE);
|
WRITE_BYTE(c ? FALSE : TRUE);
|
||||||
WRITE_STRING(motd);
|
WRITE_STRING(motd);
|
||||||
@ -133,32 +141,42 @@ void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name)
|
|||||||
|
|
||||||
void UTIL_IntToString(int value, char *output)
|
void UTIL_IntToString(int value, char *output)
|
||||||
{
|
{
|
||||||
static const char *words[] = {"zero ","one ","two ","three ","four ",
|
static const char *words[] =
|
||||||
|
{"zero ","one ","two ","three ","four ",
|
||||||
"five ", "six ","seven ","eight ","nine ","ten ",
|
"five ", "six ","seven ","eight ","nine ","ten ",
|
||||||
"eleven ","twelve ","thirteen ","fourteen ","fifteen ",
|
"eleven ","twelve ","thirteen ","fourteen ","fifteen ",
|
||||||
"sixteen ","seventeen ","eighteen ","nineteen ",
|
"sixteen ","seventeen ","eighteen ","nineteen ",
|
||||||
"twenty ","thirty ","fourty ", "fifty ","sixty ",
|
"twenty ","thirty ","fourty ", "fifty ","sixty ",
|
||||||
"seventy ","eighty ","ninety ",
|
"seventy ","eighty ","ninety ",
|
||||||
"hundred ","thousand "};
|
"hundred ","thousand "};
|
||||||
|
|
||||||
*output = 0;
|
*output = 0;
|
||||||
if (value < 0) value = -value;
|
if (value < 0) value = -value;
|
||||||
int tho = value / 1000;
|
int tho = value / 1000;
|
||||||
int aaa = 0;
|
int aaa = 0;
|
||||||
if (tho){
|
|
||||||
|
if (tho)
|
||||||
|
{
|
||||||
aaa += sprintf(&output[aaa], words[tho]);
|
aaa += sprintf(&output[aaa], words[tho]);
|
||||||
aaa += sprintf(&output[aaa], words[29]);
|
aaa += sprintf(&output[aaa], words[29]);
|
||||||
value = value % 1000;
|
value = value % 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hun = value / 100;
|
int hun = value / 100;
|
||||||
if (hun) {
|
|
||||||
|
if (hun)
|
||||||
|
{
|
||||||
aaa += sprintf(&output[aaa], words[hun]);
|
aaa += sprintf(&output[aaa], words[hun]);
|
||||||
aaa += sprintf(&output[aaa], words[28]);
|
aaa += sprintf(&output[aaa], words[28]);
|
||||||
value = value % 100;
|
value = value % 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ten = value / 10;
|
int ten = value / 10;
|
||||||
int unit = value % 10;
|
int unit = value % 10;
|
||||||
|
|
||||||
if (ten)
|
if (ten)
|
||||||
aaa += sprintf(&output[aaa], words[(ten > 1) ? (ten + 18) : (unit + 10)]);
|
aaa += sprintf(&output[aaa], words[(ten > 1) ? (ten + 18) : (unit + 10)]);
|
||||||
|
|
||||||
if (ten != 1 && (unit || (!value && !hun && !tho)))
|
if (ten != 1 && (unit || (!value && !hun && !tho)))
|
||||||
sprintf(&output[aaa], words[unit]);
|
sprintf(&output[aaa], words[unit]);
|
||||||
}
|
}
|
||||||
@ -168,27 +186,34 @@ char* UTIL_SplitHudMessage(const char *src)
|
|||||||
static char message[512];
|
static char message[512];
|
||||||
short b = 0, d = 0, e = 0, c = -1;
|
short b = 0, d = 0, e = 0, c = -1;
|
||||||
|
|
||||||
while ( src[ d ] && e < 480 ) {
|
while (src[d] && e < 480)
|
||||||
if ( src[ d ] == ' ' ) {
|
{
|
||||||
|
if (src[d] == ' ')
|
||||||
|
{
|
||||||
c = e;
|
c = e;
|
||||||
}
|
}
|
||||||
else if ( src[ d ] == '\n' ) {
|
else if (src[d] == '\n')
|
||||||
|
{
|
||||||
c = -1;
|
c = -1;
|
||||||
b = 0;
|
b = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
message[e++] = src[d++];
|
message[e++] = src[d++];
|
||||||
if ( ++b == 69 ) {
|
|
||||||
if ( c == -1 ) {
|
if (++b == 69)
|
||||||
|
{
|
||||||
|
if (c == -1)
|
||||||
|
{
|
||||||
message[e++] = '\n';
|
message[e++] = '\n';
|
||||||
b = 0;
|
b = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
message[c] = '\n';
|
message[c] = '\n';
|
||||||
b = e - c - 1;
|
b = e - c - 1;
|
||||||
c = -1;
|
c = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message[e] = 0;
|
message[e] = 0;
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@ -240,8 +265,10 @@ void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, char *pM
|
|||||||
WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8)));
|
WRITE_SHORT(FixedUnsigned16(textparms.fadeinTime, (1<<8)));
|
||||||
WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8)));
|
WRITE_SHORT(FixedUnsigned16(textparms.fadeoutTime, (1<<8)));
|
||||||
WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8)));
|
WRITE_SHORT(FixedUnsigned16(textparms.holdTime, (1<<8)));
|
||||||
|
|
||||||
if (textparms.effect == 2)
|
if (textparms.effect == 2)
|
||||||
WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8)));
|
WRITE_SHORT(FixedUnsigned16(textparms.fxTime, (1<<8)));
|
||||||
|
|
||||||
WRITE_STRING(pMessage);
|
WRITE_STRING(pMessage);
|
||||||
MESSAGE_END();
|
MESSAGE_END();
|
||||||
}
|
}
|
||||||
@ -255,10 +282,12 @@ void UTIL_ClientPrint( edict_t *pEntity, int msg_dest, char *msg )
|
|||||||
|
|
||||||
char c = msg[190];
|
char c = msg[190];
|
||||||
msg[190] = 0; // truncate without checking with strlen()
|
msg[190] = 0; // truncate without checking with strlen()
|
||||||
|
|
||||||
if (pEntity)
|
if (pEntity)
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgTextMsg, NULL, pEntity);
|
MESSAGE_BEGIN(MSG_ONE, gmsgTextMsg, NULL, pEntity);
|
||||||
else
|
else
|
||||||
MESSAGE_BEGIN(MSG_BROADCAST, gmsgTextMsg);
|
MESSAGE_BEGIN(MSG_BROADCAST, gmsgTextMsg);
|
||||||
|
|
||||||
WRITE_BYTE(msg_dest);
|
WRITE_BYTE(msg_dest);
|
||||||
WRITE_STRING(msg);
|
WRITE_STRING(msg);
|
||||||
MESSAGE_END();
|
MESSAGE_END();
|
||||||
|
@ -47,7 +47,6 @@ static cell AMX_NATIVE_CALL set_vaultdata(AMX *amx,cell *params)
|
|||||||
static cell AMX_NATIVE_CALL get_vaultdata(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL get_vaultdata(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int iLen;
|
int iLen;
|
||||||
|
|
||||||
const char* key = get_amxstring(amx, params[1], 0, iLen);
|
const char* key = get_amxstring(amx, params[1], 0, iLen);
|
||||||
|
|
||||||
if (params[3])
|
if (params[3])
|
||||||
@ -69,11 +68,11 @@ static cell AMX_NATIVE_CALL remove_vaultdata(AMX *amx,cell *params)
|
|||||||
static cell AMX_NATIVE_CALL vaultdata_exists(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL vaultdata_exists(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
int iLen;
|
int iLen;
|
||||||
|
|
||||||
return g_vault.exists(get_amxstring(amx, params[1], 0, iLen)) ? 1 : 0;
|
return g_vault.exists(get_amxstring(amx, params[1], 0, iLen)) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO vault_Natives[] = {
|
AMX_NATIVE_INFO vault_Natives[] =
|
||||||
|
{
|
||||||
{"set_vaultdata", set_vaultdata},
|
{"set_vaultdata", set_vaultdata},
|
||||||
{"get_vaultdata", get_vaultdata},
|
{"get_vaultdata", get_vaultdata},
|
||||||
{"remove_vaultdata", remove_vaultdata},
|
{"remove_vaultdata", remove_vaultdata},
|
||||||
@ -81,5 +80,3 @@ AMX_NATIVE_INFO vault_Natives[] = {
|
|||||||
{"vaultdata_exists", vaultdata_exists},
|
{"vaultdata_exists", vaultdata_exists},
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
|||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,5,0,1
|
FILEVERSION 1,6,0,0
|
||||||
PRODUCTVERSION 1,5,0,1
|
PRODUCTVERSION 1,6,0,0
|
||||||
FILEFLAGSMASK 0x17L
|
FILEFLAGSMASK 0x17L
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
@ -45,12 +45,12 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
VALUE "Comments", "AMX Mod X"
|
VALUE "Comments", "AMX Mod X"
|
||||||
VALUE "FileDescription", "AMX Mod X"
|
VALUE "FileDescription", "AMX Mod X"
|
||||||
VALUE "FileVersion", "1.50"
|
VALUE "FileVersion", "1.60"
|
||||||
VALUE "InternalName", "amxmodx"
|
VALUE "InternalName", "amxmodx"
|
||||||
VALUE "LegalCopyright", "Copyright (c) 2004-2005, AMX Mod X Dev Team"
|
VALUE "LegalCopyright", "Copyright (c) 2004-2005, AMX Mod X Dev Team"
|
||||||
VALUE "OriginalFilename", "amxmodx_mm.dll"
|
VALUE "OriginalFilename", "amxmodx_mm.dll"
|
||||||
VALUE "ProductName", "AMX Mod X"
|
VALUE "ProductName", "AMX Mod X"
|
||||||
VALUE "ProductVersion", "1.50-RC1"
|
VALUE "ProductVersion", "1.60"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||||
|
|
||||||
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
|
OPT_FLAGS = -O3 -funroll-loops -s -pipe
|
||||||
DEBUG_FLAGS = -g -ggdb3
|
DEBUG_FLAGS = -g -ggdb3
|
||||||
CPP = g++
|
CPP = gcc
|
||||||
BINARY = amxxpc
|
BINARY = amxxpc
|
||||||
|
|
||||||
OBJECTS = amx.cpp amxxpc.cpp Binary.cpp
|
OBJECTS = amx.cpp amxxpc.cpp Binary.cpp
|
||||||
|
|
||||||
LINK = -lz
|
LINK = -lz /lib/libstdc++.a
|
||||||
|
|
||||||
INCLUDE = -I. -L.
|
INCLUDE = -I. -L.
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ else
|
|||||||
CFLAGS = $(OPT_FLAGS)
|
CFLAGS = $(OPT_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -DLINUX -DNDEBUG -Wno-deprecated -fexceptions -DHAVE_STDINT_H -DAMX_ANSIONLY
|
CFLAGS += -DLINUX -DNDEBUG -Wno-deprecated -fexceptions -DHAVE_STDINT_H -DAMX_ANSIONLY -fno-rtti -static-libgcc
|
||||||
|
|
||||||
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
||||||
|
|
||||||
|
@ -30,7 +30,11 @@ int main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
HINSTANCE lib = dlmount("./amxxpc32.so");
|
HINSTANCE lib = NULL;
|
||||||
|
if (FileExists("./amxxpc32.so"))
|
||||||
|
lib = dlmount("./amxxpc32.so");
|
||||||
|
else
|
||||||
|
lib = dlmount("amxxpc32.so");
|
||||||
#else
|
#else
|
||||||
HINSTANCE lib = dlmount("amxxpc32.dll");
|
HINSTANCE lib = dlmount("amxxpc32.dll");
|
||||||
#endif
|
#endif
|
||||||
@ -99,17 +103,18 @@ int main(int argc, char **argv)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
dlclose(lib);
|
|
||||||
unlink(file);
|
unlink(file);
|
||||||
|
|
||||||
HINSTANCE lib64 = 0;
|
HINSTANCE lib64 = NULL;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
if (FileExists("./amxxpc64.so"))
|
||||||
lib64 = dlmount("./amxxpc64.so");
|
lib64 = dlmount("./amxxpc64.so");
|
||||||
|
else
|
||||||
|
lib64 = dlmount("amxxpc64.so");
|
||||||
#else
|
#else
|
||||||
lib64 = dlmount("amxxpc64.dll");
|
lib64 = dlmount("amxxpc64.dll");
|
||||||
#endif
|
#endif
|
||||||
pc_printf = (PRINTF)dlsym(lib64, "pc_printf");
|
if (!lib64)
|
||||||
if (!lib64 || !pc_printf)
|
|
||||||
{
|
{
|
||||||
pc_printf("64bit compiler failed to instantiate.\n");
|
pc_printf("64bit compiler failed to instantiate.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -129,6 +134,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
sc64(argc, argv);
|
sc64(argc, argv);
|
||||||
|
|
||||||
|
dlclose(lib64);
|
||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
pc_printf("Could not locate the output file on second pass.\n");
|
pc_printf("Could not locate the output file on second pass.\n");
|
||||||
@ -207,7 +214,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
pc_printf("Done.\n");
|
pc_printf("Done.\n");
|
||||||
|
|
||||||
dlclose(lib64);
|
dlclose(lib);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -374,3 +381,15 @@ void show_help()
|
|||||||
printf("\t-p<name> set name of \"prefix\" file\n");
|
printf("\t-p<name> set name of \"prefix\" file\n");
|
||||||
printf("\t-r[name] write cross reference report to console or to specified file\n");
|
printf("\t-r[name] write cross reference report to console or to specified file\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
bool FileExists(const char *file)
|
||||||
|
{
|
||||||
|
FILE *fp = fopen(file, "rb");
|
||||||
|
if (!fp)
|
||||||
|
return false;
|
||||||
|
fclose(fp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef _AMXXSC_INCLUDE_H
|
#ifndef _AMXXSC_INCLUDE_H
|
||||||
#define _AMXXSC_INCLUDE_H
|
#define _AMXXSC_INCLUDE_H
|
||||||
|
|
||||||
#define VERSION_STRING "1.50-300"
|
#define VERSION_STRING "1.60-300"
|
||||||
#define VERSION 03000
|
#define VERSION 03000
|
||||||
#define MAGIC_HEADER 0x414D5842
|
#define MAGIC_HEADER 0x414D5842
|
||||||
#define MAGIC_HEADER2 0x414D5858
|
#define MAGIC_HEADER2 0x414D5858
|
||||||
@ -67,4 +67,8 @@ struct BinPlugin
|
|||||||
int32_t offs; //file offset
|
int32_t offs; //file offset
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
bool FileExists(const char *file);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif //_AMXXSC_INCLUDE_H
|
#endif //_AMXXSC_INCLUDE_H
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||||
|
|
||||||
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
|
OPT_FLAGS = -O3 -funroll-loops -s -pipe
|
||||||
DEBUG_FLAGS = -g -ggdb3
|
DEBUG_FLAGS = -g -ggdb3
|
||||||
CPP = gcc
|
CPP = gcc
|
||||||
NAME = amxxpc
|
NAME = amxxpc
|
||||||
@ -18,14 +18,14 @@ INCLUDE = -I.
|
|||||||
ifeq "$(PAWN64)" "true"
|
ifeq "$(PAWN64)" "true"
|
||||||
BINARY = $(NAME)64.so
|
BINARY = $(NAME)64.so
|
||||||
BIN_DIR = Release64
|
BIN_DIR = Release64
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64
|
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -Dpc_printf=pc_printf64
|
||||||
else
|
else
|
||||||
BINARY = $(NAME)32.so
|
BINARY = $(NAME)32.so
|
||||||
BIN_DIR = Release32
|
BIN_DIR = Release32
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=32
|
CFLAGS += -DPAWN_CELL_SIZE=32
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -DLINUX -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H -DENABLE_BINRELOC -DNO_MAIN -DPAWNC_DLL
|
CFLAGS += -DLINUX -DNDEBUG -fPIC -DHAVE_STDINT_H -DENABLE_BINRELOC -DNO_MAIN -DPAWNC_DLL -static-libgcc
|
||||||
|
|
||||||
CFLAGS += $(OPT_FLAGS)
|
CFLAGS += $(OPT_FLAGS)
|
||||||
OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
|
OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
|
||||||
@ -42,9 +42,6 @@ all:
|
|||||||
pawn_make: $(OBJ_LINUX)
|
pawn_make: $(OBJ_LINUX)
|
||||||
$(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
|
$(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
|
||||||
|
|
||||||
pawn64:
|
|
||||||
$(MAKE) pawn_make PAWN64=true
|
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
$(MAKE) all DEBUG=true
|
$(MAKE) all DEBUG=true
|
||||||
|
|
||||||
|
@ -65,12 +65,16 @@
|
|||||||
* purpose messages; errors go through pc_error(). The function is modelled
|
* purpose messages; errors go through pc_error(). The function is modelled
|
||||||
* after printf().
|
* after printf().
|
||||||
*/
|
*/
|
||||||
|
#if PAWN_CELL_SIZE==32
|
||||||
#if defined __WIN32__ || defined _WIN32 || defined WIN32
|
#if defined __WIN32__ || defined _WIN32 || defined WIN32
|
||||||
__declspec (dllexport)
|
__declspec (dllexport)
|
||||||
int pc_printf(const char *message,...)
|
int pc_printf(const char *message,...)
|
||||||
#else
|
#else
|
||||||
extern int pc_printf(const char *message,...)
|
extern int pc_printf(const char *message,...)
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
int pc_printf(const char *message, ...)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#if PAWN_CELL_SIZE==32
|
#if PAWN_CELL_SIZE==32
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -6,6 +6,8 @@ EndProject
|
|||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
Debug = Debug
|
Debug = Debug
|
||||||
|
Debug32 = Debug32
|
||||||
|
Debug64 = Debug64
|
||||||
Release = Release
|
Release = Release
|
||||||
Release32 = Release32
|
Release32 = Release32
|
||||||
Release64 = Release64
|
Release64 = Release64
|
||||||
@ -13,6 +15,10 @@ Global
|
|||||||
GlobalSection(ProjectConfiguration) = postSolution
|
GlobalSection(ProjectConfiguration) = postSolution
|
||||||
{19B72687-080B-437A-917A-12AEB0031635}.Debug.ActiveCfg = Release|Win32
|
{19B72687-080B-437A-917A-12AEB0031635}.Debug.ActiveCfg = Release|Win32
|
||||||
{19B72687-080B-437A-917A-12AEB0031635}.Debug.Build.0 = Release|Win32
|
{19B72687-080B-437A-917A-12AEB0031635}.Debug.Build.0 = Release|Win32
|
||||||
|
{19B72687-080B-437A-917A-12AEB0031635}.Debug32.ActiveCfg = Debug32|Win32
|
||||||
|
{19B72687-080B-437A-917A-12AEB0031635}.Debug32.Build.0 = Debug32|Win32
|
||||||
|
{19B72687-080B-437A-917A-12AEB0031635}.Debug64.ActiveCfg = Debug64|Win32
|
||||||
|
{19B72687-080B-437A-917A-12AEB0031635}.Debug64.Build.0 = Debug64|Win32
|
||||||
{19B72687-080B-437A-917A-12AEB0031635}.Release.ActiveCfg = Release|Win32
|
{19B72687-080B-437A-917A-12AEB0031635}.Release.ActiveCfg = Release|Win32
|
||||||
{19B72687-080B-437A-917A-12AEB0031635}.Release.Build.0 = Release|Win32
|
{19B72687-080B-437A-917A-12AEB0031635}.Release.Build.0 = Release|Win32
|
||||||
{19B72687-080B-437A-917A-12AEB0031635}.Release32.ActiveCfg = Release32|Win32
|
{19B72687-080B-437A-917A-12AEB0031635}.Release32.ActiveCfg = Release32|Win32
|
||||||
|
@ -200,6 +200,104 @@
|
|||||||
<Tool
|
<Tool
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug32|Win32"
|
||||||
|
OutputDirectory="$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPC300_EXPORTS;PAWNC_DLL;PAWN_CELL_SIZE=32;NO_MAIN"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="1"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="FALSE"
|
||||||
|
DebugInformationFormat="4"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)/amxxpc32.dll"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/libpc300.pdb"
|
||||||
|
SubSystem="2"
|
||||||
|
ImportLibrary="$(OutDir)/libpc300.lib"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug64|Win32"
|
||||||
|
OutputDirectory="$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBPC300_EXPORTS;PAWNC_DLL;PAWN_CELL_SIZE=64;NO_MAIN"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="1"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="FALSE"
|
||||||
|
DebugInformationFormat="4"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="$(OutDir)/amxxpc64.dll"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/libpc300.pdb"
|
||||||
|
SubSystem="2"
|
||||||
|
ImportLibrary="$(OutDir)/libpc300.lib"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
|
@ -63,6 +63,12 @@
|
|||||||
#define PREPROC_TERM '\x7f'/* termination character for preprocessor expressions (the "DEL" code) */
|
#define PREPROC_TERM '\x7f'/* termination character for preprocessor expressions (the "DEL" code) */
|
||||||
#define sDEF_PREFIX "default.inc" /* default prefix filename */
|
#define sDEF_PREFIX "default.inc" /* default prefix filename */
|
||||||
|
|
||||||
|
#if defined WIN32
|
||||||
|
#define INVISIBLE
|
||||||
|
#else
|
||||||
|
#define INVISIBLE __attribute__((visibility("protected")))
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
void *pv; /* e.g. a name */
|
void *pv; /* e.g. a name */
|
||||||
int i;
|
int i;
|
||||||
@ -435,12 +441,16 @@ int pc_enablewarning(int number,int enable);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* general console output */
|
/* general console output */
|
||||||
|
#if PAWN_CELL_SIZE==32
|
||||||
#if defined __WIN32__ || defined _WIN32 || defined WIN32
|
#if defined __WIN32__ || defined _WIN32 || defined WIN32
|
||||||
__declspec (dllexport)
|
__declspec (dllexport)
|
||||||
int pc_printf(const char *message,...);
|
int pc_printf(const char *message,...);
|
||||||
#else
|
#else
|
||||||
extern int pc_printf(const char *message,...);
|
extern int pc_printf(const char *message,...);
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
int pc_printf(const char *message, ...) INVISIBLE;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* error report function */
|
/* error report function */
|
||||||
int pc_error(int number,char *message,char *filename,int firstline,int lastline,va_list argptr);
|
int pc_error(int number,char *message,char *filename,int firstline,int lastline,va_list argptr);
|
||||||
@ -629,11 +639,7 @@ SC_FUNC void jmp_eq0(int number);
|
|||||||
SC_FUNC void outval(cell val,int newline);
|
SC_FUNC void outval(cell val,int newline);
|
||||||
|
|
||||||
/* function prototypes in SC5.C */
|
/* function prototypes in SC5.C */
|
||||||
#ifdef __linux__
|
SC_FUNC int error(int number,...) INVISIBLE;
|
||||||
SC_FUNC int error(int number,...) __attribute__((visibility("internal")));
|
|
||||||
#else
|
|
||||||
SC_FUNC int error(int number,...)
|
|
||||||
#endif
|
|
||||||
SC_FUNC void errorset(int code);
|
SC_FUNC void errorset(int code);
|
||||||
|
|
||||||
/* function prototypes in SC6.C */
|
/* function prototypes in SC6.C */
|
||||||
|
@ -654,7 +654,6 @@ cleanup:
|
|||||||
int flag_exceed=0;
|
int flag_exceed=0;
|
||||||
if (sc_amxlimit > 0 && (long)(hdrsize+code_idx+glb_declared*sizeof(cell)+sc_stksize*sizeof(cell)) >= sc_amxlimit)
|
if (sc_amxlimit > 0 && (long)(hdrsize+code_idx+glb_declared*sizeof(cell)+sc_stksize*sizeof(cell)) >= sc_amxlimit)
|
||||||
flag_exceed=1;
|
flag_exceed=1;
|
||||||
#if PAWN_CELL_SIZE==32
|
|
||||||
if ((sc_debug & sSYMBOLIC)!=0 || verbosity>=2 || stacksize+32>=(long)sc_stksize || flag_exceed) {
|
if ((sc_debug & sSYMBOLIC)!=0 || verbosity>=2 || stacksize+32>=(long)sc_stksize || flag_exceed) {
|
||||||
pc_printf("Header size: %8ld bytes\n", (long)hdrsize);
|
pc_printf("Header size: %8ld bytes\n", (long)hdrsize);
|
||||||
pc_printf("Code size: %8ld bytes\n", (long)code_idx);
|
pc_printf("Code size: %8ld bytes\n", (long)code_idx);
|
||||||
@ -666,7 +665,6 @@ cleanup:
|
|||||||
pc_printf("estimated max. usage=%ld cells (%ld bytes)\n",stacksize,stacksize*sizeof(cell));
|
pc_printf("estimated max. usage=%ld cells (%ld bytes)\n",stacksize,stacksize*sizeof(cell));
|
||||||
pc_printf("Total requirements:%8ld bytes\n", (long)hdrsize+(long)code_idx+(long)glb_declared*sizeof(cell)+(long)sc_stksize*sizeof(cell));
|
pc_printf("Total requirements:%8ld bytes\n", (long)hdrsize+(long)code_idx+(long)glb_declared*sizeof(cell)+(long)sc_stksize*sizeof(cell));
|
||||||
} /* if */
|
} /* if */
|
||||||
#endif
|
|
||||||
if (flag_exceed)
|
if (flag_exceed)
|
||||||
error(106,sc_amxlimit); /* this causes a jump back to label "cleanup" */
|
error(106,sc_amxlimit); /* this causes a jump back to label "cleanup" */
|
||||||
} /* if */
|
} /* if */
|
||||||
@ -1920,9 +1918,11 @@ static int declloc(int fstatic)
|
|||||||
/* Although valid, a local variable whose name is equal to that
|
/* Although valid, a local variable whose name is equal to that
|
||||||
* of a global variable or to that of a local variable at a lower
|
* of a global variable or to that of a local variable at a lower
|
||||||
* level might indicate a bug.
|
* level might indicate a bug.
|
||||||
|
* NOTE - don't bother with the error if there's no valid function!
|
||||||
*/
|
*/
|
||||||
if ((sym=findloc(name))!=NULL && sym->compound!=nestlevel || findglb(name)!=NULL);
|
if ((sym=findloc(name))!=NULL && sym->compound!=nestlevel || findglb(name)!=NULL)
|
||||||
//error(219,name); /* variable shadows another symbol */
|
if (curfunc!=NULL && (curfunc->usage & uNATIVE))
|
||||||
|
error(219,name); /* variable shadows another symbol */
|
||||||
while (matchtoken('[')){
|
while (matchtoken('[')){
|
||||||
ident=iARRAY;
|
ident=iARRAY;
|
||||||
if (numdim == sDIMEN_MAX) {
|
if (numdim == sDIMEN_MAX) {
|
||||||
@ -3180,7 +3180,7 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
|
|||||||
if ((sym->usage & (uPROTOTYPED | uREAD))==uREAD && sym->tag!=0) {
|
if ((sym->usage & (uPROTOTYPED | uREAD))==uREAD && sym->tag!=0) {
|
||||||
int curstatus=sc_status;
|
int curstatus=sc_status;
|
||||||
sc_status=statWRITE; /* temporarily set status to WRITE, so the warning isn't blocked */
|
sc_status=statWRITE; /* temporarily set status to WRITE, so the warning isn't blocked */
|
||||||
error(208);
|
//error(208); //this is silly, it should be caught the first pass
|
||||||
sc_status=curstatus;
|
sc_status=curstatus;
|
||||||
sc_reparse=TRUE; /* must add another pass to "initial scan" phase */
|
sc_reparse=TRUE; /* must add another pass to "initial scan" phase */
|
||||||
} /* if */
|
} /* if */
|
||||||
@ -3645,8 +3645,8 @@ static void doarg(char *name,int ident,int offset,int tags[],int numtags,
|
|||||||
if (argsym!=NULL) {
|
if (argsym!=NULL) {
|
||||||
error(21,name); /* symbol already defined */
|
error(21,name); /* symbol already defined */
|
||||||
} else {
|
} else {
|
||||||
if ((argsym=findglb(name))!=NULL && argsym->ident!=iFUNCTN) ;
|
if ((argsym=findglb(name))!=NULL && argsym->ident!=iFUNCTN && curfunc!=NULL)
|
||||||
//error(219,name); /* variable shadows another symbol */
|
error(219,name); /* variable shadows another symbol */
|
||||||
/* add details of type and address */
|
/* add details of type and address */
|
||||||
assert(numtags>0);
|
assert(numtags>0);
|
||||||
argsym=addvariable(name,offset,ident,sLOCAL,tags[0],
|
argsym=addvariable(name,offset,ident,sLOCAL,tags[0],
|
||||||
|
@ -715,18 +715,6 @@ static int ftoi(cell *val,const unsigned char *curptr)
|
|||||||
#endif
|
#endif
|
||||||
#elif PAWN_CELL_SIZE==64
|
#elif PAWN_CELL_SIZE==64
|
||||||
*val=*((cell *)&fnum);
|
*val=*((cell *)&fnum);
|
||||||
#if !defined NDEBUG
|
|
||||||
/* I assume that the C/C++ compiler stores "double" values in IEEE 754
|
|
||||||
* format (as mandated in the ANSI standard).
|
|
||||||
*/
|
|
||||||
{ float test1 = 0.0, test2 = 50.0, test3 = -50.0;
|
|
||||||
uint64_t bit = 1;
|
|
||||||
/* test 0.0 == all bits 0 */
|
|
||||||
assert(*(uint64_t*)&test1==0x00000000L);
|
|
||||||
/* test sign & magnitude format */
|
|
||||||
assert(((*(uint64_t*)&test2) ^ (*(uint64_t*)&test3)) == (bit << (PAWN_CELL_SIZE-1)));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#error Unsupported cell size
|
#error Unsupported cell size
|
||||||
#endif
|
#endif
|
||||||
@ -1419,7 +1407,7 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
|
|||||||
int prefixlen;
|
int prefixlen;
|
||||||
const unsigned char *p,*s,*e;
|
const unsigned char *p,*s,*e;
|
||||||
unsigned char *args[10];
|
unsigned char *args[10];
|
||||||
int match,arg,len;
|
int match,arg,len,argsnum=0;
|
||||||
|
|
||||||
memset(args,0,sizeof args);
|
memset(args,0,sizeof args);
|
||||||
|
|
||||||
@ -1459,6 +1447,8 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
|
|||||||
/* store the parameter (overrule any earlier) */
|
/* store the parameter (overrule any earlier) */
|
||||||
if (args[arg]!=NULL)
|
if (args[arg]!=NULL)
|
||||||
free(args[arg]);
|
free(args[arg]);
|
||||||
|
else
|
||||||
|
argsnum++;
|
||||||
len=(int)(e-s);
|
len=(int)(e-s);
|
||||||
args[arg]=(unsigned char*)malloc(len+1);
|
args[arg]=(unsigned char*)malloc(len+1);
|
||||||
if (args[arg]==NULL)
|
if (args[arg]==NULL)
|
||||||
@ -1515,14 +1505,17 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
|
|||||||
if (match) {
|
if (match) {
|
||||||
/* calculate the length of the substituted string */
|
/* calculate the length of the substituted string */
|
||||||
for (e=(unsigned char*)substitution,len=0; *e!='\0'; e++) {
|
for (e=(unsigned char*)substitution,len=0; *e!='\0'; e++) {
|
||||||
if (*e=='%' && isdigit(*(e+1))) {
|
if (*e=='%' && isdigit(*(e+1)) && argsnum) {
|
||||||
arg=*(e+1)-'0';
|
arg=*(e+1)-'0';
|
||||||
assert(arg>=0 && arg<=9);
|
assert(arg>=0 && arg<=9);
|
||||||
if (args[arg]!=NULL)
|
if (args[arg]!=NULL) {
|
||||||
len+=strlen((char*)args[arg]);
|
len+=strlen((char*)args[arg]);
|
||||||
e++; /* skip %, digit is skipped later */
|
e++; /* skip %, digit is skipped later */
|
||||||
} else {
|
} else {
|
||||||
len++;
|
len++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
len++;
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* for */
|
} /* for */
|
||||||
/* check length of the string after substitution */
|
/* check length of the string after substitution */
|
||||||
@ -1538,12 +1531,25 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
|
|||||||
if (args[arg]!=NULL) {
|
if (args[arg]!=NULL) {
|
||||||
strins((char*)s,(char*)args[arg],strlen((char*)args[arg]));
|
strins((char*)s,(char*)args[arg],strlen((char*)args[arg]));
|
||||||
s+=strlen((char*)args[arg]);
|
s+=strlen((char*)args[arg]);
|
||||||
} /* if */
|
|
||||||
e++; /* skip %, digit is skipped later */
|
e++; /* skip %, digit is skipped later */
|
||||||
} else {
|
} else {
|
||||||
strins((char*)s,(char*)e,1);
|
strins((char*)s,(char*)e,1);
|
||||||
s++;
|
s++;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
} else if (*e=='"') {
|
||||||
|
p=e;
|
||||||
|
if (is_startstring(e)) { /* skip strings */
|
||||||
|
e=skipstring(e);
|
||||||
|
strins((char*)s,(char*)p,(e-p+1));
|
||||||
|
s+=(e-p+1);
|
||||||
|
} else {
|
||||||
|
strins((char*)s,(char*)e,1);
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strins((char*)s,(char*)e,1);
|
||||||
|
s++;
|
||||||
|
} /* if */
|
||||||
} /* for */
|
} /* for */
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* if */
|
} /* if */
|
||||||
@ -1578,7 +1584,7 @@ static void substallpatterns(unsigned char *line,int buffersize)
|
|||||||
if (*start=='\0')
|
if (*start=='\0')
|
||||||
break; /* abort loop on error */
|
break; /* abort loop on error */
|
||||||
/* if matching the operator "defined", skip it plus the symbol behind it */
|
/* if matching the operator "defined", skip it plus the symbol behind it */
|
||||||
if (strncmp((char*)start,"defined",7)==0 && *(start+7)<=' ') {
|
if (strncmp((char*)start,"defined",7)==0 && !isalpha((char)*(start+7))) {
|
||||||
start+=7; /* skip "defined" */
|
start+=7; /* skip "defined" */
|
||||||
/* skip white space & parantheses */
|
/* skip white space & parantheses */
|
||||||
while (*start<=' ' && *start!='\0' || *start=='(')
|
while (*start<=' ' && *start!='\0' || *start=='(')
|
||||||
@ -2451,7 +2457,7 @@ static symbol *find_symbol(const symbol *root,const char *name,int fnumber,int i
|
|||||||
while (ptr!=NULL) {
|
while (ptr!=NULL) {
|
||||||
if (hash==ptr->hash && strcmp(name,ptr->name)==0
|
if (hash==ptr->hash && strcmp(name,ptr->name)==0
|
||||||
&& (ptr->parent==NULL || includechildren)
|
&& (ptr->parent==NULL || includechildren)
|
||||||
&& (ptr->fnumber<0 || ptr->fnumber==fnumber))
|
&& (fnumber<0 || (ptr->fnumber<0 || ptr->fnumber==fnumber)))
|
||||||
return ptr;
|
return ptr;
|
||||||
ptr=ptr->next;
|
ptr=ptr->next;
|
||||||
} /* while */
|
} /* while */
|
||||||
|
@ -964,8 +964,12 @@ static int hier14(value *lval1)
|
|||||||
check_userop(NULL,lval2.tag,lval3.tag,2,&lval3,&lval2.tag);
|
check_userop(NULL,lval2.tag,lval3.tag,2,&lval3,&lval2.tag);
|
||||||
store(&lval3); /* now, store the expression result */
|
store(&lval3); /* now, store the expression result */
|
||||||
} /* if */
|
} /* if */
|
||||||
if (!oper && !matchtag(lval3.tag,lval2.tag,TRUE))
|
if (!oper) { /* tagname mismatch (if "oper", warning already given in plunge2()) */
|
||||||
error(213); /* tagname mismatch (if "oper", warning already given in plunge2()) */
|
if (lval3.sym && !matchtag(lval3.sym->tag, lval2.tag, TRUE))
|
||||||
|
error(213);
|
||||||
|
else if (!lval3.sym && !matchtag(lval3.tag, lval2.tag, TRUE))
|
||||||
|
error(213);
|
||||||
|
}
|
||||||
if (lval3.sym)
|
if (lval3.sym)
|
||||||
markusage(lval3.sym,uWRITTEN);
|
markusage(lval3.sym,uWRITTEN);
|
||||||
sideeffect=TRUE;
|
sideeffect=TRUE;
|
||||||
@ -2202,7 +2206,8 @@ static int nesting=0;
|
|||||||
if ((sym->usage & uNATIVE)==0)
|
if ((sym->usage & uNATIVE)==0)
|
||||||
totalsize++; /* add "call" opcode */
|
totalsize++; /* add "call" opcode */
|
||||||
totalsize+=nest_stkusage;
|
totalsize+=nest_stkusage;
|
||||||
assert(curfunc!=NULL);
|
if (!curfunc) /* if we got here, the function is invalid! */
|
||||||
|
return;
|
||||||
if (curfunc->x.stacksize<totalsize)
|
if (curfunc->x.stacksize<totalsize)
|
||||||
curfunc->x.stacksize=totalsize;
|
curfunc->x.stacksize=totalsize;
|
||||||
nest_stkusage-=nargs+heapalloc+1; /* stack/heap space, +1 for argcount param */
|
nest_stkusage-=nargs+heapalloc+1; /* stack/heap space, +1 for argcount param */
|
||||||
|
@ -581,6 +581,8 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
|||||||
constvalue *constptr;
|
constvalue *constptr;
|
||||||
cell mainaddr;
|
cell mainaddr;
|
||||||
|
|
||||||
|
fcurrent = -1;
|
||||||
|
|
||||||
/* if compression failed, restart the assembly with compaction switched off */
|
/* if compression failed, restart the assembly with compaction switched off */
|
||||||
if (setjmp(compact_err)!=0) {
|
if (setjmp(compact_err)!=0) {
|
||||||
assert(sc_compress); /* cannot arrive here if compact encoding was disabled */
|
assert(sc_compress); /* cannot arrive here if compact encoding was disabled */
|
||||||
|
@ -450,9 +450,14 @@ SC_FUNC stringlist *insert_dbgsymbol(symbol *sym)
|
|||||||
#endif
|
#endif
|
||||||
if (sym->ident==iARRAY || sym->ident==iREFARRAY) {
|
if (sym->ident==iARRAY || sym->ident==iREFARRAY) {
|
||||||
symbol *sub;
|
symbol *sub;
|
||||||
|
#if !defined NDEBUG
|
||||||
|
count = sym->dim.array.level;
|
||||||
|
#endif
|
||||||
strcat(string," [ ");
|
strcat(string," [ ");
|
||||||
for (sub=sym; sub!=NULL; sub=finddepend(sub)) {
|
for (sub=sym; sub!=NULL; sub=finddepend(sub)) {
|
||||||
assert(sub->dim.array.level==count++);
|
#if !defined NDEBUG
|
||||||
|
assert(sub->dim.array.level==count--);
|
||||||
|
#endif
|
||||||
sprintf(string+strlen(string),"%x:%x ",sub->x.idxtag,sub->dim.array.length);
|
sprintf(string+strlen(string),"%x:%x ",sub->x.idxtag,sub->dim.array.length);
|
||||||
} /* for */
|
} /* for */
|
||||||
strcat(string,"]");
|
strcat(string,"]");
|
||||||
|
@ -35,7 +35,7 @@ statscfg.amxx ; allows to manage stats plugins via menu and commands
|
|||||||
|
|
||||||
; Counter-Strike
|
; Counter-Strike
|
||||||
;restmenu.amxx ; restrict weapons menu
|
;restmenu.amxx ; restrict weapons menu
|
||||||
;statsx.amxx ; stats on death or round end (CSX Module required!)
|
statsx.amxx ; stats on death or round end (CSX Module required!)
|
||||||
;miscstats.amxx ; bunch of events announcement for Counter-Strike
|
;miscstats.amxx ; bunch of events announcement for Counter-Strike
|
||||||
;stats_logging.amxx ; weapons stats logging (CSX Module required!)
|
;stats_logging.amxx ; weapons stats logging (CSX Module required!)
|
||||||
|
|
||||||
|
@ -12,16 +12,16 @@ fun_amxx_amd64.so
|
|||||||
; ----------------------------------------------------
|
; ----------------------------------------------------
|
||||||
; Engine - provides engine functions core to Half-Life
|
; Engine - provides engine functions core to Half-Life
|
||||||
; ----------------------------------------------------
|
; ----------------------------------------------------
|
||||||
;engine_amxx_i386.so
|
engine_amxx_i386.so
|
||||||
;engine_amxx.dll
|
engine_amxx.dll
|
||||||
;engine_amxx_amd64.so
|
engine_amxx_amd64.so
|
||||||
|
|
||||||
; ----------------------------------------------------------
|
; ----------------------------------------------------------
|
||||||
; Fakemeta - provides a massive interface into the HL engine
|
; Fakemeta - provides a massive interface into the HL engine
|
||||||
; ----------------------------------------------------------
|
; ----------------------------------------------------------
|
||||||
;fakemeta_amxx_i386.so
|
fakemeta_amxx_i386.so
|
||||||
;fakemeta_amxx.dll
|
fakemeta_amxx.dll
|
||||||
;fakemeta_amxx_amd64.so
|
fakemeta_amxx_amd64.so
|
||||||
|
|
||||||
; -------------------------------------------
|
; -------------------------------------------
|
||||||
; Database Access - only enable one of these
|
; Database Access - only enable one of these
|
||||||
@ -67,10 +67,3 @@ fun_amxx_amd64.so
|
|||||||
;nvault_amxx_i386.so
|
;nvault_amxx_i386.so
|
||||||
;nvault_amxx.dll
|
;nvault_amxx.dll
|
||||||
;nvault_amxx_amd64.so
|
;nvault_amxx_amd64.so
|
||||||
|
|
||||||
; --------------------------------------------
|
|
||||||
; Adds ESF miscellanious and hacking functions
|
|
||||||
; --------------------------------------------
|
|
||||||
esfmod_amxx_i386.so
|
|
||||||
esfmod_amxx.dll
|
|
||||||
esfmod_amxx_amd64.so
|
|
||||||
|
39
configs/esf/plugins.ini
Executable file
39
configs/esf/plugins.ini
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
; AMX Mod X plugins
|
||||||
|
|
||||||
|
; Admin Base - Always one has to be activated
|
||||||
|
admin.amxx ; admin base (required for any admin-related)
|
||||||
|
;admin_sql.amxx ; admin base - SQL version (comment admin.amxx)
|
||||||
|
|
||||||
|
; Basic
|
||||||
|
admincmd.amxx ; basic admin console commands
|
||||||
|
adminhelp.amxx ; help command for admin console commands
|
||||||
|
adminslots.amxx ; slot reservation
|
||||||
|
multilingual.amxx ; Multi-Lingual management
|
||||||
|
|
||||||
|
; Menus
|
||||||
|
menufront.amxx ; front-end for admin menus
|
||||||
|
cmdmenu.amxx ; command menu (speech, settings)
|
||||||
|
plmenu.amxx ; players menu (kick, ban, client cmds.)
|
||||||
|
;telemenu.amxx ; teleport menu (Fun Module required!)
|
||||||
|
mapsmenu.amxx ; maps menu (vote, changelevel)
|
||||||
|
|
||||||
|
; Chat / Messages
|
||||||
|
adminchat.amxx ; console chat commands
|
||||||
|
antiflood.amxx ; prevent clients from chat-flooding the server
|
||||||
|
scrollmsg.amxx ; displays a scrolling message
|
||||||
|
imessage.amxx ; displays information messages
|
||||||
|
adminvote.amxx ; vote commands
|
||||||
|
|
||||||
|
; Map related
|
||||||
|
nextmap.amxx ; displays next map in mapcycle
|
||||||
|
mapchooser.amxx ; allows to vote for next map
|
||||||
|
timeleft.amxx ; displays time left on map
|
||||||
|
|
||||||
|
; Configuration
|
||||||
|
pausecfg.amxx ; allows to pause and unpause some plugins
|
||||||
|
statscfg.amxx ; allows to manage stats plugins via menu and commands
|
||||||
|
|
||||||
|
|
||||||
|
; Custom - Add 3rd party plugins here
|
||||||
|
EvolutionX.Core.amxx ; Adds extra plugin functions for Earth's Special Forces
|
||||||
|
; (made by the Corona Bytes team of EVM)
|
@ -6,7 +6,7 @@ MM_ROOT = ../metamod/metamod
|
|||||||
|
|
||||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||||
|
|
||||||
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
|
OPT_FLAGS = -O2 -funroll-loops -s -pipe -fomit-frame-pointer
|
||||||
DEBUG_FLAGS = -g -ggdb3
|
DEBUG_FLAGS = -g -ggdb3
|
||||||
CPP = gcc
|
CPP = gcc
|
||||||
NAME = cstrike_amxx
|
NAME = cstrike_amxx
|
||||||
@ -26,12 +26,11 @@ else
|
|||||||
CFLAGS = $(OPT_FLAGS)
|
CFLAGS = $(OPT_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H
|
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H -fno-rtti -static-libgcc
|
||||||
|
|
||||||
ifeq "$(AMD64)" "true"
|
ifeq "$(AMD64)" "true"
|
||||||
BINARY = $(NAME)_amd64.so
|
BINARY = $(NAME)_amd64.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
||||||
LINK += -lstdc++
|
|
||||||
else
|
else
|
||||||
BINARY = $(NAME)_i386.so
|
BINARY = $(NAME)_i386.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
||||||
|
@ -45,8 +45,6 @@
|
|||||||
enginefuncs_t g_engfuncs;
|
enginefuncs_t g_engfuncs;
|
||||||
globalvars_t *gpGlobals;
|
globalvars_t *gpGlobals;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_FUNCTIONS *g_pFunctionTable;
|
DLL_FUNCTIONS *g_pFunctionTable;
|
||||||
DLL_FUNCTIONS *g_pFunctionTable_Post;
|
DLL_FUNCTIONS *g_pFunctionTable_Post;
|
||||||
enginefuncs_t *g_pengfuncsTable;
|
enginefuncs_t *g_pengfuncsTable;
|
||||||
@ -54,7 +52,6 @@ enginefuncs_t *g_pengfuncsTable_Post;
|
|||||||
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
|
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
|
||||||
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
|
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
|
||||||
|
|
||||||
|
|
||||||
// GetEntityAPI2 functions
|
// GetEntityAPI2 functions
|
||||||
static DLL_FUNCTIONS g_EntityAPI_Table =
|
static DLL_FUNCTIONS g_EntityAPI_Table =
|
||||||
{
|
{
|
||||||
@ -2481,9 +2478,11 @@ PFN_IS_PLAYER_CONNECTING g_fn_IsPlayerConnecting;
|
|||||||
PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
||||||
PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||||
PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
PFN_ALLOCATOR g_fn_Allocator;
|
PFN_ALLOCATOR g_fn_Allocator;
|
||||||
PFN_REALLOCATOR g_fn_Reallocator;
|
PFN_REALLOCATOR g_fn_Reallocator;
|
||||||
PFN_DEALLOCATOR g_fn_Deallocator;
|
PFN_DEALLOCATOR g_fn_Deallocator;
|
||||||
|
#endif
|
||||||
PFN_AMX_EXEC g_fn_AmxExec;
|
PFN_AMX_EXEC g_fn_AmxExec;
|
||||||
PFN_AMX_EXECV g_fn_AmxExecv;
|
PFN_AMX_EXECV g_fn_AmxExecv;
|
||||||
PFN_AMX_ALLOT g_fn_AmxAllot;
|
PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||||
@ -2502,6 +2501,7 @@ PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
|
|||||||
PFN_FORMAT g_fn_Format;
|
PFN_FORMAT g_fn_Format;
|
||||||
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
||||||
PFN_REQ_FNPTR g_fn_RequestFunction;
|
PFN_REQ_FNPTR g_fn_RequestFunction;
|
||||||
|
PFN_AMX_PUSH g_fn_AmxPush;
|
||||||
|
|
||||||
// *** Exports ***
|
// *** Exports ***
|
||||||
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
||||||
@ -2610,11 +2610,14 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||||||
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
|
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
|
||||||
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
|
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
|
||||||
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
|
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
|
||||||
|
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
// Memory
|
// Memory
|
||||||
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
|
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
|
||||||
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
||||||
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
||||||
|
#endif
|
||||||
|
|
||||||
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
||||||
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
||||||
@ -2717,7 +2720,7 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
MF_IsPlayerHLTV(0);
|
MF_IsPlayerHLTV(0);
|
||||||
MF_GetPlayerArmor(0);
|
MF_GetPlayerArmor(0);
|
||||||
MF_GetPlayerHealth(0);
|
MF_GetPlayerHealth(0);
|
||||||
MF_AmxExec(0, 0, 0, 0);
|
MF_AmxExec(0, 0, 0);
|
||||||
MF_AmxExecv(0, 0, 0, 0, 0);
|
MF_AmxExecv(0, 0, 0, 0, 0);
|
||||||
MF_AmxFindPublic(0, 0, 0);
|
MF_AmxFindPublic(0, 0, 0);
|
||||||
MF_AmxAllot(0, 0, 0, 0);
|
MF_AmxAllot(0, 0, 0, 0);
|
||||||
@ -2733,6 +2736,8 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
|
|
||||||
/************* MEMORY *************/
|
/************* MEMORY *************/
|
||||||
// undef all defined macros
|
// undef all defined macros
|
||||||
#undef new
|
#undef new
|
||||||
@ -2904,6 +2909,30 @@ void operator delete[](void *reportedAddress)
|
|||||||
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
|
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if !defined NO_ALLOC_OVERRIDES && !defined MEMORY_TEST && !defined WIN32
|
||||||
|
void * ::operator new(size_t size) {
|
||||||
|
return(calloc(1, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void * ::operator new[](size_t size) {
|
||||||
|
return(calloc(1, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ::operator delete(void * ptr) {
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ::operator delete[](void * ptr) {
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
/************* stuff from dlls/util.cpp *************/
|
/************* stuff from dlls/util.cpp *************/
|
||||||
// must come here because cbase.h declares it's own operator new
|
// must come here because cbase.h declares it's own operator new
|
||||||
|
|
||||||
|
@ -46,8 +46,6 @@ struct amxx_module_info_s
|
|||||||
const char *logtag; // added in version 2
|
const char *logtag; // added in version 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// return values from functions called by amxx
|
// return values from functions called by amxx
|
||||||
#define AMXX_OK 0 /* no error */
|
#define AMXX_OK 0 /* no error */
|
||||||
#define AMXX_IFVERS 1 /* interface version */
|
#define AMXX_IFVERS 1 /* interface version */
|
||||||
@ -1981,13 +1979,15 @@ typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
|||||||
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const size_t /*size*/);
|
const unsigned int /*type*/, const size_t /*size*/);
|
||||||
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
|
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
|
||||||
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const void* /*addr*/ );
|
const unsigned int /*type*/, const void* /*addr*/ );
|
||||||
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, ... /*params*/);
|
#endif
|
||||||
|
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/);
|
||||||
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
|
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
|
||||||
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
|
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
|
||||||
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
|
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
|
||||||
@ -2002,6 +2002,7 @@ typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
|
|||||||
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
|
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
|
||||||
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
|
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
|
||||||
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
|
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
|
||||||
|
typedef int (*PFN_AMX_PUSH) (AMX * /*amx*/, cell /*value*/);
|
||||||
|
|
||||||
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
||||||
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
||||||
@ -2047,7 +2048,6 @@ extern PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
|||||||
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||||
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||||
extern PFN_AMX_EXEC g_fn_AmxExec;
|
extern PFN_AMX_EXEC g_fn_AmxExec;
|
||||||
extern PFN_AMX_EXECV g_fn_AmxExecv;
|
|
||||||
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||||
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
||||||
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
||||||
@ -2065,6 +2065,7 @@ extern PFN_FORMAT g_fn_Format;
|
|||||||
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
|
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
|
||||||
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
||||||
extern PFN_REQ_FNPTR g_fn_RequestFunction;
|
extern PFN_REQ_FNPTR g_fn_RequestFunction;
|
||||||
|
extern PFN_AMX_PUSH g_fn_AmxPush;
|
||||||
|
|
||||||
#ifdef MAY_NEVER_BE_DEFINED
|
#ifdef MAY_NEVER_BE_DEFINED
|
||||||
// Function prototypes for intellisense and similar systems
|
// Function prototypes for intellisense and similar systems
|
||||||
@ -2123,6 +2124,8 @@ edict_t* MF_GetPlayerEdict (int id) { }
|
|||||||
const char * MF_Format (const char *fmt, ...) { }
|
const char * MF_Format (const char *fmt, ...) { }
|
||||||
void MF_RegisterFunction (void *pfn, const char *description) { }
|
void MF_RegisterFunction (void *pfn, const char *description) { }
|
||||||
void * MF_RequestFunction (const char *description) { }
|
void * MF_RequestFunction (const char *description) { }
|
||||||
|
int MF_AmxPush (AMX *amx, cell *params) { }
|
||||||
|
int MF_AmxExec (AMX *amx, cell *retval, int idx) { }
|
||||||
#endif // MAY_NEVER_BE_DEFINED
|
#endif // MAY_NEVER_BE_DEFINED
|
||||||
|
|
||||||
#define MF_AddNatives g_fn_AddNatives
|
#define MF_AddNatives g_fn_AddNatives
|
||||||
@ -2187,7 +2190,9 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
|
|||||||
#define MF_Format g_fn_Format
|
#define MF_Format g_fn_Format
|
||||||
#define MF_RegisterFunction g_fn_RegisterFunction
|
#define MF_RegisterFunction g_fn_RegisterFunction
|
||||||
#define MF_RequestFunction g_fn_RequestFunction;
|
#define MF_RequestFunction g_fn_RequestFunction;
|
||||||
|
#define MF_AmxPush g_fn_AmxPush
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
/*** Memory ***/
|
/*** Memory ***/
|
||||||
void *operator new(size_t reportedSize);
|
void *operator new(size_t reportedSize);
|
||||||
void *operator new[](size_t reportedSize);
|
void *operator new[](size_t reportedSize);
|
||||||
@ -2231,4 +2236,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
|
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
|
||||||
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
|
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
|
||||||
|
|
||||||
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -175,7 +175,7 @@ static cell AMX_NATIVE_CALL cs_get_weapon_silenced(AMX *amx, cell *params) // cs
|
|||||||
// Make into edict pointer
|
// Make into edict pointer
|
||||||
edict_t *pWeapon = INDEXENT(params[1]);
|
edict_t *pWeapon = INDEXENT(params[1]);
|
||||||
|
|
||||||
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
|
int weapontype = *((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
|
||||||
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
|
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
|
||||||
switch (weapontype) {
|
switch (weapontype) {
|
||||||
case CSW_M4A1:
|
case CSW_M4A1:
|
||||||
@ -357,10 +357,12 @@ static cell AMX_NATIVE_CALL cs_get_user_armor(AMX *amx, cell *params) // cs_get_
|
|||||||
// Make into edict pointer
|
// Make into edict pointer
|
||||||
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
|
||||||
|
|
||||||
|
#if 0
|
||||||
cell *armorTypeByRef = MF_GetAmxAddr(amx, params[2]);
|
cell *armorTypeByRef = MF_GetAmxAddr(amx, params[2]);
|
||||||
*armorTypeByRef = *((int *)pPlayer->pvPrivateData + OFFSET_ARMORTYPE);
|
*armorTypeByRef = *((int *)pPlayer->pvPrivateData + OFFSET_ARMORTYPE);
|
||||||
|
#endif
|
||||||
|
|
||||||
return pPlayer->v.armorvalue;
|
return (cell)pPlayer->v.armorvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL cs_set_user_armor(AMX *amx, cell *params) // cs_set_user_armor(index, armorvalue, CsArmorType:armortype); = 3 params
|
static cell AMX_NATIVE_CALL cs_set_user_armor(AMX *amx, cell *params) // cs_set_user_armor(index, armorvalue, CsArmorType:armortype); = 3 params
|
||||||
@ -1232,6 +1234,118 @@ static cell AMX_NATIVE_CALL cs_user_spawn(AMX *amx, cell *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL cs_get_armoury_type(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
// Return CSW_* constants of specified armoury_entity.
|
||||||
|
// params[1] = entity
|
||||||
|
|
||||||
|
// Valid entity should be within range.
|
||||||
|
CHECK_NONPLAYER(params[1]);
|
||||||
|
|
||||||
|
// Make into edict pointer.
|
||||||
|
edict_t *pArmoury = INDEXENT(params[1]);
|
||||||
|
|
||||||
|
// Make sure this is an armoury_entity.
|
||||||
|
if (strcmp(STRING(pArmoury->v.classname), "armoury_entity")) {
|
||||||
|
// Error out here.
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Not an armoury_entity! (%d)", params[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if PAWN_CELL_SIZE == 32
|
||||||
|
int weapontype = *((int *)pArmoury->pvPrivateData + OFFSET_ARMOURY_TYPE);
|
||||||
|
|
||||||
|
// We do a switch instead of a mapped array because this way we can nicely catch unexpected values, and we don't get array out of bounds thingies.
|
||||||
|
int weapontype_out;
|
||||||
|
switch (weapontype) {
|
||||||
|
case CSA_MP5NAVY: weapontype_out = CSW_MP5NAVY; break;
|
||||||
|
case CSA_TMP: weapontype_out = CSW_TMP; break;
|
||||||
|
case CSA_P90: weapontype_out = CSW_P90; break;
|
||||||
|
case CSA_MAC10: weapontype_out = CSW_MAC10; break;
|
||||||
|
case CSA_AK47: weapontype_out = CSW_AK47; break;
|
||||||
|
case CSA_SG552: weapontype_out = CSW_SG552; break;
|
||||||
|
case CSA_M4A1: weapontype_out = CSW_M4A1; break;
|
||||||
|
case CSA_AUG: weapontype_out = CSW_AUG; break;
|
||||||
|
case CSA_SCOUT: weapontype_out = CSW_SCOUT; break;
|
||||||
|
case CSA_G3SG1: weapontype_out = CSW_G3SG1; break;
|
||||||
|
case CSA_AWP: weapontype_out = CSW_AWP; break;
|
||||||
|
case CSA_M3: weapontype_out = CSW_M3; break;
|
||||||
|
case CSA_XM1014: weapontype_out = CSW_XM1014; break;
|
||||||
|
case CSA_M249: weapontype_out = CSW_M249; break;
|
||||||
|
case CSA_FLASHBANG: weapontype_out = CSW_FLASHBANG; break;
|
||||||
|
case CSA_HEGRENADE: weapontype_out = CSW_HEGRENADE; break;
|
||||||
|
case CSA_VEST: weapontype_out = CSW_VEST; break;
|
||||||
|
case CSA_VESTHELM: weapontype_out = CSW_VESTHELM; break;
|
||||||
|
case CSA_SMOKEGRENADE: weapontype_out = CSW_SMOKEGRENADE; break;
|
||||||
|
default:
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Unexpected weapon type of %d!", params[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return weapontype_out;
|
||||||
|
#else
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "This function not implemented on AMD64.");
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL cs_set_armoury_type(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
// Set CSW->CSA mapped weapon type to entity.
|
||||||
|
// params[1] = entity
|
||||||
|
// params[2] = CSW_* constant
|
||||||
|
|
||||||
|
// Valid entity should be within range.
|
||||||
|
CHECK_NONPLAYER(params[1]);
|
||||||
|
|
||||||
|
// Make into edict pointer.
|
||||||
|
edict_t *pArmoury = INDEXENT(params[1]);
|
||||||
|
|
||||||
|
// Make sure this is an armoury_entity.
|
||||||
|
if (strcmp(STRING(pArmoury->v.classname), "armoury_entity")) {
|
||||||
|
// Error out here.
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Not an armoury_entity! (%d)", params[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if PAWN_CELL_SIZE == 32
|
||||||
|
|
||||||
|
// We do a switch instead of a mapped array because this way we can nicely catch unexpected values, and we don't get array out of bounds thingies.
|
||||||
|
int weapontype;
|
||||||
|
switch (params[2]) {
|
||||||
|
case CSW_MP5NAVY: weapontype = CSA_MP5NAVY; break;
|
||||||
|
case CSW_TMP: weapontype = CSA_TMP; break;
|
||||||
|
case CSW_P90: weapontype = CSA_P90; break;
|
||||||
|
case CSW_MAC10: weapontype = CSA_MAC10; break;
|
||||||
|
case CSW_AK47: weapontype = CSA_AK47; break;
|
||||||
|
case CSW_SG552: weapontype = CSA_SG552; break;
|
||||||
|
case CSW_M4A1: weapontype = CSA_M4A1; break;
|
||||||
|
case CSW_AUG: weapontype = CSA_AUG; break;
|
||||||
|
case CSW_SCOUT: weapontype = CSA_SCOUT; break;
|
||||||
|
case CSW_G3SG1: weapontype = CSA_G3SG1; break;
|
||||||
|
case CSW_AWP: weapontype = CSA_AWP; break;
|
||||||
|
case CSW_M3: weapontype = CSA_M3; break;
|
||||||
|
case CSW_XM1014: weapontype = CSA_XM1014; break;
|
||||||
|
case CSW_M249: weapontype = CSA_M249; break;
|
||||||
|
case CSW_FLASHBANG: weapontype = CSA_FLASHBANG; break;
|
||||||
|
case CSW_HEGRENADE: weapontype = CSA_HEGRENADE; break;
|
||||||
|
case CSW_VEST: weapontype = CSA_VEST; break;
|
||||||
|
case CSW_VESTHELM: weapontype = CSA_VESTHELM; break;
|
||||||
|
case CSW_SMOKEGRENADE: weapontype = CSA_SMOKEGRENADE; break;
|
||||||
|
default:
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Unsupported weapon type! (%d)", params[2]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*((int *)pArmoury->pvPrivateData + OFFSET_ARMOURY_TYPE) = weapontype;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "This function not implemented on AMD64.");
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO cstrike_Exports[] = {
|
AMX_NATIVE_INFO cstrike_Exports[] = {
|
||||||
{"cs_set_user_money", cs_set_user_money},
|
{"cs_set_user_money", cs_set_user_money},
|
||||||
{"cs_get_user_money", cs_get_user_money},
|
{"cs_get_user_money", cs_get_user_money},
|
||||||
@ -1274,6 +1388,8 @@ AMX_NATIVE_INFO cstrike_Exports[] = {
|
|||||||
{"cs_set_user_armor", cs_set_user_armor},
|
{"cs_set_user_armor", cs_set_user_armor},
|
||||||
{"cs_get_user_shield", cs_get_user_shield},
|
{"cs_get_user_shield", cs_get_user_shield},
|
||||||
{"cs_user_spawn", cs_user_spawn},
|
{"cs_user_spawn", cs_user_spawn},
|
||||||
|
{"cs_get_armoury_type", cs_get_armoury_type},
|
||||||
|
{"cs_set_armoury_type", cs_set_armoury_type},
|
||||||
//------------------- <-- max 19 characters!
|
//------------------- <-- max 19 characters!
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -102,6 +102,8 @@
|
|||||||
// "hostage_entity" entities
|
// "hostage_entity" entities
|
||||||
#define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET
|
#define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET
|
||||||
#define OFFSET_HOSTAGEID 487 + EXTRAOFFSET
|
#define OFFSET_HOSTAGEID 487 + EXTRAOFFSET
|
||||||
|
// "armoury_entity"
|
||||||
|
#define OFFSET_ARMOURY_TYPE 34 + EXTRAOFFSET
|
||||||
#else
|
#else
|
||||||
// Amd64 offsets here
|
// Amd64 offsets here
|
||||||
#define OFFSET_ARMORTYPE 137 + EXTRAOFFSET
|
#define OFFSET_ARMORTYPE 137 + EXTRAOFFSET
|
||||||
@ -174,6 +176,29 @@
|
|||||||
#define CSW_AK47 28
|
#define CSW_AK47 28
|
||||||
//#define CSW_KNIFE 29
|
//#define CSW_KNIFE 29
|
||||||
#define CSW_P90 30
|
#define CSW_P90 30
|
||||||
|
#define CSW_VEST 31 // Brand new invention!
|
||||||
|
#define CSW_VESTHELM 32 // Brand new invention!
|
||||||
|
|
||||||
|
// These are used with armoury_entity:s.
|
||||||
|
#define CSA_MP5NAVY 0
|
||||||
|
#define CSA_TMP 1
|
||||||
|
#define CSA_P90 2
|
||||||
|
#define CSA_MAC10 3
|
||||||
|
#define CSA_AK47 4
|
||||||
|
#define CSA_SG552 5
|
||||||
|
#define CSA_M4A1 6
|
||||||
|
#define CSA_AUG 7
|
||||||
|
#define CSA_SCOUT 8
|
||||||
|
#define CSA_G3SG1 9
|
||||||
|
#define CSA_AWP 10
|
||||||
|
#define CSA_M3 11
|
||||||
|
#define CSA_XM1014 12
|
||||||
|
#define CSA_M249 13
|
||||||
|
#define CSA_FLASHBANG 14
|
||||||
|
#define CSA_HEGRENADE 15
|
||||||
|
#define CSA_VEST 16
|
||||||
|
#define CSA_VESTHELM 17
|
||||||
|
#define CSA_SMOKEGRENADE 18
|
||||||
|
|
||||||
#define M4A1_SILENCED (1<<2)
|
#define M4A1_SILENCED (1<<2)
|
||||||
#define M4A1_ATTACHSILENCEANIM 6
|
#define M4A1_ATTACHSILENCEANIM 6
|
||||||
@ -276,3 +301,4 @@ bool g_noknives = false;
|
|||||||
|
|
||||||
#define GETEDICT(n) \
|
#define GETEDICT(n) \
|
||||||
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
|
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "CStrike"
|
#define MODULE_NAME "CStrike"
|
||||||
#define MODULE_VERSION "1.50"
|
#define MODULE_VERSION "1.60"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org"
|
#define MODULE_URL "http://www.amxmodx.org"
|
||||||
#define MODULE_LOGTAG "CSTRIKE"
|
#define MODULE_LOGTAG "CSTRIKE"
|
||||||
@ -460,3 +460,4 @@
|
|||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
#endif // __MODULECONFIG_H__
|
#endif // __MODULECONFIG_H__
|
||||||
|
|
||||||
|
@ -308,3 +308,4 @@ void RankSystem::saveRank( const char* filename )
|
|||||||
|
|
||||||
fclose(bfp);
|
fclose(bfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,3 +120,4 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ MM_ROOT = ../../../metamod/metamod
|
|||||||
|
|
||||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||||
|
|
||||||
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
|
OPT_FLAGS = -O3 -funroll-loops -s -pipe -fomit-frame-pointer
|
||||||
DEBUG_FLAGS = -g -ggdb3
|
DEBUG_FLAGS = -g -ggdb3
|
||||||
CPP = gcc
|
CPP = gcc
|
||||||
NAME = csx_amxx
|
NAME = csx_amxx
|
||||||
@ -26,12 +26,11 @@ else
|
|||||||
CFLAGS = $(OPT_FLAGS)
|
CFLAGS = $(OPT_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H
|
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H -static-libgcc -fno-rtti
|
||||||
|
|
||||||
ifeq "$(AMD64)" "true"
|
ifeq "$(AMD64)" "true"
|
||||||
BINARY = $(NAME)_amd64.so
|
BINARY = $(NAME)_amd64.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
||||||
LINK += -lstdc++
|
|
||||||
else
|
else
|
||||||
BINARY = $(NAME)_i386.so
|
BINARY = $(NAME)_i386.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
||||||
|
@ -45,8 +45,6 @@
|
|||||||
enginefuncs_t g_engfuncs;
|
enginefuncs_t g_engfuncs;
|
||||||
globalvars_t *gpGlobals;
|
globalvars_t *gpGlobals;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_FUNCTIONS *g_pFunctionTable;
|
DLL_FUNCTIONS *g_pFunctionTable;
|
||||||
DLL_FUNCTIONS *g_pFunctionTable_Post;
|
DLL_FUNCTIONS *g_pFunctionTable_Post;
|
||||||
enginefuncs_t *g_pengfuncsTable;
|
enginefuncs_t *g_pengfuncsTable;
|
||||||
@ -54,7 +52,6 @@ enginefuncs_t *g_pengfuncsTable_Post;
|
|||||||
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
|
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
|
||||||
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
|
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
|
||||||
|
|
||||||
|
|
||||||
// GetEntityAPI2 functions
|
// GetEntityAPI2 functions
|
||||||
static DLL_FUNCTIONS g_EntityAPI_Table =
|
static DLL_FUNCTIONS g_EntityAPI_Table =
|
||||||
{
|
{
|
||||||
@ -2481,9 +2478,11 @@ PFN_IS_PLAYER_CONNECTING g_fn_IsPlayerConnecting;
|
|||||||
PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
||||||
PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||||
PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
PFN_ALLOCATOR g_fn_Allocator;
|
PFN_ALLOCATOR g_fn_Allocator;
|
||||||
PFN_REALLOCATOR g_fn_Reallocator;
|
PFN_REALLOCATOR g_fn_Reallocator;
|
||||||
PFN_DEALLOCATOR g_fn_Deallocator;
|
PFN_DEALLOCATOR g_fn_Deallocator;
|
||||||
|
#endif
|
||||||
PFN_AMX_EXEC g_fn_AmxExec;
|
PFN_AMX_EXEC g_fn_AmxExec;
|
||||||
PFN_AMX_EXECV g_fn_AmxExecv;
|
PFN_AMX_EXECV g_fn_AmxExecv;
|
||||||
PFN_AMX_ALLOT g_fn_AmxAllot;
|
PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||||
@ -2613,10 +2612,12 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||||||
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
|
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
|
||||||
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
|
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
// Memory
|
// Memory
|
||||||
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
|
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
|
||||||
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
||||||
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
||||||
|
#endif
|
||||||
|
|
||||||
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
||||||
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
||||||
@ -2735,6 +2736,8 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
|
|
||||||
/************* MEMORY *************/
|
/************* MEMORY *************/
|
||||||
// undef all defined macros
|
// undef all defined macros
|
||||||
#undef new
|
#undef new
|
||||||
@ -2906,6 +2909,30 @@ void operator delete[](void *reportedAddress)
|
|||||||
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
|
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if !defined NO_ALLOC_OVERRIDES && !defined MEMORY_TEST && !defined WIN32
|
||||||
|
void * ::operator new(size_t size) {
|
||||||
|
return(calloc(1, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void * ::operator new[](size_t size) {
|
||||||
|
return(calloc(1, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ::operator delete(void * ptr) {
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ::operator delete[](void * ptr) {
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
/************* stuff from dlls/util.cpp *************/
|
/************* stuff from dlls/util.cpp *************/
|
||||||
// must come here because cbase.h declares it's own operator new
|
// must come here because cbase.h declares it's own operator new
|
||||||
|
|
||||||
|
@ -46,8 +46,6 @@ struct amxx_module_info_s
|
|||||||
const char *logtag; // added in version 2
|
const char *logtag; // added in version 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// return values from functions called by amxx
|
// return values from functions called by amxx
|
||||||
#define AMXX_OK 0 /* no error */
|
#define AMXX_OK 0 /* no error */
|
||||||
#define AMXX_IFVERS 1 /* interface version */
|
#define AMXX_IFVERS 1 /* interface version */
|
||||||
@ -1981,12 +1979,14 @@ typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
|||||||
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const size_t /*size*/);
|
const unsigned int /*type*/, const size_t /*size*/);
|
||||||
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
|
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
|
||||||
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const void* /*addr*/ );
|
const unsigned int /*type*/, const void* /*addr*/ );
|
||||||
|
#endif
|
||||||
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/);
|
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/);
|
||||||
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
|
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
|
||||||
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
|
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
|
||||||
@ -2048,7 +2048,6 @@ extern PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
|||||||
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||||
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||||
extern PFN_AMX_EXEC g_fn_AmxExec;
|
extern PFN_AMX_EXEC g_fn_AmxExec;
|
||||||
extern PFN_AMX_EXECV g_fn_AmxExecv;
|
|
||||||
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||||
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
||||||
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
||||||
@ -2193,6 +2192,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
|
|||||||
#define MF_RequestFunction g_fn_RequestFunction;
|
#define MF_RequestFunction g_fn_RequestFunction;
|
||||||
#define MF_AmxPush g_fn_AmxPush
|
#define MF_AmxPush g_fn_AmxPush
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
/*** Memory ***/
|
/*** Memory ***/
|
||||||
void *operator new(size_t reportedSize);
|
void *operator new(size_t reportedSize);
|
||||||
void *operator new[](size_t reportedSize);
|
void *operator new[](size_t reportedSize);
|
||||||
@ -2236,4 +2236,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
|
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
|
||||||
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
|
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
|
||||||
|
|
||||||
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "CSX"
|
#define MODULE_NAME "CSX"
|
||||||
#define MODULE_VERSION "1.50"
|
#define MODULE_VERSION "1.60"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org/"
|
#define MODULE_URL "http://www.amxmodx.org/"
|
||||||
#define MODULE_LOGTAG "CSX"
|
#define MODULE_LOGTAG "CSX"
|
||||||
@ -460,3 +460,4 @@
|
|||||||
#endif // USE_METAMOD
|
#endif // USE_METAMOD
|
||||||
|
|
||||||
#endif // __MODULECONFIG_H__
|
#endif // __MODULECONFIG_H__
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls"
|
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;csx_EXPORTS;JIT"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;csx_EXPORTS;JIT"
|
||||||
StringPooling="TRUE"
|
StringPooling="TRUE"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="4"
|
||||||
StructMemberAlignment="3"
|
StructMemberAlignment="0"
|
||||||
EnableFunctionLevelLinking="TRUE"
|
EnableFunctionLevelLinking="FALSE"
|
||||||
UsePrecompiledHeader="2"
|
UsePrecompiledHeader="2"
|
||||||
PrecompiledHeaderFile=".\release/csx.pch"
|
PrecompiledHeaderFile=".\release/csx.pch"
|
||||||
AssemblerListingLocation=".\release/"
|
AssemblerListingLocation=".\release/"
|
||||||
@ -91,7 +91,7 @@
|
|||||||
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls,..\..\hlsdk\sourcecode\pm_shared"
|
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls,..\..\hlsdk\sourcecode\pm_shared"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;csx_EXPORTS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;csx_EXPORTS"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="5"
|
||||||
UsePrecompiledHeader="2"
|
UsePrecompiledHeader="2"
|
||||||
PrecompiledHeaderFile=".\debug/csx.pch"
|
PrecompiledHeaderFile=".\debug/csx.pch"
|
||||||
AssemblerListingLocation=".\debug/"
|
AssemblerListingLocation=".\debug/"
|
||||||
|
@ -6,7 +6,7 @@ MM_ROOT = ../../../metamod/metamod
|
|||||||
|
|
||||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||||
|
|
||||||
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
|
OPT_FLAGS = -O3 -funroll-loops -s -pipe
|
||||||
DEBUG_FLAGS = -g -ggdb3
|
DEBUG_FLAGS = -g -ggdb3
|
||||||
CPP = gcc
|
CPP = gcc
|
||||||
NAME = dodfun_amxx
|
NAME = dodfun_amxx
|
||||||
@ -26,12 +26,11 @@ else
|
|||||||
CFLAGS = $(OPT_FLAGS)
|
CFLAGS = $(OPT_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H
|
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H -static-libgcc -fno-rtti
|
||||||
|
|
||||||
ifeq "$(AMD64)" "true"
|
ifeq "$(AMD64)" "true"
|
||||||
BINARY = $(NAME)_amd64.so
|
BINARY = $(NAME)_amd64.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
||||||
LINK += -lstdc++
|
|
||||||
else
|
else
|
||||||
BINARY = $(NAME)_i386.so
|
BINARY = $(NAME)_i386.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
||||||
|
@ -45,8 +45,6 @@
|
|||||||
enginefuncs_t g_engfuncs;
|
enginefuncs_t g_engfuncs;
|
||||||
globalvars_t *gpGlobals;
|
globalvars_t *gpGlobals;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DLL_FUNCTIONS *g_pFunctionTable;
|
DLL_FUNCTIONS *g_pFunctionTable;
|
||||||
DLL_FUNCTIONS *g_pFunctionTable_Post;
|
DLL_FUNCTIONS *g_pFunctionTable_Post;
|
||||||
enginefuncs_t *g_pengfuncsTable;
|
enginefuncs_t *g_pengfuncsTable;
|
||||||
@ -54,7 +52,6 @@ enginefuncs_t *g_pengfuncsTable_Post;
|
|||||||
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
|
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
|
||||||
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
|
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
|
||||||
|
|
||||||
|
|
||||||
// GetEntityAPI2 functions
|
// GetEntityAPI2 functions
|
||||||
static DLL_FUNCTIONS g_EntityAPI_Table =
|
static DLL_FUNCTIONS g_EntityAPI_Table =
|
||||||
{
|
{
|
||||||
@ -2481,9 +2478,11 @@ PFN_IS_PLAYER_CONNECTING g_fn_IsPlayerConnecting;
|
|||||||
PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
||||||
PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||||
PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
PFN_ALLOCATOR g_fn_Allocator;
|
PFN_ALLOCATOR g_fn_Allocator;
|
||||||
PFN_REALLOCATOR g_fn_Reallocator;
|
PFN_REALLOCATOR g_fn_Reallocator;
|
||||||
PFN_DEALLOCATOR g_fn_Deallocator;
|
PFN_DEALLOCATOR g_fn_Deallocator;
|
||||||
|
#endif
|
||||||
PFN_AMX_EXEC g_fn_AmxExec;
|
PFN_AMX_EXEC g_fn_AmxExec;
|
||||||
PFN_AMX_EXECV g_fn_AmxExecv;
|
PFN_AMX_EXECV g_fn_AmxExecv;
|
||||||
PFN_AMX_ALLOT g_fn_AmxAllot;
|
PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||||
@ -2502,6 +2501,7 @@ PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
|
|||||||
PFN_FORMAT g_fn_Format;
|
PFN_FORMAT g_fn_Format;
|
||||||
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
||||||
PFN_REQ_FNPTR g_fn_RequestFunction;
|
PFN_REQ_FNPTR g_fn_RequestFunction;
|
||||||
|
PFN_AMX_PUSH g_fn_AmxPush;
|
||||||
|
|
||||||
// *** Exports ***
|
// *** Exports ***
|
||||||
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
||||||
@ -2610,11 +2610,14 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||||||
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
|
REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH);
|
||||||
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
|
REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS);
|
||||||
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
|
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
|
||||||
|
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
// Memory
|
// Memory
|
||||||
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
|
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
|
||||||
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
||||||
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
||||||
|
#endif
|
||||||
|
|
||||||
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
||||||
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
||||||
@ -2717,7 +2720,7 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
MF_IsPlayerHLTV(0);
|
MF_IsPlayerHLTV(0);
|
||||||
MF_GetPlayerArmor(0);
|
MF_GetPlayerArmor(0);
|
||||||
MF_GetPlayerHealth(0);
|
MF_GetPlayerHealth(0);
|
||||||
MF_AmxExec(0, 0, 0, 0);
|
MF_AmxExec(0, 0, 0);
|
||||||
MF_AmxExecv(0, 0, 0, 0, 0);
|
MF_AmxExecv(0, 0, 0, 0, 0);
|
||||||
MF_AmxFindPublic(0, 0, 0);
|
MF_AmxFindPublic(0, 0, 0);
|
||||||
MF_AmxAllot(0, 0, 0, 0);
|
MF_AmxAllot(0, 0, 0, 0);
|
||||||
@ -2733,6 +2736,8 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
|
|
||||||
/************* MEMORY *************/
|
/************* MEMORY *************/
|
||||||
// undef all defined macros
|
// undef all defined macros
|
||||||
#undef new
|
#undef new
|
||||||
@ -2904,6 +2909,30 @@ void operator delete[](void *reportedAddress)
|
|||||||
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
|
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if !defined NO_ALLOC_OVERRIDES && !defined MEMORY_TEST && !defined WIN32
|
||||||
|
void * ::operator new(size_t size) {
|
||||||
|
return(calloc(1, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void * ::operator new[](size_t size) {
|
||||||
|
return(calloc(1, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ::operator delete(void * ptr) {
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ::operator delete[](void * ptr) {
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
/************* stuff from dlls/util.cpp *************/
|
/************* stuff from dlls/util.cpp *************/
|
||||||
// must come here because cbase.h declares it's own operator new
|
// must come here because cbase.h declares it's own operator new
|
||||||
|
|
||||||
|
@ -46,8 +46,6 @@ struct amxx_module_info_s
|
|||||||
const char *logtag; // added in version 2
|
const char *logtag; // added in version 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// return values from functions called by amxx
|
// return values from functions called by amxx
|
||||||
#define AMXX_OK 0 /* no error */
|
#define AMXX_OK 0 /* no error */
|
||||||
#define AMXX_IFVERS 1 /* interface version */
|
#define AMXX_IFVERS 1 /* interface version */
|
||||||
@ -1981,13 +1979,15 @@ typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
|||||||
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const size_t /*size*/);
|
const unsigned int /*type*/, const size_t /*size*/);
|
||||||
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
|
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
|
||||||
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
|
||||||
const unsigned int /*type*/, const void* /*addr*/ );
|
const unsigned int /*type*/, const void* /*addr*/ );
|
||||||
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, ... /*params*/);
|
#endif
|
||||||
|
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/);
|
||||||
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
|
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
|
||||||
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
|
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
|
||||||
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
|
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
|
||||||
@ -2002,6 +2002,7 @@ typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
|
|||||||
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
|
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
|
||||||
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
|
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
|
||||||
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
|
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
|
||||||
|
typedef int (*PFN_AMX_PUSH) (AMX * /*amx*/, cell /*value*/);
|
||||||
|
|
||||||
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
||||||
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
||||||
@ -2047,7 +2048,6 @@ extern PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
|||||||
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||||
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||||
extern PFN_AMX_EXEC g_fn_AmxExec;
|
extern PFN_AMX_EXEC g_fn_AmxExec;
|
||||||
extern PFN_AMX_EXECV g_fn_AmxExecv;
|
|
||||||
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||||
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
||||||
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
||||||
@ -2065,6 +2065,7 @@ extern PFN_FORMAT g_fn_Format;
|
|||||||
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
|
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
|
||||||
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
|
||||||
extern PFN_REQ_FNPTR g_fn_RequestFunction;
|
extern PFN_REQ_FNPTR g_fn_RequestFunction;
|
||||||
|
extern PFN_AMX_PUSH g_fn_AmxPush;
|
||||||
|
|
||||||
#ifdef MAY_NEVER_BE_DEFINED
|
#ifdef MAY_NEVER_BE_DEFINED
|
||||||
// Function prototypes for intellisense and similar systems
|
// Function prototypes for intellisense and similar systems
|
||||||
@ -2123,6 +2124,8 @@ edict_t* MF_GetPlayerEdict (int id) { }
|
|||||||
const char * MF_Format (const char *fmt, ...) { }
|
const char * MF_Format (const char *fmt, ...) { }
|
||||||
void MF_RegisterFunction (void *pfn, const char *description) { }
|
void MF_RegisterFunction (void *pfn, const char *description) { }
|
||||||
void * MF_RequestFunction (const char *description) { }
|
void * MF_RequestFunction (const char *description) { }
|
||||||
|
int MF_AmxPush (AMX *amx, cell *params) { }
|
||||||
|
int MF_AmxExec (AMX *amx, cell *retval, int idx) { }
|
||||||
#endif // MAY_NEVER_BE_DEFINED
|
#endif // MAY_NEVER_BE_DEFINED
|
||||||
|
|
||||||
#define MF_AddNatives g_fn_AddNatives
|
#define MF_AddNatives g_fn_AddNatives
|
||||||
@ -2187,7 +2190,9 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
|
|||||||
#define MF_Format g_fn_Format
|
#define MF_Format g_fn_Format
|
||||||
#define MF_RegisterFunction g_fn_RegisterFunction
|
#define MF_RegisterFunction g_fn_RegisterFunction
|
||||||
#define MF_RequestFunction g_fn_RequestFunction;
|
#define MF_RequestFunction g_fn_RequestFunction;
|
||||||
|
#define MF_AmxPush g_fn_AmxPush
|
||||||
|
|
||||||
|
#ifdef MEMORY_TEST
|
||||||
/*** Memory ***/
|
/*** Memory ***/
|
||||||
void *operator new(size_t reportedSize);
|
void *operator new(size_t reportedSize);
|
||||||
void *operator new[](size_t reportedSize);
|
void *operator new[](size_t reportedSize);
|
||||||
@ -2231,4 +2236,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
|||||||
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
|
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
|
||||||
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
|
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
|
||||||
|
|
||||||
|
#endif //MEMORY_TEST
|
||||||
|
|
||||||
#endif // #ifndef __AMXXMODULE_H__
|
#endif // #ifndef __AMXXMODULE_H__
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
// Module info
|
// Module info
|
||||||
#define MODULE_NAME "DoD Fun"
|
#define MODULE_NAME "DoD Fun"
|
||||||
#define MODULE_VERSION "1.50"
|
#define MODULE_VERSION "1.60"
|
||||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||||
#define MODULE_URL "http://www.amxmodx.org"
|
#define MODULE_URL "http://www.amxmodx.org"
|
||||||
#define MODULE_LOGTAG "DODFUN"
|
#define MODULE_LOGTAG "DODFUN"
|
||||||
|
@ -6,7 +6,7 @@ MM_ROOT = ../../../metamod/metamod
|
|||||||
|
|
||||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||||
|
|
||||||
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
|
OPT_FLAGS = -O3 -funroll-loops -s -pipe
|
||||||
DEBUG_FLAGS = -g -ggdb3
|
DEBUG_FLAGS = -g -ggdb3
|
||||||
CPP = gcc
|
CPP = gcc
|
||||||
NAME = dodx_amxx
|
NAME = dodx_amxx
|
||||||
@ -26,12 +26,11 @@ else
|
|||||||
CFLAGS = $(OPT_FLAGS)
|
CFLAGS = $(OPT_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H
|
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H -static-libgcc -fno-rtti
|
||||||
|
|
||||||
ifeq "$(AMD64)" "true"
|
ifeq "$(AMD64)" "true"
|
||||||
BINARY = $(NAME)_amd64.so
|
BINARY = $(NAME)_amd64.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
||||||
LINK += -lstdc++
|
|
||||||
else
|
else
|
||||||
BINARY = $(NAME)_i386.so
|
BINARY = $(NAME)_i386.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user