mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
use macros for packing/unpacking QByteArray
This commit is contained in:
parent
769755e30a
commit
513285a00e
2 changed files with 9 additions and 27 deletions
|
@ -706,22 +706,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
|
|||
// PROP_PAGED_PROPERTY,
|
||||
// PROP_CUSTOM_PROPERTIES_INCLUDED,
|
||||
|
||||
if (requestedProperties.getHasProperty(PROP_SIMULATION_OWNER)) {
|
||||
LevelDetails propertyLevel = packetData->startLevel();
|
||||
successPropertyFits = packetData->appendValue(properties._simulationOwner.toByteArray());
|
||||
if (successPropertyFits) {
|
||||
propertyFlags |= PROP_SIMULATION_OWNER;
|
||||
propertiesDidntFit -= PROP_SIMULATION_OWNER;
|
||||
propertyCount++;
|
||||
packetData->endLevel(propertyLevel);
|
||||
} else {
|
||||
packetData->discardLevel(propertyLevel);
|
||||
appendState = OctreeElement::PARTIAL;
|
||||
}
|
||||
} else {
|
||||
propertiesDidntFit -= PROP_SIMULATION_OWNER;
|
||||
}
|
||||
|
||||
APPEND_ENTITY_PROPERTY(PROP_SIMULATION_OWNER, properties._simulationOwner.toByteArray());
|
||||
APPEND_ENTITY_PROPERTY(PROP_POSITION, properties.getPosition());
|
||||
APPEND_ENTITY_PROPERTY(PROP_DIMENSIONS, properties.getDimensions()); // NOTE: PROP_RADIUS obsolete
|
||||
APPEND_ENTITY_PROPERTY(PROP_ROTATION, properties.getRotation());
|
||||
|
@ -976,17 +961,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
|||
dataAt += propertyFlags.getEncodedLength();
|
||||
processedBytes += propertyFlags.getEncodedLength();
|
||||
|
||||
if (propertyFlags.getHasProperty(PROP_SIMULATION_OWNER)) {
|
||||
QByteArray fromBuffer;
|
||||
int bytes = OctreePacketData::unpackDataFromBytes(dataAt, fromBuffer);
|
||||
|
||||
dataAt += bytes;
|
||||
processedBytes += bytes;
|
||||
SimulationOwner simOwner;
|
||||
simOwner.fromByteArray(fromBuffer);
|
||||
properties.setSimulationOwner(simOwner);
|
||||
}
|
||||
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SIMULATION_OWNER, QByteArray, setSimulationOwner);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_POSITION, glm::vec3, setPosition);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_DIMENSIONS, glm::vec3, setDimensions); // NOTE: PROP_RADIUS obsolete
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ROTATION, glm::quat, setRotation);
|
||||
|
@ -1271,3 +1246,9 @@ void EntityItemProperties::setSimulationOwner(const QUuid& id, uint8_t priority)
|
|||
_simulationOwnerChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityItemProperties::setSimulationOwner(const QByteArray& data) {
|
||||
if (_simulationOwner.fromByteArray(data)) {
|
||||
_simulationOwnerChanged = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,6 +210,7 @@ public:
|
|||
|
||||
void clearSimulationOwner();
|
||||
void setSimulationOwner(const QUuid& id, uint8_t priority);
|
||||
void setSimulationOwner(const QByteArray& data);
|
||||
void promoteSimulationPriority(quint8 priority) { _simulationOwner.promotePriority(priority); }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue