# ai_cargolist.cpp

Go to the documentation of this file.

    00001 /* $Id$ */
    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 "../../stdafx.h"
    00013 #include "ai_cargolist.hpp"
    00014 #include "ai_industry.hpp"
    00015 #include "../../cargotype.h"
    00016 #include "../../industry.h"
    00017
    00018 AICargoList::AICargoList()
    00019 {
    00020   const CargoSpec *cs;
    00021   FOR_ALL_CARGOSPECS(cs) {
    00022     this->AddItem(cs->Index());
    00023   }
    00024 }
    00025
    00026 AICargoList_IndustryAccepting::AICargoList_IndustryAccepting(IndustryID industry_id)
    00027 {
    00028   if (!AIIndustry::IsValidIndustry(industry_id)) return;
    00029
    00030   Industry *ind = ::Industry::Get(industry_id);
    00031   for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
    00032     CargoID cargo_id = ind->accepts_cargo[i];
    00033     if (cargo_id != CT_INVALID) {
    00034       this->AddItem(cargo_id);
    00035     }
    00036   }
    00037 }
    00038
    00039 AICargoList_IndustryProducing::AICargoList_IndustryProducing(IndustryID industry_id)
    00040 {
    00041   if (!AIIndustry::IsValidIndustry(industry_id)) return;
    00042
    00043   Industry *ind = ::Industry::Get(industry_id);
    00044   for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
    00045     CargoID cargo_id = ind->produced_cargo[i];
    00046     if (cargo_id != CT_INVALID) {
    00047       this->AddItem(cargo_id);
    00048     }
    00049   }
    00050 }