mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 13:14:18 +02:00
pass voxelServerConfig from domain-server through Assignment _payload to VoxelServer
This commit is contained in:
parent
b6548303d1
commit
06f739a623
4 changed files with 71 additions and 5 deletions
|
@ -167,7 +167,10 @@ int main(int argc, const char* argv[]) {
|
|||
if (voxelServerConfig) {
|
||||
qDebug("Reading Voxel Server Configuration.\n");
|
||||
qDebug() << " config: " << voxelServerConfig << "\n";
|
||||
voxelServerAssignment.setPayload((uchar*)voxelServerConfig, strlen(voxelServerConfig) + 1);
|
||||
int payloadLength = strlen(voxelServerConfig) + sizeof(char);
|
||||
uchar* payload = new uchar[payloadLength];
|
||||
memcpy(payload, voxelServerConfig, payloadLength);
|
||||
voxelServerAssignment.setPayload(payload, payloadLength);
|
||||
}
|
||||
|
||||
// construct a local socket to send with our created assignments to the global AS
|
||||
|
|
|
@ -85,17 +85,18 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
|
|||
qDebug("Received a socket that cannot be unpacked!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (numBytes > numBytesRead) {
|
||||
_numPayloadBytes = numBytes - numBytesRead;
|
||||
memcpy(_payload, dataBuffer + numBytesRead, numBytes - numBytesRead);
|
||||
_payload = new uchar[_numPayloadBytes]; // <<< the code was not allocating _payload
|
||||
memcpy(_payload, dataBuffer + numBytesRead, _numPayloadBytes);
|
||||
}
|
||||
}
|
||||
|
||||
Assignment::~Assignment() {
|
||||
delete _attachedPublicSocket;
|
||||
delete _attachedLocalSocket;
|
||||
delete _payload;
|
||||
delete _payload; // <<< this probably needs to be delete[]???
|
||||
_numPayloadBytes = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <OctalCode.h>
|
||||
#include <NodeList.h>
|
||||
#include <NodeTypes.h>
|
||||
|
@ -64,6 +67,7 @@ VoxelServer::VoxelServer(Assignment::Command command, Assignment::Location locat
|
|||
_jurisdictionSender = NULL;
|
||||
_voxelServerPacketProcessor = NULL;
|
||||
_voxelPersistThread = NULL;
|
||||
_parsedArgV = NULL;
|
||||
}
|
||||
|
||||
VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes),
|
||||
|
@ -86,6 +90,16 @@ VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assign
|
|||
_jurisdictionSender = NULL;
|
||||
_voxelServerPacketProcessor = NULL;
|
||||
_voxelPersistThread = NULL;
|
||||
_parsedArgV = NULL;
|
||||
}
|
||||
|
||||
VoxelServer::~VoxelServer() {
|
||||
if (_parsedArgV) {
|
||||
for (int i = 0; i < _argc; i++) {
|
||||
delete[] _parsedArgV[i];
|
||||
}
|
||||
delete[] _parsedArgV;
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelServer::setArguments(int argc, char** argv) {
|
||||
|
@ -93,6 +107,44 @@ void VoxelServer::setArguments(int argc, char** argv) {
|
|||
_argv = const_cast<const char**>(argv);
|
||||
}
|
||||
|
||||
void VoxelServer::parsePayload() {
|
||||
|
||||
//uchar* getPayload() { return _payload; }
|
||||
//int getNumPayloadBytes() const { return _numPayloadBytes; }
|
||||
|
||||
if (getNumPayloadBytes() > 0) {
|
||||
QString config((const char*)getPayload());
|
||||
|
||||
QString delimiterPattern(" ");
|
||||
QStringList configList = config.split(delimiterPattern);
|
||||
|
||||
int argCount = configList.size() + 2;
|
||||
|
||||
printf("VoxelServer::parsePayload()... argCount=%d\n",argCount);
|
||||
|
||||
_parsedArgV = new char*[argCount];
|
||||
const char* dummy = "dummy";
|
||||
_parsedArgV[0] = new char[strlen(dummy)+1];
|
||||
strcpy(_parsedArgV[0], dummy);
|
||||
|
||||
for (int i = 1; i < argCount-1; i++) {
|
||||
QString configItem = configList.at(i-1);
|
||||
_parsedArgV[i] = new char[configItem.length() + 1];
|
||||
strcpy(_parsedArgV[i], configItem.toLocal8Bit().constData());
|
||||
printf("VoxelServer::parsePayload()... _parsedArgV[%d]=%s\n", i, _parsedArgV[i]);
|
||||
}
|
||||
_parsedArgV[argCount - 1] = new char[strlen(dummy)+1];
|
||||
strcpy(_parsedArgV[argCount - 1], dummy);
|
||||
|
||||
setArguments(argCount, _parsedArgV);
|
||||
|
||||
for (int i = 0; i < argCount; i++) {
|
||||
printf("_argv[%d]=%s\n", i, _argv[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelServer::setupStandAlone(const char* domain, int port) {
|
||||
NodeList::createInstance(NODE_TYPE_VOXEL_SERVER, port);
|
||||
|
||||
|
@ -114,6 +166,12 @@ void VoxelServer::setupStandAlone(const char* domain, int port) {
|
|||
|
||||
//int main(int argc, const char * argv[]) {
|
||||
void VoxelServer::run() {
|
||||
|
||||
// Now would be a good time to parse our arguments, if we got them as assignment
|
||||
if (getNumPayloadBytes() > 0) {
|
||||
parsePayload();
|
||||
}
|
||||
|
||||
pthread_mutex_init(&_treeLock, NULL);
|
||||
|
||||
qInstallMessageHandler(sharedMessageHandler);
|
||||
|
@ -143,7 +201,7 @@ void VoxelServer::run() {
|
|||
_jurisdiction = new JurisdictionMap(jurisdictionRoot, jurisdictionEndNodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// should we send environments? Default is yes, but this command line suppresses sending
|
||||
const char* DUMP_VOXELS_ON_MOVE = "--dumpVoxelsOnMove";
|
||||
_dumpVoxelsOnMove = cmdOptionExists(_argc, _argv, DUMP_VOXELS_ON_MOVE);
|
||||
|
|
|
@ -27,6 +27,8 @@ public:
|
|||
|
||||
VoxelServer(const unsigned char* dataBuffer, int numBytes);
|
||||
|
||||
~VoxelServer();
|
||||
|
||||
/// runs the voxel server assignment
|
||||
void run();
|
||||
|
||||
|
@ -61,6 +63,7 @@ public:
|
|||
private:
|
||||
int _argc;
|
||||
const char** _argv;
|
||||
char** _parsedArgV;
|
||||
bool _dontKillOnMissingDomain;
|
||||
|
||||
char _voxelPersistFilename[MAX_FILENAME_LENGTH];
|
||||
|
@ -84,6 +87,7 @@ private:
|
|||
|
||||
NodeWatcher _nodeWatcher; // used to cleanup AGENT data when agents are killed
|
||||
|
||||
void parsePayload();
|
||||
};
|
||||
|
||||
#endif // __voxel_server__VoxelServer__
|
||||
|
|
Loading…
Reference in a new issue