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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
secsome committed Aug 17, 2021
2 parents 3f6d48d + 772f9fc commit 125ebe3
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 5,302 deletions.
2 changes: 1 addition & 1 deletion FA2pp
Submodule FA2pp updated 3 files
+1 −1 CLoading.h
+1 −1 FA2PPCore.h
+5 −1 FunctionInit.cpp
4 changes: 1 addition & 3 deletions FA2sp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>false</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS;WIN32;_CRT_SECURE_NO_WARNINGS;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<ExceptionHandling>false</ExceptionHandling>
<BufferSecurityCheck>true</BufferSecurityCheck>
Expand Down Expand Up @@ -192,13 +192,11 @@
<ClInclude Include="FA2sp\Ext\CTriggerOption\Body.h" />
<ClInclude Include="FA2sp\FA2sp.h" />
<ClInclude Include="FA2sp\FA2sp.Constants.h" />
<ClInclude Include="FA2sp\Helpers\Bitmap.h" />
<ClInclude Include="FA2sp\Helpers\ControlHelpers.h" />
<ClInclude Include="FA2sp\Helpers\Helper.h" />
<ClInclude Include="FA2sp\Helpers\INIParser.h" />
<ClInclude Include="FA2sp\Helpers\MultimapHelper.h" />
<ClInclude Include="FA2sp\Helpers\Parser.h" />
<ClInclude Include="FA2sp\Helpers\Screenshot.h" />
<ClInclude Include="FA2sp\Helpers\STDHelpers.h" />
<ClInclude Include="FA2sp\Helpers\Templates.hpp" />
<ClInclude Include="FA2sp\Logger.h" />
Expand Down
6 changes: 0 additions & 6 deletions FA2sp.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@
<ClInclude Include="FA2sp\Ext\CLoading\Body.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="FA2sp\Helpers\Bitmap.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="FA2sp\Miscs\Palettes.h">
<Filter>头文件</Filter>
</ClInclude>
Expand All @@ -111,9 +108,6 @@
<ClInclude Include="FA2sp\Miscs\DrawStuff.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="FA2sp\Helpers\Screenshot.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="FA2sp\ExtraWindow\CAllieEditor\CAllieEditor.h">
<Filter>头文件</Filter>
</ClInclude>
Expand Down
34 changes: 7 additions & 27 deletions FA2sp/Ext/CLoading/Body.LoadObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void CLoadingExt::LoadBuilding(ppmfc::CString ID)
{
if (Variables::Rules.GetBool(ID, "TurretAnimIsVoxel"))
{
int turzadjust = Variables::Rules.GetInteger(ID, "TurretAnimZAdjust");
int turzadjust = Variables::Rules.GetInteger(ID, "TurretAnimZAdjust"); // no idea why apply it but it worked

ppmfc::CString TurName = Variables::Rules.GetString(ID, "TurretAnim", ID + "tur");
ppmfc::CString BarlName = ID + "barl";
Expand Down Expand Up @@ -383,7 +383,7 @@ void CLoadingExt::LoadBuilding(ppmfc::CString ID)
int turdeltaY = GlobalVars::INIFiles::FAData->GetInteger("BuildingVoxelTurretsRA2", pKey);

VXL_Add(pTurImages[i], turrect[i][2] + turdeltaX, turrect[i][3] + turdeltaY, turrect[i][0], turrect[i][1]);
GameDeleteArray(pTurImages[i], turrect[i][0] * turrect[i][1]);
delete[] pTurImages[i]; // this buffer is created inside the lib

if (pBarlImages[i])
{
Expand All @@ -393,7 +393,7 @@ void CLoadingExt::LoadBuilding(ppmfc::CString ID)
int barldeltaY = GlobalVars::INIFiles::FAData->GetInteger("BuildingVoxelBarrelsRA2", pKey);

VXL_Add(pBarlImages[i], barlrect[i][2]+ barldeltaX, barlrect[i][3]+ barldeltaY, barlrect[i][0], barlrect[i][1]);
GameDeleteArray(pBarlImages[i], barlrect[i][0] * barlrect[i][1]);
delete[] pBarlImages[i];
}
}

Expand Down Expand Up @@ -578,7 +578,7 @@ void CLoadingExt::LoadVehicleOrAircraft(ppmfc::CString ID)
if (pImage[i])
{
VXL_Add(pImage[i], rect[i][2], rect[i][3], rect[i][0], rect[i][1]);
GameDeleteArray(pImage[i], rect[i][0] * rect[i][1]);
delete[] pImage[i];
}
ppmfc::CString pKey;
if (pTurretImage[i])
Expand All @@ -588,7 +588,7 @@ void CLoadingExt::LoadVehicleOrAircraft(ppmfc::CString ID)
pKey.Format("%sY%d", ID, i);
int turdeltaY = GlobalVars::INIFiles::FAData->GetInteger("VehicleVoxelTurretsRA2", pKey);
VXL_Add(pTurretImage[i], turretrect[i][2] + turdeltaX, turretrect[i][3] + turdeltaY, turretrect[i][0], turretrect[i][1]);
GameDeleteArray(pTurretImage[i], turretrect[i][0] * turretrect[i][1]);
delete[] pTurretImage[i];

if (pBarrelImage[i])
{
Expand All @@ -598,7 +598,7 @@ void CLoadingExt::LoadVehicleOrAircraft(ppmfc::CString ID)
int barldeltaY = GlobalVars::INIFiles::FAData->GetInteger("VehicleVoxelBarrelsRA2", pKey);

VXL_Add(pBarrelImage[i], barrelrect[i][2] + barldeltaX, barrelrect[i][3] + barldeltaY, barrelrect[i][0], barrelrect[i][1]);
GameDeleteArray(pBarrelImage[i], barrelrect[i][0] * barrelrect[i][1]);
delete[] pBarrelImage[i];
}
}

