widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #09930
Re: [Merge] lp:~widelands-dev/widelands/bug-1675179-lua-economy into lp:widelands
Regarding your comments: The economy number is the array index of the economies owned by a player. So, we need both the player number and he economy index to identify it.
When an economy is merged with another economy or its last flag deleted, the vector gets reshuffled. I don't expect it to be a problem with the persistence code though, because the game is paused while its being saved, so economies can't disappear on us then.
Outside of saveloading, we reference the Economy object itself and not the economy & player numbers, so the worst thing that it can do to us is to become nil. Becoming nil can happen to any map object though, so this is something that a scenario Lua script will need to test for when necessary.
> Where does a lua programme "find" that flag to fetch the economy from?
It doesn't. Whoever writes a scenario will need to tell it which flag to use.
> would it not be easier to get some "default" economy for the headquarter
(like you do in that test :-). Or some warehouses?
No, because a scenario author might need to be able to access all economies, not just the "default" one. Also, if the headquarters gets conquered and the player still has 2 other economies with warehouses in them, which one will become the "default" economy?
> Can we have a test for a bare flag? Is there an ecomony for every
disconnected flag?
A disconnected flag has an economy that consists of that flag only. Unless you connect it to a warehouse, it will be an economy without a warehouse, but it's still an economy.
--
https://code.launchpad.net/~widelands-dev/widelands/bug-1675179-lua-economy/+merge/321008
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1675179-lua-economy into lp:widelands.
References