avoid lots of gcc warnings

stable-5.2
Benjamin Herr 2010-01-25 05:00:59 +01:00
parent 3ef547e58a
commit f3b35227ea
197 changed files with 1385 additions and 987 deletions

View File

@ -47,10 +47,14 @@
C4Application::C4Application():
isFullScreen(true), UseStartupDialog(true), launchEditor(false), restartAtEnd(false),
DDraw(NULL), AppState(C4AS_None),
isFullScreen(true),
UseStartupDialog(true),
CheckForUpdates(false),
NoSplash(false),
launchEditor(false),
restartAtEnd(false),
pGamePadControl(NULL),
CheckForUpdates(false), NoSplash(false)
DDraw(NULL), AppState(C4AS_None)
{
}
@ -129,7 +133,7 @@ bool C4Application::DoInit()
// Language override by parameter
const char *pLanguage;
if (pLanguage = SSearchNoCase(GetCommandLine(), "/Language:"))
if ((pLanguage = SSearchNoCase(GetCommandLine(), "/Language:")))
SCopyUntil(pLanguage, Config.General.LanguageEx, ' ', CFG_MaxString);
// Init external language packs
@ -402,9 +406,11 @@ void C4Application::QuitGame()
void C4Application::GameTick()
{
// Exec depending on game state
assert(AppState != C4AS_None);
switch (AppState)
{
case C4AS_None:
assert(AppState != C4AS_None);
break;
case C4AS_Quit:
// Do nothing, HandleMessage will return HR_Failure soon
break;
@ -551,8 +557,8 @@ void C4Application::NextTick()
// *** C4ApplicationGameTimer
C4ApplicationGameTimer::C4ApplicationGameTimer()
: iLastGameTick(0), iGameTickDelay(0),
CStdMultimediaTimerProc(26)
: CStdMultimediaTimerProc(26),
iLastGameTick(0), iGameTickDelay(0)
{
}

View File

@ -83,7 +83,7 @@ class C4Application: public CStdApp
bool SetGameFont(const char *szFontFace, int32_t iFontSize);
void NextTick();
protected:
enum State { C4AS_None, C4AS_PreInit, C4AS_Startup, C4AS_StartGame, C4AS_Game, C4AS_Quit, } AppState;
enum State { C4AS_None, C4AS_PreInit, C4AS_Startup, C4AS_StartGame, C4AS_Game, C4AS_Quit } AppState;
C4ApplicationGameTimer *pGameTimer;
protected:
@ -122,7 +122,7 @@ class C4ApplicationSec1Timer : protected CStdTimerProc
public:
C4ApplicationSec1Timer() : CStdTimerProc(1000) { }
virtual void OnSec1Timer() = 0;
private:
protected:
virtual bool Execute(int, pollfd *)
{
if(CheckAndReset())

View File

@ -440,7 +440,7 @@ bool C4FullScreen::ViewportCheck()
iPlrNum = NO_OWNER;
// Film mode: create viewport for first player (instead of no-owner)
if (fFilm)
if (pPlr = ::Players.First)
if ((pPlr = ::Players.First))
iPlrNum = pPlr->Number;
// Create viewport
Game.CreateViewport(iPlrNum, iPlrNum==NO_OWNER);

View File

@ -84,12 +84,16 @@ class C4GameSec1Timer : public C4ApplicationSec1Timer
};
C4Game::C4Game()
: Input(Control.Input), KeyboardInput(C4KeyboardInput_Init()), StartupLogPos(0), QuitLogPos(0), fQuitWithError(false), fPreinited(false),
: Clients(Parameters.Clients),
Teams(Parameters.Teams),
PlayerInfos(Parameters.PlayerInfos),
RestorePlayerInfos(Parameters.RestorePlayerInfos),
Clients(Parameters.Clients), pFileMonitor(NULL),
pSec1Timer(new C4GameSec1Timer())
Input(Control.Input),
KeyboardInput(C4KeyboardInput_Init()),
pFileMonitor(NULL),
pSec1Timer(new C4GameSec1Timer()),
fPreinited(false), StartupLogPos(0), QuitLogPos(0),
fQuitWithError(false)
{
Default();
}
@ -1457,7 +1461,7 @@ bool C4Game::DropFile(const char *szFilename, float iX, float iY)
if (SEqualNoCase(GetExtension(szFilename),"c4d"))
{
// Get id from file
if (c_id=DefFileGetID(szFilename))
if ((c_id=DefFileGetID(szFilename)))
// Get loaded def or try to load def from file
if ( (cdef=C4Id2Def(c_id))
|| (::Definitions.Load(szFilename,C4D_Load_RX,Config.General.LanguageEx,&Application.SoundSystem) && (cdef=C4Id2Def(c_id))) )
@ -1475,7 +1479,7 @@ bool C4Game::DropDef(C4ID id, float X, float Y)
{
// Get def
C4Def *pDef;
if (pDef=C4Id2Def(id))
if ((pDef=C4Id2Def(id)))
{
StdStrBuf str;
if (pDef->Category & C4D_Structure)
@ -2014,7 +2018,7 @@ bool C4Game::ReloadFile(const char *szFile)
const char *szRelativePath = Config.AtRelativePath(szFile);
// a definition? or part of a definition?
C4Def *pDef;
if(pDef = ::Definitions.GetByPath(szRelativePath))
if((pDef = ::Definitions.GetByPath(szRelativePath)))
return ReloadDef(pDef->id);
// script?
if(ScriptEngine.ReloadScript(szRelativePath, &::Definitions))
@ -2215,6 +2219,7 @@ bool C4Game::InitGame(C4Group &hGroup, bool fLoadSection, bool fLoadSky)
// Load round results
if (!fLoadSection)
{
if (hGroup.FindEntry(C4CFN_RoundResults))
{
if (!RoundResults.Load(hGroup, C4CFN_RoundResults))
@ -2224,6 +2229,7 @@ bool C4Game::InitGame(C4Group &hGroup, bool fLoadSection, bool fLoadSky)
{
RoundResults.Init();
}
}
// Environment
if (!C4S.Head.NoInitialize && fLandscapeLoaded)
@ -2901,7 +2907,7 @@ bool C4Game::LoadScenarioComponents()
int32_t iWildcardPos = SCharPos('*', C4CFN_ScenarioSections);
SCopy(fn + iWildcardPos, SctName, _MAX_FNAME);
RemoveExtension(SctName);
if (SLen(SctName)>C4MaxName || !*SctName)
if (std::strlen(SctName)>C4MaxName || !*SctName)
{
DebugLog("invalid section name");
LogFatal(FormatString(LoadResStr("IDS_ERR_SCENSECTION"), fn).getData()); return false;
@ -3172,12 +3178,12 @@ bool C4Game::DefinitionFilenamesFromSaveGame()
szDefinitionFilenames[0]=0;
// Use loaded game text component
if (pSource = GameText.GetData())
if ((pSource = GameText.GetData()))
{
const char *szPos;
char szLinebuf[30+_MAX_PATH+1];
// Search def file name section
if (szPos = SSearch((const char*)pSource,"[DefinitionFiles]"))
if ((szPos = SSearch((const char*)pSource,"[DefinitionFiles]")))
// Scan lines
while (true)
{
@ -3481,7 +3487,7 @@ const char* C4Game::FoldersWithLocalsDefs(const char *szPath)
// do not, however, add them to the group set:
// parent folders are added by OpenScenario already!
int32_t iContents;
if (iContents = GroupSet.CheckGroupContents(hGroup, C4GSCnt_Definitions))
if ((iContents = GroupSet.CheckGroupContents(hGroup, C4GSCnt_Definitions)))
{
// Add folder to list
SNewSegment(szDefs); SAppend(szFoldername,szDefs);
@ -3498,8 +3504,8 @@ void C4Game::InitValueOverloads()
{
C4ID idOvrl; C4Def *pDef;
// set new values
for (int32_t cnt=0; idOvrl=C4S.Game.Realism.ValueOverloads.GetID(cnt); cnt++)
if (pDef=::Definitions.ID2Def(idOvrl))
for (int32_t cnt=0; (idOvrl=C4S.Game.Realism.ValueOverloads.GetID(cnt)); cnt++)
if ((pDef=::Definitions.ID2Def(idOvrl)))
pDef->Value=C4S.Game.Realism.ValueOverloads.GetIDCount(idOvrl);
}

View File

@ -149,22 +149,23 @@ int main()
static void crash_handler(int signo)
{
int logfd = STDERR_FILENO;
ssize_t ignore;
for (;;)
{
// Print out the signal
write(logfd, C4VERSION ": Caught signal ", sizeof (C4VERSION ": Caught signal ") - 1);
ignore = write(logfd, C4VERSION ": Caught signal ", sizeof (C4VERSION ": Caught signal ") - 1);
switch (signo)
{
case SIGBUS: write(logfd, "SIGBUS", sizeof ("SIGBUS") - 1); break;
case SIGILL: write(logfd, "SIGILL", sizeof ("SIGILL") - 1); break;
case SIGSEGV: write(logfd, "SIGSEGV", sizeof ("SIGSEGV") - 1); break;
case SIGABRT: write(logfd, "SIGABRT", sizeof ("SIGABRT") - 1); break;
case SIGINT: write(logfd, "SIGINT", sizeof ("SIGINT") - 1); break;
case SIGQUIT: write(logfd, "SIGQUIT", sizeof ("SIGQUIT") - 1); break;
case SIGFPE: write(logfd, "SIGFPE", sizeof ("SIGFPE") - 1); break;
case SIGTERM: write(logfd, "SIGTERM", sizeof ("SIGTERM") - 1); break;
case SIGBUS: ignore = write(logfd, "SIGBUS", sizeof ("SIGBUS") - 1); break;
case SIGILL: ignore = write(logfd, "SIGILL", sizeof ("SIGILL") - 1); break;
case SIGSEGV: ignore = write(logfd, "SIGSEGV", sizeof ("SIGSEGV") - 1); break;
case SIGABRT: ignore = write(logfd, "SIGABRT", sizeof ("SIGABRT") - 1); break;
case SIGINT: ignore = write(logfd, "SIGINT", sizeof ("SIGINT") - 1); break;
case SIGQUIT: ignore = write(logfd, "SIGQUIT", sizeof ("SIGQUIT") - 1); break;
case SIGFPE: ignore = write(logfd, "SIGFPE", sizeof ("SIGFPE") - 1); break;
case SIGTERM: ignore = write(logfd, "SIGTERM", sizeof ("SIGTERM") - 1); break;
}
write(logfd, "\n", sizeof ("\n") - 1);
ignore = write(logfd, "\n", sizeof ("\n") - 1);
if (logfd == STDERR_FILENO) logfd = GetLogFD();
else break;
if (logfd < 0) break;

View File

@ -339,7 +339,7 @@ bool C4ComponentHost::GetLanguageString(const char *szLanguage, StdStrBuf &rTarg
for(int clseg=0; SCopySegment(szLanguage ? szLanguage : "", clseg, langindex, ',', 2); clseg++)
{
SAppend(":",langindex);
if (cptr = SSearch(Data.getData(),langindex))
if ((cptr = SSearch(Data.getData(),langindex)))
{
// Return the according string
int iEndPos = SCharPos('\r', cptr);

View File

@ -823,7 +823,7 @@ bool C4Group::AddEntry(int status,
fOkay = !!hFile.Write(membuf,size);
hFile.Close();
if (fHoldBuffer) if (fBufferIsStdbuf) StdBuf::DeletePointer(membuf); else delete [] membuf;
if (fHoldBuffer) { if (fBufferIsStdbuf) StdBuf::DeletePointer(membuf); else delete [] membuf; }
return fOkay;
@ -1390,7 +1390,7 @@ bool C4Group::View(const char *szFiles)
// Display list
ResetSearch();
while (centry=SearchNextEntry(szFiles))
while ((centry=SearchNextEntry(szFiles)))
{
fcount++;
bcount+=centry->Size;
@ -1405,12 +1405,12 @@ bool C4Group::View(const char *szFiles)
Head.Ver1,Head.Ver2,
crc, crc);
ResetSearch();
while (centry=SearchNextEntry(szFiles))
while ((centry=SearchNextEntry(szFiles)))
{
// convert centry->Time into time_t for localtime
time_t cur_time = centry->Time;
tm *pcoretm = localtime(&cur_time);
tm coretm;
tm coretm = { 0 };
if (pcoretm) coretm = *pcoretm; else printf("(invalid timestamp) ");
centry->Time = cur_time;
@ -1714,7 +1714,7 @@ bool C4Group::Extract(const char *szFiles, const char *szExtractTo, const char *
{
// Search all entries
ResetSearch();
while (tentry = SearchNextEntry(szFileName))
while ((tentry = SearchNextEntry(szFileName)))
{
// skip?
if (C4Group_IsExcluded(tentry->FileName, szExclude)) continue;
@ -1861,12 +1861,13 @@ bool C4Group::OpenAsChild(C4Group *pMother,
// Get original entry name
C4GroupEntry *centry;
if (centry = Mother->GetEntry(FileName))
if ((centry = Mother->GetEntry(FileName)))
SCopy(centry->FileName,FileName,_MAX_PATH);
// Access entry in mother group
size_t iSize;
if (!Mother->AccessEntry(FileName, &iSize, NULL, NULL, true))
if ((!Mother->AccessEntry(FileName, &iSize, NULL, NULL, true)))
{
if(!fCreate)
{ CloseExclusiveMother(); Clear(); return Error("OpenAsChild: Entry not in mother group"); }
else
@ -1875,6 +1876,7 @@ bool C4Group::OpenAsChild(C4Group *pMother,
Status=GRPF_File; Modified=true;
return true;
}
}
// Child Group?
if(centry && !centry->ChildGroup)
@ -2170,7 +2172,7 @@ int C4Group::EntryCount(const char *szWildCard)
if (!szWildCard) szWildCard="*";
// Match wildcard
ResetSearch(); fcount=0;
while (tentry=SearchNextEntry(szWildCard)) fcount++;
while ((tentry=SearchNextEntry(szWildCard))) fcount++;
return fcount;
}
@ -2182,7 +2184,7 @@ int C4Group::EntrySize(const char *szWildCard)
if (!szWildCard) szWildCard="*";
// Match wildcard
ResetSearch(); fsize=0;
while (tentry=SearchNextEntry(szWildCard))
while ((tentry=SearchNextEntry(szWildCard)))
fsize+=tentry->Size;
return fsize;
}
@ -2193,7 +2195,7 @@ unsigned int C4Group::EntryCRC32(const char *szWildCard)
// iterate thorugh child
C4GroupEntry *pEntry; unsigned int iCRC = 0;
ResetSearch();
while(pEntry = SearchNextEntry(szWildCard))
while((pEntry = SearchNextEntry(szWildCard)))
{
if(!CalcCRC32(pEntry)) return false;
iCRC ^= pEntry->CRC;
@ -2336,7 +2338,7 @@ bool C4Group::Sort(const char *szSortList)
fBubble=false;
for (prev=NULL,centry=FirstEntry; centry; prev=centry,centry=next)
if (next=centry->Next)
if ((next=centry->Next))
{
// primary sort by file list
int iS1 = SortRank(centry->FileName,szSortList);

View File

@ -143,8 +143,9 @@ bool C4GroupSet::RegisterGroups(C4GroupSet &rCopy, int32_t Contents, const char
// get all groups of rCopy
int32_t Contents2;
for (C4GroupSetNode *pNode=rCopy.pFirst; pNode; pNode=pNode->pNext)
if (Contents2 = pNode->Contents & Contents)
if ((Contents2 = pNode->Contents & Contents))
if (pNode->id > iMaxSkipID)
{
if (!szFilename)
// add group but don't check the content again!
RegisterGroup(*pNode->pGroup, false, pNode->Priority, Contents2, false);
@ -159,6 +160,7 @@ bool C4GroupSet::RegisterGroups(C4GroupSet &rCopy, int32_t Contents, const char
if (!RegisterGroup(*pGroup, true, pNode->Priority, Contents2, false))
delete pGroup;
}
}
// done, success
return true;
}
@ -203,7 +205,7 @@ bool C4GroupSet::LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSi
{
// Load the entry from the first group that has it
C4Group *pGroup;
if (pGroup = FindEntry(szEntryName))
if ((pGroup = FindEntry(szEntryName)))
return pGroup->LoadEntry(szEntryName, lpbpBuf, ipSize, iAppendZeros);
// Didn't find it
return false;
@ -213,7 +215,7 @@ bool C4GroupSet::LoadEntryString(const char *szEntryName, StdStrBuf & rBuf)
{
// Load the entry from the first group that has it
C4Group *pGroup;
if (pGroup = FindEntry(szEntryName))
if ((pGroup = FindEntry(szEntryName)))
return pGroup->LoadEntryString(szEntryName, rBuf);
// Didn't find it
return false;

View File

@ -114,7 +114,7 @@ bool C4Language::Init()
// Now create a pack group for each language pack (these pack groups are child groups
// that browse along each pack to access requested data)
for (int iPack = 0; pPack = Packs.GetGroup(iPack); iPack++)
for (int iPack = 0; (pPack = Packs.GetGroup(iPack)); iPack++)
PackGroups.RegisterGroup(*(new C4Group), true, C4GSPrio_Base, C4GSCnt_Language);
// Load language infos by scanning string tables (the engine doesn't really need this at the moment)
@ -345,7 +345,7 @@ void C4Language::InitInfos()
}
// Now look through the registered packs
C4Group *pPack;
for (int iPack = 0; pPack = Packs.GetGroup(iPack); iPack++)
for (int iPack = 0; (pPack = Packs.GetGroup(iPack)); iPack++)
// Does it contain a System.c4g child group?
if (hGroup.OpenAsChild(pPack, C4CFN_System))
{
@ -443,7 +443,7 @@ bool C4Language::InitStringTable(const char *strCode)
}
// Now look through the registered packs
C4Group *pPack;
for (int iPack = 0; pPack = Packs.GetGroup(iPack); iPack++)
for (int iPack = 0; (pPack = Packs.GetGroup(iPack)); iPack++)
// Does it contain a System.c4g child group?
if (hGroup.OpenAsChild(pPack, C4CFN_System))
{
@ -496,7 +496,7 @@ bool C4Language::CloseGroup(const char *strPath)
{
// Check all open language packs
C4Group *pPack;
for (int iPack = 0; pPack = Packs.GetGroup(iPack); iPack++)
for (int iPack = 0; (pPack = Packs.GetGroup(iPack)); iPack++)
if (ItemIdentical(strPath, pPack->GetFullName().getData()))
{
Packs.UnregisterGroup(iPack);

View File

@ -154,7 +154,7 @@ public:
void SetHead(C4Group &rByGrp)
{
// Cheat away the protection
C4GroupHeader *pHdr = &static_cast<C4GroupEx &>(rByGrp).Head;
C4GroupHeader *pHdr = &static_cast<C4GroupEx&>(rByGrp).Head;
// save Entries
int Entries = Head.Entries;
// copy
@ -165,8 +165,10 @@ public:
bool HeadIdentical(C4Group &rByGrp, bool fLax)
{
// Cheat away the protection
C4GroupHeader *pHdr = &static_cast<C4GroupEx &>(rByGrp).Head;
// Cheat away the protection while avoiding
// gcc strict aliasing violation warnings.
intptr_t iGroup = (intptr_t) &rByGrp;
C4GroupHeader *pHdr = &((C4GroupEx*) iGroup)->Head;
// overwrite entries field
int Entries = Head.Entries;
Head.Entries = pHdr->Entries;
@ -213,7 +215,6 @@ public:
{
if(fHeaderUpdate) return C4Group::Close(); else { bool fSuccess = Save(false); Clear(); return fSuccess; }
}
};
// *** C4UpdatePackageCore
@ -304,11 +305,12 @@ bool C4UpdatePackage::Execute(C4Group *pGroup)
C4GroupEx TargetGrp;
char strTarget[_MAX_PATH]; SCopy(DestPath, strTarget, _MAX_PATH);
char *p = strTarget, *lp = strTarget;
while(p = strchr(p + 1, '\\'))
while((p = strchr(p + 1, '\\')))
{
*p = 0;
if(!*(p + 1)) break;
if(!SEqual(lp, ".."))
{
if(TargetGrp.Open(strTarget))
{
// packed?
@ -330,6 +332,7 @@ bool C4UpdatePackage::Execute(C4Group *pGroup)
// create dir
CreatePath(strTarget);
}
}
*p = '\\'; lp = p + 1;
}
@ -542,7 +545,7 @@ bool C4UpdatePackage::DoGrpUpdate(C4Group *pUpdateData, C4GroupEx *pGrpTo)
while(pGrpTo->FindNextEntry("*", strItemName))
{
bool fGotIt = false;
for(int i = 0; fGotIt = SCopySegment(pData, i, strItemName2, '|', _MAX_FNAME); i++)
for(int i = 0; (fGotIt = SCopySegment(pData, i, strItemName2, '|', _MAX_FNAME)); i++)
{
// remove seperator
char *pSep = strchr(strItemName2, '=');

View File

@ -136,10 +136,12 @@ bool CStdFile::Close(StdBuf **ppMemory)
if (hgzFile) if (gzclose(hgzFile)!=Z_OK) rval=false;
if (hFile) if (fclose(hFile)!=0) rval=false;
if (pMemory)
{
if(ppMemory)
{ *ppMemory = pMemory; pMemory = NULL; }
else
delete pMemory;
}
MemoryPtr=0;
hgzFile=NULL; hFile=NULL;
return !!rval;

View File

@ -459,17 +459,19 @@ int main(int argc, char *argv[]) {
globalArgV = argv;
// Register shell
if (fRegisterShell)
if (fRegisterShell) {
if (RegisterShellExtensions())
printf("Shell extensions registered.\n");
else
printf("Error registering shell extensions.\n");
}
// Unregister shell
if (fUnregisterShell)
if (fUnregisterShell) {
if (UnregisterShellExtensions())
printf("Shell extensions removed.\n");
else
printf("Error removing shell extensions.\n");
}
// At least one parameter (filename, not option or command): process file(s)
if (iFirstGroup) {

View File

@ -645,7 +645,7 @@ void C4ConfigGeneral::DeterminePaths(bool forceWorkingDirectory)
// Screenshot path
SCopy(UserDataPath, ScreenshotPath, CFG_MaxString-1);
if (ScreenshotFolder.getLength()+SLen(ScreenshotPath)+1<=CFG_MaxString)
if (ScreenshotFolder.getLength()+std::strlen(ScreenshotPath)+1<=CFG_MaxString)
{
SAppend(ScreenshotFolder.getData(), ScreenshotPath);
AppendBackslash(ScreenshotPath);
@ -742,7 +742,7 @@ const char *C4Config::AtScreenshotPath(const char *szFilename)
{
int len;
SCopy(General.ScreenshotPath,AtPathFilename,_MAX_PATH);
if(len = SLen(AtPathFilename))
if((len = SLen(AtPathFilename)))
if(AtPathFilename[len-1] == DirectorySeparator)
AtPathFilename[len-1] = '\0';
if (!CreatePath(AtPathFilename))
@ -1002,7 +1002,7 @@ bool C4Config::RemoveModule(const char *szPath, char *szModules)
return SRemoveModule(szModules,szPath);
}
void C4Config::ExpandEnvironmentVariables(char *strPath, int iMaxLen)
void C4Config::ExpandEnvironmentVariables(char *strPath, size_t iMaxLen)
{
#ifdef _WIN32
char buf[_MAX_PATH + 1];
@ -1011,7 +1011,7 @@ void C4Config::ExpandEnvironmentVariables(char *strPath, int iMaxLen)
#else // __linux__ or __APPLE___
StdStrBuf home(getenv("HOME"));
char* rest;
if (home && (rest = const_cast<char *>(SSearch(strPath, "$HOME"))) && (SLen(strPath) - 5 + home.getLength() <= iMaxLen))
if (home && (rest = const_cast<char *>(SSearch(strPath, "$HOME"))) && (std::strlen(strPath) - 5 + home.getLength() <= iMaxLen))
{
// String replace... there might be a more elegant way to do this.
memmove(rest + home.getLength() - SLen("$HOME"), rest, SLen(rest) + 1);

View File

@ -342,7 +342,7 @@ class C4Config: protected CStdConfig
bool IsModule(const char *szPath, char *szModules);
bool AddModule(const char *szPath, char *szModules);
static void ExpandEnvironmentVariables(char *strPath, int iMaxLen);
static void ExpandEnvironmentVariables(char *strPath, size_t iMaxLen);
private:
const char *AtDataReadPathCore(const char *szFilename, bool fPreferWorkdir = false);
};

View File

@ -25,6 +25,7 @@
#include <C4Log.h>
#include <C4Gui.h>
#include <Standard.h>
#include <StdFile.h>
#ifdef HAVE_IO_H
@ -70,7 +71,7 @@ EVP_PKEY* loadPublicKey(const char *memKey, bool deBase64 = false, bool deXOR =
BIO* memBio = BIO_new_mem_buf(const_cast<char *>(memKey), strlen(memKey));
BIO* b64Bio = BIO_new(BIO_f_base64());
BIO* bio = BIO_push(b64Bio, memBio);
BIO_flush(bio);
(void) BIO_flush(bio);
keyDataLen = BIO_read(bio, keyData, maxKeyDataLen * 2);
BIO_free_all(bio);
}
@ -132,7 +133,7 @@ int verifyData(char *data, unsigned int dataLen, EVP_PKEY* pubKey)
BIO* memBio = BIO_new_mem_buf(b64Sig, b64SigLen);
BIO* b64Bio = BIO_new(BIO_f_base64());
BIO* bio = BIO_push(b64Bio, memBio);
BIO_flush(bio);
(void) BIO_flush(bio);
const int MAXSIGLEN = 1024;
unsigned char sig[MAXSIGLEN] = "";
unsigned int sigLen = BIO_read(bio, sig, MAXSIGLEN * 2);
@ -307,19 +308,23 @@ bool C4ConfigShareware::LoadRegistration()
SCopy(GetKeyPath(), searchPath);
for (DirectoryIterator i(searchPath); *i; ++i)
if (WildcardMatch("*.c4k", *i))
{
if (LoadRegistration(*i))
return true;
else
SCopy(*i, InvalidKeyFile, CFG_MaxString);
}
}
// Then look in ExePath
for (DirectoryIterator i(General.ExePath); *i; ++i)
if (WildcardMatch("*.c4k", *i))
{
if (LoadRegistration(*i))
return true;
else
SCopy(*i, InvalidKeyFile, CFG_MaxString);
}
// No key file found
return HandleError("No valid key file found.");
@ -472,7 +477,7 @@ const char* C4ConfigShareware::GetRegistrationData(const char *strField)
// Advance to value
pKeyField += strlen(strFieldMask);
// Get field value
int iValueLen = 256;
size_t iValueLen = 256;
const char *pFieldEnd = strstr(pKeyField, "\x0d");
if (pFieldEnd) iValueLen = pFieldEnd - pKeyField;
iValueLen = Min(iValueLen, CFG_MaxString);

View File

@ -27,9 +27,9 @@
//============================= Main =====================================================
const size_t C4MaxTitle = 512;
const int
C4MaxDefString = 100,
C4MaxTitle = 512,
C4MaxMessage = 256,
C4ViewDelay = 100,
@ -259,7 +259,7 @@ enum C4LeagueDisconnectReason
{
C4LDR_Unknown,
C4LDR_ConnectionFailed,
C4LDR_Desync,
C4LDR_Desync
};
//=================================== Player (included by C4PlayerInfo and C4Player)
@ -268,7 +268,7 @@ enum C4PlayerType
{
C4PT_None=0,
C4PT_User=1, // Normal player
C4PT_Script=2, // AI players, etc.
C4PT_Script=2 // AI players, etc.
};
//=================================== AllowPictureStack (DefCore value)
@ -278,7 +278,7 @@ enum C4AllowPictureStack
APS_Color= 1<<0,
APS_Graphics=1<<1,
APS_Name= 1<<2,
APS_Overlay= 1<<3,
APS_Overlay= 1<<3
};
// Object size

View File

@ -149,6 +149,7 @@ void C4ControlSet::Execute() const
{
switch(eValType)
{
case C4CVT_None: break;
case C4CVT_ControlRate: // adjust control rate
// host only
@ -278,7 +279,7 @@ void C4ControlScript::Execute() const
pScript = &Game.Script;
else if (iTargetObj == SCOPE_Global)
pScript = &::ScriptEngine;
else if (pObj = ::Objects.SafeObjectPointer(iTargetObj))
else if ((pObj = ::Objects.SafeObjectPointer(iTargetObj)))
pScript = &(pObj->Def->Script);
else
// default: Fallback to global context
@ -319,7 +320,7 @@ void C4ControlScript::CompileFunc(StdCompiler *pComp)
// *** C4ControlPlayerSelect
C4ControlPlayerSelect::C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs, bool fIsAlt)
: iPlr(iPlr), iObjCnt(Objs.ObjectCount()), fIsAlt(fIsAlt)
: iPlr(iPlr), fIsAlt(fIsAlt), iObjCnt(Objs.ObjectCount())
{
pObjNrs = new int32_t[iObjCnt];
int32_t i = 0;
@ -339,15 +340,17 @@ void C4ControlPlayerSelect::Execute() const
C4ObjectList SelectObjs;
int32_t iControlChecksum = 0;
for(int32_t i = 0; i < iObjCnt; i++)
if(pObj = ::Objects.SafeObjectPointer(pObjNrs[i]))
if((pObj = ::Objects.SafeObjectPointer(pObjNrs[i])))
{
iControlChecksum += pObj->Number * (iControlChecksum+4787821);
// user defined object selection: callback to object
if (pObj->Category & C4D_MouseSelect)
{
if (fIsAlt)
pObj->Call(PSF_MouseSelectionAlt, &C4AulParSet(C4VInt(iPlr)));
else
pObj->Call(PSF_MouseSelection, &C4AulParSet(C4VInt(iPlr)));
}
// player crew selection (recheck status of pObj)
if (pObj->Status && pPlr->ObjectInCrew(pObj) && !fIsAlt)
SelectObjs.Add(pObj, C4ObjectList::stNone);
@ -600,6 +603,7 @@ void C4ControlClientUpdate::Execute() const
// do whatever specified
switch(eType)
{
case CUT_None: break;
case CUT_Activate:
// nothing to do?
if(pClient->isActivated() == !!iData) break;
@ -915,7 +919,7 @@ void C4ControlEMMoveObject::Execute() const
// move all given objects
C4Object *pObj;
for (int i=0; i<iObjectNum; ++i)
if (pObj = ::Objects.SafeObjectPointer(pObjects[i])) if (pObj->Status)
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i]))) if (pObj->Status)
{
pObj->ForcePosition(pObj->GetX()+tx,pObj->GetY()+ty);
pObj->xdir=pObj->ydir=0;
@ -930,7 +934,7 @@ void C4ControlEMMoveObject::Execute() const
C4Object *pObj, *pTarget = ::Objects.SafeObjectPointer(iTargetObj);
if (pTarget)
for (int i=0; i<iObjectNum; ++i)
if (pObj = ::Objects.SafeObjectPointer(pObjects[i]))
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i])))
pObj->Enter(pTarget);
}
break;
@ -942,7 +946,7 @@ void C4ControlEMMoveObject::Execute() const
// perform duplication
C4Object *pObj;
for (int i=0; i<iObjectNum; ++i)
if (pObj = ::Objects.SafeObjectPointer(pObjects[i]))
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i])))
{
pObj = Game.CreateObject(pObj->GetPrototype(), pObj, pObj->Owner, pObj->GetX(), pObj->GetY());
if (pObj && fLocalCall) Console.EditCursor.GetSelection().Add(pObj, C4ObjectList::stNone);
@ -975,7 +979,7 @@ void C4ControlEMMoveObject::Execute() const
// remove all objects
C4Object *pObj;
for (int i=0; i<iObjectNum; ++i)
if (pObj = ::Objects.SafeObjectPointer(pObjects[i]))
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i])))
pObj->AssignRemoval();
}
break; // Here was fallthrough. Seemed wrong. ck.
@ -985,7 +989,7 @@ void C4ControlEMMoveObject::Execute() const
// exit all objects
C4Object *pObj;
for (int i=0; i<iObjectNum; ++i)
if (pObj = ::Objects.SafeObjectPointer(pObjects[i]))
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i])))
pObj->Exit(pObj->GetX(), pObj->GetY(), pObj->r);
}
break; // Same. ck.
@ -1058,6 +1062,8 @@ void C4ControlEMDrawTool::Execute() const
::Landscape.InsertMaterial(iMat,iX+Random(iGrade)-iGrade/2,iY+Random(iGrade)-iGrade/2);
}
break;
default:
break;
}
}
@ -1139,7 +1145,7 @@ void C4ControlMessage::Execute() const
{
// for running game mode, check actual hostility
C4Player *pLocalPlr;
for(int cnt = 0; pLocalPlr = ::Players.GetLocalByIndex(cnt); cnt++)
for(int cnt = 0; (pLocalPlr = ::Players.GetLocalByIndex(cnt)); cnt++)
if(!Hostile(pLocalPlr->Number, iPlayer))
break;
if(pLocalPlr) Log(FormatString("<c %x>{%s} %s</c>", pPlr->ColorDw, pPlr->GetName(), szMessage).getData());
@ -1161,7 +1167,7 @@ void C4ControlMessage::Execute() const
if(!pPlr) break;
// show only if the target player is local
C4Player *pLocalPlr;
for(int cnt = 0; pLocalPlr = ::Players.GetLocalByIndex(cnt); cnt++)
for(int cnt = 0; (pLocalPlr = ::Players.GetLocalByIndex(cnt)); cnt++)
if(pLocalPlr->ID == iToPlayer)
break;
if(pLocalPlr)
@ -1355,12 +1361,14 @@ void C4ControlVote::Execute() const
iVotesTeam++;
// Search vote of this client on the subject
C4IDPacket *pPkt; C4ControlVote *pVote;
if(pPkt = ::Network.GetVote(iClientID, eType, iData))
if(pVote = static_cast<C4ControlVote *>(pPkt->getPkt()))
if((pPkt = ::Network.GetVote(iClientID, eType, iData)))
if((pVote = static_cast<C4ControlVote *>(pPkt->getPkt())))
{
if(pVote->isApprove())
iPositiveTeam++;
else
iNegativeTeam++;
}
}
// Any votes available?
if(iVotesTeam)
@ -1420,8 +1428,8 @@ void C4ControlVoteEnd::Execute() const
case VT_Cancel:
// Flag players
if(!Game.GameOver)
for(iClient = 0; pInfos = Game.PlayerInfos.GetIndexedInfo(iClient); iClient++)
for(iInfo = 0; pInfo = pInfos->GetPlayerInfo(iInfo); iInfo++)
for(iClient = 0; (pInfos = Game.PlayerInfos.GetIndexedInfo(iClient)); iClient++)
for(iInfo = 0; (pInfo = pInfos->GetPlayerInfo(iInfo)); iInfo++)
if(!pInfo->IsRemoved())
pInfo->SetVotedOut();
// Abort the game
@ -1432,7 +1440,7 @@ void C4ControlVoteEnd::Execute() const
pInfos = Game.PlayerInfos.GetInfoByClientID(getData());
if(!Game.GameOver)
if(pInfos)
for(iInfo = 0; pInfo = pInfos->GetPlayerInfo(iInfo); iInfo++)
for(iInfo = 0; (pInfo = pInfos->GetPlayerInfo(iInfo)); iInfo++)
if(!pInfo->IsRemoved())
pInfo->SetVotedOut();
// Remove the client
@ -1453,6 +1461,9 @@ void C4ControlVoteEnd::Execute() const
Game.DoGameOver();
}
break;
default:
// TODO
break;
}
}

View File

@ -110,7 +110,7 @@ enum C4CtrlValueType
C4CVT_MaxPlayer = 2,
C4CVT_TeamDistribution = 3,
C4CVT_TeamColors = 4,
C4CVT_FairCrew = 5,
C4CVT_FairCrew = 5
};
class C4ControlSet : public C4ControlPacket // sync, lobby
@ -135,7 +135,7 @@ public:
class C4ControlScript : public C4ControlPacket // sync
{
public:
enum { SCOPE_Console=-2, SCOPE_Global=-1, }; // special scopes to be passed as target objects
enum { SCOPE_Console=-2, SCOPE_Global=-1 }; // special scopes to be passed as target objects
C4ControlScript()
: iTargetObj(-1), fInternal(true)
@ -156,7 +156,7 @@ class C4ControlPlayerSelect : public C4ControlPacket // sync
{
public:
C4ControlPlayerSelect()
: iPlr(-1), iObjCnt(0), pObjNrs(NULL), fIsAlt(false) { }
: iPlr(-1), fIsAlt(false), iObjCnt(0), pObjNrs(NULL) { }
C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs, bool fIsAlt);
~C4ControlPlayerSelect() { delete[] pObjNrs; }
protected:
@ -265,7 +265,7 @@ public:
enum C4ControlClientUpdType
{
CUT_None = -1, CUT_Activate = 0, CUT_SetObserver = 1,
CUT_None = -1, CUT_Activate = 0, CUT_SetObserver = 1
};
class C4ControlClientUpdate : public C4ControlPacket // sync, lobby
@ -314,7 +314,7 @@ public:
const C4ClientPlayerInfos &GetInfo() const { return PlrInfo; }
virtual bool Sync() const { return false; }
virtual bool Lobby() const { return true; }
DECLARE_C4CONTROL_VIRTUALS;
DECLARE_C4CONTROL_VIRTUALS
};
struct C4ControlJoinPlayer : public C4ControlPacket // sync
@ -331,7 +331,7 @@ protected:
StdBuf PlrData; // for fByRes == false
C4Network2ResCore ResCore; // for fByRes == true
public:
DECLARE_C4CONTROL_VIRTUALS;
DECLARE_C4CONTROL_VIRTUALS
virtual bool PreExecute() const;
virtual void PreRec(C4Record *pRecord);
void Strip();
@ -344,7 +344,7 @@ enum C4ControlEMObjectAction
EMMO_Duplicate, // duplicate objects at same position; reset EditCursor
EMMO_Script, // execute Script
EMMO_Remove, // remove objects
EMMO_Exit, // exit objects
EMMO_Exit // exit objects
};
class C4ControlEMMoveObject : public C4ControlPacket // sync
@ -371,7 +371,7 @@ enum C4ControlEMDrawAction
EMDT_Brush, // drawing tool
EMDT_Fill, // drawing tool
EMDT_Line, // drawing tool
EMDT_Rect, // drawing tool
EMDT_Rect // drawing tool
};
class C4ControlEMDrawTool : public C4ControlPacket // sync
@ -401,7 +401,7 @@ enum C4ControlMessageType
C4CMT_Private = 4,
C4CMT_Sound = 5, // "message" is played as a sound instead
C4CMT_Alert = 6, // no message. just flash taskbar for inactive clients.
C4CMT_System = 10,
C4CMT_System = 10
};
class C4ControlMessage : public C4ControlPacket // not sync, lobby

View File

@ -269,9 +269,9 @@ bool C4GameControl::Prepare()
// check GameGo
return Network.CtrlReady(ControlTick);
default:
return false;
}
return false;
}
void C4GameControl::Execute()

View File

@ -30,7 +30,7 @@ enum C4ControlMode
CM_None,
CM_Local, // control = input
CM_Network, // control = input + network input
CM_Replay, // control = replay
CM_Replay // control = replay
};
enum C4ControlDeliveryType
@ -40,7 +40,7 @@ enum C4ControlDeliveryType
CDT_Direct = 2, // Send directly to all clients (not sync)
CDT_Private = 3, // Send only to some clients (not sync, obviously)
CDT_Decide, // Use whatever sync mode seems fastest atm (sync)
CDT_Decide // Use whatever sync mode seems fastest atm (sync)
};
// Additional notes / requirements:

