Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Test Builds => Topic started by: karajorma on May 07, 2008, 03:12:09 pm
-
Here's are a bunch of fixes for a rather specific series of subsystem bugs that have (especially) been plaguing the WCS and TBP teams. The bug was caused by having a ship in the mission file with a subsystem called Engine and being able to change to a ship in loadout that had a name like Engine01 etc. The problem was that if a SEXP did anything to the Engine subsystem it would then crash when it came across Engine01.
The bug affected several SEXPs including
ship-subsys-guardian-threshold (where it was first noticed)
hits-left-subsystem
distance-subsystem
set-scanned/unscanned
is-ai-class
sabotage/repair-subsystem
set-subsystem-strength
set-cargo
ship-subsys-targetable/untargatable
change-subsystem-name
Some of those would crash in retail, some only in debug while others simply give the wrong answer or do nothing. The solution to some of those problems was to add a new <all engines> and <all turrets> option to those SEXPs. For some of the others I can stop them crashing but there is no sensible way to make them give an answer (How do you give a sensible answer for distance-subsystem when you change from a ship with one engine to a ship with multiple engines!).
Anyway since this is a fairly widespread change it needs some heavy testing (especially for but not limited to people who do actually use those SEXPs on player ships), so I'm posting a build here (http://www.freespacefaq.com/Misc-Downloads/Builds/SubsystemBugFixes.7z). If you get bugs you can't reproduce in chief's build tell me.
-
Maybe it should just be agreed upon that 'Engine', 'Engines', and 'Engine01' are treated interchangably, and the mods will just have to be aware of that.
-
Err.. good to know this is a problem... so how was this fixed now. What does the game do now?
e.g. if I have guardianed subsystems Engine01 and Engine02 and chose a ship with Engine or Engines?
What if the other way around.. or what if changine from two engine subsystems to three, or stuff like that?
Will it sill be possible to just protect one engine and leave the other one unguarded? Will that always be the case when switching from
a ship with one engine to a ship with more than one?
-
The easiest solution is to use the <all engines> option.
Goober gave me a suggestion for how to protect only one engine although I can't think why you'd ever want to do that.
when-argument
-Engine
-Engine01
-whatever trigger
-ship-subsys-guardian-threshold
--<argument>
I'll have to add a slight change to the code to allow that to work but it will work once the code hits SVN.
-
(How do you give a sensible answer for distance-subsystem when you change from a ship with one engine to a ship with multiple engines!)
If the subsystem doesn't exist, NaN is probably the best return value.
Maybe it should just be agreed upon that 'Engine', 'Engines', and 'Engine01' are treated interchangably, and the mods will just have to be aware of that.
The subsystem code already treats engine/engines and communication/communications as equal (and has since 3.6) but treating engine/engine01 as equal is just asking for trouble. Karajorma and I talked about it at length a few weeks ago; that's where he came up with the <all x> option.
-
If the subsystem doesn't exist, NaN is probably the best return value.
Yep. What I did was to fix the SEXPs to check if the ship has changed its class at any point. If it hasn't it will still report it as an error or write a warning to the debug output (I might fix that to a warning in all cases). If it has changed it will simply ignore it and return NaN.
-
Yeah I like the all x idea better too.
-
I don't suppose you could implement an <any engine> or <any turret> too? That might patch the hole in the 'engine01' 'engine02' scenario you're talking about.
-
The easiest solution is to use the <all engines> option.
Goober gave me a suggestion for how to protect only one engine although I can't think why you'd ever want to do that.
when-argument
-Engine
-Engine01
-whatever trigger
-ship-subsys-guardian-threshold
--<argument>
I'll have to add a slight change to the code to allow that to work but it will work once the code hits SVN.
That's exactly what I usually do...I have never experienced problems with it. :nod:
-
I don't suppose you could implement an <any engine> or <any turret> too? That might patch the hole in the 'engine01' 'engine02' scenario you're talking about.
You mean pick the first one it comes across? Hmmm. I suppose that might be possible.