News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

[11.x] endless money rebuilding stations

Started by Philip, September 04, 2013, 06:15:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Philip

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;



jamespetts

Thank you very much - fix applied on the 11.x branch. That is very helpful.

Philip

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.

jamespetts

Hmm - I should be interested in others' views on this point.

ӔO

the 50% refund is for calculating upgrades (or downgrades) to ways and stations, correct?

jamespetts


ӔO

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.

Philip

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.

jamespetts

I should note that there is a plan 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.