Skip to content

Commit

Permalink
* Clear code and add missing GUILDLEVEL_MEMBER
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Jan 6, 2025
1 parent 05e89f3 commit 7403ee2
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 74 deletions.
2 changes: 1 addition & 1 deletion src/creatures/interactions/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ bool Chat::talkToChannel(const std::shared_ptr<Player> &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;
Expand Down
68 changes: 0 additions & 68 deletions src/io/ioguild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,63 +65,6 @@ uint32_t IOGuild::getGuildIdByName(const std::string &name) {
return result->getNumber<uint32_t>("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<uint32_t>("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";
Expand All @@ -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;
}
5 changes: 0 additions & 5 deletions src/io/ioguild.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,5 @@ class IOGuild {
static std::shared_ptr<Guild> loadGuild(uint32_t guildId);
static void saveGuild(const std::shared_ptr<Guild> &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);
};

0 comments on commit 7403ee2

Please sign in to comment.