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.2
Browse files Browse the repository at this point in the history
Fixed util.h's dynamicStack copy method
Change tabs to spaces in headers.
Added 4 functions in util namespace.
Added expChecker.h for exported functions validations. (Much easier and
able tell developers if the functions are incorrect. NOTE: This has to
be done at END of the add-on's main file!)
Added struct_tags.h (NOTE: This is a draft process!)
  • Loading branch information
RadWolfie committed Sep 20, 2014
1 parent 07e36b3 commit df95d3d
Show file tree
Hide file tree
Showing 13 changed files with 1,823 additions and 1,457 deletions.
147 changes: 75 additions & 72 deletions Add-on API.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@
#define WINAPIC __cdecl
#if _MSC_VER >= 1600
#define static_assert_check static_assert //This is needed to verify correctly and prevent to compile if something is incorrect.
/*#elif _MSC_VER >=1500
#elif _MSC_VER >=1500
//TODO: Need find a way to add assert support for older than Visual Studio 2010.
#define static_assert_check(a, b)*/
#define static_assert_check(e, m) typedef char __C_ASSERT__[(e)?1:-1]
#else
#define static_assert_check(a, b) //Only necessary for Visual Studio 2008 and below to compile.
#endif


#define STRINGIZE_HELPER(x) #x
#define STRINGIZE(x) STRINGIZE_HELPER(x)
#define WARNING(desc) message(__FILE__ "(" STRINGIZE(__LINE__) ") : Warning: " #desc)


#ifdef __cplusplus
#define CNATIVE extern "C"
#else
#define CNATIVE
#endif

#include "struct.h"
#include "struct_tags.h"
#include "util.h"

#ifdef EXT_ICINIFILE
Expand All @@ -34,9 +40,7 @@
#include "database.h"
#endif

#ifdef EXT_IOBJECT
#include "object.h"
#endif

#include "player.h"
typedef toggle (WINAPIC *CmdFunc)(IPlayer::PlayerInfo plI, util::ArgContainer& arg,char chatRconRemote, DWORD idTimer, bool* showChat);
Expand All @@ -63,108 +67,107 @@ CNATIVE dllport void WINAPI haloOutput(int r, const char *text,...);

namespace addon {

#pragma pack(push,1)
struct sectNames {
wchar_t sect_name1[24];
wchar_t sect_name2[24];
wchar_t sect_name3[24];
wchar_t sect_name4[24];
wchar_t sect_name5[24];
};
struct addonInfo {
wchar_t name[128];
wchar_t version[15];
wchar_t author[128];
wchar_t description[255];
wchar_t config_folder[24];
sectNames sectors;
};
struct versionEAO {
WORD size; //Used by sizeof(versionEAO);
WORD requiredAPI; //API requirement revision (Including command functions)
WORD general; //General revision specifically for events in Halo.
WORD pICIniFile; //CiniFile interface revision
WORD pIDatabase; //Database interface revision
WORD external; //External account revision
WORD pIHaloEngine; //Halo Engine interface revision
WORD pIObject; //Object interface revision
WORD pIPlayer; //Player interface revision
WORD pICommand; //Command interface revision
WORD pITimer; //Timer interface revision
WORD pIAdmin; //Admin interface revision
WORD reserved2; //reserved
WORD reserved3; //reserved
WORD reserved4; //reserved
WORD reserved5; //reserved
};
#pragma pack(pop)
#pragma pack(push,1)
struct sectNames {
wchar_t sect_name1[24];
wchar_t sect_name2[24];
wchar_t sect_name3[24];
wchar_t sect_name4[24];
wchar_t sect_name5[24];
};
struct addonInfo {
wchar_t name[128];
wchar_t version[15];
wchar_t author[128];
wchar_t description[255];
wchar_t config_folder[24];
sectNames sectors;
};
struct versionEAO {
WORD size; //Used by sizeof(versionEAO);
WORD requiredAPI; //API requirement revision (Including command functions)
WORD general; //General revision specifically for events in Halo.
WORD pICIniFile; //CiniFile interface revision
WORD pIDatabase; //Database interface revision
WORD external; //External account revision
WORD pIHaloEngine; //Halo Engine interface revision
WORD pIObject; //Object interface revision
WORD pIPlayer; //Player interface revision
WORD pICommand; //Command interface revision
WORD pITimer; //Timer interface revision
WORD pIAdmin; //Admin interface revision
WORD reserved2; //reserved
WORD reserved3; //reserved
WORD reserved4; //reserved
WORD reserved5; //reserved
};
#pragma pack(pop)
#ifdef EXT_ITIMER
CNATIVE class ITimer {
public:
DWORD WINAPIC EXTAddOnTimerAdd(IPlayer::PlayerInfo plI, DWORD execTime);
void WINAPIC EXTAddOnTimerDelete(DWORD id);
};
CNATIVE dllport ITimer* pITimer;
CNATIVE class ITimer {
public:
DWORD WINAPIC EXTAddOnTimerAdd(IPlayer::PlayerInfo plI, DWORD execTime);
void WINAPIC EXTAddOnTimerDelete(DWORD id);
};
CNATIVE dllport ITimer* pITimer;
#endif
}
CNATIVE dllAPI addon::versionEAO EXTversion = {
sizeof(addon::versionEAO), //size
5, //requiredAPI - API requirement revision (Including command interface)
4, //general - General revision specifically for events in Halo.
sizeof(addon::versionEAO), //size
5, //requiredAPI - API requirement revision (Including command interface)
4, //general - General revision specifically for events in Halo.
#ifdef EXT_ICINIFILE
2, //iniFile - CiniFile class revision
2, //iniFile - CiniFile class revision
#else
0, //iniFile - excluded
0, //iniFile - excluded
#endif
#ifdef EXT_IDATABASE
3, //pIDatabase - Database class revision
3, //pIDatabase - Database class revision
#else
0, //pIDatabase - excluded
0, //pIDatabase - excluded
#endif
#ifdef EXT_IEXTERNAL
0, //external - External account revision (for Remote Control or other external possiblities)
0, //external - External account revision (for Remote Control or other external possiblities)
#else
0, //external - excluded
0, //external - excluded
#endif
#ifdef EXT_IHALOENGINE
1, //pIHaloEngine - Halo Engine class revision
1, //pIHaloEngine - Halo Engine class revision
#else
0, //pIHaloEngine - excluded
0, //pIHaloEngine - excluded
#endif
#ifdef EXT_IOBJECT
2, //pIObject - Object class revision
3, //pIObject - Object class revision
#else
0, //pIObject - excluded
0, //pIObject - excluded
#endif
#ifdef EXT_IPLAYER
3, //pIPlayer - Player class revision
4, //pIPlayer - Player class revision
#else
0, //pIPlayer - excluded
0, //pIPlayer - excluded
#endif
#ifdef EXT_ICOMMAND
1, //pICommand - Command class revision
1, //pICommand - Command class revision
#else
0, //pICommand - excluded
0, //pICommand - excluded
#endif
#ifdef EXT_ITIMER
1, //pITimer - Timer class revision
1, //pITimer - Timer class revision
#else
0, //pITimer - excluded
0, //pITimer - excluded
#endif
#ifdef EXT_IADMIN
1, //pIAdmin - Admin class revision
1, //pIAdmin - Admin class revision
#else
0, //pIAdmin - excluded
0, //pIAdmin - excluded
#endif
0, //reserved
0, //reserved
0, //reserved
0 }; //reserved
0, //reserved
0, //reserved
0, //reserved
0 }; //reserved
static_assert_check(sizeof(addon::versionEAO)==32, "Error, incorrect size of versionEAO struct");

