TheSuperHackers / GeneralsGamePatch

Community Patch to fix and improve original Generals Zero Hour 1.04
Other
60 stars 20 forks source link

Implement Patch Loader tool #140

Open xezon opened 3 years ago

xezon commented 3 years ago

We will need some Patch Loader tool that is pushed infront of the regular generals.exe boot.

It needs to have

  1. Native accessibility and ability to improve original game install
  2. Simple UI with buttons to select Original game, Patched game (this), Other Mod(s)
  3. Method to clean the game install and wipe any third party changes that could mess up things
  4. Method to configure a preferred game selection that activates automatically
  5. Method to configure the Other Mod selection
  6. Method to download, install and switch Mods
  7. Method to download, install and switch Addons
  8. Method to download, install and switch Language Packs
  9. Method to download, install and manage Custom Maps
  10. Method to control and skip the app via command line
  11. Method to configure command line to pass to real generals.exe
  12. Appropriate control of launcher life time
  13. Optional information to help player discover other players
  14. [MAYBE] Method to override game Heat Effects option

Native accessibility and ability to improve original game install

Patch Loader maybe needs to replace original generals.exe. This is critical decision. Patch Loader must be well tested in this case. Patch Loader will load real generals.exe, which will be placed nearby or can be linked to original generals.exe from both Generals and Generals Zero Hour. generals.exe must have no SecuROM restrictions to avoid problems on Windows 10. Patch Loader should fix a series of install issues, such as placing default Options.ini if not exist to avoid crash on launch or removing dbghelp.dll file to avoid crash on AMD systems. See this page for reference: https://www.gamereplays.org/cnczerohour/portals.php?show=index&name=gentool&tab=8280900 And this: https://legi.cc/downloads/genpatcher/

Simple UI with buttons to select Original game, Patched game (this), Other Mod(s)

This likely would look similar to the Origin launcher where user can select Generals and Zero Hour game from dialog box. By default Patch Loader must disable all .big files that are not related to selected game version. We may offer option override for .big file author by placing PatchLoader\PreferEnable.dat file inside. Every game listed in Patch Loader must have settings option to configure optional Addons, for example ControlBarPro. We may have notification element(s) in UI that tells user that there is an update for a Mod / Addon, if the Patch Loader supports downloads and updates. Texts must be localized.

Method to clean the game install and wipe any third party changes that could mess up things

User may have modified files in his install directory from past times that override core functionality of Mods and Patch. Patch Loader may need functionality to detect and solve problems. This will help user to run game without unexpected problems. We could have it pop up a dialog which lists all unexpected files that user can select for removal/backup. Ideally Patch Loader manages all mod files itself to avoid misconfigurations in user install.

Method to configure a preferred game selection that activates automatically

We could have a (optional) short countdown that automatically launches the game with a user selected default Version / Mod. This way user does not need to click anything and game will start automatically. Countdown length can be customizable. Countdown must abort when clicking any UI element.

Method to configure the Other Mod selection

A small dialog helps linking installed Mods/Addons into the Patch Loader. User can specify a Mod name and all related .big files in Game Install directory. Information is then stored in configuration file. Configuration file can be pre-configured by Mod / Addon authors (preferred). Core UI will then display newly configured Mod as load option.

Method to download, install and switch Mods

Mod options described in previous section can be expanded by adding Download and Update functionality for existing mod setups. Patch Loader can download master file(s) from user customizable sources, that defines Mod Installs it can offer to user. This way Mod Creators can provide authority over client updates in Patch Loader. Ideally Mods have little descriptions (localized) and maybe even pictures to explain to user what this is about. Mod Installs ideally are non destructive to Game Install, meaning they only become active when launched through the Patch Loader, and are deactivated after the game session ended.

Method to download, install and switch Addons

Similar to Mod download and install, we also can have Addon support. Addons are different from Mods in the way that they are added on top of the Original games, the Patch (this) or another 3rd party Mod. Addons must be marked whether or not they will change game state or are purely cosmetic. Addons need special attention and testing to make sure they don't break original functionality by removing or changing functionality they are not supposed to.

Method to download, install and switch Language Packs

Similar to Addon download and install, we also can have Language Pack support. Language packs are simple to install by dropping the *.big files and activate by changing the Language registry keys of Generals and Zero Hour. Some Mods may not be compatible with original Language Pack, if they add new text entries in Generals.csf or new sounds in Voice.ini. In such cases, Mod definition must specify compatible languages, and Patch Loader will automatically default language if user language is not supported by Mod. User system may not have required fonts installed for certain language pack. In such case, Patch Loader should download and install font to make sure that language text renders correctly in game.

