longturn / freeciv21

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

After finishing a building that's obsoleted by another building, the city switches to a wrong build target #1398

Open daavko opened 2 years ago

daavko commented 2 years ago

Describe the bug If you have a building (concrete example: Lumber Yard in Aviation) that's obsoleted by another building (concrete example: Engine Factory in Aviation), and you buy this building, the city changes to the "obsoleted by" building for the next turn, instead of using the advisor.

To Reproduce Steps to reproduce the behavior:

  1. Start an Avi game (easiest to reproduce this way)
  2. Research Mass Production (unlocks Engine Factory)
  3. Start building a Lumber Yard in a city that doesn't have it yet
  4. Have no other buildings in the city's worklist
  5. Buy Lumber Yard so it's finished next turn
  6. Go to next turn
  7. Observe Lumber Yard finished building
  8. Observe the city switched to Engine Factory
  9. Observe you've received the message "Production of Lumber Yard is upgraded to Engine Factory in "

Expected behavior The city should use the advisor if it doesn't have a worklist, instead of upgrading production

Screenshots Messages freeciv21-client_923mCwTyJX

Platform and version (please complete the following information):

Additional context No additional context

jwrober commented 2 years ago

I think that is the correct behavior to upgrade to the current building. Does the same thing for units as well.

daavko commented 2 years ago

The problem with that is that you're still allowed to build both. It's not really the same thing as units where you just can't build the previous one at all. Engine Factory only obsoletes Lumber Yard after it's built in the city, not before, so you can still build a Lumber Yard after researching Engine Factory. Then, if you try to build a Lumber Yard, the city automatically changes it to Engine Factory every turn. Either it shouldn't be possible to build a Lumber Yard at all then (since apparently the city really doesn't want to build it), or it shouldn't auto-upgrade the production.

jwrober commented 2 years ago

Ok that makes more sense. In your reproduce example you buy the Lumber Yard, you can't switch production when you buy something. You are stuck with it until TC. It seems more like what you want is for the game to not allow you to build Lumber Yard at all once a newer "obsoleting" building becomes available. In this case, Engine Factory.

lmoureaux commented 1 year ago

The Lumber Yard in Aviation becomes obsolete once you have both an Engine Factory and an Aircraft Factory in the city [link]:

obsolete_by =
    { "type", "name", "range"
      "Building", "Engine Factory", "City"
      "Building", "Aircraft Factory", "City"
    }

However, the effect of the Lumber Yard is cancelled by having either of them in the city [link]:

[effect_lumber_yard]
type    = "Output_Bonus"
value   = 25
reqs    =
    { "type", "name", "range", "present"
      "Building", "Lumber Yard", "City", TRUE
      "Building", "Engine Factory", "City", FALSE
      "Building", "Aircraft Factory", "City", FALSE
      "OutputType", "Shield", "Local", TRUE
    }

I'm not sure exactly what confuses the game here, but I'm not surprised.