* work around asWeaps[n] still being set for IDES_SYSTEM turrets when numWeaps == 0

* Stops segfaults when hovering over a different propulsion type button than currently selected for an existing non-weapons turret
 * Also stops system turrets being 'forgotten' when changing propulsion type on an existing design (effectively reverses the current behaviour of intCheckValidWeaponForProp considering all existing system turrets invalid for all propulsion types)
Patch by pseudonym404 ( http://forums.wz2100.net/index.php?topic=148.msg7761#msg7761 ), slightly changed by me to be compatible with the changes in r2396

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2397 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-08-17 09:51:44 +00:00
parent 4d424e8ab1
commit ea537fb736
1 changed files with 5 additions and 4 deletions

View File

@ -3152,7 +3152,7 @@ static void intSetTemplatePowerShadowStats(COMP_BASE_STATS *psStats)
UDWORD repairPower = asRepairStats[sCurrDesign.asParts[COMP_REPAIRUNIT]].buildPower;
UDWORD constructPower = asConstructStats[sCurrDesign.asParts[COMP_CONSTRUCT]].buildPower;
UDWORD propulsionPower = asPropulsionStats[sCurrDesign.asParts[COMP_PROPULSION]].buildPower;
UDWORD weaponPower = asWeaponStats[sCurrDesign.asWeaps[0]].buildPower;
UDWORD weaponPower = asWeaponStats[sCurrDesign.numWeaps ? sCurrDesign.asWeaps[0] : 0].buildPower;
type = statType(psStats->ref);
@ -3239,7 +3239,7 @@ static void intSetTemplateBodyShadowStats(COMP_BASE_STATS *psStats)
UDWORD repairBody = asRepairStats[sCurrDesign.asParts[COMP_REPAIRUNIT]].body;
UDWORD constructBody = asConstructStats[sCurrDesign.asParts[COMP_CONSTRUCT]].body;
UDWORD propulsionBody = asPropulsionStats[sCurrDesign.asParts[COMP_PROPULSION]].body;
UDWORD weaponBody = asWeaponStats[sCurrDesign.asWeaps[0]].body;
UDWORD weaponBody = asWeaponStats[sCurrDesign.numWeaps ? sCurrDesign.asWeaps[0] : 0].body;
type = statType(psStats->ref);
@ -3948,8 +3948,9 @@ void intProcessDesign(UDWORD id)
}
*/
//check that the weapon is valid for this propulsion
if (!intCheckValidWeaponForProp())
//check that the weapon (if any) is valid for this propulsion
if (sCurrDesign.numWeaps
&& !intCheckValidWeaponForProp())
{
//no way of allocating more than one weapon is there?
if (sCurrDesign.numWeaps > 1)