Patch by Gerard Krol (as in message on <45D5D583.4000803@student.tudelft.nl> the dev mailing list)

* replace an awfully large amount of strange pointer usage (as struct members) with temporaries

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1122 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-02-16 19:44:23 +00:00
parent d34898df16
commit a58ba2cffc
1 changed files with 38 additions and 39 deletions

View File

@ -3615,14 +3615,14 @@ static void intSetTemplatePowerShadowStats(COMP_BASE_STATS *psStats)
UDWORD power, i; UDWORD power, i;
if (psStats != NULL) { if (psStats != NULL) {
COMP_BASE_STATS* bodyStats = asBodyStats + sCurrDesign.asParts[COMP_BODY]; UDWORD bodyPower = (asBodyStats + sCurrDesign.asParts[COMP_BODY])->buildPower;
COMP_BASE_STATS* brainStats = asBrainStats + sCurrDesign.asParts[COMP_BRAIN]; UDWORD brainPower = (asBrainStats + sCurrDesign.asParts[COMP_BRAIN])->buildPower;
COMP_BASE_STATS* sensorStats = asSensorStats + sCurrDesign.asParts[COMP_SENSOR]; UDWORD sensorPower = (asSensorStats + sCurrDesign.asParts[COMP_SENSOR])->buildPower;
COMP_BASE_STATS* ECMStats = asECMStats + sCurrDesign.asParts[COMP_ECM]; UDWORD ECMPower = (asECMStats + sCurrDesign.asParts[COMP_ECM])->buildPower;
COMP_BASE_STATS* repairStats = asRepairStats + sCurrDesign.asParts[COMP_REPAIRUNIT]; UDWORD repairPower = (asRepairStats + sCurrDesign.asParts[COMP_REPAIRUNIT])->buildPower;
COMP_BASE_STATS* constructStats = asConstructStats + sCurrDesign.asParts[COMP_CONSTRUCT]; UDWORD constructPower = (asConstructStats + sCurrDesign.asParts[COMP_CONSTRUCT])->buildPower;
COMP_BASE_STATS* propulsionStats = asPropulsionStats + sCurrDesign.asParts[COMP_PROPULSION]; UDWORD propulsionPower = (asPropulsionStats + sCurrDesign.asParts[COMP_PROPULSION])->buildPower;
COMP_BASE_STATS* weaponStats = asWeaponStats + sCurrDesign.asWeaps[0]; UDWORD weaponPower = (asWeaponStats + sCurrDesign.asWeaps[0])->buildPower;
type = statType(psStats->ref); type = statType(psStats->ref);
@ -3662,25 +3662,25 @@ static void intSetTemplatePowerShadowStats(COMP_BASE_STATS *psStats)
switch (type) switch (type)
{ {
case COMP_BODY: case COMP_BODY:
bodyStats = psStats; bodyPower = psStats->buildPower;
break; break;
case COMP_PROPULSION: case COMP_PROPULSION:
propulsionStats = psStats; propulsionPower = psStats->buildPower;
break; break;
case COMP_ECM: case COMP_ECM:
ECMStats = psStats; ECMPower = psStats->buildPower;
break; break;
case COMP_SENSOR: case COMP_SENSOR:
sensorStats = psStats; sensorPower = psStats->buildPower;
break; break;
case COMP_CONSTRUCT: case COMP_CONSTRUCT:
constructStats = psStats; constructPower = psStats->buildPower;
break; break;
case COMP_REPAIRUNIT: case COMP_REPAIRUNIT:
repairStats = psStats; repairPower = psStats->buildPower;
break; break;
case COMP_WEAPON: case COMP_WEAPON:
weaponStats = psStats; weaponPower = psStats->buildPower;
break; break;
//default: //default:
//don't want to draw for unknown comp //don't want to draw for unknown comp
@ -3689,15 +3689,15 @@ static void intSetTemplatePowerShadowStats(COMP_BASE_STATS *psStats)
// this code is from calcTemplatePower // this code is from calcTemplatePower
//get the component power //get the component power
power = bodyStats->buildPower + brainStats->buildPower + sensorStats->buildPower + ECMStats->buildPower + repairStats->buildPower + constructStats->buildPower; power = bodyPower + brainPower + sensorPower + ECMPower + repairPower + constructPower;
/* propulsion power points are a percentage of the bodys' power points */ /* propulsion power points are a percentage of the bodys' power points */
power += (propulsionStats->buildPower * power += (propulsionPower *
bodyStats->buildPower) / 100; bodyPower) / 100;
//add weapon power //add weapon power
// FIXME: Only takes first weapon into account // FIXME: Only takes first weapon into account
power += weaponStats->buildPower; power += weaponPower;
for(i=1; i<sCurrDesign.numWeaps; i++) for(i=1; i<sCurrDesign.numWeaps; i++)
{ {
power += (asWeaponStats + sCurrDesign.asWeaps[i])->buildPower; power += (asWeaponStats + sCurrDesign.asWeaps[i])->buildPower;
@ -3727,14 +3727,14 @@ static void intSetTemplateBodyShadowStats(COMP_BASE_STATS *psStats)
UDWORD body, i; UDWORD body, i;
if (psStats != NULL) { if (psStats != NULL) {
COMP_BASE_STATS* bodyStats = asBodyStats + sCurrDesign.asParts[COMP_BODY]; UDWORD bodyBody = (asBodyStats + sCurrDesign.asParts[COMP_BODY])->body;
COMP_BASE_STATS* brainStats = asBrainStats + sCurrDesign.asParts[COMP_BRAIN]; UDWORD brainBody = (asBrainStats + sCurrDesign.asParts[COMP_BRAIN])->body;
COMP_BASE_STATS* sensorStats = asSensorStats + sCurrDesign.asParts[COMP_SENSOR]; UDWORD sensorBody = (asSensorStats + sCurrDesign.asParts[COMP_SENSOR])->body;
COMP_BASE_STATS* ECMStats = asECMStats + sCurrDesign.asParts[COMP_ECM]; UDWORD ECMBody = (asECMStats + sCurrDesign.asParts[COMP_ECM])->body;
COMP_BASE_STATS* repairStats = asRepairStats + sCurrDesign.asParts[COMP_REPAIRUNIT]; UDWORD repairBody = (asRepairStats + sCurrDesign.asParts[COMP_REPAIRUNIT])->body;
COMP_BASE_STATS* constructStats = asConstructStats + sCurrDesign.asParts[COMP_CONSTRUCT]; UDWORD constructBody = (asConstructStats + sCurrDesign.asParts[COMP_CONSTRUCT])->body;
COMP_BASE_STATS* propulsionStats = asPropulsionStats + sCurrDesign.asParts[COMP_PROPULSION]; UDWORD propulsionBody = (asPropulsionStats + sCurrDesign.asParts[COMP_PROPULSION])->body;
COMP_BASE_STATS* weaponStats = asWeaponStats + sCurrDesign.asWeaps[0]; UDWORD weaponBody = (asWeaponStats + sCurrDesign.asWeaps[0])->body;
type = statType(psStats->ref); type = statType(psStats->ref);
@ -3774,42 +3774,41 @@ static void intSetTemplateBodyShadowStats(COMP_BASE_STATS *psStats)
switch (type) switch (type)
{ {
case COMP_BODY: case COMP_BODY:
bodyStats = psStats; bodyBody = psStats->body;
break; break;
case COMP_PROPULSION: case COMP_PROPULSION:
propulsionStats = psStats; propulsionBody = psStats->body;
break; break;
case COMP_ECM: case COMP_ECM:
ECMStats = psStats; ECMBody = psStats->body;
break; break;
case COMP_SENSOR: case COMP_SENSOR:
sensorStats = psStats; sensorBody = psStats->body;
break; break;
case COMP_CONSTRUCT: case COMP_CONSTRUCT:
constructStats = psStats; constructBody = psStats->body;
break; break;
case COMP_REPAIRUNIT: case COMP_REPAIRUNIT:
repairStats = psStats; repairBody = psStats->body;
break; break;
case COMP_WEAPON: case COMP_WEAPON:
weaponStats = psStats; weaponBody = psStats->body;
break; break;
//default: //default:
//don't want to draw for unknown comp //don't want to draw for unknown comp
} }
// this code is from calcTemplateBody // this code is from calcTemplateBody
//get the component power //get the component power
body = bodyStats->body + brainStats->body + sensorStats->body + ECMStats->body + repairStats->body + constructStats->body; body = bodyBody + brainBody + sensorBody + ECMBody + repairBody + constructBody;
/* propulsion power points are a percentage of the bodys' power points */ /* propulsion power points are a percentage of the bodys' power points */
body += (propulsionStats->body * body += (propulsionBody *
bodyStats->body) / 100; bodyBody) / 100;
//add weapon power //add weapon power
// FIXME: Only takes first weapon into account // FIXME: Only takes first weapon into account
body += weaponStats->body; body += weaponBody;
for(i=1; i<sCurrDesign.numWeaps; i++) for(i=1; i<sCurrDesign.numWeaps; i++)
{ {
body += (asWeaponStats + sCurrDesign.asWeaps[i])->body; body += (asWeaponStats + sCurrDesign.asWeaps[i])->body;