mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 09:03:28 +02:00
Fixed crash on invalid HazeMode.
This commit is contained in:
parent
fe286aff83
commit
edd256c600
3 changed files with 22 additions and 4 deletions
|
@ -228,11 +228,21 @@ const std::array<ComponentPair, COMPONENT_MODE_ITEM_COUNT> COMPONENT_MODES = { {
|
|||
} };
|
||||
|
||||
QString EntityItemProperties::getHazeModeAsString() const {
|
||||
return COMPONENT_MODES[_hazeMode].second;
|
||||
// return "inherit" if _hazeMode is not valid
|
||||
if (_hazeMode >= 0 && _hazeMode < COMPONENT_MODE_ITEM_COUNT) {
|
||||
return COMPONENT_MODES[_hazeMode].second;
|
||||
} else {
|
||||
return COMPONENT_MODES[0].second;
|
||||
}
|
||||
}
|
||||
|
||||
QString EntityItemProperties::getHazeModeString(uint32_t mode) {
|
||||
return COMPONENT_MODES[mode].second;
|
||||
// return "inherit" if mode is not valid
|
||||
if (mode >= 0 && mode < COMPONENT_MODE_ITEM_COUNT) {
|
||||
return COMPONENT_MODES[mode].second;
|
||||
} else {
|
||||
return COMPONENT_MODES[0].second;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityItemProperties::setHazeModeFromString(const QString& hazeMode) {
|
||||
|
|
|
@ -44,6 +44,7 @@ ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID) : EntityItem(en
|
|||
_compoundShapeURL = DEFAULT_COMPOUND_SHAPE_URL;
|
||||
|
||||
_backgroundMode = BACKGROUND_MODE_INHERIT;
|
||||
_hazeMode = (uint32_t)COMPONENT_MODE_INHERIT;
|
||||
}
|
||||
|
||||
EntityItemProperties ZoneEntityItem::getProperties(EntityPropertyFlags desiredProperties) const {
|
||||
|
@ -320,8 +321,15 @@ void ZoneEntityItem::resetRenderingPropertiesChanged() {
|
|||
});
|
||||
}
|
||||
|
||||
#pragma optimize("", off)
|
||||
void ZoneEntityItem::setHazeMode(const uint32_t value) {
|
||||
_hazeMode = value;
|
||||
if (_hazeMode >= 0 && _hazeMode < COMPONENT_MODE_ITEM_COUNT) {
|
||||
_hazeMode = value;
|
||||
}
|
||||
else {
|
||||
_hazeMode = 0;
|
||||
}
|
||||
|
||||
_hazePropertiesChanged = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
|||
|
||||
BackgroundMode _backgroundMode = BACKGROUND_MODE_INHERIT;
|
||||
|
||||
uint8_t _hazeMode{ (uint8_t)COMPONENT_MODE_INHERIT };
|
||||
uint32_t _hazeMode{ (uint32_t)COMPONENT_MODE_INHERIT };
|
||||
|
||||
float _hazeRange{ HazePropertyGroup::DEFAULT_HAZE_RANGE };
|
||||
xColor _hazeColor{ HazePropertyGroup::DEFAULT_HAZE_COLOR };
|
||||
|
|
Loading…
Reference in a new issue