Skip to content
27 changes: 27 additions & 0 deletions src/OpenSHC/Map/Enums/WallCornerType.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
THIS FILE IS AUTO GENERATED
Communicate changes to the dev team (e.g. via a Pull Request).
Changes get lost otherwise.

path: 'OpenSHC/Map/Enums/WallCornerType.hpp'
*/

#pragma once

namespace OpenSHC {
namespace Map {
namespace Enums {
typedef enum WallCornerType {

WCT_NONE = 0, // 0x00000000
WCT_SOUTHEAST = 1, // 0x00000001
WCT_SOUTHWEST = 2, // 0x00000002
WCT_NORTHWEST = 3, // 0x00000003
WCT_NORTHEAST = 4 // 0x00000004

} WallCornerType;

static_assert_cpp98_obj(sizeof(WallCornerType) == 4, WallCornerType);
} // namespace Enums
} // namespace Map
} // namespace OpenSHC
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include "../TileMapState.func.hpp"

#include "OpenSHC/Map/Enums/CardinalDirection.hpp"
#include "OpenSHC/Map/LogicHelpers/MiscDisplay.hpp"
#include "OpenSHC/Map/LogicHelpers/WallOwner.hpp"

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

namespace OpenSHC {
namespace Map {

using OpenSHC::Map::Enums::CD_EAST;
using OpenSHC::Map::Enums::CD_NORTH;
using OpenSHC::Map::Enums::CD_SOUTH;
using OpenSHC::Map::Enums::CD_WEST;
using OpenSHC::Map::LogicHelpers::L_WALL_OR_GATEHOUSE;
using OpenSHC::Map::LogicHelpers::MD_DECORATION_ENTITY;
using OpenSHC::Map::LogicHelpers::WO_OWNER_MASK;

namespace {
struct GatehouseTotalHeight : TileMapState {
__declspec(noinline) int getTotalHeightAtTile(int tile)
{
return MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::getTotalHeightAtTile, this)(tile);
}
};
}

// FUNCTION: STRONGHOLDCRUSADER 0x004FFF10
uint TileMapState::getHeightAtTileIncludingOwnersBuildings(int tile, int playerID)
{
if (!DAT_TileMapState::instance.PathConnectionLayer[tile]) {
return 0;
}
if (DAT_TileMapState::instance.MiscDisplayLayer[tile] & MD_DECORATION_ENTITY) {
return 0;
}

if (DAT_TileMapState::instance.LogicLayer[tile] & L_WALL_OR_GATEHOUSE) {
if (playerID && (this->WallOwnerLayer[tile] & WO_OWNER_MASK) + 1 != playerID) {
return 0;
}
return DAT_TileMapState::instance.HeightLayer[tile];
}

if (!DAT_TileMapState::instance.BuildingLayer[tile]) {
return 0;
}
int const building = DAT_TileMapState::instance.BuildingLayer[tile];
if (playerID && DAT_BuildingsState::instance.buildings[building].owner != playerID) {
return 0;
}

switch (DAT_BuildingsState::instance.buildings[building].buildingType) {
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_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: {
int const tileY = DAT_ViewportRenderState::instance.tileTranslationMatrix_YComponent[tile];
for (int direction = 0; direction < countof(DAT_TileMapState::instance.directionTranslationMatrix[tileY]);
direction++) {
if (this->BuildingLayer[DAT_TileMapState::instance.directionTranslationMatrix[tileY][direction] + tile]
!= building) {
return 0;
}
}
return MACRO_CALL_MEMBER(OpenSHC::Map::TileMapState_Func::getTotalHeightAtTile, this)(tile);
}
case OpenSHC::Map::Buildings::BT_GATEHOUSELARGE:
case OpenSHC::Map::Buildings::BT_GATEHOUSESMALL: {
int firstDirection;
int secondDirection;
if (DAT_BuildingsState::instance.buildings[building].buildingVariation == 80) {
firstDirection = CD_EAST;
secondDirection = CD_WEST;
} else {
firstDirection = CD_NORTH;
secondDirection = CD_SOUTH;
}
int const tileY = DAT_ViewportRenderState::instance.tileTranslationMatrix_YComponent[tile];
if (this->BuildingLayer[DAT_TileMapState::instance.directionTranslationMatrix[tileY][firstDirection] + tile]
!= building) {
return 0;
}
if (this->BuildingLayer[DAT_TileMapState::instance.directionTranslationMatrix[tileY][secondDirection]
+ tile]
!= building) {
return 0;
}
return static_cast<GatehouseTotalHeight*>(this)->getTotalHeightAtTile(tile);
}
default:
return 0;
}
}

}
}
Loading
Loading