Barracks can't be built with old savegames

Bug #1685331 reported by GunChleoc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Undecided
Unassigned

Bug Description

When loading an old savegame (e.g. Build 19) in current trunk, the Barracks isn't added to the list of allowed buildings, turning the games unplayable.

Related branches

Revision history for this message
Notabilis (notabilis27) wrote :

A related message while loading the game:

WARNING: player 1 is allowed to create worker type Recruit but his Headquarters 259 at (11, 53) does not have a next_spawn time set for that worker type; setting it to 132107

(Printed by Warehouse::load_finish().)

I am not sure how to fix this, though. Always enabling the barracks when loading a game is not feasible since that would break campaigns even when saved with the same game version.
The easiest way would be to simply ignore it. Why should anyone load that old saves anyway? ;-)

We also could use the notification above and add a special case if the recruit has not been loaded (Or add a global special case when a pre-barracks save game is loaded. Not sure whether this is possible).
Then we could either revert to the old logic and make soldiers recruitable in the warehouses. However, this might affect games played afterwards when not restarting the program. Or we could enable barracks in this case. This would possibly result in a useless building when an old campaign save game has been loaded but would probably be fine for normal games.

Changed in widelands:
status: New → Confirmed
Revision history for this message
GunChleoc (gunchleoc) wrote :

We have an allow_buildings function - maybe check if it's < the number of buildings types for the tribe? That would take care of campaigns. We will have to keep non-seafaring maps in mind though, since they disallow ports and shipyards, and the weaving mill for barbarians. So, it might be easier to just add it after all and live with the extra building in the campaigns/scenarios.

I like to keep full savegame compatibility throughout a release cycle, repeatedly breaking it between Builds 18 and 19 was a pain in the butt for bug hunting. I'm planning to break it again after Build 20, just once at the start of the new release cycle.

Revision history for this message
Notabilis (notabilis27) wrote :

A possible solution is implemented in the attached branch. I haven't created a merge request yet since I am not that fond of the code. While it works for old saves and for current campaigns it uses hard coded names from the lua files, so when those change the code will break.

If you think this approach is fine, feel free to (request a) merge.

Revision history for this message
GunChleoc (gunchleoc) wrote :

The hard coding can be avoided if we add a function barracks() to TribeDescr, just like we have for the headquarters, for example. The definition then goes on the bottom of data/tribes/<tribename>.lua

Revision history for this message
Notabilis (notabilis27) wrote :

Do we also add a special type for recruits then? As an alternative we could get them by checking the inputs of the barracks.

Revision history for this message
Notabilis (notabilis27) wrote :

Barracks are added as a special building now. The recruit is found by checking the inputs of the barracks.

Revision history for this message
GunChleoc (gunchleoc) wrote :

The proposed branch only works with 1 of the attached savegames.

Notabilis (notabilis27)
Changed in widelands:
status: Confirmed → Fix Committed
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.