Skip to content

Commit

Permalink
Network: Refactor opcode table compared to other cores and cull unnec…
Browse files Browse the repository at this point in the history
…essary opcodes

Complain if I culled smth wrongly

Yes I know I left an empty block

SPEEEEEEEED
  • Loading branch information
killerwife committed Apr 5, 2024
1 parent 21a68ba commit 0137c31
Show file tree
Hide file tree
Showing 18 changed files with 840 additions and 1,447 deletions.
41 changes: 0 additions & 41 deletions src/game/Chat/ChannelHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,44 +309,3 @@ void WorldSession::HandleChannelModerateOpcode(WorldPacket& recvPacket)
if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->ToggleModeration(_player);
}

void WorldSession::HandleChannelDisplayListQueryOpcode(WorldPacket& recvPacket)
{
DEBUG_LOG("WORLD: Received opcode %s (%u, 0x%X)", recvPacket.GetOpcodeName(), recvPacket.GetOpcode(), recvPacket.GetOpcode());
// recvPacket.hexlike();
std::string channelname;
recvPacket >> channelname;
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->SendChannelListResponse(_player, true);
}

void WorldSession::HandleGetChannelMemberCountOpcode(WorldPacket& recvPacket)
{
DEBUG_LOG("WORLD: Received opcode %s (%u, 0x%X)", recvPacket.GetOpcodeName(), recvPacket.GetOpcode(), recvPacket.GetOpcode());
// recvPacket.hexlike();
std::string channelname;
recvPacket >> channelname;
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
{
if (Channel* chn = cMgr->GetChannel(channelname, _player))
{
WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, chn->GetName().size() + 1 + 1 + 4);
data << chn->GetName();
data << uint8(chn->GetFlags());
data << uint32(chn->GetNumPlayers());
SendPacket(data);
}
}
}

void WorldSession::HandleSetChannelWatchOpcode(WorldPacket& recvPacket)
{
DEBUG_LOG("WORLD: Received opcode %s (%u, 0x%X)", recvPacket.GetOpcodeName(), recvPacket.GetOpcode(), recvPacket.GetOpcode());
// recvPacket.hexlike();
std::string channelname;
recvPacket >> channelname;
/*if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player))
chn->JoinNotify(_player->GetGUID());*/
}
24 changes: 0 additions & 24 deletions src/game/Entities/ItemHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,27 +1160,3 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data)
uint32 count = 1;
_player->DestroyItemCount(gift, count, true);
}

void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_CANCEL_TEMP_ENCHANTMENT");

uint32 eslot;

recv_data >> eslot;

// apply only to equipped item
if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, eslot))
return;

Item* item = GetPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, eslot);

if (!item)
return;

if (!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
return;

GetPlayer()->ApplyEnchantment(item, TEMP_ENCHANTMENT_SLOT, false);
item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT);
}
31 changes: 1 addition & 30 deletions src/game/Entities/MiscHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,39 +1123,10 @@ void WorldSession::HandleResetInstancesOpcode(WorldPacket& /*recv_data*/)
_player->ResetInstances(INSTANCE_RESET_ALL);
}

void WorldSession::HandleCancelMountAuraOpcode(WorldPacket& /*recv_data*/)
{
DEBUG_LOG("WORLD: Received opcode CMSG_CANCEL_MOUNT_AURA");

// If player is not mounted, so go out :)
if (!_player->IsMounted()) // not blizz like; no any messages on blizz
{
ChatHandler(this).SendSysMessage(LANG_CHAR_NON_MOUNTED);
return;
}

if (_player->IsTaxiFlying()) // not blizz like; no any messages on blizz
{
ChatHandler(this).SendSysMessage(LANG_YOU_IN_FLIGHT);
return;
}

_player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
_player->Unmount();
}

void WorldSession::HandleRequestPetInfoOpcode(WorldPacket& /*recv_data */)
{
if (_player->GetPet())
_player->PetSpellInitialize();
else if (_player->GetCharm())
_player->CharmSpellInitialize();
}

void WorldSession::HandleSetTaxiBenchmarkOpcode(WorldPacket& recv_data)
{
uint8 mode;
recv_data >> mode;

DEBUG_LOG("Client used \"/timetest %d\" command", mode);
}
}
122 changes: 0 additions & 122 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2758,7 +2758,6 @@ void Player::GiveLevel(uint32 level)

// resend quests status directly
GetSession()->SetCurrentPlayerLevel(level);
SendQuestGiverStatusMultiple();
}

void Player::UpdateFreeTalentPoints(bool resetIfNeed)
Expand Down Expand Up @@ -3017,53 +3016,6 @@ void Player::SendInitialSpells() const
DETAIL_LOG("CHARACTER: Sent Initial Spells");
}

void Player::SendUnlearnSpells() const
{
WorldPacket data(SMSG_SEND_UNLEARN_SPELLS, 4 + 4 * m_spells.size());

uint32 spellCount = 0;
size_t countPos = data.wpos();
data << uint32(spellCount); // spell count placeholder

for (auto& spellData : m_spells)
{
if (spellData.second.state == PLAYERSPELL_REMOVED)
continue;

if (spellData.second.active || spellData.second.disabled)
continue;

auto skillLineAbilities = sSpellMgr.GetSkillLineAbilityMapBoundsBySpellId(spellData.first);
if (skillLineAbilities.first == skillLineAbilities.second)
continue;

bool hasSupercededSpellInfoInClient = false;
for (auto boundsItr = skillLineAbilities.first; boundsItr != skillLineAbilities.second; ++boundsItr)
{
if (boundsItr->second->forward_spellid)
{
hasSupercededSpellInfoInClient = true;
break;
}
}

if (hasSupercededSpellInfoInClient)
continue;

uint32 nextRank = sSpellMgr.GetNextSpellInChain(spellData.first);
if (!nextRank || !HasSpell(nextRank))
continue;

data << uint32(spellData.first);

++spellCount;
}

data.put<uint32>(countPos, spellCount); // write real count value

SendDirectMessage(data);
}

void Player::SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const
{
WorldPacket data(SMSG_SUPERCEDED_SPELL, (4));
Expand Down Expand Up @@ -3249,8 +3201,6 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
{
// update spell ranks in spellbook and action bar
SendSupercededSpell(spell_id, next_active_spell_id);
if (IsUnlearnSpellsPacketNeededForSpell(spell_id))
SendUnlearnSpells();
}
else
SendRemovedSpell(spell_id);
Expand Down Expand Up @@ -3410,9 +3360,6 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen

m_spells[spell_id] = newspell;

if (needsUnlearnSpellsPacket)
SendUnlearnSpells();

// return false if spell disabled
if (newspell.disabled)
return false;
Expand Down Expand Up @@ -3651,9 +3598,6 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
}
}

if (needsUnlearnSpellsPacket)
SendUnlearnSpells();

// remove from spell book if not replaced by lesser rank
if (!prev_activate && sendUpdate)
SendRemovedSpell(spell_id);
Expand Down Expand Up @@ -12728,9 +12672,6 @@ void Player::RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver,
saBounds = sSpellMgr.GetSpellAreaForAreaMapBounds(0);
for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
itr->second->ApplyOrRemoveSpellIfCan(this, zone, area, false);

// resend quests status directly
SendQuestGiverStatusMultiple();
}

bool Player::IsQuestExplored(uint32 quest_id) const
Expand Down Expand Up @@ -13940,60 +13881,6 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, ObjectGuid guid
SetQuestSlotCounter(slot, uint8(creatureOrGO_idx), uint8(count));
}

void Player::SendQuestGiverStatusMultiple() const
{
uint32 count = 0;

WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4);
data << uint32(count); // placeholder