Expand All @@ -618,13 +618,12 @@ void CLoadingExt::LoadVehicleOrAircraft(ppmfc::CString ID)
int outW = 0x100, outH = 0x100;

VXL_Add(pImage[i], rect[i][2], rect[i][3], rect[i][0], rect[i][1]);
delete[] pImage[i];
VXL_GetAndClear(outBuffer, &outW, &outH);

SetImageData(outBuffer, DictName, outW, outH, Palettes::LoadPalette(PaletteName));
}
}


}
else // As SHP
{
Expand Down Expand Up @@ -909,23 +908,4 @@ void CLoadingExt::GetFullPaletteName(ppmfc::CString& PaletteName)
PaletteName += "tem.pal";
return;
}
}

#include "../../Helpers/Bitmap.h"
void CLoadingExt::DumpFrameToFile(unsigned char* pBuffer, Palette* pPal, int Width, int Height, ppmfc::CString name)
{
bitmap_image bmp;
bmp.setwidth_height(Width, Height, true);

int count = 0;
for (int j = 0; j < bmp.height(); ++j)
{
for (int i = 0; i < bmp.width(); ++i)
{
bmp.set_pixel(i, j, pPal->GetByteColor(pBuffer[count]));
++count;
}
}

bmp.save_image((const char*)name);
}
14 changes: 7 additions & 7 deletions FA2sp/Ext/CScriptTypes/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ BOOL CScriptTypesExt::OnInitDialogExt()
default:
case 2:
CScriptTypeParam::ExtParams[id].Param_ = atoi((const char*)pParseBuffer[1]);
SAFE_RELEASE(pParseBuffer[1]);
case 1:
CScriptTypeParam::ExtParams[id].Label_ = pParseBuffer[0];
SAFE_RELEASE(pParseBuffer[0]);
case 0:
continue;
}
}
SAFE_RELEASE(pParseBuffer[0]);
SAFE_RELEASE(pParseBuffer[1]);
}

