Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit 76534b9

Browse files
committed
MapValidator now validates the overlapping structures
1 parent 0329c92 commit 76534b9

File tree

10 files changed

+121
-4
lines changed

10 files changed

+121
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# FINALALERT2 - SP CHANGELOG
22

33
## RELEASE 1.6.0 (2023-XX-XX)
4+
- **ONLY YURI's REVENGE WILL BE SUPPORTED SINCE FA2SP 1.6.0**
45
- Reimplemented file reading system
56
- Support Ares Custom Foundation
7+
- Map validator now checks overlapping structures, raise an error instead of warning for now. String can be modified by `MV_OverlapStructures`
68

79
## RELEASE 1.5.2 (2023-03-03)
810
- Fixed the bug that money calculation is incorrect

DOCUMENT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ NOTICE THAT UNDOREDO AND COPYPASTE HASN'T BEEN SUPPORTED YET!
367367
[CURRENTLANGUAGE-TranslationsRA2]
368368
[CURRENTLANGUAGE-Translations]
369369
; Those four are all acceptable, just write under one of them is okey
370+
MV_OverlapStructures = TEXT(%1 for count, %2 for X, %3 for Y)
370371
TabPages.TilePlacement = TEXT
371372
TabPages.TriggerSort = TEXT
372373
Menu.File = TEXT

FA2pp

FA2sp.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@
163163
<ClCompile Include="FA2sp\Ext\CMapData\Hooks.cpp" />
164164
<ClCompile Include="FA2sp\Ext\CMapData\Body.Pack.cpp" />
165165
<ClCompile Include="FA2sp\Ext\CMapD\Hooks.cpp" />
166+
<ClCompile Include="FA2sp\Ext\CMapValidator\Body.cpp" />
167+
<ClCompile Include="FA2sp\Ext\CMapValidator\Hooks.cpp" />
166168
<ClCompile Include="FA2sp\Ext\CMinimap\Hooks.cpp" />
167169
<ClCompile Include="FA2sp\Ext\CPropertyAircraft\Body.cpp" />
168170
<ClCompile Include="FA2sp\Ext\CPropertyAircraft\Hooks.cpp" />
@@ -244,6 +246,7 @@
244246
<ClInclude Include="FA2sp\Ext\CLighting\Body.h" />
245247
<ClInclude Include="FA2sp\Ext\CLoading\Body.h" />
246248
<ClInclude Include="FA2sp\Ext\CMapData\Body.h" />
249+
<ClInclude Include="FA2sp\Ext\CMapValidator\Body.h" />
247250
<ClInclude Include="FA2sp\Ext\CPropertyAircraft\Body.h" />
248251
<ClInclude Include="FA2sp\Ext\CPropertyBuilding\Body.h" />
249252
<ClInclude Include="FA2sp\Ext\CPropertyInfantry\Body.h" />

FA2sp.vcxproj.filters

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@
183183
<ClInclude Include="FA2sp\Algorithms\lcw.h">
184184
<Filter>头文件</Filter>
185185
</ClInclude>
186+
<ClInclude Include="FA2sp\Ext\CMapValidator\Body.h">
187+
<Filter>头文件</Filter>
188+
</ClInclude>
186189
</ItemGroup>
187190
<ItemGroup>
188191
<ClCompile Include="FA2sp\FA2sp.cpp">
@@ -479,6 +482,18 @@
479482
<ClCompile Include="FA2sp\Ext\CLoading\Hooks.cpp">
480483
<Filter>源文件</Filter>
481484
</ClCompile>
485+
<ClCompile Include="FA2sp\Ext\CMapData\Hooks.BuildingTypeDatas.cpp">
486+
<Filter>源文件</Filter>
487+
</ClCompile>
488+
<ClCompile Include="FA2sp\Miscs\PlaceHolder.cpp">
489+
<Filter>源文件</Filter>
490+
</ClCompile>
491+
<ClCompile Include="FA2sp\Ext\CMapValidator\Body.cpp">
492+
<Filter>源文件</Filter>
493+
</ClCompile>
494+
<ClCompile Include="FA2sp\Ext\CMapValidator\Hooks.cpp">
495+
<Filter>源文件</Filter>
496+
</ClCompile>
482497
</ItemGroup>
483498
<ItemGroup>
484499
<ResourceCompile Include="FA2sp\FA2sp.rc">

FA2sp/Ext/CAITriggerTypes/Body.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "../../Helpers/Translations.h"
77
#include "..\CMapData\Body.h"
88
#include "..\CFinalSunApp\Body.h"
9+
#include "Body.h"
910

