1 /* $Id: script_cargolist.cpp 23355 2011-11-29 23:15:35Z truebrain $ */
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file script_cargolist.cpp Implementation of ScriptCargoList and friends. */
12 #include "../../stdafx.h"
13 #include "script_cargolist.hpp"
14 #include "script_industry.hpp"
15 #include "script_station.hpp"
16 #include "../../cargotype.h"
17 #include "../../industry.h"
18 #include "../../station_base.h"
20 #include "../../safeguards.h"
22 ScriptCargoList::ScriptCargoList()
25 FOR_ALL_CARGOSPECS(cs
) {
26 this->AddItem(cs
->Index());
30 ScriptCargoList_IndustryAccepting::ScriptCargoList_IndustryAccepting(IndustryID industry_id
)
32 if (!ScriptIndustry::IsValidIndustry(industry_id
)) return;
34 Industry
*ind
= ::Industry::Get(industry_id
);
35 for (uint i
= 0; i
< lengthof(ind
->accepts_cargo
); i
++) {
36 CargoID cargo_id
= ind
->accepts_cargo
[i
];
37 if (cargo_id
!= CT_INVALID
) {
38 this->AddItem(cargo_id
);
43 ScriptCargoList_IndustryProducing::ScriptCargoList_IndustryProducing(IndustryID industry_id
)
45 if (!ScriptIndustry::IsValidIndustry(industry_id
)) return;
47 Industry
*ind
= ::Industry::Get(industry_id
);
48 for (uint i
= 0; i
< lengthof(ind
->produced_cargo
); i
++) {
49 CargoID cargo_id
= ind
->produced_cargo
[i
];
50 if (cargo_id
!= CT_INVALID
) {
51 this->AddItem(cargo_id
);
56 ScriptCargoList_StationAccepting::ScriptCargoList_StationAccepting(StationID station_id
)
58 if (!ScriptStation::IsValidStation(station_id
)) return;
60 Station
*st
= ::Station::Get(station_id
);
61 for (CargoID i
= 0; i
< NUM_CARGO
; i
++) {
62 if (HasBit(st
->goods
[i
].status
, GoodsEntry::GES_ACCEPTANCE
)) this->AddItem(i
);