mirror of
https://github.com/EQEmu/Server.git
synced 2026-11-29 14:32:17 +00:00
[FIX] Fix for world crash with over 1500 guilds (#4299)
* Fix for world crash with over 1500 guilds There was an existing issue with certain clients (RoF2) if there were more than 1500 guilds. This also enhances the loading of guilds in both world and zone for performance if there are large number of guilds as RoF2 will support 1500+ guilds. * Safely access permissions map --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
1 parent
257935d33a
commit
d1c7e45437
14 files changed
+210
-136
No files matched your search
@@ -45,6 +45,31 @@ public:
|
||||
|
||||
// Custom extended repository methods here
|
||||
|
||||
static std::map<std::string, GuildPermissions> LoadAll(Database &db)
|
||||
{
|
||||
std::map<std::string, GuildPermissions> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE `guild_id` < {}",
|
||||
BaseSelect(),
|
||||
RoF2::constants::MAX_GUILD_ID
|
||||
));
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
GuildPermissions e{};
|
||||
|
||||
e.id = static_cast<int32_t>(atoi(row[0]));
|
||||
e.perm_id = static_cast<int32_t>(atoi(row[1]));
|
||||
e.guild_id = static_cast<int32_t>(atoi(row[2]));
|
||||
e.permission = static_cast<int32_t>(atoi(row[3]));
|
||||
|
||||
auto key = fmt::format("{}-{}", e.guild_id, e.perm_id);
|
||||
all_entries.emplace(key, e);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_GUILD_PERMISSIONS_REPOSITORY_H
|
||||
@@ -60,6 +60,30 @@ public:
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static std::map<std::string, std::string> LoadAll(Database &db)
|
||||
{
|
||||
std::map<std::string, std::string> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(fmt::format(
|
||||
"{} WHERE `guild_id` < {}",
|
||||
BaseSelect(),
|
||||
RoF2::constants::MAX_GUILD_ID)
|
||||
);
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
GuildRanks e{};
|
||||
|
||||
e.guild_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.rank_ = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.title = row[2] ? row[2] : "";
|
||||
|
||||
auto key = fmt::format("{}-{}", e.guild_id, e.rank_);
|
||||
all_entries.emplace(key, e.title);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_GUILD_RANKS_REPOSITORY_H
|
||||
Reference in new issue
Block a user