| 219 | } |
| 220 | |
| 221 | void AgentAssignment::updateLocation() |
| 222 | { |
| 223 | agents.clear(); |
| 224 | vehicles.clear(); |
| 225 | buildings.clear(); |
| 226 | |
| 227 | // update agents, vehicles and buildings lists |
| 228 | if (building) |
| 229 | { |
| 230 | for (auto &a : state->agents) |
| 231 | { |
| 232 | if (a.second->owner == state->getPlayer() && |
| 233 | a.second->type->role == AgentType::Role::Soldier && |
| 234 | (a.second->currentBuilding == building || |
| 235 | (a.second->currentVehicle && |
| 236 | a.second->currentVehicle->currentBuilding == building))) |
| 237 | { |
| 238 | agents.emplace_back(a.second); |
| 239 | } |
| 240 | } |
| 241 | for (auto &v : state->vehicles) |
| 242 | { |
| 243 | if (v.second->owner == state->getPlayer() && v.second->currentBuilding == building) |
| 244 | { |
| 245 | vehicles.emplace_back(v.second); |
| 246 | } |
| 247 | } |
| 248 | buildings.emplace_back(building); |
| 249 | } |
| 250 | else if (vehicle) |
| 251 | { |
| 252 | for (auto &a : state->agents) |
| 253 | { |
| 254 | if (a.second->owner == state->getPlayer() && |
| 255 | a.second->type->role == AgentType::Role::Soldier && |
| 256 | a.second->currentVehicle == vehicle) |
| 257 | { |
| 258 | agents.emplace_back(a.second); |
| 259 | } |
| 260 | } |
| 261 | vehicles.emplace_back(vehicle); |
| 262 | } |
| 263 | else if (agent) |
| 264 | { |
| 265 | agents.emplace_back(agent); |
| 266 | } |
| 267 | else |
| 268 | { |
| 269 | for (auto &a : state->agents) |
| 270 | { |
| 271 | if (a.second->owner == state->getPlayer() && |
| 272 | a.second->type->role == AgentType::Role::Soldier) |
| 273 | { |
| 274 | agents.emplace_back(a.second); |
| 275 | } |
| 276 | } |
| 277 | for (auto &v : state->vehicles) |
| 278 | { |
nothing calls this directly
no test coverage detected