Method to download, install and manage Custom Maps

Another content option is Custom Maps. Maps are installed to the Generals Data directory in My Documents. Maps can not just be downloaded and installed, but also removed. Custom Maps could also be linked to certain Mods, so they don't show up for Mod they are not supposed to. This however needs consideration with GenTool, because GenTool will auto download maps which will defeat such kind of functionality.

Mods, Addons, Languages and Maps need to be discoverable by configuration file(s). A typical configuration could look like so:

<dlcs>
  <dlc guid="161c902a-b593-49c5-9030-1bf89ac9ba2f" name="Contra" isMod="1" isAddon="0" isLanguagePack="0" isMap="0">
    <files>
      <file name="ContraZH.big" sha256="70ECE803836F..." url="https://contramod.com/download/ContraMod99.zip" isArchived="1" />
      <file name="ContraAudioZH.big" sha256="9482B9D68B4A..." url="https://contramod.com/download/ContraMod99.zip" isArchived="1" />
    </files>
    <images>
      <image url="https://contramod.com/download/image1.png">
      <image url="https://contramod.com/download/image2.png">
    </images>
    <descriptions>
      <description language="English" text="Contra Mod sets player in year 2099 and bla bla..." />
      <description language="German" text="Contra Mod lässt den Spieler in das Jahr 2099 eintauchen und bla bla..." />
    </descriptions>
  </dlc>
  <dlc guid="fe95b098-5294-4aa7-9eb9-3c3a2a817d39" name="Control Bar Pro" isMod="0" isAddon="1" isLanguagePack="0" isMap="0">
    <files>
      <file name="ControlBarProZH.big" sha256="70ECE803836F..." url="https://gentool.net/download/ControlBarPro.zip" isArchived="1" />
    </files>
    <compatibledlcs>
      <compatibledlc guid="63cfd60b-8d26-4add-91d1-f30b17f62721" />
      <compatibledlc guid="bfd30892-45b6-4f23-b619-22fa9e30919d" />
    </compatibledlcs>
  </dlc>
</dlcs>

In this case the configuration file would contain 2 DLC entries. It can contain any amount of configurations. Patch Loader can load as many configuration files as it is able to discover and combine all configurations. isMod, isAddon, isLanguagePack and isMap are hints as to what this content is for. This allows Patch Loader to properly classify and present it to the user. Hint may be incorrectly setup by the Mod Author, in which case Patch Loader should verify the integrity of the contents. However, it can only do so after download. It can inspect BIG files and check if it contains certain INI files. If it does, it can verify it as either Mod or Addon. If it only contains maps, then it verifies as Map pack. Ideally classification and verification do match. Patch Loader can check hash (sha256 or so) to check whether or not player has latest file locally. If not, Then update can be offered.

For special configurations that should only exist once, we can have special master configuration like so:

<dlcs>
  <dlc guid="7d3e70eb-b0a6-448a-9f6a-2eb234d8c704" name="Contra" isMod="1" isAddon="0" isLanguagePack="0" isMap="0" isSecondary="1" rank="1">
    <files>
      <file name="ContraZH.big" sha256="70ECE803836F..." url="https://contramod.com/download/ContraMod99.zip" isArchived="1" />
      <file name="ContraAudioZH.big" sha256="9482B9D68B4A..." url="https://contramod.com/download/ContraMod99.zip" isArchived="1" />
    </files>
  </dlc>
  <dlc guid="84f7c9c1-6661-40db-b9c6-adcf75b0c8ab" name="Shockwave" isMod="1" isAddon="0" isLanguagePack="0" isMap="0" isSecondary="1" rank="2">
  </dlc>
  <dlc guid="67776ba5-ef64-4d24-8f6e-b5566ef2c447" name="Rise of the Reds" isMod="1" isAddon="0" isLanguagePack="0" isMap="0" isSecondary="1" rank="3">
  </dlc>
</dlcs>

See new special attributes isSecondary and rank. In this case the configuration file would provide secondary DLC definition, which could be overwritten by other configuration, for example from Mod Authors themselves. The rank hint would allow Patch Loader to rank mod in user facing ui, which helps pushing better quality content more to viewers attention as opposed to lower quality content.

Method to control and skip the app via command line

We need some command line arguments so other launchers can control this launcher for compatibility reasons. For example a 3rd party may want to roll its own launcher. Instead of uninstalling this Patch Loader to avoid it from showing its UI on start, it can instruct it to do trampoline user to game. Arguments: -ploader skip Skips the loader so it does nothing other than forwarding the boot to original game -ploader original Loads original game without any mod -ploader patch104p Loads patch (this) -ploader mod Loads last selected mod -ploader MODNAME Loads mod with specific name

