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

Function Osiris_ExtractScriptsFromHog

Descent3/OsirisLoadandBind.cpp:3124–3242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3122void _clearextractedall(void) { Osiris_ClearExtractedScripts(false); }
3123
3124int Osiris_ExtractScriptsFromHog(int library_handle, bool is_mission_hog) {
3125 if (library_handle == 0)
3126 return 0;
3127
3128 mprintf(0, "OSIRIS: Extracting Scripts From Hog\n");
3129
3130 char filename[_MAX_PATH], temp_filename[_MAX_PATH];
3131 char tempdir[_MAX_PATH], temp_file[_MAX_PATH], temp_fileext[_MAX_EXT];
3132 char temp_realname[_MAX_PATH];
3133
3134 if (!OSIRIS_Extracted_script_dir) {
3135 strcpy(tempdir, Descent3_temp_directory);
3136 OSIRIS_Extracted_script_dir = mem_strdup(tempdir);
3137 if (!OSIRIS_Extracted_script_dir)
3138 Error("Out of memory");
3139 } else {
3140 strcpy(tempdir, OSIRIS_Extracted_script_dir);
3141 }
3142
3143 int count = 0;
3144
3145 const char *script_extension;
3146#if defined(MACOSX)
3147 script_extension = "*.dylib";
3148#elif defined(__LINUX__)
3149 script_extension = "*.so";
3150#elif defined(WIN32)
3151 script_extension = "*.dll";
3152#else
3153 #error Unsupported platform!
3154#endif
3155
3156 int index;
3157 index = _getfreeextractslot();
3158 if (index == -1) {
3159 mprintf(0, "OSIRIS: Out of slots extracting scripts!!!!!!!!\n");
3160 Int3();
3161 goto ex_error;
3162 }
3163
3164 mprintf(0, "Search started\n");
3165 if (cf_LibraryFindFirst(library_handle, script_extension, filename)) {
3166
3167 mprintf(0, " Found: %s...", filename);
3168 if (!ddio_GetTempFileName(tempdir, "d3s", temp_filename))
3169 Int3();
3170 else {
3171 ddio_SplitPath(temp_filename, NULL, temp_file, temp_fileext);
3172 strcat(temp_file, temp_fileext);
3173
3174 OSIRIS_Extracted_scripts[index].flags = OESF_USED;
3175 OSIRIS_Extracted_scripts[index].temp_filename = mem_strdup(temp_file);
3176
3177 ddio_SplitPath(filename, NULL, temp_realname, NULL);
3178 OSIRIS_Extracted_scripts[index].real_filename = mem_strdup(temp_realname);
3179
3180 if (is_mission_hog) {
3181 OSIRIS_Extracted_scripts[index].flags |= OESF_MISSION;

Callers 2

InitIOSystemsFunction · 0.85
mn3_OpenFunction · 0.85

Calls 8

ErrorFunction · 0.85
_getfreeextractslotFunction · 0.85
cf_LibraryFindFirstFunction · 0.85
_extractscriptFunction · 0.85
cf_LibraryFindNextFunction · 0.85
cf_LibraryFindCloseFunction · 0.85
ddio_GetTempFileNameFunction · 0.50
ddio_SplitPathFunction · 0.50

Tested by

no test coverage detected