1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-18 11:54:14 +01:00

Wow, lots of stuff here

1) Bumped version to 1.3
2) Fixed MSVC project files to compile and link against latest SDK
3) Fixed Linux compilation of stub_mm and sample_mm against new SDK (added -msse to makefiles)
4) Removed -fpermissive and -Wno-deprecated from Linux makefiles
5) Added -Wall -Wno-non-virtual-dtor -Werror to Linux makefiles
6) Stub_mm and sample_mm no longer dynamically link to libstdc++
7) SourceMM, stub_mm, and sample_mm compile cleanly (no warnings) with GCC 3.4.x and 4.x

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40269
This commit is contained in:
Scott Ehlert 2006-08-13 11:34:30 +00:00
parent ad3b6fa30f
commit 3d7ae5c6ed
24 changed files with 320 additions and 111 deletions

View File

@ -723,7 +723,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
reinterpret_cast<const char*>(&ms_Proto)); \
\
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(&SH_FHCls(ifacetype,ifacefunc,overload)::Func, mfi); \
param->SetHookfuncVfnptr( \
reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
@ -764,7 +764,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(funcptr, mfi); \
if (mfi.thisptroffs < 0 || !mfi.isVirtual) \
return false; /* No non-virtual functions / virtual inheritance supported */ \
@ -777,7 +777,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(funcptr, mfi); \
if (mfi.thisptroffs < 0) \
return false; /* No virtual inheritance supported */ \
@ -818,7 +818,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
reinterpret_cast<const char*>(&ms_Proto)); \
\
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(&SH_MFHCls(hookname)::Func, mfi); \
param->SetHookfuncVfnptr( \
reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
@ -3012,7 +3012,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
# define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(m_CC->GetThisPtr(), m_MFP, mfi); \
void *origfunc = m_CC->GetOrigFunc(mfi.thisptroffs + mfi.vtbloffs, mfi.vtblindex); \
if (!origfunc) \
@ -3051,7 +3051,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
# define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(m_CC->GetThisPtr(), m_MFP, mfi); \
void *origfunc = m_CC->GetOrigFunc(mfi.thisptroffs + mfi.vtbloffs, mfi.vtblindex); \
if (!origfunc) \

View File

@ -723,7 +723,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
reinterpret_cast<const char*>(&ms_Proto)); \
\
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(&SH_FHCls(ifacetype,ifacefunc,overload)::Func, mfi); \
param->SetHookfuncVfnptr( \
reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
@ -764,7 +764,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(funcptr, mfi); \
if (mfi.thisptroffs < 0 || !mfi.isVirtual) \
return false; /* No non-virtual functions / virtual inheritance supported */ \
@ -777,7 +777,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(funcptr, mfi); \
if (mfi.thisptroffs < 0) \
return false; /* No virtual inheritance supported */ \
@ -818,7 +818,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
reinterpret_cast<const char*>(&ms_Proto)); \
\
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(&SH_MFHCls(hookname)::Func, mfi); \
param->SetHookfuncVfnptr( \
reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
@ -1132,7 +1132,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
# define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(m_CC->GetThisPtr(), m_MFP, mfi); \
void *origfunc = m_CC->GetOrigFunc(mfi.thisptroffs + mfi.vtbloffs, mfi.vtblindex); \
if (!origfunc) \
@ -1171,7 +1171,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
# define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(m_CC->GetThisPtr(), m_MFP, mfi); \
void *origfunc = m_CC->GetOrigFunc(mfi.thisptroffs + mfi.vtbloffs, mfi.vtblindex); \
if (!origfunc) \

View File

@ -723,7 +723,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
reinterpret_cast<const char*>(&ms_Proto)); \
\
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(&SH_FHCls(ifacetype,ifacefunc,overload)::Func, mfi); \
param->SetHookfuncVfnptr( \
reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
@ -764,7 +764,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(funcptr, mfi); \
if (mfi.thisptroffs < 0 || !mfi.isVirtual) \
return false; /* No non-virtual functions / virtual inheritance supported */ \
@ -777,7 +777,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(funcptr, mfi); \
if (mfi.thisptroffs < 0) \
return false; /* No virtual inheritance supported */ \
@ -818,7 +818,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
reinterpret_cast<const char*>(&ms_Proto)); \
\
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(&SH_MFHCls(hookname)::Func, mfi); \
param->SetHookfuncVfnptr( \
reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
@ -3012,7 +3012,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
# define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(m_CC->GetThisPtr(), m_MFP, mfi); \
void *origfunc = m_CC->GetOrigFunc(mfi.thisptroffs + mfi.vtbloffs, mfi.vtblindex); \
if (!origfunc) \
@ -3051,7 +3051,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C
# define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
{ \
using namespace ::SourceHook; \
MemFuncInfo mfi; \
MemFuncInfo mfi = {true, -1, 0, 0}; \
GetFuncInfo(m_CC->GetThisPtr(), m_MFP, mfi); \
void *origfunc = m_CC->GetOrigFunc(mfi.thisptroffs + mfi.vtbloffs, mfi.vtblindex); \
if (!origfunc) \

View File

@ -113,7 +113,7 @@ void CPluginManager::SetAlias(const char *alias, const char *value)
}
}
CPluginManager::CPlugin::CPlugin() : m_Lib(NULL), m_API(NULL), m_Id(0), m_Source(0)
CPluginManager::CPlugin::CPlugin() : m_Id(0), m_Source(0), m_API(NULL), m_Lib(NULL)
{
}

