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.
Debugging
- /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.
Graphics
- /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.
Multiplayer
- /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.
UI
- /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.
Other
- /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[80] 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.
Archive Manager
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.
Comments
Congratulation for Your work !!!
I'm try to add new playable unit in DW, have Youn never work with weaponloadout ?It's very complicate to modify.
Best regards,
Fausto
I also looked into adding new playable units. I tried disassembling the DLLs used to implement the different stations. Unfortunately, the interface to the DLL is not simple, and it would require many months of reverse engineering to figure it all out, so I gave up on it. :-(
-- Adam
I am starting to use your useful grp.exe to mod DW but unpacking a grp file I get the ERROR: There is insufficient space in the output buffer .
Can you please take a look to the possible bug and let me know how to workaround the error?
Thanks in advance for any help.
thanks for support: I will try the fixed grp in the next couple of days.
My intention is to try to get the last position of the units from the replay file as if it were a save file.
Thank You !!!