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

Method extractImagePack

tools/extractors/extract_unit_image_packs.cpp:12–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10{
11
12sp<BattleUnitImagePack> InitialGameStateExtractor::extractImagePack(GameState &state,
13 const UString &path,
14 bool shadow) const
15{
16 std::ignore = state;
17 UString dirName = "xcom3/tacdata/";
18
19 auto imageTabFileName = format("%s%s.tab", dirName, path);
20 auto imageTabFile = fw().data->fs.open(imageTabFileName);
21 if (!imageTabFile)
22 {
23 LogError("Failed to open TAB file \"%s\"", imageTabFileName);
24 return nullptr;
25 }
26 size_t imageTabFileEntryCount = imageTabFile.size() / 4;
27
28 auto p = mksp<BattleUnitImagePack>();
29
30 p->image_offset = shadow ? BATTLE_SHADOW_OFFSET : BATTLE_IMAGE_OFFSET;
31
32 for (size_t i = 0; i < imageTabFileEntryCount; i++)
33 {
34 p->images.push_back(
35 fw().data->loadImage(format("%s:%s%s.pck:%s%s.tab:%u", shadow ? "PCKSHADOW" : "PCK",
36 dirName, path, dirName, path, (unsigned)i)));
37 }
38
39 return p;
40}
41
42sp<BattleUnitImagePack> InitialGameStateExtractor::extractItemImagePack(GameState &state,
43 int item) const

Callers 1

main.cppFile · 0.80

Calls 4

formatFunction · 0.85
openMethod · 0.80
sizeMethod · 0.45
loadImageMethod · 0.45

Tested by

no test coverage detected