*** empty log message ***

This commit is contained in:
Twilight Suzuka 2006-03-14 02:54:54 +00:00
parent 5c88803942
commit 4cb8d4adc7
7 changed files with 1343 additions and 0 deletions

View File

@ -0,0 +1,35 @@
#ifndef _BASE_ARRAYCLASS_H
#define _BASE_ARRAYCLASS_H
#include "JudyIncludes.h"
class CBaseList
{
public:
virtual Word_t Clear() =0;
virtual Word_t MemoryUsed() =0;
virtual int Delete(cell Key) =0;
virtual void Set(cell Index, Pvoid_t value, bool disable_check = false) =0;
virtual Pvoid_t Get(cell Index, bool disable_check = false) =0;
virtual cell First(cell Start = 0) =0;
virtual cell Next(cell Start = 0) =0;
virtual cell Prev(cell Start = -1) =0;
virtual cell Last(cell Start = -1) =0;
virtual cell FirstEmpty(cell Start = 0) =0;
virtual cell NextEmpty(cell Start = 0) =0;
virtual cell PrevEmpty(cell Start = -1) =0;
virtual cell LastEmpty(cell Start = -1) =0;
virtual cell ByCount(cell n, cell Start = 0) =0;
virtual cell Count(cell Start = 0, cell Stop = -1) =0;
virtual bool IsFilled(cell Index) =0;
virtual bool IsEmpty(cell Index) =0;
};
#endif

View File

@ -0,0 +1,28 @@
#ifndef _BASE_MAPCLASS_H
#define _BASE_MAPCLASS_H
#include "JudyIncludes.h"
class CBaseMap
{
public:
virtual Word_t Clear() =0;
virtual Word_t MemoryUsed() =0;
virtual int Delete(char* Key) =0;
virtual void Set(char* Index, Pvoid_t value, bool disable_check = false) =0;
virtual Pvoid_t Get(char* Index, bool disable_check = false) =0;
virtual char* First(char* Start = "") =0;
virtual char* Next(char* Start) =0;
virtual char* Prev(char* Start) =0;
virtual char* Last(char* Start) =0;
virtual bool IsFilled(char* Index) =0;
virtual bool IsEmpty(char* Index) =0;
};
#endif

View File

@ -0,0 +1,52 @@
#ifndef _BINTRIECLASS_H
#define _BINTRIECLASS_H
#include "JudyIncludes.h"
//#include <Judy1.h>
class BinTrie
{
private:
Pvoid_t Table;
void ThrowSearchError(char* msg);
public:
BinTrie() { Table = NULL; }
~BinTrie() { Judy1FreeArray(&Table, PJE0); }
Word_t Clear() { return Judy1FreeArray(&Table, PJE0); }
Word_t MemoryUsed() { return Judy1MemUsed(Table); }
cell Delete(cell Key) { return Judy1Unset(&Table, Key, PJE0 ); }
cell Set(cell Index, bool val)
{
if(val == false) return Delete(Index);
else return Judy1Set(&Table, Index,PJE0);
}
cell Get(cell Index)
{
cell PValue = Judy1Test(Table, Index, PJE0);
return PValue;
}
cell First(cell Start = 0);
cell Next(cell Start = 0);
cell Prev(cell Start = -1);
cell Last(cell Start = -1);
cell FirstEmpty(cell Start = 0);
cell NextEmpty(cell Start = 0);
cell PrevEmpty(cell Start = -1);
cell LastEmpty(cell Start = -1);
cell ByCount(cell n, cell Start);
cell Count(cell Start = 0, cell Stop = -1) { return Judy1Count(Table, Start, Stop, PJE0); }
bool IsFilled(cell Index) { return ( (Get(Index )) ? true : false); }
bool IsEmpty(cell Index) { return ( (Get(Index )) ? true : false); }
};
#endif

261
dlls/arrayx/SDK/Capsule.cpp Normal file
View File

