MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / extractAnimationPack

Method extractAnimationPack

tools/extractors/extract_unit_animation_packs.cpp:194–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194sp<BattleUnitAnimationPack>
195InitialGameStateExtractor::extractAnimationPack(GameState &state, const UString &path,
196 const UString &name) const
197{
198 std::ignore = state;
199 UString dirName = "xcom3/tacdata/";
200
201 auto p = mksp<BattleUnitAnimationPack>();
202
203 std::vector<AnimationDataAD> dataAD;
204 {
205 auto fileName = format("%s%s%s", dirName, path, ".ad");
206
207 auto inFile = fw().data->fs.open(fileName);
208 if (inFile)
209 {
210 auto fileSize = inFile.size();
211 auto objectCount = fileSize / sizeof(struct AnimationDataAD);
212
213 for (unsigned i = 0; i < objectCount; i++)
214 {
215 AnimationDataAD data;
216 inFile.read((char *)&data, sizeof(data));
217 if (!inFile)
218 {
219 LogError("Failed to read entry in \"%s\"", fileName);
220 return nullptr;
221 }
222 dataAD.push_back(data);
223 }
224 }
225 }
226
227 std::vector<AnimationDataUA> dataUA;
228 {
229 auto fileName = format("%s%s%s", dirName, path, ".ua");
230
231 auto inFile = fw().data->fs.open(fileName);
232 if (inFile)
233 {
234 auto fileSize = inFile.size();
235 auto objectCount = fileSize / sizeof(struct AnimationDataUA);
236
237 for (unsigned i = 0; i < objectCount; i++)
238 {
239 AnimationDataUA data;
240 inFile.read((char *)&data, sizeof(data));
241 if (!inFile)
242 {
243 LogError("Failed to read entry in \"%s\"", fileName);
244 return nullptr;
245 }
246 dataUA.push_back(data);
247 }
248 }
249 }
250
251 std::vector<AnimationDataUF> dataUF;

Callers 1

main.cppFile · 0.80

Calls 4

formatFunction · 0.85
openMethod · 0.80
readMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected