Skip to content

Commit

Permalink
Merge pull request #119 from spatialos/preview
Browse files Browse the repository at this point in the history
preview > release
  • Loading branch information
oblm authored Mar 17, 2020
2 parents 904c0a0 + 170d48f commit 5871c8b
Show file tree
Hide file tree
Showing 42 changed files with 598 additions and 162 deletions.
11 changes: 11 additions & 0 deletions .buildkite/nightly.definition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
agent_queue_id: trigger-pipelines
description: Nightly build and deployment of Unreal Example project
github:
branch_configuration: []
default_branch: master
pull_request_branch_filter_configuration: []
teams:
- name: Everyone
permission: BUILD_AND_READ
- name: gbu/develop/unreal
permission: MANAGE_BUILD_AND_READ
49 changes: 49 additions & 0 deletions .buildkite/nightly.steps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
script_runner: &script_runner
agents:
- "agent_count=8"
- "capable_of_building=platform"
- "environment=production"
- "machine_type=quarter"
- "permission_set=builder"
- "platform=linux"
- "queue=${CI_LINUX_BUILDER_QUEUE:-v3-1572524284-e64831bf1e88b227-------z}"
- "scaler_version=2"
- "working_hours_time_zone=london"

common: &common
agents:
- "agent_count=1"
- "capable_of_building=gdk-for-unreal"
- "environment=production"
- "machine_type=quad"
- "permission_set=builder"
- "platform=windows"
- "scaler_version=2"
- "queue=${CI_WINDOWS_BUILDER_QUEUE:-v4-2019-11-07-bk3700-fbffad576b9676d7}" # Has FASTbuild disabled
timeout_in_minutes: 60 # TODO(ENG-548): reduce timeout once agent-cold-start is optimised.
retry:
automatic:
# This is designed to trap and retry failures because agent lost connection. Agent exits with -1 in this case.
- exit_status: -1
limit: 3
plugins:
- ca-johnson/taskkill#v4.1: ~

# NOTE: step labels turn into commit-status names like {org}/{repo}/{pipeline}/{step-label}, lower-case and hyphenated.
# These are then relied on to have stable names by other things, so once named, please beware renaming has consequences.

steps:
- label: "generate-pipeline-steps"
commands:
- "chmod -R +rwx ci"
- "ci/generate-pipeline-steps.sh"
env:
ENGINE_VERSION: "${ENGINE_VERSION}"
<<: *script_runner

- wait

- label: "slack-notify"
if: build.env("SLACK_NOTIFY") == "true" || build.branch == "master"
command: "powershell -NoProfile -NonInteractive -InputFormat Text -Command ./ci/slack-notify.ps1"
<<: *common # This folds the YAML named anchor into this step. Overrides, if any, should follow, not precede.
4 changes: 2 additions & 2 deletions FindEngine.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set UNREAL_ENGINE=""
set UPROJECT=""

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

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

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

echo Engine association for uproject is: %ENGINE_ASSOCIATION%

Expand Down
2 changes: 1 addition & 1 deletion Game/Config/DefaultSpatialGDKEditorSettings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ bDeleteDynamicEntities=True
bGenerateDefaultLaunchConfig=True
bStopSpatialOnExit=False
SpatialOSSnapshotFile=default.snapshot
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")))
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")))
bGeneratePlaceholderEntitiesInSnapshot=True

3 changes: 1 addition & 2 deletions Game/Config/DefaultSpatialGDKSettings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ OpsUpdateRate=1000.000000
bEnableHandover=True
MaxNetCullDistanceSquared=900000000.000000
QueuedIncomingRPCWaitTime=1.000000
bUsingQBI=True
PositionUpdateFrequency=1.000000
PositionDistanceThreshold=100.000000
bEnableMetrics=True
Expand All @@ -30,4 +29,4 @@ DefaultWorkerType=(WorkerTypeName="UnrealWorker")
bEnableOffloading=False
ActorGroups=()
ServerWorkerTypes=("UnrealWorker")

