diff --git a/sourcemm/sample_mm/Makefile b/sourcemm/sample_mm/Makefile new file mode 100644 index 0000000..46c09ee --- /dev/null +++ b/sourcemm/sample_mm/Makefile @@ -0,0 +1,57 @@ +#(C)2004-2005 SourceMM Development Team +# Makefile written by David "BAILOPAN" Anderson + +OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe +DEBUG_FLAGS = -g -ggdb3 +HL2SDK = ../../../hl2sdk +CPP = g++ +SMM_ROOT = ../../ +SRCDS = ~/srcds + +### NOTHING TO EDIT BELOW ### + +OBJECTS = SamplePlugin.cpp + +LINK = vstdlib_i486.so tier0_i486.so + +HL2PUB = $(HL2SDK)/public + +INCLUDE = -I. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)tier0 -I$(HL2PUB)/tier1 \ + -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SMM_ROOT) -I$(SMM_ROOT)/sourcehook -I$(SMM_ROOT)/sourcemm + +BINARY = sourcemm_i486.so + +ifeq "$(DEBUG)" "true" + BIN_DIR = Debug + CFLAGS = $(DEBUG_FLAGS) +else + BIN_DIR = Release + CFLAGS = $(OPT_FLAGS) +endif + +CFLAGS += -fpermissive -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -fPIC + +OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) + +$(BIN_DIR)/%.o: %.cpp + $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< + +all: + mkdir -p $(BIN_DIR) + ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so + ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so + $(MAKE) sourcemm + +sourcemm: $(OBJ_LINUX) + $(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) + +debug: + $(MAKE) all DEBUG=true + +default: all + +clean: + rm -rf Release/*.o + rm -rf Release/$(BINARY) + rm -rf Debug/*.o + rm -rf Debug/$(BINARY) diff --git a/sourcemm/sample_mm/SamplePlugin.cpp b/sourcemm/sample_mm/SamplePlugin.cpp index e5e2285..dbcbc7b 100644 --- a/sourcemm/sample_mm/SamplePlugin.cpp +++ b/sourcemm/sample_mm/SamplePlugin.cpp @@ -139,12 +139,6 @@ bool SamplePlugin::Load(PluginId id, ISmmAPI *ismm, factories *list, char *error //Hook ClientCommand to our function SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, m_ServerClients, &g_SamplePlugin, ClientCommand, false); - //Now, importantly, SourceHook has modified the layout of the above classes. - //If we want to call them in their original state (i.e., without invoking hooks) - // we must request a "Call Class" from SourceHook. - m_ServerClients_CC = SH_GET_CALLCLASS(IServerGameClients, m_ServerClients); - m_ServerDll = SH_GET_CALLCLASS(IServerGameDLL, m_ServerDll); - return true; } @@ -165,10 +159,6 @@ bool SamplePlugin::Unload(char *error, size_t maxlen) SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientConnect, m_ServerClients, &g_SamplePlugin, ClientConnect, false); SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientCommand, m_ServerClients, &g_SamplePlugin, ClientCommand, false); - //Lastly, release the call classes we requested - SH_RELEASE_CALLCLASS(m_ServerDll_CC); - SH_RELEASE_CALLCLASS(m_ServerClients_CC); - return true; } diff --git a/sourcemm/sample_mm/SamplePlugin.h b/sourcemm/sample_mm/SamplePlugin.h index 1c967d6..eebde0c 100644 --- a/sourcemm/sample_mm/SamplePlugin.h +++ b/sourcemm/sample_mm/SamplePlugin.h @@ -107,8 +107,6 @@ private: IVEngineServer *m_Engine; IServerGameDLL *m_ServerDll; IServerGameClients *m_ServerClients; - IServerGameDLL *m_ServerDll_CC; - IServerGameClients *m_ServerClients_CC; }; extern SamplePlugin g_SamplePlugin; diff --git a/sourcemm/sample_mm/oslink.h b/sourcemm/sample_mm/oslink.h new file mode 100644 index 0000000..aad6c0e --- /dev/null +++ b/sourcemm/sample_mm/oslink.h @@ -0,0 +1,66 @@ +/* ======== SourceMM ======== +* Copyright (C) 2004-2005 Metamod:Source Development Team +* No warranties of any kind +* +* License: zlib/libpng +* +* Author(s): David "BAILOPAN" Anderson +* ============================ +*/ + +#ifndef _INCLUDE_OSLINK_H +#define _INCLUDE_OSLINK_H + +/** + * @brief Defines OS-independent information + * @file oslink.h + */ + +#if defined __WIN32__ || defined _WIN32 || defined WIN32 + #define WIN32_LEAN_AND_MEAN + #define OS_WIN32 + #include + #include + #include + #define mkdir(a) _mkdir(a) + #define dlmount(x) LoadLibrary(x) + #define dlsym(x, s) GetProcAddress(x, s) + #define dlclose(x) FreeLibrary(x) + const char* dlerror(); +#elif defined __linux__ + #define OS_LINUX + #include + #include + #include + #include + #define dlmount(x) dlopen(x,RTLD_NOW) + typedef void* HINSTANCE; +#endif + +#if defined __linux__ + extern int errno; + int GetLastError(); +#endif + +#if defined __WIN32__ || defined _WIN32 || defined WIN32 + #define SMM_API extern "C" __declspec(dllexport) +#elif defined __GNUC__ + #define SMM_API extern "C" +#endif + +#if defined __WIN32__ || defined _WIN32 || defined WIN32 + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; +#elif defined __GNUC__ +# if !__GLIBC_HAVE_LONG_LONG + typedef long long int64_t; +# endif + typedef unsigned long long uint64_t; +#endif + +#ifndef __linux__ + #define snprintf _snprintf + #define vsnprintf _vsnprintf +#endif + +#endif //_INCLUDE_OSLINK_H