Skip to content
Permalink
Browse files

add Guild::get_members()

  • Loading branch information
KevinEady committed Mar 22, 2020
1 parent 7b6e02a commit b0747f5b93c3e8cc50a79dbff1c154b63901160a
Showing with 28 additions and 18 deletions.
  1. +15 −2 pol-core/pol/guilds.cpp
  2. +5 −5 pol-core/pol/guilds.h
  3. +4 −7 pol-core/pol/miscmsg.cpp
  4. +3 −3 pol-core/pol/party.cpp
  5. +1 −1 pol-core/pol/party.h
@@ -175,6 +175,19 @@ void Guild::addMember( unsigned int serial )
_member_serials.insert( serial );
}

std::vector<Mobile::Character*> Guild::get_members( bool include_offline ) const
{
std::vector<Mobile::Character*> ret;

for ( auto& serial : _member_serials )
{
Mobile::Character* chr = Core::system_find_mobile( serial );
if ( chr && ( include_offline || chr->logged_in() ) )
ret.push_back( chr );
}
return ret;
}

bool Guild::AreAllies( Guild* g1, Guild* g2 )
{
return ( g1 == g2 || g1->hasAlly( g2 ) );
@@ -273,5 +286,5 @@ size_t Guild::estimateSize() const
_enemyguild_serials.size() * ( sizeof( unsigned int ) + 3 * sizeof( void* ) ) +
_proplist.estimatedSize() + sizeof( bool ); /*_disbanded*/
}
}
}
} // namespace Core
} // namespace Pol
@@ -2,16 +2,16 @@
#define GUILDS_H

#include "../clib/refptr.h"
#include "proplist.h"
#include "network/msghandl.h"
#include "proplist.h"

namespace Pol
{
namespace Clib
{
class ConfigElem;
class StreamWriter;
}
} // namespace Clib
namespace Mobile
{
class Character;
@@ -52,6 +52,7 @@ class Guild : public ref_counted

void printOn( Clib::StreamWriter& sw ) const;
void addMember( unsigned int serial );
std::vector<Mobile::Character*> get_members( bool include_offline = false ) const;

void registerWithMembers();
size_t estimateSize() const;
@@ -62,7 +63,6 @@ class Guild : public ref_counted
static Guild* FindOrCreateGuild( unsigned int guildid, unsigned int memberserial );

friend class Module::EGuildRefObjImp;
friend void handle_krrios_packet( Network::Client* client, Core::PKTBI_F0* msg );

private:
unsigned int _guildid;
@@ -72,6 +72,6 @@ class Guild : public ref_counted
PropertyList _proplist;
bool _disbanded;
};
}
}
} // namespace Core
} // namespace Pol
#endif
@@ -429,8 +429,7 @@ 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
auto members = party->get_members();
for ( auto member : members )
for ( auto member : party->get_members() )
{
if ( member->serial == me->serial )
continue;
@@ -468,14 +467,12 @@ 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 ( u32 serial : guild->_member_serials )
for ( auto member : guild->get_members() )
{
if ( serial == me->serial )
if ( member->serial == me->serial )
continue;

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

outMsg->Write<u32>( member->serial_ext );
@@ -773,14 +773,14 @@ void Party::printOn( Clib::StreamWriter& sw ) const
// sw.flush();
}

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

for ( auto& serial : _member_serials )
{
Mobile::Character* chr = Core::find_character( serial );
if ( chr )
Mobile::Character* chr = Core::system_find_mobile( serial );
if ( chr && ( include_offline || chr->logged_in() ) )
ret.push_back( chr );
}
return ret;
@@ -87,7 +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;
std::vector<Mobile::Character*> get_members( bool include_offline = false ) const;
size_t estimateSize() const;

friend class Module::EPartyRefObjImp;

0 comments on commit b0747f5

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