-
-
Notifications
You must be signed in to change notification settings - Fork 21
Network Optimization (BoundQueue Refactor) #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
reznok
wants to merge
12
commits into
dev
Choose a base branch
from
dev-bq-refactor
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5208ad5
Initial BindQueue refactor. Ability Activations converted over
reznok cd2d842
Ripped out old queue stuff
reznok c58a5e2
More stuff
reznok 5d73133
Migrate effects over to new system
reznok 4c30ea3
More refactoring. ApplyEffect currently broken.
reznok 49dab44
Add a blank operation when OpId is 0
reznok 0a41783
Server Auth effects working. Applying Predicted effects working.
reznok d053c4d
Add back in: Server Auth Events and Effect Removal
reznok d667918
clean up stale operations on client side. add teleport synced event.
reznok 81da7bf
Add some Insight Trace Macros
reznok 63492b8
Fix ability activation for server pawns
reznok 58e9d6b
fix: server-auth ability activation. added sanity checks
reznok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
990 changes: 372 additions & 618 deletions
990
Source/GMCAbilitySystem/Private/Components/GMCAbilityComponent.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
165 changes: 165 additions & 0 deletions
165
Source/GMCAbilitySystem/Private/Utility/GMASBoundQueueV2.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| #include "Utility/GMASBoundQueueV2.h" | ||
|
|
||
| #include <Utility/GMASBoundQueueV2.h> | ||
|
|
||
| #include "GMCAbilitySystem.h" | ||
| #include "GMCMovementUtilityComponent.h" | ||
|
|
||
|
|
||
| bool FGMASBoundQueueV2::IsValidGMASOperation(const FInstancedStruct& Data) const | ||
| { | ||
| // Check if the operation is a valid type | ||
| if (!OperationData.IsValid()) return false; | ||
|
|
||
| const FGMASBoundQueueV2OperationBaseData* BaseData = OperationData.GetPtr<FGMASBoundQueueV2OperationBaseData>(); | ||
| if (!BaseData) | ||
| { | ||
| UE_LOG(LogGMCAbilitySystem, Error, TEXT("OperationData is not a valid type")); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| bool FGMASBoundQueueV2::IsValidClientOperation(const FInstancedStruct& Data) const | ||
| { | ||
| if (Data.IsValid()) | ||
| { | ||
| const UScriptStruct* StructType = Data.GetScriptStruct(); | ||
| if (ValidClientInputOperationTypes.Contains(StructType)) | ||
| { | ||
| return true; | ||
| } | ||
| UE_LOG(LogGMCAbilitySystem, Error, TEXT("Client operation type %s is not allowed by server as client input"), *StructType->GetName()); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| void FGMASBoundQueueV2::ClearStaleOperationData() | ||
| { | ||
| const int MaximumFreshMoveIndex = GMCMoveCounter - GMCMovementComponent->MoveHistoryMaxSize; | ||
| for (auto It = OperationDataCacheExpiration.CreateIterator(); It; ++It) | ||
| { | ||
| const int64 MoveAddedAt = It->ModeAddedAt; | ||
| if (MoveAddedAt < MaximumFreshMoveIndex) | ||
| { | ||
| const int OperationID = It->OperationID; | ||
| if (!OperationPayloads.Contains(OperationID)) | ||
| { | ||
| UE_LOG(LogGMCAbilitySystem, Warning, TEXT("OperationID %d not found in OperationPayloads, but still in cache expiration map"), OperationID); | ||
| continue; | ||
| } | ||
| // Remove stale operation data | ||
| OperationPayloads.Remove(OperationID); | ||
| It.RemoveCurrent(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void FGMASBoundQueueV2::BindToGMC(UGMC_MovementUtilityCmp* MovementComponent) | ||
| { | ||
| OperationData = FInstancedStruct::Make<FGMASBoundQueueV2OperationBaseData>(); | ||
|
|
||
| BI_OperationData = MovementComponent->BindInstancedStruct( | ||
| OperationData, | ||
| EGMC_PredictionMode::ClientAuth_InputOutput, | ||
| EGMC_CombineMode::CombineIfUnchanged, | ||
| EGMC_SimulationMode::None, | ||
| EGMC_InterpolationFunction::TargetValue); | ||
|
|
||
| GMCMovementComponent = MovementComponent; | ||
| } | ||
|
|
||
| void FGMASBoundQueueV2::GenPreLocalMoveExecution() | ||
| { | ||
| // UE_LOG(LogTemp, Warning, TEXT("OperationDataType: %s"), *OperationData.GetScriptStruct()->GetName()); | ||
| // Client Logic | ||
| if (GMCMovementComponent->GetNetMode() == NM_Client || | ||
| GMCMovementComponent->GetNetMode() == NM_Standalone || | ||
| GMCMovementComponent->IsLocallyControlledListenServerPawn() || | ||
| GMCMovementComponent->IsLocallyControlledDedicatedServerPawn()) | ||
| { | ||
| // Get a pending operation | ||
| if (ClientQueuedOperations.Num() > 0) | ||
| { | ||
| const int OperationIDToProcess = ClientQueuedOperations.Pop(); | ||
| if (OperationPayloads.Contains(OperationIDToProcess)) | ||
| { | ||
| FInstancedStruct OperationPayload; | ||
| OperationPayload.InitializeAs<FGMASBoundQueueV2OperationBaseData>(OperationIDToProcess); | ||
| OperationData = OperationPayload; | ||
| } | ||
reznok marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| else | ||
| { | ||
| OperationData = FInstancedStruct::Make<FGMASBoundQueueV2OperationBaseData>(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void FGMASBoundQueueV2::GenAncillaryTick(const float DeltaTime) | ||
| { | ||
|
|
||
| if (GMCMovementComponent->GetNetMode() >= NM_Client) | ||
| { | ||
| GMCMoveCounter++; | ||
| ClearStaleOperationData(); | ||
| } | ||
|
|
||
| // Tick all Server Queued Operations | ||
| for (auto It = ServerQueuedBoundOperationsGracePeriods.CreateIterator(); It; ++It) | ||
| { | ||
| It.Value() -= DeltaTime; | ||
|
|
||
| if (It.Value() <= 0) | ||
| { | ||
| if (OperationPayloads.Contains(It.Key())) | ||
| { | ||
| OnServerOperationForced.Broadcast(OperationPayloads[It.Key()]); | ||
| OperationPayloads.Remove(It.Key()); | ||
| } | ||
| It.RemoveCurrent(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void FGMASBoundQueueV2::CacheOperationPayload(const int OperationID, const FInstancedStruct& Payload) | ||
| { | ||
| OperationPayloads.Add(OperationID, Payload); | ||
| OperationDataCacheExpiration.Add({OperationID, GMCMoveCounter}); | ||
| } | ||
|
|
||
| void FGMASBoundQueueV2::QueueClientOperation(const int OperationID) | ||
| { | ||
| ClientQueuedOperations.Add(OperationID); | ||
| } | ||
|
|
||
| void FGMASBoundQueueV2::QueueServerOperation(const int OperationID, const float Timeout) | ||
| { | ||
| if (!OperationPayloads.Contains(OperationID)) | ||
| { | ||
| UE_LOG(LogTemp, Error, TEXT("Tried to queue server operation, but server operation %d not found in payloads"), OperationID); | ||
| return; | ||
| } | ||
|
|
||
| const FInstancedStruct QueuedOperation = OperationPayloads[OperationID]; | ||
|
|
||
| // Add to server timeout map | ||
| ServerQueuedBoundOperationsGracePeriods.Add(OperationID, Timeout); | ||
|
|
||
| // Notify | ||
| OnServerOperationAdded.Broadcast(OperationID, QueuedOperation); | ||
| } | ||
|
|
||
| void FGMASBoundQueueV2::ServerAcknowledgeOperation(int ID) | ||
| { | ||
| if (OperationPayloads.Contains(ID)) | ||
| { | ||
| OperationPayloads.Remove(ID); | ||
| } | ||
|
|
||
| if (ServerQueuedBoundOperationsGracePeriods.Contains(ID)) | ||
| { | ||
| ServerQueuedBoundOperationsGracePeriods.Remove(ID); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Incorrect Cached Operations Incoherency Check
The Gameplay Debugger's "Cached Operations" display incorrectly checks for data incoherency. It compares
DataPack.NBActiveEffectDatawithAbilityComponent->ActiveEffectIDs.Num()instead ofDataPack.NBCachedOperationPayloadswithAbilityComponent->BoundQueueV2.OperationPayloads.Num(). This leads to inaccurate incoherency detection for cached operations.