summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-10-06 17:33:01 +0000
committerrubidium <rubidium@openttd.org>2009-10-06 17:33:01 +0000
commit832b21191d4091e9370103496671a6c9243ab1c9 (patch)
treeef0553ff6ed8efbdc8f0349c7f5d081ea6f8ad17 /src
parente0e5eae1eebf7a7b374743bdbc1bdfb49f764e8f (diff)
downloadopenttd-832b21191d4091e9370103496671a6c9243ab1c9.tar.xz
(svn r17722) -Codechange: simplify the cargopacket constructor; unduplicate if and don't set a value to 0 if it already is 0.
Diffstat (limited to 'src')
-rw-r--r--src/cargopacket.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index 4a3c9691b..8561bf069 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -23,20 +23,18 @@ void InitializeCargoPackets()
_cargopacket_pool.CleanPool();
}
-CargoPacket::CargoPacket(StationID source, uint16 count, SourceType source_type, SourceID source_id)
+CargoPacket::CargoPacket(StationID source, uint16 count, SourceType source_type, SourceID source_id) :
+ count(count),
+ source(source),
+ source_id(source_id)
{
- if (source != INVALID_STATION) assert(count != 0);
-
-// this->feeder_share = 0; // no need to zero already zeroed data (by operator new)
- this->source_xy = (source != INVALID_STATION) ? Station::Get(source)->xy : 0;
- this->loaded_at_xy = this->source_xy;
- this->source = source;
-
- this->count = count;
-// this->days_in_transit = 0;
-
this->source_type = source_type;
- this->source_id = source_id;
+
+ if (source != INVALID_STATION) {
+ assert(count != 0);
+ this->source_xy = Station::Get(source)->xy;
+ this->loaded_at_xy = this->source_xy;
+ }
}
CargoPacket::CargoPacket(uint16 count, byte days_in_transit, Money feeder_share, SourceType source_type, SourceID source_id) :