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

Function LoadGameDLL

Descent3/Game2DLL.cpp:622–708  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

620}
621// Loads the game dll. Returns 1 on success, else 0 on failure
622int LoadGameDLL(const char *name, int num_teams_to_use) {
623 static int first = 1;
624 // char lib_name[_MAX_PATH*2];
625 // char dll_name[_MAX_PATH*2];
626 // char tmp_dll_name[_MAX_PATH*2];
627 // char dll_path_name[_MAX_PATH*2];
628 // char fulldll[_MAX_PATH*2];
629 // ddio_MakePath(fulldll,Base_directory,"netgames",name,NULL);
630 if (GameDLLHandle.handle)
631 FreeGameDLL();
632 if (num_teams_to_use == -1) {
633 int mint, maxt;
634 if (GetDLLNumTeamInfo(name, &mint, &maxt)) {
635 // multi team game
636 num_teams_to_use = mint;
637 } else {
638 // non-team game
639 num_teams_to_use = 1;
640 }
641 }
642 mprintf(0, "Loading '%s', setting up for %d teams\n", name, num_teams_to_use);
643 if (!InitGameModule(name, &GameDLLHandle))
644 return 0;
645
646 // Clear out error queue
647 mod_GetLastError();
648 DLLGameInit = (DLLGameInit_fp)mod_GetSymbol(&GameDLLHandle, "DLLGameInit", 12);
649 if (!DLLGameInit) {
650 int err = mod_GetLastError();
651 mprintf(0, "Couldn't get a handle to the dll function DLLGameInit!\n");
652 Int3();
653 FreeGameDLL();
654 return 0;
655 }
656 // Clear out error queue
657 mod_GetLastError();
658 DLLGameCall = (DLLGameCall_fp)mod_GetSymbol(&GameDLLHandle, "DLLGameCall", 8);
659 if (!DLLGameCall) {
660 int err = mod_GetLastError();
661 mprintf(0, "Couldn't get a handle to the dll function DLLGameCall!\n");
662 Int3();
663 FreeGameDLL();
664 return 0;
665 }
666 // Clear out error queue
667 mod_GetLastError();
668 DLLGameClose = (DLLGameClose_fp)mod_GetSymbol(&GameDLLHandle, "DLLGameClose", 0);
669 if (!DLLGameClose) {
670 int err = mod_GetLastError();
671 mprintf(0, "Couldn't get a handle to the dll function DLLGameClose!\n");
672 Int3();
673 FreeGameDLL();
674 return 0;
675 }
676 // Clear out error queue
677 mod_GetLastError();
678 DLLGetGameInfo = (DLLGetGameInfo_fp)mod_GetSymbol(&GameDLLHandle, "DLLGetGameInfo", 4);
679 if (!DLLGetGameInfo) {

Callers 1

InitGameScriptFunction · 0.85

Calls 6

FreeGameDLLFunction · 0.85
GetDLLNumTeamInfoFunction · 0.85
InitGameModuleFunction · 0.85
mod_GetLastErrorFunction · 0.85
mod_GetSymbolFunction · 0.85
Osiris_LoadMissionModuleFunction · 0.85

Tested by

no test coverage detected