Source Code Project Mantis - FSSCP
View Issue Details
0002946FSSCPSEXPspublic2013-11-01 13:162013-11-24 02:33
ReporterFelixJim 
Assigned Toniffiwan 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS VersionWin 7
Product Version3.7.1 
Target VersionFixed in Version3.7.1 
Summary0002946: shields-on and shields-off can cause total ETS energy to increase/decrease
DescriptionFiring the shields-on and shields-off SEXPs can cause odd behaviour with the ETS gauges. For example, putting all energy into shields, and then using shields-off will leave the player with no ETS energy at all. Attempting to increase weapons or engines at this point will crash debug builds, but apparently work as if drawing from shields as normal on release builds. Let's say you put all energy into weapons. Now, if you shields-on, the shields will return, but will still be at full energy, and so the total ETS energy has doubled. It's probably easier for you to play around with the sample mission I've provided than my trying to explain any more.
Steps To ReproduceDownload and run attached mod, play ETSbug.fs2. Instructions in-game.
TagsNo tags attached.
related to 0002950resolved niffiwan shields-off & shields-on sexps don't work in multi 
Attached Files7z ETSbug.7z (1,695) 2013-11-01 13:16
http://scp.indiegames.us/mantis/file_download.php?file_id=2285&type=bug
? ETSbug2.fs2 (5,230) 2013-11-08 22:49
http://scp.indiegames.us/mantis/file_download.php?file_id=2291&type=bug

Notes
(0015378)
niffiwan   
2013-11-02 05:36   
Well, shields-on / shields-off don't rebalance the ETS indexes when called, they just modify the ship flag leaving the ETS in a "broken" state. i.e. the code assumes that the ETS will always sum to 12, and if it doesn't, it'll hit an int3() when it tries to increase an index past 8, but has 0 left to subtract from the one remaining index (with the shields index marked as unavailable)

Need to add some extra processing of indexes to this:
void sexp_shields_off(int n, bool shields_off )
(0015383)
niffiwan   
2013-11-06 02:44   
Fix committed to trunk@10014.
(0015384)
niffiwan   
2013-11-06 02:46   
(Last edited: 2013-11-06 06:01)
Can you please grab the next nightly and confirm that this issue is fixed?
http://www.hard-light.net/forums/index.php?topic=86003

(0015387)
FelixJim   
2013-11-06 10:34   
The issue does seem to be fixed, but as side effect using shields-on will result in ETS settings with nothing in shields, whereas before you'd have whatever was in before using shields-off. This would be a headache for the player to rebalance, especially after every in-mission jump, and those have become pretty popular over the last few years. Normally I'd call this an issue for FREDers to deal with, except many mods have already been released assuming old behaviour, and this could cause balance issues for unobservant players.

All this said, I can't honestly think of a perfect solution to this. Stealing 1/3 of both engines and weapons energy would accommodate players who never touch the ETS settings, assuming you could handle edge cases like all energy in weapons correctly. It probably would be a more or less reasonable distribution under any circumstances, and players who are playing around with the ETS settings will probably have to re-jig everything in any scenario.
(0015388)
Goober5000   
2013-11-06 12:54   
I think rebalancing ETS equally after shields-on is the most reasonable solution.
(0015390)
MjnMixael   
2013-11-06 14:34   
Rebalancing will work. You could also just expect FREDers to use the new get/set ETS sexps.. but that doesn't deal with old missions, obviously.
(0015391)
niffiwan   
2013-11-06 14:43   
Just to clarify, we're talking about the same effect as pressing CTRL-D when shields-on is called? i.e. set all indexes to 4 / INTIAL_????_RECHARGE_INDEX

(then just deal with edge cases of ships missing weapons/engines)
(0015396)
niffiwan   
2013-11-07 02:59   
Fix committed to trunk@10023.
(0015397)
niffiwan   
2013-11-07 03:01   
That was pretty easy - let me know how this looks in the next nightly.
(0015398)
FelixJim   
2013-11-07 11:32   
Looking good, but now using shields-on when the shields are already on will still rebalance the ETS settings. I don't know how big a problem that would be, but maybe it would be cleaner if nothing happened at all? A mention of the ETS rebalancing in the SEXP help wouldn't go amiss either.
(0015400)
niffiwan   
2013-11-07 17:16   
Ah yes, I did notice that problem but I didn't think it'd be a big deal. I've got an idea of how to deal with that, just a few more checks for state changes and it should be good to go.

I'll update the help as well.
(0015402)
niffiwan   
2013-11-08 22:48   
Fix committed to trunk@10032.
(0015403)
niffiwan   
2013-11-08 22:49   
3rd time lucky? :)

While fixing this, I noticed that alter-ship-flag had the same problem, it should also be fixed. See 2nd attached test mission for a test case.
(0015412)
niffiwan   
2013-11-16 00:36   
Have you had a chance to confirm that the problem is gone in the latest nightlies?
(0015455)
FelixJim   
2013-11-22 12:39   
Oops, sorry. Just tested on 10145 and I couldn't find anything else to nitpick and complain about; it all worked just as I'd expected, including the alter-ship-flag version.
(0015461)
niffiwan   
2013-11-24 02:33   
Thanks :)

Issue History
2013-11-01 13:16FelixJimNew Issue
2013-11-01 13:16FelixJimFile Added: ETSbug.7z
2013-11-02 05:36niffiwanNote Added: 0015378
2013-11-04 02:48niffiwanAssigned To => niffiwan
2013-11-04 02:48niffiwanStatusnew => assigned
2013-11-06 02:44niffiwanChangeset attached => fs2open trunk r10014
2013-11-06 02:44niffiwanNote Added: 0015383
2013-11-06 02:44niffiwanStatusassigned => resolved
2013-11-06 02:44niffiwanResolutionopen => fixed
2013-11-06 02:46niffiwanNote Added: 0015384
2013-11-06 02:46niffiwanStatusresolved => feedback
2013-11-06 02:46niffiwanResolutionfixed => reopened
2013-11-06 02:47niffiwanNote Edited: 0015384bug_revision_view_page.php?bugnote_id=15384#r664
2013-11-06 02:59niffiwanRelationship addedrelated to 0002950
2013-11-06 06:01niffiwanNote Edited: 0015384bug_revision_view_page.php?bugnote_id=15384#r665
2013-11-06 10:34FelixJimNote Added: 0015387
2013-11-06 10:34FelixJimStatusfeedback => assigned
2013-11-06 12:54Goober5000Note Added: 0015388
2013-11-06 14:34MjnMixaelNote Added: 0015390
2013-11-06 14:43niffiwanNote Added: 0015391
2013-11-07 02:59niffiwanChangeset attached => fs2open trunk r10023
2013-11-07 02:59niffiwanNote Added: 0015396
2013-11-07 02:59niffiwanStatusassigned => resolved
2013-11-07 03:01niffiwanNote Added: 0015397
2013-11-07 03:01niffiwanStatusresolved => feedback
2013-11-07 11:32FelixJimNote Added: 0015398
2013-11-07 11:32FelixJimStatusfeedback => assigned
2013-11-07 17:16niffiwanNote Added: 0015400
2013-11-08 22:48niffiwanChangeset attached => fs2open trunk r10032
2013-11-08 22:48niffiwanNote Added: 0015402
2013-11-08 22:48niffiwanStatusassigned => resolved
2013-11-08 22:49niffiwanNote Added: 0015403
2013-11-08 22:49niffiwanStatusresolved => feedback
2013-11-08 22:49niffiwanFile Added: ETSbug2.fs2
2013-11-16 00:36niffiwanNote Added: 0015412
2013-11-22 12:39FelixJimNote Added: 0015455
2013-11-22 12:39FelixJimStatusfeedback => assigned
2013-11-24 02:33niffiwanNote Added: 0015461
2013-11-24 02:33niffiwanStatusassigned => resolved
2013-11-24 02:33niffiwanFixed in Version => 3.7.1
2013-11-24 02:33niffiwanResolutionreopened => fixed