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

polserver / polserver / 25939934106

15 May 2026 08:30PM UTC coverage: 60.882% (-0.05%) from 60.929%
25939934106

push

github

turleypol
apply damage for items + evid_damaged

0 of 36 new or added lines in 2 files covered. (0.0%)

1083 existing lines in 14 files now uncovered.

44698 of 73417 relevant lines covered (60.88%)

524562.92 hits per line

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

47.27
/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 "../globals/settings.h"
18
#include "../item/item.h"
19
#include "../network/client.h"
20
#include "../network/pktin.h"
21
#include "../ufunc.h"
22
#include "charactr.h"
23
#include "regions/guardrgn.h"
24

25

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

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

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

90
  u32 serial = cfBEu32( msg->serial );
×
91
  Character* defender = Core::find_character( serial );
×
UNCOV
92
  if ( defender == nullptr )
×
UNCOV
93
    return;
×
94
  if ( !( Core::settingsManager.combat_config.attack_self ) )
×
95
  {
96
    if ( defender->serial == client->chr->serial )
×
97
    {
98
      client->chr->send_highlight();
×
UNCOV
99
      return;
×
100
    }
101
  }
102

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

109
  if ( defender->acct != nullptr )
×
110
  {
UNCOV
111
    if ( Core::JusticeRegion::RunNoCombatCheck( defender->client ) == true )
×
112
    {
113
      client->chr->send_highlight();
×
UNCOV
114
      Core::send_sysmessage( client, "Combat is not allowed in this area." );
×
115
      return;
×
116
    }
117
  }
118
  client->chr->select_opponent( serial );
×
119
}
120
}  // 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