• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polserver / polserver / 25988041997

17 May 2026 10:13AM UTC coverage: 60.832% (-0.07%) from 60.903%
25988041997

Pull #884

github

turleypol
run hitscript, cleanup
Pull Request #884: Attackable item

268 of 559 new or added lines in 26 files covered. (47.94%)

18 existing lines in 7 files now uncovered.

44718 of 73511 relevant lines covered (60.83%)

502068.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

32.67
/pol-core/pol/network/packetdefs.cpp
1

2
#include "packetdefs.h"
3

4
#include "../../clib/rawtypes.h"
5
#include "../globals/settings.h"
6
#include "../item/item.h"
7
#include "../mobile/charactr.h"
8
#include "../uobject.h"
9
#include "client.h"
10
#include "pktdef.h"
11

12

13
namespace Pol::Network
14
{
15
void SendWorldItem::Send( Client* client )
6,117✔
16
{
17
  if ( client->ClientType & CLIENTTYPE_7000 )
6,117✔
18
  {
19
    if ( _p->offset == 1 )
6,117✔
20
      buildF3();
6,116✔
21
    if ( client->ClientType & CLIENTTYPE_7090 ) /*once known split class?*/
6,117✔
22
      _p.Send( client, 26 );
6,117✔
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
}
6,117✔
33

34
void SendWorldItem::updateFlags( u8 flags )
6,076✔
35
{
36
  if ( flags != _flags )
6,076✔
37
  {
38
    _flags = flags;
49✔
39
    if ( _p_old->offset != 1 )
49✔
40
    {
41
      _p_old->offset = _p_oldlen - 1;
×
42
      _p_old->Write<u8>( _flags );
×
43
    }
44
    if ( _p->offset != 1 )
49✔
45
    {
46
      _p->offset = 23;
×
47
      _p->Write<u8>( _flags );
×
48
    }
49
  }
50
}
6,076✔
51

52
void SendWorldItem::build1A()
×
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.
NEW
58
  _p_old->WriteFlipped<u32>( 0x80000000u | _item->serial );  // bit 0x80000000 enables piles
×
NEW
59
  _p_old->WriteFlipped<u16>( _item->graphic );
×
NEW
60
  _p_old->WriteFlipped<u16>( _item->get_senditem_amount() );
×
NEW
61
  const auto& pos = _item->pos3d();
×
NEW
62
  if ( _item->facing == 0 )
×
63
  {
NEW
64
    _p_old->WriteFlipped<u16>( pos.x() );
×
65
    // bits 0x80 and 0x40 are Dye and Move (dunno which is which)
NEW
66
    _p_old->WriteFlipped<u16>( 0xC000u | pos.y() );  // dyeable and moveable?
×
67
  }
68
  else
69
  {
NEW
70
    _p_old->WriteFlipped<u16>( 0x8000u | pos.x() );
×
71
    // bits 0x80 and 0x40 are Dye and Move (dunno which is which)
NEW
72
    _p_old->WriteFlipped<u16>( 0xC000u | pos.y() );  // dyeable and moveable?
×
NEW
73
    _p_old->Write<u8>( _item->facing );
×
74
  }
NEW
75
  _p_old->Write<s8>( pos.z() );
×
NEW
76
  _p_old->WriteFlipped<u16>( _item->color );
×
77
  _p_old->Write<u8>( _flags );
×
78
  _p_oldlen = _p_old->offset;
×
79
  _p_old->offset = 1;
×
80
  _p_old->WriteFlipped<u16>( _p_oldlen );
×
81
}
×
82
void SendWorldItem::buildF3()
6,116✔
83
{
84
  _p->offset = 1;
6,116✔
85
  _p->WriteFlipped<u16>( 0x1_u16 );
6,116✔
86

87
  _p->Write<u8>( _item->is_attackable() ? 3_u8 : 0_u8 );
6,116✔
88
  _p->WriteFlipped<u32>( _item->serial );
6,116✔
89
  _p->WriteFlipped<u16>( _item->graphic );
6,116✔
90
  _p->Write<u8>( 0_u8 );
6,116✔
91
  const auto amount = _item->get_senditem_amount();
6,116✔
92
  _p->WriteFlipped<u16>( amount );
6,116✔
93
  _p->WriteFlipped<u16>( amount );
6,116✔
94
  const auto& pos = _item->pos3d();
6,116✔
95
  _p->WriteFlipped<u16>( pos.x() );
6,116✔
96
  _p->WriteFlipped<u16>( pos.y() );
6,116✔
97
  _p->Write<s8>( pos.z() );
6,116✔
98
  _p->Write<u8>( _item->facing );
6,116✔
99
  _p->WriteFlipped<u16>( _item->color );
6,116✔
100
  _p->Write<u8>( _flags );
6,116✔
101
}
6,116✔
102

103
SendWorldItem::SendWorldItem( const Items::Item* item, u8 flags )
13,241✔
104
    : PktSender(), _flags{ flags }, _item{ item }, _p_old(), _p()
13,241✔
105
{
106
}
13,241✔
107

108
SendWorldMulti::SendWorldMulti( u32 serial_ext, u16 graphic, Core::Pos3d pos, u16 color )
25✔
109
    : PktSender(),
110
      _p_oldlen( 0 ),
25✔
111
      _serial_ext( serial_ext ),
25✔
112
      _graphic( graphic ),
25✔
113
      _pos( std::move( pos ) ),
50✔
114
      _color( color ),
25✔
115
      _p_old(),
25✔
116
      _p()
50✔
117
{
118
}
25✔
119

120
void SendWorldMulti::build1A()
×
121
{
122
  _p_old->offset = 1;
×
123
  _p_old->offset += 2;
×
124
  _p_old->Write<u32>( _serial_ext );
×
125
  _p_old->WriteFlipped<u16>( _graphic | 0x4000u );
×
126
  _p_old->WriteFlipped<u16>( _pos.x() );
×
127
  _p_old->WriteFlipped<u16>( _pos.y() );
×
128
  _p_old->Write<s8>( _pos.z() );
×
129
  _p_oldlen = _p_old->offset;
×
130
  _p_old->offset = 1;
×
131
  _p_old->WriteFlipped<u16>( _p_oldlen );
×
132
}
×
133

134
void SendWorldMulti::buildF3()
4✔
135
{
136
  _p->offset = 1;
4✔
137
  _p->WriteFlipped<u16>( 0x1u );
4✔
138
  _p->Write<u8>( 0x02u );
4✔
139
  _p->Write<u32>( _serial_ext );
4✔
140
  _p->WriteFlipped<u16>( _graphic );
4✔
141
  _p->Write<u8>( 0u );
4✔
142
  _p->WriteFlipped<u16>( 0x1u );  // amount
4✔
143
  _p->WriteFlipped<u16>( 0x1u );  // amount
4✔
144
  _p->WriteFlipped<u16>( _pos.x() );
4✔
145
  _p->WriteFlipped<u16>( _pos.y() );
4✔
146
  _p->Write<s8>( _pos.z() );
4✔
147
  _p->Write<u8>( 0u );  // facing
4✔
148
  _p->WriteFlipped<u16>( _color );
4✔
149
  _p->Write<u8>( 0u );  // flags
4✔
150
}
4✔
151

152
void SendWorldMulti::Send( Client* client )
4✔
153
{
154
  if ( client->ClientType & CLIENTTYPE_7000 )
4✔
155
  {
156
    if ( _p->offset == 1 )
4✔
157
      buildF3();
4✔
158
    if ( client->ClientType & CLIENTTYPE_7090 ) /*once known split class?*/
4✔
159
      _p.Send( client, 26 );
4✔
160
    else
161
      _p.Send( client, 24 );
×
162
  }
163
  else
164
  {
165
    if ( _p_old->offset == 1 )
×
166
      build1A();
×
167
    _p_old.Send( client, _p_oldlen );
×
168
  }
169
}
4✔
170

171

172
AddItemContainerMsg::AddItemContainerMsg( u32 serial_ext, u16 graphic, u16 amount, Core::Pos2d pos,
71✔
173
                                          u8 slotindex, u32 containerserial_ext, u16 color )
71✔
174
    : PktSender(),
175
      _serial_ext( serial_ext ),
71✔
176
      _graphic( graphic ),
71✔
177
      _amount( amount ),
71✔
178
      _pos( std::move( pos ) ),
142✔
179
      _slotindex( slotindex ),
71✔
180
      _containerserial_ext( containerserial_ext ),
71✔
181
      _color( color ),
71✔
182
      _p_old(),
71✔
183
      _p()
142✔
184
{
185
}
71✔
186

187
void AddItemContainerMsg::buildLegacy()
×
188
{
189
  _p_old->offset = 1;
×
190
  _p_old->Write<u32>( _serial_ext );
×
191
  _p_old->WriteFlipped<u16>( _graphic );
×
192
  _p_old->offset++;  // unk7 layer?
×
193
  _p_old->WriteFlipped<u16>( _amount );
×
194
  _p_old->WriteFlipped<u16>( _pos.x() );
×
195
  _p_old->WriteFlipped<u16>( _pos.y() );
×
196
  _p_old->Write<u32>( _containerserial_ext );
×
197
  _p_old->WriteFlipped<u16>( _color );
×
198
}
×
199
void AddItemContainerMsg::build()
37✔
200
{
201
  _p->offset = 1;
37✔
202
  _p->Write<u32>( _serial_ext );
37✔
203
  _p->WriteFlipped<u16>( _graphic );
37✔
204
  _p->offset++;  // unk7 layer?
37✔
205
  _p->WriteFlipped<u16>( _amount );
37✔
206
  _p->WriteFlipped<u16>( _pos.x() );
37✔
207
  _p->WriteFlipped<u16>( _pos.y() );
37✔
208
  _p->Write<u8>( _slotindex );
37✔
209
  _p->Write<u32>( _containerserial_ext );
37✔
210
  _p->WriteFlipped<u16>( _color );
37✔
211
}
37✔
212

213
void AddItemContainerMsg::Send( Client* client )
37✔
214
{
215
  if ( client->ClientType & CLIENTTYPE_6017 )
37✔
216
  {
217
    if ( _p->offset == 1 )
37✔
218
      build();
37✔
219
    _p.Send( client, _p->getSize() );
37✔
220
  }
221
  else
222
  {
223
    if ( _p_old->offset == 1 )
×
224
      buildLegacy();
×
225
    _p_old.Send( client, _p->getSize() - 1 );
×
226
  }
227
}
37✔
228

229
MobileAnimationMsg::MobileAnimationMsg( u32 serial_ext )
8✔
230
    : PktSender(),
231
      _serial_ext( serial_ext ),
8✔
232
      _anim( 0 ),
8✔
233
      _action( 0 ),
8✔
234
      _subaction( 0 ),
8✔
235
      _action_old( 0 ),
8✔
236
      _framecount_old( 0 ),
8✔
237
      _repeat_old( 0 ),
8✔
238
      _backward_old( 0 ),
8✔
239
      _repeat_flag_old( 0 ),
8✔
240
      _delay_old( 0 ),
8✔
241
      _oldanim_valid( false ),
8✔
242
      _newanim_valid( false ),
8✔
243
      _p_old(),
8✔
244
      _p()
8✔
245
{
246
}
8✔
247
MobileAnimationMsg::MobileAnimationMsg( u32 serial_ext, u16 anim, u16 action, u8 subaction,
×
248
                                        u16 action_old, u16 framecount_old, u16 repeat_old,
249
                                        Core::DIRECTION_FLAG_OLD backward_old,
250
                                        Core::REPEAT_FLAG_OLD repeat_flag_old, u8 delay_old,
251
                                        bool oldanim_valid, bool newanim_valid )
×
252
    : PktSender(),
253
      _serial_ext( serial_ext ),
×
254
      _anim( anim ),
×
255
      _action( action ),
×
256
      _subaction( subaction ),
×
257
      _action_old( action_old ),
×
258
      _framecount_old( framecount_old ),
×
259
      _repeat_old( repeat_old ),
×
260
      _backward_old( static_cast<u8>( backward_old ) ),
×
261
      _repeat_flag_old( static_cast<u8>( repeat_flag_old ) ),
×
262
      _delay_old( delay_old ),
×
263
      _oldanim_valid( oldanim_valid ),
×
264
      _newanim_valid( newanim_valid ),
×
265
      _p_old(),
×
266
      _p()
×
267
{
268
}
×
269

270
void MobileAnimationMsg::update( u16 anim, u16 action, u8 subaction, u16 action_old,
×
271
                                 u16 framecount_old, u16 repeat_old,
272
                                 Core::DIRECTION_FLAG_OLD backward_old,
273
                                 Core::REPEAT_FLAG_OLD repeat_flag_old, u8 delay_old,
274
                                 bool oldanim_valid, bool newanim_valid )
275
{
276
  _anim = anim;
×
277
  _action = action;
×
278
  _subaction = subaction;
×
279
  _action_old = action_old;
×
280
  _framecount_old = framecount_old;
×
281
  _repeat_old = repeat_old;
×
282
  _backward_old = static_cast<u8>( backward_old );
×
283
  _repeat_flag_old = static_cast<u8>( repeat_flag_old );
×
284
  _delay_old = delay_old;
×
285
  _oldanim_valid = oldanim_valid;
×
286
  _newanim_valid = newanim_valid;
×
287
  if ( _oldanim_valid && _p_old->offset != 1 )
×
288
    build6E();
×
289
  if ( _newanim_valid && _p->offset != 1 )
×
290
    build();
×
291
}
×
292
void MobileAnimationMsg::build()
×
293
{
294
  _p->offset = 1;
×
295
  _p->Write<u32>( _serial_ext );
×
296
  _p->WriteFlipped<u16>( _anim );
×
297
  _p->WriteFlipped<u16>( _action );
×
298
  _p->Write<u8>( _subaction );
×
299
}
×
300

301
void MobileAnimationMsg::build6E()
×
302
{
303
  _p_old->offset = 1;
×
304
  _p_old->Write<u32>( _serial_ext );
×
305
  _p_old->WriteFlipped<u16>( _action_old );
×
306
  _p_old->WriteFlipped<u16>( _framecount_old );
×
307
  _p_old->WriteFlipped<u16>( _repeat_old );
×
308
  _p_old->Write<u8>( _backward_old );
×
309
  _p_old->Write<u8>( _repeat_flag_old );
×
310
  _p_old->Write<u8>( _delay_old );
×
311
}
×
312

313
void MobileAnimationMsg::Send( Client* client )
×
314
{
315
  if ( client->ClientType & CLIENTTYPE_7090 )
×
316
  {
317
    if ( !_newanim_valid )
×
318
      return;
×
319
    if ( _p->offset == 1 )
×
320
      build();
×
321
    _p.Send( client, _p->getSize() );
×
322
  }
323
  else
324
  {
325
    if ( !_oldanim_valid )
×
326
      return;
×
327
    if ( _p_old->offset == 1 )
×
328
      build6E();
×
329
    _p_old.Send( client, _p_old->getSize() );
×
330
  }
331
}
332

333

334
PlaySoundPkt::PlaySoundPkt( u8 type, u16 effect, Core::Pos3d center )
×
335
    : PktSender(), _type( type ), _effect( effect ), _center( std::move( center ) ), _p()
×
336
{
337
}
×
338

339
void PlaySoundPkt::Send( Client* client )
×
340
{
341
  if ( _p->offset == 1 )
×
342
    build();
×
343
  _p.Send( client, _p->getSize() );
×
344
}
×
345

346
void PlaySoundPkt::build()
×
347
{
348
  _p->offset = 1;
×
349
  _p->Write<u8>( _type );
×
350
  _p->WriteFlipped<u16>( _effect );
×
351
  _p->offset += 2;  // volume
×
352
  _p->WriteFlipped<u16>( _center.x() );
×
353
  _p->WriteFlipped<u16>( _center.y() );
×
354
  _p->WriteFlipped<s16>( _center.z() );
×
355
}
×
356

357
RemoveObjectPkt::RemoveObjectPkt( u32 serial_ext ) : _serial( serial_ext ), _p() {}
19,866✔
358

359
void RemoveObjectPkt::update( u32 serial )
27✔
360
{
361
  _serial = serial;
27✔
362
  if ( _p->offset != 1 )
27✔
363
    build();
13✔
364
}
27✔
365

366
void RemoveObjectPkt::Send( Client* client )
6,191✔
367
{
368
  if ( _p->offset == 1 )
6,191✔
369
    build();
6,177✔
370
  _p.Send( client, _p->getSize() );
6,191✔
371
}
6,191✔
372

373
void RemoveObjectPkt::build()
6,190✔
374
{
375
  _p->offset = 1;
6,190✔
376
  _p->Write<u32>( _serial );
6,190✔
377
}
6,190✔
378

379
SendDamagePkt::SendDamagePkt( u32 serial_ext, u16 damage )
×
380
    : PktSender(), _serial( serial_ext ), _damage( damage ), _p_old(), _p()
×
381
{
382
}
×
383
void SendDamagePkt::Send( Client* client )
×
384
{
385
  if ( client->ClientType & CLIENTTYPE_4070 )
×
386
  {
387
    if ( _p->offset == 1 )
×
388
      build();
×
389
    _p.Send( client, _p->getSize() );
×
390
  }
391
  else
392
  {
393
    if ( _p_old->offset == 1 )
×
394
      buildold();
×
395
    _p_old.Send( client );
×
396
  }
397
}
×
398

399
void SendDamagePkt::build()
×
400
{
401
  _p->offset = 1;
×
402
  _p->Write<u32>( _serial );
×
403
  _p->WriteFlipped<u16>( _damage );
×
404
}
×
405
void SendDamagePkt::buildold()
×
406
{
407
  _p_old->offset = 1;
×
408
  _p_old->WriteFlipped<u16>( 11u );
×
409
  _p_old->offset += 2;  // sub
×
410
  _p_old->Write<u8>( 1u );
×
411
  _p_old->Write<u32>( _serial );
×
412
  if ( _damage > 0xFF )
×
413
    _p_old->Write<u8>( 0xFFu );
×
414
  else
415
    _p_old->Write<u8>( _damage );
×
416
}
×
417

418

419
ObjRevisionPkt::ObjRevisionPkt( u32 serial_ext, u32 rev )
19,917✔
420
    : PktSender(), _serial_ext( serial_ext ), _rev( rev ), _p_old(), _p()
19,917✔
421
{
422
}
19,917✔
423

424
void ObjRevisionPkt::Send( Client* client )
6,465✔
425
{
426
  if ( !client->acctSupports( Plib::ExpansionVersion::AOS ) )
6,465✔
427
    return;
×
428
  if ( !Core::settingsManager.ssopt.features.supportsAOS() )
6,465✔
429
    return;
×
430
  if ( ( Core::settingsManager.ssopt.force_new_objcache_packets ) ||
6,465✔
431
       ( client->ClientType & Network::CLIENTTYPE_5000 ) )
6,465✔
432
  {
433
    if ( _p->offset == 1 )
6,465✔
434
      build();
6,451✔
435
    _p.Send( client, _p->getSize() );
6,465✔
436
  }
437
  else
438
  {
439
    if ( _p_old->offset == 1 )
×
440
      buildold();
×
441
    _p_old.Send( client );
×
442
  }
443
}
444

445
void ObjRevisionPkt::build()
6,451✔
446
{
447
  _p->offset = 1;
6,451✔
448
  _p->Write<u32>( _serial_ext );
6,451✔
449
  _p->WriteFlipped<u32>( _rev );
6,451✔
450
}
6,451✔
451
void ObjRevisionPkt::buildold()
×
452
{
453
  _p_old->offset = 1;
×
454
  _p_old->WriteFlipped<u16>( 0xDu );
×
455
  _p_old->offset += 2;  // sub
×
456
  _p_old->Write<u32>( _serial_ext );
×
457
  _p_old->WriteFlipped<u32>( _rev );
×
458
}
×
459

460
GraphicEffectPkt::GraphicEffectPkt()
×
461
    : PktSender(),
462
      _effect_type( 0 ),
×
463
      _src_serial_ext( 0 ),
×
464
      _dst_serial_ext( 0 ),
×
465
      _effect( 0 ),
×
466
      _src(),
×
467
      _dst(),
×
468
      _speed( 0 ),
×
469
      _loop( 0 ),
×
470
      _explode( 0 ),
×
471
      _unk26( 0 ),
×
472
      _p()
×
473
{
474
}
×
475

476
void GraphicEffectPkt::movingEffect( const Core::UObject* src, const Core::UObject* dst, u16 effect,
×
477
                                     u8 speed, u8 loop, u8 explode )
478
{
479
  _effect_type = Core::PKTOUT_C0::EFFECT_MOVING;
×
480
  _src_serial_ext = src->serial_ext;
×
481
  _dst_serial_ext = dst->serial_ext;
×
482
  _effect = effect;
×
483
  _src = src->toplevel_pos().xyz() + Core::Vec3d( 0, 0, src->height );
×
484
  _dst = dst->toplevel_pos().xyz() + Core::Vec3d( 0, 0, dst->height );
×
485
  _speed = speed;
×
486
  _loop = loop;
×
487
  _explode = explode;
×
488
}
×
489
void GraphicEffectPkt::movingEffect( Core::Pos3d src, Core::Pos3d dst, u16 effect, u8 speed,
×
490
                                     u8 loop, u8 explode )
491
{
492
  _effect_type = Core::PKTOUT_C0::EFFECT_MOVING;
×
493
  _effect = effect;
×
494
  _src = std::move( src );
×
495
  _dst = std::move( dst );
×
496
  _speed = speed;
×
497
  _loop = loop;
×
498
  _explode = explode;
×
499
}
×
500
void GraphicEffectPkt::lightningBold( const Core::UObject* center )
×
501
{
502
  _effect_type = Core::PKTOUT_C0::EFFECT_LIGHTNING;
×
503
  _src_serial_ext = center->serial_ext;
×
504
  _src = center->toplevel_pos().xyz();
×
505
}
×
506

507
void GraphicEffectPkt::followEffect( const Core::UObject* center, u16 effect, u8 speed, u8 loop )
×
508
{
509
  _effect_type = Core::PKTOUT_C0::EFFECT_FIXEDFROM;
×
510
  _src_serial_ext = center->serial_ext;
×
511
  _effect = effect;
×
512
  _src = center->toplevel_pos().xyz();
×
513
  _speed = speed;
×
514
  _loop = loop;
×
515
}
×
516

517
void GraphicEffectPkt::stationaryEffect( Core::Pos3d src, u16 effect, u8 speed, u8 loop,
×
518
                                         u8 explode )
519
{
520
  _effect_type = Core::PKTOUT_C0::EFFECT_FIXEDXYZ;
×
521
  _effect = effect;
×
522
  _src = std::move( src );
×
523
  _speed = speed;
×
524
  _loop = loop;
×
525
  _explode = explode;
×
526
  _unk26 = 1;  // this is right for teleport, anyway
×
527
}
×
528

529
void GraphicEffectPkt::build()
×
530
{
531
  _p->offset = 1;
×
532
  _p->Write<u8>( _effect_type );
×
533
  _p->Write<u32>( _src_serial_ext );
×
534
  _p->Write<u32>( _dst_serial_ext );
×
535
  _p->WriteFlipped<u16>( _effect );
×
536
  _p->WriteFlipped<u16>( _src.x() );
×
537
  _p->WriteFlipped<u16>( _src.y() );
×
538
  _p->Write<s8>( _src.z() );
×
539
  _p->WriteFlipped<u16>( _dst.x() );
×
540
  _p->WriteFlipped<u16>( _dst.y() );
×
541
  _p->Write<s8>( _dst.z() );
×
542
  _p->Write<u8>( _speed );
×
543
  _p->Write<u8>( _loop );
×
544
  _p->offset += 2;  // unk24,unk25
×
545
  _p->Write<u8>( _unk26 );
×
546
  _p->Write<u8>( _explode );
×
547
}
×
548

549
void GraphicEffectPkt::Send( Client* client )
×
550
{
551
  if ( _p->offset == 1 )
×
552
    build();
×
553
  _p.Send( client, _p->getSize() );
×
554
}
×
555

556

557
GraphicEffectExPkt::GraphicEffectExPkt()
×
558
    : PktSender(),
559
      _effect_type( 0 ),
×
560
      _src_serial_ext( 0 ),
×
561
      _dst_serial_ext( 0 ),
×
562
      _effect( 0 ),
×
563
      _src(),
×
564
      _dst(),
×
565
      _speed( 0 ),
×
566
      _duration( 0 ),
×
567
      _direction( 0 ),
×
568
      _explode( 0 ),
×
569
      _hue( 0 ),
×
570
      _render( 0 ),
×
571
      _effect3d( 0 ),
×
572
      _effect3dexplode( 0 ),
×
573
      _effect3dsound( 0 ),
×
574
      _itemid( 0 ),
×
575
      _layer( 0 ),
×
576
      _p()
×
577
{
578
}
×
579

580
void GraphicEffectExPkt::movingEffect( const Core::UObject* src, const Core::UObject* dst,
×
581
                                       u16 effect, u8 speed, u8 duration, u32 hue, u32 render,
582
                                       u8 direction, u8 explode, u16 effect3d, u16 effect3dexplode,
583
                                       u16 effect3dsound )
584
{
585
  _effect_type = Core::PKTOUT_C0::EFFECT_MOVING;
×
586
  _src_serial_ext = src->serial_ext;
×
587
  _dst_serial_ext = dst->serial_ext;
×
588
  _effect = effect;
×
589
  _src = src->toplevel_pos().xyz() + Core::Vec3d( 0, 0, src->height );
×
590
  _dst = dst->toplevel_pos().xyz() + Core::Vec3d( 0, 0, dst->height );
×
591
  _speed = speed;
×
592
  _duration = duration;
×
593
  _direction = direction;
×
594
  _explode = explode;
×
595
  _hue = hue;
×
596
  _render = render;
×
597
  _effect3d = effect3d;
×
598
  _effect3dexplode = effect3dexplode;
×
599
  _effect3dsound = effect3dsound;
×
600
  _layer = 0xFF;
×
601
}
×
602
void GraphicEffectExPkt::movingEffect( Core::Pos3d src, Core::Pos3d dst, u16 effect, u8 speed,
×
603
                                       u8 duration, u32 hue, u32 render, u8 direction, u8 explode,
604
                                       u16 effect3d, u16 effect3dexplode, u16 effect3dsound )
605
{
606
  _effect_type = Core::PKTOUT_C0::EFFECT_MOVING;
×
607
  _effect = effect;
×
608
  _src = std::move( src );
×
609
  _dst = std::move( dst );
×
610
  _speed = speed;
×
611
  _duration = duration;
×
612
  _direction = direction;
×
613
  _explode = explode;
×
614
  _hue = hue;
×
615
  _render = render;
×
616
  _effect3d = effect3d;
×
617
  _effect3dexplode = effect3dexplode;
×
618
  _effect3dsound = effect3dsound;
×
619
  _layer = 0xFF;
×
620
}
×
621

622
void GraphicEffectExPkt::followEffect( const Core::UObject* center, u16 effect, u8 speed,
×
623
                                       u8 duration, u32 hue, u32 render, u8 layer, u16 effect3d )
624
{
625
  _effect_type = Core::PKTOUT_C0::EFFECT_FIXEDFROM;
×
626
  _src_serial_ext = center->serial_ext;
×
627
  _dst_serial_ext = center->serial_ext;
×
628
  _effect = effect;
×
629
  _src = center->toplevel_pos().xyz();
×
630
  _dst = center->toplevel_pos().xyz();
×
631
  _speed = speed;
×
632
  _duration = duration;
×
633
  _direction = 1;
×
634
  _hue = hue;
×
635
  _render = render;
×
636
  _effect3d = effect3d;
×
637
  _effect3dexplode = 1;
×
638
  _itemid = center->serial_ext;
×
639
  _layer = layer;
×
640
}
×
641

642
void GraphicEffectExPkt::stationaryEffect( Core::Pos3d pos, u16 effect, u8 speed, u8 duration,
×
643
                                           u32 hue, u32 render, u16 effect3d )
644
{
645
  _effect_type = Core::PKTOUT_C0::EFFECT_FIXEDXYZ;
×
646
  _effect = effect;
×
647
  _src = pos;
×
648
  _dst = std::move( pos );
×
649
  _speed = speed;
×
650
  _duration = duration;
×
651
  _direction = 1;
×
652
  _hue = hue;
×
653
  _render = render;
×
654
  _effect3d = effect3d;
×
655
  _effect3dexplode = 1;
×
656
  _layer = 0xFF;
×
657
}
×
658

659
void GraphicEffectExPkt::build()
×
660
{
661
  // C0 part
662
  _p->offset = 1;
×
663
  _p->Write<u8>( _effect_type );
×
664
  _p->Write<u32>( _src_serial_ext );
×
665
  _p->Write<u32>( _dst_serial_ext );
×
666
  _p->WriteFlipped<u16>( _effect );
×
667
  _p->WriteFlipped<u16>( _src.x() );
×
668
  _p->WriteFlipped<u16>( _src.y() );
×
669
  _p->Write<s8>( _src.z() );
×
670
  _p->WriteFlipped<u16>( _dst.x() );
×
671
  _p->WriteFlipped<u16>( _dst.y() );
×
672
  _p->Write<s8>( _dst.z() );
×
673
  _p->Write<u8>( _speed );
×
674
  _p->Write<u8>( _duration );
×
675
  _p->offset += 2;  // u16 unk
×
676
  _p->Write<u8>( _direction );
×
677
  _p->Write<u8>( _explode );
×
678
  _p->WriteFlipped<u32>( _hue );
×
679
  _p->WriteFlipped<u32>( _render );
×
680
  // C7 part
681
  _p->WriteFlipped<u16>( _effect3d );         // see particleffect subdir
×
682
  _p->WriteFlipped<u16>( _effect3dexplode );  // 0 if no explosion
×
683
  _p->WriteFlipped<u16>( _effect3dsound );    // for moving effects, 0 otherwise
×
684
  _p->Write<u32>( _itemid );                  // if target is item (type 2), 0 otherwise
×
685
  _p->Write<u8>( _layer );  //(of the character, e.g left hand, right hand,  0-5,7, 0xff: moving
×
686
  // effect or target is no char)
687
  _p->offset += 2;  // u16 unk_effect
×
688
}
×
689

690
void GraphicEffectExPkt::Send( Client* client )
×
691
{
692
  if ( _p->offset == 1 )
×
693
    build();
×
694
  _p.Send( client, _p->getSize() );
×
695
}
×
696

697

698
HealthBarStatusUpdate::HealthBarStatusUpdate( u32 serial_ext, Color color, bool enable )
371✔
699
    : PktSender(), _serial_ext( serial_ext ), _enable( enable ), _color( color ), _p()
371✔
700
{
701
}
371✔
702
void HealthBarStatusUpdate::build()
46✔
703
{
704
  _p->offset = 1;
46✔
705
  _p->WriteFlipped<u16>( _p->getSize() );
46✔
706
  _p->Write<u32>( _serial_ext );
46✔
707
  _p->WriteFlipped<u16>( 1u );  // unk
46✔
708
  _p->WriteFlipped<u16>( _color );
46✔
709
  _p->Write<u8>( _enable ? 1u : 0u );  // flag
46✔
710
}
46✔
711
void HealthBarStatusUpdate::Send( Client* client )
46✔
712
{
713
  if ( client->ClientType & CLIENTTYPE_UOKR )
46✔
714
  {
715
    if ( _p->offset == 1 )
46✔
716
      build();
46✔
717
    _p.Send( client );
46✔
718
  }
719
}
46✔
720

721

722
MoveChrPkt::MoveChrPkt( const Mobile::Character* chr ) : PktSender(), _chr( chr ), _p() {}
173✔
723

724
void MoveChrPkt::build()
12✔
725
{
726
  _p->offset = 1;
12✔
727
  _p->Write<u32>( _chr->serial_ext );
12✔
728
  _p->WriteFlipped<u16>( _chr->graphic );
12✔
729
  _p->WriteFlipped<u16>( _chr->x() );
12✔
730
  _p->WriteFlipped<u16>( _chr->y() );
12✔
731
  _p->Write<s8>( _chr->z() );
12✔
732
  _p->Write<u8>( ( _chr->dir & 0x80u ) |
12✔
733
                 _chr->facing );  // NOTE, this only includes mask 0x07 of the last MOVE message
12✔
734
  _p->WriteFlipped<u16>( _chr->color );
12✔
735
}
12✔
736
void MoveChrPkt::Send( Client* client )
12✔
737
{
738
  if ( _p->offset == 1 )
12✔
739
    build();
12✔
740
  _p->offset = 15;
12✔
741
  _p->Write<u8>( _chr->get_flag1( client ) );
12✔
742
  _p->Write<u8>( _chr->hilite_color_idx( client->chr ) );
12✔
743
  _p.Send( client );
12✔
744
}
12✔
745
}  // namespace Pol::Network
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc