14 #include "pol_global_config.h" 24 #include "../clib/cfgelem.h" 25 #include "../clib/cfgfile.h" 26 #include "../clib/cfgsect.h" 27 #include "../clib/clib_endian.h" 28 #include "../clib/fileutil.h" 29 #include "../clib/logfacility.h" 30 #include "../clib/streamsaver.h" 31 #include "../plib/systemstate.h" 55 #include "../bscript/bobject.h" 67 _candidates_serials(),
68 _offlinemember_serials(),
69 _leaderserial( serial ),
104 std::string tmp = elem.
remove_string(
"PrivateMsgPrefix",
"" );
105 if ( tmp.size() == 0 )
111 for (
unsigned i = 0; i < tmp.size(); ++i )
113 arr->addElement(
new Bscript::BLong( static_cast<unsigned char>( tmp[i] ) ) );
131 if ( elem.
remove_prop(
"CanRemoveMember", &temp ) )
142 if ( elem.
remove_prop(
"ChangePublicChat", &temp ) )
145 if ( elem.
remove_prop(
"ChangePrivateChat", &temp ) )
156 if ( elem.
remove_prop(
"OnLootPermChange", &temp ) )
180 while ( cf.
read( elem ) )
184 else if ( hooks.
matches( elem ) && !reload )
299 if ( chr !=
nullptr )
355 [&](
u32& i ) {
return i == serial; } );
367 [&](
u32& i ) {
return i == serial; } );
379 [&](
u32& i ) {
return i == serial; } );
391 [&](
u32& i ) {
return i == serial; } );
427 if ( chr !=
nullptr )
436 u16 len = msg->offset;
440 msg->WriteFlipped<
u16>( len );
442 if ( to_chr ==
nullptr )
447 if ( chr !=
nullptr )
466 if ( chr !=
nullptr )
468 chr->party(
nullptr );
479 if ( chr !=
nullptr )
480 chr->candidate_of(
nullptr );
485 if ( chr !=
nullptr )
486 chr->offline_mem_of(
nullptr );
489 _member_serials.clear();
490 _candidates_serials.clear();
491 _offlinemember_serials.clear();
515 if ( chr !=
nullptr )
523 u16 len = msg->offset;
527 msg->WriteFlipped<
u16>( len );
532 if ( chr !=
nullptr )
552 if ( affix !=
nullptr )
560 if ( chr !=
nullptr )
562 if ( chr != exeptchr )
566 if ( affix !=
nullptr )
590 if ( newmember ==
nullptr )
595 if ( chr !=
nullptr )
597 if ( newmember != chr )
623 int mh = vital.maximum_ones();
626 msg->WriteFlipped<
u16>( 1000u );
627 msg->WriteFlipped<
u16>(
static_cast<u16>( h * 1000 / mh ) );
632 if ( mem !=
nullptr )
651 int mh = vital.maximum_ones();
654 msg->WriteFlipped<
u16>( 1000u );
655 msg->WriteFlipped<
u16>(
static_cast<u16>( h * 1000 / mh ) );
660 if ( mem !=
nullptr )
689 unsigned len =
static_cast<unsigned int>( arr->
ref_arr.size() );
702 msg->Write( &wtext[0], static_cast<u16>( wtextlen ),
false );
703 u16 len = msg->offset;
705 msg->WriteFlipped<
u16>( len );
710 if ( mem !=
nullptr )
719 size_t wtextlen )
const 739 unsigned len =
static_cast<unsigned int>( arr->
ref_arr.size() );
758 msg->Write( &wtext[0], static_cast<u16>( wtextlen ),
false );
759 u16 len = msg->offset;
761 msg->WriteFlipped<
u16>( len );
779 if ( mem !=
nullptr )
780 sw() <<
"\tMember\t0x" << fmt::hex( mserial ) <<
pf_endl;
783 sw() <<
"}" << pf_endl <<
pf_endl;
800 msg->WriteFlipped<
u16>( 11u );
814 if ( !( *itr )->register_with_members() )
827 [&](
PartyRef& party ) {
return party->is_leader( leader ); } );
848 static int num_until_dot = 1000;
849 clock_t start = clock();
850 while ( cf.
read( elem ) )
852 if ( --num_until_dot == 0 )
855 num_until_dot = 1000;
857 if ( sect_party.
matches( elem ) )
860 clock_t end = clock();
861 int ms =
static_cast<int>( ( end - start ) * 1000.0 / CLOCKS_PER_SEC );
874 party->printOn( sw );
880 if ( chr->has_party() )
884 Party* party = chr->party();
893 chr->party(
nullptr );
903 chr->party(
nullptr );
914 chr->offline_mem_of( party );
925 if ( chr->has_offline_mem_of() )
927 Party* party = chr->offline_mem_of();
940 chr->offline_mem_of(
nullptr );
942 else if ( !chr->has_party() )
946 Party* party = chr->party();
988 if ( chr->
client !=
nullptr )
1011 if ( chr->
client !=
nullptr )
1014 if ( rem !=
nullptr )
1016 Party* party = chr->party();
1039 rem->party(
nullptr );
1055 Party* party = client->
chr->party();
1056 if ( party ==
nullptr )
1073 if ( client->
chr == member )
1099 member->party(
nullptr );
1120 if ( member !=
nullptr )
1122 Party* party = client->
chr->party();
1124 if ( ( party !=
nullptr ) && ( member->has_party() ) && ( party->
is_member( member->
serial ) ) )
1141 if ( intextlen < 0 )
1147 for ( i = 0; i < intextlen; i++ )
1154 wtextbuf[wtextbuflen++] =
ctBEu16( wc );
1156 wtextbuf[wtextbuflen++] = (
u16)0;
1177 Party* party = client->
chr->party();
1178 if ( party !=
nullptr )
1195 if ( intextlen < 0 )
1204 char no_c = wcout.narrow( (
wchar_t)
cfBEu16( themsg[0] ),
'?' );
1205 if ( ( isdigit( no_c ) ) && (
cfBEu16( themsg[1] ) == L
' ' ) )
1207 int no = atoi( &no_c );
1222 for ( i = starti; i < intextlen; i++ )
1229 wtextbuf[wtextbuflen++] =
ctBEu16( wc );
1231 wtextbuf[wtextbuflen++] = (
u16)0;
1264 if ( !client->
chr->has_party() )
1282 if ( leader !=
nullptr )
1284 Party* party = leader->party();
1285 if ( party !=
nullptr )
1290 client->
chr->candidate_of(
nullptr );
1293 client->
chr->party( party );
1314 if ( leader !=
nullptr )
1316 Party* party = leader->party();
1317 if ( party !=
nullptr )
1322 client->
chr->candidate_of(
nullptr );
1344 if ( leader ==
nullptr )
1346 if ( member ==
nullptr )
1352 Party* party = leader->party();
1353 if ( member == leader )
1355 else if ( ( party !=
nullptr ) && ( !party->
is_leader( leader->
serial ) ) )
1359 else if ( ( party !=
nullptr ) && ( !party->
can_add() ) )
1365 else if ( ( party !=
nullptr ) && ( party->
is_member( member->
serial ) ) )
1371 else if ( member->has_party() )
1376 if ( member->has_candidate_of() )
1390 if ( party ==
nullptr )
1394 leader->party( party );
1401 member->candidate_of( party );
1414 Party* party = mem->candidate_of();
1415 if ( party !=
nullptr )
1425 if ( leader !=
nullptr )
1434 mem->candidate_of(
nullptr );
1441 msg->WriteFlipped<
u16>( 10u );
1461 int mh = hits.maximum_ones();
1464 msg->WriteFlipped<
u16>( 1000u );
1465 msg->WriteFlipped<
u16>(
static_cast<u16>( h * 1000 / mh ) );
1471 mh = mana.maximum_ones();
1474 msg->WriteFlipped<
u16>( 1000u );
1475 msg->WriteFlipped<
u16>(
static_cast<u16>( h * 1000 / mh ) );
1481 mh = stam.maximum_ones();
1484 msg->WriteFlipped<
u16>( 1000u );
1485 msg->WriteFlipped<
u16>(
static_cast<u16>( h * 1000 / mh ) );
1494 return mob_flags_.get( MOB_FLAGS::PARTY_CAN_LOOT );
1499 mob_flags_.change( MOB_FLAGS::PARTY_CAN_LOOT, b );
1504 if ( this->party_decline_timeout_ !=
nullptr )
1505 this->party_decline_timeout_->cancel();
1515 if ( this->party_decline_timeout_ !=
nullptr )
1522 if ( this->party_decline_timeout_ !=
nullptr )
1523 this->party_decline_timeout_->cancel();
const int CLP_Already_in_a_Party
void printProperties(Clib::StreamWriter &sw) const
void set_party_can_loot(bool)
void cancel_party_invite_timeout()
PKTBI_BF_06_01_IN partyadd
void build_sysmessage_cl_affix(PktOut_CC *msg, unsigned int cliloc_num, const char *affix, bool prepend, const u16 *arguments, unsigned short font, unsigned short color)
void set_party_invite_timeout()
struct Pol::Core::Party_Cfg::@14 Hooks
void send_sysmessage_cl(Client *client, unsigned int cliloc_num, const u16 *arguments, unsigned short font, unsigned short color)
FullMsgTargetCursor remove_member_cursor
const int CLP_Last_Person
std::string remove_string(const char *propname)
void printOn(Clib::StreamWriter &sw) const
ExportedFunction * OnPartyCreate
ExportedFunction * ChangePublicChat
void party_cmd_handler(Client *client, PKTBI_BF *msg)
ExportedFunction * OnDecline
bool remove_offline_mem(u32 serial)
bool is_leader(u32 serial) const
PKTBI_BF_06_02_IN partyremove
bool call(Bscript::BObjectImp *p0)
bool isa(BObjectType type) const
void send_short_statmsg(Network::Client *client, Mobile::Character *chr)
bool party_can_loot() const
std::string world_data_path
size_t estimateSize() const
PKTBI_BF_06_03 partymembermsg
ExportedFunction * OnLootPermChange
bool remove_candidate(u32 serial)
struct Pol::Core::Party_Cfg::@13 General
bool RemoveMemberOnLogoff
ExportedFunction * CanRemoveMember
void handle_unknown_packet(Client *client)
PKTBI_BF_06_08 partyaccinvite
BObjectImp * CreatePartyRefObjImp(Core::Party *party)
unsigned int remove_ulong(const char *propname)
bool is_visible_to_me(const Character *chr) const
u32 get_member_at(unsigned short pos) const
bool has_active_client() const
ExportedFunction * OnAddToParty
bool is_member(u32 serial) const
size_t estimatedSize() const
bool remove_member(u32 serial)
std::vector< u32 > _offlinemember_serials
void send_msg_to_all(unsigned int clilocnr, const char *affix=0, Mobile::Character *exeptchr=nullptr) const
FullMsgTargetCursor add_member_cursor
bool matches(const ConfigElem &elem)
void load_party_cfg_general(Clib::ConfigElem &elem)
const int CLP_Notify_Decline
ExportedFunction * CanLeaveParty
const int CLP_Cannot_Remove_Self
const int CLP_Too_Late_Decline
void invite_timeout(Mobile::Character *mem)
void send_stat_to(Mobile::Character *chr, Mobile::Character *bob) const
void handle_party_msg(Network::Client *client, PKTBI_BF *msg)
void register_party_members()
void add_offline_mem(u32 serial)
const int CLP_Ignore_Offer
void handle_add(Network::Client *client, PKTBI_BF *msg)
void build_sysmessage_cl(PktOut_C1 *msg, unsigned int cliloc_num, const u16 *arguments, unsigned short font, unsigned short color)
void on_loggon_party(Mobile::Character *chr)
void send_empty_party(Mobile::Character *chr)
const int CLP_Prevent_Loot
void on_loggoff_party(Mobile::Character *chr)
PKTBI_BF_06_04_IN partymsg
void handle_loot_perm(Network::Client *client, PKTBI_BF *msg)
virtual bool isTrue() const
void disband_party(u32 leader)
ExportedFunction * OnDisband
void handle_member_msg(Network::Client *client, PKTBI_BF *msg)
PKTBI_BF_06_06 partylootperm
const unsigned CST_NORMAL
const int CLP_Player_Rejoined
ExportedFunction * OnPublicChat
NetworkManager networkManager
const int CLP_Add_Yourself
bool convertArrayToUC(Bscript::ObjArray *&in_text, u16 *out_wtext, size_t textlen, bool ConvToBE, bool nullterm)
void Send(Client *client, int len=-1) const
void on_stam_changed(Mobile::Character *chr) const
void handle_accept_invite(Network::Client *client, PKTBI_BF *msg)
ExportedFunction * OnLeaveParty
void unload_party_hooks()
void write_party(Clib::StreamWriter &sw)
const int CLP_Already_Your_Party
virtual Bscript::BObjectImp * make_ref() POL_OVERRIDE
void readProperties(Clib::ConfigElem &elem)
bool convertUCtoArray(const u16 *in_wtext, Bscript::ObjArray *&out_text, size_t textlen, bool ConvFromBE)
const int CLP_Player_Removed
bool has_party_invite_timeout() const
PKTBI_BF_06_09 partydecinvite
Party(Clib::ConfigElem &elem)
void on_mana_changed(Mobile::Character *chr) const
const int CLP_Add_No_Leader
std::vector< u32 > _member_serials
void handle_add_member_cursor(Mobile::Character *chr, PKTBI_6C *msgin)
SettingsManager settingsManager
void send_member_msg_public(Mobile::Character *chr, u16 *wtext, size_t wtextlen) const
Bscript::BObject call_object(Bscript::BObjectImp *p0, Bscript::BObjectImp *p1)
Mobile::Character * system_find_mobile(u32 serial)
void handle_remove_member_cursor(Mobile::Character *chr, PKTBI_6C *msgin)
bool remove_prop(const char *propname, std::string *value)
const int CLP_Who_to_Remove
void load_party_cfg_hooks(Clib::ConfigElem &elem)
u16 PrivateMsgPrefix[SPEECH_MAX_LEN+1]
void send_attributes_normalized(Mobile::Character *chr, Mobile::Character *bob)
void load_party_cfg(bool reload)
void handle_decline_invite(Network::Client *client, PKTBI_BF *msg)
unsigned char PrivateMsgPrefixLen
void send_sysmessage_cl_affix(Client *client, unsigned int cliloc_num, const char *affix, bool prepend, const u16 *arguments, unsigned short font, unsigned short color)
unsigned short pol_distance(unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2)
bool send_object_cursor(Network::Client *client, PKTBI_6C::CURSOR_TYPE crstype=PKTBI_6C::CURSOR_TYPE_NEUTRAL)
void send_member_list(Mobile::Character *to_chr)
unsigned short remove_ushort(const char *propname)
ExportedFunction * FindExportedFunction(Clib::ConfigElem &elem, const Plib::Package *pkg, const std::string &descriptor, unsigned nargs, bool complain_if_missing)
bool isa(UOBJ_CLASS uobj_class) const
const VitalValue & vital(unsigned vitalid) const
ExportedFunction * CanAddToParty
bool add_candidate(u32 serial)
void handle_remove(Network::Client *client, PKTBI_BF *msg)
bool is_candidate(u32 serial) const
void send_remove_member(Mobile::Character *chr, bool *disband)
void set_leader(u32 serial)
bool FileExists(const char *filename)
ExportedFunction * OnPrivateChat
bool register_with_members()
bool read(ConfigElem &elem)
unsigned short DeclineTimeout
void send_stats_on_add(Mobile::Character *newmember) const
ExportedFunction * ChangePrivateChat
virtual std::string name() const
bool add_member(u32 serial)
std::vector< u32 > _candidates_serials
const polclock_t POLCLOCKS_PER_SEC
bool remove_bool(const char *propname)
void send_member_msg_private(Mobile::Character *chr, Mobile::Character *tochr, u16 *wtext, size_t wtextlen) const
unsigned short MaxPartyMembers
UoClientGeneral uoclient_general
void send_invite(Mobile::Character *member, Mobile::Character *leader)