author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6423 | 8e10e79e0fd1 |
child 6632 | 17d38db79a50 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
3 |
/** @file unix.cpp */ |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1892
8717d92b32b1
(svn r2398) - CodeChange: forgot to update unix and os2 specific files as well.
Darkvater
parents:
1885
diff
changeset
|
6 |
#include "openttd.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
7 |
#include "functions.h" |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1346
diff
changeset
|
8 |
#include "window.h" |
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
1093
diff
changeset
|
9 |
#include "string.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
437
diff
changeset
|
10 |
#include "table/strings.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2099
diff
changeset
|
11 |
#include "variables.h" |
0 | 12 |
|
13 |
#include <dirent.h> |
|
14 |
#include <unistd.h> |
|
15 |
#include <sys/stat.h> |
|
16 |
#include <time.h> |
|
1509
795ba683e4f0
(svn r2013) Always ignore SIGPIPE, not only when SDL is used (ShadowJK)
tron
parents:
1508
diff
changeset
|
17 |
#include <signal.h> |
0 | 18 |
|
1850
15826a18b5ac
(svn r2356) Make check if statvfs() is availible a bit more sensible
tron
parents:
1687
diff
changeset
|
19 |
#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__GLIBC__) |
1597
ef6253448620
(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
tron
parents:
1596
diff
changeset
|
20 |
#define HAS_STATVFS |
ef6253448620
(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
tron
parents:
1596
diff
changeset
|
21 |
#endif |
ef6253448620
(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
tron
parents:
1596
diff
changeset
|
22 |
|
ef6253448620
(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
tron
parents:
1596
diff
changeset
|
23 |
#ifdef HAS_STATVFS |
0 | 24 |
#include <sys/statvfs.h> |
25 |
#endif |
|
26 |
||
27 |
||
28 |
#ifdef __MORPHOS__ |
|
29 |
#include <exec/types.h> |
|
30 |
ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;) |
|
2356 | 31 |
|
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
32 |
/* The system supplied definition of SIG_IGN does not match */ |
2356 | 33 |
#undef SIG_IGN |
34 |
#define SIG_IGN (void (*)(int))1 |
|
0 | 35 |
#endif /* __MORPHOS__ */ |
36 |
||
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
704
diff
changeset
|
37 |
#ifdef __AMIGA__ |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
704
diff
changeset
|
38 |
#warning add stack symbol to avoid that user needs to set stack manually (tokai) |
915 | 39 |
// ULONG __stack = |
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
704
diff
changeset
|
40 |
#endif |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
704
diff
changeset
|
41 |
|
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:
2186
diff
changeset
|
42 |
#if defined(__APPLE__) |
2217
7a5d829eca29
(svn r2735) -Fix: [OSX] fixed issue introduced in 2733 where dedicated servers on OSX included sdl.h even when WITH_SDL was not defined (oops)
bjarni
parents:
2215
diff
changeset
|
43 |
#if defined(WITH_SDL) |
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
44 |
/*the mac implementation needs this file included in the same file as main() */ |
2217
7a5d829eca29
(svn r2735) -Fix: [OSX] fixed issue introduced in 2733 where dedicated servers on OSX included sdl.h even when WITH_SDL was not defined (oops)
bjarni
parents:
2215
diff
changeset
|
45 |
#include <SDL.h> |
7a5d829eca29
(svn r2735) -Fix: [OSX] fixed issue introduced in 2733 where dedicated servers on OSX included sdl.h even when WITH_SDL was not defined (oops)
bjarni
parents:
2215
diff
changeset
|
46 |
#endif |
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:
2186
diff
changeset
|
47 |
#endif |
0 | 48 |
|
4221
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
49 |
bool FiosIsRoot(const char *path) |
0 | 50 |
{ |
4221
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
51 |
#if !defined(__MORPHOS__) && !defined(__AMIGAOS__) |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
52 |
return path[1] == '\0'; |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
53 |
#else |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
54 |
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */ |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
55 |
const char *s = strchr(path, ':'); |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
56 |
return s[1] == '\0'; |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
57 |
#endif |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
58 |
} |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
59 |
|
6247 | 60 |
void FiosGetDrives() |
4221
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
61 |
{ |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
62 |
return; |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
63 |
} |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
64 |
|
4222
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
65 |
bool FiosGetDiskFreeSpace(const char *path, uint32 *tot) |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
66 |
{ |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
67 |
uint32 free = 0; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
68 |
|
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
69 |
#ifdef HAS_STATVFS |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
70 |
{ |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
71 |
struct statvfs s; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
72 |
|
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
73 |
if (statvfs(path, &s) != 0) return false; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
74 |
free = (uint64)s.f_frsize * s.f_bavail >> 20; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
75 |
} |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
76 |
#endif |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
77 |
if (tot != NULL) *tot = free; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
78 |
return true; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
79 |
} |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
80 |
|
4221
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
81 |
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb) |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
82 |
{ |
0 | 83 |
char filename[MAX_PATH]; |
84 |
||
4221
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
85 |
#if defined(__MORPHOS__) || defined(__AMIGAOS__) |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
86 |
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */ |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
87 |
if (FiosIsRoot(path)) { |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
88 |
snprintf(filename, lengthof(filename), "%s:%s", path, ent->d_name); |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
89 |
} else // XXX - only next line! |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
90 |
#endif |
ff4a040f30c6
(svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents:
4220
diff
changeset
|
91 |
snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name); |
0 | 92 |
|
6240
9d9874ef9f0b
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6022
diff
changeset
|
93 |
return stat(filename, sb) == 0; |
9d9874ef9f0b
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6022
diff
changeset
|
94 |
} |
0 | 95 |
|
6240
9d9874ef9f0b
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6022
diff
changeset
|
96 |
bool FiosIsHiddenFile(const struct dirent *ent) |
9d9874ef9f0b
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6022
diff
changeset
|
97 |
{ |
9d9874ef9f0b
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6022
diff
changeset
|
98 |
return ent->d_name[0] == '.'; |
0 | 99 |
} |
100 |
||
101 |
void ShowInfo(const char *str) |
|
102 |
{ |
|
5674
abe7d6b7b1d4
(svn r8134) -Fix (r8013): Add a newline after the ShowInfo console output
Darkvater
parents:
5609
diff
changeset
|
103 |
fprintf(stderr, "%s\n", str); |
0 | 104 |
} |
105 |
||
106 |
void ShowOSErrorBox(const char *buf) |
|
107 |
{ |
|
2731
888a994e9fe9
(svn r3276) reverted the last two commits. OSX 10.2 kept finding new stuff to prevent it from running OpenTTD, so now it's not supported anymore
bjarni
parents:
2730
diff
changeset
|
108 |
#if defined(__APPLE__) |
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
109 |
/* this creates an NSAlertPanel with the contents of 'buf' |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
110 |
* this is the native and nicest way to do this on OSX */ |
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:
2186
diff
changeset
|
111 |
ShowMacDialog( buf, "See readme for more info\nMost likely you are missing files from the original TTD", "Quit" ); |
529
39d3b5a074c4
(svn r869) Mac: finally made asserts open the console, so people should be able to see what went wrong even if they opened the game in the GUI
bjarni
parents:
507
diff
changeset
|
112 |
#else |
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
113 |
/* all systems, but OSX */ |
0 | 114 |
fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf); |
115 |
#endif |
|
116 |
} |
|
117 |
||
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
118 |
#ifdef WITH_COCOA |
6247 | 119 |
void cocoaSetupAutoreleasePool(); |
120 |
void cocoaReleaseAutoreleasePool(); |
|
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
121 |
#endif |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
122 |
|
0 | 123 |
int CDECL main(int argc, char* argv[]) |
124 |
{ |
|
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
125 |
int ret; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
126 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
127 |
#ifdef WITH_COCOA |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
128 |
cocoaSetupAutoreleasePool(); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3408
diff
changeset
|
129 |
/* This is passed if we are launched by double-clicking */ |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3408
diff
changeset
|
130 |
if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) { |
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
131 |
argv[1] = NULL; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
132 |
argc = 1; |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
133 |
} |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
134 |
#endif |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
135 |
|
4369
3812b4335df9
(svn r6086) -Fix: InteractiveRandom was not seeded properly resulting in the dedicated server always generating the same map. Thanks to the #openttdcoop team for detecting.
rubidium
parents:
4300
diff
changeset
|
136 |
_random_seeds[1][1] = _random_seeds[1][0] = _random_seeds[0][1] = _random_seeds[0][0] = time(NULL); |
2073 | 137 |
SeedMT(_random_seeds[0][1]); |
0 | 138 |
|
1509
795ba683e4f0
(svn r2013) Always ignore SIGPIPE, not only when SDL is used (ShadowJK)
tron
parents:
1508
diff
changeset
|
139 |
signal(SIGPIPE, SIG_IGN); |
0 | 140 |
|
2736
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
141 |
ret = ttd_main(argc, argv); |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
142 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
143 |
#ifdef WITH_COCOA |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
144 |
cocoaReleaseAutoreleasePool(); |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
145 |
#endif |
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
146 |
|
3d6487cbbb69
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
147 |
return ret; |
0 | 148 |
} |
149 |
||
1470
a8fd3e037531
(svn r1974) Cleanups, quite similar to those done to win32.c in r1972 (code duplication, anyone?)
tron
parents:
1449
diff
changeset
|
150 |
bool InsertTextBufferClipboard(Textbuf *tb) |
a8fd3e037531
(svn r1974) Cleanups, quite similar to those done to win32.c in r1972 (code duplication, anyone?)
tron
parents:
1449
diff
changeset
|
151 |
{ |
a8fd3e037531
(svn r1974) Cleanups, quite similar to those done to win32.c in r1972 (code duplication, anyone?)
tron
parents:
1449
diff
changeset
|
152 |
return false; |
a8fd3e037531
(svn r1974) Cleanups, quite similar to those done to win32.c in r1972 (code duplication, anyone?)
tron
parents:
1449
diff
changeset
|
153 |
} |
1885
aef601001f5e
(svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon.
Darkvater
parents:
1850
diff
changeset
|
154 |
|
2073 | 155 |
|
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
156 |
/* multi os compatible sleep function */ |
2073 | 157 |
|
158 |
#ifdef __AMIGA__ |
|
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
159 |
/* usleep() implementation */ |
2073 | 160 |
# include <devices/timer.h> |
161 |
# include <dos/dos.h> |
|
162 |
||
163 |
extern struct Device *TimerBase = NULL; |
|
164 |
extern struct MsgPort *TimerPort = NULL; |
|
165 |
extern struct timerequest *TimerRequest = NULL; |
|
166 |
#endif // __AMIGA__ |
|
167 |
||
168 |
void CSleep(int milliseconds) |
|
169 |
{ |
|
6022
cc9e80081d01
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
5941
diff
changeset
|
170 |
#if defined(PSP) |
cc9e80081d01
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
5941
diff
changeset
|
171 |
sceKernelDelayThread(milliseconds * 1000); |
cc9e80081d01
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
5941
diff
changeset
|
172 |
#elif defined(__BEOS__) |
2073 | 173 |
snooze(milliseconds * 1000); |
6022
cc9e80081d01
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
5941
diff
changeset
|
174 |
#elif defined(__AMIGA__) |
2073 | 175 |
{ |
176 |
ULONG signals; |
|
177 |
ULONG TimerSigBit = 1 << TimerPort->mp_SigBit; |
|
178 |
||
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
179 |
/* send IORequest */ |
2073 | 180 |
TimerRequest->tr_node.io_Command = TR_ADDREQUEST; |
181 |
TimerRequest->tr_time.tv_secs = (milliseconds * 1000) / 1000000; |
|
182 |
TimerRequest->tr_time.tv_micro = (milliseconds * 1000) % 1000000; |
|
183 |
SendIO((struct IORequest *)TimerRequest); |
|
184 |
||
185 |
if (!((signals = Wait(TimerSigBit | SIGBREAKF_CTRL_C)) & TimerSigBit) ) { |
|
186 |
AbortIO((struct IORequest *)TimerRequest); |
|
187 |
} |
|
188 |
WaitIO((struct IORequest *)TimerRequest); |
|
189 |
} |
|
6022
cc9e80081d01
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
5941
diff
changeset
|
190 |
#else |
cc9e80081d01
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
5941
diff
changeset
|
191 |
usleep(milliseconds * 1000); |
cc9e80081d01
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
5941
diff
changeset
|
192 |
#endif |
2073 | 193 |
} |
3260
ed19f95eb4f7
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
194 |
|
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
195 |
#ifdef WITH_ICONV |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
196 |
|
3332
7a671549da48
(svn r4109) - Fix (r4105) [iconv]: Only include the needed headers when ICONV is actually used. Thanks for noticing Bjarni
Darkvater
parents:
3330
diff
changeset
|
197 |
#include <iconv.h> |
7a671549da48
(svn r4109) - Fix (r4105) [iconv]: Only include the needed headers when ICONV is actually used. Thanks for noticing Bjarni
Darkvater
parents:
3330
diff
changeset
|
198 |
#include <errno.h> |
7a671549da48
(svn r4109) - Fix (r4105) [iconv]: Only include the needed headers when ICONV is actually used. Thanks for noticing Bjarni
Darkvater
parents:
3330
diff
changeset
|
199 |
#include "debug.h" |
7a671549da48
(svn r4109) - Fix (r4105) [iconv]: Only include the needed headers when ICONV is actually used. Thanks for noticing Bjarni
Darkvater
parents:
3330
diff
changeset
|
200 |
|
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4369
diff
changeset
|
201 |
#define INTERNALCODE "UTF-8" |
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
202 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
203 |
/** Try and try to decipher the current locale from environmental |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
204 |
* variables. MacOSX is hardcoded, other OS's are dynamic. If no suitable |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
205 |
* locale can be found, don't do any conversion "" */ |
6247 | 206 |
static const char *GetLocalCode() |
3260
ed19f95eb4f7
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
207 |
{ |
3408
1da501b2eae1
(svn r4219) - Add support for WITH_ICONV. It is enabled by default for OSX > 10.3 for all others set it with WITH_ICONV in Makefile.config or with --with-iconv with configure. --with-config=/somedir will search for iconv include files somewhere (or in Makefile.config with WITH_ICONV_PATH). Custom library loading is not (yet) supported
Darkvater
parents:
3332
diff
changeset
|
208 |
#if defined(__APPLE__) |
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
209 |
return "UTF-8-MAC"; |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
210 |
#else |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
211 |
/* Strip locale (eg en_US.UTF-8) to only have UTF-8 */ |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
212 |
const char *locale = GetCurrentLocale("LC_CTYPE"); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
213 |
if (locale != NULL) locale = strchr(locale, '.'); |
3260
ed19f95eb4f7
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
214 |
|
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
215 |
return (locale == NULL) ? "" : locale + 1; |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
216 |
#endif |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
217 |
} |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
218 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
219 |
/** FYI: This is not thread-safe. |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
220 |
* convert between locales, which from and which to is set in the calling |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
221 |
* functions OTTD2FS() and FS2OTTD(). You should NOT use this function directly |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
222 |
* NOTE: iconv was added in OSX 10.3. 10.2.x will still have the invalid char |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
223 |
* issues. There aren't any easy fix for this */ |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
224 |
static const char *convert_tofrom_fs(iconv_t convd, const char *name) |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
225 |
{ |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
226 |
static char buf[1024]; |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
227 |
/* Work around buggy iconv implementation where inbuf is wrongly typed as |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
228 |
* non-const. Correct implementation is at |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
229 |
* http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.html */ |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
230 |
#if defined (__GLIBC__) || defined (__GNU_LIBRARY__) |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
231 |
char *inbuf = (char*)name; |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
232 |
#else |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
233 |
const char *inbuf = name; |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
234 |
#endif |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
235 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
236 |
char *outbuf = buf; |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
237 |
size_t outlen = sizeof(buf) - 1; |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
238 |
size_t inlen = strlen(name); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
239 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
240 |
ttd_strlcpy(outbuf, name, sizeof(buf)); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
241 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
242 |
iconv(convd, NULL, NULL, NULL, NULL); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
243 |
if (iconv(convd, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1)) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
244 |
DEBUG(misc, 0, "[iconv] error converting '%s'. Errno %d", name, errno); |
3260
ed19f95eb4f7
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
245 |
} |
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
246 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
247 |
*outbuf = '\0'; |
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6318
diff
changeset
|
248 |
/* FIX: invalid characters will abort conversion, but they shouldn't occur? */ |
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
249 |
return buf; |
3260
ed19f95eb4f7
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
250 |
} |
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
251 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
252 |
/** Convert from OpenTTD's encoding to that of the local environment |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
253 |
* @param name pointer to a valid string that will be converted |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
254 |
* @return pointer to a new stringbuffer that contains the converted string */ |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
255 |
const char *OTTD2FS(const char *name) |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
256 |
{ |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
257 |
static iconv_t convd = (iconv_t)(-1); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
258 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
259 |
if (convd == (iconv_t)(-1)) { |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
260 |
const char *env = GetLocalCode(); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
261 |
convd = iconv_open(env, INTERNALCODE); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
262 |
if (convd == (iconv_t)(-1)) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
263 |
DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", INTERNALCODE, env); |
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
264 |
return name; |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
265 |
} |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
266 |
} |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
267 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
268 |
return convert_tofrom_fs(convd, name); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
269 |
} |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
270 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
271 |
/** Convert to OpenTTD's encoding from that of the local environment |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
272 |
* @param name pointer to a valid string that will be converted |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
273 |
* @return pointer to a new stringbuffer that contains the converted string */ |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
274 |
const char *FS2OTTD(const char *name) |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
275 |
{ |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
276 |
static iconv_t convd = (iconv_t)(-1); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
277 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
278 |
if (convd == (iconv_t)(-1)) { |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
279 |
const char *env = GetLocalCode(); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
280 |
convd = iconv_open(INTERNALCODE, env); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
281 |
if (convd == (iconv_t)(-1)) { |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
282 |
DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", env, INTERNALCODE); |
3329
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
283 |
return name; |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
284 |
} |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
285 |
} |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
286 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
287 |
return convert_tofrom_fs(convd, name); |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
288 |
} |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
289 |
|
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
290 |
#else |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
291 |
const char *FS2OTTD(const char *name) {return name;} |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
292 |
const char *OTTD2FS(const char *name) {return name;} |
9885789ecaf7
(svn r4105) - Feature: Add proper ISO-8859-15 <> LOCALCODE conversion. As the mess that is makefile can't properly support it at the moment, it is only available for MACOSX. Windows doesn't need FS conversion and I have no idea about OS/2 so it's disabled for them.
Darkvater
parents:
3294
diff
changeset
|
293 |
#endif /* WITH_ICONV */ |