mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 12:28:51 +02:00
add bit of sanity checking for incomming AvatarEntities data
This commit is contained in:
parent
0083c77280
commit
09f3b8f485
3 changed files with 14 additions and 0 deletions
|
@ -367,6 +367,15 @@ void Avatar::updateAvatarEntities() {
|
|||
// TODO? put a maximum number of tries on this?
|
||||
}
|
||||
} else {
|
||||
// sanity check data
|
||||
QUuid id;
|
||||
EntityTypes::EntityType type;
|
||||
EntityTypes::extractEntityTypeAndID((unsigned char*)(data.data()), data.size(), type, id);
|
||||
if (id != entityID || !EntityTypes::typeIsValid(type)) {
|
||||
// skip for corrupt
|
||||
++dataItr;
|
||||
continue;
|
||||
}
|
||||
// remember this hash for the future
|
||||
stateItr = _avatarEntityDataHashes.insert(entityID, AvatarEntityDataHash(newHash));
|
||||
}
|
||||
|
|
|
@ -58,6 +58,10 @@ REGISTER_ENTITY_TYPE(Light)
|
|||
REGISTER_ENTITY_TYPE(Zone)
|
||||
REGISTER_ENTITY_TYPE(Material)
|
||||
|
||||
bool EntityTypes::typeIsValid(EntityType type) {
|
||||
return type > EntityType::Unknown && type <= EntityType::LAST;
|
||||
}
|
||||
|
||||
const QString& EntityTypes::getEntityTypeName(EntityType entityType) {
|
||||
QMap<EntityType, QString>::iterator matchedTypeName = _typeToNameMap.find(entityType);
|
||||
if (matchedTypeName != _typeToNameMap.end()) {
|
||||
|
|
|
@ -109,6 +109,7 @@ public:
|
|||
NUM_TYPES
|
||||
} EntityType;
|
||||
|
||||
static bool typeIsValid(EntityType type);
|
||||
static const QString& getEntityTypeName(EntityType entityType);
|
||||
static EntityTypes::EntityType getEntityTypeFromName(const QString& name);
|
||||
static bool registerEntityType(EntityType entityType, const char* name, EntityTypeFactory factoryMethod);
|
||||
|
|
Loading…
Reference in a new issue