Buidcost in buildings ovewview is not updated correctly

Bug #1704955 reported by GunChleoc on 2017-07-18
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Widelands Website
Undecided
Unassigned

Bug Description

https://wl.widelands.org/encyclopedia/atlanteans/buildings/

e.g. for atlantean Armor smithy and atlantean Barracks. The buildcosts are not shown correctly in the table, but in the details of a building (click on building) the amount is correct. E.g. Detail Atlantean Armor Smithy counts 2 logs and 1 quartz. This is exactly what the corresponding init.lua contains. But in buildings overview the buildcost counts 1 log and 2 quartz (correct is 2 log, 1 quartz).

Since the detail view is correct, he info in the JSON files is probably correct as well. So, I suspect the bug is in the Python script.

Reported on the forums: https://wl.widelands.org/forum/topic/2900/

Related branches

kaputtnik (franku) wrote :

Thanks for the bug report. I looked into the json files and they seem to be correct.

My first idea is that there is a mismatch in the database between wares and amounts, but i didn't looked into that yet.

kaputtnik (franku) wrote :

The problem here is that there is no relation between build_costs and build_wares. The values get stored into the database in different fields:

    # Build cost
    build_wares = models.ManyToManyField(
        Ware, related_name='build_ware_for_buildings', blank=True)
    # ' '.joined() integer strings
    build_costs = models.CharField(max_length=100, blank=True)

Creating the relation between build_costs and build_wares is done in get_build_cost(). Retrieving build_wares is done through a query:

        for c, w in zip(count, self.build_wares.all()):
            yield [w] * c

and the query ( self.build_wares.all() ) returns the build_wares in a different order than stored in build_costs. So for atlantean Armor Smithy the result is: build_costs are '2 1 2 2' and the query returns: granite log planks quartz. The result is:

buildcost / query order
 2 / Granite
 1 / Log
 2 / Planks
 2 / Quartz

I currently don't know how to solve this. Since there is a possibility to get a default ordering of queries, we may have to make sure the values of build_costs are stored in the same order, say alphabetical depending on the name of ware? I think this would be just a workaround...

kaputtnik (franku) on 2017-07-23
Changed in widelands-website:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers