View Issue Details

IDProjectCategoryView StatusLast Update
0001714FSSCPmodelspublic2008-08-18 23:27
Reporterblowfish Assigned Tophreak  
PrioritynormalSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
Summary0001714: External secondary models behave incorrectly when there are fewer missiles than firepoints
DescriptionOK. Let's say you have a ship with a secondary bank with 8 firepoints. And let's say that bank can hold two of a certain type of missile. Looking at the ship externally, the game will display missiles on all eight firepoints. Once those two missiles have been fired, it will continue to render the remaining six missiles, even though the bank has no ammo left.
Additional InformationThe good news is I already found a fix for this. Diff attached.
TagsNo tags attached.

Activities

2008-06-29 21:35

 

ext_fix.diff (1,036 bytes)   
Index: ship.cpp
===================================================================
--- ship.cpp	(revision 4689)
+++ ship.cpp	(working copy)
@@ -7007,14 +7007,19 @@
 						continue;
 
 					w_bank *bank = &model_get(sip->model_num)->missile_banks[i];
+					
+					int num_secondaries_rendered = 0;
+					
 					for(k = 0; k < bank->num_slots; k++) {
 						vec3d secondary_weapon_pos = bank->pnt[k];
 					//	vm_vec_add(&secondary_weapon_pos, &obj->pos, &bank->pnt[k]);
 		
 					//	if(shipp->secondary_point_reload_pct[i][k] != 1.0)
 					//		vm_vec_scale_add2(&secondary_weapon_pos, &obj->orient.vec.fvec, -(1.0f-shipp->secondary_point_reload_pct[i][k]) * model_get(Weapon_info[swp->secondary_bank_weapons[i]].model_num)->rad);
-						if(shipp->secondary_point_reload_pct[i][k] <= 0.0)
+						if(shipp->secondary_point_reload_pct[i][k] <= 0.0 || num_secondaries_rendered >= shipp->weapons.secondary_bank_ammo[i])
 							continue;
+						
+						num_secondaries_rendered++;
 		
 						vec3d dir = ZERO_VECTOR;
 						dir.xyz.z = 1.0;
ext_fix.diff (1,036 bytes)   

phreak

2008-08-18 03:52

developer   ~0009574

I can apply the patch to the trunk. Is there any media I can use to test this fix?

blowfish

2008-08-18 15:39

reporter   ~0009579

Nothing official. I tested it using hacked BtRL tables. If you make the cylon nuke available on the viper, you should be able to test it ok.

phreak

2008-08-18 23:26

developer   ~0009580

Last edited: 2008-08-18 23:27

Ok i applied the patch and it compiles. I made a couple changes to your code, it should be functionally the same. I also cleaned up some existing code that was commented out.

Your changes that I changed:
Moved variable declarations from inside the for loops to outside. Declaring variables inside for loops is rather slow and bad practice.
I made the num_secondaries_rendered check into it's own if statement and broke out of the inner loop if it evaluated true. This should be a little bit more efficient than continuing until the end.

I can take your word that your tests have worked (and I can tell that it should by inspection), so I will go ahead and commit these changes.

Issue History

Date Modified Username Field Change
2008-06-29 21:35 blowfish New Issue
2008-06-29 21:35 blowfish File Added: ext_fix.diff
2008-08-18 03:52 phreak Status new => assigned
2008-08-18 03:52 phreak Assigned To => phreak
2008-08-18 03:52 phreak Note Added: 0009574
2008-08-18 15:39 blowfish Note Added: 0009579
2008-08-18 23:26 phreak Note Added: 0009580
2008-08-18 23:27 phreak Note Edited: 0009580
2008-08-18 23:27 phreak Status assigned => resolved
2008-08-18 23:27 phreak Resolution open => fixed