Author Topic: allow-weapon SEXP  (Read 1920 times)

0 Members and 1 Guest are viewing this topic.

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
As I discovered here, the allow-weapon SEXP behaves in a somewhat counter-intuitive fashion; it uses end_string_at_first_hash_symbol() to, as this comment in the sexp_allow_weapon() function says, "// add that weapon, as well as any # equivalents".

I've checked, and I can't find any instances of the retail FS2 campaign relying on this behavior. Since this can cause a somewhat-spurious "the pilot savefile for this campaign is invalid for the current mod" error when switching from the 2014 MediaVPs to no mod, it seems worthwhile looking into whether or not changing this behavior is desireable, and whether or not it would break any existing mods.

Modders: are you using the allow-weapon SEXP? If so, did you know about this behavior, and does your campaign rely on it?
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline Yarn

  • 210
I looked at the original retail source code; it appears to add only the exact weapon that's passed to the SEXP (e.g., if Hornet is used in the SEXP, then it doesn't also add the # variants like Hornet#Weak, Hornet#Shivan, and Hornet#Weak#Shivan). I haven't verified whether this really happens in retail, though. (And yes, I am able to run the retail EXEs.)

The allow-ship SEXP appears to be the same deal, only with ships.
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
I probably used that sexp at one point, wasn't aware of that behavior. Probably wouldn't break anything for my projects if this was changed.
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

  

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
In cases like these, it's helpful to do an SVN Blame and see why the original change was added...
Quote
Goober5000  11/23/2008 9:13:13 PM
if a ship or weapon is allowed, allow all its # equivalents (further insurance against the Interceptor#Weak problem)

In FSPort, we had an issue where the retail mission adds Interceptor#Weak but not Interceptor.  It does add Interceptor a few missions later, but in the meantime there was a training mission which used the standard Interceptor.  This resulted in a loadout bug where players were unable to fly the training mission.

I fixed the actual mission loadout and sexps, and then I made this code change as insurance, as described in the commit log.  However, based on the resulting unintended behavior, it does appear that the code change was a mistake, and should be reverted.  Since the missions have been corrected, reverting it should not break FSPort.