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

polserver / polserver / 25972182398

16 May 2026 08:30PM UTC coverage: 60.836% (-0.07%) from 60.903%
25972182398

Pull #884

github

turleypol
updated dynproperties
Pull Request #884: Attackable item

241 of 527 new or added lines in 26 files covered. (45.73%)

17 existing lines in 7 files now uncovered.

44729 of 73524 relevant lines covered (60.84%)

446850.64 hits per line

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

39.13
/pol-core/pol/mobile/attack.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2005/11/26 MuadDib:   Added update code for updating highlight packet to client.
5
 * - 2005/11/26 Shinigami: added Character check
6
 * - 2005/11/25 MuadDib:   Added distance check in handle_attack.
7
 * - 2006/03/07 MuadDib:   Added Justice Region NoCombat check to attack request.
8
 * - 2009/01/03 MuadDib:   Removed logging of null defenders. Who cares if it's empty :o
9
 */
10

11

12
#include <cstdio>
13

14
#include "../../clib/clib_endian.h"
15
#include "../../clib/rawtypes.h"
16
#include "../cmbtcfg.h"
17
#include "../fnsearch.h"
18
#include "../globals/settings.h"
19
#include "../item/item.h"
20
#include "../network/client.h"
21
#include "../network/pktin.h"
22
#include "../ufunc.h"
23
#include "charactr.h"
24
#include "regions/guardrgn.h"
25

26

27
namespace Pol::Mobile
28
{
29
/*Attackable::Attackable( Character* chr ) : _opp( chr ) {}
30
Attackable::Attackable( Items::Item* item ) : _opp( item )
31
{
32
  if ( !item->is_attackable() )
33
    _opp = nullptr;
34
}*/
35
Attackable::Attackable( Core::UObject* obj ) : _opp( obj )
94✔
36
{
37
  if ( !_opp )
94✔
NEW
38
    return;
×
39
  if ( obj->ismobile() )
94✔
40
    return;
94✔
NEW
41
  if ( auto* item_ = item(); item_ && item_->is_attackable() )
×
NEW
42
    return;
×
NEW
43
  _opp = nullptr;
×
44
}
45

46
Character* Attackable::mobile() const
231✔
47
{
48
  if ( _opp && _opp->ismobile() )
231✔
49
    return static_cast<Character*>( _opp );
63✔
50
  return nullptr;
168✔
51
}
52
Items::Item* Attackable::item() const
8✔
53
{
54
  if ( _opp && _opp->isitem() )
8✔
NEW
55
    return static_cast<Items::Item*>( _opp );
×
56
  return nullptr;
8✔
57
}
58
void Attackable::remove_opponent_of( const Attackable& other )
4✔
59
{
60
  if ( auto* mob = mobile() )
4✔
61
    mob->remove_opponent_of( other );
4✔
NEW
62
  else if ( auto* item_ = item() )
×
NEW
63
    item_->remove_opponent_of( other );
×
64
}
4✔
65
void Attackable::add_opponent_of( Attackable other )
4✔
66
{
67
  if ( auto* mob = mobile() )
4✔
68
    mob->add_opponent_of( std::move( other ) );
4✔
NEW
69
  else if ( auto* item_ = item() )
×
NEW
70
    item_->add_opponent_of( other );
×
71
}
4✔
72
void Attackable::inform_disengaged( const Attackable& disengaged )
4✔
73
{
74
  if ( auto* mob = mobile() )
4✔
75
    mob->inform_disengaged( disengaged );
4✔
NEW
76
  else if ( auto* item_ = item() )
×
NEW
77
    item_->inform_disengaged( disengaged );
×
78
}
4✔
79
void Attackable::inform_engaged( const Attackable& engaged )
5✔
80
{
81
  if ( auto* mob = mobile() )
5✔
82
    mob->inform_engaged( engaged );
5✔
NEW
83
  else if ( auto* item_ = item() )
×
NEW
84
    item_->inform_engaged( engaged );
×
85
}
5✔
86

UNCOV
87
void handle_attack( Network::Client* client, Core::PKTIN_05* msg )
×
88
{
89
  if ( client->chr->dead() )
×
90
  {
91
    private_say_above( client->chr, client->chr, "I am dead and cannot do that." );
×
92
    return;
×
93
  }
94

95
  u32 serial = cfBEu32( msg->serial );
×
NEW
96
  Attackable attackable{ Core::find_toplevel_object( serial ) };
×
NEW
97
  if ( !attackable )
×
98
    return;
×
NEW
99
  if ( auto* defender = attackable.mobile() )
×
100
  {
NEW
101
    if ( !( Core::settingsManager.combat_config.attack_self ) )
×
102
    {
NEW
103
      if ( defender->serial == client->chr->serial )
×
104
      {
NEW
105
        client->chr->send_highlight();
×
NEW
106
        return;
×
107
      }
108
    }
109

NEW
110
    if ( !client->chr->is_visible_to_me( defender ) )
×
111
    {
112
      client->chr->send_highlight();
×
113
      return;
×
114
    }
115

NEW
116
    if ( defender->acct != nullptr )
×
117
    {
NEW
118
      if ( Core::JusticeRegion::RunNoCombatCheck( defender->client ) == true )
×
119
      {
NEW
120
        client->chr->send_highlight();
×
NEW
121
        Core::send_sysmessage( client, "Combat is not allowed in this area." );
×
NEW
122
        return;
×
123
      }
124
    }
125
  }
NEW
126
  else if ( auto* item = attackable.item() )
×
127
  {
NEW
128
    if ( item->invisible() && !client->chr->can_seeinvisitems() )
×
129
    {
NEW
130
      client->chr->send_highlight();
×
NEW
131
      return;
×
132
    }
NEW
133
    if ( !client->chr->in_visual_range( item ) )
×
134
    {
135
      client->chr->send_highlight();
×
136
      return;
×
137
    }
138
  }
NEW
139
  client->chr->select_opponent( std::move( attackable ) );
×
140
}
141
}  // namespace Pol::Mobile
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