diff options
author | Juan Linietsky <juan@godotengine.org> | 2020-02-12 14:24:06 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2020-02-12 14:24:54 -0300 |
commit | cf8c679a23b21d6c6f29cba6a54eaa2eed88bf92 (patch) | |
tree | 52aca947b395362b2addec4843915b15947c32ca /core/object.cpp | |
parent | 4aa31a2851e3dd5b67193194f899850239b2669d (diff) |
ObjectID converted to a structure, fixes many bugs where used incorrectly as 32 bits.
Diffstat (limited to 'core/object.cpp')
-rw-r--r-- | core/object.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/core/object.cpp b/core/object.cpp index 937b1ae8d4..dc1dc2c41f 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1916,7 +1916,6 @@ Object::Object() { _class_ptr = NULL; _block_signals = false; _predelete_ok = 0; - _instance_id = 0; _instance_id = ObjectDB::add_instance(this); _can_translate = true; _is_queued_for_deletion = false; @@ -1972,7 +1971,7 @@ Object::~Object() { } ObjectDB::remove_instance(this); - _instance_id = 0; + _instance_id = ObjectID(); _predelete_ok = 2; if (!ScriptServer::are_languages_finished()) { @@ -1995,14 +1994,14 @@ void postinitialize_handler(Object *p_object) { } HashMap<ObjectID, Object *> ObjectDB::instances; -ObjectID ObjectDB::instance_counter = 1; +uint64_t ObjectDB::instance_counter = 1; HashMap<Object *, ObjectID, ObjectDB::ObjectPtrHash> ObjectDB::instance_checks; ObjectID ObjectDB::add_instance(Object *p_object) { - ERR_FAIL_COND_V(p_object->get_instance_id() != 0, 0); + ERR_FAIL_COND_V(p_object->get_instance_id().is_valid(), ObjectID()); rw_lock->write_lock(); - ObjectID instance_id = ++instance_counter; + ObjectID instance_id = ObjectID(++instance_counter); instances[instance_id] = p_object; instance_checks[p_object] = instance_id; |