From bb17030c68be93c79f534dffe8a0364f35e86d68 Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Fri, 17 Jan 2025 21:16:58 +0100 Subject: [PATCH] Add an enum for content flags instead of using magic numbers --- src/world/ContentFinder/ContentFinder.cpp | 12 ++++-------- src/world/ContentFinder/ContentFinder.h | 7 +++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/world/ContentFinder/ContentFinder.cpp b/src/world/ContentFinder/ContentFinder.cpp index 8b1d2330..b37bf8ff 100644 --- a/src/world/ContentFinder/ContentFinder.cpp +++ b/src/world/ContentFinder/ContentFinder.cpp @@ -54,14 +54,10 @@ void World::ContentFinder::update() { uint32_t inProgress = 0; // 0x01 - in progress uint32_t dutyProgress = 0; - uint32_t flags = 0; // 0x20 freerole, 0x40 ownrequest, 0x100 random - - // Undersized - if( content->m_flags & 0x01 ) - flags |= 0x20; + // uint32_t flags = 0; // 0x20 freerole, 0x40 ownrequest, 0x100 random auto finishContentMatchPacket = makeFinishContentMatchToClient( queuedPlayer->getEntityId(), contentInfo->data().TerritoryType, - queuedPlayer->m_classJob, content->m_players.size(), dutyProgress, flags ); + queuedPlayer->m_classJob, content->m_players.size(), dutyProgress, content->m_flags ); server.queueForPlayer( queuedPlayer->getCharacterId(), finishContentMatchPacket ); } @@ -161,14 +157,14 @@ void World::ContentFinder::completeRegistration( const Entity::Player &player, u if( flags & 0x01 ) { auto updatePacket = makeUpdateFindContent( player.getId(), content->data().TerritoryType, - CompleteRegistration, 1, static_cast< uint32_t >( player.getClass() ), 0x20 ); + CompleteRegistration, 1, static_cast< uint32_t >( player.getClass() ), FindContentFlag::Undersized ); server.queueForPlayer( player.getCharacterId(), updatePacket ); auto statusPacket = makeNotifyFindContentStatus( player.getId(), content->data().TerritoryType, 2, queuedContent->m_attackerCount + queuedContent->m_rangeCount, queuedContent->m_healerCount, queuedContent->m_tankCount, 0 ); server.queueForPlayer( player.getCharacterId(), statusPacket ); - queuedContent->m_flags = flags; + queuedContent->m_flags |= FindContentFlag::Undersized; queuedContent->setState( MatchingComplete ); } else diff --git a/src/world/ContentFinder/ContentFinder.h b/src/world/ContentFinder/ContentFinder.h index 5eda468b..bc77662b 100644 --- a/src/world/ContentFinder/ContentFinder.h +++ b/src/world/ContentFinder/ContentFinder.h @@ -6,6 +6,13 @@ namespace Sapphire::World { + enum FindContentFlag : uint32_t + { + Undersized = 0x20, + OwnRequest = 0x40, + Random = 0x100 + }; + enum UpdateFindContentKind : uint8_t { CompleteRegistration = 0, // value1 is used to call setResultFindSuccess if bit1 or bit2 is set, value2 is passed to setFindInfo