MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MTVersionCheck

Function MTVersionCheck

netcon/mtclient/mtclient.cpp:2320–2433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2318}
2319
2320int MTVersionCheck() {
2321#ifdef WIN32
2322 int rcode;
2323 InetGetFile *inetfile;
2324 char sznewdll[_MAX_PATH], szolddll[_MAX_PATH], szbakdll[_MAX_PATH];
2325 char fulldllpath[_MAX_PATH * 2];
2326 // char dllpath[_MAX_PATH];
2327 DLLAVInit = NULL;
2328 DLLAVCall = NULL;
2329 DLLAVClose = NULL;
2330 DLLAVGetVersion = NULL;
2331 DLLRunCheck = NULL;
2332 // Start by getting the current MT version and see if a newer is needed
2333 // Load the DLL and get it's version
2334
2335 // Specify the correct path
2336 DLLddio_MakePath(fulldllpath, DLLLocalD3Dir, "mtav.dll", NULL);
2337 if (!DLLmod_LoadModule(&MTAVDLLHandle, fulldllpath, MODF_LAZY)) {
2338 DLLmprintf(0, "Unable to load Mastertracker Auto version update DLL (mtav.dll)\n");
2339 // Try restoring a backup of the DLL
2340 DLLddio_MakePath(szolddll, DLLLocalD3Dir, "mtav.dll", NULL);
2341 DLLddio_MakePath(szbakdll, DLLLocalD3Dir, "mtav.bak", NULL);
2342 CopyFile(szbakdll, szolddll, FALSE);
2343 return 0;
2344 }
2345 DLLAVInit = (DLLAVInit_fp *)DLLmod_GetSymbol(&MTAVDLLHandle, "DLLAVInit", 4);
2346 if (!DLLAVInit) {
2347 DLLmprintf(0, "Unable to Find DLLAVInit() function in mtav.dll\n");
2348 DLLmod_FreeModule(&MTAVDLLHandle);
2349 // Try restoring a backup of the DLL
2350 DLLddio_MakePath(szolddll, DLLLocalD3Dir, "mtav.dll", NULL);
2351 DLLddio_MakePath(szbakdll, DLLLocalD3Dir, "mtav.bak", NULL);
2352 CopyFile(szbakdll, szolddll, FALSE);
2353 return 0;
2354 }
2355 DLLAVGetVersion = (DLLAVGetVersion_fp *)DLLmod_GetSymbol(&MTAVDLLHandle, "DLLAVGetVersion", 4);
2356 if (!DLLAVGetVersion) {
2357 DLLmprintf(0, "Unable to Find DLLAVGetVersion() function in mtav.dll\n");
2358 DLLmod_FreeModule(&MTAVDLLHandle);
2359 // Try restoring a backup of the DLL
2360 DLLddio_MakePath(szolddll, DLLLocalD3Dir, "mtav.dll", NULL);
2361 DLLddio_MakePath(szbakdll, DLLLocalD3Dir, "mtav.bak", NULL);
2362 CopyFile(szbakdll, szolddll, FALSE);
2363 return 0;
2364 }
2365 DLLRunCheck = (DLLRunCheck_fp *)DLLmod_GetSymbol(&MTAVDLLHandle, "DLLRunCheck", 4);
2366 if (!DLLRunCheck) {
2367 DLLmprintf(0, "Unable to Find DLLRunCheck() function in mtav.dll\n");
2368 DLLmod_FreeModule(&MTAVDLLHandle);
2369 // Try restoring a backup of the DLL
2370 DLLddio_MakePath(szolddll, DLLLocalD3Dir, "mtav.dll", NULL);
2371 DLLddio_MakePath(szbakdll, DLLLocalD3Dir, "mtav.bak", NULL);
2372 CopyFile(szbakdll, szolddll, FALSE);
2373 return 0;
2374 }
2375 uint32_t mtver;
2376 DLLAVGetVersion((int *)&mtver);
2377 if (MTAVersionCheck(mtver, MTUpdateURL)) {

Callers 1

DLLFUNCCALL DLLMultiCallFunction · 0.85

Calls 5

CopyFileFunction · 0.85
MTAVersionCheckFunction · 0.85
IsFileErrorMethod · 0.45
GetErrorCodeMethod · 0.45
IsFileReceivedMethod · 0.45

Tested by

no test coverage detected