The International Simutrans Forum

Simutrans Extended => Simutrans-Extended bug reports => Simutrans-Extended development => Simutrans-Extended closed bug reports => Topic started by: Philip on September 04, 2013, 06:15:53 PM

Title: [11.x] endless money rebuilding stations
Post by: Philip on September 04, 2013, 06:15:53 PM
It seems we changed the cost calculation in simwerkz.cc:wkz_station_aux, but kept the old formula for the refund cost; in some cases (bus stop with shelter, which has level 3 but b = h = 1), this can be used to generate endless money re-building the same stop in the same square over and over.

This should fix it:


diff --git a/simwerkz.cc b/simwerkz.cc
index 0497ca0..e094e91 100644
--- a/simwerkz.cc
+++ b/simwerkz.cc
@@ -3967,6 +3967,8 @@ DBG_MESSAGE("wkz_halt_aux()", "building %s on square %d,%d for waytype %x", besc

        halthandle_t old_halt = bd->get_halt();
        uint16 old_level = 0;
+       int old_b = 0;
+       int old_h = 0;

        halthandle_t halt;

@@ -3976,6 +3978,8 @@ DBG_MESSAGE("wkz_halt_aux()", "building %s on square %d,%d for waytype %x", besc
                {
                        const haus_besch_t *old_besch = gb->get_tile()->get_besch();
                        old_level = old_besch->get_level();
+                       old_b = old_besch->get_b();
+                       old_h = old_besch->get_h();
                        if( old_besch->get_level() >= besch->get_level() &&  old_besch->get_station_capacity() > besch-
                        {
                                return "Upgrade must have\na higher level";
@@ -4016,7 +4020,7 @@ DBG_MESSAGE("wkz_halt_aux()", "building %s on square %d,%d for waytype %x", besc
                free(name);
        }

-       const sint64 old_cost = old_level * cost;
+       const sint64 old_cost = old_b * old_h * cost;
       
        adjusted_cost -= old_cost / 2;


Title: Re: [11.x] endless money rebuilding stations
Post by: jamespetts on September 04, 2013, 11:57:52 PM
Thank you very much - fix applied on the 11.x branch. That is very helpful.
Title: Re: [11.x] endless money rebuilding stations
Post by: Philip on September 05, 2013, 05:13:49 PM
We're still not quite doing the right thing—which would be to calculate the old station cost using the logic from wkz_station_t::work (which is already duplicated in wkz_station_t::get_tooltip, so it would make sense to reorder that code). However, it might make most sense to remove the 50% refund entirely, I think. It's unlikely to affect gameplay much, and more trouble than it's worth.
Title: Re: [11.x] endless money rebuilding stations
Post by: jamespetts on September 05, 2013, 05:36:24 PM
Hmm - I should be interested in others' views on this point.
Title: Re: [11.x] endless money rebuilding stations
Post by: ӔO on September 05, 2013, 06:33:01 PM
the 50% refund is for calculating upgrades (or downgrades) to ways and stations, correct?
Title: Re: [11.x] endless money rebuilding stations
Post by: jamespetts on September 05, 2013, 06:45:47 PM
Yes, if I recall correctly.
Title: Re: [11.x] endless money rebuilding stations
Post by: ӔO on September 06, 2013, 12:23:05 AM
is it possible to keep this for the ways, but remove it for stations and stops?

The way I see it, upgrading pavement is not as difficult and costly as upgrading buildings on top of it.

Buildings can be renovated and expanded, but the graphics look more like rebuilding structures entirely, so there is the cost to tear down and rebuild.
Title: Re: [11.x] endless money rebuilding stations
Post by: Philip on September 06, 2013, 10:50:29 AM
Hmm. Experimenting, it seems there's currently no refund for ways. The code is very confusing, but I don't see anything that would result in a 50% refund. Instead, it seems you pay the full price of the more expensive way even when downgrading, which seems too expensive to me.

Anyway, I'm only proposing to remove the refund for stations, not to change the code for ways in any way.
Title: Re: [11.x] endless money rebuilding stations
Post by: jamespetts on September 06, 2013, 11:00:29 AM
I should note that there is a plan (http://forum.simutrans.com/index.php?topic=8172.0) to introduce a system allowing a substantial discount for upgrading ways, but that is being held up in a rather long queue of prior projects. It will be an economically significant enhancement, however.