• 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

0.0
/pol-core/pol/skilladv.cpp
1
/** @file
2
 *
3
 * @par History
4
 */
5

6

7
#include "skilladv.h"
8

9

10
namespace Pol::Core
11
{
12
/* skill advancement:
13
    (essentially, a base-2 logarithm..)
14
    disp     raw              bits  posn
15
    10.0    2048    1000 0000 0000    11
16
    20.0    4096  1 0000 0000 0000    12
17
    30.0      8K                      13
18
    ...
19
    70.0    128K                      17
20
    ...
21
    100.0  1024K                      20
22
    200.0     1M                     ...
23
    220.0     4M                     ...
24
    We care about the high bit, and the next 8 bits of
25
    lesser significance to it.
26
    So, we want to normalize to: 1 bbbb bbbb (n removed)
27
    "bbbb bbbb" is used to generate the "ones.decimal" part of
28
    a "tens ones . decimal" skill value.
29

30
    2047 (  111 1111 1111 )
31
    shift 2 bits:
32
    1 1111 1111
33
    Not greater than 1FFh, so done
34
    skill += (255 * 100) / 256
35
    2048: (1000 0000 0000 )
36
    shift 2 bits:
37
    10 0000 0000
38
    greater than 1FF, so skill += 100, raw >>= 1
39
    1 0000 0000
40
    not greater than 1FF, so stop
41

42
    Note, this function is faster for lower skill values than high ones.
43
    */
44
unsigned short raw_to_base( unsigned int raw )
×
45
{
46
  unsigned short skill = 0;
×
47

48
  // what we're really doing here is skipping up the power of two chain,
49
  // accumulating tens.
50
  while ( raw & 0xFFFFF000Lu )
×
51
  {
52
    raw >>= 1;
×
53
    skill += 100;  // go from 0.0 to 10.0, 10.0 to 20.0, and so forth
×
54
  }
55

56
  if ( raw & 0x800 )
×
57
  {
58
    raw &= 0x7FF;
×
59
    skill += 100;
×
60
  }
61

62
  // now, what's left is the "1 bbbb bbbb" part.
63
  //             (or "0 bbbb bbbb" if less than 1 0000 0000)
64
  // calculate (linearly) the ones digit and decimal point part, using 8 bits
65

66
  skill += static_cast<unsigned short>( raw ) * 100 / 2048;
×
67

68
  return skill;
×
69
}
70

71
unsigned int base_to_raw( unsigned short base )
×
72
{
73
  if ( base < 100 )
×
74
  {
75
    return base * 2048L / 100L;
×
76
  }
NEW
77
  if ( base > 2100 )
×
78
  {
79
    base = 2100;
×
80
  }
81

82
  unsigned int raw = 1024;
×
83
  unsigned short tmpbase = base;
×
84
  int rawadd = 10;
×
85
  while ( tmpbase >= 100 )
×
86
  {
87
    tmpbase -= 100;
×
88
    raw *= 2;
×
89
    rawadd *= 2;
×
90
  }
91
  raw += ( tmpbase * raw / 100L );
×
92

93
  int diff;
94
  while ( ( diff = base - raw_to_base( raw ) ) > 0 )
×
95
  {
96
    if ( diff > 1 )
×
97
      --diff;
×
98
    raw += rawadd * diff;
×
99
  }
100

101
  return raw;
×
102
}
103
}  // 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