diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 17882af542..abac2915b8 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -280,6 +280,11 @@ src/OpenSHC/Map/Units/UpdateMinerIronFetcher.cpp src/OpenSHC/Map/Units/UpdateWorker_ConsiderTakingABreakUnk.cpp src/OpenSHC/Map/Units/UnitsState/isWorkplaceBuildingOnAdjacentTile.cpp src/OpenSHC/Map/Units/ConsiderHavingABreakNowUnk.cpp +src/OpenSHC/Map/WildlifeState/floodFillField13FromCell.cpp +src/OpenSHC/Map/WildlifeState/floodFillField20FromCell.cpp +src/OpenSHC/Map/WildlifeState/updateWildlife.cpp +src/OpenSHC/Map/LandscapeState/getValueFrom0UpTo3ForTreeTypeAndTreeStage.cpp +src/OpenSHC/Map/LandscapeState/updateTreeStage.cpp src/OpenSHC/Map/Units/UnitsState/acquireShootTarget.cpp src/OpenSHC/Map/Units/UnitsState/calculateUnitMovementSpeed.cpp src/OpenSHC/Map/Units/UnitsState/chooseHusbandAndWife.cpp diff --git a/src/OpenSHC/Map/Enums/DebugDataMapDataDisplayType.hpp b/src/OpenSHC/Map/Enums/DebugDataMapDataDisplayType.hpp new file mode 100644 index 0000000000..f4ad240c27 --- /dev/null +++ b/src/OpenSHC/Map/Enums/DebugDataMapDataDisplayType.hpp @@ -0,0 +1,32 @@ +/** + 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/DebugDataMapDataDisplayType.hpp' +*/ + +#pragma once + +namespace OpenSHC { +namespace Map { + namespace Enums { + typedef enum DebugDataMapDataDisplayType { + + DDMDDT_CONNECT = 0, // 0x00000000 + DDMDDT_CHIMPS = 1, // 0x00000001 + DDMDDT_FARMLAND = 2, // 0x00000002 + DDMDDT_HUMANS = 3, // 0x00000003 + DDMDDT_MANKIND = 4, // 0x00000004 + DDMDDT_DEER = 5, // 0x00000005 + DDMDDT_ROUTE = 6, // 0x00000006 + DDMDDT_PANIC = 7, // 0x00000007 + DDMDDT_SIEGE = 8, // 0x00000008 + DDMDDT_SLINK = 9 // 0x00000009 + + } DebugDataMapDataDisplayType; + + static_assert_cpp98_obj(sizeof(DebugDataMapDataDisplayType) == 4, DebugDataMapDataDisplayType); + } // namespace Enums +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/Enums/DebugDataMapDataDisplayTypeInt.hpp b/src/OpenSHC/Map/Enums/DebugDataMapDataDisplayTypeInt.hpp new file mode 100644 index 0000000000..043a43cf07 --- /dev/null +++ b/src/OpenSHC/Map/Enums/DebugDataMapDataDisplayTypeInt.hpp @@ -0,0 +1,21 @@ +/** + 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/DebugDataMapDataDisplayTypeInt.hpp' +*/ + +#pragma once + +#include "OpenSHC/Map/Enums/DebugDataMapDataDisplayType.hpp" + +namespace OpenSHC { +namespace Map { + namespace Enums { + typedef int DebugDataMapDataDisplayTypeInt; + + static_assert_cpp98_obj(sizeof(DebugDataMapDataDisplayTypeInt) == 4, DebugDataMapDataDisplayTypeInt); + } // namespace Enums +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/LandscapeState.func.hpp b/src/OpenSHC/Map/LandscapeState.func.hpp index 3166d49795..103a7f1272 100644 --- a/src/OpenSHC/Map/LandscapeState.func.hpp +++ b/src/OpenSHC/Map/LandscapeState.func.hpp @@ -5,6 +5,7 @@ #include "OpenSHC/Commands/MappersEnum.hpp" #include "OpenSHC/IO/PackagedFileMagicNum.hpp" #include "OpenSHC/Map/LandscapeState.hpp" +#include "OpenSHC/Map/Rocks/Enums/RockType.hpp" #include "OpenSHC/Map/Trees/TreeType.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" namespace OpenSHC { @@ -13,6 +14,7 @@ namespace Map { using OpenSHC::Commands::MappersEnum; using OpenSHC::IO::PackagedFileMagicNum; + using OpenSHC::Map::Rocks::Enums::RockType; using OpenSHC::Map::Trees::TreeType; using OpenSHC::WindowsHelper::Enums::BOOLEnum; @@ -51,7 +53,7 @@ namespace Map { &LandscapeState::setCurrentTimeOnSomeTrees) setCurrentTimeOnSomeTrees; - MACRO_FUNCTION_RESOLVER(int (LandscapeState::*)(undefined4, undefined4, int, undefined4, undefined4), false, + MACRO_FUNCTION_RESOLVER(int (LandscapeState::*)(int, int, RockType, int, int), false, Address::SHC_3BB0A8C1_0x004F2140, &LandscapeState::createRock) createRock; diff --git a/src/OpenSHC/Map/LandscapeState.hpp b/src/OpenSHC/Map/LandscapeState.hpp index 50d40b895f..55d119ae1e 100644 --- a/src/OpenSHC/Map/LandscapeState.hpp +++ b/src/OpenSHC/Map/LandscapeState.hpp @@ -10,6 +10,7 @@ #include "OpenSHC/Commands/MappersEnum.hpp" #include "OpenSHC/IO/PackagedFileMagicNum.hpp" +#include "OpenSHC/Map/Rocks/Enums/RockType.hpp" #include "OpenSHC/Map/Rocks/Rock.hpp" #include "OpenSHC/Map/Trees/Tree.hpp" #include "OpenSHC/Map/Trees/TreeType.hpp" @@ -24,6 +25,7 @@ namespace Map { using OpenSHC::Commands::MappersEnum; using OpenSHC::IO::PackagedFileMagicNum; using OpenSHC::Map::WindState; + using OpenSHC::Map::Rocks::Enums::RockType; using OpenSHC::Map::Rocks::Rock; using OpenSHC::Map::Trees::Tree; using OpenSHC::Map::Trees::TreeType; @@ -73,7 +75,7 @@ namespace Map { void setCurrentTimeOnSomeTrees(); - int createRock(undefined4 x, undefined4 y, int rockType, undefined4 size, undefined4 orientation); + int createRock(int x, int y, RockType rockType, int size, int orientation); void removeRock(int rockID); @@ -109,7 +111,7 @@ namespace Map { void updateWind(); - void updateTreeStage(uint treeID, uint rng); + void updateTreeStage(uint treeID, uint stageSlot); int findTree(int playerID, uint unitXPosition, uint unitYPosition); diff --git a/src/OpenSHC/Map/LandscapeState/createRock.cpp b/src/OpenSHC/Map/LandscapeState/createRock.cpp new file mode 100644 index 0000000000..f22ad4c3a6 --- /dev/null +++ b/src/OpenSHC/Map/LandscapeState/createRock.cpp @@ -0,0 +1,40 @@ +#include "../LandscapeState.func.hpp" + +#include "OpenSHC/Globals/DAT_CurrentRockID.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_OrganismDefinedData.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x004F2140 + int LandscapeState::createRock(int x, int y, RockType rockType, int size, int orientation) + { + int rockID; + for (rockID = 1; rockID < countof(this->rocks); rockID++) { + if (this->rocks[rockID].one == 0) { + break; + } + if (rockID >= countof(this->rocks) - 1) { + return 0; + } + } + this->rocks[rockID].uid = DAT_GameCore::instance.uniqueGameObjectTracker; + DAT_GameCore::instance.uniqueGameObjectTracker++; + this->rocks[rockID].size = size; + this->rocks[rockID].y = y; + this->rocks[rockID].one = 1; + this->rocks[rockID].type = rockType; + this->rocks[rockID].x = x; + this->rocks[rockID].tile = this->rocks[rockID].x + + DAT_ViewportRenderState::instance.translationMatrix[this->rocks[rockID].y].addXgetTile; + this->rocks[rockID].orientation = orientation; + this->rocks[rockID].unknownGMID = DAT_OrganismDefinedData::instance.Rock_field0xe[rockType]; + DAT_CurrentRockID::instance = rockID; + DAT_OrganismDefinedData::instance.RockTypeFunctions[this->rocks[rockID].type](); + return rockID; + } + +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/LandscapeState/updateTreeStage.cpp b/src/OpenSHC/Map/LandscapeState/updateTreeStage.cpp new file mode 100644 index 0000000000..265a139cf4 --- /dev/null +++ b/src/OpenSHC/Map/LandscapeState/updateTreeStage.cpp @@ -0,0 +1,106 @@ +#include "../LandscapeState.func.hpp" + +#include "OpenSHC/Map/Navigation/PathFindingState.func.hpp" +#include "OpenSHC/Map/TileMapState.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Map/LogicHelpers/Logic1.hpp" +#include "OpenSHC/Map/Trees/TreeStateEnum.hpp" +#include "OpenSHC/Map/Trees/TreeType.hpp" +#include "OpenSHC/Map/Trees/TreeTypeShort.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_LandscapeState.hpp" +#include "OpenSHC/Globals/DAT_OrganismDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PathFindingState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x004F3960 + void LandscapeState::updateTreeStage(uint treeID, uint stageSlot) + { + if (DAT_GameSynchronyState::instance.currentGameMode == Game::GM_SOLITARY) { + if (DAT_GameCore::instance.isTimeHalted) { + return; + } + if (MACRO_CALL(UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO)) { + return; + } + } + // updateTrees draws one random slot (0 to 63) every eighth tick; a tree only advances in its own slot + if ((this->trees[treeID].rng1 & 0x3fU) != stageSlot) { + return; + } + int const treeType = this->trees[treeID].treeType; + // the shrubs and the apple tree do not advance their stage here + if (treeType >= Trees::TT_SHRUB_NEEDLE_PALM_A && treeType <= Trees::TT_SHRUB_PRICKLYPEAR) { + return; + } + if (this->trees[treeID].zeroUpTo2 != 0) { + return; + } + if (this->trees[treeID].stageRelated1 < this->trees[treeID].stageRelated2) { + return; + } + if (!this->field_0x4) { + return; + } + if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_MAP_EDITOR_LANDSCAPING) { + return; + } + this->trees[treeID].stageTracker++; + if (this->trees[treeID].stageTracker + < DAT_OrganismDefinedData::instance.TreeStageLevels[treeType][this->trees[treeID].stage + 1]) { + return; + } + this->trees[treeID].stage++; + MACRO_CALL_MEMBER(Map::LandscapeState_Func::setTreeStageRelatedValues, this)(treeID, this->trees[treeID].stage); + if (this->trees[treeID].stage >= 6) { + this->trees[treeID].state = Trees::TSE_TO_BE_REMOVED; + return; + } + if (this->trees[treeID].stage < 4) { + return; + } + DAT_GameState::instance.mapAndTime.treeSpreadCounter++; + if (DAT_GameState::instance.mapAndTime.treeSpreadCounter + > DAT_GameState::instance.mapAndTime.treeSpreadInterval) { + DAT_GameState::instance.mapAndTime.treeSpreadCounter = 0; + this->trees[treeID].stage = 5; + this->trees[treeID].stageTracker + = DAT_OrganismDefinedData::instance.TreeStageLevels[this->trees[treeID].treeType][5]; + return; + } + // set the spread counter to the lowest value for the tree type + this->trees[treeID].stageTracker + = DAT_OrganismDefinedData::instance.TreeStageLevels[this->trees[treeID].treeType][3]; + this->trees[treeID].stage = 3; + DAT_GameState::instance.mapAndTime.newOrganismsValue2++; + if (!MACRO_CALL_MEMBER(Map::LandscapeState_Func::setupBabyTreeLocation, this)( + treeID, this->trees[treeID].treeType, this->trees[treeID].xPosition, this->trees[treeID].yPosition)) { + return; + } + int const size = MACRO_CALL_MEMBER(Map::LandscapeState_Func::getValueFrom0UpTo3ForTreeTypeAndTreeStage, + DAT_LandscapeState::ptr)(this->trees[treeID].treeType, 0); + int const newTreeID = MACRO_CALL_MEMBER(Map::LandscapeState_Func::createTree, DAT_LandscapeState::ptr)( + DAT_PathFindingState::instance.ALG_ResultX, DAT_PathFindingState::instance.ALG_ResultY, + (TreeType)this->trees[treeID].treeType, size, 0, 0, 0); + DAT_TileMapState::instance.LogicLayer[DAT_PathFindingState::instance.ALG_ResultTile] |= LogicHelpers::L_TREE; + DAT_TileMapState::instance.OrganismLayer[DAT_PathFindingState::instance.ALG_ResultTile] = newTreeID; + MACRO_CALL_MEMBER(Map::TileMapState_Func::applyTreeBrushToLogicalLayer, DAT_TileMapState::ptr)(newTreeID, 0); + MACRO_CALL_MEMBER(Map::Navigation::PathFindingState_Func::updatePathLinkagesInAllEightDirections, + DAT_PathFindingState::ptr)(this->trees[newTreeID].yPosition, this->trees[newTreeID].tile); + DAT_GameState::instance.mapAndTime.newOrganisms++; + DAT_PathFindingState::instance.toggleUpdateSeparateAreaTileMap = TRUE; + } + +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/Trees/Tree.hpp b/src/OpenSHC/Map/Trees/Tree.hpp index ab58fbd1b1..f6f58f8773 100644 --- a/src/OpenSHC/Map/Trees/Tree.hpp +++ b/src/OpenSHC/Map/Trees/Tree.hpp @@ -54,7 +54,7 @@ namespace Map { short param_6; // 0x0000006E length: 2 undefined1 padding_0x70[2]; // 0x00000070 length: 2 short stageRelated1; // 0x00000072 length: 2 - undefined2 stageRelated2; // 0x00000074 length: 2 + short stageRelated2; // 0x00000074 length: 2 short zeroUpTo2; // 0x00000076 length: 2 short treeAdultHoodStageRelatedVisual3; // 0x00000078 length: 2 undefined2 stageRelated4; // 0x0000007A length: 2 diff --git a/src/OpenSHC/Map/WildlifeState.hpp b/src/OpenSHC/Map/WildlifeState.hpp index 2d2c1d06d2..7afeef92a9 100644 --- a/src/OpenSHC/Map/WildlifeState.hpp +++ b/src/OpenSHC/Map/WildlifeState.hpp @@ -8,12 +8,14 @@ #pragma once +#include "OpenSHC/Map/Enums/DebugDataMapDataDisplayTypeInt.hpp" #include "OpenSHC/Map/Wildlife/WildlifeGridElement.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" namespace OpenSHC { namespace Map { + using OpenSHC::Map::Enums::DebugDataMapDataDisplayTypeInt; using OpenSHC::Map::Wildlife::WildlifeGridElement; using OpenSHC::WindowsHelper::Enums::BOOLEnum; @@ -23,7 +25,7 @@ namespace Map { class WildlifeState { public: WildlifeGridElement grid[40][40]; // 0x00000000 length: 256000 - int DAT_DebugDataMapDataDisplayType; // 0x0003E800 length: 4 + DebugDataMapDataDisplayTypeInt DAT_DebugDataMapDataDisplayType; // 0x0003E800 length: 4 int casDisRelated; // 0x0003E804 length: 4 int candidateIndex; // 0x0003E808 length: 4 int candidateIndex2; // 0x0003E80C length: 4 diff --git a/src/OpenSHC/Map/WildlifeState/floodFillCasDisFromSignpost.cpp b/src/OpenSHC/Map/WildlifeState/floodFillCasDisFromSignpost.cpp new file mode 100644 index 0000000000..b2f24dd2ee --- /dev/null +++ b/src/OpenSHC/Map/WildlifeState/floodFillCasDisFromSignpost.cpp @@ -0,0 +1,76 @@ +#include "../WildlifeState.func.hpp" + +#include "OpenSHC/Map/MapConstants.hpp" + +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_TerrainDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TroopValueState.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x0052D9D0 + void WildlifeState::floodFillCasDisFromSignpost() + { + int const x = DAT_GameState::instance.mapAndTime + .signpostEntryData[DAT_TroopValueState::instance.attackInfo.field_0x469d4] + .x + / MC_MAP_SECTOR_SIZE; + int const y = DAT_GameState::instance.mapAndTime + .signpostEntryData[DAT_TroopValueState::instance.attackInfo.field_0x469d4] + .y + / MC_MAP_SECTOR_SIZE; + this->casDisRelated = 1; + this->candidateIndex = 0; + this->candidateIndex2 = 1; + for (int row = 0; row < countof(this->grid[0]); row++) { + for (int column = 0; column < countof(this->grid); column++) { + this->grid[column][row].casDisRelated2 = 0; + this->grid[column][row].field_0x74 = 0; + } + } + this->DAT_Y10_Array_Section1034[0] = (short)y; + this->DAT_X10_Array_Section1034[0] = (short)x; + int const areaID = this->grid[x][y].separateAreaID; + this->grid[x][y].casDisRelated2 = 1; + for (; this->candidateIndex != this->candidateIndex2;) { + int const candidateX = this->DAT_X10_Array_Section1034[this->candidateIndex]; + int const candidateY = this->DAT_Y10_Array_Section1034[this->candidateIndex]; + this->casDisRelated = this->grid[candidateX][candidateY].casDisRelated2; + if (this->casDisRelated >= 100) { + break; + } + int const level = this->casDisRelated + 1; + for (int direction = 0; + direction < countof(DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix); direction++) { + uint const neighbourX + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.xOffset + + candidateX; + uint const neighbourY + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.yOffset + + candidateY; + if (neighbourX > countof(this->grid) - 1 || neighbourY > countof(this->grid[0]) - 1 + || this->grid[neighbourX][neighbourY].firstMember <= 0 + || areaID != this->grid[neighbourX][neighbourY].separateAreaID + || this->grid[neighbourX][neighbourY].unknownNonZero01 != 0 + || this->grid[neighbourX][neighbourY].casDisRelated2 != 0) { + continue; + } + this->grid[neighbourX][neighbourY].casDisRelated2 = level; + this->grid[neighbourX][neighbourY].field_0x74++; + this->DAT_X10_Array_Section1034[this->candidateIndex2] = neighbourX; + this->DAT_Y10_Array_Section1034[this->candidateIndex2] = neighbourY; + this->candidateIndex2++; + if (this->candidateIndex2 >= countof(this->DAT_X10_Array_Section1034)) { + this->candidateIndex2 = 0; + } + } + this->candidateIndex++; + if (this->candidateIndex >= countof(this->DAT_X10_Array_Section1034)) { + this->candidateIndex = 0; + } + } + } + +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/WildlifeState/floodFillField13FromCell.cpp b/src/OpenSHC/Map/WildlifeState/floodFillField13FromCell.cpp new file mode 100644 index 0000000000..8e95777754 --- /dev/null +++ b/src/OpenSHC/Map/WildlifeState/floodFillField13FromCell.cpp @@ -0,0 +1,54 @@ +#include "../WildlifeState.func.hpp" + +#include "OpenSHC/Globals/DAT_TerrainDefinedData.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x0052C570 + void WildlifeState::floodFillField13FromCell(int cellX, int cellY, int strength) + { + this->candidateIndex2 = 1; + this->casDisRelated = 1; + this->DAT_X10_Array_Section1034[0] = cellX; + this->DAT_Y10_Array_Section1034[0] = cellY; + this->candidateIndex = 0; + this->grid[cellX][cellY].field_0x34 = strength; + for (; this->candidateIndex != this->candidateIndex2;) { + cellX = this->DAT_X10_Array_Section1034[this->candidateIndex]; + cellY = this->DAT_Y10_Array_Section1034[this->candidateIndex]; + this->casDisRelated = this->grid[cellX][cellY].field_0x34; + if (this->casDisRelated <= 1) { + break; + } + int const level = this->casDisRelated - 1; + for (int direction = 0; + direction < countof(DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix); direction++) { + uint const neighbourX + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.xOffset + + cellX; + uint const neighbourY + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.yOffset + + cellY; + if (neighbourX > countof(this->grid) - 1 || neighbourY > countof(this->grid[0]) - 1 + || this->grid[neighbourX][neighbourY].firstMember <= 0 + || this->grid[neighbourX][neighbourY].field_0x34 >= level) { + continue; + } + this->grid[neighbourX][neighbourY].field_0x34 = level; + this->DAT_X10_Array_Section1034[this->candidateIndex2] = neighbourX; + this->DAT_Y10_Array_Section1034[this->candidateIndex2] = neighbourY; + this->candidateIndex2++; + if (this->candidateIndex2 >= countof(this->DAT_X10_Array_Section1034)) { + this->candidateIndex2 = 0; + } + } + this->candidateIndex++; + if (this->candidateIndex >= countof(this->DAT_X10_Array_Section1034)) { + this->candidateIndex = 0; + } + } + } + +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/WildlifeState/floodFillField20FromCell.cpp b/src/OpenSHC/Map/WildlifeState/floodFillField20FromCell.cpp new file mode 100644 index 0000000000..196661ccf6 --- /dev/null +++ b/src/OpenSHC/Map/WildlifeState/floodFillField20FromCell.cpp @@ -0,0 +1,54 @@ +#include "../WildlifeState.func.hpp" + +#include "OpenSHC/Globals/DAT_TerrainDefinedData.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x0052C810 + void WildlifeState::floodFillField20FromCell(int cellX, int cellY, int strength) + { + this->candidateIndex2 = 1; + this->casDisRelated = 1; + this->DAT_X10_Array_Section1034[0] = cellX; + this->DAT_Y10_Array_Section1034[0] = cellY; + this->candidateIndex = 0; + this->grid[cellX][cellY].field_0x50 = strength; + for (; this->candidateIndex != this->candidateIndex2;) { + cellX = this->DAT_X10_Array_Section1034[this->candidateIndex]; + cellY = this->DAT_Y10_Array_Section1034[this->candidateIndex]; + this->casDisRelated = this->grid[cellX][cellY].field_0x50; + if (this->casDisRelated <= 1) { + break; + } + int const level = this->casDisRelated - 1; + for (int direction = 0; + direction < countof(DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix); direction++) { + uint const neighbourX + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.xOffset + + cellX; + uint const neighbourY + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.yOffset + + cellY; + if (neighbourX > countof(this->grid) - 1 || neighbourY > countof(this->grid[0]) - 1 + || this->grid[neighbourX][neighbourY].firstMember <= 0 + || this->grid[neighbourX][neighbourY].field_0x50 >= level) { + continue; + } + this->grid[neighbourX][neighbourY].field_0x50 = level; + this->DAT_X10_Array_Section1034[this->candidateIndex2] = neighbourX; + this->DAT_Y10_Array_Section1034[this->candidateIndex2] = neighbourY; + this->candidateIndex2++; + if (this->candidateIndex2 >= countof(this->DAT_X10_Array_Section1034)) { + this->candidateIndex2 = 0; + } + } + this->candidateIndex++; + if (this->candidateIndex >= countof(this->DAT_X10_Array_Section1034)) { + this->candidateIndex = 0; + } + } + } + +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/WildlifeState/floodFillZoneProximityFromCell.cpp b/src/OpenSHC/Map/WildlifeState/floodFillZoneProximityFromCell.cpp new file mode 100644 index 0000000000..145e7b800c --- /dev/null +++ b/src/OpenSHC/Map/WildlifeState/floodFillZoneProximityFromCell.cpp @@ -0,0 +1,55 @@ +#include "../WildlifeState.func.hpp" + +#include "OpenSHC/Globals/DAT_TerrainDefinedData.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x0052D720 + void WildlifeState::floodFillZoneProximityFromCell(int cellX, int cellY, int strength) + { + this->candidateIndex2 = 1; + this->casDisRelated = 1; + this->DAT_X10_Array_Section1034[0] = cellX; + this->DAT_Y10_Array_Section1034[0] = cellY; + this->candidateIndex = 0; + this->grid[cellX][cellY].unknownNonZero01 = strength; + for (; this->candidateIndex != this->candidateIndex2;) { + cellX = this->DAT_X10_Array_Section1034[this->candidateIndex]; + cellY = this->DAT_Y10_Array_Section1034[this->candidateIndex]; + this->casDisRelated = this->grid[cellX][cellY].unknownNonZero01; + if (this->casDisRelated <= 1) { + break; + } + int const level = this->casDisRelated - 1; + for (int direction = 0; + direction < countof(DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix); direction++) { + uint const neighbourX + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.xOffset + + cellX; + uint const neighbourY + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.yOffset + + cellY; + if (neighbourX > countof(this->grid) - 1 || neighbourY > countof(this->grid[0]) - 1 + || this->grid[neighbourX][neighbourY].firstMember <= 0 + || this->grid[neighbourX][neighbourY].unclaimedArea > 10 + || this->grid[neighbourX][neighbourY].unknownNonZero01 >= level) { + continue; + } + this->grid[neighbourX][neighbourY].unknownNonZero01 = level; + this->DAT_X10_Array_Section1034[this->candidateIndex2] = neighbourX; + this->DAT_Y10_Array_Section1034[this->candidateIndex2] = neighbourY; + this->candidateIndex2++; + if (this->candidateIndex2 >= countof(this->DAT_X10_Array_Section1034)) { + this->candidateIndex2 = 0; + } + } + this->candidateIndex++; + if (this->candidateIndex >= countof(this->DAT_X10_Array_Section1034)) { + this->candidateIndex = 0; + } + } + } + +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/WildlifeState/hasAdjacentCellWithField24Or25.cpp b/src/OpenSHC/Map/WildlifeState/hasAdjacentCellWithField24Or25.cpp new file mode 100644 index 0000000000..46982d2f70 --- /dev/null +++ b/src/OpenSHC/Map/WildlifeState/hasAdjacentCellWithField24Or25.cpp @@ -0,0 +1,27 @@ +#include "../WildlifeState.func.hpp" + +#include "OpenSHC/Globals/DAT_TerrainDefinedData.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x0052D620 + BOOLEnum WildlifeState::hasAdjacentCellWithField24Or25(int cellX, int cellY) + { + // the four cardinal directions + for (int direction = 0; + direction < countof(DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix); direction += 2) { + uint const x + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.xOffset + cellX; + uint const y + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.yOffset + cellY; + if (x <= countof(this->grid) - 1 && y <= countof(this->grid[0]) - 1 && this->grid[x][y].firstMember > 0 + && (this->grid[x][y].field_0x60 != 0 || this->grid[x][y].field_0x64 != 0)) { + return TRUE; + } + } + return FALSE; + } + +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/WildlifeState/isAttackStagingCandidateCell.cpp b/src/OpenSHC/Map/WildlifeState/isAttackStagingCandidateCell.cpp new file mode 100644 index 0000000000..9cd46a1bc0 --- /dev/null +++ b/src/OpenSHC/Map/WildlifeState/isAttackStagingCandidateCell.cpp @@ -0,0 +1,36 @@ +#include "../WildlifeState.func.hpp" + +#include "OpenSHC/Globals/DAT_TerrainDefinedData.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x0052D690 + BOOLEnum WildlifeState::isAttackStagingCandidateCell(int cellX, int cellY) + { + if (this->grid[cellX][cellY].unclaimedArea > 8) { + return FALSE; + } + if (this->grid[cellX][cellY].trees > 4) { + return FALSE; + } + if (this->grid[cellX][cellY].firstMember < 50) { + return FALSE; + } + // the four cardinal directions + for (int direction = 0; + direction < countof(DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix); direction += 2) { + uint const x + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.xOffset + cellX; + uint const y + = DAT_TerrainDefinedData::instance.clockwiseCardinalTranslationMatrix[direction].int_.yOffset + cellY; + if (x <= countof(this->grid) - 1 && y <= countof(this->grid[0]) - 1 && this->grid[x][y].firstMember > 0 + && this->grid[x][y].unknownNonZero01 != 0) { + return TRUE; + } + } + return FALSE; + } + +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/WildlifeState/renderDebugDataMapData.cpp b/src/OpenSHC/Map/WildlifeState/renderDebugDataMapData.cpp new file mode 100644 index 0000000000..31fbdb4b0c --- /dev/null +++ b/src/OpenSHC/Map/WildlifeState/renderDebugDataMapData.cpp @@ -0,0 +1,331 @@ +#include "../WildlifeState.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Map/Enums/DebugDataMapDataDisplayType.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/COL_BLUE.hpp" +#include "OpenSHC/Globals/COL_BRIGHT_YELLOW.hpp" +#include "OpenSHC/Globals/COL_DARK_CYAN_GREY.hpp" +#include "OpenSHC/Globals/COL_DARK_GREEN.hpp" +#include "OpenSHC/Globals/COL_LIME.hpp" +#include "OpenSHC/Globals/COL_MODERATE_GREEN.hpp" +#include "OpenSHC/Globals/COL_RED.hpp" +#include "OpenSHC/Globals/COL_VERY_DARK_GREY.hpp" +#include "OpenSHC/Globals/COL_VIVID_BLUE.hpp" +#include "OpenSHC/Globals/COL_WHITE.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x0052BF40 + void WildlifeState::renderDebugDataMapData(int x, int y, int width, int height) + { + int const x1 = x + 2; + if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_CONNECT) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Connect_005abbcc, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_CHIMPS) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Chimps_005abbc0, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_FARMLAND) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Farmland_005abbb4, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_HUMANS) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Humans_005abba8, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_MANKIND) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Mankind_005abb9c, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_DEER) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Deer_005abb94, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_ROUTE) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Route_005abb8c, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_PANIC) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Panic_005abb84, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_SIEGE) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Siege_005abb7c, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_SLINK) { + MACRO_CALL_MEMBER(Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_Slink_005abb74, x1 + 420, y + 4, Text::TTA_LEFT, 0xffffff, 17, FALSE, 0); + } + // render the squares + for (int line = 0; line < countof(this->grid) + 1; line++) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x1, y + line * 10, x1 + 400, y + line * 10, COL_WHITE::instance.shortValue); + } + for (int line = 0; line < countof(this->grid) + 1; line++) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawLine, DAT_PencilRenderCore::ptr)( + x1 + line * 10, y, x1 + line * 10, y + 400, COL_WHITE::instance.shortValue); + } + for (int row = 0; row < countof(this->grid[0]); row++) { + for (int column = 0; column < countof(this->grid); column++) { + if (this->grid[column][row].firstMember <= 0) { + continue; + } + if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_CONNECT) { + int const areaColour = this->grid[column][row].separateAreaID & 7; + if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else if (areaColour == 1) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else if (areaColour == 2) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BRIGHT_YELLOW::instance.shortValue); + } else if (areaColour == 3) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_MODERATE_GREEN::instance.shortValue); + } else if (areaColour == 4) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_WHITE::instance.shortValue); + } else if (areaColour == 5) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_DARK_CYAN_GREY::instance.shortValue); + } else if (areaColour == 6) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } else if (areaColour == 7) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_VIVID_BLUE::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_VERY_DARK_GREY::instance.shortValue); + } + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_CHIMPS) { + if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else if (this->grid[column][row].chimps) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_FARMLAND) { + if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else if (this->grid[column][row].farmFieldTiles) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_DARK_GREEN::instance.shortValue); + } else if (this->grid[column][row].rabbitCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else if (this->grid[column][row].field_0x3c) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_WHITE::instance.shortValue); + } else if (this->grid[column][row].field_0x50) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_DARK_CYAN_GREY::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_HUMANS) { + if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else if (this->grid[column][row].unstalkedUnitCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_MANKIND) { + if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else if (this->grid[column][row].unstalkedUnitCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else if (this->grid[column][row].buildingTiles) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else if (this->grid[column][row].field_0x34) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BRIGHT_YELLOW::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_DEER) { + if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else if (this->grid[column][row].unstalkedUnitCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else if (this->grid[column][row].buildingTiles) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else if (this->grid[column][row].lionCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLACK::instance.shortValue); + } else if (this->grid[column][row].camelCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLACK::instance.shortValue); + } else if (this->grid[column][row].deerCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_MODERATE_GREEN::instance.shortValue); + } else if (this->grid[column][row].field_0x34) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BRIGHT_YELLOW::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_ROUTE) { + if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else if (this->grid[column][row].deerCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else if (this->grid[column][row].lionCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_VIVID_BLUE::instance.shortValue); + } else if (this->grid[column][row].field_0x3c) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_WHITE::instance.shortValue); + } else if (this->grid[column][row].casDisRelated2) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BRIGHT_YELLOW::instance.shortValue); + } else if (this->grid[column][row].field_0x34) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLACK::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_PANIC) { + if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else if (this->grid[column][row].field_0x48) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_WHITE::instance.shortValue); + } else if (this->grid[column][row].deerCount) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else if (this->grid[column][row].field_0x34) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLACK::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_SIEGE) { + if (this->grid[column][row].field_0x60) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_WHITE::instance.shortValue); + } else if (this->grid[column][row].field_0x64) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLACK::instance.shortValue); + } else if (this->grid[column][row].castlebuildings) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BRIGHT_YELLOW::instance.shortValue); + } else if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else if (this->grid[column][row].unknownNonZero01) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_VIVID_BLUE::instance.shortValue); + } else if (this->grid[column][row].field_0x6c) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } + } else if (this->DAT_DebugDataMapDataDisplayType == Enums::DDMDDT_SLINK) { + if (this->grid[column][row].field_0x74) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_RED::instance.shortValue); + } else if (this->grid[column][row].unknownNonZero01) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_VIVID_BLUE::instance.shortValue); + } else if (!this->grid[column][row].separateAreaID) { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_BLUE::instance.shortValue); + } else { + MACRO_CALL_MEMBER(UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(x1 + column * 10 + 1, y + row * 10 + 1, x1 + column * 10 + 9, + y + row * 10 + 9, COL_LIME::instance.shortValue); + } + } + } + } + } + +} // namespace Map +} // namespace OpenSHC diff --git a/src/OpenSHC/Map/WildlifeState/updateWildlife.cpp b/src/OpenSHC/Map/WildlifeState/updateWildlife.cpp new file mode 100644 index 0000000000..737bd5241e --- /dev/null +++ b/src/OpenSHC/Map/WildlifeState/updateWildlife.cpp @@ -0,0 +1,50 @@ +#include "../WildlifeState.func.hpp" + +#include "OpenSHC/Game/GameMode.hpp" + +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x0052DF30 + void WildlifeState::updateWildlife() + { + if (DAT_GameSynchronyState::instance.currentGameMode != Game::GM_SOLITARY) { + return; + } + for (int y = 0; y < countof(this->grid[0]); y++) { + for (int x = 0; x < countof(this->grid); x++) { + this->grid[x][y].field_0x34 = 0; + this->grid[x][y].field_0x50 = 0; + this->grid[x][y].field_0x60 = 0; + this->grid[x][y].field_0x64 = 0; + this->grid[x][y].field_0x70 /= 100; + if (this->grid[x][y].chimps) { + if (this->grid[x][y].keeps) { + this->grid[x][y].field_0x60 = 1; + } + if (this->grid[x][y].castlebuildings) { + this->grid[x][y].field_0x60++; + } + } + } + } + for (int y = 0; y < countof(this->grid[0]); y++) { + for (int x = 0; x < countof(this->grid); x++) { + if (this->grid[x][y].unstalkedUnitCount) { + MACRO_CALL_MEMBER(Map::WildlifeState_Func::floodFillField13FromCell, this)(x, y, 2); + } else if (this->grid[x][y].buildingTiles) { + MACRO_CALL_MEMBER(Map::WildlifeState_Func::floodFillField13FromCell, this)(x, y, 2); + } else if (this->grid[x][y].lionCount) { + MACRO_CALL_MEMBER(Map::WildlifeState_Func::floodFillField13FromCell, this)(x, y, 3); + } + if (this->grid[x][y].farmFieldTiles) { + MACRO_CALL_MEMBER(Map::WildlifeState_Func::floodFillField20FromCell, this)(x, y, 6); + } + } + } + } + +} // namespace Map +} // namespace OpenSHC diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 47b2ecfdf6..09d3f2b9c5 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -38383,7 +38383,7 @@ SHC_3BB0A8C1_0x004F2070 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004F20E0 | 0.0% | Pending -SHC_3BB0A8C1_0x004F2140 | 0.0% | Pending +SHC_3BB0A8C1_0x004F2140 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004F2220 | 100.0% | Reimplemented @@ -38593,7 +38593,7 @@ SHC_3BB0A8C1_0x004F3900 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004F3930 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004F3960 | 0.0% | Pending +SHC_3BB0A8C1_0x004F3960 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004F3B90 | 100.0% | Pending @@ -49241,13 +49241,13 @@ SHC_3BB0A8C1_0x0052BB40 | 0.0% | Pending SHC_3BB0A8C1_0x0052BEA0 | 0.0% | Pending -SHC_3BB0A8C1_0x0052BF40 | 0.0% | Pending +SHC_3BB0A8C1_0x0052BF40 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0052C570 | 0.0% | Pending +SHC_3BB0A8C1_0x0052C570 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0052C5D0 | 0.0% | Pending -SHC_3BB0A8C1_0x0052C810 | 0.0% | Pending +SHC_3BB0A8C1_0x0052C810 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0052C870 | 0.0% | Pending @@ -49269,15 +49269,15 @@ SHC_3BB0A8C1_0x0052D100 | 0.0% | Pending SHC_3BB0A8C1_0x0052D3C0 | 0.0% | Pending -SHC_3BB0A8C1_0x0052D620 | 0.0% | Pending +SHC_3BB0A8C1_0x0052D620 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0052D690 | 0.0% | Pending +SHC_3BB0A8C1_0x0052D690 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0052D720 | 0.0% | Pending +SHC_3BB0A8C1_0x0052D720 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0052D780 | 0.0% | Pending -SHC_3BB0A8C1_0x0052D9D0 | 0.0% | Pending +SHC_3BB0A8C1_0x0052D9D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0052DA40 | 0.0% | Pending @@ -49291,7 +49291,7 @@ SHC_3BB0A8C1_0x0052DDF0 | 0.0% | Pending SHC_3BB0A8C1_0x0052DF10 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0052DF30 | 0.0% | Pending +SHC_3BB0A8C1_0x0052DF30 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0052DF50 | 0.0% | Pending