returns true if the given .cpp/.dll file is out of sync (or non-existant). Working directory doesn't necessarily have to be set to data\scripts.
| 2346 | // returns true if the given .cpp/.dll file is out of sync (or non-existant). Working directory |
| 2347 | // doesn't necessarily have to be set to data\scripts. |
| 2348 | bool IsScriptOutofSync(char *name) { |
| 2349 | bool out_of_sync = false; |
| 2350 | InitializeDLL_fp initdll; |
| 2351 | ShutdownDLL_fp shutdowndll; |
| 2352 | module mod; |
| 2353 | |
| 2354 | char filename[_MAX_PATH], ext[_MAX_EXT]; |
| 2355 | char path[_MAX_PATH]; |
| 2356 | |
| 2357 | ddio_SplitPath(name, NULL, filename, ext); |
| 2358 | |
| 2359 | Osiris_module_init.string_count = 0; |
| 2360 | Osiris_module_init.string_table = NULL; |
| 2361 | Osiris_module_init.module_is_static = false; |
| 2362 | Osiris_module_init.module_identifier = 0; |
| 2363 | Osiris_module_init.script_identifier = filename; |
| 2364 | |
| 2365 | strcat(filename, ".dll"); |
| 2366 | ddio_MakePath(path, LocalScriptDir, filename, NULL); |
| 2367 | mprintf(0, " Checking %s...", filename); |
| 2368 | |
| 2369 | if (mod_LoadModule(&mod, path)) { |
| 2370 | initdll = (InitializeDLL_fp)mod_GetSymbol(&mod, "InitializeDLL", 4); |
| 2371 | if (initdll) { |
| 2372 | if (!initdll(&Osiris_module_init)) { |
| 2373 | // dll does not initialize...out of synce |
| 2374 | out_of_sync = true; |
| 2375 | mprintf(0, "OUT OF SYNC!\n"); |
| 2376 | } else { |
| 2377 | mprintf(0, "Not Out of Sync\n"); |
| 2378 | shutdowndll = (ShutdownDLL_fp)mod_GetSymbol(&mod, "ShutdownDLL", 0); |
| 2379 | if (shutdowndll) { |
| 2380 | shutdowndll(); |
| 2381 | } |
| 2382 | } |
| 2383 | } else { |
| 2384 | // unable to load |
| 2385 | mprintf(0, "UNABLE TO GET INITIALIZEDLL\n"); |
| 2386 | } |
| 2387 | |
| 2388 | mod_FreeModule(&mod); |
| 2389 | } else { |
| 2390 | mprintf(0, "MODULE NOT FOUND\n"); |
| 2391 | } |
| 2392 | |
| 2393 | return out_of_sync; |
| 2394 | } |
| 2395 | |
| 2396 | // Returns true if there are out of date script files (only checks those in manage system) |
| 2397 | int AreScriptsOutofDate(void) { |
no test coverage detected