@ -0,0 +1,261 @@
#include "Capsule.h"
const char* capsule_types[] =
{
"-NO VALUE-",
"BOOLEAN",
"INTEGER",
"FLOAT",
"VECTOR",
"STRING"
};
void Capsule::ThrowTypeError(cell get_type)
{
char ValStr[15];
GetAsStr(ValStr);
char value[100];
sprintf(value,"Function attempted to read NON-%s value, actual type is: %s, actual value is: %s", capsule_types[get_type], capsule_types[type], ValStr );
throw JudyEx(value, true);
}
bool Capsule::CheckEmpty(bool clear)
{
bool empty = ( data == NULL );
if(empty != true && clear == true) Clear();
return empty;
}
void Capsule::Clear()
{
//This function intelligently creates a pointer x,
//which will be of correct type and then deletes it.
switch (type)
{
case capsule_type_flo:
{
REAL *real_val = reinterpret_cast<REAL*>(data);
delete real_val;
break;
}
case capsule_type_vec:
{
JudyVec *vector_val = reinterpret_cast<JudyVec*>(data);
delete vector_val;
break;
}
case capsule_type_str:
{
char *char_val = reinterpret_cast<char*>(data);
delete char_val;
break;
}
}
data = NULL; //Null the address as well. (Used for ints too.)
}
bool Capsule::GetBool( void )
{
if (type != capsule_type_bool) ThrowTypeError(capsule_type_bool);
return reinterpret_cast<bool>(data);
}
void Capsule::SetBool(bool Value)
{
CheckEmpty(true);
type = capsule_type_bool;
data = reinterpret_cast<void*>(Value);
};
cell Capsule::GetInt( void )
{
if (type != capsule_type_int) ThrowTypeError(capsule_type_int);
return reinterpret_cast<cell>(data);
}
void Capsule::SetInt(cell Value)
{
CheckEmpty(true);
type = capsule_type_int;
data = reinterpret_cast<void*>(Value);
};
REAL Capsule::GetFlo( void )
{
if (type != capsule_type_flo) ThrowTypeError(capsule_type_flo);
return *reinterpret_cast<REAL*>(data);
}
void Capsule::SetFlo(REAL Value)
{
CheckEmpty(true);
type = capsule_type_flo;
data = new REAL(Value);
};
const JudyVec* Capsule::GetVec( void )
{
if (type != capsule_type_vec) ThrowTypeError(capsule_type_vec);
return reinterpret_cast<const JudyVec*>(data);
}
void Capsule::SetVec(JudyVec* Value)
{
CheckEmpty(true);
type = capsule_type_vec;
data = reinterpret_cast<void*>(Value);
}
const char* Capsule::GetStr( void )
{
if (type != capsule_type_str) ThrowTypeError(capsule_type_str);
return reinterpret_cast<const char*>(data);
}
void Capsule::SetStr(char* Value)
{
CheckEmpty(true);
type = capsule_type_str;
char *string_val = new char[strlen(Value)+1];
strcpy(string_val,Value);
data = reinterpret_cast<void*>(string_val);
}
void Capsule::GetAsStr(char* value)
{
switch (type)
{
case capsule_type_bool:
sprintf(value, "%i",(cell)GetBool());
break;
case capsule_type_int:
sprintf(value, "%d", GetInt() );
break;
case capsule_type_flo:
sprintf(value, "%f", GetFlo() );
break;
case capsule_type_vec:
sprintf(value, "{%f,%f,%f}", GetVec()->first, GetVec()->second, GetVec()->third);
break;
case capsule_type_str:
sprintf(value, "\"%s\"", GetStr() );
break;
default:
sprintf(value, "-NO VALUE-");
}
}
void Capsule::Save(FILE* capsuleDB)
{
fwrite(&type,sizeof(char),1,capsuleDB);
switch(type)
{
case capsule_type_none: { break; }
case capsule_type_bool: { bool var = GetBool(); fwrite(&var, sizeof(bool), 1, capsuleDB); break; }
case capsule_type_int: { cell var = GetInt(); fwrite(&var, sizeof(cell), 1, capsuleDB); break; }
case capsule_type_flo: { fwrite(reinterpret_cast<REAL*>(GetData()), sizeof(REAL), 1, capsuleDB); break; }
case capsule_type_str:
{
const char* str = GetStr();
size_t len = strlen(str);
fwrite(&len,sizeof(size_t), 1, capsuleDB);
fwrite(&str, sizeof(char), len, capsuleDB);
break;
}
case capsule_type_vec:
{
const JudyVec* buffer = GetVec();
fwrite(buffer, sizeof(JudyVec), 1, capsuleDB);
break;
}
default:
{
char value[20];
sprintf(value,"Invalid type found!");
throw JudyEx(value, true);
break;
}
};
}
void Capsule::Load(FILE* capsuleDB)
{
fread(&type, sizeof(char), 1, capsuleDB);
switch(type)
{
case capsule_type_none: { CheckEmpty(true); break; }
case capsule_type_bool:
{
bool value = false;
fread(&value, sizeof(bool), 1, capsuleDB);
SetBool(value);
break;
}
case capsule_type_int:
{
cell value = NULL;
fread(&value, sizeof(cell), 1, capsuleDB);
SetInt(value);
break;
}
case capsule_type_flo:
{
REAL value = NULL;
fread(&value, sizeof(REAL), 1, capsuleDB);
SetFlo(value);
break;
}
case capsule_type_str:
{
size_t length;
fread(&length, sizeof(size_t), 1, capsuleDB);
char* value = new char[length+1];
fgets(value, length+1, capsuleDB);
SetStr(value);
delete(value);
break;
}
case capsule_type_vec:
{
JudyVec* value = new JudyVec(NULL,NULL,NULL);
fread(value, sizeof(JudyVec), 1, capsuleDB);
SetVec(value);
break;
}
default:
{
char value[20];
sprintf(value,"Invalid type found: %i",(int)type);
throw JudyEx(value, true);
}
};
}

