• 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

47.96
/pol-core/pol/irequest.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2003/03/15 Dave:      Support configurable max skillid
5
 * - 2009/07/23 MuadDib:   updates for new Enum::Packet Out ID
6
 */
7

8

9
#include <stddef.h>
10

11
#include "../bscript/eprog.h"
12
#include "../clib/clib_endian.h"
13
#include "../clib/logfacility.h"
14
#include "../clib/rawtypes.h"
15
#include "../clib/refptr.h"
16
#include "../plib/systemstate.h"
17
#include "fnsearch.h"
18
#include "globals/network.h"
19
#include "globals/settings.h"
20
#include "item/item.h"
21
#include "mobile/attribute.h"
22
#include "mobile/charactr.h"
23
#include "network/client.h"
24
#include "network/packethelper.h"
25
#include "network/packets.h"
26
#include "network/pktboth.h"
27
#include "network/pktdef.h"
28
#include "network/pktin.h"
29
#include "party.h"
30
#include "scrdef.h"
31
#include "scrstore.h"
32
#include "statmsg.h"
33
#include "ufunc.h"
34
#include "uoclient.h"
35
#include "uoskills.h"
36

37

38
namespace Pol::Core
39
{
NEW
40
void send_short_statmsg( Network::Client* client, Items::Item* item )
×
41
{
NEW
42
  Network::PktHelper::PacketOut<Network::PktOut_11> msg;
×
NEW
43
  msg->offset += 2;  // msglen
×
NEW
44
  msg->Write<u32>( item->serial_ext );
×
NEW
45
  msg->Write( Clib::strUtf8ToCp1252( item->name() ).c_str(), 30, false );
×
46

NEW
47
  msg->WriteFlipped<u16>( Clib::clamp_convert<u16>( item->hp_ * 1000 / item->maxhp() ) );
×
NEW
48
  msg->WriteFlipped<u16>( 1000_u16 );
×
NEW
49
  msg->Write<u8>( 0_u8 );
×
NEW
50
  msg->Write<u8>( 0_u8 );  // moreinfo
×
51

NEW
52
  u16 len = msg->offset;
×
NEW
53
  msg->offset = 1;
×
NEW
54
  msg->WriteFlipped<u16>( len );
×
55

NEW
56
  msg.Send( client, len );
×
NEW
57
}
×
58

59
void statrequest( Network::Client* client, u32 serial )
2✔
60
{
61
  auto chr = client->chr;
2✔
62
  if ( serial == chr->serial )
2✔
63
  {
64
    send_full_statmsg( client, chr );
2✔
65
    return;
2✔
66
  }
67
  Mobile::Character* bob = find_character( serial );
×
68
  if ( !bob )
×
69
  {
NEW
70
    auto* item = system_find_item( serial );
×
NEW
71
    if ( !item || !item->is_attackable() )
×
NEW
72
      return;
×
NEW
73
    if ( item->invisible() && !client->chr->can_seeinvisitems() )
×
NEW
74
      return;
×
NEW
75
    if ( !client->chr->in_visual_range( item ) )
×
NEW
76
      return;
×
NEW
77
    send_short_statmsg( client, item );
×
78
    return;
×
79
  }
80
  if ( chr->is_visible_to_me( bob ) )
×
81
    send_short_statmsg( client, bob );
×
82
  if ( chr->has_party() )
×
83
    chr->party()->send_stat_to( chr, bob );
×
84
}
85

86
void send_skillmsg( Network::Client* client, const Mobile::Character* chr )
2✔
87
{
88
  Network::PktHelper::PacketOut<Network::PktOut_3A> msg;
2✔
89
  msg->offset += 2;
2✔
90
  if ( settingsManager.ssopt.core_sends_caps )
2✔
91
    msg->Write<u8>( PKTBI_3A_VALUES::FULL_LIST_CAP );
×
92
  else
93
    msg->Write<u8>( PKTBI_3A_VALUES::FULL_LIST );
2✔
94

95
  for ( unsigned short i = 0; i <= networkManager.uoclient_general.maxskills; ++i )
118✔
96
  {
97
    const UOSkill& uoskill = GetUOSkill( i );
116✔
98
    msg->WriteFlipped<u16>( static_cast<u16>( i + 1 ) );  // for some reason, we send this 1-based
116✔
99
    if ( uoskill.pAttr )
116✔
100
    {
101
      const Mobile::AttributeValue& av = chr->attribute( uoskill.pAttr->attrid );
94✔
102
      int value;
103
      value = av.effective_tenths();
94✔
104
      if ( value > 0xFFFF )
94✔
105
        value = 0xFFFF;
×
106
      msg->WriteFlipped<u16>( static_cast<u16>( value ) );
94✔
107

108
      value = av.base();
94✔
109
      if ( value > 0xFFFF )
94✔
110
        value = 0xFFFF;
×
111
      msg->WriteFlipped<u16>( static_cast<u16>( value ) );
94✔
112
      msg->Write<u8>( av.lock() );
94✔
113
      if ( settingsManager.ssopt.core_sends_caps )
94✔
114
        msg->WriteFlipped<u16>( av.cap() );
×
115
    }
116
    else
117
    {
118
      msg->offset += 4;  // u16 value/value_unmod
22✔
119
      msg->Write<u8>( PKTBI_3A_VALUES::LOCK_DOWN );
22✔
120
      if ( settingsManager.ssopt.core_sends_caps )
22✔
121
        msg->WriteFlipped<u16>( settingsManager.ssopt.default_attribute_cap );
×
122
    }
123
  }
124
  if ( !settingsManager.ssopt.core_sends_caps )
2✔
125
    msg->offset += 2;  // u16 nullterm
2✔
126
  u16 len = msg->offset;
2✔
127
  msg->offset = 1;
2✔
128
  msg->WriteFlipped<u16>( len );
2✔
129
  msg.Send( client, len );
2✔
130
}
2✔
131

132
void handle_skill_lock( Network::Client* client, PKTBI_3A_LOCKS* msg )
×
133
{
134
  if ( settingsManager.ssopt.core_handled_locks )
×
135
  {
136
    unsigned int skillid = cfBEu16( msg->skillid );
×
137
    if ( skillid > networkManager.uoclient_general.maxskills )
×
138
      return;
×
139

140
    const UOSkill& uoskill = GetUOSkill( skillid );
×
141
    if ( !uoskill.pAttr )  // tried to set lockstate for a skill that isn't defined
×
142
      return;
×
143

144
    if ( msg->lock_mode < 3 )
×
145
      client->chr->attribute( uoskill.pAttr->attrid ).lock( msg->lock_mode );
×
146
    else
147
      INFO_PRINTLN( "Client {} tried to set an illegal lock state.", client->chr->name() );
×
148
  }
149
}
150

151
void skillrequest( Network::Client* client, u32 serial )
2✔
152
{
153
  if ( serial == client->chr->serial )
2✔
154
  {
155
    ScriptDef sd;
2✔
156
    sd.quickconfig( "scripts/misc/skillwin.ecl" );
2✔
157
    if ( sd.exists() )
2✔
158
    {
159
      ref_ptr<Bscript::EScriptProgram> prog;
×
160
      prog = find_script2( sd,
×
161
                           false,  // complain if not found
162
                           Plib::systemstate.config.cache_interactive_scripts );
×
163
      if ( prog.get() != nullptr && client->chr->start_script( prog.get(), false ) )
×
164
      {
165
        return;
×
166
      }
167
    }
×
168
    send_skillmsg( client, client->chr );
2✔
169
  }
2✔
170
}
171

172
void srequest( Network::Client* client, PKTIN_34* msg )
4✔
173
{
174
  u32 serial = cfBEu32( msg->serial2 );
4✔
175

176
  if ( msg->stattype == STATTYPE_STATWINDOW )
4✔
177
    statrequest( client, serial );
2✔
178
  else if ( msg->stattype == STATTYPE_SKILLWINDOW )
2✔
179
    skillrequest( client, serial );
2✔
180
}
4✔
181
}  // namespace Pol::Core
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