HotPatcher Modular Transformation and Development Planning

HotPatcher的模块化改造和开发规划

With the development of HotPatcher and my research on resource management technology, more and more features are being implemented around HotPatcher, and the implementation is becoming increasingly complex. Coupled with continuous updates of the engine, maintaining compatibility for a large and comprehensive plugin has become more difficult.

With the arrival of the new generation engine UE5, HotPatcher will also follow up with support for UE5 and develop new features based on UE5’s characteristics. I hope it will not only be a resource packaging tool but also include a comprehensive resource management solution encompassing resource management, auditing, packaging, hot updates, package optimization, and build enhancements, and serve as an open resource processing framework.

This article will introduce the modular progress of HotPatcher, support for existing features, and how to use the powerful packaging capability of HotPatcher to customize modular extensions based on project needs. Finally, I will discuss the future development plans for the HotPatcher project.

Currently, most of the core functions of HotPatcher support both UE4.21-UE5.1. However, each new engine version release brings too much effort and time for plugin adaptation. Moreover, most features used to be integrated into a single plugin, which limited functionality expansion.

Therefore, in response to these issues, I have initiated a modular transformation plan for the HotPatcher project. HotPatcher will only provide core packaging functionalities, with other extensions implemented independently and available for download as needed. Of course, the modularization of functions is not an overnight process. Since 2021, I have been considering separating non-core functionalities into standalone modules for on-demand download and use, but I did not achieve complete modular transformation.

Now, in 2023, it is time to do this. Time flies; on November 22, 2019, I made the first commit to this project, and now three years have passed, with over 700 commits and numerous blog articles. I am glad to see HotPatcher being applied in many projects, and at the same time, the plugin functions are continuously updated and iterated.

Modular Transformation

First of all, HotPatcher is an independent UE plugin. If one wants to implement a similar modular framework that can be compiled within UE, it can be counterproductive.

Therefore, my implementation is similarly based on UE’s plugin mechanism, and modules developed based on HotPatcher are also UE code plugins; they will depend on HotPatcher and can include its code.

Taking the already completed modular transformation of the GameFeaturePacker module as an example, I will introduce the mechanism of HotPatcher modules and the functionalities that can be implemented.

GameFeaturePacker is something I implemented earlier, which can be used to package the new UE5 GamePlay mechanism GameFeature. Detailed information can be found in my previous article: UE5: Game Feature Research.

First, as mentioned previously, it is also a UE plugin, and its uplugin file is as follows:

GameFeaturePacker.uplugin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "GameFeaturePacker",
"Category": "Other",
"CreatedBy": "lipengzha",
"CreatedByURL": "https://imzlp.com/",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": false,
"Plugins": [
{
"Name": "HotPatcher",
"Enabled": true
}
],
"Modules": [
{
"Name": "GameFeaturePacker",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "GameFeaturePackerEditor",
"Type": "Editor",
"LoadingPhase": "PostDefault"
}
]
}

It depends on the HotPatcher plugin, and to register the module in HotPatcher, an Editor module must be available, and its LoadingPhase should be set to PostDefault. In the Build.cs of the Editor module, include the HotPatcher modules:

GameFeaturePackerEditor.cs
1
2
3
4
5
6
7
8
PublicDependencyModuleNames.AddRange(
new string[]
{
"HotPatcherRuntime",
"HotPatcherCore",
"HotPatcherEditor"
}
);

This allows the HotPatcher’s functionalities to be used within this independent plugin.

The C++ definition of the GameFeaturePackerEditor module must also follow specific conventions, inheriting from FHotPatcherModBaseModule and overriding the GetModDesc interface:

1
2
3
4
5
6
7
8
9
class FGameFeaturePackerEditorModule : public FHotPatcherModBaseModule
{
public:

/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
virtual FHotPatcherModDesc GetModDesc()const override;
};

