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

polserver / polserver / 25990848974

17 May 2026 12:27PM UTC coverage: 60.822% (-0.08%) from 60.903%
25990848974

Pull #884

github

turleypol
listhostiles and attack_once accept now Attackable
Pull Request #884: Attackable item

268 of 575 new or added lines in 26 files covered. (46.61%)

17 existing lines in 7 files now uncovered.

44719 of 73524 relevant lines covered (60.82%)

513395.8 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 "attack.h"
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( Core::UObject* obj ) : _opp( obj )
94✔
30
{
31
  if ( !_opp )
94✔
NEW
32
    return;
×
33
  if ( obj->ismobile() )
94✔
34
    return;
94✔
NEW
35
  if ( auto* item_ = item(); item_ && item_->is_attackable() )
×
NEW
36
    return;
×
NEW
37
  _opp = nullptr;
×
38
}
39

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

UNCOV
81
void handle_attack( Network::Client* client, Core::PKTIN_05* msg )
×
82
{
83
  if ( client->chr->dead() )
×
84
  {
85
    private_say_above( client->chr, client->chr, "I am dead and cannot do that." );
×
86
    return;
×
87
  }
88

89
  u32 serial = cfBEu32( msg->serial );
×
NEW
90
  Attackable attackable{ Core::find_toplevel_object( serial ) };
×
NEW
91
  if ( !attackable )
×
92
    return;
×
NEW
93
  if ( auto* defender = attackable.mobile() )
×
94
  {
NEW
95
    if ( !( Core::settingsManager.combat_config.attack_self ) )
×
96
    {
NEW
97
      if ( defender->serial == client->chr->serial )
×
98
      {
NEW
99
        client->chr->send_highlight();
×
NEW
100
        return;
×
101
      }
102
    }
103

NEW
104
    if ( !client->chr->is_visible_to_me( defender ) )
×
105
    {
106
      client->chr->send_highlight();
×
107
      return;
×
108
    }
109

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