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

Function updateOwnerStatus

src/OpenLoco/src/World/CompanyManager.cpp:996–1079  ·  view source on GitHub ↗

0x004383ED

Source from the content-addressed store, hash-verified

994
995 // 0x004383ED
996 void updateOwnerStatus()
997 {
998 if (SceneManager::isTitleMode() || SceneManager::isEditorMode())
999 {
1000 return;
1001 }
1002
1003 auto companyId = GameCommands::getUpdatingCompanyId();
1004 auto company = CompanyManager::get(companyId);
1005 if (company == nullptr)
1006 {
1007 return;
1008 }
1009
1010 company->updateCounter += 1;
1011 if ((company->updateCounter % 128) != 0)
1012 {
1013 return;
1014 }
1015
1016 for (size_t i = 0; i < WindowManager::count(); i++)
1017 {
1018 auto w = WindowManager::get(i);
1019
1020 if (w->type != WindowType::vehicle)
1021 {
1022 continue;
1023 }
1024
1025 auto* vehicle = EntityManager::get<Vehicles::VehicleBase>(EntityId(w->number));
1026 if (vehicle == nullptr)
1027 {
1028 continue;
1029 }
1030
1031 if (vehicle->position.x == Location::null)
1032 {
1033 continue;
1034 }
1035
1036 if (vehicle->owner != companyId)
1037 {
1038 continue;
1039 }
1040
1041 GameCommands::UpdateOwnerStatusArgs args{};
1042 args.ownerStatus = OwnerStatus(vehicle->id);
1043
1044 GameCommands::doCommand(args, GameCommands::Flags::apply);
1045 return;
1046 }
1047
1048 auto main = WindowManager::getMainWindow();
1049 if (main == nullptr)
1050 {
1051 return;
1052 }
1053

Callers 1

sub_431695Function · 0.50

Calls 12

isTitleModeFunction · 0.85
isEditorModeFunction · 0.85
getUpdatingCompanyIdFunction · 0.85
countFunction · 0.85
EntityIdEnum · 0.85
OwnerStatusClass · 0.85
getMainWindowFunction · 0.85
getSurfaceLocFromUiFunction · 0.85
getUiCentreMethod · 0.80
getCentreMapPositionMethod · 0.80
getFunction · 0.70
doCommandFunction · 0.50

Tested by

no test coverage detected