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

Method extractBuildingFunctions

tools/extractors/extract_buildings.cpp:17–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15{
16
17void InitialGameStateExtractor::extractBuildingFunctions(GameState &state) const
18{
19 auto &data = this->ufo2p;
20
21 for (unsigned i = 0; i < data.building_functions->count(); i++)
22 {
23 auto f = mksp<BuildingFunction>();
24 f->name = data.building_functions->get(i);
25 if (i < data.building_cost_data->count())
26 {
27 const auto costEntry = data.building_cost_data->get(i);
28 // convert all values to signed integers to simplify calculations in-game
29 f->baseCost = static_cast<int>(costEntry.cost);
30 f->baseIncome = static_cast<int>(costEntry.income);
31 f->workersPerTile = static_cast<int>(costEntry.workers);
32 f->agentSpawnType = static_cast<int>(costEntry.agentSpawnType);
33 f->investmentValue = static_cast<int>(costEntry.investmentValue);
34 f->prestige = static_cast<int>(costEntry.respectValue);
35 }
36 if (i < data.infiltration_speed_building->count())
37 {
38 f->infiltrationSpeed = data.infiltration_speed_building->get(i).speed;
39 }
40 if (i < buildingFunctionDetectionWeights.size())
41 {
42 f->detectionWeight = buildingFunctionDetectionWeights[i];
43 }
44 auto id = format("%s%s", BuildingFunction::getPrefix(), canon_string(f->name));
45 auto ped = format("%s%s", UfopaediaEntry::getPrefix(), canon_string(f->name));
46 f->ufopaedia_entry = {&state, ped};
47 state.building_functions[id] = f;
48 }
49}
50
51void InitialGameStateExtractor::extractBuildings(GameState &state, UString bldFileName,
52 sp<City> city, bool alienBuilding) const

Callers 1

extractCommonMethod · 0.95

Calls 5

formatFunction · 0.85
canon_stringFunction · 0.85
countMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected