Problems and solutions for installing or running FreeOrion, including discussion of bugs if needed before posting a bug report. For problems building from source, post in Compile.
-
Voker57
- Space Squid
- Posts: 52
- Joined: Sat Aug 13, 2016 4:46 pm
#1
Post
by Voker57 » Wed May 09, 2018 11:18 am
We've been using part-based upkeep using this code for long time, and it seems to work ok:
https://github.com/Voker57/freeorion/co ... 67e1440eb2
However, in recent version it fails with this rather cryptic error:
Code: Select all
/opt/freeorion/share/freeorion/default/scripting/ship_hulls/SH_BASIC_MEDIUM.focs.txt:13:72: Parse error. Expected ) here:
slots = [
Slot type = External position = (0.65, 0.25)
Slot type = External position = (0.65, 0.55)
Slot type = Internal position = (0.35, 0.35)
]
buildCost = 20 * (1 + (0.002 * ShipPartsOwned empire = Source.Owner class = ShortRange) + (0.002 * ShipPartsOwned empire = Source.Owner class = FighterBay) + (0.002 * ShipPartsOwned empire = Source.Owner class = Armour) + (0.002 * ShipPartsOwned empire = Source.Owner class = Troops) + (0.002 * ShipDesignsOwned)) * (GameRule name = "RULE_SHIP_HULL_COST_FACTOR")
^
buildTime = 2
tags = [ "PEDIA_HULL_LINE_GENERIC" ]
location = Contains And [
Building name = "BLD_SHIPYARD_BASE"
OwnedBy empire = Source.Owner
I looked through parse/IntComplexValueRefParser.cpp and saw it went through a refactor but essence seems to be the same. Any idea how to fix the macro?
-
Geoff the Medio
- Programming, Design, Admin
- Posts: 12344
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
#2
Post
by Geoff the Medio » Wed May 09, 2018 2:09 pm
Try a simplified version to see how small you can make it and still reproducd the error?
-
Voker57
- Space Squid
- Posts: 52
- Joined: Sat Aug 13, 2016 4:46 pm
#3
Post
by Voker57 » Wed May 09, 2018 5:12 pm
Geoff the Medio wrote:Try a simplified version to see how small you can make it and still reproducd the error?
This is minimum that does not work:
Code: Select all
FLEET_UPKEEP_MULTIPLICATOR
'''(ShipPartsOwned empire = Source.Owner class = ShortRange)'''
-
o01eg
- Dyson Forest
- Posts: 214
- Joined: Sat Dec 10, 2011 5:46 am
#6
Post
by o01eg » Thu May 10, 2018 6:54 pm
I'm trying to implement it with game rule but couldn't understand how to check if it works.
I simplified macro to
Code: Select all
FLEET_UPKEEP_MULTIPLICATOR
'''(1 + 10 * GameRule name = "RULE_SHIP_PART_BASED_UPKEEP") '''
but got 13.0 PP in production list and 6.5 in production queue in both cases.
-
Attachments
-

- fo.png (63.3 KiB) Viewed 541 times
Gentoo Linux x64, gcc-7.3, boost-1.65.0
Ubuntu Server 18.04 x64, gcc-7.3, boost-1.65.1
Welcome to
multiplayer server at
freeorion-test.dedyn.io.Version
0.4.8
Donates are welcome:
BTC:14XLekD9ifwqLtZX4iteepvbLQNYVG87zK
-
o01eg
- Dyson Forest
- Posts: 214
- Joined: Sat Dec 10, 2011 5:46 am
#8
Post
by o01eg » Thu May 10, 2018 7:46 pm
Geoff the Medio wrote:What is your rule script?
Code: Select all
GameRule
name = "RULE_SHIP_PART_BASED_UPKEEP"
description = "RULE_SHIP_PART_BASED_UPKEEP_DESC"
category = "BALANCE"
type = Toggle
default = Off
Gentoo Linux x64, gcc-7.3, boost-1.65.0
Ubuntu Server 18.04 x64, gcc-7.3, boost-1.65.1
Welcome to
multiplayer server at
freeorion-test.dedyn.io.Version
0.4.8
Donates are welcome:
BTC:14XLekD9ifwqLtZX4iteepvbLQNYVG87zK
-
Geoff the Medio
- Programming, Design, Admin
- Posts: 12344
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
#9
Post
by Geoff the Medio » Fri May 11, 2018 9:38 am
o01eg wrote:...got 13.0 PP in production list and 6.5 in production queue in both cases.
It costs 13 PP and takes at least 2 turns to produce, so it can have up to 13/2 = 6.5 PP/turn allocated to it on the queue.
-
o01eg
- Dyson Forest
- Posts: 214
- Joined: Sat Dec 10, 2011 5:46 am
#10
Post
by o01eg » Fri May 11, 2018 10:04 am
Geoff the Medio wrote:o01eg wrote:...got 13.0 PP in production list and 6.5 in production queue in both cases.
It costs 13 PP and takes at least 2 turns to produce, so it can have up to 13/2 = 6.5 PP/turn allocated to it on the queue.
Yes, but as I suppose it should calculate with rule disabled
Code: Select all
SH_BASIC_SMALL = 10 * (1 + 0) [[FLEET_UPKEEP_MULTIPLICATOR]] * 1 [[SHIP_HULL_COST_MULTIPLIER]]
GT_TROOP_POD = 3 * (1 + 0) [[FLEET_UPKEEP_MULTIPLICATOR]] * 1 [[SHIP_PART_COST_MULTIPLIER]]
Total: 13
And with rule enabled
Code: Select all
SH_BASIC_SMALL = 10 * (1 + 10) [[FLEET_UPKEEP_MULTIPLICATOR]] * 1 [[SHIP_HULL_COST_MULTIPLIER]]
GT_TROOP_POD = 3 * (1 + 10) [[FLEET_UPKEEP_MULTIPLICATOR]] * 1 [[SHIP_PART_COST_MULTIPLIER]]
Total: 143
Gentoo Linux x64, gcc-7.3, boost-1.65.0
Ubuntu Server 18.04 x64, gcc-7.3, boost-1.65.1
Welcome to
multiplayer server at
freeorion-test.dedyn.io.Version
0.4.8
Donates are welcome:
BTC:14XLekD9ifwqLtZX4iteepvbLQNYVG87zK
-
Geoff the Medio
- Programming, Design, Admin
- Posts: 12344
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
#11
Post
by Geoff the Medio » Fri May 11, 2018 10:22 am
I think / suspect that the multiplication attempts to cast the boolean-valued rule to a double (more accurately, it attempts to get a double out of the the boost::any which stores a bool), which fails, so it defaults to returning 0.0 in this case. Should be able to fix. You could quickly try making the rule "type = Real" to test.
Edit: try after
https://github.com/freeorion/freeorion/ ... 9c1d09d65d