Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: AdmiralRalwood on January 12, 2015, 12:03:46 am

Title: allow-weapon SEXP
Post by: AdmiralRalwood on January 12, 2015, 12:03:46 am
As I discovered here (http://www.hard-light.net/forums/index.php?topic=88919.msg1773820#msg1773820), 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?
Title: Re: allow-weapon SEXP
Post by: Yarn on January 12, 2015, 12:59:26 am
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.
Title: Re: allow-weapon SEXP
Post by: Spoon on January 12, 2015, 09:29:03 am
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.
Title: Re: allow-weapon SEXP
Post by: Goober5000 on January 12, 2015, 10:55:50 am
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.