示例#1
0
void CreatureTextMgr::BuildMonsterChat(WorldPacket *data, WorldObject* source, ChatType msgtype, char const* text, Language language, uint64 whisperGuid) const
{
    if (!source)
        return;

    ChatMsg sendType = CHAT_MSG_MONSTER_SAY;
    switch (msgtype)
    {
        case CHAT_TYPE_YELL:
            sendType = CHAT_MSG_MONSTER_YELL;
            break;
        case CHAT_TYPE_TEXT_EMOTE:
            sendType = CHAT_MSG_MONSTER_EMOTE;
            break;
        case CHAT_TYPE_BOSS_EMOTE:
            sendType = CHAT_MSG_RAID_BOSS_EMOTE;
            break;
        case CHAT_TYPE_WHISPER:
            if (whisperGuid)
                sendType = CHAT_MSG_MONSTER_WHISPER;
            else
            {
                sLog->outError("CreatureTextMgr: WorldObject(%s) TypeId %u GuidLow %u sent CHAT_TYPE_WHISPER with targetGuid 0. Ignoring.", source->GetName(), uint32(source->GetTypeId()), source->GetGUIDLow());
                return;
            }
            break;
        case CHAT_TYPE_BOSS_WHISPER:
            if (whisperGuid)
                sendType = CHAT_MSG_RAID_BOSS_WHISPER;
            else
            {
                sLog->outError("CreatureTextMgr: WorldObject(%s) TypeId %u GuidLow %u sent CHAT_TYPE_BOSS_WHISPER with targetGuid 0. Ignoring.", source->GetName(), uint32(source->GetTypeId()), source->GetGUIDLow());
                return;
            }
            break;
        case CHAT_TYPE_SAY://default type
        default:
            break;
    }
    *data << (uint8)sendType;
    *data << (uint32)language;
    *data << (uint64)source->GetGUID();
    *data << (uint32)0;                                     // 2.1.0
    *data << (uint32)(strlen(source->GetName())+1);
    *data << source->GetName();
    *data << (uint64)whisperGuid;                           // Unit Target
    if (whisperGuid && !IS_PLAYER_GUID(whisperGuid))        //can only whisper players
    {
        sLog->outError("CreatureTextMgr: WorldObject(%s) TypeId %u GuidLow %u sent WHISPER msg to Non-Player target. Ignoring.", source->GetName(), uint32(source->GetTypeId()), source->GetGUIDLow());
        return;
        // *data << (uint32)1;                                 // target name length
        // *data << (uint8)0;                                  // target name
    }
    *data << (uint32)(strlen(text)+1);
    *data << text;
    *data << (uint8)0;                                      // ChatTag
}
示例#2
0
void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
{
    ;//sLog->outDetail("CMSG_PET_SPELL_AUTOCAST");
    uint64 guid;
    uint32 spellid;
    uint8  state;                                           //1 for on, 0 for off
    recvPacket >> guid >> spellid >> state;

    if (!_player->GetGuardianPet() && !_player->GetCharm())
        return;

    if (IS_PLAYER_GUID(guid))
        return;

	SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
	if (!spellInfo)
		return;

    Creature* checkPet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
    if (!checkPet || (checkPet != _player->GetGuardianPet() && checkPet != _player->GetCharm()))
    {
        sLog->outError("HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str());
        return;
    }

	Unit::ControlSet petsSet;
	if (checkPet->GetEntry() != GUID_ENPART(guid))
		petsSet.insert(checkPet);
	else
		petsSet = _player->m_Controlled;

	// Xinef: loop all pets with same entry (fixes partial state change for feral spirits)
	for (Unit::ControlSet::const_iterator itr = petsSet.begin(); itr != petsSet.end(); ++itr)
	{
		Unit* pet = *itr;
		if (checkPet->GetEntry() == GUID_ENPART(guid) && pet->GetEntry() != GUID_ENPART(guid))
			continue;

		// do not add not learned spells/ passive spells
		if (!pet->HasSpell(spellid) || !spellInfo->IsAutocastable())
			continue;

		CharmInfo* charmInfo = pet->GetCharmInfo();
		if (!charmInfo)
		{
			sLog->outError("WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
			continue;
		}

		if (pet->IsPet())
			((Pet*)pet)->ToggleAutocast(spellInfo, state);
		else
			pet->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, state);

		charmInfo->SetSpellAutocast(spellInfo, state);
	}
}
示例#3
0
Creature* ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const& u, uint64 guid)
{
    if (IS_PLAYER_GUID(guid))
        return NULL;

    if (IS_PET_GUID(guid))
        return GetPet(guid);

    return u.IsInWorld() ? u.GetMap()->GetCreature(guid) : NULL;
}
示例#4
0
Unit*
ObjectAccessor::GetUnit(WorldObject const &u, uint64 guid)
{
    if(!guid)
        return NULL;

    if(IS_PLAYER_GUID(guid))
        return FindPlayer(guid);

    return GetCreatureOrPetOrVehicle(u, guid);
}
void FollowMovementGenerator<Creature>::_updateSpeed(Creature* owner)
{
    // pet only sync speed with owner
    /// Make sure we are not in the process of a map change (IsInWorld)
	if (!IS_PLAYER_GUID(owner->GetOwnerGUID()) || !owner->IsInWorld() || !i_target.isValid() || i_target->GetGUID() != owner->GetOwnerGUID())
        return;

    owner->UpdateSpeed(MOVE_RUN, true);
    owner->UpdateSpeed(MOVE_WALK, true);
    owner->UpdateSpeed(MOVE_SWIM, true);
}
示例#6
0
            void AttackStart(Unit* who)
            {
                if (me->ToTempSummon())
                {
                    if (who->GetTypeId() == TYPEID_PLAYER || IS_PLAYER_GUID(who->GetOwnerGUID()))
                        if (Unit* summoner = me->ToTempSummon()->GetSummoner())
                            summoner->GetAI()->DoAction(ACTION_INFORM);
                    return;
                }

                ScriptedAI::AttackStart(who);
            }
