View Issue Details

IDProjectCategoryView StatusLast Update
0002802FSSCPmath-relatedpublic2013-05-01 09:08
Reporterpotterman28wxcv Assigned Toniffiwan  
PrioritylowSeverityminorReproducibilityhave not tried
Status resolvedResolutionreopened 
PlatformWindowsOSWindows 7OS Version6.1
Product Version3.6.18 
Target Version3.7.0 
Summary0002802: A miscalculation in the number of Avengers available.
DescriptionDoing the mission The Darkness and the Light from FSport 3.3 (with MediaVPs), I changed the weapon configuration, then ran into the mission. But I forgot to take Furies, so I left the mission, and launched it again : in the weapon tab, there were -6 avengers available.
Steps To Reproduce1) Launch the mission The Darkness and the Light from FSport 3.3 with MediaVPs (the mission was the main mission when the bug occured)
2) Give Alpha 1&2 one avenger instead of a ML-16, then run into the mission. (the bug may be independant of this step)
3) Leave the mission, and relaunch it
4) going in the weapon selection screen, there was "-6" avengers available, as you can see in the screenshot : (currently, alpha wing is equipped with exactly 6 avenger guns, it may be that if I had not changed the weapon settings, there would have been "-4", or 2-4 = -2, avengers available)
http://img838.imageshack.us/img838/126/sstrange.png

======================================================

Try this instead (without restarting FSO):

1) start 1st mission of ST:R (8x ships)
2) switch campaigns & start the 1st non-training mission of fsport (2x ships)
3) restart the 1st fsport mission
Additional InformationI ran the debugrelease, and tried to load the mission with it : it crashed, saying what is on crash_log.txt ; the content of the debug log is in fs2_open.log

Still, when I load the mission with the non-debug release, it doesn't crash. But it still display "-6" avengers available.

Also, you can find my current pilot files in the archive.
TagsNo tags attached.

Relationships

related to 0002753 resolvedZacam Custom loadouts not loaded 

Activities

potterman28wxcv

2013-03-04 09:36

reporter  

player_files.zip (17,409 bytes)

potterman28wxcv

2013-03-04 10:31

reporter   ~0014749

In another mission, the same steps, the same result : some weapons gets negative numbers. I guess it happens everytime a player change the loadout, then leave the game, then launch the mission again. There must be something wrong in the source code.

MjnMixael

2013-03-23 00:15

manager   ~0014809

Could not reproduce on 9593.

Yarn

2013-04-22 02:22

developer   ~0014945

This bug is most likely being masked in newer revisions because custom loadouts are not being loaded. Once 0002753 is fixed, the effect of this bug will probably return.

niffiwan

2013-04-28 02:09

developer   ~0014967

Last edited: 2013-04-28 07:22

I have an idea about the cause of this, when removing weapons from the pool the code isn't ignoring ships that are not present, i.e. Player_loadout.unit_data[idx].ship_class == -1

It would also seem that unused Player_loadout.unit_data[idx].wep/wep_count slots are not being cleared when a new mission starts. i.e. this problem would occur when the previous mission had more open ship slots than the current mission. e.g. start 1st mission of ST:R (8x ships) then switch campaigns & start the 1st non-training mission of fsport (2x ships), then restart the 1st fsport mission, all without restarting FSO.

niffiwan

2013-04-29 08:18

developer  

