| 25 | } |
| 26 | |
| 27 | GObjectID Level::createObject(const ObjectInstanceRes& object_instance_res) |
| 28 | { |
| 29 | GObjectID object_id = ObjectIDAllocator::alloc(); |
| 30 | ASSERT(object_id != k_invalid_gobject_id); |
| 31 | |
| 32 | std::shared_ptr<GObject> gobject; |
| 33 | try |
| 34 | { |
| 35 | gobject = std::make_shared<GObject>(object_id); |
| 36 | } |
| 37 | catch (const std::bad_alloc&) |
| 38 | { |
| 39 | LOG_FATAL("cannot allocate memory for new gobject"); |
| 40 | } |
| 41 | |
| 42 | bool is_loaded = gobject->load(object_instance_res); |
| 43 | if (is_loaded) |
| 44 | { |
| 45 | m_gobjects.emplace(object_id, gobject); |
| 46 | } |
| 47 | else |
| 48 | { |
| 49 | LOG_ERROR("loading object " + object_instance_res.m_name + " failed"); |
| 50 | return k_invalid_gobject_id; |
| 51 | } |
| 52 | return object_id; |
| 53 | } |
| 54 | |
| 55 | bool Level::load(const std::string& level_res_url) |
| 56 | { |
no test coverage detected