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

polserver / polserver / 21108840797

18 Jan 2026 08:35AM UTC coverage: 60.508% (+0.02%) from 60.492%
21108840797

push

github

web-flow
ClangTidy readability-else-after-return (#857)

* trigger tidy

* Automated clang-tidy change: readability-else-after-return

* compile test

* rerun

* Automated clang-tidy change: readability-else-after-return

* trigger..

* Automated clang-tidy change: readability-else-after-return

* manually removed a few

* Automated clang-tidy change: readability-else-after-return

* removed duplicate code

* fix remaining warnings

* fixed scope

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>

837 of 1874 new or added lines in 151 files covered. (44.66%)

46 existing lines in 25 files now uncovered.

44448 of 73458 relevant lines covered (60.51%)

525066.38 hits per line

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

41.67
/pol-core/pol/module/attributemod.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2006/10/07 Shinigami: GCC 3.4.x fix - added "template<>" to TmplExecutorModule
5
 */
6

7

8
#include "attributemod.h"
9
#include "../../bscript/berror.h"
10
#include "../../bscript/impstr.h"
11
#include "../globals/uvars.h"
12
#include "../mobile/attribute.h"
13
#include "../mobile/charactr.h"
14
#include "../network/cliface.h"
15
#include "../skilladv.h"
16
#include "../skillid.h"
17

18
#include "../polmodl.h"
19

20
#include <module_defs/attributes.h>
21

22

23
namespace Pol::Module
24
{
25
using namespace Bscript;
26
using namespace Mobile;
27

28
AttributeExecutorModule::AttributeExecutorModule( Executor& exec )
371✔
29
    : TmplExecutorModule<AttributeExecutorModule, Core::PolModule>( exec )
371✔
30
{
31
}
371✔
32

33
Bscript::BObjectImp* AttributeExecutorModule::mf_CheckSkill()
×
34
{
35
  Mobile::Character* chr;
36
  Core::USKILLID skillid;
37
  int difficulty;
38
  unsigned short points;
39

40
  if ( getCharacterParam( 0, chr ) && getSkillIdParam( 1, skillid ) && getParam( 2, difficulty ) &&
×
41
       getParam( 3, points ) )
×
42
  {
43
    return new Bscript::BLong( chr->check_skill( skillid, difficulty, points ) );
×
44
  }
45

NEW
46
  return new Bscript::BError( "Invalid parameter" );
×
47
}
48

49
Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttributeName( /* alias_name */ )
×
50
{
51
  const Attribute* attr;
52

53
  if ( !getAttributeParam( 0, attr ) )
×
54
  {
55
    return new Bscript::BError( "Invalid parameter type." );
×
56
  }
57

58
  return new Bscript::String( attr->name );
×
59
}
60

61
Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttributeDefaultCap( /* alias_name */ )
×
62
{
63
  const Attribute* attr;
64

65
  if ( !getAttributeParam( 0, attr ) )
×
66
  {
67
    return new Bscript::BError( "Invalid parameter type." );
×
68
  }
69

70
  return new Bscript::BLong( attr->default_cap );
×
71
}
72

73
Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttribute( /* mob, attrname, precision */ )
261✔
74
{
75
  Character* chr;
76
  const Attribute* attr;
77
  short precision;
78

79
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) && getParam( 2, precision ) )
261✔
80
  {
81
    const AttributeValue& av = chr->attribute( attr->attrid );
261✔
82
    return new Bscript::BLong( precision == 1 ? av.effective_tenths() : av.effective() );
261✔
83
  }
84

NEW
85
  return new Bscript::BError( "Invalid parameter type" );
×
86
}
87

88
Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttributeBaseValue( /* mob, attrname */ )
2✔
89
{
90
  Character* chr;
91
  const Attribute* attr;
92

93
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) )
2✔
94
  {
95
    const AttributeValue& av = chr->attribute( attr->attrid );
2✔
96
    return new Bscript::BLong( av.base() );
2✔
97
  }
98

NEW
99
  return new Bscript::BError( "Invalid parameter type" );
×
100
}
101

102
Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttributeTemporaryMod( /* mob, attrname */ )
×
103
{
104
  Character* chr;
105
  const Attribute* attr;
106

107
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) )
×
108
  {
109
    const AttributeValue& av = chr->attribute( attr->attrid );
×
110
    return new Bscript::BLong( av.temp_mod() );
×
111
  }
112

NEW
113
  return new Bscript::BError( "Invalid parameter type" );
×
114
}
115

116
Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttributeIntrinsicMod( /* mob, attrname */ )
×
117
{
118
  Character* chr;
119
  const Attribute* attr;
120

121
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) )
×
122
  {
123
    const AttributeValue& av = chr->attribute( attr->attrid );
×
124
    return new Bscript::BLong( av.intrinsic_mod() );
×
125
  }
126

NEW
127
  return new Bscript::BError( "Invalid parameter type" );
×
128
}
129

130
Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttributeLock( /* mob, attrname */ )
2✔
131
{
132
  Character* chr;
133
  const Attribute* attr;
134

135
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) )
2✔
136
  {
137
    const AttributeValue& av = chr->attribute( attr->attrid );
2✔
138
    return new Bscript::BLong( av.lock() );
2✔
139
  }
140

NEW
141
  return new Bscript::BError( "Invalid parameter type" );
×
142
}
143
Bscript::BObjectImp* AttributeExecutorModule::mf_GetAttributeCap( /* mob, attrname */ )
2✔
144
{
145
  Character* chr;
146
  const Attribute* attr;
147

148
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) )
2✔
149
  {
150
    const AttributeValue& av = chr->attribute( attr->attrid );
2✔
151
    return new Bscript::BLong( av.cap() );
2✔
152
  }
153

NEW
154
  return new Bscript::BError( "Invalid parameter type" );
×
155
}
156

157
Bscript::BObjectImp* AttributeExecutorModule::mf_SetAttributeCap( /* mob, attributeid, capvalue */ )
2✔
158
{
159
  Character* chr;
160
  const Attribute* attr;
161
  unsigned short capvalue;
162

163
  // FIXME: SetAttributeCap(mob, attributeid) should reset cap to default value :)
164

165
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) &&
4✔
166
       getParam( 2, capvalue, ATTRIBUTE_MIN_BASE, ATTRIBUTE_MAX_BASE ) )
2✔
167
  {
168
    chr->set_dirty();
2✔
169
    AttributeValue& av = chr->attribute( attr->attrid );
2✔
170
    int old_cap = av.cap();
2✔
171
    av.cap( capvalue );
2✔
172

173
    if ( old_cap != capvalue )
2✔
174
    {
175
      Network::ClientInterface::tell_attribute_changed( chr, attr );
2✔
176
    }
177

178
    return new Bscript::BLong( 1 );
2✔
179
  }
180

NEW
181
  return new Bscript::BError( "Invalid parameter type" );
×
182
}
183

184
Bscript::BObjectImp* AttributeExecutorModule::mf_SetAttributeLock(
2✔
185
    /* mob, attributeid, lockstate */ )
186
{
187
  Character* chr;
188
  const Attribute* attr;
189
  unsigned short lockstate;
190

191
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) &&
4✔
192
       getParam( 2, lockstate, 0,
2✔
193
                 2 ) )  // FIXME: hard-coded lock states min and max (0 and 2) -- Nando
194
  {
195
    chr->set_dirty();
2✔
196
    AttributeValue& av = chr->attribute( attr->attrid );
2✔
197

198
    unsigned char old_state = av.lock();
2✔
199
    av.lock( (unsigned char)lockstate );
2✔
200

201
    if ( old_state != lockstate )
2✔
202
    {
203
      Network::ClientInterface::tell_attribute_changed( chr, attr );
2✔
204
    }
205

206
    return new Bscript::BLong( 1 );
2✔
207
  }
208

NEW
209
  return new Bscript::BError( "Invalid parameter type" );
×
210
}
211

212
Bscript::BObjectImp* AttributeExecutorModule::mf_SetAttributeBaseValue(
8✔
213
    /* mob, attributeid, basevalue */ )
214
{
215
  Character* chr;
216
  const Attribute* attr;
217
  unsigned short basevalue;
218

219
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) &&
16✔
220
       getParam( 2, basevalue, ATTRIBUTE_MIN_BASE, ATTRIBUTE_MAX_BASE ) )
8✔
221
  {
222
    chr->set_dirty();
8✔
223
    AttributeValue& av = chr->attribute( attr->attrid );
8✔
224
    int eff = av.effective_tenths();
8✔
225
    av.base( basevalue );
8✔
226

227
    if ( eff != av.effective_tenths() )
8✔
228
    {
229
      Network::ClientInterface::tell_attribute_changed( chr, attr );
8✔
230
      if ( attr->attrid == Core::gamestate.pAttrParry->attrid )
8✔
231
      {
232
        if ( chr->has_shield() )
×
233
          chr->refresh_ar();
×
234
      }
235
    }
236

237
    return new Bscript::BLong( 1 );
8✔
238
  }
239

NEW
240
  return new Bscript::BError( "Invalid parameter type" );
×
241
}
242

243
Bscript::BObjectImp* AttributeExecutorModule::mf_SetAttributeTemporaryMod(
×
244
    /* mob, attributeid, temporary_mod */ )
245
{
246
  Character* chr;
247
  const Attribute* attr;
248
  int tempmod;
249

250
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) &&
×
251
       getParam( 2, tempmod, ATTRIBUTE_MIN_TEMP_MOD, ATTRIBUTE_MAX_TEMP_MOD ) )
×
252
  {
253
    AttributeValue& av = chr->attribute( attr->attrid );
×
254
    int eff = av.effective_tenths();
×
255
    av.temp_mod( static_cast<short>( tempmod ) );
×
256

257
    if ( eff != av.effective_tenths() )
×
258
    {
259
      Network::ClientInterface::tell_attribute_changed( chr, attr );
×
260
      if ( attr->attrid == Core::gamestate.pAttrParry->attrid )
×
261
      {
262
        if ( chr->has_shield() )
×
263
          chr->refresh_ar();
×
264
      }
265
    }
266

267
    return new Bscript::BLong( 1 );
×
268
  }
269

NEW
270
  return new Bscript::BError( "Invalid parameter type" );
×
271
}
272

273
Bscript::BObjectImp* AttributeExecutorModule::mf_AlterAttributeTemporaryMod(
×
274
    /* mob, attributeid, temporary_mod */ )
275
{
276
  Character* chr;
277
  const Attribute* attr;
278
  int delta;
279

280
  if ( getCharacterParam( 0, chr ) && getAttributeParam( 1, attr ) && getParam( 2, delta ) )
×
281
  {
282
    AttributeValue& av = chr->attribute( attr->attrid );
×
283
    int eff = av.effective_tenths();
×
284
    int newmod = av.temp_mod() + delta;
×
285

286
    if ( newmod < ATTRIBUTE_MIN_TEMP_MOD || newmod > ATTRIBUTE_MAX_TEMP_MOD )
×
287
      return new BError( "New modifier value is out of range" );
×
288

289
    av.temp_mod( static_cast<short>( newmod ) );
×
290

291
    if ( eff != av.effective_tenths() )
×
292
    {
293
      Network::ClientInterface::tell_attribute_changed( chr, attr );
×
294
      if ( attr->attrid == Core::gamestate.pAttrParry->attrid )
×
295
      {
296
        if ( chr->has_shield() )
×
297
          chr->refresh_ar();
×
298
      }
299
    }
300

301
    return new Bscript::BLong( 1 );
×
302
  }
303

NEW
304
  return new Bscript::BError( "Invalid parameter type" );
×
305
}
306

307

308
Bscript::BObjectImp* AttributeExecutorModule::mf_RawSkillToBaseSkill()
×
309
{
310
  int rawskill;
311
  if ( getParam( 0, rawskill ) )
×
312
  {
313
    if ( rawskill < 0 )
×
314
      rawskill = 0;
×
315
    return new Bscript::BLong( Core::raw_to_base( rawskill ) );
×
316
  }
317

NEW
318
  return new Bscript::BError( "Invalid parameter type" );
×
319
}
320

321
Bscript::BObjectImp* AttributeExecutorModule::mf_BaseSkillToRawSkill()
×
322
{
323
  unsigned short baseskill;
324
  if ( getParam( 0, baseskill ) )
×
325
    return new Bscript::BLong( Core::base_to_raw( baseskill ) );
×
NEW
326
  return new Bscript::BError( "Invalid parameter type" );
×
327
}
328
}  // namespace Pol::Module
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