コード例 #1
0
ファイル: GroupHandler.cpp プロジェクト: Artea/mangos-svn
//////////////////////////////////////////////////////////////////////////////////////////
///This function handles CMSG_GROUP_DISBAND:
//////////////////////////////////////////////////////////////////////////////////////////
void WorldSession::HandleGroupDisbandOpcode( WorldPacket & recv_data )
{
    WorldPacket data;

    // error he's not in a group
    if (!GetPlayer()->IsInGroup())
        return;

    GetPlayer()->UnSetInGroup();

    Group *group;
    group = objmgr.GetGroupByLeader(GetPlayer()->GetGroupLeader());

    if(group==NULL)
    {
        printf("Not in a group\n");
        return;
    }

    if (group->RemoveMember(GetPlayer()->GetGUID()) > 1)
        group->SendUpdate();
    else
    {
        group->Disband();
        objmgr.RemoveGroup(group);
        data.Initialize( SMSG_GROUP_DESTROYED );
        SendPacket( &data );

        delete group;
    }

    data.Initialize( SMSG_GROUP_UNINVITE );
    SendPacket( &data );
}
コード例 #2
0
ファイル: GroupHandler.cpp プロジェクト: Artea/mangos-svn
void WorldSession::HandleGroupDeclineOpcode( WorldPacket & /*recv_data*/ )
{
    Group  *group  = GetPlayer()->GetGroupInvite();
    if (!group) return;

    Player *leader = objmgr.GetPlayer(group->GetLeaderGUID());

    /** error handling **/
    if(!leader || !leader->GetSession())
        return;
    /********************/

    // everything's fine, do it
    if(group->GetMembersCount() <= 1)                       // group has just 1 member => disband
    {
        group->Disband(true);
        objmgr.RemoveGroup(group);
        delete group;
    }

    GetPlayer()->SetGroupInvite(NULL);

    WorldPacket data( SMSG_GROUP_DECLINE, 10 );             // guess size
    data << GetPlayer()->GetName();
    leader->GetSession()->SendPacket( &data );
}
コード例 #3
0
ファイル: GroupHandler.cpp プロジェクト: lasyan3/TrinityCore
void WorldSession::HandleGroupDisbandOpcode(WorldPacket & /*recvData*/)
{
    TC_LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_DISBAND");

    Group* grp = GetPlayer()->GetGroup();
    Group* grpInvite = GetPlayer()->GetGroupInvite();
    if (!grp && !grpInvite)
        return;

    if (_player->InBattleground())
    {
        SendPartyResult(PARTY_OP_INVITE, "", ERR_INVITE_RESTRICTED);
        return;
    }

    /** error handling **/
    /********************/

    // everything's fine, do it
    if (grp)
    {
        SendPartyResult(PARTY_OP_LEAVE, GetPlayer()->GetName(), ERR_PARTY_RESULT_OK);
        GetPlayer()->RemoveFromGroup(GROUP_REMOVEMETHOD_LEAVE);
    }
    else if (grpInvite && grpInvite->GetLeaderGUID() == GetPlayer()->GetGUID())
    { // pending group creation being cancelled
        SendPartyResult(PARTY_OP_LEAVE, GetPlayer()->GetName(), ERR_PARTY_RESULT_OK);
        grpInvite->Disband();
    }
}
コード例 #4
0
bool ChatHandler::HandleGroupDisbandCommand(const char *args)
{
    Player* player  = NULL;
    Group* group = NULL;
    uint64 guid  = 0;
    char* cname  = strtok((char*)args, " ");

    if (GetPlayerGroupAndGUIDByName(cname, player, group, guid))
        if (group)
            group->Disband();

    return true;
}
コード例 #5
0
ファイル: cs_group.cpp プロジェクト: Allowed/SkyFire_5xx
    static bool HandleGroupDisbandCommand(ChatHandler* handler, char const* args)
    {
        Player* player = NULL;
        Group* group = NULL;
        uint64 guid = 0;
        char* nameStr = strtok((char*)args, " ");

        if (!handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid))
            return false;

        if (!group)
        {
            handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, player->GetName().c_str());
            handler->SetSentErrorMessage(true);
            return false;
        }

        group->Disband();
        return true;
    }
