Merge pull request #3353 from ZappoMan/virtualEntities

fix couple of Entities issues: possible static memory corruption, sphere colors
This commit is contained in:
Clément Brisset 2014-09-04 16:23:38 -07:00
commit fb8b3020e5
4 changed files with 8 additions and 7 deletions

View file

@ -2862,7 +2862,7 @@ function handeMenuEvent(menuItem) {
properties.gravity.z = array[index++].value;
properties.lifetime = array[index++].value; // give ourselves that many more seconds
if (properties.type == "Box") {
if (properties.type == "Box" || properties.type == "Sphere") {
properties.color.red = array[index++].value;
properties.color.green = array[index++].value;
properties.color.blue = array[index++].value;

View file

@ -50,8 +50,6 @@ public:
EntityItemID convertToCreatorTokenVersion() const;
// these methods allow you to create models, and later edit them.
//static uint32_t getIDfromCreatorTokenID(uint32_t creatorTokenID);
static EntityItemID getIDfromCreatorTokenID(uint32_t creatorTokenID);
static uint32_t getNextCreatorTokenID();
static void handleAddEntityResponse(const QByteArray& packet);

View file

@ -24,7 +24,7 @@
QMap<EntityTypes::EntityType, QString> EntityTypes::_typeToNameMap;
QMap<QString, EntityTypes::EntityType> EntityTypes::_nameToTypeMap;
EntityTypeFactory EntityTypes::_factories[EntityTypes::LAST];
EntityTypeFactory EntityTypes::_factories[EntityTypes::LAST + 1];
bool EntityTypes::_factoriesInitialized = false;
const QString ENTITY_TYPE_NAME_UNKNOWN = "Unknown";
@ -58,8 +58,11 @@ bool EntityTypes::registerEntityType(EntityType entityType, const char* name, En
memset(&_factories,0,sizeof(_factories));
_factoriesInitialized = true;
}
_factories[entityType] = factoryMethod;
return true;
if (entityType >= 0 && entityType <= LAST) {
_factories[entityType] = factoryMethod;
return true;
}
return false;
}
EntityItem* EntityTypes::constructEntityItem(EntityType entityType, const EntityItemID& entityID, const EntityItemProperties& properties) {

View file

@ -45,7 +45,7 @@ public:
private:
static QMap<EntityType, QString> _typeToNameMap;
static QMap<QString, EntityTypes::EntityType> _nameToTypeMap;
static EntityTypeFactory _factories[LAST];
static EntityTypeFactory _factories[LAST + 1];
static bool _factoriesInitialized;
};