/** @file * * @par History * - 2009/07/23 MuadDib: updates for new Enum::Packet Out ID * - 2009/09/06 Turley: Changed Version checks to bitfield client->ClientType * - 2009/10/12 Turley: whisper/yell/say-range ssopt definition */ #include "../clib/rawtypes.h" #include "containr.h" #include "item/item.h" #include "menu.h" #include "mobile/charactr.h" #include "network/client.h" #include "network/packethelper.h" #include "network/packets.h" #include "tooltips.h" #include "ufunc.h" namespace Pol { namespace Core { using namespace Network; bool send_menu( Client* client, Menu* menu ) { // build up the message so it gets sent as a unit. if ( menu->menuitems_.size() > 255 ) return false; PktHelper::PacketOut msg; msg->offset += 2; msg->offset += 4; // used_item_serial msg->WriteFlipped( menu->menu_id ); size_t stringlen = strlen( menu->title ); if ( stringlen > 80 ) stringlen = 80; msg->Write( stringlen ); // NOTE null-term not included! msg->Write( menu->title, static_cast( stringlen ), false ); msg->Write( menu->menuitems_.size() ); for ( unsigned idx = 0; idx < menu->menuitems_.size(); idx++ ) { if ( msg->offset + 85 > static_cast( sizeof msg->buffer ) ) { return false; } MenuItem* mi = &menu->menuitems_[idx]; msg->WriteFlipped( mi->graphic_ ); msg->WriteFlipped( mi->color_ ); stringlen = strlen( mi->title ); if ( stringlen > 80 ) stringlen = 80; msg->Write( stringlen ); // NOTE null-term not included! msg->Write( mi->title, static_cast( stringlen ), false ); } u16 len = msg->offset; msg->offset = 1; msg->WriteFlipped( len ); msg.Send( client, len ); return true; } void send_open_gump( Client* client, const UContainer& cont ) { PktHelper::PacketOut msg; msg->Write( cont.serial_ext ); msg->WriteFlipped( cont.gump() ); if ( client->ClientType & CLIENTTYPE_7090 ) msg->WriteFlipped( 0x7Du ); msg.Send( client ); } // dave changed 11/9/3, don't send invis items to those who can't see invis void send_container_contents( Client* client, const UContainer& cont ) { PktHelper::PacketOut msg; msg->offset += 4; // msglen+count u16 count = 0; for ( UContainer::const_iterator itr = cont.begin(), itrend = cont.end(); itr != itrend; ++itr ) { const Items::Item* item = GET_ITEM_PTR( itr ); if ( !item->invisible() || client->chr->can_seeinvisitems() ) { msg->Write( item->serial_ext ); msg->WriteFlipped( item->graphic ); msg->offset++; // unk6 msg->WriteFlipped( item->get_senditem_amount() ); msg->WriteFlipped( item->x ); msg->WriteFlipped( item->y ); if ( client->ClientType & CLIENTTYPE_6017 ) msg->Write( item->slot_index() ); msg->Write( cont.serial_ext ); msg->WriteFlipped( item->color ); // color ++count; } else { send_remove_object( client, item ); // TODO: Doesn't this send a list of invisible items on the corpse? } } u16 len = msg->offset; msg->offset = 1; msg->WriteFlipped( len ); msg->WriteFlipped( count ); msg.Send( client, len ); if ( client->UOExpansionFlag & AOS ) { // 07/11/09 Turley: moved to bottom first the client needs to know the item then we can send // revision for ( UContainer::const_iterator itr = cont.begin(), itrend = cont.end(); itr != itrend; ++itr ) { const Items::Item* item = GET_ITEM_PTR( itr ); if ( !item->invisible() || client->chr->can_seeinvisitems() ) { send_object_cache( client, item ); } } } } } }