Pol  Revision:cb584c9
dynproperties.h File Reference
#include <bitset>
#include <boost/any.hpp>
#include <boost/variant.hpp>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>
#include "../clib/passert.h"
#include "../clib/rawtypes.h"
#include "gameclck.h"

Go to the source code of this file.

Classes

struct  Pol::Core::can_be_used_in_variant< T >
 
class  Pol::Core::DynamicPropsHolder
 
class  Pol::Core::DynProps
 
struct  Pol::Core::ExtStatBarFollowers
 
struct  Pol::Core::MovementCostMod
 
class  Pol::Core::PropHolder< Storage >
 
class  Pol::Core::PropHolderContainer< Storage >
 
class  Pol::Core::PropHolderContainer< Storage >
 
struct  Pol::Core::SkillStatCap
 
struct  Pol::Core::ValueModPack
 

Namespaces

 Pol
 
 Pol::Core
 

Macros

#define DYN_PROPERTY(name, type, id, defaultvalue)
 
#define DYN_PROPERTY_POINTER(name, type, id)
 

Typedefs

typedef boost::variant< u8, u16, u32, s8, s16, s32, ValueModPack, SkillStatCap, ExtStatBarFollowers, gameclock_t > Pol::Core::variant_storage
 

Enumerations

enum  Pol::Core::DynPropTypes : u8 {
  Pol::Core::PROP_AR_MOD = 0, Pol::Core::PROP_MAX_ITEMS_MOD = 1, Pol::Core::PROP_MAX_SLOTS_MOD = 2, Pol::Core::PROP_MAX_WEIGHT_MOD = 3,
  Pol::Core::PROP_SELLPRICE = 4, Pol::Core::PROP_BUYPRICE = 5, Pol::Core::PROP_MAXHP_MOD = 6, Pol::Core::PROP_NAME_SUFFIX = 7,
  Pol::Core::PROP_RESIST_FIRE = 8, Pol::Core::PROP_RESIST_COLD = 9, Pol::Core::PROP_RESIST_ENERGY = 10, Pol::Core::PROP_RESIST_POISON = 11,
  Pol::Core::PROP_RESIST_PHYSICAL = 12, Pol::Core::PROP_DAMAGE_FIRE = 13, Pol::Core::PROP_DAMAGE_COLD = 14, Pol::Core::PROP_DAMAGE_ENERGY = 15,
  Pol::Core::PROP_DAMAGE_POISON = 16, Pol::Core::PROP_DAMAGE_PHYSICAL = 17, Pol::Core::PROP_DMG_MOD = 18, Pol::Core::PROP_SPEED_MOD = 19,
  Pol::Core::PROP_ORIG_RESIST_FIRE = 20, Pol::Core::PROP_ORIG_RESIST_COLD = 21, Pol::Core::PROP_ORIG_RESIST_ENERGY = 22, Pol::Core::PROP_ORIG_RESIST_POISON = 23,
  Pol::Core::PROP_ORIG_RESIST_PHYSICAL = 24, Pol::Core::PROP_ORIG_DAMAGE_FIRE = 25, Pol::Core::PROP_ORIG_DAMAGE_COLD = 26, Pol::Core::PROP_ORIG_DAMAGE_ENERGY = 27,
  Pol::Core::PROP_ORIG_DAMAGE_POISON = 28, Pol::Core::PROP_ORIG_DAMAGE_PHYSICAL = 29, Pol::Core::PROP_STATCAP_SKILLCAP = 30, Pol::Core::PROP_EXT_STATBAR_LUCK = 31,
  Pol::Core::PROP_EXT_STATBAR_FOLLOWERS = 32, Pol::Core::PROP_EXT_STATBAR_TITHING = 33, Pol::Core::PROP_MOVEMENTCOST_MOD = 34, Pol::Core::PROP_QUALITY = 35,
  Pol::Core::PROP_DOUBLECLICK_WAIT = 36, Pol::Core::PROP_DISABLE_SKILLS_UNTIL = 37, Pol::Core::PROP_SQUELCHED_UNTIL = 38, Pol::Core::PROP_DEAFENED_UNTIL = 39,
  Pol::Core::PROP_LIGHTOVERRIDE_UNTIL = 40, Pol::Core::PROP_LIGHTOVERRIDE = 41, Pol::Core::PROP_TITLE_PREFIX = 42, Pol::Core::PROP_TITLE_SUFFIX = 43,
  Pol::Core::PROP_TITLE_GUILD = 44, Pol::Core::PROP_TITLE_RACE = 45, Pol::Core::PROP_SPEECH_COLOR = 46, Pol::Core::PROP_SPEECH_FONT = 47,
  Pol::Core::PROP_CARRY_CAPACITY_MOD = 48, Pol::Core::PROP_DELAY_MOD = 49, Pol::Core::PROP_HITCHANCE_MOD = 50, Pol::Core::PROP_EVASIONCHANCE_MOD = 51,
  Pol::Core::PROP_PARTY = 52, Pol::Core::PROP_PARTY_CANDIDATE = 53, Pol::Core::PROP_PARTY_OFFLINE = 54, Pol::Core::PROP_GUILD = 55,
  Pol::Core::PROP_GOTTEN_BY = 56, Pol::Core::PROP_GOTTEN_ITEM = 57, Pol::Core::PROP_PROCESS = 58, Pol::Core::PROP_HOUSE = 59,
  Pol::Core::PROP_FLAG_SIZE
}
 

