Skip to content

Commit

Permalink
addConstructorEffect: Prevent divide-by-zero
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Jul 18, 2023
1 parent 225bad0 commit 47ed012
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/droid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ static void addConstructorEffect(STRUCTURE *psStruct)
{
/* This needs fixing - it's an arse effect! */
const Vector2i size = psStruct->size() * TILE_UNITS / 4;
ASSERT_OR_RETURN(, size.x > 0 && size.y > 0, "Zero-size building?: %s", (psStruct && psStruct->pStructureType) ? psStruct->pStructureType->id.toUtf8().c_str() : "<null>");
Vector3i temp;
temp.x = psStruct->pos.x + ((rand() % (2 * size.x)) - size.x);
temp.y = map_TileHeight(map_coord(psStruct->pos.x), map_coord(psStruct->pos.y)) + (psStruct->sDisplay.imd->max.y / 6);
Expand Down

0 comments on commit 47ed012

Please sign in to comment.