Skip to content

Commit

Permalink
walls: Allow building gates on top of walls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyp committed Nov 17, 2011
1 parent 116afd0 commit a7b2a5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/action.cpp
Expand Up @@ -1585,10 +1585,11 @@ void actionUpdateDroid(DROID *psDroid)
helpBuild = true;
}
else if ((psStruct->pStructureType->type == REF_WALL ||
psStruct->pStructureType->type == REF_WALLCORNER) &&
((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_DEFENSE)
psStruct->pStructureType->type == REF_WALLCORNER) &&
(((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_DEFENSE ||
((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_GATE))
{
// building a gun tower over a wall - OK
// building a gun tower or gate over a wall - OK
if (droidStartBuild(psDroid))
{
syncDebug("Reached build target: tower");
Expand Down Expand Up @@ -1648,7 +1649,7 @@ void actionUpdateDroid(DROID *psDroid)
helpBuild = true;
}
else if ((psStruct->pStructureType->type == REF_WALL || psStruct->pStructureType->type == REF_WALLCORNER) &&
((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_DEFENSE)
(((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_DEFENSE || ((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_GATE))
{
// building a gun tower over a wall - OK
if (droidStartBuild(psDroid))
Expand Down
7 changes: 4 additions & 3 deletions src/structure.cpp
Expand Up @@ -1357,7 +1357,7 @@ static void buildFlatten(STRUCTURE *pStructure, int h)
void alignStructure(STRUCTURE *psBuilding)
{
/* DEFENSIVE structures are pulled to the terrain */
if (psBuilding->pStructureType->type != REF_DEFENSE && psBuilding->pStructureType->type != REF_WALL && psBuilding->pStructureType->type != REF_WALLCORNER)
if (psBuilding->pStructureType->type != REF_DEFENSE && psBuilding->pStructureType->type != REF_GATE && psBuilding->pStructureType->type != REF_WALL && psBuilding->pStructureType->type != REF_WALLCORNER)
{
int mapH = foundationHeight(psBuilding);

Expand Down Expand Up @@ -1507,7 +1507,7 @@ STRUCTURE* buildStructureDir(STRUCTURE_STATS *pStructureType, UDWORD x, UDWORD y

/* Remove any walls underneath the building. You can build defense buildings on top
* of walls, you see. This is not the place to test whether we own it! */
if (pStructureType->type == REF_DEFENSE && TileHasWall(psTile))
if ((pStructureType->type == REF_DEFENSE || pStructureType->type == REF_GATE) && TileHasWall(psTile))
{
removeStruct((STRUCTURE *)psTile->psObject, true);
}
Expand Down Expand Up @@ -4301,6 +4301,7 @@ bool validLocation(BASE_STATS *psStats, unsigned x, unsigned y, uint16_t directi
if (valid && // only do if necessary
(!(psBuilding->type == REF_REPAIR_FACILITY ||
psBuilding->type == REF_DEFENSE ||
psBuilding->type == REF_GATE ||
psBuilding->type == REF_WALL)))
{
/*cannot build on ground that is too steep*/
Expand Down Expand Up @@ -4355,7 +4356,7 @@ bool validLocation(BASE_STATS *psStats, unsigned x, unsigned y, uint16_t directi
psTile = mapTile(i,j);
if (TileIsOccupied(psTile))
{
if (TileHasWall(psTile) && (psBuilding->type == REF_DEFENSE || psBuilding->type == REF_WALL))
if (TileHasWall(psTile) && (psBuilding->type == REF_DEFENSE || psBuilding->type == REF_GATE || psBuilding->type == REF_WALL))
{
psStruct = getTileStructure(i,j);
if (psStruct != NULL &&
Expand Down

0 comments on commit a7b2a5b

Please sign in to comment.