Skip to content
This repository has been archived by the owner on Dec 27, 2020. It is now read-only.

Commit

Permalink
Add-on API 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RadWolfie committed Jan 9, 2014
1 parent 4a8fb13 commit d4a6706
Show file tree
Hide file tree
Showing 11 changed files with 290 additions and 315 deletions.
10 changes: 5 additions & 5 deletions Add-on API.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "database.h"
#include "object.h"
#include "player.h"
typedef toggle (WINAPIC *CmdFunc)(Player::PlayerInfo plI, util::ArgContainer arg,char chatRconRemote, short stage, LPVOID stack, bool* showChat);
typedef toggle (WINAPIC *CmdFunc)(IPlayer::PlayerInfo plI, util::ArgContainer arg,char chatRconRemote, short stage, LPVOID stack, bool* showChat);
#include "admin.h"
#include "command.h"

Expand Down Expand Up @@ -76,10 +76,10 @@ namespace addon {
}
extern "C" dllAPI addon::versionEAO EXTversion = {
sizeof(addon::versionEAO), //size
3, //requiredAPI (required)
3, //general (optional, set to 0 if not using)
1, //iniFile (optional, set to 0 if not using)
2, //database (optional, set to 0 if not using)
4, //requiredAPI (required)
4, //general (optional, set to 0 if not using)
2, //iniFile (optional, set to 0 if not using)
3, //database (optional, set to 0 if not using)
0, //external (optional, set to 0 if not using)
0, //reserved
0 }; //reserved
Expand Down
Binary file modified Add-on API.lib
Binary file not shown.
25 changes: 7 additions & 18 deletions admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@
#define LOGINFAIL 0
#define LOGINPASS 1

