Skip to content

Commit 5871c8b

Browse files
authored
Merge pull request #119 from spatialos/preview
preview > release
2 parents 904c0a0 + 170d48f commit 5871c8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+598
-162
lines changed

.buildkite/nightly.definition.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
agent_queue_id: trigger-pipelines
2+
description: Nightly build and deployment of Unreal Example project
3+
github:
4+
branch_configuration: []
5+
default_branch: master
6+
pull_request_branch_filter_configuration: []
7+
teams:
8+
- name: Everyone
9+
permission: BUILD_AND_READ
10+
- name: gbu/develop/unreal
11+
permission: MANAGE_BUILD_AND_READ

.buildkite/nightly.steps.yaml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
script_runner: &script_runner
2+
agents:
3+
- "agent_count=8"
4+
- "capable_of_building=platform"
5+
- "environment=production"
6+
- "machine_type=quarter"
7+
- "permission_set=builder"
8+
- "platform=linux"
9+
- "queue=${CI_LINUX_BUILDER_QUEUE:-v3-1572524284-e64831bf1e88b227-------z}"
10+
- "scaler_version=2"
11+
- "working_hours_time_zone=london"
12+
13+
common: &common
14+
agents:
15+
- "agent_count=1"
16+
- "capable_of_building=gdk-for-unreal"
17+
- "environment=production"
18+
- "machine_type=quad"
19+
- "permission_set=builder"
20+
- "platform=windows"
21+
- "scaler_version=2"
22+
- "queue=${CI_WINDOWS_BUILDER_QUEUE:-v4-2019-11-07-bk3700-fbffad576b9676d7}" # Has FASTbuild disabled
23+
timeout_in_minutes: 60 # TODO(ENG-548): reduce timeout once agent-cold-start is optimised.
24+
retry:
25+
automatic:
26+
# This is designed to trap and retry failures because agent lost connection. Agent exits with -1 in this case.
27+
- exit_status: -1
28+
limit: 3
29+
plugins:
30+
- ca-johnson/taskkill#v4.1: ~
31+
32+
# NOTE: step labels turn into commit-status names like {org}/{repo}/{pipeline}/{step-label}, lower-case and hyphenated.
33+
# These are then relied on to have stable names by other things, so once named, please beware renaming has consequences.
34+
35+
steps:
36+
- label: "generate-pipeline-steps"
37+
commands:
38+
- "chmod -R +rwx ci"
39+
- "ci/generate-pipeline-steps.sh"
40+
env:
41+
ENGINE_VERSION: "${ENGINE_VERSION}"
42+
<<: *script_runner
43+
44+
- wait
45+
46+
- label: "slack-notify"
47+
if: build.env("SLACK_NOTIFY") == "true" || build.branch == "master"
48+
command: "powershell -NoProfile -NonInteractive -InputFormat Text -Command ./ci/slack-notify.ps1"
49+
<<: *common # This folds the YAML named anchor into this step. Overrides, if any, should follow, not precede.

FindEngine.bat

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set UNREAL_ENGINE=""
77
set UPROJECT=""
88

99
rem First find the .uproject
10-
for /f "delims=" %%A in (' powershell -Command "Get-ChildItem %~dp0 -Depth 1 -Filter *.uproject -File | %% {$_.FullName}" ') do set UPROJECT="%%A"
10+
for /f "delims=" %%A in (' powershell -Command "Get-ChildItem '%~dp0' -Depth 1 -Filter *.uproject -File | %% {$_.FullName}" ') do set UPROJECT="%%A"
1111

1212
if %UPROJECT%=="" (
1313
echo Error: Could not find uproject. Please make sure you have passed in the project directory correctly.
@@ -18,7 +18,7 @@ if %UPROJECT%=="" (
1818
echo Using uproject: %UPROJECT%
1919

2020
rem Get the Engine association from the uproject.
21-
for /f "delims=" %%A in (' powershell -Command "(Get-Content %UPROJECT% | ConvertFrom-Json).EngineAssociation" ') do set ENGINE_ASSOCIATION=%%A
21+
for /f "delims=" %%A in (' powershell -Command "(Get-Content '%UPROJECT%' | ConvertFrom-Json).EngineAssociation" ') do set ENGINE_ASSOCIATION=%%A
2222

2323
echo Engine association for uproject is: %ENGINE_ASSOCIATION%
2424

Game/Config/DefaultSpatialGDKEditorSettings.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ bDeleteDynamicEntities=True
33
bGenerateDefaultLaunchConfig=True
44
bStopSpatialOnExit=False
55
SpatialOSSnapshotFile=default.snapshot
6-
LaunchConfigDesc=(Template="w2_r0500_e5",World=(Dimensions=(X=2000,Y=2000),ChunkEdgeLengthMeters=5,StreamingQueryIntervalSeconds=4,SnapshotWritePeriodSeconds=0,LegacyFlags=(("bridge_qos_max_timeout", "0"),("bridge_soft_handover_enabled", "false"),("enable_chunk_interest", "false")),LegacyJavaParams=()),ServerWorkers=((WorkerTypeName="UnrealWorker")))
6+
LaunchConfigDesc=(Template="w2_r0500_e5",World=(Dimensions=(X=2000,Y=2000),ChunkEdgeLengthMeters=5,SnapshotWritePeriodSeconds=0,LegacyFlags=(("bridge_qos_max_timeout", "0"),("bridge_soft_handover_enabled", "false")),LegacyJavaParams=()),ServerWorkers=((WorkerTypeName="UnrealWorker")))
77
bGeneratePlaceholderEntitiesInSnapshot=True
88

Game/Config/DefaultSpatialGDKSettings.ini

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ OpsUpdateRate=1000.000000
1010
bEnableHandover=True
1111
MaxNetCullDistanceSquared=900000000.000000
1212
QueuedIncomingRPCWaitTime=1.000000
13-
bUsingQBI=True
1413
PositionUpdateFrequency=1.000000
1514
PositionDistanceThreshold=100.000000
1615
bEnableMetrics=True
@@ -30,4 +29,4 @@ DefaultWorkerType=(WorkerTypeName="UnrealWorker")
3029
bEnableOffloading=False
3130
ActorGroups=()
3231
ServerWorkerTypes=("UnrealWorker")
33-
32+
ServicesRegion=Default
19.7 KB
Binary file not shown.
6.74 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
34.5 KB
Binary file not shown.

Game/Content/Splash/EdSplash.bmp

0 Bytes
Binary file not shown.

Game/Content/Splash/Splash.bmp

0 Bytes
Binary file not shown.

Game/Source/GDKShooter.Target.cs

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ public GDKShooterTarget(TargetInfo Target) : base(Target)
99
{
1010
Type = TargetType.Game;
1111
ExtraModuleNames.Add("GDKShooter");
12-
// TODO: UNR-1791 for long-term fix
13-
GlobalDefinitions.Add("UE_ALLOW_MAP_OVERRIDE_IN_SHIPPING=1");
1412
}
1513
}

Game/Source/GDKShooter/Private/Controllers/GDKPlayerController.cpp

+2-13
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,10 @@ AGDKPlayerController::AGDKPlayerController()
4343

4444
}
4545