示例#7
0
Unit*
ObjectAccessor::GetUnit(WorldObject const &u, uint64 guid)
{
    if(!guid)
        return NULL;

    if(IS_PLAYER_GUID(guid))
        return FindPlayer(guid);

    if (!u.IsInWorld())
        return NULL;

    return u.GetMap()->GetCreatureOrPetOrVehicle(guid);
}
示例#8
0
void WorldSession::HandleGuildFinderDeclineRecruit(WorldPacket& recvPacket)
{
    TC_LOG_DEBUG("network", "WORLD: Received CMSG_LF_GUILD_DECLINE_RECRUIT");

    ObjectGuid playerGuid;

    recvPacket.ReadBitSeq<3, 4, 0, 1, 6, 2, 5, 7>(playerGuid);
    recvPacket.ReadByteSeq<2, 6, 5, 1, 7, 0, 4, 3>(playerGuid);

    if (!IS_PLAYER_GUID(playerGuid))
        return;

    sGuildFinderMgr->RemoveMembershipRequest(GUID_LOPART(playerGuid), GetPlayer()->GetGuildId());
}
void WorldSession::HandleGuildFinderDeclineRecruit(WorldPacket& recvPacket)
{
    SF_LOG_DEBUG("network", "WORLD: Received CMSG_LF_GUILD_DECLINE_RECRUIT");

    ObjectGuid RecruitGUID;

    recvPacket.ReadGuidMask(RecruitGUID, 6, 7, 3, 1, 2, 0, 4, 5);
    recvPacket.ReadGuidBytes(RecruitGUID, 0, 7, 1, 6, 4, 3, 5, 2);
    
    if (!IS_PLAYER_GUID(RecruitGUID))
        return;

    sGuildFinderMgr->RemoveMembershipRequest(GUID_LOPART(RecruitGUID), GetPlayer()->GetGuildId());
}
示例#10
0
 static bool HandleNpcBotResetCommand(ChatHandler* handler, const char* /*args*/)
 {
     Player* owner = handler->GetSession()->GetPlayer();
     Player* master = NULL;
     bool all = false;
     uint64 guid = owner->GetTarget();
     if (!guid)
     {
         handler->PSendSysMessage(".npcbot reset");
         handler->PSendSysMessage("Reset selected npcbot, or all npcbots if used on self");
         handler->SetSentErrorMessage(true);
         return false;
     }
     if (IS_PLAYER_GUID(guid))
     {
         master = owner;
         all = true;
     }
     else if (IS_CREATURE_GUID(guid))
     {
         if (Creature* cre = ObjectAccessor::GetCreature(*owner, guid))
             master = cre->GetBotOwner();
     }
     if (master && master->GetGUID() == owner->GetGUID())
     {
         if (!master->HaveBot())
         {
             handler->PSendSysMessage("Npcbots are not found!");
             handler->SetSentErrorMessage(true);
             return false;
         }
         for (uint8 i = 0; i != master->GetMaxNpcBots(); ++i)
         {
             if (all)
                 master->RemoveBot(master->GetBotMap(i)->_Guid());
             else if (master->GetBotMap(i)->_Guid() == guid)
             {
                 master->RemoveBot(guid);
                 break;
             }
         }
         handler->SetSentErrorMessage(true);
         return true;
     }
     handler->PSendSysMessage(".npcbot reset");
     handler->PSendSysMessage("Reset selected npcbot. Cannot be used in combat");
     handler->SetSentErrorMessage(true);
     return false;
 }
示例#11
0
void
ObjectAccessor::WorldObjectChangeAccumulator::Visit(DynamicObjectMapType &m)
{
    for(DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
    {
        uint64 guid = iter->getSource()->GetCasterGUID();
        if(IS_PLAYER_GUID(guid))
        {
            //Caster may be NULL if DynObj is in removelist
            if(Player *caster = FindPlayer(guid))
                if (caster->GetUInt64Value(PLAYER_FARSIGHT) == iter->getSource()->GetGUID())
                    BuildPacket(caster);
        }
    }
}
示例#12
0
void SmartAI::EnterEvadeMode()
{
    // xinef: fixes strange jumps when charming SmartAI npc
    if (!me->IsAlive() || me->IsInEvadeMode())
        return;
    
    if (IS_PLAYER_GUID(me->GetCharmerGUID()) || me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
    {
        me->AttackStop();
        return;
    }

    me->RemoveEvadeAuras();

    me->AddUnitState(UNIT_STATE_EVADE);
    me->DeleteThreatList();
    me->CombatStop(true);
    me->LoadCreaturesAddon(true);
    me->SetLootRecipient(NULL);
    me->ResetPlayerDamageReq();
    me->SetLastDamagedTime(0);

    GetScript()->ProcessEventsFor(SMART_EVENT_EVADE);//must be after aura clear so we can cast spells from db

    SetRun(mRun);
    if (HasEscortState(SMART_ESCORT_ESCORTING))
    {
        AddEscortState(SMART_ESCORT_RETURNING);
        ReturnToLastOOCPos();
    }
    else if (mFollowGuid)
    {
        if (Unit* target = ObjectAccessor::GetUnit(*me, mFollowGuid))
            me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle);
        me->ClearUnitState(UNIT_STATE_EVADE);

        // xinef: do not forget to reset scripts as we wont call reached home
        GetScript()->OnReset();
    }
    else
    {
        me->GetMotionMaster()->MoveTargetedHome();
        
        // xinef: do not forget to reset scripts as we wont call reached home
        if (!me->HasUnitState(UNIT_STATE_EVADE))
            GetScript()->OnReset();
    }
}
示例#13
0
GameObject::~GameObject()
{
    if(m_uint32Values)                                      // field array can be not exist if GameOBject not loaded
    {
        // crash possible at access to deleted GO in Unit::m_gameobj
        uint64 owner_guid = GetOwnerGUID();
        if(owner_guid)
        {
            Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid);
            if(owner)
                owner->RemoveGameObject(this,false);
            else if(!IS_PLAYER_GUID(owner_guid))
                sLog.outError("Delete GameObject (GUID: %u Entry: %u ) that have references in not found creature %u GO list. Crash possible later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid));
        }
    }
}
示例#14
0
    static bool HandleListAurasCommand(ChatHandler* handler, char const* /*args*/)
    {
        Unit* unit = handler->getSelectedUnit();
        if (!unit)
        {
            handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char const* talentStr = handler->GetTrinityString(LANG_TALENT);
        char const* passiveStr = handler->GetTrinityString(LANG_PASSIVE);

        Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras();
        handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, auras.size());
        for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
        {
            bool talent = GetTalentSpellCost(itr->second->GetBase()->GetId()) > 0;

            AuraApplication const* aurApp = itr->second;
            Aura const* aura = aurApp->GetBase();
            char const* name = aura->GetSpellInfo()->SpellName[handler->GetSessionDbcLocale()];

            std::ostringstream ss_name;
            ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r";

            handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str().c_str() : name),
                aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(),
                aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""),
                (talent ? talentStr : ""), IS_PLAYER_GUID(aura->GetCasterGUID()) ? "player" : "creature",
                GUID_LOPART(aura->GetCasterGUID()));
        }

        for (uint16 i = 0; i < TOTAL_AURAS; ++i)
        {
            Unit::AuraEffectList const& auraList = unit->GetAuraEffectsByType(AuraType(i));
            if (auraList.empty())
                continue;

            handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, auraList.size(), i);

            for (Unit::AuraEffectList::const_iterator itr = auraList.begin(); itr != auraList.end(); ++itr)
                handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), (*itr)->GetAmount());
        }

        return true;
    }