Detailed Description

History
Design decisions (64bit)
Since boost::any has a size of 8 a padding of 8 will be introduced which means that even if the prop type is a u8 full 16 bytes will be used boost::variant is as big as the biggest possible value plus a type information member in our case the biggest type to store in a variant is u32 thus only a padding of 4 exists: min/max size is 12 instead of 16 an empty vector still uses 24bytes moving the vectors into a pointer saves if unused 16bytes.
Layout
  • Uobject
    • ptr DynProps -> 8 bytes per object
  • DynProps
    • bitset (currently 4 bytes (more then 32 types = 8 bytes)
    • vector<PropHolder> variant version
    • ptr vector<PropHolder> any version -> N "small" properties: 4+24+12*N+8 = 36+12*N -> +M "big" properties: +24+(16+unk)*M = (36+12*N) + (24+(16+unk)*M) unk is the type size which is stored in boost::any
Todo:
Is it worse it to combine e.g resistances struct? 5 * s16 24+12*5 -> 84 Combining means storage as boost::any: 24+(16+5*2) -> 50 But only valid if all 5 props are really set, if only 2 props are set variant is smaller-> 24+12*2=48 Different idea combine per resistance type mod and real value: for variant its still 24+12*5 -> 84 any would use 24+(16+5*2)*2 -> 76 (but again only if all props are set) Combining would use the u32 size for a prop in a variant without loss (2*s16) -> 8 props can be stored with less space

Definition in file dynproperties.h.

Macro Definition Documentation

#define DYN_PROPERTY (   name,
  type,
  id,
  defaultvalue 
)
Value:
type name() const \
{ \
type val; \
if ( getmember<type>( id, &val ) ) \
return val; \
return defaultvalue; \
}; \
void name( const type& val ) { setmember( id, val, static_cast<type>( defaultvalue ) ); }; \
bool has_##name() const { return hasmember( id ); }
std::string name
Definition: osmod.cpp:943

Definition at line 62 of file dynproperties.h.

Referenced by Pol::Testing::dynprops_test(), Pol::Core::UContainer::get_chr_owner(), Pol::Items::UArmor::~UArmor(), and Pol::Items::UWeapon::~UWeapon().

#define DYN_PROPERTY_POINTER (   name,
  type,
  id 
)
Value:
type name() const \
{ \
type val; \
if ( getmember<type>( id, &val ) ) \
return val; \
return nullptr; \
}; \
void name( type val ) { setmemberPointer( id, val ); }; \
bool has_##name() const { return hasmember( id ); }
std::string name
Definition: osmod.cpp:943

Definition at line 73 of file dynproperties.h.