cleaned-up versions of header files

This commit is contained in:
Borja Ferrer 2005-09-10 00:38:42 +00:00
parent fc955009da
commit e67457440d
16 changed files with 445 additions and 381 deletions

View File

@ -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
@ -130,7 +132,7 @@ private:
int m_ParsePos; // is args. num. - 1 int m_ParsePos; // is args. num. - 1
float* m_Timer; float* m_Timer;
ClEvent* getValidEvent(ClEvent* a ); ClEvent* getValidEvent(ClEvent* a);
int m_CurrentMsgType; int m_CurrentMsgType;
public: public:
@ -150,10 +152,8 @@ public:
int getArgInteger(int a) const; int getArgInteger(int a) const;
float getArgFloat(int a) const; float getArgFloat(int a) const;
void clearEvents(void); void clearEvents(void);
static int getEventId( const char* msg ); static int getEventId(const char* msg);
int getCurrentMsgType(); int getCurrentMsgType();
}; };
#endif // #ifdef __CEVENTS_H__ #endif //__CEVENTS_H__

View File

@ -41,18 +41,15 @@ class File
FILE* fp; FILE* fp;
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();
}; };

View File

@ -88,31 +88,38 @@ 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];
} }
}; };
@ -126,6 +133,7 @@ class CSPForward
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 +142,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];
} }
}; };
@ -186,8 +198,7 @@ public:
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 +213,5 @@ 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

View File

@ -79,6 +79,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 +92,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
{ {
@ -145,7 +146,7 @@ class CLangMngr
// Merge definitions into a language // Merge definitions into a language
void MergeDefinitions(const char *lang, CQueue <sKeyDef*> &tmpVec); void MergeDefinitions(const char *lang, CQueue <sKeyDef*> &tmpVec);
// strip lowercase; make lower if needed // strip lowercase; make lower if needed
static size_t strip(char *str, char *newstr, bool makelower=false); static size_t strip(char *str, char *newstr, bool makelower = false);
typedef CVector<CLang*> LangVec; typedef CVector<CLang*> LangVec;
typedef CVector<CLang*>::iterator LangVecIter; typedef CVector<CLang*>::iterator LangVecIter;

View File

@ -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
@ -162,6 +163,7 @@ public:
{ {
iterator tmp(*this); iterator tmp(*this);
m_CurPos = m_CurPos->next; m_CurPos = m_CurPos->next;
return tmp; return tmp;
} }
@ -176,6 +178,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 +190,7 @@ public:
m_pHead = NULL; m_pHead = NULL;
m_pTail = NULL; m_pTail = NULL;
} }
~CList<T,F>() ~CList<T,F>()
{ {
clear(); clear();
@ -198,12 +202,15 @@ 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 +219,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 +264,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 +274,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 +298,7 @@ public:
break; break;
++iter; ++iter;
} }
return iter; return iter;
} }
@ -300,14 +310,16 @@ public:
int size() int size()
{ {
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

View File

@ -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;
@ -69,97 +68,101 @@ public:
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();
public: public:
inline CPluginMngr::CPlugin *getPlugin() { return plugin; } inline CPluginMngr::CPlugin *getPlugin() { return plugin; }
void registerFilter( char* filter ); void registerFilter(char* filter);
inline int getFunction() { return func; } inline int getFunction() { return func; }
}; };
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++() {
a = b->getValidLogEvent( a->next ); inline iterator& operator++()
{
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 end() { return iterator(0,this); } inline iterator begin() { return iterator(getValidLogEvent(logevents[logArgc]), this); }
inline iterator end() { return iterator(0, this); }
}; };
#endif #endif //LOGEVENTS_H

View File

@ -45,15 +45,17 @@ class MenuMngr
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
@ -66,27 +68,26 @@ private:
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:
inline int getFunction() { return function; } inline int getFunction() { return function; }
inline CPluginMngr::CPlugin* getPlugin() { return plugin; } inline CPluginMngr::CPlugin* getPlugin() { return plugin; }
inline bool matchCommand( int m, int k ) { return ((m == menuid) && (keys & k)); } inline bool matchCommand(int m, int k) { return ((m == menuid) && (keys & k)); }
} *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 +97,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

View File

@ -37,27 +37,28 @@
// ***************************************************** // *****************************************************
// 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
// ***************************************************** // *****************************************************
@ -89,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];
@ -117,17 +119,20 @@ public:
CQueue<ClientCvarQuery_Info*> cvarQueryQueue; 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);
inline bool IsBot(){ bool Connect(const char* connectname, const char* ipaddress);
return ((pEdict->v.flags & FL_FAKECLIENT)?true:false);
inline bool IsBot()
{
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));
} }
inline void Authorize() { authorized = true; } inline void Authorize() { authorized = true; }
@ -149,27 +154,29 @@ 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();
}; };
// ***************************************************** // *****************************************************
// 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; }
@ -183,7 +190,8 @@ public:
class XVars class XVars
{ {
struct XVarEle { struct XVarEle
{
AMX* amx; AMX* amx;
cell* value; cell* value;
}; };
@ -191,22 +199,27 @@ class XVars
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 ) {
return ( a >= 0 && a < num ) ? *(head[a].value) : 0; inline cell getValue(int a)
{
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;
} }
}; };
@ -214,34 +227,41 @@ public:
// ***************************************************** // *****************************************************
// class CScript // class CScript
// ***************************************************** // *****************************************************
class CScript class CScript
{ {
String filename; String filename;
AMX* amx; AMX* amx;
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); }
inline void* getCode() { return code; } inline void* getCode() { return code; }
}; };
// ***************************************************** // *****************************************************
// 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;
int newTeam; int newTeam;
@ -249,15 +269,10 @@ 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

