For a while I was playing the game Dangerous Waters by Sonalysts. It's a naval simulation game, and perhaps the most advanced of its kind, but it also has a number of annoying bugs and bits of bad coding. I tried to reverse engineer the game in hopes of eventually patching the executable to fix some of the bugs. I never got that far, but here's what I found.
Command Line Arguments
These are the command-line arguments that the game recognizes. The command line arguments can begin with either a slash (e.g. /n) or a dash (e.g. -n). The names of command-line arguments are case-sensitive.
- /debugoutput – Output debug information (requires an attached debugger).
- /wences – Allows multiple instances of the game to run simultaneously, and uniquefies the names of replay files.
- /noswitchres – Disallow changes to screen resolution.
- /no3d – Disables the 3D view.
- /noenum – Do not try to enumerate display modes before running.
- /adapterID <n> – Select the graphics adapter to use, where I believe 0 is the first, 1 is the second, etc, but I'm not sure.
- /deviceID <n> – Select the graphics device to use, where I believe 0 is the first, 1 is the second, etc, but I'm not sure.
- /modeID <n> – Select the graphics mode to use, where I believe 1 is the first, 2 is the second, etc, but I'm not sure.
- /ATIFixed – Enables a graphics hack for ATI cards.
- /wantManualClear – Enables a graphics hack for Geforce3 cards.
- /wantVSync – Enable synchronization with the vertical retrace.
- /limit – Repaints the screen at most once every 33 milliseconds.
- /fullscreen – Start in fullscreen mode.
- /windowed – Start in windowed mode.
- /host – Begin hosting a game.
- /join <address> – Join a game at the given address.
- /connect <address> – Same as /join.
- /name <username> – Set the user name for multiplayer games.
- /n <username> – Same as /name.
- /maxplayers <n 1-30> – Sets the maximum number of players when hosting a game.
- /gclaunched – Unsure. Forces the game to think that a multiplayer game has been launched on startup. Perhaps this is meant to be used by lobby software such as GameSpy?
- /useiniseed – Use the seed from the INI file when generating a scenario.
- /seed <n> – Use the provided seed when generating a scenario.
- /scenario <name> – Sets the name of the scenario to use when hosting a game.
- /hull <n 1-65534> – Sets the ID of the hull you wish to use.
- /lang <e|f|g|c|j> – Display text in English, French, German, Chinese, or Japanese (assuming the corresponding language pack is installed).
- /skipopening – Skip the opening movies.
- /nodisplay – Apparently unused.
- /nosound – Disable sound support.
- /noreplay – Don't create a replay.
- /noaggie – Unknown and possibly unused.
- /noDDSSupport – Unknown and possibly unused.
- /limitDDSTexSize – Unknown and possibly unused.
- /? /help – Displays a help message.
Playing without the CD
To eliminate the need for the CD to be inserted while playing the game, simply do the following:
- Copy the "World" and "Music" directories from the CD to a location on the hard drive.
- Open HKEY_LOCAL_MACHINE\SOFTWARE\Sonalysts Combat Simulations\Dangerous Waters\1.0 in a registry editor.
- Edit cdInstallPath to the be the path to the parent of the "World" directory (e.g. if the "World" directory is at C:\DW\World, then set the value to C:\DW).
- Edit musicInstallPath to be the path to the "Music" directory (e.g. if the "Music" directory is at C:\DW\Audio\Music, then set the value to C:\DW\Audio\Music).
.ndx/.grp Archive File Format
The .ndx/.grp files hold nearly all of the game's assets. The file format is quite simple. The .grp file holds the data and the .ndx file holds indices into the .grp file.
.ndx Index File Format
An .ndx file contains a number of 100-byte records, each of which describes a single file stored within the .grp file. There is no header that tells the number of entries in the index; the file is simply a multiple of 100 bytes in length. The entries must be sorted case-insensitively by name, as the game uses strcmpi() and a binary search to find them. Names should also be unique within the index. Each index entry has the following format:
00h char name The nul-terminated name of the file within the archive, in ASCII 50h uint offset The offset within the .grp file where the data starts 54h uint uncompressedSize The uncompressed size of the data 58h uint compressedSize The compressed size of the data (and its extent within the .grp file) 5Ch uint pixelWidth If the file is an image, this is its width in pixels. Otherwise, 0. 60h uint pixelHeight If the file is an image, this is its height in pixels. Otherwise, 0.
.grp Data File Format
A .grp file simply contains blocks of data at the offsets specified within the .ndx file. Each block of data is compressed with the PKWARE Data Compression Library compression format. This format is proprietary, but a (slightly erroneous) description of the format can be found in a Usenet post by Ben Rudiak-Gould on comp.compression. I have also implemented a compressor and decompressor in my IO library.
I've implemented a pretty robust and full-featured archive manager for the .ndx/.grp archive format. It is released as part of my Dangerous Waters Mod Utilities package.
IDA Pro 6.1 Database
If you would like to continue my reverse engineering work, you can do so with IDA Pro 6.1 using my database file. This database was created to work with Dangerous Waters version 1.04 build 378. I recommend using the Hex-Rays decompiler.