Replace NULL by nullptr in C++ sources

We don't support pre-C++0x any more, so nullptr should be fine everywhere (except in the plain C source files)
directional-lights
Sven Eberhardt 2016-11-02 19:58:02 -04:00
parent 54e8c14666
commit ebda8193ef
319 changed files with 3151 additions and 3158 deletions

View File

@ -30,8 +30,8 @@ public:
const char *GetData() const { return Data.getData(); }
const StdStrBuf & GetDataBuf() const { return Data; }
size_t GetDataSize() const { return Data.getLength(); }
bool Load(C4Group &hGroup, const char *szFilename, const char *szLanguage=NULL);
bool Load(C4GroupSet &hGroupSet, const char *szFilename, const char *szLanguage=NULL);
bool Load(C4Group &hGroup, const char *szFilename, const char *szLanguage=nullptr);
bool Load(C4GroupSet &hGroupSet, const char *szFilename, const char *szLanguage=nullptr);
bool GetLanguageString(const char *szLanguage, StdStrBuf &rTarget);
protected:
// The component host's Data has changed. This callback can be used by

View File

@ -42,11 +42,11 @@ const char *C4CFN_FLS[] =
C4CFN_ScenarioSections, C4FLS_Section,
C4CFN_Sound, C4FLS_Sound,
C4CFN_Music, C4FLS_Music,
NULL, NULL
nullptr, nullptr
};
#ifdef _DEBUG
const char *szCurrAccessedEntry = NULL;
const char *szCurrAccessedEntry = nullptr;
int iC4GroupRewindFilePtrNoWarn=0;
#endif
@ -58,8 +58,8 @@ int iC4GroupRewindFilePtrNoWarn=0;
char C4Group_TempPath[_MAX_PATH+1]="";
char C4Group_Ignore[_MAX_PATH+1]="cvs;CVS;Thumbs.db;.orig;.svn";
const char **C4Group_SortList = NULL;
bool (*C4Group_ProcessCallback)(const char *, int)=NULL;
const char **C4Group_SortList = nullptr;
bool (*C4Group_ProcessCallback)(const char *, int)=nullptr;
void C4Group_SetProcessCallback(bool (*fnCallback)(const char *, int))
{
@ -260,7 +260,7 @@ bool C4Group_PackDirectoryTo(const char *szFilename, const char *szFilenameTo)
}
}
// Add normally otherwise
else if (!hGroup.Add(*i, NULL))
else if (!hGroup.Add(*i, nullptr))
break;
}
// Something went wrong?
@ -380,7 +380,7 @@ bool C4Group_ReadFile(const char *szFile, char **pData, size_t *iSize)
// create buffer
*pData = new char [iFileSize];
// read it
if (!MotherGroup.Read(*pData, iFileSize)) { delete [] *pData; *pData = NULL; return false; }
if (!MotherGroup.Read(*pData, iFileSize)) { delete [] *pData; *pData = nullptr; return false; }
// ok
MotherGroup.Close();
if (iSize) *iSize = iFileSize;
@ -435,7 +435,7 @@ C4Group::C4Group()
{
Init();
StdOutput=false;
fnProcessCallback=NULL;
fnProcessCallback=nullptr;
NoSort=false;
}
@ -445,16 +445,16 @@ void C4Group::Init()
Status=GRPF_Inactive;
FileName[0]=0;
// Child status
Mother=NULL;
Mother=nullptr;
ExclusiveChild=false;
// File only
FilePtr=0;
EntryOffset=0;
Modified=false;
InplaceReconstruct(&Head);
FirstEntry=NULL;
SearchPtr=NULL;
pInMemEntry=NULL; iInMemEntrySize=0u;
FirstEntry=nullptr;
SearchPtr=nullptr;
pInMemEntry=nullptr; iInMemEntrySize=0u;
// Folder only
FolderSearch.Clear();
// Error status
@ -603,7 +603,7 @@ bool C4Group::OpenRealGrpFile()
if (!AddEntry(C4GroupEntry::C4GRES_InGroup,!!corebuf.ChildGroup,
corebuf.FileName,corebuf.Size,
entryname.getData(),
NULL, false, false,
nullptr, false, false,
!!corebuf.Executable))
return Error("OpenRealGrpFile: Cannot add entry");
}
@ -699,7 +699,7 @@ bool C4Group::AddEntry(C4GroupEntry::EntryStatus status,
SCopy(fname,nentry->DiskPath,_MAX_FNAME);
nentry->Status=status;
nentry->bpMemBuf=membuf;
nentry->Next=NULL;
nentry->Next=nullptr;
nentry->NoSort = NoSort;
// Append entry to list
@ -714,13 +714,13 @@ bool C4Group::AddEntry(C4GroupEntry::EntryStatus status,
C4GroupEntry* C4Group::GetEntry(const char *szName)
{
if (Status==GRPF_Folder) return NULL;
if (Status==GRPF_Folder) return nullptr;
C4GroupEntry *centry;
for (centry=FirstEntry; centry; centry=centry->Next)
if (centry->Status != C4GroupEntry::C4GRES_Deleted)
if (WildcardMatch(szName,centry->FileName))
return centry;
return NULL;
return nullptr;
}
bool C4Group::Close()
@ -830,7 +830,7 @@ bool C4Group::Save(bool fReOpen)
// Write
StdBuf *pBuf;
tfile.Close(fToMemory ? &pBuf : NULL);
tfile.Close(fToMemory ? &pBuf : nullptr);
// Child: move temp file to mother
if (Mother)
@ -868,9 +868,9 @@ bool C4Group::Save(bool fReOpen)
void C4Group::Default()
{
FirstEntry = NULL;
FirstEntry = nullptr;
StdFile.Default();
Mother = NULL;
Mother = nullptr;
ExclusiveChild = 0;
Init();
}
@ -891,7 +891,7 @@ void C4Group::Clear()
if (Mother && ExclusiveChild)
{
delete Mother;
Mother=NULL;
Mother=nullptr;
}
// Reset
Init();
@ -992,7 +992,7 @@ void C4Group::ResetSearch(bool reload_contents)
switch (Status)
{
case GRPF_Folder:
SearchPtr=NULL;
SearchPtr=nullptr;
FolderSearch.Reset(FileName, reload_contents);
if (*FolderSearch)
{
@ -1016,7 +1016,7 @@ C4GroupEntry* C4Group::GetNextFolderEntry()
}
else
{
return NULL;
return nullptr;
}
}
@ -1055,8 +1055,8 @@ C4GroupEntry* C4Group::SearchNextEntry(const char *szName)
default: break; // InGrp & Deleted ignored
}
// No entry found: reset search pointer
SearchPtr=NULL;
return NULL;
SearchPtr=nullptr;
return nullptr;
}
bool C4Group::SetFilePtr(int iOffset)
@ -1177,7 +1177,7 @@ bool C4Group::RewindFilePtr()
if (szCurrAccessedEntry && !iC4GroupRewindFilePtrNoWarn)
{
LogF("C4Group::RewindFilePtr() for %s (%s) after %s", szCurrAccessedEntry ? szCurrAccessedEntry : "???", FileName, sPrevAccessedEntry.getLength() ? sPrevAccessedEntry.getData() : "???");
szCurrAccessedEntry=NULL;
szCurrAccessedEntry=nullptr;
}
#endif
@ -1228,7 +1228,7 @@ bool C4Group::Merge(const char *szFolders)
if (fnProcessCallback)
fnProcessCallback(GetFilename(*i),0); // cbytes/tbytes
// AddEntryOnDisk
AddEntryOnDisk(*i, NULL, fMove);
AddEntryOnDisk(*i, nullptr, fMove);
++i;
}
}
@ -1283,7 +1283,7 @@ bool C4Group::AddEntryOnDisk(const char *szFilename,
szFilename,
iSize,
szAddAs,
NULL,
nullptr,
fMove,
false,
fExecutable);
@ -1611,7 +1611,7 @@ bool C4Group::OpenAsChild(C4Group *pMother,
// Access entry in mother group
size_t iSize;
if ((!Mother->AccessEntry(FileName, &iSize, NULL, true)))
if ((!Mother->AccessEntry(FileName, &iSize, nullptr, true)))
{
if (!fCreate)
{ CloseExclusiveMother(); Clear(); return Error("OpenAsChild: Entry not in mother group"); }
@ -1653,7 +1653,7 @@ bool C4Group::OpenAsChild(C4Group *pMother,
EntryOffset+=sizeof(C4GroupEntryCore);
if (!AddEntry(C4GroupEntry::C4GRES_InGroup, !!corebuf.ChildGroup,
corebuf.FileName,corebuf.Size,
NULL, NULL, false, false,
nullptr, nullptr, false, false,
!!corebuf.Executable))
{ CloseExclusiveMother(); Clear(); return Error("OpenAsChild: Insufficient memory"); }
}
@ -1685,7 +1685,7 @@ bool C4Group::AccessEntry(const char *szWildCard,
bool fResult = SetFilePtr2Entry(fname.getData(), NeedsToBeAGroup);
#ifdef _DEBUG
sPrevAccessedEntry.Copy(szCurrAccessedEntry);
szCurrAccessedEntry = NULL;
szCurrAccessedEntry = nullptr;
#endif
if (!fResult) return false;
if (sFileName) SCopy(fname.getData(),sFileName);
@ -1704,7 +1704,7 @@ bool C4Group::AccessNextEntry(const char *szWildCard,
#endif
bool fResult = SetFilePtr2Entry(fname);
#ifdef _DEBUG
szCurrAccessedEntry = NULL;
szCurrAccessedEntry = nullptr;
#endif
if (!fResult) return false;
if (sFileName) SCopy(fname,sFileName);
@ -1724,7 +1724,7 @@ bool C4Group::SetFilePtr2Entry(const char *szName, bool NeedsToBeAGroup)
}
else
{
pInMemEntry = NULL;
pInMemEntry = nullptr;
}
// Not cached. Access from disk.
@ -1868,12 +1868,12 @@ bool C4Group::LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSize,
size_t size;
// Access entry, allocate buffer, read data
(*lpbpBuf)=NULL; if (ipSize) *ipSize=0;
(*lpbpBuf)=nullptr; if (ipSize) *ipSize=0;
if (!AccessEntry(szEntryName,&size)) return Error("LoadEntry: Not found");
*lpbpBuf = new char[size+iAppendZeros];
if (!Read(*lpbpBuf,size))
{
delete [] (*lpbpBuf); *lpbpBuf = NULL;
delete [] (*lpbpBuf); *lpbpBuf = nullptr;
return Error("LoadEntry: Reading error");
}
@ -1946,7 +1946,7 @@ bool C4Group::Sort(const char *szSortList)
{
fBubble=false;
for (prev=NULL,centry=FirstEntry; centry; prev=centry,centry=next)
for (prev=nullptr,centry=FirstEntry; centry; prev=centry,centry=next)
if ((next=centry->Next))
{
// primary sort by file list
@ -1985,7 +1985,7 @@ bool C4Group::CloseExclusiveMother()
{
Mother->Close();
delete Mother;
Mother=NULL;
Mother=nullptr;
return true;
}
return false;
@ -2092,7 +2092,7 @@ uint32_t C4Group::CalcCRC32(C4GroupEntry *pEntry)
CRC = 0;
else
{
BYTE *pData = NULL; bool fOwnData; CStdFile f;
BYTE *pData = nullptr; bool fOwnData; CStdFile f;
// get data
switch (pEntry->Status)
{

View File

@ -187,28 +187,28 @@ public:
bool Add(const char *szName, StdStrBuf &pBuffer, bool fChild = false, bool fHoldBuffer = false, bool fExecutable = false);
bool Merge(const char *szFolders);
bool Move(const char *szFile, const char *szAddAs);
bool Extract(const char *szFiles, const char *szExtractTo=NULL, const char *szExclude=NULL);
bool ExtractEntry(const char *szFilename, const char *szExtractTo=NULL);
bool Extract(const char *szFiles, const char *szExtractTo=nullptr, const char *szExclude=nullptr);
bool ExtractEntry(const char *szFilename, const char *szExtractTo=nullptr);
bool Delete(const char *szFiles, bool fRecursive = false);
bool DeleteEntry(const char *szFilename, bool fRecycle=false);
bool Rename(const char *szFile, const char *szNewName);
bool Sort(const char *szSortList);
bool SortByList(const char **ppSortList, const char *szFilename=NULL);
bool SortByList(const char **ppSortList, const char *szFilename=nullptr);
bool AccessEntry(const char *szWildCard,
size_t *iSize=NULL, char *sFileName=NULL,
size_t *iSize=nullptr, char *sFileName=nullptr,
bool NeedsToBeAGroup = false);
bool AccessNextEntry(const char *szWildCard,
size_t *iSize=NULL, char *sFileName=NULL,
size_t *iSize=nullptr, char *sFileName=nullptr,
bool fStartAtFilename=false);
bool LoadEntry(const char *szEntryName, char **lpbpBuf,
size_t *ipSize=NULL, int iAppendZeros=0);
size_t *ipSize=nullptr, int iAppendZeros=0);
bool LoadEntry(const char *szEntryName, StdBuf * Buf);
bool LoadEntry(const StdStrBuf & name, StdBuf * Buf) { return LoadEntry(name.getData(), Buf); }
bool LoadEntryString(const char *szEntryName, StdStrBuf * Buf);
bool LoadEntryString(const StdStrBuf & name, StdStrBuf * Buf) { return LoadEntryString(name.getData(), Buf); }
bool FindEntry(const char *szWildCard,
StdStrBuf *sFileName=NULL,
size_t *iSize=NULL);
StdStrBuf *sFileName=nullptr,
size_t *iSize=nullptr);
bool FindEntry(const char *szWildCard,
char *sFileName)
{
@ -218,12 +218,12 @@ public:
return r;
}
bool FindNextEntry(const char *szWildCard,
StdStrBuf *sFileName=NULL,
size_t *iSize=NULL,
StdStrBuf *sFileName=nullptr,
size_t *iSize=nullptr,
bool fStartAtFilename=false);
bool FindNextEntry(const char *szWildCard,
char *sFileName,
size_t *iSize=NULL,
size_t *iSize=nullptr,
bool fStartAtFilename=false)
{
StdStrBuf name(fStartAtFilename ? sFileName : "");
@ -238,10 +238,10 @@ public:
const char *GetError();
const char *GetName();
StdStrBuf GetFullName() const;
int EntryCount(const char *szWildCard=NULL);
size_t EntrySize(const char *szWildCard=NULL);
int EntryCount(const char *szWildCard=nullptr);
size_t EntrySize(const char *szWildCard=nullptr);
size_t AccessedEntrySize() { return iCurrFileSize; } // retrieve size of last accessed entry
unsigned int EntryCRC32(const char *szWildCard=NULL);
unsigned int EntryCRC32(const char *szWildCard=nullptr);
inline bool IsOpen() { return Status != GRPF_Inactive; }
C4Group *GetMother();
inline bool IsPacked() { return Status == GRPF_File; }
@ -264,18 +264,18 @@ protected:
bool OpenRealGrpFile();
bool SetFilePtr(int iOffset);
bool RewindFilePtr();
bool AdvanceFilePtr(int iOffset, C4Group *pByChild=NULL);
bool AdvanceFilePtr(int iOffset, C4Group *pByChild=nullptr);
bool AddEntry(C4GroupEntry::EntryStatus status,
bool childgroup,
const char *fname,
long size,
const char *entryname = NULL,
BYTE *membuf = NULL,
const char *entryname = nullptr,
BYTE *membuf = nullptr,
bool fDeleteOnDisk = false,
bool fHoldBuffer = false,
bool fExecutable = false,
bool fBufferIsStdbuf = false);
bool AddEntryOnDisk(const char *szFilename, const char *szAddAs=NULL, bool fMove=false);
bool AddEntryOnDisk(const char *szFilename, const char *szAddAs=nullptr, bool fMove=false);
bool SetFilePtr2Entry(const char *szName, bool NeedsToBeAGroup = false);
bool AppendEntry2StdFile(C4GroupEntry *centry, CStdFile &stdfile);
C4GroupEntry *GetEntry(const char *szName);

View File

@ -43,7 +43,7 @@ bool EraseItemSafe(const char *szFilename)
return false;
}
void DisplayGroup(const C4Group &grp, const char *filter = NULL)
void DisplayGroup(const C4Group &grp, const char *filter = nullptr)
{
const C4GroupHeader &head = grp.GetHeader();
@ -58,18 +58,18 @@ void DisplayGroup(const C4Group &grp, const char *filter = NULL)
// Find maximum file name length (matching filter)
size_t max_fn_len = 0;
for (const C4GroupEntry *entry = grp.GetFirstEntry(); entry != NULL; entry = entry->Next)
for (const C4GroupEntry *entry = grp.GetFirstEntry(); entry != nullptr; entry = entry->Next)
{
if (filter == NULL || WildcardMatch(filter, entry->FileName))
if (filter == nullptr || WildcardMatch(filter, entry->FileName))
max_fn_len = std::max(max_fn_len, strlen(entry->FileName));
}
// List files
size_t file_count = 0;
size_t byte_count = 0;
for (const C4GroupEntry *entry = grp.GetFirstEntry(); entry != NULL; entry = entry->Next)
for (const C4GroupEntry *entry = grp.GetFirstEntry(); entry != nullptr; entry = entry->Next)
{
if (filter != NULL && !WildcardMatch(filter, entry->FileName))
if (filter != nullptr && !WildcardMatch(filter, entry->FileName))
continue;
printf("%*s %8u Bytes",
@ -153,7 +153,7 @@ bool ProcessGroup(const char *FilenamePar)
// Sort
case 's':
// First sort parameter overrides default Clonk sort list
C4Group_SetSortList(NULL);
C4Group_SetSortList(nullptr);
// Missing argument
if ((iArg + 1 >= argc) || (argv[iArg + 1][0] == '-'))
{
@ -308,7 +308,7 @@ bool ProcessGroup(const char *FilenamePar)
if(iArg + 1 < argc)
{
errno = 0;
pid = strtoul(argv[iArg+1], NULL, 10);
pid = strtoul(argv[iArg+1], nullptr, 10);
if(errno == 0)
have_pid = true;
else
@ -373,7 +373,7 @@ int RegisterShellExtensions()
wchar_t strCommand[2048+1];
char strClass[128];
int i;
GetModuleFileNameW(NULL, strModule, 2048);
GetModuleFileNameW(nullptr, strModule, 2048);
// Groups
const char *strClasses =
"Clonk4.Definition;Clonk4.Folder;Clonk4.Group;Clonk4.Player;Clonk4.Scenario;Clonk4.Update;Clonk4.Weblink";
@ -436,7 +436,7 @@ int main(int argc, char *argv[])
{
#ifndef WIN32
// Always line buffer mode, even if the output is not sent to a terminal
setvbuf(stdout, NULL, _IOLBF, 0);
setvbuf(stdout, nullptr, _IOLBF, 0);
#endif
// Scan options
fQuiet = true;
@ -559,7 +559,7 @@ int main(int argc, char *argv[])
PROCESS_INFORMATION procInfo;
CreateProcessW(GetWideChar(strExecuteAtEnd), NULL, NULL, NULL, false, 0, NULL, NULL, &startInfo, &procInfo);
CreateProcessW(GetWideChar(strExecuteAtEnd), nullptr, nullptr, nullptr, false, 0, nullptr, nullptr, &startInfo, &procInfo);
#else
switch (fork())
{

View File

@ -53,13 +53,13 @@ void C4GroupSet::Clear()
{
// clear nodes
while (pFirst) delete pFirst;
pFirst = NULL;
pFirst = nullptr;
}
void C4GroupSet::Default()
{
// zero fields
pFirst=pLast=NULL;
pFirst=pLast=nullptr;
// do not reset index here, because group set IDs are meant to be unique
// for each instance of the engine
// see also C4GraphicsResource::RegisterGlobalGraphics
@ -168,10 +168,10 @@ C4Group *C4GroupSet::FindGroup(int32_t Contents, C4Group *pAfter, bool fSamePrio
// success, found an entry
return pNode->pGroup;
// find next clear flag
if (pNode->pGroup == pAfter) { pAfter=NULL; if (fSamePrio) iPriority=pNode->Priority; }
if (pNode->pGroup == pAfter) { pAfter=nullptr; if (fSamePrio) iPriority=pNode->Priority; }
}
// nothing found
return NULL;
return nullptr;
}
C4Group *C4GroupSet::FindEntry(const char *szWildcard, int32_t *pPriority, int32_t *pID)
@ -187,7 +187,7 @@ C4Group *C4GroupSet::FindEntry(const char *szWildcard, int32_t *pPriority, int32
return pNode->pGroup;
}
// nothing found
return NULL;
return nullptr;
}
C4Group *C4GroupSet::FindSuitableFile(const char *szName, const char * const extensions[], char *szFileName, int32_t *pID)
@ -262,7 +262,7 @@ C4Group* C4GroupSet::GetGroup(int32_t iIndex)
{
// Invalid index
if (iIndex < 0)
return NULL;
return nullptr;
// Find indicated group
for (C4GroupSetNode *pNode = pFirst; pNode; pNode = pNode->pNext)
if (iIndex == 0)
@ -270,7 +270,7 @@ C4Group* C4GroupSet::GetGroup(int32_t iIndex)
else
iIndex--;
// Indicated group not found
return NULL;
return nullptr;
}
bool C4GroupSet::UnregisterGroup(int32_t iIndex)
@ -296,7 +296,7 @@ bool C4GroupSet::UnregisterGroup(int32_t iIndex)
C4Group *C4GroupSet::RegisterParentFolders(const char *szScenFilename)
{
// the scenario filename may be a scenario or directly a group folder
C4Group *pParentGroup=NULL; bool fParentC4F;
C4Group *pParentGroup=nullptr; bool fParentC4F;
char szParentfolder[_MAX_PATH+1];
if (SEqualNoCase(GetExtension(szScenFilename), "ocf"))
{
@ -349,13 +349,13 @@ C4Group *C4GroupSet::RegisterParentFolders(const char *szScenFilename)
if (!pGroup->OpenAsChild(pParentGroup, szParentfolder+iPos))
{
LogFatal(FormatString("%s: %s", LoadResStr("IDS_PRC_FILENOTFOUND"), szParentfolder+iPos).getData());
delete pGroup; return NULL;
delete pGroup; return nullptr;
}
}
else if (!Reloc.Open(*pGroup, szParentfolder+iPos))
{
LogFatal(FormatString("%s: %s", LoadResStr("IDS_PRC_FILENOTFOUND"), szParentfolder+iPos).getData());
delete pGroup; return NULL;
delete pGroup; return nullptr;
}
// set this group as new parent
pParentGroup=pGroup;
@ -366,7 +366,7 @@ C4Group *C4GroupSet::RegisterParentFolders(const char *szScenFilename)
else
iContentsMask = C4GSCnt_Directory;
if (!RegisterGroup(*pParentGroup, true, C4GSPrio_Folder+iGroupIndex++, iContentsMask))
{ delete pParentGroup; LogFatal ("RegGrp: internal error"); return NULL; }
{ delete pParentGroup; LogFatal ("RegGrp: internal error"); return nullptr; }
// advance by file name length
iPos+=SLen(szParentfolder+iPos);
}

View File

@ -89,13 +89,13 @@ public:
~C4GroupSet(); // dtor
bool RegisterGroup(C4Group &rGroup, bool fOwnGrp, int32_t Priority, int32_t Contents, bool fCheckContent=true); // add group to list
bool RegisterGroups(const C4GroupSet &rCopy, int32_t Contents, const char *szFilename=NULL, int32_t iMaxSkipID=0); // add all matching (child-)groups of the set
C4Group *FindGroup(int32_t Contents, C4Group *pAfter=NULL, bool fSamePrio=false); // search for suitable group in list
C4Group *FindEntry(const char *szWildcard, int32_t *pPriority=NULL, int32_t *pID=NULL); // find entry in groups; store priority of group if ptr is given
C4Group *FindSuitableFile(const char *szName, const char * const extensions[], char *szFileName, int32_t *pID=NULL);
bool RegisterGroups(const C4GroupSet &rCopy, int32_t Contents, const char *szFilename=nullptr, int32_t iMaxSkipID=0); // add all matching (child-)groups of the set
C4Group *FindGroup(int32_t Contents, C4Group *pAfter=nullptr, bool fSamePrio=false); // search for suitable group in list
C4Group *FindEntry(const char *szWildcard, int32_t *pPriority=nullptr, int32_t *pID=nullptr); // find entry in groups; store priority of group if ptr is given
C4Group *FindSuitableFile(const char *szName, const char * const extensions[], char *szFileName, int32_t *pID=nullptr);
int32_t GetGroupCount();
C4Group *GetGroup(int32_t iIndex);
bool LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSize=NULL, int32_t iAppendZeros=0);
bool LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSize=nullptr, int32_t iAppendZeros=0);
bool LoadEntryString(const char *szEntryName, StdStrBuf * rBuf);
bool LoadEntryString(const StdStrBuf & name, StdStrBuf * Buf) { return LoadEntryString(name.getData(), Buf); }
C4Group *RegisterParentFolders(const char *szScenFilename); // register all parent .ocf groups to the given scenario filename and return an open group file of the innermost parent ocf

View File

@ -104,7 +104,7 @@ void C4LangStringTable::ReplaceStrings(const StdStrBuf &rBuf, StdStrBuf &rTarget
// Find Replace Positions
int iScriptLen = SLen(Data);
struct RP { const char *Pos; std::string String; unsigned int Len; RP *Next; } *pRPList = NULL, *pRPListEnd = NULL;
struct RP { const char *Pos; std::string String; unsigned int Len; RP *Next; } *pRPList = nullptr, *pRPListEnd = nullptr;
for (const char *pPos = SSearch(Data, "$"); pPos; pPos = SSearch(pPos, "$"))
{
// Get name
@ -127,7 +127,7 @@ void C4LangStringTable::ReplaceStrings(const StdStrBuf &rBuf, StdStrBuf &rTarget
pnRP->Pos = pPos - SLen(szStringName) - 2;
pnRP->String = pStrTblEntry;
pnRP->Len = SLen(szStringName) + 2;
pnRP->Next = NULL;
pnRP->Next = nullptr;
pRPListEnd = (pRPListEnd ? pRPListEnd->Next : pRPList) = pnRP;
// calculate new script length
iScriptLen += pStrTblEntry.size() - pnRP->Len;

View File

@ -35,7 +35,7 @@ C4Language Languages;
C4Language::C4Language()
{
Infos = NULL;
Infos = nullptr;
PackGroupLocation[0] = 0;
}
@ -119,7 +119,7 @@ void C4Language::Clear()
delete Infos;
Infos = pNext;
}
Infos = NULL;
Infos = nullptr;
}
int C4Language::GetPackCount()
@ -339,7 +339,7 @@ C4LanguageInfo* C4Language::GetInfo(int iIndex)
return pInfo;
else
iIndex--;
return NULL;
return nullptr;
}
C4LanguageInfo* C4Language::FindInfo(const char *strCode)
@ -347,7 +347,7 @@ C4LanguageInfo* C4Language::FindInfo(const char *strCode)
for (C4LanguageInfo *pInfo = Infos; pInfo; pInfo = pInfo->Next)
if (SEqualNoCase(pInfo->Code, strCode, 2))
return pInfo;
return NULL;
return nullptr;
}
bool C4Language::LoadLanguage(const char *strLanguages)

View File

@ -528,7 +528,7 @@ bool C4UpdatePackage::DoGrpUpdate(C4Group *pUpdateData, C4GroupEx *pGrpTo)
{
char *pData;
// sort entries
if (pUpdateData->LoadEntry(C4CFN_UpdateEntries, &pData, NULL, 1))
if (pUpdateData->LoadEntry(C4CFN_UpdateEntries, &pData, nullptr, 1))
{
// delete all entries that do not appear in the entries list
char strItemName[_MAX_FNAME+1], strItemName2[_MAX_FNAME+1];
@ -693,7 +693,7 @@ extern char C4Group_TempPath[_MAX_PATH+1];
bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bool *fModified)
{
// (CAUTION: pGrp1 may be NULL - that means that there is no counterpart for Grp2
// (CAUTION: pGrp1 may be nullptr - that means that there is no counterpart for Grp2
// in the base group)
// compare headers
@ -706,7 +706,7 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
strItemName[0] = strItemName2[0] = 0;
pGrp2->ResetSearch(); if (!*fModified) pGrp1->ResetSearch();
int iChangedEntries = 0;
while (pGrp2->FindNextEntry("*", strItemName, NULL, !! strItemName[0]))
while (pGrp2->FindNextEntry("*", strItemName, nullptr, !! strItemName[0]))
{
// add to entry list
if (!!EntryList) EntryList.AppendChar('|');
@ -714,7 +714,7 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
// no modification detected yet? then check order
if (!*fModified)
{
if (!pGrp1->FindNextEntry("*", strItemName2, NULL, !! strItemName2[0]))
if (!pGrp1->FindNextEntry("*", strItemName2, nullptr, !! strItemName2[0]))
*fModified = true;
else if (!SEqual(strItemName, strItemName2))
*fModified = true;
@ -729,7 +729,7 @@ bool C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp, bo
// open in Grp1
C4Group *pChildGrp1 = new C4GroupEx();
if (!pGrp1 || !pChildGrp1->OpenAsChild(pGrp1, strItemName))
{ delete pChildGrp1; pChildGrp1 = NULL; }
{ delete pChildGrp1; pChildGrp1 = nullptr; }
// open group for update data
C4GroupEx UpdGroup; char strTempGroupName[_MAX_FNAME + 1];
strTempGroupName[0] = 0;

View File

@ -52,7 +52,7 @@ public:
bool Execute(C4Group *pGroup);
static bool Optimize(C4Group *pGrpFrom, const char *strTarget);
int Check(C4Group *pGroup);
bool MakeUpdate(const char *strFile1, const char *strFile2, const char *strUpdateFile, const char *strName = NULL);
bool MakeUpdate(const char *strFile1, const char *strFile2, const char *strUpdateFile, const char *strName = nullptr);
protected:
bool DoUpdate(C4Group *pGrpFrom, class C4GroupEx *pGrpTo, const char *strFileName);

View File

@ -37,9 +37,9 @@ CStdFile::CStdFile()
{
thread_check.Set();
Status=false;
hFile=NULL;
hgzFile=NULL;
pMemory=NULL;
hFile=nullptr;
hgzFile=nullptr;
pMemory=nullptr;
ClearBuffer();
ModeWrite=false;
Name[0]=0;
@ -118,7 +118,7 @@ bool CStdFile::Open(const char *szFilename, bool fCompressed)
if(c4_gzdirect(hgzFile))
{
c4_gzclose(hgzFile);
hgzFile = NULL;
hgzFile = nullptr;
return false;
}
}
@ -166,12 +166,12 @@ bool CStdFile::Close(StdBuf **ppMemory)
if (pMemory)
{
if (ppMemory)
{ *ppMemory = pMemory; pMemory = NULL; }
{ *ppMemory = pMemory; pMemory = nullptr; }
else
delete pMemory;
}
MemoryPtr=0;
hgzFile=NULL; hFile=NULL;
hgzFile=nullptr; hFile=nullptr;
return !!rval;
}
@ -179,9 +179,9 @@ bool CStdFile::Default()
{
Status=false;
Name[0]=0;
hgzFile=NULL;
hFile=NULL;
pMemory=NULL;
hgzFile=nullptr;
hFile=nullptr;
pMemory=nullptr;
MemoryPtr=0;
BufferLoad=BufferPtr=0;
thread_check.Set();

View File

@ -56,7 +56,7 @@ public:
bool Create(const char *szFileName, bool fCompressed=false, bool fExecutable=false, bool fMemory=false);
bool Open(const char *szFileName, bool fCompressed=false);
bool Append(const char *szFilename, bool text=false); // append (uncompressed only)
bool Close(StdBuf **ppMemory = NULL);
bool Close(StdBuf **ppMemory = nullptr);
bool Default();
bool Read(void *pBuffer, size_t iSize) { return Read(pBuffer, iSize, 0); }
bool Read(void *pBuffer, size_t iSize, size_t *ipFSize);

View File

@ -411,7 +411,7 @@ bool C4Config::Save()
#endif
{
StdStrBuf filename;
GetConfigFileName(filename, ConfigFilename.getLength() ? ConfigFilename.getData() : NULL);
GetConfigFileName(filename, ConfigFilename.getLength() ? ConfigFilename.getData() : nullptr);
StdCompilerINIWrite IniWrite;
IniWrite.Decompile(*this);
IniWrite.getOutput().SaveToFile(filename.getData());
@ -431,7 +431,7 @@ void C4ConfigGeneral::DeterminePaths()
#ifdef _WIN32
// Exe path
wchar_t apath[CFG_MaxString];
if (GetModuleFileNameW(NULL,apath,CFG_MaxString))
if (GetModuleFileNameW(nullptr,apath,CFG_MaxString))
{
ExePath = StdStrBuf(apath);
TruncatePath(ExePath.getMData());

View File

@ -267,7 +267,7 @@ public:
const char* GetSubkeyPath(const char *strSubkey);
void Default();
bool Save();
bool Load(const char *szConfigFile = NULL);
bool Load(const char *szConfigFile = nullptr);
bool Init();
bool Registered();
const char *AtExePath(const char *szFilename);

View File

@ -236,7 +236,7 @@ void C4ControlScript::Execute() const
if (!Game.Parameters.AllowDebug) return;
// execute
C4PropList *pPropList = NULL;
C4PropList *pPropList = nullptr;
if (iTargetObj == SCOPE_Console)
pPropList = ::GameScript.ScenPropList.getPropList();
else if (iTargetObj == SCOPE_Global)
@ -244,7 +244,7 @@ void C4ControlScript::Execute() const
else if (!(pPropList = ::Objects.SafeObjectPointer(iTargetObj)))
// default: Fallback to global context
pPropList = ::ScriptEngine.GetPropList();
C4Value rVal(AulExec.DirectExec(pPropList, szScript, "console script", false, fUseVarsFromCallerContext ? AulExec.GetContext(AulExec.GetContextDepth()-1) : NULL));
C4Value rVal(AulExec.DirectExec(pPropList, szScript, "console script", false, fUseVarsFromCallerContext ? AulExec.GetContext(AulExec.GetContextDepth()-1) : nullptr));
#ifndef NOAULDEBUG
C4AulDebug* pDebug;
if ( (pDebug = C4AulDebug::GetDebugger()) )
@ -259,7 +259,7 @@ void C4ControlScript::Execute() const
bool is_local_script = true;
if (!LocalControl())
{
C4Network2Client *pClient = NULL;
C4Network2Client *pClient = nullptr;
if (::Network.isEnabled())
{
pClient = ::Network.Clients.GetClientByID(iByClient);
@ -419,7 +419,7 @@ void C4ControlPlayerSelect::CompileFunc(StdCompiler *pComp)
void C4ControlPlayerControl::Execute() const
{
C4PlayerControl *pTargetCtrl = NULL;
C4PlayerControl *pTargetCtrl = nullptr;
if (iPlr == -1)
{
// neutral control packet: Execute in global control
@ -740,7 +740,7 @@ void C4ControlPlayerAction::CompileFunc(StdCompiler *pComp)
{ "SetTeam", CPA_SetTeam },
{ "InitScenarioPlayer", CPA_InitScenarioPlayer },
{ "InitPlayerControl", CPA_InitPlayerControl },
{ NULL, CPA_NoAction }
{ nullptr, CPA_NoAction }
};
pComp->Value(mkNamingAdapt(mkEnumAdapt<Action, int32_t>(action, ActionNames), "Action", CPA_NoAction));
pComp->Value(mkNamingAdapt(target, "Target", NO_OWNER));
@ -1097,7 +1097,7 @@ void C4ControlJoinPlayer::Execute() const
else if (pInfo->GetType() == C4PT_Script)
{
// script players may join without data
Game.JoinPlayer(NULL, iAtClient, pClient->getName(), pInfo);
Game.JoinPlayer(nullptr, iAtClient, pClient->getName(), pInfo);
}
else
{
@ -1149,7 +1149,7 @@ void C4ControlJoinPlayer::Strip()
{ EraseFile(PlayerFilename.getData()); return; }
// remove bigicon, if the file size is too large
size_t iBigIconSize=0;
if (Grp.FindEntry(C4CFN_BigIcon, NULL, &iBigIconSize))
if (Grp.FindEntry(C4CFN_BigIcon, nullptr, &iBigIconSize))
if (iBigIconSize > C4NetResMaxBigicon*1024)
Grp.Delete(C4CFN_BigIcon);
Grp.Close();
@ -1239,7 +1239,7 @@ C4ControlEMMoveObject *C4ControlEMMoveObject::CreateObject(const C4ID &id, C4Rea
C4ControlEMMoveObject::~C4ControlEMMoveObject()
{
delete [] pObjects; pObjects = NULL;
delete [] pObjects; pObjects = nullptr;
}
void C4ControlEMMoveObject::MoveObject(C4Object *moved_object, bool move_forced) const
@ -1277,7 +1277,7 @@ void C4ControlEMMoveObject::Execute() const
{
pObj = pObj->Action.Target;
if (!pObj) break; // leftover action cancelled next frame
for (int j = 0; j < iObjectNum; ++j) if (pObjects[j] == pObj->Number) { pObj = NULL; break; } // ensure we aren't moving twice
for (int j = 0; j < iObjectNum; ++j) if (pObjects[j] == pObj->Number) { pObj = nullptr; break; } // ensure we aren't moving twice
if (!pObj) break;
MoveObject(pObj, eAction==EMMO_MoveForced);
}
@ -1354,7 +1354,7 @@ void C4ControlEMMoveObject::Execute() const
}
// Create object outside or contained
// If container is desired but not valid, do nothing (don't create object outside instead)
C4Object *container = NULL;
C4Object *container = nullptr;
if (iTargetObj)
{
container = ::Objects.SafeObjectPointer(iTargetObj);
@ -1487,7 +1487,7 @@ void C4ControlMessage::Execute() const
{
const char *szMessage = Message.getData();
// get player
C4Player *pPlr = (iPlayer < 0 ? NULL : ::Players.Get(iPlayer));
C4Player *pPlr = (iPlayer < 0 ? nullptr : ::Players.Get(iPlayer));
// security
if (pPlr && pPlr->AtClient != iByClient) return;
// do not record message as control, because it is not synced!
@ -1578,7 +1578,7 @@ void C4ControlMessage::Execute() const
// tehehe, sound!
C4Client *singer = Game.Clients.getClientByID(iByClient);
if (!singer || !singer->IsIgnored())
if (!StartSoundEffect(szMessage, false, 100, NULL))
if (!StartSoundEffect(szMessage, false, 100, nullptr))
// probably wrong sound file name
break;
// Sound icon even if someone you ignored just tried. So you know you still need to ignore.

View File

@ -189,7 +189,7 @@ class C4ControlPlayerSelect : public C4ControlPacket // sync
{
public:
C4ControlPlayerSelect()
: iPlr(-1), fIsAlt(false), iObjCnt(0), pObjNrs(NULL) { }
: iPlr(-1), fIsAlt(false), iObjCnt(0), pObjNrs(nullptr) { }
C4ControlPlayerSelect(int32_t iPlr, const C4ObjectList &Objs, bool fIsAlt);
~C4ControlPlayerSelect() { delete[] pObjNrs; }
protected:
@ -460,9 +460,9 @@ enum C4ControlEMObjectAction
class C4ControlEMMoveObject : public C4ControlPacket // sync
{
public:
C4ControlEMMoveObject() : eAction(EMMO_Move), tx(Fix0), ty(Fix0), iTargetObj(0), iObjectNum(0), pObjects(NULL) { }
C4ControlEMMoveObject() : eAction(EMMO_Move), tx(Fix0), ty(Fix0), iTargetObj(0), iObjectNum(0), pObjects(nullptr) { }
C4ControlEMMoveObject(C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj,
int32_t iObjectNum = 0, int32_t *pObjects = NULL, const char *szScript = NULL);
int32_t iObjectNum = 0, int32_t *pObjects = nullptr, const char *szScript = nullptr);
static C4ControlEMMoveObject *CreateObject(const C4ID &id, C4Real x, C4Real y, C4Object *container);
~C4ControlEMMoveObject();
protected:
@ -494,8 +494,8 @@ public:
C4ControlEMDrawTool() : eAction(EMDT_SetMode), iX(0), iY(0), iX2(0), iY2(0), iGrade(0) { }
C4ControlEMDrawTool(C4ControlEMDrawAction eAction, LandscapeMode iMode,
int32_t iX=-1, int32_t iY=-1, int32_t iX2=-1, int32_t iY2=-1, int32_t iGrade=-1,
const char *szMaterial=NULL, const char *szTexture=NULL,
const char *szBackMaterial=NULL, const char *szBackTexture=NULL);
const char *szMaterial=nullptr, const char *szTexture=nullptr,
const char *szBackMaterial=nullptr, const char *szBackTexture=nullptr);
protected:
C4ControlEMDrawAction eAction; // action to be performed
LandscapeMode iMode; // new mode, or mode action was performed in (action will fail if changed)

View File

@ -76,7 +76,7 @@ bool C4GameControl::InitReplay(C4Group &rGroup)
if (!pPlayback->Open(rGroup))
{
LogFatal(LoadResStr("IDS_ERR_REPLAYREAD"));
delete pPlayback; pPlayback = NULL;
delete pPlayback; pPlayback = nullptr;
return false;
}
// set mode
@ -110,7 +110,7 @@ void C4GameControl::ChangeToLocal()
}
// replay: close playback
else if (eMode == CM_Replay)
{ delete pPlayback; pPlayback = NULL; }
{ delete pPlayback; pPlayback = nullptr; }
// we're now managing our own player info list; make sure counter works
Game.PlayerInfos.FixIDCounter();
@ -143,7 +143,7 @@ bool C4GameControl::StartRecord(bool fInitial, bool fStreaming)
pRecord = new C4Record();
if (!pRecord->Start(fInitial))
{
delete pRecord; pRecord = NULL;
delete pRecord; pRecord = nullptr;
return false;
}
// streaming
@ -152,7 +152,7 @@ bool C4GameControl::StartRecord(bool fInitial, bool fStreaming)
if (!pRecord->StartStreaming(fInitial) ||
!::Network.StartStreaming(pRecord))
{
delete pRecord; pRecord = NULL;
delete pRecord; pRecord = nullptr;
return false;
}
}
@ -170,7 +170,7 @@ void C4GameControl::StopRecord(StdStrBuf *pRecordName, BYTE *pRecordSHA1)
::Network.FinishStreaming();
pRecord->Stop(pRecordName, pRecordSHA1);
// just delete
delete pRecord; pRecord = NULL;
delete pRecord; pRecord = nullptr;
}
}
@ -216,15 +216,15 @@ void C4GameControl::Default()
eMode = CM_None;
fHost = fInitComplete = false;
iClientID = C4ClientIDUnknown;
pRecord = NULL;
pPlayback = NULL;
pRecord = nullptr;
pPlayback = nullptr;
SyncChecks.Clear();
ControlRate = Clamp<int>(Config.Network.ControlRate, 1, C4MaxControlRate);
ControlTick = 0;
SyncRate = C4SyncCheckRate;
DoSync = false;
fRecordNeeded = false;
pExecutingControl = NULL;
pExecutingControl = nullptr;
}
bool C4GameControl::Prepare()
@ -317,7 +317,7 @@ void C4GameControl::Execute()
pExecutingControl = &Control;
Control.Execute();
Control.Clear();
pExecutingControl = NULL;
pExecutingControl = nullptr;
// statistics record
if (Game.pNetworkStatistics) Game.pNetworkStatistics->ExecuteControlFrame();
@ -505,7 +505,7 @@ C4ControlSyncCheck *C4GameControl::GetSyncCheck(int32_t iTick)
if (pCheck->getFrame() == iTick)
return pCheck;
}
return NULL;
return nullptr;
}
void C4GameControl::RemoveOldSyncChecks()

View File

@ -120,7 +120,7 @@ public:
// records
bool StartRecord(bool fInitial, bool fStreaming);
void StopRecord(StdStrBuf *pRecordName = NULL, BYTE *pRecordSHA1 = NULL);
void StopRecord(StdStrBuf *pRecordName = nullptr, BYTE *pRecordSHA1 = nullptr);
void RequestRuntimeRecord();
bool IsRuntimeRecordPossible() const;
bool RecAddFile(const char *szLocalFilename, const char *szAddAs);
@ -145,7 +145,7 @@ public:
// input
void DoInput(C4PacketType eCtrlType, C4ControlPacket *pPkt, C4ControlDeliveryType eDelivery);
void DbgRec(C4RecordChunkType eType, const uint8_t *pData=NULL, size_t iSize=0); // record debug stuff
void DbgRec(C4RecordChunkType eType, const uint8_t *pData=nullptr, size_t iSize=0); // record debug stuff
C4ControlDeliveryType DecideControlDelivery();
// sync check

View File

@ -28,7 +28,7 @@
C4GameRes::C4GameRes()
: eType(NRT_Null), pResCore(NULL), pNetRes(NULL)
: eType(NRT_Null), pResCore(nullptr), pNetRes(nullptr)
{
}
@ -64,8 +64,8 @@ void C4GameRes::Clear()
File.Clear();
if (pResCore && !pNetRes)
delete pResCore;
pResCore = NULL;
pNetRes = NULL;
pResCore = nullptr;
pNetRes = nullptr;
}
void C4GameRes::SetFile(C4Network2ResType enType, const char *sznFile)
@ -114,7 +114,7 @@ bool C4GameRes::Publish(C4Network2ResList *pNetResList)
bool fAllowUnloadable = false;
if (eType == NRT_Definitions) fAllowUnloadable = true;
// Add to network resource list
C4Network2Res::Ref pNetRes = pNetResList->AddByFile(File.getData(), false, eType, -1, NULL, fAllowUnloadable);
C4Network2Res::Ref pNetRes = pNetResList->AddByFile(File.getData(), false, eType, -1, nullptr, fAllowUnloadable);
if (!pNetRes) return false;
// Set resource
SetNetRes(pNetRes);
@ -200,8 +200,8 @@ C4GameRes *C4GameResList::iterRes(C4GameRes *pLast, C4Network2ResType eType)
return pResList[i];
}
else if (pLast == pResList[i])
pLast = NULL;
return NULL;
pLast = nullptr;
return nullptr;
}
void C4GameResList::Clear()
@ -210,7 +210,7 @@ void C4GameResList::Clear()
for (int32_t i = 0; i < iResCount; i++)
delete pResList[i];
delete [] pResList;
pResList = NULL;
pResList = nullptr;
iResCount = iResCapacity = 0;
}
@ -272,7 +272,7 @@ bool C4GameResList::Load(C4Group &hGroup, C4Scenario *pScenario, const char * sz
// add System.ocg
CreateByFile(NRT_System, C4CFN_System);
// add all instances of Material.ocg, except those inside the scenario file
C4Group *pMatParentGrp = NULL;
C4Group *pMatParentGrp = nullptr;
while ((pMatParentGrp = Game.GroupSet.FindGroup(C4GSCnt_Material, pMatParentGrp)))
if (pMatParentGrp != &Game.ScenarioFile)
{

View File

@ -68,7 +68,7 @@ private:
int32_t iResCount, iResCapacity;
public:
C4GameResList() : pResList(NULL), iResCount(0), iResCapacity(0) {}
C4GameResList() : pResList(nullptr), iResCount(0), iResCapacity(0) {}
~C4GameResList() { Clear(); }
C4GameResList &operator = (const C4GameResList &List);
@ -154,7 +154,7 @@ public:
bool InitNetwork(C4Network2ResList *pResList);
bool Save(C4Group &hGroup, C4Scenario *pDefault);
void CompileFunc(StdCompiler *pComp, C4Scenario *pScenario = NULL);
void CompileFunc(StdCompiler *pComp, C4Scenario *pScenario = nullptr);
};
#endif // C4GAMEPARAMETERS_H

View File

@ -329,7 +329,7 @@ void C4GameSave::WriteDescNetworkClients(StdStrBuf &sBuf)
// Desc
sBuf.Append(LoadResStr("IDS_DESC_CLIENTS"));
// Client names
for (C4Network2Client *pClient=::Network.Clients.GetNextClient(NULL); pClient; pClient=::Network.Clients.GetNextClient(pClient))
for (C4Network2Client *pClient=::Network.Clients.GetNextClient(nullptr); pClient; pClient=::Network.Clients.GetNextClient(pClient))
{ sBuf.Append(", "); sBuf.Append(pClient->getName()); }
// End of line
WriteDescLineFeed(sBuf);
@ -402,7 +402,7 @@ bool C4GameSave::Save(const char *szFilename)
C4Group *pLSaveGroup = new C4Group();
if (!SaveCreateGroup(szFilename, *pLSaveGroup))
{
LogF(LoadResStr("IDS_ERR_SAVE_TARGETGRP"), szFilename ? szFilename : "NULL!");
LogF(LoadResStr("IDS_ERR_SAVE_TARGETGRP"), szFilename ? szFilename : "nullptr!");
delete pLSaveGroup;
return false;
}
@ -459,7 +459,7 @@ bool C4GameSave::Close()
delete pSaveGroup;
fOwnGroup = false;
}
pSaveGroup = NULL;
pSaveGroup = nullptr;
}
return fSuccess;
}

View File

@ -58,7 +58,7 @@ protected:
virtual bool GetKeepTitle() { return !IsExact(); } // whether original, localized title with image and icon shall be deleted
virtual bool GetSaveDesc() { return true; } // should WriteDescData be executed in Save()-call?
virtual bool GetCopyScenario() { return true; } // return whether the savegame depends on the game scenario file
virtual const char *GetSortOrder() { return C4FLS_Scenario; } // return NULL to prevent sorting
virtual const char *GetSortOrder() { return C4FLS_Scenario; } // return nullptr to prevent sorting
virtual bool GetCreateSmallFile() { return false; } // return whether file size should be minimized
virtual bool GetForceExactLandscape() { return GetSaveRuntimeData() && IsExact(); } // whether exact landscape shall be saved
virtual bool GetSaveOrigin() { return false; } // return whether C4S.Head.Origin shall be set
@ -79,7 +79,7 @@ protected:
bool IsSynced() { return Sync>=SyncSynchronized; } // synchronized
// protected constructor
C4GameSave(bool fAInitial, SyncState ASync) : pSaveGroup(NULL), fOwnGroup(false), fInitial(fAInitial), Sync(ASync) { }
C4GameSave(bool fAInitial, SyncState ASync) : pSaveGroup(nullptr), fOwnGroup(false), fInitial(fAInitial), Sync(ASync) { }
protected:
// some desc writing helpers
void WriteDescLineFeed(StdStrBuf &sBuf); // append a line break to desc

View File

@ -57,7 +57,7 @@ void C4PlayerControlDef::CompileFunc(StdCompiler *pComp)
{
{ "Game", COS_Game },
{ "Viewport", COS_Viewport },
{ NULL, COS_Game }
{ nullptr, COS_Game }
};
pComp->Value(mkNamingAdapt(mkEnumAdapt<CoordinateSpace, int32_t>(eCoordSpace, CoordSpaceNames), "CoordinateSpace", COS_Game));
pComp->Value(mkNamingAdapt(fSendCursorPos, "SendCursorPos", false));
@ -83,7 +83,7 @@ void C4PlayerControlDef::CompileFunc(StdCompiler *pComp)
{ "ObjectMenuDown", CDA_ObjectMenuDown },
{ "ZoomIn", CDA_ZoomIn },
{ "ZoomOut", CDA_ZoomOut },
{ NULL, CDA_None }
{ nullptr, CDA_None }
};
pComp->Value(mkNamingAdapt(mkEnumAdapt<Actions, int32_t>(eAction, ActionNames), "Action", CDA_Script));
pComp->NameEnd();
@ -156,7 +156,7 @@ void C4PlayerControlDefs::MergeFrom(const C4PlayerControlDefs &Src)
const C4PlayerControlDef *C4PlayerControlDefs::GetControlByIndex(int32_t idx) const
{
// safe index
if (idx<0 || idx>=int32_t(Defs.size())) return NULL;
if (idx<0 || idx>=int32_t(Defs.size())) return nullptr;
return &(Defs[idx]);
}
@ -229,7 +229,7 @@ void C4PlayerControlAssignment::CompileFunc(StdCompiler *pComp)
{ "Release", CTM_Release },
{ "AlwaysUnhandled", CTM_AlwaysUnhandled },
{ "ClearRecentKeys", CTM_ClearRecentKeys },
{ NULL, 0 }
{ nullptr, 0 }
};
pComp->Value(mkNamingAdapt(mkBitfieldAdapt< int32_t>(iTriggerMode, TriggerModeNames), "TriggerMode", CTM_Default));
pComp->Value(mkNamingAdapt(fOverrideAssignments, "OverrideAssignments", false));
@ -462,7 +462,7 @@ const char *C4PlayerControlAssignment::GetGUIName(const C4PlayerControlDefs &def
const C4PlayerControlDef *def = defs.GetControlByIndex(GetControl());
if (def) return def->GetGUIName();
// no def and no name...
return NULL;
return nullptr;
}
const char *C4PlayerControlAssignment::GetGUIDesc(const C4PlayerControlDefs &defs) const
@ -473,7 +473,7 @@ const char *C4PlayerControlAssignment::GetGUIDesc(const C4PlayerControlDefs &def
const C4PlayerControlDef *def = defs.GetControlByIndex(GetControl());
if (def) return def->GetGUIDesc();
// no def and no desc...
return NULL;
return nullptr;
}
bool C4PlayerControlAssignment::IsGUIDisabled() const
@ -614,7 +614,7 @@ void C4PlayerControlAssignmentSet::SortAssignments()
C4PlayerControlAssignment *C4PlayerControlAssignmentSet::GetAssignmentByIndex(int32_t index)
{
if (index<0 || index>=int32_t(Assignments.size())) return NULL;
if (index<0 || index>=int32_t(Assignments.size())) return nullptr;
return &Assignments[index];
}
@ -625,7 +625,7 @@ C4PlayerControlAssignment *C4PlayerControlAssignmentSet::GetAssignmentByControlN
// We don't like release keys... (2do)
if (!((*i).GetTriggerMode() & C4PlayerControlAssignment::CTM_Release))
return &*i;
return NULL;
return nullptr;
}
C4PlayerControlAssignment *C4PlayerControlAssignmentSet::GetAssignmentByControl(int32_t control)
@ -636,7 +636,7 @@ C4PlayerControlAssignment *C4PlayerControlAssignmentSet::GetAssignmentByControl(
// We don't like release keys... (2do)
if (!((*i).GetTriggerMode() & C4PlayerControlAssignment::CTM_Release))
return &*i;
return NULL;
return nullptr;
}
bool C4PlayerControlAssignmentSet::operator ==(const C4PlayerControlAssignmentSet &cmp) const
@ -805,13 +805,13 @@ C4PlayerControlAssignmentSet *C4PlayerControlAssignmentSets::GetSetByName(const
for (AssignmentSetList::iterator i = Sets.begin(); i != Sets.end(); ++i)
if (WildcardMatch(szName, (*i).GetName()))
return &*i;
return NULL;
return nullptr;
}
C4PlayerControlAssignmentSet *C4PlayerControlAssignmentSets::GetDefaultSet()
{
// default set is first defined control set
if (Sets.empty()) return NULL; // nothing defined :(
if (Sets.empty()) return nullptr; // nothing defined :(
return &Sets.front();
}
@ -828,7 +828,7 @@ int32_t C4PlayerControlAssignmentSets::GetSetIndex(const C4PlayerControlAssignme
C4PlayerControlAssignmentSet *C4PlayerControlAssignmentSets::GetSetByIndex(int32_t index)
{
// bounds check
if (index < 0 || index >= (int32_t)Sets.size()) return NULL;
if (index < 0 || index >= (int32_t)Sets.size()) return nullptr;
// return indexed set
AssignmentSetList::iterator i = Sets.begin();
while (index--) ++i;
@ -913,7 +913,7 @@ bool C4PlayerControl::CSync::ControlDownState::operator ==(const ControlDownStat
const C4PlayerControl::CSync::ControlDownState *C4PlayerControl::CSync::GetControlDownState(int32_t iControl) const
{
// safe access
if (iControl < 0 || iControl >= int32_t(ControlDownStates.size())) return NULL;
if (iControl < 0 || iControl >= int32_t(ControlDownStates.size())) return nullptr;
return &ControlDownStates[iControl];
}
@ -1027,7 +1027,7 @@ bool C4PlayerControl::ProcessKeyEvent(const C4KeyCodeEx &pressed_key, const C4Ke
pControlSet->GetAssignmentsByKey(ControlDefs, matched_key, state != CONS_Down, &Matches, DownKeys, RecentKeys);
// process async controls
bool cursor_pos_added = false;
C4ControlPlayerControl *pControlPacket = NULL;
C4ControlPlayerControl *pControlPacket = nullptr;
for (C4PlayerControlAssignmentPVec::const_iterator i = Matches.begin(); i != Matches.end(); ++i)
{
const C4PlayerControlAssignment *pAssignment = *i;
@ -1253,10 +1253,10 @@ bool C4PlayerControl::ExecuteControlAction(int32_t iControl, C4PlayerControlDef:
// moved events don't make sense for menus and are only handled by script
if (state == CONS_Moved && eAction != C4PlayerControlDef::CDA_Script) return false;
// get affected player
C4Player *pPlr = NULL;
C4Player *pPlr = nullptr;
C4Viewport *pVP;
C4Object *pCursor = NULL;
C4Menu *pCursorMenu = NULL;
C4Object *pCursor = nullptr;
C4Menu *pCursorMenu = nullptr;
if (iPlr > -1)
{
pPlr = ::Players.Get(iPlr);
@ -1370,14 +1370,14 @@ void C4PlayerControl::Execute()
if (irk != RecentKeys.begin()) RecentKeys.erase(RecentKeys.begin(), irk);
}
C4PlayerControl::C4PlayerControl() : ControlDefs(Game.PlayerControlDefs), iPlr(-1), pControlSet(NULL), IsCursorPosRequested(false)
C4PlayerControl::C4PlayerControl() : ControlDefs(Game.PlayerControlDefs), iPlr(-1), pControlSet(nullptr), IsCursorPosRequested(false)
{
}
void C4PlayerControl::Clear()
{
iPlr = NO_OWNER;
pControlSet = NULL;
pControlSet = nullptr;
for (KeyBindingList::iterator i = KeyBindings.begin(); i != KeyBindings.end(); ++i) delete *i;
KeyBindings.clear();
RecentKeys.clear();
@ -1406,7 +1406,7 @@ void C4PlayerControl::AddKeyBinding(const C4KeyCodeEx &key, bool fHoldKey, int32
{
KeyBindings.push_back(new C4KeyBinding(
key, FormatString("PlrKey%02d", idx).getData(), KEYSCOPE_Control,
new C4KeyCBExPassKey<C4PlayerControl, C4KeyCodeEx>(*this, key, &C4PlayerControl::ProcessKeyDown, fHoldKey ? &C4PlayerControl::ProcessKeyUp : NULL, NULL, fHoldKey ? &C4PlayerControl::ProcessKeyMoved : NULL),
new C4KeyCBExPassKey<C4PlayerControl, C4KeyCodeEx>(*this, key, &C4PlayerControl::ProcessKeyDown, fHoldKey ? &C4PlayerControl::ProcessKeyUp : nullptr, nullptr, fHoldKey ? &C4PlayerControl::ProcessKeyMoved : nullptr),
C4CustomKey::PRIO_PlrControl));
}

View File

@ -193,7 +193,7 @@ public:
C4PlayerControlAssignment() :
TriggerKey(), fOverrideAssignments(false), is_inherited(false), fRefsResolved(false),
iGUIGroup(0), iControl(CON_None), iPriority(0), iTriggerMode(CTM_Default),
inherited_assignment(NULL)
inherited_assignment(nullptr)
{}
~C4PlayerControlAssignment() {}
@ -245,7 +245,7 @@ private:
bool has_gamepad;
public:
C4PlayerControlAssignmentSet() : parent_set(NULL), has_keyboard(true), has_mouse(true), has_gamepad(false) {}
C4PlayerControlAssignmentSet() : parent_set(nullptr), has_keyboard(true), has_mouse(true), has_gamepad(false) {}
~C4PlayerControlAssignmentSet() {}
void InitEmptyFromTemplate(const C4PlayerControlAssignmentSet &template_set); // copy all fields except assignments
@ -345,7 +345,7 @@ private:
int32_t iPlr;
// async values
C4PlayerControlAssignmentSet *pControlSet; // the control set used by this player - may be NULL if the player cannot be controlled!
C4PlayerControlAssignmentSet *pControlSet; // the control set used by this player - may be nullptr if the player cannot be controlled!
typedef std::list<C4KeyBinding *> KeyBindingList;
KeyBindingList KeyBindings; // keys registered into Game.KeyboardInput
C4PlayerControlRecentKeyList RecentKeys; // keys pressed recently; for combinations
@ -392,7 +392,7 @@ private:
CSync Sync;
// callbacks from Game.KeyboardInput
bool ProcessKeyEvent(const C4KeyCodeEx &pressed_key, const C4KeyCodeEx &matched_key, ControlState state, const C4KeyEventData &rKeyExtraData, bool reset_down_states_only=false, bool *clear_recent_keys=NULL);
bool ProcessKeyEvent(const C4KeyCodeEx &pressed_key, const C4KeyCodeEx &matched_key, ControlState state, const C4KeyEventData &rKeyExtraData, bool reset_down_states_only=false, bool *clear_recent_keys=nullptr);
bool ProcessKeyDown(const C4KeyCodeEx &pressed_key, const C4KeyCodeEx &matched_key);
bool ProcessKeyUp(const C4KeyCodeEx &pressed_key, const C4KeyCodeEx &matched_key);
bool ProcessKeyMoved(const C4KeyCodeEx &pressed_key, const C4KeyCodeEx &matched_key);

View File

@ -37,7 +37,7 @@ void C4PlayerInfo::Clear()
DeleteTempFile();
// clear fields
sName.Clear(); szFilename.Clear();
pRes = NULL;
pRes = nullptr;
ResCore.Clear();
// default fields
dwColor = dwOriginalColor = 0xffffffff;
@ -194,7 +194,7 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
{ "NoScenarioInit", PIF_NoScenarioInit },
{ "NoEliminationCheck", PIF_NoEliminationCheck },
{ "Invisible", PIF_Invisible},
{ NULL, 0 },
{ nullptr, 0 },
};
uint16_t dwSyncFlags = dwFlags & PIF_SyncFlags; // do not store local flags!
pComp->Value(mkNamingAdapt(mkBitfieldAdapt(dwSyncFlags, Entries), "Flags", 0u));
@ -207,7 +207,7 @@ void C4PlayerInfo::CompileFunc(StdCompiler *pComp)
{ "User", C4PT_User },
{ "Script", C4PT_Script },
{ NULL, C4PT_User },
{ nullptr, C4PT_User },
};
pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eType, PlayerTypes), "Type", C4PT_User));
@ -314,7 +314,7 @@ void C4PlayerInfo::DiscardResource()
if (pRes)
{
assert(dwFlags & PIF_HasRes);
pRes = NULL;
pRes = nullptr;
dwFlags &= ~PIF_HasRes;
}
else assert(~dwFlags & PIF_HasRes);
@ -353,7 +353,7 @@ bool C4PlayerInfo::LoadBigIcon(C4FacetSurface &fctTarget)
bool fSuccess = false;
// load BigIcon.png of player into target facet; return false if no bigicon present or player file not yet loaded
C4Group Plr;
C4Network2Res *pRes = NULL;
C4Network2Res *pRes = nullptr;
bool fIncompleteRes = false;
if ((pRes = GetRes()))
if (!pRes->isComplete())
@ -372,7 +372,7 @@ bool C4PlayerInfo::LoadBigIcon(C4FacetSurface &fctTarget)
// *** C4ClientPlayerInfos
C4ClientPlayerInfos::C4ClientPlayerInfos(const char *szJoinFilenames, bool fAdd, C4PlayerInfo *pAddInfo)
: iPlayerCount(0), iPlayerCapacity(0), ppPlayers(NULL), iClientID(-1), dwFlags(0)
: iPlayerCount(0), iPlayerCapacity(0), ppPlayers(nullptr), iClientID(-1), dwFlags(0)
{
// init for local client?
if (szJoinFilenames || pAddInfo)
@ -437,7 +437,7 @@ C4ClientPlayerInfos::C4ClientPlayerInfos(const C4ClientPlayerInfos &rCopy)
// no players
else
{
ppPlayers = NULL;
ppPlayers = nullptr;
iPlayerCapacity = 0;
}
// misc fields
@ -460,7 +460,7 @@ C4ClientPlayerInfos &C4ClientPlayerInfos::operator = (const C4ClientPlayerInfos
// no players
else
{
ppPlayers = NULL;
ppPlayers = nullptr;
iPlayerCapacity = 0;
}
// misc fields
@ -475,7 +475,7 @@ void C4ClientPlayerInfos::Clear()
int32_t i = iPlayerCount; C4PlayerInfo **ppCurrPlrInfo = ppPlayers;
while (i--) delete *ppCurrPlrInfo++;
// del player info vector
delete [] ppPlayers; ppPlayers = NULL;
delete [] ppPlayers; ppPlayers = nullptr;
// reset other fields
iPlayerCount = iPlayerCapacity = 0;
iClientID=-1;
@ -496,13 +496,13 @@ void C4ClientPlayerInfos::GrabMergeFrom(C4ClientPlayerInfos &rFrom)
memcpy(ppPlayers + iPlayerCount, rFrom.ppPlayers, rFrom.iPlayerCount * sizeof(C4PlayerInfo *));
iPlayerCount += rFrom.iPlayerCount;
rFrom.iPlayerCount = rFrom.iPlayerCapacity = 0;
delete [] rFrom.ppPlayers; rFrom.ppPlayers = NULL;
delete [] rFrom.ppPlayers; rFrom.ppPlayers = nullptr;
}
else
{
// no own players: take over buffer of pFrom
if (ppPlayers) delete [] ppPlayers;
ppPlayers = rFrom.ppPlayers; rFrom.ppPlayers = NULL;
ppPlayers = rFrom.ppPlayers; rFrom.ppPlayers = nullptr;
iPlayerCount = rFrom.iPlayerCount; rFrom.iPlayerCount = 0;
iPlayerCapacity = rFrom.iPlayerCapacity; rFrom.iPlayerCapacity = 0;
}
@ -571,7 +571,7 @@ int32_t C4ClientPlayerInfos::GetFlaggedPlayerCount(DWORD dwFlag) const
C4PlayerInfo *C4ClientPlayerInfos::GetPlayerInfo(int32_t iIndex) const
{
// check range
if (iIndex<0 || iIndex>=iPlayerCount) return NULL;
if (iIndex<0 || iIndex>=iPlayerCount) return nullptr;
// return indexed info
return ppPlayers[iIndex];
}
@ -587,7 +587,7 @@ C4PlayerInfo *C4ClientPlayerInfos::GetPlayerInfo(int32_t iIndex, C4PlayerType eT
return pNfo;
}
// nothing found
return NULL;
return nullptr;
}
C4PlayerInfo *C4ClientPlayerInfos::GetPlayerInfoByID(int32_t id) const
@ -600,7 +600,7 @@ C4PlayerInfo *C4ClientPlayerInfos::GetPlayerInfoByID(int32_t id) const
++ppCurrPlrInfo;
}
// none matched
return NULL;
return nullptr;
}
C4PlayerInfo *C4ClientPlayerInfos::GetPlayerInfoByRes(int32_t idResID) const
@ -616,7 +616,7 @@ C4PlayerInfo *C4ClientPlayerInfos::GetPlayerInfoByRes(int32_t idResID) const
return *ppCurrPlrInfo;
++ppCurrPlrInfo;
}
return NULL;
return nullptr;
}
bool C4ClientPlayerInfos::HasUnjoinedPlayers() const
@ -650,7 +650,7 @@ void C4ClientPlayerInfos::CompileFunc(StdCompiler *pComp)
{ "Initial", CIF_Initial },
{ "Developer", CIF_Developer },
{ NULL, 0 }
{ nullptr, 0 }
};
pComp->Value(mkNamingAdapt(mkBitfieldAdapt(dwFlags, Entries), "Flags", 0u));
@ -678,13 +678,13 @@ void C4ClientPlayerInfos::LoadResources()
// *** C4PlayerInfoList
C4PlayerInfoList::C4PlayerInfoList() : iClientCount(0), iClientCapacity(0), ppClients(NULL), iLastPlayerID(0)
C4PlayerInfoList::C4PlayerInfoList() : iClientCount(0), iClientCapacity(0), ppClients(nullptr), iLastPlayerID(0)
{
// ctor: no need to alloc mem yet
}
C4PlayerInfoList::C4PlayerInfoList(const C4PlayerInfoList &rCpy) : iClientCount(rCpy.iClientCount), iClientCapacity(rCpy.iClientCapacity),
ppClients(NULL), iLastPlayerID(rCpy.iLastPlayerID)
ppClients(nullptr), iLastPlayerID(rCpy.iLastPlayerID)
{
// copy client info vector
if (rCpy.ppClients)
@ -710,7 +710,7 @@ C4PlayerInfoList &C4PlayerInfoList::operator = (const C4PlayerInfoList &rCpy)
while (i--) *ppInfo++ = new C4ClientPlayerInfos(**ppCpy++);
}
else
ppClients = NULL;
ppClients = nullptr;
return *this;
}
@ -720,7 +720,7 @@ void C4PlayerInfoList::Clear()
C4ClientPlayerInfos **ppInfo = ppClients; int32_t i=iClientCount;
while (i--) delete *ppInfo++;
// clear client infos
delete [] ppClients; ppClients = NULL;
delete [] ppClients; ppClients = nullptr;
iClientCount = iClientCapacity = 0;
// reset player ID counter
iLastPlayerID = 0;
@ -831,7 +831,7 @@ void C4PlayerInfoList::UpdatePlayerAttributes()
C4ClientPlayerInfos *pForInfo;
while ((pForInfo = GetIndexedInfo(iIdx++))) UpdatePlayerAttributes(pForInfo, false);
// now resole all conflicts
ResolvePlayerAttributeConflicts(NULL);
ResolvePlayerAttributeConflicts(nullptr);
}
bool C4PlayerInfoList::AssignPlayerIDs(C4ClientPlayerInfos *pNewClientInfo)
@ -898,7 +898,7 @@ C4ClientPlayerInfos *C4PlayerInfoList::AddInfo(C4ClientPlayerInfos *pNewClientIn
{
// no players could be added (probably MaxPlayer)
delete pNewClientInfo;
return NULL;
return nullptr;
}
}
// ensure all teams specified in the list exist (this should be done for savegame teams as well)
@ -940,7 +940,7 @@ C4ClientPlayerInfos **C4PlayerInfoList::GetInfoPtrByClientID(int32_t iClientID)
// search list
for (int32_t i=0; i<iClientCount; ++i) if (ppClients[i]->GetClientID() == iClientID) return ppClients+i;
// nothing found
return NULL;
return nullptr;
}
int32_t C4PlayerInfoList::GetPlayerCount() const
@ -1061,7 +1061,7 @@ C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoByIndex(int32_t index) const
return pInfo;
}
// nothing found
return NULL;
return nullptr;
}
C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoByID(int32_t id) const
@ -1076,7 +1076,7 @@ C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoByID(int32_t id) const
if (pInfo->GetID() == id) return pInfo;
}
// nothing found
return NULL;
return nullptr;
}
C4ClientPlayerInfos *C4PlayerInfoList::GetClientInfoByPlayerID(int32_t id) const
@ -1090,7 +1090,7 @@ C4ClientPlayerInfos *C4PlayerInfoList::GetClientInfoByPlayerID(int32_t id) const
if (pInfo->GetID() == id) return ppClients[i];
}
// nothing found
return NULL;
return nullptr;
}
C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoByID(int32_t id, int32_t *pidClient) const
@ -1109,7 +1109,7 @@ C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoByID(int32_t id, int32_t *pidClient
}
}
// nothing found
return NULL;
return nullptr;
}
C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoBySavegameID(int32_t id) const
@ -1124,13 +1124,13 @@ C4PlayerInfo *C4PlayerInfoList::GetPlayerInfoBySavegameID(int32_t id) const
if (pInfo->GetAssociatedSavegamePlayerID() == id) return pInfo;
}
// nothing found
return NULL;
return nullptr;
}
C4PlayerInfo *C4PlayerInfoList::GetNextPlayerInfoByID(int32_t id) const
{
// check all packets for players
C4PlayerInfo *pSmallest=NULL;
C4PlayerInfo *pSmallest=nullptr;
for (int32_t i=0; i<iClientCount; ++i)
{
int32_t j=0; C4PlayerInfo *pInfo;
@ -1155,7 +1155,7 @@ C4PlayerInfo *C4PlayerInfoList::GetActivePlayerInfoByName(const char *szName)
return pInfo;
}
// nothing found
return NULL;
return nullptr;
}
C4PlayerInfo *C4PlayerInfoList::FindSavegameResumePlayerInfo(const C4PlayerInfo *pMatchInfo, MatchingLevel mlMatchStart, MatchingLevel mlMatchEnd) const
@ -1189,7 +1189,7 @@ C4PlayerInfo *C4PlayerInfoList::FindSavegameResumePlayerInfo(const C4PlayerInfo
}
}
// no match
return NULL;
return nullptr;
}
C4PlayerInfo *C4PlayerInfoList::FindUnassociatedRestoreInfo(const C4PlayerInfoList &rRestoreInfoList)
@ -1206,7 +1206,7 @@ C4PlayerInfo *C4PlayerInfoList::FindUnassociatedRestoreInfo(const C4PlayerInfoLi
return pRestoreInfo;
}
// no unassociated info found
return NULL;
return nullptr;
}
bool C4PlayerInfoList::HasSameTeamPlayers(int32_t iClient1, int32_t iClient2) const
@ -1578,7 +1578,7 @@ bool C4PlayerInfoList::RecreatePlayers(C4ValueNumbers * numbers)
const char *szName = pInfo->GetName();
if (!::Network.RetrieveRes(pJoinRes->getCore(), C4NetResRetrieveTimeout,
FormatString(LoadResStr("IDS_NET_RES_PLRFILE"), szName).getData()))
szFilename=NULL;
szFilename=nullptr;
}
// file present?
if (!szFilename || !*szFilename)
@ -1593,7 +1593,7 @@ bool C4PlayerInfoList::RecreatePlayers(C4ValueNumbers * numbers)
else
{
// for script players: Recreation without filename OK
szFilename = NULL;
szFilename = nullptr;
}
}
// record file handling: Save to the record file in the manner it's expected by C4PlayerInfoList::RecreatePlayers
@ -1652,7 +1652,7 @@ bool C4PlayerInfoList::SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fS
if (pInfo->IsJoined())
{
// pre-reset filename
pInfo->SetFilename(NULL);
pInfo->SetFilename(nullptr);
if (pInfo->GetType() == C4PT_User)
{
fKeepInfo = fSaveUserPlrs;

View File

@ -229,7 +229,7 @@ private:
uint32_t dwFlags; // bit mask of the above flags
public:
C4ClientPlayerInfos(const char *szJoinFilenames=NULL, bool fAdd=false, C4PlayerInfo *pAddInfo=NULL); // ctor; sets local data (or makes an add-player-packet if filename is given) if par is true
C4ClientPlayerInfos(const char *szJoinFilenames=nullptr, bool fAdd=false, C4PlayerInfo *pAddInfo=nullptr); // ctor; sets local data (or makes an add-player-packet if filename is given) if par is true
C4ClientPlayerInfos(const C4ClientPlayerInfos &rCopy); // copy ctor
~C4ClientPlayerInfos() { Clear(); } // dtor
@ -357,10 +357,10 @@ public:
// query functions
int32_t GetInfoCount() const { return iClientCount; } // get number of registered client infos
C4ClientPlayerInfos *GetIndexedInfo(int32_t iIndex) const // get client player infos by indexed
{ return (ppClients && Inside<int32_t>(iIndex, 0, iClientCount-1)) ? ppClients[iIndex] : NULL; }
{ return (ppClients && Inside<int32_t>(iIndex, 0, iClientCount-1)) ? ppClients[iIndex] : nullptr; }
C4ClientPlayerInfos **GetInfoPtrByClientID(int32_t iClientID) const; // get info for a specific client ID
C4ClientPlayerInfos *GetInfoByClientID(int32_t iClientID) const
{ C4ClientPlayerInfos **ppNfo = GetInfoPtrByClientID(iClientID); return ppNfo ? *ppNfo : NULL; }
{ C4ClientPlayerInfos **ppNfo = GetInfoPtrByClientID(iClientID); return ppNfo ? *ppNfo : nullptr; }
C4PlayerInfo *GetPlayerInfoByIndex(int32_t index) const; // get player info by index (for running through all players regardless of clients or ids)
C4PlayerInfo *GetPlayerInfoByID(int32_t id) const; // get player info by unique player ID
C4PlayerInfo *GetPlayerInfoByID(int32_t id, int32_t *pidClient) const; // get player info by unique player ID, and assign associated client
@ -377,7 +377,7 @@ public:
C4PlayerInfo *GetPrimaryInfoByClientID(int32_t iClientID) const
{
C4ClientPlayerInfos *pInfoPkt = GetInfoByClientID(iClientID);
if (!pInfoPkt) return NULL;
if (!pInfoPkt) return nullptr;
return pInfoPkt->GetPlayerInfo(0);
}
C4PlayerInfo *FindSavegameResumePlayerInfo(const C4PlayerInfo *pMatchInfo, MatchingLevel mlMatchStart, MatchingLevel mlMatchEnd) const; // automatic savegame player association: Associate by name (or prefcolor, if none matches)
@ -388,7 +388,7 @@ public:
{ *ppRemoveInfo = ppClients[--iClientCount]; /* maybe redundant self-assignment; no vector shrink */ }
public:
bool Load(C4Group &hGroup, const char *szFromFile, class C4LangStringTable *pLang=NULL); // clear self and load from group file
bool Load(C4Group &hGroup, const char *szFromFile, class C4LangStringTable *pLang=nullptr); // clear self and load from group file
bool Save(C4Group &hGroup, const char *szToFile); // save to group file
// external ID counter manipulation used by C4Game

View File

@ -112,7 +112,7 @@ void C4PlayerInfoList::ResolvePlayerAttributeConflicts(C4ClientPlayerInfos *pSec
// implementation of conflict resolver
C4PlayerInfoListAttributeConflictResolver::C4PlayerInfoListAttributeConflictResolver(C4PlayerInfoList &rPriCheckList, const C4PlayerInfoList &rSecCheckList, C4ClientPlayerInfos *pSecPacket)
: ppCheckInfos(NULL), iCheckInfoCount(0), rPriCheckList(rPriCheckList), rSecCheckList(rSecCheckList), pSecPacket(pSecPacket)
: ppCheckInfos(nullptr), iCheckInfoCount(0), rPriCheckList(rPriCheckList), rSecCheckList(rSecCheckList), pSecPacket(pSecPacket)
{
// prepare check array
int32_t iMaxCheckCount = rPriCheckList.GetInfoCount() + !!pSecPacket;
@ -127,7 +127,7 @@ C4PlayerInfoListAttributeConflictResolver::C4PlayerInfoListAttributeConflictReso
else
{
// if the additional packet is in the list already, it needn't be a check packed (only resolve packet)
this->pSecPacket = NULL;
this->pSecPacket = nullptr;
}
}
// must check sec packet first
@ -226,7 +226,7 @@ void C4PlayerInfoListAttributeConflictResolver::MarkConflicts(C4ClientPlayerInfo
{
// original attribute is taken by either one higher/equal priority by packet, or by two low prio packets
// in this case, don't revert to original
pLowPrioOriginalConflictPacket = NULL;
pLowPrioOriginalConflictPacket = nullptr;
fOriginalConflict = true;
}
}
@ -260,7 +260,7 @@ void C4PlayerInfoListAttributeConflictResolver::ResolveInInfo()
{
// check against all other player infos, and given info, too (may be redundant)
fCurrentConflict = false;
pLowPrioOriginalConflictPacket = pLowPrioAlternateConflictPacket = NULL;
pLowPrioOriginalConflictPacket = pLowPrioAlternateConflictPacket = nullptr;
MarkConflicts(rPriCheckList, !iTries);
// check secondary list, too. But only for colors, not for names, because secondary list is Restore list
// and colors are retained in restore while names are always taken from new joins
@ -322,7 +322,7 @@ void C4PlayerInfoListAttributeConflictResolver::ResolveInInfo()
if (!fOriginalConflict)
{
// revert to original name!
pResolveInfo->SetForcedName(NULL);
pResolveInfo->SetForcedName(nullptr);
if (pLowPrioOriginalConflictPacket) ReaddInfoForCheck(pLowPrioOriginalConflictPacket);
// done with this player (breaking the trial-loop)
break;

View File

@ -68,7 +68,7 @@ void C4PktDebugRec::CompileFunc(StdCompiler *pComp)
}
C4RecordChunk::C4RecordChunk()
: pCtrl(NULL)
: pCtrl(nullptr)
{
}
@ -77,12 +77,12 @@ void C4RecordChunk::Delete()
{
switch (Type)
{
case RCT_Ctrl: delete pCtrl; pCtrl = NULL; break;
case RCT_CtrlPkt: delete pPkt; pPkt = NULL; break;
case RCT_Ctrl: delete pCtrl; pCtrl = nullptr; break;
case RCT_CtrlPkt: delete pPkt; pPkt = nullptr; break;
case RCT_End: break;
case RCT_Frame: break;
case RCT_File: delete pFileData; break;
default: delete pDbg; pDbg = NULL; break;
default: delete pDbg; pDbg = nullptr; break;
}
}
@ -592,7 +592,7 @@ bool C4Playback::ReadBinary(const StdBuf &Buf)
return false;
}
// Add to list
chunks.push_back(c); c.pPkt = NULL;
chunks.push_back(c); c.pPkt = nullptr;
iFrame = c.Frame;
}
while (!fFinished);
@ -887,7 +887,7 @@ bool C4Playback::ExecuteControl(C4Control *pCtrl, int iFrame)
{
DebugRec.Add(CID_DebugRec, currChunk->pDbg);
// the debugrec buffer is now responsible for deleting the packet
currChunk->pDbg = NULL;
currChunk->pDbg = nullptr;
}
break;
}

View File

@ -90,7 +90,7 @@ enum C4RecordChunkType // record file chunk type
RCT_Undefined = 0xff
};
void AddDbgRec(C4RecordChunkType eType, const void *pData=NULL, int iSize=0); // record debug stuff
void AddDbgRec(C4RecordChunkType eType, const void *pData=nullptr, int iSize=0); // record debug stuff
#pragma pack(1)
@ -263,7 +263,7 @@ public:
const StdBuf &GetStreamingBuf() const { return StreamingData; }
bool Start(bool fInitial);
bool Stop(StdStrBuf *pRecordName = NULL, BYTE *pRecordSHA1 = NULL);
bool Stop(StdStrBuf *pRecordName = nullptr, BYTE *pRecordSHA1 = nullptr);
bool Rec(const C4Control &Ctrl, int iFrame); // record control
bool Rec(C4PacketType eCtrlType, C4ControlPacket *pCtrl, int iFrame); // record control packet

View File

@ -140,7 +140,7 @@ void C4RoundResultsPlayers::Clear()
{
while (iPlayerCount) delete ppPlayers[--iPlayerCount];
delete [] ppPlayers;
ppPlayers = NULL;
ppPlayers = nullptr;
iPlayerCapacity = 0;
}
@ -170,7 +170,7 @@ C4RoundResultsPlayer *C4RoundResultsPlayers::GetByIndex(int32_t idx) const
if (idx>=0 && idx<iPlayerCount)
return ppPlayers[idx];
else
return NULL;
return nullptr;
}
C4RoundResultsPlayer *C4RoundResultsPlayers::GetByID(int32_t id) const
@ -178,7 +178,7 @@ C4RoundResultsPlayer *C4RoundResultsPlayers::GetByID(int32_t id) const
for (int32_t idx=0; idx<iPlayerCount; ++idx)
if (ppPlayers[idx]->GetID() == id)
return ppPlayers[idx];
return NULL;
return nullptr;
}
void C4RoundResultsPlayers::GrowList(size_t iByVal)
@ -289,7 +289,7 @@ void C4RoundResults::EvaluateGoals(C4IDList &GoalList, C4IDList &FulfilledGoalLi
{
// 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 = C4Id2Def(idGoal) ? ::Objects.Find(::Definitions.ID2Def(idGoal)) : NULL;
C4Object *pObj = C4Id2Def(idGoal) ? ::Objects.Find(::Definitions.ID2Def(idGoal)) : nullptr;
if (pObj)
{
// Check fulfilled per player, this enables the possibility of rivalry.

View File

@ -98,8 +98,8 @@ private:
int32_t iPlayerCount, iPlayerCapacity;
public:
C4RoundResultsPlayers() : ppPlayers(NULL), iPlayerCount(0), iPlayerCapacity(0) {}
C4RoundResultsPlayers(const C4RoundResultsPlayers &cpy) : ppPlayers(NULL), iPlayerCount(0), iPlayerCapacity(0) { *this=cpy; }
C4RoundResultsPlayers() : ppPlayers(nullptr), iPlayerCount(0), iPlayerCapacity(0) {}
C4RoundResultsPlayers(const C4RoundResultsPlayers &cpy) : ppPlayers(nullptr), iPlayerCount(0), iPlayerCapacity(0) { *this=cpy; }
~C4RoundResultsPlayers() { Clear(); }
void Clear();

View File

@ -44,7 +44,7 @@ C4Team::C4Team(const C4Team &rCopy)
void C4Team::Clear()
{
delete [] piPlayers; piPlayers = NULL;
delete [] piPlayers; piPlayers = nullptr;
iPlayerCount = iPlayerCapacity = iMaxPlayer = 0;
iID = 0; *Name=0;
sIconSpec.Clear();
@ -258,7 +258,7 @@ void C4TeamList::Clear()
// del all teams
ClearTeams();
// del player team vector
delete [] ppList; ppList = NULL;
delete [] ppList; ppList = nullptr;
iTeamCapacity = 0;
fAllowHostilityChange = true;
fAllowTeamSwitch = false;
@ -315,7 +315,7 @@ bool C4TeamList::CanLocalChooseTeam(int32_t idPlayer) const
// always possible if teams are generated on the fly
if (IsAutoGenerateTeams()) return true;
// also possible if one of the teams that's not the player's is not full
C4Team *pCurrentTeam = NULL, *pCheck;
C4Team *pCurrentTeam = nullptr, *pCheck;
if (idPlayer) pCurrentTeam = GetTeamByPlayerID(idPlayer);
int32_t iCheckTeam=0;
while ((pCheck = GetTeamByIndex(iCheckTeam++)))
@ -385,13 +385,13 @@ C4Team *C4TeamList::GetTeamByID(int32_t iID) const
{
C4Team **ppCheck=ppList; int32_t iCnt=iTeamCount;
for (; iCnt--; ++ppCheck) if ((*ppCheck)->GetID() == iID) return *ppCheck;
return NULL;
return nullptr;
}
C4Team *C4TeamList::GetGenerateTeamByID(int32_t iID)
{
// only if enabled
if (!IsMultiTeams()) return NULL;
if (!IsMultiTeams()) return nullptr;
// new team?
if (iID == TEAMID_New) iID = GetLargestTeamID()+1;
// find in list
@ -405,7 +405,7 @@ C4Team *C4TeamList::GetGenerateTeamByID(int32_t iID)
C4Team *C4TeamList::GetTeamByIndex(int32_t iIndex) const
{
// safety
if (!Inside<int32_t>(iIndex, 0, iTeamCount-1)) return NULL;
if (!Inside<int32_t>(iIndex, 0, iTeamCount-1)) return nullptr;
// direct list access
return ppList[iIndex];
}
@ -415,14 +415,14 @@ C4Team *C4TeamList::GetTeamByName(const char *szName) const
assert(szName);
C4Team **ppCheck=ppList; int32_t iCnt=iTeamCount;
for (; iCnt--; ++ppCheck) if (SEqual((*ppCheck)->GetName(), szName)) return *ppCheck;
return NULL;
return nullptr;
}
C4Team *C4TeamList::GetTeamByPlayerID(int32_t iID) const
{
C4Team **ppCheck=ppList; int32_t iCnt=iTeamCount;
for (; iCnt--; ++ppCheck) if ((*ppCheck)->IsPlayerIDInTeam(iID)) return *ppCheck;
return NULL;
return nullptr;
}
int32_t C4TeamList::GetLargestTeamID() const
@ -435,7 +435,7 @@ int32_t C4TeamList::GetLargestTeamID() const
C4Team *C4TeamList::GetRandomSmallestTeam() const
{
C4Team *pLowestTeam = NULL; int iLowestTeamCount = 0;
C4Team *pLowestTeam = nullptr; int iLowestTeamCount = 0;
C4Team **ppCheck=ppList; int32_t iCnt=iTeamCount;
for (; iCnt--; ++ppCheck)
{
@ -496,7 +496,7 @@ bool C4TeamList::RecheckPlayerInfoTeams(C4PlayerInfo &rNewJoin, bool fByHost)
bool fIsTeamNeeded = IsRuntimeJoinTeamChoice() || GetTeamCount();
if (!fHasOrWillHaveLobby && (!fIsTeamNeeded || fCanPickTeamAtRuntime)) return false;
// get least-used team
C4Team *pAssignTeam=NULL;
C4Team *pAssignTeam=nullptr;
C4Team *pLowestTeam = GetRandomSmallestTeam();
// melee mode
if (IsAutoGenerateTeams() && !IsRandomTeam())
@ -580,7 +580,7 @@ void C4TeamList::CompileFunc(StdCompiler *pComp)
memset(ppList, 0, sizeof(C4Team *)*iTeamCapacity);
}
else
ppList = NULL;
ppList = nullptr;
}
if (iTeamCount)
@ -685,7 +685,7 @@ void C4TeamList::RecheckTeams()
C4Team *pLowestTeam = GetRandomSmallestTeam();
if (!pLowestTeam) break; // no teams: Nothing to re-distribute.
// get largest team that has relocateable players
C4Team *pLargestTeam = NULL;
C4Team *pLargestTeam = nullptr;
C4Team **ppCheck=ppList; int32_t iCnt=iTeamCount;
for (; iCnt--; ++ppCheck) if (!pLargestTeam || pLargestTeam->GetPlayerCount() > (*ppCheck)->GetPlayerCount())
if ((*ppCheck)->GetFirstUnjoinedPlayerID())
@ -851,7 +851,7 @@ void C4TeamList::EnforceLeagueRules()
int32_t C4TeamList::GetForcedTeamSelection(int32_t idForPlayer) const
{
// if there's only one team for the player to join, return that team ID
C4Team *pOKTeam = NULL, *pCheck;
C4Team *pOKTeam = nullptr, *pCheck;
if (idForPlayer) pOKTeam = GetTeamByPlayerID(idForPlayer); // curent team is always possible, even if full
int32_t iCheckTeam=0;
while ((pCheck = GetTeamByIndex(iCheckTeam++)))

View File

@ -53,7 +53,7 @@ protected:
friend class C4TeamList;
public:
C4Team() : piPlayers(NULL), iPlayerCount(0), iPlayerCapacity(0), iID(0), iPlrStartIndex(0), dwClr(0), iMaxPlayer(0) { *Name=0; }
C4Team() : piPlayers(nullptr), iPlayerCount(0), iPlayerCapacity(0), iID(0), iPlrStartIndex(0), dwClr(0), iMaxPlayer(0) { *Name=0; }
~C4Team() { Clear(); }
void Clear();
@ -131,7 +131,7 @@ private:
StdStrBuf sScriptPlayerNames; // default script player names
public:
C4TeamList() : ppList(NULL), iTeamCount(0), iTeamCapacity(0), iLastTeamID(0), fAllowHostilityChange(true), fAllowTeamSwitch(false),
C4TeamList() : ppList(nullptr), iTeamCount(0), iTeamCapacity(0), iLastTeamID(0), fAllowHostilityChange(true), fAllowTeamSwitch(false),
fActive(true), fCustom(false), fTeamColors(false), fAutoGenerateTeams(false), eTeamDist(TEAMDIST_Free), iMaxScriptPlayers(0) {}
~C4TeamList() { Clear(); }
void Clear();

View File

@ -52,7 +52,7 @@ C4Console::C4Console(): C4ConsoleGUI()
fGameOpen=false;
#ifdef USE_WIN32_WINDOWS
hWindow=NULL;
hWindow=nullptr;
#endif
}
@ -229,7 +229,7 @@ bool C4Console::FileSave()
{
// Save game
// FIXME: What about editing a savegame inplace? (Game.C4S.Head.SaveGame)
return SaveScenario(NULL);
return SaveScenario(nullptr);
}
bool C4Console::FileSaveAs(bool fSaveGame)
@ -501,7 +501,7 @@ void C4Console::UpdateNetMenu()
str.Format(LoadResStr("IDS_MNU_NETHOST"),Game.Clients.getLocalName(),Game.Clients.getLocalID());
AddNetMenuItemForPlayer(Game.Clients.getLocalID(), str.getData(), C4ConsoleGUI::CO_None);
// Clients
for (C4Network2Client *pClient=::Network.Clients.GetNextClient(NULL); pClient; pClient=::Network.Clients.GetNextClient(pClient))
for (C4Network2Client *pClient=::Network.Clients.GetNextClient(nullptr); pClient; pClient=::Network.Clients.GetNextClient(pClient))
{
if (pClient->isHost()) continue;
str.Format(LoadResStr(pClient->isActivated() ? "IDS_MNU_NETCLIENT_DEACTIVATE" : "IDS_MNU_NETCLIENT_ACTIVATE"),
@ -574,7 +574,7 @@ std::list<const char *> C4Console::GetScriptSuggestions(C4PropList *target, Rece
const std::list<StdCopyStrBuf> &mru = recent_script_input[section];
if (!mru.empty())
{
functions.insert(functions.begin(), NULL);
functions.insert(functions.begin(), nullptr);
// add pointers into string buffer list
// do not iterate with for (auto i : mru) because this would copy the buffer and add stack pointers
for (auto i = mru.begin(); i != mru.end(); ++i)

View File

@ -77,7 +77,7 @@ public:
bool FileSaveAs(bool fSaveGame);
bool FileSave();
bool FileNew();
bool FileOpen(const char *filename=NULL);
bool FileOpen(const char *filename=nullptr);
bool FileOpenWPlrs();
bool FileCommand();
bool FileClose();

View File

@ -86,7 +86,7 @@ void C4ConsoleGUI::SetInputFunctions(std::list<const char*> &functions)
C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
{
if (!state->CreateConsoleWindow(application)) return NULL;
if (!state->CreateConsoleWindow(application)) return nullptr;
Active = true;
EnableControls(fGameOpen);
return this;
@ -116,7 +116,7 @@ bool C4ConsoleGUI::ClearLog()
void C4ConsoleGUI::DisplayInfoText(InfoTextType type, StdStrBuf& text)
{
QLabel *target = NULL;
QLabel *target = nullptr;
switch (type)
{
case CONSOLE_Cursor: target = state->status_cursor; break;

View File

@ -84,7 +84,7 @@ void C4ConsoleQtDefinitionListModel::ReInit()
{
// Find if path is already there
RemoveExtension(&fn);
DefListNode *node_child = NULL;
DefListNode *node_child = nullptr;
for (auto &test_node_child : node_parent->items)
if (test_node_child->filename == fn)
{
@ -174,7 +174,7 @@ void C4ConsoleQtDefinitionListModel::OnItemRemoved(C4Def *p)
class C4Def *C4ConsoleQtDefinitionListModel::GetDefByModelIndex(const QModelIndex &idx)
{
DefListNode *node = static_cast<DefListNode *>(idx.internalPointer());
if (node) return node->def; else return NULL;
if (node) return node->def; else return nullptr;
}
const char *C4ConsoleQtDefinitionListModel::GetNameByModelIndex(const QModelIndex &idx)
@ -186,7 +186,7 @@ const char *C4ConsoleQtDefinitionListModel::GetNameByModelIndex(const QModelInde
int C4ConsoleQtDefinitionListModel::rowCount(const QModelIndex & parent) const
{
int result = 0;
DefListNode *parent_node = parent.isValid() ? static_cast<DefListNode *>(parent.internalPointer()) : NULL;
DefListNode *parent_node = parent.isValid() ? static_cast<DefListNode *>(parent.internalPointer()) : nullptr;
if (!parent_node) parent_node = root.get();
if (parent_node) result = parent_node->items.size();
return result;
@ -214,7 +214,7 @@ QModelIndex C4ConsoleQtDefinitionListModel::index(int row, int column, const QMo
{
// Current index out of range?
if (row < 0 || column != 0) return QModelIndex();
DefListNode *parent_node = parent.isValid() ? static_cast<DefListNode *>(parent.internalPointer()) : NULL;
DefListNode *parent_node = parent.isValid() ? static_cast<DefListNode *>(parent.internalPointer()) : nullptr;
if (!parent_node) parent_node = root.get();
if (parent_node->items.size() <= row) return QModelIndex();
// Index into tree

View File

@ -41,7 +41,7 @@ class C4ConsoleQtDefinitionListModel : public QAbstractItemModel
int32_t idx;
DefListNode *parent;
DefListNode() : def(NULL), idx(0), parent(NULL) {}
DefListNode() : def(nullptr), idx(0), parent(nullptr) {}
void SortByName(); // sort self and children
};
std::unique_ptr<DefListNode> root;

View File

@ -36,7 +36,7 @@ C4ConsoleQtDefinitionFileListModel::DefFileInfo::DefFileInfo(C4ConsoleQtDefiniti
}
C4ConsoleQtDefinitionFileListModel::DefFileInfo::DefFileInfo()
: parent(NULL), was_opened(true), is_root(true), selected(false), disabled(false)
: parent(nullptr), was_opened(true), is_root(true), selected(false), disabled(false)
{
// Init as root: List definitions in root paths
// Objects.ocd is always there (even if not actually found) and always first
@ -101,7 +101,7 @@ bool C4ConsoleQtDefinitionFileListModel::DefFileInfo::OpenGroup()
children.reserve(grp.EntryCount(C4CFN_DefFiles));
grp.ResetSearch();
while (grp.FindNextEntry(C4CFN_DefFiles, &child_filename))
children.emplace_back(new DefFileInfo(this, child_filename.getData(), NULL));
children.emplace_back(new DefFileInfo(this, child_filename.getData(), nullptr));
return true;
}
@ -114,7 +114,7 @@ int32_t C4ConsoleQtDefinitionFileListModel::DefFileInfo::GetChildCount()
C4ConsoleQtDefinitionFileListModel::DefFileInfo *C4ConsoleQtDefinitionFileListModel::DefFileInfo::GetChild(int32_t index)
{
if (!was_opened) OpenGroup();
if (index >= children.size()) return NULL;
if (index >= children.size()) return nullptr;
return children[index].get();
}
@ -351,7 +351,7 @@ void C4ConsoleQtNewScenarioDlg::BrowsePressed()
QString new_file;
for (;;)
{
new_file = QFileDialog::getSaveFileName(this, LoadResStr("IDS_CNS_NEWSCENARIO"), Config.General.UserDataPath, QString("%1 (%2)").arg(LoadResStr("IDS_CNS_SCENARIOFILE")).arg(C4CFN_ScenarioFiles), NULL, QFileDialog::DontConfirmOverwrite);
new_file = QFileDialog::getSaveFileName(this, LoadResStr("IDS_CNS_NEWSCENARIO"), Config.General.UserDataPath, QString("%1 (%2)").arg(LoadResStr("IDS_CNS_SCENARIOFILE")).arg(C4CFN_ScenarioFiles), nullptr, QFileDialog::DontConfirmOverwrite);
if (!new_file.size()) return;
// Extension must be .ocs
if (!new_file.endsWith(C4CFN_ScenarioFiles + 1)) new_file += (C4CFN_ScenarioFiles + 1);

View File

@ -39,7 +39,7 @@ C4ConsoleQtObjectListModel::C4ConsoleQtObjectListModel() : last_row_count(0)
C4ConsoleQtObjectListModel::~C4ConsoleQtObjectListModel()
{
::Console.ObjectListDlg.SetModel(NULL);
::Console.ObjectListDlg.SetModel(nullptr);
}
void C4ConsoleQtObjectListModel::Invalidate()

View File

@ -1252,7 +1252,7 @@ void C4PropertyDelegateEnum::UpdateEditorParameter(C4PropertyDelegateEnum::Edito
if (editor->parameter_widget)
{
editor->parameter_widget->deleteLater();
editor->parameter_widget = NULL;
editor->parameter_widget = nullptr;
}
editor->paint_parameter_delegate = nullptr;
int32_t idx = editor->last_selection_index;
@ -1926,7 +1926,7 @@ C4PropertyDelegateC4ValueEnum::C4PropertyDelegateC4ValueEnum(const C4PropertyDel
/* C4Value via an edit field delegate */
C4PropertyDelegateC4ValueInputEditor::C4PropertyDelegateC4ValueInputEditor(QWidget *parent)
: QWidget(parent), layout(NULL), edit(NULL), extended_button(NULL), commit_pending(false)
: QWidget(parent), layout(nullptr), edit(nullptr), extended_button(nullptr), commit_pending(false)
{
layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
@ -2363,7 +2363,7 @@ C4PropertyDelegate *C4PropertyDelegateFactory::GetDelegateByValue(const C4Value
C4PropertyDelegate *C4PropertyDelegateFactory::GetDelegateByIndex(const QModelIndex &index) const
{
C4ConsoleQtPropListModel::Property *prop = property_model->GetPropByIndex(index);
if (!prop) return NULL;
if (!prop) return nullptr;
if (!prop->delegate) prop->delegate = GetDelegateByValue(prop->delegate_info);
return prop->delegate;
}
@ -2418,7 +2418,7 @@ void C4PropertyDelegateFactory::SetPropertyData(const C4PropertyDelegate *d, QOb
QWidget *C4PropertyDelegateFactory::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
C4PropertyDelegate *d = GetDelegateByIndex(index);
if (!d) return NULL;
if (!d) return nullptr;
C4ConsoleQtPropListModel::Property *prop = property_model->GetPropByIndex(index);
prop->about_to_edit = true;
QWidget *editor = d->CreateEditor(this, parent, option, true, false);
@ -2950,7 +2950,7 @@ int32_t C4ConsoleQtPropListModel::UpdateValuePropList(C4PropList *target_proplis
internal_properties.props[i].help_text = nullptr;
internal_properties.props[i].priority = 0;
internal_properties.props[i].delegate_info.Set0(); // default C4Value delegate
internal_properties.props[i].delegate = NULL; // init when needed
internal_properties.props[i].delegate = nullptr; // init when needed
internal_properties.props[i].group_idx = num_groups;
internal_properties.props[i].shape.Clear();
internal_properties.props[i].shape_delegate = nullptr;
@ -3151,7 +3151,7 @@ QModelIndex C4ConsoleQtPropListModel::index(int row, int column, const QModelInd
}
if (parent.internalId()) return QModelIndex(); // No 3rd level depth
// Validate range of property
const PropertyGroup *property_group = NULL;
const PropertyGroup *property_group = nullptr;
if (parent.row() >= 0 && parent.row() < property_groups.size())
{
property_group = &property_groups[parent.row()];

View File

@ -368,7 +368,7 @@ public:
} storage_type;
int32_t priority; // Custom sort order
Option() : type(C4V_Any), adelegate(NULL), storage_type(StorageNone), priority(0) {}
Option() : type(C4V_Any), adelegate(nullptr), storage_type(StorageNone), priority(0) {}
};
protected:
@ -388,9 +388,9 @@ protected:
void ReserveOptions(int32_t num);
QStandardItemModel *CreateOptionModel() const;
public:
C4PropertyDelegateEnum(const class C4PropertyDelegateFactory *factory, C4PropList *props, const C4ValueArray *poptions=NULL);
C4PropertyDelegateEnum(const class C4PropertyDelegateFactory *factory, C4PropList *props, const C4ValueArray *poptions=nullptr);
void AddTypeOption(C4String *name, C4V_Type type, const C4Value &val, C4PropertyDelegate *adelegate=NULL);
void AddTypeOption(C4String *name, C4V_Type type, const C4Value &val, C4PropertyDelegate *adelegate=nullptr);
void AddConstOption(C4String *name, const C4Value &val, C4String *group=nullptr, C4String *sound_name=nullptr);
void SetEditorData(QWidget *editor, const C4Value &val, const C4PropertyPath &property_path) const override;

View File

@ -1210,13 +1210,13 @@ void C4ConsoleQtShapes::RemoveShape(C4ConsoleQtShape *shape)
{
// Remove from list and currently moving shape
shapes.remove_if([shape](auto &it) { return it.get() == shape; });
if (dragging_shape == shape) dragging_shape = NULL;
if (dragging_shape == shape) dragging_shape = nullptr;
}
void C4ConsoleQtShapes::ClearShapes()
{
shapes.clear();
dragging_shape = NULL;
dragging_shape = nullptr;
drag_cursor = Qt::CursorShape::ArrowCursor;
}

View File

@ -124,7 +124,7 @@ int ExecRecursionCheck::counter = 0;
/* Console main window */
C4ConsoleQtMainWindow::C4ConsoleQtMainWindow(C4AbstractApp *app, C4ConsoleGUIState *state)
: QMainWindow(NULL), state(state)
: QMainWindow(nullptr), state(state)
{
}
@ -482,7 +482,7 @@ void C4ConsoleQtMainWindow::WelcomeLinkActivated(const QString &link)
bool success = false;
#ifdef USE_WIN32_WINDOWS
StdStrBuf path(::Config.General.UserDataPath);
intptr_t iError = (intptr_t) ::ShellExecute(NULL, L"open", path.GetWideChar(), NULL, path.GetWideChar(), SW_SHOW);
intptr_t iError = (intptr_t) ::ShellExecute(nullptr, L"open", path.GetWideChar(), nullptr, path.GetWideChar(), SW_SHOW);
if (iError > 32) success = true;
#else
success = QDesktopServices::openUrl(QUrl::fromLocalFile(::Config.General.UserDataPath));
@ -578,7 +578,7 @@ void C4ConsoleQtMainWindow::GradeDown()
/* Common C4ConsoleGUI interface */
C4ConsoleGUIState::C4ConsoleGUIState(C4ConsoleGUI *console) : viewport_area(NULL),
C4ConsoleGUIState::C4ConsoleGUIState(C4ConsoleGUI *console) : viewport_area(nullptr),
enabled(false), recording(false), net_enabled(false), landscape_mode(LandscapeMode::Dynamic), flat_chunk_shapes(false),
editcursor_mode(C4CNS_ModePlay), drawing_tool(C4TLS_Brush), is_object_selection_updating(0), disable_shortcut_filter(new C4DisableShortcutFilter(nullptr))
{

View File

@ -378,7 +378,7 @@ void C4ConsoleQtViewportView::keyPressEvent(QKeyEvent * event)
handled = true;
}
// Handled if handled as player control or main editor
if (!handled) handled = Game.DoKeyboardInput(code, KEYEV_Down, !!(event->modifiers() & Qt::AltModifier), !!(event->modifiers() & Qt::ControlModifier), !!(event->modifiers() & Qt::ShiftModifier), event->isAutoRepeat(), NULL);
if (!handled) handled = Game.DoKeyboardInput(code, KEYEV_Down, !!(event->modifiers() & Qt::AltModifier), !!(event->modifiers() & Qt::ControlModifier), !!(event->modifiers() & Qt::ShiftModifier), event->isAutoRepeat(), nullptr);
if (!handled) handled = dock->main_window->HandleEditorKeyDown(event);
// Modifiers may update the cursor state; refresh
if (event->key() == Qt::Key_Shift || event->key() == Qt::Key_Control || event->key() == Qt::Key_Alt || event->key() == Qt::Key_AltGr)
@ -394,7 +394,7 @@ void C4ConsoleQtViewportView::keyReleaseEvent(QKeyEvent * event)
// Convert key to our internal mapping
C4KeyCode code = QtKeyToUnixScancode(*event);
// Handled if handled as player control
bool handled = Game.DoKeyboardInput(code, KEYEV_Up, !!(event->modifiers() & Qt::AltModifier), !!(event->modifiers() & Qt::ControlModifier), !!(event->modifiers() & Qt::ShiftModifier), event->isAutoRepeat(), NULL);
bool handled = Game.DoKeyboardInput(code, KEYEV_Up, !!(event->modifiers() & Qt::AltModifier), !!(event->modifiers() & Qt::ControlModifier), !!(event->modifiers() & Qt::ShiftModifier), event->isAutoRepeat(), nullptr);
if (!handled) handled = dock->main_window->HandleEditorKeyUp(event);
// Modifiers may update the cursor state; refresh
if (event->key() == Qt::Key_Shift || event->key() == Qt::Key_Control || event->key() == Qt::Key_Alt || event->key() == Qt::Key_AltGr)
@ -471,7 +471,7 @@ bool C4ConsoleQtViewportScrollArea::viewportEvent(QEvent *e)
void C4ConsoleQtViewportScrollArea::setupViewport(QWidget *viewport)
{
// Don't steal focus from the viewport. This is necessary to make keyboard input work.
viewport->setFocusProxy(NULL);
viewport->setFocusProxy(nullptr);
ScrollBarsByViewPosition();
}
@ -553,7 +553,7 @@ void C4ConsoleQtViewportDockWidget::closeEvent(QCloseEvent * event)
if (event->isAccepted())
{
if (cvp) cvp->Close();
cvp = NULL;
cvp = nullptr;
deleteLater();
}
}

View File

@ -93,17 +93,17 @@ public:
State(C4ConsoleGUI *console)
{
hbmMouse=NULL;
hbmMouse2=NULL;
hbmCursor=NULL;
hbmCursor2=NULL;
hbmBrush=NULL;
hbmBrush2=NULL;
hbmPlay=NULL;
hbmPlay2=NULL;
hbmHalt=NULL;
hbmHalt2=NULL;
hPropertyDlg=NULL;
hbmMouse=nullptr;
hbmMouse2=nullptr;
hbmCursor=nullptr;
hbmCursor2=nullptr;
hbmBrush=nullptr;
hbmBrush2=nullptr;
hbmPlay=nullptr;
hbmPlay2=nullptr;
hbmHalt=nullptr;
hbmHalt2=nullptr;
hPropertyDlg=nullptr;
MenuIndexFile = 0;
MenuIndexPlayer = 1;
MenuIndexViewport = 2;
@ -112,7 +112,7 @@ public:
property_dlg_inputarea_height = 0;
property_dlg_margin = 0;
property_dlg_okbutton_width = 0;
console_handle = NULL;
console_handle = nullptr;
console_default_width = 0;
console_default_height = 0;
console_margin = 0;
@ -202,21 +202,21 @@ public:
if (!::GetClientRect(hPropertyDlg, &rc)) return;
int y0 = rc.bottom - property_dlg_margin - property_dlg_inputarea_height;
// Output text box
::SetWindowPos(::GetDlgItem(hPropertyDlg, IDC_EDITOUTPUT), NULL,
::SetWindowPos(::GetDlgItem(hPropertyDlg, IDC_EDITOUTPUT), nullptr,
property_dlg_margin,
property_dlg_margin,
rc.right - 2* property_dlg_margin,
y0 - 2* property_dlg_margin,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// Input ComboBox
::SetWindowPos(::GetDlgItem(hPropertyDlg, IDC_COMBOINPUT), NULL,
::SetWindowPos(::GetDlgItem(hPropertyDlg, IDC_COMBOINPUT), nullptr,
property_dlg_margin,
y0,
rc.right - property_dlg_okbutton_width - 3*property_dlg_margin,
property_dlg_inputarea_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// OK button
::SetWindowPos(::GetDlgItem(hPropertyDlg, IDOK), NULL,
::SetWindowPos(::GetDlgItem(hPropertyDlg, IDOK), nullptr,
rc.right - property_dlg_margin - property_dlg_okbutton_width,
y0,
property_dlg_okbutton_width,
@ -256,75 +256,75 @@ public:
int y2 = rc.bottom - console_margin * 1 - console_button_height * 1;
int x0 = rc.right - console_margin - console_button_height;
// Output text box
::SetWindowPos(::GetDlgItem(console_handle, IDC_EDITOUTPUT), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_EDITOUTPUT), nullptr,
console_margin,
0,
x0 - console_margin - console_wide_margin,
y0 - console_margin,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// Input ComboBox
::SetWindowPos(::GetDlgItem(console_handle, IDC_COMBOINPUT), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_COMBOINPUT), nullptr,
console_margin,
y0,
rc.right - console_ok_button_width - console_margin * 3,
console_button_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// Input OK button
::SetWindowPos(::GetDlgItem(console_handle, IDOK), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDOK), nullptr,
rc.right - console_margin - console_ok_button_width,
y0,
console_ok_button_width,
console_button_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// Frame status bar
::SetWindowPos(::GetDlgItem(console_handle, IDC_STATICFRAME), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_STATICFRAME), nullptr,
console_margin,
y1,
console_status_width,
console_button_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// Play button
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONPLAY), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONPLAY), nullptr,
console_margin + console_status_width + console_wide_margin,
y1,
console_button_height,
console_button_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// Halt button
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONHALT), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONHALT), nullptr,
console_margin + console_status_width + console_wide_margin * 2 + console_button_height,
y1,
console_button_height,
console_button_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// Time/FPS status bar
::SetWindowPos(::GetDlgItem(console_handle, IDC_STATICTIME), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_STATICTIME), nullptr,
rc.right - console_margin - console_status_width,
y1,
console_status_width,
console_button_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// Main status bar
::SetWindowPos(::GetDlgItem(console_handle, IDC_STATICCURSOR), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_STATICCURSOR), nullptr,
console_margin,
y2,
rc.right - 2* console_margin,
console_button_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
// Tool buttons
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONMODEPLAY), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONMODEPLAY), nullptr,
x0,
console_margin,
console_button_height,
console_button_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONMODEEDIT), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONMODEEDIT), nullptr,
x0,
console_margin * 2 + console_button_height,
console_button_height,
console_button_height,
SWP_NOOWNERZORDER | SWP_NOZORDER);
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONMODEDRAW), NULL,
::SetWindowPos(::GetDlgItem(console_handle, IDC_BUTTONMODEDRAW), nullptr,
x0,
console_margin * 3 + console_button_height * 2,
console_button_height,
@ -339,7 +339,7 @@ static void ClearDlg(HWND &handle)
{
if (handle)
DestroyWindow(handle);
handle = NULL;
handle = nullptr;
}
INT_PTR CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
@ -525,7 +525,7 @@ public:
hbmStatic(0),
hbmExact(0)
{
pPreviewWindow = NULL;
pPreviewWindow = nullptr;
}
void LoadBitmaps(HINSTANCE instance)
@ -569,9 +569,9 @@ public:
if (pPreviewWindow)
{
delete pPreviewWindow;
pPreviewWindow = NULL;
pPreviewWindow = nullptr;
}
if (hDialog) DestroyWindow(hDialog); hDialog=NULL;
if (hDialog) DestroyWindow(hDialog); hDialog=nullptr;
}
void Default()
@ -785,7 +785,7 @@ bool C4ConsoleGUI::UpdateModeCtrls(int iMode)
C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
{
hWindow = CreateDialog(application->GetInstance(), MAKEINTRESOURCE(IDD_CONSOLE), NULL, ConsoleDlgProc);
hWindow = CreateDialog(application->GetInstance(), MAKEINTRESOURCE(IDD_CONSOLE), nullptr, ConsoleDlgProc);
if (!hWindow)
{
wchar_t * lpMsgBuf;
@ -793,16 +793,16 @@ C4Window* C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp *application)
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nullptr,
GetLastError(),
0,
(wchar_t *)&lpMsgBuf, // really.
0,
NULL);
nullptr);
Log(FormatString("Error creating dialog window: %s", StdStrBuf(lpMsgBuf).getData()).getData());
// Free the buffer.
LocalFree(lpMsgBuf);
return NULL;
return nullptr;
}
// Remember metrics
state->console_handle = hWindow;
@ -948,7 +948,7 @@ void C4ConsoleGUI::RecordingEnabled()
void C4ConsoleGUI::ShowAboutWithCopyright(StdStrBuf &copyright)
{
StdStrBuf strMessage; strMessage.Format("%s %s\n\n%s", C4ENGINECAPTION, C4VERSION, copyright.getData());
MessageBoxW(NULL, strMessage.GetWideChar(), ADDL(C4ENGINECAPTION), MB_ICONINFORMATION | MB_TASKMODAL);
MessageBoxW(nullptr, strMessage.GetWideChar(), ADDL(C4ENGINECAPTION), MB_ICONINFORMATION | MB_TASKMODAL);
}
bool C4ConsoleGUI::FileSelect(StdStrBuf *sFilename, const char * szFilter, DWORD dwFlags, bool fSave)
@ -966,7 +966,7 @@ bool C4ConsoleGUI::FileSelect(StdStrBuf *sFilename, const char * szFilter, DWORD
while (*s) s = s + strlen(s) + 1;
s++;
int n = s - szFilter;
int len = MultiByteToWideChar(CP_UTF8, 0, szFilter, n, NULL, 0);
int len = MultiByteToWideChar(CP_UTF8, 0, szFilter, n, nullptr, 0);
StdBuf filt;
filt.SetSize(len * sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, szFilter, n, getMBufPtr<wchar_t>(filt), len );
@ -986,7 +986,7 @@ bool C4ConsoleGUI::FileSelect(StdStrBuf *sFilename, const char * szFilter, DWORD
// Reset working directory to exe path as Windows file dialog might have changed it
SetCurrentDirectoryW(wd);
delete[] wd;
len = WideCharToMultiByte(CP_UTF8, 0, buffer, ArbitraryMaximumLength, NULL, 0, 0, 0);
len = WideCharToMultiByte(CP_UTF8, 0, buffer, ArbitraryMaximumLength, nullptr, 0, 0, 0);
sFilename->SetLength(len - 1);
WideCharToMultiByte(CP_UTF8, 0, buffer, ArbitraryMaximumLength, sFilename->getMData(), sFilename->getSize(), 0, 0);
return fResult;
@ -1120,7 +1120,7 @@ void C4ConsoleGUI::ClearPlayerMenu()
/*
void C4ConsoleGUI::ClearPropertyDlg(C4PropertyDlg *dlg)
{
if (dlg->state->hDialog) DestroyWindow(PropertyDlg.hDialog); PropertyDlg.hDialog=NULL;
if (dlg->state->hDialog) DestroyWindow(PropertyDlg.hDialog); PropertyDlg.hDialog=nullptr;
}
*/
@ -1130,7 +1130,7 @@ class C4ConsoleGUIPreviewWindow : public C4Window
public:
C4ConsoleGUIPreviewWindow(HWND hwndControl)
{
Init(C4Window::WindowKind::W_Control, &Application, NULL, NULL);
Init(C4Window::WindowKind::W_Control, &Application, nullptr, nullptr);
this->hWindow = this->renderwnd = hwndControl;
pSurface = new C4Surface(&Application, this);
}

View File

@ -80,12 +80,12 @@ C4Object *C4EditCursorSelection::GetObject(int32_t index) const
if ((obj = v.getObj()))
if (!index--)
return obj;
return NULL;
return nullptr;
}
C4Object *C4EditCursorSelection::GetLastObject() const
{
C4Object *obj, *last = NULL;
C4Object *obj, *last = nullptr;
for (const C4Value &v : (*this))
if ((obj = v.getObj()))
last = obj;
@ -94,7 +94,7 @@ C4Object *C4EditCursorSelection::GetLastObject() const
void C4EditCursorSelection::ConsolidateEmpty()
{
// remove NULLed entries that may happen because objects got deleted
// remove nullptred entries that may happen because objects got deleted
this->remove(C4VNull);
}
@ -148,7 +148,7 @@ void C4EditCursor::Execute()
case C4CNS_ModeEdit:
// Hold selection
if (Hold)
EMMoveObject(fShiftWasDown ? EMMO_MoveForced : EMMO_Move, Fix0, Fix0, NULL, &selection);
EMMoveObject(fShiftWasDown ? EMMO_MoveForced : EMMO_Move, Fix0, Fix0, nullptr, &selection);
break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4CNS_ModeDraw:
@ -182,7 +182,7 @@ bool C4EditCursor::Init()
void C4EditCursor::ClearPointers(C4Object *pObj)
{
if (Target==pObj) Target=NULL;
if (Target==pObj) Target=nullptr;
if (selection.ClearPointers(pObj))
OnSelectionChanged();
}
@ -256,10 +256,10 @@ bool C4EditCursor::Move(float iX, float iY, float iZoom, DWORD dwKeyState)
// Shift always indicates a target outside the current selection
else
{
Target = (dwKeyState & MK_SHIFT) ? selection.GetLastObject() : NULL;
Target = (dwKeyState & MK_SHIFT) ? selection.GetLastObject() : nullptr;
do
{
Target = Game.FindObject(NULL,X,Y,0,0,OCF_NotContained, Target);
Target = Game.FindObject(nullptr,X,Y,0,0,OCF_NotContained, Target);
}
while ((dwKeyState & MK_SHIFT) && Target && selection.IsContained(Target));
}
@ -438,7 +438,7 @@ bool C4EditCursor::LeftButtonDown(DWORD dwKeyState)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}
DropTarget=NULL;
DropTarget=nullptr;
return true;
}
@ -515,7 +515,7 @@ bool C4EditCursor::LeftButtonUp(DWORD dwKeyState)
DragLine=false;
DragShape = false;
DragTransform = false;
DropTarget=NULL;
DropTarget=nullptr;
// Update
UpdateStatusBar();
return true;
@ -588,7 +588,7 @@ bool SetMenuItemText(HMENU hMenu, WORD id, const char *szText)
bool C4EditCursor::RightButtonUp(DWORD dwKeyState)
{
Target=NULL;
Target=nullptr;
#ifndef WITH_QT_EDITOR
DoContextMenu(dwKeyState);
#endif
@ -601,7 +601,7 @@ bool C4EditCursor::RightButtonUp(DWORD dwKeyState)
bool C4EditCursor::Delete()
{
if (!EditingOK()) return false;
EMMoveObject(EMMO_Remove, Fix0, Fix0, NULL, &selection);
EMMoveObject(EMMO_Remove, Fix0, Fix0, nullptr, &selection);
if (::Control.isCtrlHost())
{
OnSelectionChanged();
@ -626,7 +626,7 @@ bool C4EditCursor::OpenPropTools()
bool C4EditCursor::Duplicate()
{
EMMoveObject(EMMO_Duplicate, Fix0, Fix0, NULL, &selection);
EMMoveObject(EMMO_Duplicate, Fix0, Fix0, nullptr, &selection);
return true;
}
@ -883,7 +883,7 @@ void C4EditCursor::Draw(C4TargetFacet &cgo)
creator_overlay.reset(new C4GraphicsOverlay());
creator_overlay->SetAsBase(&creator_def->Graphics, C4GFXBLIT_ADDITIVE);
}
creator_overlay->Draw(cgo_creator, NULL, NO_OWNER);
creator_overlay->Draw(cgo_creator, nullptr, NO_OWNER);
}
// Draw object highlight
C4Object *highlight = highlighted_object.getObj();
@ -930,13 +930,13 @@ void C4EditCursor::DrawSelectMark(C4Facet &cgo, FLOAT_RECT frame, float width, u
const unsigned int n_vertices = sizeof(vertices) / sizeof(vertices[0]);
pDraw->PerformMultiLines(cgo.Surface, vertices, n_vertices, width, NULL);
pDraw->PerformMultiLines(cgo.Surface, vertices, n_vertices, width, nullptr);
}
void C4EditCursor::MoveSelection(C4Real XOff, C4Real YOff)
{
EMMoveObject(fShiftWasDown ? EMMO_MoveForced : EMMO_Move, XOff, YOff, NULL, &selection);
EMMoveObject(fShiftWasDown ? EMMO_MoveForced : EMMO_Move, XOff, YOff, nullptr, &selection);
}
void C4EditCursor::FrameSelection()
@ -956,7 +956,7 @@ void C4EditCursor::FrameSelection()
bool C4EditCursor::In(const char *szText)
{
::Console.RegisterRecentInput(szText, C4Console::MRU_Object);
EMMoveObject(EMMO_Script, Fix0, Fix0, NULL, &selection, szText);
EMMoveObject(EMMO_Script, Fix0, Fix0, nullptr, &selection, szText);
selection.ConsolidateEmpty();
::Console.PropertyDlgUpdate(selection, true);
return true;
@ -968,14 +968,14 @@ void C4EditCursor::Default()
fShiftWasDown=false;
Mode = C4CNS_ModeEdit;
X=Y=X2=Y2=0;
Target=DropTarget=NULL;
Target=DropTarget=nullptr;
#ifdef USE_WIN32_WINDOWS
hMenu=NULL;
hMenu=nullptr;
#endif
Hold=DragFrame=DragLine=DragShape=DragTransform=false;
selection.clear();
creator_def = NULL;
creator_overlay = NULL;
creator_def = nullptr;
creator_overlay = nullptr;
has_mouse_hover = false;
selection_invalid = false;
DragRot0 = DragRotLast = 0; DragCon0 = DragConLast = FullCon;
@ -984,14 +984,14 @@ void C4EditCursor::Default()
void C4EditCursor::Clear()
{
#ifdef USE_WIN32_WINDOWS
if (hMenu) DestroyMenu(hMenu); hMenu=NULL;
if (hMenu) DestroyMenu(hMenu); hMenu=nullptr;
#endif
#ifdef WITH_DEBUG_MODE
ObjselectDelItems();
#endif
selection.clear();
Console.PropertyDlgUpdate(selection, false);
creator_overlay.reset(NULL);
creator_overlay.reset(nullptr);
#ifdef WITH_QT_EDITOR
shapes->ClearShapes(); // Should really be empty already
#endif
@ -1100,7 +1100,7 @@ void C4EditCursor::ApplyToolFill()
if (!EditingOK(true)) return;
C4ToolsDlg *pTools=&Console.ToolsDlg;
// execute/send control
EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Fill, ::Landscape.GetMode(), X,Y,0,Y2, pTools->Grade, pTools->Material, NULL, NULL, NULL));
EMControl(CID_EMDrawTool, new C4ControlEMDrawTool(EMDT_Fill, ::Landscape.GetMode(), X,Y,0,Y2, pTools->Grade, pTools->Material, nullptr, nullptr, nullptr));
}
void C4EditCursor::AppendMenuItem(int num, const StdStrBuf & label)
@ -1110,7 +1110,7 @@ void C4EditCursor::AppendMenuItem(int num, const StdStrBuf & label)
if (num)
AppendMenu(GetSubMenu(hMenu,0), MF_STRING, IDM_VPORTDYN_FIRST + num, label.GetWideChar());
else
AppendMenu(GetSubMenu(hMenu,0), MF_SEPARATOR, IDM_VPORTDYN_FIRST, NULL);
AppendMenu(GetSubMenu(hMenu,0), MF_SEPARATOR, IDM_VPORTDYN_FIRST, nullptr);
#endif
}
@ -1153,7 +1153,7 @@ bool C4EditCursor::DoContextMenu(DWORD dwKeyState)
#endif
itemsObjselect.resize(entrycount + 1); // +1 for a separator
// Add a separator bar
itemsObjselect[0].Object = NULL;
itemsObjselect[0].Object = nullptr;
itemsObjselect[0].Command.Clear();
itemsObjselect[0].EditCursor = this;
AppendMenuItem(0, StdStrBuf());
@ -1196,7 +1196,7 @@ bool C4EditCursor::DoContextMenu(DWORD dwKeyState)
{
AppendMenu(hContext, MF_GRAYED, IDM_VPORTDYN_FIRST + maxentries + 1, L"...");
itemsObjselect[maxentries + 1].ItemId = IDM_VPORTDYN_FIRST + maxentries + 1;
itemsObjselect[maxentries + 1].Object = NULL;
itemsObjselect[maxentries + 1].Object = nullptr;
itemsObjselect[maxentries + 1].Command.Clear();
}
#endif
@ -1209,7 +1209,7 @@ bool C4EditCursor::DoContextMenu(DWORD dwKeyState)
TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_NONOTIFY,
point.x,point.y, 0,
Console.hWindow,
NULL);
nullptr);
switch (iItem)
{
case IDM_VIEWPORT_DELETE: Delete(); break;
@ -1244,13 +1244,13 @@ void C4EditCursor::GrabContents()
Hold=true;
// Exit all objects
EMMoveObject(EMMO_Exit, Fix0, Fix0, NULL, &selection);
EMMoveObject(EMMO_Exit, Fix0, Fix0, nullptr, &selection);
}
void C4EditCursor::UpdateDropTarget(DWORD dwKeyState)
{
// A drop target is set if holding down control either while moving an object or in object creation mode
DropTarget=NULL;
DropTarget=nullptr;
if (dwKeyState & MK_CONTROL)
if (selection.GetObject() || (Mode == C4CNS_ModeCreateObject && creator_def))
@ -1364,7 +1364,7 @@ void C4EditCursor::ApplyToolPicker()
void C4EditCursor::EMMoveObject(C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj, const C4EditCursorSelection *pObjs, const char *szScript)
{
// construct object list
int32_t iObjCnt = 0; int32_t *pObjIDs = NULL;
int32_t iObjCnt = 0; int32_t *pObjIDs = nullptr;
if (pObjs && (iObjCnt = pObjs->ObjectCount()))
{
pObjIDs = new int32_t [iObjCnt];

View File

@ -35,7 +35,7 @@ public:
StdStrBuf GetDataString() const; // Return a string like "n objects".
C4Object *GetObject(int32_t index=0) const; // Get indexed C4Object * in list
C4Object *GetLastObject() const;
void ConsolidateEmpty(); // remove NULLed entries that may happen because objects got deleted
void ConsolidateEmpty(); // remove nullptred entries that may happen because objects got deleted
bool ClearPointers(C4Object *obj);
bool IsContained(C4PropList *obj) const;
int32_t ObjectCount() const; // count only C4Object *
@ -131,7 +131,7 @@ protected:
bool HasTransformMarker(float *x, float *y, float zoom) const;
void FrameSelection();
void MoveSelection(C4Real iXOff, C4Real iYOff);
void EMMoveObject(enum C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj, const C4EditCursorSelection *pObjs = NULL, const char *szScript = NULL);
void EMMoveObject(enum C4ControlEMObjectAction eAction, C4Real tx, C4Real ty, C4Object *pTargetObj, const C4EditCursorSelection *pObjs = nullptr, const char *szScript = nullptr);
void DoContextObjCommand(C4Object *, const char *cmd);
void ObjselectDelItems();
@ -144,9 +144,9 @@ protected:
public:
void AddToSelection(C4PropList *add_obj); // add object to selection and do script callback. Doesn't do OnSelectionChanged().
bool RemoveFromSelection(C4PropList *remove_obj); // remove object from selection and do script callback. return true if object was in selection before. Doesn't do OnSelectionChanged().
void ClearSelection(C4PropList *next_selection=NULL); // remove all objects from selection and do script callback. if next_selection is non-null, passes that to the deselection callbacks. Doesn't do OnSelectionChanged().
void ClearSelection(C4PropList *next_selection=nullptr); // remove all objects from selection and do script callback. if next_selection is non-null, passes that to the deselection callbacks. Doesn't do OnSelectionChanged().
// Type of object to create in object creation mode
void SetCreatorDef(C4Def *new_def) { creator_def = new_def; creator_overlay.reset(NULL); }
void SetCreatorDef(C4Def *new_def) { creator_def = new_def; creator_overlay.reset(nullptr); }
C4Def *GetCreatorDef() { return creator_def; }
void EMControl(enum C4PacketType eCtrlType, class C4ControlPacket *pCtrl);

View File

@ -145,7 +145,7 @@ bool C4ToolsDlg::SetIFT(bool fIFT)
{
BYTE bg_index = ::TextureMap.DefaultBkgMatTex(index);
const C4TexMapEntry* entry = ::TextureMap.GetEntry(bg_index);
if (entry != NULL)
if (entry != nullptr)
{
SCopy(entry->GetMaterialName(), BackMaterial, C4M_MaxName);
SCopy(entry->GetTextureName(), BackTexture, C4M_MaxName);

View File

@ -54,9 +54,9 @@ C4Application::C4Application():
CheckForUpdates(false),
restartAtEnd(false),
is_in_game_tick(false),
pGamePadControl(NULL),
pGamePadControl(nullptr),
AppState(C4AS_None),
pGameTimer(NULL)
pGameTimer(nullptr)
{
}
@ -152,7 +152,7 @@ bool C4Application::DoInit(int argc, char * argv[])
// Windows: handle incoming updates directly, even before starting up the gui
// because updates will be applied in the console anyway.
if (Application.IncomingUpdate)
if (C4UpdateDlg::ApplyUpdate(Application.IncomingUpdate.getData(), false, NULL))
if (C4UpdateDlg::ApplyUpdate(Application.IncomingUpdate.getData(), false, nullptr))
return true;
#endif
@ -592,7 +592,7 @@ void C4Application::Clear()
if (pGameTimer)
{
Remove(pGameTimer);
delete pGameTimer; pGameTimer = NULL;
delete pGameTimer; pGameTimer = nullptr;
}
// quit irc
IRCClient.Close();
@ -605,7 +605,7 @@ void C4Application::Clear()
Languages.Clear();
Languages.ClearLanguage();
// gamepad clear
if (pGamePadControl) { delete pGamePadControl; pGamePadControl=NULL; }
if (pGamePadControl) { delete pGamePadControl; pGamePadControl=nullptr; }
// music system clear
MusicSystem.Clear();
SoundSystem.Clear();
@ -613,7 +613,7 @@ void C4Application::Clear()
// clear editcursor holding graphics before clearing draw
::Console.EditCursor.Clear();
// Clear direct draw (late, because it's needed for e.g. Log)
if (pDraw) { delete pDraw; pDraw=NULL; }
if (pDraw) { delete pDraw; pDraw=nullptr; }
// Close window
FullScreen.Clear();
Console.Clear();

View File

@ -37,7 +37,7 @@ void C4FullScreen::CharIn(const char * c) { ::pGUI->CharIn(c); }
C4FullScreen::C4FullScreen()
{
pMenu = NULL;
pMenu = nullptr;
}
C4FullScreen::~C4FullScreen()
@ -161,7 +161,7 @@ void C4FullScreen::CloseMenu()
{
if (pMenu->IsActive()) pMenu->Close(false);
delete pMenu;
pMenu = NULL;
pMenu = nullptr;
}
}

View File

@ -127,11 +127,11 @@ bool C4Game::InitDefs()
Log(LoadResStr("IDS_PRC_INITDEFS"));
int iDefResCount = 0;
C4GameRes *pDef;
for (pDef = Parameters.GameRes.iterRes(NULL, NRT_Definitions); pDef; pDef = Parameters.GameRes.iterRes(pDef, NRT_Definitions))
for (pDef = Parameters.GameRes.iterRes(nullptr, NRT_Definitions); pDef; pDef = Parameters.GameRes.iterRes(pDef, NRT_Definitions))
++iDefResCount;
int i = 0;
// Load specified defs
for (pDef = Parameters.GameRes.iterRes(NULL, NRT_Definitions); pDef; pDef = Parameters.GameRes.iterRes(pDef, NRT_Definitions))
for (pDef = Parameters.GameRes.iterRes(nullptr, NRT_Definitions); pDef; pDef = Parameters.GameRes.iterRes(pDef, NRT_Definitions))
{
int iMinProgress = 25 + (25 * i) / iDefResCount;
int iMaxProgress = 25 + (25 * (i + 1)) / iDefResCount;
@ -269,7 +269,7 @@ void C4Game::CloseScenario()
// close scenario
ScenarioFile.Close();
GroupSet.CloseFolders();
pParentGroup = NULL;
pParentGroup = nullptr;
// remove if temporary
if (TempScenarioFile)
{
@ -279,7 +279,7 @@ void C4Game::CloseScenario()
// clear scenario section
// this removes any temp files, which may yet need to be used by any future features
// so better don't do this too early (like, in C4Game::Clear)
if (pScenarioSections) { delete pScenarioSections; pScenarioSections=pCurrentScenarioSection=NULL;}
if (pScenarioSections) { delete pScenarioSections; pScenarioSections=pCurrentScenarioSection=nullptr;}
}
@ -290,7 +290,7 @@ bool C4Game::PreInit()
// the function may return false, if no extra group is present - that is OK
Extra.InitGroup();
RandomSeed = time(NULL);
RandomSeed = time(nullptr);
// Randomize
FixRandom(RandomSeed);
// Timer flags
@ -347,7 +347,7 @@ bool C4Game::Init()
C4GameLobby::UserAbort = false;
// Store a start time that identifies this game on this host
StartTime = time(NULL);
StartTime = time(nullptr);
// Get PlayerFilenames from Config, if ParseCommandLine did not fill some in
// Must be done here, because InitGame calls PlayerInfos.InitLocal
@ -504,7 +504,7 @@ bool C4Game::Init()
if (GraphicsSystem.pLoaderScreen)
{
delete GraphicsSystem.pLoaderScreen;
GraphicsSystem.pLoaderScreen=NULL;
GraphicsSystem.pLoaderScreen=nullptr;
}
// game running now!
@ -614,7 +614,7 @@ void C4Game::Clear()
::Messages.Clear();
MessageInput.Clear();
SetGlobalSoundModifier(NULL); // must be called before script engine clear
SetGlobalSoundModifier(nullptr); // must be called before script engine clear
Application.SoundSystem.Modifiers.Clear(); // free some prop list pointers
// Clear script engine
@ -623,7 +623,7 @@ void C4Game::Clear()
::GameScript.Clear();
C4PropListNumbered::ClearShelve(); // may be nonempty if there was a fatal error during section load
ScriptEngine.Clear();
pScenarioObjectsScript = NULL;
pScenarioObjectsScript = nullptr;
// delete any remaining prop lists from circular chains
C4PropListNumbered::ClearNumberedPropLists();
C4PropListScript::ClearScriptPropLists();
@ -819,7 +819,7 @@ bool C4Game::InitMaterialTexture()
bool fHaveScenMaterials = Game.ScenarioFile.FindEntry(C4CFN_Material);
// Load all materials
C4GameRes *pMatRes = NULL;
C4GameRes *pMatRes = nullptr;
bool fFirst = true, fOverloadMaterials = true, fOverloadTextures = true;
long tex_count = 0, mat_count = 0;
while (fOverloadMaterials || fOverloadTextures)
@ -1019,7 +1019,7 @@ C4Object* C4Game::NewObject( C4PropList *pDef, C4Object *pCreator,
int32_t iCon, int32_t iController, bool grow_from_center)
{
// Safety
if (!pDef) return NULL;
if (!pDef) return nullptr;
if (Config.General.DebugRec)
{
C4RCCreateObj rc;
@ -1031,21 +1031,21 @@ C4Object* C4Game::NewObject( C4PropList *pDef, C4Object *pCreator,
}
// Create object
C4Object *pObj;
if (!(pObj=new C4Object)) return NULL;
if (!(pObj=new C4Object)) return nullptr;
// Initialize object
pObj->Init( pDef,pCreator,iOwner,pInfo,iX,iY,iR,xdir,ydir,rdir, iController );
// Add to object list
if (!Objects.Add(pObj)) { delete pObj; return NULL; }
if (!Objects.Add(pObj)) { delete pObj; return nullptr; }
// ---- From now on, object is ready to be used in scripts!
// Construction callback
C4AulParSet pars(pCreator);
pObj->Call(PSF_Construction, &pars);
// AssignRemoval called? (Con 0)
if (!pObj->Status) { return NULL; }
if (!pObj->Status) { return nullptr; }
// Do initial con (grow)
pObj->DoCon(iCon, grow_from_center);
// AssignRemoval called? (Con 0)
if (!pObj->Status) { return NULL; }
if (!pObj->Status) { return nullptr; }
// Success
return pObj;
}
@ -1064,10 +1064,10 @@ C4Object* C4Game::CreateObject(C4ID id, C4Object *pCreator, int32_t iOwner,
{
C4Def *pDef;
// Get pDef
if (!(pDef=C4Id2Def(id))) return NULL;
if (!(pDef=C4Id2Def(id))) return nullptr;
// Create object
return NewObject(pDef,pCreator,
iOwner,NULL,
iOwner,nullptr,
x,y,r,
xdir,ydir,rdir,
FullCon, iController, grow_from_center);
@ -1078,10 +1078,10 @@ C4Object* C4Game::CreateObject(C4PropList * PropList, C4Object *pCreator, int32_
C4Real xdir, C4Real ydir, C4Real rdir, int32_t iController)
{
// check Definition
if (!PropList || !PropList->GetDef()) return NULL;
if (!PropList || !PropList->GetDef()) return nullptr;
// Create object
return NewObject(PropList,pCreator,
iOwner,NULL,
iOwner,nullptr,
x,y,r,
xdir,ydir,rdir,
FullCon, iController, grow_from_center);
@ -1092,11 +1092,11 @@ C4Object* C4Game::CreateInfoObject(C4ObjectInfo *cinf, int32_t iOwner,
{
C4Def *def;
// Valid check
if (!cinf) return NULL;
if (!cinf) return nullptr;
// Get def
if (!(def=C4Id2Def(cinf->id))) return NULL;
if (!(def=C4Id2Def(cinf->id))) return nullptr;
// Create object
return NewObject( def,NULL,
return NewObject( def,nullptr,
iOwner,cinf,
tx,ty,0,
Fix0,Fix0,Fix0,
@ -1114,8 +1114,8 @@ C4Object* C4Game::CreateObjectConstruction(C4PropList * PropList,
C4Object *pObj;
// Get def
if (!PropList) return NULL;
if (!(pDef=PropList->GetDef())) return NULL;
if (!PropList) return nullptr;
if (!(pDef=PropList->GetDef())) return nullptr;
int32_t dx,dy,dwdt,dhgt;
dwdt=pDef->Shape.Wdt; dhgt=pDef->Shape.Hgt;
@ -1134,10 +1134,10 @@ C4Object* C4Game::CreateObjectConstruction(C4PropList * PropList,
// Create object
if (!(pObj=NewObject(PropList,
pCreator,
iOwner,NULL,
iOwner,nullptr,
iX,iBY,0,
Fix0,Fix0,Fix0,
iCon, pCreator ? pCreator->Controller : NO_OWNER, false))) return NULL;
iCon, pCreator ? pCreator->Controller : NO_OWNER, false))) return nullptr;
return pObj;
}
@ -1156,7 +1156,7 @@ C4Object* C4Game::FindConstuctionSiteBlock(int32_t tx, int32_t ty, int32_t wdt,
rect2=cObj->Shape; rect2.x+=cObj->GetX(); rect2.y+=cObj->GetY();
if (rect1.Overlap(rect2)) return cObj;
}
return NULL;
return nullptr;
}
C4Object* C4Game::FindObject(C4Def * pDef,
@ -1165,18 +1165,18 @@ C4Object* C4Game::FindObject(C4Def * pDef,
C4Object *pFindNext)
{
C4Object *pClosest=NULL;
C4Object *pClosest=nullptr;
int32_t iClosest = 0,iDistance,iFartherThan=-1;
C4Object *pFindNextCpy=pFindNext;
// check the easy case first: no instances at all?
if (pDef && !pDef->Count) return NULL;
if (pDef && !pDef->Count) return nullptr;
// Finding next closest: find closest but further away than last closest
if (pFindNext && (iWdt==-1) && (iHgt==-1))
{
iFartherThan = (pFindNext->GetX()-iX)*(pFindNext->GetX()-iX)+(pFindNext->GetY()-iY)*(pFindNext->GetY()-iY);
pFindNext = NULL;
pFindNext = nullptr;
}
// Scan all objects
@ -1218,7 +1218,7 @@ C4Object* C4Game::FindObject(C4Def * pDef,
}
// Find next mark reached
if (cObj == pFindNextCpy) pFindNext = pFindNextCpy = NULL;
if (cObj == pFindNextCpy) pFindNext = pFindNextCpy = nullptr;
}
@ -1232,7 +1232,7 @@ C4Object *C4Game::FindVisObject(float tx, float ty, int32_t iPlr, const C4Facet
// FIXME: Use C4FindObject here for optimization
// -- can't really do that, since sectors ignore parallaxity, etc.
// determine layer to search in
C4Object *layer_object = NULL;
C4Object *layer_object = nullptr;
C4Player *plr = ::Players.Get(iPlr);
if (plr && plr->Cursor) layer_object = plr->Cursor->Layer;
// scan all object lists separately
@ -1283,11 +1283,11 @@ C4Object *C4Game::FindVisObject(float tx, float ty, int32_t iPlr, const C4Facet
}
// next list
if (pLst == &::Objects.ForeObjects) pLst = &Objects;
else pLst = NULL;
else pLst = nullptr;
}
// none found
return NULL;
return nullptr;
}
int32_t C4Game::ObjectCount(C4ID id)
@ -1401,7 +1401,7 @@ bool C4Game::DropDef(C4ID id, float X, float Y)
C4Def *pDef;
if ((pDef=C4Id2Def(id)))
{
::Control.DoInput(CID_EMMoveObj, C4ControlEMMoveObject::CreateObject(id, ftofix(X), ftofix(Y), NULL), CDT_Decide);
::Control.DoInput(CID_EMMoveObj, C4ControlEMMoveObject::CreateObject(id, ftofix(X), ftofix(Y), nullptr), CDT_Decide);
return true;
}
else
@ -1455,7 +1455,7 @@ void C4Game::Default()
PlayerFilenames[0]=0;
DefinitionFilenames[0]=0;
DirectJoinAddress[0]=0;
pJoinReference=NULL;
pJoinReference=nullptr;
StartupPlayerCount=0;
StartupTeamCount = 0;
ScenarioTitle.Ref("");
@ -1490,8 +1490,8 @@ void C4Game::Default()
PathFinder.Default();
TransferZones.Default();
GroupSet.Default();
pParentGroup=NULL;
pScenarioSections=pCurrentScenarioSection=NULL;
pParentGroup=nullptr;
pScenarioSections=pCurrentScenarioSection=nullptr;
*CurrentScenarioSection=0;
fResortAnyObject=false;
pNetworkStatistics.reset();
@ -1513,7 +1513,7 @@ void C4Game::Evaluate()
// Stop record
StdStrBuf RecordName; BYTE RecordSHA[SHA_DIGEST_LENGTH];
if (Control.isRecord())
Control.StopRecord(&RecordName, fLeague ? RecordSHA : NULL);
Control.StopRecord(&RecordName, fLeague ? RecordSHA : nullptr);
// Send league result
if (fLeague)
@ -2203,7 +2203,7 @@ bool C4Game::InitGame(C4Group &hGroup, InitMode init_mode, bool fLoadSky, C4Valu
}
// Load section sounds
Application.SoundSystem.LoadEffects(hGroup, NULL, true);
Application.SoundSystem.LoadEffects(hGroup, nullptr, true);
// determine startup player and team count, which may be used for initial map generation
if (!FrameCounter)
@ -2390,7 +2390,7 @@ bool C4Game::InitScriptEngine()
// get scripts
char fn[_MAX_FNAME+1] = { 0 };
File.ResetSearch();
while (File.FindNextEntry(C4CFN_ScriptFiles, fn, NULL, !!fn[0]))
while (File.FindNextEntry(C4CFN_ScriptFiles, fn, nullptr, !!fn[0]))
{
// host will be destroyed by script engine, so drop the references
C4ScriptHost *scr = new C4ExtraScriptHost();
@ -2610,7 +2610,7 @@ bool C4Game::PlaceInEarth(C4ID id)
{
tx=Random(::Landscape.GetWidth()); ty=Random(::Landscape.GetHeight());
if (GBackMat(tx,ty)==MEarth)
if (CreateObject(id,NULL,NO_OWNER,tx,ty,Random(360)))
if (CreateObject(id,nullptr,NO_OWNER,tx,ty,Random(360)))
return true;
}
return false;
@ -2656,7 +2656,7 @@ C4Object* C4Game::PlaceVegetation(C4PropList * PropList, int32_t iX, int32_t iY,
// Get definition
C4Def* pDef;
if (!PropList || !(pDef = PropList->GetDef())) return NULL;
if (!PropList || !(pDef = PropList->GetDef())) return nullptr;
// No growth specified: full growth
if (iGrowth<=0)
@ -2693,7 +2693,7 @@ C4Object* C4Game::PlaceVegetation(C4PropList * PropList, int32_t iX, int32_t iY,
if (iMaterial!=MNone) if (::MaterialMap.Map[iMaterial].Soil)
{
iTy+=5;
return CreateObjectConstruction(PropList,NULL,NO_OWNER,iTx,iTy,iGrowth);
return CreateObjectConstruction(PropList,nullptr,NO_OWNER,iTx,iTy,iGrowth);
}
}
break;
@ -2701,18 +2701,18 @@ C4Object* C4Game::PlaceVegetation(C4PropList * PropList, int32_t iX, int32_t iY,
// Underwater
case C4D_Place_Liquid:
// Random range
if (!PlaceVegetation_GetRandomPoint(iX, iY, iWdt, iHgt, shape_proplist, out_pos_proplist, &iTx, &iTy)) return NULL;
if (!PlaceVegetation_GetRandomPoint(iX, iY, iWdt, iHgt, shape_proplist, out_pos_proplist, &iTx, &iTy)) return nullptr;
// Find liquid
if (!FindSurfaceLiquid(iTx,iTy,pDef->Shape.Wdt,pDef->Shape.Hgt))
if (!FindLiquid(iTx,iTy,pDef->Shape.Wdt,pDef->Shape.Hgt))
return NULL;
return nullptr;
// Liquid bottom
if (!SemiAboveSolid(iTx,iTy)) return NULL;
if (!SemiAboveSolid(iTx,iTy)) return nullptr;
iTy+=3;
// Still inside bounds?
if (!PlaceVegetation_IsPosInBounds(iTx, iTy, iX, iY, iWdt, iHgt, shape_proplist)) return NULL;
if (!PlaceVegetation_IsPosInBounds(iTx, iTy, iX, iY, iWdt, iHgt, shape_proplist)) return nullptr;
// Create object
return CreateObjectConstruction(PropList,NULL,NO_OWNER,iTx,iTy,iGrowth);
return CreateObjectConstruction(PropList,nullptr,NO_OWNER,iTx,iTy,iGrowth);
break;
// Underground/Tunnel
@ -2735,7 +2735,7 @@ C4Object* C4Game::PlaceVegetation(C4PropList * PropList, int32_t iX, int32_t iY,
{
// Create object
iTy+=5;
return CreateObjectConstruction(PropList,NULL,NO_OWNER,iTx,iTy,iGrowth);
return CreateObjectConstruction(PropList,nullptr,NO_OWNER,iTx,iTy,iGrowth);
}
}
@ -2763,20 +2763,20 @@ C4Object* C4Game::PlaceVegetation(C4PropList * PropList, int32_t iX, int32_t iY,
if (iMaterial!=MNone) if (::MaterialMap.Map[iMaterial].Soil)
{
iTy+=5;
return CreateObjectConstruction(PropList,NULL,NO_OWNER,iTx,iTy,iGrowth);
return CreateObjectConstruction(PropList,nullptr,NO_OWNER,iTx,iTy,iGrowth);
}
}
}
// Undefined placement type
return NULL;
return nullptr;
}
C4Object* C4Game::PlaceAnimal(C4PropList* PropList)
{
C4Def * pDef;
if (!PropList || !(pDef = PropList->GetDef())) return NULL;
if (!PropList || !(pDef = PropList->GetDef())) return nullptr;
int32_t iX,iY;
// Placement
switch (PropList->GetPropertyInt(P_Placement))
@ -2784,28 +2784,28 @@ C4Object* C4Game::PlaceAnimal(C4PropList* PropList)
// Running free
case C4D_Place_Surface:
iX=Random(::Landscape.GetWidth()); iY=Random(::Landscape.GetHeight());
if (!FindSolidGround(iX,iY,pDef->Shape.Wdt)) return NULL;
if (!FindSolidGround(iX,iY,pDef->Shape.Wdt)) return nullptr;
break;
// In liquid
case C4D_Place_Liquid:
iX=Random(::Landscape.GetWidth()); iY=Random(::Landscape.GetHeight());
if (!FindSurfaceLiquid(iX,iY,pDef->Shape.Wdt,pDef->Shape.Hgt))
if (!FindLiquid(iX,iY,pDef->Shape.Wdt,pDef->Shape.Hgt))
return NULL;
return nullptr;
iY+=pDef->Shape.Hgt/2;
break;
// Floating in air
case C4D_Place_Air:
iX=Random(::Landscape.GetWidth());
for (iY=0; (iY<::Landscape.GetHeight()) && !GBackSemiSolid(iX,iY); iY++) {}
if (iY<=0) return NULL;
if (iY<=0) return nullptr;
iY=Random(iY);
break;
default:
return NULL;
return nullptr;
}
// Create object
return CreateObject(PropList,NULL,NO_OWNER,iX,iY);
return CreateObject(PropList,nullptr,NO_OWNER,iX,iY);
}
void C4Game::InitInEarth()
@ -2836,7 +2836,7 @@ void C4Game::InitVegetation()
// Place vegetation
if (vidnum>0)
for (cnt=0; cnt<amt; cnt++)
PlaceVegetation(C4Id2Def(vidlist[Random(vidnum)]),0,0,::Landscape.GetWidth(),::Landscape.GetHeight(),-1,NULL,NULL);
PlaceVegetation(C4Id2Def(vidlist[Random(vidnum)]),0,0,::Landscape.GetWidth(),::Landscape.GetHeight(),-1,nullptr,nullptr);
}
void C4Game::InitAnimals()
@ -2864,7 +2864,7 @@ bool C4Game::LoadScenarioComponents()
// scenario sections
char fn[_MAX_FNAME+1] = { 0 };
ScenarioFile.ResetSearch(); *fn=0;
while (ScenarioFile.FindNextEntry(C4CFN_ScenarioSections, fn, NULL, !!*fn))
while (ScenarioFile.FindNextEntry(C4CFN_ScenarioSections, fn, nullptr, !!*fn))
{
// get section name
char SctName[_MAX_FNAME+1];
@ -2914,7 +2914,7 @@ bool C4Game::LoadAdditionalSystemGroup(C4Group &parent_group)
}
// load all scripts in there
SysGroup.ResetSearch();
while (SysGroup.FindNextEntry(C4CFN_ScriptFiles, fn, NULL, !!fn[0]))
while (SysGroup.FindNextEntry(C4CFN_ScriptFiles, fn, nullptr, !!fn[0]))
{
// host will be destroyed by script engine, so drop the references
C4ScriptHost *scr = new C4ExtraScriptHost();
@ -3062,7 +3062,7 @@ C4Player *C4Game::JoinPlayer(const char *szFilename, int32_t iAtClient, const ch
assert(pInfo);
C4Player *pPlr;
// Join
if (!( pPlr = Players.Join(szFilename,true,iAtClient,szAtClientName, pInfo, NULL) )) return NULL;
if (!( pPlr = Players.Join(szFilename,true,iAtClient,szAtClientName, pInfo, nullptr) )) return nullptr;
// Player final init
pPlr->FinalInit(true);
// Create player viewport
@ -3164,7 +3164,7 @@ bool C4Game::InitNetworkFromAddress(const char *szAddress)
StdStrBuf Message = FormatString(LoadResStr("IDS_NET_REFQUERY_QUERYMSG"), szAddress);
Log(Message.getData());
// Set up wait dialog
C4GUI::MessageDialog *pDlg = NULL;
C4GUI::MessageDialog *pDlg = nullptr;
if (!Application.isEditor)
{
// create & show
@ -3192,7 +3192,7 @@ bool C4Game::InitNetworkFromAddress(const char *szAddress)
if (!RefClient.isSuccess())
{ LogFatal(FormatString(strRefQueryFailed.getData(), RefClient.GetError()).getData()); return false; }
// Get references
C4Network2Reference **ppRefs = NULL; int32_t iRefCount;
C4Network2Reference **ppRefs = nullptr; int32_t iRefCount;
if (!RefClient.GetReferences(ppRefs, iRefCount) || iRefCount <= 0)
{ LogFatal(FormatString(strRefQueryFailed.getData(), LoadResStr("IDS_NET_REFQUERY_NOREF")).getData()); return false; }
// Connect to first reference
@ -3351,7 +3351,7 @@ void C4Game::InitEnvironment()
C4ID idType; int32_t iCount;
for (cnt=0; (idType=C4S.Environment.Objects.GetID(cnt,&iCount)); cnt++)
for (cnt2=0; cnt2<iCount; cnt2++)
CreateObject(idType,NULL);
CreateObject(idType,nullptr);
}
void C4Game::InitRules()
@ -3361,7 +3361,7 @@ void C4Game::InitRules()
C4ID idType; int32_t iCount;
for (cnt=0; (idType=Parameters.Rules.GetID(cnt,&iCount)); cnt++)
for (cnt2=0; cnt2<std::max<int32_t>(iCount,1); cnt2++)
CreateObject(idType,NULL);
CreateObject(idType,nullptr);
}
void C4Game::InitGoals()
@ -3371,7 +3371,7 @@ void C4Game::InitGoals()
C4ID idType; int32_t iCount;
for (cnt=0; (idType=Parameters.Goals.GetID(cnt,&iCount)); cnt++)
for (cnt2=0; cnt2<iCount; cnt2++)
CreateObject(idType,NULL);
CreateObject(idType,nullptr);
}
void C4Game::SetInitProgress(float fToProgress)
@ -3743,7 +3743,7 @@ bool C4Game::DrawTextSpecImage(C4Facet &fctTarget, const char *szSpec, C4DrawTra
C4Def *pDef = C4Id2Def(C4ID(szSpec));
if (!pDef) return false;
pDef->Draw(fctTarget, false, dwClr, NULL, 0, 0, pTransform);
pDef->Draw(fctTarget, false, dwClr, nullptr, 0, 0, pTransform);
return true;
}
}
@ -3806,7 +3806,7 @@ bool C4Game::DrawPropListSpecImage(C4Facet &fctTarget, C4PropList *pSpec)
// Alternative named graphics
C4DefGraphics *source_graphics = source_def->Graphics.Get(source_name->GetCStr());
if (!source_graphics) return false;
source_graphics->Draw(fctTarget, color, NULL, 0,0, NULL);
source_graphics->Draw(fctTarget, color, nullptr, 0,0, nullptr);
}
return true;
}
@ -3874,7 +3874,7 @@ void C4Game::SetGlobalSoundModifier(C4PropList *new_modifier)
else
{
GlobalSoundModifier.Set0();
mod = NULL;
mod = nullptr;
}
::Application.SoundSystem.Modifiers.SetGlobalModifier(mod, NO_OWNER);
}

View File

@ -94,7 +94,7 @@ public:
C4PlayerControlDefs PlayerControlDefs;
C4PlayerControlAssignmentSets PlayerControlUserAssignmentSets, PlayerControlDefaultAssignmentSets;
C4Scoreboard Scoreboard;
std::unique_ptr<C4Network2Stats> pNetworkStatistics; // may be NULL if no statistics are recorded
std::unique_ptr<C4Network2Stats> pNetworkStatistics; // may be nullptr if no statistics are recorded
C4KeyboardInput &KeyboardInput;
std::unique_ptr<C4FileMonitor> pFileMonitor;
std::unique_ptr<C4GameSec1Timer> pSec1Timer;
@ -154,8 +154,8 @@ public:
void Abort(bool fApproved = false); // hard-quit on Esc+Y (/J/O)
void Evaluate();
void ShowGameOverDlg();
bool DoKeyboardInput(C4KeyCode vk_code, C4KeyEventType eEventType, bool fAlt, bool fCtrl, bool fShift, bool fRepeated, class C4GUI::Dialog *pForDialog=NULL, bool fPlrCtrlOnly=false, int32_t iStrength=-1);
bool DoKeyboardInput(C4KeyCodeEx Key, C4KeyEventType eEventType, class C4GUI::Dialog *pForDialog=NULL, bool fPlrCtrlOnly=false, int32_t iStrength=-1);
bool DoKeyboardInput(C4KeyCode vk_code, C4KeyEventType eEventType, bool fAlt, bool fCtrl, bool fShift, bool fRepeated, class C4GUI::Dialog *pForDialog=nullptr, bool fPlrCtrlOnly=false, int32_t iStrength=-1);
bool DoKeyboardInput(C4KeyCodeEx Key, C4KeyEventType eEventType, class C4GUI::Dialog *pForDialog=nullptr, bool fPlrCtrlOnly=false, int32_t iStrength=-1);
void DrawCrewOverheadText(C4TargetFacet &cgo, int32_t iPlayer);
void FixRandom(uint64_t iSeed);
bool Init();
@ -205,14 +205,14 @@ public:
C4Object *FindObject(C4Def * pDef,
int32_t iX=0, int32_t iY=0, int32_t iWdt=0, int32_t iHgt=0,
DWORD ocf=OCF_All,
C4Object *pFindNext=NULL);
C4Object *pFindNext=nullptr);
C4Object *FindVisObject( // find object in view at pos, regarding parallaxity and visibility (but not distance)
float tx, float ty, int32_t iPlr, const C4Facet &fctViewportGame, const C4Facet &fctViewportGUI,
float iX, float iY,
DWORD category,
float gui_x, float gui_y);
int32_t ObjectCount(C4ID id);
void CastObjects(C4ID id, C4Object *pCreator, int32_t num, int32_t level, int32_t tx, int32_t ty, int32_t iOwner=NO_OWNER, int32_t iController=NO_OWNER, C4ValueArray *out_objects=NULL);
void CastObjects(C4ID id, C4Object *pCreator, int32_t num, int32_t level, int32_t tx, int32_t ty, int32_t iOwner=NO_OWNER, int32_t iController=NO_OWNER, C4ValueArray *out_objects=nullptr);
C4Object *PlaceVegetation(C4PropList *def, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iGrowth, C4PropList *shape_proplist, C4PropList * out_pos_proplist);
C4Object *PlaceAnimal(C4PropList *def);
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars = 0, bool fPassError=false, bool fRejectTest=false); // call function in scenario script and all goals/rules/environment objects

View File

@ -85,7 +85,7 @@ static long FnGetGravity(C4PropList * _this)
static C4String *FnGetPlayerName(C4PropList * _this, long iPlayer)
{
if (!ValidPlr(iPlayer)) return NULL;
if (!ValidPlr(iPlayer)) return nullptr;
return String(::Players.Get(iPlayer)->GetName());
}
@ -184,7 +184,7 @@ static C4Object *FnCreateConstruction(C4PropList * _this,
{
// Make sure parameters are valid
if (!PropList || !PropList->GetDef())
return NULL;
return nullptr;
// Local object calls override position offset, owner
if (Object(_this))
@ -196,7 +196,7 @@ static C4Object *FnCreateConstruction(C4PropList * _this,
// Check site
if (fCheckSite)
if (!ConstructionCheck(PropList,iXOffset,iYOffset,Object(_this)))
return NULL;
return nullptr;
long iOwner = owner;
if (owner.IsNil())
@ -220,10 +220,10 @@ static C4ValueArray *FnFindConstructionSite(C4PropList * _this, C4PropList * Pro
{
// Get def
C4Def *pDef;
if (!(pDef=PropList->GetDef())) return NULL;
if (!(pDef=PropList->GetDef())) return nullptr;
// Construction check at starting position
if (ConstructionCheck(PropList,v1,v2))
return NULL;
return nullptr;
// Search for real
bool result = !!FindConSiteSpot(v1, v2, pDef->Shape.Wdt,pDef->Shape.Hgt, 20);
if(!result) return 0;
@ -261,8 +261,8 @@ C4FindObject *CreateCriterionsFromPars(C4Value *pPars, C4FindObject **pFOs, C4So
// No data given?
if (!Data) break;
// Construct
C4SortObject *pSO = NULL;
C4FindObject *pFO = C4FindObject::CreateByValue(Data, pSOs ? &pSO : NULL, context, &has_layer_check);
C4SortObject *pSO = nullptr;
C4FindObject *pFO = C4FindObject::CreateByValue(Data, pSOs ? &pSO : nullptr, context, &has_layer_check);
// Add FindObject
if (pFO)
{
@ -278,7 +278,7 @@ C4FindObject *CreateCriterionsFromPars(C4Value *pPars, C4FindObject **pFOs, C4So
if (!iCnt)
{
for (i = 0; i < iSortCnt; ++i) delete pSOs[i];
return NULL;
return nullptr;
}
// Implicit layer check
if (context && !has_layer_check)
@ -286,7 +286,7 @@ C4FindObject *CreateCriterionsFromPars(C4Value *pPars, C4FindObject **pFOs, C4So
pFOs[iCnt++] = new C4FindObjectLayer(context->Layer);
}
// create sort criterion
C4SortObject *pSO = NULL;
C4SortObject *pSO = nullptr;
if (iSortCnt)
{
if (iSortCnt == 1)
@ -308,7 +308,7 @@ static C4Value FnObjectCount(C4PropList * _this, C4Value *pPars)
{
// Create FindObject-structure
C4FindObject *pFOs[C4AUL_MAX_Par+1]; // +1 array element to include space for implicit layer check
C4FindObject *pFO = CreateCriterionsFromPars(pPars, pFOs, NULL, Object(_this));
C4FindObject *pFO = CreateCriterionsFromPars(pPars, pFOs, nullptr, Object(_this));
// Error?
if (!pFO)
throw C4AulExecError("ObjectCount: No valid search criterions supplied");
@ -409,10 +409,10 @@ static C4String *FnGetTexture(C4PropList * _this, long x, long y)
// Get texture
int32_t iTex = PixCol2Tex(::Landscape.GetPix(x, y));
if (!iTex) return NULL;
if (!iTex) return nullptr;
// Get material-texture mapping
const C4TexMapEntry *pTex = ::TextureMap.GetEntry(iTex);
if (!pTex) return NULL;
if (!pTex) return nullptr;
// Return tex name
return String(pTex->GetTextureName());
}
@ -423,10 +423,10 @@ static C4String *FnGetBackTexture(C4PropList * _this, long x, long y)
// Get texture
int32_t iTex = PixCol2Tex(::Landscape.GetBackPix(x, y));
if (!iTex) return NULL;
if (!iTex) return nullptr;
// Get material-texture mapping
const C4TexMapEntry *pTex = ::TextureMap.GetEntry(iTex);
if (!pTex) return NULL;
if (!pTex) return nullptr;
// Return tex name
return String(pTex->GetTextureName());
}
@ -440,7 +440,7 @@ static Nillable<long> FnGetAverageTextureColor(C4PropList * _this, C4String* Tex
StdStrBuf texture_name;
texture_name.Ref(Texture->GetCStr());
const char* pch = strchr(texture_name.getData(), '-');
if (pch != NULL)
if (pch != nullptr)
{
size_t len = pch - texture_name.getData();
texture_name.Copy();
@ -517,7 +517,7 @@ static bool FnSoundAt(C4PropList * _this, C4String *szSound, long iX, long iY, N
if (modifier_props)
modifier = Application.SoundSystem.Modifiers.Get(modifier_props, true);
else
modifier = NULL;
modifier = nullptr;
// target object
C4Object *pObj = Object(_this);
if (pObj)
@ -553,9 +553,9 @@ static bool FnSound(C4PropList * _this, C4String *szSound, bool fGlobal, Nillabl
if (modifier_props)
modifier = Application.SoundSystem.Modifiers.Get(modifier_props, true);
else
modifier = NULL;
modifier = nullptr;
// target object
C4Object *pObj = NULL;
C4Object *pObj = nullptr;
if (!fGlobal) pObj = Object(_this);
// play/stop?
if (iLoop >= 0)
@ -649,7 +649,7 @@ static long FnSetPlayList(C4PropList * _this, const C4Value & playlist_data, Nil
}
// Playlist might be a string for the new playlist, a proplist with more info, or nil to reset the playlist
C4String * szPlayList = playlist_data.getStr();
C4PropList *playlist_props = NULL;
C4PropList *playlist_props = nullptr;
if (!szPlayList)
{
playlist_props = playlist_data.getPropList();
@ -756,7 +756,7 @@ C4Object* FnPlaceVegetation(C4PropList * _this, C4PropList * Def, long iX, long
if (shape)
{
// New-style call with scripted shape
C4PropList *out_pos = C4PropList::New(NULL);
C4PropList *out_pos = C4PropList::New(nullptr);
C4Value vout_pos = C4VPropList(out_pos);
return Game.PlaceVegetation(Def, iX, iY, iWdt, iHgt, iGrowth, shape, out_pos);
}
@ -766,7 +766,7 @@ C4Object* FnPlaceVegetation(C4PropList * _this, C4PropList * Def, long iX, long
// Local call: relative coordinates
if (Object(_this)) { iX += Object(_this)->GetX(); iY += Object(_this)->GetY(); }
// Place vegetation
return Game.PlaceVegetation(Def, iX, iY, iWdt, iHgt, iGrowth, NULL, NULL);
return Game.PlaceVegetation(Def, iX, iY, iWdt, iHgt, iGrowth, nullptr, nullptr);
}
}
@ -826,7 +826,7 @@ static void FnResetCursorView(C4PropList * _this, long plr, bool immediate_posit
static C4Object *FnGetPlrView(C4PropList * _this, long iPlr)
{
C4Player *pPlr = ::Players.Get(iPlr);
if (!pPlr || pPlr->ViewMode != C4PVM_Target) return NULL;
if (!pPlr || pPlr->ViewMode != C4PVM_Target) return nullptr;
return pPlr->ViewTarget;
}
@ -872,11 +872,11 @@ static C4PropList *FnGetPlayerZoomLimits(C4PropList * _this, long plr_idx)
{
// get player
C4Player *plr = ::Players.Get(plr_idx);
if (!plr) return NULL;
if (!plr) return nullptr;
// collect limits in a prop list
// if neither width not height is set for zoom limits, return engine defaults.
C4PropList *result = C4PropList::New();
if (!result) return NULL;
if (!result) return nullptr;
result->SetPropertyByS(::Strings.RegString("MaxWidth"), C4VInt((plr->ZoomLimitMaxWdt || plr->ZoomLimitMaxHgt) ? plr->ZoomLimitMaxWdt : C4VP_DefMaxViewRangeX));
result->SetPropertyByS(::Strings.RegString("MaxHeight"), C4VInt(plr->ZoomLimitMaxHgt));
result->SetPropertyByS(::Strings.RegString("MaxValue"), C4VInt(fixtoi(plr->ZoomLimitMaxVal, 100)));
@ -1052,13 +1052,13 @@ static long FnGetPlayerScoreGain(C4PropList * _this, long iPlr)
static C4Object *FnGetHiRank(C4PropList * _this, long iPlr)
{
if (!ValidPlr(iPlr)) return NULL;
if (!ValidPlr(iPlr)) return nullptr;
return ::Players.Get(iPlr)->GetHiRankActiveCrew();
}
static C4Object *FnGetCrew(C4PropList * _this, long iPlr, long index)
{
if (!ValidPlr(iPlr)) return NULL;
if (!ValidPlr(iPlr)) return nullptr;
return ::Players.Get(iPlr)->Crew.GetObject(index);
}
@ -1148,7 +1148,7 @@ static bool FnCreateScriptPlayer(C4PropList * _this, C4String *szName, long dwCo
if (dwFlags & CSPF_Invisible ) dwInfoFlags |= C4PlayerInfo::PIF_Invisible;
pScriptPlrInfo->SetAsScriptPlayer(szName->GetCStr(), dwColor, dwInfoFlags, idExtra);
pScriptPlrInfo->SetTeam(idTeam);
C4ClientPlayerInfos JoinPkt(NULL, true, pScriptPlrInfo);
C4ClientPlayerInfos JoinPkt(nullptr, true, pScriptPlrInfo);
// add to queue!
Game.PlayerInfos.DoPlayerInfoUpdate(&JoinPkt);
// always successful for sync reasons
@ -1160,7 +1160,7 @@ static C4Object *FnGetCursor(C4PropList * _this, long iPlr)
// get player
C4Player *pPlr = ::Players.Get(iPlr);
// invalid player?
if (!pPlr) return NULL;
if (!pPlr) return nullptr;
return pPlr->Cursor;
}
@ -1170,7 +1170,7 @@ static C4Object *FnGetViewCursor(C4PropList * _this, long iPlr)
// get player
C4Player *pPlr = ::Players.Get(iPlr);
// get viewcursor
return pPlr ? pPlr->ViewCursor : NULL;
return pPlr ? pPlr->ViewCursor : nullptr;
}
static bool FnSetCursor(C4PropList * _this, long iPlr, C4Object *pObj, bool fNoSelectArrow)
@ -1319,7 +1319,7 @@ static C4Value FnGameCallEx(C4PropList * _this, C4Value * Pars)
static C4Object * FnEditCursor(C4PropList * _this)
{
if (::Control.SyncMode()) return NULL;
if (::Control.SyncMode()) return nullptr;
return Console.EditCursor.GetTarget();
}
@ -1332,7 +1332,7 @@ static C4String *FnGetLeague(C4PropList * _this, long idx)
{
// get indexed league
StdStrBuf sIdxLeague;
if (!Game.Parameters.League.GetSection(idx, &sIdxLeague)) return NULL;
if (!Game.Parameters.League.GetSection(idx, &sIdxLeague)) return nullptr;
return String(sIdxLeague.getData());
}
@ -1352,15 +1352,15 @@ static bool FnSetLeagueProgressData(C4PropList * _this, C4String *pNewData, long
if(!Game.Parameters.League.getLength() || !idPlayer) return false;
C4PlayerInfo *info = Game.PlayerInfos.GetPlayerInfoByID(idPlayer);
if (!info) return false;
info->SetLeagueProgressData(pNewData ? pNewData->GetCStr() : NULL);
info->SetLeagueProgressData(pNewData ? pNewData->GetCStr() : nullptr);
return true;
}
static C4String *FnGetLeagueProgressData(C4PropList * _this, long idPlayer)
{
if(!Game.Parameters.League.getLength()) return NULL;
if(!Game.Parameters.League.getLength()) return nullptr;
C4PlayerInfo *info = Game.PlayerInfos.GetPlayerInfoByID(idPlayer);
if (!info) return NULL;
if (!info) return nullptr;
return String(info->GetLeagueProgressData());
}
@ -1562,7 +1562,7 @@ template <class T>
C4Value GetValByStdCompiler(const char *strEntry, const char *strSection, int iEntryNr, const T &rFrom)
{
// Set up name array, create compiler
const char *szNames[2] = { strSection ? strSection : strEntry, strSection ? strEntry : NULL };
const char *szNames[2] = { strSection ? strSection : strEntry, strSection ? strEntry : nullptr };
C4ValueGetCompiler Comp(szNames, strSection ? 2 : 1, iEntryNr);
// Compile
@ -1583,7 +1583,7 @@ static C4Value FnGetDefCoreVal(C4PropList * _this, C4String * strEntry, C4String
if (!_this || !_this->GetDef())
throw NeedNonGlobalContext("GetDefCoreVal");
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : NULL,
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : nullptr,
iEntryNr, mkNamingAdapt(*_this->GetDef(), "DefCore"));
}
@ -1591,7 +1591,7 @@ static C4Value FnGetObjectVal(C4Object * _this, C4String * strEntry, C4String *
{
// get value
C4ValueNumbers numbers;
C4Value retval = GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : NULL,
C4Value retval = GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : nullptr,
iEntryNr, mkNamingAdapt(mkParAdapt(*Object(_this), &numbers), "Object"));
numbers.Denumerate();
retval.Denumerate(&numbers);
@ -1609,13 +1609,13 @@ static C4Value FnGetObjectInfoCoreVal(C4Object * _this, C4String * strEntry, C4S
C4ObjectInfoCore* pObjInfoCore = (C4ObjectInfoCore*) pObjInfo;
// get value
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : NULL,
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : nullptr,
iEntryNr, mkNamingAdapt(*pObjInfoCore, "ObjectInfo"));
}
static C4Value FnGetScenarioVal(C4PropList * _this, C4String * strEntry, C4String * strSection, int iEntryNr)
{
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : NULL,
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : nullptr,
iEntryNr, mkParAdapt(Game.C4S, false));
}
@ -1627,7 +1627,7 @@ static C4Value FnGetPlayerVal(C4PropList * _this, C4String * strEntry, C4String
// get value
C4ValueNumbers numbers;
C4Value retval = GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : NULL,
C4Value retval = GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : nullptr,
iEntryNr, mkNamingAdapt(mkParAdapt(*pPlayer, &numbers), "Player"));
numbers.Denumerate();
retval.Denumerate(&numbers);
@ -1644,7 +1644,7 @@ static C4Value FnGetPlayerInfoCoreVal(C4PropList * _this, C4String * strEntry, C
C4PlayerInfoCore* pPlayerInfoCore = (C4PlayerInfoCore*) pPlayer;
// get value
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : NULL,
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : nullptr,
iEntryNr, *pPlayerInfoCore);
}
@ -1659,13 +1659,13 @@ static C4Value FnGetMaterialVal(C4PropList * _this, C4String * strEntry, C4Stri
C4MaterialCore* pMaterialCore = static_cast<C4MaterialCore*>(pMaterial);
// get value
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : NULL, iEntryNr, *pMaterialCore);
return GetValByStdCompiler(FnStringPar(strEntry), strSection ? strSection->GetCStr() : nullptr, iEntryNr, *pMaterialCore);
}
static C4String *FnMaterialName(C4PropList * _this, long iMat)
{
// mat valid?
if (!MatValid(iMat)) return NULL;
if (!MatValid(iMat)) return nullptr;
// return mat name
return String(::MaterialMap.Map[iMat].Name);
}
@ -1979,7 +1979,7 @@ static bool FnSetSkyParallax(C4PropList * _this, Nillable<long> iMode, Nillable<
static long FnReloadDef(C4PropList * _this, C4ID idDef, long iReloadWhat)
{
// get def
C4Def *pDef=NULL;
C4Def *pDef=nullptr;
if (!idDef)
{
// no def given: local def
@ -2088,7 +2088,7 @@ static bool FnDrawMaterialQuad(C4PropList * _this, C4String *szMaterial, long iX
{
const char *szMat = FnStringPar(szMaterial);
const char *szBackMat = NULL;
const char *szBackMat = nullptr;
bool fBridge = false;
if (draw_mode.GetType() == C4V_Int)
{
@ -2309,7 +2309,7 @@ static long FnGetTeamConfig(C4PropList * _this, long iConfigValue)
static C4String *FnGetTeamName(C4PropList * _this, long iTeam)
{
C4Team *pTeam = Game.Teams.GetTeamByID(iTeam);
if (!pTeam) return NULL;
if (!pTeam) return nullptr;
return String(pTeam->GetName());
}
@ -2340,7 +2340,7 @@ static bool FnInitScenarioPlayer(C4PropList * _this, long iPlayer, long idTeam)
static bool FnSetScoreboardData(C4PropList * _this, long iRowID, long iColID, C4String *pText, long iData)
{
Game.Scoreboard.SetCell(iColID, iRowID, pText ? pText->GetCStr() : NULL, iData);
Game.Scoreboard.SetCell(iColID, iRowID, pText ? pText->GetCStr() : nullptr, iData);
return true;
}
@ -2432,7 +2432,7 @@ static bool FnCustomMessage(C4PropList * _this, C4String *pMsg, C4Object *pObj,
// remove speech?
StdStrBuf sMsg;
sMsg.Ref(szMsg);
if (dwFlags & C4GM_DropSpeech) sMsg.SplitAtChar('$', NULL);
if (dwFlags & C4GM_DropSpeech) sMsg.SplitAtChar('$', nullptr);
// create it!
return ::Messages.New(iType,sMsg,pObj,iOwner,iOffX,iOffY,(uint32_t)dwClr, idDeco, pSrc, dwFlags, iHSize);
}
@ -2546,7 +2546,7 @@ static bool FnSetNextMission(C4PropList * _this, C4String *szNextMission, C4Stri
static long FnGetPlayerControlState(C4PropList * _this, long iPlr, long iControl, bool fMovedState)
{
// get control set to check
C4PlayerControl *pCheckCtrl = NULL;
C4PlayerControl *pCheckCtrl = nullptr;
if (iPlr != NO_OWNER)
{
C4Player *pPlr = ::Players.Get(iPlr);
@ -2569,7 +2569,7 @@ static long FnGetPlayerControlState(C4PropList * _this, long iPlr, long iControl
static bool FnSetPlayerControlEnabled(C4PropList * _this, long iplr, long ctrl, bool is_enabled)
{
// get control set to check
C4PlayerControl *plrctrl = NULL;
C4PlayerControl *plrctrl = nullptr;
if (iplr != NO_OWNER)
{
C4Player *plr = ::Players.Get(iplr);
@ -2590,7 +2590,7 @@ static bool FnSetPlayerControlEnabled(C4PropList * _this, long iplr, long ctrl,
static bool FnGetPlayerControlEnabled(C4PropList * _this, long iplr, long ctrl)
{
// get control set to check
C4PlayerControl *plrctrl = NULL;
C4PlayerControl *plrctrl = nullptr;
if (iplr != NO_OWNER)
{
C4Player *plr = ::Players.Get(iplr);
@ -2611,7 +2611,7 @@ static C4String *FnGetPlayerControlAssignment(C4PropList * _this, long player, l
// "" is returned for invalid controls to make the obvious if(GetPlayerControlAssignmentName(...)) not cause a sync loss
// get desired assignment from parameters
C4Player *plr = ::Players.Get(player);
if (!plr) return NULL; // invalid player
if (!plr) return nullptr; // invalid player
if (!plr->ControlSet) return String(""); // player has no control (remote player)
C4PlayerControlAssignment *assignment = plr->ControlSet->GetAssignmentByControl(control);
if (!assignment) return String("");
@ -2683,12 +2683,12 @@ static bool FnGainScenarioAchievement(C4PropList * _this, C4String *achievement_
{
C4Player *plr = ::Players.Get(player);
if (!plr) return false;
result = plr->GainScenarioAchievement(achievement_name->GetCStr(), value, for_scenario ? for_scenario->GetCStr() : NULL);
result = plr->GainScenarioAchievement(achievement_name->GetCStr(), value, for_scenario ? for_scenario->GetCStr() : nullptr);
}
else
{
for (C4Player *plr = ::Players.First; plr; plr = plr->Next)
if (!plr->GainScenarioAchievement(achievement_name->GetCStr(), value, for_scenario ? for_scenario->GetCStr() : NULL))
if (!plr->GainScenarioAchievement(achievement_name->GetCStr(), value, for_scenario ? for_scenario->GetCStr() : nullptr))
result = false;
}
return result;
@ -3058,7 +3058,7 @@ C4ScriptConstDef C4ScriptGameConstMap[]=
{ "PLRCON_MaxStrength" ,C4V_Int, C4GamePadControl::MaxStrength },
{ NULL, C4V_Nil, 0}
{ nullptr, C4V_Nil, 0}
};
C4ScriptFnDef C4ScriptGameFnMap[]=
@ -3072,5 +3072,5 @@ C4ScriptFnDef C4ScriptGameFnMap[]=
{ "AddMessage", 1, C4V_Bool, { C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnAddMessage },
{ "PV_KeyFrames", 1, C4V_Array, { C4V_Int ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnPV_KeyFrames },
{ NULL, 0, C4V_Nil, { C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil}, 0 }
{ nullptr, 0, C4V_Nil, { C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil ,C4V_Nil}, 0 }
};

View File

@ -59,7 +59,7 @@ void C4GraphicsSystem::Clear()
// Clear message board
MessageBoard.reset();
// clear loader
if (pLoaderScreen) { delete pLoaderScreen; pLoaderScreen=NULL; }
if (pLoaderScreen) { delete pLoaderScreen; pLoaderScreen=nullptr; }
// Close viewports
::Viewports.Clear();
// No debug stuff
@ -168,7 +168,7 @@ void C4GraphicsSystem::Default()
ShowHelp=false;
FlashMessageText[0]=0;
FlashMessageTime=0; FlashMessageX=FlashMessageY=0;
pLoaderScreen=NULL;
pLoaderScreen=nullptr;
}
void C4GraphicsSystem::ClearFullscreenBackground()
@ -201,7 +201,7 @@ bool C4GraphicsSystem::SaveScreenshot(bool fSaveAll, float fSaveAllZoom)
// Keep static counter so multiple screenshots in succession do not use same filename even if the background thread hasn't started writing the file yet
char szFilename[_MAX_PATH+1];
static int32_t iScreenshotIndex=1;
const char *strFilePath = NULL;
const char *strFilePath = nullptr;
do
sprintf(szFilename,"Screenshot%03i.png",iScreenshotIndex++);
while (FileExists(strFilePath = Config.AtScreenshotPath(szFilename)));

View File

@ -99,7 +99,7 @@ C4Viewport::C4Viewport()
ZoomTarget = 0.0;
ViewportOpenFrame = 0;
ZoomLimitMin = ZoomLimitMax = 0; // no limit
Next = NULL;
Next = nullptr;
PlayerLock = true;
ResetMenuPositions = false;
viewOffsX = viewOffsY = 0;
@ -209,10 +209,10 @@ void C4Viewport::Draw(C4TargetFacet &cgo0, bool fDrawGame, bool fDrawOverlay)
GameZoom.Zoom = cgo.Zoom;
// Draw landscape borders
if (BorderLeft > 0.0f) pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface, cgo.Surface, DrawX, DrawY, BorderLeft, ViewHgt, -DrawX, -DrawY, NULL);
if (BorderTop > 0.0f) pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface, cgo.Surface, DrawX + BorderLeft, DrawY, ViewWdt - BorderLeft - BorderRight, BorderTop, -DrawX - BorderLeft, -DrawY, NULL);
if (BorderRight > 0.0f) pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface, cgo.Surface, DrawX + ViewWdt - BorderRight, DrawY, BorderRight, ViewHgt, -DrawX - ViewWdt + BorderRight, -DrawY, NULL);
if (BorderBottom > 0.0f) pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface, cgo.Surface, DrawX + BorderLeft, DrawY + ViewHgt - BorderBottom, ViewWdt - BorderLeft - BorderRight, BorderBottom, -DrawX - BorderLeft, -DrawY - ViewHgt + BorderBottom, NULL);
if (BorderLeft > 0.0f) pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface, cgo.Surface, DrawX, DrawY, BorderLeft, ViewHgt, -DrawX, -DrawY, nullptr);
if (BorderTop > 0.0f) pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface, cgo.Surface, DrawX + BorderLeft, DrawY, ViewWdt - BorderLeft - BorderRight, BorderTop, -DrawX - BorderLeft, -DrawY, nullptr);
if (BorderRight > 0.0f) pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface, cgo.Surface, DrawX + ViewWdt - BorderRight, DrawY, BorderRight, ViewHgt, -DrawX - ViewWdt + BorderRight, -DrawY, nullptr);
if (BorderBottom > 0.0f) pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface, cgo.Surface, DrawX + BorderLeft, DrawY + ViewHgt - BorderBottom, ViewWdt - BorderLeft - BorderRight, BorderBottom, -DrawX - BorderLeft, -DrawY - ViewHgt + BorderBottom, nullptr);
// Compute non-bordered viewport area
cgo.X += BorderLeft; cgo.Y += BorderTop; cgo.Wdt -= (BorderLeft + BorderRight) / cgo.Zoom; cgo.Hgt -= (BorderTop + BorderBottom) / cgo.Zoom;
@ -234,7 +234,7 @@ void C4Viewport::Draw(C4TargetFacet &cgo0, bool fDrawGame, bool fDrawOverlay)
// Render FoW only if active for player
C4Player *pPlr = ::Players.Get(Player);
C4FoWRegion* pFoW = NULL;
C4FoWRegion* pFoW = nullptr;
if (pPlr && pPlr->fFogOfWar) pFoW = this->pFoW.get();
// Update FoW
@ -248,7 +248,7 @@ void C4Viewport::Draw(C4TargetFacet &cgo0, bool fDrawGame, bool fDrawOverlay)
if (!lightRect.Wdt || !lightRect.Hgt)
{
// Do not bother initializing FoW on empty region; would cause errors in drawing proc
pFoW = NULL;
pFoW = nullptr;
}
else
{
@ -257,7 +257,7 @@ void C4Viewport::Draw(C4TargetFacet &cgo0, bool fDrawGame, bool fDrawOverlay)
if (!pFoW->Render())
{
// If FoW init fails, do not set it for further drawing
pFoW = NULL;
pFoW = nullptr;
}
}
}
@ -298,7 +298,7 @@ void C4Viewport::Draw(C4TargetFacet &cgo0, bool fDrawGame, bool fDrawOverlay)
C4ST_STOP(Obj2Stat)
// Draw everything else without FoW
pDraw->SetFoW(NULL);
pDraw->SetFoW(nullptr);
}
else
{
@ -838,7 +838,7 @@ bool C4Viewport::IsViewportMenu(class C4Menu *pMenu)
C4ViewportList Viewports;
C4ViewportList::C4ViewportList():
FirstViewport(NULL)
FirstViewport(nullptr)
{
ViewportArea.Default();
}
@ -854,7 +854,7 @@ void C4ViewportList::Clear()
delete FirstViewport;
FirstViewport=next;
}
FirstViewport=NULL;
FirstViewport=nullptr;
}
void C4ViewportList::Execute(bool DrawBackground)
@ -876,7 +876,7 @@ void C4ViewportList::DrawFullscreenBackground()
for (int i=0, iNum=BackgroundAreas.GetCount(); i<iNum; ++i)
{
const C4Rect &rc = BackgroundAreas.Get(i);
pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface,FullScreen.pSurface,rc.x,rc.y,rc.Wdt,rc.Hgt,-rc.x,-rc.y, NULL);
pDraw->BlitSurfaceTile(::GraphicsResource.fctBackground.Surface,FullScreen.pSurface,rc.x,rc.y,rc.Wdt,rc.Hgt,-rc.x,-rc.y, nullptr);
}
}
@ -911,7 +911,7 @@ C4Viewport* C4ViewportList::GetViewport(HWND hwnd)
for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)
if (cvp->pWindow->hWindow==hwnd)
return cvp;
return NULL;
return nullptr;
}
#endif
bool C4ViewportList::CreateViewport(int32_t iPlayer, bool fSilent)
@ -962,7 +962,7 @@ bool C4ViewportList::CloseViewport(int32_t iPlayer, bool fSilent)
{
// Close all matching viewports
int32_t iLastCount = GetViewportCount();
C4Viewport *next,*prev=NULL;
C4Viewport *next,*prev=nullptr;
for (C4Viewport *cvp=FirstViewport; cvp; cvp=next)
{
next=cvp->Next;
@ -1005,7 +1005,7 @@ void C4ViewportList::RecalculateViewports()
::GraphicsSystem.InvalidateBg();
#ifdef _WIN32
// reset mouse clipping
ClipCursor(NULL);
ClipCursor(nullptr);
#else
// StdWindow handles this.
#endif
@ -1072,7 +1072,7 @@ C4Viewport* C4ViewportList::GetViewport(int32_t iPlayer, C4Viewport* pPrev)
for (C4Viewport *cvp=pPrev ? pPrev->Next : FirstViewport; cvp; cvp=cvp->Next)
if (cvp->Player==iPlayer || (iPlayer==NO_OWNER && cvp->fIsNoOwnerViewport))
return cvp;
return NULL;
return nullptr;
}
int32_t C4ViewportList::GetAudibility(int32_t iX, int32_t iY, int32_t *iPan, int32_t iAudibilityRadius, int32_t *outPlayer)
@ -1106,7 +1106,7 @@ void C4ViewportList::SortViewportsByPlayerControl()
do
{
fSorted = true;
for (pPrev=NULL,pView=FirstViewport; pView && (pNext = pView->Next); pView=pNext)
for (pPrev=nullptr,pView=FirstViewport; pView && (pNext = pView->Next); pView=pNext)
{
// Get players
pPlr1 = ::Players.Get(pView->Player);

View File

@ -152,13 +152,13 @@ public:
bool CreateViewport(int32_t iPlayer, bool fSilent=false);
bool CloseViewport(int32_t iPlayer, bool fSilent);
int32_t GetViewportCount();
C4Viewport* GetViewport(int32_t iPlayer, C4Viewport* pPrev = NULL);
C4Viewport* GetViewport(int32_t iPlayer, C4Viewport* pPrev = nullptr);
C4Viewport* GetFirstViewport() { return FirstViewport; }
bool CloseViewport(C4Viewport * cvp);
#ifdef USE_WIN32_WINDOWS
C4Viewport* GetViewport(HWND hwnd);
#endif
int32_t GetAudibility(int32_t iX, int32_t iY, int32_t *iPan, int32_t iAudibilityRadius = 0, int32_t *outPlayer = NULL);
int32_t GetAudibility(int32_t iX, int32_t iY, int32_t *iPan, int32_t iAudibilityRadius = 0, int32_t *outPlayer = nullptr);
bool ViewportNextPlayer();
bool FreeScroll(C4Vec2D vScrollBy); // key callback: Scroll ownerless viewport by some offset

View File

@ -76,7 +76,7 @@ int WINAPI WinMain (HINSTANCE hInst,
LPWSTR *curwarg = wargv;
while(argc--)
{
int arglen = WideCharToMultiByte(CP_UTF8, 0, *curwarg, -1, NULL, 0, 0, 0);
int arglen = WideCharToMultiByte(CP_UTF8, 0, *curwarg, -1, nullptr, 0, 0, 0);
char *utf8arg = new char[arglen ? arglen : 1];
WideCharToMultiByte(CP_UTF8, 0, *curwarg, -1, utf8arg, arglen, 0, 0);
argv.push_back(utf8arg);
@ -107,7 +107,7 @@ int WINAPI WinMain (HINSTANCE hInst,
int main()
{
return WinMain(GetModuleHandle(NULL), 0, 0, 0);
return WinMain(GetModuleHandle(nullptr), 0, 0, 0);
}
#else // _WIN32
@ -215,16 +215,16 @@ int main (int argc, char * argv[])
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
// Quit the program when asked
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGHUP, &sa, NULL);
sigaction(SIGINT, &sa, nullptr);
sigaction(SIGTERM, &sa, nullptr);
sigaction(SIGHUP, &sa, nullptr);
// Set up debugging facilities
sa.sa_flags |= SA_RESETHAND;
sigaction(SIGBUS, &sa, NULL);
sigaction(SIGILL, &sa, NULL);
sigaction(SIGSEGV, &sa, NULL);
sigaction(SIGABRT, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
sigaction(SIGBUS, &sa, nullptr);
sigaction(SIGILL, &sa, nullptr);
sigaction(SIGSEGV, &sa, nullptr);
sigaction(SIGABRT, &sa, nullptr);
sigaction(SIGFPE, &sa, nullptr);
#endif
// Init application

View File

@ -42,7 +42,7 @@ extern "C" {
#endif
// Global access pointer
C4Draw *pDraw=NULL;
C4Draw *pDraw=nullptr;
void C4BltTransform::SetRotate(float iAngle, float fOffX, float fOffY) // set by angle and rotation offset
{
@ -141,7 +141,7 @@ bool C4Pattern::Set(C4Surface * sfcSource, int iZoom)
C4Pattern::C4Pattern()
{
// disable
sfcPattern32=NULL;
sfcPattern32=nullptr;
CachedPattern = 0;
Zoom=0;
}
@ -154,7 +154,7 @@ void C4Pattern::Clear()
// unlock it
sfcPattern32->Unlock();
// clear field
sfcPattern32=NULL;
sfcPattern32=nullptr;
}
delete[] CachedPattern; CachedPattern = 0;
}
@ -171,15 +171,15 @@ DWORD C4Pattern::PatternClr(unsigned int iX, unsigned int iY) const
void C4Draw::Default()
{
RenderTarget=NULL;
RenderTarget=nullptr;
ClipAll=false;
Active=false;
BlitModulated=false;
dwBlitMode = 0;
ResetGamma();
pFoW = NULL;
pFoW = nullptr;
ZoomX = 0; ZoomY = 0; Zoom = 1;
MeshTransform = NULL;
MeshTransform = nullptr;
fUsePerspective = false;
}
@ -287,14 +287,14 @@ void C4Draw::Blit8Fast(CSurface8 * sfcSource, int fx, int fy,
if(bufcnt == BUF_SIZE)
{
PerformMultiPix(sfcTarget, vertices, BUF_SIZE, NULL);
PerformMultiPix(sfcTarget, vertices, BUF_SIZE, nullptr);
bufcnt = 0;
}
}
}
if(bufcnt > 0)
PerformMultiPix(sfcTarget, vertices, bufcnt, NULL);
PerformMultiPix(sfcTarget, vertices, bufcnt, nullptr);
delete[] vertices;
// unlock
if (!fRender) sfcTarget->Unlock();
@ -391,13 +391,13 @@ bool C4Draw::BlitUnscaled(C4Surface * sfcSource, float fx, float fy, float fwdt,
pBaseTex = sfcSource->pMainSfc->texture.get();
}
C4TexRef* pNormalTex = NULL;
C4TexRef* pNormalTex = nullptr;
if (sfcSource->pNormalSfc)
pNormalTex = sfcSource->pNormalSfc->texture.get();
// ClrByOwner is always fully opaque
const DWORD dwOverlayClrMod = 0xff000000 | sfcSource->ClrByOwnerClr;
PerformMultiTris(sfcTarget, vertices, 6, pTransform, pBaseTex, fBaseSfc ? pTex : NULL, pNormalTex, dwOverlayClrMod, NULL);
PerformMultiTris(sfcTarget, vertices, 6, pTransform, pBaseTex, fBaseSfc ? pTex : nullptr, pNormalTex, dwOverlayClrMod, nullptr);
// success
return true;
}
@ -527,7 +527,7 @@ bool C4Draw::BlitSurface(C4Surface * sfcSurface, C4Surface * sfcTarget, int tx,
{
if (!sfcSurface) return false;
C4Surface *pSfcBase = sfcSurface->pMainSfc;
sfcSurface->pMainSfc = NULL;
sfcSurface->pMainSfc = nullptr;
Blit(sfcSurface, 0.0f, 0.0f, (float)sfcSurface->Wdt, (float)sfcSurface->Hgt, sfcTarget, float(tx), float(ty), float(sfcSurface->Wdt), float(sfcSurface->Hgt), false);
sfcSurface->pMainSfc = pSfcBase;
return true;
@ -562,7 +562,7 @@ bool C4Draw::BlitSurfaceTile(C4Surface * sfcSurface, C4Surface * sfcTarget, floa
vertices[4] = vertices[0]; vertices[5] = vertices[2];
// Draw
PerformMultiTris(sfcTarget, vertices, 6, NULL, sfcSurface->texture.get(), NULL, NULL, 0, shader_call);
PerformMultiTris(sfcTarget, vertices, 6, nullptr, sfcSurface->texture.get(), nullptr, nullptr, 0, shader_call);
return true;
}
@ -610,7 +610,7 @@ void C4Draw::DrawPix(C4Surface * sfcDest, float tx, float ty, DWORD dwClr)
vtx.ftx = tx;
vtx.fty = ty;
DwTo4UB(dwClr, vtx.color);
PerformMultiPix(sfcDest, &vtx, 1, NULL);
PerformMultiPix(sfcDest, &vtx, 1, nullptr);
}
void C4Draw::DrawLineDw(C4Surface * sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width)
@ -620,7 +620,7 @@ void C4Draw::DrawLineDw(C4Surface * sfcTarget, float x1, float y1, float x2, flo
vertices[1].ftx = x2; vertices[1].fty = y2;
DwTo4UB(dwClr, vertices[0].color);
DwTo4UB(dwClr, vertices[1].color);
PerformMultiLines(sfcTarget, vertices, 2, width, NULL);
PerformMultiLines(sfcTarget, vertices, 2, width, nullptr);
}
void C4Draw::DrawCircleDw(C4Surface * sfcTarget, float cx, float cy, float r, DWORD dwClr, float width)
@ -637,7 +637,7 @@ void C4Draw::DrawCircleDw(C4Surface * sfcTarget, float cx, float cy, float r, DW
DwTo4UB(dwClr, vertices[iv].color);
vertices[(iv + 1) % (num_lines * 2)] = vertices[iv];
}
PerformMultiLines(sfcTarget, vertices.get(), num_lines * 2, width, NULL);
PerformMultiLines(sfcTarget, vertices.get(), num_lines * 2, width, nullptr);
}
void C4Draw::DrawFrameDw(C4Surface * sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr, float width) // make these parameters float...?
@ -655,7 +655,7 @@ void C4Draw::DrawFrameDw(C4Surface * sfcDest, int x1, int y1, int x2, int y2, DW
for(int i = 0; i < 8; ++i)
DwTo4UB(dwClr, vertices[i].color);
PerformMultiLines(sfcDest, vertices, 8, width, NULL);
PerformMultiLines(sfcDest, vertices, 8, width, nullptr);
}
void C4Draw::DrawQuadDw(C4Surface * sfcTarget, float *ipVtx, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4, C4ShaderCall* shader_call)
@ -671,7 +671,7 @@ void C4Draw::DrawQuadDw(C4Surface * sfcTarget, float *ipVtx, DWORD dwClr1, DWORD
DwTo4UB(dwClr4, vertices[3].color);
vertices[4] = vertices[0];
vertices[5] = vertices[2];
PerformMultiTris(sfcTarget, vertices, 6, NULL, NULL, NULL, NULL, 0, shader_call);
PerformMultiTris(sfcTarget, vertices, 6, nullptr, nullptr, nullptr, nullptr, 0, shader_call);
}
void C4Draw::DrawPatternedCircle(C4Surface * sfcDest, int x, int y, int r, BYTE col, C4Pattern & Pattern, CStdPalette &rPal)
@ -858,6 +858,6 @@ void C4Draw::DrawBoxDw(C4Surface * sfcDest, int iX1, int iY1, int iX2, int iY2,
}
else
{
DrawBoxFade(sfcDest, float(iX1), float(iY1), float(iX2 - iX1 + 1), float(iY2 - iY1 + 1), dwClr, dwClr, dwClr, dwClr, NULL);
DrawBoxFade(sfcDest, float(iX1), float(iY1), float(iX2 - iX1 + 1), float(iY2 - iY1 + 1), dwClr, dwClr, dwClr, dwClr, nullptr);
}
}

View File

@ -90,7 +90,7 @@ public:
static constexpr int COLOR_DEPTH_BYTES = COLOR_DEPTH / 8;
C4Draw(): MaxTexSize(0) { }
virtual ~C4Draw() { pDraw=NULL; }
virtual ~C4Draw() { pDraw=nullptr; }
public:
C4AbstractApp * pApp; // the application
bool Active; // set if device is ready to render, etc.
@ -117,7 +117,7 @@ public:
bool Init(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor);
virtual void Clear();
virtual void Default();
virtual CStdGLCtx *CreateContext(C4Window *, C4AbstractApp *) { return NULL; }
virtual CStdGLCtx *CreateContext(C4Window *, C4AbstractApp *) { return nullptr; }
virtual bool OnResolutionChanged(unsigned int iXRes, unsigned int iYRes) = 0; // reinit clipper for new resolution
// Clipper
bool GetPrimaryClipper(int &rX1, int &rY1, int &rX2, int &rY2);
@ -147,15 +147,15 @@ public:
C4Surface * sfcTarget, int tx, int ty, int wdt, int hgt);
bool Blit(C4Surface * sfcSource, float fx, float fy, float fwdt, float fhgt,
C4Surface * sfcTarget, float tx, float ty, float twdt, float thgt,
bool fSrcColKey=false, const C4BltTransform *pTransform=NULL);
bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr);
bool BlitUnscaled(C4Surface * sfcSource, float fx, float fy, float fwdt, float fhgt,
C4Surface * sfcTarget, float tx, float ty, float twdt, float thgt,
bool fSrcColKey=false, const C4BltTransform *pTransform=NULL);
bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr);
bool RenderMesh(StdMeshInstance &instance, C4Surface * sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform* pTransform); // Call PrepareMaterial with Mesh's material before
virtual void PerformMesh(StdMeshInstance &instance, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform* pTransform) = 0;
bool Blit8(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhgt, // force 8bit-blit (inline)
C4Surface * sfcTarget, int tx, int ty, int twdt, int thgt,
bool fSrcColKey=false, const C4BltTransform *pTransform=NULL);
bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr);
bool BlitSimple(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhgt,
C4Surface * sfcTarget, int tx, int ty, int twdt, int thgt,
bool fTransparency=true);
@ -196,7 +196,7 @@ public:
void GetZoom(ZoomData *r) { r->Zoom=Zoom; r->X=ZoomX; r->Y=ZoomY; }
void ApplyZoom(float & X, float & Y);
void RemoveZoom(float & X, float & Y);
void SetMeshTransform(const StdMeshMatrix* Transform) { MeshTransform = Transform; } // if non-NULL make sure to keep matrix valid
void SetMeshTransform(const StdMeshMatrix* Transform) { MeshTransform = Transform; } // if non-nullptr make sure to keep matrix valid
void SetPerspective(bool fSet) { fUsePerspective = fSet; }
// device objects

View File

@ -117,7 +117,7 @@ CStdGL::CStdGL():
CStdGL::~CStdGL()
{
Clear();
pGL=NULL;
pGL=nullptr;
}
void CStdGL::Clear()
@ -126,7 +126,7 @@ void CStdGL::Clear()
// cannot unlock TexMgr here or we can't preserve textures across GL reinitialization as required when changing multisampling
InvalidateDeviceObjects();
NoPrimaryClipper();
RenderTarget = NULL;
RenderTarget = nullptr;
// Clear all shaders
SpriteShader.Clear();
SpriteShaderMod2.Clear();
@ -229,7 +229,7 @@ bool CStdGL::PrepareSpriteShader(C4Shader& shader, const char* name, int ssc, C4
uniformNames[C4SSU_Bones] = "bones"; // unused
uniformNames[C4SSU_CullMode] = "cullMode"; // unused
uniformNames[C4SSU_FrameCounter] = "frameCounter";
uniformNames[C4SSU_Count] = NULL;
uniformNames[C4SSU_Count] = nullptr;
const char* attributeNames[C4SSA_Count + 1];
attributeNames[C4SSA_Position] = "oc_Position";
@ -240,7 +240,7 @@ bool CStdGL::PrepareSpriteShader(C4Shader& shader, const char* name, int ssc, C4
attributeNames[C4SSA_BoneIndices1] = "oc_BoneIndices1"; // unused
attributeNames[C4SSA_BoneWeights0] = "oc_BoneWeights0"; // unused
attributeNames[C4SSA_BoneWeights1] = "oc_BoneWeights1"; // unused
attributeNames[C4SSA_Count] = NULL;
attributeNames[C4SSA_Count] = nullptr;
// Clear previous content
shader.Clear();
@ -256,7 +256,7 @@ bool CStdGL::PrepareSpriteShader(C4Shader& shader, const char* name, int ssc, C4
if (ssc & C4SSC_OVERLAY) shader.AddDefine("OC_HAVE_OVERLAY");
if (additionalDefines)
for (const char* const* define = additionalDefines; *define != NULL; ++define)
for (const char* const* define = additionalDefines; *define != nullptr; ++define)
shader.AddDefine(*define);
// Then load slices for fragment and vertex shader
@ -268,7 +268,7 @@ bool CStdGL::PrepareSpriteShader(C4Shader& shader, const char* name, int ssc, C4
shader.SetScriptCategories({"Common", "Object"});
if (additionalSlices)
for (const char* const* slice = additionalSlices; *slice != NULL; ++slice)
for (const char* const* slice = additionalSlices; *slice != nullptr; ++slice)
shader.LoadFragmentSlices(pGroups, *slice);
if (!shader.Init(name, uniformNames, attributeNames))
@ -291,7 +291,7 @@ void CStdGL::ObjectLabel(uint32_t identifier, uint32_t name, int32_t length, con
CStdGLCtx *CStdGL::CreateContext(C4Window * pWindow, C4AbstractApp *pApp)
{
// safety
if (!pWindow) return NULL;
if (!pWindow) return nullptr;
// create it
CStdGLCtx *pCtx;
@ -358,11 +358,11 @@ CStdGLCtx *CStdGL::CreateContext(C4Window * pWindow, C4AbstractApp *pApp)
}
if (!success)
{
delete pCtx; Error(" gl: Error creating secondary context!"); return NULL;
delete pCtx; Error(" gl: Error creating secondary context!"); return nullptr;
}
// creation selected the new context - switch back to previous context
RenderTarget = NULL;
pCurrCtx = NULL;
RenderTarget = nullptr;
pCurrCtx = nullptr;
// done
return pCtx;
}
@ -408,13 +408,13 @@ void CStdGL::SetupMultiBlt(C4ShaderCall& call, const C4BltTransform* pTransform,
call.SetUniform4fv(C4SSU_OverlayClr, 1, fOverlayModClr);
}
if(pFoW != NULL && normalTex != 0)
if(pFoW != nullptr && normalTex != 0)
{
call.AllocTexUnit(C4SSU_NormalTex);
glBindTexture(GL_TEXTURE_2D, normalTex);
}
if(pFoW != NULL)
if(pFoW != nullptr)
{
const C4Rect OutRect = GetOutRect();
const C4Rect ClipRect = GetClipRect();
@ -461,7 +461,7 @@ void CStdGL::SetupMultiBlt(C4ShaderCall& call, const C4BltTransform* pTransform,
if(pTransform)
{
float sz = 1.0f;
if (pFoW != NULL && normalTex != 0)
if (pFoW != nullptr && normalTex != 0)
{
// Decompose scale factors and scale Z accordingly to X and Y, again to avoid distorting normals
// We could instead work around this by using the projection matrix, but then for object rotations (SetR)
@ -495,7 +495,7 @@ void CStdGL::SetupMultiBlt(C4ShaderCall& call, const C4BltTransform* pTransform,
call.SetUniformMatrix4x4(C4SSU_ProjectionMatrix, ProjectionMatrix);
call.SetUniformMatrix4x4(C4SSU_ModelViewMatrix, modelview);
if (pFoW != NULL && normalTex != 0)
if (pFoW != nullptr && normalTex != 0)
call.SetUniformMatrix3x3Transpose(C4SSU_NormalMatrix, StdMeshMatrix::Inverse(StdProjectionMatrix::Upper3x4(modelview)));
}
@ -514,13 +514,13 @@ void CStdGL::PerformMultiPix(C4Surface* sfcTarget, const C4BltVertex* vertices,
if (!shader_call)
{
C4ShaderCall call(GetSpriteShader(false, false, false));
SetupMultiBlt(call, NULL, 0, 0, 0, 0, &transform);
SetupMultiBlt(call, nullptr, 0, 0, 0, 0, &transform);
for(unsigned int i = 0; i < n_vertices; i += BATCH_SIZE)
PerformMultiBlt(sfcTarget, OP_POINTS, &vertices[i], std::min(n_vertices - i, BATCH_SIZE), false, &call);
}
else
{
SetupMultiBlt(*shader_call, NULL, 0, 0, 0, 0, &transform);
SetupMultiBlt(*shader_call, nullptr, 0, 0, 0, 0, &transform);
for(unsigned int i = 0; i < n_vertices; i += BATCH_SIZE)
PerformMultiBlt(sfcTarget, OP_POINTS, &vertices[i], std::min(n_vertices - i, BATCH_SIZE), false, shader_call);
}
@ -574,12 +574,12 @@ void CStdGL::PerformMultiLines(C4Surface* sfcTarget, const C4BltVertex* vertices
if (!shader_call)
{
C4ShaderCall call(GetSpriteShader(true, false, false));
SetupMultiBlt(call, NULL, lines_tex, 0, 0, 0, NULL);
SetupMultiBlt(call, nullptr, lines_tex, 0, 0, 0, nullptr);
PerformMultiBlt(sfcTarget, OP_TRIANGLES, tri_vertices, n_vertices * 3, true, &call);
}
else
{
SetupMultiBlt(*shader_call, NULL, lines_tex, 0, 0, 0, NULL);
SetupMultiBlt(*shader_call, nullptr, lines_tex, 0, 0, 0, nullptr);
PerformMultiBlt(sfcTarget, OP_TRIANGLES, tri_vertices, n_vertices * 3, true, shader_call);
}
@ -591,14 +591,14 @@ void CStdGL::PerformMultiTris(C4Surface* sfcTarget, const C4BltVertex* vertices,
// Feed the vertices to the GL
if (!shader_call)
{
C4ShaderCall call(GetSpriteShader(pTex != NULL, pOverlay != NULL, pNormal != NULL));
SetupMultiBlt(call, pTransform, pTex ? pTex->texName : 0, pOverlay ? pOverlay->texName : 0, pNormal ? pNormal->texName : 0, dwOverlayModClr, NULL);
PerformMultiBlt(sfcTarget, OP_TRIANGLES, vertices, n_vertices, pTex != NULL, &call);
C4ShaderCall call(GetSpriteShader(pTex != nullptr, pOverlay != nullptr, pNormal != nullptr));
SetupMultiBlt(call, pTransform, pTex ? pTex->texName : 0, pOverlay ? pOverlay->texName : 0, pNormal ? pNormal->texName : 0, dwOverlayModClr, nullptr);
PerformMultiBlt(sfcTarget, OP_TRIANGLES, vertices, n_vertices, pTex != nullptr, &call);
}
else
{
SetupMultiBlt(*shader_call, pTransform, pTex ? pTex->texName : 0, pOverlay ? pOverlay->texName : 0, pNormal ? pNormal->texName : 0, dwOverlayModClr, NULL);
PerformMultiBlt(sfcTarget, OP_TRIANGLES, vertices, n_vertices, pTex != NULL, shader_call);
SetupMultiBlt(*shader_call, pTransform, pTex ? pTex->texName : 0, pOverlay ? pOverlay->texName : 0, pNormal ? pNormal->texName : 0, dwOverlayModClr, nullptr);
PerformMultiBlt(sfcTarget, OP_TRIANGLES, vertices, n_vertices, pTex != nullptr, shader_call);
}
}
@ -673,8 +673,8 @@ C4Shader* CStdGL::GetSpriteShader(bool haveBase, bool haveOverlay, bool haveNorm
if(dwBlitMode & C4GFXBLIT_MOD2) ssc |= C4SSC_MOD2;
if(haveBase) ssc |= C4SSC_BASE;
if(haveBase && haveOverlay) ssc |= C4SSC_OVERLAY;
if(pFoW != NULL) ssc |= C4SSC_LIGHT;
if(pFoW != NULL && haveBase && haveNormal) ssc |= C4SSC_NORMAL;
if(pFoW != nullptr) ssc |= C4SSC_LIGHT;
if(pFoW != nullptr && haveBase && haveNormal) ssc |= C4SSC_NORMAL;
return GetSpriteShader(ssc);
}
@ -722,38 +722,38 @@ C4Shader* CStdGL::GetSpriteShader(int ssc)
bool CStdGL::InitShaders(C4GroupSet* pGroups)
{
// Create sprite blitting shaders
if(!PrepareSpriteShader(SpriteShader, "sprite", 0, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShader, "sprite", 0, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderMod2, "spriteMod2", C4SSC_MOD2, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderMod2, "spriteMod2", C4SSC_MOD2, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderBase, "spriteBase", C4SSC_BASE, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderBase, "spriteBase", C4SSC_BASE, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderBaseMod2, "spriteBaseMod2", C4SSC_MOD2 | C4SSC_BASE, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderBaseMod2, "spriteBaseMod2", C4SSC_MOD2 | C4SSC_BASE, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderBaseOverlay, "spriteBaseOverlay", C4SSC_BASE | C4SSC_OVERLAY, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderBaseOverlay, "spriteBaseOverlay", C4SSC_BASE | C4SSC_OVERLAY, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderBaseOverlayMod2, "spriteBaseOverlayMod2", C4SSC_MOD2 | C4SSC_BASE | C4SSC_OVERLAY, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderBaseOverlayMod2, "spriteBaseOverlayMod2", C4SSC_MOD2 | C4SSC_BASE | C4SSC_OVERLAY, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLight, "spriteLight", C4SSC_LIGHT, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLight, "spriteLight", C4SSC_LIGHT, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLightMod2, "spriteLightMod2", C4SSC_LIGHT | C4SSC_MOD2, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLightMod2, "spriteLightMod2", C4SSC_LIGHT | C4SSC_MOD2, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLightBase, "spriteLightBase", C4SSC_LIGHT | C4SSC_BASE, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLightBase, "spriteLightBase", C4SSC_LIGHT | C4SSC_BASE, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLightBaseMod2, "spriteLightBaseMod2", C4SSC_LIGHT | C4SSC_BASE | C4SSC_MOD2, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLightBaseMod2, "spriteLightBaseMod2", C4SSC_LIGHT | C4SSC_BASE | C4SSC_MOD2, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLightBaseOverlay, "spriteLightBaseOverlay", C4SSC_LIGHT | C4SSC_BASE | C4SSC_OVERLAY, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLightBaseOverlay, "spriteLightBaseOverlay", C4SSC_LIGHT | C4SSC_BASE | C4SSC_OVERLAY, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLightBaseOverlayMod2, "spriteLightBaseOverlayMod2", C4SSC_LIGHT | C4SSC_BASE | C4SSC_OVERLAY | C4SSC_MOD2, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLightBaseOverlayMod2, "spriteLightBaseOverlayMod2", C4SSC_LIGHT | C4SSC_BASE | C4SSC_OVERLAY | C4SSC_MOD2, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLightBaseNormal, "spriteLightBaseNormal", C4SSC_LIGHT | C4SSC_BASE | C4SSC_NORMAL, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLightBaseNormal, "spriteLightBaseNormal", C4SSC_LIGHT | C4SSC_BASE | C4SSC_NORMAL, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLightBaseNormalMod2, "spriteLightBaseNormalMod2", C4SSC_LIGHT | C4SSC_BASE | C4SSC_NORMAL | C4SSC_MOD2, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLightBaseNormalMod2, "spriteLightBaseNormalMod2", C4SSC_LIGHT | C4SSC_BASE | C4SSC_NORMAL | C4SSC_MOD2, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLightBaseNormalOverlay, "spriteLightBaseNormalOverlay", C4SSC_LIGHT | C4SSC_BASE | C4SSC_OVERLAY | C4SSC_NORMAL, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLightBaseNormalOverlay, "spriteLightBaseNormalOverlay", C4SSC_LIGHT | C4SSC_BASE | C4SSC_OVERLAY | C4SSC_NORMAL, pGroups, nullptr, nullptr))
return false;
if(!PrepareSpriteShader(SpriteShaderLightBaseNormalOverlayMod2, "spriteLightBaseNormalOverlayMod2", C4SSC_LIGHT | C4SSC_BASE | C4SSC_OVERLAY | C4SSC_NORMAL | C4SSC_MOD2, pGroups, NULL, NULL))
if(!PrepareSpriteShader(SpriteShaderLightBaseNormalOverlayMod2, "spriteLightBaseNormalOverlayMod2", C4SSC_LIGHT | C4SSC_BASE | C4SSC_OVERLAY | C4SSC_NORMAL | C4SSC_MOD2, pGroups, nullptr, nullptr))
return false;
return true;
@ -796,7 +796,7 @@ bool CStdGL::RestoreDeviceObjects()
{
GenericVBOSizes[i] = GENERIC_VBO_SIZE;
glBindBuffer(GL_ARRAY_BUFFER, GenericVBOs[i]);
glBufferData(GL_ARRAY_BUFFER, GenericVBOSizes[i] * sizeof(C4BltVertex), NULL, GL_STREAM_DRAW);
glBufferData(GL_ARRAY_BUFFER, GenericVBOSizes[i] * sizeof(C4BltVertex), nullptr, GL_STREAM_DRAW);
GenericVAOs[i] = GenVAOID();
GenericVAOs[i + N_GENERIC_VBOS] = GenVAOID();
}
@ -869,11 +869,11 @@ bool CStdGL::Error(const char *szMsg)
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nullptr,
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
0, nullptr );
LogF(" gl: GetLastError() = %d - %s", err, StdStrBuf(lpMsgBuf).getData());
LocalFree(lpMsgBuf);
#endif
@ -909,7 +909,7 @@ bool CStdGL::CheckGLError(const char *szAtOp)
return false;
}
CStdGL *pGL=NULL;
CStdGL *pGL=nullptr;
bool CStdGL::OnResolutionChanged(unsigned int iXRes, unsigned int iYRes)
{
@ -922,7 +922,7 @@ bool CStdGL::OnResolutionChanged(unsigned int iXRes, unsigned int iYRes)
void CStdGL::Default()
{
C4Draw::Default();
pCurrCtx = NULL;
pCurrCtx = nullptr;
iPixelFormat=0;
sfcFmt=0;
Workarounds.LowMaxVertexUniformCount = false;
@ -1020,7 +1020,7 @@ void CStdGL::FreeVAOID(unsigned int vaoid)
bool CStdGL::GetVAO(unsigned int vaoid, GLuint& vao)
{
assert(pCurrCtx != NULL);
assert(pCurrCtx != nullptr);
if (vaoid >= pCurrCtx->hVAOs.size())
{

View File

@ -382,7 +382,7 @@ bool CStdGLCtx::Init(C4Window * pWindow, C4AbstractApp *pApp)
return true;
}
ReleaseDC(pWindow->renderwnd, hDC); hDC = NULL;
ReleaseDC(pWindow->renderwnd, hDC); hDC = nullptr;
return false;
}
@ -425,9 +425,9 @@ void CStdGLCtx::Deselect()
{
if (pGL && pGL->pCurrCtx == this)
{
wglMakeCurrent(NULL, NULL);
pGL->pCurrCtx=NULL;
pGL->RenderTarget=NULL;
wglMakeCurrent(nullptr, nullptr);
pGL->pCurrCtx=nullptr;
pGL->RenderTarget=nullptr;
}
}
@ -441,7 +441,7 @@ bool CStdGLCtx::PageFlip()
#elif defined(USE_SDL_MAINLOOP)
CStdGLCtx::CStdGLCtx(): pWindow(0), this_context(contexts.end()) { ctx = NULL; }
CStdGLCtx::CStdGLCtx(): pWindow(0), this_context(contexts.end()) { ctx = nullptr; }
void CStdGLCtx::Clear(bool multisample_change)
{
@ -535,7 +535,7 @@ bool CStdGLCtx::PageFlip()
#include <QOpenGLContext>
#include <QOffscreenSurface>
CStdGLCtxQt::CStdGLCtxQt() { context = NULL; surface = NULL; }
CStdGLCtxQt::CStdGLCtxQt() { context = nullptr; surface = nullptr; }
void CStdGLCtxQt::Clear(bool multisample_change)
{

View File

@ -528,7 +528,7 @@ namespace
call.SetUniform1f(C4SSU_CullMode, cullFace ? 0.0f : 1.0f);
// Dynamic light
if(pFoW != NULL)
if(pFoW != nullptr)
{
call.AllocTexUnit(C4SSU_LightTex);
glBindTexture(GL_TEXTURE_2D, pFoW->getSurfaceName());
@ -705,7 +705,7 @@ namespace
// Unmapping the buffer may fail for certain reasons, in which case we need to try again.
do
{
glBufferData(GL_ARRAY_BUFFER, vertex_count * sizeof(PretransformedMeshVertex), NULL, GL_STREAM_DRAW);
glBufferData(GL_ARRAY_BUFFER, vertex_count * sizeof(PretransformedMeshVertex), nullptr, GL_STREAM_DRAW);
void *map = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
PretransformedMeshVertex *buffer = new (map) PretransformedMeshVertex[vertex_count];
@ -811,12 +811,12 @@ namespace
glBlendFunc(OgreBlendTypeToGL(pass.SceneBlendFactors[0]), GL_ONE);
}
assert(pass.Program.get() != NULL);
assert(pass.Program.get() != nullptr);
// Upload all parameters to the shader
int ssc = 0;
if (dwBlitMode & C4GFXBLIT_MOD2) ssc |= C4SSC_MOD2;
if (pFoW != NULL) ssc |= C4SSC_LIGHT;
if (pFoW != nullptr) ssc |= C4SSC_LIGHT;
const C4Shader* shader = pass.Program->Program->GetShader(ssc);
if (!shader) return;
C4ShaderCall call(shader);

View File

@ -30,7 +30,7 @@
void C4Facet::Default()
{
Set(NULL,0,0,0,0);
Set(nullptr,0,0,0,0);
}
void C4Facet::Set(C4Surface * nsfc, float nx, float ny, float nwdt, float nhgt)
@ -507,7 +507,7 @@ void C4DrawTransform::CompileFunc(StdCompiler *pComp)
val.AppendChar('.'); val.Append(val2);
}
#ifdef WITH_GLIB
mat[i] = g_ascii_strtod (val.getData(), NULL);
mat[i] = g_ascii_strtod (val.getData(), nullptr);
#else
if (fCompiler) sscanf(val.getData(), "%g", &mat[i]);
#endif

View File

@ -132,7 +132,7 @@ public:
void DrawX(C4Surface * sfcTarget, float iX, float iY, float iWdt, float iHgt, int32_t iPhaseX=0, int32_t iPhaseY=0) const;
void DrawXFloat(C4Surface * sfcTarget, float fX, float fY, float fWdt, float fHgt) const;
void DrawValue(C4Facet &cgo, int32_t iValue, int32_t iPhaseX=0, int32_t iPhaseY=0, int32_t iAlign=C4FCT_Center);
void DrawValue2(C4Facet &cgo, int32_t iValue1, int32_t iValue2, int32_t iPhaseX=0, int32_t iPhaseY=0, int32_t iAlign=C4FCT_Center, int32_t *piUsedWidth=NULL);
void DrawValue2(C4Facet &cgo, int32_t iValue1, int32_t iValue2, int32_t iPhaseX=0, int32_t iPhaseY=0, int32_t iAlign=C4FCT_Center, int32_t *piUsedWidth=nullptr);
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true);
void DrawFullScreen(C4Facet &cgo);
void DrawT(C4Surface * sfcTarget, float iX, float iY, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform *pTransform); // draw with transformation (if pTransform is assigned)
@ -179,7 +179,7 @@ public:
float ParRefX, ParRefY;
public:
void Default() { TargetX=TargetY=0; Zoom=1; ParRefX=ParRefY=0; C4Facet::Default(); }
void Clear() { Surface=NULL; }
void Clear() { Surface=nullptr; }
void Set(const C4Facet &cpy) { TargetX=TargetY=0; Zoom=1; ParRefX=ParRefY=0; C4Facet::Set(cpy); }
void Set(const C4TargetFacet &cpy) { *this = cpy; }

View File

@ -85,7 +85,7 @@ bool C4FacetSurface::Load(C4Group &hGroup, const char *szName, int iWdt, int iHg
if (!*szExt)
{
// no extension: Default to extension that is found as file in group
const char * const extensions[] = { "png", "bmp", "jpeg", "jpg", NULL };
const char * const extensions[] = { "png", "bmp", "jpeg", "jpg", nullptr };
int i = 0; const char *szExt;
while ((szExt = extensions[i++]))
{

View File

@ -101,7 +101,7 @@ bool C4FontLoader::InitFont(CStdFont * rFont, const char *szFontName, FontType e
LogF(LoadResStr("IDS_PRC_UPDATEFONT"), FontFaceName, iDefFontSize, dwDefWeight);
}
// check if one of the internally listed fonts should be used
const char * const extensions[] = { "ttf", "otf", "ttc", "fon", "fnt", "fot", NULL };
const char * const extensions[] = { "ttf", "otf", "ttc", "fon", "fnt", "fot", nullptr };
char FileName[_MAX_PATH+1];
int32_t ID;
C4Group * pGrp = pGfxGroups->FindSuitableFile(FontFaceName, extensions, FileName, &ID);
@ -110,7 +110,7 @@ bool C4FontLoader::InitFont(CStdFont * rFont, const char *szFontName, FontType e
if (LastUsedGrpID != ID || LastUsedName != FontFaceName)
{
DestroyFont(pLastUsedFont);
pLastUsedFont = NULL;
pLastUsedFont = nullptr;
}
if (!pLastUsedFont)
{
@ -126,7 +126,7 @@ bool C4FontLoader::InitFont(CStdFont * rFont, const char *szFontName, FontType e
catch (std::runtime_error & e)
{
LogFatal(e.what());
pGrp = NULL;
pGrp = nullptr;
}
}
}
@ -137,7 +137,7 @@ bool C4FontLoader::InitFont(CStdFont * rFont, const char *szFontName, FontType e
if (LastUsedGrpID != -1 || LastUsedName != FontFaceName)
{
DestroyFont(pLastUsedFont);
pLastUsedFont = NULL;
pLastUsedFont = nullptr;
}
if (!pLastUsedFont)
{
@ -180,7 +180,7 @@ void C4FontLoader::Clear()
#ifndef USE_CONSOLE
// delete vector font cache
DestroyFont(pLastUsedFont);
pLastUsedFont = NULL;
pLastUsedFont = nullptr;
#endif
}
@ -196,7 +196,7 @@ public:
#if defined(_WIN32)
// Win32 using freetype: Load TrueType-data from WinGDI into Data-buffer to be used by FreeType
bool fSuccess = false;
HDC hDC = ::CreateCompatibleDC(NULL);
HDC hDC = ::CreateCompatibleDC(nullptr);
if (hDC)
{
HFONT hFont = ::CreateFontA(0, 0, 0, 0, FW_DONTCARE, false,
@ -206,7 +206,7 @@ public:
if (hFont)
{
SelectObject( hDC, hFont );
uint32_t dwTTFSize = ::GetFontData(hDC, 0, 0, NULL, 0);
uint32_t dwTTFSize = ::GetFontData(hDC, 0, 0, nullptr, 0);
if (dwTTFSize && dwTTFSize != GDI_ERROR)
{
Data.SetSize(dwTTFSize);
@ -285,7 +285,7 @@ CStdFont::CStdFont()
{
#ifndef USE_CONSOLE
// set default values
sfcCurrent = NULL;
sfcCurrent = nullptr;
iSfcSizes = 64;
dwDefFontHeight=iLineHgt=10;
iFontZoom=1; // default: no internal font zooming - likely no antialiasing either...
@ -296,8 +296,8 @@ CStdFont::CStdFont()
// font not yet initialized
*szFontName=0;
id=0;
pCustomImages=NULL;
pVectorFont = NULL;
pCustomImages=nullptr;
pVectorFont = nullptr;
#endif
}
@ -346,11 +346,11 @@ bool CStdFont::AddRenderedChar(uint32_t dwChar, C4Facet *pfctTarget)
iBoldness = (1<<16) + (iBoldness<<16)/400;
FT_Matrix mat;
mat.xx = iBoldness; mat.xy = mat.yx = 0; mat.yy = 1<<16;
FT_Set_Transform(*pVectorFont, &mat, NULL);
FT_Set_Transform(*pVectorFont, &mat, nullptr);
}
else
{
FT_Set_Transform(*pVectorFont, NULL, NULL);
FT_Set_Transform(*pVectorFont, nullptr, nullptr);
}
// Render
if (FT_Load_Char(*pVectorFont, dwChar, FT_LOAD_RENDER | FT_LOAD_NO_HINTING))
@ -487,10 +487,10 @@ void CStdFont::Clear()
{
#ifndef USE_CONSOLE
FontLoader.DestroyFont(pVectorFont);
pVectorFont = NULL;
pVectorFont = nullptr;
// clear font sfcs
sfcCurrent = NULL;
sfcCurrent = nullptr;
psfcFontData.clear();
for (int c=' '; c<256; ++c) fctAsciiTexCoords[c-' '].Default();
fctUnicodeMap.clear();
@ -613,7 +613,7 @@ std::tuple<std::string, int> CStdFont::BreakMessage(const char *szMsg, int iWdt,
uint32_t c;
const char *szPos=szMsg, // current parse position in the text
*szLastBreakPos = szMsg, // points to the char after at (whitespace) or after ('-') which text can be broken
*szLastEmergenyBreakPos = NULL, // same, but at last char in case no suitable linebreak could be found
*szLastEmergenyBreakPos = nullptr, // same, but at last char in case no suitable linebreak could be found
*szLastPos; // last position until which buffer has been transferred to output
int iLastBreakOutLen = 0, iLastEmergencyBreakOutLen = 0; // size of output string at break positions
int iX=0, // current text width at parse pos
@ -796,7 +796,7 @@ void CStdFont::DrawText(C4Surface * sfcDest, float iX, float iY, DWORD dwColor,
{
#ifndef USE_CONSOLE
assert(IsValidUtf8(szText));
C4DrawTransform bt, *pbt=NULL;
C4DrawTransform bt, *pbt=nullptr;
// set blit color
DWORD dwOldModClr;
bool fWasModulated = pDraw->GetBlitModulation(dwOldModClr);

View File

@ -54,7 +54,7 @@ public:
C4FontLoader()
#ifndef USE_CONSOLE
: pLastUsedFont(NULL), LastUsedGrpID(0)
: pLastUsedFont(nullptr), LastUsedGrpID(0)
#endif
{ } // ctor
~C4FontLoader() { Clear(); } // dtor

View File

@ -140,7 +140,7 @@ void C4GraphicsResource::Clear()
// unhook deflist from font
FontRegular.SetCustomImages(NULL);
FontRegular.SetCustomImages(nullptr);
Achievements.Clear();
@ -365,7 +365,7 @@ void C4GraphicsResource::CloseFiles()
static C4Group *FindSuitableFile(const char *szName, C4GroupSet &rGfxSet, char *szFileName, int32_t * pID)
{
const char * const extensions[] = { "bmp", "jpeg", "jpg", "png", NULL };
const char * const extensions[] = { "bmp", "jpeg", "jpg", "png", nullptr };
return rGfxSet.FindSuitableFile(szName, extensions, szFileName, pID);
}

View File

@ -105,7 +105,7 @@ public:
// achievement graphics
C4AchievementGraphics Achievements;
public:
CStdFont &GetFontByHeight(int32_t iHgt, float *pfZoom=NULL); // get optimal font for given control size
CStdFont &GetFontByHeight(int32_t iHgt, float *pfZoom=nullptr); // get optimal font for given control size
void Default();
void Clear();
bool InitFonts();

View File

@ -73,12 +73,12 @@ void C4Shader::AddDefine(const char* name)
void C4Shader::AddVertexSlice(int iPos, const char *szText)
{
AddSlice(VertexSlices, iPos, szText, NULL, 0, 0);
AddSlice(VertexSlices, iPos, szText, nullptr, 0, 0);
}
void C4Shader::AddFragmentSlice(int iPos, const char *szText)
{
AddSlice(FragmentSlices, iPos, szText, NULL, 0, 0);
AddSlice(FragmentSlices, iPos, szText, nullptr, 0, 0);
}
void C4Shader::AddVertexSlices(const char *szWhat, const char *szText, const char *szSource, int iSourceTime)
@ -413,13 +413,13 @@ bool C4Shader::Init(const char *szWhat, const char **szUniforms, const char **sz
// Allocate uniform and attribute arrays
int iUniformCount = 0;
if (szUniforms != NULL)
if (szUniforms != nullptr)
while (szUniforms[iUniformCount])
iUniformCount++;
Uniforms.resize(iUniformCount);
int iAttributeCount = 0;
if (szAttributes != NULL)
if (szAttributes != nullptr)
while (szAttributes[iAttributeCount])
iAttributeCount++;
Attributes.resize(iAttributeCount);
@ -525,12 +525,12 @@ bool C4Shader::Refresh()
std::vector<const char*> UniformNames(Uniforms.size() + 1);
for (std::size_t i = 0; i < Uniforms.size(); ++i)
UniformNames[i] = Uniforms[i].name;
UniformNames[Uniforms.size()] = NULL;
UniformNames[Uniforms.size()] = nullptr;
std::vector<const char*> AttributeNames(Attributes.size() + 1);
for (std::size_t i = 0; i < Attributes.size(); ++i)
AttributeNames[i] = Attributes[i].name;
AttributeNames[Attributes.size()] = NULL;
AttributeNames[Attributes.size()] = nullptr;
#endif
// Reinitialise

View File

@ -82,17 +82,17 @@ void C4Surface::Default()
{
Wdt=Hgt=0;
Scale=1;
PrimarySurfaceLockPitch=0; PrimarySurfaceLockBits=NULL;
PrimarySurfaceLockPitch=0; PrimarySurfaceLockBits=nullptr;
ClipX=ClipY=ClipX2=ClipY2=0;
Locked=0;
Attached=false;
fPrimary=false;
pMainSfc=NULL;
pNormalSfc=NULL;
pMainSfc=nullptr;
pNormalSfc=nullptr;
#ifndef USE_CONSOLE
pCtx=NULL;
pCtx=nullptr;
#endif
pWindow=NULL;
pWindow=nullptr;
ClrByOwnerClr=0;
iTexSize=0;
fIsBackground=false;
@ -114,7 +114,7 @@ void C4Surface::MoveFrom(C4Surface *psfcFrom)
Wdt=psfcFrom->Wdt; Hgt=psfcFrom->Hgt;
PrimarySurfaceLockPitch=psfcFrom->PrimarySurfaceLockPitch;
PrimarySurfaceLockBits=psfcFrom->PrimarySurfaceLockBits;
psfcFrom->PrimarySurfaceLockBits=NULL;
psfcFrom->PrimarySurfaceLockBits=nullptr;
ClipX=psfcFrom->ClipX; ClipY=psfcFrom->ClipY;
ClipX2=psfcFrom->ClipX2; ClipY2=psfcFrom->ClipY2;
Locked=psfcFrom->Locked;
@ -398,8 +398,8 @@ bool C4Surface::SavePNG(const char *szFilename, bool fSaveAlpha, bool fSaveOverl
if (!png->Create(Wdt, Hgt, fSaveAlpha)) { Unlock(); return false; }
// reset overlay if desired
C4Surface *pMainSfcBackup = NULL;
if (fSaveOverlayOnly) { pMainSfcBackup=pMainSfc; pMainSfc=NULL; }
C4Surface *pMainSfcBackup = nullptr;
if (fSaveOverlayOnly) { pMainSfcBackup=pMainSfc; pMainSfc=nullptr; }
#ifndef USE_CONSOLE
if (fPrimary)
@ -500,7 +500,7 @@ bool C4Surface::Unlock()
DWORD C4Surface::GetPixDw(int iX, int iY, bool fApplyModulation)
{
BYTE *pBuf = NULL; int iPitch = 0; // TODO: are those initialised to something sensible?
BYTE *pBuf = nullptr; int iPitch = 0; // TODO: are those initialised to something sensible?
// backup pos
int iX2=iX; int iY2=iY;
// primary?
@ -650,7 +650,7 @@ C4TexRef::C4TexRef(int iSizeX, int iSizeY, int iFlags)
#ifndef USE_CONSOLE
texName = 0;
#endif
texLock.pBits=NULL; fIntLock=false;
texLock.pBits=nullptr; fIntLock=false;
// store size
this->iSizeX=iSizeX;
this->iSizeY=iSizeY;
@ -702,7 +702,7 @@ void C4TexRef::CreateTexture()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, fTileable ? GL_REPEAT : GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, fMipMap ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iSizeX, iSizeY, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iSizeX, iSizeY, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
if (fMipMap) glGenerateMipmap(GL_TEXTURE_2D);
#endif
}
@ -784,7 +784,7 @@ void C4TexRef::Unlock()
LockSize.x, LockSize.y, LockSize.Wdt, LockSize.Hgt,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, texLock.pBits);
delete[] static_cast<unsigned char*>(texLock.pBits); texLock.pBits=NULL;
delete[] static_cast<unsigned char*>(texLock.pBits); texLock.pBits=nullptr;
if (fMipMap) glGenerateMipmap(GL_TEXTURE_2D);
#endif
}
@ -844,7 +844,7 @@ void C4TexMgr::UnregTex(C4TexRef *pTex)
// remove texture from list
Textures.remove(pTex);
// if list is empty, remove self
if (Textures.empty()) { delete this; pTexMgr=NULL; }
if (Textures.empty()) { delete this; pTexMgr=nullptr; }
}
void C4TexMgr::IntLock()

View File

@ -79,7 +79,7 @@ public:
#endif
std::unique_ptr<C4TexRef> texture;
C4Surface *pMainSfc; // main surface for simple ColorByOwner-surfaces
C4Surface *pNormalSfc; // normal map; can be NULL
C4Surface *pNormalSfc; // normal map; can be nullptr
DWORD ClrByOwnerClr; // current color to be used for ColorByOwner-blits
void MoveFrom(C4Surface *psfcFrom); // grab data from other surface - invalidates other surface
@ -110,7 +110,7 @@ public:
#endif
// Only for surfaces which map to a window
bool UpdateSize(int wdt, int hgt);
bool PageFlip(C4Rect *pSrcRt=NULL, C4Rect *pDstRt=NULL);
bool PageFlip(C4Rect *pSrcRt=nullptr, C4Rect *pDstRt=nullptr);
void Clear();
void Default();

View File

@ -35,7 +35,7 @@ bool C4Surface::LoadAny(C4Group &hGroup, const char *szName, bool fOwnPal, bool
if (!*szExt)
{
// no extension: Default to extension that is found as file in group
const char * const extensions[] = { "png", "bmp", "jpeg", "jpg", NULL };
const char * const extensions[] = { "png", "bmp", "jpeg", "jpg", nullptr };
int i = 0; const char *szExt;
while ((szExt = extensions[i++]))
{
@ -58,7 +58,7 @@ bool C4Surface::LoadAny(C4GroupSet &hGroupset, const char *szName, bool fOwnPal,
if (!*szExt)
{
// no extension: Default to extension that is found as file in group
const char * const extensions[] = { "png", "bmp", "jpeg", "jpg", NULL };
const char * const extensions[] = { "png", "bmp", "jpeg", "jpg", nullptr };
int i = 0; const char *szExt;
while ((szExt = extensions[i++]))
{

View File

@ -27,16 +27,16 @@ CSurface8::CSurface8()
{
Wdt=Hgt=Pitch=0;
ClipX=ClipY=ClipX2=ClipY2=0;
Bits=NULL;
pPal=NULL;
Bits=nullptr;
pPal=nullptr;
}
CSurface8::CSurface8(int iWdt, int iHgt)
{
Wdt=Hgt=Pitch=0;
ClipX=ClipY=ClipX2=ClipY2=0;
Bits=NULL;
pPal=NULL;
Bits=nullptr;
pPal=nullptr;
Create(iWdt, iHgt);
}
@ -48,10 +48,10 @@ CSurface8::~CSurface8()
void CSurface8::Clear()
{
// clear bitmap-copy
delete [] Bits; Bits=NULL;
delete [] Bits; Bits=nullptr;
// clear pal
delete pPal;
pPal=NULL;
pPal=nullptr;
}
void CSurface8::Box(int iX, int iY, int iX2, int iY2, int iCol)
@ -250,6 +250,6 @@ void CSurface8::SetBuffer(BYTE *pbyToBuf, int Wdt, int Hgt, int Pitch)
void CSurface8::ReleaseBuffer()
{
this->Bits = NULL;
this->Bits = nullptr;
Clear();
}

View File

@ -61,7 +61,7 @@ public:
void Clip(int iX, int iY, int iX2, int iY2);
void NoClip();
bool Read(class CStdStream &hGroup);
bool Save(const char *szFilename, CStdPalette * = NULL);
bool Save(const char *szFilename, CStdPalette * = nullptr);
void GetSurfaceSize(int &irX, int &irY) const; // get surface size
void AllowColor(BYTE iRngLo, BYTE iRngHi, bool fAllowZero=false);
void SetBuffer(BYTE *pbyToBuf, int Wdt, int Hgt, int Pitch);

View File

@ -44,7 +44,7 @@ bool CPNGFile::DoLoad()
if (png_sig_cmp((unsigned char *) pFilePtr, 0, 8)) return false;
// setup png for reading
fWriteMode=false;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!png_ptr) return false;
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) return false;
@ -101,15 +101,15 @@ CPNGFile::CPNGFile()
void CPNGFile::Default()
{
// zero fields
pFile=NULL;
pFile=nullptr;
fpFileOwned=false;
pFilePtr=NULL;
png_ptr=NULL;
info_ptr=end_info=NULL;
pImageData=NULL;
pFilePtr=nullptr;
png_ptr=nullptr;
info_ptr=end_info=nullptr;
pImageData=nullptr;
iRowSize=0;
iPixSize=0;
fp=NULL;
fp=nullptr;
}
CPNGFile::~CPNGFile()
@ -128,26 +128,26 @@ void CPNGFile::ClearPngStructs()
else
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
}
png_ptr=NULL;
info_ptr=end_info=NULL;
png_ptr=nullptr;
info_ptr=end_info=nullptr;
fWriteMode=false;
}
void CPNGFile::Clear()
{
// free image data
if (pImageData) { delete [] pImageData; pImageData=NULL; }
if (pImageData) { delete [] pImageData; pImageData=nullptr; }
// clear internal png ptrs
ClearPngStructs();
// free file ptr if owned
if (pFile && fpFileOwned) delete [] pFile; pFile=NULL;
if (pFile && fpFileOwned) delete [] pFile; pFile=nullptr;
// reset fields
fpFileOwned=false;
pFilePtr=NULL;
pFilePtr=nullptr;
iRowSize=0;
iPixSize=0;
// close file if open
if (fp) { fclose(fp); fp=NULL; }
if (fp) { fclose(fp); fp=nullptr; }
}
bool CPNGFile::Load(unsigned char *pFile, int iSize)
@ -165,7 +165,7 @@ bool CPNGFile::Load(unsigned char *pFile, int iSize)
return false;
}
// reset file-field
this->pFile = NULL; iFileSize=0;
this->pFile = nullptr; iFileSize=0;
// success
return true;
}
@ -241,7 +241,7 @@ bool CPNGFile::Save(const char *szFilename)
ClearPngStructs();
// reinit them for writing
fWriteMode=true;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!png_ptr) { Clear(); return false; }
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) { Clear(); return false; }
@ -280,7 +280,7 @@ bool CPNGFile::Save(const char *szFilename)
// write end struct
png_write_end(png_ptr, info_ptr);
// finally, close the file
fclose(fp); fp = NULL;
fclose(fp); fp = nullptr;
// clear png structs
ClearPngStructs();
// success!

View File

@ -26,12 +26,12 @@
/* C4ChatControl::ChatSheet::NickItem */
C4ChatControl::ChatSheet::NickItem::NickItem(class C4Network2IRCUser *pByUser) : pStatusIcon(NULL), pNameLabel(NULL), fFlaggedExisting(false), iStatus(0)
C4ChatControl::ChatSheet::NickItem::NickItem(class C4Network2IRCUser *pByUser) : pStatusIcon(nullptr), pNameLabel(nullptr), fFlaggedExisting(false), iStatus(0)
{
// create elements - will be positioned when resized
C4Rect rcDefault(0,0,10,10);
AddElement(pStatusIcon = new C4GUI::Icon(rcDefault, C4GUI::Ico_None));
AddElement(pNameLabel = new C4GUI::Label("", rcDefault, ALeft, C4GUI_CaptionFontClr, NULL, false, false, false));
AddElement(pNameLabel = new C4GUI::Label("", rcDefault, ALeft, C4GUI_CaptionFontClr, nullptr, false, false, false));
// set height (pos and width set when added to the list)
CStdFont *pUseFont = &::GraphicsResource.TextFont;
rcBounds.Set(0,0, 100,pUseFont->GetLineHeight());
@ -87,18 +87,18 @@ 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), pChatControl(pChatControl), pNickList(NULL), pInputLbl(NULL), iBackBufferIndex(-1), eType(eType), fHasUnread(false)
: C4GUI::Tabular::Sheet(szTitle, C4Rect(0,0,10,10), C4GUI::Ico_None, true, false), pChatControl(pChatControl), pNickList(nullptr), pInputLbl(nullptr), iBackBufferIndex(-1), eType(eType), fHasUnread(false)
{
if (szIdent) sIdent.Copy(szIdent);
// create elements - positioned later
C4Rect rcDefault(0,0,10,10);
pChatBox = new C4GUI::TextWindow(rcDefault,0,0,0,100,4096," ",false,0,0,true);
pChatBox->SetDecoration(false, false, NULL, false);
pChatBox->SetDecoration(false, false, nullptr, false);
AddElement(pChatBox);
if (eType == CS_Channel)
{
pNickList = new C4GUI::ListBox(rcDefault);
pNickList->SetDecoration(false, NULL, true, false);
pNickList->SetDecoration(false, nullptr, true, false);
pNickList->SetSelectionDblClickFn(new C4GUI::CallbackHandler<C4ChatControl::ChatSheet>(this, &C4ChatControl::ChatSheet::OnNickDblClick));
AddElement(pNickList);
}
@ -157,7 +157,7 @@ C4GUI::Edit::InputResult C4ChatControl::ChatSheet::OnChatInput(C4GUI::Edit *edt,
if (!szInputText || !*szInputText)
{
// do some error sound then
DoError(NULL);
DoError(nullptr);
}
else
{
@ -194,7 +194,7 @@ void C4ChatControl::ChatSheet::OnNickDblClick(class C4GUI::Element *pEl)
{
if (!pEl) return;
NickItem *pNickItem = static_cast<NickItem *>(pEl);
pChatControl->OpenQuery(pNickItem->GetNick(), true, NULL);
pChatControl->OpenQuery(pNickItem->GetNick(), true, nullptr);
}
void C4ChatControl::ChatSheet::AddTextLine(const char *szText, uint32_t dwClr)
@ -296,7 +296,7 @@ void C4ChatControl::ChatSheet::UpdateUsers(C4Network2IRCUser *pUsers)
}
}
// sort the rest
pNickList->SortElements(&NickItem::SortFunc, NULL);
pNickList->SortElements(&NickItem::SortFunc, nullptr);
}
void C4ChatControl::ChatSheet::UserClose()
@ -328,13 +328,13 @@ C4ChatControl::ChatSheet::NickItem *C4ChatControl::ChatSheet::GetNickItem(const
if (SEqualNoCase(pNickItem->GetNick(), szByNick))
return pNickItem;
// not found
return NULL;
return nullptr;
}
/* C4ChatControl */
C4ChatControl::C4ChatControl(C4Network2IRCClient *pnIRCClient) : C4GUI::Window(), pTitleChangeBC(NULL), pIRCClient(pnIRCClient), fInitialMessagesReceived(false)
C4ChatControl::C4ChatControl(C4Network2IRCClient *pnIRCClient) : C4GUI::Window(), pTitleChangeBC(nullptr), pIRCClient(pnIRCClient), fInitialMessagesReceived(false)
{
// create elements - positioned later
C4Rect rcDefault(0,0,10,10);
@ -343,8 +343,8 @@ C4ChatControl::C4ChatControl(C4Network2IRCClient *pnIRCClient) : C4GUI::Window()
pTabMain->SetDrawDecoration(false);
pTabMain->SetSheetMargin(0);
AddElement(pTabMain);
C4GUI::Tabular::Sheet *pSheetLogin = pTabMain->AddSheet(NULL);
C4GUI::Tabular::Sheet *pSheetChats = pTabMain->AddSheet(NULL);
C4GUI::Tabular::Sheet *pSheetLogin = pTabMain->AddSheet(nullptr);
C4GUI::Tabular::Sheet *pSheetChats = pTabMain->AddSheet(nullptr);
// login sheet
CStdFont *pUseFont = &::GraphicsResource.TextFont;
pSheetLogin->AddElement(pLblLoginNick = new C4GUI::Label(LoadResStr("IDS_CTL_NICK"), rcDefault, ALeft, C4GUI_CaptionFontClr, pUseFont, false, true));
@ -426,11 +426,11 @@ void C4ChatControl::OnShown()
C4GUI::Control *C4ChatControl::GetDefaultControl()
{
// only return a default control if no control is selected to prevent deselection of other controls
if (GetDlg()->GetFocus()) return NULL;
if (GetDlg()->GetFocus()) return nullptr;
ChatSheet *pActiveSheet = GetActiveChatSheet();
if (pActiveSheet) return pActiveSheet->GetInputEdit();
if (pBtnLogin->IsVisible()) return pBtnLogin;
return NULL;
return nullptr;
}
C4ChatControl::ChatSheet *C4ChatControl::GetActiveChatSheet()
@ -440,7 +440,7 @@ C4ChatControl::ChatSheet *C4ChatControl::GetActiveChatSheet()
C4GUI::Tabular::Sheet *pSheet = pTabChats->GetActiveSheet();
if (pSheet) return static_cast<ChatSheet *>(pSheet);
}
return NULL;
return nullptr;
}
C4ChatControl::ChatSheet *C4ChatControl::GetSheetByIdent(const char *szIdent, C4ChatControl::ChatSheet::SheetType eType)
@ -454,7 +454,7 @@ C4ChatControl::ChatSheet *C4ChatControl::GetSheetByIdent(const char *szIdent, C4
if (eType == pChatSheet->GetSheetType())
return pChatSheet;
}
return NULL;
return nullptr;
}
C4ChatControl::ChatSheet *C4ChatControl::GetSheetByTitle(const char *szTitle, C4ChatControl::ChatSheet::SheetType eType)
@ -468,7 +468,7 @@ C4ChatControl::ChatSheet *C4ChatControl::GetSheetByTitle(const char *szTitle, C4
if (eType == pChatSheet->GetSheetType())
return pChatSheet;
}
return NULL;
return nullptr;
}
C4ChatControl::ChatSheet *C4ChatControl::GetServerSheet()
@ -566,7 +566,7 @@ bool C4ChatControl::IsServiceName(const char *szName)
{
// return true for some hardcoded list of service names
if (!szName) return false;
const char *szServiceNames [] = { "NickServ", "ChanServ", "MemoServ", "HelpServ", "Global", NULL }, *szServiceName;
const char *szServiceNames [] = { "NickServ", "ChanServ", "MemoServ", "HelpServ", "Global", nullptr }, *szServiceName;
int32_t i = 0;
while ((szServiceName = szServiceNames[i++]))
if (SEqualNoCase(szName, szServiceName))
@ -661,7 +661,7 @@ void C4ChatControl::Update()
}
else
{
pChatSheet = OpenQuery(pMsg->getTarget(), true, NULL);
pChatSheet = OpenQuery(pMsg->getTarget(), true, nullptr);
if (pChatSheet) pChatSheet->SetChatTitle(pMsg->getTarget());
}
}
@ -794,7 +794,7 @@ void C4ChatControl::ClearChatSheets()
{
pTabChats->ClearSheets();
// add server sheet
pTabChats->AddCustomSheet(new ChatSheet(this, LoadResStr("IDS_CHAT_SERVER"), NULL, ChatSheet::CS_Server));
pTabChats->AddCustomSheet(new ChatSheet(this, LoadResStr("IDS_CHAT_SERVER"), nullptr, ChatSheet::CS_Server));
}
bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet)
@ -886,7 +886,7 @@ bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet)
{
StdStrBuf sMsg;
sParam.SplitAtChar(' ', &sMsg);
OpenQuery(sParam.getData(), true, NULL);
OpenQuery(sParam.getData(), true, nullptr);
}
}
else if (SEqualNoCase(sCommand.getData(), "nick"))
@ -933,7 +933,7 @@ void C4ChatControl::UserQueryQuit()
// still connected? Then confirm first
if (pIRCClient->IsActive())
{
if (!GetScreen()->ShowMessageModal(LoadResStr("IDS_MSG_DISCONNECTFROMSERVER"), LoadResStr("IDS_DLG_CHAT"), C4GUI::MessageDialog::btnOKAbort, C4GUI::Ico_Confirm, NULL))
if (!GetScreen()->ShowMessageModal(LoadResStr("IDS_MSG_DISCONNECTFROMSERVER"), LoadResStr("IDS_DLG_CHAT"), C4GUI::MessageDialog::btnOKAbort, C4GUI::Ico_Confirm, nullptr))
return;
}
// disconnect from server
@ -945,7 +945,7 @@ void C4ChatControl::UserQueryQuit()
/* C4ChatDlg */
C4ChatDlg *C4ChatDlg::pInstance = NULL;
C4ChatDlg *C4ChatDlg::pInstance = nullptr;
C4ChatDlg::C4ChatDlg() : C4GUI::Dialog(100, 100, "IRC", false)
{
@ -1026,7 +1026,7 @@ bool C4ChatDlg::DoPlacement(C4GUI::Screen *pOnScreen, const C4Rect &rPreferredDl
void C4ChatDlg::OnClosed(bool fOK)
{
// callback when dlg got closed
pInstance = NULL;
pInstance = nullptr;
typedef C4GUI::Dialog ParentClass;
ParentClass::OnClosed(fOK);
}

View File

@ -99,7 +99,7 @@ private:
private:
NickItem *GetNickItem(const char *szByNick);
NickItem *GetFirstNickItem() { return pNickList ? static_cast<NickItem *>(pNickList->GetFirst()) : NULL; }
NickItem *GetFirstNickItem() { return pNickList ? static_cast<NickItem *>(pNickList->GetFirst()) : nullptr; }
NickItem *GetNextNickItem(NickItem *pPrev) { return static_cast<NickItem *>(pPrev->GetNext()); }
};

View File

@ -23,7 +23,7 @@
C4Network2HTTPClient HTTPClient;
C4DownloadDlg::C4DownloadDlg(const char *szDLType) : C4GUI::Dialog(C4GUI_ProgressDlgWdt, 100, FormatString(LoadResStr("IDS_CTL_DL_TITLE"), szDLType).getData(), false), szError(NULL)
C4DownloadDlg::C4DownloadDlg(const char *szDLType) : C4GUI::Dialog(C4GUI_ProgressDlgWdt, 100, FormatString(LoadResStr("IDS_CTL_DL_TITLE"), szDLType).getData(), false), szError(nullptr)
{
#ifdef HAVE_WINSOCK
fWinSock = AcquireWinSock();
@ -31,7 +31,7 @@ C4DownloadDlg::C4DownloadDlg(const char *szDLType) : C4GUI::Dialog(C4GUI_Progres
// add all elements - will be reposisioned when text is displayed
AddElement(pIcon = new C4GUI::Icon(C4Rect(), C4GUI::Ico_NetWait));
AddElement(pStatusLabel = new C4GUI::Label("", C4Rect(), ACenter, C4GUI_MessageFontClr, &::GraphicsResource.TextFont, false));
pProgressBar = NULL; // created when necessary
pProgressBar = nullptr; // created when necessary
AddElement(pCancelBtn = new C4GUI::CancelButton(C4Rect()));
}
@ -70,7 +70,7 @@ void C4DownloadDlg::SetStatus(const char *szNewText, int32_t iProgressPercent)
else
{
// no progress desired
if (pProgressBar) { delete pProgressBar; pProgressBar = NULL; }
if (pProgressBar) { delete pProgressBar; pProgressBar = nullptr; }
}
// place button
caMain.ExpandLeft(C4GUI_DefDlgIndent*2 + C4GUI_IconWdt);
@ -147,14 +147,14 @@ const char *C4DownloadDlg::GetError()
bool C4DownloadDlg::ShowModal(C4GUI::Screen *pScreen, const char *szURL, const char *szSaveAsFilename)
{
// reset error
szError = NULL;
szError = nullptr;
// initial text
if (!HTTPClient.Init()) return false;
HTTPClient.SetServer(szURL);
// show dlg
if (!Show(pScreen, true)) return false;
// start query
if (!HTTPClient.Query(NULL, true)) return false;
if (!HTTPClient.Query(nullptr, true)) return false;
// first time status update
OnIdle();
// cycle until query is finished or aborted
@ -186,7 +186,7 @@ bool C4DownloadDlg::DownloadFile(const char *szDLType, C4GUI::Screen *pScreen, c
if (SSearch(szError, "404") && szNotFoundMessage)
{ sError.Append("|"); sError.Append(szNotFoundMessage); }
// display message
pScreen->ShowMessageModal(sError.getData(), FormatString(LoadResStr("IDS_CTL_DL_TITLE"), szDLType).getData(), C4GUI::MessageDialog::btnOK, C4GUI::Ico_Error, NULL);
pScreen->ShowMessageModal(sError.getData(), FormatString(LoadResStr("IDS_CTL_DL_TITLE"), szDLType).getData(), C4GUI::MessageDialog::btnOK, C4GUI::Ico_Error, nullptr);
delete pDlg;
return false;
}

View File

@ -59,7 +59,7 @@ protected:
public:
// download file showing download dialog; display error if download failed
static bool DownloadFile(const char *szDLType, C4GUI::Screen *pScreen, const char *szURL, const char *szSaveAsFilename, const char *szNotFoundMessage = NULL);
static bool DownloadFile(const char *szDLType, C4GUI::Screen *pScreen, const char *szURL, const char *szSaveAsFilename, const char *szNotFoundMessage = nullptr);
};

View File

@ -55,7 +55,7 @@ C4FileSelDlg::ListItem::~ListItem()
// C4FileSelDlg::DefaultListItem
C4FileSelDlg::DefaultListItem::DefaultListItem(const char *szFilename, bool fTruncateExtension, bool fCheckbox, bool fGrayed, C4GUI::Icons eIcon)
: C4FileSelDlg::ListItem(szFilename), pLbl(NULL), pCheck(NULL), pKeyCheck(NULL), fGrayed(fGrayed)
: C4FileSelDlg::ListItem(szFilename), pLbl(nullptr), pCheck(nullptr), pKeyCheck(nullptr), fGrayed(fGrayed)
{
StdStrBuf sLabel; if (szFilename) sLabel.Ref(::GetFilename(szFilename)); else sLabel.Ref(LoadResStr("IDS_CTL_NONE"));
if (szFilename && fTruncateExtension)
@ -71,7 +71,7 @@ C4FileSelDlg::DefaultListItem::DefaultListItem(const char *szFilename, bool fTru
int32_t iHeight = caMain.GetInnerHeight();
if (fCheckbox)
{
pCheck = new C4GUI::CheckBox(caMain.GetFromLeft(iHeight), NULL, false);
pCheck = new C4GUI::CheckBox(caMain.GetFromLeft(iHeight), nullptr, false);
if (fGrayed) pCheck->SetEnabled(false);
AddElement(pCheck);
pKeyCheck = new C4KeyBinding(C4KeyCodeEx(K_SPACE), "FileSelToggleFileActive", KEYSCOPE_Gui,
@ -127,7 +127,7 @@ bool C4FileSelDlg::DefaultListItem::UserToggleCheck()
C4FileSelDlg::C4FileSelDlg(const char *szRootPath, const char *szTitle, C4FileSel_BaseCB *pSelCallback, bool fInitElements)
: C4GUI::Dialog(Clamp(C4GUI::GetScreenWdt()*2/3+10, 300,600), Clamp(C4GUI::GetScreenHgt()*2/3+10, 220,500), szTitle, false),
pLocationComboBox(NULL), pFileListBox(NULL), pSelectionInfoBox(NULL), btnOK(NULL), pLocations(NULL), iLocationCount(0), pSelection(NULL), pSelCallback(pSelCallback)
pLocationComboBox(nullptr), pFileListBox(nullptr), pSelectionInfoBox(nullptr), btnOK(nullptr), pLocations(nullptr), iLocationCount(0), pSelection(nullptr), pSelCallback(pSelCallback)
{
sTitle.Copy(szTitle);
// key bindings
@ -169,7 +169,7 @@ void C4FileSelDlg::InitElements()
{
caUpperArea.ExpandLeft(C4GUI_DefDlgIndent);
pSelectionInfoBox = new C4GUI::TextWindow(caUpperArea.GetAll());
pSelectionInfoBox->SetDecoration(true, true, NULL, true);
pSelectionInfoBox->SetDecoration(true, true, nullptr, true);
}
// create button area
C4GUI::Button *btnAbort = new C4GUI::CancelButton(caButtonArea.GetFromRight(C4GUI_DefButton2Wdt));
@ -260,7 +260,7 @@ C4FileSelDlg::ListItem *C4FileSelDlg::CreateListItem(const char *szFilename)
if (szFilename)
return new DefaultListItem(szFilename, !!GetFileMask(), IsMultiSelection(), IsItemGrayed(szFilename), GetFileItemIcon());
else
return new DefaultListItem(NULL, false, IsMultiSelection(), false, GetFileItemIcon());
return new DefaultListItem(nullptr, false, IsMultiSelection(), false, GetFileItemIcon());
}
void C4FileSelDlg::UpdateFileList()
@ -278,7 +278,7 @@ void C4FileSelDlg::UpdateFileList()
// none-item?
if (HasNoneItem())
{
pFileListBox->AddElement(CreateListItem(NULL));
pFileListBox->AddElement(CreateListItem(nullptr));
}
// list now done
EndFileListUpdate();
@ -427,7 +427,7 @@ bool C4DefinitionSelDlg::IsItemGrayed(const char *szFilename) const
bool C4DefinitionSelDlg::SelectDefinitions(C4GUI::Screen *pOnScreen, StdStrBuf *pSelection)
{
// let the user select definitions by showing a modal selection dialog
C4DefinitionSelDlg *pDlg = new C4DefinitionSelDlg(NULL, pSelection->getData());
C4DefinitionSelDlg *pDlg = new C4DefinitionSelDlg(nullptr, pSelection->getData());
bool fResult;
if ((fResult = pOnScreen->ShowModalDlg(pDlg, false)))
{
@ -572,9 +572,9 @@ C4PortraitSelDlg::C4PortraitSelDlg(C4FileSel_BaseCB *pSelCallback)
AddCheckedLocation(strLocation.getData(), path);
#ifdef _WIN32
wchar_t wpath[MAX_PATH+1];
if (SHGetSpecialFolderPathW(NULL, wpath, CSIDL_PERSONAL, false)) AddCheckedLocation(LoadResStr("IDS_TEXT_MYDOCUMENTS"), StdStrBuf(wpath).getData());
if (SHGetSpecialFolderPathW(NULL, wpath, CSIDL_MYPICTURES, false)) AddCheckedLocation(LoadResStr("IDS_TEXT_MYPICTURES"), StdStrBuf(wpath).getData());
if (SHGetSpecialFolderPathW(NULL, wpath, CSIDL_DESKTOPDIRECTORY, false)) AddCheckedLocation(LoadResStr("IDS_TEXT_DESKTOP"), StdStrBuf(wpath).getData());
if (SHGetSpecialFolderPathW(nullptr, wpath, CSIDL_PERSONAL, false)) AddCheckedLocation(LoadResStr("IDS_TEXT_MYDOCUMENTS"), StdStrBuf(wpath).getData());
if (SHGetSpecialFolderPathW(nullptr, wpath, CSIDL_MYPICTURES, false)) AddCheckedLocation(LoadResStr("IDS_TEXT_MYPICTURES"), StdStrBuf(wpath).getData());
if (SHGetSpecialFolderPathW(nullptr, wpath, CSIDL_DESKTOPDIRECTORY, false)) AddCheckedLocation(LoadResStr("IDS_TEXT_DESKTOP"), StdStrBuf(wpath).getData());
#endif
#ifdef __APPLE__
AddCheckedLocation(LoadResStr("IDS_TEXT_HOME"), getenv("HOME"));
@ -634,11 +634,11 @@ void C4PortraitSelDlg::OnIdle()
bool C4PortraitSelDlg::SelectPortrait(C4GUI::Screen *pOnScreen, StdStrBuf *pSelection)
{
// let the user select a portrait by showing a modal selection dialog
C4PortraitSelDlg *pDlg = new C4PortraitSelDlg(NULL);
C4PortraitSelDlg *pDlg = new C4PortraitSelDlg(nullptr);
bool fResult;
if ((fResult = pOnScreen->ShowModalDlg(pDlg, false)))
{
pSelection->Take(pDlg->GetSelection(NULL, false));
pSelection->Take(pDlg->GetSelection(nullptr, false));
}
delete pDlg;
return fResult;

View File

@ -128,7 +128,7 @@ protected:
virtual void UserClose(bool fOK); // allow OK only if something is sth is selected
virtual void OnClosed(bool fOK); // callback when dlg got closed
virtual const char *GetFileMask() const { return NULL; }
virtual const char *GetFileMask() const { return nullptr; }
virtual bool IsMultiSelection() const { return false; } // if true, files are checked/unchecked using checkboxes
virtual bool IsItemGrayed(const char *szFilename) const { return false; }
virtual void UpdateSelection();

View File

@ -51,7 +51,7 @@ bool C4Folder::Load(C4Group &hGroup)
{
char *pSource;
// Load
if (!hGroup.LoadEntry(C4CFN_FolderCore, &pSource, NULL, 1)) return false;
if (!hGroup.LoadEntry(C4CFN_FolderCore, &pSource, nullptr, 1)) return false;
// Compile
if (!Compile(pSource)) { delete [] pSource; return false; }
delete [] pSource;

View File

@ -29,7 +29,7 @@ bool C4AbortGameDialog::is_shown = false;
C4AbortGameDialog::C4AbortGameDialog()
: C4GUI::ConfirmationDialog(LoadResStr("IDS_HOLD_ABORT"),
LoadResStr("IDS_DLG_ABORT"),
NULL,
nullptr,
MessageDialog::btnYesNo,
true,
C4GUI::Ico_Exit),

View File

@ -68,7 +68,7 @@ namespace C4GameLobby
SetBounds(rcBounds);
C4GUI::ComponentAligner caMain(GetClientRect(), 0,0, true);
AddElement(pDescBox = new C4GUI::TextWindow(caMain.GetAll(), 0, 0, 0, 100, 4096, "", true));
pDescBox->SetDecoration(false, false, NULL, true);
pDescBox->SetDecoration(false, false, nullptr, true);
// initial update to set current data
if (fActive) Activate();
}
@ -132,8 +132,8 @@ namespace C4GameLobby
(const char *) LoadResStr("IDS_DLG_LOBBY"):
FormatString("%s - %s", Game.ScenarioTitle.getData(), LoadResStr("IDS_DLG_LOBBY")).getData(),
Game.ScenarioTitle.getData()),
pPlayerList(NULL), pResList(NULL), pChatBox(NULL), pRightTabLbl(NULL), pRightTab(NULL),
pEdt(NULL), btnRun(NULL), btnPlayers(NULL), btnResources(NULL), btnTeams(NULL), btnChat(NULL)
pPlayerList(nullptr), pResList(nullptr), pChatBox(nullptr), pRightTabLbl(nullptr), pRightTab(nullptr),
pEdt(nullptr), btnRun(nullptr), btnPlayers(nullptr), btnResources(nullptr), btnTeams(nullptr), btnChat(nullptr)
{
// key bindings
pKeyHistoryUp = new C4KeyBinding(C4KeyCodeEx(K_UP ), "LobbyChatHistoryUp" , KEYSCOPE_Gui, new C4GUI::DlgKeyCBEx<MainDlg, bool>(*this, true , &MainDlg::KeyHistoryUpDown), C4CustomKey::PRIO_CtrlOverride);
@ -192,7 +192,7 @@ namespace C4GameLobby
if (fHost)
{
btnRun = new C4GUI::CallbackButton<MainDlg>(LoadResStr("IDS_DLG_GAMEGO"), caBottom.GetFromRight(100), &MainDlg::OnRunBtn);
checkReady = NULL;
checkReady = nullptr;
}
else
{
@ -311,7 +311,7 @@ namespace C4GameLobby
// changing away from countdown?
if (eCountdownState == CDS_Countdown)
{
StopSoundEffect("Structures::Elevator::Moving", NULL);
StopSoundEffect("Structures::Elevator::Moving", nullptr);
if (eToState != CDS_Start) StartSoundEffect("Liquids::Pshshsh");
}
// change to game start?

View File

@ -115,15 +115,15 @@ namespace C4GameLobby
void OnSec1Timer(); // timer proc; update pings
C4GUI::ContextMenu *OnRightTabContext(C4GUI::Element *pLabel, int32_t iX, int32_t iY); // open context menu
void OnCtxTabPlayers(C4GUI::Element *pListItem) { OnTabPlayers(NULL); }
void OnCtxTabPlayers(C4GUI::Element *pListItem) { OnTabPlayers(nullptr); }
void OnTabPlayers(C4GUI::Control *btn);
void OnCtxTabTeams(C4GUI::Element *pListItem) { OnTabTeams(NULL); }
void OnCtxTabTeams(C4GUI::Element *pListItem) { OnTabTeams(nullptr); }
void OnTabTeams(C4GUI::Control *btn);
void OnCtxTabRes(C4GUI::Element *pListItem) { OnTabRes(NULL); }
void OnCtxTabRes(C4GUI::Element *pListItem) { OnTabRes(nullptr); }
void OnTabRes(C4GUI::Control *btn);
void OnCtxTabOptions(C4GUI::Element *pListItem) { OnTabOptions(NULL); }
void OnCtxTabOptions(C4GUI::Element *pListItem) { OnTabOptions(nullptr); }
void OnTabOptions(C4GUI::Control *btn);
void OnCtxTabScenario(C4GUI::Element *pListItem) { OnTabScenario(NULL); }
void OnCtxTabScenario(C4GUI::Element *pListItem) { OnTabScenario(nullptr); }
void OnTabScenario(C4GUI::Control *btn);
void UpdateRightTab(); // update label and tooltips for sheet change
void OnBtnChat(C4GUI::Control *btn);

View File

@ -29,7 +29,7 @@
const int32_t ObjectMsgDelayFactor = 2, GlobalMsgDelayFactor = 3; // frames per char message display time
C4GameMessage::C4GameMessage() : pFrameDeco(NULL)
C4GameMessage::C4GameMessage() : pFrameDeco(nullptr)
{
}
@ -42,7 +42,7 @@ C4GameMessage::~C4GameMessage()
void C4GameMessage::Init(int32_t iType, const StdStrBuf & sText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwClr, C4ID idDecoID, C4PropList *pSrc, uint32_t dwFlags, int width)
{
// safety!
if (pTarget && !pTarget->Status) pTarget = NULL;
if (pTarget && !pTarget->Status) pTarget = nullptr;
// Set data
Text.Copy(sText);
Target=pTarget;
@ -53,7 +53,7 @@ void C4GameMessage::Init(int32_t iType, const StdStrBuf & sText, C4Object *pTarg
Delay=std::max<int32_t>(C4GM_MinDelay, Text.getLength() * (Target ? ObjectMsgDelayFactor : GlobalMsgDelayFactor));
DecoID=idDecoID;
this->dwFlags=dwFlags;
PictureDef=NULL;
PictureDef=nullptr;
PictureDefVal.Set0();
if (pSrc)
{
@ -84,14 +84,14 @@ void C4GameMessage::Init(int32_t iType, const StdStrBuf & sText, C4Object *pTarg
Text.Shrink(1);
}
// frame decoration
delete pFrameDeco; pFrameDeco = NULL;
delete pFrameDeco; pFrameDeco = nullptr;
if (DecoID)
{
pFrameDeco = new C4GUI::FrameDecoration();
if (!pFrameDeco->SetByDef(DecoID))
{
delete pFrameDeco;
pFrameDeco = NULL;
pFrameDeco = nullptr;
}
}
}
@ -306,7 +306,7 @@ void C4GameMessage::UpdateDef(C4ID idUpdDef)
if (!pFrameDeco->UpdateGfx())
{
delete pFrameDeco;
pFrameDeco = NULL;
pFrameDeco = nullptr;
}
}
}
@ -323,12 +323,12 @@ C4GameMessageList::~C4GameMessageList()
void C4GameMessageList::Default()
{
First=NULL;
First=nullptr;
}
void C4GameMessageList::ClearPointers(C4Object *pObj)
{
C4GameMessage *cmsg,*next,*prev=NULL;
C4GameMessage *cmsg,*next,*prev=nullptr;
for (cmsg=First; cmsg; cmsg=next)
{
next=cmsg->Next;
@ -347,12 +347,12 @@ void C4GameMessageList::Clear()
next=cmsg->Next;
delete cmsg;
}
First=NULL;
First=nullptr;
}
void C4GameMessageList::Execute()
{
C4GameMessage *cmsg,*next,*prev=NULL;
C4GameMessage *cmsg,*next,*prev=nullptr;
for (cmsg=First; cmsg; cmsg=next)
{
next=cmsg->Next;
@ -396,7 +396,7 @@ bool C4GameMessageList::New(int32_t iType, const StdStrBuf & sText, C4Object *pT
bool C4GameMessageList::Append(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t bCol, bool fNoDuplicates)
{
C4GameMessage *cmsg = NULL;
C4GameMessage *cmsg = nullptr;
if (iType == C4GM_Target)
{
for (cmsg=::Messages.First; cmsg; cmsg=cmsg->Next)
@ -422,7 +422,7 @@ bool C4GameMessageList::Append(int32_t iType, const char *szText, C4Object *pTar
void C4GameMessageList::ClearPlayers(int32_t iPlayer, int32_t dwPositioningFlags)
{
C4GameMessage *cmsg,*next,*prev=NULL;
C4GameMessage *cmsg,*next,*prev=nullptr;
for (cmsg=First; cmsg; cmsg=next)
{
next=cmsg->Next;

View File

@ -94,8 +94,8 @@ public:
void ClearPlayers(int32_t iPlayer, int32_t dwPositioningFlags);
void ClearPointers(C4Object *pObj);
void UpdateDef(C4ID idUpdDef); // called after reloaddef
bool New(int32_t iType, const StdStrBuf & Text, C4Object *pTarget, int32_t iPlayer, int32_t iX = -1, int32_t iY = -1, uint32_t dwClr = 0xffFFFFFF, C4ID idDecoID=C4ID::None, C4PropList *pSrc=NULL, uint32_t dwFlags=0u, int32_t width=0);
bool New(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwClr, C4ID idDecoID=C4ID::None, C4PropList *pSrc=NULL, uint32_t dwFlags=0u, int32_t width=0);
bool New(int32_t iType, const StdStrBuf & Text, C4Object *pTarget, int32_t iPlayer, int32_t iX = -1, int32_t iY = -1, uint32_t dwClr = 0xffFFFFFF, C4ID idDecoID=C4ID::None, C4PropList *pSrc=nullptr, uint32_t dwFlags=0u, int32_t width=0);
bool New(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t dwClr, C4ID idDecoID=C4ID::None, C4PropList *pSrc=nullptr, uint32_t dwFlags=0u, int32_t width=0);
bool Append(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint32_t bCol, bool fNoDuplicates = false);
};

View File

@ -28,7 +28,7 @@
// ----------- C4GameOptionsList::Option ----------------------------------------------------------------
C4GameOptionsList::Option::Option(C4GameOptionsList *pForDlg) :
BaseClass(C4Rect(0, 0, 0, 0)), pForDlg(pForDlg), pPrimarySubcomponent(NULL)
BaseClass(C4Rect(0, 0, 0, 0)), pForDlg(pForDlg), pPrimarySubcomponent(nullptr)
{}
void C4GameOptionsList::Option::InitOption(C4GameOptionsList *pForDlg)

View File

@ -162,7 +162,7 @@ public:
GOLS_Runtime
};
C4GameOptionsList(const C4Rect &rcBounds, bool fActive, C4GameOptionsListSource source, class C4ScenarioParameterDefs *param_defs=NULL, class C4ScenarioParameters *params=NULL);
C4GameOptionsList(const C4Rect &rcBounds, bool fActive, C4GameOptionsListSource source, class C4ScenarioParameterDefs *param_defs=nullptr, class C4ScenarioParameters *params=nullptr);
~C4GameOptionsList() { Deactivate(); }
private:
@ -178,7 +178,7 @@ public:
void Update();
void OnSec1Timer() { Update(); }
// update to new parameter set. recreates option fields. set parameters to NULL for no options
// update to new parameter set. recreates option fields. set parameters to nullptr for no options
void SetParameters(C4ScenarioParameterDefs *param_defs, C4ScenarioParameters *params);
// activate/deactivate periodic updates

View File

@ -123,7 +123,7 @@ bool C4GameOverDlg::is_shown = false;
C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ? (C4GUI::GetScreenWdt()-10) : std::min<int32_t>(C4GUI::GetScreenWdt()-150, 800),
(C4GUI::GetScreenHgt() < 600) ? (C4GUI::GetScreenHgt()-10) : std::min<int32_t>(C4GUI::GetScreenHgt()-150, 600),
LoadResStr("IDS_TEXT_EVALUATION"),
false), pNetResultLabel(NULL), fIsNetDone(false), fHasNextMissionButton(false)
false), pNetResultLabel(nullptr), fIsNetDone(false), fHasNextMissionButton(false)
{
is_shown = true; // assume dlg will be shown, soon
UpdateOwnPos();
@ -153,14 +153,14 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
// league/network result, present or pending
fIsNetDone = false;
bool fHasNetResult = Game.RoundResults.HasNetResult();
const char *szNetResult = NULL;
const char *szNetResult = nullptr;
if (Game.Parameters.isLeague() || fHasNetResult)
{
if (fHasNetResult)
szNetResult = Game.RoundResults.GetNetResultString();
else
szNetResult = LoadResStr("IDS_TEXT_LEAGUEWAITINGFOREVALUATIO");
pNetResultLabel = new C4GUI::Label(szNetResult, caMain.GetFromTop(::GraphicsResource.TextFont.GetLineHeight()*2, iMainTextWidth), ACenter, C4GUI_Caption2FontClr, NULL, false, false, true);
pNetResultLabel = new C4GUI::Label(szNetResult, caMain.GetFromTop(::GraphicsResource.TextFont.GetLineHeight()*2, iMainTextWidth), ACenter, C4GUI_Caption2FontClr, nullptr, false, false, true);
AddElement(pNetResultLabel);
// only add label - contents and fIsNetDone will be set in next update
}
@ -175,16 +175,16 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
{
int32_t iMaxHgt = caMain.GetInnerHeight() / 3; // max 1/3rd of height for extra data
C4GUI::MultilineLabel *pCustomStrings = new C4GUI::MultilineLabel(caMain.GetFromTop(0 /* resized later*/, iMainTextWidth), 0,0, " ", true, true);
pCustomStrings->AddLine(szCustomEvaluationStrings, &::GraphicsResource.TextFont, C4GUI_MessageFontClr, true, false, NULL);
pCustomStrings->AddLine(szCustomEvaluationStrings, &::GraphicsResource.TextFont, C4GUI_MessageFontClr, true, false, nullptr);
C4Rect rcCustomStringBounds = pCustomStrings->GetBounds();
if (rcCustomStringBounds.Hgt > iMaxHgt)
{
// Buffer too large: Use a scrollbox instead
delete pCustomStrings;
rcCustomStringBounds.Hgt = iMaxHgt;
C4GUI::TextWindow *pCustomStringsWin = new C4GUI::TextWindow(rcCustomStringBounds, 0,0,0, 0,0," ",true, NULL,0, true);
pCustomStringsWin->SetDecoration(false, false, NULL, false);
pCustomStringsWin->AddTextLine(szCustomEvaluationStrings, &::GraphicsResource.TextFont, C4GUI_MessageFontClr, true, false, NULL);
C4GUI::TextWindow *pCustomStringsWin = new C4GUI::TextWindow(rcCustomStringBounds, 0,0,0, 0,0," ",true, nullptr,0, true);
pCustomStringsWin->SetDecoration(false, false, nullptr, false);
pCustomStringsWin->AddTextLine(szCustomEvaluationStrings, &::GraphicsResource.TextFont, C4GUI_MessageFontClr, true, false, nullptr);
caMain.ExpandTop(-iMaxHgt);
AddElement(pCustomStringsWin);
}
@ -209,7 +209,7 @@ C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ?
{
ppPlayerLists[i] = new C4PlayerInfoListBox(caPlayerArea.GetGridCell(i,iPlrListCount,0,1), C4PlayerInfoListBox::PILBM_Evaluation, fSepTeamLists ? Game.Teams.GetTeamByIndex(i)->GetID() : 0);
ppPlayerLists[i]->SetSelectionDiabled(true);
ppPlayerLists[i]->SetDecoration(false, NULL, true, false);
ppPlayerLists[i]->SetDecoration(false, nullptr, true, false);
AddElement(ppPlayerLists[i]);
}
// add buttons

View File

@ -72,7 +72,7 @@ protected:
virtual void OnShown();
virtual void OnClosed(bool fOK);
virtual bool OnEnter() { if (fIsQuitBtnVisible) OnExitBtn(NULL); return true; } // enter on non-button: Always quit
virtual bool OnEnter() { if (fIsQuitBtnVisible) OnExitBtn(nullptr); return true; } // enter on non-button: Always quit
virtual bool OnEscape() { if (fIsQuitBtnVisible) UserClose(false); return true; } // escape ignored if still streaming
// true for dialogs that should span the whole screen

View File

@ -34,7 +34,7 @@ static int edittext_toi(HWND hWnd, int field)
StdStrBuf data(buf);
const char* bufp = data.getData();
while(*bufp == ' ') ++bufp;
int res = strtol(bufp, NULL, 0);
int res = strtol(bufp, nullptr, 0);
if(errno != ERANGE)
return res;
return -1;
@ -86,7 +86,7 @@ static INT_PTR CALLBACK GfxErrProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPAR
// Check if res is in list of supportet
bool found = false;
int32_t idx = 0, iXRes, iYRes, iBitDepth;
while (Application.GetIndexedDisplayMode(idx++, &iXRes, &iYRes, &iBitDepth, NULL, Config.Graphics.Monitor))
while (Application.GetIndexedDisplayMode(idx++, &iXRes, &iYRes, &iBitDepth, nullptr, Config.Graphics.Monitor))
if (iBitDepth == C4Draw::COLOR_DEPTH)
if(iXRes == resx && iYRes == resy)
{
@ -110,14 +110,14 @@ static INT_PTR CALLBACK GfxErrProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPAR
Config.Graphics.ResY = resy;
Config.Save();
TCHAR selfpath[4096];
GetModuleFileName(NULL, selfpath, 4096);
GetModuleFileName(nullptr, selfpath, 4096);
STARTUPINFOW siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
if (CreateProcessW(selfpath, NULL,
NULL, NULL, FALSE, 0, NULL, Config.General.ExePath.GetWideChar(), &siStartupInfo, &piProcessInfo))
if (CreateProcessW(selfpath, nullptr,
nullptr, nullptr, FALSE, 0, nullptr, Config.General.ExePath.GetWideChar(), &siStartupInfo, &piProcessInfo))
{
CloseHandle(piProcessInfo.hProcess);
CloseHandle(piProcessInfo.hThread);
@ -136,14 +136,14 @@ void ShowGfxErrorDialog()
// Application.Close will eventually post a quit message. We need to discard
// that, so DialogBox() doesn't immediately exit.
auto msg = MSG();
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0)
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE) != 0)
{
if (msg.message == WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
int ret = DialogBox(Application.GetInstance(), MAKEINTRESOURCE(IDD_GFXERROR), NULL, GfxErrProcedure);
int ret = DialogBox(Application.GetInstance(), MAKEINTRESOURCE(IDD_GFXERROR), nullptr, GfxErrProcedure);
if (ret == 0 || ret == -1)
{
LPVOID lpMsgBuf;
@ -152,11 +152,11 @@ void ShowGfxErrorDialog()
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nullptr,
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
0, nullptr );
LogF("Error in GfxErrorDlg: %d - %s", err, StdStrBuf((wchar_t*)lpMsgBuf).getData());
LocalFree(lpMsgBuf);
}

View File

@ -151,9 +151,9 @@ namespace C4GUI
// --------------------------------------------------
// Element
Element::Element() : pParent(NULL), pDragTarget(NULL), fDragging(false), pContextHandler(NULL), fVisible(true), is_immediate_tooltip(false)
Element::Element() : pParent(nullptr), pDragTarget(nullptr), fDragging(false), pContextHandler(nullptr), fVisible(true), is_immediate_tooltip(false)
{
// pParent=NULL invalidates pPrev/pNext
// pParent=nullptr invalidates pPrev/pNext
// fDragging=false invalidates iDragX/Y
// zero fields
rcBounds.Set(0,0,0,0);
@ -162,7 +162,7 @@ namespace C4GUI
Element::~Element()
{
// delete context handler
if (pContextHandler) { pContextHandler->DeRef(); pContextHandler=NULL; }
if (pContextHandler) { pContextHandler->DeRef(); pContextHandler=nullptr; }
// remove from any container
if (pParent)
pParent->RemoveElement(this);
@ -286,8 +286,8 @@ namespace C4GUI
DoDragging(rMouse, iX, iY, dwKeyParam);
}
Dialog *Element::GetDlg () { if (pParent) return pParent->GetDlg (); return NULL; }
Screen *Element::GetScreen() { if (pParent) return pParent->GetScreen(); return NULL; }
Dialog *Element::GetDlg () { if (pParent) return pParent->GetDlg (); return nullptr; }
Screen *Element::GetScreen() { if (pParent) return pParent->GetScreen(); return nullptr; }
void Element::Draw3DFrame(C4TargetFacet &cgo, bool fUp, int32_t iIndent, BYTE byAlpha, bool fDrawTop, int32_t iTopOff, bool fDrawLeft, int32_t iLeftOff)
{
@ -453,8 +453,8 @@ namespace C4GUI
// reset fields
LDown=MDown=RDown=false;
dwKeys=0;
pMouseOverElement = pPrevMouseOverElement = NULL;
pDragElement = NULL;
pMouseOverElement = pPrevMouseOverElement = nullptr;
pDragElement = nullptr;
ResetToolTipTime();
// LDownX/Y initialized upon need
}
@ -531,7 +531,7 @@ namespace C4GUI
pDragElement->ScreenPos2ClientPos(iX, iY);
pDragElement->StopDragging(*this, iX, iY, dwKeys);
}
pPrevMouseOverElement = pMouseOverElement = pDragElement = NULL;
pPrevMouseOverElement = pMouseOverElement = pDragElement = nullptr;
}
void CMouse::RemoveElement(Element *pChild)
@ -540,10 +540,10 @@ namespace C4GUI
if (pMouseOverElement == pChild)
{
pMouseOverElement->MouseLeave(*this); // do leave callback so any tooltip is cleared!
pMouseOverElement = NULL;
pMouseOverElement = nullptr;
}
if (pPrevMouseOverElement == pChild) pPrevMouseOverElement = NULL;
if (pDragElement == pChild) pDragElement = NULL;
if (pPrevMouseOverElement == pChild) pPrevMouseOverElement = nullptr;
if (pDragElement == pChild) pDragElement = nullptr;
}
void CMouse::OnElementGetsInvisible(Element *pChild)
@ -561,19 +561,19 @@ namespace C4GUI
// inherited
Window::RemoveElement(pChild);
// clear ptrs
if (pActiveDlg == pChild) { pActiveDlg = NULL; Mouse.ResetElements(); }
if (pActiveDlg == pChild) { pActiveDlg = nullptr; Mouse.ResetElements(); }
Mouse.RemoveElement(pChild);
if (pContext)
{
if (pContext == pChild) pContext=NULL;
if (pContext == pChild) pContext=nullptr;
else pContext->RemoveElement(pChild);
}
}
Screen::Screen() : Window(), Mouse(0, 0), pContext(NULL), fExclusive(true), fZoom(1.0f)
Screen::Screen() : Window(), Mouse(0, 0), pContext(nullptr), fExclusive(true), fZoom(1.0f)
{
// no dialog active
pActiveDlg = NULL;
pActiveDlg = nullptr;
// set static var
pScreen = this;
}
@ -601,7 +601,7 @@ namespace C4GUI
Screen::~Screen()
{
// clear singleton
if (this == pScreen) pScreen = NULL;
if (this == pScreen) pScreen = nullptr;
}
void Screen::ElementPosChanged(Element *pOfElement)
@ -677,7 +677,7 @@ namespace C4GUI
// set new active dlg
pActiveDlg = GetTopDialog();
// do not set yet if it's fading
if (pActiveDlg && pActiveDlg->IsFading()) pActiveDlg = NULL;
if (pActiveDlg && pActiveDlg->IsFading()) pActiveDlg = nullptr;
}
// redraw background; clip update
::GraphicsSystem.InvalidateBg(); UpdateMouseFocus();
@ -689,7 +689,7 @@ namespace C4GUI
if (pActiveDlg == pNewTop) return;
Mouse.ReleaseElements();
// do not set yet if it's fading
if (pActiveDlg && pActiveDlg->IsFading()) pActiveDlg = NULL;
if (pActiveDlg && pActiveDlg->IsFading()) pActiveDlg = nullptr;
}
Dialog *Screen::GetTopDialog()
@ -701,7 +701,7 @@ namespace C4GUI
if (pDlg->IsShown())
return pDlg;
// no dlg found
return NULL;
return nullptr;
}
void Screen::CloseAllDialogs(bool fWithOK)
@ -717,7 +717,7 @@ namespace C4GUI
if ((pDlg = pEl->GetDlg()))
if (pDlg->pWindow && pDlg->pWindow->hWindow == hWindow)
return pDlg;
return NULL;
return nullptr;
}
#endif
Dialog *Screen::GetDialog(C4Window * pWindow)
@ -725,10 +725,10 @@ namespace C4GUI
// get dialog with matching window
Dialog *pDlg;
for (Element *pEl = pLast; pEl; pEl = pEl->GetPrev())
if ( (pDlg = pEl->GetDlg()) != NULL)
if ( (pDlg = pEl->GetDlg()) != nullptr)
if (pDlg->pWindow == pWindow)
return pDlg;
return NULL;
return nullptr;
}
void Screen::Render(bool fDoBG)
{
@ -802,7 +802,7 @@ namespace C4GUI
// Special: Pass to MouseControl if dragging and button is not upped
if (IsActive() && !::MouseControl.IsDragging())
{
bool fResult = MouseInput(iButton, iX, iY, dwKeyParam, NULL, pVP);
bool fResult = MouseInput(iButton, iX, iY, dwKeyParam, nullptr, pVP);
if (HasMouseFocus()) { SetMouseInGUI(true, true); return; }
// non-exclusive GUI: inform mouse-control about GUI-result
SetMouseInGUI(fResult, true);
@ -855,7 +855,7 @@ namespace C4GUI
{
// stop dragging
Mouse.pDragElement->StopDragging(Mouse, iX2, iY2, dwKeyParam);
Mouse.pDragElement = NULL;
Mouse.pDragElement = nullptr;
}
else
{
@ -865,7 +865,7 @@ namespace C4GUI
}
// backup previous MouseOver-element
Mouse.pPrevMouseOverElement = Mouse.pMouseOverElement;
Mouse.pMouseOverElement = NULL;
Mouse.pMouseOverElement = nullptr;
bool fProcessed = false;
// active context menu?
if (!pForVP && pContext && pContext->CtxMouseInput(Mouse, iButton, fX, fY, dwKeyParam))
@ -895,7 +895,7 @@ namespace C4GUI
// forward to active dialog
pActiveDlg->MouseInput(Mouse, iButton, fX - rcDlgBounds.x, fY - rcDlgBounds.y, dwKeyParam);
else
Mouse.pMouseOverElement = NULL;
Mouse.pMouseOverElement = nullptr;
}
else
// outside dialog: own handling (for screen context menu)
@ -913,7 +913,7 @@ namespace C4GUI
if (pForDlg && pDlg != pForDlg) continue;
// if specified: process specified viewport only
bool fIsExternalDrawDialog = pDlg->IsExternalDrawDialog();
C4Viewport *pVP = fIsExternalDrawDialog ? pDlg->GetViewport() : NULL;
C4Viewport *pVP = fIsExternalDrawDialog ? pDlg->GetViewport() : nullptr;
if (pForVP && pForVP != pVP) continue;
// calc offset
C4Rect &rcDlgBounds = pDlg->GetBounds();
@ -962,7 +962,7 @@ namespace C4GUI
bool Screen::RecheckMouseInput()
{
return MouseInput(C4MC_Button_None, Mouse.x, Mouse.y, Mouse.dwKeys, NULL, NULL);
return MouseInput(C4MC_Button_None, Mouse.x, Mouse.y, Mouse.dwKeys, nullptr, nullptr);
}
void Screen::UpdateMouseFocus()
@ -1046,7 +1046,7 @@ namespace C4GUI
if (pDlg->IsFullscreenDialog())
if (fIncludeFading || !pDlg->IsFading())
return pDlg;
return NULL;
return nullptr;
}
void Screen::UpdateGamepadGUIControlEnabled()

View File

@ -401,7 +401,7 @@ namespace C4GUI
virtual bool IsOwnPtrElement() { return false; } // if true is returned, item will not be deleted when container is cleared
virtual bool IsExternalDrawDialog() { return false; }
virtual bool IsMenu() { return false; }
virtual class DialogWindow* GetDialogWindow() { return NULL; } // return DialogWindow if this element is a dialog
virtual class DialogWindow* GetDialogWindow() { return nullptr; } // return DialogWindow if this element is a dialog
// for listbox-selection by character input
virtual bool CheckNameHotkey(const char *) { return false; }
@ -429,7 +429,7 @@ namespace C4GUI
Container *GetParent() { return pParent; } // get owning container
virtual class Dialog *GetDlg(); // return contained dialog
virtual Screen *GetScreen(); // return contained screen
virtual Control *IsFocusElement() { return NULL; }; // return control to gain focus in search-cycle
virtual Control *IsFocusElement() { return nullptr; }; // return control to gain focus in search-cycle
virtual void UpdateOwnPos() { }; // called when element bounds were changed externally
void ScreenPos2ClientPos(int32_t &riX, int32_t &riY); // transform screen coordinates to element coordinates
@ -449,7 +449,7 @@ namespace C4GUI
Element *GetNext() const { return pNext; }
Element *GetPrev() const { return pPrev; }
virtual Element *GetFirstNestedElement(bool fBackwards) { return this; }
virtual Element *GetFirstContained() { return NULL; }
virtual Element *GetFirstContained() { return nullptr; }
bool IsInActiveDlg(bool fForKeyboard);
virtual bool IsParentOf(Element *pEl) { return false; } // whether this is the parent container (directly or recursively) of the passed element
@ -494,8 +494,8 @@ namespace C4GUI
virtual int32_t GetLeftIndent() { return 0; }
public:
Label(const char *szLblText, int32_t iX0, int32_t iTop, int32_t iAlign=ALeft, DWORD dwFClr=0xffffffff, CStdFont *pFont=NULL, bool fMakeReadableOnBlack = true, bool fMarkup=true); // ctor
Label(const char *szLblText, const C4Rect &rcBounds, int32_t iAlign=ALeft, DWORD dwFClr=0xffffffff, CStdFont *pFont=NULL, bool fMakeReadableOnBlack = true, bool fAutosize = true, bool fMarkup=true); // ctor
Label(const char *szLblText, int32_t iX0, int32_t iTop, int32_t iAlign=ALeft, DWORD dwFClr=0xffffffff, CStdFont *pFont=nullptr, bool fMakeReadableOnBlack = true, bool fMarkup=true); // ctor
Label(const char *szLblText, const C4Rect &rcBounds, int32_t iAlign=ALeft, DWORD dwFClr=0xffffffff, CStdFont *pFont=nullptr, bool fMakeReadableOnBlack = true, bool fAutosize = true, bool fMarkup=true); // ctor
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam); // input: mouse
@ -514,7 +514,7 @@ namespace C4GUI
private:
uint32_t iAutoScrollDelay; // if set and text is longer than would fit, the label will automatically start moving if not changed and displayed for a while
// Time when the label text was changed last. NULL if not initialized; set upon first drawing
// Time when the label text was changed last. nullptr if not initialized; set upon first drawing
C4TimeMilliseconds tLastChangeTime;
int32_t iScrollPos, iScrollDir;
int32_t iRightIndent;
@ -527,11 +527,11 @@ namespace C4GUI
int32_t GetRightIndent() const { return iRightIndent; }
public:
WoodenLabel(const char *szLblText, const C4Rect &rcBounds, DWORD dwFClr=0xffffffff, CStdFont *pFont=NULL, int32_t iAlign=ACenter, bool fMarkup=true) // ctor
WoodenLabel(const char *szLblText, const C4Rect &rcBounds, DWORD dwFClr=0xffffffff, CStdFont *pFont=nullptr, int32_t iAlign=ACenter, bool fMarkup=true) // ctor
: Label(szLblText, rcBounds, iAlign, dwFClr, pFont, true, true, fMarkup), iAutoScrollDelay(0), tLastChangeTime(C4TimeMilliseconds::Now()), iScrollPos(0), iScrollDir(0), iRightIndent(0)
{ SetAutosize(false); this->rcBounds=rcBounds; }// ctor - re-sets bounds after SetText
static int32_t GetDefaultHeight(CStdFont *pUseFont=NULL);
static int32_t GetDefaultHeight(CStdFont *pUseFont=nullptr);
void SetIcon(const C4Facet &rfctIcon);
void SetAutoScrollTime(uint32_t tDelay) { iAutoScrollDelay=tDelay; ResetAutoScroll(); }
@ -959,7 +959,7 @@ namespace C4GUI
public:
ScrollWindow(Window *pParentWindow); // create scroll window in client area of window
~ScrollWindow() { if (pScrollBar) pScrollBar->pScrollWindow = NULL; }
~ScrollWindow() { if (pScrollBar) pScrollBar->pScrollWindow = nullptr; }
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam);
@ -1007,7 +1007,7 @@ namespace C4GUI
CStdFont *GetTitleFont() const;
public:
GroupBox(C4Rect &rtBounds) : Window(), pFont(NULL), dwFrameClr(0u), dwTitleClr(C4GUI_CaptionFontClr), dwBackClr(0xffffffff), iMargin(4)
GroupBox(C4Rect &rtBounds) : Window(), pFont(nullptr), dwFrameClr(0u), dwTitleClr(C4GUI_CaptionFontClr), dwBackClr(0xffffffff), iMargin(4)
{
// init client rect
SetBounds(rtBounds);
@ -1144,7 +1144,7 @@ namespace C4GUI
virtual void DrawElement(C4TargetFacet &cgo); // draw icon and highlight if necessary
public:
IconButton(Icons eUseIcon, const C4Rect &rtBounds, char cHotkey='\0', const char *tooltip_text=NULL); // ctor
IconButton(Icons eUseIcon, const C4Rect &rtBounds, char cHotkey='\0', const char *tooltip_text=nullptr); // ctor
void SetIcon(Icons eUseIcon);
void SetFacet(const C4Facet &rCpy, uint32_t dwClr=0u) { fctIcon = rCpy; }
void SetColor(uint32_t dwClr) { fHasClr=true; this->dwClr=dwClr; }
@ -1211,15 +1211,15 @@ namespace C4GUI
}
public:
CallbackButton(ArrowButton::ArrowFct eDir, const C4Rect &rtBounds, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=NULL) // ctor
CallbackButton(ArrowButton::ArrowFct eDir, const C4Rect &rtBounds, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=nullptr) // ctor
: Base(eDir, rtBounds, 0), pCB(pCB), pCallbackFn(pFn) { }
CallbackButton(const char *szBtnText, C4Rect &rtBounds, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=NULL) // ctor
CallbackButton(const char *szBtnText, C4Rect &rtBounds, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=nullptr) // ctor
: Base(szBtnText, rtBounds), pCB(pCB), pCallbackFn(pFn) { }
CallbackButton(Icons eUseIcon, const C4Rect &rtBounds, char cHotkey, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=NULL) // ctor
CallbackButton(Icons eUseIcon, const C4Rect &rtBounds, char cHotkey, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=nullptr) // ctor
: Base(eUseIcon, rtBounds, cHotkey), pCB(pCB), pCallbackFn(pFn) { }
CallbackButton(Icons eUseIcon, const C4Rect &rtBounds, const char *tooltip_text, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB = NULL) // ctor
CallbackButton(Icons eUseIcon, const C4Rect &rtBounds, const char *tooltip_text, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB = nullptr) // ctor
: Base(eUseIcon, rtBounds, '\0', tooltip_text), pCB(pCB), pCallbackFn(pFn) { }
CallbackButton(int32_t iID, const C4Rect &rtBounds, char cHotkey, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=NULL) // ctor
CallbackButton(int32_t iID, const C4Rect &rtBounds, char cHotkey, typename DlgCallback<CallbackDlg>::Func pFn, CallbackDlg *pCB=nullptr) // ctor
: Base(iID, rtBounds, cHotkey), pCB(pCB), pCallbackFn(pFn) { }
};
@ -1367,7 +1367,7 @@ namespace C4GUI
{ if (pCBAbortFunc && pCBCtrl) (pCBCtrl->*pCBAbortFunc)(); }
public:
CallbackEdit(const C4Rect &rtBounds, CallbackCtrl * pCBCtrl, CBFunc pCBFunc, CBAbortFunc pCBAbortFunc=NULL) // ctor
CallbackEdit(const C4Rect &rtBounds, CallbackCtrl * pCBCtrl, CBFunc pCBFunc, CBAbortFunc pCBAbortFunc=nullptr) // ctor
: Edit(rtBounds), pCBCtrl(pCBCtrl), pCBFunc(pCBFunc), pCBAbortFunc(pCBAbortFunc) { }
};
@ -1428,7 +1428,7 @@ namespace C4GUI
class LabeledEdit : public C4GUI::Window
{
public:
LabeledEdit(const C4Rect &rcBounds, const char *szName, bool fMultiline, const char *szPrefText=NULL, CStdFont *pUseFont=NULL, uint32_t dwTextClr = C4GUI_CaptionFontClr);
LabeledEdit(const C4Rect &rcBounds, const char *szName, bool fMultiline, const char *szPrefText=nullptr, CStdFont *pUseFont=nullptr, uint32_t dwTextClr = C4GUI_CaptionFontClr);
private:
C4GUI::Edit *pEdit;
public:
@ -1464,7 +1464,7 @@ namespace C4GUI
protected:
virtual void UpdateOwnPos();
virtual bool IsFocusOnClick() { return false; } // just check/uncheck on click; do not gain keyboard focus as well
virtual Control *IsFocusElement() { return fEnabled ? Control::IsFocusElement() : NULL; }; // this control can gain focus if enabled
virtual Control *IsFocusElement() { return fEnabled ? Control::IsFocusElement() : nullptr; }; // this control can gain focus if enabled
virtual void DrawElement(C4TargetFacet &cgo); // draw checkbox
virtual bool OnHotkey(uint32_t cHotkey); // return true when hotkey has been processed
@ -1568,8 +1568,8 @@ namespace C4GUI
void SetSelectionDiabled(bool fToVal=true) { fSelectionDisabled = fToVal; }
// get head and tail list items
Element *GetFirst() { return pClientWindow ? pClientWindow->GetFirst() : NULL; }
Element *GetLast() { return pClientWindow ? pClientWindow->GetLast() : NULL; }
Element *GetFirst() { return pClientWindow ? pClientWindow->GetFirst() : nullptr; }
Element *GetLast() { return pClientWindow ? pClientWindow->GetLast() : nullptr; }
// get margins from bounds to client rect
virtual int32_t GetMarginTop() { return 3; }
@ -1582,7 +1582,7 @@ namespace C4GUI
bool IsScrollingNecessary() { return pClientWindow && pClientWindow->IsScrollingNecessary(); }
void SelectEntry(Element *pNewSel, bool fByUser);
void SelectFirstEntry(bool fByUser) { SelectEntry(GetFirst(), fByUser); }
void SelectNone(bool fByUser) { SelectEntry(NULL, fByUser); }
void SelectNone(bool fByUser) { SelectEntry(nullptr, fByUser); }
bool IsMultiColumn() const { return iColCount > 1; }
int32_t ContractToElementHeight(); // make smaller if elements don't use up all of the available height. Return amount by which list box got contracted
@ -1650,7 +1650,7 @@ namespace C4GUI
bool fDrawSelf; // if border and bg shall be drawn
C4Facet *pfctBack, *pfctClip, *pfctIcons; // set for tabulars that have custom gfx
CStdFont *pSheetCaptionFont; // font to be used for caption drawing; NULL if default GUI font is to be used
CStdFont *pSheetCaptionFont; // font to be used for caption drawing; nullptr if default GUI font is to be used
C4KeyBinding *pKeySelUp, *pKeySelDown, *pKeySelUp2, *pKeySelDown2, *pKeyCloseTab; // key bindings
@ -1673,7 +1673,7 @@ namespace C4GUI
virtual void MouseLeave(CMouse &rMouse);
virtual void OnGetFocus(bool fByMouse);
virtual Control *IsFocusElement() { return eTabPos ? this : NULL; }; // this control can gain focus only if tabs are enabled only
virtual Control *IsFocusElement() { return eTabPos ? this : nullptr; }; // this control can gain focus only if tabs are enabled only
virtual bool IsFocusOnClick() { return false; } // but never get focus on single mouse click, because this would de-focus any contained controls!
int32_t GetTopSize() { return (eTabPos == tbTop) ? 20 : 0; } // vertical size of tab selection bar
@ -1732,12 +1732,12 @@ namespace C4GUI
virtual void ElementPosChanged(Element *pOfElement); // called when an element position is changed
virtual void UpdateSize();
virtual Control *IsFocusElement() { return NULL; }; // no focus element for now, because there's nothing to do (2do: scroll?)
virtual Control *IsFocusElement() { return nullptr; }; // no focus element for now, because there's nothing to do (2do: scroll?)
public:
TextWindow(C4Rect &rtBounds, size_t iPicWdt=0, size_t iPicHgt=0, size_t iPicPadding=0, size_t iMaxLines=100, size_t iMaxTextLen=4096, const char *szIndentChars=" ", bool fAutoGrow=false, const C4Facet *pOverlayPic=NULL, int iOverlayBorder=0, bool fMarkup=false); // ctor
TextWindow(C4Rect &rtBounds, size_t iPicWdt=0, size_t iPicHgt=0, size_t iPicPadding=0, size_t iMaxLines=100, size_t iMaxTextLen=4096, const char *szIndentChars=" ", bool fAutoGrow=false, const C4Facet *pOverlayPic=nullptr, int iOverlayBorder=0, bool fMarkup=false); // ctor
void AddTextLine(const char *szText, CStdFont *pFont, DWORD dwClr, bool fDoUpdate, bool fMakeReadableOnBlack, CStdFont *pCaptionFont=NULL) // add text in a new line
void AddTextLine(const char *szText, CStdFont *pFont, DWORD dwClr, bool fDoUpdate, bool fMakeReadableOnBlack, CStdFont *pCaptionFont=nullptr) // add text in a new line
{ if (pLogBuffer) pLogBuffer->AddLine(szText, pFont, dwClr, fDoUpdate, fMakeReadableOnBlack, pCaptionFont); }
void ScrollToBottom() // set scrolling to bottom range
{ if (pClientWindow) pClientWindow->ScrollToBottom(); }
@ -1803,7 +1803,7 @@ namespace C4GUI
virtual void DrawElement(C4TargetFacet &cgo); // draw element
MenuHandler *GetAndZeroCallback()
{ MenuHandler *pMH = pMenuHandler; pMenuHandler=NULL; return pMH; }
{ MenuHandler *pMH = pMenuHandler; pMenuHandler=nullptr; return pMH; }
virtual void MouseLeave(CMouse &rMouse)
{ if (GetParent()) ((ContextMenu *) GetParent())->MouseLeaveEntry(rMouse, this); }
@ -1813,7 +1813,7 @@ namespace C4GUI
virtual bool IsMenu() { return true; }
public:
Entry(const char *szText, Icons icoIcon=Ico_None, MenuHandler *pMenuHandler=NULL, ContextHandler *pSubmenuHandler=NULL); // ctor
Entry(const char *szText, Icons icoIcon=Ico_None, MenuHandler *pMenuHandler=nullptr, ContextHandler *pSubmenuHandler=nullptr); // ctor
~Entry()
{
if (pMenuHandler) delete pMenuHandler;
@ -1870,7 +1870,7 @@ namespace C4GUI
void Open(Element *pTarget, int32_t iScreenX, int32_t iScreenY);
void Abort(bool fByUser);
void AddItem(const char *szText, const char *szToolTip=NULL, Icons icoIcon=Ico_None, MenuHandler *pMenuHandler=NULL, ContextHandler *pSubmenuHandler=NULL)
void AddItem(const char *szText, const char *szToolTip=nullptr, Icons icoIcon=Ico_None, MenuHandler *pMenuHandler=nullptr, ContextHandler *pSubmenuHandler=nullptr)
{
Element *pNew = new ContextMenu::Entry(szText, icoIcon, pMenuHandler, pSubmenuHandler);
AddElement(pNew); pNew->SetToolTip(szToolTip);
@ -1883,7 +1883,7 @@ namespace C4GUI
int32_t GetMenuIndex() { return iMenuIndex; }
static int32_t GetLastMenuIndex() { return iGlobalMenuIndex; }
Dialog *GetTargetDialog() const { return pTarget ? pTarget->GetDlg() : NULL; }
Dialog *GetTargetDialog() const { return pTarget ? pTarget->GetDlg() : nullptr; }
friend class Screen; friend class Entry; friend class Dialog;
};
@ -1996,7 +1996,7 @@ namespace C4GUI
virtual void DrawElement(C4TargetFacet &cgo); // draw combo box
virtual bool IsFocusOnClick() { return false; } // don't select control on click
virtual Control *IsFocusElement() { return fReadOnly ? NULL : this; }; // this control can gain focus if not readonly
virtual Control *IsFocusElement() { return fReadOnly ? nullptr : this; }; // this control can gain focus if not readonly
void OnCtxComboSelect(C4GUI::Element *pListItem, const ComboMenuCBStruct &rNewSel);
@ -2030,7 +2030,7 @@ namespace C4GUI
{
public:
Dialog* pDialog;
DialogWindow(): C4Window(), pDialog(NULL) {}
DialogWindow(): C4Window(), pDialog(nullptr) {}
using C4Window::Init;
C4Window * Init(C4AbstractApp * pApp, const char * Title, const C4Rect &rcBounds, const char *szID);
virtual void Close();
@ -2104,7 +2104,7 @@ namespace C4GUI
virtual void DrawElement(C4TargetFacet &cgo); // draw dlg bg
virtual bool IsComponentOutsideClientArea() { return !!pTitle; } // pTitle lies outside client area
virtual const char *GetID() { return NULL; }
virtual const char *GetID() { return nullptr; }
// special handling for viewport dialogs
virtual void ApplyElementOffset(int32_t &riX, int32_t &riY);
@ -2126,7 +2126,7 @@ namespace C4GUI
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam); // input: mouse. forwards to child controls
// default control to be set if unprocessed keyboard input has been detected
virtual class Control *GetDefaultControl() { return NULL; }
virtual class Control *GetDefaultControl() { return nullptr; }
// default dlg actions for enter/escape
virtual bool OnEnter() { UserClose(true); return true; }
@ -2168,7 +2168,7 @@ namespace C4GUI
virtual bool IsMouseControlled() { return true; }
// For dialogs associated to a viewport: Return viewport (for placement)
virtual C4Viewport *GetViewport() { return NULL; }
virtual C4Viewport *GetViewport() { return nullptr; }
bool IsViewportDialog() { return fViewportDlg; }
// for custom placement procedures; should call SetPos
@ -2197,7 +2197,7 @@ namespace C4GUI
UpdateOwnPos(); // margin may have changed; might need to reposition stuff
}
void ClearFrameDeco() // clear border decoration; no own pos update!
{if (pFrameDeco) pFrameDeco->Deref(); pFrameDeco = NULL; }
{if (pFrameDeco) pFrameDeco->Deref(); pFrameDeco = nullptr; }
FrameDecoration *GetFrameDecoration() const { return pFrameDeco; }
void SetClientSize(int32_t iToWdt, int32_t iToHgt); // resize dialog so its client area has the specified size
@ -2336,7 +2336,7 @@ namespace C4GUI
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);
MessageDialog(const char *szMessage, const char *szCaption, DWORD dwButtons, Icons icoIcon, DlgSize eSize=dsRegular, int32_t *piConfigDontShowAgainSetting=nullptr, bool fDefaultNo=false);
~MessageDialog();
protected:
@ -2456,7 +2456,7 @@ namespace C4GUI
typedef C4KeyCB<TargetClass> Base;
typedef bool(TargetClass::*CallbackFunc)();
public:
DlgKeyCB(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL)
DlgKeyCB(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr)
: Base(rTarget, pFuncDown, pFuncUp, pFuncPressed) {}
virtual bool CheckCondition() { return Base::rTarget.IsInActiveDlg(true) && Base::rTarget.IsVisible(); }
@ -2468,7 +2468,7 @@ namespace C4GUI
typedef C4KeyCBPassKey<TargetClass> Base;
typedef bool(TargetClass::*CallbackFunc)(const C4KeyCodeEx &key);
public:
DlgKeyCBPassKey(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL)
DlgKeyCBPassKey(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr)
: Base(rTarget, pFuncDown, pFuncUp, pFuncPressed) {}
virtual bool CheckCondition() { return Base::rTarget.IsInActiveDlg(true) && Base::rTarget.IsVisible(); }
@ -2480,7 +2480,7 @@ namespace C4GUI
typedef C4KeyCBEx<TargetClass, ParameterType> Base;
typedef bool(TargetClass::*CallbackFunc)(ParameterType par);
public:
DlgKeyCBEx(TargetClass &rTarget, const ParameterType &par, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL)
DlgKeyCBEx(TargetClass &rTarget, const ParameterType &par, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr)
: Base(rTarget, par, pFuncDown, pFuncUp, pFuncPressed) {}
virtual bool CheckCondition() { return Base::rTarget.IsInActiveDlg(true) && Base::rTarget.IsVisible(); }
@ -2493,7 +2493,7 @@ namespace C4GUI
typedef C4KeyCB<TargetClass> Base;
typedef bool(TargetClass::*CallbackFunc)();
public:
ControlKeyCB(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL)
ControlKeyCB(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr)
: Base(rTarget, pFuncDown, pFuncUp, pFuncPressed) {}
virtual bool CheckCondition() { return Base::rTarget.HasDrawFocus(); }
@ -2505,7 +2505,7 @@ namespace C4GUI
typedef C4KeyCBExPassKey<TargetClass, ParameterType> Base;
typedef bool(TargetClass::*CallbackFunc)(const C4KeyCodeEx &key, const ParameterType &par);
public:
ControlKeyCBExPassKey(TargetClass &rTarget, const ParameterType &rPar, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL)
ControlKeyCBExPassKey(TargetClass &rTarget, const ParameterType &rPar, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr)
: Base(rTarget, rPar, pFuncDown, pFuncUp, pFuncPressed) {}
virtual bool CheckCondition() { return Base::rTarget.HasDrawFocus(); }
@ -2519,7 +2519,7 @@ namespace C4GUI
typedef C4KeyCB<TargetClass> Base;
typedef bool(TargetClass::*CallbackFunc)();
public:
ControlKeyDlgCB(Control *pCtrl, TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL)
ControlKeyDlgCB(Control *pCtrl, TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr)
: Base(rTarget, pFuncDown, pFuncUp, pFuncPressed), pCtrl(pCtrl) {}
virtual bool CheckCondition() { return pCtrl && pCtrl->IsInActiveDlg(true) && pCtrl->IsVisible(); }
@ -2564,7 +2564,7 @@ namespace C4GUI
void GetLastXY(int32_t &rX, int32_t &rY, DWORD &rdwKeys) { rX=x; rY=y; rdwKeys=dwKeys; }
void ResetElements() // reset MouseOver/etc.-controls
{ pMouseOverElement=pPrevMouseOverElement=pDragElement=NULL; }
{ pMouseOverElement=pPrevMouseOverElement=pDragElement=nullptr; }
void ReleaseElements(); // reset MouseOver/etc.-controls, doing the appropriate callbacks
void OnElementGetsInvisible(Element *pChild); // clear ptr
@ -2637,9 +2637,9 @@ namespace C4GUI
void SetMouseInGUI(bool fInGUI, bool fByMouse);
bool RecheckMouseInput(); // do mouse movement iusing last input flags
bool ShowMessage(const char *szMessage, const char *szCaption, Icons icoIcon, int32_t *piConfigDontShowAgainSetting=NULL); // show message
bool ShowMessage(const char *szMessage, const char *szCaption, Icons icoIcon, int32_t *piConfigDontShowAgainSetting=nullptr); // show message
bool ShowErrorMessage(const char *szMessage); // show message: Error caption and icon
bool ShowMessageModal(const char *szMessage, const char *szCaption, DWORD dwButtons, Icons icoIcon, int32_t *piConfigDontShowAgainSetting=NULL); // show modal message dlg
bool ShowMessageModal(const char *szMessage, const char *szCaption, DWORD dwButtons, Icons icoIcon, int32_t *piConfigDontShowAgainSetting=nullptr); // show modal message dlg
ProgressDialog *ShowProgressDlg(const char *szMessage, const char *szCaption, int32_t iMaxProgress=100, int32_t iInitialProgress=0, Icons icoIcon=Ico_Wait); // create and show a progress dialog
bool ShowModalDlg(Dialog *pDlg, bool fDestruct=true); // show any dialog modal and destruct it afterwards
bool ShowRemoveDlg(Dialog *pDlg); // show dialog, and flag it to delete itself when closed; return immediately

View File

@ -31,8 +31,8 @@ namespace C4GUI
// Button
Button::Button(const char *szBtnText, const C4Rect &rtBounds)
: Control(rtBounds), pCustomGfx(NULL), pCustomGfxDown(NULL), fDown(false), fMouseOver(false), fEnabled(true),
dwCustomFontClr(0), pCustomFont(NULL)
: Control(rtBounds), pCustomGfx(nullptr), pCustomGfxDown(nullptr), fDown(false), fMouseOver(false), fEnabled(true),
dwCustomFontClr(0), pCustomFont(nullptr)
{
// key callbacks
C4CustomKey::CodeList keys;
@ -252,7 +252,7 @@ namespace C4GUI
void IconButton::SetIcon(Icons eUseIcon)
{
if (eUseIcon>=0) fctIcon = Icon::GetIconFacet(eUseIcon); else fctIcon.Surface=NULL;
if (eUseIcon>=0) fctIcon = Icon::GetIconFacet(eUseIcon); else fctIcon.Surface=nullptr;
}
@ -302,7 +302,7 @@ namespace C4GUI
// FacetButton
FacetButton::FacetButton(const C4Facet &rBaseFct, const C4Facet &rHighlightFct, const FLOAT_RECT &rtfBounds, char cHotkey)
: Button("", C4Rect(rtfBounds)), fctBase(rBaseFct), fctHighlight(rHighlightFct), dwTextClrInact(0x7f000000), dwTextClrAct(0xff000000), rcfDrawBounds(rtfBounds), pFont(NULL), fFontZoom(1.0f)
: Button("", C4Rect(rtfBounds)), fctBase(rBaseFct), fctHighlight(rHighlightFct), dwTextClrInact(0x7f000000), dwTextClrAct(0xff000000), rcfDrawBounds(rtfBounds), pFont(nullptr), fFontZoom(1.0f)
{
// ctor
this->cHotkey = cHotkey;

View File

@ -33,7 +33,7 @@ namespace C4GUI
// CheckBox
CheckBox::CheckBox(const C4Rect &rtBounds, const char *szCaption, bool fChecked)
: Control(rtBounds), fChecked(fChecked), fMouseOn(false), fEnabled(true), pFont(NULL)
: Control(rtBounds), fChecked(fChecked), fMouseOn(false), fEnabled(true), pFont(nullptr)
, dwEnabledClr(C4GUI_CheckboxFontClr), dwDisabledClr(C4GUI_CheckboxDisabledFontClr), cHotkey(0)
{
if (szCaption)
@ -50,7 +50,7 @@ namespace C4GUI
}
pKeyCheck = new C4KeyBinding(Keys, "GUICheckboxToggle", KEYSCOPE_Gui,
new ControlKeyCB<CheckBox>(*this, &CheckBox::KeyCheck), C4CustomKey::PRIO_Ctrl);
pCBHandler = NULL;
pCBHandler = nullptr;
}
CheckBox::~CheckBox()

View File

@ -65,8 +65,8 @@ namespace C4GUI
// ComboBox
ComboBox::ComboBox(const C4Rect &rtBounds) :
Control(rtBounds), iOpenMenu(0), pFillCallback(NULL), fReadOnly(false), fSimple(false), fMouseOver(false),
pUseFont(NULL), dwFontClr(C4GUI_ComboFontClr), dwBGClr(C4GUI_StandardBGColor), dwBorderClr(0), pFctSideArrow(NULL)
Control(rtBounds), iOpenMenu(0), pFillCallback(nullptr), fReadOnly(false), fSimple(false), fMouseOver(false),
pUseFont(nullptr), dwFontClr(C4GUI_ComboFontClr), dwBGClr(C4GUI_StandardBGColor), dwBorderClr(0), pFctSideArrow(nullptr)
{
*Text=0;
// key callbacks - lots of possibilities to get the dropdown

View File

@ -51,7 +51,7 @@ namespace C4GUI
Container::Container() : Element()
{
// zero fields
pFirst = pLast = NULL;
pFirst = pLast = nullptr;
}
Container::~Container()
@ -74,12 +74,12 @@ namespace C4GUI
{
// unlink from list
Element *pANext = pFirst->pNext;
pFirst->pPrev = pFirst->pNext = NULL;
pFirst->pParent = NULL;
pFirst->pPrev = pFirst->pNext = nullptr;
pFirst->pParent = nullptr;
if ((pFirst = pANext))
pFirst->pPrev = NULL;
pFirst->pPrev = nullptr;
else
pLast = NULL;
pLast = nullptr;
}
else
delete pFirst;
@ -98,7 +98,7 @@ namespace C4GUI
if (pChild->pPrev) pChild->pPrev->pNext = pChild->pNext; else pFirst = pChild->pNext;
if (pChild->pNext) pChild->pNext->pPrev = pChild->pPrev; else pLast = pChild->pPrev;
// unset parent; invalidates pPrev/pNext
pChild->pParent = NULL;
pChild->pParent = nullptr;
// element has been removed
AfterElementRemoval();
}
@ -112,7 +112,7 @@ namespace C4GUI
if (pChild->pNext) pChild->pNext->pPrev = pChild->pPrev; else pLast = pChild->pPrev;
// readd to front of list
if (pLast) pLast->pNext = pChild; else pFirst = pChild;
pChild->pPrev = pLast; pChild->pNext = NULL; pLast = pChild;
pChild->pPrev = pLast; pChild->pNext = nullptr; pLast = pChild;
}
void Container::AddElement(Element *pChild)
@ -123,7 +123,7 @@ namespace C4GUI
if (pChild->pParent) pChild->pParent->RemoveElement(pChild);
// add to end of list
if (pLast) pLast->pNext = pChild; else pFirst = pChild;
pChild->pPrev = pLast; pChild->pNext = NULL; pLast = pChild;
pChild->pPrev = pLast; pChild->pNext = nullptr; pLast = pChild;
pChild->pParent = this;
assert(pChild->pNext != pChild);
@ -140,7 +140,7 @@ namespace C4GUI
if (pChild->pNext) pChild->pNext->pPrev = pChild->pPrev; else pLast = pChild->pPrev;
// add to end of list
if (pLast) pLast->pNext = pChild; else pFirst = pChild;
pChild->pPrev = pLast; pChild->pNext = NULL; pLast = pChild;
pChild->pPrev = pLast; pChild->pNext = nullptr; pLast = pChild;
assert(pChild->pNext != pChild);
assert(pChild->pPrev != pChild);
@ -173,7 +173,7 @@ namespace C4GUI
if (fBackwards)
{
// this is last
if (pPrevElement == this) return NULL;
if (pPrevElement == this) return nullptr;
// no previous given?
if (!pPrevElement)
// then use last nested for backwards search
@ -198,7 +198,7 @@ namespace C4GUI
}
// nothing found
}
return NULL;
return nullptr;
}
Element *Container::GetFirstNestedElement(bool fBackwards)
@ -223,7 +223,7 @@ namespace C4GUI
Element *Container::GetElementByIndex(int32_t i)
{
// get next until end of list or queried index is reached
// if i is negative or equal or larger than childcount, the loop will never break and NULL returned
// if i is negative or equal or larger than childcount, the loop will never break and nullptr returned
Element *pEl;
for (pEl = pFirst; i-- && pEl; pEl=pEl->pNext) {}
return pEl;
@ -259,7 +259,7 @@ namespace C4GUI
{
if (IsParentOf(pFocus))
{
pDlg->SetFocus(NULL, false);
pDlg->SetFocus(nullptr, false);
}
}
}
@ -333,7 +333,7 @@ namespace C4GUI
// --------------------------------------------------
// ScrollBar
ScrollBar::ScrollBar(C4Rect &rcBounds, ScrollWindow *pWin) : fAutoHide(false), fHorizontal(false), iCBMaxRange(100), pScrollCallback(NULL), pCustomGfx(NULL)
ScrollBar::ScrollBar(C4Rect &rcBounds, ScrollWindow *pWin) : fAutoHide(false), fHorizontal(false), iCBMaxRange(100), pScrollCallback(nullptr), pCustomGfx(nullptr)
{
// set bounds
this->rcBounds = rcBounds;
@ -347,7 +347,7 @@ namespace C4GUI
Update();
}
ScrollBar::ScrollBar(C4Rect &rcBounds, bool fHorizontal, BaseParCallbackHandler<int32_t> *pCB, int32_t iCBMaxRange) : fAutoHide(false), fHorizontal(fHorizontal), iCBMaxRange(iCBMaxRange), pScrollWindow(NULL), pCustomGfx(NULL)
ScrollBar::ScrollBar(C4Rect &rcBounds, bool fHorizontal, BaseParCallbackHandler<int32_t> *pCB, int32_t iCBMaxRange) : fAutoHide(false), fHorizontal(fHorizontal), iCBMaxRange(iCBMaxRange), pScrollWindow(nullptr), pCustomGfx(nullptr)
{
// set bounds
this->rcBounds = rcBounds;
@ -361,7 +361,7 @@ namespace C4GUI
ScrollBar::~ScrollBar()
{
if (pScrollWindow) { pScrollWindow->pScrollBar = NULL; }
if (pScrollWindow) { pScrollWindow->pScrollBar = nullptr; }
if (pScrollCallback) pScrollCallback->DeRef();
}
@ -502,7 +502,7 @@ namespace C4GUI
// ScrollWindow
ScrollWindow::ScrollWindow(Window *pParentWindow)
: Window(), pScrollBar(NULL), iScrollY(0), iClientHeight(0), fHasBar(true), iFrozen(0)
: Window(), pScrollBar(nullptr), iScrollY(0), iClientHeight(0), fHasBar(true), iFrozen(0)
{
// place within client rect
C4Rect rtBounds = pParentWindow->GetClientRect();

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