Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 202 additions and 190 deletions.
  1. +2 −2 src/Ares.version.h
  2. +200 −188 src/Ext/Building/Hooks.Foundation.cpp
View
4 src/Ares.version.h
@@ -5,8 +5,8 @@
//#define IS_RELEASE_VER
#define VERSION_MAJOR 12
-#define VERSION_MINOR 165
-#define VERSION_REVISION 880
+#define VERSION_MINOR 169
+#define VERSION_REVISION 660
#define SAVEGAME_MAGIC ((VERSION_MAJOR << 24) | (VERSION_MINOR << 16) | (VERSION_REVISION))
View
388 src/Ext/Building/Hooks.Foundation.cpp
@@ -1,188 +1,200 @@
-#include "Body.h"
-#include "../BuildingType/Body.h"
-
-#include <algorithm>
-#include <vector>
-
-CellStruct * BuildingExt::TempFoundationData1 = NULL;
-CellStruct * BuildingExt::TempFoundationData2 = NULL;
-
-DEFINE_HOOK(45EC90, Foundations_GetFoundationWidth, 6)
-{
- GET(BuildingTypeClass*, pThis, ECX);
- BuildingTypeExt::ExtData* pData = BuildingTypeExt::ExtMap.Find(pThis);
-
- if(pData->IsCustom) {
- R->EAX(pData->CustomWidth);
- return 0x45EC9D;
- }
-
- return 0;
-}
-
-DEFINE_HOOK(45ECA0, Foundations_GetFoundationHeight, 6)
-{
- GET(BuildingTypeClass*, pThis, ECX);
- BuildingTypeExt::ExtData* pData = BuildingTypeExt::ExtMap.Find(pThis);
-
- if(pData->IsCustom) {
- bool bIncludeBib = (R->Stack8(0x4) != 0);
-
- int fH = pData->CustomHeight;
- if(bIncludeBib && pThis->Bib) {
- ++fH;
- }
-
- R->EAX(fH);
- return 0x45ECDA;
- }
-
- return 0;
-}
-
-DEFINE_HOOK(568411, MapClass_AddContentAt_Foundation_P1, 0)
-{
- GET(BuildingClass *, pThis, EDI);
-
- R->EBP<CellStruct *>(pThis->GetFoundationData(false));
-
- return 0x568432;
-}
-
-DEFINE_HOOK(568565, MapClass_AddContentAt_Foundation_OccupyHeight, 5)
-{
- GET(BuildingClass *, pThis, EDI);
- GET(int, ShadowHeight, EBP);
- GET_STACK(CellStruct *, MainCoords, 0x8B4);
-
- CellStruct * Foundation = pThis->GetFoundationData(false);
- DWORD Len = BuildingExt::FoundationLength(Foundation);
-
- std::vector<CellStruct> AffectedCells;
-
- AffectedCells.reserve(Len * ShadowHeight);
-
- CellStruct * CurrentFCell = Foundation;
-
- while(CurrentFCell->X != 32767 && CurrentFCell->Y != 32767) {
- CellStruct ActualCell = *MainCoords + *CurrentFCell;
- for(int i = ShadowHeight; i > 0; --i) {
- AffectedCells.push_back(ActualCell);
- --ActualCell.X;
- --ActualCell.Y;
- }
- ++CurrentFCell;
- }
-
- std::sort(AffectedCells.begin(), AffectedCells.end(), [](const CellStruct &lhs, const CellStruct &rhs) -> bool {
- return lhs.X > rhs.X || lhs.X == rhs.X && lhs.Y > rhs.Y;
- });
- auto it = std::unique(AffectedCells.begin(), AffectedCells.end());
- AffectedCells.resize(it - AffectedCells.begin());
-
- std::for_each(AffectedCells.begin(), AffectedCells.end(), [pThis](CellStruct coords) {
- CellClass * Cell = MapClass::Instance->GetCellAt(&coords);
- ++Cell->OccupyHeightsCoveringMe;
- });
-
- return 0x568697;
-}
-
-DEFINE_HOOK(568841, MapClass_RemoveContentAt_Foundation_P1, 0)
-{
- GET(BuildingClass *, pThis, EDI);
-
- R->EBP<CellStruct *>(pThis->GetFoundationData(false));
-
- return 0x568862;
-}
-
-DEFINE_HOOK(568997, MapClass_RemoveContentAt_Foundation_OccupyHeight, 5)
-{
- GET(BuildingClass *, pThis, EDX);
- GET(int, ShadowHeight, EBP);
- GET_STACK(CellStruct *, MainCoords, 0x8B4);
-
- CellStruct * Foundation = pThis->GetFoundationData(false);
- DWORD Len = BuildingExt::FoundationLength(Foundation);
-
- std::vector<CellStruct> AffectedCells;
-
- AffectedCells.reserve(Len * ShadowHeight);
-
- CellStruct * CurrentFCell = Foundation;
-
- while(CurrentFCell->X != 32767 && CurrentFCell->Y != 32767) {
- CellStruct ActualCell = *MainCoords + *CurrentFCell;
- for(int i = ShadowHeight; i > 0; --i) {
- AffectedCells.push_back(ActualCell);
- --ActualCell.X;
- --ActualCell.Y;
- }
- ++CurrentFCell;
- }
-
- std::sort(AffectedCells.begin(), AffectedCells.end(), [](const CellStruct &lhs, const CellStruct &rhs) -> bool {
- return lhs.X > rhs.X || lhs.X == rhs.X && lhs.Y > rhs.Y;
- });
- auto it = std::unique(AffectedCells.begin(), AffectedCells.end());
- AffectedCells.resize(it - AffectedCells.begin());
-
- std::for_each(AffectedCells.begin(), AffectedCells.end(), [pThis](CellStruct coords) {
- CellClass * Cell = MapClass::Instance->GetCellAt(&coords);
- if(Cell->OccupyHeightsCoveringMe > 0) {
- --Cell->OccupyHeightsCoveringMe;
- }
- });
-
- return 0x568ADC;
-}
-
-
-DEFINE_HOOK(4A8C77, MapClass_ProcessFoundation1_UnlimitBuffer, 5)
-{
- GET_STACK(CellStruct *, Foundation, 0x18);
- GET(DisplayClass *, Display, EBX);
-
- if(BuildingExt::TempFoundationData1) {
- delete[] BuildingExt::TempFoundationData1;
- }
-
- DWORD Len = BuildingExt::FoundationLength(Foundation);
-
- BuildingExt::TempFoundationData1 = new CellStruct[Len];
- memcpy(BuildingExt::TempFoundationData1, Foundation, Len * sizeof(CellStruct));
-
- Display->CurrentFoundation_Data = BuildingExt::TempFoundationData1;
-
- CellStruct bounds;
- Display->FoundationBoundsSize(&bounds, BuildingExt::TempFoundationData1);
- R->Stack<CellStruct>(0x18, bounds);
- R->EAX<CellStruct *>(R->lea_Stack<CellStruct *>(0x18));
-
- return 0x4A8C9E;
-}
-
-DEFINE_HOOK(4A8DD7, MapClass_ProcessFoundation2_UnlimitBuffer, 5)
-{
- GET_STACK(CellStruct *, Foundation, 0x18);
- GET(DisplayClass *, Display, EBX);
-
- if(BuildingExt::TempFoundationData2) {
- delete[] BuildingExt::TempFoundationData2;
- }
-
- DWORD Len = BuildingExt::FoundationLength(Foundation);
-
- BuildingExt::TempFoundationData2 = new CellStruct[Len];
- memcpy(BuildingExt::TempFoundationData2, Foundation, Len * sizeof(CellStruct));
-
- Display->CurrentFoundationCopy_Data = BuildingExt::TempFoundationData2;
-
- CellStruct bounds;
- Display->FoundationBoundsSize(&bounds, BuildingExt::TempFoundationData2);
- R->Stack<CellStruct>(0x18, bounds);
- R->EAX<CellStruct *>(R->lea_Stack<CellStruct *>(0x18));
-
- return 0x4A8DFE;
-}
+#include "Body.h"
+#include "../BuildingType/Body.h"
+
+#include <algorithm>
+#include <vector>
+
+CellStruct * BuildingExt::TempFoundationData1 = NULL;
+CellStruct * BuildingExt::TempFoundationData2 = NULL;
+
+DEFINE_HOOK(45EC90, Foundations_GetFoundationWidth, 6)
+{
+ GET(BuildingTypeClass*, pThis, ECX);
+ BuildingTypeExt::ExtData* pData = BuildingTypeExt::ExtMap.Find(pThis);
+
+ if(pData->IsCustom) {
+ R->EAX(pData->CustomWidth);
+ return 0x45EC9D;
+ }
+
+ return 0;
+}
+
+DEFINE_HOOK(45ECA0, Foundations_GetFoundationHeight, 6)
+{
+ GET(BuildingTypeClass*, pThis, ECX);
+ BuildingTypeExt::ExtData* pData = BuildingTypeExt::ExtMap.Find(pThis);
+
+ if(pData->IsCustom) {
+ bool bIncludeBib = (R->Stack8(0x4) != 0);
+
+ int fH = pData->CustomHeight;
+ if(bIncludeBib && pThis->Bib) {
+ ++fH;
+ }
+
+ R->EAX(fH);
+ return 0x45ECDA;
+ }
+
+ return 0;
+}
+
+DEFINE_HOOK(568411, MapClass_AddContentAt_Foundation_P1, 0)
+{
+ GET(BuildingClass *, pThis, EDI);
+
+ R->EBP<CellStruct *>(pThis->GetFoundationData(false));
+
+ return 0x568432;
+}
+
+DEFINE_HOOK(568565, MapClass_AddContentAt_Foundation_OccupyHeight, 5)
+{
+ GET(BuildingClass *, pThis, EDI);
+ GET(int, ShadowHeight, EBP);
+ GET_STACK(CellStruct *, MainCoords, 0x8B4);
+
+ CellStruct * Foundation = pThis->GetFoundationData(false);
+ DWORD Len = BuildingExt::FoundationLength(Foundation);
+
+ std::vector<CellStruct> AffectedCells;
+
+ AffectedCells.reserve(Len * ShadowHeight);
+
+ CellStruct * CurrentFCell = Foundation;
+
+ while(CurrentFCell->X != 32767 && CurrentFCell->Y != 32767) {
+ CellStruct ActualCell = *MainCoords + *CurrentFCell;
+ for(int i = ShadowHeight; i > 0; --i) {
+ AffectedCells.push_back(ActualCell);
+ --ActualCell.X;
+ --ActualCell.Y;
+ }
+ ++CurrentFCell;
+ }
+
+ std::sort(AffectedCells.begin(), AffectedCells.end(), [](const CellStruct &lhs, const CellStruct &rhs) -> bool {
+ return lhs.X > rhs.X || lhs.X == rhs.X && lhs.Y > rhs.Y;
+ });
+ auto it = std::unique(AffectedCells.begin(), AffectedCells.end());
+ AffectedCells.resize(it - AffectedCells.begin());
+
+ auto &Map = MapClass::Instance;
+
+ std::for_each(AffectedCells.begin(), AffectedCells.end(), [pThis, Map](CellStruct coords) {
+ int xy = (coords.Y << 9) + coords.X;
+ if(xy >= 0 && xy < 0x40000 && xy < Map->Cells.Capacity) {
+ if(auto Cell = Map->Cells[xy]) {
+ ++Cell->OccupyHeightsCoveringMe;
+ }
+ }
+ });
+
+ return 0x568697;
+}
+
+DEFINE_HOOK(568841, MapClass_RemoveContentAt_Foundation_P1, 0)
+{
+ GET(BuildingClass *, pThis, EDI);
+
+ R->EBP<CellStruct *>(pThis->GetFoundationData(false));
+
+ return 0x568862;
+}
+
+DEFINE_HOOK(568997, MapClass_RemoveContentAt_Foundation_OccupyHeight, 5)
+{
+ GET(BuildingClass *, pThis, EDX);
+ GET(int, ShadowHeight, EBP);
+ GET_STACK(CellStruct *, MainCoords, 0x8B4);
+
+ CellStruct * Foundation = pThis->GetFoundationData(false);
+ DWORD Len = BuildingExt::FoundationLength(Foundation);
+
+ std::vector<CellStruct> AffectedCells;
+
+ AffectedCells.reserve(Len * ShadowHeight);
+
+ CellStruct * CurrentFCell = Foundation;
+
+ while(CurrentFCell->X != 32767 && CurrentFCell->Y != 32767) {
+ CellStruct ActualCell = *MainCoords + *CurrentFCell;
+ for(int i = ShadowHeight; i > 0; --i) {
+ AffectedCells.push_back(ActualCell);
+ --ActualCell.X;
+ --ActualCell.Y;
+ }
+ ++CurrentFCell;
+ }
+
+ std::sort(AffectedCells.begin(), AffectedCells.end(), [](const CellStruct &lhs, const CellStruct &rhs) -> bool {
+ return lhs.X > rhs.X || lhs.X == rhs.X && lhs.Y > rhs.Y;
+ });
+ auto it = std::unique(AffectedCells.begin(), AffectedCells.end());
+ AffectedCells.resize(it - AffectedCells.begin());
+
+ auto &Map = MapClass::Instance;
+
+ std::for_each(AffectedCells.begin(), AffectedCells.end(), [pThis, Map](CellStruct coords) {
+ int xy = (coords.Y << 9) + coords.X;
+ if(xy >= 0 && xy < 0x40000 && xy < Map->Cells.Capacity) {
+ if(auto Cell = Map->Cells[xy]) {
+ if(Cell->OccupyHeightsCoveringMe > 0) {
+ --Cell->OccupyHeightsCoveringMe;
+ }
+ }
+ }
+ });
+
+ return 0x568ADC;
+}
+
+
+DEFINE_HOOK(4A8C77, MapClass_ProcessFoundation1_UnlimitBuffer, 5)
+{
+ GET_STACK(CellStruct *, Foundation, 0x18);
+ GET(DisplayClass *, Display, EBX);
+
+ if(BuildingExt::TempFoundationData1) {
+ delete[] BuildingExt::TempFoundationData1;
+ }
+
+ DWORD Len = BuildingExt::FoundationLength(Foundation);
+
+ BuildingExt::TempFoundationData1 = new CellStruct[Len];
+ memcpy(BuildingExt::TempFoundationData1, Foundation, Len * sizeof(CellStruct));
+
+ Display->CurrentFoundation_Data = BuildingExt::TempFoundationData1;
+
+ CellStruct bounds;
+ Display->FoundationBoundsSize(&bounds, BuildingExt::TempFoundationData1);
+ R->Stack<CellStruct>(0x18, bounds);
+ R->EAX<CellStruct *>(R->lea_Stack<CellStruct *>(0x18));
+
+ return 0x4A8C9E;
+}
+
+DEFINE_HOOK(4A8DD7, MapClass_ProcessFoundation2_UnlimitBuffer, 5)
+{
+ GET_STACK(CellStruct *, Foundation, 0x18);
+ GET(DisplayClass *, Display, EBX);
+
+ if(BuildingExt::TempFoundationData2) {
+ delete[] BuildingExt::TempFoundationData2;
+ }
+
+ DWORD Len = BuildingExt::FoundationLength(Foundation);
+
+ BuildingExt::TempFoundationData2 = new CellStruct[Len];
+ memcpy(BuildingExt::TempFoundationData2, Foundation, Len * sizeof(CellStruct));
+
+ Display->CurrentFoundationCopy_Data = BuildingExt::TempFoundationData2;
+
+ CellStruct bounds;
+ Display->FoundationBoundsSize(&bounds, BuildingExt::TempFoundationData2);
+ R->Stack<CellStruct>(0x18, bounds);
+ R->EAX<CellStruct *>(R->lea_Stack<CellStruct *>(0x18));
+
+ return 0x4A8DFE;
+}

No commit comments for this range

Something went wrong with that request. Please try again.