1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-01-30 19:52:17 +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
* terminator.
* @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

View File

@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
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"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -63,7 +63,7 @@
/>
<Tool
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"
LinkIncremental="2"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmt.lib"
@ -127,7 +127,7 @@
Optimization="3"
FavorSizeOrSpeed="1"
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"
StringPooling="true"
ExceptionHandling="1"
@ -150,7 +150,7 @@
/>
<Tool
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"
LinkIncremental="1"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmtd.lib"

View File

@ -1006,7 +1006,7 @@ const char *MetamodSource::GetBaseDir()
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_start(ap, fmt);
@ -1020,6 +1020,8 @@ void MetamodSource::PathFormat(char *buffer, size_t len, const char *fmt, ...)
buffer[i] = PATH_SEP_CHAR;
}
}
return mylen;
}
void MetamodSource::ClientConPrintf(edict_t *client, const char *fmt, ...)

View File

@ -78,7 +78,7 @@ public:
int FormatIface(char iface[], unsigned int maxlength);
void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
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 *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1);
void EnableVSPListener();

View File

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

View File

@ -439,7 +439,24 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
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");
}