extern "C" class dllport Admin {
extern "C" class IAdmin {
public:
Admin();
~Admin();
Admin(Admin const &);
short unlimit;
bool reqUser;
bool reqAddr;
bool reqPort;
bool reqLoginAddr;
bool reqLoginPort;
bool reqRemoteAddr;
bool reqRemotePort;
toggle WINAPIC isPlayerAuthorized(Player::PlayerInfo* plI, wchar_t* cmd, util::ArgContainer* arg, CmdFunc* func);
toggle WINAPIC UsernameExist(wchar_t username[]);
toggle WINAPIC Add(wchar_t hashW[], wchar_t IP_Addr[], wchar_t IP_Port[], wchar_t username[],wchar_t password[],short level,bool remote, bool pass_force);
toggle WINAPIC Del(wchar_t username[]);
toggle WINAPIC Login(Player::PlayerInfo& plI, char chatRconRemote, wchar_t user[], wchar_t pass[]);
virtual toggle WINAPIC isPlayerAuthorized(IPlayer::PlayerInfo* plI, const wchar_t* cmd, util::ArgContainer* arg, CmdFunc* func)=0;
virtual toggle WINAPIC UsernameExist(wchar_t username[])=0;
virtual toggle WINAPIC Add(wchar_t hashW[32], wchar_t IP_Addr[15], wchar_t IP_Port[6], wchar_t username[24],wchar_t password[],short level,bool remote, bool pass_force)=0;
virtual toggle WINAPIC Del(wchar_t username[24])=0;
virtual toggle WINAPIC Login(IPlayer::PlayerInfo& plI, char chatRconRemote, wchar_t user[], wchar_t pass[])=0;
};
extern "C" dllport Admin* admin;
extern "C" dllport IAdmin* pIAdmin;

#endif
16 changes: 7 additions & 9 deletions command.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ struct helpInfo {
wchar_t info[4][255];
};
#pragma pack(pop)
extern "C" class Command {
extern "C" class ICommand {
public:
Command();
~Command();
dllport bool WINAPIC Add(const wchar_t command[], CmdFunc func, const wchar_t section[], unsigned short min, unsigned short max, bool allowOverride, GAME_MODE_S mode);
dllport bool WINAPIC Del(CmdFunc func, const wchar_t funcName[]);
dllport bool WINAPIC ReloadLevel();
dllport bool WINAPIC AliasAdd(const wchar_t* command, const wchar_t* alias);
dllport bool WINAPIC AliasDel(const wchar_t* command, const wchar_t* alias);
virtual bool WINAPIC Add(const wchar_t command[], CmdFunc func, const wchar_t section[], unsigned short min, unsigned short max, bool allowOverride, GAME_MODE_S mode)=0;
virtual bool WINAPIC Del(CmdFunc func, const wchar_t funcName[])=0;
virtual bool WINAPIC ReloadLevel()=0;
virtual bool WINAPIC AliasAdd(const wchar_t* command, const wchar_t* alias)=0;
virtual bool WINAPIC AliasDel(const wchar_t* command, const wchar_t* alias)=0;
};
extern "C" dllport Command* command;
extern "C" dllport ICommand* pICommand;
#endif
90 changes: 35 additions & 55 deletions database.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef databaseH
#define databaseH

extern const char dbErrorConnectionLost[];

extern "C" namespace DBSQL {
//--
//#pragma comment(lib,"Msvcrt.lib") //Basically bypass the error of vsnprintf... Replace the odbccp32.lib file with vista SDK!!!
Expand All @@ -18,65 +16,47 @@ extern "C" namespace DBSQL {
#define IS_SQL_OK(res) (res==SQL_SUCCESS_WITH_INFO || res==SQL_SUCCESS)
#define SAFE_STR(str) ((str==NULL) ? _T("") : str)
//--
void EXTHookDatabaseEnabled();
void EXTHookDatabaseDisabled();
bool EXTIsHookDatabase();
void EXTUnloadDatabase();

class dllport DBConnection {

class IDBConnection {
public:
bool WINAPIC Connect(LPCWSTR MDBPath,LPCWSTR User=L"", LPCWSTR Pass=L"",bool Exclusive=0);
virtual bool WINAPIC Connect(LPCWSTR MDBPath,LPCWSTR User=L"", LPCWSTR Pass=L"",bool Exclusive=0)=0;
//bool Connect(LPCTSTR svSource);
DBConnection();
~DBConnection();
DBConnection& operator=(DBConnection const&);
void WINAPIC Disconnect();
void WINAPIC STMTStatus();
void WINAPIC Check();
SQLHDBC WINAPIC HDBC() {
return m_hDBC;
}
//static DBConnection& operator=(DBConnection const&);
virtual void WINAPIC Disconnect()=0;
virtual void WINAPIC STMTStatus()=0;
virtual void WINAPIC Check()=0;
virtual SQLHDBC WINAPIC HDBC()=0;
//static IDBConnection dllport WINAPIC getIDBConnection();
private:
SQLRETURN m_nReturn; // Internal SQL Error code
SQLHENV m_hEnv; // Handle to environment
SQLHDBC m_hDBC; // Handle to database connection
//IDBConnection();
//~IDBConnection();
};
/*extern "C" class MDBConnection {
};*/
class dllport DBStmt {
private:
SQLHSTMT m_hStmt;
int m_nStmt;
class IDBStmt {
public:
DBStmt();
~DBStmt();
DBStmt& operator=(DBStmt const&);
DBStmt(SQLHDBC hDBCLink);
bool WINAPIC IsValid();
USHORT WINAPIC GetColumnCount();
DWORD WINAPIC GetChangedRowCount();
bool WINAPIC Query(LPCWSTR strSQL);
bool WINAPIC Fetch();
bool WINAPIC FetchRow(UINT nRow);
bool WINAPIC FetchPrevious();
bool WINAPIC FetchNext();
bool WINAPIC FetchRow(ULONG nRow,bool Absolute=1);
bool WINAPIC FetchFirst();
bool WINAPIC FetchLast();
bool WINAPIC Cancel();
/*bool SetPos(SQLSETPOSIROW irow);
bool OpenCursor();
bool CloseCursor();*/
virtual void Release();
virtual bool WINAPIC IsValid()=0;
virtual USHORT WINAPIC GetColumnCount()=0;
virtual DWORD WINAPIC GetChangedRowCount()=0;
virtual bool WINAPIC Query(LPCWSTR strSQL)=0;
virtual bool WINAPIC Fetch()=0;
virtual bool WINAPIC FetchRow(UINT nRow)=0;
virtual bool WINAPIC FetchPrevious()=0;
virtual bool WINAPIC FetchNext()=0;
virtual bool WINAPIC FetchRow(ULONG nRow,bool Absolute=1)=0;
virtual bool WINAPIC FetchFirst()=0;
virtual bool WINAPIC FetchLast()=0;
virtual bool WINAPIC Cancel()=0;

bool WINAPIC BindColumn(USHORT Column, LPVOID pBuffer, ULONG pBufferSize, LONG * pReturnedBufferSize=NULL, USHORT nType=SQL_C_TCHAR);
USHORT WINAPIC GetColumnByName(LPCTSTR Column);
bool WINAPIC GetData(USHORT Column, LPVOID pBuffer, ULONG pBufLen, LONG * dataLen=NULL, int Type=SQL_C_DEFAULT);
int WINAPIC GetColumnType( USHORT Column );
DWORD WINAPIC GetColumnSize( USHORT Column );
DWORD WINAPIC GetColumnScale( USHORT Column );
bool WINAPIC GetColumnName( USHORT Column, LPTSTR Name, SHORT NameLen );
bool WINAPIC IsColumnNullable( USHORT Column );
virtual bool WINAPIC BindColumn(USHORT Column, LPVOID pBuffer, ULONG pBufferSize, LONG * pReturnedBufferSize=NULL, USHORT nType=SQL_C_TCHAR)=0;
virtual USHORT WINAPIC GetColumnByName(LPCTSTR Column)=0;
virtual bool WINAPIC GetData(USHORT Column, LPVOID pBuffer, ULONG pBufLen, LONG * dataLen=NULL, int Type=SQL_C_DEFAULT)=0;
virtual int WINAPIC GetColumnType( USHORT Column )=0;
virtual DWORD WINAPIC GetColumnSize( USHORT Column )=0;
virtual DWORD WINAPIC GetColumnScale( USHORT Column )=0;
virtual bool WINAPIC GetColumnName( USHORT Column, LPTSTR Name, SHORT NameLen )=0;
virtual bool WINAPIC IsColumnNullable( USHORT Column )=0;
};
dllport IDBConnection* WINAPIC getIDBConnection();
dllport IDBStmt* WINAPIC getIDBStmt();
};
extern "C" dllport DBSQL::DBConnection iDB;
#endif
102 changes: 51 additions & 51 deletions haloEngine.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#ifndef haloEngineH
#define haloEngineH

#define CANTJOINSERVER 0
#define INVALIDCONREQUEST 1
#define PASSWORDREJECTED 2
#define SERVERFULL 3
#define CDINVALID 4
#define CDINUSED 5
#define OPBANNED 6
#define OPKICKED 7
#define VIDEOTEST 8
#define CPSAVED 9
#define ADDRESSINVALID 10
#define PROFILEREQUIRED 11
#define INCOMPATIBLENETWORK 12
#define OLDERCVER 13
#define NEWERCVER 14
#define ADMINREQUIREDPATCH 15
#define REQUESTDELETESAVED 16
#define REJECT_CANTJOINSERVER 0
#define REJECT_INVALIDCONREQUEST 1
#define REJECT_PASSWORDREJECTED 2
#define REJECT_SERVERFULL 3
#define REJECT_CDINVALID 4
#define REJECT_CDINUSED 5
#define REJECT_OPBANNED 6
#define REJECT_OPKICKED 7
#define REJECT_VIDEOTEST 8
#define REJECT_CPSAVED 9
#define REJECT_ADDRESSINVALID 10
#define REJECT_PROFILEREQUIRED 11
#define REJECT_INCOMPATIBLENETWORK 12
#define REJECT_OLDERCVER 13
#define REJECT_NEWERCVER 14
#define REJECT_ADMINREQUIREDPATCH 15
#define REJECT_REQUESTDELETESAVED 16

#define HALO_UNKNOWN 0
#define HALO_TRIAL 1
Expand All @@ -40,7 +40,8 @@
#define DIRECTS8 IDirectSound
#endif

extern "C" class dllport HaloEngine { // For Add-on API interface support

extern "C" class IHaloEngine { // For Add-on API interface support
public:
GlobalServer* globalServer;
PlayerAlter* playerAlter;
Expand All @@ -58,42 +59,41 @@ extern "C" class dllport HaloEngine { // For Add-on API interface support
BYTE haloGameVersion;
bool isDedi;
ConsoleColorStruct* consoleColor;
DIRECTX9** DirectX9;
DIRECTI8** DirectInput8;
DIRECTS8** DirectSound8;
HaloEngine();
DIRECTX9* DirectX9;
DIRECTI8* DirectInput8;
DIRECTS8* DirectSound8;
//Halo Simulate Functions Begin
DWORD WINAPIC BuildPacket(LPBYTE output, DWORD arg1, DWORD packettype, DWORD arg3, LPBYTE dataPtr, DWORD arg4, DWORD arg5, DWORD arg6);
void WINAPIC AddPacketToPlayerQueue(DWORD player, LPBYTE packet, DWORD packetCode, DWORD arg1, DWORD arg2, DWORD arg3, DWORD arg4, DWORD arg5);
void WINAPIC AddPacketToGlobalQueue(LPBYTE packet, DWORD packetCode, DWORD arg1, DWORD arg2, DWORD arg3, DWORD arg4, DWORD arg5);
void WINAPIC DispatchRcon(rconData& d, Player::PlayerInfo& plI);
void WINAPIC DispatchPlayer(chatData& d, int len, Player::PlayerInfo& plI);
void WINAPIC DispatchGlobal(chatData& d, int len);
bool WINAPIC sendRejectCode(MachineHeader* mH, DWORD code);
void WINAPIC GetCDHash(MachineHeader &mH, char hashKey[33]);
void WINAPIC SetObjectSpawnPlayerX(playerindex pl_ind);
void WINAPIC Kill(Player::PlayerInfo plI);
bool WINAPIC SetIdle();
bool WINAPIC MapNext();
bool WINAPIC Exec(const char* cmd);
void WINAPIC GetServerPassword(wchar_t pass[8]);
void WINAPIC SetServerPassword(wchar_t pass[8]);
void WINAPIC GetRconPassword(char pass[8]);
void WINAPIC SetRconPassword(char pass[8]);
bool WINAPIC BanPlayer(Player::PlayerExtended &plEx, tm &gmtm);
bool WINAPIC BanCDkey(wchar_t CDHash[33], tm &gmtm);
bool WINAPIC BanIP(wchar_t IP_Addr[16], tm &gmtm);
int WINAPIC BanIPGetId(wchar_t IP_Addr[16]);
int WINAPIC BanCDkeyGetId(wchar_t CDHash[33]);
bool WINAPIC UnbanID(int ID);
virtual DWORD WINAPIC BuildPacket(LPBYTE output, DWORD arg1, DWORD packettype, DWORD arg3, LPBYTE dataPtr, DWORD arg4, DWORD arg5, DWORD arg6)=0;
virtual void WINAPIC AddPacketToPlayerQueue(DWORD player, LPBYTE packet, DWORD packetCode, DWORD arg1, DWORD arg2, DWORD arg3, DWORD arg4, DWORD arg5)=0;
virtual void WINAPIC AddPacketToGlobalQueue(LPBYTE packet, DWORD packetCode, DWORD arg1, DWORD arg2, DWORD arg3, DWORD arg4, DWORD arg5)=0;
virtual void WINAPIC DispatchRcon(rconData& d, IPlayer::PlayerInfo& plI)=0;
virtual void WINAPIC DispatchPlayer(chatData& d, int len, IPlayer::PlayerInfo& plI)=0;
virtual void WINAPIC DispatchGlobal(chatData& d, int len)=0;
virtual bool WINAPIC sendRejectCode(MachineHeader* mH, DWORD code)=0;
virtual void WINAPIC GetCDHash(MachineHeader &mH, char hashKey[33])=0;
virtual void WINAPIC SetObjectSpawnPlayerX(playerindex pl_ind)=0;
virtual void WINAPIC Kill(IPlayer::PlayerInfo plI)=0;
virtual bool WINAPIC SetIdle()=0;
virtual bool WINAPIC MapNext()=0;
virtual bool WINAPIC Exec(const char* cmd)=0;
virtual void WINAPIC GetServerPassword(wchar_t pass[8])=0;
virtual void WINAPIC SetServerPassword(wchar_t pass[8])=0;
virtual void WINAPIC GetRconPassword(char pass[8])=0;
virtual void WINAPIC SetRconPassword(char pass[8])=0;
virtual bool WINAPIC BanPlayer(IPlayer::PlayerExtended &plEx, tm &gmtm)=0;
virtual bool WINAPIC BanCDkey(wchar_t CDHash[33], tm &gmtm)=0;
virtual bool WINAPIC BanIP(wchar_t IP_Addr[16], tm &gmtm)=0;
virtual int WINAPIC BanIPGetId(wchar_t IP_Addr[16])=0;
virtual int WINAPIC BanCDkeyGetId(wchar_t CDHash[33])=0;
virtual bool WINAPIC UnbanID(int ID)=0;
//char* WINAPIC GetCDHash(Player::PlayerInfo& plI);
void WINAPIC GetIP(MachineHeader& mH, BYTE m_ip[4]);
void WINAPIC GetPort(MachineHeader& mH, WORD& m_port);
virtual void WINAPIC GetIP(MachineHeader& mH, BYTE m_ip[4])=0;
virtual void WINAPIC GetPort(MachineHeader& mH, WORD& m_port)=0;
//Halo Simulate Functions End
bool WINAPIC EXTAddOnGetInfoIndex(size_t index, addon::addonInfo &getInfo);
bool WINAPIC EXTAddOnGetInfoByName(wchar_t name[], addon::addonInfo &getInfo);
bool WINAPIC EXTAddOnReloadDll(wchar_t name[128]);
virtual bool WINAPIC EXTAddOnGetInfoIndex(size_t index, addon::addonInfo &getInfo)=0;
virtual bool WINAPIC EXTAddOnGetInfoByName(wchar_t name[], addon::addonInfo &getInfo)=0;
virtual bool WINAPIC EXTAddOnReloadDll(wchar_t name[128])=0;
};
extern "C" dllport HaloEngine* haloEngine;
extern "C" dllport IHaloEngine* pIHaloEngine;

#endif
46 changes: 17 additions & 29 deletions iniFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define INIFILELENMAX 512

extern "C" class dllport CIniFile {
extern "C" class ICIniFile {
public:
#pragma pack(push,1)
struct Record {
Expand All @@ -18,34 +18,22 @@ extern "C" class dllport CIniFile {
pound = L'#',
semiColon = L';'
};
CIniFile();
~CIniFile();
CIniFile(CIniFile const&);
CIniFile& operator=(CIniFile const&);
void WINAPIC Close();
bool WINAPIC Open(wchar_t const fileName[]);
bool WINAPIC Create(wchar_t const fileName[]);
bool WINAPIC Delete(wchar_t const fileName[]);
bool WINAPIC Content(const wchar_t*& content, size_t &len);
bool WINAPIC SectionAdd(wchar_t const sectionName[]);
bool WINAPIC SectionDelete(wchar_t const sectionName[]);
bool WINAPIC SectionExist(wchar_t const sectionName[]);
bool WINAPIC ValueExist(wchar_t const keyName[], const wchar_t sectionName[]);
bool WINAPIC ValueSet(wchar_t const keyName[], wchar_t valueName[], const wchar_t sectionName[]);
bool WINAPIC ValueGet(wchar_t const keyName[], wchar_t valueName[], const wchar_t sectionName[]);
bool WINAPIC Save();
bool WINAPIC Load();
void WINAPIC Clear();
private:
wchar_t tempFileName[INIFILELENMAX];
const wchar_t* strFileContentW;
DWORD size;
HANDLE hFile;
HANDLE hFileMap;
#pragma warning( push )
#pragma warning( disable : 4251)
util::dynamicStack<Record>* content;
#pragma warning( pop )
virtual void WINAPIC Release();
virtual void WINAPIC Close()=0;
virtual bool WINAPIC Open(wchar_t const fileName[])=0;
virtual bool WINAPIC Create(wchar_t const fileName[])=0;
virtual bool WINAPIC Delete(wchar_t const fileName[])=0;
virtual bool WINAPIC Content(const wchar_t*& content, size_t &len)=0;
virtual bool WINAPIC SectionAdd(wchar_t const sectionName[])=0;
virtual bool WINAPIC SectionDelete(wchar_t const sectionName[])=0;
virtual bool WINAPIC SectionExist(wchar_t const sectionName[])=0;
virtual bool WINAPIC ValueExist(wchar_t const keyName[], const wchar_t sectionName[])=0;
virtual bool WINAPIC ValueSet(wchar_t const keyName[], wchar_t valueName[], const wchar_t sectionName[])=0;
virtual bool WINAPIC ValueGet(wchar_t const keyName[], wchar_t valueName[], const wchar_t sectionName[])=0;
virtual bool WINAPIC Save()=0;
virtual bool WINAPIC Load()=0;
virtual void WINAPIC Clear()=0;
};
extern "C" dllport ICIniFile* WINAPIC getICIniFile();

#endif
Loading

0 comments on commit d4a6706

Please sign in to comment.