Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
1f9505e
reimplement: SHC_3BB0A8C1_0x004092E0 100.00% Reimplemented
gynt Sep 27, 2026
bfbc3ff
reimplement: SHC_3BB0A8C1_0x00401040 100.00% Reimplemented
gynt Sep 27, 2026
4029c68
reimplement: SHC_3BB0A8C1_0x004E7800 100.00% Reimplemented
gynt Sep 27, 2026
274960a
reimplement: SHC_3BB0A8C1_0x004E8C90 100.00% Reimplemented
gynt Sep 27, 2026
e49b16e
reimplement: SHC_3BB0A8C1_0x004E8CC0 100.00% Reimplemented
gynt Sep 27, 2026
ef88eb0
reimplement: SHC_3BB0A8C1_0x004E8CA0 100.00% Reimplemented
gynt Sep 27, 2026
903c604
reimplement: SHC_3BB0A8C1_0x004E8C50 100.00% Reimplemented
gynt Sep 27, 2026
4643526
reimplement: SHC_3BB0A8C1_0x00401000 100.00% Reimplemented
gynt Sep 27, 2026
09059c4
reimplement: SHC_3BB0A8C1_0x004E2600 100.00% Reimplemented
gynt Sep 27, 2026
8cf4002
reimplement: SHC_3BB0A8C1_0x004E5DD0 100.00% Reimplemented
gynt Sep 27, 2026
a93d59c
reimplement: SHC_3BB0A8C1_0x004E5D80 100.00% Reimplemented
gynt Sep 27, 2026
f18f126
reimplement: SHC_3BB0A8C1_0x004E6340 100.00% Reimplemented
gynt Sep 27, 2026
264327a
reimplement: SHC_3BB0A8C1_0x004E7770 36.56% LTCG ecx reuse in callers
gynt Sep 27, 2026
b3c3de8
reimplement: SHC_3BB0A8C1_0x004E1FA0 100.00% Reimplemented
gynt Sep 27, 2026
c478137
reimplement: SHC_3BB0A8C1_0x004E25A0 100.00% Reimplemented
gynt Sep 27, 2026
3ac35e3
reimplement: SHC_3BB0A8C1_0x004E5B80 65.71% esi/edi allocation differs
gynt Sep 27, 2026
12e7a37
reimplement: SHC_3BB0A8C1_0x004E2630 51.16% register allocation differs
gynt Sep 27, 2026
d689717
reimplement: SHC_3BB0A8C1_0x004E3870 100.00% Reimplemented
gynt Sep 27, 2026
683ffc9
reimplement: SHC_3BB0A8C1_0x004E63A0 90.28% extra reg copy in original
gynt Sep 27, 2026
38f4ca7
reimplement: SHC_3BB0A8C1_0x004E5E20 90.60% goto-free loop exit, 3 instr
gynt Sep 27, 2026
088266f
reimplement: SHC_3BB0A8C1_0x004E64D0 86.86% reccmp label noise only
gynt Sep 27, 2026
7480e9f
reimplement: SHC_3BB0A8C1_0x004E5A90 100.00% Reimplemented
gynt Sep 27, 2026
b0a3af6
reimplement: SHC_3BB0A8C1_0x004E5C00 25.38% reg alloc, extra stack spill
gynt Sep 27, 2026
efde4b4
reimplement: SHC_3BB0A8C1_0x004E26D0 54.08% esi/edx allocation differs
gynt Sep 27, 2026
8bc983b
reimplement: SHC_3BB0A8C1_0x004E5ED0 34.12% reg alloc + tail merging
gynt Sep 27, 2026
792a340
reimplement: SHC_3BB0A8C1_0x004E2050 15.14% style only, asm differs
gynt Sep 27, 2026
4df501a
reimplement: SHC_3BB0A8C1_0x004E3980 34.24% reg alloc + tail merging
gynt Sep 27, 2026
d7ff5b1
reimplement: SHC_3BB0A8C1_0x004E2AD0 45.52% reg alloc, type-load CSE
gynt Sep 27, 2026
2b4d4c1
reimplement: SHC_3BB0A8C1_0x004E8CF0 29.44% frame slot allocation dif…
gynt Sep 27, 2026
83860c0
reimplement: SHC_3BB0A8C1_0x004E7810 32.43% frame and reg allocation …
gynt Sep 27, 2026
a642d6e
reimplement: SHC_3BB0A8C1_0x004E66F0 59.97% consts kept in regs by orig
gynt Sep 27, 2026
1b0f517
reimplement: SHC_3BB0A8C1_0x004E8430 44.09% reg alloc + tail merging
gynt Sep 27, 2026
c580d07
reimplement: SHC_3BB0A8C1_0x004E5ED0 42.30% reg alloc, cold block inline
gynt Sep 27, 2026
3324cbf
reimplement: SHC_3BB0A8C1_0x004E63A0 93.79% one reg-copy form differs
gynt Sep 27, 2026
ad0a8f2
reimplement: SHC_3BB0A8C1_0x004E7810 32.43% frame and reg allocation …
gynt Sep 27, 2026
285a23e
reimplement: SHC_3BB0A8C1_0x004E5C00 57.37% reg alloc + one spill
gynt Sep 27, 2026
cd04abd
reimplement: SHC_3BB0A8C1_0x004E2050 26.06% reg alloc; frame now matches
gynt Sep 27, 2026
6d24e3a
types: ViewportState::ptrColor is a ushort*, not undefined4
gynt Sep 27, 2026
d05e025
reimplement: SHC_3BB0A8C1_0x004E3980 34.24% reg alloc + tail merging
gynt Sep 27, 2026
4655fa2
reimplement: SHC_3BB0A8C1_0x004E2AD0 45.52% reg alloc, type-load CSE
gynt Sep 27, 2026
cb38d67
reimplement: SHC_3BB0A8C1_0x004E8CF0 29.44% frame slot allocation dif…
gynt Sep 27, 2026
e8194a9
reimplement: SHC_3BB0A8C1_0x004E7810 34.46% frame and reg allocation …
gynt Sep 27, 2026
a586ce1
reimplement: SHC_3BB0A8C1_0x004E2050 26.06% reg alloc; frame now matches
gynt Sep 27, 2026
078dce2
reimplement: SHC_3BB0A8C1_0x004E66F0 59.97% consts kept in regs by orig
gynt Sep 27, 2026
426d7e1
reimplement: SHC_3BB0A8C1_0x004E3980 34.24% reg alloc + tail merging
gynt Sep 27, 2026
59266bc
reimplement: SHC_3BB0A8C1_0x004E2AD0 45.52% reg alloc, type-load CSE
gynt Sep 27, 2026
1a20b50
reimplement: SHC_3BB0A8C1_0x004E8CF0 31.81% reg alloc + stack slot order
gynt Sep 27, 2026
09c1445
reimplement: SHC_3BB0A8C1_0x004E3980 44.97% reg alloc, const-in-reg
gynt Sep 27, 2026
0b41fd7
build: give each worktree its own mspdbsrv endpoint
gynt Sep 27, 2026
503ff52
types: the batch/floater counters are signed ints, not undefined4
gynt Sep 27, 2026
dd46e3c
reimplement: SHC_3BB0A8C1_0x004E6340 100.00% Reimplemented
gynt Sep 27, 2026
934a20a
reimplement: SHC_3BB0A8C1_0x004E63A0 93.79% one reg-copy form differs
gynt Sep 27, 2026
c8dc438
reimplement: SHC_3BB0A8C1_0x004E7810 34.46% frame and reg allocation …
gynt Sep 27, 2026
c04f4eb
reimplement: SHC_3BB0A8C1_0x004E26D0 54.08% esi/edx allocation differs
gynt Sep 27, 2026
ba307f4
reimplement: SHC_3BB0A8C1_0x004E2050 28.69% reg alloc; rowStart kept …
gynt Sep 27, 2026
93e4126
reimplement: SHC_3BB0A8C1_0x004E8430 49.45% reg alloc + tail merging
gynt Sep 28, 2026
f8dab5c
reimplement: SHC_3BB0A8C1_0x004E7770 38.71% LTCG ecx reuse in callers
gynt Sep 28, 2026
52481b9
reimplement: SHC_3BB0A8C1_0x004E2050 28.91% reg alloc; frame matches
gynt Sep 28, 2026
b49debc
reimplement: SHC_3BB0A8C1_0x004E2AD0 45.91% reg alloc, type-load CSE
gynt Sep 28, 2026
4f0ad4f
reimplement: SHC_3BB0A8C1_0x004E8430 49.62% reg alloc + tail merging
gynt Sep 28, 2026
6559b71
reimplement: SHC_3BB0A8C1_0x004E8CF0 31.83% reg alloc + stack slot order
gynt Sep 28, 2026
b832da8
reimplement: SHC_3BB0A8C1_0x004E7810 34.69% frame and reg allocation …
gynt Sep 28, 2026
6fda8f1
reimplement: SHC_3BB0A8C1_0x004E5ED0 43.08% reg alloc, one extra spill
gynt Sep 28, 2026
dd92b02
Merge origin/main (build.bat mspdbsrv fix, orig_asm.py, analysis help…
gynt Sep 28, 2026
e9d91c4
Merge origin/main (orig_asm.py fixes)
gynt Sep 28, 2026
8a0b988
reimplement: SHC_3BB0A8C1_0x004E2AD0 47.42% Block order, reg alloc di…
gynt Sep 28, 2026
ec3ba04
reimplement: SHC_3BB0A8C1_0x004E5ED0 43.36% Block order, reg alloc di…
gynt Sep 28, 2026
b2c4f18
reimplement: SHC_3BB0A8C1_0x004E3980 44.97% Style pass, reg alloc dif…
gynt Sep 28, 2026
2d1bcb1
reimplement: SHC_3BB0A8C1_0x004E8CF0 31.88% Style pass, reg alloc dif…
gynt Sep 28, 2026
e37d63f
reimplement: SHC_3BB0A8C1_0x004E8430 49.62% Style pass, reg alloc dif…
gynt Sep 28, 2026
c6ad821
reimplement: SHC_3BB0A8C1_0x004E3980 44.97% Style pass, reg alloc dif…
gynt Sep 28, 2026
74c1b69
reimplement: SHC_3BB0A8C1_0x004E8CF0 31.88% Style pass, reg alloc dif…
gynt Sep 28, 2026
f361ea4
reimplement: SHC_3BB0A8C1_0x004E7810 34.69% Style pass, reg alloc dif…
gynt Sep 28, 2026
2b14689
reimplement: SHC_3BB0A8C1_0x004E2050 30.73% for loops, reg alloc differs
gynt Sep 28, 2026
2d91118
reimplement: SHC_3BB0A8C1_0x004E8430 49.62% Off-by-one fix, reg alloc
gynt Sep 29, 2026
e0479c4
reimplement: SHC_3BB0A8C1_0x004E2050 33.02% Walking pointers, reg alloc
gynt Sep 29, 2026
8921124
reimplement: SHC_3BB0A8C1_0x004E2050 33.02% Walking pointers, reg alloc
gynt Sep 29, 2026
1f82e1c
tools: give the batch build scripts build.bat PDB server fix
gynt Sep 29, 2026
ecaa96f
tools/batch: retry on a fresh PDB endpoint, not just a fresh server
gynt Sep 29, 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
14 changes: 7 additions & 7 deletions src/OpenSHC/Rendering/ViewportRenderState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace Rendering {
undefined4 translationTracker1; // 0x001899E4 length: 4
undefined4 translationResult2; // 0x001899E8 length: 4
Floater floatersArray[250]; // 0x001899EC length: 7000
undefined4 availableFloaterIndex; // 0x0018B544 length: 4
int availableFloaterIndex; // 0x0018B544 length: 4
int landscapeAnimationRandomTileArray[45]; // 0x0018B548 length: 180
byte landscapeAnimationValueArray[60]; // 0x0018B5FC length: 60
int landscapeSeaWhiteCapsAnimationFrames[45]; // 0x0018B638 length: 180
Expand All @@ -78,17 +78,17 @@ namespace Rendering {
int field55_0x18b764; // 0x0018B764 length: 4
int unknownCounterUntil_0x10; // 0x0018B768 length: 4
int unknownCounterUntil_0x200; // 0x0018B76C length: 4
undefined4 unitBatchedRenderCounterUntil6; // 0x0018B770 length: 4
int unitBatchedRenderCounterUntil6; // 0x0018B770 length: 4
UnitRenderHelpStructure unitBatch1[500]; // 0x0018B774 length: 16000
UnitRenderHelpStructure unitBatch2[500]; // 0x0018F5F4 length: 16000
UnitRenderHelpStructure unitBatch3[500]; // 0x00193474 length: 16000
UnitRenderHelpStructure unitBatch4[500]; // 0x001972F4 length: 16000
UnitRenderHelpStructure unitBatch5[500]; // 0x0019B174 length: 16000
undefined4 unitRender1; // 0x0019EFF4 length: 4
undefined4 unitRender2; // 0x0019EFF8 length: 4
undefined4 unitRender3; // 0x0019EFFC length: 4
undefined4 unitRender4; // 0x0019F000 length: 4
undefined4 unitRender5; // 0x0019F004 length: 4
int unitRender1; // 0x0019EFF4 length: 4
int unitRender2; // 0x0019EFF8 length: 4
int unitRender3; // 0x0019EFFC length: 4
int unitRender4; // 0x0019F000 length: 4
int unitRender5; // 0x0019F004 length: 4

private:
ViewportRenderState(ViewportRenderState const&);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "OpenSHC/Rendering/ViewportRenderState.func.hpp"

namespace OpenSHC {
namespace Rendering {

// FUNCTION: STRONGHOLDCRUSADER 0x004E1FA0
ViewportRenderState* ViewportRenderState::Constructor_ViewportRenderState()
{
this->viewportState.viewportX = 32;
this->viewportState.viewportY = 8;
this->viewportState.field4_0x10 = -1;

DWORD now = timeGetTime();
this->previousIntervalTime_02 = now;
this->previousIntervalTime_01 = now;
this->previousIntervalTime_04 = now;
this->previousIntervalTime_03 = now;

this->viewportState.isZoomedOutUnk = 0;
this->DAT_MapEditorDisplayLayer = 0;
this->unknownCounterUntil_0x20 = 0;
this->unknownCounterUntil_0x200 = 0;
this->unknownCounterUntil_0x24 = 0;
this->field55_0x18b764 = 0;
this->unknownCounterUntil_0x10 = 0;
this->viewportState.field37_0x94 = 0;

this->interval_03_160 = 160;
this->interval_04_180 = 180;
this->interval_01_80 = 80;
this->interval_02_100 = 100;
this->availableFloaterIndex = 1;

for (int i = 0; i < 45; i++) {
this->landscapeAnimationRandomTileArray[i] = 0;
}
return this;
}

}
}
30 changes: 30 additions & 0 deletions src/OpenSHC/Rendering/ViewportRenderState/assignRandomTiles.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "OpenSHC/OS.func.hpp"
#include "OpenSHC/Rendering/ViewportRenderState.func.hpp"

#include "OpenSHC/Globals/DAT_TileMapState.hpp"

namespace OpenSHC {
namespace Rendering {

// FUNCTION: STRONGHOLDCRUSADER 0x004E5B80
void ViewportRenderState::assignRandomTiles()
{
for (int i = 0; i < 45; i++) {
if (this->landscapeAnimationRandomTileArray[i] == 0) {
int randomHighBits = MACRO_CALL(OpenSHC::OS_Func::_rand)() << 0xf;
uint randomLowBits = MACRO_CALL(OpenSHC::OS_Func::_rand)();
int randomTile = (int)(randomLowBits | randomHighBits) % 80400;
if ((DAT_TileMapState::instance.LogicLayer[randomTile] & 1) != 0
&& (DAT_TileMapState::instance.MiscDisplayLayer[randomTile] & 0x3c0) == 0
&& (DAT_TileMapState::instance.Logic2Layer[randomTile] & 8) == 0) {
this->landscapeAnimationRandomTileArray[i] = randomTile;
this->landscapeSeaWhiteCapsAnimationFrames[i] = 0;
}
} else if (8 <= this->landscapeSeaWhiteCapsAnimationFrames[i]) {
this->landscapeAnimationRandomTileArray[i] = 0;
}
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "OpenSHC/Rendering/ViewportRenderState.func.hpp"

#include "OpenSHC/Globals/DAT_TileMapState.hpp"

namespace OpenSHC {
namespace Rendering {

// FUNCTION: STRONGHOLDCRUSADER 0x004E6340
void ViewportRenderState::clearAllFloatingLayerElements()
{
int floaterIndex = 1;
if (floaterIndex < this->availableFloaterIndex) {
for (; floaterIndex < this->availableFloaterIndex; floaterIndex++) {
DAT_TileMapState::instance.FloatingLayer[this->floatersArray[floaterIndex].tile] = 0;
this->floatersArray[floaterIndex].id = 0;
}
this->availableFloaterIndex = 1;
return;
}
this->availableFloaterIndex = 1;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp"
#include "OpenSHC/Map/TileMapState.func.hpp"
#include "OpenSHC/Rendering/ViewportRenderState.func.hpp"

#include "OpenSHC/Globals/DAT_BuildingsState.hpp"
#include "OpenSHC/Globals/DAT_GameState.hpp"
#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp"
#include "OpenSHC/Globals/DAT_MapRenderDefinedData.hpp"
#include "OpenSHC/Globals/DAT_TileMapState.hpp"

namespace OpenSHC {
namespace Rendering {

// FUNCTION: STRONGHOLDCRUSADER 0x004E5ED0
void ViewportRenderState::computeMouseTileFromScreenPosition(int screenX, int screenY)
{
int probeScreenY = screenY + -8;
int foundTile = 0;
int orientationBase = 8;

this->viewportState.field27_0x6c = 0;
this->viewportState.field24_0x60 = 0;
this->viewportState.mouseX = 0;
this->viewportState.mouseY = 0;
if (this->viewportState.field0_0x0 != 0) {

uint quadrantX;
if (this->viewportState.isZoomedOutUnk == 0) {
uint viewportXInTile = this->viewportState.viewportX & 0x8000001f;
if ((int)viewportXInTile < 0) {
viewportXInTile = (viewportXInTile - 1 | 0xffffffe0) + 1;
}
quadrantX = (int)((viewportXInTile - this->windowX) + screenX) >> 1 & 0xf;
} else {
uint viewportXInTile = this->viewportState.viewportX & 0x8000001f;
if ((int)viewportXInTile < 0) {
viewportXInTile = (viewportXInTile - 1 | 0xffffffe0) + 1;
}
quadrantX = (int)((viewportXInTile + screenX * 2) - this->windowX) >> 1 & 0xf;
}

uint viewportYInTile = this->viewportState.viewportY & 0x8000000f;
if ((int)viewportYInTile < 0) {
viewportYInTile = (viewportYInTile - 1 | 0xfffffff0) + 1;
}
int probeOffset = probeScreenY - screenY;
int probeDoubledY = screenY + probeScreenY;
if (DAT_TileMapState::instance.mapOrientation == 0) {
orientationBase = 8;
} else if (DAT_TileMapState::instance.mapOrientation == 6) {
orientationBase = 0x13a18;
} else if (DAT_TileMapState::instance.mapOrientation == 4) {
orientationBase = 0x27428;
} else if (DAT_TileMapState::instance.mapOrientation == 2) {
orientationBase = 0x3ae38;
}

do {
if ((DAT_TileMapState::instance.field93_0x5548c8 != 0
|| DAT_TileMapState::instance.flatViewToggleValue2 != 0)
&& probeOffset != -8) {
break;
}

int lookupIndex;
uint tileRowY;
if (this->viewportState.isZoomedOutUnk == 0) {
int unclampedY = (this->viewportState.viewportY - this->windowY) + 8 + probeScreenY;
tileRowY = (viewportYInTile - this->windowY) + -8 + probeScreenY;
int unclampedX = (screenX - this->windowX) + this->viewportState.viewportX;
lookupIndex = ((int)(unclampedX + (unclampedX >> 0x1f & 0x1fU)) >> 5)
+ ((int)(unclampedY + (unclampedY >> 0x1f & 0xfU)) >> 4) * 0x191 + orientationBase;
} else {
int unclampedX = ((screenX * 2 + 0xa0) - this->windowX) + this->viewportState.viewportX;
tileRowY = (viewportYInTile - this->windowY) + probeDoubledY;
int unclampedY = (probeDoubledY - this->windowY) + this->viewportState.viewportY;
lookupIndex = ((int)(unclampedY + (unclampedY >> 0x1f & 0xfU)) >> 4) * 0x191
+ ((int)(unclampedX + (unclampedX >> 0x1f & 0x1fU)) >> 5) + orientationBase;
}

int quadrant = DAT_MapRenderDefinedData::instance.field618_0xc24[tileRowY & 0xf][quadrantX];
if (quadrant == 1) {
lookupIndex = lookupIndex + 200;
} else if (quadrant == 2) {
lookupIndex = lookupIndex + 0xc9;
} else if (quadrant == 3) {
lookupIndex = lookupIndex + 0x191;
}

int tile = this->screenPointToTileNumber[lookupIndex + -8];
if ((DAT_TileMapState::instance.LogicLayer[tile] & 0x30U) != 0) {
break;
}

int tileHeightOffset
= DAT_TileMapState::instance.heightBasedScreenYOffset[DAT_TileMapState::instance.HeightLayer[tile]];
if ((DAT_TileMapState::instance.LogicLayer[tile] & 0x10000000U) != 0) {
tileHeightOffset = tileHeightOffset
+ MACRO_CALL_MEMBER(
OpenSHC::Map::Buildings::BuildingsState_Func::getBuildingHeightForBuildingID,
DAT_BuildingsState::ptr)((int)DAT_TileMapState::instance.BuildingLayer[tile]);
}
if (this->viewportState.isZoomedOutUnk != 0) {
tileHeightOffset = tileHeightOffset / 2;
}

if ((probeOffset - tileHeightOffset) + 8 + screenY <= screenY
|| DAT_TileMapState::instance.field93_0x5548c8 != 0
|| DAT_TileMapState::instance.flatViewToggleValue2 != 0) {
foundTile = tile;
}

probeScreenY = probeScreenY + 1;
probeDoubledY = probeDoubledY + 2;
probeOffset = probeOffset + 1;
} while (probeOffset < 0xff);

this->viewportState.field24_0x60 = foundTile;
if (DAT_TileMapState::instance.PathConnectionLayer[foundTile] == 0
|| (DAT_TileMapState::instance.LogicLayer[foundTile] & 0x200U) != 0) {
uint direction = DAT_TileMapState::instance.field84_0x5548a4 + 4U & 0x80000007;
if ((int)direction < 0) {
direction = (direction - 1 | 0xfffffff8) + 1;
}
uint tileFlags = DAT_TileMapState::instance.LogicLayer[foundTile];
int neighbourTile
= DAT_TileMapState::instance
.directionTranslationMatrix[this->tileTranslationMatrix_YComponent[foundTile]][direction]
+ foundTile;
if ((tileFlags & 0x40000000) == 0) {
if ((tileFlags & 0x200) == 0) {
if ((tileFlags & 0x400) != 0) {
switch (DAT_BuildingsState::instance
.buildings[DAT_TileMapState::instance.BuildingLayer[foundTile]]
.buildingType) {
case OpenSHC::Map::Buildings::BT_MANORHOUSE:
case OpenSHC::Map::Buildings::BT_STONEKEEP:
case OpenSHC::Map::Buildings::BT_STRONGHOLD:
case OpenSHC::Map::Buildings::BT_KEEPFOUR:
case OpenSHC::Map::Buildings::BT_KEEPFIVE:
case OpenSHC::Map::Buildings::BT_TOWER:
case OpenSHC::Map::Buildings::BT_TOWER1:
case OpenSHC::Map::Buildings::BT_TOWER2:
case OpenSHC::Map::Buildings::BT_TOWER3:
case OpenSHC::Map::Buildings::BT_TOWER4:
case OpenSHC::Map::Buildings::BT_TOWER5:
if ((DAT_TileMapState::instance.LogicLayer[neighbourTile] & 0x10000000U) != 0) {
this->viewportState.field24_0x60 = neighbourTile;
}
break;
default:
this->viewportState.field24_0x60 = 0;
break;
}
} else {
this->viewportState.field24_0x60 = 0;
}
} else if ((DAT_TileMapState::instance.LogicLayer[neighbourTile] & 0x100U) != 0) {
this->viewportState.field24_0x60 = neighbourTile;
}
}
}

if ((DAT_TileMapState::instance.LogicLayer[this->viewportState.field24_0x60] & 0x10000300U) != 0
&& (DAT_TileMapState::instance.LogicLayer[this->viewportState.field24_0x60] & 2U) == 0) {
this->viewportState.field27_0x6c = 1;
}
this->viewportState.somePitchDitchID = 0;
this->viewportState.mouseAtomRefFloorTile = foundTile;

if (this->viewportState.field24_0x60 != 0) {

this->viewportState.mouseY = this->tileTranslationMatrix_YComponent[this->viewportState.field24_0x60];
this->viewportState.mouseX
= this->viewportState.field24_0x60 - this->translationMatrix[this->viewportState.mouseY].addXgetTile;

int hoveredTile = this->viewportState.field24_0x60;
if (DAT_TileMapState::instance.flatViewToggleValue1 != 0) {
hoveredTile = this->viewportState.mouseTile;
}
this->viewportState.field14_0x38 = DAT_TileMapState::instance.LogicLayer[hoveredTile] & 0x40000000;
this->viewportState.field16_0x40 = DAT_TileMapState::instance.LogicLayer[hoveredTile] & 0x4000;

int moatID = MACRO_CALL_MEMBER(
OpenSHC::Map::TileMapState_Func::returnOwnedMoatAtTile, DAT_TileMapState::ptr)(hoveredTile);
if (moatID == 0) {
this->viewportState.field14_0x38 = 0;
this->viewportState.field16_0x40 = 0;
}
this->viewportState.field15_0x3c = this->viewportState.field14_0x38;
if (DAT_GameState::instance.mapAndTime.playerTeams[DAT_TileMapState::instance.moats[moatID].owner]
== DAT_GameState::instance.mapAndTime
.playerTeams[DAT_GameSynchronyState::instance.currentPlayerSlotID]) {
this->viewportState.field14_0x38 = 0;
} else {
this->viewportState.field16_0x40 = 0;
this->viewportState.field15_0x3c = 0;
}

if ((DAT_TileMapState::instance.LogicLayer[hoveredTile] & 8) != 0) {
this->viewportState.somePitchDitchID = MACRO_CALL_MEMBER(
OpenSHC::Map::TileMapState_Func::getPitchDitchIDForTile, DAT_TileMapState::ptr)(hoveredTile);
}
} else {
this->viewportState.mouseY = 0;
this->viewportState.mouseX = 0;
this->viewportState.field27_0x6c = 0;
this->viewportState.field14_0x38 = 0;
this->viewportState.field16_0x40 = 0;
this->viewportState.field15_0x3c = 0;
}
} else {
this->viewportState.field24_0x60 = 0;
this->viewportState.mouseX = 0;
this->viewportState.mouseY = 0;
this->viewportState.field27_0x6c = 0;
}
}

}
}
13 changes: 13 additions & 0 deletions src/OpenSHC/Rendering/ViewportRenderState/computeTileXOffset.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "OpenSHC/Rendering/ViewportRenderState.func.hpp"

namespace OpenSHC {
namespace Rendering {

// FUNCTION: STRONGHOLDCRUSADER 0x004092E0
int ViewportRenderState::computeTileXOffset(int tile, int y)
{
return tile - this->translationMatrix[y].addXgetTile;
}

}
}
Loading