15 #ifndef __CLIB_RAWTYPES_H 16 #include "../clib/rawtypes.h" 20 #include <boost/any.hpp> 21 #include <boost/flyweight.hpp> 26 #include <type_traits> 28 #include "../clib/boostutils.h" 29 #include "../clib/refptr.h" 67 class WornItemsContainer;
69 #pragma pack( push, 1 ) 100 template <
typename ENUM,
101 typename std::enable_if<
102 std::is_enum<ENUM>::value && !std::is_convertible<ENUM, int>::value,
int>::type = 0>
105 typedef typename std::underlying_type<ENUM>::type
enum_t;
108 bool get( ENUM flag )
const 111 return ( flags_ & static_cast<enum_t>( flag ) ) == static_cast<enum_t>( flag );
113 void set( ENUM flag ) { flags_ |=
static_cast<enum_t
>( flag ); };
114 void remove( ENUM flag ) { flags_ &= ~static_cast<enum_t>( flag ); };
149 virtual std::string
name()
const;
150 virtual std::string description()
const;
152 bool specific_name()
const;
153 void setname(
const std::string& );
155 bool getprop(
const std::string& propname, std::string& propvalue )
const;
156 void setprop(
const std::string& propname,
const std::string& propvalue );
157 void eraseprop(
const std::string& propname );
158 void copyprops(
const UObject& obj );
160 void getpropnames( std::vector<std::string>& propnames )
const;
163 virtual void destroy();
165 virtual unsigned int weight()
const = 0;
167 virtual UObject* toplevel_owner();
169 virtual const UObject* owner()
const;
170 virtual UObject* self_as_owner();
171 virtual const UObject* self_as_owner()
const;
172 virtual const UObject* toplevel_owner()
const;
173 virtual bool setgraphic(
u16 newobjtype );
174 virtual bool setcolor(
u16 newcolor );
175 virtual void on_color_changed();
177 virtual void setfacing(
u8 newfacing ) = 0;
178 virtual void on_facing_changed();
180 bool saveonexit()
const;
181 void saveonexit(
bool newvalue );
187 virtual void fixInvalidGraphic();
195 const std::string& value );
197 virtual Bscript::BObjectImp* set_script_member_double(
const char* membername,
double value );
199 virtual Bscript::BObjectImp* set_script_member_id(
const int id,
const std::string& value );
208 virtual bool script_isa(
unsigned isatype )
const;
209 virtual const char* target_tag()
const;
211 virtual const char* classname()
const = 0;
213 virtual size_t estimatedSize()
const;
215 void ref_counted_add_ref();
216 void ref_counted_release();
217 unsigned ref_counted_count()
const;
223 void clear_dirty()
const;
256 DYN_PROPERTY( fire_resist, ValueModPack, PROP_RESIST_FIRE, ValueModPack::DEFAULT );
257 DYN_PROPERTY( cold_resist, ValueModPack, PROP_RESIST_COLD, ValueModPack::DEFAULT );
258 DYN_PROPERTY( energy_resist, ValueModPack, PROP_RESIST_ENERGY, ValueModPack::DEFAULT );
259 DYN_PROPERTY( poison_resist, ValueModPack, PROP_RESIST_POISON, ValueModPack::DEFAULT );
260 DYN_PROPERTY( physical_resist, ValueModPack, PROP_RESIST_PHYSICAL, ValueModPack::DEFAULT );
262 DYN_PROPERTY( fire_damage, ValueModPack, PROP_DAMAGE_FIRE, ValueModPack::DEFAULT );
263 DYN_PROPERTY( cold_damage, ValueModPack, PROP_DAMAGE_COLD, ValueModPack::DEFAULT );
264 DYN_PROPERTY( energy_damage, ValueModPack, PROP_DAMAGE_ENERGY, ValueModPack::DEFAULT );
265 DYN_PROPERTY( poison_damage, ValueModPack, PROP_DAMAGE_POISON, ValueModPack::DEFAULT );
266 DYN_PROPERTY( physical_damage, ValueModPack, PROP_DAMAGE_PHYSICAL, ValueModPack::DEFAULT );
281 UObject& operator=( const UObject& );
286 inline bool UObject::specific_name() const
288 return !name_.get().empty();
291 inline void UObject::set_dirty()
293 flags_.set( OBJ_FLAGS::DIRTY );
296 inline void UObject::ref_counted_add_ref()
298 ref_counted::add_ref( REFERER_PARAM( this ) );
301 inline void UObject::ref_counted_release()
303 ref_counted::release( REFERER_PARAM( this ) );
306 inline unsigned UObject::ref_counted_count() const
308 return ref_counted::count();
311 inline bool IsCharacter( u32 serial )
313 return ( ~serial & 0x40000000Lu ) ? true : false;
316 inline bool IsItem( u32 serial )
318 return ( serial & 0x40000000Lu ) ? true : false;
static std::atomic< unsigned int > dirty_writes
ref_counted * as_ref_counted()
static std::atomic< unsigned int > clean_writes
std::underlying_type< ENUM >::type enum_t
#define DYN_PROPERTY(name, type, id, defaultvalue)
void change(ENUM flag, bool value)
boost::flyweight< std::string, boost::flyweights::tag< object_name_tag >, FLYWEIGHT_HASH_FACTORY > object_name_flystring