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

Method loadImagePacks

game/state/battle/battle.cpp:3470–3603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3468}
3469
3470void Battle::loadImagePacks(GameState &state)
3471{
3472 if (state.battle_unit_image_packs.size() > 0)
3473 {
3474 LogInfo("Image packs are already loaded.");
3475 return;
3476 }
3477 // Find out all image packs used by map's units and items
3478 std::set<UString> imagePacks;
3479 UString brainsucker = "bsk";
3480 bool brainsuckerFound = false;
3481 UString hyperworm = "hypr";
3482 UString multiworm = "multi";
3483 bool hyperwormFound = false;
3484
3485 for (auto &o : participants)
3486 {
3487 for (auto &t : o->guard_types_reinforcements)
3488 {
3489 {
3490 auto packName = BattleUnitImagePack::getNameFromID(t->shadow_pack.id);
3491 if (imagePacks.find(packName) == imagePacks.end())
3492 imagePacks.insert(packName);
3493 }
3494 for (auto &pv : t->image_packs)
3495 {
3496 for (auto &ip : pv)
3497 {
3498 auto packName = BattleUnitImagePack::getNameFromID(ip.second.id);
3499 if (imagePacks.find(packName) == imagePacks.end())
3500 imagePacks.insert(packName);
3501 if (packName == hyperworm)
3502 {
3503 hyperwormFound = true;
3504 }
3505 if (!hyperwormFound && packName == multiworm)
3506 {
3507 imagePacks.insert(hyperworm);
3508 imagePacks.insert(hyperworm + "s");
3509 hyperwormFound = true;
3510 }
3511 if (packName == brainsucker)
3512 {
3513 brainsuckerFound = true;
3514 }
3515 }
3516 }
3517 }
3518 }
3519
3520 for (auto &p : units)
3521 {
3522 auto &bu = p.second;
3523 {
3524 auto packName = BattleUnitImagePack::getNameFromID(bu->agent->type->shadow_pack.id);
3525 if (imagePacks.find(packName) == imagePacks.end())
3526 imagePacks.insert(packName);
3527 }

Callers

nothing calls this directly

Calls 6

formatFunction · 0.85
endMethod · 0.80
insertMethod · 0.80
getPayloadTypeMethod · 0.80
loadImagePackMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected