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

polserver / polserver / 13186603372

06 Feb 2025 07:41PM UTC coverage: 58.464% (-0.01%) from 58.476%
13186603372

push

github

web-flow
Worldsave further improvements (#758)

* directly use the capi for file writing
could improve performance

* docs

* file i/o error checking also during writing

45 of 53 new or added lines in 6 files covered. (84.91%)

1 existing line in 1 file now uncovered.

41740 of 71394 relevant lines covered (58.46%)

392651.47 hits per line

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

81.64
/pol-core/pol/uobject.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2009/08/25 Shinigami: STLport-5.2.1 fix: init order changed of realm and saveonexit_
5
 * - 2009/09/14 MuadDib:   UObject::setgraphic added error printing.
6
 * - 2009/12/02 Turley:    added config.max_tile_id - Tomi
7
 */
8

9

10
#include "uobject.h"
11

12
#include <atomic>
13
#include <iosfwd>
14
#include <stddef.h>
15
#include <string>
16
#include <utility>
17

18
#include "../clib/cfgelem.h"
19
#include "../clib/logfacility.h"
20
#include "../clib/passert.h"
21
#include "../clib/rawtypes.h"
22
#include "../clib/refptr.h"
23
#include "../clib/streamsaver.h"
24
#include "../plib/clidata.h"
25
#include "../plib/objtype.h"
26
#include "../plib/systemstate.h"
27
#include "../plib/uconst.h"
28
#include "baseobject.h"
29
#include "dynproperties.h"
30
#include "globals/state.h"
31
#include "globals/uvars.h"
32
#include "item/itemdesc.h"
33
#include "proplist.h"
34
#include "realms/realm.h"
35
#include "realms/realms.h"
36
#include "syshookscript.h"
37
#include "tooltips.h"
38
#include "uobjcnt.h"
39

40
namespace Pol
41
{
42
namespace Core
43
{
44
std::set<UObject*> unreaped_orphan_instances;
45

46
void display_unreaped_orphan_instances()
3✔
47
{
48
  Clib::StreamWriter sw{ "orphans.txt" };
3✔
49

50
  for ( auto& obj : unreaped_orphan_instances )
3✔
51
  {
NEW
52
    sw.comment( "{}, {}", obj->name(), obj->ref_counted_count() );
×
NEW
53
    obj->printOnDebug( sw );
×
54
  }
55
  if ( !unreaped_orphan_instances.empty() )
3✔
NEW
56
    INFO_PRINT( "orphans detected, check orphans.txt" );
×
57
}
3✔
58

59

60
std::atomic<unsigned int> UObject::dirty_writes;
61
std::atomic<unsigned int> UObject::clean_writes;
62

63
UObject::UObject( u32 objtype, UOBJ_CLASS i_uobj_class )
6,512✔
64
    : ref_counted(),
65
      ULWObject( i_uobj_class ),
66
      DynamicPropsHolder(),
67
      serial_ext( 0 ),
6,512✔
68
      objtype_( objtype ),
6,512✔
69
      color( 0 ),
6,512✔
70
      facing( Core::FACING_N ),
6,512✔
71
      _rev( 0 ),
6,512✔
72
      name_( "" ),
6,512✔
73
      flags_(),
6,512✔
74
      proplist_( CPropProfiler::class_to_type( i_uobj_class ) )
13,024✔
75
{
76
  graphic = Items::getgraphic( objtype );
6,512✔
77
  flags_.set( OBJ_FLAGS::DIRTY );
6,512✔
78
  flags_.set( OBJ_FLAGS::SAVE_ON_EXIT );
6,512✔
79
  height = Plib::tileheight( graphic );
6,512✔
80
  ++stateManager.uobjcount.uobject_count;
6,512✔
81
}
6,512✔
82

83
UObject::~UObject()
6,512✔
84
{
85
  if ( ref_counted::count() != 0 )
6,512✔
86
  {
87
    POLLOG_INFOLN( "Ouch! UObject::~UObject() with count()=={}", ref_counted::count() );
×
88
  }
89
  passert( ref_counted::count() == 0 );
6,512✔
90
  if ( serial == 0 )
6,512✔
91
  {
92
    --stateManager.uobjcount.unreaped_orphans;
6,512✔
93
  }
94
  --stateManager.uobjcount.uobject_count;
6,512✔
95
}
6,512✔
96

97
size_t UObject::estimatedSize() const
39✔
98
{
99
  size_t size = sizeof( UObject ) + proplist_.estimatedSize();
39✔
100
  size += estimateSizeDynProps();
39✔
101
  return size;
39✔
102
}
103

104
//
105
//    Every UObject is registered with the objecthash after creation.
106
//    (This can't happen in the ctor since the object isn't fully created yet)
107
//
108
//    Scripts may still reference any object, so rather than outright delete,
109
//    we set its serial to 0 (marking it "orphan", though "zombie" would probably be a better term).
110
//    Later, when all _other_ references to the object have been deleted,
111
//    objecthash.Reap() will remove its reference to this object, deleting it.
112
//
113
void UObject::destroy()
6,515✔
114
{
115
  if ( serial != 0 )
6,515✔
116
  {
117
    if ( ref_counted::count() < 1 )
6,512✔
118
    {
119
      POLLOG_INFOLN( "Ouch! UObject::destroy() with count()=={}", ref_counted::count() );
×
120
    }
121

122
    set_dirty();  // we will have to write a 'object deleted' directive once
6,512✔
123

124
    serial =
6,512✔
125
        0;  // used to set serial_ext to 0.  This way, if debugging, one can find out the old serial
126
    passert( ref_counted::count() >= 1 );
6,512✔
127

128
    ++stateManager.uobjcount.unreaped_orphans;
6,512✔
129
  }
130
}
6,515✔
131

132
bool UObject::dirty() const
164✔
133
{
134
  return flags_.get( OBJ_FLAGS::DIRTY );
164✔
135
}
136

137
void UObject::clear_dirty() const
164✔
138
{
139
  if ( dirty() )
164✔
140
    ++dirty_writes;
122✔
141
  else
142
    ++clean_writes;
42✔
143
  flags_.remove( OBJ_FLAGS::DIRTY );
164✔
144
}
164✔
145

146
bool UObject::getprop( const std::string& propname, std::string& propval ) const
27✔
147
{
148
  return proplist_.getprop( propname, propval );
27✔
149
}
150

151
void UObject::setprop( const std::string& propname, const std::string& propvalue )
56✔
152
{
153
  if ( propname[0] != '#' )
56✔
154
    set_dirty();
51✔
155
  proplist_.setprop( propname, propvalue );  // VOID_RETURN
56✔
156
}
56✔
157

158
void UObject::eraseprop( const std::string& propname )
×
159
{
160
  if ( propname[0] != '#' )
×
161
    set_dirty();
×
162
  proplist_.eraseprop( propname );  // VOID_RETURN
×
163
}
×
164

165
void UObject::copyprops( const UObject& from )
56✔
166
{
167
  set_dirty();
56✔
168
  proplist_.copyprops( from.proplist_ );
56✔
169
}
56✔
170

171
void UObject::copyprops( const PropertyList& proplist )
6,289✔
172
{
173
  set_dirty();
6,289✔
174
  proplist_.copyprops( proplist );
6,289✔
175
}
6,289✔
176

177
void UObject::getpropnames( std::vector<std::string>& propnames ) const
×
178
{
179
  proplist_.getpropnames( propnames );
×
180
}
×
181

182
const PropertyList& UObject::getprops() const
9✔
183
{
184
  return proplist_;
9✔
185
}
186

187
std::string UObject::name() const
107✔
188
{
189
  return name_;
107✔
190
}
191

192
std::string UObject::description() const
×
193
{
194
  return name_;
×
195
}
196

197
void UObject::setname( const std::string& newname )
87✔
198
{
199
  set_dirty();
87✔
200
  increv();
87✔
201
  send_object_cache_to_inrange( this );
87✔
202
  name_ = newname;
87✔
203
}
87✔
204

205
UObject* UObject::owner()
×
206
{
207
  return nullptr;
×
208
}
209

210
const UObject* UObject::owner() const
×
211
{
212
  return nullptr;
×
213
}
214

215
UObject* UObject::self_as_owner()
1✔
216
{
217
  return this;
1✔
218
}
219

220
const UObject* UObject::self_as_owner() const
×
221
{
222
  return this;
×
223
}
224

225
UObject* UObject::toplevel_owner()
×
226
{
227
  return this;
×
228
}
229

230
const UObject* UObject::toplevel_owner() const
56,890✔
231
{
232
  return this;
56,890✔
233
}
234

235
void UObject::setposition( Pos4d newpos )
13,139✔
236
{
237
  set_dirty();
13,139✔
238
  pos( std::move( newpos ) );
13,139✔
239
}
13,139✔
240

241
UFACING UObject::direction_toward( UObject* other ) const
×
242
{
243
  return pos2d().direction_toward( other->toplevel_owner()->pos2d() );
×
244
}
245
UFACING UObject::direction_toward( const Pos2d& other ) const
×
246
{
247
  return pos2d().direction_toward( other );
×
248
}
249
UFACING UObject::direction_away( UObject* other ) const
×
250
{
251
  return pos2d().direction_away( other->toplevel_owner()->pos2d() );
×
252
}
253
UFACING UObject::direction_away( const Pos2d& other ) const
×
254
{
255
  return pos2d().direction_away( other );
×
256
}
257

258
void UObject::printProperties( Clib::StreamWriter& sw ) const
94✔
259
{
260
  using namespace fmt;
261

262
  if ( !name_.get().empty() )
94✔
263
    sw.add( "Name", name_.get() );
64✔
264

265
  sw.add( "Serial", Clib::hexintv( serial ) );
94✔
266
  sw.add( "ObjType", Clib::hexintv( objtype_ ) );
94✔
267
  sw.add( "Graphic", Clib::hexintv( graphic ) );
94✔
268

269
  if ( color != 0 )
94✔
270
    sw.add( "Color", Clib::hexintv( color ) );
14✔
271

272
  sw.add( "X", x() );
94✔
273
  sw.add( "Y", y() );
94✔
274
  sw.add( "Z", (int)z() );
94✔
275

276
  if ( facing )
94✔
277
    sw.add( "Facing", static_cast<int>( facing ) );
32✔
278

279
  sw.add( "Revision", rev() );
94✔
280
  if ( realm() == nullptr )
93✔
281
    sw.add( "Realm", "britannia" );
×
282
  else
283
    sw.add( "Realm", realm()->name() );
93✔
284

285
  s16 value = fire_resist().mod;
94✔
286
  if ( value != 0 )
94✔
287
    sw.add( "FireResistMod", value );
2✔
288
  value = cold_resist().mod;
94✔
289
  if ( value != 0 )
93✔
290
    sw.add( "ColdResistMod", value );
2✔
291
  value = energy_resist().mod;
93✔
292
  if ( value != 0 )
93✔
293
    sw.add( "EnergyResistMod", value );
2✔
294
  value = poison_resist().mod;
93✔
295
  if ( value != 0 )
93✔
296
    sw.add( "PoisonResistMod", value );
2✔
297
  value = physical_resist().mod;
93✔
298
  if ( value != 0 )
94✔
299
    sw.add( "PhysicalResistMod", value );
2✔
300

301
  value = fire_damage().mod;
94✔
302
  if ( value != 0 )
94✔
303
    sw.add( "FireDamageMod", value );
2✔
304
  value = cold_damage().mod;
94✔
305
  if ( value != 0 )
93✔
306
    sw.add( "ColdDamageMod", value );
2✔
307
  value = energy_damage().mod;
93✔
308
  if ( value != 0 )
94✔
309
    sw.add( "EnergyDamageMod", value );
2✔
310
  value = poison_damage().mod;
94✔
311
  if ( value != 0 )
94✔
312
    sw.add( "PoisonDamageMod", value );
2✔
313
  value = physical_damage().mod;
94✔
314
  if ( value != 0 )
93✔
315
    sw.add( "PhysicalDamageMod", value );
2✔
316
  // new mod stuff
317
  value = lower_reagent_cost().mod;
93✔
318
  if ( value )
93✔
319
    sw.add( "LowerReagentCostMod", value );
2✔
320
  value = defence_increase().mod;
93✔
321
  if ( value )
93✔
322
    sw.add( "DefenceIncreaseMod", value );
2✔
323
  value = defence_increase_cap().mod;
93✔
324
  if ( value )
93✔
325
    sw.add( "DefenceIncreaseCapMod", value );
2✔
326
  value = lower_mana_cost().mod;
93✔
327
  if ( value )
93✔
328
    sw.add( "LowerManaCostMod", value );
2✔
329
  value = hit_chance().mod;
93✔
330
  if ( value )
94✔
331
    sw.add( "HitChanceMod", value );
2✔
332
  value = fire_resist_cap().mod;
94✔
333
  if ( value )
94✔
334
    sw.add( "FireResistCapMod", value );
2✔
335
  value = cold_resist_cap().mod;
94✔
336
  if ( value )
93✔
337
    sw.add( "ColdResistCapMod", value );
2✔
338
  value = energy_resist_cap().mod;
93✔
339
  if ( value )
93✔
340
    sw.add( "EnergyResistCapMod", value );
2✔
341
  value = physical_resist_cap().mod;
93✔
342
  if ( value )
94✔
343
    sw.add( "PhysicalResistCapMod", value );
2✔
344
  value = poison_resist_cap().mod;
94✔
345
  if ( value )
94✔
346
    sw.add( "PoisonResistCapMod", value );
2✔
347
  value = spell_damage_increase().mod;
94✔
348
  if ( value )
93✔
349
    sw.add( "SpellDamageIncreaseMod", value );
2✔
350
  value = faster_casting().mod;
93✔
351
  if ( value )
93✔
352
    sw.add( "FasterCastingMod", value );
2✔
353
  value = faster_cast_recovery().mod;
93✔
354
  if ( value )
94✔
355
    sw.add( "FasterCastRecoveryMod", value );
2✔
356
  value = luck().mod;
94✔
357
  if ( value )
93✔
358
    sw.add( "LuckMod", value );
2✔
359
  value = swing_speed_increase().mod;
93✔
360
  if ( value )
94✔
361
    sw.add( "SwingSpeedIncreaseMod", value );
2✔
362
  value = min_attack_range_increase().mod;
94✔
363
  if ( value )
94✔
364
    sw.add( "MinAttackRangeIncreaseMod", value );
2✔
365
  value = max_attack_range_increase().mod;
94✔
366
  if ( value )
94✔
367
    sw.add( "MaxAttackRangeIncreaseMod", value );
2✔
368
  // end new mod stuff
369

370

371
  proplist_.printProperties( sw );
94✔
372
}
93✔
373

374
void UObject::printDebugProperties( Clib::StreamWriter& sw ) const
×
375
{
376
  sw.comment( "uobj_class: {}", (int)uobj_class() );
×
377
}
×
378

379
/// Fixes invalid graphic, moving here to allow it to be overridden in subclass (see Multi)
380
void UObject::fixInvalidGraphic()
97✔
381
{
382
  if ( graphic > ( Plib::systemstate.config.max_tile_id ) )
97✔
383
    graphic = GRAPHIC_NODRAW;
×
384
}
97✔
385

386
void UObject::readProperties( Clib::ConfigElem& elem )
97✔
387
{
388
  name_ = elem.remove_string( "NAME", "" );
97✔
389

390
  // serial, objtype extracted by caller
391
  graphic = elem.remove_ushort( "GRAPHIC", static_cast<u16>( objtype_ ) );
97✔
392
  fixInvalidGraphic();
97✔
393

394
  height = Plib::tileheight( graphic );
97✔
395

396
  color = elem.remove_ushort( "COLOR", 0 );
97✔
397

398

399
  std::string realmstr = elem.remove_string( "Realm", "britannia" );
97✔
400
  auto* realm_tmp = find_realm( realmstr );
97✔
401
  if ( !realm_tmp )
97✔
402
  {
403
    ERROR_PRINTLN( "{} '{}' ({:#x}): has an invalid realm property '{}'.", classname(), name(),
×
404
                   serial, realmstr );
×
405
    throw std::runtime_error( "Data integrity error" );
×
406
  }
407
  setposition( Pos4d( elem.remove_ushort( "X" ), elem.remove_ushort( "Y" ),
97✔
408
                      static_cast<s8>( elem.remove_int( "Z" ) ), realm_tmp ) );
97✔
409

410
  unsigned short tmp = elem.remove_ushort( "FACING", 0 );
97✔
411
  setfacing( static_cast<unsigned char>( tmp ) );
97✔
412

413
  _rev = elem.remove_ulong( "Revision", 0 );
97✔
414

415
  s16 mod_value = static_cast<s16>( elem.remove_int( "FIRERESISTMOD", 0 ) );
97✔
416
  if ( mod_value != 0 )
97✔
417
    fire_resist( fire_resist().setAsMod( mod_value ) );
1✔
418
  mod_value = static_cast<s16>( elem.remove_int( "COLDRESISTMOD", 0 ) );
97✔
419
  if ( mod_value != 0 )
97✔
420
    cold_resist( cold_resist().setAsMod( mod_value ) );
1✔
421
  mod_value = static_cast<s16>( elem.remove_int( "ENERGYRESISTMOD", 0 ) );
97✔
422
  if ( mod_value != 0 )
97✔
423
    energy_resist( energy_resist().setAsMod( mod_value ) );
1✔
424
  mod_value = static_cast<s16>( elem.remove_int( "POISONRESISTMOD", 0 ) );
97✔
425
  if ( mod_value != 0 )
97✔
426
    poison_resist( poison_resist().setAsMod( mod_value ) );
1✔
427
  mod_value = static_cast<s16>( elem.remove_int( "PHYSICALRESISTMOD", 0 ) );
97✔
428
  if ( mod_value != 0 )
97✔
429
    physical_resist( physical_resist().setAsMod( mod_value ) );
1✔
430

431
  mod_value = static_cast<s16>( elem.remove_int( "FIREDAMAGEMOD", 0 ) );
97✔
432
  if ( mod_value != 0 )
97✔
433
    fire_damage( fire_damage().setAsMod( mod_value ) );
1✔
434
  mod_value = static_cast<s16>( elem.remove_int( "COLDDAMAGEMOD", 0 ) );
97✔
435
  if ( mod_value != 0 )
97✔
436
    cold_damage( cold_damage().setAsMod( mod_value ) );
1✔
437
  mod_value = static_cast<s16>( elem.remove_int( "ENERGYDAMAGEMOD", 0 ) );
97✔
438
  if ( mod_value != 0 )
97✔
439
    energy_damage( energy_damage().setAsMod( mod_value ) );
1✔
440
  mod_value = static_cast<s16>( elem.remove_int( "POISONDAMAGEMOD", 0 ) );
97✔
441
  if ( mod_value != 0 )
97✔
442
    poison_damage( poison_damage().setAsMod( mod_value ) );
1✔
443
  mod_value = static_cast<s16>( elem.remove_int( "PHYSICALDAMAGEMOD", 0 ) );
97✔
444
  if ( mod_value != 0 )
97✔
445
    physical_damage( physical_damage().setAsMod( mod_value ) );
1✔
446
  mod_value = static_cast<s16>( elem.remove_int( "DEFENCEINCREASEMOD", 0 ) );
97✔
447
  if ( mod_value != 0 )
97✔
448
    defence_increase( defence_increase().setAsMod( mod_value ) );
1✔
449
  mod_value = static_cast<s16>( elem.remove_int( "DEFENCEINCREASECAPMOD", 0 ) );
97✔
450
  if ( mod_value != 0 )
97✔
451
    defence_increase_cap( defence_increase_cap().setAsMod( mod_value ) );
1✔
452
  mod_value = static_cast<s16>( elem.remove_int( "LOWERMANACOSTMOD", 0 ) );
97✔
453
  if ( mod_value != 0 )
97✔
454
    lower_mana_cost( lower_mana_cost().setAsMod( mod_value ) );
1✔
455
  mod_value = static_cast<s16>( elem.remove_int( "HITCHANCEMOD", 0 ) );
97✔
456
  if ( mod_value != 0 )
97✔
457
    hit_chance( hit_chance().setAsMod( mod_value ) );
1✔
458
  mod_value = static_cast<s16>( elem.remove_int( "FIRERESISTCAPMOD", 0 ) );
97✔
459
  if ( mod_value != 0 )
97✔
460
    fire_resist_cap( fire_resist_cap().setAsMod( mod_value ) );
1✔
461
  mod_value = static_cast<s16>( elem.remove_int( "COLDRESISTCAPMOD", 0 ) );
97✔
462
  if ( mod_value != 0 )
97✔
463
    cold_resist_cap( cold_resist_cap().setAsMod( mod_value ) );
1✔
464
  mod_value = static_cast<s16>( elem.remove_int( "ENERGYRESISTCAPMOD", 0 ) );
97✔
465
  if ( mod_value != 0 )
97✔
466
    energy_resist_cap( energy_resist_cap().setAsMod( mod_value ) );
1✔
467
  mod_value = static_cast<s16>( elem.remove_int( "POISONRESISTCAPMOD", 0 ) );
97✔
468
  if ( mod_value != 0 )
97✔
469
    poison_resist_cap( poison_resist_cap().setAsMod( mod_value ) );
1✔
470
  mod_value = static_cast<s16>( elem.remove_int( "PHYSICALRESISTCAPMOD", 0 ) );
97✔
471
  if ( mod_value != 0 )
97✔
472
    physical_resist_cap( physical_resist_cap().setAsMod( mod_value ) );
1✔
473
  mod_value = static_cast<s16>( elem.remove_int( "LOWERREAGENTCOSTMOD", 0 ) );
97✔
474
  if ( mod_value != 0 )
97✔
475
    lower_reagent_cost( lower_reagent_cost().setAsMod( mod_value ) );
1✔
476
  mod_value = static_cast<s16>( elem.remove_int( "SPELLDAMAGEINCREASEMOD", 0 ) );
97✔
477
  if ( mod_value != 0 )
97✔
478
    spell_damage_increase( spell_damage_increase().setAsMod( mod_value ) );
1✔
479
  mod_value = static_cast<s16>( elem.remove_int( "FASTERCASTINGMOD", 0 ) );
97✔
480
  if ( mod_value != 0 )
97✔
481
    faster_casting( faster_casting().setAsMod( mod_value ) );
1✔
482
  mod_value = static_cast<s16>( elem.remove_int( "FASTERCASTRECOVERYMOD", 0 ) );
97✔
483
  if ( mod_value != 0 )
97✔
484
    faster_cast_recovery( faster_cast_recovery().setAsMod( mod_value ) );
1✔
485
  mod_value = static_cast<s16>( elem.remove_int( "LUCKMOD", 0 ) );
97✔
486
  if ( mod_value != 0 )
97✔
487
    luck( luck().setAsMod( mod_value ) );
1✔
488
  mod_value = static_cast<s16>( elem.remove_int( "SWINGSPEEDINCREASEMOD", 0 ) );
97✔
489
  if ( mod_value != 0 )
97✔
490
    swing_speed_increase( swing_speed_increase().setAsMod( mod_value ) );
1✔
491
  mod_value = static_cast<s16>( elem.remove_int( "MINATTACKRANGEINCREASEMOD", 0 ) );
97✔
492
  if ( mod_value != 0 )
97✔
493
    min_attack_range_increase( min_attack_range_increase().setAsMod( mod_value ) );
1✔
494
  mod_value = static_cast<s16>( elem.remove_int( "MAXATTACKRANGEINCREASEMOD", 0 ) );
97✔
495
  if ( mod_value != 0 )
97✔
496
    max_attack_range_increase( max_attack_range_increase().setAsMod( mod_value ) );
1✔
497

498

499
  proplist_.readProperties( elem );
97✔
500
}
97✔
501

502
void UObject::printSelfOn( Clib::StreamWriter& sw ) const
×
503
{
504
  printOn( sw );
×
505
}
×
506

507
void UObject::printOn( Clib::StreamWriter& sw ) const
90✔
508
{
509
  sw.begin( classname() );
90✔
510
  printProperties( sw );
90✔
511
  sw.end();
90✔
512
}
90✔
513

514
void UObject::printOnDebug( Clib::StreamWriter& sw ) const
×
515
{
516
  sw.begin( classname() );
×
517
  printProperties( sw );
×
518
  printDebugProperties( sw );
×
519
  sw.end();
×
520
}
×
521

522
bool UObject::setgraphic( u16 /*newgraphic*/ )
×
523
{
524
  ERROR_PRINTLN(
×
525
      "UOBject::SetGraphic used, object class does not have a graphic member! Object Serial: {:#x}",
526
      serial );
×
527
  return false;
×
528
}
529

530
bool UObject::setcolor( u16 newcolor )
×
531
{
532
  set_dirty();
×
533

534
  if ( color != newcolor )
×
535
  {
536
    color = newcolor;
×
537
    on_color_changed();
×
538
  }
539

540
  return true;
×
541
}
542

543
void UObject::on_color_changed() {}
×
544

545
void UObject::on_facing_changed() {}
×
546

547
bool UObject::saveonexit() const
98✔
548
{
549
  return flags_.get( OBJ_FLAGS::SAVE_ON_EXIT );
98✔
550
}
551

552
void UObject::saveonexit( bool newvalue )
6,496✔
553
{
554
  flags_.change( OBJ_FLAGS::SAVE_ON_EXIT, newvalue );
6,496✔
555
}
6,496✔
556

557
const char* UObject::target_tag() const
×
558
{
559
  return "object";
×
560
}
561

562
bool UObject::get_method_hook( const char* methodname, Bscript::Executor* ex, ExportScript** hook,
×
563
                               unsigned int* PC ) const
564
{
565
  return gamestate.system_hooks.get_method_hook( gamestate.system_hooks.uobject_method_script.get(),
×
566
                                                 methodname, ex, hook, PC );
×
567
}
568
}  // namespace Core
569
}  // namespace Pol
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