Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

homm3se

Heroes of Might and Magic III SaveEditor

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

Heroes III SaveEditor (English edition)

A save game editor for Heroes of Might and Magic III (Windows, 2001–2005). This is the source code of the last version, 2.05 (April 2005), as it was, only translated into English. The original Russian version is in the main-rus branch and under the v2.05 tag, together with the original builds on the Releases page.

In this edition the interface, the help, the version history, the installer and the code comments are translated into English. The slang of the original is kept. Heroes, creatures, artifacts, spells, skills and classes use their official names from the English version of the game.

History

I started this project more than 25 years ago, when I was 17. I was an enthusiast and a big fan of the game, and I loved building my own maps for Heroes 3 and testing them. I wrote the utility mainly for myself. I needed a quick way to see how computer opponents develop on a map, where problems come up and how hard the map really is. For that I needed a simple program that could boost a hero.

At the same time, I have always believed that boosting a hero just to make the game easier kills the interest in the game itself. The program's help file carries a warning about this too.

The utility became quite popular: I received a lot of thanks and questions about how it works. Now it is time to publish its source code.

It all began in 2001 with a DOS program called HoMM III CRACK. In 2002 I ported it to Win32 and renamed it Heroes III SaveEditor. The full version history is in Document/history.html.

Ztalker

Features

  • Supports The Restoration of Erathia, Armageddon's Blade, The Shadow of Death, Heroes Chronicles and In the Wake of Gods. The editor can detect the game version on its own.
  • Opens campaign saves (.cgm) and single and multiplayer game saves (.gm1–.gm8).
  • Hero editor: name, class, primary skills, mana, movement points, level and experience (each is recalculated from the other), 7 troop slots, 8 secondary skills, up to 64 artifacts in the backpack, spells and the spell book.
  • Resource editor: gold, wood, mercury, ore, sulfur, crystal, gems.
  • Saving a hero's parameters and loading them onto another hero, either in full or section by section. Each tab also has quick save and quick load.

How it works

  1. A Heroes 3 save file is gzip-compressed. The editor unpacks it into a temporary file hmm3edit. next to the program.
  2. The data is located by searching: a hero by name, resources by the current amount of gold (other resources can be added to the search). If there are several matches, you can move on to the next one.
  3. New values are written at the offsets found. The data layout depends on the selected edition of the game.
  4. The file is gzip-compressed again and saved under a new name (se_* by default).

Settings and saved hero parameters are stored in the registry under HKEY_CURRENT_USER\SOFTWARE\VItonIC\Heroes III SaveEditor.

State of the source code

The code is the same as it was in 2005. The translation changed only texts: interface strings, messages, comments and the lists of game names. The one change in logic is the player count shown for an opened save ("Game for 1 player" / "Game for N players"), because English plurals work differently.

The list of hero names in the hero search matches the English version of the game. With a localized version of the game, type the hero name the way it is spelled in your game.

Sorry for the mistakes in the names of functions, variables and components, but I have left the source code as it was.

Building

Requirements

OS Windows capable of running C++Builder 6
Compiler Borland C++Builder 6 (BCB.06.00 in the project file)
Libraries VCL and RTL from C++Builder 6, ZipLib from this repository
Installer (optional) NSIS 2.x with Modern UI

Newer versions of C++Builder (2009 and later) will not build the project without changes: since then the VCL has switched to Unicode, while the code relies on AnsiString and char*.

