Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
786e39f
types: Moat tile is int, x/y and fillProgress are signed
gynt Nov 7, 2026
c6eb340
types: Rock::x and Rock::y are short
gynt Nov 7, 2026
57ad68a
types: Unit field_0x83 is a byte field, not padding
gynt Nov 7, 2026
db8c482
types: TileMapState counters and flags are signed, MacroLayer is short
gynt Nov 7, 2026
b882e31
types: validateWallPlacementAtTile takes the mapper command as short
gynt Nov 7, 2026
04af9b1
Reimplement 88 Map::TileMapState functions at 100%
gynt Nov 7, 2026
b374897
style(TileMapState): apply the reimplementation style guide to the 88…
gynt Nov 7, 2026
5de5096
style(TileMapState): write the footprint loops as while (true) with a…
gynt Nov 7, 2026
be54045
Merge origin/main into reimpl/TileMapState-100
gynt Nov 7, 2026
bb90ea0
removed comments, return FALSE instead of 0
gynt Nov 8, 2026
c21cc0c
style(TileMapState): swapWallOwnership as a plain per-tile loop
gynt Nov 8, 2026
0a5ba82
style(TileMapState): let MSVC unroll the remaining tile loops
gynt Nov 8, 2026
4227c71
style(TileMapState): apply main's style guide to the remaining spots
gynt Nov 8, 2026
0173f09
style(TileMapState): use compound assignments, drop redundant usings
gynt Nov 11, 2026
a50bdcf
style(TileMapState): drop unnecessary casts, use countof() for array …
gynt Nov 11, 2026
6ad2a6c
style(TileMapState): pass 0 instead of '\0' as the fill byte
gynt Nov 11, 2026
6f522f7
Merge origin/main into reimpl/TileMapState-100
gynt Nov 11, 2026
51479bd
style(TileMapState): use main's MapOrientation and BOOLEnum field types
gynt Nov 11, 2026
67247ca
Merge remote-tracking branch 'origin/main' into reimpl/TileMapState-100
gynt Nov 12, 2026
7d1f870
types: add the CardinalDirection enum
gynt Nov 12, 2026
31a645f
types: getOrientationThatIsWallTowerOrGatehouse returns MapOrientation
gynt Nov 12, 2026
04a5f3e
style(TileMapState): enum names from review
gynt Nov 12, 2026
03523e2
Merge remote-tracking branch 'origin/main' into reimpl/TileMapState-100
gynt Nov 12, 2026
5c1e705
reimplement(TileMapState): follow main's changeMapOrientation(MapOrie…
gynt Nov 12, 2026
9882188
types: getOrientationThatIsWallTowerOrGatehouse returns CardinalDirec…
gynt Nov 12, 2026
46b6f76
Merge remote-tracking branch 'origin/main' into reimpl/TileMapState-100
gynt Nov 13, 2026
2a224ea
Merge remote-tracking branch 'origin/main' into reimpl/TileMapState-100
gynt Nov 13, 2026
531e6e3
style(TileMapState): direction, orientation and view enums from review
gynt Nov 15, 2026
bae202f
style(TileMapState): do-while footprint loops and MiscDisplay flags f…
gynt Nov 15, 2026
ccb8650
style(TileMapState): wall owner mask, types and flag checks from review
gynt Nov 15, 2026
73f5100
style(TileMapState): enum names in the remaining PR sources
gynt Nov 15, 2026
233eacc
types(TileMapState): signed coordinates and value types from review
gynt Nov 15, 2026
e4efe7a
types(TileMapState): enums, struct and names proposed in the review
gynt Nov 16, 2026
d146f8e
Merge remote-tracking branch 'origin/main' into reimpl/TileMapState-100
gynt Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cmake/compiler-flags-gl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAn
src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_GatehouseOpenClose.cpp
src/OpenSHC/UI/MenuItems/BuildingAndStatusMenu/MenuItemRenderFunction_BuildingAndStatusMenu_WorkshopWeaponSelection.cpp
src/OpenSHC/UI/MenuItems/General/MenuItemRenderFunction_General_RenderCurrentButtonWithPossibleAlphaTexOnScreenMenuSurface.cpp
src/OpenSHC/Map/TileMapState/getBuildingSizeIndexMappingData.cpp
src/OpenSHC/Map/TileMapState/setSignpostDistanceForCampaignMission.cpp
src/OpenSHC/Map/TileMapState/clearDrawBridgeWater.cpp
src/OpenSHC/Map/TileMapState/clearFixedSizeTwoBuildingFootprint.cpp
src/OpenSHC/Map/TileMapState/markBuildingFootprintFlag.cpp
src/OpenSHC/Map/TileMapState/storeMinAndMaxHeightOfArea.cpp
src/OpenSHC/Map/TileMapState/unmarkBuildingFootprintFlag.cpp
src/OpenSHC/Map/TileMapState/updateGameRelatedValue.cpp
src/OpenSHC/Map/TileMapState/clearBuildingFromTerrain.cpp
src/OpenSHC/Map/TileMapState/clearBuildingFootprintAndResetUnits.cpp
src/OpenSHC/Map/TileMapState/computeWallCornerRenderRotation.cpp
src/OpenSHC/Map/TileMapState/isWallConnectionHeightValid.cpp
src/OpenSHC/Map/TileMapState/getWallFlagForOrientedDirection.cpp
src/OpenSHC/Map/TileMapState/setupAllMapSections.cpp
src/OpenSHC/Map/TileMapState/setupLogicalMapBorders.cpp
src/OpenSHC/Map/TileMapState/updateShowHiLayerOrResetChangedLayer.cpp
src/OpenSHC/UI/DisplayElements/RenderTimeUntilDefeatDisplayElement.cpp
src/OpenSHC/UI/DisplayElements/GetIfDisplayElementStateNotZero.cpp
src/OpenSHC/UI/DisplayElements/FindDisplayElementWithID.cpp
Expand Down
65 changes: 65 additions & 0 deletions src/OpenSHC/Map/TileMapState/Constructor_TileMapState.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include "../TileMapState.func.hpp"

#include "OpenSHC/Commands/MappersEnum.hpp"
#include "OpenSHC/Map/Enums/LoweredViewTransition.hpp"
#include "OpenSHC/Map/Rocks/Enums/EditorRockType.hpp"
#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp"

#include "OpenSHC/Globals/DAT_GameCore.hpp"
#include "OpenSHC/Globals/DAT_GameState.hpp"

namespace OpenSHC {
namespace Map {

// FUNCTION: STRONGHOLDCRUSADER 0x00515F40
TileMapState* TileMapState::Constructor_TileMapState()
{
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setupMovementDirectionTranslationMatrix, this)();
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setupBuildingSizeIndexMapping, this)();
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setupTileMapSections, this)();
this->editorActiveBrush = 7;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These bruhes are sizes, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. editorActiveBrush is a brush-size index 1..7 into TerrainDefinedData.BrushSizeArray = {0, 1, 5, 13, 25, 41, 85, 145}, the number of tiles the brush covers (raiseLand loops getTileForBrush over BrushSizeArray[brush] tiles). The landscaping brush buttons cycle it through 1..7 with wrap-around, big rocks round it up to an odd size, and unknownBrushRelated = editorActiveBrush >> 1. So 7 is the largest brush (145 tiles). These are plain sizes with no enum in Ghidra, so the value stays 7. In the same constructor, 531e6e3 now uses the new LoweredViewTransition (refreshCertainTileMap = LVT_SET_NORMAL, refreshCertainTileMap_old = LVT_RAISE, see triggerLoweredView) and EditorRockType (editorRockType = ERT_NONE) enums, plus rockOrientation = MO_NORTH. Same instructions.

