diff --git a/src/c4group/C4ComponentHost.h b/src/c4group/C4ComponentHost.h index 6e599f232..e40e842d0 100644 --- a/src/c4group/C4ComponentHost.h +++ b/src/c4group/C4ComponentHost.h @@ -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 diff --git a/src/c4group/C4Group.cpp b/src/c4group/C4Group.cpp index bae4b99ee..8e5b18b56 100644 --- a/src/c4group/C4Group.cpp +++ b/src/c4group/C4Group.cpp @@ -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) { diff --git a/src/c4group/C4Group.h b/src/c4group/C4Group.h index 821460c6b..8b3cde6b1 100644 --- a/src/c4group/C4Group.h +++ b/src/c4group/C4Group.h @@ -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); diff --git a/src/c4group/C4GroupMain.cpp b/src/c4group/C4GroupMain.cpp index 2b697e93f..589ea1880 100644 --- a/src/c4group/C4GroupMain.cpp +++ b/src/c4group/C4GroupMain.cpp @@ -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()) { diff --git a/src/c4group/C4GroupSet.cpp b/src/c4group/C4GroupSet.cpp index 0f50d2de9..af13621d8 100644 --- a/src/c4group/C4GroupSet.cpp +++ b/src/c4group/C4GroupSet.cpp @@ -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); } diff --git a/src/c4group/C4GroupSet.h b/src/c4group/C4GroupSet.h index 00b28fa06..6f40d8b76 100644 --- a/src/c4group/C4GroupSet.h +++ b/src/c4group/C4GroupSet.h @@ -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 diff --git a/src/c4group/C4LangStringTable.cpp b/src/c4group/C4LangStringTable.cpp index 076edf003..33b9f533d 100644 --- a/src/c4group/C4LangStringTable.cpp +++ b/src/c4group/C4LangStringTable.cpp @@ -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; diff --git a/src/c4group/C4Language.cpp b/src/c4group/C4Language.cpp index 42f4817f7..a45c254ff 100644 --- a/src/c4group/C4Language.cpp +++ b/src/c4group/C4Language.cpp @@ -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) diff --git a/src/c4group/C4Update.cpp b/src/c4group/C4Update.cpp index 066f8d354..d0666e56f 100644 --- a/src/c4group/C4Update.cpp +++ b/src/c4group/C4Update.cpp @@ -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; diff --git a/src/c4group/C4Update.h b/src/c4group/C4Update.h index 6c78f8008..806eee5f9 100644 --- a/src/c4group/C4Update.h +++ b/src/c4group/C4Update.h @@ -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); diff --git a/src/c4group/CStdFile.cpp b/src/c4group/CStdFile.cpp index e43daa899..8056d609d 100644 --- a/src/c4group/CStdFile.cpp +++ b/src/c4group/CStdFile.cpp @@ -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(); diff --git a/src/c4group/CStdFile.h b/src/c4group/CStdFile.h index f4af7e073..f49b6db6a 100644 --- a/src/c4group/CStdFile.h +++ b/src/c4group/CStdFile.h @@ -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); diff --git a/src/config/C4Config.cpp b/src/config/C4Config.cpp index 7ee283dd7..4b058a8cb 100644 --- a/src/config/C4Config.cpp +++ b/src/config/C4Config.cpp @@ -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()); diff --git a/src/config/C4Config.h b/src/config/C4Config.h index 325c9d262..98b830d0e 100644 --- a/src/config/C4Config.h +++ b/src/config/C4Config.h @@ -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); diff --git a/src/control/C4Control.cpp b/src/control/C4Control.cpp index 1cf7f6d18..72048205a 100644 --- a/src/control/C4Control.cpp +++ b/src/control/C4Control.cpp @@ -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, 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. diff --git a/src/control/C4Control.h b/src/control/C4Control.h index ecb6e4707..bc9fba1c7 100644 --- a/src/control/C4Control.h +++ b/src/control/C4Control.h @@ -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) diff --git a/src/control/C4GameControl.cpp b/src/control/C4GameControl.cpp index bbe9cb7e7..5c5e20f78 100644 --- a/src/control/C4GameControl.cpp +++ b/src/control/C4GameControl.cpp @@ -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(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() diff --git a/src/control/C4GameControl.h b/src/control/C4GameControl.h index 634759acd..b73281b81 100644 --- a/src/control/C4GameControl.h +++ b/src/control/C4GameControl.h @@ -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 diff --git a/src/control/C4GameParameters.cpp b/src/control/C4GameParameters.cpp index d9dcb0829..e5907b562 100644 --- a/src/control/C4GameParameters.cpp +++ b/src/control/C4GameParameters.cpp @@ -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) { diff --git a/src/control/C4GameParameters.h b/src/control/C4GameParameters.h index c18036f24..73df4bb8e 100644 --- a/src/control/C4GameParameters.h +++ b/src/control/C4GameParameters.h @@ -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 diff --git a/src/control/C4GameSave.cpp b/src/control/C4GameSave.cpp index d300b61db..7fa421fa4 100644 --- a/src/control/C4GameSave.cpp +++ b/src/control/C4GameSave.cpp @@ -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; } diff --git a/src/control/C4GameSave.h b/src/control/C4GameSave.h index 76bbaa580..fc467ad27 100644 --- a/src/control/C4GameSave.h +++ b/src/control/C4GameSave.h @@ -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 diff --git a/src/control/C4PlayerControl.cpp b/src/control/C4PlayerControl.cpp index ed0a64d8b..d1db610c5 100644 --- a/src/control/C4PlayerControl.cpp +++ b/src/control/C4PlayerControl.cpp @@ -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(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(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(*this, key, &C4PlayerControl::ProcessKeyDown, fHoldKey ? &C4PlayerControl::ProcessKeyUp : NULL, NULL, fHoldKey ? &C4PlayerControl::ProcessKeyMoved : NULL), + new C4KeyCBExPassKey(*this, key, &C4PlayerControl::ProcessKeyDown, fHoldKey ? &C4PlayerControl::ProcessKeyUp : nullptr, nullptr, fHoldKey ? &C4PlayerControl::ProcessKeyMoved : nullptr), C4CustomKey::PRIO_PlrControl)); } diff --git a/src/control/C4PlayerControl.h b/src/control/C4PlayerControl.h index 71c43027e..2d294edc9 100644 --- a/src/control/C4PlayerControl.h +++ b/src/control/C4PlayerControl.h @@ -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 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); diff --git a/src/control/C4PlayerInfo.cpp b/src/control/C4PlayerInfo.cpp index a95483d8b..5c783a77b 100644 --- a/src/control/C4PlayerInfo.cpp +++ b/src/control/C4PlayerInfo.cpp @@ -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(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; iGetClientID() == 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; iGetName(); 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; diff --git a/src/control/C4PlayerInfo.h b/src/control/C4PlayerInfo.h index 1715fd0aa..e9c437d4b 100644 --- a/src/control/C4PlayerInfo.h +++ b/src/control/C4PlayerInfo.h @@ -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(iIndex, 0, iClientCount-1)) ? ppClients[iIndex] : NULL; } + { return (ppClients && Inside(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 diff --git a/src/control/C4PlayerInfoConflicts.cpp b/src/control/C4PlayerInfoConflicts.cpp index 7bdb2ab2a..95597f3c3 100644 --- a/src/control/C4PlayerInfoConflicts.cpp +++ b/src/control/C4PlayerInfoConflicts.cpp @@ -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; diff --git a/src/control/C4Record.cpp b/src/control/C4Record.cpp index cc94d3196..4894795e6 100644 --- a/src/control/C4Record.cpp +++ b/src/control/C4Record.cpp @@ -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; } diff --git a/src/control/C4Record.h b/src/control/C4Record.h index 195be66da..be272f2e7 100644 --- a/src/control/C4Record.h +++ b/src/control/C4Record.h @@ -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 diff --git a/src/control/C4RoundResults.cpp b/src/control/C4RoundResults.cpp index 680573039..1fd755629 100644 --- a/src/control/C4RoundResults.cpp +++ b/src/control/C4RoundResults.cpp @@ -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 && idxGetID() == 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. diff --git a/src/control/C4RoundResults.h b/src/control/C4RoundResults.h index 9b98881a2..b21c8147c 100644 --- a/src/control/C4RoundResults.h +++ b/src/control/C4RoundResults.h @@ -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(); diff --git a/src/control/C4Teams.cpp b/src/control/C4Teams.cpp index 9c18072c3..f3c870b0c 100644 --- a/src/control/C4Teams.cpp +++ b/src/control/C4Teams.cpp @@ -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(iIndex, 0, iTeamCount-1)) return NULL; + if (!Inside(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++))) diff --git a/src/control/C4Teams.h b/src/control/C4Teams.h index 8af5d44b5..c9818e3e7 100644 --- a/src/control/C4Teams.h +++ b/src/control/C4Teams.h @@ -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(); diff --git a/src/editor/C4Console.cpp b/src/editor/C4Console.cpp index e63b9af0c..cbdc81f5d 100644 --- a/src/editor/C4Console.cpp +++ b/src/editor/C4Console.cpp @@ -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 C4Console::GetScriptSuggestions(C4PropList *target, Rece const std::list &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) diff --git a/src/editor/C4Console.h b/src/editor/C4Console.h index 9e8d984c4..f8ce9a2fa 100644 --- a/src/editor/C4Console.h +++ b/src/editor/C4Console.h @@ -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(); diff --git a/src/editor/C4ConsoleQt.cpp b/src/editor/C4ConsoleQt.cpp index 235a996ba..3ac6b50dd 100644 --- a/src/editor/C4ConsoleQt.cpp +++ b/src/editor/C4ConsoleQt.cpp @@ -86,7 +86,7 @@ void C4ConsoleGUI::SetInputFunctions(std::list &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; diff --git a/src/editor/C4ConsoleQtDefinitionListViewer.cpp b/src/editor/C4ConsoleQtDefinitionListViewer.cpp index b60c3e303..8fdf1ecd9 100644 --- a/src/editor/C4ConsoleQtDefinitionListViewer.cpp +++ b/src/editor/C4ConsoleQtDefinitionListViewer.cpp @@ -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(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(parent.internalPointer()) : NULL; + DefListNode *parent_node = parent.isValid() ? static_cast(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(parent.internalPointer()) : NULL; + DefListNode *parent_node = parent.isValid() ? static_cast(parent.internalPointer()) : nullptr; if (!parent_node) parent_node = root.get(); if (parent_node->items.size() <= row) return QModelIndex(); // Index into tree diff --git a/src/editor/C4ConsoleQtDefinitionListViewer.h b/src/editor/C4ConsoleQtDefinitionListViewer.h index f8acb3360..dbaefe5e4 100644 --- a/src/editor/C4ConsoleQtDefinitionListViewer.h +++ b/src/editor/C4ConsoleQtDefinitionListViewer.h @@ -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 root; diff --git a/src/editor/C4ConsoleQtNewScenario.cpp b/src/editor/C4ConsoleQtNewScenario.cpp index adee5f57a..1cdd2322d 100644 --- a/src/editor/C4ConsoleQtNewScenario.cpp +++ b/src/editor/C4ConsoleQtNewScenario.cpp @@ -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); diff --git a/src/editor/C4ConsoleQtObjectListViewer.cpp b/src/editor/C4ConsoleQtObjectListViewer.cpp index 6f9748296..aa83af554 100644 --- a/src/editor/C4ConsoleQtObjectListViewer.cpp +++ b/src/editor/C4ConsoleQtObjectListViewer.cpp @@ -39,7 +39,7 @@ C4ConsoleQtObjectListModel::C4ConsoleQtObjectListModel() : last_row_count(0) C4ConsoleQtObjectListModel::~C4ConsoleQtObjectListModel() { - ::Console.ObjectListDlg.SetModel(NULL); + ::Console.ObjectListDlg.SetModel(nullptr); } void C4ConsoleQtObjectListModel::Invalidate() diff --git a/src/editor/C4ConsoleQtPropListViewer.cpp b/src/editor/C4ConsoleQtPropListViewer.cpp index 9c68050a9..a9139503a 100644 --- a/src/editor/C4ConsoleQtPropListViewer.cpp +++ b/src/editor/C4ConsoleQtPropListViewer.cpp @@ -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()]; diff --git a/src/editor/C4ConsoleQtPropListViewer.h b/src/editor/C4ConsoleQtPropListViewer.h index 53db7bb67..909c92122 100644 --- a/src/editor/C4ConsoleQtPropListViewer.h +++ b/src/editor/C4ConsoleQtPropListViewer.h @@ -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; diff --git a/src/editor/C4ConsoleQtShapes.cpp b/src/editor/C4ConsoleQtShapes.cpp index 886d3e0f0..aa908eee8 100644 --- a/src/editor/C4ConsoleQtShapes.cpp +++ b/src/editor/C4ConsoleQtShapes.cpp @@ -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; } diff --git a/src/editor/C4ConsoleQtState.cpp b/src/editor/C4ConsoleQtState.cpp index 025c2cde1..f5fda95b4 100644 --- a/src/editor/C4ConsoleQtState.cpp +++ b/src/editor/C4ConsoleQtState.cpp @@ -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)) { diff --git a/src/editor/C4ConsoleQtViewport.cpp b/src/editor/C4ConsoleQtViewport.cpp index 8ac41dfff..7f217d7dd 100644 --- a/src/editor/C4ConsoleQtViewport.cpp +++ b/src/editor/C4ConsoleQtViewport.cpp @@ -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(); } } diff --git a/src/editor/C4ConsoleWin32.cpp b/src/editor/C4ConsoleWin32.cpp index ddcbda6d9..9ecf8a9e5 100644 --- a/src/editor/C4ConsoleWin32.cpp +++ b/src/editor/C4ConsoleWin32.cpp @@ -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 ©right) { 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(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); } diff --git a/src/editor/C4EditCursor.cpp b/src/editor/C4EditCursor.cpp index 60415ab4b..0ce82c423 100644 --- a/src/editor/C4EditCursor.cpp +++ b/src/editor/C4EditCursor.cpp @@ -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]; diff --git a/src/editor/C4EditCursor.h b/src/editor/C4EditCursor.h index 728aa7947..f175b1d8b 100644 --- a/src/editor/C4EditCursor.h +++ b/src/editor/C4EditCursor.h @@ -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); diff --git a/src/editor/C4ToolsDlg.cpp b/src/editor/C4ToolsDlg.cpp index bfe09f323..77f580f02 100644 --- a/src/editor/C4ToolsDlg.cpp +++ b/src/editor/C4ToolsDlg.cpp @@ -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); diff --git a/src/game/C4Application.cpp b/src/game/C4Application.cpp index 43236c1ef..80771a484 100644 --- a/src/game/C4Application.cpp +++ b/src/game/C4Application.cpp @@ -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(); diff --git a/src/game/C4FullScreen.cpp b/src/game/C4FullScreen.cpp index e23421d3b..78b7ee967 100644 --- a/src/game/C4FullScreen.cpp +++ b/src/game/C4FullScreen.cpp @@ -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; } } diff --git a/src/game/C4Game.cpp b/src/game/C4Game.cpp index 2ea048852..a6c5a37df 100644 --- a/src/game/C4Game.cpp +++ b/src/game/C4Game.cpp @@ -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; cntFinalInit(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,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; cnt2Draw(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); } diff --git a/src/game/C4Game.h b/src/game/C4Game.h index 26dcdf685..38007dbb9 100644 --- a/src/game/C4Game.h +++ b/src/game/C4Game.h @@ -94,7 +94,7 @@ public: C4PlayerControlDefs PlayerControlDefs; C4PlayerControlAssignmentSets PlayerControlUserAssignmentSets, PlayerControlDefaultAssignmentSets; C4Scoreboard Scoreboard; - std::unique_ptr pNetworkStatistics; // may be NULL if no statistics are recorded + std::unique_ptr pNetworkStatistics; // may be nullptr if no statistics are recorded C4KeyboardInput &KeyboardInput; std::unique_ptr pFileMonitor; std::unique_ptr 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 diff --git a/src/game/C4GameScript.cpp b/src/game/C4GameScript.cpp index cb158c40d..6407af208 100644 --- a/src/game/C4GameScript.cpp +++ b/src/game/C4GameScript.cpp @@ -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 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 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(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 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 } }; diff --git a/src/game/C4GraphicsSystem.cpp b/src/game/C4GraphicsSystem.cpp index 62e7132c2..c37137c1a 100644 --- a/src/game/C4GraphicsSystem.cpp +++ b/src/game/C4GraphicsSystem.cpp @@ -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))); diff --git a/src/game/C4Viewport.cpp b/src/game/C4Viewport.cpp index 49230af76..5b6700893 100644 --- a/src/game/C4Viewport.cpp +++ b/src/game/C4Viewport.cpp @@ -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(); iBlitSurfaceTile(::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); diff --git a/src/game/C4Viewport.h b/src/game/C4Viewport.h index 85772b170..41144c266 100644 --- a/src/game/C4Viewport.h +++ b/src/game/C4Viewport.h @@ -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 diff --git a/src/game/ClonkMain.cpp b/src/game/ClonkMain.cpp index 43cf3d22d..7092835f8 100644 --- a/src/game/ClonkMain.cpp +++ b/src/game/ClonkMain.cpp @@ -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 diff --git a/src/graphics/C4Draw.cpp b/src/graphics/C4Draw.cpp index f9ae18900..72aa8608a 100644 --- a/src/graphics/C4Draw.cpp +++ b/src/graphics/C4Draw.cpp @@ -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); } } diff --git a/src/graphics/C4Draw.h b/src/graphics/C4Draw.h index 44ce5e651..fa38a43ca 100644 --- a/src/graphics/C4Draw.h +++ b/src/graphics/C4Draw.h @@ -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 diff --git a/src/graphics/C4DrawGL.cpp b/src/graphics/C4DrawGL.cpp index c72736b5e..5098d8d1e 100644 --- a/src/graphics/C4DrawGL.cpp +++ b/src/graphics/C4DrawGL.cpp @@ -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()) { diff --git a/src/graphics/C4DrawGLCtx.cpp b/src/graphics/C4DrawGLCtx.cpp index 87901029c..26381f294 100644 --- a/src/graphics/C4DrawGLCtx.cpp +++ b/src/graphics/C4DrawGLCtx.cpp @@ -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 #include -CStdGLCtxQt::CStdGLCtxQt() { context = NULL; surface = NULL; } +CStdGLCtxQt::CStdGLCtxQt() { context = nullptr; surface = nullptr; } void CStdGLCtxQt::Clear(bool multisample_change) { diff --git a/src/graphics/C4DrawMeshGL.cpp b/src/graphics/C4DrawMeshGL.cpp index 44fca58d1..55ceafc7a 100644 --- a/src/graphics/C4DrawMeshGL.cpp +++ b/src/graphics/C4DrawMeshGL.cpp @@ -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); diff --git a/src/graphics/C4Facet.cpp b/src/graphics/C4Facet.cpp index 51b1324d0..c7bf6a489 100644 --- a/src/graphics/C4Facet.cpp +++ b/src/graphics/C4Facet.cpp @@ -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 diff --git a/src/graphics/C4Facet.h b/src/graphics/C4Facet.h index 78ae4da46..7c3302ad7 100644 --- a/src/graphics/C4Facet.h +++ b/src/graphics/C4Facet.h @@ -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; } diff --git a/src/graphics/C4FacetEx.cpp b/src/graphics/C4FacetEx.cpp index 8eb1dc21a..1613b0de4 100644 --- a/src/graphics/C4FacetEx.cpp +++ b/src/graphics/C4FacetEx.cpp @@ -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++])) { diff --git a/src/graphics/C4FontLoader.cpp b/src/graphics/C4FontLoader.cpp index 5ccd90be1..4ac823ff8 100644 --- a/src/graphics/C4FontLoader.cpp +++ b/src/graphics/C4FontLoader.cpp @@ -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 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); diff --git a/src/graphics/C4FontLoader.h b/src/graphics/C4FontLoader.h index a9739a326..d76d06cef 100644 --- a/src/graphics/C4FontLoader.h +++ b/src/graphics/C4FontLoader.h @@ -54,7 +54,7 @@ public: C4FontLoader() #ifndef USE_CONSOLE - : pLastUsedFont(NULL), LastUsedGrpID(0) + : pLastUsedFont(nullptr), LastUsedGrpID(0) #endif { } // ctor ~C4FontLoader() { Clear(); } // dtor diff --git a/src/graphics/C4GraphicsResource.cpp b/src/graphics/C4GraphicsResource.cpp index 37fc52aed..112c95dc6 100644 --- a/src/graphics/C4GraphicsResource.cpp +++ b/src/graphics/C4GraphicsResource.cpp @@ -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); } diff --git a/src/graphics/C4GraphicsResource.h b/src/graphics/C4GraphicsResource.h index c00159e46..8ce827522 100644 --- a/src/graphics/C4GraphicsResource.h +++ b/src/graphics/C4GraphicsResource.h @@ -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(); diff --git a/src/graphics/C4Shader.cpp b/src/graphics/C4Shader.cpp index e9f157d29..59e627b1e 100644 --- a/src/graphics/C4Shader.cpp +++ b/src/graphics/C4Shader.cpp @@ -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 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 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 diff --git a/src/graphics/C4Surface.cpp b/src/graphics/C4Surface.cpp index 7a9fab1a9..8111b1732 100644 --- a/src/graphics/C4Surface.cpp +++ b/src/graphics/C4Surface.cpp @@ -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(texLock.pBits); texLock.pBits=NULL; + delete[] static_cast(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() diff --git a/src/graphics/C4Surface.h b/src/graphics/C4Surface.h index fdfd16ad4..53aec9ab2 100644 --- a/src/graphics/C4Surface.h +++ b/src/graphics/C4Surface.h @@ -79,7 +79,7 @@ public: #endif std::unique_ptr 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(); diff --git a/src/graphics/C4SurfaceLoaders.cpp b/src/graphics/C4SurfaceLoaders.cpp index efe94d315..0a8934b22 100644 --- a/src/graphics/C4SurfaceLoaders.cpp +++ b/src/graphics/C4SurfaceLoaders.cpp @@ -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++])) { diff --git a/src/graphics/CSurface8.cpp b/src/graphics/CSurface8.cpp index e720330ff..60a5fe837 100644 --- a/src/graphics/CSurface8.cpp +++ b/src/graphics/CSurface8.cpp @@ -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(); } diff --git a/src/graphics/CSurface8.h b/src/graphics/CSurface8.h index 4b4c554f4..9dd0173f0 100644 --- a/src/graphics/CSurface8.h +++ b/src/graphics/CSurface8.h @@ -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); diff --git a/src/graphics/StdPNG.cpp b/src/graphics/StdPNG.cpp index 09ea955c9..ac4dbcdc3 100644 --- a/src/graphics/StdPNG.cpp +++ b/src/graphics/StdPNG.cpp @@ -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! diff --git a/src/gui/C4ChatDlg.cpp b/src/gui/C4ChatDlg.cpp index 771e9b04e..ee8f2273e 100644 --- a/src/gui/C4ChatDlg.cpp +++ b/src/gui/C4ChatDlg.cpp @@ -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(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(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(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); } diff --git a/src/gui/C4ChatDlg.h b/src/gui/C4ChatDlg.h index f594ab63c..41c285134 100644 --- a/src/gui/C4ChatDlg.h +++ b/src/gui/C4ChatDlg.h @@ -99,7 +99,7 @@ private: private: NickItem *GetNickItem(const char *szByNick); - NickItem *GetFirstNickItem() { return pNickList ? static_cast(pNickList->GetFirst()) : NULL; } + NickItem *GetFirstNickItem() { return pNickList ? static_cast(pNickList->GetFirst()) : nullptr; } NickItem *GetNextNickItem(NickItem *pPrev) { return static_cast(pPrev->GetNext()); } }; diff --git a/src/gui/C4DownloadDlg.cpp b/src/gui/C4DownloadDlg.cpp index 485b27600..18c0e67d1 100644 --- a/src/gui/C4DownloadDlg.cpp +++ b/src/gui/C4DownloadDlg.cpp @@ -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; } diff --git a/src/gui/C4DownloadDlg.h b/src/gui/C4DownloadDlg.h index abc853a6c..94eab504f 100644 --- a/src/gui/C4DownloadDlg.h +++ b/src/gui/C4DownloadDlg.h @@ -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); }; diff --git a/src/gui/C4FileSelDlg.cpp b/src/gui/C4FileSelDlg.cpp index abd7112da..4e6e80826 100644 --- a/src/gui/C4FileSelDlg.cpp +++ b/src/gui/C4FileSelDlg.cpp @@ -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; diff --git a/src/gui/C4FileSelDlg.h b/src/gui/C4FileSelDlg.h index 2e532b053..17e79b2ac 100644 --- a/src/gui/C4FileSelDlg.h +++ b/src/gui/C4FileSelDlg.h @@ -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(); diff --git a/src/gui/C4Folder.cpp b/src/gui/C4Folder.cpp index 1792a2632..6e828d265 100644 --- a/src/gui/C4Folder.cpp +++ b/src/gui/C4Folder.cpp @@ -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; diff --git a/src/gui/C4GameDialogs.cpp b/src/gui/C4GameDialogs.cpp index 7e297d7f2..53e452a3a 100644 --- a/src/gui/C4GameDialogs.cpp +++ b/src/gui/C4GameDialogs.cpp @@ -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), diff --git a/src/gui/C4GameLobby.cpp b/src/gui/C4GameLobby.cpp index 0d4377506..b363b375e 100644 --- a/src/gui/C4GameLobby.cpp +++ b/src/gui/C4GameLobby.cpp @@ -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(*this, true , &MainDlg::KeyHistoryUpDown), C4CustomKey::PRIO_CtrlOverride); @@ -192,7 +192,7 @@ namespace C4GameLobby if (fHost) { btnRun = new C4GUI::CallbackButton(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? diff --git a/src/gui/C4GameLobby.h b/src/gui/C4GameLobby.h index b30b2ab27..52d452f89 100644 --- a/src/gui/C4GameLobby.h +++ b/src/gui/C4GameLobby.h @@ -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); diff --git a/src/gui/C4GameMessage.cpp b/src/gui/C4GameMessage.cpp index f7d383b74..24e8d6011 100644 --- a/src/gui/C4GameMessage.cpp +++ b/src/gui/C4GameMessage.cpp @@ -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(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; diff --git a/src/gui/C4GameMessage.h b/src/gui/C4GameMessage.h index ba24b23a3..87f38447c 100644 --- a/src/gui/C4GameMessage.h +++ b/src/gui/C4GameMessage.h @@ -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); }; diff --git a/src/gui/C4GameOptions.cpp b/src/gui/C4GameOptions.cpp index 34e342afd..4d58790ca 100644 --- a/src/gui/C4GameOptions.cpp +++ b/src/gui/C4GameOptions.cpp @@ -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) diff --git a/src/gui/C4GameOptions.h b/src/gui/C4GameOptions.h index b2833d4c1..7e77618cf 100644 --- a/src/gui/C4GameOptions.h +++ b/src/gui/C4GameOptions.h @@ -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 diff --git a/src/gui/C4GameOverDlg.cpp b/src/gui/C4GameOverDlg.cpp index 338de7e8c..4913c9cf2 100644 --- a/src/gui/C4GameOverDlg.cpp +++ b/src/gui/C4GameOverDlg.cpp @@ -123,7 +123,7 @@ bool C4GameOverDlg::is_shown = false; C4GameOverDlg::C4GameOverDlg() : C4GUI::Dialog( (C4GUI::GetScreenWdt() < 800) ? (C4GUI::GetScreenWdt()-10) : std::min(C4GUI::GetScreenWdt()-150, 800), (C4GUI::GetScreenHgt() < 600) ? (C4GUI::GetScreenHgt()-10) : std::min(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 diff --git a/src/gui/C4GameOverDlg.h b/src/gui/C4GameOverDlg.h index aa0687a8f..2767b3068 100644 --- a/src/gui/C4GameOverDlg.h +++ b/src/gui/C4GameOverDlg.h @@ -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 diff --git a/src/gui/C4GfxErrorDlg.cpp b/src/gui/C4GfxErrorDlg.cpp index 6442212e4..e4a215a51 100644 --- a/src/gui/C4GfxErrorDlg.cpp +++ b/src/gui/C4GfxErrorDlg.cpp @@ -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); } diff --git a/src/gui/C4Gui.cpp b/src/gui/C4Gui.cpp index 4aec40cf5..b73af6577 100644 --- a/src/gui/C4Gui.cpp +++ b/src/gui/C4Gui.cpp @@ -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() diff --git a/src/gui/C4Gui.h b/src/gui/C4Gui.h index b223b29e9..af6719946 100644 --- a/src/gui/C4Gui.h +++ b/src/gui/C4Gui.h @@ -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::Func pFn, CallbackDlg *pCB=NULL) // ctor + CallbackButton(ArrowButton::ArrowFct eDir, const C4Rect &rtBounds, typename DlgCallback::Func pFn, CallbackDlg *pCB=nullptr) // ctor : Base(eDir, rtBounds, 0), pCB(pCB), pCallbackFn(pFn) { } - CallbackButton(const char *szBtnText, C4Rect &rtBounds, typename DlgCallback::Func pFn, CallbackDlg *pCB=NULL) // ctor + CallbackButton(const char *szBtnText, C4Rect &rtBounds, typename DlgCallback::Func pFn, CallbackDlg *pCB=nullptr) // ctor : Base(szBtnText, rtBounds), pCB(pCB), pCallbackFn(pFn) { } - CallbackButton(Icons eUseIcon, const C4Rect &rtBounds, char cHotkey, typename DlgCallback::Func pFn, CallbackDlg *pCB=NULL) // ctor + CallbackButton(Icons eUseIcon, const C4Rect &rtBounds, char cHotkey, typename DlgCallback::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::Func pFn, CallbackDlg *pCB = NULL) // ctor + CallbackButton(Icons eUseIcon, const C4Rect &rtBounds, const char *tooltip_text, typename DlgCallback::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::Func pFn, CallbackDlg *pCB=NULL) // ctor + CallbackButton(int32_t iID, const C4Rect &rtBounds, char cHotkey, typename DlgCallback::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 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 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 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 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 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 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 diff --git a/src/gui/C4GuiButton.cpp b/src/gui/C4GuiButton.cpp index 2f7e47e1c..0c4bbcefa 100644 --- a/src/gui/C4GuiButton.cpp +++ b/src/gui/C4GuiButton.cpp @@ -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; diff --git a/src/gui/C4GuiCheckBox.cpp b/src/gui/C4GuiCheckBox.cpp index ec7351ae4..5dcbde23b 100644 --- a/src/gui/C4GuiCheckBox.cpp +++ b/src/gui/C4GuiCheckBox.cpp @@ -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(*this, &CheckBox::KeyCheck), C4CustomKey::PRIO_Ctrl); - pCBHandler = NULL; + pCBHandler = nullptr; } CheckBox::~CheckBox() diff --git a/src/gui/C4GuiComboBox.cpp b/src/gui/C4GuiComboBox.cpp index 713c2c177..e1256163a 100644 --- a/src/gui/C4GuiComboBox.cpp +++ b/src/gui/C4GuiComboBox.cpp @@ -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 diff --git a/src/gui/C4GuiContainers.cpp b/src/gui/C4GuiContainers.cpp index cf8713dfa..72dc1a158 100644 --- a/src/gui/C4GuiContainers.cpp +++ b/src/gui/C4GuiContainers.cpp @@ -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 *pCB, int32_t iCBMaxRange) : fAutoHide(false), fHorizontal(fHorizontal), iCBMaxRange(iCBMaxRange), pScrollWindow(NULL), pCustomGfx(NULL) + ScrollBar::ScrollBar(C4Rect &rcBounds, bool fHorizontal, BaseParCallbackHandler *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(); diff --git a/src/gui/C4GuiDialogs.cpp b/src/gui/C4GuiDialogs.cpp index d372ce4da..5accc36e4 100644 --- a/src/gui/C4GuiDialogs.cpp +++ b/src/gui/C4GuiDialogs.cpp @@ -228,7 +228,7 @@ namespace C4GUI #endif } C4TargetFacet cgo; - cgo.Set(NULL, 0, 0, r.Wdt, r.Hgt, 0, 0); + cgo.Set(nullptr, 0, 0, r.Wdt, r.Hgt, 0, 0); pDialog->Draw(cgo); } @@ -251,7 +251,7 @@ namespace C4GUI if (!pWindow->Init(&Application, TitleString.getData(), rcBounds, GetID())) { delete pWindow; - pWindow = NULL; + pWindow = nullptr; return false; } // create rendering context @@ -267,15 +267,15 @@ namespace C4GUI delete pWindow->pSurface; pWindow->Clear(); delete pWindow; - pWindow = NULL; + pWindow = nullptr; } } Dialog::Dialog(int32_t iWdt, int32_t iHgt, const char *szTitle, bool fViewportDlg): - Window(), pTitle(NULL), pCloseBtn(NULL), fDelOnClose(false), fViewportDlg(fViewportDlg), pWindow(NULL), pFrameDeco(NULL) + Window(), pTitle(nullptr), pCloseBtn(nullptr), fDelOnClose(false), fViewportDlg(fViewportDlg), pWindow(nullptr), pFrameDeco(nullptr) { // zero fields - pActiveCtrl = NULL; + pActiveCtrl = nullptr; fShow = fOK = false; iFade = 100; eFade = eFadeNone; // add title @@ -374,8 +374,8 @@ namespace C4GUI } else { - if (pTitle) { delete pTitle; pTitle=NULL; } - if (pCloseBtn) { delete pCloseBtn; pCloseBtn = NULL; } + if (pTitle) { delete pTitle; pTitle=nullptr; } + if (pCloseBtn) { delete pCloseBtn; pCloseBtn = nullptr; } } } @@ -430,7 +430,7 @@ namespace C4GUI // inherited Window::RemoveElement(pChild); // clear ptr - if (pChild == pActiveCtrl) pActiveCtrl = NULL; + if (pChild == pActiveCtrl) pActiveCtrl = nullptr; } void Dialog::Draw(C4TargetFacet &cgo0) @@ -569,7 +569,7 @@ namespace C4GUI if (pActiveCtrl) { Control *pC = pActiveCtrl; - pActiveCtrl = NULL; + pActiveCtrl = nullptr; pC->OnLooseFocus(); // if leaving the old focus set a new one, abort here because it looks like the control didn't want to lose focus if (pActiveCtrl) return; @@ -588,13 +588,13 @@ namespace C4GUI // get next element pCurrElement = GetNextNestedElement(pCurrElement, fBackwards); // end reached: start from beginning - if (!pCurrElement && pActiveCtrl) if (!(pCurrElement = GetNextNestedElement(NULL, fBackwards))) return; + if (!pCurrElement && pActiveCtrl) if (!(pCurrElement = GetNextNestedElement(nullptr, fBackwards))) return; // cycled? if (pCurrElement == pActiveCtrl) { // but current is no longer a focus element? Then defocus it and return if (pCurrElement && !pCurrElement->IsFocusElement()) - SetFocus(NULL, false); + SetFocus(nullptr, false); return; } // for list elements, check whether the child can be selected @@ -784,7 +784,7 @@ namespace C4GUI // FullscreenDialog FullscreenDialog::FullscreenDialog(const char *szTitle, const char *szSubtitle) - : Dialog(Screen::GetScreenS()->GetClientRect().Wdt, Screen::GetScreenS()->GetClientRect().Hgt, NULL /* create own title */, false), pFullscreenTitle(NULL) + : Dialog(Screen::GetScreenS()->GetClientRect().Wdt, Screen::GetScreenS()->GetClientRect().Hgt, nullptr /* create own title */, false), pFullscreenTitle(nullptr) { // set margins int32_t iScreenX = Screen::GetScreenS()->GetClientRect().Wdt; @@ -801,12 +801,12 @@ namespace C4GUI AddElement(pSubTitle = new Label(szSubtitle, rcClientRect.Wdt, C4UpperBoardHeight-::GraphicsResource.CaptionFont.GetLineHeight()/2-25-GetMarginTop(), ARight, C4GUI_CaptionFontClr, &::GraphicsResource.TextFont)); pSubTitle->SetToolTip(szTitle); } - else pSubTitle = NULL; + else pSubTitle = nullptr; } void FullscreenDialog::SetTitle(const char *szTitle) { - if (pFullscreenTitle) { delete pFullscreenTitle; pFullscreenTitle=NULL; } + if (pFullscreenTitle) { delete pFullscreenTitle; pFullscreenTitle=nullptr; } // change title text; creates or removes title bar if necessary if (szTitle && *szTitle) { @@ -825,7 +825,7 @@ namespace C4GUI { // draw upper board if (HasUpperBoard()) - pDraw->BlitSurfaceTile(::GraphicsResource.fctUpperBoard.Surface,cgo.Surface,0,std::min(iFade-::GraphicsResource.fctUpperBoard.Hgt, 0),cgo.Wdt,::GraphicsResource.fctUpperBoard.Hgt, 0, 0, NULL); + pDraw->BlitSurfaceTile(::GraphicsResource.fctUpperBoard.Surface,cgo.Surface,0,std::min(iFade-::GraphicsResource.fctUpperBoard.Hgt, 0),cgo.Wdt,::GraphicsResource.fctUpperBoard.Hgt, 0, 0, nullptr); } void FullscreenDialog::UpdateOwnPos() @@ -844,7 +844,7 @@ namespace C4GUI // MessageDialog MessageDialog::MessageDialog(const char *szMessage, const char *szCaption, DWORD dwButtons, Icons icoIcon, DlgSize eSize, int32_t *piConfigDontShowAgainSetting, bool fDefaultNo) - : Dialog(eSize, 100 /* will be resized */, szCaption, false), piConfigDontShowAgainSetting(piConfigDontShowAgainSetting), pKeyCopy(NULL), sCopyText() + : Dialog(eSize, 100 /* will be resized */, szCaption, false), piConfigDontShowAgainSetting(piConfigDontShowAgainSetting), pKeyCopy(nullptr), sCopyText() { CStdFont &rUseFont = ::GraphicsResource.TextFont; // get positions @@ -876,7 +876,7 @@ namespace C4GUI { int w=100,h=20; const char *szCheckText = LoadResStr("IDS_MSG_DONTSHOW"); - CheckBox::GetStandardCheckBoxSize(&w, &h, szCheckText, NULL); + CheckBox::GetStandardCheckBoxSize(&w, &h, szCheckText, nullptr); CheckBox *pCheck = new C4GUI::CheckBox(caMain.GetFromTop(h, w), szCheckText, !!*piConfigDontShowAgainSetting); pCheck->SetOnChecked(new C4GUI::CallbackHandler(this, &MessageDialog::OnDontShowAgainCheck)); AddElement(pCheck); @@ -887,7 +887,7 @@ namespace C4GUI int32_t iButtonCount = 0; int32_t i=1; while (i) { if (dwButtons & i) ++iButtonCount; i=i<<1; } fHasOK = !!(dwButtons & btnOK) || !!(dwButtons & btnYes); - Button *btnFocus = NULL; + Button *btnFocus = nullptr; if (iButtonCount) { C4Rect rcBtn = caButtonArea.GetCentered(iButtonCount*C4GUI_DefButton2Wdt+(iButtonCount-1)*C4GUI_DefButton2HSpace, C4GUI_ButtonHgt); @@ -980,14 +980,14 @@ bool MessageDialog::KeyCopy() void ConfirmationDialog::OnClosed(bool fOK) { // confirmed only on OK - BaseCallbackHandler *pStackCB = fOK ? pCB : NULL; + BaseCallbackHandler *pStackCB = fOK ? pCB : nullptr; if (pStackCB) pStackCB->Ref(); // caution: this will usually delete the dlg (this) // so the CB-interface is backed up MessageDialog::OnClosed(fOK); if (pStackCB) { - pStackCB->DoCall(NULL); + pStackCB->DoCall(nullptr); pStackCB->DeRef(); } } @@ -1058,7 +1058,7 @@ bool MessageDialog::KeyCopy() // create progress dlg ProgressDialog *pDlg = new ProgressDialog(szMessage, szCaption, iMaxProgress, iInitialProgress, icoIcon); // show it - if (!pDlg->Show(this, true)) { delete pDlg; return NULL; } + if (!pDlg->Show(this, true)) { delete pDlg; return nullptr; } // return dlg pointer return pDlg; } @@ -1103,7 +1103,7 @@ bool MessageDialog::KeyCopy() fChatLayout ? C4GUI::Edit::GetDefaultEditHeight() + 2 : std::max(::GraphicsResource.TextFont.BreakMessage(szMessage, C4GUI_InputDlgWdt - 3 * C4GUI_DefDlgIndent - C4GUI_IconWdt, 0, 0, true), C4GUI_IconHgt) + C4GUI_InputDlgVRoom, szCaption, false), - pEdit(NULL), pCB(pCB), fChatLayout(fChatLayout), pChatLbl(NULL) + pEdit(nullptr), pCB(pCB), fChatLayout(fChatLayout), pChatLbl(nullptr) { if (fChatLayout) { @@ -1217,7 +1217,7 @@ bool MessageDialog::KeyCopy() ComponentAligner caMain(GetClientRect(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent, true); ComponentAligner caButtonArea(caMain.GetFromBottom(C4GUI_ButtonAreaHgt), 0,0); // place info box - pTextWin = new TextWindow(caMain.GetAll(), 0, 0, 0, 100, 4096, " ", true, NULL, 0); + pTextWin = new TextWindow(caMain.GetAll(), 0, 0, 0, 100, 4096, " ", true, nullptr, 0); AddElement(pTextWin); // place close button Button *pBtnClose = new DlgCloseButton(caButtonArea.GetCentered(C4GUI_DefButtonWdt, C4GUI_ButtonHgt)); diff --git a/src/gui/C4GuiEdit.cpp b/src/gui/C4GuiEdit.cpp index a21a1979a..46f9fd24e 100644 --- a/src/gui/C4GuiEdit.cpp +++ b/src/gui/C4GuiEdit.cpp @@ -651,7 +651,7 @@ namespace C4GUI ContextMenu *Edit::OnContext(C4GUI::Element *pListItem, int32_t iX, int32_t iY) { // safety: no text? - if (!Text) return NULL; + if (!Text) return nullptr; // create context menu ContextMenu *pCtx = new ContextMenu(); // fill with any valid items @@ -705,7 +705,7 @@ namespace C4GUI pPrevFocusCtrl = pDlg->GetFocus(); pDlg->SetFocus(this, false); } - else pPrevFocusCtrl=NULL; + else pPrevFocusCtrl=nullptr; // key binding for rename abort C4CustomKey::CodeList keys; keys.push_back(C4KeyCodeEx(K_ESCAPE)); diff --git a/src/gui/C4GuiLabels.cpp b/src/gui/C4GuiLabels.cpp index 1ca309594..338b9b197 100644 --- a/src/gui/C4GuiLabels.cpp +++ b/src/gui/C4GuiLabels.cpp @@ -36,7 +36,7 @@ namespace C4GUI } Label::Label(const char *szLblText, int32_t iX0, int32_t iTop, int32_t iAlign, DWORD dwFClr, CStdFont *pFont, bool fMakeReadableOnBlack, bool fMarkup) - : Element(), dwFgClr(dwFClr), x0(iX0), iAlign(iAlign), pFont(pFont), cHotkey(0), fAutosize(true), fMarkup(fMarkup), pClickFocusControl(NULL) + : Element(), dwFgClr(dwFClr), x0(iX0), iAlign(iAlign), pFont(pFont), cHotkey(0), fAutosize(true), fMarkup(fMarkup), pClickFocusControl(nullptr) { // make color readable if (fMakeReadableOnBlack) MakeColorReadableOnBlack(dwFgClr); @@ -49,7 +49,7 @@ namespace C4GUI } Label::Label(const char *szLblText, const C4Rect &rcBounds, int32_t iAlign, DWORD dwFClr, CStdFont *pFont, bool fMakeReadableOnBlack, bool fAutosize, bool fMarkup) - : Element(), dwFgClr(dwFClr), iAlign(iAlign), pFont(pFont), cHotkey(0), fAutosize(fAutosize), fMarkup(fMarkup), pClickFocusControl(NULL) + : Element(), dwFgClr(dwFClr), iAlign(iAlign), pFont(pFont), cHotkey(0), fAutosize(fAutosize), fMarkup(fMarkup), pClickFocusControl(nullptr) { // make color readable if (fMakeReadableOnBlack) MakeColorReadableOnBlack(dwFgClr); @@ -247,7 +247,7 @@ namespace C4GUI // size by line count int32_t iIndex = 0; const char *szLine; int32_t iHgt = 0; CStdFont *pLineFont; bool fNewPar; - while ((szLine = Lines.GetLine(iIndex, &pLineFont, NULL, &fNewPar))) + while ((szLine = Lines.GetLine(iIndex, &pLineFont, nullptr, &fNewPar))) { int32_t iFontLineHeight = pLineFont->GetLineHeight(); // indents between separate messages @@ -476,7 +476,7 @@ namespace C4GUI // TextWindow TextWindow::TextWindow(C4Rect &rtBounds, size_t iPicWdt, size_t iPicHgt, size_t iPicPadding, size_t iMaxLines, size_t iMaxTextLen, const char *szIndentChars, bool fAutoGrow, const C4Facet *pOverlayPic, int iOverlayBorder, bool fMarkup) - : Control(rtBounds), pLogBuffer(NULL), fDrawBackground(true), fDrawFrame(true), iPicPadding(iPicPadding) + : Control(rtBounds), pLogBuffer(nullptr), fDrawBackground(true), fDrawFrame(true), iPicPadding(iPicPadding) { // calc client rect UpdateOwnPos(); @@ -505,7 +505,7 @@ namespace C4GUI pTitlePicture = new Picture(rcImage, false); pClientWindow->AddElement(pTitlePicture); } - else pTitlePicture = NULL; + else pTitlePicture = nullptr; // update size UpdateSize(); diff --git a/src/gui/C4GuiListBox.cpp b/src/gui/C4GuiListBox.cpp index caff53d93..5e5acd6b8 100644 --- a/src/gui/C4GuiListBox.cpp +++ b/src/gui/C4GuiListBox.cpp @@ -31,7 +31,7 @@ namespace C4GUI // ListBox ListBox::ListBox(const C4Rect &rtBounds, int32_t iMultiColItemWidth) : Control(rtBounds), iMultiColItemWidth(iMultiColItemWidth), iColCount(1) - , pSelectedItem(NULL), pSelectionChangeHandler(NULL), pSelectionDblClickHandler(NULL), fDrawBackground(true), fDrawBorder(false), fSelectionDisabled(false) + , pSelectedItem(nullptr), pSelectionChangeHandler(nullptr), pSelectionDblClickHandler(nullptr), fDrawBackground(true), fDrawBorder(false), fSelectionDisabled(false) { // calc client rect UpdateOwnPos(); @@ -154,7 +154,7 @@ namespace C4GUI { // reset selection Element *pPrevSelectedItem = pSelectedItem; - pSelectedItem = NULL; + pSelectedItem = nullptr; // get client component the mouse is over iX -= GetMarginLeft(); iY -= GetMarginTop(); iY += pClientWindow->GetScrollY(); @@ -480,7 +480,7 @@ namespace C4GUI // clear selection var if (pChild == pSelectedItem) { - pSelectedItem = NULL; + pSelectedItem = nullptr; SelectionChanged(false); } // position update in AfterElementRemoval @@ -574,7 +574,7 @@ namespace C4GUI void ListBox::SelectionChanged(bool fByUser) { // selections disabled? - if (fSelectionDisabled) { pSelectedItem = NULL; return; } + if (fSelectionDisabled) { pSelectedItem = nullptr; return; } // any selection? if (pSelectedItem) { diff --git a/src/gui/C4GuiMenu.cpp b/src/gui/C4GuiMenu.cpp index 5a247779f..b8387b097 100644 --- a/src/gui/C4GuiMenu.cpp +++ b/src/gui/C4GuiMenu.cpp @@ -85,7 +85,7 @@ namespace C4GUI // ---------------------------------------------------- // ContextMenu - ContextMenu::ContextMenu() : Window(), pTarget(NULL), pSelectedItem(NULL), pSubmenu(NULL) + ContextMenu::ContextMenu() : Window(), pTarget(nullptr), pSelectedItem(nullptr), pSubmenu(nullptr) { iMenuIndex = ++iGlobalMenuIndex; // set min size @@ -152,7 +152,7 @@ namespace C4GUI ContextMenu::~ContextMenu() { // del any submenu - if (pSubmenu) { delete pSubmenu; pSubmenu=NULL; } + if (pSubmenu) { delete pSubmenu; pSubmenu=nullptr; } // forward RemoveElement to screen Screen *pScreen = GetScreen(); if (pScreen) pScreen->RemoveElement(this); @@ -208,7 +208,7 @@ namespace C4GUI { // reset selection Element *pPrevSelectedItem = pSelectedItem; - pSelectedItem = NULL; + pSelectedItem = nullptr; // get client component the mouse is over iX -= GetMarginLeft(); iY -= GetMarginTop(); for (Element *pCurr = GetFirst(); pCurr; pCurr = pCurr->GetNext()) @@ -232,7 +232,7 @@ namespace C4GUI // no submenu open? then deselect any selected item if (pOldEntry==pSelectedItem && !pSubmenu) { - pSelectedItem = NULL; + pSelectedItem = nullptr; SelectionChanged(true); } } @@ -370,11 +370,11 @@ namespace C4GUI // target lost? if (pChild == pTarget) { Abort(false); return; } // submenu? - if (pChild == pSubmenu) pSubmenu = NULL; + if (pChild == pSubmenu) pSubmenu = nullptr; // clear selection var if (pChild == pSelectedItem) { - pSelectedItem = NULL; + pSelectedItem = nullptr; SelectionChanged(false); } // forward to any submenu @@ -550,7 +550,7 @@ namespace C4GUI void ContextMenu::SelectItem(int32_t iIndex) { - // get item to be selected (may be NULL on purpose!) + // get item to be selected (may be nullptr on purpose!) Element *pNewSelElement = GetElementByIndex(iIndex); if (pNewSelElement != pSelectedItem) return; // set new diff --git a/src/gui/C4GuiTabular.cpp b/src/gui/C4GuiTabular.cpp index a42c69014..ebdcff516 100644 --- a/src/gui/C4GuiTabular.cpp +++ b/src/gui/C4GuiTabular.cpp @@ -167,9 +167,9 @@ namespace C4GUI // ---------------------------------------------------- // Tabular - Tabular::Tabular(C4Rect &rtBounds, TabPosition eTabPos) : Control(rtBounds), pActiveSheet(NULL), eTabPos(eTabPos), iMaxTabWidth(0), + Tabular::Tabular(C4Rect &rtBounds, TabPosition eTabPos) : Control(rtBounds), pActiveSheet(nullptr), eTabPos(eTabPos), iMaxTabWidth(0), iCaptionLengthTotal(0), iCaptionScrollPos(0), fScrollingLeft(false), fScrollingRight(false), fScrollingLeftDown(false), - fScrollingRightDown(false), iSheetMargin(4), fDrawSelf(true), pfctBack(NULL), pfctClip(NULL), pfctIcons(NULL), pSheetCaptionFont(NULL) + fScrollingRightDown(false), iSheetMargin(4), fDrawSelf(true), pfctBack(nullptr), pfctClip(nullptr), pfctIcons(nullptr), pSheetCaptionFont(nullptr) { // calc client rect UpdateOwnPos(); @@ -205,7 +205,7 @@ namespace C4GUI } else { - pKeySelUp = pKeySelDown = pKeySelUp2 = pKeySelDown2 = pKeyCloseTab = NULL; + pKeySelUp = pKeySelDown = pKeySelUp2 = pKeySelDown2 = pKeyCloseTab = nullptr; } SheetsChanged(); } @@ -255,7 +255,7 @@ namespace C4GUI void Tabular::SelectionChanged(bool fByUser) { - Control *pFocusCtrl = NULL; + Control *pFocusCtrl = nullptr; Dialog *pDlg = GetDlg(); if (pDlg) pFocusCtrl = pDlg->GetFocus(); // any selection? @@ -422,7 +422,7 @@ namespace C4GUI vtx[6] = d+iTabWidth; vtx[7] = y0; } DWORD dwClr = (pSheet == pActiveSheet) ? C4GUI_ActiveTabBGColor : C4GUI_StandardBGColor; - pDraw->DrawQuadDw(cgo.Surface, vtx, dwClr, dwClr, dwClr, dwClr, NULL); + pDraw->DrawQuadDw(cgo.Surface, vtx, dwClr, dwClr, dwClr, dwClr, nullptr); // draw caption frame // TODO: Switch to PerformMultiLines pDraw->DrawLineDw(cgo.Surface, (float)vtx[0]-1 , (float)vtx[1] , (float)vtx[2]-1 ,(float)vtx[3] , C4GUI_BorderColorA1); @@ -441,7 +441,7 @@ namespace C4GUI ad0=d; ad1=d+(fLeft ? iTabHeight : iTabWidth); aCptTxX = iCptTextX; aCptTxY = iCptTextY; // draw active caption - if (!fGfx) pSheet->DrawCaption(cgo, iCptTextX, iCptTextY, iMaxTabWidth, fLeft, true, HasDrawFocus(), NULL, NULL, NULL); + if (!fGfx) pSheet->DrawCaption(cgo, iCptTextX, iCptTextY, iMaxTabWidth, fLeft, true, HasDrawFocus(), nullptr, nullptr, nullptr); } else { diff --git a/src/gui/C4KeyboardInput.cpp b/src/gui/C4KeyboardInput.cpp index 73aa291a8..66c631840 100644 --- a/src/gui/C4KeyboardInput.cpp +++ b/src/gui/C4KeyboardInput.cpp @@ -50,7 +50,7 @@ const C4KeyShiftMapEntry KeyShiftMap [] = { KEYS_Alt, "Alt" }, { KEYS_Control, "Ctrl" }, { KEYS_Shift, "Shift" }, - { KEYS_Undefined, NULL } + { KEYS_Undefined, nullptr } }; C4KeyShiftState C4KeyCodeEx::String2KeyShift(const StdStrBuf &sName) @@ -83,55 +83,55 @@ struct C4KeyCodeMapEntry #else const C4KeyCodeMapEntry KeyCodeMap[] = { {K_ESCAPE, "Escape", "Esc"}, - {K_1, "1", NULL}, - {K_2, "2", NULL}, - {K_3, "3", NULL}, - {K_4, "4", NULL}, - {K_5, "5", NULL}, - {K_6, "6", NULL}, - {K_7, "7", NULL}, - {K_8, "8", NULL}, - {K_9, "9", NULL}, - {K_0, "0", NULL}, + {K_1, "1", nullptr}, + {K_2, "2", nullptr}, + {K_3, "3", nullptr}, + {K_4, "4", nullptr}, + {K_5, "5", nullptr}, + {K_6, "6", nullptr}, + {K_7, "7", nullptr}, + {K_8, "8", nullptr}, + {K_9, "9", nullptr}, + {K_0, "0", nullptr}, {K_MINUS, "Minus", "-"}, {K_EQUAL, "Equal", "="}, - {K_BACK, "BackSpace", NULL}, - {K_TAB, "Tab", NULL}, - {K_Q, "Q", NULL}, - {K_W, "W", NULL}, - {K_E, "E", NULL}, - {K_R, "R", NULL}, - {K_T, "T", NULL}, - {K_Y, "Y", NULL}, - {K_U, "U", NULL}, - {K_I, "I", NULL}, - {K_O, "O", NULL}, - {K_P, "P", NULL}, + {K_BACK, "BackSpace", nullptr}, + {K_TAB, "Tab", nullptr}, + {K_Q, "Q", nullptr}, + {K_W, "W", nullptr}, + {K_E, "E", nullptr}, + {K_R, "R", nullptr}, + {K_T, "T", nullptr}, + {K_Y, "Y", nullptr}, + {K_U, "U", nullptr}, + {K_I, "I", nullptr}, + {K_O, "O", nullptr}, + {K_P, "P", nullptr}, {K_LEFT_BRACKET, "LeftBracket", "["}, {K_RIGHT_BRACKET, "RightBracket", "]"}, {K_RETURN, "Return", "Ret"}, {K_CONTROL_L, "LeftControl", "LCtrl"}, - {K_A, "A", NULL}, - {K_S, "S", NULL}, - {K_D, "D", NULL}, - {K_F, "F", NULL}, - {K_G, "G", NULL}, - {K_H, "H", NULL}, - {K_J, "J", NULL}, - {K_K, "K", NULL}, - {K_L, "L", NULL}, + {K_A, "A", nullptr}, + {K_S, "S", nullptr}, + {K_D, "D", nullptr}, + {K_F, "F", nullptr}, + {K_G, "G", nullptr}, + {K_H, "H", nullptr}, + {K_J, "J", nullptr}, + {K_K, "K", nullptr}, + {K_L, "L", nullptr}, {K_SEMICOLON, "Semicolon", ";"}, {K_APOSTROPHE, "Apostrophe", "'"}, {K_GRAVE_ACCENT, "GraveAccent", "`"}, {K_SHIFT_L, "LeftShift", "LShift"}, {K_BACKSLASH, "Backslash", "\\"}, - {K_Z, "Z", NULL}, - {K_X, "X", NULL}, - {K_C, "C", NULL}, - {K_V, "V", NULL}, - {K_B, "B", NULL}, - {K_N, "N", NULL}, - {K_M, "M", NULL}, + {K_Z, "Z", nullptr}, + {K_X, "X", nullptr}, + {K_C, "C", nullptr}, + {K_V, "V", nullptr}, + {K_B, "B", nullptr}, + {K_N, "N", nullptr}, + {K_M, "M", nullptr}, {K_COMMA, "Comma", ","}, {K_PERIOD, "Period", "."}, {K_SLASH, "Slash", "/"}, @@ -139,17 +139,17 @@ const C4KeyCodeMapEntry KeyCodeMap[] = { {K_MULTIPLY, "Multiply", "N*"}, {K_ALT_L, "LeftAlt", "LAlt"}, {K_SPACE, "Space", "Sp"}, - {K_CAPS, "Capslock", NULL}, - {K_F1, "F1", NULL}, - {K_F2, "F2", NULL}, - {K_F3, "F3", NULL}, - {K_F4, "F4", NULL}, - {K_F5, "F5", NULL}, - {K_F6, "F6", NULL}, - {K_F7, "F7", NULL}, - {K_F8, "F8", NULL}, - {K_F9, "F9", NULL}, - {K_F10, "F10", NULL}, + {K_CAPS, "Capslock", nullptr}, + {K_F1, "F1", nullptr}, + {K_F2, "F2", nullptr}, + {K_F3, "F3", nullptr}, + {K_F4, "F4", nullptr}, + {K_F5, "F5", nullptr}, + {K_F6, "F6", nullptr}, + {K_F7, "F7", nullptr}, + {K_F8, "F8", nullptr}, + {K_F9, "F9", nullptr}, + {K_F10, "F10", nullptr}, {K_NUM, "NumLock", "NLock"}, {K_SCROLL, "ScrollLock", "SLock"}, {K_NUM7, "Num7", "N7"}, @@ -165,29 +165,29 @@ const C4KeyCodeMapEntry KeyCodeMap[] = { {K_NUM3, "Num3", "N3"}, {K_NUM0, "Num0", "N0"}, {K_DECIMAL, "Decimal", "N,"}, - {K_86, "|<>", NULL}, - {K_F11, "F11", NULL}, - {K_F12, "F12", NULL}, + {K_86, "|<>", nullptr}, + {K_F11, "F11", nullptr}, + {K_F12, "F12", nullptr}, {K_NUM_RETURN, "NumReturn", "NRet"}, {K_CONTROL_R, "RightControl", "RCtrl"}, {K_DIVIDE, "Divide", "N/"}, {K_ALT_R, "RightAlt", "RAlt"}, - {K_HOME, "Home", NULL}, - {K_UP, "Up", NULL}, - {K_PAGEUP, "PageUp", NULL}, - {K_LEFT, "Left", NULL}, - {K_RIGHT, "Right", NULL}, - {K_END, "End", NULL}, - {K_DOWN, "Down", NULL}, - {K_PAGEDOWN, "PageDown", NULL}, + {K_HOME, "Home", nullptr}, + {K_UP, "Up", nullptr}, + {K_PAGEUP, "PageUp", nullptr}, + {K_LEFT, "Left", nullptr}, + {K_RIGHT, "Right", nullptr}, + {K_END, "End", nullptr}, + {K_DOWN, "Down", nullptr}, + {K_PAGEDOWN, "PageDown", nullptr}, {K_INSERT, "Insert", "Ins"}, {K_DELETE, "Delete", "Del"}, - {K_PAUSE, "Pause", NULL}, + {K_PAUSE, "Pause", nullptr}, {K_WIN_L, "LeftWin", "LWin"}, {K_WIN_R, "RightWin", "RWin"}, - {K_MENU, "Menu", NULL}, - {K_PRINT, "Print", NULL}, - {0x00, NULL, NULL} + {K_MENU, "Menu", nullptr}, + {K_PRINT, "Print", nullptr}, + {0x00, nullptr, nullptr} }; #endif @@ -935,7 +935,7 @@ bool C4KeyboardInput::LoadCustomConfig() C4CustomKey *C4KeyboardInput::GetKeyByName(const char *szKeyName) { KeyNameMap::const_iterator i = KeysByName.find(szKeyName); - if (i == KeysByName.end()) return NULL; else return (*i).second; + if (i == KeysByName.end()) return nullptr; else return (*i).second; } StdStrBuf C4KeyboardInput::GetKeyCodeNameByKeyName(const char *szKeyName, bool fShort, int32_t iIndex) diff --git a/src/gui/C4KeyboardInput.h b/src/gui/C4KeyboardInput.h index c6520134d..0b2dedb8f 100644 --- a/src/gui/C4KeyboardInput.h +++ b/src/gui/C4KeyboardInput.h @@ -233,7 +233,7 @@ struct C4KeyCodeEx return Key == v2.Key && dwShift == v2.dwShift; } - void CompileFunc(StdCompiler *pComp, StdStrBuf *pOutBuf=NULL); + void CompileFunc(StdCompiler *pComp, StdStrBuf *pOutBuf=nullptr); C4KeyCodeEx(C4KeyCode Key = KEY_Default, C4KeyShiftState Shift = KEYS_None, bool fIsRepeated = false, int32_t deviceId = -1); @@ -288,7 +288,7 @@ public: inline void Ref() { ++iRef; } inline void Deref() { if (!--iRef) delete this; } - C4KeyboardCallbackInterface() : iRef(0), pOriginalKey(NULL) {} + C4KeyboardCallbackInterface() : iRef(0), pOriginalKey(nullptr) {} virtual ~C4KeyboardCallbackInterface() {} bool IsOriginalKey(const class C4CustomKey *pCheckKey) const { return pCheckKey == pOriginalKey; } @@ -321,7 +321,7 @@ protected: virtual bool CheckCondition() { return true; } public: - C4KeyCB(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL, CallbackFunc pFuncMoved=NULL) + C4KeyCB(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr, CallbackFunc pFuncMoved=nullptr) : rTarget(rTarget), pFuncDown(pFuncDown), pFuncUp(pFuncUp), pFuncPressed(pFuncPressed), pFuncMoved(pFuncMoved) {} }; @@ -352,7 +352,7 @@ protected: virtual bool CheckCondition() { return true; } public: - C4KeyCBPassKey(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL, CallbackFunc pFuncMoved=NULL) + C4KeyCBPassKey(TargetClass &rTarget, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr, CallbackFunc pFuncMoved=nullptr) : rTarget(rTarget), pFuncDown(pFuncDown), pFuncUp(pFuncUp), pFuncPressed(pFuncPressed), pFuncMoved(pFuncMoved) {} }; @@ -384,7 +384,7 @@ protected: virtual bool CheckCondition() { return true; } public: - C4KeyCBEx(TargetClass &rTarget, const ParameterType &par, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL, CallbackFunc pFuncMoved=NULL) + C4KeyCBEx(TargetClass &rTarget, const ParameterType &par, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr, CallbackFunc pFuncMoved=nullptr) : rTarget(rTarget), pFuncDown(pFuncDown), pFuncUp(pFuncUp), pFuncPressed(pFuncPressed), pFuncMoved(pFuncMoved), par(par) {} }; @@ -415,7 +415,7 @@ protected: virtual bool CheckCondition() { return true; } public: - C4KeyCBExPassKey(TargetClass &rTarget, const ParameterType &par, CallbackFunc pFuncDown, CallbackFunc pFuncUp=NULL, CallbackFunc pFuncPressed=NULL, CallbackFunc pFuncMoved=NULL) + C4KeyCBExPassKey(TargetClass &rTarget, const ParameterType &par, CallbackFunc pFuncDown, CallbackFunc pFuncUp=nullptr, CallbackFunc pFuncPressed=nullptr, CallbackFunc pFuncMoved=nullptr) : rTarget(rTarget), pFuncDown(pFuncDown), pFuncUp(pFuncUp), pFuncPressed(pFuncPressed), pFuncMoved(pFuncMoved), par(par) {} }; diff --git a/src/gui/C4LoaderScreen.cpp b/src/gui/C4LoaderScreen.cpp index a839ab21e..ce9eea91d 100644 --- a/src/gui/C4LoaderScreen.cpp +++ b/src/gui/C4LoaderScreen.cpp @@ -30,7 +30,7 @@ C4LoaderScreen::C4LoaderScreen() { // zero fields - szInfo=NULL; + szInfo=nullptr; fBlackScreen = false; } @@ -52,7 +52,7 @@ bool C4LoaderScreen::Init(const char *szLoaderSpec) SCopy(szLoaderSpec, szLoaderSpecJpg); DefaultExtension(szLoaderSpecJpg, "jpg"); SCopy(szLoaderSpec, szLoaderSpecJpeg); DefaultExtension(szLoaderSpecJpeg, "jpeg"); int iLoaders=0; - C4Group *pGroup=NULL,*pChosenGrp=NULL; + C4Group *pGroup=nullptr,*pChosenGrp=nullptr; char ChosenFilename[_MAX_PATH+1]; // query groups of equal priority in set while ((pGroup=Game.GroupSet.FindGroup(C4GSCnt_Loaders, pGroup, true))) @@ -102,7 +102,7 @@ bool C4LoaderScreen::Init(const char *szLoaderSpec) if (!fctBackground.Load(*pChosenGrp,ChosenFilename, C4FCT_Full,C4FCT_Full,true,0)) return false; // load info - if (szInfo) { delete [] szInfo; szInfo=NULL; } + if (szInfo) { delete [] szInfo; szInfo=nullptr; } // done, success! return true; @@ -183,7 +183,7 @@ void C4LoaderScreen::Draw(C4Facet &cgo, int iProgress, C4LogBuffer *pLog, int Pr int32_t w,h; for (int i = -iLinesVisible; i < 0; ++i) { - const char *szLine = pLog->GetLine(i, NULL, NULL, NULL); + const char *szLine = pLog->GetLine(i, nullptr, nullptr, nullptr); if (!szLine || !*szLine) continue; LogFont.GetTextExtent(szLine, w,h, true); pDraw->TextOut(szLine,LogFont,fLogBoxFontZoom,cgo.Surface,iX,iY); diff --git a/src/gui/C4LoaderScreen.h b/src/gui/C4LoaderScreen.h index b2671b463..a805be1a3 100644 --- a/src/gui/C4LoaderScreen.h +++ b/src/gui/C4LoaderScreen.h @@ -35,7 +35,7 @@ public: void SetBlackScreen(bool fIsBlack); // enabled/disables drawing of loader screen int SeekLoaderScreens(C4Group &rFromGrp, const char *szWildcard, int iLoaderCount, char *szDstName, C4Group **ppDestGrp); - void Draw(C4Facet &cgo, int iProgress=0, class C4LogBuffer *pLog=NULL, int Process=0); // draw loader screen (does not page flip!) + void Draw(C4Facet &cgo, int iProgress=0, class C4LogBuffer *pLog=nullptr, int Process=0); // draw loader screen (does not page flip!) }; #endif //INC_C4LoaderScreen diff --git a/src/gui/C4MainMenu.cpp b/src/gui/C4MainMenu.cpp index a01872bf6..8aa45ee0f 100644 --- a/src/gui/C4MainMenu.cpp +++ b/src/gui/C4MainMenu.cpp @@ -151,7 +151,7 @@ bool C4MainMenu::DoRefillInternal(bool &rfRefilled) sprintf(szInfoCaption,LoadResStr("IDS_MENU_ATTACKINFO"),pPlr->GetName(),szFriendly,szNot); if (iIndex==pPlayer->Number) SCopy(LoadResStr("IDS_MENU_ATTACKSELF"),szInfoCaption); // Add item - Add(sMsg.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,szInfoCaption); + Add(sMsg.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,nullptr,szInfoCaption); fctSymbol.Default(); } break; @@ -187,11 +187,11 @@ bool C4MainMenu::DoRefillInternal(bool &rfRefilled) } // create team symbol: Icon spec if specified; otherwise flag for empty and crew for nonempty team fctSymbol.Create(C4SymbolSize,C4SymbolSize); - const char *szIconSpec = pTeam ? pTeam->GetIconSpec() : NULL; + const char *szIconSpec = pTeam ? pTeam->GetIconSpec() : nullptr; bool fHasIcon = false; if (szIconSpec && *szIconSpec) { - fHasIcon = Game.DrawTextSpecImage(fctSymbol, szIconSpec, NULL, pTeam->GetColor()); + fHasIcon = Game.DrawTextSpecImage(fctSymbol, szIconSpec, nullptr, pTeam->GetColor()); } if (!fHasIcon) { @@ -209,7 +209,7 @@ bool C4MainMenu::DoRefillInternal(bool &rfRefilled) sTeamName.Ref(LoadResStr("IDS_PRC_NEWTEAM")); const char *szOperation = (Identification == C4MN_TeamSwitch) ? "TeamSwitch" : "TeamSel"; Add(sTeamName.getData(), fctSymbol,FormatString("%s:%d", szOperation, pTeam ? pTeam->GetID() : TEAMID_New).getData(), - C4MN_Item_NoCount,NULL,FormatString(LoadResStr("IDS_MSG_JOINTEAM"), sTeamName.getData()).getData(), C4ID(pTeam ? pTeam->GetID() : 0)); + C4MN_Item_NoCount,nullptr,FormatString(LoadResStr("IDS_MSG_JOINTEAM"), sTeamName.getData()).getData(), C4ID(pTeam ? pTeam->GetID() : 0)); fctSymbol.Default(); } break; @@ -224,7 +224,7 @@ bool C4MainMenu::DoRefillInternal(bool &rfRefilled) if (!pVP) return false; int32_t iInitialSelection = 0; // Add free view - AddRefSym(LoadResStr("IDS_MSG_FREEVIEW"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Star), "Observe:Free", C4MN_Item_NoCount, NULL, LoadResStr("IDS_MSG_FREELYSCROLLAROUNDTHEMAP")); + AddRefSym(LoadResStr("IDS_MSG_FREEVIEW"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Star), "Observe:Free", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MSG_FREELYSCROLLAROUNDTHEMAP")); // Add players C4Player *pPlr; int32_t iIndex; for (iIndex=0; (pPlr = ::Players.GetByIndex(iIndex)); iIndex++) @@ -246,7 +246,7 @@ bool C4MainMenu::DoRefillInternal(bool &rfRefilled) StdStrBuf sInfo; sInfo.Format(LoadResStr("IDS_TEXT_FOLLOWVIEWOFPLAYER"), pPlr->GetName()); // Add item - Add(sMsg.getData(),fctSymbol,sCommand.getData(),C4MN_Item_NoCount,NULL,sInfo.getData()); + Add(sMsg.getData(),fctSymbol,sCommand.getData(),C4MN_Item_NoCount,nullptr,sInfo.getData()); fctSymbol.Default(); // check if this is the currently selected player if (pVP->GetPlayer() == pPlr->Number) iInitialSelection = GetItemCount()-1; @@ -313,7 +313,7 @@ bool C4MainMenu::ActivateGoals(int32_t iPlayer, bool fDoActivate) InitRefSym(GfxR->fctMenu.GetPhase(4),LoadResStr("IDS_MENU_CPGOALS"),iPlayer); SetAlignment(C4MN_Align_Left | C4MN_Align_Bottom); SetPermanent(false); - fctGF.Set(NULL, C4SymbolSize-::GraphicsResource.fctCaptain.Wdt-2, 2, ::GraphicsResource.fctCaptain.Wdt, ::GraphicsResource.fctCaptain.Hgt); + fctGF.Set(nullptr, C4SymbolSize-::GraphicsResource.fctCaptain.Wdt-2, 2, ::GraphicsResource.fctCaptain.Wdt, ::GraphicsResource.fctCaptain.Hgt); } // determine if the goals are fulfilled - do the calls even if the menu is not to be opened to ensure synchronization C4IDList GoalList, FulfilledGoalList; @@ -339,7 +339,7 @@ bool C4MainMenu::ActivateGoals(int32_t iPlayer, bool fDoActivate) ::GraphicsResource.fctCaptain.Draw(fctGF); } StdStrBuf Command; Command.Format("Player:Goal:%s", idGoal.ToString()); - Add(pDef->GetName(),fctSymbol,Command.getData(),C4MN_Item_NoCount,NULL,""); + Add(pDef->GetName(),fctSymbol,Command.getData(),C4MN_Item_NoCount,nullptr,""); } // Go back to options menu on close SetCloseCommand("ActivateMenu:Main"); @@ -363,7 +363,7 @@ bool C4MainMenu::ActivateRules(int32_t iPlayer) { fctSymbol.Create(C4SymbolSize,C4SymbolSize); pDef->Draw(fctSymbol); sprintf(Command, "Player:Rule:%s", idGoal.ToString()); - Add(pDef->GetName(),fctSymbol,Command,C4MN_Item_NoCount,NULL,""); + Add(pDef->GetName(),fctSymbol,Command,C4MN_Item_NoCount,nullptr,""); } // Go back to options menu on close SetCloseCommand("ActivateMenu:Main"); @@ -458,7 +458,7 @@ bool C4MainMenu::ActivateSavegame(int32_t iPlayer) // Item caption strCaption = LoadResStr("IDS_MENU_CPSAVEGAME"); // add menu item - AddRefSym(strCaption.getData(), GfxR->fctMenu.GetPhase(i - 1, fFree ? 2 : 1), strCommand.getData(), C4MN_Item_NoCount, NULL, LoadResStr("IDS_MENU_CPSAVEGAMEINFO")); + AddRefSym(strCaption.getData(), GfxR->fctMenu.GetPhase(i - 1, fFree ? 2 : 1), strCommand.getData(), C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_CPSAVEGAMEINFO")); } // Go back to options menu on close @@ -474,7 +474,7 @@ bool C4MainMenu::ActivateHost(int32_t iPlayer) SetAlignment(C4MN_Align_Left | C4MN_Align_Bottom); SetPermanent(true); // 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)) { bool fHost = (pClient->getID() == 0); StdStrBuf strText, strCommand; @@ -542,9 +542,9 @@ bool C4MainMenu::ActivateDisplay(int32_t iPlayer, int32_t selection) SetAlignment(C4MN_Align_Left | C4MN_Align_Bottom); SetPermanent(true); // Crew player names - AddRefSym(LoadResStr("IDS_MNU_PLAYERNAMES"), GfxR->fctOptions.GetPhase(7 + Config.Graphics.ShowCrewNames), "Display:PlayerNames", C4MN_Item_NoCount, NULL, LoadResStr("IDS_MENU_PLAYERNAMES_DESC")); + AddRefSym(LoadResStr("IDS_MNU_PLAYERNAMES"), GfxR->fctOptions.GetPhase(7 + Config.Graphics.ShowCrewNames), "Display:PlayerNames", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_PLAYERNAMES_DESC")); // Crew clonk names - AddRefSym(LoadResStr("IDS_MNU_CLONKNAMES"), GfxR->fctOptions.GetPhase(9 + Config.Graphics.ShowCrewCNames), "Display:ClonkNames", C4MN_Item_NoCount, NULL, LoadResStr("IDS_MENU_CLONKNAMES_DESC")); + AddRefSym(LoadResStr("IDS_MNU_CLONKNAMES"), GfxR->fctOptions.GetPhase(9 + Config.Graphics.ShowCrewCNames), "Display:ClonkNames", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_CLONKNAMES_DESC")); // Upper Board if (!Application.isEditor) { @@ -581,55 +581,55 @@ bool C4MainMenu::ActivateMain(int32_t iPlayer) if (pPlr) { // Goals - AddRefSym(LoadResStr("IDS_MENU_CPGOALS"),GfxR->fctMenu.GetPhase(4),"ActivateMenu:Goals",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MENU_CPGOALSINFO")); + AddRefSym(LoadResStr("IDS_MENU_CPGOALS"),GfxR->fctMenu.GetPhase(4),"ActivateMenu:Goals",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPGOALSINFO")); // Rules - AddRefSym(LoadResStr("IDS_MENU_CPRULES"),GfxR->fctMenu.GetPhase(5),"ActivateMenu:Rules",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MENU_CPRULESINFO")); + AddRefSym(LoadResStr("IDS_MENU_CPRULES"),GfxR->fctMenu.GetPhase(5),"ActivateMenu:Rules",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPRULESINFO")); } // Observer menu in free viewport if (!pPlr) { - AddRefSym(LoadResStr("IDS_TEXT_VIEW"),C4GUI::Icon::GetIconFacet(C4GUI::Ico_View),"ActivateMenu:Observer",C4MN_Item_NoCount,NULL,LoadResStr("IDS_TEXT_DETERMINEPLAYERVIEWTOFOLL")); + AddRefSym(LoadResStr("IDS_TEXT_VIEW"),C4GUI::Icon::GetIconFacet(C4GUI::Ico_View),"ActivateMenu:Observer",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_TEXT_DETERMINEPLAYERVIEWTOFOLL")); } // Hostility (player menu only) if (pPlr && (::Players.GetCount() > 1)) { GfxR->fctFlagClr.Surface->SetClr(0xff0000); - AddRefSym(LoadResStr("IDS_MENU_CPATTACK"),GfxR->fctMenu.GetPhase(7),"ActivateMenu:Hostility",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MENU_CPATTACKINFO")); + AddRefSym(LoadResStr("IDS_MENU_CPATTACK"),GfxR->fctMenu.GetPhase(7),"ActivateMenu:Hostility",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPATTACKINFO")); } // Team change if (pPlr && Game.Teams.IsTeamSwitchAllowed()) { C4Facet fctTeams; fctTeams = C4GUI::Icon::GetIconFacet(C4GUI::Ico_Team); - AddRefSym(LoadResStr("IDS_MSG_SELTEAM"),fctTeams,"ActivateMenu:TeamSel",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MSG_ALLOWSYOUTOJOINADIFFERENT")); + AddRefSym(LoadResStr("IDS_MSG_SELTEAM"),fctTeams,"ActivateMenu:TeamSel",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MSG_ALLOWSYOUTOJOINADIFFERENT")); } // Player join if ((::Players.GetCount() < Game.Parameters.MaxPlayers) && !Game.Parameters.isLeague()) { - AddRefSym(LoadResStr("IDS_MENU_CPNEWPLAYER"),GfxR->fctPlayerClr.GetPhase(),"ActivateMenu:NewPlayer",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MENU_CPNEWPLAYERINFO")); + AddRefSym(LoadResStr("IDS_MENU_CPNEWPLAYER"),GfxR->fctPlayerClr.GetPhase(),"ActivateMenu:NewPlayer",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPNEWPLAYERINFO")); } // Save game (player menu only - should we allow saving games with no players in it?) if (pPlr && (!::Network.isEnabled() || ::Network.isHost())) { - AddRefSym(LoadResStr("IDS_MENU_CPSAVEGAME"),GfxR->fctMenu.GetPhase(0),"ActivateMenu:Save:Game",C4MN_Item_NoCount,NULL,LoadResStr("IDS_MENU_CPSAVEGAMEINFO")); + AddRefSym(LoadResStr("IDS_MENU_CPSAVEGAME"),GfxR->fctMenu.GetPhase(0),"ActivateMenu:Save:Game",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPSAVEGAMEINFO")); } // Options - AddRefSym(LoadResStr("IDS_MNU_OPTIONS"), GfxR->fctOptions.GetPhase(0), "ActivateMenu:Options",C4MN_Item_NoCount, NULL, LoadResStr("IDS_MNU_OPTIONSINFO")); + AddRefSym(LoadResStr("IDS_MNU_OPTIONS"), GfxR->fctOptions.GetPhase(0), "ActivateMenu:Options",C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MNU_OPTIONSINFO")); // Disconnect if (::Network.isEnabled()) { // Host - if (::Network.isHost() && Game.Clients.getClient(NULL)) - AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Host", C4MN_Item_NoCount, NULL, LoadResStr("IDS_TEXT_KICKCERTAINCLIENTSFROMTHE")); + if (::Network.isHost() && Game.Clients.getClient(nullptr)) + AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Host", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_TEXT_KICKCERTAINCLIENTSFROMTHE")); // Client if (!::Network.isHost()) - AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Client", C4MN_Item_NoCount, NULL, LoadResStr("IDS_TEXT_DISCONNECTTHEGAMEFROMTHES")); + AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Client", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_TEXT_DISCONNECTTHEGAMEFROMTHES")); } // Surrender (player menu only) if (pPlr) - AddRefSym(LoadResStr("IDS_MENU_CPSURRENDER"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Surrender), "ActivateMenu:Surrender", C4MN_Item_NoCount, NULL, LoadResStr("IDS_MENU_CPSURRENDERINFO")); + AddRefSym(LoadResStr("IDS_MENU_CPSURRENDER"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Surrender), "ActivateMenu:Surrender", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_CPSURRENDERINFO")); // Abort if (!Application.isEditor) - AddRefSym(LoadResStr("IDS_MENU_ABORT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Exit), "Abort", C4MN_Item_NoCount, NULL, LoadResStr("IDS_MENU_ABORT_DESC")); + AddRefSym(LoadResStr("IDS_MENU_ABORT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Exit), "Abort", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_ABORT_DESC")); // No empty menus if (GetItemCount()==0) Close(false); // Done diff --git a/src/gui/C4Menu.cpp b/src/gui/C4Menu.cpp index 0628f89d2..a901cebfd 100644 --- a/src/gui/C4Menu.cpp +++ b/src/gui/C4Menu.cpp @@ -49,7 +49,7 @@ const int32_t C4MN_InfoCaption_Delay = 90; C4MenuItem::C4MenuItem(C4Menu *pMenu, int32_t iIndex, const char *szCaption, const char *szCommand, int32_t iCount, C4Object *pObject, const char *szInfoCaption, C4ID idID, const char *szCommand2, bool fOwnValue, int32_t iValue, int32_t iStyle, bool fIsSelectable) - : C4GUI::Element(), Count(iCount), id(idID), Object(pObject), pSymbolObj(NULL), pSymbolGraphics(NULL), dwSymbolClr(0u), + : C4GUI::Element(), Count(iCount), id(idID), Object(pObject), pSymbolObj(nullptr), pSymbolGraphics(nullptr), dwSymbolClr(0u), fOwnValue(fOwnValue), iValue(iValue), fSelected(false), iStyle(iStyle), pMenu(pMenu), iIndex(iIndex), IsSelectable(fIsSelectable), TextDisplayProgress(-1) { @@ -146,11 +146,11 @@ void C4MenuItem::DrawElement(C4TargetFacet &cgo) // Draw if there is no text progression at all (TextDisplayProgress==-1, or if it's progressed far enough already (TextDisplayProgress>0) if(pSymbolObj && TextDisplayProgress) { - pSymbolObj->DrawPicture(cgoSymbolOut, false, NULL); + pSymbolObj->DrawPicture(cgoSymbolOut, false, nullptr); } else if (pSymbolGraphics && TextDisplayProgress) { - pSymbolGraphics->Draw(cgoSymbolOut, dwSymbolClr ? dwSymbolClr : 0xffffffff, NULL, 0, 0, NULL); + pSymbolGraphics->Draw(cgoSymbolOut, dwSymbolClr ? dwSymbolClr : 0xffffffff, nullptr, 0, 0, nullptr); } else if (Symbol.Surface && TextDisplayProgress) Symbol.DrawClr(cgoItemSymbol, true, dwSymbolClr); @@ -235,7 +235,7 @@ void C4MenuItem::MouseEnter(C4GUI::CMouse &rMouse) // ----------------------------------------------------------- // C4Menu -C4Menu::C4Menu() : C4GUI::Dialog(100, 100, NULL, true) // will be re-adjusted later +C4Menu::C4Menu() : C4GUI::Dialog(100, 100, nullptr, true) // will be re-adjusted later { Default(); AddElement(pClientWindow = new C4GUI::ScrollWindow(this)); @@ -825,7 +825,7 @@ void C4Menu::DrawElement(C4TargetFacet &cgo) if (pItem && pItem->fOwnValue) iValue = pItem->iValue; else - iValue = pDef->GetValue(NULL, NO_OWNER); + iValue = pDef->GetValue(nullptr, NO_OWNER); } // Store and clear global clipper @@ -1000,7 +1000,7 @@ C4Viewport *C4Menu::GetViewport() if (pVP->IsViewportMenu(this)) return pVP; // none matching - return NULL; + return nullptr; } void C4Menu::UpdateElementPositions() @@ -1012,7 +1012,7 @@ void C4Menu::UpdateElementPositions() pClientWindow->SetBounds(GetContainedClientRect()); // re-stack all list items int xOff, yOff = 0; - C4MenuItem *pCurr = static_cast(pClientWindow->GetFirst()), *pPrev = NULL; + C4MenuItem *pCurr = static_cast(pClientWindow->GetFirst()), *pPrev = nullptr; if (HasPortrait() && pCurr) { // recheck portrait @@ -1071,7 +1071,7 @@ void C4Menu::UpdateElementPositions() // following item larger height: Need to re-stack from beginning iMaxDlgOptionHeight = rcNewBounds.Hgt; pNext = pFirstStack; - pPrev = NULL; + pPrev = nullptr; yOff = 0; iIndex = 0; continue; diff --git a/src/gui/C4Menu.h b/src/gui/C4Menu.h index 2b2c9a5a1..53ff84fc5 100644 --- a/src/gui/C4Menu.h +++ b/src/gui/C4Menu.h @@ -112,7 +112,7 @@ public: C4Object *GetObject() const { return Object; } const char *GetCommand() const { return Command; } - void ClearPointers(C4Object* pObj) { if(pObj == Object) Object = NULL; if(pObj == pSymbolObj) pSymbolObj = NULL; } + void ClearPointers(C4Object* pObj) { if(pObj == Object) Object = nullptr; if(pObj == pSymbolObj) pSymbolObj = nullptr; } // GUI calls virtual void MouseInput(class C4GUI::CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam); // input: mouse movement or buttons @@ -166,7 +166,7 @@ public: int32_t GetItemHeight() { return ItemHeight; } C4MenuItem* GetSelectedItem(); C4MenuItem* GetItem(int32_t iIndex); - virtual C4Object *GetParentObject() { return NULL; } + virtual C4Object *GetParentObject() { return nullptr; } bool MoveSelection(int32_t iBy, bool fAdjustPosition, bool fDoCalls); bool SetSelection(int32_t iSelection, bool fAdjustPosition, bool fDoCalls); bool SetPosition(int32_t iPosition); @@ -176,21 +176,21 @@ public: bool Control(BYTE byCom, int32_t iData); bool KeyControl(BYTE byCom); // direct keyboard callback bool AddRefSym(const char *szCaption, const C4Facet &fctSymbol, const char *szCommand, - int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=NULL, - const char *szInfoCaption=NULL, - C4ID idID=C4ID::None, const char *szCommand2=NULL, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true); + int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, + const char *szInfoCaption=nullptr, + C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true); bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, - int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=NULL, - const char *szInfoCaption=NULL, - C4ID idID=C4ID::None, const char *szCommand2=NULL, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true); + int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, + const char *szInfoCaption=nullptr, + C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true); bool Add(const char *szCaption, C4Object* pGfxObj, const char *szCommand, - int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=NULL, - const char *szInfoCaption=NULL, - C4ID idID=C4ID::None, const char *szCommand2=NULL, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true); + int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, + const char *szInfoCaption=nullptr, + C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true); bool Add(const char *szCaption, C4DefGraphics* pGfx, const char *szCommand, - int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=NULL, - const char *szInfoCaption=NULL, - C4ID idID=C4ID::None, const char *szCommand2=NULL, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true); + int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, + const char *szInfoCaption=nullptr, + C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true); void ClearItems(); void ResetLocation() { LocationSet = false; } bool SetLocation(int32_t iX, int32_t iY); // set location relative to user viewport diff --git a/src/gui/C4MessageBoard.cpp b/src/gui/C4MessageBoard.cpp index 1507da0d2..71f7aac1e 100644 --- a/src/gui/C4MessageBoard.cpp +++ b/src/gui/C4MessageBoard.cpp @@ -85,7 +85,7 @@ void C4MessageBoard::Execute() if (Delay == -1) { // set delay based on msg length - const char *szCurrMsg = LogBuffer.GetLine(std::min(-iBackScroll, -1), NULL, NULL, NULL); + const char *szCurrMsg = LogBuffer.GetLine(std::min(-iBackScroll, -1), nullptr, nullptr, nullptr); if (szCurrMsg) Delay = strlen(szCurrMsg); else Delay = 0; } // wait... @@ -159,7 +159,7 @@ void C4MessageBoard::Draw(C4Facet &cgo) { // get message at pos if (iMsg-iBackScroll >= 0) break; - const char *Message = LogBuffer.GetLine(iMsg-iBackScroll, NULL, NULL, NULL); + const char *Message = LogBuffer.GetLine(iMsg-iBackScroll, nullptr, nullptr, nullptr); if (!Message || !*Message) continue; // calc target position (y) int iMsgY = cgo.Y + cgo.Hgt + iMsg * iLineHgt + Fader; @@ -202,7 +202,7 @@ void C4MessageBoard::AddLog(const char *szMessage) // make sure new message will be drawn ++iBackScroll; // register message in standard messageboard font - LogBuffer.AppendLines(szMessage, &::GraphicsResource.FontRegular, 0, NULL); + LogBuffer.AppendLines(szMessage, &::GraphicsResource.FontRegular, 0, nullptr); } void C4MessageBoard::ClearLog() @@ -240,7 +240,7 @@ C4Player* C4MessageBoard::GetMessagePlayer(const char *szMessage) str.CopyUntil(szMessage + 2,':'); return ::Players.GetByName(str.getData()); } - return NULL; + return nullptr; } bool C4MessageBoard::ControlScrollUp() diff --git a/src/gui/C4MessageInput.cpp b/src/gui/C4MessageInput.cpp index daa61372a..84e5263b9 100644 --- a/src/gui/C4MessageInput.cpp +++ b/src/gui/C4MessageInput.cpp @@ -35,7 +35,7 @@ // C4ChatInputDialog // singleton -C4ChatInputDialog *C4ChatInputDialog::pInstance = NULL; +C4ChatInputDialog *C4ChatInputDialog::pInstance = nullptr; // helper func: Determine whether input text is good for a chat-style-layout dialog bool IsSmallInputQuery(const char *szInputQuery) @@ -49,7 +49,7 @@ bool IsSmallInputQuery(const char *szInputQuery) } C4ChatInputDialog::C4ChatInputDialog(bool fObjInput, C4Object *pScriptTarget, bool fUppercase, bool fTeam, int32_t iPlr, const StdStrBuf &rsInputQuery) - : C4GUI::InputDialog(fObjInput ? rsInputQuery.getData() : LoadResStrNoAmp("IDS_CTL_CHAT"), NULL, C4GUI::Ico_None, NULL, !fObjInput || IsSmallInputQuery(rsInputQuery.getData())), + : C4GUI::InputDialog(fObjInput ? rsInputQuery.getData() : LoadResStrNoAmp("IDS_CTL_CHAT"), nullptr, C4GUI::Ico_None, nullptr, !fObjInput || IsSmallInputQuery(rsInputQuery.getData())), fObjInput(fObjInput), fUppercase(fUppercase), pTarget(pScriptTarget), iPlr(iPlr), BackIndex(-1), fProcessed(false) { // singleton-var @@ -79,7 +79,7 @@ C4ChatInputDialog::~C4ChatInputDialog() delete pKeyPlrControl; delete pKeyGamepadControl; delete pKeyBackClose; - if (this==pInstance) pInstance=NULL; + if (this==pInstance) pInstance=nullptr; } void C4ChatInputDialog::OnChatCancel() @@ -169,7 +169,7 @@ bool C4ChatInputDialog::KeyHistoryUpDown(bool fUp) bool C4ChatInputDialog::KeyPlrControl(const C4KeyCodeEx &key) { // Control pressed while doing this key: Reroute this key as a player-control - Game.DoKeyboardInput(WORD(key.Key), KEYEV_Down, !!(key.dwShift & KEYS_Alt), false, !!(key.dwShift & KEYS_Shift), key.IsRepeated(), NULL, true); + Game.DoKeyboardInput(WORD(key.Key), KEYEV_Down, !!(key.dwShift & KEYS_Alt), false, !!(key.dwShift & KEYS_Shift), key.IsRepeated(), nullptr, true); // mark as processed, so it won't get any double processing return true; } @@ -179,7 +179,7 @@ bool C4ChatInputDialog::KeyGamepadControlDown(const C4KeyCodeEx &key) // filter gamepad control if (!Key_IsGamepad(key.Key)) return false; // forward it - Game.DoKeyboardInput(key.Key, KEYEV_Down, false, false, false, key.IsRepeated(), NULL, true); + Game.DoKeyboardInput(key.Key, KEYEV_Down, false, false, false, key.IsRepeated(), nullptr, true); return true; } @@ -188,7 +188,7 @@ bool C4ChatInputDialog::KeyGamepadControlUp(const C4KeyCodeEx &key) // filter gamepad control if (!Key_IsGamepad(key.Key)) return false; // forward it - Game.DoKeyboardInput(key.Key, KEYEV_Up, false, false, false, key.IsRepeated(), NULL, true); + Game.DoKeyboardInput(key.Key, KEYEV_Up, false, false, false, key.IsRepeated(), nullptr, true); return true; } @@ -197,7 +197,7 @@ bool C4ChatInputDialog::KeyGamepadControlPressed(const C4KeyCodeEx &key) // filter gamepad control if (!Key_IsGamepad(key.Key)) return false; // forward it - Game.DoKeyboardInput(key.Key, KEYEV_Pressed, false, false, false, key.IsRepeated(), NULL, true); + Game.DoKeyboardInput(key.Key, KEYEV_Pressed, false, false, false, key.IsRepeated(), nullptr, true); return true; } @@ -287,7 +287,7 @@ bool C4MessageInput::KeyStartTypeIn(bool fTeam) // fullscreen only if (Application.isEditor) return false; // OK, start typing - return StartTypeIn(false, NULL, false, fTeam); + return StartTypeIn(false, nullptr, false, fTeam); } bool C4MessageInput::ToggleTypeIn() @@ -315,7 +315,7 @@ bool C4MessageInput::ProcessInput(const char *szText) // helper variables char OSTR[402]; // cba C4ControlMessageType eMsgType; - const char *szMsg = NULL; + const char *szMsg = nullptr; int32_t iToPlayer = -1; // Starts with '^', "team:" or "/team ": Team message @@ -415,7 +415,7 @@ bool C4MessageInput::ProcessInput(const char *szText) SCopy(szMsg, szMessage, std::min(C4MaxMessage, szEnd - szMsg + 1)); } // get sending player (if any) - C4Player *pPlr = Game.IsRunning ? ::Players.GetLocalByIndex(0) : NULL; + C4Player *pPlr = Game.IsRunning ? ::Players.GetLocalByIndex(0) : nullptr; // send ::Control.DoInput(CID_Message, new C4ControlMessage(eMsgType, szMessage, pPlr ? pPlr->Number : -1, iToPlayer), @@ -460,7 +460,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand) { // get player name from input text int iSepPos = SCharPos(' ', pCmdPar, 0); - C4PlayerInfo *pNfo=NULL; + C4PlayerInfo *pNfo=nullptr; int32_t idLocalClient = -1; if (::Network.Clients.GetLocal()) idLocalClient = ::Network.Clients.GetLocal()->getID(); if (iSepPos>0) @@ -478,7 +478,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand) else // no player name: Set local player pNfo = Game.PlayerInfos.GetPrimaryInfoByClientID(idLocalClient); - C4ClientPlayerInfos *pCltNfo=NULL; + C4ClientPlayerInfos *pCltNfo=nullptr; if (pNfo) pCltNfo = Game.PlayerInfos.GetClientInfoByPlayerID(pNfo->GetID()); if (!pCltNfo) { @@ -626,7 +626,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand) if (SEqual2(pCmdPar, "password ") || SEqual(pCmdPar, "password")) { if (!::Network.isEnabled() || !::Network.isHost()) return false; - ::Network.SetPassword(pCmdPar[8] ? (pCmdPar+9) : NULL); + ::Network.SetPassword(pCmdPar[8] ? (pCmdPar+9) : nullptr); if (pLobby) pLobby->UpdatePassword(); return true; } @@ -733,7 +733,7 @@ bool C4MessageInput::ProcessCommand(const char *szCommand) return false; } // what to do? - C4ControlClientUpdate *pCtrl = NULL; + C4ControlClientUpdate *pCtrl = nullptr; if (szCmdName[0] == 'a') // activate pCtrl = new C4ControlClientUpdate(pClient->getID(), CUT_Activate, true); else if (szCmdName[0] == 'd' && !Game.Parameters.isLeague()) // deactivate @@ -848,7 +848,7 @@ C4MessageBoardCommand *C4MessageInput::GetCommand(const char *strName) for (C4MessageBoardCommand *pCmd = pCommands; pCmd; pCmd = pCmd->Next) if (SEqual(pCmd->Name, strName)) return pCmd; - return NULL; + return nullptr; } void C4MessageInput::ClearPointers(C4Object *pObj) @@ -881,13 +881,13 @@ void C4MessageInput::StoreBackBuffer(const char *szMessage) const char *C4MessageInput::GetBackBuffer(int32_t iIndex) { - if (!Inside(iIndex, 0, C4MSGB_BackBufferMax-1)) return NULL; + if (!Inside(iIndex, 0, C4MSGB_BackBufferMax-1)) return nullptr; return BackBuffer[iIndex]; } C4MessageBoardCommand::C4MessageBoardCommand() { - Name[0] = '\0'; Script[0] = '\0'; Next = NULL; + Name[0] = '\0'; Script[0] = '\0'; Next = nullptr; } void C4MessageBoardQuery::CompileFunc(StdCompiler *pComp) diff --git a/src/gui/C4MessageInput.h b/src/gui/C4MessageInput.h index 51697db45..b5c23cd46 100644 --- a/src/gui/C4MessageInput.h +++ b/src/gui/C4MessageInput.h @@ -106,7 +106,7 @@ public: class C4MessageInput { public: - C4MessageInput() : pCommands(NULL) { Default(); } + C4MessageInput() : pCommands(nullptr) { Default(); } ~C4MessageInput() { Clear(); } void Default(); void Clear(); @@ -126,7 +126,7 @@ public: // Input public: bool CloseTypeIn(); - bool StartTypeIn(bool fObjInput = false, C4Object *pObj = NULL, bool fUpperCase = false, bool fTeam = false, int32_t iPlr = -1, const StdStrBuf &rsInputQuery = StdStrBuf()); + bool StartTypeIn(bool fObjInput = false, C4Object *pObj = nullptr, bool fUpperCase = false, bool fTeam = false, int32_t iPlr = -1, const StdStrBuf &rsInputQuery = StdStrBuf()); bool KeyStartTypeIn(bool fTeam); bool ToggleTypeIn(); bool IsTypeIn(); @@ -159,12 +159,12 @@ public: // ctors C4MessageBoardQuery(C4Object *pCallbackObj, const StdStrBuf &rsInputQuery, bool fIsUppercase) - : CallbackObj(pCallbackObj), fAnswered(false), fIsUppercase(fIsUppercase), pNext(NULL) + : CallbackObj(pCallbackObj), fAnswered(false), fIsUppercase(fIsUppercase), pNext(nullptr) { sInputQuery.Copy(rsInputQuery); } - C4MessageBoardQuery() : CallbackObj(NULL), fAnswered(false), fIsUppercase(false), pNext(NULL) {} + C4MessageBoardQuery() : CallbackObj(nullptr), fAnswered(false), fIsUppercase(false), pNext(nullptr) {} // use default copy ctor diff --git a/src/gui/C4MouseControl.cpp b/src/gui/C4MouseControl.cpp index d5ab35175..03f407bdf 100644 --- a/src/gui/C4MouseControl.cpp +++ b/src/gui/C4MouseControl.cpp @@ -57,8 +57,8 @@ void C4MouseControl::Default() { Active=false; Player=NO_OWNER; - pPlayer=NULL; - Viewport=NULL; + pPlayer=nullptr; + Viewport=nullptr; Cursor=0; Caption.Clear(); CaptionBottomY=0; @@ -73,18 +73,18 @@ void C4MouseControl::Default() InitCentered=false; FogOfWar=false; DragID=C4ID::None; - DragObject=NULL; + DragObject=nullptr; KeepCaption=0; Drag=C4MC_Drag_None; Selection.Default(); - TargetObject=DownTarget=NULL; + TargetObject=DownTarget=nullptr; ControlDown=false; ShiftDown=false; AltDown=false; Scrolling=false; ScrollSpeed=10; - DragImageDef=NULL; - DragImageObject=NULL; + DragImageDef=nullptr; + DragImageObject=nullptr; fMouseOwned = true; // default mouse owned fctViewport.Default(); } @@ -124,14 +124,14 @@ bool C4MouseControl::Init(int32_t iPlayer) void C4MouseControl::ClearPointers(C4Object *pObj) { - if (TargetObject==pObj) TargetObject=NULL; - if (DownTarget==pObj) DownTarget=NULL; + if (TargetObject==pObj) TargetObject=nullptr; + if (DownTarget==pObj) DownTarget=nullptr; if (DragObject==pObj) { - DragObject=NULL; + DragObject=nullptr; Drag=C4MC_Drag_None; - DragImageDef=NULL; - DragImageObject=NULL; + DragImageDef=nullptr; + DragImageObject=nullptr; } Selection.ClearPointers(pObj); } @@ -151,10 +151,10 @@ void C4MouseControl::UpdateClip() // fullscreen only if (Application.isEditor) return; // application or mouse control not active? remove any clips - if (!Active || !Application.Active || ::pGUI->HasMouseFocus()) { ClipCursor(NULL); return; } + if (!Active || !Application.Active || ::pGUI->HasMouseFocus()) { ClipCursor(nullptr); return; } // get controlled viewport C4Viewport *pVP=::Viewports.GetViewport(Player); - if (!pVP) { ClipCursor(NULL); return; } + if (!pVP) { ClipCursor(nullptr); return; } // adjust size by viewport size RECT vpRct; vpRct.left=pVP->OutX; vpRct.top=pVP->OutY; vpRct.right=pVP->OutX+pVP->ViewWdt; vpRct.bottom=pVP->OutY+pVP->ViewHgt; @@ -189,12 +189,12 @@ void C4MouseControl::Move(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyFl if (!pPlayer) { Active=false; return; } } else - pPlayer = NULL; + pPlayer = nullptr; // Check viewport if (!(Viewport=::Viewports.GetViewport(Player))) return; // get view position C4Rect rcViewport = Viewport->GetOutputRect(); - fctViewport.Set(NULL, rcViewport.x, rcViewport.y, rcViewport.Wdt, rcViewport.Hgt); + fctViewport.Set(nullptr, rcViewport.x, rcViewport.y, rcViewport.Wdt, rcViewport.Hgt); ViewX=Viewport->GetViewX(); ViewY=Viewport->GetViewY(); fctViewportGame = Viewport->last_game_draw_cgo; fctViewportGUI = Viewport->last_gui_draw_cgo; @@ -435,7 +435,7 @@ void C4MouseControl::Draw(C4TargetFacet &cgo, const ZoomData &GameZoom) DragImageObject->ColorMod = (Drag == C4MC_Drag_Script) ? 0x7fffffff : (/*DragImagePhase*/0 ? 0x8f7f0000 : 0x1f007f00); DragImageObject->BlitMode = C4GFXBLIT_MOD2; - DragImageObject->DrawPicture(ccgo, false, NULL); + DragImageObject->DrawPicture(ccgo, false, nullptr); DragImageObject->ColorMod = ColorMod; DragImageObject->BlitMode = BlitMode; @@ -447,7 +447,7 @@ void C4MouseControl::Draw(C4TargetFacet &cgo, const ZoomData &GameZoom) // draw DragImage in red or green, according to the phase to be used pDraw->ActivateBlitModulation((Drag == C4MC_Drag_Script) ? 0x7fffffff : (/*DragImagePhase*/0 ? 0x8f7f0000 : 0x1f007f00)); - DragImageDef->Draw(ccgo, false, pPlayer ? pPlayer->ColorDw : 0xff0000ff, NULL, 0, 0, NULL); + DragImageDef->Draw(ccgo, false, pPlayer ? pPlayer->ColorDw : 0xff0000ff, nullptr, 0, 0, nullptr); // reset color pDraw->DeactivateBlitModulation(); @@ -485,13 +485,13 @@ void C4MouseControl::UpdateCursorTarget() if (Scrolling) { // Scrolling: no other target - TargetObject=NULL; + TargetObject=nullptr; } else { // Target object TargetObject=GetTargetObject(); - if (TargetObject && FogOfWar && !(TargetObject->Category & C4D_IgnoreFoW)) TargetObject = NULL; + if (TargetObject && FogOfWar && !(TargetObject->Category & C4D_IgnoreFoW)) TargetObject = nullptr; // Movement if (!FogOfWar && !IsPassive()) Cursor=C4MC_Cursor_Crosshair; @@ -513,7 +513,7 @@ void C4MouseControl::UpdateCursorTarget() if ( (TargetObject->Category & C4D_MouseSelect) && CanSelect) Cursor=C4MC_Cursor_Select; else - TargetObject = NULL; + TargetObject = nullptr; } // passive cursor @@ -638,7 +638,7 @@ void C4MouseControl::LeftUp() } // Update status flag LeftButtonDown=false; - if(!RightButtonDown) DownTarget = NULL; + if(!RightButtonDown) DownTarget = nullptr; } void C4MouseControl::DragNone() @@ -719,7 +719,7 @@ void C4MouseControl::RightUp() } // Update status flag RightButtonDown=false; - if(!LeftButtonDown) DownTarget = NULL; + if(!LeftButtonDown) DownTarget = nullptr; } void C4MouseControl::Wheel(DWORD dwFlags) @@ -763,15 +763,15 @@ void C4MouseControl::ButtonUpDragScript() // Finish drag Drag=C4MC_Drag_None; DragID=C4ID::None; - DragImageObject = NULL; - DragImageDef = NULL; + DragImageObject = nullptr; + DragImageDef = nullptr; C4Object *DragObject = this->DragObject; - this->DragObject = NULL; + this->DragObject = nullptr; C4Object *DropObject = TargetObject; // drag object must exist; drop object is optional if (!DragObject) return; if (DropObject && (~DropObject->GetPropertyInt(P_MouseDrag) & C4MC_MD_DropTarget)) - DropObject = NULL; + DropObject = nullptr; // no commands if player is eliminated or doesn't exist any more C4Player *pPlr = ::Players.Get(Player); if (!pPlr || pPlr->Eliminated) return; @@ -846,7 +846,7 @@ C4Object *C4MouseControl::GetTargetObject() // find object // gui object position currently wrong...will fall apart once GUIZoom is activated C4Object *pObj = Game.FindVisObject(ViewX, ViewY, Player, fctViewportGame, fctViewportGUI, GameX,GameY, C4D_MouseSelect, GuiX-fctViewportGUI.X, GuiY-fctViewportGUI.Y); - if (!pObj) return NULL; + if (!pObj) return nullptr; return pObj; } diff --git a/src/gui/C4PlayerInfoListBox.cpp b/src/gui/C4PlayerInfoListBox.cpp index e683417b9..35e4da945 100644 --- a/src/gui/C4PlayerInfoListBox.cpp +++ b/src/gui/C4PlayerInfoListBox.cpp @@ -71,8 +71,8 @@ void C4PlayerInfoListBox::ListItem::DrawElement(C4TargetFacet &cgo) C4PlayerInfoListBox::PlayerListItem::PlayerListItem(C4PlayerInfoListBox *pForListBox, int32_t idClient, int32_t idPlayer, bool fSavegamePlayer, C4GUI::Element *pInsertBeforeElement) - : ListItem(pForListBox), pScoreLabel(NULL), pTimeLabel(NULL), pExtraLabel(NULL), - pRankIcon(NULL), pTeamCombo(NULL), pTeamPic(NULL), fIconSet(false), fJoinedInfoSet(false), + : ListItem(pForListBox), pScoreLabel(nullptr), pTimeLabel(nullptr), pExtraLabel(nullptr), + pRankIcon(nullptr), pTeamCombo(nullptr), pTeamPic(nullptr), fIconSet(false), fJoinedInfoSet(false), dwJoinClr(0), dwPlrClr(0), idClient(idClient), idPlayer(idPlayer), fFreeSavegamePlayer(fSavegamePlayer) { bool fIsEvaluation = pForListBox->IsEvaluation(), fIsLobby = pForListBox->IsLobby(); @@ -115,7 +115,7 @@ C4PlayerInfoListBox::PlayerListItem::PlayerListItem(C4PlayerInfoListBox *pForLis if (pTeam && pTeam->GetIconSpec() && *pTeam->GetIconSpec()) { pTeamPic = new C4GUI::Picture(C4Rect(iHeight + IconLabelSpacing, 0, iHeight, iHeight), true); - Game.DrawTextSpecImage(pTeamPic->GetMFacet(), pTeam->GetIconSpec(), NULL, pTeam->GetColor()); + Game.DrawTextSpecImage(pTeamPic->GetMFacet(), pTeam->GetIconSpec(), nullptr, pTeam->GetColor()); pTeamPic->SetDrawColor(pTeam->GetColor()); } } @@ -249,11 +249,11 @@ void C4PlayerInfoListBox::PlayerListItem::UpdateIcon(C4PlayerInfo *pInfo, C4Play { // check whether icon is known bool fResPresent = false; - C4Network2Res *pRes = NULL; + C4Network2Res *pRes = nullptr; if (pInfo) if ((pRes = pInfo->GetRes())) fResPresent = pRes->isComplete(); - C4RoundResultsPlayer *pEvaluationPlayer = NULL; + C4RoundResultsPlayer *pEvaluationPlayer = nullptr; if (pList->IsEvaluation()) pEvaluationPlayer = Game.RoundResults.GetPlayers().GetByID(idPlayer); bool fHasIcon = fResPresent || pEvaluationPlayer || (!::Network.isEnabled() && pInfo); // check whether joined info is present @@ -331,7 +331,7 @@ void C4PlayerInfoListBox::PlayerListItem::UpdateTeam() void C4PlayerInfoListBox::PlayerListItem::UpdateScoreLabel(C4PlayerInfo *pInfo) { assert(pInfo); - C4RoundResultsPlayer *pRoundResultsPlr = NULL; + C4RoundResultsPlayer *pRoundResultsPlr = nullptr; if (pList->IsEvaluation()) pRoundResultsPlr = Game.RoundResults.GetPlayers().GetByID(idPlayer); if (pInfo->getLeagueScore() || pInfo->IsLeagueProjectedGainValid() || pRoundResultsPlr) @@ -421,7 +421,7 @@ void C4PlayerInfoListBox::PlayerListItem::UpdateScoreLabel(C4PlayerInfo *pInfo) { // score label invisible delete pScoreLabel; - pScoreLabel = NULL; + pScoreLabel = nullptr; } if (pRankIcon) { @@ -480,7 +480,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::PlayerListItem::OnContext(C4GUI::Elemen C4PlayerInfo *pInfo = GetPlayerInfo(); assert(pInfo); // no context menu for evaluation - if (!GetLobby()) return NULL; + if (!GetLobby()) return nullptr; // create context menu C4GUI::ContextMenu *pMenu = new C4GUI::ContextMenu(); // if this is a free player, add an option to take it over @@ -489,7 +489,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::PlayerListItem::OnContext(C4GUI::Elemen if (pInfo->GetType() != C4PT_Script) { StdCopyStrBuf strTakeOver(LoadResStr("IDS_MSG_TAKEOVERPLR")); - pMenu->AddItem(strTakeOver.getData(), LoadResStr("IDS_MSG_TAKEOVERPLR_DESC"), C4GUI::Ico_Player, NULL, + pMenu->AddItem(strTakeOver.getData(), LoadResStr("IDS_MSG_TAKEOVERPLR_DESC"), C4GUI::Ico_Player, nullptr, new C4GUI::CBContextHandler(this, &PlayerListItem::OnContextTakeOver)); } } @@ -503,7 +503,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::PlayerListItem::OnContext(C4GUI::Elemen { StdCopyStrBuf strRemove(LoadResStr("IDS_MSG_REMOVEPLR")); pMenu->AddItem(strRemove.getData(), LoadResStr("IDS_MSG_REMOVEPLR_DESC"), C4GUI::Ico_Close, - new C4GUI::CBMenuHandler(this, &PlayerListItem::OnCtxRemove), NULL); + new C4GUI::CBMenuHandler(this, &PlayerListItem::OnCtxRemove), nullptr); } // color was changed: Add option to assign a new color C4PlayerInfo *pInfo = GetPlayerInfo(); @@ -512,7 +512,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::PlayerListItem::OnContext(C4GUI::Elemen { StdCopyStrBuf strNewColor(LoadResStr("IDS_MSG_NEWPLRCOLOR")); pMenu->AddItem(strNewColor.getData(), LoadResStr("IDS_MSG_NEWPLRCOLOR_DESC"), C4GUI::Ico_Player, - new C4GUI::CBMenuHandler(this, &PlayerListItem::OnCtxNewColor), NULL); + new C4GUI::CBMenuHandler(this, &PlayerListItem::OnCtxNewColor), nullptr); } } } @@ -672,7 +672,7 @@ C4PlayerInfo *C4PlayerInfoListBox::PlayerListItem::GetJoinedInfo() const { // safety C4PlayerInfo *pInfo = GetPlayerInfo(); - if (!pInfo) return NULL; + if (!pInfo) return nullptr; // is it a joined savegame player? if (fFreeSavegamePlayer) // then this is the joined player @@ -683,7 +683,7 @@ C4PlayerInfo *C4PlayerInfoListBox::PlayerListItem::GetJoinedInfo() const // then return the respective info from savegame recreation list return Game.RestorePlayerInfos.GetPlayerInfoByID(idSavegameInfo); // not joined - return NULL; + return nullptr; } bool C4PlayerInfoListBox::PlayerListItem::CanLocalChooseTeam() const @@ -724,9 +724,9 @@ C4PlayerInfoListBox::ClientListItem::ClientListItem(C4PlayerInfoListBox *pForLis int32_t iIconSize = ::GraphicsResource.TextFont.GetLineHeight(); // create subcomponents pStatusIcon = new C4GUI::Icon(C4Rect(0, 0, iIconSize, iIconSize), GetCurrentStatusIcon()); - pNameLabel = new C4GUI::Label(rClientInfo.getName(), iIconSize + IconLabelSpacing,0, ALeft, dwClientClr | C4GUI_MessageFontAlpha, NULL, true, false); - pPingLabel = NULL; - C4GUI::CallbackButton *btnAddPlayer = NULL; + pNameLabel = new C4GUI::Label(rClientInfo.getName(), iIconSize + IconLabelSpacing,0, ALeft, dwClientClr | C4GUI_MessageFontAlpha, nullptr, true, false); + pPingLabel = nullptr; + C4GUI::CallbackButton *btnAddPlayer = nullptr; if (IsLocalClientPlayer()) { // this computer: add player button @@ -763,7 +763,7 @@ void C4PlayerInfoListBox::ClientListItem::SetPing(int32_t iToPing) if (iToPing == -1) { // remove any ping label - if (pPingLabel) { delete pPingLabel; pPingLabel = NULL; } + if (pPingLabel) { delete pPingLabel; pPingLabel = nullptr; } return; } // get ping as text @@ -824,7 +824,7 @@ C4GUI::Icons C4PlayerInfoListBox::ClientListItem::GetCurrentStatusIcon() // sound icon? if (tLastSoundTime) { - time_t dt = time(NULL) - tLastSoundTime; + time_t dt = time(nullptr) - tLastSoundTime; if (dt >= SoundIconShowTime) { // stop showing sound icon @@ -887,7 +887,7 @@ void C4PlayerInfoListBox::ClientListItem::UpdatePing() void C4PlayerInfoListBox::ClientListItem::SetSoundIcon() { // remember time for reset - tLastSoundTime = time(NULL); + tLastSoundTime = time(nullptr); // force icon SetStatus(GetCurrentStatusIcon()); } @@ -895,7 +895,7 @@ void C4PlayerInfoListBox::ClientListItem::SetSoundIcon() C4GUI::ContextMenu *C4PlayerInfoListBox::ClientListItem::OnContext(C4GUI::Element *pListItem, int32_t iX, int32_t iY) { // safety - if (!::Network.isEnabled()) return NULL; + if (!::Network.isEnabled()) return nullptr; // get associated client C4Client *pClient = GetClient(); // create context menu @@ -920,7 +920,7 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::ClientListItem::OnContext(C4GUI::Elemen { StdCopyStrBuf strNewColor(LoadResStr(pClient->IsIgnored() ? "IDS_NET_CLIENT_UNIGNORE" : "IDS_NET_CLIENT_IGNORE")); pMenu->AddItem(strNewColor.getData(), FormatString(LoadResStr("IDS_NET_CLIENT_IGNORE_DESC"), pClient->getName()).getData(), - C4GUI::Ico_None, new C4GUI::CBMenuHandler(this, &ClientListItem::OnCtxIgnore), NULL); + C4GUI::Ico_None, new C4GUI::CBMenuHandler(this, &ClientListItem::OnCtxIgnore), nullptr); } // open it @@ -970,7 +970,7 @@ C4PlayerInfoListBox::TeamListItem::TeamListItem(C4PlayerInfoListBox *pForListBox bool fEvaluation = pList->IsEvaluation(); // get team data const char *szTeamName; - C4Team *pTeam = NULL; + C4Team *pTeam = nullptr; if (idTeam == TEAMID_Unknown) szTeamName = LoadResStr("IDS_MSG_RNDTEAM"); else @@ -1000,7 +1000,7 @@ C4PlayerInfoListBox::TeamListItem::TeamListItem(C4PlayerInfoListBox *pForListBox { C4FacetSurface fctSymbol; fctSymbol.Create(C4SymbolSize,C4SymbolSize); - Game.DrawTextSpecImage(fctSymbol, pTeam->GetIconSpec(), NULL, pTeam->GetColor()); + Game.DrawTextSpecImage(fctSymbol, pTeam->GetIconSpec(), nullptr, pTeam->GetColor()); pIcon->GetMFacet().GrabFrom(fctSymbol); } // calc own bounds @@ -1138,7 +1138,7 @@ C4PlayerInfoListBox::ScriptPlayersListItem::ScriptPlayersListItem(C4PlayerInfoLi // create subcomponents pIcon = new C4GUI::Icon(C4Rect(0, 0, iIconSize, iIconSize), C4GUI::Ico_Record); pNameLabel = new C4GUI::Label(LoadResStr("IDS_CTL_SCRIPTPLAYERS"), iIconSize + IconLabelSpacing,0, ALeft); - btnAddPlayer = NULL; + btnAddPlayer = nullptr; if (::Control.isCtrlHost()) { btnAddPlayer = new C4GUI::CallbackButton(C4GUI::Ico_AddPlr, C4Rect(0, 0, iIconSize, iIconSize), 'A' /* 2do TODO */, &ScriptPlayersListItem::OnBtnAddPlr, this); @@ -1186,7 +1186,7 @@ void C4PlayerInfoListBox::ScriptPlayersListItem::OnBtnAddPlr(C4GUI::Control *btn // request a script player join C4PlayerInfo *pScriptPlrInfo = new C4PlayerInfo(); pScriptPlrInfo->SetAsScriptPlayer(Game.Teams.GetScriptPlayerName().getData(), GenerateRandomPlayerColor(iCurrScriptPlrCount), 0, C4ID::None); - C4ClientPlayerInfos JoinPkt(NULL, true, pScriptPlrInfo); + C4ClientPlayerInfos JoinPkt(nullptr, true, pScriptPlrInfo); // add to queue! Game.PlayerInfos.DoPlayerInfoUpdate(&JoinPkt); } @@ -1224,7 +1224,7 @@ C4PlayerInfoListBox::ReplayPlayersListItem::ReplayPlayersListItem(C4PlayerInfoLi // ------------------- C4PlayerInfoListBox ------------------------ C4PlayerInfoListBox::C4PlayerInfoListBox(const C4Rect &rcBounds, Mode eMode, int32_t iTeamFilter) - : C4GUI::ListBox(rcBounds), eMode(eMode), iMaxUncollapsedPlayers(10), fIsCollapsed(false), iTeamFilter(iTeamFilter), dwTextColor(C4GUI_MessageFontClr), pCustomFont(NULL) + : C4GUI::ListBox(rcBounds), eMode(eMode), iMaxUncollapsedPlayers(10), fIsCollapsed(false), iTeamFilter(iTeamFilter), dwTextColor(C4GUI_MessageFontClr), pCustomFont(nullptr) { // update if client listbox selection changes SetSelectionChangeCallbackFn(new C4GUI::CallbackHandler(this, &C4PlayerInfoListBox::OnPlrListSelChange)); @@ -1254,7 +1254,7 @@ C4PlayerInfoListBox::ListItem *C4PlayerInfoListBox::GetPlayerListItem(ListItem:: if (pItem->idListItemID == idSearch) return pItem; } // nothing found - return NULL; + return nullptr; } bool C4PlayerInfoListBox::PlrListItemUpdate(ListItem::ID::IDType eType, int32_t id, class ListItem **pEnsurePos) @@ -1454,7 +1454,7 @@ void C4PlayerInfoListBox::UpdatePlayersByRandomTeam(ListItem **ppCurrInList) { // team sort but teams set to random and invisible: Show all players within one "Random Team"-label bool fTeamLabelPut = false; - C4Client *pClient = NULL; + C4Client *pClient = nullptr; while ((pClient = Game.Clients.getClient(pClient))) { // player infos for this client - not for deactivated, and never in replays @@ -1482,7 +1482,7 @@ void C4PlayerInfoListBox::UpdatePlayersByRandomTeam(ListItem **ppCurrInList) void C4PlayerInfoListBox::UpdatePlayersByClient(ListItem **ppCurrInList) { // regular players - C4Client *pClient = NULL; + C4Client *pClient = nullptr; while ((pClient = Game.Clients.getClient(pClient))) { // the client label @@ -1543,7 +1543,7 @@ void C4PlayerInfoListBox::UpdatePlayersByEvaluation(ListItem **ppCurrInList, boo UpdatePlayersByEvaluation(ppCurrInList, pTeam, eAddMode); } // Add teamless players of winning status - UpdatePlayersByEvaluation(ppCurrInList, NULL, eAddMode); + UpdatePlayersByEvaluation(ppCurrInList, nullptr, eAddMode); } } } diff --git a/src/gui/C4PlayerInfoListBox.h b/src/gui/C4PlayerInfoListBox.h index 4713ff272..c8e5da22c 100644 --- a/src/gui/C4PlayerInfoListBox.h +++ b/src/gui/C4PlayerInfoListBox.h @@ -100,7 +100,7 @@ private: C4GUI::Label *pTimeLabel; // evaluation only: label showing total playing time C4GUI::Label *pExtraLabel; // evaluation only: label showing extra data set by script C4GUI::Icon *pRankIcon; // league rank icon - C4GUI::ComboBox *pTeamCombo; // team selection combo - NULL for no-team-scens + C4GUI::ComboBox *pTeamCombo; // team selection combo - nullptr for no-team-scens C4GUI::Picture *pTeamPic; // evaluation only: Team icon spec bool fIconSet; // whether custom icon has been set @@ -155,7 +155,7 @@ private: // subcomponents C4GUI::Icon *pStatusIcon; // icon indicating client status (host, etc.) C4GUI::Label *pNameLabel; // label indicating client name - C4GUI::Label *pPingLabel; // label indicating ping to client - may be NULL + C4GUI::Label *pPingLabel; // label indicating ping to client - may be nullptr protected: int32_t idClient; // associated network interface ID @@ -189,7 +189,7 @@ private: C4Client *GetClient() const; // get client associated with this list item bool IsLocalClientPlayer() const; // whether this player is going to join locally C4GUI::Icons GetCurrentStatusIcon(); // get status icon that shows the current client state - class C4Network2Client *GetNetClient() const; // return assicuated network client; NULL for local + class C4Network2Client *GetNetClient() const; // return assicuated network client; nullptr for local bool IsLocal() const; virtual void Update() { UpdatePing(); UpdateInfo(); } diff --git a/src/gui/C4Scoreboard.cpp b/src/gui/C4Scoreboard.cpp index 960c9eacb..b6b015cd1 100644 --- a/src/gui/C4Scoreboard.cpp +++ b/src/gui/C4Scoreboard.cpp @@ -37,7 +37,7 @@ public: ~C4ScoreboardDlg(); protected: - void InvalidateRows() { delete [] piColWidths; piColWidths = NULL; } + void InvalidateRows() { delete [] piColWidths; piColWidths = nullptr; } void Update(); // update row widths and own size and caption virtual bool DoPlacement(C4GUI::Screen *pOnScreen, const C4Rect &rPreferredDlgRect); @@ -65,10 +65,10 @@ void C4Scoreboard::Clear() { // del all cells delete [] pEntries; - pEntries = NULL; iRows=iCols=0; + pEntries = nullptr; iRows=iCols=0; // del dialog iDlgShow = 0; - if (pDlg) { delete pDlg; pDlg = NULL; } + if (pDlg) { delete pDlg; pDlg = nullptr; } } void C4Scoreboard::AddRow(int32_t iInsertBefore) @@ -109,7 +109,7 @@ void C4Scoreboard::DelRow(int32_t iDelIndex) { // counts int32_t iNewEntryCount = (iRows-1) * iCols; - if (!iNewEntryCount) { --iRows; delete [] pEntries; pEntries = NULL; return; } + if (!iNewEntryCount) { --iRows; delete [] pEntries; pEntries = nullptr; return; } // realloc and copy array Entry *pNewEntries = new Entry[iNewEntryCount]; Entry *pCpy = pNewEntries; for (int32_t iRow = 0, iFromRow = 0; iRow < (iRows-1); ++iRow,++iFromRow) @@ -126,7 +126,7 @@ void C4Scoreboard::DelCol(int32_t iDelIndex) { // counts int32_t iNewEntryCount = iRows * (iCols-1); - if (!iNewEntryCount) { --iCols; delete [] pEntries; pEntries = NULL; return; } + if (!iNewEntryCount) { --iCols; delete [] pEntries; pEntries = nullptr; return; } // realloc and copy array Entry *pNewEntries = new Entry[iNewEntryCount]; Entry *pCpy = pNewEntries; for (int32_t iRow = 0; iRow < iRows; ++iRow) @@ -216,7 +216,7 @@ const char *C4Scoreboard::GetCellString(int32_t iColKey, int32_t iRowKey) // get row/col int32_t iCol = GetColByKey(iColKey); int32_t iRow = GetRowByKey(iRowKey); - if (iCol<0 || iRow<0) return NULL; + if (iCol<0 || iRow<0) return nullptr; // now get value Entry *pCell = GetCell(iCol, iRow); return pCell->Text.getData(); @@ -340,7 +340,7 @@ void C4Scoreboard::CompileFunc(StdCompiler *pComp) // *** C4ScoreboardDlg C4ScoreboardDlg::C4ScoreboardDlg(C4Scoreboard *pForScoreboard) - : C4GUI::Dialog(100, 100, "nops", false), piColWidths(NULL), pBrd(pForScoreboard) + : C4GUI::Dialog(100, 100, "nops", false), piColWidths(nullptr), pBrd(pForScoreboard) { Update(); } @@ -348,14 +348,14 @@ C4ScoreboardDlg::C4ScoreboardDlg(C4Scoreboard *pForScoreboard) C4ScoreboardDlg::~C4ScoreboardDlg() { delete [] piColWidths; - pBrd->pDlg = NULL; + pBrd->pDlg = nullptr; } void C4ScoreboardDlg::Update() { // counts int32_t iRowCount = pBrd->iRows; int32_t iColCount = pBrd->iCols; - delete [] piColWidths; piColWidths = NULL; + delete [] piColWidths; piColWidths = nullptr; // invalid board - scipters can create those, but there's no reason why the engine // should display something pretty then; just keep dialog defaults if (!iRowCount || !iColCount) return; diff --git a/src/gui/C4Scoreboard.h b/src/gui/C4Scoreboard.h index dbca9fd04..b7a3e4fe2 100644 --- a/src/gui/C4Scoreboard.h +++ b/src/gui/C4Scoreboard.h @@ -66,7 +66,7 @@ protected: friend class C4ScoreboardDlg; public: - C4Scoreboard() : iRows(0), iCols(0), pEntries(NULL), pDlg(NULL), iDlgShow(0) { } + C4Scoreboard() : iRows(0), iCols(0), pEntries(nullptr), pDlg(nullptr), iDlgShow(0) { } ~C4Scoreboard() { Clear(); } void Clear(); diff --git a/src/gui/C4ScriptGuiWindow.cpp b/src/gui/C4ScriptGuiWindow.cpp index c71ddd3ed..724cc4f3c 100644 --- a/src/gui/C4ScriptGuiWindow.cpp +++ b/src/gui/C4ScriptGuiWindow.cpp @@ -1848,7 +1848,7 @@ bool C4ScriptGuiWindow::Draw(C4TargetFacet &cgo, int32_t player, C4Rect *current C4Object *symbolObject = props[C4ScriptGuiWindowPropertyName::symbolObject].GetObject(); if (symbolObject) { - symbolObject->DrawPicture(cgoOut, false, NULL); + symbolObject->DrawPicture(cgoOut, false, nullptr); } else { diff --git a/src/gui/C4Startup.cpp b/src/gui/C4Startup.cpp index 71eb15aec..b41851f09 100644 --- a/src/gui/C4Startup.cpp +++ b/src/gui/C4Startup.cpp @@ -120,9 +120,9 @@ C4Startup::DialogID C4Startup::eLastDlgID = C4Startup::SDID_Main; StdCopyStrBuf C4Startup::sSubDialog = StdCopyStrBuf(); // startup singleton instance -C4Startup *C4Startup::pInstance = NULL; +C4Startup *C4Startup::pInstance = nullptr; -C4Startup::C4Startup() : fInStartup(false), pLastDlg(NULL), pCurrDlg(NULL) +C4Startup::C4Startup() : fInStartup(false), pLastDlg(nullptr), pCurrDlg(nullptr) { // must be single! assert(!pInstance); @@ -131,7 +131,7 @@ C4Startup::C4Startup() : fInStartup(false), pLastDlg(NULL), pCurrDlg(NULL) C4Startup::~C4Startup() { - pInstance = NULL; + pInstance = nullptr; delete pLastDlg; delete pCurrDlg; } @@ -142,7 +142,7 @@ C4StartupDlg *C4Startup::SwitchDialog(DialogID eToDlg, bool fFade, const char *s if (eToDlg == SDID_Back && (fLastDlgWasBack || !pLastDlg)) eToDlg = SDID_Main; fLastDlgWasBack = false; // create new dialog - C4StartupDlg *pToDlg = NULL; + C4StartupDlg *pToDlg = nullptr; switch (eToDlg) { case SDID_Main: @@ -172,7 +172,7 @@ C4StartupDlg *C4Startup::SwitchDialog(DialogID eToDlg, bool fFade, const char *s break; }; assert(pToDlg); - if (!pToDlg) return NULL; + if (!pToDlg) return nullptr; if (pToDlg != pLastDlg) { // remember current position @@ -191,7 +191,7 @@ C4StartupDlg *C4Startup::SwitchDialog(DialogID eToDlg, bool fFade, const char *s else { delete pLastDlg; - pLastDlg = NULL; + pLastDlg = nullptr; } } // Okay; now using this dialog @@ -203,16 +203,16 @@ C4StartupDlg *C4Startup::SwitchDialog(DialogID eToDlg, bool fFade, const char *s { if (!pToDlg->FadeIn(::pGUI)) { - delete pToDlg; pCurrDlg=NULL; - return NULL; + delete pToDlg; pCurrDlg=nullptr; + return nullptr; } } else { if (!pToDlg->Show(::pGUI, true)) { - delete pToDlg; pCurrDlg=NULL; - return NULL; + delete pToDlg; pCurrDlg=nullptr; + return nullptr; } } return pToDlg; @@ -229,8 +229,8 @@ void C4Startup::DoStartup() ::GraphicsSystem.EnableLoaderDrawing(); // clear any previous - if (pLastDlg) { delete pLastDlg; pLastDlg = NULL; } - if (pCurrDlg) { delete pCurrDlg; pCurrDlg = NULL; } + if (pLastDlg) { delete pLastDlg; pLastDlg = nullptr; } + if (pCurrDlg) { delete pCurrDlg; pCurrDlg = nullptr; } // start with the last dlg that was shown - at first startup main dialog SwitchDialog(eLastDlgID, true, sSubDialog.getData()); @@ -260,7 +260,7 @@ void C4Startup::DoStartup() void C4Startup::DontStartup() { // check whether startup was aborted - delete pLastDlg; pLastDlg = NULL; + delete pLastDlg; pLastDlg = nullptr; if (pCurrDlg) { // deinit last shown dlg @@ -269,7 +269,7 @@ void C4Startup::DontStartup() pCurrDlg->Close(true); } delete pCurrDlg; - pCurrDlg = NULL; + pCurrDlg = nullptr; } // now no more in startup! @@ -295,7 +295,7 @@ C4Startup *C4Startup::EnsureLoaded() Game.SetInitProgress(37.0f); // load startup specific gfx if (!pStartup->Graphics.Init()) - { LogFatal(LoadResStr("IDS_ERR_NOGFXSYS")); delete pStartup; return NULL; } + { LogFatal(LoadResStr("IDS_ERR_NOGFXSYS")); delete pStartup; return nullptr; } } return pInstance; } @@ -303,7 +303,7 @@ C4Startup *C4Startup::EnsureLoaded() void C4Startup::Unload() { // make sure startup data is destroyed - if (pInstance) { delete pInstance; pInstance=NULL; } + if (pInstance) { delete pInstance; pInstance=nullptr; } } void C4Startup::InitStartup() diff --git a/src/gui/C4Startup.h b/src/gui/C4Startup.h index 83c5da5af..14584b18a 100644 --- a/src/gui/C4Startup.h +++ b/src/gui/C4Startup.h @@ -83,7 +83,7 @@ public: class C4StartupDlg : public C4GUI::FullscreenDialog { public: - C4StartupDlg(const char *szTitle) : C4GUI::FullscreenDialog(szTitle, NULL) {} + C4StartupDlg(const char *szTitle) : C4GUI::FullscreenDialog(szTitle, nullptr) {} virtual bool SetSubscreen(const char *szToScreen) { return false; } // go to specified subdialog, e.g. a specific property sheet in the options dlg virtual void OnKeyboardLayoutChanged() {} @@ -112,7 +112,7 @@ private: protected: void DoStartup(); // create main dlg void DontStartup(); // close main dlg - class C4StartupDlg *SwitchDialog(DialogID eToDlg, bool fFade=true, const char *szSubDialog=NULL); // do transition to another dialog + class C4StartupDlg *SwitchDialog(DialogID eToDlg, bool fFade=true, const char *szSubDialog=nullptr); // do transition to another dialog friend class C4StartupMainDlg; friend class C4StartupNetDlg; diff --git a/src/gui/C4StartupMainDlg.cpp b/src/gui/C4StartupMainDlg.cpp index 699358ead..125487a4b 100644 --- a/src/gui/C4StartupMainDlg.cpp +++ b/src/gui/C4StartupMainDlg.cpp @@ -42,7 +42,7 @@ #endif -C4StartupMainDlg::C4StartupMainDlg() : C4StartupDlg(NULL) // create w/o title; it is drawn in custom draw proc +C4StartupMainDlg::C4StartupMainDlg() : C4StartupDlg(nullptr) // create w/o title; it is drawn in custom draw proc { // ctor fFirstShown = true; @@ -132,8 +132,8 @@ C4GUI::ContextMenu *C4StartupMainDlg::OnPlayerSelContext(C4GUI::Element *pBtn, i { // preliminary player selection via simple context menu C4GUI::ContextMenu *pCtx = new C4GUI::ContextMenu(); - pCtx->AddItem("Add", "Add participant", C4GUI::Ico_None, NULL, new C4GUI::CBContextHandler(this, &C4StartupMainDlg::OnPlayerSelContextAdd)); - pCtx->AddItem("Remove", "Remove participant", C4GUI::Ico_None, NULL, new C4GUI::CBContextHandler(this, &C4StartupMainDlg::OnPlayerSelContextRemove)); + pCtx->AddItem("Add", "Add participant", C4GUI::Ico_None, nullptr, new C4GUI::CBContextHandler(this, &C4StartupMainDlg::OnPlayerSelContextAdd)); + pCtx->AddItem("Remove", "Remove participant", C4GUI::Ico_None, nullptr, new C4GUI::CBContextHandler(this, &C4StartupMainDlg::OnPlayerSelContextRemove)); return pCtx; } @@ -148,9 +148,9 @@ C4GUI::ContextMenu *C4StartupMainDlg::OnPlayerSelContextAdd(C4GUI::Element *pBtn szFn = Config.AtRelativePath(szFn); if (*GetFilename(szFn) == '.') continue; if (!WildcardMatch(C4CFN_PlayerFiles, GetFilename(szFn))) continue; - if (!SIsModule(Config.General.Participants, szFn, NULL, false)) + if (!SIsModule(Config.General.Participants, szFn, nullptr, false)) pCtx->AddItem(GetFilenameOnly(szFn), "Let this player join in next game", C4GUI::Ico_Player, - new C4GUI::CBMenuHandlerEx(this, &C4StartupMainDlg::OnPlayerSelContextAddPlr, StdCopyStrBuf(szFn)), NULL); + new C4GUI::CBMenuHandlerEx(this, &C4StartupMainDlg::OnPlayerSelContextAddPlr, StdCopyStrBuf(szFn)), nullptr); } return pCtx; } @@ -161,7 +161,7 @@ C4GUI::ContextMenu *C4StartupMainDlg::OnPlayerSelContextRemove(C4GUI::Element *p char szPlayer[1024+1]; for (int i = 0; SCopySegment(Config.General.Participants, i, szPlayer, ';', 1024, true); i++) if (*szPlayer) - pCtx->AddItem(GetFilenameOnly(szPlayer), "Remove this player from participation list", C4GUI::Ico_Player, new C4GUI::CBMenuHandlerEx(this, &C4StartupMainDlg::OnPlayerSelContextRemovePlr, i), NULL); + pCtx->AddItem(GetFilenameOnly(szPlayer), "Remove this player from participation list", C4GUI::Ico_Player, new C4GUI::CBMenuHandlerEx(this, &C4StartupMainDlg::OnPlayerSelContextRemovePlr, i), nullptr); return pCtx; } @@ -340,7 +340,7 @@ void C4StartupMainDlg::OnShown() { // no player created yet: Create one C4GUI::Dialog *pDlg; - GetScreen()->ShowModalDlg(pDlg=new C4StartupPlrPropertiesDlg(NULL, NULL), true); + GetScreen()->ShowModalDlg(pDlg=new C4StartupPlrPropertiesDlg(nullptr, nullptr), true); } // make sure participants are updated after switching back from player selection UpdateParticipants(); diff --git a/src/gui/C4StartupNetDlg.cpp b/src/gui/C4StartupNetDlg.cpp index caca41201..96dbfba1e 100644 --- a/src/gui/C4StartupNetDlg.cpp +++ b/src/gui/C4StartupNetDlg.cpp @@ -30,7 +30,7 @@ // ----------- C4StartupNetListEntry ----------------------------------------------------------------------- C4StartupNetListEntry::C4StartupNetListEntry(C4GUI::ListBox *pForListBox, C4GUI::Element *pInsertBefore, C4StartupNetDlg *pNetDlg) - : pNetDlg(pNetDlg), pList(pForListBox), pRefClient(NULL), pRef(NULL), fError(false), eQueryType(NRQT_Unknown), iTimeout(0), iInfoIconCount(0), iSortOrder(0), fIsSmall(false), fIsCollapsed(false), fIsEnabled(true), fIsImportant(false) + : pNetDlg(pNetDlg), pList(pForListBox), pRefClient(nullptr), pRef(nullptr), fError(false), eQueryType(NRQT_Unknown), iTimeout(0), iInfoIconCount(0), iSortOrder(0), fIsSmall(false), fIsCollapsed(false), fIsEnabled(true), fIsImportant(false) { // calc height int32_t iLineHgt = ::GraphicsResource.TextFont.GetLineHeight(), iHeight = iLineHgt * 2 + 4; @@ -99,9 +99,9 @@ void C4StartupNetListEntry::ClearRef() { C4InteractiveThread &Thread = Application.InteractiveThread; Thread.RemoveProc(pRefClient); - delete pRefClient; pRefClient = NULL; + delete pRefClient; pRefClient = nullptr; } - if (pRef) { delete pRef; pRef = NULL; } + if (pRef) { delete pRef; pRef = nullptr; } eQueryType = NRQT_Unknown; iTimeout = iRequestTimeout = 0; fError = false; @@ -169,7 +169,7 @@ bool C4StartupNetListEntry::QueryReferences() return false; } // set up timeout - iRequestTimeout = time(NULL) + C4NetRefRequestTimeout; + iRequestTimeout = time(nullptr) + C4NetRefRequestTimeout; return true; } @@ -178,7 +178,7 @@ bool C4StartupNetListEntry::Execute() // update entries // if the return value is false, this entry will be deleted // timer running? - if (iTimeout) if (time(NULL) >= iTimeout) + if (iTimeout) if (time(nullptr) >= iTimeout) { // timeout! // for internet servers, this means refresh needed - search anew! @@ -205,7 +205,7 @@ bool C4StartupNetListEntry::Execute() // check if it has arrived if (pRefClient->isBusy()) // still requesting - but do not wait forever - if (time(NULL) >= iRequestTimeout) + if (time(nullptr) >= iRequestTimeout) { SetError(LoadResStr("IDS_NET_ERR_REFREQTIMEOUT"), TT_RefReqWait); pRefClient->Cancel("Timeout"); @@ -228,7 +228,7 @@ bool C4StartupNetListEntry::OnReference() // Ref getting done! pIcon->SetAnimated(false, 1); // Get reference information from client - C4Network2Reference **ppNewRefs=NULL; int32_t iNewRefCount; + C4Network2Reference **ppNewRefs=nullptr; int32_t iNewRefCount; if (!pRefClient->GetReferences(ppNewRefs, iNewRefCount)) { // References could be retrieved but not read @@ -288,7 +288,7 @@ C4GUI::Element* C4StartupNetListEntry::GetNextLower(int32_t sortOrder) return pElem; } // none found: insert at start - return NULL; + return nullptr; } @@ -338,7 +338,7 @@ void C4StartupNetListEntry::UpdateText() for (i=iInfoIconCount; iSetIcon(C4GUI::Ico_None); - pInfoIcons[i]->SetToolTip(NULL); + pInfoIcons[i]->SetToolTip(nullptr); } // text to labels for (i=0; igetServerName(); } @@ -583,7 +583,7 @@ const char *C4StartupNetListEntry::GetJoinAddress() C4Network2Reference *C4StartupNetListEntry::GrabReference() { C4Network2Reference *pOldRef = pRef; - pRef = NULL; + pRef = nullptr; return pOldRef; } @@ -592,7 +592,7 @@ C4Network2Reference *C4StartupNetListEntry::GrabReference() // ----------- C4StartupNetDlg --------------------------------------------------------------------------------- -C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART")), pChatTitleLabel(NULL), pMasterserverClient(NULL), fIsCollapsed(false), fUpdatingList(false), iGameDiscoverInterval(0), tLastRefresh(0), fUpdateCheckPending(false) +C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART")), pChatTitleLabel(nullptr), pMasterserverClient(nullptr), fIsCollapsed(false), fUpdatingList(false), iGameDiscoverInterval(0), tLastRefresh(0), fUpdateCheckPending(false) { // ctor // key bindings @@ -631,7 +631,7 @@ C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART") btnChat->SetText(LoadResStr("IDS_BTN_CHAT")); AddElement(btnChat); } - else btnChat = NULL; + else btnChat = nullptr; // main area: Tabular to switch between game list and chat pMainTabular = new C4GUI::Tabular(caMain.GetAll(), C4GUI::Tabular::tbNone); @@ -640,7 +640,7 @@ C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART") AddElement(pMainTabular); // main area: game selection sheet - C4GUI::Tabular::Sheet *pSheetGameList = pMainTabular->AddSheet(NULL); + C4GUI::Tabular::Sheet *pSheetGameList = pMainTabular->AddSheet(nullptr); C4GUI::ComponentAligner caGameList(pSheetGameList->GetContainedClientRect(), 0,0, false); C4GUI::WoodenLabel *pGameListLbl; int32_t iCaptHgt = C4GUI::WoodenLabel::GetDefaultHeight(&::GraphicsResource.TextFont); pGameListLbl = new C4GUI::WoodenLabel(LoadResStr("IDS_NET_GAMELIST"), caGameList.GetFromTop(iCaptHgt), C4GUI_Caption2FontClr, &::GraphicsResource.TextFont, ALeft); @@ -659,7 +659,7 @@ C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART") pSheetGameList->AddElement(pSearchFieldEdt); pSheetGameList->AddElement(pGameListLbl); pGameSelList = new C4GUI::ListBox(caGameList.GetFromTop(caGameList.GetHeight() - iCaptHgt)); - pGameSelList->SetDecoration(true, NULL, true, true); + pGameSelList->SetDecoration(true, nullptr, true, true); pGameSelList->UpdateElementPositions(); pGameSelList->SetSelectionDblClickFn(new C4GUI::CallbackHandler(this, &C4StartupNetDlg::OnSelDblClick)); pGameSelList->SetSelectionChangeCallbackFn(new C4GUI::CallbackHandler(this, &C4StartupNetDlg::OnSelChange)); @@ -680,7 +680,7 @@ C4StartupNetDlg::C4StartupNetDlg() : C4StartupDlg(LoadResStr("IDS_DLG_NETSTART") // main area: chat sheet if (C4ChatDlg::IsChatEnabled()) { - C4GUI::Tabular::Sheet *pSheetChat = pMainTabular->AddSheet(NULL); + C4GUI::Tabular::Sheet *pSheetChat = pMainTabular->AddSheet(nullptr); C4GUI::ComponentAligner caChat(pSheetChat->GetContainedClientRect(), 0,0, false); pSheetChat->AddElement(pChatTitleLabel = new C4GUI::WoodenLabel("", caChat.GetFromTop(iCaptHgt), C4GUI_Caption2FontClr, &::GraphicsResource.TextFont, ALeft, false)); C4GUI::GroupBox *pChatGroup = new C4GUI::GroupBox(caChat.GetAll()); @@ -779,7 +779,7 @@ void C4StartupNetDlg::OnShown() void C4StartupNetDlg::OnClosed(bool fOK) { // dlg abort: return to main screen - if (pMasterserverClient) { delete pMasterserverClient; pMasterserverClient=NULL; } + if (pMasterserverClient) { delete pMasterserverClient; pMasterserverClient=nullptr; } if (!fOK) DoBack(); } @@ -791,7 +791,7 @@ C4GUI::Control *C4StartupNetDlg::GetDefaultControl() return pChatCtrl->GetDefaultControl(); else // game list mode: No default control, because it would move focus away from IP input edit - return NULL; + return nullptr; } C4GUI::Control *C4StartupNetDlg::GetDlgModeFocusControl() @@ -867,11 +867,11 @@ void C4StartupNetDlg::UpdateMasterserver() if (!Config.Network.MasterServerSignUp) { delete pMasterserverClient; - pMasterserverClient = NULL; + pMasterserverClient = nullptr; } else { - pMasterserverClient = new C4StartupNetListEntry(pGameSelList, NULL, this); + pMasterserverClient = new C4StartupNetListEntry(pGameSelList, nullptr, this); StdStrBuf strVersion; strVersion.Format("%d.%d", C4XVER1, C4XVER2); StdStrBuf strQuery; strQuery.Format("%s?version=%s&platform=%s", Config.Network.GetLeagueServerAddress(), strVersion.getData(), C4_OS); pMasterserverClient->SetRefQuery(strQuery.getData(), C4StartupNetListEntry::NRQT_Masterserver); @@ -992,7 +992,7 @@ void C4StartupNetDlg::UpdateUpdateButton() if (!fUpdateCheckPending) return; if(!pUpdateClient.isSuccess() || pUpdateClient.isBusy()) return; - pUpdateClient.SetNotify(NULL); + pUpdateClient.SetNotify(nullptr); StdCopyStrBuf versionInfo; @@ -1184,7 +1184,7 @@ void C4StartupNetDlg::DoRefresh() // empty list of all old entries fUpdatingList = true; while (pGameSelList->GetFirst()) delete pGameSelList->GetFirst(); - pMasterserverClient=NULL; + pMasterserverClient=nullptr; // (Re-)Start discovery if (!DiscoverClient.StartDiscovery()) { @@ -1240,7 +1240,7 @@ void C4StartupNetDlg::AddReferenceQuery(const char *szAddress, C4StartupNetListE } } // No reference from same host found - create a new entry - C4StartupNetListEntry *pEntry = new C4StartupNetListEntry(pGameSelList, NULL, this); + C4StartupNetListEntry *pEntry = new C4StartupNetListEntry(pGameSelList, nullptr, this); pEntry->SetRefQuery(szAddress, eQueryType); if (eQueryType == C4StartupNetListEntry::NRQT_DirectJoin) pGameSelList->SelectEntry(pEntry, true); diff --git a/src/gui/C4StartupNetDlg.h b/src/gui/C4StartupNetDlg.h index 7ed258a63..eb4e1afa6 100644 --- a/src/gui/C4StartupNetDlg.h +++ b/src/gui/C4StartupNetDlg.h @@ -111,7 +111,7 @@ public: void UpdateCollapsed(bool fToCollapseValue); void SetVisibility(bool fToValue); - const char *GetError() { return fError ? sError.getData() : NULL; } // return error message, if any is set + const char *GetError() { return fError ? sError.getData() : nullptr; } // return error message, if any is set C4Network2Reference *GrabReference(); // grab the reference so it won't be deleted when this item is removed C4Network2Reference *GetReference() const { return pRef; } // have a look at the reference bool IsSameHost(const C4Network2Reference *pRef2); // check whether the reference was created by the same host as this one diff --git a/src/gui/C4StartupOptionsDlg.cpp b/src/gui/C4StartupOptionsDlg.cpp index ebdb7f163..f01b3c0c4 100644 --- a/src/gui/C4StartupOptionsDlg.cpp +++ b/src/gui/C4StartupOptionsDlg.cpp @@ -51,10 +51,10 @@ void C4StartupOptionsDlg::SmallButton::DrawElement(C4TargetFacet &cgo) float iDrawQuadRight[8] = { x1,y0, x1,y1, x1-iIndent,y1, x1-iIndent,y0+iIndent }; float iDrawQuadBottom[8] = { x1,y1, x0,y1, x0+iIndent,y1-iIndent, x1,y1-iIndent }; // TODO: Switch to PerformMultiTris - pDraw->DrawQuadDw(cgo.Surface, iDrawQuadTop, dwClrHigh,dwClrHigh,dwClrHigh,dwClrHigh, NULL); - pDraw->DrawQuadDw(cgo.Surface, iDrawQuadLeft, dwClrHigh,dwClrHigh,dwClrHigh,dwClrHigh, NULL); - pDraw->DrawQuadDw(cgo.Surface, iDrawQuadRight, dwClrLow,dwClrLow,dwClrLow,dwClrLow, NULL); - pDraw->DrawQuadDw(cgo.Surface, iDrawQuadBottom, dwClrLow,dwClrLow,dwClrLow,dwClrLow, NULL); + pDraw->DrawQuadDw(cgo.Surface, iDrawQuadTop, dwClrHigh,dwClrHigh,dwClrHigh,dwClrHigh, nullptr); + pDraw->DrawQuadDw(cgo.Surface, iDrawQuadLeft, dwClrHigh,dwClrHigh,dwClrHigh,dwClrHigh, nullptr); + pDraw->DrawQuadDw(cgo.Surface, iDrawQuadRight, dwClrLow,dwClrLow,dwClrLow,dwClrLow, nullptr); + pDraw->DrawQuadDw(cgo.Surface, iDrawQuadBottom, dwClrLow,dwClrLow,dwClrLow,dwClrLow, nullptr); // draw selection highlight int32_t iTxtOff = fDown ? iIndent : 0; if (fEnabled) if (HasDrawFocus() || (fMouseOver && IsInActiveDlg(false))) @@ -214,7 +214,7 @@ bool C4StartupOptionsDlg::KeySelDialog::KeyDown(const C4KeyCodeEx &key) // --- C4StartupOptionsDlg::ControlConfigListBox::ControlAssignmentLabel C4StartupOptionsDlg::ControlConfigListBox::ControlAssignmentLabel::ControlAssignmentLabel(class C4PlayerControlAssignment *assignment, class C4PlayerControlAssignmentSet *assignment_set, const C4Rect &bounds) - : C4GUI::Label("", bounds, ALeft, 0xffffffff, NULL, false, false, true), assignment(assignment), assignment_set(assignment_set) + : C4GUI::Label("", bounds, ALeft, 0xffffffff, nullptr, false, false, true), assignment(assignment), assignment_set(assignment_set) { UpdateAssignmentString(); } @@ -272,13 +272,13 @@ void C4StartupOptionsDlg::ControlConfigListBox::ControlAssignmentLabel::UpdateAs // --- C4StartupOptionsDlg::ControlConfigListBox::ListItem C4StartupOptionsDlg::ControlConfigListBox::ListItem::ListItem(ControlConfigListBox *parent_list, class C4PlayerControlAssignment *assignment, class C4PlayerControlAssignmentSet *assignment_set, bool has_extra_spacing) - : C4GUI::Window(), parent_list(parent_list), assignment_label(NULL), has_extra_spacing(has_extra_spacing) + : C4GUI::Window(), parent_list(parent_list), assignment_label(nullptr), has_extra_spacing(has_extra_spacing) { int32_t margin = 2; // adding to listbox will size the element horizontally and move to proper position int32_t height = ::GraphicsResource.TextFont.GetLineHeight() + 2 * margin; SetBounds(C4Rect(0,0,42,height)); - parent_list->InsertElement(this, NULL); + parent_list->InsertElement(this, nullptr); int32_t name_col_width = GetBounds().Wdt * 2/3; // child elements: two labels for two columns const char *gui_name = assignment->GetGUIName(Game.PlayerControlDefs); @@ -296,7 +296,7 @@ C4StartupOptionsDlg::ControlConfigListBox::ListItem::ListItem(ControlConfigListB // --- C4StartupOptionsDlg::ControlConfigListBox C4StartupOptionsDlg::ControlConfigListBox::ControlConfigListBox(const C4Rect &rcBounds, class C4PlayerControlAssignmentSet *set) - : C4GUI::ListBox(rcBounds), set(NULL) + : C4GUI::ListBox(rcBounds), set(nullptr) { SetAssignmentSet(set); } @@ -393,7 +393,7 @@ void C4StartupOptionsDlg::ControlConfigListBox::SetUserKey(class C4PlayerControl // --- C4StartupOptionsDlg::ControlConfigArea C4StartupOptionsDlg::ControlConfigArea::ControlConfigArea(const C4Rect &rcArea, int32_t iHMargin, int32_t iVMargin, bool fGamepad, C4StartupOptionsDlg *pOptionsDlg) - : C4GUI::Window(), fGamepad(fGamepad), pOptionsDlg(pOptionsDlg), pGUICtrl(NULL) + : C4GUI::Window(), fGamepad(fGamepad), pOptionsDlg(pOptionsDlg), pGUICtrl(nullptr) { CStdFont *pUseFontSmall = &(C4Startup::Get()->Graphics.BookSmallFont); SetBounds(rcArea); @@ -429,7 +429,7 @@ C4StartupOptionsDlg::ControlConfigArea::ControlConfigArea(const C4Rect &rcArea, caArea.ExpandTop(caArea.GetVMargin()); AddElement(new C4GUI::HorizontalLine(caArea.GetFromTop(2))); caArea.ExpandTop(caArea.GetVMargin()); - control_list = new ControlConfigListBox(caArea.GetFromLeft(caArea.GetInnerWidth()), NULL); + control_list = new ControlConfigListBox(caArea.GetFromLeft(caArea.GetInnerWidth()), nullptr); AddElement(control_list); UpdateCtrlSet(); @@ -626,7 +626,7 @@ void C4StartupOptionsDlg::BoolConfig::OnCheckChange(C4GUI::Element *pCheckBox) // --- C4StartupOptionsDlg::EditConfig C4StartupOptionsDlg::EditConfig::EditConfig(const C4Rect &rcBounds, const char *szName, ValidatedStdCopyStrBufBase *psConfigVal, int32_t *piConfigVal, bool fMultiline) - : C4GUI::LabeledEdit(rcBounds, szName, fMultiline, psConfigVal ? psConfigVal->getData() : NULL, &(C4Startup::Get()->Graphics.BookFont), C4StartupFontClr), psConfigVal(psConfigVal), piConfigVal(piConfigVal) + : C4GUI::LabeledEdit(rcBounds, szName, fMultiline, psConfigVal ? psConfigVal->getData() : nullptr, &(C4Startup::Get()->Graphics.BookFont), C4StartupFontClr), psConfigVal(psConfigVal), piConfigVal(piConfigVal) { // ctor GetEdit()->SetColors(C4StartupEditBGColor, C4StartupFontClr, C4StartupEditBorderColor); @@ -738,7 +738,7 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D pLangCombo->SetFont(pUseFont); pLangCombo->SetDecoration(&(C4Startup::Get()->Graphics.fctContext)); pSheetGeneral->AddElement(pLangCombo); - pLangInfoLabel = new C4GUI::Label(NULL, caLanguage.GetFromTop(::GraphicsResource.TextFont.GetLineHeight()*3), ALeft, C4StartupFontClr, pUseFont, false); + pLangInfoLabel = new C4GUI::Label(nullptr, caLanguage.GetFromTop(::GraphicsResource.TextFont.GetLineHeight()*3), ALeft, C4StartupFontClr, pUseFont, false); pLangInfoLabel->SetToolTip(szLangTip); pSheetGeneral->AddElement(pLangInfoLabel); UpdateLanguage(); @@ -768,7 +768,7 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D pSheetGeneral->AddElement(pFontSizeCombo); UpdateFontControls(); // MM timer - pCheck = new BoolConfig(caSheetProgram.GetGridCell(0,1,3,7,-1,iCheckHgt, true), LoadResStr("IDS_CTL_MMTIMER"), NULL, &Config.General.MMTimer, true, &Config.Startup.HideMsgMMTimerChange); + pCheck = new BoolConfig(caSheetProgram.GetGridCell(0,1,3,7,-1,iCheckHgt, true), LoadResStr("IDS_CTL_MMTIMER"), nullptr, &Config.General.MMTimer, true, &Config.Startup.HideMsgMMTimerChange); pCheck->SetToolTip(LoadResStr("IDS_MSG_MMTIMER_DESC")); pCheck->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled); pSheetGeneral->AddElement(pCheck); @@ -853,7 +853,7 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D pGfxMSCombo->SetReadOnly(multisamples.empty()); pGroupOptions->AddElement(pGfxMSCombo); // automatic gfx frame skip - pCheck = new BoolConfig(caGroupOptions.GetGridCell(0,1,iOpt++,iNumGfxOptions,-1,iCheckHgt,true), LoadResStr("IDS_MSG_AUTOFRAMESKIP"), NULL, &Config.Graphics.AutoFrameSkip); + pCheck = new BoolConfig(caGroupOptions.GetGridCell(0,1,iOpt++,iNumGfxOptions,-1,iCheckHgt,true), LoadResStr("IDS_MSG_AUTOFRAMESKIP"), nullptr, &Config.Graphics.AutoFrameSkip); pCheck->SetToolTip(LoadResStr("IDS_DESC_AUTOFRAMESKIP")); pCheck->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled); pGroupOptions->AddElement(pCheck); @@ -876,7 +876,7 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D pCheck->SetOnChecked(new C4GUI::CallbackHandler(this, &C4StartupOptionsDlg::OnFEMusicCheck)); pGroupFESound->AddElement(pCheck); // menu system sound effects - pCheck = pFESoundCheck = new BoolConfig(caGroupFESound.GetGridCell(0,1,1,2,-1,iCheckHgt,true), LoadResStr("IDS_CTL_SOUNDFX"), NULL, &Config.Sound.FESamples); + pCheck = pFESoundCheck = new BoolConfig(caGroupFESound.GetGridCell(0,1,1,2,-1,iCheckHgt,true), LoadResStr("IDS_CTL_SOUNDFX"), nullptr, &Config.Sound.FESamples); pCheck->SetToolTip(LoadResStr("IDS_DESC_MENUSOUND")); pCheck->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled); pGroupFESound->AddElement(pCheck); @@ -888,7 +888,7 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D pSheetSound->AddElement(pGroupRXSound); C4GUI::ComponentAligner caGroupRXSound(pGroupRXSound->GetClientRect(), iIndentX1, iIndentY2, true); // game music - pCheck = new BoolConfig(caGroupRXSound.GetGridCell(0,1,0,2,-1,iCheckHgt,true), LoadResStr("IDS_CTL_MUSIC"), NULL, &Config.Sound.RXMusic); + pCheck = new BoolConfig(caGroupRXSound.GetGridCell(0,1,0,2,-1,iCheckHgt,true), LoadResStr("IDS_CTL_MUSIC"), nullptr, &Config.Sound.RXMusic); pCheck->SetToolTip(LoadResStr("IDS_DESC_GAMEMUSIC")); pCheck->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled); pGroupRXSound->AddElement(pCheck); @@ -954,23 +954,23 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D pLeagueServerCfg->SetToolTip(LoadResStr("IDS_NET_MASTERSRV_DESC")); pSheetNetwork->AddElement(pLeagueServerCfg); #ifdef WITH_AUTOMATIC_UPDATE - pCheck = new BoolConfig(caSheetNetwork.GetFromTop(pUseFont->GetLineHeight()), LoadResStr("IDS_CTL_AUTOMATICUPDATES"), NULL, &Config.Network.AutomaticUpdate, false); + pCheck = new BoolConfig(caSheetNetwork.GetFromTop(pUseFont->GetLineHeight()), LoadResStr("IDS_CTL_AUTOMATICUPDATES"), nullptr, &Config.Network.AutomaticUpdate, false); pCheck->SetToolTip(LoadResStr("IDS_DESC_AUTOMATICUPDATES")); pCheck->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled); pSheetNetwork->AddElement(pCheck); #endif - pCheck = new BoolConfig(caSheetNetwork.GetFromTop(pUseFont->GetLineHeight()), LoadResStr("IDS_CTL_UPNP"), NULL, &Config.Network.EnableUPnP, false); + pCheck = new BoolConfig(caSheetNetwork.GetFromTop(pUseFont->GetLineHeight()), LoadResStr("IDS_CTL_UPNP"), nullptr, &Config.Network.EnableUPnP, false); pCheck->SetToolTip(LoadResStr("IDS_DESC_UPNP")); pCheck->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled); pSheetNetwork->AddElement(pCheck); - pCheck = new BoolConfig(caSheetNetwork.GetFromTop(pUseFont->GetLineHeight()), LoadResStr("IDS_CTL_PACKETLOGGING"), NULL, &Config.Network.PacketLogging, false); + pCheck = new BoolConfig(caSheetNetwork.GetFromTop(pUseFont->GetLineHeight()), LoadResStr("IDS_CTL_PACKETLOGGING"), nullptr, &Config.Network.PacketLogging, false); pCheck->SetToolTip(LoadResStr("IDS_DESC_PACKETLOGGING")); pCheck->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled); pSheetNetwork->AddElement(pCheck); const char *szNameCfgText = LoadResStr("IDS_NET_USERNAME"); int iNameCfgWdt=200, iNameCfgHgt=48; C4StartupOptionsDlg::EditConfig::GetControlSize(&iNameCfgWdt, &iNameCfgHgt, szNameCfgText, false); iNameCfgWdt += 5; - pNetworkNickEdit = new EditConfig(caSheetNetwork.GetFromTop(iNameCfgHgt), szNameCfgText, &Config.Network.Nick, NULL, false); + pNetworkNickEdit = new EditConfig(caSheetNetwork.GetFromTop(iNameCfgHgt), szNameCfgText, &Config.Network.Nick, nullptr, false); pNetworkNickEdit->SetToolTip(LoadResStr("IDS_NET_USERNAME_DESC")); pSheetNetwork->AddElement(pNetworkNickEdit); @@ -1111,7 +1111,7 @@ bool C4StartupOptionsDlg::TryNewResolution(int32_t iResX, int32_t iResY, int32_t if (!Application.SetVideoMode(iResX, iResY, iRefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed)) { StdCopyStrBuf strChRes(LoadResStr("IDS_MNU_SWITCHRESOLUTION")); - pScreen->ShowMessage(FormatString(LoadResStr("IDS_ERR_SWITCHRES"), Application.GetLastError()).getData(), strChRes.getData(), C4GUI::Ico_Clonk, NULL); + pScreen->ShowMessage(FormatString(LoadResStr("IDS_ERR_SWITCHRES"), Application.GetLastError()).getData(), strChRes.getData(), C4GUI::Ico_Clonk, nullptr); return false; } // implied font change @@ -1236,7 +1236,7 @@ bool C4StartupOptionsDlg::SetSubscreen(const char *szToScreen) { // go to specified property sheet // option sheets do not have a good identifier associated to them - just lookup from a static array - const char *page_names[] = { "general", "graphics", "sound", "controls", "network", NULL }; + const char *page_names[] = { "general", "graphics", "sound", "controls", "network", nullptr }; int32_t i = 0; while (page_names[i]) { @@ -1318,9 +1318,9 @@ void C4StartupOptionsDlg::UpdateFontControls() } #ifdef _WIN32 -const char *DefaultFonts[] = { "Arial Unicode MS", "Comic Sans MS", C4DEFAULT_FONT_NAME, "Verdana", NULL }; +const char *DefaultFonts[] = { "Arial Unicode MS", "Comic Sans MS", C4DEFAULT_FONT_NAME, "Verdana", nullptr }; #else -const char *DefaultFonts[] = { C4DEFAULT_FONT_NAME, NULL }; +const char *DefaultFonts[] = { C4DEFAULT_FONT_NAME, nullptr }; #endif void C4StartupOptionsDlg::OnFontFaceComboFill(C4GUI::ComboBox_FillCB *pFiller) @@ -1401,7 +1401,7 @@ void C4StartupOptionsDlg::OnSoundVolumeSliderChange(int32_t iNewVal) // sound system reads this value directly Config.Sound.SoundVolume = iNewVal; // test sound - StartSoundEffect("Objects::Arrow::HitGround", false, 100, NULL); + StartSoundEffect("Objects::Arrow::HitGround", false, 100, nullptr); } void C4StartupOptionsDlg::OnRXSoundCheck(C4GUI::Element *pCheckBox) diff --git a/src/gui/C4StartupOptionsDlg.h b/src/gui/C4StartupOptionsDlg.h index 868d2d613..04eb45c56 100644 --- a/src/gui/C4StartupOptionsDlg.h +++ b/src/gui/C4StartupOptionsDlg.h @@ -94,7 +94,7 @@ private: protected: void OnCheckChange(C4GUI::Element *pCheckBox); public: - BoolConfig(const C4Rect &rcBounds, const char *szName, bool *pbVal, int32_t *piVal, bool fInvert=false, int32_t *piRestartChangeCfgVal=NULL); + BoolConfig(const C4Rect &rcBounds, const char *szName, bool *pbVal, int32_t *piVal, bool fInvert=false, int32_t *piRestartChangeCfgVal=nullptr); }; // editbox below descriptive label sharing one window for common tooltip class EditConfig : public C4GUI::LabeledEdit diff --git a/src/gui/C4StartupPlrSelDlg.cpp b/src/gui/C4StartupPlrSelDlg.cpp index 52f0c5a58..a960d1e6d 100644 --- a/src/gui/C4StartupPlrSelDlg.cpp +++ b/src/gui/C4StartupPlrSelDlg.cpp @@ -70,13 +70,13 @@ StdStrBuf DateString(int iTime) // ------------------------------------------------ // --- C4StartupPlrSelDlg::ListItem C4StartupPlrSelDlg::ListItem::ListItem(C4StartupPlrSelDlg *pForDlg, C4GUI::ListBox *pForListBox, C4GUI::Element *pInsertBeforeElement, bool fActivated) - : Control(C4Rect(0,0,0,0)), pCheck(NULL), pNameLabel(NULL), pPlrSelDlg(pForDlg), pIcon(NULL) + : Control(C4Rect(0,0,0,0)), pCheck(nullptr), pNameLabel(nullptr), pPlrSelDlg(pForDlg), pIcon(nullptr) { CStdFont &rUseFont = GraphicsResource.FontRegular; // calc height int32_t iHeight = rUseFont.GetLineHeight() + 2 * IconLabelSpacing; // create subcomponents - pCheck = new C4GUI::CheckBox(C4Rect(0, 0, iHeight, iHeight), NULL, fActivated); + pCheck = new C4GUI::CheckBox(C4Rect(0, 0, iHeight, iHeight), nullptr, fActivated); pCheck->SetOnChecked(new C4GUI::CallbackHandler(pForDlg, &C4StartupPlrSelDlg::OnItemCheckChange)); pKeyCheck = new C4KeyBinding(C4KeyCodeEx(K_SPACE), "StartupPlrSelTogglePlayerActive", KEYSCOPE_Gui, new C4GUI::ControlKeyCB(*this, &ListItem::KeyCheck), C4CustomKey::PRIO_Ctrl); @@ -288,7 +288,7 @@ bool C4StartupPlrSelDlg::PlayerListItem::MoveFilename(const char *szToFilename) // --- C4StartupPlrSelDlg::CrewListItem C4StartupPlrSelDlg::CrewListItem::CrewListItem(C4StartupPlrSelDlg *pForDlg, C4GUI::ListBox *pForListBox, uint32_t dwPlrClr) - : ListItem(pForDlg, pForListBox, NULL, false), fLoaded(false), dwPlrClr(dwPlrClr), pParentGrp(NULL) + : ListItem(pForDlg, pForListBox, nullptr, false), fLoaded(false), dwPlrClr(dwPlrClr), pParentGrp(nullptr) { SetIcon(C4GUI::Ico_Wait); } @@ -369,7 +369,7 @@ void C4StartupPlrSelDlg::CrewListItem::RewriteCore() if (!fLoaded) return; C4Group CrewGroup; if (!CrewGroup.OpenAsChild(pParentGrp, GetFilename().getData()) - || !Core.Save(CrewGroup, NULL) + || !Core.Save(CrewGroup, nullptr) || !CrewGroup.Close() || !pParentGrp->Save(true)) { GetScreen()->ShowMessage(LoadResStr("IDS_FAIL_MODIFY"), "", C4GUI::Ico_Error); @@ -455,14 +455,14 @@ void C4StartupPlrSelDlg::CrewListItem::CrewRename() void C4StartupPlrSelDlg::CrewListItem::AbortRenaming(RenameParams par) { // no renaming - pPlrSelDlg->pRenameEdit = NULL; + pPlrSelDlg->pRenameEdit = nullptr; } C4GUI::RenameEdit::RenameResult C4StartupPlrSelDlg::CrewListItem::DoRenaming(RenameParams par, const char *szNewName) { // accept if name can be set; will fail if name is invalid or already given to another Crew member if (!SetName(szNewName)) return C4GUI::RenameEdit::RR_Invalid; - pPlrSelDlg->pRenameEdit = NULL; + pPlrSelDlg->pRenameEdit = nullptr; // update in selection C4StartupPlrSelDlg *pDlg = static_cast(GetDlg()); if (pDlg && pDlg->GetSelection() == this) pDlg->UpdateSelection(); @@ -474,7 +474,7 @@ C4GUI::RenameEdit::RenameResult C4StartupPlrSelDlg::CrewListItem::DoRenaming(Ren // ------------------------------------------------ // --- C4StartupPlrSelDlg -C4StartupPlrSelDlg::C4StartupPlrSelDlg() : C4StartupDlg("W"), eMode(PSDM_Player), pRenameEdit(NULL) +C4StartupPlrSelDlg::C4StartupPlrSelDlg() : C4StartupDlg("W"), eMode(PSDM_Player), pRenameEdit(nullptr) { // ctor UpdateSize(); // for clientrect @@ -497,7 +497,7 @@ C4StartupPlrSelDlg::C4StartupPlrSelDlg() : C4StartupDlg("W"), eMode(PSDM_Player) pPlrListBox->UpdateElementPositions(); pPlrListBox->SetSelectionChangeCallbackFn(new C4GUI::CallbackHandler(this, &C4StartupPlrSelDlg::OnSelChange)); pPlrListBox->SetSelectionDblClickFn(new C4GUI::CallbackHandler(this, &C4StartupPlrSelDlg::OnSelDblClick)); - AddElement(pSelectionInfo = new C4GUI::TextWindow(rcInfoWindow,0,0,0,100,4096," ",false,NULL,0,true)); + AddElement(pSelectionInfo = new C4GUI::TextWindow(rcInfoWindow,0,0,0,100,4096," ",false,nullptr,0,true)); pSelectionInfo->SetDecoration(true, true, &C4Startup::Get()->Graphics.sfctBookScroll, true); pSelectionInfo->UpdateHeight(); @@ -506,9 +506,9 @@ C4StartupPlrSelDlg::C4StartupPlrSelDlg() : C4StartupDlg("W"), eMode(PSDM_Player) AddElement(btnBack = new C4GUI::CallbackButton(LoadResStr("IDS_BTN_BACK"), rcDefault, &C4StartupPlrSelDlg::OnBackBtn)); AddElement(btnNew = new C4GUI::CallbackButton(LoadResStr("IDS_BTN_NEW"), rcDefault, &C4StartupPlrSelDlg::OnNewBtn)); btnNew->SetToolTip(LoadResStr("IDS_DLGTIP_NEWPLAYER")); - AddElement(btnActivatePlr = new C4GUI::CallbackButton(NULL, rcDefault, &C4StartupPlrSelDlg::OnActivateBtn)); + AddElement(btnActivatePlr = new C4GUI::CallbackButton(nullptr, rcDefault, &C4StartupPlrSelDlg::OnActivateBtn)); AddElement(btnDelete = new C4GUI::CallbackButton(LoadResStr("IDS_BTN_DELETE"), rcDefault, &C4StartupPlrSelDlg::OnDelBtn)); - AddElement(btnProperties = new C4GUI::CallbackButton(NULL, rcDefault, &C4StartupPlrSelDlg::OnPropertyBtn)); + AddElement(btnProperties = new C4GUI::CallbackButton(nullptr, rcDefault, &C4StartupPlrSelDlg::OnPropertyBtn)); AddElement(btnCrew = new C4GUI::CallbackButton(LoadResStr("IDS_SELECT_CREW"), rcDefault, &C4StartupPlrSelDlg::OnCrewBtn)); btnCrew->SetToolTip(LoadResStr("IDS_DLGTIP_PLAYERCREW")); @@ -624,14 +624,14 @@ void C4StartupPlrSelDlg::UpdatePlayerList() // player mode: insert all players const char *szFn; StdStrBuf sSearchPath(Config.General.UserDataPath); - PlayerListItem *pFirstActivatedPlrItem=NULL, *pFirstDeactivatedPlrItem=NULL, *pPlrItem=NULL; + PlayerListItem *pFirstActivatedPlrItem=nullptr, *pFirstDeactivatedPlrItem=nullptr, *pPlrItem=nullptr; for (DirectoryIterator i(sSearchPath.getData()); (szFn=*i); i++) { szFn = Config.AtRelativePath(szFn); if (*GetFilename(szFn) == '.') continue; // ignore ".", ".." and private files (".*") if (!WildcardMatch(C4CFN_PlayerFiles, GetFilename(szFn))) continue; - bool fIsParticipating = !!SIsModule(Config.General.Participants, szFn, NULL, false); - pPlrItem = new PlayerListItem(this, pPlrListBox, NULL, fIsParticipating); + bool fIsParticipating = !!SIsModule(Config.General.Participants, szFn, nullptr, false); + pPlrItem = new PlayerListItem(this, pPlrListBox, nullptr, fIsParticipating); try { pPlrItem->Load(StdStrBuf(szFn)); @@ -664,7 +664,7 @@ void C4StartupPlrSelDlg::UpdatePlayerList() SetTitle(FormatString("%s %s", LoadResStrNoAmp("IDS_CTL_CREW"), CurrPlayer.Core.PrefName).getData()); // crew mode: Insert complete crew of player (2do: sort) bool fSucc; char szFn[_MAX_PATH+1]; - for (fSucc=CurrPlayer.Grp.FindEntry(C4CFN_ObjectInfoFiles, szFn); fSucc; fSucc=CurrPlayer.Grp.FindNextEntry(C4CFN_ObjectInfoFiles, szFn, NULL, true)) + for (fSucc=CurrPlayer.Grp.FindEntry(C4CFN_ObjectInfoFiles, szFn); fSucc; fSucc=CurrPlayer.Grp.FindNextEntry(C4CFN_ObjectInfoFiles, szFn, nullptr, true)) { CrewListItem *pCrewItem = new CrewListItem(this, pPlrListBox, CurrPlayer.Core.PrefColorDw); try @@ -733,7 +733,7 @@ void C4StartupPlrSelDlg::OnItemCheckChange(C4GUI::Element *pCheckBox) { case PSDM_Player: // Deselect all other players - for (ListItem* pEl = static_cast(pPlrListBox->GetFirst()); pEl != NULL; pEl = pEl->GetNext()) + for (ListItem* pEl = static_cast(pPlrListBox->GetFirst()); pEl != nullptr; pEl = pEl->GetNext()) if (pCheckBox && pEl != pCheckBox->GetParent()) pEl->SetActivated(false); // update Config.General.Participants @@ -800,7 +800,7 @@ void C4StartupPlrSelDlg::OnNewBtn(C4GUI::Control *btn) { if (eMode != PSDM_Player) return; C4GUI::Dialog *pDlg; - GetScreen()->ShowRemoveDlg(pDlg=new C4StartupPlrPropertiesDlg(NULL, this)); + GetScreen()->ShowRemoveDlg(pDlg=new C4StartupPlrPropertiesDlg(nullptr, this)); pDlg->SetPos(std::min(GetBounds().Wdt/10, GetBounds().Wdt - pDlg->GetBounds().Wdt), std::min(GetBounds().Hgt/4, GetBounds().Hgt - pDlg->GetBounds().Hgt)); } @@ -1300,7 +1300,7 @@ void C4StartupPlrColorPickerDlg::Picker::MouseInput(C4GUI::CMouse &rMouse, int32 } else { - rMouse.pDragElement = NULL; + rMouse.pDragElement = nullptr; } } } @@ -1544,7 +1544,7 @@ void C4StartupPlrPropertiesDlg::UserClose(bool fOK) if (fOK) { StdStrBuf PlrName(pNameEdit->GetText()), Filename; - if (!C4StartupPlrSelDlg::CheckPlayerName(PlrName, Filename, pForPlayer ? &pForPlayer->GetFilename() : NULL, true)) return; + if (!C4StartupPlrSelDlg::CheckPlayerName(PlrName, Filename, pForPlayer ? &pForPlayer->GetFilename() : nullptr, true)) return; } Close(fOK); } @@ -1555,7 +1555,7 @@ void C4StartupPlrPropertiesDlg::OnClosed(bool fOK) { // store selected data if desired StdStrBuf PlrName(pNameEdit->GetText()), Filename; - if (C4StartupPlrSelDlg::CheckPlayerName(PlrName, Filename, pForPlayer ? &pForPlayer->GetFilename() : NULL, true)) + if (C4StartupPlrSelDlg::CheckPlayerName(PlrName, Filename, pForPlayer ? &pForPlayer->GetFilename() : nullptr, true)) { SCopy(PlrName.getData(), C4P.PrefName, C4MaxName); C4Group PlrGroup; @@ -1640,7 +1640,7 @@ void C4StartupPlrPropertiesDlg::SetNewPicture(const char *szFromFilename) { if (!szFromFilename) { - // If szFromFilename==NULL, clear bigicon + // If szFromFilename==nullptr, clear bigicon fClearBigIcon = true; fctNewBigIcon.Clear(); } diff --git a/src/gui/C4StartupPlrSelDlg.h b/src/gui/C4StartupPlrSelDlg.h index 2ff52f05d..3c425b2a0 100644 --- a/src/gui/C4StartupPlrSelDlg.h +++ b/src/gui/C4StartupPlrSelDlg.h @@ -47,7 +47,7 @@ private: StdStrBuf Filename; // file info was loaded from public: - ListItem(C4StartupPlrSelDlg *pForDlg, C4GUI::ListBox *pForListBox, C4GUI::Element *pInsertBeforeElement=NULL, bool fActivated=false); + ListItem(C4StartupPlrSelDlg *pForDlg, C4GUI::ListBox *pForListBox, C4GUI::Element *pInsertBeforeElement=nullptr, bool fActivated=false); const C4FacetSurface &GetIconFacet() const { return pIcon->GetFacet(); } virtual ~ListItem(); @@ -95,7 +95,7 @@ public: bool fHasCustomIcon; // set for players with a BigIcon.png public: - PlayerListItem(C4StartupPlrSelDlg *pForDlg, C4GUI::ListBox *pForListBox, C4GUI::Element *pInsertBeforeElement=NULL, bool fActivated=false); + PlayerListItem(C4StartupPlrSelDlg *pForDlg, C4GUI::ListBox *pForListBox, C4GUI::Element *pInsertBeforeElement=nullptr, bool fActivated=false); ~PlayerListItem() {} void Load(const StdStrBuf &rsFilename); // may throw LoadError @@ -180,7 +180,7 @@ private: void UpdatePlayerList(); // refill pPlrListBox with players in player folder, or with crew in selected player void UpdateSelection(); void OnSelChange(class C4GUI::Element *pEl) { UpdateSelection(); } - void OnSelDblClick(class C4GUI::Element *pEl) { C4GUI::GUISound("UI::Click"); OnPropertyBtn(NULL); } + void OnSelDblClick(class C4GUI::Element *pEl) { C4GUI::GUISound("UI::Click"); OnPropertyBtn(nullptr); } void UpdateActivatedPlayers(); // update Config.General.Participants by currently activated players void SelectItem(const StdStrBuf &Filename, bool fActivate); // find item by filename and select (and activate it, if desired) @@ -210,19 +210,19 @@ protected: virtual bool OnEnter() { return false; } // Enter ignored virtual bool OnEscape() { DoBack(); return true; } bool KeyBack() { DoBack(); return true; } - bool KeyProperties() { OnPropertyBtn(NULL); return true; } - bool KeyCrew() { OnCrewBtn(NULL); return true; } - bool KeyDelete() { OnDelBtn(NULL); return true; } - bool KeyNew() { OnNewBtn(NULL); return true; } + bool KeyProperties() { OnPropertyBtn(nullptr); return true; } + bool KeyCrew() { OnCrewBtn(nullptr); return true; } + bool KeyDelete() { OnDelBtn(nullptr); return true; } + bool KeyNew() { OnNewBtn(nullptr); return true; } void OnNewBtn(C4GUI::Control *btn); void OnNew(const StdStrBuf &Playername); void OnActivateBtn(C4GUI::Control *btn); void OnPropertyBtn(C4GUI::Control *btn); - void OnPropertyCtx(C4GUI::Element *el) { OnPropertyBtn(NULL); } + void OnPropertyCtx(C4GUI::Element *el) { OnPropertyBtn(nullptr); } void OnCrewBtn(C4GUI::Control *btn); void OnDelBtn(C4GUI::Control *btn); - void OnDelCtx(C4GUI::Element *el) { OnDelBtn(NULL); } + void OnDelCtx(C4GUI::Element *el) { OnDelBtn(nullptr); } void OnDelBtnConfirm(ListItem *pSel); void OnBackBtn(C4GUI::Control *btn) { DoBack(); } @@ -234,7 +234,7 @@ public: class C4StartupPlrPropertiesDlg: public C4GUI::Dialog { protected: - C4StartupPlrSelDlg *pMainDlg; // may be NULL if shown as creation dialog in main menu! + C4StartupPlrSelDlg *pMainDlg; // may be nullptr if shown as creation dialog in main menu! C4StartupPlrSelDlg::PlayerListItem * pForPlayer; C4GUI::Edit *pNameEdit; // player name edit box C4GUI::CheckBox *pAutoStopControl; // wether the player uses AutoStopControl @@ -274,7 +274,7 @@ private: void UpdateBigIcon(); bool SetNewPicture(C4Surface &srcSfc, C4FacetSurface *trgFct, int32_t iMaxSize, bool fColorize); - void SetNewPicture(const char *szFromFilename); // set new bigicon by loading and scaling if necessary. If szFromFilename==NULL, clear bigicon + void SetNewPicture(const char *szFromFilename); // set new bigicon by loading and scaling if necessary. If szFromFilename==nullptr, clear bigicon public: C4StartupPlrPropertiesDlg(C4StartupPlrSelDlg::PlayerListItem * pForPlayer, C4StartupPlrSelDlg *pMainDlg); diff --git a/src/gui/C4StartupScenSelDlg.cpp b/src/gui/C4StartupScenSelDlg.cpp index 9034d09df..8bc8f1683 100644 --- a/src/gui/C4StartupScenSelDlg.cpp +++ b/src/gui/C4StartupScenSelDlg.cpp @@ -36,7 +36,7 @@ #include // singleton -C4StartupScenSelDlg *C4StartupScenSelDlg::pInstance=NULL; +C4StartupScenSelDlg *C4StartupScenSelDlg::pInstance=nullptr; // ---------------------------------------------------------------- @@ -96,20 +96,20 @@ void C4MapFolderData::Clear() { fCoordinatesAdjusted = false; fctBackgroundPicture.Clear(); - pScenarioFolder = NULL; - pSelectedEntry = NULL; - pSelectionInfoBox = NULL; + pScenarioFolder = nullptr; + pSelectedEntry = nullptr; + pSelectionInfoBox = nullptr; rcScenInfoArea.Set(0,0,0,0); MinResX=MinResY=0; fUseFullscreenMap=false; int i; for (i=0; ipScenEntry = pScenLoaderFolder->FindEntryByName(pScen->sFilename.getData()); - pScen->pBtn = NULL; + pScen->pBtn = nullptr; pScen->sTitle.Replace("TITLE", pScen->pScenEntry ? pScen->pScenEntry->GetName().getData() : "ERROR" /* scenario not loaded; title cannot be referenced */); // developer image dump if (pScen->fImgDump) @@ -205,7 +205,7 @@ void C4MapFolderData::CompileFunc(StdCompiler *pComp) memset(ppScenList, 0, sizeof(Scenario *)*iScenCount); } else - ppScenList = NULL; + ppScenList = nullptr; } if (iScenCount) { @@ -225,7 +225,7 @@ void C4MapFolderData::CompileFunc(StdCompiler *pComp) memset(ppAccessGfxList, 0, sizeof(AccessGfx *)*iAccessGfxCount); } else - ppAccessGfxList = NULL; + ppAccessGfxList = nullptr; } if (iAccessGfxCount) { @@ -339,7 +339,7 @@ void C4MapFolderData::CreateGUIElements(C4StartupScenSelDlg *pMainDlg, C4GUI::Wi } } // create buttons for scenarios - C4GUI::Button *pBtnFirst = NULL; + C4GUI::Button *pBtnFirst = nullptr; for (i=0; iGraphics.fctScenSelTitleOverlay, C4StartupScenSel_TitleOverlayMargin); + C4StartupScenSel_TitlePicturePadding, 100, 4096, nullptr, true, &C4Startup::Get()->Graphics.fctScenSelTitleOverlay, C4StartupScenSel_TitleOverlayMargin); pSelectionInfoBox->SetDecoration(false, false, &C4Startup::Get()->Graphics.sfctBookScroll, true); rContainer.AddElement(pSelectionInfoBox); } @@ -393,7 +393,7 @@ void C4MapFolderData::OnButtonScenario(C4GUI::Control *pEl) void C4MapFolderData::ResetSelection() { - pSelectedEntry = NULL; + pSelectedEntry = nullptr; } @@ -404,7 +404,7 @@ void C4MapFolderData::ResetSelection() // ------------------------------------ // Entry -C4ScenarioListLoader::Entry::Entry(class C4ScenarioListLoader *pLoader, Folder *pParent) : pLoader(pLoader), pNext(NULL), pParent(pParent), fBaseLoaded(false), fExLoaded(false) +C4ScenarioListLoader::Entry::Entry(class C4ScenarioListLoader *pLoader, Folder *pParent) : pLoader(pLoader), pNext(nullptr), pParent(pParent), fBaseLoaded(false), fExLoaded(false) { // ctor: Put into parent tree node if (pParent) @@ -549,7 +549,7 @@ C4ScenarioListLoader::Entry *C4ScenarioListLoader::Entry::CreateEntryForFile(con { // determine entry type by file type const char *szFilename = sFilename.getData(); - if (!szFilename || !*szFilename) return NULL; + if (!szFilename || !*szFilename) return nullptr; if (WildcardMatch(C4CFN_ScenarioFiles, sFilename.getData())) return new Scenario(pLoader, pParent); if (WildcardMatch(C4CFN_FolderFiles, sFilename.getData())) return new SubFolder(pLoader, pParent); // regular, open folder (C4Group-packed folders without extensions are not regarded, because they could contain anything!) @@ -561,7 +561,7 @@ C4ScenarioListLoader::Entry *C4ScenarioListLoader::Entry::CreateEntryForFile(con return new RegularFolder(pLoader, pParent); } // type not recognized - return NULL; + return nullptr; } bool C4ScenarioListLoader::Entry::RenameTo(const char *szNewName) @@ -679,7 +679,7 @@ bool C4ScenarioListLoader::Scenario::LoadCustomPre(C4Group &rGrp) ParameterDefs.Load(rGrp, &ScenarioLangStringTable); // achievement images: Loaded from this entry and parent folder nAchievements = 0; - const C4ScenarioParameterDefs *deflists[] = { pParent ? pParent->GetAchievementDefs() : NULL, &ParameterDefs }; + const C4ScenarioParameterDefs *deflists[] = { pParent ? pParent->GetAchievementDefs() : nullptr, &ParameterDefs }; for (size_t def_list_idx=0; def_list_idx<2; ++def_list_idx) { const C4ScenarioParameterDefs *deflist = deflists[def_list_idx]; @@ -700,7 +700,7 @@ bool C4ScenarioListLoader::Scenario::LoadCustomPre(C4Group &rGrp) if (!fctAchievements[nAchievements].Load(rGrp, sAchievementFilename.getData(), C4FCT_Height, C4FCT_Full, false, true)) { // look in parent folder - const C4FacetSurface *fct = NULL; + const C4FacetSurface *fct = nullptr; const C4AchievementGraphics *parent_achv_gfx; if (pParent && (parent_achv_gfx = pParent->GetAchievementGfx())) fct = parent_achv_gfx->FindByName(achievement_gfx); // look in main gfx group file @@ -901,7 +901,7 @@ void C4ScenarioListLoader::Folder::Sort() qsort(ppEntries, iCount, sizeof(Entry *), &EntrySortFunc); ppIThis = &pFirst; for (ppI = ppEntries; iCount--; ppIThis = &((*ppIThis)->pNext)) *ppIThis = *ppI++; - *ppIThis = NULL; + *ppIThis = nullptr; delete [] ppEntries; } @@ -935,7 +935,7 @@ bool C4ScenarioListLoader::Folder::LoadContents(C4ScenarioListLoader *pLoader, C // contents already loaded? if (fContentsLoaded && !fReload) return true; // clear previous - if (pMapData) { delete pMapData; pMapData = NULL; } + if (pMapData) { delete pMapData; pMapData = nullptr; } // if filename is not given, assume it's been loaded in this entry if (!psFilename) psFilename = &this->sFilename; else this->sFilename = *psFilename; // nothing loaded: Load now @@ -952,7 +952,7 @@ C4ScenarioListLoader::Entry *C4ScenarioListLoader::Folder::FindEntryByName(const if (SEqualNoCase(szFilename, GetFilename(pEntry->GetEntryFilename().getData()))) return pEntry; // nothing found - return NULL; + return nullptr; } StdStrBuf C4ScenarioListLoader::Folder::GetOpenText() @@ -1027,7 +1027,7 @@ bool C4ScenarioListLoader::SubFolder::DoLoadContents(C4ScenarioListLoader *pLoad if (szSearchMask == szC4CFN_ScenarioFiles) szSearchMask = C4CFN_FolderFiles; else - szSearchMask = NULL; + szSearchMask = nullptr; } // initial progress estimate if (!pLoader->DoProcessCallback(0, iEntryCount)) return false; @@ -1057,7 +1057,7 @@ bool C4ScenarioListLoader::SubFolder::DoLoadContents(C4ScenarioListLoader *pLoad if (szSearchMask == szC4CFN_ScenarioFiles) szSearchMask = C4CFN_FolderFiles; else - szSearchMask = NULL; + szSearchMask = nullptr; } // load map folder data if (Group.FindEntry(C4CFN_MapFolderData)) @@ -1067,7 +1067,7 @@ bool C4ScenarioListLoader::SubFolder::DoLoadContents(C4ScenarioListLoader *pLoad { // load error :( delete pMapData; - pMapData = NULL; + pMapData = nullptr; } } // done, success @@ -1137,7 +1137,7 @@ bool C4ScenarioListLoader::RegularFolder::DoLoadContents(C4ScenarioListLoader *p if (pNewEntry) { // ...and load it - if (!pNewEntry->Load(NULL, &sChildFilename, fLoadEx)) + if (!pNewEntry->Load(nullptr, &sChildFilename, fLoadEx)) { DebugLogF("Error loading entry \"%s\" in Folder \"%s\"!", szChildFilename, it->c_str()); delete pNewEntry; @@ -1160,7 +1160,7 @@ void C4ScenarioListLoader::RegularFolder::Merge(const char *szPath) // ------------------------------------ // C4ScenarioListLoader -C4ScenarioListLoader::C4ScenarioListLoader(const C4ScenarioParameters &Achievements) : Achievements(Achievements), pRootFolder(NULL), pCurrFolder(NULL), +C4ScenarioListLoader::C4ScenarioListLoader(const C4ScenarioParameters &Achievements) : Achievements(Achievements), pRootFolder(nullptr), pCurrFolder(nullptr), iLoading(0), iProgress(0), iMaxProgress(0), fAbortThis(false), fAbortPrevious(false) { } @@ -1219,13 +1219,13 @@ bool C4ScenarioListLoader::Load(const StdStrBuf &sRootFolder) { // (unthreaded) loading of all entries in root folder if (!BeginActivity(true)) return false; - if (pRootFolder) { delete pRootFolder; pRootFolder = NULL; } - pCurrFolder = pRootFolder = new RegularFolder(this, NULL); + if (pRootFolder) { delete pRootFolder; pRootFolder = nullptr; } + pCurrFolder = pRootFolder = new RegularFolder(this, nullptr); // Load regular game data if no explicit path specified if(!sRootFolder.getData()) for(C4Reloc::iterator iter = Reloc.begin(); iter != Reloc.end(); ++iter) pRootFolder->Merge(iter->strBuf.getData()); - bool fSuccess = pRootFolder->LoadContents(this, NULL, &sRootFolder, false, false); + bool fSuccess = pRootFolder->LoadContents(this, nullptr, &sRootFolder, false, false); EndActivity(); return fSuccess; } @@ -1237,7 +1237,7 @@ bool C4ScenarioListLoader::Load(Folder *pSpecifiedFolder, bool fReload) // set new current and load it if (!BeginActivity(true)) return false; pCurrFolder = pSpecifiedFolder; - bool fSuccess = pCurrFolder->LoadContents(this, NULL, NULL, false, fReload); + bool fSuccess = pCurrFolder->LoadContents(this, nullptr, nullptr, false, fReload); EndActivity(); return fSuccess; } @@ -1248,7 +1248,7 @@ bool C4ScenarioListLoader::LoadExtended(Entry *pEntry) if (!pRootFolder || !pEntry) return false; // load info of selection if (!BeginActivity(false)) return false; - bool fSuccess = pEntry->Load(NULL, NULL, true); + bool fSuccess = pEntry->Load(nullptr, nullptr, true); EndActivity(); return fSuccess; } @@ -1288,7 +1288,7 @@ const uint32_t ClrScenarioItem = 0xff000000, // ------------------------------------------------ // --- C4StartupScenSelDlg::ScenListItem C4StartupScenSelDlg::ScenListItem::ScenListItem(C4GUI::ListBox *pForListBox, C4ScenarioListLoader::Entry *pForEntry, C4GUI::Element *pInsertBeforeElement) - : pIcon(NULL), pNameLabel(NULL), pScenListEntry(pForEntry) + : pIcon(nullptr), pNameLabel(nullptr), pScenListEntry(pForEntry) { assert(pScenListEntry); CStdFont &rUseFont = C4Startup::Get()->Graphics.BookFont; @@ -1312,7 +1312,7 @@ C4StartupScenSelDlg::ScenListItem::ScenListItem(C4GUI::ListBox *pForListBox, C4S } else { - ppAchievements[i] = NULL; + ppAchievements[i] = nullptr; } } // calc own bounds - use icon bounds only, because only the height is used when the item is added @@ -1393,7 +1393,7 @@ C4GUI::RenameEdit::RenameResult C4StartupScenSelDlg::ScenListItem::DoRenaming(Re // ------------------------------------------------ // --- C4StartupScenSelDlg -C4StartupScenSelDlg::C4StartupScenSelDlg(bool fNetwork) : C4StartupDlg(LoadResStrNoAmp(fNetwork ? "IDS_DLG_NETSTART" : "IDS_DLG_STARTGAME")), pScenLoader(NULL), pMapData(NULL), pfctBackground(NULL), fIsInitialLoading(false), fStartNetworkGame(fNetwork), pRenameEdit(NULL) +C4StartupScenSelDlg::C4StartupScenSelDlg(bool fNetwork) : C4StartupDlg(LoadResStrNoAmp(fNetwork ? "IDS_DLG_NETSTART" : "IDS_DLG_STARTGAME")), pScenLoader(nullptr), pMapData(nullptr), pfctBackground(nullptr), fIsInitialLoading(false), fStartNetworkGame(fNetwork), pRenameEdit(nullptr) { // ctor // assign singleton @@ -1416,8 +1416,8 @@ C4StartupScenSelDlg::C4StartupScenSelDlg(bool fNetwork) : C4StartupDlg(LoadResSt pScenSelStyleTabular->SetSheetMargin(0); pScenSelStyleTabular->SetGfx(&C4Startup::Get()->Graphics.fctDlgPaper, &C4Startup::Get()->Graphics.fctOptionsTabClip, &C4Startup::Get()->Graphics.fctOptionsIcons, &C4Startup::Get()->Graphics.BookSmallFont, false); AddElement(pScenSelStyleTabular); - C4GUI::Tabular::Sheet *pSheetBook = pScenSelStyleTabular->AddSheet(NULL); - /* C4GUI::Tabular::Sheet *pSheetMap = */ pScenSelStyleTabular->AddSheet(NULL); + C4GUI::Tabular::Sheet *pSheetBook = pScenSelStyleTabular->AddSheet(nullptr); + /* C4GUI::Tabular::Sheet *pSheetMap = */ pScenSelStyleTabular->AddSheet(nullptr); // scenario selection list C4GUI::ComponentAligner caBook(pSheetBook->GetClientRect(), caMain.GetWidth()/20, caMain.GetHeight()/20, true); @@ -1453,7 +1453,7 @@ C4StartupScenSelDlg::C4StartupScenSelDlg(bool fNetwork) : C4StartupDlg(LoadResSt PictureHeight = C4StartupScenSel_TitlePictureHgt * AvailHeight / C4StartupScenSel_TitlePictureHgt; } pSelectionInfo = new C4GUI::TextWindow(bounds, PictureWidth+2*C4StartupScenSel_TitleOverlayMargin, PictureHeight+2*C4StartupScenSel_TitleOverlayMargin, - C4StartupScenSel_TitlePicturePadding, 100, 4096, NULL, true, &C4Startup::Get()->Graphics.fctScenSelTitleOverlay, C4StartupScenSel_TitleOverlayMargin); + C4StartupScenSel_TitlePicturePadding, 100, 4096, nullptr, true, &C4Startup::Get()->Graphics.fctScenSelTitleOverlay, C4StartupScenSel_TitleOverlayMargin); pSelectionInfo->SetDecoration(false, false, &C4Startup::Get()->Graphics.sfctBookScroll, true); pSheetBook->AddElement(pSelectionInfo); @@ -1501,7 +1501,7 @@ C4StartupScenSelDlg::C4StartupScenSelDlg(bool fNetwork) : C4StartupDlg(LoadResSt C4StartupScenSelDlg::~C4StartupScenSelDlg() { if (pScenLoader) delete pScenLoader; - if (this == pInstance) pInstance = NULL; + if (this == pInstance) pInstance = nullptr; delete pKeyCheat; delete pKeyDelete; delete pKeyRename; @@ -1540,7 +1540,7 @@ void C4StartupScenSelDlg::OnClosed(bool fOK) if (pScenLoader) { delete pScenLoader; - pScenLoader = NULL; + pScenLoader = nullptr; UpdateList(); // must clear scenario list, because it points to deleted stuff UpdateSelection(); // must clear picture facet of selection! } @@ -1548,7 +1548,7 @@ void C4StartupScenSelDlg::OnClosed(bool fOK) if (!fOK) { // clear settings: Password - ::Network.SetPassword(NULL); + ::Network.SetPassword(nullptr); C4Startup::Get()->SwitchDialog(C4Startup::SDID_Back); } } @@ -1557,12 +1557,12 @@ void C4StartupScenSelDlg::UpdateList() { AbortRenaming(); // default: Show book (also for loading screen) - pMapData = NULL; + pMapData = nullptr; pScenSelStyleTabular->SelectSheet(ShowStyle_Book, false); // and delete any stuff from map selection C4GUI::Tabular::Sheet *pMapSheet = pScenSelStyleTabular->GetSheet(ShowStyle_Map); while (pMapSheet->GetFirst()) delete pMapSheet->GetFirst(); - pfctBackground = NULL; + pfctBackground = nullptr; // for now, all the list is loaded at once anyway // so just clear and add all loaded items // remember old selection @@ -1643,7 +1643,7 @@ void C4StartupScenSelDlg::UpdateSelection() // no selection: Display data of current parent folder pSel = pScenLoader->GetCurrFolder(); // but not root - if (pSel == pScenLoader->GetRootFolder()) pSel = NULL; + if (pSel == pScenLoader->GetRootFolder()) pSel = nullptr; } // get title image and desc of selected entry C4Facet fctTitle; StdStrBuf sTitle, sDesc, sVersion, sAuthor; @@ -1680,7 +1680,7 @@ void C4StartupScenSelDlg::UpdateSelection() pSelectionOptions->Update(); } else - pSelectionOptions->SetParameters(NULL, NULL); + pSelectionOptions->SetParameters(nullptr, nullptr); // update component heights C4Rect rcSelBounds = pSelectionInfo->GetBounds(); int32_t ymax = pSelectionOptions->GetBounds().GetBottom(); @@ -1718,7 +1718,7 @@ C4ScenarioListLoader::Entry *C4StartupScenSelDlg::GetSelectedEntry() if (pMapData) return pMapData->GetSelectedEntry(); // get selection in listbox ScenListItem *pSel = static_cast(pScenSelList->GetSelectedItem()); - return pSel ? pSel->GetEntry() : NULL; + return pSel ? pSel->GetEntry() : nullptr; } bool C4StartupScenSelDlg::StartScenario(C4ScenarioListLoader::Scenario *pStartScen) @@ -1928,7 +1928,7 @@ void C4StartupScenSelDlg::DeselectAll() { // Deselect all so current folder info is displayed if (GetFocus()) C4GUI::GUISound("UI::Tick"); - SetFocus(NULL, true); + SetFocus(nullptr, true); if (pMapData) pMapData->ResetSelection(); UpdateSelection(); } diff --git a/src/gui/C4StartupScenSelDlg.h b/src/gui/C4StartupScenSelDlg.h index 8667e6a98..3e2fa7e41 100644 --- a/src/gui/C4StartupScenSelDlg.h +++ b/src/gui/C4StartupScenSelDlg.h @@ -71,7 +71,7 @@ public: virtual bool LoadCustom(C4Group &rGrp, bool fNameLoaded, bool fIconLoaded) { return true; } // load custom data for entry type (e.g. scenario title fallback in Scenario.txt) virtual bool LoadCustomPre(C4Group &rGrp) { return true; } // preload stuff that's early in the group (Scenario.txt) virtual bool Start() = 0; // start/open entry - virtual Folder *GetIsFolder() { return NULL; } // return this if this is a folder + virtual Folder *GetIsFolder() { return nullptr; } // return this if this is a folder const StdStrBuf &GetName() const { return sName; } const StdStrBuf &GetEntryFilename() const { return sFilename; } @@ -98,13 +98,13 @@ public: virtual StdStrBuf GetOpenText() = 0; // get open button text virtual StdStrBuf GetOpenTooltip() = 0; - virtual const char *GetDefaultExtension() { return NULL; } // extension to be added when item is renamed + virtual const char *GetDefaultExtension() { return nullptr; } // extension to be added when item is renamed virtual bool SetTitleInGroup(C4Group &rGrp, const char *szNewTitle); bool RenameTo(const char *szNewName); // change name+filename virtual bool IsScenario() { return false; } - virtual C4ScenarioParameterDefs *GetParameterDefs() { return NULL; } - virtual C4ScenarioParameters *GetParameters() { return NULL; } + virtual C4ScenarioParameterDefs *GetParameterDefs() { return nullptr; } + virtual C4ScenarioParameters *GetParameters() { return nullptr; } }; // a loaded scenario to be started @@ -158,7 +158,7 @@ public: friend class Entry; public: - Folder(class C4ScenarioListLoader *pLoader, Folder *pParent) : Entry(pLoader, pParent), fContentsLoaded(false), pFirst(NULL), pMapData(NULL) {} + Folder(class C4ScenarioListLoader *pLoader, Folder *pParent) : Entry(pLoader, pParent), fContentsLoaded(false), pFirst(nullptr), pMapData(nullptr) {} virtual ~Folder(); virtual bool LoadCustomPre(C4Group &rGrp); // load folder core @@ -184,8 +184,8 @@ public: virtual StdStrBuf GetOpenTooltip(); C4MapFolderData *GetMapData() const { return pMapData; } - virtual const C4ScenarioParameterDefs *GetAchievementDefs() const { return NULL; } - virtual const C4AchievementGraphics *GetAchievementGfx() const { return NULL; } + virtual const C4ScenarioParameterDefs *GetAchievementDefs() const { return nullptr; } + virtual const C4AchievementGraphics *GetAchievementGfx() const { return nullptr; } }; // .ocf subfolder: Read through by group @@ -256,7 +256,7 @@ public: bool FolderBack(); // go upwards by one folder bool ReloadCurrent(); // reload file list bool IsLoading() const { return !!iLoading; } - Entry *GetFirstEntry() const { return pCurrFolder ? pCurrFolder->GetFirstEntry() : NULL; } + Entry *GetFirstEntry() const { return pCurrFolder ? pCurrFolder->GetFirstEntry() : nullptr; } Folder *GetCurrFolder() const { return pCurrFolder; } Folder *GetRootFolder() const { return pRootFolder; } @@ -345,7 +345,7 @@ private: class C4StartupScenSelDlg *pMainDlg; public: - C4MapFolderData() : fCoordinatesAdjusted(false), ppScenList(NULL), iScenCount(0), ppAccessGfxList(NULL), iAccessGfxCount(0), pMainDlg(NULL) {} + C4MapFolderData() : fCoordinatesAdjusted(false), ppScenList(nullptr), iScenCount(0), ppAccessGfxList(nullptr), iAccessGfxCount(0), pMainDlg(nullptr) {} ~C4MapFolderData() { Clear(); } private: @@ -390,7 +390,7 @@ public: C4ScenarioListLoader::Entry *pScenListEntry; // associated, loaded item info public: - ScenListItem(C4GUI::ListBox *pForListBox, C4ScenarioListLoader::Entry *pForEntry, C4GUI::Element *pInsertBeforeElement=NULL); + ScenListItem(C4GUI::ListBox *pForListBox, C4ScenarioListLoader::Entry *pForEntry, C4GUI::Element *pInsertBeforeElement=nullptr); protected: struct RenameParams { }; @@ -499,7 +499,7 @@ public: void StartRenaming(C4GUI::RenameEdit *pNewRenameEdit); void AbortRenaming(); bool IsRenaming() const { return !!pRenameEdit; } - void SetRenamingDone() { pRenameEdit=NULL; } + void SetRenamingDone() { pRenameEdit=nullptr; } void SetBackground(C4Facet *pNewBG) { pfctBackground=pNewBG; } diff --git a/src/gui/C4UpdateDlg.cpp b/src/gui/C4UpdateDlg.cpp index 5f502bfe7..6f2c31af4 100644 --- a/src/gui/C4UpdateDlg.cpp +++ b/src/gui/C4UpdateDlg.cpp @@ -153,7 +153,7 @@ void C4UpdateDlg::RedirectToDownloadPage() bool C4UpdateDlg::DoUpdate(const char *szUpdateURL, C4GUI::Screen *pScreen) { - if(szUpdateURL == NULL || strlen(szUpdateURL) == 0) + if(szUpdateURL == nullptr || strlen(szUpdateURL) == 0) { pScreen->ShowMessageModal(LoadResStr("IDS_MSG_NEWRELEASEAVAILABLE"), LoadResStr("IDS_TYPE_UPDATE"),C4GUI::MessageDialog::btnOK, C4GUI::Ico_Ex_Update); RedirectToDownloadPage(); @@ -248,7 +248,7 @@ bool C4UpdateDlg::ApplyUpdate(const char *strUpdateFile, bool fDeleteUpdate, C4G #ifdef _WIN32 // Notice: even if the update program and update group are in the temp path, they must be executed in our working directory // the magic verb "runas" opens the update program in a shell requesting elevation - int iError = (intptr_t)ShellExecute(NULL, L"runas", strUpdateProgEx.GetWideChar(), strUpdateArgs.GetWideChar(), Config.General.ExePath.GetWideChar(), SW_SHOW); + int iError = (intptr_t)ShellExecute(nullptr, L"runas", strUpdateProgEx.GetWideChar(), strUpdateArgs.GetWideChar(), Config.General.ExePath.GetWideChar(), SW_SHOW); if (iError <= 32) return false; // must quit ourselves for update program to work @@ -298,7 +298,7 @@ bool C4UpdateDlg::ApplyUpdate(const char *strUpdateFile, bool fDeleteUpdate, C4G bool C4UpdateDlg::IsValidUpdate(const char *szVersion) { StdStrBuf strVersion; strVersion.Format("%d.%d", C4XVER1, C4XVER2); - if (szVersion == NULL || strlen(szVersion) == 0) return false; + if (szVersion == nullptr || strlen(szVersion) == 0) return false; return strcmp(szVersion,strVersion.getData()) != 0; } @@ -306,14 +306,14 @@ bool C4UpdateDlg::CheckForUpdates(C4GUI::Screen *pScreen, bool fAutomatic) { // Automatic update only once a day if (fAutomatic) - if (time(NULL) - Config.Network.LastUpdateTime < 60 * 60 * 24) + if (time(nullptr) - Config.Network.LastUpdateTime < 60 * 60 * 24) return false; // Store the time of this update check (whether it's automatic or not or successful or not) - Config.Network.LastUpdateTime = time(NULL); + Config.Network.LastUpdateTime = time(nullptr); // Get current update url and version info from server StdStrBuf UpdateURL; StdStrBuf VersionInfo; - C4GUI::Dialog *pWaitDlg = NULL; + C4GUI::Dialog *pWaitDlg = nullptr; pWaitDlg = new C4GUI::MessageDialog(LoadResStr("IDS_MSG_LOOKINGFORUPDATES"), LoadResStr("IDS_TYPE_UPDATE"), C4GUI::MessageDialog::btnAbort, C4GUI::Ico_Ex_Update, C4GUI::MessageDialog::dsRegular); pWaitDlg->SetDelOnClose(false); pScreen->ShowDialog(pWaitDlg, false); @@ -340,7 +340,7 @@ bool C4UpdateDlg::CheckForUpdates(C4GUI::Screen *pScreen, bool fAutomatic) UpdateClient.GetUpdateURL(&UpdateURL); } Application.InteractiveThread.RemoveProc(&UpdateClient); - UpdateClient.SetNotify(NULL); + UpdateClient.SetNotify(nullptr); } delete pWaitDlg; // User abort diff --git a/src/gui/C4UpperBoard.cpp b/src/gui/C4UpperBoard.cpp index 28426e6fd..32fbc8c2a 100644 --- a/src/gui/C4UpperBoard.cpp +++ b/src/gui/C4UpperBoard.cpp @@ -42,7 +42,7 @@ void C4UpperBoard::Draw(C4Facet &cgo) { if (!cgo.Surface) return; // Background - pDraw->BlitSurfaceTile(::GraphicsResource.fctUpperBoard.Surface,Output.Surface,0,0,Output.Wdt,Output.Hgt,0,0,NULL); + pDraw->BlitSurfaceTile(::GraphicsResource.fctUpperBoard.Surface,Output.Surface,0,0,Output.Wdt,Output.Hgt,0,0,nullptr); // Logo C4Facet cgo2; float fLogoZoom = 1.0f; diff --git a/src/landscape/C4Landscape.cpp b/src/landscape/C4Landscape.cpp index afc7b4a57..f75a23f82 100644 --- a/src/landscape/C4Landscape.cpp +++ b/src/landscape/C4Landscape.cpp @@ -111,10 +111,10 @@ struct C4Landscape::P bool SaveDiffInternal(const C4Landscape *d, C4Group &hGroup, bool fSyncSave) const; int32_t ForPolygon(C4Landscape *d, int *vtcs, int length, const std::function &callback, - C4MaterialList *mats_count = NULL, uint8_t col = 0, uint8_t colBkg = 0, uint8_t *conversion_table = NULL); + C4MaterialList *mats_count = nullptr, uint8_t col = 0, uint8_t colBkg = 0, uint8_t *conversion_table = nullptr); std::unique_ptr CreateDefaultBkgSurface(CSurface8& sfcFg, bool msbAsIft) const; - void DigMaterial2Objects(int32_t tx, int32_t ty, C4MaterialList *mat_list, C4Object *pCollect = NULL); + void DigMaterial2Objects(int32_t tx, int32_t ty, C4MaterialList *mat_list, C4Object *pCollect = nullptr); void BlastMaterial2Objects(int32_t tx, int32_t ty, C4MaterialList *mat_list, int32_t caused_by, int32_t str, C4ValueArray *out_objects); bool DigFreePix(C4Landscape *d, int32_t tx, int32_t ty); @@ -532,7 +532,7 @@ C4ValueArray *C4Landscape::P::PrepareFreeShape(C4Rect &BoundingBox, C4Object *by // Remember any in-earth objects in area C4FindObjectInRect fo_inrect(BoundingBox); C4FindObjectOCF fo_insolid(OCF_InSolid); - C4FindObjectLayer fo_layer(by_object ? by_object->Layer : NULL); + C4FindObjectLayer fo_layer(by_object ? by_object->Layer : nullptr); C4FindObject *fo_list[] = { &fo_inrect, &fo_insolid, &fo_layer }; C4FindObjectAndStatic fo_srch(3, fo_list); return fo_srch.FindMany(::Objects, ::Objects.Sectors); @@ -585,7 +585,7 @@ int32_t C4Landscape::DigFreeShape(int *vtcs, int length, C4Object *by_object, bo amount = p->ForPolygon(this, vtcs, length / 2, callback, by_object->MaterialContents); } else - amount = p->ForPolygon(this, vtcs, length / 2, callback, NULL); + amount = p->ForPolygon(this, vtcs, length / 2, callback, nullptr); // create objects from the material if (!::Game.iTick5) @@ -607,14 +607,14 @@ int32_t C4Landscape::DigFreeShape(int *vtcs, int length, C4Object *by_object, bo void C4Landscape::BlastFreeShape(int *vtcs, int length, C4Object *by_object, int32_t by_player, int32_t iMaxDensity) { - C4MaterialList *MaterialContents = NULL; + C4MaterialList *MaterialContents = nullptr; C4Rect BoundingBox = getBoundingBox(vtcs, length); // Remember any collectible objects in area std::unique_ptr dig_objects(p->PrepareFreeShape(BoundingBox, by_object)); - uint8_t *pblast_tbl = NULL, blast_tbl[C4M_MaxTexIndex]; + uint8_t *pblast_tbl = nullptr, blast_tbl[C4M_MaxTexIndex]; if (iMaxDensity < C4M_Vehicle) { for (int32_t i = 0; i < C4M_MaxTexIndex; ++i) blast_tbl[i] = (GetPixDensity(i) <= iMaxDensity); @@ -634,7 +634,7 @@ void C4Landscape::BlastFreeShape(int *vtcs, int length, C4Object *by_object, int } // create objects from the material - C4MaterialList *mat_list = NULL; + C4MaterialList *mat_list = nullptr; if (by_object) mat_list = by_object->MaterialContents; else @@ -669,7 +669,7 @@ void C4Landscape::P::BlastMaterial2Objects(int32_t tx, int32_t ty, C4MaterialLis if (::MaterialMap.Map[mat].Blast2ObjectRatio != 0) { blastamount = mat_list->Amount[mat] / ::MaterialMap.Map[mat].Blast2ObjectRatio; - Game.CastObjects(::MaterialMap.Map[mat].Blast2Object, NULL, blastamount, cast_strength, tx, ty, NO_OWNER, caused_by, out_objects); + Game.CastObjects(::MaterialMap.Map[mat].Blast2Object, nullptr, blastamount, cast_strength, tx, ty, NO_OWNER, caused_by, out_objects); } } @@ -691,7 +691,7 @@ void C4Landscape::P::DigMaterial2Objects(int32_t tx, int32_t ty, C4MaterialList while (mat_list->Amount[mat] >= ::MaterialMap.Map[mat].Dig2ObjectRatio) { mat_list->Amount[mat] -= ::MaterialMap.Map[mat].Dig2ObjectRatio; - C4Object *pObj = Game.CreateObject(::MaterialMap.Map[mat].Dig2Object, NULL, NO_OWNER, tx, ty); + C4Object *pObj = Game.CreateObject(::MaterialMap.Map[mat].Dig2Object, nullptr, NO_OWNER, tx, ty); if (!pObj || !pObj->Status) continue; // Set controller to the controller of the object responsible for digging out if (pCollect && pCollect->Status) @@ -1040,7 +1040,7 @@ bool C4Landscape::InsertMaterial(int32_t mat, int32_t *tx, int32_t *ty, int32_t if ((pReact = ::MaterialMap.GetReactionUnsafe(mat, tmat = GetMat(*tx, *ty + check_dir)))) { C4Real fvx = C4REAL10(vx), fvy = C4REAL10(vy); - if ((*pReact->pFunc)(pReact, *tx, *ty, *tx, *ty + check_dir, fvx, fvy, mat, tmat, meePXSPos, NULL)) + if ((*pReact->pFunc)(pReact, *tx, *ty, *tx, *ty + check_dir, fvx, fvy, mat, tmat, meePXSPos, nullptr)) { // the material to be inserted killed itself in some material reaction below return true; @@ -1112,7 +1112,7 @@ std::unique_ptr C4Landscape::P::CreateDefaultBkgSurface(CSurface8& sf auto sfcBg = std::make_unique(); if (!sfcBg->Create(sfcFg.Wdt, sfcFg.Hgt)) { - return NULL; + return nullptr; } for (int32_t y = 0; y < sfcFg.Hgt; ++y) @@ -1179,8 +1179,8 @@ static void fill_edge_structure(CPolyEdge *edge, int *i1, int *i2) edge->bottom = i2[1] - 1; edge->dx = ((i2[0] - i1[0]) << POLYGON_FIX_SHIFT) / (i2[1] - i1[1]); edge->x = (i1[0] << POLYGON_FIX_SHIFT) + (1 << (POLYGON_FIX_SHIFT - 1)) - 1; - edge->prev = NULL; - edge->next = NULL; + edge->prev = nullptr; + edge->next = nullptr; if (edge->dx < 0) edge->x += std::min(edge->dx + (1 << POLYGON_FIX_SHIFT), 0); edge->w = std::max(Abs(edge->dx) - (1 << POLYGON_FIX_SHIFT), 0); @@ -1189,7 +1189,7 @@ static void fill_edge_structure(CPolyEdge *edge, int *i1, int *i2) static CPolyEdge *add_edge(CPolyEdge *list, CPolyEdge *edge, int sort_by_x) { CPolyEdge *pos = list; - CPolyEdge *prev = NULL; + CPolyEdge *prev = nullptr; if (sort_by_x) { while ((pos) && (pos->x + pos->w / 2 < edge->x + edge->w / 2)) @@ -1231,8 +1231,8 @@ int32_t C4Landscape::P::ForPolygon(C4Landscape *d, int *vtcs, int length, const int bottom = INT_MIN; int *i1, *i2; CPolyEdge *edge, *next_edge, *edgebuf; - CPolyEdge *active_edges = NULL; - CPolyEdge *inactive_edges = NULL; + CPolyEdge *active_edges = nullptr; + CPolyEdge *inactive_edges = nullptr; bool use_qpb = false; // Return value @@ -1431,12 +1431,12 @@ void C4Landscape::CompileFunc(StdCompiler *pComp) static std::unique_ptr GroupReadSurface8(C4Group &hGroup, const char *szWildCard) { if (!hGroup.AccessEntry(szWildCard)) - return NULL; + return nullptr; // create surface auto pSfc = std::make_unique(); if (!pSfc->Read(hGroup)) { - return NULL; + return nullptr; } return pSfc; } @@ -1540,7 +1540,7 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo return true; } - assert(sfcMapBkg != NULL); + assert(sfcMapBkg != nullptr); if (Config.General.DebugRec) { @@ -1565,8 +1565,8 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo if (fOverloadCurrent) Clear(!Game.C4S.Landscape.KeepMapCreator, fLoadSky, false); // assign new map - assert(p->Map == NULL); - assert(p->MapBkg == NULL); + assert(p->Map == nullptr); + assert(p->MapBkg == nullptr); p->Map = std::move(sfcMap); p->MapBkg = std::move(sfcMapBkg); @@ -1610,8 +1610,8 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo // (not for shaders though - they require continous textures) if (!Game.C4S.Landscape.ExactLandscape) { - assert(p->Surface8 == NULL); - assert(p->Surface8Bkg == NULL); + assert(p->Surface8 == nullptr); + assert(p->Surface8Bkg == nullptr); // Create landscape surfaces { @@ -1649,7 +1649,7 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo } // Create FoW - assert(p->pFoW == NULL); + assert(p->pFoW == nullptr); if (Game.C4S.Game.FoWEnabled) p->pFoW.reset(new C4FoW); @@ -1705,7 +1705,7 @@ bool C4Landscape::Init(C4Group &hGroup, bool fOverloadCurrent, bool fLoadSky, bo bool C4Landscape::HasMap() const { - return p->Map != NULL && p->MapBkg != NULL; + return p->Map != nullptr && p->MapBkg != nullptr; } bool C4Landscape::Save(C4Group &hGroup) const @@ -1972,7 +1972,7 @@ bool C4Landscape::SaveMap(C4Group &hGroup) const { // No map if (!p->Map) return false; - assert(p->MapBkg != NULL); + assert(p->MapBkg != nullptr); // Create map palette CStdPalette Palette; @@ -2140,7 +2140,7 @@ void C4Landscape::P::DrawChunk(C4Landscape *d, int32_t tx, int32_t ty, int32_t w vtcs[12] = tx + wdt + ChunkyRandom(cro, rx * side_rough / 4); vtcs[13] = ty - ChunkyRandom(cro, rx * top_rough / 4); vtcs[14] = tx + wdt / 2; vtcs[15] = ty - ChunkyRandom(cro, rx * top_rough / 2); - ForPolygon(d, vtcs, 8, NULL, NULL, mcol, mcolBkg); + ForPolygon(d, vtcs, 8, nullptr, nullptr, mcol, mcolBkg); } void C4Landscape::P::DrawSmoothOChunk(C4Landscape *d, int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, uint8_t mcol, uint8_t mcolBkg, int flip, uint32_t cro) @@ -2165,7 +2165,7 @@ void C4Landscape::P::DrawSmoothOChunk(C4Landscape *d, int32_t tx, int32_t ty, in case 7: vtcs[6] = tx + wdt / 2; vtcs[7] += hgt / 2; break; } - ForPolygon(d, vtcs, 4, NULL, NULL, mcol, mcolBkg); + ForPolygon(d, vtcs, 4, nullptr, nullptr, mcol, mcolBkg); } void C4Landscape::P::ChunkOZoom(C4Landscape *d, const CSurface8 &sfcMap, const CSurface8 &sfcMapBkg, int32_t iMapX, int32_t iMapY, int32_t iMapWdt, int32_t iMapHgt, uint8_t iTexture, int32_t iOffX, int32_t iOffY) @@ -2175,7 +2175,7 @@ void C4Landscape::P::ChunkOZoom(C4Landscape *d, const CSurface8 &sfcMap, const C if (!pMaterial) return; const char *texture_name = entry->GetTextureName(); C4Texture *texture = ::TextureMap.GetTexture(texture_name); - C4TextureShape *shape = texture ? texture->GetMaterialShape() : NULL; + C4TextureShape *shape = texture ? texture->GetMaterialShape() : nullptr; // Chunk type by material C4MaterialCoreShape iChunkType = ::Game.C4S.Landscape.FlatChunkShapes ? C4M_Flat : pMaterial->MapChunkType; // Get map & landscape size @@ -2420,7 +2420,7 @@ bool C4Landscape::P::CreateMapS2(C4Group &ScenFile, CSurface8*& sfcMap, CSurface // read file pMapCreator->ReadFile(C4CFN_DynLandscape, &ScenFile); // render landscape - if (!pMapCreator->Render(NULL, sfcMap, sfcMapBkg)) + if (!pMapCreator->Render(nullptr, sfcMap, sfcMapBkg)) return false; // keep map creator until script callbacks have been done @@ -3609,14 +3609,14 @@ bool C4Landscape::DrawPolygon(int *vtcs, int length, const char *szMaterial, con uint8_t mcol = MatTex2PixCol(iMatTex); // get background texture uint8_t mcolBkg = 0; - if (szBackMaterial != NULL) + if (szBackMaterial != nullptr) { const int32_t iBackMatTex = ::TextureMap.GetIndexMatTex(szBackMaterial); if (!iBackMatTex) return false; mcolBkg = MatTex2PixCol(iBackMatTex); } // do bridging? - uint8_t *conversion_map = NULL; + uint8_t *conversion_map = nullptr; if (fDrawBridge) { conversion_map = p->GetBridgeMatConversion(this, MatTex2PixCol(iMatTex)); @@ -3626,14 +3626,14 @@ bool C4Landscape::DrawPolygon(int *vtcs, int length, const char *szMaterial, con C4Rect BoundingBox = getBoundingBox(vtcs, length); // draw polygon p->PrepareChange(this, BoundingBox); - p->ForPolygon(this, vtcs, length / 2, NULL, NULL, mcol, mcolBkg, conversion_map); + p->ForPolygon(this, vtcs, length / 2, nullptr, nullptr, mcol, mcolBkg, conversion_map); p->FinishChange(this, BoundingBox); return true; } CStdPalette * C4Landscape::GetPal() const { - return p->Surface8 ? p->Surface8->pPal : NULL; + return p->Surface8 ? p->Surface8->pPal : nullptr; } int32_t C4Landscape::GetWidth() const @@ -3842,7 +3842,7 @@ uint8_t *C4Landscape::P::GetBridgeMatConversion(const C4Landscape *d, int32_t fo { // safety int32_t for_material = d->GetPixMat(for_material_col); - if (for_material < 0 || for_material >= MaterialMap.Num) return NULL; + if (for_material < 0 || for_material >= MaterialMap.Num) return nullptr; // query map. create if not done yet if (!BridgeMatConversion[for_material_col]) { @@ -3950,9 +3950,9 @@ bool C4Landscape::DrawMap(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, co // read file MapCreator.ReadScript(szMapDef); // render map - CSurface8* sfcMap = NULL; - CSurface8* sfcMapBkg = NULL; - if (!MapCreator.Render(NULL, sfcMap, sfcMapBkg)) + CSurface8* sfcMap = nullptr; + CSurface8* sfcMapBkg = nullptr; + if (!MapCreator.Render(nullptr, sfcMap, sfcMapBkg)) return false; // map it to the landscape bool fSuccess = p->MapToLandscape(this, *sfcMap, *sfcMapBkg, 0, 0, iMapWdt, iMapHgt, iX, iY, ignoreSky); @@ -3977,8 +3977,8 @@ bool C4Landscape::DrawDefMap(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, C4MCMap *pMap = p->pMapCreator->GetMap(szMapDef); if (!pMap) return false; pMap->SetSize(iMapWdt, iMapHgt); - CSurface8* sfcMap = NULL; - CSurface8* sfcMapBkg = NULL; + CSurface8* sfcMap = nullptr; + CSurface8* sfcMapBkg = nullptr; if (p->pMapCreator->Render(szMapDef, sfcMap, sfcMapBkg)) { // map to landscape diff --git a/src/landscape/C4Landscape.h b/src/landscape/C4Landscape.h index 9c798e0fc..9e5ef3751 100644 --- a/src/landscape/C4Landscape.h +++ b/src/landscape/C4Landscape.h @@ -156,14 +156,14 @@ public: int32_t GetMatCount(int material) const; int32_t GetEffectiveMatCount(int material) const; - int32_t DigFreeShape(int *vtcs, int length, C4Object *by_object = NULL, bool no_dig2objects = false, bool no_instability_check = false); - void BlastFreeShape(int *vtcs, int length, C4Object *by_object = NULL, int32_t by_player = NO_OWNER, int32_t iMaxDensity = C4M_Vehicle); + int32_t DigFreeShape(int *vtcs, int length, C4Object *by_object = nullptr, bool no_dig2objects = false, bool no_instability_check = false); + void BlastFreeShape(int *vtcs, int length, C4Object *by_object = nullptr, int32_t by_player = NO_OWNER, int32_t iMaxDensity = C4M_Vehicle); void ClearFreeRect(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt); - int32_t DigFreeRect(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, C4Object *by_object = NULL, bool no_dig2objects = false, bool no_instability_check = false); - int32_t DigFree(int32_t tx, int32_t ty, int32_t rad, C4Object *by_object = NULL, bool no_dig2objects = false, bool no_instability_check = false); + int32_t DigFreeRect(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, C4Object *by_object = nullptr, bool no_dig2objects = false, bool no_instability_check = false); + int32_t DigFree(int32_t tx, int32_t ty, int32_t rad, C4Object *by_object = nullptr, bool no_dig2objects = false, bool no_instability_check = false); void ShakeFree(int32_t tx, int32_t ty, int32_t rad); - void BlastFree(int32_t tx, int32_t ty, int32_t rad, int32_t caused_by = NO_OWNER, C4Object *by_object = NULL, int32_t iMaxDensity = C4M_Vehicle); + void BlastFree(int32_t tx, int32_t ty, int32_t rad, int32_t caused_by = NO_OWNER, C4Object *by_object = nullptr, int32_t iMaxDensity = C4M_Vehicle); void CheckInstabilityRange(int32_t tx, int32_t ty); bool CheckInstability(int32_t tx, int32_t ty, int32_t recursion_count=0); @@ -191,9 +191,9 @@ bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt, int32_t bool FindThrowingPosition(int32_t iTx, int32_t iTy, C4Real fXDir, C4Real fYDir, int32_t iHeight, int32_t &rX, int32_t &rY); bool PathFree(int32_t x1, int32_t y1, int32_t x2, int32_t y2); bool PathFree(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *ix, int32_t *iy); -bool PathFreeIgnoreVehicle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *ix=NULL, int32_t *iy=NULL); +bool PathFreeIgnoreVehicle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *ix=nullptr, int32_t *iy=nullptr); bool FindClosestFree(int32_t &rX, int32_t &rY, int32_t iAngle1, int32_t iAngle2, int32_t iExcludeAngle1, int32_t iExcludeAngle2); -bool ConstructionCheck(C4PropList *, int32_t iX, int32_t iY, C4Object *pByObj=NULL); +bool ConstructionCheck(C4PropList *, int32_t iX, int32_t iY, C4Object *pByObj=nullptr); int32_t PixCol2Mat(BYTE pixc); inline bool DensitySolid(int32_t dens) diff --git a/src/landscape/C4LandscapeRender.cpp b/src/landscape/C4LandscapeRender.cpp index 6f4f6c033..4d6df434a 100644 --- a/src/landscape/C4LandscapeRender.cpp +++ b/src/landscape/C4LandscapeRender.cpp @@ -122,7 +122,7 @@ bool C4LandscapeRenderGL::ReInit(int32_t iWidth, int32_t iHeight) for (int i = 0; i < C4LR_SurfaceCount; i++) { delete Surfaces[i]; - Surfaces[i] = NULL; + Surfaces[i] = nullptr; } // Allocate new landscape textures @@ -143,7 +143,7 @@ void C4LandscapeRenderGL::Clear() for (i = 0; i < C4LR_SurfaceCount; i++) { delete Surfaces[i]; - Surfaces[i] = NULL; + Surfaces[i] = nullptr; } if (hMaterialTexture) glDeleteTextures(1, &hMaterialTexture); hMaterialTexture = 0; @@ -204,7 +204,7 @@ bool C4LandscapeRenderGL::InitMaterialTexture(C4TextureMap *pTexs) int32_t iNormalDepth = iMaterialTextureDepth / 2; // Find the largest texture - C4Texture *pTex; C4Surface *pRefSfc = NULL; + C4Texture *pTex; C4Surface *pRefSfc = nullptr; for(int iTexIx = 0; (pTex = pTexs->GetTexture(pTexs->GetTexture(iTexIx))); iTexIx++) if(C4Surface *pSfc = pTex->Surface32) if (!pRefSfc || pRefSfc->Wdt < pSfc->Wdt || pRefSfc->Hgt < pSfc->Hgt) @@ -602,7 +602,7 @@ bool C4LandscapeRenderGL::LoadShader(C4GroupSet *pGroups, C4Shader& shader, cons AttributeNames[C4LRA_Position] = "oc_Position"; AttributeNames[C4LRA_LandscapeTexCoord] = "oc_LandscapeTexCoord"; AttributeNames[C4LRA_LightTexCoord] = "oc_LightTexCoord"; // unused if no dynamic light - AttributeNames[C4LRA_Count] = NULL; + AttributeNames[C4LRA_Count] = nullptr; // Initialise! if (!shader.Init(name, UniformNames, AttributeNames)) { @@ -650,7 +650,7 @@ bool C4LandscapeRenderGL::InitVBO() assert(hVBO == 0); glGenBuffers(1, &hVBO); glBindBuffer(GL_ARRAY_BUFFER, hVBO); - glBufferData(GL_ARRAY_BUFFER, 24 * sizeof(float), NULL, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 24 * sizeof(float), nullptr, GL_STREAM_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); // Also allocate the VAO IDs assert(hVAOIDLight == 0); diff --git a/src/landscape/C4LandscapeRender.h b/src/landscape/C4LandscapeRender.h index bc8d929f0..d7ee59dae 100644 --- a/src/landscape/C4LandscapeRender.h +++ b/src/landscape/C4LandscapeRender.h @@ -80,7 +80,7 @@ class C4LandscapeRender { public: C4LandscapeRender() - : iWidth(0), iHeight(0), pTexs(NULL) { } + : iWidth(0), iHeight(0), pTexs(nullptr) { } virtual ~C4LandscapeRender() {} diff --git a/src/landscape/C4Map.cpp b/src/landscape/C4Map.cpp index e7a24d220..73e7d3f7f 100644 --- a/src/landscape/C4Map.cpp +++ b/src/landscape/C4Map.cpp @@ -31,7 +31,7 @@ C4MapCreator::C4MapCreator() void C4MapCreator::Reset() { - MapBuf=NULL; + MapBuf=nullptr; Exclusive=-1; } diff --git a/src/landscape/C4MapCreatorS2.cpp b/src/landscape/C4MapCreatorS2.cpp index 92382f992..91d8573c8 100644 --- a/src/landscape/C4MapCreatorS2.cpp +++ b/src/landscape/C4MapCreatorS2.cpp @@ -81,7 +81,7 @@ C4MCCallbackArray::C4MCCallbackArray(C4AulFunc *pSFunc, C4MapCreatorS2 *pMapCrea // store fn pSF = pSFunc; // zero fields - pMap=NULL; pNext=NULL; + pMap=nullptr; pNext=nullptr; // store and add in map creator if ((this->pMapCreator=pMapCreator)) pMapCreator->CallbackArrays.Add(this); @@ -134,7 +134,7 @@ void C4MCCallbackArray::Execute(int32_t iMapZoom) Pars[0] = C4VInt((iIndex%iWdt) * iMapZoom - (iMapZoom/2)); Pars[1] = C4VInt((iIndex/iWdt) * iMapZoom - (iMapZoom/2)); // call - pSF->Exec(NULL, &Pars); + pSF->Exec(nullptr, &Pars); } // done } @@ -165,7 +165,7 @@ void C4MCCallbackArrayList::Clear() delete pArray; } // zero first-field - pFirst=NULL; + pFirst=nullptr; } void C4MCCallbackArrayList::Execute(int32_t iMapZoom) @@ -191,7 +191,7 @@ C4MCNode::C4MCNode(C4MCNode *pOwner) C4MCNode::C4MCNode(C4MCParser* pParser, C4MCNode *pOwner, C4MCNode &rTemplate, bool fClone) { // Make sure the template is not used recursively within itself - for(C4MCNode* pParent = pOwner; pParent != NULL; pParent = pParent->Owner) + for(C4MCNode* pParent = pOwner; pParent != nullptr; pParent = pParent->Owner) if(pParent == &rTemplate) throw C4MCParserErr(pParser, C4MCErr_NoRecTemplate, rTemplate.Name); // set owner and stuff @@ -215,7 +215,7 @@ C4MCNode::~C4MCNode() void C4MCNode::Reg2Owner(C4MCNode *pOwner) { // init list - Child0=ChildL=NULL; + Child0=ChildL=nullptr; // owner? if ((Owner=pOwner)) { @@ -229,11 +229,11 @@ void C4MCNode::Reg2Owner(C4MCNode *pOwner) } else { - Prev=NULL; - MapCreator=NULL; + Prev=nullptr; + MapCreator=nullptr; } // we're always last entry - Next=NULL; + Next=nullptr; } void C4MCNode::Clear() @@ -248,7 +248,7 @@ C4MCOverlay *C4MCNode::OwnerOverlay() if (C4MCOverlay *pOwnrOvrl=pOwnr->Overlay()) return pOwnrOvrl; // no overlay-owner - return NULL; + return nullptr; } C4MCNode *C4MCNode::GetNodeByName(const char *szName) @@ -262,7 +262,7 @@ C4MCNode *C4MCNode::GetNodeByName(const char *szName) // search owner, if present if (Owner) return Owner->GetNodeByName(szName); // nothing found - return NULL; + return nullptr; } bool C4MCNode::SetField(C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType) @@ -311,14 +311,14 @@ C4MCOverlay::C4MCOverlay(C4MCNode *pOwner) : C4MCNode(pOwner) Op=MCT_NONE; MatClr=0; MatClrBkg=0; - Algorithm=NULL; + Algorithm=nullptr; Sub=false; ZoomX=ZoomY=0; FixedSeed=Seed=0; // Alpha=Beta=0; Turbulence=Lambda=Rotate=0; Invert=LooseBounds=Group=Mask=false; - pEvaluateFunc=pDrawFunc=NULL; + pEvaluateFunc=pDrawFunc=nullptr; } C4MCOverlay::C4MCOverlay(C4MCParser* pParser, C4MCNode *pOwner, C4MCOverlay &rTemplate, bool fClone) : C4MCNode(pParser, pOwner, rTemplate, fClone) @@ -365,7 +365,7 @@ void C4MCOverlay::Default() Alpha.Set(0,false); Beta.Set(0,false); Turbulence=Lambda=Rotate=0; Invert=LooseBounds=Group=Mask=false; FixedSeed=0; // script funcs - pEvaluateFunc=pDrawFunc=NULL; + pEvaluateFunc=pDrawFunc=nullptr; } bool C4MCOverlay::SetField(C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType) @@ -451,7 +451,7 @@ C4MCAlgorithm *C4MCOverlay::GetAlgo(const char *szName) // success! return pAlgo; // nothing found - return NULL; + return nullptr; } void C4MCOverlay::Evaluate() @@ -461,7 +461,7 @@ void C4MCOverlay::Evaluate() // get mat color if (Inside(Material,0,MapCreator->MatMap->Num-1)) { - MatClr=MapCreator->TexMap->GetIndexMatTex(MapCreator->MatMap->Map[Material].Name, *Texture ? Texture : NULL); + MatClr=MapCreator->TexMap->GetIndexMatTex(MapCreator->MatMap->Map[Material].Name, *Texture ? Texture : nullptr); if(MatClr == 0 || !Sub) MatClrBkg = 0; else @@ -499,7 +499,7 @@ void C4MCOverlay::Evaluate() C4MCOverlay *C4MCOverlay::FirstOfChain() { - // run backwards until NULL, non-overlay or overlay without operator is found + // run backwards until nullptr, non-overlay or overlay without operator is found C4MCOverlay *pOvrl=this; C4MCOverlay *pPrevO; while (pOvrl->Prev) @@ -724,7 +724,7 @@ bool C4MCMap::RenderTo(BYTE *pToBuf, BYTE *pToBufBkg, int32_t iPitch) *pToBuf=0; if (pToBufBkg) *pToBufBkg=0; // render pixel value - C4MCOverlay *pRenderedOverlay = NULL; + C4MCOverlay *pRenderedOverlay = nullptr; RenderPix(iX, iY, *pToBuf, pToBufBkg ? *pToBufBkg : dummyPix, MCT_NONE, false, true, &pRenderedOverlay); // add draw-callback for rendered overlay if (pRenderedOverlay) @@ -739,7 +739,7 @@ bool C4MCMap::RenderTo(BYTE *pToBuf, BYTE *pToBufBkg, int32_t iPitch) if (pToBufBkg) pToBufBkg+=iPitch-Wdt; } // reset render target - if (MapCreator) MapCreator->pCurrentMap=NULL; + if (MapCreator) MapCreator->pCurrentMap=nullptr; // success return true; } @@ -755,7 +755,7 @@ void C4MCMap::SetSize(int32_t iWdt, int32_t iHgt) // map creator -C4MapCreatorS2::C4MapCreatorS2(C4SLandscape *pLandscape, C4TextureMap *pTexMap, C4MaterialMap *pMatMap, int iPlayerCount) : C4MCNode(NULL) +C4MapCreatorS2::C4MapCreatorS2(C4SLandscape *pLandscape, C4TextureMap *pTexMap, C4MaterialMap *pMatMap, int iPlayerCount) : C4MCNode(nullptr) { // me r b creator MapCreator=this; @@ -782,7 +782,7 @@ void C4MapCreatorS2::Default() DefaultMap.Default(); DefaultOverlay.Default(); DefaultPoint.Default(); - pCurrentMap=NULL; + pCurrentMap=nullptr; } void C4MapCreatorS2::Clear() @@ -829,7 +829,7 @@ bool C4MapCreatorS2::ReadScript(const char *szScript) C4MCMap *C4MapCreatorS2::GetMap(const char *szMapName) { - C4MCMap *pMap=NULL; C4MCNode *pNode; + C4MCMap *pMap=nullptr; C4MCNode *pNode; // get map if (szMapName && *szMapName) { @@ -853,8 +853,8 @@ C4MCMap *C4MapCreatorS2::GetMap(const char *szMapName) bool C4MapCreatorS2::Render(const char *szMapName, CSurface8*& sfcMap, CSurface8*& sfcMapBkg) { - assert(sfcMap == NULL); - assert(sfcMapBkg == NULL); + assert(sfcMap == nullptr); + assert(sfcMapBkg == nullptr); // get map C4MCMap *pMap=GetMap(szMapName); @@ -886,11 +886,11 @@ BYTE *C4MapCreatorS2::RenderBuf(const char *szMapName, int32_t &sfcWdt, int32_t { // get map C4MCMap *pMap=GetMap(szMapName); - if (!pMap) return NULL; + if (!pMap) return nullptr; // get size sfcWdt=pMap->Wdt; sfcHgt=pMap->Hgt; - if (!sfcWdt || !sfcHgt) return NULL; + if (!sfcWdt || !sfcHgt) return nullptr; int dwSfcWdt = sfcWdt; DWordAlign(dwSfcWdt); sfcWdt = dwSfcWdt; @@ -899,7 +899,7 @@ BYTE *C4MapCreatorS2::RenderBuf(const char *szMapName, int32_t &sfcWdt, int32_t BYTE *buf=new BYTE[sfcWdt*sfcHgt]; // render and return it - pMap->RenderTo(buf, NULL, sfcWdt); + pMap->RenderTo(buf, nullptr, sfcWdt); return buf; } @@ -931,7 +931,7 @@ C4MCParser::C4MCParser(C4MapCreatorS2 *pMapCreator) // store map creator MapCreator=pMapCreator; // reset some fields - Code=NULL; BPos = NULL; CPos=NULL; *Filename=0; + Code=nullptr; BPos = nullptr; CPos=nullptr; *Filename=0; } C4MCParser::~C4MCParser() @@ -943,7 +943,7 @@ C4MCParser::~C4MCParser() void C4MCParser::Clear() { // clear code if present - if (Code) delete [] Code; Code=NULL; BPos = NULL; CPos=NULL; + if (Code) delete [] Code; Code=nullptr; BPos = nullptr; CPos=nullptr; // reset filename *Filename=0; } @@ -1096,7 +1096,7 @@ static void PrintNodeTree(C4MCNode *pNode, int depth) void C4MCParser::ParseTo(C4MCNode *pToNode) { - C4MCNode *pNewNode=NULL; // new node + C4MCNode *pNewNode=nullptr; // new node bool Done=false; // finished? C4MCNodeType LastOperand = C4MCNodeType(-1); // last first operand of operator char FieldName[C4MaxName];// buffer for current field to access @@ -1301,7 +1301,7 @@ void C4MCParser::ParseTo(C4MCNode *pToNode) // evaluate node and children, if this is top-level // we mustn't evaluate everything immediately, because parents must be evaluated first! if (pToNode->GlobalScope()) pNewNode->ReEvaluate(); - pNewNode=NULL; + pNewNode=nullptr; break; case PS_SETFIELD: ParseValue (pToNode, FieldName); diff --git a/src/landscape/C4MapCreatorS2.h b/src/landscape/C4MapCreatorS2.h index 09450ee32..09cb85e98 100644 --- a/src/landscape/C4MapCreatorS2.h +++ b/src/landscape/C4MapCreatorS2.h @@ -127,7 +127,7 @@ public: class C4MCCallbackArrayList { public: - C4MCCallbackArrayList() { pFirst=NULL; } // ctor + C4MCCallbackArrayList() { pFirst=nullptr; } // ctor ~C4MCCallbackArrayList() { Clear(); } // ctor protected: @@ -149,7 +149,7 @@ public: char Name[C4MaxName]; // name, if named public: - C4MCNode(C4MCNode *pOwner=NULL); // constructor + C4MCNode(C4MCNode *pOwner=nullptr); // constructor C4MCNode(C4MCParser* pParser, C4MCNode *pOwner, C4MCNode &rTemplate, bool fClone); // constructor using template virtual ~C4MCNode(); // destructor @@ -184,7 +184,7 @@ protected: }; public: virtual C4MCNodeType Type() { return MCN_Node; } // get node type - virtual C4MCOverlay *Overlay() { return NULL; } // return overlay, if this is one + virtual C4MCOverlay *Overlay() { return nullptr; } // return overlay, if this is one C4MCOverlay *OwnerOverlay(); // return an owner who is an overlay friend class C4MCParser; @@ -194,7 +194,7 @@ public: class C4MCOverlay : public C4MCNode { public: - C4MCOverlay(C4MCNode *pOwner=NULL); // constructor + C4MCOverlay(C4MCNode *pOwner=nullptr); // constructor C4MCOverlay(C4MCParser* pParser, C4MCNode *pOwner, C4MCOverlay &rTemplate, bool fClone); // construct of template C4MCNode *clone(C4MCParser* pParser, C4MCNode *pToNode) { return new C4MCOverlay(pParser, pToNode, *this, true); } @@ -233,7 +233,7 @@ public: C4MCOverlay *FirstOfChain(); // go backwards in op chain until first overlay of chain bool CheckMask(int32_t iX, int32_t iY); // check whether algorithms succeeds at iX/iY - bool RenderPix(int32_t iX, int32_t iY, BYTE &rPix, BYTE &rPixBkg, C4MCTokenType eLastOp=MCT_NONE, bool fLastSet=false, bool fDraw=true, C4MCOverlay **ppPixelSetOverlay=NULL); // render this pixel + bool RenderPix(int32_t iX, int32_t iY, BYTE &rPix, BYTE &rPixBkg, C4MCTokenType eLastOp=MCT_NONE, bool fLastSet=false, bool fDraw=true, C4MCOverlay **ppPixelSetOverlay=nullptr); // render this pixel bool PeekPix(int32_t iX, int32_t iY); // check mask; regard operator chain bool InBounds(int32_t iX, int32_t iY) { return iX>=X && iY>=Y && iXGetIndexMatTex(cspec, NULL, false); + int32_t col = ::MapScript.pTexMap->GetIndexMatTex(cspec, nullptr, false); if (col) mat_mask[col] = true; } else @@ -221,7 +221,7 @@ bool FnParRect(C4MapScriptLayer *layer, C4ValueArray *rect, C4Rect *rc_bounds) { // Convert rect parameter passed to script function to C4Rect structure // and makes sure it is completely contained in bounding rectangle of layer - // rect==NULL defaults to bounding rectangle of layer + // rect==nullptr defaults to bounding rectangle of layer *rc_bounds = layer->GetBounds(); if (!rect) return true; // nil is OK for rect parameter. Defaults to bounds rectangle if (rect->GetSize() != 4) return false; @@ -263,7 +263,7 @@ static C4PropList *FnCreateLayer(C4PropList * _this, C4String *mattex_fill, int3 throw C4AulExecError(FormatString("CreateLayer: Invalid fill material.").getData()); C4MapScriptLayer *layer = _this->GetMapScriptLayer(); - if (!layer) return NULL; + if (!layer) return nullptr; if (!width && !height) { width = layer->GetWdt(); @@ -271,9 +271,9 @@ static C4PropList *FnCreateLayer(C4PropList * _this, C4String *mattex_fill, int3 } if (width<=0 || height<=0) throw C4AulExecError(FormatString("CreateLayer: Invalid size (%d*%d).", (int)width, (int)height).getData()); C4MapScriptMap *map = layer->GetMap(); - if (!map) return NULL; + if (!map) return nullptr; layer = map->CreateLayer(width, height); - if (fg != 0 || bg != 0) layer->Fill(fg, bg, layer->GetBounds(), NULL); + if (fg != 0 || bg != 0) layer->Fill(fg, bg, layer->GetBounds(), nullptr); return layer; } @@ -281,13 +281,13 @@ static C4PropList *FnLayerDuplicate(C4PropList * _this, const C4Value &mask_spec { // Layer script function: Create a copy of _this layer within bounds. If mask_spec is specified, copy only materials selected by mask spec C4MapScriptLayer *layer = _this->GetMapScriptLayer(); - if (!layer) return NULL; + if (!layer) return nullptr; C4MapScriptMap *map = layer->GetMap(); - if (!map) return NULL; + if (!map) return nullptr; C4MapScriptMatTexMask mat_mask(mask_spec); C4Rect src_rect; - if (!FnParRect(layer, rect, &src_rect)) return NULL; - if (!src_rect.Wdt || !src_rect.Hgt) return NULL; + if (!FnParRect(layer, rect, &src_rect)) return nullptr; + if (!src_rect.Wdt || !src_rect.Hgt) return nullptr; C4MapScriptLayer *new_layer = map->CreateLayer(src_rect.Wdt, src_rect.Hgt); new_layer->Blit(layer, src_rect, mat_mask, 0,0); return new_layer; @@ -355,7 +355,7 @@ static bool FnLayerSetPixel(C4PropList * _this, int32_t x, int32_t y, const C4Va { const C4Value& val = fg_value_c4v; C4String *str = val.getStr(); - if (str != NULL) + if (str != nullptr) { if (!TexColSingle(str->GetCStr(), fg)) throw C4AulExecError("MapLayer::SetPixel: Trying to set invalid pixel value."); @@ -376,7 +376,7 @@ static bool FnLayerSetPixel(C4PropList * _this, int32_t x, int32_t y, const C4Va { const C4Value& val = bg_value_c4v; C4String *str = val.getStr(); - if (str != NULL) + if (str != nullptr) { if (!TexColSingle(str->GetCStr(), bg)) throw C4AulExecError("MapLayer::SetPixel: Trying to set invalid pixel value."); @@ -630,12 +630,12 @@ C4MapScriptLayer *C4MapScriptMap::CreateLayer(int32_t wdt, int32_t hgt) { layers.remove(new_layer); delete new_layer; - return NULL; + return nullptr; } return new_layer; } -C4MapScriptHost::C4MapScriptHost(): LayerPrototype(NULL), MapPrototype(NULL), pTexMap(NULL), pMatMap(NULL) { } +C4MapScriptHost::C4MapScriptHost(): LayerPrototype(nullptr), MapPrototype(nullptr), pTexMap(nullptr), pMatMap(nullptr) { } C4MapScriptHost::~C4MapScriptHost() { Clear(); } @@ -644,8 +644,8 @@ void C4MapScriptHost::InitFunctionMap(C4AulScriptEngine *pEngine) // Register script host. Add Map and MapLayer prototypes, related constants and engine functions assert(pEngine && pEngine->GetPropList()); Clear(); - LayerPrototype = new C4PropListStaticMember(NULL, NULL, ::Strings.RegString("MapLayer")); - MapPrototype = new C4PropListStaticMember(LayerPrototype, NULL, ::Strings.RegString("Map")); + LayerPrototype = new C4PropListStaticMember(nullptr, nullptr, ::Strings.RegString("MapLayer")); + MapPrototype = new C4PropListStaticMember(LayerPrototype, nullptr, ::Strings.RegString("Map")); LayerPrototype->SetName("MapLayer"); MapPrototype->SetName("Map"); ::ScriptEngine.RegisterGlobalConstant("MapLayer", C4VPropList(LayerPrototype)); @@ -705,7 +705,7 @@ void C4MapScriptHost::Clear() { C4ScriptHost::Clear(); delete LayerPrototype; delete MapPrototype; - LayerPrototype = MapPrototype = NULL; + LayerPrototype = MapPrototype = nullptr; } C4PropListStatic * C4MapScriptHost::GetPropList() diff --git a/src/landscape/C4MapScript.h b/src/landscape/C4MapScript.h index c2a5f2156..96561efb0 100644 --- a/src/landscape/C4MapScript.h +++ b/src/landscape/C4MapScript.h @@ -322,7 +322,7 @@ class C4MapScriptMap : public C4MapScriptLayer { std::list layers; public: - C4MapScriptMap(C4PropList *prototype) : C4MapScriptLayer(prototype, NULL) { map=this; } + C4MapScriptMap(C4PropList *prototype) : C4MapScriptLayer(prototype, nullptr) { map=this; } ~C4MapScriptMap() { Clear(); } void Clear(); virtual C4MapScriptMap * GetMapScriptMap() { return this; } diff --git a/src/landscape/C4MapScriptAlgo.cpp b/src/landscape/C4MapScriptAlgo.cpp index f8f9b368a..70a0258c2 100644 --- a/src/landscape/C4MapScriptAlgo.cpp +++ b/src/landscape/C4MapScriptAlgo.cpp @@ -490,7 +490,7 @@ bool C4MapScriptAlgoFilter::operator () (int32_t x, int32_t y, uint8_t& fg, uint C4MapScriptAlgo *FnParAlgo(C4PropList *algo_par) { // Convert script function parameter to internal C4MapScriptAlgo class. Also resolve all parameters and nested child algos. - if (!algo_par) return NULL; + if (!algo_par) return nullptr; // if algo is a layer, take that directly C4MapScriptLayer *algo_layer = algo_par->GetMapScriptLayer(); if (algo_layer) return new C4MapScriptAlgoLayer(algo_layer); @@ -516,5 +516,5 @@ C4MapScriptAlgo *FnParAlgo(C4PropList *algo_par) default: throw C4AulExecError(FormatString("got invalid algo: %d", algo_par->GetPropertyInt(P_Algo)).getData()); } - return NULL; + return nullptr; } diff --git a/src/landscape/C4MassMover.cpp b/src/landscape/C4MassMover.cpp index 786f37c9c..16c7315fb 100644 --- a/src/landscape/C4MassMover.cpp +++ b/src/landscape/C4MassMover.cpp @@ -174,7 +174,7 @@ bool C4MassMover::Corrosion(int32_t dx, int32_t dy) if (pReact) { C4Real xdir=Fix0, ydir=Fix0; - if ((*pReact->pFunc)(pReact, x,y, x+dx,y+dy, xdir,ydir, Mat,tmat, meeMassMove, NULL)) + if ((*pReact->pFunc)(pReact, x,y, x+dx,y+dy, xdir,ydir, Mat,tmat, meeMassMove, nullptr)) return true; } return false; diff --git a/src/landscape/C4Material.cpp b/src/landscape/C4Material.cpp index 8e918af33..b1b3e9460 100644 --- a/src/landscape/C4Material.cpp +++ b/src/landscape/C4Material.cpp @@ -49,13 +49,13 @@ const ReactionFuncMapEntry ReactionFuncMap[] = { "Poof", &C4MaterialMap::mrfPoof }, { "Corrode", &C4MaterialMap::mrfCorrode }, { "Insert", &C4MaterialMap::mrfInsert }, - { NULL, &C4MaterialReaction::NoReaction } + { nullptr, &C4MaterialReaction::NoReaction } }; void C4MaterialReaction::CompileFunc(StdCompiler *pComp) { - if (pComp->isCompiler()) pScriptFunc = NULL; + if (pComp->isCompiler()) pScriptFunc = nullptr; // compile reaction func ptr StdStrBuf sReactionFuncName; int32_t i=0; while (ReactionFuncMap[i].szRFName && (ReactionFuncMap[i].pFunc != pFunc)) ++i; @@ -86,7 +86,7 @@ void C4MaterialReaction::ResolveScriptFuncs(const char *szMatName) DebugLogF("Error getting function \"%s\" for Material reaction of \"%s\"", this->ScriptFunc.getData(), szMatName); } else - pScriptFunc = NULL; + pScriptFunc = nullptr; } // -------------------------------------- C4MaterialCore @@ -196,7 +196,7 @@ void C4MaterialCore::CompileFunc(StdCompiler *pComp) { "Rough", C4M_Rough }, { "Octagon", C4M_Octagon }, { "Smoother", C4M_Smoother }, - { NULL, C4M_Flat } + { nullptr, C4M_Flat } }; pComp->Value(mkNamingAdapt(mkEnumAdaptT(MapChunkType, Shapes), "Shape", C4M_Flat)); @@ -313,8 +313,8 @@ C4MaterialMap::~C4MaterialMap() void C4MaterialMap::Clear() { - if (Map) delete [] Map; Map=NULL; Num=0; - delete [] ppReactionMap; ppReactionMap = NULL; + if (Map) delete [] Map; Map=nullptr; Num=0; + delete [] ppReactionMap; ppReactionMap = nullptr; } int32_t C4MaterialMap::Load(C4Group &hGroup) @@ -380,11 +380,11 @@ bool C4MaterialMap::CrossMapMaterials(const char* szEarthMaterial) // Called aft ppReactionMap = new C4MaterialReactionPtr[(Num+1)*(Num+1)]; for (int32_t iMatPXS=-1; iMatPXSsInMatConvert.getLength() && SEqualNoCase(pMatPXS->sInMatConvert.getData(), pMatLS ? pMatLS->Name : C4TLS_MatSky)) pReaction = &DefReactConvert; @@ -407,7 +407,7 @@ bool C4MaterialMap::CrossMapMaterials(const char* szEarthMaterial) // Called aft else if (DensitySolid(MatDensity(iMatPXS)) && DensitySolid(MatDensity(iMatLS))) pReaction = &DefReactInsert; } - // assign the function; or NULL for no reaction + // assign the function; or nullptr for no reaction SetMatReaction(iMatPXS, iMatLS, pReaction); } } @@ -418,7 +418,7 @@ bool C4MaterialMap::CrossMapMaterials(const char* szEarthMaterial) // Called aft for (cnt=0; cntGetTextureName(); // default to smooth if (!szTextureOverlay) @@ -533,13 +533,13 @@ bool C4MaterialMap::CrossMapMaterials(const char* szEarthMaterial) // Called aft for (cnt=0; cnt(iPXSMat, -1, Num-1)) return NULL; - if (!Inside(iLandscapeMat, -1, Num-1)) return NULL; + if (!ppReactionMap) return nullptr; + if (!Inside(iPXSMat, -1, Num-1)) return nullptr; + if (!Inside(iLandscapeMat, -1, Num-1)) return nullptr; // values OK; get func! return GetReactionUnsafe(iPXSMat, iLandscapeMat); } @@ -926,7 +926,7 @@ bool C4MaterialMap::mrfScript(C4MaterialReaction *pReaction, int32_t &iX, int32_ // 0 1 2 3 4 5 6 7 8 int32_t iXDir1, iYDir1, iXDir2, iYDir2; C4AulParSet pars(iX, iY, iLSPosX, iLSPosY, iXDir1 = fixtoi(fXDir, 100), iYDir1 = fixtoi(fYDir, 100), iPxsMat, iLsMat, int(evEvent)); - if (!!pReaction->pScriptFunc->Exec(NULL, &pars, false)) + if (!!pReaction->pScriptFunc->Exec(nullptr, &pars, false)) { // PXS shall be killed! return true; diff --git a/src/landscape/C4Material.h b/src/landscape/C4Material.h index 6164ee0eb..e9a82ee8f 100644 --- a/src/landscape/C4Material.h +++ b/src/landscape/C4Material.h @@ -46,7 +46,7 @@ struct C4MaterialReaction { static inline bool NoReaction(struct C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged) { return false; } - C4MaterialReactionFunc pFunc; // Guarantueed to be non-NULL + C4MaterialReactionFunc pFunc; // Guarantueed to be non-nullptr bool fUserDefined; // false for internal reactions generated by material parameters StdCopyStrBuf TargetSpec; // target material specification StdCopyStrBuf ScriptFunc; // for reaction func 'script': Script func to be called for reaction evaluation @@ -60,8 +60,8 @@ struct C4MaterialReaction int32_t iConvertMat; // in mat conversion material; evaluated in CrossMapMaterials int32_t iCorrosionRate; // chance of doing a corrosion - C4MaterialReaction(C4MaterialReactionFunc pFunc) : pFunc(pFunc), fUserDefined(false), pScriptFunc(NULL), iExecMask(~0u), fReverse(false), fInverseSpec(false), fInsertionCheck(true), iDepth(0), iConvertMat(-1), iCorrosionRate(100) {} - C4MaterialReaction() : pFunc(&NoReaction), fUserDefined(true), pScriptFunc(NULL), iExecMask(~0u), fReverse(false), fInverseSpec(false), fInsertionCheck(true), iDepth(0), iConvertMat(-1), iCorrosionRate(100) { } + C4MaterialReaction(C4MaterialReactionFunc pFunc) : pFunc(pFunc), fUserDefined(false), pScriptFunc(nullptr), iExecMask(~0u), fReverse(false), fInverseSpec(false), fInsertionCheck(true), iDepth(0), iConvertMat(-1), iCorrosionRate(100) {} + C4MaterialReaction() : pFunc(&NoReaction), fUserDefined(true), pScriptFunc(nullptr), iExecMask(~0u), fReverse(false), fInverseSpec(false), fInsertionCheck(true), iDepth(0), iConvertMat(-1), iCorrosionRate(100) { } void CompileFunc(StdCompiler *pComp); diff --git a/src/landscape/C4PXS.cpp b/src/landscape/C4PXS.cpp index 889a8b74e..2fc17b96e 100644 --- a/src/landscape/C4PXS.cpp +++ b/src/landscape/C4PXS.cpp @@ -56,7 +56,7 @@ void C4PXS::Execute() int32_t iX = fixtoi(x), iY = fixtoi(y); inmat=GBackMat(iX,iY); C4MaterialReaction *pReact = ::MaterialMap.GetReactionUnsafe(Mat, inmat); - if (pReact && (*pReact->pFunc)(pReact, iX,iY, iX,iY, xdir,ydir, Mat,inmat, meePXSPos, NULL)) + if (pReact && (*pReact->pFunc)(pReact, iX,iY, iX,iY, xdir,ydir, Mat,inmat, meePXSPos, nullptr)) { Deactivate(); return; } // Gravity @@ -168,7 +168,7 @@ void C4PXSSystem::Default() Count=0; for (unsigned int cnt=0; cntPerformMultiPix(cgo.Surface, &pixVtx[0], pixVtx.size(), NULL); - if(!lineVtx.empty()) pDraw->PerformMultiLines(cgo.Surface, &lineVtx[0], lineVtx.size(), 1.0f, NULL); + if(!pixVtx.empty()) pDraw->PerformMultiPix(cgo.Surface, &pixVtx[0], pixVtx.size(), nullptr); + if(!lineVtx.empty()) pDraw->PerformMultiLines(cgo.Surface, &lineVtx[0], lineVtx.size(), 1.0f, nullptr); // PXS graphics disabled? if (!Config.Graphics.PXSGfx) @@ -356,7 +356,7 @@ void C4PXSSystem::Draw(C4TargetFacet &cgo) for(std::map >::const_iterator iter = bltVtx.begin(); iter != bltVtx.end(); ++iter) { C4Material *pMat = &::MaterialMap.Map[iter->first]; - pDraw->PerformMultiTris(cgo.Surface, &iter->second[0], iter->second.size(), NULL, pMat->PXSFace.Surface->texture.get(), NULL, NULL, 0, NULL); + pDraw->PerformMultiTris(cgo.Surface, &iter->second[0], iter->second.size(), nullptr, pMat->PXSFace.Surface->texture.get(), nullptr, nullptr, 0, nullptr); } } @@ -483,7 +483,7 @@ void C4PXSSystem::SyncClearance() else { delete [] Chunk[cnt]; - Chunk[cnt] = NULL; + Chunk[cnt] = nullptr; } } } diff --git a/src/landscape/C4Particles.cpp b/src/landscape/C4Particles.cpp index 40c3c3c4d..1f0985aa2 100644 --- a/src/landscape/C4Particles.cpp +++ b/src/landscape/C4Particles.cpp @@ -62,7 +62,7 @@ C4ParticleDef::C4ParticleDef() : C4ParticleDefCore() // link into list if (!Particles.definitions.first) { - previous = NULL; + previous = nullptr; Particles.definitions.first = this; } else @@ -94,7 +94,7 @@ bool C4ParticleDef::Load(C4Group &group) Filename.Copy(group.GetFullName()); // load char *particle_source; - if (group.LoadEntry(C4CFN_ParticleCore,&particle_source,NULL,1)) + if (group.LoadEntry(C4CFN_ParticleCore,&particle_source,nullptr,1)) { if (!Compile(particle_source, Filename.getData())) { @@ -1164,7 +1164,7 @@ void C4ParticleList::Draw(C4TargetFacet cgo, C4Object *obj) C4ShaderCall call(pGL->GetSpriteShader(true, false, false)); // apply zoom and upload shader uniforms StdProjectionMatrix modelview = StdProjectionMatrix::Identity(); - pGL->SetupMultiBlt(call, NULL, 0, 0, 0, 0, &modelview); + pGL->SetupMultiBlt(call, nullptr, 0, 0, 0, 0, &modelview); // go to correct output position (note the normal matrix is unaffected // by this) Translate(modelview, cgo.X-cgo.TargetX, cgo.Y-cgo.TargetY, 0.0f); @@ -1205,11 +1205,11 @@ void C4ParticleList::Clear() if (targetObject) { - if (this == targetObject->FrontParticles) targetObject->FrontParticles = NULL; - else if (this == targetObject->BackParticles) targetObject->BackParticles = NULL; + if (this == targetObject->FrontParticles) targetObject->FrontParticles = nullptr; + else if (this == targetObject->BackParticles) targetObject->BackParticles = nullptr; } else - if(this == ::Particles.globalParticles) ::Particles.globalParticles = NULL; + if(this == ::Particles.globalParticles) ::Particles.globalParticles = nullptr; accessMutex.Leave(); } diff --git a/src/landscape/C4Particles.h b/src/landscape/C4Particles.h index fc366f1a4..7f0df1fa3 100644 --- a/src/landscape/C4Particles.h +++ b/src/landscape/C4Particles.h @@ -515,7 +515,7 @@ public: GLuint GetIBO(size_t forParticleAmount); // creates a new particle - void Create(C4ParticleDef *of_def, C4ParticleValueProvider &x, C4ParticleValueProvider &y, C4ParticleValueProvider &speedX, C4ParticleValueProvider &speedY, C4ParticleValueProvider &lifetime, C4PropList *properties, int amount = 1, C4Object *object=NULL); + void Create(C4ParticleDef *of_def, C4ParticleValueProvider &x, C4ParticleValueProvider &y, C4ParticleValueProvider &speedX, C4ParticleValueProvider &speedY, C4ParticleValueProvider &lifetime, C4PropList *properties, int amount = 1, C4Object *object=nullptr); #endif diff --git a/src/landscape/C4PathFinder.cpp b/src/landscape/C4PathFinder.cpp index f6dd7043a..ba03cbd6e 100644 --- a/src/landscape/C4PathFinder.cpp +++ b/src/landscape/C4PathFinder.cpp @@ -103,7 +103,7 @@ protected: bool CrawlTargetFree(int32_t iX, int32_t iY, int32_t iAttach, int32_t iDirection); bool PointFree(int32_t iX, int32_t iY); bool Crawl(); - bool PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t iToY, C4TransferZone **ppZone = NULL); + bool PathFree(int32_t &rX, int32_t &rY, int32_t iToX, int32_t iToY, C4TransferZone **ppZone = nullptr); }; C4PathFinderRay::C4PathFinderRay() @@ -122,10 +122,10 @@ void C4PathFinderRay::Default() X=Y=X2=Y2=TargetX=TargetY=0; Direction=0; Depth=0; - UseZone=NULL; - From=NULL; - Next=NULL; - pPathFinder=NULL; + UseZone=nullptr; + From=nullptr; + Next=nullptr; + pPathFinder=nullptr; CrawlStartX=CrawlStartY=CrawlAttach=0; } @@ -136,7 +136,7 @@ void C4PathFinderRay::Clear() bool C4PathFinderRay::Execute() { - C4TransferZone *pZone = NULL; + C4TransferZone *pZone = nullptr; int32_t iX,iY,iLastX,iLastY; switch (Status) { @@ -546,11 +546,11 @@ C4PathFinder::~C4PathFinder() void C4PathFinder::Default() { - PointFree=NULL; - SetWaypoint=NULL; - FirstRay=NULL; + PointFree=nullptr; + SetWaypoint=nullptr; + FirstRay=nullptr; Success=false; - TransferZones=NULL; + TransferZones=nullptr; TransferZonesEnabled=true; Level=1; } @@ -559,7 +559,7 @@ void C4PathFinder::Clear() { C4PathFinderRay *pRay,*pNext; for (pRay=FirstRay; pRay; pRay=pNext) { pNext=pRay->Next; delete pRay; } - FirstRay=NULL; + FirstRay=nullptr; } void C4PathFinder::Init(PointFreeFn fnPointFree, C4TransferZones* pTransferZones) @@ -634,8 +634,8 @@ bool C4PathFinder::Find(int32_t iFromX, int32_t iFromY, int32_t iToX, int32_t iT if (!PointFree(iFromX,iFromY) || !PointFree(iToX,iToY)) return false; // Add the first two rays - if (!AddRay(iFromX,iFromY,iToX,iToY,0,C4PF_Direction_Left,NULL)) return false; - if (!AddRay(iFromX,iFromY,iToX,iToY,0,C4PF_Direction_Right,NULL)) return false; + if (!AddRay(iFromX,iFromY,iToX,iToY,0,C4PF_Direction_Left,nullptr)) return false; + if (!AddRay(iFromX,iFromY,iToX,iToY,0,C4PF_Direction_Right,nullptr)) return false; // Run Run(); diff --git a/src/landscape/C4PathFinder.h b/src/landscape/C4PathFinder.h index 2fba5deaf..4929e4b95 100644 --- a/src/landscape/C4PathFinder.h +++ b/src/landscape/C4PathFinder.h @@ -37,14 +37,14 @@ public: void Draw(C4TargetFacet &cgo); void Clear(); void Default(); - void Init(PointFreeFn fnPointFree, C4TransferZones* pTransferZones=NULL); + void Init(PointFreeFn fnPointFree, C4TransferZones* pTransferZones=nullptr); bool Find(int32_t iFromX, int32_t iFromY, int32_t iToX, int32_t iToY, SetWaypointFn fnSetWaypoint); void EnableTransferZones(bool fEnabled); void SetLevel(int iLevel); private: void Run(); - bool AddRay(int32_t iFromX, int32_t iFromY, int32_t iToX, int32_t iToY, int32_t iDepth, int32_t iDirection, C4PathFinderRay *pFrom, C4TransferZone *pUseZone=NULL); + bool AddRay(int32_t iFromX, int32_t iFromY, int32_t iToX, int32_t iToY, int32_t iDepth, int32_t iDirection, C4PathFinderRay *pFrom, C4TransferZone *pUseZone=nullptr); bool SplitRay(C4PathFinderRay *pRay, int32_t iAtX, int32_t iAtY); bool Execute(); diff --git a/src/landscape/C4Scenario.h b/src/landscape/C4Scenario.h index 503647b76..a04734db7 100644 --- a/src/landscape/C4Scenario.h +++ b/src/landscape/C4Scenario.h @@ -92,7 +92,7 @@ public: bool LocalOnly; bool AllowUserChange; C4IDList SkipDefs; - void SetModules(const char *szList, const char *szRelativeToPath=NULL, const char *szRelativeToPath2=NULL); + void SetModules(const char *szList, const char *szRelativeToPath=nullptr, const char *szRelativeToPath2=nullptr); bool GetModules(StdStrBuf *psOutModules) const; void Default(); void CompileFunc(StdCompiler *pComp); diff --git a/src/landscape/C4ScenarioSection.cpp b/src/landscape/C4ScenarioSection.cpp index ccc867c0f..3923e19d0 100644 --- a/src/landscape/C4ScenarioSection.cpp +++ b/src/landscape/C4ScenarioSection.cpp @@ -30,7 +30,7 @@ C4ScenarioSection::C4ScenarioSection(const char *szName) name.Copy(szName); // zero fields fModified = false; - pObjectScripts = NULL; + pObjectScripts = nullptr; // link into main list pNext = Game.pScenarioSections; Game.pScenarioSections = this; @@ -43,7 +43,7 @@ C4ScenarioSection::~C4ScenarioSection() { C4ScenarioSection *pDel = pNext; pNext = pNext->pNext; - pDel->pNext = NULL; + pDel->pNext = nullptr; delete pDel; } // del temp file @@ -81,7 +81,7 @@ bool C4ScenarioSection::ScenarioLoad(const char *szFilename, bool is_temp_file) } else { - pObjectScripts = NULL; + pObjectScripts = nullptr; } } else @@ -99,18 +99,18 @@ C4Group *C4ScenarioSection::GetGroupfile(C4Group &rGrp) if (temp_filename.getData()) { if (rGrp.Open(temp_filename.getData())) return &rGrp; - else return NULL; + else return nullptr; } // check filename within scenario if (filename.getData()) { if (rGrp.OpenAsChild(&Game.ScenarioFile, filename.getData())) return &rGrp; - else return NULL; + else return nullptr; } // unmodified main section: return main group if (SEqualNoCase(name.getData(), C4ScenSect_Main)) return &Game.ScenarioFile; // failure - return NULL; + return nullptr; } bool C4ScenarioSection::EnsureTempStore(bool fExtractLandscape, bool fExtractObjects) diff --git a/src/landscape/C4Sky.cpp b/src/landscape/C4Sky.cpp index df7d360b7..3b46a38ab 100644 --- a/src/landscape/C4Sky.cpp +++ b/src/landscape/C4Sky.cpp @@ -116,10 +116,10 @@ bool C4Sky::Init(bool fSavegame, std::string names) } // Load sky shaders: regular sprite shaders with OC_SKY define - const char* const SkyDefines[] = { "OC_SKY", NULL }; - if (!pDraw->PrepareSpriteShader(Shader, "Sky", Surface ? C4SSC_BASE : 0, &::GraphicsResource.Files, SkyDefines, NULL)) + const char* const SkyDefines[] = { "OC_SKY", nullptr }; + if (!pDraw->PrepareSpriteShader(Shader, "Sky", Surface ? C4SSC_BASE : 0, &::GraphicsResource.Files, SkyDefines, nullptr)) return false; - if (!pDraw->PrepareSpriteShader(ShaderLight, "SkyLight", (Surface ? C4SSC_BASE : 0) | C4SSC_LIGHT, &::GraphicsResource.Files, SkyDefines, NULL)) + if (!pDraw->PrepareSpriteShader(ShaderLight, "SkyLight", (Surface ? C4SSC_BASE : 0) | C4SSC_LIGHT, &::GraphicsResource.Files, SkyDefines, nullptr)) return false; // no sky - using fade in newgfx @@ -143,7 +143,7 @@ bool C4Sky::Init(bool fSavegame, std::string names) void C4Sky::Default() { Width=Height=0; - Surface=NULL; + Surface=nullptr; x=y=xdir=ydir=0; Modulation=0xffffffff; ParX=ParY=10; @@ -161,7 +161,7 @@ void C4Sky::Clear() { Shader.Clear(); ShaderLight.Clear(); - delete Surface; Surface=NULL; + delete Surface; Surface=nullptr; Modulation=0xffffffff; } diff --git a/src/landscape/C4SolidMask.cpp b/src/landscape/C4SolidMask.cpp index 1ee0561fe..079e829f0 100644 --- a/src/landscape/C4SolidMask.cpp +++ b/src/landscape/C4SolidMask.cpp @@ -412,7 +412,7 @@ C4SolidMask::C4SolidMask(C4Object *pForObject) : pForObject(pForObject) MaskPut=false; MaskPutRotation=0; MaskRemovalX=MaskRemovalY=Fix0; - ppAttachingObjects=NULL; + ppAttachingObjects=nullptr; iAttachingObjectsCount=iAttachingObjectsCapacity=0; MaskMaterial=MCVehic; // Update linked list @@ -493,8 +493,8 @@ CSurface8 *C4SolidMask::LoadMaskFromFile(class C4Group &hGroup, const char *szFi // All pixels that are more than 50% transparent are not solid CPNGFile png; StdBuf png_buf; - if (!hGroup.LoadEntry(szFilename, &png_buf)) return NULL; // error messages done by caller - if (!png.Load((BYTE*)png_buf.getMData(), png_buf.getSize())) return NULL; + if (!hGroup.LoadEntry(szFilename, &png_buf)) return nullptr; // error messages done by caller + if (!png.Load((BYTE*)png_buf.getMData(), png_buf.getSize())) return nullptr; CSurface8 *result = new CSurface8(png.iWdt, png.iHgt); for (size_t y=0u; yNext; delete ctex; } - FirstTexture=NULL; + FirstTexture=nullptr; fInitialized = false; fEntriesAdded = false; fOverloadMaterials = false; @@ -478,7 +478,7 @@ C4Texture * C4TextureMap::GetTexture(const char *szTexture) for (pTexture=FirstTexture; pTexture; pTexture=pTexture->Next) if (SEqualNoCase(pTexture->Name.getData(),szTexture)) return pTexture; - return NULL; + return nullptr; } int32_t C4TextureMap::GetTextureIndex(const char *szName) @@ -507,7 +507,7 @@ const char* C4TextureMap::GetTexture(int32_t iIndex) for (pTexture=FirstTexture,cindex=0; pTexture; pTexture=pTexture->Next,cindex++) if (cindex==iIndex) return pTexture->Name.getData(); - return NULL; + return nullptr; } BYTE C4TextureMap::DefaultBkgMatTex(BYTE fg) const diff --git a/src/landscape/C4Texture.h b/src/landscape/C4Texture.h index 049b14b1b..29d64924a 100644 --- a/src/landscape/C4Texture.h +++ b/src/landscape/C4Texture.h @@ -82,7 +82,7 @@ protected: public: bool fEntriesAdded; public: - const C4TexMapEntry *GetEntry(int32_t iIndex) const { return Inside(iIndex, 0, C4M_MaxTexIndex-1) ? &Entry[iIndex] : NULL; } + const C4TexMapEntry *GetEntry(int32_t iIndex) const { return Inside(iIndex, 0, C4M_MaxTexIndex-1) ? &Entry[iIndex] : nullptr; } void RemoveEntry(int32_t iIndex); void Clear(); void StoreMapPalette(CStdPalette *, C4MaterialMap &rMaterials); @@ -94,8 +94,8 @@ public: bool HasTextures(C4Group &hGroup); const char *GetTexture(int32_t iIndex); void MoveIndex(BYTE byOldIndex, BYTE byNewIndex); // change index of texture - int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=NULL); - int32_t GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture = NULL, bool fAddIfNotExist=true, const char *szErrorIfFailed=NULL); + int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr); + int32_t GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture = nullptr, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr); C4Texture * GetTexture(const char *szTexture); bool CheckTexture(const char *szTexture); // return whether texture exists bool AddEntry(BYTE byIndex, const char *szMaterial, const char *szTexture); diff --git a/src/landscape/C4TransferZone.cpp b/src/landscape/C4TransferZone.cpp index e72f42254..708fd0758 100644 --- a/src/landscape/C4TransferZone.cpp +++ b/src/landscape/C4TransferZone.cpp @@ -28,9 +28,9 @@ C4TransferZone::C4TransferZone() { - Object = NULL; + Object = nullptr; X = Y = Wdt = Hgt = 0; - Next = NULL; + Next = nullptr; Used = false; } @@ -50,14 +50,14 @@ C4TransferZones::~C4TransferZones() void C4TransferZones::Default() { - First=NULL; + First=nullptr; } void C4TransferZones::Clear() { C4TransferZone *pZone,*pNext; for (pZone=First; pZone; pZone=pNext) { pNext=pZone->Next; delete pZone; } - First=NULL; + First=nullptr; } void C4TransferZones::ClearPointers(C4Object *pObj) @@ -65,7 +65,7 @@ void C4TransferZones::ClearPointers(C4Object *pObj) // Clear object pointers for (C4TransferZone *pZone=First; pZone; pZone=pZone->Next) if (pZone->Object==pObj) - pZone->Object=NULL; + pZone->Object=nullptr; // Remove cleared zones immediately RemoveNullZones(); } @@ -114,7 +114,7 @@ C4TransferZone* C4TransferZones::Find(int32_t iX, int32_t iY) if (Inside(iX-pZone->X,0,pZone->Wdt-1)) if (Inside(iY-pZone->Y,0,pZone->Hgt-1)) return pZone; - return NULL; + return nullptr; } void C4TransferZones::Draw(C4TargetFacet &cgo) @@ -140,7 +140,7 @@ bool C4TransferZone::At(int32_t iX, int32_t iY) int32_t C4TransferZones::RemoveNullZones() { int32_t iResult=0; - C4TransferZone *pZone,*pNext,*pPrev=NULL; + C4TransferZone *pZone,*pNext,*pPrev=nullptr; for (pZone=First; pZone; pZone=pNext) { pNext=pZone->Next; @@ -212,5 +212,5 @@ C4TransferZone* C4TransferZones::Find(C4Object *pObj) for (C4TransferZone *pZone=First; pZone; pZone=pZone->Next) if (pZone->Object==pObj) return pZone; - return NULL; + return nullptr; } diff --git a/src/landscape/fow/C4FoW.cpp b/src/landscape/fow/C4FoW.cpp index dede85650..7571635de 100644 --- a/src/landscape/fow/C4FoW.cpp +++ b/src/landscape/fow/C4FoW.cpp @@ -22,7 +22,7 @@ C4FoW::C4FoW() - : pLights(NULL), deleted_lights(nullptr) + : pLights(nullptr), deleted_lights(nullptr) { } @@ -89,21 +89,21 @@ C4Shader *C4FoW::GetFramebufShader() const char *szUniforms[C4FoWFSU_Count + 1]; szUniforms[C4FoWFSU_ProjectionMatrix] = "projectionMatrix"; szUniforms[C4FoWFSU_Texture] = "tex"; - szUniforms[C4FoWFSU_Count] = NULL; + szUniforms[C4FoWFSU_Count] = nullptr; const char *szAttributes[C4FoWFSA_Count + 1]; szAttributes[C4FoWFSA_Position] = "oc_Position"; szAttributes[C4FoWFSA_TexCoord] = "oc_TexCoord"; - szAttributes[C4FoWFSA_Count] = NULL; + szAttributes[C4FoWFSA_Count] = nullptr; if (!FramebufShader.Init("framebuf", szUniforms, szAttributes)) { FramebufShader.ClearSlices(); - return NULL; + return nullptr; } } return &FramebufShader; #else - return NULL; + return nullptr; #endif } @@ -146,22 +146,22 @@ C4Shader *C4FoW::GetRenderShader() const char* szUniforms[C4FoWRSU_Count + 1]; szUniforms[C4FoWRSU_ProjectionMatrix] = "projectionMatrix"; szUniforms[C4FoWRSU_VertexOffset] = "vertexOffset"; - szUniforms[C4FoWRSU_Count] = NULL; + szUniforms[C4FoWRSU_Count] = nullptr; const char* szAttributes[C4FoWRSA_Count + 1]; szAttributes[C4FoWRSA_Position] = "oc_Position"; szAttributes[C4FoWRSA_Color] = "oc_Color"; - szAttributes[C4FoWRSA_Count] = NULL; + szAttributes[C4FoWRSA_Count] = nullptr; if (!RenderShader.Init("fowRender", szUniforms, szAttributes)) { RenderShader.ClearSlices(); - return NULL; + return nullptr; } } return &RenderShader; #else - return NULL; + return nullptr; #endif } @@ -206,7 +206,7 @@ void C4FoW::Remove(C4Object *pObj) { #ifndef USE_CONSOLE // Look for matching light - C4FoWLight *pPrev = NULL, *pLight; + C4FoWLight *pPrev = nullptr, *pLight; for (pLight = pLights; pLight; pPrev = pLight, pLight = pLight->getNext()) if (pLight->getObj() == pObj) break; diff --git a/src/landscape/fow/C4FoWAmbient.cpp b/src/landscape/fow/C4FoWAmbient.cpp index b9b5ccd1a..517ffc747 100644 --- a/src/landscape/fow/C4FoWAmbient.cpp +++ b/src/landscape/fow/C4FoWAmbient.cpp @@ -138,7 +138,7 @@ void C4FoWAmbient::CreateFromLandscape(const C4Landscape& landscape, double reso glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, SizeX, SizeY, 0, GL_RED, GL_FLOAT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, SizeX, SizeY, 0, GL_RED, GL_FLOAT, nullptr); const C4TimeMilliseconds begin = C4TimeMilliseconds::Now(); UpdateFromLandscape(landscape, C4Rect(0, 0, Landscape.GetWidth(), Landscape.GetHeight())); diff --git a/src/landscape/fow/C4FoWBeam.h b/src/landscape/fow/C4FoWBeam.h index 3fdcf75cb..bdf7b7658 100644 --- a/src/landscape/fow/C4FoWBeam.h +++ b/src/landscape/fow/C4FoWBeam.h @@ -43,7 +43,7 @@ public: iLeftEndY(0), iRightEndY(0), iError(0), fDirty(true), - pNext(NULL) + pNext(nullptr) { } private: diff --git a/src/landscape/fow/C4FoWDrawStrategy.cpp b/src/landscape/fow/C4FoWDrawStrategy.cpp index 363459692..3f48e19bf 100644 --- a/src/landscape/fow/C4FoWDrawStrategy.cpp +++ b/src/landscape/fow/C4FoWDrawStrategy.cpp @@ -110,7 +110,7 @@ void C4FoWDrawTriangulator::Reset() } C4FoWDrawLightTextureStrategy::C4FoWDrawLightTextureStrategy(const C4FoWLight* light) - : light(light), region(NULL), vbo_size(0), ibo_size(0) + : light(light), region(nullptr), vbo_size(0), ibo_size(0) { bo[0] = bo[1] = 0u; } diff --git a/src/landscape/fow/C4FoWLight.cpp b/src/landscape/fow/C4FoWLight.cpp index 3ff51a65e..6a7ecfec9 100644 --- a/src/landscape/fow/C4FoWLight.cpp +++ b/src/landscape/fow/C4FoWLight.cpp @@ -35,7 +35,7 @@ C4FoWLight::C4FoWLight(C4Object *pObj) iFadeout(pObj->lightFadeoutRange), iSize(20), gBright(0.5), colorR(1.0), colorG(1.0), colorB(1.0), colorV(1.0), colorL(1.0), - pNext(NULL), + pNext(nullptr), pObj(pObj), sections(4) { diff --git a/src/landscape/fow/C4FoWLightSection.cpp b/src/landscape/fow/C4FoWLightSection.cpp index db28d591c..8d476703b 100644 --- a/src/landscape/fow/C4FoWLightSection.cpp +++ b/src/landscape/fow/C4FoWLightSection.cpp @@ -121,7 +121,7 @@ C4FoWBeam *C4FoWLightSection::FindBeamLeftOf(int32_t x, int32_t y) const // Trivial y = std::max(y, 0); if (!pBeams || !pBeams->isRight(x, y)) - return NULL; + return nullptr; // Go through list // Note: In case this turns out expensive, one might think about implementing // a skip-list. But I highly doubt it. @@ -180,7 +180,7 @@ void C4FoWLightSection::Update(C4Rect RectIn) if (beam) LogSilentF("Start beam is %s", beam->getDesc().getData()); #endif - C4FoWBeam *endBeam = NULL; + C4FoWBeam *endBeam = nullptr; int32_t startY = Rect.GetBottom(); while (beam && !beam->isLeft(rx, ry)) { if (beam->isDirty() && beam->getLeftEndY() <= Rect.y + Rect.Hgt) { @@ -419,7 +419,7 @@ int32_t C4FoWLightSection::FindBeamsClipped(const C4Rect &rect, C4FoWBeam *&firs // not exist or the two lines are parallel. static inline bool find_cross(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, - float *px, float *py, float *pb = NULL) + float *px, float *py, float *pb = nullptr) { // We are looking for a, b so that // px = a*x1 + (1-a)*x2 = b*x3 + (1-b)*x4 @@ -441,7 +441,7 @@ static inline bool find_cross(float x1, float y1, float x2, float y2, std::list C4FoWLightSection::CalculateTriangles(C4FoWRegion *region) const { - C4FoWBeam *startBeam = NULL, *endBeam = NULL; + C4FoWBeam *startBeam = nullptr, *endBeam = nullptr; int32_t beamCount = FindBeamsClipped(rtransRect(region->getRegion()), startBeam, endBeam); std::list result; float crossX=0.0f, crossY=0.0f; @@ -841,7 +841,7 @@ void C4FoWLightSection::CompileFunc(StdCompiler *pComp) ClearBeams(); int32_t beam_count = 0; pComp->Value(mkNamingCountAdapt(beam_count, "Beam")); - C4FoWBeam *last_beam = NULL; + C4FoWBeam *last_beam = nullptr; for (int32_t i = 0; i < beam_count; ++i) { std::unique_ptr beam(new C4FoWBeam(0, 0, 0, 0)); diff --git a/src/landscape/fow/C4FoWLightSection.h b/src/landscape/fow/C4FoWLightSection.h index c59c5b018..ef599f520 100644 --- a/src/landscape/fow/C4FoWLightSection.h +++ b/src/landscape/fow/C4FoWLightSection.h @@ -72,7 +72,7 @@ public: private: - /** Remove all beams. pBeams is NULL after that. */ + /** Remove all beams. pBeams is nullptr after that. */ void ClearBeams(); // Beam coordinate to landscape coordinate. Beam coordinates are relative to the light source. @@ -128,7 +128,7 @@ private: C4FoWBeam *FindBeamLeftOf(int32_t x, int32_t y) const; /** Find beams that go through the given rectangle. Returns the number of beams that are in the rectangle and makes - firstBeam point to the first and endBeam point to the beam after the last of these. Thus, endBeam is NULL if + firstBeam point to the first and endBeam point to the beam after the last of these. Thus, endBeam is nullptr if no beams were clipped at the end. */ int32_t FindBeamsClipped(const C4Rect &rect, C4FoWBeam *&firstBeam, C4FoWBeam *&endBeam) const; diff --git a/src/landscape/fow/C4FoWRegion.cpp b/src/landscape/fow/C4FoWRegion.cpp index 9454aee2c..cd10860c0 100644 --- a/src/landscape/fow/C4FoWRegion.cpp +++ b/src/landscape/fow/C4FoWRegion.cpp @@ -236,7 +236,7 @@ bool C4FoWRegion::Render(const C4TargetFacet *pOnScreen) // Render FoW to frame buffer object glBlendFunc(GL_ONE, GL_ONE); - pFoW->Render(this, NULL, pPlayer, projectionMatrix); + pFoW->Render(this, nullptr, pPlayer, projectionMatrix); // Copy over the old state if (OldRegion.Wdt > 0) diff --git a/src/landscape/fow/C4FoWRegion.h b/src/landscape/fow/C4FoWRegion.h index fc446b96a..365b60278 100644 --- a/src/landscape/fow/C4FoWRegion.h +++ b/src/landscape/fow/C4FoWRegion.h @@ -58,7 +58,7 @@ public: #endif void Update(C4Rect r, const FLOAT_RECT& vp); - bool Render(const C4TargetFacet *pOnScreen = NULL); + bool Render(const C4TargetFacet *pOnScreen = nullptr); // Fills a 2x3 matrix to transform fragment coordinates to light texture coordinates void GetFragTransform(const C4Rect& clipRect, const C4Rect& outRect, float lightTransform[6]) const; diff --git a/src/lib/C4Log.cpp b/src/lib/C4Log.cpp index c474c0f01..8cf6c019d 100644 --- a/src/lib/C4Log.cpp +++ b/src/lib/C4Log.cpp @@ -41,8 +41,8 @@ #include #endif -FILE *C4LogFile=NULL; -FILE *C4ShaderLogFile = NULL; +FILE *C4LogFile=nullptr; +FILE *C4ShaderLogFile = nullptr; time_t C4LogStartTime; StdStrBuf sLogFileName; @@ -87,7 +87,7 @@ bool OpenExtraLogs() { DebugLog("Couldn't lock shader log file, closing."); fclose(C4ShaderLogFile); - C4ShaderLogFile = NULL; + C4ShaderLogFile = nullptr; } #else C4ShaderLogFile = fopen(Config.AtUserDataPath(C4CFN_LogShader), "wb"); @@ -100,8 +100,8 @@ bool OpenExtraLogs() bool CloseLog() { // close - if (C4ShaderLogFile) fclose(C4ShaderLogFile); C4ShaderLogFile = NULL; - if (C4LogFile) fclose(C4LogFile); C4LogFile = NULL; + if (C4ShaderLogFile) fclose(C4ShaderLogFile); C4ShaderLogFile = nullptr; + if (C4LogFile) fclose(C4LogFile); C4LogFile = nullptr; // ok return true; } diff --git a/src/lib/C4LogBuf.cpp b/src/lib/C4LogBuf.cpp index 7571ab12e..90158708d 100644 --- a/src/lib/C4LogBuf.cpp +++ b/src/lib/C4LogBuf.cpp @@ -30,10 +30,10 @@ C4LogBuffer::C4LogBuffer(int iSize, int iMaxLines, int iLBWidth, const char *szI szIndent = new char[strlen(szIndentChars)+1]; strcpy(szIndent, szIndentChars); } - else szIndent = NULL; + else szIndent = nullptr; // create buffers, if buffer size is given. Otherwise, create/grow them dynamically - if (iBufSize) szBuf = new char[iBufSize]; else szBuf=NULL; - if (iMaxLineCount) pLineDataBuf = new LineData[iMaxLineCount]; else pLineDataBuf=NULL; + if (iBufSize) szBuf = new char[iBufSize]; else szBuf=nullptr; + if (iMaxLineCount) pLineDataBuf = new LineData[iMaxLineCount]; else pLineDataBuf=nullptr; assert(fDynamicGrow || (iBufSize && iMaxLineCount)); } @@ -189,7 +189,7 @@ void C4LogBuffer::AppendLines(const char *szLine, CStdFont *pFont, DWORD dwClr, while ((szBufPos = szPos2)) { // find first occurance of any line break char - szPos2 = NULL; + szPos2 = nullptr; for (int i = 0; i < iLineBreakCharCount; ++i) if ((szBufFind = strchr(szBufPos, LineBreakChars[i]))) if (!szPos2 || szBufFind < szPos2) @@ -202,7 +202,7 @@ void C4LogBuffer::AppendLines(const char *szLine, CStdFont *pFont, DWORD dwClr, if (pFirstLineFont) { AppendLines(szBufPos, pFirstLineFont, dwClr); - pFirstLineFont = NULL; + pFirstLineFont = nullptr; } else AppendLines(szBufPos, pFont, dwClr); @@ -213,7 +213,7 @@ void C4LogBuffer::AppendLines(const char *szLine, CStdFont *pFont, DWORD dwClr, // no line breaks desired: Output all in one line if (!iLineBreakWidth || !pFont) { - AppendSingleLine(szLine, strlen(szLine), NULL, pFont, dwClr, true); + AppendSingleLine(szLine, strlen(szLine), nullptr, pFont, dwClr, true); } else { @@ -233,7 +233,7 @@ void C4LogBuffer::AppendLines(const char *szLine, CStdFont *pFont, DWORD dwClr, const char *szNextLine; int iNumChars = pFont->GetMessageBreak(szLine, &szNextLine, iBreakWdt); // add them - AppendSingleLine(szLine, iNumChars, iLineIndex ? szIndent : NULL, pFont, dwClr, !iLineIndex); + AppendSingleLine(szLine, iNumChars, iLineIndex ? szIndent : nullptr, pFont, dwClr, !iLineIndex); // next line szLine = szNextLine; ++iLineIndex; @@ -247,10 +247,10 @@ const char *C4LogBuffer::GetLine(int iLineIndex, CStdFont **ppFont, DWORD *pdwCl if (iLineIndex < 0) { iLineIndex += iLineCount; - if (iLineIndex < 0) return NULL; + if (iLineIndex < 0) return nullptr; } // range check - if (iLineIndex >= iLineCount) return NULL; + if (iLineIndex >= iLineCount) return nullptr; // assign data LineData &rData = pLineDataBuf[(iLineDataPos + iLineIndex) % iMaxLineCount]; if (ppFont) *ppFont = rData.pFont; diff --git a/src/lib/C4LogBuf.h b/src/lib/C4LogBuf.h index ea9febbf3..67174c08c 100644 --- a/src/lib/C4LogBuf.h +++ b/src/lib/C4LogBuf.h @@ -50,7 +50,7 @@ public: C4LogBuffer(int iSize, int iMaxLines, int iLBWidth, const char *szIndentChars=" ", bool fDynamicGrow = false, bool fMarkup = true); // ctor ~C4LogBuffer(); // dtor - void AppendLines(const char *szLine, CStdFont *pFont, DWORD dwClr, CStdFont *pFirstLineFont=NULL); // append message line to buffer; overwriting old lines if necessary + void AppendLines(const char *szLine, CStdFont *pFont, DWORD dwClr, CStdFont *pFirstLineFont=nullptr); // append message line to buffer; overwriting old lines if necessary const char *GetLine(int iLineIndex, CStdFont **ppFont, DWORD *pdwClr, bool *pNewParagraph) const; // get indexed line - negative indices -n return last-n'th-line void Clear(); // clear all lines diff --git a/src/lib/C4Stat.cpp b/src/lib/C4Stat.cpp index e156cb7a1..4c4306853 100644 --- a/src/lib/C4Stat.cpp +++ b/src/lib/C4Stat.cpp @@ -101,7 +101,7 @@ void C4MainStat::Show() for (ii=0; iipNext) diff --git a/src/lib/Standard.cpp b/src/lib/Standard.cpp index cc28babc0..201550cfa 100644 --- a/src/lib/Standard.cpp +++ b/src/lib/Standard.cpp @@ -334,7 +334,7 @@ const char *SSearch(const char *szString, const char *szIndex) { const char *cscr; size_t indexlen,match=0; - if (!szString || !szIndex) return NULL; + if (!szString || !szIndex) return nullptr; indexlen=SLen(szIndex); for (cscr=szString; cscr && *cscr; cscr++) { @@ -342,14 +342,14 @@ const char *SSearch(const char *szString, const char *szIndex) else match=0; if (match>=indexlen) return cscr+1; } - return NULL; + return nullptr; } const char *SSearchNoCase(const char *szString, const char *szIndex) { const char *cscr; size_t indexlen,match=0; - if (!szString || !szIndex) return NULL; + if (!szString || !szIndex) return nullptr; indexlen=SLen(szIndex); for (cscr=szString; cscr && *cscr; cscr++) { @@ -357,14 +357,14 @@ const char *SSearchNoCase(const char *szString, const char *szIndex) else match=0; if (match>=indexlen) return cscr+1; } - return NULL; + return nullptr; } void SWordWrap(char *szText, char cSpace, char cSepa, int iMaxLine) { if (!szText) return; // Scan string - char *cPos,*cpLastSpace=NULL; + char *cPos,*cpLastSpace=nullptr; int iLineRun=0; for (cPos=szText; *cPos; cPos++) { @@ -383,25 +383,25 @@ void SWordWrap(char *szText, char cSpace, char cSepa, int iMaxLine) const char *SAdvanceSpace(const char *szSPos) { - if (!szSPos) return NULL; + if (!szSPos) return nullptr; while (IsWhiteSpace(*szSPos)) szSPos++; return szSPos; } const char *SRewindSpace(const char *szSPos, const char *pBegin) { - if (!szSPos || !pBegin) return NULL; + if (!szSPos || !pBegin) return nullptr; while (IsWhiteSpace(*szSPos)) { szSPos--; - if (szSPosisCompiler(), fNaming = pComp->hasNaming(); // Compiling? Clear object before - if(fCompiler) { delete adapt.rpObj; adapt.rpObj = NULL; } + if(fCompiler) { delete adapt.rpObj; adapt.rpObj = nullptr; } // Null checks - different with naming support. if(adapt.fAllowNull) if(fNaming) diff --git a/src/lib/StdBuf.cpp b/src/lib/StdBuf.cpp index 286a50594..8073b9336 100644 --- a/src/lib/StdBuf.cpp +++ b/src/lib/StdBuf.cpp @@ -149,29 +149,29 @@ void StdBuf::CompileFunc(StdCompiler *pComp, int iType) #ifdef _WIN32 StdStrBuf::StdStrBuf(const wchar_t * utf16) { - int len = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, 0, 0); + int len = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, nullptr, 0, 0, 0); SetSize(len); WideCharToMultiByte(CP_UTF8, 0, utf16, -1, getMData(), getSize(), 0, 0); } StdStrBuf::wchar_t_holder StdStrBuf::GetWideChar() const { - if (!getSize()) return StdStrBuf::wchar_t_holder(NULL); + if (!getSize()) return StdStrBuf::wchar_t_holder(nullptr); - int len = MultiByteToWideChar(CP_UTF8, 0, getData(), getSize(), NULL, 0); + int len = MultiByteToWideChar(CP_UTF8, 0, getData(), getSize(), nullptr, 0); wchar_t * p = new wchar_t[len]; MultiByteToWideChar(CP_UTF8, 0, getData(), getSize(), p, len); return StdStrBuf::wchar_t_holder(p); } StdBuf StdStrBuf::GetWideCharBuf() { - int len = MultiByteToWideChar(CP_UTF8, 0, getData(), getSize(), NULL, 0); + int len = MultiByteToWideChar(CP_UTF8, 0, getData(), getSize(), nullptr, 0); StdBuf r; r.SetSize(len * sizeof(wchar_t)); MultiByteToWideChar(CP_UTF8, 0, getData(), getSize(), getMBufPtr(r), len); return r; } StdStrBuf::wchar_t_holder GetWideChar(const char * utf8, bool double_null_terminate) { - int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0); + int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, nullptr, 0); if (double_null_terminate) ++len; wchar_t * p = new wchar_t[len]; MultiByteToWideChar(CP_UTF8, 0, utf8, -1, p, len); @@ -180,7 +180,7 @@ StdStrBuf::wchar_t_holder GetWideChar(const char * utf8, bool double_null_termin } StdBuf GetWideCharBuf(const char * utf8) { - int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0); + int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, nullptr, 0); StdBuf r; r.SetSize(len * sizeof(wchar_t)); MultiByteToWideChar(CP_UTF8, 0, utf8, -1, getMBufPtr(r), len); return r; diff --git a/src/lib/StdBuf.h b/src/lib/StdBuf.h index ea473f594..56a29b6bf 100644 --- a/src/lib/StdBuf.h +++ b/src/lib/StdBuf.h @@ -46,7 +46,7 @@ public: // Will take over buffer ownership. Copies data if specified. // Note: Construct with Buf2.getRef() to construct a reference (This will work for a constant Buf2, too) StdBuf(StdBuf & Buf2, bool fCopy = false) - : fRef(true), pData(NULL), iSize(0) + : fRef(true), pData(nullptr), iSize(0) { if (fCopy) Copy(Buf2); @@ -56,7 +56,7 @@ public: Ref(Buf2); } StdBuf(const StdBuf & Buf2, bool fCopy = true) - : fRef(true), pData(NULL), iSize(0) + : fRef(true), pData(nullptr), iSize(0) { if (fCopy) Copy(Buf2); @@ -64,7 +64,7 @@ public: Ref(Buf2); } StdBuf(StdBuf && Buf2) noexcept - : fRef(true), pData(NULL), iSize(0) + : fRef(true), pData(nullptr), iSize(0) { if (!Buf2.isRef()) Take(std::move(Buf2)); @@ -140,7 +140,7 @@ public: // Transfer puffer ownership to the caller void *GrabPointer() { - if (isNull()) return NULL; + if (isNull()) return nullptr; // Do not give out a buffer which someone else will free if (fRef) Copy(); void *pMData = getMData(); @@ -198,7 +198,7 @@ public: void Clear() { if (!fRef) free(pMData); - pMData = NULL; fRef = true; iSize = 0; + pMData = nullptr; fRef = true; iSize = 0; } // Free buffer that had been grabbed static void DeletePointer(void *data) diff --git a/src/lib/StdCompiler.cpp b/src/lib/StdCompiler.cpp index d137526aa..5964a265b 100644 --- a/src/lib/StdCompiler.cpp +++ b/src/lib/StdCompiler.cpp @@ -314,7 +314,7 @@ void StdCompilerINIWrite::Raw(void *pData, size_t iSize, RawCompileType eType) void StdCompilerINIWrite::Begin() { - pNaming = NULL; + pNaming = nullptr; fPutName = false; iDepth = 0; fInSection = false; @@ -404,7 +404,7 @@ void StdCompilerINIWrite::PutName(bool fSection) // *** StdCompilerINIRead StdCompilerINIRead::StdCompilerINIRead() - : pNameRoot(NULL), iDepth(0), iRealDepth(0) + : pNameRoot(nullptr), iDepth(0), iRealDepth(0) { } @@ -443,7 +443,7 @@ bool StdCompilerINIRead::Name(const char *szName) // Save tree position, indicate success pName = pNode; pPos = pName->Pos; - pReenter = NULL; + pReenter = nullptr; iRealDepth++; return true; } @@ -474,7 +474,7 @@ void StdCompilerINIRead::NameEnd(bool fBreak) // Decrease depth iDepth--; // This is the middle of nowhere - pPos = NULL; pReenter = NULL; + pPos = nullptr; pReenter = nullptr; } bool StdCompilerINIRead::FollowName(const char *szName) @@ -512,13 +512,13 @@ bool StdCompilerINIRead::Separator(Sep eSep) return Name(CurrName.getData()); } // Position saved back from separator mismatch? - if (pReenter) { pPos = pReenter; pReenter = NULL; } + if (pReenter) { pPos = pReenter; pReenter = nullptr; } // Nothing to read? if (!pPos) return false; // Read (while skipping over whitespace) SkipWhitespace(); // Separator mismatch? Let all read attempts fail until the correct separator is found or the naming ends. - if (*pPos != SeparatorToChar(eSep)) { pReenter = pPos; pPos = NULL; return false; } + if (*pPos != SeparatorToChar(eSep)) { pReenter = pPos; pPos = nullptr; return false; } // Go over separator, success pPos++; return true; @@ -527,7 +527,7 @@ bool StdCompilerINIRead::Separator(Sep eSep) void StdCompilerINIRead::NoSeparator() { // Position saved back from separator mismatch? - if (pReenter) { pPos = pReenter; pReenter = NULL; } + if (pReenter) { pPos = pReenter; pReenter = nullptr; } } int StdCompilerINIRead::NameCount(const char *szName) @@ -556,7 +556,7 @@ const char *StdCompilerINIRead::GetNameByIndex(size_t idx) const if (!idx--) return pNode->Name.getData(); // index out of range - return NULL; + return nullptr; } // Various data readers @@ -699,7 +699,7 @@ void StdCompilerINIRead::Begin() CreateNameTree(); // Start must be inside a section iDepth = iRealDepth = 0; - pPos = NULL; pReenter = NULL; + pPos = nullptr; pReenter = nullptr; } void StdCompilerINIRead::End() { @@ -773,7 +773,7 @@ void StdCompilerINIRead::FreeNameTree() { // free all nodes FreeNameNode(pNameRoot); - pName = pNameRoot = NULL; + pName = pNameRoot = nullptr; } void StdCompilerINIRead::FreeNameNode(NameNode *pDelNode) @@ -792,7 +792,7 @@ void StdCompilerINIRead::FreeNameNode(NameNode *pDelNode) else { pNode = pNode->Parent; - if (pNode) pNode->FirstChild = NULL; + if (pNode) pNode->FirstChild = nullptr; } delete pDelete; } diff --git a/src/lib/StdCompiler.h b/src/lib/StdCompiler.h index 324f148b5..9e4233888 100644 --- a/src/lib/StdCompiler.h +++ b/src/lib/StdCompiler.h @@ -45,7 +45,7 @@ class StdCompiler public: - StdCompiler() : pWarnCB(NULL), pWarnData(NULL) + StdCompiler() : pWarnCB(nullptr), pWarnData(nullptr) #ifdef STDCOMPILER_EXCEPTION_WORKAROUND , fFailSafe(false), fFail(false) #endif @@ -86,7 +86,7 @@ public: // for whatever reason (suppress warning messages). virtual bool Name(const char *szName) { return true; } virtual void NameEnd(bool fBreak = false) { } - virtual const char *GetNameByIndex(size_t idx) const { return NULL; } + virtual const char *GetNameByIndex(size_t idx) const { return nullptr; } // Special: A naming that follows to the currently active naming (on the same level). // Note this will end the current naming, so no additional NameEnd() is needed. @@ -98,7 +98,7 @@ public: virtual bool Default(const char *szName) { return true; } // Return count of sub-namings. May be unimplemented. - virtual int NameCount(const char *szName = NULL) { assert(false); return 0; } + virtual int NameCount(const char *szName = nullptr) { assert(false); return 0; } // * Separation @@ -388,14 +388,14 @@ void CompileFromBuf(StructT &&TargetStruct, const typename CompT::InT &SrcBuf) template StructT * CompileFromBufToNew(const typename CompT::InT &SrcBuf) { - StructT *pStruct = NULL; + StructT *pStruct = nullptr; CompileFromBuf(mkPtrAdaptNoNull(pStruct), SrcBuf); return pStruct; } template StructT * CompileFromBufToNewNamed(const typename CompT::InT &SrcBuf, const char *szName) { - StructT *pStruct = NULL; + StructT *pStruct = nullptr; CompileFromBuf(mkNamingAdapt(mkPtrAdaptNoNull(pStruct), szName), SrcBuf); return pStruct; } @@ -421,7 +421,7 @@ public: // Naming virtual bool Name(const char *szName) { return false; } - virtual int NameCount(const char *szName = NULL) { return 0; } + virtual int NameCount(const char *szName = nullptr) { return 0; } // Data readers virtual void DWord(int32_t &rInt) { } @@ -643,7 +643,7 @@ public: virtual void NoSeparator(); // Counters - virtual int NameCount(const char *szName = NULL); + virtual int NameCount(const char *szName = nullptr); // Data writers virtual void DWord(int32_t &rInt); @@ -684,10 +684,10 @@ protected: // Name number in parent map const char *Pos; // Constructor - NameNode(NameNode *pParent = NULL) : + NameNode(NameNode *pParent = nullptr) : Section(false), Parent(pParent), - FirstChild(NULL), PrevChild(NULL), NextChild(NULL), LastChild(NULL), - Indent(-1), Pos(NULL) + FirstChild(nullptr), PrevChild(nullptr), NextChild(nullptr), LastChild(nullptr), + Indent(-1), Pos(nullptr) { } }; NameNode *pNameRoot, *pName; diff --git a/src/lib/StdMesh.cpp b/src/lib/StdMesh.cpp index 8f4734d72..11580dbd1 100644 --- a/src/lib/StdMesh.cpp +++ b/src/lib/StdMesh.cpp @@ -41,7 +41,7 @@ static int StdMeshFaceCmp(const StdMeshFaceOrderHelper& h1, const StdMeshFaceOrd #define SORT_CMP StdMeshFaceCmp #include "timsort/sort.h" -std::vector* StdMeshInstance::SerializableValueProvider::IDs = NULL; +std::vector* StdMeshInstance::SerializableValueProvider::IDs = nullptr; namespace { @@ -150,7 +150,7 @@ namespace void CompileFunc(StdCompiler* pComp) { const StdMeshInstance::SerializableValueProvider::IDBase* id; - StdMeshInstance::SerializableValueProvider* svp = NULL; + StdMeshInstance::SerializableValueProvider* svp = nullptr; if(pComp->isCompiler()) { @@ -248,7 +248,7 @@ namespace // Reset all animation list entries corresponding to node or its children void ClearAnimationListRecursively(std::vector& list, StdMeshInstance::AnimationNode* node) { - list[node->GetNumber()] = NULL; + list[node->GetNumber()] = nullptr; if (node->GetType() == StdMeshInstance::AnimationNode::LinearInterpolationNode) { @@ -392,14 +392,14 @@ const StdMeshBone* StdMeshSkeleton::GetBoneByName(const StdStrBuf& name) const if (Bones[i]->Name == name) return Bones[i]; - return NULL; + return nullptr; } const StdMeshAnimation* StdMeshSkeleton::GetAnimationByName(const StdStrBuf& name) const { StdCopyStrBuf name2(name); std::map::const_iterator iter = Animations.find(name2); - if (iter == Animations.end()) return NULL; + if (iter == Animations.end()) return nullptr; return &iter->second; } @@ -438,7 +438,7 @@ void StdMeshSkeleton::MirrorAnimation(const StdMeshAnimation& animation) throw std::runtime_error(std::string("No counterpart for bone ") + bone.Name.getData() + " found"); // Make sure to not swap tracks twice - if ((animation.Tracks[i] != NULL || animation.Tracks[other_bone->Index] != NULL) && + if ((animation.Tracks[i] != nullptr || animation.Tracks[other_bone->Index] != nullptr) && other_bone->Index > bone.Index) { std::swap(new_anim.Tracks[i], new_anim.Tracks[other_bone->Index]); @@ -447,18 +447,18 @@ void StdMeshSkeleton::MirrorAnimation(const StdMeshAnimation& animation) StdMeshTransformation other_own_trans = other_bone->GetParent()->InverseTransformation * other_bone->Transformation; // Mirror all the keyframes of both tracks - if (new_anim.Tracks[i] != NULL) + if (new_anim.Tracks[i] != nullptr) for (std::map::iterator iter = new_anim.Tracks[i]->Frames.begin(); iter != new_anim.Tracks[i]->Frames.end(); ++iter) MirrorKeyFrame(iter->second, own_trans, StdMeshTransformation::Inverse(other_own_trans)); - if (new_anim.Tracks[other_bone->Index] != NULL) + if (new_anim.Tracks[other_bone->Index] != nullptr) for (std::map::iterator iter = new_anim.Tracks[other_bone->Index]->Frames.begin(); iter != new_anim.Tracks[other_bone->Index]->Frames.end(); ++iter) MirrorKeyFrame(iter->second, other_own_trans, StdMeshTransformation::Inverse(own_trans)); } } else if (bone.Name.Compare_(".N", bone.Name.getLength() - 2) != 0) { - if (new_anim.Tracks[i] != NULL) + if (new_anim.Tracks[i] != nullptr) { StdMeshTransformation own_trans = bone.Transformation; if (bone.GetParent()) own_trans = bone.GetParent()->InverseTransformation * bone.Transformation; @@ -494,7 +494,7 @@ void StdMeshSkeleton::InsertAnimation(const StdMeshSkeleton& source, const StdMe // sort the tracks according to the matched bones for (unsigned int i = 0; i < anim.Tracks.size(); ++i) { - if (bone_index_source[i] > -1 && animation.Tracks[bone_index_source[i]] != NULL) + if (bone_index_source[i] > -1 && animation.Tracks[bone_index_source[i]] != nullptr) { anim.Tracks[i] = new StdMeshTrack(*animation.Tracks[bone_index_source[i]]); } @@ -547,7 +547,7 @@ std::vector StdMeshSkeleton::GetMatchingBones(const StdMeshSkeleton& child_ } StdSubMesh::StdSubMesh() : - Material(NULL), vertex_buffer_offset(0), index_buffer_offset(0) + Material(nullptr), vertex_buffer_offset(0), index_buffer_offset(0) { } @@ -612,7 +612,7 @@ void StdMesh::UpdateVBO() { // Allocate VBO backing memory. If this mesh's skeleton has no animations // defined, we assume that the VBO will not change frequently. - glBufferData(GL_ARRAY_BUFFER, total_vertices * sizeof(StdMeshVertex), NULL, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, total_vertices * sizeof(StdMeshVertex), nullptr, GL_STATIC_DRAW); void *map = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); uint8_t *buffer = static_cast(map); uint8_t *cursor = buffer; @@ -653,7 +653,7 @@ void StdMesh::UpdateIBO() size_t total_faces = 0; for (auto &submesh : SubMeshes) total_faces += submesh.GetNumFaces(); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, total_faces * 3 * sizeof(GLuint), NULL, GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, total_faces * 3 * sizeof(GLuint), nullptr, GL_STATIC_DRAW); size_t offset = 0; for (auto &submesh : SubMeshes) { @@ -666,7 +666,7 @@ void StdMesh::UpdateIBO() #endif StdSubMeshInstance::StdSubMeshInstance(StdMeshInstance& instance, const StdSubMesh& submesh, float completion): - base(&submesh), Material(NULL), CurrentFaceOrdering(FO_Fixed) + base(&submesh), Material(nullptr), CurrentFaceOrdering(FO_Fixed) { #ifndef USE_CONSOLE LoadFacesForCompletion(instance, submesh, completion); @@ -793,28 +793,28 @@ void StdMeshInstance::SerializableValueProvider::CompileFunc(StdCompiler* pComp) } StdMeshInstanceAnimationNode::StdMeshInstanceAnimationNode(): - Type(LeafNode), Parent(NULL) + Type(LeafNode), Parent(nullptr) { - Leaf.Animation = NULL; - Leaf.Position = NULL; + Leaf.Animation = nullptr; + Leaf.Position = nullptr; } StdMeshInstanceAnimationNode::StdMeshInstanceAnimationNode(const StdMeshAnimation* animation, ValueProvider* position): - Type(LeafNode), Parent(NULL) + Type(LeafNode), Parent(nullptr) { Leaf.Animation = animation; Leaf.Position = position; } StdMeshInstanceAnimationNode::StdMeshInstanceAnimationNode(const StdMeshBone* bone, const StdMeshTransformation& trans): - Type(CustomNode), Parent(NULL) + Type(CustomNode), Parent(nullptr) { Custom.BoneIndex = bone->Index; Custom.Transformation = new StdMeshTransformation(trans); } StdMeshInstanceAnimationNode::StdMeshInstanceAnimationNode(AnimationNode* child_left, AnimationNode* child_right, ValueProvider* weight): - Type(LinearInterpolationNode), Parent(NULL) + Type(LinearInterpolationNode), Parent(nullptr) { LinearInterpolation.ChildLeft = child_left; LinearInterpolation.ChildRight = child_right; @@ -879,7 +879,7 @@ void StdMeshInstanceAnimationNode::CompileFunc(StdCompiler* pComp, const StdMesh { "Custom", CustomNode }, { "LinearInterpolation", LinearInterpolationNode }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; pComp->Value(mkNamingAdapt(Slot, "Slot")); @@ -942,14 +942,14 @@ void StdMeshInstanceAnimationNode::CompileFunc(StdCompiler* pComp, const StdMesh void StdMeshInstanceAnimationNode::DenumeratePointers() { - StdMeshInstance::SerializableValueProvider* value_provider = NULL; + StdMeshInstance::SerializableValueProvider* value_provider = nullptr; switch(Type) { case LeafNode: value_provider = dynamic_cast(Leaf.Position); break; case CustomNode: - value_provider = NULL; + value_provider = nullptr; break; case LinearInterpolationNode: value_provider = dynamic_cast(LinearInterpolation.Weight); @@ -962,14 +962,14 @@ void StdMeshInstanceAnimationNode::DenumeratePointers() void StdMeshInstanceAnimationNode::ClearPointers(class C4Object* pObj) { - StdMeshInstance::SerializableValueProvider* value_provider = NULL; + StdMeshInstance::SerializableValueProvider* value_provider = nullptr; switch(Type) { case LeafNode: value_provider = dynamic_cast(Leaf.Position); break; case CustomNode: - value_provider = NULL; + value_provider = nullptr; break; case LinearInterpolationNode: value_provider = dynamic_cast(LinearInterpolation.Weight); @@ -981,7 +981,7 @@ void StdMeshInstanceAnimationNode::ClearPointers(class C4Object* pObj) } StdMeshInstance::AttachedMesh::AttachedMesh(): - Number(0), Parent(NULL), Child(NULL), OwnChild(true), ChildDenumerator(NULL), ParentBone(0), ChildBone(0), FinalTransformDirty(false) + Number(0), Parent(nullptr), Child(nullptr), OwnChild(true), ChildDenumerator(nullptr), ParentBone(0), ChildBone(0), FinalTransformDirty(false) { } @@ -1039,7 +1039,7 @@ void StdMeshInstance::AttachedMesh::CompileFunc(StdCompiler* pComp, DenumeratorF { { "MatchSkeleton", AM_MatchSkeleton }, { "DrawBefore", AM_DrawBefore }, - { NULL, 0 } + { nullptr, 0 } }; pComp->Value(mkNamingAdapt(Number, "Number")); @@ -1058,7 +1058,7 @@ void StdMeshInstance::AttachedMesh::DenumeratePointers() { ChildDenumerator->DenumeratePointers(this); - assert(Child != NULL); + assert(Child != nullptr); Child->AttachParent = this; MapBonesOfChildToParent(Parent->GetMesh().GetSkeleton(), Child->GetMesh().GetSkeleton()); @@ -1085,7 +1085,7 @@ void StdMeshInstance::AttachedMesh::MapBonesOfChildToParent(const StdMeshSkeleto StdMeshInstance::StdMeshInstance(const StdMesh& mesh, float completion): Mesh(&mesh), Completion(completion), BoneTransforms(Mesh->GetSkeleton().GetNumBones(), StdMeshMatrix::Identity()), - SubMeshInstances(Mesh->GetNumSubMeshes()), AttachParent(NULL), + SubMeshInstances(Mesh->GetNumSubMeshes()), AttachParent(nullptr), BoneTransformsDirty(false) #ifndef USE_CONSOLE , ibo(0), vaoid(0) @@ -1180,7 +1180,7 @@ void StdMeshInstance::SetCompletion(float completion) StdMeshInstance::AnimationNode* StdMeshInstance::PlayAnimation(const StdStrBuf& animation_name, int slot, AnimationNode* sibling, ValueProvider* position, ValueProvider* weight, bool stop_previous_animation) { const StdMeshAnimation* animation = Mesh->GetSkeleton().GetAnimationByName(animation_name); - if (!animation) { delete position; delete weight; return NULL; } + if (!animation) { delete position; delete weight; return nullptr; } return PlayAnimation(*animation, slot, sibling, position, weight, stop_previous_animation); } @@ -1205,7 +1205,7 @@ void StdMeshInstance::StopAnimation(AnimationNode* node) ClearAnimationListRecursively(AnimationNodes, node); AnimationNode* parent = node->Parent; - if (parent == NULL) + if (parent == nullptr) { AnimationNodeList::iterator iter = GetStackIterForSlot(node->Slot, false); assert(iter != AnimationStack.end() && *iter == node); @@ -1221,12 +1221,12 @@ void StdMeshInstance::StopAnimation(AnimationNode* node) if (parent->LinearInterpolation.ChildLeft == node) { other_child = parent->LinearInterpolation.ChildRight; - parent->LinearInterpolation.ChildRight = NULL; + parent->LinearInterpolation.ChildRight = nullptr; } else { other_child = parent->LinearInterpolation.ChildLeft; - parent->LinearInterpolation.ChildLeft = NULL; + parent->LinearInterpolation.ChildLeft = nullptr; } if (parent->Parent) @@ -1244,29 +1244,29 @@ void StdMeshInstance::StopAnimation(AnimationNode* node) assert(iter != AnimationStack.end() && *iter == parent); *iter = other_child; - other_child->Parent = NULL; + other_child->Parent = nullptr; } - AnimationNodes[parent->Number] = NULL; + AnimationNodes[parent->Number] = nullptr; // Recursively deletes parent and its descendants delete parent; } - while (!AnimationNodes.empty() && AnimationNodes.back() == NULL) + while (!AnimationNodes.empty() && AnimationNodes.back() == nullptr) AnimationNodes.erase(AnimationNodes.end()-1); SetBoneTransformsDirty(true); } StdMeshInstance::AnimationNode* StdMeshInstance::GetAnimationNodeByNumber(unsigned int number) { - if (number >= AnimationNodes.size()) return NULL; + if (number >= AnimationNodes.size()) return nullptr; return AnimationNodes[number]; } StdMeshInstance::AnimationNode* StdMeshInstance::GetRootAnimationForSlot(int slot) { AnimationNodeList::iterator iter = GetStackIterForSlot(slot, false); - if (iter == AnimationStack.end()) return NULL; + if (iter == AnimationStack.end()) return nullptr; return *iter; } @@ -1349,7 +1349,7 @@ StdMeshInstance::AttachedMesh* StdMeshInstance::AttachMesh(const StdMesh& mesh, StdMeshInstance* instance = new StdMeshInstance(mesh, 1.0f); AttachedMesh* attach = AttachMesh(*instance, auto_denumerator.release(), parent_bone, child_bone, transformation, flags, true, attach_number); - if (!attach) { delete instance; return NULL; } + if (!attach) { delete instance; return nullptr; } return attach; } @@ -1359,7 +1359,7 @@ StdMeshInstance::AttachedMesh* StdMeshInstance::AttachMesh(StdMeshInstance& inst // Owned attach children must be set via the topmost instance, to ensure // attach number uniqueness. - if (AttachParent && AttachParent->OwnChild) return NULL; + if (AttachParent && AttachParent->OwnChild) return nullptr; // Find free index. unsigned int number = 0; @@ -1370,7 +1370,7 @@ StdMeshInstance::AttachedMesh* StdMeshInstance::AttachMesh(StdMeshInstance& inst if (attach_number != 0) { AttachedMesh* attach = GetAttachedMeshByNumber(attach_number); - if (attach == NULL) return NULL; + if (attach == nullptr) return nullptr; direct_parent = attach->Child; } @@ -1382,16 +1382,16 @@ StdMeshInstance::AttachedMesh* StdMeshInstance::AttachMeshImpl(StdMeshInstance& std::unique_ptr auto_denumerator(denumerator); // We don't allow an instance to be attached to multiple parent instances for now - if (instance.AttachParent) return NULL; + if (instance.AttachParent) return nullptr; // Make sure there are no cyclic attachments - for (StdMeshInstance* Parent = this; Parent->AttachParent != NULL; Parent = Parent->AttachParent->Parent) + for (StdMeshInstance* Parent = this; Parent->AttachParent != nullptr; Parent = Parent->AttachParent->Parent) if (Parent == &instance) - return NULL; + return nullptr; const StdMeshBone* parent_bone_obj = Mesh->GetSkeleton().GetBoneByName(parent_bone); const StdMeshBone* child_bone_obj = instance.Mesh->GetSkeleton().GetBoneByName(child_bone); - if (!parent_bone_obj || !child_bone_obj) return NULL; + if (!parent_bone_obj || !child_bone_obj) return nullptr; AttachedMesh* attach = new AttachedMesh(new_attach_number, this, &instance, own_child, auto_denumerator.release(), parent_bone_obj->Index, child_bone_obj->Index, transformation, flags); instance.AttachParent = attach; @@ -1415,7 +1415,7 @@ bool StdMeshInstance::DetachMesh(unsigned int number) // Reset attach parent of child so it does not try // to detach itself on destruction. - attached->Child->AttachParent = NULL; + attached->Child->AttachParent = nullptr; attached->Parent->AttachChildren.erase(iter); delete attached; @@ -1431,7 +1431,7 @@ bool StdMeshInstance::DetachMesh(unsigned int number) StdMeshInstance::AttachedMesh* StdMeshInstance::GetAttachedMeshByNumber(unsigned int number) const { - StdMeshInstance::AttachedMesh* result = NULL; + StdMeshInstance::AttachedMesh* result = nullptr; ScanAttachTree(AttachChildren.begin(), AttachChildren.end(), [number, &result](AttachedMeshList::const_iterator iter) { @@ -1458,7 +1458,7 @@ void StdMeshInstance::SetMaterial(size_t i, const StdMeshMaterial& material) const StdMeshMatrix& StdMeshInstance::GetBoneTransform(size_t i) const { - if ((AttachParent != NULL) && (AttachParent->GetFlags() & AM_MatchSkeleton)) + if ((AttachParent != nullptr) && (AttachParent->GetFlags() & AM_MatchSkeleton)) { assert(i < AttachParent->MatchedBoneInParentSkeleton.size()); @@ -1475,7 +1475,7 @@ const StdMeshMatrix& StdMeshInstance::GetBoneTransform(size_t i) const size_t StdMeshInstance::GetBoneCount() const { - if ((AttachParent != NULL) && (AttachParent->GetFlags() & AM_MatchSkeleton)) + if ((AttachParent != nullptr) && (AttachParent->GetFlags() & AM_MatchSkeleton)) return AttachParent->MatchedBoneInParentSkeleton.size(); else return BoneTransforms.size(); @@ -1616,10 +1616,10 @@ void StdMeshInstance::CompileFunc(StdCompiler* pComp, AttachedMesh::DenumeratorF for(int32_t i = 0; i < iAnimCnt; ++i) { - AnimationNode* node = NULL; + AnimationNode* node = nullptr; pComp->Value(mkParAdapt(mkNamingPtrAdapt(node, "AnimationNode"), Mesh)); AnimationNodeList::iterator iter = GetStackIterForSlot(node->Slot, true); - if(*iter != NULL) { delete node; pComp->excCorrupt("Duplicate animation slot index"); } + if(*iter != nullptr) { delete node; pComp->excCorrupt("Duplicate animation slot index"); } *iter = node; // Add nodes into lookup table @@ -1631,7 +1631,7 @@ void StdMeshInstance::CompileFunc(StdCompiler* pComp, AttachedMesh::DenumeratorF if (AnimationNodes.size() <= node->Number) AnimationNodes.resize(node->Number+1); - if(AnimationNodes[node->Number] != NULL) pComp->excCorrupt("Duplicate animation node number"); + if(AnimationNodes[node->Number] != nullptr) pComp->excCorrupt("Duplicate animation node number"); AnimationNodes[node->Number] = node; if(node->Type == AnimationNode::LinearInterpolationNode) @@ -1740,14 +1740,14 @@ StdMeshInstance::AnimationNodeList::iterator StdMeshInstance::GetStackIterForSlo if (!create) return AnimationStack.end(); else - return AnimationStack.insert(iter, NULL); + return AnimationStack.insert(iter, nullptr); } } if (!create) return AnimationStack.end(); else - return AnimationStack.insert(AnimationStack.end(), NULL); + return AnimationStack.insert(AnimationStack.end(), nullptr); } void StdMeshInstance::InsertAnimationNode(AnimationNode* node, int slot, AnimationNode* sibling, ValueProvider* weight, bool stop_previous_animation) @@ -1761,24 +1761,24 @@ void StdMeshInstance::InsertAnimationNode(AnimationNode* node, int slot, Animati if (sibling && stop_previous_animation) { StopAnimation(sibling); - sibling = NULL; + sibling = nullptr; } // Find two subsequent numbers in case we need to create two nodes, so // script can deduce the second node. unsigned int Number1, Number2; for (Number1 = 0; Number1 < AnimationNodes.size(); ++Number1) - if (AnimationNodes[Number1] == NULL && (!sibling || Number1+1 == AnimationNodes.size() || AnimationNodes[Number1+1] == NULL)) + if (AnimationNodes[Number1] == nullptr && (!sibling || Number1+1 == AnimationNodes.size() || AnimationNodes[Number1+1] == nullptr)) break; /* for(Number2 = Number1+1; Number2 < AnimationNodes.size(); ++Number2) - if(AnimationNodes[Number2] == NULL) + if(AnimationNodes[Number2] == nullptr) break;*/ Number2 = Number1 + 1; weight->Value = Clamp(weight->Value, Fix0, itofix(1)); - if (Number1 == AnimationNodes.size()) AnimationNodes.push_back( (StdMeshInstance::AnimationNode*) NULL); - if (sibling && Number2 == AnimationNodes.size()) AnimationNodes.push_back( (StdMeshInstance::AnimationNode*) NULL); + if (Number1 == AnimationNodes.size()) AnimationNodes.push_back( (StdMeshInstance::AnimationNode*) nullptr); + if (sibling && Number2 == AnimationNodes.size()) AnimationNodes.push_back( (StdMeshInstance::AnimationNode*) nullptr); AnimationNodes[Number1] = node; node->Number = Number1; @@ -1807,7 +1807,7 @@ void StdMeshInstance::InsertAnimationNode(AnimationNode* node, int slot, Animati // set new parent AnimationNodeList::iterator iter = GetStackIterForSlot(slot, false); // slot must not be empty, since sibling uses same slot - assert(iter != AnimationStack.end() && *iter != NULL); + assert(iter != AnimationStack.end() && *iter != nullptr); *iter = parent; } @@ -1826,7 +1826,7 @@ void StdMeshInstance::InsertAnimationNode(AnimationNode* node, int slot, Animati bool StdMeshInstance::ExecuteAnimationNode(AnimationNode* node) { - ValueProvider* provider = NULL; + ValueProvider* provider = nullptr; C4Real min; C4Real max; @@ -1966,7 +1966,7 @@ void StdMeshInstance::UpdateIBO() glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo); // TODO: Optimize mode. In many cases this is still fairly static. - glBufferData(GL_ELEMENT_ARRAY_BUFFER, total_faces * 3 * sizeof(GLuint), NULL, GL_STREAM_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, total_faces * 3 * sizeof(GLuint), nullptr, GL_STREAM_DRAW); } else { diff --git a/src/lib/StdMesh.h b/src/lib/StdMesh.h index f999e7e58..e739ac16e 100644 --- a/src/lib/StdMesh.h +++ b/src/lib/StdMesh.h @@ -439,7 +439,7 @@ public: { assert(IDs); IDs->erase(std::find(IDs->begin(), IDs->end(), this)); - if (!IDs->size()) { delete IDs; IDs = NULL; } + if (!IDs->size()) { delete IDs; IDs = nullptr; } } public: @@ -461,20 +461,20 @@ public: static const IDBase* Lookup(const char* name) { - if(!IDs) return NULL; + if(!IDs) return nullptr; for(unsigned int i = 0; i < IDs->size(); ++i) if(strcmp((*IDs)[i]->name, name) == 0) return (*IDs)[i]; - return NULL; + return nullptr; } static const IDBase* Lookup(const std::type_info& type) { - if(!IDs) return NULL; + if(!IDs) return nullptr; for(unsigned int i = 0; i < IDs->size(); ++i) if((*IDs)[i]->type == type) return (*IDs)[i]; - return NULL; + return nullptr; } virtual void CompileFunc(StdCompiler* pComp); diff --git a/src/lib/StdMeshLoader.h b/src/lib/StdMeshLoader.h index 4a854892c..04e3a04e4 100644 --- a/src/lib/StdMeshLoader.h +++ b/src/lib/StdMeshLoader.h @@ -46,7 +46,7 @@ public: // Interface to load skeleton files. Given a filename occuring in the // mesh file, this should load the skeleton file from wherever the mesh file // was loaded from, for example from a C4Group. Return default-construted -// StdStrBuf with NULL data in case of error. +// StdStrBuf with nullptr data in case of error. class StdMeshSkeletonLoader { public: diff --git a/src/lib/StdMeshLoaderBinary.cpp b/src/lib/StdMeshLoaderBinary.cpp index 120101713..7f0dcf56a 100644 --- a/src/lib/StdMeshLoaderBinary.cpp +++ b/src/lib/StdMeshLoaderBinary.cpp @@ -182,9 +182,9 @@ namespace void StdMeshSkeletonLoader::StoreSkeleton(const char* groupname, const char* filename, std::shared_ptr skeleton) { - assert(groupname != NULL); - assert(filename != NULL); - assert(skeleton != NULL); + assert(groupname != nullptr); + assert(filename != nullptr); + assert(skeleton != nullptr); // Create mirrored animations (#401) // this is still going to be somewhere else, but for now it will keep moving around @@ -299,7 +299,7 @@ std::shared_ptr StdMeshSkeletonLoader::GetSkeletonByName(const StdCopyStrBuf filename(name); std::map>::const_iterator iter = Skeletons.find(filename); - if (iter == Skeletons.end()) return NULL; + if (iter == Skeletons.end()) return nullptr; return iter->second; } @@ -340,7 +340,7 @@ void StdMeshSkeletonLoader::LoadSkeletonBinary(const char* groupname, const char if (bones.find(cbone.handle) != bones.end()) throw Ogre::Skeleton::IdNotUnique(); auto bone = std::make_unique(); - bone->Parent = NULL; + bone->Parent = nullptr; bone->ID = cbone.handle; bone->Name = cbone.name.c_str(); bone->Transformation.translate = cbone.position; @@ -371,7 +371,7 @@ void StdMeshSkeletonLoader::LoadSkeletonBinary(const char* groupname, const char } // Find master bone (i.e., the one without a parent) - StdMeshBone *master = NULL; + StdMeshBone *master = nullptr; for (auto& b: bones) { if (!b.second->Parent) @@ -407,7 +407,7 @@ void StdMeshSkeletonLoader::LoadSkeletonBinary(const char* groupname, const char { const StdMeshBone &bone = Skeleton->GetBone(handle_lookup[catrack->bone]); StdMeshTrack *&track = anim.Tracks[bone.Index]; - if (track != NULL) + if (track != nullptr) throw Ogre::Skeleton::MultipleBoneTracks(); track = new StdMeshTrack; for(auto &catkf: catrack->keyframes) @@ -466,7 +466,7 @@ StdMesh *StdMeshLoader::LoadMeshBinary(const char *sourcefile, size_t length, co // with this exception the assert below is useless // also, I think the bone_lookup should only be used if there is a skeleton anyway // so there could be meshes without bones even? - if (mesh->Skeleton == NULL) + if (mesh->Skeleton == nullptr) { StdCopyStrBuf exception("The specified skeleton file was not found: "); exception.Append(skeleton_filename.getData()); @@ -474,7 +474,7 @@ StdMesh *StdMeshLoader::LoadMeshBinary(const char *sourcefile, size_t length, co } } - assert(mesh->Skeleton != NULL); // the bone assignments could instead be added only, if there is a skeleton + assert(mesh->Skeleton != nullptr); // the bone assignments could instead be added only, if there is a skeleton // Build bone handle->index quick access table std::map bone_lookup; @@ -554,7 +554,7 @@ StdMesh *StdMeshLoader::LoadMeshBinary(const char *sourcefile, size_t length, co bool first = true; for (unsigned int i = 0; i < mesh->SubMeshes.size() + 1; ++i) { - const std::vector* vertices = NULL; + const std::vector* vertices = nullptr; if (i < mesh->SubMeshes.size()) vertices = &mesh->SubMeshes[i].Vertices; else @@ -641,7 +641,7 @@ void StdMeshSkeletonLoader::DoAppendSkeletons() StdMeshSkeleton* destination = GetSkeletonByDefinition(id.getData()); // append animations, if the definition has a mesh - if (destination == NULL) + if (destination == nullptr) { // Note that GetSkeletonByDefinition logs already why // the skeleton does not exist. @@ -681,7 +681,7 @@ void StdMeshSkeletonLoader::DoIncludeSkeletons() StdMeshSkeleton* source = GetSkeletonByDefinition(id.getData()); // append animations, if the definition has a mesh - if (source == NULL) + if (source == nullptr) { // Note that GetSkeletonByDefinition logs already why // the skeleton does not exist. diff --git a/src/lib/StdMeshLoaderBinaryChunks.h b/src/lib/StdMeshLoaderBinaryChunks.h index c03a4197f..9d5abec7c 100644 --- a/src/lib/StdMeshLoaderBinaryChunks.h +++ b/src/lib/StdMeshLoaderBinaryChunks.h @@ -523,7 +523,7 @@ namespace Ogre class ChunkGeometryVertexData : public Chunk { public: - ChunkGeometryVertexData() : data(NULL) {} + ChunkGeometryVertexData() : data(nullptr) {} ~ChunkGeometryVertexData() { delete[] static_cast(data); } void *data; protected: diff --git a/src/lib/StdMeshLoaderXml.cpp b/src/lib/StdMeshLoaderXml.cpp index ab80a0c74..0abdd16c3 100644 --- a/src/lib/StdMeshLoaderXml.cpp +++ b/src/lib/StdMeshLoaderXml.cpp @@ -124,7 +124,7 @@ void StdMeshLoader::StdMeshXML::LoadGeometry(StdMesh& mesh, std::vectorFirstChildElement("vertexbuffer"); buffer_elem != NULL; buffer_elem = buffer_elem->NextSiblingElement("vertexbuffer")) + for(TiXmlElement* buffer_elem = geometry_elem->FirstChildElement("vertexbuffer"); buffer_elem != nullptr; buffer_elem = buffer_elem->NextSiblingElement("vertexbuffer")) { unsigned int attributes = 0; if(buffer_elem->Attribute("positions")) attributes |= POSITIONS; @@ -133,7 +133,7 @@ void StdMeshLoader::StdMeshXML::LoadGeometry(StdMesh& mesh, std::vectorFirstChildElement("vertex"), i = 0; vertex_elem != NULL && i < vertices.size(); vertex_elem = vertex_elem->NextSiblingElement("vertex"), ++i) + for (vertex_elem = buffer_elem->FirstChildElement("vertex"), i = 0; vertex_elem != nullptr && i < vertices.size(); vertex_elem = vertex_elem->NextSiblingElement("vertex"), ++i) { if(attributes & POSITIONS) { @@ -193,7 +193,7 @@ void StdMeshLoader::StdMeshXML::LoadGeometry(StdMesh& mesh, std::vector& vertices, TiXmlElement* boneassignments_elem) { - for (TiXmlElement* vertexboneassignment_elem = boneassignments_elem->FirstChildElement("vertexboneassignment"); vertexboneassignment_elem != NULL; vertexboneassignment_elem = vertexboneassignment_elem->NextSiblingElement("vertexboneassignment")) + for (TiXmlElement* vertexboneassignment_elem = boneassignments_elem->FirstChildElement("vertexboneassignment"); vertexboneassignment_elem != nullptr; vertexboneassignment_elem = vertexboneassignment_elem->NextSiblingElement("vertexboneassignment")) { int BoneID = RequireIntAttribute(vertexboneassignment_elem, "boneindex"); int VertexIndex = RequireIntAttribute(vertexboneassignment_elem, "vertexindex"); @@ -218,7 +218,7 @@ void StdMeshLoader::StdMeshXML::LoadBoneAssignments(StdMesh& mesh, std::vector mesh(new StdMesh); - TiXmlElement* mesh_elem = xml.RequireFirstChild(NULL, "mesh"); + TiXmlElement* mesh_elem = xml.RequireFirstChild(nullptr, "mesh"); // Load shared geometry, if any TiXmlElement* sharedgeometry_elem = mesh_elem->FirstChildElement("sharedgeometry"); - if(sharedgeometry_elem != NULL) + if(sharedgeometry_elem != nullptr) xml.LoadGeometry(*mesh, mesh->SharedVertices, sharedgeometry_elem); TiXmlElement* submeshes_elem = xml.RequireFirstChild(mesh_elem, "submeshes"); TiXmlElement* submesh_elem_base = xml.RequireFirstChild(submeshes_elem, "submesh"); - for (TiXmlElement* submesh_elem = submesh_elem_base; submesh_elem != NULL; submesh_elem = submesh_elem->NextSiblingElement("submesh")) + for (TiXmlElement* submesh_elem = submesh_elem_base; submesh_elem != nullptr; submesh_elem = submesh_elem->NextSiblingElement("submesh")) { mesh->SubMeshes.push_back(StdSubMesh()); StdSubMesh& submesh = mesh->SubMeshes.back(); @@ -305,7 +305,7 @@ StdMesh *StdMeshLoader::LoadMeshXml(const char* xml_data, size_t size, const Std submesh.Faces.resize(FaceCount); unsigned int i = 0; - for (TiXmlElement* face_elem = faces_elem->FirstChildElement("face"); face_elem != NULL && i < submesh.Faces.size(); face_elem = face_elem->NextSiblingElement("face"), ++i) + for (TiXmlElement* face_elem = faces_elem->FirstChildElement("face"); face_elem != nullptr && i < submesh.Faces.size(); face_elem = face_elem->NextSiblingElement("face"), ++i) { int v[3]; @@ -349,7 +349,7 @@ StdMesh *StdMeshLoader::LoadMeshXml(const char* xml_data, size_t size, const Std // Vertex<->Bone assignments for all vertices (need to go through SubMeshes again...) unsigned int submesh_index = 0; - for (TiXmlElement* submesh_elem = submesh_elem_base; submesh_elem != NULL; submesh_elem = submesh_elem->NextSiblingElement("submesh"), ++submesh_index) + for (TiXmlElement* submesh_elem = submesh_elem_base; submesh_elem != nullptr; submesh_elem = submesh_elem->NextSiblingElement("submesh"), ++submesh_index) { StdSubMesh& submesh = mesh->SubMeshes[submesh_index]; if (!submesh.Vertices.empty()) @@ -364,7 +364,7 @@ StdMesh *StdMeshLoader::LoadMeshXml(const char* xml_data, size_t size, const Std // Mesh has no skeleton // Bone assignements do not make sense then, as the // actual bones are defined in the skeleton file. - for (TiXmlElement* submesh_elem = submesh_elem_base; submesh_elem != NULL; submesh_elem = submesh_elem->NextSiblingElement("submesh")) + for (TiXmlElement* submesh_elem = submesh_elem_base; submesh_elem != nullptr; submesh_elem = submesh_elem->NextSiblingElement("submesh")) { TiXmlElement* boneassignments_elem = submesh_elem->FirstChildElement("boneassignments"); if (boneassignments_elem) @@ -381,21 +381,21 @@ StdMesh *StdMeshLoader::LoadMeshXml(const char* xml_data, size_t size, const Std void StdMeshSkeletonLoader::LoadSkeletonXml(const char* groupname, const char* filename, const char *sourcefile, size_t size) { - if (sourcefile == NULL) + if (sourcefile == nullptr) { throw Ogre::InsufficientData(FormatString("Failed to load '%s/%s'", groupname, filename).getData()); } std::shared_ptr skeleton(new StdMeshLoader::StdMeshXML(filename, sourcefile)); - TiXmlElement* skeleton_elem = skeleton->RequireFirstChild(NULL, "skeleton"); + TiXmlElement* skeleton_elem = skeleton->RequireFirstChild(nullptr, "skeleton"); TiXmlElement* bones_elem = skeleton->RequireFirstChild(skeleton_elem, "bones"); // Read bones. Don't insert into Master bone table yet, as the master bone // table is sorted hierarchically, and we will read the hierarchy only // afterwards. std::vector bones; - for (TiXmlElement* bone_elem = bones_elem->FirstChildElement("bone"); bone_elem != NULL; bone_elem = bone_elem->NextSiblingElement("bone")) + for (TiXmlElement* bone_elem = bones_elem->FirstChildElement("bone"); bone_elem != nullptr; bone_elem = bone_elem->NextSiblingElement("bone")) { StdMeshBone* bone = new StdMeshBone; bones.push_back(bone); @@ -404,7 +404,7 @@ void StdMeshSkeletonLoader::LoadSkeletonXml(const char* groupname, const char* f bone->Name = skeleton->RequireStrAttribute(bone_elem, "name"); // TODO: Make sure ID and name are unique - bone->Parent = NULL; + bone->Parent = nullptr; // Index of bone will be set when building Master Bone Table later TiXmlElement* position_elem = skeleton->RequireFirstChild(bone_elem, "position"); @@ -430,14 +430,14 @@ void StdMeshSkeletonLoader::LoadSkeletonXml(const char* groupname, const char* f // Bone hierarchy TiXmlElement* bonehierarchy_elem = skeleton->RequireFirstChild(skeleton_elem, "bonehierarchy"); - for (TiXmlElement* boneparent_elem = bonehierarchy_elem->FirstChildElement("boneparent"); boneparent_elem != NULL; boneparent_elem = boneparent_elem->NextSiblingElement("boneparent")) + for (TiXmlElement* boneparent_elem = bonehierarchy_elem->FirstChildElement("boneparent"); boneparent_elem != nullptr; boneparent_elem = boneparent_elem->NextSiblingElement("boneparent")) { const char* child_name = skeleton->RequireStrAttribute(boneparent_elem, "bone"); const char* parent_name = skeleton->RequireStrAttribute(boneparent_elem, "parent"); // Lookup the two bones - StdMeshBone* child = NULL; - StdMeshBone* parent = NULL; + StdMeshBone* child = nullptr; + StdMeshBone* parent = nullptr; for (unsigned int i = 0; i < bones.size() && (!child || !parent); ++i) { if (!child && bones[i]->Name == child_name) @@ -457,14 +457,14 @@ void StdMeshSkeletonLoader::LoadSkeletonXml(const char* groupname, const char* f // Fill master bone table in hierarchical order: for (unsigned int i = 0; i < bones.size(); ++i) - if (bones[i]->Parent == NULL) + if (bones[i]->Parent == nullptr) Skeleton->AddMasterBone(bones[i]); // Load Animations TiXmlElement* animations_elem = skeleton_elem->FirstChildElement("animations"); if (animations_elem) { - for (TiXmlElement* animation_elem = animations_elem->FirstChildElement("animation"); animation_elem != NULL; animation_elem = animation_elem->NextSiblingElement("animation")) + for (TiXmlElement* animation_elem = animations_elem->FirstChildElement("animation"); animation_elem != nullptr; animation_elem = animation_elem->NextSiblingElement("animation")) { StdCopyStrBuf name(skeleton->RequireStrAttribute(animation_elem, "name")); if (Skeleton->Animations.find(name) != Skeleton->Animations.end()) @@ -477,22 +477,22 @@ void StdMeshSkeletonLoader::LoadSkeletonXml(const char* groupname, const char* f animation.OriginSkeleton = &(*Skeleton); TiXmlElement* tracks_elem = skeleton->RequireFirstChild(animation_elem, "tracks"); - for (TiXmlElement* track_elem = tracks_elem->FirstChildElement("track"); track_elem != NULL; track_elem = track_elem->NextSiblingElement("track")) + for (TiXmlElement* track_elem = tracks_elem->FirstChildElement("track"); track_elem != nullptr; track_elem = track_elem->NextSiblingElement("track")) { const char* bone_name = skeleton->RequireStrAttribute(track_elem, "bone"); - StdMeshBone* bone = NULL; + StdMeshBone* bone = nullptr; for (unsigned int i = 0; !bone && i < Skeleton->GetNumBones(); ++i) if (Skeleton->Bones[i]->Name == bone_name) bone = Skeleton->Bones[i]; if (!bone) skeleton->Error(FormatString("There is no such bone with name '%s'", bone_name), track_elem); - if (animation.Tracks[bone->Index] != NULL) skeleton->Error(FormatString("There is already a track for bone '%s' in animation '%s'", bone_name, animation.Name.getData()), track_elem); + if (animation.Tracks[bone->Index] != nullptr) skeleton->Error(FormatString("There is already a track for bone '%s' in animation '%s'", bone_name, animation.Name.getData()), track_elem); StdMeshTrack* track = new StdMeshTrack; animation.Tracks[bone->Index] = track; TiXmlElement* keyframes_elem = skeleton->RequireFirstChild(track_elem, "keyframes"); - for (TiXmlElement* keyframe_elem = keyframes_elem->FirstChildElement("keyframe"); keyframe_elem != NULL; keyframe_elem = keyframe_elem->NextSiblingElement("keyframe")) + for (TiXmlElement* keyframe_elem = keyframes_elem->FirstChildElement("keyframe"); keyframe_elem != nullptr; keyframe_elem = keyframe_elem->NextSiblingElement("keyframe")) { float time = skeleton->RequireFloatAttribute(keyframe_elem, "time"); StdMeshKeyFrame& frame = track->Frames[time]; diff --git a/src/lib/StdMeshMaterial.cpp b/src/lib/StdMeshMaterial.cpp index 471eac309..a4434bda9 100644 --- a/src/lib/StdMeshMaterial.cpp +++ b/src/lib/StdMeshMaterial.cpp @@ -55,7 +55,7 @@ namespace const Enumerator ShaderParameterAutoEnumerators[] = { - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const Enumerator TexAddressModeEnumerators[] = @@ -64,7 +64,7 @@ namespace { "clamp", StdMeshMaterialTextureUnit::AM_Clamp }, { "mirror", StdMeshMaterialTextureUnit::AM_Mirror }, { "border", StdMeshMaterialTextureUnit::AM_Border }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const Enumerator FilteringEnumerators[] = @@ -73,7 +73,7 @@ namespace { "point", StdMeshMaterialTextureUnit::F_Point }, { "linear", StdMeshMaterialTextureUnit::F_Linear }, { "anisotropic", StdMeshMaterialTextureUnit::F_Anisotropic }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const EnumeratorShortcut<3, StdMeshMaterialTextureUnit::FilteringType> FilteringShortcuts[] = @@ -82,7 +82,7 @@ namespace { "bilinear", { StdMeshMaterialTextureUnit::F_Linear, StdMeshMaterialTextureUnit::F_Linear, StdMeshMaterialTextureUnit::F_Point } }, { "trilinear", { StdMeshMaterialTextureUnit::F_Linear, StdMeshMaterialTextureUnit::F_Linear, StdMeshMaterialTextureUnit::F_Linear } }, { "anisotropic", { StdMeshMaterialTextureUnit::F_Anisotropic, StdMeshMaterialTextureUnit::F_Anisotropic, StdMeshMaterialTextureUnit::F_Linear } }, - { NULL, { static_cast(0), static_cast(0), static_cast(0) } } + { nullptr, { static_cast(0), static_cast(0), static_cast(0) } } }; const Enumerator BlendOpEnumerators[] = @@ -91,7 +91,7 @@ namespace { "add", StdMeshMaterialTextureUnit::BO_Add }, { "modulate", StdMeshMaterialTextureUnit::BO_Modulate }, { "alpha_blend", StdMeshMaterialTextureUnit::BO_AlphaBlend }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const Enumerator BlendOpExEnumerators[] = @@ -111,7 +111,7 @@ namespace { "blend_manual", StdMeshMaterialTextureUnit::BOX_BlendManual }, { "dotproduct", StdMeshMaterialTextureUnit::BOX_Dotproduct }, { "blend_diffuse_colour", StdMeshMaterialTextureUnit::BOX_BlendDiffuseColor }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const Enumerator BlendOpSourceEnumerators[] = @@ -123,7 +123,7 @@ namespace { "src_player_color", StdMeshMaterialTextureUnit::BOS_PlayerColor }, { "src_player_colour", StdMeshMaterialTextureUnit::BOS_PlayerColor }, { "src_manual", StdMeshMaterialTextureUnit::BOS_Manual }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const Enumerator XFormTypeEnumerators[] = @@ -133,7 +133,7 @@ namespace { "rotate", StdMeshMaterialTextureUnit::Transformation::XF_ROTATE }, { "scale_x", StdMeshMaterialTextureUnit::Transformation::XF_SCALE_X }, { "scale_y", StdMeshMaterialTextureUnit::Transformation::XF_SCALE_Y }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const Enumerator WaveTypeEnumerators[] = @@ -143,7 +143,7 @@ namespace { "square", StdMeshMaterialTextureUnit::Transformation::W_SQUARE }, { "sawtooth", StdMeshMaterialTextureUnit::Transformation::W_SAWTOOTH }, { "inverse_sawtooth", StdMeshMaterialTextureUnit::Transformation::W_INVERSE_SAWTOOTH }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const Enumerator CullHardwareEnumerators[] = @@ -151,7 +151,7 @@ namespace { "clockwise", StdMeshMaterialPass::CH_Clockwise }, { "anticlockwise", StdMeshMaterialPass::CH_CounterClockwise }, { "none", StdMeshMaterialPass::CH_None }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const Enumerator SceneBlendEnumerators[] = @@ -166,7 +166,7 @@ namespace { "src_alpha", StdMeshMaterialPass::SB_SrcAlpha }, { "one_minus_dest_alpha", StdMeshMaterialPass::SB_OneMinusDestAlpha }, { "one_minus_src_alpha", StdMeshMaterialPass::SB_OneMinusSrcAlpha }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; const EnumeratorShortcut<2, StdMeshMaterialPass::SceneBlendType> SceneBlendShortcuts[] = @@ -175,7 +175,7 @@ namespace { "modulate", { StdMeshMaterialPass::SB_DestColor, StdMeshMaterialPass::SB_Zero } }, { "colour_blend", { StdMeshMaterialPass::SB_SrcColor, StdMeshMaterialPass::SB_OneMinusSrcColor } }, { "alpha_blend", { StdMeshMaterialPass::SB_SrcAlpha, StdMeshMaterialPass::SB_OneMinusSrcAlpha } }, - { NULL, { static_cast(0), static_cast(0) } } + { nullptr, { static_cast(0), static_cast(0) } } }; const Enumerator DepthFunctionEnumerators[] = @@ -188,7 +188,7 @@ namespace { "not_equal", StdMeshMaterialPass::DF_NotEqual }, { "greater_equal", StdMeshMaterialPass::DF_GreaterEqual }, { "greater", StdMeshMaterialPass::DF_Greater }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; } @@ -485,7 +485,7 @@ void StdMeshMaterialParserCtx::AdvanceEnums(const Enumerator* enumerat else { // Both enumerator and shortcut are possible, determine by look-ahead - const Enumerator* cenum2 = NULL; + const Enumerator* cenum2 = nullptr; Token tok = Peek(buf); if (tok == TOKEN_IDTF) { @@ -560,7 +560,7 @@ void StdMeshMaterialSubLoader::Load(StdMeshMaterialParserCtx& ctx, std::vectorShader != NULL) + if(cur_shader->Shader != nullptr) ctx.Error(FormatString("There is already a %s shader in this pass", shader_type_name)); if(!shader) ctx.Error(FormatString("There is no such %s shader with name %s", shader_type_name, program_name.getData())); @@ -1541,7 +1541,7 @@ std::set StdMeshMatManager::Parse(const char* mat_script, const c // Check if there is a parent given Token next = ctx.AdvanceRequired(token_name, TOKEN_BRACE_OPEN, TOKEN_COLON); // Read parent name, if any - StdMeshMaterial* parent = NULL; + StdMeshMaterial* parent = nullptr; if (next == TOKEN_COLON) { // Note that if there is a parent, then it needs to be loaded @@ -1606,7 +1606,7 @@ std::set StdMeshMatManager::Parse(const char* mat_script, const c const StdMeshMaterial* StdMeshMatManager::GetMaterial(const char* material_name) const { std::map::const_iterator iter = Materials.find(StdCopyStrBuf(material_name)); - if (iter == Materials.end()) return NULL; + if (iter == Materials.end()) return nullptr; return &iter->second; } @@ -1631,27 +1631,27 @@ void StdMeshMatManager::Remove(const StdStrBuf &name, StdMeshMaterialUpdate *upd const StdMeshMaterialShader* StdMeshMatManager::GetFragmentShader(const char* name) const { ShaderMap::const_iterator iter = FragmentShaders.find(StdCopyStrBuf(name)); - if(iter == FragmentShaders.end()) return NULL; + if(iter == FragmentShaders.end()) return nullptr; return iter->second.get(); } const StdMeshMaterialShader* StdMeshMatManager::GetVertexShader(const char* name) const { ShaderMap::const_iterator iter = VertexShaders.find(StdCopyStrBuf(name)); - if(iter == VertexShaders.end()) return NULL; + if(iter == VertexShaders.end()) return nullptr; return iter->second.get(); } const StdMeshMaterialShader* StdMeshMatManager::GetGeometryShader(const char* name) const { ShaderMap::const_iterator iter = GeometryShaders.find(StdCopyStrBuf(name)); - if(iter == GeometryShaders.end()) return NULL; + if(iter == GeometryShaders.end()) return nullptr; return iter->second.get(); } const StdMeshMaterialShader* StdMeshMatManager::AddShader(const char* filename, const char* name, const char* language, StdMeshMaterialShaderType type, const char* text, uint32_t load_flags) { - ShaderMap* map = NULL; + ShaderMap* map = nullptr; switch(type) { case SMMS_FRAGMENT: @@ -1676,7 +1676,7 @@ const StdMeshMaterialShader* StdMeshMatManager::AddShader(const char* filename, else if ((load_flags & SMM_AcceptExisting) == SMM_AcceptExisting) return iter->second.get(); else - return NULL; + return nullptr; } std::unique_ptr shader(new StdMeshMaterialShader(filename, name, language, type, text)); @@ -1707,7 +1707,7 @@ const StdMeshMaterialProgram* StdMeshMatManager::AddProgram(const char* name, St // parameters were encountered). if(!inserted_program.IsCompiled() || fragment_added || vertex_added || geometry_added) if(!inserted_program.Compile(loader)) - return NULL; + return nullptr; return &inserted_program; } diff --git a/src/lib/StdMeshMaterial.h b/src/lib/StdMeshMaterial.h index 0ffee1f77..bdd451ad3 100644 --- a/src/lib/StdMeshMaterial.h +++ b/src/lib/StdMeshMaterial.h @@ -552,13 +552,13 @@ public: void Clear(); // Parse a material script file, and add the materials to the manager. - // filename may be NULL if the source is not a file. It will only be used + // filename may be nullptr if the source is not a file. It will only be used // for error messages. // Throws StdMeshMaterialError. // Returns a set of all loaded materials. std::set Parse(const char* mat_script, const char* filename, StdMeshMaterialLoader& loader); - // Get material by name. NULL if there is no such material with this name. + // Get material by name. nullptr if there is no such material with this name. const StdMeshMaterial* GetMaterial(const char* material_name) const; Iterator Begin() { return Iterator(Materials.begin()); } @@ -566,8 +566,8 @@ public: void Remove(const StdStrBuf& name, class StdMeshMaterialUpdate* update); Iterator Remove(const Iterator& iter, class StdMeshMaterialUpdate* update); - const StdMeshMaterialShader* AddShader(const char* filename, const char* name, const char* language, StdMeshMaterialShaderType type, const char* text, uint32_t load_flags); // if load_flags & SMM_AcceptExisting, the function returns the existing shader, otherwise returns NULL. - const StdMeshMaterialProgram* AddProgram(const char* name, StdMeshMaterialLoader& loader, const StdMeshMaterialPass::ShaderInstance& fragment_shader, const StdMeshMaterialPass::ShaderInstance& vertex_shader, const StdMeshMaterialPass::ShaderInstance& geometry_shader); // returns NULL if shader code cannot be compiled + const StdMeshMaterialShader* AddShader(const char* filename, const char* name, const char* language, StdMeshMaterialShaderType type, const char* text, uint32_t load_flags); // if load_flags & SMM_AcceptExisting, the function returns the existing shader, otherwise returns nullptr. + const StdMeshMaterialProgram* AddProgram(const char* name, StdMeshMaterialLoader& loader, const StdMeshMaterialPass::ShaderInstance& fragment_shader, const StdMeshMaterialPass::ShaderInstance& vertex_shader, const StdMeshMaterialPass::ShaderInstance& geometry_shader); // returns nullptr if shader code cannot be compiled const StdMeshMaterialShader* GetFragmentShader(const char* name) const; const StdMeshMaterialShader* GetVertexShader(const char* name) const; diff --git a/src/mape/cpp-handles/c4def-handle.cpp b/src/mape/cpp-handles/c4def-handle.cpp index 8fee51345..e22466e5f 100644 --- a/src/mape/cpp-handles/c4def-handle.cpp +++ b/src/mape/cpp-handles/c4def-handle.cpp @@ -23,13 +23,13 @@ * mape. We cannot link the full implementation since it would introduce * a dependency on C4Game, and therefore the rest of the engine. */ -C4Def::C4Def(): Script(), C4PropListStatic(ScriptEngine.GetPropList(), NULL, NULL) +C4Def::C4Def(): Script(), C4PropListStatic(ScriptEngine.GetPropList(), nullptr, nullptr) { Script.SetDef(this); assert(ScriptEngine.GetPropList()); Graphics.pDef = this; - Next = NULL; + Next = nullptr; Script.Clear(); } @@ -41,7 +41,7 @@ C4Def::~C4Def() C4DefList::C4DefList() { - FirstDef = NULL; + FirstDef = nullptr; } C4DefList::~C4DefList() @@ -62,10 +62,10 @@ void C4DefList::Clear() C4Def* C4DefList::ID2Def(C4ID id) { C4Def* cdef; - for(cdef = FirstDef; cdef != NULL; cdef = cdef->Next) + for(cdef = FirstDef; cdef != nullptr; cdef = cdef->Next) if(cdef->id == id) return cdef; - return NULL; + return nullptr; } C4Def* C4DefList::GetByName(const StdStrBuf& name) @@ -76,26 +76,26 @@ C4Def* C4DefList::GetByName(const StdStrBuf& name) C4Def* C4DefList::GetDef(int iIndex) { int counter = 0; - for(C4Def* cdef = FirstDef; cdef != NULL; cdef = cdef->Next) + for(C4Def* cdef = FirstDef; cdef != nullptr; cdef = cdef->Next) { if(counter == iIndex) return cdef; ++counter; } - return NULL; + return nullptr; } int C4DefList::GetDefCount() { int counter = 0; - for(C4Def* cdef = FirstDef; cdef != NULL; cdef = cdef->Next) + for(C4Def* cdef = FirstDef; cdef != nullptr; cdef = cdef->Next) ++counter; return counter; } bool C4DefList::Add(C4Def* def, bool fOverload) { - assert(ID2Def(def->id) == NULL); + assert(ID2Def(def->id) == nullptr); def->Next = FirstDef; FirstDef = def; @@ -112,7 +112,7 @@ bool C4Def::Load(C4Group& hGroup, StdMeshSkeletonLoader& loader, DWORD dwLoadWha ParentKeyName = ::Strings.RegString(id.ToString()); Script.Reg2List(&::ScriptEngine); - if(!Script.Load(hGroup, "Script.c", NULL, NULL)) + if(!Script.Load(hGroup, "Script.c", nullptr, nullptr)) { return false; } diff --git a/src/mape/cpp-handles/log-handle.cpp b/src/mape/cpp-handles/log-handle.cpp index 505657075..22cfbf884 100644 --- a/src/mape/cpp-handles/log-handle.cpp +++ b/src/mape/cpp-handles/log-handle.cpp @@ -60,7 +60,7 @@ void c4_log_handle_clear() const char* c4_log_handle_get_first_log_message() { - if(first_log.empty()) return NULL; + if(first_log.empty()) return nullptr; return first_log.c_str(); } diff --git a/src/mape/cpp-handles/mapgen-handle.cpp b/src/mape/cpp-handles/mapgen-handle.cpp index b3668f24b..c9d2ca281 100644 --- a/src/mape/cpp-handles/mapgen-handle.cpp +++ b/src/mape/cpp-handles/mapgen-handle.cpp @@ -47,7 +47,7 @@ bool HasAlgoScript(C4MCNode* node) class FakeSkeletonLoader: public StdMeshSkeletonLoader { public: - virtual StdMeshSkeleton* GetSkeletonByDefinition(const char* definition) const { return NULL; } + virtual StdMeshSkeleton* GetSkeletonByDefinition(const char* definition) const { return nullptr; } }; } @@ -84,7 +84,7 @@ void c4_mapgen_handle_set_map_library(C4GroupHandle* group_handle) libmap->SetName(libmap->id.ToString()); libmap->Category = C4D_StaticBack; FakeSkeletonLoader loader; - if(!libmap->Load(*HANDLE_TO_GROUP(group_handle), loader, C4D_Load_Script, NULL, NULL)) + if(!libmap->Load(*HANDLE_TO_GROUP(group_handle), loader, C4D_Load_Script, nullptr, nullptr)) { fprintf(stderr, "Failed to load Library_Map script\n"); delete libmap; @@ -115,12 +115,12 @@ C4MapgenHandle* c4_mapgen_handle_new_script(const char* filename, const char* so landscape.MapPlayerExtend = 0; c4_log_handle_clear(); - ::MapScript.LoadData(filename, source, NULL); + ::MapScript.LoadData(filename, source, nullptr); // If InitializeMap() returns false, the map creator wants to // call a fallback in the scenario script. This crashes if no // scenario script is loaded, so simply load an empty script // here: - ::GameScript.LoadData("Script.c", "", NULL); + ::GameScript.LoadData("Script.c", "", nullptr); const char* parse_error = c4_log_handle_get_first_log_message(); if(parse_error) @@ -154,7 +154,7 @@ C4MapgenHandle* c4_mapgen_handle_new_script(const char* filename, const char* so handle->width = out_ptr_fg->Wdt; handle->height = out_ptr_fg->Hgt; handle->rowstride = out_ptr_fg->Wdt; - handle->error_message = NULL; + handle->error_message = nullptr; handle->data = out_ptr_fg->Bits; out_ptr_fg->ReleaseBuffer(); @@ -166,7 +166,7 @@ C4MapgenHandle* c4_mapgen_handle_new_script(const char* filename, const char* so handle->width = 0; handle->height = 0; handle->error_message.Copy(ex.what()); - handle->data = NULL; + handle->data = nullptr; return handle; } } @@ -192,12 +192,12 @@ C4MapgenHandle* c4_mapgen_handle_new(const char* filename, const char* source, c C4MCParser parser(&mapgen); parser.ParseMemFile(source, filename); - C4MCMap* map = mapgen.GetMap(NULL); + C4MCMap* map = mapgen.GetMap(nullptr); if(!map) throw std::runtime_error("No map definition in source file"); // Setup the script engine if there is an algo=script overlay in the // Landscape.txt file - if(HasAlgoScript(mapgen.GetMap(NULL))) + if(HasAlgoScript(mapgen.GetMap(nullptr))) { // Re-initialize script engine. Otherwise, we get a warning when the user // changes the value of a constant, since it is defined already from the @@ -205,7 +205,7 @@ C4MapgenHandle* c4_mapgen_handle_new(const char* filename, const char* source, c c4_mapgen_handle_deinit_script_engine(); c4_mapgen_handle_init_script_engine(); - if(script_path == NULL) + if(script_path == nullptr) throw std::runtime_error("For algo=script overlays to work, save the file first at the location of the Script.c file"); gchar* dirname = g_path_get_dirname(script_path); @@ -222,7 +222,7 @@ C4MapgenHandle* c4_mapgen_handle_new(const char* filename, const char* source, c // get scripts File.ResetSearch(); - if(!File.FindNextEntry(basename, (char*)NULL)) + if(!File.FindNextEntry(basename, (char*)nullptr)) { g_free(dirname); g_free(basename); @@ -231,7 +231,7 @@ C4MapgenHandle* c4_mapgen_handle_new(const char* filename, const char* source, c } c4_log_handle_clear(); - GameScript.Load(File, basename, NULL, NULL); + GameScript.Load(File, basename, nullptr, nullptr); g_free(dirname); g_free(basename); @@ -248,7 +248,7 @@ C4MapgenHandle* c4_mapgen_handle_new(const char* filename, const char* source, c c4_log_handle_clear(); int32_t out_width, out_height; - BYTE* array = mapgen.RenderBuf(NULL, out_width, out_height); + BYTE* array = mapgen.RenderBuf(nullptr, out_width, out_height); // Don't show any map if there was a script runtime error const char* runtime_error = c4_log_handle_get_first_log_message(); @@ -262,7 +262,7 @@ C4MapgenHandle* c4_mapgen_handle_new(const char* filename, const char* source, c handle->width = map_width; handle->height = map_height; handle->rowstride = out_width; - handle->error_message = NULL; + handle->error_message = nullptr; handle->data = array; return handle; } @@ -272,7 +272,7 @@ C4MapgenHandle* c4_mapgen_handle_new(const char* filename, const char* source, c handle->width = 0; handle->height = 0; handle->error_message.Copy(err.Msg); - handle->data = NULL; + handle->data = nullptr; return handle; } catch(const std::exception& ex) @@ -281,7 +281,7 @@ C4MapgenHandle* c4_mapgen_handle_new(const char* filename, const char* source, c handle->width = 0; handle->height = 0; handle->error_message.Copy(ex.what()); - handle->data = NULL; + handle->data = nullptr; return handle; } } @@ -299,26 +299,26 @@ const unsigned char* c4_mapgen_handle_get_map(C4MapgenHandle* mapgen) unsigned int c4_mapgen_handle_get_width(C4MapgenHandle* mapgen) { - assert(mapgen->data != NULL); + assert(mapgen->data != nullptr); return mapgen->width; } unsigned int c4_mapgen_handle_get_height(C4MapgenHandle* mapgen) { - assert(mapgen->data != NULL); + assert(mapgen->data != nullptr); return mapgen->height; } unsigned int c4_mapgen_handle_get_rowstride(C4MapgenHandle* mapgen) { - assert(mapgen->data != NULL); + assert(mapgen->data != nullptr); return mapgen->rowstride; } const char* c4_mapgen_handle_get_error(C4MapgenHandle* mapgen) { - if(mapgen->data != NULL) - return NULL; + if(mapgen->data != nullptr) + return nullptr; return mapgen->error_message.getData(); } diff --git a/src/mape/cpp-handles/material-handle.cpp b/src/mape/cpp-handles/material-handle.cpp index 4890abe6b..02048498b 100644 --- a/src/mape/cpp-handles/material-handle.cpp +++ b/src/mape/cpp-handles/material-handle.cpp @@ -62,7 +62,7 @@ void c4_material_map_crossmap_materials(C4MaterialMapHandle* material_map, C4Tex const char* overlay = mat->sTextureOverlay.getData(); if(!overlay || *overlay == '\0') { - int first_tex_map_entry = HANDLE_TO_TEXTURE_MAP(texture_map)->GetIndex(mat->Name, NULL, false); + int first_tex_map_entry = HANDLE_TO_TEXTURE_MAP(texture_map)->GetIndex(mat->Name, nullptr, false); overlay = HANDLE_TO_TEXTURE_MAP(texture_map)->GetEntry(first_tex_map_entry)->GetTextureName(); } diff --git a/src/mape/cpp-handles/stub-handle.cpp b/src/mape/cpp-handles/stub-handle.cpp index 160d08c2a..882e72fb5 100644 --- a/src/mape/cpp-handles/stub-handle.cpp +++ b/src/mape/cpp-handles/stub-handle.cpp @@ -38,7 +38,7 @@ C4Landscape Landscape; C4PXSSystem PXS; -class C4SoundInstance *StartSoundEffectAt(const char *, int32_t, int32_t, int32_t, int32_t, int32_t, class C4SoundModifier *) { return NULL; } +class C4SoundInstance *StartSoundEffectAt(const char *, int32_t, int32_t, int32_t, int32_t, int32_t, class C4SoundModifier *) { return nullptr; } C4Facet::C4Facet() {} void C4Facet::Set(C4Surface*, float, float, float, float) {} diff --git a/src/mape/cpp-handles/texture-handle.cpp b/src/mape/cpp-handles/texture-handle.cpp index cc8eddb7a..9dac9415c 100644 --- a/src/mape/cpp-handles/texture-handle.cpp +++ b/src/mape/cpp-handles/texture-handle.cpp @@ -54,7 +54,7 @@ guint c4_texture_map_handle_load_map(C4TextureMapHandle* texture_map, C4GroupHan gboolean c4_texture_map_handle_add_texture(C4TextureMapHandle* texture_map, const char* texture, guint32 avg_color) { - gboolean result = HANDLE_TO_TEXTURE_MAP(texture_map)->AddTexture(texture, NULL); + gboolean result = HANDLE_TO_TEXTURE_MAP(texture_map)->AddTexture(texture, nullptr); if(!result) return FALSE; HANDLE_TO_TEXTURE_MAP(texture_map)->GetTexture(texture)->SetAverageColor(avg_color); return TRUE; @@ -73,14 +73,14 @@ guint32 c4_texture_handle_get_average_texture_color(C4TextureMapHandle* texture_ const char* c4_texture_handle_get_entry_material_name(C4TextureMapHandle* texture_map, guint index) { const C4TexMapEntry* entry = HANDLE_TO_TEXTURE_MAP(texture_map)->GetEntry(index); - if(!entry) return NULL; + if(!entry) return nullptr; return entry->GetMaterialName(); } const char* c4_texture_handle_get_entry_texture_name(C4TextureMapHandle* texture_map, guint index) { const C4TexMapEntry* entry = HANDLE_TO_TEXTURE_MAP(texture_map)->GetEntry(index); - if(!entry) return NULL; + if(!entry) return nullptr; return entry->GetTextureName(); } diff --git a/src/netio/TstC4NetIO.cpp b/src/netio/TstC4NetIO.cpp index 4a3af9343..68893866e 100644 --- a/src/netio/TstC4NetIO.cpp +++ b/src/netio/TstC4NetIO.cpp @@ -102,7 +102,7 @@ int main(int argc, char * argv[]) for (i = 0; i < sizeof(DummyData); i++) DummyData[i] = 'A' + i % 100; - FixedRandom(time(NULL)); + FixedRandom(time(nullptr)); #ifdef USE_UDP C4NetIOUDP NetIO; diff --git a/src/network/C4Client.cpp b/src/network/C4Client.cpp index 5db1479f3..86a39ccf6 100644 --- a/src/network/C4Client.cpp +++ b/src/network/C4Client.cpp @@ -114,12 +114,12 @@ void C4ClientCore::CompileFunc(StdCompiler *pComp) // *** C4Client C4Client::C4Client() - : fLocal(false), pNetClient(NULL), fIsIgnored(false), last_lobby_ready_change(0) + : fLocal(false), pNetClient(nullptr), fIsIgnored(false), last_lobby_ready_change(0) { } C4Client::C4Client(const C4ClientCore &Core) - : Core(Core), fLocal(false), pNetClient(NULL), fIsIgnored(false), pNext(NULL), last_lobby_ready_change(0) + : Core(Core), fLocal(false), pNetClient(nullptr), fIsIgnored(false), pNext(nullptr), last_lobby_ready_change(0) { } @@ -145,7 +145,7 @@ void C4Client::SetLobbyReady(bool fnLobbyReady, time_t *time_since_last_change) // Keep track of times if (time_since_last_change) { - time_t now = time(NULL); + time_t now = time(nullptr); *time_since_last_change = now - last_lobby_ready_change; last_lobby_ready_change = now; } @@ -174,7 +174,7 @@ void C4Client::CompileFunc(StdCompiler *pComp) // *** C4ClientList C4ClientList::C4ClientList() - : pFirst(NULL), pLocal(NULL), pNetClients(NULL) + : pFirst(nullptr), pLocal(nullptr), pNetClients(nullptr) { } @@ -202,7 +202,7 @@ void C4ClientList::Add(C4Client *pClient) // already in list? assert(!getClientByID(pClient->getID())); // find insert position - C4Client *pPos = pFirst, *pPrev = NULL; + C4Client *pPos = pFirst, *pPrev = nullptr; for (; pPos; pPrev = pPos, pPos = pPos->pNext) if (pPos->getID() > pClient->getID()) break; @@ -219,7 +219,7 @@ C4Client *C4ClientList::getClientByID(int32_t iID) const for (C4Client *pClient = pFirst; pClient; pClient = pClient->pNext) if (pClient->getID() == iID) return pClient; - return NULL; + return nullptr; } C4Client *C4ClientList::getNextClientByID(int32_t iAfterID) const @@ -227,7 +227,7 @@ C4Client *C4ClientList::getNextClientByID(int32_t iAfterID) const for (C4Client *pClient = pFirst; pClient; pClient = pClient->pNext) if (pClient->getID() > iAfterID) return pClient; - return NULL; + return nullptr; } C4Client *C4ClientList::getClientByName(const char *szName) const @@ -235,7 +235,7 @@ C4Client *C4ClientList::getClientByName(const char *szName) const for (C4Client *pClient = pFirst; pClient; pClient = pClient->pNext) if (SEqual(pClient->getName(), szName)) return pClient; - return NULL; + return nullptr; } int32_t C4ClientList::getClientCnt() const @@ -280,7 +280,7 @@ void C4ClientList::ClearNetwork() { // clear the list (should remove links) C4Network2ClientList *pOldNetClients = pNetClients; - pNetClients = NULL; + pNetClients = nullptr; if (pOldNetClients) pOldNetClients->Clear(); } @@ -299,7 +299,7 @@ bool C4ClientList::Remove(C4Client *pClient, bool fTemporary) // unlink pPrev->pNext = pClient->pNext; } - if (pClient == pLocal) pLocal = NULL; + if (pClient == pLocal) pLocal = nullptr; if (!fTemporary) { pClient->Remove(); @@ -315,7 +315,7 @@ C4Client *C4ClientList::Add(const C4ClientCore &Core) { // client with same ID in list? if (getClientByID(Core.getID())) - { Log("ClientList: Duplicated client ID!"); return NULL; } + { Log("ClientList: Duplicated client ID!"); return nullptr; } // create, add C4Client *pClient = new C4Client(Core); Add(pClient); diff --git a/src/network/C4Client.h b/src/network/C4Client.h index bec1958a3..4e79cb234 100644 --- a/src/network/C4Client.h +++ b/src/network/C4Client.h @@ -121,12 +121,12 @@ public: void SetActivated(bool fnActivated); void SetObserver() { Core.SetObserver(true); } - void SetLobbyReady(bool fnLobbyReady, time_t *time_since_last_change = NULL); + void SetLobbyReady(bool fnLobbyReady, time_t *time_since_last_change = nullptr); void SetLocal(); void ToggleIgnore() { fIsIgnored = !fIsIgnored; } - void UnlinkNetClient() { pNetClient = NULL; } + void UnlinkNetClient() { pNetClient = nullptr; } void Remove(); @@ -151,13 +151,13 @@ protected: // pointer to local client C4Client *pLocal; - // network client list (may be NULL if network is not active) + // network client list (may be nullptr if network is not active) class C4Network2ClientList *pNetClients; void Add(C4Client *pClient); public: - C4Client *getClient(const C4Client *pAfter = NULL) const { return pAfter ? pAfter->pNext : pFirst; } + C4Client *getClient(const C4Client *pAfter = nullptr) const { return pAfter ? pAfter->pNext : pFirst; } C4Client *getLocal() const { return pLocal; } C4Client *getClientByID(int32_t iID) const; C4Client *getHost() const { return getClientByID(C4ClientIDHost); } diff --git a/src/network/C4GameControlNetwork.cpp b/src/network/C4GameControlNetwork.cpp index 2caf3531d..b84bda6b1 100644 --- a/src/network/C4GameControlNetwork.cpp +++ b/src/network/C4GameControlNetwork.cpp @@ -31,7 +31,7 @@ C4GameControlNetwork::C4GameControlNetwork(C4GameControl *pnParent) fActivated(false), iTargetTick(-1), iControlPreSend(1), tWaitStart(C4TimeMilliseconds::PositiveInfinity), iAvgControlSendTime(0), iTargetFPS(38), iControlSent(0), iControlReady(0), - pCtrlStack(NULL), + pCtrlStack(nullptr), tNextControlRequest(0), pParent(pnParent) { @@ -328,7 +328,7 @@ void C4GameControlNetwork::CopyClientList(const C4ClientList &rClients) CStdLock ClientLock(&ClientsCSec); // create local copy of activated client list ClearClients(); - C4Client *pClient = NULL; + C4Client *pClient = nullptr; while ((pClient = rClients.getClient(pClient))) if (pClient->isActivated()) AddClient(pClient->getID(), pClient->getName()); @@ -398,7 +398,7 @@ void C4GameControlNetwork::CalcPerformance(int32_t iCtrlTick) for (C4GameControlClient *pClient = pClients; pClient; pClient = pClient->pNext) { // Some rudimentary PreSend-calculation - // get associated connection - NULL for self + // get associated connection - nullptr for self C4Network2Client *pNetClt = ::Network.Clients.GetClientByID(pClient->getClientID()); if (pNetClt && !pNetClt->isLocal()) { @@ -606,7 +606,7 @@ C4GameControlClient *C4GameControlNetwork::getClient(int32_t iID) // by both for (C4GameControlClient *pClient = pClients; pClient; pClient = pClient->pNext) if (pClient->getClientID() == iID) return pClient; - return NULL; + return nullptr; } void C4GameControlNetwork::AddClient(C4GameControlClient *pClient) // by main thread @@ -615,7 +615,7 @@ void C4GameControlNetwork::AddClient(C4GameControlClient *pClient) // by main th // lock CStdLock ClientsLock(&ClientsCSec); // add (ordered) - C4GameControlClient *pPrev = NULL, *pPos = pClients; + C4GameControlClient *pPrev = nullptr, *pPos = pClients; for (; pPos; pPrev = pPos, pPos = pPos->pNext) if (pPos->getClientID() > pClient->getClientID()) break; @@ -650,7 +650,7 @@ C4GameControlPacket *C4GameControlNetwork::getCtrl(int32_t iClientID, int32_t iC for (C4GameControlPacket *pCtrl = pCtrlStack; pCtrl; pCtrl = pCtrl->pNext) if (pCtrl->getClientID() == iClientID && pCtrl->getCtrlTick() == iCtrlTick) return pCtrl; - return NULL; + return nullptr; } void C4GameControlNetwork::AddCtrl(C4GameControlPacket *pCtrl) // by both @@ -667,7 +667,7 @@ void C4GameControlNetwork::ClearCtrl(int32_t iBeforeTick) // by main thread // lock CStdLock CtrlLock(&CtrlCSec); // clear all old control - C4GameControlPacket *pCtrl = pCtrlStack, *pLast = NULL; + C4GameControlPacket *pCtrl = pCtrlStack, *pLast = nullptr; while (pCtrl) { // old? @@ -765,7 +765,7 @@ C4GameControlPacket *C4GameControlNetwork::PackCompleteCtrl(int32_t iTick) // async mode: wait n extra frames for slow clients const int iMaxWait = (Config.Network.AsyncMaxWait * 1000) / iTargetFPS; if (eMode != CNM_Async || C4TimeMilliseconds::Now() <= tWaitStart + iMaxWait) - return NULL; + return nullptr; } // create packet @@ -805,7 +805,7 @@ void C4GameControlNetwork::AddSyncCtrlToQueue(const C4Control &Ctrl, int32_t iTi { // search place in queue. It's vitally important that new packets are placed // behind packets for the same tick, so they will be executed in the right order. - C4GameControlPacket *pAfter = NULL, *pBefore = pSyncCtrlQueue; + C4GameControlPacket *pAfter = nullptr, *pBefore = pSyncCtrlQueue; while (pBefore && pBefore->getCtrlTick() <= iTick) { pAfter = pBefore; pBefore = pBefore->pNext; } // create @@ -852,7 +852,7 @@ C4GameControlPacket::C4GameControlPacket() : iClientID(C4ClientIDUnknown), iCtrlTick(-1), tTime(C4TimeMilliseconds::Now()), - pNext(NULL) + pNext(nullptr) { } @@ -861,7 +861,7 @@ C4GameControlPacket::C4GameControlPacket(const C4GameControlPacket &Pkt2) : C4PacketBase(Pkt2), iClientID(Pkt2.getClientID()), iCtrlTick(Pkt2.getCtrlTick()), tTime(C4TimeMilliseconds::Now()), - pNext(NULL) + pNext(nullptr) { Ctrl.Copy(Pkt2.getControl()); } diff --git a/src/network/C4InteractiveThread.cpp b/src/network/C4InteractiveThread.cpp index bff65925b..8ee375994 100644 --- a/src/network/C4InteractiveThread.cpp +++ b/src/network/C4InteractiveThread.cpp @@ -27,7 +27,7 @@ C4InteractiveThread::C4InteractiveThread() // Add head-item pFirstEvent = pLastEvent = new Event(); pFirstEvent->Type = Ev_None; - pFirstEvent->Next = NULL; + pFirstEvent->Next = nullptr; // reset event handlers ZeroMem(&pCallbacks, sizeof(pCallbacks)); // Set notify proc @@ -39,10 +39,10 @@ C4InteractiveThread::~C4InteractiveThread() { CStdLock PushLock(&EventPushCSec), PopLock(&EventPopCSec); // Remove all items. This may leak data, if pData was allocated on the heap. - while (PopEvent(NULL, NULL)) {} + while (PopEvent(nullptr, nullptr)) {} // Delete head-item delete pFirstEvent; - pFirstEvent = pLastEvent = NULL; + pFirstEvent = pLastEvent = nullptr; // Unregister notify Application.Remove(&NotifyProc); } @@ -82,7 +82,7 @@ bool C4InteractiveThread::PushEvent(C4InteractiveEventType eEvent, void *pData) #ifdef _DEBUG pEvent->Time = C4TimeMilliseconds::Now(); #endif - pEvent->Next = NULL; + pEvent->Next = nullptr; // add item (at end) pLastEvent->Next = pEvent; pLastEvent = pEvent; diff --git a/src/network/C4InteractiveThread.h b/src/network/C4InteractiveThread.h index 339d45f5d..96826995b 100644 --- a/src/network/C4InteractiveThread.h +++ b/src/network/C4InteractiveThread.h @@ -101,7 +101,7 @@ public: void RemoveProc(StdSchedulerProc *pProc); // event queue - bool PushEvent(C4InteractiveEventType eEventType, void *pData = NULL); + bool PushEvent(C4InteractiveEventType eEventType, void *pData = nullptr); void ProcessEvents(); // by main thread // special events @@ -120,7 +120,7 @@ public: void SetCallback(C4InteractiveEventType eEvent, Callback *pnNetworkCallback) { pCallbacks[eEvent] = pnNetworkCallback; } void ClearCallback(C4InteractiveEventType eEvent, Callback *pnNetworkCallback) - { if (pCallbacks[eEvent] == pnNetworkCallback) pCallbacks[eEvent] = NULL; } + { if (pCallbacks[eEvent] == pnNetworkCallback) pCallbacks[eEvent] = nullptr; } private: bool PopEvent(C4InteractiveEventType *pEventType, void **ppData); // by main thread diff --git a/src/network/C4League.cpp b/src/network/C4League.cpp index fdc4336fa..ef6e58f0d 100644 --- a/src/network/C4League.cpp +++ b/src/network/C4League.cpp @@ -220,7 +220,7 @@ bool C4LeagueFBIDList::FindFBIDByAccount(const char *szAccount, StdStrBuf *pFBID void C4LeagueFBIDList::RemoveFBIDByAccount(const char *szAccount) { - FBIDItem *pPrev = NULL, *pItem = pFirst; + FBIDItem *pPrev = nullptr, *pItem = pFirst; while (pItem) { // Delete? @@ -514,7 +514,7 @@ bool C4LeagueClient::GetReportDisconnectReply(StdStrBuf *pMessage) // *** C4LeagueSignupDialog C4LeagueSignupDialog::C4LeagueSignupDialog(const char *szPlayerName, const char *szLeagueName, const char *szLeagueServerName, const char *szAccountPref, const char *szPassPref, bool fWarnThirdParty, bool fRegister, bool fRememberLogin) - : C4GUI::Dialog(C4GUI_MessageDlgWdt, 100 /* will be resized as needed */, FormatString(LoadResStr("IDS_DLG_LEAGUESIGNUPON"), szLeagueServerName).getData(), false), strPlayerName(szPlayerName), pChkRememberLogin(NULL) + : C4GUI::Dialog(C4GUI_MessageDlgWdt, 100 /* will be resized as needed */, FormatString(LoadResStr("IDS_DLG_LEAGUESIGNUPON"), szLeagueServerName).getData(), false), strPlayerName(szPlayerName), pChkRememberLogin(nullptr) { // get positions C4GUI::ComponentAligner caMain(GetClientRect(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent, true); @@ -539,14 +539,14 @@ C4LeagueSignupDialog::C4LeagueSignupDialog(const char *szPlayerName, const char // place username input box bool fSideEdits=true; int iCtrlHeight; StdStrBuf sAccountTxt; sAccountTxt.Copy(LoadResStr("IDS_CTL_LEAGUE_ACCOUNT")); - C4GUI::LabeledEdit::GetControlSize(NULL, &iCtrlHeight, sAccountTxt.getData(), NULL, fSideEdits); + C4GUI::LabeledEdit::GetControlSize(nullptr, &iCtrlHeight, sAccountTxt.getData(), nullptr, fSideEdits); AddElement(pEdtAccount = new C4GUI::LabeledEdit(caMain.GetFromTop(iCtrlHeight), sAccountTxt.getData(), fSideEdits, szAccountPref)); // registering? Make password field optional if (fRegister) { // place the checkbox const char *szChkPasswordCaption = LoadResStr("IDS_CTL_LEAGUE_CHK_PLRPW"); - C4GUI::CheckBox::GetStandardCheckBoxSize(NULL, &iCtrlHeight, szChkPasswordCaption, NULL); + C4GUI::CheckBox::GetStandardCheckBoxSize(nullptr, &iCtrlHeight, szChkPasswordCaption, nullptr); AddElement(pChkPassword = new C4GUI::CheckBox(caMain.GetFromTop(iCtrlHeight), szChkPasswordCaption, false)); pChkPassword->SetOnChecked(new C4GUI::CallbackHandlerNoPar(this, &C4LeagueSignupDialog::OnChkPassword)); pChkPassword->SetToolTip(LoadResStr("IDS_DESC_LEAGUECHECKPASSWORD")); @@ -554,7 +554,7 @@ C4LeagueSignupDialog::C4LeagueSignupDialog(const char *szPlayerName, const char C4GUI::ComponentAligner caTemp = caMain; const char *szEdtPassCaption = LoadResStr("IDS_CTL_LEAGUE_PLRPW"); const char *szEdtPass2Caption = LoadResStr("IDS_CTL_LEAGUE_PLRPW2"); - C4GUI::LabeledEdit::GetControlSize(NULL, &iCtrlHeight, szEdtPassCaption, NULL, fSideEdits); + C4GUI::LabeledEdit::GetControlSize(nullptr, &iCtrlHeight, szEdtPassCaption, nullptr, fSideEdits); AddElement(pEdtPass = new C4GUI::LabeledEdit(caTemp.GetFromTop(iCtrlHeight), szEdtPassCaption, fSideEdits, szPassPref)); AddElement(pEdtPass2 = new C4GUI::LabeledEdit(caTemp.GetFromTop(iCtrlHeight), szEdtPass2Caption, fSideEdits, szPassPref)); // hide them @@ -566,16 +566,16 @@ C4LeagueSignupDialog::C4LeagueSignupDialog(const char *szPlayerName, const char else { // No password checkbox - pChkPassword = NULL; + pChkPassword = nullptr; // But a password edit box const char *szEdtPassCaption = LoadResStr("IDS_CTL_LEAGUE_PLRPW"); - C4GUI::LabeledEdit::GetControlSize(NULL, &iCtrlHeight, szEdtPassCaption, NULL, fSideEdits); + C4GUI::LabeledEdit::GetControlSize(nullptr, &iCtrlHeight, szEdtPassCaption, nullptr, fSideEdits); AddElement(pEdtPass = new C4GUI::LabeledEdit(caMain.GetFromTop(iCtrlHeight), szEdtPassCaption, fSideEdits, szPassPref)); // No second password edit box - pEdtPass2 = NULL; + pEdtPass2 = nullptr; // remember login-checkbox const char *szRememberPasswordCaption = LoadResStr("IDS_CTL_LEAGUE_CHK_REMEMBERLOGIN"); - C4GUI::CheckBox::GetStandardCheckBoxSize(NULL, &iCtrlHeight, szRememberPasswordCaption, NULL); + C4GUI::CheckBox::GetStandardCheckBoxSize(nullptr, &iCtrlHeight, szRememberPasswordCaption, nullptr); AddElement(pChkRememberLogin = new C4GUI::CheckBox(caMain.GetFromTop(iCtrlHeight), szRememberPasswordCaption, fRememberLogin)); pChkRememberLogin->SetToolTip(LoadResStr("IDS_DESC_REMEMBERLOGIN")); } diff --git a/src/network/C4League.h b/src/network/C4League.h index ad9399d81..915d918c2 100644 --- a/src/network/C4League.h +++ b/src/network/C4League.h @@ -75,7 +75,7 @@ class C4LeagueReportDisconnectHead : public C4LeagueRequestHead private: C4LeagueDisconnectReason eReason; public: - C4LeagueReportDisconnectHead(const char *szCSID, C4LeagueDisconnectReason eReason) : C4LeagueRequestHead(C4LA_ReportDisconnect, szCSID, NULL), eReason(eReason) {} + C4LeagueReportDisconnectHead(const char *szCSID, C4LeagueDisconnectReason eReason) : C4LeagueRequestHead(C4LA_ReportDisconnect, szCSID, nullptr), eReason(eReason) {} public: void CompileFunc(StdCompiler *pComp); @@ -84,7 +84,7 @@ public: class C4LeagueRequestHeadEnd : public C4LeagueRequestHead { public: - C4LeagueRequestHeadEnd(C4LeagueAction eAction, const char *szCSID, const char *szRecordName = NULL, const BYTE *pRecordSHA = NULL) + C4LeagueRequestHeadEnd(C4LeagueAction eAction, const char *szCSID, const char *szRecordName = nullptr, const BYTE *pRecordSHA = nullptr) : C4LeagueRequestHead(eAction, szCSID), RecordName(szRecordName) { if (pRecordSHA) @@ -193,7 +193,7 @@ private: } *pFirst; public: - C4LeagueFBIDList() : pFirst(NULL) {} + C4LeagueFBIDList() : pFirst(nullptr) {} ~C4LeagueFBIDList() { Clear(); } void Clear(); void RemoveFBIDByAccount(const char *szAccount); @@ -229,7 +229,7 @@ public: bool GetEndReply(StdStrBuf *pMessage, class C4RoundResultsPlayers *pRoundResults); // Action "Auth" - bool Auth(const C4PlayerInfo &PlrInfo, const char *szAccount, const char *szPassword, const char *szNewAccount = NULL, const char *szNewPassword = NULL, bool fRememberLogin = false); + bool Auth(const C4PlayerInfo &PlrInfo, const char *szAccount, const char *szPassword, const char *szNewAccount = nullptr, const char *szNewPassword = nullptr, bool fRememberLogin = false); bool GetAuthReply(StdStrBuf *pMessage, StdStrBuf *pAUID, StdStrBuf *pAccount, bool *pRegister, StdStrBuf *pLoginToken); // Action "Join" diff --git a/src/network/C4NetIO.cpp b/src/network/C4NetIO.cpp index be6315916..6b1712fb6 100644 --- a/src/network/C4NetIO.cpp +++ b/src/network/C4NetIO.cpp @@ -269,15 +269,15 @@ void C4NetIOPacket::Clear() // construction / destruction C4NetIOTCP::C4NetIOTCP() - : pPeerList(NULL), - pConnectWaits(NULL), + : pPeerList(nullptr), + pConnectWaits(nullptr), PeerListCSec(this), fInit(false), iListenPort(~0), lsock(INVALID_SOCKET), #ifdef STDSCHEDULER_USE_EVENTS - Event(NULL), + Event(nullptr), #endif - pCB(NULL) + pCB(nullptr) { } @@ -360,10 +360,10 @@ bool C4NetIOTCP::Close() #ifdef STDSCHEDULER_USE_EVENTS // close event - if (Event != NULL) + if (Event != nullptr) { WSACloseEvent(Event); - Event = NULL; + Event = nullptr; } #else // close pipe @@ -463,7 +463,7 @@ bool C4NetIOTCP::Execute(int iMaxTime, pollfd *fds) // (mt-safe) #ifdef STDSCHEDULER_USE_EVENTS // get event list - if (::WSAEnumNetworkEvents(lsock, NULL, &wsaEvents) == SOCKET_ERROR) + if (::WSAEnumNetworkEvents(lsock, nullptr, &wsaEvents) == SOCKET_ERROR) return false; // a connection waiting for accept? @@ -496,7 +496,7 @@ bool C4NetIOTCP::Execute(int iMaxTime, pollfd *fds) // (mt-safe) { #ifdef STDSCHEDULER_USE_EVENTS // get event list - if (::WSAEnumNetworkEvents(pWait->sock, NULL, &wsaEvents) == SOCKET_ERROR) + if (::WSAEnumNetworkEvents(pWait->sock, nullptr, &wsaEvents) == SOCKET_ERROR) return false; if (wsaEvents.lNetworkEvents & FD_CONNECT) @@ -549,7 +549,7 @@ bool C4NetIOTCP::Execute(int iMaxTime, pollfd *fds) // (mt-safe) #ifdef STDSCHEDULER_USE_EVENTS // get event list - if (::WSAEnumNetworkEvents(sock, NULL, &wsaEvents) == SOCKET_ERROR) + if (::WSAEnumNetworkEvents(sock, nullptr, &wsaEvents) == SOCKET_ERROR) return false; // something to read from socket? @@ -860,7 +860,7 @@ C4NetIOTCP::Peer *C4NetIOTCP::Accept(SOCKET nsock, const addr_t &ConnectAddr) // { // set error SetError("socket accept failed", true); - return NULL; + return nullptr; } // connect address unknown, so zero it ZeroMem(&caddr, sizeof caddr); @@ -877,7 +877,7 @@ C4NetIOTCP::Peer *C4NetIOTCP::Accept(SOCKET nsock, const addr_t &ConnectAddr) // #endif // set error SetError("could not get peer address for connected socket", true); - return NULL; + return nullptr; #ifndef HAVE_WINSOCK } #endif @@ -890,7 +890,7 @@ C4NetIOTCP::Peer *C4NetIOTCP::Accept(SOCKET nsock, const addr_t &ConnectAddr) // // set error SetError("socket accept failed: invalid address returned"); closesocket(nsock); - return NULL; + return nullptr; } // disable nagle (yep, we know what we are doing here - I think) @@ -904,7 +904,7 @@ C4NetIOTCP::Peer *C4NetIOTCP::Accept(SOCKET nsock, const addr_t &ConnectAddr) // // set error SetError("connection accept failed: could not set event", true); closesocket(nsock); - return NULL; + return nullptr; } #elif defined(HAVE_WINSOCK) // disable blocking @@ -923,7 +923,7 @@ C4NetIOTCP::Peer *C4NetIOTCP::Accept(SOCKET nsock, const addr_t &ConnectAddr) // // set error SetError("connection accept failed: could not disable blocking", true); close(nsock); - return NULL; + return nullptr; } #endif @@ -945,7 +945,7 @@ C4NetIOTCP::Peer *C4NetIOTCP::Accept(SOCKET nsock, const addr_t &ConnectAddr) // Changed(); // ask callback if connection should be permitted - if (pCB && !pCB->OnConn(addr, caddr, NULL, this)) + if (pCB && !pCB->OnConn(addr, caddr, nullptr, this)) // close socket immediately (will be deleted later) pnPeer->Close(); @@ -1016,7 +1016,7 @@ C4NetIOTCP::Peer *C4NetIOTCP::GetPeer(const addr_t &addr) // (mt-safe) if (pPeer->Open()) if (AddrEqual(pPeer->GetAddr(), addr)) return pPeer; - return NULL; + return nullptr; } void C4NetIOTCP::OnShareFree(CStdCSecEx *pCSec) @@ -1024,7 +1024,7 @@ void C4NetIOTCP::OnShareFree(CStdCSecEx *pCSec) if (pCSec == &PeerListCSec) { // clear up - Peer *pPeer = pPeerList, *pLast = NULL; + Peer *pPeer = pPeerList, *pLast = nullptr; while (pPeer) { // delete? @@ -1044,7 +1044,7 @@ void C4NetIOTCP::OnShareFree(CStdCSecEx *pCSec) pPeer = pPeer->Next; } } - ConnectWait *pWait = pConnectWaits, *pWLast = NULL; + ConnectWait *pWait = pConnectWaits, *pWLast = nullptr; while (pWait) { // delete? @@ -1090,7 +1090,7 @@ C4NetIOTCP::ConnectWait *C4NetIOTCP::GetConnectWait(const addr_t &addr) // (mt-s for (ConnectWait *pWait = pConnectWaits; pWait; pWait = pWait->Next) if (AddrEqual(pWait->addr, addr)) return pWait; - return NULL; + return nullptr; } void C4NetIOTCP::ClearConnectWaits() // (mt-safe) @@ -1155,7 +1155,7 @@ C4NetIOTCP::Peer::Peer(const C4NetIO::addr_t &naddr, SOCKET nsock, C4NetIOTCP *p : pParent(pnParent), addr(naddr), sock(nsock), iIBufUsage(0), iIRate(0), iORate(0), - fOpen(true), fDoBroadcast(false), Next(NULL) + fOpen(true), fDoBroadcast(false), Next(nullptr) { } @@ -1306,7 +1306,7 @@ void C4NetIOTCP::Peer::ClearStatistics() // (mt-safe) C4NetIOSimpleUDP::C4NetIOSimpleUDP() : fInit(false), fMultiCast(false), iPort(~0), sock(INVALID_SOCKET), #ifdef STDSCHEDULER_USE_EVENTS - hEvent(NULL), + hEvent(nullptr), #endif fAllowReUse(false) { @@ -1481,10 +1481,10 @@ bool C4NetIOSimpleUDP::Close() #ifdef STDSCHEDULER_USE_EVENTS // close event - if (hEvent != NULL) + if (hEvent != nullptr) { WSACloseEvent(hEvent); - hEvent = NULL; + hEvent = nullptr; } #else // close pipes @@ -1808,7 +1808,7 @@ C4NetIOUDP::C4NetIOUDP() fInit(false), fMultiCast(false), iPort(~0), - pPeerList(NULL), + pPeerList(nullptr), fSavePacket(false), fDelayedLoopbackTest(false), tNextCheck(C4TimeMilliseconds::PositiveInfinity), @@ -2254,7 +2254,7 @@ void C4NetIOUDP::OnAddAddress(const addr_t &FromAddr, const AddAddrPacket &Packe C4NetIOUDP::Packet::Packet() : iNr(~0), Data(), - pFragmentGot(NULL) + pFragmentGot(nullptr) { } @@ -2262,14 +2262,14 @@ C4NetIOUDP::Packet::Packet() C4NetIOUDP::Packet::Packet(C4NetIOPacket &&rnData, nr_t inNr) : iNr(inNr), Data(rnData), - pFragmentGot(NULL) + pFragmentGot(nullptr) { } C4NetIOUDP::Packet::~Packet() { - delete [] pFragmentGot; pFragmentGot = NULL; + delete [] pFragmentGot; pFragmentGot = nullptr; } // implementation @@ -2345,7 +2345,7 @@ bool C4NetIOUDP::Packet::AddFragment(const C4NetIOPacket &Packet, const C4NetIO: // check packet size nr_t iFNr = pHdr->Nr - iNr; if (iPacketDataSize != FragmentSize(iFNr)) return false; - // already got this fragment? (needs check for first packet as FragmentPresent always assumes true if pFragmentGot is NULL) + // already got this fragment? (needs check for first packet as FragmentPresent always assumes true if pFragmentGot is nullptr) StdBuf PacketData = Packet.getPart(sizeof(DataPacketHdr), iPacketDataSize); if (!fFirstFragment && FragmentPresent(iFNr)) { @@ -2379,8 +2379,8 @@ size_t C4NetIOUDP::Packet::FragmentSize(nr_t iFNr) const // construction / destruction C4NetIOUDP::PacketList::PacketList(unsigned int inMaxPacketCnt) - : pFront(NULL), - pBack(NULL), + : pFront(nullptr), + pBack(nullptr), iPacketCnt(0), iMaxPacketCnt(inMaxPacketCnt) { @@ -2399,8 +2399,8 @@ C4NetIOUDP::Packet *C4NetIOUDP::PacketList::GetPacket(unsigned int iNr) if (pPkt->GetNr() == iNr) return pPkt; else if (pPkt->GetNr() < iNr) - return NULL; - return NULL; + return nullptr; + return nullptr; } C4NetIOUDP::Packet *C4NetIOUDP::PacketList::GetPacketFrgm(unsigned int iNr) @@ -2410,14 +2410,14 @@ C4NetIOUDP::Packet *C4NetIOUDP::PacketList::GetPacketFrgm(unsigned int iNr) if (pPkt->GetNr() <= iNr && pPkt->GetNr() + pPkt->FragmentCnt() > iNr) return pPkt; else if (pPkt->GetNr() < iNr) - return NULL; - return NULL; + return nullptr; + return nullptr; } C4NetIOUDP::Packet *C4NetIOUDP::PacketList::GetFirstPacketComplete() { CStdShareLock ListLock(&ListCSec); - return pFront && pFront->Complete() ? pFront : NULL; + return pFront && pFront->Complete() ? pFront : nullptr; } bool C4NetIOUDP::PacketList::FragmentPresent(unsigned int iNr) @@ -2431,7 +2431,7 @@ bool C4NetIOUDP::PacketList::AddPacket(Packet *pPacket) { CStdLock ListLock(&ListCSec); // find insert location - Packet *pInsertAfter = pBack, *pInsertBefore = NULL; + Packet *pInsertAfter = pBack, *pInsertBefore = nullptr; for (; pInsertAfter; pInsertBefore = pInsertAfter, pInsertAfter = pInsertAfter->Prev) if (pInsertAfter->GetNr() + pInsertAfter->FragmentCnt() <= pPacket->GetNr()) break; @@ -3096,7 +3096,7 @@ void C4NetIOUDP::OnShareFree(CStdCSecEx *pCSec) { if (pCSec == &PeerListCSec) { - Peer *pPeer = pPeerList, *pLast = NULL; + Peer *pPeer = pPeerList, *pLast = nullptr; while (pPeer) { // delete? @@ -3125,7 +3125,7 @@ C4NetIOUDP::Peer *C4NetIOUDP::GetPeer(const addr_t &addr) if (!pPeer->Closed()) if (AddrEqual(pPeer->GetAddr(), addr) || AddrEqual(pPeer->GetAltAddr(), addr)) return pPeer; - return NULL; + return nullptr; } C4NetIOUDP::Peer *C4NetIOUDP::ConnectPeer(const addr_t &PeerAddr, bool fFailCallback) // (mt-safe) @@ -3138,12 +3138,12 @@ C4NetIOUDP::Peer *C4NetIOUDP::ConnectPeer(const addr_t &PeerAddr, bool fFailCall if (pnPeer) return pnPeer; // create new Peer class pnPeer = new Peer(PeerAddr, this); - if (!pnPeer) return NULL; + if (!pnPeer) return nullptr; // add peer to list AddPeer(pnPeer); PeerListAddLock.Clear(); // send connection request - if (!pnPeer->Connect(fFailCallback)) { pnPeer->Close("connect failed"); return NULL; } + if (!pnPeer->Connect(fFailCallback)) { pnPeer->Close("connect failed"); return nullptr; } // ok (do not wait for peer) return pnPeer; } @@ -3299,7 +3299,7 @@ void C4NetIOUDP::DebugLogPkt(bool fOut, const C4NetIOPacket &Pkt) C4NetIOMan::C4NetIOMan() : StdSchedulerThread(), iNetIOCnt(0), iNetIOCapacity(0), - ppNetIO(NULL) + ppNetIO(nullptr) { } @@ -3311,7 +3311,7 @@ C4NetIOMan::~C4NetIOMan() void C4NetIOMan::Clear() { - delete[] ppNetIO; ppNetIO = NULL; + delete[] ppNetIO; ppNetIO = nullptr; iNetIOCnt = iNetIOCapacity = 0; StdSchedulerThread::Clear(); } diff --git a/src/network/C4NetIO.h b/src/network/C4NetIO.h index 936e77536..121155e9c 100644 --- a/src/network/C4NetIO.h +++ b/src/network/C4NetIO.h @@ -168,7 +168,7 @@ public: const C4NetIO::addr_t &getAddr() const { return addr; } uint8_t getStatus()const { return getSize() ? *getBufPtr(*this) : 0; } - const char *getPData() const { return getSize() ? getBufPtr(*this, 1) : NULL; } + const char *getPData() const { return getSize() ? getBufPtr(*this, 1) : nullptr; } size_t getPSize() const { return getSize() ? getSize() - 1 : 0; } StdBuf getPBuf() const { return getSize() ? getPart(1, getSize() - 1) : getRef(); } @@ -678,7 +678,7 @@ protected: // helpers bool DoConn(bool fMC); - bool DoCheck(int iAskCnt = 0, int iMCAskCnt = 0, unsigned int *pAskList = NULL); + bool DoCheck(int iAskCnt = 0, int iMCAskCnt = 0, unsigned int *pAskList = nullptr); // sending bool SendDirect(const Packet &rPacket, unsigned int iNr = ~0); diff --git a/src/network/C4Network2.cpp b/src/network/C4Network2.cpp index ccba86977..06803998f 100644 --- a/src/network/C4Network2.cpp +++ b/src/network/C4Network2.cpp @@ -135,16 +135,16 @@ C4Network2::C4Network2() iDynamicTick(-1), fDynamicNeeded(false), fStatusAck(false), fStatusReached(false), fChasing(false), - pControl(NULL), - pLobby(NULL), fLobbyRunning(false), pLobbyCountdown(NULL), + pControl(nullptr), + pLobby(nullptr), fLobbyRunning(false), pLobbyCountdown(nullptr), iNextClientID(0), iLastChaseTargetUpdate(0), tLastActivateRequest(C4TimeMilliseconds::NegativeInfinity), iLastReferenceUpdate(0), iLastLeagueUpdate(0), - pLeagueClient(NULL), + pLeagueClient(nullptr), fDelayedActivateReq(false), - pVoteDialog(NULL), + pVoteDialog(nullptr), fPausedForVote(false), iLastOwnVoting(0), fStreaming(false), @@ -221,7 +221,7 @@ C4Network2::InitResult C4Network2::InitClient(const C4Network2Reference &Ref, bo msg.Format(LoadResStr("IDS_NET_ERR_VERSIONMISMATCH"), HostCore.getRevision(), Application.GetRevision()); if (!Application.isEditor) { - if (!pGUI->ShowMessageModal(msg.getData(), "[!]Network warning", C4GUI::MessageDialog::btnOKAbort, C4GUI::Ico_Notify, NULL /* do not allow to skip this message! */)) + if (!pGUI->ShowMessageModal(msg.getData(), "[!]Network warning", C4GUI::MessageDialog::btnOKAbort, C4GUI::Ico_Notify, nullptr /* do not allow to skip this message! */)) return IR_Fatal; } else @@ -265,7 +265,7 @@ C4Network2::InitResult C4Network2::InitClient(const C4Network2Reference &Ref, bo if (!Game.Parameters.InitNetwork(&ResList)) return IR_Fatal; // init league - if (!InitLeague(NULL)) + if (!InitLeague(nullptr)) { // deinit league DeinitLeague(); @@ -323,7 +323,7 @@ C4Network2::InitResult C4Network2::InitClient(const class C4Network2Address *pAd StdStrBuf strMessage = FormatString(LoadResStr("IDS_NET_CONNECTHOST"), strAddresses.getData()); Log(strMessage.getData()); // show box - C4GUI::MessageDialog *pDlg = NULL; + C4GUI::MessageDialog *pDlg = nullptr; if (!Application.isEditor) { // create & show @@ -385,7 +385,7 @@ bool C4Network2::DoLobby() // init lobby dialog pLobby = new C4GameLobby::MainDlg(isHost()); - if (!pLobby->FadeIn(::pGUI)) { delete pLobby; pLobby = NULL; Clear(); return false; } + if (!pLobby->FadeIn(::pGUI)) { delete pLobby; pLobby = nullptr; Clear(); return false; } // init lobby countdown if specified if (Game.iLobbyTimeout) StartLobbyCountdown(Game.iLobbyTimeout); @@ -396,18 +396,18 @@ bool C4Network2::DoLobby() { Clear(); return false; } // check whether lobby was aborted - if (pLobby && pLobby->IsAborted()) { delete pLobby; pLobby = NULL; Clear(); return false; } + if (pLobby && pLobby->IsAborted()) { delete pLobby; pLobby = nullptr; Clear(); return false; } // deinit lobby if (pLobby && pLobby->IsShown()) pLobby->Close(true); - delete pLobby; pLobby = NULL; + delete pLobby; pLobby = nullptr; // close any other dialogs ::pGUI->CloseAllDialogs(false); } // lobby end - delete pLobbyCountdown; pLobbyCountdown = NULL; + delete pLobbyCountdown; pLobbyCountdown = nullptr; fLobbyRunning = false; fAllowJoin = !Config.Network.NoRuntimeJoin; @@ -468,7 +468,7 @@ bool C4Network2::FinalInit() if (!Application.FlushMessages()) return false; // show box - C4GUI::Dialog *pDlg = NULL; + C4GUI::Dialog *pDlg = nullptr; if (!Application.isEditor) { // separate dlgs for host/client @@ -584,7 +584,7 @@ void C4Network2::Execute() // check for inactive clients and deactivate them DeactivateInactiveClients(); // reference - if (!iLastReferenceUpdate || time(NULL) > (time_t) (iLastReferenceUpdate + C4NetReferenceUpdateInterval)) + if (!iLastReferenceUpdate || time(nullptr) > (time_t) (iLastReferenceUpdate + C4NetReferenceUpdateInterval)) if (NetIO.IsReferenceNeeded()) { // create @@ -592,10 +592,10 @@ void C4Network2::Execute() pRef->InitLocal(); // set NetIO.SetReference(pRef); - iLastReferenceUpdate = time(NULL); + iLastReferenceUpdate = time(nullptr); } // league server reference - if (!iLastLeagueUpdate || time(NULL) > (time_t) (iLastLeagueUpdate + iLeagueUpdateDelay)) + if (!iLastLeagueUpdate || time(nullptr) > (time_t) (iLastLeagueUpdate + iLeagueUpdateDelay)) { LeagueUpdate(); } @@ -605,14 +605,14 @@ void C4Network2::Execute() LeagueUpdateProcessReply(); } // voting timeout - if (Votes.firstPkt() && time(NULL) > (time_t) (iVoteStartTime + C4NetVotingTimeout)) + if (Votes.firstPkt() && time(nullptr) > (time_t) (iVoteStartTime + C4NetVotingTimeout)) { C4ControlVote *pVote = static_cast(Votes.firstPkt()->getPkt()); ::Control.DoInput( CID_VoteEnd, new C4ControlVoteEnd(pVote->getType(), false, pVote->getData()), CDT_Sync); - iVoteStartTime = time(NULL); + iVoteStartTime = time(nullptr); } // record streaming if (fStreaming) @@ -641,9 +641,9 @@ void C4Network2::Clear() DeinitLeague(); } // stop lobby countdown - delete pLobbyCountdown; pLobbyCountdown = NULL; + delete pLobbyCountdown; pLobbyCountdown = nullptr; // cancel lobby - delete pLobby; pLobby = NULL; + delete pLobby; pLobby = nullptr; fLobbyRunning = false; // deactivate Status.Clear(); @@ -667,7 +667,7 @@ void C4Network2::Clear() tLastActivateRequest = C4TimeMilliseconds::NegativeInfinity; iLastChaseTargetUpdate = iLastReferenceUpdate = iLastLeagueUpdate = 0; fDelayedActivateReq = false; - delete pVoteDialog; pVoteDialog = NULL; + delete pVoteDialog; pVoteDialog = nullptr; fPausedForVote = false; iLastOwnVoting = 0; NetpuncherGameID = 0; @@ -705,7 +705,7 @@ StdStrBuf C4Network2::QueryClientPassword() { // ask client for a password; return nothing if user canceled StdStrBuf sCaption; sCaption.Copy(LoadResStr("IDS_MSG_ENTERPASSWORD")); - C4GUI::InputDialog *pInputDlg = new C4GUI::InputDialog(LoadResStr("IDS_MSG_ENTERPASSWORD"), sCaption.getData(), C4GUI::Ico_Ex_Locked, NULL, false); + C4GUI::InputDialog *pInputDlg = new C4GUI::InputDialog(LoadResStr("IDS_MSG_ENTERPASSWORD"), sCaption.getData(), C4GUI::Ico_Ex_Locked, nullptr, false); pInputDlg->SetDelOnClose(false); if (!::pGUI->ShowModalDlg(pInputDlg, false)) { @@ -939,7 +939,7 @@ void C4Network2::OnGameSynchronized() // create dynamic bool fSuccess = CreateDynamic(false); // check for clients that still need join-data - C4Network2Client *pClient = NULL; + C4Network2Client *pClient = nullptr; while ((pClient = Clients.GetNextClient(pClient))) if (!pClient->hasJoinData()) { @@ -1018,7 +1018,7 @@ void C4Network2::DrawStatus(C4TargetFacet &cgo) // clients Stat.Append("|Clients:"); - for (C4Network2Client *pClient = Clients.GetNextClient(NULL); pClient; pClient = Clients.GetNextClient(pClient)) + for (C4Network2Client *pClient = Clients.GetNextClient(nullptr); pClient; pClient = Clients.GetNextClient(pClient)) { // ignore local if (pClient->isLocal()) continue; @@ -1061,7 +1061,7 @@ void C4Network2::DrawStatus(C4TargetFacet &cgo) else Stat.Append("| Not connected"); } - if (!Clients.GetNextClient(NULL)) + if (!Clients.GetNextClient(nullptr)) Stat.Append("| - none -"); // draw @@ -1426,7 +1426,7 @@ void C4Network2::HandleJoinData(const C4PacketJoinData &rPkt) // load player resources Game.Parameters.PlayerInfos.LoadResources(); // send additional addresses - Clients.SendAddresses(NULL); + Clients.SendAddresses(nullptr); } void C4Network2::OnConnect(C4Network2Client *pClient, C4Network2IOConnection *pConn, const char *szMsg, bool fFirstConnection) @@ -1548,12 +1548,12 @@ void C4Network2::SendJoinData(C4Network2Client *pClient) Clients.SendAddresses(pClient->getMsgConn()); // flag client (he will have to accept the network status sent next) pClient->SetStatus(NCS_Chasing); - if (!iLastChaseTargetUpdate) iLastChaseTargetUpdate = time(NULL); + if (!iLastChaseTargetUpdate) iLastChaseTargetUpdate = time(nullptr); } C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_t iTimeoutLen, const char *szResName, bool fWaitForCore) { - C4GUI::ProgressDialog *pDlg = NULL; + C4GUI::ProgressDialog *pDlg = nullptr; bool fLog = false; int32_t iProcess = -1; C4TimeMilliseconds tTimeout = C4TimeMilliseconds::Now() + iTimeoutLen; @@ -1568,7 +1568,7 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_ if (Core.isNull()) { // should wait for core? - if (!fWaitForCore) return NULL; + if (!fWaitForCore) return nullptr; } else { @@ -1599,7 +1599,7 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_ { LogFatal(FormatString(LoadResStr("IDS_NET_ERR_RESTIMEOUT"), szResName).getData()); if (pDlg) delete pDlg; - return NULL; + return nullptr; } } @@ -1616,7 +1616,7 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_ pDlg = new C4GUI::ProgressDialog(FormatString(LoadResStr("IDS_NET_WAITFORRES"), szResName).getData(), LoadResStr("IDS_NET_CAPTION"), 100, 0, C4GUI::Ico_NetWait); // show dialog - if (!pDlg->Show(::pGUI, true)) { delete pDlg; return NULL; } + if (!pDlg->Show(::pGUI, true)) { delete pDlg; return nullptr; } } // wait @@ -1626,20 +1626,20 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_ pDlg->SetProgress(iProcess); // execute (will do message handling) if (!pDlg->Execute()) - { if (pDlg) delete pDlg; return NULL; } + { if (pDlg) delete pDlg; return nullptr; } // aborted? if (pDlg->IsAborted()) break; } else { if (!Application.ScheduleProcs(tTimeout - C4TimeMilliseconds::Now())) - { return NULL; } + { return nullptr; } } } // aborted delete pDlg; - return NULL; + return nullptr; } @@ -1851,7 +1851,7 @@ void C4Network2::DeactivateInactiveClients() // update activity Clients.UpdateClientActivity(); // find clients to deactivate - for (C4Network2Client *pClient = Clients.GetNextClient(NULL); pClient; pClient = Clients.GetNextClient(pClient)) + for (C4Network2Client *pClient = Clients.GetNextClient(nullptr); pClient; pClient = Clients.GetNextClient(pClient)) if (!pClient->isLocal() && pClient->isActivated()) if (pClient->getLastActivity() + C4NetDeactivationDelay < Game.FrameCounter) ::Control.DoInput(CID_ClientUpdate, new C4ControlClientUpdate(pClient->getID(), CUT_Activate, false), CDT_Sync); @@ -1861,7 +1861,7 @@ void C4Network2::UpdateChaseTarget() { // no chasing clients? C4Network2Client *pClient; - for (pClient = Clients.GetNextClient(NULL); pClient; pClient = Clients.GetNextClient(pClient)) + for (pClient = Clients.GetNextClient(nullptr); pClient; pClient = Clients.GetNextClient(pClient)) if (pClient->isChasing()) break; if (!pClient) @@ -1870,16 +1870,16 @@ void C4Network2::UpdateChaseTarget() return; } // not time for an update? - if (!iLastChaseTargetUpdate || long(iLastChaseTargetUpdate + C4NetChaseTargetUpdateInterval) > time(NULL)) + if (!iLastChaseTargetUpdate || long(iLastChaseTargetUpdate + C4NetChaseTargetUpdateInterval) > time(nullptr)) return; // copy status, set current tick C4Network2Status ChaseTarget = Status; ChaseTarget.SetTargetTick(::Control.ControlTick); // send to everyone involved - for (pClient = Clients.GetNextClient(NULL); pClient; pClient = Clients.GetNextClient(pClient)) + for (pClient = Clients.GetNextClient(nullptr); pClient; pClient = Clients.GetNextClient(pClient)) if (pClient->isChasing()) pClient->SendMsg(MkC4NetIOPacket(PID_Status, ChaseTarget)); - iLastChaseTargetUpdate = time(NULL); + iLastChaseTargetUpdate = time(nullptr); } void C4Network2::LeagueGameEvaluate(const char *szRecordName, const BYTE *pRecordSHA) @@ -1907,7 +1907,7 @@ bool C4Network2::LeagueSignupEnable() // already running? if (pLeagueClient) return true; // Start it! - if (InitLeague(NULL) && LeagueStart(NULL)) return true; + if (InitLeague(nullptr) && LeagueStart(nullptr)) return true; // Failure :'( DeinitLeague(); return false; @@ -1930,7 +1930,7 @@ bool C4Network2::InitLeague(bool *pCancel) MasterServerAddress.Clear(); Game.Parameters.League.Clear(); Game.Parameters.LeagueAddress.Clear(); - if (pLeagueClient) delete pLeagueClient; pLeagueClient = NULL; + if (pLeagueClient) delete pLeagueClient; pLeagueClient = nullptr; // Not needed? if (!Config.Network.MasterServerSignUp && !Config.Network.LeagueServerSignUp) @@ -1967,7 +1967,7 @@ bool C4Network2::InitLeague(bool *pCancel) StdStrBuf Message = FormatString(LoadResStr("IDS_NET_ERR_LEAGUEINIT"), pLeagueClient->GetError()); LogFatal(Message.getData()); // Clear league - delete pLeagueClient; pLeagueClient = NULL; + delete pLeagueClient; pLeagueClient = nullptr; if (fHost) Game.Parameters.LeagueAddress.Clear(); // Show message, allow abort @@ -1996,7 +1996,7 @@ void C4Network2::DeinitLeague() if (pLeagueClient) { Application.Remove(pLeagueClient); - delete pLeagueClient; pLeagueClient = NULL; + delete pLeagueClient; pLeagueClient = nullptr; } } @@ -2039,7 +2039,7 @@ bool C4Network2::LeagueStart(bool *pCancel) StdStrBuf Message = FormatString(LoadResStr("IDS_NET_LEAGUE_REGGAME"), pLeagueClient->getServerName()); Log(Message.getData()); // Set up a dialog - C4GUI::MessageDialog *pDlg = NULL; + C4GUI::MessageDialog *pDlg = nullptr; if (!Application.isEditor) { // create & show @@ -2164,7 +2164,7 @@ bool C4Network2::LeagueUpdate() } // Timing - iLastLeagueUpdate = time(NULL); + iLastLeagueUpdate = time(nullptr); iLeagueUpdateDelay = Config.Network.MasterReferencePeriod; return true; @@ -2335,7 +2335,7 @@ bool C4Network2::LeaguePlrAuth(C4PlayerInfo *pInfo) if (!pLeagueClient) return false; // Send authentication request - if (!pLeagueClient->Auth(*pInfo, Account.getData(), Password.getData(), NULL, NULL, fRememberLogin)) + if (!pLeagueClient->Auth(*pInfo, Account.getData(), Password.getData(), nullptr, nullptr, fRememberLogin)) return false; // safety (modal dlg may have deleted network) @@ -2345,7 +2345,7 @@ bool C4Network2::LeaguePlrAuth(C4PlayerInfo *pInfo) StdStrBuf Message = FormatString(LoadResStr("IDS_MSG_TRYLEAGUESIGNUP"), pInfo->GetName(), Account.getData(), pLeagueClient->getServerName()); Log(Message.getData()); // Set up a dialog - C4GUI::MessageDialog *pDlg = NULL; + C4GUI::MessageDialog *pDlg = nullptr; if (!Application.isEditor) { // create & show @@ -2538,7 +2538,7 @@ void C4Network2::Vote(C4ControlVoteType eType, bool fApprove, int32_t iData) if (!GetVote(C4ClientIDUnknown, eType, iData)) { // Too fast? - if (time(NULL) < (time_t) (iLastOwnVoting + C4NetMinVotingInterval)) + if (time(nullptr) < (time_t) (iLastOwnVoting + C4NetMinVotingInterval)) { Log(LoadResStr("IDS_TEXT_YOUCANONLYSTARTONEVOTINGE")); if ((eType == VT_Kick && iData == Game.Clients.getLocalID()) || eType == VT_Cancel) @@ -2546,7 +2546,7 @@ void C4Network2::Vote(C4ControlVoteType eType, bool fApprove, int32_t iData) return; } // Save timestamp - iLastOwnVoting = time(NULL); + iLastOwnVoting = time(nullptr); } // Already voted? Ignore if (GetVote(::Control.ClientID(), eType, iData)) @@ -2565,7 +2565,7 @@ void C4Network2::AddVote(const C4ControlVote &Vote) { // Save back timestamp if (!Votes.firstPkt()) - iVoteStartTime = time(NULL); + iVoteStartTime = time(nullptr); // Save vote back Votes.Add(CID_Vote, new C4ControlVote(Vote)); // Set pause mode if this is the host @@ -2587,7 +2587,7 @@ C4IDPacket *C4Network2::GetVote(int32_t iClientID, C4ControlVoteType eType, int3 if (iClientID == C4ClientIDUnknown || pVote->getByClient() == iClientID) if (pVote->getType() == eType && pVote->getData() == iData) return pPkt; - return NULL; + return nullptr; } void C4Network2::EndVote(C4ControlVoteType eType, bool fApprove, int32_t iData) @@ -2601,7 +2601,7 @@ void C4Network2::EndVote(C4ControlVoteType eType, bool fApprove, int32_t iData) Votes.Delete(pPkt); } // Reset timestamp - iVoteStartTime = time(NULL); + iVoteStartTime = time(nullptr); // Approved own voting? Reset voting block if (fApprove && iOrigin == Game.Clients.getLocalID()) iLastOwnVoting = 0; @@ -2611,7 +2611,7 @@ void C4Network2::EndVote(C4ControlVoteType eType, bool fApprove, int32_t iData) { // close delete pVoteDialog; - pVoteDialog = NULL; + pVoteDialog = nullptr; } // Did we try to kick ourself? Ask if we'd like to surrender bool fCancelVote = (eType == VT_Kick && iData == Game.Clients.getLocalID()) || eType == VT_Cancel; @@ -2678,14 +2678,14 @@ void C4Network2::OpenSurrenderDialog(C4ControlVoteType eType, int32_t iData) void C4Network2::OnVoteDialogClosed() { - pVoteDialog = NULL; + pVoteDialog = nullptr; } // *** C4VoteDialog C4VoteDialog::C4VoteDialog(const char *szText, C4ControlVoteType eVoteType, int32_t iVoteData, bool fSurrender) - : MessageDialog(szText, LoadResStr("IDS_DLG_VOTING"), C4GUI::MessageDialog::btnYesNo, C4GUI::Ico_Confirm, C4GUI::MessageDialog::dsRegular, NULL, true), + : MessageDialog(szText, LoadResStr("IDS_DLG_VOTING"), C4GUI::MessageDialog::btnYesNo, C4GUI::Ico_Confirm, C4GUI::MessageDialog::dsRegular, nullptr, true), eVoteType(eVoteType), iVoteData(iVoteData), fSurrender(fSurrender) { @@ -2749,7 +2749,7 @@ void C4Network2::AbortLobbyCountdown() { pLobbyCountdown->Abort(); delete pLobbyCountdown; - pLobbyCountdown = NULL; + pLobbyCountdown = nullptr; } } @@ -2760,7 +2760,7 @@ bool C4Network2::StartStreaming(C4Record *pRecord) // Save back fStreaming = true; pStreamedRecord = pRecord; - iLastStreamAttempt = time(NULL); + iLastStreamAttempt = time(nullptr); // Initialize compressor ZeroMem(&StreamCompressor, sizeof(StreamCompressor)); @@ -2789,7 +2789,7 @@ bool C4Network2::FinishStreaming() StreamIn(true); // Reset record pointer - pStreamedRecord = NULL; + pStreamedRecord = nullptr; // Try to get rid of remaining data immediately iLastStreamAttempt = 0; @@ -2805,11 +2805,11 @@ bool C4Network2::StopStreaming() // Clear Application.Remove(pStreamer); fStreaming = false; - pStreamedRecord = NULL; + pStreamedRecord = nullptr; deflateEnd(&StreamCompressor); StreamingBuf.Clear(); delete pStreamer; - pStreamer = NULL; + pStreamer = nullptr; // ... finalization? return true; @@ -2896,7 +2896,7 @@ bool C4Network2::StreamOut() return false; // Overflow protection - if (iLastStreamAttempt && iLastStreamAttempt + C4NetStreamingInterval >= time(NULL)) + if (iLastStreamAttempt && iLastStreamAttempt + C4NetStreamingInterval >= time(nullptr)) return false; } @@ -2917,7 +2917,7 @@ bool C4Network2::StreamOut() // Send data size_t iStreamAmount = getPendingStreamData(); iCurrentStreamAmount = iStreamAmount; - iLastStreamAttempt = time(NULL); + iLastStreamAttempt = time(nullptr); return pStreamer->Query(StdBuf(StreamingBuf.getData(), iStreamAmount), false); } diff --git a/src/network/C4Network2.h b/src/network/C4Network2.h index 629335470..958553dc3 100644 --- a/src/network/C4Network2.h +++ b/src/network/C4Network2.h @@ -226,7 +226,7 @@ public: // initialization bool InitHost(bool fLobby); InitResult InitClient(const class C4Network2Reference &Ref, bool fObserver); - InitResult InitClient(const class C4Network2Address *pAddrs, int iAddrCount, const class C4ClientCore &HostCore, const char *szPassword = NULL); + InitResult InitClient(const class C4Network2Address *pAddrs, int iAddrCount, const class C4ClientCore &HostCore, const char *szPassword = nullptr); bool DoLobby(); bool Start(); bool Pause(); @@ -270,7 +270,7 @@ public: void DeactivateInactiveClients(); // host // league - void LeagueGameEvaluate(const char *szRecordName = NULL, const BYTE *pRecordSHA = NULL); + void LeagueGameEvaluate(const char *szRecordName = nullptr, const BYTE *pRecordSHA = nullptr); void LeagueSignupDisable(); // if "internet game" button is switched off in lobby: Remove from league server bool LeagueSignupEnable(); // if "internet game" button is switched on in lobby: (re)Add to league server void InvalidateReference(); // forces a recreation and re-send of the game reference in the next execution cycle @@ -354,7 +354,7 @@ protected: bool LeagueStart(bool *pCancel); bool LeagueUpdate(); bool LeagueUpdateProcessReply(); - bool LeagueEnd(const char *szRecordName = NULL, const BYTE *pRecordSHA = NULL); + bool LeagueEnd(const char *szRecordName = nullptr, const BYTE *pRecordSHA = nullptr); // streaming bool StreamIn(bool fFinish); diff --git a/src/network/C4Network2Address.cpp b/src/network/C4Network2Address.cpp index 4945ed134..005cf9e7c 100644 --- a/src/network/C4Network2Address.cpp +++ b/src/network/C4Network2Address.cpp @@ -41,7 +41,7 @@ void C4Network2Address::CompileFunc(StdCompiler *pComp) { "UDP", P_UDP }, { "TCP", P_TCP }, - { NULL, P_NONE }, + { nullptr, P_NONE }, }; pComp->Value(mkEnumAdaptT(eProtocol, Protocols)); pComp->Separator(StdCompiler::SEP_PART2); // ':' diff --git a/src/network/C4Network2Client.cpp b/src/network/C4Network2Client.cpp index 4de297c75..7476e0a67 100644 --- a/src/network/C4Network2Client.cpp +++ b/src/network/C4Network2Client.cpp @@ -39,17 +39,17 @@ C4Network2Client::C4Network2Client(C4Client *pClient) iAddrCnt(0), eStatus(NCS_Ready), iLastActivity(0), - pMsgConn(NULL), pDataConn(NULL), + pMsgConn(nullptr), pDataConn(nullptr), iNextConnAttempt(0), - pNext(NULL), pParent(NULL), pstatPing(NULL) + pNext(nullptr), pParent(nullptr), pstatPing(nullptr) { } C4Network2Client::~C4Network2Client() { ClearGraphs(); - if (pMsgConn) { pMsgConn->Close(); pMsgConn->DelRef(); } pMsgConn = NULL; - if (pDataConn) { pDataConn->Close(); pDataConn->DelRef(); } pDataConn = NULL; + if (pMsgConn) { pMsgConn->Close(); pMsgConn->DelRef(); } pMsgConn = nullptr; + if (pDataConn) { pDataConn->Close(); pDataConn->DelRef(); } pDataConn = nullptr; if (pClient) pClient->UnlinkNetClient(); } @@ -85,9 +85,9 @@ void C4Network2Client::SetDataConn(C4Network2IOConnection *pConn) void C4Network2Client::RemoveConn(C4Network2IOConnection *pConn) { if (pConn == pMsgConn) - { pMsgConn->DelRef(); pMsgConn = NULL; } + { pMsgConn->DelRef(); pMsgConn = nullptr; } if (pConn == pDataConn) - { pDataConn->DelRef(); pDataConn = NULL; } + { pDataConn->DelRef(); pDataConn = nullptr; } if (pMsgConn && !pDataConn) SetDataConn(pMsgConn); if (!pMsgConn && pDataConn) SetMsgConn(pDataConn); } @@ -125,9 +125,9 @@ bool C4Network2Client::DoConnectAttempt(C4Network2IO *pIO) // local? if (isLocal()) { iNextConnAttempt = 0; return true; } // msg and data connected? Nothing to do - if (getMsgConn() != getDataConn()) { iNextConnAttempt = time(NULL) + 10; return true; } + if (getMsgConn() != getDataConn()) { iNextConnAttempt = time(nullptr) + 10; return true; } // too early? - if (iNextConnAttempt && iNextConnAttempt > time(NULL)) return true; + if (iNextConnAttempt && iNextConnAttempt > time(nullptr)) return true; // find address to try int32_t iBestAddress = -1; for (int32_t i = 0; i < iAddrCnt; i++) @@ -141,9 +141,9 @@ bool C4Network2Client::DoConnectAttempt(C4Network2IO *pIO) iBestAddress = i; // too many attempts or nothing found? if (iBestAddress < 0 || AddrAttempts[iBestAddress] > C4NetClientConnectAttempts) - { iNextConnAttempt = time(NULL) + 10; return true; } + { iNextConnAttempt = time(nullptr) + 10; return true; } // save attempt - AddrAttempts[iBestAddress]++; iNextConnAttempt = time(NULL) + C4NetClientConnectInterval; + AddrAttempts[iBestAddress]++; iNextConnAttempt = time(nullptr) + C4NetClientConnectInterval; // log LogSilentF("Network: connecting client %s on %s...", getName(), Addr[iBestAddress].toString().getData()); // connect @@ -173,7 +173,7 @@ bool C4Network2Client::AddAddr(const C4Network2Address &addr, bool fAnnounce) Addr[iAddrCnt] = addr; AddrAttempts[iAddrCnt] = 0; iAddrCnt++; // attempt to use this one - if (!iNextConnAttempt) iNextConnAttempt = time(NULL); + if (!iNextConnAttempt) iNextConnAttempt = time(nullptr); // announce if (fAnnounce) if (!pParent->BroadcastMsgToConnClients(MkC4NetIOPacket(PID_Addr, C4PacketAddr(getID(), addr)))) @@ -189,7 +189,7 @@ void C4Network2Client::AddLocalAddrs(int16_t iPortTCP, int16_t iPortUDP) addr.sin_family = AF_INET; // get local address(es) - in_addr **ppAddr = NULL; + in_addr **ppAddr = nullptr; #ifdef HAVE_WINSOCK bool fGotWinSock = AcquireWinSock(); if (fGotWinSock) @@ -203,7 +203,7 @@ void C4Network2Client::AddLocalAddrs(int16_t iPortTCP, int16_t iPortUDP) if (ph) { if (ph->h_addrtype != AF_INET) - ph = NULL; + ph = nullptr; else ppAddr = reinterpret_cast(ph->h_addr_list); } @@ -212,16 +212,16 @@ void C4Network2Client::AddLocalAddrs(int16_t iPortTCP, int16_t iPortUDP) std::vector addr_vec; struct ifaddrs* addrs; getifaddrs(&addrs); - for(struct ifaddrs* addr = addrs; addr != NULL; addr = addr->ifa_next) + for(struct ifaddrs* addr = addrs; addr != nullptr; addr = addr->ifa_next) { struct sockaddr* ad = addr->ifa_addr; - if(ad == NULL) continue; + if(ad == nullptr) continue; if(ad->sa_family == AF_INET && (~addr->ifa_flags & IFF_LOOPBACK)) // Choose only non-loopback IPv4 devices addr_vec.push_back(&reinterpret_cast(ad)->sin_addr); } - addr_vec.push_back(NULL); + addr_vec.push_back(nullptr); ppAddr = &addr_vec[0]; #endif @@ -287,14 +287,14 @@ void C4Network2Client::ClearGraphs() { if (Game.pNetworkStatistics) Game.pNetworkStatistics->statPings.RemoveGraph(pstatPing); delete pstatPing; - pstatPing = NULL; + pstatPing = nullptr; } } // *** C4Network2ClientList C4Network2ClientList::C4Network2ClientList(C4Network2IO *pIO) - : pIO(pIO), pFirst(NULL), pLocal(NULL) + : pIO(pIO), pFirst(nullptr), pLocal(nullptr) { } @@ -309,13 +309,13 @@ C4Network2Client *C4Network2ClientList::GetClientByID(int32_t iID) const for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext) if (pClient->getID() == iID) return pClient; - return NULL; + return nullptr; } C4Network2Client *C4Network2ClientList::GetNextClientAfterID(int32_t iSmallerClientID) const { // return client with smallest ID > iSmallerClientID - C4Network2Client *pBest = NULL; + C4Network2Client *pBest = nullptr; for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext) if (pClient->getID() > iSmallerClientID) if (!pBest || pBest->getID() > pClient->getID()) @@ -328,7 +328,7 @@ C4Network2Client *C4Network2ClientList::GetClient(const char *szName) const for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext) if (SEqual(pClient->getName(), szName)) return pClient; - return NULL; + return nullptr; } C4Network2Client *C4Network2ClientList::GetClient(C4Network2IOConnection *pConn) const @@ -336,7 +336,7 @@ C4Network2Client *C4Network2ClientList::GetClient(C4Network2IOConnection *pConn) for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext) if (pClient->hasConn(pConn)) return pClient; - return NULL; + return nullptr; } C4Network2Client *C4Network2ClientList::GetClient(const C4ClientCore &CCore, int32_t iMaxDiffLevel) @@ -344,7 +344,7 @@ C4Network2Client *C4Network2ClientList::GetClient(const C4ClientCore &CCore, int for (C4Network2Client *pClient = pFirst; pClient; pClient = pClient->pNext) if (pClient->getCore().getDiffLevel(CCore) <= iMaxDiffLevel) return pClient; - return NULL; + return nullptr; } unsigned int C4Network2ClientList::Count() @@ -379,7 +379,7 @@ C4Network2Client *C4Network2ClientList::RegClient(C4Client *pClient) if (pClient->getNetClient()) return pClient->getNetClient(); // find insert position - C4Network2Client *pPos = pFirst, *pLast = NULL; + C4Network2Client *pPos = pFirst, *pLast = nullptr; for (; pPos; pLast = pPos, pPos = pPos->getNext()) if (pPos->getID() > pClient->getID()) break; @@ -428,7 +428,7 @@ void C4Network2ClientList::Clear() if (pClientList) { C4ClientList *poClientList = pClientList; - pClientList = NULL; + pClientList = nullptr; poClientList->ClearNetwork(); } // delete clients @@ -436,7 +436,7 @@ void C4Network2ClientList::Clear() { DeleteClient(pFirst); } - pLocal = NULL; + pLocal = nullptr; } bool C4Network2ClientList::BroadcastMsgToConnClients(const C4NetIOPacket &rPkt) diff --git a/src/network/C4Network2Dialogs.cpp b/src/network/C4Network2Dialogs.cpp index fd1080e33..ffe3d7827 100644 --- a/src/network/C4Network2Dialogs.cpp +++ b/src/network/C4Network2Dialogs.cpp @@ -60,7 +60,7 @@ void C4Network2ClientDlg::UpdateText() } else { - // get client (may be NULL for local info) + // get client (may be nullptr for local info) C4Network2Client *pNetClient = pClient->getNetClient(); // show some info StdCopyStrBuf strInfo; @@ -119,7 +119,7 @@ void C4Network2ClientDlg::UpdateText() // C4Network2ClientListBox::ClientListItem C4Network2ClientListBox::ClientListItem::ClientListItem(class C4Network2ClientListBox *pForDlg, int iClientID) // ctor - : ListItem(pForDlg, iClientID), pStatusIcon(NULL), pName(NULL), pPing(NULL), pActivateBtn(NULL), pKickBtn(NULL), last_sound_time(0) + : ListItem(pForDlg, iClientID), pStatusIcon(nullptr), pName(nullptr), pPing(nullptr), pActivateBtn(nullptr), pKickBtn(nullptr), last_sound_time(0) { // get associated client const C4Client *pClient = GetClient(); @@ -234,7 +234,7 @@ void C4Network2ClientListBox::ClientListItem::Update() // sound icon? if (last_sound_time) { - time_t dt = time(NULL) - last_sound_time; + time_t dt = time(nullptr) - last_sound_time; if (dt >= SoundIconShowTime) { // stop showing sound icon @@ -277,7 +277,7 @@ C4Network2ClientListBox::ClientListItem *C4Network2ClientListBox::GetClientListI return static_cast(list_item2); } // nothing found - return NULL; + return nullptr; } void C4Network2ClientListBox::ClientListItem::OnButtonActivate(C4GUI::Control *pButton) @@ -305,7 +305,7 @@ void C4Network2ClientListBox::ClientListItem::OnButtonKick(C4GUI::Control *pButt void C4Network2ClientListBox::ClientListItem::SetSoundIcon() { // remember time for reset - last_sound_time = time(NULL); + last_sound_time = time(nullptr); // force icon Update(); } @@ -315,7 +315,7 @@ void C4Network2ClientListBox::ClientListItem::SetSoundIcon() // C4Network2ClientListBox::ConnectionListItem C4Network2ClientListBox::ConnectionListItem::ConnectionListItem(class C4Network2ClientListBox *pForDlg, int32_t iClientID, int32_t iConnectionID) // ctor - : ListItem(pForDlg, iClientID), iConnID(iConnectionID), pDesc(NULL), pPing(NULL), pReconnectBtn(NULL), pDisconnectBtn(NULL) + : ListItem(pForDlg, iClientID), iConnID(iConnectionID), pDesc(nullptr), pPing(nullptr), pReconnectBtn(nullptr), pDisconnectBtn(nullptr) { // get size CStdFont &rUseFont = ::GraphicsResource.TextFont; @@ -334,7 +334,7 @@ C4Network2ClientListBox::ConnectionListItem::ConnectionListItem(class C4Network2 pDisconnectBtn->SetToolTip(LoadResStr("IDS_MENU_DISCONNECT")); } else - pDisconnectBtn = NULL; + pDisconnectBtn = nullptr; // ping time int32_t sx=40, sy=iIconSize; rUseFont.GetTextExtent("???? ms", sx,sy, true); @@ -356,10 +356,10 @@ C4Network2IOConnection *C4Network2ClientListBox::ConnectionListItem::GetConnecti { // get connection by connection ID C4Network2Client *pNetClient = ::Network.Clients.GetClientByID(iClientID); - if (!pNetClient) return NULL; + if (!pNetClient) return nullptr; if (iConnID == 0) return pNetClient->getDataConn(); if (iConnID == 1) return pNetClient->getMsgConn(); - return NULL; + return nullptr; } void C4Network2ClientListBox::ConnectionListItem::Update() @@ -430,7 +430,7 @@ void C4Network2ClientListBox::Update() { // sync with client list ListItem *pItem = static_cast(pClientWindow->GetFirst()), *pNext; - const C4Client *pClient = NULL; + const C4Client *pClient = nullptr; while ((pClient = Game.Clients.getClient(pClient))) { // skip host in startup board @@ -449,7 +449,7 @@ void C4Network2ClientListBox::Update() pItem = static_cast(pItem->GetNext()); } else - // not present: insert (or add if pItem=NULL) + // not present: insert (or add if pItem=nullptr) InsertElement(new ClientListItem(this, pClient->getID()), pItem); // update connections for client // but no connections in startup board @@ -457,7 +457,7 @@ void C4Network2ClientListBox::Update() // enumerate client connections C4Network2Client *pNetClient = pClient->getNetClient(); if (!pNetClient) continue; // local client does not have connections - C4Network2IOConnection *pLastConn = NULL; + C4Network2IOConnection *pLastConn = nullptr; for (int i = 0; i<2; ++i) { C4Network2IOConnection *pConn = i ? pNetClient->getMsgConn() : pNetClient->getDataConn(); @@ -503,7 +503,7 @@ void C4Network2ClientListBox::SetClientSoundIcon(int32_t client_id) // C4Network2ClientListDlg // singleton -C4Network2ClientListDlg *C4Network2ClientListDlg::pInstance = NULL; +C4Network2ClientListDlg *C4Network2ClientListDlg::pInstance = nullptr; C4Network2ClientListDlg::C4Network2ClientListDlg() : Dialog(::pGUI->GetPreferredDlgRect().Wdt*3/4, ::pGUI->GetPreferredDlgRect().Hgt*3/4, LoadResStr("IDS_NET_CAPTION"), false) @@ -514,7 +514,7 @@ C4Network2ClientListDlg::C4Network2ClientListDlg() C4Rect rcStatus = caAll.GetFromBottom(pUseFont->GetLineHeight()); // create game options; max 1/2 of dialog height pGameOptions = new C4GameOptionsList(caAll.GetFromTop(caAll.GetInnerHeight()/2), true, C4GameOptionsList::GOLS_Runtime); - pGameOptions->SetDecoration(false, NULL, true, false); + pGameOptions->SetDecoration(false, nullptr, true, false); pGameOptions->SetSelectionDiabled(); // but resize to actually used height int32_t iFreedHeight = pGameOptions->ContractToElementHeight(); @@ -532,7 +532,7 @@ C4Network2ClientListDlg::C4Network2ClientListDlg() C4Network2ClientListDlg::~C4Network2ClientListDlg() { - if (this==pInstance) pInstance=NULL; Application.Remove(this); + if (this==pInstance) pInstance=nullptr; Application.Remove(this); } void C4Network2ClientListDlg::Update() @@ -565,7 +565,7 @@ void C4Network2ClientListDlg::OnSound(class C4Client *singer) // C4Network2StartWaitDlg C4Network2StartWaitDlg::C4Network2StartWaitDlg() - : C4GUI::Dialog(DialogWidth, DialogHeight, LoadResStr("IDS_NET_CAPTION"), false), pClientListBox(NULL) + : C4GUI::Dialog(DialogWidth, DialogHeight, LoadResStr("IDS_NET_CAPTION"), false), pClientListBox(nullptr) { C4GUI::ComponentAligner caAll(GetContainedClientRect(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent); C4GUI::ComponentAligner caButtonArea(caAll.GetFromBottom(C4GUI_ButtonAreaHgt), 0,0); @@ -619,7 +619,7 @@ C4GameOptionButtons::C4GameOptionButtons(const C4Rect &rcBounds, bool fNetwork, btnInternet->SetEnabled(!fIsDisabled); AddElement(btnInternet); } - else btnInternet = NULL; + else btnInternet = nullptr; bool fIsLeague = false; // League button if (fNetwork) @@ -631,7 +631,7 @@ C4GameOptionButtons::C4GameOptionButtons(const C4Rect &rcBounds, bool fNetwork, btnLeague->SetEnabled(fHost && !fLobby); AddElement(btnLeague); } - else btnLeague=NULL; + else btnLeague=nullptr; if (fNetwork && fHost) { btnPassword = new C4GUI::CallbackButton(::Network.isPassworded() ? C4GUI::Ico_Ex_Locked : C4GUI::Ico_Ex_Unlocked, caButtons.GetFromLeft(iIconSize, iIconSize), LoadResStr("IDS_NET_PASSWORD_DESC"), &C4GameOptionButtons::OnBtnPassword, this); @@ -639,7 +639,7 @@ C4GameOptionButtons::C4GameOptionButtons(const C4Rect &rcBounds, bool fNetwork, btnComment = new C4GUI::CallbackButton(C4GUI::Ico_Ex_Comment, caButtons.GetFromLeft(iIconSize, iIconSize), LoadResStr("IDS_DESC_COMMENTDESCRIPTIONFORTHIS"), &C4GameOptionButtons::OnBtnComment, this); AddElement(btnComment); } - else btnPassword=btnComment=NULL; + else btnPassword=btnComment=nullptr; btnRecord = new C4GUI::CallbackButton(Game.Record || fIsLeague ? C4GUI::Ico_Ex_RecordOn : C4GUI::Ico_Ex_RecordOff, caButtons.GetFromLeft(iIconSize, iIconSize), LoadResStr("IDS_DLGTIP_RECORD"), &C4GameOptionButtons::OnBtnRecord, this); btnRecord->SetEnabled(!fIsLeague); AddElement(btnRecord); @@ -904,7 +904,7 @@ void C4Chart::DrawElement(C4TargetFacet &cgo) } } -C4Chart::C4Chart(C4Rect &rcBounds) : Element(), pDisplayGraph(NULL), fOwnGraph(false) +C4Chart::C4Chart(C4Rect &rcBounds) : Element(), pDisplayGraph(nullptr), fOwnGraph(false) { this->rcBounds = rcBounds; } @@ -916,9 +916,9 @@ C4Chart::~C4Chart() // singleton -C4ChartDialog *C4ChartDialog::pChartDlg=NULL; +C4ChartDialog *C4ChartDialog::pChartDlg=nullptr; -C4ChartDialog::C4ChartDialog() : Dialog(DialogWidth, DialogHeight, LoadResStr("IDS_NET_STATISTICS"), false), pChartTabular(NULL) +C4ChartDialog::C4ChartDialog() : Dialog(DialogWidth, DialogHeight, LoadResStr("IDS_NET_STATISTICS"), false), pChartTabular(nullptr) { // register singleton pChartDlg = this; diff --git a/src/network/C4Network2Dialogs.h b/src/network/C4Network2Dialogs.h index 39475a5a3..5bb683c24 100644 --- a/src/network/C4Network2Dialogs.h +++ b/src/network/C4Network2Dialogs.h @@ -273,7 +273,7 @@ public: C4ChartDialog(); // singleton-stuff - ~C4ChartDialog() { if (pChartDlg==this) pChartDlg = NULL; } + ~C4ChartDialog() { if (pChartDlg==this) pChartDlg = nullptr; } static void Toggle(); }; diff --git a/src/network/C4Network2IO.cpp b/src/network/C4Network2IO.cpp index 08531cf4c..5598a77e2 100644 --- a/src/network/C4Network2IO.cpp +++ b/src/network/C4Network2IO.cpp @@ -44,13 +44,13 @@ struct C4Network2IO::NetEvPacketData // *** C4Network2IO C4Network2IO::C4Network2IO() - : pNetIO_TCP(NULL), pNetIO_UDP(NULL), - pNetIODiscover(NULL), pRefServer(NULL), - UPnPMgr(NULL), - pConnList(NULL), + : pNetIO_TCP(nullptr), pNetIO_UDP(nullptr), + pNetIODiscover(nullptr), pRefServer(nullptr), + UPnPMgr(nullptr), + pConnList(nullptr), iNextConnID(0), fAllowConnect(false), - pAutoAcceptList(NULL), + pAutoAcceptList(nullptr), fExclusiveConn(false), tLastExecute(0), tLastPing(0), tLastStatistic(0), iTCPIRate(0), iTCPORate(0), iTCPBCRate(0), @@ -96,7 +96,7 @@ bool C4Network2IO::Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscove if (!pNetIO_TCP->Init(iPortTCP)) { LogF("Network: could not init TCP i/o (%s)", pNetIO_TCP->GetError() ? pNetIO_TCP->GetError() : ""); - delete pNetIO_TCP; pNetIO_TCP = NULL; + delete pNetIO_TCP; pNetIO_TCP = nullptr; } else LogSilentF("Network: TCP initialized on port %d", iPortTCP); @@ -119,7 +119,7 @@ bool C4Network2IO::Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscove if (!pNetIO_UDP->Init(iPortUDP)) { LogF("Network: could not init UDP i/o (%s)", pNetIO_UDP->GetError() ? pNetIO_UDP->GetError() : ""); - delete pNetIO_UDP; pNetIO_UDP = NULL; + delete pNetIO_UDP; pNetIO_UDP = nullptr; } else LogSilentF("Network: UDP initialized on port %d", iPortUDP); @@ -153,7 +153,7 @@ bool C4Network2IO::Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscove if (!pNetIODiscover->Init(iPortDiscover)) { LogF("Network: could not init discovery (%s)", pNetIODiscover->GetError() ? pNetIODiscover->GetError() : ""); - delete pNetIODiscover; pNetIODiscover = NULL; + delete pNetIODiscover; pNetIODiscover = nullptr; } else LogSilentF("Network: discovery initialized on port %d", iPortDiscover); @@ -171,7 +171,7 @@ bool C4Network2IO::Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscove if (!pRefServer->Init(iPortRefServer)) { LogF("Network: could not init reference server (%s)", pNetIO_UDP->GetError() ? pNetIO_UDP->GetError() : ""); - delete pRefServer; pRefServer = NULL; + delete pRefServer; pRefServer = nullptr; } else LogSilentF("Network: reference server initialized on port %d", iPortRefServer); @@ -207,15 +207,15 @@ void C4Network2IO::Clear() // by main thread RemoveConnection(pConn); } // reset list - pConnList = NULL; + pConnList = nullptr; ConnListLock.Clear(); // close net i/o classes Thread.RemoveProc(this); - if (pNetIODiscover) { Thread.RemoveProc(pNetIODiscover); delete pNetIODiscover; pNetIODiscover = NULL; } - if (pNetIO_TCP) { Thread.RemoveProc(pNetIO_TCP); delete pNetIO_TCP; pNetIO_TCP = NULL; } - if (pNetIO_UDP) { Thread.RemoveProc(pNetIO_UDP); delete pNetIO_UDP; pNetIO_UDP = NULL; } - if (pRefServer) { Thread.RemoveProc(pRefServer); delete pRefServer; pRefServer = NULL; } - if (UPnPMgr) { delete UPnPMgr; UPnPMgr = NULL; } + if (pNetIODiscover) { Thread.RemoveProc(pNetIODiscover); delete pNetIODiscover; pNetIODiscover = nullptr; } + if (pNetIO_TCP) { Thread.RemoveProc(pNetIO_TCP); delete pNetIO_TCP; pNetIO_TCP = nullptr; } + if (pNetIO_UDP) { Thread.RemoveProc(pNetIO_UDP); delete pNetIO_UDP; pNetIO_UDP = nullptr; } + if (pRefServer) { Thread.RemoveProc(pRefServer); delete pRefServer; pRefServer = nullptr; } + if (UPnPMgr) { delete UPnPMgr; UPnPMgr = nullptr; } // remove auto-accepts ClearAutoAccept(); // reset flags @@ -234,14 +234,14 @@ C4NetIO *C4Network2IO::MsgIO() // by both { if (pNetIO_UDP) return pNetIO_UDP; if (pNetIO_TCP) return pNetIO_TCP; - return NULL; + return nullptr; } C4NetIO *C4Network2IO::DataIO() // by both { if (pNetIO_TCP) return pNetIO_TCP; if (pNetIO_UDP) return pNetIO_UDP; - return NULL; + return nullptr; } bool C4Network2IO::Connect(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, const char *szPassword) // by main thread @@ -338,7 +338,7 @@ void C4Network2IO::RemoveAutoAccept(const C4ClientCore &CCore) // by main thread { CStdLock AALock(&AutoAcceptCSec); // find & remove - AutoAccept *pAcc = pAutoAcceptList, *pLast = NULL; + AutoAccept *pAcc = pAutoAcceptList, *pLast = nullptr; while (pAcc) if (pAcc->CCore.getDiffLevel(CCore) <= C4ClientCoreDL_IDMatch) { @@ -360,7 +360,7 @@ void C4Network2IO::RemoveAutoAccept(const C4ClientCore &CCore) // by main thread C4Network2IOConnection *C4Network2IO::GetMsgConnection(int iClientID) // by main thread { CStdLock ConnListLock(&ConnListCSec); - C4Network2IOConnection *pRes = NULL; + C4Network2IOConnection *pRes = nullptr; for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext) if (pConn->isAccepted()) if (pConn->getClientID() == iClientID) @@ -374,7 +374,7 @@ C4Network2IOConnection *C4Network2IO::GetMsgConnection(int iClientID) // by main C4Network2IOConnection *C4Network2IO::GetDataConnection(int iClientID) // by main thread { CStdLock ConnListLock(&ConnListCSec); - C4Network2IOConnection *pRes = NULL; + C4Network2IOConnection *pRes = nullptr; for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext) if (pConn->isAccepted()) if (pConn->getClientID() == iClientID) @@ -496,7 +496,7 @@ bool C4Network2IO::OnConn(const C4NetIO::addr_t &PeerAddr, const C4NetIO::addr_t getNetIOName(pNetIO)); #endif // search connection - C4Network2IOConnection *pConn = NULL; + C4Network2IOConnection *pConn = nullptr; if (ConnectAddr.sin_addr.s_addr) pConn = GetConnectionByConnAddr(ConnectAddr, pNetIO); // not found? @@ -507,7 +507,7 @@ bool C4Network2IO::OnConn(const C4NetIO::addr_t &PeerAddr, const C4NetIO::addr_t // create new connection object uint32_t iConnID = iNextConnID++; pConn = new C4Network2IOConnection(); - pConn->Set(pNetIO, getNetIOProt(pNetIO), PeerAddr, ConnectAddr, CS_Connected, NULL, iConnID); + pConn->Set(pNetIO, getNetIOProt(pNetIO), PeerAddr, ConnectAddr, CS_Connected, nullptr, iConnID); // add to list AddConnection(pConn); } @@ -693,13 +693,13 @@ C4NetIO *C4Network2IO::getNetIO(C4Network2IOProtocol eProt) // by both { case P_UDP: return pNetIO_UDP; case P_TCP: return pNetIO_TCP; - default: return NULL; + default: return nullptr; } } const char *C4Network2IO::getNetIOName(C4NetIO *pNetIO) { - if (!pNetIO) return "NULL"; + if (!pNetIO) return "nullptr"; if (pNetIO == pNetIO_TCP) return "TCP"; if (pNetIO == pNetIO_UDP) return "UDP"; return "UNKNOWN"; @@ -740,7 +740,7 @@ void C4Network2IO::RemoveConnection(C4Network2IOConnection *pConn) // by both return; } // remove reference - pConn->pNext = NULL; pConn->DelRef(); + pConn->pNext = nullptr; pConn->DelRef(); } C4Network2IOConnection *C4Network2IO::GetConnection(const C4NetIO::addr_t &addr, C4NetIO *pNetIO) // by both @@ -750,7 +750,7 @@ C4Network2IOConnection *C4Network2IO::GetConnection(const C4NetIO::addr_t &addr, for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext) if (pConn->getNetClass() == pNetIO && AddrEqual(pConn->getPeerAddr(), addr)) return pConn; - return NULL; + return nullptr; } C4Network2IOConnection *C4Network2IO::GetConnectionByConnAddr(const C4NetIO::addr_t &addr, C4NetIO *pNetIO) // by both @@ -760,7 +760,7 @@ C4Network2IOConnection *C4Network2IO::GetConnectionByConnAddr(const C4NetIO::add for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext) if (pConn->getNetClass() == pNetIO && AddrEqual(pConn->getConnectAddr(), addr)) return pConn; - return NULL; + return nullptr; } C4Network2IOConnection *C4Network2IO::GetConnectionByID(uint32_t iConnID) // by thread @@ -770,7 +770,7 @@ C4Network2IOConnection *C4Network2IO::GetConnectionByID(uint32_t iConnID) // by for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext) if (pConn->getID() == iConnID) return pConn; - return NULL; + return nullptr; } void C4Network2IO::SetReference(C4Network2Reference *pReference) @@ -1170,23 +1170,23 @@ void C4Network2IO::CheckTimeout() pNext = pConn->pNext; // status timeout if (!pConn->isClosed() && !pConn->isAccepted()) - if (difftime(time(NULL), pConn->getTimestamp()) > C4NetAcceptTimeout) + if (difftime(time(nullptr), pConn->getTimestamp()) > C4NetAcceptTimeout) { Application.InteractiveThread.ThreadLogS("Network: connection accept timeout to %s:%d", inet_ntoa(pConn->getPeerAddr().sin_addr), htons(pConn->getPeerAddr().sin_port)); pConn->Close(); } // ping timeout if (pConn->isAccepted()) - if ((pConn->getLag() != -1 ? pConn->getLag() : 1000 * difftime(time(NULL), pConn->getTimestamp())) + if ((pConn->getLag() != -1 ? pConn->getLag() : 1000 * difftime(time(nullptr), pConn->getTimestamp())) > C4NetPingTimeout) { - Application.InteractiveThread.ThreadLogS("%d %d %d", (int)pConn->getLag(), (int)time(NULL), (int)pConn->getTimestamp()); + Application.InteractiveThread.ThreadLogS("%d %d %d", (int)pConn->getLag(), (int)time(nullptr), (int)pConn->getTimestamp()); Application.InteractiveThread.ThreadLogS("Network: ping timeout to %s:%d", inet_ntoa(pConn->getPeerAddr().sin_addr), htons(pConn->getPeerAddr().sin_port)); pConn->Close(); } // delayed connection removal if (pConn->isClosed()) - if (difftime(time(NULL), pConn->getTimestamp()) > C4NetAcceptTimeout) + if (difftime(time(nullptr), pConn->getTimestamp()) > C4NetAcceptTimeout) RemoveConnection(pConn); } } @@ -1283,7 +1283,7 @@ void C4Network2IO::OnPuncherConnect(C4NetIO::addr_t addr) // *** C4Network2IOConnection C4Network2IOConnection::C4Network2IOConnection() - : pNetClass(NULL), + : pNetClass(nullptr), iID(~0), iRemoteID(~0), fAutoAccept(false), fBroadcastTarget(false), @@ -1294,8 +1294,8 @@ C4Network2IOConnection::C4Network2IOConnection() fConnSent(false), fPostMortemSent(false), iOutPacketCounter(0), iInPacketCounter(0), - pPacketLog(NULL), - pNext(NULL), + pPacketLog(nullptr), + pNext(nullptr), iRefCnt(0) { } @@ -1336,7 +1336,7 @@ void C4Network2IOConnection::Set(C4NetIO *pnNetClass, C4Network2IOProtocol enPro iID = inID; // initialize fBroadcastTarget = false; - iTimestamp = time(NULL); iPingTime = -1; + iTimestamp = time(nullptr); iPingTime = -1; } void C4Network2IOConnection::SetRemoteID(uint32_t inRemoteID) @@ -1378,7 +1378,7 @@ void C4Network2IOConnection::SetStatus(C4Network2IOConnStatus nStatus) Status = nStatus; // reset timestamp for connect/accept/close if (Status == CS_Connect || Status == CS_Connected || Status == CS_Accepted || Status == CS_Closed) - iTimestamp = time(NULL); + iTimestamp = time(nullptr); } } @@ -1397,14 +1397,14 @@ void C4Network2IOConnection::OnPacketReceived(uint8_t iPacketType) void C4Network2IOConnection::ClearPacketLog(uint32_t iUntilID) { // Search position of first packet to delete - PacketLogEntry *pPos, *pPrev = NULL; + PacketLogEntry *pPos, *pPrev = nullptr; for (pPos = pPacketLog; pPos; pPrev = pPos, pPos = pPos->Next) if (pPos->Number < iUntilID) break; if (pPos) { // Remove packets from list - (pPrev ? pPrev->Next : pPacketLog) = NULL; + (pPrev ? pPrev->Next : pPacketLog) = nullptr; // Delete everything while (pPos) { @@ -1545,7 +1545,7 @@ C4PacketPostMortem::C4PacketPostMortem() : iConnID(~0), iPacketCounter(~0), iPacketCount(0), - pPackets(NULL) + pPackets(nullptr) { } @@ -1565,7 +1565,7 @@ const C4NetIOPacket *C4PacketPostMortem::getPacket(uint32_t iNumber) const { // Security if (!Inside(iNumber, iPacketCounter - iPacketCount, iPacketCounter - 1)) - return NULL; + return nullptr; // Calculate position in list iNumber = iNumber + iPacketCount - iPacketCounter; // Search for the packet with the given number @@ -1573,7 +1573,7 @@ const C4NetIOPacket *C4PacketPostMortem::getPacket(uint32_t iNumber) const for (; pLink && iNumber; iNumber--) pLink = pLink->Next; // Not found? - return pLink ? &pLink->Pkt : NULL; + return pLink ? &pLink->Pkt : nullptr; } void C4PacketPostMortem::SetPacketCounter(uint32_t inPacketCounter) @@ -1615,7 +1615,7 @@ void C4PacketPostMortem::CompileFunc(StdCompiler *pComp) } // Reverse order PacketLink *pPackets2 = pPackets; - pPackets = NULL; + pPackets = nullptr; while (pPackets2) { // Get link diff --git a/src/network/C4Network2IO.h b/src/network/C4Network2IO.h index 5cdc59bfb..dba3126d7 100644 --- a/src/network/C4Network2IO.h +++ b/src/network/C4Network2IO.h @@ -114,7 +114,7 @@ public: C4NetIO *DataIO(); // by both // connections - bool Connect(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, const char *szPassword = NULL); // by main thread + bool Connect(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, const char *szPassword = nullptr); // by main thread void SetAcceptMode(bool fAcceptAll); // by main thread void SetExclusiveConnMode(bool fExclusiveConn); // by main thread int getConnectionCount(); // by main thread @@ -231,8 +231,8 @@ protected: bool fBroadcastTarget; // broadcast target? time_t iTimestamp; // timestamp of last status change int iPingTime; // ping - C4TimeMilliseconds tLastPing; // if > iLastPong, it's the first ping that hasn't been answered yet, NULL if no ping received yet - C4TimeMilliseconds tLastPong; // last pong received, NULL if no pong received yet + C4TimeMilliseconds tLastPing; // if > iLastPong, it's the first ping that hasn't been answered yet, nullptr if no ping received yet + C4TimeMilliseconds tLastPong; // last pong received, nullptr if no pong received yet C4ClientCore CCore; // client core (>= CS_HalfAccepted) CStdCSec CCoreCSec; int iIRate, iORate; // input/output rates (by C4NetIO, in b/s) @@ -349,7 +349,7 @@ class C4PacketConn : public C4PacketBase { public: C4PacketConn(); - C4PacketConn(const class C4ClientCore &nCCore, uint32_t iConnID, const char *szPassword = NULL); + C4PacketConn(const class C4ClientCore &nCCore, uint32_t iConnID, const char *szPassword = nullptr); protected: int32_t iVer; @@ -370,7 +370,7 @@ class C4PacketConnRe : public C4PacketBase { public: C4PacketConnRe(); - C4PacketConnRe(bool fOK, bool fWrongPassword, const char *szMsg = NULL); + C4PacketConnRe(bool fOK, bool fWrongPassword, const char *szMsg = nullptr); protected: bool fOK, fWrongPassword; diff --git a/src/network/C4Network2IRC.cpp b/src/network/C4Network2IRC.cpp index aa4266eef..36a2610ac 100644 --- a/src/network/C4Network2IRC.cpp +++ b/src/network/C4Network2IRC.cpp @@ -37,7 +37,7 @@ StdStrBuf ircExtractPar(const char **ppPar) { // Reference everything after the double-colon Result.Ref(*ppPar + 1); - *ppPar = NULL; + *ppPar = nullptr; } else { @@ -48,7 +48,7 @@ StdStrBuf ircExtractPar(const char **ppPar) if (**ppPar == ' ') (*ppPar)++; else - *ppPar = NULL; + *ppPar = nullptr; } // Done return Result; @@ -65,7 +65,7 @@ C4Network2IRCUser::C4Network2IRCUser(const char *szName) // *** C4Network2IRCChannel C4Network2IRCChannel::C4Network2IRCChannel(const char *szName) - : Name(szName), pUsers(NULL), fReceivingUsers(false) + : Name(szName), pUsers(nullptr), fReceivingUsers(false) { } @@ -80,7 +80,7 @@ C4Network2IRCUser *C4Network2IRCChannel::getUser(const char *szName) const for (C4Network2IRCUser *pUser = pUsers; pUser; pUser = pUser->Next) if (SEqual(pUser->getName(), szName)) return pUser; - return NULL; + return nullptr; } void C4Network2IRCChannel::OnUsers(const char *szUsers, const char *szPrefixes) @@ -182,9 +182,9 @@ void C4Network2IRCChannel::ClearUsers() C4Network2IRCClient::C4Network2IRCClient() : fConnecting(false), fConnected(false), - pChannels(NULL), - pLog(NULL), pLogEnd(NULL), iLogLength(0), iUnreadLogLength(0), - pNotify(NULL) + pChannels(nullptr), + pLog(nullptr), pLogEnd(nullptr), iLogLength(0), iUnreadLogLength(0), + pNotify(nullptr) { } @@ -288,7 +288,7 @@ C4Network2IRCChannel *C4Network2IRCClient::getChannel(const char *szName) const for (C4Network2IRCChannel *pChan = pChannels; pChan; pChan = pChan->Next) if (SEqualNoCase(pChan->getName(), szName)) return pChan; - return NULL; + return nullptr; } void C4Network2IRCClient::ClearMessageLog() @@ -684,7 +684,7 @@ void C4Network2IRCClient::OnNumericCommand(const char *szSender, int iCommand, c if (fShowMessage) { // Check if first parameter is some sort of channel name - C4Network2IRCChannel *pChannel = NULL; + C4Network2IRCChannel *pChannel = nullptr; if (szParameters && *szParameters && *szParameters != ':') pChannel = getChannel(ircExtractPar(&szParameters).getData()); // Go over other parameters @@ -769,8 +769,8 @@ void C4Network2IRCClient::PopMessage() // Unlink message C4Network2IRCMessage *pMsg = pLog; pLog = pMsg->Next; - if (!pLog) pLogEnd = NULL; - if (pLogLastRead == pMsg) pLogLastRead = NULL; + if (!pLog) pLogEnd = nullptr; + if (pLogLastRead == pMsg) pLogLastRead = nullptr; // Delete it delete pMsg; iLogLength--; diff --git a/src/network/C4Network2IRC.h b/src/network/C4Network2IRC.h index 9b8ef4b4a..5e9afdac5 100644 --- a/src/network/C4Network2IRC.h +++ b/src/network/C4Network2IRC.h @@ -36,7 +36,7 @@ class C4Network2IRCMessage friend class C4Network2IRCClient; public: C4Network2IRCMessage(C4Network2IRCMessageType enType, const char *szSource, const char *szTarget, const char *szData) - : iTimestamp(time(NULL)), eType(enType), Source(szSource), Target(szTarget), Data(szData), Next(0) + : iTimestamp(time(nullptr)), eType(enType), Source(szSource), Target(szTarget), Data(szData), Next(0) { } private: @@ -177,11 +177,11 @@ public: using C4NetIOTCP::Connect; // Simple network communication - bool Connect(const char *szServer, const char *szNick, const char *szRealName, const char *szPassword = NULL, const char *szChannel = NULL); + bool Connect(const char *szServer, const char *szNick, const char *szRealName, const char *szPassword = nullptr, const char *szChannel = nullptr); using C4NetIOTCP::Close; bool Close(); using C4NetIOTCP::Send; - bool Send(const char *szCommand, const char *szParameters = NULL); + bool Send(const char *szCommand, const char *szParameters = nullptr); // Notfiy interface void SetNotify(class C4InteractiveThread *pnNotify) { pNotify = pnNotify; } diff --git a/src/network/C4Network2Players.cpp b/src/network/C4Network2Players.cpp index 2f4d4fbf4..b061173ec 100644 --- a/src/network/C4Network2Players.cpp +++ b/src/network/C4Network2Players.cpp @@ -237,7 +237,7 @@ void C4Network2Players::HandlePlayerInfo(const class C4ClientPlayerInfos &rInfoP Game.Teams.RecheckTeams(); // recheck random teams - if a player left, teams may need to be rebalanced // make sure resources are loaded for those players rInfoList.LoadResources(); - // get associated client - note that pClientInfo might be NULL for empty packets that got discarded + // get associated client - note that pClientInfo might be nullptr for empty packets that got discarded if (pClientInfo) { const C4Client *pClient = Game.Clients.getClientByID(pClientInfo->GetClientID()); @@ -363,7 +363,7 @@ void C4Network2Players::JoinUnjoinedPlayersInControlQueue(C4ClientPlayerInfos *p { // join without resource (script player) Game.Input.Add(CID_JoinPlr, - new C4ControlJoinPlayer(NULL, pNewPacket->GetClientID(), pInfo->GetID())); + new C4ControlJoinPlayer(nullptr, pNewPacket->GetClientID(), pInfo->GetID())); } } } @@ -472,7 +472,7 @@ C4ClientPlayerInfos *C4Network2Players::GetLocalPlayerInfoPacket() const // found return pkInfo; // not found - return NULL; + return nullptr; } C4ClientPlayerInfos *C4Network2Players::GetIndexedPlayerInfoPacket(int iIndex) diff --git a/src/network/C4Network2Reference.cpp b/src/network/C4Network2Reference.cpp index 0c3d30d01..fbebd9e97 100644 --- a/src/network/C4Network2Reference.cpp +++ b/src/network/C4Network2Reference.cpp @@ -169,7 +169,7 @@ StdStrBuf C4Network2Reference::getGameGoalString() const // *** C4Network2RefServer C4Network2RefServer::C4Network2RefServer() - : pReference(NULL) + : pReference(nullptr) { } @@ -181,7 +181,7 @@ C4Network2RefServer::~C4Network2RefServer() void C4Network2RefServer::Clear() { C4NetIOTCP::Close(); - delete pReference; pReference = NULL; + delete pReference; pReference = nullptr; } void C4Network2RefServer::SetReference(C4Network2Reference *pNewReference) @@ -248,7 +248,7 @@ void C4Network2RefServer::RespondReference(const C4NetIO::addr_t &addr) C4Network2HTTPClient::C4Network2HTTPClient() : fBinary(false), fBusy(false), fSuccess(false), fConnected(false), iDataOffset(0), iDownloadedSize(0), iTotalSize(0), - pNotify(NULL) + pNotify(nullptr) { C4NetIOTCP::SetCallback(this); } @@ -442,7 +442,7 @@ void C4Network2HTTPClient::OnPacket(const class C4NetIOPacket &rPacket, C4NetIO bool C4Network2HTTPClient::Execute(int iMaxTime) { // Check timeout - if (fBusy && time(NULL) > iRequestTimeout) + if (fBusy && time(nullptr) > iRequestTimeout) { Cancel("Request timeout"); return true; @@ -457,7 +457,7 @@ C4TimeMilliseconds C4Network2HTTPClient::GetNextTick(C4TimeMilliseconds tNow) if (!fBusy) return tNetIOTCPTick; - C4TimeMilliseconds tHTTPClientTick = tNow + 1000 * std::max(iRequestTimeout - time(NULL), 0); + C4TimeMilliseconds tHTTPClientTick = tNow + 1000 * std::max(iRequestTimeout - time(nullptr), 0); return std::max(tNetIOTCPTick, tHTTPClientTick); } @@ -520,7 +520,7 @@ bool C4Network2HTTPClient::Query(const StdBuf &Data, bool fBinary) void C4Network2HTTPClient::ResetRequestTimeout() { // timeout C4Network2HTTPQueryTimeout seconds from this point - iRequestTimeout = time(NULL) + C4Network2HTTPQueryTimeout; + iRequestTimeout = time(nullptr) + C4Network2HTTPQueryTimeout; } void C4Network2HTTPClient::Cancel(const char *szReason) @@ -576,7 +576,7 @@ bool C4Network2HTTPClient::SetServer(const char *szServerAddress) bool C4Network2UpdateClient::QueryUpdateURL() { // Perform an Query query - return Query(NULL, false); + return Query(nullptr, false); } bool C4Network2UpdateClient::GetUpdateURL(StdStrBuf *pUpdateURL) @@ -624,7 +624,7 @@ bool C4Network2UpdateClient::GetVersion(StdStrBuf *pVersion) bool C4Network2RefClient::QueryReferences() { // Perform an Query query - return Query(NULL, false); + return Query(nullptr, false); } bool C4Network2RefClient::GetReferences(C4Network2Reference **&rpReferences, int32_t &rRefCount) @@ -643,7 +643,7 @@ bool C4Network2RefClient::GetReferences(C4Network2Reference **&rpReferences, int // Create reference array and initialize rpReferences = new C4Network2Reference *[rRefCount]; for (int i = 0; i < rRefCount; i++) - rpReferences[i] = NULL; + rpReferences[i] = nullptr; // Get references Comp.Value(mkNamingAdapt(mkArrayAdaptMap(rpReferences, rRefCount, mkPtrAdaptNoNull), "Reference")); mkPtrAdaptNoNull(*rpReferences); diff --git a/src/network/C4Network2Res.cpp b/src/network/C4Network2Res.cpp index 49b58f64c..0b1b72920 100644 --- a/src/network/C4Network2Res.cpp +++ b/src/network/C4Network2Res.cpp @@ -138,7 +138,7 @@ void C4Network2ResCore::CompileFunc(StdCompiler *pComp) // *** C4Network2ResLoad C4Network2ResLoad::C4Network2ResLoad(int32_t inChunk, int32_t inByClient) - : iChunk(inChunk), Timestamp(time(NULL)), iByClient(inByClient), pNext(NULL) + : iChunk(inChunk), Timestamp(time(nullptr)), iByClient(inByClient), pNext(nullptr) { } @@ -150,14 +150,14 @@ C4Network2ResLoad::~C4Network2ResLoad() bool C4Network2ResLoad::CheckTimeout() { - return difftime(time(NULL), Timestamp) >= C4NetResLoadTimeout; + return difftime(time(nullptr), Timestamp) >= C4NetResLoadTimeout; } // *** C4Network2ResChunkData C4Network2ResChunkData::C4Network2ResChunkData() : iChunkCnt(0), iPresentChunkCnt(0), - pChunkRanges(NULL), iChunkRangeCnt(0) + pChunkRanges(nullptr), iChunkRangeCnt(0) { } @@ -165,7 +165,7 @@ C4Network2ResChunkData::C4Network2ResChunkData() C4Network2ResChunkData::C4Network2ResChunkData(const C4Network2ResChunkData &Data2) : C4PacketBase(Data2), iChunkCnt(Data2.getChunkCnt()), iPresentChunkCnt(0), - pChunkRanges(NULL), iChunkRangeCnt(0) + pChunkRanges(nullptr), iChunkRangeCnt(0) { // add ranges Merge(Data2); @@ -199,7 +199,7 @@ void C4Network2ResChunkData::SetComplete(int32_t inChunkCnt) // create one range ChunkRange *pRange = new ChunkRange; pRange->Start = 0; pRange->Length = iChunkCnt; - pRange->Next = NULL; + pRange->Next = nullptr; pChunkRanges = pRange; } @@ -214,7 +214,7 @@ void C4Network2ResChunkData::AddChunkRange(int32_t iStart, int32_t iLength) if (iStart < 0 || iStart + iLength > iChunkCnt || iLength <= 0) return; // find position ChunkRange *pRange, *pPrev; - for (pRange = pChunkRanges, pPrev = NULL; pRange; pPrev = pRange, pRange = pRange->Next) + for (pRange = pChunkRanges, pPrev = nullptr; pRange; pPrev = pRange, pRange = pRange->Next) if (pRange->Start >= iStart) break; // create new @@ -330,7 +330,7 @@ void C4Network2ResChunkData::CompileFunc(StdCompiler *pComp) // Ranges if (!pComp->Name("Ranges")) pComp->excCorrupt("ResChunk ranges expected!"); - ChunkRange *pRange = NULL; + ChunkRange *pRange = nullptr; for (int32_t i = 0; i < iChunkRangeCnt; i++) { // Create new range / go to next range @@ -347,7 +347,7 @@ void C4Network2ResChunkData::CompileFunc(StdCompiler *pComp) } // Terminate list if (fCompiler) - (pRange ? pRange->Next : pChunkRanges) = NULL; + (pRange ? pRange->Next : pChunkRanges) = nullptr; pComp->NameEnd(); } @@ -359,8 +359,8 @@ C4Network2Res::C4Network2Res(C4Network2ResList *pnParent) iRefCnt(0), fRemoved(false), iLastReqTime(0), fLoading(false), - pCChunks(NULL), iDiscoverStartTime(0), pLoads(NULL), iLoadCnt(0), - pNext(NULL), + pCChunks(nullptr), iDiscoverStartTime(0), pLoads(nullptr), iLoadCnt(0), + pNext(nullptr), pParent(pnParent) { szFile[0] = szStandalone[0] = '\0'; @@ -400,7 +400,7 @@ bool C4Network2Res::SetByFile(const char *strFilePath, bool fTemp, C4Network2Res fTempFile = fTemp; fStandaloneFailed = false; fRemoved = false; - iLastReqTime = time(NULL); + iLastReqTime = time(nullptr); fLoading = false; // ok return true; @@ -431,7 +431,7 @@ bool C4Network2Res::SetByGroup(C4Group *pGrp, bool fTemp, C4Network2ResType eTyp fTempFile = fTemp; fStandaloneFailed = false; fRemoved = false; - iLastReqTime = time(NULL); + iLastReqTime = time(nullptr); fLoading = false; // ok return true; @@ -515,7 +515,7 @@ bool C4Network2Res::SetLoad(const C4Network2ResCore &nCore) // by main thread fTempFile = true; fStandaloneFailed = false; fRemoved = false; - iLastReqTime = time(NULL); + iLastReqTime = time(nullptr); fLoading = true; // No discovery yet iDiscoverStartTime = 0; @@ -537,7 +537,7 @@ bool C4Network2Res::SetDerived(const char *strName, const char *strFilePath, boo fTempFile = fTemp; fStandaloneFailed = false; fRemoved = false; - iLastReqTime = time(NULL); + iLastReqTime = time(nullptr); fLoading = false; // Do not set any chunk data - anonymous resources are very likely to change. // Wait for FinishDerived()-call. @@ -563,7 +563,7 @@ bool C4Network2Res::IsBinaryCompatible() // won't match. return false; // try to create the standalone - return GetStandalone(NULL, 0, false, false, true); + return GetStandalone(nullptr, 0, false, false, true); } bool C4Network2Res::GetStandalone(char *pTo, int32_t iMaxL, bool fSetOfficial, bool fAllowUnloadable, bool fSilent) @@ -698,7 +698,7 @@ C4Network2Res::Ref C4Network2Res::Derive() // For security: This doesn't make much sense if the resource is currently being // loaded. So better assume the caller doesn't know what he's doing and check. - if (isLoading()) return NULL; + if (isLoading()) return nullptr; CStdLock FileLock(&FileCSec); // Save back original file name @@ -710,9 +710,9 @@ C4Network2Res::Ref C4Network2Res::Derive() if (!*szStandalone || SEqual(szStandalone, szFile)) { if (!pParent->FindTempResFileName(szOrgFile, szFile)) - { Log("Derive: could not find free name for temporary file!"); return NULL; } + { Log("Derive: could not find free name for temporary file!"); return nullptr; } if (!C4Group_CopyItem(szOrgFile, szFile)) - { Log("Derive: could not copy to temporary file!"); return NULL; } + { Log("Derive: could not copy to temporary file!"); return nullptr; } // set standalone if (*szStandalone) SCopy(szFile, szStandalone, _MAX_PATH); @@ -732,11 +732,11 @@ C4Network2Res::Ref C4Network2Res::Derive() // create new resource C4Network2Res::Ref pDRes = new C4Network2Res(pParent); - if (!pDRes) return NULL; + if (!pDRes) return nullptr; // initialize if (!pDRes->SetDerived(Core.getFileName(), szOrgFile, fOrgTempFile, getType(), getResID())) - return NULL; + return nullptr; // add to list pParent->Add(pDRes); @@ -761,7 +761,7 @@ bool C4Network2Res::FinishDerive() // by main thread if (!SetByFile(szFileC, fTempFile, getType(), pParent->nextResID(), szName)) return false; // create standalone - if (!GetStandalone(NULL, 0, true)) + if (!GetStandalone(nullptr, 0, true)) return false; // Set ID Core.SetDerived(iDerID); @@ -798,7 +798,7 @@ C4Group *C4Network2Res::OpenAsGrp() const if (!pnGrp->Open(szFile)) { delete pnGrp; - return NULL; + return nullptr; } return pnGrp; } @@ -834,7 +834,7 @@ bool C4Network2Res::SendChunk(uint32_t iChunk, int32_t iToClient) C4Network2IOConnection *pConn = pParent->getIOClass()->GetDataConnection(iToClient); if (!pConn) return false; // save last request time - iLastReqTime = time(NULL); + iLastReqTime = time(nullptr); // create packet CStdLock FileLock(&FileCSec); C4Network2ResChunk ResChunk; @@ -860,7 +860,7 @@ void C4Network2Res::OnDiscover(C4Network2IOConnection *pBy) { if (!IsBinaryCompatible()) return; // discovered - iLastReqTime = time(NULL); + iLastReqTime = time(nullptr); // send status back SendStatus(pBy); } @@ -948,7 +948,7 @@ bool C4Network2Res::DoLoad() { // discover timeout? if (iDiscoverStartTime) - if (difftime(time(NULL), iDiscoverStartTime) > C4NetResDiscoverTimeout) + if (difftime(time(nullptr), iDiscoverStartTime) > C4NetResDiscoverTimeout) return false; } // ok @@ -962,7 +962,7 @@ bool C4Network2Res::NeedsDiscover() { // set timeout, if this is the first discover if (!iDiscoverStartTime) - iDiscoverStartTime = time(NULL); + iDiscoverStartTime = time(nullptr); // do discover return true; } @@ -993,7 +993,7 @@ void C4Network2Res::Clear() int32_t C4Network2Res::OpenFileRead() { CStdLock FileLock(&FileCSec); - if (!GetStandalone(NULL, 0, false, false, true)) return -1; + if (!GetStandalone(nullptr, 0, false, false, true)) return -1; // FIXME: Use standard OC file access api here #ifdef _WIN32 return _wopen(GetWideChar(szStandalone), _O_BINARY | O_RDONLY); @@ -1024,7 +1024,7 @@ void C4Network2Res::StartNewLoads() ClientChunks **pC = new ClientChunks *[iCChunkCnt]; // initialize int32_t i; - for (i = 0; i < iCChunkCnt; i++) pC[i] = NULL; + for (i = 0; i < iCChunkCnt; i++) pC[i] = nullptr; // create shuffled order for (pChunks = pCChunks, i = 0; i < iCChunkCnt; i++, pChunks = pChunks->Next) { @@ -1048,7 +1048,7 @@ void C4Network2Res::StartNewLoads() { // try to start load if (!StartLoad(pC[i]->ClientID, pC[i]->Chunks)) - { RemoveCChunks(pC[i]); pC[i] = NULL; continue; } + { RemoveCChunks(pC[i]); pC[i] = nullptr; continue; } // success? if (iLoadCnt > ioLoadCnt) break; } @@ -1178,7 +1178,7 @@ bool C4Network2Res::OptimizeStandalone(bool fSilent) { if (!fSilent) Log("OptimizeStandalone: could not open player file!"); return false; } // 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(); @@ -1293,12 +1293,12 @@ void C4Network2ResChunk::CompileFunc(StdCompiler *pComp) // *** C4Network2ResList C4Network2ResList::C4Network2ResList() - : pFirst(NULL), + : pFirst(nullptr), ResListCSec(this), iClientID(-1), iNextResID((-1) << 16), iLastDiscover(0), iLastStatus(0), - pIO(NULL) + pIO(nullptr) { } @@ -1356,7 +1356,7 @@ C4Network2Res *C4Network2ResList::getRes(int32_t iResID) for (C4Network2Res *pCur = pFirst; pCur; pCur = pCur->pNext) if (pCur->getResID() == iResID) return pCur; - return NULL; + return nullptr; } C4Network2Res *C4Network2ResList::getRes(const char *szFile, bool fLocalOnly) @@ -1367,7 +1367,7 @@ C4Network2Res *C4Network2ResList::getRes(const char *szFile, bool fLocalOnly) if (SEqual(pCur->getFile(), szFile)) if (!fLocalOnly || pCur->getResClient()==iClientID) return pCur; - return NULL; + return nullptr; } C4Network2Res::Ref C4Network2ResList::getRefRes(int32_t iResID) @@ -1385,7 +1385,7 @@ C4Network2Res::Ref C4Network2ResList::getRefRes(const char *szFile, bool fLocalO C4Network2Res::Ref C4Network2ResList::getRefNextRes(int32_t iResID) { CStdShareLock ResListLock(&ResListCSec); - C4Network2Res *pRes = NULL; + C4Network2Res *pRes = nullptr; for (C4Network2Res *pCur = pFirst; pCur; pCur = pCur->pNext) if (!pCur->isRemoved() && pCur->getResID() >= iResID) if (!pRes || pRes->getResID() > pCur->getResID()) @@ -1412,19 +1412,19 @@ C4Network2Res::Ref C4Network2ResList::AddByFile(const char *strFilePath, bool fT if (pRes) return pRes; // get resource ID if (iResID < 0) iResID = nextResID(); - if (iResID < 0) { Log("AddByFile: no more resource IDs available!"); return NULL; } + if (iResID < 0) { Log("AddByFile: no more resource IDs available!"); return nullptr; } // create new pRes = new C4Network2Res(this); // initialize - if (!pRes->SetByFile(strFilePath, fTemp, eType, iResID, szResName)) { return NULL; } + if (!pRes->SetByFile(strFilePath, fTemp, eType, iResID, szResName)) { return nullptr; } // create standalone for non-system files // system files shouldn't create a standalone; they should never be marked loadable! if (eType != NRT_System) - if (!pRes->GetStandalone(NULL, 0, true, fAllowUnloadable)) + if (!pRes->GetStandalone(nullptr, 0, true, fAllowUnloadable)) if (!fAllowUnloadable) { delete pRes; - return NULL; + return nullptr; } // add to list Add(pRes); @@ -1435,21 +1435,21 @@ C4Network2Res::Ref C4Network2ResList::AddByGroup(C4Group *pGrp, bool fTemp, C4Ne { // get resource ID if (iResID < 0) iResID = nextResID(); - if (iResID < 0) { Log("AddByGroup: no more resource IDs available!"); return NULL; } + if (iResID < 0) { Log("AddByGroup: no more resource IDs available!"); return nullptr; } // create new C4Network2Res::Ref pRes = new C4Network2Res(this); // initialize if (!pRes->SetByGroup(pGrp, fTemp, eType, iResID, szResName)) { delete pRes; - return NULL; + return nullptr; } // create standalone - if (!pRes->GetStandalone(NULL, 0, true, fAllowUnloadable)) + if (!pRes->GetStandalone(nullptr, 0, true, fAllowUnloadable)) if (!fAllowUnloadable) { delete pRes; - return NULL; + return nullptr; } // add to list Add(pRes); @@ -1472,7 +1472,7 @@ C4Network2Res::Ref C4Network2ResList::AddByCore(const C4Network2ResCore &Core, b { pRes.Clear(); // try load (if specified) - return fLoad ? AddLoad(Core) : NULL; + return fLoad ? AddLoad(Core) : nullptr; } // log Application.InteractiveThread.ThreadLogS("Network: Found identical %s. Not loading.", pRes->getCore().getFileName()); @@ -1489,7 +1489,7 @@ C4Network2Res::Ref C4Network2ResList::AddLoad(const C4Network2ResCore &Core) // { // show error msg Application.InteractiveThread.ThreadLog("Network: Cannot load %s (marked unloadable)", Core.getFileName()); - return NULL; + return nullptr; } // create new C4Network2Res::Ref pRes = new C4Network2Res(this); @@ -1614,7 +1614,7 @@ void C4Network2ResList::OnTimer() if (!pRes->DoLoad()) pRes->Remove(); // discovery time? - if (!iLastDiscover || difftime(time(NULL), iLastDiscover) >= C4NetResDiscoverInterval) + if (!iLastDiscover || difftime(time(nullptr), iLastDiscover) >= C4NetResDiscoverInterval) { // needed? bool fSendDiscover = false; @@ -1626,7 +1626,7 @@ void C4Network2ResList::OnTimer() SendDiscover(); } // status update? - if (!iLastStatus || difftime(time(NULL), iLastStatus) >= C4NetResStatusInterval) + if (!iLastStatus || difftime(time(nullptr), iLastStatus) >= C4NetResStatusInterval) { // any? bool fStatusUpdates = false; @@ -1634,7 +1634,7 @@ void C4Network2ResList::OnTimer() if (pRes->isDirty() && !pRes->isRemoved()) fStatusUpdates |= pRes->SendStatus(); // set time accordingly - iLastStatus = fStatusUpdates ? time(NULL) : 0; + iLastStatus = fStatusUpdates ? time(nullptr) : 0; } } @@ -1643,15 +1643,15 @@ void C4Network2ResList::OnShareFree(CStdCSecEx *pCSec) if (pCSec == &ResListCSec) { // remove entries - for (C4Network2Res *pRes = pFirst, *pNext, *pPrev = NULL; pRes; pRes = pNext) + for (C4Network2Res *pRes = pFirst, *pNext, *pPrev = nullptr; pRes; pRes = pNext) { pNext = pRes->pNext; - if (pRes->isRemoved() && (!pRes->getLastReqTime() || difftime(time(NULL), pRes->getLastReqTime()) > C4NetResDeleteTime)) + if (pRes->isRemoved() && (!pRes->getLastReqTime() || difftime(time(nullptr), pRes->getLastReqTime()) > C4NetResDeleteTime)) { // unlink (pPrev ? pPrev->pNext : pFirst) = pNext; // remove - pRes->pNext = NULL; + pRes->pNext = nullptr; pRes->DelRef(); } else @@ -1677,7 +1677,7 @@ bool C4Network2ResList::SendDiscover(C4Network2IOConnection *pTo) // by both if (!pTo) { // save time - iLastDiscover = time(NULL); + iLastDiscover = time(nullptr); // send return pIO->BroadcastMsg(MkC4NetIOPacket(PID_NetResDis, Pkt)); } diff --git a/src/network/C4Network2Res.h b/src/network/C4Network2Res.h index 3c20a06d4..a2b8daa26 100644 --- a/src/network/C4Network2Res.h +++ b/src/network/C4Network2Res.h @@ -183,7 +183,7 @@ public: class Ref { public: - Ref() : pRes(NULL) { } + Ref() : pRes(nullptr) { } Ref(C4Network2Res *pRes) : pRes(pRes) { if (pRes) pRes->AddRef(); } Ref(const Ref &rCopy) : pRes(rCopy.pRes) { if (pRes) pRes->AddRef(); } ~Ref() { Clear(); } @@ -195,7 +195,7 @@ public: operator C4Network2Res *() const { return pRes; } bool operator ! () const { return !pRes; } C4Network2Res * operator ->() const { return pRes; } - void Clear() { if (pRes) pRes->DelRef(); pRes = NULL; } + void Clear() { if (pRes) pRes->DelRef(); pRes = nullptr; } void Set(C4Network2Res *pnRes) { if (pRes == pnRes) return; Clear(); pRes = pnRes; if (pRes) pRes->AddRef(); } }; @@ -248,9 +248,9 @@ public: int32_t getPresentPercent() const { return fLoading ? Chunks.getPresentPercent() : 100; } bool isTempFile() const { return fTempFile; } - bool SetByFile(const char *strFilePath, bool fTemp, C4Network2ResType eType, int32_t iResID, const char *szResName = NULL, bool fSilent = false); - bool SetByGroup(C4Group *pGrp, bool fTemp, C4Network2ResType eType, int32_t iResID, const char *szResName = NULL, bool fSilent = false); - bool SetByCore(const C4Network2ResCore &nCore, bool fSilent = false, const char *szAsFilename = NULL, int32_t iRecursion=0); + bool SetByFile(const char *strFilePath, bool fTemp, C4Network2ResType eType, int32_t iResID, const char *szResName = nullptr, bool fSilent = false); + bool SetByGroup(C4Group *pGrp, bool fTemp, C4Network2ResType eType, int32_t iResID, const char *szResName = nullptr, bool fSilent = false); + bool SetByCore(const C4Network2ResCore &nCore, bool fSilent = false, const char *szAsFilename = nullptr, int32_t iRecursion=0); bool SetLoad(const C4Network2ResCore &nCore); bool SetDerived(const char *strName, const char *strFilePath, bool fTemp, C4Network2ResType eType, int32_t iDResID); @@ -266,7 +266,7 @@ public: bool FinishDerive(); bool FinishDerive(const C4Network2ResCore &nCore); - bool SendStatus(C4Network2IOConnection *pTo = NULL); + bool SendStatus(C4Network2IOConnection *pTo = nullptr); bool SendChunk(uint32_t iChunk, int32_t iToClient); // references @@ -363,15 +363,15 @@ public: C4Network2Res::Ref getRefNextRes(int32_t iResID); // by both void Add(C4Network2Res *pRes); // by both - C4Network2Res::Ref AddByFile(const char *strFilePath, bool fTemp, C4Network2ResType eType, int32_t iResID = -1, const char *szResName = NULL, bool fAllowUnloadable = false); // by both - C4Network2Res::Ref AddByGroup(C4Group *pGrp, bool fTemp, C4Network2ResType eType, int32_t iResID = -1, const char *szResName = NULL, bool fAllowUnloadable = false); // by both + C4Network2Res::Ref AddByFile(const char *strFilePath, bool fTemp, C4Network2ResType eType, int32_t iResID = -1, const char *szResName = nullptr, bool fAllowUnloadable = false); // by both + C4Network2Res::Ref AddByGroup(C4Group *pGrp, bool fTemp, C4Network2ResType eType, int32_t iResID = -1, const char *szResName = nullptr, bool fAllowUnloadable = false); // by both C4Network2Res::Ref AddByCore(const C4Network2ResCore &Core, bool fLoad = true); // by main thread C4Network2Res::Ref AddLoad(const C4Network2ResCore &Core); // by main thread void RemoveAtClient(int32_t iClientID); // by main thread void Clear(); // by main thread - bool SendDiscover(C4Network2IOConnection *pTo = NULL); // by both + bool SendDiscover(C4Network2IOConnection *pTo = nullptr); // by both void OnClientConnect(C4Network2IOConnection *pConn); // by main thread // interface for C4Network2IO diff --git a/src/network/C4Network2ResDlg.cpp b/src/network/C4Network2ResDlg.cpp index 06c29ab5d..39b0d50d9 100644 --- a/src/network/C4Network2ResDlg.cpp +++ b/src/network/C4Network2ResDlg.cpp @@ -29,7 +29,7 @@ // ----------- C4Network2ResDlg::ListItem ---------------------------------------------------------------- C4Network2ResDlg::ListItem::ListItem(C4Network2ResDlg *pForResDlg, const C4Network2Res *pByRes) - : pSaveBtn(NULL) + : pSaveBtn(nullptr) { // init by res core (2do) iResID = pByRes->getResID(); @@ -43,7 +43,7 @@ C4Network2ResDlg::ListItem::ListItem(C4Network2ResDlg *pForResDlg, const C4Netwo // create subcomponents pFileIcon = new C4GUI::Icon(ca.GetFromLeft(iIconSize), C4GUI::Ico_Resource); pLabel = new C4GUI::Label(szFilename, iIconSize + IconLabelSpacing,iVerticalIndent, ALeft); - pProgress = NULL; + pProgress = nullptr; // add components AddElement(pFileIcon); AddElement(pLabel); // tooltip @@ -71,7 +71,7 @@ void C4Network2ResDlg::ListItem::Update(const C4Network2Res *pByRes) AddElement(pProgress); } } - else if (pProgress) { delete pProgress; pProgress=NULL; } + else if (pProgress) { delete pProgress; pProgress=nullptr; } // update disk icon if (IsSavePossible()) { @@ -202,7 +202,7 @@ void C4Network2ResDlg::Update() pItem = static_cast(pItem->GetNext()); } else - // not present: insert (or add if pItem=NULL) + // not present: insert (or add if pItem=nullptr) InsertElement(new ListItem(this, pRes), pItem); } // del trailing items diff --git a/src/network/C4Network2Stats.cpp b/src/network/C4Network2Stats.cpp index 92c20a1d4..521ec8e25 100644 --- a/src/network/C4Network2Stats.cpp +++ b/src/network/C4Network2Stats.cpp @@ -31,7 +31,7 @@ C4Graph::C4Graph() } C4TableGraph::C4TableGraph(int iBackLogLength, int iStartTime) - : iBackLogLength(iBackLogLength), pValues(NULL), fMultiplier(1), pAveragedValues(NULL), iBackLogPos(0), fWrapped(false) + : iBackLogLength(iBackLogLength), pValues(nullptr), fMultiplier(1), pAveragedValues(nullptr), iBackLogPos(0), fWrapped(false) , iInitialStartTime(iStartTime), iTime(iStartTime), iAveragedTime(iStartTime), iAvgRange(1) { // create value buffer @@ -275,7 +275,7 @@ const C4Graph *C4GraphCollection::GetSeries(int iIndex) const if (iIndex < iCnt) return (*i)->GetSeries(iIndex); iIndex -= iCnt; } - return NULL; + return nullptr; } void C4GraphCollection::Update() const @@ -318,14 +318,14 @@ C4Network2Stats::C4Network2Stats() statActions.SetTitle(LoadResStr("IDS_NET_APM")); statActions.SetAverageTime(100); for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next) pPlr->CreateGraphs(); - C4Network2Client *pClient = NULL; + C4Network2Client *pClient = nullptr; while ((pClient = ::Network.Clients.GetNextClient(pClient))) pClient->CreateGraphs(); } C4Network2Stats::~C4Network2Stats() { for (C4Player *pPlr = ::Players.First; pPlr; pPlr = pPlr->Next) pPlr->ClearGraphs(); - C4Network2Client *pClient = NULL; + C4Network2Client *pClient = nullptr; while ((pClient = ::Network.Clients.GetNextClient(pClient))) pClient->ClearGraphs(); Application.Remove(this); } @@ -341,7 +341,7 @@ void C4Network2Stats::ExecuteSecond() statNetI.RecordValue(C4Graph::ValueType(::Network.NetIO.getProtIRate(P_TCP) + ::Network.NetIO.getProtIRate(P_UDP))); statNetO.RecordValue(C4Graph::ValueType(::Network.NetIO.getProtORate(P_TCP) + ::Network.NetIO.getProtORate(P_UDP))); // pings for all clients - C4Network2Client *pClient = NULL; + C4Network2Client *pClient = nullptr; while ((pClient = ::Network.Clients.GetNextClient(pClient))) if (pClient->getStatPing()) { int iPing=0; @@ -385,7 +385,7 @@ C4Graph *C4Network2Stats::GetGraphByName(const StdStrBuf &rszName, bool &rfIsTem if (SEqualNoCase(rszName.getData(), "control")) return &statControls; if (SEqualNoCase(rszName.getData(), "apm")) return &statActions; // no match - return NULL; + return nullptr; } // MassGraph.SetDumpFile(StdStrBuf("C:\\test.txt")); diff --git a/src/network/C4Network2Stats.h b/src/network/C4Network2Stats.h index b15338320..2b1101448 100644 --- a/src/network/C4Network2Stats.h +++ b/src/network/C4Network2Stats.h @@ -116,7 +116,7 @@ public: // base graph has always just one series (self) virtual int GetSeriesCount() const { return 1; } - virtual const C4Graph *GetSeries(int iIndex) const { return iIndex ? NULL : this; } + virtual const C4Graph *GetSeries(int iIndex) const { return iIndex ? nullptr : this; } virtual void SetAverageTime(int iToTime); virtual void Update() const; // make sure average times are correctly calculated diff --git a/src/network/C4Network2UPnPLinux.cpp b/src/network/C4Network2UPnPLinux.cpp index 4493588ec..b60350f8f 100644 --- a/src/network/C4Network2UPnPLinux.cpp +++ b/src/network/C4Network2UPnPLinux.cpp @@ -72,9 +72,9 @@ void C4Network2UPnPP::Init() #if MINIUPNPC_API_VERSION == 10 // Distributed with Debian jessie. - if ((devlist = upnpDiscover(2000, NULL, NULL, 0, 0, &error))) + if ((devlist = upnpDiscover(2000, nullptr, nullptr, 0, 0, &error))) #else - if ((devlist = upnpDiscover(2000, NULL, NULL, UPNP_LOCAL_PORT_ANY, 0, 2, &error))) + if ((devlist = upnpDiscover(2000, nullptr, nullptr, UPNP_LOCAL_PORT_ANY, 0, 2, &error))) #endif { if ((status = UPNP_GetValidIGD(devlist, &upnp_urls, &igd_data, lanaddr, sizeof(lanaddr)))) diff --git a/src/network/C4Network2UPnPWin32.cpp b/src/network/C4Network2UPnPWin32.cpp index feaa9fce4..78ea63c34 100644 --- a/src/network/C4Network2UPnPWin32.cpp +++ b/src/network/C4Network2UPnPWin32.cpp @@ -44,7 +44,7 @@ namespace template inline void SafeRelease(T* &t) { if (t) t->Release(); - t = NULL; + t = nullptr; } } @@ -59,7 +59,7 @@ public: C4Network2UPnPP() : MustReleaseCOM(false), - mappings(NULL) + mappings(nullptr) {} void AddMapping(C4Network2IOProtocol protocol, uint16_t intport, uint16_t extport); @@ -81,8 +81,8 @@ C4Network2UPnP::C4Network2UPnP() p->MustReleaseCOM = true; // Get the NAT service - IUPnPNAT *nat = NULL; - if (FAILED(CoCreateInstance(CLSID_UPnPNAT, NULL, CLSCTX_INPROC_SERVER, IID_IUPnPNAT, reinterpret_cast(&nat)))) + IUPnPNAT *nat = nullptr; + if (FAILED(CoCreateInstance(CLSID_UPnPNAT, nullptr, CLSCTX_INPROC_SERVER, IID_IUPnPNAT, reinterpret_cast(&nat)))) { Log("UPnP fail (no service)."); return; @@ -114,7 +114,7 @@ C4Network2UPnP::~C4Network2UPnP() // Decrement COM reference count CoUninitialize(); } - delete p; p = NULL; + delete p; p = nullptr; } void C4Network2UPnP::AddMapping(C4Network2IOProtocol protocol, uint16_t intport, uint16_t extport) @@ -155,14 +155,14 @@ void C4Network2UPnPP::AddMapping(C4Network2IOProtocol protocol, uint16_t intport // Get (one of the) local host address(es) char hostname[MAX_PATH]; hostent *host; - if (gethostname(hostname, MAX_PATH) == 0 && (host = gethostbyname(hostname)) != NULL) + if (gethostname(hostname, MAX_PATH) == 0 && (host = gethostbyname(hostname)) != nullptr) { in_addr addr; addr.s_addr = *(ULONG*)host->h_addr_list[0]; BSTR description = ::SysAllocString(ADDL(C4ENGINECAPTION)); BSTR client = ::SysAllocString(GetWideChar(inet_ntoa(addr))); - IStaticPortMapping *mapping = NULL; + IStaticPortMapping *mapping = nullptr; if (SUCCEEDED(mappings->Add(extport, protocol == P_TCP ? PROTO_TCP : PROTO_UDP, intport, client, VARIANT_TRUE, description, &mapping))) { LogF("UPnP: Successfully opened port %d->%s:%d (%s)", extport, StdStrBuf(client).getData(), intport, protocol == P_TCP ? "TCP" : "UDP"); diff --git a/src/network/C4Packet2.cpp b/src/network/C4Packet2.cpp index b5134faff..e611682ba 100644 --- a/src/network/C4Packet2.cpp +++ b/src/network/C4Packet2.cpp @@ -129,7 +129,7 @@ const C4PktHandlingData PktHandlingData[] = { CID_DebugRec, PC_Control, "Debug Rec", false, true, 0, PKT_UNPACK(C4ControlDebugRec) }, // EOL - { PID_None, PC_Network, NULL, false, true, 0, NULL } + { PID_None, PC_Network, nullptr, false, true, 0, nullptr } }; const char *PacketNameByID(C4PacketType eID) @@ -193,20 +193,20 @@ void C4PktBuf::CompileFunc(StdCompiler *pComp) // *** C4IDPacket C4IDPacket::C4IDPacket() - : eID(PID_None), pPkt(NULL), fOwnPkt(true), pNext(NULL) + : eID(PID_None), pPkt(nullptr), fOwnPkt(true), pNext(nullptr) { } C4IDPacket::C4IDPacket(C4PacketType eID, C4PacketBase *pPkt, bool fTakePkt) - : eID(eID), pPkt(pPkt), fOwnPkt(fTakePkt), pNext(NULL) + : eID(eID), pPkt(pPkt), fOwnPkt(fTakePkt), pNext(nullptr) { } C4IDPacket::C4IDPacket(const C4IDPacket &Packet2) : C4PacketBase(Packet2), - eID(PID_None), pPkt(NULL), fOwnPkt(true), pNext(NULL) + eID(PID_None), pPkt(nullptr), fOwnPkt(true), pNext(nullptr) { // kinda hacky (note this might throw an uncaught exception) C4PacketBase::unpack(Packet2.C4PacketBase::pack()); @@ -228,12 +228,12 @@ const char *C4IDPacket::getPktName() const void C4IDPacket::Default() { - eID = PID_None; pPkt = NULL; + eID = PID_None; pPkt = nullptr; } void C4IDPacket::Clear() { - if (fOwnPkt) delete pPkt; pPkt = NULL; + if (fOwnPkt) delete pPkt; pPkt = nullptr; eID = PID_None; } @@ -247,7 +247,7 @@ void C4IDPacket::CompileFunc(StdCompiler *pComp) if (!pComp->Name(getPktName())) { pComp->excCorrupt("C4IDPacket: Data value needed! Packet data missing!"); return; } // Delete old packet - if (fOwnPkt) delete pPkt; pPkt = NULL; + if (fOwnPkt) delete pPkt; pPkt = nullptr; if (eID == PID_None) return; // Search unpacking function for (const C4PktHandlingData *pPData = PktHandlingData; pPData->ID != PID_None; pPData++) @@ -268,14 +268,14 @@ void C4IDPacket::CompileFunc(StdCompiler *pComp) // *** C4PacketList C4PacketList::C4PacketList() - : pFirst(NULL), pLast(NULL) + : pFirst(nullptr), pLast(nullptr) { } C4PacketList::C4PacketList(const C4PacketList &List2) : C4PacketBase(List2), - pFirst(NULL), pLast(NULL) + pFirst(nullptr), pLast(nullptr) { Append(List2); } @@ -322,7 +322,7 @@ void C4PacketList::Take(C4PacketList &List) { pFirst = List.pFirst; pLast = List.pLast; - List.pFirst = List.pLast = NULL; + List.pFirst = List.pLast = nullptr; } void C4PacketList::Append(const C4PacketList &List) @@ -343,7 +343,7 @@ void C4PacketList::Remove(C4IDPacket *pPkt) { pFirst = pPkt->pNext; if (pPkt == pLast) - pLast = NULL; + pLast = nullptr; } else { diff --git a/src/network/C4PacketBase.h b/src/network/C4PacketBase.h index c421bee3e..561e9fb8b 100644 --- a/src/network/C4PacketBase.h +++ b/src/network/C4PacketBase.h @@ -33,7 +33,7 @@ public: // conversion (using above functions) C4NetIOPacket pack(const C4NetIO::addr_t &addr = C4NetIO::addr_t()) const; C4NetIOPacket pack(uint8_t cStatus, const C4NetIO::addr_t &addr = C4NetIO::addr_t()) const; - void unpack(const C4NetIOPacket &Pkt, char *pStatus = NULL); + void unpack(const C4NetIOPacket &Pkt, char *pStatus = nullptr); }; diff --git a/src/object/C4Action.cpp b/src/object/C4Action.cpp index f3f1afd2a..d504fda8f 100644 --- a/src/object/C4Action.cpp +++ b/src/object/C4Action.cpp @@ -37,12 +37,12 @@ void C4Action::Default() ComDir=COMD_Stop; Time=0; Data=0; - Target=Target2=NULL; + Target=Target2=nullptr; Phase=PhaseDelay=0; Facet.Default(); FacetX=FacetY=0; t_attach=CNAT_None; - Animation = NULL; + Animation = nullptr; } void C4Action::CompileFunc(StdCompiler *pComp) diff --git a/src/object/C4Command.cpp b/src/object/C4Command.cpp index 3ab9a801e..70d413a4d 100644 --- a/src/object/C4Command.cpp +++ b/src/object/C4Command.cpp @@ -120,7 +120,7 @@ bool InitEnumAdaptCommandEntries() EnumAdaptCommandEntries[i - C4CMD_First].Name = CommandName(i); EnumAdaptCommandEntries[i - C4CMD_First].Val = i; } - EnumAdaptCommandEntries[C4CMD_Last - C4CMD_First + 1].Name = NULL; + EnumAdaptCommandEntries[C4CMD_Last - C4CMD_First + 1].Name = nullptr; return true; } const bool InitEnumAdaptCommandEntriesDummy = InitEnumAdaptCommandEntries(); @@ -209,20 +209,20 @@ C4Command::~C4Command() void C4Command::Default() { Command=C4CMD_None; - cObj=NULL; + cObj=nullptr; Evaluated=false; PathChecked=false; Finished=false; Tx=C4VNull; Ty=0; - Target=Target2=NULL; + Target=Target2=nullptr; Data.Set0(); UpdateInterval=0; Failures=0; Retries=0; Permit=0; - Text=NULL; - Next=NULL; + Text=nullptr; + Next=nullptr; iExec=0; BaseMode=C4CMD_Mode_SilentSub; } @@ -236,7 +236,7 @@ struct ObjectAddWaypoint // Transfer waypoint if (TransferTarget) - return cObj->AddCommand(C4CMD_Transfer,TransferTarget,iX,iY,0,NULL,false); + return cObj->AddCommand(C4CMD_Transfer,TransferTarget,iX,iY,0,nullptr,false); // Solid offset AdjustSolidOffset(iX,iY,cObj->Shape.Wdt/2,cObj->Shape.Hgt/2); @@ -247,7 +247,7 @@ struct ObjectAddWaypoint if (cObj->Command && (cObj->Command->Command==C4CMD_Transfer)) iUpdate=0; // Add waypoint assert(cObj->Command); - if (!cObj->AddCommand(C4CMD_MoveTo,NULL,iX,iY,iUpdate,NULL,false,cObj->Command->Data)) return false; + if (!cObj->AddCommand(C4CMD_MoveTo,nullptr,iX,iY,iUpdate,nullptr,false,cObj->Command->Data)) return false; return true; } @@ -269,7 +269,7 @@ void C4Command::MoveTo() // Contained: exit if (cObj->Contained) - { cObj->AddCommand(C4CMD_Exit,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_Exit,nullptr,0,0,50); return; } // Check path (crew members or specific only) if ((cObj->OCF & OCF_CrewMember) || cObj->Def->Pathfinder) @@ -304,7 +304,7 @@ void C4Command::MoveTo() { // Re-evaluate this command because vehicle control might have blocked evaluation Evaluated=false; - cObj->AddCommand(C4CMD_UnGrab,NULL,0,0,50); return; + cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0,50); return; } // Special by procedure @@ -460,11 +460,11 @@ void C4Command::Dig() // Grabbing: let go if (cObj->GetProcedure()==DFA_PUSH) - { cObj->AddCommand(C4CMD_UnGrab,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0,50); return; } // If contained: exit if (cObj->Contained) - { cObj->AddCommand(C4CMD_Exit,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_Exit,nullptr,0,0,50); return; } // Scaling or hangling: let go if ((cObj->GetProcedure()==DFA_SCALE) || (cObj->GetProcedure()==DFA_HANGLE)) @@ -520,7 +520,7 @@ void C4Command::Follow() if (!cObj->Def->CrewMember) { Finish(); return; } // Exit/enter - if (cObj->Contained) cObj->AddCommand(C4CMD_Exit,NULL,0,0,50); + if (cObj->Contained) cObj->AddCommand(C4CMD_Exit,nullptr,0,0,50); else cObj->AddCommand(C4CMD_Enter,Target->Contained,0,0,50); return; } @@ -555,7 +555,7 @@ void C4Command::Follow() } else // Else, move to target { - cObj->AddCommand(C4CMD_MoveTo,NULL,Target->GetX(),Target->GetY(),10); + cObj->AddCommand(C4CMD_MoveTo,nullptr,Target->GetX(),Target->GetY(),10); } } @@ -577,12 +577,12 @@ void C4Command::Enter() if (cObj->GetProcedure()==DFA_PUSH) if (cObj->Action.Target) if (cObj->Action.Target->GetPropertyInt(P_Touchable) == 2 || !(Data.getInt() & C4CMD_Enter_PushTarget)) - { cObj->AddCommand(C4CMD_UnGrab,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0,50); return; } // Pushing target: let go if (cObj->GetProcedure()==DFA_PUSH) if (cObj->Action.Target==Target) - { cObj->AddCommand(C4CMD_UnGrab,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0,50); return; } // Grabbing overrides position for target int32_t cx,cy; @@ -621,7 +621,7 @@ void C4Command::Enter() { int32_t ex,ey,ewdt,ehgt; if (Target->GetEntranceArea(ex,ey,ewdt,ehgt)) - cObj->AddCommand(C4CMD_MoveTo,NULL,ex+ewdt/2,ey+ehgt/2,50, NULL, true, C4VInt((Data.getInt() & C4CMD_Enter_PushTarget) ? C4CMD_MoveTo_PushTarget : 0)); + cObj->AddCommand(C4CMD_MoveTo,nullptr,ex+ewdt/2,ey+ehgt/2,50, nullptr, true, C4VInt((Data.getInt() & C4CMD_Enter_PushTarget) ? C4CMD_MoveTo_PushTarget : 0)); } } @@ -676,7 +676,7 @@ void C4Command::Grab() if (cObj->GetProcedure()==DFA_DIG) ObjectComStop(cObj); // Grabbing: let go if (cObj->GetProcedure()==DFA_PUSH) - { cObj->AddCommand(C4CMD_UnGrab,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0,50); return; } // No target if (!Target) { Finish(); return; } // At target object: grab @@ -693,7 +693,7 @@ void C4Command::Grab() // Else, move to object else { - cObj->AddCommand(C4CMD_MoveTo,NULL,Target->GetX()+Tx._getInt(),Target->GetY()+Ty,50); + cObj->AddCommand(C4CMD_MoveTo,nullptr,Target->GetX()+Tx._getInt(),Target->GetY()+Ty,50); } } @@ -720,7 +720,7 @@ void C4Command::PushTo() { cObj->Action.ComDir=COMD_Stop; cObj->AddCommand(C4CMD_UnGrab); - cObj->AddCommand(C4CMD_Wait,NULL,0,0,10); + cObj->AddCommand(C4CMD_Wait,nullptr,0,0,10); Finish(true); return; } } @@ -738,9 +738,9 @@ void C4Command::PushTo() // Move to target position / enter target object if (Target2) - { cObj->AddCommand(C4CMD_Enter,Target2,0,0,40, NULL, true, C4Value(C4CMD_Enter_PushTarget)); return; } + { cObj->AddCommand(C4CMD_Enter,Target2,0,0,40, nullptr, true, C4Value(C4CMD_Enter_PushTarget)); return; } else - { cObj->AddCommand(C4CMD_MoveTo,NULL,Tx,Ty,40, NULL, true, C4Value(C4CMD_MoveTo_PushTarget)); return; } + { cObj->AddCommand(C4CMD_MoveTo,nullptr,Tx,Ty,40, nullptr, true, C4Value(C4CMD_MoveTo_PushTarget)); return; } } @@ -775,7 +775,7 @@ void C4Command::Throw() // Grabbing: let go if (cObj->GetProcedure()==DFA_PUSH) - { cObj->AddCommand(C4CMD_UnGrab,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0,50); return; } // Preferred throwing direction int32_t iDir=+1; if (cObj->GetX() > Tx._getInt()) iDir=-1; @@ -800,7 +800,7 @@ void C4Command::Throw() } // Move to target position - cObj->AddCommand(C4CMD_MoveTo,NULL,iTx,iTy,20); + cObj->AddCommand(C4CMD_MoveTo,nullptr,iTx,iTy,20); return; } @@ -860,7 +860,7 @@ void C4Command::Drop() { // Grabbing: let go if (cObj->GetProcedure()==DFA_PUSH) - { cObj->AddCommand(C4CMD_UnGrab,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0,50); return; } // At target position: drop if (Inside(cObj->GetX() - Tx._getInt(), -iMoveToRange, +iMoveToRange) && Inside(cObj->GetY()-Ty,-15,+15)) { @@ -870,7 +870,7 @@ void C4Command::Drop() return; } // Move to target position - cObj->AddCommand(C4CMD_MoveTo,NULL,Tx._getInt(),Ty,20); + cObj->AddCommand(C4CMD_MoveTo,nullptr,Tx._getInt(),Ty,20); return; } @@ -978,7 +978,7 @@ void C4Command::Get() { // Get-count specified: decrease count and continue with next object if (Tx._getInt() > 1) - { Target = NULL; Tx--; return; } + { Target = nullptr; Tx--; return; } // We're done else { cObj->Action.ComDir=COMD_Stop; Finish(true); return; } @@ -987,7 +987,7 @@ void C4Command::Get() // Grabbing other than target container: let go if (cObj->GetProcedure()==DFA_PUSH) if (cObj->Action.Target!=Target->Contained) - { cObj->AddCommand(C4CMD_UnGrab,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0,50); return; } // Target in solid: dig out if (!Target->Contained && (Target->OCF & OCF_InSolid)) @@ -1007,9 +1007,9 @@ void C4Command::Get() // Move to closest free position (if not in dig-direct range) if (!Inside(cObj->GetX()-iX,-DigOutPositionRange,+DigOutPositionRange) || !Inside(cObj->GetY()-iY,-DigOutPositionRange,+DigOutPositionRange)) - { cObj->AddCommand(C4CMD_MoveTo,NULL,iX,iY,50); return; } + { cObj->AddCommand(C4CMD_MoveTo,nullptr,iX,iY,50); return; } // DigTo - cObj->AddCommand(C4CMD_Dig,NULL,Target->GetX(),Target->GetY()+4,50); return; + cObj->AddCommand(C4CMD_Dig,nullptr,Target->GetX(),Target->GetY()+4,50); return; } // Digging: stop @@ -1030,7 +1030,7 @@ void C4Command::Get() // Leave own container if (cObj->Contained) - { cObj->AddCommand(C4CMD_Exit,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_Exit,nullptr,0,0,50); return; } // Target container has grab get: grab target container if (Target->Contained->Def->GrabPutGet & C4D_Grab_Get) @@ -1059,7 +1059,7 @@ void C4Command::Get() // Target outside // Leave own container - if (cObj->Contained) { cObj->AddCommand(C4CMD_Exit,NULL,0,0,50); return; } + if (cObj->Contained) { cObj->AddCommand(C4CMD_Exit,nullptr,0,0,50); return; } // Outside if (!cObj->Contained) @@ -1087,14 +1087,14 @@ void C4Command::Get() if (PathFree(iSideX,cObj->GetY(),Target->GetX(),Target->GetY())) { // Side-move jump - cObj->AddCommand(C4CMD_Jump,NULL,Tx._getInt(),Ty); + cObj->AddCommand(C4CMD_Jump,nullptr,Tx._getInt(),Ty); // FIXME: Drop stuff if full here - cObj->AddCommand(C4CMD_MoveTo,NULL,iSideX,cObj->GetY(),50); + cObj->AddCommand(C4CMD_MoveTo,nullptr,iSideX,cObj->GetY(),50); } } // Move to target (random offset for difficult pickups) // ...avoid offsets into solid which would lead to high above surface locations! - cObj->AddCommand(C4CMD_MoveTo,NULL,Target->GetX()+Random(15)-7,Target->GetY(),25,NULL); + cObj->AddCommand(C4CMD_MoveTo,nullptr,Target->GetX()+Random(15)-7,Target->GetY(),25,nullptr); } } @@ -1157,7 +1157,7 @@ void C4Command::Activate() // Leave own container if (cObj->Contained) - { cObj->AddCommand(C4CMD_Exit,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_Exit,nullptr,0,0,50); return; } // Target container has entrance: enter if (Target2->OCF & OCF_Entrance) @@ -1193,7 +1193,7 @@ void C4Command::Put() // Notice: Put command is currently using Ty as an interna { // Put-count specified: decrease count and continue with next object if (Tx._getInt() > 1) - { Target2 = NULL; Tx--; return; } + { Target2 = nullptr; Tx--; return; } // We're done else { Finish(true); return; } @@ -1219,11 +1219,11 @@ void C4Command::Put() // Notice: Put command is currently using Ty as an interna if (cObj->GetProcedure()==DFA_DIG) ObjectComStop(cObj); // Grabbing other than target: let go - C4Object *pGrabbing=NULL; + C4Object *pGrabbing=nullptr; if (cObj->GetProcedure()==DFA_PUSH) pGrabbing = cObj->Action.Target; if (pGrabbing && (pGrabbing!=Target)) - { cObj->AddCommand(C4CMD_UnGrab,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0,50); return; } // Inside target container if (cObj->Contained == Target) @@ -1236,7 +1236,7 @@ void C4Command::Put() // Notice: Put command is currently using Ty as an interna // Leave own container if (cObj->Contained) - { cObj->AddCommand(C4CMD_Exit,NULL,0,0,50); return; } + { cObj->AddCommand(C4CMD_Exit,nullptr,0,0,50); return; } // Target has collection: throw in if not fragile, not grabbing target and throwing position found if (Target->OCF & OCF_Collection) @@ -1269,7 +1269,7 @@ void C4Command::Put() // Notice: Put command is currently using Ty as an interna // Putting failed { Finish(); return; } // Let go (if we grabbed the target because of this command) - if (Ty) cObj->AddCommand(C4CMD_UnGrab,NULL,0,0); + if (Ty) cObj->AddCommand(C4CMD_UnGrab,nullptr,0,0); return; } // Grab target and let go after putting @@ -1286,9 +1286,9 @@ void C4Command::Put() // Notice: Put command is currently using Ty as an interna void C4Command::ClearPointers(C4Object *pObj) { - if (cObj==pObj) cObj=NULL; - if (Target==pObj) Target=NULL; - if (Target2==pObj) Target2=NULL; + if (cObj==pObj) cObj=nullptr; + if (Target==pObj) Target=nullptr; + if (Target2==pObj) Target2=nullptr; } void C4Command::Execute() @@ -1305,7 +1305,7 @@ void C4Command::Execute() { // Retry if (Retries>0) - { Failures=0; Retries--; cObj->AddCommand(C4CMD_Retry,NULL,0,0,10); return; } + { Failures=0; Retries--; cObj->AddCommand(C4CMD_Retry,nullptr,0,0,10); return; } // Too many failures else { Finish(); return; } @@ -1401,7 +1401,7 @@ bool C4Command::InitEvaluation() case C4CMD_MoveTo: { // Target coordinates by Target - if (Target) { Tx+=Target->GetX(); Ty+=Target->GetY(); Target=NULL; } + if (Target) { Tx+=Target->GetX(); Ty+=Target->GetY(); Target=nullptr; } // Adjust coordinates int32_t iTx = Tx._getInt(); if (~Data.getInt() & C4CMD_MoveTo_NoPosAdjust) AdjustMoveToTarget(iTx,Ty,FreeMoveTo(cObj),cObj->Shape.Hgt); @@ -1455,14 +1455,14 @@ bool C4Command::InitEvaluation() void C4Command::Clear() { Command=C4CMD_None; - cObj=NULL; + cObj=nullptr; Evaluated=false; PathChecked=false; Tx=C4VNull; Ty=0; - Target=Target2=NULL; + Target=Target2=nullptr; UpdateInterval=0; - if (Text) Text->DecRef(); Text=NULL; + if (Text) Text->DecRef(); Text=nullptr; BaseMode=C4CMD_Mode_SilentSub; } @@ -1520,7 +1520,7 @@ bool C4Command::JumpControl() // Called by DFA_WALK for (iTopFree=0; (iTopFree<50) && !GBackSolid(cx,cy+cObj->Shape.GetY()-iTopFree); ++iTopFree) {} if (iTopFree>=15) { - cObj->AddCommand(C4CMD_Jump,NULL,Tx,Ty); return true; + cObj->AddCommand(C4CMD_Jump,nullptr,Tx,Ty); return true; } } @@ -1538,8 +1538,8 @@ bool C4Command::JumpControl() // Called by DFA_WALK // Path free from side move target to jump target if (PathFree(iSideX,iSideY,Tx._getInt(),Ty)) { - cObj->AddCommand(C4CMD_Jump,NULL,Tx,Ty); - cObj->AddCommand(C4CMD_MoveTo,NULL,iSideX,iSideY,50); + cObj->AddCommand(C4CMD_Jump,nullptr,Tx,Ty); + cObj->AddCommand(C4CMD_MoveTo,nullptr,iSideX,iSideY,50); return true; } } @@ -1553,12 +1553,12 @@ bool C4Command::JumpControl() // Called by DFA_WALK if (cObj->t_contact & CNAT_Right) if (Inside(iAngle-JumpLowAngle,-iLowSideRange*JumpAngleRange,+iLowSideRange*JumpAngleRange)) { - cObj->AddCommand(C4CMD_Jump,NULL,Tx,Ty); return true; + cObj->AddCommand(C4CMD_Jump,nullptr,Tx,Ty); return true; } if (cObj->t_contact & CNAT_Left) if (Inside(iAngle+JumpLowAngle,-iLowSideRange*JumpAngleRange,+iLowSideRange*JumpAngleRange)) { - cObj->AddCommand(C4CMD_Jump,NULL,Tx,Ty); return true; + cObj->AddCommand(C4CMD_Jump,nullptr,Tx,Ty); return true; } } @@ -1581,7 +1581,7 @@ void C4Command::Transfer() if (!Inside(cObj->GetX()-pZone->X,-5,pZone->Wdt-1+5)) { if (!pZone->GetEntryPoint(iEntryX,iEntryY,cObj->GetX(),cObj->GetY())) { Finish(); return; } - cObj->AddCommand(C4CMD_MoveTo,NULL,iEntryX,iEntryY,25); + cObj->AddCommand(C4CMD_MoveTo,nullptr,iEntryX,iEntryY,25); return; } @@ -1618,14 +1618,14 @@ void C4Command::Attack() if (cObj->Contained!=Target->Contained) { // Exit - if (cObj->Contained) cObj->AddCommand(C4CMD_Exit,NULL,0,0,10); + if (cObj->Contained) cObj->AddCommand(C4CMD_Exit,nullptr,0,0,10); // Enter else cObj->AddCommand(C4CMD_Enter,Target->Contained,0,0,10); return; } // Move to target - cObj->AddCommand(C4CMD_MoveTo,NULL,Target->GetX(),Target->GetY(),10); + cObj->AddCommand(C4CMD_MoveTo,nullptr,Target->GetX(),Target->GetY(),10); return; } @@ -1672,7 +1672,7 @@ void C4Command::Acquire() { Finish(); return; } // Find available material - C4Object *pMaterial=NULL; + C4Object *pMaterial=nullptr; // Next closest while ((pMaterial = Game.FindObject(Data.getDef(),cObj->GetX(),cObj->GetY(),-1,-1,OCF_Available,pMaterial))) // Object is not in container to be ignored @@ -1694,7 +1694,7 @@ void C4Command::Acquire() // No available material found: buy material // This command will fail immediately if buying at bases is not possible // - but the command should be created anyway because it might be overloaded - cObj->AddCommand(C4CMD_Buy,NULL,0,0,100,NULL,true,Data,false,0,0,C4CMD_Mode_Sub); + cObj->AddCommand(C4CMD_Buy,nullptr,0,0,100,nullptr,true,Data,false,0,0,C4CMD_Mode_Sub); } @@ -1900,7 +1900,7 @@ void C4Command::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers) if (Text) Text->DecRef(); if (TextBuf == "0") - { Text = NULL; } + { Text = nullptr; } else { Text = Strings.RegString(TextBuf); Text->IncRef(); } } diff --git a/src/object/C4Def.cpp b/src/object/C4Def.cpp index 32cee0af7..72b215ac6 100644 --- a/src/object/C4Def.cpp +++ b/src/object/C4Def.cpp @@ -46,12 +46,12 @@ public: virtual C4Surface* LoadTexture(const char* filename) { - if (!Group.AccessEntry(filename)) return NULL; + if (!Group.AccessEntry(filename)) return nullptr; C4Surface* surface = new C4Surface; // Suppress error message here, StdMeshMaterial loader // will show one. if (!surface->Read(Group, GetExtension(filename), C4SF_MipMap)) - { delete surface; surface = NULL; } + { delete surface; surface = nullptr; } return surface; } @@ -209,13 +209,13 @@ void C4Def::CompileFunc(StdCompiler *pComp) { "C4D_MouseIgnore", C4D_MouseIgnore }, { "C4D_IgnoreFoW", C4D_IgnoreFoW }, - { NULL, 0 } + { nullptr, 0 } }; pComp->Value(mkNamingAdapt(mkBitfieldAdapt(Category, Categories), "Category", 0 )); - pComp->Value(mkParAdapt(Shape, static_cast(NULL))); + pComp->Value(mkParAdapt(Shape, static_cast(nullptr))); pComp->Value(mkNamingAdapt(Value, "Value", 0 )); pComp->Value(mkNamingAdapt(Mass, "Mass", 0 )); pComp->Value(mkNamingAdapt(SolidMask, "SolidMask", TargetRect0 )); @@ -237,7 +237,7 @@ void C4Def::CompileFunc(StdCompiler *pComp) { "C4D_GrabGet" ,C4D_Grab_Get}, { "C4D_GrabPut" ,C4D_Grab_Put}, - { NULL, 0} + { nullptr, 0} }; pComp->Value(mkNamingAdapt(mkBitfieldAdapt(GrabPutGet, GrabPutGetTypes), @@ -281,7 +281,7 @@ void C4Def::CompileFunc(StdCompiler *pComp) { "APS_Graphics", APS_Graphics }, { "APS_Name", APS_Name }, { "APS_Overlay", APS_Overlay }, - { NULL, 0 } + { nullptr, 0 } }; pComp->Value(mkNamingAdapt(mkBitfieldAdapt(AllowPictureStack, AllowPictureStackModes), //undocumented @@ -291,7 +291,7 @@ void C4Def::CompileFunc(StdCompiler *pComp) //-------------------------------- C4Def ------------------------------------------------------- -C4Def::C4Def(): Script(), C4PropListStatic(ScriptEngine.GetPropList(), NULL, NULL) +C4Def::C4Def(): Script(), C4PropListStatic(ScriptEngine.GetPropList(), nullptr, nullptr) { Script.SetDef(this); assert(ScriptEngine.GetPropList()); @@ -302,20 +302,20 @@ C4Def::C4Def(): Script(), C4PropListStatic(ScriptEngine.GetPropList(), NULL, NUL void C4Def::Default() { DefaultDefCore(); - Next=NULL; + Next=nullptr; Temporary=false; Filename[0]=0; Creation=0; Count=0; - MainFace.Set(NULL,0,0,0,0); + MainFace.Set(nullptr,0,0,0,0); Script.Clear(); StringTable.Clear(); - pClonkNames=NULL; - pRankNames=NULL; - pRankSymbols=NULL; + pClonkNames=nullptr; + pRankNames=nullptr; + pRankSymbols=nullptr; fClonkNamesOwned = fRankNamesOwned = fRankSymbolsOwned = false; iNumRankSymbols=1; - pSolidMask = NULL; + pSolidMask = nullptr; } C4Def::~C4Def() @@ -331,11 +331,11 @@ void C4Def::Clear() Graphics.Clear(); StringTable.Clear(); - if (pClonkNames && fClonkNamesOwned) delete pClonkNames; pClonkNames=NULL; - if (pRankNames && fRankNamesOwned) delete pRankNames; pRankNames=NULL; - if (pRankSymbols && fRankSymbolsOwned) delete pRankSymbols; pRankSymbols=NULL; + if (pClonkNames && fClonkNamesOwned) delete pClonkNames; pClonkNames=nullptr; + if (pRankNames && fRankNamesOwned) delete pRankNames; pRankNames=nullptr; + if (pRankSymbols && fRankSymbolsOwned) delete pRankSymbols; pRankSymbols=nullptr; fClonkNamesOwned = fRankNamesOwned = fRankSymbolsOwned = false; - delete pSolidMask; pSolidMask = NULL; + delete pSolidMask; pSolidMask = nullptr; } bool C4Def::Load(C4Group &hGroup, @@ -421,7 +421,7 @@ void C4Def::LoadMeshMaterials(C4Group &hGroup, C4DefGraphicsPtrBackup *gfx_backu ::MeshMaterialManager.Remove(mat, &gfx_backup->GetUpdater()); } mesh_materials.clear(); - while (hGroup.FindNextEntry(C4CFN_DefMaterials, MaterialFilename, NULL, !!*MaterialFilename)) + while (hGroup.FindNextEntry(C4CFN_DefMaterials, MaterialFilename, nullptr, !!*MaterialFilename)) { StdStrBuf material; if (hGroup.LoadEntryString(MaterialFilename, &material)) @@ -498,7 +498,7 @@ bool C4Def::LoadGraphics(C4Group &hGroup, StdMeshSkeletonLoader &loader) if (Graphics.GetBitmap()) { // Set MainFace (unassigned bitmap: will be set by GetMainFace()) - MainFace.Set(NULL, 0, 0, Shape.Wdt, Shape.Hgt); + MainFace.Set(nullptr, 0, 0, Shape.Wdt, Shape.Hgt); } // Adjust picture rect @@ -532,14 +532,14 @@ void C4Def::LoadScript(C4Group &hGroup, const char* szLanguage) void C4Def::LoadClonkNames(C4Group &hGroup, C4ComponentHost* pClonkNames, const char* szLanguage) { // clear any previous - if (pClonkNames) delete pClonkNames; pClonkNames = NULL; + if (pClonkNames) delete pClonkNames; pClonkNames = nullptr; if (hGroup.FindEntry(C4CFN_ClonkNameFiles)) { // create new pClonkNames = new C4ComponentHost(); if (!C4Language::LoadComponentHost(pClonkNames, hGroup, C4CFN_ClonkNames, szLanguage)) { - delete pClonkNames; pClonkNames = NULL; + delete pClonkNames; pClonkNames = nullptr; } else fClonkNamesOwned = true; @@ -549,7 +549,7 @@ void C4Def::LoadClonkNames(C4Group &hGroup, C4ComponentHost* pClonkNames, const void C4Def::LoadRankNames(C4Group &hGroup, const char* szLanguage) { // clear any previous - if (pRankNames) delete pRankNames; pRankNames = NULL; + if (pRankNames) delete pRankNames; pRankNames = nullptr; if (hGroup.FindEntry(C4CFN_RankNameFiles)) { // create new @@ -557,7 +557,7 @@ void C4Def::LoadRankNames(C4Group &hGroup, const char* szLanguage) // load from group if (!pRankNames->Load(hGroup, C4CFN_RankNames, 1000, szLanguage)) { - delete pRankNames; pRankNames = NULL; + delete pRankNames; pRankNames = nullptr; } else fRankNamesOwned = true; @@ -567,19 +567,19 @@ void C4Def::LoadRankNames(C4Group &hGroup, const char* szLanguage) void C4Def::LoadRankFaces(C4Group &hGroup) { // clear any previous - if (pRankSymbols) delete pRankSymbols; pRankSymbols = NULL; + if (pRankSymbols) delete pRankSymbols; pRankSymbols = nullptr; // load new if (hGroup.AccessEntry(C4CFN_RankFacesPNG)) { pRankSymbols = new C4FacetSurface(); - if (!pRankSymbols->GetFace().ReadPNG(hGroup, false)) { delete pRankSymbols; pRankSymbols = NULL; } + if (!pRankSymbols->GetFace().ReadPNG(hGroup, false)) { delete pRankSymbols; pRankSymbols = nullptr; } } // set size if (pRankSymbols) { pRankSymbols->Set(&pRankSymbols->GetFace(), 0, 0, pRankSymbols->GetFace().Hgt, pRankSymbols->GetFace().Hgt); int32_t Q; pRankSymbols->GetPhaseNum(iNumRankSymbols, Q); - if (!iNumRankSymbols) { delete pRankSymbols; pRankSymbols = NULL; } + if (!iNumRankSymbols) { delete pRankSymbols; pRankSymbols = nullptr; } else { if (pRankNames) @@ -595,7 +595,7 @@ void C4Def::LoadRankFaces(C4Group &hGroup) void C4Def::LoadSounds(C4Group &hGroup, C4SoundSystem* pSoundSystem) { if (pSoundSystem) - pSoundSystem->LoadEffects(hGroup, (id == C4ID::None) ? NULL : id.ToString(), true); + pSoundSystem->LoadEffects(hGroup, (id == C4ID::None) ? nullptr : id.ToString(), true); } void C4Def::Draw(C4Facet &cgo, bool fSelected, DWORD iColor, C4Object *pObj, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform* trans, const char *graphicsName) @@ -643,14 +643,14 @@ void C4Def::IncludeDefinition(C4Def *pIncludeDef) void C4Def::ResetIncludeDependencies() { // clear all pointers into foreign defs - if (!fClonkNamesOwned) pClonkNames = NULL; - if (!fRankNamesOwned) pRankNames = NULL; - if (!fRankSymbolsOwned) { pRankSymbols = NULL; iNumRankSymbols = 0; } + if (!fClonkNamesOwned) pClonkNames = nullptr; + if (!fRankNamesOwned) pRankNames = nullptr; + if (!fRankSymbolsOwned) { pRankSymbols = nullptr; iNumRankSymbols = 0; } } C4PropList *C4Def::GetActionByName(const char *actname) { - if (!actname) return NULL; + if (!actname) return nullptr; C4String * actname_str = Strings.RegString(actname); actname_str->IncRef(); C4PropList *r = GetActionByName(actname_str); @@ -661,12 +661,12 @@ C4PropList *C4Def::GetActionByName(const char *actname) C4PropList *C4Def::GetActionByName(C4String *actname) { assert(actname); - // If we get the null string or ActIdle by name, return NULL action - if (!actname || actname == &Strings.P[P_Idle]) return NULL; + // If we get the null string or ActIdle by name, return nullptr action + if (!actname || actname == &Strings.P[P_Idle]) return nullptr; // otherwise, query actmap C4Value ActMap; GetProperty(P_ActMap, &ActMap); - if (!ActMap.getPropList()) return NULL; + if (!ActMap.getPropList()) return nullptr; C4Value Action; ActMap.getPropList()->GetPropertyByS(actname, &Action); - if (!Action.getPropList()) return NULL; + if (!Action.getPropList()) return nullptr; return Action.getPropList(); } diff --git a/src/object/C4Def.h b/src/object/C4Def.h index 86f0e91d7..47c8e136d 100644 --- a/src/object/C4Def.h +++ b/src/object/C4Def.h @@ -208,7 +208,7 @@ public: DWORD dwLoadWhat, const char *szLanguage, class C4SoundSystem *pSoundSystem = nullptr, C4DefGraphicsPtrBackup *gfx_backup = nullptr); - void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=NULL, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform* trans=NULL, const char * graphicsName=NULL); + void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform* trans=nullptr, const char * graphicsName=nullptr); inline C4Facet &GetMainFace(C4DefGraphics *pGraphics, DWORD dwClr=0) { MainFace.Surface=pGraphics->GetBitmap(dwClr); return MainFace; } int32_t GetPlane() { return GetPropertyInt(P_Plane); } diff --git a/src/object/C4DefGraphics.cpp b/src/object/C4DefGraphics.cpp index e1b3dd99a..3f371ae15 100644 --- a/src/object/C4DefGraphics.cpp +++ b/src/object/C4DefGraphics.cpp @@ -49,8 +49,8 @@ C4DefGraphics::C4DefGraphics(C4Def *pOwnDef) pDef = pOwnDef; // zero fields Type = TYPE_None; - Bmp.Bitmap = Bmp.BitmapClr = Bmp.BitmapNormal = NULL; - pNext = NULL; + Bmp.Bitmap = Bmp.BitmapClr = Bmp.BitmapNormal = nullptr; + pNext = nullptr; fColorBitmapAutoCreated = false; } @@ -69,20 +69,20 @@ void C4DefGraphics::Clear() case TYPE_None: break; case TYPE_Bitmap: - if (Bmp.BitmapNormal) { delete Bmp.BitmapNormal; Bmp.BitmapNormal=NULL; } - if (Bmp.BitmapClr) { delete Bmp.BitmapClr; Bmp.BitmapClr=NULL; } - if (Bmp.Bitmap) { delete Bmp.Bitmap; Bmp.Bitmap=NULL; } + if (Bmp.BitmapNormal) { delete Bmp.BitmapNormal; Bmp.BitmapNormal=nullptr; } + if (Bmp.BitmapClr) { delete Bmp.BitmapClr; Bmp.BitmapClr=nullptr; } + if (Bmp.Bitmap) { delete Bmp.Bitmap; Bmp.Bitmap=nullptr; } break; case TYPE_Mesh: - if (Mesh) { delete Mesh; Mesh = NULL; } + if (Mesh) { delete Mesh; Mesh = nullptr; } break; } Type = TYPE_None; // delete additonal graphics C4AdditionalDefGraphics *pGrp2N = pNext, *pGrp2; - while ((pGrp2=pGrp2N)) { pGrp2N = pGrp2->pNext; pGrp2->pNext = NULL; delete pGrp2; } - pNext = NULL; fColorBitmapAutoCreated = false; + while ((pGrp2=pGrp2N)) { pGrp2N = pGrp2->pNext; pGrp2->pNext = nullptr; delete pGrp2; } + pNext = nullptr; fColorBitmapAutoCreated = false; } bool C4DefGraphics::LoadBitmap(C4Group &hGroup, const char *szFilename, const char *szOverlay, const char *szNormal, bool fColorByOwner) @@ -149,7 +149,7 @@ bool C4DefGraphics::LoadBitmap(C4Group &hGroup, const char *szFilename, const ch { // No normal map delete Bmp.BitmapNormal; - Bmp.BitmapNormal = NULL; + Bmp.BitmapNormal = nullptr; } } @@ -160,7 +160,7 @@ bool C4DefGraphics::LoadBitmap(C4Group &hGroup, const char *szFilename, const ch bool C4DefGraphics::LoadMesh(C4Group &hGroup, const char* szFileName, StdMeshSkeletonLoader& loader) { - char* buf = NULL; + char* buf = nullptr; size_t size; try @@ -195,7 +195,7 @@ bool C4DefGraphics::LoadMesh(C4Group &hGroup, const char* szFileName, StdMeshSke bool C4DefGraphics::LoadSkeleton(C4Group &hGroup, const char* szFileName, StdMeshSkeletonLoader& loader) { - char* buf = NULL; + char* buf = nullptr; size_t size; try @@ -233,7 +233,7 @@ bool C4DefGraphics::Load(C4Group &hGroup, StdMeshSkeletonLoader &loader, bool fC // load skeletons hGroup.ResetSearch(); - while (hGroup.FindNextEntry("*", Filename, NULL, !!*Filename)) + while (hGroup.FindNextEntry("*", Filename, nullptr, !!*Filename)) { if (!WildcardMatch(C4CFN_DefSkeleton, Filename) && !WildcardMatch(C4CFN_DefSkeletonXml, Filename)) continue; LoadSkeleton(hGroup, Filename, loader); @@ -248,10 +248,10 @@ bool C4DefGraphics::Load(C4Group &hGroup, StdMeshSkeletonLoader &loader, bool fC C4DefGraphics *pLastGraphics = this; const int32_t iOverlayWildcardPos = SCharPos('*', C4CFN_ClrByOwnerEx); hGroup.ResetSearch(); *Filename=0; - const char* const AdditionalGraphics[] = { C4CFN_DefGraphicsEx, C4CFN_DefGraphicsExMesh, C4CFN_DefGraphicsExMeshXml, NULL }; - while (hGroup.FindNextEntry("*", Filename, NULL, !!*Filename)) + const char* const AdditionalGraphics[] = { C4CFN_DefGraphicsEx, C4CFN_DefGraphicsExMesh, C4CFN_DefGraphicsExMeshXml, nullptr }; + while (hGroup.FindNextEntry("*", Filename, nullptr, !!*Filename)) { - for(const char* const* szWildcard = AdditionalGraphics; *szWildcard != NULL; ++szWildcard) + for(const char* const* szWildcard = AdditionalGraphics; *szWildcard != nullptr; ++szWildcard) { if(!WildcardMatch(*szWildcard, Filename)) continue; // skip def graphics @@ -294,7 +294,7 @@ bool C4DefGraphics::Load(C4Group &hGroup, StdMeshSkeletonLoader &loader, bool fC EnforceExtension(NormalFn, GetExtension(C4CFN_NormalMapEx)); // load them - if (!pLastGraphics->LoadBitmap(hGroup, Filename, fColorByOwner ? OverlayFn : NULL, NormalFn, fColorByOwner)) + if (!pLastGraphics->LoadBitmap(hGroup, Filename, fColorByOwner ? OverlayFn : nullptr, NormalFn, fColorByOwner)) return false; } else @@ -316,7 +316,7 @@ C4DefGraphics *C4DefGraphics::Get(const char *szGrpName) for (C4AdditionalDefGraphics *pGrp = pNext; pGrp; pGrp=pGrp->pNext) if (SEqualNoCase(pGrp->GetName(), szGrpName)) return pGrp; // nothing found - return NULL; + return nullptr; } void C4DefGraphics::Draw(C4Facet &cgo, DWORD iColor, C4Object *pObj, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform* trans) @@ -365,7 +365,7 @@ void C4DefGraphics::Draw(C4Facet &cgo, DWORD iColor, C4Object *pObj, int32_t iPh pDraw->SetPerspective(true); pDraw->RenderMesh(*instance, cgo.Surface, cgo.X,cgo.Y, cgo.Wdt, cgo.Hgt, pObj ? pObj->Color : iColor, trans); pDraw->SetPerspective(false); - pDraw->SetMeshTransform(NULL); + pDraw->SetMeshTransform(nullptr); break; } @@ -423,7 +423,7 @@ C4AdditionalDefGraphics::C4AdditionalDefGraphics(C4Def *pOwnDef, const char *szN // C4DefGraphicsPtrBackup: Functionality to reload def graphics at runtime C4DefGraphicsPtrBackupEntry::C4DefGraphicsPtrBackupEntry(C4DefGraphics *pSourceGraphics): - pMeshUpdate(NULL) + pMeshUpdate(nullptr) { // assign graphics + def pGraphicsPtr = pSourceGraphics; @@ -462,7 +462,7 @@ void C4DefGraphicsPtrBackupEntry::AssignUpdate() // same graphics found. Update mesh graphics if any. if(pMeshUpdate) { - assert(pObj->pMeshInstance != NULL); // object had mesh graphics, so mesh instance should be present + assert(pObj->pMeshInstance != nullptr); // object had mesh graphics, so mesh instance should be present assert(&pObj->pMeshInstance->GetMesh() == &pMeshUpdate->GetOldMesh()); // mesh instance of correct type even // Get new mesh from reloaded graphics @@ -476,7 +476,7 @@ void C4DefGraphicsPtrBackupEntry::AssignUpdate() if (!pObj->SetGraphics(Name, pObj->Def)) { // shouldn't happen - pObj->AssignRemoval(); pObj->pGraphics=NULL; + pObj->AssignRemoval(); pObj->pGraphics=nullptr; } } @@ -499,11 +499,11 @@ void C4DefGraphicsPtrBackupEntry::AssignUpdate() if (pDef && pObj->Menu && (pDeco = pObj->Menu->GetFrameDecoration())) if (pDeco->idSourceDef == pDef->id) if (!pDeco->UpdateGfx()) - pObj->Menu->SetFrameDeco(NULL); + pObj->Menu->SetFrameDeco(nullptr); } } // done; reset field to indicate finished update - pGraphicsPtr = NULL; + pGraphicsPtr = nullptr; } } @@ -529,11 +529,11 @@ void C4DefGraphicsPtrBackupEntry::AssignRemoval() pObj->AssignRemoval(); delete pObj->pMeshInstance; - pObj->pMeshInstance = NULL; - pObj->pGraphics = NULL; + pObj->pMeshInstance = nullptr; + pObj->pGraphics = nullptr; } // sprite graphics; reset them - else if (!pObj->SetGraphics()) { pObj->AssignRemoval(); pObj->pGraphics=NULL; } + else if (!pObj->SetGraphics()) { pObj->AssignRemoval(); pObj->pGraphics=nullptr; } } // remove any overlay graphics for (;;) @@ -553,10 +553,10 @@ void C4DefGraphicsPtrBackupEntry::AssignRemoval() C4GUI::FrameDecoration *pDeco; if (pDef && pObj->Menu && (pDeco = pObj->Menu->GetFrameDecoration())) if (pDeco->idSourceDef == pDef->id) - pObj->Menu->SetFrameDeco(NULL); + pObj->Menu->SetFrameDeco(nullptr); } // done; reset field to indicate finished update - pGraphicsPtr = NULL; + pGraphicsPtr = nullptr; } } @@ -626,7 +626,7 @@ C4DefGraphicsPtrBackup::~C4DefGraphicsPtrBackup() void C4DefGraphicsPtrBackup::Add(C4DefGraphics* pGfx) { - for(C4DefGraphics* pCur = pGfx; pCur != NULL; pCur = pCur->pNext) + for(C4DefGraphics* pCur = pGfx; pCur != nullptr; pCur = pCur->pNext) Entries.push_back(new C4DefGraphicsPtrBackupEntry(pCur)); // Remove all mesh materials that were loaded from this definition @@ -699,20 +699,20 @@ void C4DefGraphicsPtrBackup::UpdateMesh(StdMeshInstance* instance) C4GraphicsOverlay::~C4GraphicsOverlay() { // Free mesh instance - delete pMeshInstance; pMeshInstance = NULL; + delete pMeshInstance; pMeshInstance = nullptr; // free any additional overlays C4GraphicsOverlay *pNextOther = pNext, *pOther; while ((pOther = pNextOther)) { pNextOther = pOther->pNext; - pOther->pNext = NULL; + pOther->pNext = nullptr; delete pOther; } } void C4GraphicsOverlay::UpdateFacet() { - // special: Nothing to update for object and pSourceGfx may be NULL + // special: Nothing to update for object and pSourceGfx may be nullptr // If there will ever be something to init here, UpdateFacet() will also need to be called when objects have been loaded if (eMode == MODE_Object) return; // otherwise, source graphics must be specified @@ -721,7 +721,7 @@ void C4GraphicsOverlay::UpdateFacet() assert(pDef); fZoomToShape = false; // Clear old mesh instance, if any - delete pMeshInstance; pMeshInstance = NULL; + delete pMeshInstance; pMeshInstance = nullptr; // update by mode switch (eMode) { @@ -771,7 +771,7 @@ void C4GraphicsOverlay::UpdateFacet() const StdMeshAnimation* Animation = pSourceGfx->Mesh->GetSkeleton().GetAnimationByName(AnimationName->GetData()); if (!Animation) return; - pMeshInstance->PlayAnimation(*Animation, 0, NULL, new C4ValueProviderRef(iPhase, ftofix(Animation->Length / action->GetPropertyInt(P_Length))), new C4ValueProviderConst(itofix(1)), true); + pMeshInstance->PlayAnimation(*Animation, 0, nullptr, new C4ValueProviderRef(iPhase, ftofix(Animation->Length / action->GetPropertyInt(P_Length))), new C4ValueProviderConst(itofix(1)), true); } break; @@ -848,7 +848,7 @@ void C4GraphicsOverlay::CompileFunc(StdCompiler *pComp) // read ID pComp->Value(iID); pComp->Separator(); // read def-graphics - pComp->Value(mkDefaultAdapt(C4DefGraphicsAdapt(pSourceGfx), (C4DefGraphics *)NULL)); + pComp->Value(mkDefaultAdapt(C4DefGraphicsAdapt(pSourceGfx), (C4DefGraphics *)nullptr)); pComp->Separator(); // read mode pComp->Value(mkIntAdapt(eMode)); pComp->Separator(); @@ -873,7 +873,7 @@ void C4GraphicsOverlay::CompileFunc(StdCompiler *pComp) pComp->Value(OverlayObj); else // default - if (pComp->isCompiler()) OverlayObj = NULL; + if (pComp->isCompiler()) OverlayObj = nullptr; // update used facet according to read data if (pComp->isCompiler()) UpdateFacet(); } @@ -886,7 +886,7 @@ void C4GraphicsOverlay::DenumeratePointers() void C4GraphicsOverlay::Draw(C4TargetFacet &cgo, C4Object *pForObj, int32_t iByPlayer) { assert(!IsPicture()); - // note: Also called with pForObj==NULL for editor placement preview + // note: Also called with pForObj==nullptr for editor placement preview // get target pos float offX, offY; float newzoom; @@ -990,7 +990,7 @@ void C4GraphicsOverlay::Draw(C4TargetFacet &cgo, C4Object *pForObj, int32_t iByP C4DrawTransform trf(Transform, offX, offY); // Don't set pForObj because we don't draw the picture of pForObj, but the picture of another definition on top of pForObj: - pSourceGfx->Draw(ccgo, pForObj->Color, NULL, iPhase, 0, &trf); + pSourceGfx->Draw(ccgo, pForObj->Color, nullptr, iPhase, 0, &trf); } else { @@ -1031,7 +1031,7 @@ void C4GraphicsOverlay::Draw(C4TargetFacet &cgo, C4Object *pForObj, int32_t iByP pDraw->SetMeshTransform(&matrix); pDraw->RenderMesh(*pMeshInstance, cgo.Surface, offX - pDef->Shape.Wdt/2.0, offY - pDef->Shape.Hgt/2.0, pDef->Shape.Wdt, pDef->Shape.Hgt, pForObj ? pForObj->Color : 0xff, &trf); - pDraw->SetMeshTransform(NULL); + pDraw->SetMeshTransform(nullptr); } } @@ -1063,7 +1063,7 @@ void C4GraphicsOverlay::DrawRankSymbol(C4Facet &cgo, C4Object *rank_obj) pRankSys = rank_def->pRankNames; iRankCnt = rank_def->pRankNames->GetBaseRankNum(); } - pRankSys->DrawRankSymbol(NULL, rank_obj->Info->Rank, pRankRes, iRankCnt, false, 0, &cgo); + pRankSys->DrawRankSymbol(nullptr, rank_obj->Info->Rank, pRankRes, iRankCnt, false, 0, &cgo); } void C4GraphicsOverlay::DrawPicture(C4Facet &cgo, C4Object *pForObj, C4DrawTransform* trans) @@ -1091,7 +1091,7 @@ void C4GraphicsOverlay::DrawPicture(C4Facet &cgo, C4Object *pForObj, C4DrawTrans if(trans) trf *= *trans; // Don't set pForObj because we don't draw the picture of pForObj, but the picture of another definition on top of pForObj: - pSourceGfx->Draw(cgo, pForObj->Color, NULL, iPhase, 0, &trf); + pSourceGfx->Draw(cgo, pForObj->Color, nullptr, iPhase, 0, &trf); // cleanup if (dwBlitMode == C4GFXBLIT_PARENT) @@ -1124,9 +1124,9 @@ void C4GraphicsOverlayListAdapt::CompileFunc(StdCompiler *pComp) if (pComp->isCompiler()) { // clear list - delete [] pOverlay; pOverlay = NULL; + delete [] pOverlay; pOverlay = nullptr; // read the whole list - C4GraphicsOverlay *pLast = NULL; + C4GraphicsOverlay *pLast = nullptr; bool fContinue; do { @@ -1140,9 +1140,9 @@ void C4GraphicsOverlayListAdapt::CompileFunc(StdCompiler *pComp) { delete e; // delete unused overlay - delete pNext; pNext = NULL; + delete pNext; pNext = nullptr; // clear up - if (!pLast) pOverlay = NULL; + if (!pLast) pOverlay = nullptr; // done return; } @@ -1190,7 +1190,7 @@ void C4GraphicsOverlayListAdapt::CompileFunc(StdCompiler *pComp) C4Surface *C4DefGraphics::GetBitmap(DWORD dwClr) { if (Type != TYPE_Bitmap) - return NULL; + return nullptr; if (Bmp.BitmapClr) { Bmp.BitmapClr->SetClr(dwClr); diff --git a/src/object/C4DefGraphics.h b/src/object/C4DefGraphics.h index bf622c2d7..addef546a 100644 --- a/src/object/C4DefGraphics.h +++ b/src/object/C4DefGraphics.h @@ -60,7 +60,7 @@ public: C4Surface *GetBitmap(DWORD dwClr=0); - C4DefGraphics(C4Def *pOwnDef=NULL); // ctor + C4DefGraphics(C4Def *pOwnDef=nullptr); // ctor virtual ~C4DefGraphics() { Clear(); }; // dtor bool LoadBitmap(C4Group &hGroup, const char *szFilenamePNG, const char *szOverlayPNG, const char *szNormal, bool fColorByOwner); // load specified graphics from group @@ -76,7 +76,7 @@ public: void Draw(C4Facet &cgo, DWORD iColor, C4Object *pObj, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform* trans); - virtual const char *GetName() { return NULL; } // return name to be stored in safe game files + virtual const char *GetName() { return nullptr; } // return name to be stored in safe game files C4AdditionalDefGraphics *GetNext() { return pNext; } @@ -200,9 +200,9 @@ protected: void Set(Mode aMode, C4DefGraphics *pGfx, const char *szAction, DWORD dwBMode, C4Object *pOvrlObj); public: - C4GraphicsOverlay() : eMode(MODE_None), pSourceGfx(NULL), fctBlit(), pMeshInstance(NULL), dwBlitMode(0), dwClrModulation(0xffffff), - OverlayObj(NULL), Transform(+1), - iPhase(0), fZoomToShape(false), iID(0), pNext(NULL) { *Action=0; } // std ctor + C4GraphicsOverlay() : eMode(MODE_None), pSourceGfx(nullptr), fctBlit(), pMeshInstance(nullptr), dwBlitMode(0), dwClrModulation(0xffffff), + OverlayObj(nullptr), Transform(+1), + iPhase(0), fZoomToShape(false), iID(0), pNext(nullptr) { *Action=0; } // std ctor ~C4GraphicsOverlay(); // dtor void CompileFunc(StdCompiler *pComp); @@ -211,21 +211,21 @@ public: void DenumeratePointers(); void SetAsBase(C4DefGraphics *pBaseGfx, DWORD dwBMode) // set in MODE_Base - { Set(MODE_Base, pBaseGfx, NULL, dwBMode, NULL); } + { Set(MODE_Base, pBaseGfx, nullptr, dwBMode, nullptr); } void SetAsAction(C4DefGraphics *pBaseGfx, const char *szAction, DWORD dwBMode) - { Set(MODE_Action, pBaseGfx, szAction, dwBMode, NULL); } + { Set(MODE_Action, pBaseGfx, szAction, dwBMode, nullptr); } void SetAsPicture(C4DefGraphics *pBaseGfx, DWORD dwBMode) - { Set(MODE_Picture, pBaseGfx, NULL, dwBMode, NULL); } + { Set(MODE_Picture, pBaseGfx, nullptr, dwBMode, nullptr); } void SetAsIngamePicture(C4DefGraphics *pBaseGfx, DWORD dwBMode) - { Set(MODE_IngamePicture, pBaseGfx, NULL, dwBMode, NULL); } + { Set(MODE_IngamePicture, pBaseGfx, nullptr, dwBMode, nullptr); } void SetAsObject(C4Object *pOverlayObj, DWORD dwBMode) - { Set(MODE_Object, NULL, NULL, dwBMode, pOverlayObj); } + { Set(MODE_Object, nullptr, nullptr, dwBMode, pOverlayObj); } void SetAsObjectPicture(C4Object *pOverlayObj, DWORD dwBMode) - { Set(MODE_ObjectPicture, NULL, NULL, dwBMode, pOverlayObj); } + { Set(MODE_ObjectPicture, nullptr, nullptr, dwBMode, pOverlayObj); } void SetAsExtraGraphics(C4DefGraphics *pGfx, DWORD dwBMode) - { Set(MODE_ExtraGraphics, pGfx, NULL, dwBMode, NULL); } + { Set(MODE_ExtraGraphics, pGfx, nullptr, dwBMode, nullptr); } void SetAsRank(DWORD dwBMode, C4Object *rank_obj) - { Set(MODE_Rank, NULL, NULL, dwBMode, rank_obj); } + { Set(MODE_Rank, nullptr, nullptr, dwBMode, rank_obj); } bool IsValid(const C4Object *pForObj) const; diff --git a/src/object/C4DefList.cpp b/src/object/C4DefList.cpp index f8097703b..9d4932f2b 100644 --- a/src/object/C4DefList.cpp +++ b/src/object/C4DefList.cpp @@ -42,14 +42,14 @@ namespace if (!def) { DebugLogF("WARNING: Looking up skeleton from definition '%s' failed, because there is no such definition with that ID", definition); - return NULL; + return nullptr; } // append animations, if the definition has a mesh if (!def->Graphics.IsMesh()) { DebugLogF("WARNING: Looking up skeleton from definition '%s' failed, because the definition has no mesh", definition); - return NULL; + return nullptr; } else { @@ -194,7 +194,7 @@ bool C4DefList::Add(C4Def *pDef, bool fOverload) bool C4DefList::Remove(C4ID id) { C4Def *cdef,*prev; - for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next) + for (cdef=FirstDef,prev=nullptr; cdef; prev=cdef,cdef=cdef->Next) if (cdef->id==id) { if (prev) prev->Next=cdef->Next; @@ -208,7 +208,7 @@ bool C4DefList::Remove(C4ID id) void C4DefList::Remove(C4Def *def) { C4Def *cdef,*prev; - for (cdef=FirstDef,prev=NULL; cdef; prev=cdef,cdef=cdef->Next) + for (cdef=FirstDef,prev=nullptr; cdef; prev=cdef,cdef=cdef->Next) if (cdef==def) { if (prev) prev->Next=cdef->Next; @@ -226,7 +226,7 @@ void C4DefList::Clear() next=cdef->Next; delete cdef; } - FirstDef=NULL; + FirstDef=nullptr; // clear quick access table table.clear(); // clear loaded skeletons @@ -235,7 +235,7 @@ void C4DefList::Clear() C4Def* C4DefList::ID2Def(C4ID id) { - if (id==C4ID::None) return NULL; + if (id==C4ID::None) return nullptr; if (table.empty()) { // table not yet built: search list @@ -250,7 +250,7 @@ C4Def* C4DefList::ID2Def(C4ID id) return it->second; } // none found - return NULL; + return nullptr; } C4Def * C4DefList::GetByName(const StdStrBuf & name) @@ -278,19 +278,19 @@ int32_t C4DefList::GetDefCount() C4Def* C4DefList::GetDef(int32_t iIndex) { C4Def *pDef; int32_t iCurrentIndex; - if (iIndex<0) return NULL; + if (iIndex<0) return nullptr; for (pDef=FirstDef,iCurrentIndex=-1; pDef; pDef=pDef->Next) { iCurrentIndex++; if (iCurrentIndex==iIndex) return pDef; } - return NULL; + return nullptr; } std::vector C4DefList::GetAllDefs(C4String *filter_property) const { // Collect vector of all definitions - // Filter for those where property evaluates to true if filter_property!=NULL + // Filter for those where property evaluates to true if filter_property!=nullptr std::vector result; result.reserve(filter_property ? 32 : table.size()); C4Value prop_val; @@ -323,14 +323,14 @@ C4Def *C4DefList::GetByPath(const char *szPath) return pDef; } // not found - return NULL; + return nullptr; } int32_t C4DefList::RemoveTemporary() { C4Def *cdef,*prev,*next; int32_t removed=0; - for (cdef=FirstDef,prev=NULL; cdef; cdef=next) + for (cdef=FirstDef,prev=nullptr; cdef; cdef=next) { next=cdef->Next; if (cdef->Temporary) @@ -352,7 +352,7 @@ int32_t C4DefList::CheckEngineVersion(int32_t ver1, int32_t ver2) { int32_t rcount=0; C4Def *cdef,*prev,*next; - for (cdef=FirstDef,prev=NULL; cdef; cdef=next) + for (cdef=FirstDef,prev=nullptr; cdef; cdef=next) { next=cdef->Next; if (CompareVersion(cdef->rC4XVer[0],cdef->rC4XVer[1],ver1,ver2) > 0) @@ -374,7 +374,7 @@ int32_t C4DefList::CheckRequireDef() do { rcount2 = rcount; - for (cdef=FirstDef,prev=NULL; cdef; cdef=next) + for (cdef=FirstDef,prev=nullptr; cdef; cdef=next) { next=cdef->Next; for (int32_t i = 0; i < cdef->RequireDef.GetNumberOfIDs(); i++) @@ -398,7 +398,7 @@ void C4DefList::Draw(C4ID id, C4Facet &cgo, bool fSelected, int32_t iColor) void C4DefList::Default() { - FirstDef=NULL; + FirstDef=nullptr; LoadFailure=false; table.clear(); } diff --git a/src/object/C4DefList.h b/src/object/C4DefList.h index b870d4ef5..ed1b4cbf0 100644 --- a/src/object/C4DefList.h +++ b/src/object/C4DefList.h @@ -38,16 +38,16 @@ public: void Clear(); int32_t Load(C4Group &hGroup, DWORD dwLoadWhat, const char *szLanguage, - C4SoundSystem *pSoundSystem = NULL, + C4SoundSystem *pSoundSystem = nullptr, bool fOverload = false, bool fSearchMessage = false, int32_t iMinProgress=0, int32_t iMaxProgress=0, bool fLoadSysGroups = true); int32_t Load(const char *szFilename, DWORD dwLoadWhat, const char *szLanguage, - C4SoundSystem *pSoundSystem = NULL, + C4SoundSystem *pSoundSystem = nullptr, bool fOverload = false, int32_t iMinProgress=0, int32_t iMaxProgress=0); C4Def *ID2Def(C4ID id); C4Def *GetDef(int32_t Index); - std::vector GetAllDefs(C4String *filter_property=NULL) const; + std::vector GetAllDefs(C4String *filter_property=nullptr) const; C4Def *GetByPath(const char *szPath); C4Def *GetByName(const StdStrBuf &); int32_t GetDefCount(); @@ -58,7 +58,7 @@ public: void Draw(C4ID id, C4Facet &cgo, bool fSelected, int32_t iColor); void Remove(C4Def *def); bool Remove(C4ID id); - bool Reload(C4Def *pDef, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem = NULL); + bool Reload(C4Def *pDef, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem = nullptr); bool Add(C4Def *ndef, bool fOverload); void BuildTable(); void ResetIncludeDependencies(); // resets all pointers into foreign definitions caused by include chains diff --git a/src/object/C4FindObject.cpp b/src/object/C4FindObject.cpp index f823f714d..a56f0f64a 100644 --- a/src/object/C4FindObject.cpp +++ b/src/object/C4FindObject.cpp @@ -35,7 +35,7 @@ C4FindObject *C4FindObject::CreateByValue(const C4Value &DataVal, C4SortObject * { // Must be an array C4ValueArray *pArray = C4Value(DataVal).getArray(); - if (!pArray) return NULL; + if (!pArray) return nullptr; const C4ValueArray &Data = *pArray; int32_t iType = Data[0].getInt(); @@ -43,11 +43,11 @@ C4FindObject *C4FindObject::CreateByValue(const C4Value &DataVal, C4SortObject * { // this is not a FindObject but a sort condition! // sort condition not desired here? - if (!ppSortObj) return NULL; + if (!ppSortObj) return nullptr; // otherwise, create it! *ppSortObj = C4SortObject::CreateByValue(iType, Data, context); // done - return NULL; + return nullptr; } switch (iType) @@ -56,7 +56,7 @@ C4FindObject *C4FindObject::CreateByValue(const C4Value &DataVal, C4SortObject * { // Create child condition C4FindObject *pCond = C4FindObject::CreateByValue(Data[1], nullptr, context, has_layer_check); - if (!pCond) return NULL; + if (!pCond) return nullptr; // wrap return new C4FindObjectNot(pCond); } @@ -169,7 +169,7 @@ C4FindObject *C4FindObject::CreateByValue(const C4Value &DataVal, C4SortObject * case C4FO_Action: { C4String *pStr = Data[1].getStr(); - if (!pStr) return NULL; + if (!pStr) return nullptr; // Don't copy, it should be safe return new C4FindObjectAction(pStr->GetCStr()); } @@ -178,7 +178,7 @@ C4FindObject *C4FindObject::CreateByValue(const C4Value &DataVal, C4SortObject * { // Get function name C4String *pStr = Data[1].getStr(); - if (!pStr) return NULL; + if (!pStr) return nullptr; // Construct C4FindObjectFunc *pFO = new C4FindObjectFunc(pStr); // Add parameters @@ -223,7 +223,7 @@ C4FindObject *C4FindObject::CreateByValue(const C4Value &DataVal, C4SortObject * { // Get property name C4String *pStr = Data[1].getStr(); - if (!pStr) return NULL; + if (!pStr) return nullptr; // Construct C4FindObjectProperty *pFO = new C4FindObjectProperty(pStr); // Done @@ -233,10 +233,10 @@ C4FindObject *C4FindObject::CreateByValue(const C4Value &DataVal, C4SortObject * case C4FO_AnyLayer: // do not add implicit layer check if (has_layer_check) *has_layer_check = true; - return NULL; + return nullptr; } - return NULL; + return nullptr; } int32_t C4FindObject::Count(const C4ObjectList &Objs) @@ -258,10 +258,10 @@ C4Object *C4FindObject::Find(const C4ObjectList &Objs) { // Trivial case if (IsImpossible()) - return NULL; + return nullptr; // Search // Double-check object status, as object might be deleted after Check()! - C4Object *pBestResult = NULL; + C4Object *pBestResult = nullptr; for (C4Object *obj : Objs) if (obj->Status) if (Check(obj)) @@ -354,8 +354,8 @@ C4Object *C4FindObject::Find(const C4ObjectList &Objs, const C4LSectors &Sct) { // Trivial case if (IsImpossible()) - return NULL; - C4Object *pBestResult = NULL; + return nullptr; + C4Object *pBestResult = nullptr; // Check bounds C4Rect *pBounds = GetBounds(); if (!pBounds) @@ -826,7 +826,7 @@ C4SortObject *C4SortObject::CreateByValue(const C4Value &DataVal, const C4Object { // Must be an array const C4ValueArray *pArray = C4Value(DataVal).getArray(); - if (!pArray) return NULL; + if (!pArray) return nullptr; const C4ValueArray &Data = *pArray; int32_t iType = Data[0].getInt(); return CreateByValue(iType, Data, context); @@ -840,7 +840,7 @@ C4SortObject *C4SortObject::CreateByValue(int32_t iType, const C4ValueArray &Dat { // create child sort C4SortObject *pChildSort = C4SortObject::CreateByValue(Data[1], context); - if (!pChildSort) return NULL; + if (!pChildSort) return nullptr; // wrap return new C4SortObjectReverse(pChildSort); } @@ -897,7 +897,7 @@ C4SortObject *C4SortObject::CreateByValue(int32_t iType, const C4ValueArray &Dat { // Get function name C4String *pStr = Data[1].getStr(); - if (!pStr) return NULL; + if (!pStr) return nullptr; // Construct C4SortObjectFunc *pSO = new C4SortObjectFunc(pStr); // Add parameters @@ -908,7 +908,7 @@ C4SortObject *C4SortObject::CreateByValue(int32_t iType, const C4ValueArray &Dat } } - return NULL; + return nullptr; } void C4SortObject::SortObjects(C4ValueArray *pArray) @@ -919,19 +919,19 @@ void C4SortObject::SortObjects(C4ValueArray *pArray) // *** C4SortObjectByValue C4SortObjectByValue::C4SortObjectByValue() - : C4SortObject(), pVals(NULL), iSize(0) + : C4SortObject(), pVals(nullptr), iSize(0) { } C4SortObjectByValue::~C4SortObjectByValue() { - delete [] pVals; pVals = NULL; + delete [] pVals; pVals = nullptr; } bool C4SortObjectByValue::PrepareCache(const C4ValueArray *pObjs) { // Clear old cache - delete [] pVals; pVals = NULL; iSize = 0; + delete [] pVals; pVals = nullptr; iSize = 0; // Create new cache iSize = pObjs->GetSize(); pVals = new int32_t [iSize]; for (int32_t i = 0; i < iSize; i++) @@ -1037,7 +1037,7 @@ int32_t C4SortObjectMass::CompareGetValue(C4Object *pFor) int32_t C4SortObjectValue::CompareGetValue(C4Object *pFor) { - return pFor->GetValue(NULL, NO_OWNER); + return pFor->GetValue(nullptr, NO_OWNER); } void C4SortObjectFunc::SetPar(int i, const C4Value &Par) diff --git a/src/object/C4FindObject.h b/src/object/C4FindObject.h index 9973d0294..30599d8c0 100644 --- a/src/object/C4FindObject.h +++ b/src/object/C4FindObject.h @@ -73,10 +73,10 @@ class C4FindObject class C4SortObject *pSort; public: - C4FindObject() : pSort(NULL) { } + C4FindObject() : pSort(nullptr) { } virtual ~C4FindObject(); - static C4FindObject *CreateByValue(const C4Value &Data, C4SortObject **ppSortObj=NULL, const C4Object *context=NULL, bool *has_layer_check=NULL); // createFindObject or SortObject - if ppSortObj==NULL, SortObject is not allowed + static C4FindObject *CreateByValue(const C4Value &Data, C4SortObject **ppSortObj=nullptr, const C4Object *context=nullptr, bool *has_layer_check=nullptr); // createFindObject or SortObject - if ppSortObj==nullptr, SortObject is not allowed int32_t Count(const C4ObjectList &Objs); // Counts objects for which the condition is true C4Object *Find(const C4ObjectList &Objs); // Returns first object for which the condition is true @@ -91,7 +91,7 @@ public: protected: // Overridables virtual bool Check(C4Object *pObj) = 0; - virtual C4Rect *GetBounds() { return NULL; } + virtual C4Rect *GetBounds() { return nullptr; } virtual bool UseShapes() { return false; } virtual bool IsImpossible() { return false; } virtual bool IsEnsured() { return false; } @@ -126,11 +126,11 @@ private: C4Rect Bounds; bool fHasBounds; protected: virtual bool Check(C4Object *pObj); - virtual C4Rect *GetBounds() { return fHasBounds ? &Bounds : NULL; } + virtual C4Rect *GetBounds() { return fHasBounds ? &Bounds : nullptr; } virtual bool UseShapes() { return fUseShapes; } virtual bool IsEnsured() { return !iCnt; } virtual bool IsImpossible(); - void ForgetConditions() { ppConds=NULL; iCnt=0; } + void ForgetConditions() { ppConds=nullptr; iCnt=0; } }; // Special variant of C4FindObjectAnd that does not free its conditions @@ -153,7 +153,7 @@ private: C4Rect Bounds; bool fHasBounds; protected: virtual bool Check(C4Object *pObj); - virtual C4Rect *GetBounds() { return fHasBounds ? &Bounds : NULL; } + virtual C4Rect *GetBounds() { return fHasBounds ? &Bounds : nullptr; } virtual bool UseShapes() { return fUseShapes; } virtual bool IsEnsured(); virtual bool IsImpossible() { return !iCnt; } @@ -412,8 +412,8 @@ public: virtual int32_t CompareCache(int32_t iObj1, int32_t iObj2, C4Object *pObj1, C4Object *pObj2) { return Compare(pObj1, pObj2); } public: - static C4SortObject *CreateByValue(const C4Value &Data, const C4Object *context=NULL); - static C4SortObject *CreateByValue(int32_t iType, const C4ValueArray &Data, const C4Object *context=NULL); + static C4SortObject *CreateByValue(const C4Value &Data, const C4Object *context=nullptr); + static C4SortObject *CreateByValue(int32_t iType, const C4ValueArray &Data, const C4Object *context=nullptr); void SortObjects(C4ValueArray *pArray); }; diff --git a/src/object/C4GameObjects.cpp b/src/object/C4GameObjects.cpp index 997f9488e..111b87dc8 100644 --- a/src/object/C4GameObjects.cpp +++ b/src/object/C4GameObjects.cpp @@ -166,10 +166,10 @@ C4Object* C4GameObjects::AtObject(int ctx, int cty, DWORD &ocf, C4Object *exclud // Search match if (cocf & ocf) { ocf=cocf; return cObj; } // EXCLUSIVE block - else return NULL; + else return nullptr; } } - return NULL; + return nullptr; } void C4GameObjects::Synchronize() @@ -191,7 +191,7 @@ C4Object *C4GameObjects::ObjectPointer(int32_t iNumber) C4Object *C4GameObjects::SafeObjectPointer(int32_t iNumber) { C4Object *pObj = ObjectPointer(iNumber); - if (pObj) if (!pObj->Status) return NULL; + if (pObj) if (!pObj->Status) return nullptr; return pObj; } @@ -381,8 +381,8 @@ void C4GameObjects::FixObjectOrder() C4ObjectLink *pLnk0=First, *pLnkL=Last; while (pLnk0 != pLnkL) { - C4ObjectLink *pLnk1stUnsorted=NULL, *pLnkLastUnsorted=NULL, *pLnkPrev=NULL, *pLnk; - C4Object *pLastWarnObj = NULL; + C4ObjectLink *pLnk1stUnsorted=nullptr, *pLnkLastUnsorted=nullptr, *pLnkPrev=nullptr, *pLnk; + C4Object *pLastWarnObj = nullptr; // forward fix int lastPlane = 2147483647; //INT32_MAX; for (pLnk = pLnk0; pLnk!=pLnkL->Next; pLnk=pLnk->Next) diff --git a/src/object/C4GameObjects.h b/src/object/C4GameObjects.h index 18823962d..97f22171b 100644 --- a/src/object/C4GameObjects.h +++ b/src/object/C4GameObjects.h @@ -50,7 +50,7 @@ public: C4ObjectList &ObjectsAt(int ix, int iy); // get object list for map pos void CrossCheck(); // various collision-checks - C4Object *AtObject(int ctx, int cty, DWORD &ocf, C4Object *exclude=NULL); // find object at ctx/cty + C4Object *AtObject(int ctx, int cty, DWORD &ocf, C4Object *exclude=nullptr); // find object at ctx/cty void Synchronize(); // network synchronization void UpdateSolidMasks(); diff --git a/src/object/C4IDList.cpp b/src/object/C4IDList.cpp index 499f36794..dd1d9afaf 100644 --- a/src/object/C4IDList.cpp +++ b/src/object/C4IDList.cpp @@ -28,7 +28,7 @@ C4IDListChunk::C4IDListChunk() { // prepare list - pNext=NULL; + pNext=nullptr; } C4IDListChunk::~C4IDListChunk() @@ -43,10 +43,10 @@ void C4IDListChunk::Clear() C4IDListChunk *pChunk=pNext,*pChunk2; while (pChunk) { - pChunk2=pChunk->pNext; pChunk->pNext=NULL; + pChunk2=pChunk->pNext; pChunk->pNext=nullptr; delete pChunk; pChunk=pChunk2; } - pNext=NULL; + pNext=nullptr; } C4IDList::C4IDList() : C4IDListChunk() @@ -74,7 +74,7 @@ C4IDList &C4IDList::operator = (const C4IDList &rCopy) pTo->pNext=pNew; pTo=pNew; } // finalize - pTo->pNext=NULL; + pTo->pNext=nullptr; return *this; } diff --git a/src/object/C4IDList.h b/src/object/C4IDList.h index 153486667..dbc1dda7b 100644 --- a/src/object/C4IDList.h +++ b/src/object/C4IDList.h @@ -59,7 +59,7 @@ public: void Clear(); bool IsClear() const; // Access by direct index - C4ID GetID(size_t index, int32_t *ipCount=NULL) const; + C4ID GetID(size_t index, int32_t *ipCount=nullptr) const; int32_t GetCount(size_t index) const; bool SetCount(size_t index, int32_t iCount); // Access by ID @@ -71,7 +71,7 @@ public: int32_t GetNumberOfIDs() const; int32_t GetIndex(C4ID c_id) const; // Access by category-sorted index - C4ID GetID(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t *ipCount=NULL) const; + C4ID GetID(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t *ipCount=nullptr) const; int32_t GetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index) const; bool SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount); int32_t GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const; diff --git a/src/object/C4InfoCore.cpp b/src/object/C4InfoCore.cpp index 3af7be8e0..956d40a26 100644 --- a/src/object/C4InfoCore.cpp +++ b/src/object/C4InfoCore.cpp @@ -189,7 +189,7 @@ void C4ObjectInfoCore::Default(C4ID n_id, { // Def - C4Def *pDef=NULL; + C4Def *pDef=nullptr; if (pDefs) pDef = pDefs->ID2Def(n_id); // Defaults @@ -357,7 +357,7 @@ bool C4ObjectInfoCore::Decompile(char **ppOutput, size_t *ipSize) &Buf, "ObjectInfo")) { - if (ppOutput) *ppOutput = NULL; + if (ppOutput) *ppOutput = nullptr; if (ipSize) *ipSize = 0; return false; } diff --git a/src/object/C4InfoCore.h b/src/object/C4InfoCore.h index 1c4a94177..d8183a76d 100644 --- a/src/object/C4InfoCore.h +++ b/src/object/C4InfoCore.h @@ -51,7 +51,7 @@ public: public: bool Save(C4Group &hGroup, class C4DefList *pDefs); bool Load(C4Group &hGroup); - void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=NULL, const char *cpNames=NULL); + void Default(C4ID n_id=C4ID::None, class C4DefList *pDefs=nullptr, const char *cpNames=nullptr); void Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName); bool GetNextRankInfo(C4RankSystem &rDefaultRanks, int32_t *piNextRankExp, StdStrBuf *psNextRankName); void CompileFunc(StdCompiler *pComp); @@ -109,7 +109,7 @@ public: // achievements indexed by achievement name and scenario C4ScenarioParameters Achievements; public: - void Default(C4RankSystem *pRanks=NULL); + void Default(C4RankSystem *pRanks=nullptr); void Promote(int32_t iRank, C4RankSystem &rRanks); bool Load(C4Group &hGroup); bool Save(C4Group &hGroup); diff --git a/src/object/C4MeshAnimation.cpp b/src/object/C4MeshAnimation.cpp index 1f4a0b17b..5c8a4f9dd 100644 --- a/src/object/C4MeshAnimation.cpp +++ b/src/object/C4MeshAnimation.cpp @@ -65,13 +65,13 @@ StdMeshInstance::ValueProvider* CreateValueProviderFromArray(C4Object* pForObj, return new C4ValueProviderLinear(itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(end, 1000), len, static_cast(Data[5].getInt())); } case C4AVP_X: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; if (Data[4].getInt() == 0) throw C4AulExecError("Length cannot be zero"); return new C4ValueProviderX(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(), 1000), Data[4].getInt()); case C4AVP_Y: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; if (Data[4].getInt() == 0) throw C4AulExecError("Length cannot be zero"); @@ -79,61 +79,61 @@ StdMeshInstance::ValueProvider* CreateValueProviderFromArray(C4Object* pForObj, case C4AVP_R: if(Data.GetSize() >= 4 && Data[3] != C4VNull) pForObj = Data[3].getObj(); - if (!pForObj) return NULL; + if (!pForObj) return nullptr; return new C4ValueProviderR(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000)); case C4AVP_AbsX: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; if (Data[4].getInt() == 0) throw C4AulExecError("Length cannot be zero"); return new C4ValueProviderAbsX(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(), 1000), Data[4].getInt()); case C4AVP_AbsY: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; if (Data[4].getInt() == 0) throw C4AulExecError("Length cannot be zero"); return new C4ValueProviderAbsY(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(), 1000), Data[4].getInt()); case C4AVP_Dist: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; if (Data[4].getInt() == 0) throw C4AulExecError("Length cannot be zero"); return new C4ValueProviderDist(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(), 1000), Data[4].getInt()); case C4AVP_XDir: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; if (Data[3].getInt() == 0) throw C4AulExecError("MaxXDir cannot be zero"); return new C4ValueProviderXDir(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(),Data[4].getInt())); case C4AVP_YDir: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; if (Data[3].getInt() == 0) throw C4AulExecError("MaxYDir cannot be zero"); return new C4ValueProviderYDir(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(),Data[4].getInt())); case C4AVP_RDir: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; if (Data[4].getInt() - Data[3].getInt() == 0) throw C4AulExecError("MaxRDir - MinRDir cannot be zero"); return new C4ValueProviderRDir(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(),Data[5].getInt()), itofix(Data[4].getInt(),Data[5].getInt())); case C4AVP_AbsRDir: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; if (Data[4].getInt() - Data[3].getInt() == 0) throw C4AulExecError("MaxRDir - MinRDir cannot be zero"); return new C4ValueProviderAbsRDir(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(),Data[5].getInt()), itofix(Data[4].getInt(),Data[5].getInt())); case C4AVP_CosR: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; return new C4ValueProviderCosR(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(),Data[4].getInt())); case C4AVP_SinR: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; return new C4ValueProviderSinR(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(),Data[4].getInt())); case C4AVP_CosV: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; return new C4ValueProviderCosV(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(),Data[4].getInt())); case C4AVP_SinV: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; return new C4ValueProviderSinV(pForObj, itofix(Data[1].getInt(), 1000), itofix(Data[2].getInt(), 1000), itofix(Data[3].getInt(),Data[4].getInt())); case C4AVP_Action: - if (!pForObj) return NULL; + if (!pForObj) return nullptr; return new C4ValueProviderAction(pForObj); default: - return NULL; + return nullptr; } } @@ -187,7 +187,7 @@ void C4ValueProviderLinear::CompileFunc(StdCompiler* pComp) { "Hold", ANIM_Hold }, { "Remove", ANIM_Remove }, - { NULL, static_cast(0) } + { nullptr, static_cast(0) } }; SerializableValueProvider::CompileFunc(pComp); diff --git a/src/object/C4MeshAnimation.h b/src/object/C4MeshAnimation.h index ac784cef4..d1230677b 100644 --- a/src/object/C4MeshAnimation.h +++ b/src/object/C4MeshAnimation.h @@ -80,13 +80,13 @@ private: class C4ValueProviderX: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderX(): Object(NULL), Begin(Fix0), End(Fix0), Length(0) {} + C4ValueProviderX(): Object(nullptr), Begin(Fix0), End(Fix0), Length(0) {} C4ValueProviderX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -97,13 +97,13 @@ private: class C4ValueProviderY: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderY(): Object(NULL), Begin(Fix0), End(Fix0), Length(0) {} + C4ValueProviderY(): Object(nullptr), Begin(Fix0), End(Fix0), Length(0) {} C4ValueProviderY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -114,13 +114,13 @@ private: class C4ValueProviderR: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderR(): Object(NULL), Begin(Fix0), End(Fix0) {} + C4ValueProviderR(): Object(nullptr), Begin(Fix0), End(Fix0) {} C4ValueProviderR(C4Object* object, C4Real begin, C4Real end); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -130,13 +130,13 @@ private: class C4ValueProviderAbsX: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderAbsX(): Object(NULL), Begin(Fix0), End(Fix0), Length(0) {} + C4ValueProviderAbsX(): Object(nullptr), Begin(Fix0), End(Fix0), Length(0) {} C4ValueProviderAbsX(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -147,13 +147,13 @@ private: class C4ValueProviderAbsY: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderAbsY(): Object(NULL), Begin(Fix0), End(Fix0), Length(0) {} + C4ValueProviderAbsY(): Object(nullptr), Begin(Fix0), End(Fix0), Length(0) {} C4ValueProviderAbsY(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -164,13 +164,13 @@ private: class C4ValueProviderDist: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderDist(): Object(NULL), Begin(Fix0), End(Fix0), Length(0) {} + C4ValueProviderDist(): Object(nullptr), Begin(Fix0), End(Fix0), Length(0) {} C4ValueProviderDist(C4Object* object, C4Real pos, C4Real begin, C4Real end, int32_t length); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -181,13 +181,13 @@ private: class C4ValueProviderXDir: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderXDir(): Object(NULL), Begin(Fix0), End(Fix0), MaxXDir(Fix0) {} + C4ValueProviderXDir(): Object(nullptr), Begin(Fix0), End(Fix0), MaxXDir(Fix0) {} C4ValueProviderXDir(C4Object* object, C4Real begin, C4Real end, C4Real max_xdir); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -198,13 +198,13 @@ private: class C4ValueProviderYDir: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderYDir(): Object(NULL), Begin(Fix0), End(Fix0), MaxYDir(Fix0) {} + C4ValueProviderYDir(): Object(nullptr), Begin(Fix0), End(Fix0), MaxYDir(Fix0) {} C4ValueProviderYDir(C4Object* object, C4Real begin, C4Real end, C4Real max_ydir); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -215,13 +215,13 @@ private: class C4ValueProviderRDir: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderRDir(): Object(NULL), Begin(Fix0), End(Fix0), MinRDir(Fix0), MaxRDir(Fix0) {} + C4ValueProviderRDir(): Object(nullptr), Begin(Fix0), End(Fix0), MinRDir(Fix0), MaxRDir(Fix0) {} C4ValueProviderRDir(C4Object* object, C4Real begin, C4Real end, C4Real min_rdir, C4Real max_rdir); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -233,13 +233,13 @@ private: class C4ValueProviderAbsRDir: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderAbsRDir(): Object(NULL), Begin(Fix0), End(Fix0), MinRDir(Fix0), MaxRDir(Fix0) {} + C4ValueProviderAbsRDir(): Object(nullptr), Begin(Fix0), End(Fix0), MinRDir(Fix0), MaxRDir(Fix0) {} C4ValueProviderAbsRDir(C4Object* object, C4Real begin, C4Real end, C4Real min_rdir, C4Real max_rdir); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -251,13 +251,13 @@ private: class C4ValueProviderCosR: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderCosR(): Object(NULL), Begin(Fix0), End(Fix0), Offset(Fix0) {} + C4ValueProviderCosR(): Object(nullptr), Begin(Fix0), End(Fix0), Offset(Fix0) {} C4ValueProviderCosR(C4Object* object, C4Real begin, C4Real end, C4Real offset); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -268,13 +268,13 @@ private: class C4ValueProviderSinR: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderSinR(): Object(NULL), Begin(Fix0), End(Fix0), Offset(Fix0) {} + C4ValueProviderSinR(): Object(nullptr), Begin(Fix0), End(Fix0), Offset(Fix0) {} C4ValueProviderSinR(C4Object* object, C4Real begin, C4Real end, C4Real offset); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -285,13 +285,13 @@ private: class C4ValueProviderCosV: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderCosV(): Object(NULL), Begin(Fix0), End(Fix0), Offset(Fix0) {} + C4ValueProviderCosV(): Object(nullptr), Begin(Fix0), End(Fix0), Offset(Fix0) {} C4ValueProviderCosV(C4Object* object, C4Real begin, C4Real end, C4Real offset); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -302,13 +302,13 @@ private: class C4ValueProviderSinV: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderSinV(): Object(NULL), Begin(Fix0), End(Fix0), Offset(Fix0) {} + C4ValueProviderSinV(): Object(nullptr), Begin(Fix0), End(Fix0), Offset(Fix0) {} C4ValueProviderSinV(C4Object* object, C4Real begin, C4Real end, C4Real offset); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; C4Real Begin; @@ -319,13 +319,13 @@ private: class C4ValueProviderAction: public StdMeshInstance::SerializableValueProvider { public: - C4ValueProviderAction(): Object(NULL) {} + C4ValueProviderAction(): Object(nullptr) {} C4ValueProviderAction(C4Object* object); virtual bool Execute(); virtual void CompileFunc(StdCompiler* pComp); virtual void DenumeratePointers() { Object.DenumeratePointers(); } - virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = NULL; } + virtual void ClearPointers(C4Object* pObj) { if(Object == pObj) Object = nullptr; } private: C4ObjectPtr Object; }; @@ -349,6 +349,6 @@ private: C4Real Scale; }; -StdMeshInstance::ValueProvider* CreateValueProviderFromArray(C4Object* pForObj, C4ValueArray& Data, const StdMeshAnimation* pos_for_animation = NULL); +StdMeshInstance::ValueProvider* CreateValueProviderFromArray(C4Object* pForObj, C4ValueArray& Data, const StdMeshAnimation* pos_for_animation = nullptr); #endif diff --git a/src/object/C4MeshDenumerator.cpp b/src/object/C4MeshDenumerator.cpp index 9fe8a7463..5ae499c70 100644 --- a/src/object/C4MeshDenumerator.cpp +++ b/src/object/C4MeshDenumerator.cpp @@ -31,7 +31,7 @@ void C4MeshDenumerator::CompileFunc(StdCompiler* pComp, StdMeshInstance::Attache if(def) { - C4DefGraphics* pGfx = NULL; + C4DefGraphics* pGfx = nullptr; pComp->Value(mkNamingAdapt(C4DefGraphicsAdapt(pGfx), "ChildMesh")); Def = pGfx->pDef; @@ -39,7 +39,7 @@ void C4MeshDenumerator::CompileFunc(StdCompiler* pComp, StdMeshInstance::Attache pComp->excCorrupt("ChildMesh points to non-mesh graphics"); assert(!attach->Child); pComp->Value(mkParAdapt(mkNamingContextPtrAdapt(attach->Child, *pGfx->Mesh, "ChildInstance"), C4MeshDenumeratorFactory)); - assert(attach->Child != NULL); + assert(attach->Child != nullptr); attach->OwnChild = true; // Delete the newly allocated child instance when the parent instance is gone // TODO: Do we leak pGfx? @@ -90,7 +90,7 @@ bool C4MeshDenumerator::ClearPointers(C4Object* pObj) { if(Object == pObj) { - Object = NULL; + Object = nullptr; // Return false causes the attached mesh to be deleted by StdMeshInstance return false; } diff --git a/src/object/C4MeshDenumerator.h b/src/object/C4MeshDenumerator.h index 159819d11..a415e2aa0 100644 --- a/src/object/C4MeshDenumerator.h +++ b/src/object/C4MeshDenumerator.h @@ -26,9 +26,9 @@ private: C4ObjectPtr Object; // Set if an instance mesh was attached public: - C4MeshDenumerator(): Def(NULL), Object(NULL) {} - C4MeshDenumerator(C4Def* def): Def(def), Object(NULL) {} - C4MeshDenumerator(C4Object* object): Def(NULL), Object(object) {} + C4MeshDenumerator(): Def(nullptr), Object(nullptr) {} + C4MeshDenumerator(C4Def* def): Def(def), Object(nullptr) {} + C4MeshDenumerator(C4Object* object): Def(nullptr), Object(object) {} C4Object* GetObject() { return Object; } diff --git a/src/object/C4Object.cpp b/src/object/C4Object.cpp index 92ae80cb2..ebd401990 100644 --- a/src/object/C4Object.cpp +++ b/src/object/C4Object.cpp @@ -129,24 +129,24 @@ void C4Object::Default() Contents.Default(); SolidMask.Default(); PictureRect.Default(); - Def=NULL; - Info=NULL; - Command=NULL; - Contained=NULL; + Def=nullptr; + Info=nullptr; + Command=nullptr; + Contained=nullptr; TopFace.Default(); - Menu=NULL; - MaterialContents=NULL; + Menu=nullptr; + MaterialContents=nullptr; Marker=0; ColorMod=0xffffffff; BlitMode=0; CrewDisabled=false; - Layer=NULL; - pSolidMaskData=NULL; - pGraphics=NULL; - pMeshInstance=NULL; - pDrawTransform=NULL; - pEffects=NULL; - pGfxOverlay=NULL; + Layer=nullptr; + pSolidMaskData=nullptr; + pGraphics=nullptr; + pMeshInstance=nullptr; + pDrawTransform=nullptr; + pEffects=nullptr; + pGfxOverlay=nullptr; iLastAttachMovementFrame=-1; ClearParticleLists(); @@ -184,7 +184,7 @@ bool C4Object::Init(C4PropList *pDef, C4Object *pCreator, } else { - pMeshInstance = NULL; + pMeshInstance = nullptr; } BlitMode = Def->BlitMode; @@ -315,7 +315,7 @@ void C4Object::AssignRemoval(bool fExitContents) else { Contents.Remove(cobj); - cobj->Contained = NULL; + cobj->Contained = nullptr; cobj->AssignRemoval(); } } @@ -325,11 +325,11 @@ void C4Object::AssignRemoval(bool fExitContents) pCont->Contents.Remove(this); pCont->UpdateMass(); pCont->SetOCF(); - Contained=NULL; + Contained=nullptr; } // Object info if (Info) Info->Retire(); - Info = NULL; + Info = nullptr; // Object system operation ClearRefs(); Game.ClearPointers(this); @@ -337,7 +337,7 @@ void C4Object::AssignRemoval(bool fExitContents) if (pSolidMaskData) { delete pSolidMaskData; - pSolidMaskData = NULL; + pSolidMaskData = nullptr; } SolidMask.Wdt = 0; RemovalDelay=2; @@ -416,7 +416,7 @@ void C4Object::UpdateGraphics(bool fGraphicsChanged, bool fTemp) &pMeshInstance->GetMesh() != pGraphics->Mesh) { // If this mesh is attached somewhere, detach it before deletion - if(pMeshInstance && pMeshInstance->GetAttachParent() != NULL) + if(pMeshInstance && pMeshInstance->GetAttachParent() != nullptr) { // TODO: If the new mesh has a bone with the same name, we could try updating... StdMeshInstance::AttachedMesh* attach_parent = pMeshInstance->GetAttachParent(); @@ -432,7 +432,7 @@ void C4Object::UpdateGraphics(bool fGraphicsChanged, bool fTemp) } else { - pMeshInstance = NULL; + pMeshInstance = nullptr; } } @@ -473,7 +473,7 @@ void C4Object::UpdateFlipDir() if (pDrawTransform->IsIdentity()) { delete pDrawTransform; - pDrawTransform=NULL; + pDrawTransform=nullptr; } } } @@ -523,7 +523,7 @@ void C4Object::DrawFaceImpl(C4TargetFacet &cgo, bool action, float fx, float fy, pDraw->SetMeshTransform(&matrix); pDraw->RenderMesh(*pMeshInstance, cgo.Surface, tx, ty, twdt, thgt, Color, transform); - pDraw->SetMeshTransform(NULL); + pDraw->SetMeshTransform(nullptr); break; } } @@ -572,7 +572,7 @@ void C4Object::DrawFace(C4TargetFacet &cgo, float offX, float offY, int32_t iPha transform_active = true; } - DrawFaceImpl(cgo, false, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform : NULL); + DrawFaceImpl(cgo, false, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform : nullptr); } void C4Object::DrawActionFace(C4TargetFacet &cgo, float offX, float offY) const @@ -636,7 +636,7 @@ void C4Object::DrawActionFace(C4TargetFacet &cgo, float offX, float offY) const transform_active = true; } - DrawFaceImpl(cgo, true, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform : NULL); + DrawFaceImpl(cgo, true, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform : nullptr); } void C4Object::UpdateMass() @@ -1047,7 +1047,7 @@ void C4Object::AssignDeath(bool fForced) if(pPlr) if(!pPlr->Crew.ObjectCount()) ::Game.GRBroadcast(PSF_RelaunchPlayer, - &C4AulParSet(Owner, iDeathCausingPlayer, Status ? this : NULL)); + &C4AulParSet(Owner, iDeathCausingPlayer, Status ? this : nullptr)); if (pInfo) pInfo->HasDied = false; } @@ -1065,7 +1065,7 @@ bool C4Object::ChangeDef(C4ID idNew) SetAction(0); ResetProperty(&Strings.P[P_Action]); // Enforce ActIdle because SetAction may have failed due to NoOtherAction SetDir(0); // will drop any outdated flipdir - if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=NULL; } + if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; } Def->Count--; // Def change Def=pDef; @@ -1239,7 +1239,7 @@ void C4Object::DoExperience(int32_t change) bool C4Object::Exit(int32_t iX, int32_t iY, int32_t iR, C4Real iXDir, C4Real iYDir, C4Real iRDir, bool fCalls) { // 1. Exit the current container. - // 2. Update Contents of container object and set Contained to NULL. + // 2. Update Contents of container object and set Contained to nullptr. // 3. Set offset position/motion if desired. // 4. Call Ejection for container and Departure for object. @@ -1251,7 +1251,7 @@ bool C4Object::Exit(int32_t iX, int32_t iY, int32_t iR, C4Real iXDir, C4Real iYD pContainer->UpdateMass(); pContainer->SetOCF(); // No container - Contained=NULL; + Contained=nullptr; // Position/motion fix_x=itofix(iX); fix_y=itofix(iY); fix_r=itofix(iR); @@ -1264,7 +1264,7 @@ bool C4Object::Exit(int32_t iX, int32_t iY, int32_t iR, C4Real iXDir, C4Real iYD UpdateFace(true); SetOCF(); // Object list callback (before script callbacks, because script callbacks may enter again) - ObjectListChangeListener.OnObjectContainerChanged(this, pContainer, NULL); + ObjectListChangeListener.OnObjectContainerChanged(this, pContainer, nullptr); // Engine calls if (fCalls) pContainer->Call(PSF_Ejection,&C4AulParSet(this)); if (fCalls) Call(PSF_Departure,&C4AulParSet(pContainer)); @@ -1314,7 +1314,7 @@ bool C4Object::Enter(C4Object *pTarget, bool fCalls, bool fCopyMotion, bool *pfR // Enter if (!Contained->Contents.Add(this, C4ObjectList::stContents)) { - Contained=NULL; + Contained=nullptr; return false; } // Assume that the new container controls this object, if it cannot control itself (i.e.: Alive) @@ -1337,7 +1337,7 @@ bool C4Object::Enter(C4Object *pTarget, bool fCalls, bool fCopyMotion, bool *pfR Contained->UpdateMass(); Contained->SetOCF(); // Object list callback (before script callbacks, because script callbacks may exit again) - ObjectListChangeListener.OnObjectContainerChanged(this, NULL, Contained); + ObjectListChangeListener.OnObjectContainerChanged(this, nullptr, Contained); // Collection call if (fCalls) pTarget->Call(PSF_Collection2,&C4AulParSet(this)); if (!Contained || !Contained->Status || !pTarget->Status) return true; @@ -1451,8 +1451,8 @@ bool C4Object::Lift(C4Real tydir, C4Real dforce) C4Object* C4Object::CreateContents(C4PropList * PropList) { C4Object *nobj; - if (!(nobj=Game.CreateObject(PropList,this,Owner))) return NULL; - if (!nobj->Enter(this)) { nobj->AssignRemoval(); return NULL; } + if (!(nobj=Game.CreateObject(PropList,this,Owner))) return nullptr; + if (!nobj->Enter(this)) { nobj->AssignRemoval(); return nullptr; } return nobj; } @@ -1571,7 +1571,7 @@ bool C4Object::ActivateMenu(int32_t iMenu, int32_t iMenuSelect, (pTarget->GetY() + pTarget->Shape.GetY() - pViewport->GetViewY()) * pViewport->GetZoom()); // Add info item fctSymbol.Create(C4PictureSize, C4PictureSize); pTarget->Def->Draw(fctSymbol, false, pTarget->Color, pTarget); - Menu->Add(pTarget->GetName(), fctSymbol, "", C4MN_Item_NoCount, NULL, pTarget->GetInfoString().getData()); + Menu->Add(pTarget->GetName(), fctSymbol, "", C4MN_Item_NoCount, nullptr, pTarget->GetInfoString().getData()); fctSymbol.Default(); // Success return true; @@ -1587,7 +1587,7 @@ bool C4Object::CloseMenu(bool fForce) if (Menu) { if (Menu->IsActive()) if (!Menu->TryClose(fForce, false)) return false; - if (!Menu->IsCloseQuerying()) { delete Menu; Menu=NULL; } // protect menu deletion from recursive menu operation calls + if (!Menu->IsCloseQuerying()) { delete Menu; Menu=nullptr; } // protect menu deletion from recursive menu operation calls } return true; } @@ -1710,7 +1710,7 @@ int32_t C4Object::GetValue(C4Object *pInBase, int32_t iForPlayer) // get value of def // Caution: Do not pass pInBase here, because the def base value is to be queried // - and not the value if you had to buy the object in this particular base - iValue = Def->GetValue(NULL, iForPlayer); + iValue = Def->GetValue(nullptr, iForPlayer); } // Con percentage iValue = iValue * Con / FullCon; @@ -1759,12 +1759,12 @@ void C4Object::ClearPointers(C4Object *pObj) if (Contained == pObj) { Contained->Contents.Remove(this); - Contained = NULL; + Contained = nullptr; } Contents.Remove(pObj); // Action targets - if (Action.Target==pObj) Action.Target=NULL; - if (Action.Target2==pObj) Action.Target2=NULL; + if (Action.Target==pObj) Action.Target=nullptr; + if (Action.Target2==pObj) Action.Target2=nullptr; // Commands C4Command *cCom; for (cCom=Command; cCom; cCom=cCom->Next) @@ -1772,7 +1772,7 @@ void C4Object::ClearPointers(C4Object *pObj) // Menu if (Menu) Menu->ClearPointers(pObj); // Layer - if (Layer==pObj) Layer=NULL; + if (Layer==pObj) Layer=nullptr; // gfx overlays if (pGfxOverlay) { @@ -1955,7 +1955,7 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode, f // Visibility inside FoW const C4FoWRegion* pOldFoW = pDraw->GetFoW(); if(pOldFoW && (Category & C4D_IgnoreFoW)) - pDraw->SetFoW(NULL); + pDraw->SetFoW(nullptr); // color modulation (including construction sign...) if (ColorMod != 0xffffffff || BlitMode) if (!eDrawMode) PrepareDrawing(); @@ -2110,7 +2110,7 @@ void C4Object::DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDraw cgo.Surface, offX + Shape.GetX() + float(Def->TopFace.tx * Con) / FullCon, offY + Shape.GetY() + float(Def->TopFace.ty * Con) / FullCon, float(TopFace.Wdt * Con) / FullCon, float(TopFace.Hgt * Con) / FullCon, - true, pDrawTransform ? &C4DrawTransform(*pDrawTransform, offX, offY) : NULL); + true, pDrawTransform ? &C4DrawTransform(*pDrawTransform, offX, offY) : nullptr); else // normal pDraw->Blit(TopFace.Surface, @@ -2119,7 +2119,7 @@ void C4Object::DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDraw cgo.Surface, offX + Shape.GetX() + Def->TopFace.tx, offY + Shape.GetY() + Def->TopFace.ty, TopFace.Wdt, TopFace.Hgt, - true, pDrawTransform ? &C4DrawTransform(*pDrawTransform, offX, offY) : NULL); + true, pDrawTransform ? &C4DrawTransform(*pDrawTransform, offX, offY) : nullptr); } // end of color modulation if (!eDrawMode) FinishedDrawing(); @@ -2160,7 +2160,7 @@ void C4Object::DrawLine(C4TargetFacet &cgo, int32_t at_player) vertices[2*vtx+1].fty = Shape.VtxY[vtx+1] + cgo.Y - cgo.TargetY; } - pDraw->PerformMultiLines(cgo.Surface, &vertices[0], vertices.size(), 1.0f, NULL); + pDraw->PerformMultiLines(cgo.Surface, &vertices[0], vertices.size(), 1.0f, nullptr); // reset blit mode FinishedDrawing(); @@ -2231,7 +2231,7 @@ void C4Object::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers) pComp->Value(mkNamingAdapt( C4DefGraphicsAdapt(pGraphics), "Graphics", &Def->Graphics )); pComp->Value(mkNamingPtrAdapt( pDrawTransform, "DrawTransform" )); pComp->Value(mkParAdapt(mkNamingPtrAdapt( pEffects, "Effects" ), this, numbers)); - pComp->Value(mkNamingAdapt( C4GraphicsOverlayListAdapt(pGfxOverlay),"GfxOverlay", (C4GraphicsOverlay *)NULL)); + pComp->Value(mkNamingAdapt( C4GraphicsOverlayListAdapt(pGfxOverlay),"GfxOverlay", (C4GraphicsOverlay *)nullptr)); // Serialize mesh instance if we have a mesh graphics if(pGraphics->Type == C4DefGraphics::TYPE_Mesh) @@ -2258,7 +2258,7 @@ void C4Object::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers) { if (fCompiler) { - C4Command *pCmd = NULL; + C4Command *pCmd = nullptr; for (int i = 1; ; i++) { // Every command has its own naming environment @@ -2379,7 +2379,7 @@ void C4Object::Picture2Facet(C4FacetSurface &cgo) if (pGfxOverlay) for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext()) if (pGfxOvrl->IsPicture()) - pGfxOvrl->DrawPicture(cgo, this, NULL); + pGfxOvrl->DrawPicture(cgo, this, nullptr); // done; reset drawing states FinishedDrawing(); @@ -2437,7 +2437,7 @@ void C4Object::ClearInfo(C4ObjectInfo *pInfo) { if (Info==pInfo) { - Info=NULL; + Info=nullptr; } } @@ -2445,19 +2445,19 @@ void C4Object::Clear() { ClearParticleLists(); - if (pEffects) { delete pEffects; pEffects=NULL; } - if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=NULL; } - if (Menu) delete Menu; Menu=NULL; - if (MaterialContents) delete MaterialContents; MaterialContents=NULL; + if (pEffects) { delete pEffects; pEffects=nullptr; } + if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; } + if (Menu) delete Menu; Menu=nullptr; + if (MaterialContents) delete MaterialContents; MaterialContents=nullptr; // clear commands! C4Command *pCom, *pNext; for (pCom=Command; pCom; pCom=pNext) { pNext=pCom->Next; delete pCom; pCom=pNext; } - if (pDrawTransform) { delete pDrawTransform; pDrawTransform=NULL; } - if (pGfxOverlay) { delete pGfxOverlay; pGfxOverlay=NULL; } - if (pMeshInstance) { delete pMeshInstance; pMeshInstance = NULL; } + if (pDrawTransform) { delete pDrawTransform; pDrawTransform=nullptr; } + if (pGfxOverlay) { delete pGfxOverlay; pGfxOverlay=nullptr; } + if (pMeshInstance) { delete pMeshInstance; pMeshInstance = nullptr; } } bool C4Object::MenuCommand(const char *szCommand) @@ -2470,7 +2470,7 @@ bool C4Object::MenuCommand(const char *szCommand) void C4Object::SetSolidMask(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iTX, int32_t iTY) { // remove old - if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=NULL; } + if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; } // set new data SolidMask.Set(iX,iY,iWdt,iHgt,iTX,iTY); // re-put if valid @@ -2511,7 +2511,7 @@ void C4Object::SyncClearance() // Menu CloseMenu(true); // Material contents - if (MaterialContents) delete MaterialContents; MaterialContents=NULL; + if (MaterialContents) delete MaterialContents; MaterialContents=nullptr; // reset speed of staticback-objects if (Category & C4D_StaticBack) { @@ -2560,7 +2560,7 @@ void C4Object::ClearCommand(C4Command *pUntil) for (pCom=Command; pCom; pCom=pNext) { // Last one to clear - if (pCom==pUntil) pNext=NULL; + if (pCom==pUntil) pNext=nullptr; // Next one to clear after this else pNext=pCom->Next; Command=pCom->Next; @@ -2659,7 +2659,7 @@ C4Command *C4Object::FindCommand(int32_t iCommandType) const for (C4Command *pCom = Command; pCom; pCom=pCom->Next) if (pCom->Command == iCommandType) return pCom; // nothing found - return NULL; + return nullptr; } bool C4Object::ExecuteCommand() @@ -2708,13 +2708,13 @@ bool C4Object::SetAction(C4PropList * Act, C4Object *pTarget, C4Object *pTarget2 if (pMeshInstance) { if (Action.Animation) pMeshInstance->StopAnimation(Action.Animation); - Action.Animation = NULL; + Action.Animation = nullptr; - C4String* Animation = Act ? Act->GetPropertyStr(P_Animation) : NULL; + C4String* Animation = Act ? Act->GetPropertyStr(P_Animation) : nullptr; if (Animation) { // note that weight is ignored - Action.Animation = pMeshInstance->PlayAnimation(Animation->GetData(), 0, NULL, new C4ValueProviderAction(this), new C4ValueProviderConst(itofix(1)), true); + Action.Animation = pMeshInstance->PlayAnimation(Animation->GetData(), 0, nullptr, new C4ValueProviderAction(this), new C4ValueProviderConst(itofix(1)), true); } } // Stop previous act sound @@ -2735,8 +2735,8 @@ bool C4Object::SetAction(C4PropList * Act, C4Object *pTarget, C4Object *pTarget2 != (LastAction ? LastAction->GetPropertyP(P_Procedure) : -1)) { Action.Data = 0; - Action.Target = NULL; - Action.Target2 = NULL; + Action.Target = nullptr; + Action.Target2 = nullptr; } } // Set new action @@ -2777,8 +2777,8 @@ bool C4Object::SetAction(C4PropList * Act, C4Object *pTarget, C4Object *pTarget2 if (LastAction->GetPropertyStr(P_AbortCall)) { C4Def *pOldDef = Def; - if (pLastTarget && !pLastTarget->Status) pLastTarget = NULL; - if (pLastTarget2 && !pLastTarget2->Status) pLastTarget2 = NULL; + if (pLastTarget && !pLastTarget->Status) pLastTarget = nullptr; + if (pLastTarget2 && !pLastTarget2->Status) pLastTarget2 = nullptr; Call(LastAction->GetPropertyStr(P_AbortCall)->GetCStr(), &C4AulParSet(iLastPhase, pLastTarget, pLastTarget2)); // abort exeution if def changed if (Def != pOldDef || !Status) return true; @@ -3256,7 +3256,7 @@ static void DoGravity(C4Object *cobj) void StopActionDelayCommand(C4Object *cobj) { ObjectComStop(cobj); - cobj->AddCommand(C4CMD_Wait,NULL,0,0,50); + cobj->AddCommand(C4CMD_Wait,nullptr,0,0,50); } bool ReduceLineSegments(C4Shape &rShape, bool fAlternate) @@ -3711,7 +3711,7 @@ void C4Object::ExecAction() // Grab lost action GrabLost(this, prev_target); // Lose target - Action.Target=NULL; + Action.Target=nullptr; // Done return; } @@ -3979,7 +3979,7 @@ void C4Object::ExecAction() else { // Set new action - SetActionByName(next_action, NULL, NULL, SAC_StartCall | SAC_EndCall); + SetActionByName(next_action, nullptr, nullptr, SAC_StartCall | SAC_EndCall); } } } @@ -4167,12 +4167,12 @@ void C4Object::UpdateSolidMask(bool fRestoreAttachedObjects) } else pSolidMaskData->Remove(false); - pSolidMaskData->Put(true, NULL, fRestoreAttachedObjects); + pSolidMaskData->Put(true, nullptr, fRestoreAttachedObjects); } // Otherwise, remove and destroy mask else if (pSolidMaskData) { - delete pSolidMaskData; pSolidMaskData = NULL; + delete pSolidMaskData; pSolidMaskData = nullptr; } } @@ -4299,7 +4299,7 @@ bool C4Object::GetDragImage(C4Object **drag_object, C4Def **drag_def) const if (!parV) return false; // determine drag object/id C4Object *obj = parV.getObj(); - C4Def * def = NULL; + C4Def * def = nullptr; if (!obj) def = parV.getDef(); if (drag_object) *drag_object = obj; if (drag_def) *drag_def = def; @@ -4490,18 +4490,18 @@ C4GraphicsOverlay *C4Object::GetGraphicsOverlay(int32_t iForID) const // exact match found? if (pOverlay && pOverlay->GetID() == iForID) return pOverlay; // none found - return NULL; + return nullptr; } C4GraphicsOverlay *C4Object::GetGraphicsOverlay(int32_t iForID, bool fCreate) { // search in list until ID is found or passed - C4GraphicsOverlay *pOverlay = pGfxOverlay, *pPrevOverlay = NULL; + C4GraphicsOverlay *pOverlay = pGfxOverlay, *pPrevOverlay = nullptr; while (pOverlay && pOverlay->GetID() < iForID) { pPrevOverlay = pOverlay; pOverlay = pOverlay->GetNext(); } // exact match found? if (pOverlay && pOverlay->GetID() == iForID) return pOverlay; // ID has been passed: Create new if desired - if (!fCreate) return NULL; + if (!fCreate) return nullptr; C4GraphicsOverlay *pNewOverlay = new C4GraphicsOverlay(); pNewOverlay->SetID(iForID); pNewOverlay->SetNext(pOverlay); @@ -4513,14 +4513,14 @@ C4GraphicsOverlay *C4Object::GetGraphicsOverlay(int32_t iForID, bool fCreate) bool C4Object::RemoveGraphicsOverlay(int32_t iOverlayID) { // search in list until ID is found or passed - C4GraphicsOverlay *pOverlay = pGfxOverlay, *pPrevOverlay = NULL; + C4GraphicsOverlay *pOverlay = pGfxOverlay, *pPrevOverlay = nullptr; while (pOverlay && pOverlay->GetID() < iOverlayID) { pPrevOverlay = pOverlay; pOverlay = pOverlay->GetNext(); } // exact match found? if (pOverlay && pOverlay->GetID() == iOverlayID) { // remove it if (pPrevOverlay) pPrevOverlay->SetNext(pOverlay->GetNext()); else pGfxOverlay = pOverlay->GetNext(); - pOverlay->SetNext(NULL); // prevents deletion of following overlays + pOverlay->SetNext(nullptr); // prevents deletion of following overlays delete pOverlay; // removed return true; @@ -4663,7 +4663,7 @@ static void BubbleOut(int32_t tx, int32_t ty) // Enough bubbles out there already if (::Objects.ObjectCount(C4ID::Bubble) >= 150) return; // Create bubble - Game.CreateObject(C4ID::Bubble,NULL,NO_OWNER,tx,ty); + Game.CreateObject(C4ID::Bubble,nullptr,NO_OWNER,tx,ty); } void C4Object::Splash() diff --git a/src/object/C4Object.h b/src/object/C4Object.h index 9a513db15..ae1ec579d 100644 --- a/src/object/C4Object.h +++ b/src/object/C4Object.h @@ -179,11 +179,11 @@ public: void SetPlane(int32_t z) { if (z) Plane = z; Resort(); } int32_t GetPlane() const { return Plane; } int32_t GetSolidMaskPlane() const; - void SetCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, C4Object *pTarget2=NULL, bool fControl=false, C4Value iData=C4VNull, int32_t iRetries=0, C4String *szText=NULL); - void SetCommand(int32_t iCommand, C4Object *pTarget=NULL, int32_t iTx=0, int32_t iTy=0, C4Object *pTarget2=NULL, bool fControl=false, C4Value iData=C4VNull, int32_t iRetries=0, C4String *szText=NULL) + void SetCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, C4Object *pTarget2=nullptr, bool fControl=false, C4Value iData=C4VNull, int32_t iRetries=0, C4String *szText=nullptr); + void SetCommand(int32_t iCommand, C4Object *pTarget=nullptr, int32_t iTx=0, int32_t iTy=0, C4Object *pTarget2=nullptr, bool fControl=false, C4Value iData=C4VNull, int32_t iRetries=0, C4String *szText=nullptr) { SetCommand(iCommand, pTarget, C4VInt(iTx), iTy, pTarget2, fControl, iData, iRetries, szText); } - bool AddCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, int32_t iUpdateInterval=0, C4Object *pTarget2=NULL, bool fInitEvaluation=true, C4Value iData=C4VNull, bool fAppend=false, int32_t iRetries=0, C4String *szText=NULL, int32_t iBaseMode=0); - bool AddCommand(int32_t iCommand, C4Object *pTarget=NULL, int32_t iTx=0, int32_t iTy=0, int32_t iUpdateInterval=0, C4Object *pTarget2=NULL, bool fInitEvaluation=true, C4Value iData=C4VNull, bool fAppend=false, int32_t iRetries=0, C4String *szText=NULL, int32_t iBaseMode=0) + bool AddCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, int32_t iUpdateInterval=0, C4Object *pTarget2=nullptr, bool fInitEvaluation=true, C4Value iData=C4VNull, bool fAppend=false, int32_t iRetries=0, C4String *szText=nullptr, int32_t iBaseMode=0); + bool AddCommand(int32_t iCommand, C4Object *pTarget=nullptr, int32_t iTx=0, int32_t iTy=0, int32_t iUpdateInterval=0, C4Object *pTarget2=nullptr, bool fInitEvaluation=true, C4Value iData=C4VNull, bool fAppend=false, int32_t iRetries=0, C4String *szText=nullptr, int32_t iBaseMode=0) { return AddCommand(iCommand, pTarget, C4VInt(iTx), iTy, iUpdateInterval, pTarget2, fInitEvaluation, iData, fAppend, iRetries, szText, iBaseMode); } C4Command *FindCommand(int32_t iCommandType) const; // find a command of the given type void ClearCommand(C4Command *pUntil); @@ -201,7 +201,7 @@ public: bool AssignInfo(); bool ValidateOwner(); bool AssignLightRange(); - void DrawPicture(C4Facet &cgo, bool fSelected=false, C4DrawTransform* transform=NULL); + void DrawPicture(C4Facet &cgo, bool fSelected=false, C4DrawTransform* transform=nullptr); void Picture2Facet(C4FacetSurface &cgo); // set picture to facet, or create facet in current size and draw if specific states are being needed void Default(); bool Init(C4PropList *ndef, C4Object *pCreator, @@ -244,19 +244,19 @@ public: bool At(int32_t ctx, int32_t cty, DWORD &ocf) const; void GetOCFForPos(int32_t ctx, int32_t cty, DWORD &ocf) const; bool CloseMenu(bool fForce); - bool ActivateMenu(int32_t iMenu, int32_t iMenuSelect=0, int32_t iMenuData=0, int32_t iMenuPosition=0, C4Object *pTarget=NULL); + bool ActivateMenu(int32_t iMenu, int32_t iMenuSelect=0, int32_t iMenuData=0, int32_t iMenuPosition=0, C4Object *pTarget=nullptr); int32_t ContactCheck(int32_t atx, int32_t aty, uint32_t *border_hack_contacts=0, bool collide_halfvehic=false); bool Contact(int32_t cnat); void StopAndContact(C4Real & ctco, C4Real limit, C4Real & speed, int32_t cnat); enum { SAC_StartCall = 1, SAC_EndCall = 2, SAC_AbortCall = 4 }; C4PropList* GetAction() const; - bool SetAction(C4PropList * Act, C4Object *pTarget=NULL, C4Object *pTarget2=NULL, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false); - bool SetActionByName(C4String * ActName, C4Object *pTarget=NULL, C4Object *pTarget2=NULL, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false); - bool SetActionByName(const char * szActName, C4Object *pTarget=NULL, C4Object *pTarget2=NULL, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false); + bool SetAction(C4PropList * Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false); + bool SetActionByName(C4String * ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false); + bool SetActionByName(const char * szActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls = SAC_StartCall | SAC_AbortCall, bool fForce = false); void SetDir(int32_t tdir); void SetCategory(int32_t Category) { this->Category = Category; Resort(); SetOCF(); } int32_t GetProcedure() const; - bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=NULL); + bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr); bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true); void CopyMotion(C4Object *from); void ForcePosition(C4Real tx, C4Real ty); @@ -338,7 +338,7 @@ public: bool PutAwayUnusedObject(C4Object *pToMakeRoomForObject); // either directly put the least-needed object away, or add a command to do it - return whether successful C4DefGraphics *GetGraphics() const { return pGraphics; } // return current object graphics - bool SetGraphics(const char *szGraphicsName=NULL, C4Def *pSourceDef=NULL); // set used graphics for object; if szGraphicsName or *szGraphicsName are NULL, the default graphics of the given def are used; pSourceDef defaults to own def + bool SetGraphics(const char *szGraphicsName=nullptr, C4Def *pSourceDef=nullptr); // set used graphics for object; if szGraphicsName or *szGraphicsName are nullptr, the default graphics of the given def are used; pSourceDef defaults to own def bool SetGraphics(C4DefGraphics *pNewGfx, bool fUpdateData); // set used graphics for object class C4GraphicsOverlay *GetGraphicsOverlay(int32_t iForID) const; // get specified gfx overlay diff --git a/src/object/C4ObjectCom.cpp b/src/object/C4ObjectCom.cpp index b183bef6f..a9dc06879 100644 --- a/src/object/C4ObjectCom.cpp +++ b/src/object/C4ObjectCom.cpp @@ -209,7 +209,7 @@ bool ObjectComUnGrab(C4Object *cObj) if (!cObj->CloseMenu(false)) return false; cObj->Call(PSF_Grab, &C4AulParSet(pTarget, false)); // clear action target - cObj->Action.Target = NULL; + cObj->Action.Target = nullptr; if (pTarget && pTarget->Status && cObj->Status) { pTarget->Call(PSF_Grabbed, &C4AulParSet(cObj, false)); diff --git a/src/object/C4ObjectCom.h b/src/object/C4ObjectCom.h index ae9d69e0d..3e51e0c82 100644 --- a/src/object/C4ObjectCom.h +++ b/src/object/C4ObjectCom.h @@ -34,21 +34,21 @@ bool ObjectActionKneel(C4Object *cObj); bool ObjectActionFlat(C4Object *cObj, int32_t dir); bool ObjectActionScale(C4Object *cObj, int32_t dir); bool ObjectActionHangle(C4Object *cObj); -bool ObjectActionThrow(C4Object *cObj, C4Object *pThing=NULL); +bool ObjectActionThrow(C4Object *cObj, C4Object *pThing=nullptr); bool ObjectActionDig(C4Object *cObj); bool ObjectActionPush(C4Object *cObj, C4Object *pTarget); bool ObjectActionCornerScale(C4Object *cObj); bool ObjectComStop(C4Object *cObj); bool ObjectComGrab(C4Object *cObj, C4Object *pTarget); -bool ObjectComPut(C4Object *cObj, C4Object *pTarget, C4Object *pThing=NULL); -bool ObjectComThrow(C4Object *cObj, C4Object *pThing=NULL); -bool ObjectComDrop(C4Object *cObj, C4Object *pThing=NULL); +bool ObjectComPut(C4Object *cObj, C4Object *pTarget, C4Object *pThing=nullptr); +bool ObjectComThrow(C4Object *cObj, C4Object *pThing=nullptr); +bool ObjectComDrop(C4Object *cObj, C4Object *pThing=nullptr); bool ObjectComUnGrab(C4Object *cObj); bool ObjectComJump(C4Object *cObj); bool ObjectComLetGo(C4Object *cObj, int32_t xdirf); bool ObjectComDig(C4Object *cObj); -bool ObjectComPutTake(C4Object *cObj, C4Object *pTarget, C4Object *pThing=NULL); +bool ObjectComPutTake(C4Object *cObj, C4Object *pTarget, C4Object *pThing=nullptr); bool ObjectComTake(C4Object *cObj); // carlo bool ObjectComTake2(C4Object *cObj); // carlo bool ObjectComPunch(C4Object *cObj, C4Object *pTarget, int32_t iPunch=0); diff --git a/src/object/C4ObjectInfo.cpp b/src/object/C4ObjectInfo.cpp index a8d7745cc..969deb911 100644 --- a/src/object/C4ObjectInfo.cpp +++ b/src/object/C4ObjectInfo.cpp @@ -55,8 +55,8 @@ void C4ObjectInfo::Default() HasDied=false; ControlCount=0; Filename[0]=0; - Next=NULL; - pDef = NULL; + Next=nullptr; + pDef = nullptr; } bool C4ObjectInfo::Load(C4Group &hMother, const char *szEntryname) @@ -172,7 +172,7 @@ void C4ObjectInfo::Evaluate() void C4ObjectInfo::Clear() { - pDef=NULL; + pDef=nullptr; } void C4ObjectInfo::Recruit() @@ -202,5 +202,5 @@ void C4ObjectInfo::Retire() void C4ObjectInfo::SetBirthday() { - Birthday=time(NULL); + Birthday=time(nullptr); } diff --git a/src/object/C4ObjectInfoList.cpp b/src/object/C4ObjectInfoList.cpp index 5ec11b1f2..5c12e5902 100644 --- a/src/object/C4ObjectInfoList.cpp +++ b/src/object/C4ObjectInfoList.cpp @@ -41,7 +41,7 @@ C4ObjectInfoList::~C4ObjectInfoList() void C4ObjectInfoList::Default() { - First=NULL; + First=nullptr; iNumCreated=0; } @@ -116,7 +116,7 @@ C4ObjectInfo* C4ObjectInfoList::GetIdle(C4ID c_id, C4DefList &rDefs) { C4Def *pDef; C4ObjectInfo *pInfo; - C4ObjectInfo *pHiExp=NULL; + C4ObjectInfo *pHiExp=nullptr; // Search list for (pInfo=First; pInfo; pInfo=pInfo->Next) @@ -138,28 +138,28 @@ C4ObjectInfo* C4ObjectInfoList::GetIdle(C4ID c_id, C4DefList &rDefs) return pHiExp; } - return NULL; + return nullptr; } C4ObjectInfo* C4ObjectInfoList::New(C4ID n_id, C4DefList *pDefs) { C4ObjectInfo *pInfo; // Create new info object - if (!(pInfo = new C4ObjectInfo)) return NULL; + if (!(pInfo = new C4ObjectInfo)) return nullptr; // Default type clonk if none specified if (n_id == C4ID::None) n_id = C4ID::Clonk; // Check type valid and def available - C4Def *pDef = NULL; + C4Def *pDef = nullptr; if (pDefs) if (!(pDef = pDefs->ID2Def(n_id))) - { delete pInfo; return NULL; } + { delete pInfo; return nullptr; } // Set name source const char *cpNames = Game.Names.GetData(); if (pDef->pClonkNames) cpNames = pDef->pClonkNames->GetData(); // Default by type ((C4ObjectInfoCore*)pInfo)->Default(n_id, pDefs, cpNames); // Set birthday - pInfo->Birthday=time(NULL); + pInfo->Birthday=time(nullptr); // Make valid names MakeValidName(pInfo->Name); // Add @@ -205,7 +205,7 @@ C4ObjectInfo* C4ObjectInfoList::GetIdle(const char *szByName) pInfo->Recruit(); return pInfo; } - return NULL; + return nullptr; } void C4ObjectInfoList::DetachFromObjects() @@ -227,7 +227,7 @@ C4ObjectInfo* C4ObjectInfoList::GetPrevious(C4ObjectInfo *pInfo) for (C4ObjectInfo *cInfo = First; cInfo; cInfo=cInfo->Next) if (cInfo->Next == pInfo) return cInfo; - return NULL; + return nullptr; } bool C4ObjectInfoList::IsElement(C4ObjectInfo *pInfo) @@ -241,7 +241,7 @@ void C4ObjectInfoList::Strip(C4DefList &rDefs) { C4ObjectInfo *pInfo, *pPrev; // Search list - for (pInfo=First, pPrev=NULL; pInfo; ) + for (pInfo=First, pPrev=nullptr; pInfo; ) { // Invalid? if (!rDefs.ID2Def(pInfo->id)) diff --git a/src/object/C4ObjectList.cpp b/src/object/C4ObjectList.cpp index cd3514b78..ba52f5988 100644 --- a/src/object/C4ObjectList.cpp +++ b/src/object/C4ObjectList.cpp @@ -28,7 +28,7 @@ #include "game/C4Game.h" #include "object/C4GameObjects.h" -static const C4ObjectLink NULL_LINK = { NULL, NULL, NULL }; +static const C4ObjectLink NULL_LINK = { nullptr, nullptr, nullptr }; C4ObjectList::C4ObjectList(): FirstIter(0) { @@ -51,11 +51,11 @@ void C4ObjectList::Clear() C4ObjectLink *cLnk,*nextLnk; for (cLnk=First; cLnk; cLnk=nextLnk) { nextLnk=cLnk->Next; delete cLnk; } - First=Last=NULL; + First=Last=nullptr; if (pEnumerated) { delete pEnumerated; - pEnumerated=NULL; + pEnumerated=nullptr; } for (iterator* it = FirstIter; it; it = it->Next) @@ -147,13 +147,13 @@ bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted) nLnk->Obj=nObj; // Search insert position (default: end of list) - C4ObjectLink *cLnk = NULL, *cPrev = Last; + C4ObjectLink *cLnk = nullptr, *cPrev = Last; // Should sort? if (eSort == stReverse) { // reverse sort: Add to beginning of list - cLnk = First; cPrev = NULL; + cLnk = First; cPrev = nullptr; } else if (eSort) { @@ -164,7 +164,7 @@ bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted) // Sort by master list? if (pLstSorted) { - cPrev = NULL; cLnk = First; + cPrev = nullptr; cLnk = First; while(cLnk && (!cLnk->Obj->Status || cLnk->Obj->Unsorted)) cLnk = cLnk->Next; #ifndef _DEBUG @@ -195,7 +195,7 @@ bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted) } } - assert(cLnk2 != NULL); + assert(cLnk2 != nullptr); } } else @@ -205,7 +205,7 @@ bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted) // It is not done for static back to allow multiobject outside structure. // Unsorted objects are ignored in comparison. if (!(nObj->Category & C4D_StaticBack)) - for (cPrev=NULL,cLnk=First; cLnk; cLnk=cLnk->Next) + for (cPrev=nullptr,cLnk=First; cLnk; cLnk=cLnk->Next) if (cLnk->Obj->Status && !cLnk->Obj->Unsorted) { if (cLnk->Obj->GetPlane() == nObj->GetPlane()) @@ -216,7 +216,7 @@ bool C4ObjectList::Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted) // Find successor by relative category if(!cLnk) - for (cPrev=NULL, cLnk=First; cLnk; cLnk=cLnk->Next) + for (cPrev=nullptr, cLnk=First; cLnk; cLnk=cLnk->Next) if (cLnk->Obj->Status && !cLnk->Obj->Unsorted) { if (cLnk->Obj->GetPlane() <= nObj->GetPlane()) @@ -304,7 +304,7 @@ C4Object* C4ObjectList::Find(C4Def * def, int owner, DWORD dwOCF) if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner)) if (dwOCF & cLnk->Obj->OCF) return cLnk->Obj; - return NULL; + return nullptr; } C4Object* C4ObjectList::FindOther(C4ID id, int owner) @@ -316,7 +316,7 @@ C4Object* C4ObjectList::FindOther(C4ID id, int owner) if (cLnk->Obj->Def->id!=id) if ((owner==ANY_OWNER) || (cLnk->Obj->Owner==owner)) return cLnk->Obj; - return NULL; + return nullptr; } C4Object* C4ObjectList::GetObject(int Index) const @@ -330,17 +330,17 @@ C4Object* C4ObjectList::GetObject(int Index) const if (cIdx==Index) return cLnk->Obj; cIdx++; } - return NULL; + return nullptr; } const C4ObjectLink* C4ObjectList::GetLink(const C4Object *pObj) const { - if (!pObj) return NULL; + if (!pObj) return nullptr; C4ObjectLink *cLnk; for (cLnk=First; cLnk; cLnk=cLnk->Next) if (cLnk->Obj==pObj) return cLnk; - return NULL; + return nullptr; } int C4ObjectList::ObjectCount(C4ID id) const @@ -436,7 +436,7 @@ bool C4ObjectList::DenumeratePointers() for (std::list::const_iterator pNum = pEnumerated->begin(); pNum != pEnumerated->end(); ++pNum) Add(::Objects.ObjectPointer(*pNum), stNone); // Add to tail, unsorted // Delete old list - delete pEnumerated; pEnumerated = NULL; + delete pEnumerated; pEnumerated = nullptr; return true; } @@ -486,7 +486,7 @@ void C4ObjectList::CompileFunc(StdCompiler *pComp, bool fSkipPlayerObjects, C4Va // Load objects, add them to the list. for (int i = 0; i < iObjCnt; i++) { - C4Object *pObj = NULL; + C4Object *pObj = nullptr; try { pComp->Value(mkNamingAdapt(mkParAdapt(mkPtrAdaptNoNull(pObj), numbers), "Object")); @@ -518,7 +518,7 @@ void C4ObjectList::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers) pComp->Value(mkSTLContainerAdapt(*pEnumerated, StdCompiler::SEP_SEP2)); // Decompiling: Delete list if (!pComp->isCompiler()) - { delete pEnumerated; pEnumerated = NULL; } + { delete pEnumerated; pEnumerated = nullptr; } // Compiling: Nothing to do - list will be denumerated later } @@ -605,7 +605,7 @@ void C4ObjectList::InsertLink(C4ObjectLink *pLnk, C4ObjectLink *pAfter) // Insert at head else { - pLnk->Prev=NULL; pLnk->Next=First; + pLnk->Prev=nullptr; pLnk->Next=First; if (First) First->Prev=pLnk; else Last=pLnk; First=pLnk; } @@ -635,7 +635,7 @@ void C4ObjectList::InsertLinkBefore(C4ObjectLink *pLnk, C4ObjectLink *pBefore) // Insert at end else { - pLnk->Next = NULL; pLnk->Prev = Last; + pLnk->Next = nullptr; pLnk->Prev = Last; if (Last) Last->Next = pLnk; else First = pLnk; Last = pLnk; } @@ -711,9 +711,9 @@ void C4ObjectList::Copy(const C4ObjectList &rList) void C4ObjectList::Default() { - First=Last=NULL; + First=Last=nullptr; Mass=0; - pEnumerated=NULL; + pEnumerated=nullptr; } bool C4ObjectList::ShiftContents(C4Object *pNewFirst) @@ -730,7 +730,7 @@ bool C4ObjectList::ShiftContents(C4Object *pNewFirst) First = pNewFirstLnk; Last = pNewFirstLnk->Prev; // 3. Uncycle list - First->Prev = Last->Next = NULL; + First->Prev = Last->Next = nullptr; // done, success return true; } @@ -757,14 +757,14 @@ void C4ObjectList::DeleteObjects() C4Object *C4ObjectListIterator::GetNext(int32_t *piCount) { // end reached? - if (pCurrID == rList.end()) return NULL; + if (pCurrID == rList.end()) return nullptr; // not yet started? if (pCurr == rList.end()) // then start at first ID list head pCurr = pCurrID; else // next item - if (++pCurr == rList.end()) return NULL; + if (++pCurr == rList.end()) return nullptr; // next ID section reached? if ((*pCurr)->id != (*pCurrID)->id) pCurrID = pCurr; @@ -776,7 +776,7 @@ C4Object *C4ObjectListIterator::GetNext(int32_t *piCount) if ((*pCheck)->CanConcatPictureWith(*pCurr)) { // next object of matching category - if (++pCurr == rList.end()) return NULL; + if (++pCurr == rList.end()) return nullptr; // next ID chunk reached? if ((*pCurr)->id != (*pCurrID)->id) { @@ -847,7 +847,7 @@ bool C4ObjectList::CheckSort(C4ObjectList *pList) void C4ObjectList::CheckCategorySort() { // debug: Check whether object list is sorted correctly - C4ObjectLink *cLnk, *cPrev=NULL; + C4ObjectLink *cLnk, *cPrev=nullptr; for (cLnk=First; cLnk; cLnk=cLnk->Next) if (!cLnk->Obj->Unsorted && cLnk->Obj->Status) { diff --git a/src/object/C4ObjectList.h b/src/object/C4ObjectList.h index bd96d9afe..113677ffe 100644 --- a/src/object/C4ObjectList.h +++ b/src/object/C4ObjectList.h @@ -117,7 +117,7 @@ public: typedef int SortProc(C4Object *, C4Object *); - virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted = NULL); + virtual bool Add(C4Object *nObj, SortType eSort, C4ObjectList *pLstSorted = nullptr); bool AddSortCustom(C4Object *nObj, SortProc &pSortProc); virtual bool Remove(C4Object *pObj); @@ -138,8 +138,8 @@ public: int ListIDCount(int32_t dwCategory) const; C4Object* GetObject(int Index=0) const; - C4Object* GetFirstObject() const { return First ? First->Obj : NULL; } - C4Object* GetLastObject() const { return Last ? Last->Obj : NULL; } + C4Object* GetFirstObject() const { return First ? First->Obj : nullptr; } + C4Object* GetLastObject() const { return Last ? Last->Obj : nullptr; } C4Object* Find(C4Def * def, int iOwner=ANY_OWNER, DWORD dwOCF=OCF_All); C4Object* FindOther(C4ID id, int iOwner=ANY_OWNER); @@ -196,7 +196,7 @@ private: C4ObjectListIterator(const C4ObjectListIterator &rCopy); // no copy ctor public: C4ObjectListIterator(C4ObjectList &rList) : rList(rList), pCurr(rList.end()), pCurrID(rList.begin()) {} // ctor - C4Object *GetNext(int32_t *piCount); // get next object; return NULL if end is reached + C4Object *GetNext(int32_t *piCount); // get next object; return nullptr if end is reached }; #endif diff --git a/src/object/C4ObjectMenu.cpp b/src/object/C4ObjectMenu.cpp index c16b9fcb5..6a144c0d9 100644 --- a/src/object/C4ObjectMenu.cpp +++ b/src/object/C4ObjectMenu.cpp @@ -44,7 +44,7 @@ void C4ObjectMenu::Default() { C4Menu::Default(); eCallbackType = CB_None; - Object = ParentObject = RefillObject = NULL; + Object = ParentObject = RefillObject = nullptr; RefillObjectContentsCount=0; UserMenu = false; CloseQuerying = false; @@ -108,9 +108,9 @@ void C4ObjectMenu::OnSelectionChanged(int32_t iNewSelection) void C4ObjectMenu::ClearPointers(C4Object *pObj) { - if (Object==pObj) { Object=NULL; } - if (ParentObject==pObj) ParentObject=NULL; // Reason for menu close anyway. - if (RefillObject==pObj) RefillObject=NULL; + if (Object==pObj) { Object=nullptr; } + if (ParentObject==pObj) ParentObject=nullptr; // Reason for menu close anyway. + if (RefillObject==pObj) RefillObject=nullptr; C4Menu::ClearPointers(pObj); } @@ -119,7 +119,7 @@ C4Object* C4ObjectMenu::GetParentObject() for (C4Object *cObj : Objects) if (cObj->Menu == this) return cObj; - return NULL; + return nullptr; } void C4ObjectMenu::SetRefillObject(C4Object *pObj) @@ -305,7 +305,7 @@ bool C4ObjectMenu::MenuCommand(const char *szCommand, bool fIsCloseCommand) case CB_Scenario: // Object menu with scenario script callback - ::AulExec.DirectExec(NULL, szCommand, "MenuCommand"); + ::AulExec.DirectExec(nullptr, szCommand, "MenuCommand"); break; case CB_None: diff --git a/src/object/C4ObjectScript.cpp b/src/object/C4ObjectScript.cpp index f338418cf..8578bcab2 100644 --- a/src/object/C4ObjectScript.cpp +++ b/src/object/C4ObjectScript.cpp @@ -141,7 +141,7 @@ static bool FnJump(C4Object *Obj) static bool FnEnter(C4Object *Obj, C4Object *pTarget) { - return !!Obj->Enter(pTarget,true,true,NULL); + return !!Obj->Enter(pTarget,true,true,nullptr); } static bool FnExit(C4Object *Obj, long tx, long ty, long tr, long txdir, long tydir, long trdir) @@ -229,7 +229,7 @@ static bool FnSetName(C4PropList * _this, C4String *pNewName, bool fSetInInfo, b // make sure names in info list aren't duplicated // querying owner info list here isn't 100% accurate, as infos might have been stolen by other players // however, there is no good way to track the original list ATM - C4ObjectInfoList *pInfoList = NULL; + C4ObjectInfoList *pInfoList = nullptr; C4Player *pOwner = ::Players.Get(Object(_this)->Owner); if (pOwner) pInfoList = &pOwner->CrewInfoList; char NameBuf[C4MaxName+1]; @@ -441,7 +441,7 @@ static bool FnSetCommand(C4Object *Obj, C4String * szCommand, C4Object * pTarget long iCommand = CommandByName(FnStringPar(szCommand)); if (!iCommand) { Obj->ClearCommands(); return false; } // Special: convert iData to szText - C4String *szText=NULL; + C4String *szText=nullptr; if (iCommand==C4CMD_Call) szText=Data.getStr(); // FIXME: throw if Tx isn't int @@ -460,7 +460,7 @@ static bool FnAddCommand(C4Object *Obj, C4String * szCommand, C4Object * pTarget long iCommand = CommandByName(FnStringPar(szCommand)); if (!iCommand) return false; // Special: convert iData to szText - C4String *szText=NULL; + C4String *szText=nullptr; if (iCommand==C4CMD_Call) szText=Data.getStr(); // Add @@ -476,7 +476,7 @@ static bool FnAppendCommand(C4Object *Obj, C4String * szCommand, C4Object * pTar long iCommand = CommandByName(FnStringPar(szCommand)); if (!iCommand) return false; // Special: convert iData to szText - C4String *szText=NULL; + C4String *szText=nullptr; if (iCommand==C4CMD_Call) szText=Data.getStr(); // Add @@ -533,7 +533,7 @@ static C4Object *FnGetActionTarget(C4Object *Obj, long target_index) { if (target_index==0) return Obj->Action.Target; if (target_index==1) return Obj->Action.Target2; - return NULL; + return nullptr; } static void FnSetActionTargets(C4Object *Obj, C4Object *pTarget1, C4Object *pTarget2) @@ -964,8 +964,8 @@ static bool FnAddMenuItem(C4Object *Obj, C4String * szCaption, C4String * szComm // Create symbol C4FacetSurface fctSymbol; - C4DefGraphics* pGfx = NULL; - C4Object* pGfxObj = NULL; + C4DefGraphics* pGfx = nullptr; + C4Object* pGfxObj = nullptr; switch (iExtra & C4MN_Add_MaxImage) { case C4MN_Add_ImgRank: @@ -986,7 +986,7 @@ static bool FnAddMenuItem(C4Object *Obj, C4String * szCaption, C4String * szComm // draw indexed facet fctSymbol.Create(iSymbolSize,iSymbolSize); if (pDef) - pDef->Draw(fctSymbol, false, 0, NULL, XPar.getInt()); + pDef->Draw(fctSymbol, false, 0, nullptr, XPar.getInt()); break; case C4MN_Add_ImgObjRank: { @@ -1063,7 +1063,7 @@ static bool FnAddMenuItem(C4Object *Obj, C4String * szCaption, C4String * szComm { fctSymbol.Create(iSymbolSize,iSymbolSize); uint32_t dwClr = XPar.getInt(); - if (!szCaption || !Game.DrawTextSpecImage(fctSymbol, caption, NULL, dwClr ? dwClr : 0xff)) + if (!szCaption || !Game.DrawTextSpecImage(fctSymbol, caption, nullptr, dwClr ? dwClr : 0xff)) return false; } *caption = '\0'; @@ -1108,11 +1108,11 @@ static bool FnAddMenuItem(C4Object *Obj, C4String * szCaption, C4String * szComm // Add menu item if(pGfxObj) - Obj->Menu->Add(caption,pGfxObj,command,iCount,NULL,infocaption,pDef ? pDef->id : C4ID::None,command2,fOwnValue,iValue,fIsSelectable); + Obj->Menu->Add(caption,pGfxObj,command,iCount,nullptr,infocaption,pDef ? pDef->id : C4ID::None,command2,fOwnValue,iValue,fIsSelectable); else if(pGfx) - Obj->Menu->Add(caption,pGfx,command,iCount,NULL,infocaption,pDef ? pDef->id : C4ID::None,command2,fOwnValue,iValue,fIsSelectable); + Obj->Menu->Add(caption,pGfx,command,iCount,nullptr,infocaption,pDef ? pDef->id : C4ID::None,command2,fOwnValue,iValue,fIsSelectable); else - Obj->Menu->Add(caption,fctSymbol,command,iCount,NULL,infocaption,pDef ? pDef->id : C4ID::None,command2,fOwnValue,iValue,fIsSelectable); + Obj->Menu->Add(caption,fctSymbol,command,iCount,nullptr,infocaption,pDef ? pDef->id : C4ID::None,command2,fOwnValue,iValue,fIsSelectable); return true; } @@ -1158,7 +1158,7 @@ static C4Object *FnContents(C4Object *Obj, long index) while ((cobj=Obj->Contents.GetObject(index++))) if (cobj->GetProcedure()!=DFA_ATTACH) return cobj; - return NULL; + return nullptr; } static bool FnShiftContents(C4Object *Obj, bool fShiftBack, C4Def * idTarget, bool fDoCalls) @@ -1229,7 +1229,7 @@ static C4Object *FnCreateContents(C4Object *Obj, C4PropList * PropList, Nillable // default amount parameter if (iCount.IsNil()) iCount = 1; // create objects - C4Object *pNewObj = NULL; + C4Object *pNewObj = nullptr; while (iCount-- > 0) pNewObj = Obj->CreateContents(PropList); // controller will automatically be set upon entrance // return last created @@ -1336,7 +1336,7 @@ static C4String *FnGetProcedure(C4Object *Obj) { // no action? C4PropList* pActionDef = Obj->GetAction(); - if (!pActionDef) return NULL; + if (!pActionDef) return nullptr; // get proc return pActionDef->GetPropertyStr(P_Procedure); } @@ -1421,7 +1421,7 @@ static bool FnSetGraphics(C4Object *Obj, C4String *pGfxName, C4Def *pSrcDef, lon // any overlays must be positive for now if (iOverlayID<0) { Log("SetGraphics: Background overlays not implemented!"); return false; } // deleting overlay? - C4DefGraphics *pGrp = NULL; + C4DefGraphics *pGrp = nullptr; if (iOverlayMode == C4GraphicsOverlay::MODE_Object || iOverlayMode == C4GraphicsOverlay::MODE_Rank || iOverlayMode == C4GraphicsOverlay::MODE_ObjectPicture) { if (!pOverlayObject) return Obj->RemoveGraphicsOverlay(iOverlayID); @@ -1453,7 +1453,7 @@ static bool FnSetGraphics(C4Object *Obj, C4String *pGfxName, C4Def *pSrcDef, lon break; case C4GraphicsOverlay::MODE_Object: - if (pOverlayObject && !pOverlayObject->Status) pOverlayObject = NULL; + if (pOverlayObject && !pOverlayObject->Status) pOverlayObject = nullptr; pOverlay->SetAsObject(pOverlayObject, dwBlitMode); break; @@ -1462,18 +1462,18 @@ static bool FnSetGraphics(C4Object *Obj, C4String *pGfxName, C4Def *pSrcDef, lon break; case C4GraphicsOverlay::MODE_Rank: - if (pOverlayObject && !pOverlayObject->Status) pOverlayObject = NULL; + if (pOverlayObject && !pOverlayObject->Status) pOverlayObject = nullptr; pOverlay->SetAsRank(dwBlitMode, pOverlayObject); break; case C4GraphicsOverlay::MODE_ObjectPicture: - if (pOverlayObject && !pOverlayObject->Status) pOverlayObject = NULL; + if (pOverlayObject && !pOverlayObject->Status) pOverlayObject = nullptr; pOverlay->SetAsObjectPicture(pOverlayObject, dwBlitMode); break; default: DebugLog("SetGraphics: Invalid overlay mode"); - pOverlay->SetAsBase(NULL, 0); // make invalid, so it will be removed + pOverlay->SetAsBase(nullptr, 0); // make invalid, so it will be removed break; } // remove if invalid @@ -1486,7 +1486,7 @@ static bool FnSetGraphics(C4Object *Obj, C4String *pGfxName, C4Def *pSrcDef, lon return true; } // no overlay: Base graphics - // set graphics - pSrcDef==NULL defaults to pObj->pDef + // set graphics - pSrcDef==nullptr defaults to pObj->pDef return Obj->SetGraphics(FnStringPar(pGfxName), pSrcDef); } @@ -1621,7 +1621,7 @@ static bool FnSetObjDrawTransform(C4Object *Obj, long iA, long iB, long iC, long { // kill identity-transform, then delete pTransform; - Obj->pDrawTransform=NULL; + Obj->pDrawTransform=nullptr; return true; } // flipdir must remain: set identity @@ -1788,7 +1788,7 @@ static Nillable FnPlayAnimation(C4Object *Obj, C4String *szAnimation, int i Instance = Attached->Child; } - StdMeshInstance::AnimationNode* s_node = NULL; + StdMeshInstance::AnimationNode* s_node = nullptr; if (!iSibling.IsNil()) { s_node = Instance->GetAnimationNodeByNumber(iSibling); @@ -1838,7 +1838,7 @@ static Nillable FnTransformBone(C4Object *Obj, C4String *szBoneName, C4Valu Instance = Attached->Child; } - StdMeshInstance::AnimationNode* s_node = NULL; + StdMeshInstance::AnimationNode* s_node = nullptr; if (!iSibling.IsNil()) { s_node = Instance->GetAnimationNodeByNumber(iSibling); @@ -2543,7 +2543,7 @@ C4ScriptConstDef C4ScriptObjectConstMap[]= { "AM_DrawBefore" ,C4V_Int, StdMeshInstance::AM_DrawBefore }, { "AM_MatchSkeleton" ,C4V_Int, StdMeshInstance::AM_MatchSkeleton }, - { NULL, C4V_Nil, 0} + { nullptr, C4V_Nil, 0} }; diff --git a/src/object/C4Sector.cpp b/src/object/C4Sector.cpp index 7c04143a3..7f6fff46d 100644 --- a/src/object/C4Sector.cpp +++ b/src/object/C4Sector.cpp @@ -78,7 +78,7 @@ void C4LSectors::Clear() // clear out-sector SectorOut.Clear(); // free sectors - delete [] Sectors; Sectors=NULL; + delete [] Sectors; Sectors=nullptr; } C4LSector *C4LSectors::SectorAt(int ix, int iy) @@ -246,7 +246,7 @@ bool C4LArea::operator == (const C4LArea &Area) const void C4LArea::Set(C4LSectors *pSectors, const C4Rect &Rect) { // default: no area - pFirst=NULL; pOut=NULL; + pFirst=nullptr; pOut=nullptr; // check bounds C4Rect ClippedRect(Rect), Bounds(0, 0, pSectors->PxWdt, pSectors->PxHgt); @@ -279,7 +279,7 @@ C4LSector *C4LArea::Next(C4LSector *pPrev) const { // the outside-sector is the last sector that is returned if (pPrev == pOut) - return NULL; + return nullptr; // within one line? if (pPrev->xObjects; } @@ -325,7 +325,7 @@ C4ObjectList *C4LArea::NextObjectShapes(C4ObjectList *pPrev, C4LSector **ppSct) *ppSct = Next(*ppSct); // nothing left? if (!*ppSct) - return NULL; + return nullptr; // return object list return &(*ppSct)->ObjectShapes; } diff --git a/src/object/C4Sector.h b/src/object/C4Sector.h index c19cb2a02..b10ca352c 100644 --- a/src/object/C4Sector.h +++ b/src/object/C4Sector.h @@ -99,7 +99,7 @@ public: C4LArea(C4LSectors *pSectors, C4Object *pObj) // initializing constructor { Set(pSectors, pObj); } - inline void Clear() { pFirst=pOut=NULL; } // zero sector + inline void Clear() { pFirst=pOut=nullptr; } // zero sector bool operator == (const C4LArea &Area) const; @@ -116,11 +116,11 @@ public: bool Contains(C4LSector *pSct) const; // return whether sector is contained in area inline C4ObjectList *FirstObjects(C4LSector **ppSct) // get first object list of this area - { *ppSct=NULL; return NextObjects(NULL, ppSct); } + { *ppSct=nullptr; return NextObjects(nullptr, ppSct); } C4ObjectList *NextObjects(C4ObjectList *pPrev, C4LSector **ppSct); // get next object list of this area inline C4ObjectList *FirstObjectShapes(C4LSector **ppSct) // get first object shapes list of this area - { *ppSct=NULL; return NextObjectShapes(NULL, ppSct); } + { *ppSct=nullptr; return NextObjectShapes(nullptr, ppSct); } C4ObjectList *NextObjectShapes(C4ObjectList *pPrev, C4LSector **ppSct); // get next object shapes list of this area void DebugRec(class C4Object *pObj, char cMarker); diff --git a/src/object/C4Shape.cpp b/src/object/C4Shape.cpp index 8f1629dd8..02628956b 100644 --- a/src/object/C4Shape.cpp +++ b/src/object/C4Shape.cpp @@ -535,7 +535,7 @@ void C4Shape::CompileFunc(StdCompiler *pComp, const C4Shape *default_shape) { "CNAT_NoCollision", CNAT_NoCollision }, { "CNAT_PhaseHalfVehicle", CNAT_PhaseHalfVehicle }, - { NULL, 0 } + { nullptr, 0 } }; // a default shape is given in object compilation context only diff --git a/src/platform/C4App.h b/src/platform/C4App.h index 81e75823a..10f81a9fd 100644 --- a/src/platform/C4App.h +++ b/src/platform/C4App.h @@ -38,7 +38,7 @@ const char* KeycodeToString(C4KeyCode code); class CStdMessageProc : public StdSchedulerProc { public: - CStdMessageProc() : pApp(NULL) { } + CStdMessageProc() : pApp(nullptr) { } ~CStdMessageProc() { } private: diff --git a/src/platform/C4AppSDL.cpp b/src/platform/C4AppSDL.cpp index d057d50d9..7a26d2a72 100644 --- a/src/platform/C4AppSDL.cpp +++ b/src/platform/C4AppSDL.cpp @@ -72,7 +72,7 @@ static void sdlToC4MCBtn(const SDL_MouseButtonEvent &e, int32_t& button, DWORD& /* C4AbstractApp */ C4AbstractApp::C4AbstractApp(): - Active(false), pWindow(NULL), fQuitMsgReceived(false), + Active(false), pWindow(nullptr), fQuitMsgReceived(false), // main thread #ifdef HAVE_PTHREAD MainThread (pthread_self()), @@ -281,30 +281,30 @@ void C4AbstractApp::HandleSDLEvent(SDL_Event& e) e.key.keysym.mod & (KMOD_LALT | KMOD_RALT), e.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL), e.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT), - e.key.repeat > 0, NULL); + e.key.repeat > 0, nullptr); break; } case SDL_KEYUP: Game.DoKeyboardInput(sdl_scancode_to_keycode(e.key.keysym.scancode), KEYEV_Up, e.key.keysym.mod & (KMOD_LALT | KMOD_RALT), e.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL), - e.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT), false, NULL); + e.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT), false, nullptr); break; case SDL_MOUSEMOTION: - C4GUI::MouseMove(C4MC_Button_None, e.motion.x, e.motion.y, 0, NULL); + C4GUI::MouseMove(C4MC_Button_None, e.motion.x, e.motion.y, 0, nullptr); break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: int32_t button; sdlToC4MCBtn(e.button, button, flags); - C4GUI::MouseMove(button, e.button.x, e.button.y, flags, NULL); + C4GUI::MouseMove(button, e.button.x, e.button.y, flags, nullptr); break; case SDL_MOUSEWHEEL: flags = e.wheel.y > 0 ? (+32) << 16 : (DWORD) (-32) << 16; flags += SDL_GetModState(); int x, y; SDL_GetMouseState(&x, &y); - C4GUI::MouseMove(C4MC_Button_Wheel, x, y, flags, NULL); + C4GUI::MouseMove(C4MC_Button_Wheel, x, y, flags, nullptr); break; case SDL_CONTROLLERAXISMOTION: case SDL_CONTROLLERBUTTONDOWN: diff --git a/src/platform/C4CrashHandlerWin32.cpp b/src/platform/C4CrashHandlerWin32.cpp index 3708b6096..6a2e0533b 100644 --- a/src/platform/C4CrashHandlerWin32.cpp +++ b/src/platform/C4CrashHandlerWin32.cpp @@ -428,7 +428,7 @@ LONG WINAPI GenerateDump(EXCEPTION_POINTERS* pExceptionPointers) if (filename[0] != L'\0') { - file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_DELETE, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); // If we can't create a *new* file to dump into, don't dump at all. if (file == INVALID_HANDLE_VALUE) filename[0] = L'\0'; @@ -457,7 +457,7 @@ LONG WINAPI GenerateDump(EXCEPTION_POINTERS* pExceptionPointers) ExpParam.ExceptionPointers = pExceptionPointers; ExpParam.ClientPointers = true; MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), - file, MiniDumpNormal, &ExpParam, &user_stream_info, NULL); + file, MiniDumpNormal, &ExpParam, &user_stream_info, nullptr); CloseHandle(file); } @@ -599,7 +599,7 @@ namespace { this_thread, expression, file, line }; - HANDLE ctx_thread = CreateThread(NULL, 0L, &dump_thread, &dump_thread_data, 0L, NULL); + HANDLE ctx_thread = CreateThread(nullptr, 0L, &dump_thread, &dump_thread_data, 0L, nullptr); WaitForSingleObject(ctx_thread, INFINITE); CloseHandle(this_thread); CloseHandle(ctx_thread); diff --git a/src/platform/C4FileMonitor.cpp b/src/platform/C4FileMonitor.cpp index 318cf3ee7..0fbaa7f5b 100644 --- a/src/platform/C4FileMonitor.cpp +++ b/src/platform/C4FileMonitor.cpp @@ -106,9 +106,9 @@ void C4FileMonitor::GetFDs(std::vector & fds) #include "platform/C4windowswrapper.h" C4FileMonitor::C4FileMonitor(ChangeNotify pCallback) - : fStarted(false), pCallback(pCallback), pWatches(NULL) + : fStarted(false), pCallback(pCallback), pWatches(nullptr) { - hEvent = CreateEvent(NULL, true, false, NULL); + hEvent = CreateEvent(nullptr, true, false, nullptr); } C4FileMonitor::~C4FileMonitor() @@ -155,7 +155,7 @@ void C4FileMonitor::AddDirectory(const char *szDir) pWatch->Next = pWatches; pWatches = pWatch; // Start async directory change notification - if (!ReadDirectoryChangesW(hDir, pWatch->Buffer, sizeof(pWatch->Buffer), false, C4FileMonitorNotifies, NULL, &pWatch->ov, NULL)) + if (!ReadDirectoryChangesW(hDir, pWatch->Buffer, sizeof(pWatch->Buffer), false, C4FileMonitorNotifies, nullptr, &pWatch->ov, nullptr)) if (GetLastError() != ERROR_IO_PENDING) { delete pWatch; @@ -190,11 +190,11 @@ bool C4FileMonitor::Execute(int iTimeout, pollfd *) break; } // Restart directory change notification (flush queue) - ReadDirectoryChangesW(pWatch->hDir, pWatch->Buffer, sizeof(pWatch->Buffer), false, C4FileMonitorNotifies, NULL, &pWatch->ov, NULL); + ReadDirectoryChangesW(pWatch->hDir, pWatch->Buffer, sizeof(pWatch->Buffer), false, C4FileMonitorNotifies, nullptr, &pWatch->ov, nullptr); dwBytes = 0; while (GetOverlappedResult(pWatch->hDir, &pWatch->ov, &dwBytes, false)) { - ReadDirectoryChangesW(pWatch->hDir, pWatch->Buffer, sizeof(pWatch->Buffer), false, C4FileMonitorNotifies, NULL, &pWatch->ov, NULL); + ReadDirectoryChangesW(pWatch->hDir, pWatch->Buffer, sizeof(pWatch->Buffer), false, C4FileMonitorNotifies, nullptr, &pWatch->ov, nullptr); dwBytes = 0; } } @@ -220,7 +220,7 @@ void C4FileMonitor::HandleNotify(const char *szDir, const _FILE_NOTIFY_INFORMATI // Get filename length UINT iCodePage = CP_UTF8; int iFileNameBytes = WideCharToMultiByte(iCodePage, 0, - pNotify->FileName, pNotify->FileNameLength / 2, NULL, 0, NULL, NULL); + pNotify->FileName, pNotify->FileNameLength / 2, nullptr, 0, nullptr, nullptr); // Set up filename buffer StdCopyStrBuf Path(szDir); Path.AppendChar(DirectorySeparator); @@ -230,7 +230,7 @@ void C4FileMonitor::HandleNotify(const char *szDir, const _FILE_NOTIFY_INFORMATI int iWritten = WideCharToMultiByte(iCodePage, 0, pNotify->FileName, pNotify->FileNameLength / 2, pFilename, iFileNameBytes, - NULL, NULL); + nullptr, nullptr); if (iWritten != iFileNameBytes) Path.Shrink(iFileNameBytes+1); // Send notification diff --git a/src/platform/C4GamePadCon.cpp b/src/platform/C4GamePadCon.cpp index 2179d1ba5..4576393d0 100644 --- a/src/platform/C4GamePadCon.cpp +++ b/src/platform/C4GamePadCon.cpp @@ -103,7 +103,7 @@ void C4GamePadControl::FeedEvent(const SDL_Event& event, int feed) { Game.DoKeyboardInput( C4KeyCodeEx(KEY_Gamepad(keyCode), KEYS_None, false, which), - event, NULL, false, strength); + event, nullptr, false, strength); }; if (feed & FEED_BUTTONS) diff --git a/src/platform/C4MusicFile.cpp b/src/platform/C4MusicFile.cpp index d748bcafe..ec2f391f7 100644 --- a/src/platform/C4MusicFile.cpp +++ b/src/platform/C4MusicFile.cpp @@ -72,8 +72,8 @@ bool C4MusicFile::Init(const char *szFile) #if AUDIO_TK == AUDIO_TK_SDL_MIXER C4MusicFileSDL::C4MusicFileSDL(): - Data(NULL), - Music(NULL) + Data(nullptr), + Music(nullptr) { } @@ -148,13 +148,13 @@ void C4MusicFileSDL::Stop(int fadeout_ms) if (Music) { Mix_FreeMusic(Music); - Music = NULL; + Music = nullptr; } RemTempFile(); if (Data) { delete[] Data; - Data = NULL; + Data = nullptr; } } @@ -248,7 +248,7 @@ bool C4MusicFileOgg::Init(const char *strFile) } // open using callbacks either to memory or to file loader - if (ov_open_callbacks(data_source, &ogg_file, NULL, 0, callbacks) != 0) + if (ov_open_callbacks(data_source, &ogg_file, nullptr, 0, callbacks) != 0) { ov_clear(&ogg_file); return false; diff --git a/src/platform/C4MusicFile.h b/src/platform/C4MusicFile.h index 3e9332e43..e6b89c705 100644 --- a/src/platform/C4MusicFile.h +++ b/src/platform/C4MusicFile.h @@ -28,7 +28,7 @@ class C4MusicFile public: C4MusicFile() : - pNext(NULL), LastPlayed(-1), NoPlay(false), loop(false), SongExtracted(false), announced(false) + pNext(nullptr), LastPlayed(-1), NoPlay(false), loop(false), SongExtracted(false), announced(false) { } virtual ~C4MusicFile() { } diff --git a/src/platform/C4MusicSystem.cpp b/src/platform/C4MusicSystem.cpp index b4e9320ec..61a8a0516 100644 --- a/src/platform/C4MusicSystem.cpp +++ b/src/platform/C4MusicSystem.cpp @@ -29,9 +29,9 @@ #include "game/C4GraphicsSystem.h" C4MusicSystem::C4MusicSystem(): - Songs(NULL), + Songs(nullptr), SongCount(0), - PlayMusicFile(NULL), + PlayMusicFile(nullptr), game_music_level(100), playlist(), playlist_valid(false), @@ -39,10 +39,10 @@ C4MusicSystem::C4MusicSystem(): Volume(100), is_waiting(false), wait_time_end(), - FadeMusicFile(NULL), - upcoming_music_file(NULL) + FadeMusicFile(nullptr), + upcoming_music_file(nullptr) #if AUDIO_TK == AUDIO_TK_OPENAL - , alcDevice(NULL), alcContext(NULL) + , alcDevice(nullptr), alcContext(nullptr) #endif { } @@ -83,20 +83,20 @@ bool C4MusicSystem::InitializeMOD() MODInitialized = true; return true; #elif AUDIO_TK == AUDIO_TK_OPENAL - alcDevice = alcOpenDevice(NULL); + alcDevice = alcOpenDevice(nullptr); if (!alcDevice) { LogF("Sound system: OpenAL create context error"); return false; } - alcContext = alcCreateContext(alcDevice, NULL); + alcContext = alcCreateContext(alcDevice, nullptr); if (!alcContext) { LogF("Sound system: OpenAL create context error"); return false; } #ifndef __APPLE__ - if (!alutInitWithoutContext(NULL, NULL)) + if (!alutInitWithoutContext(nullptr, nullptr)) { LogF("Sound system: ALUT init error"); return false; @@ -119,8 +119,8 @@ void C4MusicSystem::DeinitializeMOD() #endif alcDestroyContext(alcContext); alcCloseDevice(alcDevice); - alcContext = NULL; - alcDevice = NULL; + alcContext = nullptr; + alcDevice = nullptr; #endif MODInitialized = false; } @@ -163,7 +163,7 @@ bool C4MusicSystem::InitForScenario(C4Group & hGroup) LogF(LoadResStr("IDS_PRC_LOCALMUSIC"), MusicDir.getData()); } // check for music folders in group set - C4Group *pMusicFolder = NULL; + C4Group *pMusicFolder = nullptr; while ((pMusicFolder = Game.GroupSet.FindGroup(C4GSCnt_Music, pMusicFolder))) { if (!fLocalMusic) @@ -192,7 +192,7 @@ void C4MusicSystem::Load(const char *szFile) { // safety if (!szFile || !*szFile) return; - C4MusicFile *NewSong=NULL; + C4MusicFile *NewSong=nullptr; #if AUDIO_TK == AUDIO_TK_OPENAL // openal: Only ogg supported const char *szExt = GetExtension(szFile); @@ -209,7 +209,7 @@ void C4MusicSystem::Load(const char *szFile) C4MusicFile *pCurr = Songs; while (pCurr && pCurr->pNext) pCurr = pCurr->pNext; if (pCurr) pCurr->pNext = NewSong; else Songs = NewSong; - NewSong->pNext = NULL; + NewSong->pNext = nullptr; // count songs SongCount++; playlist_valid = false; @@ -218,7 +218,7 @@ void C4MusicSystem::Load(const char *szFile) void C4MusicSystem::LoadDir(const char *szPath) { char Path[_MAX_FNAME + 1], File[_MAX_FNAME + 1]; - C4Group *pDirGroup = NULL; + C4Group *pDirGroup = nullptr; // split path SCopy(szPath, Path, _MAX_FNAME); char *pFileName = GetFilename(Path); @@ -318,7 +318,7 @@ void C4MusicSystem::ClearSongs() delete pFile; } SongCount = 0; - FadeMusicFile = upcoming_music_file = PlayMusicFile = NULL; + FadeMusicFile = upcoming_music_file = PlayMusicFile = nullptr; playlist_valid = false; } @@ -338,9 +338,9 @@ void C4MusicSystem::ClearGame() music_break_min = music_break_max = DefaultMusicBreak; music_break_chance = DefaultMusicBreakChance; music_max_position_memory = DefaultMusicMaxPositionMemory; - SetPlayList(NULL); + SetPlayList(nullptr); is_waiting = false; - upcoming_music_file = NULL; + upcoming_music_file = nullptr; } void C4MusicSystem::Execute(bool force_song_execution) @@ -353,7 +353,7 @@ void C4MusicSystem::Execute(bool force_song_execution) if (tNow >= FadeTimeEnd) { FadeMusicFile->Stop(); - FadeMusicFile = NULL; + FadeMusicFile = nullptr; if (PlayMusicFile) { PlayMusicFile->SetVolume(Volume); @@ -386,7 +386,7 @@ void C4MusicSystem::Execute(bool force_song_execution) // Play a song if no longer in silence mode and nothing is playing right now C4MusicFile *next_file = upcoming_music_file; is_waiting = false; - upcoming_music_file = NULL; + upcoming_music_file = nullptr; if (next_file) Play(next_file, false, 0.0); else @@ -405,7 +405,7 @@ bool C4MusicSystem::Play(const char *szSongname, bool fLoop, int fadetime_ms, do { // pause is done is_waiting = false; - upcoming_music_file = NULL; + upcoming_music_file = nullptr; // music off? if (Game.IsRunning ? !Config.Sound.RXMusic : !Config.Sound.FEMusic) @@ -417,7 +417,7 @@ bool C4MusicSystem::Play(const char *szSongname, bool fLoop, int fadetime_ms, do LogF("MusicSystem: Play(\"%s\", %s, %d, %.3lf, %s)", szSongname ? szSongname : "(null)", fLoop ? "true" : "false", fadetime_ms, max_resume_time, allow_break ? "true" : "false"); } - C4MusicFile* NewFile = NULL; + C4MusicFile* NewFile = nullptr; // Specified song name if (szSongname && szSongname[0]) @@ -530,7 +530,7 @@ bool C4MusicSystem::Play(const char *szSongname, bool fLoop, int fadetime_ms, do } FadeMusicFile = PlayMusicFile; - PlayMusicFile = NULL; + PlayMusicFile = nullptr; FadeTimeStart = tNow; FadeTimeEnd = FadeTimeStart + fadetime_ms; } @@ -624,7 +624,7 @@ void C4MusicSystem::FadeOut(int fadeout_ms) { if (FadeMusicFile) FadeMusicFile->Stop(); FadeMusicFile = PlayMusicFile; - PlayMusicFile = NULL; + PlayMusicFile = nullptr; FadeTimeStart = C4TimeMilliseconds::Now(); FadeTimeEnd = FadeTimeStart + fadeout_ms; } @@ -635,12 +635,12 @@ bool C4MusicSystem::Stop() if (PlayMusicFile) { PlayMusicFile->Stop(); - PlayMusicFile=NULL; + PlayMusicFile=nullptr; } if (FadeMusicFile) { FadeMusicFile->Stop(); - FadeMusicFile = NULL; + FadeMusicFile = nullptr; } return true; } @@ -742,7 +742,7 @@ int C4MusicSystem::SetPlayList(const char *szPlayList, bool fForceSwitch, int fa { // Switch music. Switching to a break is also allowed, but won't be done if there is a piece to resume // Otherwise breaks would never occur if the playlist changes often. - Play(NULL, false, fadetime_ms, max_resume_time, PlayMusicFile != NULL); + Play(nullptr, false, fadetime_ms, max_resume_time, PlayMusicFile != nullptr); } } // Remember setting (e.g. to be saved in savegames) diff --git a/src/platform/C4MusicSystem.h b/src/platform/C4MusicSystem.h index 40dc6d6a0..466626aff 100644 --- a/src/platform/C4MusicSystem.h +++ b/src/platform/C4MusicSystem.h @@ -39,9 +39,9 @@ public: void UpdateVolume(); // compute volume from game + config data void Execute(bool force_buffer_checks = false); void NotifySuccess(); - bool Init(const char * PlayList = NULL); + bool Init(const char * PlayList = nullptr); bool InitForScenario(C4Group & hGroup); - bool Play(const char *szSongname = NULL, bool fLoop = false, int fadetime_ms = 0, double max_resume_time = 0.0, bool allow_break = false); + bool Play(const char *szSongname = nullptr, bool fLoop = false, int fadetime_ms = 0, double max_resume_time = 0.0, bool allow_break = false); bool Play(C4MusicFile *NewFile, bool fLoop, double max_resume_time); bool Stop(); void FadeOut(int fadeout_ms); @@ -125,7 +125,7 @@ enum MusicType { MUSICTYPE_MID, MUSICTYPE_MOD, MUSICTYPE_MP3, MUSICTYPE_OGG, MUS class C4MusicFileInfoNode // We need this for the MoreMusic.txt stuff { public: - C4MusicFileInfoNode() { next=NULL; str=NULL; }; + C4MusicFileInfoNode() { next=nullptr; str=nullptr; }; ~C4MusicFileInfoNode() { if (str) delete [] str; } char* str; MusicType type; diff --git a/src/platform/C4SoundInstance.cpp b/src/platform/C4SoundInstance.cpp index 79c8f3136..2df276679 100644 --- a/src/platform/C4SoundInstance.cpp +++ b/src/platform/C4SoundInstance.cpp @@ -34,8 +34,8 @@ using namespace C4SoundLoaders; C4SoundEffect::C4SoundEffect(): Instances (0), pSample (0), - FirstInst (NULL), - Next (NULL) + FirstInst (nullptr), + Next (nullptr) { Name[0]=0; } @@ -135,10 +135,10 @@ void C4SoundEffect::Execute() C4SoundInstance *C4SoundEffect::New(bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier) { // check: too many instances? - if (!fLoop && Instances >= C4MaxSoundInstances) return NULL; + if (!fLoop && Instances >= C4MaxSoundInstances) return nullptr; // create & init sound instance C4SoundInstance *pInst = new C4SoundInstance(); - if (!pInst->Create(this, fLoop, iVolume, pObj, 0, iCustomFalloffDistance, iPitch, modifier)) { delete pInst; return NULL; } + if (!pInst->Create(this, fLoop, iVolume, pObj, 0, iCustomFalloffDistance, iPitch, modifier)) { delete pInst; return nullptr; } // add to list AddInst(pInst); // return @@ -150,7 +150,7 @@ C4SoundInstance *C4SoundEffect::GetInstance(C4Object *pObj) for (C4SoundInstance *pInst = FirstInst; pInst; pInst = pInst->pNext) if (pInst->getObj() == pObj) return pInst; - return NULL; + return nullptr; } void C4SoundEffect::ClearPointers(C4Object *pObj) @@ -200,14 +200,14 @@ void C4SoundEffect::RemoveInst(C4SoundInstance *pInst) C4SoundInstance::C4SoundInstance(): - pEffect (NULL), + pEffect (nullptr), iVolume(0), iPan(0), iPitch(0), player(NO_OWNER), pitch_dirty(false), iChannel (-1), - modifier(NULL), + modifier(nullptr), has_local_modifier(false), - pNext (NULL) + pNext (nullptr) { } @@ -223,7 +223,7 @@ void C4SoundInstance::Clear() if (modifier) { modifier->DelRef(); - modifier = NULL; + modifier = nullptr; has_local_modifier = false; } } @@ -418,7 +418,7 @@ void C4SoundInstance::ClearPointers(C4Object *pDelete) // otherwise: set volume by last position else SetVolumeByPos(pObj->GetX(), pObj->GetY()); - pObj = NULL; + pObj = nullptr; } } @@ -438,7 +438,7 @@ void C4SoundInstance::SetModifier(C4SoundModifier *new_modifier, bool is_global) else { // this sound has its own modifier now and doesn't care for global ones - has_local_modifier = (new_modifier != NULL); + has_local_modifier = (new_modifier != nullptr); } if (new_modifier != modifier) { diff --git a/src/platform/C4SoundInstance.h b/src/platform/C4SoundInstance.h index 89eb6d1a6..76af9bb7e 100644 --- a/src/platform/C4SoundInstance.h +++ b/src/platform/C4SoundInstance.h @@ -42,7 +42,7 @@ public: bool Load(const char *szFileName, C4Group &hGroup, const char *namespace_prefix); bool Load(BYTE *pData, size_t iDataLen, bool fRaw=false); // load directly from memory void Execute(); - C4SoundInstance *New(bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iCustomFalloffDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = NULL); + C4SoundInstance *New(bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = nullptr, int32_t iCustomFalloffDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = nullptr); C4SoundInstance *GetInstance(C4Object *pObj); void ClearPointers(C4Object *pObj); int32_t GetStartedInstanceCount(int32_t iX, int32_t iY, int32_t iRad); // local @@ -85,7 +85,7 @@ public: C4Object *getObj() const { return pObj; } bool isStarted() const { return iChannel != -1; } void Clear(); - bool Create(C4SoundEffect *pEffect, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iNearInstanceMax = 0, int32_t iFalloffDistance = 0, int32_t inPitch = 0, C4SoundModifier *modifier = NULL); + bool Create(C4SoundEffect *pEffect, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = nullptr, int32_t iNearInstanceMax = 0, int32_t iFalloffDistance = 0, int32_t inPitch = 0, C4SoundModifier *modifier = nullptr); bool CheckStart(); bool Start(); bool Stop(); diff --git a/src/platform/C4SoundLoaders.cpp b/src/platform/C4SoundLoaders.cpp index 5e10ff2b9..cbed9f695 100644 --- a/src/platform/C4SoundLoaders.cpp +++ b/src/platform/C4SoundLoaders.cpp @@ -23,7 +23,7 @@ using namespace C4SoundLoaders; -SoundLoader* SoundLoader::first_loader(NULL); +SoundLoader* SoundLoader::first_loader(nullptr); #if AUDIO_TK == AUDIO_TK_OPENAL && defined(__APPLE__) namespace @@ -57,9 +57,9 @@ bool AppleSoundLoader::ReadInfo(SoundInfo* result, BYTE* data, size_t data_lengt AudioFileID sound_file; OSStatus err = AudioFileOpenWithCallbacks((void*)data_container, AudioToolBoxReadCallback, - NULL, + nullptr, AudioToolBoxGetSizeProc, - NULL, + nullptr, 0, &sound_file ); @@ -198,7 +198,7 @@ bool VorbisLoader::ReadInfo(SoundInfo* result, BYTE* data, size_t data_length, u callbacks.tell_func = &mem_tell_func; // open using callbacks - if (ov_open_callbacks(&compressed, &ogg_file, NULL, 0, callbacks) != 0) + if (ov_open_callbacks(&compressed, &ogg_file, nullptr, 0, callbacks) != 0) { ov_clear(&ogg_file); return false; diff --git a/src/platform/C4SoundLoaders.h b/src/platform/C4SoundLoaders.h index cdf098b06..c94e85842 100644 --- a/src/platform/C4SoundLoaders.h +++ b/src/platform/C4SoundLoaders.h @@ -75,12 +75,12 @@ namespace C4SoundLoaders size_t data_pos; bool is_data_owned; // if true, dtor will delete data CompressedData(BYTE* data, size_t data_length): data(data), data_length(data_length), data_pos(0), is_data_owned(false) {} - CompressedData() : data(NULL), data_length(0), data_pos(0), is_data_owned(false) {} + CompressedData() : data(nullptr), data_length(0), data_pos(0), is_data_owned(false) {} void SetOwnedData(BYTE* data, size_t data_length) { clear(); this->data=data; this->data_length=data_length; this->data_pos=0; is_data_owned=true; } ~CompressedData() { clear(); } - void clear() { if (is_data_owned) delete [] data; data=NULL; } + void clear() { if (is_data_owned) delete [] data; data=nullptr; } }; // load from compressed data held in memory buffer static size_t mem_read_func(void* ptr, size_t byte_size, size_t size_to_read, void* datasource); diff --git a/src/platform/C4SoundModifiers.cpp b/src/platform/C4SoundModifiers.cpp index f12c41cdb..c6bbc1495 100644 --- a/src/platform/C4SoundModifiers.cpp +++ b/src/platform/C4SoundModifiers.cpp @@ -299,10 +299,10 @@ C4SoundModifier *C4SoundModifierList::Get(class C4PropList *props, bool create_i [props](const C4SoundModifier *mod) { return mod->GetProps() == props; }); if (iter != sound_modifiers.end()) return *iter; // if not found, create if desired - if (!create_if_not_found) return NULL; + if (!create_if_not_found) return nullptr; C4SoundModifier *modifier; int32_t effect_type = props->GetPropertyInt(P_Type); - if (!is_effect_available[effect_type]) return NULL; // Not supported D: + if (!is_effect_available[effect_type]) return nullptr; // Not supported D: switch (effect_type) { case C4SoundModifier::C4SMT_Reverb: @@ -316,7 +316,7 @@ C4SoundModifier *C4SoundModifierList::Get(class C4PropList *props, bool create_i break; default: // invalid modifier - return NULL; + return nullptr; } // initial parameter settings modifier->Update(); @@ -349,7 +349,7 @@ C4SoundModifier *C4SoundModifierList::GetGlobalModifier(int32_t player_index) co { // safety int32_t list_index = player_index + 1; - if (list_index < 0 || static_cast(list_index) >= global_modifiers.size()) return NULL; + if (list_index < 0 || static_cast(list_index) >= global_modifiers.size()) return nullptr; // get from player and fall back to global list C4SoundModifier *result = global_modifiers[list_index]; if (!result && list_index) result = global_modifiers[0]; diff --git a/src/platform/C4SoundSystem.cpp b/src/platform/C4SoundSystem.cpp index 25a0a9185..dec1945ad 100644 --- a/src/platform/C4SoundSystem.cpp +++ b/src/platform/C4SoundSystem.cpp @@ -31,7 +31,7 @@ #include "platform/C4SoundLoaders.h" C4SoundSystem::C4SoundSystem(): - FirstSound (NULL) + FirstSound (nullptr) { } @@ -54,7 +54,7 @@ bool C4SoundSystem::Init() if (!SoundFile.IsOpen()) if (!Reloc.Open(SoundFile, C4CFN_Sound)) return false; // Load static sound from Sound.ocg - LoadEffects(SoundFile, NULL, false); + LoadEffects(SoundFile, nullptr, false); #if AUDIO_TK == AUDIO_TK_SDL_MIXER Mix_AllocateChannels(C4MaxSoundInstances); #endif @@ -78,7 +78,7 @@ void C4SoundSystem::ClearEffects() next=csfx->Next; delete csfx; } - FirstSound=NULL; + FirstSound=nullptr; } void C4SoundSystem::Execute() @@ -115,7 +115,7 @@ C4SoundEffect* C4SoundSystem::GetEffect(const char *szSndName) ++iNumber; // Nothing found? Abort if(iNumber == 0) - return NULL; + return nullptr; iNumber=UnsyncedRandom(iNumber)+1; } // Find requested sound effect in bank @@ -124,20 +124,20 @@ C4SoundEffect* C4SoundSystem::GetEffect(const char *szSndName) if (WildcardMatch(szName,pSfx->Name)) if(!--iNumber) break; - return pSfx; // Is still NULL if nothing is found + return pSfx; // Is still nullptr if nothing is found } C4SoundInstance *C4SoundSystem::NewEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier) { // Sound not active - if (!Config.Sound.RXSound) return NULL; + if (!Config.Sound.RXSound) return nullptr; // Get sound C4SoundEffect *csfx; if (!(csfx = GetEffect(szSndName))) { // Warn about missing or incorrectly spelled sound to allow finding mistakes earlier. DebugLogF("Warning: could not find sound matching '%s'", szSndName); - return NULL; + return nullptr; } // Play return csfx->New(fLoop, iVolume, pObj, iCustomFalloffDistance, iPitch, modifier); @@ -156,7 +156,7 @@ C4SoundInstance *C4SoundSystem::FindInstance(const char *szSndName, C4Object *pO C4SoundInstance *pInst = csfx->GetInstance(pObj); if (pInst) return pInst; } - return NULL; + return nullptr; } // LoadEffects will load all sound effects of all known sound types (i.e. *.wav and *.ogg) as defined in C4CFN_SoundFiles @@ -225,7 +225,7 @@ int32_t C4SoundSystem::LoadEffects(C4Group &hGroup, const char *namespace_prefix int32_t C4SoundSystem::RemoveEffect(const char *szFilename) { int32_t iResult=0; - C4SoundEffect *pNext,*pPrev=NULL; + C4SoundEffect *pNext,*pPrev=nullptr; for (C4SoundEffect *pSfx=FirstSound; pSfx; pSfx=pNext) { pNext=pSfx->Next; @@ -253,7 +253,7 @@ C4SoundInstance *C4SoundSystem::GetFirstInstance() const // Return by searching through effect linked list. for (C4SoundEffect *pSfx = FirstSound; pSfx; pSfx = pSfx->Next) if (pSfx->FirstInst) return pSfx->FirstInst; - return NULL; + return nullptr; } C4SoundInstance *C4SoundSystem::GetNextInstance(C4SoundInstance *prev) const @@ -263,13 +263,13 @@ C4SoundInstance *C4SoundSystem::GetNextInstance(C4SoundInstance *prev) const if (prev->pNext) return prev->pNext; for (C4SoundEffect *pSfx = prev->pEffect->Next; pSfx; pSfx = pSfx->Next) if (pSfx->FirstInst) return pSfx->FirstInst; - return NULL; + return nullptr; } C4SoundInstance *StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier) { // Sound check - if (!Config.Sound.RXSound) return NULL; + if (!Config.Sound.RXSound) return nullptr; // Start new return Application.SoundSystem.NewEffect(szSndName, fLoop, iVolume, pObj, iCustomFalloffDistance, iPitch, modifier); } @@ -277,9 +277,9 @@ C4SoundInstance *StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVo C4SoundInstance *StartSoundEffectAt(const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume, int32_t iCustomFallofDistance, int32_t iPitch, C4SoundModifier *modifier) { // Sound check - if (!Config.Sound.RXSound) return NULL; + if (!Config.Sound.RXSound) return nullptr; // Create - C4SoundInstance *pInst = StartSoundEffect(szSndName, false, iVolume, NULL, iCustomFallofDistance, iPitch, modifier); + C4SoundInstance *pInst = StartSoundEffect(szSndName, false, iVolume, nullptr, iCustomFallofDistance, iPitch, modifier); // Set volume by position if (pInst) pInst->SetVolumeByPos(iX, iY); // Return diff --git a/src/platform/C4SoundSystem.h b/src/platform/C4SoundSystem.h index 47826ee6f..84c64aeb5 100644 --- a/src/platform/C4SoundSystem.h +++ b/src/platform/C4SoundSystem.h @@ -43,7 +43,7 @@ public: void Clear(); void Execute(); int32_t LoadEffects(C4Group &hGroup, const char *namespace_prefix, bool group_is_root); - C4SoundInstance *NewEffect(const char *szSound, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iCustomFalloffDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = NULL); + C4SoundInstance *NewEffect(const char *szSound, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = nullptr, int32_t iCustomFalloffDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = nullptr); C4SoundInstance *FindInstance(const char *szSound, C4Object *pObj); C4SoundInstance *GetFirstInstance() const; C4SoundInstance *GetNextInstance(C4SoundInstance *prev) const; @@ -60,8 +60,8 @@ protected: int32_t RemoveEffect(const char *szFilename); }; -C4SoundInstance *StartSoundEffect(const char *szSndName, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iCustomFalloffDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = NULL); -C4SoundInstance *StartSoundEffectAt(const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume = 100, int32_t iCustomFallofDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = NULL); +C4SoundInstance *StartSoundEffect(const char *szSndName, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = nullptr, int32_t iCustomFalloffDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = nullptr); +C4SoundInstance *StartSoundEffectAt(const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume = 100, int32_t iCustomFallofDistance = 0, int32_t iPitch = 0, C4SoundModifier *modifier = nullptr); C4SoundInstance *GetSoundInstance(const char *szSndName, C4Object *pObj); void StopSoundEffect(const char *szSndName, C4Object *pObj); void SoundLevel(const char *szSndName, C4Object *pObj, int32_t iLevel); diff --git a/src/platform/C4WindowSDL.cpp b/src/platform/C4WindowSDL.cpp index b6d788d56..b671e0a58 100644 --- a/src/platform/C4WindowSDL.cpp +++ b/src/platform/C4WindowSDL.cpp @@ -185,7 +185,7 @@ static void SetUrgencyHint(SDL_Window *window, bool urgency_hint) { auto x11 = wminfo.info.x11; XWMHints *wmhints = XGetWMHints(x11.display, x11.window); - if (wmhints == NULL) + if (wmhints == nullptr) wmhints = XAllocWMHints(); // Set the window's urgency hint. if (urgency_hint) diff --git a/src/platform/C4WindowWin32.cpp b/src/platform/C4WindowWin32.cpp index b3a155890..6a4e203fe 100644 --- a/src/platform/C4WindowWin32.cpp +++ b/src/platform/C4WindowWin32.cpp @@ -120,7 +120,7 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l { if (Application.FullScreenMode()) { - ::ChangeDisplaySettings(NULL, 0); + ::ChangeDisplaySettings(nullptr, 0); ::ShowWindow(hwnd, SW_MINIMIZE); } } @@ -150,16 +150,16 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l Application.MusicSystem.NotifySuccess(); return true; case WM_KEYUP: - if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, NULL)) + if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, nullptr)) return 0; break; case WM_KEYDOWN: - if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), nullptr)) return 0; break; case WM_SYSKEYDOWN: if (wParam == 18) break; - if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), nullptr)) { // Remove handled message from queue to prevent Windows "standard" sound for unprocessed system message MSG msg; @@ -185,21 +185,21 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l Log((const char *)lParam); return false; case WM_LBUTTONDOWN: - C4GUI::MouseMove(C4MC_Button_LeftDown,p.x,p.y,wParam, NULL); + C4GUI::MouseMove(C4MC_Button_LeftDown,p.x,p.y,wParam, nullptr); break; - case WM_LBUTTONUP: C4GUI::MouseMove(C4MC_Button_LeftUp, p.x, p.y, wParam, NULL); break; - case WM_RBUTTONDOWN: C4GUI::MouseMove(C4MC_Button_RightDown, p.x, p.y, wParam, NULL); break; - case WM_RBUTTONUP: C4GUI::MouseMove(C4MC_Button_RightUp, p.x, p.y, wParam, NULL); break; - case WM_LBUTTONDBLCLK: C4GUI::MouseMove(C4MC_Button_LeftDouble, p.x, p.y, wParam, NULL); break; - case WM_RBUTTONDBLCLK: C4GUI::MouseMove(C4MC_Button_RightDouble, p.x, p.y, wParam, NULL); break; + case WM_LBUTTONUP: C4GUI::MouseMove(C4MC_Button_LeftUp, p.x, p.y, wParam, nullptr); break; + case WM_RBUTTONDOWN: C4GUI::MouseMove(C4MC_Button_RightDown, p.x, p.y, wParam, nullptr); break; + case WM_RBUTTONUP: C4GUI::MouseMove(C4MC_Button_RightUp, p.x, p.y, wParam, nullptr); break; + case WM_LBUTTONDBLCLK: C4GUI::MouseMove(C4MC_Button_LeftDouble, p.x, p.y, wParam, nullptr); break; + case WM_RBUTTONDBLCLK: C4GUI::MouseMove(C4MC_Button_RightDouble, p.x, p.y, wParam, nullptr); break; case WM_MOUSEWHEEL: // the coordinates are screen-coordinates here (but only on this uMsg), // we need to convert them to client area coordinates ScreenToClient(hwnd, &p); - C4GUI::MouseMove(C4MC_Button_Wheel, p.x, p.y, wParam, NULL); + C4GUI::MouseMove(C4MC_Button_Wheel, p.x, p.y, wParam, nullptr); break; case WM_MOUSEMOVE: - C4GUI::MouseMove(C4MC_Button_None, p.x, p.y, wParam, NULL); + C4GUI::MouseMove(C4MC_Button_None, p.x, p.y, wParam, nullptr); // Hide cursor in client area if (NativeCursorShown) { @@ -223,7 +223,7 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l case SIZE_MAXIMIZED: ::Application.OnResolutionChanged(p.x, p.y); if(Application.pWindow) // this might be called from C4Window::Init in which case Application.pWindow is not yet set - ::SetWindowPos(Application.pWindow->renderwnd, NULL, 0, 0, p.x, p.y, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOZORDER); + ::SetWindowPos(Application.pWindow->renderwnd, nullptr, 0, 0, p.x, p.y, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOZORDER); break; } break; @@ -255,14 +255,14 @@ bool ConsoleHandleWin32KeyboardMessage(MSG *msg) switch (msg->message) { case WM_KEYDOWN: - if (Game.DoKeyboardInput(msg2scancode(msg), KEYEV_Down, !!(msg->lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(msg->lParam & 0x40000000), NULL)) return true; + if (Game.DoKeyboardInput(msg2scancode(msg), KEYEV_Down, !!(msg->lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(msg->lParam & 0x40000000), nullptr)) return true; break; case WM_KEYUP: - if (Game.DoKeyboardInput(msg2scancode(msg), KEYEV_Up, !!(msg->lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, NULL)) return 0; + if (Game.DoKeyboardInput(msg2scancode(msg), KEYEV_Up, !!(msg->lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, nullptr)) return 0; break; case WM_SYSKEYDOWN: if (msg->wParam == 18) break; // VK_MENU (Alt) - if (Game.DoKeyboardInput(msg2scancode(msg), KEYEV_Down, !!(msg->lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(msg->lParam & 0x40000000), NULL)) return 0; + if (Game.DoKeyboardInput(msg2scancode(msg), KEYEV_Down, !!(msg->lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(msg->lParam & 0x40000000), nullptr)) return 0; break; } return false; @@ -296,19 +296,19 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - default: - if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0; + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), nullptr)) return 0; break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } break; //--------------------------------------------------------------------------------------------------------------------------- case WM_KEYUP: - if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, NULL)) return 0; + if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, nullptr)) return 0; break; //------------------------------------------------------------------------------------------------------------ case WM_SYSKEYDOWN: if (wParam == 18) break; - if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0; + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), nullptr)) return 0; break; //---------------------------------------------------------------------------------------------------------------------------------- case WM_DESTROY: @@ -328,7 +328,7 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa HDROP hDrop = (HDROP)(HANDLE) wParam; if (!Console.Editing) { Console.Message(LoadResStr("IDS_CNS_NONETEDIT")); return false; } - int32_t iFileNum = DragQueryFile(hDrop,0xFFFFFFFF,NULL,0); + int32_t iFileNum = DragQueryFile(hDrop,0xFFFFFFFF,nullptr,0); POINT pntPoint; DragQueryPoint(hDrop,&pntPoint); wchar_t szFilename[500+1]; @@ -435,7 +435,7 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa case WM_MOUSEMOVE: if ( Inside(p.x-cvp->DrawX,0,cvp->ViewWdt-1) && Inside(p.y-cvp->DrawY,0,cvp->ViewHgt-1) ) - SetCursor(NULL); + SetCursor(nullptr); C4GUI::MouseMove(C4MC_Button_None, p.x, p.y, wParam, cvp); break; //---------------------------------------------------------------------------------------------------------------------------------- @@ -545,25 +545,25 @@ LRESULT APIENTRY DialogWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara break; return 0; //---------------------------------------------------------------------------------------------------------------------------------- - case WM_LBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_LeftDown, p.x, p.y, wParam, pDlg, NULL); break; + case WM_LBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_LeftDown, p.x, p.y, wParam, pDlg, nullptr); break; //---------------------------------------------------------------------------------------------------------------------------------- - case WM_LBUTTONUP: ::pGUI->MouseInput(C4MC_Button_LeftUp, p.x, p.y, wParam, pDlg, NULL); break; + case WM_LBUTTONUP: ::pGUI->MouseInput(C4MC_Button_LeftUp, p.x, p.y, wParam, pDlg, nullptr); break; //---------------------------------------------------------------------------------------------------------------------------------- - case WM_RBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_RightDown, p.x, p.y, wParam, pDlg, NULL); break; + case WM_RBUTTONDOWN: ::pGUI->MouseInput(C4MC_Button_RightDown, p.x, p.y, wParam, pDlg, nullptr); break; //---------------------------------------------------------------------------------------------------------------------------------- - case WM_RBUTTONUP: ::pGUI->MouseInput(C4MC_Button_RightUp, p.x, p.y, wParam, pDlg, NULL); break; + case WM_RBUTTONUP: ::pGUI->MouseInput(C4MC_Button_RightUp, p.x, p.y, wParam, pDlg, nullptr); break; //---------------------------------------------------------------------------------------------------------------------------------- - case WM_LBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_LeftDouble, p.x, p.y, wParam, pDlg, NULL); break; + case WM_LBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_LeftDouble, p.x, p.y, wParam, pDlg, nullptr); break; //---------------------------------------------------------------------------------------------------------------------------------- - case WM_RBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_RightDouble, p.x, p.y, wParam, pDlg, NULL); break; + case WM_RBUTTONDBLCLK: ::pGUI->MouseInput(C4MC_Button_RightDouble, p.x, p.y, wParam, pDlg, nullptr); break; //---------------------------------------------------------------------------------------------------------------------------------- case WM_MOUSEMOVE: - ::pGUI->MouseInput(C4MC_Button_None, p.x, p.y, wParam, pDlg, NULL); + ::pGUI->MouseInput(C4MC_Button_None, p.x, p.y, wParam, pDlg, nullptr); break; //---------------------------------------------------------------------------------------------------------------------------------- case WM_MOUSEWHEEL: ScreenToClient(hwnd, &p); - ::pGUI->MouseInput(C4MC_Button_Wheel, p.x, p.y, wParam, pDlg, NULL); + ::pGUI->MouseInput(C4MC_Button_Wheel, p.x, p.y, wParam, pDlg, nullptr); break; //---------------------------------------------------------------------------------------------------------------------------------- } @@ -603,13 +603,13 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = pApp->GetInstance(); - WndClass.hCursor = LoadCursor (NULL, IDC_ARROW); + WndClass.hCursor = LoadCursor (nullptr, IDC_ARROW); WndClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND; - WndClass.lpszMenuName = NULL; + WndClass.lpszMenuName = nullptr; WndClass.lpszClassName = C4ViewportClassName; WndClass.hIcon = LoadIcon (pApp->GetInstance(), MAKEINTRESOURCE (IDI_01_OCS) ); WndClass.hIconSm = LoadIcon (pApp->GetInstance(), MAKEINTRESOURCE (IDI_01_OCS) ); - if (!RegisterClassExW(&WndClass)) return NULL; + if (!RegisterClassExW(&WndClass)) return nullptr; fViewportClassRegistered = true; } // Create window @@ -617,8 +617,8 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, WS_EX_ACCEPTFILES, C4ViewportClassName, GetWideChar(Title), C4ViewportWindowStyle, CW_USEDEFAULT,CW_USEDEFAULT, size->Wdt, size->Hgt, - Console.hWindow,NULL,pApp->GetInstance(),NULL); - if(!hWindow) return NULL; + Console.hWindow,nullptr,pApp->GetInstance(),nullptr); + if(!hWindow) return nullptr; #endif // We don't re-init viewport windows currently, so we don't need a child window // for now: Render into main window. @@ -636,7 +636,7 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, WndClass.lpszClassName = C4FullScreenClassName; WndClass.hIcon = LoadIcon (pApp->GetInstance(), MAKEINTRESOURCE (IDI_00_C4X) ); WndClass.hIconSm = LoadIcon (pApp->GetInstance(), MAKEINTRESOURCE (IDI_00_C4X) ); - if (!RegisterClassExW(&WndClass)) return NULL; + if (!RegisterClassExW(&WndClass)) return nullptr; // Create window hWindow = CreateWindowExW ( @@ -645,15 +645,15 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, GetWideChar(Title), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT, size->Wdt, size->Hgt, - NULL,NULL,pApp->GetInstance(),NULL); - if(!hWindow) return NULL; + nullptr,nullptr,pApp->GetInstance(),nullptr); + if(!hWindow) return nullptr; RECT rc; GetClientRect(hWindow, &rc); - renderwnd = CreateWindowExW(0, L"STATIC", NULL, WS_CHILD, + renderwnd = CreateWindowExW(0, L"STATIC", nullptr, WS_CHILD, 0, 0, rc.right - rc.left, rc.bottom - rc.top, - hWindow, NULL, pApp->GetInstance(), NULL); - if(!renderwnd) { DestroyWindow(hWindow); return NULL; } + hWindow, nullptr, pApp->GetInstance(), nullptr); + if(!renderwnd) { DestroyWindow(hWindow); return nullptr; } ShowWindow(renderwnd, SW_SHOW); #ifndef USE_CONSOLE @@ -675,14 +675,14 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = pApp->GetInstance(); - WndClass.hCursor = LoadCursor (NULL, IDC_ARROW); // - always use normal hw cursor + WndClass.hCursor = LoadCursor (nullptr, IDC_ARROW); // - always use normal hw cursor WndClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND; - WndClass.lpszMenuName = NULL; + WndClass.lpszMenuName = nullptr; WndClass.lpszClassName = ConsoleDlgClassName; WndClass.hIcon = LoadIcon (pApp->GetInstance(), MAKEINTRESOURCE (IDI_00_C4X) ); WndClass.hIconSm = LoadIcon (pApp->GetInstance(), MAKEINTRESOURCE (IDI_00_C4X) ); if (!RegisterClassExW(&WndClass)) - return NULL; + return nullptr; } Active = true; // calculate required size @@ -692,7 +692,7 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, rtSize.right = size->Wdt; rtSize.bottom = size->Hgt; if (!::AdjustWindowRectEx(&rtSize, ConsoleDlgWindowStyle, false, 0)) - return NULL; + return nullptr; // create it! if (!Title || !*Title) Title = "???"; hWindow = ::CreateWindowExW( @@ -700,14 +700,14 @@ C4Window * C4Window::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, ConsoleDlgClassName, GetWideChar(Title), ConsoleDlgWindowStyle, CW_USEDEFAULT,CW_USEDEFAULT,rtSize.right-rtSize.left,rtSize.bottom-rtSize.top, - ::Console.hWindow,NULL,pApp->GetInstance(),NULL); + ::Console.hWindow,nullptr,pApp->GetInstance(),nullptr); renderwnd = hWindow; return hWindow ? this : 0; } else if (windowKind == W_Control) { // controlled externally - hWindow = renderwnd = NULL; + hWindow = renderwnd = nullptr; } return this; } @@ -722,9 +722,9 @@ bool C4Window::ReInit(C4AbstractApp* pApp) RECT rc; GetClientRect(hWindow, &rc); - HWND hNewRenderWindow = CreateWindowExW(0, L"STATIC", NULL, WS_CHILD, + HWND hNewRenderWindow = CreateWindowExW(0, L"STATIC", nullptr, WS_CHILD, 0, 0, rc.right - rc.left, rc.bottom - rc.top, - hWindow, NULL, pApp->hInstance, NULL); + hWindow, nullptr, pApp->hInstance, nullptr); if(!hNewRenderWindow) return false; ShowWindow(hNewRenderWindow, SW_SHOW); @@ -749,8 +749,8 @@ void C4Window::Clear() ::Console.RemoveViewport(static_cast(this)); } #endif - renderwnd = NULL; - hWindow = NULL; + renderwnd = nullptr; + hWindow = nullptr; } bool C4Window::StorePosition(const char *szWindowName, const char *szSubKey, bool fStoreSize) @@ -790,11 +790,11 @@ void C4Window::SetSize(unsigned int cx, unsigned int cy) ::AdjustWindowRectEx(&rect, GetWindowLong(hWindow, GWL_STYLE), FALSE, GetWindowLong(hWindow, GWL_EXSTYLE)); cx = rect.right - rect.left; cy = rect.bottom - rect.top; - ::SetWindowPos(hWindow, NULL, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOZORDER); + ::SetWindowPos(hWindow, nullptr, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOZORDER); // Also resize child window GetClientRect(hWindow, &rect); - ::SetWindowPos(renderwnd, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOZORDER); + ::SetWindowPos(renderwnd, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOZORDER); } } @@ -824,7 +824,7 @@ bool CStdMessageProc::Execute(int iTimeout, pollfd *) { // Peek messages MSG msg; - while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) + while (PeekMessage(&msg,nullptr,0,0,PM_REMOVE)) { // quit? if (msg.message == WM_QUIT) @@ -844,8 +844,8 @@ bool CStdMessageProc::Execute(int iTimeout, pollfd *) /* C4AbstractApp */ C4AbstractApp::C4AbstractApp() : - Active(false), pWindow(NULL), fQuitMsgReceived(false), - hInstance(NULL), fDspModeSet(false) + Active(false), pWindow(nullptr), fQuitMsgReceived(false), + hInstance(nullptr), fDspModeSet(false) { ZeroMemory(&dspMode, sizeof(dspMode)); dspMode.dmSize = sizeof(dspMode); ZeroMemory(&OldDspMode, sizeof(OldDspMode)); OldDspMode.dmSize = sizeof(OldDspMode); @@ -945,14 +945,14 @@ bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate if (!fFullScreen) { - ChangeDisplaySettings(NULL, 0); + ChangeDisplaySettings(nullptr, 0); SetWindowLong(pWindow->hWindow, GWL_STYLE, GetWindowLong(pWindow->hWindow, GWL_STYLE) | (WS_CAPTION|WS_THICKFRAME|WS_BORDER)); if(iXRes != -1 && iYRes != -1) { pWindow->SetSize(iXRes, iYRes); OnResolutionChanged(iXRes, iYRes); } - ::SetWindowPos(pWindow->hWindow, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_FRAMECHANGED); + ::SetWindowPos(pWindow->hWindow, nullptr, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_FRAMECHANGED); } else { @@ -961,8 +961,8 @@ bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate // if a monitor is given, search on that instead // get monitor infos GLMonitorInfoEnumCount = iMonitor; - hMon = NULL; - EnumDisplayMonitors(NULL, NULL, GLMonitorInfoEnumProc, (LPARAM) this); + hMon = nullptr; + EnumDisplayMonitors(nullptr, nullptr, GLMonitorInfoEnumProc, (LPARAM) this); // no monitor assigned? if (!hMon) { @@ -1010,7 +1010,7 @@ bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate dspMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if (iRefreshRate != 0) dspMode.dmFields |= DM_DISPLAYFREQUENCY; - DWORD rv = ChangeDisplaySettingsExW(iMonitor ? Mon.GetWideChar() : NULL, &dspMode, NULL, CDS_FULLSCREEN, NULL); + DWORD rv = ChangeDisplaySettingsExW(iMonitor ? Mon.GetWideChar() : nullptr, &dspMode, nullptr, CDS_FULLSCREEN, nullptr); if (rv != DISP_CHANGE_SUCCESSFUL) { switch (rv) @@ -1034,7 +1034,7 @@ bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate pWindow->SetSize(dspMode.dmPelsWidth, dspMode.dmPelsHeight); OnResolutionChanged(dspMode.dmPelsWidth, dspMode.dmPelsHeight); - ::SetWindowPos(pWindow->hWindow, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_FRAMECHANGED); + ::SetWindowPos(pWindow->hWindow, nullptr, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_FRAMECHANGED); } return true; #endif @@ -1051,12 +1051,12 @@ bool C4AbstractApp::Copy(const StdStrBuf & text, bool fClipboard) if (!fClipboard) return false; bool fSuccess = true; // gain clipboard ownership - if (!OpenClipboard(pWindow ? pWindow->hWindow : NULL)) return false; + if (!OpenClipboard(pWindow ? pWindow->hWindow : nullptr)) return false; // must empty the global clipboard, so the application clipboard equals the Windows clipboard EmptyClipboard(); int size = MultiByteToWideChar(CP_UTF8, 0, text.getData(), text.getSize(), 0, 0); HANDLE hglbCopy = GlobalAlloc(GMEM_MOVEABLE, size * sizeof(wchar_t)); - if (hglbCopy == NULL) { CloseClipboard(); return false; } + if (hglbCopy == nullptr) { CloseClipboard(); return false; } // lock the handle and copy the text to the buffer. wchar_t *szCopyChar = (wchar_t *) GlobalLock(hglbCopy); fSuccess = !!MultiByteToWideChar(CP_UTF8, 0, text.getData(), text.getSize(), szCopyChar, size); @@ -1073,7 +1073,7 @@ StdStrBuf C4AbstractApp::Paste(bool fClipboard) { if (!fClipboard) return StdStrBuf(); // open clipboard - if (!OpenClipboard(NULL)) return StdStrBuf(); + if (!OpenClipboard(nullptr)) return StdStrBuf(); // get text from clipboard HANDLE hglb = GetClipboardData(CF_UNICODETEXT); if (!hglb) return StdStrBuf(); diff --git a/src/platform/CocoaKeycodeMap.h b/src/platform/CocoaKeycodeMap.h index 316a8f5cd..1cf73dd73 100644 --- a/src/platform/CocoaKeycodeMap.h +++ b/src/platform/CocoaKeycodeMap.h @@ -16,10 +16,10 @@ #define K(k,s,a) {k+CocoaKeycodeOffset,s,a} const C4KeyCodeMapEntry KeyCodeMap [] = { - { K_BACK , "Backspace" , NULL }, - { K_TAB , "Tab" , NULL }, - //{ VK_CLEAR , "Clear" , NULL }, - { K_RETURN , "Return" , NULL }, + { K_BACK , "Backspace" , nullptr }, + { K_TAB , "Tab" , nullptr }, + //{ VK_CLEAR , "Clear" , nullptr }, + { K_RETURN , "Return" , nullptr }, { K_SHIFT_L , "LeftShift" , "LShift" }, { K_SHIFT_R , "RightShift" , "RShift" }, @@ -27,86 +27,86 @@ const C4KeyCodeMapEntry KeyCodeMap [] = { K_CONTROL_R , "RightControl" , "RCtrl" }, { K_ALT_L , "LeftAlt" , "LAlt" }, { K_ALT_R , "RightAlt" , "RAlt" }, - { K_PAUSE , "Pause" , NULL }, + { K_PAUSE , "Pause" , nullptr }, -/* K( VK_CAPITAL , "Capital" , NULL ), - K( VK_KANA , "Kana" , NULL ), - K( VK_HANGEUL , "Hangeul" , NULL ), - K( VK_HANGUL , "Hangul" , NULL ), - K( VK_JUNJA , "Junja" , NULL ), - K( VK_FINAL , "Final" , NULL ), - K( VK_HANJA , "Hanja" , NULL ), - K( VK_KANJI , "Kanji" , NULL ), +/* K( VK_CAPITAL , "Capital" , nullptr ), + K( VK_KANA , "Kana" , nullptr ), + K( VK_HANGEUL , "Hangeul" , nullptr ), + K( VK_HANGUL , "Hangul" , nullptr ), + K( VK_JUNJA , "Junja" , nullptr ), + K( VK_FINAL , "Final" , nullptr ), + K( VK_HANJA , "Hanja" , nullptr ), + K( VK_KANJI , "Kanji" , nullptr ), K( VK_ESCAPE , "Escape" , "Esc" ), - K( VK_ESCAPE , "Esc" ,NULL ), - K( VK_CONVERT , "Convert" , NULL ), - K( VK_NONCONVERT , "Noconvert" , NULL ), - K( VK_ACCEPT , "Accept" , NULL ), - K( VK_MODECHANGE , "Modechange" , NULL ),*/ + K( VK_ESCAPE , "Esc" ,nullptr ), + K( VK_CONVERT , "Convert" , nullptr ), + K( VK_NONCONVERT , "Noconvert" , nullptr ), + K( VK_ACCEPT , "Accept" , nullptr ), + K( VK_MODECHANGE , "Modechange" , nullptr ),*/ { K_SPACE , "Space" , "Sp" }, - { K_END , "End" , NULL }, - { K_HOME , "Home" , NULL }, - { K_LEFT , "Left" , NULL }, - { K_UP , "Up" , NULL }, - { K_RIGHT , "Right" , NULL }, - { K_DOWN , "Down" , NULL }, - /*{ VK_SELECT , "Select" , NULL }, - { VK_PRINT , "Print" , NULL }, - { VK_EXECUTE , "Execute" , NULL }, - { VK_SNAPSHOT , "Snapshot" , NULL }, + { K_END , "End" , nullptr }, + { K_HOME , "Home" , nullptr }, + { K_LEFT , "Left" , nullptr }, + { K_UP , "Up" , nullptr }, + { K_RIGHT , "Right" , nullptr }, + { K_DOWN , "Down" , nullptr }, + /*{ VK_SELECT , "Select" , nullptr }, + { VK_PRINT , "Print" , nullptr }, + { VK_EXECUTE , "Execute" , nullptr }, + { VK_SNAPSHOT , "Snapshot" , nullptr }, { VK_INSERT , "Insert" , "Ins" },*/ { K_DELETE , "Delete" , "Del" }, -// { VK_HELP , "Help" , NULL }, +// { VK_HELP , "Help" , nullptr }, - K( 29 , "0" , NULL ), - K( 18 , "1" , NULL ), - K( 19 , "2" , NULL ), - K( 20 , "3" , NULL ), - K( 21 , "4" , NULL ), - K( 23 , "5" , NULL ), - K( 22 , "6" , NULL ), - K( 26 , "7" , NULL ), - K( 28 , "8" , NULL ), - K( 25 , "9" , NULL ), + K( 29 , "0" , nullptr ), + K( 18 , "1" , nullptr ), + K( 19 , "2" , nullptr ), + K( 20 , "3" , nullptr ), + K( 21 , "4" , nullptr ), + K( 23 , "5" , nullptr ), + K( 22 , "6" , nullptr ), + K( 26 , "7" , nullptr ), + K( 28 , "8" , nullptr ), + K( 25 , "9" , nullptr ), - K( 0 , "A" , NULL ), - K( 11 , "B" , NULL ), - K( 8 , "C" , NULL ), - K( 2 , "D" , NULL ), - K( 14 , "E" , NULL ), - K( 3 , "F" , NULL ), - K( 5 , "G" , NULL ), - K( 4 , "H" , NULL ), - K( 34 , "I" , NULL ), - K( 38 , "J" , NULL ), - K( 40 , "K" , NULL ), - K( 37 , "L" , NULL ), - K( 46 , "M" , NULL ), - K( 45 , "N" , NULL ), - K( 31 , "O" , NULL ), - K( 35 , "P" , NULL ), - K( 12 , "Q" , NULL ), - K( 15 , "R" , NULL ), - K( 1 , "S" , NULL ), - K( 17 , "T" , NULL ), - K( 32 , "U" , NULL ), - K( 9 , "V" , NULL ), - K( 13 , "W" , NULL ), - K( 7 , "X" , NULL ), - K( 6 , "Y" , NULL ), - K( 16 , "Z" , NULL ), - K( 43 , "Comma" , NULL ), - K( 47 , "Period" , NULL ), - K( 43 , "Apostrophe", NULL ), - K( 44 , "Backslash" , NULL ), - K( 43 , "Comma_US" , NULL ), - K( 49 , "Less" , NULL ), + K( 0 , "A" , nullptr ), + K( 11 , "B" , nullptr ), + K( 8 , "C" , nullptr ), + K( 2 , "D" , nullptr ), + K( 14 , "E" , nullptr ), + K( 3 , "F" , nullptr ), + K( 5 , "G" , nullptr ), + K( 4 , "H" , nullptr ), + K( 34 , "I" , nullptr ), + K( 38 , "J" , nullptr ), + K( 40 , "K" , nullptr ), + K( 37 , "L" , nullptr ), + K( 46 , "M" , nullptr ), + K( 45 , "N" , nullptr ), + K( 31 , "O" , nullptr ), + K( 35 , "P" , nullptr ), + K( 12 , "Q" , nullptr ), + K( 15 , "R" , nullptr ), + K( 1 , "S" , nullptr ), + K( 17 , "T" , nullptr ), + K( 32 , "U" , nullptr ), + K( 9 , "V" , nullptr ), + K( 13 , "W" , nullptr ), + K( 7 , "X" , nullptr ), + K( 6 , "Y" , nullptr ), + K( 16 , "Z" , nullptr ), + K( 43 , "Comma" , nullptr ), + K( 47 , "Period" , nullptr ), + K( 43 , "Apostrophe", nullptr ), + K( 44 , "Backslash" , nullptr ), + K( 43 , "Comma_US" , nullptr ), + K( 49 , "Less" , nullptr ), - /*K( VK_LWIN , "WinLeft" , NULL ), - K( VK_RWIN , "WinRight" , NULL ),*/ - //K( VK_APPS , "Apps" , NULL ), + /*K( VK_LWIN , "WinLeft" , nullptr ), + K( VK_RWIN , "WinRight" , nullptr ),*/ + //K( VK_APPS , "Apps" , nullptr ), K( 82 , "Num0" , "N0" ), K( 83 , "Num1" , "N1" ), @@ -124,66 +124,66 @@ const C4KeyCodeMapEntry KeyCodeMap [] = K( 78 , "Subtract" , "N-" ), K( 65 , "Decimal" , "N," ), K( 75 , "Divide" , "N/" ), - { K_F1 , "F1" , NULL }, - { K_F2 , "F2" , NULL }, - { K_F3 , "F3" , NULL }, - { K_F4 , "F4" , NULL }, - { K_F5 , "F5" , NULL }, - { K_F6 , "F6" , NULL }, - { K_F7 , "F7" , NULL }, - { K_F8 , "F8" , NULL }, - { K_F9 , "F9" , NULL }, - { K_F10 , "F10" , NULL }, - { K_F11 , "F11" , NULL }, - { K_F12 , "F12" , NULL }, + { K_F1 , "F1" , nullptr }, + { K_F2 , "F2" , nullptr }, + { K_F3 , "F3" , nullptr }, + { K_F4 , "F4" , nullptr }, + { K_F5 , "F5" , nullptr }, + { K_F6 , "F6" , nullptr }, + { K_F7 , "F7" , nullptr }, + { K_F8 , "F8" , nullptr }, + { K_F9 , "F9" , nullptr }, + { K_F10 , "F10" , nullptr }, + { K_F11 , "F11" , nullptr }, + { K_F12 , "F12" , nullptr }, /* - { K_F13 , "F13" , NULL }, - { K_F14 , "F14" , NULL }, - { K_F15 , "F15" , NULL }, - { K_F16 , "F16" , NULL }, - { K_F17 , "F17" , NULL }, - { K_F18 , "F18" , NULL }, - { K_F19 , "F19" , NULL }, - { K_F20 , "F20" , NULL }, - { K_F21 , "F21" , NULL }, - { K_F22 , "F22" , NULL }, - { K_F23 , "F23" , NULL }, - { K_F24 , "F24" , NULL },*/ + { K_F13 , "F13" , nullptr }, + { K_F14 , "F14" , nullptr }, + { K_F15 , "F15" , nullptr }, + { K_F16 , "F16" , nullptr }, + { K_F17 , "F17" , nullptr }, + { K_F18 , "F18" , nullptr }, + { K_F19 , "F19" , nullptr }, + { K_F20 , "F20" , nullptr }, + { K_F21 , "F21" , nullptr }, + { K_F22 , "F22" , nullptr }, + { K_F23 , "F23" , nullptr }, + { K_F24 , "F24" , nullptr },*/ K( 71 , "NumLock" , "NLock" ), - //K( K_SCROLL , "Scroll" , NULL ), + //K( K_SCROLL , "Scroll" , nullptr ), - //K( VK_PROCESSKEY , "PROCESSKEY" , NULL ), + //K( VK_PROCESSKEY , "PROCESSKEY" , nullptr ), /*#if defined VK_SLEEP && defined VK_OEM_NEC_EQUAL - K( VK_SLEEP , "Sleep" , NULL ), + K( VK_SLEEP , "Sleep" , nullptr ), - K( VK_OEM_NEC_EQUAL , "OEM_NEC_EQUAL" , NULL ), + K( VK_OEM_NEC_EQUAL , "OEM_NEC_EQUAL" , nullptr ), - K( VK_OEM_FJ_JISHO , "OEM_FJ_JISHO" , NULL ), - K( VK_OEM_FJ_MASSHOU , "OEM_FJ_MASSHOU" , NULL ), - K( VK_OEM_FJ_TOUROKU , "OEM_FJ_TOUROKU" , NULL ), - K( VK_OEM_FJ_LOYA , "OEM_FJ_LOYA" , NULL ), - K( VK_OEM_FJ_ROYA , "OEM_FJ_ROYA" , NULL ), + K( VK_OEM_FJ_JISHO , "OEM_FJ_JISHO" , nullptr ), + K( VK_OEM_FJ_MASSHOU , "OEM_FJ_MASSHOU" , nullptr ), + K( VK_OEM_FJ_TOUROKU , "OEM_FJ_TOUROKU" , nullptr ), + K( VK_OEM_FJ_LOYA , "OEM_FJ_LOYA" , nullptr ), + K( VK_OEM_FJ_ROYA , "OEM_FJ_ROYA" , nullptr ), - K( VK_BROWSER_BACK , "BROWSER_BACK" , NULL ), - K( VK_BROWSER_FORWARD , "BROWSER_FORWARD" , NULL ), - K( VK_BROWSER_REFRESH , "BROWSER_REFRESH" , NULL ), - K( VK_BROWSER_STOP , "BROWSER_STOP" , NULL ), - K( VK_BROWSER_SEARCH , "BROWSER_SEARCH" , NULL ), - K( VK_BROWSER_FAVORITES , "BROWSER_FAVORITES" , NULL ), - K( VK_BROWSER_HOME , "BROWSER_HOME" , NULL ), + K( VK_BROWSER_BACK , "BROWSER_BACK" , nullptr ), + K( VK_BROWSER_FORWARD , "BROWSER_FORWARD" , nullptr ), + K( VK_BROWSER_REFRESH , "BROWSER_REFRESH" , nullptr ), + K( VK_BROWSER_STOP , "BROWSER_STOP" , nullptr ), + K( VK_BROWSER_SEARCH , "BROWSER_SEARCH" , nullptr ), + K( VK_BROWSER_FAVORITES , "BROWSER_FAVORITES" , nullptr ), + K( VK_BROWSER_HOME , "BROWSER_HOME" , nullptr ), - K( VK_VOLUME_MUTE , "VOLUME_MUTE" , NULL ), - K( VK_VOLUME_DOWN , "VOLUME_DOWN" , NULL ), - K( VK_VOLUME_UP , "VOLUME_UP" , NULL ), - K( VK_MEDIA_NEXT_TRACK , "MEDIA_NEXT_TRACK" , NULL ), - K( VK_MEDIA_PREV_TRACK , "MEDIA_PREV_TRACK" , NULL ), - K( VK_MEDIA_STOP , "MEDIA_STOP" , NULL ), - K( VK_MEDIA_PLAY_PAUSE , "MEDIA_PLAY_PAUSE" , NULL ), - K( VK_LAUNCH_MAIL , "LAUNCH_MAIL" , NULL ), - K( VK_LAUNCH_MEDIA_SELECT , "LAUNCH_MEDIA_SELECT" , NULL ), - K( VK_LAUNCH_APP1 , "LAUNCH_APP1" , NULL ), - K( VK_LAUNCH_APP2 , "LAUNCH_APP2" , NULL ), + K( VK_VOLUME_MUTE , "VOLUME_MUTE" , nullptr ), + K( VK_VOLUME_DOWN , "VOLUME_DOWN" , nullptr ), + K( VK_VOLUME_UP , "VOLUME_UP" , nullptr ), + K( VK_MEDIA_NEXT_TRACK , "MEDIA_NEXT_TRACK" , nullptr ), + K( VK_MEDIA_PREV_TRACK , "MEDIA_PREV_TRACK" , nullptr ), + K( VK_MEDIA_STOP , "MEDIA_STOP" , nullptr ), + K( VK_MEDIA_PLAY_PAUSE , "MEDIA_PLAY_PAUSE" , nullptr ), + K( VK_LAUNCH_MAIL , "LAUNCH_MAIL" , nullptr ), + K( VK_LAUNCH_MEDIA_SELECT , "LAUNCH_MEDIA_SELECT" , nullptr ), + K( VK_LAUNCH_APP1 , "LAUNCH_APP1" , nullptr ), + K( VK_LAUNCH_APP2 , "LAUNCH_APP2" , nullptr ), K( VK_OEM_1 , "OEM Ãœ" , "Ãœ" ), // German hax K( VK_OEM_PLUS , "OEM +" , "+" ), @@ -202,37 +202,37 @@ const C4KeyCodeMapEntry KeyCodeMap [] = K( VK_ICO_HELP , "Help" , "Help" ), K( VK_ICO_00 , "ICO_00" , "00" ), - K( VK_ICO_CLEAR , "ICO_CLEAR" , NULL ), + K( VK_ICO_CLEAR , "ICO_CLEAR" , nullptr ), - K( VK_PACKET , "PACKET" , NULL ), + K( VK_PACKET , "PACKET" , nullptr ), - K( VK_OEM_RESET , "OEM_RESET" , NULL ), - K( VK_OEM_JUMP , "OEM_JUMP" , NULL ), - K( VK_OEM_PA1 , "OEM_PA1" , NULL ), - K( VK_OEM_PA2 , "OEM_PA2" , NULL ), - K( VK_OEM_PA3 , "OEM_PA3" , NULL ), - K( VK_OEM_WSCTRL , "OEM_WSCTRL" , NULL ), - K( VK_OEM_CUSEL , "OEM_CUSEL" , NULL ), - K( VK_OEM_ATTN , "OEM_ATTN" , NULL ), - K( VK_OEM_FINISH , "OEM_FINISH" , NULL ), - K( VK_OEM_COPY , "OEM_COPY" , NULL ), - K( VK_OEM_AUTO , "OEM_AUTO" , NULL ), - K( VK_OEM_ENLW , "OEM_ENLW" , NULL ), - K( VK_OEM_BACKTAB , "OEM_BACKTAB" , NULL ), + K( VK_OEM_RESET , "OEM_RESET" , nullptr ), + K( VK_OEM_JUMP , "OEM_JUMP" , nullptr ), + K( VK_OEM_PA1 , "OEM_PA1" , nullptr ), + K( VK_OEM_PA2 , "OEM_PA2" , nullptr ), + K( VK_OEM_PA3 , "OEM_PA3" , nullptr ), + K( VK_OEM_WSCTRL , "OEM_WSCTRL" , nullptr ), + K( VK_OEM_CUSEL , "OEM_CUSEL" , nullptr ), + K( VK_OEM_ATTN , "OEM_ATTN" , nullptr ), + K( VK_OEM_FINISH , "OEM_FINISH" , nullptr ), + K( VK_OEM_COPY , "OEM_COPY" , nullptr ), + K( VK_OEM_AUTO , "OEM_AUTO" , nullptr ), + K( VK_OEM_ENLW , "OEM_ENLW" , nullptr ), + K( VK_OEM_BACKTAB , "OEM_BACKTAB" , nullptr ), #endif - K( VK_ATTN , "ATTN" , NULL ), - K( VK_CRSEL , "CRSEL" , NULL ), - K( VK_EXSEL , "EXSEL" , NULL ), - K( VK_EREOF , "EREOF" , NULL ), - K( VK_PLAY , "PLAY" , NULL ), - K( VK_ZOOM , "ZOOM" , NULL ), - K( VK_NONAME , "NONAME" , NULL ), - K( VK_PA1 , "PA1" , NULL ), - K( VK_OEM_CLEAR , "OEM_CLEAR" , NULL ),*/ + K( VK_ATTN , "ATTN" , nullptr ), + K( VK_CRSEL , "CRSEL" , nullptr ), + K( VK_EXSEL , "EXSEL" , nullptr ), + K( VK_EREOF , "EREOF" , nullptr ), + K( VK_PLAY , "PLAY" , nullptr ), + K( VK_ZOOM , "ZOOM" , nullptr ), + K( VK_NONAME , "NONAME" , nullptr ), + K( VK_PA1 , "PA1" , nullptr ), + K( VK_OEM_CLEAR , "OEM_CLEAR" , nullptr ),*/ - { KEY_Any, "Any" , NULL}, - { KEY_Default, "None", NULL}, - { KEY_Undefined, NULL, NULL} + { KEY_Any, "Any" , nullptr}, + { KEY_Default, "None", nullptr}, + { KEY_Undefined, nullptr, nullptr} }; #undef K diff --git a/src/platform/ObjectiveCAssociated.h b/src/platform/ObjectiveCAssociated.h index ebd7ae7e6..52e5010a5 100644 --- a/src/platform/ObjectiveCAssociated.h +++ b/src/platform/ObjectiveCAssociated.h @@ -29,7 +29,7 @@ class ObjectiveCAssociated { public: ObjCPtr _objectiveCObject; public: - ObjectiveCAssociated(): _objectiveCObject(NULL) {} + ObjectiveCAssociated(): _objectiveCObject(nullptr) {} #ifdef __OBJC__ void setObjectiveCObject(id obj) { _objectiveCObject = obj; } template inline T* objectiveCObject() { return (T*)_objectiveCObject; } diff --git a/src/platform/PlatformAbstraction.cpp b/src/platform/PlatformAbstraction.cpp index 4c2b4792b..0bd1fbfcb 100644 --- a/src/platform/PlatformAbstraction.cpp +++ b/src/platform/PlatformAbstraction.cpp @@ -22,7 +22,7 @@ #include bool OpenURL(const char *szURL) { - return (intptr_t)ShellExecuteW(NULL, L"open", GetWideChar(szURL), NULL, NULL, SW_SHOW) > 32; + return (intptr_t)ShellExecuteW(nullptr, L"open", GetWideChar(szURL), nullptr, nullptr, SW_SHOW) > 32; } bool EraseItemSafe(const char *szFilename) @@ -35,11 +35,11 @@ bool EraseItemSafe(const char *szFilename) shs.hwnd=0; shs.wFunc=FO_DELETE; shs.pFrom = wide_filename; - shs.pTo=NULL; + shs.pTo=nullptr; shs.fFlags=FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_SILENT; shs.fAnyOperationsAborted=false; shs.hNameMappings=0; - shs.lpszProgressTitle=NULL; + shs.lpszProgressTitle=nullptr; auto error = SHFileOperationW(&shs); return !error; } @@ -85,7 +85,7 @@ bool RestartApplication(std::vector parameters) bool success = false; #ifdef _WIN32 wchar_t buf[_MAX_PATH]; - DWORD sz = ::GetModuleFileName(::GetModuleHandle(NULL), buf, _MAX_PATH); + DWORD sz = ::GetModuleFileName(::GetModuleHandle(nullptr), buf, _MAX_PATH); if (sz) { StdStrBuf params; @@ -95,7 +95,7 @@ bool RestartApplication(std::vector parameters) params += p; params += "\" "; } - intptr_t iError = (intptr_t)::ShellExecute(NULL, NULL, buf, params.GetWideChar(), Config.General.ExePath.GetWideChar(), SW_SHOW); + intptr_t iError = (intptr_t)::ShellExecute(nullptr, nullptr, buf, params.GetWideChar(), Config.General.ExePath.GetWideChar(), SW_SHOW); if (iError > 32) success = true; } #else @@ -107,7 +107,7 @@ bool RestartApplication(std::vector parameters) { std::vector params = {"openclonk"}; params.insert(params.end(), parameters.begin(), parameters.end()); - params.push_back(NULL); + params.push_back(nullptr); execv("/proc/self/exe", const_cast(params.data())); perror("editor launch failed"); exit(1); diff --git a/src/platform/PlatformAbstraction.h b/src/platform/PlatformAbstraction.h index 4b2a4ffe0..c55fb5fda 100644 --- a/src/platform/PlatformAbstraction.h +++ b/src/platform/PlatformAbstraction.h @@ -74,13 +74,6 @@ #endif - -// C++0x nullptr -#undef NULL -#define NULL nullptr - - - // Integer dataypes #include diff --git a/src/platform/StdFile.cpp b/src/platform/StdFile.cpp index 4f328a9bb..97f428cd5 100644 --- a/src/platform/StdFile.cpp +++ b/src/platform/StdFile.cpp @@ -54,14 +54,14 @@ static const char *DirectorySeparators = "/"; char *GetFilename(char *szPath) { - if (!szPath) return NULL; + if (!szPath) return nullptr; char *pPos,*pFilename=szPath; for (pPos=szPath; *pPos; pPos++) if (*pPos==DirectorySeparator || *pPos=='/') pFilename = pPos+1; return pFilename; } const char *GetFilename(const char *szPath) { - if (!szPath) return NULL; + if (!szPath) return nullptr; const char *pPos,*pFilename=szPath; for (pPos=szPath; *pPos; pPos++) if (*pPos==DirectorySeparator || *pPos=='/') pFilename = pPos+1; return pFilename; @@ -81,7 +81,7 @@ const char* GetFilenameOnly(const char *strFilename) const char *GetC4Filename(const char *szPath) { // returns path to file starting at first .c4*-directory. - if (!szPath) return NULL; + if (!szPath) return nullptr; const char *pPos,*pFilename=szPath; for (pPos=szPath; *pPos; pPos++) { @@ -113,14 +113,14 @@ int GetTrailingNumber(const char *strString) char *GetFilenameWeb(char *szPath) { - if (!szPath) return NULL; + if (!szPath) return nullptr; char *pPos, *pFilename=szPath; for (pPos=szPath; *pPos; pPos++) if (*pPos == '/') pFilename = pPos+1; return pFilename; } const char *GetFilenameWeb(const char *szPath) { - if (!szPath) return NULL; + if (!szPath) return nullptr; const char *pPos, *pFilename=szPath; for (pPos=szPath; *pPos; pPos++) if (*pPos == '/') pFilename = pPos+1; return pFilename; @@ -158,7 +158,7 @@ void RealPath(const char *szFilename, char *pFullFilename) SCopy(path.getData(), pFullFilename, _MAX_PATH); free(wpath); #else - char *pSuffix = NULL; + char *pSuffix = nullptr; char szCopy[_MAX_PATH + 1]; for (;;) { @@ -397,7 +397,7 @@ bool WildcardMatch(const char *szWildcard, const char *szString) if (!szString || !szWildcard) return false; // match char-wise const char *pWild = szWildcard, *pPos = szString; - const char *pLWild = NULL, *pLPos = NULL; // backtracking + const char *pLWild = nullptr, *pLPos = nullptr; // backtracking while (*pWild || pLWild) // string wildcard? if (*pWild == '*') @@ -653,7 +653,7 @@ bool CreatePath(const std::string &path) { assert(!path.empty()); #ifdef _WIN32 - if (CreateDirectoryW(GetWideChar(path.c_str()), NULL)) + if (CreateDirectoryW(GetWideChar(path.c_str()), nullptr)) { return true; } @@ -671,7 +671,7 @@ bool CreatePath(const std::string &path) { wchar_t * str; if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, err, 0, (LPWSTR)&str, 0, NULL)) + nullptr, err, 0, (LPWSTR)&str, 0, nullptr)) { LogF("CreateDirectory failed: %s", StdStrBuf(str).getData()); LocalFree(str); @@ -998,7 +998,7 @@ void DirectoryIterator::Read(const char *dirname) FindClose(fh); #else DIR *fh = opendir(dirname); - if (fh == NULL) + if (fh == nullptr) { switch (errno) { @@ -1014,7 +1014,7 @@ void DirectoryIterator::Read(const char *dirname) } dirent *file; // Insert files into list - while ((file = readdir(fh)) != NULL) + while ((file = readdir(fh)) != nullptr) { // ...unless they're . or .. if (file->d_name[0] == '.' && (file->d_name[1] == '\0' || (file->d_name[1] == '.' && file->d_name[2] == '\0'))) @@ -1041,7 +1041,7 @@ DirectoryIterator& DirectoryIterator::operator++() const char * DirectoryIterator::operator*() const { if (iter == p->files.end()) - return NULL; + return nullptr; return iter->first.c_str(); } DirectoryIterator DirectoryIterator::operator++(int) diff --git a/src/platform/StdRegistry.cpp b/src/platform/StdRegistry.cpp index 5701a6442..83a6faadf 100644 --- a/src/platform/StdRegistry.cpp +++ b/src/platform/StdRegistry.cpp @@ -38,7 +38,7 @@ StdCopyStrBuf GetRegistryString(const char *szSubKey, const char *szValueName) while(true) { DWORD valtype; - switch(RegQueryValueExW(ckey, GetWideChar(szValueName), NULL, &valtype, + switch(RegQueryValueExW(ckey, GetWideChar(szValueName), nullptr, &valtype, sValue, &dwValSize)) { case ERROR_SUCCESS: @@ -75,10 +75,10 @@ bool SetRegistryString(const char *szSubKey, if ((qerr=RegCreateKeyExW(HKEY_CURRENT_USER, GetWideChar(szSubKey), 0, - NULL, + nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, - NULL, + nullptr, &ckey, &disposition ))!=ERROR_SUCCESS) return false; @@ -131,10 +131,10 @@ static bool SetRegClassesRoot(const wchar_t *szSubKey, if ((qerr=RegCreateKeyExW(HKEY_CLASSES_ROOT, szSubKey, 0, - NULL, + nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, - NULL, + nullptr, &ckey, &disposition ))!=ERROR_SUCCESS) return false; @@ -163,15 +163,15 @@ bool SetRegShell(const wchar_t *szClassName, wchar_t szKeyName[256+1]; // Set shell caption _snwprintf(szKeyName,256,L"%s\\Shell\\%s",szClassName,szShellName); - if (!SetRegClassesRoot(szKeyName, NULL, szShellCaption)) return false; + if (!SetRegClassesRoot(szKeyName, nullptr, szShellCaption)) return false; // Set shell command _snwprintf(szKeyName,256,L"%s\\Shell\\%s\\Command",szClassName,szShellName); - if (!SetRegClassesRoot(szKeyName, NULL, szCommand)) return false; + if (!SetRegClassesRoot(szKeyName, nullptr, szCommand)) return false; // Set as default command if (fMakeDefault) { _snwprintf(szKeyName, 256,L"%s\\Shell", szClassName); - if (!SetRegClassesRoot(szKeyName, NULL, szShellName)) return false; + if (!SetRegClassesRoot(szKeyName, nullptr, szShellName)) return false; } return true; } @@ -391,9 +391,9 @@ void StdCompilerConfigWrite::CreateKey(HKEY hParent) // Open/Create registry key if (RegCreateKeyExW(hParent ? hParent : pKey->Parent->Handle, pKey->Name.GetWideChar(), - 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_WRITE, NULL, - &pKey->Handle, NULL) != ERROR_SUCCESS) + 0, nullptr, REG_OPTION_NON_VOLATILE, + KEY_WRITE, nullptr, + &pKey->Handle, nullptr) != ERROR_SUCCESS) excCorrupt("Could not create key %s!", pKey->Name.getData()); } @@ -459,7 +459,7 @@ bool StdCompilerConfigRead::Name(const char *szName) hSubKey = 0; // Try to query value (exists?) if (RegQueryValueExW(pKey->Handle, sName.GetWideChar(), - 0, &dwType, NULL, NULL) != ERROR_SUCCESS) + 0, &dwType, nullptr, nullptr) != ERROR_SUCCESS) fFound = false; } // Push new subkey on the stack @@ -638,7 +638,7 @@ uint32_t StdCompilerConfigRead::ReadDWord() // Read uint32_t iVal; DWORD iSize = sizeof(iVal); if (RegQueryValueExW(pKey->Parent->Handle, pKey->Name.GetWideChar(), - 0, NULL, + 0, nullptr, reinterpret_cast(&iVal), &iSize) != ERROR_SUCCESS) { excNotFound("Could not read value %s!", pKey->Name.getData()); return 0; } @@ -660,15 +660,15 @@ StdStrBuf StdCompilerConfigRead::ReadString() // Get size of string DWORD iSize; if (RegQueryValueExW(pKey->Parent->Handle, pKey->Name.GetWideChar(), - 0, NULL, - NULL, + 0, nullptr, + nullptr, &iSize) != ERROR_SUCCESS) { excNotFound("Could not read value %s!", pKey->Name.getData()); return StdStrBuf(); } // Allocate string StdBuf Result; Result.SetSize(iSize); // Read if (RegQueryValueExW(pKey->Parent->Handle, pKey->Name.GetWideChar(), - 0, NULL, + 0, nullptr, reinterpret_cast(Result.getMData()), &iSize) != ERROR_SUCCESS) { excNotFound("Could not read value %s!", pKey->Name.getData()); return StdStrBuf(); } diff --git a/src/platform/StdScheduler.cpp b/src/platform/StdScheduler.cpp index eb32ed26a..acbfeb837 100644 --- a/src/platform/StdScheduler.cpp +++ b/src/platform/StdScheduler.cpp @@ -112,7 +112,7 @@ void StdScheduler::Remove(StdSchedulerProc *pProc) if (pProc->scheduler != this) return; Removing(pProc); - pProc->scheduler = NULL; + pProc->scheduler = nullptr; auto pos = std::find(procs.begin(), procs.end(), pProc); if (pos != procs.end()) procs.erase(pos); @@ -229,7 +229,7 @@ bool StdSchedulerThread::Start() iThread = _beginthread(_ThreadFunc, 0, this); fThread = (iThread != -1); #elif defined(HAVE_PTHREAD) - fThread = !pthread_create(&Thread, NULL, _ThreadFunc, this); + fThread = !pthread_create(&Thread, nullptr, _ThreadFunc, this); #endif // success? return fThread; @@ -252,7 +252,7 @@ void StdSchedulerThread::Stop() #elif defined(HAVE_PTHREAD) // wait for thread to terminate itself // (without security - let's trust these unwashed hackers for once) - pthread_join(Thread, NULL); + pthread_join(Thread, nullptr); #endif fThread = false; // ok @@ -309,7 +309,7 @@ bool StdThread::Start() iThread = _beginthread(_ThreadFunc, 0, this); fStarted = (iThread != -1); #elif defined(HAVE_PTHREAD) - fStarted = !pthread_create(&Thread, NULL, _ThreadFunc, this); + fStarted = !pthread_create(&Thread, nullptr, _ThreadFunc, this); #endif // success? return fStarted; @@ -338,7 +338,7 @@ void StdThread::Stop() #elif defined(HAVE_PTHREAD) // wait for thread to terminate itself // (whithout security - let's trust these unwashed hackers for once) - pthread_join(Thread, NULL); + pthread_join(Thread, nullptr); #endif fStarted = false; // ok diff --git a/src/platform/StdScheduler.h b/src/platform/StdScheduler.h index 1d486ec67..7024ff0ec 100644 --- a/src/platform/StdScheduler.h +++ b/src/platform/StdScheduler.h @@ -59,7 +59,7 @@ protected: void Changed(); public: - StdSchedulerProc(): scheduler(NULL) {} + StdSchedulerProc(): scheduler(nullptr) {} virtual ~StdSchedulerProc() { } // Do whatever the process wishes to do. Should not block longer than the timeout value. diff --git a/src/platform/StdSchedulerWin32.cpp b/src/platform/StdSchedulerWin32.cpp index aac739bbd..088801739 100644 --- a/src/platform/StdSchedulerWin32.cpp +++ b/src/platform/StdSchedulerWin32.cpp @@ -41,7 +41,7 @@ bool StdScheduler::DoScheduleProcs(int iTimeout) size_t i; // Collect event handles int iEventCnt = 0; HANDLE hEvent; - StdSchedulerProc *pMessageProc = NULL; + StdSchedulerProc *pMessageProc = nullptr; for (i = 0u; i < procs.size(); i++) { auto proc = procs[i]; diff --git a/src/platform/StdSync.h b/src/platform/StdSync.h index 1c1511cf6..1cf778726 100644 --- a/src/platform/StdSync.h +++ b/src/platform/StdSync.h @@ -38,7 +38,7 @@ public: class CStdEvent { public: - CStdEvent(bool fManualReset) { hEvent = CreateEvent(NULL, fManualReset, false, NULL); } + CStdEvent(bool fManualReset) { hEvent = CreateEvent(nullptr, fManualReset, false, nullptr); } ~CStdEvent() { CloseHandle(hEvent); } protected: @@ -95,8 +95,8 @@ class CStdEvent public: CStdEvent(bool fManualReset) : fManualReset(fManualReset), fSet(false) { - pthread_cond_init(&cond, NULL); - pthread_mutex_init(&mutex, NULL); + pthread_cond_init(&cond, nullptr); + pthread_mutex_init(&mutex, nullptr); } ~CStdEvent() { @@ -186,7 +186,7 @@ protected: public: void Clear() - { if (sec) sec->Leave(); sec = NULL; } + { if (sec) sec->Leave(); sec = nullptr; } }; class CStdCSecExCallback @@ -201,7 +201,7 @@ class CStdCSecEx : public CStdCSec { public: CStdCSecEx() - : lShareCnt(0), ShareFreeEvent(false), pCallbClass(NULL) + : lShareCnt(0), ShareFreeEvent(false), pCallbClass(nullptr) { } CStdCSecEx(CStdCSecExCallback *pCallb) : lShareCnt(0), ShareFreeEvent(false), pCallbClass(pCallb) @@ -287,7 +287,7 @@ protected: public: void Clear() - { if (sec) sec->LeaveShared(); sec = NULL; } + { if (sec) sec->LeaveShared(); sec = nullptr; } }; /* Debug helper class: Set current thread in Set(); assert that it's still the same thread in Check(); */ diff --git a/src/player/C4Player.cpp b/src/player/C4Player.cpp index 9c37fb1bc..b22e167e8 100644 --- a/src/player/C4Player.cpp +++ b/src/player/C4Player.cpp @@ -58,15 +58,15 @@ C4Player::C4Player() : C4PlayerInfoCore() CrewInfoList.Default(); LocalControl = false; BigIcon.Default(); - Next = NULL; + Next = nullptr; fFogOfWar = true; LeagueEvaluated = false; GameJoinTime = 0; // overwritten in Init - pstatControls = pstatActions = NULL; + pstatControls = pstatActions = nullptr; ControlCount = ActionCount = 0; LastControlType = PCID_None; LastControlID = 0; - pMsgBoardQuery = NULL; + pMsgBoardQuery = nullptr; NoEliminationCheck = false; Evaluated = false; ZoomLimitMinWdt = ZoomLimitMinHgt = ZoomLimitMaxWdt = ZoomLimitMaxHgt = ZoomWdt = ZoomHgt = 0; @@ -79,7 +79,7 @@ C4Player::~C4Player() { ClearGraphs(); Menu.Clear(); - SetSoundModifier(NULL); + SetSoundModifier(nullptr); while (pMsgBoardQuery) { C4MessageBoardQuery *pNext = pMsgBoardQuery->pNext; @@ -102,14 +102,14 @@ void C4Player::ClearPointers(C4Object *pObj, bool fDeath) // Crew while (Crew.Remove(pObj)) {} // View-Cursor - if (ViewCursor==pObj) ViewCursor = NULL; + if (ViewCursor==pObj) ViewCursor = nullptr; // View - if (ViewTarget==pObj) ViewTarget=NULL; + if (ViewTarget==pObj) ViewTarget=nullptr; // Cursor if (Cursor == pObj) { // object is to be deleted; do NOT do script calls (like in Cursor->UnSelect(true)) - Cursor = NULL; AdjustCursorCommand(); // also selects and eventually does a script call! + Cursor = nullptr; AdjustCursorCommand(); // also selects and eventually does a script call! } // Menu Menu.ClearPointers(pObj); @@ -126,7 +126,7 @@ bool C4Player::ScenarioAndTeamInit(int32_t idTeam) { // creation of a new team only if allowed by scenario if (!Game.Teams.IsAutoGenerateTeams()) - pTeam = NULL; + pTeam = nullptr; else { if ((pTeam = Game.Teams.GetGenerateTeamByID(idTeam))) idTeam = pTeam->GetID(); @@ -143,7 +143,7 @@ bool C4Player::ScenarioAndTeamInit(int32_t idTeam) { if (!Game.Teams.IsJoin2TeamAllowed(idTeam)) { - pTeam = NULL; + pTeam = nullptr; } } if (!pTeam && idTeam) @@ -303,7 +303,7 @@ bool C4Player::Init(int32_t iNumber, int32_t iAtClient, const char *szAtClientNa ::Players.RecheckPlayerSort(this); // check for a postponed scenario init, if no team is specified (post-lobby-join in network, or simply non-network) - C4Team *pTeam = NULL; + C4Team *pTeam = nullptr; if (Team) { if (Game.Teams.IsAutoGenerateTeams()) @@ -450,7 +450,7 @@ bool C4Player::Save() if (!hGroup.Close()) return false; // resource C4Network2Res::Ref pRes = ::Network.ResList.getRefRes(Filename), - pDRes = NULL; + pDRes = nullptr; bool fOfficial = pRes && ::Control.isCtrlHost(); if (pRes) pDRes = pRes->Derive(); // move back @@ -541,7 +541,7 @@ void C4Player::PlaceReadyBase(int32_t &tx, int32_t &ty, C4Object **pFirstBase) ctx=tx; cty=ty; if (Game.C4S.PlrStart[PlrStartIndex].EnforcePosition || FindConSiteSpot(ctx,cty,def->Shape.Wdt,def->Shape.Hgt,20)) - if ((cbase=Game.CreateObjectConstruction(C4Id2Def(cid),NULL,Number,ctx,cty,FullCon,true))) + if ((cbase=Game.CreateObjectConstruction(C4Id2Def(cid),nullptr,Number,ctx,cty,FullCon,true))) { // FirstBase if (!(*pFirstBase)) if ((cbase->Def->Entrance.Wdt>0) && (cbase->Def->Entrance.Hgt>0)) @@ -563,7 +563,7 @@ void C4Player::PlaceReadyVehic(int32_t tx1, int32_t tx2, int32_t ty, C4Object *F ctx=tx1+Random(tx2-tx1); cty=ty; if (!Game.C4S.PlrStart[PlrStartIndex].EnforcePosition) FindLevelGround(ctx,cty,def->Shape.Wdt,6); - if ((cobj=Game.CreateObject(cid,NULL,Number,ctx,cty))) + if ((cobj=Game.CreateObject(cid,nullptr,Number,ctx,cty))) { if (FirstBase) // First base overrides target location { cobj->Enter(FirstBase); cobj->SetCommand(C4CMD_Exit); } @@ -594,7 +594,7 @@ void C4Player::PlaceReadyMaterial(int32_t tx1, int32_t tx2, int32_t ty, C4Object ctx=tx1+Random(tx2-tx1); cty=ty; if (!Game.C4S.PlrStart[PlrStartIndex].EnforcePosition) FindSolidGround(ctx,cty,def->Shape.Wdt); - Game.CreateObject(cid,NULL,Number,ctx,cty); + Game.CreateObject(cid,nullptr,Number,ctx,cty); } } } @@ -671,7 +671,7 @@ bool C4Player::ScenarioInit() } // Place Readies - C4Object *FirstBase = NULL; + C4Object *FirstBase = nullptr; PlaceReadyBase(ptx,pty,&FirstBase); PlaceReadyMaterial(ptx-10,ptx+10,pty,FirstBase); PlaceReadyVehic(ptx-30,ptx+30,pty,FirstBase); @@ -775,7 +775,7 @@ void C4Player::ResetCursorView(bool immediate_position) { // reset view to cursor if any cursor exists if (!ViewCursor && !Cursor) return; - SetViewMode(C4PVM_Cursor, NULL, immediate_position); + SetViewMode(C4PVM_Cursor, nullptr, immediate_position); } void C4Player::Evaluate() @@ -860,7 +860,7 @@ bool C4Player::IsHostileTowards(const C4Player *plr) const C4Object* C4Player::GetHiExpActiveCrew() { - C4Object *hiexp=NULL; + C4Object *hiexp=nullptr; int32_t iHighestExp=-2, iExp; for (C4Object *cobj : Crew) { @@ -879,7 +879,7 @@ C4Object* C4Player::GetHiExpActiveCrew() C4Object* C4Player::GetHiRankActiveCrew() { - C4Object *hirank=NULL; + C4Object *hirank=nullptr; int32_t iHighestRank=-2, iRank; for (C4Object *cobj : Crew) { @@ -959,7 +959,7 @@ bool C4Player::Strip(const char *szFilename, bool fAggressive) { // 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(); @@ -1001,7 +1001,7 @@ void C4Player::DrawHostility(C4Facet &cgo, int32_t iIndex) bool C4Player::MakeCrewMember(C4Object *pObj, bool fForceInfo, bool fDoCalls) { - C4ObjectInfo *cInf = NULL; + C4ObjectInfo *cInf = nullptr; if (!pObj || !pObj->Def->CrewMember || !pObj->Status) return false; // only if info is not yet assigned @@ -1204,7 +1204,7 @@ void C4Player::DefaultRuntimeData() Surrendered=0; AtClient=C4ClientIDUnknown; SCopy("Local",AtClientName); - ControlSet = NULL; + ControlSet = nullptr; ControlSetName.Clear(); MouseControl=false; Position=-1; @@ -1212,13 +1212,13 @@ void C4Player::DefaultRuntimeData() RetireDelay=0; ViewMode=C4PVM_Cursor; ViewX=ViewY=0; - ViewTarget=NULL; + ViewTarget=nullptr; ShowStartup=true; Wealth=0; CurrentScore=InitialScore=0; ObjectsOwned=0; ProductionDelay=ProductionUnit=0; - Cursor=ViewCursor=NULL; + Cursor=ViewCursor=nullptr; CursorFlash=30; MessageStatus=0; MessageBuf[0]=0; @@ -1306,7 +1306,7 @@ void C4Player::NotifyOwnedObjects() { int32_t iNewOwner = FindNewOwner(); // notify objects in all object lists - for (C4ObjectList *pList = &::Objects; pList; pList = ((pList == &::Objects) ? &::Objects.InactiveObjects : NULL)) + for (C4ObjectList *pList = &::Objects; pList; pList = ((pList == &::Objects) ? &::Objects.InactiveObjects : nullptr)) { for (C4Object *cobj : *pList) { @@ -1371,7 +1371,7 @@ void C4Player::ClearControl() // Reset control LocalControl = false; ControlSetName.Clear(); - ControlSet=NULL; + ControlSet=nullptr; MouseControl = false; if (pGamepad) { @@ -1475,7 +1475,7 @@ void C4Player::Eliminate() if (::Control.isCtrlHost() && AtClient > C4ClientIDHost && !::Application.isEditor) { // Check: Any player left at this client? - C4Player *pPlr = NULL; + C4Player *pPlr = nullptr; for (int i = 0; (pPlr = ::Players.GetAtClient(AtClient, i)); i++) if (!pPlr->Eliminated) break; @@ -1571,7 +1571,7 @@ bool C4Player::SetObjectCrewStatus(C4Object *pCrew, bool fNewStatus) if (pCrew->Info && CrewInfoList.IsElement(pCrew->Info)) { pCrew->Info->Retire(); - pCrew->Info = NULL; + pCrew->Info = nullptr; } } // done, success @@ -1612,13 +1612,13 @@ void C4Player::ClearGraphs() { if (Game.pNetworkStatistics) Game.pNetworkStatistics->statControls.RemoveGraph(pstatControls); delete pstatControls; - pstatControls = NULL; + pstatControls = nullptr; } if (pstatActions) { if (Game.pNetworkStatistics) Game.pNetworkStatistics->statActions.RemoveGraph(pstatActions); delete pstatActions; - pstatActions = NULL; + pstatActions = nullptr; } } @@ -1828,8 +1828,8 @@ void C4Player::SetMaxZoom(C4Fixed zoom, bool no_increase, bool no_decrease) void C4Player::ZoomToViewports(bool direct, bool no_increase, bool no_decrease) { - C4Viewport *vp = NULL; - while((vp = ::Viewports.GetViewport(Number, vp)) != NULL) + C4Viewport *vp = nullptr; + while((vp = ::Viewports.GetViewport(Number, vp)) != nullptr) ZoomToViewport(vp, direct, no_increase, no_decrease); } @@ -1844,8 +1844,8 @@ void C4Player::ZoomToViewport(C4Viewport* vp, bool direct, bool no_increase, boo void C4Player::ZoomLimitsToViewports() { - C4Viewport *vp = NULL; - while((vp = ::Viewports.GetViewport(Number, vp)) != NULL) + C4Viewport *vp = nullptr; + while((vp = ::Viewports.GetViewport(Number, vp)) != nullptr) ZoomLimitsToViewport(vp); } @@ -1926,7 +1926,7 @@ void C4Player::SetSoundModifier(C4PropList *new_modifier) else { SoundModifier.Set0(); - mod = NULL; + mod = nullptr; } // update in sound system ::Application.SoundSystem.Modifiers.SetGlobalModifier(mod, Number); diff --git a/src/player/C4Player.h b/src/player/C4Player.h index be66f08c2..6ec8f96be 100644 --- a/src/player/C4Player.h +++ b/src/player/C4Player.h @@ -158,7 +158,7 @@ public: void ClearPointers(C4Object *tptr, bool fDeath); void Execute(); void ExecuteControl(); - void SetViewMode(int32_t iMode, C4Object *pTarget=NULL, bool immediate_position=false); + void SetViewMode(int32_t iMode, C4Object *pTarget=nullptr, bool immediate_position=false); void ResetCursorView(bool immediate_position = false); // reset view to cursor if any cursor exists void Evaluate(); void Surrender(); @@ -271,7 +271,7 @@ private: public: // custom scenario achievements - bool GainScenarioAchievement(const char *achievement_id, int32_t value, const char *scen_name_override=NULL); + bool GainScenarioAchievement(const char *achievement_id, int32_t value, const char *scen_name_override=nullptr); }; #endif diff --git a/src/player/C4PlayerList.cpp b/src/player/C4PlayerList.cpp index 724378bdf..27183f731 100644 --- a/src/player/C4PlayerList.cpp +++ b/src/player/C4PlayerList.cpp @@ -46,7 +46,7 @@ C4PlayerList::~C4PlayerList() void C4PlayerList::Default() { - First=NULL; + First=nullptr; } void C4PlayerList::Clear() @@ -54,7 +54,7 @@ void C4PlayerList::Clear() C4Player *pPlr; while ((pPlr = First)) { First = pPlr->Next; delete pPlr; } - First = NULL; + First = nullptr; } void C4PlayerList::Execute() @@ -139,7 +139,7 @@ C4Player* C4PlayerList::Get(int iNumber) const for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) if (pPlr->Number==iNumber) return pPlr; - return NULL; + return nullptr; } int C4PlayerList::GetIndex(C4Player *tPlr) const @@ -156,7 +156,7 @@ C4Player* C4PlayerList::GetByIndex(int iIndex) const for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) if (!iIndex--) return pPlr; - return NULL; + return nullptr; } C4Player* C4PlayerList::GetByIndex(int iIndex, C4PlayerType eType) const @@ -165,14 +165,14 @@ C4Player* C4PlayerList::GetByIndex(int iIndex, C4PlayerType eType) const if (pPlr->GetType() == eType) if (!iIndex--) return pPlr; - return NULL; + return nullptr; } C4Player *C4PlayerList::GetByInfoID(int iInfoID) const { for (C4Player *pPlr=First; pPlr; pPlr=pPlr->Next) if (pPlr->ID == iInfoID) return pPlr; - return NULL; + return nullptr; } int C4PlayerList::GetCount() const @@ -280,7 +280,7 @@ C4Player* C4PlayerList::Join(const char *szFilename, bool fScenarioInit, int iAt assert(fScenarioInit || numbers); // safeties - if (szFilename && !*szFilename) szFilename = NULL; + if (szFilename && !*szFilename) szFilename = nullptr; // Log LogF(LoadResStr(fScenarioInit ? "IDS_PRC_JOINPLR" : "IDS_PRC_RECREATE"),pInfo->GetName()); @@ -290,12 +290,12 @@ C4Player* C4PlayerList::Join(const char *szFilename, bool fScenarioInit, int iAt if (GetCount()+1>Game.Parameters.MaxPlayers) { LogF(LoadResStr("IDS_PRC_TOOMANYPLRS"),Game.Parameters.MaxPlayers); - return NULL; + return nullptr; } // Check duplicate file usage if (szFilename) if (FileInUse(szFilename)) - { Log(LoadResStr("IDS_PRC_PLRFILEINUSE")); return NULL; } + { Log(LoadResStr("IDS_PRC_PLRFILEINUSE")); return nullptr; } // Create C4Player *pPlr = new C4Player; @@ -307,7 +307,7 @@ C4Player* C4PlayerList::Join(const char *szFilename, bool fScenarioInit, int iAt // Init if (!pPlr->Init(GetFreeNumber(),iAtClient,szAtClientName,szFilename,fScenarioInit,pInfo, numbers)) - { Remove(pPlr, false, false); Log(LoadResStr("IDS_PRC_JOINFAIL")); return NULL; } + { Remove(pPlr, false, false); Log(LoadResStr("IDS_PRC_JOINFAIL")); return nullptr; } // Done return pPlr; @@ -425,7 +425,7 @@ C4Player* C4PlayerList::GetByName(const char *szName, int iExcluding) const if (SEqual(pPlr->GetName(),szName)) if (pPlr->Number!=iExcluding) return pPlr; - return NULL; + return nullptr; } bool C4PlayerList::FileInUse(const char *szFilename) const @@ -458,7 +458,7 @@ C4Player* C4PlayerList::GetLocalByIndex(int iIndex) const if (cindex==iIndex) return pPlr; cindex++; } - return NULL; + return nullptr; } bool C4PlayerList::RemoveAtClient(int iClient, bool fDisconnect) @@ -525,7 +525,7 @@ C4Player* C4PlayerList::GetAtClient(int iClient, int iIndex) const if (cindex==iIndex) return pPlr; cindex++; } - return NULL; + return nullptr; } C4Player* C4PlayerList::GetAtClient(const char *szName, int iIndex) const @@ -537,7 +537,7 @@ C4Player* C4PlayerList::GetAtClient(const char *szName, int iIndex) const if (cindex==iIndex) return pPlr; cindex++; } - return NULL; + return nullptr; } bool C4PlayerList::RemoveAtRemoteClient(bool fDisconnect, bool fNoCalls) @@ -563,7 +563,7 @@ C4Player* C4PlayerList::GetAtRemoteClient(int iIndex) const if (cindex==iIndex) return pPlr; cindex++; } - return NULL; + return nullptr; } bool C4PlayerList::RemoveLocal(bool fDisconnect, bool fNoCalls) diff --git a/src/player/C4RankSystem.cpp b/src/player/C4RankSystem.cpp index 5e0011434..e02559d37 100644 --- a/src/player/C4RankSystem.cpp +++ b/src/player/C4RankSystem.cpp @@ -30,7 +30,7 @@ #include "platform/StdRegistry.h" C4RankSystem::C4RankSystem() - : pszRankNames(NULL), szRankNames(NULL), pszRankExtensions(NULL) + : pszRankNames(nullptr), szRankNames(nullptr), pszRankExtensions(nullptr) { Default(); } @@ -263,9 +263,9 @@ bool C4RankSystem::Check(int iRank, const char *szDefRankName) void C4RankSystem::Clear() { // clear any loaded rank names - if (pszRankNames) { delete [] pszRankNames; pszRankNames=NULL; } - if (pszRankExtensions) { delete [] pszRankExtensions; pszRankExtensions = NULL; } - if (szRankNames) { delete [] szRankNames; szRankNames=NULL; } + if (pszRankNames) { delete [] pszRankNames; pszRankNames=nullptr; } + if (pszRankExtensions) { delete [] pszRankExtensions; pszRankExtensions = nullptr; } + if (szRankNames) { delete [] szRankNames; szRankNames=nullptr; } // reset number of ranks iRankNum=0; iRankExtNum=0; diff --git a/src/player/C4RankSystem.h b/src/player/C4RankSystem.h index eaeade6a4..a72052583 100644 --- a/src/player/C4RankSystem.h +++ b/src/player/C4RankSystem.h @@ -50,7 +50,7 @@ public: bool Check(int iRank, const char *szDefRankName); int32_t GetExtendedRankNum() const { return iRankExtNum; } int32_t GetBaseRankNum() const { return iRankNum; } - static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=NULL); // create facet from rank symbol for definition - use custom rank facets if present + static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=nullptr); // create facet from rank symbol for definition - use custom rank facets if present }; extern C4RankSystem DefaultRanks; diff --git a/src/player/C4ScenarioParameters.cpp b/src/player/C4ScenarioParameters.cpp index 6b68e50d9..4a92305c5 100644 --- a/src/player/C4ScenarioParameters.cpp +++ b/src/player/C4ScenarioParameters.cpp @@ -51,7 +51,7 @@ bool C4AchievementGraphics::Init(C4Group &File) bool C4AchievementGraphics::Init(C4GroupSet &Files) { int32_t idNewGrp=0; - C4Group *pGrp = Files.FindEntry(C4CFN_Achievements, NULL, &idNewGrp); + C4Group *pGrp = Files.FindEntry(C4CFN_Achievements, nullptr, &idNewGrp); if (!pGrp) return true; // no achievement gfx. That's OK. if (idNewGrp == idGrp) return true; // no update idGrp = idNewGrp; @@ -70,7 +70,7 @@ void C4AchievementGraphics::Clear() C4FacetSurface *C4AchievementGraphics::FindByName(const char *name) const { auto i = Graphics.find(StdCopyStrBuf(name)); - if (i != Graphics.end()) return i->second; else return NULL; + if (i != Graphics.end()) return i->second; else return nullptr; } @@ -92,12 +92,12 @@ const C4ScenarioParameterDef::Option *C4ScenarioParameterDef::GetOptionByValue(i for (auto i = Options.cbegin(); i != Options.cend(); ++i) if (i->Value == val) return &*i; - return NULL; + return nullptr; } const C4ScenarioParameterDef::Option *C4ScenarioParameterDef::GetOptionByIndex(size_t idx) const { - if (idx >= Options.size()) return NULL; + if (idx >= Options.size()) return nullptr; return &Options[idx]; } @@ -110,7 +110,7 @@ void C4ScenarioParameterDef::CompileFunc(StdCompiler *pComp) StdEnumEntry ParTypeEntries[] = { { "Enumeration", SPDT_Enum }, - { NULL, SPDT_Enum } + { nullptr, SPDT_Enum } }; pComp->Value(mkNamingAdapt(mkEnumAdaptT(Type, ParTypeEntries), "Type", SPDT_Enum)); pComp->Value(mkNamingAdapt(Default, "Default", 0)); @@ -127,7 +127,7 @@ void C4ScenarioParameterDefs::CompileFunc(StdCompiler *pComp) const C4ScenarioParameterDef *C4ScenarioParameterDefs::GetParameterDefByIndex(size_t idx) const { - if (idx >= Parameters.size()) return NULL; + if (idx >= Parameters.size()) return nullptr; return &Parameters[idx]; } diff --git a/src/script/C4Aul.cpp b/src/script/C4Aul.cpp index ea82adfc4..acb722265 100644 --- a/src/script/C4Aul.cpp +++ b/src/script/C4Aul.cpp @@ -49,7 +49,7 @@ const char *C4AulError::what() const noexcept /*--- C4AulScriptEngine ---*/ C4AulScriptEngine::C4AulScriptEngine(): - C4PropListStaticMember(NULL, NULL, ::Strings.RegString("Global")), + C4PropListStaticMember(nullptr, nullptr, ::Strings.RegString("Global")), ErrorHandler(&DefaultErrorHandler), warnCnt(0), errCnt(0), lineCnt(0) { @@ -59,7 +59,7 @@ C4AulScriptEngine::C4AulScriptEngine(): GlobalConstNames.Reset(); GlobalConsts.Reset(); GlobalConsts.SetNameList(&GlobalConstNames); - Child0 = ChildL = NULL; + Child0 = ChildL = nullptr; RegisterGlobalConstant("Global", C4VPropList(this)); } @@ -90,7 +90,7 @@ void C4AulScriptEngine::Clear() RegisterGlobalConstant("Global", C4VPropList(this)); GlobalNamed.Reset(); GlobalNamed.SetNameList(&GlobalNamedNames); - delete pGlobalEffects; pGlobalEffects=NULL; + delete pGlobalEffects; pGlobalEffects=nullptr; UserFiles.clear(); // Delete all global proplists made static (breaks // cyclic references). @@ -140,7 +140,7 @@ void C4AulScriptEngine::Denumerate(C4ValueNumbers * numbers) static void GlobalEffectsMergeCompileFunc(StdCompiler *pComp, C4Effect * & pEffects, const char * name, C4PropList * pForObj, C4ValueNumbers * numbers) { C4Effect *pOldEffect, *pNextOldEffect=pEffects; - pEffects = NULL; + pEffects = nullptr; try { pComp->Value(mkParAdapt(mkNamingPtrAdapt(pEffects, name), pForObj, numbers)); @@ -244,7 +244,7 @@ C4AulUserFile *C4AulScriptEngine::GetUserFile(int32_t handle) return &*i; } // not found - return NULL; + return nullptr; } void C4AulScriptEngine::RegisterErrorHandler(C4AulErrorHandler *handler) @@ -282,7 +282,7 @@ unsigned int C4AulFuncMap::Hash(const char * name) C4AulFunc * C4AulFuncMap::GetFirstFunc(const char * Name) { - if (!Name) return NULL; + if (!Name) return nullptr; C4AulFunc * Func = Funcs[Hash(Name) % HashSize]; while (Func && !SEqual(Name, Func->GetName())) Func = Func->MapNext; diff --git a/src/script/C4Aul.h b/src/script/C4Aul.h index 9acb4ca46..bca6d1cd3 100644 --- a/src/script/C4Aul.h +++ b/src/script/C4Aul.h @@ -131,7 +131,7 @@ public: C4ValueMapNames GlobalConstNames; C4ValueMapData GlobalConsts; - C4Effect * pGlobalEffects = NULL; + C4Effect * pGlobalEffects = nullptr; C4AulScriptEngine(); // constructor ~C4AulScriptEngine(); // destructor @@ -145,7 +145,7 @@ public: std::list GetFunctionNames(C4PropList *); void RegisterGlobalConstant(const char *szName, const C4Value &rValue); // creates a new constants or overwrites an old one - bool GetGlobalConstant(const char *szName, C4Value *pTargetValue); // check if a constant exists; assign value to pTargetValue if not NULL + bool GetGlobalConstant(const char *szName, C4Value *pTargetValue); // check if a constant exists; assign value to pTargetValue if not nullptr void Denumerate(C4ValueNumbers *); void UnLink(); // called when a script is being reloaded (clears string table) diff --git a/src/script/C4AulCompiler.cpp b/src/script/C4AulCompiler.cpp index 1d5cd0823..c54c64d53 100644 --- a/src/script/C4AulCompiler.cpp +++ b/src/script/C4AulCompiler.cpp @@ -1670,7 +1670,7 @@ void C4AulCompiler::ConstexprEvaluator::visit(const ::aul::ast::ProplistLit *n) } else { - // If proplist_magic.parent is NULL, we're handling a global constant. + // If proplist_magic.parent is nullptr, we're handling a global constant. host->Engine->GetGlobalConstant(key->GetCStr(), &old); } if (old.getPropList()) @@ -1680,7 +1680,7 @@ void C4AulCompiler::ConstexprEvaluator::visit(const ::aul::ast::ProplistLit *n) } else { - p = C4PropList::NewStatic(NULL, proplist_magic.parent, key); + p = C4PropList::NewStatic(nullptr, proplist_magic.parent, key); new_proplist.reset(p); } } diff --git a/src/script/C4AulDebug.cpp b/src/script/C4AulDebug.cpp index ca4f24aa2..2f57a6031 100644 --- a/src/script/C4AulDebug.cpp +++ b/src/script/C4AulDebug.cpp @@ -40,7 +40,7 @@ C4AulDebug::~C4AulDebug() { for (std::list::iterator it = StackTrace.begin(); it != StackTrace.end(); it++) {delete *it;} - if (pDebug == this) pDebug = NULL; + if (pDebug == this) pDebug = nullptr; } bool C4AulDebug::InitDebug(const char *szPassword, const char *szHost) @@ -105,7 +105,7 @@ size_t C4AulDebug::UnpackPacket(const StdBuf &rInBuf, const C4NetIO::addr_t &add { ProcessLineResult result = ProcessLine(Buf); // Send answer - SendLine(result.okay ? "OK" : "ERR", result.answer.length() > 0 ? result.answer.c_str() : NULL); + SendLine(result.okay ? "OK" : "ERR", result.answer.length() > 0 ? result.answer.c_str() : nullptr); } else if (!Password.getSize() || Password == Buf) { @@ -277,7 +277,7 @@ C4AulDebug::ProcessLineResult C4AulDebug::ProcessLine(const StdStrBuf &Line) auto sh = script; if (sh) { - C4AulBCC * found = NULL; + C4AulBCC * found = nullptr; for (auto script = ::ScriptEngine.Child0; script; script = script->Next) for (C4PropList *props = script->GetPropList(); props; props = props->GetPrototype()) for (auto fname = props->EnumerateOwnFuncs(); fname; fname = props->EnumerateOwnFuncs(fname)) @@ -323,7 +323,7 @@ C4AulDebug::ProcessLineResult C4AulDebug::ProcessLine(const StdStrBuf &Line) else if (SEqualNoCase(szCmd, "VAR")) { - C4Value *val = NULL; + C4Value *val = nullptr; int varIndex; C4AulScriptContext* pCtx = pExec->GetContext(pExec->GetContextDepth() - 1); if (pCtx) @@ -481,6 +481,6 @@ StdStrBuf C4AulDebug::FormatCodePos(C4AulScriptContext *pCtx, C4AulBCC *pCPos) return StdStrBuf("(eval)"); } -C4AulDebug * C4AulDebug::pDebug = NULL; +C4AulDebug * C4AulDebug::pDebug = nullptr; #endif diff --git a/src/script/C4AulDebug.h b/src/script/C4AulDebug.h index 26b5c5685..4c48a3bd2 100644 --- a/src/script/C4AulDebug.h +++ b/src/script/C4AulDebug.h @@ -94,7 +94,7 @@ private: ProcessLineResult ProcessLine(const StdStrBuf &Line); - bool SendLine(const char *szType, const char *szData = NULL); + bool SendLine(const char *szType, const char *szData = nullptr); }; #endif diff --git a/src/script/C4AulDefFunc.h b/src/script/C4AulDefFunc.h index 6e3c2f276..32e3c48ec 100644 --- a/src/script/C4AulDefFunc.h +++ b/src/script/C4AulDefFunc.h @@ -30,17 +30,17 @@ inline const static char *FnStringPar(C4String *pString) } inline C4String *String(const char * str) { - return str ? ::Strings.RegString(str) : NULL; + return str ? ::Strings.RegString(str) : nullptr; } inline C4Object * Object(C4PropList * _this) { - return _this ? _this->GetObject() : NULL; + return _this ? _this->GetObject() : nullptr; } StdStrBuf FnStringFormat(C4PropList * _this, C4String *szFormatPar, C4Value * Pars, int ParCount); C4Effect ** FnGetEffectsFor(C4PropList * pTarget); // Nillable: Allow integer and boolean parameters to be nil -// pointer parameters represent nil via plain NULL +// pointer parameters represent nil via plain nullptr // other types can use C4Void class C4Void { }; template struct C4ValueConv; diff --git a/src/script/C4AulExec.cpp b/src/script/C4AulExec.cpp index 4fc553180..d0dc59271 100644 --- a/src/script/C4AulExec.cpp +++ b/src/script/C4AulExec.cpp @@ -116,7 +116,7 @@ C4String *C4AulExec::FnTranslate(C4PropList * _this, C4String *text) } \ } while(0) - if (!text || text->GetData().isNull()) return NULL; + if (!text || text->GetData().isNull()) return nullptr; // Find correct script: translations of the context if possible, containing script as fallback if (_this && _this->GetDef()) ReturnIfTranslationAvailable(&(_this->GetDef()->Script), text->GetCStr()); @@ -141,7 +141,7 @@ void C4AulExec::ClearPointers(C4Object * obj) for (C4AulScriptContext *pCtx = pCurCtx; pCtx >= Contexts; pCtx--) { if (pCtx->Obj == obj) - pCtx->Obj = NULL; + pCtx->Obj = nullptr; } } @@ -161,10 +161,10 @@ C4Value C4AulExec::Exec(C4AulScriptFunc *pSFunc, C4PropList * p, C4Value *pnPars C4AulScriptContext ctx; ctx.tTime = 0; ctx.Obj = p; - ctx.Return = NULL; + ctx.Return = nullptr; ctx.Pars = pPars; ctx.Func = pSFunc; - ctx.CPos = NULL; + ctx.CPos = nullptr; PushContext(ctx); // Execute @@ -695,7 +695,7 @@ C4Value C4AulExec::Exec(C4AulBCC *pCPos) pCurCtx->CPos = pCPos; assert(pCurCtx->Func->GetCode() <= pCPos); // Do the call - C4AulBCC *pJump = Call(pFunc, pPars, pPars, NULL); + C4AulBCC *pJump = Call(pFunc, pPars, pPars, nullptr); if (pJump) { pCPos = pJump; @@ -842,7 +842,7 @@ C4AulBCC *C4AulExec::Call(C4AulFunc *pFunc, C4Value *pReturn, C4Value *pPars, C4 ctx.Return = pReturn; ctx.Pars = pPars; ctx.Func = pSFunc; - ctx.CPos = NULL; + ctx.CPos = nullptr; PushContext(ctx); // Jump to code @@ -902,7 +902,7 @@ C4AulBCC *C4AulExec::Call(C4AulFunc *pFunc, C4Value *pReturn, C4Value *pPars, C4 PopValuesUntil(pReturn); // Continue - return NULL; + return nullptr; } } @@ -980,7 +980,7 @@ void C4AulProfiler::StopProfiling() AulExec.StopProfiling(); // collect profiler times C4AulProfiler Profiler; - Profiler.CollectEntry(NULL, AulExec.tDirectExecTotal); + Profiler.CollectEntry(nullptr, AulExec.tDirectExecTotal); if(AulExec.pProfiledScript) Profiler.CollectTimes(AulExec.pProfiledScript->GetPropList()); else diff --git a/src/script/C4AulExec.h b/src/script/C4AulExec.h index 52dfa02fd..f47fd4cde 100644 --- a/src/script/C4AulExec.h +++ b/src/script/C4AulExec.h @@ -78,14 +78,14 @@ private: friend class C4AulProfiler; public: C4Value Exec(C4AulScriptFunc *pSFunc, C4PropList * p, C4Value pPars[], bool fPassErrors); - C4Value DirectExec(C4PropList *p, const char *szScript, const char *szContext, bool fPassErrors = false, C4AulScriptContext* context = NULL, bool parse_function = false); + C4Value DirectExec(C4PropList *p, const char *szScript, const char *szContext, bool fPassErrors = false, C4AulScriptContext* context = nullptr, bool parse_function = false); void StartTrace(); inline void StartDirectExec() { if (fProfiling) tDirectExecStart = C4TimeMilliseconds::Now(); } inline void StopDirectExec() { if (fProfiling) tDirectExecTotal += C4TimeMilliseconds::Now() - tDirectExecStart; } int GetContextDepth() const { return pCurCtx - Contexts + 1; } - C4AulScriptContext *GetContext(int iLevel) { return iLevel >= 0 && iLevel < GetContextDepth() ? Contexts + iLevel : NULL; } + C4AulScriptContext *GetContext(int iLevel) { return iLevel >= 0 && iLevel < GetContextDepth() ? Contexts + iLevel : nullptr; } void LogCallStack(); static C4String *FnTranslate(C4PropList * _this, C4String *text); static bool FnLogCallStack(C4PropList * _this); @@ -226,7 +226,7 @@ private: else throw C4AulExecError(FormatString("can't access %s as array or proplist", pStructure->GetTypeName()).getData()); } - C4AulBCC *Call(C4AulFunc *pFunc, C4Value *pReturn, C4Value *pPars, C4PropList * pContext = NULL); + C4AulBCC *Call(C4AulFunc *pFunc, C4Value *pReturn, C4Value *pPars, C4PropList * pContext = nullptr); }; extern C4AulExec AulExec; diff --git a/src/script/C4AulFunc.cpp b/src/script/C4AulFunc.cpp index 81d9746fd..08d0f3fbf 100644 --- a/src/script/C4AulFunc.cpp +++ b/src/script/C4AulFunc.cpp @@ -22,7 +22,7 @@ C4AulFunc::C4AulFunc(C4PropListStatic * Parent, const char *pName): Parent(Parent), Name(pName ? Strings.RegString(pName) : 0), - MapNext(NULL) + MapNext(nullptr) { // add to global lookuptable with this name if (GetName()) diff --git a/src/script/C4AulFunc.h b/src/script/C4AulFunc.h index 93ea3b630..1c29d6e7f 100644 --- a/src/script/C4AulFunc.h +++ b/src/script/C4AulFunc.h @@ -63,14 +63,14 @@ protected: virtual ~C4AulFunc(); public: - virtual C4AulScriptFunc *SFunc() { return NULL; } // type check func... + virtual C4AulScriptFunc *SFunc() { return nullptr; } // type check func... // Wether this function should be visible to players virtual bool GetPublic() const { return false; } virtual int GetParCount() const { return C4AUL_MAX_Par; } virtual const C4V_Type* GetParType() const = 0; virtual C4V_Type GetRetType() const = 0; - C4Value Exec(C4PropList * p = NULL, C4AulParSet *pPars = NULL, bool fPassErrors=false) + C4Value Exec(C4PropList * p = nullptr, C4AulParSet *pPars = nullptr, bool fPassErrors=false) { // Every parameter type allows conversion from nil, so no parameters are always allowed if (!pPars) diff --git a/src/script/C4AulLink.cpp b/src/script/C4AulLink.cpp index 09a3b5530..1edd8d2cb 100644 --- a/src/script/C4AulLink.cpp +++ b/src/script/C4AulLink.cpp @@ -51,7 +51,7 @@ bool C4ScriptHost::ResolveAppends(C4DefList *rDefs) { if (*a != "*" || !rDefs) { - C4Def *Def = rDefs ? rDefs->GetByName(*a) : NULL; + C4Def *Def = rDefs ? rDefs->GetByName(*a) : nullptr; if (Def) { DoAppend(Def); @@ -98,7 +98,7 @@ bool C4ScriptHost::ResolveIncludes(C4DefList *rDefs) // append all includes to local script for (std::list::reverse_iterator i = Includes.rbegin(); i != Includes.rend(); ++i) { - C4Def *Def = rDefs ? rDefs->GetByName(*i) : NULL; + C4Def *Def = rDefs ? rDefs->GetByName(*i) : nullptr; if (Def) { // resolve #includes in included script first (#include-chains :( ) diff --git a/src/script/C4AulParse.cpp b/src/script/C4AulParse.cpp index 8dacf92ac..bd3691776 100644 --- a/src/script/C4AulParse.cpp +++ b/src/script/C4AulParse.cpp @@ -110,11 +110,11 @@ C4AulParse::C4AulParse(C4ScriptHost *a) : Fn(0), Host(a), pOrgScript(a), Engine(a->Engine), SPos(a->Script.getData()), TokenSPos(SPos), TokenType(ATT_INVALID), - ContextToExecIn(NULL) + ContextToExecIn(nullptr) { } C4AulParse::C4AulParse(C4AulScriptFunc * Fn, C4AulScriptContext* context, C4AulScriptEngine *Engine) : - Fn(Fn), Host(NULL), pOrgScript(NULL), Engine(Engine), + Fn(Fn), Host(nullptr), pOrgScript(nullptr), Engine(Engine), SPos(Fn->Script), TokenSPos(SPos), TokenType(ATT_INVALID), ContextToExecIn(context) @@ -317,7 +317,7 @@ const C4ScriptOpDef C4ScriptOpMap[] = { 2, "|=", AB_BitOr, 1, 1, 0, C4V_Int, C4V_Int, C4V_Int}, { 2, "^=", AB_BitXOr, 1, 1, 0, C4V_Int, C4V_Int, C4V_Int}, - { 0, NULL, AB_ERR, 0, 0, 0, C4V_Nil, C4V_Nil, C4V_Nil} + { 0, nullptr, AB_ERR, 0, 0, 0, C4V_Nil, C4V_Nil, C4V_Nil} }; int C4AulParse::GetOperator(const char* pScript) @@ -1103,7 +1103,7 @@ void C4AulParse::Parse_CallParams(::aul::ast::CallExpr *call) case ATT_COMMA: // got no parameter before a "," if (Config.Developer.ExtraWarnings) - Warn(FormatString("parameter %zu of call to %s is empty", call->args.size(), call->callee.c_str()).getData(), NULL); + Warn(FormatString("parameter %zu of call to %s is empty", call->args.size(), call->callee.c_str()).getData(), nullptr); call->args.push_back(::aul::ast::NilLit::New(TokenSPos)); Shift(); break; @@ -1137,7 +1137,7 @@ std::unique_ptr<::aul::ast::ArrayLit> C4AulParse::Parse_Array() if (TokenType == ATT_COMMA) { if (Config.Developer.ExtraWarnings) - Warn(FormatString("array entry %zu is empty", arr->values.size()).getData(), NULL); + Warn(FormatString("array entry %zu is empty", arr->values.size()).getData(), nullptr); arr->values.emplace_back(::aul::ast::NilLit::New(TokenSPos)); } else @@ -1149,7 +1149,7 @@ std::unique_ptr<::aul::ast::ArrayLit> C4AulParse::Parse_Array() if (TokenType == ATT_BCLOSE2) { if (Config.Developer.ExtraWarnings) - Warn(FormatString("array entry %zu is empty", arr->values.size()).getData(), NULL); + Warn(FormatString("array entry %zu is empty", arr->values.size()).getData(), nullptr); arr->values.emplace_back(::aul::ast::NilLit::New(TokenSPos)); } } @@ -1650,7 +1650,7 @@ void C4ScriptHost::CopyPropList(C4Set & from, C4PropListStatic * to) if (prop->Key != &::Strings.P[P_Prototype]) if (!p || p->GetParent() != to) { - p = C4PropList::NewStatic(NULL, to, prop->Key); + p = C4PropList::NewStatic(nullptr, to, prop->Key); CopyPropList(prop->Value._getPropList()->Properties, p); } to->SetPropertyByS(prop->Key, C4VPropList(p)); diff --git a/src/script/C4AulParse.h b/src/script/C4AulParse.h index 3d5ab70af..7e747cf92 100644 --- a/src/script/C4AulParse.h +++ b/src/script/C4AulParse.h @@ -89,8 +89,8 @@ private: void ClearToken(); // clear any data held with the current token C4AulTokenType GetNextToken(); // get next token of SPos - void Match(C4AulTokenType TokenType, const char * Expected = NULL); - void Check(C4AulTokenType TokenType, const char * Expected = NULL); + void Match(C4AulTokenType TokenType, const char * Expected = nullptr); + void Check(C4AulTokenType TokenType, const char * Expected = nullptr); NORETURN void UnexpectedToken(const char * Expected); void Warn(const char *pMsg, ...) GNUC_FORMAT_ATTRIBUTE_O; diff --git a/src/script/C4AulScriptFunc.cpp b/src/script/C4AulScriptFunc.cpp index d54655608..88d6ca151 100644 --- a/src/script/C4AulScriptFunc.cpp +++ b/src/script/C4AulScriptFunc.cpp @@ -21,7 +21,7 @@ C4AulScriptFunc::C4AulScriptFunc(C4PropListStatic * Parent, C4ScriptHost *pOrgScript, const char *pName, const char *Script): C4AulFunc(Parent, pName), - OwnerOverloaded(NULL), + OwnerOverloaded(nullptr), ParCount(0), Script(Script), pOrgScript(pOrgScript), @@ -33,7 +33,7 @@ C4AulScriptFunc::C4AulScriptFunc(C4PropListStatic * Parent, C4ScriptHost *pOrgSc C4AulScriptFunc::C4AulScriptFunc(C4PropListStatic * Parent, const C4AulScriptFunc &FromFunc): C4AulFunc(Parent, FromFunc.GetName()), - OwnerOverloaded(NULL), + OwnerOverloaded(nullptr), ParCount(FromFunc.ParCount), Script(FromFunc.Script), VarNamed(FromFunc.VarNamed), diff --git a/src/script/C4AulScriptFunc.h b/src/script/C4AulScriptFunc.h index c7e830930..0720eb69b 100644 --- a/src/script/C4AulScriptFunc.h +++ b/src/script/C4AulScriptFunc.h @@ -182,7 +182,7 @@ protected: void ClearCode(); int GetCodePos() const { return Code.size(); } C4AulBCC *GetCodeByPos(int iPos) { return &Code[iPos]; } - C4AulBCC *GetLastCode() { return Code.empty() ? NULL : &Code.back(); } + C4AulBCC *GetLastCode() { return Code.empty() ? nullptr : &Code.back(); } void DumpByteCode(); std::vector Code; std::vector PosForCode; @@ -207,8 +207,8 @@ public: C4AulScriptFunc(C4PropListStatic * Parent, const C4AulScriptFunc &FromFunc); // copy script/code, etc from given func ~C4AulScriptFunc(); - void ParseDirectExecFunc(C4AulScriptEngine *Engine, C4AulScriptContext* context = NULL); - void ParseDirectExecStatement(C4AulScriptEngine *Engine, C4AulScriptContext* context = NULL); + void ParseDirectExecFunc(C4AulScriptEngine *Engine, C4AulScriptContext* context = nullptr); + void ParseDirectExecStatement(C4AulScriptEngine *Engine, C4AulScriptContext* context = nullptr); virtual bool GetPublic() const { return true; } virtual int GetParCount() const { return ParCount; } diff --git a/src/script/C4Effect.cpp b/src/script/C4Effect.cpp index 30f31aba7..e3468e6d7 100644 --- a/src/script/C4Effect.cpp +++ b/src/script/C4Effect.cpp @@ -126,7 +126,7 @@ C4Effect * C4Effect::Init(C4PropList *pForObj, int32_t iPrio, const C4Value &rVa // higher-level effects should not be inserted during the process of removing or adding a lower-level effect // because that would cause a wrong initialization order // (hardly ever causing trouble, however...) - C4Effect *pLastRemovedEffect=NULL; + C4Effect *pLastRemovedEffect=nullptr; C4AulFunc * pFn; if (!GetCallbackScript()) { @@ -158,7 +158,7 @@ C4Effect::C4Effect() // defaults iPriority=iTime=iInterval=0; CommandTarget.Set0(); - pNext = NULL; + pNext = nullptr; } C4Effect::~C4Effect() @@ -168,7 +168,7 @@ C4Effect::~C4Effect() while ((pEffect = pNext)) { pNext = pEffect->pNext; - pEffect->pNext = NULL; + pEffect->pNext = nullptr; delete pEffect; } } @@ -210,7 +210,7 @@ void C4Effect::SetDead() C4Effect *C4Effect::Get(const char *szName, int32_t iIndex, int32_t iMaxPriority) { // safety - if (!szName) return NULL; + if (!szName) return nullptr; // check all effects C4Effect *pEff = this; do @@ -230,7 +230,7 @@ C4Effect *C4Effect::Get(const char *szName, int32_t iIndex, int32_t iMaxPriority } while ((pEff=pEff->pNext)); // nothing found - return NULL; + return nullptr; } int32_t C4Effect::GetCount(const char *szMask, int32_t iMaxPriority) @@ -251,8 +251,8 @@ C4Effect* C4Effect::Check(const char *szCheckEffect, int32_t iPrio, int32_t iTim // priority=1: always OK; no callbacks if (iPrio == 1) return 0; // check this and other effects - C4Effect *pAddToEffect = NULL; bool fDoTempCallsForAdd = false; - C4Effect *pLastRemovedEffect=NULL; + C4Effect *pAddToEffect = nullptr; bool fDoTempCallsForAdd = false; + C4Effect *pLastRemovedEffect=nullptr; for (C4Effect *pCheck = this; pCheck; pCheck = pCheck->pNext) { if (!pCheck->IsDead() && pCheck->iPriority >= iPrio) @@ -313,7 +313,7 @@ void C4Effect::Execute(C4Effect **ppEffectList) { // delete it, then C4Effect *pNextEffect = pEffect->pNext; - pEffect->pNext = NULL; + pEffect->pNext = nullptr; delete pEffect; // next effect *ppPrevEffect = pEffect = pNextEffect; @@ -343,7 +343,7 @@ void C4Effect::Execute(C4Effect **ppEffectList) void C4Effect::Kill() { // active? - C4Effect *pLastRemovedEffect=NULL; + C4Effect *pLastRemovedEffect=nullptr; if (IsActive()) // then temp remove all higher priority effects TempRemoveUpperEffects(false, &pLastRemovedEffect); @@ -404,7 +404,7 @@ void C4Effect::DoDamage(int32_t &riDamage, int32_t iDamageType, int32_t iCausePl while ((pEff = pEff->pNext) && riDamage); } -static C4Object * Obj(C4PropList * p) { return p ? p->GetObject() : NULL; } +static C4Object * Obj(C4PropList * p) { return p ? p->GetObject() : nullptr; } C4Value C4Effect::DoCall(C4PropList *pObj, const char *szFn, const C4Value &rVal1, const C4Value &rVal2, const C4Value &rVal3, const C4Value &rVal4, const C4Value &rVal5, const C4Value &rVal6, const C4Value &rVal7) { @@ -550,7 +550,7 @@ void C4Effect::CompileFunc(StdCompiler *pComp, C4PropList * Owner, C4ValueNumber // read ID if (pComp->isDecompiler()) { - const C4PropListStatic * p = CommandTarget.getPropList() ? CommandTarget._getPropList()->IsStatic() : NULL; + const C4PropListStatic * p = CommandTarget.getPropList() ? CommandTarget._getPropList()->IsStatic() : nullptr; if (p) p->RefCompileFunc(pComp, numbers); else diff --git a/src/script/C4PropList.cpp b/src/script/C4PropList.cpp index dfc04a084..f9cab1c77 100644 --- a/src/script/C4PropList.cpp +++ b/src/script/C4PropList.cpp @@ -273,7 +273,7 @@ const char *C4PropListStatic::GetName() const } C4PropList::C4PropList(C4PropList * prototype): - FirstRef(NULL), prototype(prototype), + FirstRef(nullptr), prototype(prototype), constant(false), Status(1) { #ifdef _DEBUG @@ -346,7 +346,7 @@ C4PropList::~C4PropList() FirstRef->Data = 0; FirstRef->Type = C4V_Nil; C4Value *ref = FirstRef; FirstRef = FirstRef->NextRef; - ref->NextRef = NULL; + ref->NextRef = nullptr; } #ifdef _DEBUG assert(PropLists.Has(this)); @@ -626,13 +626,13 @@ C4Def const * C4PropList::GetDef() const class C4MapScriptLayer * C4PropList::GetMapScriptLayer() { if (GetPrototype()) return GetPrototype()->GetMapScriptLayer(); - return NULL; + return nullptr; } class C4MapScriptMap * C4PropList::GetMapScriptMap() { if (GetPrototype()) return GetPrototype()->GetMapScriptMap(); - return NULL; + return nullptr; } C4PropListNumbered * C4PropList::GetPropListNumbered() @@ -843,7 +843,7 @@ C4PropList *C4PropList::GetPropertyPropList(C4PropertyName n) const { return GetPrototype()->GetPropertyPropList(n); } - return NULL; + return nullptr; } C4ValueArray * C4PropList::GetProperties() const diff --git a/src/script/C4PropList.h b/src/script/C4PropList.h index 23d28abdc..dd7b3a9e3 100644 --- a/src/script/C4PropList.h +++ b/src/script/C4PropList.h @@ -59,7 +59,7 @@ public: C4Property & operator = (void * p) { assert(!p); if (Key) Key->DecRef(); Key = 0; Value.Set0(); return *this; } bool operator < (const C4Property &cmp) const { return strcmp(GetSafeKey(), cmp.GetSafeKey())<0; } - const char *GetSafeKey() const { if (Key && Key->GetCStr()) return Key->GetCStr(); return ""; } // get key as C string; return "" if undefined. never return NULL + const char *GetSafeKey() const { if (Key && Key->GetCStr()) return Key->GetCStr(); return ""; } // get key as C string; return "" if undefined. never return nullptr }; class C4PropListNumbered; class C4PropList @@ -84,7 +84,7 @@ public: void RemoveCyclicPrototypes(); // saved as a reference to a global constant? - virtual class C4PropListStatic * IsStatic() { return NULL; } + virtual class C4PropListStatic * IsStatic() { return nullptr; } const class C4PropListStatic * IsStatic() const { return const_cast(this)->IsStatic(); } // saved as a reference to separately saved objects? virtual bool IsNumbered() const { return false; } diff --git a/src/script/C4Script.cpp b/src/script/C4Script.cpp index 4541cd4e6..042a9a4d0 100644 --- a/src/script/C4Script.cpp +++ b/src/script/C4Script.cpp @@ -390,11 +390,11 @@ static C4Effect * FnGetEffect(C4PropList * _this, C4String *psEffectName, C4Prop const char *szEffect = FnStringPar(psEffectName); // get effects C4Effect *pEffect = *FnGetEffectsFor(pTarget); - if (!pEffect) return NULL; + if (!pEffect) return nullptr; // name/wildcard given: find effect by name and index if (szEffect && *szEffect) return pEffect->Get(szEffect, index, iMaxPriority); - return NULL; + return nullptr; } static bool FnRemoveEffect(C4PropList * _this, C4String *psEffectName, C4PropList *pTarget, C4Effect * pEffect2, bool fDoNoCalls) @@ -930,7 +930,7 @@ static bool FnLocateFunc(C4PropList * _this, C4String *funcname, C4PropList * p) LogF("%s%s (%s:%d)", szPrefix, pFunc->GetName(), pSFunc->pOrgScript->ScriptName.getData(), (int)iLine); } // next func in overload chain - pFunc = pSFunc ? pSFunc->OwnerOverloaded : NULL; + pFunc = pSFunc ? pSFunc->OwnerOverloaded : nullptr; szPrefix = "overloads "; } } @@ -976,7 +976,7 @@ static bool FnStartScriptProfiler(C4PropList * _this, C4Def * pDef) if (pDef) pScript = &pDef->Script; else - pScript = NULL; + pScript = nullptr; // profile it C4AulProfiler::StartProfiling(pScript); return true; @@ -1059,7 +1059,7 @@ static bool FnFileWrite(C4PropList * _this, int32_t file_handle, C4String *data) C4AulUserFile *file = ::ScriptEngine.GetUserFile(file_handle); if (!file) throw C4AulExecError("FileWrite: invalid file handle"); // prepare string to write - if (!data) return false; // write NULL? No. + if (!data) return false; // write nullptr? No. // write it file->Write(data->GetCStr(), data->GetData().getLength()); return true; @@ -1113,7 +1113,7 @@ C4ScriptConstDef C4ScriptConstMap[]= { "C4X_Ver1", C4V_Int, C4XVER1}, { "C4X_Ver2", C4V_Int, C4XVER2}, - { NULL, C4V_Nil, 0} + { nullptr, C4V_Nil, 0} }; C4ScriptFnDef C4ScriptFnMap[]= @@ -1125,7 +1125,7 @@ C4ScriptFnDef C4ScriptFnMap[]= { "Format", 1, C4V_String, { C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnFormat }, { "Trans_Mul", 1, C4V_Array, { C4V_Array ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnTrans_Mul}, - { 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 } }; void InitCoreFunctionMap(C4AulScriptEngine *pEngine) diff --git a/src/script/C4ScriptHost.cpp b/src/script/C4ScriptHost.cpp index c6b3661c4..57ed3b943 100644 --- a/src/script/C4ScriptHost.cpp +++ b/src/script/C4ScriptHost.cpp @@ -32,11 +32,11 @@ C4ScriptHost::C4ScriptHost(): // prepare lists - Prev(NULL), Next(NULL), - Engine(NULL), + Prev(nullptr), Next(nullptr), + Engine(nullptr), State(ASS_NONE) // not compiled { - Script = NULL; + Script = nullptr; stringTable = 0; SourceScripts.push_back(this); // prepare include list @@ -64,7 +64,7 @@ void C4ScriptHost::Clear() if (stringTable) { stringTable->DelRef(); - stringTable = NULL; + stringTable = nullptr; } // remove includes Includes.clear(); @@ -141,8 +141,8 @@ void C4ScriptHost::Unreg() // remove from list if (Prev) Prev->Next = Next; else if (Engine) Engine->Child0 = Next; if (Next) Next->Prev = Prev; else if (Engine) Engine->ChildL = Prev; - Prev = Next = NULL; - Engine = NULL; + Prev = Next = nullptr; + Engine = nullptr; } void C4ScriptHost::Reg2List(C4AulScriptEngine *pEngine) @@ -159,8 +159,8 @@ void C4ScriptHost::Reg2List(C4AulScriptEngine *pEngine) Engine->ChildL = this; } else - Prev = NULL; - Next = NULL; + Prev = nullptr; + Next = nullptr; } bool C4ScriptHost::Load(C4Group &hGroup, const char *szFilename, @@ -235,7 +235,7 @@ bool C4ScriptHost::ReloadScript(const char *szPath, const char *szLanguage) char szParentPath[_MAX_PATH + 1]; C4Group ParentGrp; if (GetParentPath(szPath, szParentPath)) if (ParentGrp.Open(szParentPath)) - if (Load(ParentGrp, NULL, szLanguage, stringTable)) + if (Load(ParentGrp, nullptr, szLanguage, stringTable)) return true; } return false; @@ -251,7 +251,7 @@ std::string C4ScriptHost::Translate(const std::string &text) const /*--- C4ExtraScriptHost ---*/ C4ExtraScriptHost::C4ExtraScriptHost(C4String *parent_key_name): - ParserPropList(C4PropList::NewStatic(NULL, NULL, parent_key_name)) + ParserPropList(C4PropList::NewStatic(nullptr, nullptr, parent_key_name)) { } @@ -328,7 +328,7 @@ C4PropListStatic * C4DefScriptHost::GetPropList() { return Def; } class C4PropListScen: public C4PropListStatic { public: - C4PropListScen(const C4PropListStatic * parent, C4String * key): C4PropListStatic(NULL, parent, key) + C4PropListScen(const C4PropListStatic * parent, C4String * key): C4PropListStatic(nullptr, parent, key) { C4PropList * proto = C4PropList::NewStatic(ScriptEngine.GetPropList(), this, &::Strings.P[P_Prototype]); C4PropListStatic::SetPropertyByS(&::Strings.P[P_Prototype], C4VPropList(proto)); @@ -352,7 +352,7 @@ C4GameScriptHost::~C4GameScriptHost() { } bool C4GameScriptHost::Load(C4Group & g, const char * f, const char * l, C4LangStringTable * t) { assert(ScriptEngine.GetPropList()); - C4PropListStatic * pScen = new C4PropListScen(NULL, &::Strings.P[P_Scenario]); + C4PropListStatic * pScen = new C4PropListScen(nullptr, &::Strings.P[P_Scenario]); ScenPropList.SetPropList(pScen); ::ScriptEngine.RegisterGlobalConstant("Scenario", ScenPropList); ScenPrototype.SetPropList(pScen->GetPrototype()); @@ -363,7 +363,7 @@ bool C4GameScriptHost::Load(C4Group & g, const char * f, const char * l, C4LangS bool C4GameScriptHost::LoadData(const char * f, const char * d, C4LangStringTable * t) { assert(ScriptEngine.GetPropList()); - C4PropListStatic * pScen = new C4PropListScen(NULL, &::Strings.P[P_Scenario]); + C4PropListStatic * pScen = new C4PropListScen(nullptr, &::Strings.P[P_Scenario]); ScenPropList.SetPropList(pScen); ::ScriptEngine.RegisterGlobalConstant("Scenario", ScenPropList); ScenPrototype.SetPropList(pScen->GetPrototype()); @@ -376,7 +376,7 @@ void C4GameScriptHost::Clear() C4ScriptHost::Clear(); ScenPropList.Set0(); ScenPrototype.Set0(); - delete pScenarioEffects; pScenarioEffects=NULL; + delete pScenarioEffects; pScenarioEffects=nullptr; } C4PropListStatic * C4GameScriptHost::GetPropList() diff --git a/src/script/C4ScriptHost.h b/src/script/C4ScriptHost.h index 8b53646a4..e1bd25454 100644 --- a/src/script/C4ScriptHost.h +++ b/src/script/C4ScriptHost.h @@ -113,7 +113,7 @@ class C4ExtraScriptHost: public C4ScriptHost { C4Value ParserPropList; public: - C4ExtraScriptHost(C4String *parent_key_name = NULL); + C4ExtraScriptHost(C4String *parent_key_name = nullptr); ~C4ExtraScriptHost(); void Clear(); @@ -132,7 +132,7 @@ public: class C4DefScriptHost: public C4ScriptHost { public: - C4DefScriptHost() : C4ScriptHost(), Def(NULL) { } + C4DefScriptHost() : C4ScriptHost(), Def(nullptr) { } void SetDef(C4Def *to_def) { Def=to_def; } virtual bool Parse(); @@ -156,7 +156,7 @@ public: C4Value Call(const char *szFunction, C4AulParSet *pPars=0, bool fPassError=false); C4Value ScenPropList; C4Value ScenPrototype; - C4Effect * pScenarioEffects = NULL; + C4Effect * pScenarioEffects = nullptr; }; extern C4GameScriptHost GameScript; diff --git a/src/script/C4ScriptStandalone.cpp b/src/script/C4ScriptStandalone.cpp index ed00a9fb4..361b2f74c 100644 --- a/src/script/C4ScriptStandalone.cpp +++ b/src/script/C4ScriptStandalone.cpp @@ -24,7 +24,7 @@ #include "object/C4DefList.h" /* StandaloneStubs.cpp is shared with mape, which has a real implementation of these */ -C4Def* C4DefList::GetByName(const StdStrBuf &) {return NULL;} +C4Def* C4DefList::GetByName(const StdStrBuf &) {return nullptr;} C4Def * C4DefList::GetDef(int) {return 0;} int C4DefList::GetDefCount() {return 0;} void C4DefList::SortByPriority() {} @@ -36,13 +36,13 @@ void InitializeC4Script() InitCoreFunctionMap(&ScriptEngine); // Seed PRNG - FixedRandom(time(NULL)); + FixedRandom(time(nullptr)); } C4Value RunLoadedC4Script() { // Link script engine (resolve includes/appends, generate code) - ScriptEngine.Link(NULL); + ScriptEngine.Link(nullptr); C4Value result = GameScript.Call("Main"); GameScript.Clear(); @@ -69,7 +69,7 @@ int c4s_runfile(const char * filename) } InitializeC4Script(); - GameScript.Load(File, fn.getData(), NULL, NULL); + GameScript.Load(File, fn.getData(), nullptr, nullptr); RunLoadedC4Script(); return 0; } @@ -77,7 +77,7 @@ int c4s_runfile(const char * filename) int c4s_runstring(const char *script) { InitializeC4Script(); - GameScript.LoadData("", script, NULL); + GameScript.LoadData("", script, nullptr); RunLoadedC4Script(); return 0; } diff --git a/src/script/C4StringTable.h b/src/script/C4StringTable.h index 194d0f2d9..6349f8a93 100644 --- a/src/script/C4StringTable.h +++ b/src/script/C4StringTable.h @@ -273,14 +273,14 @@ public: } static bool SortFunc(const T *p1, const T*p2) { - // elements are guarantueed to be non-NULL + // elements are guarantueed to be non-nullptr return *p1<*p2; } std::list GetSortedListOfElementPointers() const { // return a list of pointers to all elements in this set sorted by the standard less-than operation // of the elements - // elements of resulting lists are guarantueed to be non-NULL + // elements of resulting lists are guarantueed to be non-nullptr // list remains valid as long as this set is not changed std::list result; for (const T *p = First(); p; p = Next(p)) result.push_back(p); diff --git a/src/script/C4Value.cpp b/src/script/C4Value.cpp index ed19c0f31..decbb7564 100644 --- a/src/script/C4Value.cpp +++ b/src/script/C4Value.cpp @@ -69,22 +69,22 @@ C4Value::C4Value(C4Effect * p): C4Value(static_cast(p)) {} C4Object * C4Value::getObj() const { - return CheckConversion(C4V_Object) ? Data.PropList->GetObject() : NULL; + return CheckConversion(C4V_Object) ? Data.PropList->GetObject() : nullptr; } C4Object * C4Value::_getObj() const { - return Data.PropList ? Data.PropList->GetObject() : NULL; + return Data.PropList ? Data.PropList->GetObject() : nullptr; } C4Def * C4Value::getDef() const { - return CheckConversion(C4V_Def) ? Data.PropList->GetDef() : NULL; + return CheckConversion(C4V_Def) ? Data.PropList->GetDef() : nullptr; } C4Def * C4Value::_getDef() const { - return Data.PropList ? Data.PropList->GetDef() : NULL; + return Data.PropList ? Data.PropList->GetDef() : nullptr; } C4Value C4VObj(C4Object *pObj) { return C4Value(static_cast(pObj)); } @@ -540,7 +540,7 @@ bool C4Value::operator == (const C4Value& Value2) const return s; } }; - static Seen *top = NULL; + static Seen *top = nullptr; Seen here(top, this, &Value2); bool recursion = top && top->recursion(&here); diff --git a/src/script/C4Value.h b/src/script/C4Value.h index 4cf13df9b..9a8a5726b 100644 --- a/src/script/C4Value.h +++ b/src/script/C4Value.h @@ -65,33 +65,33 @@ class C4Value { public: - C4Value() : NextRef(NULL), Type(C4V_Nil) { Data = 0; } + C4Value() : NextRef(nullptr), Type(C4V_Nil) { Data = 0; } - C4Value(const C4Value &nValue) : Data(nValue.Data), NextRef(NULL), Type(nValue.Type) + C4Value(const C4Value &nValue) : Data(nValue.Data), NextRef(nullptr), Type(nValue.Type) { AddDataRef(); } C4Value(C4Value && nValue) noexcept; - explicit C4Value(bool data): NextRef(NULL), Type(C4V_Bool) + explicit C4Value(bool data): NextRef(nullptr), Type(C4V_Bool) { Data.Int = data; } - explicit C4Value(int data): NextRef(NULL), Type(C4V_Int) + explicit C4Value(int data): NextRef(nullptr), Type(C4V_Int) { Data.Int = data; } - explicit C4Value(long data): NextRef(NULL), Type(C4V_Int) + explicit C4Value(long data): NextRef(nullptr), Type(C4V_Int) { Data.Int = int32_t(data); } explicit C4Value(C4PropListStatic *p); explicit C4Value(C4Def *p); explicit C4Value(C4Object *pObj); explicit C4Value(C4Effect *p); - explicit C4Value(C4String *pStr): NextRef(NULL), Type(pStr ? C4V_String : C4V_Nil) + explicit C4Value(C4String *pStr): NextRef(nullptr), Type(pStr ? C4V_String : C4V_Nil) { Data.Str = pStr; AddDataRef(); } - explicit C4Value(const char * s): NextRef(NULL), Type(s ? C4V_String : C4V_Nil) - { Data.Str = s ? ::Strings.RegString(s) : NULL; AddDataRef(); } - explicit C4Value(const StdStrBuf & s): NextRef(NULL), Type(s.isNull() ? C4V_Nil : C4V_String) - { Data.Str = s.isNull() ? NULL: ::Strings.RegString(s); AddDataRef(); } - explicit C4Value(C4ValueArray *pArray): NextRef(NULL), Type(pArray ? C4V_Array : C4V_Nil) + explicit C4Value(const char * s): NextRef(nullptr), Type(s ? C4V_String : C4V_Nil) + { Data.Str = s ? ::Strings.RegString(s) : nullptr; AddDataRef(); } + explicit C4Value(const StdStrBuf & s): NextRef(nullptr), Type(s.isNull() ? C4V_Nil : C4V_String) + { Data.Str = s.isNull() ? nullptr: ::Strings.RegString(s); AddDataRef(); } + explicit C4Value(C4ValueArray *pArray): NextRef(nullptr), Type(pArray ? C4V_Array : C4V_Nil) { Data.Array = pArray; AddDataRef(); } - explicit C4Value(C4AulFunc * pFn): NextRef(NULL), Type(pFn ? C4V_Function : C4V_Nil) + explicit C4Value(C4AulFunc * pFn): NextRef(nullptr), Type(pFn ? C4V_Function : C4V_Nil) { Data.Fn = pFn; AddDataRef(); } - explicit C4Value(C4PropList *p): NextRef(NULL), Type(p ? C4V_PropList : C4V_Nil) + explicit C4Value(C4PropList *p): NextRef(nullptr), Type(p ? C4V_PropList : C4V_Nil) { Data.PropList = p; AddDataRef(); } C4Value(C4ObjectPtr p): C4Value(p.operator C4Object *()) {} template C4Value(Nillable v): C4Value(v.IsNil() ? C4Value() : C4Value(v.operator T())) {} @@ -105,10 +105,10 @@ public: bool getBool() const { return CheckConversion(C4V_Bool) ? !! Data : 0; } C4Object * getObj() const; C4Def * getDef() const; - C4PropList * getPropList() const { return CheckConversion(C4V_PropList) ? Data.PropList : NULL; } - C4String * getStr() const { return CheckConversion(C4V_String) ? Data.Str : NULL; } - C4ValueArray * getArray() const { return CheckConversion(C4V_Array) ? Data.Array : NULL; } - C4AulFunc * getFunction() const { return CheckConversion(C4V_Function) ? Data.Fn : NULL; } + C4PropList * getPropList() const { return CheckConversion(C4V_PropList) ? Data.PropList : nullptr; } + C4String * getStr() const { return CheckConversion(C4V_String) ? Data.Str : nullptr; } + C4ValueArray * getArray() const { return CheckConversion(C4V_Array) ? Data.Array : nullptr; } + C4AulFunc * getFunction() const { return CheckConversion(C4V_Function) ? Data.Fn : nullptr; } // Unchecked getters int32_t _getInt() const { return Data.Int; } @@ -338,14 +338,14 @@ ALWAYS_INLINE void C4Value::Set0() } ALWAYS_INLINE C4Value::C4Value(C4Value && nValue) noexcept: - Data(nValue.Data), NextRef(NULL), Type(nValue.Type) + Data(nValue.Data), NextRef(nullptr), Type(nValue.Type) { if (Type == C4V_PropList) { Data.PropList->AddRef(this); Data.PropList->DelRef(&nValue, nValue.NextRef); } - nValue.Type = C4V_Nil; nValue.Data = 0; nValue.NextRef = NULL; + nValue.Type = C4V_Nil; nValue.Data = 0; nValue.NextRef = nullptr; } #endif diff --git a/src/script/C4ValueArray.cpp b/src/script/C4ValueArray.cpp index 7a378c153..79679e4de 100644 --- a/src/script/C4ValueArray.cpp +++ b/src/script/C4ValueArray.cpp @@ -21,18 +21,18 @@ #include "object/C4FindObject.h" C4ValueArray::C4ValueArray() - : pData(NULL), iSize(0), iCapacity(0), constant(false) + : pData(nullptr), iSize(0), iCapacity(0), constant(false) { } C4ValueArray::C4ValueArray(int32_t inSize) - : pData(NULL), iSize(0), iCapacity(0), constant(false) + : pData(nullptr), iSize(0), iCapacity(0), constant(false) { SetSize(inSize); } C4ValueArray::C4ValueArray(const C4ValueArray &ValueArray2) - : pData(NULL), iSize(0), iCapacity(0), constant(false) + : pData(nullptr), iSize(0), iCapacity(0), constant(false) { SetSize(ValueArray2.GetSize()); for (int32_t i = 0; i < iSize; i++) @@ -41,7 +41,7 @@ C4ValueArray::C4ValueArray(const C4ValueArray &ValueArray2) C4ValueArray::~C4ValueArray() { - delete[] pData; pData = NULL; + delete[] pData; pData = nullptr; iSize = iCapacity = 0; } @@ -260,7 +260,7 @@ bool C4ValueArray::operator==(const C4ValueArray& IntList2) const void C4ValueArray::Reset() { - delete[] pData; pData = NULL; + delete[] pData; pData = nullptr; iSize = iCapacity = 0; } diff --git a/src/script/C4ValueMap.cpp b/src/script/C4ValueMap.cpp index e970e83ff..cefdda99b 100644 --- a/src/script/C4ValueMap.cpp +++ b/src/script/C4ValueMap.cpp @@ -356,7 +356,7 @@ void C4ValueMapNames::Reset() for (int32_t i = 0; i < iSize; i++) delete[] pNames[i]; delete[] pNames; - pNames = NULL; + pNames = nullptr; iSize = 0; }