64
dlls/arrayx/SDK/Capsule.h Normal file
View File

@ -0,0 +1,64 @@
#ifndef _JUDYCAP_INCLUDED
#define _JUDYCAP_INCLUDED
#include "JudyIncludes.h"
enum
{
capsule_type_none,
capsule_type_bool,
capsule_type_int,
capsule_type_flo,
capsule_type_vec,
capsule_type_str
};
extern const char* capsule_types[];
class Capsule
{
private:
Pvoid_t data;
char type;
protected:
void Clear( void );
void ThrowTypeError(cell get_type);
public:
Capsule() { data = NULL; type = capsule_type_none;}
~Capsule() { Clear(); }
Capsule(bool set) { SetBool(set); }
Capsule(cell set) { SetInt(set); }
Capsule(REAL set) { SetFlo(set); }
Capsule(JudyVec* set) { SetVec(set); }
Capsule(char* set) { SetStr(set); }
bool GetBool( void );
void SetBool(bool set);
cell GetInt( void );
void SetInt(cell set);
REAL GetFlo( void );
void SetFlo(REAL set);
const JudyVec* GetVec( void );
void SetVec(JudyVec* set);
const char* GetStr( void );
void SetStr(char* set);
void GetAsStr(char* value);
void Load(FILE* db);
void Save(FILE* db);
bool CheckEmpty(bool clear);
Pvoid_t GetData( void ) { return data; }
char GetType( void ) { return type; }
};
#endif

View File

