summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dedicated.c7
-rw-r--r--docs/Readme_OS2.txt110
-rw-r--r--docs/openttd.64
-rw-r--r--fileio.c2
-rw-r--r--hal.h4
-rw-r--r--intro_gui.c2
-rw-r--r--lang/english.txt1
-rw-r--r--network_core.h3
-rw-r--r--openttd.tgt790
-rw-r--r--os/os2/openttd.wpj4
-rw-r--r--os2.c217
-rw-r--r--sdl.c2
-rw-r--r--strgen/strgen.tgt48
13 files changed, 719 insertions, 475 deletions
diff --git a/dedicated.c b/dedicated.c
index ed9df3b58..223015a14 100644
--- a/dedicated.c
+++ b/dedicated.c
@@ -20,6 +20,8 @@
# include <unistd.h>
# include <conio.h>
# define STDIN 0 /* file descriptor for standard input */
+
+ extern void OS2_SwitchToConsoleMode();
#endif
#ifdef UNIX
@@ -100,6 +102,11 @@ static const char *DedicatedVideoStart(char **parm) {
SetConsoleTitle("OpenTTD Dedicated Server");
#endif
+#ifdef __OS2__
+ // For OS/2 we also need to switch to console mode instead of PM mode
+ OS2_SwitchToConsoleMode();
+#endif
+
DEBUG(misc,0)("Loading dedicated server...");
return NULL;
}
diff --git a/docs/Readme_OS2.txt b/docs/Readme_OS2.txt
index 2ef9d0e18..49e6de989 100644
--- a/docs/Readme_OS2.txt
+++ b/docs/Readme_OS2.txt
@@ -1,48 +1,114 @@
-OpenTTD: OS/2 version ** CURRENTLY INCOMPLETE **
+OpenTTD: OS/2 version
=====================
-OpenTTD has been ported to work on OS/2 4.x or later (including eComStation). At the moment, it does not work properly, but it
-can compile and work to an extent.
+OpenTTD has been ported to work on OS/2 4.x or later (including
+eComStation). The game should work as well as it does on Windows
+or other platforms: the main issues you may encounter are graphics
+card problems, but that is really the fault of SDL.
+
+=========================
+USING OPENTTD FOR OS/2
+=========================
+
+LIBRARIES REQUIRED FOR END USERS
+--------------------------------
+
+SDL.DLL (SDL 1.2.7) and FSLib.dll are required to use this program:
+these can be downloaded from the Files section at
+http://sourceforge.net/projects/openttd/ - see "os2-useful.zip".
+
+Note that to actually play the game, I have found in my own
+experience that a version of the Scitech Display Drivers or its later
+incarnation (see www.scitech.com) are necessary for it to work. If
+you have trouble with your native drivers, try the Scitech drivers
+and see if they help the problem.
+
+KNOWN ISSUES
+------------
+
+- If an error occurs during loading, the OS/2 error message window
+ is not always displayed.
+
+A NOTE ABOUT MUSIC
+------------------
+
+OpenTTD includes a music driver which uses the MCI MIDI system. Unfortunately,
+due to the lack of proper MIDI hardware myself, I have been unable to test it,
+but during testing, I found that when MIDI was enabled, I got no sound
+effects. I therefore decided to DISABLE music by default.
+
+To enable music, start OpenTTD with the command line:
+
+ openttd -m os2
+
+If I hear enough responses that both music and sound work together (it might
+just be my system), I'll have the defaults changed.
+
+A NOTE ABOUT DEDICATED MULTIPLAYER SERVERS
+------------------------------------------
+
+To start a dedicated multiplayer server, you should run the dedicated.cmd
+file. This enables OpenTTD to open up a VIO console window to display
+its output and gather any necessary input. Running "openttd -D"
+directly will result in the console not being displayed. You may
+still pass any other parameters ('-D' is already passed) to
+dedicated.cmd.
+
+=========================
+BUILDING THE OS/2 VERSION
+=========================
Compiler
--------
-Open Watcom 1.3 was used to build OpenTTD (earlier versions will NOT work). See http://www.openwatcom.org/ to download it.
-It may also be possible to build OpenTTD under OS/2: I attempted this before using Open Watcom, but found the tools available
-for OS/2 at the time to be a bit more tricky to get working.
+Open Watcom 1.3 was used to build OpenTTD (earlier versions will
+NOT work). See http://www.openwatcom.org/ to download it. It may
+also be possible to build OpenTTD under OS/2: I attempted this
+before using Open Watcom, but found the tools available for OS/2
+at the time to be a bit more tricky to get working.
-Due to complexities in my set-up, I actually used the Win32 version of Open Watcom to initially compile OpenTTD for OS/2. There
-should be no reason of course why the OS/2 version cannot be used.
+Due to complexities in my set-up, I actually used the Win32 version
+of Open Watcom to initially compile OpenTTD for OS/2. There should
+be no reason of course why the OS/2 version cannot be used.
Libraries Required
------------------
-The following libraries are required. To build zlib and libpng, I simply added the required files (watch out for sample
-programs, etc) to an IDE project file and built a library:
+The following libraries are required. To build zlib and libpng, I
+simply added the required files (watch out for sample programs, etc)
+to an IDE project file and built a library. Do not use the makefiles
+provided, they are not designed for Watcom (apart from SDL):
- zlib
- http://www.zlib.org/ - contains a makefile for OS/2, but is out of date and uses EMX
+ http://www.zlib.org/ - contains a makefile for OS/2, but is out
+ of date and uses EMX
- libpng
http://www.libpng.org/ - contains an EMX/gcc makefile
- SDL for OS/2
- I used ftp://ftp.netlabs.org/pub/sdl/SDL-1.2.7-src-20040908a.zip - take SDL.dll and SDL.lib from the src/ directory.
+ I used ftp://ftp.netlabs.org/pub/sdl/SDL-1.2.7-src-20040908a.zip -
+ take SDL.dll and SDL.lib from the src/ directory.
-Note that to use the compiled program, you also need FSLib.dll (from src/ in the SDL zip) and a version of the Scitech
-Display Drivers or its later incarnation (see www.scitech.com).
+If you do not wish to build the libraries yourself, pre-built versions
+can be downloaded from the Files section at
+http://sourceforge.net/projects/openttd/ - see "os2-useful.zip".
Compiling
---------
-To compile, open the os/os2/openttd.wpj file in the IDE and build the openttd.exe target.
-
-TODO: compilation of language files properly
-
-
-** THESE DOCS ARE INCOMPLETE FOR THE MOMENT, WILL BE COMPLETED SOON **
+To compile, open the os/os2/openttd.wpj file in the IDE and first build
+the strgen.exe target. This will build the .lng file generator, and will
+also attempt to build all the language files (plus the table\strings.h
+file which is required for openttd.exe to be built). Once strgen.exe and
+the language files are built successfully, you can build the openttd.exe
+target.
-If you have any questions, please contact me (owen@owenrudge.net) and I'll try to help you out
+Contact Information
+-------------------
-- Owen Rudge, 18th December 2004
+If you have any questions regarding OS/2 issues, please contact me
+(owen@owenrudge.net) and I'll try to help you out. For general OpenTTD
+issues, see the Contacting section of readme.txt.
+- Owen Rudge, 26th December 2004 \ No newline at end of file
diff --git a/docs/openttd.6 b/docs/openttd.6
index 39736436d..ca0d329f7 100644
--- a/docs/openttd.6
+++ b/docs/openttd.6
@@ -22,13 +22,13 @@ openttd \- An open source clone of the Microprose game "Transport Tycoon Deluxe
.RI [ options ]
.br
.SH DESCRIPTION
-Unfortanetely, there is no real manpage for openttd yet. Hopefully someone
+Unfortunately, there is no real manpage for openttd yet. Hopefully someone
will write one soon. For now you should use
.B openttd -h
for more information, or check our Wiki manual: http://wiki.openttd.org/
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
-.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
+.\" \fI<whatever>\fP escape sequences to invoke bold face and italics,
.\" respectively.
.\" \fBopenttd\fP is a program that...
.SH OPTIONS
diff --git a/fileio.c b/fileio.c
index 5645d338f..27a22b193 100644
--- a/fileio.c
+++ b/fileio.c
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
-#if defined(UNIX)
+#if defined(UNIX) || defined(__OS2__)
#include <ctype.h> // required for tolower()
#endif
diff --git a/hal.h b/hal.h
index faf2892b4..9941c4749 100644
--- a/hal.h
+++ b/hal.h
@@ -71,6 +71,10 @@ extern const HalMusicDriver _extmidi_music_driver;
extern const HalMusicDriver _bemidi_music_driver;
#endif
+#if defined(__OS2__)
+extern const HalMusicDriver _os2_music_driver;
+#endif
+
extern const HalVideoDriver _dedicated_video_driver;
enum DriverType {
diff --git a/intro_gui.c b/intro_gui.c
index baa64d785..cb3b8a055 100644
--- a/intro_gui.c
+++ b/intro_gui.c
@@ -199,6 +199,8 @@ static void AskAbandonGameWndProc(Window *w, WindowEvent *e) {
SetDParam(0, STR_OSNAME_MORPHOS);
#elif defined(__AMIGA__)
SetDParam(0, STR_OSNAME_AMIGAOS);
+#elif defined(__OS2__)
+ SetDParam(0, STR_OSNAME_OS2);
#else
SetDParam(0, STR_0134_UNIX);
#endif
diff --git a/lang/english.txt b/lang/english.txt
index 44e9be3d7..635816870 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -311,6 +311,7 @@ STR_0135_OSX :OS X
STR_OSNAME_BEOS :BeOS
STR_OSNAME_MORPHOS :MorphOS
STR_OSNAME_AMIGAOS :AmigaOS
+STR_OSNAME_OS2 :OS/2
STR_0139_IMPERIAL_MILES :Imperial (miles)
STR_013A_METRIC_KILOMETERS :Metric (kilometers)
diff --git a/network_core.h b/network_core.h
index bf29116ec..f341531de 100644
--- a/network_core.h
+++ b/network_core.h
@@ -88,7 +88,7 @@ typedef struct ifreq IFREQ;
typedef struct ifreq IFREQ;
# define ioctlsocket ioctl
# define closesocket close
-# define GET_LAST_ERROR() (errno)
+# define GET_LAST_ERROR() (sock_errno())
// Includes needed for OS/2 systems
# include <types.h>
@@ -103,6 +103,7 @@ typedef struct ifreq IFREQ;
# include <sys/time.h>
# include <netdb.h>
# include <nerrno.h>
+# define INADDR_NONE 0xffffffff
typedef unsigned long in_addr_t;
#endif // OS/2
diff --git a/openttd.tgt b/openttd.tgt
index 775586d3a..4661b0996 100644
--- a/openttd.tgt
+++ b/openttd.tgt
@@ -130,8 +130,8 @@ WString
0
33
WString
-24
-png.lib zlib.lib sdl.lib
+34
+mmpm2.lib png.lib zlib.lib sdl.lib
0
34
MVState
@@ -205,7 +205,7 @@ WString
COBJ
54
WVList
-14
+15
55
MVState
56
@@ -343,17 +343,17 @@ WString
ENABLE_NETWORK=1 WITH_ZLIB=1 WITH_PNG=1 WITH_SDL=1
0
89
-MRState
+MCState
90
WString
3
WCC
91
WString
-20
-?????Pack structures
-0
+31
+?????Force enums to be type int
0
+1
92
MRState
93
@@ -362,10 +362,10 @@ WString
WCC
94
WString
-21
-?????4 byte alignment
+20
+?????Pack structures
+0
0
-1
95
MRState
96
@@ -374,8 +374,8 @@ WString
WCC
97
WString
-29
-?????No debugging information
+21
+?????4 byte alignment
0
1
98
@@ -386,1703 +386,1715 @@ WString
WCC
100
WString
+29
+?????No debugging information
+0
+1
+101
+MRState
+102
+WString
+3
+WCC
+103
+WString
28
?????Line number information
0
0
-101
+104
WVList
0
-1
1
1
0
-102
+105
MItem
4
ai.c
-103
+106
WString
4
COBJ
-104
+107
WVList
0
-105
+108
WVList
0
52
1
1
0
-106
+109
MItem
10
ai_build.c
-107
+110
WString
4
COBJ
-108
+111
WVList
0
-109
+112
WVList
0
52
1
1
0
-110
+113
MItem
8
ai_new.c
-111
+114
WString
4
COBJ
-112
+115
WVList
0
-113
+116
WVList
0
52
1
1
0
-114
+117
MItem
15
ai_pathfinder.c
-115
+118
WString
4
COBJ
-116
+119
WVList
0
-117
+120
WVList
0
52
1
1
0
-118
+121
MItem
11
ai_shared.c
-119
+122
WString
4
COBJ
-120
+123
WVList
0
-121
+124
WVList
0
52
1
1
0
-122
+125
MItem
14
aircraft_cmd.c
-123
+126
WString
4
COBJ
-124
+127
WVList
0
-125
+128
WVList
0
52
1
1
0
-126
+129
MItem
14
aircraft_gui.c
-127
+130
WString
4
COBJ
-128
+131
WVList
0
-129
+132
WVList
0
52
1
1
0
-130
+133
MItem
9
airport.c
-131
+134
WString
4
COBJ
-132
+135
WVList
0
-133
+136
WVList
0
52
1
1
0
-134
+137
MItem
13
airport_gui.c
-135
+138
WString
4
COBJ
-136
+139
WVList
0
-137
+140
WVList
0
52
1
1
0
-138
+141
MItem
8
aystar.c
-139
+142
WString
4
COBJ
-140
+143
WVList
0
-141
+144
WVList
0
52
1
1
0
-142
+145
MItem
12
bridge_gui.c
-143
+146
WString
4
COBJ
-144
+147
WVList
0
-145
+148
WVList
0
52
1
1
0
-146
+149
MItem
16
callback_table.c
-147
+150
WString
4
COBJ
-148
+151
WVList
0
-149
+152
WVList
0
52
1
1
0
-150
+153
MItem
11
clear_cmd.c
-151
+154
WString
4
COBJ
-152
+155
WVList
0
-153
+156
WVList
0
52
1
1
0
-154
+157
MItem
9
command.c
-155
+158
WString
4
COBJ
-156
+159
WVList
0
-157
+160
WVList
0
52
1
1
0
-158
+161
MItem
9
console.c
-159
+162
WString
4
COBJ
-160
+163
WVList
0
-161
+164
WVList
0
52
1
1
0
-162
+165
MItem
14
console_cmds.c
-163
+166
WString
4
COBJ
-164
+167
WVList
0
-165
+168
WVList
0
52
1
1
0
-166
+169
MItem
11
dedicated.c
-167
+170
WString
4
COBJ
-168
+171
WVList
0
-169
+172
WVList
0
52
1
1
0
-170
+173
MItem
14
disaster_cmd.c
-171
+174
WString
4
COBJ
-172
+175
WVList
0
-173
+176
WVList
0
52
1
1
0
-174
+177
MItem
10
dock_gui.c
-175
+178
WString
4
COBJ
-176
+179
WVList
0
-177
+180
WVList
0
52
1
1
0
-178
+181
MItem
12
dummy_land.c
-179
+182
WString
4
COBJ
-180
+183
WVList
0
-181
+184
WVList
0
52
1
1
0
-182
+185
MItem
9
economy.c
-183
+186
WString
4
COBJ
-184
+187
WVList
0
-185
+188
WVList
0
52
1
1
0
-186
+189
MItem
8
engine.c
-187
+190
WString
4
COBJ
-188
+191
WVList
0
-189
+192
WVList
0
52
1
1
0
-190
+193
MItem
12
engine_gui.c
-191
+194
WString
4
COBJ
-192
+195
WVList
0
-193
+196
WVList
0
52
1
1
0
-194
+197
MItem
8
fileio.c
-195
+198
WString
4
COBJ
-196
+199
WVList
0
-197
+200
WVList
0
52
1
1
0
-198
+201
MItem
5
gfx.c
-199
+202
WString
4
COBJ
-200
+203
WVList
0
-201
+204
WVList
0
52
1
1
0
-202
+205
MItem
11
graph_gui.c
-203
+206
WString
4
COBJ
-204
+207
WVList
0
-205
+208
WVList
0
52
1
1
0
-206
+209
MItem
14
industry_cmd.c
-207
+210
WString
4
COBJ
-208
+211
WVList
0
-209
+212
WVList
0
52
1
1
0
-210
+213
MItem
14
industry_gui.c
-211
+214
WString
4
COBJ
-212
+215
WVList
0
-213
+216
WVList
0
52
1
1
0
-214
+217
MItem
11
intro_gui.c
-215
+218
WString
4
COBJ
-216
+219
WVList
0
-217
+220
WVList
0
52
1
1
0
-218
+221
MItem
11
landscape.c
-219
+222
WString
4
COBJ
-220
+223
WVList
0
-221
+224
WVList
0
52
1
1
0
-222
+225
MItem
10
main_gui.c
-223
+226
WString
4
COBJ
-224
+227
WVList
0
-225
+228
WVList
0
52
1
1
0
-226
+229
MItem
5
map.c
-227
+230
WString
4
COBJ
-228
+231
WVList
0
-229
+232
WVList
0
52
1
1
0
-230
+233
MItem
5
md5.c
-231
+234
WString
4
COBJ
-232
+235
WVList
0
-233
+236
WVList
0
52
1
1
0
-234
+237
MItem
9
minilzo.c
-235
+238
WString
4
COBJ
-236
+239
WVList
0
-237
+240
WVList
0
52
1
1
0
-238
+241
MItem
6
misc.c
-239
+242
WString
4
COBJ
-240
+243
WVList
0
-241
+244
WVList
0
52
1
1
0
-242
+245
MItem
10
misc_cmd.c
-243
+246
WString
4
COBJ
-244
+247
WVList
0
-245
+248
WVList
0
52
1
1
0
-246
+249
MItem
10
misc_gui.c
-247
+250
WString
4
COBJ
-248
+251
WVList
0
-249
+252
WVList
0
52
1
1
0
-250
+253
MItem
11
music_gui.c
-251
+254
WString
4
COBJ
-252
+255
WVList
0
-253
+256
WVList
0
52
1
1
0
-254
+257
MItem
9
namegen.c
-255
+258
WString
4
COBJ
-256
+259
WVList
0
-257
+260
WVList
0
52
1
1
0
-258
+261
MItem
9
network.c
-259
+262
WString
4
COBJ
-260
+263
WVList
0
-261
+264
WVList
0
52
1
1
0
-262
+265
MItem
16
network_client.c
-263
+266
WString
4
COBJ
-264
+267
WVList
0
-265
+268
WVList
0
52
1
1
0
-266
+269
MItem
14
network_data.c
-267
+270
WString
4
COBJ
-268
+271
WVList
0
-269
+272
WVList
0
52
1
1
0
-270
+273
MItem
18
network_gamelist.c
-271
+274
WString
4
COBJ
-272
+275
WVList
0
-273
+276
WVList
0
52
1
1
0
-274
+277
MItem
13
network_gui.c
-275
+278
WString
4
COBJ
-276
+279
WVList
0
-277
+280
WVList
0
52
1
1
0
-278
+281
MItem
16
network_server.c
-279
+282
WString
4
COBJ
-280
+283
WVList
0
-281
+284
WVList
0
52
1
1
0
-282
+285
MItem
13
network_udp.c
-283
+286
WString
4
COBJ
-284
+287
WVList
0
-285
+288
WVList
0
52
1
1
0
-286
+289
MItem
8
newgrf.c
-287
+290
WString
4
COBJ
-288
+291
WVList
0
-289
+292
WVList
0
52
1
1
0
-290
+293
MItem
10
news_gui.c
-291
+294
WString
4
COBJ
-292
+295
WVList
0
-293
+296
WVList
0
52
1
1
0
-294
+297
MItem
11
oldloader.c
-295
+298
WString
4
COBJ
-296
+299
WVList
0
-297
+300
WVList
0
52
1
1
0
-298
+301
MItem
11
order_cmd.c
-299
+302
WString
4
COBJ
-300
+303
WVList
0
-301
+304
WVList
0
52
1
1
0
-302
+305
MItem
11
order_gui.c
-303
+306
WString
4
COBJ
-304
+307
WVList
0
-305
+308
WVList
0
52
1
1
0
-306
+309
MItem
5
os2.c
-307
+310
WString
4
COBJ
-308
+311
WVList
0
-309
+312
WVList
0
52
1
1
0
-310
+313
MItem
10
pathfind.c
-311
+314
WString
4
COBJ
-312
+315
WVList
0
-313
+316
WVList
0
52
1
1
0
-314
+317
MItem
12
player_gui.c
-315
+318
WString
4
COBJ
-316
+319
WVList
0
-317
+320
WVList
0
52
1
1
0
-318
+321
MItem
9
players.c
-319
+322
WString
4
COBJ
-320
+323
WVList
0
-321
+324
WVList
0
52
1
1
0
-322
+325
MItem
7
queue.c
-323
+326
WString
4
COBJ
-324
+327
WVList
0
-325
+328
WVList
0
52
1
1
0
-326
+329
MItem
10
rail_cmd.c
-327
+330
WString
4
COBJ
-328
+331
WVList
0
-329
+332
WVList
0
52
1
1
0
-330
+333
MItem
10
rail_gui.c
-331
+334
WString
4
COBJ
-332
+335
WVList
0
-333
+336
WVList
0
52
1
1
0
-334
+337
MItem
10
road_cmd.c
-335
+338
WString
4
COBJ
-336
+339
WVList
0
-337
+340
WVList
0
52
1
1
0
-338
+341
MItem
10
road_gui.c
-339
+342
WString
4
COBJ
-340
+343
WVList
0
-341
+344
WVList
0
52
1
1
0
-342
+345
MItem
13
roadveh_cmd.c
-343
+346
WString
4
COBJ
-344
+347
WVList
0
-345
+348
WVList
0
52
1
1
0
-346
+349
MItem
13
roadveh_gui.c
-347
+350
WString
4
COBJ
-348
+351
WVList
0
-349
+352
WVList
0
52
1
1
0
-350
+353
MItem
10
saveload.c
-351
+354
WString
4
COBJ
-352
+355
WVList
0
-353
+356
WVList
0
52
1
1
0
-354
+357
MItem
12
screenshot.c
-355
+358
WString
4
COBJ
-356
+359
WVList
0
-357
+360
WVList
0
52
1
1
0
-358
+361
MItem
5
sdl.c
-359
+362
WString
4
COBJ
-360
+363
WVList
0
-361
+364
WVList
0
52
1
1
0
-362
+365
MItem
10
settings.c
-363
+366
WString
4
COBJ
-364
+367
WVList
0
-365
+368
WVList
0
52
1
1
0
-366
+369
MItem
14
settings_gui.c
-367
+370
WString
4
COBJ
-368
+371
WVList
0
-369
+372
WVList
0
52
1
1
0
-370
+373
MItem
10
ship_cmd.c
-371
+374
WString
4
COBJ
-372
+375
WVList
0
-373
+376
WVList
0
52
1
1
0
-374
+377
MItem
10
ship_gui.c
-375
+378
WString
4
COBJ
-376
+379
WVList
0
-377
+380
WVList
0
52
1
1
0
-378
+381
MItem
14
smallmap_gui.c
-379
+382
WString
4
COBJ
-380
+383
WVList
0
-381
+384
WVList
0
52
1
1
0
-382
+385
MItem
7
sound.c
-383
+386
WString
4
COBJ
-384
+387
WVList
0
-385
+388
WVList
0
52
1
1
0
-386
+389
MItem
8
sprite.c
-387
+390
WString
4
COBJ
-388
+391
WVList
0
-389
+392
WVList
0
52
1
1
0
-390
+393
MItem
13
spritecache.c
-391
+394
WString
4
COBJ
-392
+395
WVList
0
-393
+396
WVList
0
52
1
1
0
-394
+397
MItem
13
station_cmd.c
-395
+398
WString
4
COBJ
-396
+399
WVList
0
-397
+400
WVList
0
52
1
1
0
-398
+401
MItem
13
station_gui.c
-399
+402
WString
4
COBJ
-400
+403
WVList
0
-401
+404
WVList
0
52
1
1
0
-402
+405
MItem
8
StdAfx.c
-403
+406
WString
4
COBJ
-404
+407
WVList
0
-405
+408
WVList
0
52
1
1
0
-406
+409
MItem
9
strings.c
-407
+410
WString
4
COBJ
-408
+411
WVList
0
-409
+412
WVList
0
52
1
1
0
-410
+413
MItem
13
subsidy_gui.c
-411
+414
WString
4
COBJ
-412
+415
WVList
0
-413
+416
WVList
0
52
1
1
0
-414
+417
MItem
15
terraform_gui.c
-415
+418
WString
4
COBJ
-416
+419
WVList
0
-417
+420
WVList
0
52
1
1
0
-418
+421
MItem
9
texteff.c
-419
+422
WString
4
COBJ
-420
+423
WVList
0
-421
+424
WVList
0
52
1
1
0
-422
+425
MItem
10
town_cmd.c
-423
+426
WString
4
COBJ
-424
+427
WVList
0
-425
+428
WVList
0
52
1
1
0
-426
+429
MItem
10
town_gui.c
-427
+430
WString
4
COBJ
-428
+431
WVList
0
-429
+432
WVList
0
52
1
1
0
-430
+433
MItem
11
train_cmd.c
-431
+434
WString
4
COBJ
-432
+435
WVList
0
-433
+436
WVList
0
52
1
1
0
-434
+437
MItem
11
train_gui.c
-435
+438
WString
4
COBJ
-436
+439
WVList
0
-437
+440
WVList
0
52
1
1
0
-438
+441
MItem
10
tree_cmd.c
-439
+442
WString
4
COBJ
-440
+443
WVList
0
-441
+444
WVList
0
52
1
1
0
-442
+445
MItem
5
ttd.c
-443
+446
WString
4
COBJ
-444
+447
WVList
0
-445
+448
WVList
0
52
1
1
0
-446
+449
MItem
18
tunnelbridge_cmd.c
-447
+450
WString
4
COBJ
-448
+451
WVList
0
-449
+452
WVList
0
52
1
1
0
-450
+453
MItem
15
unmovable_cmd.c
-451
+454
WString
4
COBJ
-452
+455
WVList
0
-453
+456
WVList
0
52
1
1
0
-454
+457
MItem
9
vehicle.c
-455
+458
WString
4
COBJ
-456
+459
WVList
0
-457
+460
WVList
0
52
1
1
0
-458
+461
MItem
13
vehicle_gui.c
-459
+462
WString
4
COBJ
-460
+463
WVList
0
-461
+464
WVList
0
52
1
1
0
-462
+465
MItem
10
viewport.c
-463
+466
WString
4
COBJ
-464
+467
WVList
0
-465
+468
WVList
0
52
1
1
0
-466
+469
MItem
11
water_cmd.c
-467
+470
WString
4
COBJ
-468
+471
WVList
0
-469
+472
WVList
0
52
1
1
0
-470
+473
MItem
8
widget.c
-471
+474
WString
4
COBJ
-472
+475
WVList
0
-473
+476
WVList
0
52
1
1
0
-474
+477
MItem
8
window.c
-475
+478
WString
4
COBJ
-476
+479
WVList
0
-477
+480
WVList
0
52
diff --git a/os/os2/openttd.wpj b/os/os2/openttd.wpj
index f363a28d8..6c36230ad 100644
--- a/os/os2/openttd.wpj
+++ b/os/os2/openttd.wpj
@@ -42,8 +42,8 @@ WRect
WFileName
17
..\..\openttd.tgt
-51
-52
+47
+47
11
VComponent
12
diff --git a/os2.c b/os2.c
index ca24170e0..c43ba71ad 100644
--- a/os2.c
+++ b/os2.c
@@ -6,10 +6,16 @@
#include <direct.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <stdarg.h>
#include <time.h>
#include <dos.h>
+#define INCL_DOS
+#define INCL_WINDIALOGS
+#define INCL_OS2MM
+
#include <os2.h>
+#include <os2me.h>
#if defined(WITH_SDL)
#include <SDL.h>
@@ -27,6 +33,7 @@ static FiosItem *FiosAlloc()
_fios_alloc += 256;
_fios_items = realloc(_fios_items, _fios_alloc * sizeof(FiosItem));
}
+
return &_fios_items[_fios_count++];
}
@@ -45,6 +52,22 @@ int compare_FiosItems (const void *a, const void *b) {
}
+static DIR *my_opendir(char *path, char *file)
+{
+ char paths[MAX_PATH];
+
+ append_path(paths, path, file);
+ return opendir(paths);
+}
+
+static void append_path(char *out, char *path, char *file)
+{
+ if ((path[2] == '\\') && (path[3] == 0))
+ sprintf(out, "%s%s", path, file);
+ else
+ sprintf(out, "%s\\%s", path, file);
+}
+
// Get a list of savegames
FiosItem *FiosGetSavegameList(int *num, int mode)
{
@@ -60,32 +83,31 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
strcpy(_fios_save_path, _path.save_dir);
}
- if(_game_mode==GM_EDITOR)
+ if (_game_mode == GM_EDITOR)
_fios_path = _fios_scn_path;
else
_fios_path = _fios_save_path;
- // Parent directory, only if not in root already.
- if (_fios_path[1] != 0) {
+ // Parent directory, only if not of the type C:\.
+ if (_fios_path[3] != 0) {
fios = FiosAlloc();
fios->type = FIOS_TYPE_PARENT;
- fios->mtime = 0;
- sprintf(fios->title, ".. (Parent directory)");
+ strcpy(fios->title, ".. (Parent directory)");
}
// Show subdirectories first
- dir = opendir(_fios_path[0] ? _fios_path : "C:\\");
+ dir = my_opendir(_fios_path, "*.*");
if (dir != NULL) {
while ((dirent = readdir(dir))) {
- sprintf (filename, "%s\\%s", _fios_path, dirent->d_name);
+ append_path(filename, _fios_path, dirent->d_name);
if (!stat(filename, &sb)) {
if (S_ISDIR(sb.st_mode)) {
- if (dirent->d_name[0] != '.') {
+ if (!(dirent->d_name[0] == '.' && (dirent->d_name[1] == 0 || (dirent->d_name[1] == '.' && dirent->d_name[2] == 0))))
+ {
fios = FiosAlloc();
- fios->mtime = 0;
fios->type = FIOS_TYPE_DIR;
- fios->title[0] = 0;
- sprintf(fios->name, "%s\\ (Directory)", dirent->d_name);
+ strcpy(fios->name, dirent->d_name);
+ sprintf(fios->title, "%s\\ (Directory)", dirent->d_name);
}
}
}
@@ -110,10 +132,10 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
* .SV1 Transport Tycoon Deluxe (Patch) saved game
* .SV2 Transport Tycoon Deluxe (Patch) saved 2-player game
*/
- dir = opendir(_fios_path[0] ? _fios_path : "C:\\");
+ dir = my_opendir(_fios_path, "*.*");
if (dir != NULL) {
while ((dirent = readdir(dir))) {
- sprintf (filename, "%s\\%s", _fios_path, dirent->d_name);
+ append_path(filename, _fios_path, dirent->d_name);
if (!stat(filename, &sb)) {
if (!S_ISDIR(sb.st_mode)) {
char *t = strrchr(dirent->d_name, '.');
@@ -185,25 +207,35 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
int sort_start;
char filename[MAX_PATH];
- if (_fios_scn_path == NULL) {
- _fios_scn_path = malloc(MAX_PATH);
+ if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) {
+ if (_fios_scn_path == NULL)
+ _fios_scn_path = malloc(MAX_PATH);
strcpy(_fios_scn_path, _path.scenario_dir);
}
+
_fios_path = _fios_scn_path;
+ // Parent directory, only if not of the type C:\.
+ if (_fios_path[3] != 0 && mode != SLD_NEW_GAME) {
+ fios = FiosAlloc();
+ fios->type = FIOS_TYPE_PARENT;
+ strcpy(fios->title, ".. (Parent directory)");
+ }
+
// Show subdirectories first
- dir = opendir(_fios_path[0] ? _fios_path : "C:\\");
+ dir = my_opendir(_fios_path, "*.*");
if (dir != NULL) {
while ((dirent = readdir(dir))) {
- sprintf (filename, "%s\\%s", _fios_path, dirent->d_name);
+ append_path(filename, _fios_path, dirent->d_name);
if (!stat(filename, &sb)) {
if (S_ISDIR(sb.st_mode)) {
- if (dirent->d_name[0] != '.') {
+ if (!(dirent->d_name[0] == '.' && (dirent->d_name[1] == 0 || (dirent->d_name[1] == '.' && dirent->d_name[2] == 0))))
+ {
fios = FiosAlloc();
fios->mtime = 0;
fios->type = FIOS_TYPE_DIR;
- fios->title[0] = 0;
- sprintf(fios->name, "%s\\ (Directory)", dirent->d_name);
+ strcpy(fios->name, dirent->d_name);
+ sprintf(fios->title, "%s\\ (Directory)", dirent->d_name);
}
}
}
@@ -219,10 +251,10 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
* .SV0 Transport Tycoon Deluxe (Patch) scenario
* .SS0 Transport Tycoon Deluxe preset scenario
*/
- dir = opendir(_fios_path[0] ? _fios_path : "C:\\");
+ dir = my_opendir(_fios_path, "*.*");
if (dir != NULL) {
while ((dirent = readdir(dir))) {
- sprintf (filename, "%s\\%s", _fios_path, dirent->d_name);
+ append_path(filename, _fios_path, dirent->d_name);
if (!stat(filename, &sb)) {
if (!S_ISDIR(sb.st_mode)) {
char *t = strrchr(dirent->d_name, '.');
@@ -301,16 +333,28 @@ char *FiosBrowseTo(const FiosItem *item)
char *s;
switch(item->type) {
+ case FIOS_TYPE_DRIVE:
+ sprintf(path, "%c:\\", item->title[0]);
+ break;
+
case FIOS_TYPE_PARENT:
- s = strrchr(path, '\\');
- if (s != NULL) *s = 0;
+ // Skip drive part
+ path += 3;
+ s = path;
+ while (*path) {
+ if (*path== '\\')
+ s = path;
+ path++;
+ }
+ *s = 0;
break;
case FIOS_TYPE_DIR:
- s = strchr((char*)item->name, '\\');
- if (s) *s = 0;
- while (*path) path++;
- *path++ = '\\';
+ // Scan to end
+ while (*++path);
+ // Add backslash?
+ if (path[-1] != '\\') *path++ = '\\';
+
strcpy(path, item->name);
break;
@@ -325,7 +369,6 @@ char *FiosBrowseTo(const FiosItem *item)
case FIOS_TYPE_SCENARIO:
sprintf(str_buffr, "%s\\%s.scn", path, item->name);
return str_buffr;
-
case FIOS_TYPE_OLD_SCENARIO:
sprintf(str_buffr, "%s\\%s.%s", path, item->name, _old_extensions[item->old_extension]);
return str_buffr;
@@ -342,11 +385,11 @@ StringID FiosGetDescText(const char **path)
struct diskfree_t free;
char drive;
- *path = _fios_path[0] ? _fios_path : "C:\\";
- drive = 'B' - *path[0];
+ *path = _fios_path;
+ drive = *path[0] - 'A'+1;
_getdiskfree(drive, &free);
-
+
SetDParam(0, free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector);
return STR_4005_BYTES_FREE;
}
@@ -367,33 +410,33 @@ void FiosDelete(const char *name)
}
const DriverDesc _video_driver_descs[] = {
- {"null", "Null Video Driver", &_null_video_driver, 0},
+ { "null", "Null Video Driver", &_null_video_driver, 0},
#if defined(WITH_SDL)
- { "sdl", "SDL Video Driver", &_sdl_video_driver, 1},
+ { "sdl", "SDL Video Driver", &_sdl_video_driver, 1},
#endif
- { "dedicated", "Dedicated Video Driver", &_dedicated_video_driver, 0},
- { NULL, NULL, NULL, 0}
+ { "dedicated", "Dedicated Video Driver", &_dedicated_video_driver, 0},
+ { NULL, NULL, NULL, 0}
};
const DriverDesc _sound_driver_descs[] = {
- {"null", "Null Sound Driver", &_null_sound_driver, 0},
+ { "null", "Null Sound Driver", &_null_sound_driver, 0},
#if defined(WITH_SDL)
- { "sdl", "SDL Sound Driver", &_sdl_sound_driver, 1},
+ { "sdl", "SDL Sound Driver", &_sdl_sound_driver, 1},
#endif
- { NULL, NULL, NULL, 0}
+ { NULL, NULL, NULL, 0}
};
const DriverDesc _music_driver_descs[] = {
- { "null", "Null Music Driver", &_null_music_driver, 0},
- { NULL, NULL, NULL, 0}
+ { "os2", "OS/2 Music Driver", &_os2_music_driver, 0},
+ { "null", "Null Music Driver", &_null_music_driver, 1},
+ { NULL, NULL, NULL, 0}
};
/* GetOSVersion returns the minimal required version of OS to be able to use that driver.
- Not needed for *nix. */
+ Not needed for OS/2. */
byte GetOSVersion()
{
return 2; // any arbitrary number bigger then 0
- // numbers lower than 2 breaks default music selection on mac
}
bool FileExists(const char *filename)
@@ -438,15 +481,15 @@ static void ChangeWorkingDirectory(char *exe)
}
}
+// for some reason these calls don't actually work properly :/
void ShowInfo(const char *str)
{
- puts(str);
+ WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, str, "OpenTTD", 0, MB_OK | MB_SYSTEMMODAL | MB_MOVEABLE | MB_INFORMATION);
}
void ShowOSErrorBox(const char *buf)
{
- WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, buf, "OpenTTD", 263, MB_OK | MB_APPLMODAL | MB_MOVEABLE | MB_ERROR);
-// TODO: FIX, doesn't always appear
+ WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, buf, "OpenTTD", 0, MB_OK | MB_SYSTEMMODAL | MB_MOVEABLE | MB_ERROR);
}
int CDECL main(int argc, char* argv[])
@@ -529,3 +572,85 @@ void DeterminePaths()
mkdir(_path.scenario_dir);
}
+// FUNCTION: OS2_SwitchToConsoleMode
+//
+// Switches OpenTTD to a console app at run-time, instead of a PM app
+// Necessary to see stdout, etc
+
+void OS2_SwitchToConsoleMode()
+{
+ PPIB pib;
+ PTIB tib;
+
+ DosGetInfoBlocks(&tib, &pib);
+
+ // Change flag from PM to VIO
+ pib->pib_ultype = 3;
+}
+
+
+/**********************
+ * OS/2 MIDI PLAYER
+ **********************/
+
+/* Interesting how similar the MCI API in OS/2 is to the Win32 MCI API,
+ * eh? Anyone would think they both came from the same place originally! ;)
+ */
+
+static long CDECL MidiSendCommand(const char *cmd, ...)
+{
+ va_list va;
+ char buf[512];
+ va_start(va, cmd);
+ vsprintf(buf, cmd, va);
+ va_end(va);
+ return mciSendString(buf, NULL, 0, NULL, 0);
+}
+
+static void OS2MidiPlaySong(const char *filename)
+{
+ MidiSendCommand("close all");
+
+ if (MidiSendCommand("open %s type sequencer alias song", filename) != 0)
+ return;
+
+ MidiSendCommand("play song from 0");
+}
+
+static void OS2MidiStopSong()
+{
+ MidiSendCommand("close all");
+}
+
+static void OS2MidiSetVolume(byte vol)
+{
+ MidiSendCommand("set song audio volume %d", ((vol/127)*100));
+}
+
+static bool OS2MidiIsSongPlaying()
+{
+ char buf[16];
+ mciSendString("status song mode", buf, sizeof(buf), NULL, 0);
+ return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
+}
+
+static char *OS2MidiStart(char **parm)
+{
+ return 0;
+}
+
+static void OS2MidiStop()
+{
+ MidiSendCommand("close all");
+}
+
+const HalMusicDriver _os2_music_driver = {
+ OS2MidiStart,
+ OS2MidiStop,
+ OS2MidiPlaySong,
+ OS2MidiStopSong,
+ OS2MidiIsSongPlaying,
+ OS2MidiSetVolume,
+};
+
+
diff --git a/sdl.c b/sdl.c
index 1fabe2666..c9275f37a 100644
--- a/sdl.c
+++ b/sdl.c
@@ -408,7 +408,7 @@ static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
}
// check scancode for BACKQUOTE key, because we want the key left of "1", not anything else (on non-US keyboards)
-#if defined(WIN32)
+#if defined(WIN32) || defined(__OS2__)
if (sym->scancode == 41) key |= WKC_BACKQUOTE;
#elif defined(__APPLE__)
if (sym->scancode == 10) key |= WKC_BACKQUOTE;
diff --git a/strgen/strgen.tgt b/strgen/strgen.tgt
index 1ef11fe0f..8eaf49dfb 100644
--- a/strgen/strgen.tgt
+++ b/strgen/strgen.tgt
@@ -15,13 +15,15 @@ WString
oc2en
1
0
-1
+0
4
MCommand
0
5
MCommand
-0
+26
+..\os\os2\build_lang.cmd
+
6
MItem
10
@@ -77,44 +79,68 @@ WString
COBJ
19
WVList
-0
+2
20
+MRState
+21
+WString
+3
+WCC
+22
+WString
+29
+?????No debugging information
+0
+1
+23
+MRState
+24
+WString
+3
+WCC
+25
+WString
+28
+?????Line number information
+0
+0
+26
WVList
0
-1
1
1
0
-21
+27
MItem
8
stdafx.c
-22
+28
WString
4
COBJ
-23
+29
WVList
0
-24
+30
WVList
0
17
1
1
0
-25
+31
MItem
8
strgen.c
-26
+32
WString
4
COBJ
-27
+33
WVList
0
-28
+34
WVList
0
17