mirror of https://github.com/OpenTTD/OpenTTD
(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().
parent
5176319dd5
commit
ee256e770a
|
@ -87,7 +87,7 @@ const Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type typ
|
||||||
delete newd;
|
delete newd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error("Couldn't find any suitable %s driver", GetDriverTypeName(type));
|
usererror("Couldn't find any suitable %s driver", GetDriverTypeName(type));
|
||||||
} else {
|
} else {
|
||||||
char *parm;
|
char *parm;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
@ -125,7 +125,7 @@ const Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type typ
|
||||||
const char *err = newd->Start(parms);
|
const char *err = newd->Start(parms);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
delete newd;
|
delete newd;
|
||||||
error("Unable to load driver '%s'. The error was: %s", d->name, err);
|
usererror("Unable to load driver '%s'. The error was: %s", d->name, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(driver, 1, "Successfully loaded %s driver '%s'", GetDriverTypeName(type), d->name);
|
DEBUG(driver, 1, "Successfully loaded %s driver '%s'", GetDriverTypeName(type), d->name);
|
||||||
|
@ -133,7 +133,7 @@ const Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type typ
|
||||||
*GetActiveDriver(type) = newd;
|
*GetActiveDriver(type) = newd;
|
||||||
return newd;
|
return newd;
|
||||||
}
|
}
|
||||||
error("No such %s driver: %s\n", GetDriverTypeName(type), buffer);
|
usererror("No such %s driver: %s\n", GetDriverTypeName(type), buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ void FioOpenFile(int slot, const char *filename)
|
||||||
FioFreeHandle();
|
FioFreeHandle();
|
||||||
#endif /* LIMITED_FDS */
|
#endif /* LIMITED_FDS */
|
||||||
f = FioFOpenFile(filename);
|
f = FioFOpenFile(filename);
|
||||||
if (f == NULL) error("Cannot open file '%s'", filename);
|
if (f == NULL) usererror("Cannot open file '%s'", filename);
|
||||||
uint32 pos = ftell(f);
|
uint32 pos = ftell(f);
|
||||||
|
|
||||||
FioCloseFile(slot); // if file was opened before, close it
|
FioCloseFile(slot); // if file was opened before, close it
|
||||||
|
|
|
@ -55,7 +55,7 @@ static uint LoadGrfFile(const char *filename, uint load_index, int file_index)
|
||||||
load_index++;
|
load_index++;
|
||||||
sprite_id++;
|
sprite_id++;
|
||||||
if (load_index >= MAX_SPRITES) {
|
if (load_index >= MAX_SPRITES) {
|
||||||
error("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files.");
|
usererror("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index);
|
DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index);
|
||||||
|
|
|
@ -323,12 +323,12 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
|
||||||
Packet *p;
|
Packet *p;
|
||||||
|
|
||||||
// Make a dump of the current game
|
// Make a dump of the current game
|
||||||
if (SaveOrLoad(filename, SL_SAVE, AUTOSAVE_DIR) != SL_OK) error("network savedump failed");
|
if (SaveOrLoad(filename, SL_SAVE, AUTOSAVE_DIR) != SL_OK) usererror("network savedump failed");
|
||||||
|
|
||||||
file_pointer = FioFOpenFile(filename, "rb", AUTOSAVE_DIR);
|
file_pointer = FioFOpenFile(filename, "rb", AUTOSAVE_DIR);
|
||||||
fseek(file_pointer, 0, SEEK_END);
|
fseek(file_pointer, 0, SEEK_END);
|
||||||
|
|
||||||
if (ftell(file_pointer) == 0) error("network savedump failed - zero sized savegame?");
|
if (ftell(file_pointer) == 0) usererror("network savedump failed - zero sized savegame?");
|
||||||
|
|
||||||
// Now send the _frame_counter and how many packets are coming
|
// Now send the _frame_counter and how many packets are coming
|
||||||
p = NetworkSend_Init(PACKET_SERVER_MAP);
|
p = NetworkSend_Init(PACKET_SERVER_MAP);
|
||||||
|
@ -355,7 +355,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
|
||||||
p->Send_uint8(MAP_PACKET_NORMAL);
|
p->Send_uint8(MAP_PACKET_NORMAL);
|
||||||
res = (int)fread(p->buffer + p->size, 1, SEND_MTU - p->size, file_pointer);
|
res = (int)fread(p->buffer + p->size, 1, SEND_MTU - p->size, file_pointer);
|
||||||
|
|
||||||
if (ferror(file_pointer)) error("Error reading temporary network savegame!");
|
if (ferror(file_pointer)) usererror("Error reading temporary network savegame!");
|
||||||
|
|
||||||
p->size += res;
|
p->size += res;
|
||||||
cs->Send_Packet(p);
|
cs->Send_Packet(p);
|
||||||
|
|
|
@ -5783,7 +5783,7 @@ void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage)
|
||||||
* processed once at initialization. */
|
* processed once at initialization. */
|
||||||
if (stage != GLS_FILESCAN && stage != GLS_SAFETYSCAN && stage != GLS_LABELSCAN) {
|
if (stage != GLS_FILESCAN && stage != GLS_SAFETYSCAN && stage != GLS_LABELSCAN) {
|
||||||
_cur_grffile = GetFileByFilename(filename);
|
_cur_grffile = GetFileByFilename(filename);
|
||||||
if (_cur_grffile == NULL) error("File '%s' lost in cache.\n", filename);
|
if (_cur_grffile == NULL) usererror("File '%s' lost in cache.\n", filename);
|
||||||
if (stage == GLS_RESERVE && config->status != GCS_INITIALISED) return;
|
if (stage == GLS_RESERVE && config->status != GCS_INITIALISED) return;
|
||||||
if (stage == GLS_ACTIVATION && !HasBit(config->flags, GCF_RESERVED)) return;
|
if (stage == GLS_ACTIVATION && !HasBit(config->flags, GCF_RESERVED)) return;
|
||||||
_cur_grffile->is_ottdfile = config->IsOpenTTDBaseGRF();
|
_cur_grffile->is_ottdfile = config->IsOpenTTDBaseGRF();
|
||||||
|
@ -5989,7 +5989,7 @@ void LoadNewGRF(uint load_index, uint file_index)
|
||||||
if (stage > GLS_INIT && HasBit(c->flags, GCF_INIT_ONLY)) continue;
|
if (stage > GLS_INIT && HasBit(c->flags, GCF_INIT_ONLY)) continue;
|
||||||
|
|
||||||
/* @todo usererror() */
|
/* @todo usererror() */
|
||||||
if (!FioCheckFileExists(c->filename)) error("NewGRF file is missing '%s'", c->filename);
|
if (!FioCheckFileExists(c->filename)) usererror("NewGRF file is missing '%s'", c->filename);
|
||||||
|
|
||||||
if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid);
|
if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid);
|
||||||
LoadNewGRFFile(c, slot++, stage);
|
LoadNewGRFFile(c, slot++, stage);
|
||||||
|
|
|
@ -99,11 +99,31 @@ void CallWindowTickEvent();
|
||||||
|
|
||||||
extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
|
extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
|
||||||
extern Player* DoStartupNewPlayer(bool is_ai);
|
extern Player* DoStartupNewPlayer(bool is_ai);
|
||||||
extern void ShowOSErrorBox(const char *buf);
|
extern void ShowOSErrorBox(const char *buf, bool system);
|
||||||
extern void InitializeRailGUI();
|
extern void InitializeRailGUI();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error handling for fatal errors.
|
* Error handling for fatal user errors.
|
||||||
|
* @param s the string to print.
|
||||||
|
* @note Does NEVER return.
|
||||||
|
*/
|
||||||
|
void CDECL usererror(const char *s, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
char buf[512];
|
||||||
|
|
||||||
|
va_start(va, s);
|
||||||
|
vsnprintf(buf, lengthof(buf), s, va);
|
||||||
|
va_end(va);
|
||||||
|
|
||||||
|
ShowOSErrorBox(buf, false);
|
||||||
|
if (_video_driver != NULL) _video_driver->Stop();
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error handling for fatal non-user errors.
|
||||||
* @param s the string to print.
|
* @param s the string to print.
|
||||||
* @note Does NEVER return.
|
* @note Does NEVER return.
|
||||||
*/
|
*/
|
||||||
|
@ -116,7 +136,7 @@ void CDECL error(const char *s, ...)
|
||||||
vsnprintf(buf, lengthof(buf), s, va);
|
vsnprintf(buf, lengthof(buf), s, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
ShowOSErrorBox(buf);
|
ShowOSErrorBox(buf, true);
|
||||||
if (_video_driver != NULL) _video_driver->Stop();
|
if (_video_driver != NULL) _video_driver->Stop();
|
||||||
|
|
||||||
assert(0);
|
assert(0);
|
||||||
|
@ -524,30 +544,30 @@ int ttd_main(int argc, char *argv[])
|
||||||
DEBUG(misc, 1, "Loading blitter...");
|
DEBUG(misc, 1, "Loading blitter...");
|
||||||
if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL)
|
if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL)
|
||||||
StrEmpty(_ini_blitter) ?
|
StrEmpty(_ini_blitter) ?
|
||||||
error("Failed to autoprobe blitter") :
|
usererror("Failed to autoprobe blitter") :
|
||||||
error("Failed to select requested blitter '%s'; does it exist?", _ini_blitter);
|
usererror("Failed to select requested blitter '%s'; does it exist?", _ini_blitter);
|
||||||
|
|
||||||
DEBUG(driver, 1, "Loading drivers...");
|
DEBUG(driver, 1, "Loading drivers...");
|
||||||
|
|
||||||
_sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(_ini_sounddriver, Driver::DT_SOUND);
|
_sound_driver = (SoundDriver*)SoundDriverFactoryBase::SelectDriver(_ini_sounddriver, Driver::DT_SOUND);
|
||||||
if (_sound_driver == NULL) {
|
if (_sound_driver == NULL) {
|
||||||
StrEmpty(_ini_sounddriver) ?
|
StrEmpty(_ini_sounddriver) ?
|
||||||
error("Failed to autoprobe sound driver") :
|
usererror("Failed to autoprobe sound driver") :
|
||||||
error("Failed to select requested sound driver '%s'", _ini_sounddriver);
|
usererror("Failed to select requested sound driver '%s'", _ini_sounddriver);
|
||||||
}
|
}
|
||||||
|
|
||||||
_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(_ini_musicdriver, Driver::DT_MUSIC);
|
_music_driver = (MusicDriver*)MusicDriverFactoryBase::SelectDriver(_ini_musicdriver, Driver::DT_MUSIC);
|
||||||
if (_music_driver == NULL) {
|
if (_music_driver == NULL) {
|
||||||
StrEmpty(_ini_musicdriver) ?
|
StrEmpty(_ini_musicdriver) ?
|
||||||
error("Failed to autoprobe music driver") :
|
usererror("Failed to autoprobe music driver") :
|
||||||
error("Failed to select requested music driver '%s'", _ini_musicdriver);
|
usererror("Failed to select requested music driver '%s'", _ini_musicdriver);
|
||||||
}
|
}
|
||||||
|
|
||||||
_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(_ini_videodriver, Driver::DT_VIDEO);
|
_video_driver = (VideoDriver*)VideoDriverFactoryBase::SelectDriver(_ini_videodriver, Driver::DT_VIDEO);
|
||||||
if (_video_driver == NULL) {
|
if (_video_driver == NULL) {
|
||||||
StrEmpty(_ini_videodriver) ?
|
StrEmpty(_ini_videodriver) ?
|
||||||
error("Failed to autoprobe video driver") :
|
usererror("Failed to autoprobe video driver") :
|
||||||
error("Failed to select requested video driver '%s'", _ini_videodriver);
|
usererror("Failed to select requested video driver '%s'", _ini_videodriver);
|
||||||
}
|
}
|
||||||
|
|
||||||
_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
|
_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
|
||||||
|
|
|
@ -145,7 +145,7 @@ void ShowInfo(const char *str)
|
||||||
WinTerminate(hab);
|
WinTerminate(hab);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowOSErrorBox(const char *buf)
|
void ShowOSErrorBox(const char *buf, bool system)
|
||||||
{
|
{
|
||||||
HAB hab;
|
HAB hab;
|
||||||
HMQ hmq;
|
HMQ hmq;
|
||||||
|
|
|
@ -1468,7 +1468,7 @@ static bool IndividualRoadVehicleController(Vehicle *v, const Vehicle *prev)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir == INVALID_TRACKDIR) {
|
if (dir == INVALID_TRACKDIR) {
|
||||||
if (!IsRoadVehFront(v)) error("!Disconnecting road vehicle.");
|
if (!IsRoadVehFront(v)) error("Disconnecting road vehicle.");
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ static void PrepareHeader(WAVEHDR *hdr)
|
||||||
hdr->lpData = MallocT<char>(_bufsize * 4);
|
hdr->lpData = MallocT<char>(_bufsize * 4);
|
||||||
if (hdr->lpData == NULL ||
|
if (hdr->lpData == NULL ||
|
||||||
waveOutPrepareHeader(_waveout, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR)
|
waveOutPrepareHeader(_waveout, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR)
|
||||||
error("waveOutPrepareHeader failed");
|
usererror("waveOutPrepareHeader failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FillHeaders()
|
static void FillHeaders()
|
||||||
|
@ -35,7 +35,7 @@ static void FillHeaders()
|
||||||
if (!(hdr->dwFlags & WHDR_INQUEUE)) {
|
if (!(hdr->dwFlags & WHDR_INQUEUE)) {
|
||||||
MxMixSamples(hdr->lpData, hdr->dwBufferLength / 4);
|
MxMixSamples(hdr->lpData, hdr->dwBufferLength / 4);
|
||||||
if (waveOutWrite(_waveout, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR)
|
if (waveOutWrite(_waveout, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR)
|
||||||
error("waveOutWrite failed");
|
usererror("waveOutWrite failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ static void* ReadSprite(SpriteCache *sc, SpriteID id, bool real_sprite)
|
||||||
static byte warning_level = 0;
|
static byte warning_level = 0;
|
||||||
DEBUG(sprite, warning_level, "Tried to load non sprite #%d as a real sprite. Probable cause: NewGRF interference", id);
|
DEBUG(sprite, warning_level, "Tried to load non sprite #%d as a real sprite. Probable cause: NewGRF interference", id);
|
||||||
warning_level = 6;
|
warning_level = 6;
|
||||||
if (id == SPR_IMG_QUERY) error("Uhm, would you be so kind not to load a NewGRF that makes the 'query' sprite a non- sprite?");
|
if (id == SPR_IMG_QUERY) usererror("Uhm, would you be so kind not to load a NewGRF that makes the 'query' sprite a non- sprite?");
|
||||||
return (void*)GetSprite(SPR_IMG_QUERY);
|
return (void*)GetSprite(SPR_IMG_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ bool LoadNextSprite(int load_index, byte file_slot, uint file_sprite_id)
|
||||||
if (!ReadSpriteHeaderSkipData()) return false;
|
if (!ReadSpriteHeaderSkipData()) return false;
|
||||||
|
|
||||||
if (load_index >= MAX_SPRITES) {
|
if (load_index >= MAX_SPRITES) {
|
||||||
error("Tried to load too many sprites (#%d; max %d)", load_index, MAX_SPRITES);
|
usererror("Tried to load too many sprites (#%d; max %d)", load_index, MAX_SPRITES);
|
||||||
}
|
}
|
||||||
|
|
||||||
sc = AllocateSpriteCache(load_index);
|
sc = AllocateSpriteCache(load_index);
|
||||||
|
|
|
@ -317,6 +317,7 @@ assert_compile(sizeof(uint8) == 1);
|
||||||
#define CloseConnection OTTD_CloseConnection
|
#define CloseConnection OTTD_CloseConnection
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ */
|
||||||
|
|
||||||
|
void NORETURN CDECL usererror(const char *str, ...);
|
||||||
void NORETURN CDECL error(const char *str, ...);
|
void NORETURN CDECL error(const char *str, ...);
|
||||||
#define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
|
#define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ static char *GetStringWithArgs(char *buffr, uint string, const int64 *argv, cons
|
||||||
|
|
||||||
if (index >= _langtab_num[tab]) {
|
if (index >= _langtab_num[tab]) {
|
||||||
error(
|
error(
|
||||||
"!String 0x%X is invalid. "
|
"String 0x%X is invalid. "
|
||||||
"Probably because an old version of the .lng file.\n", string
|
"Probably because an old version of the .lng file.\n", string
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1427,7 +1427,7 @@ void InitializeLanguagePacks()
|
||||||
FioAppendDirectory(path, lengthof(path), sp, LANG_DIR);
|
FioAppendDirectory(path, lengthof(path), sp, LANG_DIR);
|
||||||
language_count += GetLanguageList(files, language_count, lengthof(files), path);
|
language_count += GetLanguageList(files, language_count, lengthof(files), path);
|
||||||
}
|
}
|
||||||
if (language_count == 0) error("No available language packs (invalid versions?)");
|
if (language_count == 0) usererror("No available language packs (invalid versions?)");
|
||||||
|
|
||||||
/* Acquire the locale of the current system */
|
/* Acquire the locale of the current system */
|
||||||
const char *lang = GetCurrentLocale("LC_MESSAGES");
|
const char *lang = GetCurrentLocale("LC_MESSAGES");
|
||||||
|
@ -1463,7 +1463,7 @@ void InitializeLanguagePacks()
|
||||||
dl->num++;
|
dl->num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dl->num == 0) error("Invalid version of language packs");
|
if (dl->num == 0) usererror("Invalid version of language packs");
|
||||||
|
|
||||||
/* We haven't found the language in the config nor the one in the locale.
|
/* We haven't found the language in the config nor the one in the locale.
|
||||||
* Now we set it to one of the fallback languages */
|
* Now we set it to one of the fallback languages */
|
||||||
|
@ -1471,7 +1471,7 @@ void InitializeLanguagePacks()
|
||||||
chosen_language = (language_fallback != -1) ? language_fallback : en_GB_fallback;
|
chosen_language = (language_fallback != -1) ? language_fallback : en_GB_fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ReadLanguagePack(chosen_language)) error("Can't read language pack '%s'", dl->ent[chosen_language].file);
|
if (!ReadLanguagePack(chosen_language)) usererror("Can't read language pack '%s'", dl->ent[chosen_language].file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1603,7 +1603,7 @@ bool GenerateTowns()
|
||||||
if (num == 0 && CreateRandomTown(10000, TSM_RANDOM, 0) == NULL) {
|
if (num == 0 && CreateRandomTown(10000, TSM_RANDOM, 0) == NULL) {
|
||||||
if (GetNumTowns() == 0) {
|
if (GetNumTowns() == 0) {
|
||||||
/* XXX - can we handle that more gracefully? */
|
/* XXX - can we handle that more gracefully? */
|
||||||
if (_game_mode != GM_EDITOR) error("Could not generate any town");
|
if (_game_mode != GM_EDITOR) usererror("Could not generate any town");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3113,7 +3113,7 @@ static void TrainController(Vehicle *v, Vehicle *nomove, bool update_image)
|
||||||
|
|
||||||
invalid_rail:
|
invalid_rail:
|
||||||
/* We've reached end of line?? */
|
/* We've reached end of line?? */
|
||||||
if (prev != NULL) error("!Disconnecting train");
|
if (prev != NULL) error("Disconnecting train");
|
||||||
|
|
||||||
reverse_train_direction:
|
reverse_train_direction:
|
||||||
v->load_unload_time_rem = 0;
|
v->load_unload_time_rem = 0;
|
||||||
|
|
|
@ -214,7 +214,7 @@ void ShowInfo(const char *str)
|
||||||
fprintf(stderr, "%s\n", str);
|
fprintf(stderr, "%s\n", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowOSErrorBox(const char *buf)
|
void ShowOSErrorBox(const char *buf, bool system)
|
||||||
{
|
{
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
/* this creates an NSAlertPanel with the contents of 'buf'
|
/* this creates an NSAlertPanel with the contents of 'buf'
|
||||||
|
|
|
@ -107,10 +107,10 @@ static void CreateWindowsConsoleThread()
|
||||||
/* Create event to signal when console input is ready */
|
/* Create event to signal when console input is ready */
|
||||||
_hInputReady = CreateEvent(NULL, false, false, NULL);
|
_hInputReady = CreateEvent(NULL, false, false, NULL);
|
||||||
_hWaitForInputHandling = 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);
|
_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");
|
DEBUG(driver, 2, "Windows console thread started");
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ static void GetVideoModes()
|
||||||
modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0));
|
modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0));
|
||||||
|
|
||||||
if (modes == NULL)
|
if (modes == NULL)
|
||||||
error("sdl: no modes available");
|
usererror("sdl: no modes available");
|
||||||
|
|
||||||
_all_modes = (modes == (void*)-1);
|
_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);
|
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 */
|
/* Give the application an icon */
|
||||||
icon = SDL_CALL SDL_LoadBMP(ICON_DIR PATHSEP "openttd.32.bmp");
|
icon = SDL_CALL SDL_LoadBMP(ICON_DIR PATHSEP "openttd.32.bmp");
|
||||||
|
|
|
@ -59,7 +59,7 @@ static void MakePalette()
|
||||||
|
|
||||||
}
|
}
|
||||||
_wnd.gdi_palette = CreatePalette(pal);
|
_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)
|
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));
|
_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);
|
_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);
|
ShowWindow(_wnd.main_wnd, showstyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,7 +671,7 @@ static void RegisterWndClass()
|
||||||
};
|
};
|
||||||
|
|
||||||
registered = true;
|
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);
|
w = max(w, 64);
|
||||||
h = max(h, 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)
|
if (w == _screen.width && h == _screen.height)
|
||||||
return false;
|
return false;
|
||||||
|
@ -707,7 +707,7 @@ static bool AllocateDibSection(int w, int h)
|
||||||
|
|
||||||
dc = GetDC(0);
|
dc = GetDC(0);
|
||||||
_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (VOID**)&_wnd.buffer_bits, NULL, 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);
|
ReleaseDC(0, dc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -92,14 +92,14 @@ void SetExceptionString(const char *s, ...)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ShowOSErrorBox(const char *buf)
|
void ShowOSErrorBox(const char *buf, bool system)
|
||||||
{
|
{
|
||||||
MyShowCursor(true);
|
MyShowCursor(true);
|
||||||
MessageBox(GetActiveWindow(), MB_TO_WIDE(buf), _T("Error!"), MB_ICONSTOP);
|
MessageBox(GetActiveWindow(), MB_TO_WIDE(buf), _T("Error!"), MB_ICONSTOP);
|
||||||
|
|
||||||
/* if exception tracker is enabled, we crash here to let the exception handler handle it. */
|
/* if exception tracker is enabled, we crash here to let the exception handler handle it. */
|
||||||
#if defined(WIN32_EXCEPTION_TRACKER) && !defined(_DEBUG)
|
#if defined(WIN32_EXCEPTION_TRACKER) && !defined(_DEBUG)
|
||||||
if (*buf == '!') {
|
if (system) {
|
||||||
_exception_string = buf;
|
_exception_string = buf;
|
||||||
*(byte*)0 = 0;
|
*(byte*)0 = 0;
|
||||||
}
|
}
|
||||||
|
@ -961,7 +961,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
||||||
|
|
||||||
#if !defined(WINCE)
|
#if !defined(WINCE)
|
||||||
/* Check if a win9x user started the win32 version */
|
/* Check if a win9x user started the win32 version */
|
||||||
if (HasBit(GetVersion(), 31)) error("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
|
if (HasBit(GetVersion(), 31)) usererror("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* For UNICODE we need to convert the commandline to char* _AND_
|
/* For UNICODE we need to convert the commandline to char* _AND_
|
||||||
|
|
Loading…
Reference in New Issue