author | rubidium |
Fri, 25 Apr 2008 15:20:48 +0000 | |
branch | noai |
changeset 10355 | ee4b5f7a5bf2 |
parent 9724 | b39bc69bb2f2 |
child 10455 | 22c441f5adf9 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9574 | 3 |
/** @file unix.cpp */ |
4 |
||
0 | 5 |
#include "stdafx.h" |
1892
45894b95a925
(svn r2398) - CodeChange: forgot to update unix and os2 specific files as well.
Darkvater
parents:
1885
diff
changeset
|
6 |
#include "openttd.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2099
diff
changeset
|
7 |
#include "variables.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
8 |
#include "textbuf_gui.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
#include "functions.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
10 |
#include "core/random_func.hpp" |
0 | 11 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
12 |
#include "table/strings.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
13 |
|
0 | 14 |
#include <dirent.h> |
15 |
#include <unistd.h> |
|
16 |
#include <sys/stat.h> |
|
17 |
#include <time.h> |
|
1509
2c232b7d2114
(svn r2013) Always ignore SIGPIPE, not only when SDL is used (ShadowJK)
tron
parents:
1508
diff
changeset
|
18 |
#include <signal.h> |
0 | 19 |
|
1850
7fa9e3ecb486
(svn r2356) Make check if statvfs() is availible a bit more sensible
tron
parents:
1687
diff
changeset
|
20 |
#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__GLIBC__) |
1597
cc09dbccddac
(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
tron
parents:
1596
diff
changeset
|
21 |
#define HAS_STATVFS |
cc09dbccddac
(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
tron
parents:
1596
diff
changeset
|
22 |
#endif |
cc09dbccddac
(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
tron
parents:
1596
diff
changeset
|
23 |
|
cc09dbccddac
(svn r2101) statvfs() is availible on POSIX.1 conformant systems.
tron
parents:
1596
diff
changeset
|
24 |
#ifdef HAS_STATVFS |
0 | 25 |
#include <sys/statvfs.h> |
26 |
#endif |
|
27 |
||
28 |
||
29 |
#ifdef __MORPHOS__ |
|
30 |
#include <exec/types.h> |
|
31 |
ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;) |
|
2356 | 32 |
|
9574 | 33 |
/* The system supplied definition of SIG_IGN does not match */ |
2356 | 34 |
#undef SIG_IGN |
35 |
#define SIG_IGN (void (*)(int))1 |
|
0 | 36 |
#endif /* __MORPHOS__ */ |
37 |
||
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
704
diff
changeset
|
38 |
#ifdef __AMIGA__ |
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
704
diff
changeset
|
39 |
#warning add stack symbol to avoid that user needs to set stack manually (tokai) |
915 | 40 |
// ULONG __stack = |
770
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
704
diff
changeset
|
41 |
#endif |
89dab23f04ca
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
704
diff
changeset
|
42 |
|
2188
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
2186
diff
changeset
|
43 |
#if defined(__APPLE__) |
2217
c3a8a3bbc81f
(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
|
44 |
#if defined(WITH_SDL) |
9574 | 45 |
/*the mac implementation needs this file included in the same file as main() */ |
2217
c3a8a3bbc81f
(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 |
#include <SDL.h> |
c3a8a3bbc81f
(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
|
47 |
#endif |
2188
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
2186
diff
changeset
|
48 |
#endif |
0 | 49 |
|
4221
bb06fe8dcce2
(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
|
50 |
bool FiosIsRoot(const char *path) |
0 | 51 |
{ |
4221
bb06fe8dcce2
(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 |
#if !defined(__MORPHOS__) && !defined(__AMIGAOS__) |
bb06fe8dcce2
(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 |
return path[1] == '\0'; |
bb06fe8dcce2
(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 |
#else |
bb06fe8dcce2
(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 |
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */ |
bb06fe8dcce2
(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 |
const char *s = strchr(path, ':'); |
9624 | 57 |
return s != NULL && s[1] == '\0'; |
4221
bb06fe8dcce2
(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 |
#endif |
bb06fe8dcce2
(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 |
} |
bb06fe8dcce2
(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
|
60 |
|
6573 | 61 |
void FiosGetDrives() |
4221
bb06fe8dcce2
(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 |
{ |
bb06fe8dcce2
(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 |
return; |
bb06fe8dcce2
(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 |
} |
bb06fe8dcce2
(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
|
65 |
|
4222
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
66 |
bool FiosGetDiskFreeSpace(const char *path, uint32 *tot) |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
67 |
{ |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
68 |
uint32 free = 0; |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
69 |
|
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
70 |
#ifdef HAS_STATVFS |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
71 |
# ifdef __APPLE__ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
72 |
/* OSX 10.3 lacks statvfs so don't try to use it even though later versions of OSX has it. */ |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
73 |
if (MacOSVersionIsAtLeast(10, 4, 0)) |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
74 |
# endif |
4222
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
75 |
{ |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
76 |
struct statvfs s; |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
77 |
|
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
78 |
if (statvfs(path, &s) != 0) return false; |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
79 |
free = (uint64)s.f_frsize * s.f_bavail >> 20; |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
80 |
} |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
81 |
#endif |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
82 |
if (tot != NULL) *tot = free; |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
83 |
return true; |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
84 |
} |
951fbf19b1ad
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
85 |
|
4221
bb06fe8dcce2
(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 |
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb) |
bb06fe8dcce2
(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 |
{ |
0 | 88 |
char filename[MAX_PATH]; |
89 |
||
4221
bb06fe8dcce2
(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 |
#if defined(__MORPHOS__) || defined(__AMIGAOS__) |
bb06fe8dcce2
(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 |
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */ |
bb06fe8dcce2
(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
|
92 |
if (FiosIsRoot(path)) { |
bb06fe8dcce2
(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
|
93 |
snprintf(filename, lengthof(filename), "%s:%s", path, ent->d_name); |
bb06fe8dcce2
(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
|
94 |
} else // XXX - only next line! |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
95 |
#else |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
96 |
assert(path[strlen(path) - 1] == PATHSEPCHAR); |
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
97 |
if (strlen(path) > 2) assert(path[strlen(path) - 2] != PATHSEPCHAR); |
4221
bb06fe8dcce2
(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
|
98 |
#endif |
9625
3301b1b3889c
(svn r10016) [NoAI] -Sync with trunk r9914:r10015.
rubidium
parents:
9624
diff
changeset
|
99 |
snprintf(filename, lengthof(filename), "%s%s", path, ent->d_name); |
0 | 100 |
|
6566
a780a47d6af3
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6348
diff
changeset
|
101 |
return stat(filename, sb) == 0; |
a780a47d6af3
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6348
diff
changeset
|
102 |
} |
0 | 103 |
|
6566
a780a47d6af3
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6348
diff
changeset
|
104 |
bool FiosIsHiddenFile(const struct dirent *ent) |
a780a47d6af3
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6348
diff
changeset
|
105 |
{ |
a780a47d6af3
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
6348
diff
changeset
|
106 |
return ent->d_name[0] == '.'; |
0 | 107 |
} |
108 |
||
109 |
void ShowInfo(const char *str) |
|
110 |
{ |
|
5925
f8e678955ef1
(svn r8134) -Fix (r8013): Add a newline after the ShowInfo console output
Darkvater
parents:
5860
diff
changeset
|
111 |
fprintf(stderr, "%s\n", str); |
0 | 112 |
} |
113 |
||
114 |
void ShowOSErrorBox(const char *buf) |
|
115 |
{ |
|
2731
97a409a62741
(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
|
116 |
#if defined(__APPLE__) |
9574 | 117 |
/* this creates an NSAlertPanel with the contents of 'buf' |
118 |
* this is the native and nicest way to do this on OSX */ |
|
2188
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
2186
diff
changeset
|
119 |
ShowMacDialog( buf, "See readme for more info\nMost likely you are missing files from the original TTD", "Quit" ); |
529
3b23d5073d32
(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
|
120 |
#else |
9574 | 121 |
/* all systems, but OSX */ |
0 | 122 |
fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf); |
123 |
#endif |
|
124 |
} |
|
125 |
||
2736
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
126 |
#ifdef WITH_COCOA |
6573 | 127 |
void cocoaSetupAutoreleasePool(); |
128 |
void cocoaReleaseAutoreleasePool(); |
|
2736
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
129 |
#endif |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
130 |
|
0 | 131 |
int CDECL main(int argc, char* argv[]) |
132 |
{ |
|
2736
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
133 |
int ret; |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
134 |
|
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
135 |
#ifdef WITH_COCOA |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
136 |
cocoaSetupAutoreleasePool(); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3408
diff
changeset
|
137 |
/* This is passed if we are launched by double-clicking */ |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3408
diff
changeset
|
138 |
if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) { |
2736
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
139 |
argv[1] = NULL; |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
140 |
argc = 1; |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
141 |
} |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
142 |
#endif |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
143 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9625
diff
changeset
|
144 |
SetRandomSeed(time(NULL)); |
0 | 145 |
|
1509
2c232b7d2114
(svn r2013) Always ignore SIGPIPE, not only when SDL is used (ShadowJK)
tron
parents:
1508
diff
changeset
|
146 |
signal(SIGPIPE, SIG_IGN); |
0 | 147 |
|
2736
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
148 |
ret = ttd_main(argc, argv); |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
149 |
|
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
150 |
#ifdef WITH_COCOA |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
151 |
cocoaReleaseAutoreleasePool(); |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
152 |
#endif |
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
153 |
|
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2731
diff
changeset
|
154 |
return ret; |
0 | 155 |
} |
156 |
||
1470
25c332b43280
(svn r1974) Cleanups, quite similar to those done to win32.c in r1972 (code duplication, anyone?)
tron
parents:
1449
diff
changeset
|
157 |
bool InsertTextBufferClipboard(Textbuf *tb) |
25c332b43280
(svn r1974) Cleanups, quite similar to those done to win32.c in r1972 (code duplication, anyone?)
tron
parents:
1449
diff
changeset
|
158 |
{ |
25c332b43280
(svn r1974) Cleanups, quite similar to those done to win32.c in r1972 (code duplication, anyone?)
tron
parents:
1449
diff
changeset
|
159 |
return false; |
25c332b43280
(svn r1974) Cleanups, quite similar to those done to win32.c in r1972 (code duplication, anyone?)
tron
parents:
1449
diff
changeset
|
160 |
} |
1885
4ce583a5275b
(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
|
161 |
|
2073 | 162 |
|
9574 | 163 |
/* multi os compatible sleep function */ |
2073 | 164 |
|
165 |
#ifdef __AMIGA__ |
|
9574 | 166 |
/* usleep() implementation */ |
2073 | 167 |
# include <devices/timer.h> |
168 |
# include <dos/dos.h> |
|
169 |
||
170 |
extern struct Device *TimerBase = NULL; |
|
171 |
extern struct MsgPort *TimerPort = NULL; |
|
172 |
extern struct timerequest *TimerRequest = NULL; |
|
173 |
#endif // __AMIGA__ |
|
174 |
||
175 |
void CSleep(int milliseconds) |
|
176 |
{ |
|
6348
7bba1ade34a8
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
6192
diff
changeset
|
177 |
#if defined(PSP) |
7bba1ade34a8
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
6192
diff
changeset
|
178 |
sceKernelDelayThread(milliseconds * 1000); |
7bba1ade34a8
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
6192
diff
changeset
|
179 |
#elif defined(__BEOS__) |
2073 | 180 |
snooze(milliseconds * 1000); |
6348
7bba1ade34a8
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
6192
diff
changeset
|
181 |
#elif defined(__AMIGA__) |
2073 | 182 |
{ |
183 |
ULONG signals; |
|
184 |
ULONG TimerSigBit = 1 << TimerPort->mp_SigBit; |
|
185 |
||
9574 | 186 |
/* send IORequest */ |
2073 | 187 |
TimerRequest->tr_node.io_Command = TR_ADDREQUEST; |
188 |
TimerRequest->tr_time.tv_secs = (milliseconds * 1000) / 1000000; |
|
189 |
TimerRequest->tr_time.tv_micro = (milliseconds * 1000) % 1000000; |
|
190 |
SendIO((struct IORequest *)TimerRequest); |
|
191 |
||
192 |
if (!((signals = Wait(TimerSigBit | SIGBREAKF_CTRL_C)) & TimerSigBit) ) { |
|
193 |
AbortIO((struct IORequest *)TimerRequest); |
|
194 |
} |
|
195 |
WaitIO((struct IORequest *)TimerRequest); |
|
196 |
} |
|
6348
7bba1ade34a8
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
6192
diff
changeset
|
197 |
#else |
7bba1ade34a8
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
6192
diff
changeset
|
198 |
usleep(milliseconds * 1000); |
7bba1ade34a8
(svn r8745) [PSP] -Add: added a CSleep() for PSP
truelight
parents:
6192
diff
changeset
|
199 |
#endif |
2073 | 200 |
} |
3260
7d22aa47de3b
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
201 |
|
3329
992d1f7cb747
(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 |
#ifdef WITH_ICONV |
992d1f7cb747
(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 |
|
3332
fd5624e59753
(svn r4109) - Fix (r4105) [iconv]: Only include the needed headers when ICONV is actually used. Thanks for noticing Bjarni
Darkvater
parents:
3330
diff
changeset
|
204 |
#include <iconv.h> |
fd5624e59753
(svn r4109) - Fix (r4105) [iconv]: Only include the needed headers when ICONV is actually used. Thanks for noticing Bjarni
Darkvater
parents:
3330
diff
changeset
|
205 |
#include <errno.h> |
fd5624e59753
(svn r4109) - Fix (r4105) [iconv]: Only include the needed headers when ICONV is actually used. Thanks for noticing Bjarni
Darkvater
parents:
3330
diff
changeset
|
206 |
#include "debug.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
207 |
#include "string_func.h" |
3332
fd5624e59753
(svn r4109) - Fix (r4105) [iconv]: Only include the needed headers when ICONV is actually used. Thanks for noticing Bjarni
Darkvater
parents:
3330
diff
changeset
|
208 |
|
10355
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
9724
diff
changeset
|
209 |
const char *GetCurrentLocale(const char *param); |
ee4b5f7a5bf2
(svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents:
9724
diff
changeset
|
210 |
|
5108
dc67d70b5a45
(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
|
211 |
#define INTERNALCODE "UTF-8" |
3329
992d1f7cb747
(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 |
|
992d1f7cb747
(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 |
/** Try and try to decipher the current locale from environmental |
992d1f7cb747
(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
|
214 |
* variables. MacOSX is hardcoded, other OS's are dynamic. If no suitable |
992d1f7cb747
(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 |
* locale can be found, don't do any conversion "" */ |
6573 | 216 |
static const char *GetLocalCode() |
3260
7d22aa47de3b
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
217 |
{ |
3408
313f35564673
(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
|
218 |
#if defined(__APPLE__) |
3329
992d1f7cb747
(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 |
return "UTF-8-MAC"; |
992d1f7cb747
(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 |
#else |
992d1f7cb747
(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 |
/* Strip locale (eg en_US.UTF-8) to only have UTF-8 */ |
992d1f7cb747
(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 |
const char *locale = GetCurrentLocale("LC_CTYPE"); |
992d1f7cb747
(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 |
if (locale != NULL) locale = strchr(locale, '.'); |
3260
7d22aa47de3b
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
224 |
|
3329
992d1f7cb747
(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 |
return (locale == NULL) ? "" : locale + 1; |
992d1f7cb747
(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 |
#endif |
992d1f7cb747
(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 |
} |
992d1f7cb747
(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 |
|
992d1f7cb747
(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 |
/** FYI: This is not thread-safe. |
992d1f7cb747
(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 |
* convert between locales, which from and which to is set in the calling |
992d1f7cb747
(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 |
* functions OTTD2FS() and FS2OTTD(). You should NOT use this function directly |
992d1f7cb747
(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 |
* NOTE: iconv was added in OSX 10.3. 10.2.x will still have the invalid char |
992d1f7cb747
(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 |
* issues. There aren't any easy fix for this */ |
992d1f7cb747
(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 |
static const char *convert_tofrom_fs(iconv_t convd, const char *name) |
992d1f7cb747
(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 |
{ |
992d1f7cb747
(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 |
static char buf[1024]; |
992d1f7cb747
(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 |
/* Work around buggy iconv implementation where inbuf is wrongly typed as |
992d1f7cb747
(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 |
* non-const. Correct implementation is at |
992d1f7cb747
(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 |
* http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.html */ |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9625
diff
changeset
|
240 |
#ifdef HAVE_BROKEN_ICONV |
3329
992d1f7cb747
(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 |
char *inbuf = (char*)name; |
992d1f7cb747
(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 |
#else |
992d1f7cb747
(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 |
const char *inbuf = name; |
992d1f7cb747
(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
|
244 |
#endif |
992d1f7cb747
(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
|
245 |
|
992d1f7cb747
(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 |
char *outbuf = buf; |
992d1f7cb747
(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 |
size_t outlen = sizeof(buf) - 1; |
992d1f7cb747
(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
|
248 |
size_t inlen = strlen(name); |
992d1f7cb747
(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 |
|
992d1f7cb747
(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
|
250 |
ttd_strlcpy(outbuf, name, sizeof(buf)); |
992d1f7cb747
(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 |
|
992d1f7cb747
(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 |
iconv(convd, NULL, NULL, NULL, NULL); |
992d1f7cb747
(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 |
if (iconv(convd, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1)) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
254 |
DEBUG(misc, 0, "[iconv] error converting '%s'. Errno %d", name, errno); |
3260
7d22aa47de3b
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
255 |
} |
3329
992d1f7cb747
(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 |
|
992d1f7cb747
(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 |
*outbuf = '\0'; |
9574 | 258 |
/* FIX: invalid characters will abort conversion, but they shouldn't occur? */ |
3329
992d1f7cb747
(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 |
return buf; |
3260
7d22aa47de3b
(svn r3966) -Fix: [OSX and some linux] [ 1157244 ] Can't save game if name contains german umlauts
bjarni
parents:
2952
diff
changeset
|
260 |
} |
3329
992d1f7cb747
(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 |
|
992d1f7cb747
(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 |
/** Convert from OpenTTD's encoding to that of the local environment |
992d1f7cb747
(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
|
263 |
* @param name pointer to a valid string that will be converted |
992d1f7cb747
(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 pointer to a new stringbuffer that contains the converted string */ |
992d1f7cb747
(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 |
const char *OTTD2FS(const char *name) |
992d1f7cb747
(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 |
{ |
992d1f7cb747
(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 |
static iconv_t convd = (iconv_t)(-1); |
992d1f7cb747
(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 |
|
992d1f7cb747
(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 |
if (convd == (iconv_t)(-1)) { |
992d1f7cb747
(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 |
const char *env = GetLocalCode(); |
992d1f7cb747
(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 |
convd = iconv_open(env, INTERNALCODE); |
992d1f7cb747
(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 |
if (convd == (iconv_t)(-1)) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
273 |
DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", INTERNALCODE, env); |
3329
992d1f7cb747
(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 |
return name; |
992d1f7cb747
(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 |
} |
992d1f7cb747
(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 |
} |
992d1f7cb747
(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 |
|
992d1f7cb747
(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 |
return convert_tofrom_fs(convd, name); |
992d1f7cb747
(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 |
} |
992d1f7cb747
(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 |
|
992d1f7cb747
(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 |
/** Convert to OpenTTD's encoding from that of the local environment |
992d1f7cb747
(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
|
282 |
* @param name pointer to a valid string that will be converted |
992d1f7cb747
(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 pointer to a new stringbuffer that contains the converted string */ |
992d1f7cb747
(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 |
const char *FS2OTTD(const char *name) |
992d1f7cb747
(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 |
{ |
992d1f7cb747
(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 |
static iconv_t convd = (iconv_t)(-1); |
992d1f7cb747
(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 |
|
992d1f7cb747
(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 |
if (convd == (iconv_t)(-1)) { |
992d1f7cb747
(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 |
const char *env = GetLocalCode(); |
992d1f7cb747
(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 |
convd = iconv_open(INTERNALCODE, env); |
992d1f7cb747
(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 |
if (convd == (iconv_t)(-1)) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5296
diff
changeset
|
292 |
DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", env, INTERNALCODE); |
3329
992d1f7cb747
(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 |
return name; |
992d1f7cb747
(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
|
294 |
} |
992d1f7cb747
(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
|
295 |
} |
992d1f7cb747
(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
|
296 |
|
992d1f7cb747
(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
|
297 |
return convert_tofrom_fs(convd, name); |
992d1f7cb747
(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
|
298 |
} |
992d1f7cb747
(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
|
299 |
|
992d1f7cb747
(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
|
300 |
#else |
992d1f7cb747
(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
|
301 |
const char *FS2OTTD(const char *name) {return name;} |
992d1f7cb747
(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
|
302 |
const char *OTTD2FS(const char *name) {return name;} |
992d1f7cb747
(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
|
303 |
#endif /* WITH_ICONV */ |