View Issue Details

IDProjectCategoryView StatusLast Update
0002120FSSCPSEXPspublic2010-08-27 03:43
ReporterKeldorKatarn Assigned ToZacam  
PrioritynormalSeveritytrivialReproducibilityalways
Status resolvedResolutionfixed 
PlatformIBM PCOSMS WindowsOS VersionVista SP2
Product Version3.6.11 
Fixed 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.

Activities

2010-02-10 19:22

 

is-primary-selected.patch (515 bytes)   
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;
is-primary-selected.patch (515 bytes)   

Zacam

2010-02-11 04:55

administrator   ~0011630

Last edited: 2010-02-11 04: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.

2010-02-11 04:55

 

M2120_patch_02102010.patch (421 bytes)   
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;
 	}
 
M2120_patch_02102010.patch (421 bytes)   

chief1983

2010-02-11 16:10

administrator   ~0011644

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

KeldorKatarn

2010-02-11 16:21

reporter   ~0011645

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

2010-02-11 16:30

administrator   ~0011647

Committed Zacam's version in r5900.

Zacam

2010-08-27 03:43

administrator   ~0012333

No additional feedback, marking as resolved.

Issue History

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