• 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

57.01
/pol-core/pol/dblclick.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2006/05/16 Shinigami: updated doubleclick() to support Elf
5
 * - 2006/05/26 Shinigami: fixed start_script call of dblclickother
6
 * - 2007/01/04 MuadDib:   changed a large if || || || to a case switch in dbl click check.
7
 * - 2007/01/04 MuadDib:   changed flag status in sendpaperdoll to send status, instead of
8
 *                         only warmode status.
9
 * - 2008/09/24 Luth:      If this is my paperdoll, tell me all about me otherwise tell less
10
 * - 2008/09/xx Turley:    Paperdoll info decided with ssopt.cfg option (for luth's update)
11
 * - 2009/07/23 MuadDib:   updates for new Enum::Packet Out ID
12
 * - 2009/09/03 MuadDib:   Relocation of multi related cpp/h
13
 * - 2009/12/02 Turley:    added gargoyle support
14
 */
15

16

17
#include <cstring>
18
#include <string>
19

20
#include "../bscript/eprog.h"
21
#include "../clib/clib_endian.h"
22
#include "../clib/rawtypes.h"
23
#include "../clib/refptr.h"
24
#include "../plib/systemstate.h"
25
#include "containr.h"
26
#include "eventid.h"
27
#include "gameclck.h"
28
#include "item/item.h"
29
#include "item/itemdesc.h"
30
#include "mobile/charactr.h"
31
#include "mobile/npc.h"
32
#include "network/client.h"
33
#include "network/packethelper.h"
34
#include "network/packets.h"
35
#include "network/pktdef.h"
36
#include "network/pktin.h"
37
#include "plib/objtype.h"
38
#include "realms/realm.h"
39
#include "scrdef.h"
40
#include "scrsched.h"
41
#include "scrstore.h"
42
#include "ufunc.h"
43
#include "uobject.h"
44
#include "uoscrobj.h"
45

46

47
namespace Pol::Core
48
{
49
void send_paperdoll( Network::Client* client, Mobile::Character* chr )
5✔
50
{
51
  Network::PktHelper::PacketOut<Network::PktOut_88> msg;
5✔
52
  msg->Write<u32>( chr->serial_ext );
5✔
53

54
  if ( ( !settingsManager.ssopt.privacy_paperdoll ) || ( client->chr == chr ) )
5✔
55
  {
56
    std::string name = ( !chr->has_title_prefix() ? "" : chr->title_prefix() + " " ) + chr->name() +
10✔
57
                       ( !chr->has_title_suffix() ? "" : " " + chr->title_suffix() );
15✔
58
    if ( chr->has_title_race() )
5✔
59
      name += " (" + chr->title_race() + ")";
×
60
    msg->Write( Clib::strUtf8ToCp1252( name ).c_str(), 60 );
5✔
61
  }
5✔
62
  else
63
    msg->Write( Clib::strUtf8ToCp1252( chr->name() ).c_str(), 60 );
×
64

65

66
  // MuadDib changed to reflect true status for 0x20 packet. 1/4/2007
67
  // Paperdoll Appears different type Status byte than other walk/update
68
  // packets. Using poison/hidden here will break peace/war button.
69
  u8 flag1 = chr->warmode() ? 1 : 0;
5✔
70
  if ( client->acctSupports( Plib::ExpansionVersion::AOS ) && client->chr->can_clothe( chr ) )
5✔
71
    flag1 |= CHAR_FLAG1_CANALTER;
2✔
72
  msg->Write<u8>( flag1 );
5✔
73

74
  msg.Send( client );
5✔
75
}
5✔
76

77
void doubleclick( Network::Client* client, PKTIN_06* msg )
8✔
78
{
79
  u32 serial = cfBEu32( msg->serial );
8✔
80
  u32 paperdoll_macro_flag = serial & 0x80000000Lu;
8✔
81
  serial &= ~0x80000000Lu;  // keypress versus doubleclick switch?
8✔
82

83
  // the find_character would find this, but most of the time it's your own paperdoll.
84
  // this is special-cased for two reasons:
85
  //    1) it's commonly done
86
  //    2) ghosts can doubleclick ONLY their paperdoll.
87
  if ( serial == client->chr->serial )
8✔
88
  {
89
    if ( !paperdoll_macro_flag )
×
90
    {
91
      ScriptDef sd;
×
92
      sd.quickconfig( "scripts/misc/dblclickself.ecl" );
×
93
      if ( sd.exists() )
×
94
      {
95
        ref_ptr<Bscript::EScriptProgram> prog;
×
96
        prog = find_script2( sd, false, Plib::systemstate.config.cache_interactive_scripts );
×
97
        if ( prog.get() != nullptr && client->chr->start_script( prog.get(), false ) )
×
98
        {
99
          return;
×
100
        }
101
      }
×
102
    }
×
103
    send_paperdoll( client, client->chr );
×
104
    return;
×
105
  }
106

107
  if ( client->chr->dblclick_wait() > read_gameclock() )
8✔
108
  {
109
    private_say_above( client->chr, client->chr, "You must wait to use something again." );
×
110
    return;
×
111
  }
112
  client->chr->dblclick_wait( read_gameclock() + settingsManager.ssopt.dblclick_wait );
8✔
113

114
  if ( IsCharacter( serial ) )
8✔
115
  {
116
    if ( client->chr->dead() )
5✔
117
      return;
×
118
    Mobile::Character* chr = find_character( serial );
5✔
119
    if ( !chr )
5✔
120
      return;
×
121

122
    if ( chr->isa( UOBJ_CLASS::CLASS_NPC ) )
5✔
123
    {
124
      Mobile::NPC* npc = static_cast<Mobile::NPC*>( chr );
5✔
125
      if ( npc->can_accept_event( EVID_DOUBLECLICKED ) )
5✔
126
      {
127
        npc->send_event( new Module::SourcedEvent( EVID_DOUBLECLICKED, client->chr ) );
×
128
        return;
×
129
      }
130
    }
131

132
    bool script_ran = false;
5✔
133
    ScriptDef sd;
5✔
134
    sd.quickconfig( "scripts/misc/dblclickother.ecl" );
5✔
135
    if ( sd.exists() )
5✔
136
    {
137
      ref_ptr<Bscript::EScriptProgram> prog;
×
138
      prog = find_script2( sd, false, Plib::systemstate.config.cache_interactive_scripts );
×
139
      if ( prog.get() != nullptr )
×
140
        script_ran =
141
            client->chr->start_script( prog.get(), false, new Module::ECharacterRefObjImp( chr ) );
×
142
    }
×
143
    if ( !script_ran && client->chr->in_visual_range( chr ) )
5✔
144
    {
145
      if ( chr->has_paperdoll() )
5✔
146
      {
147
        send_paperdoll( client, chr );
5✔
148
      }
149
    }
150
    return;
5✔
151
  }
5✔
152
  // doubleclicked an item
153
  // next, search worn items, items in the backpack, and items in the world.
154
  Items::Item* item = find_legal_item( client->chr, serial );
3✔
155

156
  Mobile::Character* owner = nullptr;
3✔
157
  if ( item == nullptr )
3✔
158
  {
159
    item = find_snoopable_item( serial, &owner );
2✔
160
  }
161

162
  if ( item != nullptr )
3✔
163
  {
164
    const Items::ItemDesc& id = item->itemdesc();
3✔
165

166
    if ( !id.ghosts_can_use && client->chr->dead() )
3✔
167
    {
NEW
168
      private_say_above( client->chr, client->chr, "I am dead and cannot do that." );
×
NEW
169
      return;
×
170
    }
171
    if ( !id.can_use_while_frozen && client->chr->frozen() )
3✔
172
    {
NEW
173
      private_say_above( client->chr, client->chr, "I am frozen and cannot do that." );
×
NEW
174
      return;
×
175
    }
176
    if ( !id.can_use_while_paralyzed && client->chr->paralyzed() )
3✔
177
    {
NEW
178
      private_say_above( client->chr, client->chr, "I am paralyzed and cannot do that." );
×
NEW
179
      return;
×
180
    }
181

182
    if ( !client->chr->can_dblclickany() && !item->in_range( client->chr, id.doubleclick_range ) )
3✔
183
    {
184
      private_say_above( client->chr, item, "That is too far away." );
1✔
185
      return;
1✔
186
    }
187
    UObject* obj = item->toplevel_owner();
2✔
188
    obj = obj->self_as_owner();
2✔
189
    if ( id.use_requires_los && !client->chr->realm()->has_los( *client->chr, *obj ) )  // DAVE
2✔
190
                                                                                        // 11/24
191
    {
NEW
192
      private_say_above( client->chr, item, "I can't see that." );
×
NEW
193
      return;
×
194
    }
195

196
    ScriptDef sd;
2✔
197
    sd.quickconfig( "scripts/misc/dblclickitem.ecl" );
2✔
198
    if ( sd.exists() )
2✔
199
    {
NEW
200
      ref_ptr<Bscript::EScriptProgram> prog;
×
NEW
201
      prog = find_script2( sd, false, Plib::systemstate.config.cache_interactive_scripts );
×
NEW
202
      if ( prog.get() != nullptr )
×
NEW
203
        client->chr->start_script( prog.get(), false, new Module::EItemRefObjImp( item ) );
×
NEW
204
    }
×
205

206
    if ( owner == nullptr )
2✔
207
    {
208
      item->double_click( client );
1✔
209
    }
210
    else
211
    {
212
      item->snoop( client, owner );
1✔
213
    }
214
    return;
2✔
215
  }
2✔
216

217
  // allow looking into containers being traded
NEW
218
  if ( client->chr->is_trading() )
×
219
  {
NEW
220
    UContainer* cont = client->chr->trade_container()->find_container( serial );
×
NEW
221
    if ( cont != nullptr )
×
222
    {
NEW
223
      cont->builtin_on_use( client );
×
NEW
224
      if ( !cont->locked() )
×
225
      {
NEW
226
        if ( client->chr->trading_with->client != nullptr )
×
NEW
227
          cont->builtin_on_use( client->chr->trading_with->client );
×
228
      }
NEW
229
      return;
×
230
    }
231
  }
232
}
233
}  // 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