author | tron |
Sun, 27 Mar 2005 10:35:01 +0000 | |
changeset 1580 | 0064c283b59b |
parent 1572 | 6d0111113f0b |
child 1596 | c1c439a2d5b2 |
permissions | -rw-r--r-- |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
1 |
#include "stdafx.h" |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
2 |
#include "ttd.h" |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1346
diff
changeset
|
3 |
#include "window.h" |
1317
f382f1b439c7
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
1301
diff
changeset
|
4 |
#include "string.h" |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
5 |
#include "table/strings.h" |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
6 |
#include "hal.h" |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
7 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
8 |
#include <direct.h> |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
9 |
#include <unistd.h> |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
10 |
#include <sys/stat.h> |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
11 |
#include <stdarg.h> |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
12 |
#include <time.h> |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
13 |
#include <dos.h> |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
14 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
15 |
#define INCL_DOS |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
16 |
#define INCL_OS2MM |
818
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
17 |
#define INCL_WIN |
1524
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
18 |
#define INCL_WINCLIPBOARD |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
19 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
20 |
#include <os2.h> |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
21 |
#include <os2me.h> |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
22 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
23 |
#if defined(WITH_SDL) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
24 |
#include <SDL.h> |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
25 |
#endif |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
26 |
|
1486
6a31e3d7dfe3
(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
|
27 |
static inline int strcasecmp(const char* s1, const char* s2) |
6a31e3d7dfe3
(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
|
28 |
{ |
6a31e3d7dfe3
(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
|
29 |
return stricmp(s1, s2); |
6a31e3d7dfe3
(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
|
30 |
} |
6a31e3d7dfe3
(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
|
31 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
32 |
static char *_fios_path; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
33 |
static char *_fios_save_path; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
34 |
static char *_fios_scn_path; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
35 |
static FiosItem *_fios_items; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
36 |
static int _fios_count, _fios_alloc; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
37 |
|
1486
6a31e3d7dfe3
(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
|
38 |
static FiosItem *FiosAlloc(void) |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
39 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
40 |
if (_fios_count == _fios_alloc) { |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
41 |
_fios_alloc += 256; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
42 |
_fios_items = realloc(_fios_items, _fios_alloc * sizeof(FiosItem)); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
43 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
44 |
return &_fios_items[_fios_count++]; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
45 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
46 |
|
1486
6a31e3d7dfe3
(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
|
47 |
int compare_FiosItems(const void *a, const void *b) |
6a31e3d7dfe3
(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
|
48 |
{ |
6a31e3d7dfe3
(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
|
49 |
const FiosItem *da = (const FiosItem *)a; |
6a31e3d7dfe3
(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
|
50 |
const FiosItem *db = (const FiosItem *)b; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
51 |
int r; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
52 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
53 |
if (_savegame_sort_order < 2) // sort by date |
1486
6a31e3d7dfe3
(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
|
54 |
r = da->mtime < db->mtime ? -1 : 1; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
55 |
else |
1486
6a31e3d7dfe3
(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
|
56 |
r = strcasecmp( |
6a31e3d7dfe3
(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
|
57 |
da->title[0] != '\0' ? da->title : da->name, |
6a31e3d7dfe3
(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
|
58 |
db->title[0] != '\0' ? db->title : db->name |
6a31e3d7dfe3
(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
|
59 |
); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
60 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
61 |
if (_savegame_sort_order & 1) r = -r; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
62 |
return r; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
63 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
64 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
65 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
66 |
static DIR *my_opendir(char *path, char *file) |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
67 |
{ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
68 |
char paths[MAX_PATH]; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
69 |
|
915 | 70 |
append_path(paths, path, file); |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
71 |
return opendir(paths); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
72 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
73 |
|
1486
6a31e3d7dfe3
(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
|
74 |
static void append_path(char *out, const char *path, const char *file) |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
75 |
{ |
1486
6a31e3d7dfe3
(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
|
76 |
if (path[2] == '\\' && path[3] == '\0') |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
77 |
sprintf(out, "%s%s", path, file); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
78 |
else |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
79 |
sprintf(out, "%s\\%s", path, file); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
80 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
81 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
82 |
// Get a list of savegames |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
83 |
FiosItem *FiosGetSavegameList(int *num, int mode) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
84 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
85 |
FiosItem *fios; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
86 |
DIR *dir; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
87 |
struct dirent *dirent; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
88 |
struct stat sb; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
89 |
int sort_start; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
90 |
char filename[MAX_PATH]; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
91 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
92 |
if (_fios_save_path == NULL) { |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
93 |
_fios_save_path = malloc(MAX_PATH); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
94 |
strcpy(_fios_save_path, _path.save_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
95 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
96 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
97 |
if (_game_mode == GM_EDITOR) |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
98 |
_fios_path = _fios_scn_path; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
99 |
else |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
100 |
_fios_path = _fios_save_path; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
101 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
102 |
// Parent directory, only if not of the type C:\. |
1486
6a31e3d7dfe3
(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
|
103 |
if (_fios_path[3] != '\0') { |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
104 |
fios = FiosAlloc(); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
105 |
fios->type = FIOS_TYPE_PARENT; |
1486
6a31e3d7dfe3
(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
|
106 |
fios->mtime = 0; |
1572
6d0111113f0b
(svn r2076) Set the name for the parent directory to ".."
tron
parents:
1524
diff
changeset
|
107 |
strcpy(fios->name, ".."); |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
108 |
strcpy(fios->title, ".. (Parent directory)"); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
109 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
110 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
111 |
// Show subdirectories first |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
112 |
dir = my_opendir(_fios_path, "*.*"); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
113 |
if (dir != NULL) { |
1486
6a31e3d7dfe3
(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
|
114 |
while ((dirent = readdir(dir)) != NULL) { |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
115 |
append_path(filename, _fios_path, dirent->d_name); |
1486
6a31e3d7dfe3
(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
|
116 |
if (!stat(filename, &sb) && S_ISDIR(sb.st_mode) && |
1506
c3985c29d018
(svn r2010) - Fix: [ 1162209 ] Fix OS/2 build (orudge)
darkvater
parents:
1495
diff
changeset
|
117 |
strcmp(filename, ".") != 0 && |
c3985c29d018
(svn r2010) - Fix: [ 1162209 ] Fix OS/2 build (orudge)
darkvater
parents:
1495
diff
changeset
|
118 |
strcmp(filename, "..") != 0) { |
1486
6a31e3d7dfe3
(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
|
119 |
fios = FiosAlloc(); |
6a31e3d7dfe3
(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
|
120 |
fios->type = FIOS_TYPE_DIR; |
6a31e3d7dfe3
(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
|
121 |
fios->mtime = 0; |
6a31e3d7dfe3
(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
|
122 |
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name)); |
6a31e3d7dfe3
(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
|
123 |
snprintf(fios->title, lengthof(fios->title), |
6a31e3d7dfe3
(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
|
124 |
"%s\\ (Directory)", dirent->d_name); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
125 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
126 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
127 |
closedir(dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
128 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
129 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
130 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
131 |
/* XXX ugly global variables ... */ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
132 |
byte order = _savegame_sort_order; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
133 |
_savegame_sort_order = 2; // sort ascending by name |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
134 |
qsort(_fios_items, _fios_count, sizeof(FiosItem), compare_FiosItems); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
135 |
_savegame_sort_order = order; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
136 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
137 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
138 |
// this is where to start sorting |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
139 |
sort_start = _fios_count; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
140 |
|
1486
6a31e3d7dfe3
(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
|
141 |
/* Show savegame files |
6a31e3d7dfe3
(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
|
142 |
* .SAV OpenTTD saved game |
6a31e3d7dfe3
(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
|
143 |
* .SS1 Transport Tycoon Deluxe preset game |
6a31e3d7dfe3
(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
|
144 |
* .SV1 Transport Tycoon Deluxe (Patch) saved game |
6a31e3d7dfe3
(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
|
145 |
* .SV2 Transport Tycoon Deluxe (Patch) saved 2-player game |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
146 |
*/ |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
147 |
dir = my_opendir(_fios_path, "*.*"); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
148 |
if (dir != NULL) { |
1486
6a31e3d7dfe3
(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
|
149 |
while ((dirent = readdir(dir)) != NULL) { |
6a31e3d7dfe3
(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
|
150 |
char *t; |
6a31e3d7dfe3
(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
|
151 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
152 |
append_path(filename, _fios_path, dirent->d_name); |
1486
6a31e3d7dfe3
(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
|
153 |
if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue; |
6a31e3d7dfe3
(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
|
154 |
|
6a31e3d7dfe3
(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
|
155 |
t = strrchr(dirent->d_name, '.'); |
6a31e3d7dfe3
(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
|
156 |
if (t != NULL && strcasecmp(t, ".sav") == 0) { // OpenTTD |
6a31e3d7dfe3
(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
|
157 |
fios = FiosAlloc(); |
6a31e3d7dfe3
(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
|
158 |
fios->type = FIOS_TYPE_FILE; |
6a31e3d7dfe3
(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
|
159 |
fios->mtime = sb.st_mtime; |
6a31e3d7dfe3
(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
|
160 |
fios->title[0] = '\0'; |
6a31e3d7dfe3
(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
|
161 |
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name)); |
6a31e3d7dfe3
(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
|
162 |
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) { |
6a31e3d7dfe3
(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
|
163 |
if (t != NULL && ( |
6a31e3d7dfe3
(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
|
164 |
strcasecmp(t, ".ss1") == 0 || |
6a31e3d7dfe3
(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
|
165 |
strcasecmp(t, ".sv1") == 0 || |
6a31e3d7dfe3
(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
|
166 |
strcasecmp(t, ".sv2") == 0 |
6a31e3d7dfe3
(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
|
167 |
)) { // TTDLX(Patch) |
6a31e3d7dfe3
(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
|
168 |
fios = FiosAlloc(); |
6a31e3d7dfe3
(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
|
169 |
fios->type = FIOS_TYPE_OLDFILE; |
6a31e3d7dfe3
(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
|
170 |
fios->mtime = sb.st_mtime; |
6a31e3d7dfe3
(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
|
171 |
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name)); |
6a31e3d7dfe3
(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
|
172 |
GetOldSaveGameName(fios->title, filename); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
173 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
174 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
175 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
176 |
closedir(dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
177 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
178 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
179 |
qsort(_fios_items + sort_start, _fios_count - sort_start, sizeof(FiosItem), compare_FiosItems); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
180 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
181 |
// Drives |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
182 |
{ |
1486
6a31e3d7dfe3
(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
|
183 |
uint save; |
6a31e3d7dfe3
(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
|
184 |
uint disk; |
6a31e3d7dfe3
(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
|
185 |
uint total; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
186 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
187 |
/* save original drive */ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
188 |
_dos_getdrive(&save); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
189 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
190 |
/* get available drive letters */ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
191 |
for (disk = 1; disk < 27; ++disk) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
192 |
{ |
1486
6a31e3d7dfe3
(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
|
193 |
uint disk2; |
6a31e3d7dfe3
(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
|
194 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
195 |
_dos_setdrive(disk, &total); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
196 |
_dos_getdrive(&disk2); |
915 | 197 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
198 |
if (disk == disk2) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
199 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
200 |
fios = FiosAlloc(); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
201 |
fios->type = FIOS_TYPE_DRIVE; |
1580 | 202 |
sprintf(fios->name, "%c:", 'A' + disk - 1); |
1486
6a31e3d7dfe3
(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
|
203 |
sprintf(fios->title, "%c:", 'A' + disk - 1); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
204 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
205 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
206 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
207 |
_dos_setdrive(save, &total); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
208 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
209 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
210 |
*num = _fios_count; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
211 |
return _fios_items; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
212 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
213 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
214 |
// Get a list of scenarios |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
215 |
FiosItem *FiosGetScenarioList(int *num, int mode) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
216 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
217 |
FiosItem *fios; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
218 |
DIR *dir; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
219 |
struct dirent *dirent; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
220 |
struct stat sb; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
221 |
int sort_start; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
222 |
char filename[MAX_PATH]; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
223 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
224 |
if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) { |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
225 |
if (_fios_scn_path == NULL) |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
226 |
_fios_scn_path = malloc(MAX_PATH); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
227 |
strcpy(_fios_scn_path, _path.scenario_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
228 |
} |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
229 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
230 |
_fios_path = _fios_scn_path; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
231 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
232 |
// Parent directory, only if not of the type C:\. |
1486
6a31e3d7dfe3
(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
|
233 |
if (_fios_path[3] != '\0' && mode != SLD_NEW_GAME) { |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
234 |
fios = FiosAlloc(); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
235 |
fios->type = FIOS_TYPE_PARENT; |
1486
6a31e3d7dfe3
(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
|
236 |
fios->mtime = 0; |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
237 |
strcpy(fios->title, ".. (Parent directory)"); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
238 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
239 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
240 |
// Show subdirectories first |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
241 |
dir = my_opendir(_fios_path, "*.*"); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
242 |
if (dir != NULL) { |
1486
6a31e3d7dfe3
(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
|
243 |
while ((dirent = readdir(dir)) != NULL) { |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
244 |
append_path(filename, _fios_path, dirent->d_name); |
1506
c3985c29d018
(svn r2010) - Fix: [ 1162209 ] Fix OS/2 build (orudge)
darkvater
parents:
1495
diff
changeset
|
245 |
if (!stat(filename, &sb) && S_ISDIR(sb.st_mode) && |
c3985c29d018
(svn r2010) - Fix: [ 1162209 ] Fix OS/2 build (orudge)
darkvater
parents:
1495
diff
changeset
|
246 |
strcmp(filename, ".") != 0 && |
c3985c29d018
(svn r2010) - Fix: [ 1162209 ] Fix OS/2 build (orudge)
darkvater
parents:
1495
diff
changeset
|
247 |
strcmp(filename, "..") != 0) { |
1486
6a31e3d7dfe3
(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
|
248 |
fios = FiosAlloc(); |
6a31e3d7dfe3
(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
|
249 |
fios->type = FIOS_TYPE_DIR; |
6a31e3d7dfe3
(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
|
250 |
fios->mtime = 0; |
6a31e3d7dfe3
(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
|
251 |
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name)); |
6a31e3d7dfe3
(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
|
252 |
snprintf(fios->title, lengthof(fios->title), |
6a31e3d7dfe3
(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
|
253 |
"%s\\ (Directory)", dirent->d_name); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
254 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
255 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
256 |
closedir(dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
257 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
258 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
259 |
// this is where to start sorting |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
260 |
sort_start = _fios_count; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
261 |
|
1486
6a31e3d7dfe3
(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
|
262 |
/* Show scenario files |
6a31e3d7dfe3
(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
|
263 |
* .SCN OpenTTD style scenario file |
6a31e3d7dfe3
(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
|
264 |
* .SV0 Transport Tycoon Deluxe (Patch) scenario |
6a31e3d7dfe3
(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
|
265 |
* .SS0 Transport Tycoon Deluxe preset scenario |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
266 |
*/ |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
267 |
dir = my_opendir(_fios_path, "*.*"); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
268 |
if (dir != NULL) { |
1486
6a31e3d7dfe3
(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
|
269 |
while ((dirent = readdir(dir)) != NULL) { |
6a31e3d7dfe3
(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
|
270 |
char *t; |
6a31e3d7dfe3
(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
|
271 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
272 |
append_path(filename, _fios_path, dirent->d_name); |
1486
6a31e3d7dfe3
(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
|
273 |
if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue; |
6a31e3d7dfe3
(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
|
274 |
|
6a31e3d7dfe3
(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
|
275 |
t = strrchr(dirent->d_name, '.'); |
6a31e3d7dfe3
(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
|
276 |
if (t != NULL && strcasecmp(t, ".scn") == 0) { // OpenTTD |
6a31e3d7dfe3
(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
|
277 |
fios = FiosAlloc(); |
6a31e3d7dfe3
(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
|
278 |
fios->type = FIOS_TYPE_SCENARIO; |
6a31e3d7dfe3
(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
|
279 |
fios->mtime = sb.st_mtime; |
6a31e3d7dfe3
(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
|
280 |
fios->title[0] = '\0'; |
6a31e3d7dfe3
(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
|
281 |
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name)); |
6a31e3d7dfe3
(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
|
282 |
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO || |
6a31e3d7dfe3
(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
|
283 |
mode == SLD_NEW_GAME) { |
6a31e3d7dfe3
(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
|
284 |
if (t != NULL && ( |
6a31e3d7dfe3
(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
|
285 |
strcasecmp(t, ".sv0") == 0 || |
6a31e3d7dfe3
(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
|
286 |
strcasecmp(t, ".ss0") == 0 |
6a31e3d7dfe3
(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
|
287 |
)) { // TTDLX(Patch) |
6a31e3d7dfe3
(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
|
288 |
fios = FiosAlloc(); |
6a31e3d7dfe3
(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
|
289 |
fios->type = FIOS_TYPE_OLD_SCENARIO; |
6a31e3d7dfe3
(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
|
290 |
fios->mtime = sb.st_mtime; |
6a31e3d7dfe3
(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
|
291 |
GetOldScenarioGameName(fios->title, filename); |
6a31e3d7dfe3
(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
|
292 |
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name)); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
293 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
294 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
295 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
296 |
closedir(dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
297 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
298 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
299 |
qsort(_fios_items + sort_start, _fios_count - sort_start, sizeof(FiosItem), compare_FiosItems); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
300 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
301 |
// Drives |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
302 |
if (mode != SLD_NEW_GAME) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
303 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
304 |
unsigned save, disk, disk2, total; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
305 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
306 |
/* save original drive */ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
307 |
_dos_getdrive(&save); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
308 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
309 |
/* get available drive letters */ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
310 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
311 |
for (disk = 1; disk < 27; ++disk) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
312 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
313 |
_dos_setdrive(disk, &total); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
314 |
_dos_getdrive(&disk2); |
915 | 315 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
316 |
if (disk == disk2) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
317 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
318 |
fios = FiosAlloc(); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
319 |
fios->type = FIOS_TYPE_DRIVE; |
1580 | 320 |
sprintf(fios->name, "%c:", 'A' + disk - 1); |
321 |
sprintf(fios->title, "%c:", 'A' + disk - 1); |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
322 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
323 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
324 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
325 |
_dos_setdrive(save, &total); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
326 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
327 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
328 |
*num = _fios_count; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
329 |
return _fios_items; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
330 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
331 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
332 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
333 |
// Free the list of savegames |
1486
6a31e3d7dfe3
(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
|
334 |
void FiosFreeSavegameList(void) |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
335 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
336 |
free(_fios_items); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
337 |
_fios_items = NULL; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
338 |
_fios_alloc = _fios_count = 0; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
339 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
340 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
341 |
// Browse to |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
342 |
char *FiosBrowseTo(const FiosItem *item) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
343 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
344 |
char *path = _fios_path; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
345 |
char *s; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
346 |
|
1486
6a31e3d7dfe3
(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
|
347 |
switch (item->type) { |
6a31e3d7dfe3
(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
|
348 |
case FIOS_TYPE_DRIVE: |
6a31e3d7dfe3
(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
|
349 |
sprintf(path, "%c:\\", item->title[0]); |
6a31e3d7dfe3
(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
|
350 |
break; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
351 |
|
1486
6a31e3d7dfe3
(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
|
352 |
case FIOS_TYPE_PARENT: |
6a31e3d7dfe3
(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
|
353 |
s = strrchr(path, '\\'); |
6a31e3d7dfe3
(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
|
354 |
if (s != NULL) *s = '\0'; |
6a31e3d7dfe3
(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
|
355 |
break; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
356 |
|
1486
6a31e3d7dfe3
(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
|
357 |
case FIOS_TYPE_DIR: |
6a31e3d7dfe3
(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
|
358 |
s = strchr(item->name, '\\'); |
6a31e3d7dfe3
(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
|
359 |
if (s != NULL) *s = '\0'; |
6a31e3d7dfe3
(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
|
360 |
strcat(path, "\\"); |
6a31e3d7dfe3
(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
|
361 |
strcat(path, item->name); |
6a31e3d7dfe3
(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
|
362 |
break; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
363 |
|
1486
6a31e3d7dfe3
(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
|
364 |
case FIOS_TYPE_FILE: |
6a31e3d7dfe3
(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
|
365 |
case FIOS_TYPE_OLDFILE: |
6a31e3d7dfe3
(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
|
366 |
case FIOS_TYPE_SCENARIO: |
6a31e3d7dfe3
(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
|
367 |
case FIOS_TYPE_OLD_SCENARIO: { |
6a31e3d7dfe3
(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
|
368 |
static char str_buffr[512]; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
369 |
|
1486
6a31e3d7dfe3
(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
|
370 |
sprintf(str_buffr, "%s\\%s", path, item->name); |
6a31e3d7dfe3
(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
|
371 |
return str_buffr; |
6a31e3d7dfe3
(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
|
372 |
} |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
373 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
374 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
375 |
return NULL; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
376 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
377 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
378 |
// Get descriptive texts. |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
379 |
// Returns a path as well as a |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
380 |
// string describing the path. |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
381 |
StringID FiosGetDescText(const char **path) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
382 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
383 |
struct diskfree_t free; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
384 |
char drive; |
915 | 385 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
386 |
*path = _fios_path; |
1486
6a31e3d7dfe3
(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
|
387 |
drive = *path[0] - 'A' + 1; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
388 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
389 |
_getdiskfree(drive, &free); |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
390 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
391 |
SetDParam(0, free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
392 |
return STR_4005_BYTES_FREE; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
393 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
394 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
395 |
void FiosMakeSavegameName(char *buf, const char *name) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
396 |
{ |
1508
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
397 |
const char* extension; |
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
398 |
const char* period; |
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
399 |
|
1486
6a31e3d7dfe3
(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
|
400 |
if (_game_mode == GM_EDITOR) |
1508
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
401 |
extension = ".scn"; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
402 |
else |
1508
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
403 |
extension = ".sav"; |
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
404 |
|
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
405 |
// Don't append the extension, if it is already there |
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
406 |
period = strrchr(name, '.'); |
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
407 |
if (period != NULL && strcasecmp(period, extension) == 0) extension = ""; |
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
408 |
|
3f0d2f3147c2
(svn r2012) When making a savegame name, don't append the extension, if it is already there
tron
parents:
1506
diff
changeset
|
409 |
sprintf(buf, "%s\\%s%s", _fios_path, name, extension); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
410 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
411 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
412 |
void FiosDelete(const char *name) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
413 |
{ |
1336
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1317
diff
changeset
|
414 |
char path[512]; |
c9e6b766bf21
(svn r1840) Repel str_buffr and use local buffers where possible
tron
parents:
1317
diff
changeset
|
415 |
|
1495
c8a61d136f26
(svn r1999) r1990 broke savegame deletion, fix that [1161729]
tron
parents:
1486
diff
changeset
|
416 |
snprintf(path, lengthof(path), "%s\\%s", _fios_path, name); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
417 |
unlink(path); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
418 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
419 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
420 |
const DriverDesc _video_driver_descs[] = { |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
421 |
{ "null", "Null Video Driver", &_null_video_driver, 0}, |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
422 |
#if defined(WITH_SDL) |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
423 |
{ "sdl", "SDL Video Driver", &_sdl_video_driver, 1}, |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
424 |
#endif |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
425 |
{ "dedicated", "Dedicated Video Driver", &_dedicated_video_driver, 0}, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
426 |
{ NULL, NULL, NULL, 0} |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
427 |
}; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
428 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
429 |
const DriverDesc _sound_driver_descs[] = { |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
430 |
{ "null", "Null Sound Driver", &_null_sound_driver, 0}, |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
431 |
#if defined(WITH_SDL) |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
432 |
{ "sdl", "SDL Sound Driver", &_sdl_sound_driver, 1}, |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
433 |
#endif |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
434 |
{ NULL, NULL, NULL, 0} |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
435 |
}; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
436 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
437 |
const DriverDesc _music_driver_descs[] = { |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
438 |
{ "os2", "OS/2 Music Driver", &_os2_music_driver, 0}, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
439 |
{ "null", "Null Music Driver", &_null_music_driver, 1}, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
440 |
{ NULL, NULL, NULL, 0} |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
441 |
}; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
442 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
443 |
/* GetOSVersion returns the minimal required version of OS to be able to use that driver. |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
444 |
Not needed for OS/2. */ |
1486
6a31e3d7dfe3
(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
|
445 |
byte GetOSVersion(void) |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
446 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
447 |
return 2; // any arbitrary number bigger then 0 |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
448 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
449 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
450 |
bool FileExists(const char *filename) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
451 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
452 |
return access(filename, 0) == 0; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
453 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
454 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
455 |
static int LanguageCompareFunc(const void *a, const void *b) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
456 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
457 |
return strcmp(*(const char* const *)a, *(const char* const *)b); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
458 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
459 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
460 |
int GetLanguageList(char **languages, int max) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
461 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
462 |
DIR *dir; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
463 |
struct dirent *dirent; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
464 |
int num = 0; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
465 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
466 |
dir = opendir(_path.lang_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
467 |
if (dir != NULL) { |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
468 |
while ((dirent = readdir(dir))) { |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
469 |
char *t = strrchr(dirent->d_name, '.'); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
470 |
if (t && !strcmp(t, ".lng")) { |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
471 |
languages[num++] = strdup(dirent->d_name); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
472 |
if (num == max) break; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
473 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
474 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
475 |
closedir(dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
476 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
477 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
478 |
qsort(languages, num, sizeof(char*), LanguageCompareFunc); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
479 |
return num; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
480 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
481 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
482 |
static void ChangeWorkingDirectory(char *exe) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
483 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
484 |
char *s = strrchr(exe, '\\'); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
485 |
if (s != NULL) { |
1486
6a31e3d7dfe3
(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
|
486 |
*s = '\0'; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
487 |
chdir(exe); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
488 |
*s = '\\'; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
489 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
490 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
491 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
492 |
void ShowInfo(const char *str) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
493 |
{ |
818
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
494 |
HAB hab; |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
495 |
HMQ hmq; |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
496 |
ULONG rc; |
915 | 497 |
|
818
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
498 |
// init PM env. |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
499 |
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0); |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
500 |
|
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
501 |
// display the box |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
502 |
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, str, "OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_INFORMATION); |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
503 |
|
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
504 |
// terminate PM env. |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
505 |
WinDestroyMsgQueue(hmq); |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
506 |
WinTerminate(hab); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
507 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
508 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
509 |
void ShowOSErrorBox(const char *buf) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
510 |
{ |
818
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
511 |
HAB hab; |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
512 |
HMQ hmq; |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
513 |
ULONG rc; |
915 | 514 |
|
818
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
515 |
// init PM env. |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
516 |
hmq = WinCreateMsgQueue((hab = WinInitialize(0)), 0); |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
517 |
|
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
518 |
// display the box |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
519 |
rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, buf, "OpenTTD", 0, MB_OK | MB_MOVEABLE | MB_ERROR); |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
520 |
|
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
521 |
// terminate PM env. |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
522 |
WinDestroyMsgQueue(hmq); |
906f21e653b2
(svn r1289) -Fix: Minor fix for OS/2 message boxes (orudge)
truelight
parents:
810
diff
changeset
|
523 |
WinTerminate(hab); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
524 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
525 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
526 |
int CDECL main(int argc, char* argv[]) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
527 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
528 |
// change the working directory to enable doubleclicking in UIs |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
529 |
ChangeWorkingDirectory(argv[0]); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
530 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
531 |
_random_seeds[0][1] = _random_seeds[0][0] = time(NULL); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
532 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
533 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
534 |
return ttd_main(argc, argv); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
535 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
536 |
|
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1346
diff
changeset
|
537 |
void DeterminePaths(void) |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
538 |
{ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
539 |
char *s; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
540 |
|
1486
6a31e3d7dfe3
(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
|
541 |
_path.game_data_dir = malloc(MAX_PATH); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
542 |
ttd_strlcpy(_path.game_data_dir, GAME_DATA_DIR, MAX_PATH); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
543 |
#if defined SECOND_DATA_DIR |
1486
6a31e3d7dfe3
(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
|
544 |
_path.second_data_dir = malloc(MAX_PATH); |
6a31e3d7dfe3
(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
|
545 |
ttd_strlcpy(_path.second_data_dir, SECOND_DATA_DIR, MAX_PATH); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
546 |
#endif |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
547 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
548 |
#if defined(USE_HOMEDIR) |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
549 |
{ |
1486
6a31e3d7dfe3
(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
|
550 |
const char *homedir = getenv("HOME"); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
551 |
|
1486
6a31e3d7dfe3
(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
|
552 |
if (homedir == NULL) { |
6a31e3d7dfe3
(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
|
553 |
const struct passwd *pw = getpwuid(getuid()); |
6a31e3d7dfe3
(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
|
554 |
if (pw != NULL) homedir = pw->pw_dir; |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
555 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
556 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
557 |
_path.personal_dir = str_fmt("%s" PATHSEP "%s", homedir, PERSONAL_DIR); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
558 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
559 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
560 |
#else /* not defined(USE_HOMEDIR) */ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
561 |
|
1486
6a31e3d7dfe3
(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
|
562 |
_path.personal_dir = malloc(MAX_PATH); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
563 |
ttd_strlcpy(_path.personal_dir, PERSONAL_DIR, MAX_PATH); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
564 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
565 |
// check if absolute or relative path |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
566 |
s = strchr(_path.personal_dir, '\\'); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
567 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
568 |
// add absolute path |
1486
6a31e3d7dfe3
(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
|
569 |
if (s == NULL || _path.personal_dir != s) { |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
570 |
getcwd(_path.personal_dir, MAX_PATH); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
571 |
s = strchr(_path.personal_dir, 0); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
572 |
*s++ = '\\'; |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
573 |
ttd_strlcpy(s, PERSONAL_DIR, MAX_PATH); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
574 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
575 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
576 |
#endif /* defined(USE_HOMEDIR) */ |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
577 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
578 |
s = strchr(_path.personal_dir, 0); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
579 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
580 |
// append a / ? |
1486
6a31e3d7dfe3
(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
|
581 |
if (s[-1] != '\\') strcpy(s, "\\"); |
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
582 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
583 |
_path.save_dir = str_fmt("%ssave", _path.personal_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
584 |
_path.autosave_dir = str_fmt("%s\\autosave", _path.save_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
585 |
_path.scenario_dir = str_fmt("%sscenario", _path.personal_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
586 |
_path.gm_dir = str_fmt("%sgm\\", _path.game_data_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
587 |
_path.data_dir = str_fmt("%sdata\\", _path.game_data_dir); |
1482
46a8146adecf
(svn r1986) - Fix: free _config_file when shutting down openttd. Strange that Valgrind didn't catch this, kudos to TrueLight
Darkvater
parents:
1390
diff
changeset
|
588 |
|
46a8146adecf
(svn r1986) - Fix: free _config_file when shutting down openttd. Strange that Valgrind didn't catch this, kudos to TrueLight
Darkvater
parents:
1390
diff
changeset
|
589 |
if (_config_file == NULL) |
46a8146adecf
(svn r1986) - Fix: free _config_file when shutting down openttd. Strange that Valgrind didn't catch this, kudos to TrueLight
Darkvater
parents:
1390
diff
changeset
|
590 |
_config_file = str_fmt("%sopenttd.cfg", _path.personal_dir); |
915 | 591 |
|
1486
6a31e3d7dfe3
(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
|
592 |
_highscore_file = str_fmt("%shs.dat", _path.personal_dir); |
6a31e3d7dfe3
(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
|
593 |
_log_file = str_fmt("%sopenttd.log", _path.personal_dir); |
6a31e3d7dfe3
(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
|
594 |
|
801
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
595 |
#if defined CUSTOM_LANG_DIR |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
596 |
// sets the search path for lng files to the custom one |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
597 |
_path.lang_dir = malloc( MAX_PATH ); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
598 |
ttd_strlcpy( _path.lang_dir, CUSTOM_LANG_DIR, MAX_PATH); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
599 |
#else |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
600 |
_path.lang_dir = str_fmt("%slang\\", _path.game_data_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
601 |
#endif |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
602 |
|
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
603 |
// create necessary folders |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
604 |
mkdir(_path.personal_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
605 |
mkdir(_path.save_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
606 |
mkdir(_path.autosave_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
607 |
mkdir(_path.scenario_dir); |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
608 |
} |
bfa47ec110b0
(svn r1271) -Fix: set eol-style to native on missing files
darkvater
parents:
782
diff
changeset
|
609 |
|
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
610 |
// FUNCTION: OS2_SwitchToConsoleMode |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
611 |
// |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
612 |
// Switches OpenTTD to a console app at run-time, instead of a PM app |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
613 |
// Necessary to see stdout, etc |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
614 |
|
1486
6a31e3d7dfe3
(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
|
615 |
void OS2_SwitchToConsoleMode(void) |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
616 |
{ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
617 |
PPIB pib; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
618 |
PTIB tib; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
619 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
620 |
DosGetInfoBlocks(&tib, &pib); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
621 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
622 |
// Change flag from PM to VIO |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
623 |
pib->pib_ultype = 3; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
624 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
625 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
626 |
/********************** |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
627 |
* OS/2 MIDI PLAYER |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
628 |
**********************/ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
629 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
630 |
/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
631 |
* eh? Anyone would think they both came from the same place originally! ;) |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
632 |
*/ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
633 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
634 |
static long CDECL MidiSendCommand(const char *cmd, ...) |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
635 |
{ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
636 |
va_list va; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
637 |
char buf[512]; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
638 |
va_start(va, cmd); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
639 |
vsprintf(buf, cmd, va); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
640 |
va_end(va); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
641 |
return mciSendString(buf, NULL, 0, NULL, 0); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
642 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
643 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
644 |
static void OS2MidiPlaySong(const char *filename) |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
645 |
{ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
646 |
MidiSendCommand("close all"); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
647 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
648 |
if (MidiSendCommand("open %s type sequencer alias song", filename) != 0) |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
649 |
return; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
650 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
651 |
MidiSendCommand("play song from 0"); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
652 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
653 |
|
1486
6a31e3d7dfe3
(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
|
654 |
static void OS2MidiStopSong(void) |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
655 |
{ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
656 |
MidiSendCommand("close all"); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
657 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
658 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
659 |
static void OS2MidiSetVolume(byte vol) |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
660 |
{ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
661 |
MidiSendCommand("set song audio volume %d", ((vol/127)*100)); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
662 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
663 |
|
1486
6a31e3d7dfe3
(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
|
664 |
static bool OS2MidiIsSongPlaying(void) |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
665 |
{ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
666 |
char buf[16]; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
667 |
mciSendString("status song mode", buf, sizeof(buf), NULL, 0); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
668 |
return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
669 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
670 |
|
1301
313804601383
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
915
diff
changeset
|
671 |
static const char *OS2MidiStart(const char * const *parm) |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
672 |
{ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
673 |
return 0; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
674 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
675 |
|
1486
6a31e3d7dfe3
(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
|
676 |
static void OS2MidiStop(void) |
810
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
677 |
{ |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
678 |
MidiSendCommand("close all"); |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
679 |
} |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
680 |
|
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
681 |
const HalMusicDriver _os2_music_driver = { |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
682 |
OS2MidiStart, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
683 |
OS2MidiStop, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
684 |
OS2MidiPlaySong, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
685 |
OS2MidiStopSong, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
686 |
OS2MidiIsSongPlaying, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
687 |
OS2MidiSetVolume, |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
688 |
}; |
7c51ba5a4368
(svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents:
801
diff
changeset
|
689 |
|
1486
6a31e3d7dfe3
(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
|
690 |
bool InsertTextBufferClipboard(Textbuf *tb) |
6a31e3d7dfe3
(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
|
691 |
{ |
1524
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
692 |
#if 0 |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
693 |
HAB hab = 0; // anchor-block handle |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
694 |
PSZ pszClipText, pszLocalText; |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
695 |
|
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
696 |
if (WinOpenClipbrd(hab)) |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
697 |
{ |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
698 |
if (pszClipText = (PSZ) WinQueryClipbrdData(hab, CF_TEXT)) |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
699 |
{ |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
700 |
while (*pszLocalText++ = *pszClipText++); |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
701 |
} |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
702 |
WinCloseClipbrd(hab); |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
703 |
} |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
704 |
|
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
705 |
// text is now in pszLocalText, do something with it! |
85efc2f52e2c
(svn r2028) Added detection of SVN version (rev.c generation) for OS/2, updated readme, initial clipboard support (orudge)
celestar
parents:
1508
diff
changeset
|
706 |
#endif |
1506
c3985c29d018
(svn r2010) - Fix: [ 1162209 ] Fix OS/2 build (orudge)
darkvater
parents:
1495
diff
changeset
|
707 |
// TODO |
1486
6a31e3d7dfe3
(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
|
708 |
return false; |
6a31e3d7dfe3
(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
|
709 |
} |