46-
void AGDKPlayerController::BeginPlay()
47-
{
48-
Super::BeginPlay();
49-
50-
if (PlayerState)
51-
{
52-
if (UPlayerPublisher* PlayerPublisher = Cast<UPlayerPublisher>(GetWorld()->GetGameState()->GetComponentByClass(UPlayerPublisher::StaticClass())))
53-
{
54-
PlayerPublisher->PublishPlayer(PlayerState, EPlayerProgress::Connected);
55-
}
56-
}
57-
}
58-
5946
void AGDKPlayerController::Tick(float DeltaTime)
6047
{
48+
Super::Tick(DeltaTime);
49+
6150
if (GetPawn())
6251
{
6352
LatestPawnYaw = GetPawn()->GetActorRotation().Yaw;

Game/Source/GDKShooter/Private/Deployments/DeploymentSnapshotTemplate.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ bool UDeploymentSnapshotTemplate::WriteToSnapshotOutput(Worker_SnapshotOutputStr
2828
// Serialize Session component data
2929
Worker_ComponentData SessionComponentData{};
3030
SessionComponentData.component_id = 1000;
31-
SessionComponentData.schema_type = Schema_CreateComponentData(1000);
31+
SessionComponentData.schema_type = Schema_CreateComponentData();
3232
Schema_Object* SessionComponentDataObject = Schema_GetComponentDataFields(SessionComponentData.schema_type);
3333
Schema_AddInt32(SessionComponentDataObject, 1, 1);
3434

3535
Worker_ComponentData DeploymentComponentData{};
3636
DeploymentComponentData.component_id = 1001;
37-
DeploymentComponentData.schema_type = Schema_CreateComponentData(1001);
37+
DeploymentComponentData.schema_type = Schema_CreateComponentData();
3838

3939
Components.Add(SpatialGDK::Position(SpatialGDK::Origin).CreatePositionData());
4040
Components.Add(SpatialGDK::Metadata(TEXT("Session")).CreateMetadataData());
@@ -46,7 +46,8 @@ bool UDeploymentSnapshotTemplate::WriteToSnapshotOutput(Worker_SnapshotOutputStr
4646
SessionEntity.component_count = Components.Num();
4747
SessionEntity.components = Components.GetData();
4848

49-
bool success = Worker_SnapshotOutputStream_WriteEntity(OutputStream, &SessionEntity) != 0;
49+
Worker_SnapshotOutputStream_WriteEntity(OutputStream, &SessionEntity);
50+
bool success = Worker_SnapshotOutputStream_GetState(OutputStream).stream_state == WORKER_STREAM_STATE_GOOD;
5051
if (success) {
5152
NextEntityId++;
5253
}

Game/Source/GDKShooter/Private/Deployments/DeploymentsPlayerController.cpp

+36-65
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "SpatialGameInstance.h"
66
#include "TimerManager.h"
7+
#include "SpatialGDKSettings.h"
78
#include "SpatialWorkerConnection.h"
89

910
#include "GDKLogging.h"
@@ -15,79 +16,36 @@ void ADeploymentsPlayerController::BeginPlay()
1516

1617
bShowMouseCursor = true;
1718

18-
QueryPIT();
19-
}
19+
USpatialGameInstance* SpatialGameInstance = GetGameInstance<USpatialGameInstance>();
20+
SpatialWorkerConnection = SpatialGameInstance->GetSpatialWorkerConnection();
2021

21-
void ADeploymentsPlayerController::EndPlay(const EEndPlayReason::Type Reason)
22-
{
23-
GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
24-
}
25-
26-
void OnLoginTokens(void* UserData, const Worker_Alpha_LoginTokensResponse* LoginTokens)
27-
{
28-
ADeploymentsPlayerController* contoller = static_cast<ADeploymentsPlayerController*>(UserData);
29-
if (LoginTokens->status.code == WORKER_CONNECTION_STATUS_CODE_SUCCESS)
30-
{
31-
UE_LOG(LogGDK, Log, TEXT("Success: Login Token Count %d"), LoginTokens->login_token_count);
32-
contoller->Populate(LoginTokens);
33-
}
34-
else
22+
if (SpatialWorkerConnection == nullptr)
3523
{
36-
UE_LOG(LogGDK, Log, TEXT("Failure: Error %s"), UTF8_TO_TCHAR(LoginTokens->status.detail));
24+
// We might not be using spatial networking in which case SpatialWorkerConnection will not exist so we should just return
25+
return;
3726
}
38-
}
3927

40-
void OnPlayerIdentityToken(void* UserData, const Worker_Alpha_PlayerIdentityTokenResponse* PIToken)
41-
{
42-
if (PIToken->status.code == WORKER_CONNECTION_STATUS_CODE_SUCCESS)
43-
{
44-
UE_LOG(LogGDK, Log, TEXT("Success: Received PIToken: %s"), UTF8_TO_TCHAR(PIToken->player_identity_token));
45-
ADeploymentsPlayerController* controller = static_cast<ADeploymentsPlayerController*>(UserData);
46-
controller->LatestPITokenData = PIToken->player_identity_token;
47-
controller->LatestPIToken = UTF8_TO_TCHAR(PIToken->player_identity_token);
48-
49-
if (!controller->GetWorld()->GetTimerManager().IsTimerActive(controller->QueryDeploymentsTimer))
28+
FString SpatialWorkerType = SpatialGameInstance->GetSpatialWorkerType().ToString();
29+
SpatialWorkerConnection->RegisterOnLoginTokensCallback([this](const Worker_Alpha_LoginTokensResponse* Deployments){
30+
Populate(Deployments);
31+
if (!GetWorld()->GetTimerManager().IsTimerActive(QueryDeploymentsTimer))
5032
{
51-
controller->GetWorld()->GetTimerManager().SetTimer(controller->QueryDeploymentsTimer, controller, &ADeploymentsPlayerController::QueryDeployments, 5.0f, true, 0.0f);
33+
GetWorld()->GetTimerManager().SetTimer(QueryDeploymentsTimer, this, &ADeploymentsPlayerController::ScheduleRefreshDeployments, 10.0f, true, 0.0f);
5234
}
53-
}
54-
else
35+
return true;
36+
});
37+
38+
if (GetDefault<USpatialGDKSettings>()->bUseDevelopmentAuthenticationFlow)
5539
{
56-
UE_LOG(LogGDK, Log, TEXT("Failure: Error %s"), UTF8_TO_TCHAR(PIToken->status.detail));
57-
ADeploymentsPlayerController* controller = static_cast<ADeploymentsPlayerController*>(UserData);
58-
59-
if (controller->GetWorld()->GetTimerManager().IsTimerActive(controller->QueryDeploymentsTimer))
60-
{
61-
controller->GetWorld()->GetTimerManager().ClearTimer(controller->QueryDeploymentsTimer);
62-
}
40+
SpatialWorkerConnection->Connect(true, 0);
6341
}
6442
}
6543

66-
void ADeploymentsPlayerController::QueryDeployments()
67-
{
68-
Worker_Alpha_LoginTokensRequest* LTParams = new Worker_Alpha_LoginTokensRequest();
69-
LTParams->player_identity_token = LatestPITokenData;
70-
LTParams->worker_type = "UnrealClient";
71-
Worker_Alpha_LoginTokensResponseFuture* LTFuture = Worker_Alpha_CreateDevelopmentLoginTokensAsync("locator.improbable.io", 444, LTParams);
72-
Worker_Alpha_LoginTokensResponseFuture_Get(LTFuture, nullptr, this, OnLoginTokens);
73-
}
74-
75-
void ADeploymentsPlayerController::QueryPIT()
44+
void ADeploymentsPlayerController::EndPlay(const EEndPlayReason::Type Reason)
7645
{
77-
Worker_Alpha_PlayerIdentityTokenRequest* PITParams = new Worker_Alpha_PlayerIdentityTokenRequest();
78-
// Replace this string with a dev auth token, see docs for information on how to generate one of these
79-
PITParams->development_authentication_token = "REPLACE ME";
80-
PITParams->player_id = "Player Id";
81-
PITParams->display_name = "";
82-
PITParams->metadata = "";
83-
PITParams->use_insecure_connection = false;
84-
85-
Worker_Alpha_PlayerIdentityTokenResponseFuture* PITFuture = Worker_Alpha_CreateDevelopmentPlayerIdentityTokenAsync("locator.improbable.io", 444, PITParams);
86-
87-
if (PITFuture != nullptr)
88-
{
89-
Worker_Alpha_PlayerIdentityTokenResponseFuture_Get(PITFuture, nullptr, this, OnPlayerIdentityToken);
90-
}
46+
if (SpatialWorkerConnection != nullptr)
47+
SpatialWorkerConnection->RegisterOnLoginTokensCallback([](const Worker_Alpha_LoginTokensResponse* Deployments){return false;});
48+
GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
9149
}
9250

9351
FDeploymentInfo Parse(const Worker_Alpha_LoginTokenDetails LoginToken)
@@ -137,12 +95,19 @@ void ADeploymentsPlayerController::Populate(const Worker_Alpha_LoginTokensRespon
13795

13896
void ADeploymentsPlayerController::JoinDeployment(const FString& LoginToken)
13997
{
98+
if (SpatialWorkerConnection == nullptr)
99+
{
100+
UE_LOG(LogGDK, Error, TEXT("Failure: failed to Join Deployment caused by SpatialWorkerConnection is nullptr"));
101+
return;
102+
}
103+
104+
const FLocatorConfig& LocatorConfig = SpatialWorkerConnection->LocatorConfig;
140105
FURL TravelURL;
141-
TravelURL.Host = TEXT("locator.improbable.io");
106+
TravelURL.Host = LocatorConfig.LocatorHost;
142107
TravelURL.AddOption(TEXT("locator"));
143-
TravelURL.AddOption(*FString::Printf(TEXT("playeridentity=%s"), *LatestPIToken));
108+
TravelURL.AddOption(*FString::Printf(TEXT("playeridentity=%s"), *LocatorConfig.PlayerIdentityToken));
144109
TravelURL.AddOption(*FString::Printf(TEXT("login=%s"), *LoginToken));
145-
110+
146111
OnLoadingStarted.Broadcast();
147112

148113
ClientTravel(TravelURL.ToString(), TRAVEL_Absolute, false);
@@ -152,3 +117,9 @@ void ADeploymentsPlayerController::SetLoadingScreen(UUserWidget* LoadingScreen)
152117
{
153118
GetGameInstance()->GetGameViewportClient()->AddViewportWidgetContent(LoadingScreen->TakeWidget());
154119
}
120+
121+
void ADeploymentsPlayerController::ScheduleRefreshDeployments()
122+
{
123+
if (SpatialWorkerConnection != nullptr)
124+
SpatialWorkerConnection->RequestDeploymentLoginTokens();
125+
}

Game/Source/GDKShooter/Private/Game/Components/LobbyTimerComponent.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33
#include "LobbyTimerComponent.h"
44
#include "GDKLogging.h"
55
#include "GameFramework/Actor.h"
6+
#include "Misc/CommandLine.h"
67

78
void ULobbyTimerComponent::BeginPlay()
89
{
10+
#if !UE_BUILD_SHIPPING
11+
// Developer cheat so you don't have to wait for a long time before entering a match.
12+
const TCHAR* CommandLine = FCommandLine::Get();
13+
FParse::Value(CommandLine, TEXT("lobbytime"), DefaultTimerDuration);
14+
FParse::Value(CommandLine, TEXT("lobbyminplayers"), MinimumPlayersToStartCountdown);
15+
#endif
916
bAutoStart = (MinimumPlayersToStartCountdown == 0);
1017
Super::BeginPlay();
1118
}
1219

13-
void ULobbyTimerComponent::InformOfPlayerCount(int32 PlayerCount)
20+
void ULobbyTimerComponent::ServerInformOfPlayerCount_Implementation(int32 PlayerCount)
1421
{
1522
if (bHasTimerFinished || !GetOwner()->HasAuthority())
1623
{
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
// Copyright (c) Improbable Worlds Ltd, All Rights Reserved
22

33
#include "MatchTimerComponent.h"
4+
#include "Misc/CommandLine.h"
45

5-
6+
void UMatchTimerComponent::BeginPlay()
7+
{
8+
#if !UE_BUILD_SHIPPING
9+
// Developer cheat so you can run an arbitrarily long match for testing.
10+
const TCHAR* CommandLine = FCommandLine::Get();
11+
FParse::Value(CommandLine, TEXT("matchtime"), DefaultTimerDuration);
12+
#endif
13+
Super::BeginPlay();
14+
}

Game/Source/GDKShooter/Private/Game/Components/SpatialSessionStateComponent.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void USpatialSessionStateComponent::SendStateUpdate(EGDKSessionProgress SessionP
3333
Worker_EntityId target_entity_id = SessionEntityId;
3434
Worker_ComponentUpdate component_update = {};
3535
component_update.component_id = SessionComponentId;
36-
component_update.schema_type = Schema_CreateComponentUpdate(SessionComponentId);
36+
component_update.schema_type = Schema_CreateComponentUpdate();
3737
Schema_Object* fields_object = Schema_GetComponentUpdateFields(component_update.schema_type);
3838
Schema_AddInt32(fields_object, 1, SessionState);
3939
SpatialNetDriver->Connection->SendComponentUpdate(target_entity_id, &component_update);

Game/Source/GDKShooter/Private/UI/GDKWidget.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "Components/ControllerEventsComponent.h"
55
#include "Components/GDKMovementComponent.h"
66
#include "Components/HealthComponent.h"
7+
#include "EngineClasses/SpatialGameInstance.h"
78
#include "Game/Components/LobbyTimerComponent.h"
89
#include "Game/Components/MatchTimerComponent.h"
910
#include "Game/Components/PlayerCountingComponent.h"
@@ -106,6 +107,11 @@ void UGDKWidget::LeaveGame(const FString& TargetMap)
106107
FURL TravelURL;
107108
TravelURL.Map = *TargetMap;
108109

110+
if (USpatialGameInstance* GameInstance = Cast<USpatialGameInstance>(GetGameInstance()))
111+
{
112+
GameInstance->GetSpatialWorkerConnection()->DestroyConnection();
113+
}
114+
109115
GetOwningPlayer()->ClientTravel(TravelURL.ToString(), TRAVEL_Absolute, false /*bSeamless*/);
110116

111117
}

Game/Source/GDKShooter/Public/Controllers/GDKPlayerController.h

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class GDKSHOOTER_API AGDKPlayerController : public APlayerController
1919
public:
2020
AGDKPlayerController();
2121

22-
virtual void BeginPlay() override;
2322
virtual void Tick(float DeltaTime) override;
2423

2524
FPawnEvent& OnPawn() { return PawnEvent; }

Game/Source/GDKShooter/Public/Deployments/DeploymentSnapshotTemplate.h

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "CoreMinimal.h"
66
#include "Utils/SnapshotGenerationTemplate.h"
7+
#include <WorkerSDK/improbable/c_worker.h>
8+
79
#include "DeploymentSnapshotTemplate.generated.h"
810

911

0 commit comments

Comments
 (0)