View Single Post
Re: Uh oh- has CS update broken MetaMod?
Old
  (#21)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Uh oh- has CS update broken MetaMod? - 01-05-2004

...and for Metamod:
Code:
mBOOL meta_load_gamedll(void) {
...........................
     if(!setup_gamedll(&GameDLL)) {
           META_ERROR("dll: Unrecognized game: %s", GameDLL.name);
           // meta_errno should be already set in lookup_game()
           return(mFALSE);
     }

+    // If the game DLL isn't there, try dumping it out of the Steam cache...
+    if (access(GameDLL.real_pathname, 0) == -1) {
+       int i;
+       unsigned char *filebuf;
+
+       i = strlen(GameDLL.real_pathname) - 1;
+
+       while (i >= 0) {
+          if (GameDLL.real_pathname[i] == '/')
+             break;
+          i--;
+       }
+
+       i++;
+
+       filebuf = LOAD_FILE_FOR_ME(UTIL_VarArgs("dlls/%s", &GameDLL.real_pathname[i]), &i);
+
+       if (filebuf) {
+          // Create the path for the file...
+#ifdef _WIN32
+          mkdir(UTIL_VarArgs("%s/dlls", GameDLL.gamedir));
+#else
+          mkdir(UTIL_VarArgs("%s/dlls", GameDLL.gamedir), 0777);
+#endif
+          FILE *fp = fopen(GameDLL.real_pathname, "wb");
+          if (fp) {
+              // dump the file and close it
+              fwrite(filebuf, i, 1, fp);
+              fclose(fp);
+          }
+
+          FREE_FILE(filebuf);
+       }
+    }

     // open the game DLL
     if(!(GameDLL.handle=DLOPEN(GameDLL.pathname))) {
          META_ERROR("dll: Couldn't load game DLL %s: %s", GameDLL.pathname, DLERROR());
          RETURN_ERRNO(mFALSE, ME_DLOPEN);
     }
I'll send this to Will Day and hope he can fix this in next version.
  
Reply With Quote