Implement the module registration in the .cpp file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void FGameFeaturePackerEditorModule::StartupModule()
{
FHotPatcherModBaseModule::StartupModule();
}

void FGameFeaturePackerEditorModule::ShutdownModule()
{
FHotPatcherModBaseModule::ShutdownModule();
}

FHotPatcherModDesc FGameFeaturePackerEditorModule::GetModDesc() const
{
FHotPatcherModDesc TmpModDesc;
TmpModDesc.ModName = MOD_NAME;
TmpModDesc.CurrentVersion = MOD_VERSION;
TmpModDesc.bIsBuiltInMod = IS_INTERNAL_MODE;
TmpModDesc.MinHotPatcherVersion = 80.0f;
TmpModDesc.Description = TEXT("Plugin/GameFeature Packager");
TmpModDesc.URL = TEXT("https://imzlp.com/posts/17658/");
TmpModDesc.UpdateURL = TEXT("https://github.com/hxhb/HotPatcher/Mods/GameFeaturePacker");
TArray<FHotPatcherActionDesc> ActionDescs;
TmpModDesc.ModActions.Emplace(
TEXT("Patcher"),MOD_NAME,TEXT("ByGameFeature"), TEXT("Create an Game Feature Package."),
CREATE_ACTION_WIDGET_LAMBDA(SGameFeaturePackageWidget,TEXT("ByGameFeature")),0
);
return TmpModDesc;
}

Note: Always call the base class FHotPatcherModBaseModule functions in the StartupModule and ShutdownModule of the module.

Register the current plugin in the GetModDesc function.

A HotPatcher mod definition can have the following attributes:

1
2
3
4
5
6
7
8
9
10
11
struct HOTPATCHEREDITOR_API FHotPatcherModDesc  
{
FString ModName;
bool bIsBuiltInMod = false;
float CurrentVersion = 0.f;
FString Description;
FString URL;
FString UpdateURL;
float MinHotPatcherVersion = 0.0f;
TArray<FHotPatcherActionDesc> ModActions;
};

It supports specifying the Mod name, whether it is a built-in Mod (core Mod included in HotPatcher), as well as the Mod version, description, URL, update link, and minimum supported HotPatcher version.

Finally, there’s FHotPatcherActionDesc, which describes the operational logic in the HotPatcher interface and includes Slate UI. Actions like ByPatch/ByRelease in the plugin are all part of HotPatcherAction.

Having actions in a mod will create an option in the list and include a dedicated interface, which can be customized with Slate controls.

Actions can be added as follows:

1
2
3
4
TmpModDesc.ModActions.Emplace(  
TEXT("Patcher"),MOD_NAME,TEXT("ByGameFeature"), TEXT("Create an Game Feature Package."),
CREATE_ACTION_WIDGET_LAMBDA(SGameFeaturePackageWidget,TEXT("ByGameFeature")),0
);

This completes the registration of a HotPatcher module, which can implement special functionalities within this independent plugin and be registered in the HotPatcher panel.

Moreover, opening the HotPatcher interface will show the installed mods:

Mods have the following classifications:

  1. Built-In, built-in modules in the plugin;
  2. Installed, those installed and developed by the HotPatcher author;
  3. ThirdParty, modules created by users themselves that are installed;
  4. Not-Installed, modules maintained by the HotPatcher developer but not installed locally;
  5. Unsupport, installed but with dependencies on a version of HotPatcher higher than that in the project, and they will not be registered in HotPatcher.

Built-in Modules

Currently, I have split multiple modules from the originally supported features of HotPatcher. The available modules are:

  1. HotPatcherCore, the built-in module of the plugin, containing the latest core functions with ByPatch and ByRelease actions.
  2. GameFeaturePacker, the module for packaging GameFeatures, which supports a minimum HotPatcher version of v80, with major updates focusing on the main UE5 line version.
  3. ShaderPatcherUE, to patch ShaderLibrary, see the article: UE Hot Update: Create Shader Patch

