From: <tu...@us...> - 2009-09-08 08:14:54
|
Revision: 35 http://polserver.svn.sourceforge.net/polserver/?rev=35&view=rev Author: turley Date: 2009-09-08 08:14:43 +0000 (Tue, 08 Sep 2009) Log Message: ----------- more vartype cleanup Modified Paths: -------------- trunk/pol-core/pol/network/clientio.cpp trunk/pol-core/pol/region.cpp trunk/pol-core/pol/uoclient.h trunk/pol-core/pol/uolisten.cpp Modified: trunk/pol-core/pol/network/clientio.cpp =================================================================== --- trunk/pol-core/pol/network/clientio.cpp 2009-09-08 01:42:26 UTC (rev 34) +++ trunk/pol-core/pol/network/clientio.cpp 2009-09-08 08:14:43 UTC (rev 35) @@ -237,7 +237,7 @@ passert( pch-xoutbuffer+1 <= int(sizeof xoutbuffer) ); THREAD_CHECKPOINT( active_client, 115 ); - xmit( xoutbuffer, pch-xoutbuffer+1 ); + xmit( xoutbuffer, static_cast<unsigned short>(pch-xoutbuffer+1) ); THREAD_CHECKPOINT( active_client, 116 ); } #include "../packetscrobj.h" @@ -279,7 +279,7 @@ } else { - xmit( data, len ); + xmit( data, static_cast<unsigned short>(len) ); // _xmit( client->csocket, data, len ); } } @@ -299,7 +299,7 @@ } else { - xmit( data, len ); + xmit( data, static_cast<unsigned short>(len) ); // _xmit( client->csocket, data, len ); } } Modified: trunk/pol-core/pol/region.cpp =================================================================== --- trunk/pol-core/pol/region.cpp 2009-09-08 01:42:26 UTC (rev 34) +++ trunk/pol-core/pol/region.cpp 2009-09-08 08:14:43 UTC (rev 35) @@ -187,7 +187,7 @@ regions_.push_back( rgn ); regions_byname_.insert( RegionsByName::value_type(elem.rest(), rgn) ); - paint_zones( elem, regions_.size()-1 ); + paint_zones( elem, static_cast<RegionId>(regions_.size()-1) ); rgn->read_custom_config( elem ); } Modified: trunk/pol-core/pol/uoclient.h =================================================================== --- trunk/pol-core/pol/uoclient.h 2009-09-08 01:42:26 UTC (rev 34) +++ trunk/pol-core/pol/uoclient.h 2009-09-08 08:14:43 UTC (rev 35) @@ -51,7 +51,7 @@ public: UoClientListener( ConfigElem& elem ); - unsigned port; + unsigned short port; string encryption; bool aosresist; }; Modified: trunk/pol-core/pol/uolisten.cpp =================================================================== --- trunk/pol-core/pol/uolisten.cpp 2009-09-08 01:42:26 UTC (rev 34) +++ trunk/pol-core/pol/uolisten.cpp 2009-09-08 08:14:43 UTC (rev 35) @@ -51,7 +51,7 @@ PolLock lck; client = new Client( uo_client_interface, _def.encryption ); client->csocket = _sck.release_handle(); // client cleans up its socket. - client->listen_port = static_cast<unsigned short>(_def.port); + client->listen_port = _def.port; if ( _def.aosresist ) client->aosresist = true; // UOCLient.cfg Entry // Added null setting for pre-char selection checks using NULL validation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mua...@us...> - 2009-09-14 23:57:33
|
Revision: 54 http://polserver.svn.sourceforge.net/polserver/?rev=54&view=rev Author: muaddib_pol Date: 2009-09-14 23:57:25 +0000 (Mon, 14 Sep 2009) Log Message: ----------- + Graphic change fix with layers. + Error printout if graphic member used on an object without graphic member Modified Paths: -------------- trunk/pol-core/pol/item/item.cpp trunk/pol-core/pol/module/uomod.cpp trunk/pol-core/pol/polwww.cpp trunk/pol-core/pol/uobject.cpp Modified: trunk/pol-core/pol/item/item.cpp =================================================================== --- trunk/pol-core/pol/item/item.cpp 2009-09-14 13:10:16 UTC (rev 53) +++ trunk/pol-core/pol/item/item.cpp 2009-09-14 23:57:25 UTC (rev 54) @@ -757,6 +757,9 @@ bool Item::setgraphic( u16 newgraphic ) { + if (layer && layer != LAYER_MOUNT ) + return false; + if (graphic <= UOBJ_ITEM__HIGHEST && newgraphic <= UOBJ_ITEM__HIGHEST) { set_dirty(); Modified: trunk/pol-core/pol/module/uomod.cpp =================================================================== --- trunk/pol-core/pol/module/uomod.cpp 2009-09-14 13:10:16 UTC (rev 53) +++ trunk/pol-core/pol/module/uomod.cpp 2009-09-14 23:57:25 UTC (rev 54) @@ -1609,9 +1609,12 @@ if (mi->submenu_id) { - Menu* menu = find_menu( mi->submenu_id ); - if (menu != NULL) - append_objtypes( objarr, menu ); +// Code Analyze: Commented out and replaced with tmp_menu due to hiding +// menu passed to function. +// Menu* menu = find_menu( mi->submenu_id ); + Menu* tmp_menu = find_menu( mi->submenu_id ); + if (tmp_menu != NULL) + append_objtypes( objarr, tmp_menu ); } else { @@ -2408,11 +2411,13 @@ // some part of it is contained in the box. Look at the individual statics, to see // if any of them lie within. - for( MultiDef::Components::const_iterator citr = md.components.begin(), end = md.components.end(); - citr != end; - ++citr ) +// Code Analyze: Commented and renaming due to C6246 Warning +// for( MultiDef::Components::const_iterator citr_2 = md.components.begin(), end = md.components.end(); + for( MultiDef::Components::const_iterator citr_2 = md.components.begin(), end_2 = md.components.end(); + citr_2 != end_2; + ++citr_2 ) { - const MULTI_ELEM* elem = (*citr).second; + const MULTI_ELEM* elem = (*citr_2).second; int absx = multi->x + elem->x; int absy = multi->y + elem->y; int absz = multi->z + elem->z; @@ -3295,11 +3300,13 @@ } if (res == 0) { - BStruct* res = new BStruct(); - res->addMember( "DirtyObjects", new BLong( dirty ) ); - res->addMember( "CleanObjects", new BLong( clean ) ); - res->addMember( "ElapsedMilliseconds", new BLong( elapsed_ms ) ); - return res; +// Code Analyze: C6246 +// BStruct* res = new BStruct(); + BStruct* ret = new BStruct(); + ret->addMember( "DirtyObjects", new BLong( dirty ) ); + ret->addMember( "CleanObjects", new BLong( clean ) ); + ret->addMember( "ElapsedMilliseconds", new BLong( elapsed_ms ) ); + return ret; } else { Modified: trunk/pol-core/pol/polwww.cpp =================================================================== --- trunk/pol-core/pol/polwww.cpp 2009-09-14 13:10:16 UTC (rev 53) +++ trunk/pol-core/pol/polwww.cpp 2009-09-14 23:57:25 UTC (rev 54) @@ -800,7 +800,9 @@ void start_http_conn_thread( SOCKET client_socket ) { - unsigned threadid; + // Code Analyze: C6001 + // unsigned threadid; + unsigned threadid = 0; HANDLE h; h = (HANDLE) _beginthreadex( NULL, Modified: trunk/pol-core/pol/uobject.cpp =================================================================== --- trunk/pol-core/pol/uobject.cpp 2009-09-14 13:10:16 UTC (rev 53) +++ trunk/pol-core/pol/uobject.cpp 2009-09-14 23:57:25 UTC (rev 54) @@ -1,8 +1,8 @@ /* History ======= - 2009/08/25 Shinigami: STLport-5.2.1 fix: init order changed of realm and saveonexit_ +2009/09/14 MuadDib: UObject::setgraphic added error printing. Notes ======= @@ -338,6 +338,7 @@ bool UObject::setgraphic( u16 newgraphic ) { + cerr << "UOBject::SetGraphic used, object class does not have a graphic member! Object Serial: " << serial << endl; return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mua...@us...> - 2009-09-15 19:51:07
|
Revision: 56 http://polserver.svn.sourceforge.net/polserver/?rev=56&view=rev Author: muaddib_pol Date: 2009-09-15 19:50:58 +0000 (Tue, 15 Sep 2009) Log Message: ----------- + Registration of players and some npc instances, for when walking onto Houses. Leading up to Multi Walk-on support Modified Paths: -------------- trunk/pol-core/pol/core.cpp trunk/pol-core/pol/mobile/charactr.cpp trunk/pol-core/pol/module/uomod.cpp trunk/pol-core/pol/module/uomod4.cpp trunk/pol-core/pol/multi/house.cpp trunk/pol-core/pol/multi/house.h trunk/pol-core/pol/multi/multi.h trunk/pol-core/pol/multi/multis.cpp trunk/pol-core/pol/pol.cpp Modified: trunk/pol-core/pol/core.cpp =================================================================== --- trunk/pol-core/pol/core.cpp 2009-09-15 04:32:01 UTC (rev 55) +++ trunk/pol-core/pol/core.cpp 2009-09-15 19:50:58 UTC (rev 56) @@ -97,6 +97,7 @@ chr->gradual_boost = new_boost; chr->position_changed(); + // FIXME: Need to add Walkon checks for multi right here if type is house. if (supporting_multi != NULL) { supporting_multi->register_object( chr ); Modified: trunk/pol-core/pol/mobile/charactr.cpp =================================================================== --- trunk/pol-core/pol/mobile/charactr.cpp 2009-09-15 04:32:01 UTC (rev 55) +++ trunk/pol-core/pol/mobile/charactr.cpp 2009-09-15 19:50:58 UTC (rev 56) @@ -3495,6 +3495,7 @@ y = static_cast<u16>(newy); z = static_cast<s8>(newz); + // FIXME: Need to add Walkon checks for multi right here if type is house. if (supporting_multi != NULL) { supporting_multi->register_object( this ); Modified: trunk/pol-core/pol/module/uomod.cpp =================================================================== --- trunk/pol-core/pol/module/uomod.cpp 2009-09-15 04:32:01 UTC (rev 55) +++ trunk/pol-core/pol/module/uomod.cpp 2009-09-15 19:50:58 UTC (rev 56) @@ -1329,7 +1329,8 @@ //dave added 2/3/3 send entered area events for npc create ForEachMobileInRange( x, y, realm, 32, NpcPropagateMove, static_cast<Character*>(npc.get()) ); - if (dummy_multi) + // FIXME: Need to add Walkon checks for multi right here if type is house. + if (dummy_multi) dummy_multi->register_object( npc.get() ); return new ECharacterRefObjImp( npc.get() ); } Modified: trunk/pol-core/pol/module/uomod4.cpp =================================================================== --- trunk/pol-core/pol/module/uomod4.cpp 2009-09-15 04:32:01 UTC (rev 55) +++ trunk/pol-core/pol/module/uomod4.cpp 2009-09-15 19:50:58 UTC (rev 56) @@ -238,6 +238,7 @@ y, static_cast<signed char>(z), oldrealm ); + // FIXME: Need to add Walkon checks for multi right here if type is house. if ( multi != NULL ) { multi->register_object(item); Modified: trunk/pol-core/pol/multi/house.cpp =================================================================== --- trunk/pol-core/pol/multi/house.cpp 2009-09-15 04:32:01 UTC (rev 55) +++ trunk/pol-core/pol/multi/house.cpp 2009-09-15 19:50:58 UTC (rev 56) @@ -788,8 +788,34 @@ chr_contents.pop_back(); } + house->ClearSquatters(); + house->destroy(); return new BLong(1); } +void UHouse::register_object( UObject* obj ) +{ + if (find( squatters_.begin(), squatters_.end(), obj ) == squatters_.end()) + { + set_dirty(); + squatters_.push_back( Squatter(obj) ); + } +} + +void UHouse::unregister_object( UObject* obj ) +{ + Squatters::iterator this_squatter = find( squatters_.begin(), squatters_.end(), obj ); + + if ( this_squatter != squatters_.end()) + { + set_dirty(); + squatters_.erase( this_squatter ); + } +} + +void UHouse::ClearSquatters( ) +{ + squatters_.clear(); +} \ No newline at end of file Modified: trunk/pol-core/pol/multi/house.h =================================================================== --- trunk/pol-core/pol/multi/house.h 2009-09-15 04:32:01 UTC (rev 55) +++ trunk/pol-core/pol/multi/house.h 2009-09-15 19:50:58 UTC (rev 56) @@ -43,6 +43,12 @@ bool editing; int editing_floor_num; u32 revision; + + virtual void register_object( UObject* obj ); + virtual void unregister_object( UObject* obj ); + + void ClearSquatters(); + protected: explicit UHouse( const ItemDesc& itemdesc ); void create_components(); @@ -64,6 +70,10 @@ friend class UMulti; bool custom; private: + typedef UObjectRef Squatter; + typedef std::vector< Squatter > Squatters; + Squatters squatters_; + typedef ItemRef Component; typedef std::vector< Component > Components; Components components_; Modified: trunk/pol-core/pol/multi/multi.h =================================================================== --- trunk/pol-core/pol/multi/multi.h 2009-09-15 04:32:01 UTC (rev 55) +++ trunk/pol-core/pol/multi/multi.h 2009-09-15 19:50:58 UTC (rev 56) @@ -50,6 +50,7 @@ virtual void double_click( Client* client ); virtual void register_object( UObject* obj ); + virtual void unregister_object( UObject* obj ); virtual bool script_isa( unsigned isatype ) const; const MultiDef& multidef() const; Modified: trunk/pol-core/pol/multi/multis.cpp =================================================================== --- trunk/pol-core/pol/multi/multis.cpp 2009-09-15 04:32:01 UTC (rev 55) +++ trunk/pol-core/pol/multi/multis.cpp 2009-09-15 19:50:58 UTC (rev 56) @@ -68,6 +68,10 @@ { } +void UMulti::unregister_object( UObject* obj ) +{ +} + const char* UMulti::classname() const { return "MULTI"; Modified: trunk/pol-core/pol/pol.cpp =================================================================== --- trunk/pol-core/pol/pol.cpp 2009-09-15 04:32:01 UTC (rev 55) +++ trunk/pol-core/pol/pol.cpp 2009-09-15 19:50:58 UTC (rev 56) @@ -340,6 +340,7 @@ &newz, &supporting_multi, &walkon )) { client->chr->z = static_cast<s8>(newz); + // FIXME: Need to add Walkon checks for multi right here if type is house. if (supporting_multi != NULL) { supporting_multi->register_object( client->chr ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mua...@us...> - 2009-09-15 21:57:00
|
Revision: 57 http://polserver.svn.sourceforge.net/polserver/?rev=57&view=rev Author: muaddib_pol Date: 2009-09-15 21:56:53 +0000 (Tue, 15 Sep 2009) Log Message: ----------- + Unregistering from multi on NPC/Character destroy. Modified Paths: -------------- trunk/pol-core/pol/mobile/charactr.cpp trunk/pol-core/pol/mobile/charactr.h trunk/pol-core/pol/npc.cpp trunk/pol-core/pol/npc.h Modified: trunk/pol-core/pol/mobile/charactr.cpp =================================================================== --- trunk/pol-core/pol/mobile/charactr.cpp 2009-09-15 19:50:58 UTC (rev 56) +++ trunk/pol-core/pol/mobile/charactr.cpp 2009-09-15 21:56:53 UTC (rev 57) @@ -124,6 +124,7 @@ #include "../watch.h" #include "../item/weapon.h" #include "../item/wepntmpl.h" +#include "../multi/house.h" #include "charactr.h" @@ -327,6 +328,9 @@ party_can_loot_(false), party_decline_timeout_(NULL), murderer_(false), + + registered_house( 0 ), + langid_(0) { gradual_boost = 0; @@ -466,6 +470,17 @@ void Character::destroy() { stop_skill_script(); + if ( registered_house > 0 ) + { + UMulti* multi = system_find_multi(registered_house); + if(multi != NULL) + { + UHouse* house = multi->as_house(); + if(house != NULL) + house->unregister_object((UObject*)this); + } + registered_house = 0; + } base::destroy(); } Modified: trunk/pol-core/pol/mobile/charactr.h =================================================================== --- trunk/pol-core/pol/mobile/charactr.h 2009-09-15 19:50:58 UTC (rev 56) +++ trunk/pol-core/pol/mobile/charactr.h 2009-09-15 21:56:53 UTC (rev 57) @@ -53,6 +53,7 @@ #include "../reftypes.h" #include "../ssopt.h" +#include "../multi/house.h" class Account; class Attribute; @@ -724,6 +725,8 @@ ref_ptr<WornItemsContainer> wornitems_ref; WornItemsContainer& wornitems; + u32 registered_house; + // s16 strength_mod_; // s16 intelligence_mod_; // s16 dexterity_mod_; Modified: trunk/pol-core/pol/npc.cpp =================================================================== --- trunk/pol-core/pol/npc.cpp 2009-09-15 19:50:58 UTC (rev 56) +++ trunk/pol-core/pol/npc.cpp 2009-09-15 21:56:53 UTC (rev 57) @@ -18,11 +18,11 @@ */ #include "../clib/stl_inc.h" + #ifdef _MSC_VER -#pragma warning(disable:4786) +# pragma warning(disable:4786) #endif - #include "../clib/cfgelem.h" #include "../clib/clib.h" #include "../clib/endian.h" @@ -76,6 +76,7 @@ #include "watch.h" #include "item/weapon.h" #include "wrldsize.h" +#include "multi/house.h" /* An area definition is as follows: pt: (x,y) @@ -123,6 +124,17 @@ { // stop_scripts(); wornitems.destroy_contents(); + if ( registered_house > 0 ) + { + UMulti* multi = system_find_multi(registered_house); + if(multi != NULL) + { + UHouse* house = multi->as_house(); + if(house != NULL) + house->unregister_object((UObject*)this); + } + registered_house = 0; + } base::destroy(); } Modified: trunk/pol-core/pol/npc.h =================================================================== --- trunk/pol-core/pol/npc.h 2009-09-15 19:50:58 UTC (rev 56) +++ trunk/pol-core/pol/npc.h 2009-09-15 21:56:53 UTC (rev 57) @@ -99,8 +99,6 @@ void readPropertiesForNewNPC( ConfigElem& elem ); virtual void destroy(); - - NpcTemplate::ALIGNMENT alignment() const; unsigned damaged_sound; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mua...@us...> - 2009-09-16 03:51:47
|
Revision: 58 http://polserver.svn.sourceforge.net/polserver/?rev=58&view=rev Author: muaddib_pol Date: 2009-09-16 03:51:38 +0000 (Wed, 16 Sep 2009) Log Message: ----------- + More House Multi registration code Modified Paths: -------------- trunk/pol-core/pol/core.cpp trunk/pol-core/pol/mobile/charactr.cpp trunk/pol-core/pol/mobile/charactr.h trunk/pol-core/pol/module/uomod.cpp trunk/pol-core/pol/module/uomod4.cpp trunk/pol-core/pol/multi/house.cpp trunk/pol-core/pol/npc.cpp trunk/pol-core/pol/pol.cpp Modified: trunk/pol-core/pol/core.cpp =================================================================== --- trunk/pol-core/pol/core.cpp 2009-09-15 21:56:53 UTC (rev 57) +++ trunk/pol-core/pol/core.cpp 2009-09-16 03:51:38 UTC (rev 58) @@ -2,6 +2,7 @@ History ======= 2009/09/03 MuadDib: Relocation of multi related cpp/h +2009/09/15 MuadDib: Multi registration/unregistration support added. Notes ======= @@ -16,6 +17,7 @@ #include "network/cgdata.h" #include "network/client.h" #include "core.h" +#include "fnsearch.h" #include "item/itemdesc.h" #include "polsem.h" #include "module/polsystemmod.h" @@ -101,7 +103,23 @@ if (supporting_multi != NULL) { supporting_multi->register_object( chr ); + if ( supporting_multi->as_house() != NULL ) + chr->registered_house = supporting_multi->serial; } + else + { + if ( chr->registered_house > 0 ) + { + UMulti* multi = system_find_multi(chr->registered_house); + if(multi != NULL) + { + UHouse* house = multi->as_house(); + if(house != NULL) + house->unregister_object(chr); + } + chr->registered_house = 0; + } + } // teleport( chr ); if (chr->has_active_client()) Modified: trunk/pol-core/pol/mobile/charactr.cpp =================================================================== --- trunk/pol-core/pol/mobile/charactr.cpp 2009-09-15 21:56:53 UTC (rev 57) +++ trunk/pol-core/pol/mobile/charactr.cpp 2009-09-16 03:51:38 UTC (rev 58) @@ -37,6 +37,9 @@ Changes for account related source file relocation Changes for multi related source file relocation 2009/09/09 Turley: ServSpecOpt CarryingCapacityMod as * modifier for Character::carrying_capacity() +2009/09/15 MuadDib: Cleanup from registered houses on destroy + u32 registered_house added to store serial of registered multi. + Multi registration/unregistration support added. Notes ======= @@ -3514,7 +3517,23 @@ if (supporting_multi != NULL) { supporting_multi->register_object( this ); + if ( supporting_multi->as_house() != NULL ) + registered_house = supporting_multi->serial; } + else + { + if ( registered_house > 0 ) + { + UMulti* multi = system_find_multi(registered_house); + if(multi != NULL) + { + UHouse* house = multi->as_house(); + if(house != NULL) + house->unregister_object((UObject*)this); + } + registered_house = 0; + } + } gradual_boost = current_boost; MoveCharacterWorldPosition( lastx, lasty, x, y, this, NULL ); Modified: trunk/pol-core/pol/mobile/charactr.h =================================================================== --- trunk/pol-core/pol/mobile/charactr.h 2009-09-15 21:56:53 UTC (rev 57) +++ trunk/pol-core/pol/mobile/charactr.h 2009-09-16 03:51:38 UTC (rev 58) @@ -9,6 +9,8 @@ 2008/07/08 Turley: get_flag1() changed to show WarMode of other player again get_flag1_aos() removed 2009/02/01 MuadDib: Resistance storage added. +2009/09/15 MuadDib: Cleanup from registered houses on destroy + u32 registered_house added to store serial of registered multi. Notes ======= @@ -628,6 +630,8 @@ AccountRef acct; Client* client; + u32 registered_house; + unsigned char cmdlevel; u8 dir; // the entire 'dir' from their last MSG02_WALK bool warmode; @@ -725,8 +729,6 @@ ref_ptr<WornItemsContainer> wornitems_ref; WornItemsContainer& wornitems; - u32 registered_house; - // s16 strength_mod_; // s16 intelligence_mod_; // s16 dexterity_mod_; Modified: trunk/pol-core/pol/module/uomod.cpp =================================================================== --- trunk/pol-core/pol/module/uomod.cpp 2009-09-15 21:56:53 UTC (rev 57) +++ trunk/pol-core/pol/module/uomod.cpp 2009-09-16 03:51:38 UTC (rev 58) @@ -45,6 +45,7 @@ 2009/09/03 MuadDib: Changes for account related source file relocation Changes for multi related source file relocation 2009/09/14 MuadDib: Slot support added to creation/move to container. +2009/09/15 MuadDib: Multi registration/unregistration support added. Notes ======= @@ -1331,7 +1332,26 @@ NpcPropagateMove, static_cast<Character*>(npc.get()) ); // FIXME: Need to add Walkon checks for multi right here if type is house. if (dummy_multi) + { dummy_multi->register_object( npc.get() ); + if ( dummy_multi->as_house() != NULL ) + npc->registered_house = dummy_multi->serial; + } + else + { + if ( npc->registered_house > 0 ) + { + UMulti* multi = system_find_multi(npc->registered_house); + if(multi != NULL) + { + UHouse* house = multi->as_house(); + if(house != NULL) + house->unregister_object(npc.get()); + } + npc->registered_house = 0; + } + } + return new ECharacterRefObjImp( npc.get() ); } catch( std::exception& ex ) Modified: trunk/pol-core/pol/module/uomod4.cpp =================================================================== --- trunk/pol-core/pol/module/uomod4.cpp 2009-09-15 21:56:53 UTC (rev 57) +++ trunk/pol-core/pol/module/uomod4.cpp 2009-09-16 03:51:38 UTC (rev 58) @@ -238,7 +238,6 @@ y, static_cast<signed char>(z), oldrealm ); - // FIXME: Need to add Walkon checks for multi right here if type is house. if ( multi != NULL ) { multi->register_object(item); Modified: trunk/pol-core/pol/multi/house.cpp =================================================================== --- trunk/pol-core/pol/multi/house.cpp 2009-09-15 21:56:53 UTC (rev 57) +++ trunk/pol-core/pol/multi/house.cpp 2009-09-16 03:51:38 UTC (rev 58) @@ -4,6 +4,8 @@ 2005/06/06 Shinigami: added readobjects - to get a list of statics 2005/11/26 Shinigami: changed "strcmp" into "stricmp" to suppress Script Errors 2009/09/03 MuadDib: Relocation of multi related cpp/h +2009/09/14 MuadDib: Squatters code added to register.unregister mobs. +2009/09/15 MuadDib: Better cleanup handling on house destroy. Alos clears registered_house off character. Notes ======= @@ -785,6 +787,7 @@ { Character* chr = chr_contents.back(); move_to_ground( chr ); + chr->registered_house = 0; chr_contents.pop_back(); } Modified: trunk/pol-core/pol/npc.cpp =================================================================== --- trunk/pol-core/pol/npc.cpp 2009-09-15 21:56:53 UTC (rev 57) +++ trunk/pol-core/pol/npc.cpp 2009-09-16 03:51:38 UTC (rev 58) @@ -11,6 +11,7 @@ 2009/07/23 MuadDib: updates for new Enum::Packet Out ID 2009/08/25 Shinigami: STLport-5.2.1 fix: params not used STLport-5.2.1 fix: init order changed of damaged_sound +2009/09/15 MuadDib: Cleanup from registered houses on destroy Notes ======= Modified: trunk/pol-core/pol/pol.cpp =================================================================== --- trunk/pol-core/pol/pol.cpp 2009-09-15 21:56:53 UTC (rev 57) +++ trunk/pol-core/pol/pol.cpp 2009-09-16 03:51:38 UTC (rev 58) @@ -40,6 +40,7 @@ 2009/08/19 Turley: PKTIN_5D clientflag saved in client->UOExpansionFlagClient 2009/09/03 MuadDib: Relocation of account related cpp/h Changes for multi related source file relocation +2009/09/15 MuadDib: Multi registration/unregistration support added. Notes ======= @@ -97,6 +98,7 @@ #include "core.h" #include "crypwrap.h" #include "decay.h" +#include "fnsearch.h" #include "gameclck.h" #include "gflag.h" #include "guardrgn.h" @@ -344,7 +346,23 @@ if (supporting_multi != NULL) { supporting_multi->register_object( client->chr ); + if ( supporting_multi->as_house() != NULL ) + client->chr->registered_house = supporting_multi->serial; } + else + { + if ( client->chr->registered_house > 0 ) + { + UMulti* multi = system_find_multi(client->chr->registered_house); + if(multi != NULL) + { + UHouse* house = multi->as_house(); + if(house != NULL) + house->unregister_object(client->chr); + } + client->chr->registered_house = 0; + } + } client->chr->position_changed(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mua...@us...> - 2009-09-16 05:52:31
|
Revision: 59 http://polserver.svn.sourceforge.net/polserver/?rev=59&view=rev Author: muaddib_pol Date: 2009-09-16 05:52:14 +0000 (Wed, 16 Sep 2009) Log Message: ----------- + House Walk On working. Prob needs added in additional places, will look into this before adding to changelog. Modified Paths: -------------- trunk/pol-core/pol/core.cpp trunk/pol-core/pol/mobile/charactr.cpp trunk/pol-core/pol/module/uomod.cpp trunk/pol-core/pol/multi/house.cpp trunk/pol-core/pol/multi/house.h trunk/pol-core/pol/pol.cpp Modified: trunk/pol-core/pol/core.cpp =================================================================== --- trunk/pol-core/pol/core.cpp 2009-09-16 03:51:38 UTC (rev 58) +++ trunk/pol-core/pol/core.cpp 2009-09-16 05:52:14 UTC (rev 59) @@ -102,9 +102,17 @@ // FIXME: Need to add Walkon checks for multi right here if type is house. if (supporting_multi != NULL) { - supporting_multi->register_object( chr ); - if ( supporting_multi->as_house() != NULL ) - chr->registered_house = supporting_multi->serial; + supporting_multi->register_object( chr ); + UHouse* this_house = supporting_multi->as_house(); + if ( this_house != NULL ) + { + if ( chr->registered_house == 0 ) + { + chr->registered_house = supporting_multi->serial; + //cout << "walk on multi triggered" << endl; + this_house->walk_on( chr ); + } + } } else { Modified: trunk/pol-core/pol/mobile/charactr.cpp =================================================================== --- trunk/pol-core/pol/mobile/charactr.cpp 2009-09-16 03:51:38 UTC (rev 58) +++ trunk/pol-core/pol/mobile/charactr.cpp 2009-09-16 05:52:14 UTC (rev 59) @@ -3517,8 +3517,16 @@ if (supporting_multi != NULL) { supporting_multi->register_object( this ); - if ( supporting_multi->as_house() != NULL ) - registered_house = supporting_multi->serial; + UHouse* this_house = supporting_multi->as_house(); + if ( this_house != NULL ) + { + if ( registered_house == 0 ) + { + registered_house = supporting_multi->serial; + //cout << "walk on multi triggered" << endl; + this_house->walk_on( this ); + } + } } else { Modified: trunk/pol-core/pol/module/uomod.cpp =================================================================== --- trunk/pol-core/pol/module/uomod.cpp 2009-09-16 03:51:38 UTC (rev 58) +++ trunk/pol-core/pol/module/uomod.cpp 2009-09-16 05:52:14 UTC (rev 59) @@ -1333,9 +1333,17 @@ // FIXME: Need to add Walkon checks for multi right here if type is house. if (dummy_multi) { - dummy_multi->register_object( npc.get() ); - if ( dummy_multi->as_house() != NULL ) - npc->registered_house = dummy_multi->serial; + dummy_multi->register_object( npc.get() ); + UHouse* this_house = dummy_multi->as_house(); + if ( this_house != NULL ) + { + if ( npc->registered_house == 0 ) + { + npc->registered_house = dummy_multi->serial; + //cout << "walk on multi triggered" << endl; + this_house->walk_on( npc.get() ); + } + } } else { Modified: trunk/pol-core/pol/multi/house.cpp =================================================================== --- trunk/pol-core/pol/multi/house.cpp 2009-09-16 03:51:38 UTC (rev 58) +++ trunk/pol-core/pol/multi/house.cpp 2009-09-16 05:52:14 UTC (rev 59) @@ -41,9 +41,13 @@ #include "../objtype.h" #include "../polcfg.h" #include "../realms.h" +#include "../scrsched.h" +#include "../scrstore.h" #include "../tiles.h" #include "../ufunc.h" #include "../uofile.h" +#include "../uoexec.h" +#include "../module/uomod.h" #include "../uoscrobj.h" #include "../ustruct.h" #include "../uvars.h" @@ -821,4 +825,36 @@ void UHouse::ClearSquatters( ) { squatters_.clear(); -} \ No newline at end of file +} + +void UHouse::walk_on( Character* chr ) +{ + const ItemDesc& itemdesc = find_itemdesc( objtype_ ); + if (!itemdesc.walk_on_script.empty()) + { + ref_ptr<EScriptProgram> prog; + prog = find_script2( itemdesc.walk_on_script, + true, // complain if not found + config.cache_interactive_scripts); + if (prog.get() != NULL) + { + auto_ptr<UOExecutor> ex(create_script_executor()); + ex->addModule( new UOExecutorModule( *ex ) ); + if (prog->haveProgram) + { + ex->pushArg( new BLong( chr->lastz ) ); + ex->pushArg( new BLong( chr->lasty ) ); + ex->pushArg( new BLong( chr->lastx ) ); + ex->pushArg( new EItemRefObjImp( this ) ); + ex->pushArg( new ECharacterRefObjImp( chr ) ); + } + + ex->os_module->priority = 100; + + if (ex->setProgram( prog.get() )) + { + schedule_executor( ex.release() ); + } + } + } +} Modified: trunk/pol-core/pol/multi/house.h =================================================================== --- trunk/pol-core/pol/multi/house.h 2009-09-16 03:51:38 UTC (rev 58) +++ trunk/pol-core/pol/multi/house.h 2009-09-16 05:52:14 UTC (rev 59) @@ -47,6 +47,8 @@ virtual void register_object( UObject* obj ); virtual void unregister_object( UObject* obj ); + virtual void walk_on( Character* chr ); + void ClearSquatters(); protected: Modified: trunk/pol-core/pol/pol.cpp =================================================================== --- trunk/pol-core/pol/pol.cpp 2009-09-16 03:51:38 UTC (rev 58) +++ trunk/pol-core/pol/pol.cpp 2009-09-16 05:52:14 UTC (rev 59) @@ -346,8 +346,16 @@ if (supporting_multi != NULL) { supporting_multi->register_object( client->chr ); - if ( supporting_multi->as_house() != NULL ) - client->chr->registered_house = supporting_multi->serial; + UHouse* this_house = supporting_multi->as_house(); + if ( this_house != NULL ) + { + if ( client->chr->registered_house == 0 ) + { + client->chr->registered_house = supporting_multi->serial; + //cout << "walk on multi triggered" << endl; + this_house->walk_on( client->chr ); + } + } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2009-09-16 09:02:40
|
Revision: 63 http://polserver.svn.sourceforge.net/polserver/?rev=63&view=rev Author: turley Date: 2009-09-16 09:02:33 +0000 (Wed, 16 Sep 2009) Log Message: ----------- gcc fixes Modified Paths: -------------- trunk/pol-core/pol/miscmsg.cpp trunk/pol-core/pol/mobile/charactr.cpp Modified: trunk/pol-core/pol/miscmsg.cpp =================================================================== --- trunk/pol-core/pol/miscmsg.cpp 2009-09-16 08:48:57 UTC (rev 62) +++ trunk/pol-core/pol/miscmsg.cpp 2009-09-16 09:02:33 UTC (rev 63) @@ -382,7 +382,7 @@ client->setClientType(CLIENTTYPE_UOSA); break; default: - printf( "Unknown client type send with packet 0xE1 : 0x%x\n",cfBEu32(msg->clienttype)); + printf( "Unknown client type send with packet 0xE1 : 0x%lx\n",cfBEu32(msg->clienttype)); break; } } Modified: trunk/pol-core/pol/mobile/charactr.cpp =================================================================== --- trunk/pol-core/pol/mobile/charactr.cpp 2009-09-16 08:48:57 UTC (rev 62) +++ trunk/pol-core/pol/mobile/charactr.cpp 2009-09-16 09:02:33 UTC (rev 63) @@ -245,6 +245,7 @@ trade_accepted(false), acct(NULL), client(NULL), + registered_house( 0 ), cmdlevel(0), dir(0), warmode(false), @@ -333,8 +334,6 @@ party_decline_timeout_(NULL), murderer_(false), - registered_house( 0 ), - langid_(0) { gradual_boost = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mua...@us...> - 2009-09-21 13:54:10
|
Revision: 76 http://polserver.svn.sourceforge.net/polserver/?rev=76&view=rev Author: muaddib_pol Date: 2009-09-21 13:54:01 +0000 (Mon, 21 Sep 2009) Log Message: ----------- * Working on moving resistances to base properties Modified Paths: -------------- trunk/pol-core/pol/item/item.h trunk/pol-core/pol/mobile/charactr.h trunk/pol-core/pol/uobject.h Modified: trunk/pol-core/pol/item/item.h =================================================================== --- trunk/pol-core/pol/item/item.h 2009-09-21 02:48:33 UTC (rev 75) +++ trunk/pol-core/pol/item/item.h 2009-09-21 13:54:01 UTC (rev 76) @@ -192,11 +192,6 @@ u8 layer; u8 tile_layer; - Resistances element_resist; - ElementDamages element_damage; - Resistances_Mods element_resist_mod; - ElementDamages_Mods element_damage_mod; - s16 calc_element_resist( unsigned element ) const; s16 calc_element_damage( unsigned element ) const; bool has_resistance(Character* chr); Modified: trunk/pol-core/pol/mobile/charactr.h =================================================================== --- trunk/pol-core/pol/mobile/charactr.h 2009-09-21 02:48:33 UTC (rev 75) +++ trunk/pol-core/pol/mobile/charactr.h 2009-09-21 13:54:01 UTC (rev 76) @@ -718,9 +718,6 @@ string title_guild; string title_race; - Resistances element_resist; - ElementDamages element_damage; - Expanded_Statbar expanded_statbar; u16 skillcap_; MovementCost_Mod movement_cost; @@ -737,8 +734,6 @@ s16 hitchance_mod_; s16 evasionchance_mod_; - Resistances_Mods element_resist_mod; - ElementDamages_Mods element_damage_mod; //u16 max_hits_; //u16 max_mana_; Modified: trunk/pol-core/pol/uobject.h =================================================================== --- trunk/pol-core/pol/uobject.h 2009-09-21 02:48:33 UTC (rev 75) +++ trunk/pol-core/pol/uobject.h 2009-09-21 13:54:01 UTC (rev 76) @@ -220,6 +220,12 @@ void clear_dirty() const; static unsigned long dirty_writes; static unsigned long clean_writes; + + Resistances element_resist; + ElementDamages element_damage; + Resistances_Mods element_resist_mod; + ElementDamages_Mods element_damage_mod; + protected: virtual void printProperties( std::ostream& os ) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mua...@us...> - 2009-09-22 14:13:35
|
Revision: 80 http://polserver.svn.sourceforge.net/polserver/?rev=80&view=rev Author: muaddib_pol Date: 2009-09-22 14:13:28 +0000 (Tue, 22 Sep 2009) Log Message: ----------- + Sending of light level added to sending season info as a better solution to light level resets in client due to season packets. Modified Paths: -------------- trunk/pol-core/pol/pol.cpp trunk/pol-core/pol/ufunc.cpp Modified: trunk/pol-core/pol/pol.cpp =================================================================== --- trunk/pol-core/pol/pol.cpp 2009-09-22 12:34:51 UTC (rev 79) +++ trunk/pol-core/pol/pol.cpp 2009-09-22 14:13:28 UTC (rev 80) @@ -399,14 +399,6 @@ send_season_info( client ); - // Sending Season info resets light level in client, this fixes it during login - if (client->gd->weather_region != NULL && - client->gd->weather_region->lightoverride != -1 && - client->chr->lightoverride == -1) - { - send_light( client, client->gd->weather_region->lightoverride ); - } - send_objects_newly_inrange( client ); client->chr->send_highlight(); Modified: trunk/pol-core/pol/ufunc.cpp =================================================================== --- trunk/pol-core/pol/ufunc.cpp 2009-09-22 12:34:51 UTC (rev 79) +++ trunk/pol-core/pol/ufunc.cpp 2009-09-22 14:13:28 UTC (rev 80) @@ -23,6 +23,7 @@ 2009/09/13 MuadDib: Optimized send_remove_character_to_nearby_cansee, send_remove_character_to_nearby_cantsee, send_remove_character_to_nearby to build packet and handle iter internally. Packet built just once this way, and sent to those who need it. 2009/09/06 Turley: Changed Version checks to bitfield client->ClientType +2009/09/22 MuadDib: Adding resending of light level if override not in effect, to sending of season packet. Fixes EA client bug. Notes ======= @@ -2468,6 +2469,14 @@ msg.playsound = PKTOUT_BC::PLAYSOUND_YES; client->transmit( &msg, sizeof msg ); + + // Sending Season info resets light level in client, this fixes it during login + if (client->gd->weather_region != NULL && + client->gd->weather_region->lightoverride != -1 && + client->chr->lightoverride == -1) + { + send_light( client, client->gd->weather_region->lightoverride ); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mua...@us...> - 2009-09-22 23:27:10
|
Revision: 83 http://polserver.svn.sourceforge.net/polserver/?rev=83&view=rev Author: muaddib_pol Date: 2009-09-22 23:27:01 +0000 (Tue, 22 Sep 2009) Log Message: ----------- + Character.ar_mod changes refresh ar now. + Mod update for npcs Modified Paths: -------------- trunk/pol-core/pol/npc.cpp trunk/pol-core/pol/uoscrobj.cpp Modified: trunk/pol-core/pol/npc.cpp =================================================================== --- trunk/pol-core/pol/npc.cpp 2009-09-22 23:09:52 UTC (rev 82) +++ trunk/pol-core/pol/npc.cpp 2009-09-22 23:27:01 UTC (rev 83) @@ -1000,11 +1000,11 @@ { switch(resist) { - case ELEMENTAL_FIRE: element_resist.fire = element_resist_.fire; break; - case ELEMENTAL_COLD: element_resist.cold = element_resist_.cold; break; - case ELEMENTAL_ENERGY: element_resist.energy = element_resist_.energy; break; - case ELEMENTAL_POISON: element_resist.poison = element_resist_.poison; break; - case ELEMENTAL_PHYSICAL: element_resist.physical = element_resist_.physical; break; + case ELEMENTAL_FIRE: element_resist.fire = element_resist_.fire + element_resist_mod.fire; break; + case ELEMENTAL_COLD: element_resist.cold = element_resist_.cold + element_resist_mod.cold; break; + case ELEMENTAL_ENERGY: element_resist.energy = element_resist_.energy + element_resist_mod.energy; break; + case ELEMENTAL_POISON: element_resist.poison = element_resist_.poison + element_resist_mod.poison; break; + case ELEMENTAL_PHYSICAL: element_resist.physical = element_resist_.physical + element_resist_mod.physical; break; } } @@ -1012,10 +1012,10 @@ { switch(damage) { - case ELEMENTAL_FIRE: element_damage.fire = element_damage_.fire; break; - case ELEMENTAL_COLD: element_damage.cold = element_damage_.cold; break; - case ELEMENTAL_ENERGY: element_damage.energy = element_damage_.energy; break; - case ELEMENTAL_POISON: element_damage.poison = element_damage_.poison; break; - case ELEMENTAL_PHYSICAL: element_damage.physical = element_damage_.physical; break; + case ELEMENTAL_FIRE: element_damage.fire = element_damage_.fire + element_damage_mod.fire; break; + case ELEMENTAL_COLD: element_damage.cold = element_damage_.cold + element_damage_mod.cold; break; + case ELEMENTAL_ENERGY: element_damage.energy = element_damage_.energy + element_damage_mod.energy; break; + case ELEMENTAL_POISON: element_damage.poison = element_damage_.poison + element_damage_mod.poison; break; + case ELEMENTAL_PHYSICAL: element_damage.physical = element_damage_.physical + element_damage_mod.physical; break; } } \ No newline at end of file Modified: trunk/pol-core/pol/uoscrobj.cpp =================================================================== --- trunk/pol-core/pol/uoscrobj.cpp 2009-09-22 23:09:52 UTC (rev 82) +++ trunk/pol-core/pol/uoscrobj.cpp 2009-09-22 23:27:01 UTC (rev 83) @@ -1513,7 +1513,9 @@ case MBR_TRUECOLOR: return new BLong( truecolor = static_cast<unsigned short>(value) ); case MBR_AR_MOD: - return new BLong( ar_mod(static_cast<short>(value)) ); + ar_mod(static_cast<short>(value)); + refresh_ar(); + return new BLong( ar_mod() ); case MBR_DELAY_MOD: return new BLong( delay_mod_ = static_cast<short>(value) ); case MBR_HIDDEN: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2009-09-23 07:49:05
|
Revision: 85 http://polserver.svn.sourceforge.net/polserver/?rev=85&view=rev Author: turley Date: 2009-09-23 07:48:58 +0000 (Wed, 23 Sep 2009) Log Message: ----------- Two compiler warning fixed Modified Paths: -------------- trunk/pol-core/pol/multi/boat.cpp trunk/pol-core/pol/speech.cpp Modified: trunk/pol-core/pol/multi/boat.cpp =================================================================== --- trunk/pol-core/pol/multi/boat.cpp 2009-09-23 07:22:26 UTC (rev 84) +++ trunk/pol-core/pol/multi/boat.cpp 2009-09-23 07:48:58 UTC (rev 85) @@ -1041,7 +1041,7 @@ { unsigned short graphic = descriptor.graphic; unsigned short graphic_offset = static_cast<unsigned short>((flags & CRMULTI_FACING_MASK) >> CRMULTI_FACING_SHIFT); - unsigned char facing = graphic_offset * 2; + unsigned char facing = static_cast<unsigned char>(graphic_offset * 2); graphic += graphic_offset; const MultiDef* md = MultiDefByGraphic( graphic ); Modified: trunk/pol-core/pol/speech.cpp =================================================================== --- trunk/pol-core/pol/speech.cpp 2009-09-23 07:22:26 UTC (rev 84) +++ trunk/pol-core/pol/speech.cpp 2009-09-23 07:48:58 UTC (rev 85) @@ -342,7 +342,17 @@ sayto_listening_points( client->chr, ntext, ntextlen, msgin->type, wtext, msgin->lang, wtextlen); } -u16 Get12BitNumber(u8 * thearray, u16 theindex){ u16 theresult = 0; int thenibble = theindex * 3; int thebyte = thenibble / 2; if (thenibble % 2) theresult = cfBEu16(*((u16 *) (thearray + thebyte))) & 0x0FFF; else theresult = cfBEu16(*((u16 *) (thearray + thebyte))) >> 4; return theresult;} +u16 Get12BitNumber(u8 * thearray, u16 theindex) +{ + u16 theresult = 0; + int thenibble = theindex * 3; + int thebyte = thenibble / 2; + if (thenibble % 2) + theresult = cfBEu16(*((u16 *) (thearray + thebyte))) & 0x0FFF; + else + theresult = cfBEu16(*((u16 *) (thearray + thebyte))) >> 4; + return theresult; +} int GetNextUTF8(u8 * bytemsg, int i,u16& unicodeChar) { u16 result = 0; @@ -386,7 +396,7 @@ using std::wcout; // wcout.narrow() function r0x! :-) int intextlen; - int numtokens = 0; + u16 numtokens = 0; u16 * themsg = msgin->wtext; u8 * bytemsg = ((u8 *) themsg); int bytemsglen; @@ -451,7 +461,7 @@ { if(system_hooks.speechmul_hook != NULL) { - for (int i = 0; i < numtokens; i++) + for (u16 i = 0; i < numtokens; i++) { if (speechtokens == NULL) speechtokens = new ObjArray(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2009-09-28 12:32:03
|
Revision: 87 http://polserver.svn.sourceforge.net/polserver/?rev=87&view=rev Author: turley Date: 2009-09-28 12:30:13 +0000 (Mon, 28 Sep 2009) Log Message: ----------- more cast warning fixes Modified Paths: -------------- trunk/pol-core/pol/console.cpp trunk/pol-core/pol/polwww.cpp trunk/pol-core/pol/textcmd.cpp Modified: trunk/pol-core/pol/console.cpp =================================================================== --- trunk/pol-core/pol/console.cpp 2009-09-23 10:05:29 UTC (rev 86) +++ trunk/pol-core/pol/console.cpp 2009-09-28 12:30:13 UTC (rev 87) @@ -56,7 +56,7 @@ } if (charspec[0] == '^' && charspec.size() == 2) { - ch = toupper( charspec[1] ) - 'A' + 1; + ch = static_cast<char>(toupper( charspec[1] )) - 'A' + 1; } else if (charspec.size() == 1) { @@ -236,7 +236,7 @@ #ifdef _WIN32 if (kbhit()) { - exec_console_cmd( getch() ); + exec_console_cmd( static_cast<char>(getch()) ); } #else if (kb.kbhit()) Modified: trunk/pol-core/pol/polwww.cpp =================================================================== --- trunk/pol-core/pol/polwww.cpp 2009-09-23 10:05:29 UTC (rev 86) +++ trunk/pol-core/pol/polwww.cpp 2009-09-28 12:30:13 UTC (rev 87) @@ -234,7 +234,7 @@ if (isdigit( chH )) ch = (chH - '0') << 4; else - ch = ((tolower(chH) - 'a') + 10) << 4; + ch = ((static_cast<char>(tolower(chH)) - 'a') + 10) << 4; if (isdigit(chL)) ch |= (chL - '0'); @@ -610,7 +610,7 @@ { ifs.read(bfr, sizeof(bfr)); cur_read += static_cast<unsigned long>(ifs.gcount()); - sck.send(bfr, ifs.gcount()); // This was sizeof bfr, which would send garbage... fixed -- Nando, 2009-02-22 + sck.send(bfr, static_cast<unsigned int>(ifs.gcount())); // This was sizeof bfr, which would send garbage... fixed -- Nando, 2009-02-22 } // ------------- } Modified: trunk/pol-core/pol/textcmd.cpp =================================================================== --- trunk/pol-core/pol/textcmd.cpp 2009-09-23 10:05:29 UTC (rev 86) +++ trunk/pol-core/pol/textcmd.cpp 2009-09-28 12:30:13 UTC (rev 87) @@ -575,7 +575,7 @@ do { ifs.read( temp, sizeof temp ); if (ifs.gcount()) - result.append( temp, ifs.gcount() ); + result.append( temp, static_cast<size_t>(ifs.gcount()) ); } while (!ifs.eof()); return result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2009-12-15 08:19:40
|
Revision: 167 http://polserver.svn.sourceforge.net/polserver/?rev=167&view=rev Author: turley Date: 2009-12-15 08:19:34 +0000 (Tue, 15 Dec 2009) Log Message: ----------- crypt cleanup...what else..no need for template class since all inherit from CCryptBase Modified Paths: -------------- trunk/pol-core/pol/crypt/blowfish.cpp trunk/pol-core/pol/crypt/blowfish.h trunk/pol-core/pol/crypt/cryptbase.h trunk/pol-core/pol/crypt/cryptengine.cpp trunk/pol-core/pol/crypt/cryptengine.h trunk/pol-core/pol/crypt/cryptkey.cpp trunk/pol-core/pol/crypt/nocrypt.h trunk/pol-core/pol/crypt/twofish.cpp trunk/pol-core/pol/crypt/twofish.h trunk/pol-core/pol/login.cpp trunk/pol-core/pol/network/client.h trunk/pol-core/pol/pol.cpp Modified: trunk/pol-core/pol/crypt/blowfish.cpp =================================================================== --- trunk/pol-core/pol/crypt/blowfish.cpp 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/crypt/blowfish.cpp 2009-12-15 08:19:34 UTC (rev 167) @@ -397,6 +397,11 @@ { } +CCryptBlowfish::CCryptBlowfish(unsigned int masterKey1, unsigned int masterKey2) +{ + SetMasterKeys(masterKey1,masterKey2); +} + // Member Functions int CCryptBlowfish::Receive(void *buffer, int max_expected, SOCKET socket) @@ -421,13 +426,13 @@ unsigned char *pIn = (unsigned char *)pvIn; unsigned char *pOut = (unsigned char *)pvOut; - if(m_type == CryptEngine::typeAuto) + if(m_type == CCryptBase::typeAuto) { - if(((*pIn ^ (unsigned char)m_loginKey[0])) == CRYPT_AUTO_VALUE) m_type = CryptEngine::typeLogin; - else m_type = CryptEngine::typeGame; + if(((*pIn ^ (unsigned char)m_loginKey[0])) == CRYPT_AUTO_VALUE) m_type = CCryptBase::typeLogin; + else m_type = CCryptBase::typeGame; } - if(m_type == CryptEngine::typeLogin) + if(m_type == CCryptBase::typeLogin) { int tempPos; for(tempPos = 0; tempPos < len; tempPos++) Modified: trunk/pol-core/pol/crypt/blowfish.h =================================================================== --- trunk/pol-core/pol/crypt/blowfish.h 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/crypt/blowfish.h 2009-12-15 08:19:34 UTC (rev 167) @@ -50,12 +50,13 @@ typedef CCryptBaseCrypt base; CCryptBlowfish(); + CCryptBlowfish(unsigned int masterKey1, unsigned int masterKey2); ~CCryptBlowfish(); // Member Functions public: int Receive(void *buffer, int max_expected, SOCKET socket); - void Init(void *pvSeed, int type = CryptEngine::typeAuto); + void Init(void *pvSeed, int type = CCryptBase::typeAuto); void SetMasterKeys(unsigned int masterKey1, unsigned int masterKey2); int Pack(void *pvIn, void *pvOut, int len); Modified: trunk/pol-core/pol/crypt/cryptbase.h =================================================================== --- trunk/pol-core/pol/crypt/cryptbase.h 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/crypt/cryptbase.h 2009-12-15 08:19:34 UTC (rev 167) @@ -59,7 +59,6 @@ #include "../sockets.h" #include "../ucfg.h" #include "../../clib/passert.h" -#include "cryptengine.h" //basic class only used directly by NoCrypt class CCryptBase @@ -69,10 +68,12 @@ CCryptBase(); virtual ~CCryptBase(); + enum e_crypttype { typeLogin, typeGame, typeAuto }; + // Member Functions public: virtual int Receive(void *buffer, int max_expected, SOCKET socket) = 0; - virtual void Init(void *pvSeed, int type = CryptEngine::typeAuto) = 0; + virtual void Init(void *pvSeed, int type = typeAuto) = 0; }; //crypt class Modified: trunk/pol-core/pol/crypt/cryptengine.cpp =================================================================== --- trunk/pol-core/pol/crypt/cryptengine.cpp 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/crypt/cryptengine.cpp 2009-12-15 08:19:34 UTC (rev 167) @@ -23,30 +23,30 @@ CCryptInfo g_CryptInfo; -CryptEngine* create_nocrypt_engine() +CCryptBase* create_nocrypt_engine() { - return new CryptEngineTmpl<CCryptNoCrypt>; + return new CCryptNoCrypt(); } -CryptEngine* create_crypt_blowfish_engine(unsigned int uiKey1, unsigned int uiKey2) +CCryptBase* create_crypt_blowfish_engine(unsigned int uiKey1, unsigned int uiKey2) { - return new NewCryptEngineTmpl<CCryptBlowfish>(uiKey1, uiKey2); + return new CCryptBlowfish(uiKey1, uiKey2); } -CryptEngine* create_crypt_twofish_engine(unsigned int uiKey1, unsigned int uiKey2) +CCryptBase* create_crypt_twofish_engine(unsigned int uiKey1, unsigned int uiKey2) { // This is actually just the Blowfish engine until I work out how to impliment the new crap :/ - return new NewCryptEngineTmpl<CCryptTwofish>(uiKey1, uiKey2); + return new CCryptTwofish(uiKey1, uiKey2); } -CryptEngine* create_crypt_blowfish_twofish_engine(unsigned int uiKey1, unsigned int uiKey2) +CCryptBase* create_crypt_blowfish_twofish_engine(unsigned int uiKey1, unsigned int uiKey2) { // temp kludge until I work out how the f#%$ this new encryption scheme's meant to work! :-s #define CCryptBlowfishTwofish CCryptBlowfish - return new NewCryptEngineTmpl<CCryptBlowfishTwofish>(uiKey1, uiKey2); + return new CCryptBlowfishTwofish(uiKey1, uiKey2); } -CryptEngine* create_crypt_engine( const string& name ) +CCryptBase* create_crypt_engine( const string& name ) { TCryptInfo infoCrypt; if ( g_CryptInfo.LookupClient(name, infoCrypt) ) Modified: trunk/pol-core/pol/crypt/cryptengine.h =================================================================== --- trunk/pol-core/pol/crypt/cryptengine.h 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/crypt/cryptengine.h 2009-12-15 08:19:34 UTC (rev 167) @@ -4,48 +4,8 @@ #ifndef CRYPTENGINE_H #define CRYPTENGINE_H -#include "../sockets.h" +#include "cryptbase.h" -class CryptEngine -{ -protected: - CryptEngine() {}; -public: - enum e_crypttype { typeLogin, typeGame, typeAuto } crypttype; +CCryptBase* create_crypt_engine( const std::string& name ); - virtual ~CryptEngine() {} - virtual int Receive(void *buffer, int max_expected, SOCKET socket) = 0; - virtual void Init(void *pvSeed, int type=typeAuto) = 0; -}; - -template<class T> -class CryptEngineTmpl : public CryptEngine -{ -public: - CryptEngineTmpl() : crypt() {} - virtual int Receive(void *buffer, int max_expected, SOCKET socket) - { - return crypt.Receive(buffer, max_expected, socket); - } - virtual void Init(void *pvSeed, int type) - { - crypt.Init( pvSeed, type ); - } - -protected: - T crypt; -}; - -template<class T> -class NewCryptEngineTmpl : public CryptEngineTmpl<T> -{ -public: - NewCryptEngineTmpl(unsigned int Key1, unsigned int Key2) - { - this->crypt.SetMasterKeys(Key1, Key2); - } -}; - -CryptEngine* create_crypt_engine( const std::string& name ); - #endif Modified: trunk/pol-core/pol/crypt/cryptkey.cpp =================================================================== --- trunk/pol-core/pol/crypt/cryptkey.cpp 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/crypt/cryptkey.cpp 2009-12-15 08:19:34 UTC (rev 167) @@ -30,7 +30,7 @@ CryptList.clear(); // TWOFISH - + AddClient("7.0.4", 0x2F7385BD, 0xA2AD127F, CRYPT_TWOFISH); AddClient("7.0.3", 0x2F3BB7CD, 0xA2895E7F, CRYPT_TWOFISH); AddClient("7.0.2", 0x2FE3ADDD, 0xA2E5227F, CRYPT_TWOFISH); AddClient("7.0.1", 0x2FABA7ED, 0xA2C17E7F, CRYPT_TWOFISH); Modified: trunk/pol-core/pol/crypt/nocrypt.h =================================================================== --- trunk/pol-core/pol/crypt/nocrypt.h 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/crypt/nocrypt.h 2009-12-15 08:19:34 UTC (rev 167) @@ -55,7 +55,7 @@ // Member Functions public: int Receive(void *buffer, int max_expected, SOCKET socket); - void Init(void *pvSeed, int type = CryptEngine::typeAuto); + void Init(void *pvSeed, int type = CCryptBase::typeAuto); }; #endif //__NOCRYPT_H__ Modified: trunk/pol-core/pol/crypt/twofish.cpp =================================================================== --- trunk/pol-core/pol/crypt/twofish.cpp 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/crypt/twofish.cpp 2009-12-15 08:19:34 UTC (rev 167) @@ -397,6 +397,11 @@ { } +CCryptTwofish::CCryptTwofish(unsigned int masterKey1, unsigned int masterKey2) +{ + SetMasterKeys(masterKey1,masterKey2); +} + // Member Functions int CCryptTwofish::Receive(void *buffer, int max_expected, SOCKET socket) @@ -421,13 +426,13 @@ unsigned char *pIn = (unsigned char *)pvIn; unsigned char *pOut = (unsigned char *)pvOut; - if(m_type == CryptEngine::typeAuto) + if(m_type == CCryptBase::typeAuto) { - if(((*pIn ^ (unsigned char)m_loginKey[0])) == CRYPT_AUTO_VALUE) m_type = CryptEngine::typeLogin; - else m_type = CryptEngine::typeGame; + if(((*pIn ^ (unsigned char)m_loginKey[0])) == CRYPT_AUTO_VALUE) m_type = CCryptBase::typeLogin; + else m_type = CCryptBase::typeGame; } - if(m_type == CryptEngine::typeLogin) + if(m_type == CCryptBase::typeLogin) { int tempPos; for(tempPos = 0; tempPos < len; tempPos++) Modified: trunk/pol-core/pol/crypt/twofish.h =================================================================== --- trunk/pol-core/pol/crypt/twofish.h 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/crypt/twofish.h 2009-12-15 08:19:34 UTC (rev 167) @@ -50,12 +50,13 @@ typedef CCryptBaseCrypt base; CCryptTwofish(); + CCryptTwofish(unsigned int masterKey1, unsigned int masterKey2); ~CCryptTwofish(); // Member Functions public: int Receive(void *buffer, int max_expected, SOCKET socket); - void Init(void *pvSeed, int type = CryptEngine::typeAuto); + void Init(void *pvSeed, int type = CCryptBase::typeAuto); void SetMasterKeys(unsigned int masterKey1, unsigned int masterKey2); int Pack(void *pvIn, void *pvOut, int len); Modified: trunk/pol-core/pol/login.cpp =================================================================== --- trunk/pol-core/pol/login.cpp 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/login.cpp 2009-12-15 08:19:34 UTC (rev 167) @@ -285,7 +285,7 @@ client->transmit( &rsp, sizeof rsp ); unsigned long nseed = 0xFEFE0000 + client->ClientType; - client->cryptengine->Init( &nseed, CryptEngine::typeGame ); + client->cryptengine->Init( &nseed, CCryptBase::typeGame ); } MESSAGE_HANDLER( PKTIN_A0, select_server ); Modified: trunk/pol-core/pol/network/client.h =================================================================== --- trunk/pol-core/pol/network/client.h 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/network/client.h 2009-12-15 08:19:34 UTC (rev 167) @@ -151,7 +151,7 @@ struct sockaddr ipaddr; - std::auto_ptr<CryptEngine> cryptengine; + std::auto_ptr<CCryptBase> cryptengine; bool encrypt_server_stream; // encrypt the server stream (data sent to client)? Modified: trunk/pol-core/pol/pol.cpp =================================================================== --- trunk/pol-core/pol/pol.cpp 2009-12-11 13:02:48 UTC (rev 166) +++ trunk/pol-core/pol/pol.cpp 2009-12-15 08:19:34 UTC (rev 167) @@ -875,12 +875,12 @@ tempseed[1] = client->buffer[2]; tempseed[2] = client->buffer[3]; tempseed[3] = client->buffer[4]; - client->cryptengine->Init( tempseed, CryptEngine::typeLogin ); + client->cryptengine->Init( tempseed, CCryptBase::typeLogin ); (*handler[PKTIN_EF_ID].func)(client, client->buffer); } else { - client->cryptengine->Init( client->buffer, CryptEngine::typeAuto ); + client->cryptengine->Init( client->buffer, CCryptBase::typeAuto ); client->recv_state = Client::RECV_STATE_MSGTYPE_WAIT; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2010-04-03 21:09:40
|
Revision: 228 http://polserver.svn.sourceforge.net/polserver/?rev=228&view=rev Author: turley Date: 2010-04-03 21:09:33 +0000 (Sat, 03 Apr 2010) Log Message: ----------- more pointer wierdo stuff for pktwriting optimation Modified Paths: -------------- trunk/pol-core/pol/network/packets.h trunk/pol-core/pol/pktdef.h Modified: trunk/pol-core/pol/network/packets.h =================================================================== --- trunk/pol-core/pol/network/packets.h 2010-04-03 11:51:37 UTC (rev 227) +++ trunk/pol-core/pol/network/packets.h 2010-04-03 21:09:33 UTC (rev 228) @@ -13,6 +13,7 @@ #include <climits> #include "../../clib/stl_inc.h" +#include "../../clib/endian.h" #include "../../clib/singleton.h" #include "../../clib/rawtypes.h" #include "../pktoutid.h" @@ -113,60 +114,53 @@ void ReSetBuffer() { memset(buffer,0,sizeof(buffer)); buffer[0]=_id; offset=1; } char* getBuffer() { return buffer; } inline u8 getID() { return buffer[0]; } + void Write(u32 x) { - buffer[offset++] = x & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT) & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT*2) & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT*3) & UCHAR_MAX; + (*(u32*)&buffer[offset]) = x; + offset += 4; }; void Write(s32 x) { - buffer[offset++] = x & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT) & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT*2) & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT*3) & UCHAR_MAX; + (*(s32*)&buffer[offset]) = x; + offset += 4; }; void Write(u16 x) { - buffer[offset++] = x & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT) & UCHAR_MAX; + (*(u16*)&buffer[offset]) = x; + offset += 2; }; void Write(s16 x) { - buffer[offset++] = x & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT) & UCHAR_MAX; + (*(s16*)&buffer[offset]) = x; + offset += 2; }; void Write(u8 x) { buffer[offset++] = x; }; void Write(s8 x) { buffer[offset++] = x; }; void WriteFlipped(u32 x) { - buffer[offset++] = (x >> CHAR_BIT*3) & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT*2) & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT) & UCHAR_MAX; - buffer[offset++] = x & UCHAR_MAX; + (*(u32*)&buffer[offset]) = cfBEu32(x); + offset += 4; }; void WriteFlipped(s32 x) { - buffer[offset++] = (x >> CHAR_BIT*3) & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT*2) & UCHAR_MAX; - buffer[offset++] = (x >> CHAR_BIT) & UCHAR_MAX; - buffer[offset++] = x & UCHAR_MAX; + (*(s32*)&buffer[offset]) = cfBEu32(x); + offset += 4; }; void WriteFlipped(u16 x) { - buffer[offset++] = (x >> CHAR_BIT) & UCHAR_MAX; - buffer[offset++] = x & UCHAR_MAX; + (*(u16*)&buffer[offset]) = cfBEu16(x); + offset += 2; }; void WriteFlipped(s16 x) { - buffer[offset++] = (x >> CHAR_BIT) & UCHAR_MAX; - buffer[offset++] = x & UCHAR_MAX; + (*(s16*)&buffer[offset]) = cfBEu16(x); + offset += 2; }; void Write(const char* x, u16 len) { strzcpy( &buffer[offset], x, len ); - offset+=len; + offset += len; } }; // "normal" pkt Modified: trunk/pol-core/pol/pktdef.h =================================================================== --- trunk/pol-core/pol/pktdef.h 2010-04-03 11:51:37 UTC (rev 227) +++ trunk/pol-core/pol/pktdef.h 2010-04-03 21:09:33 UTC (rev 228) @@ -102,13 +102,13 @@ #define RESPONSE_MAX_LEN 200 -#define PKTOUT_53_WARN_NO_CHARACTER 1 -#define PKTOUT_53_WARN_CHARACTER_EXISTS 2 -#define PKTOUT_53_WARN_CANT_CONNECT_1 3 -#define PKTOUT_53_WARN_CANT_CONNECT_2 4 -#define PKTOUT_53_WARN_CHARACTER_IN_WORLD 5 -#define PKTOUT_53_WARN_LOGIN_PROBLEM 6 -#define PKTOUT_53_WARN_CHARACTER_IDLE 7 +#define PKTOUT_53_WARN_NO_CHARACTER 1 +#define PKTOUT_53_WARN_CHARACTER_EXISTS 2 +#define PKTOUT_53_WARN_CANT_CONNECT_1 3 +#define PKTOUT_53_WARN_CANT_CONNECT_2 4 +#define PKTOUT_53_WARN_CHARACTER_IN_WORLD 5 +#define PKTOUT_53_WARN_LOGIN_PROBLEM 6 +#define PKTOUT_53_WARN_CHARACTER_IDLE 7 #define PKTOUT_53_WARN_CANT_CONNECT_3 8 #define PKTOUT_54_FLAG_REPEAT 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2010-04-10 10:30:33
|
Revision: 234 http://polserver.svn.sourceforge.net/polserver/?rev=234&view=rev Author: turley Date: 2010-04-10 10:30:25 +0000 (Sat, 10 Apr 2010) Log Message: ----------- pkt 0xab-0xcc had to move xmitoutbuffer to client class (threadsafty) Modified Paths: -------------- trunk/pol-core/pol/clfunc.cpp trunk/pol-core/pol/clfunc.h trunk/pol-core/pol/item/itemdesc.cpp trunk/pol-core/pol/module/uomod.cpp trunk/pol-core/pol/module/uomod2.cpp trunk/pol-core/pol/movement.cpp trunk/pol-core/pol/network/client.cpp trunk/pol-core/pol/network/client.h trunk/pol-core/pol/network/clientio.cpp trunk/pol-core/pol/network/packets.cpp trunk/pol-core/pol/network/packets.h trunk/pol-core/pol/party.cpp trunk/pol-core/pol/pktdef.h trunk/pol-core/pol/pktout.h trunk/pol-core/pol/tooltips.cpp trunk/pol-core/pol/ufunc.cpp trunk/pol-core/pol/ufunc.h trunk/pol-core/pol/uoscrobj.cpp Modified: trunk/pol-core/pol/clfunc.cpp =================================================================== --- trunk/pol-core/pol/clfunc.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/clfunc.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -21,6 +21,7 @@ #include "mobile/charactr.h" #include "network/client.h" +#include "network/packets.h" #include "pktoutid.h" #include "sockio.h" #include "clfunc.h" @@ -29,146 +30,106 @@ unsigned int cliloc_num, const u16 *arguments, unsigned short font, unsigned short color ) { - PKTOUT_C1 msg; - unsigned textlen = 0, msglen; + PktOut_C1* msg = REQUESTPACKET(PktOut_C1,PKTOUT_C1_ID); + msg->offset+=2; + unsigned textlen = 0; if (arguments != NULL) { while( arguments[textlen] != L'\0' ) ++textlen; - ++textlen; } - if (textlen > (sizeof msg.arguments / sizeof(msg.arguments[0]))) - textlen = (sizeof msg.arguments / sizeof(msg.arguments[0])); - msglen = offsetof( PKTOUT_C1, arguments ) + textlen*sizeof(msg.arguments[0]); - if (arguments == NULL) - msglen+=2; + if (textlen > (SPEECH_MAX_LEN)) + textlen = SPEECH_MAX_LEN; - if (msglen <= sizeof msg) - { - msg.msgtype = PKTOUT_C1_ID; - msg.msglen = ctBEu16( msglen ); - msg.serial = 0xFFFFFFFF; - msg.body = 0xFFFF; - msg.type = 6; - msg.hue = ctBEu16( color ); - msg.font = ctBEu16( font ); - msg.msgnumber = ctBEu32( cliloc_num ); - memset( msg.name, '\0', sizeof msg.name ); - strcpy( msg.name, "System" ); - unsigned i=0; - if (textlen>0) - { - for(; i < (textlen-1); ++i)//textlen includes 0terminator - msg.arguments[i] = ctLEu16(arguments[i]); - } - msg.arguments[i] = (u16)0L; - transmit( client, &msg, msglen ); - } - else - { - // MuadDib - FIXME need to handle this better, boooo. - Log( "send_sysmessage: unicode text is too long\n"); - } - + msg->Write(static_cast<u32>(0xFFFFFFFF)); // serial + msg->Write(static_cast<u16>(0xFFFF)); // body + msg->Write(static_cast<u8>(6)); // type 6 lower left, 7 on player + msg->WriteFlipped(color); + msg->WriteFlipped(font); + msg->WriteFlipped(cliloc_num); + msg->Write("System",30,false); + if (arguments != NULL) + msg->Write(arguments,static_cast<u16>(textlen),true); //ctLEu16 + else + msg->offset+=2; + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); + transmit( client, &msg->buffer, len ); + READDPACKET(msg); } void say_above_cl(UObject *obj, unsigned int cliloc_num, const u16 *arguments, unsigned short font, unsigned short color ) { - PKTOUT_C1 msg; - unsigned textlen = 0, msglen; + PktOut_C1* msg = REQUESTPACKET(PktOut_C1,PKTOUT_C1_ID); + msg->offset+=2; + unsigned textlen = 0; if (arguments != NULL) { while( arguments[textlen] != L'\0' ) ++textlen; - ++textlen; } - if (textlen > (sizeof msg.arguments / sizeof(msg.arguments[0]))) - textlen = (sizeof msg.arguments / sizeof(msg.arguments[0])); - msglen = offsetof( PKTOUT_C1, arguments ) + textlen*sizeof(msg.arguments[0]); - if (arguments == NULL) - msglen+=2; - if (msglen <= sizeof msg) - { - msg.msgtype = PKTOUT_C1_ID; - msg.msglen = ctBEu16( msglen ); - msg.serial = obj->serial_ext; - msg.body = obj->graphic_ext; - msg.type = 7; - msg.hue = ctBEu16( color ); - msg.font = ctBEu16( font ); - msg.msgnumber = ctBEu32( cliloc_num ); - memset( msg.name, '\0', sizeof msg.name ); - strcpy( msg.name, "System" ); - unsigned i=0; - if (textlen>0) - { - for(; i < (textlen-1); ++i)//textlen includes 0terminator - msg.arguments[i] = ctLEu16(arguments[i]); - } - msg.arguments[i] = (u16)0L; + if (textlen > (SPEECH_MAX_LEN)) + textlen = SPEECH_MAX_LEN; - // MuadDib - FIXME: only send to those that I'm visible to. - transmit_to_inrange( obj, &msg, msglen, false, false ); - } - else - { - // MuadDib - FIXME: need to handle this better - Log( "send_sysmessage: unicode text is too long\n"); - } - + msg->Write(obj->serial_ext); + msg->Write(obj->graphic_ext); // body + msg->Write(static_cast<u8>(7)); // type 6 lower left, 7 on player + msg->WriteFlipped(color); + msg->WriteFlipped(font); + msg->WriteFlipped(cliloc_num); + msg->Write("System",30,false); + if (arguments != NULL) + msg->Write(arguments,static_cast<u16>(textlen),true); //ctLEu16 + else + msg->offset+=2; + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); + // MuadDib - FIXME: only send to those that I'm visible to. + transmit_to_inrange( obj, &msg->buffer, len, false, false ); + READDPACKET(msg); } void private_say_above_cl(Character *chr, const UObject* obj, unsigned int cliloc_num, const u16 *arguments, unsigned short font, unsigned short color ) { - PKTOUT_C1 msg; - unsigned textlen = 0, msglen; + PktOut_C1* msg = REQUESTPACKET(PktOut_C1,PKTOUT_C1_ID); + msg->offset+=2; + unsigned textlen = 0; if (arguments != NULL) { while( arguments[textlen] != L'\0' ) ++textlen; - ++textlen; } - if (textlen > (sizeof msg.arguments / sizeof(msg.arguments[0]))) - textlen = (sizeof msg.arguments / sizeof(msg.arguments[0])); - msglen = offsetof( PKTOUT_C1, arguments ) + textlen*sizeof(msg.arguments[0]); - if (arguments == NULL) - msglen+=2; - if (msglen <= sizeof msg) - { - msg.msgtype = PKTOUT_C1_ID; - msg.msglen = ctBEu16( msglen ); - msg.serial = obj->serial_ext; - msg.body = obj->graphic_ext; - msg.type = 7; - msg.hue = ctBEu16( color ); - msg.font = ctBEu16( font ); - msg.msgnumber = ctBEu32( cliloc_num ); - memset( msg.name, '\0', sizeof msg.name ); - strcpy( msg.name, "System" ); - unsigned i=0; - if (textlen>0) - { - for(; i < (textlen-1); ++i)//textlen includes 0terminator - msg.arguments[i] = ctLEu16(arguments[i]); - } - msg.arguments[i] = (u16)0L; - chr->client->transmit( &msg, msglen ); - } - else - { - // MuadDib - FIXME: need to handle this better - Log( "send_sysmessage: unicode text is too long\n"); - } + if (textlen > (SPEECH_MAX_LEN)) + textlen = SPEECH_MAX_LEN; + + msg->Write(obj->serial_ext); + msg->Write(obj->graphic_ext); // body + msg->Write(static_cast<u8>(7)); // type 6 lower left, 7 on player + msg->WriteFlipped(color); + msg->WriteFlipped(font); + msg->WriteFlipped(cliloc_num); + msg->Write("System",30,false); + if (arguments != NULL) + msg->Write(arguments,static_cast<u16>(textlen),true); //ctLEu16 + else + msg->offset+=2; + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); + chr->client->transmit( &msg->buffer, len ); + READDPACKET(msg); } @@ -176,270 +137,193 @@ bool prepend, const u16 *arguments, unsigned short font, unsigned short color ) { - PKTOUT_CC msg; + PktOut_CC* msg = REQUESTPACKET(PktOut_CC,PKTOUT_CC_ID); + msg->offset+=2; + unsigned textlen = 0, affix_len = 0; - unsigned textlen = 0, affix_len = 0, msglen; - if (arguments != NULL) { while( arguments[textlen] != L'\0' ) ++textlen; - ++textlen; // to have L'\0' in the array ;) } + affix_len = strlen(affix)+1; + if (affix_len > SPEECH_MAX_LEN+1) + affix_len = SPEECH_MAX_LEN+1; - affix_len = strlen(affix)+1; // to have space for '\0' + if (textlen > (SPEECH_MAX_LEN)) + textlen = SPEECH_MAX_LEN; - size_t offset = offsetof( PKTOUT_CC, affix ); // Position of msg.affix + msg->Write(static_cast<u32>(0xFFFFFFFF)); // serial + msg->Write(static_cast<u16>(0xFFFF)); // body + msg->Write(static_cast<u8>(6)); // type 6 lower left, 7 on player + msg->WriteFlipped(color); + msg->WriteFlipped(font); + msg->WriteFlipped(cliloc_num); + msg->Write(static_cast<u8>((prepend) ? 1 : 0)); + msg->Write("System",30,false); + msg->Write(affix,static_cast<u16>(affix_len)); + if (arguments != NULL) + msg->WriteFlipped(arguments,static_cast<u16>(textlen),true); + else + msg->offset+=2; + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); - msglen = offset + affix_len*sizeof(msg.affix[0]) + textlen*sizeof(msg.arguments[0]); - if (arguments == NULL) - msglen+=2; - - msg.msgtype = PKTOUT_CC_ID; - msg.msglen = ctBEu16( msglen ); - msg.serial = 0xFFFFFFFF; - msg.body = 0xFFFF; - msg.type = 6; - msg.hue = ctBEu16( color ); - msg.font = ctBEu16( font ); - msg.msgnumber = ctBEu32( cliloc_num ); - msg.flags = (prepend) ? 1 : 0; - memset( msg.name, '\0', sizeof msg.name ); - strcpy( msg.name, "System" ); - - char *tmp_msg = new char[msglen]; - - memset(tmp_msg, '\0', msglen); - memcpy(tmp_msg, &msg, offset); // copy until before affix - memcpy(tmp_msg + offset, affix, affix_len); - - u16 *args = (u16*)(tmp_msg + offset + affix_len); // args will now point after the end of affix :) - unsigned i=0; - if (textlen>0) - { - for(; i < (textlen-1); ++i)//textlen includes 0terminator - args[i] = ctBEu16(arguments[i]); - } - args[i] = (u16)0L; - - client->transmit(tmp_msg, msglen); - - delete [] tmp_msg; - tmp_msg = NULL; + client->transmit(&msg->buffer, len); + READDPACKET(msg); } void say_above_cl_affix(UObject *obj, unsigned int cliloc_num, const char* affix, bool prepend, const u16 *arguments, unsigned short font, unsigned short color) { - PKTOUT_CC msg; + PktOut_CC* msg = REQUESTPACKET(PktOut_CC,PKTOUT_CC_ID); + msg->offset+=2; + unsigned textlen = 0, affix_len = 0; - unsigned textlen = 0, affix_len = 0, msglen; - if (arguments != NULL) { while( arguments[textlen] != L'\0' ) ++textlen; - ++textlen; // to have L'\0' in the array ;) } + affix_len = strlen(affix)+1; + if (affix_len > SPEECH_MAX_LEN+1) + affix_len = SPEECH_MAX_LEN+1; - affix_len = strlen(affix)+1; // to have space for '\0' + if (textlen > (SPEECH_MAX_LEN)) + textlen = SPEECH_MAX_LEN; - size_t offset = offsetof( PKTOUT_CC, affix ); // Position of msg.affix + msg->Write(obj->serial_ext); // serial + msg->Write(obj->graphic_ext); // body + msg->Write(7); // type 6 lower left, 7 on player + msg->WriteFlipped(color); + msg->WriteFlipped(font); + msg->WriteFlipped(cliloc_num); + msg->Write(static_cast<u8>((prepend) ? 1 : 0)); + msg->Write("System",30,false); + msg->Write(affix,static_cast<u16>(affix_len)); + if (arguments != NULL) + msg->WriteFlipped(arguments,static_cast<u16>(textlen),true); //ctLEu16 + else + msg->offset+=2; + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); - msglen = offset + affix_len*sizeof(msg.affix[0]) + textlen*sizeof(msg.arguments[0]); - if (arguments == NULL) - msglen+=2; - - msg.msgtype = PKTOUT_CC_ID; - msg.msglen = ctBEu16( msglen ); - msg.serial = obj->serial_ext; - msg.body = obj->graphic_ext; - msg.type = 7; - msg.hue = ctBEu16( color ); - msg.font = ctBEu16( font ); - msg.msgnumber = ctBEu32( cliloc_num ); - msg.flags = (prepend) ? 1 : 0; - memset( msg.name, '\0', sizeof msg.name ); - strcpy( msg.name, "System" ); - - char *tmp_msg = new char[msglen]; // Create buffer for the msg - - memset(tmp_msg, '\0', msglen); - memcpy(tmp_msg, &msg, offset); // copy until before affix - memcpy(tmp_msg + offset, affix, affix_len); - - u16 *args = (u16*)(tmp_msg + offset + affix_len); // args will now point after the end of affix :) - unsigned i=0; - if (textlen>0) - { - for(; i < (textlen-1); ++i)//textlen includes 0terminator - args[i] = ctBEu16(arguments[i]); - } - args[i] = (u16)0L; - // MuadDib - FIXME: only send to those that I'm visible to. - transmit_to_inrange( obj, tmp_msg, msglen, false, false ); - - delete [] tmp_msg; - tmp_msg = NULL; + transmit_to_inrange( obj, &msg->buffer, len, false, false ); + READDPACKET(msg); } void private_say_above_cl_affix(Character *chr, const UObject* obj, unsigned int cliloc_num, const char* affix, bool prepend, const u16 *arguments, unsigned short font, unsigned short color) { - PKTOUT_CC msg; + PktOut_CC* msg = REQUESTPACKET(PktOut_CC,PKTOUT_CC_ID); + msg->offset+=2; + unsigned textlen = 0, affix_len = 0; - unsigned textlen = 0, affix_len = 0, msglen; - if (arguments != NULL) { while( arguments[textlen] != L'\0' ) ++textlen; - ++textlen; // to have L'\0' in the array ;) } + affix_len = strlen(affix)+1; + if (affix_len > SPEECH_MAX_LEN+1) + affix_len = SPEECH_MAX_LEN+1; - affix_len = strlen(affix)+1; // to have space for '\0' + if (textlen > (SPEECH_MAX_LEN)) + textlen = SPEECH_MAX_LEN; - size_t offset = offsetof( PKTOUT_CC, affix ); // Position of msg.affix + msg->Write(obj->serial_ext); // serial + msg->Write(obj->graphic_ext); // body + msg->Write(7); // type 6 lower left, 7 on player + msg->WriteFlipped(color); + msg->WriteFlipped(font); + msg->WriteFlipped(cliloc_num); + msg->Write(static_cast<u8>((prepend) ? 1 : 0)); + msg->Write("System",30,false); + msg->Write(affix,static_cast<u16>(affix_len)); + if (arguments != NULL) + msg->WriteFlipped(arguments,static_cast<u16>(textlen),true); + else + msg->offset+=2; + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); - msglen = offset + affix_len*sizeof(msg.affix[0]) + textlen*sizeof(msg.arguments[0]); - if (arguments == NULL) - msglen+=2; - - msg.msgtype = PKTOUT_CC_ID; - msg.msglen = ctBEu16( msglen ); - msg.serial = obj->serial_ext; - msg.body = obj->graphic_ext; - msg.type = 7; - msg.hue = ctBEu16( color ); - msg.font = ctBEu16( font ); - msg.msgnumber = ctBEu32( cliloc_num ); - msg.flags = (prepend) ? 1 : 0; - memset( msg.name, '\0', sizeof msg.name ); - strcpy( msg.name, "System" ); - - char *tmp_msg = new char[msglen]; // Create buffer for the msg - - memset(tmp_msg, '\0', msglen); - memcpy(tmp_msg, &msg, offset); // copy until before affix - memcpy(tmp_msg + offset, affix, affix_len); - - u16 *args = (u16*)(tmp_msg + offset + affix_len); // args will now point after the end of affix :) - unsigned i=0; - if (textlen>0) - { - for(; i < (textlen-1); ++i)//textlen includes 0terminator - args[i] = ctBEu16(arguments[i]); - } - args[i] = (u16)0L; - - chr->client->transmit(tmp_msg, msglen); - - delete [] tmp_msg; - tmp_msg = NULL; + chr->client->transmit(&msg->buffer, len); + READDPACKET(msg); } -unsigned char* build_sysmessage_cl(unsigned* msglen,unsigned int cliloc_num, const u16 *arguments, +void build_sysmessage_cl(PktOut_C1* msg, unsigned int cliloc_num, const u16 *arguments, unsigned short font, unsigned short color ) { + msg->offset+=2; unsigned textlen = 0; if (arguments != NULL) { while( arguments[textlen] != L'\0' ) ++textlen; - ++textlen; } - if (textlen > (SPEECH_MAX_LEN+1)) - textlen = SPEECH_MAX_LEN+1; - *msglen = offsetof( PKTOUT_C1, arguments ) + textlen*2; - if (arguments == NULL) - *msglen+=2; + if (textlen > (SPEECH_MAX_LEN)) + textlen = SPEECH_MAX_LEN; - PKTOUT_C1 msg; - msg.msgtype = PKTOUT_C1_ID; - msg.msglen = ctBEu16( *msglen ); - msg.serial = 0xFFFFFFFF; - msg.body = 0xFFFF; - msg.type = 6; - msg.hue = ctBEu16( color ); - msg.font = ctBEu16( font ); - msg.msgnumber = ctBEu32( cliloc_num ); - memset( msg.name, '\0', sizeof msg.name ); - strcpy( msg.name, "System" ); - - // dont know why the heck this works but "normal" way leads to a crash on delete - unsigned char *tmp_msg = new unsigned char[*msglen]; // Create buffer for the msg - - memset(tmp_msg, '\0', *msglen); - memcpy(tmp_msg, &msg, offsetof( PKTOUT_C1, arguments )); // copy until before arguments - - u16 *args = (u16*)(tmp_msg + offsetof( PKTOUT_C1, arguments )); - unsigned i=0; - if (textlen>0) - { - for(; i < (textlen-1); ++i)//textlen includes 0terminator - args[i] = ctBEu16(arguments[i]); - } - args[i] = (u16)0L; - - return tmp_msg; + msg->Write(static_cast<u32>(0xFFFFFFFF)); // serial + msg->Write(static_cast<u16>(0xFFFF)); // body + msg->Write(static_cast<u8>(6)); // type 6 lower left, 7 on player + msg->WriteFlipped(color); + msg->WriteFlipped(font); + msg->WriteFlipped(cliloc_num); + msg->Write("System",30,false); + if (arguments != NULL) + msg->Write(arguments,static_cast<u16>(textlen),true); //ctLEu16 + else + msg->offset+=2; + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); + msg->offset=len; } -unsigned char* build_sysmessage_cl_affix(unsigned* msglen,unsigned int cliloc_num, const char* affix, +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 ) { - PKTOUT_CC msg; - + msg->offset+=2; unsigned textlen = 0, affix_len = 0; if (arguments != NULL) { while( arguments[textlen] != L'\0' ) ++textlen; - ++textlen; // to have L'\0' in the array ;) } + affix_len = strlen(affix)+1; + if (affix_len > SPEECH_MAX_LEN+1) + affix_len = SPEECH_MAX_LEN+1; - affix_len = strlen(affix)+1; // to have space for '\0' + if (textlen > (SPEECH_MAX_LEN)) + textlen = SPEECH_MAX_LEN; - size_t offset = offsetof( PKTOUT_CC, affix ); // Position of msg.affix - - *msglen = offset + affix_len*sizeof(msg.affix[0]) + textlen*sizeof(msg.arguments[0]); - if (arguments == NULL) - *msglen+=2; - - msg.msgtype = PKTOUT_CC_ID; - msg.msglen = ctBEu16( *msglen ); - msg.serial = 0xFFFFFFFF; - msg.body = 0xFFFF; - msg.type = 6; - msg.hue = ctBEu16( color ); - msg.font = ctBEu16( font ); - msg.msgnumber = ctBEu32( cliloc_num ); - msg.flags = (prepend) ? 1 : 0; - memset( msg.name, '\0', sizeof msg.name ); - strcpy( msg.name, "System" ); - - unsigned char *tmp_msg = new unsigned char[*msglen]; // Create buffer for the msg - - memset(tmp_msg, '\0', *msglen); - memcpy(tmp_msg, &msg, offset); // copy until before affix - memcpy(tmp_msg + offset, affix, affix_len); - - u16 *args = (u16*)(tmp_msg + offset + affix_len); // args will now point after the end of affix :) - unsigned i=0; - if (textlen>0) - { - for(; i < (textlen-1); ++i) //textlen includes 0terminator - args[i] = ctBEu16(arguments[i]); - } - args[i] = (u16)0L; - - return tmp_msg; - + msg->Write(static_cast<u32>(0xFFFFFFFF)); // serial + msg->Write(static_cast<u16>(0xFFFF)); // body + msg->Write(static_cast<u8>(6)); // type 6 lower left, 7 on player + msg->WriteFlipped(color); + msg->WriteFlipped(font); + msg->WriteFlipped(cliloc_num); + msg->Write(static_cast<u8>((prepend) ? 1 : 0)); + msg->Write("System",30,false); + msg->Write(affix,static_cast<u16>(affix_len)); + if (arguments != NULL) + msg->WriteFlipped(arguments,static_cast<u16>(textlen),true); + else + msg->offset+=2; + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); + msg->offset=len; } Modified: trunk/pol-core/pol/clfunc.h =================================================================== --- trunk/pol-core/pol/clfunc.h 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/clfunc.h 2010-04-10 10:30:25 UTC (rev 234) @@ -10,6 +10,7 @@ #include "ufunc.h" #include "uconst.h" +#include "network/packets.h" /* void send_sysmessage_cl(Client *client, // System message (lower left corner) @@ -63,9 +64,9 @@ unsigned short font = DEFAULT_TEXT_FONT, unsigned short color = DEFAULT_TEXT_COLOR); -unsigned char* build_sysmessage_cl(unsigned* msglen,unsigned int cliloc_num, const u16 *arguments=0, +void build_sysmessage_cl(PktOut_C1* msg, unsigned int cliloc_num, const u16 *arguments=0, unsigned short font= DEFAULT_TEXT_FONT, unsigned short color = DEFAULT_TEXT_COLOR); -unsigned char* build_sysmessage_cl_affix(unsigned* msglen,unsigned int cliloc_num, const char* affix, +void build_sysmessage_cl_affix(PktOut_CC* msg,unsigned int cliloc_num, const char* affix, bool prepend, const u16 *arguments=0, unsigned short font= DEFAULT_TEXT_FONT, unsigned short color = DEFAULT_TEXT_COLOR); #endif Modified: trunk/pol-core/pol/item/itemdesc.cpp =================================================================== --- trunk/pol-core/pol/item/itemdesc.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/item/itemdesc.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -229,9 +229,9 @@ else stack_limit = stacklimit; - if (tooltip.length() > PKTOUT_B7::MAX_CHARACTERS) + if (tooltip.length() > PKTOUT_B7_MAX_CHARACTERS) { - tooltip.erase( PKTOUT_B7::MAX_CHARACTERS, string::npos ); + tooltip.erase( PKTOUT_B7_MAX_CHARACTERS, string::npos ); } unsigned short in_movable; Modified: trunk/pol-core/pol/module/uomod.cpp =================================================================== --- trunk/pol-core/pol/module/uomod.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/module/uomod.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -4217,26 +4217,25 @@ getParam( 1, x, -1, 1000000 ) && getParam( 2, y, -1, 1000000 )) //max vaues checked below { - PKTOUT_BA msg; - msg.msgtype = PKTOUT_BA_ID; + PktOut_BA* msg = REQUESTPACKET(PktOut_BA,PKTOUT_BA_ID); if ( x == -1 && y == -1 ) { - msg.active = PKTOUT_BA::ARROW_OFF; - msg.x_tgt = 0; - msg.y_tgt = 0; + msg->Write(static_cast<u8>(PKTOUT_BA_ARROW_OFF)); + msg->offset+=4; // u16 x_tgt,y_tgt } else { if(!chr->realm->valid(static_cast<unsigned short>(x),static_cast<unsigned short>(y),0)) return new BError("Invalid Coordinates for Realm"); - msg.active = PKTOUT_BA::ARROW_ON; - msg.x_tgt = ctBEu16(static_cast<unsigned short>(x & 0xFFFF)); - msg.y_tgt = ctBEu16(static_cast<unsigned short>(y & 0xFFFF)); + msg->Write(static_cast<u8>(PKTOUT_BA_ARROW_ON)); + msg->WriteFlipped(static_cast<unsigned short>(x & 0xFFFF)); + msg->WriteFlipped(static_cast<unsigned short>(y & 0xFFFF)); } if (!chr->has_active_client()) return new BError( "No client attached" ); - chr->client->transmit(&msg, sizeof msg); + chr->client->transmit(&msg->buffer, msg->offset); + READDPACKET(msg); return new BLong( 1 ); } else @@ -5737,19 +5736,18 @@ if ( season_id < 0 || season_id > 4 ) return new BError("Invalid season id"); - PKTOUT_BC msg; + PktOut_BC* msg = REQUESTPACKET(PktOut_BC,PKTOUT_BC_ID); + msg->Write(static_cast<u8>(season_id)); + msg->Write(static_cast<u8>(playsound)); - msg.msgtype = PKTOUT_BC_ID; - msg.season = static_cast<u8>(season_id); - msg.playsound = static_cast<u8>(playsound); - for( Clients::iterator itr = clients.begin(), end = clients.end(); itr != end; ++itr ) { Client* client = *itr; if (!client->chr->logged_in || client->getversiondetail().major < 1) continue; - client->transmit( &msg, sizeof msg ); + client->transmit( &msg->buffer, msg->offset ); } + READDPACKET(msg); return new BLong(1); } else Modified: trunk/pol-core/pol/module/uomod2.cpp =================================================================== --- trunk/pol-core/pol/module/uomod2.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/module/uomod2.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -789,27 +789,14 @@ BObjectImp* UOExecutorModule::internal_SendUnCompressedGumpMenu(Character* chr, ObjArray* layout_arr, ObjArray* data_arr, int x,int y) { - PKTOUT_B0::HEADER* hdr; - PKTOUT_B0::LAYOUT* playout; - unsigned playout_idx; - PKTOUT_B0::DATA_HEADER* pdatahdr; - unsigned pdatahdr_idx; - PKTOUT_B0::DATA* pdata; - int msglen = 0; - - hdr = reinterpret_cast<PKTOUT_B0::HEADER*>(&buffer[0]); - - hdr->msgtype = PKTOUT_B0_ID; - hdr->serial = chr->serial_ext; - hdr->dialogid = ctBEu32( this->uoexec.os_module->pid() ); - hdr->x = ctBEu32( x ); - hdr->y = ctBEu32( y ); - msglen = sizeof *hdr; - - playout_idx = sizeof *hdr; - playout = reinterpret_cast<PKTOUT_B0::LAYOUT*>(&buffer[ msglen ]); - msglen += offsetof( PKTOUT_B0::LAYOUT, text ); - char* addpt = &playout->text[0]; + PktOut_B0* msg = REQUESTPACKET(PktOut_B0,PKTOUT_B0_ID); + msg->offset+=2; + msg->Write(chr->serial_ext); + msg->WriteFlipped(this->uoexec.os_module->pid()); + msg->WriteFlipped(x); + msg->WriteFlipped(y); + u16 pos=msg->offset; + msg->offset+=2; //layoutlen int layoutlen = 0; for( unsigned i = 0; i < layout_arr->ref_arr.size(); ++i ) { @@ -821,35 +808,39 @@ int addlen = 4 + s.length(); layoutlen += addlen; - msglen += addlen; - if (msglen > static_cast<int>(sizeof buffer)) + if (msg->offset+addlen > static_cast<int>(sizeof msg->buffer)) + { + READDPACKET(msg); return new BError( "Buffer length exceeded" ); - *addpt++ = '{'; - *addpt++ = ' '; - memcpy( addpt, s.c_str(), s.length() ); - addpt += s.length(); - *addpt++ = ' '; - *addpt++ = '}'; + } + msg->Write("{ ",2,false); + msg->Write(s.c_str(),static_cast<u16>(s.length()),false); + msg->Write(" }",2,false); } - ++msglen; - if (msglen > static_cast<int>(sizeof buffer)) + msg->offset++; // nullterm + layoutlen++; + if (msg->offset > static_cast<int>(sizeof msg->buffer)) + { + READDPACKET(msg); return new BError( "Buffer length exceeded" ); - *addpt++ = '\0'; - ++layoutlen; + } + + u16 len=msg->offset; + msg->offset=pos; + msg->WriteFlipped(static_cast<u16>(layoutlen)); + msg->offset=len; - - playout->len = ctBEu16( layoutlen ); - - pdatahdr_idx = msglen; - pdatahdr = reinterpret_cast<PKTOUT_B0::DATA_HEADER*>(&buffer[ msglen ]); - int numlines = 0; - msglen += sizeof *pdatahdr; - if (msglen > static_cast<int>(sizeof buffer)) + pos=msg->offset; + msg->offset+=2; //numlines + if (msg->offset > static_cast<int>(sizeof msg->buffer)) + { + READDPACKET(msg); return new BError( "Buffer length exceeded" ); + } + u16 numlines = 0; for( unsigned i = 0; i < data_arr->ref_arr.size(); ++i ) { - pdata = reinterpret_cast<PKTOUT_B0::DATA*>(&buffer[ msglen ]); BObject* bo = data_arr->ref_arr[i].get(); if (bo == NULL) continue; @@ -860,24 +851,36 @@ ++numlines; int textlen = s.length(); - msglen += sizeof *pdata - 1 + textlen * 2; - if (msglen > static_cast<int>(sizeof buffer)) + if (msg->offset+2+textlen*2 > static_cast<int>(sizeof msg->buffer)) + { + READDPACKET(msg); return new BError( "Buffer length exceeded" ); + } - pdata->len = ctBEu16( textlen ); - char* t = &pdata->text[0]; - while (*string) + msg->WriteFlipped(static_cast<u16>(textlen)); + + while (*string) //unicode { - *t++ = '\0'; - *t++ = *string; + msg->offset++; + msg->Write(string,1,false); ++string; } - // msglen += sizeof *pdata - 1 + t - &pdata->text[0]; } + msg->offset++; // nullterm + if (msg->offset > static_cast<int>(sizeof msg->buffer)) + { + READDPACKET(msg); + return new BError( "Buffer length exceeded" ); + } + + len=msg->offset; + msg->offset=pos; + msg->WriteFlipped(numlines); + msg->offset=1; + msg->WriteFlipped(len); - pdatahdr->numlines = ctBEu16( numlines ); - hdr->msglen = ctBEu16( msglen ); - chr->client->transmit( buffer, msglen ); + chr->client->transmit( &msg->buffer, len ); + READDPACKET(msg); chr->client->gd->add_gumpmod( this ); //old_gump_uoemod = this; gump_chr = chr; @@ -1298,45 +1301,32 @@ { return new BError( "No client attached" ); } - static char buffer[ 8000 ]; - // FIXME buffer overflow - unsigned short msglen; - PKTOUT_AB::HEADER* phdr; - PKTOUT_AB::TEXTLINE1* ptextline1; - PKTOUT_AB::TEXTLINE2* ptextline2; + PktOut_AB* msg = REQUESTPACKET(PktOut_AB,PKTOUT_AB_ID); + msg->offset+=2; + msg->Write(chr->serial_ext); + msg->offset+=2; // u8 type,index - phdr = reinterpret_cast<PKTOUT_AB::HEADER*>(&buffer[0]); - phdr->msgtype = PKTOUT_AB_ID; - phdr->serial = chr->serial_ext; - phdr->type = 0; - phdr->index = 0; - msglen = sizeof(*phdr); + unsigned int numbytes = line1->length()+1; + if (numbytes > 256) + numbytes = 256; + msg->WriteFlipped(static_cast<u16>(numbytes)); + msg->Write(line1->data(),static_cast<u16>(numbytes)); // null-terminated - unsigned int numbytes; - - ptextline1 = reinterpret_cast<PKTOUT_AB::TEXTLINE1*>(&buffer[msglen]); - numbytes = line1->length()+1; - msglen += static_cast<unsigned short>(offsetof( PKTOUT_AB::TEXTLINE1,text ) + numbytes); - if (numbytes > sizeof(ptextline1->text)) - numbytes = sizeof(ptextline1->text); - ptextline1->numbytes = ctBEu16( numbytes ); - memcpy( ptextline1->text, line1->data(), numbytes ); - - ptextline2 = reinterpret_cast<PKTOUT_AB::TEXTLINE2*>(&buffer[msglen]); + msg->Write(static_cast<u8>(cancel)); + msg->Write(static_cast<u8>(style)); + msg->WriteFlipped(maximum); numbytes = line2->length() + 1; - if (numbytes > sizeof(ptextline2->text)) - numbytes = sizeof(ptextline2->text); - ptextline2->cancel = static_cast<u8>(cancel); // PKTOUT_AB::TEXTLINE2::CANCEL_DISABLE; - ptextline2->style = static_cast<u8>(style); // PKTOUT_AB::TEXTLINE2::STYLE_NORMAL; - ptextline2->mask = ctBEu32(maximum); - ptextline2->numbytes = ctBEu16( numbytes ); - memcpy( ptextline2->text, line2->data(), numbytes ); - msglen += static_cast<unsigned short>(offsetof( PKTOUT_AB::TEXTLINE2,text) + numbytes); + if (numbytes > 256) + numbytes = 256; + msg->WriteFlipped(static_cast<u16>(numbytes)); + msg->Write(line2->data(),static_cast<u16>(numbytes)); // null-terminated + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); - phdr->msglen = ctBEu16( msglen ); - - chr->client->transmit( buffer, msglen ); + chr->client->transmit( &msg->buffer, len ); + READDPACKET(msg); chr->client->gd->textentry_uoemod = this; textentry_chr = chr; uoexec.os_module->suspend(); Modified: trunk/pol-core/pol/movement.cpp =================================================================== --- trunk/pol-core/pol/movement.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/movement.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -170,7 +170,7 @@ } } client->pause(); - PktBi_22* msg = REQUESTPACKET(PktBi_22,PKTBI_22_APPROVED_ID); + PktOut_22* msg = REQUESTPACKET(PktOut_22,PKTBI_22_APPROVED_ID); msg->Write(msg02->movenum); msg->Write(client->chr->hilite_color_idx( client->chr )); client->transmit( &msg->buffer, msg->offset ); Modified: trunk/pol-core/pol/network/client.cpp =================================================================== --- trunk/pol-core/pol/network/client.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/network/client.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -64,6 +64,7 @@ recv_state( RECV_STATE_CRYPTSEED_WAIT ), bufcheck1_AA(0xAA), buffer(), + xoutbuffer(), bufcheck2_55(0x55), bytes_received(0), message_length(0), Modified: trunk/pol-core/pol/network/client.h =================================================================== --- trunk/pol-core/pol/network/client.h 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/network/client.h 2010-04-10 10:30:25 UTC (rev 234) @@ -153,6 +153,7 @@ unsigned char bufcheck1_AA; unsigned char buffer[ MAXBUFFER ]; + unsigned char xoutbuffer[ 0xFFFF ]; // moved from global transmit_encrypted (threadsafe) unsigned char bufcheck2_55; unsigned int bytes_received; // how many bytes have been received into the buffer. unsigned int message_length; // how many bytes are expected for this message Modified: trunk/pol-core/pol/network/clientio.cpp =================================================================== --- trunk/pol-core/pol/network/clientio.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/network/clientio.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -87,7 +87,6 @@ } } -unsigned char xoutbuffer[ 64000 ]; /* NOTE: If this changes, code in client.cpp must change - pause() and restart() use pre-encrypted values of 33 00 and 33 01. Modified: trunk/pol-core/pol/network/packets.cpp =================================================================== --- trunk/pol-core/pol/network/packets.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/network/packets.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -67,10 +67,21 @@ packets.insert(PacketQueuePair(PKTOUT_A8_ID,new PacketQueueSingle())); packets.insert(PacketQueuePair(PKTOUT_A9_ID,new PacketQueueSingle())); packets.insert(PacketQueuePair(PKTOUT_AA_ID,new PacketQueueSingle())); - + packets.insert(PacketQueuePair(PKTOUT_AB_ID,new PacketQueueSingle())); packets.insert(PacketQueuePair(PKTOUT_AE_ID,new PacketQueueSingle())); + packets.insert(PacketQueuePair(PKTOUT_AF_ID,new PacketQueueSingle())); + packets.insert(PacketQueuePair(PKTOUT_B0_ID,new PacketQueueSingle())); + packets.insert(PacketQueuePair(PKTOUT_B7_ID,new PacketQueueSingle())); + packets.insert(PacketQueuePair(PKTOUT_B9_ID,new PacketQueueSingle())); + packets.insert(PacketQueuePair(PKTOUT_BA_ID,new PacketQueueSingle())); + packets.insert(PacketQueuePair(PKTOUT_BC_ID,new PacketQueueSingle())); packets.insert(PacketQueuePair(PKTBI_BF_ID,new PacketQueueSubs())); + + packets.insert(PacketQueuePair(PKTOUT_C1_ID,new PacketQueueSingle())); + packets.insert(PacketQueuePair(PKTOUT_C7_ID,new PacketQueueSingle())); + + packets.insert(PacketQueuePair(PKTOUT_CC_ID,new PacketQueueSingle())); } PacketInterface* PacketsSingleton::getPacket(u8 id, u16 sub) @@ -186,7 +197,7 @@ case PKTOUT_1D_ID: return new PktOut_1D(); case PKTOUT_20_ID: return new PktOut_20(); case PKTOUT_21_ID: return new PktOut_21(); - case PKTBI_22_APPROVED_ID: return new PktBi_22(); + case PKTBI_22_APPROVED_ID: return new PktOut_22(); case PKTOUT_24_ID: return new PktOut_24(); case PKTOUT_25_ID: return new PktOut_25(); case PKTOUT_27_ID: return new PktOut_27(); @@ -222,8 +233,15 @@ case PKTOUT_A8_ID: return new PktOut_A8(); case PKTOUT_A9_ID: return new PktOut_A9(); case PKTOUT_AA_ID: return new PktOut_AA(); + case PKTOUT_AB_ID: return new PktOut_AB(); + case PKTOUT_AE_ID: return new PktOut_AE(); + case PKTOUT_AF_ID: return new PktOut_AF(); + case PKTOUT_B0_ID: return new PktOut_B0(); + case PKTOUT_B7_ID: return new PktOut_B7(); + case PKTOUT_B9_ID: return new PktOut_B9(); + case PKTOUT_BA_ID: return new PktOut_BA(); + case PKTOUT_BC_ID: return new PktOut_BC(); - case PKTOUT_AE_ID: return new PktOut_AE(); case PKTBI_BF_ID: { switch (sub) @@ -232,6 +250,10 @@ default: return NULL; } } + case PKTOUT_C1_ID: return new PktOut_C1(); + case PKTOUT_C7_ID: return new PktOut_C7(); + + case PKTOUT_CC_ID: return new PktOut_CC(); default: return NULL; } } Modified: trunk/pol-core/pol/network/packets.h =================================================================== --- trunk/pol-core/pol/network/packets.h 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/network/packets.h 2010-04-10 10:30:25 UTC (rev 234) @@ -225,7 +225,7 @@ typedef PacketTemplate<PKTOUT_1D_ID,5> PktOut_1D; typedef PacketTemplate<PKTOUT_20_ID,19> PktOut_20; typedef PacketTemplate<PKTOUT_21_ID,8> PktOut_21; -typedef PacketTemplate<PKTBI_22_APPROVED_ID,3> PktBi_22; +typedef PacketTemplate<PKTBI_22_APPROVED_ID,3> PktOut_22; typedef PacketTemplate<PKTOUT_24_ID,7> PktOut_24; typedef PacketTemplate<PKTOUT_25_ID,21> PktOut_25; typedef PacketTemplate<PKTOUT_27_ID,2> PktOut_27; @@ -261,9 +261,20 @@ typedef PacketTemplate<PKTOUT_A8_ID,2000> PktOut_A8; typedef PacketTemplate<PKTOUT_A9_ID,10000> PktOut_A9; typedef PacketTemplate<PKTOUT_AA_ID,5> PktOut_AA; +typedef PacketTemplate<PKTOUT_AB_ID,531> PktOut_AB; +typedef PacketTemplate<PKTOUT_AE_ID,((SPEECH_MAX_LEN) + 1)*2+48> PktOut_AE; +typedef PacketTemplate<PKTOUT_AF_ID,13> PktOut_AF; +typedef PacketTemplate<PKTOUT_B0_ID,0xFFFF> PktOut_B0; +typedef PacketTemplate<PKTOUT_B7_ID,521> PktOut_B7; +typedef PacketTemplate<PKTOUT_B9_ID,5> PktOut_B9; +typedef PacketTemplate<PKTOUT_BA_ID,6> PktOut_BA; +typedef PacketTemplate<PKTOUT_BC_ID,3> PktOut_BC; -typedef PacketTemplate<PKTOUT_AE_ID,((SPEECH_MAX_LEN) + 1)*2+48> PktOut_AE; typedef PacketTemplateSub<PKTBI_BF_ID,0x4,12> Pktout_bf_sub4_closegump; + +typedef PacketTemplate<PKTOUT_C1_ID,48+(SPEECH_MAX_LEN+1)+2> PktOut_C1; +typedef PacketTemplate<PKTOUT_C7_ID,49> PktOut_C7; +typedef PacketTemplate<PKTOUT_CC_ID,49+(SPEECH_MAX_LEN+1)*2+SPEECH_MAX_LEN+1> PktOut_CC; // Packet defs end Modified: trunk/pol-core/pol/party.cpp =================================================================== --- trunk/pol-core/pol/party.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/party.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -517,12 +517,12 @@ void Party::send_msg_to_all(unsigned int clilocnr, const char* affix, Character* exeptchr) { - unsigned msglen=0; - unsigned char* msg_buffer=NULL; + PktOut_C1* msgc1 = REQUESTPACKET(PktOut_C1,PKTOUT_C1_ID); + PktOut_CC* msgcc = REQUESTPACKET(PktOut_CC,PKTOUT_CC_ID); if (affix!=NULL) - msg_buffer= build_sysmessage_cl_affix(&msglen,clilocnr, affix,true ); + build_sysmessage_cl_affix(msgcc, clilocnr, affix, true ); else - msg_buffer=build_sysmessage_cl(&msglen, clilocnr); + build_sysmessage_cl(msgc1, clilocnr); for( vector<u32>::iterator itr = _member_serials.begin(); itr != _member_serials.end(); ++itr) { @@ -532,15 +532,17 @@ if (chr!=exeptchr) { if (chr->has_active_client()) - chr->client->transmit(msg_buffer,msglen); + { + if (affix!=NULL) + chr->client->transmit(&msgcc->buffer,msgcc->offset); + else + chr->client->transmit(&msgc1->buffer,msgc1->offset); + } } } } - if (msg_buffer!=NULL) - { - delete[] msg_buffer; - msg_buffer=NULL; - } + READDPACKET(msgc1); + READDPACKET(msgcc); } void Party::send_stat_to(Character* chr,Character* bob) Modified: trunk/pol-core/pol/pktdef.h =================================================================== --- trunk/pol-core/pol/pktdef.h 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/pktdef.h 2010-04-10 10:30:25 UTC (rev 234) @@ -150,6 +150,26 @@ FLAG_UNK_0x2000 = 0x2000 // ? }; }; +#define PKTOUT_B7_MAX_CHARACTERS 256 +#define PKTOUT_BA_ARROW_OFF 0 +#define PKTOUT_BA_ARROW_ON 0 + +struct PKTOUT_BC +{ + enum { SEASON_SPRING = 0, SEASON_SUMMER, SEASON_FALL, SEASON_WINTER, SEASON_DESOLATION }; + enum { PLAYSOUND_NO = 0, PLAYSOUND_YES = 1 }; +}; + +struct PKTOUT_C0 +{ + enum { + EFFECT_MOVING = 0x00, + EFFECT_LIGHTNING = 0x01, + EFFECT_FIXEDXYZ = 0x02, + EFFECT_FIXEDFROM = 0x03 + }; +}; + #endif Modified: trunk/pol-core/pol/pktout.h =================================================================== --- trunk/pol-core/pol/pktout.h 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/pktout.h 2010-04-10 10:30:25 UTC (rev 234) @@ -950,32 +950,32 @@ //}; //asserteql( sizeof(PKTOUT_AA), 5 ); -struct PKTOUT_AB -{ - struct HEADER { - u8 msgtype; - u16 msglen; - u32 serial; - u8 type; - u8 index; - }; - struct TEXTLINE1 { - u16 numbytes; - char text[256]; // null-terminated - }; - struct TEXTLINE2 { - u8 cancel; enum { CANCEL_DISABLE, CANCEL_ENABLE }; - u8 style; enum { STYLE_DISABLE, STYLE_NORMAL, STYLE_NUMERICAL }; - u32 mask; - u16 numbytes; - char text[256]; // null-terminated - }; +//struct PKTOUT_AB +//{ +// struct HEADER { +// u8 msgtype; +// u16 msglen; +// u32 serial; +// u8 type; +// u8 index; +// }; +// struct TEXTLINE1 { +// u16 numbytes; +// char text[256]; // null-terminated +// }; +// struct TEXTLINE2 { +// u8 cancel; enum { CANCEL_DISABLE, CANCEL_ENABLE }; +// u8 style; enum { STYLE_DISABLE, STYLE_NORMAL, STYLE_NUMERICAL }; +// u32 mask; +// u16 numbytes; +// char text[256]; // null-terminated +// }; +// +//}; +//asserteql( sizeof(PKTOUT_AB::HEADER), 9 ); +//asserteql( sizeof(PKTOUT_AB::TEXTLINE1), 258 ); +//asserteql( sizeof(PKTOUT_AB::TEXTLINE2), 264 ); -}; -asserteql( sizeof(PKTOUT_AB::HEADER), 9 ); -asserteql( sizeof(PKTOUT_AB::TEXTLINE1), 258 ); -asserteql( sizeof(PKTOUT_AB::TEXTLINE2), 264 ); - //struct PKTOUT_AE //{ // u8 msgtype; @@ -991,123 +991,123 @@ //}; //assertsize( PKTOUT_AE, 450 ); -struct PKTOUT_AF { - u8 msgtype; - u32 player_id; - u32 corpse_id; - u32 unk4_zero; // 0x00000000 -}; -asserteql( sizeof(PKTOUT_AF), 13 ); +//struct PKTOUT_AF { +// u8 msgtype; +// u32 player_id; +// u32 corpse_id; +// u32 unk4_zero; // 0x00000000 +//}; +//asserteql( sizeof(PKTOUT_AF), 13 ); -struct PKTOUT_B0 -{ -// one of these: - struct HEADER { - u8 msgtype; - u16 msglen; - u32 serial; - u32 dialogid; - u32 x; - u32 y; - }; -// followed by one of these (variable length): - struct LAYOUT { - u16 len; - char text[ 1 ]; // null-terminated - }; -// followed by one of these: - struct DATA_HEADER { - u16 numlines; - }; -// followed by zero or more (numlines, above) of these: - struct DATA { - u16 len; - char text[ 1 ]; - }; -}; -asserteql( sizeof(PKTOUT_B0::HEADER), 19 ); -asserteql( sizeof(PKTOUT_B0::LAYOUT), 3 ); -asserteql( sizeof(PKTOUT_B0::DATA_HEADER), 2 ); -asserteql( sizeof(PKTOUT_B0::DATA), 3 ); +//struct PKTOUT_B0 +//{ +//// one of these: +// struct HEADER { +// u8 msgtype; +// u16 msglen; +// u32 serial; +// u32 dialogid; +// u32 x; +// u32 y; +// }; +//// followed by one of these (variable length): +// struct LAYOUT { +// u16 len; +// char text[ 1 ]; // null-terminated +// }; +//// followed by one of these: +// struct DATA_HEADER { +// u16 numlines; +// }; +//// followed by zero or more (numlines, above) of these: +// struct DATA { +// u16 len; +// char text[ 1 ]; +// }; +//}; +//asserteql( sizeof(PKTOUT_B0::HEADER), 19 ); +//asserteql( sizeof(PKTOUT_B0::LAYOUT), 3 ); +//asserteql( sizeof(PKTOUT_B0::DATA_HEADER), 2 ); +//asserteql( sizeof(PKTOUT_B0::DATA), 3 ); -struct PKTOUT_B7 { - u8 msgtype; - u16 msglen; - u32 serial; - enum { MAX_CHARACTERS=256 }; - char text[MAX_CHARACTERS*2+2]; // null-terminated unicode string -}; -asserteql( sizeof(PKTOUT_B7), 521 ); +//struct PKTOUT_B7 { +// u8 msgtype; +// u16 msglen; +// u32 serial; +// enum { MAX_CHARACTERS=256 }; +// char text[MAX_CHARACTERS*2+2]; // null-terminated unicode string +//}; +//asserteql( sizeof(PKTOUT_B7), 521 ); -struct PKTOUT_B9 { - u8 msgtype; - u16 enable; - /* - if (MSB not set) - Bit 0 T2A upgrade, enables chatbutton, - Bit 1 enables LBR update. (of course LBR installation is required) - (plays MP3 instead of midis, 2D LBR client shows new LBR monsters,\x85) - if (MSB set) - Bit 2 T2A upgrade, enables chatbutton, - Bit 3 enables LBR update. - Bit 4 enables Age of Shadows update (AoS monsters/map (AOS installation required for that), - AOS skills/necro/paladin/fight book stuff \x96 works for ALL clients 4.0 and above) - Bit 5 enables use of up to 6 Characters (not only 5) - Bit 6 enables Samurai Empire update (SE map (SE installation required for that)) - Bit 7 enables Mondain's Legacy update (Elves (ML/Gold installation required for that)) - */ -}; -asserteql( sizeof(PKTOUT_B9), 3 ); +//struct PKTOUT_B9 { +// u8 msgtype; +// u16 enable; +// /* +// if (MSB not set) +// Bit 0 T2A upgrade, enables chatbutton, +// Bit 1 enables LBR update. (of course LBR installation is required) +// (plays MP3 instead of midis, 2D LBR client shows new LBR monsters,\x85) +// if (MSB set) +// Bit 2 T2A upgrade, enables chatbutton, +// Bit 3 enables LBR update. +// Bit 4 enables Age of Shadows update (AoS monsters/map (AOS installation required for that), +// AOS skills/necro/paladin/fight book stuff \x96 works for ALL clients 4.0 and above) +// Bit 5 enables use of up to 6 Characters (not only 5) +// Bit 6 enables Samurai Empire update (SE map (SE installation required for that)) +// Bit 7 enables Mondain's Legacy update (Elves (ML/Gold installation required for that)) +// */ +//}; +//asserteql( sizeof(PKTOUT_B9), 3 ); +// +//struct PKTOUT_B9_V2 { +// u8 msgtype; +// u32 enable; +//}; +//asserteql( sizeof(PKTOUT_B9_V2), 5 ); -struct PKTOUT_B9_V2 { - u8 msgtype; - u32 enable; -}; -asserteql( sizeof(PKTOUT_B9_V2), 5 ); +//struct PKTOUT_BA { +// u8 msgtype; +// u8 active; enum { ARROW_OFF = 0, ARROW_ON = 1 }; +// u16 x_tgt; +// u16 y_tgt; +//}; +//asserteql( sizeof(PKTOUT_BA), 6); -struct PKTOUT_BA { - u8 msgtype; - u8 active; enum { ARROW_OFF = 0, ARROW_ON = 1 }; - u16 x_tgt; - u16 y_tgt; -}; -asserteql( sizeof(PKTOUT_BA), 6); +//struct PKTOUT_BC { +// u8 msgtype; +// u8 season; enum { SEASON_SPRING = 0, SEASON_SUMMER, SEASON_FALL, SEASON_WINTER, SEASON_DESOLATION }; +// u8 playsound; enum { PLAYSOUND_NO = 0, PLAYSOUND_YES = 1 }; +//}; +//asserteql( sizeof(PKTOUT_BC), 3 ); -struct PKTOUT_BC { - u8 msgtype; - u8 season; enum { SEASON_SPRING = 0, SEASON_SUMMER, SEASON_FALL, SEASON_WINTER, SEASON_DESOLATION }; - u8 playsound; enum { PLAYSOUND_NO = 0, PLAYSOUND_YES = 1 }; -}; -asserteql( sizeof(PKTOUT_BC), 3 ); - // Big-Endian for u16/32 unless otherwise noted. -struct PKTOUT_C0 -{ - u8 msgtype; - u8 type; - u32 source_serial; - u32 target_serial; - u16 itemid; - u16 x_source; - u16 y_source; - u8 z_source; - u16 x_target; - u16 y_target; - u8 z_target; - u8 speed; - u8 duration; - u16 unk; //On OSI, flamestrikes are 0x0100 - u8 fixed_direction; - u8 explodes; - u32 hue; - u32 render_mode; - enum { - EFFECT_MOVING = 0x00, - EFFECT_LIGHTNING = 0x01, - EFFECT_FIXEDXYZ = 0x02, - EFFECT_FIXEDFROM = 0x03 - }; -}; +//struct PKTOUT_C0 +//{ +// u8 msgtype; +// u8 type; +// u32 source_serial; +// u32 target_serial; +// u16 itemid; +// u16 x_source; +// u16 y_source; +// u8 z_source; +// u16 x_target; +// u16 y_target; +// u8 z_target; +// u8 speed; +// u8 duration; +// u16 unk; //On OSI, flamestrikes are 0x0100 +// u8 fixed_direction; +// u8 explodes; +// u32 hue; +// u32 render_mode; +// enum { +// EFFECT_MOVING = 0x00, +// EFFECT_LIGHTNING = 0x01, +// EFFECT_FIXEDXYZ = 0x02, +// EFFECT_FIXEDFROM = 0x03 +// }; +//}; //Argument example: //take number 1042762: @@ -1115,19 +1115,19 @@ //the arguments string may have "100 thousand\t25 hundred", which in turn would modify the string: //"Only 100 thousand gold could be deposited. A check for 25 hundred gold was returned to you." // Big-Endian for u16/32 unless otherwise noted. -struct PKTOUT_C1 { - u8 msgtype; - u16 msglen; - u32 serial; //0xFFffFFff for system message - u16 body; //0xFFff for system message - u8 type; //6 lower left, 7 on player - u16 hue; - u16 font; - u32 msgnumber; - char name[30]; - u16 arguments[(SPEECH_MAX_LEN) + 1]; // _little-endian_ Unicode string, tabs ('\t') separate the arguments -}; -assertsize( PKTOUT_C1, 450 ); +//struct PKTOUT_C1 { +// u8 msgtype; +// u16 msglen; +// u32 serial; //0xFFffFFff for system message +// u16 body; //0xFFff for system message +// u8 type; //6 lower left, 7 on player +// u16 hue; +// u16 font; +// u32 msgnumber; +// char name[30]; +// u16 arguments[(SPEECH_MAX_LEN) + 1]; // _little-endian_ Unicode string, tabs ('\t') separate the arguments +//}; +//assertsize( PKTOUT_C1, 450 ); //not used: // Big-Endian for u16/32 unless otherwise noted. @@ -1138,34 +1138,34 @@ }; // Big-Endian for u16/32 unless otherwise noted. -struct PKTOUT_C7 -{ - PKTOUT_C0 header; - u16 effect_num; //see particleffect subdir - u16 explode_effect_num; //0 if no explosion - u16 explode_sound_num; //for moving effects, 0 otherwise - u32 itemid; //if target is item (type 2), 0 otherwise - u8 layer; //(of the character, e.g left hand, right hand, \x85 0-5,7, 0xff: moving effect or target is no char) - u16 unk_effect; //for moving effect, 0 otherwise -}; +//struct PKTOUT_C7 +//{ +// PKTOUT_C0 header; +// u16 effect_num; //see particleffect subdir +// u16 explode_effect_num; //0 if no explosion +// u16 explode_sound_num; //for moving effects, 0 otherwise +// u32 itemid; //if target is item (type 2), 0 otherwise +// u8 layer; //(of the character, e.g left hand, right hand, \x85 0-5,7, 0xff: moving effect or target is no char) +// u16 unk_effect; //for moving effect, 0 otherwise +//}; // Big-Endian for u16/32 unless otherwise noted. -struct PKTOUT_CC -{ - u8 msgtype; - u16 msglen; - u32 serial; //0xFFffFFff for system message - u16 body; //0xFFff for system message - u8 type; //6-lowerleft, 7-on player - u16 hue; - u16 font; - u32 msgnumber; - u8 flags; //0x2 unk, 0x4 message doesn't move, - //(flags & 0x1) == 0 signals affix is appended to the localization string, (flags & 0x1) == 1 signals to prepend. - char name[30]; //u8 name[32]; - char affix[1]; //nullterminated, uh not just 1 byte - u16 arguments[1]; // _big-endian_ unicode string, tabs ('\t') seperate arguments, see 0xC1 for argument example -}; +//struct PKTOUT_CC +//{ +// u8 msgtype; +// u16 msglen; +// u32 serial; //0xFFffFFff for system message +// u16 body; //0xFFff for system message +// u8 type; //6-lowerleft, 7-on player +// u16 hue; +// u16 font; +// u32 msgnumber; +// u8 flags; //0x2 unk, 0x4 message doesn't move, +// //(flags & 0x1) == 0 signals affix is appended to the localization string, (flags & 0x1) == 1 signals to prepend. +// char name[30]; //u8 name[32]; +// char affix[1]; //nullterminated, uh not just 1 byte +// u16 arguments[1]; // _big-endian_ unicode string, tabs ('\t') seperate arguments, see 0xC1 for argument example +//}; struct CUSTOM_HOUSE_PLANE { Modified: trunk/pol-core/pol/tooltips.cpp =================================================================== --- trunk/pol-core/pol/tooltips.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/tooltips.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -18,6 +18,7 @@ #include "mobile/charactr.h" #include "network/client.h" +#include "network/packets.h" #include "item/itemdesc.h" #include "msghandl.h" #include "pktboth.h" @@ -40,20 +41,21 @@ const ItemDesc& id = find_itemdesc( item->objtype_ ); if (!id.tooltip.empty()) { - static PKTOUT_B7 msg; - msg.msgtype = PKTOUT_B7_ID; - u16 msglen = static_cast<u16>(offsetof( PKTOUT_B7, text ) + - id.tooltip.length() * 2 + 2); - msg.msglen = ctBEu16( msglen ); - msg.serial = item->serial_ext; - for( unsigned i = 0; i < id.tooltip.length(); ++i ) - { - msg.text[ i*2 ] = '\0'; - msg.text[ i*2 + 1 ] = id.tooltip[ i ]; - } - msg.text[ id.tooltip.length() * 2 ] = '\0'; - msg.text[ id.tooltip.length() * 2 + 1 ] = '\0'; - client->transmit( &msg, msglen ); + PktOut_B7* msg = REQUESTPACKET(PktOut_B7,PKTOUT_B7_ID); + msg->offset+=2; + msg->Write(item->serial_ext); + for( unsigned i = 0; i < id.tooltip.length(); ++i ) + { + msg->offset++; + msg->Write(static_cast<u8>(id.tooltip[ i ])); + } + msg->offset+=2; //nullterm + u16 len=msg->offset; + msg->offset=1; + msg->WriteFlipped(len); + + client->transmit( &msg->offset, len ); + READDPACKET(msg); } } } Modified: trunk/pol-core/pol/ufunc.cpp =================================================================== --- trunk/pol-core/pol/ufunc.cpp 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/ufunc.cpp 2010-04-10 10:30:25 UTC (rev 234) @@ -1292,8 +1292,8 @@ void play_stationary_effect_ex( u16 x, u16 y, u8 z, Realm* realm, u16 effect, u8 speed, u8 duration, u32 hue, u32 render, u16 effect3d ) { - static PKTOUT_C7 msg; - partical_effect(&msg,PKTOUT_C0::EFFECT_FIXEDXYZ, + PktOut_C7* msg = REQUESTPACKET(PktOut_C7,PKTOUT_C7_ID); + partical_effect(msg,PKTOUT_C0::EFFECT_FIXEDXYZ, 0,0,x,y,z,x,y,z, effect,speed,duration,1,0, hue,render, effect3d, 1, 0, @@ -1308,15 +1308,16 @@ if( client->chr->realm != realm ) continue; if (inrange( client->chr->x, client->chr->y, x, y )) - client->transmit( &msg, sizeof msg ); + client->transmit( &msg->buffer, msg->offset ); } + READDPACKET(msg); } void play_object_centered_effect_ex( const UObject* center, u16 effect, u8 speed, u8 duration, u32 hue, u32 render, u8 layer, u16 effect3d ) { - static PKTOUT_C7 msg; - partical_effect(&msg,PKTOUT_C0::EFFECT_FIXEDFROM, + PktOut_C7* msg = REQUESTPACKET(PktOut_C7,PKTOUT_C7_ID); + partical_effect(msg,PKTOUT_C0::EFFECT_FIXEDFROM, center->serial_ext,center->serial_ext, center->x,center->y,center->z, center->x,center->y,center->z, @@ -1324,7 +1325,8 @@ hue,render, effect3d, 1, 0, center->serial_ext,layer); - transmit_to_inrange( center, &msg, sizeof msg, false, false ); + transmit_to_inrange( center, &msg->buffer, msg->offset, false, false ); + READDPACKET(msg); } void play_moving_effect_ex( const UObject *src, const UObject *dst, @@ -1332,8 +1334,8 @@ u32 render, u8 direction, u8 explode, u16 effect3d, u16 effect3dexplode, u16 effect3dsound) { - static PKTOUT_C7 msg; - partical_effect(&msg,PKTOUT_C0::EFFECT_MOVING, + PktOut_C7* msg = REQUESTPACKET(PktOut_C7,PKTOUT_C7_ID); + partical_effect(msg,PKTOUT_C0::EFFECT_MOVING, src->serial_ext,dst->serial_ext, src->x,src->y,src->z+src->height, dst->x,dst->y,dst->z+dst->height, @@ -1351,9 +1353,10 @@ if (inrange( client->chr, src ) || inrange( client->chr, dst )) { - transmit( client, &msg, sizeof msg ); + transmit( client, &msg->buffer, msg->offset ); } } + READDPACKET(msg); } void play_moving_effect2_ex( u16 xs, u16 ys, s8 zs, @@ -1362,8 +1365,8 @@ u32 render, u8 direction, u8 explode, u16 effect3d, u16 effect3dexplode, u16 effect3dsound) { - static PKTOUT_C7 msg; - partical_effect(&msg,PKTOUT_C0::EFFECT_MOVING, + PktOut_C7* msg = REQUESTPACKET(PktOut_C7,PKTOUT_C7_ID); + partical_effect(msg,PKTOUT_C0::EFFECT_MOVING, 0,0,xs,ys,zs,xd,yd,zd, effect,speed,duration, direction,explode,hue,render, effect3d,effect3dexplode,effect3dsound, @@ -1381,13 +1384,14 @@ if (inrange( client->chr, xs, ys ) || inrange( client->chr, xd, yd )) { - transmit( client, &msg, sizeof msg ); + transmit( client, &msg->buffer, msg->offset ); } } + READDPACKET(msg); } // Central function to build 0xC7 packet -void partical_effect(struct PKTOUT_C7* msg,u8 type, u32 srcserial, u32 dstserial, +void partical_effect(PktOut_C7* msg,u8 type, u32 srcserial, u32 dstserial, u16 srcx, u16 srcy, u8 srcz, u16 dstx, u16 dsty, u8 dstz, u16 effect, u8 speed, u8 duration, u8 direction, @@ -1395,30 +1399,31 @@ u16 effect3d, u16 effect3dexplode, u16 effect3dsound, u32 itemid, u8 layer) { - msg->header.msgtype = PKTOUT_C7_ID; - msg->header.type = type; - msg->header.source_serial = srcserial; - msg->header.target_serial = dstserial; - msg->header.x_source = ctBEu16(srcx); - msg->header.y_source = ctBEu16(srcy); - msg->header.z_source = srcz; - msg->header.x_target = ctBEu16(dstx); - msg->header.y_target = ctBEu16(dsty); - msg->header.z_target = dstz; - msg->header.itemid = ctBEu16( effect ); - msg->header.speed = speed; - msg->header.duration = duration; - msg->header.unk = 0; - msg->header.fixed_direction = direction; - msg->header.explodes = explode; - msg->header.hue = ctBEu32(hue); - msg->header.render_mode = ctBEu32(render); - msg->effect_num = ctBEu16(effect3d); - msg->explode_effect_num = ctBEu16(effect3dexplode); - msg->explode_sound_num = ctBEu16(effect3dsound); - msg->itemid = itemid; - msg->layer = layer; - msg->unk_effect = 0; + //C0 part + msg->Write(type); + msg->Write(srcserial); + msg->Write(dstserial); + msg->WriteFlipped(effect); + msg->WriteFlipped(srcx); + msg->WriteFlipped(srcy); + msg->Write(srcz); + msg->WriteFlipped(dstx); + msg->WriteFlipped(dsty); + msg->Write(dstz); + msg->Write(speed); + msg->Write(duration); + msg->offset+=2; // u16 unk + msg->Write(direction); + msg->Write(explode); + msg->WriteFlipped(hue); + msg->WriteFlipped(render); + // C7 part + msg->WriteFlipped(effect3d); //see particleffect subdir + msg->WriteFlipped(effect3dexplode); //0 if no explosion + msg->WriteFlipped(effect3dsound); //for moving effects, 0 otherwise + msg->Write(itemid); //if target is item (type 2), 0 otherwise + msg->Write(layer); //(of the character, e.g left hand, right hand, \x85 0-5,7, 0xff: moving effect or target is no char) + msg->offset+=2; // u16 unk_effect } // System message -- message in lower left corner @@ -1803,11 +1808,10 @@ void send_death_message( Character *chr_died, Item *corpse ) { - PKTOUT_AF msg; - msg.msgtype = PKTOUT_AF_ID; - msg.player_id = chr_died->serial_ext; - msg.corpse_id = corpse->serial_ext; - msg.unk4_zero = 0x00000000; + PktOut_AF* msg = REQUESTPACKET(PktOut_AF,PKTOUT_AF_ID); + msg->Write(chr_died->serial_ext); + msg->Write(corpse->serial_ext); + msg->offset+=4; // u32 unk4_zero for( Clients::iterator itr = clients.begin(), end = clients.end(); itr != end; ++itr ) { @@ -1819,9 +1823,9 @@ continue; if (inrange( client->chr, corpse )) - transmit( client, &msg, sizeof msg ); + transmit( client, &msg->buffer, msg->offset ); } - + READDPACKET(msg); } void transmit_to_inrange( const UObject* center, const void* msg, unsigned msglen, bool is_6017, bool is_UOKR) @@ -2510,20 +2514,13 @@ clientflag |= 0x2000; } + PktOut_B9* msg = REQUESTPACKET(PktOut_B9,PKTOUT_B9_ID); if ( client->ClientType & CLIENTTYPE_60142 ) - { - PKTOUT_B9_V2 msg; - msg.msgtype = PKTOUT_B9_V2_ID; - msg.enable = ctBEu32(clientflag); - client->transmit(&msg, sizeof msg); - } + msg->WriteFlipped(clientflag); else - { - PKTOUT_B9 msg; - msg.msgtype = PKTOUT_B9_ID; - msg.enable = ctBEu16(static_cast<u16>(clientflag)); - client->transmit(&msg, sizeof msg); - } + msg->WriteFlipped(static_cast<u16>(clientflag)); + client->transmit(&msg->buffer, msg->offset); + READDPACKET(msg); } void send_realm_change( Client* client, Realm* realm ) @@ -2558,13 +2555,12 @@ { if (client->getversiondetail().major>=1) { - PKTOUT_BC msg; - msg.msgtype = PKTOUT_BC_ID; - msg.season = static_cast<u8>(client->chr->realm->season()); - msg.playsound = PKTOUT_BC::PLAYSOUND_YES; + PktOut_BC* msg = REQUESTPACKET(PktOut_BC,PKTOUT_BC_ID); + msg->Write(static_cast<u8>(client->chr->realm->season())); + msg->Write(static_cast<u8>(PKTOUT_BC::PLAYSOUND_YES)); + client->transmit( &msg->buffer, msg->offset ); + READDPACKET(msg); - client->transmit( &msg, sizeof msg ); - // Sending Season info resets light level in client, this fixes it during login if (client->gd->weather_region != NULL && client->gd->weather_region->lightoverride != -1 && Modified: trunk/pol-core/pol/ufunc.h =================================================================== --- trunk/pol-core/pol/ufunc.h 2010-04-09 14:00:47 UTC (rev 233) +++ trunk/pol-core/pol/ufunc.h 2010-04-10 10:30:25 UTC (rev 234) @@ -22,6 +22,7 @@ #include "uconst.h" #include "pktout.h" +#include "network/packets.h" #include "core.h" @@ -154,7 +155,7 @@ u16 xd, u16 yd, s8 zd, Realm* realm, u16 effect, u8 speed, u8 duration, u32 hue, u32 render, u8 direction, u8 explode, u16 effect3d, u16 effect3dexplode, u16 effect3dsound); -void partical_effect(struct PKTOUT_C7* msg,u8 type, u32 srcserial, u32 dstserial, +void partical_effect(PktOut_C7* msg,u8 type, u32 srcserial, u32 dstserial, u16 srcx, u16 srcy, u8 srcz, u16 dstx... [truncated message content] |
From: <tu...@us...> - 2010-10-12 15:56:17
|
Revision: 275 http://polserver.svn.sourceforge.net/polserver/?rev=275&view=rev Author: turley Date: 2010-10-12 15:56:11 +0000 (Tue, 12 Oct 2010) Log Message: ----------- fixed .multi member related crash Modified Paths: -------------- trunk/pol-core/pol/uofile03.cpp trunk/pol-core/pol/uoscrobj.cpp Modified: trunk/pol-core/pol/uofile03.cpp =================================================================== --- trunk/pol-core/pol/uofile03.cpp 2010-10-02 08:09:07 UTC (rev 274) +++ trunk/pol-core/pol/uofile03.cpp 2010-10-12 15:56:11 UTC (rev 275) @@ -182,7 +182,7 @@ MOVEMODE movemode) { - if (!VALID_WORLD_LOC(x,y, find_realm(string("britannia"))) + if (!VALID_WORLD_LOC(x,y, find_realm(string("britannia")))) { return false; } @@ -283,7 +283,7 @@ UMulti** pmulti) { - if (!VALID_WORLD_LOC(x,y, find_realm(string("britannia"))) + if (!VALID_WORLD_LOC(x,y, find_realm(string("britannia")))) { return false; } @@ -332,7 +332,7 @@ UMulti* uo_find_supporting_multi( unsigned short x, unsigned short y, int z ) { - if (!VALID_WORLD_LOC( x,y, find_realm(string("britannia") )) + if (!VALID_WORLD_LOC( x,y, find_realm(string("britannia") ))) { return NULL; } Modified: trunk/pol-core/pol/uoscrobj.cpp =================================================================== --- trunk/pol-core/pol/uoscrobj.cpp 2010-10-02 08:09:07 UTC (rev 274) +++ trunk/pol-core/pol/uoscrobj.cpp 2010-10-12 15:56:11 UTC (rev 275) @@ -769,9 +769,14 @@ case MBR_DIRTY: return new BLong(dirty_ ? 1 : 0); break; case MBR_WEIGHT: return new BLong(weight()); break; case MBR_MULTI: - UMulti* multi; - if( NULL != (multi = realm->find_supporting_multi(x,y,z)) ) - return multi->make_ref(); + if ( realm != NULL ) + { + UMulti* multi; + if( NULL != (multi = realm->find_supporting_multi(x,y,z)) ) + return multi->make_ref(); + else + return new BLong(0); + } else return new BLong(0); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2011-02-18 15:45:19
|
Revision: 306 http://polserver.svn.sourceforge.net/polserver/?rev=306&view=rev Author: turley Date: 2011-02-18 15:45:13 +0000 (Fri, 18 Feb 2011) Log Message: ----------- minor performance improvement Modified Paths: -------------- trunk/pol-core/pol/realms.cpp trunk/pol-core/pol/realms.h Modified: trunk/pol-core/pol/realms.cpp =================================================================== --- trunk/pol-core/pol/realms.cpp 2011-02-18 14:40:36 UTC (rev 305) +++ trunk/pol-core/pol/realms.cpp 2011-02-18 15:45:13 UTC (rev 306) @@ -61,7 +61,7 @@ return false; } -Realm* find_realm(const string name) +Realm* find_realm(const string& name) { vector<Realm*>::iterator itr; for(itr = Realms->begin(); itr != Realms->end(); ++itr) @@ -72,7 +72,7 @@ return NULL; } -bool defined_realm(const string name) +bool defined_realm(const string& name) { vector<Realm*>::iterator itr; for(itr = Realms->begin(); itr != Realms->end(); ++itr) @@ -83,7 +83,7 @@ return false; } -void add_realm(const string name, Realm* base) +void add_realm(const string& name, Realm* base) { Realm* r = new Realm(name,base); r->shadowid = ++shadowrealm_count; @@ -91,7 +91,7 @@ Realms->push_back( r ); } -void remove_realm(const string name) +void remove_realm(const string& name) { vector<Realm*>::iterator itr; for(itr = Realms->begin(); itr != Realms->end(); ++itr) Modified: trunk/pol-core/pol/realms.h =================================================================== --- trunk/pol-core/pol/realms.h 2011-02-18 14:40:36 UTC (rev 305) +++ trunk/pol-core/pol/realms.h 2011-02-18 15:45:13 UTC (rev 306) @@ -23,10 +23,10 @@ extern unsigned int baserealm_count; extern unsigned int shadowrealm_count; -Realm* find_realm(const std::string name); -void add_realm(const std::string name, Realm* base); -bool defined_realm(const std::string name); -void remove_realm(const std::string name); +Realm* find_realm(const std::string& name); +void add_realm(const std::string& name, Realm* base); +bool defined_realm(const std::string& name); +void remove_realm(const std::string& name); #define ENABLE_OLD_MAPCODE 0 // Support up to 5 Maps: Britannia, Britannia_alt, Ilshenar, Malas, Tokuno, TerMur This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2011-12-11 23:44:38
|
Revision: 410 http://polserver.svn.sourceforge.net/polserver/?rev=410&view=rev Author: databreaker Date: 2011-12-11 23:44:32 +0000 (Sun, 11 Dec 2011) Log Message: ----------- fixed process_data() not properly grabbing client version after seed packet Modified Paths: -------------- trunk/pol-core/pol/network/client.h trunk/pol-core/pol/pol.cpp Modified: trunk/pol-core/pol/network/client.h =================================================================== --- trunk/pol-core/pol/network/client.h 2011-12-11 20:37:33 UTC (rev 409) +++ trunk/pol-core/pol/network/client.h 2011-12-11 23:44:32 UTC (rev 410) @@ -164,7 +164,8 @@ RECV_STATE_CRYPTSEED_WAIT, RECV_STATE_MSGTYPE_WAIT, RECV_STATE_MSGLEN_WAIT, - RECV_STATE_MSGDATA_WAIT + RECV_STATE_MSGDATA_WAIT, + RECV_STATE_CLIENTVERSION_WAIT } recv_state; unsigned char bufcheck1_AA; Modified: trunk/pol-core/pol/pol.cpp =================================================================== --- trunk/pol-core/pol/pol.cpp 2011-12-11 20:37:33 UTC (rev 409) +++ trunk/pol-core/pol/pol.cpp 2011-12-11 23:44:32 UTC (rev 410) @@ -851,6 +851,21 @@ } // else keep waiting } + else if (client->recv_state == Client::RECV_STATE_CLIENTVERSION_WAIT) + { + client->recv_remaining_nocrypt(21); // receive and send to handler to get directly the version + if (client->bytes_received == 21) + { + client->recv_state = Client::RECV_STATE_MSGTYPE_WAIT; + unsigned char tempseed[4]; + tempseed[0] = client->buffer[1]; + tempseed[1] = client->buffer[2]; + tempseed[2] = client->buffer[3]; + tempseed[3] = client->buffer[4]; + client->cryptengine->Init( tempseed, CCryptBase::typeLogin ); + (*handler[PKTIN_EF_ID].func)(client, client->buffer); + } + } else if (client->recv_state == Client::RECV_STATE_CRYPTSEED_WAIT) { // The abnormal case. // The first four bytes after connection are the @@ -906,15 +921,7 @@ { printf( "6.0.5.0+ Crypt Seed Message Received: Type 0x%X\n", cstype ); } - client->recv_state = Client::RECV_STATE_MSGTYPE_WAIT; - client->recv_remaining_nocrypt(21); // receive and send to handler to get directly the version - unsigned char tempseed[4]; - tempseed[0] = client->buffer[1]; - tempseed[1] = client->buffer[2]; - tempseed[2] = client->buffer[3]; - tempseed[3] = client->buffer[4]; - client->cryptengine->Init( tempseed, CCryptBase::typeLogin ); - (*handler[PKTIN_EF_ID].func)(client, client->buffer); + client->recv_state = Client::RECV_STATE_CLIENTVERSION_WAIT; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2011-12-17 12:06:07
|
Revision: 424 http://polserver.svn.sourceforge.net/polserver/?rev=424&view=rev Author: turley Date: 2011-12-17 12:05:57 +0000 (Sat, 17 Dec 2011) Log Message: ----------- finished refactoring of pkthelper Modified Paths: -------------- trunk/pol-core/pol/bowsalut.cpp trunk/pol-core/pol/clfunc.cpp trunk/pol-core/pol/dblclick.cpp trunk/pol-core/pol/dropitem.cpp trunk/pol-core/pol/getmsg.cpp trunk/pol-core/pol/irequest.cpp trunk/pol-core/pol/login.cpp trunk/pol-core/pol/miscmsg.cpp trunk/pol-core/pol/mobile/charactr.cpp trunk/pol-core/pol/module/npcmod.cpp trunk/pol-core/pol/module/osmod.cpp trunk/pol-core/pol/module/unimod.cpp trunk/pol-core/pol/module/uomod.cpp trunk/pol-core/pol/module/uomod2.cpp trunk/pol-core/pol/movement.cpp trunk/pol-core/pol/multi/boat.cpp trunk/pol-core/pol/multi/customhouses.cpp trunk/pol-core/pol/network/cliface.cpp trunk/pol-core/pol/network/packets.h trunk/pol-core/pol/party.cpp trunk/pol-core/pol/pol.cpp trunk/pol-core/pol/speech.cpp trunk/pol-core/pol/spelbook.cpp trunk/pol-core/pol/statmsg.cpp trunk/pol-core/pol/target.cpp trunk/pol-core/pol/tips.cpp trunk/pol-core/pol/tooltips.cpp trunk/pol-core/pol/ufunc.cpp trunk/pol-core/pol/ufunc2.cpp trunk/pol-core/pol/umap.cpp trunk/pol-core/pol/uoscrobj.cpp Modified: trunk/pol-core/pol/bowsalut.cpp =================================================================== --- trunk/pol-core/pol/bowsalut.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/bowsalut.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -86,7 +86,7 @@ action = new_action; } } - PktOut_6E* msg = REQUESTPACKET(PktOut_6E,PKTOUT_6E_ID); + PktOut_6E* msg = PktHelper::RequestPacket<PktOut_6E>(PKTOUT_6E_ID); msg->Write(obj->serial_ext); msg->WriteFlipped(static_cast<u16>(action)); msg->WriteFlipped(framecount); @@ -95,7 +95,7 @@ msg->Write(static_cast<u8>(repeatflag)); msg->Write(delay); transmit_to_inrange( obj, &msg->buffer, msg->offset, false, false ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void handle_action( Client *client, PKTIN_12 *cmd ) Modified: trunk/pol-core/pol/clfunc.cpp =================================================================== --- trunk/pol-core/pol/clfunc.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/clfunc.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -31,7 +31,7 @@ unsigned int cliloc_num, const u16 *arguments, unsigned short font, unsigned short color ) { - PktOut_C1* msg = REQUESTPACKET(PktOut_C1,PKTOUT_C1_ID); + PktOut_C1* msg = PktHelper::RequestPacket<PktOut_C1>(PKTOUT_C1_ID); msg->offset+=2; unsigned textlen = 0; @@ -59,14 +59,14 @@ msg->offset=1; msg->WriteFlipped(len); transmit( client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void say_above_cl(UObject *obj, unsigned int cliloc_num, const u16 *arguments, unsigned short font, unsigned short color ) { - PktOut_C1* msg = REQUESTPACKET(PktOut_C1,PKTOUT_C1_ID); + PktOut_C1* msg = PktHelper::RequestPacket<PktOut_C1>(PKTOUT_C1_ID); msg->offset+=2; unsigned textlen = 0; @@ -95,14 +95,14 @@ msg->WriteFlipped(len); // MuadDib - FIXME: only send to those that I'm visible to. transmit_to_inrange( obj, &msg->buffer, len, false, false ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void private_say_above_cl(Character *chr, const UObject* obj, unsigned int cliloc_num, const u16 *arguments, unsigned short font, unsigned short color ) { - PktOut_C1* msg = REQUESTPACKET(PktOut_C1,PKTOUT_C1_ID); + PktOut_C1* msg = PktHelper::RequestPacket<PktOut_C1>(PKTOUT_C1_ID); msg->offset+=2; unsigned textlen = 0; @@ -130,7 +130,7 @@ msg->offset=1; msg->WriteFlipped(len); ADDTOSENDQUEUE(chr->client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } @@ -138,7 +138,7 @@ bool prepend, const u16 *arguments, unsigned short font, unsigned short color ) { - PktOut_CC* msg = REQUESTPACKET(PktOut_CC,PKTOUT_CC_ID); + PktOut_CC* msg = PktHelper::RequestPacket<PktOut_CC>(PKTOUT_CC_ID); msg->offset+=2; unsigned textlen = 0, affix_len = 0; @@ -172,14 +172,14 @@ msg->WriteFlipped(len); ADDTOSENDQUEUE(client,&msg->buffer, len); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void say_above_cl_affix(UObject *obj, unsigned int cliloc_num, const char* affix, bool prepend, const u16 *arguments, unsigned short font, unsigned short color) { - PktOut_CC* msg = REQUESTPACKET(PktOut_CC,PKTOUT_CC_ID); + PktOut_CC* msg = PktHelper::RequestPacket<PktOut_CC>(PKTOUT_CC_ID); msg->offset+=2; unsigned textlen = 0, affix_len = 0; @@ -214,14 +214,14 @@ // MuadDib - FIXME: only send to those that I'm visible to. transmit_to_inrange( obj, &msg->buffer, len, false, false ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void private_say_above_cl_affix(Character *chr, const UObject* obj, unsigned int cliloc_num, const char* affix, bool prepend, const u16 *arguments, unsigned short font, unsigned short color) { - PktOut_CC* msg = REQUESTPACKET(PktOut_CC,PKTOUT_CC_ID); + PktOut_CC* msg = PktHelper::RequestPacket<PktOut_CC>(PKTOUT_CC_ID); msg->offset+=2; unsigned textlen = 0, affix_len = 0; @@ -255,7 +255,7 @@ msg->WriteFlipped(len); ADDTOSENDQUEUE(chr->client,&msg->buffer, len); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void build_sysmessage_cl(PktOut_C1* msg, unsigned int cliloc_num, const u16 *arguments, Modified: trunk/pol-core/pol/dblclick.cpp =================================================================== --- trunk/pol-core/pol/dblclick.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/dblclick.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -46,7 +46,7 @@ void send_paperdoll( Client *client, Character *chr ) { - PktOut_88* msg = REQUESTPACKET(PktOut_88,PKTOUT_88_ID); + PktOut_88* msg = PktHelper::RequestPacket<PktOut_88>(PKTOUT_88_ID); msg->Write(chr->serial_ext); if ((!ssopt.privacy_paperdoll) || (client->chr == chr)) @@ -77,7 +77,7 @@ msg->Write(flag1); ADDTOSENDQUEUE(client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void doubleclick( Client *client, PKTIN_06 *msg ) Modified: trunk/pol-core/pol/dropitem.cpp =================================================================== --- trunk/pol-core/pol/dropitem.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/dropitem.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -404,7 +404,7 @@ Character* whos, UContainer* cont ) { - PktOut_25* msg = REQUESTPACKET(PktOut_25,PKTOUT_25_ID); + PktOut_25* msg = PktHelper::RequestPacket<PktOut_25>(PKTOUT_25_ID); msg->Write(cont->serial_ext); msg->WriteFlipped(cont->graphic); msg->offset++; //unk7 layer? @@ -416,7 +416,7 @@ msg->Write(whos->serial_ext); msg->WriteFlipped(cont->color); transmit( client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } bool do_open_trade_window( Client* client, Item* item, Character* dropon ); @@ -521,7 +521,7 @@ send_trade_container( client, client->chr, client->chr->trade_container() ); send_trade_container( dropon->client, client->chr, client->chr->trade_container() ); - PktOut_6F* msg = REQUESTPACKET(PktOut_6F,PKTBI_6F_ID); + PktOut_6F* msg = PktHelper::RequestPacket<PktOut_6F>(PKTBI_6F_ID); msg->WriteFlipped(static_cast<u16>(sizeof msg->buffer)); msg->Write(static_cast<u8>(PKTBI_6F::ACTION_INIT)); msg->Write(dropon->serial_ext); @@ -539,7 +539,7 @@ msg->offset++; // u8 havename same as above msg->Write(client->chr->name().c_str(),30,false); ADDTOSENDQUEUE(dropon->client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); if (item != NULL) return place_item_in_secure_trade_container( client, item, 20, 20 ); @@ -844,9 +844,9 @@ item->gotten_by = NULL; } - PktOut_29* drop_msg = REQUESTPACKET(PktOut_29,PKTOUT_29_ID); + PktOut_29* drop_msg = PktHelper::RequestPacket<PktOut_29>(PKTOUT_29_ID); ADDTOSENDQUEUE(client,&drop_msg->buffer, drop_msg->offset); - READDPACKET(drop_msg); + PktHelper::ReAddPacket(drop_msg); send_full_statmsg( client, client->chr ); } @@ -916,13 +916,13 @@ if (chr1->client) { - PktOut_6F* msg = REQUESTPACKET(PktOut_6F,PKTBI_6F_ID); + PktOut_6F* msg = PktHelper::RequestPacket<PktOut_6F>(PKTBI_6F_ID); msg->WriteFlipped(static_cast<u16>(17)); // no name msg->Write(static_cast<u8>(PKTBI_6F::ACTION_CANCEL)); msg->Write(chr1->trade_container()->serial_ext); msg->offset+=9; // u32 cont1_serial, cont2_serial, u8 havename transmit( chr1->client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); send_full_statmsg( chr1->client, chr1 ); } @@ -932,13 +932,13 @@ chr2->trading_with.clear(); if (chr2->client) { - PktOut_6F* msg = REQUESTPACKET(PktOut_6F,PKTBI_6F_ID); + PktOut_6F* msg = PktHelper::RequestPacket<PktOut_6F>(PKTBI_6F_ID); msg->WriteFlipped(static_cast<u16>(17)); // no name msg->Write(static_cast<u8>(PKTBI_6F::ACTION_CANCEL)); msg->Write(chr2->trade_container()->serial_ext); msg->offset+=9; // u32 cont1_serial, cont2_serial, u8 havename transmit( chr2->client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); send_full_statmsg( chr2->client, chr2 ); } } @@ -949,7 +949,7 @@ unsigned int stat1 = chr->trade_accepted?1:0; unsigned int stat2 = chr->trading_with->trade_accepted?1:0; - PktOut_6F* msg = REQUESTPACKET(PktOut_6F,PKTBI_6F_ID); + PktOut_6F* msg = PktHelper::RequestPacket<PktOut_6F>(PKTBI_6F_ID); msg->WriteFlipped(static_cast<u16>(17)); // no name msg->Write(static_cast<u8>(PKTBI_6F::ACTION_STATUS)); msg->Write(chr->trade_container()->serial_ext); @@ -963,7 +963,7 @@ msg->WriteFlipped(stat1); msg->offset++; transmit( chr->trading_with->client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void change_trade_status( Character* chr, bool set ) Modified: trunk/pol-core/pol/getmsg.cpp =================================================================== --- trunk/pol-core/pol/getmsg.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/getmsg.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -31,13 +31,13 @@ void send_prompt( Client* client, u32 serial ) { - PktOut_9A* msg = REQUESTPACKET(PktOut_9A,PKTBI_9A_ID); + PktOut_9A* msg = PktHelper::RequestPacket<PktOut_9A>(PKTBI_9A_ID); msg->WriteFlipped(static_cast<u16>(sizeof msg->buffer)); msg->Write(serial); msg->WriteFlipped(static_cast<u32>(0x15)); msg->offset+=5; // u32 type u8 text[0] transmit( client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void handle_prompt( Client* client, PKTBI_9A* msg ) Modified: trunk/pol-core/pol/irequest.cpp =================================================================== --- trunk/pol-core/pol/irequest.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/irequest.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -54,7 +54,7 @@ void send_skillmsg( Client *client, const Character *chr ) { - PktOut_3A* msg = REQUESTPACKET(PktOut_3A,PKTBI_3A_ID); + PktOut_3A* msg = PktHelper::RequestPacket<PktOut_3A>(PKTBI_3A_ID); msg->offset+=2; if (ssopt.core_sends_caps) msg->Write(static_cast<u8>(PKTBI_3A_VALUES::FULL_LIST_CAP)); @@ -96,7 +96,7 @@ msg->offset=1; msg->WriteFlipped(len); ADDTOSENDQUEUE(client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void handle_skill_lock( Client *client, PKTBI_3A_LOCKS *msg ) Modified: trunk/pol-core/pol/login.cpp =================================================================== --- trunk/pol-core/pol/login.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/login.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -59,10 +59,10 @@ void send_login_error( Client *client, unsigned char reason ) { - PktOut_82* msg = REQUESTPACKET(PktOut_82,PKTOUT_82_ID); + PktOut_82* msg = PktHelper::RequestPacket<PktOut_82>(PKTOUT_82_ID); msg->Write(reason); ADDTOSENDQUEUE(client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } bool acct_check(Client* client, int i) @@ -158,7 +158,7 @@ AddressToString( &client->ipaddr )); client->acct = acct; - PktOut_A8* msgA8 = REQUESTPACKET(PktOut_A8,PKTOUT_A8_ID); + PktOut_A8* msgA8 = PktHelper::RequestPacket<PktOut_A8>(PKTOUT_A8_ID); msgA8->offset+=2; msgA8->Write(static_cast<u8>(0xFF)); msgA8->offset+=2; //servcount @@ -208,7 +208,7 @@ msgA8->WriteFlipped(servcount); ADDTOSENDQUEUE(client, &msgA8->buffer, len);//client->transmit( &msgA8->buffer, len ); - READDPACKET(msgA8); + PktHelper::ReAddPacket(msgA8); if (servcount == 0) { @@ -265,7 +265,7 @@ ServerDescription *svr = servers[ servernum ]; - PktOut_8C* rsp = REQUESTPACKET(PktOut_8C,PKTOUT_8C_ID); + PktOut_8C* rsp = PktHelper::RequestPacket<PktOut_8C>(PKTOUT_8C_ID); rsp->Write(svr->ip[3]); rsp->Write(svr->ip[2]); rsp->Write(svr->ip[1]); @@ -283,7 +283,7 @@ rsp->WriteFlipped(nseed); // This was set to 0xffffffff in the past but this will conflict with UO:KR detection ADDTOSENDQUEUE(client, &rsp->buffer, rsp->offset ); - READDPACKET(rsp); + PktHelper::ReAddPacket(rsp); client->cryptengine->Init( &nseed, CCryptBase::typeGame ); } @@ -310,7 +310,7 @@ if (char_slots > char_count) // Max(char_slots, 5) char_count = char_slots; - PktOut_A9* msg = REQUESTPACKET(PktOut_A9,PKTOUT_A9_ID); + PktOut_A9* msg = PktHelper::RequestPacket<PktOut_A9>(PKTOUT_A9_ID); msg->offset+=2; msg->Write(char_count); @@ -376,7 +376,7 @@ msg->WriteFlipped(len); ADDTOSENDQUEUE(client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } Modified: trunk/pol-core/pol/miscmsg.cpp =================================================================== --- trunk/pol-core/pol/miscmsg.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/miscmsg.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -391,12 +391,12 @@ return; } - PktOut_98* msgOut = REQUESTPACKET(PktOut_98,PKTBI_98_OUT_ID); + PktOut_98* msgOut = PktHelper::RequestPacket<PktOut_98>(PKTBI_98_OUT_ID); msgOut->WriteFlipped(static_cast<u16>(37)); // static length msgOut->Write(the_mob->serial_ext); msgOut->Write(the_mob->name().c_str(),30,false); transmit( client, &msgOut->buffer, msgOut->offset ); - READDPACKET(msgOut); + PktHelper::ReAddPacket(msgOut); } else { Modified: trunk/pol-core/pol/mobile/charactr.cpp =================================================================== --- trunk/pol-core/pol/mobile/charactr.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/mobile/charactr.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -1863,14 +1863,14 @@ // if poisoned send_move_mobile_to_nearby_cansee handles 0x17 packet if (!poisoned) { - PktOut_17* msg = REQUESTPACKET(PktOut_17,PKTOUT_17_ID); + PktOut_17* msg = PktHelper::RequestPacket<PktOut_17>(PKTOUT_17_ID); msg->WriteFlipped(static_cast<u16>(sizeof msg->buffer)); msg->Write(this->serial_ext); msg->Write(static_cast<u16>(1)); //unk msg->Write(static_cast<u16>(1)); // status_type msg->Write(static_cast<u8>(0)); //flag transmit_to_inrange( this, &msg->buffer, msg->offset, false, true ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } } } @@ -2140,13 +2140,13 @@ void Character::send_warmode() { - PktOut_72* msg = REQUESTPACKET(PktOut_72,PKTBI_72_ID); + PktOut_72* msg = PktHelper::RequestPacket<PktOut_72>(PKTBI_72_ID); msg->Write(static_cast<u8>(warmode ? 1 : 0)); msg->offset++; // u8 unk2 msg->Write(static_cast<u8>(0x32)); msg->offset++; // u8 unk4 transmit( client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void send_remove_if_hidden_ghost( Character* chr, Client* client ) @@ -2809,7 +2809,7 @@ // NOTE: chr is at new position, lastx/lasty have old position. void PropagateMove( /*Client *client,*/ Character *chr ) { - PktOut_1D* msgremove = REQUESTPACKET(PktOut_1D,PKTOUT_1D_ID); + PktOut_1D* msgremove = PktHelper::RequestPacket<PktOut_1D>(PKTOUT_1D_ID); msgremove->Write(chr->serial_ext); PktOut_77* msgmove = build_send_move(chr); PktOut_17* msgpoison = build_poisonhealthbar(chr); @@ -2864,10 +2864,10 @@ } } - READDPACKET(msgremove); - READDPACKET(msgmove); - READDPACKET(msgpoison); - READDPACKET(msgcreate); + PktHelper::ReAddPacket(msgremove); + PktHelper::ReAddPacket(msgmove); + PktHelper::ReAddPacket(msgpoison); + PktHelper::ReAddPacket(msgcreate); } void Character::getpos_ifmove( UFACING i_facing, unsigned short* px, unsigned short* py ) @@ -3046,14 +3046,14 @@ { Character* opponent = get_opponent(); - PktOut_AA* msg = REQUESTPACKET(PktOut_AA,PKTOUT_AA_ID); + PktOut_AA* msg = PktHelper::RequestPacket<PktOut_AA>(PKTOUT_AA_ID); if (opponent != NULL) msg->Write(opponent->serial_ext); else msg->offset+=4; transmit( client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } } Modified: trunk/pol-core/pol/module/npcmod.cpp =================================================================== --- trunk/pol-core/pol/module/npcmod.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/module/npcmod.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -750,7 +750,7 @@ return new BError("texttype string param must be either 'default', 'whisper', or 'yell'"); - PktOut_1C* msg = REQUESTPACKET(PktOut_1C,PKTOUT_1C_ID); + PktOut_1C* msg = PktHelper::RequestPacket<PktOut_1C>(PKTOUT_1C_ID); msg->offset+=2; msg->Write(npc.serial_ext); msg->WriteFlipped(npc.graphic); @@ -789,7 +789,7 @@ if ( doevent >= 1 ) for_nearby_npcs(npc_spoke, &npc, text, strlen(text), texttype); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return NULL; } @@ -843,7 +843,7 @@ else texttype=TEXTTYPE_NORMAL; - PktOut_AE* talkmsg = REQUESTPACKET(PktOut_AE,PKTOUT_AE_ID); + PktOut_AE* talkmsg = PktHelper::RequestPacket<PktOut_AE>(PKTOUT_AE_ID); talkmsg->offset+=2; talkmsg->Write(npc.serial_ext); talkmsg->WriteFlipped(npc.graphic); @@ -874,7 +874,7 @@ if ( rangeok ) transmit( client, &talkmsg->buffer, len ); } - READDPACKET(talkmsg); + PktHelper::ReAddPacket(talkmsg); if ( doevent >= 1 ) { char ntextbuf[SPEECH_MAX_LEN+1]; Modified: trunk/pol-core/pol/module/osmod.cpp =================================================================== --- trunk/pol-core/pol/module/osmod.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/module/osmod.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -647,7 +647,7 @@ { if (chr->has_active_client()) { - PktOut_A5* msg = REQUESTPACKET(PktOut_A5,PKTOUT_A5_ID); + PktOut_A5* msg = PktHelper::RequestPacket<PktOut_A5>(PKTOUT_A5_ID); unsigned urllen; const char *url = str->data(); @@ -658,7 +658,7 @@ msg->WriteFlipped(static_cast<u16>(urllen+4)); msg->Write(url,static_cast<u16>(urllen+1)); ADDTOSENDQUEUE(chr->client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BLong(1); } else Modified: trunk/pol-core/pol/module/unimod.cpp =================================================================== --- trunk/pol-core/pol/module/unimod.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/module/unimod.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -49,13 +49,13 @@ void send_unicode_prompt( Client* client, u32 serial ) { - PktOut_C2* msg = REQUESTPACKET(PktOut_C2,PKTBI_C2_ID); + PktOut_C2* msg = PktHelper::RequestPacket<PktOut_C2>(PKTBI_C2_ID); msg->WriteFlipped(static_cast<u16>(PKTBI_C2::SERVER_MSGLEN)); msg->Write(serial); //serial msg->Write(serial); //msg_id Server-"decided" message ID. o_O msg->offset+=10; // 10x u8 unk transmit( client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void handle_unicode_prompt( Client* client, PKTBI_C2* msg ) Modified: trunk/pol-core/pol/module/uomod.cpp =================================================================== --- trunk/pol-core/pol/module/uomod.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/module/uomod.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -830,13 +830,13 @@ { if (chr->target_cursor_busy()) { - PktOut_6C* msg = REQUESTPACKET(PktOut_6C,PKTBI_6C_ID); + PktOut_6C* msg = PktHelper::RequestPacket<PktOut_6C>(PKTBI_6C_ID); msg->Write(static_cast<u8>(PKTBI_6C::UNK1_00)); msg->offset+=4; // u32 target_cursor_serial msg->Write(static_cast<u8>(0x3)); // rest 0 ADDTOSENDQUEUE(chr->client, &msg->buffer, sizeof msg->buffer ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BLong(0); } else @@ -4233,7 +4233,7 @@ getParam( 1, x, -1, 1000000 ) && getParam( 2, y, -1, 1000000 )) //max vaues checked below { - PktOut_BA* msg = REQUESTPACKET(PktOut_BA,PKTOUT_BA_ID); + PktOut_BA* msg = PktHelper::RequestPacket<PktOut_BA>(PKTOUT_BA_ID); if ( x == -1 && y == -1 ) { msg->Write(static_cast<u8>(PKTOUT_BA_ARROW_OFF)); @@ -4251,7 +4251,7 @@ return new BError( "No client attached" ); ADDTOSENDQUEUE(chr->client,&msg->buffer, msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BLong( 1 ); } else @@ -5779,7 +5779,7 @@ if ( season_id < 0 || season_id > 4 ) return new BError("Invalid season id"); - PktOut_BC* msg = REQUESTPACKET(PktOut_BC,PKTOUT_BC_ID); + PktOut_BC* msg = PktHelper::RequestPacket<PktOut_BC>(PKTOUT_BC_ID); msg->Write(static_cast<u8>(season_id)); msg->Write(static_cast<u8>(playsound)); @@ -5790,7 +5790,7 @@ continue; ADDTOSENDQUEUE(client,&msg->buffer, msg->offset ); } - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BLong(1); } else Modified: trunk/pol-core/pol/module/uomod2.cpp =================================================================== --- trunk/pol-core/pol/module/uomod2.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/module/uomod2.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -154,7 +154,7 @@ bool send_vendorwindow_contents( Client* client, UContainer* for_sale, bool send_aos_tooltip ) { - PktOut_74* msg = REQUESTPACKET(PktOut_74,PKTOUT_74_ID); + PktOut_74* msg = PktHelper::RequestPacket<PktOut_74>(PKTOUT_74_ID); msg->offset+=2; //msglen msg->Write(for_sale->serial_ext); msg->offset++; //num_items @@ -168,7 +168,7 @@ unsigned int addlen = 5 + desc.size(); if (msg->offset + addlen > sizeof msg->buffer) { - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return false; } msg->WriteFlipped(item->sellprice()); @@ -186,7 +186,7 @@ msg->Write(num_items); transmit( client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return true; } @@ -291,13 +291,13 @@ } //This looks good - PktOut_24* open_window = REQUESTPACKET(PktOut_24,PKTOUT_24_ID); + PktOut_24* open_window = PktHelper::RequestPacket<PktOut_24>(PKTOUT_24_ID); open_window->Write(merchant->serial_ext); open_window->WriteFlipped(static_cast<u16>(0x0030)); // FIXME: Serial of buy gump needs #define or enum? if (chr->client->ClientType & CLIENTTYPE_7090) open_window->WriteFlipped(static_cast<u16>(0x00)); transmit( chr->client, &open_window->buffer, open_window->offset ); - READDPACKET(open_window); + PktHelper::ReAddPacket(open_window); // Tell the client how much gold the character has, I guess send_full_statmsg(chr->client, chr); @@ -310,12 +310,12 @@ void send_clear_vendorwindow( Client* client, Character* vendor ) { - PktOut_3B* msg = REQUESTPACKET(PktOut_3B,PKTBI_3B_ID); + PktOut_3B* msg = PktHelper::RequestPacket<PktOut_3B>(PKTBI_3B_ID); msg->WriteFlipped(static_cast<u16>(sizeof msg->buffer)); msg->Write(vendor->serial_ext); msg->Write(static_cast<u8>(PKTBI_3B::STATUS_NOTHING_BOUGHT)); ADDTOSENDQUEUE(client,&msg->buffer, msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } @@ -569,7 +569,7 @@ bool send_vendorsell( Client* client, NPC* merchant, UContainer* sellfrom, bool send_aos_tooltip ) { unsigned short num_items = 0; - PktOut_9E* msg = REQUESTPACKET(PktOut_9E,PKTOUT_9E_ID); + PktOut_9E* msg = PktHelper::RequestPacket<PktOut_9E>(PKTOUT_9E_ID); msg->offset+=2; msg->Write(merchant->serial_ext); msg->offset+=2; //numitems @@ -595,7 +595,7 @@ string desc = item->merchant_description(); if (msg->offset + desc.size()+14 > sizeof msg->buffer) { - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return false; } msg->Write(item->serial_ext); @@ -620,7 +620,7 @@ msg->WriteFlipped(num_items); transmit( client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return true; } @@ -892,7 +892,7 @@ BObjectImp* UOExecutorModule::internal_SendUnCompressedGumpMenu(Character* chr, ObjArray* layout_arr, ObjArray* data_arr, int x,int y) { - PktOut_B0* msg = REQUESTPACKET(PktOut_B0,PKTOUT_B0_ID); + PktOut_B0* msg = PktHelper::RequestPacket<PktOut_B0>(PKTOUT_B0_ID); msg->offset+=2; msg->Write(chr->serial_ext); msg->WriteFlipped(this->uoexec.os_module->pid()); @@ -913,7 +913,7 @@ layoutlen += addlen; if (msg->offset+addlen > static_cast<int>(sizeof msg->buffer)) { - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BError( "Buffer length exceeded" ); } msg->Write("{ ",2,false); @@ -923,7 +923,7 @@ if (msg->offset+1 > static_cast<int>(sizeof msg->buffer)) { - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BError( "Buffer length exceeded" ); } msg->offset++; // nullterm @@ -938,7 +938,7 @@ if (msg->offset+2 > static_cast<int>(sizeof msg->buffer)) { - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BError( "Buffer length exceeded" ); } msg->offset+=2; //numlines @@ -958,7 +958,7 @@ if (msg->offset+2+textlen*2 > static_cast<int>(sizeof msg->buffer)) { - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BError( "Buffer length exceeded" ); } @@ -970,7 +970,7 @@ if (msg->offset+1 > static_cast<int>(sizeof msg->buffer)) { - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BError( "Buffer length exceeded" ); } msg->offset++; // nullterm @@ -982,7 +982,7 @@ msg->WriteFlipped(len); ADDTOSENDQUEUE(chr->client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); chr->client->gd->add_gumpmod( this ); //old_gump_uoemod = this; gump_chr = chr; @@ -992,8 +992,8 @@ BObjectImp* UOExecutorModule::internal_SendCompressedGumpMenu(Character* chr, ObjArray* layout_arr, ObjArray* data_arr, int x,int y) { - PktOut_DD* msg = REQUESTPACKET(PktOut_DD,PKTOUT_DD_ID); - PktOut_DD* bfr = REQUESTPACKET(PktOut_DD,PKTOUT_DD_ID); // compress buffer + PktOut_DD* msg = PktHelper::RequestPacket<PktOut_DD>(PKTOUT_DD_ID); + PktOut_DD* bfr = PktHelper::RequestPacket<PktOut_DD>(PKTOUT_DD_ID); // compress buffer bfr->offset=0; msg->offset+=2; msg->Write(chr->serial_ext); @@ -1015,8 +1015,8 @@ int addlen = 4 + s.length(); if (layoutdlen + addlen > static_cast<int>(sizeof bfr->buffer)) { - READDPACKET(msg); - READDPACKET(bfr); + PktHelper::ReAddPacket(msg); + PktHelper::ReAddPacket(bfr); return new BError( "Buffer length exceeded" ); } layoutdlen += addlen; @@ -1026,8 +1026,8 @@ } if (layoutdlen+1 > static_cast<int>(sizeof bfr->buffer)) { - READDPACKET(msg); - READDPACKET(bfr); + PktHelper::ReAddPacket(msg); + PktHelper::ReAddPacket(bfr); return new BError( "Buffer length exceeded" ); } layoutdlen++; @@ -1036,15 +1036,15 @@ unsigned long cbuflen = (((unsigned long)(( (float)(layoutdlen) )*1.001f)) +12);//as per zlib spec if (cbuflen > ((unsigned long)(0xFFFF-msg->offset))) { - READDPACKET(msg); - READDPACKET(bfr); + PktHelper::ReAddPacket(msg); + PktHelper::ReAddPacket(bfr); return new BError( "Compression error" ); } if (compress2(reinterpret_cast<unsigned char*>(msg->getBuffer()), &cbuflen, reinterpret_cast<unsigned char*>(&bfr->buffer), layoutdlen, Z_DEFAULT_COMPRESSION)!=Z_OK) { - READDPACKET(msg); - READDPACKET(bfr); + PktHelper::ReAddPacket(msg); + PktHelper::ReAddPacket(bfr); return new BError( "Compression error" ); } msg->offset-=8; @@ -1070,8 +1070,8 @@ int addlen = (s.length()+1)*2; if (datadlen + addlen > static_cast<int>(sizeof bfr->buffer)) { - READDPACKET(msg); - READDPACKET(bfr); + PktHelper::ReAddPacket(msg); + PktHelper::ReAddPacket(bfr); return new BError( "Buffer length exceeded" ); } datadlen+=addlen; @@ -1087,14 +1087,14 @@ cbuflen = (((unsigned long)(( (float)(datadlen) )*1.001f)) +12);//as per zlib spec if (cbuflen > ((unsigned long)(0xFFFF-msg->offset))) { - READDPACKET(msg); - READDPACKET(bfr); + PktHelper::ReAddPacket(msg); + PktHelper::ReAddPacket(bfr); return new BError( "Compression error" ); } if (compress2(reinterpret_cast<unsigned char*>(msg->getBuffer()), &cbuflen, reinterpret_cast<unsigned char*>(&bfr->buffer), datadlen,Z_DEFAULT_COMPRESSION)!=Z_OK) { - READDPACKET(msg); - READDPACKET(bfr); + PktHelper::ReAddPacket(msg); + PktHelper::ReAddPacket(bfr); return new BError( "Compression error" ); } @@ -1110,8 +1110,8 @@ msg->WriteFlipped(len); ADDTOSENDQUEUE(chr->client, &msg->buffer, len ); - READDPACKET(msg); - READDPACKET(bfr); + PktHelper::ReAddPacket(msg); + PktHelper::ReAddPacket(bfr); chr->client->gd->add_gumpmod( this ); //old_gump_uoemod = this; gump_chr = chr; @@ -1252,14 +1252,14 @@ return new BError( "Couldnt find script" ); } - PktOut_BF_Sub4* msg = REQUESTSUBPACKET(PktOut_BF_Sub4,PKTBI_BF_ID,PKTBI_BF::TYPE_CLOSE_GUMP); + PktOut_BF_Sub4* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub4>(PKTBI_BF_ID, PKTBI_BF::TYPE_CLOSE_GUMP); msg->WriteFlipped(static_cast<u16>(13)); msg->offset+=2; msg->WriteFlipped(pid); msg->offset+=4; //buttonid ADDTOSENDQUEUE(client,&msg->buffer, msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); uoemod->uoexec.ValueStack.top().set( new BObject(resp) ); clear_gumphandler( client, uoemod ); @@ -1292,14 +1292,14 @@ else return new BError( "Invalid type" ); - PktOut_BF_Sub16* msg = REQUESTSUBPACKET(PktOut_BF_Sub16,PKTBI_BF_ID,PKTBI_BF::TYPE_CLOSE_WINDOW); + PktOut_BF_Sub16* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub16>(PKTBI_BF_ID, PKTBI_BF::TYPE_CLOSE_WINDOW); msg->WriteFlipped(static_cast<u16>(13)); msg->offset+=2; //sub msg->WriteFlipped(type); msg->Write(obj->serial_ext); ADDTOSENDQUEUE(chr->client,&msg->buffer, msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BLong( 1 ); } @@ -1439,7 +1439,7 @@ return new BError( "No client attached" ); } - PktOut_AB* msg = REQUESTPACKET(PktOut_AB,PKTOUT_AB_ID); + PktOut_AB* msg = PktHelper::RequestPacket<PktOut_AB>(PKTOUT_AB_ID); msg->offset+=2; msg->Write(chr->serial_ext); msg->offset+=2; // u8 type,index @@ -1463,7 +1463,7 @@ msg->WriteFlipped(len); ADDTOSENDQUEUE(chr->client,&msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); chr->client->gd->textentry_uoemod = this; textentry_chr = chr; uoexec.os_module->suspend(); @@ -1946,11 +1946,11 @@ if (chr->client->gd->resurrect_uoemod != NULL) return new BError( "Client busy with another instares dialog" ); - PktOut_20* msg = REQUESTPACKET(PktOut_20,PKTBI_2C_ID); + PktOut_20* msg = PktHelper::RequestPacket<PktOut_20>(PKTBI_2C_ID); msg->Write(static_cast<u8>(RESURRECT_CHOICE_SELECT)); ADDTOSENDQUEUE(chr->client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); chr->client->gd->resurrect_uoemod = this; resurrect_chr = chr; uoexec.os_module->suspend(); @@ -2006,13 +2006,13 @@ if (chr->client->gd->resurrect_uoemod != NULL) return new BError( "Client is already selecting a color" ); - PktOut_95* msg = REQUESTPACKET(PktOut_95,PKTBI_95_ID); + PktOut_95* msg = PktHelper::RequestPacket<PktOut_95>(PKTBI_95_ID); msg->Write(item->serial_ext); msg->offset+=2; // u16 unk msg->WriteFlipped(item->graphic); ADDTOSENDQUEUE(chr->client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); chr->client->gd->selcolor_uoemod = this; selcolor_chr = chr; @@ -2065,7 +2065,7 @@ } } - PktOut_93* msg93 = REQUESTPACKET(PktOut_93,PKTBI_93_ID); + PktOut_93* msg93 = PktHelper::RequestPacket<PktOut_93>(PKTBI_93_ID); msg93->Write(book->serial_ext); msg93->Write(static_cast<u8>(writable?1:0)); msg93->Write(static_cast<u8>(1)); @@ -2074,11 +2074,11 @@ msg93->Write(author.c_str(),30,false); ADDTOSENDQUEUE(chr->client, &msg93->buffer, msg93->offset ); - READDPACKET(msg93); + PktHelper::ReAddPacket(msg93); if (writable) { - PktOut_66* msg = REQUESTPACKET(PktOut_66,PKTBI_66_ID); + PktOut_66* msg = PktHelper::RequestPacket<PktOut_66>(PKTBI_66_ID); msg->offset+=2; msg->Write(book->serial_ext); msg->WriteFlipped(static_cast<u16>(npages)); @@ -2090,7 +2090,7 @@ { if (msg->offset+4> static_cast<int>(sizeof msg->buffer)) { - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BError( "Buffer overflow" ); } msg->WriteFlipped(static_cast<u16>(page)); @@ -2106,7 +2106,7 @@ linetext = line_imp->getStringRep(); if (msg->offset+linetext.size()+1 > sizeof msg->buffer) { - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BError( "Buffer overflow" ); } msg->Write(linetext.c_str(),static_cast<u16>(linetext.size()+1)); @@ -2150,7 +2150,7 @@ msg->offset=1; msg->WriteFlipped(len); ADDTOSENDQUEUE(chr->client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } return new BLong(1); @@ -2182,7 +2182,7 @@ return; } - PktOut_66* msgOut = REQUESTPACKET(PktOut_66,PKTBI_66_ID); + PktOut_66* msgOut = PktHelper::RequestPacket<PktOut_66>(PKTBI_66_ID); msgOut->offset+=2; msgOut->Write(book->serial_ext); msgOut->WriteFlipped(static_cast<u16>(1)); @@ -2205,7 +2205,7 @@ if (msgOut->offset+linetext.size()+1 > sizeof msgOut->buffer) { - READDPACKET(msgOut); + PktHelper::ReAddPacket(msgOut); return; } msgOut->Write(linetext.c_str(),static_cast<u16>(linetext.size()+1)); @@ -2217,7 +2217,7 @@ msgOut->offset=1; msgOut->WriteFlipped(len); ADDTOSENDQUEUE(client, &msgOut->buffer, len ); - READDPACKET(msgOut); + PktHelper::ReAddPacket(msgOut); } else { @@ -2331,7 +2331,7 @@ chr->client->gd->custom_house_serial = house->serial; - PktOut_BF_Sub20* msg = REQUESTSUBPACKET(PktOut_BF_Sub20,PKTBI_BF_ID,PKTBI_BF::TYPE_ACTIVATE_CUSTOM_HOUSE_TOOL); + PktOut_BF_Sub20* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub20>(PKTBI_BF_ID, PKTBI_BF::TYPE_ACTIVATE_CUSTOM_HOUSE_TOOL); msg->WriteFlipped(static_cast<u16>(17)); msg->offset+=2; //sub msg->Write(house->serial_ext); @@ -2340,7 +2340,7 @@ msg->Write(static_cast<u32>(0xFFFFFFFF)); // fixme msg->Write(static_cast<u8>(0xFF)); // fixme ADDTOSENDQUEUE(chr->client,&msg->buffer,msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); move_character_to(chr,house->x,house->y,house->z+7,MOVEITEM_FORCELOCATION, NULL); //chr->set_script_member("hidden",1); @@ -2381,13 +2381,13 @@ Character* chr; if (getCharacterParam( exec, 0, chr )) { - PktOut_BF_Sub2A* msg = REQUESTSUBPACKET(PktOut_BF_Sub2A,PKTBI_BF_ID,PKTBI_BF::TYPE_CHARACTER_RACE_CHANGER); + PktOut_BF_Sub2A* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub2A>(PKTBI_BF_ID, PKTBI_BF::TYPE_CHARACTER_RACE_CHANGER); msg->WriteFlipped(static_cast<u16>(7)); msg->offset+=2; //sub msg->Write(static_cast<u8>(chr->gender)); msg->Write(static_cast<u8>(chr->race+1)); ADDTOSENDQUEUE(chr->client,&msg->buffer,msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); return new BLong(1); } Modified: trunk/pol-core/pol/movement.cpp =================================================================== --- trunk/pol-core/pol/movement.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/movement.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -109,7 +109,7 @@ { Character* chr = client->chr; unsigned short wxL, wyL, wxH, wyH; - PktOut_1D* msgremove = REQUESTPACKET(PktOut_1D,PKTOUT_1D_ID); + PktOut_1D* msgremove = PktHelper::RequestPacket<PktOut_1D>(PKTOUT_1D_ID); zone_convert_clip( chr->x - RANGE_VISUAL_LARGE_BUILDINGS, chr->y - RANGE_VISUAL_LARGE_BUILDINGS, chr->realm, wxL, wyL ); zone_convert_clip( chr->x + RANGE_VISUAL_LARGE_BUILDINGS, chr->y + RANGE_VISUAL_LARGE_BUILDINGS, chr->realm, wxH, wyH ); for( unsigned short wx = wxL; wx <= wxH; ++wx ) @@ -147,7 +147,7 @@ } } } - READDPACKET(msgremove); + PktHelper::ReAddPacket(msgremove); } void cancel_trade( Character* chr1 ); @@ -159,14 +159,14 @@ { //drop pkt if last request was denied, should fix the "client hopping" - /*PktOut_21* msg = REQUESTPACKET(PktOut_21,PKTOUT_21_ID); + /*PktOut_21* msg = PktHelper::RequestPacket<PktOut_21>(PKTOUT_21_ID); msg->Write(msg02->movenum); msg->WriteFlipped(chr->x); msg->WriteFlipped(chr->y); msg->Write(chr->facing); msg->Write(chr->z); client->transmit( &msg->buffer, msg->offset ); - READDPACKET(msg);*/ + PktHelper::ReAddPacket(msg);*/ return; } @@ -189,11 +189,11 @@ } } client->pause(); - PktOut_22* msg = REQUESTPACKET(PktOut_22,PKTBI_22_APPROVED_ID); + PktOut_22* msg = PktHelper::RequestPacket<PktOut_22>(PKTBI_22_APPROVED_ID); msg->Write(msg02->movenum); msg->Write(client->chr->hilite_color_idx( client->chr )); ADDTOSENDQUEUE(client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); client->movementsequence = msg02->movenum; if (client->movementsequence == 255) @@ -222,14 +222,14 @@ } else { - PktOut_21* msg = REQUESTPACKET(PktOut_21,PKTOUT_21_ID); + PktOut_21* msg = PktHelper::RequestPacket<PktOut_21>(PKTOUT_21_ID); msg->Write(msg02->movenum); msg->WriteFlipped(chr->x); msg->WriteFlipped(chr->y); msg->Write(chr->facing); msg->Write(chr->z); ADDTOSENDQUEUE(client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); client->movementsequence = 0; } Modified: trunk/pol-core/pol/multi/boat.cpp =================================================================== --- trunk/pol-core/pol/multi/boat.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/multi/boat.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -278,7 +278,7 @@ void send_boat_to_inrange( const UBoat* item, u16 oldx, u16 oldy ) { - PktOut_1A* msg = REQUESTPACKET(PktOut_1A,PKTOUT_1A_ID); + PktOut_1A* msg = PktHelper::RequestPacket<PktOut_1A>(PKTOUT_1A_ID); msg->offset+=2; u16 graphic=item->multidef().multiid | 0x4000; msg->Write(item->serial_ext); @@ -291,7 +291,7 @@ msg->WriteFlipped(len1A); // Client >= 7.0.0.0 ( SA ) - PktOut_F3* msg2 = REQUESTPACKET(PktOut_F3,PKTOUT_F3_ID); + PktOut_F3* msg2 = PktHelper::RequestPacket<PktOut_F3>(PKTOUT_F3_ID); msg2->WriteFlipped(static_cast<u16>(0x1)); msg2->Write(static_cast<u8>(0x02)); msg2->Write(item->serial_ext); @@ -307,11 +307,11 @@ msg2->offset++; // u8 flags // Client >= 7.0.9.0 ( HSA ) - PktOut_F3* msg3 = REQUESTPACKET(PktOut_F3,PKTOUT_F3_ID); + PktOut_F3* msg3 = PktHelper::RequestPacket<PktOut_F3>(PKTOUT_F3_ID); memcpy( &msg3->buffer, &msg2->buffer, sizeof msg3->buffer ); msg3->offset=26; //unk short at the end - PktOut_1D* msgremove = REQUESTPACKET(PktOut_1D,PKTOUT_1D_ID); + PktOut_1D* msgremove = PktHelper::RequestPacket<PktOut_1D>(PKTOUT_1D_ID); msgremove->Write(item->serial_ext); for( Clients::iterator itr = clients.begin(), end = clients.end(); itr != end; ++itr ) @@ -338,10 +338,10 @@ ADDTOSENDQUEUE(client, &msgremove->buffer, msgremove->offset ); } } - READDPACKET(msg); - READDPACKET(msg2); - READDPACKET(msg3); - READDPACKET(msgremove); + PktHelper::ReAddPacket(msg); + PktHelper::ReAddPacket(msg2); + PktHelper::ReAddPacket(msg3); + PktHelper::ReAddPacket(msgremove); } void unpause_paused() Modified: trunk/pol-core/pol/multi/customhouses.cpp =================================================================== --- trunk/pol-core/pol/multi/customhouses.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/multi/customhouses.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -589,7 +589,7 @@ void CustomHouseStopEditing(Character* chr, UHouse* house) { - PktOut_BF_Sub20* msg = REQUESTSUBPACKET(PktOut_BF_Sub20,PKTBI_BF_ID,PKTBI_BF::TYPE_ACTIVATE_CUSTOM_HOUSE_TOOL); + PktOut_BF_Sub20* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub20>(PKTBI_BF_ID, PKTBI_BF::TYPE_ACTIVATE_CUSTOM_HOUSE_TOOL); msg->WriteFlipped(static_cast<u16>(17)); msg->offset+=2; //sub msg->Write(house->serial_ext); @@ -598,7 +598,7 @@ msg->Write(static_cast<u32>(0xFFFFFFFF)); // fixme msg->Write(static_cast<u8>(0xFF)); // fixme ADDTOSENDQUEUE(chr->client,&msg->buffer,msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); const MultiDef& def = house->multidef(); move_character_to(chr,house->x+def.minrx,house->y+def.maxry+1,house->z,MOVEITEM_FORCELOCATION, NULL); @@ -1011,13 +1011,13 @@ void CustomHousesSendShort(UHouse* house, Client* client) { - PktOut_BF_Sub1D* msg = REQUESTSUBPACKET(PktOut_BF_Sub1D,PKTBI_BF_ID,PKTBI_BF::TYPE_CUSTOM_HOUSE_SHORT); + PktOut_BF_Sub1D* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub1D>(PKTBI_BF_ID, PKTBI_BF::TYPE_CUSTOM_HOUSE_SHORT); msg->WriteFlipped(static_cast<u16>(13)); msg->offset+=2; msg->Write(house->serial_ext); msg->WriteFlipped(house->revision); ADDTOSENDQUEUE(client,&msg->buffer, msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void UHouse::SetCustom(bool _custom) Modified: trunk/pol-core/pol/network/cliface.cpp =================================================================== --- trunk/pol-core/pol/network/cliface.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/network/cliface.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -89,7 +89,7 @@ void send_uo_hits( Client* client, Character* me, const Vital* vital ) { - PktOut_A1* msg = REQUESTPACKET(PktOut_A1,PKTOUT_A1_ID); + PktOut_A1* msg = PktHelper::RequestPacket<PktOut_A1>(PKTOUT_A1_ID); msg->Write(me->serial_ext); int v = me->vital( vital->vitalid ).maximum_ones(); if (v > 0xFFFF) @@ -101,12 +101,12 @@ v = 0xFFFF; msg->WriteFlipped(static_cast<u16>(v)); ADDTOSENDQUEUE(client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void send_uo_mana( Client* client, Character* me, const Vital* vital ) { - PktOut_A2* msg = REQUESTPACKET(PktOut_A2,PKTOUT_A2_ID); + PktOut_A2* msg = PktHelper::RequestPacket<PktOut_A2>(PKTOUT_A2_ID); msg->Write(me->serial_ext); int v = me->vital( vital->vitalid ).maximum_ones(); if (v > 0xFFFF) @@ -118,7 +118,7 @@ v = 0xFFFF; msg->WriteFlipped(static_cast<u16>(v)); ADDTOSENDQUEUE(client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); if (me->party() != NULL) me->party()->on_mana_changed(me); @@ -126,7 +126,7 @@ void send_uo_stamina( Client* client, Character* me, const Vital* vital ) { - PktOut_A3* msg = REQUESTPACKET(PktOut_A3,PKTOUT_A3_ID); + PktOut_A3* msg = PktHelper::RequestPacket<PktOut_A3>(PKTOUT_A3_ID); msg->Write(me->serial_ext); int v = me->vital( vital->vitalid ).maximum_ones(); if (v > 0xFFFF) @@ -138,7 +138,7 @@ v = 0xFFFF; msg->WriteFlipped(static_cast<u16>(v)); ADDTOSENDQUEUE(client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); if (me->party()!=NULL) me->party()->on_stam_changed(me); @@ -159,7 +159,7 @@ { ClientAttributeUpdaters& cau = client->Interface.attribute_updaters[ attr->attrid ]; - PktOut_3A* msg = REQUESTPACKET(PktOut_3A,PKTBI_3A_ID); + PktOut_3A* msg = PktHelper::RequestPacket<PktOut_3A>(PKTBI_3A_ID); msg->offset+=2; if (!ssopt.core_sends_caps) msg->Write(static_cast<u8>(PKTBI_3A_VALUES::SINGLE_SKILL)); @@ -176,7 +176,7 @@ msg->offset=1; msg->WriteFlipped(len); ADDTOSENDQUEUE(client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void ClientInterface::Initialize() { Modified: trunk/pol-core/pol/network/packets.h =================================================================== --- trunk/pol-core/pol/network/packets.h 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/network/packets.h 2011-12-17 12:05:57 UTC (rev 424) @@ -305,9 +305,6 @@ Packets::instance()->ReAddPacket(msg); } } -#define REQUESTPACKET(_pkt,_id) static_cast<_pkt*>(Packets::instance()->getPacket(_id)) -#define REQUESTSUBPACKET(_pkt,_id,_sub) static_cast<_pkt*>(Packets::instance()->getPacket(_id,_sub)) -#define READDPACKET(_msg) Packets::instance()->ReAddPacket(_msg) // buffer for encrypted Data send with a dummy pktid // NOTE: redefine id if pkt 0x0 ever gets send Modified: trunk/pol-core/pol/party.cpp =================================================================== --- trunk/pol-core/pol/party.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/party.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -390,7 +390,7 @@ void Party::send_member_list(Character* to_chr) { - PktOut_BF_Sub6* msg = REQUESTSUBPACKET(PktOut_BF_Sub6,PKTBI_BF_ID,PKTBI_BF::TYPE_PARTY_SYSTEM); + PktOut_BF_Sub6* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub6>(PKTBI_BF_ID, PKTBI_BF::TYPE_PARTY_SYSTEM); msg->offset+=4; //len+sub msg->Write(static_cast<u8>(PKTBI_BF_06::PARTYCMD_ADD)); msg->offset++; //nummembers @@ -426,7 +426,7 @@ } else ADDTOSENDQUEUE(to_chr->client,&msg->buffer,len); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void Party::disband() @@ -475,7 +475,7 @@ } else { - PktOut_BF_Sub6* msg = REQUESTSUBPACKET(PktOut_BF_Sub6,PKTBI_BF_ID,PKTBI_BF::TYPE_PARTY_SYSTEM); + PktOut_BF_Sub6* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub6>(PKTBI_BF_ID, PKTBI_BF::TYPE_PARTY_SYSTEM); msg->offset+=4; //len+sub msg->Write(static_cast<u8>(PKTBI_BF_06::PARTYCMD_REMOVE)); msg->offset++; // nummembers @@ -508,7 +508,7 @@ ADDTOSENDQUEUE(chr->client,&msg->buffer,len); } } - READDPACKET(msg); + PktHelper::ReAddPacket(msg); send_msg_to_all(CLP_Player_Removed);//A player has been removed from your party. if (!test_size()) { @@ -520,8 +520,8 @@ void Party::send_msg_to_all(unsigned int clilocnr, const char* affix, Character* exeptchr) { - PktOut_C1* msgc1 = REQUESTPACKET(PktOut_C1,PKTOUT_C1_ID); - PktOut_CC* msgcc = REQUESTPACKET(PktOut_CC,PKTOUT_CC_ID); + PktOut_C1* msgc1 = PktHelper::RequestPacket<PktOut_C1>(PKTOUT_C1_ID); + PktOut_CC* msgcc = PktHelper::RequestPacket<PktOut_CC>(PKTOUT_CC_ID); if (affix!=NULL) build_sysmessage_cl_affix(msgcc, clilocnr, affix, true ); else @@ -544,8 +544,8 @@ } } } - READDPACKET(msgc1); - READDPACKET(msgcc); + PktHelper::ReAddPacket(msgc1); + PktHelper::ReAddPacket(msgcc); } void Party::send_stat_to(Character* chr,Character* bob) @@ -586,7 +586,7 @@ void Party::on_mana_changed(Character* chr) { - PktOut_A2* msg = REQUESTPACKET(PktOut_A2,PKTOUT_A2_ID); + PktOut_A2* msg = PktHelper::RequestPacket<PktOut_A2>(PKTOUT_A2_ID); msg->Write(chr->serial_ext); int h, mh; @@ -611,11 +611,11 @@ } } } - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void Party::on_stam_changed(Character* chr) { - PktOut_A3* msg = REQUESTPACKET(PktOut_A3,PKTOUT_A3_ID); + PktOut_A3* msg = PktHelper::RequestPacket<PktOut_A3>(PKTOUT_A3_ID); msg->Write(chr->serial_ext); int h, mh; @@ -640,12 +640,12 @@ } } } - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void Party::send_member_msg_public(Character* chr,u16* wtext, size_t wtextlen) { - PktOut_BF_Sub6* msg = REQUESTSUBPACKET(PktOut_BF_Sub6,PKTBI_BF_ID,PKTBI_BF::TYPE_PARTY_SYSTEM); + PktOut_BF_Sub6* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub6>(PKTBI_BF_ID, PKTBI_BF::TYPE_PARTY_SYSTEM); msg->offset+=4; //len+sub msg->Write(static_cast<u8>(PKTBI_BF_06::PARTYCMD_PARTY_MSG)); msg->Write(chr->serial_ext); @@ -686,14 +686,14 @@ ADDTOSENDQUEUE(mem->client,&msg->buffer,len); } } - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void Party::send_member_msg_private(Character* chr, Character* tochr, u16* wtext, size_t wtextlen) { if (!tochr->has_active_client()) return; - PktOut_BF_Sub6* msg = REQUESTSUBPACKET(PktOut_BF_Sub6,PKTBI_BF_ID,PKTBI_BF::TYPE_PARTY_SYSTEM); + PktOut_BF_Sub6* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub6>(PKTBI_BF_ID, PKTBI_BF::TYPE_PARTY_SYSTEM); msg->offset+=4; //len+sub msg->Write(static_cast<u8>(PKTBI_BF_06::PARTYCMD_MEMBER_MSG)); msg->Write(chr->serial_ext); @@ -731,7 +731,7 @@ msg->WriteFlipped(len); ADDTOSENDQUEUE(tochr->client,&msg->buffer,len); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void Party::printOn( ostream& os ) const @@ -762,14 +762,14 @@ { if (chr != NULL && chr->has_active_client()) { - PktOut_BF_Sub6* msg = REQUESTSUBPACKET(PktOut_BF_Sub6,PKTBI_BF_ID,PKTBI_BF::TYPE_PARTY_SYSTEM); + PktOut_BF_Sub6* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub6>(PKTBI_BF_ID, PKTBI_BF::TYPE_PARTY_SYSTEM); msg->WriteFlipped(static_cast<u16>(11)); msg->offset+=2; //sub msg->Write(static_cast<u8>(PKTBI_BF_06::PARTYCMD_REMOVE)); msg->offset++; //nummembers msg->Write(chr->serial_ext); ADDTOSENDQUEUE(chr->client,&msg->buffer,msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } } @@ -1422,13 +1422,13 @@ void send_invite(Character* member,Character* leader) { - PktOut_BF_Sub6* msg = REQUESTSUBPACKET(PktOut_BF_Sub6,PKTBI_BF_ID,PKTBI_BF::TYPE_PARTY_SYSTEM); + PktOut_BF_Sub6* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub6>(PKTBI_BF_ID, PKTBI_BF::TYPE_PARTY_SYSTEM); msg->WriteFlipped(static_cast<u16>(10)); msg->offset+=2; //sub msg->Write(static_cast<u8>(PKTBI_BF_06::PARTYCMD_INVITE_MEMBER)); msg->Write(leader->serial_ext); ADDTOSENDQUEUE(member->client,&msg->buffer,msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); // : You are invited to join the party. Type /accept to join or /decline to decline the offer. send_sysmessage_cl_affix(member->client, CLP_Invite, leader->name().c_str(),true); @@ -1437,7 +1437,7 @@ void send_attributes_normalized(Character* chr, Character* bob) { - PktOut_2D* msg = REQUESTPACKET(PktOut_2D,PKTOUT_2D_ID); + PktOut_2D* msg = PktHelper::RequestPacket<PktOut_2D>(PKTOUT_2D_ID); msg->Write(bob->serial_ext); int h, mh; @@ -1469,6 +1469,6 @@ msg->WriteFlipped(static_cast<u16>(h * 1000 / mh)); ADDTOSENDQUEUE(chr->client,&msg->buffer, msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } Modified: trunk/pol-core/pol/pol.cpp =================================================================== --- trunk/pol-core/pol/pol.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/pol.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -252,7 +252,7 @@ void send_startup( Client *client ) { Character *chr = client->chr; - PktOut_1B* msg = REQUESTPACKET(PktOut_1B,PKTOUT_1B_ID); + PktOut_1B* msg = PktHelper::RequestPacket<PktOut_1B>(PKTOUT_1B_ID); msg->Write(chr->serial_ext); msg->offset+=4; //u8 unk5, unk6, unk7, unk8 msg->WriteFlipped(chr->graphic); @@ -269,7 +269,7 @@ msg->WriteFlipped(client->chr->realm->height()); msg->offset+=6; // u8 unk31, unk32, unk33, unk34, unk35, unk36 transmit( client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } /* @@ -868,7 +868,7 @@ { printf( "UOKR Seed Message Received: Type 0x%X\n", cstype ); } - PktOut_E3* msg = REQUESTPACKET(PktOut_E3,PKTOUT_E3_ID); + PktOut_E3* msg = PktHelper::RequestPacket<PktOut_E3>(PKTOUT_E3_ID); msg->WriteFlipped(static_cast<u16>(77)); msg->WriteFlipped(static_cast<u32>(0x03)); msg->Write(static_cast<u8>(0x02)); msg->Write(static_cast<u8>(0x01)); msg->Write(static_cast<u8>(0x03)); @@ -898,7 +898,7 @@ client->recv_state = Client::RECV_STATE_MSGTYPE_WAIT; client->setClientType(CLIENTTYPE_UOKR); // UO:KR logging in ADDTOSENDQUEUE(client, &msg->buffer, msg->offset ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } else if (client->buffer[0] == PKTIN_EF_ID) // new seed since 6.0.5.0 (0xef should never appear in normal ipseed) { @@ -1051,12 +1051,12 @@ { CLIENT_CHECKPOINT(4); PolLock lck; //multithread - PktOut_53* msg = REQUESTPACKET(PktOut_53,PKTOUT_53_ID); + PktOut_53* msg = PktHelper::RequestPacket<PktOut_53>(PKTOUT_53_ID); msg->Write(static_cast<u8>(PKTOUT_53_WARN_CHARACTER_IDLE)); CLIENT_CHECKPOINT(5); ADDTOSENDQUEUE(client, &msg->buffer, msg->offset ); CLIENT_CHECKPOINT(18); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); if (client->pause_count) client->restart2(); } Modified: trunk/pol-core/pol/speech.cpp =================================================================== --- trunk/pol-core/pol/speech.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/speech.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -110,7 +110,7 @@ if (textlen > SPEECH_MAX_LEN+1) textlen = SPEECH_MAX_LEN+1; - PktOut_1C* talkmsg = REQUESTPACKET(PktOut_1C,PKTOUT_1C_ID); + PktOut_1C* talkmsg = PktHelper::RequestPacket<PktOut_1C>(PKTOUT_1C_ID); talkmsg->offset+=2; talkmsg->Write(client->chr->serial_ext); talkmsg->WriteFlipped(client->chr->graphic); @@ -124,7 +124,7 @@ talkmsg->WriteFlipped(len); transmit( client, &talkmsg->buffer, len ); - PktOut_1C* ghostmsg = REQUESTPACKET(PktOut_1C,PKTOUT_1C_ID); + PktOut_1C* ghostmsg = PktHelper::RequestPacket<PktOut_1C>(PKTOUT_1C_ID); if (client->chr->dead() && !client->chr->can_be_heard_as_ghost()) { memcpy( &ghostmsg->buffer, &talkmsg->buffer, sizeof ghostmsg->buffer ); @@ -183,8 +183,8 @@ sayto_listening_points( client->chr, textbuf, textbuflen, type ); - READDPACKET(talkmsg); - READDPACKET(ghostmsg); + PktHelper::ReAddPacket(talkmsg); + PktHelper::ReAddPacket(ghostmsg); } @@ -266,8 +266,8 @@ textcol = 1001; } - PktOut_AE* ghostmsg = REQUESTPACKET(PktOut_AE,PKTOUT_AE_ID); - PktOut_AE* talkmsg = REQUESTPACKET(PktOut_AE,PKTOUT_AE_ID); + PktOut_AE* ghostmsg = PktHelper::RequestPacket<PktOut_AE>(PKTOUT_AE_ID); + PktOut_AE* talkmsg = PktHelper::RequestPacket<PktOut_AE>(PKTOUT_AE_ID); talkmsg->offset+=2; talkmsg->Write(client->chr->serial_ext); talkmsg->WriteFlipped(client->chr->graphic); @@ -334,8 +334,8 @@ } } } - READDPACKET(talkmsg); - READDPACKET(ghostmsg); + PktHelper::ReAddPacket(talkmsg); + PktHelper::ReAddPacket(ghostmsg); if (!client->chr->dead()) for_nearby_npcs( pc_spoke, client->chr, ntext, ntextlen, msgin->type, Modified: trunk/pol-core/pol/spelbook.cpp =================================================================== --- trunk/pol-core/pol/spelbook.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/spelbook.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -119,7 +119,7 @@ send_open_gump(client, *this); - PktOut_BF_Sub1B* msg = REQUESTSUBPACKET(PktOut_BF_Sub1B,PKTBI_BF_ID,PKTBI_BF::TYPE_NEW_SPELLBOOK); + PktOut_BF_Sub1B* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub1B>(PKTBI_BF_ID, PKTBI_BF::TYPE_NEW_SPELLBOOK); msg->WriteFlipped(static_cast<u16>(23)); msg->offset+=2; //sub msg->WriteFlipped(static_cast<u16>(1)); @@ -134,7 +134,7 @@ msg->Write(bitwise_contents,8); ADDTOSENDQUEUE(client,&msg->buffer, msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } } @@ -346,7 +346,7 @@ void send_spellbook_contents( Client *client, Spellbook& spellbook ) { - PktOut_3C* msg = REQUESTPACKET(PktOut_3C,PKTOUT_3C_ID); + PktOut_3C* msg = PktHelper::RequestPacket<PktOut_3C>(PKTOUT_3C_ID); msg->offset+=4; //msglen+count u16 count = 0; for ( u16 i = 0; i < 64; ++i ) @@ -375,5 +375,5 @@ msg->WriteFlipped(len); msg->WriteFlipped(count); ADDTOSENDQUEUE(client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } Modified: trunk/pol-core/pol/statmsg.cpp =================================================================== --- trunk/pol-core/pol/statmsg.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/statmsg.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -32,7 +32,7 @@ void send_full_statmsg( Client *client, Character *chr ) { - PktOut_11* msg = REQUESTPACKET(PktOut_11,PKTOUT_11_ID); + PktOut_11* msg = PktHelper::RequestPacket<PktOut_11>(PKTOUT_11_ID); msg->offset+=2; // msglen msg->Write(chr->serial_ext); msg->Write(chr->name().c_str(),30,false); @@ -180,7 +180,7 @@ msg->WriteFlipped(len); transmit(client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); if (ssopt.send_stat_locks) send_stat_locks(client, chr); @@ -196,7 +196,7 @@ lockbit |= chr->attribute(uoclient_general.dexterity.id).lock() << 2; lockbit |= chr->attribute(uoclient_general.intelligence.id).lock(); - PktOut_BF_Sub19* msg = REQUESTSUBPACKET(PktOut_BF_Sub19,PKTBI_BF_ID,PKTBI_BF::TYPE_EXTENDED_STATS_OUT); + PktOut_BF_Sub19* msg = PktHelper::RequestSubPacket<PktOut_BF_Sub19>(PKTBI_BF_ID, PKTBI_BF::TYPE_EXTENDED_STATS_OUT); msg->WriteFlipped(static_cast<u16>(12)); msg->offset+=2; //sub msg->Write(static_cast<u8>(0x02)); // 2D Client = 0x02, KR = 0x05 @@ -205,12 +205,12 @@ msg->Write(lockbit); ADDTOSENDQUEUE(client,&msg->buffer, msg->offset); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void send_short_statmsg( Client *client, Character *chr ) { - PktOut_11* msg = REQUESTPACKET(PktOut_11,PKTOUT_11_ID); + PktOut_11* msg = PktHelper::RequestPacket<PktOut_11>(PKTOUT_11_ID); msg->offset+=2; // msglen msg->Write(chr->serial_ext); msg->Write(chr->name().c_str(),30,false); @@ -241,12 +241,12 @@ msg->WriteFlipped(len); transmit(client, &msg->buffer, len ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } void send_update_hits_to_inrange( Character *chr ) { - PktOut_A1* msg = REQUESTPACKET(PktOut_A1,PKTOUT_A1_ID); + PktOut_A1* msg = PktHelper::RequestPacket<PktOut_A1>(PKTOUT_A1_ID); msg->Write(chr->serial_ext); if (uoclient_general.hits.any) @@ -278,5 +278,5 @@ // Exclude self... otherwise their status-window shows 1000 hp!! >_< transmit_to_others_inrange( chr, &msg->buffer, msg->offset, false, false ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); } Modified: trunk/pol-core/pol/target.cpp =================================================================== --- trunk/pol-core/pol/target.cpp 2011-12-17 09:15:28 UTC (rev 423) +++ trunk/pol-core/pol/target.cpp 2011-12-17 12:05:57 UTC (rev 424) @@ -147,13 +147,13 @@ { if (!client->chr->target_cursor_busy()) { - PktOut_6C* msg = REQUESTPACKET(PktOut_6C,PKTBI_6C_ID); + PktOut_6C* msg = PktHelper::RequestPacket<PktOut_6C>(PKTBI_6C_ID); msg->Write(static_cast<u8>(PKTBI_6C::UNK1_00)); msg->WriteFlipped(cursorid_); msg->Write(static_cast<u8>(crstype)); // rest 0 ADDTOSENDQUEUE(client, &msg->buffer, sizeof msg->buffer ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); client->chr->tcursor2 = this; return true; } @@ -355,13 +355,13 @@ { if (!client->chr->target_cursor_busy()) { - PktOut_6C* msg = REQUESTPACKET(PktOut_6C,PKTBI_6C_ID); + PktOut_6C* msg = PktHelper::RequestPacket<PktOut_6C>(PKTBI_6C_ID); msg->Write(static_cast<u8>(PKTBI_6C::UNK1_01)); msg->WriteFlipped(cursorid_); msg->Write(static_cast<u8>(PKTBI_6C::CURSOR_TYPE_NEUTRAL)); // rest 0 ADDTOSENDQUEUE(client, &msg->buffer, sizeof msg->buffer ); - READDPACKET(msg); + PktHelper::ReAddPacket(msg); client->chr->tcursor2 = this; return true; } @@ -387,7 +387,7 @@ void MultiPlacementCursor::send_placemulti( Client* client, unsigned int objtype, int flags, s16 xoffset, s16 yoffset ) { - PktOut_99* msg = REQUESTPACKET(PktOut_99,PKTBI_99_ID); + PktOut_99* msg = PktHelper::RequestPacket<PktOut_99>(PKTBI_99_ID); msg->Write(static_cast<u8>(0x1)); msg->WriteFlipped(cursorid_); msg->offset+=12; // 12x u8 unk @@ -400,7 +400,7 @@ if (client... [truncated message content] |
From: <tu...@us...> - 2012-02-18 12:39:20
|
Revision: 514 http://polserver.svn.sourceforge.net/polserver/?rev=514&view=rev Author: turley Date: 2012-02-18 12:39:13 +0000 (Sat, 18 Feb 2012) Log Message: ----------- fixed possible crash with tooltip pkt Modified Paths: -------------- trunk/pol-core/pol/network/packets.h trunk/pol-core/pol/tooltips.cpp Modified: trunk/pol-core/pol/network/packets.h =================================================================== --- trunk/pol-core/pol/network/packets.h 2012-02-18 12:20:15 UTC (rev 513) +++ trunk/pol-core/pol/network/packets.h 2012-02-18 12:39:13 UTC (rev 514) @@ -444,7 +444,7 @@ typedef PacketTemplate<PKTBI_C2_ID,21> PktOut_C2; typedef PacketTemplate<PKTOUT_C7_ID,49> PktOut_C7; typedef PacketTemplate<PKTOUT_CC_ID,49+(SPEECH_MAX_LEN+1)*2+SPEECH_MAX_LEN+1> PktOut_CC; -typedef PacketTemplate<PKTBI_D6_OUT_ID,25+(4*SPEECH_MAX_LEN)> PktOut_D6; +typedef PacketTemplate<PKTBI_D6_OUT_ID,0xFFFF> PktOut_D6; typedef PacketTemplate<PKTOUT_DC_ID,9> PktOut_DC; typedef PacketTemplate<PKTOUT_DD_ID,0xFFFF> PktOut_DD; typedef PacketTemplate<PKTOUT_E3_ID,77> PktOut_E3; Modified: trunk/pol-core/pol/tooltips.cpp =================================================================== --- trunk/pol-core/pol/tooltips.cpp 2012-02-18 12:20:15 UTC (rev 513) +++ trunk/pol-core/pol/tooltips.cpp 2012-02-18 12:39:13 UTC (rev 514) @@ -167,9 +167,15 @@ else msg->WriteFlipped(static_cast<u32>(1042971)); //1 text argument only - msg->WriteFlipped(static_cast<u16>(desc.size()*2)); + u16 textlen=desc.size(); + if ((textlen*2)>(0xFFFF - 22)) + { + textlen=0xFFFF/2 - 22; + } + msg->WriteFlipped(textlen*2); const char* string = desc.c_str(); - while (*string) //unicode + + while (*string && textlen--) //unicode msg->Write(static_cast<u16>(*string++)); msg->offset+=4; // indicates end of property list u16 len=msg->offset; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <roz...@us...> - 2013-09-21 21:33:58
|
Revision: 688 http://sourceforge.net/p/polserver/code/688 Author: rozenblit Date: 2013-09-21 21:33:54 +0000 (Sat, 21 Sep 2013) Log Message: ----------- Changed Map to also use the new lib. Missed UContainer... :D Modified Paths: -------------- trunk/pol-core/pol/containr.cpp trunk/pol-core/pol/umap.cpp trunk/pol-core/pol/umap.h Modified: trunk/pol-core/pol/containr.cpp =================================================================== --- trunk/pol-core/pol/containr.cpp 2013-09-21 21:06:30 UTC (rev 687) +++ trunk/pol-core/pol/containr.cpp 2013-09-21 21:33:54 UTC (rev 688) @@ -894,19 +894,26 @@ } } + void UContainer::printProperties( ostream& os ) const { - base::printProperties( os ); + fmt::Writer writer; + printProperties(writer); + os << writer.c_str(); +} +void UContainer::printProperties( fmt::Writer& writer ) const +{ + base::printProperties( writer ); short max_items_mod = getmember<s16>(MBR_MAX_ITEMS_MOD); short max_weight_mod = getmember<s16>(MBR_MAX_WEIGHT_MOD); s8 max_slots_mod = getmember<s8>(MBR_MAX_SLOTS_MOD); if ( max_items_mod ) - os << "\tMax_Items_mod\t" << max_items_mod << pf_endl; + writer << "\tMax_Items_mod\t" << max_items_mod << pf_endl; if ( max_weight_mod ) - os << "\tMax_Weight_mod\t" << max_weight_mod << pf_endl; + writer << "\tMax_Weight_mod\t" << max_weight_mod << pf_endl; if ( max_slots_mod ) - os << "\tMax_Slots_mod\t" << max_slots_mod << pf_endl; + writer << "\tMax_Slots_mod\t" << max_slots_mod << pf_endl; } void UContainer::readProperties( ConfigElem& elem ) Modified: trunk/pol-core/pol/umap.cpp =================================================================== --- trunk/pol-core/pol/umap.cpp 2013-09-21 21:06:30 UTC (rev 687) +++ trunk/pol-core/pol/umap.cpp 2013-09-21 21:33:54 UTC (rev 688) @@ -55,49 +55,44 @@ void Map::printProperties( std::ostream& os ) const { - base::printProperties( os ); + fmt::Writer writer; + printProperties(writer); + os << writer.c_str(); +} - os << "\txwest\t" << xwest << pf_endl; - os << "\tynorth\t" << ynorth << pf_endl; - os << "\txeast\t" << xeast << pf_endl; - os << "\tysouth\t" << ysouth << pf_endl; - os << "\tgumpwidth\t" << gumpwidth << pf_endl; - os << "\tgumpheight\t" << gumpheight << pf_endl; - os << "\tfacetid\t" << facetid << pf_endl; +void Map::printProperties( fmt::Writer& writer ) const +{ + base::printProperties( writer ); - os << "\teditable\t" << editable << pf_endl; + writer << "\txwest\t" << xwest << pf_endl; + writer << "\tynorth\t" << ynorth << pf_endl; + writer << "\txeast\t" << xeast << pf_endl; + writer << "\tysouth\t" << ysouth << pf_endl; + writer << "\tgumpwidth\t" << gumpwidth << pf_endl; + writer << "\tgumpheight\t" << gumpheight << pf_endl; + writer << "\tfacetid\t" << facetid << pf_endl; + + writer << "\teditable\t" << editable << pf_endl; - printPinPoints(os); + printPinPoints(writer); - os << pf_endl; + writer << pf_endl; } void Map::printPinPoints( std::ostream& os ) const { -/* - ObjArray* arr = new ObjArray; - PinPoints::const_iterator itr; - for( itr = pin_points.begin(); itr != pin_points.end(); itr++ ) - { - - ObjArray* struc = new ObjArray; - struc->addMember( "x", new BLong( itr->x) ); - struc->addMember( "y", new BLong( itr->y) ); - - arr->addElement( struc ); - } - arr->packonto(os); - delete arr; -*/ +} +void Map::printPinPoints( fmt::Writer& writer ) const +{ PinPoints::const_iterator itr; int i=0; - os << "\tNumPins " << pin_points.size() << pf_endl; + writer << "\tNumPins " << pin_points.size() << pf_endl; for( itr = pin_points.begin(); itr != pin_points.end(); ++itr, ++i ) { - os << "\tPin" << i << " " << itr->x << "," << itr->y << pf_endl; + writer << "\tPin" << i << " " << itr->x << "," << itr->y << pf_endl; } } Modified: trunk/pol-core/pol/umap.h =================================================================== --- trunk/pol-core/pol/umap.h 2013-09-21 21:06:30 UTC (rev 687) +++ trunk/pol-core/pol/umap.h 2013-09-21 21:33:54 UTC (rev 688) @@ -62,7 +62,9 @@ virtual BObjectImp* set_script_member_id( const int id , int value ); //id test //virtual BObjectImp* set_script_member_double( const char *membername, double value ); virtual bool script_isa( unsigned isatype ) const; + virtual void printProperties( fmt::Writer& writer ) const; virtual void printProperties( std::ostream& os ) const; + virtual void printPinPoints( fmt::Writer& writer ) const; virtual void printPinPoints( std::ostream& os ) const; virtual void readProperties( ConfigElem& elem ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2014-03-17 14:57:22
|
Revision: 777 http://sourceforge.net/p/polserver/code/777 Author: turley Date: 2014-03-17 14:57:16 +0000 (Mon, 17 Mar 2014) Log Message: ----------- Fixed missing nullptr check (client) in the cmdlevel set method Modified Paths: -------------- trunk/pol-core/pol/mobile/charactr.cpp trunk/pol-core/pol/mobile/charactr.h trunk/pol-core/pol/ufunc.cpp trunk/pol-core/pol/ufunc.h Modified: trunk/pol-core/pol/mobile/charactr.cpp =================================================================== --- trunk/pol-core/pol/mobile/charactr.cpp 2014-03-15 10:49:44 UTC (rev 776) +++ trunk/pol-core/pol/mobile/charactr.cpp 2014-03-17 14:57:16 UTC (rev 777) @@ -1921,6 +1921,12 @@ set_stealthsteps( 0 ); } + void Character::on_cmdlevel_changed() + { + send_remove_character_to_nearby_cantsee( this ); + send_create_mobile_to_nearby_cansee( this ); + } + void Character::on_facing_changed() { if ( client ) Modified: trunk/pol-core/pol/mobile/charactr.h =================================================================== --- trunk/pol-core/pol/mobile/charactr.h 2014-03-15 10:49:44 UTC (rev 776) +++ trunk/pol-core/pol/mobile/charactr.h 2014-03-17 14:57:16 UTC (rev 777) @@ -102,7 +102,6 @@ void ClientCreateChar70160( Network::Client* client, struct PKTIN_F8* msg ); void createchar2( Accounts::Account* acct, unsigned index ); void undo_get_item( Mobile::Character *chr, Items::Item *item ); - void update_nearby_visible_chars( Network::Client* client ); void write_characters( SaveContext& sc ); void write_npcs( SaveContext& sc ); } @@ -417,6 +416,7 @@ virtual void on_poison_changed(); //dave 12-24 virtual void on_hidden_changed(); virtual void on_concealed_changed(); + void on_cmdlevel_changed(); virtual void setfacing( u8 newfacing ); virtual void on_facing_changed(); void on_aos_ext_stat_changed(); @@ -1001,8 +1001,8 @@ if ( cmdlevel_ != value ) { cmdlevel_ = value; - if ( update_on_change ) - Core::update_nearby_visible_chars( client ); + if ( update_on_change ) + on_cmdlevel_changed(); } } Modified: trunk/pol-core/pol/ufunc.cpp =================================================================== --- trunk/pol-core/pol/ufunc.cpp 2014-03-15 10:49:44 UTC (rev 776) +++ trunk/pol-core/pol/ufunc.cpp 2014-03-17 14:57:16 UTC (rev 777) @@ -470,29 +470,6 @@ } ); } - void update_nearby_visible_chars( Client* client ) - { - unsigned short wxL, wyL, wxH, wyH; - PktHelper::PacketOut<PktOut_1D> msgremove; - zone_convert_clip( client->chr->x - RANGE_VISUAL, client->chr->y - RANGE_VISUAL, client->chr->realm, wxL, wyL ); - zone_convert_clip( client->chr->x + RANGE_VISUAL, client->chr->y + RANGE_VISUAL, client->chr->realm, wxH, wyH ); - for( unsigned short wx = wxL; wx <= wxH; ++wx ) - { - for( unsigned short wy = wyL; wy <= wyH; ++wy ) - { - ZoneCharacters& wchr = client->chr->realm->zone[wx][wy].characters; - for( ZoneCharacters::iterator itr = wchr.begin(), end = wchr.end(); itr != end; ++itr ) - { - Character* chr = *itr; - if ( client->chr->is_visible_to_me( chr )) - send_owncreate( client, chr ); - else - send_remove_character( client, chr, msgremove.Get() ); - } - } - } - } - void send_remove_object_if_inrange( Client *client, const Item *item ) { if ( !client->ready ) /* if a client is just connecting, don't bother him. */ Modified: trunk/pol-core/pol/ufunc.h =================================================================== --- trunk/pol-core/pol/ufunc.h 2014-03-15 10:49:44 UTC (rev 776) +++ trunk/pol-core/pol/ufunc.h 2014-03-17 14:57:16 UTC (rev 777) @@ -254,7 +254,6 @@ void move_item( Items::Item* item, UFACING facing ); void move_item( Items::Item* item, unsigned short newx, unsigned short newy, signed char newz, Plib::Realm* oldrealm ); - void update_nearby_visible_chars( Network::Client* client ); void send_char_if_newly_inrange( Mobile::Character *chr, Network::Client *client ); void send_item_if_newly_inrange( Items::Item *item, Network::Client *client ); void send_objects_newly_inrange( Network::Client* client ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2009-10-09 10:36:38
|
Revision: 105 http://polserver.svn.sourceforge.net/polserver/?rev=105&view=rev Author: turley Date: 2009-10-09 10:36:30 +0000 (Fri, 09 Oct 2009) Log Message: ----------- spellschool fixes Modified Paths: -------------- trunk/pol-core/pol/spelbook.cpp trunk/pol-core/pol/spells.cpp trunk/pol-core/pol/uoscrobj.cpp Modified: trunk/pol-core/pol/spelbook.cpp =================================================================== --- trunk/pol-core/pol/spelbook.cpp 2009-10-09 08:27:15 UTC (rev 104) +++ trunk/pol-core/pol/spelbook.cpp 2009-10-09 10:36:30 UTC (rev 105) @@ -121,14 +121,17 @@ bool Spellbook::has_spellid( unsigned long spellid ) const { - u16 spellnumber = static_cast<u16>(spellid); - u8 spellslot = spellnumber & 7; - if(spellslot == 0) spellslot = 8; + u8 spellschool = static_cast<u8>(spellid / 100); + if (spellschool == this->spell_school) + { + u16 spellnumber = static_cast<u16>(spellid % 100); + u8 spellslot = spellnumber & 7; + if(spellslot == 0) spellslot = 8; - if ( ((bitwise_contents[ (spellnumber-1) >> 3 ]) & (1 << (spellslot-1))) != 0 ) - return true; - - return false; + if ( ((bitwise_contents[ (spellnumber-1) >> 3 ]) & (1 << (spellslot-1))) != 0 ) + return true; + } + return false; } bool Spellbook::can_add( const Item& item ) const Modified: trunk/pol-core/pol/spells.cpp =================================================================== --- trunk/pol-core/pol/spells.cpp 2009-10-09 08:27:15 UTC (rev 104) +++ trunk/pol-core/pol/spells.cpp 2009-10-09 10:36:30 UTC (rev 105) @@ -69,14 +69,12 @@ bool knows_spell( Character* chr, u16 spellid ) { - u8 school = static_cast<u8>(spellid / 100); - //copied code from Character::spellbook to support multiple spellbooks in the pack Item* item = chr->wornitem( LAYER_HAND1 ); if (item != NULL && item->script_isa(POLCLASS_SPELLBOOK) ) { Spellbook* book = static_cast<Spellbook*>(item); - if(book->spell_school == school && book->has_spellid( spellid )) + if(book->has_spellid( spellid )) return true; } @@ -90,7 +88,7 @@ if(item != NULL && item->script_isa(POLCLASS_SPELLBOOK)) { const Spellbook* book = static_cast<const Spellbook*>(item); - if(book->spell_school == school && book->has_spellid( spellid )) + if(book->has_spellid( spellid )) return true; } } Modified: trunk/pol-core/pol/uoscrobj.cpp =================================================================== --- trunk/pol-core/pol/uoscrobj.cpp 2009-10-09 08:27:15 UTC (rev 104) +++ trunk/pol-core/pol/uoscrobj.cpp 2009-10-09 10:36:30 UTC (rev 105) @@ -2474,10 +2474,9 @@ return new BError( "Not enough parameters" ); if (ex.getParam(0,id)) { - if (id < 0) - return new BError( "SpellID must be >= 0" ); - u8 school = static_cast<u8>(id / 100); - if ((school == this->spell_school) && (this->has_spellid(static_cast<unsigned long>(id)))) + if (id <= 0) + return new BError( "SpellID must be >= 1" ); + if (this->has_spellid(static_cast<unsigned long>(id))) return new BLong(1); else return new BLong(0); @@ -2491,7 +2490,7 @@ ObjArray* arr = new ObjArray; for ( u16 i = 0; i < 64; ++i ) { - unsigned long id = this->spell_school + i; + unsigned long id = this->spell_school*100 + i + 1; if (this->has_spellid(id)) arr->addElement(new BLong(id)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2009-10-17 09:28:51
|
Revision: 120 http://polserver.svn.sourceforge.net/polserver/?rev=120&view=rev Author: turley Date: 2009-10-17 09:28:45 +0000 (Sat, 17 Oct 2009) Log Message: ----------- cleanup of PrivUpdater class, removed duplicate stuff Modified Paths: -------------- trunk/pol-core/pol/mobile/charactr.cpp trunk/pol-core/pol/uworld.h Modified: trunk/pol-core/pol/mobile/charactr.cpp =================================================================== --- trunk/pol-core/pol/mobile/charactr.cpp 2009-10-17 06:58:22 UTC (rev 119) +++ trunk/pol-core/pol/mobile/charactr.cpp 2009-10-17 09:28:45 UTC (rev 120) @@ -48,6 +48,7 @@ 2009/10/14 Turley: Added char.deaf() methods & char.deafened member 2009/10/17 Turley: PrivUpdater for "seehidden", "seeghosts", "seeinvisitems" and "invul" - Tomi fixed "all" priv + PrivUpdater class cleanup, removed duplicate stuff Notes @@ -250,351 +251,204 @@ { public: - static void on_change_see_hidden( Character* chr, bool enable ) - { - if ( enable ) - { - if ( chr->client) - { - if ( chr->client->ready ) - on_enable_see_hidden( chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - on_enable_see_hidden( chr ); - } - } - else - { - if ( chr->client) - { - if ( chr->client->ready ) - on_disable_see_hidden( chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - on_disable_see_hidden( chr ); - } - } - } - static void on_change_see_ghosts( Character* chr, bool enable ) - { - if ( enable ) - { - if ( chr->client) - { - if ( chr->client->ready ) - on_enable_see_ghosts( chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - on_enable_see_ghosts( chr ); - } - } - else - { - if ( chr->client) - { - if ( chr->client->ready ) - on_disable_see_ghosts( chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - on_disable_see_ghosts( chr ); - } - } - } - static void on_change_see_invis_items( Character* chr, bool enable ) - { - if ( enable ) - { - if ( chr->client && chr->client->ready ) - on_enable_see_invis_items( chr ); - } - else - { - if ( chr->client && chr->client->ready ) - on_disable_see_invis_items( chr ); - } - } - static void on_change_invul( Character* chr, bool enable ) - { - if ( enable ) - { - if ( chr->client) - { - if ( chr->client->ready ) - on_enable_invul( chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - on_enable_invul( chr ); - } - } - else - { - if ( chr->client) - { - if ( chr->client->ready ) - on_disable_invul( chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - on_disable_invul( chr ); - } - } - } + static void on_change_see_hidden( Character* chr, bool enable ) + { + if ( enable ) + { + if ( chr->client && chr->client->ready ) + on_enable_see_hidden( chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + on_enable_see_hidden( chr ); + } + else + { + if ( chr->client && chr->client->ready ) + on_disable_see_hidden( chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + on_disable_see_hidden( chr ); + } + } + static void on_change_see_ghosts( Character* chr, bool enable ) + { + if ( enable ) + { + if ( chr->client && chr->client->ready ) + on_enable_see_ghosts( chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + on_enable_see_ghosts( chr ); + } + else + { + if ( chr->client && chr->client->ready ) + on_disable_see_ghosts( chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + on_disable_see_ghosts( chr ); + } + } + static void on_change_see_invis_items( Character* chr, bool enable ) + { + if ( enable ) + { + if ( chr->client && chr->client->ready ) + on_enable_see_invis_items( chr ); + } + else + { + if ( chr->client && chr->client->ready ) + on_disable_see_invis_items( chr ); + } + } + static void on_change_invul( Character* chr, bool enable ) + { + if ( enable ) + { + if ( chr->client && chr->client->ready ) + on_enable_invul( chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + on_enable_invul( chr ); + } + else + { + if ( chr->client && chr->client->ready ) + on_disable_invul( chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + on_disable_invul( chr ); + } + } private: static void on_enable_see_hidden( Character* chr ) { if ( chr != NULL ) - { - unsigned short wxL, wyL, wxH, wyH; - zone_convert_clip( chr->x - RANGE_VISUAL, chr->y - RANGE_VISUAL, chr->realm, wxL, wyL ); - zone_convert_clip( chr->x + RANGE_VISUAL, chr->y + RANGE_VISUAL, chr->realm, wxH, wyH ); - - for( unsigned short wx = wxL; wx <= wxH; ++wx ) - { - for( unsigned short wy = wyL; wy <= wyH; ++wy ) - { - ZoneCharacters& wchr = chr->realm->zone[wx][wy].characters; - for( ZoneCharacters::iterator itr = wchr.begin(), end = wchr.end(); itr != end; ++itr ) - { - Character* in_range_chr = *itr; - if ( in_range_chr->hidden() && in_range_chr != chr ) - { - if ( chr->client ) - { - send_owncreate( chr->client, in_range_chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - NPC* npc = static_cast<NPC*>(chr); - if ( npc->can_accept_event( EVID_ENTEREDAREA ) ) - { - npc->send_event( new SourcedEvent( EVID_ENTEREDAREA, in_range_chr ) ); - } - } - } - } - } - } - } + ForEachMobileInVisualRange( chr, enable_see_hidden, chr ); } - static void on_disable_see_hidden( Character* chr ) + static void on_disable_see_hidden( Character* chr ) { if ( chr != NULL ) - { - unsigned short wxL, wyL, wxH, wyH; - zone_convert_clip( chr->x - RANGE_VISUAL, chr->y - RANGE_VISUAL, chr->realm, wxL, wyL ); - zone_convert_clip( chr->x + RANGE_VISUAL, chr->y + RANGE_VISUAL, chr->realm, wxH, wyH ); - - for( unsigned short wx = wxL; wx <= wxH; ++wx ) - { - for( unsigned short wy = wyL; wy <= wyH; ++wy ) - { - ZoneCharacters& wchr = chr->realm->zone[wx][wy].characters; - for( ZoneCharacters::iterator itr = wchr.begin(), end = wchr.end(); itr != end; ++itr ) - { - Character* in_range_chr = *itr; - if ( in_range_chr->hidden() && in_range_chr != chr ) - { - if ( chr->client ) - { - send_remove_character( chr->client, in_range_chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - NPC* npc = static_cast<NPC*>(chr); - if ( npc->can_accept_event( EVID_LEFTAREA ) ) - { - npc->send_event( new SourcedEvent( EVID_LEFTAREA, in_range_chr ) ); - } - } - } - } - } - } - } + ForEachMobileInVisualRange( chr, disable_see_hidden, chr ); } + static void enable_see_hidden( Character* in_range_chr, Character* chr ) + { + if ( in_range_chr->hidden() && in_range_chr != chr ) + { + if ( chr->client ) + send_owncreate( chr->client, in_range_chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + { + NPC* npc = static_cast<NPC*>(chr); + if ( npc->can_accept_event( EVID_ENTEREDAREA ) ) + npc->send_event( new SourcedEvent( EVID_ENTEREDAREA, in_range_chr ) ); + } + } + } + static void disable_see_hidden( Character* in_range_chr, Character* chr ) + { + if ( in_range_chr->hidden() && in_range_chr != chr ) + { + if ( chr->client ) + send_remove_character( chr->client, in_range_chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + { + NPC* npc = static_cast<NPC*>(chr); + if ( npc->can_accept_event( EVID_LEFTAREA ) ) + npc->send_event( new SourcedEvent( EVID_LEFTAREA, in_range_chr ) ); + } + } + } + static void on_enable_see_ghosts( Character* chr ) { if ( chr != NULL ) - { - unsigned short wxL, wyL, wxH, wyH; - zone_convert_clip( chr->x - RANGE_VISUAL, chr->y - RANGE_VISUAL, chr->realm, wxL, wyL ); - zone_convert_clip( chr->x + RANGE_VISUAL, chr->y + RANGE_VISUAL, chr->realm, wxH, wyH ); - - for( unsigned short wx = wxL; wx <= wxH; ++wx ) - { - for( unsigned short wy = wyL; wy <= wyH; ++wy ) - { - ZoneCharacters& wchr = chr->realm->zone[wx][wy].characters; - for( ZoneCharacters::iterator itr = wchr.begin(), end = wchr.end(); itr != end; ++itr ) - { - Character* in_range_chr = *itr; - if ( in_range_chr->dead() && in_range_chr != chr ) - { - if ( chr->client ) - { - send_owncreate( chr->client, in_range_chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - NPC* npc = static_cast<NPC*>(chr); - if ( npc->can_accept_event( EVID_ENTEREDAREA ) ) - { - npc->send_event( new SourcedEvent( EVID_ENTEREDAREA, in_range_chr ) ); - } - } - } - } - } - } - } + ForEachMobileInVisualRange( chr, enable_see_ghosts, chr ); } - static void on_disable_see_ghosts( Character* chr ) + static void on_disable_see_ghosts( Character* chr ) { if ( chr != NULL ) - { - unsigned short wxL, wyL, wxH, wyH; - zone_convert_clip( chr->x - RANGE_VISUAL, chr->y - RANGE_VISUAL, chr->realm, wxL, wyL ); - zone_convert_clip( chr->x + RANGE_VISUAL, chr->y + RANGE_VISUAL, chr->realm, wxH, wyH ); - - for( unsigned short wx = wxL; wx <= wxH; ++wx ) - { - for( unsigned short wy = wyL; wy <= wyH; ++wy ) - { - ZoneCharacters& wchr = chr->realm->zone[wx][wy].characters; - for( ZoneCharacters::iterator itr = wchr.begin(), end = wchr.end(); itr != end; ++itr ) - { - Character* in_range_chr = *itr; - if ( in_range_chr->dead() && in_range_chr != chr ) - { - if ( chr->client ) - { - send_remove_character( chr->client, in_range_chr ); - } - else if ( chr->isa( UObject::CLASS_NPC ) ) - { - NPC* npc = static_cast<NPC*>(chr); - if ( npc->can_accept_event( EVID_LEFTAREA ) ) - { - npc->send_event( new SourcedEvent( EVID_LEFTAREA, in_range_chr ) ); - } - } - } - } - } - } - } + ForEachMobileInVisualRange( chr, disable_see_ghosts, chr ); } + static void enable_see_ghosts( Character* in_range_chr, Character* chr ) + { + if ( in_range_chr->dead() && in_range_chr != chr ) + { + if ( chr->client ) + send_owncreate( chr->client, in_range_chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + { + NPC* npc = static_cast<NPC*>(chr); + if ( npc->can_accept_event( EVID_ENTEREDAREA ) ) + npc->send_event( new SourcedEvent( EVID_ENTEREDAREA, in_range_chr ) ); + } + } + } + static void disable_see_ghosts( Character* in_range_chr, Character* chr ) + { + if ( in_range_chr->dead() && in_range_chr != chr ) + { + if ( chr->client ) + send_remove_character( chr->client, in_range_chr ); + else if ( chr->isa( UObject::CLASS_NPC ) ) + { + NPC* npc = static_cast<NPC*>(chr); + if ( npc->can_accept_event( EVID_LEFTAREA ) ) + npc->send_event( new SourcedEvent( EVID_LEFTAREA, in_range_chr ) ); + } + } + } + static void on_enable_see_invis_items( Character* chr ) { if ( chr != NULL ) - { - unsigned short wxL, wyL, wxH, wyH; - zone_convert_clip( chr->x - RANGE_VISUAL, chr->y - RANGE_VISUAL, chr->realm, wxL, wyL ); - zone_convert_clip( chr->x + RANGE_VISUAL, chr->y + RANGE_VISUAL, chr->realm, wxH, wyH ); - - for( unsigned short wx = wxL; wx <= wxH; ++wx ) - { - for( unsigned short wy = wyL; wy <= wyH; ++wy ) - { - ZoneItems& witem = chr->realm->zone[wx][wy].items; - for( ZoneItems::iterator itr = witem.begin(), end = witem.end(); itr != end; ++itr ) - { - Item* item = *itr; - if ( item->invisible() ) - { - if ( chr->client ) - send_item( chr->client, item ); - } - } - } - } - } + ForEachItemInVisualRange( chr, enable_see_invis_items, chr ); } - static void on_disable_see_invis_items( Character* chr ) + static void on_disable_see_invis_items( Character* chr ) { if ( chr != NULL ) - { - unsigned short wxL, wyL, wxH, wyH; - zone_convert_clip( chr->x - RANGE_VISUAL, chr->y - RANGE_VISUAL, chr->realm, wxL, wyL ); - zone_convert_clip( chr->x + RANGE_VISUAL, chr->y + RANGE_VISUAL, chr->realm, wxH, wyH ); - - for( unsigned short wx = wxL; wx <= wxH; ++wx ) - { - for( unsigned short wy = wyL; wy <= wyH; ++wy ) - { - ZoneItems& witem = chr->realm->zone[wx][wy].items; - for( ZoneItems::iterator itr = witem.begin(), end = witem.end(); itr != end; ++itr ) - { - Item* item = *itr; - if ( item->invisible() ) - { - if ( chr->client ) - send_remove_object( chr->client, item ); - } - } - } - } - } + ForEachItemInVisualRange( chr, disable_see_invis_items, chr ); } + static void enable_see_invis_items( Item* in_range_item, Character* chr ) + { + if ( in_range_item->invisible() ) + { + if ( chr->client ) + send_item( chr->client, in_range_item ); + } + } + static void disable_see_invis_items( Item* in_range_item, Character* chr ) + { + if ( in_range_item->invisible() ) + { + if ( chr->client ) + send_remove_object( chr->client, in_range_item ); + } + } + static void on_enable_invul( Character* chr ) { if ( chr != NULL ) - { - unsigned short wxL, wyL, wxH, wyH; - zone_convert_clip( chr->x - RANGE_VISUAL, chr->y - RANGE_VISUAL, chr->realm, wxL, wyL ); - zone_convert_clip( chr->x + RANGE_VISUAL, chr->y + RANGE_VISUAL, chr->realm, wxH, wyH ); - - for( unsigned short wx = wxL; wx <= wxH; ++wx ) - { - for( unsigned short wy = wyL; wy <= wyH; ++wy ) - { - ZoneCharacters& wchr = chr->realm->zone[wx][wy].characters; - for( ZoneCharacters::iterator itr = wchr.begin(), end = wchr.end(); itr != end; ++itr ) - { - Character* in_range_chr = *itr; - if ( in_range_chr->client && in_range_chr->client->ready ) - { - if ( in_range_chr != chr && in_range_chr->is_visible_to_me( chr ) ) - send_owncreate( in_range_chr->client, chr ); - } - } - } - } - } + ForEachMobileInVisualRange( chr, enable_invul, chr ); } - static void on_disable_invul( Character* chr ) + static void on_disable_invul( Character* chr ) { if ( chr != NULL ) - { - unsigned short wxL, wyL, wxH, wyH; - zone_convert_clip( chr->x - RANGE_VISUAL, chr->y - RANGE_VISUAL, chr->realm, wxL, wyL ); - zone_convert_clip( chr->x + RANGE_VISUAL, chr->y + RANGE_VISUAL, chr->realm, wxH, wyH ); - - for( unsigned short wx = wxL; wx <= wxH; ++wx ) - { - for( unsigned short wy = wyL; wy <= wyH; ++wy ) - { - ZoneCharacters& wchr = chr->realm->zone[wx][wy].characters; - for( ZoneCharacters::iterator itr = wchr.begin(), end = wchr.end(); itr != end; ++itr ) - { - Character* in_range_chr = *itr; - if ( in_range_chr->client && in_range_chr->client->ready ) - { - if ( in_range_chr != chr && in_range_chr->is_visible_to_me( chr ) ) - send_owncreate( in_range_chr->client, chr ); - } - } - } - } - } - } + ForEachMobileInVisualRange( chr, disable_invul, chr ); + } + static void enable_invul( Character* in_range_chr, Character* chr ) + { + if ( in_range_chr->client && in_range_chr->client->ready ) + { + if ( in_range_chr != chr && in_range_chr->is_visible_to_me( chr ) ) + send_owncreate( in_range_chr->client, chr ); + } + } + static void disable_invul( Character* in_range_chr, Character* chr ) + { + if ( in_range_chr->client && in_range_chr->client->ready ) + { + if ( in_range_chr != chr && in_range_chr->is_visible_to_me( chr ) ) + send_owncreate( in_range_chr->client, chr ); + } + } }; Character::Character( u16 objtype, UOBJ_CLASS uobj_class ) : Modified: trunk/pol-core/pol/uworld.h =================================================================== --- trunk/pol-core/pol/uworld.h 2009-10-17 06:58:22 UTC (rev 119) +++ trunk/pol-core/pol/uworld.h 2009-10-17 09:28:45 UTC (rev 120) @@ -2,6 +2,7 @@ History ======= 2006/09/27 Shinigami: GCC 3.4.x fix - added "#include "charactr.h" because of ForEachMobileInVisualRange +2009/10/17 Turley: added ForEachItemInRange & ForEachItemInVisualRange Notes ======= @@ -142,4 +143,35 @@ ForEachMobileInRange( chr->x, chr->y, chr->realm, RANGE_VISUAL, f, staticdata ); } +template <class A> +void ForEachItemInRange( int x, int y, Realm* realm, unsigned range, + void (*f)(Item*, A* staticdata), A* staticdata ) +{ + unsigned short wxL, wyL, wxH, wyH; + + zone_convert_clip( x - range, y - range, realm, wxL, wyL ); + zone_convert_clip( x + range, y + range, realm, wxH, wyH ); + passert( wxL <= wxH ); + passert( wyL <= wyH ); + for( unsigned short wx = wxL; wx <= wxH; ++wx ) + { + for( unsigned short wy = wyL; wy <= wyH; ++wy ) + { + ZoneItems& wchr = realm->zone[wx][wy].items; + + for( ZoneItems::iterator itr = wchr.begin(), end = wchr.end(); itr != end; ++itr ) + { + Item* item = *itr; + (*f)(item, staticdata); + } + } + } +} +template <class A> +void ForEachItemInVisualRange( Character* chr, + void (*f)(Item*, A* staticdata), A* staticdata ) +{ + ForEachItemInRange( chr->x, chr->y, chr->realm, RANGE_VISUAL, f, staticdata ); +} + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tu...@us...> - 2009-11-19 12:44:43
|
Revision: 144 http://polserver.svn.sourceforge.net/polserver/?rev=144&view=rev Author: turley Date: 2009-11-19 12:44:37 +0000 (Thu, 19 Nov 2009) Log Message: ----------- usage of type literals Modified Paths: -------------- trunk/pol-core/pol/mobile/charactr.cpp trunk/pol-core/pol/tasks.cpp trunk/pol-core/pol/uoscrobj.cpp Modified: trunk/pol-core/pol/mobile/charactr.cpp =================================================================== --- trunk/pol-core/pol/mobile/charactr.cpp 2009-11-19 12:04:14 UTC (rev 143) +++ trunk/pol-core/pol/mobile/charactr.cpp 2009-11-19 12:44:37 UTC (rev 144) @@ -3428,7 +3428,7 @@ void Character::check_light_region_change() { - if (lightoverride_until < read_gameclock() && lightoverride_until != (gameclock_t)-1) + if (lightoverride_until < read_gameclock() && lightoverride_until != ~0Lu) { lightoverride_until = 0; lightoverride = -1; Modified: trunk/pol-core/pol/tasks.cpp =================================================================== --- trunk/pol-core/pol/tasks.cpp 2009-11-19 12:04:14 UTC (rev 143) +++ trunk/pol-core/pol/tasks.cpp 2009-11-19 12:44:37 UTC (rev 144) @@ -79,7 +79,7 @@ if (chr->lightoverride != -1) { - if (chr->lightoverride_until < now_gameclock && chr->lightoverride_until != (gameclock_t)-1) + if (chr->lightoverride_until < now_gameclock && chr->lightoverride_until != ~0Lu) { chr->lightoverride = -1; chr->lightoverride_until = 0; Modified: trunk/pol-core/pol/uoscrobj.cpp =================================================================== --- trunk/pol-core/pol/uoscrobj.cpp 2009-11-19 12:04:14 UTC (rev 143) +++ trunk/pol-core/pol/uoscrobj.cpp 2009-11-19 12:44:37 UTC (rev 144) @@ -1760,7 +1760,7 @@ lightoverride = level; if (duration == -1) - lightoverride_until = (gameclock_t)-1; + lightoverride_until = ~0Lu; else if (duration == 0) lightoverride_until = 0; else @@ -1783,7 +1783,7 @@ set_dirty(); if (duration == -1) { - squelched_until = ~0u; + squelched_until = ~0Lu; return new BLong(-1); } else if (duration == 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |