• 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

84.62
/pol-core/pol/movement.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2009/07/23 MuadDib:   updates for new Enum::Packet Out ID
5
 * - 2009/09/03 MuadDib:   Relocation of multi related cpp/h
6
 * - 2010/01/22 Turley:    Speedhack Prevention System
7
 */
8

9

10
#include <stddef.h>
11

12
#include "../clib/rawtypes.h"
13
#include "../plib/uconst.h"
14
#include "mobile/charactr.h"
15
#include "multi/customhouses.h"
16
#include "multi/house.h"
17
#include "multi/multi.h"
18
#include "network/client.h"
19
#include "network/packetdefs.h"
20
#include "network/packethelper.h"
21
#include "network/packets.h"
22
#include "network/pktdef.h"
23
#include "network/pktin.h"
24
#include "ufunc.h"
25
#include "uworld.h"
26

27

28
namespace Pol::Core
29
{
30
void cancel_trade( Mobile::Character* chr1 );
31

32
void send_char_if_newly_inrange( Mobile::Character* chr, Network::Client* client )
97✔
33
{
34
  if ( !client->chr->lastpos.in_range( chr->pos(), client->chr->los_size() ) &&
97✔
35
       client->chr->is_visible_to_me( chr ) && client->chr != chr )
97✔
36
  {
37
    send_owncreate( client, chr );
6✔
38
  }
39
}
97✔
40

41
void send_item_if_newly_inrange( Items::Item* item, Network::Client* client )
224✔
42
{
43
  if ( client->chr->in_visual_range( item ) &&
312✔
44
       !client->chr->lastpos.in_range( item->pos(),
88✔
45
                                       item->visible_size() + client->chr->los_size() ) )
88✔
46
  {
47
    send_item( client, item );
30✔
48
  }
49
}
224✔
50

51
void send_multi_if_newly_inrange( Multi::UMulti* multi, Network::Client* client )
14✔
52
{
53
  if ( client->chr->in_visual_range( multi ) &&
23✔
54
       !client->chr->lastpos.in_range( multi->pos(),
9✔
55
                                       client->chr->los_size() + multi->visible_size() ) )
9✔
56
  {
57
    send_multi( client, multi );
4✔
58
    Multi::UHouse* house = multi->as_house();
4✔
59
    if ( client->acctSupports( Plib::ExpansionVersion::AOS ) && house != nullptr &&
5✔
60
         house->IsCustom() )
1✔
61
      Multi::CustomHousesSendShort( house, client );
×
62
  }
63
}
14✔
64

65
void send_objects_newly_inrange( Network::Client* client )
84✔
66
{
67
  Mobile::Character* chr = client->chr;
84✔
68

69
  WorldIterator<MobileFilter>::InRange( chr, chr->los_size(), [&]( Mobile::Character* zonechr )
84✔
70
                                        { send_char_if_newly_inrange( zonechr, client ); } );
95✔
71
  WorldIterator<ItemFilter>::InMaxVisualRange(
84✔
72
      chr, [&]( Items::Item* zoneitem ) { send_item_if_newly_inrange( zoneitem, client ); } );
308✔
73
  WorldIterator<MultiFilter>::InMaxVisualRange(
84✔
74
      chr, [&]( Multi::UMulti* zonemulti ) { send_multi_if_newly_inrange( zonemulti, client ); } );
98✔
75
}
84✔
76

77
void send_objects_newly_inrange_on_boat( Network::Client* client, u32 serial )
19✔
78
{
79
  Mobile::Character* chr = client->chr;
19✔
80
  if ( client->ClientType & Network::CLIENTTYPE_7090 )
19✔
81
  {
82
    WorldIterator<MobileFilter>::InRange(
19✔
83
        chr, chr->los_size(),
19✔
84
        [&]( Mobile::Character* zonechr )
19✔
85
        {
86
          Multi::UMulti* multi = zonechr->realm()->find_supporting_multi( zonechr->pos3d() );
21✔
87

88
          if ( multi != nullptr && multi->serial == serial )
21✔
89
            return;
19✔
90

91
          send_char_if_newly_inrange( zonechr, client );
2✔
92
        } );
93
    WorldIterator<ItemFilter>::InMaxVisualRange(
19✔
94
        chr,
95
        [&]( Items::Item* zoneitem )
19✔
96
        {
97
          Multi::UMulti* multi = zoneitem->realm()->find_supporting_multi( zoneitem->pos3d() );
6,077✔
98

99
          if ( multi != nullptr && multi->serial == serial )
6,077✔
100
            return;
6,077✔
101

102
          send_item_if_newly_inrange( zoneitem, client );
×
103
        } );
104
    WorldIterator<MultiFilter>::InMaxVisualRange( chr,
19✔
105
                                                  [&]( Multi::UMulti* zonemulti )
19✔
106
                                                  {
107
                                                    if ( zonemulti->serial == serial )
19✔
108
                                                      return;
19✔
109

110
                                                    send_multi_if_newly_inrange( zonemulti,
×
111
                                                                                 client );
×
112
                                                  } );
113
  }
114
  else
115
  {
116
    WorldIterator<MobileFilter>::InRange( chr, chr->los_size(), [&]( Mobile::Character* zonechr )
×
117
                                          { send_char_if_newly_inrange( zonechr, client ); } );
×
118
    WorldIterator<ItemFilter>::InMaxVisualRange(
×
119
        chr, [&]( Items::Item* zoneitem ) { send_item_if_newly_inrange( zoneitem, client ); } );
×
120
    WorldIterator<MultiFilter>::InMaxVisualRange(
×
121
        chr,
122
        [&]( Multi::UMulti* zonemulti ) { send_multi_if_newly_inrange( zonemulti, client ); } );
×
123
  }
124
}
19✔
125

126
void remove_objects_inrange( Network::Client* client )
14✔
127
{
128
  Mobile::Character* chr = client->chr;
14✔
129
  Network::RemoveObjectPkt msgremove( chr->serial_ext );
14✔
130

131
  WorldIterator<MobileFilter>::InRange( chr, chr->los_size(), [&]( Mobile::Character* zonechar )
14✔
132
                                        { send_remove_character( client, zonechar, msgremove ); } );
15✔
133
  WorldIterator<ItemFilter>::InMaxVisualRange( chr,
14✔
134
                                               [&]( Items::Item* item )
14✔
135
                                               {
136
                                                 if ( chr->in_visual_range( item ) )
28✔
137
                                                   send_remove_object( client, item, msgremove );
13✔
138
                                               } );
28✔
139
  WorldIterator<MultiFilter>::InMaxVisualRange( chr,
14✔
140
                                                [&]( Multi::UMulti* multi )
14✔
141
                                                {
142
                                                  if ( chr->in_visual_range( multi ) )
3✔
143
                                                    send_remove_object( client, multi, msgremove );
1✔
144
                                                } );
3✔
145
}
14✔
146

147

148
void handle_walk( Network::Client* client, PKTIN_02* msg02 )
21✔
149
{
150
  Mobile::Character* chr = client->chr;
21✔
151

152
  if ( ( client->movementsequence == 0 ) && ( msg02->movenum != 0 ) )
21✔
153
  {
154
    // drop pkt if last request was denied, should fix the "client hopping"
155

156
    /*PktHelper::PacketOut<PktOut_21> msg;
157
    msg->Write<u8>(msg02->movenum);
158
    msg->WriteFlipped<u16>(chr->x);
159
    msg->WriteFlipped<u16>(chr->y);
160
    msg->Write<u8>(chr->facing);
161
    msg->Write<s8>(chr->z);
162
    msg.Send(client);*/
163

164
    return;
×
165
  }
166

167
  u8 oldfacing = chr->facing;
21✔
168

169
  if ( chr->move( msg02->dir ) )
21✔
170
  {
171
    // If facing is dir they are walking, check to see if already 4 tiles away
172
    // from the person trading with. If so, cancel trading!!!!
173
    if ( !settingsManager.ssopt.allow_moving_trade )
19✔
174
    {
175
      if ( chr->is_trading() )
19✔
176
      {
NEW
177
        if ( ( oldfacing == ( msg02->dir & PKTIN_02_FACING_MASK ) ) &&
×
NEW
178
             !chr->in_range( chr->trading_with.get(), 3 ) )
×
179
        {
NEW
180
          cancel_trade( chr );
×
181
        }
182
      }
183
    }
184
    client->pause();
19✔
185
    Network::PktHelper::PacketOut<Network::PktOut_22> msg;
19✔
186
    msg->Write<u8>( msg02->movenum );
19✔
187
    msg->Write<u8>( client->chr->hilite_color_idx( client->chr ) );
19✔
188
    msg.Send( client );
19✔
189

190
    client->movementsequence = msg02->movenum;
19✔
191
    if ( client->movementsequence == 255 )
19✔
NEW
192
      client->movementsequence = 1;
×
193
    else
194
      client->movementsequence++;
19✔
195

196

197
    // FIXME: Make sure we only tell those who can see us.
198
    chr->tellmove();
19✔
199

200
    send_objects_newly_inrange( client );
19✔
201

202
    client->restart();
19✔
203

204
    // here we set the delay for SpeedHackPrevention see Client::SpeedHackPrevention()
205
    if ( oldfacing == ( msg02->dir & PKTIN_02_FACING_MASK ) )
19✔
206
    {
207
      if ( client->chr->on_mount() )
14✔
NEW
208
        client->next_movement += ( msg02->dir & PKTIN_02_DIR_RUNNING_BIT )
×
NEW
209
                                     ? settingsManager.ssopt.speedhack_mountrundelay
×
NEW
210
                                     : settingsManager.ssopt.speedhack_mountwalkdelay;
×
211
      else
212
        client->next_movement += ( msg02->dir & PKTIN_02_DIR_RUNNING_BIT )
14✔
213
                                     ? settingsManager.ssopt.speedhack_footrundelay
14✔
214
                                     : settingsManager.ssopt.speedhack_footwalkdelay;
14✔
215
    }
216
    else  // changing only facing is fast
217
      client->next_movement += settingsManager.ssopt.speedhack_mountrundelay;
5✔
218
  }
19✔
219
  else
220
  {
221
    Network::PktHelper::PacketOut<Network::PktOut_21> msg;
2✔
222
    msg->Write<u8>( msg02->movenum );
2✔
223
    msg->WriteFlipped<u16>( chr->x() );
2✔
224
    msg->WriteFlipped<u16>( chr->y() );
2✔
225
    msg->Write<u8>( chr->facing );
2✔
226
    msg->Write<s8>( chr->z() );
2✔
227
    msg.Send( client );
2✔
228
    client->movementsequence = 0;
2✔
229
  }
2✔
230
}
231
}  // 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