コード例 #1
0
void Guild::SetMOTD(const char * szNewMotd, WorldSession * pClient)
{
	if(pClient->GetPlayer()->m_playerInfo->guild != this)
		return;

	if(!pClient->GetPlayer()->m_playerInfo->guildRank->CanPerformCommand(GR_RIGHT_SETMOTD))
	{
		Guild::SendGuildCommandResult(pClient, GUILD_INVITE_S, "", GUILD_PERMISSIONS);
		return;
	}

	if(m_motd)
		free(m_motd);

	if(strlen(szNewMotd))
	{
		m_motd = strdup(szNewMotd);
		CharacterDatabase.Execute("UPDATE guilds SET motd = \"%s\" WHERE guildId = %u", CharacterDatabase.EscapeString(string(szNewMotd)).c_str(), m_guildId);
	}
	else
	{
		m_motd= NULL;
		CharacterDatabase.Execute("UPDATE guilds SET motd = \"\" WHERE guildId = %u", m_guildId);
	}

	LogGuildEvent(GUILD_EVENT_MOTD, 1, szNewMotd);
}
コード例 #2
0
ファイル: Guild.cpp プロジェクト: Desch/Edge-of-Chaos
bool Guild::SetRankOfMember(PlayerInfo* pMember, uint32 rank)
{
	if(rank > MAX_GUILD_RANKS)
		return false;
	GuildRank* newRank = m_ranks[rank];

	if(newRank == NULL)
		return false;

	GuildMemberMap::iterator itr = m_members.find(pMember);
	if(itr == m_members.end())
		return false;

	if(rank == 0)
		SetGuildMaster(pMember);

	itr->second->pRank = newRank;
	itr->second->pPlayer->guildRank = newRank;

	// log it
	LogGuildEvent(GUILD_EVENT_PROMOTION, 3, pMember->name, pMember->name, newRank->szRankName);
	AddGuildLogEntry(GUILD_LOG_EVENT_PROMOTION, 3, pMember->guid, pMember->guid, newRank->iId);

	// update in the database
	CharacterDatabase.Execute("UPDATE guild_data SET guildRank = %u WHERE playerid = %u AND guildid = %u", newRank->iId, pMember->guid, m_guildId);

	// if the player is online, update his guildrank
	if(pMember->m_loggedInPlayer)
		pMember->m_loggedInPlayer->SetGuildRank(newRank->iId);
	return true;
}
コード例 #3
0
ファイル: Guild.cpp プロジェクト: Desch/Edge-of-Chaos
void Guild::SetMOTD(const char* szNewMotd, WorldSession* pClient)
{
	if(pClient->GetPlayer()->getPlayerInfo()->guild != this)
		return;

	if(szNewMotd == NULL || szNewMotd == "")
		szNewMotd = "Click here to set a message of the day.";

	if(!pClient->GetPlayer()->getPlayerInfo()->guildRank->CanPerformCommand(GR_RIGHT_SETMOTD))
	{
		Guild::SendGuildCommandResult(pClient, GUILD_INVITE_S, "", GUILD_PERMISSIONS);
		return;
	}


	if(m_motd)
	//	free(m_motd); // this causes a server crash
		m_motd = "";

	if(strlen(szNewMotd))
	{
		m_motd = strdup(szNewMotd);
		if (strlen(m_motd) == 0)
			m_motd = "Click here to set a message of the day.";
		CharacterDatabase.Execute("UPDATE guilds SET motd = \'%s\' WHERE guildId = %u", CharacterDatabase.EscapeString(string(szNewMotd)).c_str(), m_guildId);
	}
	else
	{
		m_motd = "Click here to set a message of the day.";
		CharacterDatabase.Execute("UPDATE guilds SET motd = \'\' WHERE guildId = %u", m_guildId);
	}

	LogGuildEvent(GUILD_EVENT_MOTD, 1, szNewMotd);
}
コード例 #4
0
void Guild::RemoveGuildMember(PlayerInfo * pMember, WorldSession * pClient)
{
	if(pMember->guild != this)
		return;

	if(pClient && pClient->GetPlayer()->m_playerInfo->guild != this)
		return;

	if(pClient && !pClient->GetPlayer()->m_playerInfo->guildRank->CanPerformCommand(GR_RIGHT_REMOVE) && pClient->GetPlayer()->m_playerInfo != pMember)
	{
		Guild::SendGuildCommandResult(pClient, GUILD_CREATE_S, "", GUILD_PERMISSIONS);
		return;
	}

	if(pMember->guildRank->iId==0)
	{
		if(pClient)
			pClient->SystemMessage("You cannot remove the guild master.");

		return;
	}

	CharacterDatabase.Execute("DELETE FROM guild_data WHERE playerid = %u", pMember->guid);

	m_lock.Acquire();
	GuildMemberMap::iterator itr = m_members.find(pMember);
	if(itr != m_members.end())
	{
		// this should always exist.
		if(itr->second->szOfficerNote)
			free((void*)itr->second->szOfficerNote);
		if(itr->second->szPublicNote)
			free((void*)itr->second->szPublicNote);

		delete itr->second;
		m_members.erase(itr);
	}

	LogGuildEvent(GUILD_EVENT_LEFT, 1, pMember->name);
	if(pClient && pClient->GetPlayer()->m_playerInfo != pMember)
	{
		AddGuildLogEntry(GUILD_LOG_EVENT_REMOVAL, 2, pClient->GetPlayer()->GetLowGUID(), pMember->guid);
	}
	else
	{
		AddGuildLogEntry(GUILD_LOG_EVENT_LEFT, 1, pMember->guid);
	}

	m_lock.Release();

	pMember->guildRank=NULL;
	pMember->guild=NULL;
	pMember->guildMember=NULL;

	if(pMember->m_loggedInPlayer)
	{
		pMember->m_loggedInPlayer->SetGuildRank(0);
		pMember->m_loggedInPlayer->SetGuildId(0);
	}
}
コード例 #5
0
ファイル: Guild.cpp プロジェクト: Antares84/arcemu
void Guild::DemoteGuildMember(PlayerInfo* pMember, WorldSession* pClient)
{
	if(pClient->GetPlayer()->getPlayerInfo()->guild != this || pMember->guild != this)
		return;

	if(!pClient->GetPlayer()->getPlayerInfo()->guildRank->CanPerformCommand(GR_RIGHT_DEMOTE) ||
	        pMember->guid == GetGuildLeader() ||
	        pClient->GetPlayer()->getPlayerInfo()->guildRank->iId >= pMember->guildRank->iId)
	{
		SendGuildCommandResult(pClient, GUILD_PROMOTE_S, "", GUILD_PERMISSIONS);
		return;
	}

	// find the next highest rank
	uint32 nh = pMember->guildRank->iId + 1;
	GuildRank* newRank = NULL;

	m_lock.Acquire();
	while(nh < 10 && newRank == NULL)
	{
		newRank = m_ranks[nh];
		++nh;
	}

	if(newRank == NULL)
	{
		m_lock.Release();
		pClient->SystemMessage("Could not find a rank to demote this member to.");
		return;
	}

	GuildMemberMap::iterator itr = m_members.find(pMember);
	if(itr == m_members.end())
	{
		// shouldn't happen
		m_lock.Release();
		return;
	}

	itr->second->pRank = newRank;
	itr->second->pPlayer->guildRank = newRank;

	// log it
	LogGuildEvent(GUILD_EVENT_DEMOTION, 3, pClient->GetPlayer()->GetName(), pMember->name, newRank->szRankName);
	AddGuildLogEntry(GUILD_LOG_EVENT_DEMOTION, 3, pClient->GetPlayer()->GetLowGUID(), pMember->guid, newRank->iId);

	// update in the database
	CharacterDatabase.Execute("UPDATE guild_data SET guildRank = %u WHERE playerid = %u AND guildid = %u", newRank->iId, pMember->guid, m_guildId);

	// if the player is online, update his guildrank
	if(pMember->m_loggedInPlayer)
		pMember->m_loggedInPlayer->SetGuildRank(newRank->iId);

	// release lock
	m_lock.Release();
}
コード例 #6
0
ファイル: Guild.cpp プロジェクト: Desch/Edge-of-Chaos
// adding a member
void Guild::AddGuildMember(PlayerInfo* pMember, WorldSession* pClient, int32 ForcedRank /* = -1 */)
{

	//we don't need useless paranoia checks.
	if(pMember->guild != NULL)
		return;

	m_lock.Acquire();
	GuildRank* r;
	if(m_members.size())
	{
		if(ForcedRank > 0) r = m_ranks[ForcedRank];
		else if(ForcedRank == -2) r = FindHighestRank();
		else r = FindLowestRank();
	}
	else
	{
		if(ForcedRank >= 0) r = m_ranks[ForcedRank];
		else if(ForcedRank == -2) r = FindHighestRank();
		else r = FindLowestRank();
	}

	if(r == NULL)
		r = FindLowestRank();

	if(r == NULL)
	{
		// shouldn't happen
		m_lock.Release();
		return;
	}

	GuildMember* pm = new GuildMember;
	memset(pm, 0, sizeof(GuildMember));
	pm->pPlayer = pMember;
	pm->pRank = r;
	pm->szOfficerNote = pm->szPublicNote = NULL;
	m_members.insert(make_pair(pMember, pm));

	pMember->guild = this;
	pMember->guildRank = r;
	pMember->guildMember = pm;

	if(pMember->m_loggedInPlayer)
	{
		pMember->m_loggedInPlayer->SetGuildId(m_guildId);
		pMember->m_loggedInPlayer->SetGuildRank(r->iId);
		pMember->m_loggedInPlayer->SendGuildMOTD();
	}

	CharacterDatabase.Execute("INSERT INTO guild_data VALUES(%u, %u, %u, '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", m_guildId, pMember->guid, r->iId);
	LogGuildEvent(GUILD_EVENT_JOINED, 1, pMember->name);
	AddGuildLogEntry(GUILD_LOG_EVENT_JOIN, 1, pMember->guid);
	m_lock.Release();
}
コード例 #7
0
ファイル: Guild.cpp プロジェクト: Nupper/AscEmu_Vanilla
void Guild::WithdrawMoney(WorldSession * pClient, uint32 uAmount)
{
    GuildMember * pMember = pClient->GetPlayer()->m_playerInfo->guildMember;
    if (pMember == NULL)
        return;

    // sanity checks
    if (pMember->pRank->iGoldLimitPerDay > 0)
    {
        if (pMember->CalculateAvailableAmount() < uAmount)
        {
            pClient->SystemMessage("You have already withdrawn too much today.");
            return;
        }
    }

    if (pMember->pRank->iGoldLimitPerDay == 0)
    {
        pClient->SystemMessage("You don't have permission to do that.");
        return;
    }

    if (m_bankBalance < uAmount)
        return;

    if (sWorld.GoldCapEnabled)
    {
        if ((pClient->GetPlayer()->GetUInt32Value(PLAYER_FIELD_COINAGE) + uAmount) > sWorld.GoldLimit)
        {
            pClient->GetPlayer()->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_TOO_MUCH_GOLD);
            return;
        }
    }

    // update his bank state
    pMember->OnMoneyWithdraw(uAmount);

    // give the gold! GM PLS GOLD PLS 1 COIN
    pClient->GetPlayer()->ModUnsigned32Value(PLAYER_FIELD_COINAGE, (uint32)uAmount);

    // subtract the balance
    m_bankBalance -= uAmount;

    // update in db
    CharacterDatabase.Execute("UPDATE guilds SET bankBalance = %u WHERE guildId = %u", (m_bankBalance > 0) ? m_bankBalance : 0, m_guildId);

    // notify everyone with the new balance
    char buf[20];
    snprintf(buf, 20, I64FMT, (uint64)m_bankBalance);
    LogGuildEvent(GUILD_EVENT_SETNEWBALANCE, 1, buf);

    // log it!
    LogGuildBankActionMoney(GUILD_BANK_LOG_EVENT_WITHDRAW_MONEY, pClient->GetPlayer()->GetLowGUID(), uAmount);
}
コード例 #8
0
ファイル: Guild.cpp プロジェクト: Antares84/arcemu
void Guild::SpendMoney(uint32 uAmount)
{
	// subtract the balance
	m_bankBalance -= uAmount;//check if(m_bankBalance >= uAmount) before calling this, thank you.

	// update in db
	CharacterDatabase.Execute("UPDATE guilds SET bankBalance = %llu WHERE guildId = %u", (m_bankBalance > 0) ? m_bankBalance : 0, m_guildId);

	// notify everyone with the new balance
	char buf[20];
	snprintf(buf, 20, I64FMT, m_bankBalance);
	LogGuildEvent(GUILD_EVENT_SETNEWBALANCE, 1, buf);
}
コード例 #9
0
void Guild::WithdrawMoney(WorldSession * pClient, uint32 uAmount)
{
	PlayerInfo * pPlayer = pClient->GetPlayer()->m_playerInfo;
	GuildMember * pMember = pClient->GetPlayer()->m_playerInfo->guildMember;
	if(pMember==NULL)
		return;

	if(uAmount == 0)
		return;

	if(m_bankBalance < uAmount)
	{
		pClient->SystemMessage("You cannot withdraw more money then the account holds.");
		return;
	}

	// sanity checks (execpt for guildmasters)
	if( pPlayer->guildRank->iId !=0 )
	{
		if(pMember->pRank->iGoldLimitPerDay > 0 && pMember->CalculateAvailableAmount() < uAmount )
		{
			pClient->SystemMessage("You have already withdrawn too much today.");
			return;
		}
		if(pMember->pRank->iGoldLimitPerDay == 0 )
		{
			pClient->SystemMessage("You don't have permission to withdraw money.");
			return;
		}
	}

	// update his bank state
	pMember->OnMoneyWithdraw(uAmount);

	// give the gold! GM PLS GOLD PLS 1 COIN
	pClient->GetPlayer()->ModUnsigned32Value(PLAYER_FIELD_COINAGE, (uint32)uAmount);

	// subtract the balance
	m_bankBalance -= uAmount;

	// update in db
	CharacterDatabase.Execute("UPDATE guilds SET bankBalance = %u WHERE guildId = %u", (m_bankBalance>0)?m_bankBalance:0, m_guildId);

	// notify everyone with the new balance
	char buf[20];
	snprintf(buf, 20, I64FMT, (long long unsigned int)m_bankBalance);
	LogGuildEvent(GUILD_EVENT_SETNEWBALANCE, 1, buf);

	// log it!
	LogGuildBankActionMoney(GUILD_BANK_LOG_EVENT_WITHDRAW_MONEY, pClient->GetPlayer()->GetLowGUID(), uAmount);
}
コード例 #10
0
ファイル: Guild.cpp プロジェクト: Desch/Edge-of-Chaos
void Guild::SetGuildMaster(PlayerInfo* pNewMaster)
{
	GuildMemberMap::iterator itr = m_members.find(pNewMaster);
	ARCEMU_ASSERT(m_ranks[0] != NULL);
	if(itr == m_members.end())
		return;

	itr->second->pRank = m_ranks[0];
	itr->first->guildRank = itr->second->pRank;
	CharacterDatabase.Execute("UPDATE guild_data SET guildRank = 0 WHERE playerid = %u AND guildid = %u", itr->first->guid, m_guildId);
	CharacterDatabase.Execute("UPDATE guilds SET leaderGuid = %u WHERE guildId = %u", itr->first->guid, m_guildId);
	m_guildLeader = itr->first->guid;
	LogGuildEvent(GUILD_EVENT_LEADER_CHANGED, 2, pNewMaster->name, pNewMaster->name);
}
コード例 #11
0
// adding a member
void Guild::AddGuildMember(PlayerInfo * pMember, WorldSession * pClient, int32 ForcedRank /* = -1 */)
{
	if(pMember->guild != NULL)
		return;

	if(pClient && pClient->GetPlayer()->m_playerInfo->guild != this)
		return;

	if(pClient && !pClient->GetPlayer()->m_playerInfo->guildRank->CanPerformCommand(GR_RIGHT_INVITE))
		return;

	m_lock.Acquire();
	GuildRank * r;
	if(m_members.size())
		r = (ForcedRank<=0) ? FindLowestRank() : m_ranks[ForcedRank];
	else
		r = (ForcedRank<0) ? FindLowestRank() : m_ranks[ForcedRank];

	if(r==NULL)
		r=FindLowestRank();

	if(r==NULL)
	{
		// shouldnt happen
		m_lock.Release();
		return;
	}

	GuildMember * pm = new GuildMember;
	memset(pm, 0, sizeof(GuildMember));
	pm->pPlayer = pMember;
	pm->pRank = r;
	pm->szOfficerNote = pm->szPublicNote = NULL;
	m_members.insert(make_pair(pMember, pm));

	pMember->guild=this;
	pMember->guildRank=r;
	pMember->guildMember=pm;

	if(pMember->m_loggedInPlayer)
	{
		pMember->m_loggedInPlayer->SetGuildId(m_guildId);
		pMember->m_loggedInPlayer->SetGuildRank(r->iId);
	}

	CharacterDatabase.Execute("INSERT INTO guild_data VALUES(%u, %u, %u, '', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)", m_guildId, pMember->guid, r->iId);
	LogGuildEvent(GUILD_EVENT_JOINED, 1, pMember->name);
	AddGuildLogEntry(GUILD_LOG_EVENT_JOIN, 1, pMember->guid);
	m_lock.Release();
}
コード例 #12
0
ファイル: Guild.cpp プロジェクト: Antares84/arcemu
void Guild::ChangeGuildMaster(PlayerInfo* pNewMaster, WorldSession* pClient)
{
	if(pClient->GetPlayer()->GetLowGUID() != m_guildLeader)
	{
		Guild::SendGuildCommandResult(pClient, GUILD_PROMOTE_S, "", GUILD_PERMISSIONS);
		return;
	}

	m_lock.Acquire();
	GuildRank* newRank = FindHighestRank();
	if(newRank == NULL)
	{
		m_lock.Release();
		return;
	}

	GuildMemberMap::iterator itr = m_members.find(pNewMaster);
	GuildMemberMap::iterator itr2 = m_members.find(pClient->GetPlayer()->getPlayerInfo());
	ARCEMU_ASSERT(m_ranks[0] != NULL);
	if(itr == m_members.end())
	{
		Guild::SendGuildCommandResult(pClient, GUILD_PROMOTE_S, pNewMaster->name, GUILD_PLAYER_NOT_IN_GUILD_S);
		m_lock.Release();
		return;
	}
	if(itr2 == m_members.end())
	{
		// wtf??
		Guild::SendGuildCommandResult(pClient, GUILD_PROMOTE_S, "", GUILD_INTERNAL);
		m_lock.Release();
		return;
	}

	itr->second->pRank = m_ranks[0];
	itr->first->guildRank = itr->second->pRank;
	itr2->second->pRank = newRank;
	itr2->first->guildRank = newRank;
	CharacterDatabase.Execute("UPDATE guild_data SET guildRank = 0 WHERE playerid = %u AND guildid = %u", itr->first->guid, m_guildId);
	CharacterDatabase.Execute("UPDATE guild_data SET guildRank = %u WHERE playerid = %u AND guildid = %u", newRank->iId, itr2->first->guid, m_guildId);
	CharacterDatabase.Execute("UPDATE guilds SET leaderGuid = %u WHERE guildId = %u", itr->first->guid, m_guildId);
	m_guildLeader = itr->first->guid;
	m_lock.Release();


	LogGuildEvent(GUILD_EVENT_LEADER_CHANGED, 2, pClient->GetPlayer()->GetName(), pNewMaster->name);
	//TODO: Figure out the GUILD_LOG_EVENT_LEADER_CHANGED code
}
コード例 #13
0
ファイル: Guild.cpp プロジェクト: Chero/abcwow
void Guild::DepositMoney(WorldSession * pClient, uint32 uAmount)
{
	if(pClient->GetPlayer()->GetUInt32Value(PLAYER_FIELD_COINAGE) < uAmount)
		return;

	// add to the bank balance
	m_bankBalance += uAmount;

	// update in db
	CharacterDatabase.Execute("UPDATE guilds SET bankBalance = %u WHERE guildId = %u", m_bankBalance, m_guildId);

	// take the money, oh noes gm pls gief gold mi hero poor
	pClient->GetPlayer()->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -(int32)uAmount);

	// broadcast guild event telling everyone the new balance
	char buf[20];
	snprintf(buf, 20, I64FMT, (uint64)m_bankBalance);
	LogGuildEvent(GUILD_EVENT_SETNEWBALANCE, 1, buf);

	// log it!
	LogGuildBankActionMoney(GUILD_BANK_LOG_EVENT_DEPOSIT_MONEY, pClient->GetPlayer()->GetLowGUID(), uAmount);
}
コード例 #14
0
ファイル: Guild.cpp プロジェクト: Antares84/arcemu
void Guild::DepositMoney(WorldSession* pClient, uint32 uAmount)
{
	// does player have required money?
	if(!pClient->GetPlayer()->HasGold(uAmount))
		return;

	// add to the bank balance
	m_bankBalance += uAmount;

	// update in db
	CharacterDatabase.Execute("UPDATE guilds SET bankBalance = %llu WHERE guildId = %u", m_bankBalance, m_guildId);

	// take the money, oh noes gm pls gief gold mi hero poor
	pClient->GetPlayer()->ModGold(-(int32)uAmount);

	// broadcast guild event telling everyone the new balance
	char buf[20];
	snprintf(buf, 20, I64FMT, m_bankBalance);
	LogGuildEvent(GUILD_EVENT_SETNEWBALANCE, 1, buf);

	// log it!
	LogGuildBankActionMoney(GUILD_BANK_LOG_EVENT_DEPOSIT_MONEY, pClient->GetPlayer()->GetLowGUID(), uAmount);
}
コード例 #15
0
void Guild::DemoteGuildMember(PlayerInfo * pMember, WorldSession * pClient)
{
	if(pClient->GetPlayer()->m_playerInfo->guild != this || pMember->guild != this || pClient->GetPlayer()->m_playerInfo == pMember )
		return;

	if(!pClient->GetPlayer()->m_playerInfo->guildRank->CanPerformCommand(GR_RIGHT_DEMOTE) ||
		pMember->guid == GetGuildLeader())
	{
		SendGuildCommandResult(pClient, GUILD_PROMOTE_S, "", GUILD_PERMISSIONS);
		return;
	}

	//as wowwiki says, a global rule should be set too: 
	// Members of the guild can only perform promote/demote/remove actions on those of lower ranks than themselves. 
	if(pClient != NULL )
	{
		PlayerInfo * Initiator = pClient->GetPlayer()->m_playerInfo;
		if( pMember->guildRank->iId <= Initiator->guildRank->iId && Initiator->guildRank->iId != 0)
		{
			pClient->SystemMessage("You can only demote lower ranks then yourself.");
			return;
		}
	}


	// find the next highest rank
	uint32 nh = pMember->guildRank->iId + 1;
	GuildRank * newRank = NULL;

	m_lock.Acquire();
	while(nh < 10 && newRank == NULL)
	{
		newRank = m_ranks[nh];
		++nh;
	}

	if(newRank==NULL)
	{
		m_lock.Release();
		if(pClient != NULL )
			pClient->SystemMessage("Could not find a rank to demote this member to.");
		return;
	}

	GuildMemberMap::iterator itr = m_members.find(pMember);
	if(itr == m_members.end())
	{
		// shouldnt happen
		m_lock.Release();
		return;
	}

	itr->second->pRank = newRank;
	itr->second->pPlayer->guildRank = newRank;

	// log it
	LogGuildEvent(GUILD_EVENT_DEMOTION, 3, pClient->GetPlayer()->GetName(), pMember->name, newRank->szRankName);
	AddGuildLogEntry(GUILD_LOG_EVENT_DEMOTION, 2, pClient->GetPlayer()->GetLowGUID(), pMember->guid, newRank->iId);

	// update in the database
	CharacterDatabase.Execute("UPDATE guild_data SET guildRank = %u WHERE playerid = %u AND guildid = %u", newRank->iId, pMember->guid, m_guildId);

	// if the player is online, update his guildrank
	if(pMember->m_loggedInPlayer)
		pMember->m_loggedInPlayer->SetGuildRank(newRank->iId);

	// release lock
	m_lock.Release();
}
コード例 #16
0
ファイル: Guild.cpp プロジェクト: Desch/Edge-of-Chaos
void Guild::RemoveGuildMember(PlayerInfo* pMember, WorldSession* pClient)
{
	if(pMember->guild != this)
		return;

	if(pClient && pClient->GetPlayer()->getPlayerInfo()->guild != this)
		return;
	if(pClient)
	{
		int RDiff = pMember->guildRank->iId - pClient->GetPlayer()->getPlayerInfo()->guildRank->iId;

		if((!pClient->GetPlayer()->getPlayerInfo()->guildRank->CanPerformCommand(GR_RIGHT_REMOVE)
		        && pClient->GetPlayer()->getPlayerInfo() != pMember)
		        || (RDiff <= 0 && pClient->GetPlayer()->getPlayerInfo() != pMember))
		{
			Guild::SendGuildCommandResult(pClient, GUILD_CREATE_S, "", GUILD_PERMISSIONS);
			return;
		}
	}
	if(pMember->guildRank->iId == 0)
	{
		if(pClient)
			pClient->SystemMessage("You cannot remove the guild master.");

		return;
	}

	CharacterDatabase.Execute("DELETE FROM guild_data WHERE playerid = %u", pMember->guid);

	m_lock.Acquire();
	GuildMemberMap::iterator itr = m_members.find(pMember);
	if(itr != m_members.end())
	{
		// this should always exist.
		if(itr->second->szOfficerNote)
			free((void*)itr->second->szOfficerNote);
		if(itr->second->szPublicNote)
			free((void*)itr->second->szPublicNote);

		delete itr->second;
		m_members.erase(itr);
	}
	Player* plr = objmgr.GetPlayer(pMember->guid);
	if(pClient && pClient->GetPlayer()->getPlayerInfo() != pMember)
	{
		if(plr)
			sChatHandler.SystemMessageToPlr(plr, "You have been kicked from the guild by %s", pClient->GetPlayer()->GetName());
		LogGuildEvent(GUILD_EVENT_REMOVED, 2, pMember->name, pClient->GetPlayer()->GetName());
		AddGuildLogEntry(GUILD_LOG_EVENT_REMOVAL, 2, pClient->GetPlayer()->GetLowGUID(), pMember->guid);
	}
	else
	{
		LogGuildEvent(GUILD_EVENT_LEFT, 1, pMember->name);
		AddGuildLogEntry(GUILD_LOG_EVENT_LEFT, 1, pMember->guid);
	}

	m_lock.Release();

	pMember->guildRank = NULL;
	pMember->guild = NULL;
	pMember->guildMember = NULL;

	if(plr)
	{
		plr->SetGuildRank(0);
		plr->SetGuildId(0);
		plr->SendGuildMOTD();
	}
}
コード例 #17
0
void Guild::RemoveGuildMember(PlayerInfo * pMember, WorldSession * pClient)
{
	if(pMember->guild != this )
		return;

	if(pMember->guildRank->iId==0)
	{
		if(pClient != NULL)
			pClient->SystemMessage("You cannot remove the guild master.");
		return;
	}

	if(pClient != NULL )
	{
		if( pClient->GetPlayer()->m_playerInfo->guild != this)
			return;

		if( !pClient->GetPlayer()->m_playerInfo->guildRank->CanPerformCommand(GR_RIGHT_REMOVE) && pClient->GetPlayer()->m_playerInfo != pMember)
		{
			Guild::SendGuildCommandResult(pClient, GUILD_CREATE_S, "", GUILD_PERMISSIONS);
			return;
		}
		//as wowwiki says, a global rule should be set too: 
		// Members of the guild can only perform promote/demote/remove actions on those of lower ranks than themselves. 
		PlayerInfo * Initiator = pClient->GetPlayer()->m_playerInfo;
		if( pMember != Initiator && pMember->guildRank->iId <= Initiator->guildRank->iId && Initiator->guildRank->iId != 0 )
		{
			pClient->SystemMessage("You can only remove lower ranks then yourself.");
			return;
		}

	}

	CharacterDatabase.Execute("DELETE FROM guild_data WHERE playerid = %u", pMember->guid);

	m_lock.Acquire();
	GuildMemberMap::iterator itr = m_members.find(pMember);
	if(itr != m_members.end())
	{
		// this should always exist.
		if(itr->second->szOfficerNote)
			free((void*)itr->second->szOfficerNote);
		if(itr->second->szPublicNote)
			free((void*)itr->second->szPublicNote);

		delete itr->second;
		m_members.erase(itr);
	}

	if(pClient != NULL && pClient->GetPlayer()->m_playerInfo != pMember)
	{
		if(pMember->m_loggedInPlayer)
		{
			PlayerPointer plr = objmgr.GetPlayer(pMember->guid);
			sChatHandler.SystemMessageToPlr(plr, "You have been removed from the guild by %s", pClient->GetPlayer()->GetName());
		}
		LogGuildEvent(GUILD_EVENT_REMOVED, 2, pMember->name, pClient->GetPlayer()->GetName());
		AddGuildLogEntry(GUILD_LOG_EVENT_REMOVAL, 2, pClient->GetPlayer()->GetLowGUID(), pMember->guid);
	}
	else
	{
		LogGuildEvent(GUILD_EVENT_LEFT, 1, pMember->name);
		AddGuildLogEntry(GUILD_LOG_EVENT_LEFT, 1, pMember->guid);
	}

	m_lock.Release();

	pMember->guildRank=NULL;
	pMember->guild=NULL;
	pMember->guildMember=NULL;

	if(pMember->m_loggedInPlayer)
	{
		pMember->m_loggedInPlayer->SetGuildRank(0);
		pMember->m_loggedInPlayer->SetGuildId(0);
	}
}