FreeOrion

Forums for the FreeOrion project
It is currently Sat May 26, 2018 5:52 pm

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed May 09, 2018 11:18 am 
Offline
Space Squid
User avatar

Joined: Sat Aug 13, 2016 4:46 pm
Posts: 51
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:
/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?

_________________
Team S.M.A.C.: play multiplayer with us!


Top
 Profile  
 
PostPosted: Wed May 09, 2018 2:09 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12195
Location: Munich
Try a simplified version to see how small you can make it and still reproducd the error?


Top
 Profile  
 
PostPosted: Wed May 09, 2018 5:12 pm 
Offline
Space Squid
User avatar

Joined: Sat Aug 13, 2016 4:46 pm
Posts: 51
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:
FLEET_UPKEEP_MULTIPLICATOR
'''(ShipPartsOwned empire = Source.Owner class = ShortRange)'''

_________________
Team S.M.A.C.: play multiplayer with us!


Top
 Profile  
 
PostPosted: Wed May 09, 2018 6:16 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12195
Location: Munich
I think this change broke the parsing for the case of ShipPartsOwned when specifying a class.


Top
 Profile  
 
PostPosted: Wed May 09, 2018 7:01 pm 
Offline
Space Squid
User avatar

Joined: Sat Aug 13, 2016 4:46 pm
Posts: 51
Geoff the Medio wrote:
I think this change broke the parsing for the case of ShipPartsOwned when specifying a class.


Opened an issue. https://github.com/freeorion/freeorion/issues/2089

_________________
Team S.M.A.C.: play multiplayer with us!


Top
 Profile  
 
PostPosted: Thu May 10, 2018 6:54 pm 
Offline
Space Kraken

Joined: Sat Dec 10, 2011 5:46 am
Posts: 107
I'm trying to implement it with game rule but couldn't understand how to check if it works.

I simplified macro to
Code:
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
fo.png [ 63.3 KiB | Viewed 161 times ]

_________________
Gentoo Linux amd64, gcc-6.4.0, boost-1.65.0
Ubuntu Server 18.04.0 x64, gcc-7.3, boost-1.65.1
Welcome to multiplayer public server at freeorion-test.dedyn.io. Version 2018-05-22.2e3c6f4
Donates are welcome: BTC: 14XLekD9ifwqLtZX4iteepvbLQNYVG87zK
Top
 Profile  
 
PostPosted: Thu May 10, 2018 7:44 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12195
Location: Munich
What is your rule script?


Top
 Profile  
 
PostPosted: Thu May 10, 2018 7:46 pm 
Offline
Space Kraken

Joined: Sat Dec 10, 2011 5:46 am
Posts: 107
Geoff the Medio wrote:
What is your rule script?

Code:
GameRule
    name = "RULE_SHIP_PART_BASED_UPKEEP"
    description = "RULE_SHIP_PART_BASED_UPKEEP_DESC"
    category = "BALANCE"
    type = Toggle
    default = Off

_________________
Gentoo Linux amd64, gcc-6.4.0, boost-1.65.0
Ubuntu Server 18.04.0 x64, gcc-7.3, boost-1.65.1
Welcome to multiplayer public server at freeorion-test.dedyn.io. Version 2018-05-22.2e3c6f4
Donates are welcome: BTC: 14XLekD9ifwqLtZX4iteepvbLQNYVG87zK


Top
 Profile  
 
PostPosted: Fri May 11, 2018 9:38 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12195
Location: Munich
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.


Top
 Profile  
 
PostPosted: Fri May 11, 2018 10:04 am 
Offline
Space Kraken

Joined: Sat Dec 10, 2011 5:46 am
Posts: 107
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:
 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:
 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 amd64, gcc-6.4.0, boost-1.65.0
Ubuntu Server 18.04.0 x64, gcc-7.3, boost-1.65.1
Welcome to multiplayer public server at freeorion-test.dedyn.io. Version 2018-05-22.2e3c6f4
Donates are welcome: BTC: 14XLekD9ifwqLtZX4iteepvbLQNYVG87zK


Top
 Profile  
 
PostPosted: Fri May 11, 2018 10:22 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12195
Location: Munich
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group