View File

@ -234,7 +234,7 @@ bool C4GameResList::Load(const char *szDefinitionFilenames)
CreateByFile(NRT_System, C4CFN_System);
// add all instances of Material.c4g, except those inside the scenario file
C4Group *pMatParentGrp = NULL;
while(pMatParentGrp = Game.GroupSet.FindGroup(C4GSCnt_Material, pMatParentGrp))
while((pMatParentGrp = Game.GroupSet.FindGroup(C4GSCnt_Material, pMatParentGrp)))
if(pMatParentGrp != &Game.ScenarioFile)
{
StdStrBuf MaterialPath = pMatParentGrp->GetFullName() + DirSep C4CFN_Material;
@ -524,7 +524,7 @@ StdStrBuf C4GameParameters::GetGameGoalString()
StdStrBuf sResult;
C4ID idGoal;
for (int32_t i=0; i<Goals.GetNumberOfIDs(); ++i)
if (idGoal = Goals.GetID(i)) if (idGoal != C4ID::None)
if ((idGoal = Goals.GetID(i))) if (idGoal != C4ID::None)
{
if (Game.IsRunning)
{

View File

@ -375,10 +375,11 @@ void C4GameSave::WriteDescPlayers(StdStrBuf &sBuf, bool fByTeam, int32_t idTeam)
{
// write out all players; only if they match the given team if specified
C4PlayerInfo *pPlr; bool fAnyPlrWritten = false;
for (int i = 0; pPlr = Game.PlayerInfos.GetPlayerInfoByIndex(i); i++)
for (int i = 0; (pPlr = Game.PlayerInfos.GetPlayerInfoByIndex(i)); i++)
if (pPlr->HasJoined() && !pPlr->IsRemoved() && !pPlr->IsInvisible())
{
if (fByTeam)
{
if (idTeam)
{
// match team
@ -389,6 +390,7 @@ void C4GameSave::WriteDescPlayers(StdStrBuf &sBuf, bool fByTeam, int32_t idTeam)
// must be in no known team
if (Game.Teams.GetTeamByID(pPlr->GetTeam())) continue;
}
}
if (fAnyPlrWritten)
sBuf.Append(", ");
else if (fByTeam && idTeam)
@ -413,7 +415,7 @@ void C4GameSave::WriteDescPlayers(StdStrBuf &sBuf)
// Teams defined: Print players sorted by teams
WriteDescLineFeed(sBuf);
C4Team *pTeam; int32_t i=0;
while (pTeam = Game.Teams.GetTeamByIndex(i++))
while ((pTeam = Game.Teams.GetTeamByIndex(i++)))
{
WriteDescPlayers(sBuf, true, pTeam->GetID());
}

View File

@ -54,7 +54,7 @@ class C4GameSave
SyncNONE = 0,
SyncScenario = 1, // save (eventually static) landscape and objects only to play as a seperate scenario later
SyncSavegame = 2, // save all runtime data, so the scenario can be continued at a future date
SyncSynchronized = 3, // save exact runtime data to be network- or replay-save
SyncSynchronized = 3 // save exact runtime data to be network- or replay-save
} Sync; // sync is set by ctor
// query functions

View File

@ -814,7 +814,7 @@ bool C4PlayerControl::ExecuteControl(int32_t iControl, bool fUp, const C4KeyEven
bool fHandled = ExecuteControlAction(iControl, eAction, pControlDef->GetExtraData(), fUp, KeyExtraData, fRepeated);
// handled controls hide control display
C4Player *pPlr;
if (pPlr = ::Players.Get(iPlr)) if (pPlr->ShowStartup) pPlr->ShowStartup = false;
if ((pPlr = ::Players.Get(iPlr))) if (pPlr->ShowStartup) pPlr->ShowStartup = false;
// return if handled, unless control is defined as always unhandled
return fHandled && !(iTriggerMode & C4PlayerControlAssignment::CTM_AlwaysUnhandled);
}

View File

@ -45,13 +45,13 @@ class C4PlayerControlDef
CDA_Script, // default: Script callback
CDA_Menu, // open player menu (async)
CDA_MenuOK, CDA_MenuCancel, CDA_MenuLeft, CDA_MenuUp, CDA_MenuRight, CDA_MenuDown, // player menu controls (async)
CDA_ZoomIn, CDA_ZoomOut, // player viewport control (async)
CDA_ZoomIn, CDA_ZoomOut // player viewport control (async)
};
private:
Actions eAction;
public:
C4PlayerControlDef() : fIsHoldKey(false), fDefaultDisabled(false), eAction(CDA_Script), fGlobal(false), idControlExtraData(C4ID::None) {}
C4PlayerControlDef() : fGlobal(false), fIsHoldKey(false), fDefaultDisabled(false), idControlExtraData(C4ID::None), eAction(CDA_Script) {}
~C4PlayerControlDef() {};
void CompileFunc(StdCompiler *pComp);
@ -155,7 +155,7 @@ class C4PlayerControlAssignment
CTM_Default=0, // standard behaviour: The control will be triggered
CTM_Hold= 1<<0, // the control will be put into "down"-mode
CTM_Release= 1<<1, // the hold mode of the control will be released
CTM_AlwaysUnhandled= 1<<2, // the key will not block handling of other keys even if it got handled
CTM_AlwaysUnhandled= 1<<2 // the key will not block handling of other keys even if it got handled
};
private:
@ -164,7 +164,7 @@ class C4PlayerControlAssignment
bool fRefsResolved; // set to true after sControlName and sKeyNames have been resolved to runtime values
public:
C4PlayerControlAssignment() : TriggerKey(), iControl(CON_None), iTriggerMode(CTM_Default), iPriority(0), fRefsResolved(false) {}
C4PlayerControlAssignment() : TriggerKey(), iControl(CON_None), iPriority(0), iTriggerMode(CTM_Default), fRefsResolved(false) {}
~C4PlayerControlAssignment() {}
void CompileFunc(StdCompiler *pComp);
@ -362,4 +362,4 @@ class C4PlayerControl
};
#endif // INC_C4PlayerControl
#endif // INC_C4PlayerControl

View File

@ -354,7 +354,7 @@ bool C4PlayerInfo::LoadBigIcon(C4FacetSurface &fctTarget)
C4Group Plr;
C4Network2Res *pRes = NULL;
bool fIncompleteRes = false;
if (pRes = GetRes())
if ((pRes = GetRes()))
if (!pRes->isComplete())
fIncompleteRes = true;
size_t iBigIconSize=0;
@ -371,7 +371,7 @@ bool C4PlayerInfo::LoadBigIcon(C4FacetSurface &fctTarget)
// *** C4ClientPlayerInfos
C4ClientPlayerInfos::C4ClientPlayerInfos(const char *szJoinFilenames, bool fAdd, C4PlayerInfo *pAddInfo)
: iPlayerCount(0), iClientID(-1), iPlayerCapacity(0), ppPlayers(NULL), dwFlags(0)
: iPlayerCount(0), iPlayerCapacity(0), ppPlayers(NULL), iClientID(-1), dwFlags(0)
{
// init for local client?
if (szJoinFilenames || pAddInfo)
@ -391,7 +391,7 @@ C4ClientPlayerInfos::C4ClientPlayerInfos(const char *szJoinFilenames, bool fAdd,
// set initial flag for first-time join packet
dwFlags |= CIF_Initial;
// join all players in list
if (iPlayerCapacity = (szJoinFilenames ? SModuleCount(szJoinFilenames) : 0) + !!pAddInfo)
if ((iPlayerCapacity = (szJoinFilenames ? SModuleCount(szJoinFilenames) : 0) + !!pAddInfo))
{
ppPlayers = new C4PlayerInfo *[iPlayerCapacity];
if (szJoinFilenames)
@ -419,7 +419,7 @@ C4ClientPlayerInfos::C4ClientPlayerInfos(const C4ClientPlayerInfos &rCopy)
{
// copy fields
iClientID = rCopy.iClientID;
if (iPlayerCount = rCopy.iPlayerCount)
if ((iPlayerCount = rCopy.iPlayerCount))
{
// copy player infos
ppPlayers = new C4PlayerInfo *[iPlayerCapacity = rCopy.iPlayerCapacity];
@ -442,7 +442,7 @@ C4ClientPlayerInfos &C4ClientPlayerInfos::operator = (const C4ClientPlayerInfos
Clear();
// copy fields
iClientID = rCopy.iClientID;
if (iPlayerCount = rCopy.iPlayerCount)
if ((iPlayerCount = rCopy.iPlayerCount))
{
// copy player infos
ppPlayers = new C4PlayerInfo *[iPlayerCapacity = rCopy.iPlayerCapacity];
@ -602,7 +602,7 @@ C4PlayerInfo *C4ClientPlayerInfos::GetPlayerInfoByRes(int32_t idResID) const
C4Network2Res *pRes;
while (i--)
{
if (pRes = (*ppCurrPlrInfo)->GetRes())
if ((pRes = (*ppCurrPlrInfo)->GetRes()))
if (pRes->getResID() == idResID)
// only if the player is actually using the ressource
if ((*ppCurrPlrInfo)->IsUsingPlayerFile())
@ -780,13 +780,13 @@ void C4PlayerInfoList::UpdatePlayerAttributes(C4ClientPlayerInfos *pForInfo, boo
assert(pForInfo);
// update colors of all players of this packet
C4PlayerInfo *pInfo, *pInfo2; int32_t i=0;
while (pInfo = pForInfo->GetPlayerInfo(i++))
while ((pInfo = pForInfo->GetPlayerInfo(i++)))
if (!pInfo->HasJoined())
{
// assign savegame colors
int32_t idSavegameID; bool fHasForcedColor = false; DWORD dwForceClr;
if (idSavegameID = pInfo->GetAssociatedSavegamePlayerID())
if (pInfo2 = Game.RestorePlayerInfos.GetPlayerInfoByID(idSavegameID))
if ((idSavegameID = pInfo->GetAssociatedSavegamePlayerID()))
if ((pInfo2 = Game.RestorePlayerInfos.GetPlayerInfoByID(idSavegameID)))
{
dwForceClr = pInfo2->GetColor();
fHasForcedColor = true;
@ -816,7 +816,7 @@ void C4PlayerInfoList::UpdatePlayerAttributes()
// update attributes of all packets
int32_t iIdx=0;
C4ClientPlayerInfos *pForInfo;
while (pForInfo = GetIndexedInfo(iIdx++)) UpdatePlayerAttributes(pForInfo, false);
while ((pForInfo = GetIndexedInfo(iIdx++))) UpdatePlayerAttributes(pForInfo, false);
// now resole all conflicts
ResolvePlayerAttributeConflicts(NULL);
}
@ -825,7 +825,7 @@ bool C4PlayerInfoList::AssignPlayerIDs(C4ClientPlayerInfos *pNewClientInfo)
{
// assign player IDs to those player infos without
C4PlayerInfo *pPlrInfo; int32_t i=0;
while (pPlrInfo = pNewClientInfo->GetPlayerInfo(i++))
while ((pPlrInfo = pNewClientInfo->GetPlayerInfo(i++)))
if (!pPlrInfo->GetID())
{
// are there still any player slots free?
@ -854,7 +854,7 @@ void C4PlayerInfoList::AssignTeams(C4ClientPlayerInfos *pNewClientInfo, bool fBy
if (!Game.Teams.IsMultiTeams()) return;
// assign any unset teams (host/standalone only - fByHost determines whether the packet came from the host)
C4PlayerInfo *pPlrInfo; int32_t i=0;
while (pPlrInfo = pNewClientInfo->GetPlayerInfo(i++))
while ((pPlrInfo = pNewClientInfo->GetPlayerInfo(i++)))
Game.Teams.RecheckPlayerInfoTeams(*pPlrInfo, fByHost);
}
@ -862,10 +862,10 @@ void C4PlayerInfoList::RecheckAutoGeneratedTeams()
{
// ensure all teams specified in the list exist
C4ClientPlayerInfos *pPlrInfos; int32_t j=0;
while (pPlrInfos = GetIndexedInfo(j++))
while ((pPlrInfos = GetIndexedInfo(j++)))
{
C4PlayerInfo *pPlrInfo; int32_t i=0;
while (pPlrInfo = pPlrInfos->GetPlayerInfo(i++))
while ((pPlrInfo = pPlrInfos->GetPlayerInfo(i++)))
{
int32_t idTeam = pPlrInfo->GetTeam();
if (idTeam) Game.Teams.GetGenerateTeamByID(idTeam);
@ -890,7 +890,7 @@ C4ClientPlayerInfos *C4PlayerInfoList::AddInfo(C4ClientPlayerInfos *pNewClientIn
}
// ensure all teams specified in the list exist (this should be done for savegame teams as well)
C4PlayerInfo *pInfo; int32_t i=0;
while (pInfo = pNewClientInfo->GetPlayerInfo(i++))
while ((pInfo = pNewClientInfo->GetPlayerInfo(i++)))
{
int32_t idTeam = pInfo->GetTeam();
if (idTeam) Game.Teams.GetGenerateTeamByID(idTeam);
@ -1028,7 +1028,7 @@ C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoByIndex(int32_t index) const
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
if (index-- <= 0)
return pInfo;
}
@ -1044,7 +1044,7 @@ C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoByID(int32_t id) const
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
if (pInfo->GetID() == id) return pInfo;
}
// nothing found
@ -1058,7 +1058,7 @@ C4ClientPlayerInfos *C4PlayerInfoList::GetClientInfoByPlayerID(int32_t id) const
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
if (pInfo->GetID() == id) return ppClients[i];
}
// nothing found
@ -1073,7 +1073,7 @@ C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoByID(int32_t id, int32_t *pidClient
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
if (pInfo->GetID() == id)
{
*pidClient = ppClients[i]->GetClientID();
@ -1092,7 +1092,7 @@ C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoBySavegameID(int32_t id) const
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
if (pInfo->GetAssociatedSavegamePlayerID() == id) return pInfo;
}
// nothing found
@ -1106,7 +1106,7 @@ C4PlayerInfo *C4PlayerInfoList::GetNextPlayerInfoByID(int32_t id) const
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
if (pInfo->GetID() > id)
if (!pSmallest || pSmallest->GetID()>pInfo->GetID())
pSmallest = pInfo;
@ -1121,7 +1121,7 @@ C4PlayerInfo *C4PlayerInfoList::GetActivePlayerInfoByName(const char *szName)
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
if (!pInfo->IsRemoved())
if (SEqualNoCase(szName, pInfo->GetName()))
return pInfo;
@ -1139,7 +1139,7 @@ C4PlayerInfo *C4PlayerInfoList::FindSavegameResumePlayerInfo(const C4PlayerInfo
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
if (!Game.PlayerInfos.GetPlayerInfoByID(pInfo->GetID()) && !Game.PlayerInfos.GetPlayerInfoBySavegameID(pInfo->GetID())) // only unassigned player infos
switch (iMatchLvl)
{
@ -1168,10 +1168,10 @@ C4PlayerInfo *C4PlayerInfoList::FindUnassociatedRestoreInfo(const C4PlayerInfoLi
{
// search given list for a player that's not associated locally
C4ClientPlayerInfos *pRestoreClient; int32_t iClient=0;
while (pRestoreClient = rRestoreInfoList.GetIndexedInfo(iClient++))
while ((pRestoreClient = rRestoreInfoList.GetIndexedInfo(iClient++)))
{
C4PlayerInfo *pRestoreInfo; int32_t iInfo=0;
while (pRestoreInfo = pRestoreClient->GetPlayerInfo(iInfo++))
while ((pRestoreInfo = pRestoreClient->GetPlayerInfo(iInfo++)))
if (pRestoreInfo->IsJoined())
// match association either by savegame ID (before C4Game::InitPlayers) or real ID (after C4Game::InitPlayers)
if (!GetPlayerInfoBySavegameID(pRestoreInfo->GetID()) && !GetPlayerInfoByID(pRestoreInfo->GetID()))
@ -1188,11 +1188,11 @@ bool C4PlayerInfoList::HasSameTeamPlayers(int32_t iClient1, int32_t iClient2) co
const C4ClientPlayerInfos *pCnfo2 = GetInfoByClientID(iClient2);
if (!pCnfo1 || !pCnfo2) return false;
int32_t i=0,j; const C4PlayerInfo *pNfo1, *pNfo2;
while (pNfo1 = pCnfo1->GetPlayerInfo(i++))
while ((pNfo1 = pCnfo1->GetPlayerInfo(i++)))
{
if (!pNfo1->IsUsingTeam()) continue;
j=0;
while (pNfo2 = pCnfo2->GetPlayerInfo(j++))
while ((pNfo2 = pCnfo2->GetPlayerInfo(j++)))
{
if (!pNfo2->IsUsingTeam()) continue;
if (pNfo2->GetTeam() == pNfo1->GetTeam())
@ -1252,7 +1252,7 @@ bool C4PlayerInfoList::LoadFromGameText(const char *pSource)
// hacking some data out of the game text. Luckily, the format is different nowadays.
const char *szPos;
char szLinebuf[30+_MAX_PATH+1];
if (szPos = SSearch(pSource,"[PlayerFiles]"))
if ((szPos = SSearch(pSource,"[PlayerFiles]")))
while (true)
{
szPos = SAdvanceSpace(szPos);
@ -1340,7 +1340,7 @@ bool C4PlayerInfoList::LocalJoinUnjoinedPlayersInQueue()
pkLocal = *ppkLocal;
// check all players
int32_t i=0; C4PlayerInfo *pInfo;
while (pInfo = pkLocal->GetPlayerInfo(i++))
while ((pInfo = pkLocal->GetPlayerInfo(i++)))
// not yet joined?
if (!pInfo->HasJoinIssued())
{
@ -1373,12 +1373,12 @@ void C4PlayerInfoList::CreateRestoreInfosForJoinedScriptPlayers(C4PlayerInfoList
{
C4ClientPlayerInfos *pkInfo = rSavegamePlayers.GetIndexedInfo(i);
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = pkInfo->GetPlayerInfo(j++))
while ((pInfo = pkInfo->GetPlayerInfo(j++)))
if (pInfo->GetType() == C4PT_Script)
{
// safety
C4PlayerInfo *pRejoinInfo;
if (pRejoinInfo = GetPlayerInfoBySavegameID(pInfo->GetID()))
if ((pRejoinInfo = GetPlayerInfoBySavegameID(pInfo->GetID())))
{
LogF("Warning: User player %s takes over script player %s!", pRejoinInfo->GetName(), pInfo->GetName());
continue;
@ -1417,9 +1417,9 @@ bool C4PlayerInfoList::RestoreSavegameInfos(C4PlayerInfoList &rSavegamePlayers)
{
C4ClientPlayerInfos *pkInfo = GetIndexedInfo(i);
int32_t j=0, id; C4PlayerInfo *pInfo, *pSavegameInfo;
while (pInfo = pkInfo->GetPlayerInfo(j++))
while ((pInfo = pkInfo->GetPlayerInfo(j++)))
if (!(id = pInfo->GetAssociatedSavegamePlayerID()))
if (pSavegameInfo = rSavegamePlayers.FindSavegameResumePlayerInfo(pInfo, (MatchingLevel)eMatchingLevel, (MatchingLevel)eMatchingLevel))
if ((pSavegameInfo = rSavegamePlayers.FindSavegameResumePlayerInfo(pInfo, (MatchingLevel)eMatchingLevel, (MatchingLevel)eMatchingLevel)))
{
pInfo->SetAssociatedSavegamePlayer(pSavegameInfo->GetID());
if (eMatchingLevel > PML_PlrName)
@ -1438,10 +1438,10 @@ bool C4PlayerInfoList::RestoreSavegameInfos(C4PlayerInfoList &rSavegamePlayers)
{
C4ClientPlayerInfos *pkInfo = GetIndexedInfo(i);
int32_t j=0, id; C4PlayerInfo *pInfo, *pSavegameInfo;
while (pInfo = pkInfo->GetPlayerInfo(j++))
if (id = pInfo->GetAssociatedSavegamePlayerID())
while ((pInfo = pkInfo->GetPlayerInfo(j++)))
if ((id = pInfo->GetAssociatedSavegamePlayerID()))
{
if (pSavegameInfo = rSavegamePlayers.GetPlayerInfoByID(id))
if ((pSavegameInfo = rSavegamePlayers.GetPlayerInfoByID(id)))
{
// pInfo continues for pSavegameInfo
pInfo->SetSavegameResume(pSavegameInfo);
@ -1495,7 +1495,7 @@ bool C4PlayerInfoList::RecreatePlayerFiles()
{
C4ClientPlayerInfos *pkInfo = ppClients[i];
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = pkInfo->GetPlayerInfo(j++))
while ((pInfo = pkInfo->GetPlayerInfo(j++)))
if (pInfo->IsJoined())
{
// all players in replays and runtime joins; script players even in savegames need to be restored from the scenario goup
@ -1601,7 +1601,7 @@ bool C4PlayerInfoList::RecreatePlayers()
}
// rejoin all joined players of that client
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = pkInfo->GetPlayerInfo(j++))
while ((pInfo = pkInfo->GetPlayerInfo(j++)))
if (pInfo->IsJoined())
{
// get filename to join from
@ -1654,10 +1654,10 @@ bool C4PlayerInfoList::RemoveUnassociatedPlayers(C4PlayerInfoList &rSavegamePlay
// check all joined infos
C4ClientPlayerInfos *pClient; int iClient=0;
bool fSuccess = true;
while (pClient = rSavegamePlayers.GetIndexedInfo(iClient++))
while ((pClient = rSavegamePlayers.GetIndexedInfo(iClient++)))
{
C4PlayerInfo *pInfo; int iInfo = 0;
while (pInfo = pClient->GetPlayerInfo(iInfo++))
while ((pInfo = pClient->GetPlayerInfo(iInfo++)))
{
// remove players that were in the game but are not associated
if (pInfo->IsJoined() && !GetPlayerInfoBySavegameID(pInfo->GetID()))
@ -1681,11 +1681,11 @@ bool C4PlayerInfoList::SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fS
*this = rFromPlayers;
// then remove everything that's no longer joined and update the rest
C4ClientPlayerInfos *pClient; int iClient=0;
while (pClient = GetIndexedInfo(iClient++))
while ((pClient = GetIndexedInfo(iClient++)))
{
// update all players for this client
C4PlayerInfo *pInfo; int iInfo = 0;
while (pInfo = pClient->GetPlayerInfo(iInfo++))
while ((pInfo = pClient->GetPlayerInfo(iInfo++)))
{
bool fKeepInfo = false;
// remove players that are not in the game
@ -1759,10 +1759,10 @@ bool C4PlayerInfoList::SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fS
void C4PlayerInfoList::ResetLeagueProjectedGain(bool fSetUpdated)
{
C4ClientPlayerInfos *pClient; int iClient=0;
while (pClient = GetIndexedInfo(iClient++))
while ((pClient = GetIndexedInfo(iClient++)))
{
C4PlayerInfo *pInfo; int iInfo = 0;
while (pInfo = pClient->GetPlayerInfo(iInfo++))
while ((pInfo = pClient->GetPlayerInfo(iInfo++)))
if (pInfo->IsLeagueProjectedGainValid())
{
pInfo->ResetLeagueProjectedGain();
@ -1809,7 +1809,7 @@ int32_t C4PlayerInfoList::GetStartupCount()
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
if (!pInfo->IsRemoved()) ++iCnt;
}
return iCnt;
@ -1828,7 +1828,7 @@ void C4PlayerInfoList::FixIDCounter()
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
while (pInfo = ppClients[i]->GetPlayerInfo(j++))
while ((pInfo = ppClients[i]->GetPlayerInfo(j++)))
{
iLastPlayerID = Max<int32_t>(pInfo->GetID(), iLastPlayerID);
}

View File

@ -67,7 +67,7 @@ class C4PlayerInfo
PIF_SyncFlags = PIF_Joined | PIF_Removed | PIF_HasRes | PIF_InScenarioFile | PIF_JoinedForSavegameOnly | PIF_Disconnected | PIF_Won | PIF_VotedOut | PIF_AttributesFixed | PIF_NoScenarioInit | PIF_NoEliminationCheck | PIF_Invisible,
// flags to be copied from savegame-player for takeover
PIF_SavegameTakeoverFlags = PIF_Joined | PIF_Removed | PIF_JoinIssued | PIF_AttributesFixed | PIF_NoScenarioInit | PIF_NoEliminationCheck | PIF_Invisible,
PIF_SavegameTakeoverFlags = PIF_Joined | PIF_Removed | PIF_JoinIssued | PIF_AttributesFixed | PIF_NoScenarioInit | PIF_NoEliminationCheck | PIF_Invisible
};
// player attributes used in attribute conflict resolver
@ -101,10 +101,10 @@ class C4PlayerInfo
public:
C4PlayerInfo() // construct empty
: dwFlags(0), iID(0), pRes(0), szFilename(0), dwColor(0xffffffff), sLeagueAccount(""),
dwOriginalColor(0xffffffff), dwAlternateColor(0), idSavegamePlayer(0), idTeam(0),
iLeagueScore(0), iLeagueRank(0), iLeagueRankSymbol(0), iLeagueProjectedGain(-1),
iInGameNumber(-1), iInGameJoinFrame(-1), iInGamePartFrame(-1), eType(C4PT_User), idExtraData(C4ID::None) { }
: dwFlags(0), eType(C4PT_User), iID(0), pRes(0), szFilename(0), dwColor(0xffffffff),
dwOriginalColor(0xffffffff), dwAlternateColor(0), idSavegamePlayer(0), idTeam(0), iInGameNumber(-1),
iInGameJoinFrame(-1), iInGamePartFrame(-1), idExtraData(C4ID::None), sLeagueAccount(""),
iLeagueScore(0), iLeagueRank(0), iLeagueRankSymbol(0), iLeagueProjectedGain(-1) { }
void Clear(); // clear fields
@ -219,7 +219,7 @@ class C4ClientPlayerInfos
CIF_Updated = 1<<1, // set temporarily if changed and not transmissioned to clients (valid for host only)
CIF_Initial = 1<<2, // set for first-time player info packets
CIF_Developer = 1<<3, // set for developer hosts (by regkey); client side check only!
CIF_Removed = 1<<4, // client was removed
CIF_Removed = 1<<4 // client was removed
};
uint32_t dwFlags; // bit mask of the above flags

View File

@ -181,7 +181,7 @@ void C4PlayerInfoListAttributeConflictResolver::ReaddInfoForCheck(C4ClientPlayer
// readd it - must have been in there before, so array is large enough
// and it must have been at the head of the list
ppCheckInfos[iCheckInfoCount++] = pCheckAdd;
};
}
int32_t C4PlayerInfoListAttributeConflictResolver::GetAttributePriorityDifference(const C4PlayerInfo *pInfo1, const C4ClientPlayerInfos *pPck1, const C4PlayerInfo *pInfo2, const C4ClientPlayerInfos *pPck2)
{
@ -227,8 +227,8 @@ bool C4PlayerInfoListAttributeConflictResolver::IsAttributeConflict(const C4Play
{
case C4PlayerInfo::PLRAL_Current: szName2 = pInfo2->GetName(); break;
case C4PlayerInfo::PLRAL_Original: szName2 = pInfo2->GetOriginalName(); break;
default: return SEqualNoCase(szName1, szName2);
}
return SEqualNoCase(szName1, szName2);
}
return false;
}
@ -237,7 +237,7 @@ void C4PlayerInfoListAttributeConflictResolver::MarkConflicts(C4ClientPlayerInfo
{
C4PlayerInfo *pCheckAgainstInfo;
// check current and original attribute against all player infos
for (int32_t j=0; pCheckAgainstInfo = rCheckPacket.GetPlayerInfo(j); ++j)
for (int32_t j=0; (pCheckAgainstInfo = rCheckPacket.GetPlayerInfo(j)); ++j)
{
if (pCheckAgainstInfo->IsUsingAttribute(eAttr)) if (!pResolveInfo->GetID() || pResolveInfo->GetID() != pCheckAgainstInfo->GetID()) if (pResolveInfo != pCheckAgainstInfo)
{
@ -250,6 +250,7 @@ void C4PlayerInfoListAttributeConflictResolver::MarkConflicts(C4ClientPlayerInfo
if (fTestOriginal)
{
if (IsAttributeConflict(pCheckAgainstInfo, pResolveInfo, C4PlayerInfo::PLRAL_Original))
{
if (fHasHigherPrio && !fOriginalConflict && !pLowPrioOriginalConflictPacket)
{
// original attribute is taken by a low prio packet - do not mark an original conflict, but remember the packet
@ -263,11 +264,14 @@ void C4PlayerInfoListAttributeConflictResolver::MarkConflicts(C4ClientPlayerInfo
pLowPrioOriginalConflictPacket = NULL;
fOriginalConflict = true;
}
}
if (IsAttributeConflict(pCheckAgainstInfo, pResolveInfo, C4PlayerInfo::PLRAL_Alternate))
{
if (fHasHigherPrio && !fAlternateConflict && !pLowPrioAlternateConflictPacket)
pLowPrioAlternateConflictPacket = &rCheckPacket;
else
fAlternateConflict = true;
}
}
}
}
@ -305,6 +309,7 @@ void C4PlayerInfoListAttributeConflictResolver::ResolveInInfo()
if (!iTries)
{
if (pResolveInfo->GetColor() != pResolveInfo->GetOriginalColor())
{
if (!fOriginalConflict)
{
// revert to original color!
@ -325,6 +330,7 @@ void C4PlayerInfoListAttributeConflictResolver::ResolveInInfo()
// done with this player (breaking the trial-loop)
break;
}
}
}
// conflict found?
if (!fCurrentConflict)
@ -372,7 +378,7 @@ void C4PlayerInfoListAttributeConflictResolver::ResolveInPacket()
// check all player infos
fAnyChange = false;
int32_t iCheck = 0;
while (pResolveInfo = pResolvePacket->GetPlayerInfo(iCheck++))
while ((pResolveInfo = pResolvePacket->GetPlayerInfo(iCheck++)))
{
// not already joined? Joined player must not change their attributes!
if (pResolveInfo->HasJoined()) continue;

View File

@ -671,7 +671,7 @@ StdBuf C4Playback::ReWriteBinary()
const int OUTPUT_GROW = 16 * 1024;
StdBuf Output; int iPos = 0;
bool fFinished = false;
uint32_t iFrame = 0;
int32_t iFrame = 0;
for(chunks_t::const_iterator i = chunks.begin(); !fFinished && i != chunks.end(); i++)
{
// Check frame difference
@ -783,6 +783,9 @@ void C4Playback::Strip()
i->pCtrl->Remove(pPkt);
}
break;
default:
// TODO
break;
}
}
// Strip empty control lists (always)
@ -813,6 +816,9 @@ void C4Playback::Strip()
case CID_Message:
if (fStripMessages) fStripThis=true;
break;
default:
// TODO
break;
}
if (fStripThis)
{
@ -1157,7 +1163,7 @@ bool C4Playback::StreamToRecord(const char *szStream, StdStrBuf *pRecordFile)
// Parse
C4Playback Playback;
Playback.ReadBinary(StreamData);
LogF("Got %d chunks from stream", Playback.chunks.size());
LogF("Got %lu chunks from stream", static_cast<unsigned long>(Playback.chunks.size()));
// Get first chunk, which must contain the initial
chunks_t::iterator chunkIter = Playback.chunks.begin();
@ -1166,7 +1172,6 @@ bool C4Playback::StreamToRecord(const char *szStream, StdStrBuf *pRecordFile)
// Get initial chunk, go over file name
StdBuf InitialData = *chunkIter->pFileData;
const char *szInitialFilename = chunkIter->Filename.getData();
// Put to temporary file and unpack
char szInitial[_MAX_PATH+1] = "~initial.tmp";

View File

@ -93,7 +93,7 @@ enum C4RecordChunkType // record file chunk type
RCT_Custom = 0xc0, // varies
RCT_Undefined = 0xff,
RCT_Undefined = 0xff
};
#ifdef DEBUGREC
@ -246,7 +246,7 @@ class C4PktDebugRec : public C4PktBuf
C4RecordChunkType getType() const { return eType; }
virtual void CompileFunc(StdCompiler *pComp);
ALLOW_TEMP_TO_REF(C4PktDebugRec);
ALLOW_TEMP_TO_REF(C4PktDebugRec)
};
class C4Record // demo recording

View File

@ -227,7 +227,7 @@ C4RoundResultsPlayers &C4RoundResultsPlayers::operator =(const C4RoundResultsPla
{
Clear();
C4RoundResultsPlayer *pPlr; int32_t i=0;
while (pPlr = cpy.GetByIndex(i++))
while ((pPlr = cpy.GetByIndex(i++)))
Add(new C4RoundResultsPlayer(*pPlr));
return *this;
}
@ -282,12 +282,12 @@ void C4RoundResults::EvaluateGoals(C4IDList &GoalList, C4IDList &FulfilledGoalLi
// Items
bool fRivalvry = !!Game.ObjectCount(C4ID::Rivalry);
int32_t cnt; C4ID idGoal;
for (cnt=0; idGoal=::Objects.GetListID(C4D_Goal,cnt); cnt++)
for (cnt=0; (idGoal=::Objects.GetListID(C4D_Goal,cnt)); cnt++)
{
// determine if the goal is fulfilled - do the calls even if the menu is not to be opened to ensure synchronization
bool fFulfilled = false;;
C4Object *pObj;
if (pObj = ::Objects.Find(idGoal))
if ((pObj = ::Objects.Find(idGoal)))
{
if (fRivalvry)
{
@ -327,7 +327,7 @@ void C4RoundResults::EvaluateLeague(const char *szResultMsg, bool fSuccess, cons
Game.RoundResults.EvaluateNetwork(fSuccess ? C4RoundResults::NR_LeagueOK : C4RoundResults::NR_LeagueError, szResultMsg);
// Evaluation called by league: Sets new league scores and ranks
C4RoundResultsPlayer *pPlr, *pOwnPlr; int32_t i = 0;
while (pPlr = rLeagueInfo.GetByIndex(i++))
while ((pPlr = rLeagueInfo.GetByIndex(i++)))
{
pOwnPlr = Players.GetCreateByID(pPlr->GetID());
pOwnPlr->EvaluateLeague(pPlr);

View File

@ -130,7 +130,7 @@ class C4RoundResults
NR_None=0, // undefined
NR_LeagueOK, // league evaluated
NR_LeagueError, // league evaluation error
NR_NetError, // network disconnect
NR_NetError // network disconnect
};
private:

View File

@ -63,7 +63,7 @@ void C4Team::AddPlayer(C4PlayerInfo &rInfo, bool fAdjustPlayer)
// add player; grow vector if necessary
if (iPlayerCount >= iPlayerCapacity)
{
int32_t *piNewPlayers = new int32_t[iPlayerCapacity = iPlayerCount+4&~3];
int32_t *piNewPlayers = new int32_t[iPlayerCapacity = (iPlayerCount+4)&~3];
if (iPlayerCount) memcpy(piNewPlayers, piPlayers, iPlayerCount*sizeof(int32_t));
delete [] piPlayers; piPlayers = piNewPlayers;
}
@ -121,7 +121,7 @@ int32_t C4Team::GetFirstUnjoinedPlayerID() const
int32_t i=iPlayerCount, idPlr, *piPlr = piPlayers;
C4PlayerInfo *pInfo;
while (i--)
if (pInfo = Game.PlayerInfos.GetPlayerInfoByID(idPlr = *piPlr++))
if ((pInfo = Game.PlayerInfos.GetPlayerInfoByID(idPlr = *piPlr++)))
if (!pInfo->HasJoinIssued())
return idPlr;
// none found
@ -148,8 +148,8 @@ void C4Team::RecheckPlayers()
for (int32_t i=0; i<iPlayerCount; ++i)
{
bool fIsValid = false; int32_t id; C4PlayerInfo *pInfo;
if (id = piPlayers[i])
if (pInfo = Game.PlayerInfos.GetPlayerInfoByID(id))
if ((id = piPlayers[i]))
if ((pInfo = Game.PlayerInfos.GetPlayerInfoByID(id)))
if (pInfo->GetTeam() == GetID())
if (pInfo->IsUsingTeam())
fIsValid = true;
@ -158,7 +158,7 @@ void C4Team::RecheckPlayers()
}
// now check for any new players in the team
int32_t id = 0; C4PlayerInfo *pInfo;
while (pInfo = Game.PlayerInfos.GetNextPlayerInfoByID(id))
while ((pInfo = Game.PlayerInfos.GetNextPlayerInfoByID(id)))
{
id = pInfo->GetID();
if (pInfo->GetTeam() == GetID())
@ -194,7 +194,7 @@ void C4Team::RecheckColor(C4TeamList &rForList)
{
dwClr = GenerateRandomPlayerColor(iTry);
int32_t iIdx=0; C4Team *pTeam; bool fOK=true;
while (pTeam = rForList.GetTeamByIndex(iIdx++))
while ((pTeam = rForList.GetTeamByIndex(iIdx++)))
if (pTeam != this)
if (IsColorConflict(pTeam->GetColor(), dwClr))
{
@ -224,7 +224,7 @@ StdStrBuf C4Team::GetNameWithParticipants() const
{
int32_t iPlr = GetIndexedPlayer(j);
C4PlayerInfo *pPlrInfo;
if (iPlr) if (pPlrInfo = Game.PlayerInfos.GetPlayerInfoByID(iPlr))
if (iPlr) if ((pPlrInfo = Game.PlayerInfos.GetPlayerInfoByID(iPlr)))
{
if (iTeamPlrCount++) sTeamName.Append(", ");
sTeamName.Append(pPlrInfo->GetName());
@ -242,8 +242,8 @@ bool C4Team::HasWon() const
for (int32_t i=0; i<iPlayerCount; ++i)
{
int32_t id; C4PlayerInfo *pInfo;
if (id = piPlayers[i])
if (pInfo = Game.PlayerInfos.GetPlayerInfoByID(id))
if ((id = piPlayers[i]))
if ((pInfo = Game.PlayerInfos.GetPlayerInfoByID(id)))
if (pInfo->HasWon())
{
fHasWon = true;
@ -279,7 +279,7 @@ void C4TeamList::Clear()
C4TeamList &C4TeamList::operator =(const C4TeamList &rCopy)
{
Clear();
if (iTeamCount = iTeamCapacity = rCopy.iTeamCount)
if ((iTeamCount = iTeamCapacity = rCopy.iTeamCount))
ppList = new C4Team *[iTeamCapacity];
for(int i = 0; i < iTeamCount; i++)
ppList[i] = new C4Team(*rCopy.ppList[i]);
@ -322,7 +322,7 @@ bool C4TeamList::CanLocalChooseTeam(int32_t idPlayer) const
C4Team *pCurrentTeam = NULL, *pCheck;
if (idPlayer) pCurrentTeam = GetTeamByPlayerID(idPlayer);
int32_t iCheckTeam=0;
while (pCheck = GetTeamByIndex(iCheckTeam++))
while ((pCheck = GetTeamByIndex(iCheckTeam++)))
if (pCheck != pCurrentTeam)
if (!pCheck->IsFull())
break;
@ -342,7 +342,7 @@ void C4TeamList::AddTeam(C4Team *pNewTeam)
// add team; grow vector if necessary
if (iTeamCount >= iTeamCapacity)
{
C4Team **ppNewTeams = new C4Team*[iTeamCapacity = iTeamCount+4&~3];
C4Team **ppNewTeams = new C4Team*[(iTeamCapacity = iTeamCount+4)&~3];
if (iTeamCount) memcpy(ppNewTeams, ppList, iTeamCount*sizeof(C4Team *));
delete [] ppList; ppList = ppNewTeams;
}
@ -569,7 +569,7 @@ void C4TeamList::CompileFunc(StdCompiler *pComp)
{
while (iOldTeamCount--) delete ppList[iOldTeamCount];
delete [] ppList;
if (iTeamCapacity = iTeamCount)
if ((iTeamCapacity = iTeamCount))
{
ppList = new C4Team *[iTeamCapacity];
ZeroMemory(ppList, sizeof(C4Team *)*iTeamCapacity);
@ -636,7 +636,7 @@ bool C4TeamList::Load(C4Group &hGroup, class C4Scenario *pInitDefault, class C4L
}
// post-initialization: Generate default team colors
int32_t iTeam=0; C4Team *pTeam;
while (pTeam = GetTeamByIndex(iTeam++))
while ((pTeam = GetTeamByIndex(iTeam++)))
pTeam->RecheckColor(*this);
return true;
}
@ -708,7 +708,7 @@ void C4TeamList::ReassignAllTeams()
if (!::Control.isCtrlHost()) return;
// go through all player infos; reset team in them
int32_t idStart = -1; C4PlayerInfo *pNfo;
while (pNfo = Game.PlayerInfos.GetNextPlayerInfoByID(idStart))
while ((pNfo = Game.PlayerInfos.GetNextPlayerInfoByID(idStart)))
{
idStart = pNfo->GetID();
if (pNfo->HasJoinIssued()) continue;
@ -725,7 +725,7 @@ void C4TeamList::ReassignAllTeams()
RecheckPlayers();
// reassign them
idStart = -1;
while (pNfo = Game.PlayerInfos.GetNextPlayerInfoByID(idStart))
while ((pNfo = Game.PlayerInfos.GetNextPlayerInfoByID(idStart)))
{
idStart = pNfo->GetID();
if (pNfo->HasJoinIssued()) continue;
@ -836,7 +836,7 @@ int32_t C4TeamList::GetForcedTeamSelection(int32_t idForPlayer) const
C4Team *pOKTeam = NULL, *pCheck;
if (idForPlayer) pOKTeam = GetTeamByPlayerID(idForPlayer); // curent team is always possible, even if full
int32_t iCheckTeam=0;
while (pCheck = GetTeamByIndex(iCheckTeam++))
while ((pCheck = GetTeamByIndex(iCheckTeam++)))
if (!pCheck->IsFull())
{
// this team could be joined

View File

@ -27,7 +27,7 @@ class C4Group;
// class predec
class C4TeamList;
namespace C4GUI { class ComboBox_FillCB; };
namespace C4GUI { class ComboBox_FillCB; }
// constant used by lobby to indicate invisible, random team
const int32_t TEAMID_Unknown = -1;
@ -107,7 +107,7 @@ class C4TeamList
TEAM_Dist = 4,
TEAM_AllowTeamSwitch = 5,
TEAM_AutoGenerateTeams = 6,
TEAM_TeamColors = 7,
TEAM_TeamColors = 7
};
// team distribution configuration
@ -118,7 +118,7 @@ class C4TeamList
TEAMDIST_Host = 1, // host decides teams
TEAMDIST_Random = 2, // fixed random teams
TEAMDIST_RandomInv = 3, // fixed random teams invisible in lobby
TEAMDIST_Last = 3,
TEAMDIST_Last = 3
};
private:
@ -140,7 +140,7 @@ class C4TeamList
public:
C4TeamList() : ppList(NULL), iTeamCount(0), iTeamCapacity(0), iLastTeamID(0), fAllowHostilityChange(true), fAllowTeamSwitch(false),
fActive(true), fCustom(false), eTeamDist(TEAMDIST_Free), fTeamColors(false), fAutoGenerateTeams(false), iMaxScriptPlayers(0) {}
fActive(true), fCustom(false), fTeamColors(false), fAutoGenerateTeams(false), eTeamDist(TEAMDIST_Free), iMaxScriptPlayers(0) {}
~C4TeamList() { Clear(); }
void Clear();

View File

@ -1388,7 +1388,7 @@ void C4Console::UpdateInputCtrl()
if (pRef=Game.Script.GetSFunc(0))
SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)"----------");
#endif
for (cnt=0; pRef=Game.Script.GetSFunc(cnt); cnt++)
for (cnt=0; (pRef=Game.Script.GetSFunc(cnt)); cnt++)
{
#ifdef _WIN32
SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)pRef->Name);
@ -1487,10 +1487,12 @@ void C4Console::PlayerJoin()
char szPlayerFilename[_MAX_PATH+1];
for (int iPar=0; SCopySegment(c4plist,iPar,szPlayerFilename,';',_MAX_PATH); iPar++)
if (szPlayerFilename[0])
{
if (::Network.isEnabled())
::Network.Players.JoinLocalPlayer(szPlayerFilename, true);
else
::Players.CtrlJoinLocalNoNetwork(szPlayerFilename, Game.Clients.getLocalID(), Game.Clients.getLocalName());
}
}

View File

@ -66,6 +66,7 @@ class C4Console: public C4ConsoleBase
void Default();
virtual void Clear();
virtual void Close();
using C4ConsoleBase::Init;
virtual CStdWindow * Init(CStdApp * app);
void Execute();
void ClearPointers(C4Object *pObj);

View File

@ -66,7 +66,13 @@ void C4EditCursor::Execute()
{
// alt check
bool fAltIsDown = Application.IsAltDown();
if (fAltIsDown != fAltWasDown) if (fAltWasDown = fAltIsDown) AltDown(); else AltUp();
if (fAltIsDown != fAltWasDown)
{
if ((fAltWasDown = fAltIsDown))
AltDown();
else
AltUp();
}
// drawing
switch (Mode)
{
@ -718,7 +724,7 @@ void C4EditCursor::ApplyToolPicker()
{
case C4LSC_Static:
// Material-texture from map
if (byIndex=::Landscape.GetMapIndex(X/::Landscape.MapZoom,Y/::Landscape.MapZoom))
if ((byIndex=::Landscape.GetMapIndex(X/::Landscape.MapZoom,Y/::Landscape.MapZoom)))
{
const C4TexMapEntry *pTex = ::TextureMap.GetEntry(byIndex & (IFT-1));
if(pTex)

View File

@ -48,7 +48,7 @@
enum
{
C4_LIST_COL_OBJECT,
C4_LIST_N_COLUMNS,
C4_LIST_N_COLUMNS
};
typedef struct _C4List C4List;
@ -676,10 +676,10 @@ void C4ObjectListDlg::Update(C4ObjectList &rSelection)
}
C4ObjectListDlg::C4ObjectListDlg():
updating_selection(false),
window(0),
treeview(0),
model(0)
model(0),
updating_selection(false)
{
}
@ -715,8 +715,8 @@ static void icon_cell_data_func(GtkTreeViewColumn* column, GtkCellRenderer* rend
if(pixbuf == NULL)
{
/* Not yet cached, create from Graphics */
CSurface* surface = object->Def->Graphics.Bitmap;
if(object->Def->Graphics.BitmapClr) surface = object->Def->Graphics.BitmapClr;
CSurface* surface = object->Def->Graphics.Bmp.Bitmap;
if(object->Def->Graphics.Bmp.BitmapClr) surface = object->Def->Graphics.Bmp.BitmapClr;
const C4Rect& picture = object->Def->PictureRect;
pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, picture.Wdt, picture.Hgt);

View File

@ -364,9 +364,9 @@ void C4PropertyDlg::UpdateInputCtrl(C4Object *pObj)
// Object script available
if (pObj && pObj->Def)
// Scan all functions
for (cnt=0; pRef=pObj->Def->Script.GetSFunc(cnt); cnt++)
for (cnt=0; (pRef=pObj->Def->Script.GetSFunc(cnt)); cnt++)
// Public functions only
if (pRef->Access=AA_PUBLIC)
if ((pRef->Access=AA_PUBLIC))
{
#ifdef _WIN32
// Insert divider if necessary

View File

@ -107,7 +107,7 @@ namespace {
gdk_pixbuf_unref(pixbuf);
return image;
}
};
}
#endif
#ifdef _WIN32
@ -996,7 +996,7 @@ void C4ToolsDlg::AssertValidTexture()
if (::TextureMap.GetIndex(Material,Texture,false)) return;
// Find valid material-texture
const char *szTexture;
for (int32_t iTexture=0; szTexture=::TextureMap.GetTexture(iTexture); iTexture++)
for (int32_t iTexture=0; (szTexture=::TextureMap.GetTexture(iTexture)); iTexture++)
{
if (::TextureMap.GetIndex(Material,szTexture,false))
{ SelectTexture(szTexture); return; }

View File

@ -126,12 +126,14 @@ void C4Landscape::ExecuteScan()
const int32_t iTemperature = ::Weather.GetTemperature();
for(mat = 0; mat < ::MaterialMap.Num; mat++)
if(MatCount[mat])
{
if(::MaterialMap.Map[mat].BelowTempConvertTo &&
iTemperature < ::MaterialMap.Map[mat].BelowTempConvert)
break;
else if(::MaterialMap.Map[mat].AboveTempConvertTo &&
iTemperature > ::MaterialMap.Map[mat].AboveTempConvert)
break;
}
if(mat >= ::MaterialMap.Num)
return;
@ -322,7 +324,7 @@ int32_t C4Landscape::ChunkyRandom(int32_t &iOffset, int32_t iRange)
void C4Landscape::DrawChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, int32_t iChunkType, int32_t cro)
{
BYTE top_rough; BYTE side_rough;
BYTE top_rough = 0; BYTE side_rough = 0;
// what to do?
switch(iChunkType)
{
@ -624,13 +626,13 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo
CSurface8 * sfcMap=NULL;
// Static map from scenario
if (hGroup.AccessEntry(C4CFN_Map))
if (sfcMap=GroupReadSurface8(hGroup))
if ((sfcMap=GroupReadSurface8(hGroup)))
if (!fLandscapeModeSet) Mode=C4LSC_Static;
// allow C4CFN_Landscape as map for downwards compatibility
if (!sfcMap)
if (hGroup.AccessEntry(C4CFN_Landscape))
if (sfcMap=GroupReadSurface8(hGroup))
if ((sfcMap=GroupReadSurface8(hGroup)))
{
if (!fLandscapeModeSet) Mode=C4LSC_Static;
fMapChanged = true;
@ -638,12 +640,12 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo
// dynamic map from file
if (!sfcMap)
if (sfcMap=CreateMapS2(hGroup))
if ((sfcMap=CreateMapS2(hGroup)))
if (!fLandscapeModeSet) Mode=C4LSC_Dynamic;
// Dynamic map by scenario
if (!sfcMap && !fOverloadCurrent)
if (sfcMap=CreateMap())
if ((sfcMap=CreateMap()))
if (!fLandscapeModeSet) Mode=C4LSC_Dynamic;
@ -1000,7 +1002,7 @@ int32_t C4Landscape::BlastFreePix(int32_t tx, int32_t ty, int32_t grade, int32_t
void C4Landscape::DigFree(int32_t tx, int32_t ty, int32_t rad, bool fRequest, C4Object *pByObj)
{
int32_t ycnt,xcnt,iLineWidth,iLineY,iMaterial;
int32_t ycnt,xcnt,iLineWidth = 0,iLineY,iMaterial;
// Dig free
for (ycnt=-rad; ycnt<rad; ycnt++)
{
@ -1155,12 +1157,16 @@ void C4Landscape::FindMatTop(int32_t mat, int32_t &x, int32_t &y)
{
// Left
if (fLeft)
{
if (GetMat(x-cslide,y)!=mat) fLeft=false;
else if (GetMat(x-cslide,y-1)==mat) { tslide=1; break; }
}
// Right
if (fRight)
{
if (GetMat(x+cslide,y)!=mat) fRight=false;
else if (GetMat(x+cslide,y-1)==mat) { tslide=2; break; }
}
}
// Slide
@ -1223,7 +1229,7 @@ bool C4Landscape::InsertMaterial(int32_t mat, int32_t tx, int32_t ty, int32_t vx
// Try reaction with material below
C4MaterialReaction *pReact; int32_t tmat;
if (pReact = ::MaterialMap.GetReactionUnsafe(mat, tmat=GetMat(tx,ty+Sign(GravAccel))))
if ((pReact = ::MaterialMap.GetReactionUnsafe(mat, tmat=GetMat(tx,ty+Sign(GravAccel)))))
{
FIXED fvx=FIXED10(vx), fvy=FIXED10(vy);
if ((*pReact->pFunc)(pReact, tx,ty, tx,ty+Sign(GravAccel), fvx,fvy, mat,tmat, meePXSPos,NULL))
@ -1233,7 +1239,7 @@ bool C4Landscape::InsertMaterial(int32_t mat, int32_t tx, int32_t ty, int32_t vx
}
}
int omat;
int omat = 0;
if (Game.C4S.Game.Realism.LandscapeInsertThrust)
omat = GetMat(tx, ty);
@ -1263,16 +1269,20 @@ bool C4Landscape::FindMatPath(int32_t &fx, int32_t &fy, int32_t ydir, int32_t md
{
// Check left
if (fLeft)
{
if (GetDensity(fx-cslide,fy)>=mdens) // Left clogged
fLeft=false;
else if (GetDensity(fx-cslide,fy+ydir)<mdens) // Left slide okay
{ fx--; return true; }
}
// Check right
if (fRight)
{
if (GetDensity(fx+cslide,fy)>=mdens) // Right clogged
fRight=false;
else if (GetDensity(fx+cslide,fy+ydir)<mdens) // Right slide okay
{ fx++; return true; }
}
}
return false;
@ -1293,16 +1303,20 @@ bool C4Landscape::FindMatSlide(int32_t &fx, int32_t &fy, int32_t ydir, int32_t m
{
// Check left
if (fLeft)
{
if (GetDensity(fx-cslide,fy)>=mdens && GetDensity(fx-cslide,fy+ydir)>=mdens) // Left clogged
fLeft=false;
else if (GetDensity(fx-cslide,fy+ydir)<mdens) // Left slide okay
{ fx-=cslide; fy+=ydir; return true; }
}
// Check right
if (fRight)
{
if (GetDensity(fx+cslide,fy)>=mdens && GetDensity(fx+cslide,fy+ydir)>=mdens) // Right clogged
fRight=false;
else if (GetDensity(fx+cslide,fy+ydir)<mdens) // Right slide okay
{ fx+=cslide; fy+=ydir; return true; }
}
}
return false;
@ -1369,7 +1383,7 @@ bool C4Landscape::FindMatPathPush(int32_t &fx, int32_t &fy, int32_t mdens, int32
// Save startpoint of search
int32_t sx = x, sy = y, sdir = dir;
// Best point so far
bool fGotBest = false; int32_t bx, by, bdist;
bool fGotBest = false; int32_t bx = 0, by = 0, bdist = 0;
// Start searching
do
{
@ -1689,12 +1703,16 @@ bool AboveSemiSolid(int32_t &rx, int32_t &ry) // Nearest free above semi solid
{
// Check upwards
if (cy1>=0)
{
if (GBackSemiSolid(rx,cy1)) UseUpwardsNextFree=true;
else if (UseUpwardsNextFree) { ry=cy1; return true; }
}
// Check downwards
if (cy2<GBackHgt)
{
if (!GBackSemiSolid(rx,cy2)) UseDownwardsNextSolid=true;
else if (UseDownwardsNextSolid) { ry=cy2; return true; }
}
// Advance
cy1--; cy2++;
}
@ -1756,14 +1774,18 @@ bool FindLiquidHeight(int32_t cx, int32_t &ry, int32_t hgt)
{
// Check upwards
if (cy1>=0)
{
if (GBackLiquid(cx,cy1))
{ rl1++; if (rl1>=hgt) { ry=cy1+hgt/2; return true; } }
else rl1=0;
}
// Check downwards
if (cy2+1<GBackHgt)
{
if (GBackLiquid(cx,cy2))
{ rl2++; if (rl2>=hgt) { ry=cy2-hgt/2; return true; } }
else rl2=0;
}
// Advance
cy1--; cy2++;
}
@ -1815,6 +1837,7 @@ bool FindSurfaceLiquid(int32_t &rx, int32_t &ry, int32_t width, int32_t height)
{
// Left search
if (cx1>0) // Still going
{
if (!AboveSemiSolid(cx1,cy1)) cx1=-1; // Abort left
else
{
@ -1822,8 +1845,10 @@ bool FindSurfaceLiquid(int32_t &rx, int32_t &ry, int32_t width, int32_t height)
if (lokay) rl1++; // Run okay
else rl1=0; // No run
}
}
// Right search
if (cx2<GBackWdt) // Still going
{
if (!AboveSemiSolid(cx2,cy2)) cx2=GBackWdt; // Abort right
else
{
@ -1831,6 +1856,7 @@ bool FindSurfaceLiquid(int32_t &rx, int32_t &ry, int32_t width, int32_t height)
if (lokay) rl2++; // Run okay
else rl2=0; // No run
}
}
// Check runs
if (rl1>=width) { rx=cx1+rl1/2; ry=cy1; fFound=true; break; }
if (rl2>=width) { rx=cx2-rl2/2; ry=cy2; fFound=true; break; }
@ -1849,12 +1875,16 @@ bool FindLiquid(int32_t &rx, int32_t &ry, int32_t width, int32_t height)
{
// Left search
if (cx1>0)
{
if (FindLiquidHeight(cx1,cy1,height)) rl1++;
else rl1=0;
}
// Right search
if (cx2<GBackWdt)
{
if (FindLiquidHeight(cx2,cy2,height)) rl2++;
else rl2=0;
}
// Check runs
if (rl1>=width) { rx=cx1+rl1/2; ry=cy1; return true; }
if (rl2>=width) { rx=cx2-rl2/2; ry=cy2; return true; }
@ -1883,21 +1913,29 @@ bool FindLevelGround(int32_t &rx, int32_t &ry, int32_t width, int32_t hrange)
{
// Left search
if (cx1>0) // Still going
{
if (!AboveSemiSolid(cx1,cy1)) cx1=-1; // Abort left
else
{
if (GBackSolid(cx1,cy1+1) && (Abs(cy1-rh1)<hrange))
rl1++; // Run okay
else
{ rl1=0; rh1=cy1; } // No run
}
}
// Right search
if (cx2<GBackWdt) // Still going
{
if (!AboveSemiSolid(cx2,cy2)) cx2=GBackWdt; // Abort right
else
{
if (GBackSolid(cx2,cy2+1) && (Abs(cy2-rh2)<hrange))
rl2++; // Run okay
else
{ rl2=0; rh2=cy2; } // No run
}
}
// Check runs
if (rl1>=width) { rx=cx1+rl1/2; ry=cy1; fFound=true; break; }
@ -1940,23 +1978,31 @@ bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt,
{
// Left search
if (cx1>0) // Still going
{
if (!AboveSemiSolid(cx1,cy1))
cx1=-1; // Abort left
else
{
if (GBackSolid(cx1,cy1+1) && (Abs(cy1-rh1)<hrange))
rl1++; // Run okay
else
{ rl1=0; rh1=cy1; } // No run
}
}
// Right search
if (cx2<GBackWdt) // Still going
{
if (!AboveSemiSolid(cx2,cy2))
cx2=GBackWdt; // Abort right
else
{
if (GBackSolid(cx2,cy2+1) && (Abs(cy2-rh2)<hrange))
rl2++; // Run okay
else
{ rl2=0; rh2=cy2; } // No run
}
}
// Check runs & object overlap
if (rl1>=wdt) if (cx1>0)
@ -2096,7 +2142,7 @@ bool ConstructionCheck(C4PropList * PropList, int32_t iX, int32_t iY, C4Object *
}
// Check other structures
C4Object *other;
if (other=Game.OverlapObject(rtx,rty,wdt,hgt,ndef->Category))
if ((other=Game.OverlapObject(rtx,rty,wdt,hgt,ndef->Category)))
{
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOOTHER"),other->GetName ()).getData(),pByObj,FRed);
return false;

View File

@ -143,17 +143,25 @@ class C4Landscape
extern BYTE MCVehic;
// Border checks
if (x<0)
{
if (y<LeftOpen) return 0;
else return MCVehic;
}
if (x>=Width)
{
if (y<RightOpen) return 0;
else return MCVehic;
}
if (y<0)
{
if (TopOpen) return 0;
else return MCVehic;
}
if (y>=Height)
{
if (BottomOpen) return 0;
else return MCVehic;
}
return Surface8->_GetPix(x,y);
}
inline int32_t _GetMat(int32_t x, int32_t y) // get landscape material (bounds not checked)

View File

@ -38,7 +38,7 @@ C4MCCallbackArray::C4MCCallbackArray(C4AulFunc *pSFunc, C4MapCreatorS2 *pMapCrea
// zero fields
pMap=NULL; pNext=NULL;
// store and add in map creator
if (this->pMapCreator=pMapCreator)
if ((this->pMapCreator=pMapCreator))
pMapCreator->CallbackArrays.Add(this);
// done
}
@ -114,7 +114,7 @@ void C4MCCallbackArrayList::Clear()
{
// remove all arrays
C4MCCallbackArray *pArray, *pNext=pFirst;
while (pArray=pNext)
while ((pArray=pNext))
{
pNext=pArray->pNext;
delete pArray;
@ -168,10 +168,10 @@ void C4MCNode::Reg2Owner(C4MCNode *pOwner)
// init list
Child0=ChildL=NULL;
// owner?
if (Owner=pOwner)
if ((Owner=pOwner))
{
// link into it
if (Prev = Owner->ChildL)
if ((Prev = Owner->ChildL))
Prev->Next = this;
else
Owner->Child0 = this;
@ -384,6 +384,9 @@ bool C4MCOverlay::SetField(C4MCParser *pParser, const char *szField, const char
// add to main
*((C4MCCallbackArray **) pTarget) = new C4MCCallbackArray(pSFunc, MapCreator);
}
default:
// TODO
break;
}
// done
return true;
@ -420,7 +423,7 @@ void C4MCOverlay::Evaluate()
if (Owner)
{
C4MCOverlay *pOwnrOvrl;
if (pOwnrOvrl=OwnerOverlay())
if ((pOwnrOvrl=OwnerOverlay()))
{
//int32_t iOwnerX=pOwnrOvrl->X; int32_t iOwnerY=pOwnrOvrl->Y;
int32_t iOwnerWdt=pOwnrOvrl->Wdt; int32_t iOwnerHgt=pOwnrOvrl->Hgt;
@ -623,7 +626,7 @@ void C4MCPoint::Evaluate()
if (Owner)
{
C4MCOverlay *pOwnrOvrl;
if (pOwnrOvrl=OwnerOverlay())
if ((pOwnrOvrl=OwnerOverlay()))
{
X = RX.Evaluate(pOwnrOvrl->Wdt) + pOwnrOvrl->X;
Y = RY.Evaluate(pOwnrOvrl->Hgt) + pOwnrOvrl->Y;
@ -776,7 +779,7 @@ C4MCMap *C4MapCreatorS2::GetMap(const char *szMapName)
if (szMapName && *szMapName)
{
// by name...
if (pNode = GetNodeByName(szMapName))
if ((pNode = GetNodeByName(szMapName)))
if (pNode->Type() == MCN_Map)
pMap = (C4MCMap *) pNode;
}
@ -891,7 +894,7 @@ bool C4MCParser::AdvanceSpaces()
// defaultly, not in comment
int32_t InComment = 0; // 0/1/2 = no comment/line comment/multi line comment
// don't go past end
while (C = *CPos)
while ((C = *CPos))
{
// loop until out of comment and non-whitespace is found
switch (InComment)
@ -952,7 +955,7 @@ bool C4MCParser::GetNextToken()
case TGS_None:
// get token type by first char
// +/- are operators
if (((C >= '0') && (C <= '9') || (C == '+') || (C == '-')))
if ((((C >= '0') && (C <= '9')) || (C == '+') || (C == '-')))
State = TGS_Int; // integer by +, -, 0-9
else if (C == '#') State = TGS_Dir; // directive by "#"
else if (C == ';') {CPos++; CurrToken=MCT_SCOLON; return true; } // ";"
@ -1036,7 +1039,7 @@ void C4MCParser::ParseTo(C4MCNode *pToNode)
{
C4MCNode *pNewNode=NULL; // new node
bool Done=false; // finished?
C4MCNodeType LastOperand; // last first operand of operator
C4MCNodeType LastOperand = C4MCNodeType(-1); // last first operand of operator
char FieldName[C4MaxName];// buffer for current field to access
C4MCNode *pCpyNode; // node to copy from
// current state
@ -1442,7 +1445,7 @@ bool PreparePeek(C4MCOverlay **ppOvrl, int32_t &iX, int32_t &iY, C4MCOverlay **p
if (!pOvrl2) return false;
// get uppermost overlay
C4MCOverlay *pNextOvrl;
for (*ppTopOvrl=pOvrl2; pNextOvrl=(*ppTopOvrl)->OwnerOverlay(); *ppTopOvrl=pNextOvrl) {}
for (*ppTopOvrl=pOvrl2; (pNextOvrl=(*ppTopOvrl)->OwnerOverlay()); *ppTopOvrl=pNextOvrl) {}
// get first of operator-chain
pOvrl2=pOvrl2->FirstOfChain();
// set new overlay
@ -1625,7 +1628,7 @@ bool AlgoPolygon(C4MCOverlay *pOvrl, int32_t iX, int32_t iY)
else
{
//if edge intersects line
if ((uY < iY == iY < cY) && (lX >= iX)) count++;
if ((uY < iY) == (iY < cY) && (lX >= iX)) count++;
ignore = false;
uX = cX;
uY = cY;
@ -1646,7 +1649,7 @@ bool AlgoPolygon(C4MCOverlay *pOvrl, int32_t iX, int32_t iY)
else
{
//if edge intersects line
if (uY < iY == iY <= cY)
if ((uY < iY) == (iY <= cY))
{
//and edge intersects ray, because both points are right of iX
if (iX < Min (uX, cX))
@ -1700,7 +1703,7 @@ C4MCAlgorithm C4MCAlgoMap[] = {
#ifndef offsetof
#define offsetof(s,m) (size_t)&(((s *)0)->m)
#define offsetof(s,m) ((size_t)&(((s *)0)->m))
#endif
#define offsC4MCOvrl(x) offsetof(C4MCOverlay,x)

View File

@ -212,7 +212,7 @@ enum C4MCValueType
C4MCV_Algorithm,
C4MCV_Boolean,
C4MCV_Zoom,
C4MCV_ScriptFunc,
C4MCV_ScriptFunc
};
struct C4MCNodeAttr

View File

@ -159,7 +159,7 @@ bool C4MassMover::Execute()
}*/
// Save back material that is about to be overwritten.
int omat;
int omat = 0;
if (Game.C4S.Game.Realism.LandscapeInsertThrust)
omat = GBackMat(tx, ty);

View File

@ -383,8 +383,8 @@ bool C4MaterialMap::CrossMapMaterials() // Called after load
SURFACE sfcTexture;
C4Texture * Texture;
if (Map[cnt].sPXSGfx.getLength())
if (Texture=::TextureMap.GetTexture(Map[cnt].sPXSGfx.getData()))
if (sfcTexture=Texture->Surface32)
if ((Texture=::TextureMap.GetTexture(Map[cnt].sPXSGfx.getData())))
if ((sfcTexture=Texture->Surface32))
Map[cnt].PXSFace.Set(sfcTexture, Map[cnt].PXSGfxRt.x, Map[cnt].PXSGfxRt.y, Map[cnt].PXSGfxRt.Wdt, Map[cnt].PXSGfxRt.Hgt);
// evaluate reactions for that material
for (unsigned int iRCnt = 0; iRCnt < pMat->CustomReactionList.size(); ++iRCnt)

View File

@ -40,7 +40,7 @@ enum MaterialInteractionEvent
{
meePXSPos=0, // PXS check before movement
meePXSMove=1, // PXS movement
meeMassMove=2, // MassMover-movement
meeMassMove=2 // MassMover-movement
};
typedef bool (*C4MaterialReactionFunc)(struct C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, FIXED &fXDir, FIXED &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged);

View File

@ -99,6 +99,7 @@ void C4PXS::Execute()
inmat = GBackMat(inX, inY);
C4MaterialReaction *pReact = ::MaterialMap.GetReactionUnsafe(Mat, inmat);
if (pReact)
{
if ((*pReact->pFunc)(pReact, iX,iY, inX,inY, xdir,ydir, Mat,inmat, meePXSMove, &fStopMovement))
{
// destructive contact
@ -115,6 +116,7 @@ void C4PXS::Execute()
}
// there was a reaction func, but it didn't do anything - continue movement
}
}
iX = inX; iY = inY;
}
while (iX != iToX || iY != iToY);
@ -217,6 +219,7 @@ void C4PXSSystem::Execute()
Count=0;
for (unsigned int cchunk=0; cchunk<PXSMaxChunk; cchunk++)
if (Chunk[cchunk])
{
// empty chunk?
if(!iChunkPXS[cchunk])
{ delete [] Chunk[cchunk]; Chunk[cchunk]=NULL; }
@ -231,6 +234,7 @@ void C4PXSSystem::Execute()
Count++;
}
}
}
}
void C4PXSSystem::Draw(C4TargetFacet &cgo)

View File

@ -65,7 +65,7 @@ C4ParticleDefCore::C4ParticleDefCore():
MaxCount(C4Px_MaxParticle),
MinLifetime(0),MaxLifetime(0),
YOff(0),
Reverse(0),Repeats(0),Delay(0),
Delay(0),Repeats(0),Reverse(0),
FadeOutLen(0),FadeOutDelay(0),
RByV(0),
Placement(0),
@ -90,8 +90,8 @@ C4ParticleDef::C4ParticleDef():
C4ParticleDefCore(),
InitProc(&fxStdInit),
ExecProc(&fxStdExec),
DrawProc(&fxStdDraw),
CollisionProc(NULL),
DrawProc(&fxStdDraw),
Count(0)
{
// zero fields
@ -184,7 +184,7 @@ bool C4ParticleDef::Load(C4Group &rGrp)
}
// particle overloading
C4ParticleDef *pDefOverload;
if (pDefOverload=ParticleSystem.GetDef(Name.getData(), this))
if ((pDefOverload=ParticleSystem.GetDef(Name.getData(), this)))
{
if (Config.Graphics.VerboseObjectLoading>=1)
{ char ostr[250]; sprintf(ostr,LoadResStr("IDS_PRC_DEFOVERLOAD"),pDefOverload->Name.getData(),"<particle>"); Log(ostr); }
@ -219,7 +219,7 @@ void C4Particle::MoveList(C4ParticleList &rFrom, C4ParticleList &rTo)
if (rFrom.pFirst == this) rFrom.pFirst=pNext;
if (pNext) pNext->pPrev=pPrev;
// add to the other list - insert before first
if (pNext = rTo.pFirst) pNext->pPrev = this;
if ((pNext = rTo.pFirst)) pNext->pPrev = this;
rTo.pFirst = this; pPrev = NULL;
}
@ -258,7 +258,7 @@ void C4ParticleList::Exec(C4Object *pObj)
{
// execute all particles
C4Particle *pPrtNext=pFirst, *pPrt;
while (pPrt = pPrtNext)
while ((pPrt = pPrtNext))
{
// get next now, because destruction could corrupt the list
pPrtNext=pPrt->pNext;
@ -285,7 +285,7 @@ void C4ParticleList::Clear()
{
// remove all particles
C4Particle *pPrtNext=pFirst, *pPrt;
while (pPrt = pPrtNext)
while ((pPrt = pPrtNext))
{
// get next now, because destruction could corrupt the list
pPrtNext=pPrt->pNext;
@ -300,7 +300,7 @@ int32_t C4ParticleList::Remove(C4ParticleDef *pOfDef)
int32_t iNumRemoved=0;
// check all particles for def
C4Particle *pPrtNext=pFirst, *pPrt;
while (pPrt = pPrtNext)
while ((pPrt = pPrtNext))
{
// get next now, because destruction could corrupt the list
pPrtNext=pPrt->pNext;
@ -340,7 +340,7 @@ C4ParticleChunk *C4ParticleSystem::AddChunk()
pNewChnk->pNext = Chunk.pNext;
Chunk.pNext = pNewChnk;
// register into free-particle-list
if (pNewChnk->Data[C4Px_BufSize-1].pNext = FreeParticles.pFirst)
if ((pNewChnk->Data[C4Px_BufSize-1].pNext = FreeParticles.pFirst))
FreeParticles.pFirst->pPrev = &pNewChnk->Data[C4Px_BufSize-1];
FreeParticles.pFirst = &pNewChnk->Data[0];
// return it
@ -373,7 +373,7 @@ void C4ParticleSystem::PruneChunks()
ppChnkPrev = &pChnk->pNext;
}
}
while (pChnk = pChnkNext);
while ((pChnk = pChnkNext));
}
void C4ParticleSystem::ClearParticles()
@ -387,7 +387,7 @@ void C4ParticleSystem::ClearParticles()
GlobalParticles.pFirst = NULL;
// reset chunks
C4ParticleChunk *pNextChnk=Chunk.pNext, *pChnk;
while (pChnk = pNextChnk)
while ((pChnk = pNextChnk))
{
pNextChnk = pChnk->pNext;
delete pChnk;
@ -700,7 +700,11 @@ bool fxStdExec(C4Particle *pPrt, C4Object *pTarget)
}
// fade out
int32_t iFade = pPrt->pDef->AlphaFade;
if (iFade < 0) if (Game.FrameCounter % -iFade == 0) iFade = 1; else iFade = 0;
if (iFade < 0)
{
if (Game.FrameCounter % -iFade == 0) iFade = 1;
else iFade = 0;
}
if (iFade)
{
if(pPrt->pDef->FadeDelay == 0 || Game.FrameCounter % pPrt->pDef->FadeDelay == 0)
@ -796,6 +800,7 @@ void fxStdDraw(C4Particle *pPrt, C4TargetFacet &cgo, C4Object *pTarget)
// get phase
int32_t iPhase=pPrt->life;
if (pDef->Delay)
{
if (iPhase >= 0)
{
iPhase/=pDef->Delay;
@ -808,6 +813,7 @@ void fxStdDraw(C4Particle *pPrt, C4TargetFacet &cgo, C4Object *pTarget)
else iPhase%=length;
}
else iPhase=(iPhase+1)/-pDef->FadeOutDelay+pDef->Length;
}
// get rotation
int32_t r=0;
if ((pDef->RByV==1) || (pDef->RByV==2)) // rotation by direction

View File

@ -197,7 +197,7 @@ bool C4PathFinderRay::Execute()
// Check unused zone intersection
if (pPathFinder->TransferZonesEnabled)
if (pPathFinder->TransferZones)
if (pZone = pPathFinder->TransferZones->Find(X2,Y2))
if ((pZone = pPathFinder->TransferZones->Find(X2,Y2)))
if (!pZone->Used)
{
// Add use-zone ray (with zone entry point adjust)
@ -302,7 +302,7 @@ bool C4PathFinderRay::PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t i
if (ppZone)
if (pPathFinder->TransferZonesEnabled)
if (pPathFinder->TransferZones)
if (*ppZone = pPathFinder->TransferZones->Find(rX,rY))
if ((*ppZone = pPathFinder->TransferZones->Find(rX,rY)))
return false;
// Advance
if (d>=0) { x+=xincr; d+=aincr; } else d+=bincr;
@ -322,7 +322,7 @@ bool C4PathFinderRay::PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t i
if (ppZone)
if (pPathFinder->TransferZonesEnabled)
if (pPathFinder->TransferZones)
if (*ppZone = pPathFinder->TransferZones->Find(rX,rY))
if ((*ppZone = pPathFinder->TransferZones->Find(rX,rY)))
return false;
// Advance
if (d>=0) { y+=yincr; d+=aincr; } else d+=bincr;

View File

@ -618,9 +618,17 @@ bool C4ScenarioSection::ScenarioLoad(char *szFilename)
C4Group *C4ScenarioSection::GetGroupfile(C4Group &rGrp)
{
// check temp filename
if (szTempFilename) if (rGrp.Open(szTempFilename)) return &rGrp; else return NULL;
if (szTempFilename)
{
if (rGrp.Open(szTempFilename)) return &rGrp;
else return NULL;
}
// check filename within scenario
if (szFilename) if (rGrp.OpenAsChild(&Game.ScenarioFile, szFilename)) return &rGrp; else return NULL;
if (szFilename)
{
if (rGrp.OpenAsChild(&Game.ScenarioFile, szFilename)) return &rGrp;
else return NULL;
}
// unmodified main section: return main group
if (SEqualNoCase(szName, C4ScenSect_Main)) return &Game.ScenarioFile;
// failure

View File

@ -60,14 +60,14 @@ enum C4SForceFairCrew
{
C4SFairCrew_Free = 0,
C4SFairCrew_FairCrew = 1,
C4SFairCrew_NormalCrew = 2,
C4SFairCrew_NormalCrew = 2
};
enum C4SFilmMode
{
C4SFilm_None = 0,
C4SFilm_Normal = 1,
C4SFilm_Cinematic = 2,
C4SFilm_Cinematic = 2
};
class C4SHead

View File

@ -48,7 +48,7 @@ C4Texture::~C4Texture()
}
C4TexMapEntry::C4TexMapEntry()
: pMaterial(NULL), iMaterialIndex(MNone)
: iMaterialIndex(MNone), pMaterial(NULL)
{
}
@ -333,10 +333,10 @@ int32_t C4TextureMap::GetIndexMatTex(const char *szMaterialTexture, const char *
// texture not given or invalid?
int32_t iMatTex = 0;
if(Texture.getData())
if(iMatTex = GetIndex(Material.getData(), Texture.getData(), fAddIfNotExist))
if((iMatTex = GetIndex(Material.getData(), Texture.getData(), fAddIfNotExist)))
return iMatTex;
if(szDefaultTexture)
if(iMatTex = GetIndex(Material.getData(), szDefaultTexture, fAddIfNotExist))
if((iMatTex = GetIndex(Material.getData(), szDefaultTexture, fAddIfNotExist)))
return iMatTex;
// search material
long iMaterial = ::MaterialMap.Get(szMaterialTexture);

View File

@ -147,7 +147,7 @@ void C4Weather::Clear()
bool C4Weather::LaunchLightning(int32_t x, int32_t y, int32_t xdir, int32_t xrange, int32_t ydir, int32_t yrange, bool fDoGamma)
{
C4Object *pObj;
if (pObj=Game.CreateObject(C4ID("FXL1"), NULL))
if ((pObj=Game.CreateObject(C4ID("FXL1"), NULL)))
pObj->Call(PSF_Activate,&C4AulParSet(C4VInt(x),
C4VInt(y),
C4VInt(xdir),
@ -172,7 +172,7 @@ int32_t C4Weather::GetTemperature()
bool C4Weather::LaunchVolcano(int32_t mat, int32_t x, int32_t y, int32_t size)
{
C4Object *pObj;
if (pObj=Game.CreateObject(C4ID("FXV1"), NULL))
if ((pObj=Game.CreateObject(C4ID("FXV1"), NULL)))
pObj->Call(PSF_Activate,&C4AulParSet(C4VInt(x), C4VInt(y), C4VInt(size), C4VInt(mat)));
return true;
}
@ -190,7 +190,7 @@ void C4Weather::Default()
bool C4Weather::LaunchEarthquake(int32_t iX, int32_t iY)
{
C4Object *pObj;
if (pObj=Game.CreateObject(C4ID("FXQ1"),NULL,NO_OWNER,iX,iY))
if ((pObj=Game.CreateObject(C4ID("FXQ1"),NULL,NO_OWNER,iX,iY)))
if (!! pObj->Call(PSF_Activate))
return true;
return false;
@ -200,7 +200,7 @@ bool C4Weather::LaunchCloud(int32_t iX, int32_t iY, int32_t iWidth, int32_t iStr
{
if (::MaterialMap.Get(szPrecipitation)==MNone) return false;
C4Object *pObj;
if (pObj=Game.CreateObject(C4ID("FXP1"),NULL,NO_OWNER,iX,iY))
if ((pObj=Game.CreateObject(C4ID("FXP1"),NULL,NO_OWNER,iX,iY)))
if (!!pObj->Call(PSF_Activate,&C4AulParSet(C4VInt(::MaterialMap.Get(szPrecipitation)),
C4VInt(iWidth),
C4VInt(iStrength))))
@ -265,11 +265,13 @@ void C4Weather::SetSeasonGamma()
int32_t iChanVal=(byC1*iSeasonOff2 + byC2*iSeasonOff1) / 15;
// red+green: reduce in winter
if (Temperature<0)
{
if (iChan)
iChanVal+=Temperature/2;
else
// blue channel: emphasize in winter
iChanVal-=Temperature/2;
}
// set channel
dwClr[i] |= BoundBy<int32_t>(iChanVal,0,255)<<iChan;
}

View File

@ -790,7 +790,7 @@ void C4Command::Build()
C4Object *pOtherBuilder = NULL;
if (!cObj->Contents.Find(C4ID::Linekit))
{
while (pOtherBuilder = Game.FindObjectByCommand(C4CMD_Build,Target, C4VNull,0, NULL, pOtherBuilder))
while ((pOtherBuilder = Game.FindObjectByCommand(C4CMD_Build,Target, C4VNull,0, NULL, pOtherBuilder)))
if (pOtherBuilder->Contents.Find(C4ID::Linekit))
break;
}
@ -1084,12 +1084,14 @@ void C4Command::Get()
// Target collected
if (Target->Contained == cObj)
{
// Get-count specified: decrease count and continue with next object
if (Tx._getInt() > 1)
{ Target = NULL; Tx--; return; }
// We're done
else
{ cObj->Action.ComDir=COMD_Stop; Finish(true); return; }
}
// Grabbing other than target container: let go
if (cObj->GetProcedure()==DFA_PUSH)
@ -1316,12 +1318,14 @@ void C4Command::Put() // Notice: Put command is currently using Ty as an interna
// Thing is in target
if (Target2->Contained == Target)
{
// Put-count specified: decrease count and continue with next object
if (Tx._getInt() > 1)
{ Target2 = NULL; Tx--; return; }
// We're done
else
{ Finish(true); return; }
}
// Thing to put not in contents: get object
if (!cObj->Contents.GetLink(Target2))
@ -1914,7 +1918,7 @@ void C4Command::Acquire()
// Find available material
C4Object *pMaterial=NULL;
// Next closest
while (pMaterial = Game.FindObject(Data.getC4ID(),cObj->GetX(),cObj->GetY(),-1,-1,OCF_Available,NULL,NULL,NULL,NULL,ANY_OWNER,pMaterial))
while ((pMaterial = Game.FindObject(Data.getC4ID(),cObj->GetX(),cObj->GetY(),-1,-1,OCF_Available,NULL,NULL,NULL,NULL,ANY_OWNER,pMaterial)))
// Object is not in container to be ignored
if (!Target2 || pMaterial->Contained!=Target2)
// Object is near enough
@ -2074,7 +2078,7 @@ void C4Command::Energy()
if (!(pKit=cObj->Contents.Find(C4ID::Linekit)))
{ cObj->AddCommand(C4CMD_Acquire,NULL,0,0,50,NULL,true,C4VID(C4ID::Linekit)); return; }
// Find line constructing kit
for (int32_t cnt=0; pKitWithLine=cObj->Contents.GetObject(cnt); cnt++)
for (int32_t cnt=0; (pKitWithLine=cObj->Contents.GetObject(cnt)); cnt++)
if ((pKitWithLine->id==C4ID::Linekit) && (pLine=Game.FindObject(C4ID::PowerLine,0,0,0,0,OCF_All,"Connect",pKitWithLine)))
break;
// No line constructed yet
@ -2178,9 +2182,14 @@ void C4Command::CompileFunc(StdCompiler *pComp)
// Target X/Y
pComp->Value(Tx); pComp->Seperator(StdCompiler::SEP_SEP);
pComp->Value(mkIntPackAdapt(Ty)); pComp->Seperator(StdCompiler::SEP_SEP);
int32_t iPtr;
// Target
pComp->Value(mkIntPackAdapt(reinterpret_cast<int32_t &>(Target))); pComp->Seperator(StdCompiler::SEP_SEP);
pComp->Value(mkIntPackAdapt(reinterpret_cast<int32_t &>(Target2))); pComp->Seperator(StdCompiler::SEP_SEP);
iPtr = reinterpret_cast<intptr_t>(Target);
pComp->Value(mkIntPackAdapt(iPtr)); pComp->Seperator(StdCompiler::SEP_SEP);
Target = reinterpret_cast<C4Object*>(iPtr);
iPtr = reinterpret_cast<intptr_t>(Target2);
pComp->Value(mkIntPackAdapt(iPtr)); pComp->Seperator(StdCompiler::SEP_SEP);
Target2 = reinterpret_cast<C4Object*>(iPtr);
// Data
pComp->Value(Data); pComp->Seperator(StdCompiler::SEP_SEP);
// Update interval

View File

@ -671,13 +671,13 @@ bool C4Def::Load(C4Group &hGroup,
if (Graphics.GetBitmap())
{
// check SolidMask
if (SolidMask.x<0 || SolidMask.y<0 || SolidMask.x+SolidMask.Wdt>Graphics.Bitmap->Wdt || SolidMask.y+SolidMask.Hgt>Graphics.Bitmap->Hgt) SolidMask.Default();
if (SolidMask.x<0 || SolidMask.y<0 || SolidMask.x+SolidMask.Wdt>Graphics.Bmp.Bitmap->Wdt || SolidMask.y+SolidMask.Hgt>Graphics.Bmp.Bitmap->Hgt) SolidMask.Default();
// Set MainFace (unassigned bitmap: will be set by GetMainFace())
MainFace.Set(NULL,0,0,Shape.Wdt,Shape.Hgt);
}
// validate TopFace
if (TopFace.x<0 || TopFace.y<0 || TopFace.x+TopFace.Wdt>Graphics.Bitmap->Wdt || TopFace.y+TopFace.Hgt>Graphics.Bitmap->Hgt)
if (TopFace.x<0 || TopFace.y<0 || TopFace.x+TopFace.Wdt>Graphics.Bmp.Bitmap->Wdt || TopFace.y+TopFace.Hgt>Graphics.Bmp.Bitmap->Hgt)
{
TopFace.Default();
// warn in debug mode
@ -754,7 +754,7 @@ int32_t C4Def::GetValue(C4Object *pInBase, int32_t iBuyPlayer)
if (pInBase)
{
C4AulFunc *pFn;
if (pFn = pInBase->Def->Script.GetSFunc(PSF_CalcBuyValue, AA_PROTECTED))
if ((pFn = pInBase->Def->Script.GetSFunc(PSF_CalcBuyValue, AA_PROTECTED)))
iValue = pFn->Exec(pInBase, &C4AulParSet(C4VID(id), C4VInt(iValue))).getInt();
}
return iValue;
@ -830,11 +830,13 @@ int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat,
if (fThisSearchMessage) { LogF("%s...",GetFilename(hGroup.GetName())); }
// Load primary definition
if (nDef=new C4Def)
if ((nDef=new C4Def))
{
if ( nDef->Load(hGroup,dwLoadWhat,szLanguage,pSoundSystem) && Add(nDef,fOverload) )
{ iResult++; fPrimaryDef=true; }
else
{ delete nDef; }
}
// Load sub definitions
int i = 0;
@ -895,7 +897,7 @@ int32_t C4DefList::LoadFolderLocal( const char *szPath,
SCopy(szPath,szFoldername,iBackslash);
// Load from parent folder
if (SEqualNoCase(GetExtension(szFoldername),"c4f"))
if (iDefs=Load(szFoldername,dwLoadWhat,szLanguage,pSoundSystem,fOverload))
if ((iDefs=Load(szFoldername,dwLoadWhat,szLanguage,pSoundSystem,fOverload)))
{
iResult+=iDefs;
// Add any folder containing defs to store list
@ -923,7 +925,7 @@ int32_t C4DefList::Load(const char *szSearch,
// Segments
char szSegment[_MAX_PATH+1]; int32_t iGroupCount;
if (iGroupCount=SCharCount(';',szSearch))
if ((iGroupCount=SCharCount(';',szSearch)))
{
++iGroupCount; int32_t iPrg=iMaxProgress-iMinProgress;
for (int32_t cseg=0; SCopySegment(szSearch,cseg,szSegment,';',_MAX_PATH); cseg++)
@ -1110,8 +1112,9 @@ C4Def *C4DefList::GetByPath(const char *szPath)
// search defs
const char *szDefPath;
for(C4Def *pDef = FirstDef; pDef; pDef = pDef->Next)
if(szDefPath = Config.AtRelativePath(pDef->Filename))
if((szDefPath = Config.AtRelativePath(pDef->Filename)))
if(SEqual2NoCase(szPath, szDefPath))
{
// the definition itself?
if(!szPath[SLen(szDefPath)])
return pDef;
@ -1119,6 +1122,7 @@ C4Def *C4DefList::GetByPath(const char *szPath)
else if(szPath[SLen(szDefPath)] == '\\')
if(!strchr(szPath + SLen(szDefPath) + 1, '\\'))
return pDef;
}
// not found
return NULL;
}
@ -1438,4 +1442,4 @@ void C4DefList::BuildTable()
table.clear();
for (C4Def *def = FirstDef; def; def = def->Next)
table.insert(std::make_pair(def->id, def));
}
}

View File

@ -81,7 +81,7 @@ C4DefGraphics::C4DefGraphics(C4Def *pOwnDef)
pDef = pOwnDef;
// zero fields
Type = TYPE_Bitmap;
Bitmap = BitmapClr = NULL;
Bmp.Bitmap = Bmp.BitmapClr = NULL;
pNext = NULL;
fColorBitmapAutoCreated = false;
}
@ -99,8 +99,8 @@ void C4DefGraphics::Clear()
switch (Type)
{
case TYPE_Bitmap:
if (BitmapClr) { delete BitmapClr; BitmapClr=NULL; }
if (Bitmap) { delete Bitmap; Bitmap=NULL; }
if (Bmp.BitmapClr) { delete Bmp.BitmapClr; Bmp.BitmapClr=NULL; }
if (Bmp.Bitmap) { delete Bmp.Bitmap; Bmp.Bitmap=NULL; }
break;
case TYPE_Mesh:
if (Mesh) { delete Mesh; Mesh = NULL; }
@ -109,7 +109,7 @@ void C4DefGraphics::Clear()
// delete additonal graphics
C4AdditionalDefGraphics *pGrp2N = pNext, *pGrp2;
while (pGrp2=pGrp2N) { pGrp2N = pGrp2->pNext; pGrp2->pNext = NULL; delete pGrp2; }
while ((pGrp2=pGrp2N)) { pGrp2N = pGrp2->pNext; pGrp2->pNext = NULL; delete pGrp2; }
pNext = NULL; fColorBitmapAutoCreated = false;
}
@ -120,41 +120,41 @@ bool C4DefGraphics::LoadBitmap(C4Group &hGroup, const char *szFilename, const ch
SCopy("*.", GetExtension(strScaledMaskPNG)); SAppend(GetExtension(szFilenamePNG), strScaledMaskPNG);
if (szFilenamePNG && (hGroup.FindEntry(szFilenamePNG) || hGroup.FindEntry(strScaledMaskPNG)))
{
Bitmap = new C4Surface();
if (!Bitmap->Load(hGroup, szFilenamePNG)) return false;
Bmp.Bitmap = new C4Surface();
if (!Bmp.Bitmap->Load(hGroup, szFilenamePNG)) return false;
}
else
{
if (szFilename)
if ( !hGroup.AccessEntry(szFilename)
|| !(Bitmap=GroupReadSurface(hGroup)) )
|| !(Bmp.Bitmap=GroupReadSurface(hGroup)) )
return false;
}
// Create owner color bitmaps
if (fColorByOwner)
{
// Create additionmal bitmap
BitmapClr=new C4Surface();
Bmp.BitmapClr=new C4Surface();
// if overlay-surface is present, load from that
if (szOverlayPNG && hGroup.AccessEntry(szOverlayPNG))
{
if (!BitmapClr->ReadPNG(hGroup))
if (!Bmp.BitmapClr->ReadPNG(hGroup))
return false;
// set as Clr-surface, also checking size
if (!BitmapClr->SetAsClrByOwnerOf(Bitmap))
if (!Bmp.BitmapClr->SetAsClrByOwnerOf(Bmp.Bitmap))
{
const char *szFn = szFilenamePNG ? szFilenamePNG : szFilename;
if (!szFn) szFn = "???";
DebugLogF(" Gfx loading error in %s: %s (%d x %d) doesn't match overlay %s (%d x %d) - invalid file or size mismatch",
hGroup.GetFullName().getData(), szFn, Bitmap ? Bitmap->Wdt : -1, Bitmap ? Bitmap->Hgt : -1,
szOverlayPNG, BitmapClr->Wdt, BitmapClr->Hgt);
delete BitmapClr; BitmapClr = NULL;
hGroup.GetFullName().getData(), szFn, Bmp.Bitmap ? Bmp.Bitmap->Wdt : -1, Bmp.Bitmap ? Bmp.Bitmap->Hgt : -1,
szOverlayPNG, Bmp.BitmapClr->Wdt, Bmp.BitmapClr->Hgt);
delete Bmp.BitmapClr; Bmp.BitmapClr = NULL;
return false;
}
}
else
// otherwise, create by all blue shades
if (!BitmapClr->CreateColorByOwner(Bitmap)) return false;
if (!Bmp.BitmapClr->CreateColorByOwner(Bmp.Bitmap)) return false;
fColorBitmapAutoCreated = true;
}
Type = TYPE_Bitmap;
@ -351,24 +351,24 @@ bool C4DefGraphics::CopyGraphicsFrom(C4DefGraphics &rSource)
{
if (Type != TYPE_Bitmap) return false; // TODO!
// clear previous
if (BitmapClr) { delete BitmapClr; BitmapClr=NULL; }
if (Bitmap) { delete Bitmap; Bitmap=NULL; }
if (Bmp.BitmapClr) { delete Bmp.BitmapClr; Bmp.BitmapClr=NULL; }
if (Bmp.Bitmap) { delete Bmp.Bitmap; Bmp.Bitmap=NULL; }
// copy from source
if (rSource.Bitmap)
if (rSource.Bmp.Bitmap)
{
Bitmap = new C4Surface();
if (!Bitmap->Copy(*rSource.Bitmap))
{ delete Bitmap; Bitmap=NULL; return false; }
Bmp.Bitmap = new C4Surface();
if (!Bmp.Bitmap->Copy(*rSource.Bmp.Bitmap))
{ delete Bmp.Bitmap; Bmp.Bitmap=NULL; return false; }
}
if (rSource.BitmapClr)
if (rSource.Bmp.BitmapClr)
{
BitmapClr = new C4Surface();
if (!BitmapClr->Copy(*rSource.BitmapClr))
Bmp.BitmapClr = new C4Surface();
if (!Bmp.BitmapClr->Copy(*rSource.Bmp.BitmapClr))
{
if (Bitmap) { delete Bitmap; Bitmap=NULL; }
delete BitmapClr; BitmapClr=NULL; return false;
if (Bmp.Bitmap) { delete Bmp.Bitmap; Bmp.Bitmap=NULL; }
delete Bmp.BitmapClr; Bmp.BitmapClr=NULL; return false;
}
if (Bitmap) BitmapClr->SetAsClrByOwnerOf(Bitmap);
if (Bmp.Bitmap) Bmp.BitmapClr->SetAsClrByOwnerOf(Bmp.Bitmap);
}
// done, success
return true;
@ -378,7 +378,7 @@ void C4DefGraphics::DrawClr(C4Facet &cgo, bool fAspect, DWORD dwClr)
{
if(Type != TYPE_Bitmap) return; // TODO
// create facet and draw it
C4Surface *pSfc = BitmapClr ? BitmapClr : Bitmap; if (!pSfc) return;
C4Surface *pSfc = Bmp.BitmapClr ? Bmp.BitmapClr : Bmp.Bitmap; if (!pSfc) return;
C4Facet fct(pSfc, 0,0,pSfc->Wdt, pSfc->Hgt);
fct.DrawClr(cgo, fAspect, dwClr);
}
@ -461,7 +461,7 @@ void C4DefGraphicsPtrBackup::AssignUpdate(C4DefGraphics *pNewGraphics)
// check all objects
C4Object *pObj;
for (C4ObjectLink *pLnk = ::Objects.First; pLnk; pLnk=pLnk->Next)
if (pObj=pLnk->Obj) if (pObj->Status)
if ((pObj=pLnk->Obj)) if (pObj->Status)
{
if (pObj->pGraphics == pGraphicsPtr)
{
@ -527,7 +527,7 @@ void C4DefGraphicsPtrBackup::AssignRemoval()
// check all objects
C4Object *pObj;
for (C4ObjectLink *pLnk = ::Objects.First; pLnk; pLnk=pLnk->Next)
if (pObj=pLnk->Obj) if (pObj->Status)
if ((pObj=pLnk->Obj)) if (pObj->Status)
{
if (pObj->pGraphics == pGraphicsPtr)
// same graphics found: reset them
@ -593,7 +593,7 @@ bool C4Portrait::Link(C4DefGraphics *pGfxPortrait)
bool C4Portrait::SavePNG(C4Group &rGroup, const char *szFilename, const char *szOverlayFN)
{
// safety
if (!pGfxPortrait || !szFilename || pGfxPortrait->Type != C4DefGraphics::TYPE_Bitmap || !pGfxPortrait->Bitmap) return false;
if (!pGfxPortrait || !szFilename || pGfxPortrait->Type != C4DefGraphics::TYPE_Bitmap || !pGfxPortrait->Bmp.Bitmap) return false;
// save files
if (pGfxPortrait->fColorBitmapAutoCreated)
{
@ -603,10 +603,10 @@ bool C4Portrait::SavePNG(C4Group &rGroup, const char *szFilename, const char *sz
else
{
// save regular baseface
if (!pGfxPortrait->Bitmap->SavePNG(rGroup, szFilename)) return false;
if (!pGfxPortrait->Bmp.Bitmap->SavePNG(rGroup, szFilename)) return false;
// save Overlay
if (pGfxPortrait->BitmapClr && szOverlayFN)
if (!pGfxPortrait->BitmapClr->SavePNG(rGroup, szOverlayFN, true, false, true)) return false;
if (pGfxPortrait->Bmp.BitmapClr && szOverlayFN)
if (!pGfxPortrait->Bmp.BitmapClr->SavePNG(rGroup, szOverlayFN, true, false, true)) return false;
}
// done, success
return true;
@ -630,7 +630,7 @@ bool C4Portrait::CopyFrom(C4Portrait &rCopy)
{
// clear previous
Clear();
if (fGraphicsOwned=rCopy.fGraphicsOwned)
if ((fGraphicsOwned=rCopy.fGraphicsOwned))
{
// gfx copy
pGfxPortrait = new C4DefGraphics();
@ -692,7 +692,7 @@ C4GraphicsOverlay::~C4GraphicsOverlay()
delete pMeshInstance; pMeshInstance = NULL;
// free any additional overlays
C4GraphicsOverlay *pNextOther = pNext, *pOther;
while (pOther = pNextOther)
while ((pOther = pNextOther))
{
pNextOther = pOther->pNext;
pOther->pNext = NULL;
@ -781,6 +781,10 @@ void C4GraphicsOverlay::UpdateFacet()
case MODE_Rank:
// drawn at runtime
break;
case MODE_Object:
// TODO
break;
}
}
@ -990,10 +994,12 @@ void C4GraphicsOverlay::Draw(C4TargetFacet &cgo, C4Object *pForObj, int32_t iByP
if (dwClrModulation != 0xffffff) Application.DDraw->ActivateBlitModulation(dwClrModulation);
if(pMeshInstance)
{
if( ((dwClrModulation >> 24) & 0xff) != 0xff)
pMeshInstance->SetFaceOrdering(StdMeshInstance::FO_NearestToFarthest);
else
pMeshInstance->SetFaceOrdering(StdMeshInstance::FO_Fixed);
}
}
if (eMode == MODE_Rank)
{
@ -1130,10 +1136,12 @@ void C4GraphicsOverlay::DrawPicture(C4Facet &cgo, C4Object *pForObj)
if (dwClrModulation != 0xffffff) Application.DDraw->ActivateBlitModulation(dwClrModulation);
if(pMeshInstance)
{
if( ((dwClrModulation >> 24) & 0xff) != 0xff)
pMeshInstance->SetFaceOrdering(StdMeshInstance::FO_NearestToFarthest);
else
pMeshInstance->SetFaceOrdering(StdMeshInstance::FO_Fixed);
}
}
// draw at given rect
if(!pMeshInstance)
@ -1221,10 +1229,12 @@ void C4GraphicsOverlayListAdapt::CompileFunc(StdCompiler *pComp)
{
// seperate
if(pPos != pOverlay)
{
if(fNaming)
pComp->Seperator(StdCompiler::SEP_SEP2);
else
pComp->Value(fContinue);
}
// write
pComp->Value(*pPos);
}

View File

@ -59,13 +59,13 @@ class C4DefGraphics
union {
struct {
C4Surface *Bitmap, *BitmapClr;
};
} Bmp;
StdMesh *Mesh;
};
bool fColorBitmapAutoCreated; // if set, the color-by-owner-bitmap has been created automatically by all blue shades of the bitmap
inline C4Surface *GetBitmap(DWORD dwClr=0) { if(Type != TYPE_Bitmap) return NULL; if (BitmapClr) { BitmapClr->SetClr(dwClr); return BitmapClr; } else return Bitmap; }
inline C4Surface *GetBitmap(DWORD dwClr=0) { if(Type != TYPE_Bitmap) return NULL; if (Bmp.BitmapClr) { Bmp.BitmapClr->SetClr(dwClr); return Bmp.BitmapClr; } else return Bmp.Bitmap; }
C4DefGraphics(C4Def *pOwnDef=NULL); // ctor
virtual ~C4DefGraphics() { Clear(); }; // dtor
@ -77,7 +77,7 @@ class C4DefGraphics
C4DefGraphics *Get(const char *szGrpName); // get graphics by name
void Clear(); // clear fields; delete additional graphics
bool IsColorByOwner() // returns whether ColorByOwner-surfaces have been created
{ return Type == TYPE_Mesh || !!BitmapClr; } // Mesh can always apply PlayerColor (if used in its material)
{ return Type == TYPE_Mesh || !!Bmp.BitmapClr; } // Mesh can always apply PlayerColor (if used in its material)
bool CopyGraphicsFrom(C4DefGraphics &rSource); // copy bitmaps from source graphics
virtual const char *GetName() { return NULL; } // return name to be stored in safe game files
@ -185,7 +185,7 @@ class C4GraphicsOverlay
MODE_IngamePicture=4, // draw picture of source def
MODE_Object=5, // draw another object gfx
MODE_ExtraGraphics=6, // draw like this were a ClrByOwner-surface
MODE_Rank=7, // draw rank symbol
MODE_Rank=7 // draw rank symbol
};
protected:
Mode eMode; // overlay mode

View File

@ -99,7 +99,7 @@ C4ObjectList &C4GameObjects::ObjectsAt(int ix, int iy)
void C4GameObjects::CrossCheck() // Every Tick1 by ExecObjects
{
C4Object *obj1,*obj2;
C4Object *obj1 = NULL,*obj2 = NULL;
DWORD ocf1,ocf2,focf,tocf;
// AtObject-Check: Checks for first match of obj1 at obj2
@ -119,7 +119,7 @@ void C4GameObjects::CrossCheck() // Every Tick1 by ExecObjects
if (obj1->OCF & focf)
{
ocf1=obj1->OCF; ocf2=tocf;
if (obj2=AtObject(obj1->GetX(),obj1->GetY(),ocf2,obj1))
if ((obj2=AtObject(obj1->GetX(),obj1->GetY(),ocf2,obj1)))
{
// Incineration
if ((ocf1 & OCF_OnFire) && (ocf2 & OCF_Inflammable))
@ -312,7 +312,7 @@ C4Object* C4GameObjects::Enumerated(C4Object *pObj)
{
uint32_t iPtrNum;
// If object is enumerated, convert to enumerated pointer
if (iPtrNum = ObjectNumber(pObj))
if ((iPtrNum = ObjectNumber(pObj)))
return (C4Object*) (C4EnumPointer1 + iPtrNum);
// Oops!
return (C4Object*)-1;
@ -453,7 +453,7 @@ void C4ObjResort::SortObject()
C4ObjectLink *pLnkBck = pLnk;
C4Object *pObj2; int iResult;
if (!pLnk) return;
while(pLnk = pLnk->Next)
while((pLnk = pLnk->Next))
{
// get object
pObj2 = pLnk->Obj;
@ -481,7 +481,7 @@ void C4ObjResort::SortObject()
// no movement yet: check backwards in list
Pars[0].Set(C4VObj(pSortObj));
pLnk = pLnkBck;
while (pLnk = pLnk->Prev)
while ((pLnk = pLnk->Prev))
{
// get object
pObj2 = pLnk->Obj;
@ -617,7 +617,7 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
// Denumerate pointers
// if object numbers collideded, numbers will be adjusted afterwards
// so fake inactive object list empty meanwhile
C4ObjectLink *pInFirst;
C4ObjectLink *pInFirst = NULL;
if (fObjectNumberCollision) { pInFirst = InactiveObjects.First; InactiveObjects.First = NULL; }
// denumerate pointers
Denumerate();
@ -682,7 +682,7 @@ int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive)
{
if (cLnk->Prev) cLnk->Prev->Next=cLnkNext; else First=cLnkNext;
if (cLnkNext) cLnkNext->Prev=cLnk->Prev; else Last=cLnk->Prev;
if (cLnk->Prev = InactiveObjects.Last)
if ((cLnk->Prev = InactiveObjects.Last))
InactiveObjects.Last->Next = cLnk;
else
InactiveObjects.First = cLnk;

View File

@ -47,6 +47,7 @@ class C4GameObjects : public C4NotifyingObjectList
unsigned int LastUsedMarker; // last used value for C4Object::Marker
using C4ObjectList::Add;
bool Add(C4Object *nObj); // add object
bool Remove(C4Object *pObj); // clear pointers to object

View File

@ -449,7 +449,7 @@ void C4IDList::Load(C4DefList &rDefs, int32_t dwCategory)
Clear();
// add all IDs of def list
C4IDListChunk *pChunk=this;
while (cdef=rDefs.GetDef(cnt++,dwCategory))
while ((cdef=rDefs.GetDef(cnt++,dwCategory)))
{
// add new chunk if necessary
if (cntl==C4IDListChunkSize)

View File

@ -206,7 +206,7 @@ void C4PhysicalInfo::PromotionUpdate(int32_t iRank, bool fUpdateTrainablePhysica
Fight = pTrainDef->Physical.Fight + (C4MaxPhysical - pTrainDef->Physical.Fight) * iTrainRank / 20;
// do script updates for any physicals as required (this will train stuff like magic)
const char *szPhysName; C4PhysicalInfo::Offset PhysOff;
for (int32_t iPhysIdx=0; szPhysName = GetNameByIndex(iPhysIdx, &PhysOff); ++iPhysIdx)
for (int32_t iPhysIdx=0; (szPhysName = GetNameByIndex(iPhysIdx, &PhysOff)); ++iPhysIdx)
{
C4Value PhysVal(this->*PhysOff);
C4AulParSet Pars(C4VString(szPhysName), C4VInt(iRank), C4VRef(&PhysVal));

View File

@ -183,10 +183,12 @@ void C4Object::SideBounds(int32_t &ctcox)
// layer bounds
if (pLayer) if (pLayer->Def->BorderBound & C4D_Border_Layer)
if (!Action.pActionDef || Action.pActionDef->GetPropertyInt(P_Procedure) != DFA_ATTACH)
{
if (Category & C4D_StaticBack)
TargetBounds(ctcox,pLayer->GetX()+pLayer->Shape.GetX(),pLayer->GetX()+pLayer->Shape.GetX()+pLayer->Shape.Wdt,CNAT_Left,CNAT_Right);
else
TargetBounds(ctcox,pLayer->GetX()+pLayer->Shape.GetX()-Shape.GetX(),pLayer->GetX()+pLayer->Shape.GetX()+pLayer->Shape.Wdt+Shape.GetX(),CNAT_Left,CNAT_Right);
}
// landscape bounds
if (Def->BorderBound & C4D_Border_Sides)
TargetBounds(ctcox,0-Shape.GetX(),GBackWdt+Shape.GetX(),CNAT_Left,CNAT_Right);
@ -197,10 +199,12 @@ void C4Object::VerticalBounds(int32_t &ctcoy)
// layer bounds
if (pLayer) if (pLayer->Def->BorderBound & C4D_Border_Layer)
if (!Action.pActionDef || Action.pActionDef->GetPropertyInt(P_Procedure) != DFA_ATTACH)
{
if (Category & C4D_StaticBack)
TargetBounds(ctcoy,pLayer->GetY()+pLayer->Shape.GetY(),pLayer->GetY()+pLayer->Shape.GetY()+pLayer->Shape.Hgt,CNAT_Top,CNAT_Bottom);
else
TargetBounds(ctcoy,pLayer->GetY()+pLayer->Shape.GetY()-Shape.GetY(),pLayer->GetY()+pLayer->Shape.GetY()+pLayer->Shape.Hgt+Shape.GetY(),CNAT_Top,CNAT_Bottom);
}
// landscape bounds
if (Def->BorderBound & C4D_Border_Top)
TargetBounds(ctcoy,0-Shape.GetY(),+1000000,CNAT_Top,CNAT_Bottom);
@ -254,7 +258,7 @@ void C4Object::DoMovement()
{
// Next step
int step = Sign(ctcox - GetX());
if (iContact=ContactCheck(GetX() + step, GetY()))
if ((iContact=ContactCheck(GetX() + step, GetY())))
{
fAnyContact=true; iContacts |= t_contact;
// Abort horizontal movement
@ -278,7 +282,7 @@ void C4Object::DoMovement()
{
// Next step
int step = Sign(ctcoy - GetY());
if (iContact=ContactCheck(GetX(), GetY() + step))
if ((iContact=ContactCheck(GetX(), GetY() + step)))
{
fAnyContact=true; iContacts |= t_contact;
ctcoy=GetY(); new_y = fix_y;
@ -327,7 +331,7 @@ void C4Object::DoMovement()
if (ctx != GetX() + step_x) at_xovr = true;
}
// Contact check & evaluation
if (iContact=ContactCheck(ctx,cty))
if ((iContact=ContactCheck(ctx,cty)))
{
fAnyContact=true; iContacts |= t_contact;
// Abort movement
@ -378,7 +382,7 @@ void C4Object::DoMovement()
Shape.Attach(ctx,cty,Action.t_attach);
}
// check for contact
if (iContact=ContactCheck(ctx,cty)) // Contact
if ((iContact=ContactCheck(ctx,cty))) // Contact
{
fAnyContact=true; iContacts |= t_contact;
// Undo step and abort movement

View File

@ -320,7 +320,7 @@ void C4Object::AssignRemoval(bool fExitContents)
}
// remove from container *after* contents have been removed!
C4Object *pCont;
if (pCont=Contained)
if ((pCont=Contained))
{
pCont->Contents.Remove(this);
pCont->UpdateMass();
@ -354,10 +354,12 @@ void C4Object::UpdateShape(bool bUpdateVertices)
// Construction zoom
if (Con!=FullCon)
{
if (Def->GrowthType)
Shape.Stretch(Con, bUpdateVertices);
else
Shape.Jolt(Con, bUpdateVertices);
}
// Rotation
if (Def->Rotateable)
@ -443,7 +445,7 @@ void C4Object::UpdateFlipDir()
// We're active
if (Action.pActionDef)
// Get flipdir value from action
if (iFlipDir = Action.pActionDef->GetPropertyInt(P_FlipDir))
if ((iFlipDir = Action.pActionDef->GetPropertyInt(P_FlipDir)))
// Action dir is in flipdir range
if (Action.Dir >= iFlipDir)
{
@ -656,9 +658,9 @@ void C4Object::SetOCF()
FIXED cspeed=GetSpeed();
#ifdef _DEBUG
if(Contained && !::Objects.ObjectNumber(Contained))
{ LogF("Warning: contained in wild object %p!", Contained); }
{ LogF("Warning: contained in wild object %p!", static_cast<void*>(Contained)); }
else if(Contained && !Contained->Status)
{ LogF("Warning: contained in deleted object %p (%s)!", Contained, Contained->GetName()); }
{ LogF("Warning: contained in deleted object %p (%s)!", static_cast<void*>(Contained), Contained->GetName()); }
#endif
if(Contained)
InMat = Contained->Def->ClosedContainer ? MNone : Contained->InMat;
@ -795,9 +797,9 @@ void C4Object::UpdateOCF()
FIXED cspeed=GetSpeed();
#ifdef _DEBUG
if(Contained && !::Objects.ObjectNumber(Contained))
{ LogF("Warning: contained in wild object %p!", Contained); }
{ LogF("Warning: contained in wild object %p!", static_cast<void*>(Contained)); }
else if(Contained && !Contained->Status)
{ LogF("Warning: contained in deleted object %p (%s)!", Contained, Contained->GetName()); }
{ LogF("Warning: contained in deleted object %p (%s)!", static_cast<void*>(Contained), Contained->GetName()); }
#endif
if(Contained)
InMat = Contained->Def->ClosedContainer ? MNone : Contained->InMat;
@ -1182,7 +1184,7 @@ void C4Object::AssignDeath(bool fForced)
Info->Retire();
}
// Lose contents
while (thing=Contents.GetObject()) thing->Exit(thing->GetX(),thing->GetY());
while ((thing=Contents.GetObject())) thing->Exit(thing->GetX(),thing->GetY());
// Remove from crew/cursor/view
C4Player *pPlr = ::Players.Get(Owner);
if (pPlr) pPlr->ClearPointers(this, true);
@ -1415,7 +1417,7 @@ void C4Object::DoCon(int32_t iChange, bool fInitial, bool fNoComponentChange)
if (!Def->IncompleteActivity)
{
C4Object *cobj;
while (cobj=Contents.GetObject())
while ((cobj=Contents.GetObject()))
if (Contained) cobj->Enter(Contained);
else cobj->Exit(cobj->GetX(),cobj->GetY());
}
@ -1630,7 +1632,7 @@ bool C4Object::Build(int32_t iLevel, C4Object *pBuilder)
// Grab any needed components from builder
C4ID idMat;
for (cnt=0; idMat=NeededComponents.GetID(cnt); cnt++)
for (cnt=0; (idMat=NeededComponents.GetID(cnt)); cnt++)
if (Component.GetIDCount(idMat)<NeededComponents.GetCount(cnt))
if ((pMaterial=pBuilder->Contents.Find(idMat)))
if (!pMaterial->OnFire) if (pMaterial->OCF & OCF_FullCon)
@ -1641,7 +1643,7 @@ bool C4Object::Build(int32_t iLevel, C4Object *pBuilder)
}
// Grab any needed components from container
if (Contained)
for (cnt=0; idMat=NeededComponents.GetID(cnt); cnt++)
for (cnt=0; (idMat=NeededComponents.GetID(cnt)); cnt++)
if (Component.GetIDCount(idMat)<NeededComponents.GetCount(cnt))
if ((pMaterial=Contained->Contents.Find(idMat)))
if (!pMaterial->OnFire) if (pMaterial->OCF & OCF_FullCon)
@ -1651,7 +1653,7 @@ bool C4Object::Build(int32_t iLevel, C4Object *pBuilder)
pMaterial->AssignRemoval();
}
// Check for needed components at current con
for (cnt=0; idMat=NeededComponents.GetID(cnt); cnt++)
for (cnt=0; (idMat=NeededComponents.GetID(cnt)); cnt++)
if (NeededComponents.GetCount(cnt)!=0)
if ( (100*Component.GetIDCount(idMat)/NeededComponents.GetCount(cnt)) < (100*Con/FullCon) )
{
@ -1681,7 +1683,7 @@ bool C4Object::Build(int32_t iLevel, C4Object *pBuilder)
// Do con (mass- and builder-relative)
int32_t iBuildSpeed=100; C4PhysicalInfo *pPhys;
if (pBuilder) if (pPhys=pBuilder->GetPhysical())
if (pBuilder) if ((pPhys=pBuilder->GetPhysical()))
{
iBuildSpeed=pPhys->CanConstruct;
if (!iBuildSpeed)
@ -1738,6 +1740,7 @@ bool C4Object::Push(FIXED txdir, FIXED dforce, bool fStraighten)
}
// Straighten
if (fStraighten)
{
if (Inside<int32_t>(r,-StableRange,+StableRange))
{
rdir=0; // cheap way out
@ -1747,6 +1750,7 @@ bool C4Object::Push(FIXED txdir, FIXED dforce, bool fStraighten)
if (r>0) { if (rdir>-RotateAccel) rdir-=dforce; }
else { if (rdir<+RotateAccel) rdir+=dforce; }
}
}
// Mobilization check
if (!!xdir || !!ydir || !!rdir) Mobile=1;
@ -1918,7 +1922,7 @@ bool C4Object::ActivateMenu(int32_t iMenu, int32_t iMenuSelect,
Menu->Init(fctSymbol,FormatString(LoadResStr("IDS_PLR_NOBKNOW"),pPlayer->GetName()).getData(),
this,C4MN_Extra_Components,0,iMenu);
// Add player's structure build knowledge
for (cnt=0; pDef=C4Id2Def(pPlayer->Knowledge.GetID(::Definitions,C4D_Structure,cnt,&iCount)); cnt++)
for (cnt=0; (pDef=C4Id2Def(pPlayer->Knowledge.GetID(::Definitions,C4D_Structure,cnt,&iCount))); cnt++)
{
// Caption
sprintf(szCaption,LoadResStr("IDS_MENU_CONSTRUCT"),pDef->GetName());
@ -2065,7 +2069,7 @@ int32_t C4Object::GetValue(C4Object *pInBase, int32_t iForPlayer)
if (pInBase)
{
C4AulFunc *pFn;
if (pFn = pInBase->Def->Script.GetSFunc(PSF_CalcSellValue, AA_PROTECTED))
if ((pFn = pInBase->Def->Script.GetSFunc(PSF_CalcSellValue, AA_PROTECTED)))
iValue = pFn->Exec(pInBase, &C4AulParSet(C4VObj(this), C4VInt(iValue))).getInt();
}
// Return value
@ -2078,6 +2082,7 @@ C4PhysicalInfo* C4Object::GetPhysical(bool fPermanent)
if (PhysicalTemporary && !fPermanent) return &TemporaryPhysical;
// Info physical: Available only if there's an info and it should be used
if (Info)
{
if (!Game.Parameters.UseFairCrew)
return &(Info->Physical);
else if (Info->pDef)
@ -2086,6 +2091,7 @@ C4PhysicalInfo* C4Object::GetPhysical(bool fPermanent)
// shouldn't really happen, but who knows.
// Maybe some time it will be possible to have crew infos that aren't tied to a specific definition
return Def->GetFairCrewPhysicals();
}
// Definition physical
return &(Def->Physical);
}
@ -2175,7 +2181,7 @@ void C4Object::ClearPointers(C4Object *pObj)
if (pGfxOverlay)
{
C4GraphicsOverlay *pNextGfxOvrl = pGfxOverlay, *pGfxOvrl;
while (pGfxOvrl = pNextGfxOvrl)
while ((pGfxOvrl = pNextGfxOvrl))
{
pNextGfxOvrl = pGfxOvrl->GetNext();
if (pGfxOvrl->GetOverlayObject() == pObj)
@ -2232,6 +2238,7 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode)
// Output boundary
if (!fYStretchObject && !eDrawMode)
{
if (Action.pActionDef && !r && !Action.pActionDef->GetPropertyInt(P_FacetBase) && Con<=FullCon)
{
// active
@ -2244,10 +2251,11 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode)
if ( !Inside<float>(cox,1-Shape.Wdt,cgo.Wdt)
|| (!Inside<float>(coy,1-Shape.Hgt,cgo.Hgt)) )
{ if (FrontParticles && !Contained) FrontParticles.Draw(cgo,this); return; }
}
// ensure correct color is set
if (GetGraphics()->Type == C4DefGraphics::TYPE_Bitmap)
if (GetGraphics()->BitmapClr) GetGraphics()->BitmapClr->SetClr(Color);
if (GetGraphics()->Bmp.BitmapClr) GetGraphics()->Bmp.BitmapClr->SetClr(Color);
// Debug Display //////////////////////////////////////////////////////////////////////
if (::GraphicsSystem.ShowCommand && !eDrawMode)
@ -2560,7 +2568,7 @@ void C4Object::DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDraw
TopFace.Y = Action.pActionDef->GetPropertyInt(P_Y) + Def->TopFace.y + Action.pActionDef->GetPropertyInt(P_Hgt) * Action.DrawDir;
}
// ensure correct color is set
if (GetGraphics()->BitmapClr) GetGraphics()->BitmapClr->SetClr(Color);
if (GetGraphics()->Bmp.BitmapClr) GetGraphics()->Bmp.BitmapClr->SetClr(Color);
// color modulation
if (!eDrawMode) PrepareDrawing();
// Draw top face bitmap
@ -2720,6 +2728,7 @@ void C4Object::CompileFunc(StdCompiler *pComp)
// Commands
if(pComp->FollowName("Commands"))
{
if(fCompiler)
{
C4Command *pCmd = NULL;
@ -2744,6 +2753,7 @@ void C4Object::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(*pCmd, Naming.getData()));
}
}
}
// Compiling? Do initialization.
if(fCompiler)
@ -2755,10 +2765,11 @@ void C4Object::CompileFunc(StdCompiler *pComp)
LocalNamed.SetNameList(&Def->Script.LocalNamed);
// Set action (override running data)
/* FIXME
int32_t iTime=Action.Time;
int32_t iPhase=Action.Phase;
int32_t iPhaseDelay=Action.PhaseDelay;
/* FIXME if (SetActionByName(Action.pActionDef->GetName(),0,0,false))
if (SetActionByName(Action.pActionDef->GetName(),0,0,false))
{
Action.Time=iTime;
Action.Phase=iPhase; // No checking for valid phase
@ -2985,7 +2996,7 @@ C4Object *C4Object::ComposeContents(C4ID id)
pDef->GetComponents(&NeededComponents, NULL, this);
// Check for sufficient components
StdStrBuf Needs; Needs.Format(LoadResStr("IDS_CON_BUILDMATNEED"),pDef->GetName());
for (cnt=0; c_id=NeededComponents.GetID(cnt); cnt++)
for (cnt=0; (c_id=NeededComponents.GetID(cnt)); cnt++)
if (NeededComponents.GetCount(cnt) > Contents.ObjectCount(c_id))
{
Needs.AppendFormat("|%ix %s", NeededComponents.GetCount(cnt) - Contents.ObjectCount(c_id), C4Id2Def(c_id) ? C4Id2Def(c_id)->GetName() : c_id.ToString() );
@ -3003,7 +3014,7 @@ C4Object *C4Object::ComposeContents(C4ID id)
return NULL;
}
// Remove components
for (cnt=0; c_id=NeededComponents.GetID(cnt); cnt++)
for (cnt=0; (c_id=NeededComponents.GetID(cnt)); cnt++)
for (cnt2=0; cnt2<NeededComponents.GetCount(cnt); cnt2++)
if (!( pObj = Contents.Find(c_id) ))
return NULL;
@ -3449,10 +3460,12 @@ void C4Object::NoAttachAction()
if (ObjectActionCornerScale(this)) return;
// Scaling and stopped: fall off to side (avoid zuppel)
if ((iProcedure == DFA_SCALE) && (Action.ComDir == COMD_Stop))
{
if (Action.Dir == DIR_Left)
{ if (ObjectActionJump(this,itofix(1),Fix0,false)) return; }
else
{ if (ObjectActionJump(this,itofix(-1),Fix0,false)) return; }
}
// Pushing: grab loss
if (iProcedure==DFA_PUSH) GrabLost(this);
// Else jump
@ -3864,6 +3877,7 @@ void C4Object::ExecAction()
// Energy usage
if (Game.Rules & C4RULE_StructuresNeedEnergy)
if (pAction->GetPropertyInt(P_EnergyUsage))
{
if (pAction->GetPropertyInt(P_EnergyUsage) <= Energy )
{
Energy -= pAction->GetPropertyInt(P_EnergyUsage);
@ -3877,6 +3891,7 @@ void C4Object::ExecAction()
if (Mobile) DoGravity(this);
return;
}
}
// Action time advance
Action.Time++;
@ -4449,10 +4464,12 @@ void C4Object::ExecAction()
// Force containment
if (Action.Target->Contained!=Contained)
{
if (Action.Target->Contained)
Enter(Action.Target->Contained);
else
Exit(GetX(),GetY(),r);
}
// Force position
ForcePosition(Action.Target->GetX()+Action.Target->Shape.VtxX[Action.Data&255]
@ -5016,7 +5033,7 @@ bool C4Object::PutAwayUnusedObject(C4Object *pToMakeRoomForObject)
// get unused object
C4Object *pUnusedObject;
C4AulFunc *pFnObj2Drop;
if (pFnObj2Drop = Def->Script.GetSFunc(PSF_GetObject2Drop))
if ((pFnObj2Drop = Def->Script.GetSFunc(PSF_GetObject2Drop)))
pUnusedObject = pFnObj2Drop->Exec(this, pToMakeRoomForObject ? &C4AulParSet(C4VObj(pToMakeRoomForObject)) : NULL).getObj();
else
{
@ -5122,7 +5139,7 @@ bool C4Object::HasGraphicsOverlayRecursion(const C4Object *pCheckObj) const
C4Object *pGfxOvrlObj;
if (pGfxOverlay)
for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
if (pGfxOvrlObj = pGfxOvrl->GetOverlayObject())
if ((pGfxOvrlObj = pGfxOvrl->GetOverlayObject()))
{
if (pGfxOvrlObj == pCheckObj) return true;
if (pGfxOvrlObj->HasGraphicsOverlayRecursion(pCheckObj)) return true;
@ -5376,7 +5393,7 @@ StdStrBuf C4Object::GetNeededMatStr(C4Object *pBuilder)
C4ID idComponent;
for(cnt = 0; idComponent=NeededComponents.GetID(cnt); cnt ++)
for(cnt = 0; (idComponent=NeededComponents.GetID(cnt)); cnt ++)
{
if(NeededComponents.GetCount(cnt)!=0)
{

View File

@ -243,7 +243,7 @@ class C4Object: public C4PropList
void DrawLine(C4TargetFacet &cgo);
bool SetPhase(int32_t iPhase);
void AssignRemoval(bool fExitContents=false);
enum DrawMode { ODM_Normal=0, ODM_Overlay=1, ODM_BaseOnly=2, };
enum DrawMode { ODM_Normal=0, ODM_Overlay=1, ODM_BaseOnly=2 };
void Draw(C4TargetFacet &cgo, int32_t iByPlayer = -1, DrawMode eDrawMode=ODM_Normal);
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer = -1, DrawMode eDrawMode=ODM_Normal);
void DrawActionFace(C4TargetFacet &cgo, float offX, float offY);
@ -283,7 +283,7 @@ class C4Object: public C4PropList
int32_t ContactCheck(int32_t atx, int32_t aty);
bool Contact(int32_t cnat);
void TargetBounds(int32_t &ctco, int32_t limit_low, int32_t limit_hi, int32_t cnat_low, int32_t cnat_hi);
enum { SAC_StartCall = 1, SAC_EndCall = 2, SAC_AbortCall = 4, };
enum { SAC_StartCall = 1, SAC_EndCall = 2, SAC_AbortCall = 4 };
bool SetAction(C4PropList * Act, C4Object *pTarget=NULL, C4Object *pTarget2=NULL, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false);
bool SetActionByName(C4String * ActName, C4Object *pTarget=NULL, C4Object *pTarget2=NULL, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false);
bool SetActionByName(const char * szActName, C4Object *pTarget=NULL, C4Object *pTarget2=NULL, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false);

View File

@ -446,7 +446,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
// - - - - - - - - - - - - - - - Active construction - - - - - - - - - - - - - - - - -
// Active line construction
if (cline=Game.FindObject(C4ID::None,0,0,0,0,OCF_All,"Connect",linekit))
if ((cline=Game.FindObject(C4ID::None,0,0,0,0,OCF_All,"Connect",linekit)))
{
// Check for structure connection
@ -457,7 +457,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
{
// No connect
StartSoundEffect("Error",false,100,cObj);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCONNECT")).getData(),cObj); return false;
GameMsgObject(LoadResStr("IDS_OBJ_NOCONNECT"),cObj); return false;
}
// Check short circuit -> removal
@ -511,7 +511,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
if (!tstruct || !(ocf & OCF_LineConstruct))
{
StartSoundEffect("Error",false,100,cObj);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NONEWLINE")).getData(),cObj); return false;
GameMsgObject(LoadResStr("IDS_OBJ_NONEWLINE"),cObj); return false;
}
// Determine new line type
@ -534,7 +534,7 @@ bool ObjectComLineConstruction(C4Object *cObj)
if (linetype==C4ID::None)
{
StartSoundEffect("Error",false,100,cObj);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NONEWLINE")).getData(),cObj); return false;
GameMsgObject(LoadResStr("IDS_OBJ_NONEWLINE"),cObj); return false;
}
// Create new line

View File

@ -151,6 +151,7 @@ bool C4ObjectInfo::Load(C4Group &hGroup, bool fLoadPortrait)
// portrait not defined or invalid (custom w/o file or invalid file)
// assign a new one (local players only)
if (!*PortraitFile && fLoadPortrait)
{
// try to load a custom portrait
if (!fPortraitFileChecked && Portrait.Load(hGroup, C4CFN_Portrait_Old, C4CFN_Portrait, C4CFN_PortraitOverlay))
// assign it as custom portrait
@ -158,6 +159,7 @@ bool C4ObjectInfo::Load(C4Group &hGroup, bool fLoadPortrait)
else if (Config.Graphics.AddNewCrewPortraits)
// assign a new random crew portrait
SetRandomPortrait(C4ID::None, true, false);
}
return true;
}
@ -189,6 +191,7 @@ bool C4ObjectInfo::Save(C4Group &hGroup, bool fStoreTiny, C4DefList *pDefs)
{
// Crew was renamed; file rename necessary, if the name is not blocked by another crew info
if (!hGroup.FindEntry(szTempGroup))
{
if (hGroup.Rename(Filename, szTempGroup))
SCopy(szTempGroup, Filename, _MAX_PATH);
else
@ -196,6 +199,7 @@ bool C4ObjectInfo::Save(C4Group &hGroup, bool fStoreTiny, C4DefList *pDefs)
// could not rename. Not fatal; just use old file
LogF("Error adjusting crew info for %s into %s: Rename error from %s to %s!", Name, hGroup.GetFullName().getData(), Filename, szTempGroup);
}
}
}
}
// Open group
@ -305,7 +309,7 @@ void C4ObjectInfo::Draw(C4Facet &cgo, bool fShowPortrait, C4Object *pOfObj)
if (fShowPortrait)
{
C4DefGraphics *pPortraitGfx;
if (pPortraitGfx = Portrait.GetGfx()) if (pPortraitGfx->Bitmap->Wdt)
if ((pPortraitGfx = Portrait.GetGfx())) if (pPortraitGfx->Bmp.Bitmap->Wdt)
{
//C4Facet fctPortrait; fctPortrait.Set(Portrait);
C4Facet ccgo; ccgo.Set(cgo.Surface,cgo.X+iX,cgo.Y,4*cgo.Hgt/3+10,cgo.Hgt+10);
@ -439,7 +443,11 @@ bool C4ObjectInfo::ClearPortrait(bool fPermanently)
// no portrait
Portrait.Clear();
// clear new portrait; do not delete class (because empty class means no-portrait-as-new-setting)
if (fPermanently) if (pNewPortrait) pNewPortrait->Clear(); else pNewPortrait = new C4Portrait();
if (fPermanently)
{
if (pNewPortrait) pNewPortrait->Clear();
else pNewPortrait = new C4Portrait();
}
// done, success
return true;
}

View File

@ -67,9 +67,11 @@ int32_t C4ObjectInfoList::Load(C4Group &hGroup, bool fLoadPortraits)
// Search all c4i files
hGroup.ResetSearch();
while (hGroup.FindNextEntry(C4CFN_ObjectInfoFiles,entryname))
if (ninf=new C4ObjectInfo)
if ((ninf=new C4ObjectInfo))
{
if (ninf->Load(hGroup,entryname,fLoadPortraits)) { Add(ninf); infn++; }
else delete ninf;
}
// Search all c4o files
/*hGroup.ResetSearch();
@ -127,7 +129,7 @@ C4ObjectInfo* C4ObjectInfoList::GetIdle(C4ID c_id, C4DefList &rDefs)
// Search list
for (pInfo=First; pInfo; pInfo=pInfo->Next)
// Valid only
if (pDef = rDefs.ID2Def(pInfo->id))
if ((pDef = rDefs.ID2Def(pInfo->id)))
// Use standard crew or matching id
if ( (!c_id && !pDef->NativeCrew) || (pInfo->id==c_id) )
// Participating and not in action

View File

@ -367,7 +367,7 @@ void C4ObjectList::DrawIDList(C4Facet &cgo, int iSelection,
char szCount[10];
// objects are sorted in the list already, so just draw them!
C4ObjectListIterator iter(*this);
while (pFirstObj = iter.GetNext(&iCount))
while ((pFirstObj = iter.GetNext(&iCount)))
{
// Section
cgo2 = cgo.GetSection(cSec);
@ -583,8 +583,8 @@ StdStrBuf C4ObjectList::GetNameList(C4DefList &rDefs, DWORD dwCategory)
C4ID c_id;
C4Def *cdef;
StdStrBuf Buf;
for (cpos=0; c_id=GetListID(dwCategory,cpos); cpos++)
if (cdef=rDefs.ID2Def(c_id))
for (cpos=0; (c_id=GetListID(dwCategory,cpos)); cpos++)
if ((cdef=rDefs.ID2Def(c_id)))
{
idcount=ObjectCount(c_id);
if (cpos>0) Buf.Append(", ");
@ -776,15 +776,15 @@ bool C4ObjectList::OrderObjectBefore(C4Object *pObj1, C4Object *pObj2)
C4ObjectLink *pLnk2=GetLink(pObj2); if (!pLnk2) return false;
// check if requirements are already fulfilled
C4ObjectLink *pLnk=pLnk1;
while (pLnk=pLnk->Next) if (pLnk==pLnk2) break;
while ((pLnk=pLnk->Next)) if (pLnk==pLnk2) break;
if (pLnk) return true;
// if not, reorder pLnk1 directly before pLnk2
// unlink from current position
// no need to check pLnk1->Prev here, because pLnk1 cannot be first in the list
// (at least pLnk2 must lie before it!)
if (pLnk1->Prev->Next=pLnk1->Next) pLnk1->Next->Prev=pLnk1->Prev; else Last=pLnk1->Prev;
if ((pLnk1->Prev->Next=pLnk1->Next)) pLnk1->Next->Prev=pLnk1->Prev; else Last=pLnk1->Prev;
// relink into new one
if (pLnk1->Prev=pLnk2->Prev) pLnk2->Prev->Next=pLnk1; else First=pLnk1;
if ((pLnk1->Prev=pLnk2->Prev)) pLnk2->Prev->Next=pLnk1; else First=pLnk1;
pLnk1->Next=pLnk2; pLnk2->Prev=pLnk1;
// done, success
return true;
@ -799,15 +799,15 @@ bool C4ObjectList::OrderObjectAfter(C4Object *pObj1, C4Object *pObj2)
C4ObjectLink *pLnk2=GetLink(pObj2); if (!pLnk2) return false;
// check if requirements are already fulfilled
C4ObjectLink *pLnk=pLnk1;
while (pLnk=pLnk->Prev) if (pLnk==pLnk2) break;
while ((pLnk=pLnk->Prev)) if (pLnk==pLnk2) break;
if (pLnk) return true;
// if not, reorder pLnk1 directly after pLnk2
// unlink from current position
// no need to check pLnk1->Next here, because pLnk1 cannot be last in the list
// (at least pLnk2 must lie after it!)
if (pLnk1->Next->Prev=pLnk1->Prev) pLnk1->Prev->Next=pLnk1->Next; else First=pLnk1->Next;
if ((pLnk1->Next->Prev=pLnk1->Prev)) pLnk1->Prev->Next=pLnk1->Next; else First=pLnk1->Next;
// relink into new one
if (pLnk1->Next=pLnk2->Next) pLnk2->Next->Prev=pLnk1; else Last=pLnk1;
if ((pLnk1->Next=pLnk2->Next)) pLnk2->Next->Prev=pLnk1; else Last=pLnk1;
pLnk1->Prev=pLnk2; pLnk2->Next=pLnk1;
// done, success
return true;

View File

@ -63,7 +63,7 @@ class C4ObjectList
int Mass;
std::list<int32_t> *pEnumerated;
enum SortType { stNone=0, stMain, stContents, stReverse, };
enum SortType { stNone=0, stMain, stContents, stReverse };
// An iterator which survives if an object is removed from the list
class iterator

View File

@ -154,7 +154,7 @@ bool C4ObjectMenu::DoRefillInternal(bool &rfRefilled)
{
// Add target contents items
C4ObjectListIterator iter(pTarget->Contents);
while (pObj = iter.GetNext(&iCount, C4D_Activate))
while ((pObj = iter.GetNext(&iCount, C4D_Activate)))
{
pDef = pObj->Def;
if (pDef->NoGet) continue;
@ -191,7 +191,7 @@ bool C4ObjectMenu::DoRefillInternal(bool &rfRefilled)
{
// Add target contents items
C4ObjectListIterator iter(pTarget->Contents);
while (pObj = iter.GetNext(&iCount, C4D_Get))
while ((pObj = iter.GetNext(&iCount, C4D_Get)))
{
pDef = pObj->Def;
if (pDef->NoGet) continue;
@ -404,6 +404,10 @@ bool C4ObjectMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand)
// Object menu with scenario script callback
Game.Script.DirectExec(NULL, szCommand, "MenuCommand");
break;
case CB_None:
// TODO
break;
}
if ((!l_Permanent || fIsCloseCommand) && l_Object) l_Object->AutoContextMenu(l_LastSelection);
@ -425,19 +429,21 @@ int32_t C4ObjectMenu::AddContextFunctions(C4Object *pTarget, bool fCountOnly)
// ActionContext functions of target's action target (for first target only, because otherwise strange stuff can happen with outdated Target2s...)
if (pTarget->Action.pActionDef)
if (cObj = pTarget->Action.Target)
for (iFunction=0; pFunction=cObj->Def->Script.GetSFunc(iFunction, "ActionContext"); iFunction++)
if ((cObj = pTarget->Action.Target))
for (iFunction=0; (pFunction=cObj->Def->Script.GetSFunc(iFunction, "ActionContext")); iFunction++)
if (!pFunction->OverloadedBy)
if (!pFunction->Condition || !!pFunction->Condition->Exec(cObj, &C4AulParSet(C4VObj(Object), C4VID(pFunction->idImage), C4VObj(pTarget))))
{
if (!fCountOnly)
{
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",this,Object(%d))",cObj->Number,pFunction->Name,pTarget->Number);
fctSymbol.Create(16,16); if (pDef=C4Id2Def(pFunction->idImage)) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
fctSymbol.Create(16,16); if ((pDef=C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
Add(pFunction->DescText.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,pFunction->DescLong.getData());
iResult++;
}
else
iResult++;
}
// Effect context functions of target's effects
for (C4Effect *pEff = pTarget->pEffects; pEff; pEff = pEff->pNext)
@ -446,19 +452,21 @@ int32_t C4ObjectMenu::AddContextFunctions(C4Object *pTarget, bool fCountOnly)
C4AulScript *pEffScript = pEff->GetCallbackScript();
StdStrBuf sPattern; sPattern.Format(PSF_FxCustom, pEff->Name, "Context");
if (pEffScript)
for (iFunction=0; pFunction=pEffScript->GetSFunc(iFunction, sPattern.getData()); iFunction++)
for (iFunction=0; (pFunction=pEffScript->GetSFunc(iFunction, sPattern.getData())); iFunction++)
if (!pFunction->OverloadedBy)
if (!pFunction->Condition || !!pFunction->Condition->Exec(pEff->pCommandTarget, &C4AulParSet(C4VObj(pTarget), C4VInt(pEff->iNumber), C4VObj(Object), C4VID(pFunction->idImage))))
{
if (!fCountOnly)
{
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",Object(%d),%d,Object(%d),%s)",pEff->pCommandTarget->Number,pFunction->Name,pTarget->Number,(int)pEff->iNumber,Object->Number,pFunction->idImage.ToString());
fctSymbol.Create(16,16); if (pDef=C4Id2Def(pFunction->idImage)) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
fctSymbol.Create(16,16); if ((pDef=C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
Add(pFunction->DescText.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,pFunction->DescLong.getData());
fctSymbol.Default();
iResult++;
}
else
iResult++;
}
}
// Script context functions of any objects attached to target (search global list, because attachment objects might be moved just about anywhere...)
@ -466,27 +474,29 @@ int32_t C4ObjectMenu::AddContextFunctions(C4Object *pTarget, bool fCountOnly)
if (cObj->Status && cObj->Action.Target == pTarget)
if (cObj->Action.pActionDef)
if (cObj->Action.pActionDef->GetPropertyInt(P_Procedure) == DFA_ATTACH)
for (iFunction=0; pFunction=cObj->Def->Script.GetSFunc(iFunction, "AttachContext"); iFunction++)
for (iFunction=0; (pFunction=cObj->Def->Script.GetSFunc(iFunction, "AttachContext")); iFunction++)
if (!pFunction->OverloadedBy)
if (!pFunction->Condition || !! pFunction->Condition->Exec(cObj, &C4AulParSet(C4VObj(Object), C4VID(pFunction->idImage), C4VObj(pTarget))))
{
if (!fCountOnly)
{
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",this,Object(%d))",cObj->Number,pFunction->Name,pTarget->Number);
fctSymbol.Create(16,16); if (pDef=C4Id2Def(pFunction->idImage)) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
fctSymbol.Create(16,16); if ((pDef=C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
Add(pFunction->DescText.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,pFunction->DescLong.getData());
fctSymbol.Default();
iResult++;
}
else
iResult++;
}
// 'Activate' and 'ControlDigDouble' script functions of target
const char *func, *funcs[] = { "Activate", "ControlDigDouble", 0 };
for (int i = 0; func = funcs[i]; i++)
for (int i = 0; (func = funcs[i]); i++)
// 'Activate' function only if in clonk's inventory; 'ControlDigDouble' function only if pushed by clonk
if ((SEqual(func, "Activate") && (pTarget->Contained == Object)) || (SEqual(func, "ControlDigDouble") && (Object->GetProcedure() == DFA_PUSH) && (Object->Action.Target == pTarget)))
// Find function
if (pFunction = pTarget->Def->Script.GetSFunc(func))
if ((pFunction = pTarget->Def->Script.GetSFunc(func)))
// Find function not overloaded
if (!pFunction->OverloadedBy)
// Function condition valid
@ -496,7 +506,7 @@ int32_t C4ObjectMenu::AddContextFunctions(C4Object *pTarget, bool fCountOnly)
strDescText = pFunction->DescText.getData() ? pFunction->DescText.getData() : pTarget->GetName();
// Check if there is a scripted context function doing exactly the same
bool fDouble = false;
for (iFunction = 0; pFunction2 = pTarget->Def->Script.GetSFunc(iFunction, "Context"); iFunction++)
for (iFunction = 0; (pFunction2 = pTarget->Def->Script.GetSFunc(iFunction, "Context")); iFunction++)
if (!pFunction2->OverloadedBy)
if (!pFunction2->Condition || !!pFunction2->Condition->Exec(pTarget, &C4AulParSet(C4VObj(Object), C4VID(pFunction2->idImage))))
if (SEqual(strDescText, pFunction2->DescText.getData()))
@ -511,7 +521,7 @@ int32_t C4ObjectMenu::AddContextFunctions(C4Object *pTarget, bool fCountOnly)
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",this)",pTarget->Number,pFunction->Name);
// Symbol
fctSymbol.Create(16,16);
if (pDef = C4Id2Def(pFunction->idImage)) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
if ((pDef = C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
else pTarget->DrawPicture(fctSymbol);
// Add menu item
Add(strDescText, fctSymbol, szCommand, C4MN_Item_NoCount, NULL, pFunction->DescLong.getData());
@ -522,19 +532,21 @@ int32_t C4ObjectMenu::AddContextFunctions(C4Object *pTarget, bool fCountOnly)
// Script context functions of target
if (!(pTarget->OCF & OCF_CrewMember) || (pTarget->Owner==Object->Owner)) // Crew member: only allow if owned by ourself
if (!(pTarget->Category & C4D_Living) || pTarget->GetAlive()) // No dead livings
for (iFunction=0; pFunction=pTarget->Def->Script.GetSFunc(iFunction, "Context"); iFunction++)
for (iFunction=0; (pFunction=pTarget->Def->Script.GetSFunc(iFunction, "Context")); iFunction++)
if (!pFunction->OverloadedBy)
if (!pFunction->Condition || !! pFunction->Condition->Exec(pTarget, &C4AulParSet(C4VObj(Object), C4VID(pFunction->idImage))))
{
if (!fCountOnly)
{
sprintf(szCommand,"ProtectedCall(Object(%d),\"%s\",this)",pTarget->Number,pFunction->Name);
fctSymbol.Create(16,16); if (pDef=C4Id2Def(pFunction->idImage)) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
fctSymbol.Create(16,16); if ((pDef=C4Id2Def(pFunction->idImage))) pDef->Draw(fctSymbol, false, 0, NULL, pFunction->iImagePhase);
Add(pFunction->DescText.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,pFunction->DescLong.getData());
fctSymbol.Default();
iResult++;
}
else
iResult++;
}
// Context functions of the menu clonk itself (if not same as target)
if (Object != pTarget)

View File

@ -134,7 +134,7 @@ bool C4Player::ScenarioAndTeamInit(int32_t idTeam)
pTeam = NULL;
else
{
if (pTeam = Game.Teams.GetGenerateTeamByID(idTeam)) idTeam = pTeam->GetID();
if ((pTeam = Game.Teams.GetGenerateTeamByID(idTeam))) idTeam = pTeam->GetID();
}
}
else
@ -172,7 +172,7 @@ void C4Player::Execute()
if (Status==PS_TeamSelection)
{
int32_t idSelectedTeam;
if (idSelectedTeam = Game.Teams.GetForcedTeamSelection(ID))
if ((idSelectedTeam = Game.Teams.GetForcedTeamSelection(ID)))
{
// There's only one team left to join? Join there immediately.
if (Menu.IsActive() && Menu.GetIdentification() == C4MN_TeamSelection) Menu.TryClose(false, false);
@ -187,13 +187,13 @@ void C4Player::Execute()
{
// during team selection: Update view to selected team, if it has a position assigned
C4MenuItem *pSelectedTeamItem;
if (pSelectedTeamItem = Menu.GetSelectedItem())
if ((pSelectedTeamItem = Menu.GetSelectedItem()))
{
int32_t idSelectedTeam = pSelectedTeamItem->GetValue();
if (idSelectedTeam)
{
C4Team *pSelectedTeam;
if (pSelectedTeam = Game.Teams.GetTeamByID(idSelectedTeam))
if ((pSelectedTeam = Game.Teams.GetTeamByID(idSelectedTeam)))
{
int32_t iPlrStartIndex = pSelectedTeam->GetPlrStartIndex();
if (iPlrStartIndex && Inside<int32_t>(iPlrStartIndex, 1, C4S_MaxPlayer))
@ -226,7 +226,7 @@ void C4Player::Execute()
// decay of dead viewtargets
C4ObjectLink *pLnkNext = FoWViewObjs.First, *pLnk;
while (pLnk = pLnkNext)
while ((pLnk = pLnkNext))
{
pLnkNext = pLnk->Next;
C4Object *pDeadClonk = pLnk->Obj;
@ -495,7 +495,7 @@ void C4Player::PlaceReadyCrew(int32_t tx1, int32_t tx2, int32_t ty, C4Object *Fi
if (!Game.C4S.PlrStart[PlrStartIndex].EnforcePosition)
FindSolidGround(ctx,cty,pDef->Shape.Wdt*3);
// Create object
if (nobj=Game.CreateInfoObject(pInfo,Number,ctx,cty))
if ((nobj=Game.CreateInfoObject(pInfo,Number,ctx,cty)))
{
// Add object to crew
Crew.Add(nobj, C4ObjectList::stMain);
@ -519,7 +519,7 @@ void C4Player::PlaceReadyCrew(int32_t tx1, int32_t tx2, int32_t ty, C4Object *Fi
// Place crew
int32_t iCount;
C4ID id;
for (cnt=0; id=Game.C4S.PlrStart[PlrStartIndex].ReadyCrew.GetID(cnt,&iCount); cnt++)
for (cnt=0; (id=Game.C4S.PlrStart[PlrStartIndex].ReadyCrew.GetID(cnt,&iCount)); cnt++)
{
// Minimum one clonk if empty id
@ -538,7 +538,7 @@ void C4Player::PlaceReadyCrew(int32_t tx1, int32_t tx2, int32_t ty, C4Object *Fi
if (!Game.C4S.PlrStart[PlrStartIndex].EnforcePosition)
FindSolidGround(ctx,cty,pDef->Shape.Wdt*3);
// Create object
if (nobj=Game.CreateInfoObject(pInfo,Number,ctx,cty))
if ((nobj=Game.CreateInfoObject(pInfo,Number,ctx,cty)))
{
// Add object to crew
Crew.Add(nobj, C4ObjectList::stMain);
@ -579,13 +579,13 @@ void C4Player::PlaceReadyBase(int32_t &tx, int32_t &ty, C4Object **pFirstBase)
// Create ready base structures
for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyBase.GetID(cnt)); cnt++)
{
if (def=C4Id2Def(cid))
if ((def=C4Id2Def(cid)))
for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyBase.GetCount(cnt); cnt2++)
{
ctx=tx; cty=ty;
if (Game.C4S.PlrStart[PlrStartIndex].EnforcePosition
|| FindConSiteSpot(ctx,cty,def->Shape.Wdt,def->Shape.Hgt,def->Category,20))
if (cbase=Game.CreateObjectConstruction(C4Id2Def(cid),NULL,Number,ctx,cty,FullCon,true))
if ((cbase=Game.CreateObjectConstruction(C4Id2Def(cid),NULL,Number,ctx,cty,FullCon,true)))
{
// FirstBase
if (!(*pFirstBase)) if ((cbase->Def->Entrance.Wdt>0) && (cbase->Def->Entrance.Hgt>0))
@ -613,13 +613,13 @@ void C4Player::PlaceReadyVehic(int32_t tx1, int32_t tx2, int32_t ty, C4Object *F
C4Def *def; C4ID cid; C4Object *cobj;
for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyVehic.GetID(cnt)); cnt++)
{
if (def=C4Id2Def(cid))
if ((def=C4Id2Def(cid)))
for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyVehic.GetCount(cnt); cnt2++)
{
ctx=tx1+Random(tx2-tx1); cty=ty;
if (!Game.C4S.PlrStart[PlrStartIndex].EnforcePosition)
FindLevelGround(ctx,cty,def->Shape.Wdt,6);
if (cobj=Game.CreateObject(cid,NULL,Number,ctx,cty))
if ((cobj=Game.CreateObject(cid,NULL,Number,ctx,cty)))
{
if (FirstBase) // First base overrides target location
{ cobj->Enter(FirstBase); cobj->SetCommand(C4CMD_Exit); }
@ -644,7 +644,7 @@ void C4Player::PlaceReadyMaterial(int32_t tx1, int32_t tx2, int32_t ty, C4Object
{
for (cnt=0; (cid=Game.C4S.PlrStart[PlrStartIndex].ReadyMaterial.GetID(cnt)); cnt++)
{
if (def=C4Id2Def(cid))
if ((def=C4Id2Def(cid)))
for (cnt2=0; cnt2<Game.C4S.PlrStart[PlrStartIndex].ReadyMaterial.GetCount(cnt); cnt2++)
{
ctx=tx1+Random(tx2-tx1); cty=ty;
@ -668,7 +668,7 @@ bool C4Player::ScenarioInit()
// player start index by team, if specified. Otherwise by player number
PlrStartIndex = Number % C4S_MaxPlayer;
C4Team *pTeam; int32_t i;
if (Team && (pTeam = Game.Teams.GetTeamByID(Team))) if (i=pTeam->GetPlrStartIndex()) PlrStartIndex=i-1;
if (Team && (pTeam = Game.Teams.GetTeamByID(Team))) if ((i=pTeam->GetPlrStartIndex())) PlrStartIndex=i-1;
// Set color
int32_t iColor=BoundBy<int32_t>(PrefColor,0,C4MaxColor-1);
@ -961,10 +961,10 @@ C4Object* C4Player::GetHiRankActiveCrew(bool fSelectOnly)
void C4Player::CheckCrewExPromotion()
{
C4Object *hirank;
if (hirank=GetHiRankActiveCrew(false))
if ((hirank=GetHiRankActiveCrew(false)))
if (hirank->Info)
if (hirank->Info->Rank<1) // No Fähnrich -> except. promo.
if (hirank=GetHiExpActiveCrew(false))
if ((hirank=GetHiExpActiveCrew(false)))
hirank->Promote(1,true,false);
}
@ -1100,7 +1100,7 @@ bool C4Player::Strip(const char *szFilename, bool fAggressive)
void C4Player::DrawHostility(C4Facet &cgo, int32_t iIndex)
{
C4Player *pPlr;
if (pPlr=::Players.GetByIndex(iIndex))
if ((pPlr=::Players.GetByIndex(iIndex)))
{
// Portrait
if (Config.Graphics.ShowPortraits && pPlr->BigIcon.Surface)
@ -1193,7 +1193,7 @@ void C4Player::CursorRight()
{
C4ObjectLink *cLnk;
// Get next crew member
if (cLnk=Crew.GetLink(Cursor))
if ((cLnk=Crew.GetLink(Cursor)))
for (cLnk=cLnk->Next; cLnk; cLnk=cLnk->Next)
if (cLnk->Obj->Status && !cLnk->Obj->CrewDisabled) break;
if (!cLnk)
@ -1210,7 +1210,7 @@ void C4Player::CursorLeft()
{
C4ObjectLink *cLnk;
// Get prev crew member
if (cLnk=Crew.GetLink(Cursor))
if ((cLnk=Crew.GetLink(Cursor)))
for (cLnk=cLnk->Prev; cLnk; cLnk=cLnk->Prev)
if (cLnk->Obj->Status && !cLnk->Obj->CrewDisabled) break;
if (!cLnk)
@ -1265,7 +1265,10 @@ void C4Player::CursorToggle()
if (CursorSelection)
{
if (Cursor)
if (Cursor->Select) Cursor->UnSelect(); else Cursor->DoSelect();
{
if (Cursor->Select) Cursor->UnSelect();
else Cursor->DoSelect();
}
CursorToggled=1;
}
// Pure toggle: toggle all Select
@ -1273,7 +1276,10 @@ void C4Player::CursorToggle()
{
for (clnk=Crew.First; clnk; clnk=clnk->Next)
if (!clnk->Obj->CrewDisabled)
if (clnk->Obj->Select) clnk->Obj->UnSelect(); else clnk->Obj->DoSelect();
{
if (clnk->Obj->Select) clnk->Obj->UnSelect();
else clnk->Obj->DoSelect();
}
AdjustCursorCommand();
}
// Updates
@ -1297,12 +1303,14 @@ void C4Player::SelectAllCrew()
void C4Player::UpdateSelectionToggleStatus()
{
if (CursorSelection)
{
// Select toggled: cursor to hirank
if (CursorToggled)
AdjustCursorCommand();
// Cursor select only: single control
else
SelectSingleByCursor();
}
CursorSelection=0;
CursorToggled=0;
}
@ -1401,8 +1409,13 @@ void C4Player::CompileFunc(StdCompiler *pComp, bool fExact)
pComp->Value(mkNamingAdapt(SelectCount, "SelectCount", 0));
pComp->Value(mkNamingAdapt(SelectFlash, "SelectFlash", 0));
pComp->Value(mkNamingAdapt(CursorFlash, "CursorFlash", 0));
pComp->Value(mkNamingAdapt((int32_t&)Cursor, "Cursor", 0));
pComp->Value(mkNamingAdapt((int32_t&)ViewCursor,"ViewCursor", 0));
int32_t iPtr;
iPtr = reinterpret_cast<intptr_t>(Cursor);
pComp->Value(mkNamingAdapt(iPtr, "Cursor", 0));
Cursor = reinterpret_cast<C4Object*>(iPtr);
iPtr = reinterpret_cast<intptr_t>(ViewCursor);
pComp->Value(mkNamingAdapt(iPtr, "ViewCursor", 0));
ViewCursor = reinterpret_cast<C4Object*>(iPtr);
pComp->Value(mkNamingAdapt(CursorSelection, "CursorSelection", 0));
pComp->Value(mkNamingAdapt(CursorToggled, "CursorToggled", 0));
pComp->Value(mkNamingAdapt(MessageStatus, "MessageStatus", 0));
@ -1594,7 +1607,7 @@ void C4Player::RemoveCrewObjects()
C4Object *pCrew;
// Remove all crew objects
while (pCrew = Crew.GetObject()) pCrew->AssignRemoval(true);
while ((pCrew = Crew.GetObject())) pCrew->AssignRemoval(true);
}
void C4Player::NotifyOwnedObjects()
@ -1745,10 +1758,12 @@ void C4Player::FoW2Map(CClrModAddMap &rMap, int iOffX, int iOffY)
C4Object *cobj; C4ObjectLink *clnk;
for (clnk=FoWViewObjs.First; clnk && (cobj=clnk->Obj); clnk=clnk->Next)
if (!cobj->Contained || cobj->Contained->Def->ClosedContainer != 1)
{
if (cobj->PlrViewRange > 0)
rMap.ReduceModulation(cobj->GetX() + iOffX, cobj->GetY() + iOffY, cobj->PlrViewRange, VisibilityCheck);
else
fAnyGenerators = true;
}
// Add view for target view object
if (ViewMode==C4PVM_Target)
if (ViewTarget)
@ -1800,6 +1815,7 @@ bool C4Player::FoWIsVisible(int32_t x, int32_t y)
}
if (!cobj->Contained || cobj->Contained->Def->ClosedContainer != 1)
if (Distance(cobj->GetX(), cobj->GetY(), x, y) < Abs(iRange))
{
if (iRange < 0)
{
if ((cobj->ColorMod & 0xff000000) != 0xff000000) // faded generators generate darkness only; no FoW blocking
@ -1807,6 +1823,7 @@ bool C4Player::FoWIsVisible(int32_t x, int32_t y)
}
else
fSeen = true; // made visible by FoW-repeller
}
}
return fSeen;
}
@ -1843,7 +1860,7 @@ void C4Player::Eliminate()
{
// Check: Any player left at this client?
C4Player *pPlr = NULL;
for(int i = 0; pPlr = ::Players.GetAtClient(AtClient, i); i++)
for(int i = 0; (pPlr = ::Players.GetAtClient(AtClient, i)); i++)
if(!pPlr->Eliminated)
break;
// If not, deactivate the client
@ -1860,7 +1877,7 @@ int32_t C4Player::ActiveCrewCount()
int32_t iNum=0;
C4Object *cObj;
for (C4ObjectLink *cLnk=Crew.First; cLnk; cLnk=cLnk->Next)
if (cObj=cLnk->Obj)
if ((cObj=cLnk->Obj))
if (!cObj->CrewDisabled)
++iNum;
// return it
@ -1872,7 +1889,7 @@ int32_t C4Player::GetSelectedCrewCount()
int32_t iNum=0;
C4Object *cObj;
for (C4ObjectLink *cLnk=Crew.First; cLnk; cLnk=cLnk->Next)
if (cObj=cLnk->Obj)
if ((cObj=cLnk->Obj))
if (!cObj->CrewDisabled)
if (cObj->Select)
++iNum;
@ -2087,8 +2104,8 @@ void C4Player::SetPlayerColor(uint32_t dwNewClr)
ColorDw = dwNewClr;
C4Object *pObj;
for (C4ObjectLink *pLnk = ::Objects.First; pLnk; pLnk = pLnk->Next)
if (pObj = pLnk->Obj)
if (pObj->Status)
if ((pObj = pLnk->Obj))
if ((pObj->Status))
if (pObj->Owner == Number)
{
if ((pObj->Color & 0xffffff) == (dwOldClr & 0xffffff))

View File

@ -55,7 +55,7 @@ class C4Player: public C4PlayerInfoCore
PCID_Message, // chat
PCID_Special, // goalruleinfo, etc.
PCID_Command, // mouse control
PCID_DirectCom, // menu or keyboard control
PCID_DirectCom // menu or keyboard control
};
// possible status
enum StatusTypes
@ -63,7 +63,7 @@ class C4Player: public C4PlayerInfoCore
PS_None=0, // player disabled
PS_Normal=1, // normal playing
PS_TeamSelection = 2, // team selection
PS_TeamSelectionPending = 3, // waiting for team selection packet to come through
PS_TeamSelectionPending = 3 // waiting for team selection packet to come through
};
friend class C4PlayerList;
public:

View File

@ -54,7 +54,7 @@ void C4PlayerList::Default()
void C4PlayerList::Clear()
{
C4Player *pPlr;
while (pPlr = First)
while ((pPlr = First))
{ First = pPlr->Next; delete pPlr; }
First = NULL;
}
@ -498,7 +498,7 @@ bool C4PlayerList::RemoveAtClient(int iClient, bool fDisconnect)
{
C4Player *pPlr;
// Get players
while (pPlr = GetAtClient(iClient))
while ((pPlr = GetAtClient(iClient)))
{
// Log
Log(FormatString(LoadResStr("IDS_PRC_REMOVEPLR"),pPlr->GetName()).getData());
@ -512,7 +512,7 @@ bool C4PlayerList::RemoveAtClient(const char *szName, bool fDisconnect)
{
C4Player *pPlr;
// Get players
while (pPlr = GetAtClient(szName))
while ((pPlr = GetAtClient(szName)))
{
// Log
Log(FormatString(LoadResStr("IDS_PRC_REMOVEPLR"),pPlr->GetName()).getData());
@ -577,7 +577,7 @@ bool C4PlayerList::RemoveAtRemoteClient(bool fDisconnect, bool fNoCalls)
{
C4Player *pPlr;
// Get players
while (pPlr = GetAtRemoteClient())
while ((pPlr = GetAtRemoteClient()))
{
// Log
Log(FormatString(LoadResStr("IDS_PRC_REMOVEPLR"),pPlr->GetName()).getData());

View File

@ -152,6 +152,7 @@ bool C4RankSystem::Load(C4Group &hGroup, const char *szFilenames, int DefRankBas
{
// zero-character found: content?
if (pPos-pRank0>0)
{
// extension?
if (*pRank0 == '*')
{
@ -175,6 +176,7 @@ bool C4RankSystem::Load(C4Group &hGroup, const char *szFilenames, int DefRankBas
// yeeehaa! it's a name! store it, store it!
*pszCurrRank++=pRank0;
}
}
// advance pos
pRank0=pPos+1;
}

View File

@ -85,7 +85,7 @@ C4Effect::C4Effect(C4Object *pForObj, const char *szName, int32_t iPrio, int32_t
pPrev = *ppEffectList;
if (pPrev && Abs(pPrev->iPriority) < iPrio)
{
while (pCheck = pPrev->pNext)
while ((pCheck = pPrev->pNext))
if (Abs(pCheck->iPriority) >= iPrio) break; else pPrev = pCheck;
// insert after previous
pNext = pPrev->pNext;
@ -156,7 +156,7 @@ C4Effect::~C4Effect()
{
// del following effects (not recursively)
C4Effect *pEffect;
while (pEffect = pNext)
while ((pEffect = pNext))
{
pNext = pEffect->pNext;
pEffect->pNext = NULL;
@ -174,7 +174,7 @@ void C4Effect::EnumeratePointers()
pEff->nCommandTarget = ::Objects.ObjectNumber(pEff->pCommandTarget);
// effect var denumeration: not necessary, because this is done while saving
}
while (pEff=pEff->pNext);
while ((pEff=pEff->pNext));
}
void C4Effect::DenumeratePointers()
@ -190,7 +190,7 @@ void C4Effect::DenumeratePointers()
// assign any callback functions
pEff->AssignCallbackFunctions();
}
while (pEff=pEff->pNext);
while ((pEff=pEff->pNext));
}
void C4Effect::ClearPointers(C4Object *pObj)
@ -204,7 +204,7 @@ void C4Effect::ClearPointers(C4Object *pObj)
pEff->SetDead();
pEff->pCommandTarget=NULL;
}
while (pEff=pEff->pNext);
while ((pEff=pEff->pNext));
}
C4Effect *C4Effect::Get(const char *szName, int32_t iIndex, int32_t iMaxPriority)
@ -228,7 +228,7 @@ C4Effect *C4Effect::Get(const char *szName, int32_t iIndex, int32_t iMaxPriority
// effect found
return pEff;
}
while (pEff=pEff->pNext);
while ((pEff=pEff->pNext));
// nothing found
return NULL;
}
@ -246,7 +246,7 @@ C4Effect *C4Effect::Get(int32_t iNumber, bool fIncludeDead, int32_t iMaxPriority
// effect found but denied
return NULL;
}
while (pEff=pEff->pNext);
while ((pEff=pEff->pNext));
// nothing found
return NULL;
}
@ -259,7 +259,7 @@ int32_t C4Effect::GetCount(const char *szMask, int32_t iMaxPriority)
if (!szMask || SWildcardMatchEx(pEff->Name, szMask))
if (!iMaxPriority || pEff->iPriority <= iMaxPriority)
++iCnt;
while (pEff = pEff->pNext);
while ((pEff = pEff->pNext));
// return count
return iCnt;
}
@ -336,6 +336,7 @@ void C4Effect::Execute(C4Object *pObj)
++pEffect->iTime;
// check timer execution
if (pEffect->iIntervall && !(pEffect->iTime % pEffect->iIntervall))
{
if (pEffect->pFnTimer)
{
if (pEffect->pFnTimer->Exec(pEffect->pCommandTarget, &C4AulParSet(C4VObj(pObj), C4VInt(pEffect->iNumber), C4VInt(pEffect->iTime))).getInt() == C4Fx_Execute_Kill)
@ -351,6 +352,7 @@ void C4Effect::Execute(C4Object *pObj)
else
// no timer function: mark dead after time elapsed
pEffect->Kill(pObj);
}
// next effect
ppPrevEffect = &pEffect->pNext;
pEffect = pEffect->pNext;
@ -518,6 +520,7 @@ void C4Effect::CompileFunc(StdCompiler *pComp)
pComp->Seperator(StdCompiler::SEP_END); // ')'
// read variables
if(pComp->isCompiler() || EffectVars.GetSize() > 0)
{
if(pComp->Seperator(StdCompiler::SEP_START2)) // '['
{
pComp->Value(EffectVars);
@ -525,6 +528,7 @@ void C4Effect::CompileFunc(StdCompiler *pComp)
}
else
EffectVars.Reset();
}
// is there a next effect?
bool fNext = !! pNext;
if(pComp->hasNaming())
@ -577,13 +581,13 @@ int32_t FnFxFireStart(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_
// eject contents
C4Object *cobj;
if (!pObj->Def->IncompleteActivity && !pObj->Def->NoBurnDecay)
while (cobj=pObj->Contents.GetObject())
while ((cobj=pObj->Contents.GetObject()))
if (pObj->Contained) cobj->Enter(pObj->Contained);
else cobj->Exit(cobj->GetX(),cobj->GetY());
// Detach attached objects
cobj = 0;
if (!pObj->Def->IncompleteActivity && !pObj->Def->NoBurnDecay)
while (cobj = Game.FindObject(C4ID::None, 0, 0, 0, 0, OCF_All, 0, pObj, 0, 0, ANY_OWNER, cobj))
while ((cobj = Game.FindObject(C4ID::None, 0, 0, 0, 0, OCF_All, 0, pObj, 0, 0, ANY_OWNER, cobj)))
if (cobj->Action.pActionDef && (cobj->Action.pActionDef->GetPropertyInt(P_Procedure) == DFA_ATTACH))
cobj->SetAction(0);
// fire caused?
@ -634,8 +638,8 @@ int32_t FnFxFireTimer(C4AulContext *ctx, C4Object *pObj, int32_t iNumber, int32_
// get cause
int32_t iCausedByPlr = NO_OWNER; C4Effect *pEffect;
if (pEffect = pObj->pEffects)
if (pEffect = pEffect->Get(iNumber, true))
if ((pEffect = pObj->pEffects))
if ((pEffect = pEffect->Get(iNumber, true)))
{
iCausedByPlr = FxFireVarCausedBy(pEffect).getInt();
if (!ValidPlr(iCausedByPlr)) iCausedByPlr = NO_OWNER;
@ -844,7 +848,7 @@ void Smoke(int32_t tx, int32_t ty, int32_t level, DWORD dwClr)
// Create smoke
level=BoundBy<int32_t>(level,3,32);
C4Object *pObj;
if (pObj = Game.CreateObjectConstruction(C4Id2Def(C4ID("FXS1")),NULL,NO_OWNER,tx,ty,FullCon*level/32))
if ((pObj = Game.CreateObjectConstruction(C4Id2Def(C4ID("FXS1")),NULL,NO_OWNER,tx,ty,FullCon*level/32)))
pObj->Call(PSF_Activate);
}
@ -883,7 +887,7 @@ void Explosion(int32_t tx, int32_t ty, int32_t level, C4Object *inobj, int32_t i
::Particles.Cast(::Particles.pFSpark, level/5+1, (float) tx, (float) ty, level, level/2+1.0f, 0x00ef0000, level+1.0f, 0xffff1010);
}
else
if (pBlast = Game.CreateObjectConstruction(C4Id2Def(idEffect ? idEffect : C4ID("FXB1")),pByObj,iCausedBy,tx,ty+level,FullCon*level/20))
if ((pBlast = Game.CreateObjectConstruction(C4Id2Def(idEffect ? idEffect : C4ID("FXB1")),pByObj,iCausedBy,tx,ty+level,FullCon*level/20)))
pBlast->Call(PSF_Activate);
}
// Blast objects

View File

@ -292,24 +292,30 @@ C4Object *C4FindObject::Find(const C4ObjectList &Objs, const C4LSectors &Sct)
C4LArea Area(&::Objects.Sectors, *pBounds); C4LSector *pSct;
C4Object *pObj;
for (C4ObjectList *pLst=Area.FirstObjectShapes(&pSct); pLst; pLst=Area.NextObjectShapes(pLst, &pSct))
if(pObj = Find(*pLst))
if((pObj = Find(*pLst)))
{
if (!pSort)
return pObj;
else if (!pBestResult || pSort->Compare(pObj, pBestResult) > 0)
if(pObj->Status)
pBestResult = pObj;
}
}
else
{
C4LArea Area(&::Objects.Sectors, *pBounds); C4LSector *pSct;
C4Object *pObj;
for (C4ObjectList *pLst=Area.FirstObjects(&pSct); pLst; pLst=Area.NextObjects(pLst, &pSct))
if(pObj = Find(*pLst))
{
if((pObj = Find(*pLst)))
{
if (!pSort)
return pObj;
else if (!pBestResult || pSort->Compare(pObj, pBestResult) > 0)
if(pObj->Status)
pBestResult = pObj;
}
}
}
return pBestResult;
}
@ -419,7 +425,7 @@ bool C4FindObjectNot::Check(C4Object *pObj)
// *** C4FindObjectAnd
C4FindObjectAnd::C4FindObjectAnd(int32_t inCnt, C4FindObject **ppConds, bool fFreeArray)
: iCnt(inCnt), ppConds(ppConds), fHasBounds(false), fUseShapes(false), fFreeArray(fFreeArray)
: iCnt(inCnt), ppConds(ppConds), fFreeArray(fFreeArray), fUseShapes(false), fHasBounds(false)
{
// Filter ensured entries
int32_t i;
@ -868,7 +874,7 @@ int32_t C4SortObjectMultiple::Compare(C4Object *pObj1, C4Object *pObj2)
// return first comparison that's nonzero
int32_t iCmp;
for (int32_t i=0; i<iCnt; ++i)
if (iCmp = ppSorts[i]->Compare(pObj1, pObj2))
if ((iCmp = ppSorts[i]->Compare(pObj1, pObj2)))
return iCmp;
// all comparisons equal
return 0;
@ -888,7 +894,7 @@ int32_t C4SortObjectMultiple::CompareCache(int32_t iObj1, int32_t iObj2, C4Objec
// return first comparison that's nonzero
int32_t iCmp;
for (int32_t i=0; i<iCnt; ++i)
if (iCmp = ppSorts[i]->CompareCache(iObj1, iObj2, pObj1, pObj2))
if ((iCmp = ppSorts[i]->CompareCache(iObj1, iObj2, pObj1, pObj2)))
return iCmp;
// all comparisons equal
return 0;

View File

@ -48,7 +48,7 @@ enum C4FindObjectCondID
C4FO_Owner = 50,
C4FO_Controller = 51,
C4FO_Func = 60,
C4FO_Layer = 70,
C4FO_Layer = 70
};
// Sort map - using same values as C4FindObjectCondID!
@ -63,7 +63,7 @@ enum C4SortObjectCondID
C4SO_Mass = 140, // lightest first
C4SO_Value = 150, // cheapest first
C4SO_Func = 160, // least return values first
C4SO_Last = 200, // no sort condition larger than this
C4SO_Last = 200 // no sort condition larger than this
};
class C4LSectors;
@ -430,7 +430,7 @@ class C4SortObjectMultiple : public C4SortObject // apply next sort if previous
{
public:
C4SortObjectMultiple(int32_t iCnt, C4SortObject **ppSorts, bool fFreeArray = true)
: C4SortObject(), iCnt(iCnt), ppSorts(ppSorts), fFreeArray(fFreeArray) {}
: C4SortObject(), fFreeArray(fFreeArray), iCnt(iCnt), ppSorts(ppSorts) {}
virtual ~C4SortObjectMultiple();
private:
bool fFreeArray;

View File

@ -600,7 +600,7 @@ static bool FnSetPhysical(C4AulObjectContext *cthr, C4String *szPhysical, long i
return true;
}
// Invalid mode
throw new C4AulExecError(cthr->Obj, FormatString("SetPhysical: invalid physical mode %i", iMode).getData());
throw new C4AulExecError(cthr->Obj, FormatString("SetPhysical: invalid physical mode %ld", iMode).getData());
}
static bool FnTrainPhysical(C4AulObjectContext *cthr, C4String *szPhysical, long iTrainBy, long iMaxTrain)
@ -676,10 +676,12 @@ static Nillable<long> FnGetPhysical(C4AulContext *cthr, C4String *szPhysical, lo
if (!cthr->Obj->Info) return C4VNull;
// In fair crew mode, scripts may not read permanent physical values - fallback to fair def physical instead!
if (Game.Parameters.UseFairCrew)
{
if (cthr->Obj->Info->pDef)
return cthr->Obj->Info->pDef->GetFairCrewPhysicals()->*off;
else
return cthr->Obj->Def->GetFairCrewPhysicals()->*off;
}
// Get physical
return cthr->Obj->Info->Physical.*off;
// Temporary physical
@ -690,9 +692,12 @@ static Nillable<long> FnGetPhysical(C4AulContext *cthr, C4String *szPhysical, lo
if (!cthr->Obj->PhysicalTemporary) return C4VNull;
// Get physical
return cthr->Obj->TemporaryPhysical.*off;
case PHYS_StackTemporary:
// TODO
break;
}
// Invalid mode
throw new C4AulExecError(cthr->Obj, FormatString("GetPhysical: invalid physical mode %i", iMode).getData());
throw new C4AulExecError(cthr->Obj, FormatString("GetPhysical: invalid physical mode %ld", iMode).getData());
}
static C4Void FnSetEntrance(C4AulObjectContext *cthr, bool e_status)
@ -1029,7 +1034,7 @@ static bool FnSetName(C4AulContext *cthr, C4String *pNewName, bool fSetInInfo, b
// empty names are bad; e.g., could cause problems in savegames
if (!szName || !*szName) return false;
// name must not be too long
if (SLen(szName) > C4MaxName) return false;
if (std::strlen(szName) > C4MaxName) return false;
// any change at all?
if (SEqual(szName, pInfo->Name)) return true;
// make sure names in info list aren't duplicated
@ -1371,7 +1376,7 @@ static bool FnCreateMenu(C4AulObjectContext *cthr, C4ID iSymbol, C4Object *pComm
C4Def *pDef;
C4FacetSurface fctSymbol;
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
if (pDef = C4Id2Def(iSymbol)) pDef->Draw(fctSymbol);
if ((pDef = C4Id2Def(iSymbol))) pDef->Draw(fctSymbol);
// Clear any old menu, init new menu
if (!cthr->Obj->CloseMenu(false)) return false;
@ -1709,7 +1714,7 @@ static C4Object *FnContents(C4AulObjectContext *cthr, long index)
// Special: objects attaching to another object
// cannot be accessed by FnContents
C4Object *cobj;
while (cobj=cthr->Obj->Contents.GetObject(index++))
while ((cobj=cthr->Obj->Contents.GetObject(index++)))
if (cobj->GetProcedure()!=DFA_ATTACH) return cobj;
return NULL;
@ -1820,10 +1825,12 @@ static C4Object *FnCreateObject(C4AulContext *cthr,
long iOwner = owner;
if (owner.IsNil())
{
if (cthr->Obj)
iOwner = cthr->Obj->Controller;
else
iOwner = NO_OWNER;
}
C4Object *pNewObj = Game.CreateObject(PropList,cthr->Obj,iOwner,iXOffset,iYOffset);
@ -1851,10 +1858,12 @@ static C4Object *FnCreateConstruction(C4AulContext *cthr,
long iOwner = owner;
if (owner.IsNil())
{
if (cthr->Obj)
iOwner = cthr->Obj->Controller;
else
iOwner = NO_OWNER;
}
// Create site object
C4Object *pNewObj = Game.CreateObjectConstruction(PropList,cthr->Obj,iOwner,iXOffset,iYOffset,iCompletion*FullCon/100,fTerrain);
@ -2197,7 +2206,7 @@ static bool FnGameOver(C4AulContext *cthr, long iGameOverValue /* provided for f
static bool FnGainMissionAccess(C4AulContext *cthr, C4String *szPassword)
{
if (SLen(Config.General.MissionAccess)+SLen(FnStringPar(szPassword))+3>CFG_MaxString) return false;
if (std::strlen(Config.General.MissionAccess)+std::strlen(FnStringPar(szPassword))+3>CFG_MaxString) return false;
SAddModule(Config.General.MissionAccess,FnStringPar(szPassword));
return true;
}
@ -2240,8 +2249,10 @@ static C4Value FnPlayerMessage_C4V(C4AulContext *cthr, C4Value * iPlayer, C4Valu
// Text
if (!fSpoken)
if (SCopySegment(FnStringFormat(cthr,FnStringPar(szMessage),iPar0,iPar1,iPar2,iPar3,iPar4,iPar5,iPar6).getData(),0,buf,'$'))
{
if (pObj) GameMsgObjectPlayer(buf,pObj,iPlayer->getInt());
else GameMsgPlayer(buf, iPlayer->getInt());
}
return C4VBool(true);
}
@ -2262,8 +2273,10 @@ static C4Value FnMessage_C4V(C4AulContext *cthr, C4Value *c4vMessage, C4Value *c
C4Object * pObj = c4vObj->getObj();
if (!fSpoken)
if (SCopySegment(FnStringFormat(cthr,FnStringPar(szMessage),iPar0,iPar1,iPar2,iPar3,iPar4,iPar5,iPar6,iPar7).getData(),0,buf,'$'))
{
if (pObj) GameMsgObject(buf,pObj);
else GameMsgGlobal(buf);
}
return C4VBool(true);
}
@ -2295,8 +2308,10 @@ static C4Value FnPlrMessage_C4V(C4AulContext *cthr, C4Value *c4vMessage, C4Value
// Text
if (!fSpoken)
if (SCopySegment(FnStringFormat(cthr,FnStringPar(szMessage),iPar0,iPar1,iPar2,iPar3,iPar4,iPar5,iPar6,iPar7).getData(),0,buf,'$'))
{
if (ValidPlr(iPlr->getInt())) GameMsgPlayer(buf,iPlr->getInt());
else GameMsgGlobal(buf);
}
return C4VBool(true);
}
@ -2725,7 +2740,7 @@ static C4Object *FnGetCursor(C4AulContext *cthr, long iPlr, long iIndex)
C4Object *pCrew;
for (C4ObjectLink *pLnk=pPlr->Crew.First; pLnk; pLnk=pLnk->Next)
// get crew object
if (pCrew = pLnk->Obj)
if ((pCrew = pLnk->Obj))
// is it selected?
if (pCrew->Select)
// is it not the cursor? (which is always first)
@ -2955,8 +2970,16 @@ static long FnAngle(C4AulContext *cthr, long iX1, long iY1, long iX2, long iY2,
if(!iPrec) iPrec = 1;
long dx=iX2-iX1,dy=iY2-iY1;
if (!dx) if (dy>0) return 180 * iPrec; else return 0;
if (!dy) if (dx>0) return 90 * iPrec; else return 270 * iPrec;
if (!dx)
{
if (dy>0) return 180 * iPrec;
else return 0;
}
if (!dy)
{
if (dx>0) return 90 * iPrec;
else return 270 * iPrec;
}
iAngle = static_cast<long>(180.0 * iPrec * atan2(static_cast<double>(Abs(dy)), static_cast<double>(Abs(dx))) / pi);
@ -3794,7 +3817,7 @@ static bool FnSetGraphics(C4AulObjectContext *pCtx, C4String *pGfxName, C4ID idS
// any overlays must be positive for now
if (iOverlayID<0) { Log("SetGraphics: Background overlays not implemented!"); return false; }
// deleting overlay?
C4DefGraphics *pGrp;
C4DefGraphics *pGrp = NULL;
if (iOverlayMode == C4GraphicsOverlay::MODE_Object || iOverlayMode == C4GraphicsOverlay::MODE_Rank)
{
if (!pOverlayObject) return pCtx->Obj->RemoveGraphicsOverlay(iOverlayID);
@ -4190,7 +4213,7 @@ static C4Void FnSetCrewEnabled(C4AulObjectContext *cctx, bool fEnabled)
{
cctx->Obj->Select=false;
C4Player *pOwner;
if (pOwner=::Players.Get(cctx->Obj->Owner))
if ((pOwner=::Players.Get(cctx->Obj->Owner)))
{
// if viewed player cursor gets deactivated and no new cursor is found, follow the old in target mode
bool fWasCursorMode = (pOwner->ViewMode == C4PVM_Cursor);
@ -4720,9 +4743,10 @@ static C4Value FnGetPortrait(C4AulContext *ctx, C4Value *pvfGetID, C4Value *pvfG
{
// custom portrait?
if (pObj->Info->pCustomPortrait)
{
if (fGetID) return C4Value();
else
return C4VString(C4Portrait_Custom);
else return C4VString(C4Portrait_Custom);
}
// portrait string from info?
const char *szPortrait = pObj->Info->PortraitFile;
// no portrait string: portrait undefined ("none" would mean no portrait)
@ -4973,10 +4997,10 @@ static long FnModulateColor(C4AulContext *cthr, long iClr1, long iClr2)
// get alpha
long iA1=dwClr1>>24, iA2=dwClr2>>24;
// modulate color values; mod alpha upwards
DWORD r = ((dwClr1 & 0xff) * (dwClr2 & 0xff)) >> 8 | // blue
((dwClr1>> 8 & 0xff) * (dwClr2>>8 & 0xff)) & 0xff00 | // green
((dwClr1>>16 & 0xff) * (dwClr2>>8 & 0xff00)) & 0xff0000 | // red
Min<long>(iA1+iA2 - ((iA1*iA2)>>8), 255) << 24 ; // alpha
DWORD r = (((dwClr1 & 0xff) * (dwClr2 & 0xff)) >> 8) | // blue
(((dwClr1>> 8 & 0xff) * (dwClr2>>8 & 0xff)) & 0xff00) | // green
(((dwClr1>>16 & 0xff) * (dwClr2>>8 & 0xff00)) & 0xff0000) | // red
(Min<long>(iA1+iA2 - ((iA1*iA2)>>8), 255) << 24); // alpha
return r;
}
@ -5208,7 +5232,7 @@ static bool FnOnOwnerRemoved(C4AulObjectContext *cthr)
// Do not ignore flags which might be StaticBack if being attached to castle parts
int32_t iNewOwner = NO_OWNER;
C4Team *pTeam;
if (pPlr->Team) if (pTeam = Game.Teams.GetTeamByID(pPlr->Team))
if (pPlr->Team) if ((pTeam = Game.Teams.GetTeamByID(pPlr->Team)))
{
for (int32_t i=0; i<pTeam->GetPlayerCount(); ++i)
{
@ -5364,11 +5388,11 @@ static bool FnCustomMessage(C4AulContext *ctx, C4String *pMsg, C4Object *pObj, l
// only one positioning flag per direction allowed
uint32_t hpos = dwFlags & (C4GM_Left | C4GM_HCenter | C4GM_Right);
uint32_t vpos = dwFlags & (C4GM_Top | C4GM_VCenter | C4GM_Bottom);
if (((hpos | hpos-1) + 1)>>1 != hpos)
if (((hpos | (hpos-1)) + 1)>>1 != hpos)
{
throw new C4AulExecError(ctx->Obj, "CustomMessage: Only one horizontal positioning flag allowed!");
}
if (((vpos | vpos-1) + 1)>>1 != vpos)
if (((vpos | (vpos-1)) + 1)>>1 != vpos)
{
throw new C4AulExecError(ctx->Obj, "CustomMessage: Only one vertical positioning flag allowed!");
}
@ -5747,6 +5771,8 @@ public C4AulDefFuncHelper { \
/* Constructor, using the base class to create the ParType array */ \
C4AulDefFunc##N(C4AulScript *pOwner, const char *pName, Func pFunc, bool Public): \
C4AulDefFuncHelper(pOwner, pName, Public LIST(N, CONV_TYPE)), pFunc(pFunc) { } \
/* Avoid hiding base class function */ \
using C4AulFunc::Exec; \
/* Extracts the parameters from C4Values and wraps the return value in a C4Value */ \
virtual C4Value Exec(C4AulContext *pContext, C4Value pPars[], bool fPassErrors=false) \
{ return C4ValueConv<RType>::ToC4V(pFunc(pContext LIST(N, CONV_FROM_C4V))); } \
@ -5765,6 +5791,8 @@ public C4AulDefFuncHelper { \
/* Constructor, using the base class to create the ParType array */ \
C4AulDefObjectFunc##N(C4AulScript *pOwner, const char *pName, Func pFunc, bool Public): \
C4AulDefFuncHelper(pOwner, pName, Public LIST(N, CONV_TYPE)), pFunc(pFunc) { } \
/* Avoid hiding base class function */ \
using C4AulFunc::Exec; \
/* Extracts the parameters from C4Values and wraps the return value in a C4Value */ \
virtual C4Value Exec(C4AulContext *pContext, C4Value pPars[], bool fPassErrors=false) \
{ \
@ -6179,7 +6207,7 @@ void InitFunctionMap(C4AulScriptEngine *pEngine)
AddFunc(pEngine, "DeathAnnounce", FnDeathAnnounce);
AddFunc(pEngine, "SetSolidMask", FnSetSolidMask);
AddFunc(pEngine, "GetGravity", FnGetGravity);
AddFunc(pEngine, "GetGravity", FnGetGravity);
AddFunc(pEngine, "SetGravity", FnSetGravity);
AddFunc(pEngine, "Exit", FnExit);
AddFunc(pEngine, "Collect", FnCollect);
AddFunc(pEngine, "DoNoCollectDelay", FnDoNoCollectDelay);

View File

@ -89,7 +89,7 @@ bool C4TransferZones::Set(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, C4
// Empty zone: clear existing object zones
if (!iWdt || !iHgt) { ClearPointers(pObj); return true; }
// Update existing zone
if (pZone=Find(pObj))
if ((pZone=Find(pObj)))
{
pZone->X=iX; pZone->Y=iY;
pZone->Wdt=iWdt; pZone->Hgt=iHgt;
@ -176,7 +176,10 @@ bool C4TransferZone::GetEntryPoint(int32_t &rX, int32_t &rY, int32_t iToX, int32
{
// Target inside zone: move outside horizontally
if (Inside<int32_t>(iToX-X,0,Wdt-1) && Inside<int32_t>(iToY-Y,0,Hgt-1))
if (iToX<X+Wdt/2) iToX=X-1; else iToX=X+Wdt;
{
if (iToX<X+Wdt/2) iToX=X-1;
else iToX=X+Wdt;
}
// Get closest adjacent point
rX=BoundBy<int32_t>(iToX,X-1,X+Wdt);
rY=BoundBy<int32_t>(iToY,Y-1,Y+Hgt);

View File

@ -104,7 +104,7 @@ int32_t C4ChatControl::ChatSheet::NickItem::SortFunc(const C4GUI::Element *pEl1,
/* C4ChatControl::ChatSheet */
C4ChatControl::ChatSheet::ChatSheet(C4ChatControl *pChatControl, const char *szTitle, const char *szIdent, SheetType eType)
: C4GUI::Tabular::Sheet(szTitle, C4Rect(0,0,10,10), C4GUI::Ico_None, true, false), iBackBufferIndex(-1), eType(eType), pNickList(NULL), pInputLbl(NULL), pChatControl(pChatControl), fHasUnread(false)
: C4GUI::Tabular::Sheet(szTitle, C4Rect(0,0,10,10), C4GUI::Ico_None, true, false), pChatControl(pChatControl), pNickList(NULL), pInputLbl(NULL), iBackBufferIndex(-1), eType(eType), fHasUnread(false)
{
if (szIdent) sIdent.Copy(szIdent);
// create elements - positioned later
@ -285,7 +285,7 @@ void C4ChatControl::ChatSheet::UpdateUsers(C4Network2IRCUser *pUsers)
// update existing users
for (; pUsers; pUsers = pUsers->getNext())
{
if (pNickItem = GetNickItem(pUsers->getName()))
if ((pNickItem = GetNickItem(pUsers->getName())))
{
pNickItem->Update(pUsers);
}
@ -299,7 +299,7 @@ void C4ChatControl::ChatSheet::UpdateUsers(C4Network2IRCUser *pUsers)
}
// remove left users
pNextNickItem = GetFirstNickItem();
while (pNickItem = pNextNickItem)
while ((pNickItem = pNextNickItem))
{
pNextNickItem = GetNextNickItem(pNickItem);
if (!pNickItem->IsFlaggedExisting())
@ -475,10 +475,10 @@ C4ChatControl::ChatSheet *C4ChatControl::GetActiveChatSheet()
C4ChatControl::ChatSheet *C4ChatControl::GetSheetByIdent(const char *szIdent, C4ChatControl::ChatSheet::SheetType eType)
{
int32_t i=0; C4GUI::Tabular::Sheet *pSheet; const char *szCheckIdent;
while (pSheet = pTabChats->GetSheet(i++))
while ((pSheet = pTabChats->GetSheet(i++)))
{
ChatSheet *pChatSheet = static_cast<ChatSheet *>(pSheet);
if (szCheckIdent = pChatSheet->GetIdent())
if ((szCheckIdent = pChatSheet->GetIdent()))
if (SEqualNoCase(szCheckIdent, szIdent))
if (eType == pChatSheet->GetSheetType())
return pChatSheet;
@ -489,8 +489,8 @@ C4ChatControl::ChatSheet *C4ChatControl::GetSheetByIdent(const char *szIdent, C4
C4ChatControl::ChatSheet *C4ChatControl::GetSheetByTitle(const char *szTitle, C4ChatControl::ChatSheet::SheetType eType)
{
int32_t i=0; C4GUI::Tabular::Sheet *pSheet; const char *szCheckTitle;
while (pSheet = pTabChats->GetSheet(i++))
if (szCheckTitle = pSheet->GetTitle())
while ((pSheet = pTabChats->GetSheet(i++)))
if ((szCheckTitle = pSheet->GetTitle()))
if (SEqualNoCase(szCheckTitle, szTitle))
{
ChatSheet *pChatSheet = static_cast<ChatSheet *>(pSheet);
@ -596,7 +596,7 @@ bool C4ChatControl::IsServiceName(const char *szName)
if (!szName) return false;
const char *szServiceNames [] = { "NickServ", "ChanServ", "MemoServ", "HelpServ", "Global", NULL }, *szServiceName;
int32_t i = 0;
while (szServiceName = szServiceNames[i++])
while ((szServiceName = szServiceNames[i++]))
if (SEqualNoCase(szName, szServiceName))
return true;
return false;
@ -619,7 +619,7 @@ void C4ChatControl::Update()
}
// remove parted channels
int32_t i=0; C4GUI::Tabular::Sheet *pSheet;
while (pSheet = pTabChats->GetSheet(i++))
while ((pSheet = pTabChats->GetSheet(i++)))
{
C4Network2IRCChannel *pIRCChan;
ChatSheet *pChatSheet = static_cast<ChatSheet *>(pSheet);

View File

@ -129,7 +129,7 @@ bool C4FileSelDlg::DefaultListItem::UserToggleCheck()
C4FileSelDlg::C4FileSelDlg(const char *szRootPath, const char *szTitle, C4FileSel_BaseCB *pSelCallback, bool fInitElements)
: C4GUI::Dialog(BoundBy(C4GUI::GetScreenWdt()*2/3+10, 300,600), BoundBy(C4GUI::GetScreenHgt()*2/3+10, 220,500), szTitle, false),
pFileListBox(NULL), pSelectionInfoBox(NULL), btnOK(NULL), pSelection(NULL), pSelCallback(pSelCallback), pLocations(NULL), iLocationCount(0), pLocationComboBox(NULL)
pLocationComboBox(NULL), pFileListBox(NULL), pSelectionInfoBox(NULL), btnOK(NULL), pLocations(NULL), iLocationCount(0), pSelection(NULL), pSelCallback(pSelCallback)
{
sTitle.Copy(szTitle);
// key bindings
@ -270,7 +270,7 @@ void C4FileSelDlg::UpdateFileList()
BeginFileListUpdate();
// reload files
C4GUI::Element *pEl;
while (pEl = pFileListBox->GetFirst()) delete pEl;
while ((pEl = pFileListBox->GetFirst())) delete pEl;
// file items
StdStrBuf sSearch;
const char *szFileMask = GetFileMask();
@ -432,7 +432,7 @@ bool C4DefinitionSelDlg::SelectDefinitions(C4GUI::Screen *pOnScreen, StdStrBuf *
// let the user select definitions by showing a modal selection dialog
C4DefinitionSelDlg *pDlg = new C4DefinitionSelDlg(NULL, pSelection->getData());
bool fResult;
if (fResult = pOnScreen->ShowModalDlg(pDlg, false))
if ((fResult = pOnScreen->ShowModalDlg(pDlg, false)))
{
pSelection->Copy(pDlg->GetSelection(pSelection->getData(), true));
}
@ -670,7 +670,7 @@ bool C4PortraitSelDlg::SelectPortrait(C4GUI::Screen *pOnScreen, StdStrBuf *pSele
// let the user select a portrait by showing a modal selection dialog
C4PortraitSelDlg *pDlg = new C4PortraitSelDlg(NULL, *pfSetPicture, *pfSetBigIcon);
bool fResult;
if (fResult = pOnScreen->ShowModalDlg(pDlg, false))
if ((fResult = pOnScreen->ShowModalDlg(pDlg, false)))
{
pSelection->Take(pDlg->GetSelection(NULL, false));
*pfSetPicture = pDlg->IsSetPicture();

View File

@ -35,13 +35,13 @@ bool C4AbortGameDialog::is_shown = false;
// C4GameAbortDlg
C4AbortGameDialog::C4AbortGameDialog()
: fGameHalted(false),
C4GUI::ConfirmationDialog(LoadResStr("IDS_HOLD_ABORT"),
: C4GUI::ConfirmationDialog(LoadResStr("IDS_HOLD_ABORT"),
LoadResStr("IDS_DLG_ABORT"),
NULL,
MessageDialog::btnYesNo,
true,
C4GUI::Ico_Exit)
C4GUI::Ico_Exit),
fGameHalted(false)
{
is_shown = true; // assume dlg will be shown, soon
}

View File

@ -505,7 +505,7 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
StdStrBuf sPlrName;
sPlrName.Copy(szPar, iSepPos);
szPar += iSepPos+1; int32_t id=0;
while (pNfo = Game.PlayerInfos.GetNextPlayerInfoByID(id))
while ((pNfo = Game.PlayerInfos.GetNextPlayerInfoByID(id)))
{
id = pNfo->GetID();
if (WildcardMatch(sPlrName.getData(), pNfo->GetName())) break;
@ -583,7 +583,7 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
// ------------------------------------------------------
else if (SEqualNoCase(Command, "/help"))
{
LogF(LoadResStr("IDS_TEXT_COMMANDSAVAILABLEDURINGLO"));
Log(LoadResStr("IDS_TEXT_COMMANDSAVAILABLEDURINGLO"));
LogF("/start [time] - %s", LoadResStr("IDS_TEXT_STARTTHEROUNDWITHSPECIFIE"));
LogF("/abort - %s", LoadResStr("IDS_TEXT_ABORTSTARTCOUNTDOWN"));
LogF("/alert - %s", LoadResStr("IDS_TEXT_ALERTTHEHOSTIFTHEHOSTISAW"));
@ -963,6 +963,6 @@ void Countdown::Abort()
}
}
}; // end of namespace
} // end of namespace

View File

@ -91,7 +91,7 @@ namespace C4GameLobby
int32_t iBackBufferIndex; // chat message history index
C4KeyBinding *pKeyHistoryUp, *pKeyHistoryDown; // keys used to scroll through chat history
enum { SheetIdx_PlayerList = 0, SheetIdx_Res = 1, SheetIdx_Options = 2, SheetIdx_Scenario = 3, };
enum { SheetIdx_PlayerList = 0, SheetIdx_Res = 1, SheetIdx_Options = 2, SheetIdx_Scenario = 3 };
C4PlayerInfoListBox *pPlayerList;
C4Network2ResDlg *pResList;
C4GameOptionButtons *pGameOptionButtons;
@ -180,6 +180,6 @@ namespace C4GameLobby
void Abort();
};
};
}
#endif

View File

@ -38,7 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// C4GoalDisplay
C4GoalDisplay::GoalPicture::GoalPicture(const C4Rect &rcBounds, C4ID idGoal, bool fFulfilled)
: idGoal(idGoal), fFulfilled(fFulfilled), C4GUI::Window()
: C4GUI::Window(), idGoal(idGoal), fFulfilled(fFulfilled)
{
// bounds
SetBounds(rcBounds);

View File

@ -530,7 +530,11 @@ void Screen::RemoveElement(Element *pChild)
// clear ptrs
if (pActiveDlg == pChild) { pActiveDlg = NULL; Mouse.ResetElements(); }
Mouse.RemoveElement(pChild);
if (pContext) if (pContext == pChild) pContext=NULL; else pContext->RemoveElement(pChild);
if (pContext)
{
if (pContext == pChild) pContext=NULL;
else pContext->RemoveElement(pChild);
}
}
Screen::Screen(int32_t tx, int32_t ty, int32_t twdt, int32_t thgt) : Window(), Mouse(tx+twdt/2, ty+thgt/2), pContext(NULL), fExclusive(true), pGamePadOpener(NULL), fZoom(1.0f)
@ -588,7 +592,7 @@ void Screen::ShowDialog(Dialog *pDlg, bool fFade)
// add to local component list at correct ordering
int32_t iNewZ = pDlg->GetZOrdering(); Element *pEl; Dialog *pOtherDlg;
for (pEl = GetFirst(); pEl; pEl = pEl->GetNext())
if (pOtherDlg = pEl->GetDlg())
if ((pOtherDlg = pEl->GetDlg()))
if (pOtherDlg->GetZOrdering() > iNewZ)
break;
InsertElement(pDlg, pEl);
@ -654,7 +658,7 @@ Dialog *Screen::GetTopDialog()
// search backwards in component list
Dialog *pDlg;
for (Element *pEl = pLast; pEl; pEl = pEl->GetPrev())
if (pDlg = pEl->GetDlg())
if ((pDlg = pEl->GetDlg()))
if (pDlg->IsShown())
return pDlg;
// no dlg found
@ -843,7 +847,7 @@ bool Screen::MouseInput(int32_t iButton, int32_t iPxX, int32_t iPxY, DWORD dwKey
// non-exclusive mode: process all dialogs; make them active on left-click
Dialog *pDlg;
for (Element *pEl = pLast; pEl; pEl = pEl->GetPrev())
if (pDlg = pEl->GetDlg())
if ((pDlg = pEl->GetDlg()))
if (pDlg->IsShown())
{
// if specified: process specified dlg only
@ -944,7 +948,7 @@ int32_t Screen::GetMouseControlledDialogCount()
{
Dialog *pDlg; int32_t iResult=0;
for (Element *pEl = GetFirst(); pEl; pEl = pEl->GetNext())
if (pDlg = pEl->GetDlg())
if ((pDlg = pEl->GetDlg()))
if (pDlg->IsShown() && pDlg->IsMouseControlled())
++iResult;
return iResult;
@ -982,7 +986,7 @@ Dialog *Screen::GetFullscreenDialog(bool fIncludeFading)
{
Dialog *pDlg;
for (Element *pEl = GetFirst(); pEl; pEl = pEl->GetNext())
if (pDlg = pEl->GetDlg())
if ((pDlg = pEl->GetDlg()))
if (pDlg->IsVisible())
if (pDlg->IsFullscreenDialog())
if (fIncludeFading || !pDlg->IsFading())
@ -1208,6 +1212,6 @@ Resource *Resource::pRes;
Screen *Screen::pScreen;
}; // end of namespace
} // end of namespace
C4GUIScreen *pGUI;

View File

@ -323,13 +323,13 @@ namespace C4GUI {
((pCBClass)->*CBFunc)(par);
}
CallbackHandlerExPar(CB *pTarget, Func rFunc, ParType par) : pCBClass(pTarget), CBFunc(rFunc), par(par) {}
CallbackHandlerExPar(CB *pTarget, Func rFunc, ParType par) : pCBClass(pTarget), par(par), CBFunc(rFunc) {}
};
// callback with parameter coming from calling class
template <class ParType> class BaseParCallbackHandler : public BaseCallbackHandler
{
private:
protected:
virtual void DoCall(class Element *pElement) {assert(false);} // no-par: Not to be called
public:
BaseParCallbackHandler() {}
@ -346,6 +346,11 @@ namespace C4GUI {
CB *pCBClass;
Func CBFunc;
protected:
// not to be called, but avoid warning for hiding base class functions
using BaseParCallbackHandler<ParType>::DoCall;
public:
virtual void DoCall(ParType par) { ((pCBClass)->*CBFunc)(par); }
@ -630,7 +635,7 @@ namespace C4GUI {
};
// icon indices
enum { Ico_Extended = 0x100, }; // icon index offset for extended icons
enum { Ico_Extended = 0x100 }; // icon index offset for extended icons
enum Icons
{
Ico_Empty = -2, // for context menus only
@ -708,7 +713,7 @@ namespace C4GUI {
Ico_Ex_Chat = Ico_Extended + 15,
Ico_Ex_GameList = Ico_Extended + 16,
Ico_Ex_Comment = Ico_Extended + 17,
Ico_Ex_Unregistered = Ico_Extended + 18,
Ico_Ex_Unregistered = Ico_Extended + 18
};
// cute, litte, useless thingy
@ -1123,13 +1128,13 @@ namespace C4GUI {
public:
CallbackButton(ArrowButton::ArrowFct eDir, const C4Rect &rtBounds, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=NULL) // ctor
: Base(eDir, rtBounds, 0), pCallbackFn(pFn), pCB(pCB) { }
: Base(eDir, rtBounds, 0), pCB(pCB), pCallbackFn(pFn) { }
CallbackButton(const char *szBtnText, C4Rect &rtBounds, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=NULL) // ctor
: Base(szBtnText, rtBounds), pCallbackFn(pFn), pCB(pCB) { }
: Base(szBtnText, rtBounds), pCB(pCB), pCallbackFn(pFn) { }
CallbackButton(Icons eUseIcon, const C4Rect &rtBounds, char cHotkey, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=NULL) // ctor
: Base(eUseIcon, rtBounds, cHotkey), pCallbackFn(pFn), pCB(pCB) { }
: Base(eUseIcon, rtBounds, cHotkey), pCB(pCB), pCallbackFn(pFn) { }
CallbackButton(int32_t iID, const C4Rect &rtBounds, char cHotkey, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=NULL) // ctor
: Base(iID, rtBounds, cHotkey), pCallbackFn(pFn), pCB(pCB) { }
: Base(iID, rtBounds, cHotkey), pCB(pCB), pCallbackFn(pFn) { }
};
// a button doing some callback to any class
@ -1163,11 +1168,11 @@ namespace C4GUI {
IR_None=0, // do nothing and continue pasting
IR_CloseDlg, // stop any pastes and close parent dialog successfully
IR_CloseEdit, // stop any pastes and remove this control
IR_Abort, // do nothing and stop any pastes
IR_Abort // do nothing and stop any pastes
};
private:
enum CursorOperation { COP_BACK, COP_DELETE, COP_LEFT, COP_RIGHT, COP_HOME, COP_END, };
enum CursorOperation { COP_BACK, COP_DELETE, COP_LEFT, COP_RIGHT, COP_HOME, COP_END };
bool KeyCursorOp(const C4KeyCodeEx &key, const CursorOperation &op);
bool KeyEnter();
@ -1292,7 +1297,7 @@ namespace C4GUI {
{
RR_Invalid=0, // rename not accepted; continue editing
RR_Accepted, // rename accepted; delete control
RR_Deleted, // control deleted - leave everything
RR_Deleted // control deleted - leave everything
};
public:
@ -1328,7 +1333,7 @@ namespace C4GUI {
public:
CallbackRenameEdit(Label *pForLabel, CallbackDlg *pDlg, const ParType &par, CBOKFunc pCBOKFunc, CBCancelFunc pCBCancelFunc) // ctor
: RenameEdit(pForLabel), pDlg(pDlg), par(par), pCBOKFunc(pCBOKFunc), pCBCancelFunc(pCBCancelFunc) { }
: RenameEdit(pForLabel), pCBCancelFunc(pCBCancelFunc), pCBOKFunc(pCBOKFunc), pDlg(pDlg), par(par) { }
};
// editbox below descriptive label sharing one window for common tooltip
@ -1540,7 +1545,7 @@ namespace C4GUI {
{
tbNone=0, // no tabs
tbTop, // tabs on top
tbLeft, // tabs to the left
tbLeft // tabs to the left
};
private:
@ -1911,7 +1916,7 @@ namespace C4GUI {
void SetComboCB(ComboBox_FillCB *pNewFillCallback);
static int32_t GetDefaultHeight();
void SetText(const char *szToText);
void SetReadOnly(bool fToVal) { if (fReadOnly = fToVal) AbortDropdown(false); }
void SetReadOnly(bool fToVal) { if ((fReadOnly = fToVal)) AbortDropdown(false); }
void SetSimple(bool fToVal) { fSimple = fToVal; }
const StdStrBuf GetText() { return StdStrBuf(Text, false); }
void SetFont(CStdFont *pToFont) { pUseFont=pToFont; }
@ -1927,6 +1932,7 @@ namespace C4GUI {
class DialogWindow : public CStdWindow
{
public:
using CStdWindow::Init;
CStdWindow * Init(CStdApp * pApp, const char * Title, CStdWindow * pParent, const C4Rect &rcBounds, const char *szID);
virtual void Close();
};
@ -2082,7 +2088,7 @@ namespace C4GUI {
void SetTitle(const char *szToTitle, bool fShowCloseButton = true); // change title text; creates or removes title bar if necessary
void SetFrameDeco(FrameDecoration *pNewDeco) // change border decoration
{if (pFrameDeco) pFrameDeco->Deref();
if (pFrameDeco = pNewDeco) pNewDeco->Ref();
if ((pFrameDeco = pNewDeco)) pNewDeco->Ref();
UpdateOwnPos(); // margin may have changed; might need to reposition stuff
}
void ClearFrameDeco() // clear border decoration; no own pos update!
@ -2205,7 +2211,7 @@ namespace C4GUI {
int32_t *piConfigDontShowAgainSetting;
public:
enum Buttons { btnOK=1, btnAbort=2, btnYes=4, btnNo=8, btnRetry=16,
btnOKAbort=btnOK|btnAbort, btnYesNo=btnYes|btnNo, btnRetryAbort=btnRetry|btnAbort, };
btnOKAbort=btnOK|btnAbort, btnYesNo=btnYes|btnNo, btnRetryAbort=btnRetry|btnAbort };
enum DlgSize { dsRegular=C4GUI_MessageDlgWdt, dsMedium=C4GUI_MessageDlgWdtMedium, dsSmall=C4GUI_MessageDlgWdtSmall };
MessageDialog(const char *szMessage, const char *szCaption, DWORD dwButtons, Icons icoIcon, DlgSize eSize=dsRegular, int32_t *piConfigDontShowAgainSetting=NULL, bool fDefaultNo=false);
@ -2463,6 +2469,7 @@ namespace C4GUI {
const C4Rect &GetPreferredDlgRect() { return PreferredDlgRect; }
protected:
using Window::Draw;
virtual void Draw(C4TargetFacet &cgo, bool fDoBG); // draw screen contents
virtual void ElementPosChanged(Element *pOfElement); // called when a dialog is moved
@ -2491,6 +2498,7 @@ namespace C4GUI {
bool KeyAny(); // to be called on keystrokes; resets some tooltip-times
virtual bool CharIn(const char * c); // input: character key pressed - should return false for none-character-inputs
using Window::MouseInput;
bool MouseInput(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam, Dialog *pDlg, class C4Viewport *pVP); // input: mouse movement or buttons; sends MouseEnter/Leave; return whether inside dialog
bool RecheckMouseInput(); // do mouse movement iusing last input flags
@ -2731,7 +2739,7 @@ namespace C4GUI {
// Zoom
inline float GetZoom() { Screen *s=Screen::GetScreenS(); return s ? s->GetZoom() : 1.0f; }
}; // end of namespace
} // end of namespace
typedef C4GUI::Screen C4GUIScreen;
extern C4GUIScreen *pGUI;

View File

@ -239,7 +239,7 @@ void IconButton::DrawElement(C4TargetFacet &cgo)
}
IconButton::IconButton(Icons eUseIcon, const C4Rect &rtBounds, char caHotkey)
: Button("", rtBounds), fHighlight(false), fHasClr(false), dwClr(0u)
: Button("", rtBounds), dwClr(0u), fHasClr(false), fHighlight(false)
{
// ctor
cHotkey = caHotkey;
@ -298,7 +298,7 @@ int32_t ArrowButton::GetDefaultHeight()
// FacetButton
FacetButton::FacetButton(const C4Facet &rBaseFct, const C4Facet &rHighlightFct, const FLOAT_RECT &rtfBounds, char cHotkey)
: Button("", C4Rect(rtfBounds)), fctBase(rBaseFct), fctHighlight(rHighlightFct), rcfDrawBounds(rtfBounds), dwTextClrInact(0x7f000000), dwTextClrAct(0xff000000), pFont(NULL), fFontZoom(1.0f)
: Button("", C4Rect(rtfBounds)), fctBase(rBaseFct), fctHighlight(rHighlightFct), dwTextClrInact(0x7f000000), dwTextClrAct(0xff000000), rcfDrawBounds(rtfBounds), pFont(NULL), fFontZoom(1.0f)
{
// ctor
this->cHotkey = cHotkey;
@ -338,5 +338,5 @@ void FacetButton::DrawElement(C4TargetFacet &cgo)
}
}; // end of namespace
} // end of namespace

View File

@ -140,7 +140,7 @@ void CheckBox::DrawElement(C4TargetFacet &cgo)
void CheckBox::SetOnChecked(BaseCallbackHandler *pCB)
{
if (pCBHandler) pCBHandler->DeRef();
if (pCBHandler = pCB) pCB->Ref();
if ((pCBHandler = pCB)) pCB->Ref();
}
bool CheckBox::GetStandardCheckBoxSize(int *piWdt, int *piHgt, const char *szForCaptionText, CStdFont *pUseFont)
@ -156,4 +156,4 @@ bool CheckBox::GetStandardCheckBoxSize(int *piWdt, int *piHgt, const char *szFor
return true;
}
}; // namespace C4GUI
} // namespace C4GUI

View File

@ -45,7 +45,7 @@ bool ComboBox_FillCB::FindEntry(const char *szText)
{
// check for entry with same name
ContextMenu::Entry *pEntry; int32_t idx=0;
while (pEntry = pDrop->GetIndexedEntry(idx++)) if (SEqual(pEntry->GetText(), szText)) return true;
while ((pEntry = pDrop->GetIndexedEntry(idx++))) if (SEqual(pEntry->GetText(), szText)) return true;
return false;
}
@ -240,4 +240,4 @@ void ComboBox::OnCtxComboSelect(C4GUI::Element *pListItem, const ComboMenuCBStru
// don't do anything else, because this might be deleted
}
}; // namespace C4GUI
} // namespace C4GUI

View File

@ -74,7 +74,7 @@ void Container::ClearChildren()
Element *pANext = pFirst->pNext;
pFirst->pPrev = pFirst->pNext = NULL;
pFirst->pParent = NULL;
if (pFirst = pANext)
if ((pFirst = pANext))
pFirst->pPrev = NULL;
}
else
@ -144,7 +144,7 @@ void Container::InsertElement(Element *pChild, Element *pInsertBefore)
// remove from any previous container
if (pChild->pParent) pChild->pParent->RemoveElement(pChild);
// add before given element
if (pChild->pPrev = pInsertBefore->pPrev)
if ((pChild->pPrev = pInsertBefore->pPrev))
pInsertBefore->pPrev->pNext = pChild;
else
pFirst = pChild;
@ -173,11 +173,11 @@ Element *Container::GetNextNestedElement(Element *pPrevElement, bool fBackwards)
if (!pPrevElement) return this;
// check next nested
Element *pEl;
if (pEl = pPrevElement->GetFirstContained()) return pEl;
if ((pEl = pPrevElement->GetFirstContained())) return pEl;
// check next in list, going upwards until this container is reached
while (pPrevElement && pPrevElement != this)
{
if (pEl = pPrevElement->pNext) return pEl;
if ((pEl = pPrevElement->pNext)) return pEl;
pPrevElement = pPrevElement->pParent;
}
// nothing found
@ -314,7 +314,7 @@ void Window::UpdateOwnPos()
// --------------------------------------------------
// ScrollBar
ScrollBar::ScrollBar(C4Rect &rcBounds, ScrollWindow *pWin) : fAutoHide(false), pCustomGfx(NULL), fHorizontal(false), pScrollCallback(NULL), iCBMaxRange(100)
ScrollBar::ScrollBar(C4Rect &rcBounds, ScrollWindow *pWin) : fAutoHide(false), fHorizontal(false), iCBMaxRange(100), pScrollCallback(NULL), pCustomGfx(NULL)
{
// set bounds
this->rcBounds = rcBounds;
@ -328,12 +328,12 @@ ScrollBar::ScrollBar(C4Rect &rcBounds, ScrollWindow *pWin) : fAutoHide(false), p
Update();
}
ScrollBar::ScrollBar(C4Rect &rcBounds, bool fHorizontal, BaseParCallbackHandler<int32_t> *pCB, int32_t iCBMaxRange) : fAutoHide(false), pCustomGfx(NULL), fHorizontal(fHorizontal), pScrollWindow(NULL), iCBMaxRange(iCBMaxRange)
ScrollBar::ScrollBar(C4Rect &rcBounds, bool fHorizontal, BaseParCallbackHandler<int32_t> *pCB, int32_t iCBMaxRange) : fAutoHide(false), fHorizontal(fHorizontal), iCBMaxRange(iCBMaxRange), pScrollWindow(NULL), pCustomGfx(NULL)
{
// set bounds
this->rcBounds = rcBounds;
// set initial values
if (pScrollCallback = pCB) pScrollCallback->Ref();
if ((pScrollCallback = pCB)) pScrollCallback->Ref();
fScrolling = true;
iScrollThumbSize = fHorizontal ? C4GUI_ScrollThumbWdt : C4GUI_ScrollThumbHgt;
iScrollPos = 0;
@ -353,7 +353,7 @@ void ScrollBar::Update()
{
int32_t iVisHgt = pScrollWindow->GetBounds().Hgt;
int32_t iClientHgt = pScrollWindow->GetClientRect().Hgt;
if (fScrolling = (iVisHgt < iClientHgt))
if ((fScrolling = (iVisHgt < iClientHgt)))
{
// scrolling necessary
// get vertical scroll pos
@ -470,10 +470,12 @@ void ScrollBar::DrawElement(C4TargetFacet &cgo)
DrawVBar(cgo, bar);
// draw scroll pin
if (fScrolling && HasPin())
{
if (fHorizontal)
rUseGfx.fctScrollPin.Draw(cgo.Surface, cgo.TargetX+rcBounds.x+C4GUI_ScrollArrowWdt+iScrollPos, cgo.TargetY+rcBounds.y);
else
rUseGfx.fctScrollPin.Draw(cgo.Surface, cgo.TargetX+rcBounds.x, cgo.TargetY+rcBounds.y+C4GUI_ScrollArrowHgt+iScrollPos);
}
}
@ -746,5 +748,5 @@ void Control::DisableFocus()
pDlg->AdvanceFocus(true);
}
}; // end of namespace
} // end of namespace

View File

@ -126,7 +126,7 @@ void FrameDecoration::Draw(C4TargetFacet &cgo, C4Rect &rcBounds)
// draw borders
int x,y,Q;
// top
if (Q=fctTop.Wdt)
if ((Q=fctTop.Wdt))
{
for (x = iBorderLeft; x < rcBounds.Wdt-iBorderRight; x += fctTop.Wdt)
{
@ -137,7 +137,7 @@ void FrameDecoration::Draw(C4TargetFacet &cgo, C4Rect &rcBounds)
fctTop.Wdt = Q;
}
// left
if (Q=fctLeft.Hgt)
if ((Q=fctLeft.Hgt))
{
for (y = iBorderTop; y < rcBounds.Hgt-iBorderBottom; y += fctLeft.Hgt)
{
@ -148,7 +148,7 @@ void FrameDecoration::Draw(C4TargetFacet &cgo, C4Rect &rcBounds)
fctLeft.Hgt = Q;
}
// right
if (Q=fctRight.Hgt)
if ((Q=fctRight.Hgt))
{
for (y = iBorderTop; y < rcBounds.Hgt-iBorderBottom; y += fctRight.Hgt)
{
@ -159,7 +159,7 @@ void FrameDecoration::Draw(C4TargetFacet &cgo, C4Rect &rcBounds)
fctRight.Hgt = Q;
}
// bottom
if (Q=fctBottom.Wdt)
if ((Q=fctBottom.Wdt))
{
for (x = iBorderLeft; x < rcBounds.Wdt-iBorderRight; x += fctBottom.Wdt)
{
@ -525,7 +525,7 @@ void Dialog::Draw(C4TargetFacet &cgo)
// fade in
if ((iFade+=10) >= 100)
{
if (pScreen = GetScreen())
if ((pScreen = GetScreen()))
{
if (pScreen->GetTopDialog() == this)
pScreen->ActivateDialog(this);
@ -538,7 +538,7 @@ void Dialog::Draw(C4TargetFacet &cgo)
if ((iFade-=10) <= 0)
{
fVisible = fShow = false;
if (pScreen = GetScreen())
if ((pScreen = GetScreen()))
pScreen->RecheckActiveDialog();
eFade = eFadeNone;
}
@ -641,7 +641,7 @@ void Dialog::SetFocus(Control *pCtrl, bool fByMouse)
if (pActiveCtrl) return;
}
// set new
if (pActiveCtrl = pCtrl) pCtrl->OnGetFocus(fByMouse);
if ((pActiveCtrl = pCtrl)) pCtrl->OnGetFocus(fByMouse);
}
void Dialog::AdvanceFocus(bool fBackwards)
@ -911,7 +911,7 @@ void FullscreenDialog::UpdateOwnPos()
Dialog::UpdateOwnPos();
// reposition help button
UpdateHelpButtonPos();
};
}
void FullscreenDialog::UpdateHelpButtonPos()
{
@ -1042,7 +1042,7 @@ MessageDialog::MessageDialog(const char *szMessage, const char *szCaption, DWORD
ConfirmationDialog::ConfirmationDialog(const char *szMessage, const char *szCaption, BaseCallbackHandler *pCB, DWORD dwButtons, bool fSmall, Icons icoIcon)
: MessageDialog(szMessage, szCaption, dwButtons, icoIcon, fSmall ? MessageDialog::dsSmall : MessageDialog::dsRegular)
{
if (this->pCB=pCB) pCB->Ref();
if ((this->pCB=pCB)) pCB->Ref();
// always log confirmation messages
LogSilentF("[Cnf] %s: %s", szCaption, szMessage);
// confirmations always get deleted on close
@ -1179,7 +1179,7 @@ InputDialog::InputDialog(const char *szMessage, const char *szCaption, Icons ico
fChatLayout ? C4GUI::Edit::GetDefaultEditHeight() + 2 :
Max(GetRes()->TextFont.BreakMessage(szMessage, C4GUI_InputDlgWdt - 3 * C4GUI_DefDlgIndent - C4GUI_IconWdt, 0, 0, true),
C4GUI_IconHgt) + C4GUI_InputDlgVRoom, szCaption, false),
pEdit(NULL), pChatLbl(NULL), pCB(pCB), fChatLayout(fChatLayout)
pEdit(NULL), pCB(pCB), fChatLayout(fChatLayout), pChatLbl(NULL)
{
if (fChatLayout)
{
@ -1322,7 +1322,7 @@ void InfoDialog::BeginUpdateText()
iScroll = pTextWin->GetScrollPos();
// clear text window, so new text can be added
pTextWin->ClearText(false);
};
}
void InfoDialog::EndUpdateText()
{
@ -1340,5 +1340,5 @@ void InfoDialog::OnSec1Timer()
UpdateText();
}
}; // end of namespace
} // end of namespace

View File

@ -424,6 +424,7 @@ bool Edit::KeyCursorOp(const C4KeyCodeEx &key, const CursorOperation &op)
{
// evaluate move length? (not home+end)
if (iMoveDir)
{
if (fCtrl)
{
// move one word
@ -448,6 +449,7 @@ bool Edit::KeyCursorOp(const C4KeyCodeEx &key, const CursorOperation &op)
}
}
else iMoveLength = iMoveDir;
}
// delete stuff
if (op == COP_BACK || op == COP_DELETE)
{
@ -654,10 +656,11 @@ void Edit::DrawElement(C4TargetFacet &cgo)
lpDDraw->TextOut("¦", *pFont, 1.5f, cgo.Surface, rcClientRect.x + cgo.TargetX + w - wc - iXScroll, iY0 + cgo.TargetY - h/3, dwFontClr, ALeft, false);
}
// unclip
if (fOwnClip) if (fClip)
lpDDraw->SetPrimaryClipper(cx0,cy0,cx1,cy1);
else
lpDDraw->NoPrimaryClipper();
if (fOwnClip)
{
if (fClip) lpDDraw->SetPrimaryClipper(cx0,cy0,cx1,cy1);
else lpDDraw->NoPrimaryClipper();
}
}
void Edit::SelectAll()
@ -714,7 +717,7 @@ bool Edit::GetCurrentWord(char *szTargetBuf, int32_t iMaxTargetBufLen)
// ----------------------------------------------------
// RenameEdit
RenameEdit::RenameEdit(Label *pLabel) : Edit(pLabel->GetBounds(), true), pForLabel(pLabel), fFinishing(false)
RenameEdit::RenameEdit(Label *pLabel) : Edit(pLabel->GetBounds(), true), fFinishing(false), pForLabel(pLabel)
{
// ctor - construct for label
assert(pForLabel);
@ -856,5 +859,5 @@ bool LabeledEdit::GetControlSize(int *piWdt, int *piHgt, const char *szForText,
return true;
}
}; // end of namespace
} // end of namespace

View File

@ -38,7 +38,7 @@ void Label::DrawElement(C4TargetFacet &cgo)
}
Label::Label(const char *szLblText, int32_t iX0, int32_t iTop, int32_t iAlign, DWORD dwFClr, CStdFont *pFont, bool fMakeReadableOnBlack, bool fMarkup)
: Element(), dwFgClr(dwFClr), x0(iX0), iAlign(iAlign), pFont(pFont), cHotkey(0), pClickFocusControl(NULL), fAutosize(true), fMarkup(fMarkup)
: Element(), dwFgClr(dwFClr), x0(iX0), iAlign(iAlign), pFont(pFont), cHotkey(0), fAutosize(true), fMarkup(fMarkup), pClickFocusControl(NULL)
{
// make color readable
if (fMakeReadableOnBlack) MakeColorReadableOnBlack(dwFgClr);
@ -51,7 +51,7 @@ Label::Label(const char *szLblText, int32_t iX0, int32_t iTop, int32_t iAlign, D
}
Label::Label(const char *szLblText, const C4Rect &rcBounds, int32_t iAlign, DWORD dwFClr, CStdFont *pFont, bool fMakeReadableOnBlack, bool fAutosize, bool fMarkup)
: Element(), dwFgClr(dwFClr), iAlign(iAlign), pFont(pFont), cHotkey(0), pClickFocusControl(NULL), fAutosize(fAutosize), fMarkup(fMarkup)
: Element(), dwFgClr(dwFClr), iAlign(iAlign), pFont(pFont), cHotkey(0), fAutosize(fAutosize), fMarkup(fMarkup), pClickFocusControl(NULL)
{
// make color readable
if (fMakeReadableOnBlack) MakeColorReadableOnBlack(dwFgClr);
@ -217,7 +217,7 @@ void MultilineLabel::DrawElement(C4TargetFacet &cgo)
int32_t iIndex = 0; const char *szLine;
int32_t iY = rcBounds.y + cgo.TargetY;
CStdFont *pLineFont; DWORD dwLineClr; bool fNewParagraph;
while (szLine = Lines.GetLine(iIndex, &pLineFont, &dwLineClr, &fNewParagraph))
while ((szLine = Lines.GetLine(iIndex, &pLineFont, &dwLineClr, &fNewParagraph)))
{
int32_t iFontLineHeight = pLineFont->GetLineHeight();
// indents between paragraphs
@ -247,7 +247,7 @@ void MultilineLabel::UpdateHeight()
// size by line count
int32_t iIndex = 0; const char *szLine; int32_t iHgt = 0;
CStdFont *pLineFont; bool fNewPar;
while (szLine = Lines.GetLine(iIndex, &pLineFont, NULL, &fNewPar))
while ((szLine = Lines.GetLine(iIndex, &pLineFont, NULL, &fNewPar)))
{
int32_t iFontLineHeight = pLineFont->GetLineHeight();
// indents between seperate messages
@ -375,7 +375,7 @@ bool Picture::EnsureOwnSurface()
void Picture::SetAnimated(bool fEnabled, int iDelay)
{
if (fAnimate = fEnabled)
if ((fAnimate = fEnabled))
{
// starts cycling through all phases of the specified facet
iAnimationPhase=iPhaseTime=0;
@ -476,7 +476,7 @@ PaintBox::~PaintBox()
// TextWindow
TextWindow::TextWindow(C4Rect &rtBounds, size_t iPicWdt, size_t iPicHgt, size_t iPicPadding, size_t iMaxLines, size_t iMaxTextLen, const char *szIndentChars, bool fAutoGrow, const C4Facet *pOverlayPic, int iOverlayBorder, bool fMarkup)
: Control(rtBounds), fDrawBackground(true), fDrawFrame(true), iPicPadding(iPicPadding), pLogBuffer(NULL)
: Control(rtBounds), pLogBuffer(NULL), fDrawBackground(true), fDrawFrame(true), iPicPadding(iPicPadding)
{
// calc client rect
UpdateOwnPos();
@ -562,5 +562,5 @@ void TextWindow::SetPicture(const C4Facet &rNewPic)
pTitlePicture->SetVisibility(!!rNewPic.Surface);
}
}; // end of namespace
} // end of namespace

View File

@ -128,7 +128,7 @@ void ListBox::DrawElement(C4TargetFacet &cgo)
// draw delimeter bars
Element *pCurr = pClientWindow->GetFirst();
if (!pCurr) return;
while (pCurr = pCurr->GetNext())
while ((pCurr = pCurr->GetNext()))
if (pCurr->GetListItemTopSpacingBar())
{
int32_t iYSpace = pCurr->GetListItemTopSpacing();
@ -300,13 +300,13 @@ bool ListBox::KeyPageDown()
// start from first item or selected
Element *pNextSelectedItem = pSelectedItem ? pSelectedItem : pClientWindow->GetFirstContained(), *pNext;
if (!pNextSelectedItem) return false;
if (pNext = pNextSelectedItem->GetNext())
if ((pNext = pNextSelectedItem->GetNext()))
{
pNextSelectedItem = pNext;
// if this is not the last, visible item in the list: go down until item is no longer fully in view
if (pClientWindow->IsRangeInView(pNextSelectedItem->GetBounds().y, pNextSelectedItem->GetBounds().Hgt))
{
while (pNext = pNextSelectedItem->GetNext())
while ((pNext = pNextSelectedItem->GetNext()))
if (pClientWindow->IsRangeInView(pNext->GetBounds().y, pNext->GetBounds().Hgt))
pNextSelectedItem = pNext;
else
@ -318,7 +318,7 @@ bool ListBox::KeyPageDown()
pClientWindow->ScrollPages(+1);
pNextSelectedItem = pClientWindow->GetLastContained();
while (!pClientWindow->IsRangeInView(pNextSelectedItem->GetBounds().y, pNextSelectedItem->GetBounds().Hgt))
if (pNext = pNextSelectedItem->GetPrev()) pNextSelectedItem = pNext; else break;
if ((pNext = pNextSelectedItem->GetPrev())) pNextSelectedItem = pNext; else break;
}
}
// selection might have changed
@ -336,13 +336,13 @@ bool ListBox::KeyPageUp()
// start from last item or selected
Element *pNextSelectedItem = pSelectedItem ? pSelectedItem : pClientWindow->GetLastContained(), *pNext;
if (!pNextSelectedItem) return false;
if (pNext = pNextSelectedItem->GetPrev())
if ((pNext = pNextSelectedItem->GetPrev()))
{
pNextSelectedItem = pNext;
// if this is not the first, visible item in the list: go up until item is no longer fully in view
if (pClientWindow->IsRangeInView(pNextSelectedItem->GetBounds().y, pNextSelectedItem->GetBounds().Hgt))
{
while (pNext = pNextSelectedItem->GetPrev())
while ((pNext = pNextSelectedItem->GetPrev()))
if (pClientWindow->IsRangeInView(pNext->GetBounds().y, pNext->GetBounds().Hgt))
pNextSelectedItem = pNext;
else
@ -354,7 +354,7 @@ bool ListBox::KeyPageUp()
pClientWindow->ScrollPages(-1);
pNextSelectedItem = pClientWindow->GetFirstContained();
while (!pClientWindow->IsRangeInView(pNextSelectedItem->GetBounds().y, pNextSelectedItem->GetBounds().Hgt))
if (pNext = pNextSelectedItem->GetNext()) pNextSelectedItem = pNext; else break;
if ((pNext = pNextSelectedItem->GetNext())) pNextSelectedItem = pNext; else break;
}
}
// selection might have changed
@ -424,7 +424,7 @@ void ListBox::UpdateElementPositions()
}
iOverallHgt = pCurr->GetBounds().Hgt;
// others stacked under it
while (pCurr = pCurr->GetNext())
while ((pCurr = pCurr->GetNext()))
{
int32_t iYSpace = pCurr->GetListItemTopSpacing();
int32_t iNewY = iOverallHgt + iYSpace;
@ -629,7 +629,7 @@ class SortCompareElements
ListBox::SortFunction SortFunc;
public:
SortCompareElements(ListBox::SortFunction SortFunc, void *par) : SortFunc(SortFunc), par(par) {}
SortCompareElements(ListBox::SortFunction SortFunc, void *par) : par(par), SortFunc(SortFunc) {}
int operator()(const Element *pEl1, const Element *pEl2)
{ return (*SortFunc)(pEl1, pEl2, par)>0; }
@ -661,5 +661,5 @@ void ListBox::SortElements(SortFunction SortFunc, void *par)
UpdateElementPositions();
}
}; // end of namespace
} // end of namespace

View File

@ -334,7 +334,7 @@ void ContextMenu::UpdateElementPositions()
int32_t iMinWdt = Max<int32_t>(20, pCurr->GetBounds().Wdt);;
int32_t iOverallHgt = pCurr->GetBounds().Hgt;
// others stacked under it
while (pCurr = pCurr->GetNext())
while ((pCurr = pCurr->GetNext()))
{
iMinWdt = Max(iMinWdt, pCurr->GetBounds().Wdt);
int32_t iYSpace = pCurr->GetListItemTopSpacing();
@ -436,7 +436,7 @@ Screen *ContextMenu::GetScreen()
{
// context menus don't have a parent; get screen by static var
return Screen::GetScreenS();
};
}
bool ContextMenu::CtxMouseInput(CMouse &rMouse, int32_t iButton, int32_t iScreenX, int32_t iScreenY, DWORD dwKeyParam)
{
@ -570,7 +570,7 @@ ContextButton::ContextButton(Element *pForEl, bool fAdd, int32_t iHIndent, int32
SetContextHandler(pForEl->GetContextHandler());
// add if desired
Container *pCont;
if (fAdd) if (pCont = pForEl->GetContainer())
if (fAdd) if ((pCont = pForEl->GetContainer()))
pCont->AddElement(this);
RegisterContextKey();
}
@ -657,5 +657,5 @@ void ContextButton::MouseLeave(CMouse &rMouse)
}; // end of namespace
} // end of namespace

View File

@ -172,8 +172,8 @@ bool Tabular::Sheet::IsActiveSheet()
// Tabular
Tabular::Tabular(C4Rect &rtBounds, TabPosition eTabPos) : Control(rtBounds), pActiveSheet(NULL), eTabPos(eTabPos), iMaxTabWidth(0),
pfctBack(NULL), pfctClip(NULL), pfctIcons(NULL), pSheetCaptionFont(NULL), iSheetMargin(4), fDrawSelf(true),
iCaptionLengthTotal(0), iCaptionScrollPos(0), fScrollingLeft(false), fScrollingRight(false), fScrollingLeftDown(false), fScrollingRightDown(false)
iCaptionLengthTotal(0), iCaptionScrollPos(0), fScrollingLeft(false), fScrollingRight(false), fScrollingLeftDown(false),
fScrollingRightDown(false), iSheetMargin(4), fDrawSelf(true), pfctBack(NULL), pfctClip(NULL), pfctIcons(NULL), pSheetCaptionFont(NULL)
{
// calc client rect
UpdateOwnPos();
@ -237,7 +237,11 @@ bool Tabular::KeySelDown()
{
// keyboard callback: Select next sheet
int32_t iNewSel = GetActiveSheetIndex() + 1, iSheetCount = GetSheetCount();
if (iNewSel >= iSheetCount) if (!iSheetCount) return false; else iNewSel = 0;
if (iNewSel >= iSheetCount)
{
if (!iSheetCount) return false;
else iNewSel = 0;
}
SelectSheet(iNewSel, true);
return true;
}
@ -615,7 +619,7 @@ void Tabular::ClearSheets()
{
// del all sheets
Sheet *pSheet;
while (pSheet = GetSheet(0)) delete pSheet;
while ((pSheet = GetSheet(0))) delete pSheet;
SheetsChanged();
}
@ -635,7 +639,7 @@ int32_t Tabular::GetActiveSheetIndex()
{
int32_t i=-1;
Sheet *pSheet;
while (pSheet = GetSheet(++i)) if (pSheet == pActiveSheet) return i;
while ((pSheet = GetSheet(++i))) if (pSheet == pActiveSheet) return i;
return -1;
}
@ -681,5 +685,5 @@ void Tabular::UpdateSize()
}
}; // end of namespace
} // end of namespace

View File

@ -39,7 +39,7 @@ enum C4KeyScope
KEYSCOPE_FullSMenu = 32, // fullscreen menu control. If fullscreen menu is active, this disables viewport controls (e.g. Return to close player join menu)
KEYSCOPE_FilmView = 64, // ownerless viewport scrolling in film mode, player switching, etc. (e.g. Enter to switch to next player)
KEYSCOPE_FreeView = 128, // ownerless viewport scrolling, player switching, etc. (e.g. arrow left to scroll left in view)
KEYSCOPE_FullSView = 256, // player fullscreen viewport
KEYSCOPE_FullSView = 256 // player fullscreen viewport
};
// what can happen to keys
@ -48,7 +48,7 @@ enum C4KeyEventType
KEYEV_None = 0, // no event
KEYEV_Down = 1, // in response to WM_KEYDOWN or joypad button pressed
KEYEV_Up = 2, // in response to WM_KEYUP or joypad button released
KEYEV_Pressed = 3, // in response to WM_KEYPRESSED
KEYEV_Pressed = 3 // in response to WM_KEYPRESSED
};
// keyboard code
@ -186,7 +186,7 @@ enum C4KeyShiftState
KEYS_Control = 2,
KEYS_Shift = 4,
KEYS_Max = KEYS_Shift,
KEYS_Undefined = 0xffff,
KEYS_Undefined = 0xffff
};
// extended key information containing shift state
@ -278,8 +278,8 @@ template <class TargetClass> class C4KeyCB : public C4KeyboardCallbackInterface
case KEYEV_Down: return pFuncDown ? (rTarget.*pFuncDown)() : false;
case KEYEV_Up: return pFuncUp ? (rTarget.*pFuncUp)() : false;
case KEYEV_Pressed: return pFuncPressed ? (rTarget.*pFuncPressed)() : false;
default: return false;
}
return false;
}
virtual bool CheckCondition() { return true; }
@ -308,8 +308,8 @@ template <class TargetClass> class C4KeyCBPassKey : public C4KeyboardCallbackInt
case KEYEV_Down: return pFuncDown ? (rTarget.*pFuncDown)(key) : false;
case KEYEV_Up: return pFuncUp ? (rTarget.*pFuncUp)(key) : false;
case KEYEV_Pressed: return pFuncPressed ? (rTarget.*pFuncPressed)(key) : false;
default: return false;
}
return false;
}
virtual bool CheckCondition() { return true; }
@ -339,8 +339,8 @@ template <class TargetClass, class ParameterType> class C4KeyCBEx : public C4Key
case KEYEV_Down: return pFuncDown ? (rTarget.*pFuncDown)(par) : false;
case KEYEV_Up: return pFuncUp ? (rTarget.*pFuncUp)(par) : false;
case KEYEV_Pressed: return pFuncPressed ? (rTarget.*pFuncPressed)(par) : false;
default: return false;
}
return false;
}
virtual bool CheckCondition() { return true; }
@ -369,8 +369,8 @@ template <class TargetClass, class ParameterType> class C4KeyCBExPassKey : publi
case KEYEV_Down: return pFuncDown ? (rTarget.*pFuncDown)(key, par) : false;
case KEYEV_Up: return pFuncUp ? (rTarget.*pFuncUp)(key, par) : false;
case KEYEV_Pressed: return pFuncPressed ? (rTarget.*pFuncPressed)(key, par) : false;
default: return false;
}
return false;
}
virtual bool CheckCondition() { return true; }
@ -405,7 +405,7 @@ class C4CustomKey
PRIO_FocusCtrl = 5u, // controls override special dialog handling keys (e.g., RenameEdit)
PRIO_Context = 6u, // context menus above controls
PRIO_PlrControl = 7u, // player controls overwrite any other controls
PRIO_MoreThanMax = 100u, // must be larger than otherwise largest used priority
PRIO_MoreThanMax = 100u // must be larger than otherwise largest used priority
};
protected:

View File

@ -57,7 +57,7 @@ bool C4LoaderScreen::Init(const char *szLoaderSpec)
C4Group *pGroup=NULL,*pChosenGrp=NULL;
char ChosenFilename[_MAX_PATH+1];
// query groups of equal priority in set
while (pGroup=Game.GroupSet.FindGroup(C4GSCnt_Loaders, pGroup, true))
while ((pGroup=Game.GroupSet.FindGroup(C4GSCnt_Loaders, pGroup, true)))
{
iLoaders+=SeekLoaderScreens(*pGroup, szLoaderSpecPng, iLoaders, ChosenFilename, &pChosenGrp);
iLoaders+=SeekLoaderScreens(*pGroup, szLoaderSpecJpeg, iLoaders, ChosenFilename, &pChosenGrp);

Some files were not shown because too many files have changed in this diff Show More