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

Function LoadMultiDLL

Descent3/multi_dll_mgr.cpp:588–697  ·  view source on GitHub ↗

Loads the Multi dll. Returns 1 on success, else 0 on failure

Source from the content-addressed store, hash-verified

586}
587// Loads the Multi dll. Returns 1 on success, else 0 on failure
588int LoadMultiDLL(const char *name) {
589 static int first = 1;
590 char lib_name[_MAX_PATH * 2];
591 char dll_name[_MAX_PATH * 2];
592 char tmp_dll_name[_MAX_PATH * 2];
593 char dll_path_name[_MAX_PATH * 2];
594 MultiFlushAllIncomingBuffers();
595
596 // Delete old dlls
597 if (MultiDLLHandle.handle)
598 FreeMultiDLL();
599
600 ddio_MakePath(dll_path_name, Base_directory, "online", "*.tmp", NULL);
601 ddio_DeleteFile(dll_path_name);
602 // Make the hog filename
603 ddio_MakePath(lib_name, Base_directory, "online", name, NULL);
604 strcat(lib_name, ".d3c");
605// Make the dll filename
606#if defined(WIN32)
607 snprintf(dll_name, sizeof(dll_name), "%s.dll", name);
608#elif defined(MACOSX)
609 snprintf(dll_name, sizeof(dll_name), "%s.dylib", name);
610#else
611 snprintf(dll_name, sizeof(dll_name), "%s.so", name);
612#endif
613
614 // Open the hog file
615 if (!cf_OpenLibrary(lib_name)) {
616 ddio_MakePath(tmp_dll_name, Base_directory, "online", name, NULL);
617 strcat(tmp_dll_name, ".d3c");
618 Multi_conn_dll_name[0] = 0;
619 goto loaddll;
620 }
621 // get a temp file name
622 if (!ddio_GetTempFileName(Descent3_temp_directory, "d3c", tmp_dll_name)) {
623 return 0;
624 }
625 // Copy the DLL
626 // ddio_MakePath(dll_path_name,Base_directory,"online",tmp_dll_name,NULL);
627 if (!cf_CopyFile(tmp_dll_name, dll_name)) {
628 mprintf(0, "DLL copy failed!\n");
629 return 0;
630 }
631 strcpy(Multi_conn_dll_name, tmp_dll_name);
632loaddll:
633
634 if (!mod_LoadModule(&MultiDLLHandle, tmp_dll_name)) {
635 int err = mod_GetLastError();
636 mprintf(0, "You are missing the DLL %s!\n", name);
637 return 0;
638 }
639
640 DLLMultiInit = (DLLMultiInit_fp)mod_GetSymbol(&MultiDLLHandle, "DLLMultiInit", 4);
641 if (!DLLMultiInit) {
642 int err = mod_GetLastError();
643 mprintf(0, "Couldn't get a handle to the dll function DLLMultiInit!\n");
644 Int3();
645 FreeMultiDLL();

Callers 6

MainMultiplayerMenuFunction · 0.85
AutoConnectPXOFunction · 0.85
AutoConnectLANIPFunction · 0.85
AutoConnectHeatFunction · 0.85
RunServerConfigsFunction · 0.85
ProcessCommandLineFunction · 0.85

Calls 11

FreeMultiDLLFunction · 0.85
cf_OpenLibraryFunction · 0.85
cf_CopyFileFunction · 0.85
mod_LoadModuleFunction · 0.85
mod_GetLastErrorFunction · 0.85
mod_GetSymbolFunction · 0.85
ddio_MakePathFunction · 0.50
ddio_DeleteFileFunction · 0.50
ddio_GetTempFileNameFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected