Example #1
0
//.admin dispellall
bool ChatHandler::HandleAdminDispelAllCommand(const char* args, WorldSession* m_session)
{
    uint32 pos = 0;
    if (*args)
        pos = atoi(args);

    sGMLog.writefromsession(m_session, "used dispelall command, pos %u", pos);

    PlayerStorageMap::const_iterator itr;
    objmgr._playerslock.AcquireReadLock();
    for (itr = objmgr._players.begin(); itr != objmgr._players.end(); ++itr)
    {
        Player* player = itr->second;
        if (player->GetSession() && player->IsInWorld())
        {
            if (player->GetMapMgr() != m_session->GetPlayer()->GetMapMgr())
            {
                sEventMgr.AddEvent(static_cast< Unit* >(player), &Unit::DispelAll, pos ? true : false, EVENT_PLAYER_CHECKFORCHEATS, 100, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
            }
            else
            {
                player->DispelAll(pos ? true : false);
            }
        }
    }
    sGMLog.writefromsession(m_session, "used mass dispel");
    objmgr._playerslock.ReleaseReadLock();

    BlueSystemMessage(m_session, "Dispel action done.");
    return true;
}
Example #2
0
bool ChatHandler::HandleGMTicketListCommand(const char* args, WorldSession *m_session)
{
	Player *cplr = m_session->GetPlayer();

	Channel *chn = channelmgr.GetChannel(sWorld.getGmClientChannel().c_str(), cplr);
	if(!chn)
		return false;

	chn->Say(cplr, "GmTicket 2", cplr, true);

	for(GmTicketList::iterator itr = objmgr.GM_TicketList.begin(); itr != objmgr.GM_TicketList.end(); itr++)
	{
		if((*itr)->deleted)
			continue;

		Player* plr = objmgr.GetPlayer((uint32)(*itr)->playerGuid);

		if( plr == NULL )
			continue;

//		Player* aplr = ((*itr)->assignedToPlayer == 0 ? NULL : objmgr.GetPlayer((uint32)(*itr)->assignedToPlayer));

		std::stringstream ss;

		uint32 zone = 0;
		if(plr->IsInWorld())
		{
			zone = plr->GetZoneId();
		}
		ss << "GmTicket 0," << (*itr)->name << "," << (*itr)->level << ",0," << zone;
		chn->Say(cplr, ss.str().c_str(), cplr, true);
	}

	return true;
}
Example #3
0
void Vehicle::TeleportVehicle(float x, float y, float z, float o)
{
    if (!IsVehicleInUse() || !GetBase()->isAlive())
        return;

    std::list<PlayerSeatSave> players;

    for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
    {
        uint64 guid = itr->second.Passenger;
        Player* player = GetBase()->GetPlayer(guid);

        if (player && player->IsInWorld() && player->isAlive())
        {
            PlayerSeatSave pss;
            pss.player = player;
            pss.seatId = itr->first;
            player->ExitVehicle();
        }
    }

    if (players.empty())
        return;

    GetBase()->NearTeleportTo(x, y, z, o, false);

    for (std::list<PlayerSeatSave>::const_iterator itr = players.begin(); itr != players.end(); ++itr)
    {
        if (!itr->player->IsInWorld() || !itr->player->isAlive())
            continue;

        itr->player->TeleportTo(GetBase()->GetMapId(), x, y, z, o, 0);
        itr->player->EnterVehicle(GetBase(), itr->seatId);
    }
}
Example #4
0
void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
{
    if (!player)
        return;

    AccountTypes gmSecLevel = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST));
    for (SocialMap::const_iterator itr = m_socialMap.begin(); itr != m_socialMap.end(); ++itr)
    {
        PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(player->GetGUID());
        if (itr2 != itr->second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND))
        {
            Player* target = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));
            if (!target || !target->IsInWorld())
                continue;

            WorldSession* session = target->GetSession();
            if (!session->HasPermission(rbac::RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS) && player->GetSession()->GetSecurity() > gmSecLevel)
                continue;

            if (target->GetTeam() != player->GetTeam() && !session->HasPermission(rbac::RBAC_PERM_TWO_SIDE_WHO_LIST))
                continue;

            if (player->IsVisibleGloballyFor(target))
                session->SendPacket(packet);
        }
    }
}
Example #5
0
void BfGraveyard::Resurrect()
{
    if (m_ResurrectQueue.empty())
        return;

    for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
    {
        // Get player object from his guid
        Player* player = ObjectAccessor::FindPlayer(*itr);
        if (!player)
            continue;

        // Check  if the player is in world and on the good graveyard
        if (player->IsInWorld())
            if (Creature* spirit = m_Bf->GetCreature(m_SpiritGuide[m_ControlTeam]))
                spirit->CastSpell(spirit, SPELL_SPIRIT_HEAL, true);

        // Resurrect player
        player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true);
        player->ResurrectPlayer(1.0f);
        player->CastSpell(player, 6962, true);
        player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true);

        player->SpawnCorpseBones(false);
    }

    m_ResurrectQueue.clear();
}
Example #6
0
void WorldSession::HandleCancelTrade(WorldPacket & recv_data)
{
	if(_player)
	{
		if(!_player->IsInWorld() || _player->mTradeTarget == 0)
			return;

		if( _player->mTradeStatus == TRADE_STATUS_COMPLETE)
		{
			_player->ResetTradeVariables();
			return;
		}

		uint32 TradeStatus = TRADE_STATUS_CANCELLED;

		Player* pTarget = _player->GetTradeTarget();
		if(pTarget == NULL || !pTarget->IsInWorld())
		{
			TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;
			_player->ResetTradeVariables();
			SendTradeStatus(TradeStatus);
		}
		else
		{
			pTarget->ResetTradeVariables();
			_player->ResetTradeVariables();

			SendTradeStatus(TradeStatus);
			if(pTarget->m_session && pTarget->m_session->GetSocket())
				pTarget->m_session->SendTradeStatus(TradeStatus);
		}
	}
}
Example #7
0
void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
{
    if (!player)
        return;

    uint32 team = player->GetTeam();
    AccountTypes security = player->GetSession()->GetSecurity();
    uint32 guid = player->GetGUIDLow();
    AccountTypes gmLevelInWhoList = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST));
    bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST);

    for (SocialMap::const_iterator itr = m_socialMap.begin(); itr != m_socialMap.end(); ++itr)
    {
        PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(guid);
        if (itr2 != itr->second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND))
        {
            Player* pFriend = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER));

            // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
            // MODERATOR, GAME MASTER, ADMINISTRATOR can see all
            if (pFriend && pFriend->IsInWorld() &&
                (!AccountMgr::IsPlayerAccount(pFriend->GetSession()->GetSecurity()) ||
                ((pFriend->GetTeam() == team || allowTwoSideWhoList) && security <= gmLevelInWhoList)) &&
                player->IsVisibleGloballyFor(pFriend))
            {
                pFriend->GetSession()->SendPacket(packet);
            }
        }
    }
}
Example #8
0
Player*
ObjectAccessor::FindPlayer(uint64 guid)
{
    Player * plr = GetObjectInWorld(guid, (Player*)NULL);
    if(!plr || !plr->IsInWorld())
        return NULL;

    return plr;
}
Example #9
0
bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant, uint8 group)
{
    if (IsFull())
        return false;

    if (!guid)
        return false;

    Player* player = sObjectMgr.GetPlayer(guid, false);

    MemberSlot member;
    member.guid      = guid;
    member.name      = name;
    member.group     = group;
    member.assistant = isAssistant;
    m_memberSlots.push_back(member);

    SubGroupCounterIncrease(group);

    if (player)
    {
        player->SetGroupInvite(NULL);
        // if player is in group and he is being added to BG raid group, then call SetBattleGroundRaid()
        if (player->GetGroup() && isBGGroup())
            player->SetBattleGroundRaid(this, group);
        // if player is in bg raid and we are adding him to normal group, then call SetOriginalGroup()
        else if (player->GetGroup())
            player->SetOriginalGroup(this, group);
        // if player is not in group, then call set group
        else
            player->SetGroup(this, group);

        if (player->IsInWorld())
        {
            // if the same group invites the player back, cancel the homebind timer
            if (InstanceGroupBind* bind = GetBoundInstance(player->GetMapId()))
                if (bind->state->GetInstanceId() == player->GetInstanceId())
                    player->m_InstanceValid = true;
        }
    }

    if (!isRaidGroup())                                     // reset targetIcons for non-raid-groups
    {
        for (int i = 0; i < TARGET_ICON_COUNT; ++i)
            m_targetIcons[i].Clear();
    }

    if (!isBGGroup())
    {
        // insert into group table
        CharacterDatabase.PExecute("INSERT INTO group_member(groupId,memberGuid,assistant,subgroup) VALUES('%u','%u','%u','%u')",
                                   m_Id, member.guid.GetCounter(), ((member.assistant == 1) ? 1 : 0), member.group);
    }

    return true;
}
Example #10
0
Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/)
{
    if (!guid)
        return NULL;

    Player* plr = HashMapHolder<Player>::Find(guid);
    if (!plr || (!plr->IsInWorld() && inWorld))
        return NULL;

    return plr;
}
Example #11
0
void WorldSession::HandleInitiateTrade(WorldPacket & recv_data)
{
	CHECK_INWORLD_RETURN;

	CHECK_PACKET_SIZE(recv_data, 8);

	uint64 guid;
	recv_data >> guid;

	uint32 TradeStatus = TRADE_STATUS_PROPOSED;

	Player* pTarget = _player->GetMapMgr()->GetPlayer((uint32)guid);
	if(pTarget == NULL || !pTarget->IsInWorld())
		TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;
	else
	{
		// Handle possible error outcomes
		if(_player->isDead())
			TradeStatus = TRADE_STATUS_DEAD;
		if(pTarget->isDead())
			TradeStatus = TRADE_STATUS_TARGET_DEAD;
		else if(pTarget->mTradeTarget != 0)
			TradeStatus = TRADE_STATUS_ALREADY_TRADING;
		else if(pTarget->GetTeam() != _player->GetTeam() && GetPermissionCount() == 0)
			TradeStatus = TRADE_STATUS_WRONG_FACTION;
		else if(_player->CalcDistance(pTarget) > 10.0f)		// This needs to be checked
			TradeStatus = TRADE_STATUS_TOO_FAR_AWAY;
	}	

	if(TradeStatus != TRADE_STATUS_PROPOSED)
	{
		_player->ResetTradeVariables();
		SendTradeStatus(TradeStatus);
	}
	else
	{
		_player->ResetTradeVariables();
		pTarget->ResetTradeVariables();

		pTarget->mTradeTarget = _player->GetLowGUID();
		_player->mTradeTarget = pTarget->GetLowGUID();

		pTarget->mTradeStatus = TradeStatus;
		_player->mTradeStatus = TradeStatus;

		WorldPacket data(SMSG_TRADE_STATUS, 12);
		data << TradeStatus;
		data << _player->GetGUID();

		if(pTarget->m_session && pTarget->m_session->GetSocket())
			pTarget->m_session->SendPacket(&data);
	}
}
void VisibleNotifier::SendToSelf()
{
    // at this moment i_clientGUIDs have guids that not iterate at grid level checks
    // but exist one case when this possible and object not out of range: transports
    if (Transport* transport = i_player.GetTransport())
        for (std::set<WorldObject*>::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end();++itr)
        {
            if (vis_guids.find((*itr)->GetGUID()) != vis_guids.end())
            {
                vis_guids.erase((*itr)->GetGUID());

                switch ((*itr)->GetTypeId())
                {
                    case TYPEID_GAMEOBJECT:
                        i_player.UpdateVisibilityOf((*itr)->ToGameObject(), i_data, i_visibleNow);
                        break;
                    case TYPEID_PLAYER:
                        i_player.UpdateVisibilityOf((*itr)->ToPlayer(), i_data, i_visibleNow);
                        if (!(*itr)->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
                            (*itr)->ToPlayer()->UpdateVisibilityOf(&i_player);
                        break;
                    case TYPEID_UNIT:
                        i_player.UpdateVisibilityOf((*itr)->ToCreature(), i_data, i_visibleNow);
                        break;
                    default:
                        break;
                }
            }
        }

    for (Player::ClientGUIDs::const_iterator it = vis_guids.begin();it != vis_guids.end(); ++it)
    {
        i_player.m_clientGUIDs.erase(*it);
        i_data.AddOutOfRangeGUID(*it);

        if (IS_PLAYER_GUID(*it))
        {
            Player* player = ObjectAccessor::FindPlayer(*it);
            if (player && player->IsInWorld() && !player->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
                player->UpdateVisibilityOf(&i_player);
        }
    }

    if (!i_data.HasData())
        return;

    WorldPacket packet;
    i_data.BuildPacket(&packet);
    i_player.GetSession()->SendPacket(&packet);

    for (std::set<Unit*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it)
        i_player.SendInitialVisiblePackets(*it);
}
Example #13
0
//.admin castall
bool ChatHandler::HandleAdminCastAllCommand(const char* args, WorldSession* m_session)
{
    if (!args)
    {
        RedSystemMessage(m_session, "No spellid specified.");
        return true;
    }

    uint32 spell_id = atol(args);
    auto spell_entry = sSpellCustomizations.GetSpellInfo(spell_id);
    if (!spell_entry)
    {
        RedSystemMessage(m_session, "Spell %u is not a valid spell!", spell_id);
        return true;
    }

    for (uint8 i = 0; i < 3; ++i)
    {
        if (spell_entry->getEffect(i) == SPELL_EFFECT_LEARN_SPELL)
        {
            sGMLog.writefromsession(m_session, "used learn spell stopped %u", spell_id);
            RedSystemMessage(m_session, "Learn spell specified.");
            return true;
        }
    }

    sGMLog.writefromsession(m_session, "used castall command, spellid %u", spell_id);

    PlayerStorageMap::const_iterator itr;
    objmgr._playerslock.AcquireReadLock();
    for (itr = objmgr._players.begin(); itr != objmgr._players.end(); ++itr)
    {
        Player* player = itr->second;
        if (player->GetSession() && player->IsInWorld())
        {
            if (player->GetMapMgr() != m_session->GetPlayer()->GetMapMgr())
            {
                sEventMgr.AddEvent(static_cast< Unit* >(player), &Unit::EventCastSpell, static_cast< Unit* >(player), spell_entry, EVENT_PLAYER_CHECKFORCHEATS, 100, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
            }
            else
            {
                Spell* spell = sSpellFactoryMgr.NewSpell(player, spell_entry, true, 0);
                SpellCastTargets targets(player->getGuid());
                spell->prepare(&targets);
            }
        }
    }
    objmgr._playerslock.ReleaseReadLock();

    BlueSystemMessage(m_session, "Casted spell %u on all players!", spell_id);
    return true;
}
Example #14
0
//.admin masssummon
bool ChatHandler::HandleAdminMassSummonCommand(const char* args, WorldSession* m_session)
{
    PlayerStorageMap::const_iterator itr;
    objmgr._playerslock.AcquireReadLock();

    Player* summon_player = m_session->GetPlayer();

    int faction = -1;
    char Buffer[170];

    if (*args == 'a')
    {
        faction = 0;
        snprintf(Buffer, 170, "%s%s Has requested a mass summon of all Alliance players. Do not feel obliged to accept the summon, as it is most likely for an event or a test of sorts", MSG_COLOR_GOLD, m_session->GetPlayer()->GetName());

    }
    else if (*args == 'h')
    {
        faction = 1;
        snprintf(Buffer, 170, "%s%s Has requested a mass summon of all Horde players. Do not feel obliged to accept the summon, as it is most likely for an event or a test of sorts", MSG_COLOR_GOLD, m_session->GetPlayer()->GetName());
    }
    else
    {
        snprintf(Buffer, 170, "%s%s Has requested a mass summon of all players. Do not feel obliged to accept the summon, as it is most likely for an event or a test of sorts", MSG_COLOR_GOLD, m_session->GetPlayer()->GetName());
    }

    uint32 summon_count = 0;
    for (itr = objmgr._players.begin(); itr != objmgr._players.end(); ++itr)
    {
        Player* plr = itr->second;
        if (plr->GetSession() && plr->IsInWorld())
        {
            if (faction > -1 && plr->GetTeam() == static_cast<uint32>(faction))
            {
                plr->SummonRequest(summon_player->getGuidLow(), summon_player->GetZoneId(), summon_player->GetMapId(), summon_player->GetInstanceID(), summon_player->GetPosition());
                ++summon_count;
            }
            else if (faction == -1)
            {
                plr->SummonRequest(summon_player->getGuidLow(), summon_player->GetZoneId(), summon_player->GetMapId(), summon_player->GetInstanceID(), summon_player->GetPosition());
                ++summon_count;
            }

        }
    }

    sGMLog.writefromsession(m_session, "requested a mass summon of %u players.", summon_count);

    objmgr._playerslock.ReleaseReadLock();

    return true;
}
Example #15
0
    static bool HandleGMTicketUnAssignCommand(ChatHandler* handler, char const* args)
    {
        if (!*args)
            return false;

        uint32 ticketId = atoi(args);
        GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
        if (!ticket || ticket->IsClosed())
        {
            handler->SendSysMessage(LANG_COMMAND_TICKETNOTEXIST);
            return true;
        }
        // Ticket must be assigned
        if (!ticket->IsAssigned())
        {
            handler->PSendSysMessage(LANG_COMMAND_TICKETNOTASSIGNED, ticket->GetId());
            return true;
        }

        // Get security level of player, whom this ticket is assigned to
        uint32 security = SEC_PLAYER;
        Player* assignedPlayer = ticket->GetAssignedPlayer();
        if (assignedPlayer && assignedPlayer->IsInWorld())
            security = assignedPlayer->GetSession()->GetSecurity();
        else
        {
            uint64 guid = ticket->GetAssignedToGUID();
            uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid);
            security = AccountMgr::GetSecurity(accountId, realmID);
        }

        // Check security
        //! If no m_session present it means we're issuing this command from the console
        uint32 mySecurity = handler->GetSession() ? handler->GetSession()->GetSecurity() : SEC_CONSOLE;
        if (security > mySecurity)
        {
            handler->SendSysMessage(LANG_COMMAND_TICKETUNASSIGNSECURITY);
            return true;
        }

        std::string assignedTo = ticket->GetAssignedToName(); // copy assignedto name because we need it after the ticket has been unnassigned
        SQLTransaction trans = SQLTransaction(NULL);
        ticket->SetUnassigned();
        ticket->SaveToDB(trans);
        sTicketMgr->UpdateLastChange();

        std::string msg = ticket->FormatMessageString(*handler, NULL, assignedTo.c_str(),
            handler->GetSession() ? handler->GetSession()->GetPlayer()->GetName().c_str() : "Console", NULL);
        handler->SendGlobalGMSysMessage(msg.c_str());

        return true;
    }
Example #16
0
    static bool HandleNpcBotDistanceCommand(ChatHandler* handler, const char* args)
    {
        Player* owner = handler->GetSession()->GetPlayer();
        if (!*args)
        {
            if (owner->HaveBot())
            {
                handler->PSendSysMessage("bot follow distance is %u", owner->GetBotFollowDist());
                handler->SetSentErrorMessage(true);
                return false;
            }
            handler->PSendSysMessage(".npcbot distance");
            handler->PSendSysMessage("Sets 'distance to target' at which bots will follow you");
            handler->PSendSysMessage("if set to 0, bots will not attack anything unless you point them");
            handler->PSendSysMessage("min: 0, max: 75");
            handler->SetSentErrorMessage(true);
            return false;
        }
        char* distance = strtok((char*)args, " ");
        int8 dist = -1;

        if (distance)
            dist = (int8)atoi(distance);

        if (dist >= 0 && dist <= 75)
        {
            owner->SetBotFollowDist(dist);
            if (!owner->IsInCombat() && owner->HaveBot())
                owner->GetBotMgr()->SendBotCommandState(COMMAND_FOLLOW);

            Group* gr = owner->GetGroup();
            if (gr && owner->GetMap()->Instanceable() && /*gr->isRaidGroup() &&*/ gr->IsLeader(owner->GetGUID()))
            {
                for (GroupReference* itr = gr->GetFirstMember(); itr != NULL; itr = itr->next())
                {
                    Player* pl = itr->GetSource();
                    if (pl && pl->IsInWorld() && pl->GetMap() == owner->GetMap())
                    {
                        pl->SetBotFollowDist(dist);
                        if (!pl->IsInCombat() && pl->HaveBot())
                            pl->GetBotMgr()->SendBotCommandState(COMMAND_FOLLOW);
                    }
                }
            }
            handler->PSendSysMessage("bot follow distance set to %u", dist);
            return true;
        }
        handler->SendSysMessage("follow distance should be between 0 and 75");
        handler->SetSentErrorMessage(true);
        return false;
    }
Example #17
0
void
World::SendPacketToZone(WorldPacket *packet, uint32 zoneId)
{
	ZThread::Guard<ZThread::Mutex> guard(m_sessions_lock);
    SessionMap::iterator itr;
    for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
    {
		Player* cPlayer = itr->second->GetPlayer();
        if (!cPlayer || !cPlayer->IsInWorld())	continue;
		if (cPlayer->GetZoneId() == zoneId)
			itr->second->SendPacket(packet);
		cPlayer=NULL;
    }
}
Example #18
0
// select opcodes appropriate for processing in Map::Update context for current session state
static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& opHandle)
{
    // we do not process thread-unsafe packets
    if (opHandle.packetProcessing == PROCESS_THREADUNSAFE)
        return false;

    // we do not process not loggined player packets
    Player * plr = session->GetPlayer();
    if (!plr)
        return false;

    // in Map::Update() we do not process packets where player is not in world!
    return plr->IsInWorld();
}
Example #19
0
void WorldSession::HandleIgnoreTrade(WorldPacket & recv_data)
{
	if(!_player->IsInWorld() || _player->mTradeTarget == 0)
		return;

	uint32 TradeStatus = TRADE_STATUS_PLAYER_IGNORED;

	Player* pTarget = _player->GetTradeTarget();
	if(pTarget == NULL || !pTarget->IsInWorld())
		TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;

	_player->ResetTradeVariables();

	SendTradeStatus(TradeStatus);
}
Example #20
0
bool ChatHandler::HandleGMTicketRemoveByIdCommand(const char* args, WorldSession *m_session)
{
	uint64 ticketGuid = (args ? atoi(args) : 0);
	if(!ticketGuid)
	{
		RedSystemMessage(m_session, "You must specify a ticket id.");
		return true;
	}

	Player *cplr = m_session->GetPlayer();
	Channel *chn = channelmgr.GetChannel(sWorld.getGmClientChannel().c_str(), cplr);
	if(!chn)
		return false;

	GM_Ticket *ticket = objmgr.GetGMTicket(ticketGuid);
	if(ticket == NULL || ticket->deleted)
	{
		chn->Say(cplr, "GmTicket:0:Ticket not found.", cplr, true);
		return true;
	}

	if(ticket->assignedToPlayer != 0 && ticket->assignedToPlayer != cplr->GetGUID() && !cplr->GetSession()->CanUseCommand('z'))
	{
		chn->Say(cplr, "GmTicket:0:Ticket is assigned to another GM.", cplr, true);
		return true;
	}

	Player* plr = objmgr.GetPlayer((uint32)ticket->playerGuid);

	std::stringstream ss;
	ss << "GmTicket:" << GM_TICKET_CHAT_OPCODE_REMOVED;
	ss << ":" << ticket->guid;
	chn->Say(cplr, ss.str().c_str(), NULL, true);

	objmgr.RemoveGMTicket(ticket->guid);

	if(!plr)
		return true;
	if(!plr->IsInWorld())
		return true;

	// Notify player about removing ticket
	WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4);
	data << uint32(9);
	plr->GetSession()->SendPacket( &data );

	return true;
}
Example #21
0
void WorldSession::HandleSetTradeItem(WorldPacket & recv_data)
{
	if(!_player->IsInWorld() || _player->mTradeTarget == 0)
		return;

	CHECK_PACKET_SIZE(recv_data, 3);

	uint8 TradeSlot = recv_data.contents()[0];
	int8 SourceBag = recv_data.contents()[1];
	uint8 SourceSlot = recv_data.contents()[2];

	Player* pTarget = _player->GetTradeTarget();
	if(pTarget == NULL || !pTarget->IsInWorld() || TradeSlot > 6)
		return;

	Item* pItem = _player->GetItemInterface()->GetInventoryItem(SourceBag, SourceSlot);
	if( pItem == NULL )
		return;

	if(pItem->IsContainer())
	{
		if( pItem->IsContainer() && TO_CONTAINER(pItem)->HasItems() )
		{
			_player->GetItemInterface()->BuildInventoryChangeError( pItem, NULL, INV_ERR_CANT_TRADE_EQUIP_BAGS);
			return;
		}
	}

	for(uint32 i = 0; i < 7; ++i)
	{
		// duping little shits
		if(_player->mTradeItems[i] == pItem || pTarget->mTradeItems[i] == pItem)
		{
			sCheatLog.writefromsession(this, "tried to dupe an item through trade");
			Disconnect();

			uint8 TradeStatus = TRADE_STATUS_CANCELLED;
			if( pTarget->m_session && pTarget->m_session->GetSocket())
				pTarget->m_session->SendTradeStatus(TradeStatus);
			return;
		}
	}

	_player->mTradeItems[TradeSlot] = pItem;
	_player->SendTradeUpdate();
}
bool ChatHandler::HandleGMTicketUnAssignCommand(const char* args)
{
    if (!*args)
        return false;

    uint32 ticketId = atoi(args);
    GmTicket *ticket = sTicketMgr->GetTicket(ticketId);
    if (!ticket || ticket->IsClosed())
    {
        SendSysMessage(LANG_COMMAND_TICKETNOTEXIST);
        return true;
    }
    // Ticket must be assigned
    if (!ticket->IsAssigned())
    {
        PSendSysMessage(LANG_COMMAND_TICKETNOTASSIGNED, ticket->GetId());
        return true;
    }
    // Get security level of player, whom this ticket is assigned to
    uint32 security = SEC_PLAYER;
    Player* assignedPlayer = ticket->GetAssignedPlayer();
    if (assignedPlayer && assignedPlayer->IsInWorld())
        security = assignedPlayer->GetSession()->GetSecurity();
    else
    {
        uint64 guid = ticket->GetAssignedToGUID();
        uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid);
        security = AccountMgr::GetSecurity(accountId, realmID);
    }
    // Check security
    Player* player = m_session->GetPlayer();
    if (security > uint32(player->GetSession()->GetSecurity()))
    {
        SendSysMessage(LANG_COMMAND_TICKETUNASSIGNSECURITY);
        return true;
    }

    SQLTransaction trans = SQLTransaction(NULL);
    ticket->SetUnassigned();
    ticket->SaveToDB(trans);
    sTicketMgr->UpdateLastChange();

    std::string msg = ticket->FormatMessageString(*this, NULL, ticket->GetAssignedToName().c_str(), player->GetName(), NULL);
    SendGlobalGMSysMessage(msg.c_str());
    return true;
}
Example #23
0
bool ChatHandler::HandleGMTicketReleaseCommand(const char* args, WorldSession *m_session)
{
	uint64 ticketGuid = (args ? atoi(args) : 0);
	if(!ticketGuid)
	{
		RedSystemMessage(m_session, "You must specify a ticket id.");
		return true;
	}

	Player *cplr = m_session->GetPlayer();
	Channel *chn = channelmgr.GetChannel(sWorld.getGmClientChannel().c_str(), cplr);
	if(!chn)
		return false;

	GM_Ticket *ticket = objmgr.GetGMTicket(ticketGuid);
	if(ticket == NULL || ticket->deleted)
	{
		chn->Say(cplr, "GmTicket:0:Ticket not found.", cplr, true);
		return true;
	}

	if(ticket->assignedToPlayer == 0)
	{
		chn->Say(cplr, "GmTicket:0:Ticket not assigned to a GM.", cplr, true);
		return true;
	}

	Player *plr = objmgr.GetPlayer((uint32)ticket->assignedToPlayer);
	if(!cplr->GetSession()->CanUseCommand('z') && plr != NULL && plr->IsInWorld() && plr->GetSession()->CanUseCommand('z'))
	{
		chn->Say(cplr, "GmTicket:0:You can not release tickets from admins.", cplr, true);
		return true;
	}
	
	ticket->assignedToPlayer = 0;
	objmgr.UpdateGMTicket(ticket);

	std::stringstream ss;
	ss << "GmTicket:" << GM_TICKET_CHAT_OPCODE_RELEASED;
	ss << ":" << ticket->guid;
	chn->Say(cplr, ss.str().c_str(), NULL, true);

	return true;
}
Example #24
0
void VisibleNotifier::SendToSelf()
{
    Player& player = *_camera.GetOwner();
    // at this moment i_clientGUIDs have guids that not iterate at grid level checks
    // but exist one case when this possible and object not out of range: transports
    if (Transport* transport = player.GetTransport())
    {
        for (Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
        {
            if (vis_guids.find((*itr)->GetGUID()) != vis_guids.end())
            {
                vis_guids.erase((*itr)->GetGUID());

                (*itr)->UpdateVisibilityOf(*itr, &player);
                player.UpdateVisibilityOf(&player, *itr, i_data, i_visibleNow);
            }
        }
    }

    for (Player::ClientGUIDs::const_iterator it = vis_guids.begin(); it != vis_guids.end(); ++it)
    {
        player.m_clientGUIDs.erase(*it);
        i_data.AddOutOfRangeGUID(*it);
        if (IS_PLAYER_GUID(*it))
        {
            Player* plr = ObjectAccessor::FindPlayer(*it);
            if (plr && plr->IsInWorld())
                plr->UpdateVisibilityOf(plr->GetCamera().GetBody(), &player);
        }
    }

    if (!i_data.HasData())
        return;

    WorldPacket packet;
    i_data.BuildPacket(&packet);
    player.SendPacketToSelf(&packet);

    for (std::set<WorldObject*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it)
    {
        if ((*it)->GetObjectGuid().IsUnit())
            player.SendInitialVisiblePackets((*it)->ToUnit());
    }
}
bool WorldSessionFilter::Process(WorldPacket* packet)
{
    if (packet->GetOpcode() >= NUM_MSG_TYPES)
        return true;

    OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];

    if (opHandle.packetProcessing == PROCESS_INPLACE)
        return true;

    if (opHandle.packetProcessing == PROCESS_THREADUNSAFE)
        return true;

    Player* player = m_pSession->GetPlayer();
    if (!player)
        return true;

    return (player->IsInWorld() == false);
}
Example #26
0
//we should process ALL packets when player is not in world/logged in
//OR packet handler is not thread-safe!
bool WorldSessionFilter::Process(WorldPacket* packet)
{
    OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];
    //check if packet handler is supposed to be safe
    if (opHandle.packetProcessing == PROCESS_INPLACE)
        return true;

    //thread-unsafe packets should be processed in World::UpdateSessions()
    if (opHandle.packetProcessing == PROCESS_THREADUNSAFE)
        return true;

    //no player attached? -> our client! ^^
    Player* player = m_pSession->GetPlayer();
    if (!player)
        return true;

    //lets process all packets for non-in-the-world player
    return (player->IsInWorld() == false);
}
Example #27
0
bool MapSessionFilter::Process(WorldPacket* packet)
{
    OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];

    //let's check if our opcode can be really processed in Map::Update()
    if (opHandle.packetProcessing == PROCESS_INPLACE)
        return true;

    //we do not process thread-unsafe packets
    if (opHandle.packetProcessing == PROCESS_THREADUNSAFE)
        return false;

    Player* player = m_pSession->GetPlayer();
    if (!player)
        return false;

    //in Map::Update() we do not process packets where player is not in world!
    return player->IsInWorld();
}
Example #28
0
bool ChatHandler::HandleGMTicketCompleteCommand(const char* args)
{
    if (!*args)
        return false;

    uint64 tguid = atoi(args);
    GM_Ticket *ticket = sTicketMgr->GetGMTicket(tguid);
    if (!ticket || ticket->closed != 0 || ticket->completed)
    {
        SendSysMessage(LANG_COMMAND_TICKETNOTEXIST);
        return true;
    }

    Player *plr = sObjectMgr->GetPlayer(ticket->playerGuid);
    if (plr && plr->IsInWorld())
        plr->GetSession()->SendGMTicketResponse(ticket);
    sTicketMgr->UpdateLastChange();
    return true;
}
Example #29
0
bool ChatHandler::HandleGMTicketUnAssignCommand(const char* args)
{
    if (!*args)
        return false;

    uint64 ticketGuid = atoi(args);
    Player *cplr = m_session->GetPlayer();
    GM_Ticket *ticket = sTicketMgr->GetGMTicket(ticketGuid);

    if (!ticket|| ticket->closed != 0)
    {
        SendSysMessage(LANG_COMMAND_TICKETNOTEXIST);
        return true;
    }
    if (ticket->assignedToGM == 0)
    {
        PSendSysMessage(LANG_COMMAND_TICKETNOTASSIGNED, ticket->guid);
        return true;
    }

    std::string gmname;
    sObjectMgr->GetPlayerNameByGUID(ticket->assignedToGM, gmname);
    Player *plr = sObjectMgr->GetPlayer(ticket->assignedToGM);
    if (plr && plr->IsInWorld() && plr->GetSession()->GetSecurity() > cplr->GetSession()->GetSecurity())
    {
        SendSysMessage(LANG_COMMAND_TICKETUNASSIGNSECURITY);
        return true;
    }

    std::stringstream ss;
    ss << PGetParseString(LANG_COMMAND_TICKETLISTGUID, ticket->guid);
    ss << PGetParseString(LANG_COMMAND_TICKETLISTNAME, ticket->name.c_str());
    ss << PGetParseString(LANG_COMMAND_TICKETLISTASSIGNEDTO, gmname.c_str());
    ss << PGetParseString(LANG_COMMAND_TICKETLISTUNASSIGNED, cplr->GetName());
    SendGlobalGMSysMessage(ss.str().c_str());
    ticket->assignedToGM = 0;
    if (ticket->escalated != TICKET_UNASSIGNED && ticket->escalated != TICKET_IN_ESCALATION_QUEUE)
        ticket->escalated--;
    sTicketMgr->AddOrUpdateGMTicket(*ticket);
    sTicketMgr->UpdateLastChange();
    return true;
}
Example #30
0
        void JustDied(Unit* who)
        {
            if(!who)
                return;

            Player* pKiller = who->ToPlayer();
            if(!pKiller || !pKiller->IsInWorld())
                return;

            if(who->GetTypeId() == TYPEID_PLAYER)
            {
                if(who->ToPlayer()->GetQuestStatus(QUEST_RIVENWOOD_CAPTIVES) == QUEST_STATUS_INCOMPLETE)
                {
                    if(urand(0, 3) == 0)
                        me->CastSpell(who, SPELL_QUEST, true);
                    else
                        me->CastSpell(who, SPELL_NO_QUEST, true);
                } else me->CastSpell(who, SPELL_NO_QUEST, true);
            } else me->CastSpell(who, SPELL_NO_QUEST, true);
        }