MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / CSavedGameWrapper

Method CSavedGameWrapper

ogsr_engine/xrGame/saved_game_wrapper.cpp:72–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72CSavedGameWrapper::CSavedGameWrapper(LPCSTR saved_game_name)
73{
74 string_path file_name;
75 saved_game_full_name(saved_game_name, file_name);
76 R_ASSERT3(FS.exist(file_name), "There is no saved game ", file_name);
77
78 u32 magic = 0;
79
80 IReader* stream = FS.r_open(file_name);
81 if (!valid_saved_game(*stream, magic))
82 {
83 FS.r_close(stream);
84 CALifeTimeManager time_manager(alife_section);
85 m_game_time = time_manager.game_time();
86 m_actor_health = 1.f;
87 m_level_id = _LEVEL_ID(-1);
88 m_level_name = "";
89 return;
90 }
91
92 u32 source_count = stream->r_u32();
93 void* source_data = xr_malloc(source_count);
94 if (magic == 0)
95 R_ASSERT(ZSTD_decompress(source_data, source_count, stream->pointer(), stream->length() - 3 * sizeof(u32)) == source_count);
96 else
97 rtc_decompress(source_data, source_count, stream->pointer(), stream->length() - 3 * sizeof(u32));
98 FS.r_close(stream);
99
100 IReader reader(source_data, source_count);
101
102 {
103 CALifeTimeManager time_manager(alife_section);
104 time_manager.load(reader);
105 m_game_time = time_manager.game_time();
106 }
107
108 {
109 R_ASSERT2(reader.find_chunk(OBJECT_CHUNK_DATA), "Can't find chunk OBJECT_CHUNK_DATA!");
110#ifdef DEBUG
111 u32 count =
112#endif
113 reader.r_u32();
114 VERIFY(count > 0);
115 CSE_ALifeDynamicObject* object = CALifeObjectRegistry::get_object(reader);
116 VERIFY(object->ID == 0);
117 CSE_ALifeCreatureActor* actor = smart_cast<CSE_ALifeCreatureActor*>(object);
118 VERIFY(actor);
119
120 m_actor_health = actor->g_Health();
121
122 IReader* R = reader.open_chunk(SPAWN_CHUNK_DATA);
123 R_ASSERT(R, "Spawn version mismatch - REBUILD SPAWN!");
124
125 string_path spawn_file_name;
126 {
127 IReader* sub_chunk = R->open_chunk(0);
128 if (!sub_chunk)
129 {

Callers

nothing calls this directly

Calls 15

xr_mallocFunction · 0.85
rtc_decompressFunction · 0.85
get_objectFunction · 0.85
F_entity_DestroyFunction · 0.85
CStringTableClass · 0.85
xr_freeFunction · 0.85
existMethod · 0.80
r_openMethod · 0.80
r_closeMethod · 0.80
game_timeMethod · 0.80
pointerMethod · 0.80
find_chunkMethod · 0.80

Tested by

no test coverage detected