Skip to content

Commit

Permalink
Make it work again
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Sep 9, 2024
1 parent 58de916 commit a6cc4b9
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/game/Chat/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void Channel::Join(Player* player, const char* password)

if (HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_CHANNEL_RESTRICTED_LFG))
{
if (player->GetSession()->GetSecurity() == SEC_PLAYER && !player->m_lfgInfo.queued)
if (player->GetSession()->GetSecurity() == SEC_PLAYER && !player->GetSession()->m_lfgInfo.queued)
{
MakeNotInLFG(data, m_name);
SendToOne(data, guid);
Expand Down
4 changes: 0 additions & 4 deletions src/game/Entities/CharacterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,10 +1158,6 @@ void WorldSession::HandleSetFactionAtWarOpcode(WorldPacket& recv_data)
void WorldSession::HandleMeetingStoneInfoOpcode(WorldPacket& /*recv_data*/)
{
DEBUG_LOG("WORLD: Received CMSG_MEETING_STONE_INFO");

WorldPacket data(SMSG_MEETINGSTONE_SETQUEUE, 5);
data << uint32(0) << uint8(6);
SendPacket(data);
}

void WorldSession::HandleTutorialFlagOpcode(WorldPacket& recv_data)
Expand Down
6 changes: 6 additions & 0 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19636,6 +19636,12 @@ void Player::SendInitialPacketsAfterAddToMap()

SendExtraAuraDurationsOnLogin(true);
SendExtraAuraDurationsOnLogin(false);

if (!sWorld.getConfig(CONFIG_BOOL_LFG_ENABLED))
{
WorldPacket data(SMSG_LFG_DISABLED);
GetSession()->SendPacket(data);
}
}

void Player::SendUpdateToOutOfRangeGroupMembers()
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 @@ -41,7 +41,6 @@
#include "Server/SQLStorages.h"
#include "Loot/LootMgr.h"
#include "Cinematics/CinematicMgr.h"
#include "LFG/LFGDefines.h"

#include <functional>
#include <vector>
Expand Down Expand Up @@ -2133,8 +2132,6 @@ class Player : public Unit
void RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also = false);
static bool ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialHair, uint8 skinColor, bool create = false);

LfgPlayerInfo m_lfgInfo;

// Temporarily removed pet cache
uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
Expand Down
16 changes: 13 additions & 3 deletions src/game/LFG/LFGDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ enum class MeetingstoneFailedStatus : uint8
MEETINGSTONE_FAIL_RAID_GROUP = 3,
};

enum class MeetingstoneSetqueue : uint8
{
LEFT_QUEUE = 0,
IN_QUEUE = 1,
UNK = 2,
OTHER_MEMBER_LEFT = 3,
KICKED_FROM_QUEUE = 4,
JOINED_GROUP = 5,
};

struct LfgPlayerInfo
{
std::string comment;
bool autojoin;
bool autofill;
bool queued; // cached async information
bool autojoin = false;
bool autofill = false;
bool queued = false; // cached async information
};

#endif
94 changes: 66 additions & 28 deletions src/game/LFG/LFGHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,36 @@ void WorldSession::HandleLfgSetAutoJoinOpcode(WorldPacket& /*recv_data*/)
{
DEBUG_LOG("CMSG_LFG_SET_AUTOJOIN");

_player->m_lfgInfo.autojoin = true;
m_lfgInfo.autojoin = true;

sWorld.GetLFGQueue().GetMessager().AddMessage([playerGuid = _player->GetObjectGuid()](LFGQueue* queue)
if (_player)
{
queue->SetAutoJoin(playerGuid, true);
});
sWorld.GetLFGQueue().GetMessager().AddMessage([playerGuid = _player->GetObjectGuid()](LFGQueue* queue)
{
queue->SetAutoJoin(playerGuid, true);
});
}

uint8 result = uint8(MeetingstoneFailedStatus::MEETINGSTONE_FAIL_NONE);

WorldPacket data(SMSG_MEETINGSTONE_JOINFAILED, 1);
data << uint8(result);
_player->GetSession()->SendPacket(data);
SendPacket(data);
}

void WorldSession::HandleLfgClearAutoJoinOpcode(WorldPacket& /*recv_data*/)
{
DEBUG_LOG("CMSG_LFG_CLEAR_AUTOJOIN");

_player->m_lfgInfo.autojoin = false;
m_lfgInfo.autojoin = false;

sWorld.GetLFGQueue().GetMessager().AddMessage([playerGuid = _player->GetObjectGuid()](LFGQueue* queue)
if (_player)
{
queue->SetAutoJoin(playerGuid, false);
});
sWorld.GetLFGQueue().GetMessager().AddMessage([playerGuid = _player->GetObjectGuid()](LFGQueue* queue)
{
queue->SetAutoJoin(playerGuid, false);
});
}
}

void WorldSession::HandleLfmSetAutoFillOpcode(WorldPacket& /*recv_data*/)
Expand All @@ -59,40 +65,46 @@ void WorldSession::HandleLfmSetAutoFillOpcode(WorldPacket& /*recv_data*/)

