Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
Release 0.6.2-rc (#1418)
Browse files Browse the repository at this point in the history
* Bugfix/UNR-2164 GSM Reception Fix (#1378)

* Process GSM-related Ops first

* Addressing PR feedback

* Cleaned up FindAndDispatchStartupOpsClient function

* Update SpatialGDK/Source/SpatialGDK/Private/EngineClasses/SpatialNetDriver.cpp

Co-Authored-By: improbable-valentyn <32096431+improbable-valentyn@users.noreply.github.com>

* Add CHANGELOG entry

* Add CHANGELOG entry

* Update CHANGELOG.md

Co-Authored-By: improbable-valentyn <32096431+improbable-valentyn@users.noreply.github.com>

* Update CHANGELOG.md
  • Loading branch information
oblm authored Oct 10, 2019
1 parent 887cc1e commit bade5c7
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased-`x.y.z`] - 2019-xx-xx

## [`0.6.2`] - 2019-10-10

- The GDK no longer relies on an ordering of entity and interest queries that is not guaranteed by the SpatialOS runtime.
- The multiserver offloading tutorial has been simplified and re-factored.

## [`0.6.1`] - 2019-08-15

### Features:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ USpatialNetDriver::USpatialNetDriver(const FObjectInitializer& ObjectInitializer
, bConnectAsClient(false)
, bPersistSpatialConnection(true)
, bWaitingForAcceptingPlayersToSpawn(false)
, bIsReadyToStart(false)
, bMapLoaded(false)
, NextRPCIndex(0)
, TimeWhenPositionLastUpdated(0.f)
{
Expand All @@ -68,8 +70,6 @@ bool USpatialNetDriver::InitBase(bool bInitAsClient, FNetworkNotify* InNotify, c
checkf(!GetReplicationDriver(), TEXT("Replication Driver not supported, please remove it from config"));

bConnectAsClient = bInitAsClient;
bAuthoritativeDestruction = true;
bIsReadyToStart = bInitAsClient;

FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(this, &USpatialNetDriver::OnMapLoaded);

Expand Down Expand Up @@ -400,6 +400,8 @@ void USpatialNetDriver::OnMapLoaded(UWorld* LoadedWorld)
checkNoEntry();
}
}

bMapLoaded = true;
}

void USpatialNetDriver::OnLevelAddedToWorld(ULevel* LoadedLevel, UWorld* OwningWorld)
Expand Down Expand Up @@ -1840,19 +1842,29 @@ void USpatialNetDriver::HandleStartupOpQueueing(const TArray<Worker_OpList*>& In
}

QueuedStartupOpLists.Append(InOpLists);
bIsReadyToStart = FindAndDispatchStartupOps(InOpLists);
if (IsServer())
{
bIsReadyToStart = FindAndDispatchStartupOpsServer(InOpLists);

if (bIsReadyToStart)
{
// We've found and dispatched all ops we need for startup,
// trigger BeginPlay() on the GSM and process the queued ops.
// Note that FindAndDispatchStartupOps() will have notified the Dispatcher
// to skip the startup ops that we've processed already.
GlobalStateManager->TriggerBeginPlay();
}
}
else
{
bIsReadyToStart = FindAndDispatchStartupOpsClient(InOpLists);
}

if (!bIsReadyToStart)
{
return;
}

// We've found and dispatched all ops we need for startup, trigger BeginPlay()
// on the GSM and process the queued ops. Note that FindAndDispatchStartupOps()
// will have notified the Dispatcher to skip the startup ops that we've
// processed already.
GlobalStateManager->TriggerBeginPlay();

for (Worker_OpList* OpList : QueuedStartupOpLists)
{
Dispatcher->ProcessOps(OpList);
Expand All @@ -1866,7 +1878,7 @@ void USpatialNetDriver::HandleStartupOpQueueing(const TArray<Worker_OpList*>& In
QueuedStartupOpLists.Empty();
}

bool USpatialNetDriver::FindAndDispatchStartupOps(const TArray<Worker_OpList*>& InOpLists)
bool USpatialNetDriver::FindAndDispatchStartupOpsServer(const TArray<Worker_OpList*>& InOpLists)
{
TArray<Worker_Op*> FoundOps;

Expand Down Expand Up @@ -1912,6 +1924,42 @@ bool USpatialNetDriver::FindAndDispatchStartupOps(const TArray<Worker_OpList*>&
}
}

SelectiveProcessOps(FoundOps);

if (EntityPool->IsReady() && GlobalStateManager->IsReadyToCallBeginPlay())
{
// Return whether or not we are ready to start
return true;
}

return false;
}

bool USpatialNetDriver::FindAndDispatchStartupOpsClient(const TArray<Worker_OpList*>& InOpLists)
{
if (bMapLoaded)
{
return true;
}
else
{
// Search for the entity query response for the GlobalStateManager
Worker_Op* Op = nullptr;
FindFirstOpOfType(InOpLists, WORKER_OP_TYPE_ENTITY_QUERY_RESPONSE, &Op);

TArray<Worker_Op*> FoundOps;
if (Op != nullptr)
{
FoundOps.Add(Op);
}

SelectiveProcessOps(FoundOps);
return false;
}
}

void USpatialNetDriver::SelectiveProcessOps(TArray<Worker_Op*> FoundOps)
{
// For each Op we've found, make a Worker_OpList that just contains that Op,
// and pass it to the dispatcher for processing. This allows us to avoid copying
// the Ops around and dealing with memory that is / should be managed by the Worker SDK.
Expand All @@ -1926,13 +1974,4 @@ bool USpatialNetDriver::FindAndDispatchStartupOps(const TArray<Worker_OpList*>&
Dispatcher->ProcessOps(&SingleOpList);
Dispatcher->MarkOpToSkip(Op);
}

if (EntityPool->IsReady() &&
GlobalStateManager->IsReadyToCallBeginPlay())
{
// Return whether or not we are ready to start
return true;
}

return false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class SPATIALGDK_API USpatialNetDriver : public UIpNetDriver
bool bPersistSpatialConnection;
bool bWaitingForAcceptingPlayersToSpawn;
bool bIsReadyToStart;
bool bMapLoaded;

FString SnapshotToLoad;

Expand All @@ -198,7 +199,9 @@ class SPATIALGDK_API USpatialNetDriver : public UIpNetDriver
void HandleOngoingServerTravel();

void HandleStartupOpQueueing(const TArray<Worker_OpList*>& InOpLists);
bool FindAndDispatchStartupOps(const TArray<Worker_OpList*>& InOpLists);
bool FindAndDispatchStartupOpsServer(const TArray<Worker_OpList*>& InOpLists);
bool FindAndDispatchStartupOpsClient(const TArray<Worker_OpList*>& InOpLists);
void SelectiveProcessOps(TArray<Worker_Op*> FoundOps);

UFUNCTION()
void OnMapLoaded(UWorld* LoadedWorld);
Expand Down

0 comments on commit bade5c7

Please sign in to comment.