# ai_cargolist.cpp

Go to the documentation of this file.

    00001 /* $Id: ai_cargolist.cpp 15299 2009-01-31 20:16:06Z smatz $ */
    00002
    00005 #include "ai_cargolist.hpp"
    00006 #include "ai_industry.hpp"
    00007 #include "../../cargotype.h"
    00008 #include "../../tile_type.h"
    00009 #include "../../industry.h"
    00010
    00011 AICargoList::AICargoList()
    00012 {
    00013   for (byte i = 0; i < NUM_CARGO; i++) {
    00014     const CargoSpec *c = ::GetCargo(i);
    00015     if (c->IsValid()) {
    00016       this->AddItem(i);
    00017     }
    00018   }
    00019 }
    00020
    00021 AICargoList_IndustryAccepting::AICargoList_IndustryAccepting(IndustryID industry_id)
    00022 {
    00023   if (!AIIndustry::IsValidIndustry(industry_id)) return;
    00024
    00025   Industry *ind = ::GetIndustry(industry_id);
    00026   for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
    00027     CargoID cargo_id = ind->accepts_cargo[i];
    00028     if (cargo_id != CT_INVALID) {
    00029       this->AddItem(cargo_id);
    00030     }
    00031   }
    00032 }
    00033
    00034 AICargoList_IndustryProducing::AICargoList_IndustryProducing(IndustryID industry_id)
    00035 {
    00036   if (!AIIndustry::IsValidIndustry(industry_id)) return;
    00037
    00038   Industry *ind = ::GetIndustry(industry_id);
    00039   for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
    00040     CargoID cargo_id = ind->produced_cargo[i];
    00041     if (cargo_id != CT_INVALID) {
    00042       this->AddItem(cargo_id);
    00043     }
    00044   }
    00045 }