Steps

  1. Open hmm3se.bpr in C++Builder 6.
  2. Run Project → Build hmm3se. The built-in Delphi compiler compiles the ZipLib Pascal units and generates .obj and .hpp files for them.
  3. The result is hmm3se.exe in the project root. The help files Document/*.html must sit next to it, in the Document folder.

Project file notes

  • The project is saved in the debug configuration, as it was in 2005: _DEBUG, no optimization (-Od), with debug information. This does not get in the way of building. How to build a release version is described below.
  • The precompiled header cache is written to the C++Builder folder: -H=$(BCB)\lib\vcl60.csm. In 2005 this was a hard-coded path to the author's folder; it was replaced with the standard one before publication.

Release build

The program works in the debug configuration, but the exe is larger and slower, and a debug information file hmm3se.tds is created next to it. To build a release version, open Project → Options in C++Builder 6 and do the following:

  1. Compiler tab: click Release. This turns on -O2 optimization and turns off debug information.
  2. Pascal tab: click Release. These are the settings for the ZipLib units.
  3. Linker tab: clear Create debug information.
  4. Directories/Conditionals tab: remove _DEBUG from Conditional defines. The code does not use this macro, but this keeps the configuration clean.
  5. Click OK and run Project → Build hmm3se. Use Build, not Make, so that all units are recompiled with the new settings.

The IDE will write the new settings to hmm3se.bpr. If you build a release only for yourself, do not commit this file.

Installer

The NSIS 2 script Install/hmm3se.nsi takes ..\hmm3se.exe and the documentation and builds heroes3se205.exe. The installer interface is in English.

Encoding

All text files keep the Windows-1251 encoding with CRLF line endings, as C++Builder 6 expects. After the translation they are almost pure ASCII, so GitHub shows them correctly. The only Russian letters left are in the help note about Russian translations of the game. Form files (.dfm) and resources (.res) are binary.

Repository layout

Path Contents
hmm3se.bpr, hmm3se.cpp, hmm3se.res project, entry point, resources (icon, version info)
crakMain.* main window: opening and saving, hero and resource search
CrackHero.* hero parameters window
Unit_SaveHero.*, Unit_LoadHero.* saving and loading hero parameters
Options.*, About.* settings, About box
const.hpp, heroconst.hpp constants: version, registry keys, lists of creatures, artifacts and classes
utilits.h, Utilfind.h searching the save file
ZipLib/ gzip compression (see below)
Document/ help and version history (HTML)
image/ icons and images used by the interface
Install/ NSIS installer script and its icons

Third-party code: ZipLib

ZipLib/ contains the source code of the compression library:

  • PasZLib 1.0, revision of March 24, 2000: a Pascal translation of zlib 1.1.2 (Jean-loup Gailly, Mark Adler) by Jacques Nomssi Nzali.
  • DelphiGzip 0.2.99: a TGzip component on top of PasZLib for packing and unpacking gzip files. The author is not named in the source code.

Why the library is in the repository: there were no package managers for C++Builder back then, and the units are compiled together with the project. In addition, DelphiGzip.pas, gzio.pas, TREES.PAS and Zutil.pas were modified for the project in 2003–2005.

ZipLib is distributed under the zlib license. The license text and the PasZLib description are in ZipLib/readme.txt, the file the source headers refer to. It was not part of the project in 2005: it was taken from the official Free Pascal repository (tag release_2_2_4, packages/paszlib/readme.txt). It is the author's readme for the same revision of March 24, 2000.

License

The project code is distributed under the MIT license; see LICENSE.

Exceptions:

  • ZipLib/: its own licenses. PasZLib is distributed under the zlib license, see ZipLib/readme.txt. The author and license of DelphiGzip are not stated in the source code; the component is included as it was received.
  • Graphics from Heroes of Might and Magic III: hero portraits and the coat of arms in the edition icons (image/ico/Erathia.ico, Blade.ico, Shad.ico, Chron.ico, Chron2.ico, h3erath.ico, H3Blade.ico, H3Shad.ico, h3chUW.ico, h3chWL.ico) and the game logo in image/about2.BMP. These images belong to the game's rights holders and are not covered by the MIT license. They are here as part of the original 2005 project: the program's interface uses them, and the same images are embedded in the .dfm form files and in hmm3se.res.
  • The game's names and logos belong to their rights holders (see "Trademarks").

Trademarks

Heroes of Might and Magic is a trademark of Ubisoft Entertainment (formerly New World Computing and The 3DO Company). This project is not affiliated with the rights holders. Use it at your own risk and keep backups of your saves.