MeetingstoneFailedStatus result = MeetingstoneFailedStatus::MEETINGSTONE_FAIL_NONE;

if (Group* _group = _player->GetGroup())
if (_player) // can be sent during login
{
if (_group->IsRaidGroup())
result = MeetingstoneFailedStatus::MEETINGSTONE_FAIL_RAID_GROUP;
else if (!_group->IsLeader(_player->GetObjectGuid()))
result = MeetingstoneFailedStatus::MEETINGSTONE_FAIL_PARTYLEADER;
else
result = MeetingstoneFailedStatus::MEETINGSTONE_FAIL_FULL_GROUP;
}
if (Group* _group = _player->GetGroup())
{
if (_group->IsRaidGroup())
result = MeetingstoneFailedStatus::MEETINGSTONE_FAIL_RAID_GROUP;
else if (!_group->IsLeader(_player->GetObjectGuid()))
result = MeetingstoneFailedStatus::MEETINGSTONE_FAIL_PARTYLEADER;
else
result = MeetingstoneFailedStatus::MEETINGSTONE_FAIL_FULL_GROUP;
}

if (result == MeetingstoneFailedStatus::MEETINGSTONE_FAIL_NONE)
{
_player->m_lfgInfo.autofill = true;
sWorld.GetLFGQueue().GetMessager().AddMessage([playerGuid = _player->GetObjectGuid()](LFGQueue* queue)
if (result == MeetingstoneFailedStatus::MEETINGSTONE_FAIL_NONE)
{
queue->SetAutoFill(playerGuid, true);
});
m_lfgInfo.autofill = true;
sWorld.GetLFGQueue().GetMessager().AddMessage([playerGuid = _player->GetObjectGuid()](LFGQueue* queue)
{
queue->SetAutoFill(playerGuid, true);
});
}
}

WorldPacket data(SMSG_MEETINGSTONE_JOINFAILED, 1);
data << uint8(result);
_player->GetSession()->SendPacket(data);
SendPacket(data);
}

void WorldSession::HandleLfmClearAutoFillOpcode(WorldPacket& /*recv_data*/)
{
DEBUG_LOG("CMSG_LFM_CLEAR_AUTOFILL");

_player->m_lfgInfo.autofill = false;
m_lfgInfo.autofill = false;

sWorld.GetLFGQueue().GetMessager().AddMessage([playerGuid = _player->GetObjectGuid()](LFGQueue* queue)
if (_player)
{
queue->SetAutoFill(playerGuid, false);
});
sWorld.GetLFGQueue().GetMessager().AddMessage([playerGuid = _player->GetObjectGuid()](LFGQueue* queue)
{
queue->SetAutoFill(playerGuid, false);
});
}
}

void WorldSession::HandleLfgClearOpcode(WorldPacket& /*recv_data */)
Expand Down Expand Up @@ -147,8 +159,21 @@ void WorldSession::HandleSetLfgOpcode(WorldPacket& recv_data)
uint16 entry = (data & 0xFFFF);
uint16 type = ((data >> 24) & 0xFFFF);

if (m_lfgInfo.queued) // setting a slot instead of starting lfg entirely
{
sWorld.GetLFGQueue().GetMessager().AddMessage([leaderGuid, slot, entry, type](LFGQueue* queue)
{
queue->SetLfgSlot(leaderGuid, slot, entry, type);
});
return;
}

info.leaderGuid = leaderGuid;
info.group[slot].set(entry, type);
info.team = _player->GetTeam();
info.level = _player->GetLevel();
info.zoneId = _player->GetZoneId();
info.autoJoin = m_lfgInfo.autojoin;

DEBUG_LOG("LFG set: looknumber %u, temp %X, type %u, entry %u", slot, data, type, entry);
sWorld.GetLFGQueue().GetMessager().AddMessage([playerGuid = _player->GetObjectGuid(), info](LFGQueue* queue)
Expand Down Expand Up @@ -207,8 +232,21 @@ void WorldSession::HandleSetLfmOpcode(WorldPacket& recv_data)
uint16 entry = (data & 0xFFFF);
uint16 type = ((data >> 24) & 0xFFFF);

if (m_lfgInfo.queued) // setting a slot instead of starting lfg entirely
{
sWorld.GetLFGQueue().GetMessager().AddMessage([leaderGuid, entry, type](LFGQueue* queue)
{
queue->SetLfmData(leaderGuid, entry, type);
});
return;
}

info.leaderGuid = leaderGuid;
info.more.set(entry, type);
info.team = _player->GetTeam();
info.level = _player->GetLevel();
info.zoneId = _player->GetZoneId();
info.autoFill = m_lfgInfo.autofill;

DEBUG_LOG("LFM set: temp %u, zone %u, type %u", data, entry, type);
sWorld.GetLFGQueue().GetMessager().AddMessage([objectGuid = _player->GetObjectGuid(), info](LFGQueue* queue)
Expand Down
Loading

0 comments on commit a6cc4b9

Please sign in to comment.