mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
PM: Added 64bit compatibility
dvander: Fixed minor bugs
This commit is contained in:
parent
8e8633a49a
commit
6dc00f64f8
@ -71,6 +71,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
if (iter->pPlugin->isExecutable(iter->func))
|
if (iter->pPlugin->isExecutable(iter->func))
|
||||||
{
|
{
|
||||||
// handle strings & arrays
|
// handle strings & arrays
|
||||||
|
AMXXLOG_Log("String handling");
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < m_NumParams; ++i)
|
for (i = 0; i < m_NumParams; ++i)
|
||||||
{
|
{
|
||||||
@ -105,13 +106,16 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
realParams[i] = params[i];
|
realParams[i] = params[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AMXXLOG_Log("Exec");
|
||||||
// exec
|
// exec
|
||||||
cell retVal;
|
cell retVal;
|
||||||
|
AMXXLOG_Log("Entering exec");
|
||||||
int err = amx_Execv(iter->pPlugin->getAMX(), &retVal, iter->func, m_NumParams, realParams);
|
int err = amx_Execv(iter->pPlugin->getAMX(), &retVal, iter->func, m_NumParams, realParams);
|
||||||
// log runtime error, if any
|
// log runtime error, if any
|
||||||
if (err != AMX_ERR_NONE)
|
if (err != AMX_ERR_NONE)
|
||||||
AMXXLOG_Log("[AMXX] Run time error %d on line %ld (plugin \"%s\")", err, iter->pPlugin->getAMX()->curline, iter->pPlugin->getName());
|
AMXXLOG_Log("[AMXX] Run time error %d on line %ld (plugin \"%s\")", err, iter->pPlugin->getAMX()->curline, iter->pPlugin->getName());
|
||||||
|
|
||||||
|
AMXXLOG_Log("Cleanup strings");
|
||||||
// cleanup strings & arrays
|
// cleanup strings & arrays
|
||||||
for (i = 0; i < m_NumParams; ++i)
|
for (i = 0; i < m_NumParams; ++i)
|
||||||
{
|
{
|
||||||
@ -236,6 +240,7 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
|
|
||||||
// exec
|
// exec
|
||||||
cell retVal;
|
cell retVal;
|
||||||
|
AMXXLOG_Log("Entering exec2");
|
||||||
amx_Execv(m_Amx, &retVal, m_Func, m_NumParams, realParams);
|
amx_Execv(m_Amx, &retVal, m_Func, m_NumParams, realParams);
|
||||||
|
|
||||||
// cleanup strings & arrays
|
// cleanup strings & arrays
|
||||||
|
@ -90,6 +90,7 @@ protected:
|
|||||||
T *m_Data;
|
T *m_Data;
|
||||||
size_t m_Size;
|
size_t m_Size;
|
||||||
size_t m_CurrentUsedSize;
|
size_t m_CurrentUsedSize;
|
||||||
|
size_t m_CurrentSize;
|
||||||
public:
|
public:
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
@ -397,7 +398,7 @@ public:
|
|||||||
if (where != m_Data)
|
if (where != m_Data)
|
||||||
--where;
|
--where;
|
||||||
// validate iter
|
// validate iter
|
||||||
if (where < m_Data || where >= (m_Data + m_CurrentSize))
|
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
++m_CurrentUsedSize;
|
++m_CurrentUsedSize;
|
||||||
@ -415,7 +416,7 @@ public:
|
|||||||
void erase(iterator where)
|
void erase(iterator where)
|
||||||
{
|
{
|
||||||
// validate iter
|
// validate iter
|
||||||
if (where < m_Data || where >= (m_Data + m_CurrentSize))
|
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_CurrentUsedSize > 1)
|
if (m_CurrentUsedSize > 1)
|
||||||
@ -438,3 +439,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // __CVECTOR_H__
|
#endif // __CVECTOR_H__
|
||||||
|
|
||||||
|
@ -3,7 +3,9 @@ SRCFILES = meta_api.cpp CFile.cpp CString.cpp CVault.cpp vault.cpp\
|
|||||||
float.cpp file.cpp modules.cpp CMisc.cpp CTask.cpp string.cpp\
|
float.cpp file.cpp modules.cpp CMisc.cpp CTask.cpp string.cpp\
|
||||||
amxmodx.cpp CEvent.cpp CCmd.cpp CLogEvent.cpp srvcmd.cpp strptime.cpp\
|
amxmodx.cpp CEvent.cpp CCmd.cpp CLogEvent.cpp srvcmd.cpp strptime.cpp\
|
||||||
CForward.cpp CPlugin.cpp CModule.cpp CMenu.cpp emsg.cpp util.cpp \
|
CForward.cpp CPlugin.cpp CModule.cpp CMenu.cpp emsg.cpp util.cpp \
|
||||||
amx.cpp amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp mmgr/mmgr.cpp
|
amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp mmgr/mmgr.cpp \
|
||||||
|
amxxfile.cpp
|
||||||
|
CSRCFILES = amx.c minilzo/minilzo.c
|
||||||
|
|
||||||
EXTRA_LIBS_LINUX =
|
EXTRA_LIBS_LINUX =
|
||||||
EXTRA_LIBS_WIN32 =
|
EXTRA_LIBS_WIN32 =
|
||||||
@ -44,7 +46,7 @@ endif
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
LIBFILE_LINUX = $(MODNAME)_i386.so
|
LIBFILE_LINUX = $(MODNAME)_amd64.so
|
||||||
LIBFILE_WIN32 = $(MODNAME).dll
|
LIBFILE_WIN32 = $(MODNAME).dll
|
||||||
TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX)
|
TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX)
|
||||||
TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32)
|
TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32)
|
||||||
@ -61,7 +63,7 @@ OBJ_WIN32 := $(SRCFILES:%.cpp=$(OBJDIR_WIN32)/%.o)
|
|||||||
OBJC_WIN32 := $(CSRCFILES:%.c=$(OBJDIR_WIN32)/%.o)
|
OBJC_WIN32 := $(CSRCFILES:%.c=$(OBJDIR_WIN32)/%.o)
|
||||||
|
|
||||||
|
|
||||||
CCOPT = -march=i386 -O2 -s -DNDEBUG
|
CCOPT = -m64 -g -ggdb3 -DHAVE_I64
|
||||||
|
|
||||||
INCLUDEDIRS=-I../curl/include -I$(SRCDIR) -I$(METADIR) -I$(SDKSRC)/engine -I$(SDKSRC)/common -I$(SDKSRC)/pm_shared -I$(SDKSRC)/dlls -I$(SDKSRC) $(EXTRA_INCLUDEDIRS)
|
INCLUDEDIRS=-I../curl/include -I$(SRCDIR) -I$(METADIR) -I$(SDKSRC)/engine -I$(SDKSRC)/common -I$(SDKSRC)/pm_shared -I$(SDKSRC)/dlls -I$(SDKSRC) $(EXTRA_INCLUDEDIRS)
|
||||||
CFLAGS=-Wall -Wno-unknown-pragmas
|
CFLAGS=-Wall -Wno-unknown-pragmas
|
||||||
@ -70,7 +72,7 @@ CFLAGS:=$(CCOPT) $(CFLAGS) $(ODEF) $(EXTRA_FLAGS)
|
|||||||
|
|
||||||
DO_CC_LINUX=$(CC_LINUX) $(CFLAGS) -fPIC $(INCLUDEDIRS) -o $@ -c $<
|
DO_CC_LINUX=$(CC_LINUX) $(CFLAGS) -fPIC $(INCLUDEDIRS) -o $@ -c $<
|
||||||
DO_CC_WIN32=$(CC_WIN32) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $<
|
DO_CC_WIN32=$(CC_WIN32) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $<
|
||||||
LINK_LINUX=$(CC_LINUX) $(CFLAGS) -shared -ldl -lm $(OBJ_LINUX) $(OBJC_LINUX) $(EXTRA_LIBDIRS_LINUX) $(EXTRA_LIBS_LINUX) jits.o -o $@
|
LINK_LINUX=$(CC_LINUX) $(CFLAGS) -shared -ldl -lm $(OBJ_LINUX) $(OBJC_LINUX) $(EXTRA_LIBDIRS_LINUX) $(EXTRA_LIBS_LINUX) -o $@
|
||||||
LINK_WIN32=$(LD_WINDLL) -mwindows --def $(MODNAME).def --add-stdcall-alias $(OBJ_WIN32) $(OBJC_WIN32) $(EXTRA_LIBDIRS_WIN32) $(EXTRA_LIBS_WIN32) -o $@
|
LINK_WIN32=$(LD_WINDLL) -mwindows --def $(MODNAME).def --add-stdcall-alias $(OBJ_WIN32) $(OBJC_WIN32) $(EXTRA_LIBDIRS_WIN32) $(EXTRA_LIBS_WIN32) -o $@
|
||||||
|
|
||||||
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.c
|
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.c
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// not used
|
// not used
|
||||||
|
#include <stdio.h>
|
||||||
#define AMX_NODYNALOAD
|
#define AMX_NODYNALOAD
|
||||||
|
|
||||||
// bad bad workaround but we have to prevent a compiler crash :/
|
// bad bad workaround but we have to prevent a compiler crash :/
|
||||||
@ -274,8 +275,8 @@ typedef enum {
|
|||||||
} OPCODE;
|
} OPCODE;
|
||||||
|
|
||||||
typedef struct tagFUNCSTUBNT {
|
typedef struct tagFUNCSTUBNT {
|
||||||
uint32_t address PACKED;
|
ucell address PACKED;
|
||||||
uint32_t nameofs PACKED;
|
ucell nameofs PACKED;
|
||||||
} FUNCSTUBNT PACKED;
|
} FUNCSTUBNT PACKED;
|
||||||
|
|
||||||
#define USENAMETABLE(hdr) \
|
#define USENAMETABLE(hdr) \
|
||||||
@ -373,7 +374,7 @@ uint16_t *amx_Align16(uint16_t *v)
|
|||||||
|
|
||||||
uint32_t *amx_Align32(uint32_t *v)
|
uint32_t *amx_Align32(uint32_t *v)
|
||||||
{
|
{
|
||||||
assert(sizeof(cell)==4);
|
assert(sizeof(*v)==4);
|
||||||
init_little_endian();
|
init_little_endian();
|
||||||
if (!amx_LittleEndian)
|
if (!amx_LittleEndian)
|
||||||
swap32(v);
|
swap32(v);
|
||||||
@ -383,7 +384,7 @@ uint32_t *amx_Align32(uint32_t *v)
|
|||||||
#if defined _I64_MAX || defined HAVE_I64
|
#if defined _I64_MAX || defined HAVE_I64
|
||||||
uint64_t *amx_Align64(uint64_t *v)
|
uint64_t *amx_Align64(uint64_t *v)
|
||||||
{
|
{
|
||||||
assert(sizeof(cell)==8);
|
assert(sizeof(*v)==8);
|
||||||
init_little_endian();
|
init_little_endian();
|
||||||
if (!amx_LittleEndian)
|
if (!amx_LittleEndian)
|
||||||
swap64(v);
|
swap64(v);
|
||||||
@ -436,7 +437,6 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
|
|||||||
func=GETENTRY(hdr,natives,index);
|
func=GETENTRY(hdr,natives,index);
|
||||||
f=(AMX_NATIVE)func->address;
|
f=(AMX_NATIVE)func->address;
|
||||||
assert(f!=NULL);
|
assert(f!=NULL);
|
||||||
|
|
||||||
/* now that we have found the function, patch the program so that any
|
/* now that we have found the function, patch the program so that any
|
||||||
* subsequent call will call the function directly (bypassing this
|
* subsequent call will call the function directly (bypassing this
|
||||||
* callback)
|
* callback)
|
||||||
@ -468,6 +468,7 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
|
|||||||
|
|
||||||
amx->error=AMX_ERR_NONE;
|
amx->error=AMX_ERR_NONE;
|
||||||
*result= f(amx,params);
|
*result= f(amx,params);
|
||||||
|
|
||||||
return amx->error;
|
return amx->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,9 +950,9 @@ int AMXAPI amx_Init(AMX *amx,void *program)
|
|||||||
assert(hdr->publics<=hdr->natives);
|
assert(hdr->publics<=hdr->natives);
|
||||||
num=NUMENTRIES(hdr,publics,natives);
|
num=NUMENTRIES(hdr,publics,natives);
|
||||||
for (i=0; i<num; i++) {
|
for (i=0; i<num; i++) {
|
||||||
amx_Align32(&fs->address);
|
amx_AlignCell(&fs->address);
|
||||||
if (USENAMETABLE(hdr))
|
if (USENAMETABLE(hdr))
|
||||||
amx_Align32(&((FUNCSTUBNT*)fs)->nameofs);
|
amx_AlignCell(&((FUNCSTUBNT*)fs)->nameofs);
|
||||||
fs=(AMX_FUNCSTUB*)((unsigned char *)fs+hdr->defsize);
|
fs=(AMX_FUNCSTUB*)((unsigned char *)fs+hdr->defsize);
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
@ -959,9 +960,9 @@ int AMXAPI amx_Init(AMX *amx,void *program)
|
|||||||
assert(hdr->pubvars<=hdr->tags);
|
assert(hdr->pubvars<=hdr->tags);
|
||||||
num=NUMENTRIES(hdr,pubvars,tags);
|
num=NUMENTRIES(hdr,pubvars,tags);
|
||||||
for (i=0; i<num; i++) {
|
for (i=0; i<num; i++) {
|
||||||
amx_Align32(&fs->address);
|
amx_AlignCell(&fs->address);
|
||||||
if (USENAMETABLE(hdr))
|
if (USENAMETABLE(hdr))
|
||||||
amx_Align32(&((FUNCSTUBNT*)fs)->nameofs);
|
amx_AlignCell(&((FUNCSTUBNT*)fs)->nameofs);
|
||||||
fs=(AMX_FUNCSTUB*)((unsigned char *)fs+hdr->defsize);
|
fs=(AMX_FUNCSTUB*)((unsigned char *)fs+hdr->defsize);
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
@ -974,9 +975,9 @@ int AMXAPI amx_Init(AMX *amx,void *program)
|
|||||||
num=NUMENTRIES(hdr,tags,nametable);
|
num=NUMENTRIES(hdr,tags,nametable);
|
||||||
} /* if */
|
} /* if */
|
||||||
for (i=0; i<num; i++) {
|
for (i=0; i<num; i++) {
|
||||||
amx_Align32(&fs->address);
|
amx_AlignCell(&fs->address);
|
||||||
if (USENAMETABLE(hdr))
|
if (USENAMETABLE(hdr))
|
||||||
amx_Align32(&((FUNCSTUBNT*)fs)->nameofs);
|
amx_AlignCell(&((FUNCSTUBNT*)fs)->nameofs);
|
||||||
fs=(AMX_FUNCSTUB*)((unsigned char *)fs+hdr->defsize);
|
fs=(AMX_FUNCSTUB*)((unsigned char *)fs+hdr->defsize);
|
||||||
} /* for */
|
} /* for */
|
||||||
} /* if */
|
} /* if */
|
||||||
@ -1591,7 +1592,7 @@ int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
|
|||||||
/* this function is not yet located */
|
/* this function is not yet located */
|
||||||
funcptr=(list!=NULL) ? findfunction(GETENTRYNAME(hdr,func),list,number) : NULL;
|
funcptr=(list!=NULL) ? findfunction(GETENTRYNAME(hdr,func),list,number) : NULL;
|
||||||
if (funcptr!=NULL)
|
if (funcptr!=NULL)
|
||||||
func->address=(uint32_t)funcptr;
|
func->address=(ucell)funcptr;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
no_function = GETENTRYNAME(hdr,func);
|
no_function = GETENTRYNAME(hdr,func);
|
||||||
@ -1788,6 +1789,7 @@ static void *amx_opcodelist_nodebug[] = {
|
|||||||
amx->debug(amx);
|
amx->debug(amx);
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
|
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
assert(OP_PUSH_PRI==36);
|
assert(OP_PUSH_PRI==36);
|
||||||
assert(OP_PROC==46);
|
assert(OP_PROC==46);
|
||||||
@ -1830,6 +1832,7 @@ static void *amx_opcodelist_nodebug[] = {
|
|||||||
/* check stack/heap before starting to run */
|
/* check stack/heap before starting to run */
|
||||||
CHKMARGIN();
|
CHKMARGIN();
|
||||||
|
|
||||||
|
|
||||||
/* start running */
|
/* start running */
|
||||||
NEXT(cip);
|
NEXT(cip);
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
#include <sclinux.h>
|
#include <sclinux.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SMALL_CELL_SIZE 64
|
||||||
|
#undef JIT
|
||||||
|
|
||||||
#ifndef AMX_H_INCLUDED
|
#ifndef AMX_H_INCLUDED
|
||||||
#define AMX_H_INCLUDED
|
#define AMX_H_INCLUDED
|
||||||
|
|
||||||
@ -179,7 +182,7 @@ typedef struct {
|
|||||||
#define sNAMEMAX 31 /* maximum name length of symbol name */
|
#define sNAMEMAX 31 /* maximum name length of symbol name */
|
||||||
|
|
||||||
typedef struct tagAMX_FUNCSTUB {
|
typedef struct tagAMX_FUNCSTUB {
|
||||||
uint32_t address PACKED;
|
ucell address PACKED;
|
||||||
const char name[sEXPMAX+1] PACKED;
|
const char name[sEXPMAX+1] PACKED;
|
||||||
} AMX_FUNCSTUB;
|
} AMX_FUNCSTUB;
|
||||||
|
|
||||||
@ -335,6 +338,13 @@ uint32_t * AMXAPI amx_Align32(uint32_t *v);
|
|||||||
#if defined _I64_MAX || defined HAVE_I64
|
#if defined _I64_MAX || defined HAVE_I64
|
||||||
uint64_t * AMXAPI amx_Align64(uint64_t *v);
|
uint64_t * AMXAPI amx_Align64(uint64_t *v);
|
||||||
#endif
|
#endif
|
||||||
|
#if SMALL_CELL_SIZE==32
|
||||||
|
#define amx_AlignCell amx_Align32
|
||||||
|
#elif SMALL_CELL_SIZE==64
|
||||||
|
#define amx_AlignCell amx_Align64
|
||||||
|
#else
|
||||||
|
#error Unsupported cell size
|
||||||
|
#endif
|
||||||
int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
|
int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
|
||||||
int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params);
|
int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params);
|
||||||
int AMXAPI amx_Cleanup(AMX *amx);
|
int AMXAPI amx_Cleanup(AMX *amx);
|
||||||
|
@ -1322,9 +1322,9 @@ static cell AMX_NATIVE_CALL read_data(AMX *amx, cell *params) /* 3 param */
|
|||||||
return set_amxstring(amx,params[2], g_events.getArgString( params[1] ),*get_amxaddr(amx,params[3]));
|
return set_amxstring(amx,params[2], g_events.getArgString( params[1] ),*get_amxaddr(amx,params[3]));
|
||||||
default:
|
default:
|
||||||
cell *fCell = get_amxaddr(amx,params[2]);
|
cell *fCell = get_amxaddr(amx,params[2]);
|
||||||
float *pFloat = (REAL *)((void *)fCell);
|
REAL pFloat = amx_ctof(fCell);
|
||||||
*pFloat = g_events.getArgFloat( params[1] );
|
pFloat = g_events.getArgFloat( params[1] );
|
||||||
return (int)(*pFloat);
|
return (int)(pFloat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1941,8 +1941,8 @@ static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param *
|
|||||||
cell *cpId = get_amxaddr(amx,params[2]);
|
cell *cpId = get_amxaddr(amx,params[2]);
|
||||||
cell *cpBody = get_amxaddr(amx,params[3]);
|
cell *cpBody = get_amxaddr(amx,params[3]);
|
||||||
cell fCell;
|
cell fCell;
|
||||||
float *pFloat = (REAL *)((void *)&fCell);
|
REAL pFloat = amx_ctof(fCell);
|
||||||
*pFloat = 0.0;
|
pFloat = 0.0;
|
||||||
if (pPlayer->ingame) {
|
if (pPlayer->ingame) {
|
||||||
edict_t* edict = pPlayer->pEdict;
|
edict_t* edict = pPlayer->pEdict;
|
||||||
Vector v_forward;
|
Vector v_forward;
|
||||||
@ -1967,7 +1967,7 @@ static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param *
|
|||||||
*cpId = FNullEnt(trEnd.pHit) ? 0 : ENTINDEX(trEnd.pHit);
|
*cpId = FNullEnt(trEnd.pHit) ? 0 : ENTINDEX(trEnd.pHit);
|
||||||
*cpBody = trEnd.iHitgroup;
|
*cpBody = trEnd.iHitgroup;
|
||||||
if (trEnd.flFraction < 1.0) {
|
if (trEnd.flFraction < 1.0) {
|
||||||
*pFloat = (trEnd.vecEndPos - v_src).Length();
|
pFloat = (trEnd.vecEndPos - v_src).Length();
|
||||||
return fCell;
|
return fCell;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -51,11 +51,15 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef lzo_byte mint8_t;
|
||||||
|
typedef int16_t mint16_t;
|
||||||
|
typedef int32_t mint32_t;
|
||||||
|
|
||||||
struct TableEntry
|
struct TableEntry
|
||||||
{
|
{
|
||||||
CAmxxReader::mint8_t cellSize PACKED;
|
mint8_t cellSize PACKED;
|
||||||
CAmxxReader::mint32_t origSize PACKED; // contains AMX_HEADER->stp
|
mint32_t origSize PACKED; // contains AMX_HEADER->stp
|
||||||
CAmxxReader::mint32_t offset PACKED;
|
mint32_t offset PACKED;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DATAREAD(addr, itemsize, itemcount) \
|
#define DATAREAD(addr, itemsize, itemcount) \
|
||||||
@ -136,7 +140,8 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
TableEntry entry;
|
TableEntry entry;
|
||||||
|
|
||||||
m_SectionHdrOffset = 0;
|
m_SectionHdrOffset = 0;
|
||||||
for (int i = 0; i < static_cast<int>(numOfPlugins); ++i)
|
int i = 0;
|
||||||
|
for (i = 0; i < static_cast<int>(numOfPlugins); ++i)
|
||||||
{
|
{
|
||||||
DATAREAD(&entry, sizeof(entry), 1);
|
DATAREAD(&entry, sizeof(entry), 1);
|
||||||
if (entry.cellSize == m_CellSize)
|
if (entry.cellSize == m_CellSize)
|
||||||
@ -154,7 +159,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// compute section length
|
// compute section length
|
||||||
if (i < static_cast<int>(numOfPlugins))
|
if ((i+1) < static_cast<int>(numOfPlugins))
|
||||||
{
|
{
|
||||||
// there is a next section
|
// there is a next section
|
||||||
TableEntry nextEntry;
|
TableEntry nextEntry;
|
||||||
@ -164,7 +169,7 @@ CAmxxReader::CAmxxReader(const char *filename, int cellsize)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fseek(m_pFile, 0, SEEK_END);
|
fseek(m_pFile, 0, SEEK_END);
|
||||||
m_SectionLength = ftell(m_pFile) - entry.offset;
|
m_SectionLength = ftell(m_pFile) - (long)entry.offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +47,6 @@ public:
|
|||||||
Err_Decompress
|
Err_Decompress
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef char mint8_t;
|
|
||||||
typedef short mint16_t;
|
|
||||||
typedef long mint32_t;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Error m_Status;
|
Error m_Status;
|
||||||
FILE *m_pFile;
|
FILE *m_pFile;
|
||||||
@ -71,3 +67,4 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
#endif // __AMXXFILE_H__
|
#endif // __AMXXFILE_H__
|
||||||
|
|
||||||
|
@ -35,7 +35,9 @@
|
|||||||
// 3 = HL Logs
|
// 3 = HL Logs
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#ifndef __linux__
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
#endif
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
|
|
||||||
CLog::CLog()
|
CLog::CLog()
|
||||||
|
@ -49,3 +49,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // __AMXXLOG_H__
|
#endif // __AMXXLOG_H__
|
||||||
|
|
||||||
|
@ -226,3 +226,4 @@ public:
|
|||||||
extern CFakeMeta g_FakeMeta;
|
extern CFakeMeta g_FakeMeta;
|
||||||
|
|
||||||
#endif // #ifndef __FAKEMETA_H__
|
#endif // #ifndef __FAKEMETA_H__
|
||||||
|
|
||||||
|
@ -390,8 +390,11 @@ void C_ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax )
|
|||||||
pPlayer->Init( pEdictList + i , i );
|
pPlayer->Init( pEdictList + i , i );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AMXXLOG_Log("BLABLA0");
|
||||||
executeForwards(FF_PluginInit);
|
executeForwards(FF_PluginInit);
|
||||||
|
AMXXLOG_Log("BLABLA1");
|
||||||
executeForwards(FF_PluginCfg);
|
executeForwards(FF_PluginCfg);
|
||||||
|
AMXXLOG_Log("BLABLA2");
|
||||||
|
|
||||||
// Correct time in Counter-Strike and other mods (except DOD)
|
// Correct time in Counter-Strike and other mods (except DOD)
|
||||||
if ( !g_bmod_dod) g_game_timeleft = 0;
|
if ( !g_bmod_dod) g_game_timeleft = 0;
|
||||||
|
@ -90,47 +90,6 @@ void free_amxmemory(void **ptr)
|
|||||||
|
|
||||||
int load_amxscript(AMX *amx, void **program, const char *filename, char error[64])
|
int load_amxscript(AMX *amx, void **program, const char *filename, char error[64])
|
||||||
{
|
{
|
||||||
/* :TODO: REMOVE
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
AMX_HEADER hdr;
|
|
||||||
|
|
||||||
memset(amx, 0, sizeof(*amx));
|
|
||||||
*program = 0;
|
|
||||||
*error = 0;
|
|
||||||
|
|
||||||
if ( (fp = fopen( filename, "rb" )) == NULL)
|
|
||||||
{
|
|
||||||
strcpy(error,"Plugin file open error");
|
|
||||||
return (amx->error = AMX_ERR_NOTFOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
fread(&hdr, sizeof(hdr), 1, fp);
|
|
||||||
|
|
||||||
amx_Align16(&hdr.magic);
|
|
||||||
|
|
||||||
if (hdr.magic!=AMX_MAGIC)
|
|
||||||
{
|
|
||||||
strcpy(error,"Invalid plugin");
|
|
||||||
return (amx->error = AMX_ERR_FORMAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
amx_Align32((uint32_t *)&hdr.stp);
|
|
||||||
amx_Align32((uint32_t *)&hdr.size);
|
|
||||||
|
|
||||||
if ( (*program = new unsigned char[ (int)hdr.stp ]) == 0 )
|
|
||||||
//if ( (*program = malloc( (int)hdr.stp )) == 0 )
|
|
||||||
{
|
|
||||||
strcpy(error,"Failed to allocate memory");
|
|
||||||
fclose(fp);
|
|
||||||
return (amx->error = AMX_ERR_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
rewind(fp);
|
|
||||||
fread(*program, 1, (size_t)hdr.size, fp);
|
|
||||||
fclose(fp);
|
|
||||||
*/
|
|
||||||
|
|
||||||
*error = 0;
|
*error = 0;
|
||||||
CAmxxReader reader(filename, SMALL_CELL_SIZE / 8);
|
CAmxxReader reader(filename, SMALL_CELL_SIZE / 8);
|
||||||
if (reader.GetStatus() == CAmxxReader::Err_None)
|
if (reader.GetStatus() == CAmxxReader::Err_None)
|
||||||
@ -242,6 +201,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_loadedscripts.put( aa );
|
g_loadedscripts.put( aa );
|
||||||
|
amx->sysreq_d = 0;
|
||||||
return set_amxnatives(amx,error);
|
return set_amxnatives(amx,error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +237,6 @@ int unload_amxscript(AMX* amx, void** program)
|
|||||||
CList<CScript,AMX*>::iterator a = g_loadedscripts.find( amx );
|
CList<CScript,AMX*>::iterator a = g_loadedscripts.find( amx );
|
||||||
if ( a ) a.remove();
|
if ( a ) a.remove();
|
||||||
delete[] *program;
|
delete[] *program;
|
||||||
//free( *program );
|
|
||||||
*program = 0;
|
*program = 0;
|
||||||
return AMX_ERR_NONE;
|
return AMX_ERR_NONE;
|
||||||
}
|
}
|
||||||
@ -983,3 +942,14 @@ void *Module_ReqFnptr(const char *funcName)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// :TODO: REMOVE!!!!!
|
||||||
|
extern "C" void amxx_print(const char * fmt, ...)
|
||||||
|
{
|
||||||
|
static char string[256];
|
||||||
|
|
||||||
|
va_list argptr;
|
||||||
|
va_start (argptr, fmt);
|
||||||
|
vsnprintf (string, 255, fmt, argptr);
|
||||||
|
va_end (argptr);
|
||||||
|
print_srvconsole(string);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user