(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().

This commit is contained in:
glx
2008-06-05 20:54:52 +00:00
parent 5176319dd5
commit ee256e770a
19 changed files with 67 additions and 46 deletions

View File

@@ -107,10 +107,10 @@ static void CreateWindowsConsoleThread()
/* Create event to signal when console input is ready */
_hInputReady = CreateEvent(NULL, false, false, NULL);
_hWaitForInputHandling = CreateEvent(NULL, false, false, NULL);
if (_hInputReady == NULL || _hWaitForInputHandling == NULL) error("Cannot create console event!");
if (_hInputReady == NULL || _hWaitForInputHandling == NULL) usererror("Cannot create console event!");
_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CheckForConsoleInput, NULL, 0, &dwThreadId);
if (_hThread == NULL) error("Cannot create console thread!");
if (_hThread == NULL) usererror("Cannot create console thread!");
DEBUG(driver, 2, "Windows console thread started");
}

View File

@@ -118,7 +118,7 @@ static void GetVideoModes()
modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0));
if (modes == NULL)
error("sdl: no modes available");
usererror("sdl: no modes available");
_all_modes = (modes == (void*)-1);
@@ -198,7 +198,7 @@ static bool CreateMainSurface(int w, int h)
DEBUG(driver, 1, "SDL: using mode %dx%dx%d", w, h, bpp);
if (bpp == 0) error("Can't use a blitter that blits 0 bpp for normal visuals");
if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");
/* Give the application an icon */
icon = SDL_CALL SDL_LoadBMP(ICON_DIR PATHSEP "openttd.32.bmp");

View File

@@ -59,7 +59,7 @@ static void MakePalette()
}
_wnd.gdi_palette = CreatePalette(pal);
if (_wnd.gdi_palette == NULL) error("CreatePalette failed!\n");
if (_wnd.gdi_palette == NULL) usererror("CreatePalette failed!\n");
}
static void UpdatePalette(HDC dc, uint start, uint count)
@@ -292,7 +292,7 @@ static bool MakeWindow(bool full_screen)
_sntprintf(Windowtitle, sizeof(Windowtitle), _T("OpenTTD %s"), MB_TO_WIDE(_openttd_revision));
_wnd.main_wnd = CreateWindow(_T("OTTD"), Windowtitle, style, x, y, w, h, 0, 0, GetModuleHandle(NULL), 0);
if (_wnd.main_wnd == NULL) error("CreateWindow failed");
if (_wnd.main_wnd == NULL) usererror("CreateWindow failed");
ShowWindow(_wnd.main_wnd, showstyle);
}
}
@@ -671,7 +671,7 @@ static void RegisterWndClass()
};
registered = true;
if (!RegisterClass(&wnd)) error("RegisterClass failed");
if (!RegisterClass(&wnd)) usererror("RegisterClass failed");
}
}
@@ -684,7 +684,7 @@ static bool AllocateDibSection(int w, int h)
w = max(w, 64);
h = max(h, 64);
if (bpp == 0) error("Can't use a blitter that blits 0 bpp for normal visuals");
if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals");
if (w == _screen.width && h == _screen.height)
return false;
@@ -707,7 +707,7 @@ static bool AllocateDibSection(int w, int h)
dc = GetDC(0);
_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (VOID**)&_wnd.buffer_bits, NULL, 0);
if (_wnd.dib_sect == NULL) error("CreateDIBSection failed");
if (_wnd.dib_sect == NULL) usererror("CreateDIBSection failed");
ReleaseDC(0, dc);
return true;