MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / updateYearly2

Function updateYearly2

src/OpenLoco/src/Objects/ObjectManager.cpp:1036–1082  ·  view source on GitHub ↗

0x004C3A9E

Source from the content-addressed store, hash-verified

1034
1035 // 0x004C3A9E
1036 void updateYearly2()
1037 {
1038 const auto currentYear = getCurrentYear();
1039 for (uint16_t vehicleObjId = 0; vehicleObjId < ObjectManager::getMaxObjects(ObjectType::vehicle); vehicleObjId++)
1040 {
1041 const auto* vehicleObject = ObjectManager::get<VehicleObject>(vehicleObjId);
1042 if (vehicleObject == nullptr)
1043 {
1044 continue;
1045 }
1046 if (currentYear == vehicleObject->designed)
1047 {
1048 for (Company& company : CompanyManager::companies())
1049 {
1050 const auto forbiddenVehicles = CompanyManager::isPlayerCompany(company.id()) ? getGameState().forbiddenVehiclesPlayers : getGameState().forbiddenVehiclesCompetitors;
1051 if (forbiddenVehicles & (1U << enumValue(vehicleObject->type)))
1052 {
1053 continue;
1054 }
1055 if (company.unlockedVehicles[vehicleObjId])
1056 {
1057 continue;
1058 }
1059 company.unlockedVehicles.set(vehicleObjId, true);
1060 company.availableVehicles = VehicleManager::determineAvailableVehicleTypes(company);
1061 if (CompanyManager::getControllingId() != company.id())
1062 {
1063 continue;
1064 }
1065 if (vehicleObject->hasFlags(VehicleObjectFlags::quietInvention))
1066 {
1067 continue;
1068 }
1069 MessageManager::post(MessageType::newVehicle, CompanyId::null, vehicleObjId, 0xFFFF);
1070 }
1071 }
1072 if (currentYear == vehicleObject->obsolete)
1073 {
1074 for (Company& company : CompanyManager::companies())
1075 {
1076 company.unlockedVehicles.set(vehicleObjId, false);
1077 }
1078 }
1079 }
1080 Ui::Windows::Construction::updateAvailableRoadAndRailOptions();
1081 Ui::Windows::Construction::updateAvailableAirportAndDockOptions();
1082 }
1083
1084 // 0x004697A1
1085 static void updateLandObjectFlags()

Callers 2

dateTickFunction · 0.85
onCloseFunction · 0.85

Calls 12

getCurrentYearFunction · 0.85
getMaxObjectsFunction · 0.85
companiesFunction · 0.85
isPlayerCompanyFunction · 0.85
enumValueFunction · 0.85
getControllingIdFunction · 0.85
postFunction · 0.85
idMethod · 0.45
hasFlagsMethod · 0.45

Tested by

no test coverage detected