mantis2802-svn.patch (1,239 bytes)   
Index: code/missionui/missionshipchoice.cpp
===================================================================
--- code/missionui/missionshipchoice.cpp	(revision 9657)
+++ code/missionui/missionshipchoice.cpp	(working copy)
@@ -2919,6 +2919,10 @@
 
 	for ( i = 0; i < MAX_WSS_SLOTS; i++ ) {
 		Wss_slots[i].ship_class = -1;
+		for ( j = 0; j < MAX_SHIP_WEAPONS; j++ ) {
+			Wss_slots[i].wep[j] = 0;
+			Wss_slots[i].wep_count[j] = 0;
+		}
 	}
 
 	for ( i = 0; i < MAX_WING_BLOCKS; i++ ) {
Index: code/missionui/missionscreencommon.cpp
===================================================================
--- code/missionui/missionscreencommon.cpp	(revision 9657)
+++ code/missionui/missionscreencommon.cpp	(working copy)
@@ -1113,7 +1113,7 @@
 		Wss_slots[i].ship_class = slot->ship_class;
 
 		for ( j = 0; j < MAX_SHIP_WEAPONS; j++ ) {
-			if ((slot->wep[j] >= 0) && (slot->wep[j] < MAX_WEAPON_TYPES)) {
+			if ((slot->ship_class >= 0) && (slot->wep[j] >= 0) && (slot->wep[j] < MAX_WEAPON_TYPES)) {
 				this_loadout_weapons[slot->wep[j]] -= slot->wep_count[j];
 				Assertion((this_loadout_weapons[slot->wep[j]] >= 0), "Attempting to restore the previous missions loadout has resulted in an invalid number of weapons available");
 			}
mantis2802-svn.patch (1,239 bytes)   

niffiwan

2013-04-29 08:19

developer   ~0014975

Please test this patch.

Two changes:
1) when restoring last missions loadout, ignore weapons on absent ships
2) clear ship weapons & weapon-counts when clearing loadout slots

niffiwan

2013-04-30 07:33

developer   ~0014992

Fix committed to trunk@9662.

niffiwan

2013-04-30 07:35

developer   ~0014993

Fix committed to trunk@9663.

niffiwan

2013-04-30 07:37

developer   ~0014994

sorry, committed the wrong patch! Back to code review

Zacam

2013-05-01 07:43

administrator   ~0015006

Seems to do as advertised on the tin. I had some difficulty in reproducing the issue to begin with, and with this, I can't reproduce it at all.

niffiwan

2013-05-01 09:08

developer   ~0015008

Fix committed to trunk@9668.

Related Changesets

fs2open: trunk r9662

2013-04-30 04:25

niffiwan


Ported: N/A

Details Diff
Fix for mantis 2802: when restoring last missions loadout, ignore weapons on absent ships
Also clear ship weapons & weapon-counts when clearing loadout slots
Affected Issues
0002802
mod - /trunk/fs2_open/code/missionui/missionscreencommon.cpp Diff File
mod - /trunk/fs2_open/code/missionui/missionshipchoice.cpp Diff File

fs2open: trunk r9663

2013-04-30 04:28

niffiwan


Ported: N/A

Details Diff
Revert "Fix for mantis 2802: when restoring last missions loadout, ignore weapons on absent ships"
Wrong patch you git!
Affected Issues
0002802
mod - /trunk/fs2_open/code/missionui/missionscreencommon.cpp Diff File
mod - /trunk/fs2_open/code/missionui/missionshipchoice.cpp Diff File

fs2open: trunk r9668

2013-05-01 06:00

niffiwan


Ported: N/A

Details Diff
Fix for mantis 2802: when restoring last missions loadout, ignore weapons on absent ships
Also clear ship weapons & weapon-counts when clearing loadout slots
Affected Issues
0002802
mod - /trunk/fs2_open/code/missionui/missionscreencommon.cpp Diff File
mod - /trunk/fs2_open/code/missionui/missionshipchoice.cpp Diff File

Issue History

Date Modified Username Field Change
2013-03-04 09:36 potterman28wxcv New Issue
2013-03-04 09:36 potterman28wxcv File Added: player_files.zip
2013-03-04 10:31 potterman28wxcv Note Added: 0014749
2013-03-23 00:15 MjnMixael Note Added: 0014809
2013-04-22 02:22 Yarn Note Added: 0014945
2013-04-22 03:08 niffiwan Relationship added related to 0002753
2013-04-28 02:09 niffiwan Note Added: 0014967
2013-04-28 02:09 niffiwan Assigned To => niffiwan
2013-04-28 02:09 niffiwan Status new => assigned
2013-04-28 02:10 niffiwan Target Version => 3.7.0
2013-04-28 02:10 niffiwan Note Edited: 0014967
2013-04-28 07:22 niffiwan Note Edited: 0014967
2013-04-28 07:23 niffiwan Steps to Reproduce Updated
2013-04-29 08:18 niffiwan File Added: mantis2802-svn.patch
2013-04-29 08:19 niffiwan Note Added: 0014975
2013-04-29 08:19 niffiwan Status assigned => code review
2013-04-30 07:33 niffiwan Changeset attached => fs2open trunk r9662
2013-04-30 07:33 niffiwan Note Added: 0014992
2013-04-30 07:33 niffiwan Status code review => resolved
2013-04-30 07:33 niffiwan Resolution open => fixed
2013-04-30 07:35 niffiwan Changeset attached => fs2open trunk r9663
2013-04-30 07:35 niffiwan Note Added: 0014993
2013-04-30 07:37 niffiwan Note Added: 0014994
2013-04-30 07:37 niffiwan Status resolved => feedback
2013-04-30 07:37 niffiwan Resolution fixed => reopened
2013-04-30 07:37 niffiwan Status feedback => code review
2013-05-01 07:43 Zacam Note Added: 0015006
2013-05-01 09:08 niffiwan Changeset attached => fs2open trunk r9668
2013-05-01 09:08 niffiwan Note Added: 0015008
2013-05-01 09:08 niffiwan Status code review => resolved