00001 /* $Id: script_cargolist.cpp 23355 2011-11-29 23:15:35Z truebrain $ */ 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 "script_cargolist.hpp" 00014 #include "script_industry.hpp" 00015 #include "script_station.hpp" 00016 #include "../../cargotype.h" 00017 #include "../../industry.h" 00018 #include "../../station_base.h" 00019 00020 ScriptCargoList::ScriptCargoList() 00021 { 00022 const CargoSpec *cs; 00023 FOR_ALL_CARGOSPECS(cs) { 00024 this->AddItem(cs->Index()); 00025 } 00026 } 00027 00028 ScriptCargoList_IndustryAccepting::ScriptCargoList_IndustryAccepting(IndustryID industry_id) 00029 { 00030 if (!ScriptIndustry::IsValidIndustry(industry_id)) return; 00031 00032 Industry *ind = ::Industry::Get(industry_id); 00033 for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) { 00034 CargoID cargo_id = ind->accepts_cargo[i]; 00035 if (cargo_id != CT_INVALID) { 00036 this->AddItem(cargo_id); 00037 } 00038 } 00039 } 00040 00041 ScriptCargoList_IndustryProducing::ScriptCargoList_IndustryProducing(IndustryID industry_id) 00042 { 00043 if (!ScriptIndustry::IsValidIndustry(industry_id)) return; 00044 00045 Industry *ind = ::Industry::Get(industry_id); 00046 for (uint i = 0; i < lengthof(ind->produced_cargo); i++) { 00047 CargoID cargo_id = ind->produced_cargo[i]; 00048 if (cargo_id != CT_INVALID) { 00049 this->AddItem(cargo_id); 00050 } 00051 } 00052 } 00053 00054 ScriptCargoList_StationAccepting::ScriptCargoList_StationAccepting(StationID station_id) 00055 { 00056 if (!ScriptStation::IsValidStation(station_id)) return; 00057 00058 Station *st = ::Station::Get(station_id); 00059 for (CargoID i = 0; i < NUM_CARGO; i++) { 00060 if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::GES_ACCEPTANCE)) this->AddItem(i); 00061 } 00062 }