• 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

28.85
/pol-core/pol/module/vitalmod.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2006/10/07 Shinigami: GCC 3.4.x fix - added "template<>" to TmplExecutorModule
5
 * - 2009/09/22 Turley:    repsys param to applydamage
6
 * - 2009/11/20 Turley:    RecalcVitals can update single Attributes/Vitals - based on Tomi
7
 * - 2010/01/15 Turley:    (Tomi) send damage param ApplyDamage/ApplyRawDamage
8
 */
9

10

11
#include "vitalmod.h"
12
#include "../../bscript/berror.h"
13
#include "../../bscript/bobject.h"
14
#include "../../bscript/impstr.h"
15
#include "../cmbtcfg.h"
16
#include "../globals/settings.h"
17
#include "../mobile/attribute.h"
18
#include "../mobile/charactr.h"
19
#include "../spells.h"
20
#include "../ufunc.h"
21
#include "../vital.h"
22

23
#include <module_defs/vitals.h>
24

25

26
namespace Pol::Module
27
{
28
using namespace Bscript;
29

30
VitalExecutorModule::VitalExecutorModule( Bscript::Executor& exec )
371✔
31
    : Bscript::TmplExecutorModule<VitalExecutorModule, Core::PolModule>( exec )
371✔
32
{
33
}
371✔
34

35
BObjectImp* VitalExecutorModule::mf_ApplyRawDamage()
×
36
{
37
  Mobile::Character* chr;
38
  int damage;
39
  int userepsys;
40
  int send_damage_packet;
41
  if ( getCharacterParam( 0, chr ) && getParam( 1, damage ) && getParam( 2, userepsys ) &&
×
42
       getParam( 3, send_damage_packet ) && damage >= 0 && damage <= USHRT_MAX )
×
43
  {
44
    bool send_dmg = send_damage_packet == 2 ? Core::settingsManager.combat_config.send_damage_packet
×
45
                                            : ( send_damage_packet > 0 ? true : false );
×
46
    chr->apply_raw_damage_hundredths( static_cast<unsigned int>( damage * 100 ), GetUOController(),
×
47
                                      userepsys > 0 ? true : false, send_dmg );
48
    return new BLong( 1 );
×
49
  }
NEW
50
  return new BLong( 0 );
×
51
}
52

53
BObjectImp* VitalExecutorModule::mf_ApplyDamage()
×
54
{
55
  Mobile::Character* chr;
56
  double damage;
57
  int userepsys;
58
  int send_damage_packet;
59
  if ( getCharacterParam( 0, chr ) && getRealParam( 1, damage ) && getParam( 2, userepsys ) &&
×
60
       getParam( 3, send_damage_packet ) )
×
61
  {
62
    if ( damage >= 0.0 && damage <= 30000.0 )
×
63
    {
64
      bool send_dmg = send_damage_packet == 2
×
65
                          ? Core::settingsManager.combat_config.send_damage_packet
×
66
                          : ( send_damage_packet > 0 ? true : false );
×
67
      damage = chr->apply_damage( static_cast<unsigned short>( damage ), GetUOController(),
×
68
                                  userepsys > 0 ? true : false, send_dmg );
69
      return new BLong( static_cast<int>( damage ) );
×
70
    }
NEW
71
    return new BError( "Damage is out of range" );
×
72
  }
NEW
73
  return new BError( "Invalid parameter type" );
×
74
}
75

76
BObjectImp* VitalExecutorModule::mf_HealDamage()
×
77
{
78
  Mobile::Character* chr;
79
  int amount;
80
  if ( getCharacterParam( 0, chr ) && getParam( 1, amount ) && amount >= 0 && amount <= USHRT_MAX )
×
81
  {
82
    Mobile::Character* controller = GetUOController();
×
83
    if ( controller )
×
84
      controller->repsys_on_help( chr );
×
85

86
    chr->heal_damage_hundredths( static_cast<unsigned short>( amount ) * 100L );
×
87
    return new BLong( 1 );
×
88
  }
89

NEW
90
  return new BError( "Invalid parameter" );
×
91
}
92

93
BObjectImp* VitalExecutorModule::mf_ConsumeMana()
×
94
{
95
  Mobile::Character* chr;
96
  int spellid;
97
  if ( getCharacterParam( 0, chr ) && getParam( 1, spellid ) )
×
98
  {
99
    if ( !Core::VALID_SPELL_ID( spellid ) )
×
100
      return new BError( "Spell ID out of range" );
×
101

102
    Core::USpell* spell = Core::gamestate.spells[spellid];
×
103
    if ( spell == nullptr )
×
104
      return new BError( "No such spell" );
×
NEW
105
    if ( spell->check_mana( chr ) == false )
×
106
      return new BLong( 0 );
×
107

108
    spell->consume_mana( chr );
×
109
    if ( chr->has_active_client() )
×
110
      Core::send_mana_level( chr->client );
×
111

112
    return new BLong( 1 );
×
113
  }
114

NEW
115
  return new BError( "Invalid parameter" );
×
116
}
117

118
BObjectImp* VitalExecutorModule::mf_GetVitalName( /* alias_name */ )
×
119
{
120
  const Core::Vital* vital;
121

122
  if ( !getVitalParam( 0, vital ) )
×
123
  {
124
    return new BError( "Invalid parameter type." );
×
125
  }
126

127
  return new String( vital->name );
×
128
}
129

130
BObjectImp* VitalExecutorModule::mf_GetVital( /* mob, vitalid */ )
11✔
131
{
132
  Mobile::Character* chr;
133
  const Core::Vital* vital;
134

135
  if ( getCharacterParam( 0, chr ) && getVitalParam( 1, vital ) )
11✔
136
  {
137
    const Mobile::VitalValue& vv = chr->vital( vital->vitalid );
11✔
138
    return new BLong( vv.current() );
11✔
139
  }
NEW
140
  return new BError( "Invalid parameter type" );
×
141
}
142

143
BObjectImp* VitalExecutorModule::mf_GetVitalMaximumValue( /* mob, vitalid */ )
6✔
144
{
145
  Mobile::Character* chr;
146
  const Core::Vital* vital;
147

148
  if ( getCharacterParam( 0, chr ) && getVitalParam( 1, vital ) )
6✔
149
  {
150
    const Mobile::VitalValue& vv = chr->vital( vital->vitalid );
6✔
151
    return new BLong( vv.maximum() );
6✔
152
  }
NEW
153
  return new BError( "Invalid parameter type" );
×
154
}
155

156
BObjectImp* VitalExecutorModule::mf_GetVitalRegenRate( /* mob, vitalid */ )
×
157
{
158
  Mobile::Character* chr;
159
  const Core::Vital* vital;
160

161
  if ( getCharacterParam( 0, chr ) && getVitalParam( 1, vital ) )
×
162
  {
163
    const Mobile::VitalValue& vv = chr->vital( vital->vitalid );
×
164
    return new BLong( vv.regenrate() );
×
165
  }
NEW
166
  return new BError( "Invalid parameter type" );
×
167
}
168

169
BObjectImp* VitalExecutorModule::mf_SetVital( /* mob, vitalid, hundredths */ )
9✔
170
{
171
  Mobile::Character* chr;
172
  const Core::Vital* vital;
173
  int value;
174

175
  if ( getCharacterParam( 0, chr ) && getVitalParam( 1, vital ) &&
18✔
176
       getParam( 2, value, Core::VITAL_MAX_HUNDREDTHS ) )
9✔
177
  {
178
    Mobile::VitalValue& vv = chr->vital( vital->vitalid );
9✔
179
    chr->set_current( vital, vv, value, Mobile::Character::VitalDepletedReason::SCRIPT );
9✔
180
    return new BLong( 1 );
9✔
181
  }
NEW
182
  return new BError( "Invalid parameter type" );
×
183
}
184

185
BObjectImp* VitalExecutorModule::mf_ConsumeVital( /* mob, vital, hundredths */ )
×
186
{
187
  Mobile::Character* chr;
188
  const Core::Vital* vital;
189
  int hundredths;
190

191
  if ( getCharacterParam( 0, chr ) && getVitalParam( 1, vital ) &&
×
192
       getParam( 2, hundredths, Core::VITAL_MAX_HUNDREDTHS ) )
×
193
  {
194
    Mobile::VitalValue& vv = chr->vital( vital->vitalid );
×
195
    bool res =
196
        chr->consume( vital, vv, hundredths, Mobile::Character::VitalDepletedReason::SCRIPT );
×
197
    return new BLong( res ? 1 : 0 );
×
198
  }
NEW
199
  return new BError( "Invalid parameter type" );
×
200
}
201

202
BObjectImp* VitalExecutorModule::mf_RecalcVitals( /* mob, attributes, vitals */ )
2✔
203
{
204
  Mobile::Character* chr;
205
  BObjectImp* param1 = getParamImp( 1 );
2✔
206
  BObjectImp* param2 = getParamImp( 2 );
2✔
207

208
  if ( getCharacterParam( 0, chr ) && param1 != nullptr && param2 != nullptr )
2✔
209
  {
210
    if ( chr->logged_in() )
2✔
211
    {
212
      bool calc_attr = false;
2✔
213
      bool calc_vital = false;
2✔
214

215
      if ( auto* v = impptrIf<BLong>( param1 ) )
2✔
216
        calc_attr = v->isTrue();
2✔
217
      else if ( auto* attrname = impptrIf<String>( param1 ) )
×
218
      {
219
        Mobile::Attribute* attr = Mobile::Attribute::FindAttribute( attrname->value() );
×
220
        if ( attr == nullptr )
×
221
          return new BError( "Attribute not defined: " + attrname->value() );
×
222
        chr->calc_single_attribute( attr );
×
223
      }
224
      else
225
        return new BError( "Invalid parameter type" );
×
226

227
      if ( auto* v = impptrIf<BLong>( param2 ) )
2✔
228
        calc_vital = v->isTrue();
2✔
229
      else if ( auto* vitalname = impptrIf<String>( param2 ) )
×
230
      {
231
        Core::Vital* vital = Core::FindVital( vitalname->value() );
×
232
        if ( vital == nullptr )
×
233
          return new BError( "Vital not defined: " + vitalname->value() );
×
234
        chr->calc_single_vital( vital );
×
235
      }
236
      else
237
        return new BError( "Invalid parameter type" );
×
238

239
      chr->calc_vital_stuff( calc_attr, calc_vital );
2✔
240
      return new BLong( 1 );
2✔
241
    }
NEW
242
    return new BError( "Mobile must be online." );
×
243
  }
NEW
244
  return new BError( "Invalid parameter type" );
×
245
}
246
}  // 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