ServicesRegion=Default
Binary file modified Game/Content/Characters/BP_Base_Character.uasset
Binary file not shown.
Binary file modified Game/Content/Characters/BP_FPS_Character.uasset
Binary file not shown.
Binary file modified Game/Content/Controllers/BP_GDK_PlayerController.uasset
Binary file not shown.
Binary file modified Game/Content/GameMode/BP_DeathmatchGameState.uasset
Binary file not shown.
Binary file modified Game/Content/GameMode/BP_PlayerState.uasset
Binary file not shown.
Binary file modified Game/Content/Splash/EdSplash.bmp
Binary file not shown.
Binary file modified Game/Content/Splash/Splash.bmp
Binary file not shown.
2 changes: 0 additions & 2 deletions Game/Source/GDKShooter.Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ public GDKShooterTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
ExtraModuleNames.Add("GDKShooter");
// TODO: UNR-1791 for long-term fix
GlobalDefinitions.Add("UE_ALLOW_MAP_OVERRIDE_IN_SHIPPING=1");
}
}
15 changes: 2 additions & 13 deletions Game/Source/GDKShooter/Private/Controllers/GDKPlayerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,10 @@ AGDKPlayerController::AGDKPlayerController()

}

void AGDKPlayerController::BeginPlay()
{
Super::BeginPlay();

if (PlayerState)
{
if (UPlayerPublisher* PlayerPublisher = Cast<UPlayerPublisher>(GetWorld()->GetGameState()->GetComponentByClass(UPlayerPublisher::StaticClass())))
{
PlayerPublisher->PublishPlayer(PlayerState, EPlayerProgress::Connected);
}
}
}

void AGDKPlayerController::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