this->refreshCertainTileMap = OpenSHC::Map::Enums::LVT_SET_NORMAL;
this->counter1 = 0;
this->mapperMax = FALSE;
this->editorSnapToMode = 0;
this->editorAffectType = 0;
this->unknownZero_0x554900 = 0;
this->currentMapperCommand = OpenSHC::Commands::M_MAPPER_NULL;
this->refreshRelatedOne = 1;
this->disableElevationRendering = 0;
this->refreshRelatedTwo = 0;
this->forceUpdateLogicalAndMiscDisplayLayers = TRUE;
this->forceUpdateTextureTilemap = TRUE;
this->forceUpdateGFXLayers = TRUE;
this->refreshCertainTileMap_old = OpenSHC::Map::Enums::LVT_RAISE;
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::setChangedLayerToThreeAndMapping0x40x40, this)();
this->moatTileCount = 0;
this->skipPlacementCheck = 0;
this->gateOrientationVariant = 80;
this->lastTime = timeGetTime();
this->rockOrientation = OpenSHC::Map::Enums::MO_NORTH;
this->editorRockType = OpenSHC::Map::Rocks::Enums::ERT_NONE;
this->cursorAnimationTime = timeGetTime();
this->cursorOverlayAnimationFrame = 1;
this->temporaryTerrainTypeIndex = 0;
this->skipPlacementFailChecks = 0;
DAT_GameCore::instance.isTimeHalted = FALSE;
DAT_GameState::instance.mapAndTime.skirmishFogOfWar = 0;
this->ptr_LogicLayer = this->LogicLayer;
this->ptr_TerrainTypeTileMap = this->Logic2Layer;
this->ptr_TerrainHeightTileMap = this->HeightLayer;
this->ptr_ChangedLayer = this->ChangedLayer;
this->ptr_OccupancyLayer = this->OccupancyLayer;
this->ptr_DamageLayer = this->DamageLayer;
this->ptr_PathConnectionLayer = this->PathConnectionLayer;
this->ptr_MovementDirectionTranslationMatrix = this;
this->ptr_SpecialAreasArray = this->specialAreasArray;
this->ptr_AIZoneLayer = this->AIZoneLayer;
this->ptr_MiscDisplayLayer = this->MiscDisplayLayer;
this->currentMoatCount = 16000;
this->maxPitchDitchCount = 4000;
return this;
}

}
}
43 changes: 43 additions & 0 deletions src/OpenSHC/Map/TileMapState/advanceMoatDigProgress.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "../TileMapState.func.hpp"

#include "OpenSHC/Map/Navigation/PathFindingState.func.hpp"
#include "OpenSHC/UI/MinimapViewState.func.hpp"

#include "OpenSHC/Globals/DAT_MinimapViewState.hpp"
#include "OpenSHC/Globals/DAT_PathFindingState.hpp"

namespace OpenSHC {
namespace Map {

using OpenSHC::Map::LogicHelpers::L2_NONE;
using OpenSHC::Map::LogicHelpers::L_MOAT;
using OpenSHC::Map::LogicHelpers::L_MOAT_DUG_OR_PLANNED;
using OpenSHC::Map::LogicHelpers::L_PLAIN2_AND_PITCH;

// FUNCTION: STRONGHOLDCRUSADER 0x00500500
BOOLEnum TileMapState::advanceMoatDigProgress(int moatID)
{
this->moats[moatID].fillProgress += 1;
if (this->moats[moatID].fillProgress >= 4) {
int tile = this->moats[moatID].tile;
this->moats[moatID].someCountDown = 0;
this->moats[moatID].fillProgress = 4;
this->moats[moatID].stage = 2;
this->HeightLayer[tile] = 0;
this->LogicLayer[this->moats[moatID].tile] &= ~L_MOAT_DUG_OR_PLANNED;
this->LogicLayer[this->moats[moatID].tile] &= ~L_PLAIN2_AND_PITCH;
this->LogicLayer[this->moats[moatID].tile] |= L_MOAT;
this->Logic2Layer[this->moats[moatID].tile] = L2_NONE;
MACRO_CALL_MEMBER(OpenSHC::Map::Navigation::PathFindingState_Func::updateWalkAndPathLayer,
DAT_PathFindingState::ptr)(2, this->moats[moatID].x, this->moats[moatID].y);
MACRO_CALL_MEMBER(OpenSHC::Map::Navigation::PathFindingState_Func::updatePathLinkagesInAllEightDirections,
DAT_PathFindingState::ptr)(this->moats[moatID].y, this->moats[moatID].tile);
DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = 1;
MACRO_CALL_MEMBER(OpenSHC::UI::MinimapViewState_Func::triggerMinimapRedraw, DAT_MinimapViewState::ptr)(1);
return TRUE;
}
return FALSE;
}

}
}
59 changes: 59 additions & 0 deletions src/OpenSHC/Map/TileMapState/applyRockGraphicsToFootprint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "../TileMapState.func.hpp"

#include "OpenSHC/Map/LandscapeState.func.hpp"
#include "OpenSHC/Map/Enums/CardinalDirection.hpp"

#include "OpenSHC/Globals/DAT_LandscapeState.hpp"
#include "OpenSHC/Globals/DAT_TileMapState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"
#include "OpenSHC/Globals/GMFirstPictureIndex.hpp"