if (auto entities = fadata.GetSection("ScriptsRA2"))
Expand All @@ -236,23 +236,23 @@ BOOL CScriptTypesExt::OnInitDialogExt()
case 5:
default:
CScriptTypeAction::ExtActions[id].Description_ = pParseBuffer[4];
SAFE_RELEASE(pParseBuffer[4]);
case 4:
CScriptTypeAction::ExtActions[id].Editable_ = ParseBool((const char*)pParseBuffer[3]);
SAFE_RELEASE(pParseBuffer[3]);
case 3:
CScriptTypeAction::ExtActions[id].Hide_ = ParseBool((const char*)pParseBuffer[2]);
SAFE_RELEASE(pParseBuffer[2]);
case 2:
CScriptTypeAction::ExtActions[id].ParamCode_ = atoi((const char*)pParseBuffer[1]);
SAFE_RELEASE(pParseBuffer[1]);
case 1:
CScriptTypeAction::ExtActions[id].Name_ = pParseBuffer[0];
SAFE_RELEASE(pParseBuffer[0]);
case 0:
continue;
}
}
SAFE_RELEASE(pParseBuffer[0]);
SAFE_RELEASE(pParseBuffer[1]);
SAFE_RELEASE(pParseBuffer[2]);
SAFE_RELEASE(pParseBuffer[3]);
SAFE_RELEASE(pParseBuffer[4]);
}

int counter = 0;
Expand Down
5 changes: 3 additions & 2 deletions FA2sp/Ext/CTeamTypes/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ void CTeamTypesExt::OnBNCloneClicked()

auto copyitem = [&value, &currentID](ppmfc::CString key)
{
auto data = GlobalVars::INIFiles::CurrentDocument->GetString(currentID, key);
GlobalVars::INIFiles::CurrentDocument->WriteString(value, key, data);
if (auto ppStr = GlobalVars::INIFiles::CurrentDocument->TryGetString(currentID, key))
GlobalVars::INIFiles::CurrentDocument->WriteString(value, key, *ppStr);
};

copyitem("Max");
Expand Down Expand Up @@ -139,6 +139,7 @@ void CTeamTypesExt::OnBNCloneClicked()
copyitem("LooseRecruit");
copyitem("VeteranLevel");
copyitem("IsBaseDefense");
copyitem("TransportWaypoint");
copyitem("UseTransportOrigin");
copyitem("MindControlDecision");
copyitem("OnlyTargetHouseEnemy");
Expand Down
156 changes: 98 additions & 58 deletions FA2sp/ExtraWindow/CAllieEditor/CAllieEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,72 +51,112 @@ BOOL CALLBACK CAllieEditor::DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM l
return TRUE;
}
case WM_COMMAND: {
switch (wParam)
WORD ID = LOWORD(wParam);
WORD CODE = HIWORD(wParam);
if (CODE == BN_CLICKED)
{
case IDOK: {
ppmfc::CString allies = "";
HWND LBA = GetDlgItem(hwnd, 6302);//Allies ListBox
int cnt = SendMessage(LBA, LB_GETCOUNT, NULL, NULL);
for (int i = 0; i < cnt - 1; ++i)
switch (ID)
{
int TextLen = SendMessage(LBA, LB_GETTEXTLEN, i, NULL);
case IDOK: {
ppmfc::CString allies = "";
HWND LBA = GetDlgItem(hwnd, 6302);//Allies ListBox
int cnt = SendMessage(LBA, LB_GETCOUNT, NULL, NULL);
for (int i = 0; i < cnt - 1; ++i)
{
int TextLen = SendMessage(LBA, LB_GETTEXTLEN, i, NULL);
if (TextLen == LB_ERR) break;
TCHAR* str = new TCHAR[TextLen + 1];
SendMessage(LBA, LB_GETTEXT, i, (LPARAM)str);
FA2sp::Buffer.Format("%s,", str);
delete[] str;
allies += FA2sp::Buffer;
}
int TextLen = SendMessage(LBA, LB_GETTEXTLEN, cnt - 1, NULL);
if (TextLen == LB_ERR) break;
TCHAR* str = new TCHAR[TextLen + 1];
SendMessage(LBA, LB_GETTEXT, i, (LPARAM)str);
FA2sp::Buffer.Format("%s,", str);
SendMessage(LBA, LB_GETTEXT, cnt - 1, (LPARAM)str);
FA2sp::Buffer.Format("%s", str);
delete[] str;
allies += FA2sp::Buffer;
}
int TextLen = SendMessage(LBA, LB_GETTEXTLEN, cnt - 1, NULL);
if (TextLen == LB_ERR) break;
TCHAR* str = new TCHAR[TextLen + 1];
SendMessage(LBA, LB_GETTEXT, cnt - 1, (LPARAM)str);
FA2sp::Buffer.Format("%s", str);
delete[] str;
allies += FA2sp::Buffer;

cHouses.CETAllies.SetWindowText(allies);
EndDialog(hwnd, NULL);
return TRUE;
}
case IDCANCEL: {
EndDialog(hwnd, NULL);
return TRUE;
}
case 6300: {//Go Allies
HWND LBA = GetDlgItem(hwnd, 6302);//Allies ListBox
HWND LBB = GetDlgItem(hwnd, 6303);//Enemy ListBox
int EnemyCount = SendMessage(LBB, LB_GETCOUNT, NULL, NULL);
if (EnemyCount <= 0) break;
int EnemyCurSelIndex = SendMessage(LBB, LB_GETCURSEL, NULL, NULL);
if (EnemyCurSelIndex < 0 || EnemyCurSelIndex >= EnemyCount) break;
int TextLen = SendMessage(LBB, LB_GETTEXTLEN, EnemyCurSelIndex, NULL);
if (TextLen == LB_ERR) break;
TCHAR* str = new TCHAR[TextLen + 1];
SendMessage(LBB, LB_GETTEXT, EnemyCurSelIndex, (LPARAM)str);
SendMessage(LBB, LB_DELETESTRING, EnemyCurSelIndex, NULL);
SendMessage(LBA, LB_ADDSTRING, NULL, (LPARAM)str);
delete[] str;
break;
}
case 6301: {//Go Enemies
HWND LBA = GetDlgItem(hwnd, 6302);//Allies ListBox
HWND LBB = GetDlgItem(hwnd, 6303);//Enemy ListBox
int AllieCount = SendMessage(LBA, LB_GETCOUNT, NULL, NULL);
if (AllieCount <= 0) break;
int AllieCurSelIndex = SendMessage(LBA, LB_GETCURSEL, NULL, NULL);
if (AllieCurSelIndex < 0 || AllieCurSelIndex >= AllieCount) break;
int TextLen = SendMessage(LBA, LB_GETTEXTLEN, AllieCurSelIndex, NULL);
if (TextLen == LB_ERR) break;
TCHAR* str = new TCHAR[TextLen + 1];
SendMessage(LBA, LB_GETTEXT, AllieCurSelIndex, (LPARAM)str);
SendMessage(LBA, LB_DELETESTRING, AllieCurSelIndex, NULL);
SendMessage(LBB, LB_ADDSTRING, NULL, (LPARAM)str);
delete[] str;
break;
cHouses.CETAllies.SetWindowText(allies);
EndDialog(hwnd, NULL);
return TRUE;
}
case IDCANCEL: {
EndDialog(hwnd, NULL);
return TRUE;
}
case 6300: {//Go Allies
HWND LBA = GetDlgItem(hwnd, 6302);//Allies ListBox
HWND LBB = GetDlgItem(hwnd, 6303);//Enemy ListBox
int EnemyCount = SendMessage(LBB, LB_GETCOUNT, NULL, NULL);
if (EnemyCount <= 0) break;
int EnemyCurSelIndex = SendMessage(LBB, LB_GETCURSEL, NULL, NULL);
if (EnemyCurSelIndex < 0 || EnemyCurSelIndex >= EnemyCount) break;
int TextLen = SendMessage(LBB, LB_GETTEXTLEN, EnemyCurSelIndex, NULL);
if (TextLen == LB_ERR) break;
TCHAR* str = new TCHAR[TextLen + 1];
SendMessage(LBB, LB_GETTEXT, EnemyCurSelIndex, (LPARAM)str);
SendMessage(LBB, LB_DELETESTRING, EnemyCurSelIndex, NULL);
SendMessage(LBA, LB_ADDSTRING, NULL, (LPARAM)str);
delete[] str;
break;
}
case 6301: {//Go Enemies
HWND LBA = GetDlgItem(hwnd, 6302);//Allies ListBox
HWND LBB = GetDlgItem(hwnd, 6303);//Enemy ListBox
int AllieCount = SendMessage(LBA, LB_GETCOUNT, NULL, NULL);
if (AllieCount <= 0) break;
int AllieCurSelIndex = SendMessage(LBA, LB_GETCURSEL, NULL, NULL);
if (AllieCurSelIndex < 0 || AllieCurSelIndex >= AllieCount) break;
int TextLen = SendMessage(LBA, LB_GETTEXTLEN, AllieCurSelIndex, NULL);
if (TextLen == LB_ERR) break;
TCHAR* str = new TCHAR[TextLen + 1];
SendMessage(LBA, LB_GETTEXT, AllieCurSelIndex, (LPARAM)str);
SendMessage(LBA, LB_DELETESTRING, AllieCurSelIndex, NULL);
SendMessage(LBB, LB_ADDSTRING, NULL, (LPARAM)str);
delete[] str;
break;
}
default:
break;
}
}
default:
break;
else if (CODE == LBN_DBLCLK)
{
if (ID == 6303) // Go allies
{
HWND LBA = GetDlgItem(hwnd, 6302);//Allies ListBox
HWND LBB = GetDlgItem(hwnd, 6303);//Enemy ListBox
int EnemyCount = SendMessage(LBB, LB_GETCOUNT, NULL, NULL);
if (EnemyCount <= 0) break;
int EnemyCurSelIndex = SendMessage(LBB, LB_GETCURSEL, NULL, NULL);
if (EnemyCurSelIndex < 0 || EnemyCurSelIndex >= EnemyCount) break;
int TextLen = SendMessage(LBB, LB_GETTEXTLEN, EnemyCurSelIndex, NULL);
if (TextLen == LB_ERR) break;
TCHAR* str = new TCHAR[TextLen + 1];
SendMessage(LBB, LB_GETTEXT, EnemyCurSelIndex, (LPARAM)str);
SendMessage(LBB, LB_DELETESTRING, EnemyCurSelIndex, NULL);
SendMessage(LBA, LB_ADDSTRING, NULL, (LPARAM)str);
delete[] str;
}
else if (ID == 6302) // Go Enemies
{
HWND LBA = GetDlgItem(hwnd, 6302);//Allies ListBox
HWND LBB = GetDlgItem(hwnd, 6303);//Enemy ListBox
int AllieCount = SendMessage(LBA, LB_GETCOUNT, NULL, NULL);
if (AllieCount <= 0) break;
int AllieCurSelIndex = SendMessage(LBA, LB_GETCURSEL, NULL, NULL);
if (AllieCurSelIndex < 0 || AllieCurSelIndex >= AllieCount) break;
int TextLen = SendMessage(LBA, LB_GETTEXTLEN, AllieCurSelIndex, NULL);
if (TextLen == LB_ERR) break;
TCHAR* str = new TCHAR[TextLen + 1];
SendMessage(LBA, LB_GETTEXT, AllieCurSelIndex, (LPARAM)str);
SendMessage(LBA, LB_DELETESTRING, AllieCurSelIndex, NULL);
SendMessage(LBB, LB_ADDSTRING, NULL, (LPARAM)str);
delete[] str;
}
}
break;
}
Expand Down
4 changes: 2 additions & 2 deletions FA2sp/ExtraWindow/CAllieEditor/CAllieEditor.rc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,252,155,50,14
LTEXT "Enemies",-1,7,7,21,13,SS_SUNKEN
LTEXT "Allies",-1,281,7,21,11,SS_SUNKEN
LISTBOX 6302,177,19,125,129,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LISTBOX 6303,7,19,125,129,LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LISTBOX 6302,177,19,125,129,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP | LBS_NOTIFY
LISTBOX 6303,7,19,125,129,LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP | LBS_NOTIFY
PUSHBUTTON "->",6300,137,57,36,14
PUSHBUTTON "<-",6301,137,78,36,14
EDITTEXT 6304,69,155,167,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP,WS_EX_STATICEDGE
Expand Down
Loading

0 comments on commit 125ebe3

Please sign in to comment.