View File

@ -350,7 +350,7 @@ void *CSmmAPI::InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max,
break;
if (num > max)
break;
} while ( num = FormatIface(_if, len+1) );
} while (( num = FormatIface(_if, len+1) ));
delete[] _if;

View File

@ -1,13 +1,13 @@
#(C)2004-2005 SourceMM Development Team
# Makefile written by David "BAILOPAN" Anderson
HL2SDK = /home/users/dvander/BRANCHES/newsdk
HL2SDK = ../hl2sdk
SMM_ROOT = ..
SRCDS = ~/srcds
### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O2 -fno-rtti -funroll-loops -s -pipe
OPT_FLAGS = -O2 -funroll-loops -s -pipe
DEBUG_FLAGS = -g -ggdb3
CPP = gcc-3.4
BINARY = server_i486.so
@ -19,7 +19,7 @@ LINK = vstdlib_i486.so tier0_i486.so -static-libgcc
HL2PUB = $(HL2SDK)/public
INCLUDE = -I. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)tier0 -I$(HL2PUB)/tier1 \
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
ifeq "$(DEBUG)" "true"
@ -30,7 +30,7 @@ else
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 -Wno-deprecated -fno-exceptions -fno-rtti -msse
CFLAGS += -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Wno-non-virtual-dtor -Werror -fPIC -fno-exceptions -fno-rtti -msse
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
@ -41,6 +41,7 @@ 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
ln -sf $(HL2SDK)/tier1/convar.cpp convar.cpp
ln -sf $(SMM_ROOT)/sourcehook/sourcehook.cpp sourcehook.cpp
$(MAKE) sourcemm
rm -rf $(BINARY)
@ -59,3 +60,4 @@ clean:
rm -rf Release/$(BINARY)
rm -rf Debug/*.o
rm -rf Debug/$(BINARY)

View File

@ -1,4 +1,4 @@
2006/xx/xx 1.2.4:
2006/08/xx 1.3:
- Added SourceHook support for functions that return references.
- Added some extra information to the "meta game" command: Description and Interface. For
example, CS:S would display "Counter-Strike: Source" and "ServerGameDLL004."

View File

@ -242,7 +242,7 @@ private:
FnCommandCompletionCallback m_fnCompletionCallback;
bool m_bHasCompletionCallback;
public:
FnCommandCallback GetCallback() { return m_fnCommandCallback; }
FnCommandCallback GetCallback() { return m_fnCommandCallback; }
};
//-----------------------------------------------------------------------------

View File

@ -32,9 +32,10 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="tier0.lib vstdlib.lib"
AdditionalDependencies="tier0.lib tier1.lib vstdlib.lib"
OutputFile="$(OutDir)/server.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="libc.lib;libcmt.lib;libcmtd.lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/sourcemm.pdb"
SubSystem="2"
@ -86,10 +87,10 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="tier0.lib vstdlib.lib"
AdditionalDependencies="tier0.lib tier1.lib vstdlib.lib"
OutputFile="$(OutDir)/server.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames=""
IgnoreDefaultLibraryNames="libcd.lib;libcmt.lib;libcmtd.lib"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
@ -238,9 +239,6 @@
<Filter
Name="HL2SDK"
Filter="">
<File
RelativePath="..\convar.cpp">
</File>
<File
RelativePath="..\convar.h">
</File>

View File

@ -62,9 +62,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="tier0.lib vstdlib.lib"
AdditionalDependencies="tier0.lib tier1.lib vstdlib.lib"
OutputFile="$(OutDir)/server.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmt.lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/sourcemm.pdb"
SubSystem="2"
@ -147,10 +148,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="tier0.lib vstdlib.lib"
AdditionalDependencies="tier0.lib tier1.lib vstdlib.lib"
OutputFile="$(OutDir)/server.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames=""
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmtd.lib"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
@ -336,10 +337,6 @@
<Filter
Name="HL2SDK"
>
<File
RelativePath="..\convar.cpp"
>
</File>
<File
RelativePath="..\convar.h"
>

View File

@ -42,7 +42,7 @@ bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength)
{
#if defined WIN32 || defined _WIN32
MEMORY_BASIC_INFORMATION mem;
if (!VirtualQuery((void *)pAddr, &mem, sizeof(mem)))
if (!VirtualQuery(pAddr, &mem, sizeof(mem)))
return false;
if (mem.AllocationBase == NULL)
return false;
@ -50,7 +50,7 @@ bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength)
GetModuleFileName(dll, (LPTSTR)buffer, maxlength);
#elif defined __linux__
Dl_info info;
if (!dladdr((void *)pAddr, &info))
if (!dladdr(pAddr, &info))
return false;
if (!info.dli_fbase || !info.dli_fname)
return false;

View File

@ -1,24 +1,24 @@
#(C)2004-2005 SourceMM Development Team
# Makefile written by David "BAILOPAN" Anderson
HL2SDK = ../../../hl2sdk
SMM_ROOT = ../../
SRCDS = ~/srcds_l
HL2SDK = ../../hl2sdk
SMM_ROOT = ../..
SRCDS = ~/srcds
### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
OPT_FLAGS = -O3 -funroll-loops -s -pipe
DEBUG_FLAGS = -g -ggdb3
CPP = g++
CPP = gcc-3.4
BINARY = sample_mm_i486.so
OBJECTS = SamplePlugin.cpp cvars.cpp convar.cpp
LINK = vstdlib_i486.so tier0_i486.so
LINK = vstdlib_i486.so tier0_i486.so -static-libgcc
HL2PUB = $(HL2SDK)/public
INCLUDE = -I. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)tier0 -I$(HL2PUB)/tier1 \
INCLUDE = -I. -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
ifeq "$(DEBUG)" "true"
@ -29,7 +29,7 @@ else
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 -Wno-deprecated
CFLAGS += -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Wno-non-virtual-dtor -Werror -fPIC -fno-exceptions -fno-rtti -msse
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
@ -40,7 +40,10 @@ 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
ln -sf $(HL2SDK)/tier1/convar.cpp convar.cpp
$(MAKE) sourcemm
rm -rf $(BINARY)
ln -sf $(BIN_DIR)/$(BINARY) $(BINARY)
sourcemm: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)

View File

@ -28,7 +28,7 @@ PLUGIN_EXPOSE(SamplePlugin, g_SamplePlugin);
} \
if (num_var >= 999) \
break; \
} while ( num_var=ismm->FormatIface(name, sizeof(name)-1) ); \
} while (( num_var=ismm->FormatIface(name, sizeof(name)-1) )); \
if (!assn_var) { \
if (error) \
snprintf(error, maxlen, "Could not find interface %s", name); \
@ -126,7 +126,7 @@ bool SamplePlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen,
char iface_buffer[255];
int num = 0;
strcpy(iface_buffer, INTERFACEVERSION_SERVERGAMEDLL);
strcpy(iface_buffer, "ServerGameDLL003");
FIND_IFACE(serverFactory, m_ServerDll, num, iface_buffer, IServerGameDLL *);
strcpy(iface_buffer, INTERFACEVERSION_VENGINESERVER);
FIND_IFACE(engineFactory, m_Engine, num, iface_buffer, IVEngineServer *);

View File

@ -6,28 +6,216 @@
//
//=============================================================================//
#ifdef _XBOX
#include "xbox/xbox_platform.h"
#include "xbox/xbox_win32stubs.h"
#include "xbox/xbox_core.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "basetypes.h"
#include "convar.h"
#include "vstdlib/strtools.h"
#include "icvar.h"
#include "tier0/dbg.h"
#ifdef _XBOX
#include "vstdlib/ICommandLine.h"
#endif
#include "tier0/memdbgon.h"
ConCommandBase *ConCommandBase::s_pConCommandBases = NULL;
IConCommandBaseAccessor *ConCommandBase::s_pAccessor = NULL;
#ifdef _XBOX
static char const* GetCommandLineValue( char const *pVariableName )
{
int nLen = Q_strlen(pVariableName);
char *pSearch = (char*)stackalloc(nLen + 2);
pSearch[0] = '+';
memcpy(&pSearch[1], pVariableName, nLen + 1);
return CommandLine()->ParmValue(pSearch);
}
#endif
#if defined( _XBOX ) && !defined( _RETAIL )
void ConCommandBaseMgr::PublishCommands( bool bForce )
{
ConCommandBase *pCur;
const char *commands[2048];
const char *helptext[2048];
int numCommands = 0;
if ( bForce )
{
for ( pCur=ConCommandBase::s_pConCommandBases; pCur; pCur=pCur->m_pNext )
{
pCur->m_bRegistered = false;
}
}
// iterate and publish commands to the remote console
for ( pCur=ConCommandBase::s_pConCommandBases; pCur; pCur=pCur->m_pNext )
{
if ( !pCur->m_bRegistered )
{
// add unregistered commands to list
if ( numCommands < sizeof(commands)/sizeof(commands[0]) )
{
commands[numCommands] = pCur->m_pszName;
helptext[numCommands] = pCur->m_pszHelpString;
numCommands++;
}
// mark as registered
pCur->m_bRegistered = true;
}
}
if ( numCommands )
{
XBX_rAddCommands( numCommands, commands, helptext );
}
}
#endif
#ifdef _XBOX
bool ConCommandBaseMgr::Fixup(ConCommandBase* pConCommand)
{
ConCommandBase *pCur;
ConCommandBase *pPrev2;
ConCommandBase *pCur2;
ConCommandBase *pNext2;
const char *name;
static int initCount = 0;
// xboxissue - cvars and its class hierarchy could not be made to instance per subsystem
// without massive mangling and re-arranging, instead...
// there is only a single chain and therefore single /init/fixup
// missing: need to identify which subsystem
// could pass as part of declaration in constructor, but how to hide parameter for pc
// the accessors (aka callbacks to subsystems) to register with engine
// cannot be invoked as their unlink logic expect private lists
// so this just mimics the expected end result
// must handle early and late constructors
// late constructors are usually function scoped static
if (!pConCommand)
{
// the caller is one-time-init
if (++initCount > 1)
{
// the list has already been fixed
return true;
}
}
else
{
// the caller is a console command constructor
if (!initCount)
{
// the list has not been fixed yet
// no special behavior
return false;
}
else
{
// the list has already been fixed
// the console command is a late constructor
// add in to fixed list
bool hasParent = false;
if (!pConCommand->IsCommand())
{
pCur = ConCommandBase::s_pConCommandBases;
while (pCur)
{
if (pCur->IsCommand() && !stricmp(pCur->m_pszName, pConCommand->m_pszName))
{
// set its parent
((ConVar*)pConCommand)->m_pParent = ((ConVar*)pCur)->m_pParent;
hasParent = true;
break;
}
pCur = pCur->m_pNext;
}
}
if (!hasParent)
{
// add to head of list
pConCommand->m_pNext = ConCommandBase::s_pConCommandBases;
ConCommandBase::s_pConCommandBases = pConCommand;
}
else
return true;
}
}
if (initCount == 1)
{
// iterate the cvars and set their possible proxy parents
// skip over registered (fixed) entries
pCur = ConCommandBase::s_pConCommandBases;
while (pCur)
{
if (!pCur->IsCommand() && !pCur->m_bRegistered)
{
// iterate from the next node until end of list
name = pCur->m_pszName;
pPrev2 = pCur;
pCur2 = pCur->m_pNext;
while (pCur2)
{
pNext2 = pCur2->m_pNext;
if (!pCur2->IsCommand() && !stricmp(pCur2->m_pszName, name))
{
// found duplicate
// unlink and fixup
pCur2->m_pNext = NULL;
pPrev2->m_pNext = pNext2;
// set its parent
((ConVar*)pCur2)->m_pParent = ((ConVar*)pCur)->m_pParent;
}
else
{
// no unlink, advance to next node
pPrev2 = pCur2;
}
pCur2 = pNext2;
}
char const *pValue = GetCommandLineValue(name);
if (pValue)
((ConVar*)pCur)->SetValue(pValue);
}
pCur = pCur->m_pNext;
}
}
#if !defined( _RETAIL )
XBX_rTimeStampLog( Plat_FloatTime(), "xbx PublishCommands:Start" );
PublishCommands( false );
XBX_rTimeStampLog( Plat_FloatTime(), "xbx PublishCommands:Done" );
#endif
// fixup has been performed
return true;
}
#endif
// ----------------------------------------------------------------------------- //
// ConCommandBaseMgr.
// ----------------------------------------------------------------------------- //
void ConCommandBaseMgr::OneTimeInit( IConCommandBaseAccessor *pAccessor )
{
#ifdef _XBOX
// fixup the list
ConCommandBaseMgr::Fixup(NULL);
#else
ConCommandBase *pCur, *pNext;
ConCommandBase::s_pAccessor = pAccessor;
pCur = ConCommandBase::s_pConCommandBases;
while ( pCur )
{
@ -35,6 +223,7 @@ void ConCommandBaseMgr::OneTimeInit( IConCommandBaseAccessor *pAccessor )
pCur->Init();
pCur = pNext;
}
#endif
}
//-----------------------------------------------------------------------------
@ -42,12 +231,12 @@ void ConCommandBaseMgr::OneTimeInit( IConCommandBaseAccessor *pAccessor )
//-----------------------------------------------------------------------------
ConCommandBase::ConCommandBase( void )
{
m_bRegistered = false;
m_pszName = NULL;
m_pszHelpString = NULL;
m_bRegistered = false;
m_pszName = NULL;
m_pszHelpString = NULL;
m_nFlags = 0;
m_pNext = NULL;
m_nFlags = 0;
m_pNext = NULL;
}
//-----------------------------------------------------------------------------
@ -89,24 +278,55 @@ void ConCommandBase::Create( char const *pName, char const *pHelpString /*= 0*/,
{
static char *empty_string = "";
m_bRegistered = false;
m_bRegistered = false;
// Name should be static data
Assert( pName );
m_pszName = pName;
m_pszHelpString = pHelpString ? pHelpString : empty_string;
m_pszName = pName;
m_pszHelpString = pHelpString ? pHelpString : empty_string;
m_nFlags = flags;
#ifdef _XBOX
if (ConCommandBaseMgr::Fixup(this))
return;
#endif
if ( !( m_nFlags & FCVAR_UNREGISTERED ) )
{
m_pNext = s_pConCommandBases;
s_pConCommandBases = this;
#ifndef _XBOX
m_pNext = s_pConCommandBases;
s_pConCommandBases = this;
#else
// xboxissue - engine cvars should be at head of list to
// ensure they are set as the cvar master/parent during fixup
if (!s_pConCommandBases || !(flags & FCVAR_NON_ENGINE))
{
// engine cvars, place at head of list
m_pNext = s_pConCommandBases;
s_pConCommandBases = this;
}
else
{
// non-engine cvars, place at end of list
ConCommandBase *cur = s_pConCommandBases;
while (1)
{
if (!cur->m_pNext)
{
cur->m_pNext = this;
m_pNext = NULL;
break;
}
cur = cur->m_pNext;
}
}
#endif
}
else
{
// It's unregistered
m_pNext = NULL;
m_pNext = NULL;
}
// If s_pAccessor is already set (this ConVar is not a global variable),
@ -329,7 +549,6 @@ ConCommand::ConCommand( char const *pName, FnCommandCallback callback, char cons
//-----------------------------------------------------------------------------
ConCommand::~ConCommand( void )
{
}
//-----------------------------------------------------------------------------
@ -565,12 +784,8 @@ void ConVar::ChangeStringValue( char const *tempVal )
{
Assert( !( m_nFlags & FCVAR_NEVER_AS_STRING ) );
char* pszOldValue = (char*)stackalloc( m_StringLength );
if ( m_fnChangeCallback )
{
memcpy( pszOldValue, m_pszString, m_StringLength );
}
char* pszOldValue = (char*)stackalloc( m_StringLength );
memcpy( pszOldValue, m_pszString, m_StringLength );
int len = Q_strlen(tempVal) + 1;
@ -591,6 +806,8 @@ void ConVar::ChangeStringValue( char const *tempVal )
m_fnChangeCallback( this, pszOldValue );
}
GetCVarIF()->CallGlobalChangeCallback( this, pszOldValue );
stackfree( pszOldValue );
}

View File

@ -32,9 +32,10 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="tier0.lib vstdlib.lib"
AdditionalDependencies="tier0.lib tier1.lib vstdlib.lib"
OutputFile="$(OutDir)/sample_mm.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="libc.lib;libcmt.lib;libcmtd.lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/sample_mm.pdb"
SubSystem="2"
@ -80,9 +81,10 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="vstdlib.lib"
AdditionalDependencies="tier0.lib tier1.lib vstdlib.lib"
OutputFile="$(OutDir)/sample_mm.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames="libcd.lib;libcmt.lib;libcmtd.lib"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
@ -144,13 +146,6 @@
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<Filter
Name="HL2SDK"
Filter="">
<File
RelativePath="..\convar.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -62,9 +62,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="tier0.lib vstdlib.lib"
AdditionalDependencies="tier0.lib tier1.lib vstdlib.lib"
OutputFile="$(OutDir)/sample_mm.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmt.lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/sample_mm.pdb"
SubSystem="2"
@ -141,9 +142,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="vstdlib.lib"
AdditionalDependencies="tier0.lib tier1.lib vstdlib.lib"
OutputFile="$(OutDir)/sample_mm.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmtd.lib"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
@ -218,14 +220,6 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="HL2SDK"
>
<File
RelativePath="..\convar.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -91,7 +91,7 @@ void ClearGamedllList();
void InitMainStates()
{
char full_path[260] = {0};
GetFileOfAddress(g_GameDll.factory, full_path, sizeof(full_path)-1);
GetFileOfAddress((void *)g_GameDll.factory, full_path, sizeof(full_path)-1);
g_BinPath.assign(full_path);
//Like metamod, reload plugins at the end of the map.
@ -331,7 +331,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
if (gamebin)
{
g_SmmAPI.PathFormat(temp_path, sizeof(temp_path)-1, "%s/%s/%s", lptr, ptr, SERVER_DLL);
} else if (ptr[0] == NULL) {
} else if (!ptr[0]) {
g_SmmAPI.PathFormat(temp_path, sizeof(temp_path)-1, "%s/%s/%s", lptr, "bin", SERVER_DLL);
} else {
g_SmmAPI.PathFormat(temp_path, sizeof(temp_path)-1, "%s/%s/%s/%s", lptr, ptr, "bin", SERVER_DLL);
@ -348,7 +348,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
for (iter=gamedll_list.begin(); iter!=gamedll_list.end(); iter++)
{
pCheck = (*iter);
if (GetFileOfAddress(pCheck->factory, buffer, sizeof(buffer)-1))
if (GetFileOfAddress((void *)pCheck->factory, buffer, sizeof(buffer)-1))
{
if (UTIL_PathCmp(temp_path, buffer))
{

View File

@ -34,7 +34,7 @@
* increase vers_release when bug fix releases are made
* never increase major
*/
#define SOURCEMM_VERSION "1.2.4"
#define SOURCEMM_VERSION "1.3"
#define SOURCEMM_DATE __DATE__
#define SM_MAJOR_VERSION 1 //never need to increase this
#define SM_VERS_API_MAJOR 1 //increase this on a breaking change

View File

@ -1,24 +1,24 @@
#(C)2004-2005 SourceMM Development Team
# Makefile written by David "BAILOPAN" Anderson
HL2SDK = ../../../hl2sdk
SMM_ROOT = ../../
HL2SDK = ../../hl2sdk
SMM_ROOT = ../..
SRCDS = ~/srcds
### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
OPT_FLAGS = -O3 -funroll-loops -s -pipe
DEBUG_FLAGS = -g -ggdb3
CPP = g++
CPP = gcc-3.4
BINARY = stub_mm_i486.so
OBJECTS = stub_mm.cpp
LINK = vstdlib_i486.so tier0_i486.so
LINK = vstdlib_i486.so tier0_i486.so -static-libgcc
HL2PUB = $(HL2SDK)/public
INCLUDE = -I. -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)tier0 -I$(HL2PUB)/tier1 \
INCLUDE = -I. -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
ifeq "$(DEBUG)" "true"
@ -29,7 +29,7 @@ else
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 -Wno-deprecated
CFLAGS += -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Wno-non-virtual-dtor -Werror -fPIC -fno-exceptions -fno-rtti -msse
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
@ -41,6 +41,8 @@ all:
ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
$(MAKE) sourcemm
rm -rf $(BINARY)
ln -sf $(BIN_DIR)/$(BINARY) $(BINARY)
sourcemm: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)

View File

@ -35,6 +35,7 @@
ShowProgress="0"
OutputFile="$(OutDir)/stub_mm.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="libc.lib;libcmt.lib;libcmtd.lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/stub_mm.pdb"
SubSystem="2"
@ -82,6 +83,7 @@
AdditionalDependencies="tier0.lib"
OutputFile="$(OutDir)/stub_mm.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames="libcd.lib;libcmt.lib;libcmtd.lib"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"

View File

@ -66,6 +66,7 @@
ShowProgress="0"
OutputFile="$(OutDir)/stub_mm.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmt.lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/stub_mm.pdb"
SubSystem="2"
@ -144,6 +145,7 @@
AdditionalDependencies="tier0.lib"
OutputFile="$(OutDir)/stub_mm.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmtd.lib"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"

View File

@ -26,7 +26,7 @@ PLUGIN_EXPOSE(SamplePlugin, g_StubPlugin);
} \
if (num_var >= 999) \
break; \
} while ( num_var=ismm->FormatIface(name, sizeof(name)-1) ); \
} while (( num_var=ismm->FormatIface(name, sizeof(name)-1) )); \
if (!assn_var) { \
if (error) \
snprintf(error, maxlen, "Could not find interface %s", name); \
@ -46,7 +46,7 @@ bool StubPlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bo
char iface_buffer[255];
int num = 0;
strcpy(iface_buffer, INTERFACEVERSION_SERVERGAMEDLL);
strcpy(iface_buffer, "ServerGameDLL003");
FIND_IFACE(serverFactory, m_ServerDll, num, iface_buffer, IServerGameDLL *);
SH_ADD_HOOK_STATICFUNC(IServerGameDLL, ServerActivate, m_ServerDll, ServerActivate_handler, true);

View File

@ -161,9 +161,7 @@ void UTIL_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t
bool UTIL_PathCmp(const char *path1, const char *path2)
{
size_t len1=strlen(path1);
size_t len2=strlen(path2);
size_t pos1=0,pos2=0;
size_t pos1 = 0, pos2 = 0;
while (true)
{

View File

@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,4,0
PRODUCTVERSION 1,2,4,0
FILEVERSION 1,3,0,0
PRODUCTVERSION 1,3,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -43,12 +43,12 @@ BEGIN
BEGIN
VALUE "Comments", "Metamod: Source"
VALUE "FileDescription", "Metamod: Source"
VALUE "FileVersion", "1.2.4"
VALUE "FileVersion", "1.3"
VALUE "InternalName", "sourcemm"
VALUE "LegalCopyright", "Copyright (c) 2004-2006, Metamod: Source Development Team"
VALUE "OriginalFilename", "server.dll"
VALUE "ProductName", "Metamod: Source"
VALUE "ProductVersion", "1.2.4"
VALUE "ProductVersion", "1.3"
END
END
BLOCK "VarFileInfo"
@ -97,4 +97,3 @@ END
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED