Skip to content

Commit

Permalink
Merge pull request #1305 from Kurtsley/lab-list
Browse files Browse the repository at this point in the history
Fix lab choice when no scientist selected
  • Loading branch information
FilmBoy84 committed Jan 4, 2024
2 parents 8fe932c + afd7c33 commit d102d38
Showing 1 changed file with 42 additions and 26 deletions.
68 changes: 42 additions & 26 deletions game/ui/tileview/cityview.cpp
Expand Up @@ -135,54 +135,70 @@ sp<Facility> findCurrentResearchFacility(sp<GameState> state, AgentType::Role ro
FacilityType::Capacity capacity)
{
sp<Facility> lab;
for (auto &a : state->current_city->cityViewSelectedCivilians)
if (!state->current_city->cityViewSelectedCivilians.empty())
{
if (a && a->type->role == role)
for (auto &a : state->current_city->cityViewSelectedCivilians)
{
state->current_base = a->homeBuilding->base;
if (a->assigned_to_lab)
if (a && a->type->role == role)
{
auto thisRef = StateRef<Agent>{state.get(), a};
for (auto &fac : state->current_base->facilities)
state->current_base = a->homeBuilding->base;
if (a->assigned_to_lab)
{
if (!fac->lab)
auto thisRef = StateRef<Agent>{state.get(), a};
for (auto &fac : state->current_base->facilities)
{
continue;
if (!fac->lab)
{
continue;
}
auto it = std::find(fac->lab->assigned_agents.begin(),
fac->lab->assigned_agents.end(), thisRef);
if (it != fac->lab->assigned_agents.end())
{
lab = fac;
break;
}
}
auto it = std::find(fac->lab->assigned_agents.begin(),
fac->lab->assigned_agents.end(), thisRef);
if (it != fac->lab->assigned_agents.end())
}
else
{
for (auto &f : state->current_base->facilities)
{
lab = fac;
break;
if (f->type->capacityType == capacity)
{
lab = f;
break;
}
}
}
break;
}
else
}
if (lab == nullptr)
{
for (auto &base : state->player_bases)
{
for (auto &f : state->current_base->facilities)
for (auto &facility : base.second->facilities)
{
if (f->type->capacityType == capacity)
if (facility->type->capacityType == capacity)
{
lab = f;
lab = facility;
break;
}
}
if (lab)
break;
}
break;
}
}
if (lab == nullptr)
else
{
for (auto &base : state->player_bases)
for (auto &f : state->current_base->facilities)
{
for (auto &facility : base.second->facilities)
if (f->type->capacityType == capacity)
{
if (facility->type->capacityType == capacity)
{
lab = facility;
break;
}
lab = f;
break;
}
if (lab)
break;
Expand Down

0 comments on commit d102d38

Please sign in to comment.