# ai_cargolist.cpp

Go to the documentation of this file.

    00001 /* $Id: ai_cargolist.cpp 17693 2009-10-04 17:16:41Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #include "ai_cargolist.hpp"
    00013 #include "ai_industry.hpp"
    00014 #include "../../cargotype.h"
    00015 #include "../../industry.h"
    00016
    00017 AICargoList::AICargoList()
    00018 {
    00019   const CargoSpec *cs;
    00020   FOR_ALL_CARGOSPECS(cs) {
    00021     this->AddItem(cs->Index());
    00022   }
    00023 }
    00024
    00025 AICargoList_IndustryAccepting::AICargoList_IndustryAccepting(IndustryID industry_id)
    00026 {
    00027   if (!AIIndustry::IsValidIndustry(industry_id)) return;
    00028
    00029   Industry *ind = ::Industry::Get(industry_id);
    00030   for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
    00031     CargoID cargo_id = ind->accepts_cargo[i];
    00032     if (cargo_id != CT_INVALID) {
    00033       this->AddItem(cargo_id);
    00034     }
    00035   }
    00036 }
    00037
    00038 AICargoList_IndustryProducing::AICargoList_IndustryProducing(IndustryID industry_id)
    00039 {
    00040   if (!AIIndustry::IsValidIndustry(industry_id)) return;
    00041
    00042   Industry *ind = ::Industry::Get(industry_id);
    00043   for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
    00044     CargoID cargo_id = ind->produced_cargo[i];
    00045     if (cargo_id != CT_INVALID) {
    00046       this->AddItem(cargo_id);
    00047     }
    00048   }
    00049 }