1011
void CAITriggerTypesExt::ProgramStartupInit()
1112
{
@@ -118,4 +119,4 @@ void CAITriggerTypesExt::OnBNCloneAITriggerClicked()
118119

119120
this->SetDlgItemText(1010, name); // update the name huh
120121
}
121-
}
122+
}

FA2sp/Ext/CMapValidator/Body.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "Body.h"
2+
3+
#include "../../Helpers/Translations.h"
4+
5+
#include <CMapData.h>
6+
7+
ppmfc::CString CMapValidatorExt::FetchLanguageString(const char* Key, const char* def)
8+
{
9+
ppmfc::CString buffer;
10+
11+
if (!Translations::GetTranslationItem(Key, buffer))
12+
buffer = def;
13+
14+
return buffer;
15+
}
16+
17+
void CMapValidatorExt::InsertString(const char* String, bool IsWarning)
18+
{
19+
CLCResults.InsertItem(LVIF_TEXT | LVIF_IMAGE, CLCResults.GetItemCount(), String, NULL, NULL, IsWarning, NULL);
20+
}

FA2sp/Ext/CMapValidator/Body.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
#include <CMapValidator.h>
4+
5+
class CMapValidatorExt : public CMapValidator
6+
{
7+
public:
8+
ppmfc::CString FetchLanguageString(const char* Key, const char* def);
9+
void InsertString(const char* String, bool IsWarning);
10+
};

FA2sp/Ext/CMapValidator/Hooks.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include "Body.h"
2+
3+
#include <Helpers/Macro.h>
4+
5+
#include <CMapData.h>
6+
7+
#include "../../Helpers/STDHelpers.h"
8+
#include "../../Ext/CMapData/Body.h"
9+
10+
DEFINE_HOOK(4D19A0, CMapValidator_DoValidator_Extra, 5)
11+
{
12+
GET(CMapValidatorExt*, pThis, EDI);
13+
REF_STACK(BOOL, result, STACK_OFFS(0x200, 0x168));
14+
15+
// Check for overlapped buildings
16+
{
17+
std::vector<int> Occupied;
18+
int length = CMapData::Instance->MapWidthPlusHeight;
19+
length *= length;
20+
Occupied.resize(length);
21+
22+
if (auto pSection = CMapData::Instance->INI.GetSection("Structures"))
23+
{
24+
for (const auto& [_, Data] : pSection->GetEntities())
25+
{
26+
const auto splits = STDHelpers::SplitString(Data, 4);
27+
const int Index = CMapData::Instance->GetBuildingTypeID(splits[1]);
28+
const int Y = atoi(splits[3]);
29+
const int X = atoi(splits[4]);
30+
const auto& DataExt = CMapDataExt::BuildingDataExts[Index];
31+
32+
if (!DataExt.IsCustomFoundation())
33+
{
34+
for (int dx = 0; dx < DataExt.Height; ++dx)
35+
{
36+
for (int dy = 0; dy < DataExt.Width; ++dy)
37+
++Occupied[CMapData::Instance->GetCoordIndex(X + dx, Y + dy)];
38+
}
39+
}
40+
else
41+
{
42+
for (const auto& block : *DataExt.Foundations)
43+
++Occupied[CMapData::Instance->GetCoordIndex(X + block.Y, Y + block.X)];
44+
}
45+
}
46+
}
47+
48+
ppmfc::CString Format = pThis->FetchLanguageString(
49+
"MV_OverlapStructures", "%1 structures overlap at (%2, %3)");
50+
for (int i = 0; i < length; ++i)
51+
{
52+
if (Occupied[i] > 1)
53+
{
54+
result = FALSE;
55+
auto buffer = Format;
56+
buffer.ReplaceNumString(1, Occupied[i]);
57+
buffer.ReplaceNumString(2, CMapData::Instance->GetYFromCoordIndex(i));
58+
buffer.ReplaceNumString(3, CMapData::Instance->GetXFromCoordIndex(i));
59+
pThis->InsertString(buffer, false);
60+
}
61+
}
62+
}
63+
64+
return 0;
65+
}

FA2sp/FA2sp.Constants.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#define __str_(x) #x
55

66
#define PRODUCT_MAJOR 1
7-
#define PRODUCT_MINOR 5
8-
#define PRODUCT_REVISION 2
7+
#define PRODUCT_MINOR 6
8+
#define PRODUCT_REVISION 0
99

1010
#ifdef NDEBUG
1111
#define PRODUCT_STR __str(PRODUCT_MAJOR) "." __str(PRODUCT_MINOR) "." __str(PRODUCT_REVISION)

0 commit comments

Comments
 (0)