author | celestar |
Mon, 15 Jan 2007 20:14:06 +0000 | |
branch | custombridgeheads |
changeset 5650 | aefc131bf5ce |
parent 5643 | 3778051e8095 |
permissions | -rw-r--r-- |
2847
5c667829bc67
(svn r3395) Add Id tag (and svn property) to macosx files.
peter1138
parents:
2827
diff
changeset
|
1 |
/* $Id$ */ |
5c667829bc67
(svn r3395) Add Id tag (and svn property) to macosx files.
peter1138
parents:
2827
diff
changeset
|
2 |
|
2188
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
3 |
#include <AppKit/AppKit.h> |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
4 |
|
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
5 |
#include <mach/mach.h> |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
6 |
#include <mach/mach_host.h> |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
7 |
#include <mach/host_info.h> |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
8 |
#include <mach/machine.h> |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
9 |
#include <stdio.h> |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
10 |
#include "../../stdafx.h" |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
11 |
#include "../../macros.h" |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
12 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
13 |
#ifndef CPU_SUBTYPE_POWERPC_970 |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
14 |
#define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100) |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
15 |
#endif |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
16 |
|
2188
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
17 |
/* |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
18 |
* This file contains objective C |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
19 |
* Apple uses objective C instead of plain C to interact with OS specific/native functions |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
20 |
* |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
21 |
* Note: TrueLight's crosscompiler can handle this, but it likely needs a manual modification for each change in this file. |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
22 |
* To insure that the crosscompiler still works, let him try any changes before they are committed |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
23 |
*/ |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
24 |
|
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5643
diff
changeset
|
25 |
void ToggleFullScreen(bool fs); |
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5643
diff
changeset
|
26 |
|
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
27 |
static char *GetOSString(void) |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
28 |
{ |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
29 |
static char buffer[175]; |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
30 |
const char* CPU; |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
31 |
char OS[20]; |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
32 |
char newgrf[125]; |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
33 |
long sysVersion; |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
34 |
extern const char _openttd_revision[]; |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
35 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
36 |
// get the hardware info |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
37 |
host_basic_info_data_t hostInfo; |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
38 |
mach_msg_type_number_t infoCount; |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
39 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
40 |
infoCount = HOST_BASIC_INFO_COUNT; |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
41 |
host_info( |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
42 |
mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo, &infoCount |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
43 |
); |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
44 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
45 |
// replace the hardware info with strings, that tells a bit more than just an int |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
46 |
switch (hostInfo.cpu_subtype) { |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
47 |
#ifdef __POWERPC__ |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
48 |
case CPU_SUBTYPE_POWERPC_750: CPU = "G3"; break; |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
49 |
case CPU_SUBTYPE_POWERPC_7400: |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
50 |
case CPU_SUBTYPE_POWERPC_7450: CPU = "G4"; break; |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
51 |
case CPU_SUBTYPE_POWERPC_970: CPU = "G5"; break; |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
52 |
default: CPU = "Unknown PPC"; break; |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
53 |
#else |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
54 |
/* it looks odd to have a switch for two cases, but it leaves room for easy |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
55 |
* expansion. Odds are that Apple will some day use newer CPUs than i686 |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
56 |
*/ |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
57 |
case CPU_SUBTYPE_PENTPRO: CPU = "i686"; break; |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
58 |
default: CPU = "Unknown Intel"; break; |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
59 |
#endif |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
60 |
} |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
61 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
62 |
// get the version of OSX |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
63 |
if (Gestalt(gestaltSystemVersion, &sysVersion) != noErr) { |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
64 |
sprintf(OS, "Undetected"); |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
65 |
} else { |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
66 |
int majorHiNib = GB(sysVersion, 12, 4); |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
67 |
int majorLoNib = GB(sysVersion, 8, 4); |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
68 |
int minorNib = GB(sysVersion, 4, 4); |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
69 |
int bugNib = GB(sysVersion, 0, 4); |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
70 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
71 |
sprintf(OS, "%d%d.%d.%d", majorHiNib, majorLoNib, minorNib, bugNib); |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
72 |
} |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
73 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
74 |
// make a list of used newgrf files |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5643
diff
changeset
|
75 |
/* if (_first_grffile != NULL) { |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
76 |
char* n = newgrf; |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
77 |
const GRFFile* file; |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
78 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
79 |
for (file = _first_grffile; file != NULL; file = file->next) { |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
80 |
n = strecpy(n, " ", lastof(newgrf)); |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
81 |
n = strecpy(n, file->filename, lastof(newgrf)); |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
82 |
} |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5643
diff
changeset
|
83 |
} else {*/ |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
84 |
sprintf(newgrf, "none"); |
5650
aefc131bf5ce
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents:
5643
diff
changeset
|
85 |
// } |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
86 |
|
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
87 |
snprintf( |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
88 |
buffer, lengthof(buffer), |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
89 |
"Please add this info: (tip: copy-paste works)\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
90 |
"CPU: %s, OSX: %s, OpenTTD version: %s\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
91 |
"NewGRF files:%s", |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
92 |
CPU, OS, _openttd_revision, newgrf |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
93 |
); |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
94 |
return buffer; |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
95 |
} |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
96 |
|
2827
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
97 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
98 |
#ifdef WITH_SDL |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
99 |
|
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
100 |
void ShowMacDialog(const char* title, const char* message, const char* buttonLabel) |
2188
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
101 |
{ |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
102 |
NSRunAlertPanel([NSString stringWithCString: title], [NSString stringWithCString: message], [NSString stringWithCString: buttonLabel], nil, nil); |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
103 |
} |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
104 |
|
2827
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
105 |
#elif defined WITH_COCOA |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
106 |
|
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
107 |
void CocoaDialog(const char* title, const char* message, const char* buttonLabel); |
2827
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
108 |
|
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
109 |
void ShowMacDialog(const char* title, const char* message, const char* buttonLabel) |
2827
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
110 |
{ |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
111 |
CocoaDialog(title, message, buttonLabel); |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
112 |
} |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
113 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
114 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
115 |
#else |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
116 |
|
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
117 |
void ShowMacDialog(const char* title, const char* message, const char* buttonLabel) |
2827
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
118 |
{ |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
119 |
fprintf(stderr, "%s: %s\n", title, message); |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
120 |
} |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
121 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
122 |
#endif |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
123 |
|
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
124 |
void ShowMacAssertDialog(const char* function, const char* file, const int line, const char* expression) |
2223
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
125 |
{ |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
126 |
const char* buffer = |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
127 |
[[NSString stringWithFormat:@ |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
128 |
"An assertion has failed and OpenTTD must quit.\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
129 |
"%s in %s (line %d)\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
130 |
"\"%s\"\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
131 |
"\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
132 |
"You should report this error the OpenTTD developers if you think you found a bug.\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
133 |
"\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
134 |
"%s", |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
135 |
function, file, line, expression, GetOSString()] cString |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
136 |
]; |
2223
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
137 |
NSLog(@"%s", buffer); |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
138 |
ToggleFullScreen(0); |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
139 |
ShowMacDialog("Assertion Failed", buffer, "Quit"); |
2736
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2223
diff
changeset
|
140 |
|
2223
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
141 |
// abort so that a debugger has a chance to notice |
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
142 |
abort(); |
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
143 |
} |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
144 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
145 |
|
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
146 |
void ShowMacErrorDialog(const char *error) |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
147 |
{ |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
148 |
const char* buffer = |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
149 |
[[NSString stringWithFormat:@ |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
150 |
"Please update to the newest version of OpenTTD\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
151 |
"If the problem presists, please report this to\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
152 |
"http://bugs.openttd.org\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
153 |
"\n" |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
154 |
"%s", |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
155 |
GetOSString()] cString |
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
156 |
]; |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
157 |
ToggleFullScreen(0); |
3130
87a9577f6945
(svn r3745) Fix two buffer overflows, one case of undefined behavior (the destination buffer of sprintf() may not alias with one of its arguments) and some other minor stuff introduced in r3740
tron
parents:
3127
diff
changeset
|
158 |
ShowMacDialog(error, buffer, "Quit"); |
3127
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
159 |
abort(); |
c734d50ad134
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents:
2847
diff
changeset
|
160 |
} |