From 97172fff8d293758266e8e47e0f559c15ec9bb92 Mon Sep 17 00:00:00 2001 From: Sergey Lapin Date: Tue, 1 Oct 2024 00:33:29 +0300 Subject: [PATCH] Cleanup --- src/godot | 2 +- src/modules/stream/buildings_data.cpp | 98 --------------------------- src/modules/stream/buildings_data.h | 1 - 3 files changed, 1 insertion(+), 100 deletions(-) diff --git a/src/godot b/src/godot index f70472f..361b0df 160000 --- a/src/godot +++ b/src/godot @@ -1 +1 @@ -Subproject commit f70472f1ccb10dd25f83cbecb0be571bc8ea8cbd +Subproject commit 361b0dff172ce7a6d6c0d93d38e06f4dbbef05a0 diff --git a/src/modules/stream/buildings_data.cpp b/src/modules/stream/buildings_data.cpp index 0593622..dce0f2c 100644 --- a/src/modules/stream/buildings_data.cpp +++ b/src/modules/stream/buildings_data.cpp @@ -21,7 +21,6 @@ struct scene_data { Ref packed_scene; String path; Ref loader; - // std::vector buildings; }; struct CBuildingInstance { @@ -433,13 +432,6 @@ void BuildingsData::remove_scene_item(const String &key, const String &bkey) assert(e.is_valid()); CSceneData *d = e.get_mut(); assert(d); -#if 0 - std::vector::iterator b = d->sd.buildings.begin(); - std::vector::iterator h = d->sd.buildings.end(); - // if (item_nodes.has(item)) - // item_nodes[item]->queue_delete(); - d->sd.buildings.erase(std::remove(b, h, bkey), d->sd.buildings.end()); -#endif flecs::query_builder qb = ecs.query_builder().with( flecs::ChildOf, e); @@ -463,11 +455,6 @@ void BuildingsData::add_scene_item(const String &key, const String &bkey) assert(e.is_valid()); CSceneData *d = e.get_mut(); assert(d); -#if 0 - if (std::find(d->sd.buildings.begin(), d->sd.buildings.end(), bkey) == - d->sd.buildings.end()) - d->sd.buildings.push_back(bkey); -#endif String ename = "bi:" + bkey; flecs::entity ce = e.lookup(ename.ascii().ptr()); if (ce.is_valid()) @@ -488,11 +475,6 @@ void BuildingsData::create_scene_data(const String &key, const String &bkey) sd.path = path; sd.loader = ResourceLoader::load_interactive( path, "PackedScene", true); -#if 0 - if (std::find(sd.buildings.begin(), sd.buildings.end(), bkey) == - sd.buildings.end()) - sd.buildings.push_back(bkey); -#endif e.set({ sd }); assert(e.get_mut()); String ename = "bi:" + bkey; @@ -572,11 +554,6 @@ void BuildingsData::set_scene_item_node(const String &key, const String &bkey, assert(e.is_valid()); CSceneData *d = e.get_mut(); assert(d); -#if 0 - if (std::find(d->sd.buildings.begin(), d->sd.buildings.end(), bkey) == - d->sd.buildings.end()) - d->sd.buildings.push_back(bkey); -#endif String ename = "bi:" + bkey; flecs::entity ce = e.lookup(ename.ascii().ptr()); assert(ce.is_valid()); @@ -612,12 +589,6 @@ Node *BuildingsData::get_scene_item_node(const String &key, } void BuildingsData::item_nodes_delete_node(const String &key) { -#if 0 - if (item_nodes.has(key)) { - item_nodes[key]->queue_delete(); - item_nodes.erase(key); - } -#endif flecs::query_builder qb = ecs.query_builder(); flecs::query q = qb.build(); @@ -633,64 +604,9 @@ void BuildingsData::item_nodes_delete_node(const String &key) ib->node = nullptr; } -#if 0 -bool BuildingsData::item_nodes_exists(const String &key) const -{ -#if 0 - bool result = false; - return item_nodes.has(key); - flecs::query_builder qb = - ecs.query_builder(); - flecs::query q = qb.build(); - uint64_t key_hash = key.hash64(); - q.run([key_hash, &result](flecs::iter &it) { - while (it.next()) { - auto em = it.field(0); - auto ib = it.field(1); - if (ib->key.hash64() == key_hash) { - result = true; - it.fini(); - break; - } - } - }); - return result; -#endif - String ename = "bi:" + key; - flecs::entity ce = ecs.lookup(ename.ascii().ptr()); - bool result = ce.is_valid(); - if (!result) - return result; - const CBuildingInstance *bi = ce.get(); - if (!bi) - return false; - if (bi->node) - return true; - return false; -} - -void BuildingsData::item_nodes_set_node(const String &key, Node *node) -{ - item_nodes[key] = node; - String ename = "bi:" + key; - print_line(ename); - flecs::entity ce = ecs.lookup(ename.ascii().ptr()); - assert(ce.is_valid()); - CBuildingInstance *bi = ce.get_mut(); - assert(bi); - bi->node = node; -} -#endif - void BuildingsData::item_nodes_item_removed(const String &key) { int i; -#if 0 - if (item_nodes[key]) - item_nodes[key]->queue_delete(); - item_nodes.erase(key); -#endif - flecs::query_builder qb = ecs.query_builder(); flecs::query q = qb.build(); @@ -713,20 +629,6 @@ String BuildingsData::item_nodes_get_key(int item) const return buildings[item].key; } -#if 0 -Node *BuildingsData::item_nodes_get_node(const String &key) const -{ - if (!item_nodes_exists(key)) - return nullptr; - // return item_nodes[key]; - String ename = "bi:" + key; - flecs::entity ce = ecs.lookup(ename.ascii().ptr()); - assert(ce.is_valid()); - CBuildingInstance *bi = ce.get_mut(); - assert(bi); - return bi->node; -} -#endif Node *BuildingsData::item_nodes_get_node(const String &key) const { flecs::query_builder qb = diff --git a/src/modules/stream/buildings_data.h b/src/modules/stream/buildings_data.h index 853f3a1..a54a180 100644 --- a/src/modules/stream/buildings_data.h +++ b/src/modules/stream/buildings_data.h @@ -60,7 +60,6 @@ public: /* Data for each building in a world */ private: std::vector buildings; - // HashMap item_nodes; public: int get_building_count() const;