HotPatcherCore is included in the main repository, while the other modules are independent repositories.

When downloading, they can all be cloned together, and they are by default located in the Mods directory.

Install Modules

HotPatcherCore is included in the HotPatcher plugin, while the other modules are managed in the form of git submodules.

You can check the current available modules under hxhb/HotPatcher/Mods on Github.

Since the modules are managed as git submodules, both downloading and updating modules require the respective submodule commands.

For initial downloading of public modules, execute the following command in the root directory of the HotPatcher plugin:

1
git submodule update --init --recursive

For subsequent module updates:

1
2
3
git submodule foreach git fetch
# or
git submodule update --remote

I have an article explaining git commands, which also includes detailed descriptions of submodules, see: Quick Start Guide to Git#submodule

Note: Not all modules shown in the images above can be pulled, as some modules are currently not public, and there will be permission errors during pulling. However, this does not affect functionality.

Currently available modules can be found in the HotPatcher Star category: hxhb/list/HotPatcher.

Create New Modules

As mentioned earlier, I hope HotPatcher is an open resource management framework, allowing anyone to develop modules based on HotPatcher functionality according to their project’s needs.

To facilitate this, I provide a Mod Template plugin that can be modified based on this template: hxhb/HotPatcherModTemplate

It includes an Editor and Runtime Module, with the Module declaration and definition created according to the HotPatcherMod specifications, and only requires the corresponding registration information to be implemented in the GetModDesc interface.

Version Release

Due to the modularization, the release process for HotPatcher will change slightly.

  1. The version release of HotPatcher will only include the HotPatcherCore module.
  2. The updates for independent mods will be released separately.

There will be no impact on existing functionalities, as core functionalities like ByPatch and ByRelease are still integrated into the plugin itself.

Other modules will need to be updated manually, and attention should be paid to the HotPatcher version dependencies of the mods.

Future Plans

Currently, the functionalities supported by HotPatcher:

At present, HotPatcher has supported a large number of mod functionalities, and some new runtime optimization mechanisms are also being brewed and developed.

Most modules have not yet been opened to the public but may be released at an appropriate time and in an appropriate manner in the future. If your project hopes to use these modules and technologies, commercial collaboration for technical consultation is welcome.

The development plan for HotPatcherCore currently includes several important items, primarily targeting the UE5 engine:

  1. Support for World Partition
  2. Adaptation support for IoStore
  3. Optimization support for GameFeature
  4. Enhancing packaging efficiency
  5. Improving modular development capabilities to facilitate intervention at various stages of the packaging process

Currently, the development and updates of HotPatcher are maintained and supported by myself. I have limited personal energy and only spare time for open-source matters. Friends interested in joining the development of HotPatcher are welcome to contribute to the project.

Donations

For several years, HotPatcher has been freely available as a tool. The development and update process has consumed a significant amount of my energy and time.

Nevertheless, I still insist on providing this tool for free and continuously updating it simply because I love coding and hope to share my technology with more people, enhancing the technical sharing within the UE community. The value of interest cannot be measured in money.

In the future, the core functionality of HotPatcher will continue to be released as free tools and will be consistently updated.

If the HotPatcher project has helped you, and you hope it can do better in the future, you can scan the donation QR code below.

WeChat Pay Alipay

After you donate, you can click on the HotPatcher Donor Information Collection Form to submit your donation information.

If you have submitted your donation information after donating, I will periodically整理, displaying it on the project page to express my gratitude for your donations.

The article is finished. If you have any questions, please comment and communicate.

Scan the QR code on WeChat and follow me.

Title:HotPatcher Modular Transformation and Development Planning
Author:LIPENGZHA
Publish Date:2023/01/07 11:25
World Count:8.7k Words
Link:https://en.imzlp.com/posts/30178/
License: CC BY-NC-SA 4.0
Reprinting of the full article is prohibited.
Your donation will encourage me to keep creating!