When joining with public halts, the goods at the public halts get lost. This patch fixes this.
Index: simhalt.cc
===================================================================
--- simhalt.cc (revision 2489)
+++ simhalt.cc (working copy)
@@ -1772,6 +1772,9 @@
add_grund(gr);
// and check for existence
if(!halt->existiert_in_welt()) {
+ // transfer goods from halt to self
+ halt->transfer_goods(self);
+
destroy(halt);
}
}
@@ -1780,6 +1783,23 @@
recalc_station_type();
}
+void haltestelle_t::transfer_goods(halthandle_t halt)
+{
+ if (!self.is_bound() || !halt.is_bound()) {
+ return;
+ }
+ // transfer goods
+ for(uint8 i=0; i<warenbauer_t::get_max_catg_index(); i++) {
+ vector_tpl<ware_t> * warray = waren[i];
+ if (warray) {
+ for(uint32 j=0; j<warray->get_count(); j++) {
+ halt->add_ware_to_halt( (*warray)[j] );
+ }
+ delete waren[i];
+ waren[i] = NULL;
+ }
+ }
+}
/*
Index: simhalt.h
===================================================================
--- simhalt.h (revision 2489)
+++ simhalt.h (working copy)
@@ -478,6 +478,13 @@
uint32 liefere_an(ware_t ware);
uint32 starte_mit_route(ware_t ware);
+ /*
+ * transfers all goods to given station
+ *
+ * @author Dwachs
+ */
+ void transfer_goods(halthandle_t halt);
+
/**
* wird von Fahrzeug aufgerufen, wenn dieses an der Haltestelle
* gehalten hat.
Since this is called at exactly one location, I would use direct this code.
Thank you
Quote from: prissi on May 26, 2009, 07:59:50 PM
Since this is called at exactly one location, I would use direct this code.
Then however, the waren-variable has to be declared public, otherwise there is no chance for the new stop to get the goods of the joined stop.
I think it's better to put this code in an extra function even though it's only used in one location:
- If the same method is used in future, it's already a function and you haven't to search it in the code.
- It increases readability of the code, since you haven't to read 10 lines, but only the statement "transfer goods", and you know what this line does - or should do ;)
[idea]
How about a new tool: joining two (own) adjacent stops? This could be realized with the code, which makes a stop public.
[/idea]
Gerw,
that seems like a very useful idea :-)
It isn't in the game already? :o Of course supported... that might be very useful, although I can't imagine when - but it seems logical to enable this.
Quote from: VS on May 27, 2009, 08:40:47 AM
It isn't in the game already?
No. If you build two separate stops only some tiles away and connect them afterwards (e.g. if they "grow"). Then you get two adjacent halts.
Edit: By reading the code I think the change in r2492 doesn't work. It would remove also all goods from the halt ("delete waren
").
yes, you are right. It now transfers goods from self to self and deletes them afterwards, the transfer however should go from halt to self. Should be fixed in 2494.