mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Bug Fix] Update FreeGuildID Routine (#4143)
Updates the routine to determine a free guild id on guild creation
This commit is contained in:
parent
c4613e1b0f
commit
398ecbc8cf
@ -342,41 +342,14 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 BaseGuildManager::_GetFreeGuildID()
|
||||
{
|
||||
GuildsRepository::DeleteWhere(*m_db, "`name` = ''");
|
||||
|
||||
GuildsRepository::Guilds out;
|
||||
out.id = 0;
|
||||
out.leader = 0;
|
||||
out.minstatus = 0;
|
||||
out.tribute = 0;
|
||||
out.name = "";
|
||||
out.motd = "";
|
||||
out.motd_setter = "";
|
||||
out.url = "";
|
||||
out.channel = "";
|
||||
auto last_insert_id = GuildsRepository::InsertOne(*m_db, out);
|
||||
if (last_insert_id.id > 0) {
|
||||
LogGuilds("Located a free guild ID [{}] in the database", last_insert_id.id);
|
||||
return last_insert_id.id;
|
||||
}
|
||||
|
||||
LogGuilds("Unable to find a free guild ID in the database");
|
||||
return GUILD_NONE;
|
||||
}
|
||||
|
||||
uint32 BaseGuildManager::CreateGuild(std::string name, uint32 leader_char_id)
|
||||
{
|
||||
uint32 guild_id = UpdateDbCreateGuild(name, leader_char_id);
|
||||
if (guild_id == GUILD_NONE) {
|
||||
return (GUILD_NONE);
|
||||
}
|
||||
//RefreshGuild(guild_id);
|
||||
//SendGuildRefresh(guild_id, true, false, false, false);
|
||||
//SendCharRefresh(GUILD_NONE, guild_id, leader_char_id);
|
||||
uint32 guild_id = UpdateDbCreateGuild(name, leader_char_id);
|
||||
if (guild_id == GUILD_NONE) {
|
||||
return (GUILD_NONE);
|
||||
}
|
||||
|
||||
return guild_id;
|
||||
return guild_id;
|
||||
}
|
||||
|
||||
bool BaseGuildManager::DeleteGuild(uint32 guild_id)
|
||||
@ -539,8 +512,8 @@ bool BaseGuildManager::SetPublicNote(uint32 charid, std::string public_note)
|
||||
|
||||
uint32 BaseGuildManager::UpdateDbCreateGuild(std::string name, uint32 leader)
|
||||
{
|
||||
auto new_id = _GetFreeGuildID();
|
||||
if (new_id == GUILD_NONE) {
|
||||
auto new_id = GuildsRepository::GetMaxId(*m_db) + 1;
|
||||
if (!new_id) {
|
||||
return GUILD_NONE;
|
||||
}
|
||||
|
||||
|
||||
@ -208,7 +208,6 @@ class BaseGuildManager
|
||||
|
||||
bool _StoreGuildDB(uint32 guild_id);
|
||||
GuildInfo* _CreateGuild(uint32 guild_id, std::string guild_name, uint32 leader_char_id, uint8 minstatus, std::string guild_motd, std::string motd_setter, std::string Channel, std::string URL, uint32 favour);
|
||||
uint32 _GetFreeGuildID();
|
||||
GuildsRepository::Guilds CreateGuildRepoFromGuildInfo(uint32 guild_id, BaseGuildManager::GuildInfo& in);
|
||||
};
|
||||
#endif /*GUILD_BASE_H_*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user