mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
parse voxel costs to the DomainHandler object
This commit is contained in:
parent
40e08d5008
commit
9dbe74b02f
7 changed files with 42 additions and 34 deletions
|
@ -28,6 +28,7 @@
|
|||
"default": ""
|
||||
},
|
||||
"per-voxel-credits": {
|
||||
"type": "double",
|
||||
"label": "Per Voxel Cost",
|
||||
"help": "Credit cost to change each voxel",
|
||||
"placeholder": "0.0",
|
||||
|
@ -35,6 +36,7 @@
|
|||
"input_addon": "₵"
|
||||
},
|
||||
"per-meter-cubed-credits": {
|
||||
"type": "double",
|
||||
"label": "Per Meter Cubed Cost",
|
||||
"help": "Credit cost to change each cubed meter of voxel space",
|
||||
"placeholder": "0.0",
|
||||
|
|
|
@ -141,6 +141,8 @@ bool DomainServerSettingsManager::handleAuthenticatedHTTPRequest(HTTPConnection
|
|||
return false;
|
||||
}
|
||||
|
||||
const QString SETTING_DESCRIPTION_TYPE_KEY = "type";
|
||||
|
||||
void DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject,
|
||||
QVariantMap& settingsVariant,
|
||||
QJsonObject descriptionObject) {
|
||||
|
@ -155,7 +157,12 @@ void DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ
|
|||
// this is an empty value, clear it in settings variant so the default is sent
|
||||
settingsVariant.remove(key);
|
||||
} else {
|
||||
settingsVariant[key] = rootValue.toString();
|
||||
if (descriptionObject[key].toObject().contains(SETTING_DESCRIPTION_TYPE_KEY)) {
|
||||
// for now this means that this is a double, so set it as a double
|
||||
settingsVariant[key] = rootValue.toString().toDouble();
|
||||
} else {
|
||||
settingsVariant[key] = rootValue.toString();
|
||||
}
|
||||
}
|
||||
} else if (rootValue.isBool()) {
|
||||
settingsVariant[key] = rootValue.toBool();
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <tgmath.h>
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
|
||||
#include "Assignment.h"
|
||||
|
@ -159,6 +161,8 @@ void DomainHandler::settingsRequestFinished() {
|
|||
qDebug() << "Received domain settings.";
|
||||
emit settingsReceived();
|
||||
|
||||
updateVoxelCosts();
|
||||
|
||||
// reset failed settings requests to 0, we got them
|
||||
_failedSettingsRequests = 0;
|
||||
} else {
|
||||
|
@ -177,6 +181,25 @@ void DomainHandler::settingsRequestFinished() {
|
|||
}
|
||||
}
|
||||
|
||||
void DomainHandler::updateVoxelCosts() {
|
||||
|
||||
// from the domain-handler, figure out the satoshi cost per voxel and per meter cubed
|
||||
const QString VOXEL_SETTINGS_KEY = "voxels";
|
||||
const QString PER_VOXEL_COST_KEY = "per-voxel-credits";
|
||||
const QString PER_METER_CUBED_COST_KEY = "per-meter-cubed-credits";
|
||||
|
||||
if (!_settingsObject.isEmpty()) {
|
||||
float perVoxelCredits = (float) _settingsObject[VOXEL_SETTINGS_KEY].toObject()[PER_VOXEL_COST_KEY].toDouble();
|
||||
float perMeterCubedCredits = (float) _settingsObject[VOXEL_SETTINGS_KEY].toObject()[PER_METER_CUBED_COST_KEY].toDouble();
|
||||
|
||||
_satoshisPerVoxel = (qint64) floorf(perVoxelCredits * SATOSHIS_PER_CREDIT);
|
||||
_satoshisPerMeterCubed = (qint64) floorf(perMeterCubedCredits * SATOSHIS_PER_CREDIT);
|
||||
} else {
|
||||
_satoshisPerVoxel = 0;
|
||||
_satoshisPerMeterCubed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DomainHandler::parseDTLSRequirementPacket(const QByteArray& dtlsRequirementPacket) {
|
||||
// figure out the port that the DS wants us to use for us to talk to them with DTLS
|
||||
int numBytesPacketHeader = numBytesForPacketHeader(dtlsRequirementPacket);
|
||||
|
|
|
@ -62,6 +62,9 @@ public:
|
|||
|
||||
void parseDTLSRequirementPacket(const QByteArray& dtlsRequirementPacket);
|
||||
|
||||
qint64 getSatoshisPerVoxel() const { return _satoshisPerVoxel; }
|
||||
qint64 getSatoshisPerMeterCubed() const { return _satoshisPerMeterCubed; }
|
||||
|
||||
private slots:
|
||||
void completedHostnameLookup(const QHostInfo& hostInfo);
|
||||
void settingsRequestFinished();
|
||||
|
@ -75,6 +78,8 @@ signals:
|
|||
private:
|
||||
void reset();
|
||||
|
||||
void updateVoxelCosts();
|
||||
|
||||
QUuid _uuid;
|
||||
QString _hostname;
|
||||
HifiSockAddr _sockAddr;
|
||||
|
@ -83,6 +88,9 @@ private:
|
|||
QTimer* _handshakeTimer;
|
||||
QJsonObject _settingsObject;
|
||||
int _failedSettingsRequests;
|
||||
|
||||
qint64 _satoshisPerVoxel;
|
||||
qint64 _satoshisPerMeterCubed;
|
||||
};
|
||||
|
||||
#endif // hifi_DomainHandler_h
|
||||
|
|
|
@ -70,7 +70,7 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall
|
|||
}
|
||||
|
||||
void UserActivityLogger::requestFinished(const QJsonObject& object) {
|
||||
qDebug() << object;
|
||||
// qDebug() << object;
|
||||
}
|
||||
|
||||
void UserActivityLogger::requestError(QNetworkReply::NetworkError error,const QString& string) {
|
||||
|
|
|
@ -143,25 +143,6 @@ void VoxelEditPacketSender::queueVoxelEditMessages(PacketType type, int numberOf
|
|||
}
|
||||
}
|
||||
|
||||
void VoxelEditPacketSender::updateVoxelCosts(const QJsonObject& domainSettingsObject) {
|
||||
|
||||
// from the domain-handler, figure out the satoshi cost per voxel and per meter cubed
|
||||
const QString VOXEL_SETTINGS_KEY = "voxels";
|
||||
const QString PER_VOXEL_COST_KEY = "per-voxel-credits";
|
||||
const QString PER_METER_CUBED_COST_KEY = "per-meter-cubed-credits";
|
||||
|
||||
if (!domainSettingsObject.isEmpty()) {
|
||||
float perVoxelCredits = (float) domainSettingsObject[VOXEL_SETTINGS_KEY].toObject()[PER_VOXEL_COST_KEY].toDouble();
|
||||
float perMeterCubedCredits = (float) domainSettingsObject[VOXEL_SETTINGS_KEY].toObject()[PER_METER_CUBED_COST_KEY].toDouble();
|
||||
|
||||
qDebug() << "PV: " << perVoxelCredits << "PMC: " << perMeterCubedCredits;
|
||||
} else {
|
||||
qDebug() << "CALLED WITH EMPTY SETTINGS!";
|
||||
_satoshisPerVoxel = 0;
|
||||
_satoshisPerMeterCubed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
qint64 VoxelEditPacketSender::satoshiCostForMessage(PacketType type, int numberOfDetails, VoxelDetail *details) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -52,18 +52,5 @@ public:
|
|||
virtual char getMyNodeType() const { return NodeType::VoxelServer; }
|
||||
|
||||
qint64 satoshiCostForMessage(PacketType type, int numberOfDetails, VoxelDetail* details);
|
||||
|
||||
void setSatoshisPerVoxel(qint64 satoshisPerVoxel) { _satoshisPerVoxel = satoshisPerVoxel; }
|
||||
qint64 getSatoshisPerVoxel() const { return _satoshisPerVoxel; }
|
||||
|
||||
void setSatoshisPerMeterCubed(qint64 satoshisPerMeterCubed) { _satoshisPerMeterCubed = satoshisPerMeterCubed; }
|
||||
qint64 getSatoshisPerMeterCubed() const { return _satoshisPerMeterCubed; }
|
||||
|
||||
public slots:
|
||||
void updateVoxelCosts(const QJsonObject& domainSettingsObject);
|
||||
|
||||
private:
|
||||
qint64 _satoshisPerVoxel;
|
||||
qint64 _satoshisPerMeterCubed;
|
||||
};
|
||||
#endif // hifi_VoxelEditPacketSender_h
|
||||
|
|
Loading…
Reference in a new issue