Added support for Mac OS X and building with clang (bug 5601, r=dvander).

This commit is contained in:
Scott Ehlert
2013-02-13 01:14:37 -06:00
parent b0fe6c83e2
commit 40c1fee55a
191 changed files with 3835 additions and 1946 deletions

View File

@ -1,74 +1,124 @@
#(C)2004-2005 AMX Mod X Development Team
# (C)2004-2013 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson
HLSDK = ../../../hlsdk
###########################################
### EDIT THESE PATHS FOR YOUR OWN SETUP ###
###########################################
HLSDK = ../../../hlsdk/multiplayer
MM_ROOT = ../../../metamod/metamod
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
PROJECT = hamsandwich
OPT_FLAGS = -O3 -funroll-loops -s -pipe -fomit-frame-pointer -fno-strict-aliasing -DNDEBUG
OBJECTS = sdk/amxxmodule.cpp amxx_api.cpp config_parser.cpp hook_callbacks.cpp hook_native.cpp \
srvcmd.cpp call_funcs.cpp hook_create.cpp DataHandler.cpp pdata.cpp
DEBUG_FLAGS = -g -ggdb3
CPP = gcc-4.1
#CPP = gcc-2.95
NAME = hamsandwich
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
##############################################
BIN_SUFFIX = amxx_i386.so
C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -fomit-frame-pointer -pipe
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC4_FLAGS = -fvisibility=hidden
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
CPP = gcc
CPP_OSX = clang
OBJECTS = sdk/amxxmodule.cpp amxx_api.cpp config_parser.cpp \
hook_callbacks.cpp hook_native.cpp srvcmd.cpp \
call_funcs.cpp hook_create.cpp DataHandler.cpp pdata.cpp
LINK =
INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/common -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared \
-I$(HLSDK)/pm_shared -I$(MM_ROOT) -Isdk
LINK =
################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
################################################
INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \
-I$(MM_ROOT) -I$(HLSDK)/common -I$(HLSDK)/pm_shared -I./tableentries -Isdk
OS := $(shell uname -s)
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
ifeq "$(OS)" "Darwin"
CPP = $(CPP_OSX)
LIB_EXT = dylib
LIB_SUFFIX = _amxx
CFLAGS += -DOSX
LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5
else
LIB_EXT = so
LIB_SUFFIX = _amxx_i386
CFLAGS += -DLINUX
LINK += -shared
endif
LINK += -m32 -lm -ldl
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32 -DHAVE_STDINT_H -fno-strict-aliasing -m32 -Wall -Werror
CPPFLAGS += -fno-exceptions -fno-rtti
BINARY = $(PROJECT)$(LIB_SUFFIX).$(LIB_EXT)
ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS = $(DEBUG_FLAGS)
CFLAGS += $(C_DEBUG_FLAGS)
else
BIN_DIR = Release
ifeq "$(GCC_VERSION)" "4"
OPT_FLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
endif
CFLAGS = $(OPT_FLAGS)
CFLAGS += $(C_OPT_FLAGS)
LINK += -s
endif
CFLAGS += -Wall -Wno-non-virtual-dtor -fno-exceptions -DHAVE_STDINT_H -fno-rtti -Werror -m32
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
BINARY = $(NAME)_$(BIN_SUFFIX)
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
OPT_FLAGS += -march=i586
ifeq "$(IS_CLANG)" "1"
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
else
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
endif
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
# Clang || GCC >= 4
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
CFLAGS += $(C_GCC4_FLAGS)
CPPFLAGS += $(CPP_GCC4_FLAGS)
endif
# Clang >= 3 || GCC >= 4.7
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
CFLAGS += -Wno-delete-non-virtual-dtor
endif
# OS is Linux and not using clang
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
LINK += -static-libgcc
endif
OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
# This will break if we include other Makefiles, but is fine for now. It allows
# us to make a copy of this file that uses altered paths (ie. Makefile.mine)
# or other changes without mucking up the original.
MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
all:
mkdir -p $(BIN_DIR)
mkdir -p $(BIN_DIR)/sdk
$(MAKE) hamsandwich
$(MAKE) -f $(MAKEFILE_NAME) $(PROJECT)
hamsandwich: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
$(PROJECT): $(OBJ_BIN)
$(CPP) $(INCLUDE) $(OBJ_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY)
debug:
$(MAKE) all DEBUG=true
debug:
$(MAKE) -f $(MAKEFILE_NAME) all DEBUG=true
default: all
clean:
rm -rf Release/*.o
rm -rf Release/sdk/*.o
rm -rf Release/$(NAME)_$(BIN_SUFFIX)
rm -rf Debug/*.o
rm -rf Debug/sdk/*.o
rm -rf Debug/$(NAME)_$(BIN_SUFFIX)
rm -rf $(BIN_DIR)/*.o
rm -rf $(BIN_DIR)/sdk/*.o
rm -f $(BIN_DIR)/$(BINARY)

View File

@ -46,10 +46,12 @@
#endif // offsetof
#endif // _MSC_VER >= 1400
#include <windows.h>
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
#include <sys/mman.h>
#if defined (__linux__)
#include <malloc.h>
#endif
#endif
#include <stddef.h> // size_t
#include <string.h> // memcpy
#include <stdlib.h> // memalign
@ -113,14 +115,14 @@ namespace Trampolines
* pushes it onto the target's stack.
*/
const unsigned char codePushThis[] = {
#if defined _WIN32
#if defined(_WIN32)
0x51 // push ecx
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
0xFF, 0x75, 0x04 // pushl [ebp+0x08h]
#endif
};
#if defined __linux__
#if defined(__linux__) || defined(__APPLE__)
const int codePushThisReplace = 2;
#endif
@ -410,7 +412,7 @@ namespace Trampolines
memcpy(&code[0],&::Trampolines::Bytecode::codePushThis[0],sizeof(::Trampolines::Bytecode::codePushThis));
#if defined __linux__
#if defined(__linux__) || defined(__APPLE__)
unsigned char *c=&code[0];
union
@ -427,7 +429,7 @@ namespace Trampolines
Append(&code[0],sizeof(::Trampolines::Bytecode::codePushThis));
#if defined __linux__
#if defined(__linux__) || defined(__APPLE__)
m_mystack+=4;
#endif
m_calledstack+=4;
@ -531,7 +533,7 @@ namespace Trampolines
*/
void PushParam(int which)
{
#if defined __linux__
#if defined(__linux__) || defined(__APPLE__)
if (m_thiscall)
{
which++;
@ -608,10 +610,14 @@ namespace Trampolines
}
// Reallocate with proper flags
#if defined _WIN32
#if defined(_WIN32)
void *ret=VirtualAlloc(NULL, m_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#elif defined __linux__
#elif defined(__GNUC__)
# if defined(__APPLE__)
void *ret = valloc(m_size);
# else
void *ret=memalign(sysconf(_SC_PAGESIZE), m_size);
# endif
mprotect(ret,m_size,PROT_READ|PROT_WRITE|PROT_EXEC);
#endif
memcpy(ret, m_buffer, m_size);
@ -675,17 +681,17 @@ inline void *CreateGenericTrampoline(bool thiscall, bool voidcall, int paramcoun
tramp.FreeTargetStack();
if (voidcall)
{
#if defined _WIN32
#if defined(_WIN32)
tramp.VoidEpilogueAndFree();
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
tramp.VoidEpilogue();
#endif
}
else
{
#if defined _WIN32
#if defined(_WIN32)
tramp.ReturnEpilogueAndFree();
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
tramp.ReturnEpilogue();
#endif
}

View File

@ -79,8 +79,10 @@ void OnAmxxAttach(void)
{
#ifdef _WIN32
MF_Log("Error: pev and base not set for section \"%s windows\", cannot register natives.", MF_GetModname());
#elif defined __linux__
#elif defined(__linux__)
MF_Log("Error: pev and base not set for section \"%s linux\", cannot register natives.", MF_GetModname());
#elif defined(__APPLE__)
MF_Log("Error: pev and base not set for section \"%s mac\", cannot register natives.", MF_GetModname());
#endif
}
}

View File

@ -114,9 +114,9 @@ cell Call_Void_Void(AMX *amx, cell *params)
{
SETUP(0);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int)>(__func)(pv, 0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *)>(__func)(pv);
#endif
return 1;
@ -126,9 +126,9 @@ cell Call_Int_Void(AMX *amx, cell *params)
{
SETUP(0);
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void*, int)>(__func)(pv, 0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *)>(__func)(pv);
#endif
}
@ -143,9 +143,9 @@ cell Call_Void_Entvar(AMX *amx, cell *params)
entvars_t *ev1=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *)>(__func)(pv, 0, ev1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, entvars_t *)>(__func)(pv, ev1);
#endif
return 1;
@ -162,9 +162,9 @@ cell Call_Void_Cbase(AMX *amx, cell *params)
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, void *)>(__func)(pv, 0, pv1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, void *)>(__func)(pv, pv1);
#endif
return 1;
@ -177,9 +177,9 @@ cell Call_Int_Float_Int(AMX *amx, cell *params)
float f3=amx_ftoc2(*MF_GetAmxAddr(amx, params[3]));
int i4=*MF_GetAmxAddr(amx, params[4]);
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void*, int, float, int)>(__func)(pv, 0, f3, i4);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, float, int)>(__func)(pv, f3, i4);
#endif
}
@ -196,9 +196,9 @@ cell Call_Void_Entvar_Int(AMX *amx, cell *params)
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *, int)>(__func)(pv, 0, ev3, i4);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, entvars_t *, int)>(__func)(pv, ev3, i4);
#endif
return 1;
@ -215,9 +215,9 @@ cell Call_Int_Cbase(AMX *amx, cell *params)
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData);
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void*, int, void *)>(__func)(pv, 0, pv1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, void *)>(__func)(pv, pv1);
#endif
}
@ -229,9 +229,9 @@ cell Call_Void_Int_Int(AMX *amx, cell *params)
int i3=*MF_GetAmxAddr(amx, params[3]);
int i4=*MF_GetAmxAddr(amx, params[4]);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, int, int)>(__func)(pv, 0, i3, i4);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, int, int)>(__func)(pv, i3, i4);
#endif
return 1;
@ -246,9 +246,9 @@ cell Call_Int_Int_Str_Int(AMX *amx, cell *params)
char *sz4=MF_GetAmxString(amx, params[4], 0, NULL);
int i5=*MF_GetAmxAddr(amx, params[5]);
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void*, int, int, const char *, int)>(__func)(pv, 0, i3, sz4, i5);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, int, const char *, int)>(__func)(pv, i3, sz4, i5);
#endif
}
@ -259,9 +259,9 @@ cell Call_Int_Int(AMX *amx, cell *params)
int i3=*MF_GetAmxAddr(amx, params[3]);
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void*, int, int)>(__func)(pv, 0, i3);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, int)>(__func)(pv, i3);
#endif
}
@ -276,9 +276,9 @@ cell Call_Int_Entvar(AMX *amx, cell *params)
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *)>(__func)(pv, 0, ev3);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, entvars_t *)>(__func)(pv, ev3);
#endif
}
@ -298,9 +298,9 @@ cell Call_Int_Entvar_Entvar_Float_Int(AMX *amx, cell *params)
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
entvars_t *ev4=&(INDEXENT_NEW(id4)->v);
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, int)>(__func)(pv, 0, ev3, ev4, f5, i6);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, entvars_t *, entvars_t *, float, int)>(__func)(pv, ev3, ev4, f5, i6);
#endif
}
@ -321,9 +321,9 @@ cell Call_Int_Entvar_Entvar_Float_Float_Int(AMX *amx, cell *params)
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
entvars_t *ev4=&(INDEXENT_NEW(id4)->v);
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, float, int)>(__func)(pv, 0, ev3, ev4, f5, f6, i7);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, entvars_t *, entvars_t *, float, float, int)>(__func)(pv, ev3, ev4, f5, f6, i7);
#endif
}
@ -334,9 +334,9 @@ cell Call_Void_Int(AMX *amx, cell *params)
int i3=*MF_GetAmxAddr(amx, params[3]);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, int)>(__func)(pv, 0, i3);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, int)>(__func)(pv, i3);
#endif
@ -358,9 +358,9 @@ cell Call_Void_Cbase_Cbase_Int_Float(AMX *amx, cell *params)
void *p3=IndexToPrivate(id3);
void *p4=IndexToPrivate(id4);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, void *, void *, int, float)>(__func)(pv, 0, p3, p4, i5, f6);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, void *, void *, int, float)>(__func)(pv, p3, p4, i5, f6);
#endif
@ -392,9 +392,9 @@ cell Call_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, cell *params)
CHECK_ENTITY(id3);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, Vector, TraceResult *, int)>(__func)(pv, 0, ev3, f4, v5, tr6, i7);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, entvars_t *, float, Vector, TraceResult *, int)>(__func)(pv, ev3, f4, v5, tr6, i7);
#endif
@ -422,9 +422,9 @@ cell Call_Void_Float_Vector_Trace_Int(AMX *amx, cell *params)
return 0;
}
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, float, Vector, TraceResult *, int)>(__func)(pv, 0, f3, v4, tr5, i6);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, float, Vector, TraceResult *, int)>(__func)(pv, f3, v4, tr5, i6);
#endif
@ -435,9 +435,9 @@ cell Call_Str_Void(AMX *amx, cell *params)
{
SETUP(2);
#ifdef _WIN32
#if defined(_WIN32)
char *v=reinterpret_cast<char *(__fastcall *)(void *, int)>(__func)(pv, 0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
char *v=reinterpret_cast<char *(*)(void *)>(__func)(pv);
#endif
return MF_SetAmxString(amx, params[3], v == NULL ? "" : v, *MF_GetAmxAddr(amx, params[4]));
@ -447,9 +447,9 @@ cell Call_Str_Void(AMX *amx, cell *params)
cell Call_Cbase_Void(AMX *amx, cell *params)
{
SETUP(0);
#ifdef _WIN32
#if defined(_WIN32)
void *ret=reinterpret_cast<void *(__fastcall *)(void *, int)>(__func)(pv, 0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
void *ret=reinterpret_cast<void *(*)(void *)>(__func)(pv);
#endif
return PrivateToIndex(ret);
@ -458,9 +458,9 @@ cell Call_Cbase_Void(AMX *amx, cell *params)
cell Call_Vector_Void(AMX *amx, cell *params)
{
SETUP(1);
#ifdef _WIN32
#if defined(_WIN32)
Vector ret=reinterpret_cast<Vector (__fastcall *)(void *, int)>(__func)(pv, 0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
Vector ret=reinterpret_cast<Vector (*)(void *)>(__func)(pv);
#endif
float *out=(float *)MF_GetAmxAddr(amx, params[3]);
@ -481,9 +481,9 @@ cell Call_Vector_pVector(AMX *amx, cell *params)
v3.y=fl3[1];
v3.z=fl3[2];
#ifdef _WIN32
#if defined(_WIN32)
Vector ret=reinterpret_cast<Vector (__fastcall *)(void *, int, Vector*)>(__func)(pv, 0, &v3);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
Vector ret=reinterpret_cast<Vector (*)(void *, Vector*)>(__func)(pv, &v3);
#endif
float *out=(float *)MF_GetAmxAddr(amx, params[4]);
@ -508,9 +508,9 @@ cell Call_Int_pVector(AMX *amx, cell *params)
v3.y=fl3[1];
v3.z=fl3[2];
#ifdef _WIN32
#if defined(_WIN32)
int ret=reinterpret_cast<int (__fastcall *)(void *, int, Vector*)>(__func)(pv, 0, &v3);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
int ret=reinterpret_cast<int (*)(void *, Vector*)>(__func)(pv, &v3);
#endif
@ -533,9 +533,9 @@ cell Call_Void_Entvar_Float_Float(AMX *amx, cell *params)
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, float)>(__func)(pv, 0, ev3, f4, f5);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, entvars_t *, float, float)>(__func)(pv, ev3, f4, f5);
#endif
@ -549,9 +549,9 @@ cell Call_Int_pFloat_pFloat(AMX *amx, cell *params)
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3]));
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4]));
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, float*, float*)>(__func)(pv, 0, &f3, &f4);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, float*, float*)>(__func)(pv, &f3, &f4);
#endif
@ -568,9 +568,9 @@ cell Call_Void_Entvar_Float(AMX *amx, cell *params)
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32
#if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t*, float)>(__func)(pv, 0, ev3, f4);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
return reinterpret_cast<int (*)(void *, entvars_t*, float)>(__func)(pv, ev3, f4);
#endif
}
@ -583,9 +583,9 @@ cell Call_Void_Int_Int_Int(AMX *amx, cell *params)
int i4=*MF_GetAmxAddr(amx, params[4]);
int i5=*MF_GetAmxAddr(amx, params[5]);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, int, int, int)>(__func)(pv, 0, i3, i4, i5);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, int, int, int)>(__func)(pv, i3, i4, i5);
#endif
return 1;
@ -602,9 +602,9 @@ cell Call_Void_ItemInfo(AMX *amx, cell *params)
MF_LogError(amx, AMX_ERR_NATIVE, "Null ItemInfo handle!");
return 0;
}
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, void *)>(__func)(pv, 0, ptr);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, void *)>(__func)(pv, ptr);
#endif
return 1;
@ -614,9 +614,9 @@ cell Call_Float_Void(AMX *amx, cell *params)
{
SETUP(1);
#ifdef _WIN32
#if defined(_WIN32)
float ret=reinterpret_cast<float (__fastcall *)(void*, int)>(__func)(pv, 0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
float ret=reinterpret_cast<float (*)(void *)>(__func)(pv);
#endif
*MF_GetAmxAddr(amx, params[3])=amx_ftoc2(ret);
@ -628,9 +628,9 @@ cell Call_Void_Float_Int(AMX* amx, cell* params)
{
SETUP(2);
#ifdef _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, float, char)>(__func)(pv, 0, amx_ctof2(params[3]), static_cast<char>(params[4]));
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, float, char)>(__func)(pv, amx_ctof2(params[3]), static_cast<char>(params[4]));
#endif
return 1;

View File

@ -37,7 +37,7 @@
; use the same binary so all of its vtable offsets are guaranteed to
; be identical. Mirrors should always come first in the file!
;
; Version: $Id$
; Version: $Id: hamdata.ini 3687 2008-03-04 18:51:35Z sawce $
@mirror cstrike czero
@ -261,6 +261,116 @@
cstrike_item_candrop 63
cstrike_item_getmaxspeed 78
@end
@section cstrike mac
pev 4
base 0x0
spawn 0
precache 1
keyvalue 3
objectcaps 6
activate 7
setobjectcollisionbox 8
classify 9
deathnotice 10
traceattack 11
takedamage 12
takehealth 13
killed 14
bloodcolor 15
tracebleed 16
istriggered 17
mymonsterpointer 18
mysquadmonsterpointer 19
gettogglestate 20
addpoints 21
addpointstoteam 22
addplayeritem 23
removeplayeritem 24
giveammo 25
getdelay 26
ismoving 27
overridereset 28
damagedecal 29
settogglestate 30
startsneaking 31
stopsneaking 32
oncontrols 33
issneaking 34
isalive 35
isbspmodel 36
reflectgauss 37
hastarget 38
isinworld 39
isplayer 40
isnetclient 41
teamid 42
getnexttarget 43
think 44
touch 45
use 46
blocked 47
respawn 48
updateowner 49
fbecomeprone 50
center 51
eyeposition 52
earposition 53
bodytarget 54
illumination 55
fvisible 56
fvecvisible 57
player_jump 76
player_duck 77
player_prethink 78
player_postthink 79
player_getgunposition 80
player_shouldfadeondeath 66
player_impulsecommands 83
player_updateclientdata 82
item_addtoplayer 59
item_addduplicate 60
item_getiteminfo 61
item_candeploy 62
item_deploy 64
item_canholster 66
item_holster 67
item_updateiteminfo 68
item_preframe 69
item_postframe 70
item_drop 71
item_kill 72
item_attachtoplayer 73
item_primaryammoindex 74
item_secondaryammoindex 75
item_updateclientdata 76
item_getweaponptr 77
item_itemslot 79
weapon_extractammo 80
weapon_extractclipammo 81
weapon_addweapon 82
weapon_playemptysound 83
weapon_resetemptysound 84
weapon_sendweaponanim 85
weapon_isusable 86
weapon_primaryattack 87
weapon_secondaryattack 88
weapon_reload 89
weapon_weaponidle 90
weapon_retireweapon 91
weapon_shouldweaponidle 92
weapon_usedecrement 93
cstrike_restart 2
cstrike_roundrespawn 84
cstrike_item_candrop 63
cstrike_item_getmaxspeed 78
@end
@section dod linux
pev 0
base 0x154
@ -1747,8 +1857,112 @@
weapon_retireweapon 87
weapon_shouldweaponidle 88
weapon_usedecrement 89
@end
@section valve mac
pev 4
base 0x0
spawn 0
precache 1
keyvalue 2
objectcaps 5
activate 6
setobjectcollisionbox 7
classify 8
deathnotice 9
traceattack 10
takedamage 11
takehealth 12
killed 13
bloodcolor 14
tracebleed 15
istriggered 16
mymonsterpointer 17
mysquadmonsterpointer 18
gettogglestate 19
addpoints 20
addpointstoteam 21
addplayeritem 22
removeplayeritem 23
giveammo 24
getdelay 25
ismoving 26
overridereset 27
damagedecal 28
settogglestate 29
startsneaking 30
stopsneaking 31
oncontrols 32
issneaking 33
isalive 34
isbspmodel 35
reflectgauss 36
hastarget 37
isinworld 38
isplayer 39
isnetclient 40
teamid 41
getnexttarget 42
think 43
touch 44
use 45
blocked 46
respawn 47
updateowner 48
fbecomeprone 49
center 50
eyeposition 51
earposition 52
bodytarget 53
illumination 54
fvisible 55
fvecvisible 56
player_jump 125
player_duck 126
player_prethink 127
player_postthink 128
player_getgunposition 119
player_shouldfadeondeath 60
player_impulsecommands 130
player_updateclientdata 129
item_addtoplayer 58
item_addduplicate 59
item_getiteminfo 60
item_candeploy 61
item_deploy 62
item_canholster 63
item_holster 64
item_updateiteminfo 65
item_preframe 66
item_postframe 67
item_drop 68
item_kill 69
item_attachtoplayer 70
item_primaryammoindex 71
item_secondaryammoindex 72
item_updateclientdata 73
item_getweaponptr 74
item_itemslot 75
weapon_extractammo 76
weapon_extractclipammo 77
weapon_addweapon 78
weapon_playemptysound 79
weapon_resetemptysound 80
weapon_sendweaponanim 81
weapon_isusable 82
weapon_primaryattack 83
weapon_secondaryattack 84
weapon_reload 85
weapon_weaponidle 86
weapon_retireweapon 87
weapon_shouldweaponidle 88
weapon_usedecrement 89
@end
; Sven-Coop has no linux binaries. This makes disassembly much harder.
; These offsets were contributed by ts2do
@section SvenCoop windows

View File

@ -240,8 +240,10 @@ int read_start_section(char *data)
#ifdef _WIN32
if (strcmp(data, "windows")==0)
#elif defined __linux__
#elif defined(__linux__)
if (strcmp(data, "linux")==0)
#elif defined(__APPLE__)
if (strcmp(data, "mac")==0)
#endif
{
return 1;

View File

@ -64,10 +64,10 @@ public:
tramp=CreateGenericTrampoline(true, voidcall, paramcount, (void*)this, target);
// Insert into vtable
#if defined _WIN32
#if defined(_WIN32)
DWORD OldFlags;
VirtualProtect(&ivtable[entry],sizeof(int*),PAGE_READWRITE,&OldFlags);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
void *addr = (void *)ALIGN(&ivtable[entry]);
mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE);
#endif
@ -84,18 +84,18 @@ public:
// Insert the original function back into the vtable
int **ivtable=(int **)vtable;
#if defined _WIN32
#if defined(_WIN32)
DWORD OldFlags;
VirtualProtect(&ivtable[entry],sizeof(int*),PAGE_READWRITE,&OldFlags);
#elif defined __linux_
#elif defined(__linux_) || defined(__APPLE__)
void *addr = (void *)ALIGN(&ivtable[entry]);
mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE);
#endif
ivtable[entry]=(int *)func;
#if defined _WIN32
#if defined(_WIN32)
VirtualFree(tramp, 0, MEM_RELEASE);
#elif __linux__
#elif defined(__linux__) || defined(__APPLE__)
free(tramp);
#endif

View File

@ -166,9 +166,9 @@ void Hook_Void_Void(Hook *hook, void *pthis)
PRE_START()
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*,int)>(hook->func)(pthis,0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*)>(hook->func)(pthis);
#endif
@ -192,9 +192,9 @@ int Hook_Int_Void(Hook *hook, void *pthis)
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void*,int)>(hook->func)(pthis,0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void*)>(hook->func)(pthis);
#endif
@ -222,9 +222,9 @@ void Hook_Void_Entvar(Hook *hook, void *pthis, entvars_t *entvar)
, iOther
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, entvars_t *)>(hook->func)(pthis, 0, entvar);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, entvars_t *)>(hook->func)(pthis, entvar);
#endif
@ -250,9 +250,9 @@ void Hook_Void_Cbase(Hook *hook, void *pthis, void *other)
, iOther
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, void *)>(hook->func)(pthis, 0, other);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, void *)>(hook->func)(pthis, other);
#endif
@ -279,9 +279,9 @@ int Hook_Int_Float_Int(Hook *hook, void *pthis, float f1, int i1)
, f1, i1
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void*, int, float, int)>(hook->func)(pthis, 0, f1, i1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void*, float, int)>(hook->func)(pthis, f1, i1);
#endif
@ -309,9 +309,9 @@ void Hook_Void_Entvar_Int(Hook *hook, void *pthis, entvars_t *ev1, int i1)
, iOther, i1
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, entvars_t *, int)>(hook->func)(pthis, 0, ev1, i1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, entvars_t *, int)>(hook->func)(pthis, ev1, i1);
#endif
@ -339,9 +339,9 @@ int Hook_Int_Cbase(Hook *hook, void *pthis, void *cb1)
PRE_START()
, iOther
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void*, int, void *)>(hook->func)(pthis, 0, cb1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void*, void *)>(hook->func)(pthis, cb1);
#endif
@ -367,9 +367,9 @@ void Hook_Void_Int_Int(Hook *hook, void *pthis, int i1, int i2)
PRE_START()
,i1, i2
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, int, int)>(hook->func)(pthis, 0, i1, i2);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, int, int)>(hook->func)(pthis, i1, i2);
#endif
@ -398,9 +398,9 @@ int Hook_Int_Int_Str_Int(Hook *hook, void *pthis, int i1, const char *sz1, int i
PRE_START()
,i1, a.c_str(), i2
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void*, int, int, const char *, int)>(hook->func)(pthis, 0, i1, a.c_str(), i2);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void*, int, const char *, int)>(hook->func)(pthis, i1, a.c_str(), i2);
#endif
@ -429,9 +429,9 @@ int Hook_Int_Int(Hook *hook, void *pthis, int i1)
,i1
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void*, int, int)>(hook->func)(pthis, 0, i1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void*, int)>(hook->func)(pthis, i1);
#endif
@ -460,9 +460,9 @@ int Hook_Int_Entvar(Hook *hook, void *pthis, entvars_t *ev1)
,iOther
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void*, int, entvars_t *)>(hook->func)(pthis, 0, ev1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void*, entvars_t *)>(hook->func)(pthis, ev1);
#endif
@ -497,9 +497,9 @@ int Hook_Int_Entvar_Entvar_Float_Int(Hook *hook, void *pthis, entvars_t *inflict
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void*, int, entvars_t *, entvars_t *, float, int)>(hook->func)(pthis, 0, inflictor, attacker, damage, damagebits);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void*, entvars_t *, entvars_t *, float, int)>(hook->func)(pthis, inflictor, attacker, damage, damagebits);
#endif
@ -532,9 +532,9 @@ int Hook_Int_Entvar_Entvar_Float_Float_Int(Hook *hook, void *pthis, entvars_t *i
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void*, int, entvars_t *, entvars_t *, float, float, int)>(hook->func)(pthis, 0, inflictor, attacker, damage, unknown, damagebits);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void*, entvars_t *, entvars_t *, float, float, int)>(hook->func)(pthis, inflictor, attacker, damage, unknown, damagebits);
#endif
@ -559,9 +559,9 @@ void Hook_Void_Int(Hook *hook, void *pthis, int i1)
, i1
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, int)>(hook->func)(pthis, 0, i1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, int)>(hook->func)(pthis, i1);
#endif
@ -590,9 +590,9 @@ void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1, void *c
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, void *, void *, int, float)>(hook->func)(pthis, 0, cb1, cb2, i1, f1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, void *, void *, int, float)>(hook->func)(pthis, cb1, cb2, i1, f1);
#endif
@ -620,9 +620,9 @@ void Hook_Void_Entvar_Float_Vector_Trace_Int(Hook *hook, void *pthis, entvars_t
,iev1, f1, MF_PrepareCellArrayA(reinterpret_cast<cell *>(&v1), 3, false), tr1, i1
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, entvars_t *, float, Vector, TraceResult *, int)>(hook->func)(pthis, 0, ev1, f1, v1, tr1, i1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, entvars_t *, float, Vector, TraceResult *, int)>(hook->func)(pthis, ev1, f1, v1, tr1, i1);
#endif
@ -648,9 +648,9 @@ void Hook_Void_Float_Vector_Trace_Int(Hook *hook, void *pthis, float f1, Vector
, f1, MF_PrepareCellArrayA(reinterpret_cast<cell *>(&v1), 3, false), tr1, i1
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, float, Vector, TraceResult *, int)>(hook->func)(pthis, 0, f1, v1, tr1, i1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, float, Vector, TraceResult *, int)>(hook->func)(pthis, f1, v1, tr1, i1);
#endif
@ -672,9 +672,9 @@ const char *Hook_Str_Void(Hook *hook, void *pthis)
PRE_START()
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret.assign(reinterpret_cast<const char *(__fastcall*)(void*, int)>(hook->func)(pthis, 0));
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret.assign(reinterpret_cast<const char *(*)(void*)>(hook->func)(pthis));
#endif
@ -699,9 +699,9 @@ void *Hook_Cbase_Void(Hook *hook, void *pthis)
PRE_START()
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<void *(__fastcall*)(void*, int)>(hook->func)(pthis, 0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<void *(*)(void*)>(hook->func)(pthis);
#endif
@ -717,7 +717,7 @@ void *Hook_Cbase_Void(Hook *hook, void *pthis)
#ifdef _WIN32
void Hook_Vector_Void(Hook *hook, void *pthis, Vector *out)
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis)
#endif
{
@ -734,9 +734,9 @@ void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis)
PRE_START()
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, Vector *)>(hook->func)(pthis, 0, &origret);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<Vector (*)(void *)>(hook->func)(pthis);
#endif
@ -751,7 +751,7 @@ void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis)
}
#ifdef _WIN32
void Hook_Vector_pVector(Hook *hook, void *pthis, Vector *out, Vector *v1)
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1)
#endif
{
@ -770,9 +770,9 @@ void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1)
, MF_PrepareCellArrayA(reinterpret_cast<cell *>(v1), 3, false)
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, Vector *, Vector *)>(hook->func)(pthis, 0, &origret, v1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<Vector (*)(void*, Vector *)>(hook->func)(pthis, v1);
#endif
@ -800,9 +800,9 @@ int Hook_Int_pVector(Hook *hook, void *pthis, Vector *v1)
, MF_PrepareCellArrayA(reinterpret_cast<cell *>(v1), 3, false)
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void*, int, Vector *)>(hook->func)(pthis, 0, v1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void*, Vector *)>(hook->func)(pthis, v1);
#endif
@ -831,9 +831,9 @@ void Hook_Void_Entvar_Float_Float(Hook *hook, void *pthis, entvars_t *ev1, float
, cev1, f1, f2
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void *, int, entvars_t *, float, float)>(hook->func)(pthis, 0, ev1, f1, f2);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, entvars_t *, float, float)>(hook->func)(pthis, ev1, f1, f2);
#endif
@ -860,9 +860,9 @@ int Hook_Int_pFloat_pFloat(Hook *hook, void *pthis, float *f1, float *f2)
, f1 != NULL ? *f1 : 0, f2 != NULL ? *f2 : 0
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<int (__fastcall*)(void *, int, float *, float *)>(hook->func)(pthis, 0, f1, f2);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<int (*)(void *, float *, float *)>(hook->func)(pthis, f1, f2);
#endif
@ -889,9 +889,9 @@ void Hook_Void_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1)
, cev1, f1
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void *, int, entvars_t *, float)>(hook->func)(pthis, 0, ev1, f1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void *, entvars_t *, float)>(hook->func)(pthis, ev1, f1);
#endif
@ -916,9 +916,9 @@ void Hook_Void_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2, int i3)
PRE_START()
,i1, i2, i3
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, int, int, int)>(hook->func)(pthis, 0, i1, i2, i3);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, int, int, int)>(hook->func)(pthis, i1, i2, i3);
#endif
@ -940,9 +940,9 @@ void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo)
PRE_START()
,iteminfo
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, void *)>(hook->func)(pthis, 0, iteminfo);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, void *)>(hook->func)(pthis, iteminfo);
#endif
@ -964,9 +964,9 @@ float Hook_Float_Void(Hook *hook, void *pthis)
PRE_START()
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
origret=reinterpret_cast<float (__fastcall*)(void*, int)>(hook->func)(pthis, 0);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
origret=reinterpret_cast<float (*)(void*)>(hook->func)(pthis);
#endif
@ -990,9 +990,9 @@ void Hook_Void_Float_Int(Hook* hook, void* pthis, float f1, int i1)
PRE_START()
, f1, i1
PRE_END()
#if defined _WIN32
#if defined(_WIN32)
reinterpret_cast<void (__fastcall*)(void*, int, float, int)>(hook->func)(pthis, 0, f1, i1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
reinterpret_cast<void (*)(void*, float, int)>(hook->func)(pthis, f1, i1);
#endif

View File

@ -130,7 +130,7 @@ const bool RT_Vector_Void = true;
const int PC_Vector_Void = 1;
#ifdef _WIN32
void Hook_Vector_Void(Hook *hook, void *pthis, Vector *out);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis);
#endif
@ -138,7 +138,7 @@ const bool RT_Vector_pVector = true;
const int PC_Vector_pVector = 2;
#ifdef _WIN32
void Hook_Vector_pVector(Hook *hook, void *pthis, Vector *out, Vector *v1);
#elif defined __linux__
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1);
#endif

View File

@ -57,6 +57,12 @@ static cell AMX_NATIVE_CALL get_pdata_cbase_safe(AMX *amx, cell *params)
int iOffset=params[2];
#ifdef __linux__
iOffset += params[3];
#elif defined __APPLE__
// Use Linux offset in older plugins
if (params[0] / sizeof(cell) == 3)
iOffset += params[3];
else
iOffset += params[4];
#endif
if (iOffset <0)
{
@ -87,7 +93,14 @@ static cell AMX_NATIVE_CALL get_pdata_cbase(AMX *amx, cell *params)
int iOffset=params[2];
#ifdef __linux__
iOffset += params[3];
#elif defined __APPLE__
// Use Linux offset in older plugins
if (params[0] / sizeof(cell) == 3)
iOffset += params[3];
else
iOffset += params[4];
#endif
if (iOffset <0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset);
@ -110,6 +123,12 @@ static cell AMX_NATIVE_CALL set_pdata_cbase(AMX *amx, cell *params)
int iOffset=params[2];
#ifdef __linux__
iOffset += params[4];
#elif defined __APPLE__
// Use Linux offset in older plugins
if (params[0] / sizeof(cell) == 4)
iOffset += params[4];
else
iOffset += params[5];
#endif
if (iOffset <0)
{

View File

@ -244,7 +244,7 @@ public:
if (is_space(v[len-1]))
{
for (i=len-1; i>=0; i--)
for (i=len-1; i<len; i--)
{
if (!is_space(v[i])
|| (is_space(v[i]) && i==0))

View File

@ -2240,7 +2240,7 @@ static META_FUNCTIONS g_MetaFunctions_Table =
GetEngineFunctions_Post
};
C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs)
C_DLLEXPORT int Meta_Query(const char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs)
{
if ((int) CVAR_GET_FLOAT("developer") != 0)
UTIL_LogPrintf("[%s] dev: called: Meta_Query; version=%s, ours=%s\n",
@ -2334,7 +2334,7 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
// linux prototype
C_DLLEXPORT void GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) {
@ -3050,7 +3050,7 @@ char* UTIL_VarArgs( char *format, ... )
// UTIL_LogPrintf - Prints a logged message to console.
// Preceded by LOG: ( timestamp ) < message >
//=========================================================
void UTIL_LogPrintf( char *fmt, ... )
void UTIL_LogPrintf( const char *fmt, ... )
{
va_list argptr;
static char string[1024];

View File

@ -20,11 +20,16 @@
// DLL Export
#undef DLLEXPORT
#ifndef __linux__
#if defined(_WIN32)
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __attribute__((visibility("default")))
#endif
#if defined(__linux__) && !defined(LINUX)
#define LINUX
#elif defined(__APPLE__) && !defined(OSX)
#define OSX
#endif
#undef C_DLLEXPORT
@ -66,7 +71,7 @@ struct amxx_module_info_s
#if defined HAVE_STDINT_H
#include <stdint.h>
#else
#if defined __LCC__ || defined __DMC__ || defined LINUX
#if defined __LCC__ || defined __DMC__ || defined LINUX || defined __APPLE__
#if defined HAVE_INTTYPES_H
#include <inttypes.h>
#else
@ -308,7 +313,7 @@ typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx);
#endif
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
#pragma pack(1) /* structures must be packed (byte-aligned) */
#elif defined MACOS && defined __MWERKS__
#pragma options align=mac68k
@ -395,7 +400,7 @@ enum {
};
#if !defined AMX_NO_ALIGN
#if defined __linux__
#if defined(__linux__) || defined(__APPLE__)
#pragma pack() /* reset default packing */
#else
#pragma pack(pop) /* reset previous packing */
@ -406,7 +411,7 @@ enum {
// ***** declare functions *****
#ifdef USE_METAMOD
void UTIL_LogPrintf( char *fmt, ... );
void UTIL_LogPrintf( const char *fmt, ... );
void UTIL_HudMessage(CBaseEntity *pEntity, const hudtextparms_t &textparms, const char *pMessage);
short FixedSigned16( float value, float scale );
unsigned short FixedUnsigned16( float value, float scale );
@ -833,11 +838,11 @@ int FN_AllowLagCompensation_Post(void);
#ifdef FN_PrecacheModel
int FN_PrecacheModel(char *s);
int FN_PrecacheModel(const char *s);
#endif // FN_PrecacheModel
#ifdef FN_PrecacheSound
int FN_PrecacheSound(char *s);
int FN_PrecacheSound(const char *s);
#endif // FN_PrecacheSound
#ifdef FN_SetModel
@ -857,7 +862,7 @@ void FN_SetSize(edict_t *e, const float *rgflMin, const float *rgflMax);
#endif // FN_SetSize
#ifdef FN_ChangeLevel
void FN_ChangeLevel(char *s1, char *s2);
void FN_ChangeLevel(const char *s1, const char *s2);
#endif // FN_ChangeLevel
#ifdef FN_GetSpawnParms
@ -1261,19 +1266,19 @@ char *FN_GetInfoKeyBuffer(edict_t *e);
#endif // FN_GetInfoKeyBuffer
#ifdef FN_InfoKeyValue
char *FN_InfoKeyValue(char *infobuffer, char *key);
char *FN_InfoKeyValue(char *infobuffer, const char *key);
#endif // FN_InfoKeyValue
#ifdef FN_SetKeyValue
void FN_SetKeyValue(char *infobuffer, char *key, char *value);
void FN_SetKeyValue(char *infobuffer, const char *key, const char *value);
#endif // FN_SetKeyValue
#ifdef FN_SetClientKeyValue
void FN_SetClientKeyValue(int clientIndex, char *infobuffer, char *key, char *value);
void FN_SetClientKeyValue(int clientIndex, char *infobuffer, const char *key, const char *value);
#endif // FN_SetClientKeyValue
#ifdef FN_IsMapValid
int FN_IsMapValid(char *filename);
int FN_IsMapValid(const char *filename);
#endif // FN_IsMapValid
#ifdef FN_StaticDecal
@ -1281,7 +1286,7 @@ void FN_StaticDecal(const float *origin, int decalIndex, int entityIndex, int mo
#endif // FN_StaticDecal
#ifdef FN_PrecacheGeneric
int FN_PrecacheGeneric(char *s);
int FN_PrecacheGeneric(const char *s);
#endif // FN_PrecacheGeneric
#ifdef FN_GetPlayerUserId
@ -1414,11 +1419,11 @@ const char *FN_GetPlayerAuthId(edict_t *e);
#ifdef FN_PrecacheModel_Post
int FN_PrecacheModel_Post(char *s);
int FN_PrecacheModel_Post(const char *s);
#endif // FN_PrecacheModel_Post
#ifdef FN_PrecacheSound_Post
int FN_PrecacheSound_Post(char *s);
int FN_PrecacheSound_Post(const char *s);
#endif // FN_PrecacheSound_Post
#ifdef FN_SetModel_Post
@ -1438,7 +1443,7 @@ void FN_SetSize_Post(edict_t *e, const float *rgflMin, const float *rgflMax);
#endif // FN_SetSize_Post
#ifdef FN_ChangeLevel_Post
void FN_ChangeLevel_Post(char *s1, char *s2);
void FN_ChangeLevel_Post(const char *s1, const char *s2);
#endif // FN_ChangeLevel_Post
#ifdef FN_GetSpawnParms_Post
@ -1842,19 +1847,19 @@ char *FN_GetInfoKeyBuffer_Post(edict_t *e);
#endif // FN_GetInfoKeyBuffer_Post
#ifdef FN_InfoKeyValue_Post
char *FN_InfoKeyValue_Post(char *infobuffer, char *key);
char *FN_InfoKeyValue_Post(char *infobuffer, const char *key);
#endif // FN_InfoKeyValue_Post
#ifdef FN_SetKeyValue_Post
void FN_SetKeyValue_Post(char *infobuffer, char *key, char *value);
void FN_SetKeyValue_Post(char *infobuffer, const char *key, const char *value);
#endif // FN_SetKeyValue_Post
#ifdef FN_SetClientKeyValue_Post
void FN_SetClientKeyValue_Post(int clientIndex, char *infobuffer, char *key, char *value);
void FN_SetClientKeyValue_Post(int clientIndex, char *infobuffer, const char *key, const char *value);
#endif // FN_SetClientKeyValue_Post
#ifdef FN_IsMapValid_Post
int FN_IsMapValid_Post(char *filename);
int FN_IsMapValid_Post(const char *filename);
#endif // FN_IsMapValid_Post
#ifdef FN_StaticDecal_Post
@ -1862,7 +1867,7 @@ void FN_StaticDecal_Post(const float *origin, int decalIndex, int entityIndex, i
#endif // FN_StaticDecal_Post
#ifdef FN_PrecacheGeneric_Post
int FN_PrecacheGeneric_Post(char *s);
int FN_PrecacheGeneric_Post(const char *s);
#endif // FN_PrecacheGeneric_Post
#ifdef FN_GetPlayerUserId_Post
@ -2116,7 +2121,7 @@ typedef int (*PFN_ADD_NEW_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef void (*PFN_PRINT_SRVCONSOLE) (const char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void);
typedef const char * (*PFN_GET_AMXSCRIPTNAME) (int /*id*/);
typedef AMX * (*PFN_GET_AMXSCRIPT) (int /*id*/);
@ -2175,8 +2180,8 @@ typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned i
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/);
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
typedef int (*PFN_AMX_FINDNATIVE) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, const char* /*func name*/, int* /*index*/);
typedef int (*PFN_AMX_FINDNATIVE) (AMX* /*amx*/, const char* /*func name*/, int* /*index*/);
typedef int (*PFN_LOAD_AMXSCRIPT) (AMX* /*amx*/, void** /*code*/, const char* /*path*/, char[64] /*error info*/, int /* debug */);
typedef int (*PFN_UNLOAD_AMXSCRIPT) (AMX* /*amx*/,void** /*code*/);
typedef cell (*PFN_REAL_TO_CELL) (REAL /*x*/);

View File

@ -43,7 +43,7 @@
extern hook_t hooklist[];
extern CVector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
void print_srvconsole(char *fmt, ...)
void print_srvconsole(const char *fmt, ...)
{
va_list argptr;
static char string[384];