2022-08-07 22:58 EDT

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002120FSSCPSEXPspublic2010-08-26 23:43
Assigned ToZacam 
PlatformIBM PCOSMS WindowsOS VersionVista SP2
Product Version3.6.11 
Target VersionFixed in Version3.6.12 
Summary0002120: 'is-primary-selected' returns wrong value if primaries linked
DescriptionSince a ship can only have one primary as the currently selected one, this SEXP returns false for every bank but the last one before primaries were linked.

This is of course wrong behavior. When primaries are linked this should return true for ALL primary banks.
This SEXP is checking whether a gun is active and will fail if it isn't active.

I provided a patch that fixes this. In the long run it might be beneficial to also have a 'are-primaries-linked' SEXP in case this special case should be handled differently.

However this fix is necessary right now because it interpretes game data wrong, therefore one cannot handle linked primaries correctly at the moment.
if one checks for
and {
    is-primary-selected (bank 1)
    is-primary-selected (bank 2)
on a two-primaries fighter, it will return false when primaries are linked.
because in that case bank 2 is most likely selected as the current primary.
This should however return true, since both banks are active.
The game ignores the currently selected primary variable when primaries are linked, and so should the SEXP.

As mentioned, patch attached.
TagsNo tags attached.
Attached Files
  • patch file icon is-primary-selected.patch (515 bytes) 2010-02-10 14:22 -
    Index: code/parse/sexp.cpp
    --- code/parse/sexp.cpp	(revision 5893)
    +++ code/parse/sexp.cpp	(working copy)
    @@ -15299,6 +15299,12 @@
     		return SEXP_FALSE;
    +	// primaries are linked. In this case this may not be
    +	// marked as selected, but is active anyway
    +	if(shipp->flags & SF_PRIMARY_LINKED) {
    +		return SEXP_TRUE;
    +	}
     	// is this the bank currently selected
     	if(bank == shipp->weapons.current_primary_bank){
     		return SEXP_TRUE;
    patch file icon is-primary-selected.patch (515 bytes) 2010-02-10 14:22 +
  • patch file icon M2120_patch_02102010.patch (421 bytes) 2010-02-10 23:55 -
    Index: code/parse/sexp.cpp
    --- code/parse/sexp.cpp	(revision 5899)
    +++ code/parse/sexp.cpp	(working copy)
    @@ -15300,7 +15300,7 @@
     	// is this the bank currently selected
    -	if(bank == shipp->weapons.current_primary_bank){
    +	if( (bank == shipp->weapons.current_primary_bank) || (shipp->flags & SF_PRIMARY_LINKED) ){
     		return SEXP_TRUE;
    patch file icon M2120_patch_02102010.patch (421 bytes) 2010-02-10 23:55 +




Zacam (administrator)

Last edited: 2010-02-10 23:58

Yeah, it seems that when banks are linked, Bank 0 (Primary 1) and Bank 1 (Primary 2) become considered as being Bank 0, so checks on Bank 1 fail because it "technically" doesn't exist while they are linked.

Technically, I think the attached one line change _should_ handle the idea better, but it may require some testing to verify that it works as well as I think it does.


chief1983 (administrator)

We'll go ahead with it and make sure it works during the RC phase. Just keep it in mind when testing.


KeldorKatarn (reporter)

I tested it with some SEXP events that change some HUD element.

Checking for both banks to be true with an "and" condition works when linked.

For one being active

Bank1 selected AND NOT bank2 selected

works also fine

NOT (AND bank1 selected, bank2 selected) never triggers

so this works as expected from my point of view.


chief1983 (administrator)

Committed Zacam's version in r5900.


Zacam (administrator)

No additional feedback, marking as resolved.

-Issue History
Date Modified Username Field Change
2010-02-10 14:22 KeldorKatarn New Issue
2010-02-10 14:22 KeldorKatarn File Added: is-primary-selected.patch
2010-02-10 23:55 Zacam Note Added: 0011630
2010-02-10 23:55 Zacam File Added: M2120_patch_02102010.patch
2010-02-10 23:58 Zacam Note Edited: 0011630
2010-02-11 00:22 Zacam Status new => feedback
2010-02-11 04:08 Zacam Status feedback => assigned
2010-02-11 04:08 Zacam Assigned To => Zacam
2010-02-11 04:09 Zacam Status assigned => feedback
2010-02-11 11:10 chief1983 Note Added: 0011644
2010-02-11 11:21 KeldorKatarn Note Added: 0011645
2010-02-11 11:30 chief1983 Note Added: 0011647
2010-08-26 23:43 Zacam Note Added: 0012333
2010-08-26 23:43 Zacam Status feedback => resolved
2010-08-26 23:43 Zacam Fixed in Version => 3.6.12
2010-08-26 23:43 Zacam Resolution open => fixed
+Issue History