equal
deleted
inserted
replaced
1 /* $Id$ */ |
1 /* $Id$ */ |
|
2 |
|
3 /** @file unix.cpp */ |
2 |
4 |
3 #include "stdafx.h" |
5 #include "stdafx.h" |
4 #include "openttd.h" |
6 #include "openttd.h" |
5 #include "functions.h" |
7 #include "functions.h" |
6 #include "window.h" |
8 #include "window.h" |
25 |
27 |
26 #ifdef __MORPHOS__ |
28 #ifdef __MORPHOS__ |
27 #include <exec/types.h> |
29 #include <exec/types.h> |
28 ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;) |
30 ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;) |
29 |
31 |
30 // The system supplied definition of SIG_IGN does not match |
32 /* The system supplied definition of SIG_IGN does not match */ |
31 #undef SIG_IGN |
33 #undef SIG_IGN |
32 #define SIG_IGN (void (*)(int))1 |
34 #define SIG_IGN (void (*)(int))1 |
33 #endif /* __MORPHOS__ */ |
35 #endif /* __MORPHOS__ */ |
34 |
36 |
35 #ifdef __AMIGA__ |
37 #ifdef __AMIGA__ |
37 // ULONG __stack = |
39 // ULONG __stack = |
38 #endif |
40 #endif |
39 |
41 |
40 #if defined(__APPLE__) |
42 #if defined(__APPLE__) |
41 #if defined(WITH_SDL) |
43 #if defined(WITH_SDL) |
42 //the mac implementation needs this file included in the same file as main() |
44 /*the mac implementation needs this file included in the same file as main() */ |
43 #include <SDL.h> |
45 #include <SDL.h> |
44 #endif |
46 #endif |
45 #endif |
47 #endif |
46 |
48 |
47 bool FiosIsRoot(const char *path) |
49 bool FiosIsRoot(const char *path) |
102 } |
104 } |
103 |
105 |
104 void ShowOSErrorBox(const char *buf) |
106 void ShowOSErrorBox(const char *buf) |
105 { |
107 { |
106 #if defined(__APPLE__) |
108 #if defined(__APPLE__) |
107 // this creates an NSAlertPanel with the contents of 'buf' |
109 /* this creates an NSAlertPanel with the contents of 'buf' |
108 // this is the native and nicest way to do this on OSX |
110 * this is the native and nicest way to do this on OSX */ |
109 ShowMacDialog( buf, "See readme for more info\nMost likely you are missing files from the original TTD", "Quit" ); |
111 ShowMacDialog( buf, "See readme for more info\nMost likely you are missing files from the original TTD", "Quit" ); |
110 #else |
112 #else |
111 // all systems, but OSX |
113 /* all systems, but OSX */ |
112 fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf); |
114 fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf); |
113 #endif |
115 #endif |
114 } |
116 } |
115 |
117 |
116 #ifdef WITH_COCOA |
118 #ifdef WITH_COCOA |
149 { |
151 { |
150 return false; |
152 return false; |
151 } |
153 } |
152 |
154 |
153 |
155 |
154 // multi os compatible sleep function |
156 /* multi os compatible sleep function */ |
155 |
157 |
156 #ifdef __AMIGA__ |
158 #ifdef __AMIGA__ |
157 // usleep() implementation |
159 /* usleep() implementation */ |
158 # include <devices/timer.h> |
160 # include <devices/timer.h> |
159 # include <dos/dos.h> |
161 # include <dos/dos.h> |
160 |
162 |
161 extern struct Device *TimerBase = NULL; |
163 extern struct Device *TimerBase = NULL; |
162 extern struct MsgPort *TimerPort = NULL; |
164 extern struct MsgPort *TimerPort = NULL; |
172 #elif defined(__AMIGA__) |
174 #elif defined(__AMIGA__) |
173 { |
175 { |
174 ULONG signals; |
176 ULONG signals; |
175 ULONG TimerSigBit = 1 << TimerPort->mp_SigBit; |
177 ULONG TimerSigBit = 1 << TimerPort->mp_SigBit; |
176 |
178 |
177 // send IORequest |
179 /* send IORequest */ |
178 TimerRequest->tr_node.io_Command = TR_ADDREQUEST; |
180 TimerRequest->tr_node.io_Command = TR_ADDREQUEST; |
179 TimerRequest->tr_time.tv_secs = (milliseconds * 1000) / 1000000; |
181 TimerRequest->tr_time.tv_secs = (milliseconds * 1000) / 1000000; |
180 TimerRequest->tr_time.tv_micro = (milliseconds * 1000) % 1000000; |
182 TimerRequest->tr_time.tv_micro = (milliseconds * 1000) % 1000000; |
181 SendIO((struct IORequest *)TimerRequest); |
183 SendIO((struct IORequest *)TimerRequest); |
182 |
184 |
241 if (iconv(convd, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1)) { |
243 if (iconv(convd, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1)) { |
242 DEBUG(misc, 0, "[iconv] error converting '%s'. Errno %d", name, errno); |
244 DEBUG(misc, 0, "[iconv] error converting '%s'. Errno %d", name, errno); |
243 } |
245 } |
244 |
246 |
245 *outbuf = '\0'; |
247 *outbuf = '\0'; |
246 // FIX: invalid characters will abort conversion, but they shouldn't occur? |
248 /* FIX: invalid characters will abort conversion, but they shouldn't occur? */ |
247 return buf; |
249 return buf; |
248 } |
250 } |
249 |
251 |
250 /** Convert from OpenTTD's encoding to that of the local environment |
252 /** Convert from OpenTTD's encoding to that of the local environment |
251 * @param name pointer to a valid string that will be converted |
253 * @param name pointer to a valid string that will be converted |