@ -0,0 +1,845 @@
#ifndef _GENERIC_INC_H
#define _GENERIC_INC_H
// Master table
ComboArray MNAME;
///* MASTER FUNCTIONS *///
///* Start Master Edit Funcs *///
#ifdef JUDY_MASTER_EDIT_FUNCTIONS
#ifdef JUDY_MASTER_DELETE_FUNC
// generic_delete(id)
static cell AMX_NATIVE_CALL JUDY_MASTER_DELETE_FUNC(AMX *amx,cell *params)
{
try { return MNAME.Delete( params[1] ); }
JUDY_ERROR_CATCH("Judy Error: (No error possible) - Delete function ");
}
#else
#error Must Have Delete func: JUDY_MASTER_DELETE_FUNC not defined!
#endif
#ifdef JUDY_MASTER_CLEAR_FUNC
// generic_clear(id)
static cell AMX_NATIVE_CALL JUDY_MASTER_CLEAR_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1] );
try { return Unit->Clear(); }
JUDY_ERROR_CATCH("Judy Error: (Search error likely) - Clear function ");
}
#else
#error Must Have Clear func: JUDY_MASTER_CLEAR_FUNC not defined!
#endif
///* End Master Edit Funcs *///
#endif
///* Start Master IO Funcs *///
#ifdef JUDY_MASTER_IO_FUNCTIONS
#ifdef JUDY_MASTER_SAVE_FUNC
// generic_save(id,file[])
static cell AMX_NATIVE_CALL JUDY_MASTER_SAVE_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
return JUDY_SAVE_FUNC(Unit, JUDY_BUILD_PATH(amx,params[2]) );
}
#else
#error Must Have Save func: JUDY_MASTER_SAVE_FUNC not defined properly!
#endif
#ifdef JUDY_MASTER_LOAD_FUNC
// generic_load(file[],id)
static cell AMX_NATIVE_CALL JUDY_MASTER_LOAD_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[2]);
return JUDY_LOAD_FUNC(Unit, JUDY_BUILD_PATH(amx,params[1]) );
}
#else
#error Must Have Load func: JUDY_MASTER_LOAD_FUNC not defined!
#endif
///* End Master IO Funcs *///
#endif
///* Start Master Amount Funcs *///
#ifdef JUDY_MASTER_AMOUNT_FUNCTIONS
#ifdef JUDY_MASTER_COUNT_FUNC
// generic_count(start = 0, stop = -1)
static cell AMX_NATIVE_CALL JUDY_MASTER_COUNT_FUNC(AMX *amx,cell *params)
{
try { return MNAME.Count(params[1],params[2] ); }
JUDY_ERROR_CATCH("Judy Error: (Search error likely) - Count Function ");
}
#else
#error Must Have Count func: JUDY_MASTER_COUNT_FUNC not defined!
#endif
#ifdef JUDY_MASTER_BYCOUNT_FUNC
// generic_bycount(nth, start = -1)
static cell AMX_NATIVE_CALL JUDY_MASTER_BYCOUNT_FUNC(AMX *amx,cell *params)
{
try { return MNAME.ByCount(params[1],params[2] ); }
JUDY_ERROR_CATCH("Judy Error: (Search error likely) - ByCount Function ");
}
#else
#error Must Have ByCount func: JUDY_MASTER_BYCOUNT_FUNC not defined!
#endif
///* End Master Amount Funcs *///
#endif
///* SLAVE FUNCTIONS *///
///* Start Slave Amount Funcs *///
#ifdef JUDY_SLAVE_AMOUNT_FUNCTIONS
#ifdef JUDY_SLAVE_COUNT_FUNC
// generic_size(id, start = 0, stop = -1)
static cell AMX_NATIVE_CALL JUDY_SLAVE_COUNT_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
try { return Unit->Count(JUDY_GET_KEY(params,2),JUDY_GET_KEY(params, 3) ); }
JUDY_ERROR_CATCH("Judy Error: (Search error likely) - Slave Count Function ");
}
#else
#error Must Have Count func: JUDY_SLAVE_COUNT_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_BYCOUNT_FUNC
// generic_get_nth(id, nth, start = -1)
static cell AMX_NATIVE_CALL JUDY_SLAVE_BYCOUNT_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
try { return Unit->ByCount(JUDY_GET_KEY(params,2),JUDY_GET_KEY(params, 3) ); }
JUDY_ERROR_CATCH("Judy Error: (Search error likely) - Slave ByCount Function ");
}
#else
#error Must Have ByCount func: JUDY_SLAVE_BYCOUNT_FUNC not defined!
#endif
///* End Slave Amount Funcs *///
#endif
///* Start Slave Edit Funcs *///
#ifdef JUDY_SLAVE_EDIT_FUNCTIONS
#ifdef JUDY_SLAVE_MEMORY_FUNC
// generic_memory(id)
static cell AMX_NATIVE_CALL JUDY_SLAVE_MEMORY_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
try { return Unit->MemoryUsed(); }
JUDY_ERROR_CATCH("Judy Error: (Search error likely) - Slave ByCount Function ");
}
#else
#error Must Have Memory func: JUDY_SLAVE_MEMORY_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_ISFILLED_FUNC
// generic_isfilled(id, index)
static cell AMX_NATIVE_CALL JUDY_SLAVE_ISFILLED_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
try { return Unit->IsFilled(JUDY_GET_KEY(params,2) ); }
JUDY_ERROR_CATCH("Judy Error: (No error possible) - Slave IsFilled Function ");
}
#else
#error Must Have IsFilled func: JUDY_SLAVE_ISFILLED_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_ISEMPTY_FUNC
// generic_isempty(id, index)
static cell AMX_NATIVE_CALL JUDY_SLAVE_ISEMPTY_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
try { return Unit->IsEmpty(JUDY_GET_KEY(params,2) ); }
JUDY_ERROR_CATCH("Judy Error: (No error possible) - Slave IsEmpty Function ");
}
#else
#error Must Have IsEmpty func: JUDY_SLAVE_ISEMPTY_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_REMOVE_FUNC
// generic_remove(id, index)
static cell AMX_NATIVE_CALL JUDY_SLAVE_REMOVE_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
try { return Unit->Delete(JUDY_GET_KEY(params,2) ); }
JUDY_ERROR_CATCH("Judy Error: (No error possible) - Slave Delete Function ");
}
#else
#error Must Have Delete func: JUDY_SLAVE_DELETE_FUNC not defined!
#endif
///* End Required Slave Edit Funcs *///
///* Start Slave Bool Funcs *///
#ifdef JUDY_SLAVE_EDIT_BOOL
#ifdef JUDY_SLAVE_SET_BOOL_FUNC
// generic_set_bool(id, index, Bool:val)
static cell AMX_NATIVE_CALL JUDY_SLAVE_SET_BOOL_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
bool Value = (params[3] != NULL);
Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
if(Storage == NULL) Storage = new STYPE(Value);
else Storage->SetBool(Value);
JUDY_SET_INDEX_P(Unit,Storage,Indice);
}
#else
#error Must Have Set func: JUDY_SLAVE_SET_BOOL_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_GET_BOOL_FUNC
// Bool:generic_get_bool(id, index, disable_check = 0)
static cell AMX_NATIVE_CALL JUDY_SLAVE_GET_BOOL_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
bool disable_check = (params[3] != NULL);
try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
if(Storage == NULL) return 0;
return Storage->GetBool();
}
#else
#error Must Have Get func: JUDY_SLAVE_GET_BOOL_FUNC not defined!
#endif
///* End Slave Bool Funcs *///
#endif
///* Start Slave Int Funcs *///
#ifdef JUDY_SLAVE_EDIT_INT
#ifdef JUDY_SLAVE_SET_INT_FUNC
// generic_set_bool(id, index, val)
static cell AMX_NATIVE_CALL JUDY_SLAVE_SET_INT_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell Value = params[3];
Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
if(Storage == NULL) Storage = new STYPE(Value);
else Storage->SetInt(Value);
JUDY_SET_INDEX_P(Unit,Storage,Indice);
}
#else
#error Must Have Set func: JUDY_SLAVE_SET_INT_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_GET_INT_FUNC
// generic_get_int(id, index, disable_check = 0)
static cell AMX_NATIVE_CALL JUDY_SLAVE_GET_INT_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
bool disable_check = (params[3] != NULL);
try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
if(Storage == NULL) return 0;
return Storage->GetInt();
}
#else
#error Must Have Get func: JUDY_SLAVE_GET_INT_FUNC not defined!
#endif
///* End Slave Int Funcs *///
#endif
///* Start Slave Float Funcs *///
#ifdef JUDY_SLAVE_EDIT_FLO
#ifdef JUDY_SLAVE_SET_FLO_FUNC
// generic_set_float(id, index, Float:val)
static cell AMX_NATIVE_CALL JUDY_SLAVE_SET_FLO_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
REAL Value = amx_ctof(params[3]);
Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
if(Storage == NULL) Storage = new STYPE(Value);
else Storage->SetFlo(Value);
JUDY_SET_INDEX_P(Unit,Storage,Indice);
}
#else
#error Must Have Set func: JUDY_SLAVE_SET_FLO_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_GET_FLO_FUNC
// Float:generic_get_float(id, index, disable_check = 0)
static cell AMX_NATIVE_CALL JUDY_SLAVE_GET_FLO_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
bool disable_check = (params[3] != NULL);
try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
if(Storage == NULL) return 0;
return amx_ftoc(Storage->GetFlo() );
}
#else
#error Must Have Get func: JUDY_SLAVE_GET_FLO_FUNC not defined!
#endif
///* End Slave Float Funcs *///
#endif
///* Start Slave String Funcs *///
#ifdef JUDY_SLAVE_EDIT_STR
#ifdef JUDY_SLAVE_SET_STR_FUNC
// generic_set_string(id, index, val[])
static cell AMX_NATIVE_CALL JUDY_SLAVE_SET_STR_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
char* Value = MF_GetAmxString(amx,params[3],3,NULL);
Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
if(Storage == NULL) Storage = new STYPE(Value);
else Storage->SetStr(Value);
JUDY_SET_INDEX_P(Unit,Storage,Indice);
}
#else
#error Must Have Set func: JUDY_SLAVE_SET_STR_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_GET_STR_FUNC
// generic_get_string(id, index, val[], len, disable_check = 0)
static cell AMX_NATIVE_CALL JUDY_SLAVE_GET_STR_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
bool disable_check = (params[5] != NULL);
try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
if(Storage == NULL) return 0;
return MF_SetAmxString(amx,params[3], Storage->GetStr(), params[4] );
}
#else
#error Must Have Get func: JUDY_SLAVE_GET_STR_FUNC not defined!
#endif
///* End Slave String Funcs *///
#endif
///* Start Slave Vector Funcs *///
#ifdef JUDY_SLAVE_EDIT_VEC
#ifdef JUDY_SLAVE_SET_VEC_FUNC
// generic_set_vec(id, index, Float:val[3])
static cell AMX_NATIVE_CALL JUDY_SLAVE_SET_VEC_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell *input_vec = MF_GetAmxAddr(amx, params[3]);
JudyVec *Value = new JudyVec(
amx_ctof(input_vec[0]),
amx_ctof(input_vec[1]),
amx_ctof(input_vec[2])
);
Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
if(Storage == NULL) Storage = new STYPE(Value);
else Storage->SetVec(Value);
JUDY_SET_INDEX_P(Unit,Storage,Indice);
}
#else
#error Must Have Set func: JUDY_SLAVE_SET_VEC_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_GET_FLO_FUNC
// generic_get_vec(id,index,Float:vec[3], disable_check = 0)
static cell AMX_NATIVE_CALL JUDY_SLAVE_GET_VEC_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
STYPE* Storage;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell *vAmx = MF_GetAmxAddr(amx, params[3]);
bool disable_check = (params[4] != NULL);
try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
if(Storage == NULL)
{
vAmx[0] = amx_ftoc(0);
vAmx[1] = amx_ftoc(0);
vAmx[2] = amx_ftoc(0);
return 0;
}
JudyVec* Vec = const_cast<JudyVec*>( Storage->GetVec() );
REAL One, Two, Three;
Vec->Get(One, Two, Three);
vAmx[0] = amx_ftoc(One);
vAmx[1] = amx_ftoc(Two);
vAmx[2] = amx_ftoc(Three);
return 1;
}
#else
#error Must Have Get func: JUDY_SLAVE_GET_VEC_FUNC not defined!
#endif
///* End Slave VEC Funcs *///
#endif
///* End Slave Edit Funcs *///
#endif
///* Start Slave Search Funcs
#ifdef JUDY_SLAVE_SEARCH_FUNCTIONS
#ifdef JUDY_SLAVE_FIRST_FUNC
// generic_first(id, index,...)
static cell AMX_NATIVE_CALL JUDY_SLAVE_FIRST_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell* success = MF_GetAmxAddr(amx, params[3 + SE_OFFSET]);
*success = 1;
try { return JUDY_SET_KEY(Unit->First(Indice),3); }
JUDY_SEARCH_ERROR_CATCH("Judy Error (Search failed) - Slave Search Function", *success);
}
#else
#error Must Have Search func: JUDY_SLAVE_FIRST_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_NEXT_FUNC
// generic_next(id, index,...)
static cell AMX_NATIVE_CALL JUDY_SLAVE_NEXT_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell* success = MF_GetAmxAddr(amx, params[3 + SE_OFFSET]);
*success = 1;
try { return JUDY_SET_KEY(Unit->Next(Indice),3); }
JUDY_SEARCH_ERROR_CATCH("Judy Error (Search failed) - Slave Search Function", *success);
}
#else
#error Must Have Search func: JUDY_SLAVE_NEXT_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_PREV_FUNC
// generic_prev(id, index,...)
static cell AMX_NATIVE_CALL JUDY_SLAVE_PREV_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell* success = MF_GetAmxAddr(amx, params[3 + SE_OFFSET]);
*success = 1;
try { return JUDY_SET_KEY(Unit->Prev(Indice),3); }
JUDY_SEARCH_ERROR_CATCH("Judy Error (Search failed) - Slave Search Function", *success);
}
#else
#error Must Have Search func: JUDY_SLAVE_PREV_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_LAST_FUNC
// generic_first(id, index,...)
static cell AMX_NATIVE_CALL JUDY_SLAVE_LAST_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell* success = MF_GetAmxAddr(amx, params[3 + SE_OFFSET]);
*success = 1;
try { return JUDY_SET_KEY(Unit->Last(Indice),3); }
JUDY_SEARCH_ERROR_CATCH("Judy Error (Search failed) - Slave Search Function", *success);
}
#else
#error Must Have Search func: JUDY_SLAVE_LAST_FUNC not defined!
#endif
///* End Slave Search Funcs *///
#endif
///* Start Slave Empty Search Funcs
#ifdef JUDY_SLAVE_SEARCH_EMPTY_FUNCTIONS
#ifdef JUDY_SLAVE_FIRSTEMPTY_FUNC
// generic_firstempty(id, index,...)
static cell AMX_NATIVE_CALL JUDY_SLAVE_FIRSTEMPTY_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell* success = MF_GetAmxAddr(amx, params[3 + SE_OFFSET]);
*success = 1;
try { return JUDY_SET_KEY(Unit->FirstEmpty(Indice),3); }
JUDY_SEARCH_ERROR_CATCH("Judy Error (Search failed) - Slave Search Function", *success);
}
#else
#error Must Have Search func: JUDY_SLAVE_FIRSTEMPTY_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_NEXTEMPTY_FUNC
// generic_next(id, index,...)
static cell AMX_NATIVE_CALL JUDY_SLAVE_NEXTEMPTY_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell* success = MF_GetAmxAddr(amx, params[3 + SE_OFFSET]);
*success = 1;
try { return JUDY_SET_KEY(Unit->NextEmpty(Indice),3); }
JUDY_SEARCH_ERROR_CATCH("Judy Error (Search failed) - Slave Search Function", *success);
}
#else
#error Must Have Search func: JUDY_SLAVE_NEXTEMPTY_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_PREVEMPTY_FUNC
// generic_prev(id, index,...)
static cell AMX_NATIVE_CALL JUDY_SLAVE_PREVEMPTY_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell* success = MF_GetAmxAddr(amx, params[3 + SE_OFFSET]);
*success = 1;
try { return JUDY_SET_KEY(Unit->PrevEmpty(Indice),3); }
JUDY_SEARCH_ERROR_CATCH("Judy Error (Search failed) - Slave Search Function", *success);
}
#else
#error Must Have Search func: JUDY_SLAVE_PREVEMPTY_FUNC not defined!
#endif
#ifdef JUDY_SLAVE_LASTEMPTY_FUNC
// generic_first(id, index,...)
static cell AMX_NATIVE_CALL JUDY_SLAVE_LASTEMPTY_FUNC(AMX *amx,cell *params)
{
DTYPE* Unit = NULL;
JUDY_GET_INDEX(MNAME,Unit, params[1]);
ITYPE Indice = JUDY_GET_KEY(params,2);
cell* success = MF_GetAmxAddr(amx, params[3 + SE_OFFSET]);
*success = 1;
try { return JUDY_SET_KEY(Unit->LastEmpty(Indice),3); }
JUDY_SEARCH_ERROR_CATCH("Judy Error (Search failed) - Slave Search Function",*success);
}
#else
#error Must Have Search func: JUDY_SLAVE_LASTEMPTY_FUNC not defined!
#endif
///* End Slave Search Empty Funcs *///
#endif
AMX_NATIVE_INFO EXPORT_NAME[] =
{
#ifdef JUDY_MASTER_EDIT_FUNCTIONS
{ JUDY_MASTER_CLEAR_STR , JUDY_MASTER_CLEAR_FUNC },
{ JUDY_MASTER_DELETE_STR , JUDY_MASTER_DELETE_FUNC },
#endif
#ifdef JUDY_MASTER_IO_FUNCTIONS
{ JUDY_MASTER_SAVE_STR , JUDY_MASTER_SAVE_FUNC },
{ JUDY_MASTER_LOAD_STR , JUDY_MASTER_LOAD_FUNC },
#endif
#ifdef JUDY_MASTER_AMOUNT_FUNCTIONS
{ JUDY_MASTER_COUNT_STR , JUDY_MASTER_COUNT_FUNC },
{ JUDY_MASTER_BYCOUNT_STR , JUDY_MASTER_BYCOUNT_FUNC },
#endif
#ifdef JUDY_SLAVE_AMOUNT_FUNCTIONS
{ JUDY_SLAVE_COUNT_STR , JUDY_SLAVE_COUNT_FUNC },
{ JUDY_SLAVE_BYCOUNT_STR , JUDY_SLAVE_BYCOUNT_FUNC },
#endif
#ifdef JUDY_SLAVE_EDIT_FUNCTIONS
{ JUDY_SLAVE_MEMORY_STR , JUDY_SLAVE_MEMORY_FUNC },
{ JUDY_SLAVE_ISFILLED_STR , JUDY_SLAVE_ISFILLED_FUNC },
{ JUDY_SLAVE_ISEMPTY_STR , JUDY_SLAVE_ISEMPTY_FUNC },
{ JUDY_SLAVE_REMOVE_STR , JUDY_SLAVE_REMOVE_FUNC },
#ifdef JUDY_SLAVE_EDIT_BOOL
{ JUDY_SLAVE_GET_BOOL_STR , JUDY_SLAVE_GET_BOOL_FUNC },
{ JUDY_SLAVE_SET_BOOL_STR , JUDY_SLAVE_SET_BOOL_FUNC },
#endif
#ifdef JUDY_SLAVE_EDIT_INT
{ JUDY_SLAVE_GET_INT_STR , JUDY_SLAVE_GET_INT_FUNC },
{ JUDY_SLAVE_SET_INT_STR , JUDY_SLAVE_SET_INT_FUNC },
#endif
#ifdef JUDY_SLAVE_EDIT_FLO
{ JUDY_SLAVE_GET_FLO_STR , JUDY_SLAVE_GET_FLO_FUNC },
{ JUDY_SLAVE_SET_FLO_STR , JUDY_SLAVE_SET_FLO_FUNC },
#endif
#ifdef JUDY_SLAVE_EDIT_STR
{ JUDY_SLAVE_GET_STR_STR , JUDY_SLAVE_GET_STR_FUNC },
{ JUDY_SLAVE_SET_STR_STR , JUDY_SLAVE_SET_STR_FUNC },
#endif
#ifdef JUDY_SLAVE_EDIT_VEC
{ JUDY_SLAVE_GET_VEC_STR , JUDY_SLAVE_GET_VEC_FUNC },
{ JUDY_SLAVE_SET_VEC_STR , JUDY_SLAVE_SET_VEC_FUNC },
#endif
// End all edit functions
#endif
#ifdef JUDY_SLAVE_SEARCH_FUNCTIONS
{ JUDY_SLAVE_FIRST_STR , JUDY_SLAVE_FIRST_FUNC },
{ JUDY_SLAVE_LAST_STR , JUDY_SLAVE_LAST_FUNC },
{ JUDY_SLAVE_NEXT_STR , JUDY_SLAVE_NEXT_FUNC },
{ JUDY_SLAVE_PREV_STR , JUDY_SLAVE_PREV_FUNC },
#endif
#ifdef JUDY_SLAVE_SEARCH_EMPTY_FUNCTIONS
{ JUDY_SLAVE_FIRSTEMPTY_STR , JUDY_SLAVE_FIRSTEMPTY_FUNC },
{ JUDY_SLAVE_LASTEMPTY_STR , JUDY_SLAVE_LASTEMPTY_FUNC },
{ JUDY_SLAVE_NEXTEMPTY_STR , JUDY_SLAVE_NEXTEMPTY_FUNC },
{ JUDY_SLAVE_PREVEMPTY_STR , JUDY_SLAVE_PREVEMPTY_FUNC },
#endif
{ NULL, NULL }
};
#endif

