Skip to content

Commit

Permalink
Fix blueprint alignment and snap modules.
Browse files Browse the repository at this point in the history
Closes #3466.
  • Loading branch information
Safety0ff committed Jun 21, 2012
1 parent adc13fe commit 581d654
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/edit3d.cpp
Expand Up @@ -30,6 +30,7 @@
#include "objects.h"
#include "display.h"
#include "hci.h"
#include "geometry.h"

/*
Definition of a tile to highlight - presently more than is required
Expand Down Expand Up @@ -186,12 +187,35 @@ bool process3DBuilding(void)

if (buildState != BUILD3D_FINISHED)
{
Vector2i size = getStatsSize(sBuildDetails.psStats, player.r.y);
Vector2i offset = size * (TILE_UNITS / 2); // This presumably gets added to the chosen coordinates, somewhere, based on looking at what pickStructLocation does. No idea where it gets added, though.
Vector2i offset(TILE_UNITS/2, TILE_UNITS/2); // This presumably gets added to the chosen coordinates, somewhere, based on looking at what pickStructLocation does. No idea where it gets added, though.

if (validLocation(sBuildDetails.psStats, world_coord(Vector2i(bX, bY)) + offset, player.r.y, selectedPlayer, true))
{
buildState = BUILD3D_VALID;

// if it's a structure
if (sBuildDetails.psStats->ref >= REF_STRUCTURE_START && sBuildDetails.psStats->ref < REF_STRUCTURE_START + REF_RANGE)
{
STRUCTURE_STATS* const psBuilding = (STRUCTURE_STATS *)sBuildDetails.psStats;
switch(psBuilding->type)
{
case REF_FACTORY_MODULE:
case REF_RESEARCH_MODULE:
case REF_POWER_MODULE:
{
// If it's a module snap it
STRUCTURE const *psStruct = getTileStructure(bX, bY);
if (psStruct)
{
bX = map_coord(psStruct->pos.x);
bY = map_coord(psStruct->pos.y);
}
break;
}
default:
break;
}
}
}
else
{
Expand Down

0 comments on commit 581d654

Please sign in to comment.