mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:08:00 +02:00
fix various compiler warnings on gcc
This commit is contained in:
parent
366209668d
commit
f1da6bf90b
6 changed files with 10 additions and 101 deletions
|
@ -33,7 +33,7 @@ bool VoxelHideShowThread::process() {
|
||||||
|
|
||||||
bool showExtraDebugging = Application::getInstance()->getLogger()->extraDebugging();
|
bool showExtraDebugging = Application::getInstance()->getLogger()->extraDebugging();
|
||||||
if (showExtraDebugging && elapsed > USECS_PER_FRAME) {
|
if (showExtraDebugging && elapsed > USECS_PER_FRAME) {
|
||||||
printf("VoxelHideShowThread::process()... checkForCulling took %llu\n", elapsed);
|
qDebug() << "VoxelHideShowThread::process()... checkForCulling took " << elapsed << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isStillRunning()) {
|
if (isStillRunning()) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ bool Controller::computeStars(unsigned numStars, unsigned seed) {
|
||||||
|
|
||||||
this->retile(numStars, _tileResolution);
|
this->retile(numStars, _tileResolution);
|
||||||
|
|
||||||
qDebug("Total time to generate stars: %llu msec\n", (usecTimestampNow() - usecTimestamp(&startTime)) / 1000);
|
qDebug() << "Total time to generate stars: " << (usecTimestampNow() - usecTimestamp(&startTime)) / 1000) << " msec\n";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ void Generator::computeStarPositions(InputVertices& destination, unsigned limit,
|
||||||
vertices->push_back(InputVertex(azimuth, altitude, computeStarColor(STAR_COLORIZATION)));
|
vertices->push_back(InputVertex(azimuth, altitude, computeStarColor(STAR_COLORIZATION)));
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("Took %llu msec to generate stars.\n", (usecTimestampNow() - usecTimestamp(&startTime)) / 1000);
|
qDebug() << "Total time to generate stars: " << (usecTimestampNow() - usecTimestamp(&startTime)) / 1000) << " msec\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// computeStarColor
|
// computeStarColor
|
||||||
|
|
|
@ -100,8 +100,10 @@ void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned c
|
||||||
uint64_t createdAt = (*((uint64_t*)(buffer + numBytesPacketHeader + sizeof(sequence))));
|
uint64_t createdAt = (*((uint64_t*)(buffer + numBytesPacketHeader + sizeof(sequence))));
|
||||||
uint64_t queuedAt = usecTimestampNow();
|
uint64_t queuedAt = usecTimestampNow();
|
||||||
uint64_t transitTime = queuedAt - createdAt;
|
uint64_t transitTime = queuedAt - createdAt;
|
||||||
printf("OctreeEditPacketSender::queuePacketToNode() queued %c - command to node bytes=%ld sequence=%d transitTimeSoFar=%llu usecs\n",
|
qDebug() << "OctreeEditPacketSender::queuePacketToNode() queued " << buffer[0] <<
|
||||||
buffer[0], length, sequence, transitTime);
|
" - command to node bytes=" << length <<
|
||||||
|
" sequence=" << sequence <<
|
||||||
|
" transitTimeSoFar=" << transitTime << " usecs\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,9 +458,9 @@ void Particle::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssiz
|
||||||
const bool wantDebug = false;
|
const bool wantDebug = false;
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
qDebug("Particle::adjustEditPacketForClockSkew()...\n");
|
qDebug("Particle::adjustEditPacketForClockSkew()...\n");
|
||||||
qDebug(" lastEditedInLocalTime: %llu\n", lastEditedInLocalTime);
|
qDebug() << " lastEditedInLocalTime: " << lastEditedInLocalTime << "\n";
|
||||||
qDebug(" clockSkew: %d\n", clockSkew);
|
qDebug() << " clockSkew: " << clockSkew << "\n";
|
||||||
qDebug(" lastEditedInServerTime: %llu\n", lastEditedInServerTime);
|
qDebug() << " lastEditedInServerTime: " << lastEditedInServerTime << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,14 +481,6 @@ void Particle::update() {
|
||||||
bool shouldDie = getShouldDie() || (!isInHand && !isStillMoving && isReallyOld);
|
bool shouldDie = getShouldDie() || (!isInHand && !isStillMoving && isReallyOld);
|
||||||
setShouldDie(shouldDie);
|
setShouldDie(shouldDie);
|
||||||
|
|
||||||
const bool wantDebug = false;
|
|
||||||
if (wantDebug) {
|
|
||||||
printf("Particle::update()... timeElapsed: %f lifeTime:%f editedAgo:%f "
|
|
||||||
"isInHand:%s isStillMoveing:%s isReallyOld:%s shouldDie:%s\n",
|
|
||||||
timeElapsed, getLifetime(), getEditedAgo(), debug::valueOf(isInHand), debug::valueOf(isStillMoving),
|
|
||||||
debug::valueOf(isReallyOld), debug::valueOf(shouldDie));
|
|
||||||
}
|
|
||||||
|
|
||||||
runUpdateScript(); // allow the javascript to alter our state
|
runUpdateScript(); // allow the javascript to alter our state
|
||||||
|
|
||||||
// If the ball is in hand, it doesn't move or have gravity effect it
|
// If the ball is in hand, it doesn't move or have gravity effect it
|
||||||
|
|
|
@ -41,11 +41,9 @@ PacketSender::PacketSender(PacketSenderNotify* notify, int packetsPerSecond) :
|
||||||
_totalPacketsQueued(0),
|
_totalPacketsQueued(0),
|
||||||
_totalBytesQueued(0)
|
_totalBytesQueued(0)
|
||||||
{
|
{
|
||||||
//printf("PacketSender[%p] created... \n", this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketSender::~PacketSender() {
|
PacketSender::~PacketSender() {
|
||||||
//printf("PacketSender::~PacketSender[%p] destroyed... \n", this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,11 +137,6 @@ bool PacketSender::nonThreadedProcess() {
|
||||||
const uint64_t USECS_PER_SECOND = 1000 * 1000;
|
const uint64_t USECS_PER_SECOND = 1000 * 1000;
|
||||||
const float ZERO_RESET_CALLS_PER_SECOND = 1; // used in guard against divide by zero
|
const float ZERO_RESET_CALLS_PER_SECOND = 1; // used in guard against divide by zero
|
||||||
|
|
||||||
bool wantDebugging = false;
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf("\n\nPacketSender::nonThreadedProcess() _packets.size()=%ld\n",_packets.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// keep track of our process call times, so we have a reliable account of how often our caller calls us
|
// keep track of our process call times, so we have a reliable account of how often our caller calls us
|
||||||
uint64_t elapsedSinceLastCall = now - _lastProcessCallTime;
|
uint64_t elapsedSinceLastCall = now - _lastProcessCallTime;
|
||||||
_lastProcessCallTime = now;
|
_lastProcessCallTime = now;
|
||||||
|
@ -153,24 +146,10 @@ bool PacketSender::nonThreadedProcess() {
|
||||||
const int TRUST_AVERAGE_AFTER = AVERAGE_CALL_TIME_SAMPLES * 2;
|
const int TRUST_AVERAGE_AFTER = AVERAGE_CALL_TIME_SAMPLES * 2;
|
||||||
if (_usecsPerProcessCallHint == 0 || _averageProcessCallTime.getSampleCount() > TRUST_AVERAGE_AFTER) {
|
if (_usecsPerProcessCallHint == 0 || _averageProcessCallTime.getSampleCount() > TRUST_AVERAGE_AFTER) {
|
||||||
averageCallTime = _averageProcessCallTime.getAverage();
|
averageCallTime = _averageProcessCallTime.getAverage();
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf("averageCallTime = _averageProcessCallTime.getAverage() =%f\n",averageCallTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
averageCallTime = _usecsPerProcessCallHint;
|
averageCallTime = _usecsPerProcessCallHint;
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf("averageCallTime = _usecsPerProcessCallHint =%f\n",averageCallTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf("elapsedSinceLastCall=%llu averageCallTime=%f\n",elapsedSinceLastCall, averageCallTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_packets.size() == 0) {
|
if (_packets.size() == 0) {
|
||||||
// in non-threaded mode, if there's nothing to do, just return, keep running till they terminate us
|
// in non-threaded mode, if there's nothing to do, just return, keep running till they terminate us
|
||||||
return isStillRunning();
|
return isStillRunning();
|
||||||
|
@ -202,25 +181,15 @@ bool PacketSender::nonThreadedProcess() {
|
||||||
// packets per second send rate.
|
// packets per second send rate.
|
||||||
float callsPerSecond = USECS_PER_SECOND / averageCallTime;
|
float callsPerSecond = USECS_PER_SECOND / averageCallTime;
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf("PacketSender::process() USECS_PER_SECOND=%llu averageCallTime=%f callsPerSecond=%f\n",
|
|
||||||
USECS_PER_SECOND, averageCallTime, callsPerSecond );
|
|
||||||
}
|
|
||||||
|
|
||||||
// theoretically we could get called less than 1 time per second... but since we're using floats, it really shouldn't be
|
// theoretically we could get called less than 1 time per second... but since we're using floats, it really shouldn't be
|
||||||
// possible to get 0 calls per second, but we will guard agains that here, just in case.
|
// possible to get 0 calls per second, but we will guard agains that here, just in case.
|
||||||
if (callsPerSecond == 0) {
|
if (callsPerSecond == 0) {
|
||||||
callsPerSecond = ZERO_RESET_CALLS_PER_SECOND;
|
callsPerSecond = ZERO_RESET_CALLS_PER_SECOND;
|
||||||
qDebug("PacketSender::nonThreadedProcess() UNEXPECTED:callsPerSecond==0, assuming ZERO_RESET_CALLS_PER_SECOND\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the average number of packets per call...
|
// This is the average number of packets per call...
|
||||||
averagePacketsPerCall = _packetsPerSecond / callsPerSecond;
|
averagePacketsPerCall = _packetsPerSecond / callsPerSecond;
|
||||||
packetsToSendThisCall = averagePacketsPerCall;
|
packetsToSendThisCall = averagePacketsPerCall;
|
||||||
if (wantDebugging) {
|
|
||||||
printf("PacketSender::process() averageCallTime=%f averagePacketsPerCall=%f packetsToSendThisCall=%d\n",
|
|
||||||
averageCallTime, averagePacketsPerCall, packetsToSendThisCall);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we get called more than 1 per second, we want to mostly divide the packets evenly across the calls...
|
// if we get called more than 1 per second, we want to mostly divide the packets evenly across the calls...
|
||||||
// but we want to track the remainder and make sure over the course of a second, we are sending the target PPS
|
// but we want to track the remainder and make sure over the course of a second, we are sending the target PPS
|
||||||
|
@ -252,83 +221,33 @@ bool PacketSender::nonThreadedProcess() {
|
||||||
// than 5 times per second) This gives us sufficient smoothing in our packet adjustments
|
// than 5 times per second) This gives us sufficient smoothing in our packet adjustments
|
||||||
float callIntervalsPerReset = fmax(callsPerSecond, MIN_CALL_INTERVALS_PER_RESET);
|
float callIntervalsPerReset = fmax(callsPerSecond, MIN_CALL_INTERVALS_PER_RESET);
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf("about to check interval... callsPerSecond=%f elapsedSinceLastPPSCheck=%llu checkInterval=%f\n",
|
|
||||||
callsPerSecond, elapsedSinceLastCheck, (averageCallTime * CALL_INTERVALS_TO_CHECK));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (elapsedSinceLastCheck > (averageCallTime * CALL_INTERVALS_TO_CHECK)) {
|
if (elapsedSinceLastCheck > (averageCallTime * CALL_INTERVALS_TO_CHECK)) {
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf(">>>>>>>>>>>>>>> check interval... _packetsOverCheckInterval=%d elapsedSinceLastPPSCheck=%llu\n",
|
|
||||||
_packetsOverCheckInterval, elapsedSinceLastCheck);
|
|
||||||
}
|
|
||||||
|
|
||||||
float ppsOverCheckInterval = (float)_packetsOverCheckInterval;
|
float ppsOverCheckInterval = (float)_packetsOverCheckInterval;
|
||||||
float ppsExpectedForCheckInterval = (float)_packetsPerSecond * ((float)elapsedSinceLastCheck / (float)USECS_PER_SECOND);
|
float ppsExpectedForCheckInterval = (float)_packetsPerSecond * ((float)elapsedSinceLastCheck / (float)USECS_PER_SECOND);
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf(">>>>>>>>>>>>>>> check interval... ppsOverCheckInterval=%f ppsExpectedForCheckInterval=%f\n",
|
|
||||||
ppsOverCheckInterval, ppsExpectedForCheckInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ppsOverCheckInterval < ppsExpectedForCheckInterval) {
|
if (ppsOverCheckInterval < ppsExpectedForCheckInterval) {
|
||||||
int adjust = ppsExpectedForCheckInterval - ppsOverCheckInterval;
|
int adjust = ppsExpectedForCheckInterval - ppsOverCheckInterval;
|
||||||
packetsToSendThisCall += adjust;
|
packetsToSendThisCall += adjust;
|
||||||
if (wantDebugging) {
|
|
||||||
qDebug("Lower pps [%f] than expected [%f] over check interval [%llu], adjusting UP by %d.\n",
|
|
||||||
ppsOverCheckInterval, ppsExpectedForCheckInterval, elapsedSinceLastCheck, adjust);
|
|
||||||
}
|
|
||||||
} else if (ppsOverCheckInterval > ppsExpectedForCheckInterval) {
|
} else if (ppsOverCheckInterval > ppsExpectedForCheckInterval) {
|
||||||
int adjust = ppsOverCheckInterval - ppsExpectedForCheckInterval;
|
int adjust = ppsOverCheckInterval - ppsExpectedForCheckInterval;
|
||||||
packetsToSendThisCall -= adjust;
|
packetsToSendThisCall -= adjust;
|
||||||
if (wantDebugging) {
|
|
||||||
qDebug("Higher pps [%f] than expected [%f] over check interval [%llu], adjusting DOWN by %d.\n",
|
|
||||||
ppsOverCheckInterval, ppsExpectedForCheckInterval, elapsedSinceLastCheck, adjust);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (wantDebugging) {
|
|
||||||
qDebug("pps [%f] is expected [%f] over check interval [%llu], NO ADJUSTMENT.\n",
|
|
||||||
ppsOverCheckInterval, ppsExpectedForCheckInterval, elapsedSinceLastCheck);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now, do we want to reset the check interval? don't want to completely reset, because we would still have
|
// now, do we want to reset the check interval? don't want to completely reset, because we would still have
|
||||||
// a rounding error. instead, we check to see that we've passed the reset interval (which is much larger than
|
// a rounding error. instead, we check to see that we've passed the reset interval (which is much larger than
|
||||||
// the check interval), and on those reset intervals we take the second half average and keep that for the next
|
// the check interval), and on those reset intervals we take the second half average and keep that for the next
|
||||||
// interval window...
|
// interval window...
|
||||||
if (wantDebugging) {
|
|
||||||
printf(">>>>>>>>>>> RESET >>>>>>>>>>>>>>> Should we reset? callsPerSecond=%f elapsedSinceLastPPSCheck=%llu resetInterval=%f\n",
|
|
||||||
callsPerSecond, elapsedSinceLastCheck, (averageCallTime * callIntervalsPerReset));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (elapsedSinceLastCheck > (averageCallTime * callIntervalsPerReset)) {
|
if (elapsedSinceLastCheck > (averageCallTime * callIntervalsPerReset)) {
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf(">>>>>>>>>>> RESET >>>>>>>>>>>>>>> elapsedSinceLastCheck/2=%llu _packetsOverCheckInterval/2=%d\n",
|
|
||||||
(elapsedSinceLastCheck / 2), (_packetsOverCheckInterval / 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keep average packets and time for "second half" of check interval
|
// Keep average packets and time for "second half" of check interval
|
||||||
_lastPPSCheck += (elapsedSinceLastCheck / 2);
|
_lastPPSCheck += (elapsedSinceLastCheck / 2);
|
||||||
_packetsOverCheckInterval = (_packetsOverCheckInterval / 2);
|
_packetsOverCheckInterval = (_packetsOverCheckInterval / 2);
|
||||||
|
|
||||||
elapsedSinceLastCheck = now - _lastPPSCheck;
|
elapsedSinceLastCheck = now - _lastPPSCheck;
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf(">>>>>>>>>>> RESET >>>>>>>>>>>>>>> NEW _lastPPSCheck=%llu elapsedSinceLastCheck=%llu _packetsOverCheckInterval=%d\n",
|
|
||||||
_lastPPSCheck, elapsedSinceLastCheck, _packetsOverCheckInterval);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int packetsLeft = _packets.size();
|
int packetsLeft = _packets.size();
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf("packetsSentThisCall=%d packetsToSendThisCall=%d packetsLeft=%d\n",
|
|
||||||
packetsSentThisCall, packetsToSendThisCall, packetsLeft);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now that we know how many packets to send this call to process, just send them.
|
// Now that we know how many packets to send this call to process, just send them.
|
||||||
while ((packetsSentThisCall < packetsToSendThisCall) && (packetsLeft > 0)) {
|
while ((packetsSentThisCall < packetsToSendThisCall) && (packetsLeft > 0)) {
|
||||||
lock();
|
lock();
|
||||||
|
@ -347,10 +266,6 @@ bool PacketSender::nonThreadedProcess() {
|
||||||
_totalPacketsSent++;
|
_totalPacketsSent++;
|
||||||
_totalBytesSent += temporary.getLength();
|
_totalBytesSent += temporary.getLength();
|
||||||
|
|
||||||
if (wantDebugging) {
|
|
||||||
printf("nodeSocket->send()... packetsSentThisCall=%d _packetsOverCheckInterval=%d\n",
|
|
||||||
packetsSentThisCall, _packetsOverCheckInterval);
|
|
||||||
}
|
|
||||||
if (_notify) {
|
if (_notify) {
|
||||||
_notify->packetSentNotification(temporary.getLength());
|
_notify->packetSentNotification(temporary.getLength());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue