Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move delivery points under newly-built structures.

Fixes ticket:2998.
  • Loading branch information...
commit 1cc0d533f4edf33e672da3b55eb8f3d741db81e1 1 parent 8c83693
Cyp authored September 25, 2012

Showing 1 changed file with 27 additions and 0 deletions. Show diff stats Hide diff stats

  1. 27  src/structure.cpp
27  src/structure.cpp
@@ -1648,6 +1648,33 @@ STRUCTURE* buildStructureDir(STRUCTURE_STATS *pStructureType, UDWORD x, UDWORD y
1648 1648
 		{
1649 1649
 			psBuilding->asWeaps[0].ammo = 1; // ready to trigger the fire button
1650 1650
 		}
  1651
+
  1652
+		// Move any delivery points under the new structure.
  1653
+		StructureBounds bounds = getStructureBounds(psBuilding);
  1654
+		for (unsigned player = 0; player < MAX_PLAYERS; ++player)
  1655
+		{
  1656
+			for (STRUCTURE *psStruct = apsStructLists[player]; psStruct != NULL; psStruct = psStruct->psNext)
  1657
+			{
  1658
+				FLAG_POSITION *fp = NULL;
  1659
+				if (StructIsFactory(psStruct))
  1660
+				{
  1661
+					fp = psStruct->pFunctionality->factory.psAssemblyPoint;
  1662
+				}
  1663
+				else if (psStruct->pStructureType->type == REF_REPAIR_FACILITY)
  1664
+				{
  1665
+					fp = psStruct->pFunctionality->repairFacility.psDeliveryPoint;
  1666
+				}
  1667
+				if (fp != NULL)
  1668
+				{
  1669
+					Vector2i pos = map_coord(removeZ(fp->coords));
  1670
+					if (unsigned(pos.x - bounds.map.x) < unsigned(bounds.size.x) && unsigned(pos.y - bounds.map.y) < unsigned(bounds.size.y))
  1671
+					{
  1672
+						// Delivery point fp is under the new structure. Need to move it.
  1673
+						setAssemblyPoint(fp, fp->coords.x, fp->coords.y, player, true);
  1674
+					}
  1675
+				}
  1676
+			}
  1677
+		}
1651 1678
 	}
1652 1679
 	else //its an upgrade
1653 1680
 	{

0 notes on commit 1cc0d53

Please sign in to comment.
Something went wrong with that request. Please try again.