From 7403ee2e4619322be0809b18b8a81505790d1c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Mon, 6 Jan 2025 05:36:16 -0300 Subject: [PATCH] * Clear code and add missing GUILDLEVEL_MEMBER --- src/creatures/interactions/chat.cpp | 2 +- src/io/ioguild.cpp | 68 ----------------------------- src/io/ioguild.hpp | 5 --- 3 files changed, 1 insertion(+), 74 deletions(-) diff --git a/src/creatures/interactions/chat.cpp b/src/creatures/interactions/chat.cpp index 256d1549..7fa23335 100644 --- a/src/creatures/interactions/chat.cpp +++ b/src/creatures/interactions/chat.cpp @@ -582,7 +582,7 @@ bool Chat::talkToChannel(const std::shared_ptr &player, SpeakClasses typ if (channelId == CHANNEL_GUILD) { const auto &rank = player->getGuildRank(); - if (rank && rank->level > 1) { + if (rank && rank->level > GUILDLEVEL_MEMBER) { type = TALKTYPE_CHANNEL_O; } else if (type != TALKTYPE_CHANNEL_Y) { type = TALKTYPE_CHANNEL_Y; diff --git a/src/io/ioguild.cpp b/src/io/ioguild.cpp index 1fad260a..4c58e235 100644 --- a/src/io/ioguild.cpp +++ b/src/io/ioguild.cpp @@ -65,63 +65,6 @@ uint32_t IOGuild::getGuildIdByName(const std::string &name) { return result->getNumber("id"); } -std::string IOGuild::getGuildNameById(uint32_t id) { - Database &db = Database::getInstance(); - - std::ostringstream query; - query << "SELECT `name` FROM `guilds` WHERE `id` = " << id; - - DBResult_ptr result = db.storeQuery(query.str()); - if (!result) { - return ""; - } - - return result->getString("name"); -} - -uint32_t IOGuild::getRankIdByGuildIdAndLevel(uint32_t guildId, uint32_t guildLevel) { - Database &db = Database::getInstance(); - - std::ostringstream query; - query << "SELECT `id` FROM `guild_ranks` WHERE `level` = " << guildLevel - << " AND `guild_id` = " << guildId << " LIMIT 1;"; - - DBResult_ptr result = db.storeQuery(query.str()); - if (!result) { - return 0; - } - - return result->getNumber("id"); -} - -std::string IOGuild::getRankName(int16_t guildLevel, uint32_t guildId) { - Database &db = Database::getInstance(); - - std::ostringstream query; - query << "SELECT `name` FROM `guild_ranks` WHERE `guild_id` = " << guildId - << " AND `level` = " << guildLevel << " LIMIT 1;"; - - DBResult_ptr result = db.storeQuery(query.str()); - if (!result) { - return ""; - } - - return result->getString("name"); -} - -bool IOGuild::rankNameExists(const std::string &rankName, uint32_t guildId) { - Database &db = Database::getInstance(); - - std::ostringstream query; - query << "SELECT `name` FROM `guild_ranks` WHERE `guild_id` = " << guildId - << " AND `name` = " - << "'" << db.escapeString(rankName) << "'" - << " LIMIT 1;"; - - DBResult_ptr result = db.storeQuery(query.str()); - return result != nullptr; -} - void IOGuild::getWarList(uint32_t guildId, GuildWarVector &guildWarVector) { std::ostringstream query; query << "SELECT `guild1`, `guild2` FROM `guild_wars` WHERE (`guild1` = " << guildId << " OR `guild2` = " << guildId << ") AND `status` = 1"; @@ -140,14 +83,3 @@ void IOGuild::getWarList(uint32_t guildId, GuildWarVector &guildWarVector) { } } while (result->next()); } - -bool IOGuild::guildExists(uint32_t guildId) { - Database &db = Database::getInstance(); - std::ostringstream query; - query << "SELECT `id` FROM `guilds` WHERE `id` = " << guildId << " LIMIT 1;"; - if (DBResult_ptr result = db.storeQuery(query.str())) { - return true; - } - - return false; -} diff --git a/src/io/ioguild.hpp b/src/io/ioguild.hpp index ed877541..20a3eed8 100644 --- a/src/io/ioguild.hpp +++ b/src/io/ioguild.hpp @@ -25,10 +25,5 @@ class IOGuild { static std::shared_ptr loadGuild(uint32_t guildId); static void saveGuild(const std::shared_ptr &guild); static uint32_t getGuildIdByName(const std::string &name); - static std::string getGuildNameById(uint32_t id); - static uint32_t getRankIdByGuildIdAndLevel(uint32_t guildId, uint32_t guildLevel); - static std::string getRankName(int16_t guildLevel, uint32_t guildId); - static bool rankNameExists(const std::string &rankName, uint32_t guildId); static void getWarList(uint32_t guildId, GuildWarVector &guildWarVector); - static bool guildExists(uint32_t guildId); };