1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-01-31 20:52:18 +01:00

- PathFormat() now returns size_t - this is a nearly irrelevant ABI break that shouldn't break

- implemented the rest of METAMOD_FN_LOAD

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40493
This commit is contained in:
David Anderson 2007-10-10 01:42:25 +00:00
parent e5c5a2c1a0
commit 81cea20c97
6 changed files with 32 additions and 8 deletions

View File

@ -231,8 +231,11 @@ namespace SourceMM
* @param len Maximum length of buffer, including null * @param len Maximum length of buffer, including null
* terminator. * terminator.
* @param fmt Formatted string. * @param fmt Formatted string.
* @param ... Arguments in the string.
* @return Number of bytes written, not including the null
* terminator.
*/ */
virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...) =0; virtual size_t PathFormat(char *buffer, size_t len, const char *fmt, ...) =0;
/** /**
* @brief Prints text in the specified client's console. Same as * @brief Prints text in the specified client's console. Same as

View File

@ -41,7 +41,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..;..\..\..;..\..\..\sourcehook" AdditionalIncludeDirectories="..\..;..\..\..;..\..\..\sourcehook;$(HL2SDKOB)\public;$(HL2SDKOB)\public\dlls;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(HL2SDKOB)\tier1"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMM_EXPORTS;_CRT_SECURE_NO_DEPRECATE" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMM_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
@ -63,7 +63,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="tier0.lib tier1.lib tier2.lib vstdlib.lib" AdditionalDependencies="$(HL2SDKOB)\lib\public\tier0.lib $(HL2SDKOB)\lib\public\tier1.lib $(HL2SDKOB)\lib\public\tier2.lib $(HL2SDKOB)\lib\public\vstdlib.lib"
OutputFile="$(OutDir)/server.dll" OutputFile="$(OutDir)/server.dll"
LinkIncremental="2" LinkIncremental="2"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmt.lib" IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmt.lib"
@ -127,7 +127,7 @@
Optimization="3" Optimization="3"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
AdditionalIncludeDirectories="..\..;..\..\..;..\..\..\sourcehook" AdditionalIncludeDirectories="..\..;..\..\..;..\..\..\sourcehook;$(HL2SDKOB)\public;$(HL2SDKOB)\public\dlls;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(HL2SDKOB)\tier1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMM_EXPORTS;_CRT_SECURE_NO_DEPRECATE" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMM_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true" StringPooling="true"
ExceptionHandling="1" ExceptionHandling="1"
@ -150,7 +150,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="tier0.lib tier1.lib vstdlib.lib" AdditionalDependencies="$(HL2SDKOB)\lib\public\tier0.lib $(HL2SDKOB)\lib\public\tier1.lib $(HL2SDKOB)\lib\public\tier2.lib $(HL2SDKOB)\lib\public\vstdlib.lib"
OutputFile="$(OutDir)/server.dll" OutputFile="$(OutDir)/server.dll"
LinkIncremental="1" LinkIncremental="1"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmtd.lib" IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmtd.lib"

View File

@ -1006,7 +1006,7 @@ const char *MetamodSource::GetBaseDir()
return mod_path.c_str(); return mod_path.c_str();
} }
void MetamodSource::PathFormat(char *buffer, size_t len, const char *fmt, ...) size_t MetamodSource::PathFormat(char *buffer, size_t len, const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
@ -1020,6 +1020,8 @@ void MetamodSource::PathFormat(char *buffer, size_t len, const char *fmt, ...)
buffer[i] = PATH_SEP_CHAR; buffer[i] = PATH_SEP_CHAR;
} }
} }
return mylen;
} }
void MetamodSource::ClientConPrintf(edict_t *client, const char *fmt, ...) void MetamodSource::ClientConPrintf(edict_t *client, const char *fmt, ...)

View File

@ -78,7 +78,7 @@ public:
int FormatIface(char iface[], unsigned int maxlength); int FormatIface(char iface[], unsigned int maxlength);
void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret); void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
const char *GetBaseDir(); const char *GetBaseDir();
void PathFormat(char *buffer, size_t len, const char *fmt, ...); size_t PathFormat(char *buffer, size_t len, const char *fmt, ...);
void ClientConPrintf(edict_t *client, const char *fmt, ...); void ClientConPrintf(edict_t *client, const char *fmt, ...);
void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1); void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1);
void EnableVSPListener(); void EnableVSPListener();

View File

@ -55,6 +55,7 @@
#define PATH_SIZE MAX_PATH #define PATH_SIZE MAX_PATH
#define SERVER_DLL "server.dll" #define SERVER_DLL "server.dll"
#define strcasecmp stricmp #define strcasecmp stricmp
inline bool _IsPathSepChar(char c) { return (c == '/' || c == '\\'); }
#elif defined __linux__ #elif defined __linux__
#define OS_LINUX #define OS_LINUX
#include <dlfcn.h> #include <dlfcn.h>
@ -71,6 +72,7 @@
#define stricmp strcasecmp #define stricmp strcasecmp
#define strnicmp strncasecmp #define strnicmp strncasecmp
#define SERVER_DLL "server_i486.so" #define SERVER_DLL "server_i486.so"
inline bool _IsPathSepChar(char c) { return (c == '/'); }
#endif #endif
#if defined __linux__ #if defined __linux__

View File

@ -439,7 +439,24 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
GlobVersionInfo.source_engine = g_Metamod.GetSourceEngineBuild(); GlobVersionInfo.source_engine = g_Metamod.GetSourceEngineBuild();
} }
pl->m_API = fnLoad(&GlobVersionInfo, NULL); /* Build path information */
char file_path[256];
size_t len = g_Metamod.PathFormat(file_path, sizeof(file_path), "%s", file);
for (size_t i = len - 1; i >= 0 && i < len; i--)
{
if (_IsPathSepChar(file_path[i]))
{
file_path[i] = '\0';
break;
}
}
MetamodLoaderInfo info;
info.pl_file = file;
info.pl_path = file_path;
pl->m_API = fnLoad(&GlobVersionInfo, &info);
pl->m_UnloadFn = (METAMOD_FN_UNLOAD)dlsym(pl->m_Lib, "UnloadInterface_MMS"); pl->m_UnloadFn = (METAMOD_FN_UNLOAD)dlsym(pl->m_Lib, "UnloadInterface_MMS");
} }