mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:21:16 +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?
|
// TODO? put a maximum number of tries on this?
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
// remember this hash for the future
|
||||||
stateItr = _avatarEntityDataHashes.insert(entityID, AvatarEntityDataHash(newHash));
|
stateItr = _avatarEntityDataHashes.insert(entityID, AvatarEntityDataHash(newHash));
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,10 @@ REGISTER_ENTITY_TYPE(Light)
|
||||||
REGISTER_ENTITY_TYPE(Zone)
|
REGISTER_ENTITY_TYPE(Zone)
|
||||||
REGISTER_ENTITY_TYPE(Material)
|
REGISTER_ENTITY_TYPE(Material)
|
||||||
|
|
||||||
|
bool EntityTypes::typeIsValid(EntityType type) {
|
||||||
|
return type > EntityType::Unknown && type <= EntityType::LAST;
|
||||||
|
}
|
||||||
|
|
||||||
const QString& EntityTypes::getEntityTypeName(EntityType entityType) {
|
const QString& EntityTypes::getEntityTypeName(EntityType entityType) {
|
||||||
QMap<EntityType, QString>::iterator matchedTypeName = _typeToNameMap.find(entityType);
|
QMap<EntityType, QString>::iterator matchedTypeName = _typeToNameMap.find(entityType);
|
||||||
if (matchedTypeName != _typeToNameMap.end()) {
|
if (matchedTypeName != _typeToNameMap.end()) {
|
||||||
|
|
|
@ -109,6 +109,7 @@ public:
|
||||||
NUM_TYPES
|
NUM_TYPES
|
||||||
} EntityType;
|
} EntityType;
|
||||||
|
|
||||||
|
static bool typeIsValid(EntityType type);
|
||||||
static const QString& getEntityTypeName(EntityType entityType);
|
static const QString& getEntityTypeName(EntityType entityType);
|
||||||
static EntityTypes::EntityType getEntityTypeFromName(const QString& name);
|
static EntityTypes::EntityType getEntityTypeFromName(const QString& name);
|
||||||
static bool registerEntityType(EntityType entityType, const char* name, EntityTypeFactory factoryMethod);
|
static bool registerEntityType(EntityType entityType, const char* name, EntityTypeFactory factoryMethod);
|
||||||
|
|
Loading…
Reference in a new issue