New update! 3.1 is liiiive!
Error handling: Array now has sufficiently advanced error handling to remove most, if not all, disable_checks. Extention: With the metaprogramming techniques, new types can be added easily. Speed: With the new changes I've made to Judy, the Array module has far exceeded the speed of any traditional datatype
This commit is contained in:
130
dlls/arrayx/NativeIncludes.h
Normal file
130
dlls/arrayx/NativeIncludes.h
Normal file
@ -0,0 +1,130 @@
|
||||
#ifndef _NATIVE_INC_H
|
||||
#define _NATIVE_INC_H
|
||||
|
||||
#include "ComboArray.h"
|
||||
|
||||
#ifndef SEARCH_ERROR_OFFSET
|
||||
#define SEARCH_ERROR_OFFSET 0
|
||||
#endif
|
||||
|
||||
#define SE_OFFSET SEARCH_ERROR_OFFSET
|
||||
|
||||
#ifndef STORAGE_TYPE
|
||||
#error No storage type declared
|
||||
#endif
|
||||
|
||||
#define STYPE STORAGE_TYPE
|
||||
|
||||
#ifndef KEY_TYPE
|
||||
#error No key type declared
|
||||
#endif
|
||||
|
||||
#define ITYPE KEY_TYPE
|
||||
|
||||
#ifndef DYNAMIC_UNIT_TYPE
|
||||
#error No Dynamic type declared
|
||||
#endif
|
||||
|
||||
#define DTYPE DYNAMIC_UNIT_TYPE
|
||||
|
||||
#ifndef MASTER_NAME
|
||||
#error No master name declared
|
||||
#endif
|
||||
|
||||
#define MNAME MASTER_NAME
|
||||
#define M_ITYPE cell
|
||||
|
||||
#ifndef GET_KEY
|
||||
#error No method of getting keys has been declared
|
||||
#endif
|
||||
|
||||
#ifndef EXPORT_NAME
|
||||
#define EXPORT_NAME MNAME_exports
|
||||
#endif
|
||||
|
||||
#define SE_OFFSET SEARCH_ERROR_OFFSET
|
||||
|
||||
#define JUDY_GET_KEY GET_KEY
|
||||
|
||||
#ifndef SET_KEY
|
||||
#error No method of setting keys has been declared
|
||||
#endif
|
||||
|
||||
#define JUDY_SET_KEY SET_KEY
|
||||
|
||||
#ifndef JUDY_ERROR_CATCH
|
||||
#define JUDY_ERROR_CATCH(x_str) \
|
||||
catch(JudyEx& e) \
|
||||
{ \
|
||||
if(e.IsFatal() )\
|
||||
{\
|
||||
MF_LogError(amx,AMX_ERR_NATIVE, "%s || Judy Error: %s", x_str, e.ErrorMessage());\
|
||||
return NULL;\
|
||||
};\
|
||||
return NULL;\
|
||||
}\
|
||||
catch(...) { MF_LogError(amx,AMX_ERR_NATIVE,"Unknown error occured, please post a bug report at www.amxmodx.org/forums"); return NULL; }
|
||||
#endif
|
||||
|
||||
#ifndef JUDY_SEARCH_ERROR_CATCH
|
||||
#define JUDY_SEARCH_ERROR_CATCH(x_str, success) \
|
||||
catch(JudyEx& e) \
|
||||
{ \
|
||||
if(e.IsFatal() )\
|
||||
{\
|
||||
MF_LogError(amx,AMX_ERR_NATIVE, "%s || Judy Error: %s", x_str, e.ErrorMessage());\
|
||||
return NULL;\
|
||||
};\
|
||||
return (success = 0);\
|
||||
}\
|
||||
catch(...) { MF_LogError(amx,AMX_ERR_NATIVE,"Unknown error occured, please post a bug report at www.amxmodx.org/forums"); return NULL; }
|
||||
#endif
|
||||
|
||||
#ifndef JUDY_CREATE_INDEX
|
||||
#define JUDY_CREATE_INDEX(master, slave, slave_type, index)\
|
||||
\
|
||||
if( index == NULL )\
|
||||
{\
|
||||
try { index = master.FirstEmpty(); }\
|
||||
JUDY_ERROR_CATCH("Unable to create new unit (out of memory)");\
|
||||
\
|
||||
slave = new slave_type;\
|
||||
master.Set(index,slave);\
|
||||
} \
|
||||
else if(master.IsEmpty(index) )\
|
||||
{\
|
||||
slave = new slave_type;\
|
||||
master.Set(index,slave);\
|
||||
}\
|
||||
else slave = master.Get(index, slave );
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef JUDY_GET_INDEX
|
||||
#define JUDY_GET_INDEX(master,slave, where) \
|
||||
try { slave = master.Get(where,slave); } \
|
||||
JUDY_ERROR_CATCH("Unable to access old unit (invalid index)");
|
||||
#endif
|
||||
|
||||
#ifndef JUDY_SET_INDEX
|
||||
#define JUDY_SET_INDEX(master,slave, where) \
|
||||
try { master.Set(where,slave); } \
|
||||
JUDY_ERROR_CATCH("Unknown Error occured (No error possible) - Set Function");\
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
#ifndef JUDY_SET_INDEX_P
|
||||
#define JUDY_SET_INDEX_P(master,slave, where) \
|
||||
try { master->Set(where,slave); } \
|
||||
JUDY_ERROR_CATCH("Unknown Error occured (No error possible) - Set Function");\
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
inline char* JUDY_BUILD_PATH(AMX *amx, cell param, int buffer = 0)
|
||||
{
|
||||
char *file = MF_GetAmxString(amx, param, 0, NULL);
|
||||
return MF_BuildPathname("%s", file);
|
||||
}
|
||||
|
||||
#include "GenericNatives.h"
|
||||
#endif
|
Reference in New Issue
Block a user