this function will load up the DLL, but not get any symbols
| 563 | } |
| 564 | // this function will load up the DLL, but not get any symbols |
| 565 | bool InitGameModule(const char *name, module *mod) { |
| 566 | char lib_name[_MAX_PATH * 2]; |
| 567 | char dll_name[_MAX_PATH * 2]; |
| 568 | char tmp_dll_name[_MAX_PATH * 2]; |
| 569 | // Make the hog filename |
| 570 | ddio_MakePath(lib_name, Base_directory, "netgames", name, NULL); |
| 571 | strcat(lib_name, ".d3m"); |
| 572 | // Make the dll filename |
| 573 | #if defined(WIN32) |
| 574 | snprintf(dll_name, sizeof(dll_name), "%s.dll", name); |
| 575 | #elif defined(MACOSX) |
| 576 | snprintf(dll_name, sizeof(dll_name), "%s.dylib", name); |
| 577 | #else |
| 578 | snprintf(dll_name, sizeof(dll_name), "%s.so", name); |
| 579 | #endif |
| 580 | |
| 581 | // Open the hog file |
| 582 | if (!cf_OpenLibrary(lib_name)) { |
| 583 | ddio_MakePath(tmp_dll_name, Base_directory, "netgames", name, NULL); |
| 584 | strcat(tmp_dll_name, ".d3m"); |
| 585 | Multi_game_dll_name[0] = '\0'; |
| 586 | goto loaddll; |
| 587 | } |
| 588 | // get a temp file name |
| 589 | if (!ddio_GetTempFileName(Descent3_temp_directory, "d3m", tmp_dll_name)) { |
| 590 | return false; |
| 591 | } |
| 592 | // Copy the DLL |
| 593 | if (!cf_CopyFile(tmp_dll_name, dll_name)) { |
| 594 | mprintf(0, "DLL copy failed!\n"); |
| 595 | return false; |
| 596 | } |
| 597 | strcpy(Multi_game_dll_name, tmp_dll_name); |
| 598 | loaddll: |
| 599 | // Clear out error queue |
| 600 | mod_GetLastError(); |
| 601 | if (!mod_LoadModule(mod, tmp_dll_name)) { |
| 602 | int err = mod_GetLastError(); |
| 603 | mprintf(0, "You are missing the DLL %s!\n", name); |
| 604 | return false; |
| 605 | } |
| 606 | return true; |
| 607 | } |
| 608 | // Frees the dll if its in memory |
| 609 | void FreeGameDLL() { |
| 610 | if (!GameDLLHandle.handle) |
no test coverage detected