Example #1
0
/// Logging helper for unexpected opcodes
void WorldSession::LogUnexpectedOpcode(WorldPacket const& packet, const char* reason) const
{
    sLog.outError("SESSION: received unexpected opcode %s (0x%.4X) %s",
                  packet.GetOpcodeName(),
                  packet.GetOpcode(),
                  reason);
}
Example #2
0
bool ChatHandler::HandleCastSpellNECommand(const char* args, WorldSession* m_session)
{
	Unit* caster = m_session->GetPlayer();
	Unit* target = getSelectedChar(m_session, false);
	if(!target)
		target = getSelectedCreature(m_session, false);
	if(!target)
	{
		RedSystemMessage(m_session, "Must select a char or creature.");
		return false;
	}

	uint32 spellId = atol(args);
	SpellEntry* spellentry = dbcSpell.LookupEntryForced(spellId);
	if(!spellentry)
	{
		RedSystemMessage(m_session, "Invalid spell id!");
		return false;
	}
	BlueSystemMessage(m_session, "Casting spell %d on target.", spellId);

	WorldPacket data;

	data.Initialize(SMSG_SPELL_START);
	data << caster->GetNewGUID();
	data << caster->GetNewGUID();
	data << spellId;
	data << uint8(0);
	data << uint16(0);
	data << uint32(0);
	data << uint16(2);
	data << target->GetGUID();
	//		WPARCPRO_ASSERT(   data.size() == 36);
	m_session->SendPacket(&data);

	data.Initialize(SMSG_SPELL_GO);
	data << caster->GetNewGUID();
	data << caster->GetNewGUID();
	data << spellId;
	data << uint8(0) << uint8(1) << uint8(1);
	data << target->GetGUID();
	data << uint8(0);
	data << uint16(2);
	data << target->GetGUID();
	//		WPARCPRO_ASSERT(   data.size() == 42);
	m_session->SendPacket(&data);

	switch(target->GetTypeId())
	{
		case TYPEID_PLAYER:
			if(caster != target)
				sGMLog.writefromsession(m_session, "cast spell %d on PLAYER %s", spellId, TO< Player* >(target)->GetName());
			break;
		case TYPEID_UNIT:
			sGMLog.writefromsession(m_session, "cast spell %d on CREATURE %u [%s], sqlid %u", spellId, TO< Creature* >(target)->GetEntry(), TO< Creature* >(target)->GetCreatureInfo()->Name, TO< Creature* >(target)->GetSQL_id());
			break;
	}

	return true;
}
Example #3
0
void WorldSession::HandleGMSurveySubmit( WorldPacket & recv_data)
{
    // GM survey is shown after SMSG_GM_TICKET_STATUS_UPDATE with status = 3
    CHECK_PACKET_SIZE(recv_data,4+4);
    uint32 x;
    recv_data >> x;                                         // answer range? (6 = 0-5?)
    sLog.outDebug("SURVEY: X = %u", x);

    uint8 result[10];
    memset(result, 0, sizeof(result));
    for( int i = 0; i < 10; ++i)
    {
        CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+4);
        uint32 questionID;
        recv_data >> questionID;                            // GMSurveyQuestions.dbc
        if (!questionID)
            break;

        CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1+1);
        uint8 value;
        std::string unk_text;
        recv_data >> value;                                 // answer
        recv_data >> unk_text;                              // always empty?

        result[i] = value;
        sLog.outDebug("SURVEY: ID %u, value %u, text %s", questionID, value, unk_text.c_str());
    }

    CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1);
    std::string comment;
    recv_data >> comment;                                   // addional comment
    sLog.outDebug("SURVEY: comment %s", comment.c_str());

    // TODO: chart this data in some way
}
Example #4
0
void ObjectAccessor::Update(uint32 /*diff*/)
{
    UpdateDataMapType update_players;

    // Critical section
    {
        ACE_GUARD(LockType, g, i_updateGuard);

        while (!i_objects.empty())
        {
            Object* obj = *i_objects.begin();
            ASSERT(obj && obj->IsInWorld());
            i_objects.erase(i_objects.begin());
            obj->BuildUpdate(update_players);
        }
    }

    WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000
    for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
    {
        iter->second.BuildPacket(&packet);
        iter->first->GetSession()->SendPacket(&packet);
        packet.clear();                                     // clean the string
    }
}
Example #5
0
void WorldSession::HandleChannelVoiceOnOpcode(WorldPacket& recvData)
{
    TC_LOG_DEBUG("network", "WORLD: CMSG_CHANNEL_VOICE_ON");
    // Enable Voice button in channel context menu
    recvData.ReadString(recvData.ReadBits(8));
    //channel->EnableVoice(recvData.GetOpcode() == CMSG_CHANNEL_VOICE_ON);
}
Example #6
0
void WorldSession::HandleMoveRootAck(WorldPacket& recv_data)
{
    DEBUG_LOG("WORLD: CMSG_FORCE_MOVE_ROOT_ACK");
    ObjectGuid guid;
    recv_data >> guid;

    // now can skip not our packet
    if (_player->GetObjectGuid() != guid)
    {
        recv_data.rpos(recv_data.wpos());                   // prevent warnings spam
        return;
    }
    MovementInfo movementInfo;
    recv_data.read_skip<uint32>();                          // unk
    recv_data >> movementInfo;
    movementInfo.UpdateTime(recv_data.GetPacketTime());

    if (!VerifyMovementInfo(movementInfo))
        return;

    if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data))
        return;

    // Position change
    HandleMoverRelocation(movementInfo);
    _player->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode());

    WorldPacket data(MSG_MOVE_ROOT, recv_data.size());
    data << _player->GetPackGUID();
    movementInfo.Write(data);
    _player->SendMovementMessageToSet(std::move(data), true, _player);
}
Example #7
0
void WorldSession::HandleReadItemOpcode(WorldPacket& recv_data)
{
    // DEBUG_LOG("WORLD: Received opcode CMSG_READ_ITEM");

    uint8 bag, slot;
    recv_data >> bag >> slot;

    // sLog.outDetail("STORAGE: Read bag = %u, slot = %u", bag, slot);
    Item* pItem = _player->GetItemByPos(bag, slot);

    if (pItem && pItem->GetProto()->PageText)
    {
        WorldPacket data;

        InventoryResult msg = _player->CanUseItem(pItem);
        if (msg == EQUIP_ERR_OK)
        {
            data.Initialize(SMSG_READ_ITEM_OK, 8);
            DETAIL_LOG("STORAGE: Item page sent");
        }
        else
        {
            data.Initialize(SMSG_READ_ITEM_FAILED, 8);
            DETAIL_LOG("STORAGE: Unable to read item");
            _player->SendEquipError(msg, pItem, nullptr);
        }
        data << ObjectGuid(pItem->GetObjectGuid());
        SendPacket(&data);
    }
    else
        _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
}
void WorldSession::HandleEnterPlayerVehicle(WorldPacket& data)
{
    // Read guid
    ObjectGuid guid;

	guid[5] = data.ReadBit();
 	guid[0] = data.ReadBit();
 	guid[3] = data.ReadBit();
 	guid[1] = data.ReadBit();
 	guid[7] = data.ReadBit();
 	guid[2] = data.ReadBit();
 	guid[6] = data.ReadBit();
 	guid[4] = data.ReadBit();

	data.ReadByteSeq(guid[7]);
 	data.ReadByteSeq(guid[6]);
 	data.ReadByteSeq(guid[0]);
 	data.ReadByteSeq(guid[3]);
 	data.ReadByteSeq(guid[5]);
 	data.ReadByteSeq(guid[4]);
 	data.ReadByteSeq(guid[1]);
 	data.ReadByteSeq(guid[2]);

    if (Player* player = ObjectAccessor::FindPlayer(guid))
    {
        if (!player->GetVehicleKit())
            return;
        if (!player->IsInRaidWith(_player))
            return;
        if (!player->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
            return;

        _player->EnterVehicle(player);
    }
}
Example #9
0
WorldPacket * Mailbox::BuildMailboxListingPacket()
{
	WorldPacket * data = new WorldPacket(SMSG_MAIL_LIST_RESULT, 500);
	MessageMap::iterator itr;
	uint32 count = 0;
	uint32 t = (uint32)UNIXTIME;
	*data << uint8(0);	 // size placeholder

	for(itr = Messages.begin(); itr != Messages.end(); ++itr)
	{
		if(itr->second.expire_time && t > itr->second.expire_time)
			continue;	   // expired mail -> skip it

		if((uint32)UNIXTIME < itr->second.delivery_time)
			continue;		// undelivered
		
		if(itr->second.AddMessageDataToPacket(*data))
			++count;
		
		if(count == 50)
			break;
	}

	const_cast<uint8*>(data->contents())[0] = count;

	// do cleanup on request mail
	CleanupExpiredMessages();
	return data;
}
Example #10
0
void WorldSocket::OutPacket(uint16 opcode, size_t len, const void* data)
{
	OUTPACKET_RESULT res;
	if( (len + 10) > WORLDSOCKET_SENDBUF_SIZE )
	{
		printf("WARNING: Tried to send a packet of %u bytes (which is too large) to a socket. Opcode was: %u (0x%03X)\n", (unsigned int)len, (unsigned int)opcode, (unsigned int)opcode);
		return;
	}

	res = _OutPacket(opcode, len, data);
	if(res == OUTPACKET_RESULT_SUCCESS)
		return;

	if(res == OUTPACKET_RESULT_NO_ROOM_IN_BUFFER)
	{
		/* queue the packet */
		queueLock.Acquire();
		//WorldPacket * pck = new WorldPacket(opcode, len);
		WorldPacket * pck = g_bufferPool.Allocate(len);
		pck->SetOpcode(opcode);
		if(len) pck->append((const uint8*)data, len);
		_queue.Push(pck);
		queueLock.Release();
	}
}
Example #11
0
//called when mail is read
void WorldSession::HandleMailMarkAsRead(WorldPacket& recvData)
{
    ObjectGuid mailbox;
    uint32 mailId;

    recvData >> mailId;

    recvData.ReadGuidMask(mailbox, 0, 2, 3);
    recvData.ReadBit();
    recvData.ReadGuidMask(mailbox, 4, 6, 7, 1, 5);
    recvData.FlushBits();

    recvData.ReadGuidBytes(mailbox, 1, 7, 2, 5, 6, 3, 4, 0);

    if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
        return;

    if (Mail* mail = _player->GetMail(mailId))
    {
        if (_player->unReadMails)
            --_player->unReadMails;

        mail->checked |= MAIL_CHECK_MASK_READ;
        mail->state = MAIL_STATE_CHANGED;

        _player->m_mailsUpdated = true;
    }
}
Example #12
0
void WorldSession::HandleChannelVoiceOnOpcode(WorldPacket& recv_data)
{
    DEBUG_LOG("WORLD: CMSG_CHANNEL_VOICE_ON");
    // Enable Voice button in channel context menu
    std::string channelName = recv_data.ReadString(recv_data.ReadBits(8));
    recv_data.hexlike();
}
Example #13
0
WorldPacket * Mailbox::MailboxTimePacket()
{

	WorldPacket * data = new WorldPacket(MSG_QUERY_NEXT_MAIL_TIME, 100);
	uint32 count = 0;
	MessageMap::iterator iter;


	*data << uint32(0) << uint32(0);

	for( iter = Messages.begin(); iter != Messages.end(); ++iter )
	{
		if(AddMessageToTimePacket(* data, &iter->second))
		{
			++count;
		}
	}

	if(count==0)
	{
		data->put(0, uint32(0xc7a8c000));
//		*(uint32*)(data->contents()[0])=0xc7a8c000;
	}
	else
	{
		data->put(4, uint32(count));
//		*(uint32*)(data->contents()[0])=uint32(0);
//		*(uint32*)(data->contents()[4])=count;
	}
	return data;
}
Example #14
0
/// Logging helper for unexpected opcodes
void WorldSession::LogUnprocessedTail(WorldPacket const& packet) const
{
    sLog.outError("SESSION: opcode %s (0x%.4X) have unprocessed tail data (read stop at " SIZEFMTD " from " SIZEFMTD ")",
                  packet.GetOpcodeName(),
                  packet.GetOpcode(),
                  packet.rpos(), packet.wpos());
}
Example #15
0
void WorldSession::HandleWardenDataOpcode(WorldPacket& recvData)
{
    _warden->DecryptData(const_cast<uint8*>(recvData.contents()), recvData.size());
    uint8 opcode;
    recvData >> opcode;
    sLog->outDebug(LOG_FILTER_WARDEN, "Got packet, opcode %02X, size %u", opcode, uint32(recvData.size()));
    recvData.hexlike();

    switch (opcode)
    {
        case WARDEN_CMSG_MODULE_MISSING:
            _warden->SendModuleToClient();
            break;
        case WARDEN_CMSG_MODULE_OK:
            _warden->RequestHash();
            break;
        case WARDEN_CMSG_CHEAT_CHECKS_RESULT:
            _warden->HandleData(recvData);
            break;
        case WARDEN_CMSG_MEM_CHECKS_RESULT:
            sLog->outDebug(LOG_FILTER_WARDEN, "NYI WARDEN_CMSG_MEM_CHECKS_RESULT received!");
            break;
        case WARDEN_CMSG_HASH_RESULT:
            _warden->HandleHashResult(recvData);
            _warden->InitializeModule();
            break;
        case WARDEN_CMSG_MODULE_FAILED:
            sLog->outDebug(LOG_FILTER_WARDEN, "NYI WARDEN_CMSG_MODULE_FAILED received!");
            break;
        default:
            sLog->outDebug(LOG_FILTER_WARDEN, "Got unknown warden opcode %02X of size %u.", opcode, uint32(recvData.size() - 1));
            break;
    }
}
Example #16
0
void Mailbox::FillTimePacket(WorldPacket& data)
{
	uint32 c = 0;
	MessageMap::iterator iter = Messages.begin();
	data << uint32(0) << uint32(0);

	for(; iter != Messages.end(); ++iter)
	{
		if(iter->second.deleted_flag == 0 && iter->second.read_flag == 0 && (uint32)UNIXTIME >= iter->second.delivery_time)
		{
			// unread message, w00t.
			++c;
			data << uint64(iter->second.sender_guid);
			data << uint32(0);
			data << uint32(0);// money or smth?
			data << uint32(iter->second.stationary);
			//data << float(UNIXTIME-iter->second.delivery_time);
			data << float(-9.0f);	// maybe the above?
		}
	}

	if(c==0)
	{
		*(uint32*)(&data.contents()[0])=0xc7a8c000;
	}
	else
	{
		*(uint32*)(&data.contents()[4])=c;
	}
}
Example #17
0
void WorldSession::HandleFeatherFallAck(WorldPacket &recv_data)
{
    DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK size %u", recv_data.wpos());

    ObjectGuid guid;
    MovementInfo movementInfo;
    recv_data >> guid; // guid
    recv_data.read_skip<uint32>(); // counter
    recv_data >> movementInfo;
    movementInfo.UpdateTime(recv_data.GetPacketTime());

    if (guid != _clientMoverGuid)
        return;

    if (!VerifyMovementInfo(movementInfo))
        return;

    if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data))
        return;

    // Position change
    HandleMoverRelocation(movementInfo);
    _player->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode());

    WorldPacket data(MSG_MOVE_FEATHER_FALL, recv_data.size());
    data << guid.WriteAsPacked();
    movementInfo.Write(data);
    _player->SendMovementMessageToSet(std::move(data), true, _player);
}
Example #18
0
void WorldSession::HandleReadItem(WorldPacket & recv_data)
{
    //sLog.outDebug("WORLD: CMSG_READ_ITEM");

    uint8 bag, slot;
    recv_data >> bag >> slot;

    //sLog.outDetail("STORAGE: Read bag = %u, slot = %u", bag, slot);
    Item *pItem = _player->GetItemByPos(bag, slot);

    if (pItem && pItem->GetProto()->PageText)
    {
        WorldPacket data;

        uint8 msg = _player->CanUseItem(pItem);
        if (msg == EQUIP_ERR_OK)
        {
            data.Initialize (SMSG_READ_ITEM_OK, 8);
            sLog.outDetail("STORAGE: Item page sent");
        }
        else
        {
            data.Initialize(SMSG_READ_ITEM_FAILED, 8);
            sLog.outDetail("STORAGE: Unable to read item");
            _player->SendEquipError(msg, pItem, NULL);
        }
        data << pItem->GetGUID();
        SendPacket(&data);
    }
    else
        _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
}
Example #19
0
void WorldSession::HandleMoveKnockBackAck( WorldPacket & recv_data )
{
    DEBUG_LOG("CMSG_MOVE_KNOCK_BACK_ACK");

    Unit *mover = _player->GetMover();
    Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;

    // ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
    if(plMover && plMover->IsBeingTeleported())
    {
        recv_data.rpos(recv_data.wpos());                   // prevent warnings spam
        return;
    }

    ObjectGuid guid;
    MovementInfo movementInfo;

    recv_data >> guid.ReadAsPacked();
    recv_data >> Unused<uint32>();                          // knockback packets counter
    recv_data >> movementInfo;

    if (!VerifyMovementInfo(movementInfo, guid))
        return;

    HandleMoverRelocation(movementInfo);

    WorldPacket data(MSG_MOVE_KNOCK_BACK, recv_data.size() + 15);
    data << mover->GetPackGUID();
    data << movementInfo;
    data << movementInfo.GetJumpInfo().sinAngle;
    data << movementInfo.GetJumpInfo().cosAngle;
    data << movementInfo.GetJumpInfo().xyspeed;
    data << movementInfo.GetJumpInfo().velocity;
    mover->SendMessageToSetExcept(&data, _player);
}
Example #20
0
void ClusterInterface::HandlePackedPlayerInfo(WorldPacket & pck)
{
	uint32 real_size;
	pck >> real_size;
	uLongf rsize = real_size;

	ByteBuffer buf(real_size);
	buf.resize(real_size);

	if(uncompress((uint8*)buf.contents(), &rsize, pck.contents() + 4, (u_long)pck.size() - 4) != Z_OK)
	{
		printf("Uncompress of player info failed.\n");
		return;
	}

	RPlayerInfo * pi;
	uint32 count;
	buf >> count;
	for(uint32 i = 0; i < count; ++i)
	{
		pi = new RPlayerInfo;
		pi->Unpack(buf);
		_onlinePlayers[pi->Guid] = pi;
	}
}
Example #21
0
void WorldSession::HandleWardenDataOpcode(WorldPacket& recv_data)
{
    m_Warden->DecryptData(const_cast<uint8*>(recv_data.contents()), recv_data.size());
    uint8 Opcode;
    recv_data >> Opcode;
    sLog.outDebug("WARDEN: Got packet, opcode %02X, size %u", Opcode, recv_data.size());
    recv_data.hexlike();

    switch (Opcode)
    {
        case WARDEN_CMSG_MODULE_MISSING:
            m_Warden->SendModuleToClient();
            break;
        case WARDEN_CMSG_MODULE_OK:
            m_Warden->RequestHash();
            break;
        case WARDEN_CMSG_CHEAT_CHECKS_RESULT:
            m_Warden->HandleData(recv_data);
            break;
        case WARDEN_CMSG_MEM_CHECKS_RESULT:
            sLog.outDebug("WARDEN: NYI WARDEN_CMSG_MEM_CHECKS_RESULT received!");
            break;
        case WARDEN_CMSG_HASH_RESULT:
            m_Warden->HandleHashResult(recv_data);
            m_Warden->InitializeModule();
            break;
        case WARDEN_CMSG_MODULE_FAILED:
            sLog.outDebug("WARDEN: NYI WARDEN_CMSG_MODULE_FAILED received!");
            break;
        default:
            sLog.outError("Got unknown warden opcode %02X of size %u.", Opcode, recv_data.size() - 1);
            break;
    }
}
Example #22
0
//This must be an event to stay in the correct context!
void Player::EventClusterMapChange(uint32 mapid, uint32 instanceid, LocationVector location)
{
	WorldPacket data;
	uint32 status = sInstanceMgr.PreTeleport(mapid, this, instanceid);
	if(status != INSTANCE_OK)
	{
		data.Initialize(SMSG_TRANSFER_ABORTED);
		data << mapid << status;
		GetSession()->SendPacket(&data);
		return;
	}

	if(instanceid)
		m_instanceId = instanceid;

	if(IsInWorld())
		RemoveFromWorld();

	data.Initialize(SMSG_NEW_WORLD);
	data << (uint32)mapid << location << location.o;
	GetSession()->SendPacket( &data );
	SetMapId(mapid);


	SetPlayerStatus(TRANSFER_PENDING);
	m_sentTeleportPosition = location;
	SetPosition(location);
	ResetHeartbeatCoords();
	z_axisposition = 0.0f;
}
Example #23
0
void WorldSession::HandleChannelJoin(WorldPacket& recvPacket)
{
    CHECK_INWORLD_RETURN

    CHECK_PACKET_SIZE(recvPacket, 1);
    std::string channelname, pass;
    uint32 channel_id;

    recvPacket >> channel_id;
    recvPacket.readBit();       // has voice
    recvPacket.readBit();       // zone update

    uint8 channelLength = recvPacket.readBits(8);
    uint8 passwordLength = recvPacket.readBits(8);

    channelname = recvPacket.ReadString(channelLength);
    pass = recvPacket.ReadString(passwordLength);

    if (sWorld.settings.gm.gmClientChannelName.size() && !stricmp(sWorld.settings.gm.gmClientChannelName.c_str(), channelname.c_str()) && !GetPermissionCount())
        return;

    Channel* channel = channelmgr.GetCreateChannel(channelname.c_str(), _player, channel_id);
    if (channel == nullptr)
        return;

    channel->AttemptJoin(_player, pass.c_str());
    LogDebugFlag(LF_OPCODE, "ChannelJoin %s", channelname.c_str());
}
void WorldSession::HandleReadItem(WorldPacket& recvData)
{
    //IC_LOG_DEBUG("network", "WORLD: CMSG_READ_ITEM");

    uint8 bag, slot;
    recvData >> bag >> slot;

    //IC_LOG_INFO("network", "STORAGE: Read bag = %u, slot = %u", bag, slot);
    Item* pItem = _player->GetItemByPos(bag, slot);

    if (pItem && pItem->GetTemplate()->PageText)
    {
        WorldPacket data;

        InventoryResult msg = _player->CanUseItem(pItem);
        if (msg == EQUIP_ERR_OK)
        {
            data.Initialize (SMSG_READ_ITEM_OK, 8);
            IC_LOG_INFO("network", "STORAGE: Item page sent");
        }
        else
        {
            data.Initialize(SMSG_READ_ITEM_FAILED, 8);
            IC_LOG_INFO("network", "STORAGE: Unable to read item");
            _player->SendEquipError(msg, pItem, NULL);
        }
        data << pItem->GetGUID();
        SendPacket(&data);
    }
    else
        _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
}
void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data)
{
    sLog->outDebug("WORLD: Recvd CMSG_DISMISS_CONTROLLED_VEHICLE");
    recv_data.hexlike();

    uint64 vehicleGUID = _player->GetCharmGUID();

    if (!vehicleGUID)                                        // something wrong here...
    {
        recv_data.rpos(recv_data.wpos());                   // prevent warnings spam
        return;
    }

    uint64 guid;

    recv_data.readPackGUID(guid);

    MovementInfo mi;
    mi.guid = guid;
    ReadMovementInfo(recv_data, &mi);

    _player->m_movementInfo = mi;

    _player->ExitVehicle();
}
Example #26
0
void WorldSession::HandleGuildAddRankOpcode(WorldPacket& recvPacket)
{
    DEBUG_LOG("WORLD: Received opcode CMSG_GUILD_ADD_RANK");

    recvPacket >> Unused<uint32>(); // rank id
    std::string rankname = recvPacket.ReadString(recvPacket.ReadBits(7));

    Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
    if (!guild)
    {
        SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD);
        return;
    }

    if (GetPlayer()->GetObjectGuid() != guild->GetLeaderGuid())
    {
        SendGuildCommandResult(GUILD_INVITE_S, "", ERR_GUILD_PERMISSIONS);
        return;
    }

    if (guild->GetRanksSize() >= GUILD_RANKS_MAX_COUNT)     // client not let create more 10 than ranks
        return;

    guild->CreateRank(rankname, GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK);

    guild->Query(this);
    guild->QueryRanks(this);
    guild->Roster();                                        // broadcast for tab rights update
}
Example #27
0
void Mailbox::FillTimePacket(WorldPacket& data)
{
    uint32_t c = 0;
    MessageMap::iterator iter = Messages.begin();
    data << uint32_t(0);
    data << uint32_t(0);

    for (; iter != Messages.end(); ++iter)
    {
        if (iter->second.checked_flag & MAIL_CHECK_MASK_READ)
            continue;

        if (iter->second.deleted_flag == 0 && (uint32_t)UNIXTIME >= iter->second.delivery_time)
        {
            ++c;
            data << uint64_t(iter->second.sender_guid);
            data << uint32_t(0);
            data << uint32_t(0);
            data << uint32_t(iter->second.stationery);
            data << float(-9.0f);
        }
    }

    if (c == 0)
        *(uint32_t*)(&data.contents()[0]) = 0xc7a8c000;
    else
        *(uint32_t*)(&data.contents()[4]) = c;

}
Example #28
0
void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_CALENDAR_ADD_EVENT");
    recv_data.hexlike();
    recv_data.rpos(recv_data.wpos());                       // set to end to avoid warnings spam

    //std::string unk1, unk2;
    //recv_data >> (std::string)unk1;
    //recv_data >> (std::string)unk2;

    //uint8   unk3, unk4;
    //uint32  unk5, unk6, unk7, unk8, unk9, count = 0;
    //recv_data >> (uint8)unk3;
    //recv_data >> (uint8)unk4;
    //recv_data >> (uint32)unk5;
    //recv_data >> (uint32)unk6;
    //recv_data >> (uint32)unk7;
    //recv_data >> (uint32)unk8;
    //recv_data >> (uint32)unk9;
    //if (!((unk9 >> 6) & 1))
    //{
    //    recv_data >> (uint32)count;
    //    if (count)
    //    {
    //        uint8 unk12, unk13;
    //        uint64 guid;
    //        for (int i=0; i<count; i++)
    //        {
    //            recv_data.readPackGUID(guid);
    //            recv_data >> (uint8)unk12;
    //            recv_data >> (uint8)unk13;
    //        }
    //    }
    //}
}
Example #29
0
void WorldSession::HandleMoveKnockBackAck(WorldPacket & recvData)
{
    ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_MOVE_KNOCK_BACK_ACK");

    uint64 guid;
    recvData.readPackGUID(guid);

    // pussywizard: typical check for incomming movement packets
    if (!_player->m_mover || !_player->m_mover->IsInWorld() || _player->m_mover->IsDuringRemoveFromWorld() || guid != _player->m_mover->GetGUID())
    {
        recvData.rfinish(); // prevent warnings spam
        return;
    }

    recvData.read_skip<uint32>();                          // unk

    MovementInfo movementInfo;
    movementInfo.guid = guid;
    ReadMovementInfo(recvData, &movementInfo);

    _player->m_mover->m_movementInfo = movementInfo;

    WorldPacket data(MSG_MOVE_KNOCK_BACK, 66);
    data.appendPackGUID(guid);
    _player->m_mover->BuildMovementPacket(&data);

    // knockback specific info
    data << movementInfo.jump.sinAngle;
    data << movementInfo.jump.cosAngle;
    data << movementInfo.jump.xyspeed;
    data << movementInfo.jump.zspeed;

    _player->SendMessageToSet(&data, false);
}
Example #30
0
void PacketLog::LogPacket(WorldPacket const& packet, Direction direction, boost::asio::ip::address const& addr, uint16 port, ConnectionType connectionType)
{
    std::lock_guard<std::mutex> lock(_logPacketLock);

    PacketHeader header;
    header.Direction = direction == CLIENT_TO_SERVER ? 0x47534d43 : 0x47534d53;
    header.ConnectionId = connectionType;
    header.ArrivalTicks = getMSTime();

    header.OptionalDataSize = sizeof(header.OptionalData);
    memset(header.OptionalData.SocketIPBytes, 0, sizeof(header.OptionalData.SocketIPBytes));
    if (addr.is_v4())
    {
        auto bytes = addr.to_v4().to_bytes();
        memcpy(header.OptionalData.SocketIPBytes, bytes.data(), bytes.size());
    }
    else if (addr.is_v6())
    {
        auto bytes = addr.to_v6().to_bytes();
        memcpy(header.OptionalData.SocketIPBytes, bytes.data(), bytes.size());
    }

    header.OptionalData.SocketPort = port;
    header.Length = packet.size() + sizeof(header.Opcode);
    header.Opcode = packet.GetOpcode();

    fwrite(&header, sizeof(header), 1, _file);
    if (!packet.empty())
        fwrite(packet.contents(), 1, packet.size(), _file);

    fflush(_file);
}