/* * * * * * * * * * * * * * * * 
 * 	 ______     __  __     ______     __  __     ______     ______     __  __    
 *	/\  __ \   /\ \/\ \   /\  == \   /\ \_\ \   /\  __ \   /\  ___\   /\ \/ /    
 *	\ \ \/\ \  \ \ \_\ \  \ \  __<   \ \  __ \  \ \  __ \  \ \ \____  \ \  _"-.  
 *	 \ \_____\  \ \_____\  \ \_____\  \ \_\ \_\  \ \_\ \_\  \ \_____\  \ \_\ \_\ 
 *	  \/_____/   \/_____/   \/_____/   \/_/\/_/   \/_/\/_/   \/_____/   \/_/\/_/ 
 *
 *  - Version : 3L
 *  - By Oubliette
 * * * * * * * * * * * * * * * */

#ifndef _LUA_SHARED

#define _LUA_SHARED

#include "main.h"
#include "vector"

using namespace std;

// ======================= TYPEDEFS ======================= //

typedef void* ( __thiscall* InitFn )					( void*, void* , bool, void*, void* );
typedef void* ( __thiscall* ShutdownFn )				( void* );
typedef void* ( __thiscall* DumpStatsFn )				( void* );
typedef PDWORD_PTR* ( __thiscall* CreateLuaInterfaceFn )( void*, unsigned char, bool );
typedef void* ( __thiscall* CloseLuaInterfaceFn )		( void*, PDWORD_PTR* );
typedef PDWORD_PTR* ( __thiscall* GetLuaInterfaceFn )	( void*, unsigned char );
typedef void* ( __thiscall* LoadFileFn )				( void*, const std::string&, const std::string&, bool, bool );
typedef void* ( __thiscall* GetCacheFn )				( void*, const std::string& );
typedef void* ( __thiscall* MountLuaFn )				( void*, const char * );
typedef void* ( __thiscall* MountLuaAddFn )				( void*, const char*, const char* );
typedef void* ( __thiscall* UnMountLuaFn )				( void*, const char* );
typedef void* ( __thiscall* SetFileContentsFn )			( void*, const char*, const char* );
typedef void* ( __thiscall* SetLuaFindHookFn )			( void*, void* );
typedef void* ( __thiscall* FindScriptsFn )				( void*, const std::string&, const std::string&, std::vector< std::string, std::allocator< std::string > >& );

// ======================= INDICES ======================= //

#define INDEX_LUASHARED_DESTROY					0
#define INDEX_LUASHARED_INIT					1
#define INDEX_LUASHARED_SHUTDOWN				2
#define INDEX_LUASHARED_DUMPSTATS				3			
#define INDEX_LUASHARED_CREATELUAINTERFACE		4
#define INDEX_LUASHARED_CLOSELUAINTERFACE		5
#define INDEX_LUASHARED_GETLUAINTERFACE			6
#define INDEX_LUASHARED_LOADFILE				7
#define INDEX_LUASHARED_GETCACHE				8
#define INDEX_LUASHARED_MOUNTLUA				9
#define INDEX_LUASHARED_MOUNTLUAADD				10
#define INDEX_LUASHARED_UNMOUNTLUA				11
#define INDEX_LUASHARED_SETFILECONTENTS			12
#define INDEX_LUASHARED_SETLUAFINDHOOK			13
#define INDEX_LUASHARED_FINDSCRIPTS				14

// ======================= CLASS HEADER ======================= //


class ILuaShared {
	
protected:

	PDWORD_PTR* base;
	template <typename T> T GetFunction( PDWORD_PTR*, UINT index );

public:

	/* -- */ ILuaShared( PDWORD_PTR* );

	/* 00 */ ~ILuaShared();

	PDWORD_PTR* GetBase( void );

	/* 01 */ void* Init( void*, bool, void*, void* );
	/* 02 */ void* Shutdown( void );
	/* 03 */ void* DumpStats( void );
	/* 04 */ PDWORD_PTR* CreateLuaInterface( unsigned char, bool );
	/* 05 */ void* CloseLuaInterface( PDWORD_PTR* );
	/* 06 */ PDWORD_PTR* GetLuaInterface( unsigned char );
	/* 07 */ void* LoadFile( const std::string&, const std::string&, bool, bool );
	/* 08 */ void* GetCache( const std::string& );
	/* 09 */ void* MountLua( const char * );
	/* 10 */ void* MoutLuaAdd( const char*, const char* );
	/* 11 */ void* UnMountLua( const char* );
	/* 12 */ void* SetFileContents( const char*, const char* );
	/* 13 */ void* SetLuaFindHook( void* );
	/* 14 */ void* FindScripts( const std::string&, const std::string&, std::vector< std::string, std::allocator< std::string > >& );

};

#endif