Fix/Patch [0.3.6pl1] !disband fix

Skazw

New Member
Joined
Jun 23, 2013
Messages
3
Reaction score
2
Fix for !disband command ^_^

ioguild.cpp, find:
Code:
bool IOGuild::disbandGuild(uint32_t guildId)
{
	Database* db = Database::getInstance();

	DBQuery query;
	query << "UPDATE `players` SET `rank_id` = '' AND `guildnick` = '' WHERE `rank_id` = " << getRankIdByLevel(guildId, GUILDLEVEL_LEADER) << " OR rank_id = " << getRankIdByLevel(guildId, GUILDLEVEL_VICE) << " OR rank_id = " << getRankIdByLevel(guildId, GUILDLEVEL_MEMBER);
	if(!db->executeQuery(query.str()))
		return false;

	for(AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it)
	{
		if(it->second->getGuildId() == guildId)
			it->second->leaveGuild();
	}

	query.str("");
	query << "DELETE FROM `guilds` WHERE `id` = " << guildId << " LIMIT 1";
	if(!db->executeQuery(query.str()))
		return false;

	query.str("");
	query << "DELETE FROM `guild_invites` WHERE `guild_id` = " << guildId;
	if(!db->executeQuery(query.str()))
		return false;

	query.str("");
	query << "DELETE FROM `guild_ranks` WHERE `guild_id` = " << guildId;
	return db->executeQuery(query.str());
}
replace with:
Code:
bool IOGuild::disbandGuild(uint32_t guildId)
{
    Database* db = Database::getInstance();

    DBQuery query;
    query << "UPDATE `players` SET `rank_id` = '' AND `guildnick` = '' WHERE `rank_id` = " << getRankIdByLevel(guildId, GUILDLEVEL_LEADER) << " OR rank_id = " << getRankIdByLevel(guildId, GUILDLEVEL_VICE) << " OR rank_id = " << getRankIdByLevel(guildId, GUILDLEVEL_MEMBER);
    if(!db->executeQuery(query.str()))
        return false;

    InvitedToGuildsList::iterator iit;
    for(AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it)
    {
        if(it->second->getGuildId() == guildId)
            it->second->leaveGuild();
        else
        {
         iit = std::find(it->second->invitedToGuildsList.begin(), it->second->invitedToGuildsList.end(), guildId);
            if(iit != it->second->invitedToGuildsList.end())
                 it->second->invitedToGuildsList.erase(iit);
        }
    }

    query.str("");
    query << "DELETE FROM `guilds` WHERE `id` = " << guildId << db->getUpdateLimiter();
    if(!db->executeQuery(query.str()))
        return false;

    query.str("");
    query << "DELETE FROM `guild_invites` WHERE `guild_id` = " << guildId;
    if(!db->executeQuery(query.str()))
        return false;

    query.str("");
    query << "DELETE FROM `guild_ranks` WHERE `guild_id` = " << guildId;
    return db->executeQuery(query.str());
}
Credits: slawkens
 

waqmaz

Member
Joined
Jun 17, 2015
Messages
203
Reaction score
10
and what does it do? clears invitations? 036 already does it
 
Top