From ff1b4a93b3275b5d58865933b24086d87d97180b Mon Sep 17 00:00:00 2001 From: cdemeyer-teachx Date: Wed, 12 Nov 2025 12:34:20 +0900 Subject: [PATCH] SQL setup --- CMakeLists.txt | 20 +- .../{achievements.hpp => achievements.h} | 0 .../{harvestables.hpp => harvestables.h} | 0 include/configs/{items.hpp => items.h} | 0 include/configs/{loot.hpp => loot.h} | 0 include/configs/{npcs.hpp => npcs.h} | 0 include/configs/{shops.hpp => shops.h} | 0 include/helpers.hpp | 9 + include/project_parser.h | 15 +- src/configs/achievements.cpp | 2 +- src/configs/harvestables.cpp | 2 +- src/configs/items.cpp | 2 +- src/configs/loot.cpp | 2 +- src/configs/npcs.cpp | 2 +- src/configs/shops.cpp | 2 +- src/helpers.cpp | 183 ++++++++++++++++++ src/main.cpp | 2 +- src/project_parser.cpp | 10 +- 18 files changed, 231 insertions(+), 20 deletions(-) rename include/configs/{achievements.hpp => achievements.h} (100%) rename include/configs/{harvestables.hpp => harvestables.h} (100%) rename include/configs/{items.hpp => items.h} (100%) rename include/configs/{loot.hpp => loot.h} (100%) rename include/configs/{npcs.hpp => npcs.h} (100%) rename include/configs/{shops.hpp => shops.h} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b20027..519d28e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ include(FetchContent) message(STATUS "Using rapidyaml") message(STATUS "Using GLM") message(STATUS "Using TinyXML2") +message(STATUS "Using SQLiteCpp") +message(STATUS "Using rapidjson") FetchContent_Declare( rapidyaml @@ -33,11 +35,23 @@ FetchContent_Declare( GIT_TAG master ) +FetchContent_Declare( + sqlitecpp + GIT_REPOSITORY https://github.com/SRombauts/SQLiteCpp.git + GIT_TAG master +) + +FetchContent_Declare( + rapidjson + GIT_REPOSITORY https://github.com/Tencent/rapidjson + GIT_TAG master +) + # Enable exceptions in rapidyaml set(RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS ON CACHE BOOL "" FORCE) set(RYML_DBG OFF CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(rapidyaml glm tinyxml2) +FetchContent_MakeAvailable(rapidyaml glm tinyxml2 sqlitecpp rapidjson) # Create the main executable add_executable(${PROJECT_NAME} ${SOURCES}) @@ -45,6 +59,7 @@ add_executable(${PROJECT_NAME} ${SOURCES}) # Link libraries to our executable target_link_libraries(${PROJECT_NAME} PUBLIC ryml::ryml) target_link_libraries(${PROJECT_NAME} PUBLIC tinyxml2::tinyxml2) +target_link_libraries(${PROJECT_NAME} PUBLIC SQLiteCpp) # Add include directories for rapidyaml target_include_directories(${PROJECT_NAME} PRIVATE ${rapidyaml_SOURCE_DIR}/src) @@ -52,5 +67,8 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${rapidyaml_SOURCE_DIR}/src) # Add include directories for GLM target_include_directories(${PROJECT_NAME} PRIVATE ${glm_SOURCE_DIR}) +# Add include directories for rapidjson +target_include_directories(${PROJECT_NAME} PRIVATE ${rapidjson_SOURCE_DIR}/include) + # Include directories target_include_directories(${PROJECT_NAME} PRIVATE include) \ No newline at end of file diff --git a/include/configs/achievements.hpp b/include/configs/achievements.h similarity index 100% rename from include/configs/achievements.hpp rename to include/configs/achievements.h diff --git a/include/configs/harvestables.hpp b/include/configs/harvestables.h similarity index 100% rename from include/configs/harvestables.hpp rename to include/configs/harvestables.h diff --git a/include/configs/items.hpp b/include/configs/items.h similarity index 100% rename from include/configs/items.hpp rename to include/configs/items.h diff --git a/include/configs/loot.hpp b/include/configs/loot.h similarity index 100% rename from include/configs/loot.hpp rename to include/configs/loot.h diff --git a/include/configs/npcs.hpp b/include/configs/npcs.h similarity index 100% rename from include/configs/npcs.hpp rename to include/configs/npcs.h diff --git a/include/configs/shops.hpp b/include/configs/shops.h similarity index 100% rename from include/configs/shops.hpp rename to include/configs/shops.h diff --git a/include/helpers.hpp b/include/helpers.hpp index 264dbf0..b0b226f 100644 --- a/include/helpers.hpp +++ b/include/helpers.hpp @@ -17,4 +17,13 @@ WorkbenchType stringToWorkbenchType(const std::string& str); GenstatType stringToGenstatType(const std::string& str); ActionType stringToActionType(const std::string& str); +std::string statTypeToString(StatType type); +std::string itemCategoryToString(ItemCategory category); +std::string itemTypeToString(ItemType type); +std::string toolToString(Tool tool); +std::string skillTypeToString(SkillType skill); +std::string workbenchTypeToString(WorkbenchType workbench); +std::string genstatTypeToString(GenstatType genstat); +std::string actionTypeToString(ActionType action); + } // namespace cursebreaker \ No newline at end of file diff --git a/include/project_parser.h b/include/project_parser.h index 35afb81..4a15ae8 100644 --- a/include/project_parser.h +++ b/include/project_parser.h @@ -6,14 +6,17 @@ #include #include +#include +#include + #include "assets/asset_base.hpp" #include "assets/scene.hpp" -#include "configs/items.hpp" -#include "configs/loot.hpp" -#include "configs/harvestables.hpp" -#include "configs/npcs.hpp" -#include "configs/shops.hpp" -#include "configs/achievements.hpp" +#include "configs/items.h" +#include "configs/loot.h" +#include "configs/harvestables.h" +#include "configs/npcs.h" +#include "configs/shops.h" +#include "configs/achievements.h" struct AssetPath { diff --git a/src/configs/achievements.cpp b/src/configs/achievements.cpp index a46b7c2..8d70207 100644 --- a/src/configs/achievements.cpp +++ b/src/configs/achievements.cpp @@ -1,4 +1,4 @@ -#include "configs/achievements.hpp" +#include "configs/achievements.h" #include "project_parser.h" #include "helpers.hpp" #include diff --git a/src/configs/harvestables.cpp b/src/configs/harvestables.cpp index aeac60c..274343d 100644 --- a/src/configs/harvestables.cpp +++ b/src/configs/harvestables.cpp @@ -1,4 +1,4 @@ -#include "configs/harvestables.hpp" +#include "configs/harvestables.h" #include "project_parser.h" #include "helpers.hpp" #include diff --git a/src/configs/items.cpp b/src/configs/items.cpp index 4826ecf..a61d3cb 100644 --- a/src/configs/items.cpp +++ b/src/configs/items.cpp @@ -1,4 +1,4 @@ -#include "configs/items.hpp" +#include "configs/items.h" #include "project_parser.h" #include "helpers.hpp" #include diff --git a/src/configs/loot.cpp b/src/configs/loot.cpp index 2550e94..f1b6386 100644 --- a/src/configs/loot.cpp +++ b/src/configs/loot.cpp @@ -1,4 +1,4 @@ -#include "configs/loot.hpp" +#include "configs/loot.h" #include "project_parser.h" #include diff --git a/src/configs/npcs.cpp b/src/configs/npcs.cpp index c067eba..c3ae128 100644 --- a/src/configs/npcs.cpp +++ b/src/configs/npcs.cpp @@ -1,4 +1,4 @@ -#include "configs/npcs.hpp" +#include "configs/npcs.h" #include "project_parser.h" #include "helpers.hpp" #include diff --git a/src/configs/shops.cpp b/src/configs/shops.cpp index 706dcc8..a894d28 100644 --- a/src/configs/shops.cpp +++ b/src/configs/shops.cpp @@ -1,4 +1,4 @@ -#include "configs/shops.hpp" +#include "configs/shops.h" #include "project_parser.h" #include diff --git a/src/helpers.cpp b/src/helpers.cpp index 067831b..9033b79 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -195,4 +195,187 @@ ActionType stringToActionType(const std::string& str) { return (it != actionMap.end()) ? it->second : ActionType::none; } +// Enum to string conversions +std::string statTypeToString(StatType type) { + switch (type) { + case StatType::damagePhysical: return "damagephysical"; + case StatType::damageMagical: return "damagemagical"; + case StatType::damageRanged: return "damageranged"; + case StatType::accuracyPhysical: return "accuracyphysical"; + case StatType::accuracyMagical: return "accuracymagical"; + case StatType::accuracyRanged: return "accuracyranged"; + case StatType::resistancePhysical: return "resistancephysical"; + case StatType::resistanceMagical: return "resistancemagical"; + case StatType::resistanceRanged: return "resistanceranged"; + case StatType::health: return "health"; + case StatType::mana: return "mana"; + case StatType::manaregen: return "manaregen"; + case StatType::healthregen: return "healthregen"; + case StatType::movementSpeed: return "movementSpeed"; + case StatType::power: return "power"; + case StatType::critical: return "critical"; + case StatType::healing: return "healing"; + case StatType::DamageVsUndead: return "DamageVsUndead"; + case StatType::DamageVsBeasts: return "DamageVsBeasts"; + case StatType::CritterSlaying: return "CritterSlaying"; + case StatType::harvestingSpeedWoodcutting: return "harvestingSpeedWoodcutting"; + case StatType::none: return "none"; + default: return "none"; + } +} + +std::string itemCategoryToString(ItemCategory category) { + switch (category) { + case ItemCategory::bone: return "bone"; + case ItemCategory::bow: return "bow"; + case ItemCategory::crossbow: return "crossbow"; + case ItemCategory::constructable: return "constructable"; + case ItemCategory::torch: return "torch"; + case ItemCategory::blacksmithhammer: return "blacksmithhammer"; + case ItemCategory::questitem: return "questitem"; + case ItemCategory::heavyArmor: return "heavyArmor"; + case ItemCategory::warhammer: return "warhammer"; + case ItemCategory::shield: return "shield"; + case ItemCategory::hatchet: return "hatchet"; + case ItemCategory::blade: return "blade"; + case ItemCategory::armor: return "armor"; + case ItemCategory::pickaxe: return "pickaxe"; + case ItemCategory::fish: return "fish"; + case ItemCategory::fishingrod: return "fishingrod"; + case ItemCategory::shears: return "shears"; + case ItemCategory::hammer: return "hammer"; + case ItemCategory::battleaxe: return "battleaxe"; + case ItemCategory::morningstar: return "morningstar"; + case ItemCategory::wand: return "wand"; + case ItemCategory::staff: return "staff"; + case ItemCategory::dagger: return "dagger"; + case ItemCategory::none: return "none"; + default: return "none"; + } +} + +std::string itemTypeToString(ItemType type) { + switch (type) { + case ItemType::weapon: return "weapon"; + case ItemType::shield: return "shield"; + case ItemType::armor: return "armor"; + case ItemType::head: return "head"; + case ItemType::resource: return "resource"; + case ItemType::consumable: return "consumable"; + case ItemType::trinket: return "trinket"; + case ItemType::bracelet: return "bracelet"; + default: return "resource"; + } +} + +std::string toolToString(Tool tool) { + switch (tool) { + case Tool::hatchet: return "hatchet"; + case Tool::pickaxe: return "pickaxe"; + case Tool::broom: return "broom"; + case Tool::fishingrod: return "fishingrod"; + case Tool::none: return "none"; + default: return "none"; + } +} + +std::string skillTypeToString(SkillType skill) { + switch (skill) { + case SkillType::woodcutting: return "woodcutting"; + case SkillType::fishing: return "fishing"; + case SkillType::swordsmanship: return "swordsmanship"; + case SkillType::mining: return "mining"; + case SkillType::archery: return "archery"; + case SkillType::magic: return "magic"; + case SkillType::defence: return "defence"; + case SkillType::blacksmithy: return "blacksmithy"; + case SkillType::tailoring: return "tailoring"; + case SkillType::carpentry: return "carpentry"; + case SkillType::alchemy: return "alchemy"; + case SkillType::cooking: return "cooking"; + case SkillType::none: return "none"; + default: return "none"; + } +} + +std::string workbenchTypeToString(WorkbenchType workbench) { + switch (workbench) { + case WorkbenchType::none: return "none"; + case WorkbenchType::anvil: return "anvil"; + case WorkbenchType::oven: return "oven"; + case WorkbenchType::cooking: return "cooking"; + case WorkbenchType::carpenter: return "carpenter"; + case WorkbenchType::tailor: return "tailor"; + case WorkbenchType::forge: return "forge"; + case WorkbenchType::alchemist: return "alchemist"; + case WorkbenchType::mystic: return "mystic"; + default: return "none"; + } +} + +std::string genstatTypeToString(GenstatType genstat) { + switch (genstat) { + case GenstatType::dagger: return "dagger"; + case GenstatType::broadsword: return "broadsword"; + case GenstatType::battleaxe: return "battleaxe"; + case GenstatType::greatsword: return "greatsword"; + case GenstatType::morningstar: return "morningstar"; + case GenstatType::hammer: return "hammer"; + case GenstatType::spear: return "spear"; + case GenstatType::bow: return "bow"; + case GenstatType::staff: return "staff"; + case GenstatType::wand: return "wand"; + case GenstatType::crossbow: return "crossbow"; + case GenstatType::woodenshield: return "woodenshield"; + case GenstatType::wizardhat: return "wizardhat"; + case GenstatType::wizardrobe: return "wizardrobe"; + case GenstatType::grandwizardhat: return "grandwizardhat"; + case GenstatType::grandwizardrobe: return "grandwizardrobe"; + case GenstatType::leatherhood: return "leatherhood"; + case GenstatType::leatherbracelet: return "leatherbracelet"; + case GenstatType::leatherarmor: return "leatherarmor"; + case GenstatType::studdedleatherhood: return "studdedleatherhood"; + case GenstatType::studdedleatherbracelet: return "studdedleatherbracelet"; + case GenstatType::studdedleatherarmor: return "studdedleatherarmor"; + case GenstatType::helmet: return "helmet"; + case GenstatType::shield: return "shield"; + case GenstatType::armor: return "armor"; + case GenstatType::platehelmet: return "platehelmet"; + case GenstatType::kiteshield: return "kiteshield"; + case GenstatType::platearmor: return "platearmor"; + case GenstatType::none: return "none"; + default: return "none"; + } +} + +std::string actionTypeToString(ActionType action) { + switch (action) { + case ActionType::NpcDeath: return "NpcDeath"; + case ActionType::PlayerDeath: return "PlayerDeath"; + case ActionType::PlayerRespawn: return "PlayerRespawn"; + case ActionType::NpcInteract: return "NpcInteract"; + case ActionType::QuestUpdate: return "QuestUpdate"; + case ActionType::QuestTimerEnd: return "QuestTimerEnd"; + case ActionType::UseItemOnItem: return "UseItemOnItem"; + case ActionType::UseItemOnNpc: return "UseItemOnNpc"; + case ActionType::ConsumeItem: return "ConsumeItem"; + case ActionType::NpcCombatInteract: return "NpcCombatInteract"; + case ActionType::NpcKilledByPlayer: return "NpcKilledByPlayer"; + case ActionType::EnterMap: return "EnterMap"; + case ActionType::VarUpdated: return "VarUpdated"; + case ActionType::GrantAchievement: return "GrantAchievement"; + case ActionType::PlayerKilledByNpc: return "PlayerKilledByNpc"; + case ActionType::UseItem: return "UseItem"; + case ActionType::CraftItem: return "CraftItem"; + case ActionType::HarvestItem: return "HarvestItem"; + case ActionType::BuyItem: return "BuyItem"; + case ActionType::NpcTagKilledByPlayer: return "NpcTagKilledByPlayer"; + case ActionType::UseAbility: return "UseAbility"; + case ActionType::LootItem: return "LootItem"; + case ActionType::UseItemCategoryOnItem: return "UseItemCategoryOnItem"; + case ActionType::none: return "none"; + default: return "none"; + } +} + } // namespace cursebreaker \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 38e1698..a7af5a7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ #include "project_parser.h" #include "tree_builder.h" #include "assets/scene.hpp" -#include "configs/items.hpp" +#include "configs/items.h" using namespace cursebreaker; diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 2e139b3..8b509df 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -27,8 +27,9 @@ #include "assets/game_object.hpp" #include "assets/transform.hpp" #include "assets/mesh_filter.hpp" -#include "assets/prefab_instance.hpp" - +#include "assets/prefab_instance.hpp" +#include "helpers.hpp" + namespace cursebreaker { constexpr uint32_t fnv1a_hash(const char* str, uint32_t hash = 2166136261u) @@ -461,7 +462,4 @@ void ParseProject(const std::filesystem::path& projectRoot) project.m_prefabAssets = ParsePrefabs(std::vector(prefabFiles.begin(), prefabFiles.end()), project.m_prefabsMap); project.m_sceneAssets = ParseScenes(std::vector(tilesFiles.begin(), tilesFiles.end())); -} - - -} // namespace cursebreaker +} \ No newline at end of file