From d52f15ed908cb3891d5dba988e812ae942d0f54c Mon Sep 17 00:00:00 2001 From: Joshua Huburn Date: Thu, 7 Nov 2019 15:28:43 +0000 Subject: [PATCH] Updated worker usages to 14.1 --- .../ExternalSchemaInterface.cpp | 48 ++++++++++--------- .../DeploymentSnapshotTemplate.cpp | 7 +-- .../SpatialSessionStateComponent.cpp | 2 +- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/Game/Source/GDKShooter/ExternalSchemaCodegen/ExternalSchemaInterface.cpp b/Game/Source/GDKShooter/ExternalSchemaCodegen/ExternalSchemaInterface.cpp index 443aacb..f5c3600 100644 --- a/Game/Source/GDKShooter/ExternalSchemaCodegen/ExternalSchemaInterface.cpp +++ b/Game/Source/GDKShooter/ExternalSchemaCodegen/ExternalSchemaInterface.cpp @@ -12,7 +12,7 @@ void ExternalSchemaInterface::SerializeAndSendComponentUpdate(Worker_EntityId En { Worker_ComponentUpdate SerializedUpdate = {}; SerializedUpdate.component_id = ComponentId; - SerializedUpdate.schema_type = Schema_CreateComponentUpdate(ComponentId); + SerializedUpdate.schema_type = Schema_CreateComponentUpdate(); Update.Serialize(SerializedUpdate.schema_type); SpatialWorkerConnection->SendComponentUpdate(EntityId, &SerializedUpdate); } @@ -21,7 +21,8 @@ Worker_RequestId ExternalSchemaInterface::SerializeAndSendCommandRequest(Worker_ { Worker_CommandRequest SerializedRequest = {}; SerializedRequest.component_id = ComponentId; - SerializedRequest.schema_type = Schema_CreateCommandRequest(ComponentId, CommandIndex); + SerializedRequest.command_index = CommandIndex; + SerializedRequest.schema_type = Schema_CreateCommandRequest(); Schema_Object* RequestObject = Schema_GetCommandRequestObject(SerializedRequest.schema_type); Request.Serialize(RequestObject); return SpatialWorkerConnection->SendCommandRequest(EntityId, &SerializedRequest, CommandIndex); @@ -31,7 +32,8 @@ void ExternalSchemaInterface::SerializeAndSendCommandResponse(Worker_RequestId R { Worker_CommandResponse SerializedResponse = {}; SerializedResponse.component_id = ComponentId; - SerializedResponse.schema_type = Schema_CreateCommandResponse(ComponentId, CommandIndex); + SerializedResponse.command_index = CommandIndex; + SerializedResponse.schema_type = Schema_CreateCommandResponse(); Schema_Object* ResponseObject = Schema_GetCommandResponseObject(SerializedResponse.schema_type); Response.Serialize(ResponseObject); return SpatialWorkerConnection->SendCommandResponse(RequestId, &SerializedResponse); @@ -182,12 +184,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 1) + if (Op.response.command_index == 1) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::GetItem::Response(::improbable::database_sync::DatabaseSyncService::Commands::GetItem::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::GetItem::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::GetItem::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::GetItem::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } @@ -215,12 +217,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 2) + if (Op.response.command_index == 2) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::GetItems::Response(::improbable::database_sync::DatabaseSyncService::Commands::GetItems::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::GetItems::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::GetItems::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::GetItems::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } @@ -248,12 +250,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 3) + if (Op.response.command_index == 3) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::Increment::Response(::improbable::database_sync::DatabaseSyncService::Commands::Increment::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::Increment::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::Increment::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::Increment::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } @@ -281,12 +283,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 4) + if (Op.response.command_index == 4) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::Decrement::Response(::improbable::database_sync::DatabaseSyncService::Commands::Decrement::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::Decrement::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::Decrement::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::Decrement::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } @@ -314,12 +316,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 5) + if (Op.response.command_index == 5) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::SetParent::Response(::improbable::database_sync::DatabaseSyncService::Commands::SetParent::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::SetParent::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::SetParent::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::SetParent::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } @@ -347,12 +349,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 6) + if (Op.response.command_index == 6) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::Create::Response(::improbable::database_sync::DatabaseSyncService::Commands::Create::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::Create::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::Create::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::Create::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } @@ -380,12 +382,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 7) + if (Op.response.command_index == 7) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::Delete::Response(::improbable::database_sync::DatabaseSyncService::Commands::Delete::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::Delete::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::Delete::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::Delete::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } @@ -413,12 +415,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 8) + if (Op.response.command_index == 8) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::Batch::Response(::improbable::database_sync::DatabaseSyncService::Commands::Batch::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::Batch::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::Batch::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::Batch::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } @@ -446,12 +448,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 9) + if (Op.response.command_index == 9) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::AssociatePathWithClient::Response(::improbable::database_sync::DatabaseSyncService::Commands::AssociatePathWithClient::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::AssociatePathWithClient::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::AssociatePathWithClient::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::AssociatePathWithClient::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } @@ -479,12 +481,12 @@ USpatialDispatcher::FCallbackId ExternalSchemaInterface::OnCommandResponse(const { return SpatialDispatcher->OnCommandResponse(1901, [Callback](const Worker_CommandResponseOp& Op) { - if (Op.command_id == 10) + if (Op.response.command_index == 10) { auto Response = Op.status_code == Worker_StatusCode::WORKER_STATUS_CODE_SUCCESS ? ::improbable::database_sync::DatabaseSyncService::Commands::GetMetrics::Response(::improbable::database_sync::DatabaseSyncService::Commands::GetMetrics::Response::Type::Deserialize(Schema_GetCommandResponseObject(Op.response.schema_type))) : ::improbable::database_sync::DatabaseSyncService::Commands::GetMetrics::Response(); - Callback(::improbable::database_sync::DatabaseSyncService::Commands::GetMetrics::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.command_id, Response)); + Callback(::improbable::database_sync::DatabaseSyncService::Commands::GetMetrics::ResponseOp(Op.entity_id, Op.request_id, Op.status_code, Op.message, Op.response.command_index, Response)); } }); } diff --git a/Game/Source/GDKShooter/Private/Deployments/DeploymentSnapshotTemplate.cpp b/Game/Source/GDKShooter/Private/Deployments/DeploymentSnapshotTemplate.cpp index a204aae..7489e87 100644 --- a/Game/Source/GDKShooter/Private/Deployments/DeploymentSnapshotTemplate.cpp +++ b/Game/Source/GDKShooter/Private/Deployments/DeploymentSnapshotTemplate.cpp @@ -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()); @@ -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_StreamState::WORKER_STREAM_STATE_GOOD; if (success) { NextEntityId++; } diff --git a/Game/Source/GDKShooter/Private/Game/Components/SpatialSessionStateComponent.cpp b/Game/Source/GDKShooter/Private/Game/Components/SpatialSessionStateComponent.cpp index 73e7a63..aa1771d 100644 --- a/Game/Source/GDKShooter/Private/Game/Components/SpatialSessionStateComponent.cpp +++ b/Game/Source/GDKShooter/Private/Game/Components/SpatialSessionStateComponent.cpp @@ -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);