View File

@ -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 */
@ -84,12 +84,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; }
@ -97,7 +100,7 @@ public:
inline const char* getName() const { return m_InfoNew.name; } inline const char* getName() const { return m_InfoNew.name; }
inline const amxx_module_info_s* getInfoNew() const { return &m_InfoNew; } // new inline const amxx_module_info_s* getInfoNew() const { return &m_InfoNew; } // new
inline int getStatusValue() { return m_Status; } inline int getStatusValue() { return m_Status; }
inline bool operator==( const char* fname ) { return !strcmp( m_Filename.c_str() , fname ); } inline bool operator==(const char* fname) { return !strcmp(m_Filename.c_str(), fname); }
inline bool isReloadable() { return ((m_Status == MODULE_LOADED) && (m_InfoNew.reload != 0)); } inline bool isReloadable() { return ((m_Status == MODULE_LOADED) && (m_InfoNew.reload != 0)); }
inline bool isAmxx() const { return m_Amxx; } inline bool isAmxx() const { return m_Amxx; }
inline const char *getMissingFunc() const { return m_MissingFunc; } inline const char *getMissingFunc() const { return m_MissingFunc; }
@ -108,7 +111,4 @@ public:
CList<AMX_NATIVE_INFO*> m_Natives; CList<AMX_NATIVE_INFO*> m_Natives;
}; };
#endif #endif //CMODULE_H

View File

@ -36,7 +36,8 @@
// class CPluginMngr // class CPluginMngr
// ***************************************************** // *****************************************************
enum { enum
{
ps_bad_load, ps_bad_load,
ps_error, ps_error,
ps_locked, ps_locked,
@ -47,7 +48,6 @@ enum {
class CPluginMngr class CPluginMngr
{ {
public: public:
class iterator; class iterator;
@ -70,12 +70,10 @@ public:
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();}
@ -85,19 +83,19 @@ public:
inline int getId() const { return id; } inline int getId() const { return id; }
inline AMX* getAMX() { return &amx; } inline AMX* getAMX() { return &amx; }
inline const AMX* getAMX() const { return &amx; } inline const AMX* getAMX() const { return &amx; }
inline void setTitle( const char* n ) { title.assign(n); } inline void setTitle(const char* n) { title.assign(n); }
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_paused); } inline bool isValid() const { return (status >= ps_paused); }
inline bool isPaused() const { return ( (status == ps_paused) || (status == ps_stopped) ); } inline bool isPaused() const { return ((status == ps_paused) || (status == ps_stopped)); }
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; }
}; };
@ -105,8 +103,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(); }
@ -117,8 +113,8 @@ public:
// Interface // Interface
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);
@ -127,7 +123,8 @@ public:
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) {}
@ -137,10 +134,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

View File

@ -43,27 +43,32 @@ 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);
} }
void push(const T & v) void push(const T & v)
@ -98,4 +103,3 @@ private:
}; };
#endif //_INCLUDE_CQUEUE_H #endif //_INCLUDE_CQUEUE_H

View File

@ -91,8 +91,7 @@ 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) &&
(right.m_pAmx ? left.getPlugin()->getAMX() == right.m_pAmx : true) &&
left.getTaskId() == right.m_iId; left.getTaskId() == right.m_iId;
} }
}; };
@ -117,6 +116,4 @@ public:
void clear(); void clear();
}; };
#endif #endif //CTASK_H

View File

@ -47,12 +47,12 @@ class Vault
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);
} *head; } *head;
String path; String path;
Obj** find( const char* n ); Obj** find(const char* n);
public: public:
@ -61,22 +61,22 @@ 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) {}
iterator& operator++() { if ( a ) a = a->next; return *this; } iterator& operator++() { if (a) a = a->next; return *this; }
bool operator==(const iterator& b) const { return a == b.a; } bool operator==(const iterator& b) const { return a == b.a; }
bool operator!=(const iterator& b) const { return !operator==(b); } bool operator!=(const iterator& b) const { return !operator==(b); }
String& key() const { return a->key; } String& key() const { return a->key; }
@ -87,7 +87,4 @@ public:
inline iterator end() const { return iterator(0); } inline iterator end() const { return iterator(0); }
}; };
#endif #endif //VAULT_CUSTOM_H

View File

@ -32,8 +32,8 @@
#define __FAKEMETA_H__ #define __FAKEMETA_H__
#ifndef FAKEMETA #ifndef FAKEMETA
int UnloadMetamodPlugin(void *handle); int UnloadMetamodPlugin(void *handle);
int LoadMetamodPlugin(const char *path, void **handle, PLUG_LOADTIME now); int LoadMetamodPlugin(const char *path, void **handle, PLUG_LOADTIME now);
#else #else
// Fake metamod api for modules // Fake metamod api for modules
@ -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__

View File

@ -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