View File

@ -0,0 +1,58 @@
#ifndef _NATIVE_FUNC_INC_H
#define _NATIVE_FUNC_INC_H
#define JUDY_GLUE_FUNC( x , y ) x ## y
#define JUDY_MASTER_FUNCTIONS
#define JUDY_MASTER_CREATE_FUNC JUDY_GLUE_FUNC( array , _create )
#define JUDY_MASTER_CLEAR_FUNC JUDY_GLUE_FUNC( array , _clear )
#define JUDY_MASTER_DELETE_FUNC JUDY_GLUE_FUNC( array , _delete )
#define JUDY_MASTER_IO_FUNCTIONS
#define JUDY_MASTER_SAVE_FUNC JUDY_GLUE_FUNC( array , _save )
#define JUDY_MASTER_LOAD_FUNC JUDY_GLUE_FUNC( array , _load )
#define JUDY_MASTER_AMOUNT_FUNCTIONS
#define JUDY_MASTER_COUNT_FUNC JUDY_GLUE_FUNC( array , _count )
#define JUDY_MASTER_BYCOUNT_FUNC JUDY_GLUE_FUNC( array , _bycount )
#define JUDY_MASTER_MEMORY_FUNC JUDY_GLUE_FUNC( array , _memory )
#define JUDY_SLAVE_AMOUNT_FUNCTIONS
#define JUDY_SLAVE_COUNT_FUNC JUDY_GLUE_FUNC( array , _size )
#define JUDY_SLAVE_BYCOUNT_FUNC JUDY_GLUE_FUNC( array , _get_nth )
#define JUDY_SLAVE_EDIT_FUNCTIONS
#define JUDY_SLAVE_GET_BOOL_FUNC JUDY_GLUE_FUNC( array , _get_bool )
#define JUDY_SLAVE_SET_BOOL_FUNC JUDY_GLUE_FUNC( array , _set_bool )
#define JUDY_SLAVE_GET_INT_FUNC JUDY_GLUE_FUNC( array , _get_int )
#define JUDY_SLAVE_SET_INT_FUNC JUDY_GLUE_FUNC( array , _set_int )
#define JUDY_SLAVE_GET_FLO_FUNC JUDY_GLUE_FUNC( array , _get_float )
#define JUDY_SLAVE_SET_FLO_FUNC JUDY_GLUE_FUNC( array , _set_float )
#define JUDY_SLAVE_GET_STR_FUNC JUDY_GLUE_FUNC( array , _get_string )
#define JUDY_SLAVE_SET_STR_FUNC JUDY_GLUE_FUNC( array , _set_string )
#define JUDY_SLAVE_GET_VEC_FUNC JUDY_GLUE_FUNC( array , _get_vector )
#define JUDY_SLAVE_SET_VEC_FUNC JUDY_GLUE_FUNC( array , _set_vector )
#define JUDY_SLAVE_ISFILLED_FUNC JUDY_GLUE_FUNC( array , _isfilled )
#define JUDY_SLAVE_ISEMPTY_FUNC JUDY_GLUE_FUNC( array , _isempty )
#define JUDY_SLAVE_REMOVE_FUNC JUDY_GLUE_FUNC( array , _remove )
#define JUDY_SLAVE_SEARCH_FUNCTIONS
#define JUDY_SLAVE_GET_FIRST_FUNC JUDY_GLUE_FUNC( array , _first )
#define JUDY_SLAVE_SET_LAST_FUNC JUDY_GLUE_FUNC( array , _last )
#define JUDY_SLAVE_GET_NEXT_FUNC JUDY_GLUE_FUNC( array , _next )
#define JUDY_SLAVE_SET_PREV_FUNC JUDY_GLUE_FUNC( array , _prev )
#define JUDY_SLAVE_SEARCH_EMPTY_FUNCTIONS
#define JUDY_SLAVE_GET_FIRSTEMPTY_FUNC JUDY_GLUE_FUNC( array , _firstempty )
#define JUDY_SLAVE_SET_LASTEMPTY_FUNC JUDY_GLUE_FUNC( array , _lastempty )
#define JUDY_SLAVE_GET_NEXTEMPTY_FUNC JUDY_GLUE_FUNC( array , _nextempty )
#define JUDY_SLAVE_SET_PREVEMPTY_FUNC JUDY_GLUE_FUNC( array , _prevempty )
#endif