Method to configure command line to pass to real generals.exe

Provide functionality to configure command line arguments that are passed to real generals.exe. And/or check boxes for simplicity. This allows to append command line in scenarios where parent launcher does not allow to configure command line, such as GameRanger and Origin. This functionality will make GeneralsProxyLauncher obsolete. See: http://gentool.net/download/tools/

Appropriate control of launcher life time

Launcher life time requirements need to be properly established. In case of GameRanger for example it will be critical to keep the launcher running as long as the game runs, but close the launcher when the game closes. Otherwise GameRanger will not handle room session enter and leave correctly.

Optional information to help player discover other players

With players spread around different platforms, it is difficult to keep track of where players are. In GameRanger it is easy, because everyone is put in one lobby. With CNC Online it is a little bit more tricky, because player needs to register a CNC Online Account and download GenTool or CNC Online Launcher app to connect, and then find a lobby where players are. With Radmin it is most difficult, because there is no way to discover VPN servers natively. Patch Loader eventually could pull a list of popular servers and present them to user for discovery.

There should be a single unified backend accessible through the native game multiplayer lobby.

Method to override game Heat Effects option

Heat Effect can cause serious graphical issues in game and is best turned off by default. Most users are not aware about this problem and when it happens, they don't know how to fix it. In Patch Loader we could force disable this setting via native Options.ini file and provide a manual switch to give game control over enabling it. This way user can be educated about potential bad side effects.

Thyme should fix Heat Effects rendering bug.

Patch Loader needs to be compatible with Origin, which has only one game in its library for Generals + Zero Hour.

xezon commented 3 years ago

This is first mockup. It follows visual style of official Generals Zero Hour Origin Launcher. Images, colors, texts, button sizes are just at random. This is just to convey the idea of the front window. Clicking the Settings button at the bottom would then open the customization menu where Mod can be configured. Mod can be toggled by pressing left and right. User will know what is in his Launcher Mod Library, because he installs new Mod or configures it himself in the Launcher settings. Generals game must be present in the launcher, otherwise we could get problems with Origin, because Generals and Generals Zero Hour are listed as one game in Origin itself. To be tested.

Mockup1

xezon commented 3 years ago

DeL is currently working on "GenLauncher" tool twritten in C# that implements Mod downloads and Generals Launcher. We need to evaluate if .NET App is ok for our purposes.

C# pros

C# cons

C++ pros

C++ cons

We can check if there is a C++ Project we could use as a base to cut some time setting up the project. Basically all we need is libraries for

Archived compression is very valuable for Mod downloads. BIG container with TGA, INI, WND compress very nicely and compact.

If these things are in place, it should be fairly easy to implement the functionality and setup the UI. If we don't want to go this tedious route, then C# or Java would be the easier options, but would come with draw backs when it comes to the final product.

My 2 cents.

xezon commented 3 years ago

Organization of mod files needs some thinking. There are different approaches:

Moving .big files into a sub folder does not disable them entirely, unless folder starts with dot. Big files can load from sub folders, but .big files in install directory take precedence. Organizing mod files in sub folders may be a preferable approach to have a somewhat clean root directory that does not get too messed up by installing a lot of Mods and Addons.

Kesanov commented 3 years ago

I am against duplication of effort. However, since C++ was suggested, I have to suggest another language: Rust

Rust is a nice middle ground between C++ and C#.

Rust pros

Rust cons

I have made a proof of concept to give a better idea of how UIs are built: https://github.com/Kesanov/GeneralsLauncherRust

xezon commented 1 year ago

Survey options

The tool may be utilized for survey questions to gather intel about player impressions for any given project. Survey questions could be integrated in a classic dedicated format, or in a more integrated fashion where game interactions lead to an occasional and non-intrusive survey question. With Thyme it would be possible to have knowledge about player game interactions and select appropriate survey question(s) accordingly. A question could be posted after game shutdown or in the game after a match. If easy to use, then over time it could allow to gather valuable feedback from the general player population. This can help shape a project for the time to come.

xezon commented 1 year ago

Hash and signature verification

Mod Builder will generate plain hash and encrypted hash files for bundle packs (TheSuperHackers/GeneralsModBuilder#38). This can then be used by Patch Loader to verify hash and signature of new releases. This can help prevent installing and executing wrong or malicious files on client machines, as long as their original Patch Loader client install was of legitimate origin.