Fixed bug where trying to load Metamod:Source a second time as a SourceMM or Valve server plugin could cause a crash.
Fixed bug where trying to load Metamod:Source a second time as a SourceMM or Valve server plugin could cause a crash.
1.1 --- a/sourcemm/changelog.txt Thu Jul 20 11:31:41 2006 +0000
1.2 +++ b/sourcemm/changelog.txt Fri Jul 21 06:59:58 2006 +0000
1.3 @@ -5,7 +5,9 @@
1.4 GameDLL. This issue occured in HL2 CTF, SourceForts, or any other mod that relied on
1.5 files from another mod directory.
1.6 - Fixed bug where returning false in Load() after adding a Metamod event listener or
1.7 - hooking a function could cause a crash.
1.8 + hooking a function could cause a crash instead of rejecting the plugin.
1.9 + - Fixed bug where trying to load Metamod:Source a second time as a SourceMM or Valve
1.10 + server plugin could cause a crash.
1.11
1.12 2006/06/14 1.2.3:
1.13 - Added SourceHook API for manual recalls: RETURN_META_(VALUE_)MNEWPARAMS
2.1 --- a/sourcemm/oslink.h Thu Jul 20 11:31:41 2006 +0000
2.2 +++ b/sourcemm/oslink.h Fri Jul 21 06:59:58 2006 +0000
2.3 @@ -47,6 +47,7 @@
2.4 #define PATH_SEP_CHAR '/'
2.5 #define ALT_SEP_CHAR '\\'
2.6 #define stricmp strcasecmp
2.7 + #define strnicmp strncasecmp
2.8 #define SERVER_DLL "server_i486.so"
2.9 #endif
2.10
3.1 --- a/sourcemm/sourcemm.cpp Thu Jul 20 11:31:41 2006 +0000
3.2 +++ b/sourcemm/sourcemm.cpp Fri Jul 21 06:59:58 2006 +0000
3.3 @@ -172,6 +172,17 @@
3.4 //This is where the magic happens
3.5 SMM_API void *CreateInterface(const char *iface, int *ret)
3.6 {
3.7 + // Prevent loading of self as a SourceMM plugin or Valve server plugin :x
3.8 + const char *vspIface = "ISERVERPLUGINCALLBACKS";
3.9 + if (strcmp(iface, PLAPI_NAME) == 0 || strnicmp(iface, vspIface, strlen(vspIface)) == 0)
3.10 + {
3.11 + Warning("Do not try loading Metamod:Source as a SourceMM or Valve server plugin.\n");
3.12 +
3.13 + if (ret)
3.14 + *ret = IFACE_FAILED;
3.15 + return NULL;
3.16 + }
3.17 +
3.18 if (!gParsedGameInfo)
3.19 {
3.20 gParsedGameInfo = true;
3.21 @@ -180,7 +191,7 @@
3.22 getcwd(curpath, sizeof(curpath)-1);
3.23 if (!GetFileOfAddress((void *)CreateInterface, dllpath, sizeof(dllpath)-1))
3.24 {
3.25 - Error("GetFileOfAddress() failed! Metamod cannot load.");
3.26 + Error("GetFileOfAddress() failed! Metamod cannot load.\n");
3.27 return NULL;
3.28 }
3.29 SourceHook::String s_dllpath(dllpath);
3.30 @@ -213,7 +224,7 @@
3.31 // c:\gaben.dll
3.32 if (path_len > dll_len)
3.33 {
3.34 - Error("Could not detect GameDLL path! Metamod cannot load[1].");
3.35 + Error("Could not detect GameDLL path! Metamod cannot load[1].\n");
3.36 return NULL;
3.37 }
3.38
3.39 @@ -229,7 +240,7 @@
3.40 if ( ((cmp)(curpath, dllpath, path_len)) != 0 )
3.41 {
3.42 //:TODO: In this case, we should read /proc/self/maps and find srcds!
3.43 - Error("Could not detect GameDLL path! Metamod cannot load[2].");
3.44 + Error("Could not detect GameDLL path! Metamod cannot load[2].\n");
3.45 return NULL;
3.46 }
3.47 //this will skip past the dir and its separator char
3.48 @@ -241,7 +252,7 @@
3.49 {
3.50 if (i == 0)
3.51 {
3.52 - Error("Could not detect GameDLL path! Metamod cannot load[3].");
3.53 + Error("Could not detect GameDLL path! Metamod cannot load[3].\n");
3.54 return NULL;
3.55 } else {
3.56 ptr[i] = '\0';
3.57 @@ -269,7 +280,7 @@
3.58 FILE *fp = fopen(temp_path, "rt");
3.59 if (!fp)
3.60 {
3.61 - Error("Unable to open gameinfo.txt! Metamod cannot load.");
3.62 + Error("Unable to open gameinfo.txt! Metamod cannot load.\n");
3.63 return NULL;
3.64 }
3.65 char buffer[255];
3.66 @@ -411,7 +422,7 @@
3.67 {
3.68 if (sizeTooBig)
3.69 {
3.70 - Error("This mod version requires a SourceMM update (ServerGameDLL%03d)!", sizeTooBig);
3.71 + Error("This mod version requires a SourceMM update (ServerGameDLL%03d)!\n", sizeTooBig);
3.72 if (ret)
3.73 *ret = IFACE_FAILED;
3.74 return NULL;
3.75 @@ -427,7 +438,7 @@
3.76 } else {
3.77 //wtf do we do...
3.78 //:TODO: .. something a bit more intelligent?
3.79 - Error("Engine requested unknown interface before GameDLL was known!");
3.80 + Error("Engine requested unknown interface before GameDLL was known!\n");
3.81 return NULL;
3.82 }
3.83 }