author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9470 | 08424e2e79e4 |
child 10040 | ea25953ada79 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8264
diff
changeset
|
3 |
/** @file os2.cpp OS2 related OS support. */ |
6351
8d0b6cce8d6d
(svn r9390) -Documentation : correct Doxygen of comments and @file inclusion. This time, brought to you by the letter O
belugas
parents:
6318
diff
changeset
|
4 |
|
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
5 |
#include "stdafx.h" |
1892
8717d92b32b1
(svn r2398) - CodeChange: forgot to update unix and os2 specific files as well.
Darkvater
parents:
1890
diff
changeset
|
6 |
#include "openttd.h" |
2167
5686131337a4
(svn r2681) - Fix OS/2 port, please do not modify openttd.wpj/tgt by hand unless you know what you're doing!
orudge
parents:
2099
diff
changeset
|
7 |
#include "variables.h" |
1888
dac7806032f8
(svn r2394) - Completed clipboard functions for OS/2 port
orudge
parents:
1887
diff
changeset
|
8 |
#include "gui.h" |
6298
01c80746f308
(svn r9129) -Codechange: unify parts of DeterminePaths.
rubidium
parents:
6247
diff
changeset
|
9 |
#include "fileio.h" |
7045
5d5306f074db
(svn r10310) -Fix: Trunk can now be built on OS/2 :)
orudge
parents:
6492
diff
changeset
|
10 |
#include "fios.h" // opendir/readdir/closedir |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8121
diff
changeset
|
11 |
#include "functions.h" |
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8121
diff
changeset
|
12 |
#include "core/random_func.hpp" |
8250
900ec4fbafb5
(svn r11814) -Fix: Get OpenTTD compiling again on OS/2
orudge
parents:
8214
diff
changeset
|
13 |
#include "string_func.h" |
900ec4fbafb5
(svn r11814) -Fix: Get OpenTTD compiling again on OS/2
orudge
parents:
8214
diff
changeset
|
14 |
#include "textbuf_gui.h" |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
15 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8250
diff
changeset
|
16 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8250
diff
changeset
|
17 |
|
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
18 |
#include <dirent.h> |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
19 |
#include <unistd.h> |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
20 |
#include <sys/stat.h> |
1887 | 21 |
#include <stdlib.h> |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
22 |
#include <time.h> |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
23 |
#ifndef __INNOTEK_LIBC__ |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
24 |
#include <dos.h> |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
25 |
#endif |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
26 |
|
818
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
27 |
#define INCL_WIN |
1524
d5cb3a8cfddc
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
28 |
#define INCL_WINCLIPBOARD |
810
a1494b19bd2a
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
29 |
|
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
30 |
#include <os2.h> |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
31 |
#ifndef __INNOTEK_LIBC__ |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
32 |
#include <i86.h> |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
33 |
#endif |
2167
5686131337a4
(svn r2681) - Fix OS/2 port, please do not modify openttd.wpj/tgt by hand unless you know what you're doing!
orudge
parents:
2099
diff
changeset
|
34 |
|
4223
d4c9ef555f43
(svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents:
4222
diff
changeset
|
35 |
bool FiosIsRoot(const char *file) |
810
a1494b19bd2a
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
36 |
{ |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
37 |
return file[3] == '\0'; |
810
a1494b19bd2a
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
38 |
} |
a1494b19bd2a
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
39 |
|
6247 | 40 |
void FiosGetDrives() |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
41 |
{ |
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
|
42 |
unsigned disk, disk2, save, total; |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
43 |
|
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
44 |
#ifndef __INNOTEK_LIBC__ |
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
|
45 |
_dos_getdrive(&save); // save original drive |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
46 |
#else |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
47 |
save = _getdrive(); // save original drive |
7302
4642431b4413
(svn r10651) -Fix: Fix chdir problem with open/save dialog on OS/2 (Paul Smedley)
orudge
parents:
7045
diff
changeset
|
48 |
char wd[MAX_PATH]; |
4642431b4413
(svn r10651) -Fix: Fix chdir problem with open/save dialog on OS/2 (Paul Smedley)
orudge
parents:
7045
diff
changeset
|
49 |
getcwd(wd, MAX_PATH); |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
50 |
total = 'z'; |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
51 |
#endif |
1486
647d3a2be4fe
(svn r1990) Reduce the diff between the OS specific files with respect to file handling and fix some inconsitencies (I hope I didn't break the OS/2 part, couldn't test it, feedback is welcome)
tron
parents:
1482
diff
changeset
|
52 |
|
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
|
53 |
/* get an available drive letter */ |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
54 |
#ifndef __INNOTEK_LIBC__ |
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
|
55 |
for (disk = 1;; disk++) { |
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 |
_dos_setdrive(disk, &total); |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
57 |
#else |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
58 |
for (disk = 'A';; disk++) { |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
59 |
_chdrive(disk); |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
60 |
#endif |
7302
4642431b4413
(svn r10651) -Fix: Fix chdir problem with open/save dialog on OS/2 (Paul Smedley)
orudge
parents:
7045
diff
changeset
|
61 |
if (disk >= total) break; |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
62 |
|
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
63 |
#ifndef __INNOTEK_LIBC__ |
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
|
64 |
_dos_getdrive(&disk2); |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
65 |
#else |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
66 |
disk2 = _getdrive(); |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
67 |
#endif |
2099
02c5a49863e9
(svn r2609) - Feature: remove extension from savegames/scenarios when browsing the folders.
Darkvater
parents:
1893
diff
changeset
|
68 |
|
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
|
69 |
if (disk == disk2) { |
9443 | 70 |
FiosItem *fios = _fios_items.Append(); |
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
|
71 |
fios->type = FIOS_TYPE_DRIVE; |
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
|
72 |
fios->mtime = 0; |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
73 |
#ifndef __INNOTEK_LIBC__ |
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
|
74 |
snprintf(fios->name, lengthof(fios->name), "%c:", 'A' + disk - 1); |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
75 |
#else |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
76 |
snprintf(fios->name, lengthof(fios->name), "%c:", disk); |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
77 |
#endif |
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
|
78 |
ttd_strlcpy(fios->title, fios->name, lengthof(fios->title)); |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
79 |
} |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
80 |
} |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
81 |
|
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
82 |
/* Restore the original drive */ |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
83 |
#ifndef __INNOTEK_LIBC__ |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
84 |
_dos_setdrive(save, &total); |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
85 |
#else |
7302
4642431b4413
(svn r10651) -Fix: Fix chdir problem with open/save dialog on OS/2 (Paul Smedley)
orudge
parents:
7045
diff
changeset
|
86 |
chdir(wd); |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
87 |
#endif |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
88 |
} |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
89 |
|
4222
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
90 |
bool FiosGetDiskFreeSpace(const char *path, uint32 *tot) |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
91 |
{ |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
92 |
#ifndef __INNOTEK_LIBC__ |
4222
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
93 |
struct diskfree_t free; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
94 |
char drive = path[0] - 'A' + 1; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
95 |
|
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
96 |
if (tot != NULL && _getdiskfree(drive, &free) == 0) { |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
97 |
*tot = free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
98 |
return true; |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
99 |
} |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
100 |
|
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
101 |
return false; |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
102 |
#else |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
103 |
uint32 free = 0; |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
104 |
|
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
105 |
#ifdef HAS_STATVFS |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
106 |
{ |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
107 |
struct statvfs s; |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
108 |
|
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
109 |
if (statvfs(path, &s) != 0) return false; |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
110 |
free = (uint64)s.f_frsize * s.f_bavail >> 20; |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
111 |
} |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
112 |
#endif |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
113 |
if (tot != NULL) *tot = free; |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
114 |
return true; |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
115 |
#endif |
4222
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
116 |
} |
36e9bd216011
(svn r5766) - Cleanup: Unify FiosBrowseTo and FiosGetDescText
Darkvater
parents:
4221
diff
changeset
|
117 |
|
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
|
118 |
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb) |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
119 |
{ |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
120 |
char filename[MAX_PATH]; |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
121 |
|
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
|
122 |
snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name); |
6240
9d9874ef9f0b
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
5591
diff
changeset
|
123 |
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:
5591
diff
changeset
|
124 |
} |
1486
647d3a2be4fe
(svn r1990) Reduce the diff between the OS specific files with respect to file handling and fix some inconsitencies (I hope I didn't break the OS/2 part, couldn't test it, feedback is welcome)
tron
parents:
1482
diff
changeset
|
125 |
|
6240
9d9874ef9f0b
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
5591
diff
changeset
|
126 |
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:
5591
diff
changeset
|
127 |
{ |
9d9874ef9f0b
(svn r9043) -Fix [FS#652]: the personal (.openttd) directories were hidden in the load/save directory listings (stepancheg).
rubidium
parents:
5591
diff
changeset
|
128 |
return ent->d_name[0] == '.'; |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
129 |
} |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
130 |
|
7045
5d5306f074db
(svn r10310) -Fix: Trunk can now be built on OS/2 :)
orudge
parents:
6492
diff
changeset
|
131 |
void ShowInfo(const char *str) |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
132 |
{ |
818
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
133 |
HAB hab; |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
134 |
HMQ hmq; |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
135 |
ULONG rc; |
915 | 136 |
|
818
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
137 |
// init PM env. |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
138 |
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0); |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
139 |
|
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
140 |
// display the box |
7045
5d5306f074db
(svn r10310) -Fix: Trunk can now be built on OS/2 :)
orudge
parents:
6492
diff
changeset
|
141 |
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)str, (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_INFORMATION); |
818
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
142 |
|
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
143 |
// terminate PM env. |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
144 |
WinDestroyMsgQueue(hmq); |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
145 |
WinTerminate(hab); |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
146 |
} |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
147 |
|
9470
08424e2e79e4
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
glx
parents:
9443
diff
changeset
|
148 |
void ShowOSErrorBox(const char *buf, bool system) |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
149 |
{ |
818
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
150 |
HAB hab; |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
151 |
HMQ hmq; |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
152 |
ULONG rc; |
915 | 153 |
|
818
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
154 |
// init PM env. |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
155 |
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0); |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
156 |
|
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
157 |
// display the box |
7045
5d5306f074db
(svn r10310) -Fix: Trunk can now be built on OS/2 :)
orudge
parents:
6492
diff
changeset
|
158 |
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (const unsigned char *)buf, (const unsigned char *)"OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_ERROR); |
818
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
159 |
|
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
160 |
// terminate PM env. |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
161 |
WinDestroyMsgQueue(hmq); |
546a7894f312
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
162 |
WinTerminate(hab); |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
163 |
} |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
164 |
|
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
165 |
int CDECL main(int argc, char* argv[]) |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
166 |
{ |
7935
c2d1b2f4ecd6
(svn r11488) -Codechange: Spilt the random functions out to seperate file
skidd13
parents:
7372
diff
changeset
|
167 |
SetRandomSeed(time(NULL)); |
801
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
168 |
|
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
169 |
return ttd_main(argc, argv); |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
170 |
} |
7b6cb481359c
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
171 |
|
1888
dac7806032f8
(svn r2394) - Completed clipboard functions for OS/2 port
orudge
parents:
1887
diff
changeset
|
172 |
/** |
dac7806032f8
(svn r2394) - Completed clipboard functions for OS/2 port
orudge
parents:
1887
diff
changeset
|
173 |
* Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard |
dac7806032f8
(svn r2394) - Completed clipboard functions for OS/2 port
orudge
parents:
1887
diff
changeset
|
174 |
* and append this up to the maximum length (either absolute or screenlength). If maxlength |
dac7806032f8
(svn r2394) - Completed clipboard functions for OS/2 port
orudge
parents:
1887
diff
changeset
|
175 |
* is zero, we don't care about the screenlength but only about the physical length of the string |
6483
ae78fc3c6b20
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents:
6351
diff
changeset
|
176 |
* @param tb Textbuf type to be changed |
7372
6fac48ff7c4d
(svn r10736) -Fix: Correct all mispellings of 'successful'.
peter1138
parents:
7302
diff
changeset
|
177 |
* @return Return true on successful change of Textbuf, or false otherwise |
1888
dac7806032f8
(svn r2394) - Completed clipboard functions for OS/2 port
orudge
parents:
1887
diff
changeset
|
178 |
*/ |
1486
647d3a2be4fe
(svn r1990) Reduce the diff between the OS specific files with respect to file handling and fix some inconsitencies (I hope I didn't break the OS/2 part, couldn't test it, feedback is welcome)
tron
parents:
1482
diff
changeset
|
179 |
bool InsertTextBufferClipboard(Textbuf *tb) |
647d3a2be4fe
(svn r1990) Reduce the diff between the OS specific files with respect to file handling and fix some inconsitencies (I hope I didn't break the OS/2 part, couldn't test it, feedback is welcome)
tron
parents:
1482
diff
changeset
|
180 |
{ |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
181 |
/* XXX -- Currently no clipboard support implemented with GCC */ |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
182 |
#ifndef __INNOTEK_LIBC__ |
1893
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
183 |
HAB hab = 0; |
1524
d5cb3a8cfddc
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
184 |
|
d5cb3a8cfddc
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
185 |
if (WinOpenClipbrd(hab)) |
d5cb3a8cfddc
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
186 |
{ |
1893
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
187 |
const char* text = (const char*)WinQueryClipbrdData(hab, CF_TEXT); |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
188 |
|
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
189 |
if (text != NULL) |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
190 |
{ |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
191 |
uint length = 0; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
192 |
uint width = 0; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
193 |
const char* i; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
194 |
|
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
195 |
for (i = text; IsValidAsciiChar(*i); i++) |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
196 |
{ |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
197 |
uint w; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
198 |
|
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
199 |
if (tb->length + length >= tb->maxlength - 1) break; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
200 |
|
3800
75a58f751bfe
(svn r4808) - Fix GetCharacterWidth() change in os2.c missed in r4802.
peter1138
parents:
3329
diff
changeset
|
201 |
w = GetCharacterWidth(FS_NORMAL, (byte)*i); |
1893
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
202 |
if (tb->maxwidth != 0 && width + tb->width + w > tb->maxwidth) break; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
203 |
|
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
204 |
width += w; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
205 |
length++; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
206 |
} |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
207 |
|
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
208 |
memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->length - tb->caretpos + 1); |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
209 |
memcpy(tb->buf + tb->caretpos, text, length); |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
210 |
tb->width += width; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
211 |
tb->caretxoffs += width; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
212 |
tb->length += length; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
213 |
tb->caretpos += length; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
214 |
|
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
215 |
WinCloseClipbrd(hab); |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
216 |
return true; |
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
217 |
} |
1888
dac7806032f8
(svn r2394) - Completed clipboard functions for OS/2 port
orudge
parents:
1887
diff
changeset
|
218 |
|
1524
d5cb3a8cfddc
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
219 |
WinCloseClipbrd(hab); |
d5cb3a8cfddc
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
220 |
} |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
221 |
#endif |
1893
99e4c49938af
(svn r2399) - Fix: Update OS/2 project file with filename changes
orudge
parents:
1892
diff
changeset
|
222 |
return false; |
1486
647d3a2be4fe
(svn r1990) Reduce the diff between the OS specific files with respect to file handling and fix some inconsitencies (I hope I didn't break the OS/2 part, couldn't test it, feedback is welcome)
tron
parents:
1482
diff
changeset
|
223 |
} |
1887 | 224 |
|
2167
5686131337a4
(svn r2681) - Fix OS/2 port, please do not modify openttd.wpj/tgt by hand unless you know what you're doing!
orudge
parents:
2099
diff
changeset
|
225 |
|
5686131337a4
(svn r2681) - Fix OS/2 port, please do not modify openttd.wpj/tgt by hand unless you know what you're doing!
orudge
parents:
2099
diff
changeset
|
226 |
void CSleep(int milliseconds) |
5686131337a4
(svn r2681) - Fix OS/2 port, please do not modify openttd.wpj/tgt by hand unless you know what you're doing!
orudge
parents:
2099
diff
changeset
|
227 |
{ |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
228 |
#ifndef __INNOTEK_LIBC__ |
6492
286a52449b54
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents:
6483
diff
changeset
|
229 |
delay(milliseconds); |
5591
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
230 |
#else |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
231 |
usleep(milliseconds * 1000); |
51e4c59c31dd
(svn r8042) - Fix: OS/2 compilation with GCC (thanks to Paul Smedley and TrueBrain for their help)
orudge
parents:
5584
diff
changeset
|
232 |
#endif |
2167
5686131337a4
(svn r2681) - Fix OS/2 port, please do not modify openttd.wpj/tgt by hand unless you know what you're doing!
orudge
parents:
2099
diff
changeset
|
233 |
} |
5167
12c46fb7eccf
(svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents:
4369
diff
changeset
|
234 |
|
12c46fb7eccf
(svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents:
4369
diff
changeset
|
235 |
const char *FS2OTTD(const char *name) {return name;} |
12c46fb7eccf
(svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents:
4369
diff
changeset
|
236 |
const char *OTTD2FS(const char *name) {return name;} |