Pol  Revision:4b29d2b
packetdefs.cpp
Go to the documentation of this file.
1 
2 #include "packetdefs.h"
3 
4 #include "../../clib/rawtypes.h"
5 #include "../globals/settings.h"
6 #include "../mobile/charactr.h"
7 #include "../pktdef.h"
8 #include "../uobject.h"
9 #include "client.h"
10 
11 namespace Pol
12 {
13 namespace Network
14 {
15 void SendWorldItem::Send( Client* client )
16 {
17  if ( client->ClientType & CLIENTTYPE_7000 )
18  {
19  if ( _p->offset == 1 )
20  buildF3();
21  if ( client->ClientType & CLIENTTYPE_7090 ) /*once known split class?*/
22  _p.Send( client, 26 );
23  else
24  _p.Send( client, 24 );
25  }
26  else
27  {
28  if ( _p_old->offset == 1 )
29  build1A();
30  _p_old.Send( client, _p_oldlen );
31  }
32 }
33 
35 {
36  if ( flags != _flags )
37  {
38  _flags = flags;
39  if ( _p_old->offset != 1 )
40  {
41  _p_old->offset = _p_oldlen - 1;
42  _p_old->Write<u8>( _flags );
43  }
44  if ( _p->offset != 1 )
45  {
46  _p->offset = 23;
47  _p->Write<u8>( _flags );
48  }
49  }
50 }
51 
53 {
54  _p_old->offset = 1;
55  // transmit item info
56  _p_old->offset += 2;
57  // If the 0x80000000 is left out, the item won't show up.
58  _p_old->WriteFlipped<u32>( 0x80000000u | _serial ); // bit 0x80000000 enables piles
59  _p_old->WriteFlipped<u16>( _graphic );
60  _p_old->WriteFlipped<u16>( _amount );
61  if ( _facing == 0 )
62  {
63  _p_old->WriteFlipped<u16>( _x );
64  // bits 0x80 and 0x40 are Dye and Move (dunno which is which)
65  _p_old->WriteFlipped<u16>( 0xC000u | _y ); // dyeable and moveable?
66  }
67  else
68  {
69  _p_old->WriteFlipped<u16>( 0x8000u | _x );
70  // bits 0x80 and 0x40 are Dye and Move (dunno which is which)
71  _p_old->WriteFlipped<u16>( 0xC000u | _y ); // dyeable and moveable?
72  _p_old->Write<u8>( _facing );
73  }
74  _p_old->Write<s8>( _z );
75  _p_old->WriteFlipped<u16>( _color );
76  _p_old->Write<u8>( _flags );
77  _p_oldlen = _p_old->offset;
78  _p_old->offset = 1;
79  _p_old->WriteFlipped<u16>( _p_oldlen );
80 }
82 {
83  _p->offset = 1;
84  _p->WriteFlipped<u16>( 0x1u );
85  _p->offset++; // datatype
86  _p->WriteFlipped<u32>( _serial );
87  _p->WriteFlipped<u16>( _graphic );
88  _p->Write<u8>( 0u );
89  _p->WriteFlipped<u16>( _amount );
90  _p->WriteFlipped<u16>( _amount );
91  _p->WriteFlipped<u16>( _x );
92  _p->WriteFlipped<u16>( _y );
93  _p->Write<s8>( _z );
94  _p->Write<u8>( _facing );
95  _p->WriteFlipped<u16>( _color );
96  _p->Write<u8>( _flags );
97 }
98 
99 SendWorldItem::SendWorldItem( u32 serial, u16 graphic, u16 amount, u16 x, u16 y, s8 z, u8 facing,
100  u16 color, u8 flags )
101  : PktSender(),
102  _p_oldlen( 0 ),
103  _serial( serial ),
104  _graphic( graphic ),
105  _amount( amount ),
106  _x( x ),
107  _y( y ),
108  _z( z ),
109  _facing( facing ),
110  _color( color ),
111  _flags( flags ),
112  _p_old(),
113  _p()
114 {
115 }
116 
117 SendWorldMulti::SendWorldMulti( u32 serial_ext, u16 graphic, u16 x, u16 y, s8 z, u16 color )
118  : PktSender(),
119  _p_oldlen( 0 ),
120  _serial_ext( serial_ext ),
121  _graphic( graphic ),
122  _x( x ),
123  _y( y ),
124  _z( z ),
125  _color( color ),
126  _p_old(),
127  _p()
128 {
129 }
130 
132 {
133  _p_old->offset = 1;
134  _p_old->offset += 2;
135  _p_old->Write<u32>( _serial_ext );
136  _p_old->WriteFlipped<u16>( _graphic | 0x4000u );
137  _p_old->WriteFlipped<u16>( _x );
138  _p_old->WriteFlipped<u16>( _y );
139  _p_old->Write<s8>( _z );
140  _p_oldlen = _p_old->offset;
141  _p_old->offset = 1;
142  _p_old->WriteFlipped<u16>( _p_oldlen );
143 }
144 
146 {
147  _p->offset = 1;
148  _p->WriteFlipped<u16>( 0x1u );
149  _p->Write<u8>( 0x02u );
150  _p->Write<u32>( _serial_ext );
151  _p->WriteFlipped<u16>( _graphic );
152  _p->Write<u8>( 0u );
153  _p->WriteFlipped<u16>( 0x1u ); // amount
154  _p->WriteFlipped<u16>( 0x1u ); // amount
155  _p->WriteFlipped<u16>( _x );
156  _p->WriteFlipped<u16>( _y );
157  _p->Write<s8>( _z );
158  _p->Write<u8>( 0u ); // facing
159  _p->WriteFlipped<u16>( _color );
160  _p->Write<u8>( 0u ); // flags
161 }
162 
164 {
165  if ( client->ClientType & CLIENTTYPE_7000 )
166  {
167  if ( _p->offset == 1 )
168  buildF3();
169  if ( client->ClientType & CLIENTTYPE_7090 ) /*once known split class?*/
170  _p.Send( client, 26 );
171  else
172  _p.Send( client, 24 );
173  }
174  else
175  {
176  if ( _p_old->offset == 1 )
177  build1A();
178  _p_old.Send( client, _p_oldlen );
179  }
180 }
181 
182 
183 AddItemContainerMsg::AddItemContainerMsg( u32 serial_ext, u16 graphic, u16 amount, u16 x, u16 y,
184  u8 slotindex, u32 containerserial_ext, u16 color )
185  : PktSender(),
186  _serial_ext( serial_ext ),
187  _graphic( graphic ),
188  _amount( amount ),
189  _x( x ),
190  _y( y ),
191  _slotindex( slotindex ),
192  _containerserial_ext( containerserial_ext ),
193  _color( color ),
194  _p_old(),
195  _p()
196 {
197 }
198 
200 {
201  _p_old->offset = 1;
202  _p_old->Write<u32>( _serial_ext );
203  _p_old->WriteFlipped<u16>( _graphic );
204  _p_old->offset++; // unk7 layer?
205  _p_old->WriteFlipped<u16>( _amount );
206  _p_old->WriteFlipped<u16>( _x );
207  _p_old->WriteFlipped<u16>( _y );
208  _p_old->Write<u32>( _containerserial_ext );
209  _p_old->WriteFlipped<u16>( _color );
210 }
212 {
213  _p->offset = 1;
214  _p->Write<u32>( _serial_ext );
215  _p->WriteFlipped<u16>( _graphic );
216  _p->offset++; // unk7 layer?
217  _p->WriteFlipped<u16>( _amount );
218  _p->WriteFlipped<u16>( _x );
219  _p->WriteFlipped<u16>( _y );
220  _p->Write<u8>( _slotindex );
221  _p->Write<u32>( _containerserial_ext );
222  _p->WriteFlipped<u16>( _color );
223 }
224 
226 {
227  if ( client->ClientType & CLIENTTYPE_6017 )
228  {
229  if ( _p->offset == 1 )
230  build();
231  _p.Send( client, _p->getSize() );
232  }
233  else
234  {
235  if ( _p_old->offset == 1 )
236  buildLegacy();
237  _p_old.Send( client, _p->getSize() - 1 );
238  }
239 }
240 
242  : PktSender(),
243  _serial_ext( serial_ext ),
244  _anim( 0 ),
245  _action( 0 ),
246  _subaction( 0 ),
247  _action_old( 0 ),
248  _framecount_old( 0 ),
249  _repeat_old( 0 ),
250  _backward_old( 0 ),
251  _repeat_flag_old( 0 ),
252  _delay_old( 0 ),
253  _oldanim_valid( false ),
254  _newanim_valid( false ),
255  _p_old(),
256  _p()
257 {
258 }
259 MobileAnimationMsg::MobileAnimationMsg( u32 serial_ext, u16 anim, u16 action, u8 subaction,
260  u16 action_old, u16 framecount_old, u16 repeat_old,
261  Core::DIRECTION_FLAG_OLD backward_old,
262  Core::REPEAT_FLAG_OLD repeat_flag_old, u8 delay_old,
263  bool oldanim_valid, bool newanim_valid )
264  : PktSender(),
265  _serial_ext( serial_ext ),
266  _anim( anim ),
267  _action( action ),
268  _subaction( subaction ),
269  _action_old( action_old ),
270  _framecount_old( framecount_old ),
271  _repeat_old( repeat_old ),
272  _backward_old( static_cast<u8>( backward_old ) ),
273  _repeat_flag_old( static_cast<u8>( repeat_flag_old ) ),
274  _delay_old( delay_old ),
275  _oldanim_valid( oldanim_valid ),
276  _newanim_valid( newanim_valid ),
277  _p_old(),
278  _p()
279 {
280 }
281 
282 void MobileAnimationMsg::update( u16 anim, u16 action, u8 subaction, u16 action_old,
283  u16 framecount_old, u16 repeat_old,
284  Core::DIRECTION_FLAG_OLD backward_old,
285  Core::REPEAT_FLAG_OLD repeat_flag_old, u8 delay_old,
286  bool oldanim_valid, bool newanim_valid )
287 {
288  _anim = anim;
289  _action = action;
290  _subaction = subaction;
291  _action_old = action_old;
292  _framecount_old = framecount_old;
293  _repeat_old = repeat_old;
294  _backward_old = static_cast<u8>( backward_old );
295  _repeat_flag_old = static_cast<u8>( repeat_flag_old );
296  _delay_old = delay_old;
297  _oldanim_valid = oldanim_valid;
298  _newanim_valid = newanim_valid;
299  if ( _oldanim_valid && _p_old->offset != 1 )
300  build6E();
301  if ( _newanim_valid && _p->offset != 1 )
302  build();
303 }
305 {
306  _p->offset = 1;
307  _p->Write<u32>( _serial_ext );
308  _p->WriteFlipped<u16>( _anim );
309  _p->WriteFlipped<u16>( _action );
310  _p->Write<u8>( _subaction );
311 }
312 
314 {
315  _p_old->offset = 1;
316  _p_old->Write<u32>( _serial_ext );
317  _p_old->WriteFlipped<u16>( _action_old );
318  _p_old->WriteFlipped<u16>( _framecount_old );
319  _p_old->WriteFlipped<u16>( _repeat_old );
320  _p_old->Write<u8>( _backward_old );
321  _p_old->Write<u8>( _repeat_flag_old );
322  _p_old->Write<u8>( _delay_old );
323 }
324 
326 {
327  if ( client->ClientType & CLIENTTYPE_7090 )
328  {
329  if ( !_newanim_valid )
330  return;
331  if ( _p->offset == 1 )
332  build();
333  _p.Send( client, _p->getSize() );
334  }
335  else
336  {
337  if ( !_oldanim_valid )
338  return;
339  if ( _p_old->offset == 1 )
340  build6E();
341  _p_old.Send( client, _p_old->getSize() );
342  }
343 }
344 
345 
346 PlaySoundPkt::PlaySoundPkt( u8 type, u16 effect, u16 xcenter, u16 ycenter, s16 zcenter )
347  : PktSender(),
348  _type( type ),
349  _effect( effect ),
350  _xcenter( xcenter ),
351  _ycenter( ycenter ),
352  _zcenter( zcenter ),
353  _p()
354 {
355 }
356 
357 void PlaySoundPkt::Send( Client* client )
358 {
359  if ( _p->offset == 1 )
360  build();
361  _p.Send( client, _p->getSize() );
362 }
363 
365 {
366  _p->offset = 1;
367  _p->Write<u8>( _type );
368  _p->WriteFlipped<u16>( _effect );
369  _p->offset += 2; // volume
370  _p->WriteFlipped<u16>( _xcenter );
371  _p->WriteFlipped<u16>( _ycenter );
372  _p->WriteFlipped<s16>( _zcenter );
373 }
374 
375 RemoveObjectPkt::RemoveObjectPkt( u32 serial_ext ) : _serial( serial_ext ), _p() {}
376 
378 {
379  _serial = serial;
380  if ( _p->offset != 1 )
381  build();
382 }
383 
385 {
386  if ( _p->offset == 1 )
387  build();
388  _p.Send( client, _p->getSize() );
389 }
390 
392 {
393  _p->offset = 1;
394  _p->Write<u32>( _serial );
395 }
396 
397 SendDamagePkt::SendDamagePkt( u32 serial_ext, u16 damage )
398  : PktSender(), _serial( serial_ext ), _damage( damage ), _p_old(), _p()
399 {
400 }
402 {
403  if ( client->ClientType & CLIENTTYPE_4070 )
404  {
405  if ( _p->offset == 1 )
406  build();
407  _p.Send( client, _p->getSize() );
408  }
409  else
410  {
411  if ( _p_old->offset == 1 )
412  buildold();
413  _p_old.Send( client );
414  }
415 }
416 
418 {
419  _p->offset = 1;
420  _p->Write<u32>( _serial );
421  _p->WriteFlipped<u16>( _damage );
422 }
424 {
425  _p_old->offset = 1;
426  _p_old->WriteFlipped<u16>( 11u );
427  _p_old->offset += 2; // sub
428  _p_old->Write<u8>( 1u );
429  _p_old->Write<u32>( _serial );
430  if ( _damage > 0xFF )
431  _p_old->Write<u8>( 0xFFu );
432  else
433  _p_old->Write<u8>( _damage );
434 }
435 
436 
438  : PktSender(), _serial_ext( serial_ext ), _rev( rev ), _p_old(), _p()
439 {
440 }
441 
443 {
444  if ( client->UOExpansionFlag & AOS )
445  {
446  if ( Core::settingsManager.ssopt.uo_feature_enable & Core::PKTOUT_A9::FLAG_AOS_FEATURES )
447  {
448  if ( ( Core::settingsManager.ssopt.force_new_objcache_packets ) ||
449  ( client->ClientType & Network::CLIENTTYPE_5000 ) )
450  {
451  if ( _p->offset == 1 )
452  build();
453  _p.Send( client, _p->getSize() );
454  }
455  else
456  {
457  if ( _p_old->offset == 1 )
458  buildold();
459  _p_old.Send( client );
460  }
461  }
462  }
463 }
464 
466 {
467  _p->offset = 1;
468  _p->Write<u32>( _serial_ext );
469  _p->WriteFlipped<u32>( _rev );
470 }
472 {
473  _p_old->offset = 1;
474  _p_old->WriteFlipped<u16>( 0xDu );
475  _p_old->offset += 2; // sub
476  _p_old->Write<u32>( _serial_ext );
477  _p_old->WriteFlipped<u32>( _rev );
478 }
479 
481  : PktSender(),
482  _effect_type( 0 ),
483  _src_serial_ext( 0 ),
484  _dst_serial_ext( 0 ),
485  _effect( 0 ),
486  _xs( 0 ),
487  _ys( 0 ),
488  _zs( 0 ),
489  _xd( 0 ),
490  _yd( 0 ),
491  _zd( 0 ),
492  _speed( 0 ),
493  _loop( 0 ),
494  _explode( 0 ),
495  _unk26( 0 ),
496  _p()
497 {
498 }
499 GraphicEffectPkt::GraphicEffectPkt( u8 effect_type, u32 src_serial_ext, u32 dst_serial_ext,
500  u16 effect, u16 xs, u16 ys, s8 zs, u16 xd, u16 yd, s8 zd,
501  u8 speed, u8 loop, u8 explode, u8 unk26 )
502  : PktSender(),
503  _effect_type( effect_type ),
504  _src_serial_ext( src_serial_ext ),
505  _dst_serial_ext( dst_serial_ext ),
506  _effect( effect ),
507  _xs( xs ),
508  _ys( ys ),
509  _zs( zs ),
510  _xd( xd ),
511  _yd( yd ),
512  _zd( zd ),
513  _speed( speed ),
514  _loop( loop ),
515  _explode( explode ),
516  _unk26( unk26 ),
517  _p()
518 {
519 }
520 
521 void GraphicEffectPkt::movingEffect( const Core::UObject* src, const Core::UObject* dst, u16 effect,
522  u8 speed, u8 loop, u8 explode )
523 {
527  _effect = effect;
528  _xs = src->x;
529  _ys = src->y;
530  _zs = src->z + src->height;
531  _xd = dst->x;
532  _yd = dst->y;
533  _zd = dst->z + dst->height;
534  _speed = speed;
535  _loop = loop;
536  _explode = explode;
537  _unk26 = 0;
538 }
539 void GraphicEffectPkt::movingEffect( u16 xs, u16 ys, s8 zs, u16 xd, u16 yd, s8 zd, u16 effect,
540  u8 speed, u8 loop, u8 explode )
541 {
543  _src_serial_ext = 0;
544  _dst_serial_ext = 0;
545  _effect = effect;
546  _xs = xs;
547  _ys = ys;
548  _zs = zs;
549  _xd = xd;
550  _yd = yd;
551  _zd = zd;
552  _speed = speed;
553  _loop = loop;
554  _explode = explode;
555  _unk26 = 0;
556 }
558 {
560  _src_serial_ext = center->serial_ext;
561  _dst_serial_ext = 0;
562  _effect = 0;
563  _xs = center->x;
564  _ys = center->y;
565  _zs = center->z;
566  _xd = 0;
567  _yd = 0;
568  _zd = 0;
569  _speed = 0;
570  _loop = 0;
571  _explode = 0;
572  _unk26 = 0;
573 }
574 
575 void GraphicEffectPkt::followEffect( const Core::UObject* center, u16 effect, u8 speed, u8 loop )
576 {
578  _src_serial_ext = center->serial_ext;
579  _dst_serial_ext = 0;
580  _effect = effect;
581  _xs = center->x;
582  _ys = center->y;
583  _zs = center->z;
584  _xd = 0;
585  _yd = 0;
586  _zd = 0;
587  _speed = speed;
588  _loop = loop;
589  _explode = 0;
590  _unk26 = 0;
591 }
592 
593 void GraphicEffectPkt::stationaryEffect( u16 xs, u16 ys, s8 zs, u16 effect, u8 speed, u8 loop,
594  u8 explode )
595 {
597  _src_serial_ext = 0;
598  _dst_serial_ext = 0;
599  _effect = effect;
600  _xs = xs;
601  _ys = ys;
602  _zs = zs;
603  _xd = 0;
604  _yd = 0;
605  _zd = 0;
606  _speed = speed;
607  _loop = loop;
608  _explode = explode;
609  _unk26 = 1; // this is right for teleport, anyway
610 }
611 
613 {
614  _p->offset = 1;
615  _p->Write<u8>( _effect_type );
616  _p->Write<u32>( _src_serial_ext );
617  _p->Write<u32>( _dst_serial_ext );
618  _p->WriteFlipped<u16>( _effect );
619  _p->WriteFlipped<u16>( _xs );
620  _p->WriteFlipped<u16>( _ys );
621  _p->Write<s8>( _zs );
622  _p->WriteFlipped<u16>( _xd );
623  _p->WriteFlipped<u16>( _yd );
624  _p->Write<s8>( _zd );
625  _p->Write<u8>( _speed );
626  _p->Write<u8>( _loop );
627  _p->offset += 2; // unk24,unk25
628  _p->Write<u8>( _unk26 );
629  _p->Write<u8>( _explode );
630 }
631 
633 {
634  if ( _p->offset == 1 )
635  build();
636  _p.Send( client, _p->getSize() );
637 }
638 
639 
641  : PktSender(),
642  _effect_type( 0 ),
643  _src_serial_ext( 0 ),
644  _dst_serial_ext( 0 ),
645  _effect( 0 ),
646  _xs( 0 ),
647  _ys( 0 ),
648  _zs( 0 ),
649  _xd( 0 ),
650  _yd( 0 ),
651  _zd( 0 ),
652  _speed( 0 ),
653  _duration( 0 ),
654  _direction( 0 ),
655  _explode( 0 ),
656  _hue( 0 ),
657  _render( 0 ),
658  _effect3d( 0 ),
659  _effect3dexplode( 0 ),
660  _effect3dsound( 0 ),
661  _itemid( 0 ),
662  _layer( 0 ),
663  _p()
664 {
665 }
666 GraphicEffectExPkt::GraphicEffectExPkt( u8 effect_type, u32 src_serial_ext, u32 dst_serial_ext,
667  u16 srcx, u16 srcy, s8 srcz, u16 dstx, u16 dsty, s8 dstz,
668  u16 effect, u8 speed, u8 duration, u8 direction, u8 explode,
669  u32 hue, u32 render, u16 effect3d, u16 effect3dexplode,
670  u16 effect3dsound, u32 itemid, u8 layer )
671  : PktSender(),
672  _effect_type( effect_type ),
673  _src_serial_ext( src_serial_ext ),
674  _dst_serial_ext( dst_serial_ext ),
675  _effect( effect ),
676  _xs( srcx ),
677  _ys( srcy ),
678  _zs( srcz ),
679  _xd( dstx ),
680  _yd( dsty ),
681  _zd( dstz ),
682  _speed( speed ),
683  _duration( duration ),
684  _direction( direction ),
685  _explode( explode ),
686  _hue( hue ),
687  _render( render ),
688  _effect3d( effect3d ),
689  _effect3dexplode( effect3dexplode ),
690  _effect3dsound( effect3dsound ),
691  _itemid( itemid ),
692  _layer( layer ),
693  _p()
694 {
695 }
696 
698  u16 effect, u8 speed, u8 duration, u32 hue, u32 render,
699  u8 direction, u8 explode, u16 effect3d, u16 effect3dexplode,
700  u16 effect3dsound )
701 {
705  _effect = effect;
706  _xs = src->x;
707  _ys = src->y;
708  _zs = src->z + src->height;
709  _xd = dst->x;
710  _yd = dst->y;
711  _zd = dst->z + dst->height;
712  _speed = speed;
713  _duration = duration;
714  _direction = direction;
715  _explode = explode;
716  _hue = hue;
717  _render = render;
718  _effect3d = effect3d;
719  _effect3dexplode = effect3dexplode;
720  _effect3dsound = effect3dsound;
721  _itemid = 0;
722  _layer = 0xFF;
723 }
724 void GraphicEffectExPkt::movingEffect( u16 xs, u16 ys, s8 zs, u16 xd, u16 yd, s8 zd, u16 effect,
725  u8 speed, u8 duration, u32 hue, u32 render, u8 direction,
726  u8 explode, u16 effect3d, u16 effect3dexplode,
727  u16 effect3dsound )
728 {
730  _src_serial_ext = 0;
731  _dst_serial_ext = 0;
732  _effect = effect;
733  _xs = xs;
734  _ys = ys;
735  _zs = zs;
736  _xd = xd;
737  _yd = yd;
738  _zd = zd;
739  _speed = speed;
740  _duration = duration;
741  _direction = direction;
742  _explode = explode;
743  _hue = hue;
744  _render = render;
745  _effect3d = effect3d;
746  _effect3dexplode = effect3dexplode;
747  _effect3dsound = effect3dsound;
748  _itemid = 0;
749  _layer = 0xFF;
750 }
751 
752 void GraphicEffectExPkt::followEffect( const Core::UObject* center, u16 effect, u8 speed,
753  u8 duration, u32 hue, u32 render, u8 layer, u16 effect3d )
754 {
756  _src_serial_ext = center->serial_ext;
757  _dst_serial_ext = center->serial_ext;
758  _effect = effect;
759  _xs = center->x;
760  _ys = center->y;
761  _zs = center->z;
762  _xd = center->x;
763  _yd = center->y;
764  _zd = center->z;
765  _speed = speed;
766  _duration = duration;
767  _direction = 1;
768  _explode = 0;
769  _hue = hue;
770  _render = render;
771  _effect3d = effect3d;
772  _effect3dexplode = 1;
773  _effect3dsound = 0;
774  _itemid = center->serial_ext;
775  _layer = layer;
776 }
777 
778 void GraphicEffectExPkt::stationaryEffect( u16 x, u16 y, s8 z, u16 effect, u8 speed, u8 duration,
779  u32 hue, u32 render, u16 effect3d )
780 {
782  _src_serial_ext = 0;
783  _dst_serial_ext = 0;
784  _effect = effect;
785  _xs = x;
786  _ys = y;
787  _zs = z;
788  _xd = x;
789  _yd = y;
790  _zd = z;
791  _speed = speed;
792  _duration = duration;
793  _direction = 1;
794  _explode = 0;
795  _hue = hue;
796  _render = render;
797  _effect3d = effect3d;
798  _effect3dexplode = 1;
799  _effect3dsound = 0;
800  _itemid = 0;
801  _layer = 0xFF;
802 }
803 
805 {
806  // C0 part
807  _p->offset = 1;
808  _p->Write<u8>( _effect_type );
809  _p->Write<u32>( _src_serial_ext );
810  _p->Write<u32>( _dst_serial_ext );
811  _p->WriteFlipped<u16>( _effect );
812  _p->WriteFlipped<u16>( _xs );
813  _p->WriteFlipped<u16>( _ys );
814  _p->Write<s8>( _zs );
815  _p->WriteFlipped<u16>( _xd );
816  _p->WriteFlipped<u16>( _yd );
817  _p->Write<s8>( _zd );
818  _p->Write<u8>( _speed );
819  _p->Write<u8>( _duration );
820  _p->offset += 2; // u16 unk
821  _p->Write<u8>( _direction );
822  _p->Write<u8>( _explode );
823  _p->WriteFlipped<u32>( _hue );
824  _p->WriteFlipped<u32>( _render );
825  // C7 part
826  _p->WriteFlipped<u16>( _effect3d ); // see particleffect subdir
827  _p->WriteFlipped<u16>( _effect3dexplode ); // 0 if no explosion
828  _p->WriteFlipped<u16>( _effect3dsound ); // for moving effects, 0 otherwise
829  _p->Write<u32>( _itemid ); // if target is item (type 2), 0 otherwise
830  _p->Write<u8>( _layer ); //(of the character, e.g left hand, right hand, 0-5,7, 0xff: moving
831  // effect or target is no char)
832  _p->offset += 2; // u16 unk_effect
833 }
834 
836 {
837  if ( _p->offset == 1 )
838  build();
839  _p.Send( client, _p->getSize() );
840 }
841 
842 
843 HealthBarStatusUpdate::HealthBarStatusUpdate( u32 serial_ext, Color color, bool enable )
844  : PktSender(), _serial_ext( serial_ext ), _enable( enable ), _color( color ), _p()
845 {
846 }
848 {
849  _p->offset = 1;
850  _p->WriteFlipped<u16>( _p->getSize() );
851  _p->Write<u32>( _serial_ext );
852  _p->WriteFlipped<u16>( 1u ); // unk
853  _p->WriteFlipped<u16>( _color );
854  _p->Write<u8>( _enable ? 1u : 0u ); // flag
855 }
857 {
858  if ( client->ClientType & CLIENTTYPE_UOKR )
859  {
860  if ( _p->offset == 1 )
861  build();
862  _p.Send( client );
863  }
864 }
865 
866 
867 MoveChrPkt::MoveChrPkt( const Mobile::Character* chr ) : PktSender(), _chr( chr ), _p() {}
868 
870 {
871  _p->offset = 1;
872  _p->Write<u32>( _chr->serial_ext );
873  _p->WriteFlipped<u16>( _chr->graphic );
874  _p->WriteFlipped<u16>( _chr->x );
875  _p->WriteFlipped<u16>( _chr->y );
876  _p->Write<s8>( _chr->z );
877  _p->Write<u8>( ( _chr->dir & 0x80u ) |
878  _chr->facing ); // NOTE, this only includes mask 0x07 of the last MOVE message
879  _p->WriteFlipped<u16>( _chr->color );
880 }
881 void MoveChrPkt::Send( Client* client )
882 {
883  if ( _p->offset == 1 )
884  build();
885  _p->offset = 15;
886  _p->Write<u8>( _chr->get_flag1( client ) );
887  _p->Write<u8>( _chr->hilite_color_idx( client->chr ) );
888  _p.Send( client );
889 }
890 }
891 }
void updateFlags(u8 flags)
Definition: packetdefs.cpp:34
unsigned char u8
Definition: rawtypes.h:25
void update(u16 anim, u16 action, u8 subaction, u16 action_old, u16 framecount_old, u16 repeat_old, Core::DIRECTION_FLAG_OLD backward_old, Core::REPEAT_FLAG_OLD repeat_flag_old, u8 delay_old, bool oldanim_valid, bool newanim_valid)
Definition: packetdefs.cpp:282
PktHelper::PacketOut< PktOut_C7 > _p
Definition: packetdefs.h:289
void movingEffect(const Core::UObject *src, const Core::UObject *dst, u16 effect, u8 speed, u8 duration, u32 hue, u32 render, u8 direction, u8 explode, u16 effect3d, u16 effect3dexplode, u16 effect3dsound)
Definition: packetdefs.cpp:697
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:401
PlaySoundPkt(u8 type, u16 effect, u16 xcenter, u16 ycenter, s16 zcenter)
Definition: packetdefs.cpp:346
MobileAnimationMsg(u32 serial_ext, u16 anim, u16 action, u8 subaction, u16 action_old, u16 framecount_old, u16 repeat_old, Core::DIRECTION_FLAG_OLD backward_old, Core::REPEAT_FLAG_OLD repeat_flag_old, u8 delay_old, bool oldanim_valid, bool newanim_valid)
Definition: packetdefs.cpp:259
PktHelper::PacketOut< PktOut_F3 > _p
Definition: packetdefs.h:76
u8 get_flag1(Network::Client *other_client) const
Definition: charactr.cpp:1771
PktHelper::PacketOut< PktOut_70 > _p
Definition: packetdefs.h:238
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:442
const Mobile::Character * _chr
Definition: packetdefs.h:324
PktHelper::PacketOut< PktOut_1D > _p
Definition: packetdefs.h:165
void lightningBold(const Core::UObject *center)
Definition: packetdefs.cpp:557
AddItemContainerMsg(u32 serial_ext, u16 graphic, u16 amount, u16 x, u16 y, u8 slotindex, u32 containerserial_ext, u16 color)
Definition: packetdefs.cpp:183
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:856
SendDamagePkt(u32 serial, u16 damage)
Definition: packetdefs.cpp:397
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:163
void followEffect(const Core::UObject *center, u16 effect, u8 speed, u8 duration, u32 hue, u32 render, u8 layer, u16 effect3d)
Definition: packetdefs.cpp:752
PktHelper::PacketOut< PktOut_6E > _p_old
Definition: packetdefs.h:133
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:384
Mobile::Character * chr
Definition: client.h:182
PktHelper::PacketOut< PktOut_E2 > _p
Definition: packetdefs.h:134
unsigned short u16
Definition: rawtypes.h:26
unsigned int u32
Definition: rawtypes.h:27
void stationaryEffect(u16 x, u16 y, s8 z, u16 effect, u8 speed, u8 duration, u32 hue, u32 render, u16 effect3d)
Definition: packetdefs.cpp:778
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:835
const u16 AOS
Definition: client.h:75
SendWorldItem(u32 serial, u16 graphic, u16 amount, u16 x, u16 y, s8 z, u8 facing, u16 color, u8 flags)
Definition: packetdefs.cpp:99
PktHelper::PacketOut< PktOut_1A > _p_old
Definition: packetdefs.h:54
signed short s16
Definition: rawtypes.h:30
PktHelper::PacketOut< PktOut_25 > _p_old
Definition: packetdefs.h:98
REPEAT_FLAG_OLD
Definition: action.h:78
virtual unsigned char hilite_color_idx(const Character *seen_by) const
Definition: repsys.cpp:981
signed char s8
Definition: rawtypes.h:29
PktHelper::PacketOut< PktOut_BF_Sub22 > _p_old
Definition: packetdefs.h:181
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:15
void stationaryEffect(u16 xs, u16 ys, s8 zs, u16 effect, u8 speed, u8 loop, u8 explode)
Definition: packetdefs.cpp:593
SendWorldMulti(u32 serial_ext, u16 graphic, u16 x, u16 y, s8 z, u16 color)
Definition: packetdefs.cpp:117
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:225
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:881
PktHelper::PacketOut< PktOut_25 > _p
Definition: packetdefs.h:99
SettingsManager settingsManager
Definition: settings.cpp:14
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:632
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:357
PktHelper::PacketOut< PktOut_54 > _p
Definition: packetdefs.h:151
PktHelper::PacketOut< PktOut_DC > _p
Definition: packetdefs.h:199
PktHelper::PacketOut< PktOut_0B > _p
Definition: packetdefs.h:182
void movingEffect(const Core::UObject *src, const Core::UObject *dst, u16 effect, u8 speed, u8 loop, u8 explode)
Definition: packetdefs.cpp:521
PktHelper::PacketOut< PktOut_F3 > _p
Definition: packetdefs.h:55
PktHelper::PacketOut< PktOut_17 > _p
Definition: packetdefs.h:311
virtual void Send(Client *client) POL_OVERRIDE
Definition: packetdefs.cpp:325
PktHelper::PacketOut< PktOut_BF_Sub10 > _p_old
Definition: packetdefs.h:198
PktHelper::PacketOut< PktOut_1A > _p_old
Definition: packetdefs.h:75
ObjRevisionPkt(u32 serial_ext, u32 rev)
Definition: packetdefs.cpp:437
DIRECTION_FLAG_OLD
Definition: action.h:73
void followEffect(const Core::UObject *center, u16 effect, u8 speed, u8 loop)
Definition: packetdefs.cpp:575
Definition: berror.cpp:12
HealthBarStatusUpdate(u32 serial_ext, Color color, bool enable)
Definition: packetdefs.cpp:843
MoveChrPkt(const Mobile::Character *chr)
Definition: packetdefs.cpp:867
PktHelper::PacketOut< PktOut_77 > _p
Definition: packetdefs.h:325