namespace OpenSHC {
namespace Map {

using OpenSHC::Map::Enums::CD_UPPER_LIMIT;
using OpenSHC::Map::LogicHelpers::L_WALL_OR_GATEHOUSE;

// FUNCTION: STRONGHOLDCRUSADER 0x004FB770
void TileMapState::applyRockGraphicsToFootprint(int rockID)
{
int rockX = DAT_LandscapeState::instance.rocks[rockID].x;
int rockY = DAT_LandscapeState::instance.rocks[rockID].y;
int orientation = DAT_LandscapeState::instance.rocks[rockID].orientation + this->mapOrientation;
int index = 0;
if (orientation >= CD_UPPER_LIMIT) {
orientation -= CD_UPPER_LIMIT;
}
int size = DAT_LandscapeState::instance.rocks[rockID].size;
int surface = (orientation / 2) * size * size;

do {
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::getBuildingSizeIndexMappingData, this)(
index, DAT_LandscapeState::instance.rocks[rockID].size);
int tile = DAT_ViewportRenderState::instance.translationMatrix[this->buildingY + rockY].addXgetTile + rockX
+ this->buildingX;
if ((this->LogicLayer[tile] & L_WALL_OR_GATEHOUSE) == 0) {
if (this->disableElevationRendering == 0) {
this->GfxLayer[tile]
= GMFirstPictureIndex::instance[DAT_LandscapeState::instance.rocks[rockID].unknownGMID]
+ DAT_LandscapeState::instance.rocks[rockID].gfx + this->buildingOrientedPartIndex + surface
- 1;
} else if (DAT_LandscapeState::instance.rocks[rockID].size == 1) {
this->GfxLayer[tile]
= GMFirstPictureIndex::instance[DAT_LandscapeState::instance.rocks[rockID].unknownGMID]
+ DAT_LandscapeState::instance.rocks[rockID].gfx + this->buildingOrientedPartIndex + surface
- 1;
} else {
this->GfxLayer[tile]
= MACRO_CALL_MEMBER(OpenSHC::Map::LandscapeState_Func::getRandomRockImageOffset,
DAT_LandscapeState::ptr)((DAT_TileMapState::instance.RandomLayer[tile] & 3) + 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the 3 marks the first two byte in this layer, but we have no info on them at the moment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RandomLayer is not a bit field: setupTileMapSections fills every tile once with nextRandomNumber2(), and nothing in the game writes it afterwards (every other access is a read). & 3 picks one of four variants from that per-tile random number, and getRandomRockImageOffset(n) reads RandomRockImageGMImageOffsets[n], so (RandomLayer[tile] & 3) + 1 is one of the four single-tile rock images 1..4. renderMap uses the identical expression for rocks in the flat view, and the fire spread / archer-point code tests & 3 as a one-in-four chance. It stays & 3: the layer is a signed short, so % 4 would add the negative-remainder fix-up.

+ GMFirstPictureIndex::instance[DAT_LandscapeState::instance.rocks[rockID].unknownGMID]
+ surface - 1;
}
}
index++;
} while (index < this->constructionTileCount);
}

}
}
58 changes: 58 additions & 0 deletions src/OpenSHC/Map/TileMapState/changeMapOrientation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "../TileMapState.func.hpp"

#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp"
#include "OpenSHC/Rendering/ViewportRenderState.func.hpp"
#include "OpenSHC/Map/Enums/CardinalDirection.hpp"

#include "OpenSHC/Globals/DAT_BuildingsState.hpp"
#include "OpenSHC/Globals/DAT_TileMapState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"

