Skip to content

Commit

Permalink
support package game feature/fix crypto issue,update to v70
Browse files Browse the repository at this point in the history
  • Loading branch information
hxhb committed Nov 19, 2021
1 parent ff94d34 commit 2ab59d8
Show file tree
Hide file tree
Showing 29 changed files with 1,355 additions and 230 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#pragma once


#include "ETargetPlatform.h"
#include "FlibPatchParserHelper.h"

#define PATCHER_CONFIG_PARAM_NAME TEXT("-config=")

namespace CommandletHelper
{
namespace NSPatch
{
void ReceiveMsg(const FString& InMsgType,const FString& InMsg)
{
UE_LOG(LogHotPatcherCommandlet,Display,TEXT("%s:%s"),*InMsgType,*InMsg);
}

void ReceiveShowMsg(const FString& InMsg)
{
UE_LOG(LogHotPatcherCommandlet,Display,TEXT("%s"),*InMsg);
}
}

TArray<FString> ParserPatchConfigByCommandline(const FString& Commandline,const FString& Token)
{
TArray<FString> result;
TMap<FString, FString> KeyValues = UFlibPatchParserHelper::GetCommandLineParamsMap(Commandline);
if(KeyValues.Find(Token))
{
FString AddPakListInfo = *KeyValues.Find(Token);
AddPakListInfo.ParseIntoArray(result,TEXT(","));
}
return result;
}


#define ADD_PATCH_PLATFORMS TEXT("AddPatchPlatforms")
TArray<ETargetPlatform> ParserPatchPlatforms(const FString& Commandline)
{
TArray<ETargetPlatform> result;
for(auto& PlatformName:ParserPatchConfigByCommandline(Commandline,ADD_PATCH_PLATFORMS))
{
ETargetPlatform Platform = ETargetPlatform::None;
UFlibPatchParserHelper::GetEnumValueByName(PlatformName,Platform);
if(Platform != ETargetPlatform::None)
{
result.AddUnique(Platform);
}
}
return result;
}

TArray<FDirectoryPath> ParserPatchFilters(const FString& Commandline,const FString& FilterName)
{
TArray<FDirectoryPath> Result;
for(auto& FilterPath:ParserPatchConfigByCommandline(Commandline,FString::Printf(TEXT("Add%s"),*FilterName)))
{
FDirectoryPath Path;
Path.Path = FilterPath;
Result.Add(Path);
}
return Result;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "HotPatcherCommandlet.h"
// #include "CreatePatch/FExportPatchSettingsEx.h"
#include "CreatePatch/PatcherProxy.h"
#include "CommandletHelper.hpp"

// engine header
#include "CoreMinimal.h"
Expand All @@ -10,62 +11,6 @@

DEFINE_LOG_CATEGORY(LogHotPatcherCommandlet);

#define PATCHER_CONFIG_PARAM_NAME TEXT("-config=")

namespace NSPatch
{
void ReceiveMsg(const FString& InMsgType,const FString& InMsg)
{
UE_LOG(LogHotPatcherCommandlet,Display,TEXT("%s:%s"),*InMsgType,*InMsg);
}

void ReceiveShowMsg(const FString& InMsg)
{
UE_LOG(LogHotPatcherCommandlet,Display,TEXT("%s"),*InMsg);
}
}

TArray<FString> ParserPatchConfigByCommandline(const FString& Commandline,const FString& Token)
{
TArray<FString> result;
TMap<FString, FString> KeyValues = UFlibPatchParserHelper::GetCommandLineParamsMap(Commandline);
if(KeyValues.Find(Token))
{
FString AddPakListInfo = *KeyValues.Find(Token);
AddPakListInfo.ParseIntoArray(result,TEXT(","));
}
return result;
}


#define ADD_PATCH_PLATFORMS TEXT("AddPatchPlatforms")
TArray<ETargetPlatform> ParserPatchPlatforms(const FString& Commandline)
{
TArray<ETargetPlatform> result;
for(auto& PlatformName:ParserPatchConfigByCommandline(Commandline,ADD_PATCH_PLATFORMS))
{
ETargetPlatform Platform = ETargetPlatform::None;
UFlibPatchParserHelper::GetEnumValueByName(PlatformName,Platform);
if(Platform != ETargetPlatform::None)
{
result.AddUnique(Platform);
}
}
return result;
}

TArray<FDirectoryPath> ParserPatchFilters(const FString& Commandline,const FString& FilterName)
{
TArray<FDirectoryPath> Result;
for(auto& FilterPath:ParserPatchConfigByCommandline(Commandline,FString::Printf(TEXT("Add%s"),*FilterName)))
{
FDirectoryPath Path;
Path.Path = FilterPath;
Result.Add(Path);
}
return Result;
}

int32 UHotPatcherCommandlet::Main(const FString& Params)
{
UE_LOG(LogHotPatcherCommandlet, Display, TEXT("UHotPatcherCommandlet::Main"));
Expand Down Expand Up @@ -100,7 +45,7 @@ int32 UHotPatcherCommandlet::Main(const FString& Params)

TMap<FString, FString> KeyValues = UFlibPatchParserHelper::GetCommandLineParamsMap(Params);
UFlibPatchParserHelper::ReplaceProperty(*ExportPatchSetting, KeyValues);
TArray<ETargetPlatform> AddPlatforms = ParserPatchPlatforms(Params);
TArray<ETargetPlatform> AddPlatforms = CommandletHelper::ParserPatchPlatforms(Params);

if(AddPlatforms.Num())
{
Expand All @@ -109,8 +54,8 @@ int32 UHotPatcherCommandlet::Main(const FString& Params)
ExportPatchSetting->PakTargetPlatforms.AddUnique(Platform);
}
}
ExportPatchSetting->AssetIncludeFilters.Append(ParserPatchFilters(Params,TEXT("AssetIncludeFilters")));
ExportPatchSetting->AssetIgnoreFilters.Append(ParserPatchFilters(Params,TEXT("AssetIgnoreFilters")));
ExportPatchSetting->AssetIncludeFilters.Append(CommandletHelper::ParserPatchFilters(Params,TEXT("AssetIncludeFilters")));
ExportPatchSetting->AssetIgnoreFilters.Append(CommandletHelper::ParserPatchFilters(Params,TEXT("AssetIgnoreFilters")));

FString FinalConfig;
UFlibPatchParserHelper::TSerializeStructAsJsonString(*ExportPatchSetting,FinalConfig);
Expand All @@ -120,8 +65,8 @@ int32 UHotPatcherCommandlet::Main(const FString& Params)
UPatcherProxy* PatcherProxy = NewObject<UPatcherProxy>();
PatcherProxy->AddToRoot();
PatcherProxy->SetProxySettings(ExportPatchSetting.Get());
PatcherProxy->OnPaking.AddStatic(&::NSPatch::ReceiveMsg);
PatcherProxy->OnShowMsg.AddStatic(&::NSPatch::ReceiveShowMsg);
PatcherProxy->OnPaking.AddStatic(&::CommandletHelper::NSPatch::ReceiveMsg);
PatcherProxy->OnShowMsg.AddStatic(&::CommandletHelper::NSPatch::ReceiveShowMsg);
bExportStatus = PatcherProxy->DoExport();

UE_LOG(LogHotPatcherCommandlet,Display,TEXT("Export Patch Misstion is %s!"),bExportStatus?TEXT("Successed"):TEXT("Failure"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "HotPluginCommandlet.h"
#include "ThreadUtils/FProcWorkerThread.hpp"
#include "GameFeature/FGameFeaturePackagerSettings.h"
#include "FlibPatchParserHelper.h"
#include "HotPatcherEditor.h"
#include "CommandletHelper.hpp"

// engine header
#include "CoreMinimal.h"
#include "GameFeature/GameFeatureProxy.h"
#include "Misc/FileHelper.h"
#include "Misc/CommandLine.h"
#include "Kismet/KismetSystemLibrary.h"
#include "Misc/Paths.h"

DEFINE_LOG_CATEGORY(LogHotPluginCommandlet);

TSharedPtr<FProcWorkerThread> PluginProc;

int32 UHotPluginCommandlet::Main(const FString& Params)
{
UE_LOG(LogHotPluginCommandlet, Display, TEXT("UHotPluginCommandlet::Main"));

FString config_path;
bool bStatus = FParse::Value(*Params, *FString(PATCHER_CONFIG_PARAM_NAME).ToLower(), config_path);
if (!bStatus)
{
UE_LOG(LogHotPluginCommandlet, Error, TEXT("not -config=xxxx.json params."));
return -1;
}

if (!FPaths::FileExists(config_path))
{
UE_LOG(LogHotPluginCommandlet, Error, TEXT("cofnig file %s not exists."), *config_path);
return -1;
}

FString JsonContent;
bool bExportStatus = false;
if (FFileHelper::LoadFileToString(JsonContent, *config_path))
{

if(IsRunningCommandlet())
{
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
AssetRegistryModule.Get().SearchAllAssets(true);
}

TSharedPtr<FGameFeaturePackagerSettings> PluginPackagerSetting = MakeShareable(new FGameFeaturePackagerSettings);
UFlibPatchParserHelper::TDeserializeJsonStringAsStruct(JsonContent,*PluginPackagerSetting);

TMap<FString, FString> KeyValues = UFlibPatchParserHelper::GetCommandLineParamsMap(Params);
UFlibPatchParserHelper::ReplaceProperty(*PluginPackagerSetting, KeyValues);
TArray<ETargetPlatform> AddPlatforms = CommandletHelper::ParserPatchPlatforms(Params);

FString FinalConfig;
UFlibPatchParserHelper::TSerializeStructAsJsonString(*PluginPackagerSetting,FinalConfig);
UE_LOG(LogHotPluginCommandlet, Display, TEXT("%s"), *FinalConfig);


UGameFeatureProxy* GameFeatureProxy = NewObject<UGameFeatureProxy>();
GameFeatureProxy->AddToRoot();
GameFeatureProxy->SetProxySettings(PluginPackagerSetting.Get());
GameFeatureProxy->OnPaking.AddStatic(&::CommandletHelper::NSPatch::ReceiveMsg);
GameFeatureProxy->OnShowMsg.AddStatic(&::CommandletHelper::NSPatch::ReceiveShowMsg);
bExportStatus = GameFeatureProxy->DoExport();

UE_LOG(LogHotPluginCommandlet,Display,TEXT("Generate Game Feature Misstion is %s!"),bExportStatus?TEXT("Successed"):TEXT("Failure"));
}

if(FParse::Param(FCommandLine::Get(), TEXT("wait")))
{
system("pause");
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "Commandlets/Commandlet.h"
#include "HotPluginCommandlet.generated.h"

DECLARE_LOG_CATEGORY_EXTERN(LogHotPluginCommandlet, Log, All);

UCLASS()
class UHotPluginCommandlet :public UCommandlet
{
GENERATED_BODY()

public:

virtual int32 Main(const FString& Params)override;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "HotReleaseCommandlet.h"
#include "CreatePatch/FExportReleaseSettings.h"
#include "CreatePatch/ReleaseProxy.h"
#include "CommandletHelper.hpp"

// engine header
#include "CoreMinimal.h"
Expand All @@ -10,20 +11,6 @@

DEFINE_LOG_CATEGORY(LogHotReleaseCommandlet);

#define PATCHER_CONFIG_PARAM_NAME TEXT("-config=")

namespace NSRelease
{
void ReceiveMsg(const FString& InMsgType,const FString& InMsg)
{
UE_LOG(LogHotReleaseCommandlet,Log,TEXT("%s:%s"),*InMsgType,*InMsg);
}

void ReceiveShowMsg(const FString& InMsg)
{
UE_LOG(LogHotReleaseCommandlet,Log,TEXT("%s"),*InMsg);
}
}

#define ADD_PLATFORM_PAK_LIST TEXT("AddPlatformPakList")
TArray<FPlatformPakListFiles> ParserPlatformPakList(const FString& Commandline)
Expand Down Expand Up @@ -119,8 +106,8 @@ int32 UHotReleaseCommandlet::Main(const FString& Params)
UReleaseProxy* ReleaseProxy = NewObject<UReleaseProxy>();
ReleaseProxy->AddToRoot();
ReleaseProxy->SetProxySettings(ExportReleaseSetting.Get());
ReleaseProxy->OnPaking.AddStatic(&::NSRelease::ReceiveMsg);
ReleaseProxy->OnShowMsg.AddStatic(&::NSRelease::ReceiveShowMsg);
ReleaseProxy->OnPaking.AddStatic(&::CommandletHelper::NSPatch::ReceiveMsg);
ReleaseProxy->OnShowMsg.AddStatic(&::CommandletHelper::NSPatch::ReceiveShowMsg);
bool bExportStatus = ReleaseProxy->DoExport();

UE_LOG(LogHotReleaseCommandlet,Display,TEXT("Export Release Misstion is %s!"),bExportStatus?TEXT("Successed"):TEXT("Failure"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "HotShaderPatchCommandlet.h"
#include "ShaderPatch/FExportShaderPatchSettings.h"

#include "CommandletHelper.hpp"
// engine header
#include "CoreMinimal.h"
#include "Misc/FileHelper.h"
Expand All @@ -11,8 +11,6 @@

DEFINE_LOG_CATEGORY(LogHotShaderPatchCommandlet);

#define PATCHER_CONFIG_PARAM_NAME TEXT("-config=")

int32 UHotShaderPatchCommandlet::Main(const FString& Params)
{
UE_LOG(LogHotShaderPatchCommandlet, Display, TEXT("UHotShaderPatchCommandlet::Main"));
Expand Down
16 changes: 14 additions & 2 deletions HotPatcher/Source/HotPatcherEditor/HotPatcherEditor.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public HotPatcherEditor(ReadOnlyTargetRules Target) : base(Target)
"PakFileUtilities",
"HotPatcherRuntime",
"BinariesPatchFeature"
// ... add other public dependencies that you statically link with here ...
// ... add other public dependencies that you statically link with here ...
}
);

Expand Down Expand Up @@ -143,11 +143,23 @@ public HotPatcherEditor(ReadOnlyTargetRules Target) : base(Target)
System.Console.WriteLine("MajorVersion {0} MinorVersion: {1} PatchVersion {2}",Target.Version.MajorVersion,Target.Version.MinorVersion,Target.Version.PatchVersion);
bLegacyPublicIncludePaths = false;
OptimizeCode = CodeOptimization.InShippingBuildsOnly;

// Game feature
bool bEnableGameFeature = false;
if (bEnableGameFeature || (Target.Version.MajorVersion > 4 || Target.Version.MinorVersion > 26))
{
PublicDefinitions.Add("ENGINE_GAME_FEATURE");
PublicDependencyModuleNames.AddRange(new string[]
{
// "GameFeatures",
// "ModularGameplay",
});
}

PublicDefinitions.AddRange(new string[]
{
"TOOL_NAME=\"HotPatcher\"",
"CURRENT_VERSION_ID=69",
"CURRENT_VERSION_ID=70",
"REMOTE_VERSION_FILE=\"https://imzlp.com/opensource/version.json\""
});
}
Expand Down
Loading

0 comments on commit 2ab59d8

Please sign in to comment.