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

Method updateEndOfSecond

game/state/gamestate.cpp:1088–1147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1086}
1087
1088void GameState::updateEndOfSecond()
1089{
1090 for (auto &b : current_city->buildings)
1091 {
1092 b.second->updateCargo(*this);
1093 if (!b.second->base || b.second->owner != getPlayer())
1094 {
1095 continue;
1096 }
1097 auto base = b.second->base;
1098 for (auto v : b.second->currentVehicles)
1099 {
1100 for (auto &e : v->equipment)
1101 {
1102 // We only can reload VehicleWeapon and VehicleEngine(?)
1103 if (e->type->type != EquipmentSlotType::VehicleWeapon &&
1104 e->type->type != EquipmentSlotType::VehicleEngine) // e->type->max_ammo == 0
1105 {
1106 continue;
1107 }
1108 // Only show events for vehicles owned by current player
1109 if (v->owner->name == getPlayer()->name)
1110 {
1111 if (e->reload(*this, base))
1112 {
1113 switch (e->type->type)
1114 {
1115 case EquipmentSlotType::VehicleEngine:
1116 fw().pushEvent(
1117 new GameVehicleEvent(GameEventType::VehicleRefuelled, v));
1118 break;
1119 case EquipmentSlotType::VehicleWeapon:
1120 fw().pushEvent(
1121 new GameVehicleEvent(GameEventType::VehicleRearmed, v));
1122 break;
1123 default:
1124 LogInfo("Implement the remaining messages for vehicle rearmed / "
1125 "reloaded / refueled / whatever");
1126 break;
1127 }
1128 }
1129 }
1130 }
1131 }
1132 }
1133 for (auto &v : vehicles)
1134 {
1135 if (v.second->city == current_city)
1136 {
1137 v.second->updateEachSecond(*this);
1138 }
1139 }
1140 for (auto &a : this->agents)
1141 {
1142 if (a.second->city == current_city)
1143 {
1144 a.second->updateEachSecond(*this);
1145 }

Callers 1

updateMethod · 0.95

Calls 4

reloadMethod · 0.80
pushEventMethod · 0.80
updateCargoMethod · 0.45
updateEachSecondMethod · 0.45

Tested by

no test coverage detected