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

polserver / polserver / 21541532363

31 Jan 2026 08:14AM UTC coverage: 60.532% (+0.03%) from 60.507%
21541532363

push

github

web-flow
Tidy modernize for loops (#862)

* trigger loop convert

* Automated clang-tidy change: modernize-loop-convert

* fixed refactor

* Automated clang-tidy change: modernize-loop-convert

* compile

* first look through

* fixes and start to use a few ranges

* revert autogenerated file

* compilation fix

* second pass

* renamed loop variable

---------

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

164 of 447 new or added lines in 61 files covered. (36.69%)

6 existing lines in 5 files now uncovered.

44377 of 73312 relevant lines covered (60.53%)

499857.83 hits per line

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

55.68
/pol-core/pol/mobile/corpse.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2009/08/07 MuadDib:   Added layer_list_ and functions like WornItems to corpse class. Used to
5
 * handle showing equippable items
6
 *                         on a corpse.
7
 */
8

9

10
#include "corpse.h"
11

12
#include <stddef.h>
13

14
#include "../../bscript/executor.h"
15
#include "../../clib/cfgelem.h"
16
#include "../../clib/passert.h"
17
#include "../../clib/stlutil.h"
18
#include "../../clib/streamsaver.h"
19
#include "../containr.h"
20
#include "../globals/uvars.h"
21
#include "../layers.h"
22
#include "../syshookscript.h"
23
#include "../ufunc.h"
24
#include "../uobject.h"
25

26

27
namespace Pol::Core
28
{
29
UCorpse::UCorpse( const Items::ContainerDesc& descriptor )
74✔
30
    : UContainer( descriptor ), corpsetype( 0 ), ownerserial( 0 )
74✔
31
{
32
  movable( false );
74✔
33
  can_equip_list_.resize( HIGHEST_LAYER + 1 );
74✔
34
}
74✔
35

36
const Core::ItemRef& UCorpse::GetItemOnLayer( unsigned idx ) const
1,605✔
37
{
38
  passert( Items::valid_equip_layer( idx ) );
1,605✔
39
  return can_equip_list_.at( idx );
1,605✔
40
}
41

42
bool UCorpse::take_contents_to_grave() const
10✔
43
{
44
  return flags_.get( OBJ_FLAGS::CONTENT_TO_GRAVE );
10✔
45
}
46

47
void UCorpse::take_contents_to_grave( bool newvalue )
74✔
48
{
49
  flags_.change( OBJ_FLAGS::CONTENT_TO_GRAVE, newvalue );
74✔
50
}
74✔
51

52
void UCorpse::add( Item* item, const Pos2d& pos )
6✔
53
{
54
  // When an item is added, check if it's equippable and add to the appropriate layer
55
  if ( Items::valid_equip_layer( item ) && GetItemOnLayer( item->tile_layer ) == item )
6✔
56
  {
57
    PutItemOnLayer( item );
4✔
58
  }
59

60
  // plus the defaults from UContainer
61
  base::add( item, pos );
6✔
62
}
6✔
63

64
void UCorpse::equip_and_add( Item* item, unsigned idx )
4✔
65
{
66
  can_equip_list_[idx].set( item );
4✔
67
  add_at_random_location( item );
4✔
68
}
4✔
69

70
void UCorpse::remove( iterator itr )
×
71
{
72
  Item* item = *itr;
×
73

74
  if ( Items::valid_equip_layer( item ) )
×
75
  {
76
    auto& item_on_layer = GetItemOnLayer( item->tile_layer );
×
77

78
    if ( item_on_layer != nullptr && item_on_layer->serial == item->serial )
×
79
    {
80
      RemoveItemFromLayer( item );
×
81
    }
82
  }
83
  base::remove( itr );
×
84
}
×
85

86

87
u16 UCorpse::get_senditem_amount() const
161✔
88
{
89
  return corpsetype;
161✔
90
}
91

92
void UCorpse::spill_contents( Multi::UMulti* multi )
×
93
{
94
  bool any;
95
  do
×
96
  {
97
    any = false;
×
NEW
98
    for ( auto item : *this )
×
99
    {
100
      if ( item->tile_layer == LAYER_HAIR || item->tile_layer == LAYER_BEARD ||
×
101
           item->tile_layer == LAYER_FACE || item->movable() == false )
×
102
      {
103
        Core::destroy_item( item );
×
104
        any = true;
×
105
        break;  // our iterators are now useless, so start over
×
106
      }
107
    }
108
  } while ( any );
109

110
  if ( !take_contents_to_grave() )
×
111
    base::spill_contents( multi );
×
112
}
×
113

114
void UCorpse::PutItemOnLayer( Item* item )
4✔
115
{
116
  passert( Items::valid_equip_layer(
4✔
117
      item ) );  // Calling code must make sure that item->tile_layer is valid!
118

119
  item->set_dirty();
4✔
120
  set_dirty();
4✔
121
  item->layer = item->tile_layer;
4✔
122
}
4✔
123

124
void UCorpse::RemoveItemFromLayer( Item* item )
×
125
{
126
  passert( Items::valid_equip_layer(
×
127
      item ) );  // Calling code must make sure that item->tile_layer is valid!
128

129
  item->set_dirty();
×
130
  set_dirty();
×
131
  item->layer = 0;
×
132
}
×
133

134
void UCorpse::printProperties( Clib::StreamWriter& sw ) const
10✔
135
{
136
  base::printProperties( sw );
10✔
137
  sw.add( "CorpseType", corpsetype );
10✔
138
  sw.add( "OwnerSerial", ownerserial );
10✔
139
  sw.add( "TakeContentsToGrave", take_contents_to_grave() );
10✔
140
}
10✔
141

142
void UCorpse::readProperties( Clib::ConfigElem& elem )
2✔
143
{
144
  // corpses can be the same color as mobiles
145
  u16 savecolor = elem.remove_ushort( "COLOR", 0 );
2✔
146

147
  base::readProperties( elem );
2✔
148

149
  color = savecolor;
2✔
150

151
  elem.remove_prop( "CorpseType", &corpsetype );
2✔
152
  elem.remove_prop( "OwnerSerial", &ownerserial );
2✔
153
  take_contents_to_grave( elem.remove_bool( "TakeContentsToGrave", false ) );
2✔
154
  movable( false );
2✔
155
}
2✔
156

157
size_t UCorpse::estimatedSize() const
5✔
158
{
159
  size_t size = base::estimatedSize() + sizeof( u16 ) /*corpsetype*/
5✔
160
                + sizeof( u32 )                       /*ownerserial*/
161
                // no estimateSize here element is in objhash
162
                + Clib::memsize( can_equip_list_ );
5✔
163
  return size;
5✔
164
}
165

166
void UCorpse::on_insert_add_item( Mobile::Character* mob, MoveType move, Items::Item* new_item )
×
167
{
168
  // If we are a corpse and the item has a valid_equip_layer, we equipped it and need to send an
169
  // update
170
  if ( Items::valid_equip_layer( new_item ) )
×
171
  {
172
    UCorpse* corpse = static_cast<UCorpse*>( this );
×
173
    auto& item_on_layer = corpse->GetItemOnLayer( new_item->tile_layer );
×
174
    if ( item_on_layer != nullptr && !item_on_layer->orphan() &&
×
175
         item_on_layer->serial == new_item->serial )
×
176
    {
177
      send_corpse_equip_inrange( corpse );
×
178
    }
179
  }
180

181
  base::on_insert_add_item( mob, move, new_item );
×
182
}
×
183

184
bool UCorpse::get_method_hook( const char* methodname, Bscript::Executor* ex, ExportScript** hook,
×
185
                               unsigned int* PC ) const
186
{
187
  if ( gamestate.system_hooks.get_method_hook( gamestate.system_hooks.corpse_method_script.get(),
×
188
                                               methodname, ex, hook, PC ) )
189
    return true;
×
190
  return base::get_method_hook( methodname, ex, hook, PC );
×
191
}
192
}  // 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