From c3472b8abd8185f392e6c2afb68a7411232396d6 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sun, 27 Jan 2019 08:10:36 +0500 Subject: Added slow GameState sync --- src/RendererWorld.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/RendererWorld.cpp') diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp index 78519f3..d798343 100644 --- a/src/RendererWorld.cpp +++ b/src/RendererWorld.cpp @@ -36,6 +36,8 @@ void RendererWorld::WorkerFunction(size_t workerId) { } void RendererWorld::ParseQueueUpdate() { + World world = gs->GetWorld(); + while (!parseQueue.empty()) { size_t id = 0; for (; id < RendererWorld::parsingBufferSize && parsing[id].parsing; ++id) {} @@ -52,13 +54,13 @@ void RendererWorld::ParseQueueUpdate() { vec.y -= 4500; } - parsing[id].data.section = gs->GetWorld().GetSection(vec); - parsing[id].data.north = gs->GetWorld().GetSection(vec + Vector(0, 0, 1)); - parsing[id].data.south = gs->GetWorld().GetSection(vec + Vector(0, 0, -1)); - parsing[id].data.west = gs->GetWorld().GetSection(vec + Vector(1, 0, 0)); - parsing[id].data.east = gs->GetWorld().GetSection(vec + Vector(-1, 0, 0)); - parsing[id].data.bottom = gs->GetWorld().GetSection(vec + Vector(0, -1, 0)); - parsing[id].data.top = gs->GetWorld().GetSection(vec + Vector(0, 1, 0)); + parsing[id].data.section = world.GetSection(vec); + parsing[id].data.north = world.GetSection(vec + Vector(0, 0, 1)); + parsing[id].data.south = world.GetSection(vec + Vector(0, 0, -1)); + parsing[id].data.west = world.GetSection(vec + Vector(1, 0, 0)); + parsing[id].data.east = world.GetSection(vec + Vector(-1, 0, 0)); + parsing[id].data.bottom = world.GetSection(vec + Vector(0, -1, 0)); + parsing[id].data.top = world.GetSection(vec + Vector(0, 1, 0)); parsing[id].parsing = true; @@ -74,6 +76,8 @@ void RendererWorld::ParseQeueueRemoveUnnecessary() { elements.clear(); elements.reserve(size); + World world = gs->GetWorld(); + for (size_t i = 0; i < size; i++) { Vector vec = parseQueue.front(); parseQueue.pop(); @@ -86,7 +90,7 @@ void RendererWorld::ParseQeueueRemoveUnnecessary() { if (std::find(elements.begin(), elements.end(), vec) != elements.end()) continue; - const Section& section = gs->GetWorld().GetSection(vec); + const Section& section = world.GetSection(vec); bool skip = false; @@ -186,7 +190,7 @@ RendererWorld::RendererWorld(GameState* ptr) { auto data = eventData.get(); for (unsigned int entityId : gs->GetWorld().GetEntitiesList()) { if (entityId == data) { - entities.push_back(RendererEntity(&gs->GetWorld(), entityId)); + entities.push_back(RendererEntity(entityId)); } } }); -- cgit v1.2.3