# cargo_type.h

Go to the documentation of this file.

    00001 /* $Id: cargo_type.h 18413 2009-12-05 21:39:28Z alberth $ */
    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 #ifndef CARGO_TYPE_H
    00013 #define CARGO_TYPE_H
    00014
    00015 #include "core/enum_type.hpp"
    00016
    00022 typedef byte CargoID;
    00023
    00025 enum CargoTypes {
    00026   /* Temperate */
    00027   CT_PASSENGERS   =  0,
    00028   CT_COAL         =  1,
    00029   CT_MAIL         =  2,
    00030   CT_OIL          =  3,
    00031   CT_LIVESTOCK    =  4,
    00032   CT_GOODS        =  5,
    00033   CT_GRAIN        =  6,
    00034   CT_WOOD         =  7,
    00035   CT_IRON_ORE     =  8,
    00036   CT_STEEL        =  9,
    00037   CT_VALUABLES    = 10,
    00038
    00039   /* Arctic */
    00040   CT_WHEAT        =  6,
    00041   CT_HILLY_UNUSED =  8,
    00042   CT_PAPER        =  9,
    00043   CT_GOLD         = 10,
    00044   CT_FOOD         = 11,
    00045
    00046   /* Tropic */
    00047   CT_RUBBER       =  1,
    00048   CT_FRUIT        =  4,
    00049   CT_MAIZE        =  6,
    00050   CT_COPPER_ORE   =  8,
    00051   CT_WATER        =  9,
    00052   CT_DIAMONDS     = 10,
    00053
    00054   /* Toyland */
    00055   CT_SUGAR        =  1,
    00056   CT_TOYS         =  3,
    00057   CT_BATTERIES    =  4,
    00058   CT_CANDY        =  5,
    00059   CT_TOFFEE       =  6,
    00060   CT_COLA         =  7,
    00061   CT_COTTON_CANDY =  8,
    00062   CT_BUBBLES      =  9,
    00063   CT_PLASTIC      = 10,
    00064   CT_FIZZY_DRINKS = 11,
    00065
    00066   NUM_CARGO       = 32,
    00067
    00068   CT_NO_REFIT     = 0xFE,
    00069   CT_INVALID      = 0xFF,
    00070 };
    00071
    00073 struct CargoArray {
    00074 private:
    00075   uint amount[NUM_CARGO];
    00076
    00077 public:
    00079   FORCEINLINE CargoArray()
    00080   {
    00081     this->Clear();
    00082   }
    00083
    00085   FORCEINLINE void Clear()
    00086   {
    00087     memset(this->amount, 0, sizeof(this->amount));
    00088   }
    00089
    00093   FORCEINLINE uint &operator[](CargoID cargo)
    00094   {
    00095     return this->amount[cargo];
    00096   }
    00097
    00101   FORCEINLINE const uint &operator[](CargoID cargo) const
    00102   {
    00103     return this->amount[cargo];
    00104   }
    00105 };
    00106
    00107
    00109 enum SourceType {
    00110   ST_INDUSTRY,
    00111   ST_TOWN,
    00112   ST_HEADQUARTERS,
    00113 };
    00114 typedef SimpleTinyEnumT<SourceType, byte> SourceTypeByte;
    00115
    00116 typedef uint16 SourceID;
    00117 static const SourceID INVALID_SOURCE = 0xFFFF;
    00118
    00119 #endif /* CARGO_TYPE_H */