Skip to content
Permalink
Browse files

add Party::get_members()

  • Loading branch information
KevinEady committed Mar 19, 2020
1 parent ae81a6f commit 9b1b7b856365d516979630082ddf06d282489ea9
Showing with 24 additions and 12 deletions.
  1. +6 −12 pol-core/pol/miscmsg.cpp
  2. +17 −0 pol-core/pol/party.cpp
  3. +1 −0 pol-core/pol/party.h
@@ -429,24 +429,20 @@ void handle_krrios_packet( Client* client, PKTBI_F0* msg )
Network::PktHelper::PacketOut<Network::PktOut_F0_Sub01> outMsg;
outMsg->offset += 2; // len
outMsg->Write<u8>( PKTBI_F0::QUERY_PARTY + 1U ); // sub, response is +1
u32 serial = party->leader();
unsigned short index = 0;
do
auto members = party->get_members();
for ( auto member : members )
{
if ( serial == me->serial )
if ( member->serial == me->serial )
continue;

auto* member = Core::find_character( serial );
if ( !member || ( Core::inrange( me, member ) && me->is_visible_to_me( member ) ) )
if ( Core::inrange( me, member ) && me->is_visible_to_me( member ) )
continue;

outMsg->Write<u32>( member->serial_ext );
outMsg->WriteFlipped<u16>( member->x );
outMsg->WriteFlipped<u16>( member->y );
outMsg->Write<u8>( member->realm->getUOMapID() );

// on first call index is 0, as the first loop iteration is party leader
} while ( ( serial = party->get_member_at( index++ ) ) != 0 );
}

if ( outMsg->offset != 4 ) // only send if there is an update
{
@@ -472,10 +468,8 @@ void handle_krrios_packet( Client* client, PKTBI_F0* msg )
outMsg->offset += 2; // len
outMsg->Write<u8>( PKTBI_F0::QUERY_GUILD + 1U ); // sub, response is +1
outMsg->Write<u8>( locations );
for ( Core::SerialSet::iterator itr = guild->_member_serials.begin();
itr != guild->_member_serials.end(); ++itr )
for ( u32 serial : guild->_member_serials )
{
u32 serial = *itr;
if ( serial == me->serial )
continue;

@@ -773,6 +773,23 @@ void Party::printOn( Clib::StreamWriter& sw ) const
// sw.flush();
}

std::vector<Mobile::Character*> Party::get_members() const
{
std::vector<Mobile::Character*> ret;
Mobile::Character* chr;

chr = Core::find_character( _leaderserial );
if ( chr )
ret.emplace_back( chr );
for ( auto& serial : _member_serials )
{
chr = Core::find_character( serial );
if ( chr )
ret.emplace_back( chr );
}
return ret;
}

size_t Party::estimateSize() const
{
return 3 * sizeof( u32* ) + _member_serials.capacity() * sizeof( u32 ) + 3 * sizeof( u32* ) +
@@ -87,6 +87,7 @@ class Party : public ref_counted
void printOn( Clib::StreamWriter& sw ) const;
u32 get_member_at( unsigned short pos ) const;
void cleanup();
std::vector<Mobile::Character*> get_members() const;
size_t estimateSize() const;

friend class Module::EPartyRefObjImp;

0 comments on commit 9b1b7b8

Please sign in to comment.
You can’t perform that action at this time.