コード例 #6
0
ファイル: LFGScripts.cpp プロジェクト: Diyvol/TrinityCore
void LFGPlayerScript::OnMapChanged(Player* player)
{
    Map const* map = player->GetMap();

    if (sLFGMgr->inLfgDungeonMap(player->GetGUID(), map->GetId(), map->GetDifficultyID()))
    {
        Group* group = player->GetGroup();
        // This function is also called when players log in
        // if for some reason the LFG system recognises the player as being in a LFG dungeon,
        // but the player was loaded without a valid group, we'll teleport to homebind to prevent
        // crashes or other undefined behaviour
        if (!group)
        {
            sLFGMgr->LeaveLfg(player->GetGUID());
            player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW);
            player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, 0.0f);
            TC_LOG_ERROR("lfg", "LFGPlayerScript::OnMapChanged, Player %s (%s) is in LFG dungeon map but does not have a valid group! "
                "Teleporting to homebind.", player->GetName().c_str(), player->GetGUID().ToString().c_str());
            return;
        }

        for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
            if (Player* member = itr->GetSource())
                player->GetSession()->SendNameQueryOpcode(member->GetGUID());

        if (sLFGMgr->selectedRandomLfgDungeon(player->GetGUID()))
            player->CastSpell(player, LFG_SPELL_LUCK_OF_THE_DRAW, true);
    }
    else
    {
        Group* group = player->GetGroup();
        if (group && group->GetMembersCount() == 1)
        {
            sLFGMgr->LeaveLfg(group->GetGUID());
            group->Disband();
            TC_LOG_DEBUG("lfg", "LFGPlayerScript::OnMapChanged, Player %s(%s) is last in the lfggroup so we disband the group.",
                player->GetName().c_str(), player->GetGUID().ToString().c_str());
        }
        player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW);
    }
}
コード例 #7
0
ファイル: GroupHandler.cpp プロジェクト: Artea/mangos-svn
void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data )
{
    std::string membername;
    recv_data >> membername;

    // attempt add selected player

    // cheating
    if(membername.empty())
    {
        SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET);
        return;
    }

    normalizePlayerName(membername);
    Player *player = objmgr.GetPlayer(membername.c_str());

    // no player
    if(!player)
    {
        SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_CANT_FIND_TARGET);
        return;
    }

    // can't group with
    if(!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam())
    {
        SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_UNFRIENDLY);
        return;
    }

    // just ignore us
    if(player->HasInIgnoreList(GetPlayer()->GetGUID()))
    {
        SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_TARGET_IGNORE_YOU);
        return;
    }

    // player already in another group or invited
    if(player->GetGroup() || player->GetGroupInvite() )
    {
        SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_ALREADY_IN_GROUP);
        return;
    }

    Group *group = GetPlayer()->GetGroup();

    if(group)
    {
        // not have permissions for invite
        if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
        {
            SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_YOU_NOT_LEADER);
            return;
        }

        // not have place
        if(group->IsFull())
        {
            SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL);
            return;
        }
    }

    // ok, but group not exist, creating new
    if(!group)
    {
        group = new Group;
        if(!group->Create(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
        {
            delete group;
            return;
        }

        objmgr.AddGroup(group);

        // new group: if can't add then delete
        if(!group->AddInvite(player))
        {
            group->Disband(true);
            objmgr.RemoveGroup(group);
            delete group;
            return;
        }
    }
    else
    {
        // already existed group: if can't add then just leave
        if(!group->AddInvite(player))
        {
            return;
        }
    }

    // ok, we do it
    WorldPacket data(SMSG_GROUP_INVITE, 10);                // guess size
    data << GetPlayer()->GetName();
    player->GetSession()->SendPacket(&data);

    SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_OK);
}
コード例 #8
0
ファイル: WorldSession.cpp プロジェクト: vata/prebcwow
//-----------------------------------------------------------------------------
void WorldSession::LogoutPlayer()
{
    if (_player)
    {
        // Save the player
        _player->SaveToDB();

        // Issue a message saying we left the world
		if (!_player->m_gmInvisible)
		{
			std::string outstring = "|c8fff9920";
			outstring.append( _player->GetName());
			outstring.append( " has left the world.|r" );
			sWorld.SendWorldText( outstring.c_str() );
		}

		_player->ClearHate();

        // Remove ourself from a group
        if (_player->IsInGroup())
        {
            _player->UnSetInGroup();
            Group *group;
            group = objmgr.GetGroupByLeader(_player->GetGroupLeader());
            if (group->RemoveMember(_player->GetGUID()) > 1)
                group->SendUpdate();
            else
            {
                group->Disband();
                objmgr.RemoveGroup(group);

                delete group;
            }
        }

        // Remove us from world
        if (_player->IsInWorld())
        {
            sLog.outDebug( "SESSION: removing player from world" );
            _player->RemoveFromMap();
        }

        objmgr.RemoveObject_Free (_player);

		//////////////////////////////////////////////////
		// Set Time of Logout for Player, will be used for RESTSTATE calculation
		std::stringstream ss;
		ss << "UPDATE characters SET timestamp = " << (uint32)time(NULL) << ", online = 0 WHERE guid = " << _player->GetGUID();
		sDatabase.Execute (ss.str().c_str());
		//////////////////////////////////////////////////

        _player = NULL;
        WorldPacket packet;

        packet.Initialize( SMSG_LOGOUT_COMPLETE );
        SendPacket( &packet );

        sLog.outDebug( "SESSION: Sent SMSG_LOGOUT_COMPLETE Message" );
    }
    LogoutRequest(0);
}
コード例 #9
0
ファイル: WorldSession.cpp プロジェクト: Artea/mangos-svn
void WorldSession::LogoutPlayer(bool Save)
{
    if (_player)
    {
        // logging out just after died
        if (_player->GetDeathTimer())
        {
            _player->KillPlayer();
            _player->BuildPlayerRepop();
        }

        sDatabase.PExecute("UPDATE `character` SET `online` = 0 WHERE `guid` = '%u'", _player->GetGUID());
        loginDatabase.PExecute("UPDATE `account` SET `online` = 0 WHERE `id` = '%u'", GetAccountId());

        if (_player->IsInGroup())
        {
            _player->UnSetInGroup();
            Group *group;
            group = objmgr.GetGroupByLeader(_player->GetGroupLeader());
            if(group!=NULL)
            {
                if (group->RemoveMember(_player->GetGUID()) > 1)
                    group->SendUpdate();
                else
                {
                    group->Disband();
                    objmgr.RemoveGroup(group);

                    delete group;
                }
            }
        }
        Guild *guild;
        guild = objmgr.GetGuildById(_player->GetGuildId());
        if(guild)
        {
            guild->LoadPlayerStatsByGuid(_player->GetGUID());
        }
        _player->UnsummonPet();
        _player->Uncharm();
        _player->UnsummonTotem();

        ObjectAccessor::Instance().RemovePlayer(_player);
        MapManager::Instance().GetMap(_player->GetMapId())->Remove(_player, false);

        if(Save)
        {
            uint32 eslot;
            for(int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; j++)
            {
                eslot = j - BUYBACK_SLOT_START;
                _player->SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1+eslot*2,0);
                _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1+eslot,0);
                _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1+eslot,0);
            }
            _player->SaveToDB();

        }
        delete _player;
        _player = 0;

        WorldPacket packet;

        packet.Initialize( SMSG_LOGOUT_COMPLETE );
        SendPacket( &packet );

        sLog.outDebug( "SESSION: Sent SMSG_LOGOUT_COMPLETE Message" );
    }

    LogoutRequest(0);
}
コード例 #10
0
ファイル: WorldSession.cpp プロジェクト: Artea/mangos-svn
void WorldSession::LogoutPlayer(bool Save)
{
    if (_player)
    {
        
        std::stringstream ss;
        ss << "UPDATE characters SET online = 0 WHERE guid = " << _player->GetGUID();

#ifndef __NO_PLAYERS_ARRAY__
        bool found = false;
        uint32 loop = 0;
        
        std::stringstream ss2;
        ss2.rdbuf()->str("");
        ss2 << _player->GetGUID();
        long long int guid = atoi(ss2.str().c_str());

        // Remove the player from the player list...
        for (loop = 0; loop < NumActivePlayers; loop++)
        {
            if (found)
            {
                ActivePlayers[loop] = ActivePlayers[loop+1];
            }
            else if (ActivePlayers[loop] == guid)
            {
                found = true;
                ActivePlayers[loop] = ActivePlayers[loop+1];
            }
        }

        NumActivePlayers--;
#endif //__NO_PLAYERS_ARRAY__

        // Remove ourself from a group
        if (_player->IsInGroup())
        {
            _player->UnSetInGroup();
            Group *group;
            group = objmgr.GetGroupByLeader(_player->GetGroupLeader());
            if(group!=NULL)
            {
                if (group->RemoveMember(_player->GetGUID()) > 1)
                    group->SendUpdate();
                else
                {
                    group->Disband();
                    objmgr.RemoveGroup(group);

                    delete group;
                }
            }
        }

        // Remove us from world
        if (_player->IsInWorld())
        {
            sLog.outDebug( "SESSION: removing player from world" );
#ifndef ENABLE_GRID_SYSTEM
            _player->RemoveFromMap();
#else
        MapManager::Instance().GetMap(_player->GetMapId())->RemoveFromMap(_player);
        ObjectAccessor::Instance().RemovePlayer(_player);
#endif
        }

#ifndef ENABLE_GRID_SYSTEM
        objmgr.RemoveObject(_player);
#else
    MapManager::Instance().GetMap(_player->GetMapId())->Remove(_player, false);
#endif
        if(Save)
        {
            // Save the player
            /*    Removed this to help prevent Character coruption while the server
            still dies alot. ReEnable when fixed */
            _player->SaveToDB();
        }
        delete _player;
        _player = 0;

        WorldPacket packet;

        packet.Initialize( SMSG_LOGOUT_COMPLETE );
        SendPacket( &packet );

        sLog.outDebug( "SESSION: Sent SMSG_LOGOUT_COMPLETE Message" );
    }

    LogoutRequest(0);
}