summaryrefslogtreecommitdiff
path: root/src/cargopacket.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-10-06 17:23:15 +0000
committerrubidium <rubidium@openttd.org>2009-10-06 17:23:15 +0000
commit5f59d0c5b4e85a3bb51936fa05b2c5493f571eca (patch)
treeca2af53f7c2c4af662725813b62d480a3748954d /src/cargopacket.cpp
parenta4835e3f0b8c0d4f330fc8e91bdd529af60cc7a3 (diff)
downloadopenttd-5f59d0c5b4e85a3bb51936fa05b2c5493f571eca.tar.xz
(svn r17720) -Codechange: guard the CargoPacket variables that are cached in CargoLists so they cannot be written from outside the CargoList class (based on patch by fonsinchen)
Diffstat (limited to 'src/cargopacket.cpp')
-rw-r--r--src/cargopacket.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index a961e62f4..6e08c6f6a 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -39,6 +39,15 @@ CargoPacket::CargoPacket(StationID source, uint16 count, SourceType source_type,
this->source_id = source_id;
}
+CargoPacket::CargoPacket(uint16 count, byte days_in_transit, Money feeder_share, SourceType source_type, SourceID source_id) :
+ feeder_share(feeder_share),
+ count(count),
+ days_in_transit(days_in_transit),
+ source_id(source_id)
+{
+ this->source_type = source_type;
+}
+
/**
* Invalidates (sets source_id to INVALID_SOURCE) all cargo packets from given source
* @param src_type type of source
@@ -149,7 +158,7 @@ bool CargoList::MoveTo(CargoList *dest, uint count, CargoList::MoveToAction mta,
break;
case MTA_TRANSFER:
- payment->PayTransfer(cp, cp->count);
+ cp->feeder_share += payment->PayTransfer(cp, cp->count);
break;
case MTA_UNLOAD:
@@ -178,7 +187,7 @@ bool CargoList::MoveTo(CargoList *dest, uint count, CargoList::MoveToAction mta,
cp_new->count = count;
dest->packets.push_back(cp_new);
- if (mta == MTA_TRANSFER) payment->PayTransfer(cp_new, count);
+ if (mta == MTA_TRANSFER) cp_new->feeder_share += payment->PayTransfer(cp_new, count);
} else {
payment->PayFinalDelivery(cp, count);
}