if (GetPawn())
{
LatestPawnYaw = GetPawn()->GetActorRotation().Yaw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ bool UDeploymentSnapshotTemplate::WriteToSnapshotOutput(Worker_SnapshotOutputStr
// Serialize Session component data
Worker_ComponentData SessionComponentData{};
SessionComponentData.component_id = 1000;
SessionComponentData.schema_type = Schema_CreateComponentData(1000);
SessionComponentData.schema_type = Schema_CreateComponentData();
Schema_Object* SessionComponentDataObject = Schema_GetComponentDataFields(SessionComponentData.schema_type);
Schema_AddInt32(SessionComponentDataObject, 1, 1);

Worker_ComponentData DeploymentComponentData{};
DeploymentComponentData.component_id = 1001;
DeploymentComponentData.schema_type = Schema_CreateComponentData(1001);
DeploymentComponentData.schema_type = Schema_CreateComponentData();

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

bool success = Worker_SnapshotOutputStream_WriteEntity(OutputStream, &SessionEntity) != 0;
Worker_SnapshotOutputStream_WriteEntity(OutputStream, &SessionEntity);
bool success = Worker_SnapshotOutputStream_GetState(OutputStream).stream_state == WORKER_STREAM_STATE_GOOD;
if (success) {
NextEntityId++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "SpatialGameInstance.h"
#include "TimerManager.h"
#include "SpatialGDKSettings.h"
#include "SpatialWorkerConnection.h"

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

bShowMouseCursor = true;

QueryPIT();
}
USpatialGameInstance* SpatialGameInstance = GetGameInstance<USpatialGameInstance>();
SpatialWorkerConnection = SpatialGameInstance->GetSpatialWorkerConnection();

void ADeploymentsPlayerController::EndPlay(const EEndPlayReason::Type Reason)
{
GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
}

void OnLoginTokens(void* UserData, const Worker_Alpha_LoginTokensResponse* LoginTokens)
{
ADeploymentsPlayerController* contoller = static_cast<ADeploymentsPlayerController*>(UserData);
if (LoginTokens->status.code == WORKER_CONNECTION_STATUS_CODE_SUCCESS)
{
UE_LOG(LogGDK, Log, TEXT("Success: Login Token Count %d"), LoginTokens->login_token_count);
contoller->Populate(LoginTokens);
}
else
if (SpatialWorkerConnection == nullptr)
{
UE_LOG(LogGDK, Log, TEXT("Failure: Error %s"), UTF8_TO_TCHAR(LoginTokens->status.detail));
// We might not be using spatial networking in which case SpatialWorkerConnection will not exist so we should just return
return;
}
}

void OnPlayerIdentityToken(void* UserData, const Worker_Alpha_PlayerIdentityTokenResponse* PIToken)
{
if (PIToken->status.code == WORKER_CONNECTION_STATUS_CODE_SUCCESS)
{
UE_LOG(LogGDK, Log, TEXT("Success: Received PIToken: %s"), UTF8_TO_TCHAR(PIToken->player_identity_token));
ADeploymentsPlayerController* controller = static_cast<ADeploymentsPlayerController*>(UserData);
controller->LatestPITokenData = PIToken->player_identity_token;
controller->LatestPIToken = UTF8_TO_TCHAR(PIToken->player_identity_token);

if (!controller->GetWorld()->GetTimerManager().IsTimerActive(controller->QueryDeploymentsTimer))
FString SpatialWorkerType = SpatialGameInstance->GetSpatialWorkerType().ToString();
SpatialWorkerConnection->RegisterOnLoginTokensCallback([this](const Worker_Alpha_LoginTokensResponse* Deployments){
Populate(Deployments);
if (!GetWorld()->GetTimerManager().IsTimerActive(QueryDeploymentsTimer))
{
controller->GetWorld()->GetTimerManager().SetTimer(controller->QueryDeploymentsTimer, controller, &ADeploymentsPlayerController::QueryDeployments, 5.0f, true, 0.0f);
GetWorld()->GetTimerManager().SetTimer(QueryDeploymentsTimer, this, &ADeploymentsPlayerController::ScheduleRefreshDeployments, 10.0f, true, 0.0f);
}
}
else
return true;
});

if (GetDefault<USpatialGDKSettings>()->bUseDevelopmentAuthenticationFlow)
{
UE_LOG(LogGDK, Log, TEXT("Failure: Error %s"), UTF8_TO_TCHAR(PIToken->status.detail));
ADeploymentsPlayerController* controller = static_cast<ADeploymentsPlayerController*>(UserData);

if (controller->GetWorld()->GetTimerManager().IsTimerActive(controller->QueryDeploymentsTimer))
{
controller->GetWorld()->GetTimerManager().ClearTimer(controller->QueryDeploymentsTimer);
}
SpatialWorkerConnection->Connect(true, 0);
}
}

void ADeploymentsPlayerController::QueryDeployments()
{
Worker_Alpha_LoginTokensRequest* LTParams = new Worker_Alpha_LoginTokensRequest();
LTParams->player_identity_token = LatestPITokenData;
LTParams->worker_type = "UnrealClient";
Worker_Alpha_LoginTokensResponseFuture* LTFuture = Worker_Alpha_CreateDevelopmentLoginTokensAsync("locator.improbable.io", 444, LTParams);
Worker_Alpha_LoginTokensResponseFuture_Get(LTFuture, nullptr, this, OnLoginTokens);
}

void ADeploymentsPlayerController::QueryPIT()
void ADeploymentsPlayerController::EndPlay(const EEndPlayReason::Type Reason)
{
Worker_Alpha_PlayerIdentityTokenRequest* PITParams = new Worker_Alpha_PlayerIdentityTokenRequest();
// Replace this string with a dev auth token, see docs for information on how to generate one of these
PITParams->development_authentication_token = "REPLACE ME";
PITParams->player_id = "Player Id";
PITParams->display_name = "";
PITParams->metadata = "";
PITParams->use_insecure_connection = false;

Worker_Alpha_PlayerIdentityTokenResponseFuture* PITFuture = Worker_Alpha_CreateDevelopmentPlayerIdentityTokenAsync("locator.improbable.io", 444, PITParams);

if (PITFuture != nullptr)
{
Worker_Alpha_PlayerIdentityTokenResponseFuture_Get(PITFuture, nullptr, this, OnPlayerIdentityToken);
}
if (SpatialWorkerConnection != nullptr)
SpatialWorkerConnection->RegisterOnLoginTokensCallback([](const Worker_Alpha_LoginTokensResponse* Deployments){return false;});
GetWorld()->GetTimerManager().ClearAllTimersForObject(this);
}

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

void ADeploymentsPlayerController::JoinDeployment(const FString& LoginToken)
{
if (SpatialWorkerConnection == nullptr)
{
UE_LOG(LogGDK, Error, TEXT("Failure: failed to Join Deployment caused by SpatialWorkerConnection is nullptr"));
return;
}

const FLocatorConfig& LocatorConfig = SpatialWorkerConnection->LocatorConfig;
FURL TravelURL;
TravelURL.Host = TEXT("locator.improbable.io");
TravelURL.Host = LocatorConfig.LocatorHost;
TravelURL.AddOption(TEXT("locator"));
TravelURL.AddOption(*FString::Printf(TEXT("playeridentity=%s"), *LatestPIToken));
TravelURL.AddOption(*FString::Printf(TEXT("playeridentity=%s"), *LocatorConfig.PlayerIdentityToken));
TravelURL.AddOption(*FString::Printf(TEXT("login=%s"), *LoginToken));

OnLoadingStarted.Broadcast();

ClientTravel(TravelURL.ToString(), TRAVEL_Absolute, false);
Expand All @@ -152,3 +117,9 @@ void ADeploymentsPlayerController::SetLoadingScreen(UUserWidget* LoadingScreen)
{
GetGameInstance()->GetGameViewportClient()->AddViewportWidgetContent(LoadingScreen->TakeWidget());
}

void ADeploymentsPlayerController::ScheduleRefreshDeployments()
{
if (SpatialWorkerConnection != nullptr)
SpatialWorkerConnection->RequestDeploymentLoginTokens();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
#include "LobbyTimerComponent.h"
#include "GDKLogging.h"
#include "GameFramework/Actor.h"
#include "Misc/CommandLine.h"

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

void ULobbyTimerComponent::InformOfPlayerCount(int32 PlayerCount)
void ULobbyTimerComponent::ServerInformOfPlayerCount_Implementation(int32 PlayerCount)
{
if (bHasTimerFinished || !GetOwner()->HasAuthority())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
// Copyright (c) Improbable Worlds Ltd, All Rights Reserved

#include "MatchTimerComponent.h"
#include "Misc/CommandLine.h"


void UMatchTimerComponent::BeginPlay()
{
#if !UE_BUILD_SHIPPING
// Developer cheat so you can run an arbitrarily long match for testing.
const TCHAR* CommandLine = FCommandLine::Get();
FParse::Value(CommandLine, TEXT("matchtime"), DefaultTimerDuration);
#endif
Super::BeginPlay();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void USpatialSessionStateComponent::SendStateUpdate(EGDKSessionProgress SessionP
Worker_EntityId target_entity_id = SessionEntityId;
Worker_ComponentUpdate component_update = {};
component_update.component_id = SessionComponentId;
component_update.schema_type = Schema_CreateComponentUpdate(SessionComponentId);
component_update.schema_type = Schema_CreateComponentUpdate();
Schema_Object* fields_object = Schema_GetComponentUpdateFields(component_update.schema_type);
Schema_AddInt32(fields_object, 1, SessionState);
SpatialNetDriver->Connection->SendComponentUpdate(target_entity_id, &component_update);
Expand Down
6 changes: 6 additions & 0 deletions Game/Source/GDKShooter/Private/UI/GDKWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Components/ControllerEventsComponent.h"
#include "Components/GDKMovementComponent.h"
#include "Components/HealthComponent.h"
#include "EngineClasses/SpatialGameInstance.h"
#include "Game/Components/LobbyTimerComponent.h"
#include "Game/Components/MatchTimerComponent.h"
#include "Game/Components/PlayerCountingComponent.h"
Expand Down Expand Up @@ -106,6 +107,11 @@ void UGDKWidget::LeaveGame(const FString& TargetMap)
FURL TravelURL;
TravelURL.Map = *TargetMap;

if (USpatialGameInstance* GameInstance = Cast<USpatialGameInstance>(GetGameInstance()))
{
GameInstance->GetSpatialWorkerConnection()->DestroyConnection();
}

GetOwningPlayer()->ClientTravel(TravelURL.ToString(), TRAVEL_Absolute, false /*bSeamless*/);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class GDKSHOOTER_API AGDKPlayerController : public APlayerController
public:
AGDKPlayerController();

virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override;

FPawnEvent& OnPawn() { return PawnEvent; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "CoreMinimal.h"
#include "Utils/SnapshotGenerationTemplate.h"
#include <WorkerSDK/improbable/c_worker.h>

#include "DeploymentSnapshotTemplate.generated.h"


Expand Down
Loading

0 comments on commit 5871c8b

Please sign in to comment.