diff --git a/Content/EditorUtilityWidgets/ChannelDataSchemaEditor.uasset b/Content/EditorUtilityWidgets/ChannelDataSchemaEditor.uasset index dee4a487..04e5901c 100644 Binary files a/Content/EditorUtilityWidgets/ChannelDataSchemaEditor.uasset and b/Content/EditorUtilityWidgets/ChannelDataSchemaEditor.uasset differ diff --git a/Content/EditorUtilityWidgets/CloudDeployment.uasset b/Content/EditorUtilityWidgets/CloudDeployment.uasset index a94994c7..f5dcc252 100644 Binary files a/Content/EditorUtilityWidgets/CloudDeployment.uasset and b/Content/EditorUtilityWidgets/CloudDeployment.uasset differ diff --git a/Content/EditorUtilityWidgets/EUW_ChannelDataSchemaItem.uasset b/Content/EditorUtilityWidgets/EUW_ChannelDataSchemaItem.uasset index f5de6327..62aaefb4 100644 Binary files a/Content/EditorUtilityWidgets/EUW_ChannelDataSchemaItem.uasset and b/Content/EditorUtilityWidgets/EUW_ChannelDataSchemaItem.uasset differ diff --git a/Content/EditorUtilityWidgets/EUW_EditableTextListItem.uasset b/Content/EditorUtilityWidgets/EUW_EditableTextListItem.uasset index 9e66582f..98161812 100644 Binary files a/Content/EditorUtilityWidgets/EUW_EditableTextListItem.uasset and b/Content/EditorUtilityWidgets/EUW_EditableTextListItem.uasset differ diff --git a/Content/EditorUtilityWidgets/EUW_FilePicker.uasset b/Content/EditorUtilityWidgets/EUW_FilePicker.uasset index 91e9a8f7..cdf18423 100644 Binary files a/Content/EditorUtilityWidgets/EUW_FilePicker.uasset and b/Content/EditorUtilityWidgets/EUW_FilePicker.uasset differ diff --git a/Content/EditorUtilityWidgets/EUW_ServerGroup.uasset b/Content/EditorUtilityWidgets/EUW_ServerGroup.uasset index b9336f86..7cf34362 100644 Binary files a/Content/EditorUtilityWidgets/EUW_ServerGroup.uasset and b/Content/EditorUtilityWidgets/EUW_ServerGroup.uasset differ diff --git a/Content/EditorUtilityWidgets/WBP_ChannelDataStateSchemaItem.uasset b/Content/EditorUtilityWidgets/WBP_ChannelDataStateSchemaItem.uasset index eecf2aaa..dd4fe9da 100644 Binary files a/Content/EditorUtilityWidgets/WBP_ChannelDataStateSchemaItem.uasset and b/Content/EditorUtilityWidgets/WBP_ChannelDataStateSchemaItem.uasset differ diff --git a/Content/EditorUtilityWidgets/WBP_Selector_ChanneldUE.uasset b/Content/EditorUtilityWidgets/WBP_Selector_ChanneldUE.uasset index 09572804..4481de50 100644 Binary files a/Content/EditorUtilityWidgets/WBP_Selector_ChanneldUE.uasset and b/Content/EditorUtilityWidgets/WBP_Selector_ChanneldUE.uasset differ diff --git a/Docs/zh/add-replication.md b/Docs/zh/add-replication.md index 51a69dd6..6f3aad48 100644 --- a/Docs/zh/add-replication.md +++ b/Docs/zh/add-replication.md @@ -62,7 +62,10 @@ 最后,代码生成后,会自动编译。编译成功,则整个生成步骤完毕。下面可以进入游戏看看效果了。 ``` -注意:每次进行同步相关的修改后(包括:增删改名同步类,同步变量,或RPC)都需要重新生成同步代码。每次新增同步Actor后都需要将其状态添加至对应的频道数据模型中。 +注意: +1. 请保证UE编辑器偏好中的Live Coding功能在关闭的情况下,进行代码生成,否则重新启动游戏服务器时会报错; +2. 每次进行同步相关的修改后(包括:增删改名同步类,同步变量,或RPC)都需要重新生成同步代码; +3. 每次新增同步Actor后都需要将其状态添加至对应的频道数据模型中,才能使其正常同步。 ``` ## 6.5.启动服务器并测试 diff --git a/Docs/zh/troubleshooting.md b/Docs/zh/troubleshooting.md index 5382ef89..9d0d15ea 100644 --- a/Docs/zh/troubleshooting.md +++ b/Docs/zh/troubleshooting.md @@ -9,8 +9,9 @@ - 如果输出日志中出现`failed to listen`的错误,说明端口被占用。请检查默认的端口12108和11288是否被其它程序占用,或者在channeld配置文件中修改端口号 ## 游戏服务器启动后自动退出 -- 检查channeld服务是否正常运行。在开启了channeld网络(`Enable Channeld Networking`)时,游戏服务器会尝试连接channeld服务。如果连接失败,游戏服务器会自动退出 -- 检查游戏服务器的日志。日志文件通常位于项目目录下的`Saved/Logs`目录中,以项目名_{数字}命名。在单服模式下,数字为2是游戏服务器日志;在多服模式下,数字为2是主服务器日志,数字从3开始是空间服务器日志 +- 检查channeld服务是否正常运行。在开启了channeld网络(`Enable Channeld Networking`)时,游戏服务器会尝试连接channeld服务。如果连接失败,游戏服务器会自动退出; +- 确认[Live Coding](https://docs.unrealengine.com/5.0/en-US/using-live-coding-to-recompile-unreal-engine-applications-at-runtime/)的设置是关闭的,否则会日志中会出现`Error: Failed to register channel data type by name`; +- 如果上述方法仍无法解决,请检查游戏服务器的日志。日志文件通常位于项目目录下的`Saved/Logs`目录中,以项目名_{数字}命名。在单服模式下,数字为2是游戏服务器日志;在多服模式下,数字为2是主服务器日志,数字从3开始是空间服务器日志。 ## 无法保存蓝图 如果出现“无法保存资产”的错误提示,通常是由于游戏服务器仍在运行,导致蓝图文件被占用。请先关闭游戏服务器,再保存蓝图。 diff --git a/Source/ChanneldEditor/ChanneldEditor.Build.cs b/Source/ChanneldEditor/ChanneldEditor.Build.cs index d9c30b7d..c396ef37 100644 --- a/Source/ChanneldEditor/ChanneldEditor.Build.cs +++ b/Source/ChanneldEditor/ChanneldEditor.Build.cs @@ -62,7 +62,7 @@ public ChanneldEditor(ReadOnlyTargetRules Target) : base(Target) "EngineSettings", "Json", "JsonUtilities", - #if UE_5_0_OR_LATER +#if UE_5_0_OR_LATER "DeveloperToolSettings", "ToolMenus", #endif @@ -70,7 +70,6 @@ public ChanneldEditor(ReadOnlyTargetRules Target) : base(Target) } ); - DynamicallyLoadedModuleNames.AddRange( new string[] { diff --git a/Source/ChanneldEditor/ChanneldEditor.cpp b/Source/ChanneldEditor/ChanneldEditor.cpp index ce98f4b8..c669dabb 100644 --- a/Source/ChanneldEditor/ChanneldEditor.cpp +++ b/Source/ChanneldEditor/ChanneldEditor.cpp @@ -94,7 +94,7 @@ void FChanneldEditorModule::StartupModule() TSharedPtr ToolbarExtender = MakeShareable(new FExtender()); ToolbarExtender->AddToolBarExtension("Compile", EExtensionHook::After, PluginCommands, - FToolBarExtensionDelegate::CreateRaw(this, &FChanneldEditorModule::AddToolbarButton)); + FToolBarExtensionDelegate::CreateRaw(this, &FChanneldEditorModule::AddToolbarButton)); LevelEditorModule.GetToolBarExtensibilityManager()->AddExtender(ToolbarExtender); #endif diff --git a/Source/ChanneldEditor/ChanneldEditorSubsystem.cpp b/Source/ChanneldEditor/ChanneldEditorSubsystem.cpp index a0c55fcb..c0a14bec 100644 --- a/Source/ChanneldEditor/ChanneldEditorSubsystem.cpp +++ b/Source/ChanneldEditor/ChanneldEditorSubsystem.cpp @@ -34,7 +34,7 @@ #include "Misc/Base64.h" #include "Settings/EditorExperimentalSettings.h" #include "Settings/ProjectPackagingSettings.h" -#if ENGINE_MAJOR_VERSION >= 5 +#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 #include "Settings/PlatformsMenuSettings.h" #endif #include "Windows/MinWindows.h" @@ -609,7 +609,7 @@ void UChanneldEditorSubsystem::BuildServerDockerImage(const FString& Tag, return; } -#if ENGINE_MAJOR_VERSION >= 5 +#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 const UPlatformsMenuSettings* PlatformsSettings = GetDefault(); FDirectoryPath StagingDirectory = PlatformsSettings->StagingDirectory; #else @@ -888,15 +888,19 @@ void UChanneldEditorSubsystem::PackageProject(const FName InPlatformInfoName, bool bProjectHasCode = GameProjectModule.Get().ProjectHasCodeFiles(); #if ENGINE_MAJOR_VERSION >= 5 - const PlatformInfo::FTargetPlatformInfo* PlatformInfo = nullptr; - if (FApp::IsInstalled()) - { - PlatformInfo = PlatformInfo::FindPlatformInfo(InPlatformInfoName); -} - else - { - PlatformInfo = PlatformInfo::FindPlatformInfo(GetMutableDefault()->GetTargetFlavorForPlatform(InPlatformInfoName)); - } + #if ENGINE_MINOR_VERSION >= 2 + const PlatformInfo::FTargetPlatformInfo* PlatformInfo = nullptr; + if (FApp::IsInstalled()) + { + PlatformInfo = PlatformInfo::FindPlatformInfo(InPlatformInfoName); + } + else + { + PlatformInfo = PlatformInfo::FindPlatformInfo(GetMutableDefault()->GetTargetFlavorForPlatform(InPlatformInfoName)); + } + #else + const PlatformInfo::FTargetPlatformInfo* PlatformInfo = PlatformInfo::FindPlatformInfo(InPlatformInfoName); + #endif #else const PlatformInfo::FPlatformInfo* const PlatformInfo = PlatformInfo::FindPlatformInfo(InPlatformInfoName); #endif @@ -929,8 +933,7 @@ void UChanneldEditorSubsystem::PackageProject(const FName InPlatformInfoName, // NOTE: Cannot find SDKStatus in UE5 #if ENGINE_MAJOR_VERSION < 5 if (PlatformInfo->SDKStatus == PlatformInfo::EPlatformSDKStatus::NotInstalled || (bProjectHasCode && - PlatformInfo-> - bUsesHostCompiler && !FSourceCodeNavigation::IsCompilerAvailable())) + PlatformInfo->bUsesHostCompiler && !FSourceCodeNavigation::IsCompilerAvailable())) { IMainFrameModule& MainFrameModule = FModuleManager::GetModuleChecked(TEXT("MainFrame")); MainFrameModule.BroadcastMainFrameSDKNotInstalled(PlatformInfo->TargetPlatformName.ToString(), @@ -1116,7 +1119,7 @@ void UChanneldEditorSubsystem::PackageProject(const FName InPlatformInfoName, return; } -#if ENGINE_MAJOR_VERSION >= 5 +#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 UPlatformsMenuSettings* PlatformsSettings = GetMutableDefault(); FDirectoryPath& StagingDirectory = PlatformsSettings->StagingDirectory; #else @@ -1148,7 +1151,7 @@ void UChanneldEditorSubsystem::PackageProject(const FName InPlatformInfoName, } StagingDirectory.Path = OutFolderName; -#if ENGINE_MAJOR_VERSION >= 5 +#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 PlatformsSettings->SaveConfig(); #else PackagingSettings->SaveConfig(); diff --git a/Source/ChanneldEditor/ClientInterestSettingsCustomization.cpp b/Source/ChanneldEditor/ClientInterestSettingsCustomization.cpp index 04fb4139..b85cfbc5 100644 --- a/Source/ChanneldEditor/ClientInterestSettingsCustomization.cpp +++ b/Source/ChanneldEditor/ClientInterestSettingsCustomization.cpp @@ -4,6 +4,9 @@ #include "SlateBasics.h" #include "DetailWidgetRow.h" #include "DetailLayoutBuilder.h" +#if ENGINE_MAJOR_VERSION >= 5 +#include "EditorStyleSet.h" +#endif #include "IDetailChildrenBuilder.h" @@ -39,8 +42,13 @@ void FClientInterestSettingsCustomization::CustomizeHeader(TSharedRef= 5 + .Font(FAppStyle::GetFontStyle("PropertyWindow.NormalFont")) +#else + .Font(FEditorStyle::GetFontStyle("PropertyWindow.NormalFont")) +#endif + + .Text(FText::Format(LOCTEXT("ClientInterestSettingsAreaTypeString", "The area type is \"{0}\""), AreaTypeText)) ] ]; } @@ -57,7 +65,8 @@ void FClientInterestSettingsCustomization::OnTypeChanged(TSharedPtr StructPropertyHandle, - IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils) + IDetailChildrenBuilder& StructBuilder, + IPropertyTypeCustomizationUtils& StructCustomizationUtils) { auto TypePropertyHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FClientInterestSettingsPreset, AreaType)); auto SpotsPropertyHandle = StructPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FClientInterestSettingsPreset, SpotsAndDists)); @@ -84,7 +93,7 @@ void FClientInterestSettingsCustomization::CustomizeChildren(TSharedRefCreatePropertyNameWidget() ] - +SVerticalBox::Slot() + + SVerticalBox::Slot() .AutoHeight() [ TypePropertyHandle->CreatePropertyValueWidget() @@ -94,7 +103,7 @@ void FClientInterestSettingsCustomization::CustomizeChildren(TSharedRefCreatePropertyNameWidget() ] - +SVerticalBox::Slot() + + SVerticalBox::Slot() .AutoHeight() [ SpotsPropertyHandle->CreateDefaultPropertyButtonWidgets() @@ -114,7 +123,7 @@ void FClientInterestSettingsCustomization::CustomizeChildren(TSharedRefCreatePropertyNameWidget() ] - +SVerticalBox::Slot() + + SVerticalBox::Slot() .AutoHeight() [ StructBuilder.GenerateStructValueWidget(ExtentPropertyHandle.ToSharedRef()) @@ -135,7 +144,7 @@ void FClientInterestSettingsCustomization::CustomizeChildren(TSharedRefCreatePropertyNameWidget() ] - +SVerticalBox::Slot() + + SVerticalBox::Slot() .AutoHeight() [ RadiusPropertyHandle->CreatePropertyValueWidget() @@ -155,7 +164,7 @@ void FClientInterestSettingsCustomization::CustomizeChildren(TSharedRefCreatePropertyNameWidget() ] - +SVerticalBox::Slot() + + SVerticalBox::Slot() .AutoHeight() [ AnglePropertyHandle->CreatePropertyValueWidget() diff --git a/Source/ChanneldEditor/Widget/ChanneldIntegerSpinBox.cpp b/Source/ChanneldEditor/Widget/ChanneldIntegerSpinBox.cpp index ebc6dfaf..8c28b727 100644 --- a/Source/ChanneldEditor/Widget/ChanneldIntegerSpinBox.cpp +++ b/Source/ChanneldEditor/Widget/ChanneldIntegerSpinBox.cpp @@ -33,7 +33,11 @@ UChanneldIntegerSpinBox::UChanneldIntegerSpinBox(const FObjectInitializer& Objec MinDesiredWidth = 0; ClearKeyboardFocusOnCommit = false; SelectAllTextOnCommit = true; +#if ENGINE_MAJOR_VERSION < 5 ForegroundColor = FSlateColor(FLinearColor::Black); +#else + ForegroundColor = FSlateColor(FLinearColor::White); +#endif if (DefaultSpinBoxStyle == nullptr) { diff --git a/Source/ChanneldUE/ChanneldNetConnection.cpp b/Source/ChanneldUE/ChanneldNetConnection.cpp index 2442eae1..cff23bd5 100644 --- a/Source/ChanneldUE/ChanneldNetConnection.cpp +++ b/Source/ChanneldUE/ChanneldNetConnection.cpp @@ -9,6 +9,7 @@ #include "unreal_common.pb.h" #include "ChanneldUtils.h" #include "ChanneldSettings.h" +#include #include "Interest/ClientInterestManager.h" UChanneldNetConnection::UChanneldNetConnection(const FObjectInitializer& ObjectInitializer) @@ -341,12 +342,16 @@ FString UChanneldNetConnection::LowLevelGetRemoteAddress(bool bAppendPort /*= fa if (RemoteAddr) { if (bAppendPort) - RemoteAddr->SetPort(GetSendToChannelId()); + { + // Use the native UNetConnection::ConnectionId as the port (which is limited to 1024 by default). + // If we use the GetConnId(), FInternetAddrBSD::SetPort() will throw check error when ConnId > 65535. + RemoteAddr->SetPort(GetConnectionId()); + } return RemoteAddr->ToString(bAppendPort); } else { - return bAppendPort ? FString::Printf(TEXT("0.0.0.0:%d"), GetSendToChannelId()) : TEXT("0.0.0.0"); + return bAppendPort ? FString::Printf(TEXT("0.0.0.0:%d"), GetConnectionId()) : TEXT("0.0.0.0"); } } diff --git a/Source/ChanneldUE/ChanneldNetConnection.h b/Source/ChanneldUE/ChanneldNetConnection.h index ed3480fd..29185cbb 100644 --- a/Source/ChanneldUE/ChanneldNetConnection.h +++ b/Source/ChanneldUE/ChanneldNetConnection.h @@ -28,6 +28,7 @@ class CHANNELDUE_API UChanneldNetConnection : public UNetConnection virtual void Tick(float DeltaSeconds) override; virtual void ReceivedRawPacket(void* Data, int32 Count) override; + // Get the ConnectionID associated with channeld, which is different from the native UNetConnection::GetConnectionId(). FORCEINLINE Channeld::ConnectionId GetConnId() const { if (RemoteAddr.IsValid()) @@ -39,6 +40,7 @@ class CHANNELDUE_API UChanneldNetConnection : public UNetConnection return 0; } + // Get the ChannelID used for SendData() when `ChId` is not specified. Channeld::ChannelId GetSendToChannelId(); // Send data between UE client and sever via channeld. MsgType should be in user space (>= 100). diff --git a/Source/ChanneldUE/ChanneldNetDriver.cpp b/Source/ChanneldUE/ChanneldNetDriver.cpp index c8246594..ad6b90d9 100644 --- a/Source/ChanneldUE/ChanneldNetDriver.cpp +++ b/Source/ChanneldUE/ChanneldNetDriver.cpp @@ -303,6 +303,7 @@ TSharedRef UChanneldNetDriver::ConnIdToAddr(Channeld::ConnectionI { auto Addr = GetSocketSubsystem()->CreateInternetAddr(); Addr->SetIp(ConnId); + // Won't set the port until UChanneldNetConnection::LowLevelGetRemoteAddress(true) is called. CachedAddr.Add(ConnId, Addr); AddrPtr = &Addr; } diff --git a/Source/ChanneldUE/ChanneldSettings.cpp b/Source/ChanneldUE/ChanneldSettings.cpp index 8e540b6a..5c7616df 100644 --- a/Source/ChanneldUE/ChanneldSettings.cpp +++ b/Source/ChanneldUE/ChanneldSettings.cpp @@ -20,10 +20,18 @@ UChanneldSettings::UChanneldSettings(const FObjectInitializer& ObjectInitializer SpatialOutlinerClass(LoadClass(NULL, TEXT("BlueprintGeneratedClass'/ChanneldUE/Blueprints/BP_SpatialOutliner.BP_SpatialOutliner_C'"))) { FClientInterestSettingsPreset DefaultInterestPreset; + DefaultInterestPreset.bActivateByDefault = true; DefaultInterestPreset.AreaType = EClientInterestAreaType::Sphere; DefaultInterestPreset.PresetName = "ThirdPerson"; DefaultInterestPreset.Radius = 1000; ClientInterestPresets.Add(DefaultInterestPreset); + + FClientInterestSettingsPreset InspectorInterestPreset; + InspectorInterestPreset.bActivateByDefault = false; + InspectorInterestPreset.AreaType = EClientInterestAreaType::Box; + InspectorInterestPreset.PresetName = "Inspector"; + InspectorInterestPreset.Extent = FVector(100000, 100000, 100000); + ClientInterestPresets.Add(InspectorInterestPreset); } void UChanneldSettings::PostInitProperties() diff --git a/Source/ChanneldUE/ChanneldUE.cpp b/Source/ChanneldUE/ChanneldUE.cpp index 9ba64c66..3df94804 100644 --- a/Source/ChanneldUE/ChanneldUE.cpp +++ b/Source/ChanneldUE/ChanneldUE.cpp @@ -28,7 +28,7 @@ void FChanneldUEModule::StartupModule() if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr("Settings")) { SettingsModule->RegisterSettings("Project", "Plugins", "ChanneldSettings", - LOCTEXT("RuntimeSettingsName", "Channeld"), + LOCTEXT("RuntimeSettingsName", "Channeld"), LOCTEXT("RuntimeSettingsDesc", ""), GetMutableDefault()); } @@ -60,5 +60,5 @@ void FChanneldUEModule::ShutdownModule() } #undef LOCTEXT_NAMESPACE - -IMPLEMENT_MODULE(FChanneldUEModule, ChanneldUE) \ No newline at end of file + +IMPLEMENT_MODULE(FChanneldUEModule, ChanneldUE) diff --git a/Source/ChanneldUE/ChanneldUtils.cpp b/Source/ChanneldUE/ChanneldUtils.cpp index 95342b16..253d4f96 100644 --- a/Source/ChanneldUE/ChanneldUtils.cpp +++ b/Source/ChanneldUE/ChanneldUtils.cpp @@ -250,7 +250,7 @@ TSharedRef ChanneldUtils::GetRefOfObject(UObject* Obj ObjRef->set_owningconnid(CastChecked(Connection)->GetConnId()); auto PackageMap = Cast(Connection->PackageMap); - + if (IsValid(PackageMap)) { // If the NetGUID is not created yet, assign an new one and send the new NetGUID CachedObjects to the client. diff --git a/Source/ChanneldUE/ChanneldUtils.h b/Source/ChanneldUE/ChanneldUtils.h index 0e6a23b1..a5e9b7ed 100644 --- a/Source/ChanneldUE/ChanneldUtils.h +++ b/Source/ChanneldUE/ChanneldUtils.h @@ -8,6 +8,8 @@ #include "ChanneldNetConnection.h" #include "AssetRegistry/AssetRegistryModule.h" #include "Engine/DemoNetDriver.h" +//#define CHANNELD_TOLERANCE (1.e-8f) +#define CHANNELD_TOLERANCE (0.001f) class CHANNELDUE_API ChanneldUtils { @@ -70,7 +72,9 @@ class CHANNELDUE_API ChanneldUtils return Vec; } - [[deprecated("Use SetRotatorFromPB instead. Use GetRotator can cause the value of pitch/yaw/roll to be 0 if the it is not set.")]] + [[deprecated( + "Use SetRotatorFromPB instead. Use GetRotator can cause the value of pitch/yaw/roll to be 0 if the it is not set." + )]] static FRotator GetRotator(const unrealpb::FVector& InVec) { return FRotator(InVec.x(), InVec.y(), InVec.z()); @@ -78,35 +82,37 @@ class CHANNELDUE_API ChanneldUtils static bool CheckDifference(const FVector& VectorToCheck, const unrealpb::FVector* VectorPBToCheck) { - if (!FMath::IsNearlyEqual(VectorPBToCheck->x(), VectorToCheck.X)) + if (!FMath::IsNearlyEqual(VectorPBToCheck->x(), VectorToCheck.X, CHANNELD_TOLERANCE)) { return true; } - if (!FMath::IsNearlyEqual(VectorPBToCheck->y(), VectorToCheck.Y)) + if (!FMath::IsNearlyEqual(VectorPBToCheck->y(), VectorToCheck.Y, CHANNELD_TOLERANCE)) { return true; } - if (!FMath::IsNearlyEqual(VectorPBToCheck->z(), VectorToCheck.Z)) + if (!FMath::IsNearlyEqual(VectorPBToCheck->z(), VectorToCheck.Z, CHANNELD_TOLERANCE)) { return true; } + return false; } static bool CheckDifference(const FRotator& RotatorToCheck, const unrealpb::FVector* RotatorPBToCheck) { - if (!FMath::IsNearlyEqual(RotatorPBToCheck->x(), RotatorToCheck.Pitch)) + if (!FMath::IsNearlyEqual(RotatorPBToCheck->x(), RotatorToCheck.Pitch, CHANNELD_TOLERANCE)) { return true; } - if (!FMath::IsNearlyEqual(RotatorPBToCheck->y(), RotatorToCheck.Yaw)) + if (!FMath::IsNearlyEqual(RotatorPBToCheck->y(), RotatorToCheck.Yaw, CHANNELD_TOLERANCE)) { return true; } - if (!FMath::IsNearlyEqual(RotatorPBToCheck->z(), RotatorToCheck.Roll)) + if (!FMath::IsNearlyEqual(RotatorPBToCheck->z(), RotatorToCheck.Roll, CHANNELD_TOLERANCE)) { return true; } + return false; } @@ -123,17 +129,17 @@ class CHANNELDUE_API ChanneldUtils VectorPBToCheck = VectorToSet; bool bNotSame = false; - if (!FMath::IsNearlyEqual(VectorPBToCheck->x(), VectorToCheck.X)) + if (!FMath::IsNearlyEqual(VectorPBToCheck->x(), VectorToCheck.X, CHANNELD_TOLERANCE)) { VectorToSet->set_x(VectorToCheck.X); bNotSame = true; } - if (!FMath::IsNearlyEqual(VectorPBToCheck->y(), VectorToCheck.Y)) + if (!FMath::IsNearlyEqual(VectorPBToCheck->y(), VectorToCheck.Y, CHANNELD_TOLERANCE)) { VectorToSet->set_y(VectorToCheck.Y); bNotSame = true; } - if (!FMath::IsNearlyEqual(VectorPBToCheck->z(), VectorToCheck.Z)) + if (!FMath::IsNearlyEqual(VectorPBToCheck->z(), VectorToCheck.Z, CHANNELD_TOLERANCE)) { VectorToSet->set_z(VectorToCheck.Z); bNotSame = true; @@ -148,17 +154,17 @@ class CHANNELDUE_API ChanneldUtils RotatorPBToCheck = RotatorToSet; bool bNotSame = false; - if (!FMath::IsNearlyEqual(RotatorPBToCheck->x(), RotatorToCheck.Pitch)) + if (!FMath::IsNearlyEqual(RotatorPBToCheck->x(), RotatorToCheck.Pitch, CHANNELD_TOLERANCE)) { RotatorToSet->set_x(RotatorToCheck.Pitch); bNotSame = true; } - if (!FMath::IsNearlyEqual(RotatorPBToCheck->y(), RotatorToCheck.Yaw)) + if (!FMath::IsNearlyEqual(RotatorPBToCheck->y(), RotatorToCheck.Yaw, CHANNELD_TOLERANCE)) { RotatorToSet->set_y(RotatorToCheck.Yaw); bNotSame = true; } - if (!FMath::IsNearlyEqual(RotatorPBToCheck->z(), RotatorToCheck.Roll)) + if (!FMath::IsNearlyEqual(RotatorPBToCheck->z(), RotatorToCheck.Roll, CHANNELD_TOLERANCE)) { RotatorToSet->set_z(RotatorToCheck.Roll); bNotSame = true; diff --git a/Source/ChanneldUE/Interest/ClientInterestManager.cpp b/Source/ChanneldUE/Interest/ClientInterestManager.cpp index daac30bb..9d1b701c 100644 --- a/Source/ChanneldUE/Interest/ClientInterestManager.cpp +++ b/Source/ChanneldUE/Interest/ClientInterestManager.cpp @@ -218,11 +218,12 @@ void UClientInterestManager::OnPlayerEnterSpatialChannel(UChanneldNetConnection* PawnLocation = NetConn->PlayerController->GetSpawnLocation(); PawnRotation = FRotator::ZeroRotator; } - + + auto Query = InterestMsg.mutable_query(); for (auto& AOI : ActiveAOIs) { // AOI->OnPlayerEnterSpatialChannel(NetConn, SpatialChId); - AOI->SetSpatialQuery(InterestMsg.mutable_query(), PawnLocation, PawnRotation); + AOI->SetSpatialQuery(Query, PawnLocation, PawnRotation); } GEngine->GetEngineSubsystem()->Send(SpatialChId, channeldpb::UPDATE_SPATIAL_INTEREST, InterestMsg); diff --git a/Source/ChanneldUE/Replication/ChanneldPlayerStateReplicator.cpp b/Source/ChanneldUE/Replication/ChanneldPlayerStateReplicator.cpp index 67650249..6c508c5f 100644 --- a/Source/ChanneldUE/Replication/ChanneldPlayerStateReplicator.cpp +++ b/Source/ChanneldUE/Replication/ChanneldPlayerStateReplicator.cpp @@ -118,7 +118,11 @@ void FChanneldPlayerStateReplicator::OnStateChanged(const google::protobuf::Mess } if (NewState->has_ping()) { +#if ENGINE_MAJOR_VERSION == 5 + //TODO::fix this later +#else *PingPtr = NewState->ping(); +#endif } if (NewState->has_playername()) { diff --git a/Source/ReplicatorGenerator/Private/Commandlets/CookAndFilterRepActorCommandlet.cpp b/Source/ReplicatorGenerator/Private/Commandlets/CookAndFilterRepActorCommandlet.cpp index 66ea4d7c..ab29a474 100644 --- a/Source/ReplicatorGenerator/Private/Commandlets/CookAndFilterRepActorCommandlet.cpp +++ b/Source/ReplicatorGenerator/Private/Commandlets/CookAndFilterRepActorCommandlet.cpp @@ -50,7 +50,11 @@ int32 UCookAndFilterRepActorCommandlet::Main(const FString& CmdLineParams) TArray LoadedRepClassPath; for (const FSoftClassPath& ObjSoftPath : ObjLoadedListener.FilteredClasses) { +#if ENGINE_MAJOR_VERSION < 5 FString AssetPath = ObjSoftPath.GetAssetPathName().ToString(); +#else + FString AssetPath = ObjSoftPath.GetAssetPath().ToString(); +#endif // AssetPath.RemoveFromEnd(TEXT("_C")); LoadedRepClassPath.Add(AssetPath); } diff --git a/Source/ReplicatorGenerator/Private/Commandlets/CookAndUpdateRepActorCacheCommandlet.cpp b/Source/ReplicatorGenerator/Private/Commandlets/CookAndUpdateRepActorCacheCommandlet.cpp index 2ecc4c0f..d083c90d 100644 --- a/Source/ReplicatorGenerator/Private/Commandlets/CookAndUpdateRepActorCacheCommandlet.cpp +++ b/Source/ReplicatorGenerator/Private/Commandlets/CookAndUpdateRepActorCacheCommandlet.cpp @@ -67,6 +67,7 @@ int32 UCookAndUpdateRepActorCacheCommandlet::Main(const FString& CmdLineParams) FString NewCmdLine = CmdLineParams; NewCmdLine.Append(AdditionalParam); int32 Result = Super::Main(NewCmdLine); + ObjLoadedListener.StopListen(); if (Result != 0) { diff --git a/Source/ReplicatorGenerator/Private/Persistence/ChannelDataSchemaController.cpp b/Source/ReplicatorGenerator/Private/Persistence/ChannelDataSchemaController.cpp index 60f7746c..804a537b 100644 --- a/Source/ReplicatorGenerator/Private/Persistence/ChannelDataSchemaController.cpp +++ b/Source/ReplicatorGenerator/Private/Persistence/ChannelDataSchemaController.cpp @@ -27,7 +27,11 @@ void UChannelDataSchemaController::Initialize(FSubsystemCollectionBase& Collecti void UChannelDataSchemaController::GetUnhiddenChannelTypes(TArray& ChannelTypes) const { +#if ENGINE_MAJOR_VERSION < 5 const UEnum* EnumPtr = FindObject(ANY_PACKAGE, TEXT("EChanneldChannelType"), true); +#else + const UEnum* EnumPtr = FindObject(FTopLevelAssetPath(TEXT("/Script/ChanneldUE.EChanneldChannelType")), true); +#endif if (!EnumPtr) { UE_LOG(LogChanneldRepGenerator, Error, TEXT("Failed to find enum EChanneldChannelType")); diff --git a/Source/ReplicatorGenerator/Private/ReplicatorCodeGenerator.cpp b/Source/ReplicatorGenerator/Private/ReplicatorCodeGenerator.cpp index 5fdaebae..87fd04cd 100644 --- a/Source/ReplicatorGenerator/Private/ReplicatorCodeGenerator.cpp +++ b/Source/ReplicatorGenerator/Private/ReplicatorCodeGenerator.cpp @@ -106,20 +106,11 @@ bool FReplicatorCodeGenerator::Generate( ChannelDataRegistrationGoCode; ReplicationCodeBundle.ChannelDataMerge_GoCode.Append(FString::Printf(TEXT("package %s\n"), *ProtoPackageName)); // Entity channel data.go imports anypb - bool bHasEntityChannelData = ChannelDataInfos.ContainsByPredicate( - [](const auto& Info) - { - return Info.Schema.ChannelType == EChanneldChannelType::ECT_Entity; - } - ); - ReplicationCodeBundle.ChannelDataMerge_GoCode.Append( - FString::Format( - CodeGen_Go_Data_ImportTemplate, - FStringFormatNamedArguments{ - {"Code_AnypbImport", bHasEntityChannelData ? TEXT("\"google.golang.org/protobuf/types/known/anypb\"") : TEXT("")} - } - ) - ); + + bool bHasEntityChannelData = ChannelDataInfos.ContainsByPredicate([](const auto& Info) {return Info.Schema.ChannelType == EChanneldChannelType::ECT_Entity;}); + ReplicationCodeBundle.ChannelDataMerge_GoCode.Append(FString::Format(CodeGen_Go_Data_ImportTemplate, + FStringFormatNamedArguments{{"Code_AnypbImport", bHasEntityChannelData ? TEXT("\"google.golang.org/protobuf/types/known/anypb\"") : TEXT("")}})); + for (const FChannelDataInfo& ChannelDataInfo : ChannelDataInfos) { ReplicationCodeBundle.ChannelDataCodes.Add(FChannelDataCode()); @@ -399,7 +390,11 @@ bool FReplicatorCodeGenerator::GenerateChannelDataCode( , FString& ResultMessage ) { +#if ENGINE_MAJOR_VERSION < 5 const UEnum* EnumPtr = FindObject(ANY_PACKAGE, TEXT("EChanneldChannelType"), true); +#else + const UEnum* EnumPtr = FindObject(FTopLevelAssetPath(TEXT("/Script/ChanneldUE.EChanneldChannelType")), true); +#endif if (!EnumPtr) { ResultMessage = TEXT("Cannot find EChanneldChannelType enum"); diff --git a/Source/ReplicatorGenerator/ReplicatorGenerator.Build.cs b/Source/ReplicatorGenerator/ReplicatorGenerator.Build.cs index b3285e8f..e61ef9d3 100644 --- a/Source/ReplicatorGenerator/ReplicatorGenerator.Build.cs +++ b/Source/ReplicatorGenerator/ReplicatorGenerator.Build.cs @@ -26,9 +26,14 @@ public ReplicatorGenerator(ReadOnlyTargetRules Target) : base(Target) "ChanneldUE", "AnalyticsET", "JsonUtilities", +#if UE_5_0_OR_LATER + "RenderCore", + "DeveloperToolSettings", + "AssetRegistry", +#endif } ); - + string CompilerConfigurationName; switch (Target.Configuration) {