Skip to content

Commit

Permalink
LFG: Rewrite into async and add pending autoinvite protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Sep 9, 2024
1 parent ba94c75 commit b721958
Show file tree
Hide file tree
Showing 18 changed files with 1,297 additions and 648 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_lookingForGroup.isEmpty())
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
57 changes: 0 additions & 57 deletions src/game/Entities/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,61 +307,6 @@ struct EnchantDuration
typedef std::list<EnchantDuration> EnchantDurationList;
typedef std::list<Item*> ItemDurationList;

#define MAX_LOOKING_FOR_GROUP_SLOT 3

struct LookingForGroupInfo
{
struct Slot
{
bool empty() const { return (!type || !entry); }
void clear() { entry = 0; }
bool set(uint16 _entry, uint16 _type) { entry = _entry; type = _type; return !empty(); }
bool is(uint16 _entry, uint16 _type) const { return entry == _entry && type == _type; }
bool isAuto() const { return entry && (type == LFG_TYPE_DUNGEON || type == LFG_TYPE_HEROIC_DUNGEON); }

uint16 entry = 0;
uint16 type = LFG_TYPE_DUNGEON;
};

inline void clear()
{
more.clear();
for (auto& slot : group)
slot.clear();
}
inline bool isAutoFill() const { return more.isAuto(); }
inline bool isAutoJoin() const
{
for (auto& slot : group)
if (slot.isAuto())
return true;
return false;
}
inline bool isEmpty() const { return (!isLFM() && !isLFG()); }
inline bool isLFG() const
{
for (auto& slot : group)
if (!slot.empty())
return true;
return false;
}
inline bool isLFG(uint32 entry, uint32 type, bool autoOnly) const
{
for (auto& slot : group)
if (slot.is(uint16(entry), uint16(type)) && (!autoOnly || slot.isAuto()))
return true;
return false;
}
inline bool isLFG(LookingForGroupInfo const& info, bool autoOnly) const { return isLFG(uint16(info.more.entry), uint16(info.more.type), autoOnly); }
inline bool isLFM() const { return !more.empty(); }
inline bool isLFM(uint32 entry, uint32 type) const { return more.is(uint16(entry), uint16(type)); }

// bool queued = false;
Slot group[MAX_LOOKING_FOR_GROUP_SLOT];
Slot more;
std::string comment;
};

enum RaidGroupError
{
ERR_RAID_GROUP_NONE = 0,
Expand Down Expand Up @@ -2187,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);

LookingForGroupInfo m_lookingForGroup;

// Temporarily removed pet cache
uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; }
void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; }
Expand Down
6 changes: 6 additions & 0 deletions src/game/Groups/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ uint32 Group::RemoveMember(ObjectGuid guid, uint8 method)
BroadcastPacket(data, true);
}

// TODO: Check if member leaving should just update queue
sWorld.GetLFGQueue().GetMessager().AddMessage([guid](LFGQueue* queue)
{
queue->StopLookingForGroup(guid, guid);
});

SendUpdate();
}
// if group before remove <= 2 disband it
Expand Down
62 changes: 62 additions & 0 deletions src/game/LFG/LFGDefines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This file is part of the CMaNGOS Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef _LFG_DEFINES_H
#define _LFG_DEFINES_H

#include "Common.h"

#define MAX_LOOKING_FOR_GROUP_SLOT 3

enum LfgType : uint32
{
LFG_TYPE_NONE = 0,
LFG_TYPE_DUNGEON = 1,
LFG_TYPE_RAID = 2,
LFG_TYPE_QUEST = 3,
LFG_TYPE_ZONE = 4,
LFG_TYPE_HEROIC_DUNGEON = 5
};

enum class MeetingstoneFailedStatus : uint8
{
MEETINGSTONE_FAIL_NONE = 0, // custom, not to be sent
MEETINGSTONE_FAIL_PARTYLEADER = 1,
MEETINGSTONE_FAIL_FULL_GROUP = 2,
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 = false;
bool autofill = false;
bool queued = false; // cached async information
};

#endif
Loading

1 comment on commit b721958

@al3xc1985
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Epic, like allways! Dunno why your name is KW it should be Epic!

Please sign in to comment.