Skip to content

InfrastructureManager::infrastructureConstructionHandler does not remove demand-triggered infrastructure #36

@degorelick

Description

@degorelick

Lines 388-401 of InfrastructureManager.cpp on master branch will not properly remove a built project from the demand_infra_construction_order vector if any ROF-triggered projects exist (i.e. if rof_infra_construction_order is not empty) because of the if-elseif structure. Given increasing demand, this can result in repeated implementation of the same demand-triggered project. A solution would be replacing these lines with the following:

                bool rof_check = false; bool demand_check = false;
                if (!rof_infra_construction_order.empty()) {
                    Utils::removeIntFromVector(rof_infra_construction_order, wss);
                    rof_check = true;
                }
                if (!demand_infra_construction_order.empty()) {
                    Utils::removeIntFromVector(demand_infra_construction_order, wss);
                    demand_check = true;
                }
                // if a project was triggered, but removed from neither list, throw error
                if (!rof_check && !demand_check)
                    throw logic_error("Infrastructure option whose construction was"
                                        " complete is not in the demand or "
                                        "rof triggered construction lists.");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions