Skip to content

Commit 5a416e5

Browse files
committed
If removing wall overlay, sell it instead if wall owner matches building owner
1 parent 0b2cbfb commit 5a416e5

5 files changed

Lines changed: 9 additions & 6 deletions

File tree

YRpp

Submodule YRpp updated 1 file

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ ProneSpeed= ; floating point value, multiplier, by default, us
11781178
### Buildable-upon OverlayTypes
11791179

11801180
- It is now possible to make OverlayTypes allow buildings to be placed on them by setting `CanBeBuiltOn` to true. This still requires the tile's landtype (which is changed to overlay's land type unless OverlayType has `NoUseTileLandType=false`) to allow buildings to be placed.
1181-
- If `CanBeBuiltOn.Remove=true`, the overlay will be removed upon the building being placed. If this is not set to true, buildings with `Wall=true` cannot be placed on the overlay and neither does overlay with `Wall=true` allow buildings to be placed on itself regardless of other settings.
1181+
- If `CanBeBuiltOn.Remove=true`, the overlay will be removed (if it is a wall owned by the player placing the building, it is sold) upon the building being placed. If this is not set to true, buildings with `Wall=true` cannot be placed on the overlay and neither does overlay with `Wall=true` allow buildings to be placed on itself regardless of other settings.
11821182

11831183
In `rulesmd.ini`:
11841184
```ini

src/Ext/OverlayType/Body.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ bool OverlayTypeExt::CanBeBuiltOn(int overlayTypeIndex, BuildingTypeClass* pBuil
1616
return requireToBeRemovable ? pTypeExt->CanBeBuiltOn_Remove : true;
1717
}
1818

19-
void OverlayTypeExt::RemoveOverlayFromCell(int overlayTypeIndex, CellClass* pCell)
19+
void OverlayTypeExt::RemoveOverlayFromCell(int overlayTypeIndex, CellClass* pCell, HouseClass* pSource)
2020
{
2121
if (overlayTypeIndex != -1 && OverlayTypeClass::Array[overlayTypeIndex]->Wall)
2222
{
23-
pCell->DamageWall(-1);
23+
if (pSource && pCell->WallOwnerIndex == pSource->ArrayIndex)
24+
pSource->SellWall(pCell->MapCoords, true);
25+
else
26+
pCell->DamageWall(-1);
2427
}
2528
else
2629
{

src/Ext/OverlayType/Body.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ class OverlayTypeExt
5656
static bool SaveGlobals(PhobosStreamWriter& Stm);
5757

5858
static bool CanBeBuiltOn(int overlayTypeIndex, BuildingTypeClass* pBuildingType, bool requireToBeRemovable);
59-
static void RemoveOverlayFromCell(int overlayTypeIndex, CellClass* pCell);
59+
static void RemoveOverlayFromCell(int overlayTypeIndex, CellClass* pCell, HouseClass* pSource);
6060
};

src/Ext/TerrainType/Hooks.Passable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ DEFINE_HOOK(0x5684B1, MapClass_PlaceDown_BuildableTerrain, 0x6)
122122
auto const pBuildingType = static_cast<BuildingTypeClass*>(pObject->GetType());
123123

124124
if (OverlayTypeExt::CanBeBuiltOn(overlayTypeIndex, pBuildingType, true))
125-
OverlayTypeExt::RemoveOverlayFromCell(overlayTypeIndex, pCell);
125+
OverlayTypeExt::RemoveOverlayFromCell(overlayTypeIndex, pCell, pObject->GetOwningHouse());
126126
}
127127
}
128128

0 commit comments

Comments
 (0)