#ifdef EXT_IHALOENGINE
#include "haloEngine.h"
#endif

#endif

#endif
Binary file modified Add-on API.lib
Binary file not shown.
10 changes: 5 additions & 5 deletions admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

CNATIVE class IAdmin {
public:
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;
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;
};
CNATIVE dllport IAdmin* pIAdmin;

Expand Down
12 changes: 6 additions & 6 deletions command.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

#pragma pack(push,1)
struct helpInfo {
wchar_t info[4][255];
wchar_t info[4][255];
};
#pragma pack(pop)
CNATIVE class ICommand {
public:
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;
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;
};
CNATIVE dllport ICommand* pICommand;
#endif
108 changes: 54 additions & 54 deletions database.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,63 @@
#define databaseH

CNATIVE namespace DBSQL {
//--
//#pragma comment(lib,"Msvcrt.lib") //Basically bypass the error of vsnprintf... Replace the odbccp32.lib file with vista SDK!!!
#pragma comment(lib,"odbc32.lib")
//#pragma comment(lib,"odbcbcp.lib")
#pragma comment(lib,"odbccp32.lib")
//--
#include <sql.h>
#include <sqlext.h>
#include <odbcinst.h>
//--
//#pragma comment(lib,"Msvcrt.lib") //Basically bypass the error of vsnprintf... Replace the odbccp32.lib file with vista SDK!!!
#pragma comment(lib,"odbc32.lib")
//#pragma comment(lib,"odbcbcp.lib")
#pragma comment(lib,"odbccp32.lib")
//--
#include <sql.h>
#include <sqlext.h>
#include <odbcinst.h>

#define IS_SQL_ERR !IS_SQL_OK
#define IS_SQL_OK(res) (res==SQL_SUCCESS_WITH_INFO || res==SQL_SUCCESS)
#define SAFE_STR(str) ((str==NULL) ? _T("") : str)
//--
class IDBConnection {
public:
virtual bool WINAPIC Connect(LPCWSTR MDBPath,LPCWSTR User=L"", LPCWSTR Pass=L"",bool Exclusive=0)=0;
//bool Connect(LPCTSTR svSource);
//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:
//IDBConnection();
//~IDBConnection();
};
class IDBStmt {
public:
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;
#define IS_SQL_ERR !IS_SQL_OK
#define IS_SQL_OK(res) (res==SQL_SUCCESS_WITH_INFO || res==SQL_SUCCESS)
#define SAFE_STR(str) ((str==NULL) ? _T("") : str)
//--
class IDBConnection {
public:
virtual bool WINAPIC Connect(LPCWSTR MDBPath,LPCWSTR User=L"", LPCWSTR Pass=L"",bool Exclusive=0)=0;
//bool Connect(LPCTSTR svSource);
//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:
//IDBConnection();
//~IDBConnection();
};
class IDBStmt {
public:
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;

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;
};
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;
};
#ifdef EXT_IDATABASE
dllport IDBConnection* WINAPIC getIDBConnection();
dllport IDBStmt* WINAPIC getIDBStmt();
dllport IDBConnection* WINAPIC getIDBConnection();
dllport IDBStmt* WINAPIC getIDBStmt();
#endif
};
#endif
Loading

0 comments on commit df95d3d

Please sign in to comment.