Ship created without structure [7185] (fix included)

Problems and solutions for installing or running FreeOrion, including discussion of bugs if needed before posting a bug report on GitHub. For problems building from source, post in Compile.

Moderator: Oberlus

Post Reply
Message
Author
pyrolytic_tungsten
Space Krill
Posts: 3
Joined: Tue Jun 24, 2014 8:27 pm

Ship created without structure [7185] (fix included)

#1 Post by pyrolytic_tungsten »

See this post for the fix.

So I built a ship without any structure points (but the maximum amount seems right). I've created other ships of the same type without issue. The only thing that might be different is that in the same system 3 troop ships were built that turn and automaticaly placed in a seperate fleet. This is repeatable if I load the previous turns save and end the turn. This is the only instance I've seen of this issue.

Image

Running 64 bit linux (ubuntu trusty 14.04 LTS). Using freeorion from commit 7185.

To reproduce: Load the save attached and end the turn. Notice ship created at Njord without structure.
Attachments
ship_structure_save.7z
(245.04 KiB) Downloaded 106 times
Last edited by pyrolytic_tungsten on Thu Jun 26, 2014 2:48 pm, edited 1 time in total.

pyrolytic_tungsten
Space Krill
Posts: 3
Joined: Tue Jun 24, 2014 8:27 pm

Re: Ship created without structure [7185]

#2 Post by pyrolytic_tungsten »

After playing more I realize that it's an issue with my nanorobotic hull ships when ever I look at them after they're built. Considering that they repair themselves fully every turn this issue doesn't really have gameplay impact. In the save I uploaded I noticed a different ship of the same type that had 0 structure at the time of the save. I probably didn't notice it earlier because it was in a border system where I didn't want to move ships at that moment.

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: Ship created without structure [7185]

#3 Post by MatGB »

Known issue, that I was going to look at ages back but got stuck and forgot to ask for help, basically hulls are created with 0 structure, but is fixed by an effect (Geoff explained the process in more detail in a thread about nanobot hulls in scripting), BUT the nanobot self repair routine sets the structure to its notional max (0 on turn 1) after the effect that's going to give it a boost is set.

The same thing happens with one of the other hull types that repairs itself or all ships present, I forget which. It does actually effect gameplay if they're attacked in the turn they're at 0, hence me learning to never put my shipyard on the frontline against, say, Experimentor nasties and instead use stargates to get them in.

It needs fixing, but the code I tried didn't work then I got distracted and I've no idea if I saved my work before reverting to trunk, it's definitely not saved under a sensible name :-(
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

pyrolytic_tungsten
Space Krill
Posts: 3
Joined: Tue Jun 24, 2014 8:27 pm

Re: Ship created without structure [7185] (fix included)

#4 Post by pyrolytic_tungsten »

While writing this post I came up with a quick fix to put in the scripts which I've tested to work for nano-robotic hulls. The same thing should fix logistics facilitator hulls as well. Since Target.MaxStructure will return 0 for the effect processing phase of the turn a ship is created, I added the previous value of structure (a large number) to Target.MaxStructure. It will get clamped off to the correct maximum value later on like all the other meters.

In ship_hulls.txt change this line from the nano-robotic(line: 298) and facilitator(line: 454) hulls from this:

Code: Select all

            effects = SetStructure Target.MaxStructure
To this:

Code: Select all

            effects = SetStructure Value + Target.MaxStructure
This is my original explaination:

When new ships are constructed they have current and initial values of structure set to a large number. The maximum structure current and initial values are left at the default of 0. Regardless at every turn before effects processing the current (not initial) max values are reset to 0.

When the effects processing gets around to the hull's effect (SetStructure Target.MaxStructure) the Eval function returns the initial value for MaxStructure which is still 0 since meters haven't been back propigated yet. Of course at that time the current value isn't correct either since effects for things like armor haven't been evaluated yet. Since no other effects add anything to structure it stays at 0. When the meter is clamped it stays at 0.

This doesn't effect ships on subsequent turns since MaxStrucure will have a proper initial value. It doesn't effect ships that don't reset their structure every turn since the effects either add something or just leave it at a large falue which then gets clamped to max structure.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Ship created without structure [7185] (fix included)

#5 Post by Geoff the Medio »

An alternative to consider:

Code: Select all

effects = SetStructure max(Value, Target.MaxStructure)

Post Reply