mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-11-29 11:24:19 +01:00
Fixed bug where trying to load Metamod:Source a second time as a SourceMM or Valve server plugin could cause a crash.
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40237
This commit is contained in:
parent
c538c9634b
commit
7c1b752c52
@ -5,7 +5,9 @@
|
||||
GameDLL. This issue occured in HL2 CTF, SourceForts, or any other mod that relied on
|
||||
files from another mod directory.
|
||||
- Fixed bug where returning false in Load() after adding a Metamod event listener or
|
||||
hooking a function could cause a crash.
|
||||
hooking a function could cause a crash instead of rejecting the plugin.
|
||||
- Fixed bug where trying to load Metamod:Source a second time as a SourceMM or Valve
|
||||
server plugin could cause a crash.
|
||||
|
||||
2006/06/14 1.2.3:
|
||||
- Added SourceHook API for manual recalls: RETURN_META_(VALUE_)MNEWPARAMS
|
||||
|
@ -47,6 +47,7 @@
|
||||
#define PATH_SEP_CHAR '/'
|
||||
#define ALT_SEP_CHAR '\\'
|
||||
#define stricmp strcasecmp
|
||||
#define strnicmp strncasecmp
|
||||
#define SERVER_DLL "server_i486.so"
|
||||
#endif
|
||||
|
||||
|
@ -172,6 +172,17 @@ bool DLLInit_Post(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFact
|
||||
//This is where the magic happens
|
||||
SMM_API void *CreateInterface(const char *iface, int *ret)
|
||||
{
|
||||
// Prevent loading of self as a SourceMM plugin or Valve server plugin :x
|
||||
const char *vspIface = "ISERVERPLUGINCALLBACKS";
|
||||
if (strcmp(iface, PLAPI_NAME) == 0 || strnicmp(iface, vspIface, strlen(vspIface)) == 0)
|
||||
{
|
||||
Warning("Do not try loading Metamod:Source as a SourceMM or Valve server plugin.\n");
|
||||
|
||||
if (ret)
|
||||
*ret = IFACE_FAILED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!gParsedGameInfo)
|
||||
{
|
||||
gParsedGameInfo = true;
|
||||
@ -180,7 +191,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
|
||||
getcwd(curpath, sizeof(curpath)-1);
|
||||
if (!GetFileOfAddress((void *)CreateInterface, dllpath, sizeof(dllpath)-1))
|
||||
{
|
||||
Error("GetFileOfAddress() failed! Metamod cannot load.");
|
||||
Error("GetFileOfAddress() failed! Metamod cannot load.\n");
|
||||
return NULL;
|
||||
}
|
||||
SourceHook::String s_dllpath(dllpath);
|
||||
@ -213,7 +224,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
|
||||
// c:\gaben.dll
|
||||
if (path_len > dll_len)
|
||||
{
|
||||
Error("Could not detect GameDLL path! Metamod cannot load[1].");
|
||||
Error("Could not detect GameDLL path! Metamod cannot load[1].\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -229,7 +240,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
|
||||
if ( ((cmp)(curpath, dllpath, path_len)) != 0 )
|
||||
{
|
||||
//:TODO: In this case, we should read /proc/self/maps and find srcds!
|
||||
Error("Could not detect GameDLL path! Metamod cannot load[2].");
|
||||
Error("Could not detect GameDLL path! Metamod cannot load[2].\n");
|
||||
return NULL;
|
||||
}
|
||||
//this will skip past the dir and its separator char
|
||||
@ -241,7 +252,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
Error("Could not detect GameDLL path! Metamod cannot load[3].");
|
||||
Error("Could not detect GameDLL path! Metamod cannot load[3].\n");
|
||||
return NULL;
|
||||
} else {
|
||||
ptr[i] = '\0';
|
||||
@ -269,7 +280,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
|
||||
FILE *fp = fopen(temp_path, "rt");
|
||||
if (!fp)
|
||||
{
|
||||
Error("Unable to open gameinfo.txt! Metamod cannot load.");
|
||||
Error("Unable to open gameinfo.txt! Metamod cannot load.\n");
|
||||
return NULL;
|
||||
}
|
||||
char buffer[255];
|
||||
@ -411,7 +422,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
|
||||
{
|
||||
if (sizeTooBig)
|
||||
{
|
||||
Error("This mod version requires a SourceMM update (ServerGameDLL%03d)!", sizeTooBig);
|
||||
Error("This mod version requires a SourceMM update (ServerGameDLL%03d)!\n", sizeTooBig);
|
||||
if (ret)
|
||||
*ret = IFACE_FAILED;
|
||||
return NULL;
|
||||
@ -427,7 +438,7 @@ SMM_API void *CreateInterface(const char *iface, int *ret)
|
||||
} else {
|
||||
//wtf do we do...
|
||||
//:TODO: .. something a bit more intelligent?
|
||||
Error("Engine requested unknown interface before GameDLL was known!");
|
||||
Error("Engine requested unknown interface before GameDLL was known!\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user