Re: [Warzone-dev] Please apply this patch
Giel van Schijndel wrote: Giel van Schijndel schreef: Gerard Krol schreef: I know I only posted it only 4 days ago, but I really sleep better when I know my patches have been applied. Could someone apply this patch? I even polished it a little bit more. This patch prevents a segfault when designing a droid on amd64. Reproduce: on amd64, go to the droid design screen and design a construction droid. Then hover your mouse over another system, like sensor or command. Regards, Gerard Applied in r750. Hope you did sleep well enough those 4 days? Anyway I'm hoping you'll sleep better now again ;-) . Sorry, I haven't looked at your latest patch until after committing the previous one. Anyway your latest version looks a bit ugly to me. There's an awfully large amount of casts in there, not to mention that your insertion of that switch statement uses the variable `type` which at that point isn't yet initialized = undefined behaviour. Oops, I guess that must be a copy-paste error. Plus I'm not quite sure what the difference is between the first and second patch. Not meaning to offend you though. I just noticed that my patch created a lot of warnings (16) about 'warning: initialization from incompatible pointer type'. The second patch was a quick attempt to solve that problem. A little too quick as it seems. I tought about it a little and the attached patch avoids the casting problem and also doesn't give the warnings. - Gerard Index: src/design.c === --- src/design.c (revision 762) +++ src/design.c (working copy) @@ -3615,14 +3615,14 @@ UDWORDpower, i; if (psStats != NULL) { -COMP_BASE_STATS* bodyStats = asBodyStats + sCurrDesign.asParts[COMP_BODY]; -COMP_BASE_STATS* brainStats = asBrainStats + sCurrDesign.asParts[COMP_BRAIN]; -COMP_BASE_STATS* sensorStats = asSensorStats + sCurrDesign.asParts[COMP_SENSOR]; -COMP_BASE_STATS* ECMStats = asECMStats + sCurrDesign.asParts[COMP_ECM]; -COMP_BASE_STATS* repairStats = asRepairStats + sCurrDesign.asParts[COMP_REPAIRUNIT]; -COMP_BASE_STATS* constructStats = asConstructStats + sCurrDesign.asParts[COMP_CONSTRUCT]; -COMP_BASE_STATS* propulsionStats = asPropulsionStats + sCurrDesign.asParts[COMP_PROPULSION]; -COMP_BASE_STATS* weaponStats = asWeaponStats + sCurrDesign.asWeaps[0]; +UDWORD bodyPower= (asBodyStats + sCurrDesign.asParts[COMP_BODY])-buildPower; +UDWORD brainPower = (asBrainStats + sCurrDesign.asParts[COMP_BRAIN])-buildPower; +UDWORD sensorPower = (asSensorStats + sCurrDesign.asParts[COMP_SENSOR])-buildPower; +UDWORD ECMPower = (asECMStats + sCurrDesign.asParts[COMP_ECM])-buildPower; +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; type = statType(psStats-ref); @@ -3662,25 +3662,25 @@ switch (type) { case COMP_BODY: - bodyStats = psStats; + bodyPower = psStats-buildPower; break; case COMP_PROPULSION: - propulsionStats = psStats; + propulsionPower = psStats-buildPower; break; case COMP_ECM: - ECMStats = psStats; + ECMPower = psStats-buildPower; break; case COMP_SENSOR: - sensorStats = psStats; + sensorPower = psStats-buildPower; break; case COMP_CONSTRUCT: - constructStats = psStats; + constructPower = psStats-buildPower; break; case COMP_REPAIRUNIT: - repairStats = psStats; + repairPower = psStats-buildPower; break; case COMP_WEAPON: - weaponStats = psStats; + weaponPower = psStats-buildPower; break; //default: //don't want to draw for unknown comp @@ -3689,15 +3689,15 @@ // this code is from calcTemplatePower //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 */ - power += (propulsionStats-buildPower * - bodyStats-buildPower) / 100; + power += (propulsionPower * + bodyPower) / 100; //add weapon power // FIXME: Only takes first weapon into account -power += weaponStats-buildPower; +power += weaponPower; for(i=1; isCurrDesign.numWeaps; i++) { power += (asWeaponStats + sCurrDesign.asWeaps[i])-buildPower; @@ -3727,14 +3727,14 @@ UDWORDbody, i; if (psStats != NULL) { -
[Warzone-dev] Please apply this patch
I know I only posted it only 4 days ago, but I really sleep better when I know my patches have been applied. Could someone apply this patch? I even polished it a little bit more. This patch prevents a segfault when designing a droid on amd64. Reproduce: on amd64, go to the droid design screen and design a construction droid. Then hover your mouse over another system, like sensor or command. Regards, Gerard Index: src/design.c === --- src/design.c (revision 747) +++ src/design.c (working copy) @@ -3612,13 +3612,43 @@ static void intSetTemplatePowerShadowStats(COMP_BASE_STATS *psStats) { UDWORDtype; - //SDWORDAvail, Used, Total; - DROID_TEMPLATE compTempl; - if (sCurrDesign != NULL psStats != NULL) - { - //create the comparison Template - memcpy(compTempl, sCurrDesign, sizeof(DROID_TEMPLATE)); + if (psStats != NULL) { +BODY_STATS* bodyStats = asBodyStats + sCurrDesign.asParts[COMP_BODY]; +BRAIN_STATS* brainStats = asBrainStats + sCurrDesign.asParts[COMP_BRAIN]; +SENSOR_STATS* sensorStats = asSensorStats + sCurrDesign.asParts[COMP_SENSOR]; +ECM_STATS* ECMStats = asECMStats + sCurrDesign.asParts[COMP_ECM]; +REPAIR_STATS* repairStats = asRepairStats + sCurrDesign.asParts[COMP_REPAIRUNIT]; +CONSTRUCT_STATS* constructStats = asConstructStats + sCurrDesign.asParts[COMP_CONSTRUCT]; +PROPULSION_STATS* propulsionStats = asPropulsionStats + sCurrDesign.asParts[COMP_PROPULSION]; +WEAPON_STATS* weaponStats = asWeaponStats + sCurrDesign.asWeaps[0]; + switch (type) + { + case COMP_BODY: + bodyStats = (BODY_STATS*)psStats; + break; + case COMP_PROPULSION: + propulsionStats = (PROPULSION_STATS*)psStats; + break; + case COMP_ECM: + ECMStats = (ECM_STATS*)psStats; + break; + case COMP_SENSOR: + sensorStats = (SENSOR_STATS*)psStats; + break; + case COMP_CONSTRUCT: + constructStats = (CONSTRUCT_STATS*)psStats; + break; + case COMP_REPAIRUNIT: + repairStats = (REPAIR_STATS*)psStats; + break; + case COMP_WEAPON: + weaponStats = (WEAPON_STATS*)psStats; + break; + //default: + //don't want to draw for unknown comp + } + type = statType(psStats-ref); /*if type = BODY or PROPULSION can do a straight comparison but if the new stat is a 'system' stat then need to find out which 'system' is currently in place so the @@ -3648,43 +3678,56 @@ } else { -type = COMP_UNKNOWN; + // compare it with the current weapon +type = COMP_WEAPON; } } switch (type) { case COMP_BODY: - compTempl.asParts[COMP_BODY] = (BODY_STATS *)psStats - asBodyStats; + bodyStats = (BODY_STATS*)psStats; break; case COMP_PROPULSION: - compTempl.asParts[COMP_PROPULSION] = (PROPULSION_STATS *)psStats - -asPropulsionStats; + propulsionStats = (PROPULSION_STATS*)psStats; break; case COMP_ECM: - compTempl.asParts[COMP_ECM] = (ECM_STATS *)psStats - asECMStats; + ECMStats = (ECM_STATS*)psStats; break; case COMP_SENSOR: - compTempl.asParts[COMP_SENSOR] = (SENSOR_STATS *)psStats - -asSensorStats; + sensorStats = (SENSOR_STATS*)psStats; break; case COMP_CONSTRUCT: - compTempl.asParts[COMP_CONSTRUCT] = (CONSTRUCT_STATS *)psStats - -asConstructStats; + constructStats = (CONSTRUCT_STATS*)psStats; break; case COMP_REPAIRUNIT: - compTempl.asParts[COMP_REPAIRUNIT] = (REPAIR_STATS *)psStats - -asRepairStats; + repairStats = (REPAIR_STATS*)psStats; break; case COMP_WEAPON: - compTempl.asWeaps[0] = (WEAPON_STATS *)psStats - asWeaponStats; + weaponStats = (WEAPON_STATS*)psStats; break; //default: //don't want to draw for unknown comp } + // this code is from calcTemplatePower + UDWORD power, i; - widgSetMinorBarSize( psWScreen, IDDES_POWERBAR, -calcTemplatePower(compTempl)); + //get the component power + power = bodyStats-buildPower + brainStats-buildPower + sensorStats-buildPower + ECMStats-buildPower + repairStats-buildPower + constructStats-buildPower; + + /* propulsion power points are a percentage of the bodys' power points */ + power += (propulsionStats-buildPower * + bodyStats-buildPower) / 100; + + //add weapon power +// FIXME: Only takes first weapon into account +power += weaponStats-buildPower; + for(i=1; isCurrDesign.numWeaps; i++) + { + power += (asWeaponStats + sCurrDesign.asWeaps[i])-buildPower; + } + widgSetMinorBarSize( psWScreen, IDDES_POWERBAR, +power); } else { @@ -3705,12 +3748,18 @@ static void intSetTemplateBodyShadowStats(COMP_BASE_STATS *psStats) { UDWORDtype; - DROID_TEMPLATE compTempl; - if (sCurrDesign != NULL psStats != NULL) - { - //create the comparison Template - memcpy(compTempl, sCurrDesign, sizeof(DROID_TEMPLATE)); + if (psStats != NULL) { +BODY_STATS* bodyStats = asBodyStats +
Re: [Warzone-dev] Please apply this patch
Am Mittwoch, 14. Februar 2007 schrieb Gerard Krol: I know I only posted it only 4 days ago, but I really sleep better when I know my patches have been applied. Could someone apply this patch? I even polished it a little bit more. I think there were no objections? I'll commit it when I am back from my journey to Windows... --Dennis pgpK8c8b2TNnL.pgp Description: PGP signature ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev
Re: [Warzone-dev] Please apply this patch
Gerard Krol schreef: I know I only posted it only 4 days ago, but I really sleep better when I know my patches have been applied. Could someone apply this patch? I even polished it a little bit more. This patch prevents a segfault when designing a droid on amd64. Reproduce: on amd64, go to the droid design screen and design a construction droid. Then hover your mouse over another system, like sensor or command. Regards, Gerard Applied in r750. Hope you did sleep well enough those 4 days? Anyway I'm hoping you'll sleep better now again ;-) . -- Giel signature.asc Description: OpenPGP digital signature ___ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev