diff --git a/sourcehook/generate/sourcehook.h b/sourcehook/generate/sourcehook.h index 312892d..c7a7099 100644 --- a/sourcehook/generate/sourcehook.h +++ b/sourcehook/generate/sourcehook.h @@ -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(&ms_Proto)); \ \ - MemFuncInfo mfi; \ + MemFuncInfo mfi = {true, -1, 0, 0}; \ GetFuncInfo(&SH_FHCls(ifacetype,ifacefunc,overload)::Func, mfi); \ param->SetHookfuncVfnptr( \ reinterpret_cast(reinterpret_cast(&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(&ms_Proto)); \ \ - MemFuncInfo mfi; \ + MemFuncInfo mfi = {true, -1, 0, 0}; \ GetFuncInfo(&SH_MFHCls(hookname)::Func, mfi); \ param->SetHookfuncVfnptr( \ reinterpret_cast(reinterpret_cast(&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) \ diff --git a/sourcehook/generate/sourcehook.hxx b/sourcehook/generate/sourcehook.hxx index da74d6a..b85eb3c 100755 --- a/sourcehook/generate/sourcehook.hxx +++ b/sourcehook/generate/sourcehook.hxx @@ -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(&ms_Proto)); \ \ - MemFuncInfo mfi; \ + MemFuncInfo mfi = {true, -1, 0, 0}; \ GetFuncInfo(&SH_FHCls(ifacetype,ifacefunc,overload)::Func, mfi); \ param->SetHookfuncVfnptr( \ reinterpret_cast(reinterpret_cast(&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(&ms_Proto)); \ \ - MemFuncInfo mfi; \ + MemFuncInfo mfi = {true, -1, 0, 0}; \ GetFuncInfo(&SH_MFHCls(hookname)::Func, mfi); \ param->SetHookfuncVfnptr( \ reinterpret_cast(reinterpret_cast(&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) \ diff --git a/sourcehook/sourcehook.h b/sourcehook/sourcehook.h index 312892d..c7a7099 100644 --- a/sourcehook/sourcehook.h +++ b/sourcehook/sourcehook.h @@ -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(&ms_Proto)); \ \ - MemFuncInfo mfi; \ + MemFuncInfo mfi = {true, -1, 0, 0}; \ GetFuncInfo(&SH_FHCls(ifacetype,ifacefunc,overload)::Func, mfi); \ param->SetHookfuncVfnptr( \ reinterpret_cast(reinterpret_cast(&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(&ms_Proto)); \ \ - MemFuncInfo mfi; \ + MemFuncInfo mfi = {true, -1, 0, 0}; \ GetFuncInfo(&SH_MFHCls(hookname)::Func, mfi); \ param->SetHookfuncVfnptr( \ reinterpret_cast(reinterpret_cast(&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) \ diff --git a/sourcemm/CPlugin.cpp b/sourcemm/CPlugin.cpp index c1d005b..687ac6b 100644 --- a/sourcemm/CPlugin.cpp +++ b/sourcemm/CPlugin.cpp @@ -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) { } diff --git a/sourcemm/CSmmAPI.cpp b/sourcemm/CSmmAPI.cpp index f63eb31..b39bb10 100644 --- a/sourcemm/CSmmAPI.cpp +++ b/sourcemm/CSmmAPI.cpp @@ -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; diff --git a/sourcemm/Makefile b/sourcemm/Makefile index d5abc34..edd46f5 100644 --- a/sourcemm/Makefile +++ b/sourcemm/Makefile @@ -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) + diff --git a/sourcemm/changelog.txt b/sourcemm/changelog.txt index 75f1822..435229d 100644 --- a/sourcemm/changelog.txt +++ b/sourcemm/changelog.txt @@ -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." diff --git a/sourcemm/convar.h b/sourcemm/convar.h index edf0b1c..26abce9 100644 --- a/sourcemm/convar.h +++ b/sourcemm/convar.h @@ -242,7 +242,7 @@ private: FnCommandCompletionCallback m_fnCompletionCallback; bool m_bHasCompletionCallback; public: - FnCommandCallback GetCallback() { return m_fnCommandCallback; } + FnCommandCallback GetCallback() { return m_fnCommandCallback; } }; //----------------------------------------------------------------------------- diff --git a/sourcemm/msvc7/sourcemm.vcproj b/sourcemm/msvc7/sourcemm.vcproj index b6ade0a..b825015 100644 --- a/sourcemm/msvc7/sourcemm.vcproj +++ b/sourcemm/msvc7/sourcemm.vcproj @@ -32,9 +32,10 @@ Name="VCCustomBuildTool"/> - - diff --git a/sourcemm/msvc8/sourcemm.vcproj b/sourcemm/msvc8/sourcemm.vcproj index 07a0e33..2292db1 100644 --- a/sourcemm/msvc8/sourcemm.vcproj +++ b/sourcemm/msvc8/sourcemm.vcproj @@ -62,9 +62,10 @@ /> - - diff --git a/sourcemm/oslink.cpp b/sourcemm/oslink.cpp index e92beae..50fa4ae 100644 --- a/sourcemm/oslink.cpp +++ b/sourcemm/oslink.cpp @@ -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; diff --git a/sourcemm/sample_mm/Makefile b/sourcemm/sample_mm/Makefile index 9da4b1a..e509bd2 100644 --- a/sourcemm/sample_mm/Makefile +++ b/sourcemm/sample_mm/Makefile @@ -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) diff --git a/sourcemm/sample_mm/SamplePlugin.cpp b/sourcemm/sample_mm/SamplePlugin.cpp index f41d9f6..4c6d22a 100644 --- a/sourcemm/sample_mm/SamplePlugin.cpp +++ b/sourcemm/sample_mm/SamplePlugin.cpp @@ -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 *); diff --git a/sourcemm/sample_mm/convar.cpp b/sourcemm/sample_mm/convar.cpp index 5c9536a..954665c 100644 --- a/sourcemm/sample_mm/convar.cpp +++ b/sourcemm/sample_mm/convar.cpp @@ -6,28 +6,216 @@ // //=============================================================================// +#ifdef _XBOX +#include "xbox/xbox_platform.h" +#include "xbox/xbox_win32stubs.h" +#include "xbox/xbox_core.h" +#endif #include #include #include #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 ); } diff --git a/sourcemm/sample_mm/msvc7/sample_mm.vcproj b/sourcemm/sample_mm/msvc7/sample_mm.vcproj index 844d65d..4e2f150 100644 --- a/sourcemm/sample_mm/msvc7/sample_mm.vcproj +++ b/sourcemm/sample_mm/msvc7/sample_mm.vcproj @@ -32,9 +32,10 @@ Name="VCCustomBuildTool"/> - - - - diff --git a/sourcemm/sample_mm/msvc8/sample_mm.vcproj b/sourcemm/sample_mm/msvc8/sample_mm.vcproj index 4397b2a..91fb4ba 100644 --- a/sourcemm/sample_mm/msvc8/sample_mm.vcproj +++ b/sourcemm/sample_mm/msvc8/sample_mm.vcproj @@ -62,9 +62,10 @@ /> - - - - diff --git a/sourcemm/sourcemm.cpp b/sourcemm/sourcemm.cpp index 079bf52..4a69567 100644 --- a/sourcemm/sourcemm.cpp +++ b/sourcemm/sourcemm.cpp @@ -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)) { diff --git a/sourcemm/sourcemm.h b/sourcemm/sourcemm.h index d347690..3630112 100644 --- a/sourcemm/sourcemm.h +++ b/sourcemm/sourcemm.h @@ -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 diff --git a/sourcemm/stub_mm/Makefile b/sourcemm/stub_mm/Makefile index 1c907d9..e43ee4b 100644 --- a/sourcemm/stub_mm/Makefile +++ b/sourcemm/stub_mm/Makefile @@ -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) diff --git a/sourcemm/stub_mm/msvc7/stub_mm.vcproj b/sourcemm/stub_mm/msvc7/stub_mm.vcproj index f5e101c..d56adfe 100644 --- a/sourcemm/stub_mm/msvc7/stub_mm.vcproj +++ b/sourcemm/stub_mm/msvc7/stub_mm.vcproj @@ -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" diff --git a/sourcemm/stub_mm/msvc8/stub_mm.vcproj b/sourcemm/stub_mm/msvc8/stub_mm.vcproj index 1753e4b..36b6d36 100644 --- a/sourcemm/stub_mm/msvc8/stub_mm.vcproj +++ b/sourcemm/stub_mm/msvc8/stub_mm.vcproj @@ -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" diff --git a/sourcemm/stub_mm/stub_mm.cpp b/sourcemm/stub_mm/stub_mm.cpp index ce86331..7c7d623 100644 --- a/sourcemm/stub_mm/stub_mm.cpp +++ b/sourcemm/stub_mm/stub_mm.cpp @@ -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); diff --git a/sourcemm/util.cpp b/sourcemm/util.cpp index 5987647..f562ec1 100644 --- a/sourcemm/util.cpp +++ b/sourcemm/util.cpp @@ -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) { diff --git a/sourcemm/version.rc b/sourcemm/version.rc index 1b1496e..d06b6ba 100755 --- a/sourcemm/version.rc +++ b/sourcemm/version.rc @@ -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 -