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

Method initState

game/state/gamestate.cpp:136–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134StateRef<Organisation> GameState::getCivilian() { return this->civilian; }
135
136void GameState::initState()
137{
138 if (current_battle)
139 {
140 current_battle->initBattle(*this);
141 }
142
143 for (auto &c : this->cities)
144 {
145 auto &city = c.second;
146 for (auto &s : city->scenery)
147 {
148 for (auto &b : city->buildings)
149 {
150 auto &building = b.second;
151 Vec2<int> pos2d{s->initialPosition.x, s->initialPosition.y};
152 if (building->bounds.within(pos2d))
153 {
154 s->building = {this, building};
155 if (s->isAlive() && !s->type->commonProperty)
156 {
157 s->building->buildingParts.insert(s->initialPosition);
158 }
159 break;
160 }
161 }
162 }
163 }
164 for (auto &c : this->cities)
165 {
166 auto &city = c.second;
167 city->initCity(*this);
168 if (newGame)
169 {
170 // if (c.first == "CITYMAP_HUMAN")
171 {
172 city->fillRoadSegmentMap(*this);
173 city->initialSceneryLinkUp();
174
175 // Use values provided with original maps for now
176 // Uncomment this if algoritm improves
177 // for (auto &b : c.second->buildings)
178 //{
179 // b.second->initBuilding(*this);
180 //}
181 }
182 }
183 // Add vehicles to map
184 for (auto &v : this->vehicles)
185 {
186 auto vehicle = v.second;
187 if (vehicle->city == city && !vehicle->currentBuilding && !vehicle->betweenDimensions)
188 {
189
190 city->map->addObjectToMap(*this, vehicle);
191 }
192 vehicle->strategyImages = city_common_image_list->strategyImages;
193 vehicle->setupMover();

Callers 4

loadGameMethod · 0.80
updateMethod · 0.80
loadGameFunction · 0.80
mainFunction · 0.80

Calls 15

validateFunction · 0.85
initBattleMethod · 0.80
withinMethod · 0.80
insertMethod · 0.80
initCityMethod · 0.80
fillRoadSegmentMapMethod · 0.80
initialSceneryLinkUpMethod · 0.80
addObjectToMapMethod · 0.80
setupMoverMethod · 0.80
emptyMethod · 0.80
generatePortalsMethod · 0.80
getFirstItemInSlotMethod · 0.80

Tested by 1

mainFunction · 0.64