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

polserver / polserver / 13406681870

19 Feb 2025 06:24AM UTC coverage: 58.736% (-0.02%) from 58.754%
13406681870

push

github

web-flow
Windows backtrace fix with pdb files (#764)

* pdb location is stored as absolute path in the executable
overwritten this default behaviour to find pdbs in the workdirectory
in addition add during runtime pdb searchpath to the directory where the
executable is located (CI case)

* added exception text to log if worldsave fails

1 of 3 new or added lines in 1 file covered. (33.33%)

13 existing lines in 5 files now uncovered.

42224 of 71888 relevant lines covered (58.74%)

387187.67 hits per line

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

75.27
/pol-core/pol/multi/multis.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2005/11/26 Shinigami: changed "strcmp" into "stricmp" to suppress Script Errors
5
 * - 2009/09/03 MuadDib:   Relocation of multi related cpp/h
6
 */
7

8

9
#include <stddef.h>
10

11
#include "../../bscript/bobject.h"
12
#include "../../bscript/bstruct.h"
13
#include "../../bscript/executor.h"
14
#include "../../bscript/objmembers.h"
15
#include "../../clib/cfgelem.h"
16
#include "../../clib/logfacility.h"
17
#include "../../clib/passert.h"
18
#include "../../clib/streamsaver.h"
19
#include "../../plib/uconst.h"
20
#include "../baseobject.h"
21
#include "../globals/state.h"
22
#include "../globals/uvars.h"
23
#include "../item/item.h"
24
#include "../item/itemdesc.h"
25
#include "../syshookscript.h"
26
#include "../uobjcnt.h"
27
#include "multi.h"
28
#include "multidef.h"
29

30
namespace Pol
31
{
32
namespace Multi
33
{
34
UMulti::UMulti( const Items::ItemDesc& itemdesc ) : Item( itemdesc, Core::UOBJ_CLASS::CLASS_MULTI )
37✔
35
{
36
  const auto& desc = static_cast<const Items::MultiDesc&>( itemdesc );
37✔
37
  multiid_ = desc.multiid;
37✔
38
  items_decay_ = desc.items_decay;
37✔
39

40
  if ( !MultiDefByMultiIDExists( desc.multiid ) )
37✔
41
  {
42
    ERROR_PRINTLN( "Tried to create a Multi type {:#x}", desc.objtype );
×
43
    throw std::runtime_error( "Invalid Multi type" );
×
44
  }
45
  ++Core::stateManager.uobjcount.umulti_count;
37✔
46
}
37✔
47

48
UMulti::~UMulti()
37✔
49
{
50
  --Core::stateManager.uobjcount.umulti_count;
37✔
51
}
37✔
52

53
void UMulti::double_click( Network::Client* /*client*/ )
×
54
{
55
  ERROR_PRINTLN( "Ack! You can't double-click a multi!" );
×
56
  throw std::runtime_error( "double_click() on a multi should not be possible." );
×
57
}
58

59
UBoat* UMulti::as_boat()
15✔
60
{
61
  return nullptr;
15✔
62
}
63
UHouse* UMulti::as_house()
18,358✔
64
{
65
  return nullptr;
18,358✔
66
}
67

68
void UMulti::register_object( UObject* /*obj*/ ) {}
×
69

70
void UMulti::unregister_object( UObject* /*obj*/ ) {}
×
71

72
const char* UMulti::classname() const
6✔
73
{
74
  return "MULTI";
6✔
75
}
76

77
const MultiDef& UMulti::multidef() const
24,012✔
78
{
79
  passert( MultiDefByMultiIDExists( multiid_ ) );
24,012✔
80

81
  return *MultiDefByMultiID( multiid_ );
24,012✔
82
}
83

84
Bscript::BStruct* UMulti::footprint() const
2✔
85
{
86
  const MultiDef& md = multidef();
2✔
87
  std::unique_ptr<Bscript::BStruct> ret( new Bscript::BStruct );
2✔
88
  ret->addMember( "xmin", new Bscript::BLong( x() + md.minrxyz.x() ) );
2✔
89
  ret->addMember( "xmax", new Bscript::BLong( x() + md.maxrxyz.x() ) );
2✔
90
  ret->addMember( "ymin", new Bscript::BLong( y() + md.minrxyz.y() ) );
2✔
91
  ret->addMember( "ymax", new Bscript::BLong( y() + md.maxrxyz.y() ) );
2✔
92
  return ret.release();
4✔
93
}
2✔
94

95
Core::Range3d UMulti::current_box() const
52✔
96
{
97
  const MultiDef& md = multidef();
52✔
98
  return Core::Range3d( pos() + md.minrxyz, pos() + md.maxrxyz );
52✔
99
}
100

101
u8 UMulti::visible_size() const
168✔
102
{
103
  const MultiDef& md = multidef();
168✔
104
  return md.max_radius;
168✔
105
}
106

107
Bscript::BObjectImp* UMulti::get_script_member_id( const int id ) const  /// id test
6,234✔
108
{
109
  Bscript::BObjectImp* imp = base::get_script_member_id( id );
6,234✔
110
  if ( imp )
6,234✔
111
    return imp;
6,180✔
112

113
  switch ( id )
54✔
114
  {
115
  case Bscript::MBR_FOOTPRINT:
2✔
116
    return footprint();
2✔
117
  case Bscript::MBR_ITEMS_DECAY:
2✔
118
    return new Bscript::BLong( items_decay() );
2✔
119
  default:
50✔
120
    return nullptr;
50✔
121
  }
122
}
123

124
Bscript::BObjectImp* UMulti::get_script_member( const char* membername ) const
×
125
{
126
  Bscript::ObjMember* objmember = Bscript::getKnownObjMember( membername );
×
127
  if ( objmember != nullptr )
×
128
    return this->get_script_member_id( objmember->id );
×
129
  return nullptr;
×
130
}
131

132
Bscript::BObjectImp* UMulti::set_script_member_id( const int id, int value )
1✔
133
{
134
  auto* imp = base::set_script_member_id( id, value );
1✔
135
  if ( imp != nullptr )
1✔
136
    return imp;
×
137

138
  switch ( id )
1✔
139
  {
140
  case Bscript::MBR_ITEMS_DECAY:
1✔
141
    items_decay_ = value != 0;
1✔
142
    return new Bscript::BLong( items_decay_ );
1✔
143
  default:
×
144
    break;
×
145
  }
146
  return nullptr;
×
147
}
148

149
bool UMulti::get_method_hook( const char* methodname, Bscript::Executor* ex,
×
150
                              Core::ExportScript** hook, unsigned int* PC ) const
151
{
152
  if ( Core::gamestate.system_hooks.get_method_hook(
×
153
           Core::gamestate.system_hooks.multi_method_script.get(), methodname, ex, hook, PC ) )
154
    return true;
×
155
  return base::get_method_hook( methodname, ex, hook, PC );
×
156
}
157

158
void UMulti::readProperties( Clib::ConfigElem& elem )
3✔
159
{
160
  base::readProperties( elem );
3✔
161
  // POL098 and earlier was not saving a MultiID in its data files,
162
  // but it was using 0x4000 + id as graphic instead. Not respecting
163
  // this would rotate most of the boats during POL098 -> POL99 migration
164
  if ( as_boat() )
3✔
165
  {
166
    if ( Core::settingsManager.polvar.DataWrittenBy99OrLater )
1✔
167
      multiid_ = elem.remove_ushort( "MultiID", this->multidef().multiid );
1✔
168
  }
169
  else
170
    multiid_ = elem.remove_ushort( "MultiID", multidef().multiid );
2✔
171
  const auto& desc = static_cast<const Items::MultiDesc&>( itemdesc() );
3✔
172
  items_decay_ = elem.remove_ushort( "ItemsDecay", desc.items_decay );
3✔
173
}
3✔
174

175
void UMulti::printProperties( Clib::StreamWriter& sw ) const
6✔
176
{
177
  base::printProperties( sw );
6✔
178

179
  sw.add( "MultiID", multiid_ );
6✔
180
  if ( static_cast<const Items::MultiDesc&>( itemdesc() ).items_decay != items_decay_ )
6✔
181
    sw.add( "ItemsDecay", items_decay_ );
2✔
182
}
6✔
183

184
void UMulti::items_decay( bool decay )
1✔
185
{
186
  items_decay_ = decay;
1✔
187
}
1✔
188

UNCOV
189
size_t UMulti::estimatedSize() const
×
190
{
UNCOV
191
  return base::estimatedSize() + sizeof( u16 ) /*multiid*/
×
UNCOV
192
         + sizeof( bool ) /*items_decay*/;
×
193
}
194
}  // namespace Multi
195
}  // 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