mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
rewrite Operative stubbed code to be able to be killed
This commit is contained in:
parent
4e9bac4617
commit
4773e70c15
3 changed files with 18 additions and 7 deletions
0
interface/src/Application.cpp
Executable file → Normal file
0
interface/src/Application.cpp
Executable file → Normal file
|
@ -89,7 +89,7 @@ const BugPart bugParts[VOXELS_PER_BUG] = {
|
||||||
BugPart(glm::vec3(-2, -1, 0), 153, 200, 0) ,
|
BugPart(glm::vec3(-2, -1, 0), 153, 200, 0) ,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void renderMovingBug() {
|
void removeOldBug() {
|
||||||
VoxelDetail details[VOXELS_PER_BUG];
|
VoxelDetail details[VOXELS_PER_BUG];
|
||||||
unsigned char* bufferOut;
|
unsigned char* bufferOut;
|
||||||
int sizeOut;
|
int sizeOut;
|
||||||
|
@ -118,11 +118,17 @@ static void renderMovingBug() {
|
||||||
::packetsSent++;
|
::packetsSent++;
|
||||||
::bytesSent += sizeOut;
|
::bytesSent += sizeOut;
|
||||||
|
|
||||||
printf("sending packet of size=%d\n", sizeOut);
|
|
||||||
|
|
||||||
NodeList::getInstance()->broadcastToNodes(bufferOut, sizeOut, &NODE_TYPE_VOXEL_SERVER, 1);
|
NodeList::getInstance()->broadcastToNodes(bufferOut, sizeOut, &NODE_TYPE_VOXEL_SERVER, 1);
|
||||||
delete[] bufferOut;
|
delete[] bufferOut;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void renderMovingBug() {
|
||||||
|
VoxelDetail details[VOXELS_PER_BUG];
|
||||||
|
unsigned char* bufferOut;
|
||||||
|
int sizeOut;
|
||||||
|
|
||||||
|
removeOldBug();
|
||||||
|
|
||||||
// Move the bug...
|
// Move the bug...
|
||||||
if (moveBugInLine) {
|
if (moveBugInLine) {
|
||||||
|
@ -181,14 +187,12 @@ static void renderMovingBug() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the "create message" ...
|
// send the "create message" ...
|
||||||
message = PACKET_HEADER_SET_VOXEL_DESTRUCTIVE;
|
PACKET_HEADER message = PACKET_HEADER_SET_VOXEL_DESTRUCTIVE;
|
||||||
if (createVoxelEditMessage(message, 0, VOXELS_PER_BUG, (VoxelDetail*)&details, bufferOut, sizeOut)){
|
if (createVoxelEditMessage(message, 0, VOXELS_PER_BUG, (VoxelDetail*)&details, bufferOut, sizeOut)){
|
||||||
|
|
||||||
::packetsSent++;
|
::packetsSent++;
|
||||||
::bytesSent += sizeOut;
|
::bytesSent += sizeOut;
|
||||||
|
|
||||||
printf("sending packet of size=%d\n", sizeOut);
|
|
||||||
|
|
||||||
NodeList::getInstance()->broadcastToNodes(bufferOut, sizeOut, &NODE_TYPE_VOXEL_SERVER, 1);
|
NodeList::getInstance()->broadcastToNodes(bufferOut, sizeOut, &NODE_TYPE_VOXEL_SERVER, 1);
|
||||||
delete[] bufferOut;
|
delete[] bufferOut;
|
||||||
}
|
}
|
||||||
|
@ -212,8 +216,9 @@ void Operative::run() {
|
||||||
// change the owner type on our NodeList
|
// change the owner type on our NodeList
|
||||||
NodeList::getInstance()->setOwnerType(NODE_TYPE_AGENT);
|
NodeList::getInstance()->setOwnerType(NODE_TYPE_AGENT);
|
||||||
NodeList::getInstance()->setNodeTypesOfInterest(&NODE_TYPE_VOXEL_SERVER, 1);
|
NodeList::getInstance()->setNodeTypesOfInterest(&NODE_TYPE_VOXEL_SERVER, 1);
|
||||||
|
NodeList::getInstance()->getNodeSocket()->setBlocking(false);
|
||||||
|
|
||||||
while (true) {
|
while (!shouldStop) {
|
||||||
gettimeofday(&lastSendTime, NULL);
|
gettimeofday(&lastSendTime, NULL);
|
||||||
|
|
||||||
renderMovingBug();
|
renderMovingBug();
|
||||||
|
@ -238,4 +243,9 @@ void Operative::run() {
|
||||||
std::cout << "Last send took too much time, not sleeping!\n";
|
std::cout << "Last send took too much time, not sleeping!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("Removing the old bird and dying.\n");
|
||||||
|
|
||||||
|
// we've been told to stop, remove the last bug
|
||||||
|
removeOldBug();
|
||||||
}
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
class Operative {
|
class Operative {
|
||||||
public:
|
public:
|
||||||
|
bool volatile shouldStop;
|
||||||
void run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue