Skip to content

Commit

Permalink
fix guild
Browse files Browse the repository at this point in the history
  • Loading branch information
hatersgit committed Mar 8, 2024
1 parent e42ff16 commit 4870ae3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 41 deletions.
6 changes: 6 additions & 0 deletions modules/mod-Forge/src/ForgePlayerMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class ForgePlayerMessageHandler : public PlayerScript

}

void OnFirstLogin(Player* player) override {
if (sConfigMgr->GetBoolDefault("StarterGuild.autojoin", false))
if (Guild* guild = sGuildMgr->GetGuildById(sConfigMgr->GetIntDefault("StarterGuild.id", 0)))
guild->AddMember(player->GetGUID());
}

void OnLogin(Player* player) override
{
if (!player)
Expand Down
5 changes: 0 additions & 5 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,6 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
}
// all item positions resolved
UpdateThorns();
if (sConfigMgr->GetBoolDefault("StarterGuild.autojoin", false)) {
if (Guild* guild = sGuildMgr->GetGuildById(sConfigMgr->GetIntDefault("StarterGuild.id", 0))) {
guild->AddMemberOnCreate(this);
}
}

CheckAllAchievementCriteria();

Expand Down
35 changes: 0 additions & 35 deletions src/server/game/Guilds/Guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2163,41 +2163,6 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max
session->SendPacket(&data);
}

bool Guild::AddMemberOnCreate(Player* ply) {
auto guid = ply->GetGUID();
auto lowguid = guid.GetCounter();
auto rankId = _GetLowestRankId();

auto [memberIt, isNew] = m_members.try_emplace(lowguid, m_id, guid, rankId);
if (!isNew)
{
LOG_ERROR("guild", "Tried to add {} to guild '{}'. Member already exists? How did that happen?", guid.ToString(), m_name);
return false;
}

Member& member = memberIt->second;
std::string name;

ply->SetInGuild(m_id);
ply->SetGuildIdInvited(0);
ply->SetRank(rankId);
member.SetStats(ply);
SendLoginInfo(ply->GetSession());
name = ply->GetName();

CharacterDatabaseTransaction trans(nullptr);
member.SaveToDB(trans);

_UpdateAccountsNumber();
_LogEvent(GUILD_EVENT_LOG_JOIN_GUILD, guid);
_BroadcastEvent(GE_JOINED, guid, name);

// Call scripts if member was succesfully added (and stored to database)
sScriptMgr->OnGuildAddMember(this, ply, rankId);

return true;
}

// Members handling
bool Guild::AddMember(ObjectGuid guid, uint8 rankId)
{
Expand Down
1 change: 0 additions & 1 deletion src/server/game/Guilds/Guild.h
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,6 @@ class Guild

// Members
// Adds member to guild. If rankId == GUILD_RANK_NONE, lowest rank is assigned.
bool AddMemberOnCreate(Player* ply);
bool AddMember(ObjectGuid guid, uint8 rankId = GUILD_RANK_NONE);
void DeleteMember(ObjectGuid guid, bool isDisbanding = false, bool isKicked = false, bool canDeleteGuild = false);
bool ChangeMemberRank(ObjectGuid guid, uint8 newRank);
Expand Down

0 comments on commit 4870ae3

Please sign in to comment.