Fixed bug: Building buildings with 0 build time, dumps core. division by zero.

This commit is contained in:
johns 2001-03-26 20:13:01 +00:00
parent 5261117c78
commit 2e94b4dfec
2 changed files with 12 additions and 2 deletions

View file

@ -569,7 +569,11 @@
<LI>Some more menu code for network menus - unfinished yet. <LI>Some more menu code for network menus - unfinished yet.
<LI>Let the AI workers only harvest reachable trees. (very great <LI>Let the AI workers only harvest reachable trees. (very great
performance increase.) performance increase.)
<LI>Made icons configurable. <LI>Made icons configurable (with CCL FreeCraft configuration language).
<LI>Made buttons configurable (with CCL FreeCraft configuration language).
<LI>Removed old command code, only the new order code is now present.
<LI>Fixed bug: Attacking walls broken with new orders.
<LI>Fixed bug: Building buildings with 0 build time, dumps core. (/0)
<LI>+++ <LI>+++
<LI>TODO: Fixed bug: Unit does not return to starting point, if attacking. <LI>TODO: Fixed bug: Unit does not return to starting point, if attacking.
</UL> </UL>

View file

@ -154,7 +154,13 @@ global void HandleActionBuild(Unit* unit)
build->Data.Builded.Sum=0; // FIXME: Is it necessary? build->Data.Builded.Sum=0; // FIXME: Is it necessary?
build->Data.Builded.Val=stats->HitPoints; build->Data.Builded.Val=stats->HitPoints;
n=(stats->Costs[TimeCost]*FRAMES_PER_SECOND/6)/(SpeedBuild*5); n=(stats->Costs[TimeCost]*FRAMES_PER_SECOND/6)/(SpeedBuild*5);
build->Data.Builded.Add=stats->HitPoints/n; if( n ) {
build->Data.Builded.Add=stats->HitPoints/n;
} else { // No build time pops-up?
build->Data.Builded.Add=stats->HitPoints;
// This checks if the value fits in the data type
DebugCheck( build->Data.Builded.Add!=stats->HitPoints );
}
build->Data.Builded.Sub=n; build->Data.Builded.Sub=n;
build->Data.Builded.Cancel=0; // FIXME: Is it necessary? build->Data.Builded.Cancel=0; // FIXME: Is it necessary?
build->Data.Builded.Worker=unit; build->Data.Builded.Worker=unit;