From a771a5de0771b0971894f93c2d751f93ffa96c25 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 2 Oct 2013 10:53:54 -0700 Subject: [PATCH 1/2] fix for restart hold behavior in domain-server --- domain-server/src/DomainServer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 11408e8a6d..a062c22ad3 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -345,7 +345,7 @@ void DomainServer::possiblyAddStaticAssignmentsBackToQueueAfterRestart(timeval* // throw into the assignment queue const uint64_t RESTART_HOLD_TIME_USECS = 5 * 1000 * 1000; - if (usecTimestampNow() - usecTimestamp(startTime) > RESTART_HOLD_TIME_USECS) { + if (!_hasCompletedRestartHold && usecTimestampNow() - usecTimestamp(startTime) > RESTART_HOLD_TIME_USECS) { _hasCompletedRestartHold = true; // pull anything in the static assignment file that isn't spoken for and add to the assignment queue @@ -530,7 +530,7 @@ int DomainServer::run() { qDebug("Received a request for assignment.\n"); - if (_hasCompletedRestartHold) { + if (!_hasCompletedRestartHold) { possiblyAddStaticAssignmentsBackToQueueAfterRestart(&startTime); } From e8b0790b3e8121a9593035bf31917d93c5f759ba Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 2 Oct 2013 11:42:27 -0700 Subject: [PATCH 2/2] updates to VoxelScriptingInterface for smarter packet sending --- assignment-client/src/Agent.cpp | 6 +++++- assignment-client/src/voxels/VoxelScriptingInterface.cpp | 4 ++-- domain-server/resources/web/assignment/placeholder.js | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 1a0a17e0c8..c9d5dd3d09 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -138,7 +138,9 @@ void Agent::run() { hasVoxelServer = true; } } - } else { + } + + if (hasVoxelServer) { // allow the scripter's call back to setup visual data emit willSendVisualDataCallback(); @@ -147,6 +149,8 @@ void Agent::run() { qDebug() << "Uncaught exception at line" << line << ":" << engine.uncaughtException().toString() << "\n"; } + // flush the queue of packets and then process them so they are all sent off + voxelScripter.getVoxelPacketSender()->flushQueue(); voxelScripter.getVoxelPacketSender()->processWithoutSleep(); } diff --git a/assignment-client/src/voxels/VoxelScriptingInterface.cpp b/assignment-client/src/voxels/VoxelScriptingInterface.cpp index 3f4df78baf..e94f87264a 100644 --- a/assignment-client/src/voxels/VoxelScriptingInterface.cpp +++ b/assignment-client/src/voxels/VoxelScriptingInterface.cpp @@ -9,7 +9,7 @@ #include "VoxelScriptingInterface.h" void VoxelScriptingInterface::queueVoxelAdd(PACKET_TYPE addPacketType, VoxelDetail& addVoxelDetails) { - _voxelPacketSender.sendVoxelEditMessage(addPacketType, addVoxelDetails); + _voxelPacketSender.queueVoxelEditMessages(addPacketType, 1, &addVoxelDetails); } void VoxelScriptingInterface::queueVoxelAdd(float x, float y, float z, float scale, uchar red, uchar green, uchar blue) { @@ -34,5 +34,5 @@ void VoxelScriptingInterface::queueVoxelDelete(float x, float y, float z, float // setup a VoxelDetail struct with data VoxelDetail deleteVoxelDetail = {x, y, z, scale, 0, 0, 0}; - _voxelPacketSender.sendVoxelEditMessage(PACKET_TYPE_ERASE_VOXEL, deleteVoxelDetail); + _voxelPacketSender.queueVoxelEditMessages(PACKET_TYPE_ERASE_VOXEL, 1, &deleteVoxelDetail); } diff --git a/domain-server/resources/web/assignment/placeholder.js b/domain-server/resources/web/assignment/placeholder.js index e351f5e2b7..74891d12e8 100644 --- a/domain-server/resources/web/assignment/placeholder.js +++ b/domain-server/resources/web/assignment/placeholder.js @@ -2,14 +2,14 @@ // The following is an example of Conway's Game of Life (http://en.wikipedia.org/wiki/Conway's_Game_of_Life) -var NUMBER_OF_CELLS_EACH_DIMENSION = 32; +var NUMBER_OF_CELLS_EACH_DIMENSION = 64; var NUMBER_OF_CELLS = NUMBER_OF_CELLS_EACH_DIMENSION * NUMBER_OF_CELLS_EACH_DIMENSION; var currentCells = []; var nextCells = []; var METER_LENGTH = 1 / TREE_SCALE; -var cellScale = (8 * METER_LENGTH) / NUMBER_OF_CELLS_EACH_DIMENSION; +var cellScale = (NUMBER_OF_CELLS_EACH_DIMENSION * METER_LENGTH) / NUMBER_OF_CELLS_EACH_DIMENSION; print("TREE_SCALE = " + TREE_SCALE + "\n");