author | KUDr |
Sat, 13 Jan 2007 18:55:54 +0000 | |
changeset 5651 | 79496e6d8a56 |
parent 5587 | 167d9a91ef02 |
permissions | -rw-r--r-- |
2847
65c54f935db6
(svn r3395) Add Id tag (and svn property) to macosx files.
peter1138
parents:
2827
diff
changeset
|
1 |
/* $Id$ */ |
65c54f935db6
(svn r3395) Add Id tag (and svn property) to macosx files.
peter1138
parents:
2827
diff
changeset
|
2 |
|
2188
640a0a5f77ea
(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> |
640a0a5f77ea
(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
56a9c0db7c18
(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> |
56a9c0db7c18
(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> |
56a9c0db7c18
(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> |
56a9c0db7c18
(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> |
56a9c0db7c18
(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> |
56a9c0db7c18
(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
c65ad41ee90b
(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
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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 |
56a9c0db7c18
(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) |
56a9c0db7c18
(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 |
56a9c0db7c18
(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
640a0a5f77ea
(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 |
/* |
640a0a5f77ea
(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 |
640a0a5f77ea
(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 |
640a0a5f77ea
(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 |
* |
640a0a5f77ea
(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. |
640a0a5f77ea
(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 |
640a0a5f77ea
(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 |
*/ |
640a0a5f77ea
(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 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
25 |
void ToggleFullScreen(bool fs); |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
26 |
|
3127
56a9c0db7c18
(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) |
56a9c0db7c18
(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 |
{ |
56a9c0db7c18
(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
c65ad41ee90b
(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
56a9c0db7c18
(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]; |
56a9c0db7c18
(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
c65ad41ee90b
(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; |
c65ad41ee90b
(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
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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 |
56a9c0db7c18
(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; |
56a9c0db7c18
(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; |
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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
c65ad41ee90b
(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( |
c65ad41ee90b
(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 |
c65ad41ee90b
(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
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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 |
56a9c0db7c18
(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
c65ad41ee90b
(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__ |
c65ad41ee90b
(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
56a9c0db7c18
(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
c65ad41ee90b
(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; |
c65ad41ee90b
(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; |
c65ad41ee90b
(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; |
c65ad41ee90b
(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 |
c65ad41ee90b
(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 |
c65ad41ee90b
(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 |
c65ad41ee90b
(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 |
*/ |
c65ad41ee90b
(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; |
c65ad41ee90b
(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; |
c65ad41ee90b
(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
56a9c0db7c18
(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 |
} |
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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
c65ad41ee90b
(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) { |
c65ad41ee90b
(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
56a9c0db7c18
(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
c65ad41ee90b
(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); |
c65ad41ee90b
(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); |
c65ad41ee90b
(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); |
c65ad41ee90b
(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
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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); |
56a9c0db7c18
(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 |
} |
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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 |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
75 |
/* if (_first_grffile != NULL) { |
3130
c65ad41ee90b
(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; |
c65ad41ee90b
(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
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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
c65ad41ee90b
(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)); |
c65ad41ee90b
(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
56a9c0db7c18
(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 |
} |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
83 |
} else {*/ |
3127
56a9c0db7c18
(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"); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
85 |
// } |
3130
c65ad41ee90b
(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 |
|
c65ad41ee90b
(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( |
c65ad41ee90b
(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), |
c65ad41ee90b
(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" |
c65ad41ee90b
(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" |
c65ad41ee90b
(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", |
c65ad41ee90b
(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 |
c65ad41ee90b
(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
56a9c0db7c18
(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; |
56a9c0db7c18
(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 |
} |
56a9c0db7c18
(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
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
97 |
|
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
98 |
#ifdef WITH_SDL |
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
99 |
|
3130
c65ad41ee90b
(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
640a0a5f77ea
(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 |
{ |
640a0a5f77ea
(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); |
640a0a5f77ea
(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 |
} |
640a0a5f77ea
(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
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
105 |
#elif defined WITH_COCOA |
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
106 |
|
3130
c65ad41ee90b
(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
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
108 |
|
3130
c65ad41ee90b
(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
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
110 |
{ |
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
111 |
CocoaDialog(title, message, buttonLabel); |
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
112 |
} |
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
113 |
|
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
114 |
|
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
115 |
#else |
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
116 |
|
3130
c65ad41ee90b
(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
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
118 |
{ |
12c9eda7edcd
(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); |
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
120 |
} |
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
121 |
|
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
122 |
#endif |
12c9eda7edcd
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
123 |
|
3130
c65ad41ee90b
(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
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
125 |
{ |
3130
c65ad41ee90b
(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 = |
c65ad41ee90b
(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:@ |
c65ad41ee90b
(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" |
c65ad41ee90b
(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" |
c65ad41ee90b
(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" |
c65ad41ee90b
(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" |
c65ad41ee90b
(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" |
c65ad41ee90b
(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" |
c65ad41ee90b
(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", |
c65ad41ee90b
(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 |
c65ad41ee90b
(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
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
137 |
NSLog(@"%s", buffer); |
3127
56a9c0db7c18
(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
c65ad41ee90b
(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
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2223
diff
changeset
|
140 |
|
2223
b9564d70ec3d
(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 |
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
142 |
abort(); |
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
143 |
} |
3127
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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 |
|
56a9c0db7c18
(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) |
56a9c0db7c18
(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
c65ad41ee90b
(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 = |
c65ad41ee90b
(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:@ |
c65ad41ee90b
(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" |
c65ad41ee90b
(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" |
c65ad41ee90b
(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" |
c65ad41ee90b
(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" |
c65ad41ee90b
(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", |
c65ad41ee90b
(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 |
c65ad41ee90b
(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
56a9c0db7c18
(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
c65ad41ee90b
(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
56a9c0db7c18
(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(); |
56a9c0db7c18
(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 |
} |