code reformatted .

This commit is contained in:
Zero Fanker 2024-04-16 20:51:17 -04:00
parent 76d336504f
commit 1de6ad56c2
265 changed files with 18240 additions and 21591 deletions

View file

@ -1,21 +1,21 @@
/*
FinalSun/FinalAlert 2 Mission Editor
FinalSun/FinalAlert 2 Mission Editor
Copyright (C) 1999-2024 Electronic Arts, Inc.
Authored by Matthias Wagner
Copyright (C) 1999-2024 Electronic Arts, Inc.
Authored by Matthias Wagner
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**************************************
@ -49,8 +49,7 @@ enum class TheaterChar : char
inline TheaterChar toTheaterChar(char c)
{
switch (c)
{
switch (c) {
case 'T':
return TheaterChar::T;
case 'A':
@ -67,7 +66,7 @@ inline TheaterChar toTheaterChar(char c)
return TheaterChar::Generic;
default:
return TheaterChar::None;
}
}
}
struct CLIPBOARD_MAPCOPY_ENTRY
@ -76,7 +75,7 @@ struct CLIPBOARD_MAPCOPY_ENTRY
BYTE overlay;
BYTE overlaydata;
WORD wGround;
WORD bMapData;
WORD bMapData;
BYTE bSubTile;
BYTE bHeight;
BYTE bMapData2;
@ -108,7 +107,7 @@ picdata
Holds information for every picture:
a directdraw surface, and additional data
*/
struct PICDATA{
struct PICDATA {
PICDATA() = default;
PICDATA(const PICDATA& c) = default;
PICDATA& operator=(const PICDATA& c) = default;
@ -124,7 +123,7 @@ struct PICDATA{
std::shared_ptr<std::vector<BYTE>> rawPic;
std::shared_ptr<std::vector<VBORDER>> _vBorder;
#endif
FSunPackLib::VoxelNormalClass normalClass = FSunPackLib::VoxelNormalClass::Unknown;
short x = 0; // for SHPs (starting point of main graphic inside surface)
short y = 0; // for SHPs (starting point of main graphic inside surface)
@ -152,7 +151,7 @@ TILEPIC / TILEDATA
Holds information for every tile/subtile in TS.
*/
struct SUBTILE{
struct SUBTILE {
#ifndef NOSURFACES
LPDIRECTDRAWSURFACE4 pic;
#else
@ -160,9 +159,9 @@ struct SUBTILE{
BOOL bNotExtracted; // pic is not extracted, even if NOSURFACES_EXTRACT is specifed. Probably there is inner transparency!
#endif
BYTE* pic; // optionally use direct blitting? This is either a palette index array or non-palette data (if NOSURFACES_EXTRACT is specified)
VBORDER * vborder;
VBORDER* vborder;
#endif
WORD wWidth; // width of tile
WORD wHeight; // height "
short sX; // x starting pos
@ -181,7 +180,7 @@ struct SUBTILE{
return ProjectedVec(sX, sY);
}
};
struct TILEDATA{
struct TILEDATA {
TILEDATA() = default;
~TILEDATA();
WORD wTileSet = 0;
@ -196,7 +195,7 @@ struct TILEDATA{
BOOL bMarbleMadness = FALSE;
WORD wMarbleGround = 0xFFFF;
public:
public:
RECT rect = { 0 };
TILEDATA* lpReplacements = nullptr;
@ -209,7 +208,7 @@ actiondata
CViewObjects sets this data struct,
and CIsoView uses it to interact with the user´s CViewObjects and terrain editing choice
*/
struct ACTIONDATA{
struct ACTIONDATA {
DWORD mode;
DWORD type;
DWORD data;
@ -224,12 +223,12 @@ struct ACTIONDATA{
void reset();
};
struct SIDEINFO{
struct SIDEINFO {
CString name;
int orig_n;
};
};
struct HOUSEINFO{
struct HOUSEINFO {
CString name;
SIDEINFO* side; // side is used for rules.ini owner= settings
RGBTRIPLE color;
@ -240,8 +239,8 @@ struct HOUSEINFO{
Unittype infos
**********************/
/*
building infos
/*
building infos
*/
struct BUILDING_INFO
{
@ -285,12 +284,12 @@ enum ConditionEnum {
struct AITrigInfo
{
union{
struct{
int Number;
ConditionEnum Condition;
};
char Padding[32];
union {
struct {
int Number;
ConditionEnum Condition;
};
char Padding[32];
};
};
@ -304,54 +303,52 @@ struct XCString
{
//wString=new(WCHAR[2]);
//memset(wString, 0, 4);
wString=NULL;
bUsedDefault=FALSE;
len=0;
wString = NULL;
bUsedDefault = FALSE;
len = 0;
}
~XCString()
{
if(wString) delete[] wString;
len=0;
wString=NULL;
if (wString) delete[] wString;
len = 0;
wString = NULL;
}
void SetString(const CHAR* cString)
{
len=strlen(cString);
len = strlen(cString);
this->cString = cString;
if (wString) delete[] wString;
bUsedDefault = FALSE;
wString = new(WCHAR[len + 1]);
memset(wString, 0, (len + 1) * 2);
this->cString=cString;
if(wString) delete[] wString;
bUsedDefault=FALSE;
wString=new(WCHAR[len+1]);
memset(wString, 0, (len+1)*2);
//MultiByteToWideChar(CP_ACP, WC_COMPOSITECHECK, cString, len, wString, len+1);
mbstowcs(wString, cString, len);
mbstowcs(wString, cString, len);
}
void SetString(const WCHAR* wString, int len)
{
this->len=len;
this->len = len;
if(this->wString) delete[] this->wString;
bUsedDefault=FALSE;
if (this->wString) delete[] this->wString;
this->wString=new(WCHAR[len+1]);
memset(this->wString, 0, (len+1)*2);
memcpy(this->wString, wString, len*2);
bUsedDefault = FALSE;
this->wString = new(WCHAR[len + 1]);
memset(this->wString, 0, (len + 1) * 2);
memcpy(this->wString, wString, len * 2);
auto bufferSize = WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, this->wString, len + 1, nullptr, 0, NULL, &bUsedDefault);
if (bufferSize == 0)
{
if (bufferSize == 0) {
cString = "";
return; // failed
}
std::vector<BYTE> bByte(bufferSize + 4, 0);
if (WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, this->wString, len + 1, (LPSTR)bByte.data(), bufferSize, NULL, &bUsedDefault) == 0)
{
if (WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, this->wString, len + 1, (LPSTR)bByte.data(), bufferSize, NULL, &bUsedDefault) == 0) {
cString = "";
return; // failed
}
@ -374,7 +371,7 @@ AITRIGGERTYPE{};
Data for ai trigger types
*/
struct AITRIGGERTYPE{
struct AITRIGGERTYPE {
CString ID; // ai trigger id
CString name; // param 1
CString teamtype1; // param 2
@ -400,7 +397,7 @@ struct AITRIGGERTYPE{
STDOBJECTDATA
Data for Trees, Units, Infantry, Aircraft & Structures
This should be used for painting procedure...
This should be used for painting procedure...
except if you want to draw the upgrades on buildings
*/
struct STDOBJECTDATA
@ -417,7 +414,7 @@ STRUCTURE
Data for a structure
*/
struct STRUCTURE{
struct STRUCTURE {
CString house; // 1
CString type; // 2
CString strength; // 3
@ -435,11 +432,11 @@ struct STRUCTURE{
CString upgrade3; // 15
CString flag3; // 16
CString flag4; // 17
unsigned deleted:1;
unsigned deleted : 1;
};
// structure data especially for painting
struct STRUCTUREPAINT{
struct STRUCTUREPAINT {
COLORREF col;
CString type;
short x;
@ -458,7 +455,7 @@ struct INFANTRY{};
Data for an infantry unit
*/
struct INFANTRY{
struct INFANTRY {
CString house; // 1
CString type; // 2
CString strength; // 3
@ -473,10 +470,10 @@ struct INFANTRY{
CString flag3; // 12
CString flag4; // 13
CString flag5; // 14
unsigned deleted:1;
unsigned deleted : 1;
};
struct UNIT{
struct UNIT {
CString house; // 1
CString type; // 2
CString strength; // 3
@ -491,12 +488,12 @@ struct UNIT{
CString flag4; // 12
CString flag5; // 13
CString flag6; // 14
unsigned deleted:1;
unsigned deleted : 1;
};
struct AIRCRAFT{
struct AIRCRAFT {
CString house; // 1
CString type; // 2
CString strength; // 3
@ -509,23 +506,23 @@ struct AIRCRAFT{
CString flag2; // 10
CString flag3; // 11
CString flag4; // 12
unsigned deleted:1;
unsigned deleted : 1;
};
struct TERRAIN{
struct TERRAIN {
CString type;
int x;
int y;
unsigned deleted:1;
unsigned deleted : 1;
};
// MW 08/07/01: Smudge
#ifdef SMUDGE_SUPP
struct SMUDGE{
struct SMUDGE {
CString type;
int x;
int y;
unsigned deleted:1;
unsigned deleted : 1;
};
#endif
@ -534,7 +531,7 @@ NODE
Data for a node
*/
struct NODE{
struct NODE {
CString house;
CString type;
CString x;
@ -555,95 +552,89 @@ struct RA2STRFILEHEAD
struct RA2STRINGENTRY
{
RA2STRINGENTRY(){
RA2STRINGENTRY() {
//memset(this, 0, sizeof(RA2STRINGENTRY));
id=NULL;
value=NULL;
value_asc=0;
value_asc_size=0;
id = NULL;
value = NULL;
value_asc = 0;
value_asc_size = 0;
dwFlag = 0;
id_size = 0;
value_size = 0;
}
~RA2STRINGENTRY(){
if(value) delete[] value;
if(id) delete[] id;
if(value_asc) delete[] value_asc;
value=NULL;
value_size=0;
id=NULL;
id_size=0;
value_asc=0;
value_asc_size=0;
~RA2STRINGENTRY() {
if (value) delete[] value;
if (id) delete[] id;
if (value_asc) delete[] value_asc;
value = NULL;
value_size = 0;
id = NULL;
id_size = 0;
value_asc = 0;
value_asc_size = 0;
}
RA2STRINGENTRY(RA2STRINGENTRY& ref)
{
value=NULL;
value_size=0;
id=NULL;
value = NULL;
value_size = 0;
id = NULL;
id_size = 0;
value_asc=0;
value_asc_size=0;
if(ref.value_size && ref.value)
{
value_size=ref.value_size;
value=new(WCHAR[value_size+1]);
memcpy(value, ref.value, value_size*sizeof(WCHAR));
value[value_size]=0;
value_asc = 0;
value_asc_size = 0;
if (ref.value_size && ref.value) {
value_size = ref.value_size;
value = new(WCHAR[value_size + 1]);
memcpy(value, ref.value, value_size * sizeof(WCHAR));
value[value_size] = 0;
}
if(ref.id_size && ref.id)
{
id_size=ref.id_size;
id=new(CHAR[id_size+1]);
memcpy(id, ref.id, id_size*sizeof(CHAR));
id[id_size]=0;
if (ref.id_size && ref.id) {
id_size = ref.id_size;
id = new(CHAR[id_size + 1]);
memcpy(id, ref.id, id_size * sizeof(CHAR));
id[id_size] = 0;
}
if(ref.value_asc_size && ref.value_asc)
{
value_asc_size=ref.value_asc_size;
value_asc=new(CHAR[value_asc_size+1]);
memcpy(value_asc, ref.value_asc, value_asc_size*sizeof(CHAR));
value_asc[value_asc_size]=0;
if (ref.value_asc_size && ref.value_asc) {
value_asc_size = ref.value_asc_size;
value_asc = new(CHAR[value_asc_size + 1]);
memcpy(value_asc, ref.value_asc, value_asc_size * sizeof(CHAR));
value_asc[value_asc_size] = 0;
}
dwFlag=ref.dwFlag;
dwFlag = ref.dwFlag;
}
RA2STRINGENTRY& operator=(RA2STRINGENTRY& ref)
{
if(value) delete[] value;
if(id) delete[] id;
value=NULL;
value_size=0;
id=NULL;
value_asc=0;
value_asc_size=0;
if(ref.value_size)
{
value_size=ref.value_size;
value=new(WCHAR[value_size+1]);
memcpy(value, ref.value, value_size*sizeof(WCHAR));
value[value_size]=0;
if (value) delete[] value;
if (id) delete[] id;
value = NULL;
value_size = 0;
id = NULL;
value_asc = 0;
value_asc_size = 0;
if (ref.value_size) {
value_size = ref.value_size;
value = new(WCHAR[value_size + 1]);
memcpy(value, ref.value, value_size * sizeof(WCHAR));
value[value_size] = 0;
}
if(ref.id_size)
{
id_size=ref.id_size;
id=new(CHAR[id_size+1]);
memcpy(id, ref.id, id_size*sizeof(CHAR));
id[id_size]=0;
if (ref.id_size) {
id_size = ref.id_size;
id = new(CHAR[id_size + 1]);
memcpy(id, ref.id, id_size * sizeof(CHAR));
id[id_size] = 0;
}
if(ref.value_asc_size)
{
value_asc_size=ref.value_asc_size;
value_asc=new(CHAR[value_asc_size+1]);
memcpy(value_asc, ref.value_asc, value_asc_size*sizeof(CHAR));
value_asc[value_asc_size]=0;
if (ref.value_asc_size) {
value_asc_size = ref.value_asc_size;
value_asc = new(CHAR[value_asc_size + 1]);
memcpy(value_asc, ref.value_asc, value_asc_size * sizeof(CHAR));
value_asc[value_asc_size] = 0;
}
dwFlag=ref.dwFlag;
dwFlag = ref.dwFlag;
return *this;
}
DWORD dwFlag;
CHAR* id;
DWORD id_size;