forked from Mirrors/openclonk
Fix misleading indentation on several controlled statements
The C++ standard doesn't require us to stuff multiple statements onto the same line, so we should avoid this for readability reasons. This is especially true if one of the statements is controlled and others aren't.master
parent
dca6d2caaf
commit
3edc6d9ead
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "C4Version.h"
|
#include "C4Version.h"
|
||||||
#include "lib/C4InputValidation.h"
|
#include "lib/C4InputValidation.h"
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
struct C4GameVersion
|
struct C4GameVersion
|
||||||
{
|
{
|
||||||
|
@ -51,8 +52,11 @@ struct C4GameVersion
|
||||||
inline int CompareVersion(int iVer1, int iVer2,
|
inline int CompareVersion(int iVer1, int iVer2,
|
||||||
int iRVer1 = C4XVER1, int iRVer2 = C4XVER2)
|
int iRVer1 = C4XVER1, int iRVer2 = C4XVER2)
|
||||||
{
|
{
|
||||||
if (iVer1 > iRVer1) return 1; if (iVer1 < iRVer1) return -1;
|
auto ver = std::make_pair(iVer1, iVer2);
|
||||||
if (iVer2 > iRVer2) return 1; if (iVer2 < iRVer2) return -1;
|
auto rVer = std::make_pair(iRVer1, iRVer2);
|
||||||
|
|
||||||
|
if (ver < rVer) return -1;
|
||||||
|
if (ver > rVer) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,14 @@ bool C4FacetSurface::Create(int iWdt, int iHgt, int iWdt2, int iHgt2)
|
||||||
Face.Default();
|
Face.Default();
|
||||||
if (!Face.Create(iWdt,iHgt)) return false;
|
if (!Face.Create(iWdt,iHgt)) return false;
|
||||||
// Set facet
|
// Set facet
|
||||||
if (iWdt2==C4FCT_Full) iWdt2=Face.Wdt; if (iWdt2==C4FCT_Height) iWdt2=Face.Hgt; if (iWdt2==C4FCT_Width) iWdt2=Face.Wdt;
|
if (iWdt2 == C4FCT_Full || iWdt2 == C4FCT_Width)
|
||||||
if (iHgt2==C4FCT_Full) iHgt2=Face.Hgt; if (iHgt2==C4FCT_Height) iHgt2=Face.Hgt; if (iHgt2==C4FCT_Width) iHgt2=Face.Wdt;
|
iWdt2 = Face.Wdt;
|
||||||
|
else if (iWdt2 == C4FCT_Height)
|
||||||
|
iWdt2 = Face.Hgt;
|
||||||
|
if (iHgt2 == C4FCT_Full || iHgt2 == C4FCT_Height)
|
||||||
|
iHgt2 = Face.Hgt;
|
||||||
|
else if (iHgt2 == C4FCT_Width)
|
||||||
|
iHgt2 = Face.Wdt;
|
||||||
Set(&Face,0,0,iWdt2,iHgt2);
|
Set(&Face,0,0,iWdt2,iHgt2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -96,8 +102,14 @@ bool C4FacetSurface::Load(C4Group &hGroup, const char *szName, int iWdt, int iHg
|
||||||
// Load surface
|
// Load surface
|
||||||
if (!Face.Load(hGroup,szFilename,false,fNoErrIfNotFound, iFlags)) return false;
|
if (!Face.Load(hGroup,szFilename,false,fNoErrIfNotFound, iFlags)) return false;
|
||||||
// Set facet
|
// Set facet
|
||||||
if (iWdt==C4FCT_Full) iWdt=Face.Wdt; if (iWdt==C4FCT_Height) iWdt=Face.Hgt; if (iWdt==C4FCT_Width) iWdt=Face.Wdt;
|
if (iWdt == C4FCT_Full || iWdt == C4FCT_Width)
|
||||||
if (iHgt==C4FCT_Full) iHgt=Face.Hgt; if (iHgt==C4FCT_Height) iHgt=Face.Hgt; if (iHgt==C4FCT_Width) iHgt=Face.Wdt;
|
iWdt = Face.Wdt;
|
||||||
|
else if (iWdt == C4FCT_Height)
|
||||||
|
iWdt = Face.Hgt;
|
||||||
|
if (iHgt == C4FCT_Full || iHgt == C4FCT_Height)
|
||||||
|
iHgt = Face.Hgt;
|
||||||
|
else if (iHgt == C4FCT_Width)
|
||||||
|
iHgt = Face.Wdt;
|
||||||
Set(&Face,0,0,iWdt,iHgt);
|
Set(&Face,0,0,iWdt,iHgt);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,9 @@ void CPNGFile::Clear()
|
||||||
// clear internal png ptrs
|
// clear internal png ptrs
|
||||||
ClearPngStructs();
|
ClearPngStructs();
|
||||||
// free file ptr if owned
|
// free file ptr if owned
|
||||||
if (pFile && fpFileOwned) delete [] pFile; pFile=nullptr;
|
if (fpFileOwned)
|
||||||
|
delete [] pFile;
|
||||||
|
pFile=nullptr;
|
||||||
// reset fields
|
// reset fields
|
||||||
fpFileOwned=false;
|
fpFileOwned=false;
|
||||||
pFilePtr=nullptr;
|
pFilePtr=nullptr;
|
||||||
|
|
|
@ -142,7 +142,8 @@ namespace
|
||||||
d = 2 * dx - dy; aincr = 2 * (dx - dy); bincr = 2 * dx; x = x1; y = y1;
|
d = 2 * dx - dy; aincr = 2 * (dx - dy); bincr = 2 * dx; x = x1; y = y1;
|
||||||
if (!fnCallback(x, y))
|
if (!fnCallback(x, y))
|
||||||
{
|
{
|
||||||
if (lastx) *lastx = x; if (lasty) *lasty = y;
|
if (lastx) *lastx = x;
|
||||||
|
if (lasty) *lasty = y;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (y = y1 + 1; y <= y2; ++y)
|
for (y = y1 + 1; y <= y2; ++y)
|
||||||
|
@ -151,7 +152,8 @@ namespace
|
||||||
else d += bincr;
|
else d += bincr;
|
||||||
if (!fnCallback(x, y))
|
if (!fnCallback(x, y))
|
||||||
{
|
{
|
||||||
if (lastx) *lastx = x; if (lasty) *lasty = y;
|
if (lastx) *lastx = x;
|
||||||
|
if (lasty) *lasty = y;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +166,8 @@ namespace
|
||||||
d = 2 * dy - dx; aincr = 2 * (dy - dx); bincr = 2 * dy; x = x1; y = y1;
|
d = 2 * dy - dx; aincr = 2 * (dy - dx); bincr = 2 * dy; x = x1; y = y1;
|
||||||
if (!fnCallback(x, y))
|
if (!fnCallback(x, y))
|
||||||
{
|
{
|
||||||
if (lastx) *lastx = x; if (lasty) *lasty = y;
|
if (lastx) *lastx = x;
|
||||||
|
if (lasty) *lasty = y;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (x = x1 + 1; x <= x2; ++x)
|
for (x = x1 + 1; x <= x2; ++x)
|
||||||
|
@ -173,7 +176,8 @@ namespace
|
||||||
else d += bincr;
|
else d += bincr;
|
||||||
if (!fnCallback(x, y))
|
if (!fnCallback(x, y))
|
||||||
{
|
{
|
||||||
if (lastx) *lastx = x; if (lasty) *lasty = y;
|
if (lastx) *lastx = x;
|
||||||
|
if (lasty) *lasty = y;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -944,7 +944,7 @@ C4MCParser::~C4MCParser()
|
||||||
void C4MCParser::Clear()
|
void C4MCParser::Clear()
|
||||||
{
|
{
|
||||||
// clear code if present
|
// clear code if present
|
||||||
if (Code) delete [] Code; Code=nullptr; BPos = nullptr; CPos=nullptr;
|
delete [] Code; Code=nullptr; BPos = nullptr; CPos=nullptr;
|
||||||
// reset filename
|
// reset filename
|
||||||
*Filename=0;
|
*Filename=0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,8 @@ C4MapScriptAlgoTurbulence::C4MapScriptAlgoTurbulence(const C4PropList *props) :
|
||||||
if (!seed) seed = Random(65536);
|
if (!seed) seed = Random(65536);
|
||||||
GetXYProps(props, P_Amplitude, amp, true);
|
GetXYProps(props, P_Amplitude, amp, true);
|
||||||
GetXYProps(props, P_Scale, scale, true);
|
GetXYProps(props, P_Scale, scale, true);
|
||||||
if (!scale[0]) scale[0] = 10; if (!scale[1]) scale[1] = 10;
|
if (!scale[0]) scale[0] = 10;
|
||||||
|
if (!scale[1]) scale[1] = 10;
|
||||||
if (!amp[0] && !amp[1]) { amp[0] = amp[1] = 10; }
|
if (!amp[0] && !amp[1]) { amp[0] = amp[1] = 10; }
|
||||||
iterations = props->GetPropertyInt(P_Iterations);
|
iterations = props->GetPropertyInt(P_Iterations);
|
||||||
if (!iterations) iterations = 2;
|
if (!iterations) iterations = 2;
|
||||||
|
|
|
@ -312,7 +312,7 @@ C4MaterialMap::~C4MaterialMap()
|
||||||
|
|
||||||
void C4MaterialMap::Clear()
|
void C4MaterialMap::Clear()
|
||||||
{
|
{
|
||||||
if (Map) delete [] Map; Map=nullptr; Num=0;
|
delete [] Map; Map=nullptr; Num=0;
|
||||||
delete [] ppReactionMap; ppReactionMap = nullptr;
|
delete [] ppReactionMap; ppReactionMap = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,10 @@ bool OpenExtraLogs()
|
||||||
bool CloseLog()
|
bool CloseLog()
|
||||||
{
|
{
|
||||||
// close
|
// close
|
||||||
if (C4ShaderLogFile) fclose(C4ShaderLogFile); C4ShaderLogFile = nullptr;
|
if (C4ShaderLogFile) fclose(C4ShaderLogFile);
|
||||||
if (C4LogFile) fclose(C4LogFile); C4LogFile = nullptr;
|
C4ShaderLogFile = nullptr;
|
||||||
|
if (C4LogFile) fclose(C4LogFile);
|
||||||
|
C4LogFile = nullptr;
|
||||||
// ok
|
// ok
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,9 @@ int32_t StrToI32(const char *str, int base, const char **scan_end)
|
||||||
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
|
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
|
||||||
{
|
{
|
||||||
if (szSource == sTarget) return;
|
if (szSource == sTarget) return;
|
||||||
if (!sTarget) return; *sTarget=0; if (!szSource) return;
|
if (!sTarget) return;
|
||||||
|
*sTarget=0;
|
||||||
|
if (!szSource) return;
|
||||||
while (*szSource && (iMaxL>0))
|
while (*szSource && (iMaxL>0))
|
||||||
{ *sTarget=*szSource; iMaxL--; szSource++; sTarget++; }
|
{ *sTarget=*szSource; iMaxL--; szSource++; sTarget++; }
|
||||||
*sTarget=0;
|
*sTarget=0;
|
||||||
|
@ -161,14 +163,18 @@ void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
|
||||||
void SCopy(const char *szSource, char *sTarget)
|
void SCopy(const char *szSource, char *sTarget)
|
||||||
{
|
{
|
||||||
if (szSource == sTarget) return;
|
if (szSource == sTarget) return;
|
||||||
if (!sTarget) return; *sTarget=0; if (!szSource) return;
|
if (!sTarget) return;
|
||||||
strcpy(sTarget,szSource);
|
*sTarget=0;
|
||||||
|
if (!szSource) return;
|
||||||
|
strcpy(sTarget,szSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCopyUntil(const char *szSource, char *sTarget, char cUntil, int iMaxL, int iIndex)
|
void SCopyUntil(const char *szSource, char *sTarget, char cUntil, int iMaxL, int iIndex)
|
||||||
{
|
{
|
||||||
if (szSource == sTarget) return;
|
if (szSource == sTarget) return;
|
||||||
if (!sTarget) return; *sTarget=0; if (!szSource) return;
|
if (!sTarget) return;
|
||||||
|
*sTarget=0;
|
||||||
|
if (!szSource) return;
|
||||||
while ( *szSource && ((*szSource!=cUntil) || (iIndex>0)) && (iMaxL!=0) )
|
while ( *szSource && ((*szSource!=cUntil) || (iIndex>0)) && (iMaxL!=0) )
|
||||||
{ *sTarget=*szSource; if (*szSource==cUntil) iIndex--; szSource++; sTarget++; iMaxL--; }
|
{ *sTarget=*szSource; if (*szSource==cUntil) iIndex--; szSource++; sTarget++; iMaxL--; }
|
||||||
*sTarget=0;
|
*sTarget=0;
|
||||||
|
|
|
@ -139,7 +139,9 @@ inline DWORD GetClrModulation(DWORD dwSrcClr, DWORD dwDstClr, DWORD &dwBack)
|
||||||
int bB=sB+(cB*255)/diffN;
|
int bB=sB+(cB*255)/diffN;
|
||||||
dwBack=RGBA(bR, bG, bB, 255);
|
dwBack=RGBA(bR, bG, bB, 255);
|
||||||
}
|
}
|
||||||
if (!sR) sR=1; if (!sG) sG=1; if (!sB) sB=1;
|
if (!sR) sR=1;
|
||||||
|
if (!sG) sG=1;
|
||||||
|
if (!sB) sB=1;
|
||||||
return RGBA(std::min((int)dR*256/sR, 255), std::min((int)dG*256/sG, 255), std::min((int)dB*256/sB, 255), 255-diffN);
|
return RGBA(std::min((int)dR*256/sR, 255), std::min((int)dG*256/sG, 255), std::min((int)dB*256/sB, 255), 255-diffN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2053,7 +2053,8 @@ bool C4Network2::InitLeague(bool *pCancel)
|
||||||
MasterServerAddress.Clear();
|
MasterServerAddress.Clear();
|
||||||
Game.Parameters.League.Clear();
|
Game.Parameters.League.Clear();
|
||||||
Game.Parameters.LeagueAddress.Clear();
|
Game.Parameters.LeagueAddress.Clear();
|
||||||
if (pLeagueClient) delete pLeagueClient; pLeagueClient = nullptr;
|
delete pLeagueClient;
|
||||||
|
pLeagueClient = nullptr;
|
||||||
|
|
||||||
// Not needed?
|
// Not needed?
|
||||||
if (!Config.Network.MasterServerSignUp && !Config.Network.LeagueServerSignUp)
|
if (!Config.Network.MasterServerSignUp && !Config.Network.LeagueServerSignUp)
|
||||||
|
|
|
@ -527,7 +527,8 @@ C4Network2ClientListDlg::C4Network2ClientListDlg()
|
||||||
|
|
||||||
C4Network2ClientListDlg::~C4Network2ClientListDlg()
|
C4Network2ClientListDlg::~C4Network2ClientListDlg()
|
||||||
{
|
{
|
||||||
if (this==pInstance) pInstance=nullptr; Application.Remove(this);
|
if (this==pInstance) pInstance=nullptr;
|
||||||
|
Application.Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4Network2ClientListDlg::Update()
|
void C4Network2ClientListDlg::Update()
|
||||||
|
|
|
@ -831,7 +831,8 @@ bool C4Network2IO::doAutoAccept(const C4ClientCore &CCore, const C4Network2IOCon
|
||||||
bool C4Network2IO::HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnection *pConn, bool fThread)
|
bool C4Network2IO::HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnection *pConn, bool fThread)
|
||||||
{
|
{
|
||||||
// security: add connection reference
|
// security: add connection reference
|
||||||
if (!pConn) return false; pConn->AddRef();
|
if (!pConn) return false;
|
||||||
|
pConn->AddRef();
|
||||||
|
|
||||||
// accept only PID_Conn and PID_Ping on non-accepted connections
|
// accept only PID_Conn and PID_Ping on non-accepted connections
|
||||||
if(!pConn->isHalfAccepted())
|
if(!pConn->isHalfAccepted())
|
||||||
|
|
|
@ -625,7 +625,8 @@ bool C4Network2Res::GetStandalone(char *pTo, int32_t iMaxL, bool fSetOfficial, b
|
||||||
if (!fSetOfficial && iSize != Core.getFileSize())
|
if (!fSetOfficial && iSize != Core.getFileSize())
|
||||||
{
|
{
|
||||||
// remove file
|
// remove file
|
||||||
if (!SEqual(szFile, szStandalone)) EraseItem(szStandalone); szStandalone[0] = '\0';
|
if (!SEqual(szFile, szStandalone)) EraseItem(szStandalone);
|
||||||
|
szStandalone[0] = '\0';
|
||||||
// sorry, this version isn't good enough :(
|
// sorry, this version isn't good enough :(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -638,7 +639,8 @@ bool C4Network2Res::GetStandalone(char *pTo, int32_t iMaxL, bool fSetOfficial, b
|
||||||
if (!fSetOfficial && iCRC32 != Core.getFileCRC())
|
if (!fSetOfficial && iCRC32 != Core.getFileCRC())
|
||||||
{
|
{
|
||||||
// remove file, return
|
// remove file, return
|
||||||
if (!SEqual(szFile, szStandalone)) EraseItem(szStandalone); szStandalone[0] = '\0';
|
if (!SEqual(szFile, szStandalone)) EraseItem(szStandalone);
|
||||||
|
szStandalone[0] = '\0';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,8 @@ void C4IDPacket::Default()
|
||||||
|
|
||||||
void C4IDPacket::Clear()
|
void C4IDPacket::Clear()
|
||||||
{
|
{
|
||||||
if (fOwnPkt) delete pPkt; pPkt = nullptr;
|
if (fOwnPkt) delete pPkt;
|
||||||
|
pPkt = nullptr;
|
||||||
eID = PID_None;
|
eID = PID_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +236,8 @@ void C4IDPacket::CompileFunc(StdCompiler *pComp)
|
||||||
if (!pComp->Name(getPktName()))
|
if (!pComp->Name(getPktName()))
|
||||||
{ pComp->excCorrupt("C4IDPacket: Data value needed! Packet data missing!"); return; }
|
{ pComp->excCorrupt("C4IDPacket: Data value needed! Packet data missing!"); return; }
|
||||||
// Delete old packet
|
// Delete old packet
|
||||||
if (fOwnPkt) delete pPkt; pPkt = nullptr;
|
if (fOwnPkt) delete pPkt;
|
||||||
|
pPkt = nullptr;
|
||||||
if (eID == PID_None) return;
|
if (eID == PID_None) return;
|
||||||
// Search unpacking function
|
// Search unpacking function
|
||||||
for (const C4PktHandlingData *pPData = PktHandlingData; pPData->ID != PID_None; pPData++)
|
for (const C4PktHandlingData *pPData = PktHandlingData; pPData->ID != PID_None; pPData++)
|
||||||
|
|
|
@ -1464,7 +1464,8 @@ void C4Command::Clear()
|
||||||
Ty=0;
|
Ty=0;
|
||||||
Target=Target2=nullptr;
|
Target=Target2=nullptr;
|
||||||
UpdateInterval=0;
|
UpdateInterval=0;
|
||||||
if (Text) Text->DecRef(); Text=nullptr;
|
if (Text) Text->DecRef();
|
||||||
|
Text=nullptr;
|
||||||
BaseMode=C4CMD_Mode_SilentSub;
|
BaseMode=C4CMD_Mode_SilentSub;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -327,9 +327,19 @@ void C4Def::Clear()
|
||||||
Graphics.Clear();
|
Graphics.Clear();
|
||||||
|
|
||||||
StringTable.Clear();
|
StringTable.Clear();
|
||||||
if (pClonkNames && fClonkNamesOwned) delete pClonkNames; pClonkNames=nullptr;
|
|
||||||
if (pRankNames && fRankNamesOwned) delete pRankNames; pRankNames=nullptr;
|
if (fClonkNamesOwned)
|
||||||
if (pRankSymbols && fRankSymbolsOwned) delete pRankSymbols; pRankSymbols=nullptr;
|
delete pClonkNames;
|
||||||
|
pClonkNames = nullptr;
|
||||||
|
|
||||||
|
if (fRankNamesOwned)
|
||||||
|
delete pRankNames;
|
||||||
|
pRankNames = nullptr;
|
||||||
|
|
||||||
|
if (fRankSymbolsOwned)
|
||||||
|
delete pRankSymbols;
|
||||||
|
pRankSymbols = nullptr;
|
||||||
|
|
||||||
fClonkNamesOwned = fRankNamesOwned = fRankSymbolsOwned = false;
|
fClonkNamesOwned = fRankNamesOwned = fRankSymbolsOwned = false;
|
||||||
delete pSolidMask; pSolidMask = nullptr;
|
delete pSolidMask; pSolidMask = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +538,7 @@ void C4Def::LoadScript(C4Group &hGroup, const char* szLanguage)
|
||||||
void C4Def::LoadClonkNames(C4Group &hGroup, C4ComponentHost* pClonkNames, const char* szLanguage)
|
void C4Def::LoadClonkNames(C4Group &hGroup, C4ComponentHost* pClonkNames, const char* szLanguage)
|
||||||
{
|
{
|
||||||
// clear any previous
|
// clear any previous
|
||||||
if (pClonkNames) delete pClonkNames; pClonkNames = nullptr;
|
delete pClonkNames; pClonkNames = nullptr;
|
||||||
if (hGroup.FindEntry(C4CFN_ClonkNameFiles))
|
if (hGroup.FindEntry(C4CFN_ClonkNameFiles))
|
||||||
{
|
{
|
||||||
// create new
|
// create new
|
||||||
|
@ -545,7 +555,7 @@ void C4Def::LoadClonkNames(C4Group &hGroup, C4ComponentHost* pClonkNames, const
|
||||||
void C4Def::LoadRankNames(C4Group &hGroup, const char* szLanguage)
|
void C4Def::LoadRankNames(C4Group &hGroup, const char* szLanguage)
|
||||||
{
|
{
|
||||||
// clear any previous
|
// clear any previous
|
||||||
if (pRankNames) delete pRankNames; pRankNames = nullptr;
|
delete pRankNames; pRankNames = nullptr;
|
||||||
if (hGroup.FindEntry(C4CFN_RankNameFiles))
|
if (hGroup.FindEntry(C4CFN_RankNameFiles))
|
||||||
{
|
{
|
||||||
// create new
|
// create new
|
||||||
|
@ -563,7 +573,7 @@ void C4Def::LoadRankNames(C4Group &hGroup, const char* szLanguage)
|
||||||
void C4Def::LoadRankFaces(C4Group &hGroup)
|
void C4Def::LoadRankFaces(C4Group &hGroup)
|
||||||
{
|
{
|
||||||
// clear any previous
|
// clear any previous
|
||||||
if (pRankSymbols) delete pRankSymbols; pRankSymbols = nullptr;
|
delete pRankSymbols; pRankSymbols = nullptr;
|
||||||
// load new
|
// load new
|
||||||
if (hGroup.AccessEntry(C4CFN_RankFacesPNG))
|
if (hGroup.AccessEntry(C4CFN_RankFacesPNG))
|
||||||
{
|
{
|
||||||
|
|
|
@ -2437,19 +2437,19 @@ void C4Object::Clear()
|
||||||
{
|
{
|
||||||
ClearParticleLists();
|
ClearParticleLists();
|
||||||
|
|
||||||
if (pEffects) { delete pEffects; pEffects=nullptr; }
|
delete pEffects; pEffects = nullptr;
|
||||||
if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; }
|
delete pSolidMaskData; pSolidMaskData = nullptr;
|
||||||
if (Menu) delete Menu; Menu=nullptr;
|
delete Menu; Menu = nullptr;
|
||||||
if (MaterialContents) delete MaterialContents; MaterialContents=nullptr;
|
delete MaterialContents; MaterialContents = nullptr;
|
||||||
// clear commands!
|
// clear commands!
|
||||||
C4Command *pCom, *pNext;
|
C4Command *pCom, *pNext;
|
||||||
for (pCom=Command; pCom; pCom=pNext)
|
for (pCom=Command; pCom; pCom=pNext)
|
||||||
{
|
{
|
||||||
pNext=pCom->Next; delete pCom; pCom=pNext;
|
pNext=pCom->Next; delete pCom; pCom=pNext;
|
||||||
}
|
}
|
||||||
if (pDrawTransform) { delete pDrawTransform; pDrawTransform=nullptr; }
|
delete pDrawTransform; pDrawTransform = nullptr;
|
||||||
if (pGfxOverlay) { delete pGfxOverlay; pGfxOverlay=nullptr; }
|
delete pGfxOverlay; pGfxOverlay = nullptr;
|
||||||
if (pMeshInstance) { delete pMeshInstance; pMeshInstance = nullptr; }
|
delete pMeshInstance; pMeshInstance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4Object::MenuCommand(const char *szCommand)
|
bool C4Object::MenuCommand(const char *szCommand)
|
||||||
|
@ -2504,7 +2504,7 @@ void C4Object::SyncClearance()
|
||||||
// Menu
|
// Menu
|
||||||
CloseMenu(true);
|
CloseMenu(true);
|
||||||
// Material contents
|
// Material contents
|
||||||
if (MaterialContents) delete MaterialContents; MaterialContents=nullptr;
|
delete MaterialContents; MaterialContents=nullptr;
|
||||||
// reset speed of staticback-objects
|
// reset speed of staticback-objects
|
||||||
if (Category & C4D_StaticBack)
|
if (Category & C4D_StaticBack)
|
||||||
{
|
{
|
||||||
|
@ -3430,11 +3430,13 @@ void C4Object::ExecAction()
|
||||||
case COMD_Up: case COMD_UpRight: case COMD_UpLeft:
|
case COMD_Up: case COMD_UpRight: case COMD_UpLeft:
|
||||||
if (ydir > 0) ydir -= decel;
|
if (ydir > 0) ydir -= decel;
|
||||||
else ydir -= accel;
|
else ydir -= accel;
|
||||||
if (ydir < -limit) ydir = -limit; break;
|
if (ydir < -limit) ydir = -limit;
|
||||||
|
break;
|
||||||
case COMD_Down: case COMD_DownRight: case COMD_DownLeft:
|
case COMD_Down: case COMD_DownRight: case COMD_DownLeft:
|
||||||
if (ydir < 0) ydir += decel;
|
if (ydir < 0) ydir += decel;
|
||||||
else ydir += accel;
|
else ydir += accel;
|
||||||
if (ydir > +limit) ydir = +limit; break;
|
if (ydir > +limit) ydir = +limit;
|
||||||
|
break;
|
||||||
case COMD_Left: case COMD_Right: case COMD_Stop:
|
case COMD_Left: case COMD_Right: case COMD_Stop:
|
||||||
if (ydir < 0) ydir += decel;
|
if (ydir < 0) ydir += decel;
|
||||||
if (ydir > 0) ydir -= decel;
|
if (ydir > 0) ydir -= decel;
|
||||||
|
@ -3561,8 +3563,8 @@ void C4Object::ExecAction()
|
||||||
// xdir/ydir bounds, don't apply if COMD_None
|
// xdir/ydir bounds, don't apply if COMD_None
|
||||||
if (Action.ComDir != COMD_None)
|
if (Action.ComDir != COMD_None)
|
||||||
{
|
{
|
||||||
if (ydir<-limit) ydir=-limit; if (ydir>+limit) ydir=+limit;
|
ydir = Clamp(ydir, -limit, limit);
|
||||||
if (xdir>+limit) xdir=+limit; if (xdir<-limit) xdir=-limit;
|
xdir = Clamp(xdir, -limit, limit);
|
||||||
}
|
}
|
||||||
// Surface dir bound
|
// Surface dir bound
|
||||||
if (!GBackLiquid(GetX(),GetY()-1+Def->Float*Con/FullCon-1)) if (ydir<0) ydir=0;
|
if (!GBackLiquid(GetX(),GetY()-1+Def->Float*Con/FullCon-1)) if (ydir<0) ydir=0;
|
||||||
|
@ -3635,8 +3637,17 @@ void C4Object::ExecAction()
|
||||||
if (GetY()-iPushDistance > say+sahgt && iTXDir) { if (iTXDir>0) sax+=sawdt/2; sawdt/=2; }
|
if (GetY()-iPushDistance > say+sahgt && iTXDir) { if (iTXDir>0) sax+=sawdt/2; sawdt/=2; }
|
||||||
// Horizontal follow
|
// Horizontal follow
|
||||||
iTargetX=Clamp(GetX(),sax-iPushDistance,sax+sawdt-1+iPushDistance);
|
iTargetX=Clamp(GetX(),sax-iPushDistance,sax+sawdt-1+iPushDistance);
|
||||||
if (GetX()==iTargetX) xdir=0;
|
if (GetX()==iTargetX)
|
||||||
else { if (GetX()<iTargetX) xdir=+limit; if (GetX()>iTargetX) xdir=-limit; }
|
{
|
||||||
|
xdir=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GetX()<iTargetX)
|
||||||
|
xdir=+limit;
|
||||||
|
else if (GetX()>iTargetX)
|
||||||
|
xdir=-limit;
|
||||||
|
}
|
||||||
// Phase by XDir
|
// Phase by XDir
|
||||||
iPhaseAdvance=0;
|
iPhaseAdvance=0;
|
||||||
if (xdir<0) { iPhaseAdvance=-fixtoi(xdir*10); SetDir(DIR_Left); }
|
if (xdir<0) { iPhaseAdvance=-fixtoi(xdir*10); SetDir(DIR_Left); }
|
||||||
|
@ -3794,8 +3805,8 @@ void C4Object::ExecAction()
|
||||||
// xdir/ydir bounds, don't apply if COMD_None
|
// xdir/ydir bounds, don't apply if COMD_None
|
||||||
if (Action.ComDir != COMD_None)
|
if (Action.ComDir != COMD_None)
|
||||||
{
|
{
|
||||||
if (ydir<-limit) ydir=-limit; if (ydir>+limit) ydir=+limit;
|
ydir = Clamp(ydir, -limit, limit);
|
||||||
if (xdir>+limit) xdir=+limit; if (xdir<-limit) xdir=-limit;
|
xdir = Clamp(xdir, -limit, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mobile=true;
|
Mobile=true;
|
||||||
|
@ -4111,7 +4122,8 @@ bool C4Object::IsInLiquidCheck() const
|
||||||
|
|
||||||
void C4Object::SetRotation(int32_t nr)
|
void C4Object::SetRotation(int32_t nr)
|
||||||
{
|
{
|
||||||
while (nr<0) nr+=360; nr%=360;
|
while (nr<0) nr+=360;
|
||||||
|
nr%=360;
|
||||||
// remove solid mask
|
// remove solid mask
|
||||||
if (pSolidMaskData) pSolidMaskData->Remove(false);
|
if (pSolidMaskData) pSolidMaskData->Remove(false);
|
||||||
// set rotation
|
// set rotation
|
||||||
|
@ -4194,7 +4206,8 @@ bool C4Object::Collect(C4Object *pObj)
|
||||||
bool C4Object::GrabInfo(C4Object *pFrom)
|
bool C4Object::GrabInfo(C4Object *pFrom)
|
||||||
{
|
{
|
||||||
// safety
|
// safety
|
||||||
if (!pFrom) return false; if (!Status || !pFrom->Status) return false;
|
if (!pFrom) return false;
|
||||||
|
if (!Status || !pFrom->Status) return false;
|
||||||
// even more safety (own info: success)
|
// even more safety (own info: success)
|
||||||
if (pFrom == this) return true;
|
if (pFrom == this) return true;
|
||||||
// only if other object has info
|
// only if other object has info
|
||||||
|
|
|
@ -115,7 +115,8 @@ static bool FnPunch(C4Object *Obj, C4Object *target, long punch)
|
||||||
|
|
||||||
static bool FnKill(C4PropList * _this, C4Object *pObj, bool fForced)
|
static bool FnKill(C4PropList * _this, C4Object *pObj, bool fForced)
|
||||||
{
|
{
|
||||||
if (!pObj) pObj=Object(_this); if (!pObj) return false;
|
if (!pObj) pObj=Object(_this);
|
||||||
|
if (!pObj) return false;
|
||||||
if (!pObj->GetAlive()) return false;
|
if (!pObj->GetAlive()) return false;
|
||||||
// Trace kills by player-owned objects
|
// Trace kills by player-owned objects
|
||||||
// Do not trace for NO_OWNER, because that would include e.g. the Suicide-rule
|
// Do not trace for NO_OWNER, because that would include e.g. the Suicide-rule
|
||||||
|
@ -1274,7 +1275,8 @@ static long FnSetTransferZone(C4Object *Obj, long iX, long iY, long iWdt, long i
|
||||||
|
|
||||||
static long FnObjectDistance(C4PropList * _this, C4Object *pObj2, C4Object *pObj)
|
static long FnObjectDistance(C4PropList * _this, C4Object *pObj2, C4Object *pObj)
|
||||||
{
|
{
|
||||||
if (!pObj) pObj=Object(_this); if (!pObj || !pObj2) return 0;
|
if (!pObj) pObj=Object(_this);
|
||||||
|
if (!pObj || !pObj2) return 0;
|
||||||
return Distance(pObj->GetX(),pObj->GetY(),pObj2->GetX(),pObj2->GetY());
|
return Distance(pObj->GetX(),pObj->GetY(),pObj2->GetX(),pObj2->GetY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1286,7 +1288,8 @@ static long FnObjectNumber(C4Object *Obj)
|
||||||
|
|
||||||
static long FnShowInfo(C4Object *Obj, C4Object *pObj)
|
static long FnShowInfo(C4Object *Obj, C4Object *pObj)
|
||||||
{
|
{
|
||||||
if (!pObj) pObj=Obj; if (!pObj) return false;
|
if (!pObj) pObj=Obj;
|
||||||
|
if (!pObj) return false;
|
||||||
return Obj->ActivateMenu(C4MN_Info,0,0,0,pObj);
|
return Obj->ActivateMenu(C4MN_Info,0,0,0,pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1515,7 +1515,8 @@ int32_t C4Player::GetSelectedCrewCount()
|
||||||
void C4Player::EvaluateLeague(bool fDisconnected, bool fWon)
|
void C4Player::EvaluateLeague(bool fDisconnected, bool fWon)
|
||||||
{
|
{
|
||||||
// already evaluated?
|
// already evaluated?
|
||||||
if (LeagueEvaluated) return; LeagueEvaluated=true;
|
if (LeagueEvaluated) return;
|
||||||
|
LeagueEvaluated=true;
|
||||||
// set fate
|
// set fate
|
||||||
C4PlayerInfo *pInfo = GetInfo();
|
C4PlayerInfo *pInfo = GetInfo();
|
||||||
if (pInfo)
|
if (pInfo)
|
||||||
|
|
Loading…
Reference in New Issue