Exemplo n.º 1
0
//----------------------------------------------------------------------------
void cbClientGroupAbandonMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    uint8 index;
    msgin.serial(userId,index);

    if (!checkPlayer(userId, "cbClientGroupAbandonMission")) return;
    CCharacter * user = PlayerManager.getChar( userId );

    user->setAfkState(false);
    CTeam * team = TeamManager.getRealTeam( user->getTeamId() );
    if ( !team )
    {
        MISLOG("user:%s cbClientGroupAbandonMission : Invalid team", userId.toString().c_str());
        return;
    }
    if ( team->getLeader() != userId )
    {
        CCharacter::sendDynamicSystemMessage( user->getEntityRowId(), "REQ_LEADER_TO_ABANDON_MISSION" );
        return;
    }

    if ( index >=  team->getMissions().size() )
    {
        MISLOG("user:%s cbClientGroupAbandonMission : Invalid group mission %u ( count %u )",
               userId.toString().c_str(), index, team->getMissions().size());
        return;
    }


    CMissionTeam* mission = team->getMissions()[index];
    nlassert(mission);

    if ( mission->getFinished() == false )
    {
        CMissionTemplate * templ = CMissionManager::getInstance()->getTemplate( mission->getTemplateId() );
        if ( !templ )
        {
            MISLOG("user:%s cbClientGroupAbandonMission : invalid group mission alias %u",
                   userId.toString().c_str(), mission->getTemplateId());
            return;
        }
        if ( templ->Tags.NonAbandonnable )
        {
            MISLOG("user:%s cbClientGroupAbandonMission : group mission alias %u is not abandonnable but user tries to abandon it",
                   userId.toString().c_str(), mission->getTemplateId());
            return;
        }
        set<CEntityId> excluded;
        excluded.insert( userId );

        team->sendDynamicMessageToMembers( "ABANDON_GROUP_MISSION",TVectorParamCheck(), excluded );
    }
    team->removeMission( index, mr_abandon );
}
Exemplo n.º 2
0
//----------------------------------------------------------------------------
void cbClientMissionGroupWake( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    msgin.serial(userId);

    uint8 missionGroupIndex;
    msgin.serial(missionGroupIndex);

    CCharacter * user = PlayerManager.getChar(userId);
    if ( !user || !user->getEnterFlag() )
        return;

    user->setAfkState(false);

    CTeam * team = TeamManager.getRealTeam( user->getTeamId() );
    if ( !team )
    {
        MISLOG("user:%s cbClientMissionGroupWake : Invalid team", userId.toString().c_str());
        return;
    }
    if ( team->getLeader() != userId )
    {
        return;
    }

    if ( missionGroupIndex >=  team->getMissions().size() )
    {
        MISLOG("user:%s cbClientMissionGroupWake : Invalid group mission %u ( count %u )",
               userId.toString().c_str(), missionGroupIndex, team->getMissions().size());
        return;
    }


    CMissionTeam* mission = team->getMissions()[missionGroupIndex];
    nlassert(mission);

    if ( mission->getFinished() == false )
    {
        CMissionTemplate * templ = CMissionManager::getInstance()->getTemplate( mission->getTemplateId() );
        if ( !templ )
        {
            MISLOG("user:%s cbClientGroupAbandonMission : invalid group mission alias %u",
                   userId.toString().c_str(), mission->getTemplateId());
            return;
        }

        CMissionQueueManager::getInstance()->playerWakesUp (userId, templ->Alias );
    }
}