summaryrefslogtreecommitdiff
path: root/src/os/windows
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-04-10 22:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-10 23:22:20 +0200
commit7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch)
tree99f134b7e66367cf11e10bc5061896eab4a3264f /src/os/windows
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/os/windows')
-rw-r--r--src/os/windows/crashlog_win.cpp42
-rw-r--r--src/os/windows/string_uniscribe.cpp46
-rw-r--r--src/os/windows/win32.cpp82
3 files changed, 85 insertions, 85 deletions
diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp
index 458a76163..a19789976 100644
--- a/src/os/windows/crashlog_win.cpp
+++ b/src/os/windows/crashlog_win.cpp
@@ -66,7 +66,7 @@ public:
* A crash log is always generated when it's generated.
* @param ep the data related to the exception.
*/
- CrashLogWindows(EXCEPTION_POINTERS *ep = NULL) :
+ CrashLogWindows(EXCEPTION_POINTERS *ep = nullptr) :
ep(ep)
{
this->crashlog[0] = '\0';
@@ -81,7 +81,7 @@ public:
static CrashLogWindows *current;
};
-/* static */ CrashLogWindows *CrashLogWindows::current = NULL;
+/* static */ CrashLogWindows *CrashLogWindows::current = nullptr;
/* virtual */ char *CrashLogWindows::LogOSVersion(char *buffer, const char *last) const
{
@@ -114,7 +114,7 @@ public:
" Message: %s\n\n",
(int)ep->ExceptionRecord->ExceptionCode,
(size_t)ep->ExceptionRecord->ExceptionAddress,
- message == NULL ? "<none>" : message
+ message == nullptr ? "<none>" : message
);
}
@@ -156,7 +156,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
HANDLE file;
memset(dfi, 0, sizeof(*dfi));
- file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
+ file = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, 0);
if (file != INVALID_HANDLE_VALUE) {
byte buffer[1024];
DWORD numread;
@@ -165,7 +165,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
uint32 crc = (uint32)-1;
for (;;) {
- if (ReadFile(file, buffer, sizeof(buffer), &numread, NULL) == 0 || numread == 0) {
+ if (ReadFile(file, buffer, sizeof(buffer), &numread, nullptr) == 0 || numread == 0) {
break;
}
filesize += numread;
@@ -174,7 +174,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
dfi->size = filesize;
dfi->crc32 = crc ^ (uint32)-1;
- if (GetFileTime(file, NULL, NULL, &write_time)) {
+ if (GetFileTime(file, nullptr, nullptr, &write_time)) {
FileTimeToSystemTime(&write_time, &dfi->file_time);
}
CloseHandle(file);
@@ -217,7 +217,7 @@ static char *PrintModuleInfo(char *output, const char *last, HMODULE mod)
BOOL res;
HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
- if (proc != NULL) {
+ if (proc != nullptr) {
res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
CloseHandle(proc);
if (res) {
@@ -228,7 +228,7 @@ static char *PrintModuleInfo(char *output, const char *last, HMODULE mod)
}
}
}
- output = PrintModuleInfo(output, last, NULL);
+ output = PrintModuleInfo(output, last, nullptr);
return output + seprintf(output, last, "\n");
}
@@ -362,7 +362,7 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
if (LoadLibraryList((Function*)&proc, dbg_import)) {
/* Initialize symbol handler. */
HANDLE hCur = GetCurrentProcess();
- proc.pSymInitialize(hCur, NULL, TRUE);
+ proc.pSymInitialize(hCur, nullptr, TRUE);
/* Load symbols only when needed, fail silently on errors, demangle symbol names. */
proc.pSymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_FAIL_CRITICAL_ERRORS | SYMOPT_UNDNAME);
@@ -399,7 +399,7 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
#else
IMAGE_FILE_MACHINE_I386,
#endif
- hCur, GetCurrentThread(), &frame, &ctx, NULL, proc.pSymFunctionTableAccess64, proc.pSymGetModuleBase64, NULL)) break;
+ hCur, GetCurrentThread(), &frame, &ctx, nullptr, proc.pSymFunctionTableAccess64, proc.pSymGetModuleBase64, nullptr)) break;
if (frame.AddrPC.Offset == frame.AddrReturn.Offset) {
buffer += seprintf(buffer, last, " <infinite loop>\n");
@@ -443,16 +443,16 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
{
int ret = 0;
HMODULE dbghelp = LoadLibrary(_T("dbghelp.dll"));
- if (dbghelp != NULL) {
+ if (dbghelp != nullptr) {
typedef BOOL (WINAPI *MiniDumpWriteDump_t)(HANDLE, DWORD, HANDLE,
MINIDUMP_TYPE,
CONST PMINIDUMP_EXCEPTION_INFORMATION,
CONST PMINIDUMP_USER_STREAM_INFORMATION,
CONST PMINIDUMP_CALLBACK_INFORMATION);
MiniDumpWriteDump_t funcMiniDumpWriteDump = (MiniDumpWriteDump_t)GetProcAddress(dbghelp, "MiniDumpWriteDump");
- if (funcMiniDumpWriteDump != NULL) {
+ if (funcMiniDumpWriteDump != nullptr) {
seprintf(filename, filename_last, "%scrash.dmp", _personal_dir);
- HANDLE file = CreateFile(OTTD2FS(filename), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
+ HANDLE file = CreateFile(OTTD2FS(filename), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, 0);
HANDLE proc = GetCurrentProcess();
DWORD procid = GetCurrentProcessId();
MINIDUMP_EXCEPTION_INFORMATION mdei;
@@ -470,7 +470,7 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
mdei.ExceptionPointers = ep;
mdei.ClientPointers = false;
- funcMiniDumpWriteDump(proc, procid, file, MiniDumpWithDataSegs, &mdei, &musi, NULL);
+ funcMiniDumpWriteDump(proc, procid, file, MiniDumpWithDataSegs, &mdei, &musi, nullptr);
ret = 1;
} else {
ret = -1;
@@ -488,11 +488,11 @@ static void ShowCrashlogWindow();
* Stack pointer for use when 'starting' the crash handler.
* Not static as gcc's inline assembly needs it that way.
*/
-void *_safe_esp = NULL;
+void *_safe_esp = nullptr;
static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
{
- if (CrashLogWindows::current != NULL) {
+ if (CrashLogWindows::current != nullptr) {
CrashLog::AfterCrashLogCleanup();
ExitProcess(2);
}
@@ -501,7 +501,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
static const TCHAR _emergency_crash[] =
_T("A serious fault condition occurred in the game. The game will shut down.\n")
_T("As you loaded an emergency savegame no crash information will be generated.\n");
- MessageBox(NULL, _emergency_crash, _T("Fatal Application Failure"), MB_ICONERROR);
+ MessageBox(nullptr, _emergency_crash, _T("Fatal Application Failure"), MB_ICONERROR);
ExitProcess(3);
}
@@ -510,7 +510,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
_T("A serious fault condition occurred in the game. The game will shut down.\n")
_T("As you loaded an savegame for which you do not have the required NewGRFs\n")
_T("no crash information will be generated.\n");
- MessageBox(NULL, _saveload_crash, _T("Fatal Application Failure"), MB_ICONERROR);
+ MessageBox(nullptr, _saveload_crash, _T("Fatal Application Failure"), MB_ICONERROR);
ExitProcess(3);
}
@@ -525,7 +525,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
/* Close any possible log files */
CloseConsoleLogIfActive();
- if ((VideoDriver::GetInstance() == NULL || VideoDriver::GetInstance()->HasGUI()) && _safe_esp != NULL) {
+ if ((VideoDriver::GetInstance() == nullptr || VideoDriver::GetInstance()->HasGUI()) && _safe_esp != nullptr) {
#ifdef _M_AMD64
ep->ContextRecord->Rip = (DWORD64)ShowCrashlogWindow;
ep->ContextRecord->Rsp = (DWORD64)_safe_esp;
@@ -542,7 +542,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
static void CDECL CustomAbort(int signal)
{
- RaiseException(0xE1212012, 0, 0, NULL);
+ RaiseException(0xE1212012, 0, 0, nullptr);
}
/* static */ void CrashLog::InitialiseCrashLog()
@@ -693,5 +693,5 @@ static void ShowCrashlogWindow()
{
ShowCursor(TRUE);
ShowWindow(GetActiveWindow(), FALSE);
- DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(100), NULL, CrashDialogFunc);
+ DialogBox(GetModuleHandle(nullptr), MAKEINTRESOURCE(100), nullptr, CrashDialogFunc);
}
diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp
index 5abe848bd..8c4e11d3f 100644
--- a/src/os/windows/string_uniscribe.cpp
+++ b/src/os/windows/string_uniscribe.cpp
@@ -86,7 +86,7 @@ public:
int num_glyphs;
Font *font;
- mutable int *glyph_to_char = NULL;
+ mutable int *glyph_to_char = nullptr;
public:
UniscribeVisualRun(const UniscribeRun &range, int x);
@@ -139,9 +139,9 @@ public:
void UniscribeResetScriptCache(FontSize size)
{
- if (_script_cache[size] != NULL) {
+ if (_script_cache[size] != nullptr) {
ScriptFreeCache(&_script_cache[size]);
- _script_cache[size] = NULL;
+ _script_cache[size] = nullptr;
}
}
@@ -168,9 +168,9 @@ static bool UniscribeShapeRun(const UniscribeParagraphLayoutFactory::CharType *b
/* The char-to-glyph array is the same size as the input. */
range.char_to_glyph.resize(range.len);
- HDC temp_dc = NULL;
- HFONT old_font = NULL;
- HFONT cur_font = NULL;
+ HDC temp_dc = nullptr;
+ HFONT old_font = nullptr;
+ HFONT cur_font = nullptr;
while (true) {
/* Shape the text run by determining the glyphs needed for display. */
@@ -217,9 +217,9 @@ static bool UniscribeShapeRun(const UniscribeParagraphLayoutFactory::CharType *b
} else if (hr == E_PENDING) {
/* Glyph data is not in cache, load native font. */
cur_font = HFontFromFont(range.font);
- if (cur_font == NULL) return false; // Sorry, no dice.
+ if (cur_font == nullptr) return false; // Sorry, no dice.
- temp_dc = CreateCompatibleDC(NULL);
+ temp_dc = CreateCompatibleDC(nullptr);
SetMapMode(temp_dc, MM_TEXT);
old_font = (HFONT)SelectObject(temp_dc, cur_font);
} else if (hr == USP_E_SCRIPT_NOT_IN_FONT && range.sa.eScript != SCRIPT_UNDEFINED) {
@@ -227,19 +227,19 @@ static bool UniscribeShapeRun(const UniscribeParagraphLayoutFactory::CharType *b
range.sa.eScript = SCRIPT_UNDEFINED;
} else {
/* Some unknown other error. */
- if (temp_dc != NULL) {
+ if (temp_dc != nullptr) {
SelectObject(temp_dc, old_font);
DeleteObject(cur_font);
- ReleaseDC(NULL, temp_dc);
+ ReleaseDC(nullptr, temp_dc);
}
return false;
}
}
- if (temp_dc != NULL) {
+ if (temp_dc != nullptr) {
SelectObject(temp_dc, old_font);
DeleteObject(cur_font);
- ReleaseDC(NULL, temp_dc);
+ ReleaseDC(nullptr, temp_dc);
}
return true;
@@ -280,16 +280,16 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
{
int32 length = buff_end - buff;
/* Can't layout an empty string. */
- if (length == 0) return NULL;
+ if (length == 0) return nullptr;
/* Can't layout our in-built sprite fonts. */
for (auto const &pair : fontMapping) {
- if (pair.second->fc->IsBuiltInFont()) return NULL;
+ if (pair.second->fc->IsBuiltInFont()) return nullptr;
}
/* Itemize text. */
std::vector<SCRIPT_ITEM> items = UniscribeItemizeString(buff, length);
- if (items.size() == 0) return NULL;
+ if (items.size() == 0) return nullptr;
/* Build ranges from the items and the font map. A range is a run of text
* that is part of a single item and formatted using a single font style. */
@@ -306,7 +306,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
/* Shape the range. */
if (!UniscribeShapeRun(buff, ranges.back())) {
- return NULL;
+ return nullptr;
}
/* If we are at the end of the current item, advance to the next item. */
@@ -323,7 +323,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
std::vector<UniscribeRun>::iterator start_run = this->cur_range;
std::vector<UniscribeRun>::iterator last_run = this->cur_range;
- if (start_run == this->ranges.end()) return NULL;
+ if (start_run == this->ranges.end()) return nullptr;
/* Add remaining width of the first run if it is a broken run. */
int cur_width = 0;
@@ -355,7 +355,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
int last_cluster = this->cur_range_offset + 1;
for (std::vector<UniscribeRun>::iterator r = start_run; r != last_run; r++) {
log_attribs.resize(r->pos - start_run->pos + r->len);
- if (FAILED(ScriptBreak(this->text_buffer + r->pos + start_offs, r->len - start_offs, &r->sa, &log_attribs[r->pos - start_run->pos + start_offs]))) return NULL;
+ if (FAILED(ScriptBreak(this->text_buffer + r->pos + start_offs, r->len - start_offs, &r->sa, &log_attribs[r->pos - start_run->pos + start_offs]))) return nullptr;
std::vector<int> dx(r->len);
ScriptGetLogicalWidths(&r->sa, r->len, (int)r->glyphs.size(), &r->advances[0], &r->char_to_glyph[0], &r->vis_attribs[0], &dx[0]);
@@ -401,7 +401,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
bidi_level.push_back(r->sa.s.uBidiLevel);
}
std::vector<INT> vis_to_log(bidi_level.size());
- if (FAILED(ScriptLayout((int)bidi_level.size(), &bidi_level[0], &vis_to_log[0], NULL))) return NULL;
+ if (FAILED(ScriptLayout((int)bidi_level.size(), &bidi_level[0], &vis_to_log[0], nullptr))) return nullptr;
/* Create line. */
std::unique_ptr<UniscribeLine> line(new UniscribeLine());
@@ -415,14 +415,14 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
if (i_run == last_run - 1 && remaing_offset < (last_run - 1)->len) {
run.len = remaing_offset - 1;
- if (!UniscribeShapeRun(this->text_buffer, run)) return NULL;
+ if (!UniscribeShapeRun(this->text_buffer, run)) return nullptr;
}
if (i_run == start_run && this->cur_range_offset > 0) {
assert(run.len - this->cur_range_offset > 0);
run.pos += this->cur_range_offset;
run.len -= this->cur_range_offset;
- if (!UniscribeShapeRun(this->text_buffer, run)) return NULL;
+ if (!UniscribeShapeRun(this->text_buffer, run)) return nullptr;
}
line->emplace_back(run, cur_pos);
@@ -490,12 +490,12 @@ UniscribeParagraphLayout::UniscribeVisualRun::UniscribeVisualRun(UniscribeVisual
start_pos(other.start_pos), total_advance(other.total_advance), num_glyphs(other.num_glyphs), font(other.font)
{
this->glyph_to_char = other.glyph_to_char;
- other.glyph_to_char = NULL;
+ other.glyph_to_char = nullptr;
}
const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() const
{
- if (this->glyph_to_char == NULL) {
+ if (this->glyph_to_char == nullptr) {
this->glyph_to_char = CallocT<int>(this->GetGlyphCount());
/* The char to glyph array contains the first glyph index of the cluster that is associated
diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp
index ae78407ac..b0495d64d 100644
--- a/src/os/windows/win32.cpp
+++ b/src/os/windows/win32.cpp
@@ -61,14 +61,14 @@ bool LoadLibraryList(Function proc[], const char *dll)
HMODULE lib;
lib = LoadLibrary(MB_TO_WIDE(dll));
- if (lib == NULL) return false;
+ if (lib == nullptr) return false;
for (;;) {
FARPROC p;
while (*dll++ != '\0') { /* Nothing */ }
if (*dll == '\0') break;
p = GetProcAddress(lib, dll);
- if (p == NULL) return false;
+ if (p == nullptr) return false;
*proc++ = (Function)p;
}
dll++;
@@ -84,7 +84,7 @@ void ShowOSErrorBox(const char *buf, bool system)
void OSOpenBrowser(const char *url)
{
- ShellExecute(GetActiveWindow(), _T("open"), OTTD2FS(url), NULL, NULL, SW_SHOWNORMAL);
+ ShellExecute(GetActiveWindow(), _T("open"), OTTD2FS(url), nullptr, nullptr, SW_SHOWNORMAL);
}
/* Code below for windows version of opendir/readdir/closedir copied and
@@ -142,7 +142,7 @@ DIR *opendir(const TCHAR *path)
if ((fa != INVALID_FILE_ATTRIBUTES) && (fa & FILE_ATTRIBUTE_DIRECTORY)) {
d = dir_calloc();
- if (d != NULL) {
+ if (d != nullptr) {
TCHAR search_path[MAX_PATH];
bool slash = path[_tcslen(path) - 1] == '\\';
@@ -158,14 +158,14 @@ DIR *opendir(const TCHAR *path)
d->at_first_entry = true;
} else {
dir_free(d);
- d = NULL;
+ d = nullptr;
}
} else {
errno = ENOMEM;
}
} else {
/* path not found or not a directory */
- d = NULL;
+ d = nullptr;
errno = ENOENT;
}
@@ -179,11 +179,11 @@ struct dirent *readdir(DIR *d)
if (d->at_first_entry) {
/* the directory was empty when opened */
- if (d->hFind == INVALID_HANDLE_VALUE) return NULL;
+ if (d->hFind == INVALID_HANDLE_VALUE) return nullptr;
d->at_first_entry = false;
} else if (!FindNextFile(d->hFind, &d->fd)) { // determine cause and bail
if (GetLastError() == ERROR_NO_MORE_FILES) SetLastError(prev_err);
- return NULL;
+ return nullptr;
}
/* This entry has passed all checks; return information about it.
@@ -251,7 +251,7 @@ bool FiosGetDiskFreeSpace(const char *path, uint64 *tot)
DWORD spc, bps, nfc, tnc;
_sntprintf(root, lengthof(root), _T("%c:") _T(PATHSEP), path[0]);
- if (tot != NULL && GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) {
+ if (tot != nullptr && GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) {
*tot = ((spc * bps) * (uint64)nfc);
retval = true;
}
@@ -339,9 +339,9 @@ void CreateConsole()
*stderr = *fdopen(2, "w" );
#endif
- setvbuf(stdin, NULL, _IONBF, 0);
- setvbuf(stdout, NULL, _IONBF, 0);
- setvbuf(stderr, NULL, _IONBF, 0);
+ setvbuf(stdin, nullptr, _IONBF, 0);
+ setvbuf(stdout, nullptr, _IONBF, 0);
+ setvbuf(stderr, nullptr, _IONBF, 0);
}
/** Temporary pointer to get the help message to the window */
@@ -398,7 +398,7 @@ void ShowInfo(const char *str)
* ShowInfo are much shorter, or so long they need this way of displaying
* them anyway. */
_help_msg = str;
- DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(101), NULL, HelpDialogFunc);
+ DialogBox(GetModuleHandle(nullptr), MAKEINTRESOURCE(101), nullptr, HelpDialogFunc);
} else {
/* We need to put the text in a separate buffer because the default
* buffer in OTTD2FS might not be large enough (512 chars). */
@@ -459,28 +459,28 @@ void DetermineBasePaths(const char *exe)
char tmp[MAX_PATH];
TCHAR path[MAX_PATH];
#ifdef WITH_PERSONAL_DIR
- if (SUCCEEDED(OTTDSHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path))) {
+ if (SUCCEEDED(OTTDSHGetFolderPath(nullptr, CSIDL_PERSONAL, nullptr, SHGFP_TYPE_CURRENT, path))) {
strecpy(tmp, FS2OTTD(path), lastof(tmp));
AppendPathSeparator(tmp, lastof(tmp));
strecat(tmp, PERSONAL_DIR, lastof(tmp));
AppendPathSeparator(tmp, lastof(tmp));
_searchpaths[SP_PERSONAL_DIR] = stredup(tmp);
} else {
- _searchpaths[SP_PERSONAL_DIR] = NULL;
+ _searchpaths[SP_PERSONAL_DIR] = nullptr;
}
- if (SUCCEEDED(OTTDSHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, SHGFP_TYPE_CURRENT, path))) {
+ if (SUCCEEDED(OTTDSHGetFolderPath(nullptr, CSIDL_COMMON_DOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, path))) {
strecpy(tmp, FS2OTTD(path), lastof(tmp));
AppendPathSeparator(tmp, lastof(tmp));
strecat(tmp, PERSONAL_DIR, lastof(tmp));
AppendPathSeparator(tmp, lastof(tmp));
_searchpaths[SP_SHARED_DIR] = stredup(tmp);
} else {
- _searchpaths[SP_SHARED_DIR] = NULL;
+ _searchpaths[SP_SHARED_DIR] = nullptr;
}
#else
- _searchpaths[SP_PERSONAL_DIR] = NULL;
- _searchpaths[SP_SHARED_DIR] = NULL;
+ _searchpaths[SP_PERSONAL_DIR] = nullptr;
+ _searchpaths[SP_SHARED_DIR] = nullptr;
#endif
/* Get the path to working directory of OpenTTD */
@@ -488,15 +488,15 @@ void DetermineBasePaths(const char *exe)
AppendPathSeparator(tmp, lastof(tmp));
_searchpaths[SP_WORKING_DIR] = stredup(tmp);
- if (!GetModuleFileName(NULL, path, lengthof(path))) {
+ if (!GetModuleFileName(nullptr, path, lengthof(path))) {
DEBUG(misc, 0, "GetModuleFileName failed (%lu)\n", GetLastError());
- _searchpaths[SP_BINARY_DIR] = NULL;
+ _searchpaths[SP_BINARY_DIR] = nullptr;
} else {
TCHAR exec_dir[MAX_PATH];
_tcsncpy(path, convert_to_fs(exe, path, lengthof(path)), lengthof(path));
- if (!GetFullPathName(path, lengthof(exec_dir), exec_dir, NULL)) {
+ if (!GetFullPathName(path, lengthof(exec_dir), exec_dir, nullptr)) {
DEBUG(misc, 0, "GetFullPathName failed (%lu)\n", GetLastError());
- _searchpaths[SP_BINARY_DIR] = NULL;
+ _searchpaths[SP_BINARY_DIR] = nullptr;
} else {
strecpy(tmp, convert_from_fs(exec_dir, tmp, lengthof(tmp)), lastof(tmp));
char *s = strrchr(tmp, PATHSEPCHAR);
@@ -505,8 +505,8 @@ void DetermineBasePaths(const char *exe)
}
}
- _searchpaths[SP_INSTALLATION_DIR] = NULL;
- _searchpaths[SP_APPLICATION_BUNDLE_DIR] = NULL;
+ _searchpaths[SP_INSTALLATION_DIR] = nullptr;
+ _searchpaths[SP_APPLICATION_BUNDLE_DIR] = nullptr;
}
@@ -516,18 +516,18 @@ bool GetClipboardContents(char *buffer, const char *last)
const char *ptr;
if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
- OpenClipboard(NULL);
+ OpenClipboard(nullptr);
cbuf = GetClipboardData(CF_UNICODETEXT);
ptr = (const char*)GlobalLock(cbuf);
- int out_len = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)ptr, -1, buffer, (last - buffer) + 1, NULL, NULL);
+ int out_len = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)ptr, -1, buffer, (last - buffer) + 1, nullptr, nullptr);
GlobalUnlock(cbuf);
CloseClipboard();
if (out_len == 0) return false;
#if !defined(UNICODE)
} else if (IsClipboardFormatAvailable(CF_TEXT)) {
- OpenClipboard(NULL);
+ OpenClipboard(nullptr);
cbuf = GetClipboardData(CF_TEXT);
ptr = (const char*)GlobalLock(cbuf);
@@ -596,7 +596,7 @@ char *convert_from_fs(const TCHAR *name, char *utf8_buf, size_t buflen)
const WCHAR *wide_buf = name;
#else
/* Convert string from the local codepage to UTF-16. */
- int wide_len = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);
+ int wide_len = MultiByteToWideChar(CP_ACP, 0, name, -1, nullptr, 0);
if (wide_len == 0) {
utf8_buf[0] = '\0';
return utf8_buf;
@@ -607,7 +607,7 @@ char *convert_from_fs(const TCHAR *name, char *utf8_buf, size_t buflen)
#endif
/* Convert UTF-16 string to UTF-8. */
- int len = WideCharToMultiByte(CP_UTF8, 0, wide_buf, -1, utf8_buf, (int)buflen, NULL, NULL);
+ int len = WideCharToMultiByte(CP_UTF8, 0, wide_buf, -1, utf8_buf, (int)buflen, nullptr, nullptr);
if (len == 0) utf8_buf[0] = '\0';
return utf8_buf;
@@ -630,7 +630,7 @@ TCHAR *convert_to_fs(const char *name, TCHAR *system_buf, size_t buflen, bool co
int len = MultiByteToWideChar(CP_UTF8, 0, name, -1, system_buf, (int)buflen);
if (len == 0) system_buf[0] = '\0';
#else
- int len = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0);
+ int len = MultiByteToWideChar(CP_UTF8, 0, name, -1, nullptr, 0);
if (len == 0) {
system_buf[0] = '\0';
return system_buf;
@@ -639,7 +639,7 @@ TCHAR *convert_to_fs(const char *name, TCHAR *system_buf, size_t buflen, bool co
WCHAR *wide_buf = AllocaM(WCHAR, len);
MultiByteToWideChar(CP_UTF8, 0, name, -1, wide_buf, len);
- len = WideCharToMultiByte(console_cp ? CP_OEMCP : CP_ACP, 0, wide_buf, len, system_buf, (int)buflen, NULL, NULL);
+ len = WideCharToMultiByte(console_cp ? CP_OEMCP : CP_ACP, 0, wide_buf, len, system_buf, (int)buflen, nullptr, nullptr);
if (len == 0) system_buf[0] = '\0';
#endif
@@ -654,7 +654,7 @@ TCHAR *convert_to_fs(const char *name, TCHAR *system_buf, size_t buflen, bool co
*/
HRESULT OTTDSHGetFolderPath(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPTSTR pszPath)
{
- static HRESULT (WINAPI *SHGetFolderPath)(HWND, int, HANDLE, DWORD, LPTSTR) = NULL;
+ static HRESULT (WINAPI *SHGetFolderPath)(HWND, int, HANDLE, DWORD, LPTSTR) = nullptr;
static bool first_time = true;
/* We only try to load the library one time; if it fails, it fails */
@@ -674,7 +674,7 @@ HRESULT OTTDSHGetFolderPath(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags,
first_time = false;
}
- if (SHGetFolderPath != NULL) return SHGetFolderPath(hwnd, csidl, hToken, dwFlags, pszPath);
+ if (SHGetFolderPath != nullptr) return SHGetFolderPath(hwnd, csidl, hToken, dwFlags, pszPath);
/* SHGetFolderPath doesn't exist, try a more conservative approach,
* eg environment variables. This is only included for legacy modes
@@ -698,7 +698,7 @@ HRESULT OTTDSHGetFolderPath(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags,
HKEY key;
if (RegOpenKeyEx(csidl == CSIDL_PERSONAL ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, REGSTR_PATH_SPECIAL_FOLDERS, 0, KEY_READ, &key) != ERROR_SUCCESS) break;
DWORD len = MAX_PATH;
- ret = RegQueryValueEx(key, csidl == CSIDL_PERSONAL ? _T("Personal") : _T("Common Documents"), NULL, NULL, (LPBYTE)pszPath, &len);
+ ret = RegQueryValueEx(key, csidl == CSIDL_PERSONAL ? _T("Personal") : _T("Common Documents"), nullptr, nullptr, (LPBYTE)pszPath, &len);
RegCloseKey(key);
if (ret == ERROR_SUCCESS) return (HRESULT)0;
break;
@@ -718,7 +718,7 @@ const char *GetCurrentLocale(const char *)
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lang, lengthof(lang)) == 0 ||
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, country, lengthof(country)) == 0) {
/* Unable to retrieve the locale. */
- return NULL;
+ return nullptr;
}
/* Format it as 'en_us'. */
static char retbuf[6] = {lang[0], lang[1], '_', country[0], country[1], 0};
@@ -750,7 +750,7 @@ void Win32SetCurrentLocaleName(const char *iso_code)
int OTTDStringCompare(const char *s1, const char *s2)
{
typedef int (WINAPI *PFNCOMPARESTRINGEX)(LPCWSTR, DWORD, LPCWCH, int, LPCWCH, int, LPVOID, LPVOID, LPARAM);
- static PFNCOMPARESTRINGEX _CompareStringEx = NULL;
+ static PFNCOMPARESTRINGEX _CompareStringEx = nullptr;
static bool first_time = true;
#ifndef SORT_DIGITSASNUMBERS
@@ -765,10 +765,10 @@ int OTTDStringCompare(const char *s1, const char *s2)
first_time = false;
}
- if (_CompareStringEx != NULL) {
+ if (_CompareStringEx != nullptr) {
/* CompareStringEx takes UTF-16 strings, even in ANSI-builds. */
- int len_s1 = MultiByteToWideChar(CP_UTF8, 0, s1, -1, NULL, 0);
- int len_s2 = MultiByteToWideChar(CP_UTF8, 0, s2, -1, NULL, 0);
+ int len_s1 = MultiByteToWideChar(CP_UTF8, 0, s1, -1, nullptr, 0);
+ int len_s2 = MultiByteToWideChar(CP_UTF8, 0, s2, -1, nullptr, 0);
if (len_s1 != 0 && len_s2 != 0) {
LPWSTR str_s1 = AllocaM(WCHAR, len_s1);
@@ -777,7 +777,7 @@ int OTTDStringCompare(const char *s1, const char *s2)
MultiByteToWideChar(CP_UTF8, 0, s1, -1, str_s1, len_s1);
MultiByteToWideChar(CP_UTF8, 0, s2, -1, str_s2, len_s2);
- int result = _CompareStringEx(_cur_iso_locale, LINGUISTIC_IGNORECASE | SORT_DIGITSASNUMBERS, str_s1, -1, str_s2, -1, NULL, NULL, 0);
+ int result = _CompareStringEx(_cur_iso_locale, LINGUISTIC_IGNORECASE | SORT_DIGITSASNUMBERS, str_s1, -1, str_s2, -1, nullptr, nullptr, 0);
if (result != 0) return result;
}
}