mirror of
https://github.com/rehlds/metamod-r.git
synced 2025-01-26 05:28:19 +03:00
Add Makefile for linux
This commit is contained in:
parent
e49aa9bb2b
commit
3aa6adf7d5
45
metamod/extra/example/Makefile
Normal file
45
metamod/extra/example/Makefile
Normal file
@ -0,0 +1,45 @@
|
||||
HLSDK = include/hlsdk
|
||||
METAMOD = include/metamod
|
||||
|
||||
NAME = example_plugin
|
||||
|
||||
COMPILER = g++
|
||||
|
||||
OBJECTS = *.cpp
|
||||
|
||||
LINK =
|
||||
|
||||
OPT_FLAGS = -O3 -msse3 -flto -funroll-loops -fomit-frame-pointer -fno-stack-protector
|
||||
|
||||
INCLUDE = -I. -I$(HLSDK)/common -I$(HLSDK)/dlls -I$(HLSDK)/engine \
|
||||
-I$(HLSDK)/game_shared -I$(HLSDK)/pm_shared -I$(HLSDK)/public -I$(METAMOD)
|
||||
|
||||
BIN_DIR = Release
|
||||
CFLAGS = $(OPT_FLAGS)
|
||||
|
||||
CFLAGS += -g -DNDEBUG -Dlinux -D__linux__ -D__USE_GNU -std=gnu++11 -shared
|
||||
|
||||
OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
|
||||
|
||||
$(BIN_DIR)/%.o: %.c
|
||||
$(COMPILER) $(INCLUDE) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
all:
|
||||
mkdir -p $(BIN_DIR)
|
||||
|
||||
$(MAKE) $(NAME) && strip -x $(BIN_DIR)/$(NAME)_mm_i386.so
|
||||
|
||||
$(NAME): $(OBJ_LINUX)
|
||||
$(COMPILER) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -o$(BIN_DIR)/$(NAME)_mm_i386.so
|
||||
|
||||
check:
|
||||
cppcheck $(INCLUDE) --quiet --max-configs=100 -D__linux__ -DNDEBUG .
|
||||
|
||||
debug:
|
||||
$(MAKE) all DEBUG=false
|
||||
|
||||
default: all
|
||||
|
||||
clean:
|
||||
rm -rf Release/*.o
|
||||
rm -rf Release/$(NAME)_mm_i386.so
|
@ -129,14 +129,12 @@ NEW_DLL_FUNCTIONS g_NewDllFunctionTable_Post =
|
||||
|
||||
C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
|
||||
{
|
||||
if (!pFunctionTable)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " called with null pFunctionTable");
|
||||
if (!pFunctionTable) {
|
||||
ALERT(at_logged, "%s called with null pFunctionTable", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
if (*interfaceVersion != INTERFACE_VERSION)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION);
|
||||
if (*interfaceVersion != INTERFACE_VERSION) {
|
||||
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, INTERFACE_VERSION);
|
||||
*interfaceVersion = INTERFACE_VERSION;
|
||||
return FALSE;
|
||||
}
|
||||
@ -147,14 +145,12 @@ C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersi
|
||||
|
||||
C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
|
||||
{
|
||||
if (!pFunctionTable)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " called with null pFunctionTable");
|
||||
if (!pFunctionTable) {
|
||||
ALERT(at_logged, "%s called with null pFunctionTable", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
if (*interfaceVersion != INTERFACE_VERSION)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION);
|
||||
if (*interfaceVersion != INTERFACE_VERSION) {
|
||||
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, INTERFACE_VERSION);
|
||||
*interfaceVersion = INTERFACE_VERSION;
|
||||
return FALSE;
|
||||
}
|
||||
@ -165,14 +161,12 @@ C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interface
|
||||
|
||||
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
|
||||
{
|
||||
if (!pNewFunctionTable)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " called with null pNewFunctionTable");
|
||||
if (!pNewFunctionTable) {
|
||||
ALERT(at_logged, "%s called with null pNewFunctionTable", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
if (*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " version mismatch; requested=%d ours=%d", *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION);
|
||||
if (*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) {
|
||||
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION);
|
||||
*interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
|
||||
return FALSE;
|
||||
}
|
||||
@ -183,14 +177,12 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *in
|
||||
|
||||
C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
|
||||
{
|
||||
if (!pNewFunctionTable)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " called with null pNewFunctionTable");
|
||||
if (!pNewFunctionTable) {
|
||||
ALERT(at_logged, "%s called with null pNewFunctionTable", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
if (*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " version mismatch; requested=%d ours=%d", *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION);
|
||||
if (*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) {
|
||||
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION);
|
||||
*interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -348,11 +348,11 @@ enginefuncs_t g_EngineFunctionsTable_Post =
|
||||
C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion)
|
||||
{
|
||||
if (!pengfuncsFromEngine) {
|
||||
ALERT(at_logged, __FUNCTION__ " called with null pengfuncsFromEngine");
|
||||
ALERT(at_logged, "%s called with null pengfuncsFromEngine", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
if (*interfaceVersion != ENGINE_INTERFACE_VERSION) {
|
||||
ALERT(at_logged, __FUNCTION__ " version mismatch; requested=%d ours=%d", *interfaceVersion, ENGINE_INTERFACE_VERSION);
|
||||
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, ENGINE_INTERFACE_VERSION);
|
||||
*interfaceVersion = ENGINE_INTERFACE_VERSION;
|
||||
return FALSE;
|
||||
}
|
||||
@ -363,14 +363,12 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
|
||||
|
||||
C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion)
|
||||
{
|
||||
if (!pengfuncsFromEngine)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " called with null pengfuncsFromEngine");
|
||||
if (!pengfuncsFromEngine) {
|
||||
ALERT(at_logged, "%s called with null pengfuncsFromEngine", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
if (*interfaceVersion != ENGINE_INTERFACE_VERSION)
|
||||
{
|
||||
ALERT(at_logged, __FUNCTION__ " version mismatch; requested=%d ours=%d", *interfaceVersion, ENGINE_INTERFACE_VERSION);
|
||||
if (*interfaceVersion != ENGINE_INTERFACE_VERSION) {
|
||||
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, ENGINE_INTERFACE_VERSION);
|
||||
*interfaceVersion = ENGINE_INTERFACE_VERSION;
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __GNUC__
|
||||
enum class sv_delta_s;
|
||||
#endif
|
||||
|
||||
#include <rehlds_api.h>
|
||||
|
||||
extern IRehldsApi* g_RehldsApi;
|
||||
|
@ -43,7 +43,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
||||
gpMetaGlobals = pMGlobals;
|
||||
gpGamedllFuncs = pGamedllFuncs;
|
||||
|
||||
g_engfuncs.pfnServerPrint("\n###############\n# Hello World! #\n###############\n\n");
|
||||
g_engfuncs.pfnServerPrint("\n################\n# Hello World! #\n################\n\n");
|
||||
|
||||
memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS));
|
||||
return TRUE;
|
||||
|
@ -2,4 +2,4 @@
|
||||
#include <string.h>
|
||||
#include "sys_shared.cpp"
|
||||
#include "interface.cpp"
|
||||
#include "crc32c.cpp"
|
||||
|
||||
|
@ -12,7 +12,7 @@ NEW_DLL_FUNCTIONS sNewFunctionTable;
|
||||
NEW_DLL_FUNCTIONS sNewFunctionTable_jit;
|
||||
NEW_DLL_FUNCTIONS *pHookedNewDllFunctions = &sNewFunctionTable;
|
||||
|
||||
void MM_PRE_HOOK EXT_FUNC mm_ClientConnect(edict_t *pEntity, const char *, const char *, char [128])
|
||||
void MM_PRE_HOOK EXT_FUNC mm_ClientConnect(edict_t *pEntity, const char *, const char *, char[128])
|
||||
{
|
||||
g_players.clear_player_cvar_query(pEntity);
|
||||
}
|
||||
|
@ -14,6 +14,10 @@
|
||||
#define C_DLLEXPORT extern "C" DLLEXPORT
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#define WINAPI
|
||||
#endif
|
||||
|
||||
typedef void (*FN_GAMEINIT)();
|
||||
|
||||
// Typedefs for these are provided in SDK engine/eiface.h, but I didn't
|
||||
|
Loading…
x
Reference in New Issue
Block a user