Merge: Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
#endif
|
||||
|
||||
typedef BOOL (WINAPI *PFNTRACKMOUSEEVENT)(LPTRACKMOUSEEVENT lpEventTrack);
|
||||
static PFNTRACKMOUSEEVENT _pTrackMouseEvent = NULL;
|
||||
static PFNTRACKMOUSEEVENT _pTrackMouseEvent = nullptr;
|
||||
|
||||
static struct {
|
||||
HWND main_wnd;
|
||||
@@ -72,9 +72,9 @@ DWORD _imm_props;
|
||||
/** Whether the drawing is/may be done in a separate thread. */
|
||||
static bool _draw_threaded;
|
||||
/** Mutex to keep the access to the shared memory controlled. */
|
||||
static std::recursive_mutex *_draw_mutex = NULL;
|
||||
static std::recursive_mutex *_draw_mutex = nullptr;
|
||||
/** Signal to draw the next frame. */
|
||||
static std::condition_variable_any *_draw_signal = NULL;
|
||||
static std::condition_variable_any *_draw_signal = nullptr;
|
||||
/** Should we keep continue drawing? */
|
||||
static volatile bool _draw_continue;
|
||||
/** Local copy of the palette for use in the drawing thread. */
|
||||
@@ -95,7 +95,7 @@ static void MakePalette()
|
||||
|
||||
}
|
||||
_wnd.gdi_palette = CreatePalette(pal);
|
||||
if (_wnd.gdi_palette == NULL) usererror("CreatePalette failed!\n");
|
||||
if (_wnd.gdi_palette == nullptr) usererror("CreatePalette failed!\n");
|
||||
|
||||
_cur_palette.first_dirty = 0;
|
||||
_cur_palette.count_dirty = 256;
|
||||
@@ -313,7 +313,7 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen)
|
||||
}
|
||||
} else if (_wnd.fullscreen) {
|
||||
/* restore display? */
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
ChangeDisplaySettings(nullptr, 0);
|
||||
/* restore the resolution */
|
||||
_wnd.width = _bck_resolution.width;
|
||||
_wnd.height = _bck_resolution.height;
|
||||
@@ -340,7 +340,7 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen)
|
||||
w = r.right - r.left;
|
||||
h = r.bottom - r.top;
|
||||
|
||||
if (_wnd.main_wnd != NULL) {
|
||||
if (_wnd.main_wnd != nullptr) {
|
||||
if (!_window_maximize) SetWindowPos(_wnd.main_wnd, 0, 0, 0, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
|
||||
} else {
|
||||
int x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
|
||||
@@ -349,8 +349,8 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen)
|
||||
char window_title[64];
|
||||
seprintf(window_title, lastof(window_title), "OpenTTD %s", _openttd_revision);
|
||||
|
||||
_wnd.main_wnd = CreateWindow(_T("OTTD"), MB_TO_WIDE(window_title), style, x, y, w, h, 0, 0, GetModuleHandle(NULL), 0);
|
||||
if (_wnd.main_wnd == NULL) usererror("CreateWindow failed");
|
||||
_wnd.main_wnd = CreateWindow(_T("OTTD"), MB_TO_WIDE(window_title), style, x, y, w, h, 0, 0, GetModuleHandle(nullptr), 0);
|
||||
if (_wnd.main_wnd == nullptr) usererror("CreateWindow failed");
|
||||
ShowWindow(_wnd.main_wnd, showstyle);
|
||||
}
|
||||
}
|
||||
@@ -503,7 +503,7 @@ static bool DrawIMECompositionString()
|
||||
static void SetCompositionPos(HWND hwnd)
|
||||
{
|
||||
HIMC hIMC = ImmGetContext(hwnd);
|
||||
if (hIMC != NULL) {
|
||||
if (hIMC != nullptr) {
|
||||
COMPOSITIONFORM cf;
|
||||
cf.dwStyle = CFS_POINT;
|
||||
|
||||
@@ -525,7 +525,7 @@ static void SetCompositionPos(HWND hwnd)
|
||||
static void SetCandidatePos(HWND hwnd)
|
||||
{
|
||||
HIMC hIMC = ImmGetContext(hwnd);
|
||||
if (hIMC != NULL) {
|
||||
if (hIMC != nullptr) {
|
||||
CANDIDATEFORM cf;
|
||||
cf.dwIndex = 0;
|
||||
cf.dwStyle = CFS_EXCLUDE;
|
||||
@@ -560,17 +560,17 @@ static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HIMC hIMC = ImmGetContext(hwnd);
|
||||
|
||||
if (hIMC != NULL) {
|
||||
if (hIMC != nullptr) {
|
||||
if (lParam & GCS_RESULTSTR) {
|
||||
/* Read result string from the IME. */
|
||||
LONG len = ImmGetCompositionString(hIMC, GCS_RESULTSTR, NULL, 0); // Length is always in bytes, even in UNICODE build.
|
||||
LONG len = ImmGetCompositionString(hIMC, GCS_RESULTSTR, nullptr, 0); // Length is always in bytes, even in UNICODE build.
|
||||
TCHAR *str = (TCHAR *)_alloca(len + sizeof(TCHAR));
|
||||
len = ImmGetCompositionString(hIMC, GCS_RESULTSTR, str, len);
|
||||
str[len / sizeof(TCHAR)] = '\0';
|
||||
|
||||
/* Transmit text to windowing system. */
|
||||
if (len > 0) {
|
||||
HandleTextInput(NULL, true); // Clear marked string.
|
||||
HandleTextInput(nullptr, true); // Clear marked string.
|
||||
HandleTextInput(FS2OTTD(str));
|
||||
}
|
||||
SetCompositionPos(hwnd);
|
||||
@@ -581,7 +581,7 @@ static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if ((lParam & GCS_COMPSTR) && DrawIMECompositionString()) {
|
||||
/* Read composition string from the IME. */
|
||||
LONG len = ImmGetCompositionString(hIMC, GCS_COMPSTR, NULL, 0); // Length is always in bytes, even in UNICODE build.
|
||||
LONG len = ImmGetCompositionString(hIMC, GCS_COMPSTR, nullptr, 0); // Length is always in bytes, even in UNICODE build.
|
||||
TCHAR *str = (TCHAR *)_alloca(len + sizeof(TCHAR));
|
||||
len = ImmGetCompositionString(hIMC, GCS_COMPSTR, str, len);
|
||||
str[len / sizeof(TCHAR)] = '\0';
|
||||
@@ -591,7 +591,7 @@ static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
convert_from_fs(str, utf8_buf, lengthof(utf8_buf));
|
||||
|
||||
/* Convert caret position from bytes in the input string to a position in the UTF-8 encoded string. */
|
||||
LONG caret_bytes = ImmGetCompositionString(hIMC, GCS_CURSORPOS, NULL, 0);
|
||||
LONG caret_bytes = ImmGetCompositionString(hIMC, GCS_CURSORPOS, nullptr, 0);
|
||||
const char *caret = utf8_buf;
|
||||
for (const TCHAR *c = str; *c != '\0' && *caret != '\0' && caret_bytes > 0; c++, caret_bytes--) {
|
||||
/* Skip DBCS lead bytes or leading surrogates. */
|
||||
@@ -608,7 +608,7 @@ static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
HandleTextInput(utf8_buf, true, caret);
|
||||
} else {
|
||||
HandleTextInput(NULL, true);
|
||||
HandleTextInput(nullptr, true);
|
||||
}
|
||||
|
||||
lParam &= ~(GCS_COMPSTR | GCS_COMPATTR | GCS_COMPCLAUSE | GCS_CURSORPOS | GCS_DELTASTART);
|
||||
@@ -623,10 +623,10 @@ static LRESULT HandleIMEComposition(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
static void CancelIMEComposition(HWND hwnd)
|
||||
{
|
||||
HIMC hIMC = ImmGetContext(hwnd);
|
||||
if (hIMC != NULL) ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
|
||||
if (hIMC != nullptr) ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
|
||||
ImmReleaseContext(hwnd, hIMC);
|
||||
/* Clear any marked string from the current edit box. */
|
||||
HandleTextInput(NULL, true);
|
||||
HandleTextInput(nullptr, true);
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
@@ -651,14 +651,14 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
if (!in_sizemove && _draw_mutex != NULL && !HasModalProgress()) {
|
||||
if (!in_sizemove && _draw_mutex != nullptr && !HasModalProgress()) {
|
||||
/* Get the union of the old update rect and the new update rect. */
|
||||
RECT r;
|
||||
GetUpdateRect(hwnd, &r, FALSE);
|
||||
UnionRect(&_wnd.update_rect, &_wnd.update_rect, &r);
|
||||
|
||||
/* Mark the window as updated, otherwise Windows would send more WM_PAINT messages. */
|
||||
ValidateRect(hwnd, NULL);
|
||||
ValidateRect(hwnd, nullptr);
|
||||
_draw_signal->notify_one();
|
||||
} else {
|
||||
PAINTSTRUCT ps;
|
||||
@@ -680,7 +680,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||
|
||||
SelectPalette(hDC, hOldPalette, TRUE);
|
||||
ReleaseDC(hwnd, hDC);
|
||||
if (nChanged != 0) InvalidateRect(hwnd, NULL, FALSE);
|
||||
if (nChanged != 0) InvalidateRect(hwnd, nullptr, FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||
* tracking the mouse for exiting the window */
|
||||
if (!_cursor.in_window) {
|
||||
_cursor.in_window = true;
|
||||
if (_pTrackMouseEvent != NULL) {
|
||||
if (_pTrackMouseEvent != nullptr) {
|
||||
TRACKMOUSEEVENT tme;
|
||||
tme.cbSize = sizeof(tme);
|
||||
tme.dwFlags = TME_LEAVE;
|
||||
@@ -787,7 +787,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||
|
||||
case WM_IME_ENDCOMPOSITION:
|
||||
/* Clear any pending composition string. */
|
||||
HandleTextInput(NULL, true);
|
||||
HandleTextInput(nullptr, true);
|
||||
if (DrawIMECompositionString()) return 0;
|
||||
break;
|
||||
|
||||
@@ -835,7 +835,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||
|
||||
/* Silently drop all messages handled by WM_CHAR. */
|
||||
MSG msg;
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
|
||||
if (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) {
|
||||
if ((msg.message == WM_CHAR || msg.message == WM_DEADCHAR) && GB(lParam, 16, 8) == GB(msg.lParam, 16, 8)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -997,7 +997,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||
} else if (!active && !minimized) {
|
||||
/* Minimise the window and restore desktop */
|
||||
ShowWindow(hwnd, SW_MINIMIZE);
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
ChangeDisplaySettings(nullptr, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1012,7 +1012,7 @@ static void RegisterWndClass()
|
||||
static bool registered = false;
|
||||
|
||||
if (!registered) {
|
||||
HINSTANCE hinst = GetModuleHandle(NULL);
|
||||
HINSTANCE hinst = GetModuleHandle(nullptr);
|
||||
WNDCLASS wnd = {
|
||||
CS_OWNDC,
|
||||
WndProcGdi,
|
||||
@@ -1020,7 +1020,7 @@ static void RegisterWndClass()
|
||||
0,
|
||||
hinst,
|
||||
LoadIcon(hinst, MAKEINTRESOURCE(100)),
|
||||
LoadCursor(NULL, IDC_ARROW),
|
||||
LoadCursor(nullptr, IDC_ARROW),
|
||||
0,
|
||||
0,
|
||||
_T("OTTD")
|
||||
@@ -1061,8 +1061,8 @@ static bool AllocateDibSection(int w, int h, bool force)
|
||||
if (_wnd.dib_sect) DeleteObject(_wnd.dib_sect);
|
||||
|
||||
dc = GetDC(0);
|
||||
_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (VOID**)&_wnd.buffer_bits, NULL, 0);
|
||||
if (_wnd.dib_sect == NULL) usererror("CreateDIBSection failed");
|
||||
_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (VOID**)&_wnd.buffer_bits, nullptr, 0);
|
||||
if (_wnd.dib_sect == nullptr) usererror("CreateDIBSection failed");
|
||||
ReleaseDC(0, dc);
|
||||
|
||||
_screen.width = w;
|
||||
@@ -1099,7 +1099,7 @@ static void FindResolutions()
|
||||
/* XXX - EnumDisplaySettingsW crashes with unicows.dll on Windows95
|
||||
* Doesn't really matter since we don't pass a string anyways, but still
|
||||
* a letdown */
|
||||
for (i = 0; EnumDisplaySettingsA(NULL, i, &dm) != 0; i++) {
|
||||
for (i = 0; EnumDisplaySettingsA(nullptr, i, &dm) != 0; i++) {
|
||||
if (dm.dmBitsPerPel == bpp &&
|
||||
dm.dmPelsWidth >= 640 && dm.dmPelsHeight >= 480) {
|
||||
uint j;
|
||||
@@ -1153,9 +1153,9 @@ const char *VideoDriver_Win32::Start(const char * const *parm)
|
||||
|
||||
MarkWholeScreenDirty();
|
||||
|
||||
_draw_threaded = GetDriverParam(parm, "no_threads") == NULL && GetDriverParam(parm, "no_thread") == NULL && std::thread::hardware_concurrency() > 1;
|
||||
_draw_threaded = GetDriverParam(parm, "no_threads") == nullptr && GetDriverParam(parm, "no_thread") == nullptr && std::thread::hardware_concurrency() > 1;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void VideoDriver_Win32::Stop()
|
||||
@@ -1164,7 +1164,7 @@ void VideoDriver_Win32::Stop()
|
||||
DeleteObject(_wnd.dib_sect);
|
||||
DestroyWindow(_wnd.main_wnd);
|
||||
|
||||
if (_wnd.fullscreen) ChangeDisplaySettings(NULL, 0);
|
||||
if (_wnd.fullscreen) ChangeDisplaySettings(nullptr, 0);
|
||||
MyShowCursor(true);
|
||||
}
|
||||
|
||||
@@ -1180,7 +1180,7 @@ static void CheckPaletteAnim()
|
||||
if (_cur_palette.count_dirty == 0) return;
|
||||
|
||||
_local_palette = _cur_palette;
|
||||
InvalidateRect(_wnd.main_wnd, NULL, FALSE);
|
||||
InvalidateRect(_wnd.main_wnd, nullptr, FALSE);
|
||||
}
|
||||
|
||||
void VideoDriver_Win32::MainLoop()
|
||||
@@ -1215,8 +1215,8 @@ void VideoDriver_Win32::MainLoop()
|
||||
draw_lock.release();
|
||||
delete _draw_mutex;
|
||||
delete _draw_signal;
|
||||
_draw_mutex = NULL;
|
||||
_draw_signal = NULL;
|
||||
_draw_mutex = nullptr;
|
||||
_draw_signal = nullptr;
|
||||
} else {
|
||||
DEBUG(driver, 1, "Threaded drawing enabled");
|
||||
/* Wait till the draw thread has started itself. */
|
||||
@@ -1231,7 +1231,7 @@ void VideoDriver_Win32::MainLoop()
|
||||
for (;;) {
|
||||
uint32 prev_cur_ticks = cur_ticks; // to check for wrapping
|
||||
|
||||
while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) {
|
||||
while (PeekMessage(&mesg, nullptr, 0, 0, PM_REMOVE)) {
|
||||
InteractiveRandom(); // randomness
|
||||
/* Convert key messages to char messages if we want text input. */
|
||||
if (EditBoxInGlobalFocus()) TranslateMessage(&mesg);
|
||||
@@ -1314,14 +1314,14 @@ void VideoDriver_Win32::MainLoop()
|
||||
delete _draw_mutex;
|
||||
delete _draw_signal;
|
||||
|
||||
_draw_mutex = NULL;
|
||||
_draw_mutex = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoDriver_Win32::ChangeResolution(int w, int h)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock;
|
||||
if (_draw_mutex != NULL) lock = std::unique_lock<std::recursive_mutex>(*_draw_mutex);
|
||||
if (_draw_mutex != nullptr) lock = std::unique_lock<std::recursive_mutex>(*_draw_mutex);
|
||||
|
||||
if (_window_maximize) ShowWindow(_wnd.main_wnd, SW_SHOWNORMAL);
|
||||
|
||||
@@ -1334,7 +1334,7 @@ bool VideoDriver_Win32::ChangeResolution(int w, int h)
|
||||
bool VideoDriver_Win32::ToggleFullscreen(bool full_screen)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock;
|
||||
if (_draw_mutex != NULL) lock = std::unique_lock<std::recursive_mutex>(*_draw_mutex);
|
||||
if (_draw_mutex != nullptr) lock = std::unique_lock<std::recursive_mutex>(*_draw_mutex);
|
||||
|
||||
return this->MakeWindow(full_screen);
|
||||
}
|
||||
@@ -1346,18 +1346,18 @@ bool VideoDriver_Win32::AfterBlitterChange()
|
||||
|
||||
void VideoDriver_Win32::AcquireBlitterLock()
|
||||
{
|
||||
if (_draw_mutex != NULL) _draw_mutex->lock();
|
||||
if (_draw_mutex != nullptr) _draw_mutex->lock();
|
||||
}
|
||||
|
||||
void VideoDriver_Win32::ReleaseBlitterLock()
|
||||
{
|
||||
if (_draw_mutex != NULL) _draw_mutex->unlock();
|
||||
if (_draw_mutex != nullptr) _draw_mutex->unlock();
|
||||
}
|
||||
|
||||
void VideoDriver_Win32::EditBoxLostFocus()
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock;
|
||||
if (_draw_mutex != NULL) lock = std::unique_lock<std::recursive_mutex>(*_draw_mutex);
|
||||
if (_draw_mutex != nullptr) lock = std::unique_lock<std::recursive_mutex>(*_draw_mutex);
|
||||
|
||||
CancelIMEComposition(_wnd.main_wnd);
|
||||
SetCompositionPos(_wnd.main_wnd);
|
||||
|
||||
Reference in New Issue
Block a user