Osiris_RestoreSystemState Purpose: Restore the state of the system from file (does not restore scripts!)
| 2684 | // Purpose: |
| 2685 | // Restore the state of the system from file (does not restore scripts!) |
| 2686 | bool Osiris_RestoreSystemState(CFILE *file) { |
| 2687 | int i; |
| 2688 | int restore_start = cftell(file); |
| 2689 | int num_bytes_to_be_restored; |
| 2690 | |
| 2691 | char tag[256]; |
| 2692 | cf_ReadString(tag, 256, file); |
| 2693 | if (strcmp(tag, "OSIRIS")) { |
| 2694 | // Things aren't right...our tag is not here |
| 2695 | mprintf(0, "Missing OSIRIS tag\n"); |
| 2696 | Int3(); |
| 2697 | return false; |
| 2698 | } |
| 2699 | |
| 2700 | uint8_t version = (uint8_t)cf_ReadByte(file); |
| 2701 | |
| 2702 | num_bytes_to_be_restored = cf_ReadInt(file); |
| 2703 | |
| 2704 | Osiris_timer_counter = cf_ReadInt(file); |
| 2705 | |
| 2706 | // restore timer state |
| 2707 | for (i = 0; i < MAX_OSIRIS_TIMERS; i++) { |
| 2708 | if (cf_ReadByte(file)) { |
| 2709 | // timer is used |
| 2710 | OsirisTimers[i].flags = cf_ReadShort(file); |
| 2711 | OsirisTimers[i].id = cf_ReadInt(file); |
| 2712 | OsirisTimers[i].repeat_count = cf_ReadInt(file); |
| 2713 | OsirisTimers[i].timer_interval = cf_ReadFloat(file); |
| 2714 | OsirisTimers[i].timer_next_signal = cf_ReadFloat(file); |
| 2715 | OsirisTimers[i].timer_end = cf_ReadFloat(file); |
| 2716 | OsirisTimers[i].objhandle = cf_ReadInt(file); |
| 2717 | OsirisTimers[i].objhandle_detonator = cf_ReadInt(file); |
| 2718 | OsirisTimers[i].handle = cf_ReadInt(file); |
| 2719 | |
| 2720 | } else { |
| 2721 | OsirisTimers[i].flags = 0; |
| 2722 | } |
| 2723 | } |
| 2724 | |
| 2725 | // restore auto-saved memory chunks |
| 2726 | Osiris_RestoreMemoryChunks(file); |
| 2727 | |
| 2728 | // now we need to restore the global state of the DLLs |
| 2729 | // byte offset size description |
| 2730 | // 0 1 Number of loaded DLLs |
| 2731 | // ... |
| 2732 | // +1 1 String length of module name |
| 2733 | // +2 x Name of the module |
| 2734 | // +2+x 4 Size of global data stored |
| 2735 | // +6+x y global data |
| 2736 | // ... |
| 2737 | int loaded_module_count = 0; |
| 2738 | for (i = 0; i < MAX_LOADED_MODULES; i++) { |
| 2739 | if (OSIRIS_loaded_modules[i].flags & OSIMF_INUSE) { |
| 2740 | // this is a loaded module |
| 2741 | loaded_module_count++; |
| 2742 | } |
| 2743 | } |
no test coverage detected