longturn / freeciv21

Develop your civilization from humble roots to a global empire
GNU General Public License v3.0
223 stars 42 forks source link

Show obsolete buildings in economy view #1861

Open jwrober opened 1 year ago

jwrober commented 1 year ago

Describe the bug Some city improvements become obsolete via technology or by different forms of government, e.g. the Workshop in LTX has no effect when in Democracy or Federation. The "redundant" column in econ view doesn't show this.

To Reproduce Steps to reproduce the behavior:

  1. Play an LTX game
  2. Build some workshops
  3. Switch to Democracy
  4. See error

Expected behavior If a building isn't doing anything it is redundant and should be shown as such

Screenshots N/A

Platform and version (please complete the following information):

Additional context Came up while playing LT76Teams game.

lmoureaux commented 1 year ago

To be checked, but I think phrasing the ruleset in a different way could make the workshop look "redundant" to the code. It's a bit peculiar as one could expect...

https://github.com/longturn/freeciv21/blob/3761a311762fe5d91b70f9f523bd0936bba1847f/common/effects.cpp#L535

The workshop is implemented in LTX as (code):

[effect_workshop]
type    = "Output_Bonus"
value   = 30
reqs    =
    { "type", "name", "range"
      "Gov", "Monarchy", "Player", TRUE
      "Building", "Workshop", "City"
      "OutputType", "Shield", "Local"
    }
... and similar for other Republic and City States

It looks like implementing it as follows would make the "redundant" code work:

[effect_workshop]
type    = "Output_Bonus"
value   = 30
reqs    =
    { "type", "name", "range", "present"
      "Building", "Workshop", "City", TRUE
      "OutputType", "Shield", "Local", TRUE
      "Gov", "Anarchy", "Player", FALSE
      "Gov", "Despotism", "Player", FALSE
      "Gov", "Tribal", "Player", FALSE
      "Gov", "Fundamentalism", "Player", FALSE
      "Gov", "Democracy", "Player", FALSE
      "Gov", "Federation", "Player", FALSE
      "Gov", "Communism", "Player", FALSE
    }
... and similar for pollution effects

The key here is to have requirements with present=FALSE that disable the effect.