Pol  Revision:cb584c9
item00.cpp
Go to the documentation of this file.
1 
10 #include <stddef.h>
11 
12 #include "../baseobject.h"
13 #include "../gameclck.h"
14 #include "../globals/state.h"
15 #include "../resource.h"
16 #include "../uobjcnt.h"
17 #include "../uobject.h"
18 #include "item.h"
19 #include "itemdesc.h"
20 
21 namespace Pol
22 {
23 namespace Items
24 {
25 Item::Item( const ItemDesc& id, Core::UOBJ_CLASS uobj_class )
26  : UObject( id.objtype, uobj_class ),
27  container( nullptr ),
28  decayat_gameclock_( 0 ),
29  amount_( 1 ),
30  slot_index_( 0 ),
31  _itemdesc( nullptr ),
32  layer( 0 ),
33  hp_( id.maxhp )
34 {
35  graphic = id.graphic;
36  color = id.color;
37  setfacing( id.facing );
38  equip_script_ = id.equip_script;
39  unequip_script_ = id.unequip_script;
40  newbie( id.newbie );
41  insured( id.insured );
42  movable( id.default_movable() );
43  inuse( false );
44  invisible( id.invisible );
45 
47 
48  // hmm, doesn't quite work right with items created on startup..
49  decayat_gameclock_ = Core::read_gameclock() + id.decay_time * 60;
50 }
51 
53 {
56 }
57 
58 size_t Item::estimatedSize() const
59 {
60  return base::estimatedSize() + sizeof( Core::UContainer* ) /* container*/
61  + sizeof( int ) /* decayat_gameclock_*/
62  + sizeof( u16 ) /* amount_*/
63  + sizeof( u8 ) /* slot_index_*/
64  + sizeof( const ItemDesc* ) /* _itemdesc*/
65  + sizeof( u8 ) /* layer*/
66  + sizeof( u8 ) /* tile_layer*/
67  + sizeof( unsigned short ) /* hp_*/
68  + sizeof( boost_utils::script_name_flystring ) /*on_use_script_*/
69  + sizeof( boost_utils::script_name_flystring ) /*equip_script_*/
70  + sizeof( boost_utils::script_name_flystring ); /*unequip_script_*/
71 }
72 }
73 }
unsigned char u8
Definition: rawtypes.h:25
bool newbie() const
Definition: item.h:338
virtual ~Item()
Definition: item00.cpp:52
void return_resources(u32 objtype, u16)
Definition: itemdesc.cpp:1232
boost_utils::script_name_flystring unequip_script_
Definition: item.h:265
virtual size_t estimatedSize() const
Definition: uobject.cpp:106
unsigned short u16
Definition: rawtypes.h:26
Item(const ItemDesc &itemdesc, Core::UOBJ_CLASS uobj_class)
Definition: item00.cpp:25
virtual void setfacing(u8 newfacing) POL_OVERRIDE
Definition: item.cpp:888
unsigned int decayat_gameclock_
Definition: item.h:259
gameclock_t read_gameclock()
Reads the current value of the game clock.
Definition: gameclck.cpp:57
const u32 objtype_
Definition: uobject.h:249
bool movable() const
Definition: item.h:300
StateManager stateManager
Definition: state.cpp:8
virtual size_t estimatedSize() const POL_OVERRIDE
Definition: item00.cpp:58
boost::flyweight< std::string, boost::flyweights::tag< script_name_tag >, FLYWEIGHT_HASH_FACTORY > script_name_flystring
Definition: boostutils.h:148
bool invisible() const
Definition: item.h:324
bool default_movable() const
Definition: item.cpp:275
bool inuse() const
Definition: item.h:314
bool insured() const
Definition: item.h:348
Definition: berror.cpp:12
boost_utils::script_name_flystring equip_script_
Definition: item.h:264
UObjCount uobjcount
Definition: state.h:49