for (auto m_clientGUID : m_clientGUIDs)
{
if (m_clientGUID.IsAnyTypeCreature())
{
// need also pet quests case support
Creature* questgiver = GetMap()->GetAnyTypeCreature(m_clientGUID);

if (!questgiver || !CanInteract(questgiver))
continue;

if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
continue;

uint8 dialogStatus = sScriptDevAIMgr.GetDialogStatus(this, questgiver);

if (dialogStatus == DIALOG_STATUS_UNDEFINED)
dialogStatus = GetSession()->getDialogStatus(this, questgiver, DIALOG_STATUS_NONE);

data << questgiver->GetObjectGuid();
data << uint8(dialogStatus);
++count;
}
else if (m_clientGUID.IsGameObject())
{
GameObject* questgiver = GetMap()->GetGameObject(m_clientGUID);

if (!questgiver)
continue;

if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
continue;

uint8 dialogStatus = sScriptDevAIMgr.GetDialogStatus(this, questgiver);

if (dialogStatus == DIALOG_STATUS_UNDEFINED)
dialogStatus = GetSession()->getDialogStatus(this, questgiver, DIALOG_STATUS_NONE);

data << questgiver->GetObjectGuid();
data << uint8(dialogStatus);
++count;
}
}

data.put<uint32>(0, count); // write real count
GetSession()->SendPacket(data);
}

/*********************************************************/
/*** LOAD SYSTEM ***/
/*********************************************************/
Expand Down Expand Up @@ -16474,13 +16361,6 @@ void Player::SendExplorationExperience(uint32 Area, uint32 Experience) const
GetSession()->SendPacket(data);
}

void Player::SendResetFailedNotify(uint32 mapid) const
{
WorldPacket data(SMSG_RESET_FAILED_NOTIFY, 4);
data << uint32(mapid);
GetSession()->SendPacket(data);
}

/// Reset all solo instances and optionally send a message on success for each
void Player::ResetInstances(InstanceResetMethod method)
{
Expand Down Expand Up @@ -18099,8 +17979,6 @@ void Player::SendInitialPacketsBeforeAddToMap()

SendInitialSpells();

SendUnlearnSpells();

SendInitialActionButtons();
m_reputationMgr.SendInitialReputations();
UpdateHonor();
Expand Down
3 changes: 0 additions & 3 deletions src/game/Entities/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,6 @@ class Player : public Unit
void SendPushToPartyResponse(Player* pPlayer, uint32 msg) const;
void SendQuestUpdateAddItem(Quest const* pQuest, uint32 item_idx, uint32 current, uint32 count);
void SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 count);
void SendQuestGiverStatusMultiple() const;

ObjectGuid GetDividerGuid() const { return m_dividerGuid; }
void SetDividerGuid(ObjectGuid guid) { m_dividerGuid = guid; }
Expand Down Expand Up @@ -1473,7 +1472,6 @@ class Player : public Unit

void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const;
void SendInitialSpells() const;
void SendUnlearnSpells() const;
void SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const;
void SendRemovedSpell(uint32 spellId) const;
bool addSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled);
Expand Down Expand Up @@ -1656,7 +1654,6 @@ class Player : public Unit
void ResetInstances(InstanceResetMethod method);
void SendResetInstanceSuccess(uint32 MapId) const;
void SendResetInstanceFailed(uint32 reason, uint32 MapId) const;
void SendResetFailedNotify(uint32 mapid) const;

bool SetPosition(float x, float y, float z, float orientation, bool teleport = false);
void UpdateTerainEnvironmentFlags(Map* m, float x, float y, float z);
Expand Down
15 changes: 0 additions & 15 deletions src/game/Groups/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,21 +814,6 @@ void Group::BroadcastReadyCheck(WorldPacket const& packet) const
}
}

void Group::OfflineReadyCheck()
{
for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
{
Player* pl = sObjectMgr.GetPlayer(citr->guid);
if (!pl || !pl->GetSession())
{
WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9);
data << citr->guid;
data << uint8(0);
BroadcastReadyCheck(data);
}
}
}

bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant)
{
// get first not-full group
Expand Down
1 change: 0 additions & 1 deletion src/game/Groups/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ class Group
void BroadcastPacket(WorldPacket const& packet, bool ignorePlayersInBGRaid, int group = -1, ObjectGuid ignore = ObjectGuid()) const;
void BroadcastPacketInRange(WorldObject const* who, WorldPacket const& packet, bool ignorePlayersInBGRaid, int group = -1, ObjectGuid ignore = ObjectGuid()) const;
void BroadcastReadyCheck(WorldPacket const& packet) const;
void OfflineReadyCheck();

void RewardGroupAtKill(Unit* pVictim, Player* player_tap);

Expand Down
Loading

0 comments on commit 0137c31

Please sign in to comment.