namespace OpenSHC {
namespace Map {

// FUNCTION: STRONGHOLDCRUSADER 0x00501B90
void TileMapState::changeMapOrientation(MapOrientation mapOrientation)
{
MACRO_CALL_MEMBER(OpenSHC::Rendering::ViewportRenderState_Func::saveFocusTileAndCenterPreview,
DAT_ViewportRenderState::ptr)();
DAT_TileMapState::instance.mapOrientation = mapOrientation;
MACRO_CALL_MEMBER(
OpenSHC::Rendering::ViewportRenderState_Func::restoreFocusTile, DAT_ViewportRenderState::ptr)();
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::forceFullTileMapRedraw, this)();
MACRO_CALL_MEMBER(
OpenSHC::Map::Buildings::BuildingsState_Func::refreshAllBuildingTileDisplays, DAT_BuildingsState::ptr)();
DAT_BuildingsState::instance.field_0x10 = 5;
switch (this->mapOrientation) {
case OpenSHC::Map::Enums::MO_NORTH:
this->screenSouthEastDirection = OpenSHC::Map::Enums::CD_SOUTHEAST;
this->orientedRowStep = 1;
this->screenEastDirection = OpenSHC::Map::Enums::CD_EAST;
this->screenSouthDirection = OpenSHC::Map::Enums::CD_SOUTH;
this->screenSouthWestDirection = OpenSHC::Map::Enums::CD_SOUTHWEST;
return;
case OpenSHC::Map::Enums::MO_EAST:
this->screenSouthEastDirection = OpenSHC::Map::Enums::CD_SOUTHWEST;
this->orientedRowStep = 1;
this->screenEastDirection = OpenSHC::Map::Enums::CD_SOUTH;
this->screenSouthDirection = OpenSHC::Map::Enums::CD_WEST;
this->screenSouthWestDirection = OpenSHC::Map::Enums::CD_NORTHWEST;
return;
case OpenSHC::Map::Enums::MO_SOUTH:
this->screenSouthEastDirection = OpenSHC::Map::Enums::CD_NORTHWEST;
this->screenEastDirection = OpenSHC::Map::Enums::CD_WEST;
this->screenSouthDirection = OpenSHC::Map::Enums::CD_NORTH;
this->screenSouthWestDirection = OpenSHC::Map::Enums::CD_NORTHEAST;
this->orientedRowStep = -1;
return;
case OpenSHC::Map::Enums::MO_WEST:
this->screenSouthEastDirection = OpenSHC::Map::Enums::CD_NORTHEAST;
this->screenEastDirection = OpenSHC::Map::Enums::CD_NORTH;
this->screenSouthDirection = OpenSHC::Map::Enums::CD_EAST;
this->screenSouthWestDirection = OpenSHC::Map::Enums::CD_SOUTHEAST;
this->orientedRowStep = -1;
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "../TileMapState.func.hpp"

#include "OpenSHC/Map/Entities/EntityState.func.hpp"
#include "OpenSHC/Map/LogicHelpers/MiscDisplay.hpp"

#include "OpenSHC/Globals/DAT_BuildingsState.hpp"
#include "OpenSHC/Globals/DAT_EntityState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"

namespace OpenSHC {
namespace Map {

using OpenSHC::Map::LogicHelpers::MD_BUILDING_TILES;

// FUNCTION: STRONGHOLDCRUSADER 0x004FB360
void TileMapState::clearBuildingDisplayFlagsAndEntities(int buildingID, int destroyEntities)
{
int buildingSizeTileIndex = 0;
int buildingX = DAT_BuildingsState::instance.buildings[buildingID].x;
int buildingY = DAT_BuildingsState::instance.buildings[buildingID].y;
uint widthOrHeight = DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight;

do {
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::getBuildingSizeIndexMappingData, this)(
buildingSizeTileIndex, widthOrHeight);
int tileUnk = DAT_ViewportRenderState::instance.translationMatrix[this->buildingY + buildingY].addXgetTile
+ this->buildingX + buildingX;
this->MiscDisplayLayer[tileUnk] &= ~MD_BUILDING_TILES;
if (destroyEntities == 1) {
MACRO_CALL_MEMBER(
OpenSHC::Map::Entities::EntityState_Func::destroyEntitiesOnTile, DAT_EntityState::ptr)(tileUnk);
}
buildingSizeTileIndex++;
} while (buildingSizeTileIndex < this->constructionTileCount);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "../TileMapState.func.hpp"

#include "OpenSHC/Map/Navigation/PathFindingState.func.hpp"
#include "OpenSHC/Map/Units/States/UnitState.hpp"
#include "OpenSHC/Map/Units/UnitType.hpp"

#include "OpenSHC/Globals/DAT_PathFindingState.hpp"
#include "OpenSHC/Globals/DAT_UnitsState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"

namespace OpenSHC {
namespace Map {

using OpenSHC::Map::LogicHelpers::L_BUILDING;
using OpenSHC::Map::LogicHelpers::L_CRENEL;
using OpenSHC::Map::LogicHelpers::L_CRENEL_VARIATIONUnk;
using OpenSHC::Map::LogicHelpers::L_KEEP_NON_MANOR_HOUSE;
using OpenSHC::Map::LogicHelpers::L_STAIRS;
using OpenSHC::Map::LogicHelpers::L_WALL_OR_GATEHOUSE;

// FUNCTION: STRONGHOLDCRUSADER 0x004FAC70
void TileMapState::clearBuildingFootprintAndRemoveSiegeTower(int x, int y, int size)
{
int tileIndex = 0;

do {
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::getBuildingSizeIndexMappingData, this)(tileIndex, size);
int tile = DAT_ViewportRenderState::instance.translationMatrix[this->buildingY + y].addXgetTile
+ this->buildingX + x;
this->LogicLayer[tile] &= ~(L_WALL_OR_GATEHOUSE | L_CRENEL | L_BUILDING | L_STAIRS | L_CRENEL_VARIATIONUnk
| L_KEEP_NON_MANOR_HOUSE);
this->BuildingLayer[tile] = 0;
this->HeightLayer[tile] = this->DefaultHeightLayer[tile];
MACRO_CALL_MEMBER(OpenSHC::Map::Navigation::PathFindingState_Func::updatePathLinkagesInAllEightDirections,
DAT_PathFindingState::ptr)(
DAT_ViewportRenderState::instance.tileTranslationMatrix_YComponent[tile], tile);
int unitID = this->UnitLayer[tile];
if (unitID != 0 && DAT_UnitsState::instance.units[unitID].unitType == OpenSHC::Map::Units::UT_S_TOWER) {
DAT_UnitsState::instance.units[unitID].state.generic = OpenSHC::Map::Units::States::US_DISAPPEAR;
}
tileIndex++;
} while (tileIndex < this->constructionTileCount);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "../TileMapState.func.hpp"

#include "OpenSHC/Map/LogicHelpers/MiscDisplay.hpp"
#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp"

#include "OpenSHC/Globals/DAT_BuildingsState.hpp"
#include "OpenSHC/Globals/DAT_UnitsState.hpp"
#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp"

namespace OpenSHC {
namespace Map {

using OpenSHC::Map::LogicHelpers::L_BUILDING;
using OpenSHC::Map::LogicHelpers::L_CRENEL;
using OpenSHC::Map::LogicHelpers::L_CRENEL_VARIATIONUnk;
using OpenSHC::Map::LogicHelpers::L_KEEP_NON_MANOR_HOUSE;
using OpenSHC::Map::LogicHelpers::L_STAIRS;
using OpenSHC::Map::LogicHelpers::L_WALL_OR_GATEHOUSE;
using OpenSHC::Map::LogicHelpers::MD_GATEHOUSE_RAISED;
using OpenSHC::Map::LogicHelpers::MD_RUBBLE_EDGEUnk;
using OpenSHC::Map::LogicHelpers::MD_RUBBLE_INNERUnk;

// FUNCTION: STRONGHOLDCRUSADER 0x004FAB70
void TileMapState::clearBuildingFootprintAndResetUnits(int x, int y, int size)
{
int buildingSizeTileIndex = 0;

do {
MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::getBuildingSizeIndexMappingData, this)(
buildingSizeTileIndex, size);
int tile = DAT_ViewportRenderState::instance.translationMatrix[this->buildingY + y].addXgetTile
+ this->buildingX + x;
this->LogicLayer[tile] &= ~(L_WALL_OR_GATEHOUSE | L_CRENEL | L_BUILDING | L_STAIRS | L_CRENEL_VARIATIONUnk
| L_KEEP_NON_MANOR_HOUSE);
if ((this->MiscDisplayLayer[tile] & MD_GATEHOUSE_RAISED) != 0) {
this->MiscDisplayLayer[tile] &= ~MD_GATEHOUSE_RAISED;
this->HeightLayer[tile] = this->DefaultHeightLayer[tile];
}
int buildingID = this->BuildingLayer[tile];
this->BuildingLayer[tile] = 0;
if (DAT_BuildingsState::instance.buildings[buildingID].noRubble == 0) {
this->BuildingWasLayer[tile] = 0;
} else if (MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::isFootprintIndexOnEdge, this)(
buildingSizeTileIndex, size)) {
this->MiscDisplayLayer[tile] |= MD_RUBBLE_EDGEUnk;
} else {
this->MiscDisplayLayer[tile] |= MD_RUBBLE_INNERUnk;
}
for (int unitID = this->UnitLayer[tile]; unitID != 0;
unitID = DAT_UnitsState::instance.units[unitID].nextUnitOnTheSameTile) {
DAT_UnitsState::instance.units[unitID].vanish = 0;
DAT_UnitsState::instance.units[unitID].unknownCountdown_0x402 = 0;
}
buildingSizeTileIndex++;
this->ChangedLayer[tile] = 2;
} while (buildingSizeTileIndex < this->constructionTileCount);
}

}
}
Loading
Loading