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.
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.
Ship created without structure [7185] (fix included)
Moderator: Oberlus
-
- Space Krill
- Posts: 3
- Joined: Tue Jun 24, 2014 8:27 pm
Ship created without structure [7185] (fix included)
- Attachments
-
- ship_structure_save.7z
- (245.04 KiB) Downloaded 107 times
Last edited by pyrolytic_tungsten on Thu Jun 26, 2014 2:48 pm, edited 1 time in total.
-
- Space Krill
- Posts: 3
- Joined: Tue Jun 24, 2014 8:27 pm
Re: Ship created without structure [7185]
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.
Re: Ship created without structure [7185]
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
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.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.
-
- Space Krill
- Posts: 3
- Joined: Tue Jun 24, 2014 8:27 pm
Re: Ship created without structure [7185] (fix included)
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:
To this:
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.
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
Code: Select all
effects = SetStructure Value + Target.MaxStructure
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.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: Ship created without structure [7185] (fix included)
An alternative to consider:
Code: Select all
effects = SetStructure max(Value, Target.MaxStructure)