示例#15
0
    //delete object by selection or guid
    static bool HandleGameObjectDeleteCommand (ChatHandler* handler, const char* args)
    {
        // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
        char* cId = handler->extractKeyFromLink((char*) args, "Hgameobject");
        if (!cId)
            return false;

        uint32 lowguid = atoi(cId);
        if (!lowguid)
            return false;

        GameObject* obj = NULL;

        // by DB guid
        if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid))
            obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id);

        if (!obj)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
            handler->SetSentErrorMessage(true);
            return false;
        }

        uint64 owner_guid = obj->GetOwnerGUID();
        if (owner_guid)
        {
            Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), owner_guid);
            if (!owner || !IS_PLAYER_GUID(owner_guid))
            {
                handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow());
                handler->SetSentErrorMessage(true);
                return false;
            }

            owner->RemoveGameObject(obj, false);
        }

        obj->SetRespawnTime(0);          // not save respawn time
        obj->Delete();
        obj->DeleteFromDB();

        handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow());
        sLog->outSQLDev("DELETE FROM gameobject WHERE guid = %u;", obj->GetGUIDLow());
        return true;
    }
示例#16
0
    //delete object by selection or guid
    static bool HandleGameObjectDeleteCommand(ChatHandler* handler, char const* args)
    {
        // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
        char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
        if (!id)
            return false;

        uint32 guidLow = atoi(id);
        if (!guidLow)
            return false;

        GameObject* object = NULL;

        // by DB guid
        if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);

        if (!object)
        {
            handler->PSendSysMessage(LANGUAGE_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        uint64 ownerGuid = object->GetOwnerGUID();
        if (ownerGuid)
        {
            Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid);
            if (!owner || !IS_PLAYER_GUID(ownerGuid))
            {
                handler->PSendSysMessage(LANGUAGE_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(ownerGuid), object->GetGUIDLow());
                handler->SetSentErrorMessage(true);
                return false;
            }

            owner->RemoveGameObject(object, false);
        }

        object->SetRespawnTime(0);                                 // not save respawn time
        object->Delete();
        object->DeleteFromDB();

        handler->PSendSysMessage(LANGUAGE_COMMAND_DELOBJMESSAGE, object->GetGUIDLow());

        return true;
    }
示例#17
0
void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket & recv_data) {
	uint64 guid;
	uint32 quest;
	uint8 unk1;
	recv_data >> guid >> quest >> unk1;
	sLog->outDebug(
			LOG_FILTER_NETWORKIO,
			"WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST npc = %u, quest = %u, unk1 = %u",
			uint32(GUID_LOPART(guid)), quest, unk1);

	// Verify that the guid is valid and is a questgiver or involved in the requested quest
	Object* pObject = ObjectAccessor::GetObjectByTypeMask(
			*_player,
			guid,
			TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM
					| TYPEMASK_PLAYER);

	if (!IS_PLAYER_GUID(guid)) {
		if (!pObject
				|| (!pObject->hasQuest(quest)
						&& !pObject->hasInvolvedQuest(quest))) {
			_player->PlayerTalkClass->CloseGossip();
			return;
		}
	}

	Quest const* pQuest = sObjectMgr->GetQuestTemplate(quest);
	if (pQuest) {
		if (pQuest->IsAutoAccept() && _player->CanAddQuest(pQuest, true)) {
			_player->AddQuest(pQuest, pObject);
			if (_player->CanCompleteQuest(quest))
				_player->CompleteQuest(quest);
		}

		if (pQuest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
			_player->PlayerTalkClass->SendQuestGiverRequestItems(pQuest,
					pObject->GetGUID(),
					_player->CanCompleteQuest(pQuest->GetQuestId()), true);
		else
			_player->PlayerTalkClass->SendQuestGiverQuestDetails(pQuest,
					pObject->GetGUID(), true);
	}
	// Now save player every accept/deliver a quest
	if (_player)
		_player->SaveToDB();
}
示例#18
0
void WorldSession::HandleGuildFinderDeclineRecruit(WorldPacket& recvPacket)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_LF_GUILD_DECLINE_RECRUIT");

    ObjectGuid playerGuid;

    uint8 bitOrder[8] = {5, 1, 3, 7, 6, 2, 0, 4};
    recvPacket.ReadBitInOrder(playerGuid, bitOrder);

    uint8 byteOrder[8] = {4, 2, 3, 7, 6, 0, 1, 5};
    recvPacket.ReadBytesSeq(playerGuid, byteOrder);

    if (!IS_PLAYER_GUID(playerGuid))
        return;

    sGuildFinderMgr->RemoveMembershipRequest(GUID_LOPART(playerGuid), GetPlayer()->GetGuildId());
}
示例#19
0
void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recvData)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_RAID_TARGET_UPDATE");

    Group* group = GetPlayer()->GetGroup();
    if (!group)
        return;

    uint8 x, unk;
    recvData >> unk;
    recvData >> x;

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

    // everything's fine, do it
    if (x == 0xFF)                                           // target icon request
        group->SendTargetIconList(this);
    else                                                    // target icon update
    {
        if (group->isRaidGroup() && !group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()) && !(group->GetGroupType() & GROUPTYPE_EVERYONE_IS_ASSISTANT))
            return;

        ObjectGuid guid;

        uint8 bitOrder[8] = { 6, 3, 2, 5, 4, 1, 0, 7 };
        recvData.ReadBitInOrder(guid, bitOrder);

        recvData.FlushBits();

        uint8 byteOrder[8] = { 0, 3, 4, 2, 5, 1, 7, 6 };
        recvData.ReadBytesSeq(guid, byteOrder);

        if (IS_PLAYER_GUID(guid))
        {
            Player* target = ObjectAccessor::FindPlayer(guid);

            if (!target || target->IsHostileTo(GetPlayer()))
                return;
        }

        group->SetTargetIcon(x, _player->GetGUID(), guid);
    }
}
示例#20
0
void WorldSession::HandleEjectPassenger(WorldPacket &data)
{
    if (Vehicle* vehicle = _player->GetVehicleKit())
    {
        uint64 guid;
        data >> guid;

        if (IS_PLAYER_GUID(guid))
        {
            if (Player *plr = ObjectAccessor::FindPlayer(guid))
            {
                VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(plr);
                if (seat->IsEjectable())
                    plr->ExitVehicle();
                else
                    sLog->outError("Player %u attempted to eject player %u from non-ejectable seat.", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
            }
            else
                sLog->outError("Player %u tried to eject player %u from vehicle, but the latter was not found in world!", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
        }

        else if (IS_CREATURE_GUID(guid))
        {
            if (Unit *unit = ObjectAccessor::GetUnit(*_player, guid)) // creatures can be ejected too from player mounts
            {
                VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(unit);
                ASSERT(seat);
                if (seat->IsEjectable())
                {
                    ASSERT(GetPlayer() == vehicle->GetBase());
                    unit->ExitVehicle();
                    unit->ToCreature()->DespawnOrUnsummon(1000);
                    ASSERT(!unit->IsOnVehicle(vehicle->GetBase()));
                }
                else
                    sLog->outError("Player %u attempted to eject creature GUID "UI64FMTD" from non-ejectable seat.", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
            }
            else
                sLog->outError("Player %u tried to eject creature guid %u from vehicle, but the latter was not found in world!", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
        }
        else
            sLog->outError("HandleEjectPassenger: Player %u tried to eject invalid GUID "UI64FMTD, GetPlayer()->GetGUIDLow(), guid);
    }
示例#21
0
size_t CreatureTextMgr::BuildMonsterChat(WorldPacket* data, WorldObject* source, ChatMsg msgtype, std::string text, Language language, WorldObject* whisperTarget, int loc_idx)
{
    if (!source)
        return 0;

    size_t receiverGUIDPos = 0;
    data->Initialize(SMSG_MESSAGECHAT);

    std::string senderName = "";
    uint64 senderGuid = 0;
    if (source)
    {
        senderGuid = source->GetGUID();
        senderName = source->GetNameForLocaleIdx(loc_idx);
    }

    std::string receiverName = "";
    uint64 receiverGuid = 0;
    if (whisperTarget)
    {
        receiverGuid = whisperTarget->GetGUID();
        receiverName = whisperTarget->GetNameForLocaleIdx(loc_idx);
    }

    *data << (uint8)msgtype;
    *data << (uint32)language;
    *data << (uint64)senderGuid;
    *data << (uint32)0; // 2.1.0
    *data << (uint32)(senderName.length() + 1);
    *data << senderName.c_str();
    receiverGUIDPos = data->wpos();
    *data << (uint64)receiverGuid; // Unit Target
    if (whisperTarget && !IS_PLAYER_GUID(receiverGuid)) //can only whisper players
    {
        *data << uint32(receiverName.length() + 1);                         // string listener_name_length
        *data << receiverName.c_str();                                      // string listener_name
    }
    *data << (uint32)(text.length() + 1);
    *data << text;
    *data << (uint8)0; // ChatTag

    return receiverGUIDPos;
}
示例#22
0
void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
{
    CHECK_PACKET_SIZE(recv_data,8);

    uint64 guid;
    recv_data >> guid;

    DEBUG_LOG( "WORLD: Recvd CMSG_ATTACKSWING Message guidlow:%u guidhigh:%u", GUID_LOPART(guid), GUID_HIPART(guid) );

    Unit *pEnemy = ObjectAccessor::GetUnit(*_player, guid);

    if(!pEnemy)
    {
        if(!IS_UNIT_GUID(guid))
            sLog.outError("WORLD: Object %u (TypeID: %u) isn't player, pet or creature",GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)));
        else
            sLog.outError( "WORLD: Enemy %s %u not found",GetLogNameForGuid(guid),GUID_LOPART(guid));

        // stop attack state at client
        SendAttackStop(NULL);
        return;
    }

    if(_player->IsFriendlyTo(pEnemy) || pEnemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
    {
        sLog.outError( "WORLD: Enemy %s %u is friendly",(IS_PLAYER_GUID(guid) ? "player" : "creature"),GUID_LOPART(guid));

        // stop attack state at client
        SendAttackStop(pEnemy);
        return;
    }

    if(!pEnemy->isAlive())
    {
        // client can generate swing to known dead target if autoswitch between autoshot and autohit is enabled in client options
        // stop attack state at client
        SendAttackStop(pEnemy);
        return;
    }

    _player->Attack(pEnemy,true);
}
示例#23
0
    //delete object by selection or guid
    static bool HandleGameObjectDeleteCommand(ChatHandler* handler, char const* args)
    {
        uint32 guidLow = GetGuidLowFromArgsOrLastTargetedGo(handler, args);

        if (!guidLow)
            return false;

        GameObject* object = NULL;

        // by DB guid
        if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
            object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);

        if (!object)
        {
            handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
            handler->SetSentErrorMessage(true);
            return false;
        }

        uint64 ownerGuid = object->GetOwnerGUID();
        if (ownerGuid)
        {
            Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid);
            if (!owner || !IS_PLAYER_GUID(ownerGuid))
            {
                handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(ownerGuid), object->GetGUIDLow());
                handler->SetSentErrorMessage(true);
                return false;
            }

            owner->RemoveGameObject(object, false);
        }

        object->SetRespawnTime(0);                                 // not save respawn time
        object->Delete();
        object->DeleteFromDB();

        handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetGUIDLow());

        return true;
    }
示例#24
0
    static void DeleteObject(GameObject* object/*, uint32 GObjectID = 0*/)
    {
        //if(GObjectID)
        //    GObjects.erase(GObjectID);
        if (object)
        {
            GObjects.erase(object->GetGUIDHigh()); // remove from temp store

            uint64 ownerGuid = object->GetOwnerGUID();
            if (ownerGuid)
            {
                Unit* owner = ObjectAccessor::GetUnit(*object, ownerGuid);
                if (owner && IS_PLAYER_GUID(ownerGuid))
                    owner->RemoveGameObject(object, false);
            }
            object->SetRespawnTime(0);
            object->Delete();
            object->DeleteFromDB();
        }
    }
示例#25
0
void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received MSG_RAID_TARGET_UPDATE");
#endif

    Group* group = GetPlayer()->GetGroup();
    if (!group)
        return;

    uint8  x;
    recvData >> x;

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

    // everything's fine, do it
    if (x == 0xFF)                                           // target icon request
    {
        group->SendTargetIconList(this);
    }
    else                                                    // target icon update
    {
        if (group->isRaidGroup() && !group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
            return;

        uint64 guid;
        recvData >> guid;

        if (IS_PLAYER_GUID(guid))
        {
            Player* target = ObjectAccessor::FindPlayerInOrOutOfWorld(guid);

            if (!target || target->IsHostileTo(GetPlayer()))
                return;
        }

        group->SetTargetIcon(x, _player->GetGUID(), guid);
    }
}
示例#26
0
void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
{
    
    uint64 guid;
    recv_data >> guid;

    
    DEBUG_LOG( "WORLD: Recvd CMSG_ATTACKSWING Message guidlow:%u guidhigh:%u", GUID_LOPART(guid), GUID_HIPART(guid) );
    
    if( IS_CREATURE_GUID(guid) )
    {
	Creature *pEnemy = ObjectAccessor::Instance().GetCreature(*_player, guid);
	if( pEnemy != NULL )
	{
	    assert( pEnemy != NULL );
	    _player->addStateFlag(UF_ATTACKING);
	    _player->smsg_AttackStart(pEnemy);
	    pEnemy->AI().AttackStart(_player);
	    _player->inCombat = true;
	    _player->logoutDelay = LOGOUTDELAY;
	    return;
	}
    }
    else if( IS_PLAYER_GUID(guid) )
    {
	Player *pPVPEnemy = ObjectAccessor::Instance().GetPlayer(*_player, guid);
	if( pPVPEnemy != NULL )
	{
	    _player->addStateFlag(UF_ATTACKING);
	    _player->smsg_AttackStart(pPVPEnemy);
	    _player->inCombat = true;
	    _player->logoutDelay = LOGOUTDELAY;
	    return;
	}
    }

    Log::getSingleton( ).outError( "WORLD: Enemy %u %.8X is not a player or a creature",
				   GUID_LOPART(guid), GUID_HIPART(guid));	
}
void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recvData)
{
    TC_LOG_DEBUG("network", "WORLD: Received MSG_RAID_TARGET_UPDATE");

    Group* group = GetPlayer()->GetGroup();
    if (!group)
        return;

    uint8  x;
    recvData >> x;

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

    // everything's fine, do it
    if (x == 0xFF)                                           // target icon request
    {
        group->SendTargetIconList(this);
    }
    else                                                    // target icon update
    {
        if (group->isRaidGroup() && !group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
            return;

        uint64 guid;
        recvData >> guid;

        if (IS_PLAYER_GUID(guid))
        {
            Player* target = ObjectAccessor::FindPlayer(guid);

            if (!target || target->IsHostileTo(GetPlayer()))
                return;
        }

        group->SetTargetIcon(x, _player->GetGUID(), guid);
    }
}
示例#28
0
文件: GameObject.cpp 项目: wk23/tst
void GameObject::CleanupsBeforeDelete()
{
    if(m_uint32Values)                                      // field array can be not exist if GameOBject not loaded
    {
        // Possible crash at access to deleted GO in Unit::m_gameobj
        if(uint64 owner_guid = GetOwnerGUID())
        {
            if(Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid))
                owner->RemoveGameObject(this,false);
            else
            {
                const char * ownerType = "creature";
                if(IS_PLAYER_GUID(owner_guid))
                    ownerType = "player";
                else if(IS_PET_GUID(owner_guid))
                    ownerType = "pet";

                sLog.outError("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.",
                    GetGUIDLow(), GetGOInfo()->id, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType);
            }
        }
    }
}
示例#29
0
        size_t operator()(WorldPacket* data, LocaleConstant locale) const
        {
            std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale);

            *data << uint8(_msgType);
            *data << uint32(_language);
            *data << uint64(_talker->GetGUID());
            *data << uint32(1);                                      // 2.1.0
            *data << uint32(_talker->GetName().size() + 1);
            *data << _talker->GetName();
            size_t whisperGUIDpos = data->wpos();
            *data << uint64(_targetGUID);                           // Unit Target
            if (_targetGUID && !IS_PLAYER_GUID(_targetGUID))
            {
                *data << uint32(1);                                  // target name length
                *data << uint8(0);                                   // target name
            }
            *data << uint32(text.length() + 1);
            *data << text;
            *data << uint8(0);                                       // ChatTag

            return whisperGUIDpos;
        }
示例#30
0
bool PoolImp::update(uint64 guid)
{
	POOL_LOG_DEBUG("update entity, guid is <%llu>", guid);

	if ((IS_PLAYER_GUID(guid) || (IS_ROLE_GUID(guid))))
	{
		return true;
	}

	uint64 owner_guid = 0;
	{
		Guid2OwnerGuidMap_t::iterator it = m_guid2ownerguid_map.find(guid);
		if (it != m_guid2ownerguid_map.end())
		{
			owner_guid = it->second;
		}
		else
		{
			POOL_LOG_ERROR("failed to get owner_guid of guid while update <%llu>", guid);
			return false;
		}
	}

	EntityMap_t::iterator it = m_entity_map.find(guid);
	if (it != m_entity_map.end())
	{
		it->second->op_type |= EOT_UPDATE;
		updateToDb(owner_guid, guid, EOT_UPDATE);
	}
	else
	{
		POOL_LOG_ERROR("failed to update guid from pool, not found <%s>", boost::lexical_cast<string>(guid).c_str());
	}

	return true;
}