diff --git a/BigBaseV2/src/gui/window/dbg/debug_globals.cpp b/BigBaseV2/src/gui/window/dbg/debug_globals.cpp index 74b328a8..79e9ff94 100644 --- a/BigBaseV2/src/gui/window/dbg/debug_globals.cpp +++ b/BigBaseV2/src/gui/window/dbg/debug_globals.cpp @@ -30,28 +30,28 @@ namespace big ImGui::Separator(); char label[64]; - sprintf(label, "Freeze###freeze_%d", global.m_base_address); + sprintf(label, "Freeze###freeze_%d", global.get_id()); ImGui::Checkbox(label, &global.m_freeze); ImGui::SameLine(); ImGui::Text(global.m_name.c_str()); ImGui::SameLine(); - sprintf(label, "###input_%d", global.m_base_address); + sprintf(label, "###input_%d", global.get_id()); ImGui::PushItemWidth(200.f); ImGui::InputInt(label, global.get()); ImGui::PopItemWidth(); - sprintf(label, "Write###btn_%d", global.m_base_address); + sprintf(label, "Write###btn_%d", global.get_id()); if (ImGui::Button(label)) global.write(); ImGui::SameLine(); - sprintf(label, "Delete##delet_%d", global.m_base_address); + sprintf(label, "Delete##delete_%d", global.get_id()); if (ImGui::Button(label)) { for (int i = 0; i < g_globals_service->m_globals.size(); i++) - if (const auto& it = g_globals_service->m_globals.at(i); it.m_base_address == global.m_base_address && it.m_name == global.m_name) + if (auto& it = g_globals_service->m_globals.at(i); it.get_id() == global.get_id()) g_globals_service->m_globals.erase(g_globals_service->m_globals.begin() + i); break; diff --git a/BigBaseV2/src/gui/window/dbg/modals/new_globals.cpp b/BigBaseV2/src/gui/window/dbg/modals/new_globals.cpp index b1559af9..eadd4a4b 100644 --- a/BigBaseV2/src/gui/window/dbg/modals/new_globals.cpp +++ b/BigBaseV2/src/gui/window/dbg/modals/new_globals.cpp @@ -80,7 +80,10 @@ namespace big ImGui::SameLine(); if (ImGui::Button("Save")) { - g_globals_service->m_globals.push_back(global(name, base_address, freeze, offsets, offset_count)); + auto new_global = global(name, base_address, freeze, offsets, offset_count); + new_global.build_cache(); + + g_globals_service->m_globals.push_back(new_global); strcpy(name, ""); freeze = false; diff --git a/BigBaseV2/src/services/globals_service.hpp b/BigBaseV2/src/services/globals_service.hpp index 994ac5a1..024050da 100644 --- a/BigBaseV2/src/services/globals_service.hpp +++ b/BigBaseV2/src/services/globals_service.hpp @@ -52,6 +52,8 @@ namespace big global(nlohmann::json data) { + m_internal_id = ++m_instance_count; + m_base_address = data["base_address"]; m_freeze = data["freeze"]; m_name = data["name"]; @@ -63,6 +65,8 @@ namespace big global(const char* name, const int base_address, const bool freeze, const int(*offsets)[2], int offset_count) { + m_internal_id = ++m_instance_count; + m_base_address = base_address; m_freeze = freeze; m_name = std::string(name); @@ -89,6 +93,11 @@ namespace big return m_internal_addr; } + int get_id() + { + return m_internal_id; + } + void set(int value) { m_value = value; @@ -118,6 +127,9 @@ namespace big } private: + inline static int m_instance_count; + + int m_internal_id; int* m_internal_addr; };