Building help: remove logic from wrappers

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

Bug Description

This bug will need attention after https://code.launchpad.net/~widelands-dev/widelands/bug-1074353 has been merged.

The following properties in lua_map.cc contain programming logic:

L_WareDescription::get_producers
L_WareDescription::get_consumers

catch-22: If I fill up the list in the constructor of WareDescr, the tribe's buildings haven't been parsed yet. If I fill it up later, I can't make it const, which then blows up in lua_map.cc.

Any ideas?

Comment from SirVer:

> How would I get it from there into the constructor of the WareDescr, which have already been parsed and constructed by this point?

You don't. You get the (mutable) wares_description container from the tribe_description into the building constructor and add a member (mutable_ware_description(), either in Tribe_Descr or if there is a container with every ware in there than there). So you can get something like this in the buildingdesc constructor:

tribe.mutable_ware_description("log")->add_producer(*this);

Tags: lua

Related branches

GunChleoc (gunchleoc)
description: updated
Changed in widelands:
assignee: nobody → GunChleoc (gunchleoc)
tags: added: lua
GunChleoc (gunchleoc)
Changed in widelands:
milestone: none → build19-rc1
status: New → In Progress
GunChleoc (gunchleoc)
Changed in widelands:
status: In Progress → Fix Committed
assignee: GunChleoc (gunchleoc) → nobody
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

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.