diff --git a/src/xrServerEntities/InfoPortionDefs.h b/src/xrServerEntities/InfoPortionDefs.h index 38d5f0a5dd8..729f6030d12 100644 --- a/src/xrServerEntities/InfoPortionDefs.h +++ b/src/xrServerEntities/InfoPortionDefs.h @@ -1,14 +1,13 @@ #pragma once - typedef shared_str INFO_DATA; DEFINE_VECTOR(INFO_DATA, KNOWN_INFO_VECTOR, KNOWN_INFO_VECTOR_IT); class CFindByIDPred { public: - CFindByIDPred(shared_str element_to_find) {element = element_to_find;} - IC bool operator () (const INFO_DATA& data) const {return data == element;} + CFindByIDPred(shared_str element_to_find) { element = element_to_find; } + IC bool operator()(const INFO_DATA& data) const { return data == element; } private: - shared_str element; + shared_str element; }; diff --git a/src/xrServerEntities/ItemListTypes.h b/src/xrServerEntities/ItemListTypes.h index 8179c65e252..219dd934218 100644 --- a/src/xrServerEntities/ItemListTypes.h +++ b/src/xrServerEntities/ItemListTypes.h @@ -4,50 +4,56 @@ //--------------------------------------------------------------------------- -class ListItem{ - friend class CListHelper; - friend class TItemList; - shared_str key; - int type; - void* item; -public: - typedef fastdelegate::FastDelegate1 TOnListItemFocused; - typedef fastdelegate::FastDelegate1 TOnClick; - TOnClick OnClickEvent; - TOnListItemFocused OnItemFocused; - TOnDrawThumbnail OnDrawThumbnail; +class ListItem +{ + friend class CListHelper; + friend class TItemList; + shared_str key; + int type; + void* item; + public: - int tag; - LPVOID m_Object; - int icon_index; - u32 prop_color; + typedef fastdelegate::FastDelegate1 TOnListItemFocused; + typedef fastdelegate::FastDelegate1 TOnClick; + TOnClick OnClickEvent; + TOnListItemFocused OnItemFocused; + TOnDrawThumbnail OnDrawThumbnail; + public: - enum{ - flShowCB = (1<<0), - flCBChecked = (1<<1), - flDrawThumbnail = (1<<2), - flDrawCanvas = (1<<3), - flSorted = (1<<4), - flHidden = (1<<5), - }; - Flags32 m_Flags; + int tag; + LPVOID m_Object; + int icon_index; + u32 prop_color; + public: - ListItem (int _type):type(_type),prop_color(0),item(0),key(0),tag(0),icon_index(-1),OnDrawThumbnail(0),OnItemFocused(0),m_Object(0){m_Flags.zero();} - virtual ~ListItem (){}; - void SetName (LPCSTR _key){key=_key;} + enum + { + flShowCB = (1 << 0), + flCBChecked = (1 << 1), + flDrawThumbnail = (1 << 2), + flDrawCanvas = (1 << 3), + flSorted = (1 << 4), + flHidden = (1 << 5), + }; + Flags32 m_Flags; - IC void Visible (BOOL val){m_Flags.set(flHidden, !val);} - IC BOOL Visible () const{ return !m_Flags.test(flHidden);} - IC int Type (){return type;} - IC void* Item (){return item;} - IC LPCSTR Key (){return *key;} - IC void SetIcon (int index){icon_index=index;} +public: + ListItem(int _type) + : type(_type), prop_color(0), item(0), key(0), tag(0), icon_index(-1), OnDrawThumbnail(0), OnItemFocused(0), + m_Object(0) + { + m_Flags.zero(); + } + virtual ~ListItem(){}; + void SetName(LPCSTR _key) { key = _key; } + IC void Visible(BOOL val) { m_Flags.set(flHidden, !val); } + IC BOOL Visible() const { return !m_Flags.test(flHidden); } + IC int Type() { return type; } + IC void* Item() { return item; } + IC LPCSTR Key() { return *key; } + IC void SetIcon(int index) { icon_index = index; } }; -DEFINE_VECTOR (ListItem*,ListItemsVec,ListItemsIt); +DEFINE_VECTOR(ListItem*, ListItemsVec, ListItemsIt); //--------------------------------------------------------------------------- #endif - - - - diff --git a/src/xrServerEntities/PHNetState.cpp b/src/xrServerEntities/PHNetState.cpp index 1094dedc375..cafeef05acd 100644 --- a/src/xrServerEntities/PHNetState.cpp +++ b/src/xrServerEntities/PHNetState.cpp @@ -5,266 +5,263 @@ //////////////////////////////////////8///////////////////////////////////////////////////// -static void w_vec_q8(NET_Packet& P,const Fvector& vec,const Fvector& min,const Fvector& max) +static void w_vec_q8(NET_Packet& P, const Fvector& vec, const Fvector& min, const Fvector& max) { - P.w_float_q8(vec.x,min.x,max.x); - P.w_float_q8(vec.y,min.y,max.y); - P.w_float_q8(vec.z,min.z,max.z); + P.w_float_q8(vec.x, min.x, max.x); + P.w_float_q8(vec.y, min.y, max.y); + P.w_float_q8(vec.z, min.z, max.z); } -template -static void r_vec_q8(src& P,Fvector& vec,const Fvector& min,const Fvector& max) +template +static void r_vec_q8(src& P, Fvector& vec, const Fvector& min, const Fvector& max) { - vec.x=P.r_float_q8(min.x,max.x); - vec.y=P.r_float_q8(min.y,max.y); - vec.z=P.r_float_q8(min.z,max.z); + vec.x = P.r_float_q8(min.x, max.x); + vec.y = P.r_float_q8(min.y, max.y); + vec.z = P.r_float_q8(min.z, max.z); - clamp(vec.x,min.x,max.x); - clamp(vec.y,min.y,max.y); - clamp(vec.z,min.z,max.z); + clamp(vec.x, min.x, max.x); + clamp(vec.y, min.y, max.y); + clamp(vec.z, min.z, max.z); } -static void w_qt_q8(NET_Packet& P,const Fquaternion& q) +static void w_qt_q8(NET_Packet& P, const Fquaternion& q) { - //Fvector Q; - //Q.set(q.x,q.y,q.z); - //if(q.w<0.f) Q.invert(); - //P.w_float_q8(Q.x,-1.f,1.f); - //P.w_float_q8(Q.y,-1.f,1.f); - //P.w_float_q8(Q.z,-1.f,1.f); -/////////////////////////////////////////////////// - P.w_float_q8(q.x,-1.f,1.f); - P.w_float_q8(q.y,-1.f,1.f); - P.w_float_q8(q.z,-1.f,1.f); - P.w_float_q8(q.w,-1.f,1.f); - -/////////////////////////////////////////// - - - //P.w_float_q8(q.x,-1.f,1.f); - //P.w_float_q8(q.y,-1.f,1.f); - //P.w_float_q8(q.z,-1.f,1.f); - //P.w(sign()) + // Fvector Q; + // Q.set(q.x,q.y,q.z); + // if(q.w<0.f) Q.invert(); + // P.w_float_q8(Q.x,-1.f,1.f); + // P.w_float_q8(Q.y,-1.f,1.f); + // P.w_float_q8(Q.z,-1.f,1.f); + /////////////////////////////////////////////////// + P.w_float_q8(q.x, -1.f, 1.f); + P.w_float_q8(q.y, -1.f, 1.f); + P.w_float_q8(q.z, -1.f, 1.f); + P.w_float_q8(q.w, -1.f, 1.f); + + /////////////////////////////////////////// + + // P.w_float_q8(q.x,-1.f,1.f); + // P.w_float_q8(q.y,-1.f,1.f); + // P.w_float_q8(q.z,-1.f,1.f); + // P.w(sign()) } -template -static void r_qt_q8(src& P,Fquaternion& q) +template +static void r_qt_q8(src& P, Fquaternion& q) { - //// x^2 + y^2 + z^2 + w^2 = 1 - //P.r_float_q8(q.x,-1.f,1.f); - //P.r_float_q8(q.y,-1.f,1.f); - //P.r_float_q8(q.z,-1.f,1.f); - //float w2=1.f-q.x*q.x-q.y*q.y-q.z*q.z; - //w2=w2<0.f ? 0.f : w2; - //q.w=_sqrt(w2); -///////////////////////////////////////////////////// - /////////////////////////////////////////////////// - q.x=P.r_float_q8(-1.f,1.f); - q.y=P.r_float_q8(-1.f,1.f); - q.z=P.r_float_q8(-1.f,1.f); - q.w=P.r_float_q8(-1.f,1.f); + //// x^2 + y^2 + z^2 + w^2 = 1 + // P.r_float_q8(q.x,-1.f,1.f); + // P.r_float_q8(q.y,-1.f,1.f); + // P.r_float_q8(q.z,-1.f,1.f); + // float w2=1.f-q.x*q.x-q.y*q.y-q.z*q.z; + // w2=w2<0.f ? 0.f : w2; + // q.w=_sqrt(w2); + ///////////////////////////////////////////////////// + /////////////////////////////////////////////////// + q.x = P.r_float_q8(-1.f, 1.f); + q.y = P.r_float_q8(-1.f, 1.f); + q.z = P.r_float_q8(-1.f, 1.f); + q.w = P.r_float_q8(-1.f, 1.f); - clamp(q.x,-1.f,1.f); - clamp(q.y,-1.f,1.f); - clamp(q.z,-1.f,1.f); - clamp(q.w,-1.f,1.f); + clamp(q.x, -1.f, 1.f); + clamp(q.y, -1.f, 1.f); + clamp(q.z, -1.f, 1.f); + clamp(q.w, -1.f, 1.f); } #ifdef XRGAME_EXPORTS /////////////////////////////////16//////////////////////////////////////////////////////////////// -static void w_vec_q16(NET_Packet& P,const Fvector& vec,const Fvector& min,const Fvector& max) +static void w_vec_q16(NET_Packet& P, const Fvector& vec, const Fvector& min, const Fvector& max) { - P.w_float_q16(vec.x,min.x,max.x); - P.w_float_q16(vec.y,min.y,max.y); - P.w_float_q16(vec.z,min.z,max.z); + P.w_float_q16(vec.x, min.x, max.x); + P.w_float_q16(vec.y, min.y, max.y); + P.w_float_q16(vec.z, min.z, max.z); } -static void r_vec_q16(NET_Packet& P,Fvector& vec,const Fvector& min,const Fvector& max) +static void r_vec_q16(NET_Packet& P, Fvector& vec, const Fvector& min, const Fvector& max) { - P.r_float_q16(vec.x,min.x,max.x); - P.r_float_q16(vec.y,min.y,max.y); - P.r_float_q16(vec.z,min.z,max.z); - - //clamp(vec.x,min.x,max.x); - //clamp(vec.y,min.y,max.y); - //clamp(vec.z,min.z,max.z); + P.r_float_q16(vec.x, min.x, max.x); + P.r_float_q16(vec.y, min.y, max.y); + P.r_float_q16(vec.z, min.z, max.z); + + // clamp(vec.x,min.x,max.x); + // clamp(vec.y,min.y,max.y); + // clamp(vec.z,min.z,max.z); } -template -static void w_qt_q16(src& P,const Fquaternion& q) +template +static void w_qt_q16(src& P, const Fquaternion& q) { - //Fvector Q; - //Q.set(q.x,q.y,q.z); - //if(q.w<0.f) Q.invert(); - //P.w_float_q16(Q.x,-1.f,1.f); - //P.w_float_q16(Q.y,-1.f,1.f); - //P.w_float_q16(Q.z,-1.f,1.f); - /////////////////////////////////////////// - P.w_float_q16(q.x,-1.f,1.f); - P.w_float_q16(q.y,-1.f,1.f); - P.w_float_q16(q.z,-1.f,1.f); - P.w_float_q16(q.w,-1.f,1.f); + // Fvector Q; + // Q.set(q.x,q.y,q.z); + // if(q.w<0.f) Q.invert(); + // P.w_float_q16(Q.x,-1.f,1.f); + // P.w_float_q16(Q.y,-1.f,1.f); + // P.w_float_q16(Q.z,-1.f,1.f); + /////////////////////////////////////////// + P.w_float_q16(q.x, -1.f, 1.f); + P.w_float_q16(q.y, -1.f, 1.f); + P.w_float_q16(q.z, -1.f, 1.f); + P.w_float_q16(q.w, -1.f, 1.f); } -static void r_qt_q16(NET_Packet& P,Fquaternion& q) +static void r_qt_q16(NET_Packet& P, Fquaternion& q) { - // x^2 + y^2 + z^2 + w^2 = 1 - //P.r_float_q16(q.x,-1.f,1.f); - //P.r_float_q16(q.y,-1.f,1.f); - //P.r_float_q16(q.z,-1.f,1.f); - //float w2=1.f-q.x*q.x-q.y*q.y-q.z*q.z; - //w2=w2<0.f ? 0.f : w2; - //q.w=_sqrt(w2); -/////////////////////////////////////////////////// - P.r_float_q16(q.x,-1.f,1.f); - P.r_float_q16(q.y,-1.f,1.f); - P.r_float_q16(q.z,-1.f,1.f); - P.r_float_q16(q.w,-1.f,1.f); + // x^2 + y^2 + z^2 + w^2 = 1 + // P.r_float_q16(q.x,-1.f,1.f); + // P.r_float_q16(q.y,-1.f,1.f); + // P.r_float_q16(q.z,-1.f,1.f); + // float w2=1.f-q.x*q.x-q.y*q.y-q.z*q.z; + // w2=w2<0.f ? 0.f : w2; + // q.w=_sqrt(w2); + /////////////////////////////////////////////////// + P.r_float_q16(q.x, -1.f, 1.f); + P.r_float_q16(q.y, -1.f, 1.f); + P.r_float_q16(q.z, -1.f, 1.f); + P.r_float_q16(q.w, -1.f, 1.f); - //clamp(q.x,-1.f,1.f); - //clamp(q.y,-1.f,1.f); - //clamp(q.z,-1.f,1.f); - //clamp(q.w,-1.f,1.f); + // clamp(q.x,-1.f,1.f); + // clamp(q.y,-1.f,1.f); + // clamp(q.z,-1.f,1.f); + // clamp(q.w,-1.f,1.f); } #endif /////////////////////////////////////////////////////////////////////////////////// -void SPHNetState::net_Export(NET_Packet& P) +void SPHNetState::net_Export(NET_Packet& P) { - P.w_vec3(linear_vel); - //P.w_vec3(angular_vel); - //P.w_vec3(force); - //P.w_vec3(torque); - P.w_vec3(position); - P.w_vec4(*((Fvector4*)&quaternion)); - //P.w_vec4(*((Fvector4*)&previous_quaternion)); - P.w_u8 ((u8)enabled); - + P.w_vec3(linear_vel); + // P.w_vec3(angular_vel); + // P.w_vec3(force); + // P.w_vec3(torque); + P.w_vec3(position); + P.w_vec4(*((Fvector4*)&quaternion)); + // P.w_vec4(*((Fvector4*)&previous_quaternion)); + P.w_u8((u8)enabled); } -template -void SPHNetState::read (src& P) +template +void SPHNetState::read(src& P) { - linear_vel=P.r_vec3(); - angular_vel.set(0.f,0.f,0.f); //P.r_vec3(angular_vel); - force.set(0.f,0.f,0.f); //P.r_vec3(force); - torque.set(0.f,0.f,0.f); //P.r_vec3(torque); - position=P.r_vec3(); - *((Fvector4*)&quaternion)=P.r_vec4(); - previous_quaternion.set(quaternion);//P.r_vec4(*((Fvector4*)&previous_quaternion)); - enabled=!!P.r_u8 (); + linear_vel = P.r_vec3(); + angular_vel.set(0.f, 0.f, 0.f); // P.r_vec3(angular_vel); + force.set(0.f, 0.f, 0.f); // P.r_vec3(force); + torque.set(0.f, 0.f, 0.f); // P.r_vec3(torque); + position = P.r_vec3(); + *((Fvector4*)&quaternion) = P.r_vec4(); + previous_quaternion.set(quaternion); // P.r_vec4(*((Fvector4*)&previous_quaternion)); + enabled = !!P.r_u8(); } -void SPHNetState::net_Import(NET_Packet& P) +void SPHNetState::net_Import(NET_Packet& P) { - read(P); + read(P); } void SPHNetState::net_Import(IReader& P) { - read(P); + read(P); } -void SPHNetState::net_Save(NET_Packet &P) +void SPHNetState::net_Save(NET_Packet& P) { - net_Export(P); + net_Export(P); } -void SPHNetState::net_Load(NET_Packet &P) +void SPHNetState::net_Load(NET_Packet& P) { - net_Import(P); - previous_position.set(position); + net_Import(P); + previous_position.set(position); } -void SPHNetState::net_Load(IReader &P) +void SPHNetState::net_Load(IReader& P) { - net_Import(P); - previous_position.set(position); + net_Import(P); + previous_position.set(position); } -void SPHNetState::net_Save(NET_Packet &P,const Fvector& min,const Fvector& max) +void SPHNetState::net_Save(NET_Packet& P, const Fvector& min, const Fvector& max) { - //P.w_vec3(linear_vel); - //P.w_vec3(angular_vel); - //P.w_vec3(force); - //P.w_vec3(torque); - //P.w_vec3(position); - w_vec_q8(P,position,min,max); - w_qt_q8(P,quaternion); - //P.w_vec4(*((Fvector4*)&quaternion)); - //P.w_vec4(*((Fvector4*)&previous_quaternion)); - P.w_u8 ((u8)enabled); + // P.w_vec3(linear_vel); + // P.w_vec3(angular_vel); + // P.w_vec3(force); + // P.w_vec3(torque); + // P.w_vec3(position); + w_vec_q8(P, position, min, max); + w_qt_q8(P, quaternion); + // P.w_vec4(*((Fvector4*)&quaternion)); + // P.w_vec4(*((Fvector4*)&previous_quaternion)); + P.w_u8((u8)enabled); } -template -void SPHNetState::read(src &P,const Fvector& min,const Fvector& max) +template +void SPHNetState::read(src& P, const Fvector& min, const Fvector& max) { -VERIFY( !(fsimilar(min.x,max.x)&&fsimilar(min.y,max.y)&&fsimilar(min.z,max.z)) ); - linear_vel.set(0.f,0.f,0.f); - angular_vel.set(0.f,0.f,0.f); - force.set(0.f,0.f,0.f); - torque.set(0.f,0.f,0.f); - r_vec_q8(P,position,min,max); - previous_position.set(position); - r_qt_q8(P,quaternion); - previous_quaternion.set(quaternion); - enabled=!!P.r_u8(); - + VERIFY(!(fsimilar(min.x, max.x) && fsimilar(min.y, max.y) && fsimilar(min.z, max.z))); + linear_vel.set(0.f, 0.f, 0.f); + angular_vel.set(0.f, 0.f, 0.f); + force.set(0.f, 0.f, 0.f); + torque.set(0.f, 0.f, 0.f); + r_vec_q8(P, position, min, max); + previous_position.set(position); + r_qt_q8(P, quaternion); + previous_quaternion.set(quaternion); + enabled = !!P.r_u8(); } -void SPHNetState::net_Load(NET_Packet &P,const Fvector& min,const Fvector& max) +void SPHNetState::net_Load(NET_Packet& P, const Fvector& min, const Fvector& max) { -VERIFY( !(fsimilar(min.x,max.x)&&fsimilar(min.y,max.y)&&fsimilar(min.z,max.z)) ); - read(P,min,max); + VERIFY(!(fsimilar(min.x, max.x) && fsimilar(min.y, max.y) && fsimilar(min.z, max.z))); + read(P, min, max); } -void SPHNetState::net_Load(IReader &P,const Fvector& min,const Fvector& max) +void SPHNetState::net_Load(IReader& P, const Fvector& min, const Fvector& max) { -VERIFY( !(fsimilar(min.x,max.x)&&fsimilar(min.y,max.y)&&fsimilar(min.z,max.z)) ); - read(P,min,max); + VERIFY(!(fsimilar(min.x, max.x) && fsimilar(min.y, max.y) && fsimilar(min.z, max.z))); + read(P, min, max); } SPHBonesData::SPHBonesData() { - bones_mask =u64(-1); - root_bone =0; + bones_mask = u64(-1); + root_bone = 0; - Fvector _mn, _mx; + Fvector _mn, _mx; - _mn.set (-100.f,-100.f,-100.f); - _mx.set (100.f,100.f,100.f); - set_min_max (_mn, _mx); + _mn.set(-100.f, -100.f, -100.f); + _mx.set(100.f, 100.f, 100.f); + set_min_max(_mn, _mx); } -void SPHBonesData::net_Save(NET_Packet &P) +void SPHBonesData::net_Save(NET_Packet& P) { - P.w_u64 (bones_mask); - P.w_u16 (root_bone); - - P.w_vec3 (get_min()); - P.w_vec3 (get_max()); - P.w_u16 ((u16)bones.size());//bones number; - PHNETSTATE_I i=bones.begin(),e=bones.end(); - for(;e!=i;i++) - { - (*i).net_Save(P,get_min(),get_max()); - } - // this comment is added by Dima (correct me if this is wrong) - // if we call 2 times in a row StateWrite then we get different results - // WHY??? - // bones.clear (); + P.w_u64(bones_mask); + P.w_u16(root_bone); + + P.w_vec3(get_min()); + P.w_vec3(get_max()); + P.w_u16((u16)bones.size()); // bones number; + PHNETSTATE_I i = bones.begin(), e = bones.end(); + for (; e != i; i++) + { + (*i).net_Save(P, get_min(), get_max()); + } + // this comment is added by Dima (correct me if this is wrong) + // if we call 2 times in a row StateWrite then we get different results + // WHY??? + // bones.clear (); } -void SPHBonesData::net_Load(NET_Packet &P) +void SPHBonesData::net_Load(NET_Packet& P) { - bones.clear (); + bones.clear(); - bones_mask =P.r_u64(); - root_bone =P.r_u16(); - Fvector _mn, _mx; - P.r_vec3 (_mn); - P.r_vec3 (_mx); - set_min_max (_mn, _mx); + bones_mask = P.r_u64(); + root_bone = P.r_u16(); + Fvector _mn, _mx; + P.r_vec3(_mn); + P.r_vec3(_mx); + set_min_max(_mn, _mx); - u16 bones_number =P.r_u16();//bones number /**/ - for(int i=0;i - void read ( src& P); -template - void read ( src& P,const Fvector& min,const Fvector& max); + template + void read(src& P); + template + void read(src& P, const Fvector& min, const Fvector& max); }; -DEFINE_VECTOR(SPHNetState,PHNETSTATE_VECTOR,PHNETSTATE_I); +DEFINE_VECTOR(SPHNetState, PHNETSTATE_VECTOR, PHNETSTATE_I); -struct SPHBonesData +struct SPHBonesData { - u64 bones_mask; - u16 root_bone; - PHNETSTATE_VECTOR bones; - Fvector m_min; - Fvector m_max; + u64 bones_mask; + u16 root_bone; + PHNETSTATE_VECTOR bones; + Fvector m_min; + Fvector m_max; + public: - SPHBonesData () ; - void net_Save ( NET_Packet& P); - void net_Load ( NET_Packet& P); - void net_Load ( IReader& P); - void set_min_max (const Fvector& _min, const Fvector& _max); - const Fvector& get_min () const {return m_min;} - const Fvector& get_max () const {return m_max;} + SPHBonesData(); + void net_Save(NET_Packet& P); + void net_Load(NET_Packet& P); + void net_Load(IReader& P); + void set_min_max(const Fvector& _min, const Fvector& _max); + const Fvector& get_min() const { return m_min; } + const Fvector& get_max() const { return m_max; } }; #endif \ No newline at end of file diff --git a/src/xrServerEntities/PHSynchronize.cpp b/src/xrServerEntities/PHSynchronize.cpp index 35c700f273a..be616a7a890 100644 --- a/src/xrServerEntities/PHSynchronize.cpp +++ b/src/xrServerEntities/PHSynchronize.cpp @@ -1,4 +1,2 @@ -#include "stdafx.h" #include "PHSynchronize.h" - - +#include "stdafx.h" diff --git a/src/xrServerEntities/PHSynchronize.h b/src/xrServerEntities/PHSynchronize.h index cad32b32a7d..09ae18eda3c 100644 --- a/src/xrServerEntities/PHSynchronize.h +++ b/src/xrServerEntities/PHSynchronize.h @@ -8,16 +8,15 @@ class NET_Packet; class CPHSynchronize { public: - virtual void net_Export ( NET_Packet& P) {}; // export to server - virtual void net_Import ( NET_Packet& P) {}; - virtual void get_State ( SPHNetState& state) =0; - virtual void set_State (const SPHNetState& state) =0; - virtual void cv2obj_Xfrom (const Fquaternion& q,const Fvector& pos, Fmatrix& xform) =0; - virtual void cv2bone_Xfrom (const Fquaternion& q,const Fvector& pos, Fmatrix& xform) =0; + virtual void net_Export(NET_Packet& P){}; // export to server + virtual void net_Import(NET_Packet& P){}; + virtual void get_State(SPHNetState& state) = 0; + virtual void set_State(const SPHNetState& state) = 0; + virtual void cv2obj_Xfrom(const Fquaternion& q, const Fvector& pos, Fmatrix& xform) = 0; + virtual void cv2bone_Xfrom(const Fquaternion& q, const Fvector& pos, Fmatrix& xform) = 0; + protected: private: }; - - #endif \ No newline at end of file diff --git a/src/xrServerEntities/PropertiesListHelper.h b/src/xrServerEntities/PropertiesListHelper.h index bab39cfac18..b0bb4a640f0 100644 --- a/src/xrServerEntities/PropertiesListHelper.h +++ b/src/xrServerEntities/PropertiesListHelper.h @@ -1,79 +1,107 @@ //--------------------------------------------------------------------------- #ifndef PropertiesListHelperH #define PropertiesListHelperH - + // refs class ListItem; //--------------------------------------------------------------------------- -class CPropHelper:public IPropHelper{ - PropItem* CreateItem (PropItemVec& items, const shared_str& key, EPropType type, u32 item_flags=0); - PropValue* AppendValue (PropItemVec& items, const shared_str& key, PropValue* val, EPropType type, u32 item_flags=0); +class CPropHelper : public IPropHelper +{ + PropItem* CreateItem(PropItemVec& items, const shared_str& key, EPropType type, u32 item_flags = 0); + PropValue* AppendValue( + PropItemVec& items, const shared_str& key, PropValue* val, EPropType type, u32 item_flags = 0); + public: - virtual PropItem* __stdcall FindItem (PropItemVec& items, shared_str key, EPropType type=PROP_UNDEF); + virtual PropItem* __stdcall FindItem(PropItemVec& items, shared_str key, EPropType type = PROP_UNDEF); + public: -//------------------------------------------------------------------------------ -// predefind event routines - virtual bool __stdcall FvectorRDOnAfterEdit(PropValue* sender, Fvector& edit_val); - virtual void __stdcall FvectorRDOnBeforeEdit(PropValue* sender,Fvector& edit_val); - virtual void __stdcall FvectorRDOnDraw (PropValue* sender, xr_string& draw_val); - virtual bool __stdcall floatRDOnAfterEdit (PropValue* sender, float& edit_val); - virtual void __stdcall floatRDOnBeforeEdit (PropValue* sender, float& edit_val); - virtual void __stdcall floatRDOnDraw (PropValue* sender, xr_string& draw_val); -// R-name edit - virtual void __stdcall NameBeforeEdit (PropValue* sender, shared_str& edit_val); - virtual bool __stdcall NameAfterEdit (PropValue* sender, shared_str& edit_val); - virtual void __stdcall NameDraw (PropValue* sender, xr_string& draw_val); -// C-name edit - virtual void __stdcall CNameBeforeEdit (PropValue* sender, xr_string& edit_val); - virtual bool __stdcall CNameAfterEdit (PropValue* sender, xr_string& edit_val); - virtual void __stdcall CNameDraw (PropValue* sender, xr_string& draw_val); + //------------------------------------------------------------------------------ + // predefind event routines + virtual bool __stdcall FvectorRDOnAfterEdit(PropValue* sender, Fvector& edit_val); + virtual void __stdcall FvectorRDOnBeforeEdit(PropValue* sender, Fvector& edit_val); + virtual void __stdcall FvectorRDOnDraw(PropValue* sender, xr_string& draw_val); + virtual bool __stdcall floatRDOnAfterEdit(PropValue* sender, float& edit_val); + virtual void __stdcall floatRDOnBeforeEdit(PropValue* sender, float& edit_val); + virtual void __stdcall floatRDOnDraw(PropValue* sender, xr_string& draw_val); + // R-name edit + virtual void __stdcall NameBeforeEdit(PropValue* sender, shared_str& edit_val); + virtual bool __stdcall NameAfterEdit(PropValue* sender, shared_str& edit_val); + virtual void __stdcall NameDraw(PropValue* sender, xr_string& draw_val); + // C-name edit + virtual void __stdcall CNameBeforeEdit(PropValue* sender, xr_string& edit_val); + virtual bool __stdcall CNameAfterEdit(PropValue* sender, xr_string& edit_val); + virtual void __stdcall CNameDraw(PropValue* sender, xr_string& draw_val); + public: - virtual CaptionValue* __stdcall CreateCaption (PropItemVec& items, shared_str key, shared_str val); - virtual CanvasValue* __stdcall CreateCanvas (PropItemVec& items, shared_str key, shared_str val, int height); - virtual ButtonValue* __stdcall CreateButton (PropItemVec& items, shared_str key, shared_str val, u32 flags, ButtonValue::TOnBtnClick onclick=0); - virtual ChooseValue* __stdcall CreateChoose (PropItemVec& items, shared_str key, shared_str* val, u32 mode, LPCSTR path=0, void* fill_param=0, u32 sub_item_count=1, u32 choose_flags=cfAllowNone); - virtual S8Value* __stdcall CreateS8 (PropItemVec& items, shared_str key, s8* val, s8 mn=0, s8 mx=100, s8 inc=1); - virtual S16Value* __stdcall CreateS16 (PropItemVec& items, shared_str key, s16* val, s16 mn=0, s16 mx=100, s16 inc=1); - virtual S32Value* __stdcall CreateS32 (PropItemVec& items, shared_str key, s32* val, s32 mn=0, s32 mx=100, s32 inc=1); - virtual U8Value* __stdcall CreateU8 (PropItemVec& items, shared_str key, u8* val, u8 mn=0, u8 mx=100, u8 inc=1); - virtual U16Value* __stdcall CreateU16 (PropItemVec& items, shared_str key, u16* val, u16 mn=0, u16 mx=100, u16 inc=1); - virtual U32Value* __stdcall CreateU32 (PropItemVec& items, shared_str key, u32* val, u32 mn=0, u32 mx=100, u32 inc=1); - virtual FloatValue* __stdcall CreateFloat (PropItemVec& items, shared_str key, float* val, float mn=0.f, float mx=1.f, float inc=0.01f, int decim=2); - virtual BOOLValue* __stdcall CreateBOOL (PropItemVec& items, shared_str key, BOOL* val); - virtual VectorValue* __stdcall CreateVector (PropItemVec& items, shared_str key, Fvector* val, float mn=0.f, float mx=1.f, float inc=0.01f, int decim=2); - virtual Flag8Value* __stdcall CreateFlag8 (PropItemVec& items, shared_str key, Flags8* val, u8 mask, LPCSTR c0=0, LPCSTR c1=0, u32 flags=0); - virtual Flag16Value* __stdcall CreateFlag16 (PropItemVec& items, shared_str key, Flags16* val, u16 mask, LPCSTR c0=0, LPCSTR c1=0, u32 flags=0); - virtual Flag32Value* __stdcall CreateFlag32 (PropItemVec& items, shared_str key, Flags32* val, u32 mask, LPCSTR c0=0, LPCSTR c1=0, u32 flags=0); - virtual Token8Value* __stdcall CreateToken8 (PropItemVec& items, shared_str key, u8* val, xr_token* token); - virtual Token16Value* __stdcall CreateToken16 (PropItemVec& items, shared_str key, u16* val, xr_token* token); - virtual Token32Value* __stdcall CreateToken32 (PropItemVec& items, shared_str key, u32* val, xr_token* token); - virtual RToken8Value* __stdcall CreateRToken8 (PropItemVec& items, shared_str key, u8* val, xr_rtoken* token, u32 t_cnt); - virtual RToken16Value* __stdcall CreateRToken16 (PropItemVec& items, shared_str key, u16* val, xr_rtoken* token, u32 t_cnt); - virtual RToken32Value* __stdcall CreateRToken32 (PropItemVec& items, shared_str key, u32* val, xr_rtoken* token, u32 t_cnt); - virtual RListValue* __stdcall CreateRList (PropItemVec& items, shared_str key, shared_str* val, shared_str* lst, u32 cnt); - virtual U32Value* __stdcall CreateColor (PropItemVec& items, shared_str key, u32* val); - virtual ColorValue* __stdcall CreateFColor (PropItemVec& items, shared_str key, Fcolor* val); - virtual VectorValue* __stdcall CreateVColor (PropItemVec& items, shared_str key, Fvector* val); - virtual RTextValue* __stdcall CreateRText (PropItemVec& items, shared_str key, shared_str* val); - virtual STextValue* __stdcall CreateSText (PropItemVec& items, shared_str key, xr_string* val); - virtual WaveValue* __stdcall CreateWave (PropItemVec& items, shared_str key, WaveForm* val); - virtual FloatValue* __stdcall CreateTime (PropItemVec& items, shared_str key, float* val, float mn=0.f, float mx=86400.f); - virtual ShortcutValue* __stdcall CreateShortcut (PropItemVec& items, shared_str key, xr_shortcut* val); + virtual CaptionValue* __stdcall CreateCaption(PropItemVec& items, shared_str key, shared_str val); + virtual CanvasValue* __stdcall CreateCanvas(PropItemVec& items, shared_str key, shared_str val, int height); + virtual ButtonValue* __stdcall CreateButton( + PropItemVec& items, shared_str key, shared_str val, u32 flags, ButtonValue::TOnBtnClick onclick = 0); + virtual ChooseValue* __stdcall CreateChoose(PropItemVec& items, shared_str key, shared_str* val, u32 mode, + LPCSTR path = 0, void* fill_param = 0, u32 sub_item_count = 1, u32 choose_flags = cfAllowNone); + virtual S8Value* __stdcall CreateS8( + PropItemVec& items, shared_str key, s8* val, s8 mn = 0, s8 mx = 100, s8 inc = 1); + virtual S16Value* __stdcall CreateS16( + PropItemVec& items, shared_str key, s16* val, s16 mn = 0, s16 mx = 100, s16 inc = 1); + virtual S32Value* __stdcall CreateS32( + PropItemVec& items, shared_str key, s32* val, s32 mn = 0, s32 mx = 100, s32 inc = 1); + virtual U8Value* __stdcall CreateU8( + PropItemVec& items, shared_str key, u8* val, u8 mn = 0, u8 mx = 100, u8 inc = 1); + virtual U16Value* __stdcall CreateU16( + PropItemVec& items, shared_str key, u16* val, u16 mn = 0, u16 mx = 100, u16 inc = 1); + virtual U32Value* __stdcall CreateU32( + PropItemVec& items, shared_str key, u32* val, u32 mn = 0, u32 mx = 100, u32 inc = 1); + virtual FloatValue* __stdcall CreateFloat(PropItemVec& items, shared_str key, float* val, float mn = 0.f, + float mx = 1.f, float inc = 0.01f, int decim = 2); + virtual BOOLValue* __stdcall CreateBOOL(PropItemVec& items, shared_str key, BOOL* val); + virtual VectorValue* __stdcall CreateVector(PropItemVec& items, shared_str key, Fvector* val, float mn = 0.f, + float mx = 1.f, float inc = 0.01f, int decim = 2); + virtual Flag8Value* __stdcall CreateFlag8( + PropItemVec& items, shared_str key, Flags8* val, u8 mask, LPCSTR c0 = 0, LPCSTR c1 = 0, u32 flags = 0); + virtual Flag16Value* __stdcall CreateFlag16( + PropItemVec& items, shared_str key, Flags16* val, u16 mask, LPCSTR c0 = 0, LPCSTR c1 = 0, u32 flags = 0); + virtual Flag32Value* __stdcall CreateFlag32( + PropItemVec& items, shared_str key, Flags32* val, u32 mask, LPCSTR c0 = 0, LPCSTR c1 = 0, u32 flags = 0); + virtual Token8Value* __stdcall CreateToken8(PropItemVec& items, shared_str key, u8* val, xr_token* token); + virtual Token16Value* __stdcall CreateToken16(PropItemVec& items, shared_str key, u16* val, xr_token* token); + virtual Token32Value* __stdcall CreateToken32(PropItemVec& items, shared_str key, u32* val, xr_token* token); + virtual RToken8Value* __stdcall CreateRToken8( + PropItemVec& items, shared_str key, u8* val, xr_rtoken* token, u32 t_cnt); + virtual RToken16Value* __stdcall CreateRToken16( + PropItemVec& items, shared_str key, u16* val, xr_rtoken* token, u32 t_cnt); + virtual RToken32Value* __stdcall CreateRToken32( + PropItemVec& items, shared_str key, u32* val, xr_rtoken* token, u32 t_cnt); + virtual RListValue* __stdcall CreateRList( + PropItemVec& items, shared_str key, shared_str* val, shared_str* lst, u32 cnt); + virtual U32Value* __stdcall CreateColor(PropItemVec& items, shared_str key, u32* val); + virtual ColorValue* __stdcall CreateFColor(PropItemVec& items, shared_str key, Fcolor* val); + virtual VectorValue* __stdcall CreateVColor(PropItemVec& items, shared_str key, Fvector* val); + virtual RTextValue* __stdcall CreateRText(PropItemVec& items, shared_str key, shared_str* val); + virtual STextValue* __stdcall CreateSText(PropItemVec& items, shared_str key, xr_string* val); + virtual WaveValue* __stdcall CreateWave(PropItemVec& items, shared_str key, WaveForm* val); + virtual FloatValue* __stdcall CreateTime( + PropItemVec& items, shared_str key, float* val, float mn = 0.f, float mx = 86400.f); + virtual ShortcutValue* __stdcall CreateShortcut(PropItemVec& items, shared_str key, xr_shortcut* val); - virtual FloatValue* __stdcall CreateAngle (PropItemVec& items, shared_str key, float* val, float mn=flt_min, float mx=flt_max, float inc=0.01f, int decim=2); - virtual VectorValue* __stdcall CreateAngle3 (PropItemVec& items, shared_str key, Fvector* val, float mn=flt_min, float mx=flt_max, float inc=0.01f, int decim=2); - virtual RTextValue* __stdcall CreateName (PropItemVec& items, shared_str key, shared_str* val, ListItem* owner); - virtual RTextValue* __stdcall CreateNameCB (PropItemVec& items, shared_str key, shared_str* val, TOnDrawTextEvent=0, RTextValue::TOnBeforeEditEvent=0, RTextValue::TOnAfterEditEvent=0); + virtual FloatValue* __stdcall CreateAngle(PropItemVec& items, shared_str key, float* val, float mn = flt_min, + float mx = flt_max, float inc = 0.01f, int decim = 2); + virtual VectorValue* __stdcall CreateAngle3(PropItemVec& items, shared_str key, Fvector* val, float mn = flt_min, + float mx = flt_max, float inc = 0.01f, int decim = 2); + virtual RTextValue* __stdcall CreateName(PropItemVec& items, shared_str key, shared_str* val, ListItem* owner); + virtual RTextValue* __stdcall CreateNameCB(PropItemVec& items, shared_str key, shared_str* val, + TOnDrawTextEvent = 0, RTextValue::TOnBeforeEditEvent = 0, RTextValue::TOnAfterEditEvent = 0); - virtual GameTypeValue* __stdcall CreateGameType (PropItemVec& items, shared_str key, GameTypeChooser* val); + virtual GameTypeValue* __stdcall CreateGameType(PropItemVec& items, shared_str key, GameTypeChooser* val); - // obsolette - virtual CTextValue* __stdcall CreateCText (PropItemVec& items, shared_str key, LPSTR val, u32 sz); - virtual CListValue* __stdcall CreateCList (PropItemVec& items, shared_str key, LPSTR val, u32 sz, xr_string* lst, u32 cnt); - virtual CTextValue* __stdcall CreateCName (PropItemVec& items, shared_str key, LPSTR val, u32 sz, ListItem* owner); - virtual TokenValueSH* __stdcall CreateTokenSH (PropItemVec& items, shared_str key, u32* val, const TokenValueSH::Item* lst, u32 cnt); - virtual CTextValue* __stdcall CreateTexture (PropItemVec& items, shared_str key, LPSTR val, u32 sz); + // obsolette + virtual CTextValue* __stdcall CreateCText(PropItemVec& items, shared_str key, LPSTR val, u32 sz); + virtual CListValue* __stdcall CreateCList( + PropItemVec& items, shared_str key, LPSTR val, u32 sz, xr_string* lst, u32 cnt); + virtual CTextValue* __stdcall CreateCName(PropItemVec& items, shared_str key, LPSTR val, u32 sz, ListItem* owner); + virtual TokenValueSH* __stdcall CreateTokenSH( + PropItemVec& items, shared_str key, u32* val, const TokenValueSH::Item* lst, u32 cnt); + virtual CTextValue* __stdcall CreateTexture(PropItemVec& items, shared_str key, LPSTR val, u32 sz); }; //--------------------------------------------------------------------------- #endif diff --git a/src/xrServerEntities/PropertiesListTypes.h b/src/xrServerEntities/PropertiesListTypes.h index cb2bf864a47..96917659213 100644 --- a/src/xrServerEntities/PropertiesListTypes.h +++ b/src/xrServerEntities/PropertiesListTypes.h @@ -2,196 +2,212 @@ #ifndef PropertiesListTypesH #define PropertiesListTypesH - #include "WaveForm.H" #include "gametype_chooser.h" -#ifdef __BORLANDC__ -# include "ElTree.hpp" +#ifdef __BORLANDC__ +#include "ElTree.hpp" #endif -#pragma pack( push,1 ) +#pragma pack(push, 1) //--------------------------------------------------------------------------- -enum EPropType{ - PROP_UNDEF = -1, - PROP_CAPTION = 0x1000, - PROP_SHORTCUT, - PROP_BUTTON, +enum EPropType +{ + PROP_UNDEF = -1, + PROP_CAPTION = 0x1000, + PROP_SHORTCUT, + PROP_BUTTON, PROP_CHOOSE, - PROP_NUMERIC, // {u8,u16,u32,s8,s16,s32,f32} - PROP_BOOLEAN, - PROP_FLAG, - PROP_VECTOR, - PROP_TOKEN, - PROP_RTOKEN, - PROP_RLIST, - PROP_COLOR, - PROP_FCOLOR, - PROP_VCOLOR, - PROP_RTEXT, + PROP_NUMERIC, // {u8,u16,u32,s8,s16,s32,f32} + PROP_BOOLEAN, + PROP_FLAG, + PROP_VECTOR, + PROP_TOKEN, + PROP_RTOKEN, + PROP_RLIST, + PROP_COLOR, + PROP_FCOLOR, + PROP_VCOLOR, + PROP_RTEXT, PROP_STEXT, - PROP_WAVE, + PROP_WAVE, PROP_CANVAS, PROP_TIME, - PROP_CTEXT, - PROP_CLIST, + PROP_CTEXT, + PROP_CLIST, PROP_SH_TOKEN, - PROP_TEXTURE2, + PROP_TEXTURE2, PROP_GAMETYPE, }; // refs -struct xr_token; +struct xr_token; class PropValue; class PropItem; -DEFINE_VECTOR (PropItem*,PropItemVec,PropItemIt); +DEFINE_VECTOR(PropItem*, PropItemVec, PropItemIt); //------------------------------------------------------------------------------ -#include "xrCore/ChooseTypes.H" +#include "xrCore/ChooseTypes.H" //------------------------------------------------------------------------------ -typedef fastdelegate::FastDelegate2 TOnDrawTextEvent; -typedef fastdelegate::FastDelegate1 TOnClick; +typedef fastdelegate::FastDelegate2 TOnDrawTextEvent; +typedef fastdelegate::FastDelegate1 TOnClick; //------------------------------------------------------------------------------ class PropValue { - friend class CPropHelper; - friend class PropItem; + friend class CPropHelper; + friend class PropItem; + protected: - PropItem* m_Owner; + PropItem* m_Owner; + public: - u32 tag; + u32 tag; + public: - // base events - typedef fastdelegate::FastDelegate1 TOnChange; - TOnChange OnChangeEvent; + // base events + typedef fastdelegate::FastDelegate1 TOnChange; + TOnChange OnChangeEvent; + public: - PropValue ():tag(0),m_Owner(0),OnChangeEvent(0){;} - virtual ~PropValue (){} - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText)=0; - virtual void ResetValue ()=0; - virtual bool Equal (PropValue* prop)=0; - IC PropItem* Owner (){return m_Owner;} + PropValue() : tag(0), m_Owner(0), OnChangeEvent(0) { ; } + virtual ~PropValue() {} + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) = 0; + virtual void ResetValue() = 0; + virtual bool Equal(PropValue* prop) = 0; + IC PropItem* Owner() { return m_Owner; } }; //------------------------------------------------------------------------------ template IC void set_value(T& val, const T& _val) { - val = _val; + val = _val; }; template -class CustomValue: public PropValue +class CustomValue : public PropValue { public: - typedef T TYPE; + typedef T TYPE; + public: - TYPE init_value; - TYPE* value; + TYPE init_value; + TYPE* value; + public: - typedef fastdelegate::FastDelegate2 TOnBeforeEditEvent; - typedef fastdelegate::FastDelegate2 TOnAfterEditEvent; - TOnBeforeEditEvent OnBeforeEditEvent; - TOnAfterEditEvent OnAfterEditEvent; + typedef fastdelegate::FastDelegate2 TOnBeforeEditEvent; + typedef fastdelegate::FastDelegate2 TOnAfterEditEvent; + TOnBeforeEditEvent OnBeforeEditEvent; + TOnAfterEditEvent OnAfterEditEvent; + public: - CustomValue (T* val) - { - OnBeforeEditEvent = 0; - OnAfterEditEvent = 0; - set_value (value,val); - set_value (init_value,*val); + CustomValue(T* val) + { + OnBeforeEditEvent = 0; + OnAfterEditEvent = 0; + set_value(value, val); + set_value(init_value, *val); }; - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText){return "";} - virtual bool Equal (PropValue* val) + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) { return ""; } + virtual bool Equal(PropValue* val) { - CustomValue* prop = (CustomValue*)val; - return (*value==*prop->value); + CustomValue* prop = (CustomValue*)val; + return (*value == *prop->value); } - virtual const T& GetValue (){return *value; } - virtual void ResetValue (){set_value(*value,init_value);} - bool ApplyValue (const T& val) + virtual const T& GetValue() { return *value; } + virtual void ResetValue() { set_value(*value, init_value); } + bool ApplyValue(const T& val) { - if (!(*value==val)){ - set_value (*value,val); - return true; + if (!(*value == val)) { + set_value(*value, val); + return true; } - return false; + return false; } }; class PropItem { - friend class CPropHelper; - friend class TProperties; - shared_str key; - EPropType type; - void* item; + friend class CPropHelper; + friend class TProperties; + shared_str key; + EPropType type; + void* item; + public: - DEFINE_VECTOR (PropValue*,PropValueVec,PropValueIt); + DEFINE_VECTOR(PropValue*, PropValueVec, PropValueIt); + private: - PropValueVec values; - TProperties* m_Owner; -// events -public: - typedef fastdelegate::FastDelegate1 TOnPropItemFocused; - TOnDrawTextEvent OnDrawTextEvent; - TOnPropItemFocused OnItemFocused; - TOnClick OnClickEvent; -public: - u32 prop_color; - u32 val_color; - Irect draw_rect; -public: - enum{ - flDisabled = (1<<0), - flShowCB = (1<<1), - flCBChecked = (1<<2), - flMixed = (1<<3), - flDrawThumbnail = (1<<4), - flSorted = (1<<5), - }; - Flags32 m_Flags; + PropValueVec values; + TProperties* m_Owner; + // events +public: + typedef fastdelegate::FastDelegate1 TOnPropItemFocused; + TOnDrawTextEvent OnDrawTextEvent; + TOnPropItemFocused OnItemFocused; + TOnClick OnClickEvent; + +public: + u32 prop_color; + u32 val_color; + Irect draw_rect; + public: - PropItem (EPropType _type):type(_type),prop_color(0),val_color(0),item(0),key(0),OnClickEvent(0),OnDrawTextEvent(0),OnItemFocused(0){m_Flags.zero();} - virtual ~PropItem () + enum { - for (PropValueIt it=values.begin(); values.end() != it; ++it) - xr_delete (*it); + flDisabled = (1 << 0), + flShowCB = (1 << 1), + flCBChecked = (1 << 2), + flMixed = (1 << 3), + flDrawThumbnail = (1 << 4), + flSorted = (1 << 5), }; - IC TProperties* Owner (){return m_Owner;} - void SetName (const shared_str& name) + Flags32 m_Flags; + +public: + PropItem(EPropType _type) + : type(_type), prop_color(0), val_color(0), item(0), key(0), OnClickEvent(0), OnDrawTextEvent(0), + OnItemFocused(0) { - key=name; + m_Flags.zero(); } - IC void ResetValues () + virtual ~PropItem() + { + for (PropValueIt it = values.begin(); values.end() != it; ++it) + xr_delete(*it); + }; + IC TProperties* Owner() { return m_Owner; } + void SetName(const shared_str& name) { key = name; } + IC void ResetValues() { - for (PropValueIt it=values.begin(); values.end() != it; ++it) - (*it)->ResetValue(); - CheckMixed (); + for (PropValueIt it = values.begin(); values.end() != it; ++it) + (*it)->ResetValue(); + CheckMixed(); } - IC void AppendValue (PropValue* value) + IC void AppendValue(PropValue* value) { - if (!values.empty()&&!value->Equal(values.front())) - m_Flags.set (flMixed,TRUE); - values.push_back(value); + if (!values.empty() && !value->Equal(values.front())) m_Flags.set(flMixed, TRUE); + values.push_back(value); } - IC xr_string GetDrawText () + IC xr_string GetDrawText() { - VERIFY(!values.empty()); - return m_Flags.is(flMixed)?xr_string("(mixed)"):values.front()->GetDrawText(OnDrawTextEvent); + VERIFY(!values.empty()); + return m_Flags.is(flMixed) ? xr_string("(mixed)") : values.front()->GetDrawText(OnDrawTextEvent); } - IC void CheckMixed () + IC void CheckMixed() { - m_Flags.set (flMixed,FALSE); - if (values.size()>1){ - PropValueIt F = values.begin(); - PropValueIt it = F; ++it; - for (; values.end() != it; ++it){ - if (!(*it)->Equal(*F)){ - m_Flags.set(flMixed,TRUE); + m_Flags.set(flMixed, FALSE); + if (values.size() > 1) { + PropValueIt F = values.begin(); + PropValueIt it = F; + ++it; + for (; values.end() != it; ++it) + { + if (!(*it)->Equal(*F)) { + m_Flags.set(flMixed, TRUE); break; } } @@ -199,282 +215,346 @@ class PropItem } template - IC void BeforeEdit (T2& val) + IC void BeforeEdit(T2& val) { - T1* CV = smart_cast(values.front()); VERIFY(CV); - if (!CV->OnBeforeEditEvent.empty()) CV->OnBeforeEditEvent(CV,val); + T1* CV = smart_cast(values.front()); + VERIFY(CV); + if (!CV->OnBeforeEditEvent.empty()) CV->OnBeforeEditEvent(CV, val); } template - IC bool AfterEdit (T2& val) + IC bool AfterEdit(T2& val) { - T1* CV = smart_cast(values.front()); VERIFY(CV); - if (!CV->OnAfterEditEvent.empty()) return CV->OnAfterEditEvent(CV,val); + T1* CV = smart_cast(values.front()); + VERIFY(CV); + if (!CV->OnAfterEditEvent.empty()) return CV->OnAfterEditEvent(CV, val); return true; - } + } template - IC bool ApplyValue (const T2& val) - { - bool bChanged = false; - m_Flags.set (flMixed,FALSE); - for (PropValueIt it=values.begin(); values.end() != it; ++it){ - T1* CV = smart_cast(*it); VERIFY(CV); - if (CV->ApplyValue(val)){ - bChanged = true; + IC bool ApplyValue(const T2& val) + { + bool bChanged = false; + m_Flags.set(flMixed, FALSE); + for (PropValueIt it = values.begin(); values.end() != it; ++it) + { + T1* CV = smart_cast(*it); + VERIFY(CV); + if (CV->ApplyValue(val)) { + bChanged = true; if (!CV->OnChangeEvent.empty()) CV->OnChangeEvent(*it); } - if (!CV->Equal(values.front())) - m_Flags.set (flMixed,TRUE); + if (!CV->Equal(values.front())) m_Flags.set(flMixed, TRUE); } return bChanged; } - IC PropValueVec& Values (){return values;} - IC PropValue* GetFrontValue (){VERIFY(!values.empty()); return values.front(); }; - IC EPropType Type (){return type;} -#ifdef __BORLANDC__ - IC TElTreeItem* Item (){return (TElTreeItem*)item;} + IC PropValueVec& Values() { return values; } + IC PropValue* GetFrontValue() + { + VERIFY(!values.empty()); + return values.front(); + }; + IC EPropType Type() { return type; } +#ifdef __BORLANDC__ + IC TElTreeItem* Item() { return (TElTreeItem*)item; } #endif - IC LPCSTR Key (){return key.c_str();} - IC void Enable (BOOL val){m_Flags.set(flDisabled,!val);} - IC BOOL Enabled (){return !m_Flags.is(flDisabled);} - IC void OnChange () + IC LPCSTR Key() { return key.c_str(); } + IC void Enable(BOOL val) { m_Flags.set(flDisabled, !val); } + IC BOOL Enabled() { return !m_Flags.is(flDisabled); } + IC void OnChange() { - for (PropValueIt it=values.begin(); values.end() != it; ++it) - if (!(*it)->OnChangeEvent.empty()) - (*it)->OnChangeEvent(*it); + for (PropValueIt it = values.begin(); values.end() != it; ++it) + if (!(*it)->OnChangeEvent.empty()) (*it)->OnChangeEvent(*it); } -/* - template - IC void OnBeforeEdit () - { - for (PropValueIt it=values.begin(); values.end() != it; ++it){ - T1* CV = smart_cast(*it); VERIFY(CV); - if (CV->OnChangeEvent) CV->OnChangeEvent(*it); + /* + template + IC void OnBeforeEdit () + { + for (PropValueIt it=values.begin(); values.end() != it; ++it){ + T1* CV = smart_cast(*it); VERIFY(CV); + if (CV->OnChangeEvent) CV->OnChangeEvent(*it); + } } - } -*/ + */ }; //------------------------------------------------------------------------------ // values //------------------------------------------------------------------------------ -class CaptionValue: public PropValue{ - shared_str value; -public: - CaptionValue (const shared_str& val){value=val;} - virtual xr_string GetDrawText (TOnDrawTextEvent) {return value.c_str()?value.c_str():"";} - virtual void ResetValue (){;} - virtual bool Equal (PropValue* val) {return (value==((CaptionValue*)val)->value);} - bool ApplyValue (const shared_str& val){value=val; return false;} +class CaptionValue : public PropValue +{ + shared_str value; + +public: + CaptionValue(const shared_str& val) { value = val; } + virtual xr_string GetDrawText(TOnDrawTextEvent) { return value.c_str() ? value.c_str() : ""; } + virtual void ResetValue() { ; } + virtual bool Equal(PropValue* val) { return (value == ((CaptionValue*)val)->value); } + bool ApplyValue(const shared_str& val) + { + value = val; + return false; + } }; -class CanvasValue: public PropValue{ - shared_str value; +class CanvasValue : public PropValue +{ + shared_str value; + public: - typedef fastdelegate::FastDelegate3 TOnTestEqual; - typedef fastdelegate::FastDelegate3 TOnDrawCanvasEvent; + typedef fastdelegate::FastDelegate3 TOnTestEqual; + typedef fastdelegate::FastDelegate3 TOnDrawCanvasEvent; + public: - int height; - TOnTestEqual OnTestEqual; - TOnDrawCanvasEvent OnDrawCanvasEvent; + int height; + TOnTestEqual OnTestEqual; + TOnDrawCanvasEvent OnDrawCanvasEvent; + public: - CanvasValue (const shared_str& val, int h):OnDrawCanvasEvent(0),OnTestEqual(0),height(h){value=val;} - virtual xr_string GetDrawText (TOnDrawTextEvent){return value.c_str()?value.c_str():"";} - virtual void ResetValue (){;} - virtual bool Equal (PropValue* val) + CanvasValue(const shared_str& val, int h) : OnDrawCanvasEvent(0), OnTestEqual(0), height(h) { value = val; } + virtual xr_string GetDrawText(TOnDrawTextEvent) { return value.c_str() ? value.c_str() : ""; } + virtual void ResetValue() { ; } + virtual bool Equal(PropValue* val) { - if (!OnTestEqual.empty()){bool res=true; OnTestEqual(this,(CanvasValue*)val,res); return res;} - return false; + if (!OnTestEqual.empty()) { + bool res = true; + OnTestEqual(this, (CanvasValue*)val, res); + return res; + } + return false; } }; -class ButtonValue: public PropValue{ +class ButtonValue : public PropValue +{ public: - RStringVec value; - int btn_num; - typedef fastdelegate::FastDelegate3 TOnBtnClick; - TOnBtnClick OnBtnClickEvent; - enum{ - flFirstOnly = (1<<0) + RStringVec value; + int btn_num; + typedef fastdelegate::FastDelegate3 TOnBtnClick; + TOnBtnClick OnBtnClickEvent; + enum + { + flFirstOnly = (1 << 0) }; - Flags32 m_Flags; -public: - ButtonValue (const shared_str& val, u32 flags) - { - m_Flags.assign (flags); - OnBtnClickEvent = 0; - btn_num = -1; - xr_string v; - int cnt =_GetItemCount(val.c_str()); - for (int k=0; k{ +IC bool operator==(const xr_shortcut& A, const xr_shortcut& B) +{ + return !!A.similar(B); +} +class ShortcutValue : public CustomValue +{ public: - typedef fastdelegate::FastDelegate3 TOnValidateResult; - TOnValidateResult OnValidateResultEvent; + typedef fastdelegate::FastDelegate3 TOnValidateResult; + TOnValidateResult OnValidateResultEvent; + public: - ShortcutValue (TYPE* val):CustomValue(val){} - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText); - bool ApplyValue (const xr_shortcut& val) + ShortcutValue(TYPE* val) : CustomValue(val) {} + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText); + bool ApplyValue(const xr_shortcut& val) { - if (!(*value==val)){ - bool allow = true; - if (!OnValidateResultEvent.empty()) - OnValidateResultEvent(this,val,allow); - if (allow){ - set_value (*value,val); - return true; + if (!(*value == val)) { + bool allow = true; + if (!OnValidateResultEvent.empty()) OnValidateResultEvent(this, val, allow); + if (allow) { + set_value(*value, val); + return true; } } - return false; + return false; } }; -class RTextValue: public CustomValue{ +class RTextValue : public CustomValue +{ public: - RTextValue (TYPE* val):CustomValue(val){}; - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText) + RTextValue(TYPE* val) : CustomValue(val){}; + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) { - xr_string txt = GetValue().c_str()?GetValue().c_str():""; - if (!OnDrawText.empty())OnDrawText(this, txt); + xr_string txt = GetValue().c_str() ? GetValue().c_str() : ""; + if (!OnDrawText.empty()) OnDrawText(this, txt); return txt; } }; -class STextValue: public CustomValue{ +class STextValue : public CustomValue +{ public: - STextValue (TYPE* val):CustomValue(val){}; - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText) + STextValue(TYPE* val) : CustomValue(val){}; + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) { - xr_string txt = GetValue(); - if (!OnDrawText.empty())OnDrawText(this, txt); + xr_string txt = GetValue(); + if (!OnDrawText.empty()) OnDrawText(this, txt); return txt; } }; -class CTextValue: public PropValue{ - xr_string init_value; +class CTextValue : public PropValue +{ + xr_string init_value; + public: - LPSTR value; + LPSTR value; + public: - typedef fastdelegate::FastDelegate2 TOnBeforeEditEvent; - typedef fastdelegate::FastDelegate2 TOnAfterEditEvent; - TOnBeforeEditEvent OnBeforeEditEvent; - TOnAfterEditEvent OnAfterEditEvent; + typedef fastdelegate::FastDelegate2 TOnBeforeEditEvent; + typedef fastdelegate::FastDelegate2 TOnAfterEditEvent; + TOnBeforeEditEvent OnBeforeEditEvent; + TOnAfterEditEvent OnAfterEditEvent; + public: - int lim; + int lim; + public: - CTextValue (LPSTR val, int _lim):value(val),init_value(val),lim(_lim) + CTextValue(LPSTR val, int _lim) : value(val), init_value(val), lim(_lim) { - OnBeforeEditEvent = 0; - OnAfterEditEvent = 0; + OnBeforeEditEvent = 0; + OnAfterEditEvent = 0; }; - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText) + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) { - xr_string txt = GetValue(); - if (!OnDrawText.empty())OnDrawText(this, txt); + xr_string txt = GetValue(); + if (!OnDrawText.empty()) OnDrawText(this, txt); return txt; } - virtual bool Equal (PropValue* val) - { - return (0==xr_strcmp(value,((CTextValue*)val)->value)); - } - bool ApplyValue (LPCSTR val) + virtual bool Equal(PropValue* val) { return (0 == xr_strcmp(value, ((CTextValue*)val)->value)); } + bool ApplyValue(LPCSTR val) { - if (0!=xr_strcmp(value,val)){ - xr_strcpy (value,xr_strlen(val)+1,val); - return true; + if (0 != xr_strcmp(value, val)) { + xr_strcpy(value, xr_strlen(val) + 1, val); + return true; } - return false; + return false; } - LPSTR GetValue (){return value;} - virtual void ResetValue (){xr_strcpy(value,init_value.size()+1,init_value.c_str());} + LPSTR GetValue() { return value; } + virtual void ResetValue() { xr_strcpy(value, init_value.size() + 1, init_value.c_str()); } }; //------------------------------------------------------------------------------ -class ChooseValue: public RTextValue{ -public: - int subitem; - u32 m_ChooseID; - u32 m_ChooseFlags; - shared_str m_StartPath; - ChooseItemVec* m_Items; - typedef fastdelegate::FastDelegate1 TOnChooseValueFill; - TOnChooseValueFill OnChooseFillEvent; - TOnDrawThumbnail OnDrawThumbnailEvent; - void* m_FillParam; -// utils - void AppendChooseItem (LPCSTR name, LPCSTR hint){VERIFY(m_Items); m_Items->push_back(SChooseItem(name,hint));} -public: - ChooseValue (shared_str* val, u32 cid, LPCSTR path, void* param, u32 sub_item_count, u32 choose_flags):RTextValue(val),m_ChooseID(cid),m_StartPath(path),subitem(sub_item_count),m_Items(0),m_FillParam(param),OnChooseFillEvent(0),OnDrawThumbnailEvent(0),m_ChooseFlags(choose_flags){} +class ChooseValue : public RTextValue +{ +public: + int subitem; + u32 m_ChooseID; + u32 m_ChooseFlags; + shared_str m_StartPath; + ChooseItemVec* m_Items; + typedef fastdelegate::FastDelegate1 TOnChooseValueFill; + TOnChooseValueFill OnChooseFillEvent; + TOnDrawThumbnail OnDrawThumbnailEvent; + void* m_FillParam; + // utils + void AppendChooseItem(LPCSTR name, LPCSTR hint) + { + VERIFY(m_Items); + m_Items->push_back(SChooseItem(name, hint)); + } + +public: + ChooseValue(shared_str* val, u32 cid, LPCSTR path, void* param, u32 sub_item_count, u32 choose_flags) + : RTextValue(val), m_ChooseID(cid), m_StartPath(path), subitem(sub_item_count), m_Items(0), m_FillParam(param), + OnChooseFillEvent(0), OnDrawThumbnailEvent(0), m_ChooseFlags(choose_flags) + { + } }; -typedef CustomValue BOOLValue; +typedef CustomValue BOOLValue; //------------------------------------------------------------------------------ -IC bool operator == (const WaveForm& A, const WaveForm& B){return !!A.Similar(B);} -class WaveValue: public CustomValue{ +IC bool operator==(const WaveForm& A, const WaveForm& B) +{ + return !!A.Similar(B); +} +class WaveValue : public CustomValue +{ public: - WaveValue (TYPE* val):CustomValue(val){}; - virtual xr_string GetDrawText (TOnDrawTextEvent){return "[Wave]";} + WaveValue(TYPE* val) : CustomValue(val){}; + virtual xr_string GetDrawText(TOnDrawTextEvent) { return "[Wave]"; } }; -IC bool operator == (const GameTypeChooser& A, const GameTypeChooser& B){return A.m_GameType.flags==B.m_GameType.flags;} -class GameTypeValue: public CustomValue{ +IC bool operator==(const GameTypeChooser& A, const GameTypeChooser& B) +{ + return A.m_GameType.flags == B.m_GameType.flags; +} +class GameTypeValue : public CustomValue +{ public: - GameTypeValue (TYPE* val):CustomValue(val){}; - virtual xr_string GetDrawText (TOnDrawTextEvent); + GameTypeValue(TYPE* val) : CustomValue(val){}; + virtual xr_string GetDrawText(TOnDrawTextEvent); }; //------------------------------------------------------------------------------ -IC bool operator == (const Fcolor& A, const Fcolor& B) -{ return !!A.similar_rgba(B); } -typedef CustomValue ColorValue; +IC bool operator==(const Fcolor& A, const Fcolor& B) +{ + return !!A.similar_rgba(B); +} +typedef CustomValue ColorValue; //------------------------------------------------------------------------------ template -class NumericValue: public CustomValue +class NumericValue : public CustomValue { public: - T lim_mn; - T lim_mx; - T inc; - int dec; + T lim_mn; + T lim_mx; + T inc; + int dec; + public: - NumericValue (T* val):CustomValue(val) - { - value = val; - init_value = *value; - dec = 0; + NumericValue(T* val) : CustomValue(val) + { + value = val; + init_value = *value; + dec = 0; }; - NumericValue (T* val, T mn, T mx, T increm, int decim):CustomValue(val),lim_mn(mn),lim_mx(mx),inc(increm),dec(decim) - { - clamp (*val,lim_mn,lim_mx); - value = val; - init_value = *value; + NumericValue(T* val, T mn, T mx, T increm, int decim) + : CustomValue(val), lim_mn(mn), lim_mx(mx), inc(increm), dec(decim) + { + clamp(*val, lim_mn, lim_mx); + value = val; + init_value = *value; }; - bool ApplyValue (const T& _val) + bool ApplyValue(const T& _val) { - T val = _val; - clamp (val,lim_mn,lim_mx); + T val = _val; + clamp(val, lim_mn, lim_mx); return CustomValue::ApplyValue(val); } - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText) - { - xr_string draw_val; - if (!OnDrawText.empty()) OnDrawText(this, draw_val); - else draw_sprintf (draw_val,*value,dec); + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) + { + xr_string draw_val; + if (!OnDrawText.empty()) + OnDrawText(this, draw_val); + else + draw_sprintf(draw_val, *value, dec); return draw_val; } }; @@ -482,47 +562,59 @@ class NumericValue: public CustomValue //------------------------------------------------------------------------------ template IC xr_string draw_sprintf(xr_string& s, const T& V, int tag) -{ string256 tmp; xr_sprintf(tmp,sizeof(tmp),"%d",V); s=tmp; return s;} +{ + string256 tmp; + xr_sprintf(tmp, sizeof(tmp), "%d", V); + s = tmp; + return s; +} //------------------------------------------------------------------------------ IC xr_string draw_sprintf(xr_string& s, const float& V, int dec) { - string32 fmt; xr_sprintf(fmt,sizeof(fmt),"%%.%df",dec); - string256 tmp; xr_sprintf(tmp,sizeof(tmp),fmt,V); - s = tmp; + string32 fmt; + xr_sprintf(fmt, sizeof(fmt), "%%.%df", dec); + string256 tmp; + xr_sprintf(tmp, sizeof(tmp), fmt, V); + s = tmp; return s; } //------------------------------------------------------------------------------ -IC bool operator == (const Fvector& A, const Fvector& B) -{ return !!A.similar(B); } +IC bool operator==(const Fvector& A, const Fvector& B) +{ + return !!A.similar(B); +} IC void clamp(Fvector& V, const Fvector& mn, const Fvector& mx) { - clamp(V.x,mn.x,mx.x); - clamp(V.y,mn.y,mx.y); - clamp(V.z,mn.z,mx.z); + clamp(V.x, mn.x, mx.x); + clamp(V.y, mn.y, mx.y); + clamp(V.z, mn.z, mx.z); } IC xr_string draw_sprintf(xr_string& s, const Fvector& V, int dec) { - string128 fmt; xr_sprintf(fmt,sizeof(fmt),"{%%.%df, %%.%df, %%.%df}",dec,dec,dec); - string256 tmp; xr_sprintf(tmp,sizeof(tmp),fmt,V.x,V.y,V.z); - s = tmp; + string128 fmt; + xr_sprintf(fmt, sizeof(fmt), "{%%.%df, %%.%df, %%.%df}", dec, dec, dec); + string256 tmp; + xr_sprintf(tmp, sizeof(tmp), fmt, V.x, V.y, V.z); + s = tmp; return s; } //------------------------------------------------------------------------------ -typedef NumericValue U8Value; -typedef NumericValue U16Value; -typedef NumericValue U32Value; -typedef NumericValue S8Value; -typedef NumericValue S16Value; -typedef NumericValue S32Value; -typedef NumericValue FloatValue; -class VectorValue: public NumericValue{ -public: - VectorValue (Fvector* val, float mn, float mx, float increment, int decimal):NumericValue(val) - { - lim_mn.set (mn,mn,mn); - lim_mx.set (mx,mx,mx); - inc.set (increment,increment,increment); - dec = decimal; +typedef NumericValue U8Value; +typedef NumericValue U16Value; +typedef NumericValue U32Value; +typedef NumericValue S8Value; +typedef NumericValue S16Value; +typedef NumericValue S32Value; +typedef NumericValue FloatValue; +class VectorValue : public NumericValue +{ +public: + VectorValue(Fvector* val, float mn, float mx, float increment, int decimal) : NumericValue(val) + { + lim_mn.set(mn, mn, mn); + lim_mx.set(mx, mx, mx); + inc.set(increment, increment, increment); + dec = decimal; }; }; //------------------------------------------------------------------------------ @@ -530,164 +622,188 @@ class VectorValue: public NumericValue{ class FlagValueCustom { public: - shared_str caption[2]; - enum{ - flInvertedDraw = (1<<0), + shared_str caption[2]; + enum + { + flInvertedDraw = (1 << 0), }; - Flags32 m_Flags; + Flags32 m_Flags; + public: - FlagValueCustom (u32 mask, LPCSTR c0, LPCSTR c1) + FlagValueCustom(u32 mask, LPCSTR c0, LPCSTR c1) { - caption[0] = c0; - caption[1] = c1; + caption[0] = c0; + caption[1] = c1; m_Flags.assign(mask); } - virtual bool HaveCaption (){return caption[0].size()&&caption[1].size();} - virtual bool GetValueEx ()=0; + virtual bool HaveCaption() { return caption[0].size() && caption[1].size(); } + virtual bool GetValueEx() = 0; }; template -class FlagValue: public CustomValue, public FlagValueCustom +class FlagValue : public CustomValue, public FlagValueCustom { public: - typedef T TYPE; - typedef typename T::TYPE FLAG_TYPE; + typedef T TYPE; + typedef typename T::TYPE FLAG_TYPE; + public: - FLAG_TYPE mask; + FLAG_TYPE mask; + public: - FlagValue (T* val, FLAG_TYPE _mask, LPCSTR c0, LPCSTR c1, u32 flags):CustomValue(val),FlagValueCustom(flags,c0,c1),mask(_mask){} - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText) - { - xr_string draw_val; - if (!OnDrawText.empty()) OnDrawText(this, draw_val); - else return HaveCaption()?caption[GetValueEx()?1:0].c_str():""; - return draw_val; + FlagValue(T* val, FLAG_TYPE _mask, LPCSTR c0, LPCSTR c1, u32 flags) + : CustomValue(val), FlagValueCustom(flags, c0, c1), mask(_mask) + { + } + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) + { + xr_string draw_val; + if (!OnDrawText.empty()) + OnDrawText(this, draw_val); + else + return HaveCaption() ? caption[GetValueEx() ? 1 : 0].c_str() : ""; + return draw_val; } - virtual bool Equal (PropValue* val){return !!value->equal(*((FlagValue*)val)->value,mask);} - virtual const T& GetValue () {return *value; } - virtual void ResetValue () {value->set(mask,init_value.is(mask));} - virtual bool GetValueEx () {return !!value->is(mask);} - bool ApplyValue (const T& val) + virtual bool Equal(PropValue* val) { return !!value->equal(*((FlagValue*)val)->value, mask); } + virtual const T& GetValue() { return *value; } + virtual void ResetValue() { value->set(mask, init_value.is(mask)); } + virtual bool GetValueEx() { return !!value->is(mask); } + bool ApplyValue(const T& val) { - if (!val.equal(*value,mask)){ - value->set (mask,val.is(mask)); - return true; + if (!val.equal(*value, mask)) { + value->set(mask, val.is(mask)); + return true; } - return false; + return false; } }; //------------------------------------------------------------------------------ -typedef FlagValue Flag8Value; -typedef FlagValue Flag16Value; -typedef FlagValue Flag32Value; +typedef FlagValue Flag8Value; +typedef FlagValue Flag16Value; +typedef FlagValue Flag32Value; //------------------------------------------------------------------------------ template -bool operator == (_flags const & A, _flags const & B){return A.flags==B.flags;} +bool operator==(_flags const& A, _flags const& B) +{ + return A.flags == B.flags; +} //------------------------------------------------------------------------------ -class TokenValueCustom{ -public: - xr_token* token; - TokenValueCustom(xr_token* _token):token(_token){;} +class TokenValueCustom +{ +public: + xr_token* token; + TokenValueCustom(xr_token* _token) : token(_token) { ; } }; template -class TokenValue: public CustomValue, public TokenValueCustom +class TokenValue : public CustomValue, public TokenValueCustom { public: - TokenValue (T* val, xr_token* _token):TokenValueCustom(_token),CustomValue(val){}; - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText) + TokenValue(T* val, xr_token* _token) : TokenValueCustom(_token), CustomValue(val){}; + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) { - xr_string draw_val; - if (!OnDrawText.empty()) OnDrawText(this, draw_val); - else for(int i=0; token[i].name; i++) if (token[i].id==(int)GetValue()) return token[i].name; + xr_string draw_val; + if (!OnDrawText.empty()) + OnDrawText(this, draw_val); + else + for (int i = 0; token[i].name; i++) + if (token[i].id == (int)GetValue()) return token[i].name; return draw_val; } }; //------------------------------------------------------------------------------ -typedef TokenValue Token8Value; -typedef TokenValue Token16Value; -typedef TokenValue Token32Value; +typedef TokenValue Token8Value; +typedef TokenValue Token16Value; +typedef TokenValue Token32Value; //------------------------------------------------------------------------------ -class RTokenValueCustom{ +class RTokenValueCustom +{ public: - xr_rtoken* token; - u32 token_count; - RTokenValueCustom(xr_rtoken* _token, u32 _t_cnt):token(_token),token_count(_t_cnt){;} + xr_rtoken* token; + u32 token_count; + RTokenValueCustom(xr_rtoken* _token, u32 _t_cnt) : token(_token), token_count(_t_cnt) { ; } }; template -class RTokenValue: public CustomValue, public RTokenValueCustom +class RTokenValue : public CustomValue, public RTokenValueCustom { public: - RTokenValue (T* val, xr_rtoken* _token, u32 _t_cnt):CustomValue(val),RTokenValueCustom(_token,_t_cnt){}; - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText) + RTokenValue(T* val, xr_rtoken* _token, u32 _t_cnt) : CustomValue(val), RTokenValueCustom(_token, _t_cnt){}; + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) { xr_string draw_val; - if (!OnDrawText.empty()) OnDrawText(this, draw_val); - else for(u32 k=0; k RToken8Value; -typedef RTokenValueRToken16Value; -typedef RTokenValueRToken32Value; +typedef RTokenValue RToken8Value; +typedef RTokenValue RToken16Value; +typedef RTokenValue RToken32Value; //------------------------------------------------------------------------------ -class TokenValueSH: public CustomValue{ +class TokenValueSH : public CustomValue +{ public: - struct Item { - u32 ID; - string64 str; - }; - u32 cnt; - const Item* items; + struct Item + { + u32 ID; + string64 str; + }; + u32 cnt; + const Item* items; + public: - TokenValueSH (u32* val, const Item* _items, u32 _cnt):CustomValue(val),cnt(_cnt),items(_items){}; - virtual xr_string GetDrawText (TOnDrawTextEvent OnDrawText) + TokenValueSH(u32* val, const Item* _items, u32 _cnt) : CustomValue(val), cnt(_cnt), items(_items){}; + virtual xr_string GetDrawText(TOnDrawTextEvent OnDrawText) { - u32 draw_val = GetValue(); - for(u32 i=0; iitems){ - m_Owner->m_Flags.set(PropItem::flDisabled,TRUE); - return false; +class RListValue : public RTextValue +{ +public: + shared_str* items; + u32 item_count; + +public: + RListValue(shared_str* val, shared_str* _items, u32 cnt) : RTextValue(val), items(_items), item_count(cnt){}; + virtual bool Equal(PropValue* val) + { + if (items != ((RListValue*)val)->items) { + m_Owner->m_Flags.set(PropItem::flDisabled, TRUE); + return false; } return RTextValue::Equal(val); } }; -class CListValue: public CTextValue{ -public: - xr_string* items; - u32 item_count; -public: - CListValue (LPSTR val, u32 sz, xr_string* _items, u32 cnt):CTextValue(val,sz),items(_items),item_count(cnt){}; - virtual bool Equal (PropValue* val) - { - if (items!=((CListValue*)val)->items){ - m_Owner->m_Flags.set(PropItem::flDisabled,TRUE); - return false; +class CListValue : public CTextValue +{ +public: + xr_string* items; + u32 item_count; + +public: + CListValue(LPSTR val, u32 sz, xr_string* _items, u32 cnt) : CTextValue(val, sz), items(_items), item_count(cnt){}; + virtual bool Equal(PropValue* val) + { + if (items != ((CListValue*)val)->items) { + m_Owner->m_Flags.set(PropItem::flDisabled, TRUE); + return false; } return CTextValue::Equal(val); } }; //------------------------------------------------------------------------------ -#pragma pack( pop ) +#pragma pack(pop) #endif - - - - diff --git a/src/xrServerEntities/ShapeData.h b/src/xrServerEntities/ShapeData.h index fccd26da0fc..7557dbd4fe5 100644 --- a/src/xrServerEntities/ShapeData.h +++ b/src/xrServerEntities/ShapeData.h @@ -3,22 +3,23 @@ struct CShapeData { - enum{ - cfSphere=0, + enum + { + cfSphere = 0, cfBox }; - union shape_data - { - Fsphere sphere; - Fmatrix box; - }; - struct shape_def - { - u8 type; - shape_data data; - }; - DEFINE_VECTOR (shape_def,ShapeVec,ShapeIt); - ShapeVec shapes; + union shape_data + { + Fsphere sphere; + Fmatrix box; + }; + struct shape_def + { + u8 type; + shape_data data; + }; + DEFINE_VECTOR(shape_def, ShapeVec, ShapeIt); + ShapeVec shapes; }; #endif \ No newline at end of file diff --git a/src/xrServerEntities/WaveForm.h b/src/xrServerEntities/WaveForm.h index 1ec8e105ef8..bb44aa823dc 100644 --- a/src/xrServerEntities/WaveForm.h +++ b/src/xrServerEntities/WaveForm.h @@ -2,62 +2,64 @@ #define WAVEFORM_H #pragma once -#pragma pack(push,4) +#pragma pack(push, 4) struct WaveForm { - enum EFunction - { - fCONSTANT = 0, - fSIN, - fTRIANGLE, - fSQUARE, - fSAWTOOTH, - fINVSAWTOOTH, - fFORCE32 = u32(-1) - }; - IC float signf (float t) { return t/_abs(t); } - IC float Func (float t) - { - switch (F) - { - case fCONSTANT: return 0; - case fSIN: return _sin(t*PI_MUL_2); - case fTRIANGLE: return asinf(_sin((t-0.25f)*PI_MUL_2))/PI_DIV_2; - case fSQUARE: return signf(_cos(t*PI)); - case fSAWTOOTH: return atanf(tanf((t+0.5f)*PI))/PI_DIV_2; - case fINVSAWTOOTH: return -(atanf(tanf((t+0.5f)*PI))/PI_DIV_2); - } - return 0.f; - } + enum EFunction + { + fCONSTANT = 0, + fSIN, + fTRIANGLE, + fSQUARE, + fSAWTOOTH, + fINVSAWTOOTH, + fFORCE32 = u32(-1) + }; + IC float signf(float t) { return t / _abs(t); } + IC float Func(float t) + { + switch (F) + { + case fCONSTANT: return 0; + case fSIN: return _sin(t * PI_MUL_2); + case fTRIANGLE: return asinf(_sin((t - 0.25f) * PI_MUL_2)) / PI_DIV_2; + case fSQUARE: return signf(_cos(t * PI)); + case fSAWTOOTH: return atanf(tanf((t + 0.5f) * PI)) / PI_DIV_2; + case fINVSAWTOOTH: return -(atanf(tanf((t + 0.5f) * PI)) / PI_DIV_2); + } + return 0.f; + } + public: - EFunction F; - float arg[4]; + EFunction F; + float arg[4]; - IC float Calculate (float t) - { - // y = arg0 + arg1*func( (time+arg2)*arg3 ) - float x = (t+arg[2])*arg[3]; - return arg[0] + arg[1]*Func(x-floorf(x)); - } + IC float Calculate(float t) + { + // y = arg0 + arg1*func( (time+arg2)*arg3 ) + float x = (t + arg[2]) * arg[3]; + return arg[0] + arg[1] * Func(x - floorf(x)); + } - WaveForm() { - F = fCONSTANT; - arg[0] = 0; - arg[1] = 1; - arg[2] = 0; - arg[3] = 1; - } + WaveForm() + { + F = fCONSTANT; + arg[0] = 0; + arg[1] = 1; + arg[2] = 0; + arg[3] = 1; + } - IC BOOL Similar (const WaveForm& W) const - { - if (!fsimilar(arg[0],W.arg[0],EPS_L)) return FALSE; - if (!fsimilar(arg[1],W.arg[1],EPS_L)) return FALSE; - if (fis_zero(arg[1],EPS_L)) return TRUE; - if (F != W.F) return FALSE; - if (!fsimilar(arg[2],W.arg[2],EPS_L)) return FALSE; - if (!fsimilar(arg[3],W.arg[3],EPS_L)) return FALSE; - return TRUE; - } + IC BOOL Similar(const WaveForm& W) const + { + if (!fsimilar(arg[0], W.arg[0], EPS_L)) return FALSE; + if (!fsimilar(arg[1], W.arg[1], EPS_L)) return FALSE; + if (fis_zero(arg[1], EPS_L)) return TRUE; + if (F != W.F) return FALSE; + if (!fsimilar(arg[2], W.arg[2], EPS_L)) return FALSE; + if (!fsimilar(arg[3], W.arg[3], EPS_L)) return FALSE; + return TRUE; + } }; #pragma pack(pop) diff --git a/src/xrServerEntities/ai_sounds.h b/src/xrServerEntities/ai_sounds.h index 66ef42b72d5..42d8a82b28e 100644 --- a/src/xrServerEntities/ai_sounds.h +++ b/src/xrServerEntities/ai_sounds.h @@ -9,76 +9,77 @@ #ifndef ai_soundsH #define ai_soundsH -enum ESoundTypes { - SOUND_TYPE_NO_SOUND = 0x00000000ui32, - - SOUND_TYPE_WEAPON = 0x80000000ui32, - SOUND_TYPE_ITEM = 0x40000000ui32, - SOUND_TYPE_MONSTER = 0x20000000ui32, - SOUND_TYPE_ANOMALY = 0x10000000ui32, - SOUND_TYPE_WORLD = 0x08000000ui32, - - SOUND_TYPE_PICKING_UP = 0x04000000ui32, - SOUND_TYPE_DROPPING = 0x02000000ui32, - SOUND_TYPE_HIDING = 0x01000000ui32, - SOUND_TYPE_TAKING = 0x00800000ui32, - SOUND_TYPE_USING = 0x00400000ui32, - - SOUND_TYPE_SHOOTING = 0x00200000ui32, - SOUND_TYPE_EMPTY_CLICKING = 0x00100000ui32, - SOUND_TYPE_BULLET_HIT = 0x00080000ui32, - SOUND_TYPE_RECHARGING = 0x00040000ui32, - - SOUND_TYPE_DYING = 0x00020000ui32, - SOUND_TYPE_INJURING = 0x00010000ui32, - SOUND_TYPE_STEP = 0x00008000ui32, - SOUND_TYPE_TALKING = 0x00004000ui32, - SOUND_TYPE_ATTACKING = 0x00002000ui32, - SOUND_TYPE_EATING = 0x00001000ui32, - - SOUND_TYPE_IDLE = 0x00000800ui32, - - SOUND_TYPE_OBJECT_BREAKING = 0x00000400ui32, - SOUND_TYPE_OBJECT_COLLIDING = 0x00000200ui32, - SOUND_TYPE_OBJECT_EXPLODING = 0x00000100ui32, - SOUND_TYPE_AMBIENT = 0x00000080ui32, - - SOUND_TYPE_ITEM_PICKING_UP = SOUND_TYPE_ITEM | SOUND_TYPE_PICKING_UP, - SOUND_TYPE_ITEM_DROPPING = SOUND_TYPE_ITEM | SOUND_TYPE_DROPPING, - SOUND_TYPE_ITEM_HIDING = SOUND_TYPE_ITEM | SOUND_TYPE_HIDING, - SOUND_TYPE_ITEM_TAKING = SOUND_TYPE_ITEM | SOUND_TYPE_TAKING, - SOUND_TYPE_ITEM_USING = SOUND_TYPE_ITEM | SOUND_TYPE_USING, - - SOUND_TYPE_WEAPON_SHOOTING = SOUND_TYPE_WEAPON | SOUND_TYPE_SHOOTING, - SOUND_TYPE_WEAPON_EMPTY_CLICKING = SOUND_TYPE_WEAPON | SOUND_TYPE_EMPTY_CLICKING, - SOUND_TYPE_WEAPON_BULLET_HIT = SOUND_TYPE_WEAPON | SOUND_TYPE_BULLET_HIT, - SOUND_TYPE_WEAPON_RECHARGING = SOUND_TYPE_WEAPON | SOUND_TYPE_RECHARGING, - - SOUND_TYPE_MONSTER_DYING = SOUND_TYPE_MONSTER | SOUND_TYPE_DYING, - SOUND_TYPE_MONSTER_INJURING = SOUND_TYPE_MONSTER | SOUND_TYPE_INJURING, - SOUND_TYPE_MONSTER_STEP = SOUND_TYPE_MONSTER | SOUND_TYPE_STEP, - SOUND_TYPE_MONSTER_TALKING = SOUND_TYPE_MONSTER | SOUND_TYPE_TALKING, - SOUND_TYPE_MONSTER_ATTACKING = SOUND_TYPE_MONSTER | SOUND_TYPE_ATTACKING, - SOUND_TYPE_MONSTER_EATING = SOUND_TYPE_MONSTER | SOUND_TYPE_EATING, - - SOUND_TYPE_ANOMALY_IDLE = SOUND_TYPE_ANOMALY | SOUND_TYPE_IDLE, - - SOUND_TYPE_WORLD_OBJECT_BREAKING = SOUND_TYPE_WORLD | SOUND_TYPE_OBJECT_BREAKING, - SOUND_TYPE_WORLD_OBJECT_COLLIDING = SOUND_TYPE_WORLD | SOUND_TYPE_OBJECT_COLLIDING, - SOUND_TYPE_WORLD_OBJECT_EXPLODING = SOUND_TYPE_WORLD | SOUND_TYPE_OBJECT_EXPLODING, - SOUND_TYPE_WORLD_AMBIENT = SOUND_TYPE_WORLD | SOUND_TYPE_AMBIENT, - - SOUND_TYPE_WEAPON_PISTOL = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_GUN = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_SUBMACHINEGUN = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_MACHINEGUN = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_SNIPERRIFLE = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_GRENADELAUNCHER = SOUND_TYPE_WEAPON, - SOUND_TYPE_WEAPON_ROCKETLAUNCHER = SOUND_TYPE_WEAPON, +enum ESoundTypes +{ + SOUND_TYPE_NO_SOUND = 0x00000000ui32, + + SOUND_TYPE_WEAPON = 0x80000000ui32, + SOUND_TYPE_ITEM = 0x40000000ui32, + SOUND_TYPE_MONSTER = 0x20000000ui32, + SOUND_TYPE_ANOMALY = 0x10000000ui32, + SOUND_TYPE_WORLD = 0x08000000ui32, + + SOUND_TYPE_PICKING_UP = 0x04000000ui32, + SOUND_TYPE_DROPPING = 0x02000000ui32, + SOUND_TYPE_HIDING = 0x01000000ui32, + SOUND_TYPE_TAKING = 0x00800000ui32, + SOUND_TYPE_USING = 0x00400000ui32, + + SOUND_TYPE_SHOOTING = 0x00200000ui32, + SOUND_TYPE_EMPTY_CLICKING = 0x00100000ui32, + SOUND_TYPE_BULLET_HIT = 0x00080000ui32, + SOUND_TYPE_RECHARGING = 0x00040000ui32, + + SOUND_TYPE_DYING = 0x00020000ui32, + SOUND_TYPE_INJURING = 0x00010000ui32, + SOUND_TYPE_STEP = 0x00008000ui32, + SOUND_TYPE_TALKING = 0x00004000ui32, + SOUND_TYPE_ATTACKING = 0x00002000ui32, + SOUND_TYPE_EATING = 0x00001000ui32, + + SOUND_TYPE_IDLE = 0x00000800ui32, + + SOUND_TYPE_OBJECT_BREAKING = 0x00000400ui32, + SOUND_TYPE_OBJECT_COLLIDING = 0x00000200ui32, + SOUND_TYPE_OBJECT_EXPLODING = 0x00000100ui32, + SOUND_TYPE_AMBIENT = 0x00000080ui32, + + SOUND_TYPE_ITEM_PICKING_UP = SOUND_TYPE_ITEM | SOUND_TYPE_PICKING_UP, + SOUND_TYPE_ITEM_DROPPING = SOUND_TYPE_ITEM | SOUND_TYPE_DROPPING, + SOUND_TYPE_ITEM_HIDING = SOUND_TYPE_ITEM | SOUND_TYPE_HIDING, + SOUND_TYPE_ITEM_TAKING = SOUND_TYPE_ITEM | SOUND_TYPE_TAKING, + SOUND_TYPE_ITEM_USING = SOUND_TYPE_ITEM | SOUND_TYPE_USING, + + SOUND_TYPE_WEAPON_SHOOTING = SOUND_TYPE_WEAPON | SOUND_TYPE_SHOOTING, + SOUND_TYPE_WEAPON_EMPTY_CLICKING = SOUND_TYPE_WEAPON | SOUND_TYPE_EMPTY_CLICKING, + SOUND_TYPE_WEAPON_BULLET_HIT = SOUND_TYPE_WEAPON | SOUND_TYPE_BULLET_HIT, + SOUND_TYPE_WEAPON_RECHARGING = SOUND_TYPE_WEAPON | SOUND_TYPE_RECHARGING, + + SOUND_TYPE_MONSTER_DYING = SOUND_TYPE_MONSTER | SOUND_TYPE_DYING, + SOUND_TYPE_MONSTER_INJURING = SOUND_TYPE_MONSTER | SOUND_TYPE_INJURING, + SOUND_TYPE_MONSTER_STEP = SOUND_TYPE_MONSTER | SOUND_TYPE_STEP, + SOUND_TYPE_MONSTER_TALKING = SOUND_TYPE_MONSTER | SOUND_TYPE_TALKING, + SOUND_TYPE_MONSTER_ATTACKING = SOUND_TYPE_MONSTER | SOUND_TYPE_ATTACKING, + SOUND_TYPE_MONSTER_EATING = SOUND_TYPE_MONSTER | SOUND_TYPE_EATING, + + SOUND_TYPE_ANOMALY_IDLE = SOUND_TYPE_ANOMALY | SOUND_TYPE_IDLE, + + SOUND_TYPE_WORLD_OBJECT_BREAKING = SOUND_TYPE_WORLD | SOUND_TYPE_OBJECT_BREAKING, + SOUND_TYPE_WORLD_OBJECT_COLLIDING = SOUND_TYPE_WORLD | SOUND_TYPE_OBJECT_COLLIDING, + SOUND_TYPE_WORLD_OBJECT_EXPLODING = SOUND_TYPE_WORLD | SOUND_TYPE_OBJECT_EXPLODING, + SOUND_TYPE_WORLD_AMBIENT = SOUND_TYPE_WORLD | SOUND_TYPE_AMBIENT, + + SOUND_TYPE_WEAPON_PISTOL = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_GUN = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_SUBMACHINEGUN = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_MACHINEGUN = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_SNIPERRIFLE = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_GRENADELAUNCHER = SOUND_TYPE_WEAPON, + SOUND_TYPE_WEAPON_ROCKETLAUNCHER = SOUND_TYPE_WEAPON, }; -#define CROUCH_SOUND_FACTOR .3f -#define ACCELERATED_SOUND_FACTOR .5f +#define CROUCH_SOUND_FACTOR .3f +#define ACCELERATED_SOUND_FACTOR .5f extern xr_token anomaly_type_token[]; diff --git a/src/xrServerEntities/alife_human_brain.cpp b/src/xrServerEntities/alife_human_brain.cpp index 8d7d161f3c3..f3bd8f0afd2 100644 --- a/src/xrServerEntities/alife_human_brain.cpp +++ b/src/xrServerEntities/alife_human_brain.cpp @@ -6,110 +6,108 @@ // Description : ALife human brain class //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" #include "alife_human_brain.h" #include "Common/object_broker.h" +#include "stdafx.h" #include "xrServer_Objects_ALife_Monsters.h" #ifdef XRGAME_EXPORTS -# include "alife_human_object_handler.h" -# include "alife_monster_movement_manager.h" -# include "alife_monster_detail_path_manager.h" -# include "alife_monster_patrol_path_manager.h" -# include "ai_space.h" -# include "ef_storage.h" -# include "ef_primary.h" -# include "alife_simulator.h" -# include "alife_graph_registry.h" -# include "movement_manager_space.h" -# include "alife_smart_terrain_registry.h" -# include "alife_time_manager.h" -# include "date_time.h" -# ifdef DEBUG -# include "Level.h" -# include "map_location.h" -# include "map_manager.h" -# endif +#include "alife_human_object_handler.h" +#include "alife_monster_movement_manager.h" +#include "alife_monster_detail_path_manager.h" +#include "alife_monster_patrol_path_manager.h" +#include "ai_space.h" +#include "ef_storage.h" +#include "ef_primary.h" +#include "alife_simulator.h" +#include "alife_graph_registry.h" +#include "movement_manager_space.h" +#include "alife_smart_terrain_registry.h" +#include "alife_time_manager.h" +#include "date_time.h" +#ifdef DEBUG +#include "Level.h" +#include "map_location.h" +#include "map_manager.h" +#endif #endif -#define MAX_ITEM_FOOD_COUNT 3 -#define MAX_ITEM_MEDIKIT_COUNT 3 -#define MAX_AMMO_ATTACH_COUNT 1 +#define MAX_ITEM_FOOD_COUNT 3 +#define MAX_ITEM_MEDIKIT_COUNT 3 +#define MAX_AMMO_ATTACH_COUNT 1 -CALifeHumanBrain::CALifeHumanBrain (object_type *object) : inherited(object) +CALifeHumanBrain::CALifeHumanBrain(object_type* object) : inherited(object) { - VERIFY (object); - m_object = object; + VERIFY(object); + m_object = object; #ifdef XRGAME_EXPORTS - m_object_handler = new CALifeHumanObjectHandler(object); + m_object_handler = new CALifeHumanObjectHandler(object); #endif - - m_dwTotalMoney = 0; - m_cpEquipmentPreferences.resize (5); - m_cpMainWeaponPreferences.resize(4); + + m_dwTotalMoney = 0; + m_cpEquipmentPreferences.resize(5); + m_cpMainWeaponPreferences.resize(4); #ifdef XRGAME_EXPORTS - m_cpEquipmentPreferences.resize (iFloor(ai().ef_storage().m_pfEquipmentType->ffGetMaxResultValue() + .5f)); - m_cpMainWeaponPreferences.resize(iFloor(ai().ef_storage().m_pfMainWeaponType->ffGetMaxResultValue() + .5f)); - R_ASSERT2 ((iFloor(ai().ef_storage().m_pfEquipmentType->ffGetMaxResultValue() + .5f) == 5) && (iFloor(ai().ef_storage().m_pfMainWeaponType->ffGetMaxResultValue() + .5f) == 4),"Recompile Level Editor and xrAI and rebuild file \"game.spawn\"!"); + m_cpEquipmentPreferences.resize(iFloor(ai().ef_storage().m_pfEquipmentType->ffGetMaxResultValue() + .5f)); + m_cpMainWeaponPreferences.resize(iFloor(ai().ef_storage().m_pfMainWeaponType->ffGetMaxResultValue() + .5f)); + R_ASSERT2((iFloor(ai().ef_storage().m_pfEquipmentType->ffGetMaxResultValue() + .5f) == 5) && + (iFloor(ai().ef_storage().m_pfMainWeaponType->ffGetMaxResultValue() + .5f) == 4), + "Recompile Level Editor and xrAI and rebuild file \"game.spawn\"!"); #endif - for (int i=0, n=m_cpEquipmentPreferences.size(); i temp; - load_data (temp,packet); - } - } - - if (object().m_wVersion <= 35) - return; - - if (object().m_wVersion < 110) { - shared_str temp; - packet.r_stringZ (temp); - } - - if (object().m_wVersion < 118) { - ALife::OBJECT_VECTOR temp; - load_data (temp,packet); - } - - if(packet.inistream==NULL) - { - load_data (m_cpEquipmentPreferences,packet); - load_data (m_cpMainWeaponPreferences,packet); - } + if (object().m_wVersion <= 19) return; + + if (object().m_wVersion < 110) { + { + DWORD_VECTOR temp; + load_data(temp, packet); + } + { + xr_vector temp; + load_data(temp, packet); + } + } + + if (object().m_wVersion <= 35) return; + + if (object().m_wVersion < 110) { + shared_str temp; + packet.r_stringZ(temp); + } + + if (object().m_wVersion < 118) { + ALife::OBJECT_VECTOR temp; + load_data(temp, packet); + } + + if (packet.inistream == NULL) { + load_data(m_cpEquipmentPreferences, packet); + load_data(m_cpMainWeaponPreferences, packet); + } } diff --git a/src/xrServerEntities/alife_human_brain.h b/src/xrServerEntities/alife_human_brain.h index 3d3429e9a6a..8ec1e28e763 100644 --- a/src/xrServerEntities/alife_human_brain.h +++ b/src/xrServerEntities/alife_human_brain.h @@ -13,38 +13,39 @@ class CALifeHumanObjectHandler; class CSE_ALifeHumanAbstract; -class CALifeHumanBrain : public CALifeMonsterBrain { +class CALifeHumanBrain : public CALifeMonsterBrain +{ private: - typedef CALifeMonsterBrain inherited; + typedef CALifeMonsterBrain inherited; public: - typedef CSE_ALifeHumanAbstract object_type; - typedef CALifeHumanObjectHandler object_handler_type; + typedef CSE_ALifeHumanAbstract object_type; + typedef CALifeHumanObjectHandler object_handler_type; private: - object_type *m_object; - object_handler_type *m_object_handler; + object_type* m_object; + object_handler_type* m_object_handler; -// old not yet obsolete stuff + // old not yet obsolete stuff public: - svector m_cpEquipmentPreferences; - svector m_cpMainWeaponPreferences; + svector m_cpEquipmentPreferences; + svector m_cpMainWeaponPreferences; -// old, to be obsolete + // old, to be obsolete public: - u32 m_dwTotalMoney; + u32 m_dwTotalMoney; public: - CALifeHumanBrain (object_type *object); - virtual ~CALifeHumanBrain (); + CALifeHumanBrain(object_type* object); + virtual ~CALifeHumanBrain(); public: - void on_state_write (NET_Packet &packet); - void on_state_read (NET_Packet &packet); + void on_state_write(NET_Packet& packet); + void on_state_read(NET_Packet& packet); public: - IC object_type &object () const; - IC object_handler_type &objects () const; + IC object_type& object() const; + IC object_handler_type& objects() const; }; #include "alife_human_brain_inline.h" diff --git a/src/xrServerEntities/alife_human_brain_inline.h b/src/xrServerEntities/alife_human_brain_inline.h index 367ec35361b..0994e2f6120 100644 --- a/src/xrServerEntities/alife_human_brain_inline.h +++ b/src/xrServerEntities/alife_human_brain_inline.h @@ -8,14 +8,14 @@ #pragma once -IC CALifeHumanBrain::object_type &CALifeHumanBrain::object () const +IC CALifeHumanBrain::object_type& CALifeHumanBrain::object() const { - VERIFY (m_object); - return (*m_object); + VERIFY(m_object); + return (*m_object); } -IC CALifeHumanBrain::object_handler_type &CALifeHumanBrain::objects () const +IC CALifeHumanBrain::object_handler_type& CALifeHumanBrain::objects() const { - VERIFY (m_object_handler); - return (*m_object_handler); + VERIFY(m_object_handler); + return (*m_object_handler); } diff --git a/src/xrServerEntities/alife_monster_brain.cpp b/src/xrServerEntities/alife_monster_brain.cpp index 13a10ac9313..ebc2a74190f 100644 --- a/src/xrServerEntities/alife_monster_brain.cpp +++ b/src/xrServerEntities/alife_monster_brain.cpp @@ -6,151 +6,149 @@ // Description : ALife monster brain class //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" #include "alife_monster_brain.h" #include "Common/object_broker.h" +#include "stdafx.h" #include "xrServer_Objects_ALife_Monsters.h" #ifdef XRGAME_EXPORTS -# include "alife_monster_movement_manager.h" -# include "alife_monster_detail_path_manager.h" -# include "alife_monster_patrol_path_manager.h" -# include "ai_space.h" -# include "ef_storage.h" -# include "ef_primary.h" -# include "alife_simulator.h" -# include "alife_graph_registry.h" -# include "movement_manager_space.h" -# include "alife_smart_terrain_registry.h" -# include "alife_time_manager.h" -# include "date_time.h" -# ifdef DEBUG -# include "Level.h" -# include "map_location.h" -# include "map_manager.h" -# endif +#include "alife_monster_movement_manager.h" +#include "alife_monster_detail_path_manager.h" +#include "alife_monster_patrol_path_manager.h" +#include "ai_space.h" +#include "ef_storage.h" +#include "ef_primary.h" +#include "alife_simulator.h" +#include "alife_graph_registry.h" +#include "movement_manager_space.h" +#include "alife_smart_terrain_registry.h" +#include "alife_time_manager.h" +#include "date_time.h" +#ifdef DEBUG +#include "Level.h" +#include "map_location.h" +#include "map_manager.h" +#endif #endif -#define MAX_ITEM_FOOD_COUNT 3 -#define MAX_ITEM_MEDIKIT_COUNT 3 -#define MAX_AMMO_ATTACH_COUNT 1 +#define MAX_ITEM_FOOD_COUNT 3 +#define MAX_ITEM_MEDIKIT_COUNT 3 +#define MAX_AMMO_ATTACH_COUNT 1 -CALifeMonsterBrain::CALifeMonsterBrain (object_type *object) +CALifeMonsterBrain::CALifeMonsterBrain(object_type* object) { - VERIFY (object); - m_object = object; - m_last_search_time = 0; - m_smart_terrain = 0; + VERIFY(object); + m_object = object; + m_last_search_time = 0; + m_smart_terrain = 0; #ifdef XRGAME_EXPORTS - m_movement_manager = new CALifeMonsterMovementManager(object); + m_movement_manager = new CALifeMonsterMovementManager(object); #endif - + #ifdef XRGAME_EXPORTS - u32 hours,minutes,seconds; - sscanf (pSettings->r_string(this->object().name(),"smart_terrain_choose_interval"),"%d:%d:%d",&hours,&minutes,&seconds); - m_time_interval = (u32)generate_time(1,1,1,hours,minutes,seconds); + u32 hours, minutes, seconds; + sscanf(pSettings->r_string(this->object().name(), "smart_terrain_choose_interval"), "%d:%d:%d", &hours, &minutes, + &seconds); + m_time_interval = (u32)generate_time(1, 1, 1, hours, minutes, seconds); #endif - m_can_choose_alife_tasks = true; + m_can_choose_alife_tasks = true; } -CALifeMonsterBrain::~CALifeMonsterBrain () +CALifeMonsterBrain::~CALifeMonsterBrain() { #ifdef XRGAME_EXPORTS - xr_delete (m_movement_manager); + xr_delete(m_movement_manager); #endif } -void CALifeMonsterBrain::on_state_write (NET_Packet &packet) +void CALifeMonsterBrain::on_state_write(NET_Packet& packet) { } -void CALifeMonsterBrain::on_state_read (NET_Packet &packet) +void CALifeMonsterBrain::on_state_read(NET_Packet& packet) { } #ifdef XRGAME_EXPORTS -bool CALifeMonsterBrain::perform_attack () +bool CALifeMonsterBrain::perform_attack() { - return (false); + return (false); } -ALife::EMeetActionType CALifeMonsterBrain::action_type (CSE_ALifeSchedulable *tpALifeSchedulable, const int &iGroupIndex, const bool &bMutualDetection) +ALife::EMeetActionType CALifeMonsterBrain::action_type( + CSE_ALifeSchedulable* tpALifeSchedulable, const int& iGroupIndex, const bool& bMutualDetection) { - return (ALife::eMeetActionTypeIgnore); + return (ALife::eMeetActionTypeIgnore); } -void CALifeMonsterBrain::on_register () +void CALifeMonsterBrain::on_register() { } -void CALifeMonsterBrain::on_unregister () +void CALifeMonsterBrain::on_unregister() { } -void CALifeMonsterBrain::on_location_change () +void CALifeMonsterBrain::on_location_change() { } -IC CSE_ALifeSmartZone &CALifeMonsterBrain::smart_terrain () +IC CSE_ALifeSmartZone& CALifeMonsterBrain::smart_terrain() { - VERIFY (object().m_smart_terrain_id != 0xffff); - if (m_smart_terrain && (object().m_smart_terrain_id == m_smart_terrain->ID)) - return (*m_smart_terrain); + VERIFY(object().m_smart_terrain_id != 0xffff); + if (m_smart_terrain && (object().m_smart_terrain_id == m_smart_terrain->ID)) return (*m_smart_terrain); - m_smart_terrain = ai().alife().smart_terrains().object(object().m_smart_terrain_id); - VERIFY (m_smart_terrain); - return (*m_smart_terrain); + m_smart_terrain = ai().alife().smart_terrains().object(object().m_smart_terrain_id); + VERIFY(m_smart_terrain); + return (*m_smart_terrain); } -void CALifeMonsterBrain::process_task () +void CALifeMonsterBrain::process_task() { - CALifeSmartTerrainTask *task = smart_terrain().task(&object()); - THROW3 (task,"smart terrain returned nil task, while npc is registered in it",smart_terrain().name_replace()); - movement().path_type (MovementManager::ePathTypeGamePath); - movement().detail().target (*task); + CALifeSmartTerrainTask* task = smart_terrain().task(&object()); + THROW3(task, "smart terrain returned nil task, while npc is registered in it", smart_terrain().name_replace()); + movement().path_type(MovementManager::ePathTypeGamePath); + movement().detail().target(*task); } -void CALifeMonsterBrain::select_task () +void CALifeMonsterBrain::select_task() { - if (object().m_smart_terrain_id != 0xffff) - return; + if (object().m_smart_terrain_id != 0xffff) return; - if (!can_choose_alife_tasks()) - return; + if (!can_choose_alife_tasks()) return; - ALife::_TIME_ID current_time = ai().alife().time_manager().game_time(); + ALife::_TIME_ID current_time = ai().alife().time_manager().game_time(); - if (m_last_search_time + m_time_interval > current_time) - return; + if (m_last_search_time + m_time_interval > current_time) return; - m_last_search_time = current_time; + m_last_search_time = current_time; - float best_value = flt_min; - CALifeSmartTerrainRegistry::OBJECTS::const_iterator I = ai().alife().smart_terrains().objects().begin(); - CALifeSmartTerrainRegistry::OBJECTS::const_iterator E = ai().alife().smart_terrains().objects().end(); - for ( ; I != E; ++I) { - if (!(*I).second->enabled(&object())) - continue; + float best_value = flt_min; + CALifeSmartTerrainRegistry::OBJECTS::const_iterator I = ai().alife().smart_terrains().objects().begin(); + CALifeSmartTerrainRegistry::OBJECTS::const_iterator E = ai().alife().smart_terrains().objects().end(); + for (; I != E; ++I) + { + if (!(*I).second->enabled(&object())) continue; - float value = (*I).second->suitable(&object()); - if (value > best_value) { - best_value = value; - object().m_smart_terrain_id = (*I).second->ID; - } - } + float value = (*I).second->suitable(&object()); + if (value > best_value) { + best_value = value; + object().m_smart_terrain_id = (*I).second->ID; + } + } - if (object().m_smart_terrain_id != 0xffff) { - smart_terrain().register_npc (&object()); - m_last_search_time = 0; - } + if (object().m_smart_terrain_id != 0xffff) { + smart_terrain().register_npc(&object()); + m_last_search_time = 0; + } } -void CALifeMonsterBrain::update () +void CALifeMonsterBrain::update() { -#if 0//def DEBUG +#if 0 // def DEBUG if (!Level().MapManager().HasMapLocation("debug_stalker",object().ID)) { CMapLocation *map_location = Level().MapManager().AddMapLocation( @@ -162,29 +160,29 @@ void CALifeMonsterBrain::update () } #endif - select_task (); - - if (object().m_smart_terrain_id != 0xffff) - process_task (); - else - default_behaviour (); + select_task(); + + if (object().m_smart_terrain_id != 0xffff) + process_task(); + else + default_behaviour(); - movement().update (); + movement().update(); } -void CALifeMonsterBrain::default_behaviour () +void CALifeMonsterBrain::default_behaviour() { - movement().path_type (MovementManager::ePathTypeNoPath); + movement().path_type(MovementManager::ePathTypeNoPath); } -void CALifeMonsterBrain::on_switch_online () +void CALifeMonsterBrain::on_switch_online() { - movement().on_switch_online (); + movement().on_switch_online(); } -void CALifeMonsterBrain::on_switch_offline () +void CALifeMonsterBrain::on_switch_offline() { - movement().on_switch_offline (); + movement().on_switch_offline(); } -#endif // XRGAME_EXPORTS \ No newline at end of file +#endif // XRGAME_EXPORTS \ No newline at end of file diff --git a/src/xrServerEntities/alife_monster_brain.h b/src/xrServerEntities/alife_monster_brain.h index 8423f6c4e87..4e1d4c859f9 100644 --- a/src/xrServerEntities/alife_monster_brain.h +++ b/src/xrServerEntities/alife_monster_brain.h @@ -8,62 +8,64 @@ #pragma once +#include "alife_space.h" #include "xrAICore/Navigation/game_graph_space.h" #include "xrserver_space.h" -#include "alife_space.h" class CSE_ALifeMonsterAbstract; class CALifeMonsterMovementManager; class CSE_ALifeSmartZone; class NET_Packet; -class CALifeMonsterBrain { +class CALifeMonsterBrain +{ public: - typedef CSE_ALifeMonsterAbstract object_type; - typedef CALifeMonsterMovementManager movement_manager_type; + typedef CSE_ALifeMonsterAbstract object_type; + typedef CALifeMonsterMovementManager movement_manager_type; private: - object_type *m_object; - movement_manager_type *m_movement_manager; - bool m_can_choose_alife_tasks; + object_type* m_object; + movement_manager_type* m_movement_manager; + bool m_can_choose_alife_tasks; public: - CSE_ALifeSmartZone *m_smart_terrain; - ALife::_TIME_ID m_last_search_time; - ALife::_TIME_ID m_time_interval; + CSE_ALifeSmartZone* m_smart_terrain; + ALife::_TIME_ID m_last_search_time; + ALife::_TIME_ID m_time_interval; -// sad, but true + // sad, but true public: - void select_task (); + void select_task(); private: - void process_task (); - void default_behaviour (); - IC bool can_choose_alife_tasks () const; + void process_task(); + void default_behaviour(); + IC bool can_choose_alife_tasks() const; public: - CALifeMonsterBrain (object_type *object); - virtual ~CALifeMonsterBrain (); + CALifeMonsterBrain(object_type* object); + virtual ~CALifeMonsterBrain(); public: - void on_state_write (NET_Packet &packet); - void on_state_read (NET_Packet &packet); - void on_register (); - void on_unregister (); - void on_location_change (); - void on_switch_online (); - void on_switch_offline (); + void on_state_write(NET_Packet& packet); + void on_state_read(NET_Packet& packet); + void on_register(); + void on_unregister(); + void on_location_change(); + void on_switch_online(); + void on_switch_offline(); public: - void update (); - bool perform_attack (); - ALife::EMeetActionType action_type (CSE_ALifeSchedulable *tpALifeSchedulable, const int &iGroupIndex, const bool &bMutualDetection); + void update(); + bool perform_attack(); + ALife::EMeetActionType action_type( + CSE_ALifeSchedulable* tpALifeSchedulable, const int& iGroupIndex, const bool& bMutualDetection); public: - IC object_type &object () const; - IC movement_manager_type &movement () const; - IC CSE_ALifeSmartZone &smart_terrain (); - IC void can_choose_alife_tasks (bool value); + IC object_type& object() const; + IC movement_manager_type& movement() const; + IC CSE_ALifeSmartZone& smart_terrain(); + IC void can_choose_alife_tasks(bool value); }; #include "alife_monster_brain_inline.h" diff --git a/src/xrServerEntities/alife_monster_brain_inline.h b/src/xrServerEntities/alife_monster_brain_inline.h index 10bad40cf0b..17969a2f733 100644 --- a/src/xrServerEntities/alife_monster_brain_inline.h +++ b/src/xrServerEntities/alife_monster_brain_inline.h @@ -8,24 +8,24 @@ #pragma once -IC CALifeMonsterBrain::object_type &CALifeMonsterBrain::object () const +IC CALifeMonsterBrain::object_type& CALifeMonsterBrain::object() const { - VERIFY (m_object); - return (*m_object); + VERIFY(m_object); + return (*m_object); } -IC CALifeMonsterBrain::movement_manager_type &CALifeMonsterBrain::movement () const +IC CALifeMonsterBrain::movement_manager_type& CALifeMonsterBrain::movement() const { - VERIFY (m_movement_manager); - return (*m_movement_manager); + VERIFY(m_movement_manager); + return (*m_movement_manager); } -IC bool CALifeMonsterBrain::can_choose_alife_tasks () const +IC bool CALifeMonsterBrain::can_choose_alife_tasks() const { - return (m_can_choose_alife_tasks); + return (m_can_choose_alife_tasks); } -IC void CALifeMonsterBrain::can_choose_alife_tasks (bool value) +IC void CALifeMonsterBrain::can_choose_alife_tasks(bool value) { - m_can_choose_alife_tasks = value; + m_can_choose_alife_tasks = value; } diff --git a/src/xrServerEntities/alife_movement_manager_holder.h b/src/xrServerEntities/alife_movement_manager_holder.h index 0dc80da0ccb..954d5cce550 100644 --- a/src/xrServerEntities/alife_movement_manager_holder.h +++ b/src/xrServerEntities/alife_movement_manager_holder.h @@ -7,21 +7,22 @@ //////////////////////////////////////////////////////////////////////////// #pragma once; -class CMovementManagerHolder { +class CMovementManagerHolder +{ public: - GameGraph::_GRAPH_ID m_tNextGraphID; - GameGraph::_GRAPH_ID m_tPrevGraphID; - float m_fGoingSpeed; - float m_fCurrentLevelGoingSpeed; - float m_fCurSpeed; - float m_fDistanceFromPoint; - float m_fDistanceToPoint; - GameGraph::TERRAIN_VECTOR m_tpaTerrain; + GameGraph::_GRAPH_ID m_tNextGraphID; + GameGraph::_GRAPH_ID m_tPrevGraphID; + float m_fGoingSpeed; + float m_fCurrentLevelGoingSpeed; + float m_fCurSpeed; + float m_fDistanceFromPoint; + float m_fDistanceToPoint; + GameGraph::TERRAIN_VECTOR m_tpaTerrain; #ifdef XRGAME_EXPORTS public: - virtual void on_location_change ( ) const = 0; - virtual CSE_ALifeDynamicObject const& get_object ( ) const = 0; - virtual CSE_ALifeDynamicObject& get_object ( ) = 0; -#endif //#ifdef XRGAME_EXPORTS -}; // CMovementManagerHolder \ No newline at end of file + virtual void on_location_change() const = 0; + virtual CSE_ALifeDynamicObject const& get_object() const = 0; + virtual CSE_ALifeDynamicObject& get_object() = 0; +#endif //#ifdef XRGAME_EXPORTS +}; // CMovementManagerHolder \ No newline at end of file diff --git a/src/xrServerEntities/alife_space.cpp b/src/xrServerEntities/alife_space.cpp index 99bb694aaa2..0bf3587ff89 100644 --- a/src/xrServerEntities/alife_space.cpp +++ b/src/xrServerEntities/alife_space.cpp @@ -1,22 +1,12 @@ -#include "stdafx.h" #include "alife_space.h" +#include "stdafx.h" -namespace ALife { - -xr_token hit_types_token [ ]={ - { "burn", eHitTypeBurn }, - { "shock", eHitTypeShock }, - { "strike", eHitTypeStrike }, - { "wound", eHitTypeWound }, - { "radiation", eHitTypeRadiation }, - { "telepatic", eHitTypeTelepatic }, - { "fire_wound", eHitTypeFireWound }, - { "chemical_burn", eHitTypeChemicalBurn }, - { "explosion", eHitTypeExplosion }, - { "wound_2", eHitTypeWound_2 }, -// { "physic_strike", eHitTypePhysicStrike }, - { "light_burn", eHitTypeLightBurn }, - { 0, 0 } -}; - +namespace ALife +{ +xr_token hit_types_token[] = {{"burn", eHitTypeBurn}, {"shock", eHitTypeShock}, {"strike", eHitTypeStrike}, + {"wound", eHitTypeWound}, {"radiation", eHitTypeRadiation}, {"telepatic", eHitTypeTelepatic}, + {"fire_wound", eHitTypeFireWound}, {"chemical_burn", eHitTypeChemicalBurn}, {"explosion", eHitTypeExplosion}, + {"wound_2", eHitTypeWound_2}, + // { "physic_strike", eHitTypePhysicStrike }, + {"light_burn", eHitTypeLightBurn}, {0, 0}}; }; \ No newline at end of file diff --git a/src/xrServerEntities/alife_space.h b/src/xrServerEntities/alife_space.h index 039caea9c83..52dc8b93266 100644 --- a/src/xrServerEntities/alife_space.h +++ b/src/xrServerEntities/alife_space.h @@ -9,21 +9,20 @@ #ifndef XRAY_ALIFE_SPACE #define XRAY_ALIFE_SPACE - // ALife objects, events and tasks -#define ALIFE_VERSION 0x0006 -#define ALIFE_CHUNK_DATA 0x0000 -#define SPAWN_CHUNK_DATA 0x0001 -#define OBJECT_CHUNK_DATA 0x0002 -#define GAME_TIME_CHUNK_DATA 0x0005 -#define REGISTRY_CHUNK_DATA 0x0009 -#define SECTION_HEADER "location_" -#define SAVE_EXTENSION ".scop" -#define SPAWN_NAME "game.spawn" +#define ALIFE_VERSION 0x0006 +#define ALIFE_CHUNK_DATA 0x0000 +#define SPAWN_CHUNK_DATA 0x0001 +#define OBJECT_CHUNK_DATA 0x0002 +#define GAME_TIME_CHUNK_DATA 0x0005 +#define REGISTRY_CHUNK_DATA 0x0009 +#define SECTION_HEADER "location_" +#define SAVE_EXTENSION ".scop" +#define SPAWN_NAME "game.spawn" // inventory rukzak size -#define MAX_ITEM_VOLUME 100 -#define INVALID_STORY_ID ALife::_STORY_ID(-1) -#define INVALID_SPAWN_STORY_ID ALife::_SPAWN_STORY_ID(-1) +#define MAX_ITEM_VOLUME 100 +#define INVALID_STORY_ID ALife::_STORY_ID(-1) +#define INVALID_SPAWN_STORY_ID ALife::_SPAWN_STORY_ID(-1) class CSE_ALifeDynamicObject; class CSE_ALifeMonsterAbstract; @@ -33,165 +32,178 @@ class CSE_ALifeItemWeapon; class CSE_ALifeSchedulable; class CGameGraph; -namespace ALife { - typedef u64 _CLASS_ID; // Class ID - typedef u16 _OBJECT_ID; // Object ID - typedef u64 _TIME_ID; // Time ID - typedef u32 _EVENT_ID; // Event ID - typedef u32 _TASK_ID; // Event ID - typedef u16 _SPAWN_ID; // Spawn ID - typedef u16 _TERRAIN_ID; // Terrain ID - typedef u32 _STORY_ID; // Story ID - typedef u32 _SPAWN_STORY_ID; // Spawn Story ID - - struct SSumStackCell { - int i1; - int i2; - int iCurrentSum; - }; - - enum ECombatResult { - eCombatResultRetreat1 = u32(0), - eCombatResultRetreat2, - eCombatResultRetreat12, - eCombatResult1Kill2, - eCombatResult2Kill1, - eCombatResultBothKilled, - eCombatDummy = u32(-1), - }; - - enum ECombatAction { - eCombatActionAttack = u32(0), - eCombatActionRetreat, - eCombatActionDummy = u32(-1), - }; - - enum EMeetActionType { - eMeetActionTypeAttack = u32(0), - eMeetActionTypeInteract, - eMeetActionTypeIgnore, - eMeetActionSmartTerrain, - eMeetActionTypeDummy = u32(-1), - }; - - enum ERelationType { - eRelationTypeFriend = u32(0), - eRelationTypeNeutral, - eRelationTypeEnemy, - eRelationTypeWorstEnemy, - eRelationTypeLast, - eRelationTypeDummy = u32(-1), - }; - - enum EHitType { - eHitTypeBurn = u32(0), - eHitTypeShock, - eHitTypeChemicalBurn, - eHitTypeRadiation, - eHitTypeTelepatic, - eHitTypeWound, - eHitTypeFireWound, - eHitTypeStrike, - eHitTypeExplosion, - eHitTypeWound_2, //knife's alternative fire -// eHitTypePhysicStrike, - eHitTypeLightBurn, - eHitTypeMax, - }; - - enum EInfluenceType { - infl_rad = u32(0), - infl_fire, - infl_acid, - infl_psi, - infl_electra, - infl_max_count - }; - - enum EConditionRestoreType { - eHealthRestoreSpeed = u32(0), - eSatietyRestoreSpeed, - ePowerRestoreSpeed, - eBleedingRestoreSpeed, - eRadiationRestoreSpeed, - eRestoreTypeMax, - }; - - enum ETakeType { - eTakeTypeAll, - eTakeTypeMin, - eTakeTypeRest, - }; - - enum EWeaponPriorityType { - eWeaponPriorityTypeKnife = u32(0), - eWeaponPriorityTypeSecondary, - eWeaponPriorityTypePrimary, - eWeaponPriorityTypeGrenade, - eWeaponPriorityTypeDummy = u32(-1), - }; - - enum ECombatType { - eCombatTypeMonsterMonster = u32(0), - eCombatTypeMonsterAnomaly, - eCombatTypeAnomalyMonster, - eCombatTypeSmartTerrain, - eCombatTypeDummy = u32(-1), - }; - - enum EWeaponAddonStatus { - eAddonDisabled = 0, - eAddonPermanent = 1, - eAddonAttachable = 2 - }; - - IC EHitType g_tfString2HitType(LPCSTR caHitType) - { - if (!stricmp(caHitType,"burn")) - return(eHitTypeBurn); - else if (!stricmp(caHitType,"light_burn")) - return(eHitTypeLightBurn); - else if (!stricmp(caHitType,"shock")) - return(eHitTypeShock); - else if (!stricmp(caHitType,"strike")) - return(eHitTypeStrike); - else if (!stricmp(caHitType,"wound")) - return(eHitTypeWound); - else if (!stricmp(caHitType,"radiation")) - return(eHitTypeRadiation); - else if (!stricmp(caHitType,"telepatic")) - return(eHitTypeTelepatic); - else if (!stricmp(caHitType,"fire_wound")) - return(eHitTypeFireWound); - else if (!stricmp(caHitType,"chemical_burn")) - return(eHitTypeChemicalBurn); - else if (!stricmp(caHitType,"explosion")) - return(eHitTypeExplosion); - else if (!stricmp(caHitType,"wound_2")) - return(eHitTypeWound_2); - else - FATAL ("Unsupported hit type!"); - NODEFAULT; +namespace ALife +{ +typedef u64 _CLASS_ID; // Class ID +typedef u16 _OBJECT_ID; // Object ID +typedef u64 _TIME_ID; // Time ID +typedef u32 _EVENT_ID; // Event ID +typedef u32 _TASK_ID; // Event ID +typedef u16 _SPAWN_ID; // Spawn ID +typedef u16 _TERRAIN_ID; // Terrain ID +typedef u32 _STORY_ID; // Story ID +typedef u32 _SPAWN_STORY_ID; // Spawn Story ID + +struct SSumStackCell +{ + int i1; + int i2; + int iCurrentSum; +}; + +enum ECombatResult +{ + eCombatResultRetreat1 = u32(0), + eCombatResultRetreat2, + eCombatResultRetreat12, + eCombatResult1Kill2, + eCombatResult2Kill1, + eCombatResultBothKilled, + eCombatDummy = u32(-1), +}; + +enum ECombatAction +{ + eCombatActionAttack = u32(0), + eCombatActionRetreat, + eCombatActionDummy = u32(-1), +}; + +enum EMeetActionType +{ + eMeetActionTypeAttack = u32(0), + eMeetActionTypeInteract, + eMeetActionTypeIgnore, + eMeetActionSmartTerrain, + eMeetActionTypeDummy = u32(-1), +}; + +enum ERelationType +{ + eRelationTypeFriend = u32(0), + eRelationTypeNeutral, + eRelationTypeEnemy, + eRelationTypeWorstEnemy, + eRelationTypeLast, + eRelationTypeDummy = u32(-1), +}; + +enum EHitType +{ + eHitTypeBurn = u32(0), + eHitTypeShock, + eHitTypeChemicalBurn, + eHitTypeRadiation, + eHitTypeTelepatic, + eHitTypeWound, + eHitTypeFireWound, + eHitTypeStrike, + eHitTypeExplosion, + eHitTypeWound_2, // knife's alternative fire + // eHitTypePhysicStrike, + eHitTypeLightBurn, + eHitTypeMax, +}; + +enum EInfluenceType +{ + infl_rad = u32(0), + infl_fire, + infl_acid, + infl_psi, + infl_electra, + infl_max_count +}; + +enum EConditionRestoreType +{ + eHealthRestoreSpeed = u32(0), + eSatietyRestoreSpeed, + ePowerRestoreSpeed, + eBleedingRestoreSpeed, + eRadiationRestoreSpeed, + eRestoreTypeMax, +}; + +enum ETakeType +{ + eTakeTypeAll, + eTakeTypeMin, + eTakeTypeRest, +}; + +enum EWeaponPriorityType +{ + eWeaponPriorityTypeKnife = u32(0), + eWeaponPriorityTypeSecondary, + eWeaponPriorityTypePrimary, + eWeaponPriorityTypeGrenade, + eWeaponPriorityTypeDummy = u32(-1), +}; + +enum ECombatType +{ + eCombatTypeMonsterMonster = u32(0), + eCombatTypeMonsterAnomaly, + eCombatTypeAnomalyMonster, + eCombatTypeSmartTerrain, + eCombatTypeDummy = u32(-1), +}; + +enum EWeaponAddonStatus +{ + eAddonDisabled = 0, + eAddonPermanent = 1, + eAddonAttachable = 2 +}; + +IC EHitType g_tfString2HitType(LPCSTR caHitType) +{ + if (!stricmp(caHitType, "burn")) + return (eHitTypeBurn); + else if (!stricmp(caHitType, "light_burn")) + return (eHitTypeLightBurn); + else if (!stricmp(caHitType, "shock")) + return (eHitTypeShock); + else if (!stricmp(caHitType, "strike")) + return (eHitTypeStrike); + else if (!stricmp(caHitType, "wound")) + return (eHitTypeWound); + else if (!stricmp(caHitType, "radiation")) + return (eHitTypeRadiation); + else if (!stricmp(caHitType, "telepatic")) + return (eHitTypeTelepatic); + else if (!stricmp(caHitType, "fire_wound")) + return (eHitTypeFireWound); + else if (!stricmp(caHitType, "chemical_burn")) + return (eHitTypeChemicalBurn); + else if (!stricmp(caHitType, "explosion")) + return (eHitTypeExplosion); + else if (!stricmp(caHitType, "wound_2")) + return (eHitTypeWound_2); + else + FATAL("Unsupported hit type!"); + NODEFAULT; #ifdef DEBUG - return(eHitTypeMax); + return (eHitTypeMax); #endif - } -#ifndef _EDITOR - extern xr_token hit_types_token [ ]; - - IC LPCSTR g_cafHitType2String(EHitType tHitType) - { - return get_token_name(hit_types_token, tHitType); - } +} +#ifndef _EDITOR +extern xr_token hit_types_token[]; + +IC LPCSTR g_cafHitType2String(EHitType tHitType) +{ + return get_token_name(hit_types_token, tHitType); +} #endif - DEFINE_VECTOR (int, INT_VECTOR, INT_IT); - DEFINE_VECTOR (_OBJECT_ID, OBJECT_VECTOR, OBJECT_IT); - DEFINE_VECTOR (CSE_ALifeInventoryItem*, ITEM_P_VECTOR, ITEM_P_IT); - DEFINE_VECTOR (CSE_ALifeItemWeapon*, WEAPON_P_VECTOR, WEAPON_P_IT); - DEFINE_VECTOR (CSE_ALifeSchedulable*, SCHEDULE_P_VECTOR, SCHEDULE_P_IT); - - DEFINE_MAP (_OBJECT_ID, CSE_ALifeDynamicObject*, D_OBJECT_P_MAP, D_OBJECT_P_PAIR_IT); - DEFINE_MAP (_STORY_ID, CSE_ALifeDynamicObject*, STORY_P_MAP, STORY_P_PAIR_IT); +DEFINE_VECTOR(int, INT_VECTOR, INT_IT); +DEFINE_VECTOR(_OBJECT_ID, OBJECT_VECTOR, OBJECT_IT); +DEFINE_VECTOR(CSE_ALifeInventoryItem*, ITEM_P_VECTOR, ITEM_P_IT); +DEFINE_VECTOR(CSE_ALifeItemWeapon*, WEAPON_P_VECTOR, WEAPON_P_IT); +DEFINE_VECTOR(CSE_ALifeSchedulable*, SCHEDULE_P_VECTOR, SCHEDULE_P_IT); + +DEFINE_MAP(_OBJECT_ID, CSE_ALifeDynamicObject*, D_OBJECT_P_MAP, D_OBJECT_P_PAIR_IT); +DEFINE_MAP(_STORY_ID, CSE_ALifeDynamicObject*, STORY_P_MAP, STORY_P_PAIR_IT); }; -#endif //XRAY_ALIFE_SPACE +#endif // XRAY_ALIFE_SPACE diff --git a/src/xrServerEntities/character_info.cpp b/src/xrServerEntities/character_info.cpp index dd62f69f0c6..b71ad734ab6 100644 --- a/src/xrServerEntities/character_info.cpp +++ b/src/xrServerEntities/character_info.cpp @@ -1,197 +1,179 @@ ////////////////////////////////////////////////////////////////////////// // character_info.cpp èãðîâàÿ èíôîðìàöèÿ äëÿ ïåðñîíàæåé â èãðå -// +// ////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" #include "character_info.h" +#include "stdafx.h" #ifdef XRGAME_EXPORTS -# include "ui/xrUIXmlParser.h" -# include "PhraseDialog.h" -# include "xrServer_Objects_ALife_Monsters.h" -#else // XRGAME_EXPORTS -# include "xrUIXmlParser.h" -#endif // XRGAME_EXPORTS +#include "ui/xrUIXmlParser.h" +#include "PhraseDialog.h" +#include "xrServer_Objects_ALife_Monsters.h" +#else // XRGAME_EXPORTS +#include "xrUIXmlParser.h" +#endif // XRGAME_EXPORTS ////////////////////////////////////////////////////////////////////////// SCharacterProfile::SCharacterProfile() { - m_CharacterId = NULL; - m_Rank = NO_RANK; - m_Reputation = NO_REPUTATION; + m_CharacterId = NULL; + m_Rank = NO_RANK; + m_Reputation = NO_REPUTATION; } SCharacterProfile::~SCharacterProfile() { } - - ////////////////////////////////////////////////////////////////////////// CCharacterInfo::CCharacterInfo() { - m_ProfileId = NULL; - m_SpecificCharacterId = NULL; + m_ProfileId = NULL; + m_SpecificCharacterId = NULL; #ifdef XRGAME_EXPORTS - m_CurrentRank.set(NO_RANK); - m_CurrentReputation.set(NO_REPUTATION); - m_StartDialog = NULL; - m_Sympathy = 0.0f; + m_CurrentRank.set(NO_RANK); + m_CurrentReputation.set(NO_REPUTATION); + m_StartDialog = NULL; + m_Sympathy = 0.0f; #endif } - CCharacterInfo::~CCharacterInfo() { } - void CCharacterInfo::Load(shared_str id) { - m_ProfileId = id; - inherited_shared::load_shared(m_ProfileId, NULL); + m_ProfileId = id; + inherited_shared::load_shared(m_ProfileId, NULL); } #ifdef XRGAME_EXPORTS -void CCharacterInfo::InitSpecificCharacter (shared_str new_id) +void CCharacterInfo::InitSpecificCharacter(shared_str new_id) { - R_ASSERT(new_id.size()); - m_SpecificCharacterId = new_id; + R_ASSERT(new_id.size()); + m_SpecificCharacterId = new_id; - m_SpecificCharacter.Load(m_SpecificCharacterId); - if(Rank().value() == NO_RANK) - SetRank(m_SpecificCharacter.Rank()); - if(Reputation().value() == NO_REPUTATION) - SetReputation(m_SpecificCharacter.Reputation()); - if(Community().index() == NO_COMMUNITY_INDEX) - SetCommunity(m_SpecificCharacter.Community().index()); - if(!m_StartDialog || !m_StartDialog.size() ) - m_StartDialog = m_SpecificCharacter.data()->m_StartDialog; + m_SpecificCharacter.Load(m_SpecificCharacterId); + if (Rank().value() == NO_RANK) SetRank(m_SpecificCharacter.Rank()); + if (Reputation().value() == NO_REPUTATION) SetReputation(m_SpecificCharacter.Reputation()); + if (Community().index() == NO_COMMUNITY_INDEX) SetCommunity(m_SpecificCharacter.Community().index()); + if (!m_StartDialog || !m_StartDialog.size()) m_StartDialog = m_SpecificCharacter.data()->m_StartDialog; } - #endif -void CCharacterInfo::load_shared (LPCSTR) +void CCharacterInfo::load_shared(LPCSTR) { - const ITEM_DATA& item_data = *id_to_index::GetById(m_ProfileId); + const ITEM_DATA& item_data = *id_to_index::GetById(m_ProfileId); - CUIXml* pXML = item_data._xml; - pXML->SetLocalRoot (pXML->GetRoot()); + CUIXml* pXML = item_data._xml; + pXML->SetLocalRoot(pXML->GetRoot()); - XML_NODE* item_node = pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file); - R_ASSERT3(item_node, "profile id=", *item_data.id); + XML_NODE* item_node = pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file); + R_ASSERT3(item_node, "profile id=", *item_data.id); - pXML->SetLocalRoot(item_node); + pXML->SetLocalRoot(item_node); + LPCSTR spec_char = pXML->Read("specific_character", 0, NULL); + if (!spec_char) { + data()->m_CharacterId = NULL; + LPCSTR char_class = pXML->Read("class", 0, NULL); - LPCSTR spec_char = pXML->Read("specific_character", 0, NULL); - if(!spec_char) - { - data()->m_CharacterId = NULL; - - LPCSTR char_class = pXML->Read ("class", 0, NULL); + if (char_class) { + char* buf_str = xr_strdup(char_class); + xr_strlwr(buf_str); + data()->m_Class = buf_str; + xr_free(buf_str); + } + else + data()->m_Class = NO_CHARACTER_CLASS; - if(char_class) - { - char* buf_str = xr_strdup(char_class); - xr_strlwr(buf_str); - data()->m_Class = buf_str; - xr_free(buf_str); - } - else - data()->m_Class = NO_CHARACTER_CLASS; - - data()->m_Rank = pXML->ReadInt ("rank", 0, NO_RANK); - data()->m_Reputation = pXML->ReadInt ("reputation", 0, NO_REPUTATION); - } - else - data()->m_CharacterId = spec_char; + data()->m_Rank = pXML->ReadInt("rank", 0, NO_RANK); + data()->m_Reputation = pXML->ReadInt("reputation", 0, NO_REPUTATION); + } + else + data()->m_CharacterId = spec_char; } #ifdef XRGAME_EXPORTS -void CCharacterInfo::Init (CSE_ALifeTraderAbstract* trader) +void CCharacterInfo::Init(CSE_ALifeTraderAbstract* trader) { - SetCommunity (trader->m_community_index); - SetRank (trader->m_rank); - SetReputation (trader->m_reputation); - Load (trader->character_profile()); - InitSpecificCharacter (trader->specific_character()); + SetCommunity(trader->m_community_index); + SetRank(trader->m_rank); + SetReputation(trader->m_reputation); + Load(trader->character_profile()); + InitSpecificCharacter(trader->specific_character()); } - -shared_str CCharacterInfo::Profile() const +shared_str CCharacterInfo::Profile() const { - return m_ProfileId; + return m_ProfileId; } LPCSTR CCharacterInfo::Name() const { - R_ASSERT2(m_SpecificCharacterId.size(), m_SpecificCharacter.Name()); - return m_SpecificCharacter.Name(); + R_ASSERT2(m_SpecificCharacterId.size(), m_SpecificCharacter.Name()); + return m_SpecificCharacter.Name(); } shared_str CCharacterInfo::Bio() const { - return m_SpecificCharacter.Bio(); + return m_SpecificCharacter.Bio(); } -void CCharacterInfo::SetRank (CHARACTER_RANK_VALUE rank) +void CCharacterInfo::SetRank(CHARACTER_RANK_VALUE rank) { - m_CurrentRank.set(rank); + m_CurrentRank.set(rank); } -void CCharacterInfo::SetReputation (CHARACTER_REPUTATION_VALUE reputation) +void CCharacterInfo::SetReputation(CHARACTER_REPUTATION_VALUE reputation) { - m_CurrentReputation.set(reputation); + m_CurrentReputation.set(reputation); } void CCharacterInfo::SetCommunity(CHARACTER_COMMUNITY_INDEX community) { - m_CurrentCommunity.set( community ); - m_Sympathy = m_CurrentCommunity.sympathy( m_CurrentCommunity.index() ); + m_CurrentCommunity.set(community); + m_Sympathy = m_CurrentCommunity.sympathy(m_CurrentCommunity.index()); } const shared_str& CCharacterInfo::IconName() const { - R_ASSERT(m_SpecificCharacterId.size()); - return m_SpecificCharacter.IconName(); + R_ASSERT(m_SpecificCharacterId.size()); + return m_SpecificCharacter.IconName(); } -shared_str CCharacterInfo::StartDialog () const +shared_str CCharacterInfo::StartDialog() const { - return m_StartDialog; + return m_StartDialog; } -const DIALOG_ID_VECTOR& CCharacterInfo::ActorDialogs () const +const DIALOG_ID_VECTOR& CCharacterInfo::ActorDialogs() const { - R_ASSERT(m_SpecificCharacterId.size()); - return m_SpecificCharacter.data()->m_ActorDialogs; + R_ASSERT(m_SpecificCharacterId.size()); + return m_SpecificCharacter.data()->m_ActorDialogs; } -void CCharacterInfo::load (IReader& stream) +void CCharacterInfo::load(IReader& stream) { - stream.r_stringZ (m_StartDialog); + stream.r_stringZ(m_StartDialog); } -void CCharacterInfo::save (NET_Packet& stream) +void CCharacterInfo::save(NET_Packet& stream) { - stream.w_stringZ (m_StartDialog); + stream.w_stringZ(m_StartDialog); } #endif - - void CCharacterInfo::InitXmlIdToIndex() { - if(!id_to_index::tag_name) - id_to_index::tag_name = "character"; - if(!id_to_index::file_str) - id_to_index::file_str = pSettings->r_string("profiles", "files"); + if (!id_to_index::tag_name) id_to_index::tag_name = "character"; + if (!id_to_index::file_str) id_to_index::file_str = pSettings->r_string("profiles", "files"); } diff --git a/src/xrServerEntities/character_info.h b/src/xrServerEntities/character_info.h index 1d1e2410c5e..95f06c5ad0a 100644 --- a/src/xrServerEntities/character_info.h +++ b/src/xrServerEntities/character_info.h @@ -1,9 +1,9 @@ ////////////////////////////////////////////////////////////////////////// // character_info.h øàáëîí, äëÿ ïðåäñòàâëåíèÿ àáñòðàêòíîãî ïåñîíàæà -// +// ////////////////////////////////////////////////////////////////////////// -#pragma once +#pragma once #include "character_info_defs.h" #include "shared_data.h" @@ -12,129 +12,125 @@ class NET_Packet; #ifndef AI_COMPILER - #include "specific_character.h" +#include "specific_character.h" #endif #ifdef XRGAME_EXPORTS - #include "PhraseDialogDefs.h" - #include "character_community.h" - #include "character_rank.h" - #include "character_reputation.h" - class CSE_ALifeTraderAbstract; +#include "PhraseDialogDefs.h" +#include "character_community.h" +#include "character_rank.h" +#include "character_reputation.h" +class CSE_ALifeTraderAbstract; #endif - ////////////////////////////////////////////////////////////////////////// // SCharacterProfile: äàííûå ïðîôèëÿ ïåðñîíàæà ////////////////////////////////////////////////////////////////////////// struct SCharacterProfile : CSharedResource { - SCharacterProfile (); - virtual ~SCharacterProfile (); + SCharacterProfile(); + virtual ~SCharacterProfile(); //åñëè çàäàíî, òî âûáèðàåòñÿ èìåííî òàêîé ïðîôèëü, - //èíà÷å èùåòñÿ ñëó÷àéíî,óäîâëåòâîðÿþùåå øàáëîíó - shared_str m_CharacterId; + //èíà÷å èùåòñÿ ñëó÷àéíî,óäîâëåòâîðÿþùåå øàáëîíó + shared_str m_CharacterId; - //òðåáóåìûå ïàðàìåòðû ïåðñîíàæà - CHARACTER_CLASS m_Class; - CHARACTER_RANK_VALUE m_Rank; - CHARACTER_REPUTATION_VALUE m_Reputation; + //òðåáóåìûå ïàðàìåòðû ïåðñîíàæà + CHARACTER_CLASS m_Class; + CHARACTER_RANK_VALUE m_Rank; + CHARACTER_REPUTATION_VALUE m_Reputation; }; - class CInventoryOwner; class CSE_ALifeTraderAbstract; -class CCharacterInfo: public CSharedClass, - public CXML_IdToIndex +class CCharacterInfo : public CSharedClass, public CXML_IdToIndex { private: - typedef CSharedClass inherited_shared; - typedef CXML_IdToIndex id_to_index; + typedef CSharedClass inherited_shared; + typedef CXML_IdToIndex id_to_index; - friend id_to_index; - friend CInventoryOwner; - friend CSE_ALifeTraderAbstract; -public: + friend id_to_index; + friend CInventoryOwner; + friend CSE_ALifeTraderAbstract; +public: + CCharacterInfo(); + ~CCharacterInfo(); - - CCharacterInfo (); - ~CCharacterInfo (); - - virtual void Load (shared_str id); + virtual void Load(shared_str id); #ifdef XRGAME_EXPORTS - void load (IReader&); - void save (NET_Packet&); - - //èíèöèàëèçàöèÿ ïðîôèëÿ ïîäðàçóìåâàåò - //çàãðóçêó ñîîòâåòñòâóþùåãî CSpecificCharacter, ïî - //óêàçàííîìó èíäåêñó - void Init (CSE_ALifeTraderAbstract* trader); - void InitSpecificCharacter (shared_str new_id); + void load(IReader&); + void save(NET_Packet&); + + //èíèöèàëèçàöèÿ ïðîôèëÿ ïîäðàçóìåâàåò + //çàãðóçêó ñîîòâåòñòâóþùåãî CSpecificCharacter, ïî + //óêàçàííîìó èíäåêñó + void Init(CSE_ALifeTraderAbstract* trader); + void InitSpecificCharacter(shared_str new_id); #endif protected: - const SCharacterProfile* data () const { VERIFY(inherited_shared::get_sd()); return inherited_shared::get_sd();} - SCharacterProfile* data () { VERIFY(inherited_shared::get_sd()); return inherited_shared::get_sd();} + const SCharacterProfile* data() const + { + VERIFY(inherited_shared::get_sd()); + return inherited_shared::get_sd(); + } + SCharacterProfile* data() + { + VERIFY(inherited_shared::get_sd()); + return inherited_shared::get_sd(); + } - static void InitXmlIdToIndex (); + static void InitXmlIdToIndex(); + //çàãðóçêà èç XML ôàéëà + virtual void load_shared(LPCSTR); - //çàãðóçêà èç XML ôàéëà - virtual void load_shared (LPCSTR); + //èíäåêñ çàãðóæåííîãî ïðîôèëÿ + shared_str m_ProfileId; - //èíäåêñ çàãðóæåííîãî ïðîôèëÿ - shared_str m_ProfileId; - - //èíäåêñ äàííûõ î êîíêðåòíîì ïåðñîíàæå, êîòîðûé - //èñïîëüçóåòñÿ â äàííîì ýêçåìïëÿðå êëàññà - shared_str m_SpecificCharacterId; + //èíäåêñ äàííûõ î êîíêðåòíîì ïåðñîíàæå, êîòîðûé + //èñïîëüçóåòñÿ â äàííîì ýêçåìïëÿðå êëàññà + shared_str m_SpecificCharacterId; #ifdef XRGAME_EXPORTS - shared_str m_StartDialog; + shared_str m_StartDialog; - //çàãðóæåííàÿ èíôîðìàöèÿ î êîíêðåòíîì ïåðñîíàæå - CSpecificCharacter m_SpecificCharacter; + //çàãðóæåííàÿ èíôîðìàöèÿ î êîíêðåòíîì ïåðñîíàæå + CSpecificCharacter m_SpecificCharacter; #endif public: - - #ifdef XRGAME_EXPORTS - shared_str Profile() const; - LPCSTR Name() const; - shared_str Bio() const; - - - const CHARACTER_COMMUNITY& Community() const { return m_CurrentCommunity; } - const CHARACTER_RANK& Rank() const { return m_CurrentRank; } - const CHARACTER_REPUTATION& Reputation() const { return m_CurrentReputation; } - float Sympathy() const { return m_Sympathy; } - void SetSympathy (float sympathy) { m_Sympathy = sympathy; } - - //äîñòóïóò òîëüêî ó InventoryOwner + shared_str Profile() const; + LPCSTR Name() const; + shared_str Bio() const; + + const CHARACTER_COMMUNITY& Community() const { return m_CurrentCommunity; } + const CHARACTER_RANK& Rank() const { return m_CurrentRank; } + const CHARACTER_REPUTATION& Reputation() const { return m_CurrentReputation; } + float Sympathy() const { return m_Sympathy; } + void SetSympathy(float sympathy) { m_Sympathy = sympathy; } + //äîñòóïóò òîëüêî ó InventoryOwner protected: - void SetRank (CHARACTER_RANK_VALUE rank); - void SetReputation (CHARACTER_REPUTATION_VALUE reputation); - void SetCommunity (CHARACTER_COMMUNITY_INDEX community); + void SetRank(CHARACTER_RANK_VALUE rank); + void SetReputation(CHARACTER_REPUTATION_VALUE reputation); + void SetCommunity(CHARACTER_COMMUNITY_INDEX community); public: - const shared_str& IconName () const; + const shared_str& IconName() const; - shared_str StartDialog () const; - const DIALOG_ID_VECTOR& ActorDialogs () const; + shared_str StartDialog() const; + const DIALOG_ID_VECTOR& ActorDialogs() const; #endif protected: - - #ifdef XRGAME_EXPORTS - CHARACTER_RANK m_CurrentRank; - CHARACTER_REPUTATION m_CurrentReputation; - CHARACTER_COMMUNITY m_CurrentCommunity; - float m_Sympathy; // % âëèÿíèÿ íà ãðóïïèðîâêó + CHARACTER_RANK m_CurrentRank; + CHARACTER_REPUTATION m_CurrentReputation; + CHARACTER_COMMUNITY m_CurrentCommunity; + float m_Sympathy; // % âëèÿíèÿ íà ãðóïïèðîâêó #endif }; \ No newline at end of file diff --git a/src/xrServerEntities/character_info_defs.h b/src/xrServerEntities/character_info_defs.h index 81ac658a4f1..7901adde4e1 100644 --- a/src/xrServerEntities/character_info_defs.h +++ b/src/xrServerEntities/character_info_defs.h @@ -2,30 +2,28 @@ #include "alife_space.h" - -//ëè÷íîå îòíîøåíèå (áëàãîñêëîííîñòü) îäíîãî ïåðñîíàæà ê äðóãîìó - +//ëè÷íîå îòíîøåíèå (áëàãîñêëîííîñòü) îäíîãî ïåðñîíàæà ê äðóãîìó - //âåëè÷èíà îò -100< (êðàéíå âðàæäåáíîå) äî >100 (î÷åíü äðþæåëþáíîå) -typedef int CHARACTER_GOODWILL; -#define NO_GOODWILL -type_max(CHARACTER_GOODWILL) -#define NEUTRAL_GOODWILL CHARACTER_GOODWILL(0) +typedef int CHARACTER_GOODWILL; +#define NO_GOODWILL -type_max(CHARACTER_GOODWILL) +#define NEUTRAL_GOODWILL CHARACTER_GOODWILL(0) -typedef shared_str CHARACTER_CLASS; -#define NO_CHARACTER_CLASS NULL +typedef shared_str CHARACTER_CLASS; +#define NO_CHARACTER_CLASS NULL -//ðåïóòàöèÿ ïåðñîíàæà - âåëè÷èíà îò -100 (î÷åíü ïëîõîé, áåñïðåäåëüùèê) +//ðåïóòàöèÿ ïåðñîíàæà - âåëè÷èíà îò -100 (î÷åíü ïëîõîé, áåñïðåäåëüùèê) //äî 100 (î÷åíü õîðîøèé, áëàãîðîäíûé) -typedef int CHARACTER_REPUTATION_VALUE; -#define NO_REPUTATION -type_max(CHARACTER_REPUTATION_VALUE) -#define NEUTAL_REPUTATION 0 +typedef int CHARACTER_REPUTATION_VALUE; +#define NO_REPUTATION -type_max(CHARACTER_REPUTATION_VALUE) +#define NEUTAL_REPUTATION 0 -//ðàíã ïåðñîíàæà - âåëè÷èíà îò 0 (ñîâñåì íåîïûòíûé) +//ðàíã ïåðñîíàæà - âåëè÷èíà îò 0 (ñîâñåì íåîïûòíûé) //äî >100 (î÷åíü îïûòíûé) -typedef int CHARACTER_RANK_VALUE; -#define NO_RANK -type_max(CHARACTER_RANK_VALUE) - +typedef int CHARACTER_RANK_VALUE; +#define NO_RANK -type_max(CHARACTER_RANK_VALUE) -typedef shared_str CHARACTER_COMMUNITY_ID; -#define NO_COMMUNITY_ID CHARACTER_COMMUNITY_ID(NULL) +typedef shared_str CHARACTER_COMMUNITY_ID; +#define NO_COMMUNITY_ID CHARACTER_COMMUNITY_ID(NULL) -typedef int CHARACTER_COMMUNITY_INDEX; -#define NO_COMMUNITY_INDEX CHARACTER_COMMUNITY_INDEX(-1) \ No newline at end of file +typedef int CHARACTER_COMMUNITY_INDEX; +#define NO_COMMUNITY_INDEX CHARACTER_COMMUNITY_INDEX(-1) \ No newline at end of file diff --git a/src/xrServerEntities/clsid_game.h b/src/xrServerEntities/clsid_game.h index e233f5e5191..b56fd4df4f4 100644 --- a/src/xrServerEntities/clsid_game.h +++ b/src/xrServerEntities/clsid_game.h @@ -1,227 +1,226 @@ #pragma once -#define CLSID_OBJECT_ACTOR MK_CLSID('O','_','A','C','T','O','R',' ') -#define CLSID_OBJECT_HLAMP MK_CLSID('O','_','H','L','A','M','P',' ') -#define CLSID_ENTITY MK_CLSID('E','N','T','I','T','Y',' ',' ') -#define CLSID_SPECTATOR MK_CLSID('S','P','E','C','T',' ',' ',' ') -#define CLSID_OBJECT_PROJECTOR MK_CLSID('O','_','S','E','A','R','C','H') +#define CLSID_OBJECT_ACTOR MK_CLSID('O', '_', 'A', 'C', 'T', 'O', 'R', ' ') +#define CLSID_OBJECT_HLAMP MK_CLSID('O', '_', 'H', 'L', 'A', 'M', 'P', ' ') +#define CLSID_ENTITY MK_CLSID('E', 'N', 'T', 'I', 'T', 'Y', ' ', ' ') +#define CLSID_SPECTATOR MK_CLSID('S', 'P', 'E', 'C', 'T', ' ', ' ', ' ') +#define CLSID_OBJECT_PROJECTOR MK_CLSID('O', '_', 'S', 'E', 'A', 'R', 'C', 'H') // all the monsters -#define CLSID_LEVEL_POINT MK_CLSID('L','V','L','P','O','I','N','T') -#define CLSID_SCRIPT_OBJECT MK_CLSID('S','C','R','P','T','O','B','J') -#define CLSID_AI_GRAPH MK_CLSID('A','I','_','G','R','A','P','H') -#define CLSID_AI_CROW MK_CLSID('A','I','_','C','R','O','W',' ') - -#define CLSID_AI_ZOMBIE MK_CLSID('A','I','_','Z','O','M',' ',' ') -#define CLSID_AI_POLTERGEIST MK_CLSID('A','I','_','P','O','L','T','R') - -#define CLSID_AI_FLESH MK_CLSID('A','I','_','F','L','E','S','H') -#define CLSID_AI_FLESH_GROUP MK_CLSID('A','I','_','F','L','E','_','G') - -#define CLSID_AI_PHANTOM MK_CLSID('A','I','_','P','H','A','N','T') -#define CLSID_AI_SPONGER MK_CLSID('A','I','_','S','P','O','N','G') -#define CLSID_AI_CONTROLLER MK_CLSID('A','I','_','C','O','N','T','R') -#define CLSID_AI_BLOODSUCKER MK_CLSID('A','I','_','B','L','O','O','D') -#define CLSID_AI_STALKER MK_CLSID('A','I','_','S','T','L',' ',' ') -#define CLSID_AI_BURER MK_CLSID('A','I','_','B','U','R','E','R') -#define CLSID_AI_GIANT MK_CLSID('A','I','_','G','I','A','N','T') -#define CLSID_AI_CHIMERA MK_CLSID('A','I','_','H','I','M','E','R') -#define CLSID_AI_FRACTURE MK_CLSID('A','I','_','F','R','A','C','T') -#define CLSID_AI_DOG_BLACK MK_CLSID('A','I','_','D','O','G','_','B') -#define CLSID_AI_DOG_RED MK_CLSID('A','I','_','D','O','G','_','R') -#define CLSID_AI_DOG_PSY MK_CLSID('A','I','_','D','O','G','_','P') -#define CLSID_AI_DOG_PSY_PHANTOM MK_CLSID('A','I','_','D','O','G','_','F') -#define CLSID_AI_TRADER MK_CLSID('A','I','_','T','R','A','D','E') -#define CLSID_AI_BOAR MK_CLSID('A','I','_','B','O','A','R',' ') -#define CLSID_AI_SNORK MK_CLSID('A','I','_','S','N','O','R','K') -#define CLSID_AI_CAT MK_CLSID('A','I','_','C','A','T',' ',' ') -#define CLSID_AI_TUSHKANO MK_CLSID('A','I','_','T','U','S','H',' ') -#define CLSID_AI_RAT MK_CLSID('A','I','_','R','A','T',' ',' ') +#define CLSID_LEVEL_POINT MK_CLSID('L', 'V', 'L', 'P', 'O', 'I', 'N', 'T') +#define CLSID_SCRIPT_OBJECT MK_CLSID('S', 'C', 'R', 'P', 'T', 'O', 'B', 'J') +#define CLSID_AI_GRAPH MK_CLSID('A', 'I', '_', 'G', 'R', 'A', 'P', 'H') +#define CLSID_AI_CROW MK_CLSID('A', 'I', '_', 'C', 'R', 'O', 'W', ' ') + +#define CLSID_AI_ZOMBIE MK_CLSID('A', 'I', '_', 'Z', 'O', 'M', ' ', ' ') +#define CLSID_AI_POLTERGEIST MK_CLSID('A', 'I', '_', 'P', 'O', 'L', 'T', 'R') + +#define CLSID_AI_FLESH MK_CLSID('A', 'I', '_', 'F', 'L', 'E', 'S', 'H') +#define CLSID_AI_FLESH_GROUP MK_CLSID('A', 'I', '_', 'F', 'L', 'E', '_', 'G') + +#define CLSID_AI_PHANTOM MK_CLSID('A', 'I', '_', 'P', 'H', 'A', 'N', 'T') +#define CLSID_AI_SPONGER MK_CLSID('A', 'I', '_', 'S', 'P', 'O', 'N', 'G') +#define CLSID_AI_CONTROLLER MK_CLSID('A', 'I', '_', 'C', 'O', 'N', 'T', 'R') +#define CLSID_AI_BLOODSUCKER MK_CLSID('A', 'I', '_', 'B', 'L', 'O', 'O', 'D') +#define CLSID_AI_STALKER MK_CLSID('A', 'I', '_', 'S', 'T', 'L', ' ', ' ') +#define CLSID_AI_BURER MK_CLSID('A', 'I', '_', 'B', 'U', 'R', 'E', 'R') +#define CLSID_AI_GIANT MK_CLSID('A', 'I', '_', 'G', 'I', 'A', 'N', 'T') +#define CLSID_AI_CHIMERA MK_CLSID('A', 'I', '_', 'H', 'I', 'M', 'E', 'R') +#define CLSID_AI_FRACTURE MK_CLSID('A', 'I', '_', 'F', 'R', 'A', 'C', 'T') +#define CLSID_AI_DOG_BLACK MK_CLSID('A', 'I', '_', 'D', 'O', 'G', '_', 'B') +#define CLSID_AI_DOG_RED MK_CLSID('A', 'I', '_', 'D', 'O', 'G', '_', 'R') +#define CLSID_AI_DOG_PSY MK_CLSID('A', 'I', '_', 'D', 'O', 'G', '_', 'P') +#define CLSID_AI_DOG_PSY_PHANTOM MK_CLSID('A', 'I', '_', 'D', 'O', 'G', '_', 'F') +#define CLSID_AI_TRADER MK_CLSID('A', 'I', '_', 'T', 'R', 'A', 'D', 'E') +#define CLSID_AI_BOAR MK_CLSID('A', 'I', '_', 'B', 'O', 'A', 'R', ' ') +#define CLSID_AI_SNORK MK_CLSID('A', 'I', '_', 'S', 'N', 'O', 'R', 'K') +#define CLSID_AI_CAT MK_CLSID('A', 'I', '_', 'C', 'A', 'T', ' ', ' ') +#define CLSID_AI_TUSHKANO MK_CLSID('A', 'I', '_', 'T', 'U', 'S', 'H', ' ') +#define CLSID_AI_RAT MK_CLSID('A', 'I', '_', 'R', 'A', 'T', ' ', ' ') // vehicles -#define CLSID_CAR MK_CLSID('C','_','N','I','V','A',' ',' ') -#define CLSID_VEHICLE_HELICOPTER MK_CLSID('C','_','H','L','C','P','T','R') +#define CLSID_CAR MK_CLSID('C', '_', 'N', 'I', 'V', 'A', ' ', ' ') +#define CLSID_VEHICLE_HELICOPTER MK_CLSID('C', '_', 'H', 'L', 'C', 'P', 'T', 'R') -#define CLSID_EVENT MK_CLSID('E','V','E','N','T',' ',' ',' ') -#define CLSID_OBJECT_FLYER MK_CLSID('O','_','F','L','Y','E','R',' ') -#define CLSID_OBJECT_DOOR MK_CLSID('O','_','D','O','O','R',' ',' ') -#define CLSID_OBJECT_LIFT MK_CLSID('O','_','L','I','F','T',' ',' ') +#define CLSID_EVENT MK_CLSID('E', 'V', 'E', 'N', 'T', ' ', ' ', ' ') +#define CLSID_OBJECT_FLYER MK_CLSID('O', '_', 'F', 'L', 'Y', 'E', 'R', ' ') +#define CLSID_OBJECT_DOOR MK_CLSID('O', '_', 'D', 'O', 'O', 'R', ' ', ' ') +#define CLSID_OBJECT_LIFT MK_CLSID('O', '_', 'L', 'I', 'F', 'T', ' ', ' ') // Artefacts -#define CLSID_AF_MERCURY_BALL MK_CLSID('A','F','_','M','B','A','L','L') -#define CLSID_AF_GRAVI MK_CLSID('A','F','_','G','R','A','V','I') -#define CLSID_AF_BLACKDROPS MK_CLSID('A','F','_','B','D','R','O','P') -#define CLSID_AF_NEEDLES MK_CLSID('A','F','_','N','E','E','D','L') -#define CLSID_AF_BAST MK_CLSID('A','F','_','B','A','S','T',' ') -#define CLSID_AF_BLACK_GRAVI MK_CLSID('A','F','_','B','G','R','A','V') -#define CLSID_AF_DUMMY MK_CLSID('A','F','_','D','U','M','M','Y') -#define CLSID_AF_ZUDA MK_CLSID('A','F','_','Z','U','D','A',' ') -#define CLSID_AF_THORN MK_CLSID('A','F','_','T','H','O','R','N') -#define CLSID_AF_FADED_BALL MK_CLSID('A','F','_','F','B','A','L','L') -#define CLSID_AF_ELECTRIC_BALL MK_CLSID('A','F','_','E','B','A','L','L') -#define CLSID_AF_RUSTY_HAIR MK_CLSID('A','F','_','R','H','A','I','R') -#define CLSID_AF_GALANTINE MK_CLSID('A','F','_','G','A','L','A','N') -#define CLSID_AF_CTA MK_CLSID('A','F','_','C','T','A',' ',' ') - -#define CLSID_ARTEFACT MK_CLSID('A','R','T','E','F','A','C','T') +#define CLSID_AF_MERCURY_BALL MK_CLSID('A', 'F', '_', 'M', 'B', 'A', 'L', 'L') +#define CLSID_AF_GRAVI MK_CLSID('A', 'F', '_', 'G', 'R', 'A', 'V', 'I') +#define CLSID_AF_BLACKDROPS MK_CLSID('A', 'F', '_', 'B', 'D', 'R', 'O', 'P') +#define CLSID_AF_NEEDLES MK_CLSID('A', 'F', '_', 'N', 'E', 'E', 'D', 'L') +#define CLSID_AF_BAST MK_CLSID('A', 'F', '_', 'B', 'A', 'S', 'T', ' ') +#define CLSID_AF_BLACK_GRAVI MK_CLSID('A', 'F', '_', 'B', 'G', 'R', 'A', 'V') +#define CLSID_AF_DUMMY MK_CLSID('A', 'F', '_', 'D', 'U', 'M', 'M', 'Y') +#define CLSID_AF_ZUDA MK_CLSID('A', 'F', '_', 'Z', 'U', 'D', 'A', ' ') +#define CLSID_AF_THORN MK_CLSID('A', 'F', '_', 'T', 'H', 'O', 'R', 'N') +#define CLSID_AF_FADED_BALL MK_CLSID('A', 'F', '_', 'F', 'B', 'A', 'L', 'L') +#define CLSID_AF_ELECTRIC_BALL MK_CLSID('A', 'F', '_', 'E', 'B', 'A', 'L', 'L') +#define CLSID_AF_RUSTY_HAIR MK_CLSID('A', 'F', '_', 'R', 'H', 'A', 'I', 'R') +#define CLSID_AF_GALANTINE MK_CLSID('A', 'F', '_', 'G', 'A', 'L', 'A', 'N') +#define CLSID_AF_CTA MK_CLSID('A', 'F', '_', 'C', 'T', 'A', ' ', ' ') + +#define CLSID_ARTEFACT MK_CLSID('A', 'R', 'T', 'E', 'F', 'A', 'C', 'T') // Weapons -#define CLSID_OBJECT_W_M134 MK_CLSID('W','_','M','1','3','4',' ',' ') -#define CLSID_OBJECT_W_FN2000 MK_CLSID('W','_','F','N','2','0','0','0') -#define CLSID_OBJECT_W_AK74 MK_CLSID('W','_','A','K','7','4',' ',' ') -#define CLSID_OBJECT_W_LR300 MK_CLSID('W','_','L','R','3','0','0',' ') -#define CLSID_OBJECT_W_HPSA MK_CLSID('W','_','H','P','S','A',' ',' ') -#define CLSID_OBJECT_W_PM MK_CLSID('W','_','P','M',' ',' ',' ',' ') -#define CLSID_OBJECT_W_FORT MK_CLSID('W','_','F','O','R','T',' ',' ') -#define CLSID_OBJECT_W_BINOCULAR MK_CLSID('W','_','B','I','N','O','C',' ') -#define CLSID_OBJECT_W_SHOTGUN MK_CLSID('W','_','S','H','O','T','G','N') -#define CLSID_OBJECT_W_ASHOTGUN MK_CLSID('W','_','A','S','H','T','G','N') +#define CLSID_OBJECT_W_M134 MK_CLSID('W', '_', 'M', '1', '3', '4', ' ', ' ') +#define CLSID_OBJECT_W_FN2000 MK_CLSID('W', '_', 'F', 'N', '2', '0', '0', '0') +#define CLSID_OBJECT_W_AK74 MK_CLSID('W', '_', 'A', 'K', '7', '4', ' ', ' ') +#define CLSID_OBJECT_W_LR300 MK_CLSID('W', '_', 'L', 'R', '3', '0', '0', ' ') +#define CLSID_OBJECT_W_HPSA MK_CLSID('W', '_', 'H', 'P', 'S', 'A', ' ', ' ') +#define CLSID_OBJECT_W_PM MK_CLSID('W', '_', 'P', 'M', ' ', ' ', ' ', ' ') +#define CLSID_OBJECT_W_FORT MK_CLSID('W', '_', 'F', 'O', 'R', 'T', ' ', ' ') +#define CLSID_OBJECT_W_BINOCULAR MK_CLSID('W', '_', 'B', 'I', 'N', 'O', 'C', ' ') +#define CLSID_OBJECT_W_SHOTGUN MK_CLSID('W', '_', 'S', 'H', 'O', 'T', 'G', 'N') +#define CLSID_OBJECT_W_ASHOTGUN MK_CLSID('W', '_', 'A', 'S', 'H', 'T', 'G', 'N') // [8/15/2006] -#define CLSID_OBJECT_W_MAGAZINED MK_CLSID('W','_','W','M','A','G','A','Z') +#define CLSID_OBJECT_W_MAGAZINED MK_CLSID('W', '_', 'W', 'M', 'A', 'G', 'A', 'Z') // [8/15/2006] // [8/17/2006] -#define CLSID_OBJECT_W_MAGAZWGL MK_CLSID('W','_','W','M','A','G','G','L') +#define CLSID_OBJECT_W_MAGAZWGL MK_CLSID('W', '_', 'W', 'M', 'A', 'G', 'G', 'L') // [8/17/2006] -#define CLSID_OBJECT_W_SVD MK_CLSID('W','_','S','V','D',' ',' ',' ') -#define CLSID_OBJECT_W_SVU MK_CLSID('W','_','S','V','U',' ',' ',' ') -#define CLSID_OBJECT_W_RPG7 MK_CLSID('W','_','R','P','G','7',' ',' ') -#define CLSID_OBJECT_W_VAL MK_CLSID('W','_','V','A','L',' ',' ',' ') -#define CLSID_OBJECT_W_VINTOREZ MK_CLSID('W','_','V','I','N','T',' ',' ') -#define CLSID_OBJECT_W_WALTHER MK_CLSID('W','_','W','A','L','T','H','R') -#define CLSID_OBJECT_W_USP45 MK_CLSID('W','_','U','S','P','4','5',' ') -#define CLSID_OBJECT_W_GROZA MK_CLSID('W','_','G','R','O','Z','A',' ') -#define CLSID_OBJECT_W_KNIFE MK_CLSID('W','_','K','N','I','F','E',' ') -#define CLSID_OBJECT_W_BM16 MK_CLSID('W','_','B','M','1','6',' ',' ') -#define CLSID_OBJECT_W_RG6 MK_CLSID('W','_','R','G','6',' ',' ',' ') - -#define CLSID_OBJECT_W_STATMGUN MK_CLSID('W','_','S','T','M','G','U','N') +#define CLSID_OBJECT_W_SVD MK_CLSID('W', '_', 'S', 'V', 'D', ' ', ' ', ' ') +#define CLSID_OBJECT_W_SVU MK_CLSID('W', '_', 'S', 'V', 'U', ' ', ' ', ' ') +#define CLSID_OBJECT_W_RPG7 MK_CLSID('W', '_', 'R', 'P', 'G', '7', ' ', ' ') +#define CLSID_OBJECT_W_VAL MK_CLSID('W', '_', 'V', 'A', 'L', ' ', ' ', ' ') +#define CLSID_OBJECT_W_VINTOREZ MK_CLSID('W', '_', 'V', 'I', 'N', 'T', ' ', ' ') +#define CLSID_OBJECT_W_WALTHER MK_CLSID('W', '_', 'W', 'A', 'L', 'T', 'H', 'R') +#define CLSID_OBJECT_W_USP45 MK_CLSID('W', '_', 'U', 'S', 'P', '4', '5', ' ') +#define CLSID_OBJECT_W_GROZA MK_CLSID('W', '_', 'G', 'R', 'O', 'Z', 'A', ' ') +#define CLSID_OBJECT_W_KNIFE MK_CLSID('W', '_', 'K', 'N', 'I', 'F', 'E', ' ') +#define CLSID_OBJECT_W_BM16 MK_CLSID('W', '_', 'B', 'M', '1', '6', ' ', ' ') +#define CLSID_OBJECT_W_RG6 MK_CLSID('W', '_', 'R', 'G', '6', ' ', ' ', ' ') + +#define CLSID_OBJECT_W_STATMGUN MK_CLSID('W', '_', 'S', 'T', 'M', 'G', 'U', 'N') // Weapons Ammo -#define CLSID_OBJECT_AMMO MK_CLSID('A','M','M','O',' ',' ',' ',' ') +#define CLSID_OBJECT_AMMO MK_CLSID('A', 'M', 'M', 'O', ' ', ' ', ' ', ' ') //----------------------------------------------------------------------------- -#define CLSID_OBJECT_A_VOG25 MK_CLSID('A','_','V','O','G','2','5',' ') -#define CLSID_OBJECT_A_OG7B MK_CLSID('A','_','O','G','7','B',' ',' ') -#define CLSID_OBJECT_A_M209 MK_CLSID('A','_','M','2','0','9',' ',' ') +#define CLSID_OBJECT_A_VOG25 MK_CLSID('A', '_', 'V', 'O', 'G', '2', '5', ' ') +#define CLSID_OBJECT_A_OG7B MK_CLSID('A', '_', 'O', 'G', '7', 'B', ' ', ' ') +#define CLSID_OBJECT_A_M209 MK_CLSID('A', '_', 'M', '2', '0', '9', ' ', ' ') //----------------------------------------------------------------------------- // Weapons Add-ons -#define CLSID_OBJECT_W_SCOPE MK_CLSID('W','_','S','C','O','P','E',' ') -#define CLSID_OBJECT_W_SILENCER MK_CLSID('W','_','S','I','L','E','N','C') -#define CLSID_OBJECT_W_GLAUNCHER MK_CLSID('W','_','G','L','A','U','N','C') +#define CLSID_OBJECT_W_SCOPE MK_CLSID('W', '_', 'S', 'C', 'O', 'P', 'E', ' ') +#define CLSID_OBJECT_W_SILENCER MK_CLSID('W', '_', 'S', 'I', 'L', 'E', 'N', 'C') +#define CLSID_OBJECT_W_GLAUNCHER MK_CLSID('W', '_', 'G', 'L', 'A', 'U', 'N', 'C') // Modifiers -#define CLSID_OBJECT_M_QDAMAGE MK_CLSID('O','_','Q','D','M','G',' ',' ') -#define CLSID_OBJECT_M_IMMORTAL MK_CLSID('O','_','I','M','M','O','R','T') -#define CLSID_OBJECT_M_INVIS MK_CLSID('O','_','I','N','V','I','S',' ') +#define CLSID_OBJECT_M_QDAMAGE MK_CLSID('O', '_', 'Q', 'D', 'M', 'G', ' ', ' ') +#define CLSID_OBJECT_M_IMMORTAL MK_CLSID('O', '_', 'I', 'M', 'M', 'O', 'R', 'T') +#define CLSID_OBJECT_M_INVIS MK_CLSID('O', '_', 'I', 'N', 'V', 'I', 'S', ' ') -#define CLSID_OBJECT_HEALTH MK_CLSID('O','_','H','E','A','L','T','H') -#define CLSID_OBJECT_ARMOR MK_CLSID('O','_','A','R','M','O','R',' ') +#define CLSID_OBJECT_HEALTH MK_CLSID('O', '_', 'H', 'E', 'A', 'L', 'T', 'H') +#define CLSID_OBJECT_ARMOR MK_CLSID('O', '_', 'A', 'R', 'M', 'O', 'R', ' ') -#define CLSID_OBJECT_TRIGGER MK_CLSID('O','_','T','R','I','G','E','R') +#define CLSID_OBJECT_TRIGGER MK_CLSID('O', '_', 'T', 'R', 'I', 'G', 'E', 'R') // Targets -#define CLSID_TARGET MK_CLSID('T','_','B','A','S','E',' ',' ') -#define CLSID_TARGET_ASSAULT MK_CLSID('T','_','A','S','S',' ',' ',' ') -#define CLSID_TARGET_CS_BASE MK_CLSID('T','_','C','S','B','A','S','E') -#define CLSID_TARGET_CS MK_CLSID('T','_','C','S',' ',' ',' ',' ') -#define CLSID_TARGET_CS_CASK MK_CLSID('T','_','C','S','C','A','S','K') +#define CLSID_TARGET MK_CLSID('T', '_', 'B', 'A', 'S', 'E', ' ', ' ') +#define CLSID_TARGET_ASSAULT MK_CLSID('T', '_', 'A', 'S', 'S', ' ', ' ', ' ') +#define CLSID_TARGET_CS_BASE MK_CLSID('T', '_', 'C', 'S', 'B', 'A', 'S', 'E') +#define CLSID_TARGET_CS MK_CLSID('T', '_', 'C', 'S', ' ', ' ', ' ', ' ') +#define CLSID_TARGET_CS_CASK MK_CLSID('T', '_', 'C', 'S', 'C', 'A', 'S', 'K') // Standard level object -#define CLSID_OBJECT_ITEM_STD MK_CLSID('O','_','I','T','E','M',' ',' ') -#define CLSID_OBJECT_BREAKABLE MK_CLSID('O','_','B','R','K','B','L',' ') -#define CLSID_OBJECT_CLIMABLE MK_CLSID('O','_','C','L','M','B','L',' ') +#define CLSID_OBJECT_ITEM_STD MK_CLSID('O', '_', 'I', 'T', 'E', 'M', ' ', ' ') +#define CLSID_OBJECT_BREAKABLE MK_CLSID('O', '_', 'B', 'R', 'K', 'B', 'L', ' ') +#define CLSID_OBJECT_CLIMABLE MK_CLSID('O', '_', 'C', 'L', 'M', 'B', 'L', ' ') // -#define CLSID_PH_SKELETON_OBJECT MK_CLSID('P','_','S','K','E','L','E','T') -#define CLSID_OBJECT_PHYSIC MK_CLSID('O','_','P','H','Y','S','I','C') -#define CLSID_PHYSICS_DESTROYABLE MK_CLSID('P','_','D','S','T','R','B','L') -#define CLSID_INVENTORY_BOX MK_CLSID('O','_','I','N','V','B','O','X') - -// Zones -#define CLSID_ZONE MK_CLSID('Z','_','Z','O','N','E',' ',' ') -#define CLSID_Z_MBALD MK_CLSID('Z','_','M','B','A','L','D',' ') -#define CLSID_Z_MINCER MK_CLSID('Z','_','M','I','N','C','E','R') -#define CLSID_Z_ACIDF MK_CLSID('Z','_','A','C','I','D','F',' ') -#define CLSID_Z_GALANT MK_CLSID('Z','_','G','A','L','A','N','T') -#define CLSID_Z_RADIO MK_CLSID('Z','_','R','A','D','I','O',' ') -#define CLSID_Z_BFUZZ MK_CLSID('Z','_','B','F','U','Z','Z',' ') -#define CLSID_Z_RUSTYH MK_CLSID('Z','_','R','U','S','T','Y','H') -#define CLSID_Z_AMEBA MK_CLSID('Z','_','A','M','E','B','A',' ') -#define CLSID_Z_NOGRAVITY MK_CLSID('Z','_','N','O','G','R','A','V') -#define CLSID_Z_FRYUP MK_CLSID('Z','_','F','R','Y','U','P ',' ') -#define CLSID_Z_DEAD MK_CLSID('Z','_','D','E','A','D',' ',' ') -#define CLSID_LEVEL_CHANGER MK_CLSID('L','V','L','C','H','N','G','R') -#define CLSID_SCRIPT_ZONE MK_CLSID('S','C','R','I','P','T','Z','N') -#define CLSID_Z_TEAM_BASE MK_CLSID('Z','_','T','E','A','M','B','S') -#define CLSID_Z_TORRID MK_CLSID('Z','_','T','O','R','R','I','D') -#define CLSID_SPACE_RESTRICTOR MK_CLSID('S','P','A','C','E','_','R','S') -#define CLSID_SMART_ZONE MK_CLSID('S','M','R','T','Z','O','N','E') -#define CLSID_Z_CAMPFIRE MK_CLSID('Z','_','C','F','I','R','E',' ') +#define CLSID_PH_SKELETON_OBJECT MK_CLSID('P', '_', 'S', 'K', 'E', 'L', 'E', 'T') +#define CLSID_OBJECT_PHYSIC MK_CLSID('O', '_', 'P', 'H', 'Y', 'S', 'I', 'C') +#define CLSID_PHYSICS_DESTROYABLE MK_CLSID('P', '_', 'D', 'S', 'T', 'R', 'B', 'L') +#define CLSID_INVENTORY_BOX MK_CLSID('O', '_', 'I', 'N', 'V', 'B', 'O', 'X') + +// Zones +#define CLSID_ZONE MK_CLSID('Z', '_', 'Z', 'O', 'N', 'E', ' ', ' ') +#define CLSID_Z_MBALD MK_CLSID('Z', '_', 'M', 'B', 'A', 'L', 'D', ' ') +#define CLSID_Z_MINCER MK_CLSID('Z', '_', 'M', 'I', 'N', 'C', 'E', 'R') +#define CLSID_Z_ACIDF MK_CLSID('Z', '_', 'A', 'C', 'I', 'D', 'F', ' ') +#define CLSID_Z_GALANT MK_CLSID('Z', '_', 'G', 'A', 'L', 'A', 'N', 'T') +#define CLSID_Z_RADIO MK_CLSID('Z', '_', 'R', 'A', 'D', 'I', 'O', ' ') +#define CLSID_Z_BFUZZ MK_CLSID('Z', '_', 'B', 'F', 'U', 'Z', 'Z', ' ') +#define CLSID_Z_RUSTYH MK_CLSID('Z', '_', 'R', 'U', 'S', 'T', 'Y', 'H') +#define CLSID_Z_AMEBA MK_CLSID('Z', '_', 'A', 'M', 'E', 'B', 'A', ' ') +#define CLSID_Z_NOGRAVITY MK_CLSID('Z', '_', 'N', 'O', 'G', 'R', 'A', 'V') +#define CLSID_Z_FRYUP MK_CLSID('Z', '_', 'F', 'R', 'Y', 'U', 'P ', ' ') +#define CLSID_Z_DEAD MK_CLSID('Z', '_', 'D', 'E', 'A', 'D', ' ', ' ') +#define CLSID_LEVEL_CHANGER MK_CLSID('L', 'V', 'L', 'C', 'H', 'N', 'G', 'R') +#define CLSID_SCRIPT_ZONE MK_CLSID('S', 'C', 'R', 'I', 'P', 'T', 'Z', 'N') +#define CLSID_Z_TEAM_BASE MK_CLSID('Z', '_', 'T', 'E', 'A', 'M', 'B', 'S') +#define CLSID_Z_TORRID MK_CLSID('Z', '_', 'T', 'O', 'R', 'R', 'I', 'D') +#define CLSID_SPACE_RESTRICTOR MK_CLSID('S', 'P', 'A', 'C', 'E', '_', 'R', 'S') +#define CLSID_SMART_ZONE MK_CLSID('S', 'M', 'R', 'T', 'Z', 'O', 'N', 'E') +#define CLSID_Z_CAMPFIRE MK_CLSID('Z', '_', 'C', 'F', 'I', 'R', 'E', ' ') // Detectors -#define CLSID_DETECTOR_SIMPLE MK_CLSID('D','_','S','I','M','D','E','T') -#define CLSID_DETECTOR_ADVANCED MK_CLSID('D','_','A','D','V','A','N','C') -#define CLSID_DETECTOR_ELITE MK_CLSID('D','_','E','L','I','T','E',' ') -#define CLSID_DETECTOR_SCIENTIFIC MK_CLSID('D','_','S','C','I','E','N','T') +#define CLSID_DETECTOR_SIMPLE MK_CLSID('D', '_', 'S', 'I', 'M', 'D', 'E', 'T') +#define CLSID_DETECTOR_ADVANCED MK_CLSID('D', '_', 'A', 'D', 'V', 'A', 'N', 'C') +#define CLSID_DETECTOR_ELITE MK_CLSID('D', '_', 'E', 'L', 'I', 'T', 'E', ' ') +#define CLSID_DETECTOR_SCIENTIFIC MK_CLSID('D', '_', 'S', 'C', 'I', 'E', 'N', 'T') // PDA -#define CLSID_DEVICE_PDA MK_CLSID('D','_','P','D','A',' ',' ',' ') +#define CLSID_DEVICE_PDA MK_CLSID('D', '_', 'P', 'D', 'A', ' ', ' ', ' ') // Devices -#define CLSID_DEVICE_TORCH MK_CLSID('D','_','T','O','R','C','H',' ') -#define CLSID_DEVICE_AF_MERGER MK_CLSID('D','_','A','F','M','E','R','G') -#define CLSID_DEVICE_FLARE MK_CLSID('D','_','F','L','A','R','E',' ') +#define CLSID_DEVICE_TORCH MK_CLSID('D', '_', 'T', 'O', 'R', 'C', 'H', ' ') +#define CLSID_DEVICE_AF_MERGER MK_CLSID('D', '_', 'A', 'F', 'M', 'E', 'R', 'G') +#define CLSID_DEVICE_FLARE MK_CLSID('D', '_', 'F', 'L', 'A', 'R', 'E', ' ') // Inventory items -#define CLSID_IITEM_BOLT MK_CLSID('I','I','_','B','O','L','T',' ') +#define CLSID_IITEM_BOLT MK_CLSID('I', 'I', '_', 'B', 'O', 'L', 'T', ' ') -#define CLSID_IITEM_MEDKIT MK_CLSID('I','I','_','M','E','D','K','I') -#define CLSID_IITEM_BANDAGE MK_CLSID('I','I','_','B','A','N','D','G') -#define CLSID_IITEM_FOOD MK_CLSID('I','I','_','F','O','O','D',' ') -#define CLSID_IITEM_BOTTLE MK_CLSID('I','I','_','B','O','T','T','L') -#define CLSID_IITEM_ANTIRAD MK_CLSID('I','I','_','A','N','T','I','R') -#define CLSID_IITEM_EXPLOSIVE MK_CLSID('I','I','_','E','X','P','L','O') +#define CLSID_IITEM_MEDKIT MK_CLSID('I', 'I', '_', 'M', 'E', 'D', 'K', 'I') +#define CLSID_IITEM_BANDAGE MK_CLSID('I', 'I', '_', 'B', 'A', 'N', 'D', 'G') +#define CLSID_IITEM_FOOD MK_CLSID('I', 'I', '_', 'F', 'O', 'O', 'D', ' ') +#define CLSID_IITEM_BOTTLE MK_CLSID('I', 'I', '_', 'B', 'O', 'T', 'T', 'L') +#define CLSID_IITEM_ANTIRAD MK_CLSID('I', 'I', '_', 'A', 'N', 'T', 'I', 'R') +#define CLSID_IITEM_EXPLOSIVE MK_CLSID('I', 'I', '_', 'E', 'X', 'P', 'L', 'O') // Info Document -#define CLSID_IITEM_DOCUMENT MK_CLSID('I','I','_','D','O','C',' ',' ') - -#define CLSID_IITEM_ATTACH MK_CLSID('I','I','_','A','T','T','C','H') +#define CLSID_IITEM_DOCUMENT MK_CLSID('I', 'I', '_', 'D', 'O', 'C', ' ', ' ') +#define CLSID_IITEM_ATTACH MK_CLSID('I', 'I', '_', 'A', 'T', 'T', 'C', 'H') // Grenades -#define CLSID_GRENADE_F1 MK_CLSID('G','_','F','1',' ',' ',' ',' ') -#define CLSID_OBJECT_G_RPG7 MK_CLSID('G','_','R','P','G','7',' ',' ') -#define CLSID_GRENADE_RGD5 MK_CLSID('G','_','R','G','D','5',' ',' ') -#define CLSID_OBJECT_G_FAKE MK_CLSID('G','_','F','A','K','E',' ',' ') +#define CLSID_GRENADE_F1 MK_CLSID('G', '_', 'F', '1', ' ', ' ', ' ', ' ') +#define CLSID_OBJECT_G_RPG7 MK_CLSID('G', '_', 'R', 'P', 'G', '7', ' ', ' ') +#define CLSID_GRENADE_RGD5 MK_CLSID('G', '_', 'R', 'G', 'D', '5', ' ', ' ') +#define CLSID_OBJECT_G_FAKE MK_CLSID('G', '_', 'F', 'A', 'K', 'E', ' ', ' ') //--------------------------------------------------------------------------------- -#define CLSID_OBJECT_PLAYERS_BAG MK_CLSID('M','P','_','P','L','B','A','G') +#define CLSID_OBJECT_PLAYERS_BAG MK_CLSID('M', 'P', '_', 'P', 'L', 'B', 'A', 'G') //--------------------------------------------------------------------------------- // Equipment -#define CLSID_EQUIPMENT_SIMPLE MK_CLSID('E','Q','U','_','S','M','P','L') -#define CLSID_EQUIPMENT_SCIENTIFIC MK_CLSID('E','Q','U','_','S','C','I','E') -#define CLSID_EQUIPMENT_STALKER MK_CLSID('E','Q','U','_','S','T','L','K') -#define CLSID_EQUIPMENT_MILITARY MK_CLSID('E','Q','U','_','M','L','T','R') -#define CLSID_EQUIPMENT_EXO MK_CLSID('E','Q','U','_','E','X','O',' ') -#define CLSID_EQUIPMENT_HELMET MK_CLSID('E','Q','_','H','L','M','E','T') +#define CLSID_EQUIPMENT_SIMPLE MK_CLSID('E', 'Q', 'U', '_', 'S', 'M', 'P', 'L') +#define CLSID_EQUIPMENT_SCIENTIFIC MK_CLSID('E', 'Q', 'U', '_', 'S', 'C', 'I', 'E') +#define CLSID_EQUIPMENT_STALKER MK_CLSID('E', 'Q', 'U', '_', 'S', 'T', 'L', 'K') +#define CLSID_EQUIPMENT_MILITARY MK_CLSID('E', 'Q', 'U', '_', 'M', 'L', 'T', 'R') +#define CLSID_EQUIPMENT_EXO MK_CLSID('E', 'Q', 'U', '_', 'E', 'X', 'O', ' ') +#define CLSID_EQUIPMENT_HELMET MK_CLSID('E', 'Q', '_', 'H', 'L', 'M', 'E', 'T') // Game types -#define CLSID_SV_GAME_SINGLE MK_CLSID('S','V','_','S','I','N','G','L') -#define CLSID_SV_GAME_DEATHMATCH MK_CLSID('S','V','_','D','M',' ',' ',' ') -#define CLSID_SV_GAME_TEAMDEATHMATCH MK_CLSID('S','V','_','T','D','M',' ',' ') -#define CLSID_SV_GAME_ARTEFACTHUNT MK_CLSID('S','V','_','A','H','U','N','T') -#define CLSID_SV_GAME_CAPTURETHEARTEFACT MK_CLSID('S','V','_','C','T','A',' ',' ') +#define CLSID_SV_GAME_SINGLE MK_CLSID('S', 'V', '_', 'S', 'I', 'N', 'G', 'L') +#define CLSID_SV_GAME_DEATHMATCH MK_CLSID('S', 'V', '_', 'D', 'M', ' ', ' ', ' ') +#define CLSID_SV_GAME_TEAMDEATHMATCH MK_CLSID('S', 'V', '_', 'T', 'D', 'M', ' ', ' ') +#define CLSID_SV_GAME_ARTEFACTHUNT MK_CLSID('S', 'V', '_', 'A', 'H', 'U', 'N', 'T') +#define CLSID_SV_GAME_CAPTURETHEARTEFACT MK_CLSID('S', 'V', '_', 'C', 'T', 'A', ' ', ' ') //#define CLSID_GAME_CS MK_CLSID('S','V','_','C','S',' ',' ',' ') -#define CLSID_CL_GAME_SINGLE MK_CLSID('C','L','_','S','I','N','G','L') -#define CLSID_CL_GAME_DEATHMATCH MK_CLSID('C','L','_','D','M',' ',' ',' ') -#define CLSID_CL_GAME_TEAMDEATHMATCH MK_CLSID('C','L','_','T','D','M',' ',' ') -#define CLSID_CL_GAME_ARTEFACTHUNT MK_CLSID('C','L','_','A','H','U','N','T') -#define CLSID_CL_GAME_CAPTURETHEARTEFACT MK_CLSID('C','L','_','C','T','A',' ',' ') +#define CLSID_CL_GAME_SINGLE MK_CLSID('C', 'L', '_', 'S', 'I', 'N', 'G', 'L') +#define CLSID_CL_GAME_DEATHMATCH MK_CLSID('C', 'L', '_', 'D', 'M', ' ', ' ', ' ') +#define CLSID_CL_GAME_TEAMDEATHMATCH MK_CLSID('C', 'L', '_', 'T', 'D', 'M', ' ', ' ') +#define CLSID_CL_GAME_ARTEFACTHUNT MK_CLSID('C', 'L', '_', 'A', 'H', 'U', 'N', 'T') +#define CLSID_CL_GAME_CAPTURETHEARTEFACT MK_CLSID('C', 'L', '_', 'C', 'T', 'A', ' ', ' ') // Game UI types -#define CLSID_GAME_UI_SINGLE MK_CLSID('U','I','_','S','I','N','G','L') -#define CLSID_GAME_UI_DEATHMATCH MK_CLSID('U','I','_','D','M',' ',' ',' ') -#define CLSID_GAME_UI_TEAMDEATHMATCH MK_CLSID('U','I','_','T','D','M',' ',' ') -#define CLSID_GAME_UI_ARTEFACTHUNT MK_CLSID('U','I','_','A','H','U','N','T') -#define CLSID_GAME_UI_CAPTURETHEARTEFACT MK_CLSID('U','I','_','C','T','A',' ',' ') +#define CLSID_GAME_UI_SINGLE MK_CLSID('U', 'I', '_', 'S', 'I', 'N', 'G', 'L') +#define CLSID_GAME_UI_DEATHMATCH MK_CLSID('U', 'I', '_', 'D', 'M', ' ', ' ', ' ') +#define CLSID_GAME_UI_TEAMDEATHMATCH MK_CLSID('U', 'I', '_', 'T', 'D', 'M', ' ', ' ') +#define CLSID_GAME_UI_ARTEFACTHUNT MK_CLSID('U', 'I', '_', 'A', 'H', 'U', 'N', 'T') +#define CLSID_GAME_UI_CAPTURETHEARTEFACT MK_CLSID('U', 'I', '_', 'C', 'T', 'A', ' ', ' ') -#define CLSID_ONLINE_OFFLINE_GROUP MK_CLSID('O','N','_','O','F','F','_','G') +#define CLSID_ONLINE_OFFLINE_GROUP MK_CLSID('O', 'N', '_', 'O', 'F', 'F', '_', 'G') diff --git a/src/xrServerEntities/doug_lea_memory_allocator.c b/src/xrServerEntities/doug_lea_memory_allocator.c index fe02da2e54f..3dc9d5ff5a6 100644 --- a/src/xrServerEntities/doug_lea_memory_allocator.c +++ b/src/xrServerEntities/doug_lea_memory_allocator.c @@ -363,9 +363,9 @@ MALLINFO_FIELD_TYPE default: size_t size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set REALLOC_ZERO_BYTES_FREES default: not defined - This should be set if a call to realloc with zero bytes should - be the same as a call to free. Some people think it should. Otherwise, - since this malloc returns a unique pointer for malloc(0), so does + This should be set if a call to realloc with zero bytes should + be the same as a call to free. Some people think it should. Otherwise, + since this malloc returns a unique pointer for malloc(0), so does realloc(p, 0). LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H @@ -438,14 +438,14 @@ DEFAULT_MMAP_THRESHOLD default: 256K */ #ifdef DEBUG -# undef DEBUG -#endif // DEBUG +#undef DEBUG +#endif // DEBUG #ifndef WIN32 #ifdef _WIN32 #define WIN32 1 -#endif /* _WIN32 */ -#endif /* WIN32 */ +#endif /* _WIN32 */ +#endif /* WIN32 */ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -460,120 +460,120 @@ DEFAULT_MMAP_THRESHOLD default: 256K #define LACKS_ERRNO_H #define MALLOC_FAILURE_ACTION #define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */ -#endif /* WIN32 */ +#endif /* WIN32 */ #if defined(DARWIN) || defined(_DARWIN) /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ #ifndef HAVE_MORECORE #define HAVE_MORECORE 0 #define HAVE_MMAP 1 -#endif /* HAVE_MORECORE */ -#endif /* DARWIN */ +#endif /* HAVE_MORECORE */ +#endif /* DARWIN */ #ifndef LACKS_SYS_TYPES_H -#include /* For size_t */ -#endif /* LACKS_SYS_TYPES_H */ +#include /* For size_t */ +#endif /* LACKS_SYS_TYPES_H */ /* The maximum possible size_t value has all bits set */ -#define MAX_SIZE_T (~(size_t)0) +#define MAX_SIZE_T (~(size_t)0) #ifndef ONLY_MSPACES #define ONLY_MSPACES 0 -#endif /* ONLY_MSPACES */ +#endif /* ONLY_MSPACES */ #ifndef MSPACES #if ONLY_MSPACES #define MSPACES 1 -#else /* ONLY_MSPACES */ +#else /* ONLY_MSPACES */ #define MSPACES 0 -#endif /* ONLY_MSPACES */ -#endif /* MSPACES */ +#endif /* ONLY_MSPACES */ +#endif /* MSPACES */ #ifndef MALLOC_ALIGNMENT #define MALLOC_ALIGNMENT ((size_t)8U) -#endif /* MALLOC_ALIGNMENT */ +#endif /* MALLOC_ALIGNMENT */ #ifndef FOOTERS #define FOOTERS 0 -#endif /* FOOTERS */ +#endif /* FOOTERS */ #ifndef ABORT -#define ABORT abort() -#endif /* ABORT */ +#define ABORT abort() +#endif /* ABORT */ #ifndef ABORT_ON_ASSERT_FAILURE #define ABORT_ON_ASSERT_FAILURE 1 -#endif /* ABORT_ON_ASSERT_FAILURE */ +#endif /* ABORT_ON_ASSERT_FAILURE */ #ifndef PROCEED_ON_ERROR #define PROCEED_ON_ERROR 0 -#endif /* PROCEED_ON_ERROR */ +#endif /* PROCEED_ON_ERROR */ #ifndef USE_LOCKS #define USE_LOCKS 0 -#endif /* USE_LOCKS */ +#endif /* USE_LOCKS */ #ifndef INSECURE #define INSECURE 0 -#endif /* INSECURE */ +#endif /* INSECURE */ #ifndef HAVE_MMAP #define HAVE_MMAP 1 -#endif /* HAVE_MMAP */ +#endif /* HAVE_MMAP */ #ifndef MMAP_CLEARS #define MMAP_CLEARS 1 -#endif /* MMAP_CLEARS */ +#endif /* MMAP_CLEARS */ #ifndef HAVE_MREMAP #ifdef linux #define HAVE_MREMAP 1 -#else /* linux */ +#else /* linux */ #define HAVE_MREMAP 0 -#endif /* linux */ -#endif /* HAVE_MREMAP */ +#endif /* linux */ +#endif /* HAVE_MREMAP */ #ifndef MALLOC_FAILURE_ACTION -#define MALLOC_FAILURE_ACTION errno = ENOMEM; -#endif /* MALLOC_FAILURE_ACTION */ +#define MALLOC_FAILURE_ACTION errno = ENOMEM; +#endif /* MALLOC_FAILURE_ACTION */ #ifndef HAVE_MORECORE #if ONLY_MSPACES #define HAVE_MORECORE 0 -#else /* ONLY_MSPACES */ +#else /* ONLY_MSPACES */ #define HAVE_MORECORE 1 -#endif /* ONLY_MSPACES */ -#endif /* HAVE_MORECORE */ +#endif /* ONLY_MSPACES */ +#endif /* HAVE_MORECORE */ #if !HAVE_MORECORE #define MORECORE_CONTIGUOUS 0 -#else /* !HAVE_MORECORE */ +#else /* !HAVE_MORECORE */ #ifndef MORECORE #define MORECORE sbrk -#endif /* MORECORE */ +#endif /* MORECORE */ #ifndef MORECORE_CONTIGUOUS #define MORECORE_CONTIGUOUS 1 -#endif /* MORECORE_CONTIGUOUS */ -#endif /* HAVE_MORECORE */ +#endif /* MORECORE_CONTIGUOUS */ +#endif /* HAVE_MORECORE */ #ifndef DEFAULT_GRANULARITY #if MORECORE_CONTIGUOUS -#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ -#else /* MORECORE_CONTIGUOUS */ +#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ +#else /* MORECORE_CONTIGUOUS */ #define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) -#endif /* MORECORE_CONTIGUOUS */ -#endif /* DEFAULT_GRANULARITY */ +#endif /* MORECORE_CONTIGUOUS */ +#endif /* DEFAULT_GRANULARITY */ #ifndef DEFAULT_TRIM_THRESHOLD #ifndef MORECORE_CANNOT_TRIM #define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) -#else /* MORECORE_CANNOT_TRIM */ +#else /* MORECORE_CANNOT_TRIM */ #define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T -#endif /* MORECORE_CANNOT_TRIM */ -#endif /* DEFAULT_TRIM_THRESHOLD */ +#endif /* MORECORE_CANNOT_TRIM */ +#endif /* DEFAULT_TRIM_THRESHOLD */ #ifndef DEFAULT_MMAP_THRESHOLD #if HAVE_MMAP #define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) -#else /* HAVE_MMAP */ +#else /* HAVE_MMAP */ #define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T -#endif /* HAVE_MMAP */ -#endif /* DEFAULT_MMAP_THRESHOLD */ +#endif /* HAVE_MMAP */ +#endif /* DEFAULT_MMAP_THRESHOLD */ #ifndef USE_BUILTIN_FFS #define USE_BUILTIN_FFS 0 -#endif /* USE_BUILTIN_FFS */ +#endif /* USE_BUILTIN_FFS */ #ifndef USE_DEV_RANDOM #define USE_DEV_RANDOM 0 -#endif /* USE_DEV_RANDOM */ +#endif /* USE_DEV_RANDOM */ #ifndef NO_MALLINFO #define NO_MALLINFO 0 -#endif /* NO_MALLINFO */ +#endif /* NO_MALLINFO */ #ifndef MALLINFO_FIELD_TYPE #define MALLINFO_FIELD_TYPE size_t -#endif /* MALLINFO_FIELD_TYPE */ +#endif /* MALLINFO_FIELD_TYPE */ /* mallopt tuning options. SVID/XPG defines four standard parameter @@ -582,9 +582,9 @@ DEFAULT_MMAP_THRESHOLD default: 256K malloc does support the following options. */ -#define M_TRIM_THRESHOLD (-1) -#define M_GRANULARITY (-2) -#define M_MMAP_THRESHOLD (-3) +#define M_TRIM_THRESHOLD (-1) +#define M_GRANULARITY (-2) +#define M_MMAP_THRESHOLD (-3) /* ------------------------ Mallinfo declarations ------------------------ */ @@ -617,17 +617,18 @@ DEFAULT_MMAP_THRESHOLD default: 256K #include "doug_lea_memory_allocator.h" #else /* HAVE_USR_INCLUDE_MALLOC_H */ -struct mallinfo { - MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ - MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ - MALLINFO_FIELD_TYPE smblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ - MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ - MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ - MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ - MALLINFO_FIELD_TYPE fordblks; /* total free space */ - MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ +struct mallinfo +{ + MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ + MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ + MALLINFO_FIELD_TYPE smblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ + MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ + MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ + MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ + MALLINFO_FIELD_TYPE fordblks; /* total free space */ + MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ }; #endif /* HAVE_USR_INCLUDE_MALLOC_H */ @@ -642,25 +643,24 @@ extern "C" { /* ------------------- Declarations of public routines ------------------- */ #ifndef USE_DL_PREFIX -#define dlcalloc calloc -#define dlfree free -#define dlmalloc malloc -#define dlmemalign memalign -#define dlrealloc realloc -#define dlvalloc valloc -#define dlpvalloc pvalloc -#define dlmallinfo mallinfo -#define dlmallopt mallopt -#define dlmalloc_trim malloc_trim -#define dlmalloc_stats malloc_stats -#define dlmalloc_usable_size malloc_usable_size -#define dlmalloc_footprint malloc_footprint +#define dlcalloc calloc +#define dlfree free +#define dlmalloc malloc +#define dlmemalign memalign +#define dlrealloc realloc +#define dlvalloc valloc +#define dlpvalloc pvalloc +#define dlmallinfo mallinfo +#define dlmallopt mallopt +#define dlmalloc_trim malloc_trim +#define dlmalloc_stats malloc_stats +#define dlmalloc_usable_size malloc_usable_size +#define dlmalloc_footprint malloc_footprint #define dlmalloc_max_footprint malloc_max_footprint -#define dlindependent_calloc independent_calloc +#define dlindependent_calloc independent_calloc #define dlindependent_comalloc independent_comalloc #endif /* USE_DL_PREFIX */ - /* malloc(size_t n) Returns a pointer to a newly allocated chunk of at least n bytes, or @@ -684,7 +684,7 @@ void* dlmalloc(size_t); It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cause the current program to abort. */ -void dlfree(void*); +void dlfree(void*); /* calloc(size_t n_elements, size_t element_size); @@ -924,13 +924,12 @@ void** dlindependent_calloc(size_t, size_t, void**); */ void** dlindependent_comalloc(size_t, size_t*, void**); - /* pvalloc(size_t n); Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize. */ -void* dlpvalloc(size_t); +void* dlpvalloc(size_t); /* malloc_trim(size_t pad); @@ -953,7 +952,7 @@ void* dlpvalloc(size_t); Malloc_trim returns 1 if it actually released any memory, else 0. */ -int dlmalloc_trim(size_t); +int dlmalloc_trim(size_t); /* malloc_usable_size(void* p); @@ -990,7 +989,7 @@ size_t dlmalloc_usable_size(void*); malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo. */ -void dlmalloc_stats(void); +void dlmalloc_stats(void); #endif /* ONLY_MSPACES */ @@ -1077,15 +1076,13 @@ void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); mspace_independent_calloc behaves as independent_calloc, but operates within the given space. */ -void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]); +void** mspace_independent_calloc(mspace msp, size_t n_elements, size_t elem_size, void* chunks[]); /* mspace_independent_comalloc behaves as independent_comalloc, but operates within the given space. */ -void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]); +void** mspace_independent_comalloc(mspace msp, size_t n_elements, size_t sizes[], void* chunks[]); /* mspace_footprint() returns the number of bytes obtained from the @@ -1099,7 +1096,6 @@ size_t mspace_footprint(mspace msp); */ size_t mspace_max_footprint(mspace msp); - #if !NO_MALLINFO /* mspace_mallinfo behaves as mallinfo, but reports properties of @@ -1128,7 +1124,7 @@ int mspace_mallopt(int, int); #endif /* MSPACES */ #ifdef __cplusplus -}; /* end of extern "C" */ +}; /* end of extern "C" */ #endif /* __cplusplus */ /* @@ -1144,23 +1140,24 @@ int mspace_mallopt(int, int); /*------------------------------ internal #includes ---------------------- */ #ifdef WIN32 -#pragma warning( disable : 4146 ) /* no "unsigned" warnings */ -#endif /* WIN32 */ +#pragma warning(disable : 4146) /* no "unsigned" warnings */ +#endif /* WIN32 */ -#include /* for printing in malloc_stats */ +#include /* for printing in malloc_stats */ #ifndef LACKS_ERRNO_H -#include /* for MALLOC_FAILURE_ACTION */ -#endif /* LACKS_ERRNO_H */ +#include /* for MALLOC_FAILURE_ACTION */ +#endif /* LACKS_ERRNO_H */ #if FOOTERS -#include /* for magic initialization */ -#endif /* FOOTERS */ +#include /* for magic initialization */ +#endif /* FOOTERS */ #ifndef LACKS_STDLIB_H -#include /* for abort() */ -#endif /* LACKS_STDLIB_H */ +#include /* for abort() */ +#endif /* LACKS_STDLIB_H */ #ifdef DEBUG #if ABORT_ON_ASSERT_FAILURE -#define assert(x) if(!(x)) ABORT +#define assert(x) \ + if (!(x)) ABORT #else /* ABORT_ON_ASSERT_FAILURE */ #include #endif /* ABORT_ON_ASSERT_FAILURE */ @@ -1168,104 +1165,104 @@ int mspace_mallopt(int, int); #define assert(x) #endif /* DEBUG */ #ifndef LACKS_STRING_H -#include /* for memset etc */ -#endif /* LACKS_STRING_H */ +#include /* for memset etc */ +#endif /* LACKS_STRING_H */ #if USE_BUILTIN_FFS #ifndef LACKS_STRINGS_H -#include /* for ffs */ -#endif /* LACKS_STRINGS_H */ -#endif /* USE_BUILTIN_FFS */ +#include /* for ffs */ +#endif /* LACKS_STRINGS_H */ +#endif /* USE_BUILTIN_FFS */ #if HAVE_MMAP #ifndef LACKS_SYS_MMAN_H -#include /* for mmap */ -#endif /* LACKS_SYS_MMAN_H */ +#include /* for mmap */ +#endif /* LACKS_SYS_MMAN_H */ #ifndef LACKS_FCNTL_H #include #endif /* LACKS_FCNTL_H */ #endif /* HAVE_MMAP */ #if HAVE_MORECORE #ifndef LACKS_UNISTD_H -#include /* for sbrk */ -#else /* LACKS_UNISTD_H */ +#include /* for sbrk */ +#else /* LACKS_UNISTD_H */ #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void* sbrk(ptrdiff_t); +extern void* sbrk(ptrdiff_t); #endif /* FreeBSD etc */ #endif /* LACKS_UNISTD_H */ #endif /* HAVE_MMAP */ #ifndef WIN32 #ifndef malloc_getpagesize -# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ -# ifndef _SC_PAGE_SIZE -# define _SC_PAGE_SIZE _SC_PAGESIZE -# endif -# endif -# ifdef _SC_PAGE_SIZE -# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) -# else -# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) - extern size_t getpagesize(); -# define malloc_getpagesize getpagesize() -# else -# ifdef WIN32 /* use supplied emulation of getpagesize */ -# define malloc_getpagesize getpagesize() -# else -# ifndef LACKS_SYS_PARAM_H -# include -# endif -# ifdef EXEC_PAGESIZE -# define malloc_getpagesize EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define malloc_getpagesize NBPG -# else -# define malloc_getpagesize (NBPG * CLSIZE) -# endif -# else -# ifdef NBPC -# define malloc_getpagesize NBPC -# else -# ifdef PAGESIZE -# define malloc_getpagesize PAGESIZE -# else /* just guess */ -# define malloc_getpagesize ((size_t)4096U) -# endif -# endif -# endif -# endif -# endif -# endif -# endif +#ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ +#ifndef _SC_PAGE_SIZE +#define _SC_PAGE_SIZE _SC_PAGESIZE +#endif +#endif +#ifdef _SC_PAGE_SIZE +#define malloc_getpagesize sysconf(_SC_PAGE_SIZE) +#else +#if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) +extern size_t getpagesize(); +#define malloc_getpagesize getpagesize() +#else +#ifdef WIN32 /* use supplied emulation of getpagesize */ +#define malloc_getpagesize getpagesize() +#else +#ifndef LACKS_SYS_PARAM_H +#include +#endif +#ifdef EXEC_PAGESIZE +#define malloc_getpagesize EXEC_PAGESIZE +#else +#ifdef NBPG +#ifndef CLSIZE +#define malloc_getpagesize NBPG +#else +#define malloc_getpagesize (NBPG * CLSIZE) +#endif +#else +#ifdef NBPC +#define malloc_getpagesize NBPC +#else +#ifdef PAGESIZE +#define malloc_getpagesize PAGESIZE +#else /* just guess */ +#define malloc_getpagesize ((size_t)4096U) +#endif +#endif +#endif +#endif +#endif +#endif +#endif #endif #endif /* ------------------- size_t and alignment properties -------------------- */ /* The byte and bit size of a size_t */ -#define SIZE_T_SIZE (sizeof(size_t)) -#define SIZE_T_BITSIZE (sizeof(size_t) << 3) +#define SIZE_T_SIZE (sizeof(size_t)) +#define SIZE_T_BITSIZE (sizeof(size_t) << 3) /* Some constants coerced to size_t */ /* Annoying but necessary to avoid errors on some plaftorms */ -#define SIZE_T_ZERO ((size_t)0) -#define SIZE_T_ONE ((size_t)1) -#define SIZE_T_TWO ((size_t)2) -#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) -#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) -#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) -#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) +#define SIZE_T_ZERO ((size_t)0) +#define SIZE_T_ONE ((size_t)1) +#define SIZE_T_TWO ((size_t)2) +#define TWO_SIZE_T_SIZES (SIZE_T_SIZE << 1) +#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE << 2) +#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES + TWO_SIZE_T_SIZES) +#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) /* The bit mask value corresponding to MALLOC_ALIGNMENT */ -#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) +#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) /* True if address a has acceptable alignment */ -#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) +#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) /* the number of bytes to offset an address to align it */ -#define align_offset(A)\ - ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ - ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) +#define align_offset(A) \ + ((((size_t)(A)&CHUNK_ALIGN_MASK) == 0) ? 0 : \ + ((MALLOC_ALIGNMENT - ((size_t)(A)&CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) /* -------------------------- MMAP preliminaries ------------------------- */ @@ -1275,102 +1272,101 @@ extern void* sbrk(ptrdiff_t); using so many "#if"s. */ - /* MORECORE and MMAP must return MFAIL on failure */ -#define MFAIL ((void*)(MAX_SIZE_T)) -#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ +#define MFAIL ((void*)(MAX_SIZE_T)) +#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ #if !HAVE_MMAP -#define IS_MMAPPED_BIT (SIZE_T_ZERO) -#define USE_MMAP_BIT (SIZE_T_ZERO) -#define CALL_MMAP(s) MFAIL -#define CALL_MUNMAP(a, s) (-1) -#define DIRECT_MMAP(s) MFAIL +#define IS_MMAPPED_BIT (SIZE_T_ZERO) +#define USE_MMAP_BIT (SIZE_T_ZERO) +#define CALL_MMAP(s) MFAIL +#define CALL_MUNMAP(a, s) (-1) +#define DIRECT_MMAP(s) MFAIL #else /* HAVE_MMAP */ -#define IS_MMAPPED_BIT (SIZE_T_ONE) -#define USE_MMAP_BIT (SIZE_T_ONE) +#define IS_MMAPPED_BIT (SIZE_T_ONE) +#define USE_MMAP_BIT (SIZE_T_ONE) #ifndef WIN32 -#define CALL_MUNMAP(a, s) munmap((a), (s)) -#define MMAP_PROT (PROT_READ|PROT_WRITE) +#define CALL_MUNMAP(a, s) munmap((a), (s)) +#define MMAP_PROT (PROT_READ | PROT_WRITE) #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -#define MAP_ANONYMOUS MAP_ANON +#define MAP_ANONYMOUS MAP_ANON #endif /* MAP_ANON */ #ifdef MAP_ANONYMOUS -#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) -#define CALL_MMAP(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0) +#define MMAP_FLAGS (MAP_PRIVATE | MAP_ANONYMOUS) +#define CALL_MMAP(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0) #else /* MAP_ANONYMOUS */ /* Nearly all versions of mmap support MAP_ANONYMOUS, so the following is unlikely to be needed, but is supplied just in case. */ -#define MMAP_FLAGS (MAP_PRIVATE) +#define MMAP_FLAGS (MAP_PRIVATE) static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ -#define CALL_MMAP(s) ((dev_zero_fd < 0) ? \ - (dev_zero_fd = open("/dev/zero", O_RDWR), \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ +#define CALL_MMAP(s) \ + ((dev_zero_fd < 0) ? \ + (dev_zero_fd = open("/dev/zero", O_RDWR), mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) #endif /* MAP_ANONYMOUS */ -#define DIRECT_MMAP(s) CALL_MMAP(s) +#define DIRECT_MMAP(s) CALL_MMAP(s) #else /* WIN32 */ /* Win32 MMAP via VirtualAlloc */ -static void* win32mmap(size_t size) { - void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); - return (ptr != 0)? ptr: MFAIL; +static void* win32mmap(size_t size) +{ + void* ptr = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + return (ptr != 0) ? ptr : MFAIL; } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ -static void* win32direct_mmap(size_t size) { - void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, - PAGE_READWRITE); - return (ptr != 0)? ptr: MFAIL; +static void* win32direct_mmap(size_t size) +{ + void* ptr = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE); + return (ptr != 0) ? ptr : MFAIL; } /* This function supports releasing coalesed segments */ -static int win32munmap(void* ptr, size_t size) { - MEMORY_BASIC_INFORMATION minfo; - char* cptr = ptr; - while (size) { - if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) - return -1; - if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || - minfo.State != MEM_COMMIT || minfo.RegionSize > size) - return -1; - if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) - return -1; - cptr += minfo.RegionSize; - size -= minfo.RegionSize; - } - return 0; +static int win32munmap(void* ptr, size_t size) +{ + MEMORY_BASIC_INFORMATION minfo; + char* cptr = ptr; + while (size) + { + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) return -1; + if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || minfo.State != MEM_COMMIT || + minfo.RegionSize > size) + return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) return -1; + cptr += minfo.RegionSize; + size -= minfo.RegionSize; + } + return 0; } -#define CALL_MMAP(s) win32mmap(s) -#define CALL_MUNMAP(a, s) win32munmap((a), (s)) -#define DIRECT_MMAP(s) win32direct_mmap(s) +#define CALL_MMAP(s) win32mmap(s) +#define CALL_MUNMAP(a, s) win32munmap((a), (s)) +#define DIRECT_MMAP(s) win32direct_mmap(s) #endif /* WIN32 */ #endif /* HAVE_MMAP */ #if HAVE_MMAP && HAVE_MREMAP #define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv)) -#else /* HAVE_MMAP && HAVE_MREMAP */ +#else /* HAVE_MMAP && HAVE_MREMAP */ #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL #endif /* HAVE_MMAP && HAVE_MREMAP */ #if HAVE_MORECORE -#define CALL_MORECORE(S) MORECORE(S) -#else /* HAVE_MORECORE */ -#define CALL_MORECORE(S) MFAIL +#define CALL_MORECORE(S) MORECORE(S) +#else /* HAVE_MORECORE */ +#define CALL_MORECORE(S) MFAIL #endif /* HAVE_MORECORE */ /* mstate bit set if continguous morecore disabled or failed */ #define USE_NONCONTIGUOUS_BIT (4U) /* segment bit set in create_mspace_with_base */ -#define EXTERN_BIT (8U) - +#define EXTERN_BIT (8U) /* --------------------------- Lock preliminaries ------------------------ */ @@ -1394,9 +1390,9 @@ static int win32munmap(void* ptr, size_t size) { /* By default use posix locks */ #include #define MLOCK_T pthread_mutex_t -#define INITIAL_LOCK(l) pthread_mutex_init(l, NULL) -#define ACQUIRE_LOCK(l) pthread_mutex_lock(l) -#define RELEASE_LOCK(l) pthread_mutex_unlock(l) +#define INITIAL_LOCK(l) pthread_mutex_init(l, NULL) +#define ACQUIRE_LOCK(l) pthread_mutex_lock(l) +#define RELEASE_LOCK(l) pthread_mutex_unlock(l) #if HAVE_MORECORE static MLOCK_T morecore_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -1411,55 +1407,55 @@ static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER; */ #define MLOCK_T long -static int win32_acquire_lock (MLOCK_T *sl) { - for (;;) { +static int win32_acquire_lock(MLOCK_T* sl) +{ + for (;;) + { #ifdef InterlockedCompareExchangePointer - if (!InterlockedCompareExchange(sl, 1, 0)) - return 0; -#else /* Use older void* version */ - if (!InterlockedCompareExchange((void**)sl, (void*)1, (void*)0)) - return 0; + if (!InterlockedCompareExchange(sl, 1, 0)) return 0; +#else /* Use older void* version */ + if (!InterlockedCompareExchange((void**)sl, (void*)1, (void*)0)) return 0; #endif /* InterlockedCompareExchangePointer */ - Sleep (0); - } + Sleep(0); + } } -static void win32_release_lock (MLOCK_T *sl) { - InterlockedExchange (sl, 0); +static void win32_release_lock(MLOCK_T* sl) +{ + InterlockedExchange(sl, 0); } -#define INITIAL_LOCK(l) *(l)=0 -#define ACQUIRE_LOCK(l) win32_acquire_lock(l) -#define RELEASE_LOCK(l) win32_release_lock(l) +#define INITIAL_LOCK(l) *(l) = 0 +#define ACQUIRE_LOCK(l) win32_acquire_lock(l) +#define RELEASE_LOCK(l) win32_release_lock(l) #if HAVE_MORECORE static MLOCK_T morecore_mutex; #endif /* HAVE_MORECORE */ static MLOCK_T magic_init_mutex; #endif /* WIN32 */ -#define USE_LOCK_BIT (2U) -#else /* USE_LOCKS */ -#define USE_LOCK_BIT (0U) +#define USE_LOCK_BIT (2U) +#else /* USE_LOCKS */ +#define USE_LOCK_BIT (0U) #define INITIAL_LOCK(l) #endif /* USE_LOCKS */ #if USE_LOCKS && HAVE_MORECORE -#define ACQUIRE_MORECORE_LOCK() ACQUIRE_LOCK(&morecore_mutex); -#define RELEASE_MORECORE_LOCK() RELEASE_LOCK(&morecore_mutex); +#define ACQUIRE_MORECORE_LOCK() ACQUIRE_LOCK(&morecore_mutex); +#define RELEASE_MORECORE_LOCK() RELEASE_LOCK(&morecore_mutex); #else /* USE_LOCKS && HAVE_MORECORE */ #define ACQUIRE_MORECORE_LOCK() #define RELEASE_MORECORE_LOCK() #endif /* USE_LOCKS && HAVE_MORECORE */ #if USE_LOCKS -#define ACQUIRE_MAGIC_INIT_LOCK() ACQUIRE_LOCK(&magic_init_mutex); -#define RELEASE_MAGIC_INIT_LOCK() RELEASE_LOCK(&magic_init_mutex); -#else /* USE_LOCKS */ +#define ACQUIRE_MAGIC_INIT_LOCK() ACQUIRE_LOCK(&magic_init_mutex); +#define RELEASE_MAGIC_INIT_LOCK() RELEASE_LOCK(&magic_init_mutex); +#else /* USE_LOCKS */ #define ACQUIRE_MAGIC_INIT_LOCK() #define RELEASE_MAGIC_INIT_LOCK() #endif /* USE_LOCKS */ - /* ----------------------- Chunk representations ------------------------ */ /* @@ -1597,57 +1593,54 @@ static MLOCK_T magic_init_mutex; */ -struct malloc_chunk { - size_t prev_foot; /* Size of previous chunk (if free). */ - size_t head; /* Size and inuse bits. */ - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; +struct malloc_chunk +{ + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk* fd; /* double links -- used only if free. */ + struct malloc_chunk* bk; }; -typedef struct malloc_chunk mchunk; +typedef struct malloc_chunk mchunk; typedef struct malloc_chunk* mchunkptr; -typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ -typedef unsigned int bindex_t; /* Described below */ -typedef unsigned int binmap_t; /* Described below */ -typedef unsigned int flag_t; /* The type of various bit flag sets */ +typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ +typedef unsigned int bindex_t; /* Described below */ +typedef unsigned int binmap_t; /* Described below */ +typedef unsigned int flag_t; /* The type of various bit flag sets */ /* ------------------- Chunks sizes and alignments ----------------------- */ -#define MCHUNK_SIZE (sizeof(mchunk)) +#define MCHUNK_SIZE (sizeof(mchunk)) #if FOOTERS -#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) #else /* FOOTERS */ -#define CHUNK_OVERHEAD (SIZE_T_SIZE) +#define CHUNK_OVERHEAD (SIZE_T_SIZE) #endif /* FOOTERS */ /* MMapped chunks need a second word of overhead ... */ #define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) /* ... and additional padding for fake next-chunk at foot */ -#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) +#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) /* The smallest size we can malloc is an aligned minimal chunk */ -#define MIN_CHUNK_SIZE\ - ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) +#define MIN_CHUNK_SIZE ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* conversion from malloc headers to user pointers, and back */ -#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) -#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) +#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) +#define mem2chunk(mem) ((mchunkptr)((char*)(mem)-TWO_SIZE_T_SIZES)) /* chunk associated with aligned address A */ -#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) +#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) /* Bounds on request (not chunk) sizes. */ -#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) -#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) +#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) +#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) /* pad request bytes into a usable size */ -#define pad_request(req) \ - (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) +#define pad_request(req) (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* pad request, checking for minimum (but not maximum) */ -#define request2size(req) \ - (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) - +#define request2size(req) (((req) < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(req)) /* ------------------ Operations on head and foot fields ----------------- */ @@ -1659,50 +1652,46 @@ typedef unsigned int flag_t; /* The type of various bit flag sets */ mmapped region to the base of the chunk. */ -#define PINUSE_BIT (SIZE_T_ONE) -#define CINUSE_BIT (SIZE_T_TWO) -#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) +#define PINUSE_BIT (SIZE_T_ONE) +#define CINUSE_BIT (SIZE_T_TWO) +#define INUSE_BITS (PINUSE_BIT | CINUSE_BIT) /* Head value for fenceposts */ -#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) +#define FENCEPOST_HEAD (INUSE_BITS | SIZE_T_SIZE) /* extraction of fields from head words */ -#define cinuse(p) ((p)->head & CINUSE_BIT) -#define pinuse(p) ((p)->head & PINUSE_BIT) -#define chunksize(p) ((p)->head & ~(INUSE_BITS)) +#define cinuse(p) ((p)->head & CINUSE_BIT) +#define pinuse(p) ((p)->head & PINUSE_BIT) +#define chunksize(p) ((p)->head & ~(INUSE_BITS)) -#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) -#define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT) +#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) +#define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT) /* Treat space at ptr +/- offset as a chunk */ -#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) +#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) #define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) /* Ptr to next or previous physical malloc_chunk. */ -#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~INUSE_BITS))) -#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) +#define next_chunk(p) ((mchunkptr)(((char*)(p)) + ((p)->head & ~INUSE_BITS))) +#define prev_chunk(p) ((mchunkptr)(((char*)(p)) - ((p)->prev_foot))) /* extract next chunk's pinuse bit */ -#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) +#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) /* Get/set size at footer */ -#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) -#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) +#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) +#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) /* Set size, pinuse bit, and foot */ -#define set_size_and_pinuse_of_free_chunk(p, s)\ - ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) +#define set_size_and_pinuse_of_free_chunk(p, s) ((p)->head = (s | PINUSE_BIT), set_foot(p, s)) /* Set size, pinuse bit, foot, and clear next pinuse */ -#define set_free_with_pinuse(p, s, n)\ - (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) +#define set_free_with_pinuse(p, s, n) (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) -#define is_mmapped(p)\ - (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT)) +#define is_mmapped(p) (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT)) /* Get the internal overhead associated with chunk p */ -#define overhead_for(p)\ - (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) +#define overhead_for(p) (is_mmapped(p) ? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) /* Return true if malloced space is not necessarily cleared */ #if MMAP_CLEARS @@ -1802,24 +1791,25 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ is of course much better. */ -struct malloc_tree_chunk { - /* The first four fields must be compatible with malloc_chunk */ - size_t prev_foot; - size_t head; - struct malloc_tree_chunk* fd; - struct malloc_tree_chunk* bk; - - struct malloc_tree_chunk* child[2]; - struct malloc_tree_chunk* parent; - bindex_t index; +struct malloc_tree_chunk +{ + /* The first four fields must be compatible with malloc_chunk */ + size_t prev_foot; + size_t head; + struct malloc_tree_chunk* fd; + struct malloc_tree_chunk* bk; + + struct malloc_tree_chunk* child[2]; + struct malloc_tree_chunk* parent; + bindex_t index; }; -typedef struct malloc_tree_chunk tchunk; +typedef struct malloc_tree_chunk tchunk; typedef struct malloc_tree_chunk* tchunkptr; typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ /* A little helper macro for trees */ -#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) +#define leftmost_child(t) ((t)->child[0] != 0 ? (t)->child[0] : (t)->child[1]) /* ----------------------------- Segments -------------------------------- */ @@ -1878,17 +1868,18 @@ typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ and deallocated/trimmed using MORECORE with negative arguments. */ -struct malloc_segment { - char* base; /* base address */ - size_t size; /* allocated size */ - struct malloc_segment* next; /* ptr to next segment */ - flag_t sflags; /* mmap and extern flag */ +struct malloc_segment +{ + char* base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment* next; /* ptr to next segment */ + flag_t sflags; /* mmap and extern flag */ }; -#define is_mmapped_segment(S) ((S)->sflags & IS_MMAPPED_BIT) -#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) +#define is_mmapped_segment(S) ((S)->sflags & IS_MMAPPED_BIT) +#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) -typedef struct malloc_segment msegment; +typedef struct malloc_segment msegment; typedef struct malloc_segment* msegmentptr; /* ---------------------------- malloc_state ----------------------------- */ @@ -1967,37 +1958,38 @@ typedef struct malloc_segment* msegmentptr; */ /* Bin types, widths and sizes */ -#define NSMALLBINS (32U) -#define NTREEBINS (32U) -#define SMALLBIN_SHIFT (3U) -#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) -#define TREEBIN_SHIFT (8U) -#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) -#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) +#define NSMALLBINS (32U) +#define NTREEBINS (32U) +#define SMALLBIN_SHIFT (3U) +#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) +#define TREEBIN_SHIFT (8U) +#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) +#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) #define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) -struct malloc_state { - binmap_t smallmap; - binmap_t treemap; - size_t dvsize; - size_t topsize; - char* least_addr; - mchunkptr dv; - mchunkptr top; - size_t trim_check; - size_t magic; - mchunkptr smallbins[(NSMALLBINS+1)*2]; - tbinptr treebins[NTREEBINS]; - size_t footprint; - size_t max_footprint; - flag_t mflags; +struct malloc_state +{ + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + char* least_addr; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t magic; + mchunkptr smallbins[(NSMALLBINS + 1) * 2]; + tbinptr treebins[NTREEBINS]; + size_t footprint; + size_t max_footprint; + flag_t mflags; #if USE_LOCKS - MLOCK_T mutex; /* locate lock among fields that rarely change */ -#endif /* USE_LOCKS */ - msegment seg; + MLOCK_T mutex; /* locate lock among fields that rarely change */ +#endif /* USE_LOCKS */ + msegment seg; }; -typedef struct malloc_state* mstate; +typedef struct malloc_state* mstate; /* ------------- Global malloc_state and malloc_params ------------------- */ @@ -2007,86 +1999,79 @@ typedef struct malloc_state* mstate; initialized in init_mparams. */ -struct malloc_params { - size_t magic; - size_t page_size; - size_t granularity; - size_t mmap_threshold; - size_t trim_threshold; - flag_t default_mflags; +struct malloc_params +{ + size_t magic; + size_t page_size; + size_t granularity; + size_t mmap_threshold; + size_t trim_threshold; + flag_t default_mflags; }; static struct malloc_params mparams; /* The global malloc_state used for all non-"mspace" calls */ static struct malloc_state _gm_; -#define gm (&_gm_) -#define is_global(M) ((M) == &_gm_) -#define is_initialized(M) ((M)->top != 0) +#define gm (&_gm_) +#define is_global(M) ((M) == &_gm_) +#define is_initialized(M) ((M)->top != 0) /* -------------------------- system alloc setup ------------------------- */ /* Operations on mflags */ -#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) -#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) -#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) +#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) +#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) +#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) -#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) -#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) -#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) +#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) +#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) +#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) -#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) -#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) +#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) +#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) -#define set_lock(M,L)\ - ((M)->mflags = (L)?\ - ((M)->mflags | USE_LOCK_BIT) :\ - ((M)->mflags & ~USE_LOCK_BIT)) +#define set_lock(M, L) ((M)->mflags = (L) ? ((M)->mflags | USE_LOCK_BIT) : ((M)->mflags & ~USE_LOCK_BIT)) /* page-align a size */ -#define page_align(S)\ - (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE)) +#define page_align(S) (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE)) /* granularity-align a size */ -#define granularity_align(S)\ - (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE)) +#define granularity_align(S) (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE)) -#define is_page_aligned(S)\ - (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) -#define is_granularity_aligned(S)\ - (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) +#define is_page_aligned(S) (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) +#define is_granularity_aligned(S) (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) /* True if segment S holds address A */ -#define segment_holds(S, A)\ - ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) +#define segment_holds(S, A) ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) /* Return segment holding given address */ -static msegmentptr segment_holding(mstate m, char* addr) { - msegmentptr sp = &m->seg; - for (;;) { - if (addr >= sp->base && addr < sp->base + sp->size) - return sp; - if ((sp = sp->next) == 0) - return 0; - } +static msegmentptr segment_holding(mstate m, char* addr) +{ + msegmentptr sp = &m->seg; + for (;;) + { + if (addr >= sp->base && addr < sp->base + sp->size) return sp; + if ((sp = sp->next) == 0) return 0; + } } /* Return true if segment contains a segment link */ -static int has_segment_link(mstate m, msegmentptr ss) { - msegmentptr sp = &m->seg; - for (;;) { - if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) - return 1; - if ((sp = sp->next) == 0) - return 0; - } +static int has_segment_link(mstate m, msegmentptr ss) +{ + msegmentptr sp = &m->seg; + for (;;) + { + if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) return 1; + if ((sp = sp->next) == 0) return 0; + } } #ifndef MORECORE_CANNOT_TRIM -#define should_trim(M,s) ((s) > (M)->trim_check) -#else /* MORECORE_CANNOT_TRIM */ -#define should_trim(M,s) (0) +#define should_trim(M, s) ((s) > (M)->trim_check) +#else /* MORECORE_CANNOT_TRIM */ +#define should_trim(M, s) (0) #endif /* MORECORE_CANNOT_TRIM */ /* @@ -2094,9 +2079,7 @@ static int has_segment_link(mstate m, msegmentptr ss) { that may be needed to place segment records and fenceposts when new noncontiguous segments are added. */ -#define TOP_FOOT_SIZE\ - (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) - +#define TOP_FOOT_SIZE (align_offset(chunk2mem(0)) + pad_request(sizeof(struct malloc_segment)) + MIN_CHUNK_SIZE) /* ------------------------------- Hooks -------------------------------- */ @@ -2111,17 +2094,20 @@ static int has_segment_link(mstate m, msegmentptr ss) { /* Ensure locks are initialized */ #define GLOBALLY_INITIALIZE() (mparams.page_size == 0 && init_mparams()) -#define PREACTION(M) ((GLOBALLY_INITIALIZE() || use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) -#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } +#define PREACTION(M) ((GLOBALLY_INITIALIZE() || use_lock(M)) ? ACQUIRE_LOCK(&(M)->mutex) : 0) +#define POSTACTION(M) \ + { \ + if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); \ + } #else /* USE_LOCKS */ #ifndef PREACTION #define PREACTION(M) (0) -#endif /* PREACTION */ +#endif /* PREACTION */ #ifndef POSTACTION #define POSTACTION(M) -#endif /* POSTACTION */ +#endif /* POSTACTION */ #endif /* USE_LOCKS */ @@ -2141,7 +2127,7 @@ int malloc_corruption_error_count; /* default corruption action */ static void reset_on_error(mstate m); -#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) +#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) #define USAGE_ERROR_ACTION(m, p) #else /* PROCEED_ON_ERROR */ @@ -2151,158 +2137,160 @@ static void reset_on_error(mstate m); #endif /* CORRUPTION_ERROR_ACTION */ #ifndef USAGE_ERROR_ACTION -#define USAGE_ERROR_ACTION(m,p) ABORT +#define USAGE_ERROR_ACTION(m, p) ABORT #endif /* USAGE_ERROR_ACTION */ #endif /* PROCEED_ON_ERROR */ /* -------------------------- Debugging setup ---------------------------- */ -#if ! DEBUG +#if !DEBUG -#define check_free_chunk(M,P) -#define check_inuse_chunk(M,P) -#define check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) +#define check_free_chunk(M, P) +#define check_inuse_chunk(M, P) +#define check_malloced_chunk(M, P, N) +#define check_mmapped_chunk(M, P) #define check_malloc_state(M) -#define check_top_chunk(M,P) +#define check_top_chunk(M, P) #else /* DEBUG */ -#define check_free_chunk(M,P) do_check_free_chunk(M,P) -#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) -#define check_top_chunk(M,P) do_check_top_chunk(M,P) -#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) -#define check_malloc_state(M) do_check_malloc_state(M) - -static void do_check_any_chunk(mstate m, mchunkptr p); -static void do_check_top_chunk(mstate m, mchunkptr p); -static void do_check_mmapped_chunk(mstate m, mchunkptr p); -static void do_check_inuse_chunk(mstate m, mchunkptr p); -static void do_check_free_chunk(mstate m, mchunkptr p); -static void do_check_malloced_chunk(mstate m, void* mem, size_t s); -static void do_check_tree(mstate m, tchunkptr t); -static void do_check_treebin(mstate m, bindex_t i); -static void do_check_smallbin(mstate m, bindex_t i); -static void do_check_malloc_state(mstate m); -static int bin_find(mstate m, mchunkptr x); +#define check_free_chunk(M, P) do_check_free_chunk(M, P) +#define check_inuse_chunk(M, P) do_check_inuse_chunk(M, P) +#define check_top_chunk(M, P) do_check_top_chunk(M, P) +#define check_malloced_chunk(M, P, N) do_check_malloced_chunk(M, P, N) +#define check_mmapped_chunk(M, P) do_check_mmapped_chunk(M, P) +#define check_malloc_state(M) do_check_malloc_state(M) + +static void do_check_any_chunk(mstate m, mchunkptr p); +static void do_check_top_chunk(mstate m, mchunkptr p); +static void do_check_mmapped_chunk(mstate m, mchunkptr p); +static void do_check_inuse_chunk(mstate m, mchunkptr p); +static void do_check_free_chunk(mstate m, mchunkptr p); +static void do_check_malloced_chunk(mstate m, void* mem, size_t s); +static void do_check_tree(mstate m, tchunkptr t); +static void do_check_treebin(mstate m, bindex_t i); +static void do_check_smallbin(mstate m, bindex_t i); +static void do_check_malloc_state(mstate m); +static int bin_find(mstate m, mchunkptr x); static size_t traverse_and_check(mstate m); #endif /* DEBUG */ /* ---------------------------- Indexing Bins ---------------------------- */ -#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) -#define small_index(s) ((s) >> SMALLBIN_SHIFT) -#define small_index2size(i) ((i) << SMALLBIN_SHIFT) -#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) +#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) +#define small_index(s) ((s) >> SMALLBIN_SHIFT) +#define small_index2size(i) ((i) << SMALLBIN_SHIFT) +#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) /* addressing by index. See above about smallbin repositioning */ -#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) -#define treebin_at(M,i) (&((M)->treebins[i])) +#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i) << 1]))) +#define treebin_at(M, i) (&((M)->treebins[i])) /* assign tree index for size S to variable I */ #if defined(__GNUC__) && defined(i386) -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int K;\ - __asm__("bsrl %1,%0\n\t" : "=r" (K) : "rm" (X));\ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} +#define compute_tree_index(S, I) \ + { \ + size_t X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else \ + { \ + unsigned int K; \ + __asm__("bsrl %1,%0\n\t" : "=r"(K) : "rm"(X)); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ + } \ + } #else /* GNUC */ -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int Y = (unsigned int)X;\ - unsigned int N = ((Y - 0x100) >> 16) & 8;\ - unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ - N += K;\ - N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ - K = 14 - N + ((Y <<= K) >> 15);\ - I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ - }\ -} +#define compute_tree_index(S, I) \ + { \ + size_t X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else \ + { \ + unsigned int Y = (unsigned int)X; \ + unsigned int N = ((Y - 0x100) >> 16) & 8; \ + unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4; \ + N += K; \ + N += K = (((Y <<= K) - 0x4000) >> 16) & 2; \ + K = 14 - N + ((Y <<= K) >> 15); \ + I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1)); \ + } \ + } #endif /* GNUC */ /* Bit representing maximum resolved size in a treebin at i */ -#define bit_for_tree_index(i) \ - (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) +#define bit_for_tree_index(i) (i == NTREEBINS - 1) ? (SIZE_T_BITSIZE - 1) : (((i) >> 1) + TREEBIN_SHIFT - 2) /* Shift placing maximum resolved bit in a treebin at i as sign bit */ -#define leftshift_for_tree_index(i) \ - ((i == NTREEBINS-1)? 0 : \ - ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) +#define leftshift_for_tree_index(i) \ + ((i == NTREEBINS - 1) ? 0 : ((SIZE_T_BITSIZE - SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) /* The size of the smallest chunk held in bin with index i */ -#define minsize_for_tree_index(i) \ - ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ - (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) - +#define minsize_for_tree_index(i) \ + ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | (((size_t)((i)&SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) /* ------------------------ Operations on bin maps ----------------------- */ /* bit corresponding to given index */ -#define idx2bit(i) ((binmap_t)(1) << (i)) +#define idx2bit(i) ((binmap_t)(1) << (i)) /* Mark/Clear bits with given index */ -#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) -#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) -#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) +#define mark_smallmap(M, i) ((M)->smallmap |= idx2bit(i)) +#define clear_smallmap(M, i) ((M)->smallmap &= ~idx2bit(i)) +#define smallmap_is_marked(M, i) ((M)->smallmap & idx2bit(i)) -#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) -#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) -#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) +#define mark_treemap(M, i) ((M)->treemap |= idx2bit(i)) +#define clear_treemap(M, i) ((M)->treemap &= ~idx2bit(i)) +#define treemap_is_marked(M, i) ((M)->treemap & idx2bit(i)) /* index corresponding to given bit */ #if defined(__GNUC__) && defined(i386) -#define compute_bit2idx(X, I)\ -{\ - unsigned int J;\ - __asm__("bsfl %1,%0\n\t" : "=r" (J) : "rm" (X));\ - I = (bindex_t)J;\ -} +#define compute_bit2idx(X, I) \ + { \ + unsigned int J; \ + __asm__("bsfl %1,%0\n\t" : "=r"(J) : "rm"(X)); \ + I = (bindex_t)J; \ + } #else /* GNUC */ -#if USE_BUILTIN_FFS -#define compute_bit2idx(X, I) I = ffs(X)-1 +#if USE_BUILTIN_FFS +#define compute_bit2idx(X, I) I = ffs(X) - 1 #else /* USE_BUILTIN_FFS */ -#define compute_bit2idx(X, I)\ -{\ - unsigned int Y = X - 1;\ - unsigned int K = Y >> (16-4) & 16;\ - unsigned int N = K; Y >>= K;\ - N += K = Y >> (8-3) & 8; Y >>= K;\ - N += K = Y >> (4-2) & 4; Y >>= K;\ - N += K = Y >> (2-1) & 2; Y >>= K;\ - N += K = Y >> (1-0) & 1; Y >>= K;\ - I = (bindex_t)(N + Y);\ -} +#define compute_bit2idx(X, I) \ + { \ + unsigned int Y = X - 1; \ + unsigned int K = Y >> (16 - 4) & 16; \ + unsigned int N = K; \ + Y >>= K; \ + N += K = Y >> (8 - 3) & 8; \ + Y >>= K; \ + N += K = Y >> (4 - 2) & 4; \ + Y >>= K; \ + N += K = Y >> (2 - 1) & 2; \ + Y >>= K; \ + N += K = Y >> (1 - 0) & 1; \ + Y >>= K; \ + I = (bindex_t)(N + Y); \ + } #endif /* USE_BUILTIN_FFS */ #endif /* GNUC */ /* isolate the least set bit of a bitmap */ -#define least_bit(x) ((x) & -(x)) +#define least_bit(x) ((x) & -(x)) /* mask with all bits to left of least bit of x on */ -#define left_bits(x) ((x<<1) | -(x<<1)) +#define left_bits(x) ((x << 1) | -(x << 1)) /* mask with all bits to left of or equal to least bit of x on */ #define same_or_left_bits(x) ((x) | -(x)) - /* ----------------------- Runtime Check Support ------------------------- */ /* @@ -2335,525 +2323,522 @@ static size_t traverse_and_check(mstate m); /* Check if address a is at least as high as any from MORECORE or MMAP */ #define ok_address(M, a) ((char*)(a) >= (M)->least_addr) /* Check if address of next chunk n is higher than base chunk p */ -#define ok_next(p, n) ((char*)(p) < (char*)(n)) +#define ok_next(p, n) ((char*)(p) < (char*)(n)) /* Check if p has its cinuse bit on */ -#define ok_cinuse(p) cinuse(p) +#define ok_cinuse(p) cinuse(p) /* Check if p has its pinuse bit on */ -#define ok_pinuse(p) pinuse(p) +#define ok_pinuse(p) pinuse(p) #else /* !INSECURE */ #define ok_address(M, a) (1) -#define ok_next(b, n) (1) -#define ok_cinuse(p) (1) -#define ok_pinuse(p) (1) +#define ok_next(b, n) (1) +#define ok_cinuse(p) (1) +#define ok_pinuse(p) (1) #endif /* !INSECURE */ #if (FOOTERS && !INSECURE) /* Check if (alleged) mstate m has expected magic field */ -#define ok_magic(M) ((M)->magic == mparams.magic) -#else /* (FOOTERS && !INSECURE) */ -#define ok_magic(M) (1) +#define ok_magic(M) ((M)->magic == mparams.magic) +#else /* (FOOTERS && !INSECURE) */ +#define ok_magic(M) (1) #endif /* (FOOTERS && !INSECURE) */ - /* In gcc, use __builtin_expect to minimize impact of checks */ #if !INSECURE #if defined(__GNUC__) && __GNUC__ >= 3 -#define RTCHECK(e) __builtin_expect(e, 1) +#define RTCHECK(e) __builtin_expect(e, 1) #else /* GNUC */ -#define RTCHECK(e) (e) +#define RTCHECK(e) (e) #endif /* GNUC */ -#else /* !INSECURE */ -#define RTCHECK(e) (1) +#else /* !INSECURE */ +#define RTCHECK(e) (1) #endif /* !INSECURE */ /* macros to set up inuse chunks with or without footers */ #if !FOOTERS -#define mark_inuse_foot(M,p,s) +#define mark_inuse_foot(M, p, s) /* Set cinuse bit and pinuse bit of next chunk */ -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) +#define set_inuse(M, p, s) \ + ((p)->head = (((p)->head & PINUSE_BIT) | s | CINUSE_BIT), ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) /* Set cinuse and pinuse of this chunk and pinuse of next chunk */ -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) +#define set_inuse_and_pinuse(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) /* Set size, cinuse and pinuse bit of this chunk */ -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) +#define set_size_and_pinuse_of_inuse_chunk(M, p, s) ((p)->head = (s | PINUSE_BIT | CINUSE_BIT)) #else /* FOOTERS */ /* Set foot of inuse chunk to be xor of mstate and seed */ -#define mark_inuse_foot(M,p,s)\ - (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) +#define mark_inuse_foot(M, p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) -#define get_mstate_for(p)\ - ((mstate)(((mchunkptr)((char*)(p) +\ - (chunksize(p))))->prev_foot ^ mparams.magic)) +#define get_mstate_for(p) ((mstate)(((mchunkptr)((char*)(p) + (chunksize(p))))->prev_foot ^ mparams.magic)) -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ - mark_inuse_foot(M,p,s)) +#define set_inuse(M, p, s) \ + ((p)->head = (((p)->head & PINUSE_BIT) | s | CINUSE_BIT), (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M, p, s)) -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ - mark_inuse_foot(M,p,s)) +#define set_inuse_and_pinuse(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M, p, s)) -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - mark_inuse_foot(M, p, s)) +#define set_size_and_pinuse_of_inuse_chunk(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), mark_inuse_foot(M, p, s)) #endif /* !FOOTERS */ /* ---------------------------- setting mparams -------------------------- */ /* Initialize mparams */ -static int init_mparams(void) { - if (mparams.page_size == 0) { - size_t s; +static int init_mparams(void) +{ + if (mparams.page_size == 0) { + size_t s; - mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; - mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; + mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; + mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; #if MORECORE_CONTIGUOUS - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; + mparams.default_mflags = USE_LOCK_BIT | USE_MMAP_BIT; #else /* MORECORE_CONTIGUOUS */ - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; + mparams.default_mflags = USE_LOCK_BIT | USE_MMAP_BIT | USE_NONCONTIGUOUS_BIT; #endif /* MORECORE_CONTIGUOUS */ #if (FOOTERS && !INSECURE) - { + { #if USE_DEV_RANDOM - int fd; - unsigned char buf[sizeof(size_t)]; - /* Try to use /dev/urandom, else fall back on using time */ - if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && - read(fd, buf, sizeof(buf)) == sizeof(buf)) { - s = *((size_t *) buf); - close(fd); - } - else + int fd; + unsigned char buf[sizeof(size_t)]; + /* Try to use /dev/urandom, else fall back on using time */ + if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && read(fd, buf, sizeof(buf)) == sizeof(buf)) { + s = *((size_t*)buf); + close(fd); + } + else #endif /* USE_DEV_RANDOM */ - s = (size_t)(time(0) ^ (size_t)0x55555555U); - - s |= (size_t)8U; /* ensure nonzero */ - s &= ~(size_t)7U; /* improve chances of fault for bad values */ + s = (size_t)(time(0) ^ (size_t)0x55555555U); - } -#else /* (FOOTERS && !INSECURE) */ - s = (size_t)0x58585858U; + s |= (size_t)8U; /* ensure nonzero */ + s &= ~(size_t)7U; /* improve chances of fault for bad values */ + } +#else /* (FOOTERS && !INSECURE) */ + s = (size_t)0x58585858U; #endif /* (FOOTERS && !INSECURE) */ - ACQUIRE_MAGIC_INIT_LOCK(); - if (mparams.magic == 0) { - mparams.magic = s; - /* Set up lock for main malloc area */ - INITIAL_LOCK(&gm->mutex); - gm->mflags = mparams.default_mflags; - } - RELEASE_MAGIC_INIT_LOCK(); + ACQUIRE_MAGIC_INIT_LOCK(); + if (mparams.magic == 0) { + mparams.magic = s; + /* Set up lock for main malloc area */ + INITIAL_LOCK(&gm->mutex); + gm->mflags = mparams.default_mflags; + } + RELEASE_MAGIC_INIT_LOCK(); #ifndef WIN32 - mparams.page_size = malloc_getpagesize; - mparams.granularity = ((DEFAULT_GRANULARITY != 0)? - DEFAULT_GRANULARITY : mparams.page_size); -#else /* WIN32 */ - { - SYSTEM_INFO system_info; - GetSystemInfo(&system_info); - mparams.page_size = system_info.dwPageSize; - mparams.granularity = system_info.dwAllocationGranularity; - } + mparams.page_size = malloc_getpagesize; + mparams.granularity = ((DEFAULT_GRANULARITY != 0) ? DEFAULT_GRANULARITY : mparams.page_size); +#else /* WIN32 */ + { + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); + mparams.page_size = system_info.dwPageSize; + mparams.granularity = system_info.dwAllocationGranularity; + } #endif /* WIN32 */ - /* Sanity-check configuration: - size_t must be unsigned and as wide as pointer type. - ints must be at least 4 bytes. - alignment must be at least 8. - Alignment, min chunk size, and page size must all be powers of 2. - */ - if ((sizeof(size_t) != sizeof(char*)) || - (MAX_SIZE_T < MIN_CHUNK_SIZE) || - (sizeof(int) < 4) || - (MALLOC_ALIGNMENT < (size_t)8U) || - ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || - ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || - ((mparams.granularity & (mparams.granularity-SIZE_T_ONE)) != 0) || - ((mparams.page_size & (mparams.page_size-SIZE_T_ONE)) != 0)) - ABORT; - } - return 0; + /* Sanity-check configuration: + size_t must be unsigned and as wide as pointer type. + ints must be at least 4 bytes. + alignment must be at least 8. + Alignment, min chunk size, and page size must all be powers of 2. + */ + if ((sizeof(size_t) != sizeof(char*)) || (MAX_SIZE_T < MIN_CHUNK_SIZE) || (sizeof(int) < 4) || + (MALLOC_ALIGNMENT < (size_t)8U) || ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT - SIZE_T_ONE)) != 0) || + ((MCHUNK_SIZE & (MCHUNK_SIZE - SIZE_T_ONE)) != 0) || + ((mparams.granularity & (mparams.granularity - SIZE_T_ONE)) != 0) || + ((mparams.page_size & (mparams.page_size - SIZE_T_ONE)) != 0)) + ABORT; + } + return 0; } /* support for mallopt */ -static int change_mparam(int param_number, int value) { - size_t val = (size_t)value; - init_mparams(); - switch(param_number) { - case M_TRIM_THRESHOLD: - mparams.trim_threshold = val; - return 1; - case M_GRANULARITY: - if (val >= mparams.page_size && ((val & (val-1)) == 0)) { - mparams.granularity = val; - return 1; +static int change_mparam(int param_number, int value) +{ + size_t val = (size_t)value; + init_mparams(); + switch (param_number) + { + case M_TRIM_THRESHOLD: mparams.trim_threshold = val; return 1; + case M_GRANULARITY: + if (val >= mparams.page_size && ((val & (val - 1)) == 0)) { + mparams.granularity = val; + return 1; + } + else + return 0; + case M_MMAP_THRESHOLD: mparams.mmap_threshold = val; return 1; + default: return 0; } - else - return 0; - case M_MMAP_THRESHOLD: - mparams.mmap_threshold = val; - return 1; - default: - return 0; - } } #if DEBUG /* ------------------------- Debugging Support --------------------------- */ /* Check properties of any chunk, whether free, inuse, mmapped etc */ -static void do_check_any_chunk(mstate m, mchunkptr p) { - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); +static void do_check_any_chunk(mstate m, mchunkptr p) +{ + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); } /* Check properties of top chunk */ -static void do_check_top_chunk(mstate m, mchunkptr p) { - msegmentptr sp = segment_holding(m, (char*)p); - size_t sz = chunksize(p); - assert(sp != 0); - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); - assert(sz == m->topsize); - assert(sz > 0); - assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); - assert(pinuse(p)); - assert(!next_pinuse(p)); +static void do_check_top_chunk(mstate m, mchunkptr p) +{ + msegmentptr sp = segment_holding(m, (char*)p); + size_t sz = chunksize(p); + assert(sp != 0); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(sz == m->topsize); + assert(sz > 0); + assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); + assert(pinuse(p)); + assert(!next_pinuse(p)); } /* Check properties of (inuse) mmapped chunks */ -static void do_check_mmapped_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize(p); - size_t len = (sz + (p->prev_foot & ~IS_MMAPPED_BIT) + MMAP_FOOT_PAD); - assert(is_mmapped(p)); - assert(use_mmap(m)); - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); - assert(ok_address(m, p)); - assert(!is_small(sz)); - assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); - assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); - assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); +static void do_check_mmapped_chunk(mstate m, mchunkptr p) +{ + size_t sz = chunksize(p); + size_t len = (sz + (p->prev_foot & ~IS_MMAPPED_BIT) + MMAP_FOOT_PAD); + assert(is_mmapped(p)); + assert(use_mmap(m)); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(!is_small(sz)); + assert((len & (mparams.page_size - SIZE_T_ONE)) == 0); + assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); + assert(chunk_plus_offset(p, sz + SIZE_T_SIZE)->head == 0); } /* Check properties of inuse chunks */ -static void do_check_inuse_chunk(mstate m, mchunkptr p) { - do_check_any_chunk(m, p); - assert(cinuse(p)); - assert(next_pinuse(p)); - /* If not pinuse and not mmapped, previous chunk has OK offset */ - assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); - if (is_mmapped(p)) - do_check_mmapped_chunk(m, p); +static void do_check_inuse_chunk(mstate m, mchunkptr p) +{ + do_check_any_chunk(m, p); + assert(cinuse(p)); + assert(next_pinuse(p)); + /* If not pinuse and not mmapped, previous chunk has OK offset */ + assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); + if (is_mmapped(p)) do_check_mmapped_chunk(m, p); } /* Check properties of free chunks */ -static void do_check_free_chunk(mstate m, mchunkptr p) { - size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT); - mchunkptr next = chunk_plus_offset(p, sz); - do_check_any_chunk(m, p); - assert(!cinuse(p)); - assert(!next_pinuse(p)); - assert (!is_mmapped(p)); - if (p != m->dv && p != m->top) { - if (sz >= MIN_CHUNK_SIZE) { - assert((sz & CHUNK_ALIGN_MASK) == 0); - assert(is_aligned(chunk2mem(p))); - assert(next->prev_foot == sz); - assert(pinuse(p)); - assert (next == m->top || cinuse(next)); - assert(p->fd->bk == p); - assert(p->bk->fd == p); +static void do_check_free_chunk(mstate m, mchunkptr p) +{ + size_t sz = p->head & ~(PINUSE_BIT | CINUSE_BIT); + mchunkptr next = chunk_plus_offset(p, sz); + do_check_any_chunk(m, p); + assert(!cinuse(p)); + assert(!next_pinuse(p)); + assert(!is_mmapped(p)); + if (p != m->dv && p != m->top) { + if (sz >= MIN_CHUNK_SIZE) { + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(is_aligned(chunk2mem(p))); + assert(next->prev_foot == sz); + assert(pinuse(p)); + assert(next == m->top || cinuse(next)); + assert(p->fd->bk == p); + assert(p->bk->fd == p); + } + else /* markers are always of size SIZE_T_SIZE */ + assert(sz == SIZE_T_SIZE); } - else /* markers are always of size SIZE_T_SIZE */ - assert(sz == SIZE_T_SIZE); - } } /* Check properties of malloced chunks at the point they are malloced */ -static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); - size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT); - do_check_inuse_chunk(m, p); - assert((sz & CHUNK_ALIGN_MASK) == 0); - assert(sz >= MIN_CHUNK_SIZE); - assert(sz >= s); - /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ - assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); - } +static void do_check_malloced_chunk(mstate m, void* mem, size_t s) +{ + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + size_t sz = p->head & ~(PINUSE_BIT | CINUSE_BIT); + do_check_inuse_chunk(m, p); + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(sz >= MIN_CHUNK_SIZE); + assert(sz >= s); + /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ + assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); + } } /* Check a tree and its subtrees. */ -static void do_check_tree(mstate m, tchunkptr t) { - tchunkptr head = 0; - tchunkptr u = t; - bindex_t tindex = t->index; - size_t tsize = chunksize(t); - bindex_t idx; - compute_tree_index(tsize, idx); - assert(tindex == idx); - assert(tsize >= MIN_LARGE_SIZE); - assert(tsize >= minsize_for_tree_index(idx)); - assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); - - do { /* traverse through chain of same-sized nodes */ - do_check_any_chunk(m, ((mchunkptr)u)); - assert(u->index == tindex); - assert(chunksize(u) == tsize); - assert(!cinuse(u)); - assert(!next_pinuse(u)); - assert(u->fd->bk == u); - assert(u->bk->fd == u); - if (u->parent == 0) { - assert(u->child[0] == 0); - assert(u->child[1] == 0); - } - else { - assert(head == 0); /* only one node on chain has parent */ - head = u; - assert(u->parent != u); - assert (u->parent->child[0] == u || - u->parent->child[1] == u || - *((tbinptr*)(u->parent)) == u); - if (u->child[0] != 0) { - assert(u->child[0]->parent == u); - assert(u->child[0] != u); - do_check_tree(m, u->child[0]); - } - if (u->child[1] != 0) { - assert(u->child[1]->parent == u); - assert(u->child[1] != u); - do_check_tree(m, u->child[1]); - } - if (u->child[0] != 0 && u->child[1] != 0) { - assert(chunksize(u->child[0]) < chunksize(u->child[1])); - } - } - u = u->fd; - } while (u != t); - assert(head != 0); +static void do_check_tree(mstate m, tchunkptr t) +{ + tchunkptr head = 0; + tchunkptr u = t; + bindex_t tindex = t->index; + size_t tsize = chunksize(t); + bindex_t idx; + compute_tree_index(tsize, idx); + assert(tindex == idx); + assert(tsize >= MIN_LARGE_SIZE); + assert(tsize >= minsize_for_tree_index(idx)); + assert((idx == NTREEBINS - 1) || (tsize < minsize_for_tree_index((idx + 1)))); + + do + { /* traverse through chain of same-sized nodes */ + do_check_any_chunk(m, ((mchunkptr)u)); + assert(u->index == tindex); + assert(chunksize(u) == tsize); + assert(!cinuse(u)); + assert(!next_pinuse(u)); + assert(u->fd->bk == u); + assert(u->bk->fd == u); + if (u->parent == 0) { + assert(u->child[0] == 0); + assert(u->child[1] == 0); + } + else + { + assert(head == 0); /* only one node on chain has parent */ + head = u; + assert(u->parent != u); + assert(u->parent->child[0] == u || u->parent->child[1] == u || *((tbinptr*)(u->parent)) == u); + if (u->child[0] != 0) { + assert(u->child[0]->parent == u); + assert(u->child[0] != u); + do_check_tree(m, u->child[0]); + } + if (u->child[1] != 0) { + assert(u->child[1]->parent == u); + assert(u->child[1] != u); + do_check_tree(m, u->child[1]); + } + if (u->child[0] != 0 && u->child[1] != 0) { + assert(chunksize(u->child[0]) < chunksize(u->child[1])); + } + } + u = u->fd; + } while (u != t); + assert(head != 0); } /* Check all the chunks in a treebin. */ -static void do_check_treebin(mstate m, bindex_t i) { - tbinptr* tb = treebin_at(m, i); - tchunkptr t = *tb; - int empty = (m->treemap & (1U << i)) == 0; - if (t == 0) - assert(empty); - if (!empty) - do_check_tree(m, t); +static void do_check_treebin(mstate m, bindex_t i) +{ + tbinptr* tb = treebin_at(m, i); + tchunkptr t = *tb; + int empty = (m->treemap & (1U << i)) == 0; + if (t == 0) assert(empty); + if (!empty) do_check_tree(m, t); } /* Check all the chunks in a smallbin. */ -static void do_check_smallbin(mstate m, bindex_t i) { - sbinptr b = smallbin_at(m, i); - mchunkptr p = b->bk; - unsigned int empty = (m->smallmap & (1U << i)) == 0; - if (p == b) - assert(empty); - if (!empty) { - for (; p != b; p = p->bk) { - size_t size = chunksize(p); - mchunkptr q; - /* each chunk claims to be free */ - do_check_free_chunk(m, p); - /* chunk belongs in bin */ - assert(small_index(size) == i); - assert(p->bk == b || chunksize(p->bk) == chunksize(p)); - /* chunk is followed by an inuse chunk */ - q = next_chunk(p); - if (q->head != FENCEPOST_HEAD) - do_check_inuse_chunk(m, q); +static void do_check_smallbin(mstate m, bindex_t i) +{ + sbinptr b = smallbin_at(m, i); + mchunkptr p = b->bk; + unsigned int empty = (m->smallmap & (1U << i)) == 0; + if (p == b) assert(empty); + if (!empty) { + for (; p != b; p = p->bk) + { + size_t size = chunksize(p); + mchunkptr q; + /* each chunk claims to be free */ + do_check_free_chunk(m, p); + /* chunk belongs in bin */ + assert(small_index(size) == i); + assert(p->bk == b || chunksize(p->bk) == chunksize(p)); + /* chunk is followed by an inuse chunk */ + q = next_chunk(p); + if (q->head != FENCEPOST_HEAD) do_check_inuse_chunk(m, q); + } } - } } /* Find x in a bin. Used in other check functions. */ -static int bin_find(mstate m, mchunkptr x) { - size_t size = chunksize(x); - if (is_small(size)) { - bindex_t sidx = small_index(size); - sbinptr b = smallbin_at(m, sidx); - if (smallmap_is_marked(m, sidx)) { - mchunkptr p = b; - do { - if (p == x) - return 1; - } while ((p = p->fd) != b); +static int bin_find(mstate m, mchunkptr x) +{ + size_t size = chunksize(x); + if (is_small(size)) { + bindex_t sidx = small_index(size); + sbinptr b = smallbin_at(m, sidx); + if (smallmap_is_marked(m, sidx)) { + mchunkptr p = b; + do + { + if (p == x) return 1; + } while ((p = p->fd) != b); + } } - } - else { - bindex_t tidx; - compute_tree_index(size, tidx); - if (treemap_is_marked(m, tidx)) { - tchunkptr t = *treebin_at(m, tidx); - size_t sizebits = size << leftshift_for_tree_index(tidx); - while (t != 0 && chunksize(t) != size) { - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - sizebits <<= 1; - } - if (t != 0) { - tchunkptr u = t; - do { - if (u == (tchunkptr)x) - return 1; - } while ((u = u->fd) != t); - } + else + { + bindex_t tidx; + compute_tree_index(size, tidx); + if (treemap_is_marked(m, tidx)) { + tchunkptr t = *treebin_at(m, tidx); + size_t sizebits = size << leftshift_for_tree_index(tidx); + while (t != 0 && chunksize(t) != size) + { + t = t->child[(sizebits >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]; + sizebits <<= 1; + } + if (t != 0) { + tchunkptr u = t; + do + { + if (u == (tchunkptr)x) return 1; + } while ((u = u->fd) != t); + } + } } - } - return 0; + return 0; } /* Traverse each chunk and check it; return total */ -static size_t traverse_and_check(mstate m) { - size_t sum = 0; - if (is_initialized(m)) { - msegmentptr s = &m->seg; - sum += m->topsize + TOP_FOOT_SIZE; - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - mchunkptr lastq = 0; - assert(pinuse(q)); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - sum += chunksize(q); - if (cinuse(q)) { - assert(!bin_find(m, q)); - do_check_inuse_chunk(m, q); - } - else { - assert(q == m->dv || bin_find(m, q)); - assert(lastq == 0 || cinuse(lastq)); /* Not 2 consecutive free */ - do_check_free_chunk(m, q); +static size_t traverse_and_check(mstate m) +{ + size_t sum = 0; + if (is_initialized(m)) { + msegmentptr s = &m->seg; + sum += m->topsize + TOP_FOOT_SIZE; + while (s != 0) + { + mchunkptr q = align_as_chunk(s->base); + mchunkptr lastq = 0; + assert(pinuse(q)); + while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) + { + sum += chunksize(q); + if (cinuse(q)) { + assert(!bin_find(m, q)); + do_check_inuse_chunk(m, q); + } + else + { + assert(q == m->dv || bin_find(m, q)); + assert(lastq == 0 || cinuse(lastq)); /* Not 2 consecutive free */ + do_check_free_chunk(m, q); + } + lastq = q; + q = next_chunk(q); + } + s = s->next; } - lastq = q; - q = next_chunk(q); - } - s = s->next; } - } - return sum; + return sum; } /* Check all properties of malloc_state. */ -static void do_check_malloc_state(mstate m) { - bindex_t i; - size_t total; - /* check bins */ - for (i = 0; i < NSMALLBINS; ++i) - do_check_smallbin(m, i); - for (i = 0; i < NTREEBINS; ++i) - do_check_treebin(m, i); - - if (m->dvsize != 0) { /* check dv chunk */ - do_check_any_chunk(m, m->dv); - assert(m->dvsize == chunksize(m->dv)); - assert(m->dvsize >= MIN_CHUNK_SIZE); - assert(bin_find(m, m->dv) == 0); - } +static void do_check_malloc_state(mstate m) +{ + bindex_t i; + size_t total; + /* check bins */ + for (i = 0; i < NSMALLBINS; ++i) + do_check_smallbin(m, i); + for (i = 0; i < NTREEBINS; ++i) + do_check_treebin(m, i); + + if (m->dvsize != 0) { /* check dv chunk */ + do_check_any_chunk(m, m->dv); + assert(m->dvsize == chunksize(m->dv)); + assert(m->dvsize >= MIN_CHUNK_SIZE); + assert(bin_find(m, m->dv) == 0); + } - if (m->top != 0) { /* check top chunk */ - do_check_top_chunk(m, m->top); - assert(m->topsize == chunksize(m->top)); - assert(m->topsize > 0); - assert(bin_find(m, m->top) == 0); - } + if (m->top != 0) { /* check top chunk */ + do_check_top_chunk(m, m->top); + assert(m->topsize == chunksize(m->top)); + assert(m->topsize > 0); + assert(bin_find(m, m->top) == 0); + } - total = traverse_and_check(m); - assert(total <= m->footprint); - assert(m->footprint <= m->max_footprint); + total = traverse_and_check(m); + assert(total <= m->footprint); + assert(m->footprint <= m->max_footprint); } #endif /* DEBUG */ /* ----------------------------- statistics ------------------------------ */ #if !NO_MALLINFO -static struct mallinfo internal_mallinfo(mstate m) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - if (!PREACTION(m)) { - check_malloc_state(m); - if (is_initialized(m)) { - size_t nfree = SIZE_T_ONE; /* top always free */ - size_t mfree = m->topsize + TOP_FOOT_SIZE; - size_t sum = mfree; - msegmentptr s = &m->seg; - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - size_t sz = chunksize(q); - sum += sz; - if (!cinuse(q)) { - mfree += sz; - ++nfree; - } - q = next_chunk(q); +static struct mallinfo internal_mallinfo(mstate m) +{ + struct mallinfo nm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + if (!PREACTION(m)) { + check_malloc_state(m); + if (is_initialized(m)) { + size_t nfree = SIZE_T_ONE; /* top always free */ + size_t mfree = m->topsize + TOP_FOOT_SIZE; + size_t sum = mfree; + msegmentptr s = &m->seg; + while (s != 0) + { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) + { + size_t sz = chunksize(q); + sum += sz; + if (!cinuse(q)) { + mfree += sz; + ++nfree; + } + q = next_chunk(q); + } + s = s->next; + } + + nm.arena = sum; + nm.ordblks = nfree; + nm.hblkhd = m->footprint - sum; + nm.usmblks = m->max_footprint; + nm.uordblks = m->footprint - mfree; + nm.fordblks = mfree; + nm.keepcost = m->topsize; } - s = s->next; - } - nm.arena = sum; - nm.ordblks = nfree; - nm.hblkhd = m->footprint - sum; - nm.usmblks = m->max_footprint; - nm.uordblks = m->footprint - mfree; - nm.fordblks = mfree; - nm.keepcost = m->topsize; + POSTACTION(m); } - - POSTACTION(m); - } - return nm; + return nm; } #endif /* !NO_MALLINFO */ -static void internal_malloc_stats(mstate m) { - if (!PREACTION(m)) { - size_t maxfp = 0; - size_t fp = 0; - size_t used = 0; - check_malloc_state(m); - if (is_initialized(m)) { - msegmentptr s = &m->seg; - maxfp = m->max_footprint; - fp = m->footprint; - used = fp - (m->topsize + TOP_FOOT_SIZE); - - while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - if (!cinuse(q)) - used -= chunksize(q); - q = next_chunk(q); +static void internal_malloc_stats(mstate m) +{ + if (!PREACTION(m)) { + size_t maxfp = 0; + size_t fp = 0; + size_t used = 0; + check_malloc_state(m); + if (is_initialized(m)) { + msegmentptr s = &m->seg; + maxfp = m->max_footprint; + fp = m->footprint; + used = fp - (m->topsize + TOP_FOOT_SIZE); + + while (s != 0) + { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) + { + if (!cinuse(q)) used -= chunksize(q); + q = next_chunk(q); + } + s = s->next; + } } - s = s->next; - } - } - fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); - fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); - fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); + fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); + fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); + fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); - POSTACTION(m); - } + POSTACTION(m); + } } /* ----------------------- Operations on smallbins ----------------------- */ @@ -2866,127 +2851,143 @@ static void internal_malloc_stats(mstate m) { */ /* Link a free chunk into a smallbin */ -#define insert_small_chunk(M, P, S) {\ - bindex_t I = small_index(S);\ - mchunkptr B = smallbin_at(M, I);\ - mchunkptr F = B;\ - assert(S >= MIN_CHUNK_SIZE);\ - if (!smallmap_is_marked(M, I))\ - mark_smallmap(M, I);\ - else if (RTCHECK(ok_address(M, B->fd)))\ - F = B->fd;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - B->fd = P;\ - F->bk = P;\ - P->fd = F;\ - P->bk = B;\ -} +#define insert_small_chunk(M, P, S) \ + { \ + bindex_t I = small_index(S); \ + mchunkptr B = smallbin_at(M, I); \ + mchunkptr F = B; \ + assert(S >= MIN_CHUNK_SIZE); \ + if (!smallmap_is_marked(M, I)) \ + mark_smallmap(M, I); \ + else if (RTCHECK(ok_address(M, B->fd))) \ + F = B->fd; \ + else \ + { \ + CORRUPTION_ERROR_ACTION(M); \ + } \ + B->fd = P; \ + F->bk = P; \ + P->fd = F; \ + P->bk = B; \ + } /* Unlink a chunk from a smallbin */ -#define unlink_small_chunk(M, P, S) {\ - mchunkptr F = P->fd;\ - mchunkptr B = P->bk;\ - bindex_t I = small_index(S);\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (F == B)\ - clear_smallmap(M, I);\ - else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\ - (B == smallbin_at(M,I) || ok_address(M, B)))) {\ - F->bk = B;\ - B->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} +#define unlink_small_chunk(M, P, S) \ + { \ + mchunkptr F = P->fd; \ + mchunkptr B = P->bk; \ + bindex_t I = small_index(S); \ + assert(P != B); \ + assert(P != F); \ + assert(chunksize(P) == small_index2size(I)); \ + if (F == B) \ + clear_smallmap(M, I); \ + else if (RTCHECK( \ + (F == smallbin_at(M, I) || ok_address(M, F)) && (B == smallbin_at(M, I) || ok_address(M, B)))) \ + { \ + F->bk = B; \ + B->fd = F; \ + } \ + else \ + { \ + CORRUPTION_ERROR_ACTION(M); \ + } \ + } /* Unlink the first chunk from a smallbin */ -#define unlink_first_small_chunk(M, B, P, I) {\ - mchunkptr F = P->fd;\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (B == F)\ - clear_smallmap(M, I);\ - else if (RTCHECK(ok_address(M, F))) {\ - B->fd = F;\ - F->bk = B;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} +#define unlink_first_small_chunk(M, B, P, I) \ + { \ + mchunkptr F = P->fd; \ + assert(P != B); \ + assert(P != F); \ + assert(chunksize(P) == small_index2size(I)); \ + if (B == F) \ + clear_smallmap(M, I); \ + else if (RTCHECK(ok_address(M, F))) \ + { \ + B->fd = F; \ + F->bk = B; \ + } \ + else \ + { \ + CORRUPTION_ERROR_ACTION(M); \ + } \ + } /* Replace dv node, binning the old one */ /* Used only when dvsize known to be small */ -#define replace_dv(M, P, S) {\ - size_t DVS = M->dvsize;\ - if (DVS != 0) {\ - mchunkptr DV = M->dv;\ - assert(is_small(DVS));\ - insert_small_chunk(M, DV, DVS);\ - }\ - M->dvsize = S;\ - M->dv = P;\ -} +#define replace_dv(M, P, S) \ + { \ + size_t DVS = M->dvsize; \ + if (DVS != 0) { \ + mchunkptr DV = M->dv; \ + assert(is_small(DVS)); \ + insert_small_chunk(M, DV, DVS); \ + } \ + M->dvsize = S; \ + M->dv = P; \ + } /* ------------------------- Operations on trees ------------------------- */ /* Insert chunk into tree */ -#define insert_large_chunk(M, X, S) {\ - tbinptr* H;\ - bindex_t I;\ - compute_tree_index(S, I);\ - H = treebin_at(M, I);\ - X->index = I;\ - X->child[0] = X->child[1] = 0;\ - if (!treemap_is_marked(M, I)) {\ - mark_treemap(M, I);\ - *H = X;\ - X->parent = (tchunkptr)H;\ - X->fd = X->bk = X;\ - }\ - else {\ - tchunkptr T = *H;\ - size_t K = S << leftshift_for_tree_index(I);\ - for (;;) {\ - if (chunksize(T) != S) {\ - tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ - K <<= 1;\ - if (*C != 0)\ - T = *C;\ - else if (RTCHECK(ok_address(M, C))) {\ - *C = X;\ - X->parent = T;\ - X->fd = X->bk = X;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - else {\ - tchunkptr F = T->fd;\ - if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ - T->fd = F->bk = X;\ - X->fd = F;\ - X->bk = T;\ - X->parent = 0;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - }\ - }\ -} +#define insert_large_chunk(M, X, S) \ + { \ + tbinptr* H; \ + bindex_t I; \ + compute_tree_index(S, I); \ + H = treebin_at(M, I); \ + X->index = I; \ + X->child[0] = X->child[1] = 0; \ + if (!treemap_is_marked(M, I)) { \ + mark_treemap(M, I); \ + *H = X; \ + X->parent = (tchunkptr)H; \ + X->fd = X->bk = X; \ + } \ + else \ + { \ + tchunkptr T = *H; \ + size_t K = S << leftshift_for_tree_index(I); \ + for (;;) \ + { \ + if (chunksize(T) != S) { \ + tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]); \ + K <<= 1; \ + if (*C != 0) \ + T = *C; \ + else if (RTCHECK(ok_address(M, C))) \ + { \ + *C = X; \ + X->parent = T; \ + X->fd = X->bk = X; \ + break; \ + } \ + else \ + { \ + CORRUPTION_ERROR_ACTION(M); \ + break; \ + } \ + } \ + else \ + { \ + tchunkptr F = T->fd; \ + if (RTCHECK(ok_address(M, T) && ok_address(M, F))) { \ + T->fd = F->bk = X; \ + X->fd = F; \ + X->bk = T; \ + X->parent = 0; \ + break; \ + } \ + else \ + { \ + CORRUPTION_ERROR_ACTION(M); \ + break; \ + } \ + } \ + } \ + } \ + } /* Unlink steps: @@ -3005,99 +3006,109 @@ static void internal_malloc_stats(mstate m) { x's parent and children to x's replacement (or null if none). */ -#define unlink_large_chunk(M, X) {\ - tchunkptr XP = X->parent;\ - tchunkptr R;\ - if (X->bk != X) {\ - tchunkptr F = X->fd;\ - R = X->bk;\ - if (RTCHECK(ok_address(M, F))) {\ - F->bk = R;\ - R->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else {\ - tchunkptr* RP;\ - if (((R = *(RP = &(X->child[1]))) != 0) ||\ - ((R = *(RP = &(X->child[0]))) != 0)) {\ - tchunkptr* CP;\ - while ((*(CP = &(R->child[1])) != 0) ||\ - (*(CP = &(R->child[0])) != 0)) {\ - R = *(RP = CP);\ - }\ - if (RTCHECK(ok_address(M, RP)))\ - *RP = 0;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - }\ - if (XP != 0) {\ - tbinptr* H = treebin_at(M, X->index);\ - if (X == *H) {\ - if ((*H = R) == 0) \ - clear_treemap(M, X->index);\ - }\ - else if (RTCHECK(ok_address(M, XP))) {\ - if (XP->child[0] == X) \ - XP->child[0] = R;\ - else \ - XP->child[1] = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - if (R != 0) {\ - if (RTCHECK(ok_address(M, R))) {\ - tchunkptr C0, C1;\ - R->parent = XP;\ - if ((C0 = X->child[0]) != 0) {\ - if (RTCHECK(ok_address(M, C0))) {\ - R->child[0] = C0;\ - C0->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - if ((C1 = X->child[1]) != 0) {\ - if (RTCHECK(ok_address(M, C1))) {\ - R->child[1] = C1;\ - C1->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ -} +#define unlink_large_chunk(M, X) \ + { \ + tchunkptr XP = X->parent; \ + tchunkptr R; \ + if (X->bk != X) { \ + tchunkptr F = X->fd; \ + R = X->bk; \ + if (RTCHECK(ok_address(M, F))) { \ + F->bk = R; \ + R->fd = F; \ + } \ + else \ + { \ + CORRUPTION_ERROR_ACTION(M); \ + } \ + } \ + else \ + { \ + tchunkptr* RP; \ + if (((R = *(RP = &(X->child[1]))) != 0) || ((R = *(RP = &(X->child[0]))) != 0)) { \ + tchunkptr* CP; \ + while ((*(CP = &(R->child[1])) != 0) || (*(CP = &(R->child[0])) != 0)) \ + { \ + R = *(RP = CP); \ + } \ + if (RTCHECK(ok_address(M, RP))) \ + *RP = 0; \ + else \ + { \ + CORRUPTION_ERROR_ACTION(M); \ + } \ + } \ + } \ + if (XP != 0) { \ + tbinptr* H = treebin_at(M, X->index); \ + if (X == *H) { \ + if ((*H = R) == 0) clear_treemap(M, X->index); \ + } \ + else if (RTCHECK(ok_address(M, XP))) \ + { \ + if (XP->child[0] == X) \ + XP->child[0] = R; \ + else \ + XP->child[1] = R; \ + } \ + else \ + CORRUPTION_ERROR_ACTION(M); \ + if (R != 0) { \ + if (RTCHECK(ok_address(M, R))) { \ + tchunkptr C0, C1; \ + R->parent = XP; \ + if ((C0 = X->child[0]) != 0) { \ + if (RTCHECK(ok_address(M, C0))) { \ + R->child[0] = C0; \ + C0->parent = R; \ + } \ + else \ + CORRUPTION_ERROR_ACTION(M); \ + } \ + if ((C1 = X->child[1]) != 0) { \ + if (RTCHECK(ok_address(M, C1))) { \ + R->child[1] = C1; \ + C1->parent = R; \ + } \ + else \ + CORRUPTION_ERROR_ACTION(M); \ + } \ + } \ + else \ + CORRUPTION_ERROR_ACTION(M); \ + } \ + } \ + } /* Relays to large vs small bin operations */ -#define insert_chunk(M, P, S)\ - if (is_small(S)) insert_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } - -#define unlink_chunk(M, P, S)\ - if (is_small(S)) unlink_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } +#define insert_chunk(M, P, S) \ + if (is_small(S)) insert_small_chunk(M, P, S) else \ + { \ + tchunkptr TP = (tchunkptr)(P); \ + insert_large_chunk(M, TP, S); \ + } +#define unlink_chunk(M, P, S) \ + if (is_small(S)) unlink_small_chunk(M, P, S) else \ + { \ + tchunkptr TP = (tchunkptr)(P); \ + unlink_large_chunk(M, TP); \ + } /* Relays to internal calls to malloc/free from realloc, memalign etc */ #if ONLY_MSPACES #define internal_malloc(m, b) mspace_malloc(m, b) -#define internal_free(m, mem) mspace_free(m,mem); +#define internal_free(m, mem) mspace_free(m, mem); #else /* ONLY_MSPACES */ #if MSPACES -#define internal_malloc(m, b)\ - (m == gm)? dlmalloc(b) : mspace_malloc(m, b) -#define internal_free(m, mem)\ - if (m == gm) dlfree(mem); else mspace_free(m,mem); +#define internal_malloc(m, b) (m == gm) ? dlmalloc(b) : mspace_malloc(m, b) +#define internal_free(m, mem) \ + if (m == gm) \ + dlfree(mem); \ + else \ + mspace_free(m, mem); #else /* MSPACES */ #define internal_malloc(m, b) dlmalloc(b) #define internal_free(m, mem) dlfree(mem) @@ -3117,1249 +3128,1273 @@ static void internal_malloc_stats(mstate m) { */ /* Malloc using mmap */ -static void* mmap_alloc(mstate m, size_t nb) { - size_t mmsize = granularity_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - if (mmsize > nb) { /* Check for wrap around 0 */ - char* mm = (char*)(DIRECT_MMAP(mmsize)); - if (mm != CMFAIL) { - size_t offset = align_offset(chunk2mem(mm)); - size_t psize = mmsize - offset - MMAP_FOOT_PAD; - mchunkptr p = (mchunkptr)(mm + offset); - p->prev_foot = offset | IS_MMAPPED_BIT; - (p)->head = (psize|CINUSE_BIT); - mark_inuse_foot(m, p, psize); - chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; - - if (mm < m->least_addr) - m->least_addr = mm; - if ((m->footprint += mmsize) > m->max_footprint) - m->max_footprint = m->footprint; - assert(is_aligned(chunk2mem(p))); - check_mmapped_chunk(m, p); - return chunk2mem(p); +static void* mmap_alloc(mstate m, size_t nb) +{ + size_t mmsize = granularity_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + if (mmsize > nb) { /* Check for wrap around 0 */ + char* mm = (char*)(DIRECT_MMAP(mmsize)); + if (mm != CMFAIL) { + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - MMAP_FOOT_PAD; + mchunkptr p = (mchunkptr)(mm + offset); + p->prev_foot = offset | IS_MMAPPED_BIT; + (p)->head = (psize | CINUSE_BIT); + mark_inuse_foot(m, p, psize); + chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(p, psize + SIZE_T_SIZE)->head = 0; + + if (mm < m->least_addr) m->least_addr = mm; + if ((m->footprint += mmsize) > m->max_footprint) m->max_footprint = m->footprint; + assert(is_aligned(chunk2mem(p))); + check_mmapped_chunk(m, p); + return chunk2mem(p); + } } - } - return 0; + return 0; } /* Realloc using mmap */ -static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) { - size_t oldsize = chunksize(oldp); - if (is_small(nb)) /* Can't shrink mmap regions below small size */ - return 0; - /* Keep old chunk if big enough but not too big */ - if (oldsize >= nb + SIZE_T_SIZE && - (oldsize - nb) <= (mparams.granularity << 1)) - return oldp; - else { - size_t offset = oldp->prev_foot & ~IS_MMAPPED_BIT; - size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; - size_t newmmsize = granularity_align(nb + SIX_SIZE_T_SIZES + - CHUNK_ALIGN_MASK); - char* cp = (char*)CALL_MREMAP((char*)oldp - offset, - oldmmsize, newmmsize, 1); - if (cp != CMFAIL) { - mchunkptr newp = (mchunkptr)(cp + offset); - size_t psize = newmmsize - offset - MMAP_FOOT_PAD; - newp->head = (psize|CINUSE_BIT); - mark_inuse_foot(m, newp, psize); - chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; - - if (cp < m->least_addr) - m->least_addr = cp; - if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) - m->max_footprint = m->footprint; - check_mmapped_chunk(m, newp); - return newp; +static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) +{ + size_t oldsize = chunksize(oldp); + if (is_small(nb)) /* Can't shrink mmap regions below small size */ + return 0; + /* Keep old chunk if big enough but not too big */ + if (oldsize >= nb + SIZE_T_SIZE && (oldsize - nb) <= (mparams.granularity << 1)) + return oldp; + else + { + size_t offset = oldp->prev_foot & ~IS_MMAPPED_BIT; + size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; + size_t newmmsize = granularity_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + char* cp = (char*)CALL_MREMAP((char*)oldp - offset, oldmmsize, newmmsize, 1); + if (cp != CMFAIL) { + mchunkptr newp = (mchunkptr)(cp + offset); + size_t psize = newmmsize - offset - MMAP_FOOT_PAD; + newp->head = (psize | CINUSE_BIT); + mark_inuse_foot(m, newp, psize); + chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(newp, psize + SIZE_T_SIZE)->head = 0; + + if (cp < m->least_addr) m->least_addr = cp; + if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) m->max_footprint = m->footprint; + check_mmapped_chunk(m, newp); + return newp; + } } - } - return 0; + return 0; } /* -------------------------- mspace management -------------------------- */ /* Initialize top chunk and its size */ -static void init_top(mstate m, mchunkptr p, size_t psize) { - /* Ensure alignment */ - size_t offset = align_offset(chunk2mem(p)); - p = (mchunkptr)((char*)p + offset); - psize -= offset; - - m->top = p; - m->topsize = psize; - p->head = psize | PINUSE_BIT; - /* set size of fake trailing chunk holding overhead space only once */ - chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; - m->trim_check = mparams.trim_threshold; /* reset on each update */ +static void init_top(mstate m, mchunkptr p, size_t psize) +{ + /* Ensure alignment */ + size_t offset = align_offset(chunk2mem(p)); + p = (mchunkptr)((char*)p + offset); + psize -= offset; + + m->top = p; + m->topsize = psize; + p->head = psize | PINUSE_BIT; + /* set size of fake trailing chunk holding overhead space only once */ + chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; + m->trim_check = mparams.trim_threshold; /* reset on each update */ } /* Initialize bins for a new mstate that is otherwise zeroed out */ -static void init_bins(mstate m) { - /* Establish circular links for smallbins */ - bindex_t i; - for (i = 0; i < NSMALLBINS; ++i) { - sbinptr bin = smallbin_at(m,i); - bin->fd = bin->bk = bin; - } +static void init_bins(mstate m) +{ + /* Establish circular links for smallbins */ + bindex_t i; + for (i = 0; i < NSMALLBINS; ++i) + { + sbinptr bin = smallbin_at(m, i); + bin->fd = bin->bk = bin; + } } #if PROCEED_ON_ERROR /* default corruption action */ -static void reset_on_error(mstate m) { - int i; - ++malloc_corruption_error_count; - /* Reinitialize fields to forget about all memory */ - m->smallbins = m->treebins = 0; - m->dvsize = m->topsize = 0; - m->seg.base = 0; - m->seg.size = 0; - m->seg.next = 0; - m->top = m->dv = 0; - for (i = 0; i < NTREEBINS; ++i) - *treebin_at(m, i) = 0; - init_bins(m); +static void reset_on_error(mstate m) +{ + int i; + ++malloc_corruption_error_count; + /* Reinitialize fields to forget about all memory */ + m->smallbins = m->treebins = 0; + m->dvsize = m->topsize = 0; + m->seg.base = 0; + m->seg.size = 0; + m->seg.next = 0; + m->top = m->dv = 0; + for (i = 0; i < NTREEBINS; ++i) + *treebin_at(m, i) = 0; + init_bins(m); } #endif /* PROCEED_ON_ERROR */ /* Allocate chunk and prepend remainder with chunk in successor base. */ -static void* prepend_alloc(mstate m, char* newbase, char* oldbase, - size_t nb) { - mchunkptr p = align_as_chunk(newbase); - mchunkptr oldfirst = align_as_chunk(oldbase); - size_t psize = (char*)oldfirst - (char*)p; - mchunkptr q = chunk_plus_offset(p, nb); - size_t qsize = psize - nb; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - - assert((char*)oldfirst > (char*)q); - assert(pinuse(oldfirst)); - assert(qsize >= MIN_CHUNK_SIZE); - - /* consolidate remainder with first chunk of old base */ - if (oldfirst == m->top) { - size_t tsize = m->topsize += qsize; - m->top = q; - q->head = tsize | PINUSE_BIT; - check_top_chunk(m, q); - } - else if (oldfirst == m->dv) { - size_t dsize = m->dvsize += qsize; - m->dv = q; - set_size_and_pinuse_of_free_chunk(q, dsize); - } - else { - if (!cinuse(oldfirst)) { - size_t nsize = chunksize(oldfirst); - unlink_chunk(m, oldfirst, nsize); - oldfirst = chunk_plus_offset(oldfirst, nsize); - qsize += nsize; +static void* prepend_alloc(mstate m, char* newbase, char* oldbase, size_t nb) +{ + mchunkptr p = align_as_chunk(newbase); + mchunkptr oldfirst = align_as_chunk(oldbase); + size_t psize = (char*)oldfirst - (char*)p; + mchunkptr q = chunk_plus_offset(p, nb); + size_t qsize = psize - nb; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + + assert((char*)oldfirst > (char*)q); + assert(pinuse(oldfirst)); + assert(qsize >= MIN_CHUNK_SIZE); + + /* consolidate remainder with first chunk of old base */ + if (oldfirst == m->top) { + size_t tsize = m->topsize += qsize; + m->top = q; + q->head = tsize | PINUSE_BIT; + check_top_chunk(m, q); + } + else if (oldfirst == m->dv) + { + size_t dsize = m->dvsize += qsize; + m->dv = q; + set_size_and_pinuse_of_free_chunk(q, dsize); + } + else + { + if (!cinuse(oldfirst)) { + size_t nsize = chunksize(oldfirst); + unlink_chunk(m, oldfirst, nsize); + oldfirst = chunk_plus_offset(oldfirst, nsize); + qsize += nsize; + } + set_free_with_pinuse(q, qsize, oldfirst); + insert_chunk(m, q, qsize); + check_free_chunk(m, q); } - set_free_with_pinuse(q, qsize, oldfirst); - insert_chunk(m, q, qsize); - check_free_chunk(m, q); - } - check_malloced_chunk(m, chunk2mem(p), nb); - return chunk2mem(p); + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); } - /* Add a segment to hold a new noncontiguous region */ -static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { - /* Determine locations and sizes of segment, fenceposts, old top */ - char* old_top = (char*)m->top; - msegmentptr oldsp = segment_holding(m, old_top); - char* old_end = oldsp->base + oldsp->size; - size_t ssize = pad_request(sizeof(struct malloc_segment)); - char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - size_t offset = align_offset(chunk2mem(rawsp)); - char* asp = rawsp + offset; - char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; - mchunkptr sp = (mchunkptr)csp; - msegmentptr ss = (msegmentptr)(chunk2mem(sp)); - mchunkptr tnext = chunk_plus_offset(sp, ssize); - mchunkptr p = tnext; - int nfences = 0; - - /* reset top to new space */ - init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); - - /* Set up segment record */ - assert(is_aligned(ss)); - set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); - *ss = m->seg; /* Push current record */ - m->seg.base = tbase; - m->seg.size = tsize; - m->seg.sflags = mmapped; - m->seg.next = ss; - - /* Insert trailing fenceposts */ - for (;;) { - mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); - p->head = FENCEPOST_HEAD; - ++nfences; - if ((char*)(&(nextp->head)) < old_end) - p = nextp; - else - break; - } - assert(nfences >= 2); - - /* Insert the rest of old top into a bin as an ordinary free chunk */ - if (csp != old_top) { - mchunkptr q = (mchunkptr)old_top; - size_t psize = csp - old_top; - mchunkptr tn = chunk_plus_offset(q, psize); - set_free_with_pinuse(q, psize, tn); - insert_chunk(m, q, psize); - } +static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) +{ + /* Determine locations and sizes of segment, fenceposts, old top */ + char* old_top = (char*)m->top; + msegmentptr oldsp = segment_holding(m, old_top); + char* old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char* asp = rawsp + offset; + char* csp = (asp < (old_top + MIN_CHUNK_SIZE)) ? old_top : asp; + mchunkptr sp = (mchunkptr)csp; + msegmentptr ss = (msegmentptr)(chunk2mem(sp)); + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + int nfences = 0; + + /* reset top to new space */ + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + + /* Set up segment record */ + assert(is_aligned(ss)); + set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); + *ss = m->seg; /* Push current record */ + m->seg.base = tbase; + m->seg.size = tsize; + m->seg.sflags = mmapped; + m->seg.next = ss; + + /* Insert trailing fenceposts */ + for (;;) + { + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); + p->head = FENCEPOST_HEAD; + ++nfences; + if ((char*)(&(nextp->head)) < old_end) + p = nextp; + else + break; + } + assert(nfences >= 2); + + /* Insert the rest of old top into a bin as an ordinary free chunk */ + if (csp != old_top) { + mchunkptr q = (mchunkptr)old_top; + size_t psize = csp - old_top; + mchunkptr tn = chunk_plus_offset(q, psize); + set_free_with_pinuse(q, psize, tn); + insert_chunk(m, q, psize); + } - check_top_chunk(m, m->top); + check_top_chunk(m, m->top); } /* -------------------------- System allocation -------------------------- */ /* Get memory from system using MORECORE or MMAP */ -static void* sys_alloc(mstate m, size_t nb) { - char* tbase = CMFAIL; - size_t tsize = 0; - flag_t mmap_flag = 0; - - init_mparams(); - - /* Directly map large chunks */ - if (use_mmap(m) && nb >= mparams.mmap_threshold) { - void* mem = mmap_alloc(m, nb); - if (mem != 0) - return mem; - } - - /* - Try getting memory in any of three ways (in most-preferred to - least-preferred order): - 1. A call to MORECORE that can normally contiguously extend memory. - (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or - or main space is mmapped or a previous contiguous call failed) - 2. A call to MMAP new space (disabled if not HAVE_MMAP). - Note that under the default settings, if MORECORE is unable to - fulfill a request, and HAVE_MMAP is true, then mmap is - used as a noncontiguous system allocator. This is a useful backup - strategy for systems with holes in address spaces -- in this case - sbrk cannot contiguously expand the heap, but mmap may be able to - find space. - 3. A call to MORECORE that cannot usually contiguously extend memory. - (disabled if not HAVE_MORECORE) - */ - - if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { - char* br = CMFAIL; - msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); - size_t asize = 0; - ACQUIRE_MORECORE_LOCK(); - - if (ss == 0) { /* First time through or recovery */ - char* base = (char*)CALL_MORECORE(0); - if (base != CMFAIL) { - asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); - /* Adjust to end on a page boundary */ - if (!is_page_aligned(base)) - asize += (page_align((size_t)base) - (size_t)base); - /* Can't call MORECORE if size is negative when treated as signed */ - if (asize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(asize))) == base) { - tbase = base; - tsize = asize; - } - } - } - else { - /* Subtract out existing available top space from MORECORE request. */ - asize = granularity_align(nb - m->topsize + TOP_FOOT_SIZE + SIZE_T_ONE); - /* Use mem here only if it did continuously extend old space */ - if (asize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(asize))) == ss->base+ss->size) { - tbase = br; - tsize = asize; - } +static void* sys_alloc(mstate m, size_t nb) +{ + char* tbase = CMFAIL; + size_t tsize = 0; + flag_t mmap_flag = 0; + + init_mparams(); + + /* Directly map large chunks */ + if (use_mmap(m) && nb >= mparams.mmap_threshold) { + void* mem = mmap_alloc(m, nb); + if (mem != 0) return mem; } - if (tbase == CMFAIL) { /* Cope with partial failure */ - if (br != CMFAIL) { /* Try to use/extend the space we did get */ - if (asize < HALF_MAX_SIZE_T && - asize < nb + TOP_FOOT_SIZE + SIZE_T_ONE) { - size_t esize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE - asize); - if (esize < HALF_MAX_SIZE_T) { - char* end = (char*)CALL_MORECORE(esize); - if (end != CMFAIL) - asize += esize; - else { /* Can't use; try to release */ - CALL_MORECORE(-asize); - br = CMFAIL; + /* + Try getting memory in any of three ways (in most-preferred to + least-preferred order): + 1. A call to MORECORE that can normally contiguously extend memory. + (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or + or main space is mmapped or a previous contiguous call failed) + 2. A call to MMAP new space (disabled if not HAVE_MMAP). + Note that under the default settings, if MORECORE is unable to + fulfill a request, and HAVE_MMAP is true, then mmap is + used as a noncontiguous system allocator. This is a useful backup + strategy for systems with holes in address spaces -- in this case + sbrk cannot contiguously expand the heap, but mmap may be able to + find space. + 3. A call to MORECORE that cannot usually contiguously extend memory. + (disabled if not HAVE_MORECORE) + */ + + if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { + char* br = CMFAIL; + msegmentptr ss = (m->top == 0) ? 0 : segment_holding(m, (char*)m->top); + size_t asize = 0; + ACQUIRE_MORECORE_LOCK(); + + if (ss == 0) { /* First time through or recovery */ + char* base = (char*)CALL_MORECORE(0); + if (base != CMFAIL) { + asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); + /* Adjust to end on a page boundary */ + if (!is_page_aligned(base)) asize += (page_align((size_t)base) - (size_t)base); + /* Can't call MORECORE if size is negative when treated as signed */ + if (asize < HALF_MAX_SIZE_T && (br = (char*)(CALL_MORECORE(asize))) == base) { + tbase = base; + tsize = asize; + } + } + } + else + { + /* Subtract out existing available top space from MORECORE request. */ + asize = granularity_align(nb - m->topsize + TOP_FOOT_SIZE + SIZE_T_ONE); + /* Use mem here only if it did continuously extend old space */ + if (asize < HALF_MAX_SIZE_T && (br = (char*)(CALL_MORECORE(asize))) == ss->base + ss->size) { + tbase = br; + tsize = asize; } - } } - } - if (br != CMFAIL) { /* Use the space we did get */ - tbase = br; - tsize = asize; - } - else - disable_contiguous(m); /* Don't try contiguous path in the future */ - } - RELEASE_MORECORE_LOCK(); - } + if (tbase == CMFAIL) { /* Cope with partial failure */ + if (br != CMFAIL) { /* Try to use/extend the space we did get */ + if (asize < HALF_MAX_SIZE_T && asize < nb + TOP_FOOT_SIZE + SIZE_T_ONE) { + size_t esize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE - asize); + if (esize < HALF_MAX_SIZE_T) { + char* end = (char*)CALL_MORECORE(esize); + if (end != CMFAIL) + asize += esize; + else + { /* Can't use; try to release */ + CALL_MORECORE(-asize); + br = CMFAIL; + } + } + } + } + if (br != CMFAIL) { /* Use the space we did get */ + tbase = br; + tsize = asize; + } + else + disable_contiguous(m); /* Don't try contiguous path in the future */ + } - if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ - size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; - size_t rsize = granularity_align(req); - if (rsize > nb) { /* Fail if wraps around zero */ - char* mp = (char*)(CALL_MMAP(rsize)); - if (mp != CMFAIL) { - tbase = mp; - tsize = rsize; - mmap_flag = IS_MMAPPED_BIT; - } + RELEASE_MORECORE_LOCK(); } - } - if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ - size_t asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); - if (asize < HALF_MAX_SIZE_T) { - char* br = CMFAIL; - char* end = CMFAIL; - ACQUIRE_MORECORE_LOCK(); - br = (char*)(CALL_MORECORE(asize)); - end = (char*)(CALL_MORECORE(0)); - RELEASE_MORECORE_LOCK(); - if (br != CMFAIL && end != CMFAIL && br < end) { - size_t ssize = end - br; - if (ssize > nb + TOP_FOOT_SIZE) { - tbase = br; - tsize = ssize; + if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ + size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; + size_t rsize = granularity_align(req); + if (rsize > nb) { /* Fail if wraps around zero */ + char* mp = (char*)(CALL_MMAP(rsize)); + if (mp != CMFAIL) { + tbase = mp; + tsize = rsize; + mmap_flag = IS_MMAPPED_BIT; + } } - } } - } - if (tbase != CMFAIL) { - - if ((m->footprint += tsize) > m->max_footprint) - m->max_footprint = m->footprint; - - if (!is_initialized(m)) { /* first-time initialization */ - m->seg.base = m->least_addr = tbase; - m->seg.size = tsize; - m->seg.sflags = mmap_flag; - m->magic = mparams.magic; - init_bins(m); - if (is_global(m)) - init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); - else { - /* Offset top by embedded malloc_state */ - mchunkptr mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); - } + if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ + size_t asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); + if (asize < HALF_MAX_SIZE_T) { + char* br = CMFAIL; + char* end = CMFAIL; + ACQUIRE_MORECORE_LOCK(); + br = (char*)(CALL_MORECORE(asize)); + end = (char*)(CALL_MORECORE(0)); + RELEASE_MORECORE_LOCK(); + if (br != CMFAIL && end != CMFAIL && br < end) { + size_t ssize = end - br; + if (ssize > nb + TOP_FOOT_SIZE) { + tbase = br; + tsize = ssize; + } + } + } } - else { - /* Try to merge with an existing segment */ - msegmentptr sp = &m->seg; - while (sp != 0 && tbase != sp->base + sp->size) - sp = sp->next; - if (sp != 0 && - !is_extern_segment(sp) && - (sp->sflags & IS_MMAPPED_BIT) == mmap_flag && - segment_holds(sp, m->top)) { /* append */ - sp->size += tsize; - init_top(m, m->top, m->topsize + tsize); - } - else { - if (tbase < m->least_addr) - m->least_addr = tbase; - sp = &m->seg; - while (sp != 0 && sp->base != tbase + tsize) - sp = sp->next; - if (sp != 0 && - !is_extern_segment(sp) && - (sp->sflags & IS_MMAPPED_BIT) == mmap_flag) { - char* oldbase = sp->base; - sp->base = tbase; - sp->size += tsize; - return prepend_alloc(m, tbase, oldbase, nb); + if (tbase != CMFAIL) { + if ((m->footprint += tsize) > m->max_footprint) m->max_footprint = m->footprint; + + if (!is_initialized(m)) { /* first-time initialization */ + m->seg.base = m->least_addr = tbase; + m->seg.size = tsize; + m->seg.sflags = mmap_flag; + m->magic = mparams.magic; + init_bins(m); + if (is_global(m)) + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + else + { + /* Offset top by embedded malloc_state */ + mchunkptr mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); + } } + else - add_segment(m, tbase, tsize, mmap_flag); - } - } + { + /* Try to merge with an existing segment */ + msegmentptr sp = &m->seg; + while (sp != 0 && tbase != sp->base + sp->size) + sp = sp->next; + if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & IS_MMAPPED_BIT) == mmap_flag && + segment_holds(sp, m->top)) + { /* append */ + sp->size += tsize; + init_top(m, m->top, m->topsize + tsize); + } + else + { + if (tbase < m->least_addr) m->least_addr = tbase; + sp = &m->seg; + while (sp != 0 && sp->base != tbase + tsize) + sp = sp->next; + if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & IS_MMAPPED_BIT) == mmap_flag) { + char* oldbase = sp->base; + sp->base = tbase; + sp->size += tsize; + return prepend_alloc(m, tbase, oldbase, nb); + } + else + add_segment(m, tbase, tsize, mmap_flag); + } + } - if (nb < m->topsize) { /* Allocate from new or extended top space */ - size_t rsize = m->topsize -= nb; - mchunkptr p = m->top; - mchunkptr r = m->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(m, p, nb); - check_top_chunk(m, m->top); - check_malloced_chunk(m, chunk2mem(p), nb); - return chunk2mem(p); + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; + mchunkptr p = m->top; + mchunkptr r = m->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + check_top_chunk(m, m->top); + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); + } } - } - MALLOC_FAILURE_ACTION; - return 0; + MALLOC_FAILURE_ACTION; + return 0; } /* ----------------------- system deallocation -------------------------- */ /* Unmap and unlink any mmapped segments that don't contain used chunks */ -static size_t release_unused_segments(mstate m) { - size_t released = 0; - msegmentptr pred = &m->seg; - msegmentptr sp = pred->next; - while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; - msegmentptr next = sp->next; - if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { - mchunkptr p = align_as_chunk(base); - size_t psize = chunksize(p); - /* Can unmap if first chunk holds entire segment and not pinned */ - if (!cinuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { - tchunkptr tp = (tchunkptr)p; - assert(segment_holds(sp, (char*)sp)); - if (p == m->dv) { - m->dv = 0; - m->dvsize = 0; - } - else { - unlink_large_chunk(m, tp); - } - if (CALL_MUNMAP(base, size) == 0) { - released += size; - m->footprint -= size; - /* unlink obsoleted record */ - sp = pred; - sp->next = next; - } - else { /* back out if cannot unmap */ - insert_large_chunk(m, tp, psize); +static size_t release_unused_segments(mstate m) +{ + size_t released = 0; + msegmentptr pred = &m->seg; + msegmentptr sp = pred->next; + while (sp != 0) + { + char* base = sp->base; + size_t size = sp->size; + msegmentptr next = sp->next; + if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { + mchunkptr p = align_as_chunk(base); + size_t psize = chunksize(p); + /* Can unmap if first chunk holds entire segment and not pinned */ + if (!cinuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { + tchunkptr tp = (tchunkptr)p; + assert(segment_holds(sp, (char*)sp)); + if (p == m->dv) { + m->dv = 0; + m->dvsize = 0; + } + else + { + unlink_large_chunk(m, tp); + } + if (CALL_MUNMAP(base, size) == 0) { + released += size; + m->footprint -= size; + /* unlink obsoleted record */ + sp = pred; + sp->next = next; + } + else + { /* back out if cannot unmap */ + insert_large_chunk(m, tp, psize); + } + } } - } + pred = sp; + sp = next; } - pred = sp; - sp = next; - } - return released; + return released; } -static int sys_trim(mstate m, size_t pad) { - size_t released = 0; - if (pad < MAX_REQUEST && is_initialized(m)) { - pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ - - if (m->topsize > pad) { - /* Shrink top space in granularity-size units, keeping at least one */ - size_t unit = mparams.granularity; - size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - - SIZE_T_ONE) * unit; - msegmentptr sp = segment_holding(m, (char*)m->top); - - if (!is_extern_segment(sp)) { - if (is_mmapped_segment(sp)) { - if (HAVE_MMAP && - sp->size >= extra && - !has_segment_link(m, sp)) { /* can't shrink if pinned */ - size_t newsize = sp->size - extra; - /* Prefer mremap, fall back to munmap */ - if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || - (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { - released = extra; +static int sys_trim(mstate m, size_t pad) +{ + size_t released = 0; + if (pad < MAX_REQUEST && is_initialized(m)) { + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + + if (m->topsize > pad) { + /* Shrink top space in granularity-size units, keeping at least one */ + size_t unit = mparams.granularity; + size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char*)m->top); + + if (!is_extern_segment(sp)) { + if (is_mmapped_segment(sp)) { + if (HAVE_MMAP && sp->size >= extra && !has_segment_link(m, sp)) { /* can't shrink if pinned */ + size_t newsize = sp->size - extra; + /* Prefer mremap, fall back to munmap */ + if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || + (CALL_MUNMAP(sp->base + newsize, extra) == 0)) + { + released = extra; + } + } + } + else if (HAVE_MORECORE) + { + if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ + extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; + ACQUIRE_MORECORE_LOCK(); + { + /* Make sure end of memory is where we last set it. */ + char* old_br = (char*)(CALL_MORECORE(0)); + if (old_br == sp->base + sp->size) { + char* rel_br = (char*)(CALL_MORECORE(-extra)); + char* new_br = (char*)(CALL_MORECORE(0)); + if (rel_br != CMFAIL && new_br < old_br) released = old_br - new_br; + } + } + RELEASE_MORECORE_LOCK(); + } } - } - } - else if (HAVE_MORECORE) { - if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ - extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; - ACQUIRE_MORECORE_LOCK(); - { - /* Make sure end of memory is where we last set it. */ - char* old_br = (char*)(CALL_MORECORE(0)); - if (old_br == sp->base + sp->size) { - char* rel_br = (char*)(CALL_MORECORE(-extra)); - char* new_br = (char*)(CALL_MORECORE(0)); - if (rel_br != CMFAIL && new_br < old_br) - released = old_br - new_br; + + if (released != 0) { + sp->size -= released; + m->footprint -= released; + init_top(m, m->top, m->topsize - released); + check_top_chunk(m, m->top); } - } - RELEASE_MORECORE_LOCK(); } - } - if (released != 0) { - sp->size -= released; - m->footprint -= released; - init_top(m, m->top, m->topsize - released); - check_top_chunk(m, m->top); - } - } - - /* Unmap any unused mmapped segments */ - if (HAVE_MMAP) - released += release_unused_segments(m); + /* Unmap any unused mmapped segments */ + if (HAVE_MMAP) released += release_unused_segments(m); - /* On failure, disable autotrim to avoid repeated failed future calls */ - if (released == 0) - m->trim_check = MAX_SIZE_T; - } + /* On failure, disable autotrim to avoid repeated failed future calls */ + if (released == 0) m->trim_check = MAX_SIZE_T; + } - return (released != 0)? 1 : 0; + return (released != 0) ? 1 : 0; } /* ---------------------------- malloc support --------------------------- */ /* allocate a large request from the best fitting chunk in a treebin */ -static void* tmalloc_large(mstate m, size_t nb) { - tchunkptr v = 0; - size_t rsize = -nb; /* Unsigned negation */ - tchunkptr t; - bindex_t idx; - compute_tree_index(nb, idx); - - if ((t = *treebin_at(m, idx)) != 0) { - /* Traverse tree for this bin looking for node with size == nb */ - size_t sizebits = nb << leftshift_for_tree_index(idx); - tchunkptr rst = 0; /* The deepest untaken right subtree */ - for (;;) { - tchunkptr rt; - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - v = t; - if ((rsize = trem) == 0) - break; - } - rt = t->child[1]; - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - if (rt != 0 && rt != t) - rst = rt; - if (t == 0) { - t = rst; /* set t to least subtree holding sizes > nb */ - break; - } - sizebits <<= 1; +static void* tmalloc_large(mstate m, size_t nb) +{ + tchunkptr v = 0; + size_t rsize = -nb; /* Unsigned negation */ + tchunkptr t; + bindex_t idx; + compute_tree_index(nb, idx); + + if ((t = *treebin_at(m, idx)) != 0) { + /* Traverse tree for this bin looking for node with size == nb */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ + for (;;) + { + tchunkptr rt; + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + v = t; + if ((rsize = trem) == 0) break; + } + rt = t->child[1]; + t = t->child[(sizebits >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) rst = rt; + if (t == 0) { + t = rst; /* set t to least subtree holding sizes > nb */ + break; + } + sizebits <<= 1; + } } - } - if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ - binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; - if (leftbits != 0) { - bindex_t i; - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - t = *treebin_at(m, i); + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; + if (leftbits != 0) { + bindex_t i; + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + t = *treebin_at(m, i); + } } - } - while (t != 0) { /* find smallest of tree or subtree */ - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - rsize = trem; - v = t; + while (t != 0) + { /* find smallest of tree or subtree */ + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + t = leftmost_child(t); } - t = leftmost_child(t); - } - /* If dv is a better fit, return 0 so malloc will use it */ - if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { - if (RTCHECK(ok_address(m, v))) { /* split */ - mchunkptr r = chunk_plus_offset(v, nb); - assert(chunksize(v) == rsize + nb); - if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(m, v, (rsize + nb)); - else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - insert_chunk(m, r, rsize); + /* If dv is a better fit, return 0 so malloc will use it */ + if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { + if (RTCHECK(ok_address(m, v))) { /* split */ + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else + { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + insert_chunk(m, r, rsize); + } + return chunk2mem(v); + } } - return chunk2mem(v); - } + CORRUPTION_ERROR_ACTION(m); } - CORRUPTION_ERROR_ACTION(m); - } - return 0; + return 0; } /* allocate a small request from the best fitting chunk in a treebin */ -static void* tmalloc_small(mstate m, size_t nb) { - tchunkptr t, v; - size_t rsize; - bindex_t i; - binmap_t leastbit = least_bit(m->treemap); - compute_bit2idx(leastbit, i); - - v = t = *treebin_at(m, i); - rsize = chunksize(t) - nb; - - while ((t = leftmost_child(t)) != 0) { - size_t trem = chunksize(t) - nb; - if (trem < rsize) { - rsize = trem; - v = t; +static void* tmalloc_small(mstate m, size_t nb) +{ + tchunkptr t, v; + size_t rsize; + bindex_t i; + binmap_t leastbit = least_bit(m->treemap); + compute_bit2idx(leastbit, i); + + v = t = *treebin_at(m, i); + rsize = chunksize(t) - nb; + + while ((t = leftmost_child(t)) != 0) + { + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } } - } - if (RTCHECK(ok_address(m, v))) { - mchunkptr r = chunk_plus_offset(v, nb); - assert(chunksize(v) == rsize + nb); - if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); - if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(m, v, (rsize + nb)); - else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(m, r, rsize); - } - return chunk2mem(v); + if (RTCHECK(ok_address(m, v))) { + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else + { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(m, r, rsize); + } + return chunk2mem(v); + } } - } - CORRUPTION_ERROR_ACTION(m); - return 0; + CORRUPTION_ERROR_ACTION(m); + return 0; } /* --------------------------- realloc support --------------------------- */ -static void* internal_realloc(mstate m, void* oldmem, size_t bytes) { - if (bytes >= MAX_REQUEST) { - MALLOC_FAILURE_ACTION; - return 0; - } - if (!PREACTION(m)) { - mchunkptr oldp = mem2chunk(oldmem); - size_t oldsize = chunksize(oldp); - mchunkptr next = chunk_plus_offset(oldp, oldsize); - mchunkptr newp = 0; - void* extra = 0; - - /* Try to either shrink or extend into top. Else malloc-copy-free */ - - if (RTCHECK(ok_address(m, oldp) && ok_cinuse(oldp) && - ok_next(oldp, next) && ok_pinuse(next))) { - size_t nb = request2size(bytes); - if (is_mmapped(oldp)) - newp = mmap_resize(m, oldp, nb); - else if (oldsize >= nb) { /* already big enough */ - size_t rsize = oldsize - nb; - newp = oldp; - if (rsize >= MIN_CHUNK_SIZE) { - mchunkptr remainder = chunk_plus_offset(newp, nb); - set_inuse(m, newp, nb); - set_inuse(m, remainder, rsize); - extra = chunk2mem(remainder); - } - } - else if (next == m->top && oldsize + m->topsize > nb) { - /* Expand into top */ - size_t newsize = oldsize + m->topsize; - size_t newtopsize = newsize - nb; - mchunkptr newtop = chunk_plus_offset(oldp, nb); - set_inuse(m, oldp, nb); - newtop->head = newtopsize |PINUSE_BIT; - m->top = newtop; - m->topsize = newtopsize; - newp = oldp; - } - } - else { - USAGE_ERROR_ACTION(m, oldmem); - POSTACTION(m); - return 0; +static void* internal_realloc(mstate m, void* oldmem, size_t bytes) +{ + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + return 0; } + if (!PREACTION(m)) { + mchunkptr oldp = mem2chunk(oldmem); + size_t oldsize = chunksize(oldp); + mchunkptr next = chunk_plus_offset(oldp, oldsize); + mchunkptr newp = 0; + void* extra = 0; + + /* Try to either shrink or extend into top. Else malloc-copy-free */ + + if (RTCHECK(ok_address(m, oldp) && ok_cinuse(oldp) && ok_next(oldp, next) && ok_pinuse(next))) { + size_t nb = request2size(bytes); + if (is_mmapped(oldp)) + newp = mmap_resize(m, oldp, nb); + else if (oldsize >= nb) + { /* already big enough */ + size_t rsize = oldsize - nb; + newp = oldp; + if (rsize >= MIN_CHUNK_SIZE) { + mchunkptr remainder = chunk_plus_offset(newp, nb); + set_inuse(m, newp, nb); + set_inuse(m, remainder, rsize); + extra = chunk2mem(remainder); + } + } + else if (next == m->top && oldsize + m->topsize > nb) + { + /* Expand into top */ + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; + mchunkptr newtop = chunk_plus_offset(oldp, nb); + set_inuse(m, oldp, nb); + newtop->head = newtopsize | PINUSE_BIT; + m->top = newtop; + m->topsize = newtopsize; + newp = oldp; + } + } + else + { + USAGE_ERROR_ACTION(m, oldmem); + POSTACTION(m); + return 0; + } - POSTACTION(m); + POSTACTION(m); - if (newp != 0) { - if (extra != 0) { - internal_free(m, extra); - } - check_inuse_chunk(m, newp); - return chunk2mem(newp); - } - else { - void* newmem = internal_malloc(m, bytes); - if (newmem != 0) { - size_t oc = oldsize - overhead_for(oldp); - memcpy(newmem, oldmem, (oc < bytes)? oc : bytes); - internal_free(m, oldmem); - } - return newmem; + if (newp != 0) { + if (extra != 0) { + internal_free(m, extra); + } + check_inuse_chunk(m, newp); + return chunk2mem(newp); + } + else + { + void* newmem = internal_malloc(m, bytes); + if (newmem != 0) { + size_t oc = oldsize - overhead_for(oldp); + memcpy(newmem, oldmem, (oc < bytes) ? oc : bytes); + internal_free(m, oldmem); + } + return newmem; + } } - } - return 0; + return 0; } /* --------------------------- memalign support -------------------------- */ -static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { - if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ - return internal_malloc(m, bytes); - if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ - alignment = MIN_CHUNK_SIZE; - if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ - size_t a = MALLOC_ALIGNMENT << 1; - while (a < alignment) a <<= 1; - alignment = a; - } - - if (bytes >= MAX_REQUEST - alignment) { - if (m != 0) { /* Test isn't needed but avoids compiler warning */ - MALLOC_FAILURE_ACTION; +static void* internal_memalign(mstate m, size_t alignment, size_t bytes) +{ + if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ + return internal_malloc(m, bytes); + if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ + alignment = MIN_CHUNK_SIZE; + if ((alignment & (alignment - SIZE_T_ONE)) != 0) { /* Ensure a power of 2 */ + size_t a = MALLOC_ALIGNMENT << 1; + while (a < alignment) + a <<= 1; + alignment = a; } - } - else { - size_t nb = request2size(bytes); - size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; - char* mem = (char*)internal_malloc(m, req); - if (mem != 0) { - void* leader = 0; - void* trailer = 0; - mchunkptr p = mem2chunk(mem); - - if (PREACTION(m)) return 0; - if ((((size_t)(mem)) % alignment) != 0) { /* misaligned */ - /* - Find an aligned spot inside chunk. Since we need to give - back leading space in a chunk of at least MIN_CHUNK_SIZE, if - the first calculation places us at a spot with less than - MIN_CHUNK_SIZE leader, we can move to the next aligned spot. - We've allocated enough total room so that this is always - possible. - */ - char* br = (char*)mem2chunk((size_t)(((size_t)(mem + - alignment - - SIZE_T_ONE)) & - -alignment)); - char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? - br : br+alignment; - mchunkptr newp = (mchunkptr)pos; - size_t leadsize = pos - (char*)(p); - size_t newsize = chunksize(p) - leadsize; - - if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ - newp->prev_foot = p->prev_foot + leadsize; - newp->head = (newsize|CINUSE_BIT); - } - else { /* Otherwise, give back leader, use the rest */ - set_inuse(m, newp, newsize); - set_inuse(m, p, leadsize); - leader = chunk2mem(p); - } - p = newp; - } - /* Give back spare room at the end */ - if (!is_mmapped(p)) { - size_t size = chunksize(p); - if (size > nb + MIN_CHUNK_SIZE) { - size_t remainder_size = size - nb; - mchunkptr remainder = chunk_plus_offset(p, nb); - set_inuse(m, p, nb); - set_inuse(m, remainder, remainder_size); - trailer = chunk2mem(remainder); + if (bytes >= MAX_REQUEST - alignment) { + if (m != 0) { /* Test isn't needed but avoids compiler warning */ + MALLOC_FAILURE_ACTION; } - } + } + else + { + size_t nb = request2size(bytes); + size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; + char* mem = (char*)internal_malloc(m, req); + if (mem != 0) { + void* leader = 0; + void* trailer = 0; + mchunkptr p = mem2chunk(mem); + + if (PREACTION(m)) return 0; + if ((((size_t)(mem)) % alignment) != 0) { /* misaligned */ + /* + Find an aligned spot inside chunk. Since we need to give + back leading space in a chunk of at least MIN_CHUNK_SIZE, if + the first calculation places us at a spot with less than + MIN_CHUNK_SIZE leader, we can move to the next aligned spot. + We've allocated enough total room so that this is always + possible. + */ + char* br = (char*)mem2chunk((size_t)(((size_t)(mem + alignment - SIZE_T_ONE)) & -alignment)); + char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE) ? br : br + alignment; + mchunkptr newp = (mchunkptr)pos; + size_t leadsize = pos - (char*)(p); + size_t newsize = chunksize(p) - leadsize; + + if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ + newp->prev_foot = p->prev_foot + leadsize; + newp->head = (newsize | CINUSE_BIT); + } + else + { /* Otherwise, give back leader, use the rest */ + set_inuse(m, newp, newsize); + set_inuse(m, p, leadsize); + leader = chunk2mem(p); + } + p = newp; + } - assert (chunksize(p) >= nb); - assert((((size_t)(chunk2mem(p))) % alignment) == 0); - check_inuse_chunk(m, p); - POSTACTION(m); - if (leader != 0) { - internal_free(m, leader); - } - if (trailer != 0) { - internal_free(m, trailer); - } - return chunk2mem(p); + /* Give back spare room at the end */ + if (!is_mmapped(p)) { + size_t size = chunksize(p); + if (size > nb + MIN_CHUNK_SIZE) { + size_t remainder_size = size - nb; + mchunkptr remainder = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, remainder, remainder_size); + trailer = chunk2mem(remainder); + } + } + + assert(chunksize(p) >= nb); + assert((((size_t)(chunk2mem(p))) % alignment) == 0); + check_inuse_chunk(m, p); + POSTACTION(m); + if (leader != 0) { + internal_free(m, leader); + } + if (trailer != 0) { + internal_free(m, trailer); + } + return chunk2mem(p); + } } - } - return 0; + return 0; } /* ------------------------ comalloc/coalloc support --------------------- */ -static void** ialloc(mstate m, - size_t n_elements, - size_t* sizes, - int opts, - void* chunks[]) { - /* - This provides common support for independent_X routines, handling - all of the combinations that can result. - - The opts arg has: - bit 0 set if all elements are same size (using sizes[0]) - bit 1 set if elements should be zeroed - */ - - size_t element_size; /* chunksize of each element, if all same */ - size_t contents_size; /* total size of elements */ - size_t array_size; /* request size of pointer array */ - void* mem; /* malloced aggregate space */ - mchunkptr p; /* corresponding chunk */ - size_t remainder_size; /* remaining bytes while splitting */ - void** marray; /* either "chunks" or malloced ptr array */ - mchunkptr array_chunk; /* chunk for malloced ptr array */ - flag_t was_enabled; /* to disable mmap */ - size_t size; - size_t i; - - /* compute array length, if needed */ - if (chunks != 0) { - if (n_elements == 0) - return chunks; /* nothing to do */ - marray = chunks; - array_size = 0; - } - else { - /* if empty req, must still return chunk representing empty array */ - if (n_elements == 0) - return (void**)internal_malloc(m, 0); - marray = 0; - array_size = request2size(n_elements * (sizeof(void*))); - } +static void** ialloc(mstate m, size_t n_elements, size_t* sizes, int opts, void* chunks[]) +{ + /* + This provides common support for independent_X routines, handling + all of the combinations that can result. - /* compute total element size */ - if (opts & 0x1) { /* all-same-size */ - element_size = request2size(*sizes); - contents_size = n_elements * element_size; - } - else { /* add up all the sizes */ - element_size = 0; - contents_size = 0; - for (i = 0; i != n_elements; ++i) - contents_size += request2size(sizes[i]); - } + The opts arg has: + bit 0 set if all elements are same size (using sizes[0]) + bit 1 set if elements should be zeroed + */ - size = contents_size + array_size; - - /* - Allocate the aggregate chunk. First disable direct-mmapping so - malloc won't use it, since we would not be able to later - free/realloc space internal to a segregated mmap region. - */ - was_enabled = use_mmap(m); - disable_mmap(m); - mem = internal_malloc(m, size - CHUNK_OVERHEAD); - if (was_enabled) - enable_mmap(m); - if (mem == 0) - return 0; + size_t element_size; /* chunksize of each element, if all same */ + size_t contents_size; /* total size of elements */ + size_t array_size; /* request size of pointer array */ + void* mem; /* malloced aggregate space */ + mchunkptr p; /* corresponding chunk */ + size_t remainder_size; /* remaining bytes while splitting */ + void** marray; /* either "chunks" or malloced ptr array */ + mchunkptr array_chunk; /* chunk for malloced ptr array */ + flag_t was_enabled; /* to disable mmap */ + size_t size; + size_t i; + + /* compute array length, if needed */ + if (chunks != 0) { + if (n_elements == 0) return chunks; /* nothing to do */ + marray = chunks; + array_size = 0; + } + else + { + /* if empty req, must still return chunk representing empty array */ + if (n_elements == 0) return (void**)internal_malloc(m, 0); + marray = 0; + array_size = request2size(n_elements * (sizeof(void*))); + } - if (PREACTION(m)) return 0; - p = mem2chunk(mem); - remainder_size = chunksize(p); + /* compute total element size */ + if (opts & 0x1) { /* all-same-size */ + element_size = request2size(*sizes); + contents_size = n_elements * element_size; + } + else + { /* add up all the sizes */ + element_size = 0; + contents_size = 0; + for (i = 0; i != n_elements; ++i) + contents_size += request2size(sizes[i]); + } - assert(!is_mmapped(p)); + size = contents_size + array_size; - if (opts & 0x2) { /* optionally clear the elements */ - memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); - } + /* + Allocate the aggregate chunk. First disable direct-mmapping so + malloc won't use it, since we would not be able to later + free/realloc space internal to a segregated mmap region. + */ + was_enabled = use_mmap(m); + disable_mmap(m); + mem = internal_malloc(m, size - CHUNK_OVERHEAD); + if (was_enabled) enable_mmap(m); + if (mem == 0) return 0; - /* If not provided, allocate the pointer array as final part of chunk */ - if (marray == 0) { - size_t array_chunk_size; - array_chunk = chunk_plus_offset(p, contents_size); - array_chunk_size = remainder_size - contents_size; - marray = (void**) (chunk2mem(array_chunk)); - set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); - remainder_size = contents_size; - } + if (PREACTION(m)) return 0; + p = mem2chunk(mem); + remainder_size = chunksize(p); - /* split out elements */ - for (i = 0; ; ++i) { - marray[i] = chunk2mem(p); - if (i != n_elements-1) { - if (element_size != 0) - size = element_size; - else - size = request2size(sizes[i]); - remainder_size -= size; - set_size_and_pinuse_of_inuse_chunk(m, p, size); - p = chunk_plus_offset(p, size); + assert(!is_mmapped(p)); + + if (opts & 0x2) { /* optionally clear the elements */ + memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); } - else { /* the final element absorbs any overallocation slop */ - set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); - break; + + /* If not provided, allocate the pointer array as final part of chunk */ + if (marray == 0) { + size_t array_chunk_size; + array_chunk = chunk_plus_offset(p, contents_size); + array_chunk_size = remainder_size - contents_size; + marray = (void**)(chunk2mem(array_chunk)); + set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); + remainder_size = contents_size; } - } -#if DEBUG - if (marray != chunks) { - /* final element must have exactly exhausted chunk */ - if (element_size != 0) { - assert(remainder_size == element_size); + /* split out elements */ + for (i = 0;; ++i) + { + marray[i] = chunk2mem(p); + if (i != n_elements - 1) { + if (element_size != 0) + size = element_size; + else + size = request2size(sizes[i]); + remainder_size -= size; + set_size_and_pinuse_of_inuse_chunk(m, p, size); + p = chunk_plus_offset(p, size); + } + else + { /* the final element absorbs any overallocation slop */ + set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); + break; + } } - else { - assert(remainder_size == request2size(sizes[i])); + +#if DEBUG + if (marray != chunks) { + /* final element must have exactly exhausted chunk */ + if (element_size != 0) { + assert(remainder_size == element_size); + } + else + { + assert(remainder_size == request2size(sizes[i])); + } + check_inuse_chunk(m, mem2chunk(marray)); } - check_inuse_chunk(m, mem2chunk(marray)); - } - for (i = 0; i != n_elements; ++i) - check_inuse_chunk(m, mem2chunk(marray[i])); + for (i = 0; i != n_elements; ++i) + check_inuse_chunk(m, mem2chunk(marray[i])); #endif /* DEBUG */ - POSTACTION(m); - return marray; + POSTACTION(m); + return marray; } - /* -------------------------- public routines ---------------------------- */ #if !ONLY_MSPACES -void* dlmalloc(size_t bytes) { - /* - Basic algorithm: - If a small request (< 256 bytes minus per-chunk overhead): - 1. If one exists, use a remainderless chunk in associated smallbin. - (Remainderless means that there are too few excess bytes to - represent as a chunk.) - 2. If it is big enough, use the dv chunk, which is normally the - chunk adjacent to the one used for the most recent small request. - 3. If one exists, split the smallest available chunk in a bin, - saving remainder in dv. - 4. If it is big enough, use the top chunk. - 5. If available, get memory from system and use it - Otherwise, for a large request: - 1. Find the smallest available binned chunk that fits, and use it - if it is better fitting than dv chunk, splitting if necessary. - 2. If better fitting than any binned chunk, use the dv chunk. - 3. If it is big enough, use the top chunk. - 4. If request size >= mmap threshold, try to directly mmap this chunk. - 5. If available, get memory from system and use it - - The ugly goto's here ensure that postaction occurs along all paths. - */ - - if (!PREACTION(gm)) { - void* mem; - size_t nb; - if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; - binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); - idx = small_index(nb); - smallbits = gm->smallmap >> idx; - - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ - mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at(gm, idx); - p = b->fd; - assert(chunksize(p) == small_index2size(idx)); - unlink_first_small_chunk(gm, b, p, idx); - set_inuse_and_pinuse(gm, p, small_index2size(idx)); - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } +void* dlmalloc(size_t bytes) +{ + /* + Basic algorithm: + If a small request (< 256 bytes minus per-chunk overhead): + 1. If one exists, use a remainderless chunk in associated smallbin. + (Remainderless means that there are too few excess bytes to + represent as a chunk.) + 2. If it is big enough, use the dv chunk, which is normally the + chunk adjacent to the one used for the most recent small request. + 3. If one exists, split the smallest available chunk in a bin, + saving remainder in dv. + 4. If it is big enough, use the top chunk. + 5. If available, get memory from system and use it + Otherwise, for a large request: + 1. Find the smallest available binned chunk that fits, and use it + if it is better fitting than dv chunk, splitting if necessary. + 2. If better fitting than any binned chunk, use the dv chunk. + 3. If it is big enough, use the top chunk. + 4. If request size >= mmap threshold, try to directly mmap this chunk. + 5. If available, get memory from system and use it + + The ugly goto's here ensure that postaction occurs along all paths. + */ - else if (nb > gm->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ - mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - b = smallbin_at(gm, i); - p = b->fd; - assert(chunksize(p) == small_index2size(i)); - unlink_first_small_chunk(gm, b, p, i); - rsize = small_index2size(i) - nb; - /* Fit here cannot be remainderless if 4byte sizes */ - if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(gm, p, small_index2size(i)); - else { - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - r = chunk_plus_offset(p, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(gm, r, rsize); - } - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } + if (!PREACTION(gm)) { + void* mem; + size_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = gm->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(gm, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(gm, b, p, idx); + set_inuse_and_pinuse(gm, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } - else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); - goto postaction; + else if (nb > gm->dvsize) + { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(gm, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(gm, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(gm, p, small_index2size(i)); + else + { + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(gm, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) + { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else + { + nb = pad_request(bytes); + if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } } - } - } - else if (bytes >= MAX_REQUEST) - nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ - else { - nb = pad_request(bytes); - if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); - goto postaction; - } - } - if (nb <= gm->dvsize) { - size_t rsize = gm->dvsize - nb; - mchunkptr p = gm->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = gm->dv = chunk_plus_offset(p, nb); - gm->dvsize = rsize; - set_size_and_pinuse_of_free_chunk(r, rsize); - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - } - else { /* exhaust dv */ - size_t dvs = gm->dvsize; - gm->dvsize = 0; - gm->dv = 0; - set_inuse_and_pinuse(gm, p, dvs); - } - mem = chunk2mem(p); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } + if (nb <= gm->dvsize) { + size_t rsize = gm->dvsize - nb; + mchunkptr p = gm->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = gm->dv = chunk_plus_offset(p, nb); + gm->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + } + else + { /* exhaust dv */ + size_t dvs = gm->dvsize; + gm->dvsize = 0; + gm->dv = 0; + set_inuse_and_pinuse(gm, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } - else if (nb < gm->topsize) { /* Split top */ - size_t rsize = gm->topsize -= nb; - mchunkptr p = gm->top; - mchunkptr r = gm->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - mem = chunk2mem(p); - check_top_chunk(gm, gm->top); - check_malloced_chunk(gm, mem, nb); - goto postaction; - } + else if (nb < gm->topsize) + { /* Split top */ + size_t rsize = gm->topsize -= nb; + mchunkptr p = gm->top; + mchunkptr r = gm->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + mem = chunk2mem(p); + check_top_chunk(gm, gm->top); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } - mem = sys_alloc(gm, nb); + mem = sys_alloc(gm, nb); - postaction: - POSTACTION(gm); - return mem; - } + postaction: + POSTACTION(gm); + return mem; + } - return 0; + return 0; } -void dlfree(void* mem) { - /* - Consolidate freed chunks with preceeding or succeeding bordering - free chunks, if they exist, and then place in a bin. Intermixed - with special cases for top, dv, mmapped chunks, and usage errors. - */ +void dlfree(void* mem) +{ + /* + Consolidate freed chunks with preceeding or succeeding bordering + free chunks, if they exist, and then place in a bin. Intermixed + with special cases for top, dv, mmapped chunks, and usage errors. + */ - if (mem != 0) { - mchunkptr p = mem2chunk(mem); + if (mem != 0) { + mchunkptr p = mem2chunk(mem); #if FOOTERS - mstate fm = get_mstate_for(p); - if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); - return; - } + mstate fm = get_mstate_for(p); + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; + } #else /* FOOTERS */ #define fm gm #endif /* FOOTERS */ - if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); - if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { - size_t psize = chunksize(p); - mchunkptr next = chunk_plus_offset(p, psize); - if (!pinuse(p)) { - size_t prevsize = p->prev_foot; - if ((prevsize & IS_MMAPPED_BIT) != 0) { - prevsize &= ~IS_MMAPPED_BIT; - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - fm->footprint -= psize; - goto postaction; - } - else { - mchunkptr prev = chunk_minus_offset(p, prevsize); - psize += prevsize; - p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ - if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { - fm->dvsize = psize; - set_free_with_pinuse(p, psize, next); - goto postaction; - } - } - else - goto erroraction; - } - } - - if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ - if (next == fm->top) { - size_t tsize = fm->topsize += psize; - fm->top = p; - p->head = tsize | PINUSE_BIT; - if (p == fm->dv) { - fm->dv = 0; - fm->dvsize = 0; - } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); - goto postaction; + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if ((prevsize & IS_MMAPPED_BIT) != 0) { + prevsize &= ~IS_MMAPPED_BIT; + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) fm->footprint -= psize; + goto postaction; + } + else + { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) + { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) + { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else + { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + insert_chunk(fm, p, psize); + check_free_chunk(fm, p); + goto postaction; + } } - else if (next == fm->dv) { - size_t dsize = fm->dvsize += psize; - fm->dv = p; - set_size_and_pinuse_of_free_chunk(p, dsize); - goto postaction; - } - else { - size_t nsize = chunksize(next); - psize += nsize; - unlink_chunk(fm, next, nsize); - set_size_and_pinuse_of_free_chunk(p, psize); - if (p == fm->dv) { - fm->dvsize = psize; - goto postaction; - } - } - } - else - set_free_with_pinuse(p, psize, next); - insert_chunk(fm, p, psize); - check_free_chunk(fm, p); - goto postaction; + erroraction: + USAGE_ERROR_ACTION(fm, p); + postaction: + POSTACTION(fm); } - } - erroraction: - USAGE_ERROR_ACTION(fm, p); - postaction: - POSTACTION(fm); } - } #if !FOOTERS #undef fm #endif /* FOOTERS */ } -void* dlcalloc(size_t n_elements, size_t elem_size) { - void* mem; - size_t req = 0; - if (n_elements != 0) { - req = n_elements * elem_size; - if (((n_elements | elem_size) & ~(size_t)0xffff) && - (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - } - mem = dlmalloc(req); - if (mem != 0 && calloc_must_clear(mem2chunk(mem))) - memset(mem, 0, req); - return mem; +void* dlcalloc(size_t n_elements, size_t elem_size) +{ + void* mem; + size_t req = 0; + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = dlmalloc(req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) memset(mem, 0, req); + return mem; } -void* dlrealloc(void* oldmem, size_t bytes) { - if (oldmem == 0) - return dlmalloc(bytes); +void* dlrealloc(void* oldmem, size_t bytes) +{ + if (oldmem == 0) return dlmalloc(bytes); #ifdef REALLOC_ZERO_BYTES_FREES - if (bytes == 0) { - dlfree(oldmem); - return 0; - } -#endif /* REALLOC_ZERO_BYTES_FREES */ - else { -#if ! FOOTERS - mstate m = gm; -#else /* FOOTERS */ - mstate m = get_mstate_for(mem2chunk(oldmem)); - if (!ok_magic(m)) { - USAGE_ERROR_ACTION(m, oldmem); - return 0; + if (bytes == 0) { + dlfree(oldmem); + return 0; } +#endif /* REALLOC_ZERO_BYTES_FREES */ + else + { +#if !FOOTERS + mstate m = gm; +#else /* FOOTERS */ + mstate m = get_mstate_for(mem2chunk(oldmem)); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } #endif /* FOOTERS */ - return internal_realloc(m, oldmem, bytes); - } + return internal_realloc(m, oldmem, bytes); + } } -void* dlmemalign(size_t alignment, size_t bytes) { - return internal_memalign(gm, alignment, bytes); +void* dlmemalign(size_t alignment, size_t bytes) +{ + return internal_memalign(gm, alignment, bytes); } -void** dlindependent_calloc(size_t n_elements, size_t elem_size, - void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ - return ialloc(gm, n_elements, &sz, 3, chunks); +void** dlindependent_calloc(size_t n_elements, size_t elem_size, void* chunks[]) +{ + size_t sz = elem_size; /* serves as 1-element array */ + return ialloc(gm, n_elements, &sz, 3, chunks); } -void** dlindependent_comalloc(size_t n_elements, size_t sizes[], - void* chunks[]) { - return ialloc(gm, n_elements, sizes, 0, chunks); +void** dlindependent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]) +{ + return ialloc(gm, n_elements, sizes, 0, chunks); } -void* dlvalloc(size_t bytes) { - size_t pagesz; - init_mparams(); - pagesz = mparams.page_size; - return dlmemalign(pagesz, bytes); +void* dlvalloc(size_t bytes) +{ + size_t pagesz; + init_mparams(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, bytes); } -void* dlpvalloc(size_t bytes) { - size_t pagesz; - init_mparams(); - pagesz = mparams.page_size; - return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); +void* dlpvalloc(size_t bytes) +{ + size_t pagesz; + init_mparams(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); } -int dlmalloc_trim(size_t pad) { - int result = 0; - if (!PREACTION(gm)) { - result = sys_trim(gm, pad); - POSTACTION(gm); - } - return result; +int dlmalloc_trim(size_t pad) +{ + int result = 0; + if (!PREACTION(gm)) { + result = sys_trim(gm, pad); + POSTACTION(gm); + } + return result; } -size_t dlmalloc_footprint(void) { - return gm->footprint; +size_t dlmalloc_footprint(void) +{ + return gm->footprint; } -size_t dlmalloc_max_footprint(void) { - return gm->max_footprint; +size_t dlmalloc_max_footprint(void) +{ + return gm->max_footprint; } #if !NO_MALLINFO -struct mallinfo dlmallinfo(void) { - return internal_mallinfo(gm); +struct mallinfo dlmallinfo(void) +{ + return internal_mallinfo(gm); } #endif /* NO_MALLINFO */ -void dlmalloc_stats() { - internal_malloc_stats(gm); +void dlmalloc_stats() +{ + internal_malloc_stats(gm); } -size_t dlmalloc_usable_size(void* mem) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); - if (cinuse(p)) - return chunksize(p) - overhead_for(p); - } - return 0; +size_t dlmalloc_usable_size(void* mem) +{ + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (cinuse(p)) return chunksize(p) - overhead_for(p); + } + return 0; } -int dlmallopt(int param_number, int value) { - return change_mparam(param_number, value); +int dlmallopt(int param_number, int value) +{ + return change_mparam(param_number, value); } #endif /* !ONLY_MSPACES */ @@ -4368,78 +4403,80 @@ int dlmallopt(int param_number, int value) { #if MSPACES -static mstate init_user_mstate(char* tbase, size_t tsize) { - size_t msize = pad_request(sizeof(struct malloc_state)); - mchunkptr mn; - mchunkptr msp = align_as_chunk(tbase); - mstate m = (mstate)(chunk2mem(msp)); - memset(m, 0, msize); - INITIAL_LOCK(&m->mutex); - msp->head = (msize|PINUSE_BIT|CINUSE_BIT); - m->seg.base = m->least_addr = tbase; - m->seg.size = m->footprint = m->max_footprint = tsize; - m->magic = mparams.magic; - m->mflags = mparams.default_mflags; - disable_contiguous(m); - init_bins(m); - mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); - check_top_chunk(m, m->top); - return m; +static mstate init_user_mstate(char* tbase, size_t tsize) +{ + size_t msize = pad_request(sizeof(struct malloc_state)); + mchunkptr mn; + mchunkptr msp = align_as_chunk(tbase); + mstate m = (mstate)(chunk2mem(msp)); + memset(m, 0, msize); + INITIAL_LOCK(&m->mutex); + msp->head = (msize | PINUSE_BIT | CINUSE_BIT); + m->seg.base = m->least_addr = tbase; + m->seg.size = m->footprint = m->max_footprint = tsize; + m->magic = mparams.magic; + m->mflags = mparams.default_mflags; + disable_contiguous(m); + init_bins(m); + mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); + check_top_chunk(m, m->top); + return m; } -mspace create_mspace(size_t capacity, int locked) { - mstate m = 0; - size_t msize = pad_request(sizeof(struct malloc_state)); - init_mparams(); /* Ensure pagesize etc initialized */ - - if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - size_t rs = ((capacity == 0)? mparams.granularity : - (capacity + TOP_FOOT_SIZE + msize)); - size_t tsize = granularity_align(rs); - char* tbase = (char*)(CALL_MMAP(tsize)); - if (tbase != CMFAIL) { - m = init_user_mstate(tbase, tsize); - m->seg.sflags = IS_MMAPPED_BIT; - set_lock(m, locked); +mspace create_mspace(size_t capacity, int locked) +{ + mstate m = 0; + size_t msize = pad_request(sizeof(struct malloc_state)); + init_mparams(); /* Ensure pagesize etc initialized */ + + if (capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { + size_t rs = ((capacity == 0) ? mparams.granularity : (capacity + TOP_FOOT_SIZE + msize)); + size_t tsize = granularity_align(rs); + char* tbase = (char*)(CALL_MMAP(tsize)); + if (tbase != CMFAIL) { + m = init_user_mstate(tbase, tsize); + m->seg.sflags = IS_MMAPPED_BIT; + set_lock(m, locked); + } } - } - return (mspace)m; + return (mspace)m; } -mspace create_mspace_with_base(void* base, size_t capacity, int locked) { - mstate m = 0; - size_t msize = pad_request(sizeof(struct malloc_state)); - init_mparams(); /* Ensure pagesize etc initialized */ +mspace create_mspace_with_base(void* base, size_t capacity, int locked) +{ + mstate m = 0; + size_t msize = pad_request(sizeof(struct malloc_state)); + init_mparams(); /* Ensure pagesize etc initialized */ - if (capacity > msize + TOP_FOOT_SIZE && - capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - m = init_user_mstate((char*)base, capacity); - m->seg.sflags = EXTERN_BIT; - set_lock(m, locked); - } - return (mspace)m; + if (capacity > msize + TOP_FOOT_SIZE && capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { + m = init_user_mstate((char*)base, capacity); + m->seg.sflags = EXTERN_BIT; + set_lock(m, locked); + } + return (mspace)m; } -size_t destroy_mspace(mspace msp) { - size_t freed = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - msegmentptr sp = &ms->seg; - while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; - flag_t flag = sp->sflags; - sp = sp->next; - if ((flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) && - CALL_MUNMAP(base, size) == 0) - freed += size; +size_t destroy_mspace(mspace msp) +{ + size_t freed = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + msegmentptr sp = &ms->seg; + while (sp != 0) + { + char* base = sp->base; + size_t size = sp->size; + flag_t flag = sp->sflags; + sp = sp->next; + if ((flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) && CALL_MUNMAP(base, size) == 0) freed += size; + } } - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return freed; + else + { + USAGE_ERROR_ACTION(ms, ms); + } + return freed; } /* @@ -4447,345 +4484,361 @@ size_t destroy_mspace(mspace msp) { versions. This is not so nice but better than the alternatives. */ +void* mspace_malloc(mspace msp, size_t bytes) +{ + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); + return 0; + } + if (!PREACTION(ms)) { + void* mem; + size_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = ms->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(ms, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(ms, b, p, idx); + set_inuse_and_pinuse(ms, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } -void* mspace_malloc(mspace msp, size_t bytes) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - if (!PREACTION(ms)) { - void* mem; - size_t nb; - if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; - binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); - idx = small_index(nb); - smallbits = ms->smallmap >> idx; - - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ - mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at(ms, idx); - p = b->fd; - assert(chunksize(p) == small_index2size(idx)); - unlink_first_small_chunk(ms, b, p, idx); - set_inuse_and_pinuse(ms, p, small_index2size(idx)); - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } + else if (nb > ms->dvsize) + { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(ms, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(ms, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(ms, p, small_index2size(i)); + else + { + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(ms, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) + { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else + { + nb = pad_request(bytes); + if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } - else if (nb > ms->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ - mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); - compute_bit2idx(leastbit, i); - b = smallbin_at(ms, i); - p = b->fd; - assert(chunksize(p) == small_index2size(i)); - unlink_first_small_chunk(ms, b, p, i); - rsize = small_index2size(i) - nb; - /* Fit here cannot be remainderless if 4byte sizes */ - if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse(ms, p, small_index2size(i)); - else { - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - r = chunk_plus_offset(p, nb); - set_size_and_pinuse_of_free_chunk(r, rsize); - replace_dv(ms, r, rsize); - } - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; + if (nb <= ms->dvsize) { + size_t rsize = ms->dvsize - nb; + mchunkptr p = ms->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = ms->dv = chunk_plus_offset(p, nb); + ms->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + } + else + { /* exhaust dv */ + size_t dvs = ms->dvsize; + ms->dvsize = 0; + ms->dv = 0; + set_inuse_and_pinuse(ms, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; } - else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); - goto postaction; + else if (nb < ms->topsize) + { /* Split top */ + size_t rsize = ms->topsize -= nb; + mchunkptr p = ms->top; + mchunkptr r = ms->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + mem = chunk2mem(p); + check_top_chunk(ms, ms->top); + check_malloced_chunk(ms, mem, nb); + goto postaction; } - } - } - else if (bytes >= MAX_REQUEST) - nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ - else { - nb = pad_request(bytes); - if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); - goto postaction; - } - } - if (nb <= ms->dvsize) { - size_t rsize = ms->dvsize - nb; - mchunkptr p = ms->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = ms->dv = chunk_plus_offset(p, nb); - ms->dvsize = rsize; - set_size_and_pinuse_of_free_chunk(r, rsize); - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - } - else { /* exhaust dv */ - size_t dvs = ms->dvsize; - ms->dvsize = 0; - ms->dv = 0; - set_inuse_and_pinuse(ms, p, dvs); - } - mem = chunk2mem(p); - check_malloced_chunk(ms, mem, nb); - goto postaction; - } + mem = sys_alloc(ms, nb); - else if (nb < ms->topsize) { /* Split top */ - size_t rsize = ms->topsize -= nb; - mchunkptr p = ms->top; - mchunkptr r = ms->top = chunk_plus_offset(p, nb); - r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - mem = chunk2mem(p); - check_top_chunk(ms, ms->top); - check_malloced_chunk(ms, mem, nb); - goto postaction; + postaction: + POSTACTION(ms); + return mem; } - mem = sys_alloc(ms, nb); - - postaction: - POSTACTION(ms); - return mem; - } - - return 0; + return 0; } -void mspace_free(mspace msp, void* mem) { - if (mem != 0) { - mchunkptr p = mem2chunk(mem); +void mspace_free(mspace msp, void* mem) +{ + if (mem != 0) { + mchunkptr p = mem2chunk(mem); #if FOOTERS - mstate fm = get_mstate_for(p); -#else /* FOOTERS */ - mstate fm = (mstate)msp; + mstate fm = get_mstate_for(p); +#else /* FOOTERS */ + mstate fm = (mstate)msp; #endif /* FOOTERS */ - if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); - return; - } - if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); - if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { - size_t psize = chunksize(p); - mchunkptr next = chunk_plus_offset(p, psize); - if (!pinuse(p)) { - size_t prevsize = p->prev_foot; - if ((prevsize & IS_MMAPPED_BIT) != 0) { - prevsize &= ~IS_MMAPPED_BIT; - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - fm->footprint -= psize; - goto postaction; - } - else { - mchunkptr prev = chunk_minus_offset(p, prevsize); - psize += prevsize; - p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ - if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { - fm->dvsize = psize; - set_free_with_pinuse(p, psize, next); - goto postaction; - } - } - else - goto erroraction; - } + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; } - - if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ - if (next == fm->top) { - size_t tsize = fm->topsize += psize; - fm->top = p; - p->head = tsize | PINUSE_BIT; - if (p == fm->dv) { - fm->dv = 0; - fm->dvsize = 0; - } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); - goto postaction; - } - else if (next == fm->dv) { - size_t dsize = fm->dvsize += psize; - fm->dv = p; - set_size_and_pinuse_of_free_chunk(p, dsize); - goto postaction; - } - else { - size_t nsize = chunksize(next); - psize += nsize; - unlink_chunk(fm, next, nsize); - set_size_and_pinuse_of_free_chunk(p, psize); - if (p == fm->dv) { - fm->dvsize = psize; - goto postaction; - } + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if ((prevsize & IS_MMAPPED_BIT) != 0) { + prevsize &= ~IS_MMAPPED_BIT; + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) fm->footprint -= psize; + goto postaction; + } + else + { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) + { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) + { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else + { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + insert_chunk(fm, p, psize); + check_free_chunk(fm, p); + goto postaction; + } } - } - else - set_free_with_pinuse(p, psize, next); - insert_chunk(fm, p, psize); - check_free_chunk(fm, p); - goto postaction; + erroraction: + USAGE_ERROR_ACTION(fm, p); + postaction: + POSTACTION(fm); } - } - erroraction: - USAGE_ERROR_ACTION(fm, p); - postaction: - POSTACTION(fm); } - } } -void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { - void* mem; - size_t req = 0; - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - if (n_elements != 0) { - req = n_elements * elem_size; - if (((n_elements | elem_size) & ~(size_t)0xffff) && - (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - } - mem = internal_malloc(ms, req); - if (mem != 0 && calloc_must_clear(mem2chunk(mem))) - memset(mem, 0, req); - return mem; +void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) +{ + void* mem; + size_t req = 0; + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); + return 0; + } + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = internal_malloc(ms, req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) memset(mem, 0, req); + return mem; } -void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { - if (oldmem == 0) - return mspace_malloc(msp, bytes); +void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) +{ + if (oldmem == 0) return mspace_malloc(msp, bytes); #ifdef REALLOC_ZERO_BYTES_FREES - if (bytes == 0) { - mspace_free(msp, oldmem); - return 0; - } + if (bytes == 0) { + mspace_free(msp, oldmem); + return 0; + } #endif /* REALLOC_ZERO_BYTES_FREES */ - else { + else + { #if FOOTERS - mchunkptr p = mem2chunk(oldmem); - mstate ms = get_mstate_for(p); -#else /* FOOTERS */ - mstate ms = (mstate)msp; + mchunkptr p = mem2chunk(oldmem); + mstate ms = get_mstate_for(p); +#else /* FOOTERS */ + mstate ms = (mstate)msp; #endif /* FOOTERS */ - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); + return 0; + } + return internal_realloc(ms, oldmem, bytes); } - return internal_realloc(ms, oldmem, bytes); - } } -void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return internal_memalign(ms, alignment, bytes); +void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) +{ + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); + return 0; + } + return internal_memalign(ms, alignment, bytes); } -void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return ialloc(ms, n_elements, &sz, 3, chunks); +void** mspace_independent_calloc(mspace msp, size_t n_elements, size_t elem_size, void* chunks[]) +{ + size_t sz = elem_size; /* serves as 1-element array */ + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); + return 0; + } + return ialloc(ms, n_elements, &sz, 3, chunks); } -void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - return 0; - } - return ialloc(ms, n_elements, sizes, 0, chunks); +void** mspace_independent_comalloc(mspace msp, size_t n_elements, size_t sizes[], void* chunks[]) +{ + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); + return 0; + } + return ialloc(ms, n_elements, sizes, 0, chunks); } -int mspace_trim(mspace msp, size_t pad) { - int result = 0; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - if (!PREACTION(ms)) { - result = sys_trim(ms, pad); - POSTACTION(ms); +int mspace_trim(mspace msp, size_t pad) +{ + int result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + if (!PREACTION(ms)) { + result = sys_trim(ms, pad); + POSTACTION(ms); + } } - } - else { - USAGE_ERROR_ACTION(ms,ms); - } - return result; + else + { + USAGE_ERROR_ACTION(ms, ms); + } + return result; } -void mspace_malloc_stats(mspace msp) { - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - internal_malloc_stats(ms); - } - else { - USAGE_ERROR_ACTION(ms,ms); - } +void mspace_malloc_stats(mspace msp) +{ + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + internal_malloc_stats(ms); + } + else + { + USAGE_ERROR_ACTION(ms, ms); + } } -size_t mspace_footprint(mspace msp) { - size_t result; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - result = ms->footprint; - } - USAGE_ERROR_ACTION(ms,ms); - return result; +size_t mspace_footprint(mspace msp) +{ + size_t result; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->footprint; + } + USAGE_ERROR_ACTION(ms, ms); + return result; } - -size_t mspace_max_footprint(mspace msp) { - size_t result; - mstate ms = (mstate)msp; - if (ok_magic(ms)) { - result = ms->max_footprint; - } - USAGE_ERROR_ACTION(ms,ms); - return result; +size_t mspace_max_footprint(mspace msp) +{ + size_t result; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->max_footprint; + } + USAGE_ERROR_ACTION(ms, ms); + return result; } - #if !NO_MALLINFO -struct mallinfo mspace_mallinfo(mspace msp) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - } - return internal_mallinfo(ms); +struct mallinfo mspace_mallinfo(mspace msp) +{ + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); + } + return internal_mallinfo(ms); } #endif /* NO_MALLINFO */ -int mspace_mallopt(int param_number, int value) { - return change_mparam(param_number, value); +int mspace_mallopt(int param_number, int value) +{ + return change_mparam(param_number, value); } #endif /* MSPACES */ @@ -4881,7 +4934,6 @@ int mspace_mallopt(int param_number, int value) { */ - /* ----------------------------------------------------------------------- History: V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) @@ -5060,5 +5112,5 @@ int mspace_mallopt(int param_number, int value) { Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) * Based loosely on libg++-1.2X malloc. (It retains some of the overall structure of old version, but most details differ.) - + */ diff --git a/src/xrServerEntities/doug_lea_memory_allocator.h b/src/xrServerEntities/doug_lea_memory_allocator.h index 7450fa94352..1f60fd3a0d9 100644 --- a/src/xrServerEntities/doug_lea_memory_allocator.h +++ b/src/xrServerEntities/doug_lea_memory_allocator.h @@ -1,14 +1,14 @@ /* Default header file for malloc-2.8.x, written by Doug Lea and released to the public domain, as explained at - http://creativecommons.org/licenses/publicdomain. - + http://creativecommons.org/licenses/publicdomain. + last update: Mon Aug 15 08:55:52 2005 Doug Lea (dl at gee) This header is for ANSI C/C++ only. You can set any of the following #defines before including: - * If USE_DL_PREFIX is defined, it is assumed that malloc.c + * If USE_DL_PREFIX is defined, it is assumed that malloc.c was also compiled with this option, so all routines have names starting with "dl". @@ -29,31 +29,30 @@ extern "C" { #endif -#include /* for size_t */ +#include /* for size_t */ #if !ONLY_MSPACES #define USE_DL_PREFIX #ifndef USE_DL_PREFIX -#define dlcalloc calloc -#define dlfree free -#define dlmalloc malloc -#define dlmemalign memalign -#define dlrealloc realloc -#define dlvalloc valloc -#define dlpvalloc pvalloc -#define dlmallinfo mallinfo -#define dlmallopt mallopt -#define dlmalloc_trim malloc_trim -#define dlmalloc_stats malloc_stats -#define dlmalloc_usable_size malloc_usable_size -#define dlmalloc_footprint malloc_footprint -#define dlindependent_calloc independent_calloc +#define dlcalloc calloc +#define dlfree free +#define dlmalloc malloc +#define dlmemalign memalign +#define dlrealloc realloc +#define dlvalloc valloc +#define dlpvalloc pvalloc +#define dlmallinfo mallinfo +#define dlmallopt mallopt +#define dlmalloc_trim malloc_trim +#define dlmalloc_stats malloc_stats +#define dlmalloc_usable_size malloc_usable_size +#define dlmalloc_footprint malloc_footprint +#define dlindependent_calloc independent_calloc #define dlindependent_comalloc independent_comalloc #endif /* USE_DL_PREFIX */ - /* malloc(size_t n) Returns a pointer to a newly allocated chunk of at least n bytes, or @@ -77,7 +76,7 @@ void* dlmalloc(size_t); It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cuase the current program to abort. */ -void dlfree(void*); +void dlfree(void*); /* calloc(size_t n_elements, size_t element_size); @@ -150,10 +149,9 @@ void* dlvalloc(size_t); */ int dlmallopt(int, int); -#define M_TRIM_THRESHOLD (-1) -#define M_GRANULARITY (-2) -#define M_MMAP_THRESHOLD (-3) - +#define M_TRIM_THRESHOLD (-1) +#define M_GRANULARITY (-2) +#define M_MMAP_THRESHOLD (-3) /* malloc_footprint(); @@ -189,28 +187,29 @@ size_t dlmalloc_footprint(); be kept as longs, the reported values may wrap around zero and thus be inaccurate. */ -#if 1//ndef HAVE_USR_INCLUDE_MALLOC_H -#if 1//ndef _MALLOC_H +#if 1 // ndef HAVE_USR_INCLUDE_MALLOC_H +#if 1 // ndef _MALLOC_H #ifndef MALLINFO_FIELD_TYPE #define MALLINFO_FIELD_TYPE size_t #endif /* MALLINFO_FIELD_TYPE */ -struct mallinfo { - MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ - MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ - MALLINFO_FIELD_TYPE smblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ - MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ - MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ - MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ - MALLINFO_FIELD_TYPE fordblks; /* total free space */ - MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ +struct mallinfo +{ + MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ + MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ + MALLINFO_FIELD_TYPE smblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ + MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ + MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ + MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ + MALLINFO_FIELD_TYPE fordblks; /* total free space */ + MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ }; -#endif /* _MALLOC_H */ -#endif /* HAVE_USR_INCLUDE_MALLOC_H */ +#endif /* _MALLOC_H */ +#endif /* HAVE_USR_INCLUDE_MALLOC_H */ struct mallinfo dlmallinfo(void); -#endif /* NO_MALLINFO */ +#endif /* NO_MALLINFO */ /* independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); @@ -327,13 +326,12 @@ void** dlindependent_calloc(size_t, size_t, void**); */ void** dlindependent_comalloc(size_t, size_t*, void**); - /* pvalloc(size_t n); Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize. */ -void* dlpvalloc(size_t); +void* dlpvalloc(size_t); /* malloc_trim(size_t pad); @@ -356,7 +354,7 @@ void* dlpvalloc(size_t); Malloc_trim returns 1 if it actually released any memory, else 0. */ -int dlmalloc_trim(size_t); +int dlmalloc_trim(size_t); /* malloc_usable_size(void* p); @@ -393,7 +391,7 @@ size_t dlmalloc_usable_size(void*); malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo. */ -void dlmalloc_stats(); +void dlmalloc_stats(); #endif /* !ONLY_MSPACES */ @@ -480,15 +478,13 @@ void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); mspace_independent_calloc behaves as independent_calloc, but operates within the given space. */ -void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]); +void** mspace_independent_calloc(mspace msp, size_t n_elements, size_t elem_size, void* chunks[]); /* mspace_independent_comalloc behaves as independent_comalloc, but operates within the given space. */ -void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]); +void** mspace_independent_comalloc(mspace msp, size_t n_elements, size_t sizes[], void* chunks[]); /* mspace_footprint() returns the number of bytes obtained from the @@ -496,7 +492,6 @@ void** mspace_independent_comalloc(mspace msp, size_t n_elements, */ size_t mspace_footprint(mspace msp); - #if !NO_MALLINFO /* mspace_mallinfo behaves as mallinfo, but reports properties of @@ -522,10 +517,10 @@ int mspace_trim(mspace msp, size_t pad); */ int mspace_mallopt(int, int); -#endif /* MSPACES */ +#endif /* MSPACES */ #ifdef __cplusplus -}; /* end of extern "C" */ +}; /* end of extern "C" */ #endif #endif /* MALLOC_280_H */ diff --git a/src/xrServerEntities/game_base_space.h b/src/xrServerEntities/game_base_space.h index 7a6aa0e0b55..faf3303d447 100644 --- a/src/xrServerEntities/game_base_space.h +++ b/src/xrServerEntities/game_base_space.h @@ -1,44 +1,44 @@ #pragma once /* enum EGameIDs { - eGameIDNoGame = u32(0), - eGameIDSingle = u32(1) << 0, - eGameIDDeathmatch = u32(1) << 1, - eGameIDTeamDeathmatch = u32(1) << 2, - eGameIDArtefactHunt = u32(1) << 3, - eGameIDCaptureTheArtefact = u32(1) << 4, - eGameIDDominationZone = u32(1) << 5, - eGameIDTeamDominationZone = u32(1) << 6, + eGameIDNoGame = u32(0), + eGameIDSingle = u32(1) << 0, + eGameIDDeathmatch = u32(1) << 1, + eGameIDTeamDeathmatch = u32(1) << 2, + eGameIDArtefactHunt = u32(1) << 3, + eGameIDCaptureTheArtefact = u32(1) << 4, + eGameIDDominationZone = u32(1) << 5, + eGameIDTeamDominationZone = u32(1) << 6, };*/ enum EGamePlayerFlags { - GAME_PLAYER_FLAG_LOCAL = (1<<0), - GAME_PLAYER_FLAG_READY = (1<<1), - GAME_PLAYER_FLAG_VERY_VERY_DEAD = (1<<2), - GAME_PLAYER_FLAG_SPECTATOR = (1<<3), + GAME_PLAYER_FLAG_LOCAL = (1 << 0), + GAME_PLAYER_FLAG_READY = (1 << 1), + GAME_PLAYER_FLAG_VERY_VERY_DEAD = (1 << 2), + GAME_PLAYER_FLAG_SPECTATOR = (1 << 3), - GAME_PLAYER_FLAG_SCRIPT_BEGINS_FROM = (1<<4), - GAME_PLAYER_FLAG_INVINCIBLE = (1<<5), - GAME_PLAYER_FLAG_ONBASE = (1<<6), - GAME_PLAYER_FLAG_SKIP = (1<<7), - GAME_PLAYER_HAS_ADMIN_RIGHTS = (1<<8), + GAME_PLAYER_FLAG_SCRIPT_BEGINS_FROM = (1 << 4), + GAME_PLAYER_FLAG_INVINCIBLE = (1 << 5), + GAME_PLAYER_FLAG_ONBASE = (1 << 6), + GAME_PLAYER_FLAG_SKIP = (1 << 7), + GAME_PLAYER_HAS_ADMIN_RIGHTS = (1 << 8), - GAME_PLAYER_FLAG_FORCEDWORD = u32(-1) + GAME_PLAYER_FLAG_FORCEDWORD = u32(-1) }; enum EGamePhases { - GAME_PHASE_NONE = 0, - GAME_PHASE_INPROGRESS, - GAME_PHASE_PENDING, - GAME_PHASE_TEAM1_SCORES, - GAME_PHASE_TEAM2_SCORES, - GAME_PHASE_TEAM1_ELIMINATED, - GAME_PHASE_TEAM2_ELIMINATED, - GAME_PHASE_TEAMS_IN_A_DRAW, - GAME_PHASE_PLAYER_SCORES, + GAME_PHASE_NONE = 0, + GAME_PHASE_INPROGRESS, + GAME_PHASE_PENDING, + GAME_PHASE_TEAM1_SCORES, + GAME_PHASE_TEAM2_SCORES, + GAME_PHASE_TEAM1_ELIMINATED, + GAME_PHASE_TEAM2_ELIMINATED, + GAME_PHASE_TEAMS_IN_A_DRAW, + GAME_PHASE_PLAYER_SCORES, - GAME_PHASE_SCRIPT_BEGINS_FROM, - GAME_PHASE_FORCEDWORD = u32(-1) + GAME_PHASE_SCRIPT_BEGINS_FROM, + GAME_PHASE_FORCEDWORD = u32(-1) }; diff --git a/src/xrServerEntities/gametype_chooser.cpp b/src/xrServerEntities/gametype_chooser.cpp index e18e9f756bf..3cd76fedb84 100644 --- a/src/xrServerEntities/gametype_chooser.cpp +++ b/src/xrServerEntities/gametype_chooser.cpp @@ -1,88 +1,80 @@ #include "stdafx.h" #pragma hdrstop - #include "gametype_chooser.h" #include "xrServer_Objects_Abstract.h" -//old -enum ERPGameType{ // [0..255] - rpgtGameAny = u8(0), - rpgtGameDeathmatch, - rpgtGameTeamDeathmatch, - rpgtGameArtefactHunt, - rpgtGameCaptureTheArtefact, - rpgtGameCount, +// old +enum ERPGameType +{ // [0..255] + rpgtGameAny = u8(0), + rpgtGameDeathmatch, + rpgtGameTeamDeathmatch, + rpgtGameArtefactHunt, + rpgtGameCaptureTheArtefact, + rpgtGameCount, }; -xr_token rpoint_game_type[]={ - { "Any game", rpgtGameAny }, - { "Deathmatch", rpgtGameDeathmatch }, - { "TeamDeathmatch", rpgtGameTeamDeathmatch }, - { "ArtefactHunt", rpgtGameArtefactHunt }, - { "CaptureTheArtefact", rpgtGameCaptureTheArtefact }, - { 0, 0 } -}; +xr_token rpoint_game_type[] = {{"Any game", rpgtGameAny}, {"Deathmatch", rpgtGameDeathmatch}, + {"TeamDeathmatch", rpgtGameTeamDeathmatch}, {"ArtefactHunt", rpgtGameArtefactHunt}, + {"CaptureTheArtefact", rpgtGameCaptureTheArtefact}, {0, 0}}; #ifdef _EDITOR bool GameTypeChooser::LoadStream(IReader& F) { - m_GameType.assign (F.r_u16()); + m_GameType.assign(F.r_u16()); return true; } bool GameTypeChooser::LoadLTX(CInifile& ini, LPCSTR sect_name, bool bOldFormat) { - if(bOldFormat/*version==0x0014*/) - { - u8 tmp = ini.r_u8 (sect_name, "game_type"); - m_GameType.zero (); - switch(tmp) + if (bOldFormat /*version==0x0014*/) { + u8 tmp = ini.r_u8(sect_name, "game_type"); + m_GameType.zero(); + switch (tmp) { - case rpgtGameAny: - m_GameType.one(); - break; - case rpgtGameDeathmatch: - m_GameType.set(eGameIDDeathmatch,TRUE); - break; - case rpgtGameTeamDeathmatch: - m_GameType.set(eGameIDTeamDeathmatch,TRUE); - break; - case rpgtGameArtefactHunt: - m_GameType.set(eGameIDArtefactHunt,TRUE); - break; - case rpgtGameCaptureTheArtefact: - m_GameType.set(eGameIDCaptureTheArtefact,TRUE); - break; + case rpgtGameAny: m_GameType.one(); break; + case rpgtGameDeathmatch: m_GameType.set(eGameIDDeathmatch, TRUE); break; + case rpgtGameTeamDeathmatch: m_GameType.set(eGameIDTeamDeathmatch, TRUE); break; + case rpgtGameArtefactHunt: m_GameType.set(eGameIDArtefactHunt, TRUE); break; + case rpgtGameCaptureTheArtefact: m_GameType.set(eGameIDCaptureTheArtefact, TRUE); break; } - }else - m_GameType.assign (ini.r_u16 (sect_name, "game_type")); + } + else + m_GameType.assign(ini.r_u16(sect_name, "game_type")); return true; } void GameTypeChooser::SaveStream(IWriter& F) { - F.w_u16 (m_GameType.get()); + F.w_u16(m_GameType.get()); } void GameTypeChooser::SaveLTX(CInifile& ini, LPCSTR sect_name) { - ini.w_u16(sect_name, "game_type", m_GameType.get()); + ini.w_u16(sect_name, "game_type", m_GameType.get()); } #endif #ifndef XRGAME_EXPORTS -void GameTypeChooser::FillProp(LPCSTR pref, PropItemVec& items) +void GameTypeChooser::FillProp(LPCSTR pref, PropItemVec& items) { - PHelper().CreateGameType (items, PrepareKey(pref, "Game Type"), this); -/* - PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\single"), &m_GameType, eGameIDSingle); - PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\deathmatch"), &m_GameType, eGameIDDeathmatch); - PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\team deathmatch"), &m_GameType, eGameIDTeamDeathmatch); - PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\artefact hunt"), &m_GameType, eGameIDArtefactHunt); - PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\capture the artefact"), &m_GameType, eGameIDCaptureTheArtefact); - PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\domination zone"), &m_GameType, eGameIDDominationZone); - PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\team domination zone"), &m_GameType, eGameIDTeamDominationZone); -*/ - } -#endif // #ifndef XRGAME_EXPORTS \ No newline at end of file + PHelper().CreateGameType(items, PrepareKey(pref, "Game Type"), this); + /* + PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\single"), &m_GameType, + eGameIDSingle); + PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\deathmatch"), &m_GameType, + eGameIDDeathmatch); + PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\team deathmatch"), &m_GameType, + eGameIDTeamDeathmatch); + PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\artefact hunt"), &m_GameType, + eGameIDArtefactHunt); + PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\capture the artefact"), &m_GameType, + eGameIDCaptureTheArtefact); + PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\domination zone"), &m_GameType, + eGameIDDominationZone); + PHelper().CreateFlag16 (items, PrepareKey(pref, "Game Type\\team domination zone"), &m_GameType, + eGameIDTeamDominationZone); + */ +} +#endif // #ifndef XRGAME_EXPORTS \ No newline at end of file diff --git a/src/xrServerEntities/gametype_chooser.h b/src/xrServerEntities/gametype_chooser.h index 1832ffd9d0a..8a3364b7d50 100644 --- a/src/xrServerEntities/gametype_chooser.h +++ b/src/xrServerEntities/gametype_chooser.h @@ -4,56 +4,50 @@ #pragma once #include "xrCore/xrCore.h" -//new -enum EGameIDs { - eGameIDNoGame = u32(0), - eGameIDSingle = u32(1) << 0, - eGameIDDeathmatch = u32(1) << 1, - eGameIDTeamDeathmatch = u32(1) << 2, - eGameIDArtefactHunt = u32(1) << 3, - eGameIDCaptureTheArtefact = u32(1) << 4, - eGameIDDominationZone = u32(1) << 5, - eGameIDTeamDominationZone = u32(1) << 6, +// new +enum EGameIDs +{ + eGameIDNoGame = u32(0), + eGameIDSingle = u32(1) << 0, + eGameIDDeathmatch = u32(1) << 1, + eGameIDTeamDeathmatch = u32(1) << 2, + eGameIDArtefactHunt = u32(1) << 3, + eGameIDCaptureTheArtefact = u32(1) << 4, + eGameIDDominationZone = u32(1) << 5, + eGameIDTeamDominationZone = u32(1) << 6, }; inline EGameIDs ParseStringToGameType(LPCSTR str) { - if (!xr_strcmp(str, "single")) - return eGameIDSingle; - if (!xr_strcmp(str, "deathmatch") || !xr_strcmp(str, "dm")) - return eGameIDDeathmatch; - if (!xr_strcmp(str, "teamdeathmatch") || !xr_strcmp(str, "tdm")) - return eGameIDTeamDeathmatch; - if (!xr_strcmp(str, "artefacthunt") || !xr_strcmp(str, "ah")) - return eGameIDArtefactHunt; - if (!xr_strcmp(str, "capturetheartefact") || !xr_strcmp(str, "cta")) - return eGameIDCaptureTheArtefact; - if (!xr_strcmp(str, "dominationzone")) - return eGameIDDominationZone; - if (!xr_strcmp(str, "teamdominationzone")) - return eGameIDTeamDominationZone; - return eGameIDNoGame; //EGameIDs + if (!xr_strcmp(str, "single")) return eGameIDSingle; + if (!xr_strcmp(str, "deathmatch") || !xr_strcmp(str, "dm")) return eGameIDDeathmatch; + if (!xr_strcmp(str, "teamdeathmatch") || !xr_strcmp(str, "tdm")) return eGameIDTeamDeathmatch; + if (!xr_strcmp(str, "artefacthunt") || !xr_strcmp(str, "ah")) return eGameIDArtefactHunt; + if (!xr_strcmp(str, "capturetheartefact") || !xr_strcmp(str, "cta")) return eGameIDCaptureTheArtefact; + if (!xr_strcmp(str, "dominationzone")) return eGameIDDominationZone; + if (!xr_strcmp(str, "teamdominationzone")) return eGameIDTeamDominationZone; + return eGameIDNoGame; // EGameIDs } class PropValue; class PropItem; -DEFINE_VECTOR (PropItem*,PropItemVec,PropItemIt); +DEFINE_VECTOR(PropItem*, PropItemVec, PropItemIt); struct GameTypeChooser { - Flags16 m_GameType; + Flags16 m_GameType; #ifndef XRGAME_EXPORTS - void FillProp (LPCSTR pref, PropItemVec& items); -#endif // #ifndef XRGAME_EXPORTS + void FillProp(LPCSTR pref, PropItemVec& items); +#endif // #ifndef XRGAME_EXPORTS #ifdef _EDITOR - bool LoadStream (IReader&F); - bool LoadLTX (CInifile& ini, LPCSTR sect_name, bool bOldFormat); - void SaveStream (IWriter&); - void SaveLTX (CInifile& ini, LPCSTR sect_name); + bool LoadStream(IReader& F); + bool LoadLTX(CInifile& ini, LPCSTR sect_name, bool bOldFormat); + void SaveStream(IWriter&); + void SaveLTX(CInifile& ini, LPCSTR sect_name); #endif - void SetDefaults () {m_GameType.one();} - bool MatchType (const u16 t) const {return (t==eGameIDNoGame) || !!m_GameType.test(t);}; + void SetDefaults() { m_GameType.one(); } + bool MatchType(const u16 t) const { return (t == eGameIDNoGame) || !!m_GameType.test(t); }; }; #endif \ No newline at end of file diff --git a/src/xrServerEntities/inventory_space.h b/src/xrServerEntities/inventory_space.h index 544394c35b8..f57653d6d86 100644 --- a/src/xrServerEntities/inventory_space.h +++ b/src/xrServerEntities/inventory_space.h @@ -1,82 +1,83 @@ #pragma once -#define CMD_START (1<<0) -#define CMD_STOP (1<<1) +#define CMD_START (1 << 0) +#define CMD_STOP (1 << 1) -enum{ - NO_ACTIVE_SLOT = 0, - KNIFE_SLOT = 1,//btn1 was (0) !!! - INV_SLOT_2, //btn2 PISTOL_SLOT was (1) - INV_SLOT_3, //btn3 RIFLE_SLOT was (2) - GRENADE_SLOT, //btn4 GRENADE_SLOT was (3) - BINOCULAR_SLOT, //btn5 BINOCULAR_SLOT - BOLT_SLOT, //btn6 BOLT_SLOT - OUTFIT_SLOT, // outfit - PDA_SLOT, // pda - DETECTOR_SLOT, // detector - TORCH_SLOT, // torch - ARTEFACT_SLOT, // artefact - HELMET_SLOT, - LAST_SLOT = HELMET_SLOT +enum +{ + NO_ACTIVE_SLOT = 0, + KNIFE_SLOT = 1, // btn1 was (0) !!! + INV_SLOT_2, // btn2 PISTOL_SLOT was (1) + INV_SLOT_3, // btn3 RIFLE_SLOT was (2) + GRENADE_SLOT, // btn4 GRENADE_SLOT was (3) + BINOCULAR_SLOT, // btn5 BINOCULAR_SLOT + BOLT_SLOT, // btn6 BOLT_SLOT + OUTFIT_SLOT, // outfit + PDA_SLOT, // pda + DETECTOR_SLOT, // detector + TORCH_SLOT, // torch + ARTEFACT_SLOT, // artefact + HELMET_SLOT, + LAST_SLOT = HELMET_SLOT }; -#define RUCK_HEIGHT 280 -#define RUCK_WIDTH 7 +#define RUCK_HEIGHT 280 +#define RUCK_WIDTH 7 class CInventoryItem; class CInventory; -typedef CInventoryItem* PIItem; -typedef xr_vector TIItemContainer; - +typedef CInventoryItem* PIItem; +typedef xr_vector TIItemContainer; enum eItemPlace -{ - eItemPlaceUndefined = 0, - eItemPlaceSlot, - eItemPlaceBelt, - eItemPlaceRuck +{ + eItemPlaceUndefined = 0, + eItemPlaceSlot, + eItemPlaceBelt, + eItemPlaceRuck }; struct SInvItemPlace { - union{ - struct{ - u16 type : 4; - u16 slot_id : 6; - u16 base_slot_id : 6; - }; - u16 value; - }; + union + { + struct + { + u16 type : 4; + u16 slot_id : 6; + u16 base_slot_id : 6; + }; + u16 value; + }; }; -extern u16 INV_STATE_LADDER; -extern u16 INV_STATE_CAR; -extern u16 INV_STATE_BLOCK_ALL; -extern u16 INV_STATE_INV_WND; -extern u16 INV_STATE_BUY_MENU; +extern u16 INV_STATE_LADDER; +extern u16 INV_STATE_CAR; +extern u16 INV_STATE_BLOCK_ALL; +extern u16 INV_STATE_INV_WND; +extern u16 INV_STATE_BUY_MENU; struct II_BriefInfo { - shared_str name; - shared_str icon; - shared_str cur_ammo; - shared_str fmj_ammo; - shared_str ap_ammo; - shared_str fire_mode; + shared_str name; + shared_str icon; + shared_str cur_ammo; + shared_str fmj_ammo; + shared_str ap_ammo; + shared_str fire_mode; - shared_str grenade; + shared_str grenade; - II_BriefInfo() { clear(); } - - IC void clear() - { - name = ""; - icon = ""; - cur_ammo = ""; - fmj_ammo = ""; - ap_ammo = ""; - fire_mode = ""; - grenade = ""; - } + II_BriefInfo() { clear(); } + IC void clear() + { + name = ""; + icon = ""; + cur_ammo = ""; + fmj_ammo = ""; + ap_ammo = ""; + fire_mode = ""; + grenade = ""; + } }; diff --git a/src/xrServerEntities/object_factory.cpp b/src/xrServerEntities/object_factory.cpp index 9e9a3ef1bb2..bc3d95337a5 100644 --- a/src/xrServerEntities/object_factory.cpp +++ b/src/xrServerEntities/object_factory.cpp @@ -6,24 +6,24 @@ // Description : Object factory //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" #include "object_factory.h" #include "Common/object_broker.h" +#include "stdafx.h" -CObjectFactory *g_object_factory = 0; +CObjectFactory* g_object_factory = 0; -CObjectFactory::CObjectFactory () +CObjectFactory::CObjectFactory() { - m_actual = false; - register_classes (); + m_actual = false; + register_classes(); } -CObjectFactory::~CObjectFactory () +CObjectFactory::~CObjectFactory() { - delete_data (m_clsids); + delete_data(m_clsids); } -void CObjectFactory::init () +void CObjectFactory::init() { - register_script_classes (); + register_script_classes(); } diff --git a/src/xrServerEntities/object_factory.h b/src/xrServerEntities/object_factory.h index 7920aad2543..9a46cab57a9 100644 --- a/src/xrServerEntities/object_factory.h +++ b/src/xrServerEntities/object_factory.h @@ -14,7 +14,8 @@ #include "object_item_abstract.h" #include "xrServer_Objects.h" -class CObjectFactory { +class CObjectFactory +{ public: #ifndef NO_XR_GAME using ClientObjectBaseClass = ObjectFactory::ClientObjectBaseClass; @@ -22,69 +23,72 @@ class CObjectFactory { using ServerObjectBaseClass = ObjectFactory::ServerObjectBaseClass; protected: - struct CObjectItemPredicate { - IC bool operator() (const CObjectItemAbstract *item1, const CObjectItemAbstract *item2) const; - IC bool operator() (const CObjectItemAbstract *item, const CLASS_ID &clsid) const; - }; + struct CObjectItemPredicate + { + IC bool operator()(const CObjectItemAbstract* item1, const CObjectItemAbstract* item2) const; + IC bool operator()(const CObjectItemAbstract* item, const CLASS_ID& clsid) const; + }; - struct CObjectItemPredicateCLSID { - CLASS_ID m_clsid; + struct CObjectItemPredicateCLSID + { + CLASS_ID m_clsid; - IC CObjectItemPredicateCLSID (const CLASS_ID &clsid); - IC bool operator() (const CObjectItemAbstract *item) const; - }; + IC CObjectItemPredicateCLSID(const CLASS_ID& clsid); + IC bool operator()(const CObjectItemAbstract* item) const; + }; - struct CObjectItemPredicateScript { - shared_str m_script_clsid_name; + struct CObjectItemPredicateScript + { + shared_str m_script_clsid_name; - IC CObjectItemPredicateScript (const shared_str &script_clsid_name); - IC bool operator() (const CObjectItemAbstract *item) const; - }; + IC CObjectItemPredicateScript(const shared_str& script_clsid_name); + IC bool operator()(const CObjectItemAbstract* item) const; + }; public: - typedef xr_vector OBJECT_ITEM_STORAGE; - typedef OBJECT_ITEM_STORAGE::iterator iterator; - typedef OBJECT_ITEM_STORAGE::const_iterator const_iterator; + typedef xr_vector OBJECT_ITEM_STORAGE; + typedef OBJECT_ITEM_STORAGE::iterator iterator; + typedef OBJECT_ITEM_STORAGE::const_iterator const_iterator; protected: - mutable OBJECT_ITEM_STORAGE m_clsids; - mutable bool m_actual; + mutable OBJECT_ITEM_STORAGE m_clsids; + mutable bool m_actual; protected: - void register_classes (); - IC void add (CObjectItemAbstract *item); - IC const OBJECT_ITEM_STORAGE &clsids () const; - IC void actualize () const; - template - IC void add (const CLASS_ID &clsid, LPCSTR script_clsid); + void register_classes(); + IC void add(CObjectItemAbstract* item); + IC const OBJECT_ITEM_STORAGE& clsids() const; + IC void actualize() const; + template + IC void add(const CLASS_ID& clsid, LPCSTR script_clsid); #ifndef NO_XR_GAME - template - IC void add (const CLASS_ID &clsid, LPCSTR script_clsid); - IC const CObjectItemAbstract &item (const CLASS_ID &clsid) const; + template + IC void add(const CLASS_ID& clsid, LPCSTR script_clsid); + IC const CObjectItemAbstract& item(const CLASS_ID& clsid) const; #else - IC const CObjectItemAbstract *item (const CLASS_ID &clsid, bool no_assert) const; + IC const CObjectItemAbstract* item(const CLASS_ID& clsid, bool no_assert) const; #endif public: - CObjectFactory (); - virtual ~CObjectFactory (); - void init (); + CObjectFactory(); + virtual ~CObjectFactory(); + void init(); #ifndef NO_XR_GAME - inline ClientObjectBaseClass *client_object(const CLASS_ID &clsid) const; + inline ClientObjectBaseClass* client_object(const CLASS_ID& clsid) const; #endif - inline ServerObjectBaseClass *server_object(const CLASS_ID &clsid, LPCSTR section) const; + inline ServerObjectBaseClass* server_object(const CLASS_ID& clsid, LPCSTR section) const; - IC int script_clsid (const CLASS_ID &clsid) const; - void register_script () const; - void register_script_class (LPCSTR client_class, LPCSTR server_class, LPCSTR clsid, LPCSTR script_clsid); - void register_script_class (LPCSTR unknown_class, LPCSTR clsid, LPCSTR script_clsid); - void register_script_classes (); - }; + IC int script_clsid(const CLASS_ID& clsid) const; + void register_script() const; + void register_script_class(LPCSTR client_class, LPCSTR server_class, LPCSTR clsid, LPCSTR script_clsid); + void register_script_class(LPCSTR unknown_class, LPCSTR clsid, LPCSTR script_clsid); + void register_script_classes(); +}; -extern CObjectFactory *g_object_factory; +extern CObjectFactory* g_object_factory; -IC const CObjectFactory &object_factory(); +IC const CObjectFactory& object_factory(); #include "object_factory_inline.h" #endif \ No newline at end of file diff --git a/src/xrServerEntities/object_factory_impl.h b/src/xrServerEntities/object_factory_impl.h index 1e0a3651e31..44ce5f1ea46 100644 --- a/src/xrServerEntities/object_factory_impl.h +++ b/src/xrServerEntities/object_factory_impl.h @@ -15,51 +15,46 @@ #include "object_item_single.h" #ifndef NO_XR_GAME -# include "Common/object_type_traits.h" -# include "object_item_client_server.h" -#endif // NO_XR_GAME +#include "Common/object_type_traits.h" +#include "object_item_client_server.h" +#endif // NO_XR_GAME #ifndef NO_XR_GAME template -IC void CObjectFactory::add (const CLASS_ID &clsid, LPCSTR script_clsid) +IC void CObjectFactory::add(const CLASS_ID& clsid, LPCSTR script_clsid) { - { - typedef object_type_traits::is_base_and_derived a; + { + typedef object_type_traits::is_base_and_derived a; static_assert(a::value, "Client object must derive ClientObjectBaseClass"); - } - { - typedef object_type_traits::is_base_and_derived a; + } + { + typedef object_type_traits::is_base_and_derived a; static_assert(a::value, "Server object must derive ServerObjectBaseClass"); - } - add (new CObjectItemClientServer<_client_type,_server_type>(clsid,script_clsid)); + } + add(new CObjectItemClientServer<_client_type, _server_type>(clsid, script_clsid)); } template -IC void CObjectFactory::add (const CLASS_ID &clsid, LPCSTR script_clsid) +IC void CObjectFactory::add(const CLASS_ID& clsid, LPCSTR script_clsid) { - { - typedef object_type_traits::is_base_and_derived a; - typedef object_type_traits::is_base_and_derived b; + { + typedef object_type_traits::is_base_and_derived a; + typedef object_type_traits::is_base_and_derived b; static_assert(a::value || b::value, "Class must derive ClientObjectBaseClass or ServerObjectBaseClass"); - } - add ( - new CObjectItemSingle< - _unknown_type, - object_type_traits::is_base_and_derived::value - > - (clsid,script_clsid) - ); + } + add(new CObjectItemSingle<_unknown_type, + object_type_traits::is_base_and_derived::value>(clsid, script_clsid)); } -#else // NO_XR_GAME +#else // NO_XR_GAME template -IC void CObjectFactory::add (const CLASS_ID &clsid, LPCSTR script_clsid) +IC void CObjectFactory::add(const CLASS_ID& clsid, LPCSTR script_clsid) { - add (new CObjectItemSingle<_unknown_type,false>(clsid,script_clsid)); + add(new CObjectItemSingle<_unknown_type, false>(clsid, script_clsid)); } -#endif // NO_XR_GAME +#endif // NO_XR_GAME -#endif // object_factory_implH \ No newline at end of file +#endif // object_factory_implH \ No newline at end of file diff --git a/src/xrServerEntities/object_factory_inline.h b/src/xrServerEntities/object_factory_inline.h index 6afd07a3c8d..90c8a621a42 100644 --- a/src/xrServerEntities/object_factory_inline.h +++ b/src/xrServerEntities/object_factory_inline.h @@ -11,124 +11,122 @@ #pragma once -IC const CObjectFactory &object_factory() +IC const CObjectFactory& object_factory() { - if (!g_object_factory) { - g_object_factory = new CObjectFactory(); - g_object_factory->init (); - } - return (*g_object_factory); + if (!g_object_factory) { + g_object_factory = new CObjectFactory(); + g_object_factory->init(); + } + return (*g_object_factory); } -IC bool CObjectFactory::CObjectItemPredicate::operator() (const CObjectItemAbstract *item1, const CObjectItemAbstract *item2) const +IC bool CObjectFactory::CObjectItemPredicate::operator()( + const CObjectItemAbstract* item1, const CObjectItemAbstract* item2) const { - return (item1->clsid() < item2->clsid()); + return (item1->clsid() < item2->clsid()); } -IC bool CObjectFactory::CObjectItemPredicate::operator() (const CObjectItemAbstract *item, const CLASS_ID &clsid) const +IC bool CObjectFactory::CObjectItemPredicate::operator()(const CObjectItemAbstract* item, const CLASS_ID& clsid) const { - return (item->clsid() < clsid); + return (item->clsid() < clsid); } -IC CObjectFactory::CObjectItemPredicateCLSID::CObjectItemPredicateCLSID (const CLASS_ID &clsid) : - m_clsid (clsid) +IC CObjectFactory::CObjectItemPredicateCLSID::CObjectItemPredicateCLSID(const CLASS_ID& clsid) : m_clsid(clsid) { } -IC bool CObjectFactory::CObjectItemPredicateCLSID::operator() (const CObjectItemAbstract *item) const +IC bool CObjectFactory::CObjectItemPredicateCLSID::operator()(const CObjectItemAbstract* item) const { - return (m_clsid == item->clsid()); + return (m_clsid == item->clsid()); } -IC CObjectFactory::CObjectItemPredicateScript::CObjectItemPredicateScript (const shared_str &script_clsid_name) : - m_script_clsid_name (script_clsid_name) +IC CObjectFactory::CObjectItemPredicateScript::CObjectItemPredicateScript(const shared_str& script_clsid_name) + : m_script_clsid_name(script_clsid_name) { } -IC bool CObjectFactory::CObjectItemPredicateScript::operator() (const CObjectItemAbstract *item) const +IC bool CObjectFactory::CObjectItemPredicateScript::operator()(const CObjectItemAbstract* item) const { - return (m_script_clsid_name == item->script_clsid()); + return (m_script_clsid_name == item->script_clsid()); } -IC const CObjectFactory::OBJECT_ITEM_STORAGE &CObjectFactory::clsids () const +IC const CObjectFactory::OBJECT_ITEM_STORAGE& CObjectFactory::clsids() const { - return (m_clsids); + return (m_clsids); } #ifndef NO_XR_GAME -IC const CObjectItemAbstract &CObjectFactory::item (const CLASS_ID &clsid) const +IC const CObjectItemAbstract& CObjectFactory::item(const CLASS_ID& clsid) const { - actualize (); - const_iterator I = std::lower_bound(clsids().begin(),clsids().end(),clsid,CObjectItemPredicate()); - VERIFY ((I != clsids().end()) && ((*I)->clsid() == clsid)); - return (**I); + actualize(); + const_iterator I = std::lower_bound(clsids().begin(), clsids().end(), clsid, CObjectItemPredicate()); + VERIFY((I != clsids().end()) && ((*I)->clsid() == clsid)); + return (**I); } #else -IC const CObjectItemAbstract *CObjectFactory::item (const CLASS_ID &clsid, bool no_assert) const +IC const CObjectItemAbstract* CObjectFactory::item(const CLASS_ID& clsid, bool no_assert) const { - actualize (); - const_iterator I = std::lower_bound(clsids().begin(),clsids().end(),clsid,CObjectItemPredicate()); - if ((I == clsids().end()) || ((*I)->clsid() != clsid)) { - R_ASSERT (no_assert); - return (0); - } - return (*I); + actualize(); + const_iterator I = std::lower_bound(clsids().begin(), clsids().end(), clsid, CObjectItemPredicate()); + if ((I == clsids().end()) || ((*I)->clsid() != clsid)) { + R_ASSERT(no_assert); + return (0); + } + return (*I); } #endif -IC void CObjectFactory::add (CObjectItemAbstract *item) +IC void CObjectFactory::add(CObjectItemAbstract* item) { - const_iterator I; - - I = std::find_if(clsids().begin(),clsids().end(),CObjectItemPredicateCLSID(item->clsid())); - if(I != clsids().end()) - { - string16 temp; - CLSID2TEXT (item->clsid(),temp); - VERIFY2 (0, make_string("clsid is duplicated : %s",temp)); - } - + const_iterator I; + + I = std::find_if(clsids().begin(), clsids().end(), CObjectItemPredicateCLSID(item->clsid())); + if (I != clsids().end()) { + string16 temp; + CLSID2TEXT(item->clsid(), temp); + VERIFY2(0, make_string("clsid is duplicated : %s", temp)); + } + #ifndef NO_XR_GAME - I = std::find_if(clsids().begin(),clsids().end(),CObjectItemPredicateScript(item->script_clsid())); - VERIFY (I == clsids().end()); + I = std::find_if(clsids().begin(), clsids().end(), CObjectItemPredicateScript(item->script_clsid())); + VERIFY(I == clsids().end()); #endif - - m_actual = false; - m_clsids.push_back (item); + + m_actual = false; + m_clsids.push_back(item); } -IC int CObjectFactory::script_clsid (const CLASS_ID &clsid) const +IC int CObjectFactory::script_clsid(const CLASS_ID& clsid) const { - actualize (); - const_iterator I = std::lower_bound(clsids().begin(),clsids().end(),clsid,CObjectItemPredicate()); - VERIFY ((I != clsids().end()) && ((*I)->clsid() == clsid)); - return (int(I - clsids().begin())); + actualize(); + const_iterator I = std::lower_bound(clsids().begin(), clsids().end(), clsid, CObjectItemPredicate()); + VERIFY((I != clsids().end()) && ((*I)->clsid() == clsid)); + return (int(I - clsids().begin())); } #ifndef NO_XR_GAME -inline CObjectFactory::ClientObjectBaseClass *CObjectFactory::client_object (const CLASS_ID &clsid) const +inline CObjectFactory::ClientObjectBaseClass* CObjectFactory::client_object(const CLASS_ID& clsid) const { - return (item(clsid).client_object()); + return (item(clsid).client_object()); } #endif -inline CObjectFactory::ServerObjectBaseClass *CObjectFactory::server_object (const CLASS_ID &clsid, LPCSTR section) const +inline CObjectFactory::ServerObjectBaseClass* CObjectFactory::server_object(const CLASS_ID& clsid, LPCSTR section) const { #ifndef NO_XR_GAME - return (item(clsid).server_object(section)); + return (item(clsid).server_object(section)); #else - const CObjectItemAbstract *object = item(clsid, true); - return (object ? object->server_object(section) : 0); + const CObjectItemAbstract* object = item(clsid, true); + return (object ? object->server_object(section) : 0); #endif } -IC void CObjectFactory::actualize () const +IC void CObjectFactory::actualize() const { - if (m_actual) - return; + if (m_actual) return; - m_actual = true; - std::sort (m_clsids.begin(),m_clsids.end(),CObjectItemPredicate()); + m_actual = true; + std::sort(m_clsids.begin(), m_clsids.end(), CObjectItemPredicate()); } #endif \ No newline at end of file diff --git a/src/xrServerEntities/object_factory_register.cpp b/src/xrServerEntities/object_factory_register.cpp index 9f59767c603..cbe3aa4792e 100644 --- a/src/xrServerEntities/object_factory_register.cpp +++ b/src/xrServerEntities/object_factory_register.cpp @@ -12,422 +12,420 @@ #include "object_factory_impl.h" // server entities includes +#include "clsid_game.h" #include "xrServer_Objects_ALife_All.h" #include "xrServer_Objects_ALife_Smartcovers.h" -#include "clsid_game.h" // client entities includes #ifndef NO_XR_GAME -# include "xrEngine/std_classes.h" -# include "Level.h" -# include "gamepersistent.h" -# include "hudmanager.h" -# include "actor.h" -# include "spectator.h" - -# include "ai/monsters/flesh/flesh.h" -# include "ai/monsters/chimera/chimera.h" -# include "ai/monsters/dog/dog.h" -# include "ai/stalker/ai_stalker.h" -# include "ai/monsters/bloodsucker/bloodsucker.h" -# include "ai/monsters/boar/boar.h" -# include "ai/monsters/pseudodog/pseudodog.h" -# include "ai/monsters/pseudodog/psy_dog.h" -# include "ai/monsters/Burer/burer.h" -# include "ai/monsters/PseudoGigant/pseudo_gigant.h" -# include "ai/monsters/controller/controller.h" -# include "ai/monsters/poltergeist/poltergeist.h" -# include "ai/monsters/zombie/zombie.h" -# include "ai/monsters/fracture/fracture.h" -# include "ai/monsters/snork/snork.h" -# include "ai/monsters/cat/cat.h" -# include "ai/monsters/tushkano/tushkano.h" -# include "ai/monsters/rats/ai_rat.h" - -# include "ai/phantom/phantom.h" - -# include "ai/trader/ai_trader.h" - -# include "ai/crow/ai_crow.h" - -# ifdef DEBUG -# include "xrEngine/StatGraph.h" -# include "PHDebug.h" -# endif // DEBUG - -# include "hit.h" -# include "PHDestroyable.h" -# include "car.h" - -# include "helicopter.h" - -# include "MercuryBall.h" -# include "BlackDrops.h" -# include "BlackGraviArtifact.h" -# include "BastArtifact.h" -# include "DummyArtifact.h" -# include "ZudaArtifact.h" -# include "ThornArtifact.h" -# include "FadedBall.h" -# include "ElectricBall.h" -# include "RustyHairArtifact.h" -# include "GalantineArtifact.h" -# include "GraviArtifact.h" -# include "cta_game_artefact.h" - -# include "weaponFN2000.h" -# include "weaponAK74.h" -# include "weaponLR300.h" -# include "weaponHPSA.h" -# include "weaponPM.h" -# include "weaponAMMO.h" -# include "weaponFORT.h" -# include "weaponBINOCULARS.h" -# include "weaponShotgun.h" -# include "weaponsvd.h" -# include "weaponsvu.h" -# include "weaponrpg7.h" -# include "weaponval.h" -# include "weaponvintorez.h" -# include "weaponwalther.h" -# include "weaponusp45.h" -# include "weapongroza.h" -# include "weaponknife.h" -# include "weaponBM16.h" -# include "weaponRG6.h" -# include "WeaponStatMgun.h" - -# include "scope.h" -# include "silencer.h" -# include "grenadelauncher.h" - -# include "bolt.h" -# include "medkit.h" -# include "antirad.h" -# include "fooditem.h" -# include "bottleitem.h" -# include "explosiveitem.h" - -# include "infodocument.h" -# include "attachable_item.h" - -# include "ScientificOutfit.h" -# include "StalkerOutfit.h" -# include "MilitaryOutfit.h" -# include "ExoOutfit.h" -# include "ActorHelmet.h" - -# include "f1.h" -# include "rgd5.h" - -# include "explosiverocket.h" - -# include "MPPlayersBag.h" - -# include "customzone.h" -# include "mosquitobald.h" -# include "mincer.h" -# include "gravizone.h" -# include "radioactivezone.h" -# include "level_changer.h" -# include "script_zone.h" -# include "team_base_zone.h" -# include "torridZone.h" -# include "ZoneVisual.h" -# include "hairszone.h" +#include "xrEngine/std_classes.h" +#include "Level.h" +#include "gamepersistent.h" +#include "hudmanager.h" +#include "actor.h" +#include "spectator.h" + +#include "ai/monsters/flesh/flesh.h" +#include "ai/monsters/chimera/chimera.h" +#include "ai/monsters/dog/dog.h" +#include "ai/stalker/ai_stalker.h" +#include "ai/monsters/bloodsucker/bloodsucker.h" +#include "ai/monsters/boar/boar.h" +#include "ai/monsters/pseudodog/pseudodog.h" +#include "ai/monsters/pseudodog/psy_dog.h" +#include "ai/monsters/Burer/burer.h" +#include "ai/monsters/PseudoGigant/pseudo_gigant.h" +#include "ai/monsters/controller/controller.h" +#include "ai/monsters/poltergeist/poltergeist.h" +#include "ai/monsters/zombie/zombie.h" +#include "ai/monsters/fracture/fracture.h" +#include "ai/monsters/snork/snork.h" +#include "ai/monsters/cat/cat.h" +#include "ai/monsters/tushkano/tushkano.h" +#include "ai/monsters/rats/ai_rat.h" + +#include "ai/phantom/phantom.h" + +#include "ai/trader/ai_trader.h" + +#include "ai/crow/ai_crow.h" + +#ifdef DEBUG +#include "xrEngine/StatGraph.h" +#include "PHDebug.h" +#endif // DEBUG + +#include "hit.h" +#include "PHDestroyable.h" +#include "car.h" + +#include "helicopter.h" + +#include "MercuryBall.h" +#include "BlackDrops.h" +#include "BlackGraviArtifact.h" +#include "BastArtifact.h" +#include "DummyArtifact.h" +#include "ZudaArtifact.h" +#include "ThornArtifact.h" +#include "FadedBall.h" +#include "ElectricBall.h" +#include "RustyHairArtifact.h" +#include "GalantineArtifact.h" +#include "GraviArtifact.h" +#include "cta_game_artefact.h" + +#include "weaponFN2000.h" +#include "weaponAK74.h" +#include "weaponLR300.h" +#include "weaponHPSA.h" +#include "weaponPM.h" +#include "weaponAMMO.h" +#include "weaponFORT.h" +#include "weaponBINOCULARS.h" +#include "weaponShotgun.h" +#include "weaponsvd.h" +#include "weaponsvu.h" +#include "weaponrpg7.h" +#include "weaponval.h" +#include "weaponvintorez.h" +#include "weaponwalther.h" +#include "weaponusp45.h" +#include "weapongroza.h" +#include "weaponknife.h" +#include "weaponBM16.h" +#include "weaponRG6.h" +#include "WeaponStatMgun.h" + +#include "scope.h" +#include "silencer.h" +#include "grenadelauncher.h" + +#include "bolt.h" +#include "medkit.h" +#include "antirad.h" +#include "fooditem.h" +#include "bottleitem.h" +#include "explosiveitem.h" + +#include "infodocument.h" +#include "attachable_item.h" + +#include "ScientificOutfit.h" +#include "StalkerOutfit.h" +#include "MilitaryOutfit.h" +#include "ExoOutfit.h" +#include "ActorHelmet.h" + +#include "f1.h" +#include "rgd5.h" + +#include "explosiverocket.h" + +#include "MPPlayersBag.h" + +#include "customzone.h" +#include "mosquitobald.h" +#include "mincer.h" +#include "gravizone.h" +#include "radioactivezone.h" +#include "level_changer.h" +#include "script_zone.h" +#include "team_base_zone.h" +#include "torridZone.h" +#include "ZoneVisual.h" +#include "hairszone.h" //. # include "amebazone.h" -# include "nogravityzone.h" -# include "simpledetector.h" -# include "elitedetector.h" -# include "advanceddetector.h" -# include "zonecampfire.h" - -# include "torch.h" -# include "pda.h" -# include "flare.h" - -# include "searchlight.h" - -# include "HangingLamp.h" -# include "physicobject.h" -# include "script_object.h" -# include "BreakableObject.h" -# include "PhysicsSkeletonObject.h" -# include "DestroyablePhysicsObject.h" - -# include "game_sv_single.h" -# include "game_sv_deathmatch.h" -# include "game_sv_teamdeathmatch.h" -# include "game_sv_ArtefactHunt.h" -# include "game_sv_capture_the_artefact.h" - -# include "game_cl_single.h" -# include "game_cl_deathmatch.h" -# include "game_cl_teamdeathmatch.h" -# include "game_cl_ArtefactHunt.h" -# include "game_cl_capture_the_artefact.h" - -# include "UIGameSP.h" -# include "UIGameAHunt.h" -# include "UIGameCTA.h" -# include "climableobject.h" -# include "space_restrictor.h" -# include "smart_zone.h" -# include "InventoryBox.h" - -# include "actor_mp_server.h" -# include "actor_mp_client.h" -# include "smart_cover_object.h" -#endif // NO_XR_GAME +#include "nogravityzone.h" +#include "simpledetector.h" +#include "elitedetector.h" +#include "advanceddetector.h" +#include "zonecampfire.h" + +#include "torch.h" +#include "pda.h" +#include "flare.h" + +#include "searchlight.h" + +#include "HangingLamp.h" +#include "physicobject.h" +#include "script_object.h" +#include "BreakableObject.h" +#include "PhysicsSkeletonObject.h" +#include "DestroyablePhysicsObject.h" + +#include "game_sv_single.h" +#include "game_sv_deathmatch.h" +#include "game_sv_teamdeathmatch.h" +#include "game_sv_ArtefactHunt.h" +#include "game_sv_capture_the_artefact.h" + +#include "game_cl_single.h" +#include "game_cl_deathmatch.h" +#include "game_cl_teamdeathmatch.h" +#include "game_cl_ArtefactHunt.h" +#include "game_cl_capture_the_artefact.h" + +#include "UIGameSP.h" +#include "UIGameAHunt.h" +#include "UIGameCTA.h" +#include "climableobject.h" +#include "space_restrictor.h" +#include "smart_zone.h" +#include "InventoryBox.h" + +#include "actor_mp_server.h" +#include "actor_mp_client.h" +#include "smart_cover_object.h" +#endif // NO_XR_GAME #ifndef NO_XR_GAME - ENGINE_API bool g_dedicated_server; -# define ADD(a,b,c,d) add(c,d) -# define ADD_MP(a,b,c,d,e,f) add(new CObjectItemClientServerSingleMp(e,f)) +ENGINE_API bool g_dedicated_server; +#define ADD(a, b, c, d) add(c, d) +#define ADD_MP(a, b, c, d, e, f) add(new CObjectItemClientServerSingleMp(e, f)) #else -# define ADD(a,b,c,d) add(c,d) +#define ADD(a, b, c, d) add(c, d) #endif -void CObjectFactory::register_classes () +void CObjectFactory::register_classes() { #ifndef NO_XR_GAME - // client entities - add (CLSID_GAME_LEVEL ,"level"); - add (CLSID_GAME_PERSISTANT ,"game"); - add (CLSID_HUDMANAGER ,"hud_manager"); - //Server Game type - add (CLSID_SV_GAME_SINGLE ,"game_sv_single"); -#ifndef BENCHMARK_BUILD - add (CLSID_SV_GAME_DEATHMATCH ,"game_sv_deathmatch"); - add (CLSID_SV_GAME_TEAMDEATHMATCH ,"game_sv_team_deathmatch"); - add (CLSID_SV_GAME_ARTEFACTHUNT ,"game_sv_artefact_hunt"); - add (CLSID_SV_GAME_CAPTURETHEARTEFACT ,"game_sv_capture_the_artefact"); -#endif // BENCHMARK_BUILD - //Client Game type - add (CLSID_CL_GAME_SINGLE ,"game_cl_single"); -#ifndef BENCHMARK_BUILD - add (CLSID_CL_GAME_DEATHMATCH ,"game_cl_deathmatch"); - add (CLSID_CL_GAME_TEAMDEATHMATCH ,"game_cl_team_deathmatch"); - add (CLSID_CL_GAME_ARTEFACTHUNT ,"game_cl_artefact_hunt"); - add (CLSID_CL_GAME_CAPTURETHEARTEFACT ,"game_cl_capture_the_artefact"); -#endif // BENCHMARK_BUILD - - - add (CLSID_GAME_UI_SINGLE ,"game_ui_single"); - add (CLSID_GAME_UI_DEATHMATCH ,"game_ui_deathmatch"); - add (CLSID_GAME_UI_TEAMDEATHMATCH ,"game_ui_team_deathmatch"); - add (CLSID_GAME_UI_ARTEFACTHUNT ,"game_ui_artefact_hunt"); - add (CLSID_GAME_UI_CAPTURETHEARTEFACT ,"game_ui_capture_the_artefact"); - ADD_MP(CActor,CActorMP,CSE_ALifeCreatureActor,CSE_ActorMP ,CLSID_OBJECT_ACTOR ,"actor"); -#else // NO_XR_GAME - ADD(CActor ,CSE_ALifeCreatureActor ,CLSID_OBJECT_ACTOR ,"actor"); -#endif // NO_XR_GAME - - // server entities - add > (CLSID_AI_FLESH_GROUP ,"flesh_group"); -// add (CLSID_AI_SPAWN_GROUP ,"spawn_group"); - add (CLSID_AI_GRAPH ,"graph_point"); - add (CLSID_ONLINE_OFFLINE_GROUP ,"online_offline_group"); - // client and server entities - ADD(CSpectator ,CSE_Spectator ,CLSID_SPECTATOR ,"spectator"); - ADD(CAI_Flesh ,CSE_ALifeMonsterBase ,CLSID_AI_FLESH ,"flesh"); - ADD(CChimera ,CSE_ALifeMonsterBase ,CLSID_AI_CHIMERA ,"chimera"); - ADD(CAI_Dog ,CSE_ALifeMonsterBase ,CLSID_AI_DOG_RED ,"dog_red"); - ADD(CAI_Stalker ,CSE_ALifeHumanStalker ,CLSID_AI_STALKER ,"stalker"); - ADD(CAI_Bloodsucker ,CSE_ALifeMonsterBase ,CLSID_AI_BLOODSUCKER ,"bloodsucker"); - ADD(CAI_Boar ,CSE_ALifeMonsterBase ,CLSID_AI_BOAR ,"boar"); - ADD(CAI_PseudoDog ,CSE_ALifeMonsterBase ,CLSID_AI_DOG_BLACK ,"dog_black"); - ADD(CPsyDog ,CSE_ALifeMonsterBase ,CLSID_AI_DOG_PSY ,"psy_dog"); - ADD(CPsyDogPhantom ,CSE_ALifePsyDogPhantom ,CLSID_AI_DOG_PSY_PHANTOM ,"psy_dog_phantom"); - ADD(CBurer ,CSE_ALifeMonsterBase ,CLSID_AI_BURER ,"burer"); - ADD(CPseudoGigant ,CSE_ALifeMonsterBase ,CLSID_AI_GIANT ,"pseudo_gigant"); - ADD(CController ,CSE_ALifeMonsterBase ,CLSID_AI_CONTROLLER ,"controller"); - ADD(CPoltergeist ,CSE_ALifeMonsterBase ,CLSID_AI_POLTERGEIST ,"poltergeist"); - ADD(CZombie ,CSE_ALifeMonsterBase ,CLSID_AI_ZOMBIE ,"zombie"); - ADD(CFracture ,CSE_ALifeMonsterBase ,CLSID_AI_FRACTURE ,"fracture"); - ADD(CSnork ,CSE_ALifeMonsterBase ,CLSID_AI_SNORK ,"snork"); - ADD(CCat ,CSE_ALifeMonsterBase ,CLSID_AI_CAT ,"cat"); - ADD(CTushkano ,CSE_ALifeMonsterBase ,CLSID_AI_TUSHKANO ,"tushkano"); - - ADD(CPhantom ,CSE_ALifeCreaturePhantom ,CLSID_AI_PHANTOM ,"phantom"); - - // Trader - ADD(CAI_Trader ,CSE_ALifeTrader ,CLSID_AI_TRADER ,"trader"); - - ADD(CAI_Crow ,CSE_ALifeCreatureCrow ,CLSID_AI_CROW ,"crow"); - ADD(CAI_Rat ,CSE_ALifeMonsterRat ,CLSID_AI_RAT ,"rat"); - ADD(CCar ,CSE_ALifeCar ,CLSID_CAR ,"car"); - - ADD(CHelicopter ,CSE_ALifeHelicopter ,CLSID_VEHICLE_HELICOPTER ,"helicopter"); - // Artefacts - ADD(CMercuryBall ,CSE_ALifeItemArtefact ,CLSID_AF_MERCURY_BALL ,"art_mercury_ball"); - ADD(CBlackDrops ,CSE_ALifeItemArtefact ,CLSID_AF_BLACKDROPS ,"art_black_drops"); - ADD(CBlackGraviArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_NEEDLES ,"art_needles"); - ADD(CBastArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_BAST ,"art_bast_artefact"); - ADD(CBlackGraviArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_BLACK_GRAVI ,"art_gravi_black"); - ADD(CDummyArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_DUMMY ,"art_dummy"); - ADD(CZudaArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_ZUDA ,"art_zuda"); - ADD(CThornArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_THORN ,"art_thorn"); - ADD(CFadedBall ,CSE_ALifeItemArtefact ,CLSID_AF_FADED_BALL ,"art_faded_ball"); - ADD(CElectricBall ,CSE_ALifeItemArtefact ,CLSID_AF_ELECTRIC_BALL ,"art_electric_ball"); - ADD(CRustyHairArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_RUSTY_HAIR ,"art_rusty_hair"); - ADD(CGalantineArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_GALANTINE ,"art_galantine"); - ADD(CGraviArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_GRAVI ,"art_gravi"); - ADD(CGraviArtefact ,CSE_ALifeItemArtefact ,CLSID_ARTEFACT ,"artefact"); - ADD(CtaGameArtefact ,CSE_ALifeItemArtefact ,CLSID_AF_CTA ,"art_cta"); - - // [8/15/2006] - ADD(CWeaponMagazined ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_MAGAZINED ,"wpn_wmagaz"); - // [8/15/2006] - // [8/17/2006] - ADD(CWeaponMagazinedWGrenade,CSE_ALifeItemWeaponMagazinedWGL,CLSID_OBJECT_W_MAGAZWGL ,"wpn_wmaggl"); - // [8/17/2006] - ADD(CWeaponFN2000 ,CSE_ALifeItemWeaponMagazinedWGL ,CLSID_OBJECT_W_FN2000 ,"wpn_fn2000"); - ADD(CWeaponAK74 ,CSE_ALifeItemWeaponMagazinedWGL ,CLSID_OBJECT_W_AK74 ,"wpn_ak74"); - ADD(CWeaponLR300 ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_LR300 ,"wpn_lr300"); - ADD(CWeaponHPSA ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_HPSA ,"wpn_hpsa"); - ADD(CWeaponPM ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_PM ,"wpn_pm"); - ADD(CWeaponFORT ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_FORT ,"wpn_fort"); - ADD(CWeaponBinoculars ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_BINOCULAR ,"wpn_binocular"); - ADD(CWeaponShotgun ,CSE_ALifeItemWeaponShotGun ,CLSID_OBJECT_W_SHOTGUN ,"wpn_shotgun"); - ADD(CWeaponSVD ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_SVD ,"wpn_svd"); - ADD(CWeaponSVU ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_SVU ,"wpn_svu"); - ADD(CWeaponRPG7 ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_RPG7 ,"wpn_rpg7"); - ADD(CWeaponVal ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_VAL ,"wpn_val"); - ADD(CWeaponVintorez ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_VINTOREZ ,"wpn_vintorez"); - ADD(CWeaponWalther ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_WALTHER ,"wpn_walther"); - ADD(CWeaponUSP45 ,CSE_ALifeItemWeaponMagazined ,CLSID_OBJECT_W_USP45 ,"wpn_usp45"); - ADD(CWeaponGroza ,CSE_ALifeItemWeaponMagazinedWGL,CLSID_OBJECT_W_GROZA ,"wpn_groza"); - ADD(CWeaponKnife ,CSE_ALifeItemWeapon ,CLSID_OBJECT_W_KNIFE ,"wpn_knife"); - ADD(CWeaponBM16 ,CSE_ALifeItemWeaponShotGun ,CLSID_OBJECT_W_BM16 ,"wpn_bm16"); - ADD(CWeaponRG6 ,CSE_ALifeItemWeaponShotGun ,CLSID_OBJECT_W_RG6 ,"wpn_rg6"); - //----------------------------------------------------------------------------------------------------- - ADD(CWeaponAmmo ,CSE_ALifeItemAmmo ,CLSID_OBJECT_AMMO ,"wpn_ammo"); - ADD(CWeaponAmmo ,CSE_ALifeItemAmmo ,CLSID_OBJECT_A_VOG25 ,"wpn_ammo_vog25"); - ADD(CWeaponAmmo ,CSE_ALifeItemAmmo ,CLSID_OBJECT_A_OG7B ,"wpn_ammo_og7b"); - ADD(CWeaponAmmo ,CSE_ALifeItemAmmo ,CLSID_OBJECT_A_M209 ,"wpn_ammo_m209"); - //----------------------------------------------------------------------------------------------------- - - //Weapons Add-on - ADD(CScope ,CSE_ALifeItem ,CLSID_OBJECT_W_SCOPE ,"wpn_scope"); - ADD(CSilencer ,CSE_ALifeItem ,CLSID_OBJECT_W_SILENCER ,"wpn_silencer"); - ADD(CGrenadeLauncher ,CSE_ALifeItem ,CLSID_OBJECT_W_GLAUNCHER ,"wpn_grenade_launcher"); - - // Inventory - ADD(CBolt ,CSE_ALifeItemBolt ,CLSID_IITEM_BOLT ,"obj_bolt"); - ADD(CMedkit ,CSE_ALifeItem ,CLSID_IITEM_MEDKIT ,"obj_medkit"); - ADD(CMedkit ,CSE_ALifeItem ,CLSID_IITEM_BANDAGE ,"obj_bandage"); - ADD(CAntirad ,CSE_ALifeItem ,CLSID_IITEM_ANTIRAD ,"obj_antirad"); - ADD(CFoodItem ,CSE_ALifeItem ,CLSID_IITEM_FOOD ,"obj_food"); - ADD(CBottleItem ,CSE_ALifeItem ,CLSID_IITEM_BOTTLE ,"obj_bottle"); - ADD(CExplosiveItem ,CSE_ALifeItemExplosive ,CLSID_IITEM_EXPLOSIVE ,"obj_explosive"); - - //Info Document - ADD(CInfoDocument ,CSE_ALifeItemDocument ,CLSID_IITEM_DOCUMENT ,"obj_document"); - ADD(CInventoryItemObject ,CSE_ALifeItem ,CLSID_IITEM_ATTACH ,"obj_attachable"); - - //Equipment outfit - ADD(CScientificOutfit ,CSE_ALifeItemCustomOutfit ,CLSID_EQUIPMENT_SCIENTIFIC ,"equ_scientific"); - ADD(CStalkerOutfit ,CSE_ALifeItemCustomOutfit ,CLSID_EQUIPMENT_STALKER ,"equ_stalker"); - ADD(CMilitaryOutfit ,CSE_ALifeItemCustomOutfit ,CLSID_EQUIPMENT_MILITARY ,"equ_military"); - ADD(CExoOutfit ,CSE_ALifeItemCustomOutfit ,CLSID_EQUIPMENT_EXO ,"equ_exo"); - ADD(CHelmet ,CSE_ALifeItem ,CLSID_EQUIPMENT_HELMET ,"helmet"); - - // Grenades - ADD(CF1 ,CSE_ALifeItemGrenade ,CLSID_GRENADE_F1 ,"wpn_grenade_f1"); - ADD(CRGD5 ,CSE_ALifeItemGrenade ,CLSID_GRENADE_RGD5 ,"wpn_grenade_rgd5"); - - // Rockets - ADD(CExplosiveRocket ,CSE_Temporary ,CLSID_OBJECT_G_RPG7 ,"wpn_grenade_rpg7"); - ADD(CExplosiveRocket ,CSE_Temporary ,CLSID_OBJECT_G_FAKE ,"wpn_grenade_fake"); - - //----------------------------------------------------------------------------------------------------------------- - ADD(CMPPlayersBag ,CSE_ALifeItem ,CLSID_OBJECT_PLAYERS_BAG ,"mp_players_bag"); - //----------------------------------------------------------------------------------------------------------------- - - // Zones - ADD(CCustomZone ,CSE_ALifeCustomZone ,CLSID_ZONE ,"zone"); - ADD(CMosquitoBald ,CSE_ALifeAnomalousZone ,CLSID_Z_MBALD ,"zone_mosquito_bald"); - ADD(CMincer ,CSE_ALifeAnomalousZone ,CLSID_Z_MINCER ,"zone_mincer"); - ADD(CMosquitoBald ,CSE_ALifeAnomalousZone ,CLSID_Z_ACIDF ,"zone_acid_fog"); - ADD(CMincer ,CSE_ALifeAnomalousZone ,CLSID_Z_GALANT ,"zone_galantine"); - ADD(CRadioactiveZone ,CSE_ALifeAnomalousZone ,CLSID_Z_RADIO ,"zone_radioactive"); - ADD(CHairsZone ,CSE_ALifeZoneVisual ,CLSID_Z_BFUZZ ,"zone_bfuzz"); - ADD(CHairsZone ,CSE_ALifeZoneVisual ,CLSID_Z_RUSTYH ,"zone_rusty_hair"); - ADD(CMosquitoBald ,CSE_ALifeAnomalousZone ,CLSID_Z_DEAD ,"zone_dead"); -#ifndef BENCHMARK_BUILD - ADD(CLevelChanger ,CSE_ALifeLevelChanger ,CLSID_LEVEL_CHANGER ,"level_changer"); -#endif // BENCHMARK_BUILD - ADD(CScriptZone ,CSE_ALifeSpaceRestrictor ,CLSID_SCRIPT_ZONE ,"script_zone"); - ADD(CSmartZone ,CSE_ALifeSmartZone ,CLSID_SMART_ZONE ,"smart_zone"); - ADD(CTeamBaseZone ,CSE_ALifeTeamBaseZone ,CLSID_Z_TEAM_BASE ,"team_base_zone"); - ADD(CTorridZone ,CSE_ALifeTorridZone ,CLSID_Z_TORRID ,"torrid_zone"); - ADD(CSpaceRestrictor ,CSE_ALifeSpaceRestrictor ,CLSID_SPACE_RESTRICTOR ,"space_restrictor"); -//. ADD(CAmebaZone ,CSE_ALifeZoneVisual ,CLSID_Z_AMEBA ,"ameba_zone"); - ADD(CNoGravityZone ,CSE_ALifeAnomalousZone ,CLSID_Z_NOGRAVITY ,"nogravity_zone"); - ADD(CZoneCampfire ,CSE_ALifeAnomalousZone ,CLSID_Z_CAMPFIRE ,"zone_campfire"); - // Detectors - ADD(CSimpleDetector ,CSE_ALifeItemDetector ,CLSID_DETECTOR_SIMPLE ,"device_detector_simple"); - ADD(CAdvancedDetector ,CSE_ALifeItemDetector ,CLSID_DETECTOR_ADVANCED ,"device_detector_advanced"); - ADD(CEliteDetector ,CSE_ALifeItemDetector ,CLSID_DETECTOR_ELITE ,"device_detector_elite"); - ADD(CScientificDetector ,CSE_ALifeItemDetector ,CLSID_DETECTOR_SCIENTIFIC ,"device_detector_scientific"); - - // Devices - ADD(CTorch ,CSE_ALifeItemTorch ,CLSID_DEVICE_TORCH ,"device_torch"); - ADD(CPda ,CSE_ALifeItemPDA ,CLSID_DEVICE_PDA ,"device_pda"); - ADD(CFlare ,CSE_ALifeItem ,CLSID_DEVICE_FLARE ,"device_flare"); - - // objects - ADD(CProjector ,CSE_ALifeObjectProjector ,CLSID_OBJECT_PROJECTOR ,"projector"); - ADD(CWeaponStatMgun ,CSE_ALifeStationaryMgun ,CLSID_OBJECT_W_STATMGUN ,"wpn_stat_mgun"); -// ADD(CTrigger ,CSE_Trigger ,CLSID_OBJECT_TRIGGER ,"trigger"); - - // entity - ADD(CHangingLamp ,CSE_ALifeObjectHangingLamp ,CLSID_OBJECT_HLAMP ,"hanging_lamp"); - ADD(CPhysicObject ,CSE_ALifeObjectPhysic ,CLSID_OBJECT_PHYSIC ,"obj_physic"); - ADD(CScriptObject ,CSE_ALifeDynamicObjectVisual ,CLSID_SCRIPT_OBJECT ,"script_object"); - ADD(CBreakableObject ,CSE_ALifeObjectBreakable ,CLSID_OBJECT_BREAKABLE ,"obj_breakable"); - ADD(CClimableObject ,CSE_ALifeObjectClimable ,CLSID_OBJECT_CLIMABLE ,"obj_climable"); - ADD(CPhysicsSkeletonObject ,CSE_ALifePHSkeletonObject ,CLSID_PH_SKELETON_OBJECT ,"obj_phskeleton"); - ADD(CDestroyablePhysicsObject,CSE_ALifeObjectPhysic ,CLSID_PHYSICS_DESTROYABLE ,"obj_phys_destroyable"); - - ADD(CInventoryBox ,CSE_ALifeInventoryBox ,CLSID_INVENTORY_BOX ,"inventory_box"); - ADD(smart_cover::object ,CSE_SmartCover ,TEXT2CLSID("SMRTCOVR") ,"smart_cover"); + // client entities + add(CLSID_GAME_LEVEL, "level"); + add(CLSID_GAME_PERSISTANT, "game"); + add(CLSID_HUDMANAGER, "hud_manager"); + // Server Game type + add(CLSID_SV_GAME_SINGLE, "game_sv_single"); +#ifndef BENCHMARK_BUILD + add(CLSID_SV_GAME_DEATHMATCH, "game_sv_deathmatch"); + add(CLSID_SV_GAME_TEAMDEATHMATCH, "game_sv_team_deathmatch"); + add(CLSID_SV_GAME_ARTEFACTHUNT, "game_sv_artefact_hunt"); + add(CLSID_SV_GAME_CAPTURETHEARTEFACT, "game_sv_capture_the_artefact"); +#endif // BENCHMARK_BUILD + // Client Game type + add(CLSID_CL_GAME_SINGLE, "game_cl_single"); +#ifndef BENCHMARK_BUILD + add(CLSID_CL_GAME_DEATHMATCH, "game_cl_deathmatch"); + add(CLSID_CL_GAME_TEAMDEATHMATCH, "game_cl_team_deathmatch"); + add(CLSID_CL_GAME_ARTEFACTHUNT, "game_cl_artefact_hunt"); + add(CLSID_CL_GAME_CAPTURETHEARTEFACT, "game_cl_capture_the_artefact"); +#endif // BENCHMARK_BUILD + + add(CLSID_GAME_UI_SINGLE, "game_ui_single"); + add(CLSID_GAME_UI_DEATHMATCH, "game_ui_deathmatch"); + add(CLSID_GAME_UI_TEAMDEATHMATCH, "game_ui_team_deathmatch"); + add(CLSID_GAME_UI_ARTEFACTHUNT, "game_ui_artefact_hunt"); + add(CLSID_GAME_UI_CAPTURETHEARTEFACT, "game_ui_capture_the_artefact"); + ADD_MP(CActor, CActorMP, CSE_ALifeCreatureActor, CSE_ActorMP, CLSID_OBJECT_ACTOR, "actor"); +#else // NO_XR_GAME + ADD(CActor, CSE_ALifeCreatureActor, CLSID_OBJECT_ACTOR, "actor"); +#endif // NO_XR_GAME + + // server entities + add>(CLSID_AI_FLESH_GROUP, "flesh_group"); + // add (CLSID_AI_SPAWN_GROUP ,"spawn_group"); + add(CLSID_AI_GRAPH, "graph_point"); + add(CLSID_ONLINE_OFFLINE_GROUP, "online_offline_group"); + // client and server entities + ADD(CSpectator, CSE_Spectator, CLSID_SPECTATOR, "spectator"); + ADD(CAI_Flesh, CSE_ALifeMonsterBase, CLSID_AI_FLESH, "flesh"); + ADD(CChimera, CSE_ALifeMonsterBase, CLSID_AI_CHIMERA, "chimera"); + ADD(CAI_Dog, CSE_ALifeMonsterBase, CLSID_AI_DOG_RED, "dog_red"); + ADD(CAI_Stalker, CSE_ALifeHumanStalker, CLSID_AI_STALKER, "stalker"); + ADD(CAI_Bloodsucker, CSE_ALifeMonsterBase, CLSID_AI_BLOODSUCKER, "bloodsucker"); + ADD(CAI_Boar, CSE_ALifeMonsterBase, CLSID_AI_BOAR, "boar"); + ADD(CAI_PseudoDog, CSE_ALifeMonsterBase, CLSID_AI_DOG_BLACK, "dog_black"); + ADD(CPsyDog, CSE_ALifeMonsterBase, CLSID_AI_DOG_PSY, "psy_dog"); + ADD(CPsyDogPhantom, CSE_ALifePsyDogPhantom, CLSID_AI_DOG_PSY_PHANTOM, "psy_dog_phantom"); + ADD(CBurer, CSE_ALifeMonsterBase, CLSID_AI_BURER, "burer"); + ADD(CPseudoGigant, CSE_ALifeMonsterBase, CLSID_AI_GIANT, "pseudo_gigant"); + ADD(CController, CSE_ALifeMonsterBase, CLSID_AI_CONTROLLER, "controller"); + ADD(CPoltergeist, CSE_ALifeMonsterBase, CLSID_AI_POLTERGEIST, "poltergeist"); + ADD(CZombie, CSE_ALifeMonsterBase, CLSID_AI_ZOMBIE, "zombie"); + ADD(CFracture, CSE_ALifeMonsterBase, CLSID_AI_FRACTURE, "fracture"); + ADD(CSnork, CSE_ALifeMonsterBase, CLSID_AI_SNORK, "snork"); + ADD(CCat, CSE_ALifeMonsterBase, CLSID_AI_CAT, "cat"); + ADD(CTushkano, CSE_ALifeMonsterBase, CLSID_AI_TUSHKANO, "tushkano"); + + ADD(CPhantom, CSE_ALifeCreaturePhantom, CLSID_AI_PHANTOM, "phantom"); + + // Trader + ADD(CAI_Trader, CSE_ALifeTrader, CLSID_AI_TRADER, "trader"); + + ADD(CAI_Crow, CSE_ALifeCreatureCrow, CLSID_AI_CROW, "crow"); + ADD(CAI_Rat, CSE_ALifeMonsterRat, CLSID_AI_RAT, "rat"); + ADD(CCar, CSE_ALifeCar, CLSID_CAR, "car"); + + ADD(CHelicopter, CSE_ALifeHelicopter, CLSID_VEHICLE_HELICOPTER, "helicopter"); + // Artefacts + ADD(CMercuryBall, CSE_ALifeItemArtefact, CLSID_AF_MERCURY_BALL, "art_mercury_ball"); + ADD(CBlackDrops, CSE_ALifeItemArtefact, CLSID_AF_BLACKDROPS, "art_black_drops"); + ADD(CBlackGraviArtefact, CSE_ALifeItemArtefact, CLSID_AF_NEEDLES, "art_needles"); + ADD(CBastArtefact, CSE_ALifeItemArtefact, CLSID_AF_BAST, "art_bast_artefact"); + ADD(CBlackGraviArtefact, CSE_ALifeItemArtefact, CLSID_AF_BLACK_GRAVI, "art_gravi_black"); + ADD(CDummyArtefact, CSE_ALifeItemArtefact, CLSID_AF_DUMMY, "art_dummy"); + ADD(CZudaArtefact, CSE_ALifeItemArtefact, CLSID_AF_ZUDA, "art_zuda"); + ADD(CThornArtefact, CSE_ALifeItemArtefact, CLSID_AF_THORN, "art_thorn"); + ADD(CFadedBall, CSE_ALifeItemArtefact, CLSID_AF_FADED_BALL, "art_faded_ball"); + ADD(CElectricBall, CSE_ALifeItemArtefact, CLSID_AF_ELECTRIC_BALL, "art_electric_ball"); + ADD(CRustyHairArtefact, CSE_ALifeItemArtefact, CLSID_AF_RUSTY_HAIR, "art_rusty_hair"); + ADD(CGalantineArtefact, CSE_ALifeItemArtefact, CLSID_AF_GALANTINE, "art_galantine"); + ADD(CGraviArtefact, CSE_ALifeItemArtefact, CLSID_AF_GRAVI, "art_gravi"); + ADD(CGraviArtefact, CSE_ALifeItemArtefact, CLSID_ARTEFACT, "artefact"); + ADD(CtaGameArtefact, CSE_ALifeItemArtefact, CLSID_AF_CTA, "art_cta"); + + // [8/15/2006] + ADD(CWeaponMagazined, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_MAGAZINED, "wpn_wmagaz"); + // [8/15/2006] + // [8/17/2006] + ADD(CWeaponMagazinedWGrenade, CSE_ALifeItemWeaponMagazinedWGL, CLSID_OBJECT_W_MAGAZWGL, "wpn_wmaggl"); + // [8/17/2006] + ADD(CWeaponFN2000, CSE_ALifeItemWeaponMagazinedWGL, CLSID_OBJECT_W_FN2000, "wpn_fn2000"); + ADD(CWeaponAK74, CSE_ALifeItemWeaponMagazinedWGL, CLSID_OBJECT_W_AK74, "wpn_ak74"); + ADD(CWeaponLR300, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_LR300, "wpn_lr300"); + ADD(CWeaponHPSA, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_HPSA, "wpn_hpsa"); + ADD(CWeaponPM, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_PM, "wpn_pm"); + ADD(CWeaponFORT, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_FORT, "wpn_fort"); + ADD(CWeaponBinoculars, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_BINOCULAR, "wpn_binocular"); + ADD(CWeaponShotgun, CSE_ALifeItemWeaponShotGun, CLSID_OBJECT_W_SHOTGUN, "wpn_shotgun"); + ADD(CWeaponSVD, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_SVD, "wpn_svd"); + ADD(CWeaponSVU, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_SVU, "wpn_svu"); + ADD(CWeaponRPG7, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_RPG7, "wpn_rpg7"); + ADD(CWeaponVal, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_VAL, "wpn_val"); + ADD(CWeaponVintorez, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_VINTOREZ, "wpn_vintorez"); + ADD(CWeaponWalther, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_WALTHER, "wpn_walther"); + ADD(CWeaponUSP45, CSE_ALifeItemWeaponMagazined, CLSID_OBJECT_W_USP45, "wpn_usp45"); + ADD(CWeaponGroza, CSE_ALifeItemWeaponMagazinedWGL, CLSID_OBJECT_W_GROZA, "wpn_groza"); + ADD(CWeaponKnife, CSE_ALifeItemWeapon, CLSID_OBJECT_W_KNIFE, "wpn_knife"); + ADD(CWeaponBM16, CSE_ALifeItemWeaponShotGun, CLSID_OBJECT_W_BM16, "wpn_bm16"); + ADD(CWeaponRG6, CSE_ALifeItemWeaponShotGun, CLSID_OBJECT_W_RG6, "wpn_rg6"); + //----------------------------------------------------------------------------------------------------- + ADD(CWeaponAmmo, CSE_ALifeItemAmmo, CLSID_OBJECT_AMMO, "wpn_ammo"); + ADD(CWeaponAmmo, CSE_ALifeItemAmmo, CLSID_OBJECT_A_VOG25, "wpn_ammo_vog25"); + ADD(CWeaponAmmo, CSE_ALifeItemAmmo, CLSID_OBJECT_A_OG7B, "wpn_ammo_og7b"); + ADD(CWeaponAmmo, CSE_ALifeItemAmmo, CLSID_OBJECT_A_M209, "wpn_ammo_m209"); + //----------------------------------------------------------------------------------------------------- + + // Weapons Add-on + ADD(CScope, CSE_ALifeItem, CLSID_OBJECT_W_SCOPE, "wpn_scope"); + ADD(CSilencer, CSE_ALifeItem, CLSID_OBJECT_W_SILENCER, "wpn_silencer"); + ADD(CGrenadeLauncher, CSE_ALifeItem, CLSID_OBJECT_W_GLAUNCHER, "wpn_grenade_launcher"); + + // Inventory + ADD(CBolt, CSE_ALifeItemBolt, CLSID_IITEM_BOLT, "obj_bolt"); + ADD(CMedkit, CSE_ALifeItem, CLSID_IITEM_MEDKIT, "obj_medkit"); + ADD(CMedkit, CSE_ALifeItem, CLSID_IITEM_BANDAGE, "obj_bandage"); + ADD(CAntirad, CSE_ALifeItem, CLSID_IITEM_ANTIRAD, "obj_antirad"); + ADD(CFoodItem, CSE_ALifeItem, CLSID_IITEM_FOOD, "obj_food"); + ADD(CBottleItem, CSE_ALifeItem, CLSID_IITEM_BOTTLE, "obj_bottle"); + ADD(CExplosiveItem, CSE_ALifeItemExplosive, CLSID_IITEM_EXPLOSIVE, "obj_explosive"); + + // Info Document + ADD(CInfoDocument, CSE_ALifeItemDocument, CLSID_IITEM_DOCUMENT, "obj_document"); + ADD(CInventoryItemObject, CSE_ALifeItem, CLSID_IITEM_ATTACH, "obj_attachable"); + + // Equipment outfit + ADD(CScientificOutfit, CSE_ALifeItemCustomOutfit, CLSID_EQUIPMENT_SCIENTIFIC, "equ_scientific"); + ADD(CStalkerOutfit, CSE_ALifeItemCustomOutfit, CLSID_EQUIPMENT_STALKER, "equ_stalker"); + ADD(CMilitaryOutfit, CSE_ALifeItemCustomOutfit, CLSID_EQUIPMENT_MILITARY, "equ_military"); + ADD(CExoOutfit, CSE_ALifeItemCustomOutfit, CLSID_EQUIPMENT_EXO, "equ_exo"); + ADD(CHelmet, CSE_ALifeItem, CLSID_EQUIPMENT_HELMET, "helmet"); + + // Grenades + ADD(CF1, CSE_ALifeItemGrenade, CLSID_GRENADE_F1, "wpn_grenade_f1"); + ADD(CRGD5, CSE_ALifeItemGrenade, CLSID_GRENADE_RGD5, "wpn_grenade_rgd5"); + + // Rockets + ADD(CExplosiveRocket, CSE_Temporary, CLSID_OBJECT_G_RPG7, "wpn_grenade_rpg7"); + ADD(CExplosiveRocket, CSE_Temporary, CLSID_OBJECT_G_FAKE, "wpn_grenade_fake"); + + //----------------------------------------------------------------------------------------------------------------- + ADD(CMPPlayersBag, CSE_ALifeItem, CLSID_OBJECT_PLAYERS_BAG, "mp_players_bag"); + //----------------------------------------------------------------------------------------------------------------- + + // Zones + ADD(CCustomZone, CSE_ALifeCustomZone, CLSID_ZONE, "zone"); + ADD(CMosquitoBald, CSE_ALifeAnomalousZone, CLSID_Z_MBALD, "zone_mosquito_bald"); + ADD(CMincer, CSE_ALifeAnomalousZone, CLSID_Z_MINCER, "zone_mincer"); + ADD(CMosquitoBald, CSE_ALifeAnomalousZone, CLSID_Z_ACIDF, "zone_acid_fog"); + ADD(CMincer, CSE_ALifeAnomalousZone, CLSID_Z_GALANT, "zone_galantine"); + ADD(CRadioactiveZone, CSE_ALifeAnomalousZone, CLSID_Z_RADIO, "zone_radioactive"); + ADD(CHairsZone, CSE_ALifeZoneVisual, CLSID_Z_BFUZZ, "zone_bfuzz"); + ADD(CHairsZone, CSE_ALifeZoneVisual, CLSID_Z_RUSTYH, "zone_rusty_hair"); + ADD(CMosquitoBald, CSE_ALifeAnomalousZone, CLSID_Z_DEAD, "zone_dead"); +#ifndef BENCHMARK_BUILD + ADD(CLevelChanger, CSE_ALifeLevelChanger, CLSID_LEVEL_CHANGER, "level_changer"); +#endif // BENCHMARK_BUILD + ADD(CScriptZone, CSE_ALifeSpaceRestrictor, CLSID_SCRIPT_ZONE, "script_zone"); + ADD(CSmartZone, CSE_ALifeSmartZone, CLSID_SMART_ZONE, "smart_zone"); + ADD(CTeamBaseZone, CSE_ALifeTeamBaseZone, CLSID_Z_TEAM_BASE, "team_base_zone"); + ADD(CTorridZone, CSE_ALifeTorridZone, CLSID_Z_TORRID, "torrid_zone"); + ADD(CSpaceRestrictor, CSE_ALifeSpaceRestrictor, CLSID_SPACE_RESTRICTOR, "space_restrictor"); + //. ADD(CAmebaZone ,CSE_ALifeZoneVisual ,CLSID_Z_AMEBA ,"ameba_zone"); + ADD(CNoGravityZone, CSE_ALifeAnomalousZone, CLSID_Z_NOGRAVITY, "nogravity_zone"); + ADD(CZoneCampfire, CSE_ALifeAnomalousZone, CLSID_Z_CAMPFIRE, "zone_campfire"); + // Detectors + ADD(CSimpleDetector, CSE_ALifeItemDetector, CLSID_DETECTOR_SIMPLE, "device_detector_simple"); + ADD(CAdvancedDetector, CSE_ALifeItemDetector, CLSID_DETECTOR_ADVANCED, "device_detector_advanced"); + ADD(CEliteDetector, CSE_ALifeItemDetector, CLSID_DETECTOR_ELITE, "device_detector_elite"); + ADD(CScientificDetector, CSE_ALifeItemDetector, CLSID_DETECTOR_SCIENTIFIC, "device_detector_scientific"); + + // Devices + ADD(CTorch, CSE_ALifeItemTorch, CLSID_DEVICE_TORCH, "device_torch"); + ADD(CPda, CSE_ALifeItemPDA, CLSID_DEVICE_PDA, "device_pda"); + ADD(CFlare, CSE_ALifeItem, CLSID_DEVICE_FLARE, "device_flare"); + + // objects + ADD(CProjector, CSE_ALifeObjectProjector, CLSID_OBJECT_PROJECTOR, "projector"); + ADD(CWeaponStatMgun, CSE_ALifeStationaryMgun, CLSID_OBJECT_W_STATMGUN, "wpn_stat_mgun"); + // ADD(CTrigger ,CSE_Trigger ,CLSID_OBJECT_TRIGGER ,"trigger"); + + // entity + ADD(CHangingLamp, CSE_ALifeObjectHangingLamp, CLSID_OBJECT_HLAMP, "hanging_lamp"); + ADD(CPhysicObject, CSE_ALifeObjectPhysic, CLSID_OBJECT_PHYSIC, "obj_physic"); + ADD(CScriptObject, CSE_ALifeDynamicObjectVisual, CLSID_SCRIPT_OBJECT, "script_object"); + ADD(CBreakableObject, CSE_ALifeObjectBreakable, CLSID_OBJECT_BREAKABLE, "obj_breakable"); + ADD(CClimableObject, CSE_ALifeObjectClimable, CLSID_OBJECT_CLIMABLE, "obj_climable"); + ADD(CPhysicsSkeletonObject, CSE_ALifePHSkeletonObject, CLSID_PH_SKELETON_OBJECT, "obj_phskeleton"); + ADD(CDestroyablePhysicsObject, CSE_ALifeObjectPhysic, CLSID_PHYSICS_DESTROYABLE, "obj_phys_destroyable"); + + ADD(CInventoryBox, CSE_ALifeInventoryBox, CLSID_INVENTORY_BOX, "inventory_box"); + ADD(smart_cover::object, CSE_SmartCover, TEXT2CLSID("SMRTCOVR"), "smart_cover"); #ifndef NO_XR_GAME - // hack, for dedicated server only - // because we do not have scripts - // and script functionality is not - // needed here - if (!g_dedicated_server) - return; - - ADD(CElectricBall ,CSE_ALifeItemArtefact ,TEXT2CLSID("SCRPTART") ,"artefact_s"); -// ADD(CtaGameArtefact ,CSE_ALifeItemArtefact ,TEXT2CLSID("AF_CTA") ,"ctaartefact_s"); - ADD(CTorch ,CSE_ALifeItemTorch ,TEXT2CLSID("TORCH_S") ,"device_torch_s"); - ADD(CStalkerOutfit ,CSE_ALifeItemCustomOutfit ,TEXT2CLSID("E_STLK") ,"equ_stalker_s"); - ADD(CScope ,CSE_ALifeItem ,TEXT2CLSID("WP_SCOPE") ,"wpn_scope_s"); - ADD(CWeaponAK74 ,CSE_ALifeItemWeaponMagazinedWGL,TEXT2CLSID("WP_AK74") ,"wpn_ak74_s"); - ADD(CWeaponLR300 ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_LR300") ,"wpn_lr300_s"); - ADD(CWeaponBinoculars ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_BINOC") ,"wpn_binocular_s"); - ADD(CWeaponBM16 ,CSE_ALifeItemWeaponShotGun ,TEXT2CLSID("WP_BM16") ,"wpn_bm16_s"); - ADD(CWeaponGroza ,CSE_ALifeItemWeaponMagazinedWGL,TEXT2CLSID("WP_GROZA") ,"wpn_groza_s"); - ADD(CWeaponSVD ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_SVD") ,"wpn_svd_s"); - ADD(CWeaponHPSA ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_HPSA") ,"wpn_hpsa_s"); - ADD(CWeaponKnife ,CSE_ALifeItemWeapon ,TEXT2CLSID("WP_KNIFE") ,"wpn_knife_s"); - ADD(CWeaponPM ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_PM") ,"wpn_pm_s"); - ADD(CWeaponRG6 ,CSE_ALifeItemWeaponShotGun ,TEXT2CLSID("WP_RG6") ,"wpn_rg6_s"); - ADD(CWeaponRPG7 ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_RPG7") ,"wpn_rpg7_s"); - ADD(CWeaponShotgun ,CSE_ALifeItemWeaponShotGun ,TEXT2CLSID("WP_SHOTG") ,"wpn_shotgun_s"); - ADD(CWeaponSVU ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_SVU") ,"wpn_svu_s"); - ADD(CWeaponUSP45 ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_USP45") ,"wpn_usp45_s"); - ADD(CWeaponVal ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_VAL") ,"wpn_val_s"); - ADD(CWeaponVintorez ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_VINT") ,"wpn_vintorez_s"); - ADD(CWeaponWalther ,CSE_ALifeItemWeaponMagazined ,TEXT2CLSID("WP_WALTH") ,"wpn_walther_s"); - ADD(CHairsZone ,CSE_ALifeZoneVisual ,TEXT2CLSID("ZS_BFUZZ") ,"zone_bfuzz_s"); - ADD(CMosquitoBald ,CSE_ALifeAnomalousZone ,TEXT2CLSID("ZS_MBALD") ,"zone_mbald_s"); - ADD(CMincer ,CSE_ALifeAnomalousZone ,TEXT2CLSID("ZS_GALAN") ,"zone_galant_s"); - ADD(CMincer ,CSE_ALifeAnomalousZone ,TEXT2CLSID("ZS_MINCE") ,"zone_mincer_s"); - ADD(CSpaceRestrictor ,CSE_ALifeSpaceRestrictor ,TEXT2CLSID("SPC_RS_S") ,"script_restr"); -#endif // NO_XR_GAME + // hack, for dedicated server only + // because we do not have scripts + // and script functionality is not + // needed here + if (!g_dedicated_server) return; + + ADD(CElectricBall, CSE_ALifeItemArtefact, TEXT2CLSID("SCRPTART"), "artefact_s"); + // ADD(CtaGameArtefact ,CSE_ALifeItemArtefact ,TEXT2CLSID("AF_CTA") ,"ctaartefact_s"); + ADD(CTorch, CSE_ALifeItemTorch, TEXT2CLSID("TORCH_S"), "device_torch_s"); + ADD(CStalkerOutfit, CSE_ALifeItemCustomOutfit, TEXT2CLSID("E_STLK"), "equ_stalker_s"); + ADD(CScope, CSE_ALifeItem, TEXT2CLSID("WP_SCOPE"), "wpn_scope_s"); + ADD(CWeaponAK74, CSE_ALifeItemWeaponMagazinedWGL, TEXT2CLSID("WP_AK74"), "wpn_ak74_s"); + ADD(CWeaponLR300, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_LR300"), "wpn_lr300_s"); + ADD(CWeaponBinoculars, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_BINOC"), "wpn_binocular_s"); + ADD(CWeaponBM16, CSE_ALifeItemWeaponShotGun, TEXT2CLSID("WP_BM16"), "wpn_bm16_s"); + ADD(CWeaponGroza, CSE_ALifeItemWeaponMagazinedWGL, TEXT2CLSID("WP_GROZA"), "wpn_groza_s"); + ADD(CWeaponSVD, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_SVD"), "wpn_svd_s"); + ADD(CWeaponHPSA, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_HPSA"), "wpn_hpsa_s"); + ADD(CWeaponKnife, CSE_ALifeItemWeapon, TEXT2CLSID("WP_KNIFE"), "wpn_knife_s"); + ADD(CWeaponPM, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_PM"), "wpn_pm_s"); + ADD(CWeaponRG6, CSE_ALifeItemWeaponShotGun, TEXT2CLSID("WP_RG6"), "wpn_rg6_s"); + ADD(CWeaponRPG7, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_RPG7"), "wpn_rpg7_s"); + ADD(CWeaponShotgun, CSE_ALifeItemWeaponShotGun, TEXT2CLSID("WP_SHOTG"), "wpn_shotgun_s"); + ADD(CWeaponSVU, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_SVU"), "wpn_svu_s"); + ADD(CWeaponUSP45, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_USP45"), "wpn_usp45_s"); + ADD(CWeaponVal, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_VAL"), "wpn_val_s"); + ADD(CWeaponVintorez, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_VINT"), "wpn_vintorez_s"); + ADD(CWeaponWalther, CSE_ALifeItemWeaponMagazined, TEXT2CLSID("WP_WALTH"), "wpn_walther_s"); + ADD(CHairsZone, CSE_ALifeZoneVisual, TEXT2CLSID("ZS_BFUZZ"), "zone_bfuzz_s"); + ADD(CMosquitoBald, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_MBALD"), "zone_mbald_s"); + ADD(CMincer, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_GALAN"), "zone_galant_s"); + ADD(CMincer, CSE_ALifeAnomalousZone, TEXT2CLSID("ZS_MINCE"), "zone_mincer_s"); + ADD(CSpaceRestrictor, CSE_ALifeSpaceRestrictor, TEXT2CLSID("SPC_RS_S"), "script_restr"); +#endif // NO_XR_GAME } diff --git a/src/xrServerEntities/object_factory_script.cpp b/src/xrServerEntities/object_factory_script.cpp index 5b2db6741bf..8408f4b95e9 100644 --- a/src/xrServerEntities/object_factory_script.cpp +++ b/src/xrServerEntities/object_factory_script.cpp @@ -6,101 +6,91 @@ // Description : Object factory script export //////////////////////////////////////////////////////////////////////////// -#include "pch_script.h" -#include "object_factory.h" #include "ai_space.h" -#include "xrScriptEngine/script_engine.hpp" +#include "object_factory.h" #include "object_item_script.h" +#include "pch_script.h" #include "xrScriptEngine/ScriptExporter.hpp" +#include "xrScriptEngine/script_engine.hpp" -void CObjectFactory::register_script_class (LPCSTR client_class, LPCSTR server_class, LPCSTR clsid, LPCSTR script_clsid) +void CObjectFactory::register_script_class(LPCSTR client_class, LPCSTR server_class, LPCSTR clsid, LPCSTR script_clsid) { #ifdef CONFIG_OBJECT_FACTORY_LOG_REGISTER Msg("* CObjectFactory: registering script class '%s'", clsid); #endif #ifndef NO_XR_GAME - luabind::object client; - if (!ai().script_engine().function_object(client_class,client,LUA_TUSERDATA)) { - ai().script_engine().script_log (LuaMessageType::Error,"Cannot register class %s",client_class); - return; - } + luabind::object client; + if (!ai().script_engine().function_object(client_class, client, LUA_TUSERDATA)) { + ai().script_engine().script_log(LuaMessageType::Error, "Cannot register class %s", client_class); + return; + } #endif - luabind::object server; - if (!ai().script_engine().function_object(server_class,server,LUA_TUSERDATA)) { - ai().script_engine().script_log (LuaMessageType::Error,"Cannot register class %s",server_class); - return; - } - - add ( - new CObjectItemScript( + luabind::object server; + if (!ai().script_engine().function_object(server_class, server, LUA_TUSERDATA)) { + ai().script_engine().script_log(LuaMessageType::Error, "Cannot register class %s", server_class); + return; + } + + add(new CObjectItemScript( #ifndef NO_XR_GAME - client, + client, #endif - server, - TEXT2CLSID(clsid), - script_clsid - ) - ); + server, TEXT2CLSID(clsid), script_clsid)); } -void CObjectFactory::register_script_class (LPCSTR unknown_class, LPCSTR clsid, LPCSTR script_clsid) +void CObjectFactory::register_script_class(LPCSTR unknown_class, LPCSTR clsid, LPCSTR script_clsid) { #ifdef CONFIG_OBJECT_FACTORY_LOG_REGISTER Msg("* CObjectFactory: registering script class '%s'", clsid); #endif - luabind::object creator; - if (!ai().script_engine().function_object(unknown_class,creator,LUA_TUSERDATA)) { - ai().script_engine().script_log (LuaMessageType::Error,"Cannot register class %s",unknown_class); - return; - } - add ( - new CObjectItemScript( + luabind::object creator; + if (!ai().script_engine().function_object(unknown_class, creator, LUA_TUSERDATA)) { + ai().script_engine().script_log(LuaMessageType::Error, "Cannot register class %s", unknown_class); + return; + } + add(new CObjectItemScript( #ifndef NO_XR_GAME - creator, + creator, #endif - creator, - TEXT2CLSID(clsid), - script_clsid - ) - ); + creator, TEXT2CLSID(clsid), script_clsid)); } #ifndef NO_XR_GAME - ENGINE_API bool g_dedicated_server; -#endif // NO_XR_GAME +ENGINE_API bool g_dedicated_server; +#endif // NO_XR_GAME void CObjectFactory::register_script_classes() { #ifndef NO_XR_GAME - if (!g_dedicated_server) -#endif // NO_XR_GAME - ai(); + if (!g_dedicated_server) +#endif // NO_XR_GAME + ai(); } using namespace luabind; -struct CInternal{}; +struct CInternal +{ +}; -void CObjectFactory::register_script () const +void CObjectFactory::register_script() const { - actualize (); + actualize(); - luabind::class_ instance("clsid"); + luabind::class_ instance("clsid"); - const_iterator I = clsids().begin(), B = I; - const_iterator E = clsids().end(); - for ( ; I != E; ++I) - instance.enum_ ("_clsid")[luabind::value(*(*I)->script_clsid(),int(I - B))]; + const_iterator I = clsids().begin(), B = I; + const_iterator E = clsids().end(); + for (; I != E; ++I) + instance.enum_("_clsid")[luabind::value(*(*I)->script_clsid(), int(I - B))]; - luabind::module (ai().script_engine().lua())[instance]; + luabind::module(ai().script_engine().lua())[instance]; } -SCRIPT_EXPORT(CObjectFactory, (), -{ - module(luaState) - [ - class_("object_factory") - .def("register", (void (CObjectFactory::*)(LPCSTR,LPCSTR,LPCSTR,LPCSTR))(&CObjectFactory::register_script_class)) - .def("register", (void (CObjectFactory::*)(LPCSTR,LPCSTR,LPCSTR))(&CObjectFactory::register_script_class)) - ]; +SCRIPT_EXPORT(CObjectFactory, (), { + module(luaState)[class_("object_factory") + .def("register", (void (CObjectFactory::*)(LPCSTR, LPCSTR, LPCSTR, LPCSTR))( + &CObjectFactory::register_script_class)) + .def("register", (void (CObjectFactory::*)(LPCSTR, LPCSTR, LPCSTR))( + &CObjectFactory::register_script_class))]; }); diff --git a/src/xrServerEntities/object_item_abstract.h b/src/xrServerEntities/object_item_abstract.h index ea93228c212..a872b3efc58 100644 --- a/src/xrServerEntities/object_item_abstract.h +++ b/src/xrServerEntities/object_item_abstract.h @@ -13,19 +13,20 @@ #include "object_factory_space.h" -class CObjectItemAbstract { +class CObjectItemAbstract +{ protected: - CLASS_ID m_clsid; - shared_str m_script_clsid; + CLASS_ID m_clsid; + shared_str m_script_clsid; public: - IC CObjectItemAbstract (const CLASS_ID &clsid, LPCSTR script_clsid); - IC const CLASS_ID &clsid () const; - IC shared_str script_clsid () const; + IC CObjectItemAbstract(const CLASS_ID& clsid, LPCSTR script_clsid); + IC const CLASS_ID& clsid() const; + IC shared_str script_clsid() const; #ifndef NO_XR_GAME - virtual ObjectFactory::ClientObjectBaseClass *client_object() const = 0; + virtual ObjectFactory::ClientObjectBaseClass* client_object() const = 0; #endif - virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const = 0; + virtual ObjectFactory::ServerObjectBaseClass* server_object(LPCSTR section) const = 0; }; #include "object_item_abstract_inline.h" diff --git a/src/xrServerEntities/object_item_abstract_inline.h b/src/xrServerEntities/object_item_abstract_inline.h index ea55c96f74d..126ff32d7d2 100644 --- a/src/xrServerEntities/object_item_abstract_inline.h +++ b/src/xrServerEntities/object_item_abstract_inline.h @@ -11,20 +11,19 @@ #pragma once -IC CObjectItemAbstract::CObjectItemAbstract (const CLASS_ID &clsid, LPCSTR script_clsid) : - m_clsid (clsid), - m_script_clsid (script_clsid) +IC CObjectItemAbstract::CObjectItemAbstract(const CLASS_ID& clsid, LPCSTR script_clsid) + : m_clsid(clsid), m_script_clsid(script_clsid) { } -IC const CLASS_ID &CObjectItemAbstract::clsid () const +IC const CLASS_ID& CObjectItemAbstract::clsid() const { - return (m_clsid); + return (m_clsid); } -IC shared_str CObjectItemAbstract::script_clsid () const +IC shared_str CObjectItemAbstract::script_clsid() const { - return (m_script_clsid); + return (m_script_clsid); } #endif diff --git a/src/xrServerEntities/object_item_client_server.h b/src/xrServerEntities/object_item_client_server.h index b520d7dbf34..6af8cf2ed55 100644 --- a/src/xrServerEntities/object_item_client_server.h +++ b/src/xrServerEntities/object_item_client_server.h @@ -11,35 +11,39 @@ #pragma once +#include "object_factory.h" #include "object_factory_space.h" #include "object_item_abstract.h" -#include "object_factory.h" template -class CObjectItemClientServer : public CObjectItemAbstract { +class CObjectItemClientServer : public CObjectItemAbstract +{ protected: - typedef CObjectItemAbstract inherited; - typedef _client_type CLIENT_TYPE; - typedef _server_type SERVER_TYPE; + typedef CObjectItemAbstract inherited; + typedef _client_type CLIENT_TYPE; + typedef _server_type SERVER_TYPE; public: - IC CObjectItemClientServer (const CLASS_ID &clsid, LPCSTR script_clsid); + IC CObjectItemClientServer(const CLASS_ID& clsid, LPCSTR script_clsid); #ifndef NO_XR_GAME - virtual ObjectFactory::ClientObjectBaseClass *client_object() const; + virtual ObjectFactory::ClientObjectBaseClass* client_object() const; #endif - virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const; + virtual ObjectFactory::ServerObjectBaseClass* server_object(LPCSTR section) const; }; #ifndef NO_XR_GAME - template - class CObjectItemClientServerSingleMp : public CObjectItemAbstract { - typedef CObjectItemAbstract inherited; - public: - IC CObjectItemClientServerSingleMp (const CLASS_ID &clsid, LPCSTR script_clsid); - virtual ObjectFactory::ClientObjectBaseClass *client_object() const; - virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const; - }; -#endif // NO_XR_GAME +template +class CObjectItemClientServerSingleMp : public CObjectItemAbstract +{ + typedef CObjectItemAbstract inherited; + +public: + IC CObjectItemClientServerSingleMp(const CLASS_ID& clsid, LPCSTR script_clsid); + virtual ObjectFactory::ClientObjectBaseClass* client_object() const; + virtual ObjectFactory::ServerObjectBaseClass* server_object(LPCSTR section) const; +}; +#endif // NO_XR_GAME #include "object_item_client_server_inline.h" diff --git a/src/xrServerEntities/object_item_client_server_inline.h b/src/xrServerEntities/object_item_client_server_inline.h index 4b310e74554..35f6157a5de 100644 --- a/src/xrServerEntities/object_item_client_server_inline.h +++ b/src/xrServerEntities/object_item_client_server_inline.h @@ -12,70 +12,69 @@ #pragma once #define TEMPLATE_SPECIALIZATION template -#define CSObjectItemClientServer CObjectItemClientServer<_client_type,_server_type> +#define CSObjectItemClientServer CObjectItemClientServer<_client_type, _server_type> TEMPLATE_SPECIALIZATION -IC CSObjectItemClientServer::CObjectItemClientServer (const CLASS_ID &clsid, LPCSTR script_clsid) : - inherited (clsid,script_clsid) +IC CSObjectItemClientServer::CObjectItemClientServer(const CLASS_ID& clsid, LPCSTR script_clsid) + : inherited(clsid, script_clsid) { } #ifndef NO_XR_GAME TEMPLATE_SPECIALIZATION -ObjectFactory::ClientObjectBaseClass *CSObjectItemClientServer::client_object () const +ObjectFactory::ClientObjectBaseClass* CSObjectItemClientServer::client_object() const { - return (new CLIENT_TYPE())->_construct(); + return (new CLIENT_TYPE())->_construct(); } #endif TEMPLATE_SPECIALIZATION -ObjectFactory::ServerObjectBaseClass *CSObjectItemClientServer::server_object (LPCSTR section) const +ObjectFactory::ServerObjectBaseClass* CSObjectItemClientServer::server_object(LPCSTR section) const { - ObjectFactory::ServerObjectBaseClass * o = (new SERVER_TYPE(section))->init(); - R_ASSERT (o); - return (o); + ObjectFactory::ServerObjectBaseClass* o = (new SERVER_TYPE(section))->init(); + R_ASSERT(o); + return (o); } #undef TEMPLATE_SPECIALIZATION #undef CSObjectItemClientServer #ifndef NO_XR_GAME -# define TEMPLATE_SPECIALIZATION template -# define CSObjectItemClientServerSingleMp CObjectItemClientServerSingleMp<_client_type_single,_client_type_mp,_server_type_single,_server_type_mp> - - TEMPLATE_SPECIALIZATION - IC CSObjectItemClientServerSingleMp::CObjectItemClientServerSingleMp (const CLASS_ID &clsid, LPCSTR script_clsid) : - inherited (clsid,script_clsid) - { - } - - TEMPLATE_SPECIALIZATION - ObjectFactory::ClientObjectBaseClass *CSObjectItemClientServerSingleMp::client_object () const - { - ObjectFactory::ClientObjectBaseClass *result = - IsGameTypeSingle() ? - new _client_type_single() : - new _client_type_mp(); - - return (result->_construct()); - } - - TEMPLATE_SPECIALIZATION - ObjectFactory::ServerObjectBaseClass *CSObjectItemClientServerSingleMp::server_object (LPCSTR section) const - { - ObjectFactory::ServerObjectBaseClass *result = - IsGameTypeSingle() ? - new _server_type_single(section) : - new _server_type_mp(section); - - result = result->init(); - R_ASSERT (result); - return (result); - } - -# undef TEMPLATE_SPECIALIZATION -# undef CSObjectItemClientServerSingleMp - -#endif // NO_XR_GAME +#define TEMPLATE_SPECIALIZATION \ + template +#define CSObjectItemClientServerSingleMp \ + CObjectItemClientServerSingleMp<_client_type_single, _client_type_mp, _server_type_single, _server_type_mp> + +TEMPLATE_SPECIALIZATION +IC CSObjectItemClientServerSingleMp::CObjectItemClientServerSingleMp(const CLASS_ID& clsid, LPCSTR script_clsid) + : inherited(clsid, script_clsid) +{ +} + +TEMPLATE_SPECIALIZATION +ObjectFactory::ClientObjectBaseClass* CSObjectItemClientServerSingleMp::client_object() const +{ + ObjectFactory::ClientObjectBaseClass* result = + IsGameTypeSingle() ? new _client_type_single() : new _client_type_mp(); + + return (result->_construct()); +} + +TEMPLATE_SPECIALIZATION +ObjectFactory::ServerObjectBaseClass* CSObjectItemClientServerSingleMp::server_object(LPCSTR section) const +{ + ObjectFactory::ServerObjectBaseClass* result = + IsGameTypeSingle() ? new _server_type_single(section) : new _server_type_mp(section); + + result = result->init(); + R_ASSERT(result); + return (result); +} + +#undef TEMPLATE_SPECIALIZATION +#undef CSObjectItemClientServerSingleMp + +#endif // NO_XR_GAME #endif \ No newline at end of file diff --git a/src/xrServerEntities/object_item_script.cpp b/src/xrServerEntities/object_item_script.cpp index d31a8cecb6a..656e687508a 100644 --- a/src/xrServerEntities/object_item_script.cpp +++ b/src/xrServerEntities/object_item_script.cpp @@ -6,77 +6,75 @@ // Description : Object item script class //////////////////////////////////////////////////////////////////////////// -#include "pch_script.h" #include "object_item_script.h" #include "object_factory.h" +#include "pch_script.h" #include "xrScriptEngine/Functor.hpp" #ifndef NO_XR_GAME -# include "attachable_item.h" +#include "attachable_item.h" -ObjectFactory::ClientObjectBaseClass *CObjectItemScript::client_object () const +ObjectFactory::ClientObjectBaseClass* CObjectItemScript::client_object() const { - ObjectFactory::ClientObjectBaseClass *object = nullptr; - try { - object = m_client_creator(); - } - catch(...) { - return (0); - } - R_ASSERT (object); - return (object->_construct()); + ObjectFactory::ClientObjectBaseClass* object = nullptr; + try + { + object = m_client_creator(); + } + catch (...) + { + return (0); + } + R_ASSERT(object); + return (object->_construct()); } #endif -ObjectFactory::ServerObjectBaseClass *CObjectItemScript::server_object (LPCSTR section) const +ObjectFactory::ServerObjectBaseClass* CObjectItemScript::server_object(LPCSTR section) const { - ObjectFactory::ServerObjectBaseClass *object = nullptr; + ObjectFactory::ServerObjectBaseClass* object = nullptr; - try { + try + { object = m_server_creator(section); - } - catch(std::exception e) { - Msg ("Exception [%s] raised while creating server object from section [%s]", e.what(),section); - return (0); - } - catch(...) { - Msg ("Exception raised while creating server object from section [%s]",section); - return (0); - } + } + catch (std::exception e) + { + Msg("Exception [%s] raised while creating server object from section [%s]", e.what(), section); + return (0); + } + catch (...) + { + Msg("Exception raised while creating server object from section [%s]", section); + return (0); + } - R_ASSERT (object); + R_ASSERT(object); object = object->init(); - R_ASSERT (object); - return (object); + R_ASSERT(object); + return (object); } -CObjectItemScript::CObjectItemScript ( +CObjectItemScript::CObjectItemScript( #ifndef NO_XR_GAME - luabind::object client_creator, + luabind::object client_creator, #endif - luabind::object server_creator, - const CLASS_ID &clsid, - LPCSTR script_clsid -) : - inherited (clsid,script_clsid) + luabind::object server_creator, const CLASS_ID& clsid, LPCSTR script_clsid) + : inherited(clsid, script_clsid) { #ifndef NO_XR_GAME - m_client_creator = client_creator; + m_client_creator = client_creator; #endif - m_server_creator = server_creator; + m_server_creator = server_creator; } #ifndef NO_XR_GAME -CObjectItemScript::CObjectItemScript ( - luabind::object unknown_creator, - const CLASS_ID &clsid, - LPCSTR script_clsid -) : - inherited (clsid,script_clsid) +CObjectItemScript::CObjectItemScript(luabind::object unknown_creator, const CLASS_ID& clsid, LPCSTR script_clsid) + : inherited(clsid, script_clsid) { - m_client_creator = m_server_creator = unknown_creator; + m_client_creator = m_server_creator = unknown_creator; } #endif diff --git a/src/xrServerEntities/object_item_script.h b/src/xrServerEntities/object_item_script.h index 3086fee53f5..b24350af583 100644 --- a/src/xrServerEntities/object_item_script.h +++ b/src/xrServerEntities/object_item_script.h @@ -12,30 +12,24 @@ #include "object_item_abstract.h" #include "xrScriptEngine/Functor.hpp" -class CObjectItemScript : public CObjectItemAbstract { +class CObjectItemScript : public CObjectItemAbstract +{ protected: - typedef CObjectItemAbstract inherited; + typedef CObjectItemAbstract inherited; protected: - mutable luabind::functor> m_client_creator; - mutable luabind::functor> m_server_creator; + mutable luabind::functor> m_client_creator; + mutable luabind::functor> m_server_creator; public: - CObjectItemScript ( + CObjectItemScript( #ifndef NO_XR_GAME - luabind::object client_creator, + luabind::object client_creator, #endif - luabind::object server_creator, - const CLASS_ID &clsid, - LPCSTR script_clsid - ); + luabind::object server_creator, const CLASS_ID& clsid, LPCSTR script_clsid); #ifndef NO_XR_GAME - CObjectItemScript ( - luabind::object creator, - const CLASS_ID &clsid, - LPCSTR script_clsid - ); - virtual ObjectFactory::ClientObjectBaseClass *client_object() const; + CObjectItemScript(luabind::object creator, const CLASS_ID& clsid, LPCSTR script_clsid); + virtual ObjectFactory::ClientObjectBaseClass* client_object() const; #endif - virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const; + virtual ObjectFactory::ServerObjectBaseClass* server_object(LPCSTR section) const; }; diff --git a/src/xrServerEntities/object_item_single.h b/src/xrServerEntities/object_item_single.h index adbf894f1f2..048a6329c3c 100644 --- a/src/xrServerEntities/object_item_single.h +++ b/src/xrServerEntities/object_item_single.h @@ -15,30 +15,32 @@ #include "object_item_abstract.h" template -class CObjectItemSingle : public CObjectItemAbstract { +class CObjectItemSingle : public CObjectItemAbstract +{ protected: - typedef CObjectItemAbstract inherited; - typedef _unknown_type SERVER_TYPE; + typedef CObjectItemAbstract inherited; + typedef _unknown_type SERVER_TYPE; public: - IC CObjectItemSingle (const CLASS_ID &clsid, LPCSTR script_clsid); + IC CObjectItemSingle(const CLASS_ID& clsid, LPCSTR script_clsid); #ifndef NO_XR_GAME - virtual ObjectFactory::ClientObjectBaseClass *client_object() const; + virtual ObjectFactory::ClientObjectBaseClass* client_object() const; #endif - virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const; + virtual ObjectFactory::ServerObjectBaseClass* server_object(LPCSTR section) const; }; #ifndef NO_XR_GAME template -class CObjectItemSingle<_unknown_type,true> : public CObjectItemAbstract { +class CObjectItemSingle<_unknown_type, true> : public CObjectItemAbstract +{ protected: - typedef CObjectItemAbstract inherited; - typedef _unknown_type CLIENT_TYPE; + typedef CObjectItemAbstract inherited; + typedef _unknown_type CLIENT_TYPE; public: - IC CObjectItemSingle (const CLASS_ID &clsid, LPCSTR script_clsid); - virtual ObjectFactory::ClientObjectBaseClass *client_object() const; - virtual ObjectFactory::ServerObjectBaseClass *server_object(LPCSTR section) const; + IC CObjectItemSingle(const CLASS_ID& clsid, LPCSTR script_clsid); + virtual ObjectFactory::ClientObjectBaseClass* client_object() const; + virtual ObjectFactory::ServerObjectBaseClass* server_object(LPCSTR section) const; }; #endif diff --git a/src/xrServerEntities/object_item_single_inline.h b/src/xrServerEntities/object_item_single_inline.h index f3d65973aad..9ec0f71d252 100644 --- a/src/xrServerEntities/object_item_single_inline.h +++ b/src/xrServerEntities/object_item_single_inline.h @@ -12,47 +12,46 @@ #pragma once #define TEMPLATE_SPECIALIZATION template -#define CSObjectItemSingle CObjectItemSingle<_unknown_type,_client_object> +#define CSObjectItemSingle CObjectItemSingle<_unknown_type, _client_object> TEMPLATE_SPECIALIZATION -IC CSObjectItemSingle::CObjectItemSingle (const CLASS_ID &clsid, LPCSTR script_clsid) : - inherited (clsid,script_clsid) +IC CSObjectItemSingle::CObjectItemSingle(const CLASS_ID& clsid, LPCSTR script_clsid) : inherited(clsid, script_clsid) { } #ifndef NO_XR_GAME TEMPLATE_SPECIALIZATION -ObjectFactory::ClientObjectBaseClass *CSObjectItemSingle::client_object () const +ObjectFactory::ClientObjectBaseClass* CSObjectItemSingle::client_object() const { - FATAL ("Cannot instantiate client object, because client class is not declared!"); - return (0); + FATAL("Cannot instantiate client object, because client class is not declared!"); + return (0); } #endif TEMPLATE_SPECIALIZATION -ObjectFactory::ServerObjectBaseClass *CSObjectItemSingle::server_object (LPCSTR section) const +ObjectFactory::ServerObjectBaseClass* CSObjectItemSingle::server_object(LPCSTR section) const { - return (new SERVER_TYPE(section))->init(); + return (new SERVER_TYPE(section))->init(); } #ifndef NO_XR_GAME template -IC CObjectItemSingle<_unknown_type,true>::CObjectItemSingle (const CLASS_ID &clsid, LPCSTR script_clsid) : - inherited (clsid,script_clsid) +IC CObjectItemSingle<_unknown_type, true>::CObjectItemSingle(const CLASS_ID& clsid, LPCSTR script_clsid) + : inherited(clsid, script_clsid) { } template -ObjectFactory::ClientObjectBaseClass *CObjectItemSingle<_unknown_type,true>::client_object () const +ObjectFactory::ClientObjectBaseClass* CObjectItemSingle<_unknown_type, true>::client_object() const { - return (new CLIENT_TYPE())->_construct(); + return (new CLIENT_TYPE())->_construct(); } template -ObjectFactory::ServerObjectBaseClass *CObjectItemSingle<_unknown_type,true>::server_object (LPCSTR section) const +ObjectFactory::ServerObjectBaseClass* CObjectItemSingle<_unknown_type, true>::server_object(LPCSTR section) const { - FATAL ("Cannot instantiate server object, because server class is not declared!"); - return (0); + FATAL("Cannot instantiate server object, because server class is not declared!"); + return (0); } #endif diff --git a/src/xrServerEntities/pch_script.cpp b/src/xrServerEntities/pch_script.cpp index 520c3974c98..06256423aaf 100644 --- a/src/xrServerEntities/pch_script.cpp +++ b/src/xrServerEntities/pch_script.cpp @@ -1,2 +1,2 @@ -#pragma warning(disable:4503) +#pragma warning(disable : 4503) #include "pch_script.h" diff --git a/src/xrServerEntities/pch_script.h b/src/xrServerEntities/pch_script.h index 1f974dd5d50..d891629e402 100644 --- a/src/xrServerEntities/pch_script.h +++ b/src/xrServerEntities/pch_script.h @@ -12,4 +12,4 @@ #include "stdafx.h" #include "xrScriptEngine/xrScriptEngine.hpp" -#endif // PCH_SCRIPT_H +#endif // PCH_SCRIPT_H diff --git a/src/xrServerEntities/restriction_space.h b/src/xrServerEntities/restriction_space.h index a00effc0ada..11895943bde 100644 --- a/src/xrServerEntities/restriction_space.h +++ b/src/xrServerEntities/restriction_space.h @@ -8,28 +8,27 @@ #pragma once -namespace RestrictionSpace { - struct CTimeIntrusiveBase : public intrusive_base { - u32 m_last_time_dec; +namespace RestrictionSpace +{ +struct CTimeIntrusiveBase : public intrusive_base +{ + u32 m_last_time_dec; - IC CTimeIntrusiveBase () : m_last_time_dec(0) - { - } - - template - IC void _release (T*object) - { - m_last_time_dec = Device.dwTimeGlobal; - } - }; - - enum ERestrictorTypes { - eDefaultRestrictorTypeNone = u8(0), - eDefaultRestrictorTypeOut = u8(1), - eDefaultRestrictorTypeIn = u8(2), - eRestrictorTypeNone = u8(3), - eRestrictorTypeIn = u8(4), - eRestrictorTypeOut = u8(5), - }; + IC CTimeIntrusiveBase() : m_last_time_dec(0) {} + template + IC void _release(T* object) + { + m_last_time_dec = Device.dwTimeGlobal; + } }; +enum ERestrictorTypes +{ + eDefaultRestrictorTypeNone = u8(0), + eDefaultRestrictorTypeOut = u8(1), + eDefaultRestrictorTypeIn = u8(2), + eRestrictorTypeNone = u8(3), + eRestrictorTypeIn = u8(4), + eRestrictorTypeOut = u8(5), +}; +}; diff --git a/src/xrServerEntities/script_fcolor_script.cpp b/src/xrServerEntities/script_fcolor_script.cpp index 68bd5760f5b..7aeebdc52e3 100644 --- a/src/xrServerEntities/script_fcolor_script.cpp +++ b/src/xrServerEntities/script_fcolor_script.cpp @@ -12,18 +12,15 @@ using namespace luabind; using namespace luabind::policy; -SCRIPT_EXPORT(Fcolor, (), -{ - module(luaState) - [ - class_("fcolor") - .def_readwrite("r", &Fcolor::r) - .def_readwrite("g", &Fcolor::g) - .def_readwrite("b", &Fcolor::b) - .def_readwrite("a", &Fcolor::a) - .def( constructor<>()) - .def("set", (Fcolor & (Fcolor::*)(float,float,float,float))(&Fcolor::set), return_reference_to<1>()) - .def("set", (Fcolor & (Fcolor::*)(const Fcolor &))(&Fcolor::set), return_reference_to<1>()) - .def("set", (Fcolor & (Fcolor::*)(u32))(&Fcolor::set), return_reference_to<1>()) - ]; +SCRIPT_EXPORT(Fcolor, (), { + module(luaState)[class_( + "fcolor").def_readwrite("r", &Fcolor::r) + .def_readwrite("g", &Fcolor::g) + .def_readwrite("b", &Fcolor::b) + .def_readwrite("a", &Fcolor::a) + .def(constructor<>()) + .def("set", (Fcolor & (Fcolor::*)(float, float, float, float))(&Fcolor::set), + return_reference_to<1>()) + .def("set", (Fcolor & (Fcolor::*)(const Fcolor&))(&Fcolor::set), return_reference_to<1>()) + .def("set", (Fcolor & (Fcolor::*)(u32))(&Fcolor::set), return_reference_to<1>())]; }); diff --git a/src/xrServerEntities/script_flags_script.cpp b/src/xrServerEntities/script_flags_script.cpp index f36acb681a5..3253f55482c 100644 --- a/src/xrServerEntities/script_flags_script.cpp +++ b/src/xrServerEntities/script_flags_script.cpp @@ -12,124 +12,112 @@ using namespace luabind; template -T& set(T *self, const typename T::TYPE mask, bool value) +T& set(T* self, const typename T::TYPE mask, bool value) { - return (self->set(mask,value)); + return (self->set(mask, value)); } template -bool is(T *self, const typename T::TYPE mask) +bool is(T* self, const typename T::TYPE mask) { - return (!!self->is(mask)); + return (!!self->is(mask)); } template -bool is_any(T *self, const typename T::TYPE mask) +bool is_any(T* self, const typename T::TYPE mask) { - return (!!self->is_any(mask)); + return (!!self->is_any(mask)); } template -bool test(T *self, const typename T::TYPE mask) +bool test(T* self, const typename T::TYPE mask) { - return (!!self->test(mask)); + return (!!self->test(mask)); } template -bool equal(T *self, const T &f) +bool equal(T* self, const T& f) { - return (!!self->equal(f)); + return (!!self->equal(f)); } template -bool equal(T *self, const T &f, const typename T::TYPE mask) +bool equal(T* self, const T& f, const typename T::TYPE mask) { - return (!!self->equal(f,mask)); + return (!!self->equal(f, mask)); } template -void one(T *self) +void one(T* self) { - self->assign(typename T::TYPE(-1)); + self->assign(typename T::TYPE(-1)); } -SCRIPT_EXPORT(Flags8, (), -{ - module(luaState) - [ - class_("flags8") - .def(constructor<>()) - .def("get", &Flags8::get) - .def("zero", &Flags8::zero) - .def("one", &one) - .def("invert", (Flags8& (Flags8::*)())(&Flags8::invert)) - .def("invert", (Flags8& (Flags8::*)(const Flags8&))(&Flags8::invert)) - .def("invert", (Flags8& (Flags8::*)(const Flags8::TYPE))(&Flags8::invert)) - .def("assign", (Flags8& (Flags8::*)(const Flags8&))(&Flags8::assign)) - .def("assign", (Flags8& (Flags8::*)(const Flags8::TYPE))(&Flags8::assign)) - .def("or", (Flags8& (Flags8::*)(const Flags8::TYPE))(&Flags8:: or )) - .def("or", (Flags8& (Flags8::*)(const Flags8&,const Flags8::TYPE))(&Flags8:: or )) - .def("and", (Flags8& (Flags8::*)(const Flags8::TYPE))(&Flags8::and)) - .def("and", (Flags8& (Flags8::*)(const Flags8&,const Flags8::TYPE))(&Flags8::and)) - .def("set", &::set) - .def("is", &is) - .def("is_any", &is_any) - .def("test", &test) - .def("equal", (bool(*)(Flags8*,const Flags8&))(&equal)) - .def("equal", (bool(*)(Flags8*,const Flags8&,const Flags8::TYPE))(&equal)) - ]; +SCRIPT_EXPORT(Flags8, (), { + module(luaState)[class_( + "flags8").def(constructor<>()) + .def("get", &Flags8::get) + .def("zero", &Flags8::zero) + .def("one", &one) + .def("invert", (Flags8 & (Flags8::*)())(&Flags8::invert)) + .def("invert", (Flags8 & (Flags8::*)(const Flags8&))(&Flags8::invert)) + .def("invert", (Flags8 & (Flags8::*)(const Flags8::TYPE))(&Flags8::invert)) + .def("assign", (Flags8 & (Flags8::*)(const Flags8&))(&Flags8::assign)) + .def("assign", (Flags8 & (Flags8::*)(const Flags8::TYPE))(&Flags8::assign)) + .def("or", (Flags8 & (Flags8::*)(const Flags8::TYPE))(&Flags8:: or)) + .def("or", (Flags8 & (Flags8::*)(const Flags8&, const Flags8::TYPE))(&Flags8:: or)) + .def("and", (Flags8 & (Flags8::*)(const Flags8::TYPE))(&Flags8::and)) + .def("and", (Flags8 & (Flags8::*)(const Flags8&, const Flags8::TYPE))(&Flags8::and)) + .def("set", &::set) + .def("is", &is) + .def("is_any", &is_any) + .def("test", &test) + .def("equal", (bool (*)(Flags8*, const Flags8&))(&equal)) + .def("equal", (bool (*)(Flags8*, const Flags8&, const Flags8::TYPE))(&equal))]; }); -SCRIPT_EXPORT(Flags16, (), -{ - module(luaState) - [ - class_("flags16") - .def(constructor<>()) - .def("get", &Flags16::get) - .def("zero", &Flags16::zero) - .def("one", &one) - .def("invert", (Flags16& (Flags16::*)())(&Flags16::invert)) - .def("invert", (Flags16& (Flags16::*)(const Flags16&))(&Flags16::invert)) - .def("invert", (Flags16& (Flags16::*)(const Flags16::TYPE))(&Flags16::invert)) - .def("assign", (Flags16& (Flags16::*)(const Flags16&))(&Flags16::assign)) - .def("assign", (Flags16& (Flags16::*)(const Flags16::TYPE))(&Flags16::assign)) - .def("or", (Flags16& (Flags16::*)(const Flags16::TYPE))(&Flags16:: or )) - .def("or", (Flags16& (Flags16::*)(const Flags16&,const Flags16::TYPE))(&Flags16:: or )) - .def("and", (Flags16& (Flags16::*)(const Flags16::TYPE))(&Flags16::and)) - .def("and", (Flags16& (Flags16::*)(const Flags16&,const Flags16::TYPE))(&Flags16::and)) - .def("set", &::set) - .def("is", &is) - .def("is_any", &is_any) - .def("test", &test) - .def("equal", (bool(*)(Flags16*,const Flags16&))(&equal)) - .def("equal", (bool(*)(Flags16*,const Flags16&,const Flags16::TYPE))(&equal)) - ]; +SCRIPT_EXPORT(Flags16, (), { + module(luaState)[class_( + "flags16").def(constructor<>()) + .def("get", &Flags16::get) + .def("zero", &Flags16::zero) + .def("one", &one) + .def("invert", (Flags16 & (Flags16::*)())(&Flags16::invert)) + .def("invert", (Flags16 & (Flags16::*)(const Flags16&))(&Flags16::invert)) + .def("invert", (Flags16 & (Flags16::*)(const Flags16::TYPE))(&Flags16::invert)) + .def("assign", (Flags16 & (Flags16::*)(const Flags16&))(&Flags16::assign)) + .def("assign", (Flags16 & (Flags16::*)(const Flags16::TYPE))(&Flags16::assign)) + .def("or", (Flags16 & (Flags16::*)(const Flags16::TYPE))(&Flags16:: or)) + .def("or", (Flags16 & (Flags16::*)(const Flags16&, const Flags16::TYPE))(&Flags16:: or)) + .def("and", (Flags16 & (Flags16::*)(const Flags16::TYPE))(&Flags16::and)) + .def("and", (Flags16 & (Flags16::*)(const Flags16&, const Flags16::TYPE))(&Flags16::and)) + .def("set", &::set) + .def("is", &is) + .def("is_any", &is_any) + .def("test", &test) + .def("equal", (bool (*)(Flags16*, const Flags16&))(&equal)) + .def("equal", (bool (*)(Flags16*, const Flags16&, const Flags16::TYPE))(&equal))]; }); -SCRIPT_EXPORT(Flags32, (), -{ - module(luaState) - [ - class_ ("flags32") - .def( constructor<>()) - .def("get", &Flags32::get) - .def("zero", &Flags32::zero) - .def("one", &Flags32::one) - .def("invert", (Flags32& (Flags32::*)())(&Flags32::invert)) - .def("invert", (Flags32& (Flags32::*)(const Flags32&))(&Flags32::invert)) - .def("invert", (Flags32& (Flags32::*)(const Flags32::TYPE))(&Flags32::invert)) - .def("assign", (Flags32& (Flags32::*)(const Flags32&))(&Flags32::assign)) - .def("assign", (Flags32& (Flags32::*)(const Flags32::TYPE))(&Flags32::assign)) - .def("or", (Flags32& (Flags32::*)(const Flags32::TYPE))(&Flags32::or)) - .def("or", (Flags32& (Flags32::*)(const Flags32&,const Flags32::TYPE))(&Flags32::or)) - .def("and", (Flags32& (Flags32::*)(const Flags32::TYPE))(&Flags32::and)) - .def("and", (Flags32& (Flags32::*)(const Flags32&,const Flags32::TYPE))(&Flags32::and)) - .def("set", &::set) - .def("is", &is) - .def("is_any", &is_any) - .def("test", &test) - .def("equal", (bool (*)(Flags32*,const Flags32&))(&equal)) - .def("equal", (bool (*)(Flags32*,const Flags32&,const Flags32::TYPE))(&equal)) - ]; +SCRIPT_EXPORT(Flags32, (), { + module(luaState)[class_( + "flags32").def(constructor<>()) + .def("get", &Flags32::get) + .def("zero", &Flags32::zero) + .def("one", &Flags32::one) + .def("invert", (Flags32 & (Flags32::*)())(&Flags32::invert)) + .def("invert", (Flags32 & (Flags32::*)(const Flags32&))(&Flags32::invert)) + .def("invert", (Flags32 & (Flags32::*)(const Flags32::TYPE))(&Flags32::invert)) + .def("assign", (Flags32 & (Flags32::*)(const Flags32&))(&Flags32::assign)) + .def("assign", (Flags32 & (Flags32::*)(const Flags32::TYPE))(&Flags32::assign)) + .def("or", (Flags32 & (Flags32::*)(const Flags32::TYPE))(&Flags32:: or)) + .def("or", (Flags32 & (Flags32::*)(const Flags32&, const Flags32::TYPE))(&Flags32:: or)) + .def("and", (Flags32 & (Flags32::*)(const Flags32::TYPE))(&Flags32::and)) + .def("and", (Flags32 & (Flags32::*)(const Flags32&, const Flags32::TYPE))(&Flags32::and)) + .def("set", &::set) + .def("is", &is) + .def("is_any", &is_any) + .def("test", &test) + .def("equal", (bool (*)(Flags32*, const Flags32&))(&equal)) + .def("equal", (bool (*)(Flags32*, const Flags32&, const Flags32::TYPE))(&equal))]; }); diff --git a/src/xrServerEntities/script_fmatrix_script.cpp b/src/xrServerEntities/script_fmatrix_script.cpp index dbec8114948..7a15632c5ef 100644 --- a/src/xrServerEntities/script_fmatrix_script.cpp +++ b/src/xrServerEntities/script_fmatrix_script.cpp @@ -14,94 +14,151 @@ using namespace luabind::policy; void get_matrix_hpb(Fmatrix* self, float* h, float* p, float* b) { - self->getHPB (*h, *p, *b); + self->getHPB(*h, *p, *b); } -void matrix_transform (Fmatrix* self, Fvector* v) +void matrix_transform(Fmatrix* self, Fvector* v) { - self->transform (*v); + self->transform(*v); } -SCRIPT_EXPORT(Fmatrix, (), -{ - module(luaState) - [ - class_("matrix") - .def_readwrite("i", &Fmatrix::i) - .def_readwrite("_14_", &Fmatrix::_14_) - .def_readwrite("j", &Fmatrix::j) - .def_readwrite("_24_", &Fmatrix::_24_) - .def_readwrite("k", &Fmatrix::k) - .def_readwrite("_34_", &Fmatrix::_34_) - .def_readwrite("c", &Fmatrix::c) - .def_readwrite("_44_", &Fmatrix::_44_) - .def( constructor<>()) - .def("set", (Fmatrix & (Fmatrix::*)(const Fmatrix &))(&Fmatrix::set), return_reference_to<1>()) - .def("set", (Fmatrix & (Fmatrix::*)(const Fvector &, const Fvector &, const Fvector &, const Fvector &))(&Fmatrix::set), return_reference_to<1>()) - .def("identity", &Fmatrix::identity, return_reference_to<1>()) - .def("mk_xform", &Fmatrix::mk_xform, return_reference_to<1>()) - .def("mul", (Fmatrix & (Fmatrix::*)(const Fmatrix &, const Fmatrix &))(&Fmatrix::mul), return_reference_to<1>()) - .def("mul", (Fmatrix & (Fmatrix::*)(const Fmatrix &, float))(&Fmatrix::mul), return_reference_to<1>()) - .def("mul", (Fmatrix & (Fmatrix::*)(float))(&Fmatrix::mul), return_reference_to<1>()) - .def("div", (Fmatrix & (Fmatrix::*)(const Fmatrix &, float))(&Fmatrix::div), return_reference_to<1>()) - .def("div", (Fmatrix & (Fmatrix::*)(float))(&Fmatrix::div), return_reference_to<1>()) -// .def("invert", (Fmatrix & (Fmatrix::*)())(&Fmatrix::invert), return_reference_to<1>()) -// .def("invert", (Fmatrix & (Fmatrix::*)(const Fmatrix &))(&Fmatrix::invert), return_reference_to<1>()) -// .def("transpose", (Fmatrix & (Fmatrix::*)())(&Fmatrix::transpose), return_reference_to<1>()) -// .def("transpose", (Fmatrix & (Fmatrix::*)(const Fmatrix &))(&Fmatrix::transpose), return_reference_to<1>()) -// .def("translate", (Fmatrix & (Fmatrix::*)(const Fvector &))(&Fmatrix::translate), return_reference_to<1>()) -// .def("translate", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::translate), return_reference_to<1>()) -// .def("translate_over", (Fmatrix & (Fmatrix::*)(const Fvector &))(&Fmatrix::translate_over), return_reference_to<1>()) -// .def("translate_over", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::translate_over), return_reference_to<1>()) -// .def("translate_add", &Fmatrix::translate_add, return_reference_to<1>()) -// .def("scale", (Fmatrix & (Fmatrix::*)(const Fvector &))(&Fmatrix::scale), return_reference_to<1>()) -// .def("scale", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::scale), return_reference_to<1>()) -// .def("rotateX", &Fmatrix::rotateX, return_reference_to<1>()) -// .def("rotateY", &Fmatrix::rotateY, return_reference_to<1>()) -// .def("rotateZ", &Fmatrix::rotateZ, return_reference_to<1>()) -// .def("rotation", (Fmatrix & (Fmatrix::*)(const Fvector &, const Fvector &))(&Fmatrix::rotation), return_reference_to<1>()) -// .def("rotation", (Fmatrix & (Fmatrix::*)(const Fvector &, float))(&Fmatrix::rotation), return_reference_to<1>()) -// .def("rotation", &Fmatrix::rotation, return_reference_to<1>()) -/* - .def("mapXYZ", &Fmatrix::mapXYZ, return_reference_to<1>()) - .def("mapXZY", &Fmatrix::mapXZY, return_reference_to<1>()) - .def("mapYXZ", &Fmatrix::mapYXZ, return_reference_to<1>()) - .def("mapYZX", &Fmatrix::mapYZX, return_reference_to<1>()) - .def("mapZXY", &Fmatrix::mapZXY, return_reference_to<1>()) - .def("mapZYX", &Fmatrix::mapZYX, return_reference_to<1>()) - .def("mirrorX", &Fmatrix::mirrorX, return_reference_to<1>()) - .def("mirrorX_over", &Fmatrix::mirrorX_over, return_reference_to<1>()) - .def("mirrorX_add ", &Fmatrix::mirrorX_add, return_reference_to<1>()) - .def("mirrorY", &Fmatrix::mirrorY, return_reference_to<1>()) - .def("mirrorY_over", &Fmatrix::mirrorY_over, return_reference_to<1>()) - .def("mirrorY_add ", &Fmatrix::mirrorY_add, return_reference_to<1>()) - .def("mirrorZ", &Fmatrix::mirrorZ, return_reference_to<1>()) - .def("mirrorZ_over", &Fmatrix::mirrorZ_over, return_reference_to<1>()) - .def("mirrorZ_add ", &Fmatrix::mirrorZ_add, return_reference_to<1>()) -*/ -// .def("build_projection", &Fmatrix::build_projection, return_reference_to<1>()) -// .def("build_projection_HAT", &Fmatrix::build_projection_HAT, return_reference_to<1>()) -// .def("build_projection_ortho", &Fmatrix::build_projection_ortho, return_reference_to<1>()) -// .def("build_camera", &Fmatrix::build_camera, return_reference_to<1>()) -// .def("build_camera_dir", &Fmatrix::build_camera_dir, return_reference_to<1>()) -// .def("inertion", &Fmatrix::inertion, return_reference_to<1>()) -// .def("transform_tiny32", &Fmatrix::transform_tiny32) -// .def("transform_tiny23", &Fmatrix::transform_tiny23) -// .def("transform_tiny", (void (Fmatrix::*)(Fvector &) const)(&Fmatrix::transform_tiny), out_value<2>()) -// .def("transform_tiny", (void (Fmatrix::*)(Fvector &, const Fvector &) const)(&Fmatrix::transform_tiny), out_value<2>()) -// .def("transform_dir", (void (Fmatrix::*)(Fvector &) const)(&Fmatrix::transform_dir), out_value<2>()) -// .def("transform_dir", (void (Fmatrix::*)(Fvector &, const Fvector &) const)(&Fmatrix::transform_dir), out_value<2>()) -// .def("transform", (void (Fmatrix::*)(Fvector &) const)(&Fmatrix::transform), out_value<2>()) -// .def("transform", &matrix_transform) - .def("setHPB", &Fmatrix::setHPB, return_reference_to<1>()) -// .def("setXYZ", (Fmatrix & (Fmatrix::*)(Fvector &))(&Fmatrix::setXYZ), policy_list, out_value<2>>()) - .def("setXYZ", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::setXYZ), return_reference_to<1>()) -// .def("setXYZi", (Fmatrix & (Fmatrix::*)(Fvector &))(&Fmatrix::setXYZi), policy_list, out_value<2>>()) - .def("setXYZi", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::setXYZi), return_reference_to<1>()) -// .def("getHPB", (void (Fmatrix::*)(Fvector &) const)(&Fmatrix::getHPB), out_value<2>()) - .def("getHPB", &get_matrix_hpb) -// .def("getXYZ", (void (Fmatrix::*)(Fvector &) const)(&Fmatrix::getXYZ), out_value<2>()) -// .def("getXYZ", (void (Fmatrix::*)(float &, float &, float &) const)(&Fmatrix::getXYZ)) -// .def("getXYZi", (void (Fmatrix::*)(Fvector &) const)(&Fmatrix::getXYZi), out_value<2>()) -// .def("getXYZi", (void (Fmatrix::*)(float &, float &, float &) const)(&Fmatrix::getXYZi)) - ]; +SCRIPT_EXPORT(Fmatrix, (), { + module( + luaState)[class_( + "matrix").def_readwrite("i", &Fmatrix::i) + .def_readwrite("_14_", &Fmatrix::_14_) + .def_readwrite("j", &Fmatrix::j) + .def_readwrite("_24_", &Fmatrix::_24_) + .def_readwrite("k", &Fmatrix::k) + .def_readwrite("_34_", &Fmatrix::_34_) + .def_readwrite("c", &Fmatrix::c) + .def_readwrite("_44_", &Fmatrix::_44_) + .def(constructor<>()) + .def("set", (Fmatrix & (Fmatrix::*)(const Fmatrix&))(&Fmatrix::set), return_reference_to<1>()) + .def("set", (Fmatrix & (Fmatrix::*)(const Fvector&, const Fvector&, const Fvector&, + const Fvector&))(&Fmatrix::set), + return_reference_to<1>()) + .def("identity", &Fmatrix::identity, return_reference_to<1>()) + .def("mk_xform", &Fmatrix::mk_xform, return_reference_to<1>()) + .def("mul", (Fmatrix & (Fmatrix::*)(const Fmatrix&, const Fmatrix&))(&Fmatrix::mul), + return_reference_to<1>()) + .def("mul", (Fmatrix & (Fmatrix::*)(const Fmatrix&, float))(&Fmatrix::mul), + return_reference_to<1>()) + .def("mul", (Fmatrix & (Fmatrix::*)(float))(&Fmatrix::mul), return_reference_to<1>()) + .def("div", (Fmatrix & (Fmatrix::*)(const Fmatrix&, float))(&Fmatrix::div), + return_reference_to<1>()) + .def("div", (Fmatrix & (Fmatrix::*)(float))(&Fmatrix::div), return_reference_to<1>()) + // .def("invert", (Fmatrix & (Fmatrix::*)())(&Fmatrix::invert), + //return_reference_to<1>()) + // .def("invert", (Fmatrix & (Fmatrix::*)(const Fmatrix + //&))(&Fmatrix::invert), return_reference_to<1>()) + // .def("transpose", (Fmatrix & + //(Fmatrix::*)())(&Fmatrix::transpose), + //return_reference_to<1>()) + // .def("transpose", (Fmatrix & (Fmatrix::*)(const Fmatrix + //&))(&Fmatrix::transpose), return_reference_to<1>()) + // .def("translate", (Fmatrix & (Fmatrix::*)(const Fvector + //&))(&Fmatrix::translate), return_reference_to<1>()) + // .def("translate", (Fmatrix & (Fmatrix::*)(float, float, + //float))(&Fmatrix::translate), return_reference_to<1>()) + // .def("translate_over", (Fmatrix & (Fmatrix::*)(const Fvector + //&))(&Fmatrix::translate_over), return_reference_to<1>()) + // .def("translate_over", (Fmatrix & (Fmatrix::*)(float, float, + //float))(&Fmatrix::translate_over), + //return_reference_to<1>()) + // .def("translate_add", &Fmatrix::translate_add, + //return_reference_to<1>()) + // .def("scale", (Fmatrix & (Fmatrix::*)(const Fvector + //&))(&Fmatrix::scale), return_reference_to<1>()) + // .def("scale", (Fmatrix & (Fmatrix::*)(float, float, + //float))(&Fmatrix::scale), return_reference_to<1>()) + // .def("rotateX", &Fmatrix::rotateX, + //return_reference_to<1>()) + // .def("rotateY", &Fmatrix::rotateY, + //return_reference_to<1>()) + // .def("rotateZ", &Fmatrix::rotateZ, + //return_reference_to<1>()) + // .def("rotation", (Fmatrix & (Fmatrix::*)(const Fvector &, const + //Fvector &))(&Fmatrix::rotation), return_reference_to<1>()) + // .def("rotation", (Fmatrix & (Fmatrix::*)(const Fvector &, + //float))(&Fmatrix::rotation), return_reference_to<1>()) + // .def("rotation", &Fmatrix::rotation, + //return_reference_to<1>()) + /* + .def("mapXYZ", &Fmatrix::mapXYZ, + return_reference_to<1>()) + .def("mapXZY", &Fmatrix::mapXZY, + return_reference_to<1>()) + .def("mapYXZ", &Fmatrix::mapYXZ, + return_reference_to<1>()) + .def("mapYZX", &Fmatrix::mapYZX, + return_reference_to<1>()) + .def("mapZXY", &Fmatrix::mapZXY, + return_reference_to<1>()) + .def("mapZYX", &Fmatrix::mapZYX, + return_reference_to<1>()) + .def("mirrorX", &Fmatrix::mirrorX, + return_reference_to<1>()) + .def("mirrorX_over", &Fmatrix::mirrorX_over, + return_reference_to<1>()) + .def("mirrorX_add ", &Fmatrix::mirrorX_add, + return_reference_to<1>()) + .def("mirrorY", &Fmatrix::mirrorY, + return_reference_to<1>()) + .def("mirrorY_over", &Fmatrix::mirrorY_over, + return_reference_to<1>()) + .def("mirrorY_add ", &Fmatrix::mirrorY_add, + return_reference_to<1>()) + .def("mirrorZ", &Fmatrix::mirrorZ, + return_reference_to<1>()) + .def("mirrorZ_over", &Fmatrix::mirrorZ_over, + return_reference_to<1>()) + .def("mirrorZ_add ", &Fmatrix::mirrorZ_add, + return_reference_to<1>()) + */ + // .def("build_projection", &Fmatrix::build_projection, + //return_reference_to<1>()) + // .def("build_projection_HAT", &Fmatrix::build_projection_HAT, + //return_reference_to<1>()) + // .def("build_projection_ortho", &Fmatrix::build_projection_ortho, + //return_reference_to<1>()) + // .def("build_camera", &Fmatrix::build_camera, + //return_reference_to<1>()) + // .def("build_camera_dir", &Fmatrix::build_camera_dir, + //return_reference_to<1>()) + // .def("inertion", &Fmatrix::inertion, + //return_reference_to<1>()) + // .def("transform_tiny32", &Fmatrix::transform_tiny32) + // .def("transform_tiny23", &Fmatrix::transform_tiny23) + // .def("transform_tiny", (void (Fmatrix::*)(Fvector &) + //const)(&Fmatrix::transform_tiny), out_value<2>()) + // .def("transform_tiny", (void (Fmatrix::*)(Fvector &, const + //Fvector &) const)(&Fmatrix::transform_tiny), out_value<2>()) + // .def("transform_dir", (void (Fmatrix::*)(Fvector &) + //const)(&Fmatrix::transform_dir), out_value<2>()) + // .def("transform_dir", (void (Fmatrix::*)(Fvector &, const + //Fvector &) const)(&Fmatrix::transform_dir), out_value<2>()) + // .def("transform", (void (Fmatrix::*)(Fvector &) + //const)(&Fmatrix::transform), out_value<2>()) + // .def("transform", &matrix_transform) + .def("setHPB", &Fmatrix::setHPB, return_reference_to<1>()) + // .def("setXYZ", (Fmatrix & (Fmatrix::*)(Fvector + //&))(&Fmatrix::setXYZ), policy_list, out_value<2>>()) + .def("setXYZ", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::setXYZ), + return_reference_to<1>()) + // .def("setXYZi", (Fmatrix & (Fmatrix::*)(Fvector + //&))(&Fmatrix::setXYZi), policy_list, out_value<2>>()) + .def("setXYZi", (Fmatrix & (Fmatrix::*)(float, float, float))(&Fmatrix::setXYZi), + return_reference_to<1>()) + // .def("getHPB", (void (Fmatrix::*)(Fvector &) + //const)(&Fmatrix::getHPB), out_value<2>()) + .def("getHPB", &get_matrix_hpb) + // .def("getXYZ", (void (Fmatrix::*)(Fvector &) const)(&Fmatrix::getXYZ), + //out_value<2>()) + // .def("getXYZ", (void (Fmatrix::*)(float &, float &, float &) + //const)(&Fmatrix::getXYZ)) + // .def("getXYZi", (void (Fmatrix::*)(Fvector &) const)(&Fmatrix::getXYZi), + //out_value<2>()) + // .def("getXYZi", (void (Fmatrix::*)(float &, float &, float &) + //const)(&Fmatrix::getXYZi)) + ]; }); diff --git a/src/xrServerEntities/script_fvector_script.cpp b/src/xrServerEntities/script_fvector_script.cpp index 7f7a61436e3..31a4cc14c64 100644 --- a/src/xrServerEntities/script_fvector_script.cpp +++ b/src/xrServerEntities/script_fvector_script.cpp @@ -12,123 +12,153 @@ using namespace luabind; using namespace luabind::policy; -SCRIPT_EXPORT(Fvector, (), -{ - module(luaState) - [ - class_("vector") - .def_readwrite("x", &Fvector::x) - .def_readwrite("y", &Fvector::y) - .def_readwrite("z", &Fvector::z) - .def( constructor<>()) - .def("set", (Fvector & (Fvector::*)(float,float,float))(&Fvector::set), return_reference_to<1>()) - .def("set", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::set), return_reference_to<1>()) - .def("add", (Fvector & (Fvector::*)(float))(&Fvector::add), return_reference_to<1>()) - .def("add", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::add), return_reference_to<1>()) - .def("add", (Fvector & (Fvector::*)(const Fvector &, const Fvector &))(&Fvector::add), return_reference_to<1>()) - .def("add", (Fvector & (Fvector::*)(const Fvector &, float))(&Fvector::add), return_reference_to<1>()) - .def("sub", (Fvector & (Fvector::*)(float))(&Fvector::sub), return_reference_to<1>()) - .def("sub", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::sub), return_reference_to<1>()) - .def("sub", (Fvector & (Fvector::*)(const Fvector &, const Fvector &))(&Fvector::sub), return_reference_to<1>()) - .def("sub", (Fvector & (Fvector::*)(const Fvector &, float))(&Fvector::sub), return_reference_to<1>()) - .def("mul", (Fvector & (Fvector::*)(float))(&Fvector::mul), return_reference_to<1>()) - .def("mul", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::mul), return_reference_to<1>()) - .def("mul", (Fvector & (Fvector::*)(const Fvector &, const Fvector &))(&Fvector::mul), return_reference_to<1>()) - .def("mul", (Fvector & (Fvector::*)(const Fvector &, float))(&Fvector::mul), return_reference_to<1>()) - .def("div", (Fvector & (Fvector::*)(float))(&Fvector::div), return_reference_to<1>()) - .def("div", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::div), return_reference_to<1>()) - .def("div", (Fvector & (Fvector::*)(const Fvector &, const Fvector &))(&Fvector::div), return_reference_to<1>()) - .def("div", (Fvector & (Fvector::*)(const Fvector &, float))(&Fvector::div), return_reference_to<1>()) - .def("invert", (Fvector & (Fvector::*)())(&Fvector::invert), return_reference_to<1>()) - .def("invert", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::invert), return_reference_to<1>()) - .def("min", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::min), return_reference_to<1>()) - .def("min", (Fvector & (Fvector::*)(const Fvector &, const Fvector &))(&Fvector::min), return_reference_to<1>()) - .def("max", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::max), return_reference_to<1>()) - .def("max", (Fvector & (Fvector::*)(const Fvector &, const Fvector &))(&Fvector::max), return_reference_to<1>()) - .def("abs", &Fvector::abs, return_reference_to<1>()) - .def("similar", &Fvector::similar) - .def("set_length", &Fvector::set_length, return_reference_to<1>()) - .def("align", &Fvector::align, return_reference_to<1>()) -// .def("squeeze", &Fvector::squeeze, return_reference_to<1>()) - .def("clamp", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::clamp), return_reference_to<1>()) - .def("clamp", (Fvector & (Fvector::*)(const Fvector &, const Fvector &))(&Fvector::clamp), return_reference_to<1>()) - .def("inertion", &Fvector::inertion, return_reference_to<1>()) - .def("average", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::average), return_reference_to<1>()) - .def("average", (Fvector & (Fvector::*)(const Fvector &, const Fvector &))(&Fvector::average), return_reference_to<1>()) - .def("lerp", &Fvector::lerp, return_reference_to<1>()) - .def("mad", (Fvector & (Fvector::*)(const Fvector &, float))(&Fvector::mad), return_reference_to<1>()) - .def("mad", (Fvector & (Fvector::*)(const Fvector &, const Fvector &, float))(&Fvector::mad), return_reference_to<1>()) - .def("mad", (Fvector & (Fvector::*)(const Fvector &, const Fvector &))(&Fvector::mad), return_reference_to<1>()) - .def("mad", (Fvector & (Fvector::*)(const Fvector &, const Fvector &, const Fvector &))(&Fvector::mad), return_reference_to<1>()) -// .def("square_magnitude", &Fvector::square_magnitude) - .def("magnitude", &Fvector::magnitude) -// .def("normalize_magnitude", &Fvector::normalize_magn) - .def("normalize", (Fvector & (Fvector::*)())(&Fvector::normalize_safe), return_reference_to<1>()) - .def("normalize", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::normalize_safe), return_reference_to<1>()) - .def("normalize_safe", (Fvector & (Fvector::*)())(&Fvector::normalize_safe), return_reference_to<1>()) - .def("normalize_safe", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::normalize_safe), return_reference_to<1>()) -// .def("random_dir", (Fvector & (Fvector::*)())(&Fvector::random_dir), return_reference_to<1>()) -// .def("random_dir", (Fvector & (Fvector::*)(const Fvector &, float))(&Fvector::random_dir), return_reference_to<1>()) -// .def("random_point", (Fvector & (Fvector::*)(const Fvector &))(&Fvector::random_point), return_reference_to<1>()) -// .def("random_point", (Fvector & (Fvector::*)(float))(&Fvector::random_point), return_reference_to<1>()) - .def("dotproduct", &Fvector::dotproduct) - .def("crossproduct", &Fvector::crossproduct, return_reference_to<1>()) - .def("distance_to_xz", &Fvector::distance_to_xz) - .def("distance_to_sqr", &Fvector::distance_to_sqr) - .def("distance_to", &Fvector::distance_to) -// .def("from_bary", (Fvector & (Fvector::*)(const Fvector &, const Fvector &, const Fvector &, float, float, float))(&Fvector::from_bary), return_reference_to<1>()) -// .def("from_bary", (Fvector & (Fvector::*)(const Fvector &, const Fvector &, const Fvector &, const Fvector &))(&Fvector::from_bary), return_reference_to<1>()) -// .def("from_bary4", &Fvector::from_bary4, return_reference_to<1>()) -// .def("mknormal_non_normalized", &Fvector::mknormal_non_normalized, return_reference_to<1>()) -// .def("mknormal", &Fvector::mknormal, return_reference_to<1>()) - .def("setHP", &Fvector::setHP, return_reference_to<1>()) -// .def("getHP", &Fvector::getHP, policy_list, out_value<3>>()) - .def("getH", &Fvector::getH) - .def("getP", &Fvector::getP) +SCRIPT_EXPORT( + Fvector, (), { + module( + luaState)[class_( + "vector").def_readwrite("x", &Fvector::x) + .def_readwrite("y", &Fvector::y) + .def_readwrite("z", &Fvector::z) + .def(constructor<>()) + .def("set", (Fvector & (Fvector::*)(float, float, float))(&Fvector::set), + return_reference_to<1>()) + .def("set", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::set), return_reference_to<1>()) + .def("add", (Fvector & (Fvector::*)(float))(&Fvector::add), return_reference_to<1>()) + .def("add", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::add), return_reference_to<1>()) + .def("add", (Fvector & (Fvector::*)(const Fvector&, const Fvector&))(&Fvector::add), + return_reference_to<1>()) + .def("add", (Fvector & (Fvector::*)(const Fvector&, float))(&Fvector::add), + return_reference_to<1>()) + .def("sub", (Fvector & (Fvector::*)(float))(&Fvector::sub), return_reference_to<1>()) + .def("sub", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::sub), return_reference_to<1>()) + .def("sub", (Fvector & (Fvector::*)(const Fvector&, const Fvector&))(&Fvector::sub), + return_reference_to<1>()) + .def("sub", (Fvector & (Fvector::*)(const Fvector&, float))(&Fvector::sub), + return_reference_to<1>()) + .def("mul", (Fvector & (Fvector::*)(float))(&Fvector::mul), return_reference_to<1>()) + .def("mul", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::mul), return_reference_to<1>()) + .def("mul", (Fvector & (Fvector::*)(const Fvector&, const Fvector&))(&Fvector::mul), + return_reference_to<1>()) + .def("mul", (Fvector & (Fvector::*)(const Fvector&, float))(&Fvector::mul), + return_reference_to<1>()) + .def("div", (Fvector & (Fvector::*)(float))(&Fvector::div), return_reference_to<1>()) + .def("div", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::div), return_reference_to<1>()) + .def("div", (Fvector & (Fvector::*)(const Fvector&, const Fvector&))(&Fvector::div), + return_reference_to<1>()) + .def("div", (Fvector & (Fvector::*)(const Fvector&, float))(&Fvector::div), + return_reference_to<1>()) + .def("invert", (Fvector & (Fvector::*)())(&Fvector::invert), return_reference_to<1>()) + .def("invert", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::invert), + return_reference_to<1>()) + .def("min", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::min), return_reference_to<1>()) + .def("min", (Fvector & (Fvector::*)(const Fvector&, const Fvector&))(&Fvector::min), + return_reference_to<1>()) + .def("max", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::max), return_reference_to<1>()) + .def("max", (Fvector & (Fvector::*)(const Fvector&, const Fvector&))(&Fvector::max), + return_reference_to<1>()) + .def("abs", &Fvector::abs, return_reference_to<1>()) + .def("similar", &Fvector::similar) + .def("set_length", &Fvector::set_length, return_reference_to<1>()) + .def("align", &Fvector::align, return_reference_to<1>()) + // .def("squeeze", &Fvector::squeeze, + //return_reference_to<1>()) + .def("clamp", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::clamp), + return_reference_to<1>()) + .def("clamp", (Fvector & (Fvector::*)(const Fvector&, const Fvector&))(&Fvector::clamp), + return_reference_to<1>()) + .def("inertion", &Fvector::inertion, return_reference_to<1>()) + .def("average", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::average), + return_reference_to<1>()) + .def("average", (Fvector & (Fvector::*)(const Fvector&, const Fvector&))(&Fvector::average), + return_reference_to<1>()) + .def("lerp", &Fvector::lerp, return_reference_to<1>()) + .def("mad", (Fvector & (Fvector::*)(const Fvector&, float))(&Fvector::mad), + return_reference_to<1>()) + .def("mad", (Fvector & (Fvector::*)(const Fvector&, const Fvector&, float))(&Fvector::mad), + return_reference_to<1>()) + .def("mad", (Fvector & (Fvector::*)(const Fvector&, const Fvector&))(&Fvector::mad), + return_reference_to<1>()) + .def("mad", + (Fvector & (Fvector::*)(const Fvector&, const Fvector&, const Fvector&))(&Fvector::mad), + return_reference_to<1>()) + // .def("square_magnitude", &Fvector::square_magnitude) + .def("magnitude", &Fvector::magnitude) + // .def("normalize_magnitude", &Fvector::normalize_magn) + .def("normalize", (Fvector & (Fvector::*)())(&Fvector::normalize_safe), + return_reference_to<1>()) + .def("normalize", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::normalize_safe), + return_reference_to<1>()) + .def("normalize_safe", (Fvector & (Fvector::*)())(&Fvector::normalize_safe), + return_reference_to<1>()) + .def("normalize_safe", (Fvector & (Fvector::*)(const Fvector&))(&Fvector::normalize_safe), + return_reference_to<1>()) + // .def("random_dir", (Fvector & + //(Fvector::*)())(&Fvector::random_dir), + //return_reference_to<1>()) + // .def("random_dir", (Fvector & (Fvector::*)(const Fvector &, + //float))(&Fvector::random_dir), + //return_reference_to<1>()) + // .def("random_point", (Fvector & (Fvector::*)(const Fvector + //&))(&Fvector::random_point), + //return_reference_to<1>()) + // .def("random_point", (Fvector & + //(Fvector::*)(float))(&Fvector::random_point), + //return_reference_to<1>()) + .def("dotproduct", &Fvector::dotproduct) + .def("crossproduct", &Fvector::crossproduct, return_reference_to<1>()) + .def("distance_to_xz", &Fvector::distance_to_xz) + .def("distance_to_sqr", &Fvector::distance_to_sqr) + .def("distance_to", &Fvector::distance_to) + // .def("from_bary", (Fvector & (Fvector::*)(const Fvector &, + //const Fvector &, const Fvector &, float, float, float))(&Fvector::from_bary), + //return_reference_to<1>()) + // .def("from_bary", (Fvector & (Fvector::*)(const Fvector &, + //const Fvector &, const Fvector &, const Fvector &))(&Fvector::from_bary), + //return_reference_to<1>()) + // .def("from_bary4", &Fvector::from_bary4, + //return_reference_to<1>()) + // .def("mknormal_non_normalized", &Fvector::mknormal_non_normalized, + //return_reference_to<1>()) + // .def("mknormal", &Fvector::mknormal, + //return_reference_to<1>()) + .def("setHP", &Fvector::setHP, return_reference_to<1>()) + // .def("getHP", &Fvector::getHP, policy_list, + //out_value<3>>()) + .def("getH", &Fvector::getH) + .def("getP", &Fvector::getP) - .def("reflect", &Fvector::reflect, return_reference_to<1>()) - .def("slide", &Fvector::slide, return_reference_to<1>()) -// .def("generate_orthonormal_basis", &Fvector::generate_orthonormal_basis), - ]; -}); + .def("reflect", &Fvector::reflect, return_reference_to<1>()) + .def("slide", &Fvector::slide, return_reference_to<1>()) + // .def("generate_orthonormal_basis", &Fvector::generate_orthonormal_basis), + ]; + }); -SCRIPT_EXPORT(Fvector2, (), -{ - module(luaState) - [ - class_("vector2") - .def_readwrite("x", &Fvector2::x) - .def_readwrite("y", &Fvector2::y) - .def(constructor<>()) - .def("set", (Fvector2 & (Fvector2::*)(float,float))(&Fvector2::set), return_reference_to<1>()) - .def("set", (Fvector2 & (Fvector2::*)(const Fvector2 &))(&Fvector2::set), return_reference_to<1>()) - ]; +SCRIPT_EXPORT(Fvector2, (), { + module(luaState)[class_( + "vector2").def_readwrite("x", &Fvector2::x) + .def_readwrite("y", &Fvector2::y) + .def(constructor<>()) + .def("set", (Fvector2 & (Fvector2::*)(float, float))(&Fvector2::set), return_reference_to<1>()) + .def("set", (Fvector2 & (Fvector2::*)(const Fvector2&))(&Fvector2::set), + return_reference_to<1>())]; }); -SCRIPT_EXPORT(Fbox, (), -{ +SCRIPT_EXPORT(Fbox, (), { module(luaState) - [ - class_("Fbox") - .def_readwrite("min", &Fbox::min) - .def_readwrite("max", &Fbox::max) - .def(constructor<>()) - ]; + [class_("Fbox").def_readwrite("min", &Fbox::min).def_readwrite("max", &Fbox::max).def(constructor<>())]; }); -SCRIPT_EXPORT(Frect, (), -{ - module(luaState) - [ - class_("Frect") - .def( constructor<>()) - .def("set", (Frect & (Frect::*)(float,float,float,float))(&Frect::set), return_reference_to<1>()) - .def_readwrite("lt", &Frect::lt) - .def_readwrite("rb", &Frect::rb) - .def_readwrite("x1", &Frect::x1) - .def_readwrite("x2", &Frect::x2) - .def_readwrite("y1", &Frect::y1) - .def_readwrite("y2", &Frect::y2) +SCRIPT_EXPORT(Frect, (), { + module(luaState)[class_( + "Frect").def(constructor<>()) + .def("set", (Frect & (Frect::*)(float, float, float, float))(&Frect::set), + return_reference_to<1>()) + .def_readwrite("lt", &Frect::lt) + .def_readwrite("rb", &Frect::rb) + .def_readwrite("x1", &Frect::x1) + .def_readwrite("x2", &Frect::x2) + .def_readwrite("y1", &Frect::y1) + .def_readwrite("y2", &Frect::y2) - ]; + ]; }); diff --git a/src/xrServerEntities/script_ini_file.cpp b/src/xrServerEntities/script_ini_file.cpp index fcd6bdee092..3511bf66793 100644 --- a/src/xrServerEntities/script_ini_file.cpp +++ b/src/xrServerEntities/script_ini_file.cpp @@ -6,100 +6,99 @@ // Description : Script ini file class //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" #include "script_ini_file.h" -#include "xrScriptEngine/script_engine.hpp" #include "ai_space.h" #include "object_factory.h" +#include "stdafx.h" +#include "xrScriptEngine/script_engine.hpp" -CScriptIniFile::CScriptIniFile (IReader *F, LPCSTR path) : - inherited (F,path) +CScriptIniFile::CScriptIniFile(IReader* F, LPCSTR path) : inherited(F, path) { } -CScriptIniFile::CScriptIniFile (LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd) : - inherited (update(szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) +CScriptIniFile::CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly, BOOL bLoadAtStart, BOOL SaveAtEnd) + : inherited(update(szFileName), ReadOnly, bLoadAtStart, SaveAtEnd) { } -CScriptIniFile::~CScriptIniFile () +CScriptIniFile::~CScriptIniFile() { } -LPCSTR CScriptIniFile::update (LPCSTR file_name) +LPCSTR CScriptIniFile::update(LPCSTR file_name) { - string_path S1; - FS.update_path (S1,"$game_config$",file_name); - return (*shared_str(S1)); + string_path S1; + FS.update_path(S1, "$game_config$", file_name); + return (*shared_str(S1)); } -bool CScriptIniFile::line_exist (LPCSTR S, LPCSTR L) +bool CScriptIniFile::line_exist(LPCSTR S, LPCSTR L) { - return (!!inherited::line_exist(S,L)); + return (!!inherited::line_exist(S, L)); } -bool CScriptIniFile::section_exist (LPCSTR S) +bool CScriptIniFile::section_exist(LPCSTR S) { - return (!!inherited::section_exist(S)); + return (!!inherited::section_exist(S)); } -int CScriptIniFile::r_clsid (LPCSTR S, LPCSTR L) +int CScriptIniFile::r_clsid(LPCSTR S, LPCSTR L) { - return (object_factory().script_clsid(inherited::r_clsid(S,L))); + return (object_factory().script_clsid(inherited::r_clsid(S, L))); } -bool CScriptIniFile::r_bool (LPCSTR S, LPCSTR L) +bool CScriptIniFile::r_bool(LPCSTR S, LPCSTR L) { - return (!!inherited::r_bool(S,L)); + return (!!inherited::r_bool(S, L)); } -int CScriptIniFile::r_token (LPCSTR S, LPCSTR L, const CScriptTokenList &token_list) +int CScriptIniFile::r_token(LPCSTR S, LPCSTR L, const CScriptTokenList& token_list) { - return (inherited::r_token(S,L,&*token_list.tokens().begin())); + return (inherited::r_token(S, L, &*token_list.tokens().begin())); } -LPCSTR CScriptIniFile::r_string_wb (LPCSTR S, LPCSTR L) +LPCSTR CScriptIniFile::r_string_wb(LPCSTR S, LPCSTR L) { - return (*inherited::r_string_wb(S,L)); + return (*inherited::r_string_wb(S, L)); } -u32 CScriptIniFile::line_count (LPCSTR S) +u32 CScriptIniFile::line_count(LPCSTR S) { - THROW3 (inherited::section_exist(S),"Cannot find section",S); - return (inherited::line_count(S)); + THROW3(inherited::section_exist(S), "Cannot find section", S); + return (inherited::line_count(S)); } -LPCSTR CScriptIniFile::r_string (LPCSTR S, LPCSTR L) +LPCSTR CScriptIniFile::r_string(LPCSTR S, LPCSTR L) { - THROW3 (inherited::section_exist(S),"Cannot find section",S); - THROW3 (inherited::line_exist(S,L),"Cannot find line",L); - return (inherited::r_string(S,L)); + THROW3(inherited::section_exist(S), "Cannot find section", S); + THROW3(inherited::line_exist(S, L), "Cannot find line", L); + return (inherited::r_string(S, L)); } -u32 CScriptIniFile::r_u32 (LPCSTR S, LPCSTR L) +u32 CScriptIniFile::r_u32(LPCSTR S, LPCSTR L) { - THROW3 (inherited::section_exist(S),"Cannot find section",S); - THROW3 (inherited::line_exist(S,L),"Cannot find line",L); - return (inherited::r_u32(S,L)); + THROW3(inherited::section_exist(S), "Cannot find section", S); + THROW3(inherited::line_exist(S, L), "Cannot find line", L); + return (inherited::r_u32(S, L)); } -int CScriptIniFile::r_s32 (LPCSTR S, LPCSTR L) +int CScriptIniFile::r_s32(LPCSTR S, LPCSTR L) { - THROW3 (inherited::section_exist(S),"Cannot find section",S); - THROW3 (inherited::line_exist(S,L),"Cannot find line",L); - return (inherited::r_s32(S,L)); + THROW3(inherited::section_exist(S), "Cannot find section", S); + THROW3(inherited::line_exist(S, L), "Cannot find line", L); + return (inherited::r_s32(S, L)); } -float CScriptIniFile::r_float (LPCSTR S, LPCSTR L) +float CScriptIniFile::r_float(LPCSTR S, LPCSTR L) { - THROW3 (inherited::section_exist(S),"Cannot find section",S); - THROW3 (inherited::line_exist(S,L),"Cannot find line",L); - return (inherited::r_float(S,L)); + THROW3(inherited::section_exist(S), "Cannot find section", S); + THROW3(inherited::line_exist(S, L), "Cannot find line", L); + return (inherited::r_float(S, L)); } -Fvector CScriptIniFile::r_fvector3 (LPCSTR S, LPCSTR L) +Fvector CScriptIniFile::r_fvector3(LPCSTR S, LPCSTR L) { - THROW3 (inherited::section_exist(S),"Cannot find section",S); - THROW3 (inherited::line_exist(S,L),"Cannot find line",L); - return (inherited::r_fvector3(S,L)); + THROW3(inherited::section_exist(S), "Cannot find section", S); + THROW3(inherited::line_exist(S, L), "Cannot find line", L); + return (inherited::r_fvector3(S, L)); } diff --git a/src/xrServerEntities/script_ini_file.h b/src/xrServerEntities/script_ini_file.h index 0f13da707a9..6b6832eb361 100644 --- a/src/xrServerEntities/script_ini_file.h +++ b/src/xrServerEntities/script_ini_file.h @@ -10,27 +10,28 @@ #include "script_token_list.h" -class CScriptIniFile : public CInifile { +class CScriptIniFile : public CInifile +{ protected: - typedef CInifile inherited; + typedef CInifile inherited; public: - CScriptIniFile (IReader *F, LPCSTR path=0); - CScriptIniFile (LPCSTR szFileName, BOOL ReadOnly=TRUE, BOOL bLoadAtStart=TRUE, BOOL SaveAtEnd=TRUE); - virtual ~CScriptIniFile (); - bool line_exist (LPCSTR S, LPCSTR L); - bool section_exist (LPCSTR S); - int r_clsid (LPCSTR S, LPCSTR L); - bool r_bool (LPCSTR S, LPCSTR L); - int r_token (LPCSTR S, LPCSTR L, const CScriptTokenList &token_list); - LPCSTR r_string_wb (LPCSTR S, LPCSTR L); - LPCSTR update (LPCSTR file_name); - u32 line_count (LPCSTR S); - LPCSTR r_string (LPCSTR S, LPCSTR L); - u32 r_u32 (LPCSTR S, LPCSTR L); - int r_s32 (LPCSTR S, LPCSTR L); - float r_float (LPCSTR S, LPCSTR L); - Fvector r_fvector3 (LPCSTR S, LPCSTR L); + CScriptIniFile(IReader* F, LPCSTR path = 0); + CScriptIniFile(LPCSTR szFileName, BOOL ReadOnly = TRUE, BOOL bLoadAtStart = TRUE, BOOL SaveAtEnd = TRUE); + virtual ~CScriptIniFile(); + bool line_exist(LPCSTR S, LPCSTR L); + bool section_exist(LPCSTR S); + int r_clsid(LPCSTR S, LPCSTR L); + bool r_bool(LPCSTR S, LPCSTR L); + int r_token(LPCSTR S, LPCSTR L, const CScriptTokenList& token_list); + LPCSTR r_string_wb(LPCSTR S, LPCSTR L); + LPCSTR update(LPCSTR file_name); + u32 line_count(LPCSTR S); + LPCSTR r_string(LPCSTR S, LPCSTR L); + u32 r_u32(LPCSTR S, LPCSTR L); + int r_s32(LPCSTR S, LPCSTR L); + float r_float(LPCSTR S, LPCSTR L); + Fvector r_fvector3(LPCSTR S, LPCSTR L); }; #include "script_ini_file_inline.h" diff --git a/src/xrServerEntities/script_ini_file_inline.h b/src/xrServerEntities/script_ini_file_inline.h index a3bb3a82e94..e251a416690 100644 --- a/src/xrServerEntities/script_ini_file_inline.h +++ b/src/xrServerEntities/script_ini_file_inline.h @@ -7,4 +7,3 @@ //////////////////////////////////////////////////////////////////////////// #pragma once - diff --git a/src/xrServerEntities/script_ini_file_script.cpp b/src/xrServerEntities/script_ini_file_script.cpp index e77774550b0..6f3b80fd93d 100644 --- a/src/xrServerEntities/script_ini_file_script.cpp +++ b/src/xrServerEntities/script_ini_file_script.cpp @@ -13,76 +13,65 @@ using namespace luabind; using namespace luabind::policy; -CScriptIniFile *get_system_ini() +CScriptIniFile* get_system_ini() { - return ((CScriptIniFile*)pSettings); + return ((CScriptIniFile*)pSettings); } -bool r_line(CScriptIniFile *self, LPCSTR S, int L, luabind::string &N, luabind::string &V) +bool r_line(CScriptIniFile* self, LPCSTR S, int L, luabind::string& N, luabind::string& V) { - THROW3 (self->section_exist(S),"Cannot find section",S); - THROW2 ((int)self->line_count(S) > L,"Invalid line number"); - - N = ""; - V = ""; - - LPCSTR n,v; - bool result = !!self->r_line(S,L,&n,&v); - if (!result) - return (false); + THROW3(self->section_exist(S), "Cannot find section", S); + THROW2((int)self->line_count(S) > L, "Invalid line number"); - N = n; - if (v) - V = v; - return (true); + N = ""; + V = ""; + + LPCSTR n, v; + bool result = !!self->r_line(S, L, &n, &v); + if (!result) return (false); + + N = n; + if (v) V = v; + return (true); } #pragma warning(push) -#pragma warning(disable:4238) -CScriptIniFile *create_ini_file (LPCSTR ini_string) +#pragma warning(disable : 4238) +CScriptIniFile* create_ini_file(LPCSTR ini_string) { - return ( - (CScriptIniFile*) - new CInifile( - &IReader ( - (void*)ini_string, - xr_strlen(ini_string) - ), - FS.get_path("$game_config$")->m_Path - ) - ); + return ((CScriptIniFile*)new CInifile( + &IReader((void*)ini_string, xr_strlen(ini_string)), FS.get_path("$game_config$")->m_Path)); } #pragma warning(pop) #ifdef XRGAME_EXPORTS -CScriptIniFile *get_game_ini() { return (CScriptIniFile*)pGameIni; } +CScriptIniFile* get_game_ini() +{ + return (CScriptIniFile*)pGameIni; +} #endif -static void CScriptIniFile_Export(lua_State *luaState) +static void CScriptIniFile_Export(lua_State* luaState) { - module(luaState) - [ - class_("ini_file") - .def( constructor()) - .def("section_exist", &CScriptIniFile::section_exist ) - .def("line_exist", &CScriptIniFile::line_exist ) - .def("r_clsid", &CScriptIniFile::r_clsid ) - .def("r_bool", &CScriptIniFile::r_bool ) - .def("r_token", &CScriptIniFile::r_token ) - .def("r_string_wq", &CScriptIniFile::r_string_wb ) - .def("line_count", &CScriptIniFile::line_count) - .def("r_string", &CScriptIniFile::r_string) - .def("r_u32", &CScriptIniFile::r_u32) - .def("r_s32", &CScriptIniFile::r_s32) - .def("r_float", &CScriptIniFile::r_float) - .def("r_vector", &CScriptIniFile::r_fvector3) - .def("r_line", &::r_line, policy_list, out_value<5>>()), + module(luaState)[class_("ini_file") + .def(constructor()) + .def("section_exist", &CScriptIniFile::section_exist) + .def("line_exist", &CScriptIniFile::line_exist) + .def("r_clsid", &CScriptIniFile::r_clsid) + .def("r_bool", &CScriptIniFile::r_bool) + .def("r_token", &CScriptIniFile::r_token) + .def("r_string_wq", &CScriptIniFile::r_string_wb) + .def("line_count", &CScriptIniFile::line_count) + .def("r_string", &CScriptIniFile::r_string) + .def("r_u32", &CScriptIniFile::r_u32) + .def("r_s32", &CScriptIniFile::r_s32) + .def("r_float", &CScriptIniFile::r_float) + .def("r_vector", &CScriptIniFile::r_fvector3) + .def("r_line", &::r_line, policy_list, out_value<5>>()), #ifdef XRGAME_EXPORTS def("game_ini", &get_game_ini), #endif - def("system_ini", &get_system_ini), - def("create_ini_file", &create_ini_file, adopt<0>()) - ]; + def("system_ini", &get_system_ini), def("create_ini_file", &create_ini_file, adopt<0>())]; } SCRIPT_EXPORT_FUNC(CScriptIniFile, (), CScriptIniFile_Export); diff --git a/src/xrServerEntities/script_net_packet_script.cpp b/src/xrServerEntities/script_net_packet_script.cpp index e0bbf2e22c2..b0a685eb4dc 100644 --- a/src/xrServerEntities/script_net_packet_script.cpp +++ b/src/xrServerEntities/script_net_packet_script.cpp @@ -12,110 +12,102 @@ using namespace luabind; using namespace luabind::policy; -bool r_eof(NET_Packet *self) +bool r_eof(NET_Packet* self) { - return (!!self->r_eof()); + return (!!self->r_eof()); } -LPCSTR r_stringZ(NET_Packet *self) +LPCSTR r_stringZ(NET_Packet* self) { - shared_str temp; - self->r_stringZ (temp); - return (*temp); + shared_str temp; + self->r_stringZ(temp); + return (*temp); } -void w_bool(NET_Packet *self, bool value) +void w_bool(NET_Packet* self, bool value) { - self->w_u8 (value ? 1 : 0); + self->w_u8(value ? 1 : 0); } -bool r_bool(NET_Packet *self) +bool r_bool(NET_Packet* self) { - return (!!self->r_u8()); + return (!!self->r_u8()); } -ClientID r_clientID(NET_Packet *self) +ClientID r_clientID(NET_Packet* self) { - ClientID clientID; - self->r_clientID(clientID); - return clientID; + ClientID clientID; + self->r_clientID(clientID); + return clientID; } -extern u16 script_server_object_version (); +extern u16 script_server_object_version(); -SCRIPT_EXPORT(ClientID, (), -{ - module(luaState) - [ - class_("ClientID") - .def( constructor<>() ) - .def("value", &ClientID::value ) - .def("set", &ClientID::set ) - .def(self == other()) - ]; +SCRIPT_EXPORT(ClientID, (), { + module(luaState)[class_("ClientID") + .def(constructor<>()) + .def("value", &ClientID::value) + .def("set", &ClientID::set) + .def(self == other())]; }); -SCRIPT_EXPORT(NET_Packet, (), -{ - module(luaState) - [ - def("script_server_object_version", &script_server_object_version), - class_("net_packet") - .def( constructor<>() ) - .def("w_begin", &NET_Packet::w_begin ) -// .def("w", &NET_Packet::w ) -// .def("w_seek", &NET_Packet::w_seek ) - .def("w_tell", &NET_Packet::w_tell ) - .def("w_vec3", &NET_Packet::w_vec3 ) - .def("w_float", &NET_Packet::w_float ) - .def("w_u64", &NET_Packet::w_u64 ) - .def("w_s64", &NET_Packet::w_s64 ) - .def("w_u32", &NET_Packet::w_u32 ) - .def("w_s32", &NET_Packet::w_s32 ) - .def("w_u16", &NET_Packet::w_u16 ) - .def("w_s16", &NET_Packet::w_s16 ) - .def("w_u8", &NET_Packet::w_u8 ) -// .def("w_s8", &NET_Packet::w_s8 ) - .def("w_bool", &w_bool ) - .def("w_float_q16", &NET_Packet::w_float_q16 ) - .def("w_float_q8", &NET_Packet::w_float_q8 ) - .def("w_angle16", &NET_Packet::w_angle16 ) - .def("w_angle8", &NET_Packet::w_angle8 ) - .def("w_dir", &NET_Packet::w_dir ) - .def("w_sdir", &NET_Packet::w_sdir ) - .def("w_stringZ", (void (NET_Packet::*)(LPCSTR))(&NET_Packet::w_stringZ )) - .def("w_matrix", &NET_Packet::w_matrix ) - .def("w_clientID", &NET_Packet::w_clientID ) - .def("w_chunk_open8", &NET_Packet::w_chunk_open8, out_value<2>()) - .def("w_chunk_close8", &NET_Packet::w_chunk_close8 ) - .def("w_chunk_open16", &NET_Packet::w_chunk_open16, out_value<2>()) - .def("w_chunk_close16", &NET_Packet::w_chunk_close16) - .def("r_begin", &NET_Packet::r_begin, out_value<2>()) -// .def("r", &NET_Packet::r ) - .def("r_seek", &NET_Packet::r_seek ) - .def("r_tell", &NET_Packet::r_tell ) +SCRIPT_EXPORT(NET_Packet, (), { + module(luaState)[def("script_server_object_version", &script_server_object_version), + class_("net_packet") + .def(constructor<>()) + .def("w_begin", &NET_Packet::w_begin) + // .def("w", &NET_Packet::w ) + // .def("w_seek", &NET_Packet::w_seek ) + .def("w_tell", &NET_Packet::w_tell) + .def("w_vec3", &NET_Packet::w_vec3) + .def("w_float", &NET_Packet::w_float) + .def("w_u64", &NET_Packet::w_u64) + .def("w_s64", &NET_Packet::w_s64) + .def("w_u32", &NET_Packet::w_u32) + .def("w_s32", &NET_Packet::w_s32) + .def("w_u16", &NET_Packet::w_u16) + .def("w_s16", &NET_Packet::w_s16) + .def("w_u8", &NET_Packet::w_u8) + // .def("w_s8", &NET_Packet::w_s8 ) + .def("w_bool", &w_bool) + .def("w_float_q16", &NET_Packet::w_float_q16) + .def("w_float_q8", &NET_Packet::w_float_q8) + .def("w_angle16", &NET_Packet::w_angle16) + .def("w_angle8", &NET_Packet::w_angle8) + .def("w_dir", &NET_Packet::w_dir) + .def("w_sdir", &NET_Packet::w_sdir) + .def("w_stringZ", (void (NET_Packet::*)(LPCSTR))(&NET_Packet::w_stringZ)) + .def("w_matrix", &NET_Packet::w_matrix) + .def("w_clientID", &NET_Packet::w_clientID) + .def("w_chunk_open8", &NET_Packet::w_chunk_open8, out_value<2>()) + .def("w_chunk_close8", &NET_Packet::w_chunk_close8) + .def("w_chunk_open16", &NET_Packet::w_chunk_open16, out_value<2>()) + .def("w_chunk_close16", &NET_Packet::w_chunk_close16) + .def("r_begin", &NET_Packet::r_begin, out_value<2>()) + // .def("r", &NET_Packet::r ) + .def("r_seek", &NET_Packet::r_seek) + .def("r_tell", &NET_Packet::r_tell) // XXX: used as r_vec3(vec) -- remove pure_out_value? - .def("r_vec3", (void (NET_Packet::*)(Fvector&))(&NET_Packet::r_vec3), pure_out_value<2>()) - .def("r_bool", &r_bool ) - .def("r_float", (float (NET_Packet::*)() )(&NET_Packet::r_float )) - .def("r_u64", (u64 (NET_Packet::*)() )(&NET_Packet::r_u64 )) - .def("r_s64", (s64 (NET_Packet::*)() )(&NET_Packet::r_s64 )) - .def("r_u32", (u32 (NET_Packet::*)() )(&NET_Packet::r_u32 )) - .def("r_s32", (s32 (NET_Packet::*)() )(&NET_Packet::r_s32 )) - .def("r_u16", (u16 (NET_Packet::*)() )(&NET_Packet::r_u16 )) - .def("r_s16", (s16 (NET_Packet::*)() )(&NET_Packet::r_s16 )) - .def("r_u8", (u8 (NET_Packet::*)() )(&NET_Packet::r_u8 )) - .def("r_s8", (s8 (NET_Packet::*)() )(&NET_Packet::r_s8 )) + .def("r_vec3", (void (NET_Packet::*)(Fvector&))(&NET_Packet::r_vec3), pure_out_value<2>()) + .def("r_bool", &r_bool) + .def("r_float", (float (NET_Packet::*)())(&NET_Packet::r_float)) + .def("r_u64", (u64(NET_Packet::*)())(&NET_Packet::r_u64)) + .def("r_s64", (s64(NET_Packet::*)())(&NET_Packet::r_s64)) + .def("r_u32", (u32(NET_Packet::*)())(&NET_Packet::r_u32)) + .def("r_s32", (s32(NET_Packet::*)())(&NET_Packet::r_s32)) + .def("r_u16", (u16(NET_Packet::*)())(&NET_Packet::r_u16)) + .def("r_s16", (s16(NET_Packet::*)())(&NET_Packet::r_s16)) + .def("r_u8", (u8(NET_Packet::*)())(&NET_Packet::r_u8)) + .def("r_s8", (s8(NET_Packet::*)())(&NET_Packet::r_s8)) // XXX: should use pure_out_value here - .def("r_angle16", &NET_Packet::r_angle16, out_value<2>()) - .def("r_angle8", &NET_Packet::r_angle8, out_value<2>()) - .def("r_dir", &NET_Packet::r_dir ) - .def("r_sdir", &NET_Packet::r_sdir ) - .def("r_stringZ", &r_stringZ) - .def("r_matrix", &NET_Packet::r_matrix ) - .def("r_clientID", &r_clientID ) - .def("r_elapsed", &NET_Packet::r_elapsed ) - .def("r_advance", &NET_Packet::r_advance ) - .def("r_eof", &r_eof ) - ]; + .def("r_angle16", &NET_Packet::r_angle16, out_value<2>()) + .def("r_angle8", &NET_Packet::r_angle8, out_value<2>()) + .def("r_dir", &NET_Packet::r_dir) + .def("r_sdir", &NET_Packet::r_sdir) + .def("r_stringZ", &r_stringZ) + .def("r_matrix", &NET_Packet::r_matrix) + .def("r_clientID", &r_clientID) + .def("r_elapsed", &NET_Packet::r_elapsed) + .def("r_advance", &NET_Packet::r_advance) + .def("r_eof", &r_eof)]; }); diff --git a/src/xrServerEntities/script_reader_script.cpp b/src/xrServerEntities/script_reader_script.cpp index a6df02e9b26..c0439838163 100644 --- a/src/xrServerEntities/script_reader_script.cpp +++ b/src/xrServerEntities/script_reader_script.cpp @@ -11,55 +11,51 @@ using namespace luabind; -bool r_eof(IReader *self) +bool r_eof(IReader* self) { - return (!!self->eof()); + return (!!self->eof()); } -LPCSTR r_stringZ(IReader *self) +LPCSTR r_stringZ(IReader* self) { - shared_str temp; - self->r_stringZ (temp); - return (*temp); + shared_str temp; + self->r_stringZ(temp); + return (*temp); } -bool r_bool(IReader *self) +bool r_bool(IReader* self) { - return (!!self->r_u8()); + return (!!self->r_u8()); } -void r_fvector3(IReader *self, Fvector *arg0) +void r_fvector3(IReader* self, Fvector* arg0) { - self->r_fvector3(*arg0); + self->r_fvector3(*arg0); } -SCRIPT_EXPORT(IReader, (), -{ - module(luaState) - [ - class_("reader") - .def("r_seek", &IReader::seek ) - .def("r_tell", &IReader::tell ) - .def("r_vec3", &::r_fvector3 ) - .def("r_bool", &::r_bool ) - .def("r_float", &IReader::r_float ) - .def("r_u64", &IReader::r_u64) - .def("r_s64", &IReader::r_s64) - .def("r_u32", &IReader::r_u32) - .def("r_s32", &IReader::r_s32) - .def("r_u16", &IReader::r_u16) - .def("r_s16", &IReader::r_s16) - .def("r_u8", &IReader::r_u8 ) - .def("r_s8", &IReader::r_s8 ) - .def("r_float_q16", &IReader::r_float_q16 ) - .def("r_float_q8", &IReader::r_float_q8 ) - .def("r_angle16", &IReader::r_angle16 ) - .def("r_angle8", &IReader::r_angle8 ) - .def("r_dir", &IReader::r_dir ) - .def("r_sdir", &IReader::r_sdir ) - .def("r_stringZ", &r_stringZ ) - .def("r_elapsed", &IReader::elapsed ) - .def("r_advance", &IReader::advance ) - .def("r_eof", &r_eof ) - ]; +SCRIPT_EXPORT(IReader, (), { + module(luaState)[class_( + "reader").def("r_seek", &IReader::seek) + .def("r_tell", &IReader::tell) + .def("r_vec3", &::r_fvector3) + .def("r_bool", &::r_bool) + .def("r_float", &IReader::r_float) + .def("r_u64", &IReader::r_u64) + .def("r_s64", &IReader::r_s64) + .def("r_u32", &IReader::r_u32) + .def("r_s32", &IReader::r_s32) + .def("r_u16", &IReader::r_u16) + .def("r_s16", &IReader::r_s16) + .def("r_u8", &IReader::r_u8) + .def("r_s8", &IReader::r_s8) + .def("r_float_q16", &IReader::r_float_q16) + .def("r_float_q8", &IReader::r_float_q8) + .def("r_angle16", &IReader::r_angle16) + .def("r_angle8", &IReader::r_angle8) + .def("r_dir", &IReader::r_dir) + .def("r_sdir", &IReader::r_sdir) + .def("r_stringZ", &r_stringZ) + .def("r_elapsed", &IReader::elapsed) + .def("r_advance", &IReader::advance) + .def("r_eof", &r_eof)]; }); diff --git a/src/xrServerEntities/script_rtoken_list.h b/src/xrServerEntities/script_rtoken_list.h index 35f8a92e5da..b8f37318d51 100644 --- a/src/xrServerEntities/script_rtoken_list.h +++ b/src/xrServerEntities/script_rtoken_list.h @@ -8,19 +8,21 @@ #pragma once -class CScriptRTokenList { +class CScriptRTokenList +{ public: - typedef xr_vector RTOKEN_LIST; + typedef xr_vector RTOKEN_LIST; + protected: - RTOKEN_LIST m_values; + RTOKEN_LIST m_values; public: - IC void add (LPCSTR value); - IC void remove (u32 index); - IC LPCSTR get (u32 index); - IC u32 size (); - IC void clear (); - IC RTOKEN_LIST &tokens (); + IC void add(LPCSTR value); + IC void remove(u32 index); + IC LPCSTR get(u32 index); + IC u32 size(); + IC void clear(); + IC RTOKEN_LIST& tokens(); }; #include "script_rtoken_list_inline.h" \ No newline at end of file diff --git a/src/xrServerEntities/script_rtoken_list_inline.h b/src/xrServerEntities/script_rtoken_list_inline.h index d58a3997b04..e18aacb5674 100644 --- a/src/xrServerEntities/script_rtoken_list_inline.h +++ b/src/xrServerEntities/script_rtoken_list_inline.h @@ -8,36 +8,34 @@ #pragma once -IC void CScriptRTokenList::add (LPCSTR value) +IC void CScriptRTokenList::add(LPCSTR value) { - m_values.push_back(shared_str(value)); + m_values.push_back(shared_str(value)); } -IC void CScriptRTokenList::remove (u32 index) +IC void CScriptRTokenList::remove(u32 index) { - if (index >= size()) - return; - m_values.erase (m_values.begin() + index); + if (index >= size()) return; + m_values.erase(m_values.begin() + index); } -IC LPCSTR CScriptRTokenList::get (u32 index) +IC LPCSTR CScriptRTokenList::get(u32 index) { - if (index >= size()) - return (0); - return (*m_values[index]); + if (index >= size()) return (0); + return (*m_values[index]); } -IC u32 CScriptRTokenList::size () +IC u32 CScriptRTokenList::size() { - return (u32(m_values.size())); + return (u32(m_values.size())); } -IC void CScriptRTokenList::clear () +IC void CScriptRTokenList::clear() { - m_values.clear (); + m_values.clear(); } -IC CScriptRTokenList::RTOKEN_LIST &CScriptRTokenList::tokens () +IC CScriptRTokenList::RTOKEN_LIST& CScriptRTokenList::tokens() { - return (m_values); + return (m_values); } diff --git a/src/xrServerEntities/script_rtoken_list_script.cpp b/src/xrServerEntities/script_rtoken_list_script.cpp index eec5bb12d4f..aa5a52ebf80 100644 --- a/src/xrServerEntities/script_rtoken_list_script.cpp +++ b/src/xrServerEntities/script_rtoken_list_script.cpp @@ -12,16 +12,12 @@ using namespace luabind; -SCRIPT_EXPORT(CScriptRTokenList, (), -{ - module(luaState) - [ - class_("rtoken_list") - .def( constructor<>()) - .def("add", &CScriptRTokenList::add) - .def("remove", &CScriptRTokenList::remove) - .def("clear", &CScriptRTokenList::clear) - .def("count", &CScriptRTokenList::size) - .def("get", &CScriptRTokenList::get) - ]; +SCRIPT_EXPORT(CScriptRTokenList, (), { + module(luaState)[class_("rtoken_list") + .def(constructor<>()) + .def("add", &CScriptRTokenList::add) + .def("remove", &CScriptRTokenList::remove) + .def("clear", &CScriptRTokenList::clear) + .def("count", &CScriptRTokenList::size) + .def("get", &CScriptRTokenList::get)]; }); diff --git a/src/xrServerEntities/script_sound_type_script.cpp b/src/xrServerEntities/script_sound_type_script.cpp index da055a1a1c5..f52a49b76d6 100644 --- a/src/xrServerEntities/script_sound_type_script.cpp +++ b/src/xrServerEntities/script_sound_type_script.cpp @@ -6,66 +6,48 @@ // Description : Script sound type script export //////////////////////////////////////////////////////////////////////////// -#include "pch_script.h" #include "ai_sounds.h" +#include "pch_script.h" #include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -SCRIPT_EXPORT(CScriptSoundType, (), -{ - class CScriptSoundType {}; +SCRIPT_EXPORT(CScriptSoundType, (), { + class CScriptSoundType + { + }; module(luaState) - [ - class_("snd_type") - .enum_("sound_types") - [ - value("no_sound", int(SOUND_TYPE_NO_SOUND )), - value("weapon", int(SOUND_TYPE_WEAPON )), - value("item", int(SOUND_TYPE_ITEM )), - value("monster", int(SOUND_TYPE_MONSTER )), - value("anomaly", int(SOUND_TYPE_ANOMALY )), - value("world", int(SOUND_TYPE_WORLD )), - value("pick_up", int(SOUND_TYPE_PICKING_UP )), - value("drop", int(SOUND_TYPE_DROPPING )), - value("hide", int(SOUND_TYPE_HIDING )), - value("take", int(SOUND_TYPE_TAKING )), - value("use", int(SOUND_TYPE_USING )), - value("shoot", int(SOUND_TYPE_SHOOTING )), - value("empty", int(SOUND_TYPE_EMPTY_CLICKING )), - value("bullet_hit", int(SOUND_TYPE_BULLET_HIT )), - value("reload", int(SOUND_TYPE_RECHARGING )), - value("die", int(SOUND_TYPE_DYING )), - value("injure", int(SOUND_TYPE_INJURING )), - value("step", int(SOUND_TYPE_STEP )), - value("talk", int(SOUND_TYPE_TALKING )), - value("attack", int(SOUND_TYPE_ATTACKING )), - value("eat", int(SOUND_TYPE_EATING )), - value("idle", int(SOUND_TYPE_IDLE )), - value("object_break", int(SOUND_TYPE_OBJECT_BREAKING )), - value("object_collide", int(SOUND_TYPE_OBJECT_COLLIDING )), - value("object_explode", int(SOUND_TYPE_OBJECT_EXPLODING )), - value("ambient", int(SOUND_TYPE_AMBIENT )), - value("item_pick_up", int(SOUND_TYPE_ITEM_PICKING_UP )), - value("item_drop", int(SOUND_TYPE_ITEM_DROPPING )), - value("item_hide", int(SOUND_TYPE_ITEM_HIDING )), - value("item_take", int(SOUND_TYPE_ITEM_TAKING )), - value("item_use", int(SOUND_TYPE_ITEM_USING )), - value("weapon_shoot", int(SOUND_TYPE_WEAPON_SHOOTING )), - value("weapon_empty", int(SOUND_TYPE_WEAPON_EMPTY_CLICKING )), - value("weapon_bullet_hit", int(SOUND_TYPE_WEAPON_BULLET_HIT )), - value("weapon_reload", int(SOUND_TYPE_WEAPON_RECHARGING )), - value("monster_die", int(SOUND_TYPE_MONSTER_DYING )), - value("monster_injure", int(SOUND_TYPE_MONSTER_INJURING )), - value("monster_step", int(SOUND_TYPE_MONSTER_STEP )), - value("monster_talk", int(SOUND_TYPE_MONSTER_TALKING )), - value("monster_attack", int(SOUND_TYPE_MONSTER_ATTACKING )), - value("monster_eat", int(SOUND_TYPE_MONSTER_EATING )), - value("anomaly_idle", int(SOUND_TYPE_ANOMALY_IDLE )), - value("world_object_break", int(SOUND_TYPE_WORLD_OBJECT_BREAKING )), - value("world_object_collide", int(SOUND_TYPE_WORLD_OBJECT_COLLIDING )), - value("world_object_explode", int(SOUND_TYPE_WORLD_OBJECT_EXPLODING )), - value("world_ambient", int(SOUND_TYPE_WORLD_AMBIENT )) - ] - ]; + [class_("snd_type") + .enum_("sound_types")[value("no_sound", int(SOUND_TYPE_NO_SOUND)), + value("weapon", int(SOUND_TYPE_WEAPON)), value("item", int(SOUND_TYPE_ITEM)), + value("monster", int(SOUND_TYPE_MONSTER)), value("anomaly", int(SOUND_TYPE_ANOMALY)), + value("world", int(SOUND_TYPE_WORLD)), value("pick_up", int(SOUND_TYPE_PICKING_UP)), + value("drop", int(SOUND_TYPE_DROPPING)), value("hide", int(SOUND_TYPE_HIDING)), + value("take", int(SOUND_TYPE_TAKING)), value("use", int(SOUND_TYPE_USING)), + value("shoot", int(SOUND_TYPE_SHOOTING)), value("empty", int(SOUND_TYPE_EMPTY_CLICKING)), + value("bullet_hit", int(SOUND_TYPE_BULLET_HIT)), value("reload", int(SOUND_TYPE_RECHARGING)), + value("die", int(SOUND_TYPE_DYING)), value("injure", int(SOUND_TYPE_INJURING)), + value("step", int(SOUND_TYPE_STEP)), value("talk", int(SOUND_TYPE_TALKING)), + value("attack", int(SOUND_TYPE_ATTACKING)), value("eat", int(SOUND_TYPE_EATING)), + value("idle", int(SOUND_TYPE_IDLE)), value("object_break", int(SOUND_TYPE_OBJECT_BREAKING)), + value("object_collide", int(SOUND_TYPE_OBJECT_COLLIDING)), + value("object_explode", int(SOUND_TYPE_OBJECT_EXPLODING)), + value("ambient", int(SOUND_TYPE_AMBIENT)), value("item_pick_up", int(SOUND_TYPE_ITEM_PICKING_UP)), + value("item_drop", int(SOUND_TYPE_ITEM_DROPPING)), value("item_hide", int(SOUND_TYPE_ITEM_HIDING)), + value("item_take", int(SOUND_TYPE_ITEM_TAKING)), value("item_use", int(SOUND_TYPE_ITEM_USING)), + value("weapon_shoot", int(SOUND_TYPE_WEAPON_SHOOTING)), + value("weapon_empty", int(SOUND_TYPE_WEAPON_EMPTY_CLICKING)), + value("weapon_bullet_hit", int(SOUND_TYPE_WEAPON_BULLET_HIT)), + value("weapon_reload", int(SOUND_TYPE_WEAPON_RECHARGING)), + value("monster_die", int(SOUND_TYPE_MONSTER_DYING)), + value("monster_injure", int(SOUND_TYPE_MONSTER_INJURING)), + value("monster_step", int(SOUND_TYPE_MONSTER_STEP)), + value("monster_talk", int(SOUND_TYPE_MONSTER_TALKING)), + value("monster_attack", int(SOUND_TYPE_MONSTER_ATTACKING)), + value("monster_eat", int(SOUND_TYPE_MONSTER_EATING)), + value("anomaly_idle", int(SOUND_TYPE_ANOMALY_IDLE)), + value("world_object_break", int(SOUND_TYPE_WORLD_OBJECT_BREAKING)), + value("world_object_collide", int(SOUND_TYPE_WORLD_OBJECT_COLLIDING)), + value("world_object_explode", int(SOUND_TYPE_WORLD_OBJECT_EXPLODING)), + value("world_ambient", int(SOUND_TYPE_WORLD_AMBIENT))]]; }); diff --git a/src/xrServerEntities/script_token_list.cpp b/src/xrServerEntities/script_token_list.cpp index 52c6fbacaaf..47d626f30c9 100644 --- a/src/xrServerEntities/script_token_list.cpp +++ b/src/xrServerEntities/script_token_list.cpp @@ -6,13 +6,13 @@ // Description : Script token list class //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" #include "script_token_list.h" +#include "stdafx.h" -CScriptTokenList::~CScriptTokenList () +CScriptTokenList::~CScriptTokenList() { - iterator I = tokens().begin(); - iterator E = tokens().end(); - for ( ; I != E; ++I) - xr_free ((*I).name); + iterator I = tokens().begin(); + iterator E = tokens().end(); + for (; I != E; ++I) + xr_free((*I).name); } diff --git a/src/xrServerEntities/script_token_list.h b/src/xrServerEntities/script_token_list.h index dc7eb8c37c3..4cd2175f7f7 100644 --- a/src/xrServerEntities/script_token_list.h +++ b/src/xrServerEntities/script_token_list.h @@ -8,58 +8,47 @@ #pragma once -class CScriptTokenList { +class CScriptTokenList +{ protected: - typedef xr_vector TOKEN_LIST; - typedef TOKEN_LIST::iterator iterator; - typedef TOKEN_LIST::const_iterator const_iterator; + typedef xr_vector TOKEN_LIST; + typedef TOKEN_LIST::iterator iterator; + typedef TOKEN_LIST::const_iterator const_iterator; protected: - struct CTokenPredicateName { - LPCSTR m_name; + struct CTokenPredicateName + { + LPCSTR m_name; - IC CTokenPredicateName (LPCSTR name) - { - m_name = name; - } + IC CTokenPredicateName(LPCSTR name) { m_name = name; } + IC bool operator()(const xr_token& token) const { return (token.name && !xr_strcmp(token.name, m_name)); } + }; - IC bool operator() (const xr_token &token) const - { - return (token.name && !xr_strcmp(token.name,m_name)); - } - }; - - struct CTokenPredicateID { - int m_id; + struct CTokenPredicateID + { + int m_id; - IC CTokenPredicateID (int id) - { - m_id = id; - } - - IC bool operator() (const xr_token &token) const - { - return (token.name && (token.id == m_id)); - } - }; + IC CTokenPredicateID(int id) { m_id = id; } + IC bool operator()(const xr_token& token) const { return (token.name && (token.id == m_id)); } + }; protected: - TOKEN_LIST m_token_list; + TOKEN_LIST m_token_list; protected: - IC iterator token (LPCSTR name); - IC iterator token (int id); + IC iterator token(LPCSTR name); + IC iterator token(int id); public: - IC CScriptTokenList (); - ~CScriptTokenList (); - IC void add (LPCSTR name, int id); - IC void remove (LPCSTR name); - IC void clear (); - IC int id (LPCSTR name); - IC LPCSTR name (int id); - IC const TOKEN_LIST &tokens () const; - IC TOKEN_LIST &tokens (); + IC CScriptTokenList(); + ~CScriptTokenList(); + IC void add(LPCSTR name, int id); + IC void remove(LPCSTR name); + IC void clear(); + IC int id(LPCSTR name); + IC LPCSTR name(int id); + IC const TOKEN_LIST& tokens() const; + IC TOKEN_LIST& tokens(); }; #include "script_token_list_inline.h" diff --git a/src/xrServerEntities/script_token_list_inline.h b/src/xrServerEntities/script_token_list_inline.h index 9be438ccafc..9c52e2faa56 100644 --- a/src/xrServerEntities/script_token_list_inline.h +++ b/src/xrServerEntities/script_token_list_inline.h @@ -8,70 +8,69 @@ #pragma once - -IC CScriptTokenList::CScriptTokenList () +IC CScriptTokenList::CScriptTokenList() { - clear (); + clear(); } -IC void CScriptTokenList::add (LPCSTR name, int id) +IC void CScriptTokenList::add(LPCSTR name, int id) { - VERIFY ((token(name) == m_token_list.end()) && (token(id) == m_token_list.end())); - xr_token temp; - //! memory leak is here - temp.name = xr_strdup(name); - temp.id = id; - m_token_list.pop_back (); - m_token_list.push_back (temp); - ZeroMemory (&temp,sizeof(temp)); - m_token_list.push_back (temp); + VERIFY((token(name) == m_token_list.end()) && (token(id) == m_token_list.end())); + xr_token temp; + //! memory leak is here + temp.name = xr_strdup(name); + temp.id = id; + m_token_list.pop_back(); + m_token_list.push_back(temp); + ZeroMemory(&temp, sizeof(temp)); + m_token_list.push_back(temp); } -IC void CScriptTokenList::remove (LPCSTR name) +IC void CScriptTokenList::remove(LPCSTR name) { - iterator I = token(name); - VERIFY (I != m_token_list.end()); - m_token_list.erase (I); + iterator I = token(name); + VERIFY(I != m_token_list.end()); + m_token_list.erase(I); } -IC void CScriptTokenList::clear () +IC void CScriptTokenList::clear() { - m_token_list.clear (); - xr_token temp; - ZeroMemory (&temp,sizeof(temp)); - m_token_list.push_back (temp); + m_token_list.clear(); + xr_token temp; + ZeroMemory(&temp, sizeof(temp)); + m_token_list.push_back(temp); } -IC int CScriptTokenList::id (LPCSTR name) +IC int CScriptTokenList::id(LPCSTR name) { - iterator I = token(name); - VERIFY (I != m_token_list.end()); - return ((*I).id); + iterator I = token(name); + VERIFY(I != m_token_list.end()); + return ((*I).id); } -IC LPCSTR CScriptTokenList::name (int id) +IC LPCSTR CScriptTokenList::name(int id) { - iterator I = token(id); - VERIFY (I != m_token_list.end()); - return ((*I).name); + iterator I = token(id); + VERIFY(I != m_token_list.end()); + return ((*I).name); } -IC CScriptTokenList::iterator CScriptTokenList::token (LPCSTR name) +IC CScriptTokenList::iterator CScriptTokenList::token(LPCSTR name) { - return (std::find_if(m_token_list.begin(),m_token_list.end(),CTokenPredicateName(name))); + return (std::find_if(m_token_list.begin(), m_token_list.end(), CTokenPredicateName(name))); } -IC CScriptTokenList::iterator CScriptTokenList::token (int id) +IC CScriptTokenList::iterator CScriptTokenList::token(int id) { - return (std::find_if(m_token_list.begin(),m_token_list.end(),CTokenPredicateID(id))); + return (std::find_if(m_token_list.begin(), m_token_list.end(), CTokenPredicateID(id))); } -IC const CScriptTokenList::TOKEN_LIST &CScriptTokenList::tokens() const +IC const CScriptTokenList::TOKEN_LIST& CScriptTokenList::tokens() const { - return (m_token_list); + return (m_token_list); } -IC CScriptTokenList::TOKEN_LIST &CScriptTokenList::tokens() +IC CScriptTokenList::TOKEN_LIST& CScriptTokenList::tokens() { - return (m_token_list); + return (m_token_list); } diff --git a/src/xrServerEntities/script_token_list_script.cpp b/src/xrServerEntities/script_token_list_script.cpp index 8556e515b06..200fa238d49 100644 --- a/src/xrServerEntities/script_token_list_script.cpp +++ b/src/xrServerEntities/script_token_list_script.cpp @@ -12,21 +12,17 @@ using namespace luabind; -SCRIPT_EXPORT(CScriptTokenList, (), -{ - module(luaState) - [ - class_("token") - .def( constructor<>()) - .def_readwrite("name", &xr_token::name) - .def_readwrite("id", &xr_token::id), +SCRIPT_EXPORT(CScriptTokenList, (), { + module(luaState)[class_("token") + .def(constructor<>()) + .def_readwrite("name", &xr_token::name) + .def_readwrite("id", &xr_token::id), - class_("token_list") - .def( constructor<>()) - .def("add", &CScriptTokenList::add) - .def("remove", &CScriptTokenList::remove) - .def("clear", &CScriptTokenList::clear) - .def("id", &CScriptTokenList::id) - .def("name", &CScriptTokenList::name) - ]; + class_("token_list") + .def(constructor<>()) + .def("add", &CScriptTokenList::add) + .def("remove", &CScriptTokenList::remove) + .def("clear", &CScriptTokenList::clear) + .def("id", &CScriptTokenList::id) + .def("name", &CScriptTokenList::name)]; }); diff --git a/src/xrServerEntities/script_value_container.h b/src/xrServerEntities/script_value_container.h index 3f23fde687b..f8c8bb1e8ff 100644 --- a/src/xrServerEntities/script_value_container.h +++ b/src/xrServerEntities/script_value_container.h @@ -9,18 +9,23 @@ #pragma once #ifdef XRSE_FACTORY_EXPORTS - class CScriptValue; +class CScriptValue; #else - class CScriptValue {public: virtual ~CScriptValue(){}}; +class CScriptValue +{ +public: + virtual ~CScriptValue() {} +}; #endif -class CScriptValueContainer { +class CScriptValueContainer +{ protected: - xr_vector m_values; + xr_vector m_values; public: - virtual ~CScriptValueContainer (); - IC void assign (); - IC void clear (); - IC void add (CScriptValue *value); + virtual ~CScriptValueContainer(); + IC void assign(); + IC void clear(); + IC void add(CScriptValue* value); }; diff --git a/src/xrServerEntities/script_value_container_impl.h b/src/xrServerEntities/script_value_container_impl.h index 13d1dffe391..28e0cc719fc 100644 --- a/src/xrServerEntities/script_value_container_impl.h +++ b/src/xrServerEntities/script_value_container_impl.h @@ -10,44 +10,43 @@ #include "Common/object_broker.h" #ifdef XRSE_FACTORY_EXPORTS -# include "script_value.h" +#include "script_value.h" #endif -IC CScriptValueContainer::~CScriptValueContainer () +IC CScriptValueContainer::~CScriptValueContainer() { - clear (); + clear(); } -IC void CScriptValueContainer::add (CScriptValue *new_value) +IC void CScriptValueContainer::add(CScriptValue* new_value) { #ifdef XRSE_FACTORY_EXPORTS - CScriptValue *value = 0; - xr_vector::const_iterator I = m_values.begin(); - xr_vector::const_iterator E = m_values.end(); - for ( ; I != E; ++I) - if (!xr_strcmp((*I)->name(),new_value->name())) { - value = *I; - break; - } - - if (value) - return; - - m_values.push_back (new_value); + CScriptValue* value = 0; + xr_vector::const_iterator I = m_values.begin(); + xr_vector::const_iterator E = m_values.end(); + for (; I != E; ++I) + if (!xr_strcmp((*I)->name(), new_value->name())) { + value = *I; + break; + } + + if (value) return; + + m_values.push_back(new_value); #endif } -IC void CScriptValueContainer::assign () +IC void CScriptValueContainer::assign() { #ifdef XRSE_FACTORY_EXPORTS - xr_vector::iterator I = m_values.begin(); - xr_vector::iterator E = m_values.end(); - for ( ; I != E; ++I) - (*I)->assign (); + xr_vector::iterator I = m_values.begin(); + xr_vector::iterator E = m_values.end(); + for (; I != E; ++I) + (*I)->assign(); #endif } -IC void CScriptValueContainer::clear () +IC void CScriptValueContainer::clear() { - delete_data (m_values); + delete_data(m_values); } diff --git a/src/xrServerEntities/shared_data.h b/src/xrServerEntities/shared_data.h index 1eb06dd1549..f79bff76bac 100644 --- a/src/xrServerEntities/shared_data.h +++ b/src/xrServerEntities/shared_data.h @@ -1,144 +1,158 @@ #pragma once -// Singleton template definition -template class CSingleton { +// Singleton template definition +template +class CSingleton +{ private: - static T* _self; - static int _refcount; -public: - //whether singleton will delete itself on FreeInst - //when _refcount = 0 - //otherwise user should call DestroySingleton() manually - static bool _on_self_delete; + static T* _self; + static int _refcount; + public: - CSingleton () {} - virtual ~CSingleton () {_self=NULL;} - - static void DestroySingleton () { - if(!_self) return; - Log ("DestroySingleton::RefCounter:",_refcount); - VERIFY(_on_self_delete == false); - VERIFY(_refcount == 0); - xr_delete(_self); - }; + // whether singleton will delete itself on FreeInst + // when _refcount = 0 + // otherwise user should call DestroySingleton() manually + static bool _on_self_delete; + public: - static T* Instance () { - if(!_self) _self=new T(); - ++_refcount; - return _self; - } - void FreeInst () { - if(0 == --_refcount) { - if(_on_self_delete){ - CSingleton *ptr = this; - xr_delete(ptr); - } - } - } -}; + CSingleton() {} + virtual ~CSingleton() { _self = NULL; } + static void DestroySingleton() + { + if (!_self) return; + Log("DestroySingleton::RefCounter:", _refcount); + VERIFY(_on_self_delete == false); + VERIFY(_refcount == 0); + xr_delete(_self); + }; -template T* CSingleton::_self = NULL; -template int CSingleton::_refcount = 0; -template bool CSingleton::_on_self_delete = true; +public: + static T* Instance() + { + if (!_self) _self = new T(); + ++_refcount; + return _self; + } + void FreeInst() + { + if (0 == --_refcount) { + if (_on_self_delete) { + CSingleton* ptr = this; + xr_delete(ptr); + } + } + } +}; +template +T* CSingleton::_self = NULL; +template +int CSingleton::_refcount = 0; +template +bool CSingleton::_on_self_delete = true; -template class CSharedObj : public CSingleton > +template +class CSharedObj : public CSingleton> { - xr_map _shared_tab; - typedef typename xr_map::iterator SHARED_DATA_MAP_IT; + xr_map _shared_tab; + typedef typename xr_map::iterator SHARED_DATA_MAP_IT; public: - CSharedObj () {}; - virtual ~CSharedObj () { - for (SHARED_DATA_MAP_IT it = _shared_tab.begin(); it != _shared_tab.end(); ++it){ - xr_delete(it->second); - } - } - - // Access to data - SHARED_TYPE *get_shared (KEY_TYPE id) { - SHARED_DATA_MAP_IT shared_it = _shared_tab.find(id); - - SHARED_TYPE *_data; - - // if not found - create appropriate shared data object - if (_shared_tab.end() == shared_it) { - _data = new SHARED_TYPE(); - _shared_tab.insert(mk_pair(id, _data)); - } else _data = shared_it->second; - - return _data; - } + CSharedObj(){}; + virtual ~CSharedObj() + { + for (SHARED_DATA_MAP_IT it = _shared_tab.begin(); it != _shared_tab.end(); ++it) + { + xr_delete(it->second); + } + } + + // Access to data + SHARED_TYPE* get_shared(KEY_TYPE id) + { + SHARED_DATA_MAP_IT shared_it = _shared_tab.find(id); + + SHARED_TYPE* _data; + + // if not found - create appropriate shared data object + if (_shared_tab.end() == shared_it) { + _data = new SHARED_TYPE(); + _shared_tab.insert(mk_pair(id, _data)); + } + else + _data = shared_it->second; + + return _data; + } }; -class CSharedResource { - bool loaded; -public: - CSharedResource () {loaded = false;} +class CSharedResource +{ + bool loaded; - bool IsLoaded () {return loaded;} - void SetLoad (bool l = true) {loaded = l;} +public: + CSharedResource() { loaded = false; } + bool IsLoaded() { return loaded; } + void SetLoad(bool l = true) { loaded = l; } }; +template +class CSharedClass +{ + SHARED_TYPE* _sd; + CSharedObj* pSharedObj; -template class CSharedClass { - SHARED_TYPE *_sd; - CSharedObj *pSharedObj; public: - CSharedClass ():_sd(NULL) {pSharedObj = CSharedObj::Instance(); pSharedObj->_on_self_delete = auto_delete;} - virtual ~CSharedClass () {pSharedObj->FreeInst();} - - - static void DeleteSharedData () { - CSharedObj::DestroySingleton(); - } - - void load_shared (KEY_TYPE key, LPCSTR section) { - _sd = pSharedObj->get_shared(key); - - if (!get_sd()->IsLoaded()) { - load_shared(section); - get_sd()->SetLoad(); - } - } - - virtual void load_shared (LPCSTR section) {} - - SHARED_TYPE *get_sd () {return _sd;} - const SHARED_TYPE *get_sd () const {return _sd;} - - - // óïðàâëåíèå çàãðóçêîé äàííûõ ïðè êîìïîíåíòíîì ïîäõîäå (çàãðóçêà äàííûõ âðó÷íóþ) - bool start_load_shared (KEY_TYPE key){ - _sd = pSharedObj->get_shared(key); - if (get_sd()->IsLoaded()) return false; - return true; - } - void finish_load_shared (){get_sd()->SetLoad();} - + CSharedClass() : _sd(NULL) + { + pSharedObj = CSharedObj::Instance(); + pSharedObj->_on_self_delete = auto_delete; + } + virtual ~CSharedClass() { pSharedObj->FreeInst(); } + static void DeleteSharedData() { CSharedObj::DestroySingleton(); } + void load_shared(KEY_TYPE key, LPCSTR section) + { + _sd = pSharedObj->get_shared(key); + + if (!get_sd()->IsLoaded()) { + load_shared(section); + get_sd()->SetLoad(); + } + } + + virtual void load_shared(LPCSTR section) {} + SHARED_TYPE* get_sd() { return _sd; } + const SHARED_TYPE* get_sd() const { return _sd; } + // óïðàâëåíèå çàãðóçêîé äàííûõ ïðè êîìïîíåíòíîì ïîäõîäå (çàãðóçêà äàííûõ âðó÷íóþ) + bool start_load_shared(KEY_TYPE key) + { + _sd = pSharedObj->get_shared(key); + if (get_sd()->IsLoaded()) return false; + return true; + } + void finish_load_shared() { get_sd()->SetLoad(); } }; - //----------------------------------------- // Usage //----------------------------------------- ////1. define shared class storage -//struct shared_struc : public CSharedResource { +// struct shared_struc : public CSharedResource { // u8 a; // u8 b; //}; // ////2. define custom class inherited CSharedClass -//class CClass : public CSharedClass { +// class CClass : public CSharedClass { // typedef CSharedClass inherited_shared; -// -//public: +// +// public: // // //3. call shared load on Load // virtual void Load (LPCSTR section) { // inherited_shared::load_shared(class_id(), section); // } -// +// // //4. load shared data // virtual void load_shared (LPCSTR section) { // a = pSettings->r_u8(section, "smth1"); @@ -150,4 +164,3 @@ template class CShar // Msg("shared: a = [%d] b =[%d]", inherited_shared::get_sd()->a, inherited_shared::get_sd()->b); // } //}; - diff --git a/src/xrServerEntities/smart_cast.cpp b/src/xrServerEntities/smart_cast.cpp index 6cdd27b859f..3e8edc61ea7 100644 --- a/src/xrServerEntities/smart_cast.cpp +++ b/src/xrServerEntities/smart_cast.cpp @@ -9,20 +9,20 @@ #include "stdafx.h" #ifndef PURE_DYNAMIC_CAST -# ifdef XRGAME_EXPORTS -# include "Include/xrRender/rendervisual.h" -# include "alife_space.h" -# include "hit.h" -# include "actor.h" -# include "custommonster.h" -# include "ai/stalker/ai_stalker.h" -# include "ui/uiwindow.h" -# include "customzone.h" -# include "weapon.h" -# include "cameraeffector.h" -# endif -# include "xrServer_Objects_ALife_Monsters.h" +#ifdef XRGAME_EXPORTS +#include "Include/xrRender/rendervisual.h" +#include "alife_space.h" +#include "hit.h" +#include "actor.h" +#include "custommonster.h" +#include "ai/stalker/ai_stalker.h" +#include "ui/uiwindow.h" +#include "customzone.h" +#include "weapon.h" +#include "cameraeffector.h" +#endif +#include "xrServer_Objects_ALife_Monsters.h" #endif -#undef SMART_CAST_H +#undef SMART_CAST_H #include "smart_cast.h" diff --git a/src/xrServerEntities/smart_cast.h b/src/xrServerEntities/smart_cast.h index 2aa3e4e4013..08f46cf49f0 100644 --- a/src/xrServerEntities/smart_cast.h +++ b/src/xrServerEntities/smart_cast.h @@ -10,323 +10,326 @@ #define SMART_CAST_H #ifdef DEBUG -# define PURE_DYNAMIC_CAST -#endif // DEBUG +#define PURE_DYNAMIC_CAST +#endif // DEBUG #ifdef PURE_DYNAMIC_CAST -# define smart_cast dynamic_cast +#define smart_cast dynamic_cast #else #define TL_FAST_COMPILATION #undef STATIC_CHECK -# include +#include -# define PURE_DYNAMIC_CAST_COMPATIBILITY_CHECK +#define PURE_DYNAMIC_CAST_COMPATIBILITY_CHECK -# ifdef DEBUG +#ifdef DEBUG //# define SMART_CAST_STATS_ALL -# endif - -# ifndef DECLARE_SPECIALIZATION -# include "smart_cast_impl0.h" -# else -# include "smart_cast_impl2.h" -# define DO_NOT_DECLARE_TYPE_LIST -# endif - -# ifdef XRGAME_EXPORTS - - DECLARE_SPECIALIZATION (IKinematics, IRenderVisual, dcast_PKinematics); -# undef cast_type_list -# define cast_type_list save_cast_list (IKinematics, IRenderVisual) - - DECLARE_SPECIALIZATION (IKinematicsAnimated, IRenderVisual, dcast_PKinematicsAnimated); -# undef cast_type_list -# define cast_type_list save_cast_list (IKinematicsAnimated, IRenderVisual) - - DECLARE_SPECIALIZATION (IParticleCustom, IRenderVisual, dcast_ParticleCustom); -# undef cast_type_list -# define cast_type_list save_cast_list (IParticleCustom, IRenderVisual) - - DECLARE_SPECIALIZATION (IKinematics, IKinematicsAnimated, dcast_PKinematics); -# undef cast_type_list -# define cast_type_list save_cast_list (IKinematics, IKinematicsAnimated) +#endif - DECLARE_SPECIALIZATION (IKinematicsAnimated, IKinematics, dcast_PKinematicsAnimated); -# undef cast_type_list -# define cast_type_list save_cast_list (IKinematicsAnimated, IKinematics) +#ifndef DECLARE_SPECIALIZATION +#include "smart_cast_impl0.h" +#else +#include "smart_cast_impl2.h" +#define DO_NOT_DECLARE_TYPE_LIST +#endif - DECLARE_SPECIALIZATION (IRenderVisual, IKinematicsAnimated, dcast_RenderVisual); -# undef cast_type_list -# define cast_type_list save_cast_list (IRenderVisual, IKinematicsAnimated) +#ifdef XRGAME_EXPORTS + +DECLARE_SPECIALIZATION(IKinematics, IRenderVisual, dcast_PKinematics); +#undef cast_type_list +#define cast_type_list save_cast_list(IKinematics, IRenderVisual) + +DECLARE_SPECIALIZATION(IKinematicsAnimated, IRenderVisual, dcast_PKinematicsAnimated); +#undef cast_type_list +#define cast_type_list save_cast_list(IKinematicsAnimated, IRenderVisual) + +DECLARE_SPECIALIZATION(IParticleCustom, IRenderVisual, dcast_ParticleCustom); +#undef cast_type_list +#define cast_type_list save_cast_list(IParticleCustom, IRenderVisual) + +DECLARE_SPECIALIZATION(IKinematics, IKinematicsAnimated, dcast_PKinematics); +#undef cast_type_list +#define cast_type_list save_cast_list(IKinematics, IKinematicsAnimated) + +DECLARE_SPECIALIZATION(IKinematicsAnimated, IKinematics, dcast_PKinematicsAnimated); +#undef cast_type_list +#define cast_type_list save_cast_list(IKinematicsAnimated, IKinematics) + +DECLARE_SPECIALIZATION(IRenderVisual, IKinematicsAnimated, dcast_RenderVisual); +#undef cast_type_list +#define cast_type_list save_cast_list(IRenderVisual, IKinematicsAnimated) + +DECLARE_SPECIALIZATION(IRenderVisual, IKinematics, dcast_RenderVisual); +#undef cast_type_list +#define cast_type_list save_cast_list(IRenderVisual, IKinematics) + +#ifndef DO_NOT_DECLARE_TYPE_LIST +class ENGINE_API ISpatial; +namespace Feel +{ +class ENGINE_API Sound; +} +typedef Feel::Sound Feel__Sound; +template <> +extern Feel::Sound* SmartDynamicCast::smart_cast(ISpatial* p); +add_to_cast_list(Feel__Sound, ISpatial); +#undef cast_type_list +#define cast_type_list save_cast_list(Feel__Sound, ISpatial) +#endif - DECLARE_SPECIALIZATION (IRenderVisual, IKinematics, dcast_RenderVisual); -# undef cast_type_list -# define cast_type_list save_cast_list (IRenderVisual, IKinematics) - -# ifndef DO_NOT_DECLARE_TYPE_LIST - class ENGINE_API ISpatial; - namespace Feel { class ENGINE_API Sound; } - typedef Feel::Sound Feel__Sound; - template <> extern\ - Feel::Sound* SmartDynamicCast::smart_cast(ISpatial *p);\ - add_to_cast_list(Feel__Sound,ISpatial); -# undef cast_type_list -# define cast_type_list save_cast_list (Feel__Sound, ISpatial) -# endif - - DECLARE_SPECIALIZATION (IRenderable, ISpatial, dcast_Renderable); -# undef cast_type_list -# define cast_type_list save_cast_list (IRenderable, ISpatial) +DECLARE_SPECIALIZATION(IRenderable, ISpatial, dcast_Renderable); +#undef cast_type_list +#define cast_type_list save_cast_list(IRenderable, ISpatial) - DECLARE_SPECIALIZATION (IRender_Light, ISpatial, dcast_Light); -# undef cast_type_list -# define cast_type_list save_cast_list (IRender_Light, ISpatial) +DECLARE_SPECIALIZATION(IRender_Light, ISpatial, dcast_Light); +#undef cast_type_list +#define cast_type_list save_cast_list(IRender_Light, ISpatial) - DECLARE_SPECIALIZATION (IGameObject, ISpatial, dcast_GameObject); -# undef cast_type_list -# define cast_type_list save_cast_list (IGameObject, ISpatial) +DECLARE_SPECIALIZATION(IGameObject, ISpatial, dcast_GameObject); +#undef cast_type_list +#define cast_type_list save_cast_list(IGameObject, ISpatial) -# ifndef DO_NOT_DECLARE_TYPE_LIST - class IGameObject; - class CGameObject; - add_to_cast_list (CGameObject, IGameObject); -# undef cast_type_list -# define cast_type_list save_cast_list (CGameObject, IGameObject) -# endif +#ifndef DO_NOT_DECLARE_TYPE_LIST +class IGameObject; +class CGameObject; +add_to_cast_list(CGameObject, IGameObject); +#undef cast_type_list +#define cast_type_list save_cast_list(CGameObject, IGameObject) +#endif - DECLARE_SPECIALIZATION (CEntity, CGameObject, cast_entity); -# undef cast_type_list -# define cast_type_list save_cast_list (CEntity, CGameObject) +DECLARE_SPECIALIZATION(CEntity, CGameObject, cast_entity); +#undef cast_type_list +#define cast_type_list save_cast_list(CEntity, CGameObject) - DECLARE_SPECIALIZATION (CEntityAlive, CGameObject, cast_entity_alive); -# undef cast_type_list -# define cast_type_list save_cast_list (CEntityAlive, CGameObject) +DECLARE_SPECIALIZATION(CEntityAlive, CGameObject, cast_entity_alive); +#undef cast_type_list +#define cast_type_list save_cast_list(CEntityAlive, CGameObject) - DECLARE_SPECIALIZATION (CInventoryItem, CGameObject, cast_inventory_item); -# undef cast_type_list -# define cast_type_list save_cast_list (CInventoryItem, CGameObject) +DECLARE_SPECIALIZATION(CInventoryItem, CGameObject, cast_inventory_item); +#undef cast_type_list +#define cast_type_list save_cast_list(CInventoryItem, CGameObject) - DECLARE_SPECIALIZATION (CInventoryOwner, CGameObject, cast_inventory_owner); -# undef cast_type_list -# define cast_type_list save_cast_list (CInventoryOwner, CGameObject) +DECLARE_SPECIALIZATION(CInventoryOwner, CGameObject, cast_inventory_owner); +#undef cast_type_list +#define cast_type_list save_cast_list(CInventoryOwner, CGameObject) - DECLARE_SPECIALIZATION (CActor, CGameObject, cast_actor); -# undef cast_type_list -# define cast_type_list save_cast_list (CActor, CGameObject) +DECLARE_SPECIALIZATION(CActor, CGameObject, cast_actor); +#undef cast_type_list +#define cast_type_list save_cast_list(CActor, CGameObject) - DECLARE_SPECIALIZATION (CGameObject, CInventoryOwner, cast_game_object); -# undef cast_type_list -# define cast_type_list save_cast_list (CGameObject, CInventoryOwner) +DECLARE_SPECIALIZATION(CGameObject, CInventoryOwner, cast_game_object); +#undef cast_type_list +#define cast_type_list save_cast_list(CGameObject, CInventoryOwner) - DECLARE_SPECIALIZATION (CWeapon, CInventoryItem, cast_weapon); -# undef cast_type_list -# define cast_type_list save_cast_list (CWeapon, CInventoryItem) +DECLARE_SPECIALIZATION(CWeapon, CInventoryItem, cast_weapon); +#undef cast_type_list +#define cast_type_list save_cast_list(CWeapon, CInventoryItem) - DECLARE_SPECIALIZATION (CWeapon, CGameObject, cast_weapon); -# undef cast_type_list -# define cast_type_list save_cast_list (CWeapon, CGameObject) +DECLARE_SPECIALIZATION(CWeapon, CGameObject, cast_weapon); +#undef cast_type_list +#define cast_type_list save_cast_list(CWeapon, CGameObject) - DECLARE_SPECIALIZATION (CFoodItem, CInventoryItem, cast_food_item); -# undef cast_type_list -# define cast_type_list save_cast_list (CFoodItem, CInventoryItem) +DECLARE_SPECIALIZATION(CFoodItem, CInventoryItem, cast_food_item); +#undef cast_type_list +#define cast_type_list save_cast_list(CFoodItem, CInventoryItem) - DECLARE_SPECIALIZATION (CMissile, CInventoryItem, cast_missile); -# undef cast_type_list -# define cast_type_list save_cast_list (CMissile, CInventoryItem) +DECLARE_SPECIALIZATION(CMissile, CInventoryItem, cast_missile); +#undef cast_type_list +#define cast_type_list save_cast_list(CMissile, CInventoryItem) - DECLARE_SPECIALIZATION (CCustomZone, CGameObject, cast_custom_zone); -# undef cast_type_list -# define cast_type_list save_cast_list (CCustomZone, CGameObject) +DECLARE_SPECIALIZATION(CCustomZone, CGameObject, cast_custom_zone); +#undef cast_type_list +#define cast_type_list save_cast_list(CCustomZone, CGameObject) - DECLARE_SPECIALIZATION (CWeaponMagazined, CWeapon, cast_weapon_magazined); -# undef cast_type_list -# define cast_type_list save_cast_list (CWeaponMagazined, CWeapon) +DECLARE_SPECIALIZATION(CWeaponMagazined, CWeapon, cast_weapon_magazined); +#undef cast_type_list +#define cast_type_list save_cast_list(CWeaponMagazined, CWeapon) - DECLARE_SPECIALIZATION (CHudItem, CInventoryItem, cast_hud_item); -# undef cast_type_list -# define cast_type_list save_cast_list (CHudItem, CInventoryItem) +DECLARE_SPECIALIZATION(CHudItem, CInventoryItem, cast_hud_item); +#undef cast_type_list +#define cast_type_list save_cast_list(CHudItem, CInventoryItem) - DECLARE_SPECIALIZATION (CPhysicsShellHolder,CGameObject, cast_physics_shell_holder); -# undef cast_type_list -# define cast_type_list save_cast_list (CPhysicsShellHolder,CGameObject) +DECLARE_SPECIALIZATION(CPhysicsShellHolder, CGameObject, cast_physics_shell_holder); +#undef cast_type_list +#define cast_type_list save_cast_list(CPhysicsShellHolder, CGameObject) - DECLARE_SPECIALIZATION (IInputReceiver, CGameObject, cast_input_receiver); -# undef cast_type_list -# define cast_type_list save_cast_list (IInputReceiver, CGameObject) +DECLARE_SPECIALIZATION(IInputReceiver, CGameObject, cast_input_receiver); +#undef cast_type_list +#define cast_type_list save_cast_list(IInputReceiver, CGameObject) - DECLARE_SPECIALIZATION (CWeaponAmmo, CInventoryItem, cast_weapon_ammo); -# undef cast_type_list -# define cast_type_list save_cast_list (CWeaponAmmo, CInventoryItem) +DECLARE_SPECIALIZATION(CWeaponAmmo, CInventoryItem, cast_weapon_ammo); +#undef cast_type_list +#define cast_type_list save_cast_list(CWeaponAmmo, CInventoryItem) /* - DECLARE_SPECIALIZATION (CCameraShotEffector, CCameraEffector, cast_effector_shot); + DECLARE_SPECIALIZATION (CCameraShotEffector, CCameraEffector, cast_effector_shot); # undef cast_type_list # define cast_type_list save_cast_list (CCameraShotEffector, CCameraEffector) - DECLARE_SPECIALIZATION (CEffectorZoomInertion, CCameraEffector, cast_effector_zoom_inertion); + DECLARE_SPECIALIZATION (CEffectorZoomInertion, CCameraEffector, cast_effector_zoom_inertion); # undef cast_type_list # define cast_type_list save_cast_list (CEffectorZoomInertion, CCameraEffector) */ - DECLARE_SPECIALIZATION (CParticlesPlayer, CGameObject, cast_particles_player); -# undef cast_type_list -# define cast_type_list save_cast_list (CParticlesPlayer, CGameObject) +DECLARE_SPECIALIZATION(CParticlesPlayer, CGameObject, cast_particles_player); +#undef cast_type_list +#define cast_type_list save_cast_list(CParticlesPlayer, CGameObject) - DECLARE_SPECIALIZATION (CArtefact, CGameObject, cast_artefact); -# undef cast_type_list -# define cast_type_list save_cast_list (CArtefact, CGameObject) +DECLARE_SPECIALIZATION(CArtefact, CGameObject, cast_artefact); +#undef cast_type_list +#define cast_type_list save_cast_list(CArtefact, CGameObject) - DECLARE_SPECIALIZATION (CCustomMonster, CGameObject, cast_custom_monster); -# undef cast_type_list -# define cast_type_list save_cast_list (CCustomMonster, CGameObject) +DECLARE_SPECIALIZATION(CCustomMonster, CGameObject, cast_custom_monster); +#undef cast_type_list +#define cast_type_list save_cast_list(CCustomMonster, CGameObject) - DECLARE_SPECIALIZATION (CAI_Stalker, CGameObject, cast_stalker); -# undef cast_type_list -# define cast_type_list save_cast_list (CAI_Stalker, CGameObject) +DECLARE_SPECIALIZATION(CAI_Stalker, CGameObject, cast_stalker); +#undef cast_type_list +#define cast_type_list save_cast_list(CAI_Stalker, CGameObject) - DECLARE_SPECIALIZATION (CScriptEntity, CGameObject, cast_script_entity); -# undef cast_type_list -# define cast_type_list save_cast_list (CScriptEntity, CGameObject) +DECLARE_SPECIALIZATION(CScriptEntity, CGameObject, cast_script_entity); +#undef cast_type_list +#define cast_type_list save_cast_list(CScriptEntity, CGameObject) - DECLARE_SPECIALIZATION (CSpaceRestrictor, CGameObject, cast_restrictor); -# undef cast_type_list -# define cast_type_list save_cast_list (CSpaceRestrictor, CGameObject) +DECLARE_SPECIALIZATION(CSpaceRestrictor, CGameObject, cast_restrictor); +#undef cast_type_list +#define cast_type_list save_cast_list(CSpaceRestrictor, CGameObject) - DECLARE_SPECIALIZATION (CExplosive, CGameObject, cast_explosive); -# undef cast_type_list -# define cast_type_list save_cast_list (CExplosive, CGameObject) +DECLARE_SPECIALIZATION(CExplosive, CGameObject, cast_explosive); +#undef cast_type_list +#define cast_type_list save_cast_list(CExplosive, CGameObject) - DECLARE_SPECIALIZATION (CGameObject, CAttachmentOwner, cast_game_object); -# undef cast_type_list -# define cast_type_list save_cast_list (CGameObject, CAttachmentOwner) +DECLARE_SPECIALIZATION(CGameObject, CAttachmentOwner, cast_game_object); +#undef cast_type_list +#define cast_type_list save_cast_list(CGameObject, CAttachmentOwner) - DECLARE_SPECIALIZATION (CGameObject, CInventoryItem, cast_game_object); -# undef cast_type_list -# define cast_type_list save_cast_list (CGameObject, CInventoryItem) +DECLARE_SPECIALIZATION(CGameObject, CInventoryItem, cast_game_object); +#undef cast_type_list +#define cast_type_list save_cast_list(CGameObject, CInventoryItem) - DECLARE_SPECIALIZATION (CAttachableItem, CGameObject, cast_attachable_item); -# undef cast_type_list -# define cast_type_list save_cast_list (CAttachableItem, CGameObject) +DECLARE_SPECIALIZATION(CAttachableItem, CGameObject, cast_attachable_item); +#undef cast_type_list +#define cast_type_list save_cast_list(CAttachableItem, CGameObject) - DECLARE_SPECIALIZATION (CHolderCustom, CGameObject, cast_holder_custom); -# undef cast_type_list -# define cast_type_list save_cast_list (CHolderCustom, CGameObject) +DECLARE_SPECIALIZATION(CHolderCustom, CGameObject, cast_holder_custom); +#undef cast_type_list +#define cast_type_list save_cast_list(CHolderCustom, CGameObject) - DECLARE_SPECIALIZATION (CAttachmentOwner, CGameObject, cast_attachment_owner); -# undef cast_type_list -# define cast_type_list save_cast_list (CAttachmentOwner, CGameObject) +DECLARE_SPECIALIZATION(CAttachmentOwner, CGameObject, cast_attachment_owner); +#undef cast_type_list +#define cast_type_list save_cast_list(CAttachmentOwner, CGameObject) - DECLARE_SPECIALIZATION (CEatableItem, CInventoryItem, cast_eatable_item); -# undef cast_type_list -# define cast_type_list save_cast_list (CEatableItem, CInventoryItem) +DECLARE_SPECIALIZATION(CEatableItem, CInventoryItem, cast_eatable_item); +#undef cast_type_list +#define cast_type_list save_cast_list(CEatableItem, CInventoryItem) - DECLARE_SPECIALIZATION (CBaseMonster, CGameObject, cast_base_monster); -# undef cast_type_list -# define cast_type_list save_cast_list (CBaseMonster, CGameObject) +DECLARE_SPECIALIZATION(CBaseMonster, CGameObject, cast_base_monster); +#undef cast_type_list +#define cast_type_list save_cast_list(CBaseMonster, CGameObject) -# endif - - DECLARE_SPECIALIZATION (CSE_Abstract, CSE_ALifeInventoryItem, cast_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_Abstract, CSE_ALifeInventoryItem) +#endif - DECLARE_SPECIALIZATION (CSE_Abstract, CSE_ALifeTraderAbstract, cast_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_Abstract, CSE_ALifeTraderAbstract) +DECLARE_SPECIALIZATION(CSE_Abstract, CSE_ALifeInventoryItem, cast_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_Abstract, CSE_ALifeInventoryItem) - DECLARE_SPECIALIZATION (CSE_Abstract, CSE_ALifeGroupAbstract, cast_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_Abstract, CSE_ALifeGroupAbstract) +DECLARE_SPECIALIZATION(CSE_Abstract, CSE_ALifeTraderAbstract, cast_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_Abstract, CSE_ALifeTraderAbstract) - DECLARE_SPECIALIZATION (CSE_Abstract, CSE_ALifeSchedulable, cast_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_Abstract, CSE_ALifeSchedulable) +DECLARE_SPECIALIZATION(CSE_Abstract, CSE_ALifeGroupAbstract, cast_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_Abstract, CSE_ALifeGroupAbstract) - DECLARE_SPECIALIZATION (CSE_ALifeGroupAbstract, CSE_Abstract, cast_group_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeGroupAbstract, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_Abstract, CSE_ALifeSchedulable, cast_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_Abstract, CSE_ALifeSchedulable) - DECLARE_SPECIALIZATION (CSE_ALifeSchedulable, CSE_Abstract, cast_schedulable); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeSchedulable, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeGroupAbstract, CSE_Abstract, cast_group_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeGroupAbstract, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeInventoryItem, CSE_Abstract, cast_inventory_item); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeInventoryItem, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeSchedulable, CSE_Abstract, cast_schedulable); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeSchedulable, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeTraderAbstract, CSE_Abstract, cast_trader_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeTraderAbstract, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeInventoryItem, CSE_Abstract, cast_inventory_item); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeInventoryItem, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_Visual, CSE_Abstract, visual); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_Visual, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeTraderAbstract, CSE_Abstract, cast_trader_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeTraderAbstract, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_Motion, CSE_Abstract, motion); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_Motion, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_Visual, CSE_Abstract, visual); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_Visual, CSE_Abstract) - DECLARE_SPECIALIZATION (IServerEntityShape, CSE_Abstract, shape); -# undef cast_type_list -# define cast_type_list save_cast_list (IServerEntityShape, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_Motion, CSE_Abstract, motion); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_Motion, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_Abstract, CSE_PHSkeleton, cast_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_Abstract, CSE_PHSkeleton) +DECLARE_SPECIALIZATION(IServerEntityShape, CSE_Abstract, shape); +#undef cast_type_list +#define cast_type_list save_cast_list(IServerEntityShape, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeObject, CSE_Abstract, cast_alife_object); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeObject, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_Abstract, CSE_PHSkeleton, cast_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_Abstract, CSE_PHSkeleton) - DECLARE_SPECIALIZATION (CSE_ALifeDynamicObject, CSE_Abstract, cast_alife_dynamic_object); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeDynamicObject, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeObject, CSE_Abstract, cast_alife_object); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeObject, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeItemAmmo, CSE_Abstract, cast_item_ammo); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeItemAmmo, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeDynamicObject, CSE_Abstract, cast_alife_dynamic_object); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeDynamicObject, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeItemWeapon, CSE_Abstract, cast_item_weapon); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeItemWeapon, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeItemAmmo, CSE_Abstract, cast_item_ammo); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeItemAmmo, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeItemDetector, CSE_Abstract, cast_item_detector); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeItemDetector, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeItemWeapon, CSE_Abstract, cast_item_weapon); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeItemWeapon, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeMonsterAbstract, CSE_Abstract, cast_monster_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeMonsterAbstract, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeItemDetector, CSE_Abstract, cast_item_detector); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeItemDetector, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeHumanAbstract, CSE_Abstract, cast_human_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeHumanAbstract, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeMonsterAbstract, CSE_Abstract, cast_monster_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeMonsterAbstract, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeAnomalousZone, CSE_Abstract, cast_anomalous_zone); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeAnomalousZone, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeHumanAbstract, CSE_Abstract, cast_human_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeHumanAbstract, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeTrader, CSE_Abstract, cast_trader); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeTrader, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeAnomalousZone, CSE_Abstract, cast_anomalous_zone); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeAnomalousZone, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeCreatureAbstract, CSE_Abstract, cast_creature_abstract); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeCreatureAbstract, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeTrader, CSE_Abstract, cast_trader); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeTrader, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeSmartZone, CSE_Abstract, cast_smart_zone); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeSmartZone, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeCreatureAbstract, CSE_Abstract, cast_creature_abstract); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeCreatureAbstract, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeOnlineOfflineGroup, CSE_Abstract, cast_online_offline_group); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeOnlineOfflineGroup, CSE_Abstract) +DECLARE_SPECIALIZATION(CSE_ALifeSmartZone, CSE_Abstract, cast_smart_zone); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeSmartZone, CSE_Abstract) - DECLARE_SPECIALIZATION (CSE_ALifeItemPDA, CSE_Abstract, cast_item_pda); -# undef cast_type_list -# define cast_type_list save_cast_list (CSE_ALifeItemPDA, CSE_Abstract) - -# ifndef DO_NOT_DECLARE_TYPE_LIST -# include "smart_cast_impl1.h" -# endif +DECLARE_SPECIALIZATION(CSE_ALifeOnlineOfflineGroup, CSE_Abstract, cast_online_offline_group); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeOnlineOfflineGroup, CSE_Abstract) + +DECLARE_SPECIALIZATION(CSE_ALifeItemPDA, CSE_Abstract, cast_item_pda); +#undef cast_type_list +#define cast_type_list save_cast_list(CSE_ALifeItemPDA, CSE_Abstract) + +#ifndef DO_NOT_DECLARE_TYPE_LIST +#include "smart_cast_impl1.h" +#endif #endif -#endif //SMART_CAST_H \ No newline at end of file +#endif // SMART_CAST_H \ No newline at end of file diff --git a/src/xrServerEntities/smart_cast_impl0.h b/src/xrServerEntities/smart_cast_impl0.h index d8dc40b4efa..3d0f75b216f 100644 --- a/src/xrServerEntities/smart_cast_impl0.h +++ b/src/xrServerEntities/smart_cast_impl0.h @@ -10,57 +10,53 @@ #include "Common/object_type_traits.h" -namespace SmartDynamicCast { - template - IC T1* smart_cast(T2 *p); - - template - struct CTypeHelper { - template - struct add { - typedef typename T1::Head Head; - - template - struct selector { - typedef Loki::Typelist< - Loki::Typelist< - typename Head::Head, - Loki::Typelist< - P, - typename Head::Tail - > - >, - typename Loki::TL::Erase< - List, - Head - >::Result - > result; - }; - - template <> - struct selector { - typedef typename add::result result; - }; - - typedef typename selector::value>::result result; - }; - - template <> - struct add { - typedef Loki::Typelist >,List> result; - }; - - typedef typename add::result result; - }; +namespace SmartDynamicCast +{ +template +IC T1* smart_cast(T2* p); + +template +struct CTypeHelper +{ + template + struct add + { + typedef typename T1::Head Head; + + template + struct selector + { + typedef Loki::Typelist>, + typename Loki::TL::Erase::Result> + result; + }; + + template <> + struct selector + { + typedef typename add::result result; + }; + + typedef typename selector::value>::result result; + }; + + template <> + struct add + { + typedef Loki::Typelist>, List> result; + }; + + typedef typename add::result result; +}; }; -#define cast_type_list Loki::NullType -#define add_to_cast_list(B,A) typedef SmartDynamicCast::CTypeHelper::result TypeList_##A##B -#define save_cast_list(B,A) TypeList_##A##B +#define cast_type_list Loki::NullType +#define add_to_cast_list(B, A) typedef SmartDynamicCast::CTypeHelper::result TypeList_##A##B +#define save_cast_list(B, A) TypeList_##A##B -#define DECLARE_SPECIALIZATION(B,A,C) \ - class A;\ - class B;\ - template <> extern\ - B* SmartDynamicCast::smart_cast(A *p);\ - add_to_cast_list(B,A); +#define DECLARE_SPECIALIZATION(B, A, C) \ + class A; \ + class B; \ + template <> \ + extern B* SmartDynamicCast::smart_cast(A * p); \ + add_to_cast_list(B, A); diff --git a/src/xrServerEntities/smart_cast_impl1.h b/src/xrServerEntities/smart_cast_impl1.h index 3a216bff695..217a06bddc3 100644 --- a/src/xrServerEntities/smart_cast_impl1.h +++ b/src/xrServerEntities/smart_cast_impl1.h @@ -9,508 +9,576 @@ #pragma once #ifdef DEBUG - void add_smart_cast_stats (LPCSTR,LPCSTR); -# ifdef SMART_CAST_STATS_ALL - void add_smart_cast_stats_all (LPCSTR,LPCSTR); -# endif +void add_smart_cast_stats(LPCSTR, LPCSTR); +#ifdef SMART_CAST_STATS_ALL +void add_smart_cast_stats_all(LPCSTR, LPCSTR); +#endif #endif #ifdef MASTER_GOLD -# define MAX_SEQUENCE_LENGTH 1 -#else // #ifdef MASTER_GOLD -# define MAX_SEQUENCE_LENGTH 1 -#endif // #ifdef MASTER_GOLD +#define MAX_SEQUENCE_LENGTH 1 +#else // #ifdef MASTER_GOLD +#define MAX_SEQUENCE_LENGTH 1 +#endif // #ifdef MASTER_GOLD //#define SHOW_SMART_CAST_UNOPTIMIZED_CASES -namespace SmartDynamicCast { - - template - struct exists { - template - struct iterator { - typedef typename P::Head Head; - typedef typename P::Tail Tail; - - template - struct selector { - enum { value = iterator::value }; - }; - - template <> - struct selector { - enum { value = true }; - }; - - enum { value = selector::value }; - }; - - template <> - struct iterator { - enum { value = false }; - }; - - enum { value = iterator::value }; - }; - - template - struct merge +namespace SmartDynamicCast +{ +template +struct exists +{ + template + struct iterator + { + typedef typename P::Head Head; + typedef typename P::Tail Tail; + + template + struct selector + { + enum + { + value = iterator::value + }; + }; + + template <> + struct selector + { + enum + { + value = true + }; + }; + + enum + { + value = selector::value + }; + }; + + template <> + struct iterator + { + enum + { + value = false + }; + }; + + enum + { + value = iterator::value + }; +}; + +template +struct merge +{ + template + struct iterator + { + typedef Loki::Typelist::result> result; + }; + + template <> + struct iterator + { + typedef List2 result; + }; + + typedef typename iterator::result result; +}; + +template +struct has_conversion +{ + template + struct search_base + { + typedef typename T::Head Head; + typedef typename T::Tail Tail; + + template + struct selector + { + typedef typename Head result; + }; + + template <> + struct selector + { + typedef typename search_base::result result; + }; + + typedef typename selector::value>::result result; + }; + + template <> + struct search_base + { + typedef Loki::NullType result; + }; + + template + struct search_conversion + { + template + struct selector + { + enum + { + value = true + }; + }; + + template <> + struct selector + { + enum + { + value = search_conversion::value + }; + }; + + enum + { + value = selector::value>::value + }; + }; + + template <> + struct search_conversion + { + enum + { + value = false + }; + }; + + enum + { + value = search_conversion::result>::value + }; +}; + +template +struct has_any_conversion +{ + template + struct iterator + { + typedef typename P::Head Head; + typedef typename P::Tail Tail; + + template + struct _selector + { + enum + { + value = iterator::value + }; + }; + + template <> + struct _selector + { + enum + { + value = true + }; + }; + + enum + { + value = _selector::value + }; + }; + + template <> + struct iterator + { + enum + { + value = false + }; + }; + + enum + { + value = iterator::value + }; +}; + +template +struct CMatcher +{ + template + struct CMatchHelper; + + template + struct CMatchHelper2 + { + template + struct CMatchHelper3 + { + typedef typename P::Head Head; + typedef typename P::Tail Tail; + typedef typename T::Head PrevHead; + + template + struct selector + { + template + struct _selector + { + typedef Loki::Typelist> result; + }; + + template <> + struct _selector + { + typedef Loki::Typelist>> + result; + }; + + typedef typename _selector::value>::result + result; + }; + + template <> + struct selector + { + typedef typename CMatchHelper3::result result; + }; + + typedef typename selector::value>::result result; + }; + + template <> + struct CMatchHelper3 + { + typedef typename CMatchHelper::result result; + }; + + typedef typename CMatchHelper3::result result; + }; + + template + struct CMatchHelper + { + typedef typename T::Head Head; + typedef typename T::Tail Tail; + typedef typename Head::Tail HeadTail; + + template + struct selector + { + typedef typename CMatchHelper2::result result; + }; + + template <> + struct selector + { + typedef typename CMatchHelper::result result; + }; + + typedef typename selector::value || + object_type_traits::is_same::value>::result result; + }; + + template <> + struct CMatchHelper + { + typedef Loki::NullType result; + }; + + typedef typename CMatchHelper::result result; +}; + +template +struct conversion_sequence +{ + template + struct list_iterator + { + typedef typename T::Head Head; + typedef typename T::Tail Tail; + typedef typename Head::Tail HeadTail; + + template + struct helper + { + typedef + typename conversion_sequence::result search_result; + + template + struct selector + { + typedef typename list_iterator::result result; + }; + + template <> + struct selector + { + typedef search_result result; + }; + + typedef typename selector::value>::result result; + }; + + template + struct selector + { + typedef typename helper::result helper_result; + + template + struct _selector + { + typedef helper_result result; + }; + + template <> + struct _selector + { + typedef typename list_iterator::result result; + }; + + typedef typename _selector::value>::result result; + }; + + template <> + struct selector + { + template + struct _selector + { + typedef typename helper::result helper_result; + + template + struct _selector2 + { + typedef Loki::Typelist result; + }; + + template <> + struct _selector2 + { + typedef typename list_iterator::result result; + }; + + typedef typename _selector2::value>::result result; + }; + + template <> + struct _selector + { + typedef typename list_iterator::result result; + }; + + typedef typename _selector::value>::result result; + }; + + typedef typename selector::value>::result + result; + }; + + template <> + struct list_iterator + { + typedef Loki::NullType result; + }; + + template + struct selector + { + STATIC_CHECK(length > 1, Internal_error_please_report); + + typedef typename selector<1>::result nearest; + + template + struct _selector + { + typedef nearest result; + }; + + template <> + struct _selector + { + typedef typename list_iterator::result result; + }; + + typedef typename _selector::value>::result result; + }; + + template <> + struct selector<1> + { + typedef typename CMatcher::result result; + }; + + template <> + struct selector<0> + { + typedef Loki::NullType result; + }; + + typedef typename selector::result result; +}; + +template +struct get_conversion_sequence +{ + typedef typename conversion_sequence::result result; +}; + +template +struct CSmartCaster +{ + typedef typename T::Head Head; + typedef typename T::Tail Tail; + typedef typename Tail::Head NextHead; + + template + struct CHelper + { + IC static Target* smart_cast(Head* p) + { + return (CSmartCaster::smart_cast(SmartDynamicCast::smart_cast(p))); + } + }; + + template <> + struct CHelper + { + IC static Target* smart_cast(Head* p) { return (SmartDynamicCast::smart_cast(p)); } + }; + + IC static Target* smart_cast(Head* p) + { + if (!p) return (reinterpret_cast(p)); + return (CHelper::smart_cast(p)); + } +}; + +template +struct CSmartMatcher +{ + template + IC static T1* smart_cast(T2* p) + { + return (CSmartCaster::smart_cast(static_cast(p))); + } + + template <> + IC static T1* smart_cast(T2* p) { - template - struct iterator { - typedef Loki::Typelist::result > result; - }; - - template <> - struct iterator { - typedef List2 result; - }; - - typedef typename iterator::result result; - }; - - template - struct has_conversion { - template - struct search_base { - typedef typename T::Head Head; - typedef typename T::Tail Tail; - - template - struct selector { - typedef typename Head result; - }; - - template <> - struct selector { - typedef typename search_base::result result; - }; - - typedef typename - selector< - is_type::value - >::result result; - }; - - template <> - struct search_base { - typedef Loki::NullType result; - }; - - template - struct search_conversion { - template - struct selector { - enum { value = true }; - }; - - template <> - struct selector { - enum { value = search_conversion::value }; - }; - - enum { - value = - selector< - object_type_traits::is_same< - typename T::Head, - Source - >::value - >::value - }; - }; - - template <> - struct search_conversion { - enum { value = false}; - }; - - enum { value = search_conversion::result>::value }; - }; - - template - struct has_any_conversion { - template - struct iterator { - typedef typename P::Head Head; - typedef typename P::Tail Tail; - - template - struct _selector { - enum { value = iterator::value }; - }; - - template <> - struct _selector { - enum { value = true }; - }; - - enum { value = _selector::value }; - }; - - template <> - struct iterator { - enum { value = false }; - }; - - enum { value = iterator::value }; - }; - - template - struct CMatcher { - - template - struct CMatchHelper; - - template - struct CMatchHelper2 { - template - struct CMatchHelper3 { - typedef typename P::Head Head; - typedef typename P::Tail Tail; - typedef typename T::Head PrevHead; - - template - struct selector { - template - struct _selector { - typedef Loki::Typelist > result; - }; - - template <> - struct _selector { - typedef Loki::Typelist > > result; - }; - - typedef typename - _selector< - object_type_traits::is_same< - Head, - typename PrevHead::Head - >::value - >::result result; - }; - - template <> - struct selector { - typedef typename CMatchHelper3::result result; - }; - - typedef typename selector::value>::result result; - }; - - template <> - struct CMatchHelper3 { - typedef typename CMatchHelper::result result; - }; - - typedef typename CMatchHelper3::result result; - }; - - template - struct CMatchHelper { - typedef typename T::Head Head; - typedef typename T::Tail Tail; - typedef typename Head::Tail HeadTail; - - template - struct selector { - typedef typename CMatchHelper2::result result; - }; - - template <> - struct selector { - typedef typename CMatchHelper::result result; - }; - - typedef typename selector< - object_type_traits::is_base_and_derived::value || object_type_traits::is_same::value - >::result result; - }; - - template <> - struct CMatchHelper { - typedef Loki::NullType result; - }; - - typedef typename CMatchHelper::result result; - }; - - template - struct conversion_sequence { - - template - struct list_iterator { - typedef typename T::Head Head; - typedef typename T::Tail Tail; - typedef typename Head::Tail HeadTail; - - template - struct helper { - typedef typename conversion_sequence::result search_result; - - template - struct selector { - typedef typename list_iterator::result result; - }; - - template <> - struct selector { - typedef search_result result; - }; - - typedef typename - selector< - is_type::value - >::result result; - }; - - template - struct selector { - typedef typename helper::result helper_result; - - template - struct _selector { - typedef helper_result result; - }; - - template <> - struct _selector { - typedef typename list_iterator::result result; - }; - - typedef typename _selector::value>::result result; - }; - - template <> - struct selector { - template - struct _selector { - typedef typename helper::result helper_result; - - template - struct _selector2 { - typedef Loki::Typelist result; - }; - - template <> - struct _selector2 { - typedef typename list_iterator::result result; - }; - - typedef typename _selector2::value>::result result; - }; - - template <> - struct _selector { - typedef typename list_iterator::result result; - }; - - typedef typename _selector::value>::result result; - }; - - typedef typename - selector< - can_use_heritage && - object_type_traits::is_base_and_derived< - typename Head::Head, - Source - >::value - >::result result; - }; - - template <> - struct list_iterator { - typedef Loki::NullType result; - }; - - - template - struct selector { - STATIC_CHECK(length > 1,Internal_error_please_report); - - typedef typename selector<1>::result nearest; - - template - struct _selector { - typedef nearest result; - }; - - template <> - struct _selector { - typedef typename list_iterator::result result; - }; - - typedef typename - _selector< - !is_type::value - >::result result; - }; - - template <> - struct selector<1> { - typedef typename CMatcher::result result; - }; - - template <> - struct selector<0> { - typedef Loki::NullType result; - }; - - typedef typename selector::result result; - }; - - template - struct get_conversion_sequence { - typedef typename conversion_sequence::result result; - }; - - template - struct CSmartCaster { - typedef typename T::Head Head; - typedef typename T::Tail Tail; - typedef typename Tail::Head NextHead; - - template - struct CHelper { - IC static Target* smart_cast(Head *p) - { - return (CSmartCaster::smart_cast(SmartDynamicCast::smart_cast(p))); - } - }; - - template <> - struct CHelper { - IC static Target* smart_cast(Head *p) - { - return (SmartDynamicCast::smart_cast(p)); - } - }; - - IC static Target* smart_cast(Head *p) - { - if (!p) - return (reinterpret_cast(p)); - return (CHelper::smart_cast(p)); - } - }; - - template - struct CSmartMatcher { - template - IC static T1* smart_cast(T2 *p) - { - return (CSmartCaster::smart_cast(static_cast(p))); - } - - template <> - IC static T1* smart_cast(T2 *p) - { #ifdef SHOW_SMART_CAST_UNOPTIMIZED_CASES #pragma todo("Dima to all : this smart_cast is not optimized!") #endif #ifdef DEBUG - add_smart_cast_stats(typeid(T2*).name(),typeid(T1*).name()); + add_smart_cast_stats(typeid(T2*).name(), typeid(T1*).name()); #endif - return (dynamic_cast(p)); - } - }; - - template - struct CHelper1 { - template - IC static T1* smart_cast(T2 *p) - { - return (CSmartMatcher::smart_cast::result>(p)); - } - - template <> - IC static T1* smart_cast(T2 *p) - { - return (static_cast(p)); - } - }; - - template - IC T1* smart_cast(T2 *p) - { - return (CHelper1::smart_cast::value || object_type_traits::is_same::value>(p)); - } - - template - struct CHelper2 { - template - IC static T1* smart_cast(T2* p) - { - STATIC_CHECK (!object_type_traits::is_const::value || object_type_traits::is_const::value,Cannot_use_smart_cast_to_convert_const_to_non_const); - typedef object_type_traits::remove_const::type _T1; - typedef object_type_traits::remove_const::type _T2; + return (dynamic_cast(p)); + } +}; + +template +struct CHelper1 +{ + template + IC static T1* smart_cast(T2* p) + { + return (CSmartMatcher::smart_cast::result>(p)); + } + + template <> + IC static T1* smart_cast(T2* p) + { + return (static_cast(p)); + } +}; + +template +IC T1* smart_cast(T2* p) +{ + return (CHelper1::smart_cast < object_type_traits::is_base_and_derived::value || + object_type_traits::is_same::value > (p)); +} + +template +struct CHelper2 +{ + template + IC static T1* smart_cast(T2* p) + { + STATIC_CHECK(!object_type_traits::is_const::value || object_type_traits::is_const::value, + Cannot_use_smart_cast_to_convert_const_to_non_const); + typedef object_type_traits::remove_const::type _T1; + typedef object_type_traits::remove_const::type _T2; #ifdef DEBUG - T1 *temp = SmartDynamicCast::smart_cast<_T1>(const_cast<_T2*>(p)); - T1 *test = dynamic_cast(p); - VERIFY2 ( - temp == test, - make_string( - "SmartCast<%s*>(%s*) FAILED (result differs from the dynamic_cast) or object is CORRUPTED (0x%08x -> 0x%08x)!", - typeid(T1).name(), - typeid(T2).name(), - *(u32*)&test, - *(u32*)&temp - ) - ); - return (temp); + T1* temp = SmartDynamicCast::smart_cast<_T1>(const_cast<_T2*>(p)); + T1* test = dynamic_cast(p); + VERIFY2(temp == test, make_string("SmartCast<%s*>(%s*) FAILED (result differs from the dynamic_cast) or object " + "is CORRUPTED (0x%08x -> 0x%08x)!", + typeid(T1).name(), typeid(T2).name(), *(u32*)&test, *(u32*)&temp)); + return (temp); #else - return (SmartDynamicCast::smart_cast<_T1>(const_cast<_T2*>(p))); + return (SmartDynamicCast::smart_cast<_T1>(const_cast<_T2*>(p))); #endif - } + } - template <> - IC static void* smart_cast(T2* p) - { + template <> + IC static void* smart_cast(T2* p) + { #ifdef SHOW_SMART_CAST_UNOPTIMIZED_CASES #pragma todo("Dima to all : this smart_cast is not optimized!") #endif #ifdef DEBUG - add_smart_cast_stats(typeid(T2*).name(),typeid(void*).name()); + add_smart_cast_stats(typeid(T2*).name(), typeid(void*).name()); #endif - if (!p) - return ((void*)0); - return (dynamic_cast(p)); - } - }; + if (!p) return ((void*)0); + return (dynamic_cast(p)); + } +}; }; template -IC T1 smart_cast(T2* p) +IC T1 smart_cast(T2* p) { #ifdef PURE_DYNAMIC_CAST_COMPATIBILITY_CHECK - STATIC_CHECK (object_type_traits::is_pointer::value,Invalid_target_type_for_Dynamic_Cast); - STATIC_CHECK (object_type_traits::is_void::type>::value || std::is_polymorphic::type>::value,Invalid_target_type_for_Dynamic_Cast); - STATIC_CHECK (std::is_polymorphic::value,Invalid_source_type_for_Dynamic_Cast); + STATIC_CHECK(object_type_traits::is_pointer::value, Invalid_target_type_for_Dynamic_Cast); + STATIC_CHECK(object_type_traits::is_void::type>::value || + std::is_polymorphic::type>::value, + Invalid_target_type_for_Dynamic_Cast); + STATIC_CHECK(std::is_polymorphic::value, Invalid_source_type_for_Dynamic_Cast); #endif #ifdef SMART_CAST_STATS_ALL - add_smart_cast_stats_all (typeid(T2*).name(),typeid(T1).name()); + add_smart_cast_stats_all(typeid(T2*).name(), typeid(T1).name()); #endif - if (!p) - return (reinterpret_cast(p)); - return (SmartDynamicCast::CHelper2::smart_cast::type>(p)); + if (!p) return (reinterpret_cast(p)); + return (SmartDynamicCast::CHelper2::smart_cast::type>(p)); } template -IC T1 smart_cast(T2& p) +IC T1 smart_cast(T2& p) { #ifdef PURE_DYNAMIC_CAST_COMPATIBILITY_CHECK - STATIC_CHECK (object_type_traits::is_reference::value,Invalid_target_type_for_Dynamic_Cast); - STATIC_CHECK (std::is_polymorphic::type>::value,Invalid_target_type_for_Dynamic_Cast); - STATIC_CHECK (std::is_polymorphic::value,Invalid_source_type_for_Dynamic_Cast); + STATIC_CHECK(object_type_traits::is_reference::value, Invalid_target_type_for_Dynamic_Cast); + STATIC_CHECK(std::is_polymorphic::type>::value, + Invalid_target_type_for_Dynamic_Cast); + STATIC_CHECK(std::is_polymorphic::value, Invalid_source_type_for_Dynamic_Cast); #endif #ifdef SMART_CAST_STATS_ALL - add_smart_cast_stats_all (typeid(T2*).name(),typeid(object_type_traits::remove_reference::type*).name()); + add_smart_cast_stats_all(typeid(T2*).name(), typeid(object_type_traits::remove_reference::type*).name()); #endif - return (*SmartDynamicCast::CHelper2::smart_cast::type>(&p)); + return (*SmartDynamicCast::CHelper2::smart_cast::type>(&p)); } #ifdef XRGAME_EXPORTS - template <> extern - CGameObject* SmartDynamicCast::smart_cast(IGameObject *p); +template <> +extern CGameObject* SmartDynamicCast::smart_cast(IGameObject* p); #endif diff --git a/src/xrServerEntities/smart_cast_impl2.h b/src/xrServerEntities/smart_cast_impl2.h index b9f1907bb87..b94c577f1ac 100644 --- a/src/xrServerEntities/smart_cast_impl2.h +++ b/src/xrServerEntities/smart_cast_impl2.h @@ -8,22 +8,25 @@ #pragma once -#undef DECLARE_SPECIALIZATION +#undef DECLARE_SPECIALIZATION -#define DECLARE_SPECIALIZATION(B,A,C) \ - template <>\ - B* SmartDynamicCast::smart_cast(A *p){return p->C();};\ +#define DECLARE_SPECIALIZATION(B, A, C) \ + template <> \ + B* SmartDynamicCast::smart_cast(A * p) \ + { \ + return p->C(); \ + }; #ifdef XRGAME_EXPORTS - template <> - CGameObject* SmartDynamicCast::smart_cast(IGameObject *p) - { - return static_cast(p); - } +template <> +CGameObject* SmartDynamicCast::smart_cast(IGameObject* p) +{ + return static_cast(p); +} - template <> - Feel::Sound* SmartDynamicCast::smart_cast(ISpatial *p) - { - return (p->dcast_FeelSound()); - } +template <> +Feel::Sound* SmartDynamicCast::smart_cast(ISpatial* p) +{ + return (p->dcast_FeelSound()); +} #endif \ No newline at end of file diff --git a/src/xrServerEntities/smart_cast_stats.cpp b/src/xrServerEntities/smart_cast_stats.cpp index 06f45c80afc..7e6a93b2e1f 100644 --- a/src/xrServerEntities/smart_cast_stats.cpp +++ b/src/xrServerEntities/smart_cast_stats.cpp @@ -8,173 +8,166 @@ #include "stdafx.h" -#ifdef DEBUG +#ifdef DEBUG #define SMART_CAST_STATS -class CSmartCastStats { +class CSmartCastStats +{ private: - static CSmartCastStats* m_instance; + static CSmartCastStats* m_instance; private: - struct CStats { - LPCSTR m_from; - LPCSTR m_to; - u32 m_count; - - IC CStats (LPCSTR from, LPCSTR to, u32 count) : - m_from (from), - m_to (to), - m_count (count) - { - } - - IC bool operator< (const CStats &stats) const - { - return ((m_from < stats.m_from) || ((m_from == stats.m_from) && (m_to < stats.m_to))); - } - }; - - struct CStatsPredicate { - IC bool operator() (const CStats &_1, const CStats &_2) const - { - return (_1.m_count < _2.m_count); - } - }; + struct CStats + { + LPCSTR m_from; + LPCSTR m_to; + u32 m_count; + + IC CStats(LPCSTR from, LPCSTR to, u32 count) : m_from(from), m_to(to), m_count(count) {} + IC bool operator<(const CStats& stats) const + { + return ((m_from < stats.m_from) || ((m_from == stats.m_from) && (m_to < stats.m_to))); + } + }; + + struct CStatsPredicate + { + IC bool operator()(const CStats& _1, const CStats& _2) const { return (_1.m_count < _2.m_count); } + }; private: - typedef xr_set STATS; + typedef xr_set STATS; private: - STATS m_stats; - xr_vector m_temp; + STATS m_stats; + xr_vector m_temp; public: - IC static CSmartCastStats* instance (); - IC static void _release (); + IC static CSmartCastStats* instance(); + IC static void _release(); public: - IC void add (LPCSTR from, LPCSTR to); - IC void clear (); - IC void show (); + IC void add(LPCSTR from, LPCSTR to); + IC void clear(); + IC void show(); }; CSmartCastStats* CSmartCastStats::m_instance = 0; -IC CSmartCastStats* CSmartCastStats::instance () +IC CSmartCastStats* CSmartCastStats::instance() { - if (!m_instance) - m_instance = new CSmartCastStats(); - return (m_instance); + if (!m_instance) m_instance = new CSmartCastStats(); + return (m_instance); } -IC void CSmartCastStats::_release () +IC void CSmartCastStats::_release() { - xr_delete (m_instance); + xr_delete(m_instance); } -IC CSmartCastStats &stats () +IC CSmartCastStats& stats() { - return (*CSmartCastStats::instance()); + return (*CSmartCastStats::instance()); } #ifdef SMART_CAST_STATS_ALL CSmartCastStats* g_smart_cast_opt = 0; -IC CSmartCastStats &stats_all () +IC CSmartCastStats& stats_all() { - if (!g_smart_cast_opt) - g_smart_cast_opt = new CSmartCastStats(); - return (*g_smart_cast_opt); + if (!g_smart_cast_opt) g_smart_cast_opt = new CSmartCastStats(); + return (*g_smart_cast_opt); } #endif -IC void CSmartCastStats::add (LPCSTR from, LPCSTR to) +IC void CSmartCastStats::add(LPCSTR from, LPCSTR to) { - CStats temp(from,to,1); - STATS::iterator I = m_stats.find(temp); - if (I == m_stats.end()) - m_stats.insert (temp); - else - ++(const_cast(*I).m_count); + CStats temp(from, to, 1); + STATS::iterator I = m_stats.find(temp); + if (I == m_stats.end()) + m_stats.insert(temp); + else + ++(const_cast(*I).m_count); } -IC void CSmartCastStats::clear () +IC void CSmartCastStats::clear() { - m_stats.clear (); + m_stats.clear(); } -IC void CSmartCastStats::show () +IC void CSmartCastStats::show() { - if (m_stats.empty()) { - Msg ("CONGRATULATIONS : SmartCast stats is empty!!!"); - return; - } - - m_temp.clear (); - m_temp.insert (m_temp.begin(),m_stats.begin(),m_stats.end()); - std::sort (m_temp.begin(),m_temp.end(),CStatsPredicate()); - u32 total = 0; - - xr_vector::const_iterator I = m_temp.begin(); - xr_vector::const_iterator E = m_temp.end(); - for ( ; I != E; ++I) - total += (*I).m_count; - - Msg ("SmartCast stats (different %d, total %d) : ",(u32)m_stats.size(),total); - - I = m_temp.begin(); - for ( ; I != E; ++I) - Msg ("%8d %6.2f% : smart_cast<%s>(%s)",(*I).m_count,float((*I).m_count)*100.f/float(total),(*I).m_to,(*I).m_from); + if (m_stats.empty()) { + Msg("CONGRATULATIONS : SmartCast stats is empty!!!"); + return; + } + + m_temp.clear(); + m_temp.insert(m_temp.begin(), m_stats.begin(), m_stats.end()); + std::sort(m_temp.begin(), m_temp.end(), CStatsPredicate()); + u32 total = 0; + + xr_vector::const_iterator I = m_temp.begin(); + xr_vector::const_iterator E = m_temp.end(); + for (; I != E; ++I) + total += (*I).m_count; + + Msg("SmartCast stats (different %d, total %d) : ", (u32)m_stats.size(), total); + + I = m_temp.begin(); + for (; I != E; ++I) + Msg("%8d %6.2f% : smart_cast<%s>(%s)", (*I).m_count, float((*I).m_count) * 100.f / float(total), (*I).m_to, + (*I).m_from); } -void add_smart_cast_stats (LPCSTR from, LPCSTR to) +void add_smart_cast_stats(LPCSTR from, LPCSTR to) { #ifdef SMART_CAST_STATS - stats().add (from,to); + stats().add(from, to); #endif } -void add_smart_cast_stats_all (LPCSTR from, LPCSTR to) +void add_smart_cast_stats_all(LPCSTR from, LPCSTR to) { #ifdef SMART_CAST_STATS -# ifdef SMART_CAST_STATS_ALL - stats_all().add (from,to); -# endif +#ifdef SMART_CAST_STATS_ALL + stats_all().add(from, to); +#endif #endif } -void show_smart_cast_stats () +void show_smart_cast_stats() { #ifdef SMART_CAST_STATS - stats().show (); -# ifdef SMART_CAST_STATS_ALL - stats_all().show (); -# endif + stats().show(); +#ifdef SMART_CAST_STATS_ALL + stats_all().show(); +#endif #else - Msg ("! SMART_CAST_STATS macros is not defined, stats is disabled"); + Msg("! SMART_CAST_STATS macros is not defined, stats is disabled"); #endif } -void clear_smart_cast_stats () +void clear_smart_cast_stats() { #ifdef SMART_CAST_STATS - stats().clear (); -# ifdef SMART_CAST_STATS_ALL - stats_all().clear (); -# endif + stats().clear(); +#ifdef SMART_CAST_STATS_ALL + stats_all().clear(); +#endif #else - Msg ("! SMART_CAST_STATS macros is not defined, stats is disabled"); + Msg("! SMART_CAST_STATS macros is not defined, stats is disabled"); #endif } -void release_smart_cast_stats () +void release_smart_cast_stats() { #ifdef SMART_CAST_STATS - CSmartCastStats::_release (); -# ifdef SMART_CAST_STATS_ALL - xr_delete (g_smart_cast_opt); -# endif + CSmartCastStats::_release(); +#ifdef SMART_CAST_STATS_ALL + xr_delete(g_smart_cast_opt); +#endif #endif } -#endif // DEBUG \ No newline at end of file +#endif // DEBUG \ No newline at end of file diff --git a/src/xrServerEntities/specific_character.cpp b/src/xrServerEntities/specific_character.cpp index 2818e3fc42c..578e56ad62c 100644 --- a/src/xrServerEntities/specific_character.cpp +++ b/src/xrServerEntities/specific_character.cpp @@ -1,32 +1,30 @@ -#include "stdafx.h" #include "specific_character.h" +#include "stdafx.h" -#ifdef XRGAME_EXPORTS +#ifdef XRGAME_EXPORTS #include "PhraseDialog.h" #include "string_table.h" - SSpecificCharacterData::SSpecificCharacterData() { - m_sGameName.clear (); - m_sBioText = NULL; - m_sVisual.clear (); - m_sSupplySpawn.clear (); - m_sNpcConfigSect.clear (); - - - m_StartDialog = NULL; - m_ActorDialogs.clear (); - - m_Rank = NO_RANK; - m_Reputation = NO_REPUTATION; - - m_bNoRandom = false; - m_bDefaultForCommunity = false; - m_fPanic_threshold = 0.0f; - m_fHitProbabilityFactor = 1.f; - m_crouch_type = 0; - m_upgrade_mechanic = false; + m_sGameName.clear(); + m_sBioText = NULL; + m_sVisual.clear(); + m_sSupplySpawn.clear(); + m_sNpcConfigSect.clear(); + + m_StartDialog = NULL; + m_ActorDialogs.clear(); + + m_Rank = NO_RANK; + m_Reputation = NO_REPUTATION; + + m_bNoRandom = false; + m_bDefaultForCommunity = false; + m_fPanic_threshold = 0.0f; + m_fHitProbabilityFactor = 1.f; + m_crouch_type = 0; + m_upgrade_mechanic = false; } SSpecificCharacterData::~SSpecificCharacterData() @@ -37,172 +35,157 @@ SSpecificCharacterData::~SSpecificCharacterData() CSpecificCharacter::CSpecificCharacter() { - m_OwnId = NULL; + m_OwnId = NULL; } - CSpecificCharacter::~CSpecificCharacter() { } - void CSpecificCharacter::InitXmlIdToIndex() { - if(!id_to_index::tag_name) - id_to_index::tag_name = "specific_character"; - if(!id_to_index::file_str) - id_to_index::file_str = pSettings->r_string("profiles", "specific_characters_files"); + if (!id_to_index::tag_name) id_to_index::tag_name = "specific_character"; + if (!id_to_index::file_str) id_to_index::file_str = pSettings->r_string("profiles", "specific_characters_files"); } - void CSpecificCharacter::Load(shared_str id) { - R_ASSERT(id.size()); - m_OwnId = id; - inherited_shared::load_shared(m_OwnId, NULL); + R_ASSERT(id.size()); + m_OwnId = id; + inherited_shared::load_shared(m_OwnId, NULL); } - -void CSpecificCharacter::load_shared (LPCSTR) +void CSpecificCharacter::load_shared(LPCSTR) { #if 0 CTimer timer; timer.Start (); #endif - const ITEM_DATA& item_data = *id_to_index::GetById(m_OwnId); - - CUIXml* pXML = item_data._xml; + const ITEM_DATA& item_data = *id_to_index::GetById(m_OwnId); - pXML->SetLocalRoot (pXML->GetRoot()); + CUIXml* pXML = item_data._xml; + pXML->SetLocalRoot(pXML->GetRoot()); - XML_NODE* item_node = pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file); - R_ASSERT3(item_node, "specific_character id=", *item_data.id); + XML_NODE* item_node = pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file); + R_ASSERT3(item_node, "specific_character id=", *item_data.id); - pXML->SetLocalRoot(item_node); + pXML->SetLocalRoot(item_node); + int norandom = pXML->ReadAttribInt(item_node, "no_random", 0); + if (1 == norandom) + data()->m_bNoRandom = true; + else + data()->m_bNoRandom = false; + int team_default = pXML->ReadAttribInt(item_node, "team_default", 0); + if (1 == team_default) + data()->m_bDefaultForCommunity = true; + else + data()->m_bDefaultForCommunity = false; - int norandom = pXML->ReadAttribInt(item_node, "no_random", 0); - if (1 == norandom) - data()->m_bNoRandom = true; - else - data()->m_bNoRandom = false; + R_ASSERT3(!(data()->m_bNoRandom && data()->m_bDefaultForCommunity), + "cannot set 'no_random' and 'team_default' flags simultaneously, profile id", *shared_str(item_data.id)); - int team_default = pXML->ReadAttribInt(item_node, "team_default", 0); - if (1 == team_default) - data()->m_bDefaultForCommunity = true; - else - data()->m_bDefaultForCommunity = false; +#ifdef XRGAME_EXPORTS - R_ASSERT3(!(data()->m_bNoRandom && data()->m_bDefaultForCommunity), - "cannot set 'no_random' and 'team_default' flags simultaneously, profile id", *shared_str(item_data.id)); - -#ifdef XRGAME_EXPORTS + LPCSTR start_dialog = pXML->Read("start_dialog", 0, NULL); + if (start_dialog) { + data()->m_StartDialog = start_dialog; + } + else + data()->m_StartDialog = NULL; - LPCSTR start_dialog = pXML->Read("start_dialog", 0, NULL); - if(start_dialog) - { - data()->m_StartDialog = start_dialog; - } - else - data()->m_StartDialog = NULL; + int dialogs_num = pXML->GetNodesNum(pXML->GetLocalRoot(), "actor_dialog"); + data()->m_ActorDialogs.clear(); + for (int i = 0; i < dialogs_num; ++i) + { + shared_str dialog_name = pXML->Read(pXML->GetLocalRoot(), "actor_dialog", i, ""); + data()->m_ActorDialogs.push_back(dialog_name); + } - int dialogs_num = pXML->GetNodesNum(pXML->GetLocalRoot(), "actor_dialog"); - data()->m_ActorDialogs.clear(); - for(int i=0; iRead(pXML->GetLocalRoot(), "actor_dialog", i, ""); - data()->m_ActorDialogs.push_back(dialog_name); - } + data()->m_icon_name = pXML->Read("icon", 0, "ui_npc_u_barman"); - data()->m_icon_name = pXML->Read("icon", 0, "ui_npc_u_barman"); - + //èãðîâîå èìÿ ïåðñîíàæà + data()->m_sGameName = pXML->Read("name", 0, ""); + data()->m_sBioText = CStringTable().translate(pXML->Read("bio", 0, "")); - //èãðîâîå èìÿ ïåðñîíàæà - data()->m_sGameName = pXML->Read("name", 0, ""); - data()->m_sBioText = CStringTable().translate(pXML->Read("bio", 0, "")); + data()->m_fPanic_threshold = pXML->ReadFlt("panic_threshold", 0, 0.f); + data()->m_fHitProbabilityFactor = pXML->ReadFlt("hit_probability_factor", 0, 1.f); + data()->m_crouch_type = pXML->ReadInt("crouch_type", 0, 0); + data()->m_upgrade_mechanic = (pXML->ReadInt("mechanic_mode", 0, 0) == 1); - - data()->m_fPanic_threshold = pXML->ReadFlt("panic_threshold",0,0.f); - data()->m_fHitProbabilityFactor = pXML->ReadFlt("hit_probability_factor",0,1.f); - data()->m_crouch_type = pXML->ReadInt("crouch_type",0,0); - data()->m_upgrade_mechanic = ( pXML->ReadInt("mechanic_mode",0,0) == 1 ); - - data()->m_critical_wound_weights= pXML->Read("critical_wound_weights", 0, "1"); + data()->m_critical_wound_weights = pXML->Read("critical_wound_weights", 0, "1"); #endif - data()->m_sVisual = pXML->Read("visual", 0, ""); - + data()->m_sVisual = pXML->Read("visual", 0, ""); -#ifdef XRGAME_EXPORTS - data()->m_sSupplySpawn = pXML->Read("supplies", 0, ""); - - if(!data()->m_sSupplySpawn.empty()) - { - xr_string &str = data()->m_sSupplySpawn; - xr_string::size_type pos = str.find("\\n"); +#ifdef XRGAME_EXPORTS + data()->m_sSupplySpawn = pXML->Read("supplies", 0, ""); - while (xr_string::npos != pos) - { - str.replace(pos, 2, "\n"); - pos = str.find("\\n", pos + 1); - } - } + if (!data()->m_sSupplySpawn.empty()) { + xr_string& str = data()->m_sSupplySpawn; + xr_string::size_type pos = str.find("\\n"); - data()->m_sNpcConfigSect = pXML->Read("npc_config", 0, ""); - data()->m_sound_voice_prefix = pXML->Read("snd_config", 0, ""); + while (xr_string::npos != pos) + { + str.replace(pos, 2, "\n"); + pos = str.find("\\n", pos + 1); + } + } - data()->m_terrain_sect = pXML->Read("terrain_sect", 0, ""); + data()->m_sNpcConfigSect = pXML->Read("npc_config", 0, ""); + data()->m_sound_voice_prefix = pXML->Read("snd_config", 0, ""); + + data()->m_terrain_sect = pXML->Read("terrain_sect", 0, ""); #endif - data()->m_Classes.clear (); - int classes_num = pXML->GetNodesNum (pXML->GetLocalRoot(), "class"); - for(int i=0; iRead ("class", 0, ""); - if(char_class) - { - char* buf_str = xr_strdup(char_class); - xr_strlwr (buf_str); - data()->m_Classes.push_back(buf_str); - xr_free (buf_str); - } - } - - -#ifdef XRGAME_EXPORTS - - LPCSTR team = pXML->Read("community", 0, NULL); - R_ASSERT3(team != NULL, "'community' field not fulfiled for specific character", *m_OwnId); - - char* buf_str = xr_strdup(team); - xr_strlwr(buf_str); - data()->m_Community.set(buf_str); - xr_free(buf_str); - - if(data()->m_Community.index() == NO_COMMUNITY_INDEX) - xrDebug::Fatal(DEBUG_INFO,"wrong 'community' '%s' in specific character %s ", team, *m_OwnId); - - data()->m_Rank = pXML->ReadInt("rank", 0, NO_RANK); - R_ASSERT3(data()->m_Rank != NO_RANK, "'rank' field not fulfiled for specific character", *m_OwnId); - data()->m_Reputation = pXML->ReadInt("reputation", 0, NO_REPUTATION); - R_ASSERT3(data()->m_Reputation != NO_REPUTATION, "'reputation' field not fulfiled for specific character", *m_OwnId); - - if(pXML->NavigateToNode(pXML->GetLocalRoot(), "money", 0)) - { - MoneyDef().min_money = pXML->ReadAttribInt("money", 0, "min"); - MoneyDef().max_money = pXML->ReadAttribInt("money", 0, "max"); - MoneyDef().inf_money = !!pXML->ReadAttribInt("money", 0, "infinitive"); - MoneyDef().max_money = _max(MoneyDef().max_money, MoneyDef().min_money); // :) - - }else{ - MoneyDef().min_money = 0; - MoneyDef().max_money = 0; - MoneyDef().inf_money = false; - } + data()->m_Classes.clear(); + int classes_num = pXML->GetNodesNum(pXML->GetLocalRoot(), "class"); + for (int i = 0; i < classes_num; i++) + { + LPCSTR char_class = pXML->Read("class", 0, ""); + if (char_class) { + char* buf_str = xr_strdup(char_class); + xr_strlwr(buf_str); + data()->m_Classes.push_back(buf_str); + xr_free(buf_str); + } + } + +#ifdef XRGAME_EXPORTS + + LPCSTR team = pXML->Read("community", 0, NULL); + R_ASSERT3(team != NULL, "'community' field not fulfiled for specific character", *m_OwnId); + + char* buf_str = xr_strdup(team); + xr_strlwr(buf_str); + data()->m_Community.set(buf_str); + xr_free(buf_str); + + if (data()->m_Community.index() == NO_COMMUNITY_INDEX) + xrDebug::Fatal(DEBUG_INFO, "wrong 'community' '%s' in specific character %s ", team, *m_OwnId); + + data()->m_Rank = pXML->ReadInt("rank", 0, NO_RANK); + R_ASSERT3(data()->m_Rank != NO_RANK, "'rank' field not fulfiled for specific character", *m_OwnId); + data()->m_Reputation = pXML->ReadInt("reputation", 0, NO_REPUTATION); + R_ASSERT3( + data()->m_Reputation != NO_REPUTATION, "'reputation' field not fulfiled for specific character", *m_OwnId); + + if (pXML->NavigateToNode(pXML->GetLocalRoot(), "money", 0)) { + MoneyDef().min_money = pXML->ReadAttribInt("money", 0, "min"); + MoneyDef().max_money = pXML->ReadAttribInt("money", 0, "max"); + MoneyDef().inf_money = !!pXML->ReadAttribInt("money", 0, "infinitive"); + MoneyDef().max_money = _max(MoneyDef().max_money, MoneyDef().min_money); // :) + } + else + { + MoneyDef().min_money = 0; + MoneyDef().max_money = 0; + MoneyDef().inf_money = false; + } #endif @@ -211,82 +194,81 @@ void CSpecificCharacter::load_shared (LPCSTR) #endif } +#ifdef XRGAME_EXPORTS -#ifdef XRGAME_EXPORTS - -LPCSTR CSpecificCharacter::Name() const +LPCSTR CSpecificCharacter::Name() const { - return data()->m_sGameName.c_str(); + return data()->m_sGameName.c_str(); } -shared_str CSpecificCharacter::Bio() const +shared_str CSpecificCharacter::Bio() const { - return data()->m_sBioText; + return data()->m_sBioText; } -const CHARACTER_COMMUNITY& CSpecificCharacter::Community() const +const CHARACTER_COMMUNITY& CSpecificCharacter::Community() const { - return data()->m_Community; + return data()->m_Community; } -LPCSTR CSpecificCharacter::SupplySpawn () const +LPCSTR CSpecificCharacter::SupplySpawn() const { - return data()->m_sSupplySpawn.c_str(); + return data()->m_sSupplySpawn.c_str(); } -LPCSTR CSpecificCharacter::NpcConfigSect () const +LPCSTR CSpecificCharacter::NpcConfigSect() const { - return data()->m_sNpcConfigSect.c_str(); + return data()->m_sNpcConfigSect.c_str(); } -LPCSTR CSpecificCharacter::sound_voice_prefix () const +LPCSTR CSpecificCharacter::sound_voice_prefix() const { - return data()->m_sound_voice_prefix.c_str(); + return data()->m_sound_voice_prefix.c_str(); } -float CSpecificCharacter::panic_threshold () const +float CSpecificCharacter::panic_threshold() const { - return data()->m_fPanic_threshold; + return data()->m_fPanic_threshold; } -float CSpecificCharacter::hit_probability_factor () const +float CSpecificCharacter::hit_probability_factor() const { - return data()->m_fHitProbabilityFactor; + return data()->m_fHitProbabilityFactor; } -int CSpecificCharacter::crouch_type () const +int CSpecificCharacter::crouch_type() const { - return data()->m_crouch_type; + return data()->m_crouch_type; } -bool CSpecificCharacter::upgrade_mechanic() const +bool CSpecificCharacter::upgrade_mechanic() const { - return data()->m_upgrade_mechanic; + return data()->m_upgrade_mechanic; } -LPCSTR CSpecificCharacter::critical_wound_weights () const +LPCSTR CSpecificCharacter::critical_wound_weights() const { - return data()->m_critical_wound_weights.c_str(); + return data()->m_critical_wound_weights.c_str(); } #endif -shared_str CSpecificCharacter::terrain_sect () const +shared_str CSpecificCharacter::terrain_sect() const { - return data()->m_terrain_sect; + return data()->m_terrain_sect; } -CHARACTER_RANK_VALUE CSpecificCharacter::Rank() const +CHARACTER_RANK_VALUE CSpecificCharacter::Rank() const { - return data()->m_Rank; + return data()->m_Rank; } -CHARACTER_REPUTATION_VALUE CSpecificCharacter::Reputation () const +CHARACTER_REPUTATION_VALUE CSpecificCharacter::Reputation() const { - return data()->m_Reputation; + return data()->m_Reputation; } -LPCSTR CSpecificCharacter::Visual () const +LPCSTR CSpecificCharacter::Visual() const { - return data()->m_sVisual.c_str(); + return data()->m_sVisual.c_str(); } \ No newline at end of file diff --git a/src/xrServerEntities/specific_character.h b/src/xrServerEntities/specific_character.h index 4674c925a88..7f98c37c3f2 100644 --- a/src/xrServerEntities/specific_character.h +++ b/src/xrServerEntities/specific_character.h @@ -1,16 +1,14 @@ ////////////////////////////////////////////////////////////////////////// -// specific_character.h: èãðîâàÿ èíôîðìàöèÿ äëÿ î êîíêðåòíîì +// specific_character.h: èãðîâàÿ èíôîðìàöèÿ äëÿ î êîíêðåòíîì // ïåðñîíàæåé â èãðå ////////////////////////////////////////////////////////////////////////// -#pragma once - +#pragma once #include "character_info_defs.h" #include "shared_data.h" #include "xml_str_id_loader.h" - #ifdef XRGAME_EXPORTS #include "PhraseDialogDefs.h" @@ -18,76 +16,74 @@ #endif - ////////////////////////////////////////////////////////////////////////// // SSpecificCharacterData: äàííûå î êîíêðåòíîì ïåðñîíàæå ////////////////////////////////////////////////////////////////////////// struct SSpecificCharacterData : CSharedResource { +#ifdef XRGAME_EXPORTS + + SSpecificCharacterData(); + virtual ~SSpecificCharacterData(); + + //èãðîâîå èìÿ ïåðñîíàæà + xr_string m_sGameName; + //òåêñò ñ áèîãðàôèåé ïåðñîíàæà (ëèíê íà string table) + shared_str m_sBioText; + //ñòðîêà ñîäåðæàùàÿ ïðåäìåòû, êîòîðûå íóæíî ïðîñïàâíèòü + xr_string m_sSupplySpawn; + //èìÿ ñåêöèè êîíôèãóðàöèè íàñòðîåê NPC äëÿ ïåðñîíàæà + xr_string m_sNpcConfigSect; + //èìÿ ñåêöèè êîíôèãóðàöèè çâóêà äëÿ NPC ïåðñîíàæà + xr_string m_sound_voice_prefix; + + float m_fPanic_threshold; + float m_fHitProbabilityFactor; + int m_crouch_type; + bool m_upgrade_mechanic; + + xr_string m_critical_wound_weights; +#endif + shared_str m_terrain_sect; -#ifdef XRGAME_EXPORTS + //èìÿ ìîäåëè + xr_string m_sVisual; - SSpecificCharacterData (); - virtual ~SSpecificCharacterData (); +#ifdef XRGAME_EXPORTS - //èãðîâîå èìÿ ïåðñîíàæà - xr_string m_sGameName; - //òåêñò ñ áèîãðàôèåé ïåðñîíàæà (ëèíê íà string table) - shared_str m_sBioText; - //ñòðîêà ñîäåðæàùàÿ ïðåäìåòû, êîòîðûå íóæíî ïðîñïàâíèòü - xr_string m_sSupplySpawn; - //èìÿ ñåêöèè êîíôèãóðàöèè íàñòðîåê NPC äëÿ ïåðñîíàæà - xr_string m_sNpcConfigSect; - //èìÿ ñåêöèè êîíôèãóðàöèè çâóêà äëÿ NPC ïåðñîíàæà - xr_string m_sound_voice_prefix; + //íà÷àëüíûé äèàëîã + shared_str m_StartDialog; + //äèàëîãè àêòåðà, êîòîðûå áóäóò äîñòóïíû òîëüêî ïðè âñòðå÷å ñ äàííûì ïåðñîíàæåì + DIALOG_ID_VECTOR m_ActorDialogs; - float m_fPanic_threshold; - float m_fHitProbabilityFactor; - int m_crouch_type; - bool m_upgrade_mechanic; + shared_str m_icon_name; + //êîìàíäà + CHARACTER_COMMUNITY m_Community; - xr_string m_critical_wound_weights; #endif - shared_str m_terrain_sect; - - //èìÿ ìîäåëè - xr_string m_sVisual; -#ifdef XRGAME_EXPORTS - - //íà÷àëüíûé äèàëîã - shared_str m_StartDialog; - //äèàëîãè àêòåðà, êîòîðûå áóäóò äîñòóïíû òîëüêî ïðè âñòðå÷å ñ äàííûì ïåðñîíàæåì - DIALOG_ID_VECTOR m_ActorDialogs; + //ðàíã + CHARACTER_RANK_VALUE m_Rank; + //ðåïóòàöèÿ + CHARACTER_REPUTATION_VALUE m_Reputation; - shared_str m_icon_name; - //êîìàíäà - CHARACTER_COMMUNITY m_Community; + //êëàññû ïåðñîíàæà (âîåííûå-âåòåðàíû, ó÷åíûå è ò.ä.) + //ê êîòîðûì îí ïðèíàäëåæèò + xr_vector m_Classes; -#endif - - //ðàíã - CHARACTER_RANK_VALUE m_Rank; - //ðåïóòàöèÿ - CHARACTER_REPUTATION_VALUE m_Reputation; - - //êëàññû ïåðñîíàæà (âîåííûå-âåòåðàíû, ó÷åíûå è ò.ä.) - //ê êîòîðûì îí ïðèíàäëåæèò - xr_vector m_Classes; - - - //óêàçàíèå íà òî ÷òî ïåðñîíàæ íå ïðåäíàçíà÷åí äëÿ ñëó÷àéíîãî âûáîðà - //è çàäàåòñÿ òîëüêî ÷åðåç ÿâíîå óêàçàíèå ID - bool m_bNoRandom; - //åñëè ïåðñîíàæ ÿâëÿåòñÿ çàäàíûì ïî óìîë÷àíèþ äëÿ ñâîåé êîìàíäû - bool m_bDefaultForCommunity; -#ifdef XRGAME_EXPORTS - struct SMoneyDef{ - u32 min_money; - u32 max_money; - bool inf_money; - }; - SMoneyDef money_def; + //óêàçàíèå íà òî ÷òî ïåðñîíàæ íå ïðåäíàçíà÷åí äëÿ ñëó÷àéíîãî âûáîðà + //è çàäàåòñÿ òîëüêî ÷åðåç ÿâíîå óêàçàíèå ID + bool m_bNoRandom; + //åñëè ïåðñîíàæ ÿâëÿåòñÿ çàäàíûì ïî óìîë÷àíèþ äëÿ ñâîåé êîìàíäû + bool m_bDefaultForCommunity; +#ifdef XRGAME_EXPORTS + struct SMoneyDef + { + u32 min_money; + u32 max_money; + bool inf_money; + }; + SMoneyDef money_def; #endif }; @@ -95,61 +91,67 @@ class CInventoryOwner; class CCharacterInfo; class CSE_ALifeTraderAbstract; - -class CSpecificCharacter: public CSharedClass, - public CXML_IdToIndex +class CSpecificCharacter : public CSharedClass, + public CXML_IdToIndex { private: - typedef CSharedClass inherited_shared; - typedef CXML_IdToIndex id_to_index; + typedef CSharedClass inherited_shared; + typedef CXML_IdToIndex id_to_index; - friend id_to_index; - friend CInventoryOwner; - friend CCharacterInfo; - friend CSE_ALifeTraderAbstract; -public: + friend id_to_index; + friend CInventoryOwner; + friend CCharacterInfo; + friend CSE_ALifeTraderAbstract; - CSpecificCharacter (); - ~CSpecificCharacter (); +public: + CSpecificCharacter(); + ~CSpecificCharacter(); - virtual void Load (shared_str id); + virtual void Load(shared_str id); protected: - const SSpecificCharacterData* data () const { VERIFY(inherited_shared::get_sd()); return inherited_shared::get_sd();} - SSpecificCharacterData* data () { VERIFY(inherited_shared::get_sd()); return inherited_shared::get_sd();} + const SSpecificCharacterData* data() const + { + VERIFY(inherited_shared::get_sd()); + return inherited_shared::get_sd(); + } + SSpecificCharacterData* data() + { + VERIFY(inherited_shared::get_sd()); + return inherited_shared::get_sd(); + } + + //çàãðóçêà èç XML ôàéëà + virtual void load_shared(LPCSTR); + static void InitXmlIdToIndex(); + + shared_str m_OwnId; - //çàãðóçêà èç XML ôàéëà - virtual void load_shared (LPCSTR); - static void InitXmlIdToIndex (); - - shared_str m_OwnId; public: - -#ifdef XRGAME_EXPORTS - LPCSTR Name () const ; - shared_str Bio () const ; - const CHARACTER_COMMUNITY& Community () const ; - SSpecificCharacterData::SMoneyDef& MoneyDef () {return data()->money_def;} +#ifdef XRGAME_EXPORTS + LPCSTR Name() const; + shared_str Bio() const; + const CHARACTER_COMMUNITY& Community() const; + SSpecificCharacterData::SMoneyDef& MoneyDef() { return data()->money_def; } #endif - CHARACTER_RANK_VALUE Rank () const ; - CHARACTER_REPUTATION_VALUE Reputation () const ; - LPCSTR Visual () const ; - -#ifdef XRGAME_EXPORTS - LPCSTR SupplySpawn () const ; - LPCSTR NpcConfigSect () const ; - LPCSTR sound_voice_prefix () const ; - float panic_threshold () const ; - float hit_probability_factor () const ; - int crouch_type () const ; - bool upgrade_mechanic () const ; - LPCSTR critical_wound_weights () const ; - - const shared_str& IconName () const {return data()->m_icon_name;}; + CHARACTER_RANK_VALUE Rank() const; + CHARACTER_REPUTATION_VALUE Reputation() const; + LPCSTR Visual() const; + +#ifdef XRGAME_EXPORTS + LPCSTR SupplySpawn() const; + LPCSTR NpcConfigSect() const; + LPCSTR sound_voice_prefix() const; + float panic_threshold() const; + float hit_probability_factor() const; + int crouch_type() const; + bool upgrade_mechanic() const; + LPCSTR critical_wound_weights() const; + + const shared_str& IconName() const { return data()->m_icon_name; }; #endif - shared_str terrain_sect () const; + shared_str terrain_sect() const; }; - ////////////////////////////////////////////////////////////////////////// diff --git a/src/xrServerEntities/xml_str_id_loader.h b/src/xrServerEntities/xml_str_id_loader.h index 7ca1f65feee..ffed1b59512 100644 --- a/src/xrServerEntities/xml_str_id_loader.h +++ b/src/xrServerEntities/xml_str_id_loader.h @@ -1,75 +1,72 @@ #pragma once #ifdef XRGAME_EXPORTS -# include "ui/xrUIXmlParser.h" -#else // XRGAME_EXPORTS -# include "xrUIXmlParser.h" -# include "Common/object_broker.h" -#endif // XRGAME_EXPORTS - - -//T_ID - óíèêàëüíûé òåêñòîâûé èäåíòèôèêàòîð (àòòðèáóò id â XML ôàéëå) -//T_INDEX - óíèêàëüíûé ÷èñëîâîé èíäåêñ -//T_INIT - êëàññ ãäå îïðåäåëåíà ñòàòè÷åñêàÿ InitXmlIdToIndex +#include "ui/xrUIXmlParser.h" +#else // XRGAME_EXPORTS +#include "xrUIXmlParser.h" +#include "Common/object_broker.h" +#endif // XRGAME_EXPORTS + +// T_ID - óíèêàëüíûé òåêñòîâûé èäåíòèôèêàòîð (àòòðèáóò id â XML ôàéëå) +// T_INDEX - óíèêàëüíûé ÷èñëîâîé èíäåêñ +// T_INIT - êëàññ ãäå îïðåäåëåíà ñòàòè÷åñêàÿ InitXmlIdToIndex // ôóíêöèÿ èíèöèàëèçàöèè file_str è tag_name -//ñòðóêòóðà õðàíèò ñòðîêîâûé id ýëåìåíòà +//ñòðóêòóðà õðàíèò ñòðîêîâûé id ýëåìåíòà //ôàéë è ïîçèöèþ, ãäå ýòîò ýëåìåíò íàõîäèòñÿ struct ITEM_DATA { - shared_str id; - int index; - int pos_in_file; - CUIXml* _xml; + shared_str id; + int index; + int pos_in_file; + CUIXml* _xml; }; -typedef xr_vector T_VECTOR; +typedef xr_vector T_VECTOR; void _destroy_item_data_vector_cont(T_VECTOR* vec); -#define TEMPLATE_SPECIALIZATION template +#define TEMPLATE_SPECIALIZATION template #define CSXML_IdToIndex CXML_IdToIndex TEMPLATE_SPECIALIZATION class CXML_IdToIndex { public: - private: - static T_VECTOR* m_pItemDataVector; + static T_VECTOR* m_pItemDataVector; protected: - //èìåíà xml ôàéëîâ (ðàçäåëåííûõ çàïÿòîé) èç êîòîðûõ - //ïðîèçâîäèòü çàãðóçêó ýëåìåíòîâ - static LPCSTR file_str; - //èìåíà òåãîâ - static LPCSTR tag_name; -public: - CXML_IdToIndex (); - virtual ~CXML_IdToIndex (); + //èìåíà xml ôàéëîâ (ðàçäåëåííûõ çàïÿòîé) èç êîòîðûõ + //ïðîèçâîäèòü çàãðóçêó ýëåìåíòîâ + static LPCSTR file_str; + //èìåíà òåãîâ + static LPCSTR tag_name; - static void InitInternal (); - - static const ITEM_DATA* GetById (const shared_str& str_id, bool no_assert = false); - static const ITEM_DATA* GetByIndex (int index, bool no_assert = false); - - static const int IdToIndex (const shared_str& str_id, int default_index = T_INDEX(-1), bool no_assert = false) -{ - const ITEM_DATA* item = GetById(str_id, no_assert); - return item?item->index:default_index; - } - static const shared_str IndexToId (int index, shared_str default_id = NULL, bool no_assert = false) - { - const ITEM_DATA* item = GetByIndex(index, no_assert); - return item?item->id:default_id; - } - - static const int GetMaxIndex () {return m_pItemDataVector->size()-1;} - - //óäàëåíèå ñòàòè÷åêîãî ìàññèâà - static void DeleteIdToIndexData (); +public: + CXML_IdToIndex(); + virtual ~CXML_IdToIndex(); + + static void InitInternal(); + + static const ITEM_DATA* GetById(const shared_str& str_id, bool no_assert = false); + static const ITEM_DATA* GetByIndex(int index, bool no_assert = false); + + static const int IdToIndex(const shared_str& str_id, int default_index = T_INDEX(-1), bool no_assert = false) + { + const ITEM_DATA* item = GetById(str_id, no_assert); + return item ? item->index : default_index; + } + static const shared_str IndexToId(int index, shared_str default_id = NULL, bool no_assert = false) + { + const ITEM_DATA* item = GetByIndex(index, no_assert); + return item ? item->id : default_id; + } + + static const int GetMaxIndex() { return m_pItemDataVector->size() - 1; } + //óäàëåíèå ñòàòè÷åêîãî ìàññèâà + static void DeleteIdToIndexData(); }; - TEMPLATE_SPECIALIZATION typename T_VECTOR* CSXML_IdToIndex::m_pItemDataVector = NULL; @@ -78,123 +75,113 @@ LPCSTR CSXML_IdToIndex::file_str = NULL; TEMPLATE_SPECIALIZATION LPCSTR CSXML_IdToIndex::tag_name = NULL; - TEMPLATE_SPECIALIZATION CSXML_IdToIndex::CXML_IdToIndex() { } - TEMPLATE_SPECIALIZATION CSXML_IdToIndex::~CXML_IdToIndex() { } - TEMPLATE_SPECIALIZATION -const typename ITEM_DATA* CSXML_IdToIndex::GetById (const shared_str& str_id, bool no_assert) +const typename ITEM_DATA* CSXML_IdToIndex::GetById(const shared_str& str_id, bool no_assert) { - T_INIT::InitXmlIdToIndex(); + T_INIT::InitXmlIdToIndex(); T_VECTOR::iterator it; - for (it = m_pItemDataVector->begin(); m_pItemDataVector->end()!=it; it++) - { - if ((*it).id == str_id) - break; - } - - if (it==m_pItemDataVector->end()) - { - int i=0; - for (it = m_pItemDataVector->begin(); m_pItemDataVector->end()!=it; it++, i++) - Msg("[%d]=[%s]",i,*(*it).id ); - - R_ASSERT3(no_assert, "item not found, id", *str_id); - return NULL; - } - - return &(*it); + for (it = m_pItemDataVector->begin(); m_pItemDataVector->end() != it; it++) + { + if ((*it).id == str_id) break; + } + + if (it == m_pItemDataVector->end()) { + int i = 0; + for (it = m_pItemDataVector->begin(); m_pItemDataVector->end() != it; it++, i++) + Msg("[%d]=[%s]", i, *(*it).id); + + R_ASSERT3(no_assert, "item not found, id", *str_id); + return NULL; + } + + return &(*it); } TEMPLATE_SPECIALIZATION const typename ITEM_DATA* CSXML_IdToIndex::GetByIndex(int index, bool no_assert) { - if((size_t)index>=m_pItemDataVector->size()) - { - R_ASSERT3(no_assert, "item by index not found in files", file_str); - return NULL; - } - return &(*m_pItemDataVector)[index]; + if ((size_t)index >= m_pItemDataVector->size()) { + R_ASSERT3(no_assert, "item by index not found in files", file_str); + return NULL; + } + return &(*m_pItemDataVector)[index]; } TEMPLATE_SPECIALIZATION -void CSXML_IdToIndex::DeleteIdToIndexData () +void CSXML_IdToIndex::DeleteIdToIndexData() { - VERIFY (m_pItemDataVector); - _destroy_item_data_vector_cont (m_pItemDataVector); + VERIFY(m_pItemDataVector); + _destroy_item_data_vector_cont(m_pItemDataVector); - xr_delete (m_pItemDataVector); + xr_delete(m_pItemDataVector); } TEMPLATE_SPECIALIZATION -typename void CSXML_IdToIndex::InitInternal () +typename void CSXML_IdToIndex::InitInternal() { - VERIFY(!m_pItemDataVector); - T_INIT::InitXmlIdToIndex(); - - m_pItemDataVector = new T_VECTOR(); - - VERIFY(file_str); - VERIFY(tag_name); - - string_path xml_file; - int count = _GetItemCount (file_str); - int index = 0; - for (int it=0; itLoad (CONFIG_PATH, "gameplay", xml_file_full.c_str()); - - //îáùèé ñïèñîê - int items_num = uiXml->GetNodesNum(uiXml->GetRoot(), tag_name); - - for(int i=0; iReadAttrib(uiXml->GetRoot(), tag_name, i, "id", NULL); - - string256 buf; - xr_sprintf (buf, "id for item don't set, number %d in %s", i, xml_file); - R_ASSERT2 (item_name, buf); - - - //ïðîâåðåòèòü ID íà óíèêàëüíîñòü - T_VECTOR::iterator t_it = m_pItemDataVector->begin(); - for(;m_pItemDataVector->end() != t_it; t_it++) - { - if(shared_str((*t_it).id) == shared_str(item_name)) - break; - } - - R_ASSERT3(m_pItemDataVector->end() == t_it, "duplicate item id", item_name); - - ITEM_DATA data; - data.id = item_name; - data.index = index; - data.pos_in_file = i; -//. data.file_name = xml_file; - data._xml = uiXml; - m_pItemDataVector->push_back(data); - - index++; - } - if(0==items_num) - delete_data(uiXml); - } + VERIFY(!m_pItemDataVector); + T_INIT::InitXmlIdToIndex(); + + m_pItemDataVector = new T_VECTOR(); + + VERIFY(file_str); + VERIFY(tag_name); + + string_path xml_file; + int count = _GetItemCount(file_str); + int index = 0; + for (int it = 0; it < count; ++it) + { + _GetItem(file_str, it, xml_file); + + CUIXml* uiXml = new CUIXml(); + xr_string xml_file_full; + xml_file_full = xml_file; + xml_file_full += ".xml"; + uiXml->Load(CONFIG_PATH, "gameplay", xml_file_full.c_str()); + + //îáùèé ñïèñîê + int items_num = uiXml->GetNodesNum(uiXml->GetRoot(), tag_name); + + for (int i = 0; i < items_num; ++i) + { + LPCSTR item_name = uiXml->ReadAttrib(uiXml->GetRoot(), tag_name, i, "id", NULL); + + string256 buf; + xr_sprintf(buf, "id for item don't set, number %d in %s", i, xml_file); + R_ASSERT2(item_name, buf); + + //ïðîâåðåòèòü ID íà óíèêàëüíîñòü + T_VECTOR::iterator t_it = m_pItemDataVector->begin(); + for (; m_pItemDataVector->end() != t_it; t_it++) + { + if (shared_str((*t_it).id) == shared_str(item_name)) break; + } + + R_ASSERT3(m_pItemDataVector->end() == t_it, "duplicate item id", item_name); + + ITEM_DATA data; + data.id = item_name; + data.index = index; + data.pos_in_file = i; + //. data.file_name = xml_file; + data._xml = uiXml; + m_pItemDataVector->push_back(data); + + index++; + } + if (0 == items_num) delete_data(uiXml); + } } #undef TEMPLATE_SPECIALIZATION - diff --git a/src/xrServerEntities/xrEProps.h b/src/xrServerEntities/xrEProps.h index 68375a228b0..bcf98f2d8d4 100644 --- a/src/xrServerEntities/xrEProps.h +++ b/src/xrServerEntities/xrEProps.h @@ -6,151 +6,181 @@ #ifdef XR_EPROPS_EXPORTS #define XR_EPROPS_API XR_EXPORT #else -# ifndef XR_EPROPS_API -# define XR_EPROPS_API XR_IMPORT -# endif +#ifndef XR_EPROPS_API +#define XR_EPROPS_API XR_IMPORT +#endif #endif -#include "PropertiesListTypes.h" #include "ItemListTypes.h" - -enum EItemType{ - TYPE_INVALID= -1, - TYPE_FOLDER = 0, - TYPE_OBJECT = 1 +#include "PropertiesListTypes.h" + +enum EItemType +{ + TYPE_INVALID = -1, + TYPE_FOLDER = 0, + TYPE_OBJECT = 1 }; -typedef fastdelegate::FastDelegate1 TOnILItemsFocused; -typedef fastdelegate::FastDelegate0<> TOnILCloseEvent; -typedef fastdelegate::FastDelegate3 TOnItemRename; -typedef fastdelegate::FastDelegate3 TOnItemRemove; -typedef fastdelegate::FastDelegate0<> TOnItemAfterRemove; -typedef fastdelegate::FastDelegate0<> TOnCloseEvent; -typedef fastdelegate::FastDelegate0<> TOnModifiedEvent; +typedef fastdelegate::FastDelegate1 TOnILItemsFocused; +typedef fastdelegate::FastDelegate0<> TOnILCloseEvent; +typedef fastdelegate::FastDelegate3 TOnItemRename; +typedef fastdelegate::FastDelegate3 TOnItemRemove; +typedef fastdelegate::FastDelegate0<> TOnItemAfterRemove; +typedef fastdelegate::FastDelegate0<> TOnCloseEvent; +typedef fastdelegate::FastDelegate0<> TOnModifiedEvent; #ifdef __BORLANDC__ -# include "mxPlacemnt.hpp" - typedef fastdelegate::FastDelegate1 TOnILItemFocused; - //--------------------------------------------------------------------------- - void XR_EPROPS_API CheckWindowPos(TForm* form); - //--------------------------------------------------------------------------- +#include "mxPlacemnt.hpp" +typedef fastdelegate::FastDelegate1 TOnILItemFocused; +//--------------------------------------------------------------------------- +void XR_EPROPS_API CheckWindowPos(TForm* form); +//--------------------------------------------------------------------------- #endif //------------------------------------------------------------------------------ // Prepare Key //------------------------------------------------------------------------------ -IC xr_string FolderAppend (LPCSTR val) +IC xr_string FolderAppend(LPCSTR val) { - xr_string tmp = (val&&val[0])?val:""; - if (val&&val[0])tmp += "\\"; - return tmp; + xr_string tmp = (val && val[0]) ? val : ""; + if (val && val[0]) tmp += "\\"; + return tmp; } -IC shared_str PrepareKey (LPCSTR pref, LPCSTR key) +IC shared_str PrepareKey(LPCSTR pref, LPCSTR key) { - R_ASSERT (key); - return shared_str(xr_string(FolderAppend(pref)+key).c_str()); + R_ASSERT(key); + return shared_str(xr_string(FolderAppend(pref) + key).c_str()); } -IC shared_str PrepareKey (LPCSTR pref0, LPCSTR pref1, LPCSTR key) +IC shared_str PrepareKey(LPCSTR pref0, LPCSTR pref1, LPCSTR key) { - R_ASSERT (key); - return shared_str(xr_string(FolderAppend(pref0)+FolderAppend(pref1)+key).c_str()); + R_ASSERT(key); + return shared_str(xr_string(FolderAppend(pref0) + FolderAppend(pref1) + key).c_str()); } -IC shared_str PrepareKey (LPCSTR pref0, LPCSTR pref1, LPCSTR pref2, LPCSTR key) +IC shared_str PrepareKey(LPCSTR pref0, LPCSTR pref1, LPCSTR pref2, LPCSTR key) { - R_ASSERT (key); - return shared_str(xr_string(FolderAppend(pref0)+FolderAppend(pref1)+FolderAppend(pref2)+key).c_str()); + R_ASSERT(key); + return shared_str(xr_string(FolderAppend(pref0) + FolderAppend(pref1) + FolderAppend(pref2) + key).c_str()); } //------------------------------------------------------------------------------ // Properties //------------------------------------------------------------------------------ -class XR_EPROPS_API IPropHelper{ +class XR_EPROPS_API IPropHelper +{ public: - virtual PropItem* __stdcall FindItem (PropItemVec& items, shared_str key, EPropType type=PROP_UNDEF)=0; + virtual PropItem* __stdcall FindItem(PropItemVec& items, shared_str key, EPropType type = PROP_UNDEF) = 0; + public: -//------------------------------------------------------------------------------ -// predefind event routines - virtual bool __stdcall FvectorRDOnAfterEdit(PropValue* sender, Fvector& edit_val)=0; - virtual void __stdcall FvectorRDOnBeforeEdit(PropValue* sender,Fvector& edit_val)=0; - virtual void __stdcall FvectorRDOnDraw (PropValue* sender, xr_string& draw_val)=0; - virtual bool __stdcall floatRDOnAfterEdit (PropValue* sender, float& edit_val)=0; - virtual void __stdcall floatRDOnBeforeEdit (PropValue* sender, float& edit_val)=0; - virtual void __stdcall floatRDOnDraw (PropValue* sender, xr_string& draw_val)=0; -// R-name edit - virtual void __stdcall NameBeforeEdit (PropValue* sender, shared_str& edit_val)=0; - virtual bool __stdcall NameAfterEdit (PropValue* sender, shared_str& edit_val)=0; - virtual void __stdcall NameDraw (PropValue* sender, xr_string& draw_val)=0; -// C-name edit - virtual void __stdcall CNameBeforeEdit (PropValue* sender, xr_string& edit_val)=0; - virtual bool __stdcall CNameAfterEdit (PropValue* sender, xr_string& edit_val)=0; - virtual void __stdcall CNameDraw (PropValue* sender, xr_string& draw_val)=0; + //------------------------------------------------------------------------------ + // predefind event routines + virtual bool __stdcall FvectorRDOnAfterEdit(PropValue* sender, Fvector& edit_val) = 0; + virtual void __stdcall FvectorRDOnBeforeEdit(PropValue* sender, Fvector& edit_val) = 0; + virtual void __stdcall FvectorRDOnDraw(PropValue* sender, xr_string& draw_val) = 0; + virtual bool __stdcall floatRDOnAfterEdit(PropValue* sender, float& edit_val) = 0; + virtual void __stdcall floatRDOnBeforeEdit(PropValue* sender, float& edit_val) = 0; + virtual void __stdcall floatRDOnDraw(PropValue* sender, xr_string& draw_val) = 0; + // R-name edit + virtual void __stdcall NameBeforeEdit(PropValue* sender, shared_str& edit_val) = 0; + virtual bool __stdcall NameAfterEdit(PropValue* sender, shared_str& edit_val) = 0; + virtual void __stdcall NameDraw(PropValue* sender, xr_string& draw_val) = 0; + // C-name edit + virtual void __stdcall CNameBeforeEdit(PropValue* sender, xr_string& edit_val) = 0; + virtual bool __stdcall CNameAfterEdit(PropValue* sender, xr_string& edit_val) = 0; + virtual void __stdcall CNameDraw(PropValue* sender, xr_string& draw_val) = 0; + public: - virtual CaptionValue* __stdcall CreateCaption (PropItemVec& items, shared_str key, shared_str val)=0; - virtual CanvasValue* __stdcall CreateCanvas (PropItemVec& items, shared_str key, shared_str val, int height)=0; - virtual ButtonValue* __stdcall CreateButton (PropItemVec& items, shared_str key, shared_str val, u32 flags, ButtonValue::TOnBtnClick onclick=0)=0; - virtual ChooseValue* __stdcall CreateChoose (PropItemVec& items, shared_str key, shared_str* val, u32 mode, LPCSTR path=0, void* fill_param=0, u32 sub_item_count=1, u32 choose_flags=cfAllowNone)=0; - virtual S8Value* __stdcall CreateS8 (PropItemVec& items, shared_str key, s8* val, s8 mn=0, s8 mx=100, s8 inc=1)=0; - virtual S16Value* __stdcall CreateS16 (PropItemVec& items, shared_str key, s16* val, s16 mn=0, s16 mx=100, s16 inc=1)=0; - virtual S32Value* __stdcall CreateS32 (PropItemVec& items, shared_str key, s32* val, s32 mn=0, s32 mx=100, s32 inc=1)=0; - virtual U8Value* __stdcall CreateU8 (PropItemVec& items, shared_str key, u8* val, u8 mn=0, u8 mx=100, u8 inc=1)=0; - virtual U16Value* __stdcall CreateU16 (PropItemVec& items, shared_str key, u16* val, u16 mn=0, u16 mx=100, u16 inc=1)=0; - virtual U32Value* __stdcall CreateU32 (PropItemVec& items, shared_str key, u32* val, u32 mn=0, u32 mx=100, u32 inc=1)=0; - virtual FloatValue* __stdcall CreateFloat (PropItemVec& items, shared_str key, float* val, float mn=0.f, float mx=1.f, float inc=0.01f, int decim=2)=0; - virtual BOOLValue* __stdcall CreateBOOL (PropItemVec& items, shared_str key, BOOL* val)=0; - virtual VectorValue* __stdcall CreateVector (PropItemVec& items, shared_str key, Fvector* val, float mn=0.f, float mx=1.f, float inc=0.01f, int decim=2)=0; - virtual Flag8Value* __stdcall CreateFlag8 (PropItemVec& items, shared_str key, Flags8* val, u8 mask, LPCSTR c0=0, LPCSTR c1=0, u32 flags=0)=0; - virtual Flag16Value* __stdcall CreateFlag16 (PropItemVec& items, shared_str key, Flags16* val, u16 mask, LPCSTR c0=0, LPCSTR c1=0, u32 flags=0)=0; - virtual Flag32Value* __stdcall CreateFlag32 (PropItemVec& items, shared_str key, Flags32* val, u32 mask, LPCSTR c0=0, LPCSTR c1=0, u32 flags=0)=0; - virtual Token8Value* __stdcall CreateToken8 (PropItemVec& items, shared_str key, u8* val, xr_token* token)=0; - virtual Token16Value* __stdcall CreateToken16 (PropItemVec& items, shared_str key, u16* val, xr_token* token)=0; - virtual Token32Value* __stdcall CreateToken32 (PropItemVec& items, shared_str key, u32* val, xr_token* token)=0; - virtual RToken8Value* __stdcall CreateRToken8 (PropItemVec& items, shared_str key, u8* val, xr_rtoken* token, u32 t_cnt)=0; - virtual RToken16Value* __stdcall CreateRToken16 (PropItemVec& items, shared_str key, u16* val, xr_rtoken* token, u32 t_cnt)=0; - virtual RToken32Value* __stdcall CreateRToken32 (PropItemVec& items, shared_str key, u32* val, xr_rtoken* token, u32 t_cnt)=0; - virtual RListValue* __stdcall CreateRList (PropItemVec& items, shared_str key, shared_str* val, shared_str* lst, u32 cnt)=0; - virtual U32Value* __stdcall CreateColor (PropItemVec& items, shared_str key, u32* val)=0; - virtual ColorValue* __stdcall CreateFColor (PropItemVec& items, shared_str key, Fcolor* val)=0; - virtual VectorValue* __stdcall CreateVColor (PropItemVec& items, shared_str key, Fvector* val)=0; - virtual RTextValue* __stdcall CreateRText (PropItemVec& items, shared_str key, shared_str* val)=0; - virtual STextValue* __stdcall CreateSText (PropItemVec& items, shared_str key, xr_string* val)=0; - virtual WaveValue* __stdcall CreateWave (PropItemVec& items, shared_str key, WaveForm* val)=0; - virtual FloatValue* __stdcall CreateTime (PropItemVec& items, shared_str key, float* val, float mn=0.f, float mx=86400.f)=0; - virtual ShortcutValue* __stdcall CreateShortcut (PropItemVec& items, shared_str key, xr_shortcut* val)=0; + virtual CaptionValue* __stdcall CreateCaption(PropItemVec& items, shared_str key, shared_str val) = 0; + virtual CanvasValue* __stdcall CreateCanvas(PropItemVec& items, shared_str key, shared_str val, int height) = 0; + virtual ButtonValue* __stdcall CreateButton( + PropItemVec& items, shared_str key, shared_str val, u32 flags, ButtonValue::TOnBtnClick onclick = 0) = 0; + virtual ChooseValue* __stdcall CreateChoose(PropItemVec& items, shared_str key, shared_str* val, u32 mode, + LPCSTR path = 0, void* fill_param = 0, u32 sub_item_count = 1, u32 choose_flags = cfAllowNone) = 0; + virtual S8Value* __stdcall CreateS8( + PropItemVec& items, shared_str key, s8* val, s8 mn = 0, s8 mx = 100, s8 inc = 1) = 0; + virtual S16Value* __stdcall CreateS16( + PropItemVec& items, shared_str key, s16* val, s16 mn = 0, s16 mx = 100, s16 inc = 1) = 0; + virtual S32Value* __stdcall CreateS32( + PropItemVec& items, shared_str key, s32* val, s32 mn = 0, s32 mx = 100, s32 inc = 1) = 0; + virtual U8Value* __stdcall CreateU8( + PropItemVec& items, shared_str key, u8* val, u8 mn = 0, u8 mx = 100, u8 inc = 1) = 0; + virtual U16Value* __stdcall CreateU16( + PropItemVec& items, shared_str key, u16* val, u16 mn = 0, u16 mx = 100, u16 inc = 1) = 0; + virtual U32Value* __stdcall CreateU32( + PropItemVec& items, shared_str key, u32* val, u32 mn = 0, u32 mx = 100, u32 inc = 1) = 0; + virtual FloatValue* __stdcall CreateFloat(PropItemVec& items, shared_str key, float* val, float mn = 0.f, + float mx = 1.f, float inc = 0.01f, int decim = 2) = 0; + virtual BOOLValue* __stdcall CreateBOOL(PropItemVec& items, shared_str key, BOOL* val) = 0; + virtual VectorValue* __stdcall CreateVector(PropItemVec& items, shared_str key, Fvector* val, float mn = 0.f, + float mx = 1.f, float inc = 0.01f, int decim = 2) = 0; + virtual Flag8Value* __stdcall CreateFlag8( + PropItemVec& items, shared_str key, Flags8* val, u8 mask, LPCSTR c0 = 0, LPCSTR c1 = 0, u32 flags = 0) = 0; + virtual Flag16Value* __stdcall CreateFlag16( + PropItemVec& items, shared_str key, Flags16* val, u16 mask, LPCSTR c0 = 0, LPCSTR c1 = 0, u32 flags = 0) = 0; + virtual Flag32Value* __stdcall CreateFlag32( + PropItemVec& items, shared_str key, Flags32* val, u32 mask, LPCSTR c0 = 0, LPCSTR c1 = 0, u32 flags = 0) = 0; + virtual Token8Value* __stdcall CreateToken8(PropItemVec& items, shared_str key, u8* val, xr_token* token) = 0; + virtual Token16Value* __stdcall CreateToken16(PropItemVec& items, shared_str key, u16* val, xr_token* token) = 0; + virtual Token32Value* __stdcall CreateToken32(PropItemVec& items, shared_str key, u32* val, xr_token* token) = 0; + virtual RToken8Value* __stdcall CreateRToken8( + PropItemVec& items, shared_str key, u8* val, xr_rtoken* token, u32 t_cnt) = 0; + virtual RToken16Value* __stdcall CreateRToken16( + PropItemVec& items, shared_str key, u16* val, xr_rtoken* token, u32 t_cnt) = 0; + virtual RToken32Value* __stdcall CreateRToken32( + PropItemVec& items, shared_str key, u32* val, xr_rtoken* token, u32 t_cnt) = 0; + virtual RListValue* __stdcall CreateRList( + PropItemVec& items, shared_str key, shared_str* val, shared_str* lst, u32 cnt) = 0; + virtual U32Value* __stdcall CreateColor(PropItemVec& items, shared_str key, u32* val) = 0; + virtual ColorValue* __stdcall CreateFColor(PropItemVec& items, shared_str key, Fcolor* val) = 0; + virtual VectorValue* __stdcall CreateVColor(PropItemVec& items, shared_str key, Fvector* val) = 0; + virtual RTextValue* __stdcall CreateRText(PropItemVec& items, shared_str key, shared_str* val) = 0; + virtual STextValue* __stdcall CreateSText(PropItemVec& items, shared_str key, xr_string* val) = 0; + virtual WaveValue* __stdcall CreateWave(PropItemVec& items, shared_str key, WaveForm* val) = 0; + virtual FloatValue* __stdcall CreateTime( + PropItemVec& items, shared_str key, float* val, float mn = 0.f, float mx = 86400.f) = 0; + virtual ShortcutValue* __stdcall CreateShortcut(PropItemVec& items, shared_str key, xr_shortcut* val) = 0; - virtual FloatValue* __stdcall CreateAngle (PropItemVec& items, shared_str key, float* val, float mn=flt_min, float mx=flt_max, float inc=0.01f, int decim=2)=0; - virtual VectorValue* __stdcall CreateAngle3 (PropItemVec& items, shared_str key, Fvector* val, float mn=flt_min, float mx=flt_max, float inc=0.01f, int decim=2)=0; - virtual RTextValue* __stdcall CreateName (PropItemVec& items, shared_str key, shared_str* val, ListItem* owner)=0; - virtual RTextValue* __stdcall CreateNameCB (PropItemVec& items, shared_str key, shared_str* val, TOnDrawTextEvent=0, RTextValue::TOnBeforeEditEvent=0, RTextValue::TOnAfterEditEvent=0)=0; + virtual FloatValue* __stdcall CreateAngle(PropItemVec& items, shared_str key, float* val, float mn = flt_min, + float mx = flt_max, float inc = 0.01f, int decim = 2) = 0; + virtual VectorValue* __stdcall CreateAngle3(PropItemVec& items, shared_str key, Fvector* val, float mn = flt_min, + float mx = flt_max, float inc = 0.01f, int decim = 2) = 0; + virtual RTextValue* __stdcall CreateName(PropItemVec& items, shared_str key, shared_str* val, ListItem* owner) = 0; + virtual RTextValue* __stdcall CreateNameCB(PropItemVec& items, shared_str key, shared_str* val, + TOnDrawTextEvent = 0, RTextValue::TOnBeforeEditEvent = 0, RTextValue::TOnAfterEditEvent = 0) = 0; - virtual GameTypeValue* __stdcall CreateGameType (PropItemVec& items, shared_str key, GameTypeChooser* val)=0; - // obsolette - virtual CTextValue* __stdcall CreateCText (PropItemVec& items, shared_str key, LPSTR val, u32 sz)=0; - virtual CListValue* __stdcall CreateCList (PropItemVec& items, shared_str key, LPSTR val, u32 sz, xr_string* lst, u32 cnt)=0; - virtual CTextValue* __stdcall CreateCName (PropItemVec& items, shared_str key, LPSTR val, u32 sz, ListItem* owner)=0; - virtual TokenValueSH* __stdcall CreateTokenSH (PropItemVec& items, shared_str key, u32* val, const TokenValueSH::Item* lst, u32 cnt)=0; - virtual CTextValue* __stdcall CreateTexture (PropItemVec& items, shared_str key, LPSTR val, u32 sz)=0; + virtual GameTypeValue* __stdcall CreateGameType(PropItemVec& items, shared_str key, GameTypeChooser* val) = 0; + // obsolette + virtual CTextValue* __stdcall CreateCText(PropItemVec& items, shared_str key, LPSTR val, u32 sz) = 0; + virtual CListValue* __stdcall CreateCList( + PropItemVec& items, shared_str key, LPSTR val, u32 sz, xr_string* lst, u32 cnt) = 0; + virtual CTextValue* __stdcall CreateCName( + PropItemVec& items, shared_str key, LPSTR val, u32 sz, ListItem* owner) = 0; + virtual TokenValueSH* __stdcall CreateTokenSH( + PropItemVec& items, shared_str key, u32* val, const TokenValueSH::Item* lst, u32 cnt) = 0; + virtual CTextValue* __stdcall CreateTexture(PropItemVec& items, shared_str key, LPSTR val, u32 sz) = 0; }; //--------------------------------------------------------------------------- #ifdef __BORLANDC__ - extern "C" XR_EPROPS_API IPropHelper& PHelper (); +extern "C" XR_EPROPS_API IPropHelper& PHelper(); #else - extern IPropHelper &PHelper(); +extern IPropHelper& PHelper(); #endif //--------------------------------------------------------------------------- //------------------------------------------------------------------------------ // List //------------------------------------------------------------------------------ -class XR_EPROPS_API IListHelper{ +class XR_EPROPS_API IListHelper +{ public: - virtual ListItem* __stdcall FindItem (ListItemsVec& items, LPCSTR key)=0; - virtual bool __stdcall NameAfterEdit (ListItem* sender, LPCSTR value, shared_str& edit_val)=0; + virtual ListItem* __stdcall FindItem(ListItemsVec& items, LPCSTR key) = 0; + virtual bool __stdcall NameAfterEdit(ListItem* sender, LPCSTR value, shared_str& edit_val) = 0; + public: - virtual ListItem* __stdcall CreateItem (ListItemsVec& items, LPCSTR key, int type, u32 item_flags=0, void* object=0)=0; + virtual ListItem* __stdcall CreateItem( + ListItemsVec& items, LPCSTR key, int type, u32 item_flags = 0, void* object = 0) = 0; }; #ifdef __BORLANDC__ - extern "C" XR_EPROPS_API IListHelper& LHelper (); +extern "C" XR_EPROPS_API IListHelper& LHelper(); #endif #endif - \ No newline at end of file diff --git a/src/xrServerEntities/xrMessages.h b/src/xrServerEntities/xrMessages.h index f2aa875ed0a..b5b5078426d 100644 --- a/src/xrServerEntities/xrMessages.h +++ b/src/xrServerEntities/xrMessages.h @@ -6,254 +6,253 @@ // CL == client 2 server message // SV == server 2 client message -enum { - M_UPDATE = 0, // DUAL: Update state - M_SPAWN, // DUAL: Spawning, full state - - M_SV_CONFIG_NEW_CLIENT, - M_SV_CONFIG_GAME, - M_SV_CONFIG_FINISHED, - - M_MIGRATE_DEACTIVATE, // TO: Changing server, just deactivate - M_MIGRATE_ACTIVATE, // TO: Changing server, full state - - M_CHAT, // DUAL: - - M_EVENT, // Game Event - M_CL_INPUT, // Client Input Data - //----------- for E3 ----------------------------- - M_CL_UPDATE, - M_UPDATE_OBJECTS, - //------------------------------------------------- - M_CLIENTREADY, // Client has finished to load level and are ready to play - - M_CHANGE_LEVEL, // changing level - M_LOAD_GAME, - M_RELOAD_GAME, - M_SAVE_GAME, - M_SAVE_PACKET, - - M_SWITCH_DISTANCE, - M_GAMEMESSAGE, // Game Message - M_EVENT_PACK, // Pack of M_EVENT - - //----------------------------------------------------- - M_GAMESPY_CDKEY_VALIDATION_CHALLENGE, - M_GAMESPY_CDKEY_VALIDATION_CHALLENGE_RESPOND, - M_CLIENT_CONNECT_RESULT, - M_CLIENT_REQUEST_CONNECTION_DATA, - - M_CHAT_MESSAGE, - M_CLIENT_WARN, - M_CHANGE_LEVEL_GAME, - //----------------------------------------------------- - M_CL_PING_CHALLENGE, - M_CL_PING_CHALLENGE_RESPOND, - //----------------------------------------------------- - M_AUTH_CHALLENGE, - M_CL_AUTH, - M_BULLET_CHECK_RESPOND, - //----------------------------------------------------- - M_STATISTIC_UPDATE, - M_STATISTIC_UPDATE_RESPOND, - //----------------------------------------------------- - M_PLAYER_FIRE, - //----------------------------------------------------- - M_MOVE_PLAYERS, - M_MOVE_ARTEFACTS, - M_MOVE_PLAYERS_RESPOND, - //----------------------------------------------------- - M_CHANGE_SELF_NAME, - M_REMOTE_CONTROL_AUTH, - M_REMOTE_CONTROL_CMD, - M_BATTLEYE, - - M_SV_MAP_NAME, //request and responce - M_SV_DIGEST, //request and responce - - M_FILE_TRANSFER, - M_MAKE_SCREENSHOT, - M_SECURE_KEY_SYNC, - M_SECURE_MESSAGE, - M_CREATE_PLAYER_STATE, - M_COMPRESSED_UPDATE_OBJECTS, - - MSG_FORCEDWORD = u32(-1) +enum +{ + M_UPDATE = 0, // DUAL: Update state + M_SPAWN, // DUAL: Spawning, full state + + M_SV_CONFIG_NEW_CLIENT, + M_SV_CONFIG_GAME, + M_SV_CONFIG_FINISHED, + + M_MIGRATE_DEACTIVATE, // TO: Changing server, just deactivate + M_MIGRATE_ACTIVATE, // TO: Changing server, full state + + M_CHAT, // DUAL: + + M_EVENT, // Game Event + M_CL_INPUT, // Client Input Data + //----------- for E3 ----------------------------- + M_CL_UPDATE, + M_UPDATE_OBJECTS, + //------------------------------------------------- + M_CLIENTREADY, // Client has finished to load level and are ready to play + + M_CHANGE_LEVEL, // changing level + M_LOAD_GAME, + M_RELOAD_GAME, + M_SAVE_GAME, + M_SAVE_PACKET, + + M_SWITCH_DISTANCE, + M_GAMEMESSAGE, // Game Message + M_EVENT_PACK, // Pack of M_EVENT + + //----------------------------------------------------- + M_GAMESPY_CDKEY_VALIDATION_CHALLENGE, + M_GAMESPY_CDKEY_VALIDATION_CHALLENGE_RESPOND, + M_CLIENT_CONNECT_RESULT, + M_CLIENT_REQUEST_CONNECTION_DATA, + + M_CHAT_MESSAGE, + M_CLIENT_WARN, + M_CHANGE_LEVEL_GAME, + //----------------------------------------------------- + M_CL_PING_CHALLENGE, + M_CL_PING_CHALLENGE_RESPOND, + //----------------------------------------------------- + M_AUTH_CHALLENGE, + M_CL_AUTH, + M_BULLET_CHECK_RESPOND, + //----------------------------------------------------- + M_STATISTIC_UPDATE, + M_STATISTIC_UPDATE_RESPOND, + //----------------------------------------------------- + M_PLAYER_FIRE, + //----------------------------------------------------- + M_MOVE_PLAYERS, + M_MOVE_ARTEFACTS, + M_MOVE_PLAYERS_RESPOND, + //----------------------------------------------------- + M_CHANGE_SELF_NAME, + M_REMOTE_CONTROL_AUTH, + M_REMOTE_CONTROL_CMD, + M_BATTLEYE, + + M_SV_MAP_NAME, // request and responce + M_SV_DIGEST, // request and responce + + M_FILE_TRANSFER, + M_MAKE_SCREENSHOT, + M_SECURE_KEY_SYNC, + M_SECURE_MESSAGE, + M_CREATE_PLAYER_STATE, + M_COMPRESSED_UPDATE_OBJECTS, + + MSG_FORCEDWORD = u32(-1) }; -enum { - GE_RESPAWN, - GE_OWNERSHIP_TAKE, // DUAL: Client request for ownership of an item - GE_OWNERSHIP_TAKE_MP_FORCED, - GE_OWNERSHIP_REJECT, // DUAL: Client request ownership rejection - GE_TRANSFER_AMMO, // DUAL: Take ammo out of weapon for our weapon - GE_HIT, // - GE_DIE, // - GE_ASSIGN_KILLER, // - GE_DESTROY, // authorative client request for entity-destroy - GE_DESTROY_REJECT, // GE_DESTROY + GE_OWNERSHIP_REJECT - GE_TELEPORT_OBJECT, - - GE_ADD_RESTRICTION, - GE_REMOVE_RESTRICTION, - GE_REMOVE_ALL_RESTRICTIONS, - - GE_BUY, - - - GE_INFO_TRANSFER, //transfer _new_ info on PDA - - GE_TRADE_SELL, - GE_TRADE_BUY, - - GE_WPN_AMMO_ADD, - GE_WPN_STATE_CHANGE, - - GE_ADDON_ATTACH, - GE_ADDON_DETACH, - GE_ADDON_CHANGE, - GE_INSTALL_UPGRADE, - - GE_GRENADE_EXPLODE, - GE_INV_ACTION, //a action beign taken on inventory - GE_INV_BOX_STATUS, - GE_INV_OWNER_STATUS, - - GE_ZONE_STATE_CHANGE, - - GE_MOVE_ACTOR, //move actor to desired position instantly - GE_ACTOR_JUMPING, //actor press jump key - GE_ACTOR_MAX_POWER, - GE_ACTOR_MAX_HEALTH, - - GE_CHANGE_POS, - - GE_GAME_EVENT, - - GE_CHANGE_VISUAL, - GE_MONEY, - - GEG_PLAYER_ACTIVATE_SLOT, - GEG_PLAYER_ITEM2SLOT, - GEG_PLAYER_ITEM2BELT, - GEG_PLAYER_ITEM2RUCK, - GEG_PLAYER_ITEM_EAT, - GEG_PLAYER_ITEM_SELL, - GEG_PLAYER_ACTIVATEARTEFACT, - - GEG_PLAYER_WEAPON_HIDE_STATE, - GEG_PLAYER_DISABLE_SPRINT, - - - GEG_PLAYER_ATTACH_HOLDER, - GEG_PLAYER_DETACH_HOLDER, - - GEG_PLAYER_PLAY_HEADSHOT_PARTICLE, - //------------------------------------- - GE_HIT_STATISTIC, - //------------------------------------- - GE_KILL_SOMEONE, - - GE_FREEZE_OBJECT, - GE_LAUNCH_ROCKET, - - GEG_PLAYER_USE_BOOSTER, - GE_REQUEST_PLAYERS_INFO, - - GE_FORCEDWORD = u32(-1) -}; +enum +{ + GE_RESPAWN, + GE_OWNERSHIP_TAKE, // DUAL: Client request for ownership of an item + GE_OWNERSHIP_TAKE_MP_FORCED, + GE_OWNERSHIP_REJECT, // DUAL: Client request ownership rejection + GE_TRANSFER_AMMO, // DUAL: Take ammo out of weapon for our weapon + GE_HIT, // + GE_DIE, // + GE_ASSIGN_KILLER, // + GE_DESTROY, // authorative client request for entity-destroy + GE_DESTROY_REJECT, // GE_DESTROY + GE_OWNERSHIP_REJECT + GE_TELEPORT_OBJECT, + + GE_ADD_RESTRICTION, + GE_REMOVE_RESTRICTION, + GE_REMOVE_ALL_RESTRICTIONS, + + GE_BUY, + + GE_INFO_TRANSFER, // transfer _new_ info on PDA + + GE_TRADE_SELL, + GE_TRADE_BUY, + + GE_WPN_AMMO_ADD, + GE_WPN_STATE_CHANGE, + + GE_ADDON_ATTACH, + GE_ADDON_DETACH, + GE_ADDON_CHANGE, + GE_INSTALL_UPGRADE, + + GE_GRENADE_EXPLODE, + GE_INV_ACTION, // a action beign taken on inventory + GE_INV_BOX_STATUS, + GE_INV_OWNER_STATUS, + + GE_ZONE_STATE_CHANGE, + GE_MOVE_ACTOR, // move actor to desired position instantly + GE_ACTOR_JUMPING, // actor press jump key + GE_ACTOR_MAX_POWER, + GE_ACTOR_MAX_HEALTH, -enum EGameMessages { //game_cl <----> game_sv messages - GAME_EVENT_PLAYER_READY, - GAME_EVENT_PLAYER_KILL, //player wants to die - GAME_EVENT_PLAYER_BUY_FINISHED, //player end to buy items - GAME_EVENT_PLAYER_BUYMENU_OPEN, - GAME_EVENT_PLAYER_BUYMENU_CLOSE, - GAME_EVENT_PLAYER_BUY_SPAWN, - - GAME_EVENT_PLAYER_GAME_MENU, - GAME_EVENT_PLAYER_GAME_MENU_RESPOND, - - GAME_EVENT_PLAYER_CONNECTED , - GAME_EVENT_PLAYER_DISCONNECTED , - GAME_EVENT_PLAYER_ENTERED_GAME , - - GAME_EVENT_PLAYER_KILLED ,//////!!!!! - GAME_EVENT_PLAYER_HITTED, - - GAME_EVENT_PLAYER_JOIN_TEAM , - GAME_EVENT_ROUND_STARTED , - GAME_EVENT_ROUND_END , - - GAME_EVENT_ARTEFACT_SPAWNED , - GAME_EVENT_ARTEFACT_DESTROYED , - GAME_EVENT_ARTEFACT_TAKEN, - GAME_EVENT_ARTEFACT_DROPPED , - GAME_EVENT_ARTEFACT_ONBASE , - - GAME_EVENT_PLAYER_ENTER_TEAM_BASE , - GAME_EVENT_PLAYER_LEAVE_TEAM_BASE , - - GAME_EVENT_BUY_MENU_CLOSED , - GAME_EVENT_TEAM_MENU_CLOSED , - GAME_EVENT_SKIN_MENU_CLOSED , - - GAME_EVENT_CREATE_CLIENT, - GAME_EVENT_ON_HIT, - GAME_EVENT_ON_TOUCH, - - GAME_EVENT_VOTE_START, - GAME_EVENT_VOTE_YES, - GAME_EVENT_VOTE_NO, - GAME_EVENT_VOTE_STOP, - GAME_EVENT_VOTE_END, - GAME_EVENT_GET_ACTIVE_VOTE, -// GAME_EVENT_VOTE_PLAYER_VOTED, - - GAME_EVENT_PLAYER_AUTH, - GAME_EVENT_PLAYER_NAME, - - GAME_EVENT_SPEECH_MESSAGE, - - //----------------------------------------- - GAME_EVENT_PLAYERS_MONEY_CHANGED, - GAME_EVENT_SERVER_STRING_MESSAGE, - GAME_EVENT_SERVER_DIALOG_MESSAGE, - - GAME_EVENT_PLAYER_STARTED, - GAME_EVENT_MAKE_DATA, - GAME_EVENT_RECEIVE_SERVER_LOGO, - GAME_EVENT_CREATE_PLAYER_STATE, - GAME_EVENT_PLAYERS_INFO_REPLY, - - //----------------------------------------- - GAME_EVENT_SCRIPT_BEGINS_FROM, // don't add messages after this - GAME_EVENT_FORCEDWORD = u32(-1) + GE_CHANGE_POS, + + GE_GAME_EVENT, + + GE_CHANGE_VISUAL, + GE_MONEY, + + GEG_PLAYER_ACTIVATE_SLOT, + GEG_PLAYER_ITEM2SLOT, + GEG_PLAYER_ITEM2BELT, + GEG_PLAYER_ITEM2RUCK, + GEG_PLAYER_ITEM_EAT, + GEG_PLAYER_ITEM_SELL, + GEG_PLAYER_ACTIVATEARTEFACT, + + GEG_PLAYER_WEAPON_HIDE_STATE, + GEG_PLAYER_DISABLE_SPRINT, + + GEG_PLAYER_ATTACH_HOLDER, + GEG_PLAYER_DETACH_HOLDER, + + GEG_PLAYER_PLAY_HEADSHOT_PARTICLE, + //------------------------------------- + GE_HIT_STATISTIC, + //------------------------------------- + GE_KILL_SOMEONE, + + GE_FREEZE_OBJECT, + GE_LAUNCH_ROCKET, + + GEG_PLAYER_USE_BOOSTER, + GE_REQUEST_PLAYERS_INFO, + + GE_FORCEDWORD = u32(-1) +}; + +enum EGameMessages +{ // game_cl <----> game_sv messages + GAME_EVENT_PLAYER_READY, + GAME_EVENT_PLAYER_KILL, // player wants to die + GAME_EVENT_PLAYER_BUY_FINISHED, // player end to buy items + GAME_EVENT_PLAYER_BUYMENU_OPEN, + GAME_EVENT_PLAYER_BUYMENU_CLOSE, + GAME_EVENT_PLAYER_BUY_SPAWN, + + GAME_EVENT_PLAYER_GAME_MENU, + GAME_EVENT_PLAYER_GAME_MENU_RESPOND, + + GAME_EVENT_PLAYER_CONNECTED, + GAME_EVENT_PLAYER_DISCONNECTED, + GAME_EVENT_PLAYER_ENTERED_GAME, + + GAME_EVENT_PLAYER_KILLED, //////!!!!! + GAME_EVENT_PLAYER_HITTED, + + GAME_EVENT_PLAYER_JOIN_TEAM, + GAME_EVENT_ROUND_STARTED, + GAME_EVENT_ROUND_END, + + GAME_EVENT_ARTEFACT_SPAWNED, + GAME_EVENT_ARTEFACT_DESTROYED, + GAME_EVENT_ARTEFACT_TAKEN, + GAME_EVENT_ARTEFACT_DROPPED, + GAME_EVENT_ARTEFACT_ONBASE, + + GAME_EVENT_PLAYER_ENTER_TEAM_BASE, + GAME_EVENT_PLAYER_LEAVE_TEAM_BASE, + + GAME_EVENT_BUY_MENU_CLOSED, + GAME_EVENT_TEAM_MENU_CLOSED, + GAME_EVENT_SKIN_MENU_CLOSED, + + GAME_EVENT_CREATE_CLIENT, + GAME_EVENT_ON_HIT, + GAME_EVENT_ON_TOUCH, + + GAME_EVENT_VOTE_START, + GAME_EVENT_VOTE_YES, + GAME_EVENT_VOTE_NO, + GAME_EVENT_VOTE_STOP, + GAME_EVENT_VOTE_END, + GAME_EVENT_GET_ACTIVE_VOTE, + // GAME_EVENT_VOTE_PLAYER_VOTED, + + GAME_EVENT_PLAYER_AUTH, + GAME_EVENT_PLAYER_NAME, + + GAME_EVENT_SPEECH_MESSAGE, + + //----------------------------------------- + GAME_EVENT_PLAYERS_MONEY_CHANGED, + GAME_EVENT_SERVER_STRING_MESSAGE, + GAME_EVENT_SERVER_DIALOG_MESSAGE, + + GAME_EVENT_PLAYER_STARTED, + GAME_EVENT_MAKE_DATA, + GAME_EVENT_RECEIVE_SERVER_LOGO, + GAME_EVENT_CREATE_PLAYER_STATE, + GAME_EVENT_PLAYERS_INFO_REPLY, + + //----------------------------------------- + GAME_EVENT_SCRIPT_BEGINS_FROM, // don't add messages after this + GAME_EVENT_FORCEDWORD = u32(-1) }; enum { - M_SPAWN_OBJECT_LOCAL = (1<<0), // after spawn it becomes local (authorative) - M_SPAWN_OBJECT_HASUPDATE = (1<<2), // after spawn info it has update inside message - M_SPAWN_OBJECT_ASPLAYER = (1<<3), // after spawn it must become viewable - M_SPAWN_OBJECT_PHANTOM = (1<<4), // after spawn it must become viewable - M_SPAWN_VERSION = (1<<5), // control version - M_SPAWN_UPDATE = (1<<6), // + update packet - M_SPAWN_TIME = (1<<7), // + spawn time - M_SPAWN_DENIED = (1<<8), // don't spawn entity with this flag - - M_SPAWN_OBJECT_FORCEDWORD = u32(-1) + M_SPAWN_OBJECT_LOCAL = (1 << 0), // after spawn it becomes local (authorative) + M_SPAWN_OBJECT_HASUPDATE = (1 << 2), // after spawn info it has update inside message + M_SPAWN_OBJECT_ASPLAYER = (1 << 3), // after spawn it must become viewable + M_SPAWN_OBJECT_PHANTOM = (1 << 4), // after spawn it must become viewable + M_SPAWN_VERSION = (1 << 5), // control version + M_SPAWN_UPDATE = (1 << 6), // + update packet + M_SPAWN_TIME = (1 << 7), // + spawn time + M_SPAWN_DENIED = (1 << 8), // don't spawn entity with this flag + + M_SPAWN_OBJECT_FORCEDWORD = u32(-1) }; enum enum_connection_results { - ecr_data_verification_failed = 0x00, - ecr_cdkey_validation_failed, - ecr_password_verification_failed, - ecr_have_been_banned, - ecr_profile_error, -};//enum enum_connection_results - + ecr_data_verification_failed = 0x00, + ecr_cdkey_validation_failed, + ecr_password_verification_failed, + ecr_have_been_banned, + ecr_profile_error, +}; // enum enum_connection_results #endif /*_INCDEF_XRMESSAGES_H_*/ \ No newline at end of file diff --git a/src/xrServerEntities/xrServer_Factory.cpp b/src/xrServerEntities/xrServer_Factory.cpp index 6cd458e36c8..5dee000ef2a 100644 --- a/src/xrServerEntities/xrServer_Factory.cpp +++ b/src/xrServerEntities/xrServer_Factory.cpp @@ -6,10 +6,10 @@ // Description : Server objects factory //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" #include "object_factory.h" +#include "stdafx.h" -CSE_Abstract *F_entity_Create (LPCSTR section) +CSE_Abstract* F_entity_Create(LPCSTR section) { - return (object_factory().server_object(pSettings->r_clsid(section,"class"),section)); + return (object_factory().server_object(pSettings->r_clsid(section, "class"), section)); } diff --git a/src/xrServerEntities/xrServer_Object_Base.cpp b/src/xrServerEntities/xrServer_Object_Base.cpp index bf5b9247300..a791bc57e4a 100644 --- a/src/xrServerEntities/xrServer_Object_Base.cpp +++ b/src/xrServerEntities/xrServer_Object_Base.cpp @@ -6,229 +6,222 @@ // Description : Server base object //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" -#include "xrServer_Objects.h" -#include "xrMessages.h" +#include "clsid_game.h" #include "game_base_space.h" #include "script_value_container_impl.h" -#include "clsid_game.h" +#include "stdafx.h" +#include "xrMessages.h" +#include "xrServer_Objects.h" #pragma warning(push) -#pragma warning(disable:4995) +#pragma warning(disable : 4995) #include #pragma warning(pop) #ifndef AI_COMPILER -# include "object_factory.h" +#include "object_factory.h" #endif #ifndef XRSE_FACTORY_EXPORTS -# include "xrEProps.h" - - IPropHelper &PHelper() - { - NODEFAULT; -# ifdef DEBUG - return(*(IPropHelper*)0); -# endif - } - -# ifdef XRGAME_EXPORTS -# include "ai_space.h" -# include "alife_simulator.h" -# endif // #ifdef XRGAME_EXPORTS +#include "xrEProps.h" + +IPropHelper& PHelper() +{ + NODEFAULT; +#ifdef DEBUG + return (*(IPropHelper*)0); +#endif +} + +#ifdef XRGAME_EXPORTS +#include "ai_space.h" +#include "alife_simulator.h" +#endif // #ifdef XRGAME_EXPORTS #endif LPCSTR script_section = "script"; LPCSTR current_version = "current_server_entity_version"; -IC u16 script_server_object_version () +IC u16 script_server_object_version() { - static bool initialized = false; - static u16 script_version = 0; - if (!initialized) { - initialized = true; - if (!pSettings->section_exist(script_section) || !pSettings->line_exist(script_section,current_version)) - script_version = 0; - script_version = pSettings->r_u16(script_section,current_version); - } - return (script_version); + static bool initialized = false; + static u16 script_version = 0; + if (!initialized) { + initialized = true; + if (!pSettings->section_exist(script_section) || !pSettings->line_exist(script_section, current_version)) + script_version = 0; + script_version = pSettings->r_u16(script_section, current_version); + } + return (script_version); } //////////////////////////////////////////////////////////////////////////// // CPureServerObject //////////////////////////////////////////////////////////////////////////// -void CPureServerObject::save (IWriter &tMemoryStream) +void CPureServerObject::save(IWriter& tMemoryStream) { } -void CPureServerObject::load (IReader &tFileStream) +void CPureServerObject::load(IReader& tFileStream) { } -void CPureServerObject::load (NET_Packet &tNetPacket) +void CPureServerObject::load(NET_Packet& tNetPacket) { } -void CPureServerObject::save (NET_Packet &tNetPacket) +void CPureServerObject::save(NET_Packet& tNetPacket) { } //////////////////////////////////////////////////////////////////////////// // CSE_Abstract //////////////////////////////////////////////////////////////////////////// -CSE_Abstract::CSE_Abstract (LPCSTR caSection) +CSE_Abstract::CSE_Abstract(LPCSTR caSection) { - m_editor_flags.zero (); - RespawnTime = 0; - net_Ready = FALSE; - ID = 0xffff; - ID_Parent = 0xffff; - ID_Phantom = 0xffff; - owner = 0; - m_gameType.SetDefaults (); -//. s_gameid = 0; - s_RP = 0xFE; // Use supplied coords - s_flags.assign (0); - s_name = caSection; - s_name_replace = 0; //xr_strdup(""); - o_Angle.set (0.f,0.f,0.f); - o_Position.set (0.f,0.f,0.f); - m_bALifeControl = false; - m_wVersion = 0; - m_script_version = 0; - m_tClassID = TEXT2CLSID(pSettings->r_string(caSection,"class")); - -// m_spawn_probability = 1.f; - m_spawn_flags.zero (); - m_spawn_flags.set (flSpawnEnabled ,TRUE); - m_spawn_flags.set (flSpawnOnSurgeOnly ,TRUE); - m_spawn_flags.set (flSpawnSingleItemOnly ,TRUE); - m_spawn_flags.set (flSpawnIfDestroyedOnly ,TRUE); - m_spawn_flags.set (flSpawnInfiniteCount ,TRUE); -// m_max_spawn_count = 1; -// m_spawn_control = ""; -// m_spawn_count = 0; -// m_last_spawn_time = 0; -// m_next_spawn_time = 0; -// m_min_spawn_interval = 0; -// m_max_spawn_interval = 0; - m_ini_file = 0; - - if (pSettings->line_exist(caSection,"custom_data")) { - pcstr const raw_file_name = pSettings->r_string(caSection,"custom_data"); - IReader const* config = 0; + m_editor_flags.zero(); + RespawnTime = 0; + net_Ready = FALSE; + ID = 0xffff; + ID_Parent = 0xffff; + ID_Phantom = 0xffff; + owner = 0; + m_gameType.SetDefaults(); + //. s_gameid = 0; + s_RP = 0xFE; // Use supplied coords + s_flags.assign(0); + s_name = caSection; + s_name_replace = 0; // xr_strdup(""); + o_Angle.set(0.f, 0.f, 0.f); + o_Position.set(0.f, 0.f, 0.f); + m_bALifeControl = false; + m_wVersion = 0; + m_script_version = 0; + m_tClassID = TEXT2CLSID(pSettings->r_string(caSection, "class")); + + // m_spawn_probability = 1.f; + m_spawn_flags.zero(); + m_spawn_flags.set(flSpawnEnabled, TRUE); + m_spawn_flags.set(flSpawnOnSurgeOnly, TRUE); + m_spawn_flags.set(flSpawnSingleItemOnly, TRUE); + m_spawn_flags.set(flSpawnIfDestroyedOnly, TRUE); + m_spawn_flags.set(flSpawnInfiniteCount, TRUE); + // m_max_spawn_count = 1; + // m_spawn_control = ""; + // m_spawn_count = 0; + // m_last_spawn_time = 0; + // m_next_spawn_time = 0; + // m_min_spawn_interval = 0; + // m_max_spawn_interval = 0; + m_ini_file = 0; + + if (pSettings->line_exist(caSection, "custom_data")) { + pcstr const raw_file_name = pSettings->r_string(caSection, "custom_data"); + IReader const* config = 0; #ifdef XRGAME_EXPORTS - if ( ai().get_alife() ) - config = ai().alife().get_config( raw_file_name ); - else -#endif // #ifdef XRGAME_EXPORTS - { - string_path file_name; - FS.update_path (file_name,"$game_config$", raw_file_name); - if ( FS.exist(file_name) ) - config = FS.r_open(file_name); - } - - if ( config ) { - int size = config->length()*sizeof(char); - LPSTR temp = (LPSTR)_alloca(size + 1); - CopyMemory (temp,config->pointer(),size); - temp[size] = 0; - m_ini_string = temp; + if (ai().get_alife()) + config = ai().alife().get_config(raw_file_name); + else +#endif // #ifdef XRGAME_EXPORTS + { + string_path file_name; + FS.update_path(file_name, "$game_config$", raw_file_name); + if (FS.exist(file_name)) config = FS.r_open(file_name); + } + + if (config) { + int size = config->length() * sizeof(char); + LPSTR temp = (LPSTR)_alloca(size + 1); + CopyMemory(temp, config->pointer(), size); + temp[size] = 0; + m_ini_string = temp; #ifdef XRGAME_EXPORTS - if ( NULL==ai().get_alife() ) -#endif // #ifdef XRGAME_EXPORTS - { - IReader* _r = (IReader*)config; - FS.r_close(_r); - } - - } - else - Msg ( "! cannot open config file %s", raw_file_name ); - } + if (NULL == ai().get_alife()) +#endif // #ifdef XRGAME_EXPORTS + { + IReader* _r = (IReader*)config; + FS.r_close(_r); + } + } + else + Msg("! cannot open config file %s", raw_file_name); + } #ifndef AI_COMPILER - m_script_clsid = object_factory().script_clsid(m_tClassID); + m_script_clsid = object_factory().script_clsid(m_tClassID); #endif } -CSE_Abstract::~CSE_Abstract () +CSE_Abstract::~CSE_Abstract() { - xr_free (s_name_replace); - xr_delete (m_ini_file); + xr_free(s_name_replace); + xr_delete(m_ini_file); } -CSE_Visual* CSE_Abstract::visual () +CSE_Visual* CSE_Abstract::visual() { - return (0); + return (0); } -IServerEntityShape* CSE_Abstract::shape () +IServerEntityShape* CSE_Abstract::shape() { - return (0); + return (0); } -CSE_Motion* CSE_Abstract::motion () +CSE_Motion* CSE_Abstract::motion() { - return (0); + return (0); } -CInifile &CSE_Abstract::spawn_ini () +CInifile& CSE_Abstract::spawn_ini() { - if (!m_ini_file) + if (!m_ini_file) #pragma warning(push) -#pragma warning(disable:4238) - m_ini_file = new CInifile( - &IReader ( - (void*)(*(m_ini_string)), - m_ini_string.size() - ), - FS.get_path("$game_config$")->m_Path - ); +#pragma warning(disable : 4238) + m_ini_file = + new CInifile(&IReader((void*)(*(m_ini_string)), m_ini_string.size()), FS.get_path("$game_config$")->m_Path); #pragma warning(pop) - return (*m_ini_file); + return (*m_ini_file); } - -void CSE_Abstract::Spawn_Write (NET_Packet &tNetPacket, BOOL bLocal) + +void CSE_Abstract::Spawn_Write(NET_Packet& tNetPacket, BOOL bLocal) { - // generic - tNetPacket.w_begin (M_SPAWN); - tNetPacket.w_stringZ (s_name ); - tNetPacket.w_stringZ (s_name_replace ? s_name_replace : ""); - tNetPacket.w_u8 (0); - tNetPacket.w_u8 (s_RP ); - tNetPacket.w_vec3 (o_Position ); - tNetPacket.w_vec3 (o_Angle ); - tNetPacket.w_u16 (RespawnTime ); - tNetPacket.w_u16 (ID ); - tNetPacket.w_u16 (ID_Parent ); - tNetPacket.w_u16 (ID_Phantom ); - - s_flags.set (M_SPAWN_VERSION,TRUE); - if (bLocal) - tNetPacket.w_u16 (u16(s_flags.flags|M_SPAWN_OBJECT_LOCAL) ); - else - tNetPacket.w_u16 (u16(s_flags.flags&~(M_SPAWN_OBJECT_LOCAL|M_SPAWN_OBJECT_ASPLAYER))); - - tNetPacket.w_u16 (SPAWN_VERSION); - - tNetPacket.w_u16 (m_gameType.m_GameType.get()); - - tNetPacket.w_u16 (script_server_object_version()); - - - //client object custom data serialization SAVE - u16 client_data_size = (u16)client_data.size(); //íå ìîæåò áûòü áîëüøå 256 áàéò - tNetPacket.w_u16 (client_data_size); -// Msg ("SERVER:saving:save:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : ""); - if (client_data_size > 0) { - tNetPacket.w (&*client_data.begin(),client_data_size); - } - - tNetPacket.w_u16 (m_tSpawnID); + // generic + tNetPacket.w_begin(M_SPAWN); + tNetPacket.w_stringZ(s_name); + tNetPacket.w_stringZ(s_name_replace ? s_name_replace : ""); + tNetPacket.w_u8(0); + tNetPacket.w_u8(s_RP); + tNetPacket.w_vec3(o_Position); + tNetPacket.w_vec3(o_Angle); + tNetPacket.w_u16(RespawnTime); + tNetPacket.w_u16(ID); + tNetPacket.w_u16(ID_Parent); + tNetPacket.w_u16(ID_Phantom); + + s_flags.set(M_SPAWN_VERSION, TRUE); + if (bLocal) + tNetPacket.w_u16(u16(s_flags.flags | M_SPAWN_OBJECT_LOCAL)); + else + tNetPacket.w_u16(u16(s_flags.flags & ~(M_SPAWN_OBJECT_LOCAL | M_SPAWN_OBJECT_ASPLAYER))); + + tNetPacket.w_u16(SPAWN_VERSION); + + tNetPacket.w_u16(m_gameType.m_GameType.get()); + + tNetPacket.w_u16(script_server_object_version()); + + // client object custom data serialization SAVE + u16 client_data_size = (u16)client_data.size(); //íå ìîæåò áûòü áîëüøå 256 áàéò + tNetPacket.w_u16(client_data_size); + // Msg ("SERVER:saving:save:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : + //""); + if (client_data_size > 0) { + tNetPacket.w(&*client_data.begin(), client_data_size); + } + + tNetPacket.w_u16(m_tSpawnID); // tNetPacket.w_float (m_spawn_probability); // tNetPacket.w_u32 (m_spawn_flags.get()); // tNetPacket.w_stringZ (m_spawn_control); @@ -237,240 +230,234 @@ void CSE_Abstract::Spawn_Write (NET_Packet &tNetPacket, BOOL bLocal) // tNetPacket.w_u64 (m_max_spawn_interval); #ifdef XRSE_FACTORY_EXPORTS - CScriptValueContainer::assign(); + CScriptValueContainer::assign(); #endif - // write specific data - u32 position = tNetPacket.w_tell(); - tNetPacket.w_u16 (0); - STATE_Write (tNetPacket); - u16 size = u16(tNetPacket.w_tell() - position); -//#ifdef XRSE_FACTORY_EXPORTS - R_ASSERT3 ((m_tClassID == CLSID_SPECTATOR) || (size > sizeof(size)), - "object isn't successfully saved, get your backup :(",name_replace()); -//#endif - tNetPacket.w_seek (position,&size,sizeof(u16)); + // write specific data + u32 position = tNetPacket.w_tell(); + tNetPacket.w_u16(0); + STATE_Write(tNetPacket); + u16 size = u16(tNetPacket.w_tell() - position); + //#ifdef XRSE_FACTORY_EXPORTS + R_ASSERT3((m_tClassID == CLSID_SPECTATOR) || (size > sizeof(size)), + "object isn't successfully saved, get your backup :(", name_replace()); + //#endif + tNetPacket.w_seek(position, &size, sizeof(u16)); } static enum EGameTypes { - GAME_ANY = 0, - GAME_SINGLE = 1, - GAME_DEATHMATCH = 2, -// GAME_CTF = 3, -// GAME_ASSAULT = 4, // Team1 - assaulting, Team0 - Defending - GAME_CS = 5, - GAME_TEAMDEATHMATCH = 6, - GAME_ARTEFACTHUNT = 7, - GAME_CAPTURETHEARTEFACT = 8, - - //identifiers in range [100...254] are registered for script game type - GAME_DUMMY = 255 // temporary game type + GAME_ANY = 0, + GAME_SINGLE = 1, + GAME_DEATHMATCH = 2, + // GAME_CTF = 3, + // GAME_ASSAULT = 4, // Team1 - assaulting, Team0 - Defending + GAME_CS = 5, + GAME_TEAMDEATHMATCH = 6, + GAME_ARTEFACTHUNT = 7, + GAME_CAPTURETHEARTEFACT = 8, + + // identifiers in range [100...254] are registered for script game type + GAME_DUMMY = 255 // temporary game type }; -BOOL CSE_Abstract::Spawn_Read (NET_Packet &tNetPacket) +BOOL CSE_Abstract::Spawn_Read(NET_Packet& tNetPacket) { - u16 dummy16; - // generic - tNetPacket.r_begin (dummy16); - R_ASSERT (M_SPAWN==dummy16); - tNetPacket.r_stringZ (s_name ); - - string256 temp; - tNetPacket.r_stringZ (temp); - set_name_replace (temp); - u8 temp_gt; - tNetPacket.r_u8 (temp_gt/*s_gameid*/ ); - tNetPacket.r_u8 (s_RP ); - tNetPacket.r_vec3 (o_Position ); - tNetPacket.r_vec3 (o_Angle ); - tNetPacket.r_u16 (RespawnTime ); - tNetPacket.r_u16 (ID ); - tNetPacket.r_u16 (ID_Parent ); - tNetPacket.r_u16 (ID_Phantom ); - - tNetPacket.r_u16 (s_flags.flags ); - - // dangerous!!!!!!!!! - if (s_flags.is(M_SPAWN_VERSION)) - tNetPacket.r_u16 (m_wVersion); - - if(m_wVersion > 120) - { - u16 gt; - tNetPacket.r_u16 (gt); - m_gameType.m_GameType.assign(gt); - }else - m_gameType.SetDefaults (); - - if (0==m_wVersion) { - tNetPacket.r_pos -= sizeof(u16); - m_wVersion = 0; - return FALSE; - } - - if (m_wVersion > 69) - m_script_version = tNetPacket.r_u16(); - - // read specific data - - //client object custom data serialization LOAD - if (m_wVersion > 70) { - u16 client_data_size = (m_wVersion > 93) ? tNetPacket.r_u16() : tNetPacket.r_u8(); //íå ìîæåò áûòü áîëüøå 256 áàéò - if (client_data_size > 0) { -// Msg ("SERVER:loading:load:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : ""); - client_data.resize (client_data_size); - tNetPacket.r (&*client_data.begin(),client_data_size); - } - else - client_data.clear (); - } - else - client_data.clear (); - - if (m_wVersion > 79) - tNetPacket.r_u16 (m_tSpawnID); - - if (m_wVersion < 112) { - if (m_wVersion > 82) - tNetPacket.r_float ();//m_spawn_probability); - - if (m_wVersion > 83) { - tNetPacket.r_u32 ();//m_spawn_flags.assign(tNetPacket.r_u32()); - xr_string temp; - tNetPacket.r_stringZ (temp);//tNetPacket.r_stringZ(m_spawn_control); - tNetPacket.r_u32 ();//m_max_spawn_count); - // this stuff we do not need even in case of uncomment - tNetPacket.r_u32 ();//m_spawn_count); - tNetPacket.r_u64 ();//m_last_spawn_time); - } - - if (m_wVersion > 84) { - tNetPacket.r_u64 ();//m_min_spawn_interval); - tNetPacket.r_u64 ();//m_max_spawn_interval); - } - } - - u16 size; - tNetPacket.r_u16 (size); // size - bool b1 = (m_tClassID == CLSID_SPECTATOR); - bool b2 = (size > sizeof(size)) || (tNetPacket.inistream!=NULL); - R_ASSERT3 ( (b1 || b2),"cannot read object, which is not successfully saved :(",name_replace()); - STATE_Read (tNetPacket,size); - return TRUE; + u16 dummy16; + // generic + tNetPacket.r_begin(dummy16); + R_ASSERT(M_SPAWN == dummy16); + tNetPacket.r_stringZ(s_name); + + string256 temp; + tNetPacket.r_stringZ(temp); + set_name_replace(temp); + u8 temp_gt; + tNetPacket.r_u8(temp_gt /*s_gameid*/); + tNetPacket.r_u8(s_RP); + tNetPacket.r_vec3(o_Position); + tNetPacket.r_vec3(o_Angle); + tNetPacket.r_u16(RespawnTime); + tNetPacket.r_u16(ID); + tNetPacket.r_u16(ID_Parent); + tNetPacket.r_u16(ID_Phantom); + + tNetPacket.r_u16(s_flags.flags); + + // dangerous!!!!!!!!! + if (s_flags.is(M_SPAWN_VERSION)) tNetPacket.r_u16(m_wVersion); + + if (m_wVersion > 120) { + u16 gt; + tNetPacket.r_u16(gt); + m_gameType.m_GameType.assign(gt); + } + else + m_gameType.SetDefaults(); + + if (0 == m_wVersion) { + tNetPacket.r_pos -= sizeof(u16); + m_wVersion = 0; + return FALSE; + } + + if (m_wVersion > 69) m_script_version = tNetPacket.r_u16(); + + // read specific data + + // client object custom data serialization LOAD + if (m_wVersion > 70) { + u16 client_data_size = + (m_wVersion > 93) ? tNetPacket.r_u16() : tNetPacket.r_u8(); //íå ìîæåò áûòü áîëüøå 256 áàéò + if (client_data_size > 0) { + // Msg ("SERVER:loading:load:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? + //s_name_replace : ""); + client_data.resize(client_data_size); + tNetPacket.r(&*client_data.begin(), client_data_size); + } + else + client_data.clear(); + } + else + client_data.clear(); + + if (m_wVersion > 79) tNetPacket.r_u16(m_tSpawnID); + + if (m_wVersion < 112) { + if (m_wVersion > 82) tNetPacket.r_float(); // m_spawn_probability); + + if (m_wVersion > 83) { + tNetPacket.r_u32(); // m_spawn_flags.assign(tNetPacket.r_u32()); + xr_string temp; + tNetPacket.r_stringZ(temp); // tNetPacket.r_stringZ(m_spawn_control); + tNetPacket.r_u32(); // m_max_spawn_count); + // this stuff we do not need even in case of uncomment + tNetPacket.r_u32(); // m_spawn_count); + tNetPacket.r_u64(); // m_last_spawn_time); + } + + if (m_wVersion > 84) { + tNetPacket.r_u64(); // m_min_spawn_interval); + tNetPacket.r_u64(); // m_max_spawn_interval); + } + } + + u16 size; + tNetPacket.r_u16(size); // size + bool b1 = (m_tClassID == CLSID_SPECTATOR); + bool b2 = (size > sizeof(size)) || (tNetPacket.inistream != NULL); + R_ASSERT3((b1 || b2), "cannot read object, which is not successfully saved :(", name_replace()); + STATE_Read(tNetPacket, size); + return TRUE; } -void CSE_Abstract::load (NET_Packet &tNetPacket) +void CSE_Abstract::load(NET_Packet& tNetPacket) { - CPureServerObject::load (tNetPacket); - u16 client_data_size = (m_wVersion > 93) ? tNetPacket.r_u16() : tNetPacket.r_u8(); //íå ìîæåò áûòü áîëüøå 256 áàéò - if (client_data_size > 0) { + CPureServerObject::load(tNetPacket); + u16 client_data_size = (m_wVersion > 93) ? tNetPacket.r_u16() : tNetPacket.r_u8(); //íå ìîæåò áûòü áîëüøå 256 áàéò + if (client_data_size > 0) { #ifdef DEBUG -// Msg ("SERVER:loading:load:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : ""); -#endif // DEBUG - client_data.resize (client_data_size); - tNetPacket.r (&*client_data.begin(),client_data_size); - } - else { +// Msg ("SERVER:loading:load:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : +//""); +#endif // DEBUG + client_data.resize(client_data_size); + tNetPacket.r(&*client_data.begin(), client_data_size); + } + else + { #ifdef DEBUG - if (!client_data.empty()) - Msg ("CSE_Abstract::load: client_data is cleared for [%d][%s]",ID,name_replace()); -#endif // DEBUG - client_data.clear (); - } + if (!client_data.empty()) Msg("CSE_Abstract::load: client_data is cleared for [%d][%s]", ID, name_replace()); +#endif // DEBUG + client_data.clear(); + } } -CSE_Abstract *CSE_Abstract::base () +CSE_Abstract* CSE_Abstract::base() { - return (this); + return (this); } -const CSE_Abstract *CSE_Abstract::base () const +const CSE_Abstract* CSE_Abstract::base() const { - return (this); + return (this); } -CSE_Abstract *CSE_Abstract::init () +CSE_Abstract* CSE_Abstract::init() { - return (this); + return (this); } -LPCSTR CSE_Abstract::name () const +LPCSTR CSE_Abstract::name() const { - return (*s_name); + return (*s_name); } -LPCSTR CSE_Abstract::name_replace () const +LPCSTR CSE_Abstract::name_replace() const { - return (s_name_replace); + return (s_name_replace); } -Fvector& CSE_Abstract::position () +Fvector& CSE_Abstract::position() { - return (o_Position); + return (o_Position); } -Fvector& CSE_Abstract::angle () +Fvector& CSE_Abstract::angle() { - return (o_Angle); + return (o_Angle); } -Flags16& CSE_Abstract::flags () +Flags16& CSE_Abstract::flags() { - return (s_flags); + return (s_flags); } -xr_token game_types[]={ - { "any_game", eGameIDNoGame }, - { "single", eGameIDSingle }, - { "deathmatch", eGameIDDeathmatch }, - { "team_deathmatch", eGameIDTeamDeathmatch }, - { "artefacthunt", eGameIDArtefactHunt }, - { "capture_the_artefact", eGameIDCaptureTheArtefact }, - //eGameIDDominationZone - //eGameIDTeamDominationZone - { 0, 0 } -}; +xr_token game_types[] = {{"any_game", eGameIDNoGame}, {"single", eGameIDSingle}, {"deathmatch", eGameIDDeathmatch}, + {"team_deathmatch", eGameIDTeamDeathmatch}, {"artefacthunt", eGameIDArtefactHunt}, + {"capture_the_artefact", eGameIDCaptureTheArtefact}, + // eGameIDDominationZone + // eGameIDTeamDominationZone + {0, 0}}; #ifndef XRGAME_EXPORTS void CSE_Abstract::FillProps(LPCSTR pref, PropItemVec& items) { #ifdef XRSE_FACTORY_EXPORTS m_gameType.FillProp(pref, items); -#endif // #ifdef XRSE_FACTORY_EXPORTS -/* -#ifdef XRGAME_EXPORTS -# ifdef DEBUG - PHelper().CreateToken8 (items, PrepareKey(pref,"Game Type"), &s_gameid, game_types); - PHelper().CreateU16 (items, PrepareKey(pref, "Respawn Time (s)"), &RespawnTime, 0,43200); - -*/ +#endif // #ifdef XRSE_FACTORY_EXPORTS + /* + #ifdef XRGAME_EXPORTS + # ifdef DEBUG + PHelper().CreateToken8 (items, PrepareKey(pref,"Game Type"), &s_gameid, game_types); + PHelper().CreateU16 (items, PrepareKey(pref, "Respawn Time (s)"), &RespawnTime, 0,43200); + + */ } -void CSE_Abstract::FillProp (LPCSTR pref, PropItemVec &items) +void CSE_Abstract::FillProp(LPCSTR pref, PropItemVec& items) { - CScriptValueContainer::assign(); - CScriptValueContainer::clear(); - FillProps (pref,items); + CScriptValueContainer::assign(); + CScriptValueContainer::clear(); + FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_Abstract::validate () +bool CSE_Abstract::validate() { - return (true); + return (true); } /** void CSE_Abstract::save_update (NET_Packet &tNetPacket) { - tNetPacket.w (&m_spawn_count,sizeof(m_spawn_count)); - tNetPacket.w (&m_last_spawn_time,sizeof(m_last_spawn_time)); - tNetPacket.w (&m_next_spawn_time,sizeof(m_next_spawn_time)); + tNetPacket.w (&m_spawn_count,sizeof(m_spawn_count)); + tNetPacket.w (&m_last_spawn_time,sizeof(m_last_spawn_time)); + tNetPacket.w (&m_next_spawn_time,sizeof(m_next_spawn_time)); } void CSE_Abstract::load_update (NET_Packet &tNetPacket) { - tNetPacket.r (&m_spawn_count,sizeof(m_spawn_count)); - tNetPacket.r (&m_last_spawn_time,sizeof(m_last_spawn_time)); - tNetPacket.r (&m_next_spawn_time,sizeof(m_next_spawn_time)); + tNetPacket.r (&m_spawn_count,sizeof(m_spawn_count)); + tNetPacket.r (&m_last_spawn_time,sizeof(m_last_spawn_time)); + tNetPacket.r (&m_next_spawn_time,sizeof(m_next_spawn_time)); } /**/ diff --git a/src/xrServerEntities/xrServer_Object_Base.h b/src/xrServerEntities/xrServer_Object_Base.h index 7aaa5ebf6e0..49850baf370 100644 --- a/src/xrServerEntities/xrServer_Object_Base.h +++ b/src/xrServerEntities/xrServer_Object_Base.h @@ -8,11 +8,11 @@ #pragma once -#include "xrServer_Objects_Abstract.h" #include "Common/object_interfaces.h" -#include "script_value_container.h" #include "alife_space.h" +#include "script_value_container.h" #include "xrCore/client_id.h" +#include "xrServer_Objects_Abstract.h" class NET_Packet; class xrClientData; @@ -35,144 +35,150 @@ class CSE_ALifeOnlineOfflineGroup; class CSE_ALifeItemPDA; #pragma warning(push) -#pragma warning(disable:4005) +#pragma warning(disable : 4005) class CPureServerObject : public IPureServerObject { using inherited = IPureServerObject; + public: - virtual ~CPureServerObject(){} - virtual void load(IReader &tFileStream); - virtual void save(IWriter &tMemoryStream); - virtual void load(NET_Packet &tNetPacket); - virtual void save(NET_Packet &tNetPacket); + virtual ~CPureServerObject() {} + virtual void load(IReader& tFileStream); + virtual void save(IWriter& tMemoryStream); + virtual void load(NET_Packet& tNetPacket); + virtual void save(NET_Packet& tNetPacket); }; -class CSE_Abstract : - public IServerEntity, - public CPureServerObject, - public CScriptValueContainer +class CSE_Abstract : public IServerEntity, public CPureServerObject, public CScriptValueContainer { using inherited1 = IServerEntity; using inherited2 = CPureServerObject; using inherited3 = CScriptValueContainer; + public: - enum ESpawnFlags { - flSpawnEnabled = u32(1 << 0), - flSpawnOnSurgeOnly = u32(1 << 1), - flSpawnSingleItemOnly = u32(1 << 2), - flSpawnIfDestroyedOnly = u32(1 << 3), - flSpawnInfiniteCount = u32(1 << 4), - flSpawnDestroyOnSpawn = u32(1 << 5), + enum ESpawnFlags + { + flSpawnEnabled = u32(1 << 0), + flSpawnOnSurgeOnly = u32(1 << 1), + flSpawnSingleItemOnly = u32(1 << 2), + flSpawnIfDestroyedOnly = u32(1 << 3), + flSpawnInfiniteCount = u32(1 << 4), + flSpawnDestroyOnSpawn = u32(1 << 5), }; private: - LPSTR s_name_replace; + LPSTR s_name_replace; public: - BOOL net_Ready; - BOOL net_Processed; // Internal flag for connectivity-graph - - u16 m_wVersion; - u16 m_script_version; - u16 RespawnTime; - - u16 ID; // internal ID - u16 ID_Parent; // internal ParentID, 0xffff means no parent - u16 ID_Phantom; // internal PhantomID, 0xffff means no phantom - xrClientData* owner; + BOOL net_Ready; + BOOL net_Processed; // Internal flag for connectivity-graph + + u16 m_wVersion; + u16 m_script_version; + u16 RespawnTime; + + u16 ID; // internal ID + u16 ID_Parent; // internal ParentID, 0xffff means no parent + u16 ID_Phantom; // internal PhantomID, 0xffff means no phantom + xrClientData* owner; // spawn data - shared_str s_name; -//. u8 s_gameid; - GameTypeChooser m_gameType; - u8 s_RP; - Flags16 s_flags; // state flags - xr_vector children; + shared_str s_name; + //. u8 s_gameid; + GameTypeChooser m_gameType; + u8 s_RP; + Flags16 s_flags; // state flags + xr_vector children; // update data - Fvector o_Position; - Fvector o_Angle; - CLASS_ID m_tClassID; - int m_script_clsid; - shared_str m_ini_string; - CInifile *m_ini_file; + Fvector o_Position; + Fvector o_Angle; + CLASS_ID m_tClassID; + int m_script_clsid; + shared_str m_ini_string; + CInifile* m_ini_file; // for ALife control - bool m_bALifeControl; - ALife::_SPAWN_ID m_tSpawnID; + bool m_bALifeControl; + ALife::_SPAWN_ID m_tSpawnID; // ALife spawn params // obsolete, just because we hope to uncomment all this stuff - Flags32 m_spawn_flags; + Flags32 m_spawn_flags; - //client object custom data serialization - xr_vector client_data; - virtual void load (NET_Packet &tNetPacket); + // client object custom data serialization + xr_vector client_data; + virtual void load(NET_Packet& tNetPacket); ////////////////////////////////////////////////////////////////////////// - - CSE_Abstract (LPCSTR caSection); - virtual ~CSE_Abstract (); - virtual void OnEvent (NET_Packet &tNetPacket, u16 type, u32 time, ClientID sender ){}; + + CSE_Abstract(LPCSTR caSection); + virtual ~CSE_Abstract(); + virtual void OnEvent(NET_Packet& tNetPacket, u16 type, u32 time, ClientID sender){}; #ifndef XRGAME_EXPORTS - virtual void FillProps (LPCSTR pref, PropItemVec &items); - virtual void __stdcall FillProp (LPCSTR pref, PropItemVec &items); - virtual void __stdcall on_render (CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent,int priority, bool strictB2F){} - virtual visual_data*__stdcall visual_collection () const { return 0; } - virtual u32 __stdcall visual_collection_size () const { return 0; } - virtual void __stdcall set_additional_info (void* info) {}; -#endif // #ifndef XRGAME_EXPORTS - virtual BOOL Net_Relevant (){return FALSE;}; // !!!! WARNING!!! + virtual void FillProps(LPCSTR pref, PropItemVec& items); + virtual void __stdcall FillProp(LPCSTR pref, PropItemVec& items); + virtual void __stdcall on_render(CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, + const Fmatrix& parent, int priority, bool strictB2F) + { + } + virtual visual_data* __stdcall visual_collection() const { return 0; } + virtual u32 __stdcall visual_collection_size() const { return 0; } + virtual void __stdcall set_additional_info(void* info){}; +#endif // #ifndef XRGAME_EXPORTS + virtual BOOL Net_Relevant() { return FALSE; }; // !!!! WARNING!!! // - virtual void __stdcall Spawn_Write (NET_Packet &tNetPacket, BOOL bLocal); - virtual BOOL __stdcall Spawn_Read (NET_Packet &tNetPacket); - virtual LPCSTR __stdcall name () const; - virtual LPCSTR __stdcall name_replace () const; - virtual void __stdcall set_name (LPCSTR s) + virtual void __stdcall Spawn_Write(NET_Packet& tNetPacket, BOOL bLocal); + virtual BOOL __stdcall Spawn_Read(NET_Packet& tNetPacket); + virtual LPCSTR __stdcall name() const; + virtual LPCSTR __stdcall name_replace() const; + virtual void __stdcall set_name(LPCSTR s) { s_name = s; }; + virtual void __stdcall set_name_replace(LPCSTR s) { - s_name = s; + xr_free(s_name_replace); + s_name_replace = xr_strdup(s); }; - virtual void __stdcall set_name_replace (LPCSTR s) {xr_free(s_name_replace); s_name_replace = xr_strdup(s);}; - virtual Fvector& __stdcall position (); - virtual Fvector& __stdcall angle (); - virtual Flags16& __stdcall flags (); - virtual CSE_Visual* __stdcall visual (); - virtual IServerEntityShape* __stdcall shape (); - virtual CSE_Motion* __stdcall motion (); - virtual bool __stdcall validate (); + virtual Fvector& __stdcall position(); + virtual Fvector& __stdcall angle(); + virtual Flags16& __stdcall flags(); + virtual CSE_Visual* __stdcall visual(); + virtual IServerEntityShape* __stdcall shape(); + virtual CSE_Motion* __stdcall motion(); + virtual bool __stdcall validate(); // - IC const Fvector &Position () const {return o_Position;}; + IC const Fvector& Position() const { return o_Position; }; // we need this to prevent virtual inheritance :-( - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual CSE_Abstract *init (); - virtual bool match_configuration () const {return true;} + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual CSE_Abstract* init(); + virtual bool match_configuration() const { return true; } // end of the virtual inheritance dependant code - IC int script_clsid () const {VERIFY(m_script_clsid >= 0); return (m_script_clsid);} - CInifile &spawn_ini (); - -// for smart cast - virtual CSE_ALifeGroupAbstract *cast_group_abstract () {return 0;}; - virtual CSE_ALifeSchedulable *cast_schedulable () {return 0;}; - virtual CSE_ALifeInventoryItem *cast_inventory_item () {return 0;}; - virtual CSE_ALifeTraderAbstract *cast_trader_abstract () {return 0;}; - - virtual CSE_ALifeObject *cast_alife_object () {return 0;} - virtual CSE_ALifeDynamicObject *cast_alife_dynamic_object () {return 0;} - virtual CSE_ALifeItemAmmo *cast_item_ammo () {return 0;} - virtual CSE_ALifeItemWeapon *cast_item_weapon () {return 0;} - virtual CSE_ALifeItemDetector *cast_item_detector () {return 0;} - virtual CSE_ALifeMonsterAbstract *cast_monster_abstract () {return 0;}; - virtual CSE_ALifeHumanAbstract *cast_human_abstract () {return 0;}; - virtual CSE_ALifeAnomalousZone *cast_anomalous_zone () {return 0;}; - virtual CSE_ALifeTrader *cast_trader () {return 0;}; - - virtual CSE_ALifeCreatureAbstract *cast_creature_abstract () {return 0;}; - virtual CSE_ALifeSmartZone *cast_smart_zone () {return 0;}; - virtual CSE_ALifeOnlineOfflineGroup *cast_online_offline_group () {return 0;}; - virtual CSE_ALifeItemPDA *cast_item_pda () {return 0;}; + IC int script_clsid() const + { + VERIFY(m_script_clsid >= 0); + return (m_script_clsid); + } + CInifile& spawn_ini(); + + // for smart cast + virtual CSE_ALifeGroupAbstract* cast_group_abstract() { return 0; }; + virtual CSE_ALifeSchedulable* cast_schedulable() { return 0; }; + virtual CSE_ALifeInventoryItem* cast_inventory_item() { return 0; }; + virtual CSE_ALifeTraderAbstract* cast_trader_abstract() { return 0; }; + virtual CSE_ALifeObject* cast_alife_object() { return 0; } + virtual CSE_ALifeDynamicObject* cast_alife_dynamic_object() { return 0; } + virtual CSE_ALifeItemAmmo* cast_item_ammo() { return 0; } + virtual CSE_ALifeItemWeapon* cast_item_weapon() { return 0; } + virtual CSE_ALifeItemDetector* cast_item_detector() { return 0; } + virtual CSE_ALifeMonsterAbstract* cast_monster_abstract() { return 0; }; + virtual CSE_ALifeHumanAbstract* cast_human_abstract() { return 0; }; + virtual CSE_ALifeAnomalousZone* cast_anomalous_zone() { return 0; }; + virtual CSE_ALifeTrader* cast_trader() { return 0; }; + virtual CSE_ALifeCreatureAbstract* cast_creature_abstract() { return 0; }; + virtual CSE_ALifeSmartZone* cast_smart_zone() { return 0; }; + virtual CSE_ALifeOnlineOfflineGroup* cast_online_offline_group() { return 0; }; + virtual CSE_ALifeItemPDA* cast_item_pda() { return 0; }; }; #pragma warning(pop) diff --git a/src/xrServerEntities/xrServer_Objects.cpp b/src/xrServerEntities/xrServer_Objects.cpp index 8b04dafaa62..3e652fe28b3 100644 --- a/src/xrServerEntities/xrServer_Objects.cpp +++ b/src/xrServerEntities/xrServer_Objects.cpp @@ -6,156 +6,149 @@ // Description : Server objects //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" #include "xrServer_Objects.h" #include "game_base_space.h" +#include "stdafx.h" //////////////////////////////////////////////////////////////////////////// // CSE_Shape //////////////////////////////////////////////////////////////////////////// -CSE_Shape::CSE_Shape () -{ -} - -CSE_Shape::~CSE_Shape () -{ -} - -void CSE_Shape::cform_read (NET_Packet &tNetPacket) -{ - shapes.clear (); - u8 count; - tNetPacket.r_u8 (count); - - while (count) { - shape_def S; - tNetPacket.r_u8 (S.type); - switch (S.type) { - case 0 : - { - if(tNetPacket.inistream) - { - tNetPacket.r_vec3(S.data.sphere.P); - tNetPacket.r_float(S.data.sphere.R); - }else - tNetPacket.r (&S.data.sphere,sizeof(S.data.sphere)); - - }break; - case 1 : - tNetPacket.r_matrix(S.data.box); - break; - } - shapes.push_back (S); - --count; - } -} - -void CSE_Shape::cform_write (NET_Packet &tNetPacket) -{ - tNetPacket.w_u8 (u8(shapes.size())); - for (u32 i=0; i 80) { - if (m_wVersion < 84) { - tNetPacket.r_float (); - tNetPacket.r_float (); - m_spawn_flags.assign(tNetPacket.r_u32()); - tNetPacket.r_stringZ(m_spawn_control); - } - else { - if (m_wVersion < 85) { - tNetPacket.r_u64 (m_min_spawn_interval); - tNetPacket.r_u64 (m_max_spawn_interval); - } - } - } + if (m_wVersion < 84) + tNetPacket.r_float (m_spawn_probability); + + if (m_wVersion > 80) { + if (m_wVersion < 84) { + tNetPacket.r_float (); + tNetPacket.r_float (); + m_spawn_flags.assign(tNetPacket.r_u32()); + tNetPacket.r_stringZ(m_spawn_control); + } + else { + if (m_wVersion < 85) { + tNetPacket.r_u64 (m_min_spawn_interval); + tNetPacket.r_u64 (m_max_spawn_interval); + } + } + } } void CSE_SpawnGroup::STATE_Write (NET_Packet &tNetPacket) @@ -206,8 +199,9 @@ void CSE_SpawnGroup::UPDATE_Write (NET_Packet &tNetPacket) #ifndef XRGAME_EXPORTS void CSE_SpawnGroup::FillProps (LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref,values); - PHelper().CreateFlag32 (values,PrepareKey(pref,*s_name,"Spawn\\spawn single item only"), &m_spawn_flags, flSpawnSingleItemOnly); + inherited::FillProps (pref,values); + PHelper().CreateFlag32 (values,PrepareKey(pref,*s_name,"Spawn\\spawn single item only"), &m_spawn_flags, +flSpawnSingleItemOnly); } #endif // #ifndef XRGAME_EXPORTS /**/ @@ -217,79 +211,75 @@ void CSE_SpawnGroup::FillProps (LPCSTR pref, PropItemVec& values) //////////////////////////////////////////////////////////////////////////// CSE_PHSkeleton::CSE_PHSkeleton(LPCSTR caSection) { - source_id = u16(-1); - _flags.zero (); + source_id = u16(-1); + _flags.zero(); } CSE_PHSkeleton::~CSE_PHSkeleton() { - } -void CSE_PHSkeleton::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_PHSkeleton::STATE_Read(NET_Packet& tNetPacket, u16 size) { - CSE_Visual *visual = smart_cast(this); - R_ASSERT (visual); - tNetPacket.r_stringZ (visual->startup_animation); - tNetPacket.r_u8 (_flags.flags); - tNetPacket.r_u16 (source_id); - if (_flags.test(flSavedData)) { - data_load(tNetPacket); - } + CSE_Visual* visual = smart_cast(this); + R_ASSERT(visual); + tNetPacket.r_stringZ(visual->startup_animation); + tNetPacket.r_u8(_flags.flags); + tNetPacket.r_u16(source_id); + if (_flags.test(flSavedData)) { + data_load(tNetPacket); + } } -void CSE_PHSkeleton::STATE_Write (NET_Packet &tNetPacket) +void CSE_PHSkeleton::STATE_Write(NET_Packet& tNetPacket) { - CSE_Visual *visual = smart_cast(this); - R_ASSERT (visual); - tNetPacket.w_stringZ (visual->startup_animation); - tNetPacket.w_u8 (_flags.flags); - tNetPacket.w_u16 (source_id); - ////////////////////////saving/////////////////////////////////////// - if(_flags.test(flSavedData)) - { - data_save(tNetPacket); - } + CSE_Visual* visual = smart_cast(this); + R_ASSERT(visual); + tNetPacket.w_stringZ(visual->startup_animation); + tNetPacket.w_u8(_flags.flags); + tNetPacket.w_u16(source_id); + ////////////////////////saving/////////////////////////////////////// + if (_flags.test(flSavedData)) { + data_save(tNetPacket); + } } -void CSE_PHSkeleton::data_load(NET_Packet &tNetPacket) +void CSE_PHSkeleton::data_load(NET_Packet& tNetPacket) { - saved_bones.net_Load(tNetPacket); - _flags.set(flSavedData,TRUE); + saved_bones.net_Load(tNetPacket); + _flags.set(flSavedData, TRUE); } -void CSE_PHSkeleton::data_save(NET_Packet &tNetPacket) +void CSE_PHSkeleton::data_save(NET_Packet& tNetPacket) { - saved_bones.net_Save(tNetPacket); -// this comment is added by Dima (correct me if this is wrong) -// if we call 2 times in a row StateWrite then we get different results -// WHY??? -// _flags.set(flSavedData,FALSE); + saved_bones.net_Save(tNetPacket); + // this comment is added by Dima (correct me if this is wrong) + // if we call 2 times in a row StateWrite then we get different results + // WHY??? + // _flags.set(flSavedData,FALSE); } -void CSE_PHSkeleton::load(NET_Packet &tNetPacket) +void CSE_PHSkeleton::load(NET_Packet& tNetPacket) { - _flags.assign (tNetPacket.r_u8()); - data_load (tNetPacket); - source_id =u16(-1);//. + _flags.assign(tNetPacket.r_u8()); + data_load(tNetPacket); + source_id = u16(-1); //. } -void CSE_PHSkeleton::UPDATE_Write(NET_Packet &tNetPacket) +void CSE_PHSkeleton::UPDATE_Write(NET_Packet& tNetPacket) { - } -void CSE_PHSkeleton::UPDATE_Read(NET_Packet &tNetPacket) +void CSE_PHSkeleton::UPDATE_Read(NET_Packet& tNetPacket) { - } #ifndef XRGAME_EXPORTS -void CSE_PHSkeleton::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_PHSkeleton::FillProps(LPCSTR pref, PropItemVec& values) { } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -CSE_AbstractVisual::CSE_AbstractVisual(LPCSTR section):inherited1(section),inherited2(section) +CSE_AbstractVisual::CSE_AbstractVisual(LPCSTR section) : inherited1(section), inherited2(section) { } @@ -297,39 +287,39 @@ CSE_AbstractVisual::~CSE_AbstractVisual() { } -void CSE_AbstractVisual::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_AbstractVisual::STATE_Read(NET_Packet& tNetPacket, u16 size) { - visual_read (tNetPacket,m_wVersion); - tNetPacket.r_stringZ (startup_animation); + visual_read(tNetPacket, m_wVersion); + tNetPacket.r_stringZ(startup_animation); } -void CSE_AbstractVisual::STATE_Write (NET_Packet &tNetPacket) +void CSE_AbstractVisual::STATE_Write(NET_Packet& tNetPacket) { - visual_write (tNetPacket); - tNetPacket.w_stringZ (startup_animation); + visual_write(tNetPacket); + tNetPacket.w_stringZ(startup_animation); } #ifndef XRGAME_EXPORTS -void CSE_AbstractVisual::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_AbstractVisual::FillProps(LPCSTR pref, PropItemVec& values) { - inherited1::FillProps (pref,values); - inherited2::FillProps (pref,values); + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -void CSE_AbstractVisual::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_AbstractVisual::UPDATE_Read(NET_Packet& tNetPacket) { } -void CSE_AbstractVisual::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_AbstractVisual::UPDATE_Write(NET_Packet& tNetPacket) { } -LPCSTR CSE_AbstractVisual::getStartupAnimation () +LPCSTR CSE_AbstractVisual::getStartupAnimation() { - return *startup_animation; + return *startup_animation; } -CSE_Visual* CSE_AbstractVisual::visual () +CSE_Visual* CSE_AbstractVisual::visual() { - return this; + return this; } diff --git a/src/xrServerEntities/xrServer_Objects.h b/src/xrServerEntities/xrServer_Objects.h index 4562c10cf5f..d89a83b6b01 100644 --- a/src/xrServerEntities/xrServer_Objects.h +++ b/src/xrServerEntities/xrServer_Objects.h @@ -8,12 +8,12 @@ #pragma once +#include "phnetstate.h" #include "xrMessages.h" #include "xrServer_Object_Base.h" -#include "phnetstate.h" #pragma warning(push) -#pragma warning(disable:4005) +#pragma warning(disable : 4005) //------------------------------------------------------------------------------ // Version history @@ -58,7 +58,7 @@ // 43 - CSE_ALifeObjectHangingLamp appended glow_texture and glow_radius // 44 - xrSE_ALifeObjectHangingLamp appended with property 'fixed bones' // 45 - xrSE_ALifeObjectHangingLamp appended with property 'health' -// 46 - xrSE_ALifeObjectSearchLight appended with property 'guid_bone', +// 46 - xrSE_ALifeObjectSearchLight appended with property 'guid_bone', // appended with property 'rotation_bone' // 47 - CSE_ALifeItemWeapon appended with ammo type index // 48 - CSE_ALifeObjectSearchlight appended with property 'cone_bone' @@ -81,10 +81,10 @@ // 65 - CSE_ALifeObjectPhysic startup_anim moved to CSE_AlifePHSkeletonObject // 66 - CSE_ALifeObjectPhysic CSE_ALifeCar - heritage changed // 67 - CSE_ALifeCustomZone new class appended, heritage changed -// 68 - CSE_ALifeHumanStalker, +// 68 - CSE_ALifeHumanStalker, // CSE_ALifeMonsterBase new class appended, heritage changed // 69 - object broker changed from this version -// CSE_ALifeObjectHangingLamp, +// CSE_ALifeObjectHangingLamp, // CSE_ALifeHelicopter heritage changed // 70 - CSE_Abstract appended with m_script_version, script version support // 71 - CSE_Abstract appended with m_client_data, ability to save/load client data @@ -113,8 +113,10 @@ // 94 - CSE_Abstract client_data size increased // 95 - CSE_ALifeCreatureAbstract appended with m_killer_id property // 96 - CSE_ALifeTraderAbstract changed m_iCharacterProfile(int) to m_sCharacterProfile(shared_str) -// 97 - CSE_ALifeItemPDA changed m_info_portion(int) to m_info_portion(shared_str) +m_specific_character +CSE_ALifeItemDocument m_wDoc (int-> shared_str) -// 98 - CSE_ALifeItemPDA changed m_info_portion(int) to m_info_portion(shared_str) +m_specific_character +CSE_ALifeItemDocument m_wDoc (int-> shared_str) +// 97 - CSE_ALifeItemPDA changed m_info_portion(int) to m_info_portion(shared_str) +m_specific_character +// +CSE_ALifeItemDocument m_wDoc (int-> shared_str) +// 98 - CSE_ALifeItemPDA changed m_info_portion(int) to m_info_portion(shared_str) +m_specific_character +// +CSE_ALifeItemDocument m_wDoc (int-> shared_str) // 99 - CSE_ALifeObjectClimable inheritance changed CSE_Abstruct -> CSE_AlifeObject // 100 - CSE_ALifeObjectClimable inheritance changed CSE_AlifeObject -> CSE_AlifeDynamicObject // 101 - CSE_ALifeCreaturePhantom new class based on CSE_ALifeCreatureAbstract @@ -163,45 +165,45 @@ // 127 CSE_ALifeObjectClimable added material; // 128 CSE_ALifeObjectClimable added can_fire in smart covers; //------------------------------------------------------------------------------ -#define SPAWN_VERSION u16(128) +#define SPAWN_VERSION u16(128) -class CSE_Shape : - public IServerEntityShape, - public CShapeData +class CSE_Shape : public IServerEntityShape, public CShapeData { using inherited1 = IServerEntityShape; using inherited2 = CShapeData; + public: - void cform_read (NET_Packet& P); - void cform_write (NET_Packet& P); - CSE_Shape (); - virtual ~CSE_Shape (); - virtual IServerEntityShape* __stdcall shape () = 0; - virtual void __stdcall assign_shapes (CShapeData::shape_def* shapes, u32 cnt); + void cform_read(NET_Packet& P); + void cform_write(NET_Packet& P); + CSE_Shape(); + virtual ~CSE_Shape(); + virtual IServerEntityShape* __stdcall shape() = 0; + virtual void __stdcall assign_shapes(CShapeData::shape_def* shapes, u32 cnt); }; -class CSE_Spectator : - public CSE_Abstract +class CSE_Spectator : public CSE_Abstract { using inherited = CSE_Abstract; + public: - CSE_Spectator (LPCSTR caSection); - virtual ~CSE_Spectator (); - virtual u8 g_team (); - virtual void UPDATE_Read (NET_Packet& P); - virtual void UPDATE_Write (NET_Packet& P); - virtual void STATE_Read (NET_Packet& P, u16 size); - virtual void STATE_Write (NET_Packet& P); + CSE_Spectator(LPCSTR caSection); + virtual ~CSE_Spectator(); + virtual u8 g_team(); + virtual void UPDATE_Read(NET_Packet& P); + virtual void UPDATE_Write(NET_Packet& P); + virtual void STATE_Read(NET_Packet& P, u16 size); + virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS }; class CSE_Temporary : public CSE_Abstract { using inherited = CSE_Abstract; + public: - u32 m_tNodeID; - CSE_Temporary (LPCSTR caSection); - virtual ~CSE_Temporary (); + u32 m_tNodeID; + CSE_Temporary(LPCSTR caSection); + virtual ~CSE_Temporary(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -212,26 +214,28 @@ class CSE_Temporary : public CSE_Abstract class CSE_PHSkeleton { public: - CSE_PHSkeleton(LPCSTR caSection); -virtual ~CSE_PHSkeleton(); + CSE_PHSkeleton(LPCSTR caSection); + virtual ~CSE_PHSkeleton(); -enum{ - flActive = (1<<0), - flSpawnCopy = (1<<1), - flSavedData = (1<<2), - flNotSave = (1<<3) -}; - Flags8 _flags; - SPHBonesData saved_bones; - u16 source_id;//for break only - virtual void load (NET_Packet &tNetPacket); - virtual bool need_save () const{return(!_flags.test(flNotSave));} - virtual void set_sorce_id (u16 si){source_id=si;} - virtual u16 get_source_id (){return source_id;} - virtual CSE_Abstract *cast_abstract () {return 0;} + enum + { + flActive = (1 << 0), + flSpawnCopy = (1 << 1), + flSavedData = (1 << 2), + flNotSave = (1 << 3) + }; + Flags8 _flags; + SPHBonesData saved_bones; + u16 source_id; // for break only + virtual void load(NET_Packet& tNetPacket); + virtual bool need_save() const { return (!_flags.test(flNotSave)); } + virtual void set_sorce_id(u16 si) { source_id = si; } + virtual u16 get_source_id() { return source_id; } + virtual CSE_Abstract* cast_abstract() { return 0; } protected: - virtual void data_load (NET_Packet &tNetPacket); - virtual void data_save (NET_Packet &tNetPacket); + virtual void data_load(NET_Packet& tNetPacket); + virtual void data_save(NET_Packet& tNetPacket); + public: virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -240,18 +244,16 @@ enum{ SERVER_ENTITY_EDITOR_METHODS }; -class CSE_AbstractVisual : - public CSE_Abstract, - public CSE_Visual +class CSE_AbstractVisual : public CSE_Abstract, public CSE_Visual { public: using inherited1 = CSE_Abstract; using inherited2 = CSE_Visual; - CSE_AbstractVisual (LPCSTR caSection); - virtual ~CSE_AbstractVisual (); - virtual CSE_Visual* __stdcall visual (); - LPCSTR getStartupAnimation (); + CSE_AbstractVisual(LPCSTR caSection); + virtual ~CSE_AbstractVisual(); + virtual CSE_Visual* __stdcall visual(); + LPCSTR getStartupAnimation(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -260,7 +262,7 @@ class CSE_AbstractVisual : }; #ifndef AI_COMPILER -extern CSE_Abstract *F_entity_Create (LPCSTR caSection); +extern CSE_Abstract* F_entity_Create(LPCSTR caSection); #endif #pragma warning(pop) diff --git a/src/xrServerEntities/xrServer_Objects_ALife.cpp b/src/xrServerEntities/xrServer_Objects_ALife.cpp index 0f9fa7446eb..0ef7da92d82 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife.cpp @@ -6,443 +6,442 @@ // Description : Server objects for ALife simulator //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" #include "xrServer_Objects_ALife.h" -#include "xrServer_Objects_ALife_Monsters.h" -#include "game_base_space.h" #include "Common/object_broker.h" +#include "game_base_space.h" #include "restriction_space.h" - +#include "stdafx.h" +#include "xrServer_Objects_ALife_Monsters.h" #ifndef AI_COMPILER -# include "character_info.h" -#endif // AI_COMPILER +#include "character_info.h" +#endif // AI_COMPILER #include "xrCore/Animation/Bone.hpp" #ifndef XRGAME_EXPORTS - LPCSTR GAME_CONFIG = "game.ltx"; -#else // XRGAME_EXPORTS -# include "xrEngine/render.h" -#endif // XRGAME_EXPORTS +LPCSTR GAME_CONFIG = "game.ltx"; +#else // XRGAME_EXPORTS +#include "xrEngine/render.h" +#endif // XRGAME_EXPORTS #ifdef XRSE_FACTORY_EXPORTS -# include "ai_space.h" -# include "xrScriptEngine/script_engine.hpp" -# pragma warning(push) -# pragma warning(disable:4995) -# include -# include -# pragma warning(pop) +#include "ai_space.h" +#include "xrScriptEngine/script_engine.hpp" +#pragma warning(push) +#pragma warning(disable : 4995) +#include +#include +#pragma warning(pop) #pragma comment(lib, "shlwapi.lib") -struct logical_string_predicate { - static HRESULT AnsiToUnicode (LPCSTR pszA, LPVOID buffer, u32 const& buffer_size) +struct logical_string_predicate +{ + static HRESULT AnsiToUnicode(LPCSTR pszA, LPVOID buffer, u32 const& buffer_size) { - VERIFY (pszA); - VERIFY (buffer); - VERIFY (buffer_size); + VERIFY(pszA); + VERIFY(buffer); + VERIFY(buffer_size); - u32 cCharacters = xr_strlen(pszA)+1; - VERIFY (cCharacters*2 <= buffer_size); + u32 cCharacters = xr_strlen(pszA) + 1; + VERIFY(cCharacters * 2 <= buffer_size); - if (MultiByteToWideChar(CP_ACP, 0, pszA, cCharacters, (LPOLESTR)buffer, cCharacters)) - return (NOERROR); + if (MultiByteToWideChar(CP_ACP, 0, pszA, cCharacters, (LPOLESTR)buffer, cCharacters)) return (NOERROR); - return (HRESULT_FROM_WIN32(GetLastError())); + return (HRESULT_FROM_WIN32(GetLastError())); } - bool operator() (LPCSTR const& first, LPCSTR const& second) const + bool operator()(LPCSTR const& first, LPCSTR const& second) const { - u32 buffer_size0 = (xr_strlen(first) + 1)*2; - LPCWSTR buffer0 = (LPCWSTR)_alloca(buffer_size0); - AnsiToUnicode (first, (LPVOID)buffer0, buffer_size0); + u32 buffer_size0 = (xr_strlen(first) + 1) * 2; + LPCWSTR buffer0 = (LPCWSTR)_alloca(buffer_size0); + AnsiToUnicode(first, (LPVOID)buffer0, buffer_size0); - u32 buffer_size1 = (xr_strlen(second) + 1)*2; - LPCWSTR buffer1 = (LPCWSTR)_alloca(buffer_size1); - AnsiToUnicode (second, (LPVOID)buffer1, buffer_size1); + u32 buffer_size1 = (xr_strlen(second) + 1) * 2; + LPCWSTR buffer1 = (LPCWSTR)_alloca(buffer_size1); + AnsiToUnicode(second, (LPVOID)buffer1, buffer_size1); - return (StrCmpLogicalW(buffer0, buffer1) < 0); + return (StrCmpLogicalW(buffer0, buffer1) < 0); } - bool operator() (shared_str const& first, shared_str const& second) const + bool operator()(shared_str const& first, shared_str const& second) const { - u32 buffer_size0 = (first.size() + 1)*2; - LPCWSTR buffer0 = (LPCWSTR)_alloca(buffer_size0); - AnsiToUnicode (first.c_str(), (LPVOID)buffer0, buffer_size0); + u32 buffer_size0 = (first.size() + 1) * 2; + LPCWSTR buffer0 = (LPCWSTR)_alloca(buffer_size0); + AnsiToUnicode(first.c_str(), (LPVOID)buffer0, buffer_size0); - u32 buffer_size1 = (second.size() + 1)*2; - LPCWSTR buffer1 = (LPCWSTR)_alloca(buffer_size1); - AnsiToUnicode (second.c_str(), (LPVOID)buffer1, buffer_size1); + u32 buffer_size1 = (second.size() + 1) * 2; + LPCWSTR buffer1 = (LPCWSTR)_alloca(buffer_size1); + AnsiToUnicode(second.c_str(), (LPVOID)buffer1, buffer_size1); - return (StrCmpLogicalW(buffer0, buffer1) < 0); + return (StrCmpLogicalW(buffer0, buffer1) < 0); } -}; // struct logical_string_predicate +}; // struct logical_string_predicate -#endif // XRSE_FACTORY_EXPORTS +#endif // XRSE_FACTORY_EXPORTS -bool SortStringsByAlphabetPred (const shared_str& s1, const shared_str& s2) +bool SortStringsByAlphabetPred(const shared_str& s1, const shared_str& s2) { R_ASSERT(s1.size()); R_ASSERT(s2.size()); - return (xr_strcmp(s1,s2)<0); + return (xr_strcmp(s1, s2) < 0); }; -struct story_name_predicate { - IC bool operator() (const xr_rtoken &_1, const xr_rtoken &_2) const +struct story_name_predicate +{ + IC bool operator()(const xr_rtoken& _1, const xr_rtoken& _2) const { - VERIFY (_1.name.size()); - VERIFY (_2.name.size()); + VERIFY(_1.name.size()); + VERIFY(_2.name.size()); - return (xr_strcmp(_1.name,_2.name) < 0); + return (xr_strcmp(_1.name, _2.name) < 0); } }; #ifdef XRSE_FACTORY_EXPORTS -SFillPropData::SFillPropData () +SFillPropData::SFillPropData() { counter = 0; }; -SFillPropData::~SFillPropData () +SFillPropData::~SFillPropData() { - VERIFY (0==counter); + VERIFY(0 == counter); }; -void SFillPropData::load () - { - // create ini +void SFillPropData::load() +{ +// create ini #ifdef XRGAME_EXPORTS - CInifile *Ini = pGameIni; -#else // XRGAME_EXPORTS - CInifile *Ini = 0; - string_path gm_name; - FS.update_path (gm_name,"$game_config$",GAME_CONFIG); - R_ASSERT3 (FS.exist(gm_name),"Couldn't find file",gm_name); - Ini = new CInifile(gm_name); -#endif // XRGAME_EXPORTS + CInifile* Ini = pGameIni; +#else // XRGAME_EXPORTS + CInifile* Ini = 0; + string_path gm_name; + FS.update_path(gm_name, "$game_config$", GAME_CONFIG); + R_ASSERT3(FS.exist(gm_name), "Couldn't find file", gm_name); + Ini = new CInifile(gm_name); +#endif // XRGAME_EXPORTS // location type - LPCSTR N,V; - u32 k; - for (int i=0; isection_exist(caSection)); - for (k = 0; Ini->r_line(caSection,k,&N,&V); ++k) - locations[i].push_back (xr_rtoken(V,atoi(N))); + LPCSTR N, V; + u32 k; + for (int i = 0; i < GameGraph::LOCATION_TYPE_COUNT; ++i) + { + VERIFY(locations[i].empty()); + string256 caSection, T; + strconcat(sizeof(caSection), caSection, SECTION_HEADER, itoa(i, T, 10)); + R_ASSERT(Ini->section_exist(caSection)); + for (k = 0; Ini->r_line(caSection, k, &N, &V); ++k) + locations[i].push_back(xr_rtoken(V, atoi(N))); } - for (k = 0; Ini->r_line("graph_points_draw_color_palette",k,&N,&V); ++k) + for (k = 0; Ini->r_line("graph_points_draw_color_palette", k, &N, &V); ++k) { u32 color; - if(1==sscanf(V,"%x", &color)) - { - location_colors[N] = color; - }else - Msg("! invalid record format in [graph_points_draw_color_palette] %s=%s",N,V); + if (1 == sscanf(V, "%x", &color)) { + location_colors[N] = color; + } + else + Msg("! invalid record format in [graph_points_draw_color_palette] %s=%s", N, V); } - + // level names/ids - VERIFY (level_ids.empty()); - for (k = 0; Ini->r_line("levels",k,&N,&V); ++k) - level_ids.push_back (Ini->r_string_wb(N,"caption")); + VERIFY(level_ids.empty()); + for (k = 0; Ini->r_line("levels", k, &N, &V); ++k) + level_ids.push_back(Ini->r_string_wb(N, "caption")); // story names { - VERIFY (story_names.empty()); - LPCSTR section = "story_ids"; - R_ASSERT (Ini->section_exist(section)); - for (k = 0; Ini->r_line(section,k,&N,&V); ++k) - story_names.push_back (xr_rtoken(V,atoi(N))); - - std::sort (story_names.begin(),story_names.end(),story_name_predicate()); - story_names.insert (story_names.begin(),xr_rtoken("NO STORY ID",ALife::_STORY_ID(-1))); + VERIFY(story_names.empty()); + LPCSTR section = "story_ids"; + R_ASSERT(Ini->section_exist(section)); + for (k = 0; Ini->r_line(section, k, &N, &V); ++k) + story_names.push_back(xr_rtoken(V, atoi(N))); + + std::sort(story_names.begin(), story_names.end(), story_name_predicate()); + story_names.insert(story_names.begin(), xr_rtoken("NO STORY ID", ALife::_STORY_ID(-1))); } // spawn story names { - VERIFY (spawn_story_names.empty()); - LPCSTR section = "spawn_story_ids"; - R_ASSERT (Ini->section_exist(section)); - for (k = 0; Ini->r_line(section,k,&N,&V); ++k) - spawn_story_names.push_back (xr_rtoken(V,atoi(N))); - - std::sort (spawn_story_names.begin(),spawn_story_names.end(),story_name_predicate()); - spawn_story_names.insert(spawn_story_names.begin(),xr_rtoken("NO SPAWN STORY ID",ALife::_SPAWN_STORY_ID(-1))); + VERIFY(spawn_story_names.empty()); + LPCSTR section = "spawn_story_ids"; + R_ASSERT(Ini->section_exist(section)); + for (k = 0; Ini->r_line(section, k, &N, &V); ++k) + spawn_story_names.push_back(xr_rtoken(V, atoi(N))); + + std::sort(spawn_story_names.begin(), spawn_story_names.end(), story_name_predicate()); + spawn_story_names.insert(spawn_story_names.begin(), xr_rtoken("NO SPAWN STORY ID", ALife::_SPAWN_STORY_ID(-1))); } #ifndef AI_COMPILER - //character profiles indexes - VERIFY (character_profiles.empty()); - for(int i = 0; i<=CCharacterInfo::GetMaxIndex(); i++) + // character profiles indexes + VERIFY(character_profiles.empty()); + for (int i = 0; i <= CCharacterInfo::GetMaxIndex(); i++) { character_profiles.push_back(CCharacterInfo::IndexToId(i)); } std::sort(character_profiles.begin(), character_profiles.end(), SortStringsByAlphabetPred); -#endif // AI_COMPILER - - // destroy ini +#endif // AI_COMPILER + +// destroy ini #ifndef XRGAME_EXPORTS - xr_delete (Ini); -#endif // XRGAME_EXPORTS + xr_delete(Ini); +#endif // XRGAME_EXPORTS - luabind::object table; - R_ASSERT (ai().script_engine().function_object("smart_covers.descriptions", table, LUA_TTABLE)); - luabind::object::iterator I = table.begin(); - luabind::object::iterator E = table.end(); - for ( ; I != E; ++I) - smart_covers.push_back (luabind::object_cast(I.key())); + luabind::object table; + R_ASSERT(ai().script_engine().function_object("smart_covers.descriptions", table, LUA_TTABLE)); + luabind::object::iterator I = table.begin(); + luabind::object::iterator E = table.end(); + for (; I != E; ++I) + smart_covers.push_back(luabind::object_cast(I.key())); - std::sort (smart_covers.begin(), smart_covers.end(), logical_string_predicate()); + std::sort(smart_covers.begin(), smart_covers.end(), logical_string_predicate()); }; -void SFillPropData::unload () +void SFillPropData::unload() { - for (int i=0; i 0); + VERIFY(counter > 0); --counter; - if (!counter) - unload (); + if (!counter) unload(); }; -void SFillPropData::inc () +void SFillPropData::inc() { - VERIFY (counter < 0xffffffff); + VERIFY(counter < 0xffffffff); - if (!counter) - load (); + if (!counter) load(); ++counter; } -static SFillPropData fp_data; -#endif // #ifdef XRSE_FACTORY_EXPORTS +static SFillPropData fp_data; +#endif // #ifdef XRSE_FACTORY_EXPORTS #ifndef XRGAME_EXPORTS -void CSE_ALifeTraderAbstract::FillProps (LPCSTR pref, PropItemVec& items) -{ -# ifdef XRSE_FACTORY_EXPORTS - PHelper().CreateU32 (items, PrepareKey(pref,*base()->s_name,"Money"), &m_dwMoney, 0, u32(-1)); - PHelper().CreateFlag32 (items, PrepareKey(pref,*base()->s_name,"Trader\\Infinite ammo"),&m_trader_flags, eTraderFlagInfiniteAmmo); - RListValue *value = PHelper().CreateRList (items, PrepareKey(pref,*base()->s_name,"npc profile"), - &m_sCharacterProfile, - &*fp_data.character_profiles.begin(), fp_data.character_profiles.size()); - - value->OnChangeEvent.bind (this,&CSE_ALifeTraderAbstract::OnChangeProfile); -# endif // #ifdef XRSE_FACTORY_EXPORTS -} -#endif // #ifndef XRGAME_EXPORTS +void CSE_ALifeTraderAbstract::FillProps(LPCSTR pref, PropItemVec& items) +{ +#ifdef XRSE_FACTORY_EXPORTS + PHelper().CreateU32(items, PrepareKey(pref, *base()->s_name, "Money"), &m_dwMoney, 0, u32(-1)); + PHelper().CreateFlag32( + items, PrepareKey(pref, *base()->s_name, "Trader\\Infinite ammo"), &m_trader_flags, eTraderFlagInfiniteAmmo); + RListValue* value = PHelper().CreateRList(items, PrepareKey(pref, *base()->s_name, "npc profile"), + &m_sCharacterProfile, &*fp_data.character_profiles.begin(), fp_data.character_profiles.size()); + + value->OnChangeEvent.bind(this, &CSE_ALifeTraderAbstract::OnChangeProfile); +#endif // #ifdef XRSE_FACTORY_EXPORTS +} +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeGraphPoint //////////////////////////////////////////////////////////////////////////// -CSE_ALifeGraphPoint::CSE_ALifeGraphPoint (LPCSTR caSection) : CSE_Abstract(caSection) +CSE_ALifeGraphPoint::CSE_ALifeGraphPoint(LPCSTR caSection) : CSE_Abstract(caSection) { -//. s_gameid = GAME_DUMMY; - m_tLocations[0] = 0; - m_tLocations[1] = 0; - m_tLocations[2] = 0; - m_tLocations[3] = 0; + //. s_gameid = GAME_DUMMY; + m_tLocations[0] = 0; + m_tLocations[1] = 0; + m_tLocations[2] = 0; + m_tLocations[3] = 0; #ifdef XRSE_FACTORY_EXPORTS - fp_data.inc (); -#endif // XRSE_FACTORY_EXPORTS + fp_data.inc(); +#endif // XRSE_FACTORY_EXPORTS } -CSE_ALifeGraphPoint::~CSE_ALifeGraphPoint () +CSE_ALifeGraphPoint::~CSE_ALifeGraphPoint() { #ifdef XRSE_FACTORY_EXPORTS - fp_data.dec (); -#endif // XRSE_FACTORY_EXPORTS + fp_data.dec(); +#endif // XRSE_FACTORY_EXPORTS } -void CSE_ALifeGraphPoint::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeGraphPoint::STATE_Read(NET_Packet& tNetPacket, u16 size) { - tNetPacket.r_stringZ (m_caConnectionPointName); + tNetPacket.r_stringZ(m_caConnectionPointName); if (m_wVersion < 33) - tNetPacket.r_u32 (); + tNetPacket.r_u32(); else - tNetPacket.r_stringZ (m_caConnectionLevelName); - tNetPacket.r_u8 (m_tLocations[0]); - tNetPacket.r_u8 (m_tLocations[1]); - tNetPacket.r_u8 (m_tLocations[2]); - tNetPacket.r_u8 (m_tLocations[3]); + tNetPacket.r_stringZ(m_caConnectionLevelName); + tNetPacket.r_u8(m_tLocations[0]); + tNetPacket.r_u8(m_tLocations[1]); + tNetPacket.r_u8(m_tLocations[2]); + tNetPacket.r_u8(m_tLocations[3]); }; -void CSE_ALifeGraphPoint::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeGraphPoint::STATE_Write(NET_Packet& tNetPacket) { - tNetPacket.w_stringZ (m_caConnectionPointName); - tNetPacket.w_stringZ (m_caConnectionLevelName); - tNetPacket.w_u8 (m_tLocations[0]); - tNetPacket.w_u8 (m_tLocations[1]); - tNetPacket.w_u8 (m_tLocations[2]); - tNetPacket.w_u8 (m_tLocations[3]); + tNetPacket.w_stringZ(m_caConnectionPointName); + tNetPacket.w_stringZ(m_caConnectionLevelName); + tNetPacket.w_u8(m_tLocations[0]); + tNetPacket.w_u8(m_tLocations[1]); + tNetPacket.w_u8(m_tLocations[2]); + tNetPacket.w_u8(m_tLocations[3]); }; -void CSE_ALifeGraphPoint::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeGraphPoint::UPDATE_Read(NET_Packet& tNetPacket) { } -void CSE_ALifeGraphPoint::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeGraphPoint::UPDATE_Write(NET_Packet& tNetPacket) { } #ifndef XRGAME_EXPORTS -void CSE_ALifeGraphPoint::FillProps (LPCSTR pref, PropItemVec& items) -{ -# ifdef XRSE_FACTORY_EXPORTS - PHelper().CreateRToken8 (items, PrepareKey(pref,*s_name,"Location\\1"), &m_tLocations[0], &*fp_data.locations[0].begin(), fp_data.locations[0].size()); - PHelper().CreateRToken8 (items, PrepareKey(pref,*s_name,"Location\\2"), &m_tLocations[1], &*fp_data.locations[1].begin(), fp_data.locations[1].size()); - PHelper().CreateRToken8 (items, PrepareKey(pref,*s_name,"Location\\3"), &m_tLocations[2], &*fp_data.locations[2].begin(), fp_data.locations[2].size()); - PHelper().CreateRToken8 (items, PrepareKey(pref,*s_name,"Location\\4"), &m_tLocations[3], &*fp_data.locations[3].begin(), fp_data.locations[3].size()); - PHelper().CreateRList (items, PrepareKey(pref,*s_name,"Connection\\Level name"), &m_caConnectionLevelName, &*fp_data.level_ids.begin(), fp_data.level_ids.size()); - PHelper().CreateRText (items, PrepareKey(pref,*s_name,"Connection\\Point name"), &m_caConnectionPointName); -# endif // #ifdef XRSE_FACTORY_EXPORTS -} - -void CSE_ALifeGraphPoint::on_render(CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent,int priority, bool strictB2F) -{ -# ifdef XRSE_FACTORY_EXPORTS -static const u32 IL[16]={0,1, 0,2, 0,3, 0,4, 1,3, 3,2, 2,4, 4,1}; -static const u32 IT[12]={1,3,0, 3,2,0, 2,4,0, 4,1,0}; -static Fvector PT [5] = { - {0.0f, 1.0f, 0.0f}, - {0.0f, 0.0f, -0.5f}, - {0.0f, 0.0f, 0.5f}, - {-0.5f, 0.0f, 0.0f}, - {0.5f, 0.0f, 0.0f}, -}; +void CSE_ALifeGraphPoint::FillProps(LPCSTR pref, PropItemVec& items) +{ +#ifdef XRSE_FACTORY_EXPORTS + PHelper().CreateRToken8(items, PrepareKey(pref, *s_name, "Location\\1"), &m_tLocations[0], + &*fp_data.locations[0].begin(), fp_data.locations[0].size()); + PHelper().CreateRToken8(items, PrepareKey(pref, *s_name, "Location\\2"), &m_tLocations[1], + &*fp_data.locations[1].begin(), fp_data.locations[1].size()); + PHelper().CreateRToken8(items, PrepareKey(pref, *s_name, "Location\\3"), &m_tLocations[2], + &*fp_data.locations[2].begin(), fp_data.locations[2].size()); + PHelper().CreateRToken8(items, PrepareKey(pref, *s_name, "Location\\4"), &m_tLocations[3], + &*fp_data.locations[3].begin(), fp_data.locations[3].size()); + PHelper().CreateRList(items, PrepareKey(pref, *s_name, "Connection\\Level name"), &m_caConnectionLevelName, + &*fp_data.level_ids.begin(), fp_data.level_ids.size()); + PHelper().CreateRText(items, PrepareKey(pref, *s_name, "Connection\\Point name"), &m_caConnectionPointName); +#endif // #ifdef XRSE_FACTORY_EXPORTS +} + +void CSE_ALifeGraphPoint::on_render( + CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent, int priority, bool strictB2F) +{ +#ifdef XRSE_FACTORY_EXPORTS + static const u32 IL[16] = {0, 1, 0, 2, 0, 3, 0, 4, 1, 3, 3, 2, 2, 4, 4, 1}; + static const u32 IT[12] = {1, 3, 0, 3, 2, 0, 2, 4, 0, 4, 1, 0}; + static Fvector PT[5] = { + {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, -0.5f}, {0.0f, 0.0f, 0.5f}, {-0.5f, 0.0f, 0.0f}, {0.5f, 0.0f, 0.0f}, + }; Fcolor C; u32 cc; string16 buff; - xr_sprintf(buff,"%03d_%03d_%03d_%03d",m_tLocations[0],m_tLocations[1],m_tLocations[2],m_tLocations[3]); + xr_sprintf(buff, "%03d_%03d_%03d_%03d", m_tLocations[0], m_tLocations[1], m_tLocations[2], m_tLocations[3]); xr_map::iterator it = fp_data.location_colors.find(buff); - if(it==fp_data.location_colors.end()) - { + if (it == fp_data.location_colors.end()) { it = fp_data.location_colors.find("default"); } - if(it!=fp_data.location_colors.end()) - cc=it->second; + if (it != fp_data.location_colors.end()) + cc = it->second; else - cc=0x107f7f7f; + cc = 0x107f7f7f; C.set(cc); - if(!bSelected) - C.a *= 0.6f; + if (!bSelected) C.a *= 0.6f; - du->DrawIndexedPrimitive(2/*D3DPT_LINELIST*/, 8, parent.c, PT, 6, IL, 16, C.get()); + du->DrawIndexedPrimitive(2 /*D3DPT_LINELIST*/, 8, parent.c, PT, 6, IL, 16, C.get()); C.mul_rgba(0.75f); - du->DrawIndexedPrimitive(4/*D3DPT_TRIANGLELIST*/, 4, parent.c, PT, 6, IT, 12, C.get()); - - if(bSelected) - du->DrawSelectionBox(parent.c, Fvector().set(0.5f,1.0f,0.5f),NULL); -# endif // #ifdef XRSE_FACTORY_EXPORTS + du->DrawIndexedPrimitive(4 /*D3DPT_TRIANGLELIST*/, 4, parent.c, PT, 6, IT, 12, C.get()); + + if (bSelected) du->DrawSelectionBox(parent.c, Fvector().set(0.5f, 1.0f, 0.5f), NULL); +#endif // #ifdef XRSE_FACTORY_EXPORTS } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeObject //////////////////////////////////////////////////////////////////////////// -CSE_ALifeObject::CSE_ALifeObject (LPCSTR caSection) : CSE_Abstract(caSection) -{ - m_bOnline = false; - m_fDistance = 0.0f; - ID = ALife::_OBJECT_ID(-1); - m_tGraphID = GameGraph::_GRAPH_ID(-1); - m_tSpawnID = ALife::_SPAWN_ID(-1); - m_bDirectControl = true; - m_bALifeControl = true; - m_tNodeID = u32(-1); - m_flags.one (); - m_story_id = INVALID_STORY_ID; - m_spawn_story_id = INVALID_SPAWN_STORY_ID; +CSE_ALifeObject::CSE_ALifeObject(LPCSTR caSection) : CSE_Abstract(caSection) +{ + m_bOnline = false; + m_fDistance = 0.0f; + ID = ALife::_OBJECT_ID(-1); + m_tGraphID = GameGraph::_GRAPH_ID(-1); + m_tSpawnID = ALife::_SPAWN_ID(-1); + m_bDirectControl = true; + m_bALifeControl = true; + m_tNodeID = u32(-1); + m_flags.one(); + m_story_id = INVALID_STORY_ID; + m_spawn_story_id = INVALID_SPAWN_STORY_ID; #ifdef XRGAME_EXPORTS - m_alife_simulator = 0; + m_alife_simulator = 0; #endif #ifdef XRSE_FACTORY_EXPORTS - fp_data.inc (); -#endif // XRSE_FACTORY_EXPORTS - m_flags.set (flOfflineNoMove,FALSE); - seed (u32(CPU::QPC() & 0xffffffff)); + fp_data.inc(); +#endif // XRSE_FACTORY_EXPORTS + m_flags.set(flOfflineNoMove, FALSE); + seed(u32(CPU::QPC() & 0xffffffff)); } #ifdef XRGAME_EXPORTS -CALifeSimulator &CSE_ALifeObject::alife () const +CALifeSimulator& CSE_ALifeObject::alife() const { - VERIFY (m_alife_simulator); - return (*m_alife_simulator); + VERIFY(m_alife_simulator); + return (*m_alife_simulator); } -Fvector CSE_ALifeObject::draw_level_position () const +Fvector CSE_ALifeObject::draw_level_position() const { - return (Position()); + return (Position()); } #endif -CSE_ALifeObject::~CSE_ALifeObject () +CSE_ALifeObject::~CSE_ALifeObject() { #ifdef XRSE_FACTORY_EXPORTS - fp_data.dec (); -#endif // XRSE_FACTORY_EXPORTS + fp_data.dec(); +#endif // XRSE_FACTORY_EXPORTS } -bool CSE_ALifeObject::move_offline () const +bool CSE_ALifeObject::move_offline() const { - return (!m_flags.test(flOfflineNoMove)); + return (!m_flags.test(flOfflineNoMove)); } -void CSE_ALifeObject::move_offline (bool value) +void CSE_ALifeObject::move_offline(bool value) { - m_flags.set (flOfflineNoMove,!value ? TRUE : FALSE); + m_flags.set(flOfflineNoMove, !value ? TRUE : FALSE); } -bool CSE_ALifeObject::visible_for_map () const +bool CSE_ALifeObject::visible_for_map() const { - return (!!m_flags.test(flVisibleForMap)); + return (!!m_flags.test(flVisibleForMap)); } -void CSE_ALifeObject::visible_for_map (bool value) +void CSE_ALifeObject::visible_for_map(bool value) { - m_flags.set (flVisibleForMap,value ? TRUE : FALSE); + m_flags.set(flVisibleForMap, value ? TRUE : FALSE); } -void CSE_ALifeObject::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeObject::STATE_Write(NET_Packet& tNetPacket) { - tNetPacket.w_u16 (m_tGraphID); - tNetPacket.w_float (m_fDistance); - tNetPacket.w_u32 (m_bDirectControl); - tNetPacket.w_u32 (m_tNodeID); - tNetPacket.w_u32 (m_flags.get()); - tNetPacket.w_stringZ (m_ini_string); - tNetPacket.w_u32 (m_story_id); - tNetPacket.w_u32 (m_spawn_story_id); + tNetPacket.w_u16(m_tGraphID); + tNetPacket.w_float(m_fDistance); + tNetPacket.w_u32(m_bDirectControl); + tNetPacket.w_u32(m_tNodeID); + tNetPacket.w_u32(m_flags.get()); + tNetPacket.w_stringZ(m_ini_string); + tNetPacket.w_u32(m_story_id); + tNetPacket.w_u32(m_spawn_story_id); } -void CSE_ALifeObject::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeObject::STATE_Read(NET_Packet& tNetPacket, u16 size) { if (m_wVersion >= 1) { if (m_wVersion > 24) { if (m_wVersion < 83) { - tNetPacket.r_float ();//m_spawn_probability); + tNetPacket.r_float(); // m_spawn_probability); } } - else { - tNetPacket.r_u8 (); + else + { + tNetPacket.r_u8(); /** u8 l_ucTemp; tNetPacket.r_u8 (l_ucTemp); @@ -450,153 +449,148 @@ void CSE_ALifeObject::STATE_Read (NET_Packet &tNetPacket, u16 size) /**/ } if (m_wVersion < 83) { - tNetPacket.r_u32 (); + tNetPacket.r_u32(); } if (m_wVersion < 4) { - u16 wDummy; - tNetPacket.r_u16 (wDummy); + u16 wDummy; + tNetPacket.r_u16(wDummy); } - tNetPacket.r_u16 (m_tGraphID); - tNetPacket.r_float (m_fDistance); + tNetPacket.r_u16(m_tGraphID); + tNetPacket.r_float(m_fDistance); } if (m_wVersion >= 4) { - u32 dwDummy; - tNetPacket.r_u32 (dwDummy); - m_bDirectControl = !!dwDummy; + u32 dwDummy; + tNetPacket.r_u32(dwDummy); + m_bDirectControl = !!dwDummy; } - - if (m_wVersion >= 8) - tNetPacket.r_u32 (m_tNodeID); - - if ((m_wVersion > 22) && (m_wVersion <= 79)) - tNetPacket.r_u16 (m_tSpawnID); - + + if (m_wVersion >= 8) tNetPacket.r_u32(m_tNodeID); + + if ((m_wVersion > 22) && (m_wVersion <= 79)) tNetPacket.r_u16(m_tSpawnID); + if ((m_wVersion > 23) && (m_wVersion < 84)) { - shared_str temp; - tNetPacket.r_stringZ (temp);//m_spawn_control); + shared_str temp; + tNetPacket.r_stringZ(temp); // m_spawn_control); } if (m_wVersion > 49) { - tNetPacket.r_u32 (m_flags.flags); + tNetPacket.r_u32(m_flags.flags); } - + if (m_wVersion > 57) { - if (m_ini_file) - xr_delete (m_ini_file); - tNetPacket.r_stringZ (m_ini_string); + if (m_ini_file) xr_delete(m_ini_file); + tNetPacket.r_stringZ(m_ini_string); } - if (m_wVersion > 61) - tNetPacket.r_u32 (m_story_id); + if (m_wVersion > 61) tNetPacket.r_u32(m_story_id); - if (m_wVersion > 111) - tNetPacket.r_u32 (m_spawn_story_id); + if (m_wVersion > 111) tNetPacket.r_u32(m_spawn_story_id); } -void CSE_ALifeObject::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeObject::UPDATE_Write(NET_Packet& tNetPacket) { } -void CSE_ALifeObject::UPDATE_Read (NET_Packet &tNetPacket) -{ -}; +void CSE_ALifeObject::UPDATE_Read(NET_Packet& tNetPacket){}; #ifndef XRGAME_EXPORTS -void CSE_ALifeObject::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeObject::FillProps(LPCSTR pref, PropItemVec& items) { -# ifdef XRSE_FACTORY_EXPORTS - inherited::FillProps (pref, items); - PHelper().CreateRText (items, PrepareKey(pref,*s_name,"Custom data"),&m_ini_string); +#ifdef XRSE_FACTORY_EXPORTS + inherited::FillProps(pref, items); + PHelper().CreateRText(items, PrepareKey(pref, *s_name, "Custom data"), &m_ini_string); if (m_flags.is(flUseSwitches)) { - PHelper().CreateFlag32 (items, PrepareKey(pref,*s_name,"ALife\\Can switch online"), &m_flags, flSwitchOnline); - PHelper().CreateFlag32 (items, PrepareKey(pref,*s_name,"ALife\\Can switch offline"), &m_flags, flSwitchOffline); - } - PHelper().CreateFlag32 (items, PrepareKey(pref,*s_name,"ALife\\Interactive"), &m_flags, flInteractive); - PHelper().CreateFlag32 (items, PrepareKey(pref,*s_name,"ALife\\Used AI locations"), &m_flags, flUsedAI_Locations); - PHelper().CreateRToken32 (items, PrepareKey(pref,*s_name,"ALife\\Story ID"), &m_story_id, &*fp_data.story_names.begin(), fp_data.story_names.size()); - PHelper().CreateRToken32 (items, PrepareKey(pref,*s_name,"ALife\\Spawn Story ID"), &m_spawn_story_id, &*fp_data.spawn_story_names.begin(), fp_data.spawn_story_names.size()); -# endif // #ifdef XRSE_FACTORY_EXPORTS + PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife\\Can switch online"), &m_flags, flSwitchOnline); + PHelper().CreateFlag32( + items, PrepareKey(pref, *s_name, "ALife\\Can switch offline"), &m_flags, flSwitchOffline); + } + PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife\\Interactive"), &m_flags, flInteractive); + PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife\\Used AI locations"), &m_flags, flUsedAI_Locations); + PHelper().CreateRToken32(items, PrepareKey(pref, *s_name, "ALife\\Story ID"), &m_story_id, + &*fp_data.story_names.begin(), fp_data.story_names.size()); + PHelper().CreateRToken32(items, PrepareKey(pref, *s_name, "ALife\\Spawn Story ID"), &m_spawn_story_id, + &*fp_data.spawn_story_names.begin(), fp_data.spawn_story_names.size()); +#endif // #ifdef XRSE_FACTORY_EXPORTS } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -u32 CSE_ALifeObject::ef_equipment_type () const +u32 CSE_ALifeObject::ef_equipment_type() const { - string16 temp; CLSID2TEXT(m_tClassID,temp); - R_ASSERT3 (false,"Invalid alife equipment type request, virtual function is not properly overloaded!",temp); - return (u32(-1)); -// return (6); + string16 temp; + CLSID2TEXT(m_tClassID, temp); + R_ASSERT3(false, "Invalid alife equipment type request, virtual function is not properly overloaded!", temp); + return (u32(-1)); + // return (6); } -u32 CSE_ALifeObject::ef_main_weapon_type () const +u32 CSE_ALifeObject::ef_main_weapon_type() const { - string16 temp; CLSID2TEXT(m_tClassID,temp); - R_ASSERT3 (false,"Invalid alife main weapon type request, virtual function is not properly overloaded!",temp); - return (u32(-1)); -// return (5); + string16 temp; + CLSID2TEXT(m_tClassID, temp); + R_ASSERT3(false, "Invalid alife main weapon type request, virtual function is not properly overloaded!", temp); + return (u32(-1)); + // return (5); } -u32 CSE_ALifeObject::ef_weapon_type () const +u32 CSE_ALifeObject::ef_weapon_type() const { -// string16 temp; CLSID2TEXT(m_tClassID,temp); -// R_ASSERT3 (false,"Invalid alife weapon type request, virtual function is not properly overloaded!",temp); -// return (u32(-1)); - return (0); + // string16 temp; CLSID2TEXT(m_tClassID,temp); + // R_ASSERT3 (false,"Invalid alife weapon type request, virtual function is not properly overloaded!",temp); + // return (u32(-1)); + return (0); } -u32 CSE_ALifeObject::ef_detector_type () const +u32 CSE_ALifeObject::ef_detector_type() const { - string16 temp; CLSID2TEXT(m_tClassID,temp); - R_ASSERT3 (false,"Invalid alife detector type request, virtual function is not properly overloaded!",temp); - return (u32(-1)); + string16 temp; + CLSID2TEXT(m_tClassID, temp); + R_ASSERT3(false, "Invalid alife detector type request, virtual function is not properly overloaded!", temp); + return (u32(-1)); } -bool CSE_ALifeObject::used_ai_locations () const +bool CSE_ALifeObject::used_ai_locations() const { - return (!!m_flags.is(flUsedAI_Locations)); + return (!!m_flags.is(flUsedAI_Locations)); } -bool CSE_ALifeObject::can_switch_online () const +bool CSE_ALifeObject::can_switch_online() const { - return (match_configuration() && !!m_flags.is(flSwitchOnline)); + return (match_configuration() && !!m_flags.is(flSwitchOnline)); } -bool CSE_ALifeObject::can_switch_offline () const +bool CSE_ALifeObject::can_switch_offline() const { - return (!match_configuration() || !!m_flags.is(flSwitchOffline)); + return (!match_configuration() || !!m_flags.is(flSwitchOffline)); } -bool CSE_ALifeObject::can_save () const +bool CSE_ALifeObject::can_save() const { - return (!!m_flags.is(flCanSave)); + return (!!m_flags.is(flCanSave)); } -bool CSE_ALifeObject::interactive () const +bool CSE_ALifeObject::interactive() const { - return ( - !!m_flags.is(flInteractive) && - !!m_flags.is(flVisibleForAI) && - !!m_flags.is(flUsefulForAI) - ); + return (!!m_flags.is(flInteractive) && !!m_flags.is(flVisibleForAI) && !!m_flags.is(flUsefulForAI)); } -void CSE_ALifeObject::use_ai_locations (bool value) +void CSE_ALifeObject::use_ai_locations(bool value) { - m_flags.set (flUsedAI_Locations, BOOL(value)); + m_flags.set(flUsedAI_Locations, BOOL(value)); } -void CSE_ALifeObject::can_switch_online (bool value) +void CSE_ALifeObject::can_switch_online(bool value) { - m_flags.set (flSwitchOnline,BOOL(value)); + m_flags.set(flSwitchOnline, BOOL(value)); } -void CSE_ALifeObject::can_switch_offline (bool value) +void CSE_ALifeObject::can_switch_offline(bool value) { - m_flags.set (flSwitchOffline,BOOL(value)); + m_flags.set(flSwitchOffline, BOOL(value)); } -void CSE_ALifeObject::interactive (bool value) +void CSE_ALifeObject::interactive(bool value) { - m_flags.set (flInteractive,BOOL(value)); + m_flags.set(flInteractive, BOOL(value)); } //////////////////////////////////////////////////////////////////////////// @@ -604,57 +598,56 @@ void CSE_ALifeObject::interactive (bool value) //////////////////////////////////////////////////////////////////////////// CSE_ALifeGroupAbstract::CSE_ALifeGroupAbstract(LPCSTR caSection) { - m_tpMembers.clear (); - m_bCreateSpawnPositions = true; - m_wCount = 1; - m_tNextBirthTime = 0; + m_tpMembers.clear(); + m_bCreateSpawnPositions = true; + m_wCount = 1; + m_tNextBirthTime = 0; } -CSE_Abstract *CSE_ALifeGroupAbstract::init () +CSE_Abstract* CSE_ALifeGroupAbstract::init() { - return (base()); + return (base()); } CSE_ALifeGroupAbstract::~CSE_ALifeGroupAbstract() { } -void CSE_ALifeGroupAbstract::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeGroupAbstract::STATE_Read(NET_Packet& tNetPacket, u16 size) { u16 m_wVersion = base()->m_wVersion; - u32 dwDummy; - tNetPacket.r_u32 (dwDummy); - m_bCreateSpawnPositions = !!dwDummy; - tNetPacket.r_u16 (m_wCount); - if (m_wVersion > 19) - load_data (m_tpMembers,tNetPacket); + u32 dwDummy; + tNetPacket.r_u32(dwDummy); + m_bCreateSpawnPositions = !!dwDummy; + tNetPacket.r_u16(m_wCount); + if (m_wVersion > 19) load_data(m_tpMembers, tNetPacket); }; -void CSE_ALifeGroupAbstract::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeGroupAbstract::STATE_Write(NET_Packet& tNetPacket) { - tNetPacket.w_u32 (m_bCreateSpawnPositions); - tNetPacket.w_u16 (m_wCount); - save_data (m_tpMembers,tNetPacket); + tNetPacket.w_u32(m_bCreateSpawnPositions); + tNetPacket.w_u16(m_wCount); + save_data(m_tpMembers, tNetPacket); }; -void CSE_ALifeGroupAbstract::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeGroupAbstract::UPDATE_Read(NET_Packet& tNetPacket) { - u32 dwDummy; - tNetPacket.r_u32 (dwDummy); - m_bCreateSpawnPositions = !!dwDummy; + u32 dwDummy; + tNetPacket.r_u32(dwDummy); + m_bCreateSpawnPositions = !!dwDummy; }; -void CSE_ALifeGroupAbstract::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeGroupAbstract::UPDATE_Write(NET_Packet& tNetPacket) { - tNetPacket.w_u32 (m_bCreateSpawnPositions); + tNetPacket.w_u32(m_bCreateSpawnPositions); }; #ifndef XRGAME_EXPORTS -void CSE_ALifeGroupAbstract::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeGroupAbstract::FillProps(LPCSTR pref, PropItemVec& items) { - PHelper().CreateU16 (items, PrepareKey(pref, "ALife\\Count"), &m_wCount, 0,0xff); -}; -#endif // #ifndef XRGAME_EXPORTS + PHelper().CreateU16(items, PrepareKey(pref, "ALife\\Count"), &m_wCount, 0, 0xff); +}; +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeDynamicObject @@ -662,143 +655,138 @@ void CSE_ALifeGroupAbstract::FillProps (LPCSTR pref, PropItemVec& items) CSE_ALifeDynamicObject::CSE_ALifeDynamicObject(LPCSTR caSection) : CSE_ALifeObject(caSection) { - m_tTimeID = 0; - m_switch_counter = u64(-1); + m_tTimeID = 0; + m_switch_counter = u64(-1); } CSE_ALifeDynamicObject::~CSE_ALifeDynamicObject() { } -void CSE_ALifeDynamicObject::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeDynamicObject::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeDynamicObject::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeDynamicObject::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket, size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeDynamicObject::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeDynamicObject::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); }; -void CSE_ALifeDynamicObject::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeDynamicObject::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); }; #ifndef XRGAME_EXPORTS -void CSE_ALifeDynamicObject::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeDynamicObject::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref,values); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeDynamicObjectVisual //////////////////////////////////////////////////////////////////////////// -CSE_ALifeDynamicObjectVisual::CSE_ALifeDynamicObjectVisual(LPCSTR caSection) : CSE_ALifeDynamicObject(caSection), CSE_Visual() +CSE_ALifeDynamicObjectVisual::CSE_ALifeDynamicObjectVisual(LPCSTR caSection) + : CSE_ALifeDynamicObject(caSection), CSE_Visual() { - if (pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); + if (pSettings->line_exist(caSection, "visual")) set_visual(pSettings->r_string(caSection, "visual")); } CSE_ALifeDynamicObjectVisual::~CSE_ALifeDynamicObjectVisual() { } -CSE_Visual* CSE_ALifeDynamicObjectVisual::visual () +CSE_Visual* CSE_ALifeDynamicObjectVisual::visual() { - return (this); + return (this); } -void CSE_ALifeDynamicObjectVisual::STATE_Write(NET_Packet &tNetPacket) +void CSE_ALifeDynamicObjectVisual::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - visual_write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + visual_write(tNetPacket); } -void CSE_ALifeDynamicObjectVisual::STATE_Read(NET_Packet &tNetPacket, u16 size) +void CSE_ALifeDynamicObjectVisual::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket, size); - if (m_wVersion > 31) - visual_read (tNetPacket,m_wVersion); + inherited1::STATE_Read(tNetPacket, size); + if (m_wVersion > 31) visual_read(tNetPacket, m_wVersion); } -void CSE_ALifeDynamicObjectVisual::UPDATE_Write(NET_Packet &tNetPacket) +void CSE_ALifeDynamicObjectVisual::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); }; -void CSE_ALifeDynamicObjectVisual::UPDATE_Read(NET_Packet &tNetPacket) +void CSE_ALifeDynamicObjectVisual::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); }; #ifndef XRGAME_EXPORTS -void CSE_ALifeDynamicObjectVisual::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeDynamicObjectVisual::FillProps(LPCSTR pref, PropItemVec& items) { - inherited1::FillProps (pref,items); - inherited2::FillProps (pref,items); + inherited1::FillProps(pref, items); + inherited2::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifePHSkeletonObject //////////////////////////////////////////////////////////////////////////// -CSE_ALifePHSkeletonObject::CSE_ALifePHSkeletonObject(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection),CSE_PHSkeleton(caSection) +CSE_ALifePHSkeletonObject::CSE_ALifePHSkeletonObject(LPCSTR caSection) + : CSE_ALifeDynamicObjectVisual(caSection), CSE_PHSkeleton(caSection) { - m_flags.set (flUseSwitches,FALSE); - m_flags.set (flSwitchOffline,FALSE); + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); } CSE_ALifePHSkeletonObject::~CSE_ALifePHSkeletonObject() { - } - -void CSE_ALifePHSkeletonObject::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifePHSkeletonObject::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read(tNetPacket,size); - if (m_wVersion>=64) - inherited2::STATE_Read(tNetPacket,size); - + inherited1::STATE_Read(tNetPacket, size); + if (m_wVersion >= 64) inherited2::STATE_Read(tNetPacket, size); } -void CSE_ALifePHSkeletonObject::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifePHSkeletonObject::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); } - -void CSE_ALifePHSkeletonObject::load (NET_Packet &tNetPacket) +void CSE_ALifePHSkeletonObject::load(NET_Packet& tNetPacket) { - inherited1::load (tNetPacket); - inherited2::load (tNetPacket); + inherited1::load(tNetPacket); + inherited2::load(tNetPacket); } -void CSE_ALifePHSkeletonObject::UPDATE_Write(NET_Packet &tNetPacket) +void CSE_ALifePHSkeletonObject::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); }; -void CSE_ALifePHSkeletonObject::UPDATE_Read(NET_Packet &tNetPacket) +void CSE_ALifePHSkeletonObject::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); }; -bool CSE_ALifePHSkeletonObject::can_save () const +bool CSE_ALifePHSkeletonObject::can_save() const { - return CSE_PHSkeleton::need_save(); + return CSE_PHSkeleton::need_save(); } -bool CSE_ALifePHSkeletonObject::used_ai_locations () const +bool CSE_ALifePHSkeletonObject::used_ai_locations() const { return false; } @@ -806,322 +794,305 @@ bool CSE_ALifePHSkeletonObject::used_ai_locations () const #ifndef XRGAME_EXPORTS void CSE_ALifePHSkeletonObject::FillProps(LPCSTR pref, PropItemVec& items) { - inherited1::FillProps (pref,items); - inherited2::FillProps (pref,items); + inherited1::FillProps(pref, items); + inherited2::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeSpaceRestrictor //////////////////////////////////////////////////////////////////////////// -CSE_ALifeSpaceRestrictor::CSE_ALifeSpaceRestrictor (LPCSTR caSection) : CSE_ALifeDynamicObject(caSection) +CSE_ALifeSpaceRestrictor::CSE_ALifeSpaceRestrictor(LPCSTR caSection) : CSE_ALifeDynamicObject(caSection) { - m_flags.set (flUseSwitches,FALSE); - m_space_restrictor_type = RestrictionSpace::eDefaultRestrictorTypeNone; - m_flags.set (flUsedAI_Locations,FALSE); - m_spawn_flags.set (flSpawnDestroyOnSpawn,FALSE); - m_flags.set (flCheckForSeparator,TRUE); + m_flags.set(flUseSwitches, FALSE); + m_space_restrictor_type = RestrictionSpace::eDefaultRestrictorTypeNone; + m_flags.set(flUsedAI_Locations, FALSE); + m_spawn_flags.set(flSpawnDestroyOnSpawn, FALSE); + m_flags.set(flCheckForSeparator, TRUE); } -CSE_ALifeSpaceRestrictor::~CSE_ALifeSpaceRestrictor () +CSE_ALifeSpaceRestrictor::~CSE_ALifeSpaceRestrictor() { } -bool CSE_ALifeSpaceRestrictor::can_switch_offline () const +bool CSE_ALifeSpaceRestrictor::can_switch_offline() const { - return (false); + return (false); } -bool CSE_ALifeSpaceRestrictor::used_ai_locations () const +bool CSE_ALifeSpaceRestrictor::used_ai_locations() const { - return (false); + return (false); } -IServerEntityShape* CSE_ALifeSpaceRestrictor::shape () +IServerEntityShape* CSE_ALifeSpaceRestrictor::shape() { - return (this); + return (this); } -void CSE_ALifeSpaceRestrictor::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeSpaceRestrictor::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket,size); - cform_read (tNetPacket); - if (m_wVersion > 74) - m_space_restrictor_type = tNetPacket.r_u8(); + inherited1::STATE_Read(tNetPacket, size); + cform_read(tNetPacket); + if (m_wVersion > 74) m_space_restrictor_type = tNetPacket.r_u8(); } -void CSE_ALifeSpaceRestrictor::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeSpaceRestrictor::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - cform_write (tNetPacket); - tNetPacket.w_u8 (m_space_restrictor_type); + inherited1::STATE_Write(tNetPacket); + cform_write(tNetPacket); + tNetPacket.w_u8(m_space_restrictor_type); } -void CSE_ALifeSpaceRestrictor::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeSpaceRestrictor::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); } -void CSE_ALifeSpaceRestrictor::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeSpaceRestrictor::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); } -xr_token defaul_retrictor_types[]={ - { "NOT A restrictor", RestrictionSpace::eRestrictorTypeNone}, - { "NONE default restrictor", RestrictionSpace::eDefaultRestrictorTypeNone}, - { "OUT default restrictor", RestrictionSpace::eDefaultRestrictorTypeOut }, - { "IN default restrictor", RestrictionSpace::eDefaultRestrictorTypeIn }, - { 0, 0} -}; +xr_token defaul_retrictor_types[] = {{"NOT A restrictor", RestrictionSpace::eRestrictorTypeNone}, + {"NONE default restrictor", RestrictionSpace::eDefaultRestrictorTypeNone}, + {"OUT default restrictor", RestrictionSpace::eDefaultRestrictorTypeOut}, + {"IN default restrictor", RestrictionSpace::eDefaultRestrictorTypeIn}, {0, 0}}; #ifndef XRGAME_EXPORTS -void CSE_ALifeSpaceRestrictor::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeSpaceRestrictor::FillProps(LPCSTR pref, PropItemVec& items) { - inherited1::FillProps (pref,items); - PHelper().CreateToken8 (items, PrepareKey(pref,*s_name,"restrictor type"), &m_space_restrictor_type, defaul_retrictor_types); - PHelper().CreateFlag32 (items, PrepareKey(pref,*s_name,"check for separator"), &m_flags, flCheckForSeparator); + inherited1::FillProps(pref, items); + PHelper().CreateToken8( + items, PrepareKey(pref, *s_name, "restrictor type"), &m_space_restrictor_type, defaul_retrictor_types); + PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "check for separator"), &m_flags, flCheckForSeparator); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeLevelChanger //////////////////////////////////////////////////////////////////////////// CSE_ALifeLevelChanger::CSE_ALifeLevelChanger(LPCSTR caSection) : CSE_ALifeSpaceRestrictor(caSection) { - m_tNextGraphID = GameGraph::_GRAPH_ID(-1); - m_dwNextNodeID = u32(-1); - m_tNextPosition.set (0.f,0.f,0.f); - m_tAngles.set (0.f,0.f,0.f); + m_tNextGraphID = GameGraph::_GRAPH_ID(-1); + m_dwNextNodeID = u32(-1); + m_tNextPosition.set(0.f, 0.f, 0.f); + m_tAngles.set(0.f, 0.f, 0.f); #ifdef XRSE_FACTORY_EXPORTS - fp_data.inc (); -#endif // XRSE_FACTORY_EXPORTS - m_bSilentMode = FALSE; + fp_data.inc(); +#endif // XRSE_FACTORY_EXPORTS + m_bSilentMode = FALSE; } -CSE_ALifeLevelChanger::~CSE_ALifeLevelChanger()\ +CSE_ALifeLevelChanger::~CSE_ALifeLevelChanger() { #ifdef XRSE_FACTORY_EXPORTS - fp_data.dec (); -#endif // XRSE_FACTORY_EXPORTS + fp_data.dec(); +#endif // XRSE_FACTORY_EXPORTS } -void CSE_ALifeLevelChanger::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeLevelChanger::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); if (m_wVersion < 34) { - tNetPacket.r_u32 (); - tNetPacket.r_u32 (); + tNetPacket.r_u32(); + tNetPacket.r_u32(); } - else { - tNetPacket.r_u16 (m_tNextGraphID); - tNetPacket.r_u32 (m_dwNextNodeID); - tNetPacket.r_float (m_tNextPosition.x); - tNetPacket.r_float (m_tNextPosition.y); - tNetPacket.r_float (m_tNextPosition.z); + else + { + tNetPacket.r_u16(m_tNextGraphID); + tNetPacket.r_u32(m_dwNextNodeID); + tNetPacket.r_float(m_tNextPosition.x); + tNetPacket.r_float(m_tNextPosition.y); + tNetPacket.r_float(m_tNextPosition.z); if (m_wVersion <= 53) - m_tAngles.set (0.f,tNetPacket.r_float(),0.f); + m_tAngles.set(0.f, tNetPacket.r_float(), 0.f); else - tNetPacket.r_vec3 (m_tAngles); + tNetPacket.r_vec3(m_tAngles); } - tNetPacket.r_stringZ (m_caLevelToChange); - tNetPacket.r_stringZ (m_caLevelPointToChange); - - if (m_wVersion > 116) - m_bSilentMode = !!tNetPacket.r_u8(); + tNetPacket.r_stringZ(m_caLevelToChange); + tNetPacket.r_stringZ(m_caLevelPointToChange); + if (m_wVersion > 116) m_bSilentMode = !!tNetPacket.r_u8(); } -void CSE_ALifeLevelChanger::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeLevelChanger::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_u16 (m_tNextGraphID); - tNetPacket.w_u32 (m_dwNextNodeID); - tNetPacket.w_float (m_tNextPosition.x); - tNetPacket.w_float (m_tNextPosition.y); - tNetPacket.w_float (m_tNextPosition.z); - tNetPacket.w_vec3 (m_tAngles); - tNetPacket.w_stringZ (m_caLevelToChange); - tNetPacket.w_stringZ (m_caLevelPointToChange); - tNetPacket.w_u8 (m_bSilentMode?1:0); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_u16(m_tNextGraphID); + tNetPacket.w_u32(m_dwNextNodeID); + tNetPacket.w_float(m_tNextPosition.x); + tNetPacket.w_float(m_tNextPosition.y); + tNetPacket.w_float(m_tNextPosition.z); + tNetPacket.w_vec3(m_tAngles); + tNetPacket.w_stringZ(m_caLevelToChange); + tNetPacket.w_stringZ(m_caLevelPointToChange); + tNetPacket.w_u8(m_bSilentMode ? 1 : 0); } -void CSE_ALifeLevelChanger::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeLevelChanger::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeLevelChanger::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeLevelChanger::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeLevelChanger::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeLevelChanger::FillProps(LPCSTR pref, PropItemVec& items) { -# ifdef XRSE_FACTORY_EXPORTS - inherited::FillProps (pref,items); - - PHelper().CreateRList (items,PrepareKey(pref,*s_name,"Level to change"), &m_caLevelToChange, &*fp_data.level_ids.begin(), fp_data.level_ids.size()); - PHelper().CreateRText (items,PrepareKey(pref,*s_name,"Level point to change"), &m_caLevelPointToChange); +#ifdef XRSE_FACTORY_EXPORTS + inherited::FillProps(pref, items); + + PHelper().CreateRList(items, PrepareKey(pref, *s_name, "Level to change"), &m_caLevelToChange, + &*fp_data.level_ids.begin(), fp_data.level_ids.size()); + PHelper().CreateRText(items, PrepareKey(pref, *s_name, "Level point to change"), &m_caLevelPointToChange); - PHelper().CreateBOOL (items,PrepareKey(pref,*s_name,"Silent mode"), &m_bSilentMode); -# endif // #ifdef XRSE_FACTORY_EXPORTS + PHelper().CreateBOOL(items, PrepareKey(pref, *s_name, "Silent mode"), &m_bSilentMode); +#endif // #ifdef XRSE_FACTORY_EXPORTS } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeObjectPhysic //////////////////////////////////////////////////////////////////////////// -CSE_ALifeObjectPhysic::CSE_ALifeObjectPhysic(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection), CSE_PHSkeleton(caSection) +CSE_ALifeObjectPhysic::CSE_ALifeObjectPhysic(LPCSTR caSection) + : CSE_ALifeDynamicObjectVisual(caSection), CSE_PHSkeleton(caSection) { - type = epotSkeleton; - mass = 10.f; + type = epotSkeleton; + mass = 10.f; - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - { - set_visual (pSettings->r_string(caSection,"visual")); - - if(pSettings->line_exist(caSection,"startup_animation")) - startup_animation = pSettings->r_string(caSection,"startup_animation"); + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) { + set_visual(pSettings->r_string(caSection, "visual")); + + if (pSettings->line_exist(caSection, "startup_animation")) + startup_animation = pSettings->r_string(caSection, "startup_animation"); } - - if(pSettings->line_exist(caSection,"fixed_bones")) - fixed_bones = pSettings->r_string(caSection,"fixed_bones"); - - m_flags.set (flUseSwitches,FALSE); - m_flags.set (flSwitchOffline,FALSE); - m_flags.set (flUsedAI_Locations,FALSE); - + + if (pSettings->line_exist(caSection, "fixed_bones")) fixed_bones = pSettings->r_string(caSection, "fixed_bones"); + + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); + m_flags.set(flUsedAI_Locations, FALSE); + #ifdef XRGAME_EXPORTS - m_freeze_time = Device.dwTimeGlobal; -# ifdef DEBUG - m_last_update_time = Device.dwTimeGlobal; -# endif + m_freeze_time = Device.dwTimeGlobal; +#ifdef DEBUG + m_last_update_time = Device.dwTimeGlobal; +#endif #else - m_freeze_time = 0; + m_freeze_time = 0; #endif - m_relevent_random.seed (u32(CPU::GetCLK() & u32(-1))); + m_relevent_random.seed(u32(CPU::GetCLK() & u32(-1))); } -CSE_ALifeObjectPhysic::~CSE_ALifeObjectPhysic () +CSE_ALifeObjectPhysic::~CSE_ALifeObjectPhysic() { } -void CSE_ALifeObjectPhysic::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeObjectPhysic::STATE_Read(NET_Packet& tNetPacket, u16 size) { if (m_wVersion >= 14) if (m_wVersion >= 16) { - inherited1::STATE_Read(tNetPacket,size); - if (m_wVersion < 32) - visual_read (tNetPacket,m_wVersion); + inherited1::STATE_Read(tNetPacket, size); + if (m_wVersion < 32) visual_read(tNetPacket, m_wVersion); } - else { - CSE_ALifeObject::STATE_Read(tNetPacket,size); - visual_read (tNetPacket,m_wVersion); + else + { + CSE_ALifeObject::STATE_Read(tNetPacket, size); + visual_read(tNetPacket, m_wVersion); } - if (m_wVersion>=64) inherited2::STATE_Read(tNetPacket,size); - - tNetPacket.r_u32 (type); - tNetPacket.r_float (mass); - - if (m_wVersion > 9) - tNetPacket.r_stringZ (fixed_bones); + if (m_wVersion >= 64) inherited2::STATE_Read(tNetPacket, size); - if (m_wVersion<65&&m_wVersion > 28) - tNetPacket.r_stringZ (startup_animation); + tNetPacket.r_u32(type); + tNetPacket.r_float(mass); - if(m_wVersion<64) - { - if (m_wVersion > 39) // > 39 - tNetPacket.r_u8 (_flags.flags); + if (m_wVersion > 9) tNetPacket.r_stringZ(fixed_bones); + + if (m_wVersion < 65 && m_wVersion > 28) tNetPacket.r_stringZ(startup_animation); - if (m_wVersion>56) - tNetPacket.r_u16 (source_id); + if (m_wVersion < 64) { + if (m_wVersion > 39) // > 39 + tNetPacket.r_u8(_flags.flags); - if (m_wVersion>60 && _flags.test(flSavedData)) { + if (m_wVersion > 56) tNetPacket.r_u16(source_id); + + if (m_wVersion > 60 && _flags.test(flSavedData)) { data_load(tNetPacket); } } - set_editor_flag (flVisualAnimationChange); + set_editor_flag(flVisualAnimationChange); } -void CSE_ALifeObjectPhysic::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeObjectPhysic::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); - tNetPacket.w_u32 (type); - tNetPacket.w_float (mass); - tNetPacket.w_stringZ (fixed_bones); - + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); + tNetPacket.w_u32(type); + tNetPacket.w_float(mass); + tNetPacket.w_stringZ(fixed_bones); } -static inline bool check (const u8 &mask, const u8 &test) +static inline bool check(const u8& mask, const u8& test) { - return (!!(mask & test)); + return (!!(mask & test)); } -const u32 CSE_ALifeObjectPhysic::m_freeze_delta_time = 5000; -const u32 CSE_ALifeObjectPhysic::random_limit = 40; +const u32 CSE_ALifeObjectPhysic::m_freeze_delta_time = 5000; +const u32 CSE_ALifeObjectPhysic::random_limit = 40; #ifdef DEBUG -const u32 CSE_ALifeObjectPhysic::m_update_delta_time = 0; -#endif // #ifdef DEBUG +const u32 CSE_ALifeObjectPhysic::m_update_delta_time = 0; +#endif // #ifdef DEBUG -//if TRUE, then object sends update packet +// if TRUE, then object sends update packet BOOL CSE_ALifeObjectPhysic::Net_Relevant() { - if (!freezed) - { + if (!freezed) { #ifdef XRGAME_EXPORTS -#ifdef DEBUG //this block of code is only for test - if (Device.dwTimeGlobal < (m_last_update_time + m_update_delta_time)) - return FALSE; +#ifdef DEBUG // this block of code is only for test + if (Device.dwTimeGlobal < (m_last_update_time + m_update_delta_time)) return FALSE; #endif #endif - return TRUE; + return TRUE; } #ifdef XRGAME_EXPORTS - if (Device.dwTimeGlobal >= (m_freeze_time + m_freeze_delta_time)) - return FALSE; + if (Device.dwTimeGlobal >= (m_freeze_time + m_freeze_delta_time)) return FALSE; #endif - if (!prev_freezed) - { - prev_freezed = true; //i.e. freezed - return TRUE; + if (!prev_freezed) { + prev_freezed = true; // i.e. freezed + return TRUE; } - if (m_relevent_random.randI(random_limit)) - return FALSE; + if (m_relevent_random.randI(random_limit)) return FALSE; - return TRUE; + return TRUE; } -void CSE_ALifeObjectPhysic::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeObjectPhysic::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); - if (tNetPacket.r_eof()) //backward compatibility + if (tNetPacket.r_eof()) // backward compatibility return; -////////////////////////////////////////////////////////////////////////// - tNetPacket.r_u8 (m_u8NumItems); + ////////////////////////////////////////////////////////////////////////// + tNetPacket.r_u8(m_u8NumItems); if (!m_u8NumItems) { return; } - mask_num_items num_items; - num_items.common = m_u8NumItems; - m_u8NumItems = num_items.num_items; + mask_num_items num_items; + num_items.common = m_u8NumItems; + m_u8NumItems = num_items.num_items; + + R_ASSERT2(m_u8NumItems < (u8(1) << 5), make_string("%d", m_u8NumItems)); - R_ASSERT2 ( - m_u8NumItems < (u8(1) << 5), - make_string("%d",m_u8NumItems) - ); - /*if (check(num_items.mask,animated)) { tNetPacket.r_float(m_blend_timeCurrent); @@ -1133,33 +1104,33 @@ void CSE_ALifeObjectPhysic::UPDATE_Read (NET_Packet &tNetPacket) }*/ { - tNetPacket.r_vec3 (State.force); - tNetPacket.r_vec3 (State.torque); + tNetPacket.r_vec3(State.force); + tNetPacket.r_vec3(State.torque); - tNetPacket.r_vec3 (State.position); + tNetPacket.r_vec3(State.position); - tNetPacket.r_float (State.quaternion.x); - tNetPacket.r_float (State.quaternion.y); - tNetPacket.r_float (State.quaternion.z); - tNetPacket.r_float (State.quaternion.w); + tNetPacket.r_float(State.quaternion.x); + tNetPacket.r_float(State.quaternion.y); + tNetPacket.r_float(State.quaternion.z); + tNetPacket.r_float(State.quaternion.w); - State.enabled = check(num_items.mask,inventory_item_state_enabled); + State.enabled = check(num_items.mask, inventory_item_state_enabled); - if (!check(num_items.mask,inventory_item_angular_null)) { - tNetPacket.r_float (State.angular_vel.x); - tNetPacket.r_float (State.angular_vel.y); - tNetPacket.r_float (State.angular_vel.z); + if (!check(num_items.mask, inventory_item_angular_null)) { + tNetPacket.r_float(State.angular_vel.x); + tNetPacket.r_float(State.angular_vel.y); + tNetPacket.r_float(State.angular_vel.z); } else - State.angular_vel.set (0.f,0.f,0.f); + State.angular_vel.set(0.f, 0.f, 0.f); - if (!check(num_items.mask,inventory_item_linear_null)) { - tNetPacket.r_float (State.linear_vel.x); - tNetPacket.r_float (State.linear_vel.y); - tNetPacket.r_float (State.linear_vel.z); + if (!check(num_items.mask, inventory_item_linear_null)) { + tNetPacket.r_float(State.linear_vel.x); + tNetPacket.r_float(State.linear_vel.y); + tNetPacket.r_float(State.linear_vel.z); } else - State.linear_vel.set (0.f,0.f,0.f); + State.linear_vel.set(0.f, 0.f, 0.f); /*if (check(num_items.mask,animated)) { @@ -1167,51 +1138,48 @@ void CSE_ALifeObjectPhysic::UPDATE_Read (NET_Packet &tNetPacket) }*/ } prev_freezed = freezed; - if (tNetPacket.r_eof()) // in case spawn + update + if (tNetPacket.r_eof()) // in case spawn + update { freezed = false; return; } - if (tNetPacket.r_u8()) - { + if (tNetPacket.r_u8()) { freezed = false; } - else { + else + { if (!freezed) #ifdef XRGAME_EXPORTS - m_freeze_time = Device.dwTimeGlobal; + m_freeze_time = Device.dwTimeGlobal; #else - m_freeze_time = 0; + m_freeze_time = 0; #endif freezed = true; } } -void CSE_ALifeObjectPhysic::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeObjectPhysic::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); -////////////////////////////////////////////////////////////////////////// + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); + ////////////////////////////////////////////////////////////////////////// if (!m_u8NumItems) { - tNetPacket.w_u8 (0); + tNetPacket.w_u8(0); return; } - mask_num_items num_items; - num_items.mask = 0; - num_items.num_items = m_u8NumItems; + mask_num_items num_items; + num_items.mask = 0; + num_items.num_items = m_u8NumItems; - R_ASSERT2 ( - num_items.num_items < (u8(1) << 5), - make_string("%d",num_items.num_items) - ); + R_ASSERT2(num_items.num_items < (u8(1) << 5), make_string("%d", num_items.num_items)); - if (State.enabled) num_items.mask |= inventory_item_state_enabled; + if (State.enabled) num_items.mask |= inventory_item_state_enabled; if (fis_zero(State.angular_vel.square_magnitude())) num_items.mask |= inventory_item_angular_null; - if (fis_zero(State.linear_vel.square_magnitude())) num_items.mask |= inventory_item_linear_null; - //if (anim_use) num_items.mask |= animated; + if (fis_zero(State.linear_vel.square_magnitude())) num_items.mask |= inventory_item_linear_null; + // if (anim_use) num_items.mask |= animated; - tNetPacket.w_u8 (num_items.common); + tNetPacket.w_u8(num_items.common); /*if(check(num_items.mask,animated)) { @@ -1219,236 +1187,222 @@ void CSE_ALifeObjectPhysic::UPDATE_Write (NET_Packet &tNetPacket) }*/ { - tNetPacket.w_vec3 (State.force); - tNetPacket.w_vec3 (State.torque); + tNetPacket.w_vec3(State.force); + tNetPacket.w_vec3(State.torque); - tNetPacket.w_vec3 (State.position); + tNetPacket.w_vec3(State.position); - tNetPacket.w_float (State.quaternion.x); - tNetPacket.w_float (State.quaternion.y); - tNetPacket.w_float (State.quaternion.z); - tNetPacket.w_float (State.quaternion.w); + tNetPacket.w_float(State.quaternion.x); + tNetPacket.w_float(State.quaternion.y); + tNetPacket.w_float(State.quaternion.z); + tNetPacket.w_float(State.quaternion.w); - if (!check(num_items.mask,inventory_item_angular_null)) { - tNetPacket.w_float (State.angular_vel.x); - tNetPacket.w_float (State.angular_vel.y); - tNetPacket.w_float (State.angular_vel.z); + if (!check(num_items.mask, inventory_item_angular_null)) { + tNetPacket.w_float(State.angular_vel.x); + tNetPacket.w_float(State.angular_vel.y); + tNetPacket.w_float(State.angular_vel.z); } - if (!check(num_items.mask,inventory_item_linear_null)) { - tNetPacket.w_float (State.linear_vel.x); - tNetPacket.w_float (State.linear_vel.y); - tNetPacket.w_float (State.linear_vel.z); + if (!check(num_items.mask, inventory_item_linear_null)) { + tNetPacket.w_float(State.linear_vel.x); + tNetPacket.w_float(State.linear_vel.y); + tNetPacket.w_float(State.linear_vel.z); } - } -//. Msg("--- Sync PH [%d].", ID); - tNetPacket.w_u8(1); //not freezed - doesn't mean anything.. + //. Msg("--- Sync PH [%d].", ID); + tNetPacket.w_u8(1); // not freezed - doesn't mean anything.. #ifdef XRGAME_EXPORTS #ifdef DEBUG - m_last_update_time = Device.dwTimeGlobal; + m_last_update_time = Device.dwTimeGlobal; #endif #endif } - - - -void CSE_ALifeObjectPhysic::load(NET_Packet &tNetPacket) +void CSE_ALifeObjectPhysic::load(NET_Packet& tNetPacket) { inherited1::load(tNetPacket); inherited2::load(tNetPacket); } - -xr_token po_types[]={ - { "Box", epotBox }, - { "Fixed chain", epotFixedChain }, - { "Free chain", epotFreeChain }, - { "Skeleton", epotSkeleton }, - { 0, 0 } -}; +xr_token po_types[] = {{"Box", epotBox}, {"Fixed chain", epotFixedChain}, {"Free chain", epotFreeChain}, + {"Skeleton", epotSkeleton}, {0, 0}}; #ifndef XRGAME_EXPORTS -void CSE_ALifeObjectPhysic::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeObjectPhysic::FillProps(LPCSTR pref, PropItemVec& values) { - inherited1::FillProps (pref, values); - inherited2::FillProps (pref, values); + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); - PHelper().CreateToken32 (values, PrepareKey(pref,*s_name,"Type"), &type, po_types); - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Mass"), &mass, 0.1f, 10000.f); - PHelper().CreateFlag8 (values, PrepareKey(pref,*s_name,"Active"), &_flags, flActive); + PHelper().CreateToken32(values, PrepareKey(pref, *s_name, "Type"), &type, po_types); + PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Mass"), &mass, 0.1f, 10000.f); + PHelper().CreateFlag8(values, PrepareKey(pref, *s_name, "Active"), &_flags, flActive); // motions & bones - PHelper().CreateChoose (values, PrepareKey(pref,*s_name,"Model\\Fixed bones"), &fixed_bones, smSkeletonBones,0,(void*)visual()->get_visual(),8); + PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Model\\Fixed bones"), &fixed_bones, smSkeletonBones, 0, + (void*)visual()->get_visual(), 8); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeObjectPhysic::used_ai_locations () const +bool CSE_ALifeObjectPhysic::used_ai_locations() const { - return (false); + return (false); } -bool CSE_ALifeObjectPhysic::can_save () const +bool CSE_ALifeObjectPhysic::can_save() const { - return CSE_PHSkeleton::need_save(); + return CSE_PHSkeleton::need_save(); } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeObjectHangingLamp //////////////////////////////////////////////////////////////////////////// -CSE_ALifeObjectHangingLamp::CSE_ALifeObjectHangingLamp(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection),CSE_PHSkeleton(caSection) +CSE_ALifeObjectHangingLamp::CSE_ALifeObjectHangingLamp(LPCSTR caSection) + : CSE_ALifeDynamicObjectVisual(caSection), CSE_PHSkeleton(caSection) { - flags.assign (flTypeSpot|flR1|flR2); + flags.assign(flTypeSpot | flR1 | flR2); - range = 10.f; - color = 0xffffffff; - brightness = 1.f; - m_health = 100.f; - m_flags.set (flUseSwitches,FALSE); - m_flags.set (flSwitchOffline,FALSE); + range = 10.f; + color = 0xffffffff; + brightness = 1.f; + m_health = 100.f; + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); - m_virtual_size = 0.1f; - m_ambient_radius = 10.f; - m_ambient_power = 0.1f; - spot_cone_angle = deg2rad(120.f); - glow_radius = 0.7f; - m_volumetric_quality = 1.0f; - m_volumetric_intensity = 1.0f; - m_volumetric_distance = 1.0f; + m_virtual_size = 0.1f; + m_ambient_radius = 10.f; + m_ambient_power = 0.1f; + spot_cone_angle = deg2rad(120.f); + glow_radius = 0.7f; + m_volumetric_quality = 1.0f; + m_volumetric_intensity = 1.0f; + m_volumetric_distance = 1.0f; } CSE_ALifeObjectHangingLamp::~CSE_ALifeObjectHangingLamp() { } -void CSE_ALifeObjectHangingLamp::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeObjectHangingLamp::STATE_Read(NET_Packet& tNetPacket, u16 size) { - if (m_wVersion > 20) - inherited1::STATE_Read (tNetPacket,size); - if (m_wVersion>=69) - inherited2::STATE_Read (tNetPacket,size); - if (m_wVersion < 32) - visual_read (tNetPacket,m_wVersion); + if (m_wVersion > 20) inherited1::STATE_Read(tNetPacket, size); + if (m_wVersion >= 69) inherited2::STATE_Read(tNetPacket, size); + if (m_wVersion < 32) visual_read(tNetPacket, m_wVersion); - if (m_wVersion < 49){ + if (m_wVersion < 49) { shared_str s_tmp; - float f_tmp; + float f_tmp; // model - tNetPacket.r_u32 (color); - tNetPacket.r_stringZ (color_animator); - tNetPacket.r_stringZ (s_tmp); - tNetPacket.r_stringZ (s_tmp); - tNetPacket.r_float (range); - tNetPacket.r_angle8 (f_tmp); - if (m_wVersion>10) - tNetPacket.r_float (brightness); - if (m_wVersion>11) - tNetPacket.r_u16 (flags.flags); - if (m_wVersion>12) - tNetPacket.r_float (f_tmp); - if (m_wVersion>17) - tNetPacket.r_stringZ (startup_animation); - - set_editor_flag (flVisualAnimationChange); + tNetPacket.r_u32(color); + tNetPacket.r_stringZ(color_animator); + tNetPacket.r_stringZ(s_tmp); + tNetPacket.r_stringZ(s_tmp); + tNetPacket.r_float(range); + tNetPacket.r_angle8(f_tmp); + if (m_wVersion > 10) tNetPacket.r_float(brightness); + if (m_wVersion > 11) tNetPacket.r_u16(flags.flags); + if (m_wVersion > 12) tNetPacket.r_float(f_tmp); + if (m_wVersion > 17) tNetPacket.r_stringZ(startup_animation); + + set_editor_flag(flVisualAnimationChange); if (m_wVersion > 42) { - tNetPacket.r_stringZ (s_tmp); - tNetPacket.r_float (f_tmp); + tNetPacket.r_stringZ(s_tmp); + tNetPacket.r_float(f_tmp); } - if (m_wVersion > 43){ - tNetPacket.r_stringZ (fixed_bones); + if (m_wVersion > 43) { + tNetPacket.r_stringZ(fixed_bones); } - if (m_wVersion > 44){ - tNetPacket.r_float (m_health); + if (m_wVersion > 44) { + tNetPacket.r_float(m_health); } - }else{ + } + else + { // model - tNetPacket.r_u32 (color); - tNetPacket.r_float (brightness); - tNetPacket.r_stringZ (color_animator); - tNetPacket.r_float (range); - tNetPacket.r_u16 (flags.flags); - tNetPacket.r_stringZ (startup_animation); - set_editor_flag (flVisualAnimationChange); - tNetPacket.r_stringZ (fixed_bones); - tNetPacket.r_float (m_health); + tNetPacket.r_u32(color); + tNetPacket.r_float(brightness); + tNetPacket.r_stringZ(color_animator); + tNetPacket.r_float(range); + tNetPacket.r_u16(flags.flags); + tNetPacket.r_stringZ(startup_animation); + set_editor_flag(flVisualAnimationChange); + tNetPacket.r_stringZ(fixed_bones); + tNetPacket.r_float(m_health); } - if (m_wVersion > 55){ - tNetPacket.r_float (m_virtual_size); - tNetPacket.r_float (m_ambient_radius); - tNetPacket.r_float (m_ambient_power); - tNetPacket.r_stringZ (m_ambient_texture); - tNetPacket.r_stringZ (light_texture); - tNetPacket.r_stringZ (light_main_bone); - tNetPacket.r_float (spot_cone_angle); - tNetPacket.r_stringZ (glow_texture); - tNetPacket.r_float (glow_radius); + if (m_wVersion > 55) { + tNetPacket.r_float(m_virtual_size); + tNetPacket.r_float(m_ambient_radius); + tNetPacket.r_float(m_ambient_power); + tNetPacket.r_stringZ(m_ambient_texture); + tNetPacket.r_stringZ(light_texture); + tNetPacket.r_stringZ(light_main_bone); + tNetPacket.r_float(spot_cone_angle); + tNetPacket.r_stringZ(glow_texture); + tNetPacket.r_float(glow_radius); } - if (m_wVersion > 96){ - tNetPacket.r_stringZ (light_ambient_bone); - }else{ - light_ambient_bone = light_main_bone; + if (m_wVersion > 96) { + tNetPacket.r_stringZ(light_ambient_bone); } - - if (m_wVersion>118) + else { - tNetPacket.r_float (m_volumetric_quality); - tNetPacket.r_float (m_volumetric_intensity); - tNetPacket.r_float (m_volumetric_distance); + light_ambient_bone = light_main_bone; + } + + if (m_wVersion > 118) { + tNetPacket.r_float(m_volumetric_quality); + tNetPacket.r_float(m_volumetric_intensity); + tNetPacket.r_float(m_volumetric_distance); } } -void CSE_ALifeObjectHangingLamp::STATE_Write(NET_Packet &tNetPacket) +void CSE_ALifeObjectHangingLamp::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); // model - tNetPacket.w_u32 (color); - tNetPacket.w_float (brightness); - tNetPacket.w_stringZ (color_animator); - tNetPacket.w_float (range); - tNetPacket.w_u16 (flags.flags); - tNetPacket.w_stringZ (startup_animation); - tNetPacket.w_stringZ (fixed_bones); - tNetPacket.w_float (m_health); - tNetPacket.w_float (m_virtual_size); - tNetPacket.w_float (m_ambient_radius); - tNetPacket.w_float (m_ambient_power); - tNetPacket.w_stringZ (m_ambient_texture); + tNetPacket.w_u32(color); + tNetPacket.w_float(brightness); + tNetPacket.w_stringZ(color_animator); + tNetPacket.w_float(range); + tNetPacket.w_u16(flags.flags); + tNetPacket.w_stringZ(startup_animation); + tNetPacket.w_stringZ(fixed_bones); + tNetPacket.w_float(m_health); + tNetPacket.w_float(m_virtual_size); + tNetPacket.w_float(m_ambient_radius); + tNetPacket.w_float(m_ambient_power); + tNetPacket.w_stringZ(m_ambient_texture); - tNetPacket.w_stringZ (light_texture); - tNetPacket.w_stringZ (light_main_bone); - tNetPacket.w_float (spot_cone_angle); - tNetPacket.w_stringZ (glow_texture); - tNetPacket.w_float (glow_radius); - - tNetPacket.w_stringZ (light_ambient_bone); + tNetPacket.w_stringZ(light_texture); + tNetPacket.w_stringZ(light_main_bone); + tNetPacket.w_float(spot_cone_angle); + tNetPacket.w_stringZ(glow_texture); + tNetPacket.w_float(glow_radius); - tNetPacket.w_float (m_volumetric_quality); - tNetPacket.w_float (m_volumetric_intensity); - tNetPacket.w_float (m_volumetric_distance); -} + tNetPacket.w_stringZ(light_ambient_bone); + tNetPacket.w_float(m_volumetric_quality); + tNetPacket.w_float(m_volumetric_intensity); + tNetPacket.w_float(m_volumetric_distance); +} -void CSE_ALifeObjectHangingLamp::UPDATE_Read(NET_Packet &tNetPacket) +void CSE_ALifeObjectHangingLamp::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); } -void CSE_ALifeObjectHangingLamp::UPDATE_Write(NET_Packet &tNetPacket) +void CSE_ALifeObjectHangingLamp::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); - + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); } -void CSE_ALifeObjectHangingLamp::load(NET_Packet &tNetPacket) +void CSE_ALifeObjectHangingLamp::load(NET_Packet& tNetPacket) { inherited1::load(tNetPacket); inherited2::load(tNetPacket); @@ -1456,116 +1410,123 @@ void CSE_ALifeObjectHangingLamp::load(NET_Packet &tNetPacket) void CSE_ALifeObjectHangingLamp::OnChangeFlag(PropValue* sender) { - set_editor_flag (flUpdateProperties); + set_editor_flag(flUpdateProperties); } #ifndef XRGAME_EXPORTS -void CSE_ALifeObjectHangingLamp::FillProps (LPCSTR pref, PropItemVec& values) -{ - inherited1::FillProps (pref,values); - inherited2::FillProps (pref,values); - - PropValue* P = 0; - PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Flags\\Physic"), &flags, flPhysic); - PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Flags\\Cast Shadow"), &flags, flCastShadow); - PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Flags\\Allow R1"), &flags, flR1); - PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Flags\\Allow R2"), &flags, flR2); - P=PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Flags\\Allow Ambient"),&flags, flPointAmbient); - P->OnChangeEvent.bind (this,&CSE_ALifeObjectHangingLamp::OnChangeFlag); - // - P=PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Light\\Type"), &flags, flTypeSpot, "Point", "Spot"); - P->OnChangeEvent.bind (this,&CSE_ALifeObjectHangingLamp::OnChangeFlag); - PHelper().CreateColor (values, PrepareKey(pref,*s_name,"Light\\Main\\Color"), &color); - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Light\\Main\\Brightness"), &brightness, 0.1f, 5.f); - PHelper().CreateChoose (values, PrepareKey(pref,*s_name,"Light\\Main\\Color Animator"),&color_animator, smLAnim); - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Light\\Main\\Range"), &range, 0.1f, 1000.f); - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Light\\Main\\Virtual Size"), &m_virtual_size, 0.f, 100.f); - PHelper().CreateChoose (values, PrepareKey(pref,*s_name,"Light\\Main\\Texture"), &light_texture, smTexture, "lights"); - PHelper().CreateChoose (values, PrepareKey(pref,*s_name,"Light\\Main\\Bone"), &light_main_bone, smSkeletonBones,0,(void*)visual()->get_visual()); - if (flags.is(flTypeSpot)) - { - PHelper().CreateAngle (values, PrepareKey(pref,*s_name,"Light\\Main\\Cone Angle"), &spot_cone_angle, deg2rad(1.f), deg2rad(120.f)); -// PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Light\\Main\\Volumetric"), &flags, flVolumetric); - P=PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Flags\\Volumetric"), &flags, flVolumetric); - P->OnChangeEvent.bind (this,&CSE_ALifeObjectHangingLamp::OnChangeFlag); +void CSE_ALifeObjectHangingLamp::FillProps(LPCSTR pref, PropItemVec& values) +{ + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); + + PropValue* P = 0; + PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags\\Physic"), &flags, flPhysic); + PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags\\Cast Shadow"), &flags, flCastShadow); + PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags\\Allow R1"), &flags, flR1); + PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags\\Allow R2"), &flags, flR2); + P = PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags\\Allow Ambient"), &flags, flPointAmbient); + P->OnChangeEvent.bind(this, &CSE_ALifeObjectHangingLamp::OnChangeFlag); + // + P = PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Light\\Type"), &flags, flTypeSpot, "Point", "Spot"); + P->OnChangeEvent.bind(this, &CSE_ALifeObjectHangingLamp::OnChangeFlag); + PHelper().CreateColor(values, PrepareKey(pref, *s_name, "Light\\Main\\Color"), &color); + PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Light\\Main\\Brightness"), &brightness, 0.1f, 5.f); + PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Light\\Main\\Color Animator"), &color_animator, smLAnim); + PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Light\\Main\\Range"), &range, 0.1f, 1000.f); + PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Light\\Main\\Virtual Size"), &m_virtual_size, 0.f, 100.f); + PHelper().CreateChoose( + values, PrepareKey(pref, *s_name, "Light\\Main\\Texture"), &light_texture, smTexture, "lights"); + PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Light\\Main\\Bone"), &light_main_bone, smSkeletonBones, 0, + (void*)visual()->get_visual()); + if (flags.is(flTypeSpot)) { + PHelper().CreateAngle(values, PrepareKey(pref, *s_name, "Light\\Main\\Cone Angle"), &spot_cone_angle, + deg2rad(1.f), deg2rad(120.f)); + // PHelper().CreateFlag16 (values, PrepareKey(pref,*s_name,"Light\\Main\\Volumetric"), &flags, + // flVolumetric); + P = PHelper().CreateFlag16(values, PrepareKey(pref, *s_name, "Flags\\Volumetric"), &flags, flVolumetric); + P->OnChangeEvent.bind(this, &CSE_ALifeObjectHangingLamp::OnChangeFlag); } - if (flags.is(flPointAmbient)){ - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Light\\Ambient\\Radius"), &m_ambient_radius, 0.f, 1000.f); - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Light\\Ambient\\Power"), &m_ambient_power); - PHelper().CreateChoose (values, PrepareKey(pref,*s_name,"Light\\Ambient\\Texture"), &m_ambient_texture, smTexture, "lights"); - PHelper().CreateChoose (values, PrepareKey(pref,*s_name,"Light\\Ambient\\Bone"), &light_ambient_bone,smSkeletonBones,0,(void*)visual()->get_visual()); + if (flags.is(flPointAmbient)) { + PHelper().CreateFloat( + values, PrepareKey(pref, *s_name, "Light\\Ambient\\Radius"), &m_ambient_radius, 0.f, 1000.f); + PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Light\\Ambient\\Power"), &m_ambient_power); + PHelper().CreateChoose( + values, PrepareKey(pref, *s_name, "Light\\Ambient\\Texture"), &m_ambient_texture, smTexture, "lights"); + PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Light\\Ambient\\Bone"), &light_ambient_bone, + smSkeletonBones, 0, (void*)visual()->get_visual()); } - if (flags.is(flVolumetric)) - { - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Light\\Volumetric\\Quality"), &m_volumetric_quality, 0.f, 1.f); - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Light\\Volumetric\\Intensity"), &m_volumetric_intensity,0.f, 10.f); - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Light\\Volumetric\\Distance"), &m_volumetric_distance, 0.f, 1.f); + if (flags.is(flVolumetric)) { + PHelper().CreateFloat( + values, PrepareKey(pref, *s_name, "Light\\Volumetric\\Quality"), &m_volumetric_quality, 0.f, 1.f); + PHelper().CreateFloat( + values, PrepareKey(pref, *s_name, "Light\\Volumetric\\Intensity"), &m_volumetric_intensity, 0.f, 10.f); + PHelper().CreateFloat( + values, PrepareKey(pref, *s_name, "Light\\Volumetric\\Distance"), &m_volumetric_distance, 0.f, 1.f); } // fixed bones - PHelper().CreateChoose (values, PrepareKey(pref,*s_name,"Model\\Fixed bones"), &fixed_bones, smSkeletonBones,0,(void*)visual()->get_visual(),8); + PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Model\\Fixed bones"), &fixed_bones, smSkeletonBones, 0, + (void*)visual()->get_visual(), 8); // glow - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Glow\\Radius"), &glow_radius, 0.01f, 100.f); - PHelper().CreateChoose (values, PrepareKey(pref,*s_name,"Glow\\Texture"), &glow_texture, smTexture, "glow"); + PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Glow\\Radius"), &glow_radius, 0.01f, 100.f); + PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Glow\\Texture"), &glow_texture, smTexture, "glow"); // game - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Game\\Health"), &m_health, 0.f, 100.f); + PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Game\\Health"), &m_health, 0.f, 100.f); } -#define VIS_RADIUS 0.25f -void CSE_ALifeObjectHangingLamp::on_render(CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent,int priority, bool strictB2F) +#define VIS_RADIUS 0.25f +void CSE_ALifeObjectHangingLamp::on_render( + CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent, int priority, bool strictB2F) { - inherited1::on_render (du,owner,bSelected,parent,priority,strictB2F); - if ((1==priority)&&(false==strictB2F)){ - u32 clr = bSelected?0x00FFFFFF:0x00FFFF00; + inherited1::on_render(du, owner, bSelected, parent, priority, strictB2F); + if ((1 == priority) && (false == strictB2F)) { + u32 clr = bSelected ? 0x00FFFFFF : 0x00FFFF00; Fmatrix main_xform, ambient_xform; - owner->get_bone_xform (*light_main_bone,main_xform); - main_xform.mulA_43 (parent); - if(flags.is(flPointAmbient) ){ - owner->get_bone_xform (*light_ambient_bone,ambient_xform); - ambient_xform.mulA_43 (parent); + owner->get_bone_xform(*light_main_bone, main_xform); + main_xform.mulA_43(parent); + if (flags.is(flPointAmbient)) { + owner->get_bone_xform(*light_ambient_bone, ambient_xform); + ambient_xform.mulA_43(parent); } - if (bSelected){ - if (flags.is(flTypeSpot)){ - du->DrawSpotLight (main_xform.c, main_xform.k, range, spot_cone_angle, clr); - }else{ - du->DrawLineSphere (main_xform.c, range, clr, true); + if (bSelected) { + if (flags.is(flTypeSpot)) { + du->DrawSpotLight(main_xform.c, main_xform.k, range, spot_cone_angle, clr); } - if(flags.is(flPointAmbient) ) - du->DrawLineSphere (ambient_xform.c, m_ambient_radius, clr, true); + else + { + du->DrawLineSphere(main_xform.c, range, clr, true); + } + if (flags.is(flPointAmbient)) du->DrawLineSphere(ambient_xform.c, m_ambient_radius, clr, true); } - du->DrawPointLight (main_xform.c,VIS_RADIUS, clr); - if(flags.is(flPointAmbient) ) - du->DrawPointLight (ambient_xform.c,VIS_RADIUS, clr); + du->DrawPointLight(main_xform.c, VIS_RADIUS, clr); + if (flags.is(flPointAmbient)) du->DrawPointLight(ambient_xform.c, VIS_RADIUS, clr); } } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeObjectHangingLamp::used_ai_locations () const +bool CSE_ALifeObjectHangingLamp::used_ai_locations() const { - return (false); + return (false); } -bool CSE_ALifeObjectHangingLamp::validate () +bool CSE_ALifeObjectHangingLamp::validate() { - if (flags.test(flR1) || flags.test(flR2)) - return (true); + if (flags.test(flR1) || flags.test(flR2)) return (true); - Msg ("! Render type is not set properly!"); - return (false); + Msg("! Render type is not set properly!"); + return (false); } bool CSE_ALifeObjectHangingLamp::match_configuration() const { - R_ASSERT3(flags.test(flR1) || flags.test(flR2),"no renderer type set for hanging-lamp ",name_replace()); + R_ASSERT3(flags.test(flR1) || flags.test(flR2), "no renderer type set for hanging-lamp ", name_replace()); #ifdef XRGAME_EXPORTS - return ( - (flags.test(flR1) && (GlobalEnv.Render->get_generation() == IRender::GENERATION_R1)) || - (flags.test(flR2) && (GlobalEnv.Render->get_generation() == IRender::GENERATION_R2)) - ); + return ((flags.test(flR1) && (GlobalEnv.Render->get_generation() == IRender::GENERATION_R1)) || + (flags.test(flR2) && (GlobalEnv.Render->get_generation() == IRender::GENERATION_R2))); #else - return (true); + return (true); #endif } @@ -1575,307 +1536,311 @@ bool CSE_ALifeObjectHangingLamp::match_configuration() const CSE_ALifeObjectProjector::CSE_ALifeObjectProjector(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) { - m_flags.set (flUseSwitches,FALSE); - m_flags.set (flSwitchOffline,FALSE); + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); } CSE_ALifeObjectProjector::~CSE_ALifeObjectProjector() { } -void CSE_ALifeObjectProjector::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeObjectProjector::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeObjectProjector::STATE_Write(NET_Packet &tNetPacket) +void CSE_ALifeObjectProjector::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeObjectProjector::UPDATE_Read(NET_Packet &tNetPacket) +void CSE_ALifeObjectProjector::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeObjectProjector::UPDATE_Write(NET_Packet &tNetPacket) +void CSE_ALifeObjectProjector::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeObjectProjector::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeObjectProjector::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref, values); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS bool CSE_ALifeObjectProjector::used_ai_locations() const { - return (false); + return (false); } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeSchedulable //////////////////////////////////////////////////////////////////////////// -CSE_ALifeSchedulable::CSE_ALifeSchedulable (LPCSTR caSection) +CSE_ALifeSchedulable::CSE_ALifeSchedulable(LPCSTR caSection) { - m_tpCurrentBestWeapon = 0; - m_tpBestDetector = 0; - m_schedule_counter = u64(-1); + m_tpCurrentBestWeapon = 0; + m_tpBestDetector = 0; + m_schedule_counter = u64(-1); } -CSE_ALifeSchedulable::~CSE_ALifeSchedulable () +CSE_ALifeSchedulable::~CSE_ALifeSchedulable() { } -bool CSE_ALifeSchedulable::need_update (CSE_ALifeDynamicObject *object) +bool CSE_ALifeSchedulable::need_update(CSE_ALifeDynamicObject* object) { - return (!object || (object->m_bDirectControl && /**object->interactive() && /**/object->used_ai_locations() && !object->m_bOnline)); + return (!object || (object->m_bDirectControl && /**object->interactive() && /**/ object->used_ai_locations() && + !object->m_bOnline)); } -CSE_Abstract *CSE_ALifeSchedulable::init () +CSE_Abstract* CSE_ALifeSchedulable::init() { - return (base()); + return (base()); } -u32 CSE_ALifeSchedulable::ef_creature_type () const +u32 CSE_ALifeSchedulable::ef_creature_type() const { - string16 temp; CLSID2TEXT(base()->m_tClassID,temp); - R_ASSERT3 (false,"Invalid alife creature type request, virtual function is not properly overloaded!",temp); - return (u32(-1)); + string16 temp; + CLSID2TEXT(base()->m_tClassID, temp); + R_ASSERT3(false, "Invalid alife creature type request, virtual function is not properly overloaded!", temp); + return (u32(-1)); } -u32 CSE_ALifeSchedulable::ef_anomaly_type () const +u32 CSE_ALifeSchedulable::ef_anomaly_type() const { - string16 temp; CLSID2TEXT(base()->m_tClassID,temp); - R_ASSERT3 (false,"Invalid alife anomaly type request, virtual function is not properly overloaded!",temp); - return (u32(-1)); + string16 temp; + CLSID2TEXT(base()->m_tClassID, temp); + R_ASSERT3(false, "Invalid alife anomaly type request, virtual function is not properly overloaded!", temp); + return (u32(-1)); } -u32 CSE_ALifeSchedulable::ef_weapon_type () const +u32 CSE_ALifeSchedulable::ef_weapon_type() const { - string16 temp; CLSID2TEXT(base()->m_tClassID,temp); - R_ASSERT3 (false,"Invalid alife weapon type request, virtual function is not properly overloaded!",temp); - return (u32(-1)); + string16 temp; + CLSID2TEXT(base()->m_tClassID, temp); + R_ASSERT3(false, "Invalid alife weapon type request, virtual function is not properly overloaded!", temp); + return (u32(-1)); } -u32 CSE_ALifeSchedulable::ef_detector_type () const +u32 CSE_ALifeSchedulable::ef_detector_type() const { - string16 temp; CLSID2TEXT(base()->m_tClassID,temp); - R_ASSERT3 (false,"Invalid alife detector type request, virtual function is not properly overloaded!",temp); - return (u32(-1)); + string16 temp; + CLSID2TEXT(base()->m_tClassID, temp); + R_ASSERT3(false, "Invalid alife detector type request, virtual function is not properly overloaded!", temp); + return (u32(-1)); } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeHelicopter //////////////////////////////////////////////////////////////////////////// -CSE_ALifeHelicopter::CSE_ALifeHelicopter (LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection), CSE_Motion(),CSE_PHSkeleton(caSection) +CSE_ALifeHelicopter::CSE_ALifeHelicopter(LPCSTR caSection) + : CSE_ALifeDynamicObjectVisual(caSection), CSE_Motion(), CSE_PHSkeleton(caSection) { - m_flags.set (flUseSwitches, FALSE); - m_flags.set (flSwitchOffline, FALSE); - m_flags.set (flInteractive, FALSE); + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); + m_flags.set(flInteractive, FALSE); } -CSE_ALifeHelicopter::~CSE_ALifeHelicopter () +CSE_ALifeHelicopter::~CSE_ALifeHelicopter() { } -CSE_Motion* CSE_ALifeHelicopter::motion () +CSE_Motion* CSE_ALifeHelicopter::motion() { - return (this); + return (this); } -void CSE_ALifeHelicopter::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeHelicopter::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket,size); - CSE_Motion::motion_read (tNetPacket); - if(m_wVersion>=69) - inherited3::STATE_Read (tNetPacket,size); - tNetPacket.r_stringZ (startup_animation); - tNetPacket.r_stringZ (engine_sound); + inherited1::STATE_Read(tNetPacket, size); + CSE_Motion::motion_read(tNetPacket); + if (m_wVersion >= 69) inherited3::STATE_Read(tNetPacket, size); + tNetPacket.r_stringZ(startup_animation); + tNetPacket.r_stringZ(engine_sound); - set_editor_flag (flVisualAnimationChange | flMotionChange); + set_editor_flag(flVisualAnimationChange | flMotionChange); } -void CSE_ALifeHelicopter::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeHelicopter::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - CSE_Motion::motion_write (tNetPacket); - inherited3::STATE_Write (tNetPacket); - tNetPacket.w_stringZ (startup_animation); - tNetPacket.w_stringZ (engine_sound); + inherited1::STATE_Write(tNetPacket); + CSE_Motion::motion_write(tNetPacket); + inherited3::STATE_Write(tNetPacket); + tNetPacket.w_stringZ(startup_animation); + tNetPacket.w_stringZ(engine_sound); } -void CSE_ALifeHelicopter::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeHelicopter::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited3::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); + inherited3::UPDATE_Read(tNetPacket); } -void CSE_ALifeHelicopter::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeHelicopter::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited3::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); + inherited3::UPDATE_Write(tNetPacket); } -void CSE_ALifeHelicopter::load (NET_Packet &tNetPacket) +void CSE_ALifeHelicopter::load(NET_Packet& tNetPacket) { inherited1::load(tNetPacket); inherited3::load(tNetPacket); } bool CSE_ALifeHelicopter::can_save() const { - return CSE_PHSkeleton::need_save(); + return CSE_PHSkeleton::need_save(); } #ifndef XRGAME_EXPORTS void CSE_ALifeHelicopter::FillProps(LPCSTR pref, PropItemVec& values) { - inherited1::FillProps (pref, values); - inherited2::FillProps (pref, values); - inherited3::FillProps (pref, values); + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); + inherited3::FillProps(pref, values); - PHelper().CreateChoose (values, PrepareKey(pref,*s_name,"Engine Sound"), &engine_sound, smSoundSource); + PHelper().CreateChoose(values, PrepareKey(pref, *s_name, "Engine Sound"), &engine_sound, smSoundSource); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeHelicopter::used_ai_locations () const +bool CSE_ALifeHelicopter::used_ai_locations() const { - return (false); + return (false); } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeCar //////////////////////////////////////////////////////////////////////////// -CSE_ALifeCar::CSE_ALifeCar (LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection),CSE_PHSkeleton(caSection) +CSE_ALifeCar::CSE_ALifeCar(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection), CSE_PHSkeleton(caSection) { - - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); - m_flags.set (flUseSwitches,FALSE); - m_flags.set (flSwitchOffline,FALSE); - health =1.0f; + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) + set_visual(pSettings->r_string(caSection, "visual")); + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); + health = 1.0f; } -CSE_ALifeCar::~CSE_ALifeCar () +CSE_ALifeCar::~CSE_ALifeCar() { } -void CSE_ALifeCar::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeCar::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket,size); + inherited1::STATE_Read(tNetPacket, size); - if(m_wVersion>65) - inherited2::STATE_Read (tNetPacket,size); - if ((m_wVersion > 52) && (m_wVersion < 55)) - tNetPacket.r_float (); - if(m_wVersion>92) - health=tNetPacket.r_float(); - if(health>1.0f) health/=100.0f; + if (m_wVersion > 65) inherited2::STATE_Read(tNetPacket, size); + if ((m_wVersion > 52) && (m_wVersion < 55)) tNetPacket.r_float(); + if (m_wVersion > 92) health = tNetPacket.r_float(); + if (health > 1.0f) health /= 100.0f; } -void CSE_ALifeCar::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCar::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); tNetPacket.w_float(health); } -void CSE_ALifeCar::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeCar::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); } -void CSE_ALifeCar::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCar::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); } bool CSE_ALifeCar::used_ai_locations() const { - return (false); + return (false); } bool CSE_ALifeCar::can_save() const { - return CSE_PHSkeleton::need_save(); + return CSE_PHSkeleton::need_save(); } -void CSE_ALifeCar::load(NET_Packet &tNetPacket) +void CSE_ALifeCar::load(NET_Packet& tNetPacket) { inherited1::load(tNetPacket); inherited2::load(tNetPacket); - } -void CSE_ALifeCar::data_load(NET_Packet &tNetPacket) +void CSE_ALifeCar::data_load(NET_Packet& tNetPacket) { - //inherited1::data_load(tNetPacket); + // inherited1::data_load(tNetPacket); inherited2::data_load(tNetPacket); - //VERIFY(door_states.empty()); + // VERIFY(door_states.empty()); tNetPacket.r_vec3(o_Position); tNetPacket.r_vec3(o_Angle); door_states.clear(); - u16 doors_number=tNetPacket.r_u16(); - for(u16 i=0;i::iterator i=door_states.begin(),e=door_states.end(); - for(;e!=i;++i) + xr_vector::iterator i = door_states.begin(), e = door_states.end(); + for (; e != i; ++i) { i->write(tNetPacket); } - //door_states.clear(); + // door_states.clear(); } { tNetPacket.w_u16(u16(wheel_states.size())); - xr_vector::iterator i=wheel_states.begin(),e=wheel_states.end(); - for(;e!=i;++i) + xr_vector::iterator i = wheel_states.begin(), e = wheel_states.end(); + for (; e != i; ++i) { i->write(tNetPacket); } - //wheel_states.clear(); + // wheel_states.clear(); } tNetPacket.w_float(health); } void CSE_ALifeCar::SDoorState::read(NET_Packet& P) { - open_state=P.r_u8();health=P.r_float(); + open_state = P.r_u8(); + health = P.r_float(); } void CSE_ALifeCar::SDoorState::write(NET_Packet& P) { - P.w_u8(open_state);P.w_float(health); + P.w_u8(open_state); + P.w_float(health); } void CSE_ALifeCar::SWheelState::read(NET_Packet& P) { - health=P.r_float(); + health = P.r_float(); } void CSE_ALifeCar::SWheelState::write(NET_Packet& P) { @@ -1883,330 +1848,328 @@ void CSE_ALifeCar::SWheelState::write(NET_Packet& P) } #ifndef XRGAME_EXPORTS -void CSE_ALifeCar::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeCar::FillProps(LPCSTR pref, PropItemVec& values) { - inherited1::FillProps (pref,values); - inherited2::FillProps (pref,values); - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Health"), &health, 0.f, 1.0f); + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); + PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Health"), &health, 0.f, 1.0f); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeObjectBreakable //////////////////////////////////////////////////////////////////////////// -CSE_ALifeObjectBreakable::CSE_ALifeObjectBreakable (LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) +CSE_ALifeObjectBreakable::CSE_ALifeObjectBreakable(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) { - m_health = 1.f; - m_flags.set (flUseSwitches,FALSE); - m_flags.set (flSwitchOffline,FALSE); + m_health = 1.f; + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); } -CSE_ALifeObjectBreakable::~CSE_ALifeObjectBreakable () +CSE_ALifeObjectBreakable::~CSE_ALifeObjectBreakable() { } -void CSE_ALifeObjectBreakable::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeObjectBreakable::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); - tNetPacket.r_float (m_health); + inherited::STATE_Read(tNetPacket, size); + tNetPacket.r_float(m_health); } -void CSE_ALifeObjectBreakable::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeObjectBreakable::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_float (m_health); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_float(m_health); } -void CSE_ALifeObjectBreakable::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeObjectBreakable::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeObjectBreakable::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeObjectBreakable::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeObjectBreakable::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeObjectBreakable::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref,values); - PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Health"), &m_health, 0.f, 100.f); + inherited::FillProps(pref, values); + PHelper().CreateFloat(values, PrepareKey(pref, *s_name, "Health"), &m_health, 0.f, 100.f); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeObjectBreakable::used_ai_locations () const +bool CSE_ALifeObjectBreakable::used_ai_locations() const { - return (false); + return (false); } -bool CSE_ALifeObjectBreakable::can_switch_offline () const +bool CSE_ALifeObjectBreakable::can_switch_offline() const { - return (false); + return (false); } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeObjectClimable //////////////////////////////////////////////////////////////////////////// -CSE_ALifeObjectClimable::CSE_ALifeObjectClimable (LPCSTR caSection) : CSE_Shape(), CSE_ALifeDynamicObject(caSection) +CSE_ALifeObjectClimable::CSE_ALifeObjectClimable(LPCSTR caSection) : CSE_Shape(), CSE_ALifeDynamicObject(caSection) { - //m_health = 100.f; - //m_flags.set (flUseSwitches,FALSE); - //m_flags.set (flSwitchOffline,FALSE); - material = "materials\\fake_ladders"; + // m_health = 100.f; + // m_flags.set (flUseSwitches,FALSE); + // m_flags.set (flSwitchOffline,FALSE); + material = "materials\\fake_ladders"; } -CSE_ALifeObjectClimable::~CSE_ALifeObjectClimable () +CSE_ALifeObjectClimable::~CSE_ALifeObjectClimable() { } -IServerEntityShape* CSE_ALifeObjectClimable::shape () +IServerEntityShape* CSE_ALifeObjectClimable::shape() { - return (this); + return (this); } -void CSE_ALifeObjectClimable::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeObjectClimable::STATE_Read(NET_Packet& tNetPacket, u16 size) { - //inherited1::STATE_Read (tNetPacket,size); - if(m_wVersion==99) - CSE_ALifeObject::STATE_Read (tNetPacket,size); - if(m_wVersion>99) - inherited2::STATE_Read (tNetPacket,size); + // inherited1::STATE_Read (tNetPacket,size); + if (m_wVersion == 99) CSE_ALifeObject::STATE_Read(tNetPacket, size); + if (m_wVersion > 99) inherited2::STATE_Read(tNetPacket, size); cform_read(tNetPacket); - if(m_wVersion>126) - tNetPacket.r_stringZ( material ); + if (m_wVersion > 126) tNetPacket.r_stringZ(material); } -void CSE_ALifeObjectClimable::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeObjectClimable::STATE_Write(NET_Packet& tNetPacket) { - //inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); + // inherited1::STATE_Write (tNetPacket); + inherited2::STATE_Write(tNetPacket); cform_write(tNetPacket); - tNetPacket.w_stringZ( material ); + tNetPacket.w_stringZ(material); } -void CSE_ALifeObjectClimable::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeObjectClimable::UPDATE_Read(NET_Packet& tNetPacket) { - //inherited1::UPDATE_Read (tNetPacket); - //inherited2::UPDATE_Read (tNetPacket); - + // inherited1::UPDATE_Read (tNetPacket); + // inherited2::UPDATE_Read (tNetPacket); } -void CSE_ALifeObjectClimable::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeObjectClimable::UPDATE_Write(NET_Packet& tNetPacket) { - //inherited1::UPDATE_Write (tNetPacket); - //inherited2::UPDATE_Write (tNetPacket); + // inherited1::UPDATE_Write (tNetPacket); + // inherited2::UPDATE_Write (tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeObjectClimable::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeObjectClimable::FillProps(LPCSTR pref, PropItemVec& values) { - //inherited1::FillProps (pref,values); - inherited2::FillProps (pref,values); - //PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Health"), &m_health, 0.f, 100.f); + // inherited1::FillProps (pref,values); + inherited2::FillProps(pref, values); + // PHelper().CreateFloat (values, PrepareKey(pref,*s_name,"Health"), &m_health, 0.f, 100.f); } void CSE_ALifeObjectClimable::set_additional_info(void* info) { LPCSTR material_name = (LPCSTR)info; - material = material_name; + material = material_name; } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeObjectClimable::used_ai_locations () const +bool CSE_ALifeObjectClimable::used_ai_locations() const { - return (false); + return (false); } -bool CSE_ALifeObjectClimable::can_switch_offline () const +bool CSE_ALifeObjectClimable::can_switch_offline() const { - return (false); + return (false); } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeMountedWeapon //////////////////////////////////////////////////////////////////////////// -CSE_ALifeMountedWeapon::CSE_ALifeMountedWeapon (LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) -{ +CSE_ALifeMountedWeapon::CSE_ALifeMountedWeapon(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) +{ } -CSE_ALifeMountedWeapon::~CSE_ALifeMountedWeapon () +CSE_ALifeMountedWeapon::~CSE_ALifeMountedWeapon() { } -void CSE_ALifeMountedWeapon::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeMountedWeapon::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeMountedWeapon::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeMountedWeapon::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeMountedWeapon::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeMountedWeapon::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeMountedWeapon::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeMountedWeapon::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeMountedWeapon::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeMountedWeapon::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref,values); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS - -CSE_ALifeStationaryMgun::CSE_ALifeStationaryMgun (LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) -{} +#endif // #ifndef XRGAME_EXPORTS -CSE_ALifeStationaryMgun::~CSE_ALifeStationaryMgun () -{} +CSE_ALifeStationaryMgun::CSE_ALifeStationaryMgun(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) +{ +} -void CSE_ALifeStationaryMgun::UPDATE_Read (NET_Packet &tNetPacket) +CSE_ALifeStationaryMgun::~CSE_ALifeStationaryMgun() { - inherited::UPDATE_Read (tNetPacket); - m_bWorking = !!tNetPacket.r_u8 (); - load_data (m_destEnemyDir, tNetPacket); } -void CSE_ALifeStationaryMgun::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeStationaryMgun::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); - tNetPacket.w_u8 (m_bWorking? 1:0); - save_data (m_destEnemyDir, tNetPacket); + inherited::UPDATE_Read(tNetPacket); + m_bWorking = !!tNetPacket.r_u8(); + load_data(m_destEnemyDir, tNetPacket); } +void CSE_ALifeStationaryMgun::UPDATE_Write(NET_Packet& tNetPacket) +{ + inherited::UPDATE_Write(tNetPacket); + tNetPacket.w_u8(m_bWorking ? 1 : 0); + save_data(m_destEnemyDir, tNetPacket); +} -void CSE_ALifeStationaryMgun::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeStationaryMgun::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeStationaryMgun::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeStationaryMgun::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeStationaryMgun::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeStationaryMgun::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref,values); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeTeamBaseZone //////////////////////////////////////////////////////////////////////////// CSE_ALifeTeamBaseZone::CSE_ALifeTeamBaseZone(LPCSTR caSection) : CSE_ALifeSpaceRestrictor(caSection) { - m_team = 0; + m_team = 0; } CSE_ALifeTeamBaseZone::~CSE_ALifeTeamBaseZone() { } -void CSE_ALifeTeamBaseZone::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeTeamBaseZone::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); - tNetPacket.r_u8 (m_team); + inherited::STATE_Read(tNetPacket, size); + tNetPacket.r_u8(m_team); } -void CSE_ALifeTeamBaseZone::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeTeamBaseZone::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_u8 (m_team); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_u8(m_team); } -void CSE_ALifeTeamBaseZone::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeTeamBaseZone::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeTeamBaseZone::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeTeamBaseZone::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeTeamBaseZone::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeTeamBaseZone::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); - PHelper().CreateU8 (items, PrepareKey(pref,*s_name,"team"), &m_team, 0, 16); + inherited::FillProps(pref, items); + PHelper().CreateU8(items, PrepareKey(pref, *s_name, "team"), &m_team, 0, 16); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeSmartZone //////////////////////////////////////////////////////////////////////////// -CSE_ALifeSmartZone::CSE_ALifeSmartZone (LPCSTR caSection) : CSE_ALifeSpaceRestrictor(caSection), CSE_ALifeSchedulable(caSection) +CSE_ALifeSmartZone::CSE_ALifeSmartZone(LPCSTR caSection) + : CSE_ALifeSpaceRestrictor(caSection), CSE_ALifeSchedulable(caSection) { } -CSE_ALifeSmartZone::~CSE_ALifeSmartZone () +CSE_ALifeSmartZone::~CSE_ALifeSmartZone() { } -CSE_Abstract *CSE_ALifeSmartZone::base () +CSE_Abstract* CSE_ALifeSmartZone::base() { - return (this); + return (this); } -const CSE_Abstract *CSE_ALifeSmartZone::base () const +const CSE_Abstract* CSE_ALifeSmartZone::base() const { - return (this); + return (this); } -CSE_Abstract *CSE_ALifeSmartZone::init () +CSE_Abstract* CSE_ALifeSmartZone::init() { - inherited1::init (); - inherited2::init (); - return (this); + inherited1::init(); + inherited2::init(); + return (this); } -void CSE_ALifeSmartZone::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeSmartZone::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket,size); + inherited1::STATE_Read(tNetPacket, size); } -void CSE_ALifeSmartZone::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeSmartZone::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); } -void CSE_ALifeSmartZone::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeSmartZone::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); } -void CSE_ALifeSmartZone::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeSmartZone::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeSmartZone::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeSmartZone::FillProps(LPCSTR pref, PropItemVec& items) { - inherited1::FillProps (pref,items); + inherited1::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -void CSE_ALifeSmartZone::update () +void CSE_ALifeSmartZone::update() { } float CSE_ALifeSmartZone::detect_probability() { - return (0.f); + return (0.f); } -void CSE_ALifeSmartZone::smart_touch (CSE_ALifeMonsterAbstract *monster) +void CSE_ALifeSmartZone::smart_touch(CSE_ALifeMonsterAbstract* monster) { } @@ -2214,52 +2177,53 @@ void CSE_ALifeSmartZone::smart_touch (CSE_ALifeMonsterAbstract *monster) // CSE_ALifeInventoryBox //////////////////////////////////////////////////////////////////////////// -CSE_ALifeInventoryBox::CSE_ALifeInventoryBox( LPCSTR caSection ) : CSE_ALifeDynamicObjectVisual( caSection ) +CSE_ALifeInventoryBox::CSE_ALifeInventoryBox(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) { m_can_take = true; - m_closed = false; - m_tip_text._set( "inventory_box_use" ); + m_closed = false; + m_tip_text._set("inventory_box_use"); } CSE_ALifeInventoryBox::~CSE_ALifeInventoryBox() { } -void CSE_ALifeInventoryBox::STATE_Read( NET_Packet &tNetPacket, u16 size ) +void CSE_ALifeInventoryBox::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read( tNetPacket, size ); + inherited::STATE_Read(tNetPacket, size); - u16 m_wVersion = base()->m_wVersion; - if ( m_wVersion > 124 ) - { + u16 m_wVersion = base()->m_wVersion; + if (m_wVersion > 124) { u8 temp; - tNetPacket.r_u8 ( temp ); m_can_take = (temp == 1); - tNetPacket.r_u8 ( temp ); m_closed = (temp == 1); - tNetPacket.r_stringZ( m_tip_text ); + tNetPacket.r_u8(temp); + m_can_take = (temp == 1); + tNetPacket.r_u8(temp); + m_closed = (temp == 1); + tNetPacket.r_stringZ(m_tip_text); } } -void CSE_ALifeInventoryBox::STATE_Write( NET_Packet &tNetPacket ) +void CSE_ALifeInventoryBox::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write( tNetPacket ); - tNetPacket.w_u8 ( (m_can_take)? 1 : 0 ); - tNetPacket.w_u8 ( (m_closed)? 1 : 0 ); - tNetPacket.w_stringZ( m_tip_text ); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_u8((m_can_take) ? 1 : 0); + tNetPacket.w_u8((m_closed) ? 1 : 0); + tNetPacket.w_stringZ(m_tip_text); } -void CSE_ALifeInventoryBox::UPDATE_Read( NET_Packet &tNetPacket ) +void CSE_ALifeInventoryBox::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read( tNetPacket ); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeInventoryBox::UPDATE_Write( NET_Packet &tNetPacket ) +void CSE_ALifeInventoryBox::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write( tNetPacket ); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeInventoryBox::FillProps( LPCSTR pref, PropItemVec& values ) +void CSE_ALifeInventoryBox::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps( pref, values ); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS diff --git a/src/xrServerEntities/xrServer_Objects_ALife.h b/src/xrServerEntities/xrServer_Objects_ALife.h index 74e5c57f326..d71919beae5 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife.h +++ b/src/xrServerEntities/xrServer_Objects_ALife.h @@ -8,19 +8,19 @@ #ifndef xrServer_Objects_ALifeH #define xrServer_Objects_ALifeH -#include "pch_script.h" -#include "xrServer_Objects.h" #include "alife_space.h" +#include "pch_script.h" #include "xrAICore/Navigation/game_graph_space.h" +#include "xrServer_Objects.h" #ifdef XRGAME_EXPORTS #include "alife_smart_terrain_task.h" -#endif //#ifdef XRGAME_EXPORTS +#endif //#ifdef XRGAME_EXPORTS #pragma warning(push) -#pragma warning(disable:4005) +#pragma warning(disable : 4005) #ifdef XRGAME_EXPORTS - class CALifeSimulator; +class CALifeSimulator; #endif class CSE_ALifeItemWeapon; @@ -28,78 +28,80 @@ class CSE_ALifeDynamicObject; class CSE_ALifeObject; #ifdef XRGAME_EXPORTS class CALifeSmartTerrainTask; -#endif //#ifdef XRGAME_EXPORTS +#endif //#ifdef XRGAME_EXPORTS class CALifeMonsterAbstract; - -struct SFillPropData +struct SFillPropData { - RTokenVec locations[4]; - RStringVec level_ids; - RTokenVec story_names; - RTokenVec spawn_story_names; - RStringVec character_profiles; - RStringVec smart_covers; - xr_map location_colors; - u32 counter; - SFillPropData (); - ~SFillPropData (); - void load (); - void unload (); - void inc (); - void dec (); + RTokenVec locations[4]; + RStringVec level_ids; + RTokenVec story_names; + RTokenVec spawn_story_names; + RStringVec character_profiles; + RStringVec smart_covers; + xr_map location_colors; + u32 counter; + SFillPropData(); + ~SFillPropData(); + void load(); + void unload(); + void inc(); + void dec(); }; class CSE_ALifeSchedulable : public IPureSchedulableObject { using inherited = IPureSchedulableObject; + public: - CSE_ALifeItemWeapon *m_tpCurrentBestWeapon; - CSE_ALifeDynamicObject *m_tpBestDetector; - u64 m_schedule_counter; + CSE_ALifeItemWeapon* m_tpCurrentBestWeapon; + CSE_ALifeDynamicObject* m_tpBestDetector; + u64 m_schedule_counter; - CSE_ALifeSchedulable (LPCSTR caSection); - virtual ~CSE_ALifeSchedulable (); + CSE_ALifeSchedulable(LPCSTR caSection); + virtual ~CSE_ALifeSchedulable(); // we need this to prevent virtual inheritance :-( - virtual CSE_Abstract *base () = 0; - virtual const CSE_Abstract *base () const = 0; - virtual CSE_Abstract *init (); - virtual CSE_ALifeSchedulable *cast_schedulable () {return this;}; - virtual CSE_Abstract *cast_abstract () {return 0;}; + virtual CSE_Abstract* base() = 0; + virtual const CSE_Abstract* base() const = 0; + virtual CSE_Abstract* init(); + virtual CSE_ALifeSchedulable* cast_schedulable() { return this; }; + virtual CSE_Abstract* cast_abstract() { return 0; }; // end of the virtual inheritance dependant code - virtual bool need_update (CSE_ALifeDynamicObject *object); - virtual u32 ef_creature_type () const; - virtual u32 ef_anomaly_type () const; - virtual u32 ef_weapon_type () const; - virtual u32 ef_detector_type () const; - virtual bool natural_weapon () const {return true;} - virtual bool natural_detector () const {return true;} + virtual bool need_update(CSE_ALifeDynamicObject* object); + virtual u32 ef_creature_type() const; + virtual u32 ef_anomaly_type() const; + virtual u32 ef_weapon_type() const; + virtual u32 ef_detector_type() const; + virtual bool natural_weapon() const { return true; } + virtual bool natural_detector() const { return true; } #ifdef XRGAME_EXPORTS - virtual CSE_ALifeItemWeapon *tpfGetBestWeapon (ALife::EHitType &tHitType, float &fHitPower) = 0; - virtual bool bfPerformAttack () {return(true);}; - virtual void vfUpdateWeaponAmmo () {}; - virtual void vfProcessItems () {}; - virtual void vfAttachItems (ALife::ETakeType tTakeType = ALife::eTakeTypeAll) {}; - virtual ALife::EMeetActionType tfGetActionType (CSE_ALifeSchedulable *tpALifeSchedulable,int iGroupIndex, bool bMutualDetection) = 0; - virtual bool bfActive () = 0; - virtual CSE_ALifeDynamicObject *tpfGetBestDetector () = 0; + virtual CSE_ALifeItemWeapon* tpfGetBestWeapon(ALife::EHitType& tHitType, float& fHitPower) = 0; + virtual bool bfPerformAttack() { return (true); }; + virtual void vfUpdateWeaponAmmo(){}; + virtual void vfProcessItems(){}; + virtual void vfAttachItems(ALife::ETakeType tTakeType = ALife::eTakeTypeAll){}; + virtual ALife::EMeetActionType tfGetActionType( + CSE_ALifeSchedulable* tpALifeSchedulable, int iGroupIndex, bool bMutualDetection) = 0; + virtual bool bfActive() = 0; + virtual CSE_ALifeDynamicObject* tpfGetBestDetector() = 0; #endif }; class CSE_ALifeGraphPoint : public CSE_Abstract { using inherited = CSE_Abstract; -public: - shared_str m_caConnectionLevelName; - shared_str m_caConnectionPointName; - u8 m_tLocations[GameGraph::LOCATION_TYPE_COUNT]; - CSE_ALifeGraphPoint (LPCSTR caSection); - virtual ~CSE_ALifeGraphPoint(); - virtual bool match_configuration () const { return false; } +public: + shared_str m_caConnectionLevelName; + shared_str m_caConnectionPointName; + u8 m_tLocations[GameGraph::LOCATION_TYPE_COUNT]; + CSE_ALifeGraphPoint(LPCSTR caSection); + virtual ~CSE_ALifeGraphPoint(); + virtual bool match_configuration() const { return false; } #ifndef XRGAME_EXPORTS - virtual void __stdcall on_render (CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent,int priority, bool strictB2F); + virtual void __stdcall on_render(CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, + const Fmatrix& parent, int priority, bool strictB2F); #endif virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -108,70 +110,70 @@ class CSE_ALifeGraphPoint : public CSE_Abstract SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeObject : - public CSE_Abstract, - public CRandom +class CSE_ALifeObject : public CSE_Abstract, public CRandom { using inherited1 = CSE_Abstract; using inherited2 = CRandom; + public: - enum { - flUseSwitches = u32(1) << 0, - flSwitchOnline = u32(1) << 1, - flSwitchOffline = u32(1) << 2, - flInteractive = u32(1) << 3, - flVisibleForAI = u32(1) << 4, - flUsefulForAI = u32(1) << 5, - flOfflineNoMove = u32(1) << 6, - flUsedAI_Locations = u32(1) << 7, - flGroupBehaviour = u32(1) << 8, - flCanSave = u32(1) << 9, - flVisibleForMap = u32(1) << 10, - flUseSmartTerrains = u32(1) << 11, + enum + { + flUseSwitches = u32(1) << 0, + flSwitchOnline = u32(1) << 1, + flSwitchOffline = u32(1) << 2, + flInteractive = u32(1) << 3, + flVisibleForAI = u32(1) << 4, + flUsefulForAI = u32(1) << 5, + flOfflineNoMove = u32(1) << 6, + flUsedAI_Locations = u32(1) << 7, + flGroupBehaviour = u32(1) << 8, + flCanSave = u32(1) << 9, + flVisibleForMap = u32(1) << 10, + flUseSmartTerrains = u32(1) << 11, flCheckForSeparator = u32(1) << 12, }; public: using inherited = CSE_Abstract; - GameGraph::_GRAPH_ID m_tGraphID; - float m_fDistance; - bool m_bOnline; - bool m_bDirectControl; - u32 m_tNodeID; - flags32 m_flags; - ALife::_STORY_ID m_story_id; - ALife::_SPAWN_STORY_ID m_spawn_story_id; + GameGraph::_GRAPH_ID m_tGraphID; + float m_fDistance; + bool m_bOnline; + bool m_bDirectControl; + u32 m_tNodeID; + flags32 m_flags; + ALife::_STORY_ID m_story_id; + ALife::_SPAWN_STORY_ID m_spawn_story_id; #ifdef XRGAME_EXPORTS - CALifeSimulator *m_alife_simulator; + CALifeSimulator* m_alife_simulator; #endif - CSE_ALifeObject (LPCSTR caSection); - virtual ~CSE_ALifeObject (); - virtual bool used_ai_locations () const; - virtual bool can_save () const; - virtual bool can_switch_online () const; - virtual bool can_switch_offline () const; - virtual bool interactive () const; - virtual CSE_ALifeObject *cast_alife_object () {return this;} - bool move_offline () const; - void can_switch_online (bool value); - void can_switch_offline (bool value); - void use_ai_locations (bool value); - void interactive (bool value); - void move_offline (bool value); - bool visible_for_map () const; - void visible_for_map (bool value); - virtual u32 ef_equipment_type () const; - virtual u32 ef_main_weapon_type () const; - virtual u32 ef_weapon_type () const; - virtual u32 ef_detector_type () const; + CSE_ALifeObject(LPCSTR caSection); + virtual ~CSE_ALifeObject(); + virtual bool used_ai_locations() const; + virtual bool can_save() const; + virtual bool can_switch_online() const; + virtual bool can_switch_offline() const; + virtual bool interactive() const; + virtual CSE_ALifeObject* cast_alife_object() { return this; } + bool move_offline() const; + void can_switch_online(bool value); + void can_switch_offline(bool value); + void use_ai_locations(bool value); + void interactive(bool value); + void move_offline(bool value); + bool visible_for_map() const; + void visible_for_map(bool value); + virtual u32 ef_equipment_type() const; + virtual u32 ef_main_weapon_type() const; + virtual u32 ef_weapon_type() const; + virtual u32 ef_detector_type() const; #ifdef XRGAME_EXPORTS - virtual void spawn_supplies (LPCSTR); - virtual void spawn_supplies (); - CALifeSimulator &alife () const; - virtual Fvector draw_level_position () const; - virtual bool keep_saved_data_anyway () const; + virtual void spawn_supplies(LPCSTR); + virtual void spawn_supplies(); + CALifeSimulator& alife() const; + virtual Fvector draw_level_position() const; + virtual bool keep_saved_data_anyway() const; #endif virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -183,25 +185,25 @@ class CSE_ALifeObject : class CSE_ALifeGroupAbstract { public: - ALife::OBJECT_VECTOR m_tpMembers; - bool m_bCreateSpawnPositions; - u16 m_wCount; - ALife::_TIME_ID m_tNextBirthTime; - - CSE_ALifeGroupAbstract (LPCSTR caSection); - virtual ~CSE_ALifeGroupAbstract (); - virtual CSE_Abstract *init (); - virtual CSE_Abstract *base () = 0; - virtual const CSE_Abstract *base () const = 0; - virtual CSE_ALifeGroupAbstract *cast_group_abstract () {return this;}; - virtual CSE_Abstract *cast_abstract () {return 0;}; + ALife::OBJECT_VECTOR m_tpMembers; + bool m_bCreateSpawnPositions; + u16 m_wCount; + ALife::_TIME_ID m_tNextBirthTime; + + CSE_ALifeGroupAbstract(LPCSTR caSection); + virtual ~CSE_ALifeGroupAbstract(); + virtual CSE_Abstract* init(); + virtual CSE_Abstract* base() = 0; + virtual const CSE_Abstract* base() const = 0; + virtual CSE_ALifeGroupAbstract* cast_group_abstract() { return this; }; + virtual CSE_Abstract* cast_abstract() { return 0; }; #ifdef XRGAME_EXPORTS - virtual bool synchronize_location (); - virtual void try_switch_online (); - virtual void try_switch_offline (); - virtual void switch_online (); - virtual void switch_offline (); - virtual bool redundant () const; + virtual bool synchronize_location(); + virtual void try_switch_online(); + virtual void try_switch_offline(); + virtual void switch_online(); + virtual void switch_offline(); + virtual bool redundant() const; #endif virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -210,141 +212,103 @@ class CSE_ALifeGroupAbstract SERVER_ENTITY_EDITOR_METHODS }; -template -class CSE_ALifeGroupTemplate : - public __A, public CSE_ALifeGroupAbstract +template +class CSE_ALifeGroupTemplate : public __A, public CSE_ALifeGroupAbstract { using inherited1 = __A; using inherited2 = CSE_ALifeGroupAbstract; + public: - CSE_ALifeGroupTemplate(LPCSTR caSection) : __A(pSettings->line_exist(caSection,"monster_section") ? pSettings->r_string(caSection,"monster_section") : caSection), CSE_ALifeGroupAbstract(caSection) - { - }; - - virtual ~CSE_ALifeGroupTemplate() - { - }; - - virtual void STATE_Read (NET_Packet &tNetPacket, u16 size) - { - inherited1::STATE_Read (tNetPacket,size); - inherited2::STATE_Read (tNetPacket,size); - }; + CSE_ALifeGroupTemplate(LPCSTR caSection) + : __A(pSettings->line_exist(caSection, "monster_section") ? pSettings->r_string(caSection, "monster_section") : + caSection), + CSE_ALifeGroupAbstract(caSection){}; - virtual void STATE_Write (NET_Packet &tNetPacket) - { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); - }; + virtual ~CSE_ALifeGroupTemplate(){}; - virtual void UPDATE_Read (NET_Packet &tNetPacket) + virtual void STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); + inherited1::STATE_Read(tNetPacket, size); + inherited2::STATE_Read(tNetPacket, size); }; - virtual void UPDATE_Write (NET_Packet &tNetPacket) + virtual void STATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); }; - virtual CSE_Abstract *init () + virtual void UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::init (); - inherited2::init (); - return (base()); - } + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); + }; - virtual CSE_Abstract *base () + virtual void UPDATE_Write(NET_Packet& tNetPacket) { - return (inherited1::base()); - } + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); + }; - virtual const CSE_Abstract *base() const + virtual CSE_Abstract* init() { - return (inherited1::base()); + inherited1::init(); + inherited2::init(); + return (base()); } + virtual CSE_Abstract* base() { return (inherited1::base()); } + virtual const CSE_Abstract* base() const { return (inherited1::base()); } #ifndef XRGAME_EXPORTS - virtual void FillProps (LPCSTR pref, PropItemVec& items) - { - inherited1::FillProps (pref, items); - inherited2::FillProps (pref, items); - }; -#endif // #ifndef XRGAME_EXPORTS - - virtual CSE_Abstract *cast_abstract () + virtual void FillProps(LPCSTR pref, PropItemVec& items) { - return (this); - } - - virtual CSE_ALifeGroupAbstract *cast_group_abstract () - { - return (this); - } + inherited1::FillProps(pref, items); + inherited2::FillProps(pref, items); + }; +#endif // #ifndef XRGAME_EXPORTS + virtual CSE_Abstract* cast_abstract() { return (this); } + virtual CSE_ALifeGroupAbstract* cast_group_abstract() { return (this); } #ifdef XRGAME_EXPORTS - virtual void switch_online () - { - inherited2::switch_online (); - } - - virtual void switch_offline () - { - inherited2::switch_offline (); - } - - virtual bool synchronize_location () - { - return (inherited2::synchronize_location()); - } - - virtual void try_switch_online () - { - inherited2::try_switch_online (); - } - - virtual void try_switch_offline () - { - inherited2::try_switch_offline (); - } - - virtual bool redundant () const - { - return (inherited2::redundant()); - } + virtual void switch_online() { inherited2::switch_online(); } + virtual void switch_offline() { inherited2::switch_offline(); } + virtual bool synchronize_location() { return (inherited2::synchronize_location()); } + virtual void try_switch_online() { inherited2::try_switch_online(); } + virtual void try_switch_offline() { inherited2::try_switch_offline(); } + virtual bool redundant() const { return (inherited2::redundant()); } #endif }; class CSE_ALifeDynamicObject : public CSE_ALifeObject { using inherited = CSE_ALifeObject; + public: - ALife::_TIME_ID m_tTimeID; - u64 m_switch_counter; - - CSE_ALifeDynamicObject (LPCSTR caSection); - virtual ~CSE_ALifeDynamicObject (); + ALife::_TIME_ID m_tTimeID; + u64 m_switch_counter; + + CSE_ALifeDynamicObject(LPCSTR caSection); + virtual ~CSE_ALifeDynamicObject(); #ifdef XRGAME_EXPORTS - virtual void on_spawn (); - virtual void on_before_register (); - virtual void on_register (); - virtual void on_unregister (); - virtual bool synchronize_location (); - virtual void try_switch_online (); - virtual void try_switch_offline (); - virtual void switch_online (); - virtual void switch_offline (); - virtual void add_online (const bool &update_registries); - virtual void add_offline (const xr_vector &saved_children, const bool &update_registries); - virtual bool redundant () const; - void attach (CSE_ALifeInventoryItem *tpALifeInventoryItem, bool bALifeRequest, bool bAddChildren = true); - void detach (CSE_ALifeInventoryItem *tpALifeInventoryItem, ALife::OBJECT_IT *I = 0, bool bALifeRequest = true, bool bRemoveChildren = true); - virtual void clear_client_data (); - virtual void on_failed_switch_online (); + virtual void on_spawn(); + virtual void on_before_register(); + virtual void on_register(); + virtual void on_unregister(); + virtual bool synchronize_location(); + virtual void try_switch_online(); + virtual void try_switch_offline(); + virtual void switch_online(); + virtual void switch_offline(); + virtual void add_online(const bool& update_registries); + virtual void add_offline(const xr_vector& saved_children, const bool& update_registries); + virtual bool redundant() const; + void attach(CSE_ALifeInventoryItem* tpALifeInventoryItem, bool bALifeRequest, bool bAddChildren = true); + void detach(CSE_ALifeInventoryItem* tpALifeInventoryItem, ALife::OBJECT_IT* I = 0, bool bALifeRequest = true, + bool bRemoveChildren = true); + virtual void clear_client_data(); + virtual void on_failed_switch_online(); #endif - virtual CSE_ALifeDynamicObject *cast_alife_dynamic_object () {return this;} + virtual CSE_ALifeDynamicObject* cast_alife_dynamic_object() { return this; } virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -352,16 +316,15 @@ class CSE_ALifeDynamicObject : public CSE_ALifeObject SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeDynamicObjectVisual : - public CSE_ALifeDynamicObject, - public CSE_Visual +class CSE_ALifeDynamicObjectVisual : public CSE_ALifeDynamicObject, public CSE_Visual { using inherited1 = CSE_ALifeDynamicObject; using inherited2 = CSE_Visual; + public: - CSE_ALifeDynamicObjectVisual(LPCSTR caSection); - virtual ~CSE_ALifeDynamicObjectVisual(); - virtual CSE_Visual* __stdcall visual (); + CSE_ALifeDynamicObjectVisual(LPCSTR caSection); + virtual ~CSE_ALifeDynamicObjectVisual(); + virtual CSE_Visual* __stdcall visual(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -369,19 +332,18 @@ class CSE_ALifeDynamicObjectVisual : SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifePHSkeletonObject : - public CSE_ALifeDynamicObjectVisual, - public CSE_PHSkeleton +class CSE_ALifePHSkeletonObject : public CSE_ALifeDynamicObjectVisual, public CSE_PHSkeleton { using inherited1 = CSE_ALifeDynamicObjectVisual; using inherited2 = CSE_PHSkeleton; + public: - CSE_ALifePHSkeletonObject(LPCSTR caSection); - virtual ~CSE_ALifePHSkeletonObject(); - virtual bool can_save () const; - virtual bool used_ai_locations () const; - virtual void load (NET_Packet &tNetPacket); - virtual CSE_Abstract *cast_abstract () {return this;} + CSE_ALifePHSkeletonObject(LPCSTR caSection); + virtual ~CSE_ALifePHSkeletonObject(); + virtual bool can_save() const; + virtual bool used_ai_locations() const; + virtual void load(NET_Packet& tNetPacket); + virtual CSE_Abstract* cast_abstract() { return this; } public: virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -390,20 +352,19 @@ class CSE_ALifePHSkeletonObject : SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeSpaceRestrictor : - public CSE_ALifeDynamicObject, - public CSE_Shape +class CSE_ALifeSpaceRestrictor : public CSE_ALifeDynamicObject, public CSE_Shape { using inherited1 = CSE_ALifeDynamicObject; using inherited2 = CSE_Shape; + public: - u8 m_space_restrictor_type; + u8 m_space_restrictor_type; - CSE_ALifeSpaceRestrictor (LPCSTR caSection); - virtual ~CSE_ALifeSpaceRestrictor (); - virtual IServerEntityShape* __stdcall shape (); - virtual bool can_switch_offline () const; - virtual bool used_ai_locations () const; + CSE_ALifeSpaceRestrictor(LPCSTR caSection); + virtual ~CSE_ALifeSpaceRestrictor(); + virtual IServerEntityShape* __stdcall shape(); + virtual bool can_switch_offline() const; + virtual bool used_ai_locations() const; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -414,17 +375,18 @@ class CSE_ALifeSpaceRestrictor : class CSE_ALifeLevelChanger : public CSE_ALifeSpaceRestrictor { using inherited = CSE_ALifeSpaceRestrictor; + public: - GameGraph::_GRAPH_ID m_tNextGraphID; - u32 m_dwNextNodeID; - Fvector m_tNextPosition; - Fvector m_tAngles; - shared_str m_caLevelToChange; - shared_str m_caLevelPointToChange; - BOOL m_bSilentMode; - - CSE_ALifeLevelChanger (LPCSTR caSection); - virtual ~CSE_ALifeLevelChanger (); + GameGraph::_GRAPH_ID m_tNextGraphID; + u32 m_dwNextNodeID; + Fvector m_tNextPosition; + Fvector m_tAngles; + shared_str m_caLevelToChange; + shared_str m_caLevelPointToChange; + BOOL m_bSilentMode; + + CSE_ALifeLevelChanger(LPCSTR caSection); + virtual ~CSE_ALifeLevelChanger(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -432,36 +394,36 @@ class CSE_ALifeLevelChanger : public CSE_ALifeSpaceRestrictor SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeSmartZone : - public CSE_ALifeSpaceRestrictor, - public CSE_ALifeSchedulable +class CSE_ALifeSmartZone : public CSE_ALifeSpaceRestrictor, public CSE_ALifeSchedulable { using inherited1 = CSE_ALifeSpaceRestrictor; using inherited2 = CSE_ALifeSchedulable; + public: - CSE_ALifeSmartZone (LPCSTR caSection); - virtual ~CSE_ALifeSmartZone (); - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual CSE_Abstract *init (); - virtual CSE_Abstract *cast_abstract () {return this;}; - virtual CSE_ALifeSchedulable *cast_schedulable () {return this;}; - virtual void update (); - virtual float detect_probability (); - virtual void smart_touch (CSE_ALifeMonsterAbstract *monster); - virtual bool used_ai_locations () const {return true;}; - virtual CSE_ALifeSmartZone *cast_smart_zone () {return this;}; + CSE_ALifeSmartZone(LPCSTR caSection); + virtual ~CSE_ALifeSmartZone(); + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual CSE_Abstract* init(); + virtual CSE_Abstract* cast_abstract() { return this; }; + virtual CSE_ALifeSchedulable* cast_schedulable() { return this; }; + virtual void update(); + virtual float detect_probability(); + virtual void smart_touch(CSE_ALifeMonsterAbstract* monster); + virtual bool used_ai_locations() const { return true; }; + virtual CSE_ALifeSmartZone* cast_smart_zone() { return this; }; #ifdef XRGAME_EXPORTS - virtual bool bfActive (); - virtual CSE_ALifeItemWeapon *tpfGetBestWeapon (ALife::EHitType &tHitType, float &fHitPower); - virtual CSE_ALifeDynamicObject *tpfGetBestDetector (); - virtual ALife::EMeetActionType tfGetActionType (CSE_ALifeSchedulable *tpALifeSchedulable,int iGroupIndex, bool bMutualDetection); + virtual bool bfActive(); + virtual CSE_ALifeItemWeapon* tpfGetBestWeapon(ALife::EHitType& tHitType, float& fHitPower); + virtual CSE_ALifeDynamicObject* tpfGetBestDetector(); + virtual ALife::EMeetActionType tfGetActionType( + CSE_ALifeSchedulable* tpALifeSchedulable, int iGroupIndex, bool bMutualDetection); // additional functionality - virtual bool enabled (CSE_ALifeMonsterAbstract *object) const {return false;}; - virtual float suitable (CSE_ALifeMonsterAbstract *object) const {return 0.f;}; - virtual void register_npc (CSE_ALifeMonsterAbstract *object) {}; - virtual void unregister_npc (CSE_ALifeMonsterAbstract *object) {}; - virtual CALifeSmartTerrainTask *task (CSE_ALifeMonsterAbstract *object) {return 0;}; + virtual bool enabled(CSE_ALifeMonsterAbstract* object) const { return false; }; + virtual float suitable(CSE_ALifeMonsterAbstract* object) const { return 0.f; }; + virtual void register_npc(CSE_ALifeMonsterAbstract* object){}; + virtual void unregister_npc(CSE_ALifeMonsterAbstract* object){}; + virtual CALifeSmartTerrainTask* task(CSE_ALifeMonsterAbstract* object) { return 0; }; #endif virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -470,55 +432,57 @@ class CSE_ALifeSmartZone : SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeObjectPhysic : - public CSE_ALifeDynamicObjectVisual, - public CSE_PHSkeleton +class CSE_ALifeObjectPhysic : public CSE_ALifeDynamicObjectVisual, public CSE_PHSkeleton { using inherited1 = CSE_ALifeDynamicObjectVisual; using inherited2 = CSE_PHSkeleton; + public: - u32 type; - f32 mass; - shared_str fixed_bones; - CSE_ALifeObjectPhysic (LPCSTR caSection); - virtual ~CSE_ALifeObjectPhysic (); - virtual bool used_ai_locations () const; - virtual bool can_save () const; - virtual void load (NET_Packet &tNetPacket); - virtual CSE_Abstract *cast_abstract () {return this;} -// virtual void load (IReader& r){inherited::load(r);} -// using inherited::load(IReader&); + u32 type; + f32 mass; + shared_str fixed_bones; + CSE_ALifeObjectPhysic(LPCSTR caSection); + virtual ~CSE_ALifeObjectPhysic(); + virtual bool used_ai_locations() const; + virtual bool can_save() const; + virtual void load(NET_Packet& tNetPacket); + virtual CSE_Abstract* cast_abstract() { return this; } + // virtual void load (IReader& r){inherited::load(r);} + // using inherited::load(IReader&); private: - u32 m_freeze_time; - static const u32 m_freeze_delta_time; -#ifdef DEBUG //only for testing interpolation - u32 m_last_update_time; - static const u32 m_update_delta_time; + u32 m_freeze_time; + static const u32 m_freeze_delta_time; +#ifdef DEBUG // only for testing interpolation + u32 m_last_update_time; + static const u32 m_update_delta_time; #endif - static const u32 random_limit; - CRandom m_relevent_random; + static const u32 random_limit; + CRandom m_relevent_random; public: - enum { - inventory_item_state_enabled = u8(1) << 0, - inventory_item_angular_null = u8(1) << 1, - inventory_item_linear_null = u8(1) << 2//, - //animated = u8(1) << 3 + enum + { + inventory_item_state_enabled = u8(1) << 0, + inventory_item_angular_null = u8(1) << 1, + inventory_item_linear_null = u8(1) << 2 //, + // animated = u8(1) << 3 }; - union mask_num_items { - struct { - u8 num_items : 5; - u8 mask : 3; + union mask_num_items + { + struct + { + u8 num_items : 5; + u8 mask : 3; }; - u8 common; + u8 common; }; /////////// network /////////////// - u8 m_u8NumItems; - bool prev_freezed; - bool freezed; - SPHNetState State; - - virtual BOOL Net_Relevant (); + u8 m_u8NumItems; + bool prev_freezed; + bool freezed; + SPHNetState State; + + virtual BOOL Net_Relevant(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -527,65 +491,65 @@ class CSE_ALifeObjectPhysic : SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeObjectHangingLamp : - public CSE_ALifeDynamicObjectVisual, - public CSE_PHSkeleton +class CSE_ALifeObjectHangingLamp : public CSE_ALifeDynamicObjectVisual, public CSE_PHSkeleton { using inherited1 = CSE_ALifeDynamicObjectVisual; using inherited2 = CSE_PHSkeleton; -public: - void __stdcall OnChangeFlag (PropValue* sender); - enum{ - flPhysic = (1<<0), - flCastShadow = (1<<1), - flR1 = (1<<2), - flR2 = (1<<3), - flTypeSpot = (1<<4), - flPointAmbient = (1<<5), - flVolumetric = (1<<6), +public: + void __stdcall OnChangeFlag(PropValue* sender); + enum + { + flPhysic = (1 << 0), + flCastShadow = (1 << 1), + flR1 = (1 << 2), + flR2 = (1 << 3), + flTypeSpot = (1 << 4), + flPointAmbient = (1 << 5), + flVolumetric = (1 << 6), }; - Flags16 flags; -// light color - u32 color; - float brightness; - shared_str color_animator; -// light texture - shared_str light_texture; -// range - float range; - float m_virtual_size; -// bones&motions - shared_str light_ambient_bone; - shared_str light_main_bone; - shared_str fixed_bones; -// spot - float spot_cone_angle; -// ambient - float m_ambient_radius; - float m_ambient_power; - shared_str m_ambient_texture; -// volumetric - float m_volumetric_quality; - float m_volumetric_intensity; - float m_volumetric_distance; -// glow - shared_str glow_texture; - float glow_radius; -// game - float m_health; - - CSE_ALifeObjectHangingLamp (LPCSTR caSection); - virtual ~CSE_ALifeObjectHangingLamp (); - virtual void load (NET_Packet &tNetPacket); - virtual bool used_ai_locations () const; - virtual bool match_configuration () const; - virtual bool __stdcall validate (); + Flags16 flags; + // light color + u32 color; + float brightness; + shared_str color_animator; + // light texture + shared_str light_texture; + // range + float range; + float m_virtual_size; + // bones&motions + shared_str light_ambient_bone; + shared_str light_main_bone; + shared_str fixed_bones; + // spot + float spot_cone_angle; + // ambient + float m_ambient_radius; + float m_ambient_power; + shared_str m_ambient_texture; + // volumetric + float m_volumetric_quality; + float m_volumetric_intensity; + float m_volumetric_distance; + // glow + shared_str glow_texture; + float glow_radius; + // game + float m_health; + + CSE_ALifeObjectHangingLamp(LPCSTR caSection); + virtual ~CSE_ALifeObjectHangingLamp(); + virtual void load(NET_Packet& tNetPacket); + virtual bool used_ai_locations() const; + virtual bool match_configuration() const; + virtual bool __stdcall validate(); #ifndef XRGAME_EXPORTS - virtual void __stdcall on_render (CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent,int priority, bool strictB2F); -#endif // #ifndef XRGAME_EXPORTS - virtual CSE_Abstract *cast_abstract () {return this;} + virtual void __stdcall on_render(CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, + const Fmatrix& parent, int priority, bool strictB2F); +#endif // #ifndef XRGAME_EXPORTS + virtual CSE_Abstract* cast_abstract() { return this; } virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -596,10 +560,11 @@ class CSE_ALifeObjectHangingLamp : class CSE_ALifeObjectProjector : public CSE_ALifeDynamicObjectVisual { using inherited = CSE_ALifeDynamicObjectVisual; + public: - CSE_ALifeObjectProjector (LPCSTR caSection); - virtual ~CSE_ALifeObjectProjector (); - virtual bool used_ai_locations () const; + CSE_ALifeObjectProjector(LPCSTR caSection); + virtual ~CSE_ALifeObjectProjector(); + virtual bool used_ai_locations() const; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -607,24 +572,21 @@ class CSE_ALifeObjectProjector : public CSE_ALifeDynamicObjectVisual SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeHelicopter : - public CSE_ALifeDynamicObjectVisual, - public CSE_Motion, - public CSE_PHSkeleton +class CSE_ALifeHelicopter : public CSE_ALifeDynamicObjectVisual, public CSE_Motion, public CSE_PHSkeleton { using inherited1 = CSE_ALifeDynamicObjectVisual; using inherited2 = CSE_Motion; using inherited3 = CSE_PHSkeleton; -public: - shared_str engine_sound; - CSE_ALifeHelicopter (LPCSTR caSection); - virtual ~CSE_ALifeHelicopter (); - virtual void load (NET_Packet &tNetPacket); - virtual bool can_save () const; - virtual bool used_ai_locations () const; - virtual CSE_Motion* __stdcall motion (); - virtual CSE_Abstract *cast_abstract () {return this;} +public: + shared_str engine_sound; + CSE_ALifeHelicopter(LPCSTR caSection); + virtual ~CSE_ALifeHelicopter(); + virtual void load(NET_Packet& tNetPacket); + virtual bool can_save() const; + virtual bool used_ai_locations() const; + virtual CSE_Motion* __stdcall motion(); + virtual CSE_Abstract* cast_abstract() { return this; } virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -632,38 +594,38 @@ class CSE_ALifeHelicopter : SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeCar : - public CSE_ALifeDynamicObjectVisual, - public CSE_PHSkeleton +class CSE_ALifeCar : public CSE_ALifeDynamicObjectVisual, public CSE_PHSkeleton { using inherited1 = CSE_ALifeDynamicObjectVisual; using inherited2 = CSE_PHSkeleton; + public: - struct SDoorState + struct SDoorState { - void read (NET_Packet& P); - void write (NET_Packet& P); + void read(NET_Packet& P); + void write(NET_Packet& P); u8 open_state; float health; }; - struct SWheelState + struct SWheelState { - void read (NET_Packet& P); - void write (NET_Packet& P); + void read(NET_Packet& P); + void write(NET_Packet& P); float health; }; - xr_vector door_states; - xr_vector wheel_states; - float health; - CSE_ALifeCar (LPCSTR caSection); - virtual ~CSE_ALifeCar (); - virtual bool used_ai_locations () const; - virtual void load (NET_Packet &tNetPacket); - virtual bool can_save () const; - virtual CSE_Abstract *cast_abstract () {return this;} + xr_vector door_states; + xr_vector wheel_states; + float health; + CSE_ALifeCar(LPCSTR caSection); + virtual ~CSE_ALifeCar(); + virtual bool used_ai_locations() const; + virtual void load(NET_Packet& tNetPacket); + virtual bool can_save() const; + virtual CSE_Abstract* cast_abstract() { return this; } protected: - virtual void data_load (NET_Packet &tNetPacket); - virtual void data_save (NET_Packet &tNetPacket); + virtual void data_load(NET_Packet& tNetPacket); + virtual void data_save(NET_Packet& tNetPacket); + public: virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -675,12 +637,13 @@ class CSE_ALifeCar : class CSE_ALifeObjectBreakable : public CSE_ALifeDynamicObjectVisual { typedef CSE_ALifeDynamicObjectVisual inherited; + public: - float m_health; - CSE_ALifeObjectBreakable (LPCSTR caSection); - virtual ~CSE_ALifeObjectBreakable (); - virtual bool used_ai_locations () const; - virtual bool can_switch_offline () const; + float m_health; + CSE_ALifeObjectBreakable(LPCSTR caSection); + virtual ~CSE_ALifeObjectBreakable(); + virtual bool used_ai_locations() const; + virtual bool can_switch_offline() const; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -688,36 +651,36 @@ class CSE_ALifeObjectBreakable : public CSE_ALifeDynamicObjectVisual SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeObjectClimable : - public CSE_Shape, - public CSE_ALifeDynamicObject +class CSE_ALifeObjectClimable : public CSE_Shape, public CSE_ALifeDynamicObject { using inherited1 = CSE_Shape; using inherited2 = CSE_ALifeDynamicObject; + public: -CSE_ALifeObjectClimable (LPCSTR caSection); -shared_str material; -virtual ~CSE_ALifeObjectClimable (); -virtual bool used_ai_locations () const; -virtual bool can_switch_offline () const; -virtual IServerEntityShape* __stdcall shape (); + CSE_ALifeObjectClimable(LPCSTR caSection); + shared_str material; + virtual ~CSE_ALifeObjectClimable(); + virtual bool used_ai_locations() const; + virtual bool can_switch_offline() const; + virtual IServerEntityShape* __stdcall shape(); #ifndef XRGAME_EXPORTS -virtual void __stdcall set_additional_info (void* info); + virtual void __stdcall set_additional_info(void* info); #endif -virtual void UPDATE_Read(NET_Packet& P); -virtual void UPDATE_Write(NET_Packet& P); -virtual void STATE_Read(NET_Packet& P, u16 size); -virtual void STATE_Write(NET_Packet& P); -SERVER_ENTITY_EDITOR_METHODS + virtual void UPDATE_Read(NET_Packet& P); + virtual void UPDATE_Write(NET_Packet& P); + virtual void STATE_Read(NET_Packet& P, u16 size); + virtual void STATE_Write(NET_Packet& P); + SERVER_ENTITY_EDITOR_METHODS }; class CSE_ALifeMountedWeapon : public CSE_ALifeDynamicObjectVisual { using inherited = CSE_ALifeDynamicObjectVisual; + public: - CSE_ALifeMountedWeapon (LPCSTR caSection); - virtual ~CSE_ALifeMountedWeapon (); + CSE_ALifeMountedWeapon(LPCSTR caSection); + virtual ~CSE_ALifeMountedWeapon(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -728,13 +691,14 @@ class CSE_ALifeMountedWeapon : public CSE_ALifeDynamicObjectVisual class CSE_ALifeStationaryMgun : public CSE_ALifeDynamicObjectVisual { using inherited = CSE_ALifeDynamicObjectVisual; + public: - bool m_bWorking; - Fvector m_destEnemyDir; + bool m_bWorking; + Fvector m_destEnemyDir; + + CSE_ALifeStationaryMgun(LPCSTR caSection); + virtual ~CSE_ALifeStationaryMgun(); - CSE_ALifeStationaryMgun (LPCSTR caSection); - virtual ~CSE_ALifeStationaryMgun (); - virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -745,11 +709,12 @@ class CSE_ALifeStationaryMgun : public CSE_ALifeDynamicObjectVisual class CSE_ALifeTeamBaseZone : public CSE_ALifeSpaceRestrictor { using inherited = CSE_ALifeSpaceRestrictor; + public: - CSE_ALifeTeamBaseZone (LPCSTR caSection); - virtual ~CSE_ALifeTeamBaseZone (); + CSE_ALifeTeamBaseZone(LPCSTR caSection); + virtual ~CSE_ALifeTeamBaseZone(); - u8 m_team; + u8 m_team; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -760,16 +725,17 @@ class CSE_ALifeTeamBaseZone : public CSE_ALifeSpaceRestrictor class CSE_ALifeInventoryBox : public CSE_ALifeDynamicObjectVisual { using inherited = CSE_ALifeDynamicObjectVisual; + public: - bool m_can_take; - bool m_closed; - shared_str m_tip_text; + bool m_can_take; + bool m_closed; + shared_str m_tip_text; - CSE_ALifeInventoryBox (LPCSTR caSection); - virtual ~CSE_ALifeInventoryBox (); + CSE_ALifeInventoryBox(LPCSTR caSection); + virtual ~CSE_ALifeInventoryBox(); #ifdef XRGAME_EXPORTS - virtual void add_offline (const xr_vector &saved_children, const bool &update_registries); - virtual void add_online (const bool &update_registries); + virtual void add_offline(const xr_vector& saved_children, const bool& update_registries); + virtual void add_online(const bool& update_registries); #endif virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Items.cpp index 869e8b64d5c..1c5ae70776a 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Items.cpp @@ -6,17 +6,17 @@ // Description : Server objects items for ALife simulator //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" -#include "xrMessages.h" #include "xrServer_Objects_ALife_Items.h" -#include "clsid_game.h" #include "Common/object_broker.h" +#include "clsid_game.h" +#include "stdafx.h" #include "xrCore/Animation/Bone.hpp" +#include "xrMessages.h" #ifdef XRGAME_EXPORTS -# ifdef DEBUG -# define PHPH_DEBUG -# endif +#ifdef DEBUG +#define PHPH_DEBUG +#endif #endif #ifdef PHPH_DEBUG #include "PHDebug.h" @@ -26,848 +26,824 @@ //////////////////////////////////////////////////////////////////////////// CSE_ALifeInventoryItem::CSE_ALifeInventoryItem(LPCSTR caSection) { - //òåêóùåå ñîñòîÿíèå âåùè - m_fCondition = 1.0f; + //òåêóùåå ñîñòîÿíèå âåùè + m_fCondition = 1.0f; - m_fMass = pSettings->r_float(caSection, "inv_weight"); - m_dwCost = pSettings->r_u32(caSection, "cost"); + m_fMass = pSettings->r_float(caSection, "inv_weight"); + m_dwCost = pSettings->r_u32(caSection, "cost"); - if (pSettings->line_exist(caSection, "condition")) - m_fCondition = pSettings->r_float(caSection, "condition"); + if (pSettings->line_exist(caSection, "condition")) m_fCondition = pSettings->r_float(caSection, "condition"); - if (pSettings->line_exist(caSection, "health_value")) - m_iHealthValue = pSettings->r_s32(caSection, "health_value"); - else - m_iHealthValue = 0; + if (pSettings->line_exist(caSection, "health_value")) + m_iHealthValue = pSettings->r_s32(caSection, "health_value"); + else + m_iHealthValue = 0; - if (pSettings->line_exist(caSection, "food_value")) - m_iFoodValue = pSettings->r_s32(caSection, "food_value"); - else - m_iFoodValue = 0; + if (pSettings->line_exist(caSection, "food_value")) + m_iFoodValue = pSettings->r_s32(caSection, "food_value"); + else + m_iFoodValue = 0; - m_fDeteriorationValue = 0; + m_fDeteriorationValue = 0; - m_last_update_time = 0; + m_last_update_time = 0; - State.quaternion.x = 0.f; - State.quaternion.y = 0.f; - State.quaternion.z = 1.f; - State.quaternion.w = 0.f; + State.quaternion.x = 0.f; + State.quaternion.y = 0.f; + State.quaternion.z = 1.f; + State.quaternion.w = 0.f; - State.angular_vel.set (0.f,0.f,0.f); - State.linear_vel.set (0.f,0.f,0.f); + State.angular_vel.set(0.f, 0.f, 0.f); + State.linear_vel.set(0.f, 0.f, 0.f); #ifdef XRGAME_EXPORTS - m_freeze_time = Device.dwTimeGlobal; + m_freeze_time = Device.dwTimeGlobal; #else - m_freeze_time = 0; + m_freeze_time = 0; #endif - m_relevent_random.seed (u32(CPU::GetCLK() & u32(-1))); - freezed = false; + m_relevent_random.seed(u32(CPU::GetCLK() & u32(-1))); + freezed = false; } -CSE_Abstract *CSE_ALifeInventoryItem::init () +CSE_Abstract* CSE_ALifeInventoryItem::init() { - m_self = smart_cast(this); - R_ASSERT (m_self); -// m_self->m_flags.set (CSE_ALifeObject::flSwitchOffline,TRUE); - return (base()); + m_self = smart_cast(this); + R_ASSERT(m_self); + // m_self->m_flags.set (CSE_ALifeObject::flSwitchOffline,TRUE); + return (base()); } -CSE_ALifeInventoryItem::~CSE_ALifeInventoryItem () +CSE_ALifeInventoryItem::~CSE_ALifeInventoryItem() { } -void CSE_ALifeInventoryItem::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeInventoryItem::STATE_Write(NET_Packet& tNetPacket) { - tNetPacket.w_float (m_fCondition); - save_data (m_upgrades, tNetPacket); - State.position = base()->o_Position; + tNetPacket.w_float(m_fCondition); + save_data(m_upgrades, tNetPacket); + State.position = base()->o_Position; } -void CSE_ALifeInventoryItem::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeInventoryItem::STATE_Read(NET_Packet& tNetPacket, u16 size) { - u16 m_wVersion = base()->m_wVersion; - if (m_wVersion > 52) - tNetPacket.r_float (m_fCondition); + u16 m_wVersion = base()->m_wVersion; + if (m_wVersion > 52) tNetPacket.r_float(m_fCondition); - if (m_wVersion > 123) - { - load_data (m_upgrades, tNetPacket); - } + if (m_wVersion > 123) { + load_data(m_upgrades, tNetPacket); + } - State.position = base()->o_Position; + State.position = base()->o_Position; } -static inline bool check (const u8 &mask, const u8 &test) +static inline bool check(const u8& mask, const u8& test) { - return (!!(mask & test)); + return (!!(mask & test)); } -const u32 CSE_ALifeInventoryItem::m_freeze_delta_time = 1000; -const u32 CSE_ALifeInventoryItem::random_limit = 120; +const u32 CSE_ALifeInventoryItem::m_freeze_delta_time = 1000; +const u32 CSE_ALifeInventoryItem::random_limit = 120; -//if TRUE, then object sends update packet +// if TRUE, then object sends update packet BOOL CSE_ALifeInventoryItem::Net_Relevant() { - if (base()->ID_Parent != u16(-1)) - return FALSE; + if (base()->ID_Parent != u16(-1)) return FALSE; - if (!freezed) - return TRUE; + if (!freezed) return TRUE; #ifdef XRGAME_EXPORTS - if (Device.dwTimeGlobal >= (m_freeze_time + m_freeze_delta_time)) - return FALSE; + if (Device.dwTimeGlobal >= (m_freeze_time + m_freeze_delta_time)) return FALSE; #endif - if (!prev_freezed) - { - prev_freezed = true; //i.e. freezed - return TRUE; - } + if (!prev_freezed) { + prev_freezed = true; // i.e. freezed + return TRUE; + } - if (m_relevent_random.randI(random_limit)) - return FALSE; + if (m_relevent_random.randI(random_limit)) return FALSE; - return TRUE; + return TRUE; } -void CSE_ALifeInventoryItem::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeInventoryItem::UPDATE_Write(NET_Packet& tNetPacket) { - if (!m_u8NumItems) { - tNetPacket.w_u8 (0); - return; - } - - mask_num_items num_items; - num_items.mask = 0; - num_items.num_items = m_u8NumItems; + if (!m_u8NumItems) { + tNetPacket.w_u8(0); + return; + } - R_ASSERT2 ( - num_items.num_items < (u8(1) << 5), - make_string("%d",num_items.num_items) - ); + mask_num_items num_items; + num_items.mask = 0; + num_items.num_items = m_u8NumItems; - if (State.enabled) num_items.mask |= inventory_item_state_enabled; - if (fis_zero(State.angular_vel.square_magnitude())) num_items.mask |= inventory_item_angular_null; - if (fis_zero(State.linear_vel.square_magnitude())) num_items.mask |= inventory_item_linear_null; - //if (anim_use) num_items.mask |= animated; + R_ASSERT2(num_items.num_items < (u8(1) << 5), make_string("%d", num_items.num_items)); - tNetPacket.w_u8 (num_items.common); + if (State.enabled) num_items.mask |= inventory_item_state_enabled; + if (fis_zero(State.angular_vel.square_magnitude())) num_items.mask |= inventory_item_angular_null; + if (fis_zero(State.linear_vel.square_magnitude())) num_items.mask |= inventory_item_linear_null; + // if (anim_use) num_items.mask |= animated; - /*if(check(num_items.mask,animated)) - { - tNetPacket.w_float (m_blend_timeCurrent); - }*/ + tNetPacket.w_u8(num_items.common); - { - tNetPacket.w_vec3 (State.force); - tNetPacket.w_vec3 (State.torque); + /*if(check(num_items.mask,animated)) + { + tNetPacket.w_float (m_blend_timeCurrent); + }*/ - tNetPacket.w_vec3 (State.position); + { + tNetPacket.w_vec3(State.force); + tNetPacket.w_vec3(State.torque); - tNetPacket.w_float (State.quaternion.x); - tNetPacket.w_float (State.quaternion.y); - tNetPacket.w_float (State.quaternion.z); - tNetPacket.w_float (State.quaternion.w); + tNetPacket.w_vec3(State.position); - if (!check(num_items.mask,inventory_item_angular_null)) { - tNetPacket.w_float (State.angular_vel.x); - tNetPacket.w_float (State.angular_vel.y); - tNetPacket.w_float (State.angular_vel.z); - } + tNetPacket.w_float(State.quaternion.x); + tNetPacket.w_float(State.quaternion.y); + tNetPacket.w_float(State.quaternion.z); + tNetPacket.w_float(State.quaternion.w); - if (!check(num_items.mask,inventory_item_linear_null)) { - tNetPacket.w_float (State.linear_vel.x); - tNetPacket.w_float (State.linear_vel.y); - tNetPacket.w_float (State.linear_vel.z); - } + if (!check(num_items.mask, inventory_item_angular_null)) { + tNetPacket.w_float(State.angular_vel.x); + tNetPacket.w_float(State.angular_vel.y); + tNetPacket.w_float(State.angular_vel.z); + } - } - tNetPacket.w_u8(1); // not freezed - doesn't mean anything... + if (!check(num_items.mask, inventory_item_linear_null)) { + tNetPacket.w_float(State.linear_vel.x); + tNetPacket.w_float(State.linear_vel.y); + tNetPacket.w_float(State.linear_vel.z); + } + } + tNetPacket.w_u8(1); // not freezed - doesn't mean anything... }; -void CSE_ALifeInventoryItem::UPDATE_Read (NET_Packet &tNetPacket) -{ - tNetPacket.r_u8 (m_u8NumItems); - if (!m_u8NumItems) { - //Msg("--- Object [%d] has no sync items", this->cast_abstract()->ID); - return; - } - - mask_num_items num_items; - num_items.common = m_u8NumItems; - m_u8NumItems = num_items.num_items; - - R_ASSERT2 ( - m_u8NumItems < (u8(1) << 5), - make_string("%d",m_u8NumItems) - ); - - /*if (check(num_items.mask,animated)) - { - tNetPacket.r_float(m_blend_timeCurrent); - anim_use=true; - } - else - { - anim_use=false; - }*/ - - { - tNetPacket.r_vec3 (State.force); - tNetPacket.r_vec3 (State.torque); - - tNetPacket.r_vec3 (State.position); - base()->o_Position.set (State.position); //this is very important because many functions use this o_Position.. - - tNetPacket.r_float (State.quaternion.x); - tNetPacket.r_float (State.quaternion.y); - tNetPacket.r_float (State.quaternion.z); - tNetPacket.r_float (State.quaternion.w); - - State.enabled = check(num_items.mask,inventory_item_state_enabled); - - if (!check(num_items.mask,inventory_item_angular_null)) { - tNetPacket.r_float (State.angular_vel.x); - tNetPacket.r_float (State.angular_vel.y); - tNetPacket.r_float (State.angular_vel.z); - } - else - State.angular_vel.set (0.f,0.f,0.f); - - if (!check(num_items.mask,inventory_item_linear_null)) { - tNetPacket.r_float (State.linear_vel.x); - tNetPacket.r_float (State.linear_vel.y); - tNetPacket.r_float (State.linear_vel.z); - } - else - State.linear_vel.set (0.f,0.f,0.f); - - /*if (check(num_items.mask,animated)) - { - anim_use=true; - }*/ - } - prev_freezed = freezed; - if (tNetPacket.r_eof()) // in case spawn + update - { - freezed = false; - return; - } - if (tNetPacket.r_u8()) - { - freezed = false; - } - else { - if (!freezed) +void CSE_ALifeInventoryItem::UPDATE_Read(NET_Packet& tNetPacket) +{ + tNetPacket.r_u8(m_u8NumItems); + if (!m_u8NumItems) { + // Msg("--- Object [%d] has no sync items", this->cast_abstract()->ID); + return; + } + + mask_num_items num_items; + num_items.common = m_u8NumItems; + m_u8NumItems = num_items.num_items; + + R_ASSERT2(m_u8NumItems < (u8(1) << 5), make_string("%d", m_u8NumItems)); + + /*if (check(num_items.mask,animated)) + { + tNetPacket.r_float(m_blend_timeCurrent); + anim_use=true; + } + else + { + anim_use=false; + }*/ + + { + tNetPacket.r_vec3(State.force); + tNetPacket.r_vec3(State.torque); + + tNetPacket.r_vec3(State.position); + base()->o_Position.set(State.position); // this is very important because many functions use this o_Position.. + + tNetPacket.r_float(State.quaternion.x); + tNetPacket.r_float(State.quaternion.y); + tNetPacket.r_float(State.quaternion.z); + tNetPacket.r_float(State.quaternion.w); + + State.enabled = check(num_items.mask, inventory_item_state_enabled); + + if (!check(num_items.mask, inventory_item_angular_null)) { + tNetPacket.r_float(State.angular_vel.x); + tNetPacket.r_float(State.angular_vel.y); + tNetPacket.r_float(State.angular_vel.z); + } + else + State.angular_vel.set(0.f, 0.f, 0.f); + + if (!check(num_items.mask, inventory_item_linear_null)) { + tNetPacket.r_float(State.linear_vel.x); + tNetPacket.r_float(State.linear_vel.y); + tNetPacket.r_float(State.linear_vel.z); + } + else + State.linear_vel.set(0.f, 0.f, 0.f); + + /*if (check(num_items.mask,animated)) + { + anim_use=true; + }*/ + } + prev_freezed = freezed; + if (tNetPacket.r_eof()) // in case spawn + update + { + freezed = false; + return; + } + if (tNetPacket.r_u8()) { + freezed = false; + } + else + { + if (!freezed) #ifdef XRGAME_EXPORTS - m_freeze_time = Device.dwTimeGlobal; + m_freeze_time = Device.dwTimeGlobal; #else - m_freeze_time = 0; + m_freeze_time = 0; #endif - freezed = true; - } + freezed = true; + } }; #ifndef XRGAME_EXPORTS -void CSE_ALifeInventoryItem::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeInventoryItem::FillProps(LPCSTR pref, PropItemVec& values) { - PHelper().CreateFloat (values, PrepareKey(pref, *base()->s_name, "Item condition"), &m_fCondition, 0.f, 1.f); - CSE_ALifeObject *alife_object = smart_cast(base()); - R_ASSERT (alife_object); - PHelper().CreateFlag32 (values, PrepareKey(pref, *base()->s_name,"ALife\\Useful for AI"), &alife_object->m_flags, CSE_ALifeObject::flUsefulForAI); - PHelper().CreateFlag32 (values, PrepareKey(pref, *base()->s_name,"ALife\\Visible for AI"), &alife_object->m_flags, CSE_ALifeObject::flVisibleForAI); + PHelper().CreateFloat(values, PrepareKey(pref, *base()->s_name, "Item condition"), &m_fCondition, 0.f, 1.f); + CSE_ALifeObject* alife_object = smart_cast(base()); + R_ASSERT(alife_object); + PHelper().CreateFlag32(values, PrepareKey(pref, *base()->s_name, "ALife\\Useful for AI"), &alife_object->m_flags, + CSE_ALifeObject::flUsefulForAI); + PHelper().CreateFlag32(values, PrepareKey(pref, *base()->s_name, "ALife\\Visible for AI"), &alife_object->m_flags, + CSE_ALifeObject::flVisibleForAI); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeInventoryItem::bfUseful () +bool CSE_ALifeInventoryItem::bfUseful() { - return (true); + return (true); } -u32 CSE_ALifeInventoryItem::update_rate () const +u32 CSE_ALifeInventoryItem::update_rate() const { - return (1000); + return (1000); } -bool CSE_ALifeInventoryItem::has_upgrade( const shared_str& upgrade_id ) +bool CSE_ALifeInventoryItem::has_upgrade(const shared_str& upgrade_id) { - return ( std::find( m_upgrades.begin(), m_upgrades.end(), upgrade_id ) != m_upgrades.end() ); + return (std::find(m_upgrades.begin(), m_upgrades.end(), upgrade_id) != m_upgrades.end()); } -void CSE_ALifeInventoryItem::add_upgrade( const shared_str& upgrade_id ) +void CSE_ALifeInventoryItem::add_upgrade(const shared_str& upgrade_id) { - if ( !has_upgrade( upgrade_id ) ) - { - m_upgrades.push_back( upgrade_id ); - return; - } - FATAL( make_string( "Can`t add existent upgrade (%s)!", upgrade_id.c_str() ).c_str() ); + if (!has_upgrade(upgrade_id)) { + m_upgrades.push_back(upgrade_id); + return; + } + FATAL(make_string("Can`t add existent upgrade (%s)!", upgrade_id.c_str()).c_str()); } - //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItem //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItem::CSE_ALifeItem (LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection), CSE_ALifeInventoryItem(caSection) +CSE_ALifeItem::CSE_ALifeItem(LPCSTR caSection) + : CSE_ALifeDynamicObjectVisual(caSection), CSE_ALifeInventoryItem(caSection) { - m_physics_disabled = false; + m_physics_disabled = false; } -CSE_ALifeItem::~CSE_ALifeItem () +CSE_ALifeItem::~CSE_ALifeItem() { } -CSE_Abstract *CSE_ALifeItem::init () +CSE_Abstract* CSE_ALifeItem::init() { - inherited1::init (); - inherited2::init (); - return (base()); + inherited1::init(); + inherited2::init(); + return (base()); } -CSE_Abstract *CSE_ALifeItem::base () +CSE_Abstract* CSE_ALifeItem::base() { - return (inherited1::base()); + return (inherited1::base()); } -const CSE_Abstract *CSE_ALifeItem::base () const +const CSE_Abstract* CSE_ALifeItem::base() const { - return (inherited1::base()); + return (inherited1::base()); } -void CSE_ALifeItem::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItem::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); } -void CSE_ALifeItem::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItem::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket, size); - if ((m_tClassID == CLSID_OBJECT_W_BINOCULAR) && (m_wVersion < 37)) { - tNetPacket.r_u16 (); - tNetPacket.r_u16 (); - tNetPacket.r_u8 (); - } - inherited2::STATE_Read (tNetPacket, size); + inherited1::STATE_Read(tNetPacket, size); + if ((m_tClassID == CLSID_OBJECT_W_BINOCULAR) && (m_wVersion < 37)) { + tNetPacket.r_u16(); + tNetPacket.r_u16(); + tNetPacket.r_u8(); + } + inherited2::STATE_Read(tNetPacket, size); } -void CSE_ALifeItem::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItem::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); #ifdef XRGAME_EXPORTS - m_last_update_time = Device.dwTimeGlobal; -#endif // XRGAME_EXPORTS + m_last_update_time = Device.dwTimeGlobal; +#endif // XRGAME_EXPORTS }; -void CSE_ALifeItem::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItem::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); - m_physics_disabled = false; + m_physics_disabled = false; }; #ifndef XRGAME_EXPORTS -void CSE_ALifeItem::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeItem::FillProps(LPCSTR pref, PropItemVec& values) { - inherited1::FillProps (pref, values); - inherited2::FillProps (pref, values); + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -BOOL CSE_ALifeItem::Net_Relevant () +BOOL CSE_ALifeItem::Net_Relevant() { - if (inherited1::Net_Relevant()) - return (TRUE); + if (inherited1::Net_Relevant()) return (TRUE); - if (inherited2::Net_Relevant()) - return (TRUE); + if (inherited2::Net_Relevant()) return (TRUE); - if (attached()) - return (FALSE); + if (attached()) return (FALSE); - if (!m_physics_disabled && !fis_zero(State.linear_vel.square_magnitude(),EPS_L)) - return (TRUE); + if (!m_physics_disabled && !fis_zero(State.linear_vel.square_magnitude(), EPS_L)) return (TRUE); #ifdef XRGAME_EXPORTS // if (Device.dwTimeGlobal < (m_last_update_time + update_rate())) // return (FALSE); -#endif // XRGAME_EXPORTS +#endif // XRGAME_EXPORTS - return (FALSE); + return (FALSE); } -void CSE_ALifeItem::OnEvent (NET_Packet &tNetPacket, u16 type, u32 time, ClientID sender ) +void CSE_ALifeItem::OnEvent(NET_Packet& tNetPacket, u16 type, u32 time, ClientID sender) { - inherited1::OnEvent (tNetPacket,type,time,sender); + inherited1::OnEvent(tNetPacket, type, time, sender); - if (type != GE_FREEZE_OBJECT) - return; + if (type != GE_FREEZE_OBJECT) return; -// R_ASSERT (!m_physics_disabled); - m_physics_disabled = true; + // R_ASSERT (!m_physics_disabled); + m_physics_disabled = true; } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemTorch //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemTorch::CSE_ALifeItemTorch (LPCSTR caSection) : CSE_ALifeItem(caSection) +CSE_ALifeItemTorch::CSE_ALifeItemTorch(LPCSTR caSection) : CSE_ALifeItem(caSection) { - m_active = false; - m_nightvision_active = false; - m_attached = false; + m_active = false; + m_nightvision_active = false; + m_attached = false; } -CSE_ALifeItemTorch::~CSE_ALifeItemTorch () +CSE_ALifeItemTorch::~CSE_ALifeItemTorch() { } -BOOL CSE_ALifeItemTorch::Net_Relevant () +BOOL CSE_ALifeItemTorch::Net_Relevant() { - if (m_attached) return true; - return inherited::Net_Relevant(); + if (m_attached) return true; + return inherited::Net_Relevant(); } - -void CSE_ALifeItemTorch::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemTorch::STATE_Read(NET_Packet& tNetPacket, u16 size) { - if (m_wVersion > 20) - inherited::STATE_Read (tNetPacket,size); - + if (m_wVersion > 20) inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeItemTorch::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemTorch::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeItemTorch::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemTorch::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); - - BYTE F = tNetPacket.r_u8(); - m_active = !!(F & eTorchActive); - m_nightvision_active = !!(F & eNightVisionActive); - m_attached = !!(F & eAttached); + inherited::UPDATE_Read(tNetPacket); + + BYTE F = tNetPacket.r_u8(); + m_active = !!(F & eTorchActive); + m_nightvision_active = !!(F & eNightVisionActive); + m_attached = !!(F & eAttached); } -void CSE_ALifeItemTorch::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemTorch::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); - BYTE F = 0; - F |= (m_active ? eTorchActive : 0); - F |= (m_nightvision_active ? eNightVisionActive : 0); - F |= (m_attached ? eAttached : 0); - tNetPacket.w_u8(F); + BYTE F = 0; + F |= (m_active ? eTorchActive : 0); + F |= (m_nightvision_active ? eNightVisionActive : 0); + F |= (m_attached ? eAttached : 0); + tNetPacket.w_u8(F); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemTorch::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeItemTorch::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref, values); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemWeapon //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemWeapon::CSE_ALifeItemWeapon (LPCSTR caSection) : CSE_ALifeItem(caSection) +CSE_ALifeItemWeapon::CSE_ALifeItemWeapon(LPCSTR caSection) : CSE_ALifeItem(caSection) { - a_current = 90; - a_elapsed = 0; - a_elapsed_grenades.grenades_count = 0; - a_elapsed_grenades.grenades_type = 0; + a_current = 90; + a_elapsed = 0; + a_elapsed_grenades.grenades_count = 0; + a_elapsed_grenades.grenades_type = 0; - wpn_flags = 0; - wpn_state = 0; - ammo_type = 0; + wpn_flags = 0; + wpn_state = 0; + ammo_type = 0; - m_fHitPower = pSettings->r_float(caSection,"hit_power"); - m_tHitType = ALife::g_tfString2HitType(pSettings->r_string(caSection,"hit_type")); - m_caAmmoSections = pSettings->r_string(caSection,"ammo_class"); - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); + m_fHitPower = pSettings->r_float(caSection, "hit_power"); + m_tHitType = ALife::g_tfString2HitType(pSettings->r_string(caSection, "hit_type")); + m_caAmmoSections = pSettings->r_string(caSection, "ammo_class"); + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) + set_visual(pSettings->r_string(caSection, "visual")); - m_addon_flags.zero (); + m_addon_flags.zero(); - m_scope_status = (EWeaponAddonStatus)pSettings->r_s32(s_name,"scope_status"); - m_silencer_status = (EWeaponAddonStatus)pSettings->r_s32(s_name,"silencer_status"); - m_grenade_launcher_status = (EWeaponAddonStatus)pSettings->r_s32(s_name,"grenade_launcher_status"); - m_ef_main_weapon_type = READ_IF_EXISTS(pSettings,r_u32,caSection,"ef_main_weapon_type",u32(-1)); - m_ef_weapon_type = READ_IF_EXISTS(pSettings,r_u32,caSection,"ef_weapon_type",u32(-1)); + m_scope_status = (EWeaponAddonStatus)pSettings->r_s32(s_name, "scope_status"); + m_silencer_status = (EWeaponAddonStatus)pSettings->r_s32(s_name, "silencer_status"); + m_grenade_launcher_status = (EWeaponAddonStatus)pSettings->r_s32(s_name, "grenade_launcher_status"); + m_ef_main_weapon_type = READ_IF_EXISTS(pSettings, r_u32, caSection, "ef_main_weapon_type", u32(-1)); + m_ef_weapon_type = READ_IF_EXISTS(pSettings, r_u32, caSection, "ef_weapon_type", u32(-1)); } -CSE_ALifeItemWeapon::~CSE_ALifeItemWeapon () +CSE_ALifeItemWeapon::~CSE_ALifeItemWeapon() { } -u32 CSE_ALifeItemWeapon::ef_main_weapon_type() const +u32 CSE_ALifeItemWeapon::ef_main_weapon_type() const { - VERIFY (m_ef_main_weapon_type != u32(-1)); - return (m_ef_main_weapon_type); + VERIFY(m_ef_main_weapon_type != u32(-1)); + return (m_ef_main_weapon_type); } -u32 CSE_ALifeItemWeapon::ef_weapon_type() const +u32 CSE_ALifeItemWeapon::ef_weapon_type() const { - VERIFY (m_ef_weapon_type != u32(-1)); - return (m_ef_weapon_type); + VERIFY(m_ef_weapon_type != u32(-1)); + return (m_ef_weapon_type); } -void CSE_ALifeItemWeapon::UPDATE_Read(NET_Packet &tNetPacket) +void CSE_ALifeItemWeapon::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); - tNetPacket.r_float_q8 (m_fCondition,0.0f,1.0f); - tNetPacket.r_u8 (wpn_flags); - tNetPacket.r_u16 (a_elapsed); - tNetPacket.r_u8 (m_addon_flags.flags); - tNetPacket.r_u8 (ammo_type); - tNetPacket.r_u8 (wpn_state); - tNetPacket.r_u8 (m_bZoom); + tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f); + tNetPacket.r_u8(wpn_flags); + tNetPacket.r_u16(a_elapsed); + tNetPacket.r_u8(m_addon_flags.flags); + tNetPacket.r_u8(ammo_type); + tNetPacket.r_u8(wpn_state); + tNetPacket.r_u8(m_bZoom); } void CSE_ALifeItemWeapon::clone_addons(CSE_ALifeItemWeapon* parent) { - m_addon_flags = parent->m_addon_flags; + m_addon_flags = parent->m_addon_flags; } -void CSE_ALifeItemWeapon::UPDATE_Write(NET_Packet &tNetPacket) +void CSE_ALifeItemWeapon::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); - tNetPacket.w_float_q8 (m_fCondition,0.0f,1.0f); - tNetPacket.w_u8 (wpn_flags); - tNetPacket.w_u16 (a_elapsed); - tNetPacket.w_u8 (m_addon_flags.get()); - tNetPacket.w_u8 (ammo_type); - tNetPacket.w_u8 (wpn_state); - tNetPacket.w_u8 (m_bZoom); + tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f); + tNetPacket.w_u8(wpn_flags); + tNetPacket.w_u16(a_elapsed); + tNetPacket.w_u8(m_addon_flags.get()); + tNetPacket.w_u8(ammo_type); + tNetPacket.w_u8(wpn_state); + tNetPacket.w_u8(m_bZoom); } -void CSE_ALifeItemWeapon::STATE_Read(NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemWeapon::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket, size); - tNetPacket.r_u16 (a_current); - tNetPacket.r_u16 (a_elapsed); - tNetPacket.r_u8 (wpn_state); - - if (m_wVersion > 40) - tNetPacket.r_u8 (m_addon_flags.flags); + inherited::STATE_Read(tNetPacket, size); + tNetPacket.r_u16(a_current); + tNetPacket.r_u16(a_elapsed); + tNetPacket.r_u8(wpn_state); + + if (m_wVersion > 40) tNetPacket.r_u8(m_addon_flags.flags); - if (m_wVersion > 46) - tNetPacket.r_u8 (ammo_type); - - if (m_wVersion > 122) - a_elapsed_grenades.unpack_from_byte(tNetPacket.r_u8()); + if (m_wVersion > 46) tNetPacket.r_u8(ammo_type); + + if (m_wVersion > 122) a_elapsed_grenades.unpack_from_byte(tNetPacket.r_u8()); } -void CSE_ALifeItemWeapon::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemWeapon::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_u16 (a_current); - tNetPacket.w_u16 (a_elapsed); - tNetPacket.w_u8 (wpn_state); - tNetPacket.w_u8 (m_addon_flags.get()); - tNetPacket.w_u8 (ammo_type); - tNetPacket.w_u8 (a_elapsed_grenades.pack_to_byte()); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_u16(a_current); + tNetPacket.w_u16(a_elapsed); + tNetPacket.w_u8(wpn_state); + tNetPacket.w_u8(m_addon_flags.get()); + tNetPacket.w_u8(ammo_type); + tNetPacket.w_u8(a_elapsed_grenades.pack_to_byte()); } -void CSE_ALifeItemWeapon::OnEvent (NET_Packet &tNetPacket, u16 type, u32 time, ClientID sender ) +void CSE_ALifeItemWeapon::OnEvent(NET_Packet& tNetPacket, u16 type, u32 time, ClientID sender) { - inherited::OnEvent (tNetPacket,type,time,sender); - switch (type) { - case GE_WPN_STATE_CHANGE: - { - tNetPacket.r_u8 (wpn_state); -// u8 sub_state = - tNetPacket.r_u8(); -// u8 NewAmmoType = - tNetPacket.r_u8(); -// u8 AmmoElapsed = - tNetPacket.r_u8(); - }break; - } + inherited::OnEvent(tNetPacket, type, time, sender); + switch (type) + { + case GE_WPN_STATE_CHANGE: + { + tNetPacket.r_u8(wpn_state); + // u8 sub_state = + tNetPacket.r_u8(); + // u8 NewAmmoType = + tNetPacket.r_u8(); + // u8 AmmoElapsed = + tNetPacket.r_u8(); + } + break; + } } -u8 CSE_ALifeItemWeapon::get_slot () +u8 CSE_ALifeItemWeapon::get_slot() { - return ((u8)pSettings->r_u8(s_name,"slot")); + return ((u8)pSettings->r_u8(s_name, "slot")); } -u16 CSE_ALifeItemWeapon::get_ammo_limit () +u16 CSE_ALifeItemWeapon::get_ammo_limit() { - return (u16) pSettings->r_u16(s_name,"ammo_limit"); + return (u16)pSettings->r_u16(s_name, "ammo_limit"); } -u16 CSE_ALifeItemWeapon::get_ammo_total () +u16 CSE_ALifeItemWeapon::get_ammo_total() { - return ((u16)a_current); + return ((u16)a_current); } -u16 CSE_ALifeItemWeapon::get_ammo_elapsed () +u16 CSE_ALifeItemWeapon::get_ammo_elapsed() { - return ((u16)a_elapsed); + return ((u16)a_elapsed); } -u16 CSE_ALifeItemWeapon::get_ammo_magsize () +u16 CSE_ALifeItemWeapon::get_ammo_magsize() { - if (pSettings->line_exist(s_name,"ammo_mag_size")) - return (pSettings->r_u16(s_name,"ammo_mag_size")); - else - return 0; + if (pSettings->line_exist(s_name, "ammo_mag_size")) + return (pSettings->r_u16(s_name, "ammo_mag_size")); + else + return 0; } - BOOL CSE_ALifeItemWeapon::Net_Relevant() { - if (wpn_flags==1) - return TRUE; + if (wpn_flags == 1) return TRUE; - return inherited::Net_Relevant(); + return inherited::Net_Relevant(); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemWeapon::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeItemWeapon::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref, items); - PHelper().CreateU8 (items,PrepareKey(pref,*s_name,"Ammo type:"), &ammo_type,0,255,1); - PHelper().CreateU16 (items,PrepareKey(pref,*s_name,"Ammo: in magazine"), &a_elapsed,0,30,1); - + inherited::FillProps(pref, items); + PHelper().CreateU8(items, PrepareKey(pref, *s_name, "Ammo type:"), &ammo_type, 0, 255, 1); + PHelper().CreateU16(items, PrepareKey(pref, *s_name, "Ammo: in magazine"), &a_elapsed, 0, 30, 1); - if (m_scope_status == ALife::eAddonAttachable) - PHelper().CreateFlag8(items,PrepareKey(pref,*s_name,"Addons\\Scope"), &m_addon_flags, eWeaponAddonScope); + if (m_scope_status == ALife::eAddonAttachable) + PHelper().CreateFlag8(items, PrepareKey(pref, *s_name, "Addons\\Scope"), &m_addon_flags, eWeaponAddonScope); - if (m_silencer_status == ALife::eAddonAttachable) - PHelper().CreateFlag8 (items,PrepareKey(pref,*s_name,"Addons\\Silencer"), &m_addon_flags, eWeaponAddonSilencer); + if (m_silencer_status == ALife::eAddonAttachable) + PHelper().CreateFlag8( + items, PrepareKey(pref, *s_name, "Addons\\Silencer"), &m_addon_flags, eWeaponAddonSilencer); - if (m_grenade_launcher_status == ALife::eAddonAttachable) - PHelper().CreateFlag8 (items,PrepareKey(pref,*s_name,"Addons\\Podstvolnik"),&m_addon_flags,eWeaponAddonGrenadeLauncher); + if (m_grenade_launcher_status == ALife::eAddonAttachable) + PHelper().CreateFlag8( + items, PrepareKey(pref, *s_name, "Addons\\Podstvolnik"), &m_addon_flags, eWeaponAddonGrenadeLauncher); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemWeaponShotGun //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemWeaponShotGun::CSE_ALifeItemWeaponShotGun (LPCSTR caSection) : CSE_ALifeItemWeaponMagazined(caSection) +CSE_ALifeItemWeaponShotGun::CSE_ALifeItemWeaponShotGun(LPCSTR caSection) : CSE_ALifeItemWeaponMagazined(caSection) { - m_AmmoIDs.clear(); + m_AmmoIDs.clear(); } -CSE_ALifeItemWeaponShotGun::~CSE_ALifeItemWeaponShotGun () +CSE_ALifeItemWeaponShotGun::~CSE_ALifeItemWeaponShotGun() { } -void CSE_ALifeItemWeaponShotGun::UPDATE_Read (NET_Packet& P) +void CSE_ALifeItemWeaponShotGun::UPDATE_Read(NET_Packet& P) { - inherited::UPDATE_Read(P); + inherited::UPDATE_Read(P); - m_AmmoIDs.clear(); - u8 AmmoCount = P.r_u8(); - for (u8 i=0; ir_s32(caSection, "box_size"); - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); + a_elapsed = m_boxSize = (u16)pSettings->r_s32(caSection, "box_size"); + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) + set_visual(pSettings->r_string(caSection, "visual")); } -CSE_ALifeItemAmmo::~CSE_ALifeItemAmmo () +CSE_ALifeItemAmmo::~CSE_ALifeItemAmmo() { } -void CSE_ALifeItemAmmo::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemAmmo::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); - tNetPacket.r_u16 (a_elapsed); + inherited::STATE_Read(tNetPacket, size); + tNetPacket.r_u16(a_elapsed); } -void CSE_ALifeItemAmmo::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemAmmo::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_u16 (a_elapsed); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_u16(a_elapsed); } -void CSE_ALifeItemAmmo::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemAmmo::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); - tNetPacket.r_u16 (a_elapsed); + tNetPacket.r_u16(a_elapsed); } -void CSE_ALifeItemAmmo::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemAmmo::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); - tNetPacket.w_u16 (a_elapsed); + tNetPacket.w_u16(a_elapsed); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemAmmo::FillProps (LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref,values); - PHelper().CreateU16 (values, PrepareKey(pref, *s_name, "Ammo: left"), &a_elapsed, 0, m_boxSize, m_boxSize); +void CSE_ALifeItemAmmo::FillProps(LPCSTR pref, PropItemVec& values) +{ + inherited::FillProps(pref, values); + PHelper().CreateU16(values, PrepareKey(pref, *s_name, "Ammo: left"), &a_elapsed, 0, m_boxSize, m_boxSize); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeItemAmmo::can_switch_online () const +bool CSE_ALifeItemAmmo::can_switch_online() const { - return inherited::can_switch_online(); + return inherited::can_switch_online(); } -bool CSE_ALifeItemAmmo::can_switch_offline () const +bool CSE_ALifeItemAmmo::can_switch_offline() const { - return ( inherited::can_switch_offline() && a_elapsed!=0 ); + return (inherited::can_switch_offline() && a_elapsed != 0); } //////////////////////////////////////////////////////////////////////////// @@ -875,445 +851,441 @@ bool CSE_ALifeItemAmmo::can_switch_offline () const //////////////////////////////////////////////////////////////////////////// CSE_ALifeItemDetector::CSE_ALifeItemDetector(LPCSTR caSection) : CSE_ALifeItem(caSection) { - m_ef_detector_type = pSettings->r_u32(caSection,"ef_detector_type"); + m_ef_detector_type = pSettings->r_u32(caSection, "ef_detector_type"); } CSE_ALifeItemDetector::~CSE_ALifeItemDetector() { } -u32 CSE_ALifeItemDetector::ef_detector_type () const +u32 CSE_ALifeItemDetector::ef_detector_type() const { - return (m_ef_detector_type); + return (m_ef_detector_type); } -void CSE_ALifeItemDetector::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemDetector::STATE_Read(NET_Packet& tNetPacket, u16 size) { - if (m_wVersion > 20) - inherited::STATE_Read (tNetPacket,size); + if (m_wVersion > 20) inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeItemDetector::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemDetector::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeItemDetector::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemDetector::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeItemDetector::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemDetector::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemDetector::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeItemDetector::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); + inherited::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemDetector //////////////////////////////////////////////////////////////////////////// CSE_ALifeItemArtefact::CSE_ALifeItemArtefact(LPCSTR caSection) : CSE_ALifeItem(caSection) { - m_fAnomalyValue = 100.f; + m_fAnomalyValue = 100.f; } CSE_ALifeItemArtefact::~CSE_ALifeItemArtefact() { } -void CSE_ALifeItemArtefact::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemArtefact::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeItemArtefact::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemArtefact::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeItemArtefact::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemArtefact::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeItemArtefact::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemArtefact::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemArtefact::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeItemArtefact::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); - PHelper().CreateFloat (items, PrepareKey(pref, *s_name, "Anomaly value:"), &m_fAnomalyValue, 0.f, 200.f); + inherited::FillProps(pref, items); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Anomaly value:"), &m_fAnomalyValue, 0.f, 200.f); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -BOOL CSE_ALifeItemArtefact::Net_Relevant () +BOOL CSE_ALifeItemArtefact::Net_Relevant() { - if (base()->ID_Parent == u16(-1)) - return TRUE; + if (base()->ID_Parent == u16(-1)) return TRUE; - return FALSE; + return FALSE; } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemPDA //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemPDA::CSE_ALifeItemPDA (LPCSTR caSection) : CSE_ALifeItem(caSection) +CSE_ALifeItemPDA::CSE_ALifeItemPDA(LPCSTR caSection) : CSE_ALifeItem(caSection) { - m_original_owner = 0xffff; - m_specific_character = NULL; - m_info_portion = NULL; + m_original_owner = 0xffff; + m_specific_character = NULL; + m_info_portion = NULL; } - -CSE_ALifeItemPDA::~CSE_ALifeItemPDA () +CSE_ALifeItemPDA::~CSE_ALifeItemPDA() { } -void CSE_ALifeItemPDA::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemPDA::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); - if (m_wVersion > 58) - tNetPacket.r_u16 (m_original_owner); + inherited::STATE_Read(tNetPacket, size); + if (m_wVersion > 58) tNetPacket.r_u16(m_original_owner); - if (m_wVersion > 89) + if (m_wVersion > 89) - if ( (m_wVersion > 89)&&(m_wVersion < 98) ) - { - int tmp,tmp2; - tNetPacket.r (&tmp, sizeof(int)); - tNetPacket.r (&tmp2, sizeof(int)); - m_info_portion = NULL; - m_specific_character = NULL; - }else{ - tNetPacket.r_stringZ (m_specific_character); - tNetPacket.r_stringZ (m_info_portion); - - } + if ((m_wVersion > 89) && (m_wVersion < 98)) { + int tmp, tmp2; + tNetPacket.r(&tmp, sizeof(int)); + tNetPacket.r(&tmp2, sizeof(int)); + m_info_portion = NULL; + m_specific_character = NULL; + } + else + { + tNetPacket.r_stringZ(m_specific_character); + tNetPacket.r_stringZ(m_info_portion); + } } -void CSE_ALifeItemPDA::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemPDA::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_u16 (m_original_owner); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_u16(m_original_owner); #ifdef XRGAME_EXPORTS - tNetPacket.w_stringZ (m_specific_character); - tNetPacket.w_stringZ (m_info_portion); + tNetPacket.w_stringZ(m_specific_character); + tNetPacket.w_stringZ(m_info_portion); #else - shared_str tmp_1 = NULL; - shared_str tmp_2 = NULL; + shared_str tmp_1 = NULL; + shared_str tmp_2 = NULL; - tNetPacket.w_stringZ (tmp_1); - tNetPacket.w_stringZ (tmp_2); + tNetPacket.w_stringZ(tmp_1); + tNetPacket.w_stringZ(tmp_2); #endif - } -void CSE_ALifeItemPDA::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemPDA::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeItemPDA::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemPDA::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemPDA::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeItemPDA::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); + inherited::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemDocument //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemDocument::CSE_ALifeItemDocument(LPCSTR caSection): CSE_ALifeItem(caSection) +CSE_ALifeItemDocument::CSE_ALifeItemDocument(LPCSTR caSection) : CSE_ALifeItem(caSection) { - m_wDoc = NULL; + m_wDoc = NULL; } CSE_ALifeItemDocument::~CSE_ALifeItemDocument() { } -void CSE_ALifeItemDocument::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemDocument::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); - if ( m_wVersion < 98 ){ - u16 tmp; - tNetPacket.r_u16 (tmp); - m_wDoc = NULL; - }else - tNetPacket.r_stringZ (m_wDoc); + if (m_wVersion < 98) { + u16 tmp; + tNetPacket.r_u16(tmp); + m_wDoc = NULL; + } + else + tNetPacket.r_stringZ(m_wDoc); } -void CSE_ALifeItemDocument::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemDocument::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_stringZ (m_wDoc); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_stringZ(m_wDoc); } -void CSE_ALifeItemDocument::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemDocument::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeItemDocument::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemDocument::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemDocument::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeItemDocument::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); -// PHelper().CreateU16 (items, PrepareKey(pref, *s_name, "Document index :"), &m_wDocIndex, 0, 65535); - PHelper().CreateRText (items, PrepareKey(pref, *s_name, "Info portion :"), &m_wDoc); + inherited::FillProps(pref, items); + // PHelper().CreateU16 (items, PrepareKey(pref, *s_name, "Document index :"), &m_wDocIndex, 0, 65535); + PHelper().CreateRText(items, PrepareKey(pref, *s_name, "Info portion :"), &m_wDoc); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemGrenade //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemGrenade::CSE_ALifeItemGrenade (LPCSTR caSection): CSE_ALifeItem(caSection) +CSE_ALifeItemGrenade::CSE_ALifeItemGrenade(LPCSTR caSection) : CSE_ALifeItem(caSection) { - m_ef_weapon_type = READ_IF_EXISTS(pSettings,r_u32,caSection,"ef_weapon_type",u32(-1)); + m_ef_weapon_type = READ_IF_EXISTS(pSettings, r_u32, caSection, "ef_weapon_type", u32(-1)); } -CSE_ALifeItemGrenade::~CSE_ALifeItemGrenade () +CSE_ALifeItemGrenade::~CSE_ALifeItemGrenade() { } -u32 CSE_ALifeItemGrenade::ef_weapon_type() const +u32 CSE_ALifeItemGrenade::ef_weapon_type() const { - VERIFY (m_ef_weapon_type != u32(-1)); - return (m_ef_weapon_type); + VERIFY(m_ef_weapon_type != u32(-1)); + return (m_ef_weapon_type); } -void CSE_ALifeItemGrenade::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemGrenade::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeItemGrenade::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemGrenade::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeItemGrenade::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemGrenade::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeItemGrenade::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemGrenade::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemGrenade::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeItemGrenade::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); + inherited::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemExplosive //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemExplosive::CSE_ALifeItemExplosive (LPCSTR caSection): CSE_ALifeItem(caSection) +CSE_ALifeItemExplosive::CSE_ALifeItemExplosive(LPCSTR caSection) : CSE_ALifeItem(caSection) { } -CSE_ALifeItemExplosive::~CSE_ALifeItemExplosive () +CSE_ALifeItemExplosive::~CSE_ALifeItemExplosive() { } -void CSE_ALifeItemExplosive::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemExplosive::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeItemExplosive::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemExplosive::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeItemExplosive::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemExplosive::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeItemExplosive::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemExplosive::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemExplosive::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeItemExplosive::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); + inherited::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemBolt //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemBolt::CSE_ALifeItemBolt (LPCSTR caSection) : CSE_ALifeItem(caSection) +CSE_ALifeItemBolt::CSE_ALifeItemBolt(LPCSTR caSection) : CSE_ALifeItem(caSection) { - m_flags.set (flUseSwitches,FALSE); - m_flags.set (flSwitchOffline,FALSE); - m_ef_weapon_type = READ_IF_EXISTS(pSettings,r_u32,caSection,"ef_weapon_type",u32(-1)); + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); + m_ef_weapon_type = READ_IF_EXISTS(pSettings, r_u32, caSection, "ef_weapon_type", u32(-1)); } -CSE_ALifeItemBolt::~CSE_ALifeItemBolt () +CSE_ALifeItemBolt::~CSE_ALifeItemBolt() { } -u32 CSE_ALifeItemBolt::ef_weapon_type() const +u32 CSE_ALifeItemBolt::ef_weapon_type() const { - VERIFY (m_ef_weapon_type != u32(-1)); - return (m_ef_weapon_type); + VERIFY(m_ef_weapon_type != u32(-1)); + return (m_ef_weapon_type); } -void CSE_ALifeItemBolt::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemBolt::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeItemBolt::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemBolt::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket, size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeItemBolt::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemBolt::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); }; -void CSE_ALifeItemBolt::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemBolt::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); }; -bool CSE_ALifeItemBolt::can_save () const +bool CSE_ALifeItemBolt::can_save() const { - return (false);//!attached()); + return (false); //! attached()); } -bool CSE_ALifeItemBolt::used_ai_locations () const +bool CSE_ALifeItemBolt::used_ai_locations() const { - return false; + return false; } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemBolt::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeItemBolt::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref, values); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemCustomOutfit //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemCustomOutfit::CSE_ALifeItemCustomOutfit (LPCSTR caSection): CSE_ALifeItem(caSection) +CSE_ALifeItemCustomOutfit::CSE_ALifeItemCustomOutfit(LPCSTR caSection) : CSE_ALifeItem(caSection) { - m_ef_equipment_type = pSettings->r_u32(caSection,"ef_equipment_type"); + m_ef_equipment_type = pSettings->r_u32(caSection, "ef_equipment_type"); } -CSE_ALifeItemCustomOutfit::~CSE_ALifeItemCustomOutfit () +CSE_ALifeItemCustomOutfit::~CSE_ALifeItemCustomOutfit() { } -u32 CSE_ALifeItemCustomOutfit::ef_equipment_type () const +u32 CSE_ALifeItemCustomOutfit::ef_equipment_type() const { - return (m_ef_equipment_type); + return (m_ef_equipment_type); } -void CSE_ALifeItemCustomOutfit::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemCustomOutfit::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeItemCustomOutfit::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemCustomOutfit::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeItemCustomOutfit::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemCustomOutfit::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); - tNetPacket.r_float_q8 (m_fCondition,0.0f,1.0f); + inherited::UPDATE_Read(tNetPacket); + tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f); } -void CSE_ALifeItemCustomOutfit::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemCustomOutfit::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); - tNetPacket.w_float_q8 (m_fCondition,0.0f,1.0f); + inherited::UPDATE_Write(tNetPacket); + tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemCustomOutfit::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeItemCustomOutfit::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); + inherited::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -BOOL CSE_ALifeItemCustomOutfit::Net_Relevant () +BOOL CSE_ALifeItemCustomOutfit::Net_Relevant() { - return (true); + return (true); } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeItemHelmet //////////////////////////////////////////////////////////////////////////// -CSE_ALifeItemHelmet::CSE_ALifeItemHelmet (LPCSTR caSection): CSE_ALifeItem(caSection) +CSE_ALifeItemHelmet::CSE_ALifeItemHelmet(LPCSTR caSection) : CSE_ALifeItem(caSection) { } -CSE_ALifeItemHelmet::~CSE_ALifeItemHelmet () +CSE_ALifeItemHelmet::~CSE_ALifeItemHelmet() { } -void CSE_ALifeItemHelmet::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeItemHelmet::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeItemHelmet::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemHelmet::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeItemHelmet::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeItemHelmet::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); - tNetPacket.r_float_q8 (m_fCondition,0.0f,1.0f); + inherited::UPDATE_Read(tNetPacket); + tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f); } -void CSE_ALifeItemHelmet::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeItemHelmet::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); - tNetPacket.w_float_q8 (m_fCondition,0.0f,1.0f); + inherited::UPDATE_Write(tNetPacket); + tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f); } #ifndef XRGAME_EXPORTS -void CSE_ALifeItemHelmet::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeItemHelmet::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); + inherited::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -BOOL CSE_ALifeItemHelmet::Net_Relevant () +BOOL CSE_ALifeItemHelmet::Net_Relevant() { - return (true); + return (true); } \ No newline at end of file diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items.h b/src/xrServerEntities/xrServer_Objects_ALife_Items.h index 50c4cf112fe..f7870ba9e6d 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items.h +++ b/src/xrServerEntities/xrServer_Objects_ALife_Items.h @@ -9,82 +9,82 @@ #ifndef xrServer_Objects_ALife_ItemsH #define xrServer_Objects_ALife_ItemsH -#include "xrServer_Objects_ALife.h" #include "PHSynchronize.h" #include "inventory_space.h" +#include "xrServer_Objects_ALife.h" #include "character_info_defs.h" #include "infoportiondefs.h" #pragma warning(push) -#pragma warning(disable:4005) +#pragma warning(disable : 4005) class CSE_ALifeItemAmmo; class CSE_ALifeInventoryItem { public: - enum { - inventory_item_state_enabled = u8(1) << 0, - inventory_item_angular_null = u8(1) << 1, - inventory_item_linear_null = u8(1) << 2, - }; - - union mask_num_items { - struct { - u8 num_items : 5; - u8 mask : 3; - }; - u8 common; - }; + enum + { + inventory_item_state_enabled = u8(1) << 0, + inventory_item_angular_null = u8(1) << 1, + inventory_item_linear_null = u8(1) << 2, + }; + + union mask_num_items + { + struct + { + u8 num_items : 5; + u8 mask : 3; + }; + u8 common; + }; public: - float m_fCondition; - float m_fMass; - u32 m_dwCost; - s32 m_iHealthValue; - s32 m_iFoodValue; - float m_fDeteriorationValue; - CSE_ALifeObject *m_self; - u32 m_last_update_time; - xr_vector m_upgrades; + float m_fCondition; + float m_fMass; + u32 m_dwCost; + s32 m_iHealthValue; + s32 m_iFoodValue; + float m_fDeteriorationValue; + CSE_ALifeObject* m_self; + u32 m_last_update_time; + xr_vector m_upgrades; public: - CSE_ALifeInventoryItem (LPCSTR caSection); - virtual ~CSE_ALifeInventoryItem (); - // we need this to prevent virtual inheritance :-( - virtual CSE_Abstract *base () = 0; - virtual const CSE_Abstract *base () const = 0; - virtual CSE_Abstract *init (); - virtual CSE_Abstract *cast_abstract () {return 0;}; - virtual CSE_ALifeInventoryItem *cast_inventory_item () {return this;}; - virtual u32 update_rate () const; - virtual BOOL Net_Relevant (); - - bool has_upgrade (const shared_str& upgrade_id); - void add_upgrade (const shared_str& upgrade_id); + CSE_ALifeInventoryItem(LPCSTR caSection); + virtual ~CSE_ALifeInventoryItem(); + // we need this to prevent virtual inheritance :-( + virtual CSE_Abstract* base() = 0; + virtual const CSE_Abstract* base() const = 0; + virtual CSE_Abstract* init(); + virtual CSE_Abstract* cast_abstract() { return 0; }; + virtual CSE_ALifeInventoryItem* cast_inventory_item() { return this; }; + virtual u32 update_rate() const; + virtual BOOL Net_Relevant(); + + bool has_upgrade(const shared_str& upgrade_id); + void add_upgrade(const shared_str& upgrade_id); private: - bool prev_freezed; - bool freezed; - u32 m_freeze_time; - static const u32 m_freeze_delta_time; - static const u32 random_limit; - CRandom m_relevent_random; + bool prev_freezed; + bool freezed; + u32 m_freeze_time; + static const u32 m_freeze_delta_time; + static const u32 random_limit; + CRandom m_relevent_random; public: - // end of the virtual inheritance dependant code - - IC bool attached () const - { - return (base()->ID_Parent < 0xffff); - } - virtual bool bfUseful(); - - /////////// network /////////////// - u8 m_u8NumItems; - SPHNetState State; - /////////////////////////////////// + // end of the virtual inheritance dependant code + + IC bool attached() const { return (base()->ID_Parent < 0xffff); } + virtual bool bfUseful(); + + /////////// network /////////////// + u8 m_u8NumItems; + SPHNetState State; + /////////////////////////////////// virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -92,24 +92,23 @@ class CSE_ALifeInventoryItem SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeItem : - public CSE_ALifeDynamicObjectVisual, - public CSE_ALifeInventoryItem +class CSE_ALifeItem : public CSE_ALifeDynamicObjectVisual, public CSE_ALifeInventoryItem { using inherited1 = CSE_ALifeDynamicObjectVisual; using inherited2 = CSE_ALifeInventoryItem; + public: - bool m_physics_disabled; - - CSE_ALifeItem (LPCSTR caSection); - virtual ~CSE_ALifeItem (); - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual CSE_Abstract *init (); - virtual CSE_Abstract *cast_abstract () {return this;}; - virtual CSE_ALifeInventoryItem *cast_inventory_item () {return this;}; - virtual BOOL Net_Relevant (); - virtual void OnEvent (NET_Packet &tNetPacket, u16 type, u32 time, ClientID sender ); + bool m_physics_disabled; + + CSE_ALifeItem(LPCSTR caSection); + virtual ~CSE_ALifeItem(); + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual CSE_Abstract* init(); + virtual CSE_Abstract* cast_abstract() { return this; }; + virtual CSE_ALifeInventoryItem* cast_inventory_item() { return this; }; + virtual BOOL Net_Relevant(); + virtual void OnEvent(NET_Packet& tNetPacket, u16 type, u32 time, ClientID sender); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -120,18 +119,20 @@ class CSE_ALifeItem : class CSE_ALifeItemTorch : public CSE_ALifeItem { typedef CSE_ALifeItem inherited; + public: - enum EStats{ - eTorchActive = (1<<0), - eNightVisionActive = (1<<1), - eAttached = (1<<2) - }; - bool m_active; - bool m_nightvision_active; - bool m_attached; - CSE_ALifeItemTorch (LPCSTR caSection); - virtual ~CSE_ALifeItemTorch (); - virtual BOOL Net_Relevant (); + enum EStats + { + eTorchActive = (1 << 0), + eNightVisionActive = (1 << 1), + eAttached = (1 << 2) + }; + bool m_active; + bool m_nightvision_active; + bool m_attached; + CSE_ALifeItemTorch(LPCSTR caSection); + virtual ~CSE_ALifeItemTorch(); + virtual BOOL Net_Relevant(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -142,15 +143,16 @@ class CSE_ALifeItemTorch : public CSE_ALifeItem class CSE_ALifeItemAmmo : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - u16 a_elapsed; - u16 m_boxSize; - - CSE_ALifeItemAmmo (LPCSTR caSection); - virtual ~CSE_ALifeItemAmmo (); - virtual CSE_ALifeItemAmmo *cast_item_ammo () {return this;}; - virtual bool can_switch_online () const; - virtual bool can_switch_offline () const; + u16 a_elapsed; + u16 m_boxSize; + + CSE_ALifeItemAmmo(LPCSTR caSection); + virtual ~CSE_ALifeItemAmmo(); + virtual CSE_ALifeItemAmmo* cast_item_ammo() { return this; }; + virtual bool can_switch_online() const; + virtual bool can_switch_offline() const; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -161,69 +163,67 @@ class CSE_ALifeItemAmmo : public CSE_ALifeItem class CSE_ALifeItemWeapon : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - typedef ALife::EWeaponAddonStatus EWeaponAddonStatus; - - //òåêóùåå ñîñòîÿíèå àääîíîâ - enum EWeaponAddonState - { - eWeaponAddonScope = 0x01, - eWeaponAddonGrenadeLauncher = 0x02, - eWeaponAddonSilencer = 0x04 - }; - - EWeaponAddonStatus m_scope_status; - EWeaponAddonStatus m_silencer_status; - EWeaponAddonStatus m_grenade_launcher_status; - - u32 timestamp; - u8 wpn_flags; - u8 wpn_state; - u8 ammo_type; - u16 a_current; - u16 a_elapsed; - //count of grenades to spawn in grenade launcher [ttcccccc] - //WARNING! hight 2 bits (tt bits) indicate type of grenade, so maximum grenade count is 2^6 = 64 - struct grenade_count_t - { - u8 grenades_count : 6; - u8 grenades_type : 2; - u8 pack_to_byte() const - { - return (grenades_type << 6) | grenades_count; - } - void unpack_from_byte(u8 const b) - { - grenades_type = (b >> 6); - grenades_count = b & 0x3f; //111111 - } - }; //struct grenade_count_t - grenade_count_t a_elapsed_grenades; - - float m_fHitPower; - ALife::EHitType m_tHitType; - LPCSTR m_caAmmoSections; - u32 m_dwAmmoAvailable; - Flags8 m_addon_flags; - u8 m_bZoom; - u32 m_ef_main_weapon_type; - u32 m_ef_weapon_type; - - CSE_ALifeItemWeapon (LPCSTR caSection); - virtual ~CSE_ALifeItemWeapon(); - virtual void OnEvent (NET_Packet& P, u16 type, u32 time, ClientID sender ); - virtual u32 ef_main_weapon_type () const; - virtual u32 ef_weapon_type () const; - u8 get_slot (); - u16 get_ammo_limit (); - u16 get_ammo_total (); - u16 get_ammo_elapsed (); - u16 get_ammo_magsize (); - void clone_addons (CSE_ALifeItemWeapon* parent); - - virtual BOOL Net_Relevant (); - - virtual CSE_ALifeItemWeapon *cast_item_weapon () {return this;} + typedef ALife::EWeaponAddonStatus EWeaponAddonStatus; + + //òåêóùåå ñîñòîÿíèå àääîíîâ + enum EWeaponAddonState + { + eWeaponAddonScope = 0x01, + eWeaponAddonGrenadeLauncher = 0x02, + eWeaponAddonSilencer = 0x04 + }; + + EWeaponAddonStatus m_scope_status; + EWeaponAddonStatus m_silencer_status; + EWeaponAddonStatus m_grenade_launcher_status; + + u32 timestamp; + u8 wpn_flags; + u8 wpn_state; + u8 ammo_type; + u16 a_current; + u16 a_elapsed; + // count of grenades to spawn in grenade launcher [ttcccccc] + // WARNING! hight 2 bits (tt bits) indicate type of grenade, so maximum grenade count is 2^6 = 64 + struct grenade_count_t + { + u8 grenades_count : 6; + u8 grenades_type : 2; + u8 pack_to_byte() const { return (grenades_type << 6) | grenades_count; } + void unpack_from_byte(u8 const b) + { + grenades_type = (b >> 6); + grenades_count = b & 0x3f; // 111111 + } + }; // struct grenade_count_t + grenade_count_t a_elapsed_grenades; + + float m_fHitPower; + ALife::EHitType m_tHitType; + LPCSTR m_caAmmoSections; + u32 m_dwAmmoAvailable; + Flags8 m_addon_flags; + u8 m_bZoom; + u32 m_ef_main_weapon_type; + u32 m_ef_weapon_type; + + CSE_ALifeItemWeapon(LPCSTR caSection); + virtual ~CSE_ALifeItemWeapon(); + virtual void OnEvent(NET_Packet& P, u16 type, u32 time, ClientID sender); + virtual u32 ef_main_weapon_type() const; + virtual u32 ef_weapon_type() const; + u8 get_slot(); + u16 get_ammo_limit(); + u16 get_ammo_total(); + u16 get_ammo_elapsed(); + u16 get_ammo_magsize(); + void clone_addons(CSE_ALifeItemWeapon* parent); + + virtual BOOL Net_Relevant(); + + virtual CSE_ALifeItemWeapon* cast_item_weapon() { return this; } virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -234,75 +234,80 @@ class CSE_ALifeItemWeapon : public CSE_ALifeItem class CSE_ALifeItemWeaponMagazined : public CSE_ALifeItemWeapon { typedef CSE_ALifeItemWeapon inherited; + public: -u8 m_u8CurFireMode; -CSE_ALifeItemWeaponMagazined(LPCSTR caSection); -virtual ~CSE_ALifeItemWeaponMagazined(); - -virtual CSE_ALifeItemWeapon *cast_item_weapon () {return this;} -virtual void UPDATE_Read(NET_Packet& P); -virtual void UPDATE_Write(NET_Packet& P); -virtual void STATE_Read(NET_Packet& P, u16 size); -virtual void STATE_Write(NET_Packet& P); -SERVER_ENTITY_EDITOR_METHODS + u8 m_u8CurFireMode; + CSE_ALifeItemWeaponMagazined(LPCSTR caSection); + virtual ~CSE_ALifeItemWeaponMagazined(); + + virtual CSE_ALifeItemWeapon* cast_item_weapon() { return this; } + virtual void UPDATE_Read(NET_Packet& P); + virtual void UPDATE_Write(NET_Packet& P); + virtual void STATE_Read(NET_Packet& P, u16 size); + virtual void STATE_Write(NET_Packet& P); + SERVER_ENTITY_EDITOR_METHODS }; class CSE_ALifeItemWeaponMagazinedWGL : public CSE_ALifeItemWeaponMagazined { using inherited = CSE_ALifeItemWeaponMagazined; + public: -bool m_bGrenadeMode; -CSE_ALifeItemWeaponMagazinedWGL(LPCSTR caSection); -virtual ~CSE_ALifeItemWeaponMagazinedWGL(); - -virtual CSE_ALifeItemWeapon *cast_item_weapon () {return this;} -virtual void UPDATE_Read(NET_Packet& P); -virtual void UPDATE_Write(NET_Packet& P); -virtual void STATE_Read(NET_Packet& P, u16 size); -virtual void STATE_Write(NET_Packet& P); -SERVER_ENTITY_EDITOR_METHODS + bool m_bGrenadeMode; + CSE_ALifeItemWeaponMagazinedWGL(LPCSTR caSection); + virtual ~CSE_ALifeItemWeaponMagazinedWGL(); + + virtual CSE_ALifeItemWeapon* cast_item_weapon() { return this; } + virtual void UPDATE_Read(NET_Packet& P); + virtual void UPDATE_Write(NET_Packet& P); + virtual void STATE_Read(NET_Packet& P, u16 size); + virtual void STATE_Write(NET_Packet& P); + SERVER_ENTITY_EDITOR_METHODS }; class CSE_ALifeItemWeaponShotGun : public CSE_ALifeItemWeaponMagazined { using inherited = CSE_ALifeItemWeaponMagazined; + public: - xr_vector m_AmmoIDs; - CSE_ALifeItemWeaponShotGun(LPCSTR caSection); -virtual ~CSE_ALifeItemWeaponShotGun(); - -virtual CSE_ALifeItemWeapon *cast_item_weapon () {return this;} -virtual void UPDATE_Read(NET_Packet& P); -virtual void UPDATE_Write(NET_Packet& P); -virtual void STATE_Read(NET_Packet& P, u16 size); -virtual void STATE_Write(NET_Packet& P); -SERVER_ENTITY_EDITOR_METHODS + xr_vector m_AmmoIDs; + CSE_ALifeItemWeaponShotGun(LPCSTR caSection); + virtual ~CSE_ALifeItemWeaponShotGun(); + + virtual CSE_ALifeItemWeapon* cast_item_weapon() { return this; } + virtual void UPDATE_Read(NET_Packet& P); + virtual void UPDATE_Write(NET_Packet& P); + virtual void STATE_Read(NET_Packet& P, u16 size); + virtual void STATE_Write(NET_Packet& P); + SERVER_ENTITY_EDITOR_METHODS }; class CSE_ALifeItemWeaponAutoShotGun : public CSE_ALifeItemWeaponShotGun { using inherited = CSE_ALifeItemWeaponShotGun; + public: - CSE_ALifeItemWeaponAutoShotGun(LPCSTR caSection); -virtual ~CSE_ALifeItemWeaponAutoShotGun(); - -virtual CSE_ALifeItemWeapon *cast_item_weapon () {return this;} -virtual void UPDATE_Read(NET_Packet& P); -virtual void UPDATE_Write(NET_Packet& P); -virtual void STATE_Read(NET_Packet& P, u16 size); -virtual void STATE_Write(NET_Packet& P); -SERVER_ENTITY_EDITOR_METHODS + CSE_ALifeItemWeaponAutoShotGun(LPCSTR caSection); + virtual ~CSE_ALifeItemWeaponAutoShotGun(); + + virtual CSE_ALifeItemWeapon* cast_item_weapon() { return this; } + virtual void UPDATE_Read(NET_Packet& P); + virtual void UPDATE_Write(NET_Packet& P); + virtual void STATE_Read(NET_Packet& P, u16 size); + virtual void STATE_Write(NET_Packet& P); + SERVER_ENTITY_EDITOR_METHODS }; class CSE_ALifeItemDetector : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - u32 m_ef_detector_type; - CSE_ALifeItemDetector(LPCSTR caSection); - virtual ~CSE_ALifeItemDetector(); - virtual u32 ef_detector_type() const; - virtual CSE_ALifeItemDetector *cast_item_detector () {return this;} + u32 m_ef_detector_type; + CSE_ALifeItemDetector(LPCSTR caSection); + virtual ~CSE_ALifeItemDetector(); + virtual u32 ef_detector_type() const; + virtual CSE_ALifeItemDetector* cast_item_detector() { return this; } virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -313,11 +318,12 @@ class CSE_ALifeItemDetector : public CSE_ALifeItem class CSE_ALifeItemArtefact : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - float m_fAnomalyValue; - CSE_ALifeItemArtefact (LPCSTR caSection); - virtual ~CSE_ALifeItemArtefact (); - virtual BOOL Net_Relevant (); + float m_fAnomalyValue; + CSE_ALifeItemArtefact(LPCSTR caSection); + virtual ~CSE_ALifeItemArtefact(); + virtual BOOL Net_Relevant(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -328,14 +334,15 @@ class CSE_ALifeItemArtefact : public CSE_ALifeItem class CSE_ALifeItemPDA : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - u16 m_original_owner; - shared_str m_specific_character; - shared_str m_info_portion; + u16 m_original_owner; + shared_str m_specific_character; + shared_str m_info_portion; - CSE_ALifeItemPDA(LPCSTR caSection); - virtual ~CSE_ALifeItemPDA(); - virtual CSE_ALifeItemPDA *cast_item_pda () {return this;}; + CSE_ALifeItemPDA(LPCSTR caSection); + virtual ~CSE_ALifeItemPDA(); + virtual CSE_ALifeItemPDA* cast_item_pda() { return this; }; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -346,10 +353,11 @@ class CSE_ALifeItemPDA : public CSE_ALifeItem class CSE_ALifeItemDocument : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - shared_str m_wDoc; - CSE_ALifeItemDocument(LPCSTR caSection); - virtual ~CSE_ALifeItemDocument(); + shared_str m_wDoc; + CSE_ALifeItemDocument(LPCSTR caSection); + virtual ~CSE_ALifeItemDocument(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -360,11 +368,12 @@ class CSE_ALifeItemDocument : public CSE_ALifeItem class CSE_ALifeItemGrenade : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - u32 m_ef_weapon_type; - CSE_ALifeItemGrenade (LPCSTR caSection); - virtual ~CSE_ALifeItemGrenade (); - virtual u32 ef_weapon_type () const; + u32 m_ef_weapon_type; + CSE_ALifeItemGrenade(LPCSTR caSection); + virtual ~CSE_ALifeItemGrenade(); + virtual u32 ef_weapon_type() const; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -375,9 +384,10 @@ class CSE_ALifeItemGrenade : public CSE_ALifeItem class CSE_ALifeItemExplosive : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - CSE_ALifeItemExplosive(LPCSTR caSection); - virtual ~CSE_ALifeItemExplosive(); + CSE_ALifeItemExplosive(LPCSTR caSection); + virtual ~CSE_ALifeItemExplosive(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -388,13 +398,14 @@ class CSE_ALifeItemExplosive : public CSE_ALifeItem class CSE_ALifeItemBolt : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - u32 m_ef_weapon_type; - CSE_ALifeItemBolt (LPCSTR caSection); - virtual ~CSE_ALifeItemBolt (); - virtual bool can_save () const; - virtual bool used_ai_locations () const; - virtual u32 ef_weapon_type () const; + u32 m_ef_weapon_type; + CSE_ALifeItemBolt(LPCSTR caSection); + virtual ~CSE_ALifeItemBolt(); + virtual bool can_save() const; + virtual bool used_ai_locations() const; + virtual u32 ef_weapon_type() const; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -405,12 +416,13 @@ class CSE_ALifeItemBolt : public CSE_ALifeItem class CSE_ALifeItemCustomOutfit : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - u32 m_ef_equipment_type; - CSE_ALifeItemCustomOutfit (LPCSTR caSection); - virtual ~CSE_ALifeItemCustomOutfit (); - virtual u32 ef_equipment_type () const; - virtual BOOL Net_Relevant (); + u32 m_ef_equipment_type; + CSE_ALifeItemCustomOutfit(LPCSTR caSection); + virtual ~CSE_ALifeItemCustomOutfit(); + virtual u32 ef_equipment_type() const; + virtual BOOL Net_Relevant(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -421,10 +433,11 @@ class CSE_ALifeItemCustomOutfit : public CSE_ALifeItem class CSE_ALifeItemHelmet : public CSE_ALifeItem { using inherited = CSE_ALifeItem; + public: - CSE_ALifeItemHelmet (LPCSTR caSection); - virtual ~CSE_ALifeItemHelmet (); - virtual BOOL Net_Relevant (); + CSE_ALifeItemHelmet(LPCSTR caSection); + virtual ~CSE_ALifeItemHelmet(); + virtual BOOL Net_Relevant(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items_script.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Items_script.cpp index 2a784a03238..1e2402087a6 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Items_script.cpp @@ -7,117 +7,47 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife_Items.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -SCRIPT_EXPORT(CSE_ALifeInventoryItem, (), -{ - module(luaState) - [ - class_ - ("cse_alife_inventory_item") -// .def( constructor()) +SCRIPT_EXPORT(CSE_ALifeInventoryItem, (), { + module(luaState)[class_("cse_alife_inventory_item") + // .def( constructor()) ]; }); -SCRIPT_EXPORT(CSE_ALifeItem, (CSE_ALifeDynamicObjectVisual, CSE_ALifeInventoryItem), -{ - module(luaState) - [ - luabind_class_item2( -// luabind_class_abstract2( - CSE_ALifeItem, - "cse_alife_item", - CSE_ALifeDynamicObjectVisual, - CSE_ALifeInventoryItem - ) - ]; +SCRIPT_EXPORT(CSE_ALifeItem, (CSE_ALifeDynamicObjectVisual, CSE_ALifeInventoryItem), { + module(luaState)[luabind_class_item2( + // luabind_class_abstract2( + CSE_ALifeItem, "cse_alife_item", CSE_ALifeDynamicObjectVisual, CSE_ALifeInventoryItem)]; }); SCRIPT_EXPORT(CSE_ALifeItemTorch, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemTorch, - "cse_alife_item_torch", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemTorch, "cse_alife_item_torch", CSE_ALifeItem)]; }); SCRIPT_EXPORT(CSE_ALifeItemAmmo, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemAmmo, - "cse_alife_item_ammo", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemAmmo, "cse_alife_item_ammo", CSE_ALifeItem)]; }); -SCRIPT_EXPORT(CSE_ALifeItemWeapon, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemWeapon, - "cse_alife_item_weapon", - CSE_ALifeItem - ) - .def("clone_addons", &CSE_ALifeItemWeapon::clone_addons) - ]; +SCRIPT_EXPORT(CSE_ALifeItemWeapon, (CSE_ALifeItem), { + module(luaState)[luabind_class_item1(CSE_ALifeItemWeapon, "cse_alife_item_weapon", + CSE_ALifeItem).def("clone_addons", &CSE_ALifeItemWeapon::clone_addons)]; }); -SCRIPT_EXPORT(CSE_ALifeItemWeaponShotGun, (CSE_ALifeItemWeapon), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemWeaponShotGun, - "cse_alife_item_weapon_shotgun", - CSE_ALifeItemWeapon - ) - ]; +SCRIPT_EXPORT(CSE_ALifeItemWeaponShotGun, (CSE_ALifeItemWeapon), { + module(luaState)[luabind_class_item1( + CSE_ALifeItemWeaponShotGun, "cse_alife_item_weapon_shotgun", CSE_ALifeItemWeapon)]; }); -SCRIPT_EXPORT(CSE_ALifeItemWeaponAutoShotGun, (CSE_ALifeItemWeapon), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemWeaponAutoShotGun, - "cse_alife_item_weapon_auto_shotgun", - CSE_ALifeItemWeapon - ) - ]; +SCRIPT_EXPORT(CSE_ALifeItemWeaponAutoShotGun, (CSE_ALifeItemWeapon), { + module(luaState)[luabind_class_item1( + CSE_ALifeItemWeaponAutoShotGun, "cse_alife_item_weapon_auto_shotgun", CSE_ALifeItemWeapon)]; }); SCRIPT_EXPORT(CSE_ALifeItemDetector, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemDetector, - "cse_alife_item_detector", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemDetector, "cse_alife_item_detector", CSE_ALifeItem)]; }); SCRIPT_EXPORT(CSE_ALifeItemArtefact, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemArtefact, - "cse_alife_item_artefact", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemArtefact, "cse_alife_item_artefact", CSE_ALifeItem)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp index 85de8ba10b7..1db70aa0142 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Items_script2.cpp @@ -7,104 +7,35 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife_Items.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; SCRIPT_EXPORT(CSE_ALifeItemPDA, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemPDA, - "cse_alife_item_pda", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemPDA, "cse_alife_item_pda", CSE_ALifeItem)]; }); SCRIPT_EXPORT(CSE_ALifeItemDocument, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemDocument, - "cse_alife_item_document", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemDocument, "cse_alife_item_document", CSE_ALifeItem)]; }); SCRIPT_EXPORT(CSE_ALifeItemGrenade, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemGrenade, - "cse_alife_item_grenade", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemGrenade, "cse_alife_item_grenade", CSE_ALifeItem)]; }); SCRIPT_EXPORT(CSE_ALifeItemExplosive, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemExplosive, - "cse_alife_item_explosive", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemExplosive, "cse_alife_item_explosive", CSE_ALifeItem)]; }); SCRIPT_EXPORT(CSE_ALifeItemBolt, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemBolt, - "cse_alife_item_bolt", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemBolt, "cse_alife_item_bolt", CSE_ALifeItem)]; }); -SCRIPT_EXPORT(CSE_ALifeItemCustomOutfit, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemCustomOutfit, - "cse_alife_item_custom_outfit", - CSE_ALifeItem - ) - ]; +SCRIPT_EXPORT(CSE_ALifeItemCustomOutfit, (CSE_ALifeItem), { + module(luaState)[luabind_class_item1(CSE_ALifeItemCustomOutfit, "cse_alife_item_custom_outfit", CSE_ALifeItem)]; }); SCRIPT_EXPORT(CSE_ALifeItemHelmet, (CSE_ALifeItem), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemHelmet, - "cse_alife_item_helmet", - CSE_ALifeItem - ) - ]; -}); + { module(luaState)[luabind_class_item1(CSE_ALifeItemHelmet, "cse_alife_item_helmet", CSE_ALifeItem)]; }); -SCRIPT_EXPORT(CSE_ALifeItemWeaponMagazined, (CSE_ALifeItemWeapon), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemWeaponMagazined, - "cse_alife_item_weapon_magazined", - CSE_ALifeItemWeapon - ) - ]; +SCRIPT_EXPORT(CSE_ALifeItemWeaponMagazined, (CSE_ALifeItemWeapon), { + module(luaState)[luabind_class_item1( + CSE_ALifeItemWeaponMagazined, "cse_alife_item_weapon_magazined", CSE_ALifeItemWeapon)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Items_script3.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Items_script3.cpp index ffa809679cc..f47a680816f 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Items_script3.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Items_script3.cpp @@ -7,20 +7,13 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife_Items.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -SCRIPT_EXPORT(CSE_ALifeItemWeaponMagazinedWGL, (CSE_ALifeItemWeaponMagazined), -{ - module(luaState) - [ - luabind_class_item1( - CSE_ALifeItemWeaponMagazinedWGL, - "cse_alife_item_weapon_magazined_w_gl", - CSE_ALifeItemWeaponMagazined - ) - ]; +SCRIPT_EXPORT(CSE_ALifeItemWeaponMagazinedWGL, (CSE_ALifeItemWeaponMagazined), { + module(luaState)[luabind_class_item1( + CSE_ALifeItemWeaponMagazinedWGL, "cse_alife_item_weapon_magazined_w_gl", CSE_ALifeItemWeaponMagazined)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp index 08797031dff..d1f28ee1815 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters.cpp @@ -6,111 +6,108 @@ // Description : Server objects monsters for ALife simulator //////////////////////////////////////////////////////////////////////////// -#include "stdafx.h" -#include "xrServer_Objects_ALife_Items.h" #include "xrServer_Objects_ALife_Monsters.h" #include "Common/object_broker.h" #include "alife_human_brain.h" - - +#include "stdafx.h" +#include "xrServer_Objects_ALife_Items.h" #ifndef AI_COMPILER -# include "ai_space.h" -# include "character_info.h" -# include "specific_character.h" +#include "ai_space.h" +#include "character_info.h" +#include "specific_character.h" #endif #ifdef XRGAME_EXPORTS -# include "alife_time_manager.h" -# include "ef_storage.h" -# include "xrAICore/Navigation/game_graph.h" -# include "ai_space.h" -# include "alife_group_registry.h" -# include "alife_simulator.h" -# include "alife_registry_container.h" -# include "ef_primary.h" -# include "string_table.h" -# include "alife_online_offline_group_brain.h" -# include "alife_simulator.h" -# include "alife_object_registry.h" -# include "date_time.h" -# include "custommonster.h" -# include "movement_manager.h" -# include "location_manager.h" +#include "ai_space.h" +#include "alife_group_registry.h" +#include "alife_object_registry.h" +#include "alife_online_offline_group_brain.h" +#include "alife_registry_container.h" +#include "alife_simulator.h" +#include "alife_simulator.h" +#include "alife_time_manager.h" +#include "custommonster.h" +#include "date_time.h" +#include "ef_primary.h" +#include "ef_storage.h" +#include "location_manager.h" +#include "movement_manager.h" +#include "string_table.h" +#include "xrAICore/Navigation/game_graph.h" #endif -void setup_location_types_section(GameGraph::TERRAIN_VECTOR &m_vertex_types, CInifile const * ini, LPCSTR section) -{ - VERIFY3 (ini->section_exist(section),"cannot open section",section); - GameGraph::STerrainPlace terrain_mask; - terrain_mask.tMask.resize (GameGraph::LOCATION_TYPE_COUNT); - - CInifile::Sect& sect = ini->r_section(section); - CInifile::SectCIt I = sect.Data.begin(); - CInifile::SectCIt E = sect.Data.end(); - for ( ; I != E; ++I) { - LPCSTR S = *(*I).first; - string16 I; - u32 N = _GetItemCount(S); - - if (N != GameGraph::LOCATION_TYPE_COUNT) - continue; - - for (u32 j=0; jsection_exist(section), "cannot open section", section); + GameGraph::STerrainPlace terrain_mask; + terrain_mask.tMask.resize(GameGraph::LOCATION_TYPE_COUNT); + + CInifile::Sect& sect = ini->r_section(section); + CInifile::SectCIt I = sect.Data.begin(); + CInifile::SectCIt E = sect.Data.end(); + for (; I != E; ++I) + { + LPCSTR S = *(*I).first; + string16 I; + u32 N = _GetItemCount(S); + + if (N != GameGraph::LOCATION_TYPE_COUNT) continue; + + for (u32 j = 0; j < GameGraph::LOCATION_TYPE_COUNT; ++j) + terrain_mask.tMask[j] = GameGraph::_LOCATION_ID(atoi(_GetItem(S, j, I))); + + m_vertex_types.push_back(terrain_mask); } - - if (!m_vertex_types.empty()) - return; - for (u32 j=0; jsection_exist(string) && ini->line_count(string)) - setup_location_types_section(m_vertex_types,ini,string); - else - setup_location_types_line (m_vertex_types,string); + setup_location_types_section(m_vertex_types, ini, string); + else + setup_location_types_line(m_vertex_types, string); } ////////////////////////////////////////////////////////////////////////// //âîçìîæíîå îòêëîíåíèå îò çíà÷åíèÿ ðåïóòàöèè //çàäàíîãî â ïðîôèëå è äëÿ êîíêðåòíîãî ïåðñîíàæà -#define REPUTATION_DELTA 10 -#define RANK_DELTA 10 - +#define REPUTATION_DELTA 10 +#define RANK_DELTA 10 ////////////////////////////////////////////////////////////////////////// @@ -121,92 +118,91 @@ using namespace ALife; //////////////////////////////////////////////////////////////////////////// CSE_ALifeTraderAbstract::CSE_ALifeTraderAbstract(LPCSTR caSection) { -// m_fCumulativeItemMass = 0.f; -// m_iCumulativeItemVolume = 0; - m_dwMoney = 0; - if (pSettings->line_exist(caSection, "money")) - m_dwMoney = pSettings->r_u32(caSection, "money"); - m_fMaxItemMass = pSettings->r_float(caSection, "max_item_mass"); + // m_fCumulativeItemMass = 0.f; + // m_iCumulativeItemVolume = 0; + m_dwMoney = 0; + if (pSettings->line_exist(caSection, "money")) m_dwMoney = pSettings->r_u32(caSection, "money"); + m_fMaxItemMass = pSettings->r_float(caSection, "max_item_mass"); - m_sCharacterProfile = READ_IF_EXISTS(pSettings,r_string,caSection,"character_profile","default"); - m_SpecificCharacter = NULL; + m_sCharacterProfile = READ_IF_EXISTS(pSettings, r_string, caSection, "character_profile", "default"); + m_SpecificCharacter = NULL; #ifdef XRGAME_EXPORTS - m_community_index = NO_COMMUNITY_INDEX; - m_rank = NO_RANK; - m_reputation = NO_REPUTATION; + m_community_index = NO_COMMUNITY_INDEX; + m_rank = NO_RANK; + m_reputation = NO_REPUTATION; #endif - m_deadbody_can_take = true; - m_deadbody_closed = false; + m_deadbody_can_take = true; + m_deadbody_closed = false; - m_trader_flags.zero (); - m_trader_flags.set (eTraderFlagInfiniteAmmo,FALSE); + m_trader_flags.zero(); + m_trader_flags.set(eTraderFlagInfiniteAmmo, FALSE); } -CSE_Abstract *CSE_ALifeTraderAbstract::init () +CSE_Abstract* CSE_ALifeTraderAbstract::init() { - string4096 S; - //xr_sprintf (S,"%s\r\n[game_info]\r\nname_id = default\r\n",!*base()->m_ini_string ? "" : *base()->m_ini_string); - xr_sprintf (S,"%s\r\n[game_info]\r\n",!*base()->m_ini_string ? "" : *base()->m_ini_string); - base()->m_ini_string = S; + string4096 S; + // xr_sprintf (S,"%s\r\n[game_info]\r\nname_id = default\r\n",!*base()->m_ini_string ? "" : + // *base()->m_ini_string); + xr_sprintf(S, "%s\r\n[game_info]\r\n", !*base()->m_ini_string ? "" : *base()->m_ini_string); + base()->m_ini_string = S; - return (base()); + return (base()); } CSE_ALifeTraderAbstract::~CSE_ALifeTraderAbstract() { } -void CSE_ALifeTraderAbstract::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeTraderAbstract::STATE_Write(NET_Packet& tNetPacket) { - tNetPacket.w_u32 (m_dwMoney); + tNetPacket.w_u32(m_dwMoney); #ifdef XRGAME_EXPORTS - tNetPacket.w_stringZ (m_SpecificCharacter); + tNetPacket.w_stringZ(m_SpecificCharacter); #else shared_str s; - tNetPacket.w_stringZ (s); + tNetPacket.w_stringZ(s); #endif - tNetPacket.w_u32 (m_trader_flags.get()); -// tNetPacket.w_s32 (m_iCharacterProfile); - tNetPacket.w_stringZ (m_sCharacterProfile); + tNetPacket.w_u32(m_trader_flags.get()); + // tNetPacket.w_s32 (m_iCharacterProfile); + tNetPacket.w_stringZ(m_sCharacterProfile); #ifdef XRGAME_EXPORTS - tNetPacket.w_s32 (m_community_index); - tNetPacket.w_s32 (m_rank); - tNetPacket.w_s32 (m_reputation); + tNetPacket.w_s32(m_community_index); + tNetPacket.w_s32(m_rank); + tNetPacket.w_s32(m_reputation); #else - tNetPacket.w_s32 (NO_COMMUNITY_INDEX); - tNetPacket.w_s32 (NO_RANK); - tNetPacket.w_s32 (NO_REPUTATION); + tNetPacket.w_s32(NO_COMMUNITY_INDEX); + tNetPacket.w_s32(NO_RANK); + tNetPacket.w_s32(NO_REPUTATION); #endif - save_data (m_character_name, tNetPacket); - - tNetPacket.w_u8 ( (m_deadbody_can_take)? 1 : 0 ); - tNetPacket.w_u8 ( (m_deadbody_closed)? 1 : 0 ); + save_data(m_character_name, tNetPacket); + + tNetPacket.w_u8((m_deadbody_can_take) ? 1 : 0); + tNetPacket.w_u8((m_deadbody_closed) ? 1 : 0); } -void CSE_ALifeTraderAbstract::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeTraderAbstract::STATE_Read(NET_Packet& tNetPacket, u16 size) { u16 m_wVersion = base()->m_wVersion; if (m_wVersion > 19) { if (m_wVersion < 108) { - R_ASSERT (!tNetPacket.r_u32()); + R_ASSERT(!tNetPacket.r_u32()); } if (m_wVersion < 36) { - xr_vector temp; - load_data (temp,tNetPacket); + xr_vector temp; + load_data(temp, tNetPacket); } - if (m_wVersion > 62) - tNetPacket.r_u32 (m_dwMoney); + if (m_wVersion > 62) tNetPacket.r_u32(m_dwMoney); - if ((m_wVersion > 75) && (m_wVersion < 98)){ + if ((m_wVersion > 75) && (m_wVersion < 98)) { int tmp; - tNetPacket.r_s32 (tmp); + tNetPacket.r_s32(tmp); #ifndef AI_COMPILER - if(tmp!=-1) + if (tmp != -1) m_SpecificCharacter = CSpecificCharacter::IndexToId(tmp); else m_SpecificCharacter = NULL; @@ -214,48 +210,48 @@ void CSE_ALifeTraderAbstract::STATE_Read (NET_Packet &tNetPacket, u16 size) #else m_SpecificCharacter = NULL; #endif - }else if (m_wVersion>=98){ + } + else if (m_wVersion >= 98) + { tNetPacket.r_stringZ(m_SpecificCharacter); } - if (m_wVersion > 77) - m_trader_flags.assign(tNetPacket.r_u32()); + if (m_wVersion > 77) m_trader_flags.assign(tNetPacket.r_u32()); if ((m_wVersion > 81) && (m_wVersion < 96)) { - int tmp; - tNetPacket.r_s32 (tmp); + int tmp; + tNetPacket.r_s32(tmp); #ifndef AI_COMPILER m_sCharacterProfile = CCharacterInfo::IndexToId(tmp); #else m_sCharacterProfile = "default"; #endif - VERIFY (xr_strlen(m_sCharacterProfile)); + VERIFY(xr_strlen(m_sCharacterProfile)); } - else - if(m_wVersion > 95) - tNetPacket.r_stringZ (m_sCharacterProfile); + else if (m_wVersion > 95) + tNetPacket.r_stringZ(m_sCharacterProfile); - if (m_wVersion > 85) - tNetPacket.r_s32 (m_community_index); + if (m_wVersion > 85) tNetPacket.r_s32(m_community_index); if (m_wVersion > 86) { - tNetPacket.r_s32 (m_rank); - tNetPacket.r_s32 (m_reputation); + tNetPacket.r_s32(m_rank); + tNetPacket.r_s32(m_reputation); } if (m_wVersion > 104) { - load_data (m_character_name, tNetPacket); + load_data(m_character_name, tNetPacket); } } #ifdef XRGAME_EXPORTS - specific_character (); + specific_character(); #endif - - if ( m_wVersion > 124 ) - { + + if (m_wVersion > 124) { u8 temp; - tNetPacket.r_u8 ( temp ); m_deadbody_can_take = (temp == 1); - tNetPacket.r_u8 ( temp ); m_deadbody_closed = (temp == 1); + tNetPacket.r_u8(temp); + m_deadbody_can_take = (temp == 1); + tNetPacket.r_u8(temp); + m_deadbody_closed = (temp == 1); } } @@ -265,16 +261,15 @@ void CSE_ALifeTraderAbstract::OnChangeProfile(PropValue* sender) #ifndef AI_COMPILER specific_character(); #endif - base()->set_editor_flag (IServerEntity::flVisualChange); + base()->set_editor_flag(IServerEntity::flVisualChange); } #ifndef AI_COMPILER - #ifdef XRGAME_EXPORTS -#include "game_base_space.h" #include "Level.h" +#include "game_base_space.h" #endif @@ -285,17 +280,13 @@ shared_str CSE_ALifeTraderAbstract::specific_character() if (g_pGameLevel && Level().game && (GameID() != eGameIDSingle)) return m_SpecificCharacter; #endif - if(m_SpecificCharacter.size()) - return m_SpecificCharacter; - + if (m_SpecificCharacter.size()) return m_SpecificCharacter; CCharacterInfo char_info; char_info.Load(character_profile()); - //ïðîôèëü çàäàí èíäåêñîì - if(char_info.data()->m_CharacterId.size() ) - { + if (char_info.data()->m_CharacterId.size()) { set_specific_character(char_info.data()->m_CharacterId); return m_SpecificCharacter; } @@ -304,59 +295,57 @@ shared_str CSE_ALifeTraderAbstract::specific_character() //ïðîâåðÿåì âñå èíôîðìàöèè î ïåðñîíàæå, çàïîìèíàåì ïîäõîäÿùèå, //à ïîòîì äåëàåì ñëó÷àéíûé âûáîð else - { + { m_CheckedCharacters.clear(); m_DefaultCharacters.clear(); - for(int i=0; i<=CSpecificCharacter::GetMaxIndex(); i++) + for (int i = 0; i <= CSpecificCharacter::GetMaxIndex(); i++) { CSpecificCharacter spec_char; shared_str id = CSpecificCharacter::IndexToId(i); spec_char.Load(id); - if(spec_char.data()->m_bNoRandom) continue; + if (spec_char.data()->m_bNoRandom) continue; bool class_found = false; - for(std::size_t j=0; jm_Classes.size(); j++) + for (std::size_t j = 0; j < spec_char.data()->m_Classes.size(); j++) { - if(char_info.data()->m_Class == spec_char.data()->m_Classes[j]) - { + if (char_info.data()->m_Class == spec_char.data()->m_Classes[j]) { class_found = true; break; } } - if(!char_info.data()->m_Class.size() || class_found) - { + if (!char_info.data()->m_Class.size() || class_found) { //çàïîìíèòü ïïîäõîäÿùèé ïåðñîíàæ ñ ôëàæêîì m_bDefaultForCommunity - if(spec_char.data()->m_bDefaultForCommunity) - m_DefaultCharacters.push_back(id); + if (spec_char.data()->m_bDefaultForCommunity) m_DefaultCharacters.push_back(id); - if(char_info.data()->m_Rank == NO_RANK || _abs(spec_char.Rank() - char_info.data()->m_Rank)m_Rank == NO_RANK || + _abs(spec_char.Rank() - char_info.data()->m_Rank) < RANK_DELTA) { - if(char_info.data()->m_Reputation == NO_REPUTATION || _abs(spec_char.Reputation() - char_info.data()->m_Reputation)m_Reputation == NO_REPUTATION || + _abs(spec_char.Reputation() - char_info.data()->m_Reputation) < REPUTATION_DELTA) { #ifdef XRGAME_EXPORTS int* count = NULL; - if(ai().get_alife()) - count = ai().alife().registry(specific_characters).object(id, true); + if (ai().get_alife()) count = ai().alife().registry(specific_characters).object(id, true); //åñëè èíäåêñ åùå íå áûë èñïîëüçîâàí - if(NULL == count) + if (NULL == count) #endif m_CheckedCharacters.push_back(id); } } } } - R_ASSERT3(!m_DefaultCharacters.empty(), - "no default specific character set for class", *char_info.data()->m_Class); + R_ASSERT3( + !m_DefaultCharacters.empty(), "no default specific character set for class", *char_info.data()->m_Class); #ifdef XRGAME_EXPORTS - if(m_CheckedCharacters.empty()) + if (m_CheckedCharacters.empty()) char_info.m_SpecificCharacterId = m_DefaultCharacters[Random.randI(m_DefaultCharacters.size())]; else char_info.m_SpecificCharacterId = m_CheckedCharacters[Random.randI(m_CheckedCharacters.size())]; #else - char_info.m_SpecificCharacterId = m_DefaultCharacters[Random.randI(m_DefaultCharacters.size())]; + char_info.m_SpecificCharacterId = m_DefaultCharacters[Random.randI(m_DefaultCharacters.size())]; #endif set_specific_character(char_info.m_SpecificCharacterId); @@ -364,24 +353,20 @@ shared_str CSE_ALifeTraderAbstract::specific_character() } } -void CSE_ALifeTraderAbstract::set_specific_character (shared_str new_spec_char) +void CSE_ALifeTraderAbstract::set_specific_character(shared_str new_spec_char) { R_ASSERT(new_spec_char.size()); #ifdef XRGAME_EXPORTS //óáðàòü ïðåäûäóùèé íîìåð èç ðååñòðà - if ( m_SpecificCharacter.size() ) - { - if(ai().get_alife()) - ai().alife().registry(specific_characters).remove(m_SpecificCharacter, true); + if (m_SpecificCharacter.size()) { + if (ai().get_alife()) ai().alife().registry(specific_characters).remove(m_SpecificCharacter, true); } #endif m_SpecificCharacter = new_spec_char; - #ifdef XRGAME_EXPORTS - if(ai().get_alife()) - { + if (ai().get_alife()) { //çàïîìíèòü, òî ÷òî ìû èñïîëüçîâàëè èíäåêñ int a = 1; ai().alife().registry(specific_characters).add(m_SpecificCharacter, a, true); @@ -390,71 +375,61 @@ void CSE_ALifeTraderAbstract::set_specific_character (shared_str new_spec_cha CSpecificCharacter selected_char; selected_char.Load(m_SpecificCharacter); - if(selected_char.Visual()) - { - CSE_Visual* visual = smart_cast(base()); VERIFY(visual); - if(xr_strlen(selected_char.Visual())>0) - visual->set_visual(selected_char.Visual()); + if (selected_char.Visual()) { + CSE_Visual* visual = smart_cast(base()); + VERIFY(visual); + if (xr_strlen(selected_char.Visual()) > 0) visual->set_visual(selected_char.Visual()); } #ifdef XRGAME_EXPORTS - if(NO_COMMUNITY_INDEX == m_community_index) - { + if (NO_COMMUNITY_INDEX == m_community_index) { m_community_index = selected_char.Community().index(); CSE_ALifeCreatureAbstract* creature = smart_cast(base()); - if (creature) - creature->s_team = selected_char.Community().team(); + if (creature) creature->s_team = selected_char.Community().team(); } - - -//---- + //---- CSE_ALifeMonsterAbstract* monster = smart_cast(base()); - if(monster&&selected_char.terrain_sect().size()){ - setup_location_types_section (monster->m_tpaTerrain, pSettings, *(selected_char.terrain_sect())); + if (monster && selected_char.terrain_sect().size()) { + setup_location_types_section(monster->m_tpaTerrain, pSettings, *(selected_char.terrain_sect())); } -//---- - if(NO_RANK == m_rank) - m_rank = selected_char.Rank(); + //---- + if (NO_RANK == m_rank) m_rank = selected_char.Rank(); - if(NO_REPUTATION == m_reputation) - m_reputation = selected_char.Reputation(); + if (NO_REPUTATION == m_reputation) m_reputation = selected_char.Reputation(); m_character_name = *(CStringTable().translate(selected_char.Name())); - + LPCSTR gen_name = "GENERATE_NAME_"; - if( strstr(m_character_name.c_str(),gen_name) ){ - //select name and lastname - xr_string subset = m_character_name.c_str()+xr_strlen(gen_name); - - string_path t1; - strconcat (sizeof(t1),t1,"stalker_names_",subset.c_str()); - u32 name_cnt = pSettings->r_u32(t1, "name_cnt"); - u32 last_name_cnt = pSettings->r_u32(t1, "last_name_cnt"); - - string512 S; - xr_string n = "name_"; - n += subset; - n += "_"; - n += itoa(::Random.randI(name_cnt),S,10); - m_character_name = *(CStringTable().translate(n.c_str())); - m_character_name += " "; - - n = "lname_"; - n += subset; - n += "_"; - n += itoa(::Random.randI(last_name_cnt),S,10); - m_character_name += *(CStringTable().translate(n.c_str())); - - - + if (strstr(m_character_name.c_str(), gen_name)) { + // select name and lastname + xr_string subset = m_character_name.c_str() + xr_strlen(gen_name); + + string_path t1; + strconcat(sizeof(t1), t1, "stalker_names_", subset.c_str()); + u32 name_cnt = pSettings->r_u32(t1, "name_cnt"); + u32 last_name_cnt = pSettings->r_u32(t1, "last_name_cnt"); + + string512 S; + xr_string n = "name_"; + n += subset; + n += "_"; + n += itoa(::Random.randI(name_cnt), S, 10); + m_character_name = *(CStringTable().translate(n.c_str())); + m_character_name += " "; + + n = "lname_"; + n += subset; + n += "_"; + n += itoa(::Random.randI(last_name_cnt), S, 10); + m_character_name += *(CStringTable().translate(n.c_str())); } u32 min_m = selected_char.MoneyDef().min_money; u32 max_m = selected_char.MoneyDef().max_money; - if(min_m!=0 && max_m!=0){ + if (min_m != 0 && max_m != 0) { m_dwMoney = min_m; - if(min_m!=max_m) m_dwMoney += ::Random.randI(max_m-min_m); + if (min_m != max_m) m_dwMoney += ::Random.randI(max_m - min_m); } #else //â ðåäàêòîðå ñïåöèôè÷åñêèé ïðîôèëü îñòàâëÿåì íå çàïîëíåíûì @@ -469,31 +444,30 @@ void CSE_ALifeTraderAbstract::set_character_profile(shared_str new_profile) shared_str CSE_ALifeTraderAbstract::character_profile() { - return m_sCharacterProfile; + return m_sCharacterProfile; } #endif - #ifdef XRGAME_EXPORTS //äëÿ ðàáîòû ñ relation system -u16 CSE_ALifeTraderAbstract::object_id () const +u16 CSE_ALifeTraderAbstract::object_id() const { return base()->ID; } -CHARACTER_COMMUNITY_INDEX CSE_ALifeTraderAbstract::Community () const +CHARACTER_COMMUNITY_INDEX CSE_ALifeTraderAbstract::Community() const { return m_community_index; } -LPCSTR CSE_ALifeTraderAbstract::CommunityName () const +LPCSTR CSE_ALifeTraderAbstract::CommunityName() const { return *CHARACTER_COMMUNITY::IndexToId(m_community_index); } -CHARACTER_RANK_VALUE CSE_ALifeTraderAbstract::Rank () +CHARACTER_RANK_VALUE CSE_ALifeTraderAbstract::Rank() { specific_character(); return m_rank; @@ -505,7 +479,7 @@ void CSE_ALifeTraderAbstract::SetRank(CHARACTER_RANK_VALUE val) m_rank = val; } -CHARACTER_REPUTATION_VALUE CSE_ALifeTraderAbstract::Reputation () +CHARACTER_REPUTATION_VALUE CSE_ALifeTraderAbstract::Reputation() { specific_character(); return m_reputation; @@ -513,442 +487,437 @@ CHARACTER_REPUTATION_VALUE CSE_ALifeTraderAbstract::Reputation () #endif -void CSE_ALifeTraderAbstract::UPDATE_Write (NET_Packet &tNetPacket) -{ -}; - -void CSE_ALifeTraderAbstract::UPDATE_Read (NET_Packet &tNetPacket) -{ -}; +void CSE_ALifeTraderAbstract::UPDATE_Write(NET_Packet& tNetPacket){}; +void CSE_ALifeTraderAbstract::UPDATE_Read(NET_Packet& tNetPacket){}; //////////////////////////////////////////////////////////////////////////// // CSE_ALifeTrader //////////////////////////////////////////////////////////////////////////// -CSE_ALifeTrader::CSE_ALifeTrader (LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection), CSE_ALifeTraderAbstract(caSection) +CSE_ALifeTrader::CSE_ALifeTrader(LPCSTR caSection) + : CSE_ALifeDynamicObjectVisual(caSection), CSE_ALifeTraderAbstract(caSection) { - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) + set_visual(pSettings->r_string(caSection, "visual")); } -CSE_ALifeTrader::~CSE_ALifeTrader () +CSE_ALifeTrader::~CSE_ALifeTrader() { } #ifdef DEBUG -bool CSE_ALifeTrader::match_configuration () const +bool CSE_ALifeTrader::match_configuration() const { - return (!strstr(Core.Params,"-designer")); + return (!strstr(Core.Params, "-designer")); } #endif -CSE_Abstract *CSE_ALifeTrader::init () +CSE_Abstract* CSE_ALifeTrader::init() { - inherited1::init (); - inherited2::init (); - return (base()); + inherited1::init(); + inherited2::init(); + return (base()); } -CSE_Abstract *CSE_ALifeTrader::base () +CSE_Abstract* CSE_ALifeTrader::base() { - return (inherited1::base()); + return (inherited1::base()); } -const CSE_Abstract *CSE_ALifeTrader::base () const +const CSE_Abstract* CSE_ALifeTrader::base() const { - return (inherited1::base()); + return (inherited1::base()); } -void CSE_ALifeTrader::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeTrader::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); } -void CSE_ALifeTrader::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeTrader::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket, size); - inherited2::STATE_Read (tNetPacket, size); - if ((m_wVersion > 35) && (m_wVersion < 118)) - tNetPacket.r_u32 (); - + inherited1::STATE_Read(tNetPacket, size); + inherited2::STATE_Read(tNetPacket, size); + if ((m_wVersion > 35) && (m_wVersion < 118)) tNetPacket.r_u32(); + if ((m_wVersion > 29) && (m_wVersion < 118)) { - u32 l_dwCount = tNetPacket.r_u32(); - for (int i=0 ; i<(int)l_dwCount; ++i) { - shared_str temp; + u32 l_dwCount = tNetPacket.r_u32(); + for (int i = 0; i < (int)l_dwCount; ++i) + { + shared_str temp; tNetPacket.r_stringZ(temp); - tNetPacket.r_u32 (); - for (int i=0, n=tNetPacket.r_u32(); i 30) && (m_wVersion < 118)) { - u32 count = tNetPacket.r_u32(); - shared_str temp; - for (u32 i=0; ir_float(caSection,"min_start_power"); - if (pSettings->line_exist(caSection,"hit_type")) - m_tHitType = ALife::g_tfString2HitType(pSettings->r_string(caSection,"hit_type")); + m_owner_id = u32(-1); + // m_maxPower = pSettings->r_float(caSection,"min_start_power"); + if (pSettings->line_exist(caSection, "hit_type")) + m_tHitType = ALife::g_tfString2HitType(pSettings->r_string(caSection, "hit_type")); else - m_tHitType = ALife::eHitTypeMax; - m_enabled_time = 0; - m_disabled_time = 0; - m_start_time_shift = 0; - + m_tHitType = ALife::eHitTypeMax; + m_enabled_time = 0; + m_disabled_time = 0; + m_start_time_shift = 0; } -CSE_ALifeCustomZone::~CSE_ALifeCustomZone () +CSE_ALifeCustomZone::~CSE_ALifeCustomZone() { } -void CSE_ALifeCustomZone::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeCustomZone::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); - + inherited::STATE_Read(tNetPacket, size); + float tmp; - tNetPacket.r_float (tmp/*m_maxPower*/); + tNetPacket.r_float(tmp /*m_maxPower*/); if (m_wVersion < 113) { - tNetPacket.r_float (); - tNetPacket.r_u32 (); + tNetPacket.r_float(); + tNetPacket.r_u32(); } if ((m_wVersion > 66) && (m_wVersion < 118)) { - tNetPacket.r_u32 (); + tNetPacket.r_u32(); } - if(m_wVersion > 102) - tNetPacket.r_u32 (m_owner_id); + if (m_wVersion > 102) tNetPacket.r_u32(m_owner_id); if (m_wVersion > 105) { - tNetPacket.r_u32 (m_enabled_time); - tNetPacket.r_u32 (m_disabled_time); + tNetPacket.r_u32(m_enabled_time); + tNetPacket.r_u32(m_disabled_time); } if (m_wVersion > 106) { - tNetPacket.r_u32 (m_start_time_shift); + tNetPacket.r_u32(m_start_time_shift); } - } -void CSE_ALifeCustomZone::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCustomZone::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_float (0.0/*m_maxPower*/); - tNetPacket.w_u32 (m_owner_id); - tNetPacket.w_u32 (m_enabled_time); - tNetPacket.w_u32 (m_disabled_time); - tNetPacket.w_u32 (m_start_time_shift); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_float(0.0 /*m_maxPower*/); + tNetPacket.w_u32(m_owner_id); + tNetPacket.w_u32(m_enabled_time); + tNetPacket.w_u32(m_disabled_time); + tNetPacket.w_u32(m_start_time_shift); } -void CSE_ALifeCustomZone::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeCustomZone::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeCustomZone::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCustomZone::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeCustomZone::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeCustomZone::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); - PHelper().CreateU32 (items,PrepareKey(pref,*s_name,"on/off mode\\Shift time (sec)"), &m_start_time_shift,0,100000); - PHelper().CreateU32 (items,PrepareKey(pref,*s_name,"on/off mode\\Enabled time (sec)"), &m_enabled_time, 0,100000); - PHelper().CreateU32 (items,PrepareKey(pref,*s_name,"on/off mode\\Disabled time (sec)"), &m_disabled_time, 0,100000); + inherited::FillProps(pref, items); + PHelper().CreateU32( + items, PrepareKey(pref, *s_name, "on/off mode\\Shift time (sec)"), &m_start_time_shift, 0, 100000); + PHelper().CreateU32( + items, PrepareKey(pref, *s_name, "on/off mode\\Enabled time (sec)"), &m_enabled_time, 0, 100000); + PHelper().CreateU32( + items, PrepareKey(pref, *s_name, "on/off mode\\Disabled time (sec)"), &m_disabled_time, 0, 100000); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeAnomalousZone //////////////////////////////////////////////////////////////////////////// CSE_ALifeAnomalousZone::CSE_ALifeAnomalousZone(LPCSTR caSection) : CSE_ALifeCustomZone(caSection) { - m_offline_interactive_radius = 30.f; - m_artefact_spawn_count = 32; - m_spawn_flags.set (flSpawnDestroyOnSpawn,TRUE); + m_offline_interactive_radius = 30.f; + m_artefact_spawn_count = 32; + m_spawn_flags.set(flSpawnDestroyOnSpawn, TRUE); } -CSE_Abstract *CSE_ALifeAnomalousZone::init () +CSE_Abstract* CSE_ALifeAnomalousZone::init() { - inherited::init (); - return (base()); + inherited::init(); + return (base()); } -CSE_Abstract *CSE_ALifeAnomalousZone::base () +CSE_Abstract* CSE_ALifeAnomalousZone::base() { - return (inherited::base()); + return (inherited::base()); } -const CSE_Abstract *CSE_ALifeAnomalousZone::base () const +const CSE_Abstract* CSE_ALifeAnomalousZone::base() const { - return (inherited::base()); + return (inherited::base()); } -CSE_ALifeAnomalousZone::~CSE_ALifeAnomalousZone () +CSE_ALifeAnomalousZone::~CSE_ALifeAnomalousZone() { } -u32 CSE_ALifeAnomalousZone::ef_anomaly_type () const +u32 CSE_ALifeAnomalousZone::ef_anomaly_type() const { - return (pSettings->r_u32(name(),"ef_anomaly_type")); + return (pSettings->r_u32(name(), "ef_anomaly_type")); } -u32 CSE_ALifeAnomalousZone::ef_weapon_type () const +u32 CSE_ALifeAnomalousZone::ef_weapon_type() const { - return (pSettings->r_u32(name(),"ef_weapon_type")); + return (pSettings->r_u32(name(), "ef_weapon_type")); } -u32 CSE_ALifeAnomalousZone::ef_creature_type () const +u32 CSE_ALifeAnomalousZone::ef_creature_type() const { - return (inherited::ef_weapon_type()); + return (inherited::ef_weapon_type()); } -void CSE_ALifeAnomalousZone::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeAnomalousZone::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); if (m_wVersion > 21) { - tNetPacket.r_float (m_offline_interactive_radius); + tNetPacket.r_float(m_offline_interactive_radius); if (m_wVersion < 113) { + tNetPacket.r_float(); - tNetPacket.r_float (); + shared_str temp; + for (u16 i = 0, n = tNetPacket.r_u16(); i < n; ++i) + { + tNetPacket.r_stringZ(temp); - shared_str temp; - for (u16 i=0, n=tNetPacket.r_u16(); i 26) - tNetPacket.r_float (); + tNetPacket.r_float(); else - tNetPacket.r_u32 (); + tNetPacket.r_u32(); } } } - + if (m_wVersion > 25) { - tNetPacket.r_u16 (m_artefact_spawn_count); - tNetPacket.r_u32 (m_artefact_position_offset); + tNetPacket.r_u16(m_artefact_spawn_count); + tNetPacket.r_u32(m_artefact_position_offset); } if ((m_wVersion < 67) && (m_wVersion > 27)) { - tNetPacket.r_u32 (); + tNetPacket.r_u32(); } - if ((m_wVersion > 38) && (m_wVersion < 113)) - tNetPacket.r_float (); + if ((m_wVersion > 38) && (m_wVersion < 113)) tNetPacket.r_float(); if ((m_wVersion > 78) && (m_wVersion < 113)) { - tNetPacket.r_float (); - tNetPacket.r_float (); - tNetPacket.r_float (); + tNetPacket.r_float(); + tNetPacket.r_float(); + tNetPacket.r_float(); } - if( (m_wVersion == 102) ){ //fuck + if ((m_wVersion == 102)) { // fuck u32 dummy; - tNetPacket.r_u32 (dummy); + tNetPacket.r_u32(dummy); } - } -void CSE_ALifeAnomalousZone::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeAnomalousZone::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_float (m_offline_interactive_radius); - tNetPacket.w_u16 (m_artefact_spawn_count); - tNetPacket.w_u32 (m_artefact_position_offset); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_float(m_offline_interactive_radius); + tNetPacket.w_u16(m_artefact_spawn_count); + tNetPacket.w_u32(m_artefact_position_offset); } -void CSE_ALifeAnomalousZone::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeAnomalousZone::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeAnomalousZone::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeAnomalousZone::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeAnomalousZone::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeAnomalousZone::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); - PHelper().CreateFloat (items,PrepareKey(pref,*s_name,"offline interactive radius"), &m_offline_interactive_radius, 0.f, 100.f); - PHelper().CreateU16 (items,PrepareKey(pref,*s_name,"ALife\\Artefact spawn places count"), &m_artefact_spawn_count, 32, 256); - PHelper().CreateFlag32 (items,PrepareKey(pref,*s_name,"ALife\\Visible for AI"), &m_flags, flVisibleForAI); + inherited::FillProps(pref, items); + PHelper().CreateFloat( + items, PrepareKey(pref, *s_name, "offline interactive radius"), &m_offline_interactive_radius, 0.f, 100.f); + PHelper().CreateU16( + items, PrepareKey(pref, *s_name, "ALife\\Artefact spawn places count"), &m_artefact_spawn_count, 32, 256); + PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife\\Visible for AI"), &m_flags, flVisibleForAI); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS ////////////////////////////////////////////////////////////////////////// -//SE_ALifeTorridZone +// SE_ALifeTorridZone ////////////////////////////////////////////////////////////////////////// -CSE_ALifeTorridZone::CSE_ALifeTorridZone (LPCSTR caSection) -:CSE_ALifeCustomZone(caSection),CSE_Motion() +CSE_ALifeTorridZone::CSE_ALifeTorridZone(LPCSTR caSection) : CSE_ALifeCustomZone(caSection), CSE_Motion() { } -CSE_ALifeTorridZone::~CSE_ALifeTorridZone () +CSE_ALifeTorridZone::~CSE_ALifeTorridZone() { } -CSE_Motion* CSE_ALifeTorridZone::motion () +CSE_Motion* CSE_ALifeTorridZone::motion() { - return (this); + return (this); } -void CSE_ALifeTorridZone::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeTorridZone::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket,size); - CSE_Motion::motion_read (tNetPacket); - set_editor_flag (flMotionChange); + inherited1::STATE_Read(tNetPacket, size); + CSE_Motion::motion_read(tNetPacket); + set_editor_flag(flMotionChange); } -void CSE_ALifeTorridZone::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeTorridZone::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - CSE_Motion::motion_write (tNetPacket); - + inherited1::STATE_Write(tNetPacket); + CSE_Motion::motion_write(tNetPacket); } -void CSE_ALifeTorridZone::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeTorridZone::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); } -void CSE_ALifeTorridZone::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeTorridZone::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS void CSE_ALifeTorridZone::FillProps(LPCSTR pref, PropItemVec& values) { - inherited1::FillProps (pref, values); - inherited2::FillProps (pref, values); + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS ////////////////////////////////////////////////////////////////////////// -//CSE_ALifeZoneVisual +// CSE_ALifeZoneVisual ////////////////////////////////////////////////////////////////////////// -CSE_ALifeZoneVisual::CSE_ALifeZoneVisual (LPCSTR caSection) -:CSE_ALifeAnomalousZone(caSection),CSE_Visual(caSection) +CSE_ALifeZoneVisual::CSE_ALifeZoneVisual(LPCSTR caSection) : CSE_ALifeAnomalousZone(caSection), CSE_Visual(caSection) { - if (pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); -// if(pSettings->line_exist(caSection,"blast_animation")) -// attack_animation=pSettings->r_string(caSection,"blast_animation"); + if (pSettings->line_exist(caSection, "visual")) set_visual(pSettings->r_string(caSection, "visual")); + // if(pSettings->line_exist(caSection,"blast_animation")) + // attack_animation=pSettings->r_string(caSection,"blast_animation"); } -CSE_ALifeZoneVisual::~CSE_ALifeZoneVisual () +CSE_ALifeZoneVisual::~CSE_ALifeZoneVisual() { - } -CSE_Visual* CSE_ALifeZoneVisual::visual () +CSE_Visual* CSE_ALifeZoneVisual::visual() { - return static_cast(this); + return static_cast(this); } -void CSE_ALifeZoneVisual::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeZoneVisual::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket,size); - visual_read (tNetPacket,m_wVersion); + inherited1::STATE_Read(tNetPacket, size); + visual_read(tNetPacket, m_wVersion); tNetPacket.r_stringZ(startup_animation); tNetPacket.r_stringZ(attack_animation); } -void CSE_ALifeZoneVisual::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeZoneVisual::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - visual_write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + visual_write(tNetPacket); tNetPacket.w_stringZ(startup_animation); tNetPacket.w_stringZ(attack_animation); } -void CSE_ALifeZoneVisual::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeZoneVisual::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); } -void CSE_ALifeZoneVisual::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeZoneVisual::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS void CSE_ALifeZoneVisual::FillProps(LPCSTR pref, PropItemVec& values) { - inherited1::FillProps (pref, values); - inherited2::FillProps (pref, values); - IServerEntity* abstract = smart_cast(this); VERIFY(abstract); - PHelper().CreateChoose(values, PrepareKey(pref,abstract->name(),"Attack animation"), &attack_animation, smSkeletonAnims,0,(void*)*visual_name); + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); + IServerEntity* abstract = smart_cast(this); + VERIFY(abstract); + PHelper().CreateChoose(values, PrepareKey(pref, abstract->name(), "Attack animation"), &attack_animation, + smSkeletonAnims, 0, (void*)*visual_name); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////// // CSE_ALifeCreatureAbstract //////////////////////////////////////////////////////////////////////////// -CSE_ALifeCreatureAbstract::CSE_ALifeCreatureAbstract(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) -{ - s_team = s_squad = s_group = 0; - o_model = 0.f; - o_torso.pitch = 0.f; - o_torso.yaw = 0.f; - o_torso.roll = 0.f; - fHealth = 1; - m_bDeathIsProcessed = false; - m_fAccuracy = 25.f; - m_fIntelligence = 25.f; - m_fMorale = 100.f; - m_ef_creature_type = pSettings->r_u32(caSection,"ef_creature_type"); - m_ef_weapon_type = READ_IF_EXISTS(pSettings,r_u32,caSection,"ef_weapon_type",u32(-1)); - m_ef_detector_type = READ_IF_EXISTS(pSettings,r_u32,caSection,"ef_detector_type",u32(-1)); - m_killer_id = ALife::_OBJECT_ID(-1); - m_game_death_time = 0; +CSE_ALifeCreatureAbstract::CSE_ALifeCreatureAbstract(LPCSTR caSection) : CSE_ALifeDynamicObjectVisual(caSection) +{ + s_team = s_squad = s_group = 0; + o_model = 0.f; + o_torso.pitch = 0.f; + o_torso.yaw = 0.f; + o_torso.roll = 0.f; + fHealth = 1; + m_bDeathIsProcessed = false; + m_fAccuracy = 25.f; + m_fIntelligence = 25.f; + m_fMorale = 100.f; + m_ef_creature_type = pSettings->r_u32(caSection, "ef_creature_type"); + m_ef_weapon_type = READ_IF_EXISTS(pSettings, r_u32, caSection, "ef_weapon_type", u32(-1)); + m_ef_detector_type = READ_IF_EXISTS(pSettings, r_u32, caSection, "ef_detector_type", u32(-1)); + m_killer_id = ALife::_OBJECT_ID(-1); + m_game_death_time = 0; } CSE_ALifeCreatureAbstract::~CSE_ALifeCreatureAbstract() @@ -956,167 +925,162 @@ CSE_ALifeCreatureAbstract::~CSE_ALifeCreatureAbstract() } #ifdef DEBUG -bool CSE_ALifeCreatureAbstract::match_configuration () const +bool CSE_ALifeCreatureAbstract::match_configuration() const { - return (!strstr(Core.Params,"-designer")); + return (!strstr(Core.Params, "-designer")); } #endif -u32 CSE_ALifeCreatureAbstract::ef_creature_type () const +u32 CSE_ALifeCreatureAbstract::ef_creature_type() const { - return (m_ef_creature_type); + return (m_ef_creature_type); } -u32 CSE_ALifeCreatureAbstract::ef_weapon_type () const +u32 CSE_ALifeCreatureAbstract::ef_weapon_type() const { - VERIFY (m_ef_weapon_type != u32(-1)); - return (m_ef_weapon_type); + VERIFY(m_ef_weapon_type != u32(-1)); + return (m_ef_weapon_type); } -u32 CSE_ALifeCreatureAbstract::ef_detector_type() const +u32 CSE_ALifeCreatureAbstract::ef_detector_type() const { - VERIFY (m_ef_detector_type != u32(-1)); - return (m_ef_detector_type); + VERIFY(m_ef_detector_type != u32(-1)); + return (m_ef_detector_type); } #ifdef XRGAME_EXPORTS -void CSE_ALifeCreatureAbstract::on_death (CSE_Abstract *killer) +void CSE_ALifeCreatureAbstract::on_death(CSE_Abstract* killer) { - VERIFY (!m_game_death_time); - m_game_death_time = ai().get_alife() ? alife().time_manager().game_time() : Level().GetGameTime(); - fHealth = -1.f; + VERIFY(!m_game_death_time); + m_game_death_time = ai().get_alife() ? alife().time_manager().game_time() : Level().GetGameTime(); + fHealth = -1.f; } -#endif // XRGAME_EXPORTS +#endif // XRGAME_EXPORTS -void CSE_ALifeCreatureAbstract::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCreatureAbstract::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); - tNetPacket.w_u8 (s_team ); - tNetPacket.w_u8 (s_squad); - tNetPacket.w_u8 (s_group); - tNetPacket.w_float (fHealth); - save_data (m_dynamic_out_restrictions,tNetPacket); - save_data (m_dynamic_in_restrictions,tNetPacket); - tNetPacket.w_u16 ( get_killer_id() ); + inherited::STATE_Write(tNetPacket); + tNetPacket.w_u8(s_team); + tNetPacket.w_u8(s_squad); + tNetPacket.w_u8(s_group); + tNetPacket.w_float(fHealth); + save_data(m_dynamic_out_restrictions, tNetPacket); + save_data(m_dynamic_in_restrictions, tNetPacket); + tNetPacket.w_u16(get_killer_id()); R_ASSERT(!(get_health() > 0.0f && get_killer_id() != u16(-1))); - tNetPacket.w_u64 (m_game_death_time); + tNetPacket.w_u64(m_game_death_time); } -void CSE_ALifeCreatureAbstract::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeCreatureAbstract::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket, size); - tNetPacket.r_u8 (s_team ); - tNetPacket.r_u8 (s_squad); - tNetPacket.r_u8 (s_group); - if (m_wVersion > 18) - tNetPacket.r_float (fHealth); + inherited::STATE_Read(tNetPacket, size); + tNetPacket.r_u8(s_team); + tNetPacket.r_u8(s_squad); + tNetPacket.r_u8(s_group); + if (m_wVersion > 18) tNetPacket.r_float(fHealth); - if (m_wVersion < 115) - fHealth /=100.0f; + if (m_wVersion < 115) fHealth /= 100.0f; - if (m_wVersion < 32) - visual_read (tNetPacket,m_wVersion); - o_model = o_torso.yaw; + if (m_wVersion < 32) visual_read(tNetPacket, m_wVersion); + o_model = o_torso.yaw; if (m_wVersion > 87) { - load_data (m_dynamic_out_restrictions,tNetPacket); - load_data (m_dynamic_in_restrictions,tNetPacket); + load_data(m_dynamic_out_restrictions, tNetPacket); + load_data(m_dynamic_in_restrictions, tNetPacket); } - if (m_wVersion > 94) - set_killer_id( tNetPacket.r_u16() ); - - o_torso.pitch = o_Angle.x; - o_torso.yaw = o_Angle.y; - - if (m_wVersion > 115) - tNetPacket.r_u64 (m_game_death_time); -} - -void CSE_ALifeCreatureAbstract::UPDATE_Write(NET_Packet &tNetPacket) -{ - inherited::UPDATE_Write (tNetPacket); - - tNetPacket.w_float (fHealth); - - tNetPacket.w_u32 (timestamp ); - tNetPacket.w_u8 (flags ); - tNetPacket.w_vec3 (o_Position ); - tNetPacket.w_float /*w_angle8*/ (o_model ); - tNetPacket.w_float /*w_angle8*/ (o_torso.yaw ); - tNetPacket.w_float /*w_angle8*/ (o_torso.pitch ); - tNetPacket.w_float /*w_angle8*/ (o_torso.roll ); - tNetPacket.w_u8 (s_team); - tNetPacket.w_u8 (s_squad); - tNetPacket.w_u8 (s_group); + if (m_wVersion > 94) set_killer_id(tNetPacket.r_u16()); + + o_torso.pitch = o_Angle.x; + o_torso.yaw = o_Angle.y; + + if (m_wVersion > 115) tNetPacket.r_u64(m_game_death_time); +} + +void CSE_ALifeCreatureAbstract::UPDATE_Write(NET_Packet& tNetPacket) +{ + inherited::UPDATE_Write(tNetPacket); + + tNetPacket.w_float(fHealth); + + tNetPacket.w_u32(timestamp); + tNetPacket.w_u8(flags); + tNetPacket.w_vec3(o_Position); + tNetPacket.w_float /*w_angle8*/ (o_model); + tNetPacket.w_float /*w_angle8*/ (o_torso.yaw); + tNetPacket.w_float /*w_angle8*/ (o_torso.pitch); + tNetPacket.w_float /*w_angle8*/ (o_torso.roll); + tNetPacket.w_u8(s_team); + tNetPacket.w_u8(s_squad); + tNetPacket.w_u8(s_group); }; -void CSE_ALifeCreatureAbstract::UPDATE_Read (NET_Packet &tNetPacket) -{ - inherited::UPDATE_Read (tNetPacket); - - tNetPacket.r_float (fHealth); - - tNetPacket.r_u32 (timestamp ); - tNetPacket.r_u8 (flags ); - tNetPacket.r_vec3 (o_Position ); - tNetPacket.r_float /*r_angle8*/ (o_model ); - tNetPacket.r_float /*r_angle8*/ (o_torso.yaw ); - tNetPacket.r_float /*r_angle8*/ (o_torso.pitch ); - tNetPacket.r_float /*r_angle8*/ (o_torso.roll ); - - tNetPacket.r_u8 (s_team); - tNetPacket.r_u8 (s_squad); - tNetPacket.r_u8 (s_group); +void CSE_ALifeCreatureAbstract::UPDATE_Read(NET_Packet& tNetPacket) +{ + inherited::UPDATE_Read(tNetPacket); + + tNetPacket.r_float(fHealth); + + tNetPacket.r_u32(timestamp); + tNetPacket.r_u8(flags); + tNetPacket.r_vec3(o_Position); + tNetPacket.r_float /*r_angle8*/ (o_model); + tNetPacket.r_float /*r_angle8*/ (o_torso.yaw); + tNetPacket.r_float /*r_angle8*/ (o_torso.pitch); + tNetPacket.r_float /*r_angle8*/ (o_torso.roll); + + tNetPacket.r_u8(s_team); + tNetPacket.r_u8(s_squad); + tNetPacket.r_u8(s_group); }; -u8 CSE_ALifeCreatureAbstract::g_team () +u8 CSE_ALifeCreatureAbstract::g_team() { return s_team; } -u8 CSE_ALifeCreatureAbstract::g_squad () +u8 CSE_ALifeCreatureAbstract::g_squad() { return s_squad; } -u8 CSE_ALifeCreatureAbstract::g_group () +u8 CSE_ALifeCreatureAbstract::g_group() { return s_group; } #ifndef XRGAME_EXPORTS -void CSE_ALifeCreatureAbstract::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeCreatureAbstract::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref,items); - PHelper().CreateU8 (items,PrepareKey(pref,*s_name, "Team"), &s_team, 0,64,1); - PHelper().CreateU8 (items,PrepareKey(pref,*s_name, "Squad"), &s_squad, 0,64,1); - PHelper().CreateU8 (items,PrepareKey(pref,*s_name, "Group"), &s_group, 0,64,1); - PHelper().CreateFloat (items,PrepareKey(pref,*s_name,"Personal", "Health" ),&fHealth, 0,2,5); + inherited::FillProps(pref, items); + PHelper().CreateU8(items, PrepareKey(pref, *s_name, "Team"), &s_team, 0, 64, 1); + PHelper().CreateU8(items, PrepareKey(pref, *s_name, "Squad"), &s_squad, 0, 64, 1); + PHelper().CreateU8(items, PrepareKey(pref, *s_name, "Group"), &s_group, 0, 64, 1); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Health"), &fHealth, 0, 2, 5); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeCreatureAbstract::used_ai_locations () const +bool CSE_ALifeCreatureAbstract::used_ai_locations() const { - return (true); + return (true); } -bool CSE_ALifeCreatureAbstract::can_switch_online () const +bool CSE_ALifeCreatureAbstract::can_switch_online() const { - return (inherited::can_switch_online()); + return (inherited::can_switch_online()); } -bool CSE_ALifeCreatureAbstract::can_switch_offline () const +bool CSE_ALifeCreatureAbstract::can_switch_offline() const { - return (inherited::can_switch_offline() && (get_health() > 0.f)); + return (inherited::can_switch_offline() && (get_health() > 0.f)); } -void CSE_ALifeCreatureAbstract::set_health (float const health_value) +void CSE_ALifeCreatureAbstract::set_health(float const health_value) { - VERIFY( !((get_killer_id() != u16(-1)) && (health_value > 0.f)) ); + VERIFY(!((get_killer_id() != u16(-1)) && (health_value > 0.f))); fHealth = health_value; } -void CSE_ALifeCreatureAbstract::set_killer_id (ALife::_OBJECT_ID const killer_id) +void CSE_ALifeCreatureAbstract::set_killer_id(ALife::_OBJECT_ID const killer_id) { m_killer_id = killer_id; } @@ -1124,232 +1088,231 @@ void CSE_ALifeCreatureAbstract::set_killer_id (ALife::_OBJECT_ID const killer_ //////////////////////////////////////////////////////////////////////////// // CSE_ALifeMonsterAbstract //////////////////////////////////////////////////////////////////////////// -CSE_ALifeMonsterAbstract::CSE_ALifeMonsterAbstract(LPCSTR caSection) : CSE_ALifeCreatureAbstract(caSection), CSE_ALifeSchedulable(caSection) -{ - m_group_id = 0xffff; - - - m_tNextGraphID = m_tGraphID; - m_tPrevGraphID = m_tGraphID; - m_fCurSpeed = 0.0f; - m_fDistanceFromPoint = 0.0f; - m_fDistanceToPoint = 0.0f; - m_fGoingSpeed = pSettings->r_float(caSection, "going_speed"); - m_fCurrentLevelGoingSpeed = READ_IF_EXISTS(pSettings,r_float,caSection,"current_level_going_speed",m_fGoingSpeed); - - setup_location_types (m_tpaTerrain,pSettings,pSettings->r_string(caSection,"terrain")); - - m_fMaxHealthValue = pSettings->r_float (caSection,"MaxHealthValue"); - if (pSettings->line_exist(caSection,"hit_power")) { - m_fHitPower = pSettings->r_float(caSection,"hit_power"); - m_tHitType = ALife::g_tfString2HitType(pSettings->r_string(caSection,"hit_type")); +CSE_ALifeMonsterAbstract::CSE_ALifeMonsterAbstract(LPCSTR caSection) + : CSE_ALifeCreatureAbstract(caSection), CSE_ALifeSchedulable(caSection) +{ + m_group_id = 0xffff; + + m_tNextGraphID = m_tGraphID; + m_tPrevGraphID = m_tGraphID; + m_fCurSpeed = 0.0f; + m_fDistanceFromPoint = 0.0f; + m_fDistanceToPoint = 0.0f; + m_fGoingSpeed = pSettings->r_float(caSection, "going_speed"); + m_fCurrentLevelGoingSpeed = + READ_IF_EXISTS(pSettings, r_float, caSection, "current_level_going_speed", m_fGoingSpeed); + + setup_location_types(m_tpaTerrain, pSettings, pSettings->r_string(caSection, "terrain")); + + m_fMaxHealthValue = pSettings->r_float(caSection, "MaxHealthValue"); + if (pSettings->line_exist(caSection, "hit_power")) { + m_fHitPower = pSettings->r_float(caSection, "hit_power"); + m_tHitType = ALife::g_tfString2HitType(pSettings->r_string(caSection, "hit_type")); } - else { - m_fHitPower = 0; - m_tHitType = ALife::eHitTypeMax; + else + { + m_fHitPower = 0; + m_tHitType = ALife::eHitTypeMax; } { - string64 S; - m_fpImmunityFactors.resize (ALife::eHitTypeMax); - svector::iterator B = m_fpImmunityFactors.begin(), I = B; - svector::iterator E = m_fpImmunityFactors.end(); + string64 S; + m_fpImmunityFactors.resize(ALife::eHitTypeMax); + svector::iterator B = m_fpImmunityFactors.begin(), I = B; + svector::iterator E = m_fpImmunityFactors.end(); LPCSTR imm_section = caSection; - if(pSettings->line_exist(caSection, "immunities_sect")) + if (pSettings->line_exist(caSection, "immunities_sect")) imm_section = pSettings->r_string(caSection, "immunities_sect"); - for ( ; I != E; ++I) + for (; I != E; ++I) { - xr_strcpy (S, ALife::g_cafHitType2String(ALife::EHitType(I - B))); - xr_strcat (S,"_immunity"); - *I = READ_IF_EXISTS(pSettings,r_float,imm_section,S,1.f); + xr_strcpy(S, ALife::g_cafHitType2String(ALife::EHitType(I - B))); + xr_strcat(S, "_immunity"); + *I = READ_IF_EXISTS(pSettings, r_float, imm_section, S, 1.f); } } - if (pSettings->line_exist(caSection,"retreat_threshold")) - m_fRetreatThreshold = pSettings->r_float(caSection,"retreat_threshold"); + if (pSettings->line_exist(caSection, "retreat_threshold")) + m_fRetreatThreshold = pSettings->r_float(caSection, "retreat_threshold"); else - m_fRetreatThreshold = 0.2f; + m_fRetreatThreshold = 0.2f; - m_fEyeRange = pSettings->r_float(caSection,"eye_range"); + m_fEyeRange = pSettings->r_float(caSection, "eye_range"); - m_tpBestDetector = this; + m_tpBestDetector = this; - m_brain = 0; - m_smart_terrain_id = 0xffff; - m_task_reached = false; + m_brain = 0; + m_smart_terrain_id = 0xffff; + m_task_reached = false; - m_rank = (pSettings->line_exist(caSection,"rank")) ? pSettings->r_s32(caSection,"rank") : 0; + m_rank = (pSettings->line_exist(caSection, "rank")) ? pSettings->r_s32(caSection, "rank") : 0; #ifdef XRGAME_EXPORTS - m_stay_after_death_time_interval = generate_time(1,1,1,pSettings->r_u32("monsters_common","stay_after_death_time_interval"),0,0); -#endif // XRGAME_EXPORTS + m_stay_after_death_time_interval = + generate_time(1, 1, 1, pSettings->r_u32("monsters_common", "stay_after_death_time_interval"), 0, 0); +#endif // XRGAME_EXPORTS } CSE_ALifeMonsterAbstract::~CSE_ALifeMonsterAbstract() { - xr_delete (m_brain); + xr_delete(m_brain); } -CALifeMonsterBrain *CSE_ALifeMonsterAbstract::create_brain () +CALifeMonsterBrain* CSE_ALifeMonsterAbstract::create_brain() { - return (new CALifeMonsterBrain(this)); + return (new CALifeMonsterBrain(this)); } -CSE_Abstract *CSE_ALifeMonsterAbstract::init () +CSE_Abstract* CSE_ALifeMonsterAbstract::init() { - inherited1::init (); - inherited2::init (); + inherited1::init(); + inherited2::init(); - if (spawn_ini().section_exist("alife") && spawn_ini().line_exist("alife","terrain")) - setup_location_types (m_tpaTerrain,&spawn_ini(),spawn_ini().r_string("alife","terrain")); + if (spawn_ini().section_exist("alife") && spawn_ini().line_exist("alife", "terrain")) + setup_location_types(m_tpaTerrain, &spawn_ini(), spawn_ini().r_string("alife", "terrain")); - m_brain = create_brain(); + m_brain = create_brain(); - return (base()); + return (base()); } -CSE_Abstract *CSE_ALifeMonsterAbstract::base () +CSE_Abstract* CSE_ALifeMonsterAbstract::base() { - return (inherited1::base()); + return (inherited1::base()); } -u32 CSE_ALifeMonsterAbstract::ef_creature_type () const +u32 CSE_ALifeMonsterAbstract::ef_creature_type() const { - return (inherited1::ef_creature_type()); + return (inherited1::ef_creature_type()); } -u32 CSE_ALifeMonsterAbstract::ef_weapon_type () const +u32 CSE_ALifeMonsterAbstract::ef_weapon_type() const { - return (inherited1::ef_weapon_type()); + return (inherited1::ef_weapon_type()); } -u32 CSE_ALifeMonsterAbstract::ef_detector_type () const +u32 CSE_ALifeMonsterAbstract::ef_detector_type() const { - return (inherited1::ef_detector_type()); + return (inherited1::ef_detector_type()); } -const CSE_Abstract *CSE_ALifeMonsterAbstract::base () const +const CSE_Abstract* CSE_ALifeMonsterAbstract::base() const { - return (inherited1::base()); + return (inherited1::base()); } -void CSE_ALifeMonsterAbstract::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeMonsterAbstract::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - tNetPacket.w_stringZ (m_out_space_restrictors); - tNetPacket.w_stringZ (m_in_space_restrictors); - tNetPacket.w_u16 (m_smart_terrain_id); + inherited1::STATE_Write(tNetPacket); + tNetPacket.w_stringZ(m_out_space_restrictors); + tNetPacket.w_stringZ(m_in_space_restrictors); + tNetPacket.w_u16(m_smart_terrain_id); - if(tNetPacket.inistream) - tNetPacket.w_u16 ((m_task_reached)?1:0); + if (tNetPacket.inistream) + tNetPacket.w_u16((m_task_reached) ? 1 : 0); else - tNetPacket.w (&m_task_reached, sizeof(m_task_reached)); + tNetPacket.w(&m_task_reached, sizeof(m_task_reached)); } -void CSE_ALifeMonsterAbstract::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeMonsterAbstract::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket, size); + inherited1::STATE_Read(tNetPacket, size); if (m_wVersion > 72) { - tNetPacket.r_stringZ (m_out_space_restrictors); - if (m_wVersion > 73) - tNetPacket.r_stringZ(m_in_space_restrictors); + tNetPacket.r_stringZ(m_out_space_restrictors); + if (m_wVersion > 73) tNetPacket.r_stringZ(m_in_space_restrictors); } - if (m_wVersion > 111) - tNetPacket.r_u16 (m_smart_terrain_id); + if (m_wVersion > 111) tNetPacket.r_u16(m_smart_terrain_id); - if (m_wVersion > 113) - { - if(tNetPacket.inistream) - { + if (m_wVersion > 113) { + if (tNetPacket.inistream) { u16 tmp; - tNetPacket.r_u16 (tmp); - m_task_reached = (tmp!=0); - }else - tNetPacket.r (&m_task_reached, sizeof(m_task_reached)); + tNetPacket.r_u16(tmp); + m_task_reached = (tmp != 0); + } + else + tNetPacket.r(&m_task_reached, sizeof(m_task_reached)); } - } -void CSE_ALifeMonsterAbstract::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeMonsterAbstract::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - - tNetPacket.w_u16 (m_tNextGraphID); - tNetPacket.w_u16 (m_tPrevGraphID); - tNetPacket.w_float (m_fDistanceFromPoint); - tNetPacket.w_float (m_fDistanceToPoint); + inherited1::UPDATE_Write(tNetPacket); + tNetPacket.w_u16(m_tNextGraphID); + tNetPacket.w_u16(m_tPrevGraphID); + tNetPacket.w_float(m_fDistanceFromPoint); + tNetPacket.w_float(m_fDistanceToPoint); }; -void CSE_ALifeMonsterAbstract::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeMonsterAbstract::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - - tNetPacket.r_u16 (m_tNextGraphID); - tNetPacket.r_u16 (m_tPrevGraphID); - tNetPacket.r_float (m_fDistanceFromPoint); - tNetPacket.r_float (m_fDistanceToPoint); + inherited1::UPDATE_Read(tNetPacket); + tNetPacket.r_u16(m_tNextGraphID); + tNetPacket.r_u16(m_tPrevGraphID); + tNetPacket.r_float(m_fDistanceFromPoint); + tNetPacket.r_float(m_fDistanceToPoint); }; #ifndef XRGAME_EXPORTS -void CSE_ALifeMonsterAbstract::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeMonsterAbstract::FillProps(LPCSTR pref, PropItemVec& items) { - inherited1::FillProps (pref,items); - - PHelper().CreateFlag32 (items, PrepareKey(pref,*s_name,"ALife\\No move in offline"), &m_flags, flOfflineNoMove); - PHelper().CreateFlag32 (items, PrepareKey(pref,*s_name,"Use smart terrain tasks"), &m_flags, flUseSmartTerrains); + inherited1::FillProps(pref, items); + + PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "ALife\\No move in offline"), &m_flags, flOfflineNoMove); + PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "Use smart terrain tasks"), &m_flags, flUseSmartTerrains); - if (pSettings->line_exist(s_name,"SpaceRestrictionSection")) { - LPCSTR gcs = pSettings->r_string(s_name,"SpaceRestrictionSection"); - PHelper().CreateChoose (items, PrepareKey(pref,*s_name,"out space restrictions"),&m_out_space_restrictors, smSpawnItem, 0, (void*)gcs, 16); - PHelper().CreateChoose (items, PrepareKey(pref,*s_name,"in space restrictions"),&m_in_space_restrictors, smSpawnItem, 0, (void*)gcs, 16); + if (pSettings->line_exist(s_name, "SpaceRestrictionSection")) { + LPCSTR gcs = pSettings->r_string(s_name, "SpaceRestrictionSection"); + PHelper().CreateChoose(items, PrepareKey(pref, *s_name, "out space restrictions"), &m_out_space_restrictors, + smSpawnItem, 0, (void*)gcs, 16); + PHelper().CreateChoose(items, PrepareKey(pref, *s_name, "in space restrictions"), &m_in_space_restrictors, + smSpawnItem, 0, (void*)gcs, 16); } } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeMonsterAbstract::need_update (CSE_ALifeDynamicObject *object) +bool CSE_ALifeMonsterAbstract::need_update(CSE_ALifeDynamicObject* object) { - return (CSE_ALifeSchedulable::need_update(object) && (get_health() > EPS_L)); + return (CSE_ALifeSchedulable::need_update(object) && (get_health() > EPS_L)); } #ifdef XRGAME_EXPORTS -void CSE_ALifeMonsterAbstract::kill () +void CSE_ALifeMonsterAbstract::kill() { - if (m_group_id != 0xffff) - ai().alife().groups().object(m_group_id).unregister_member (ID); + if (m_group_id != 0xffff) ai().alife().groups().object(m_group_id).unregister_member(ID); set_health(0.f); - } -bool CSE_ALifeMonsterAbstract::has_detector () +bool CSE_ALifeMonsterAbstract::has_detector() { - OBJECT_IT I = this->children.begin(); - OBJECT_IT E = this->children.end(); - for ( ; I != E; ++I){ + OBJECT_IT I = this->children.begin(); + OBJECT_IT E = this->children.end(); + for (; I != E; ++I) + { CSE_ALifeItemDetector* detector = smart_cast(ai().alife().objects().object(*I)); if (detector) return true; }; return false; } -#endif // #ifdef XRGAME_EXPORTS +#endif // #ifdef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_ALifeCreatureActor //////////////////////////////////////////////////////////////////////////// -CSE_ALifeCreatureActor::CSE_ALifeCreatureActor (LPCSTR caSection) : CSE_ALifeCreatureAbstract(caSection), CSE_ALifeTraderAbstract(caSection),CSE_PHSkeleton(caSection) +CSE_ALifeCreatureActor::CSE_ALifeCreatureActor(LPCSTR caSection) + : CSE_ALifeCreatureAbstract(caSection), CSE_ALifeTraderAbstract(caSection), CSE_PHSkeleton(caSection) { - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); - m_u16NumItems = 0; -// fArmor = 0.f; - fRadiation = 0.f; - accel.set (0.f,0.f,0.f); - velocity.set (0.f,0.f,0.f); - m_holderID =u16(-1); - mstate = 0; + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) + set_visual(pSettings->r_string(caSection, "visual")); + m_u16NumItems = 0; + // fArmor = 0.f; + fRadiation = 0.f; + accel.set(0.f, 0.f, 0.f); + velocity.set(0.f, 0.f, 0.f); + m_holderID = u16(-1); + mstate = 0; } CSE_ALifeCreatureActor::~CSE_ALifeCreatureActor() @@ -1357,171 +1320,165 @@ CSE_ALifeCreatureActor::~CSE_ALifeCreatureActor() } #ifdef DEBUG -bool CSE_ALifeCreatureActor::match_configuration () const +bool CSE_ALifeCreatureActor::match_configuration() const { - return (true); + return (true); } #endif -CSE_Abstract *CSE_ALifeCreatureActor::init () +CSE_Abstract* CSE_ALifeCreatureActor::init() { - inherited1::init (); - inherited2::init (); - return (inherited1::base()); + inherited1::init(); + inherited2::init(); + return (inherited1::base()); } -CSE_Abstract *CSE_ALifeCreatureActor::base () +CSE_Abstract* CSE_ALifeCreatureActor::base() { - return (inherited1::base()); + return (inherited1::base()); } -const CSE_Abstract *CSE_ALifeCreatureActor::base () const +const CSE_Abstract* CSE_ALifeCreatureActor::base() const { - return (inherited1::base()); + return (inherited1::base()); } -void CSE_ALifeCreatureActor::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeCreatureActor::STATE_Read(NET_Packet& tNetPacket, u16 size) { if (m_wVersion < 21) { - CSE_ALifeDynamicObject::STATE_Read(tNetPacket,size); - tNetPacket.r_u8 (s_team ); - tNetPacket.r_u8 (s_squad); - tNetPacket.r_u8 (s_group); - if (m_wVersion > 18) - set_health( tNetPacket.r_float() ); - if (m_wVersion >= 3) - visual_read (tNetPacket,m_wVersion); + CSE_ALifeDynamicObject::STATE_Read(tNetPacket, size); + tNetPacket.r_u8(s_team); + tNetPacket.r_u8(s_squad); + tNetPacket.r_u8(s_group); + if (m_wVersion > 18) set_health(tNetPacket.r_float()); + if (m_wVersion >= 3) visual_read(tNetPacket, m_wVersion); } - else { - inherited1::STATE_Read (tNetPacket,size); - inherited2::STATE_Read (tNetPacket,size); - if (m_wVersion < 32) - visual_read (tNetPacket,m_wVersion); - } - if(m_wVersion>91) + else { - inherited3::STATE_Read(tNetPacket,size); + inherited1::STATE_Read(tNetPacket, size); + inherited2::STATE_Read(tNetPacket, size); + if (m_wVersion < 32) visual_read(tNetPacket, m_wVersion); } - if(m_wVersion>88) - { - m_holderID=tNetPacket.r_u16(); + if (m_wVersion > 91) { + inherited3::STATE_Read(tNetPacket, size); + } + if (m_wVersion > 88) { + m_holderID = tNetPacket.r_u16(); } }; -void CSE_ALifeCreatureActor::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCreatureActor::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); - inherited3::STATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); + inherited3::STATE_Write(tNetPacket); tNetPacket.w_u16(m_holderID); }; -void CSE_ALifeCreatureActor::load(NET_Packet &tNetPacket) +void CSE_ALifeCreatureActor::load(NET_Packet& tNetPacket) { inherited1::load(tNetPacket); inherited3::load(tNetPacket); - m_holderID=tNetPacket.r_u16(); + m_holderID = tNetPacket.r_u16(); } BOOL CSE_ALifeCreatureActor::Net_Relevant() { - return TRUE; // this is a big question ;) + return TRUE; // this is a big question ;) } -void CSE_ALifeCreatureActor::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeCreatureActor::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); - tNetPacket.r_u16 (mstate ); - tNetPacket.r_sdir (accel ); - tNetPacket.r_sdir (velocity ); - tNetPacket.r_float (fRadiation ); - tNetPacket.r_u8 (weapon ); + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); + tNetPacket.r_u16(mstate); + tNetPacket.r_sdir(accel); + tNetPacket.r_sdir(velocity); + tNetPacket.r_float(fRadiation); + tNetPacket.r_u8(weapon); //////////////////////////////////////////////////// - tNetPacket.r_u16 (m_u16NumItems); + tNetPacket.r_u16(m_u16NumItems); if (!m_u16NumItems) return; - if (m_u16NumItems == 1) - { - tNetPacket.r_u8 ( *((u8*)&(m_AliveState.enabled)) ); + if (m_u16NumItems == 1) { + tNetPacket.r_u8(*((u8*)&(m_AliveState.enabled))); - tNetPacket.r_vec3 ( m_AliveState.angular_vel ); - tNetPacket.r_vec3 ( m_AliveState.linear_vel ); + tNetPacket.r_vec3(m_AliveState.angular_vel); + tNetPacket.r_vec3(m_AliveState.linear_vel); - tNetPacket.r_vec3 ( m_AliveState.force ); - tNetPacket.r_vec3 ( m_AliveState.torque ); + tNetPacket.r_vec3(m_AliveState.force); + tNetPacket.r_vec3(m_AliveState.torque); - tNetPacket.r_vec3 ( m_AliveState.position ); + tNetPacket.r_vec3(m_AliveState.position); - tNetPacket.r_float ( m_AliveState.quaternion.x ); - tNetPacket.r_float ( m_AliveState.quaternion.y ); - tNetPacket.r_float ( m_AliveState.quaternion.z ); - tNetPacket.r_float ( m_AliveState.quaternion.w ); + tNetPacket.r_float(m_AliveState.quaternion.x); + tNetPacket.r_float(m_AliveState.quaternion.y); + tNetPacket.r_float(m_AliveState.quaternion.z); + tNetPacket.r_float(m_AliveState.quaternion.w); return; - }; + }; ////////////// Import dead body //////////////////// - Msg ("A mi ni hera tut ne chitaem (m_u16NumItems == %d)",m_u16NumItems); + Msg("A mi ni hera tut ne chitaem (m_u16NumItems == %d)", m_u16NumItems); { m_BoneDataSize = tNetPacket.r_u8(); - u32 BodyDataSize = 24 + m_BoneDataSize*m_u16NumItems; + u32 BodyDataSize = 24 + m_BoneDataSize * m_u16NumItems; tNetPacket.r(m_DeadBodyData, BodyDataSize); }; }; -void CSE_ALifeCreatureActor::UPDATE_Write (NET_Packet &tNetPacket) -{ - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); - tNetPacket.w_u16 (mstate ); - tNetPacket.w_sdir (accel ); - tNetPacket.w_sdir (velocity ); - tNetPacket.w_float (fRadiation ); - tNetPacket.w_u8 (weapon ); +void CSE_ALifeCreatureActor::UPDATE_Write(NET_Packet& tNetPacket) +{ + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); + tNetPacket.w_u16(mstate); + tNetPacket.w_sdir(accel); + tNetPacket.w_sdir(velocity); + tNetPacket.w_float(fRadiation); + tNetPacket.w_u8(weapon); //////////////////////////////////////////////////// - tNetPacket.w_u16 (m_u16NumItems); - if (!m_u16NumItems) return; + tNetPacket.w_u16(m_u16NumItems); + if (!m_u16NumItems) return; - if (m_u16NumItems == 1) - { - tNetPacket.w_u8 ( m_AliveState.enabled ); + if (m_u16NumItems == 1) { + tNetPacket.w_u8(m_AliveState.enabled); - tNetPacket.w_vec3 ( m_AliveState.angular_vel ); - tNetPacket.w_vec3 ( m_AliveState.linear_vel ); + tNetPacket.w_vec3(m_AliveState.angular_vel); + tNetPacket.w_vec3(m_AliveState.linear_vel); - tNetPacket.w_vec3 ( m_AliveState.force ); - tNetPacket.w_vec3 ( m_AliveState.torque ); + tNetPacket.w_vec3(m_AliveState.force); + tNetPacket.w_vec3(m_AliveState.torque); - tNetPacket.w_vec3 ( m_AliveState.position ); + tNetPacket.w_vec3(m_AliveState.position); - tNetPacket.w_float ( m_AliveState.quaternion.x ); - tNetPacket.w_float ( m_AliveState.quaternion.y ); - tNetPacket.w_float ( m_AliveState.quaternion.z ); - tNetPacket.w_float ( m_AliveState.quaternion.w ); + tNetPacket.w_float(m_AliveState.quaternion.x); + tNetPacket.w_float(m_AliveState.quaternion.y); + tNetPacket.w_float(m_AliveState.quaternion.z); + tNetPacket.w_float(m_AliveState.quaternion.w); return; }; ////////////// Export dead body //////////////////// { tNetPacket.w_u8(m_BoneDataSize); - u32 BodyDataSize = 24 + m_BoneDataSize*m_u16NumItems; + u32 BodyDataSize = 24 + m_BoneDataSize * m_u16NumItems; tNetPacket.w(m_DeadBodyData, BodyDataSize); }; } #ifndef XRGAME_EXPORTS -void CSE_ALifeCreatureActor::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeCreatureActor::FillProps(LPCSTR pref, PropItemVec& items) { - inherited1::FillProps (pref,items); - inherited2::FillProps (pref,items); + inherited1::FillProps(pref, items); + inherited2::FillProps(pref, items); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS #ifdef XRGAME_EXPORTS -void CSE_ALifeCreatureActor::spawn_supplies () +void CSE_ALifeCreatureActor::spawn_supplies() { - inherited1::spawn_supplies (); - inherited2::spawn_supplies (); + inherited1::spawn_supplies(); + inherited2::spawn_supplies(); } #endif @@ -1530,421 +1487,423 @@ void CSE_ALifeCreatureActor::spawn_supplies () //////////////////////////////////////////////////////////////////////////// CSE_ALifeCreatureCrow::CSE_ALifeCreatureCrow(LPCSTR caSection) : CSE_ALifeCreatureAbstract(caSection) { - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); - m_flags.set (flUseSwitches,FALSE); - m_flags.set (flSwitchOffline,FALSE); + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) + set_visual(pSettings->r_string(caSection, "visual")); + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); } CSE_ALifeCreatureCrow::~CSE_ALifeCreatureCrow() { } -void CSE_ALifeCreatureCrow::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeCreatureCrow::STATE_Read(NET_Packet& tNetPacket, u16 size) { if (m_wVersion > 20) { - inherited::STATE_Read (tNetPacket,size); - if (m_wVersion < 32) - visual_read (tNetPacket,m_wVersion); + inherited::STATE_Read(tNetPacket, size); + if (m_wVersion < 32) visual_read(tNetPacket, m_wVersion); } } -void CSE_ALifeCreatureCrow::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCreatureCrow::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeCreatureCrow::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeCreatureCrow::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeCreatureCrow::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCreatureCrow::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeCreatureCrow::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeCreatureCrow::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref,values); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeCreatureCrow::used_ai_locations () const +bool CSE_ALifeCreatureCrow::used_ai_locations() const { - return (false); + return (false); } - //////////////////////////////////////////////////////////////////////////// // CSE_ALifeCreaturePhantom //////////////////////////////////////////////////////////////////////////// CSE_ALifeCreaturePhantom::CSE_ALifeCreaturePhantom(LPCSTR caSection) : CSE_ALifeCreatureAbstract(caSection) { - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); - m_flags.set (flUseSwitches,FALSE); - m_flags.set (flSwitchOffline,FALSE); + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) + set_visual(pSettings->r_string(caSection, "visual")); + m_flags.set(flUseSwitches, FALSE); + m_flags.set(flSwitchOffline, FALSE); } CSE_ALifeCreaturePhantom::~CSE_ALifeCreaturePhantom() { } -void CSE_ALifeCreaturePhantom::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeCreaturePhantom::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifeCreaturePhantom::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCreaturePhantom::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifeCreaturePhantom::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeCreaturePhantom::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeCreaturePhantom::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeCreaturePhantom::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeCreaturePhantom::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeCreaturePhantom::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref,values); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -bool CSE_ALifeCreaturePhantom::used_ai_locations () const +bool CSE_ALifeCreaturePhantom::used_ai_locations() const { - return (false); + return (false); } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeMonsterRat //////////////////////////////////////////////////////////////////////////// -CSE_ALifeMonsterRat::CSE_ALifeMonsterRat (LPCSTR caSection) : CSE_ALifeMonsterAbstract(caSection), CSE_ALifeInventoryItem(caSection) +CSE_ALifeMonsterRat::CSE_ALifeMonsterRat(LPCSTR caSection) + : CSE_ALifeMonsterAbstract(caSection), CSE_ALifeInventoryItem(caSection) { - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) + set_visual(pSettings->r_string(caSection, "visual")); // personal charactersitics - fEyeFov = 120; - fEyeRange = 10; - set_health ( 5 ); //fHealth = 5; - fMinSpeed = .5; - fMaxSpeed = 1.5; - fAttackSpeed = 4.0; - fMaxPursuitRadius = 100; - fMaxHomeRadius = 10; + fEyeFov = 120; + fEyeRange = 10; + set_health(5); // fHealth = 5; + fMinSpeed = .5; + fMaxSpeed = 1.5; + fAttackSpeed = 4.0; + fMaxPursuitRadius = 100; + fMaxHomeRadius = 10; // morale - fMoraleSuccessAttackQuant = 20; - fMoraleDeathQuant = -10; - fMoraleFearQuant = -20; - fMoraleRestoreQuant = 10; - u16MoraleRestoreTimeInterval= 3000; - fMoraleMinValue = 0; - fMoraleMaxValue = 100; - fMoraleNormalValue = 66; + fMoraleSuccessAttackQuant = 20; + fMoraleDeathQuant = -10; + fMoraleFearQuant = -20; + fMoraleRestoreQuant = 10; + u16MoraleRestoreTimeInterval = 3000; + fMoraleMinValue = 0; + fMoraleMaxValue = 100; + fMoraleNormalValue = 66; // attack - fHitPower = 10.0; - u16HitInterval = 1500; - fAttackDistance = 0.7f; - fAttackAngle = 45; - fAttackSuccessProbability = 0.5f; + fHitPower = 10.0; + u16HitInterval = 1500; + fAttackDistance = 0.7f; + fAttackAngle = 45; + fAttackSuccessProbability = 0.5f; } -CSE_ALifeMonsterRat::~CSE_ALifeMonsterRat () +CSE_ALifeMonsterRat::~CSE_ALifeMonsterRat() { } -void CSE_ALifeMonsterRat::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeMonsterRat::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket,size); - tNetPacket.r_float (fEyeFov); - tNetPacket.r_float (fEyeRange); - if (m_wVersion <= 5) - set_health (tNetPacket.r_float()); - - tNetPacket.r_float (fMinSpeed); - tNetPacket.r_float (fMaxSpeed); - tNetPacket.r_float (fAttackSpeed); - tNetPacket.r_float (fMaxPursuitRadius); - tNetPacket.r_float (fMaxHomeRadius); + inherited1::STATE_Read(tNetPacket, size); + tNetPacket.r_float(fEyeFov); + tNetPacket.r_float(fEyeRange); + if (m_wVersion <= 5) set_health(tNetPacket.r_float()); + + tNetPacket.r_float(fMinSpeed); + tNetPacket.r_float(fMaxSpeed); + tNetPacket.r_float(fAttackSpeed); + tNetPacket.r_float(fMaxPursuitRadius); + tNetPacket.r_float(fMaxHomeRadius); // morale - tNetPacket.r_float (fMoraleSuccessAttackQuant); - tNetPacket.r_float (fMoraleDeathQuant); - tNetPacket.r_float (fMoraleFearQuant); - tNetPacket.r_float (fMoraleRestoreQuant); - tNetPacket.r_u16 (u16MoraleRestoreTimeInterval); - tNetPacket.r_float (fMoraleMinValue); - tNetPacket.r_float (fMoraleMaxValue); - tNetPacket.r_float (fMoraleNormalValue); + tNetPacket.r_float(fMoraleSuccessAttackQuant); + tNetPacket.r_float(fMoraleDeathQuant); + tNetPacket.r_float(fMoraleFearQuant); + tNetPacket.r_float(fMoraleRestoreQuant); + tNetPacket.r_u16(u16MoraleRestoreTimeInterval); + tNetPacket.r_float(fMoraleMinValue); + tNetPacket.r_float(fMoraleMaxValue); + tNetPacket.r_float(fMoraleNormalValue); // attack - tNetPacket.r_float (fHitPower); - tNetPacket.r_u16 (u16HitInterval); - tNetPacket.r_float (fAttackDistance); - tNetPacket.r_float (fAttackAngle); - tNetPacket.r_float (fAttackSuccessProbability); - inherited2::STATE_Read (tNetPacket,size); -} - -void CSE_ALifeMonsterRat::STATE_Write (NET_Packet &tNetPacket) -{ - inherited1::STATE_Write (tNetPacket); - tNetPacket.w_float (fEyeFov); - tNetPacket.w_float (fEyeRange); - tNetPacket.w_float (fMinSpeed); - tNetPacket.w_float (fMaxSpeed); - tNetPacket.w_float (fAttackSpeed); - tNetPacket.w_float (fMaxPursuitRadius); - tNetPacket.w_float (fMaxHomeRadius); + tNetPacket.r_float(fHitPower); + tNetPacket.r_u16(u16HitInterval); + tNetPacket.r_float(fAttackDistance); + tNetPacket.r_float(fAttackAngle); + tNetPacket.r_float(fAttackSuccessProbability); + inherited2::STATE_Read(tNetPacket, size); +} + +void CSE_ALifeMonsterRat::STATE_Write(NET_Packet& tNetPacket) +{ + inherited1::STATE_Write(tNetPacket); + tNetPacket.w_float(fEyeFov); + tNetPacket.w_float(fEyeRange); + tNetPacket.w_float(fMinSpeed); + tNetPacket.w_float(fMaxSpeed); + tNetPacket.w_float(fAttackSpeed); + tNetPacket.w_float(fMaxPursuitRadius); + tNetPacket.w_float(fMaxHomeRadius); // morale - tNetPacket.w_float (fMoraleSuccessAttackQuant); - tNetPacket.w_float (fMoraleDeathQuant); - tNetPacket.w_float (fMoraleFearQuant); - tNetPacket.w_float (fMoraleRestoreQuant); - tNetPacket.w_u16 (u16MoraleRestoreTimeInterval); - tNetPacket.w_float (fMoraleMinValue); - tNetPacket.w_float (fMoraleMaxValue); - tNetPacket.w_float (fMoraleNormalValue); + tNetPacket.w_float(fMoraleSuccessAttackQuant); + tNetPacket.w_float(fMoraleDeathQuant); + tNetPacket.w_float(fMoraleFearQuant); + tNetPacket.w_float(fMoraleRestoreQuant); + tNetPacket.w_u16(u16MoraleRestoreTimeInterval); + tNetPacket.w_float(fMoraleMinValue); + tNetPacket.w_float(fMoraleMaxValue); + tNetPacket.w_float(fMoraleNormalValue); // attack - tNetPacket.w_float (fHitPower); - tNetPacket.w_u16 (u16HitInterval); - tNetPacket.w_float (fAttackDistance); - tNetPacket.w_float (fAttackAngle); - tNetPacket.w_float (fAttackSuccessProbability); - inherited2::STATE_Write (tNetPacket); + tNetPacket.w_float(fHitPower); + tNetPacket.w_u16(u16HitInterval); + tNetPacket.w_float(fAttackDistance); + tNetPacket.w_float(fAttackAngle); + tNetPacket.w_float(fAttackSuccessProbability); + inherited2::STATE_Write(tNetPacket); } -void CSE_ALifeMonsterRat::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeMonsterRat::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); } -void CSE_ALifeMonsterRat::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeMonsterRat::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); } -CSE_Abstract *CSE_ALifeMonsterRat::init () +CSE_Abstract* CSE_ALifeMonsterRat::init() { - inherited1::init (); - inherited2::init (); - return (base()); + inherited1::init(); + inherited2::init(); + return (base()); } -CSE_Abstract *CSE_ALifeMonsterRat::base () +CSE_Abstract* CSE_ALifeMonsterRat::base() { - return (inherited1::base()); + return (inherited1::base()); } -const CSE_Abstract *CSE_ALifeMonsterRat::base () const +const CSE_Abstract* CSE_ALifeMonsterRat::base() const { - return (inherited1::base()); + return (inherited1::base()); } #ifndef XRGAME_EXPORTS -void CSE_ALifeMonsterRat::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeMonsterRat::FillProps(LPCSTR pref, PropItemVec& items) { - inherited1::FillProps (pref, items); - inherited2::FillProps (pref, items); + inherited1::FillProps(pref, items); + inherited2::FillProps(pref, items); // personal characteristics - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Field of view" ),&fEyeFov, 0,170,10); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Eye range" ),&fEyeRange, 0,300,10); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Minimum speed" ),&fMinSpeed, 0,10,0.1f); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Maximum speed" ),&fMaxSpeed, 0,10,0.1f); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Attack speed" ),&fAttackSpeed, 0,10,0.1f); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Pursuit distance" ),&fMaxPursuitRadius, 0,300,10); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Home distance" ),&fMaxHomeRadius, 0,300,10); - // morale - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Morale", "Success attack quant" ),&fMoraleSuccessAttackQuant, -100,100,5); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Morale", "Death quant" ),&fMoraleDeathQuant, -100,100,5); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Morale", "Fear quant" ),&fMoraleFearQuant, -100,100,5); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Morale", "Restore quant" ),&fMoraleRestoreQuant, -100,100,5); - PHelper().CreateU16 (items, PrepareKey(pref,*s_name,"Morale", "Restore time interval" ),&u16MoraleRestoreTimeInterval, 0,65535,500); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Morale", "Minimum value" ),&fMoraleMinValue, -100,100,5); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Morale", "Maximum value" ),&fMoraleMaxValue, -100,100,5); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Morale", "Normal value" ),&fMoraleNormalValue, -100,100,5); - // attack - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Attack", "Hit power" ),&fHitPower, 0,200,5); - PHelper().CreateU16 (items, PrepareKey(pref,*s_name,"Attack", "Hit interval" ),&u16HitInterval, 0,65535,500); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Attack", "Distance" ),&fAttackDistance, 0,300,10); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Attack", "Maximum angle" ),&fAttackAngle, 0,180,10); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Attack", "Success probability" ),&fAttackSuccessProbability, 0,100,1); -} -#endif // #ifndef XRGAME_EXPORTS - -bool CSE_ALifeMonsterRat::bfUseful () -{ - return (!smart_cast(this) && (get_health() <= EPS_L)); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Field of view"), &fEyeFov, 0, 170, 10); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Eye range"), &fEyeRange, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Minimum speed"), &fMinSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Maximum speed"), &fMaxSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Attack speed"), &fAttackSpeed, 0, 10, 0.1f); + PHelper().CreateFloat( + items, PrepareKey(pref, *s_name, "Personal", "Pursuit distance"), &fMaxPursuitRadius, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Home distance"), &fMaxHomeRadius, 0, 300, 10); + // morale + PHelper().CreateFloat( + items, PrepareKey(pref, *s_name, "Morale", "Success attack quant"), &fMoraleSuccessAttackQuant, -100, 100, 5); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Morale", "Death quant"), &fMoraleDeathQuant, -100, 100, 5); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Morale", "Fear quant"), &fMoraleFearQuant, -100, 100, 5); + PHelper().CreateFloat( + items, PrepareKey(pref, *s_name, "Morale", "Restore quant"), &fMoraleRestoreQuant, -100, 100, 5); + PHelper().CreateU16(items, PrepareKey(pref, *s_name, "Morale", "Restore time interval"), + &u16MoraleRestoreTimeInterval, 0, 65535, 500); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Morale", "Minimum value"), &fMoraleMinValue, -100, 100, 5); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Morale", "Maximum value"), &fMoraleMaxValue, -100, 100, 5); + PHelper().CreateFloat( + items, PrepareKey(pref, *s_name, "Morale", "Normal value"), &fMoraleNormalValue, -100, 100, 5); + // attack + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Hit power"), &fHitPower, 0, 200, 5); + PHelper().CreateU16(items, PrepareKey(pref, *s_name, "Attack", "Hit interval"), &u16HitInterval, 0, 65535, 500); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Distance"), &fAttackDistance, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Maximum angle"), &fAttackAngle, 0, 180, 10); + PHelper().CreateFloat( + items, PrepareKey(pref, *s_name, "Attack", "Success probability"), &fAttackSuccessProbability, 0, 100, 1); +} +#endif // #ifndef XRGAME_EXPORTS + +bool CSE_ALifeMonsterRat::bfUseful() +{ + return (!smart_cast(this) && (get_health() <= EPS_L)); } //////////////////////////////////////////////////////////////////////////// // CSE_ALifeMonsterZombie //////////////////////////////////////////////////////////////////////////// -CSE_ALifeMonsterZombie::CSE_ALifeMonsterZombie (LPCSTR caSection) : CSE_ALifeMonsterAbstract(caSection) +CSE_ALifeMonsterZombie::CSE_ALifeMonsterZombie(LPCSTR caSection) : CSE_ALifeMonsterAbstract(caSection) { - if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection,"visual")) - set_visual (pSettings->r_string(caSection,"visual")); + if (pSettings->section_exist(caSection) && pSettings->line_exist(caSection, "visual")) + set_visual(pSettings->r_string(caSection, "visual")); // personal charactersitics - fEyeFov = 120; - fEyeRange = 30; - set_health ( 200 ); //fHealth = 200; - fMinSpeed = 1.5; - fMaxSpeed = 1.75; - fAttackSpeed = 2.0; - fMaxPursuitRadius = 100; - fMaxHomeRadius = 30; + fEyeFov = 120; + fEyeRange = 30; + set_health(200); // fHealth = 200; + fMinSpeed = 1.5; + fMaxSpeed = 1.75; + fAttackSpeed = 2.0; + fMaxPursuitRadius = 100; + fMaxHomeRadius = 30; // attack - fHitPower = 20.0; - u16HitInterval = 1000; - fAttackDistance = 1.0f; - fAttackAngle = 15; + fHitPower = 20.0; + u16HitInterval = 1000; + fAttackDistance = 1.0f; + fAttackAngle = 15; } CSE_ALifeMonsterZombie::~CSE_ALifeMonsterZombie() { } -void CSE_ALifeMonsterZombie::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeMonsterZombie::STATE_Read(NET_Packet& tNetPacket, u16 size) { // inherited properties - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); // personal characteristics - tNetPacket.r_float (fEyeFov); - tNetPacket.r_float (fEyeRange); - if (m_wVersion <= 5) - set_health ( tNetPacket.r_float() ); - - tNetPacket.r_float (fMinSpeed); - tNetPacket.r_float (fMaxSpeed); - tNetPacket.r_float (fAttackSpeed); - tNetPacket.r_float (fMaxPursuitRadius); - tNetPacket.r_float (fMaxHomeRadius); + tNetPacket.r_float(fEyeFov); + tNetPacket.r_float(fEyeRange); + if (m_wVersion <= 5) set_health(tNetPacket.r_float()); + + tNetPacket.r_float(fMinSpeed); + tNetPacket.r_float(fMaxSpeed); + tNetPacket.r_float(fAttackSpeed); + tNetPacket.r_float(fMaxPursuitRadius); + tNetPacket.r_float(fMaxHomeRadius); // attack - tNetPacket.r_float (fHitPower); - tNetPacket.r_u16 (u16HitInterval); - tNetPacket.r_float (fAttackDistance); - tNetPacket.r_float (fAttackAngle); + tNetPacket.r_float(fHitPower); + tNetPacket.r_u16(u16HitInterval); + tNetPacket.r_float(fAttackDistance); + tNetPacket.r_float(fAttackAngle); } -void CSE_ALifeMonsterZombie::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeMonsterZombie::STATE_Write(NET_Packet& tNetPacket) { // inherited properties - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); // personal characteristics - tNetPacket.w_float (fEyeFov); - tNetPacket.w_float (fEyeRange); - tNetPacket.w_float (fMinSpeed); - tNetPacket.w_float (fMaxSpeed); - tNetPacket.w_float (fAttackSpeed); - tNetPacket.w_float (fMaxPursuitRadius); - tNetPacket.w_float (fMaxHomeRadius); + tNetPacket.w_float(fEyeFov); + tNetPacket.w_float(fEyeRange); + tNetPacket.w_float(fMinSpeed); + tNetPacket.w_float(fMaxSpeed); + tNetPacket.w_float(fAttackSpeed); + tNetPacket.w_float(fMaxPursuitRadius); + tNetPacket.w_float(fMaxHomeRadius); // attack - tNetPacket.w_float (fHitPower); - tNetPacket.w_u16 (u16HitInterval); - tNetPacket.w_float (fAttackDistance); - tNetPacket.w_float (fAttackAngle); + tNetPacket.w_float(fHitPower); + tNetPacket.w_u16(u16HitInterval); + tNetPacket.w_float(fAttackDistance); + tNetPacket.w_float(fAttackAngle); } -void CSE_ALifeMonsterZombie::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeMonsterZombie::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifeMonsterZombie::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeMonsterZombie::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeMonsterZombie::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeMonsterZombie::FillProps(LPCSTR pref, PropItemVec& items) { - inherited::FillProps (pref, items); + inherited::FillProps(pref, items); // personal characteristics - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Field of view" ),&fEyeFov, 0,170,10); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Eye range" ),&fEyeRange, 0,300,10); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Minimum speed" ),&fMinSpeed, 0,10,0.1f); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Maximum speed" ),&fMaxSpeed, 0,10,0.1f); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Attack speed" ),&fAttackSpeed, 0,10,0.1f); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Pursuit distance" ),&fMaxPursuitRadius, 0,300,10); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Personal", "Home distance" ),&fMaxHomeRadius, 0,300,10); - // attack - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Attack", "Hit power" ),&fHitPower, 0,200,5); - PHelper().CreateU16 (items, PrepareKey(pref,*s_name,"Attack", "Hit interval" ),&u16HitInterval, 0,65535,500); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Attack", "Distance" ),&fAttackDistance, 0,300,10); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"Attack", "Maximum angle" ),&fAttackAngle, 0,100,1); -} -#endif // #ifndef XRGAME_EXPORTS + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Field of view"), &fEyeFov, 0, 170, 10); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Eye range"), &fEyeRange, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Minimum speed"), &fMinSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Maximum speed"), &fMaxSpeed, 0, 10, 0.1f); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Attack speed"), &fAttackSpeed, 0, 10, 0.1f); + PHelper().CreateFloat( + items, PrepareKey(pref, *s_name, "Personal", "Pursuit distance"), &fMaxPursuitRadius, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Personal", "Home distance"), &fMaxHomeRadius, 0, 300, 10); + // attack + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Hit power"), &fHitPower, 0, 200, 5); + PHelper().CreateU16(items, PrepareKey(pref, *s_name, "Attack", "Hit interval"), &u16HitInterval, 0, 65535, 500); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Distance"), &fAttackDistance, 0, 300, 10); + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "Attack", "Maximum angle"), &fAttackAngle, 0, 100, 1); +} +#endif // #ifndef XRGAME_EXPORTS ////////////////////////////////////////////////////////////////////////// // CSE_ALifeMonsterBase ////////////////////////////////////////////////////////////////////////// -CSE_ALifeMonsterBase::CSE_ALifeMonsterBase (LPCSTR caSection) : CSE_ALifeMonsterAbstract(caSection),CSE_PHSkeleton(caSection) +CSE_ALifeMonsterBase::CSE_ALifeMonsterBase(LPCSTR caSection) + : CSE_ALifeMonsterAbstract(caSection), CSE_PHSkeleton(caSection) { - set_visual (pSettings->r_string(caSection,"visual")); - m_spec_object_id = 0xffff; - + set_visual(pSettings->r_string(caSection, "visual")); + m_spec_object_id = 0xffff; } CSE_ALifeMonsterBase::~CSE_ALifeMonsterBase() { } -void CSE_ALifeMonsterBase::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeMonsterBase::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket,size); - if(m_wVersion>=68) - inherited2::STATE_Read (tNetPacket,size); + inherited1::STATE_Read(tNetPacket, size); + if (m_wVersion >= 68) inherited2::STATE_Read(tNetPacket, size); - if (m_wVersion>=109) - tNetPacket.r_u16 (m_spec_object_id); + if (m_wVersion >= 109) tNetPacket.r_u16(m_spec_object_id); } -void CSE_ALifeMonsterBase::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeMonsterBase::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); - - tNetPacket.w_u16 (m_spec_object_id); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); + + tNetPacket.w_u16(m_spec_object_id); } -void CSE_ALifeMonsterBase::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeMonsterBase::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); } -void CSE_ALifeMonsterBase::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeMonsterBase::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); } -void CSE_ALifeMonsterBase::load(NET_Packet &tNetPacket) +void CSE_ALifeMonsterBase::load(NET_Packet& tNetPacket) { inherited1::load(tNetPacket); inherited2::load(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeMonsterBase::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeMonsterBase::FillProps(LPCSTR pref, PropItemVec& values) { - inherited1::FillProps (pref,values); - inherited2::FillProps (pref,values); + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS ////////////////////////////////////////////////////////////////////////// // CSE_ALifePsyDogPhantom ////////////////////////////////////////////////////////////////////////// -CSE_ALifePsyDogPhantom::CSE_ALifePsyDogPhantom (LPCSTR caSection) : CSE_ALifeMonsterBase(caSection) +CSE_ALifePsyDogPhantom::CSE_ALifePsyDogPhantom(LPCSTR caSection) : CSE_ALifeMonsterBase(caSection) { } @@ -1952,37 +1911,38 @@ CSE_ALifePsyDogPhantom::~CSE_ALifePsyDogPhantom() { } -void CSE_ALifePsyDogPhantom::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifePsyDogPhantom::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited::STATE_Read (tNetPacket,size); + inherited::STATE_Read(tNetPacket, size); } -void CSE_ALifePsyDogPhantom::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifePsyDogPhantom::STATE_Write(NET_Packet& tNetPacket) { - inherited::STATE_Write (tNetPacket); + inherited::STATE_Write(tNetPacket); } -void CSE_ALifePsyDogPhantom::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifePsyDogPhantom::UPDATE_Read(NET_Packet& tNetPacket) { - inherited::UPDATE_Read (tNetPacket); + inherited::UPDATE_Read(tNetPacket); } -void CSE_ALifePsyDogPhantom::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifePsyDogPhantom::UPDATE_Write(NET_Packet& tNetPacket) { - inherited::UPDATE_Write (tNetPacket); + inherited::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifePsyDogPhantom::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifePsyDogPhantom::FillProps(LPCSTR pref, PropItemVec& values) { - inherited::FillProps (pref,values); + inherited::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS ////////////////////////////////////////////////////////////////////////// // CSE_ALifeHumanAbstract ////////////////////////////////////////////////////////////////////////// -CSE_ALifeHumanAbstract::CSE_ALifeHumanAbstract(LPCSTR caSection) : CSE_ALifeTraderAbstract(caSection), CSE_ALifeMonsterAbstract(caSection) +CSE_ALifeHumanAbstract::CSE_ALifeHumanAbstract(LPCSTR caSection) + : CSE_ALifeTraderAbstract(caSection), CSE_ALifeMonsterAbstract(caSection) { } @@ -1990,224 +1950,224 @@ CSE_ALifeHumanAbstract::~CSE_ALifeHumanAbstract() { } -CALifeMonsterBrain *CSE_ALifeHumanAbstract::create_brain () +CALifeMonsterBrain* CSE_ALifeHumanAbstract::create_brain() { - m_brain = new CALifeHumanBrain(this); - return (m_brain); + m_brain = new CALifeHumanBrain(this); + return (m_brain); } -CSE_Abstract *CSE_ALifeHumanAbstract::init () +CSE_Abstract* CSE_ALifeHumanAbstract::init() { - inherited1::init (); - inherited2::init (); + inherited1::init(); + inherited2::init(); - return (base()); + return (base()); } -CSE_Abstract *CSE_ALifeHumanAbstract::base () +CSE_Abstract* CSE_ALifeHumanAbstract::base() { - return (inherited2::base()); + return (inherited2::base()); } -const CSE_Abstract *CSE_ALifeHumanAbstract::base () const +const CSE_Abstract* CSE_ALifeHumanAbstract::base() const { - return (inherited2::base()); + return (inherited2::base()); } -void CSE_ALifeHumanAbstract::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeHumanAbstract::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); - brain().on_state_write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); + brain().on_state_write(tNetPacket); } -void CSE_ALifeHumanAbstract::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeHumanAbstract::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket, size); - inherited2::STATE_Read (tNetPacket, size); - brain().on_state_read (tNetPacket); - if ((m_wVersion >= 110) && (m_wVersion < 112)) - tNetPacket.r (&m_smart_terrain_id,sizeof(m_smart_terrain_id)); + inherited1::STATE_Read(tNetPacket, size); + inherited2::STATE_Read(tNetPacket, size); + brain().on_state_read(tNetPacket); + if ((m_wVersion >= 110) && (m_wVersion < 112)) tNetPacket.r(&m_smart_terrain_id, sizeof(m_smart_terrain_id)); } -void CSE_ALifeHumanAbstract::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeHumanAbstract::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); }; -void CSE_ALifeHumanAbstract::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeHumanAbstract::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); - + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); + if (m_wVersion < 110) { - tNetPacket.r_u32 (); - tNetPacket.r_u32 (); - tNetPacket.r_u32 (); + tNetPacket.r_u32(); + tNetPacket.r_u32(); + tNetPacket.r_u32(); } }; #ifndef XRGAME_EXPORTS -void CSE_ALifeHumanAbstract::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_ALifeHumanAbstract::FillProps(LPCSTR pref, PropItemVec& items) { - inherited1::FillProps (pref,items); - inherited2::FillProps (pref,items); - PHelper().CreateFlag32 (items, PrepareKey(pref,*s_name,"Group behaviour"), &m_flags, flGroupBehaviour); + inherited1::FillProps(pref, items); + inherited2::FillProps(pref, items); + PHelper().CreateFlag32(items, PrepareKey(pref, *s_name, "Group behaviour"), &m_flags, flGroupBehaviour); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS ////////////////////////////////////////////////////////////////////////// // CSE_ALifeHumanStalker ////////////////////////////////////////////////////////////////////////// -CSE_ALifeHumanStalker::CSE_ALifeHumanStalker(LPCSTR caSection) : CSE_ALifeHumanAbstract(caSection),CSE_PHSkeleton(caSection) +CSE_ALifeHumanStalker::CSE_ALifeHumanStalker(LPCSTR caSection) + : CSE_ALifeHumanAbstract(caSection), CSE_PHSkeleton(caSection) { - m_trader_flags.set (eTraderFlagInfiniteAmmo,TRUE); - m_start_dialog = ""; + m_trader_flags.set(eTraderFlagInfiniteAmmo, TRUE); + m_start_dialog = ""; } CSE_ALifeHumanStalker::~CSE_ALifeHumanStalker() { } -void CSE_ALifeHumanStalker::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeHumanStalker::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - inherited2::STATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); + inherited2::STATE_Write(tNetPacket); } -void CSE_ALifeHumanStalker::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeHumanStalker::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket, size); - - if (m_wVersion > 67) - inherited2::STATE_Read (tNetPacket, size); + inherited1::STATE_Read(tNetPacket, size); + + if (m_wVersion > 67) inherited2::STATE_Read(tNetPacket, size); - if ((m_wVersion > 90) && (m_wVersion < 111)) - tNetPacket.r_u8 (); + if ((m_wVersion > 90) && (m_wVersion < 111)) tNetPacket.r_u8(); } -void CSE_ALifeHumanStalker::UPDATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeHumanStalker::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); - inherited2::UPDATE_Write (tNetPacket); - tNetPacket.w_stringZ (m_start_dialog); + inherited1::UPDATE_Write(tNetPacket); + inherited2::UPDATE_Write(tNetPacket); + tNetPacket.w_stringZ(m_start_dialog); } -void CSE_ALifeHumanStalker::UPDATE_Read (NET_Packet &tNetPacket) +void CSE_ALifeHumanStalker::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); - inherited2::UPDATE_Read (tNetPacket); - tNetPacket.r_stringZ (m_start_dialog); + inherited1::UPDATE_Read(tNetPacket); + inherited2::UPDATE_Read(tNetPacket); + tNetPacket.r_stringZ(m_start_dialog); } -void CSE_ALifeHumanStalker::load (NET_Packet &tNetPacket) +void CSE_ALifeHumanStalker::load(NET_Packet& tNetPacket) { - inherited1::load (tNetPacket); - inherited2::load (tNetPacket); + inherited1::load(tNetPacket); + inherited2::load(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_ALifeHumanStalker::FillProps (LPCSTR pref, PropItemVec& values) +void CSE_ALifeHumanStalker::FillProps(LPCSTR pref, PropItemVec& values) { - inherited1::FillProps (pref,values); - inherited2::FillProps (pref,values); + inherited1::FillProps(pref, values); + inherited2::FillProps(pref, values); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS ////////////////////////////////////////////////////////////////////////// // CSE_ALifeOnlineOfflineGroup ////////////////////////////////////////////////////////////////////////// -CSE_ALifeOnlineOfflineGroup::CSE_ALifeOnlineOfflineGroup (LPCSTR caSection) : CSE_ALifeDynamicObject(caSection), CSE_ALifeSchedulable(caSection) +CSE_ALifeOnlineOfflineGroup::CSE_ALifeOnlineOfflineGroup(LPCSTR caSection) + : CSE_ALifeDynamicObject(caSection), CSE_ALifeSchedulable(caSection) { } -CSE_Abstract *CSE_ALifeOnlineOfflineGroup::base () +CSE_Abstract* CSE_ALifeOnlineOfflineGroup::base() { - return (this); + return (this); } -const CSE_Abstract *CSE_ALifeOnlineOfflineGroup::base () const +const CSE_Abstract* CSE_ALifeOnlineOfflineGroup::base() const { - return (this); + return (this); } -CSE_Abstract *CSE_ALifeOnlineOfflineGroup::init () +CSE_Abstract* CSE_ALifeOnlineOfflineGroup::init() { - inherited1::init (); - inherited2::init (); + inherited1::init(); + inherited2::init(); #ifdef XRGAME_EXPORTS - m_brain = new CALifeOnlineOfflineGroupBrain(this); + m_brain = new CALifeOnlineOfflineGroupBrain(this); #endif - VERIFY (m_members.empty()); - m_flags.set (flUsedAI_Locations,FALSE); + VERIFY(m_members.empty()); + m_flags.set(flUsedAI_Locations, FALSE); - return (this); + return (this); } -CSE_ALifeOnlineOfflineGroup::~CSE_ALifeOnlineOfflineGroup () +CSE_ALifeOnlineOfflineGroup::~CSE_ALifeOnlineOfflineGroup() { #ifdef XRGAME_EXPORTS - while ( !m_members.empty() ) - unregister_member( (*m_members.begin()).first ); - xr_delete (m_brain); + while (!m_members.empty()) + unregister_member((*m_members.begin()).first); + xr_delete(m_brain); #endif } #ifdef XRGAME_EXPORTS -CALifeSmartTerrainTask* CSE_ALifeOnlineOfflineGroup::get_current_task () +CALifeSmartTerrainTask* CSE_ALifeOnlineOfflineGroup::get_current_task() { NODEFAULT; #ifdef DEBUG return 0; -#endif // #ifdef DEBUG +#endif // #ifdef DEBUG } -#endif // #ifdef XRGAME_EXPORTS +#endif // #ifdef XRGAME_EXPORTS -void CSE_ALifeOnlineOfflineGroup::STATE_Write (NET_Packet &tNetPacket) +void CSE_ALifeOnlineOfflineGroup::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); + inherited1::STATE_Write(tNetPacket); #if 1 - tNetPacket.w_u32 (m_members.size()); + tNetPacket.w_u32(m_members.size()); - MEMBERS::iterator I = m_members.begin(); - MEMBERS::iterator E = m_members.end(); - for ( ; I != E; ++I) - save_data ((*I).first,tNetPacket); + MEMBERS::iterator I = m_members.begin(); + MEMBERS::iterator E = m_members.end(); + for (; I != E; ++I) + save_data((*I).first, tNetPacket); #endif } -void CSE_ALifeOnlineOfflineGroup::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_ALifeOnlineOfflineGroup::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket, size); + inherited1::STATE_Read(tNetPacket, size); #if 1 - u32 container_size = tNetPacket.r_u32(); - for (u32 i=0; i m_CheckedCharacters; xr_vector m_DefaultCharacters; -public: - CSE_ALifeTraderAbstract (LPCSTR caSection); - virtual ~CSE_ALifeTraderAbstract (); +public: + CSE_ALifeTraderAbstract(LPCSTR caSection); + virtual ~CSE_ALifeTraderAbstract(); // we need this to prevent virtual inheritance :-( - virtual CSE_Abstract *base () = 0; - virtual const CSE_Abstract *base () const = 0; - virtual CSE_Abstract *init (); - virtual CSE_Abstract *cast_abstract () {return 0;}; - virtual CSE_ALifeTraderAbstract *cast_trader_abstract () {return this;}; + virtual CSE_Abstract* base() = 0; + virtual const CSE_Abstract* base() const = 0; + virtual CSE_Abstract* init(); + virtual CSE_Abstract* cast_abstract() { return 0; }; + virtual CSE_ALifeTraderAbstract* cast_trader_abstract() { return this; }; // end of the virtual inheritance dependant code - void __stdcall OnChangeProfile (PropValue* sender); + void __stdcall OnChangeProfile(PropValue* sender); #ifdef XRGAME_EXPORTS - virtual void add_online (const bool &update_registries); - virtual void add_offline (const xr_vector &saved_children, const bool &update_registries); -#if 0//def DEBUG + virtual void add_online(const bool& update_registries); + virtual void add_offline(const xr_vector& saved_children, const bool& update_registries); +#if 0 // def DEBUG bool check_inventory_consistency (); #endif - void vfInitInventory (); - virtual void spawn_supplies (); + void vfInitInventory(); + virtual void spawn_supplies(); #endif - virtual void UPDATE_Read (NET_Packet& P); - virtual void UPDATE_Write (NET_Packet& P); - virtual void STATE_Read (NET_Packet& P, u16 size); - virtual void STATE_Write (NET_Packet& P); + virtual void UPDATE_Read(NET_Packet& P); + virtual void UPDATE_Write(NET_Packet& P); + virtual void STATE_Read(NET_Packet& P, u16 size); + virtual void STATE_Write(NET_Packet& P); SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeTrader : - public CSE_ALifeDynamicObjectVisual, - public CSE_ALifeTraderAbstract +class CSE_ALifeTrader : public CSE_ALifeDynamicObjectVisual, public CSE_ALifeTraderAbstract { using inherited1 = CSE_ALifeDynamicObjectVisual; using inherited2 = CSE_ALifeTraderAbstract; -public: - CSE_ALifeTrader (LPCSTR caSection); - virtual ~CSE_ALifeTrader (); - virtual bool interactive () const; - virtual CSE_Abstract *init (); - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual bool natural_weapon () const {return false;} - virtual bool natural_detector () const {return false;} +public: + CSE_ALifeTrader(LPCSTR caSection); + virtual ~CSE_ALifeTrader(); + virtual bool interactive() const; + virtual CSE_Abstract* init(); + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual bool natural_weapon() const { return false; } + virtual bool natural_detector() const { return false; } #ifdef XRGAME_EXPORTS - u32 dwfGetItemCost (CSE_ALifeInventoryItem *tpALifeInventoryItem); - virtual void spawn_supplies (); - virtual void add_online (const bool &update_registries); - virtual void add_offline (const xr_vector &saved_children, const bool &update_registries); + u32 dwfGetItemCost(CSE_ALifeInventoryItem* tpALifeInventoryItem); + virtual void spawn_supplies(); + virtual void add_online(const bool& update_registries); + virtual void add_offline(const xr_vector& saved_children, const bool& update_registries); #endif #ifdef DEBUG - virtual bool match_configuration () const; + virtual bool match_configuration() const; #endif - virtual CSE_Abstract *cast_abstract () {return this;}; - virtual CSE_ALifeTraderAbstract *cast_trader_abstract () {return this;}; - virtual CSE_ALifeTrader *cast_trader () {return this;}; + virtual CSE_Abstract* cast_abstract() { return this; }; + virtual CSE_ALifeTraderAbstract* cast_trader_abstract() { return this; }; + virtual CSE_ALifeTrader* cast_trader() { return this; }; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -134,16 +135,17 @@ class CSE_ALifeTrader : class CSE_ALifeCustomZone : public CSE_ALifeSpaceRestrictor { using inherited = CSE_ALifeSpaceRestrictor; + public: -//. f32 m_maxPower; - ALife::EHitType m_tHitType; - u32 m_owner_id; - u32 m_enabled_time; - u32 m_disabled_time; - u32 m_start_time_shift; - - CSE_ALifeCustomZone (LPCSTR caSection); - virtual ~CSE_ALifeCustomZone (); + //. f32 m_maxPower; + ALife::EHitType m_tHitType; + u32 m_owner_id; + u32 m_enabled_time; + u32 m_disabled_time; + u32 m_start_time_shift; + + CSE_ALifeCustomZone(LPCSTR caSection); + virtual ~CSE_ALifeCustomZone(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -154,29 +156,31 @@ class CSE_ALifeCustomZone : public CSE_ALifeSpaceRestrictor class CSE_ALifeAnomalousZone : public CSE_ALifeCustomZone { typedef CSE_ALifeCustomZone inherited; + public: - CSE_ALifeItemWeapon *m_tpCurrentBestWeapon; - float m_offline_interactive_radius; - u32 m_artefact_position_offset; - u16 m_artefact_spawn_count; - - CSE_ALifeAnomalousZone (LPCSTR caSection); - virtual ~CSE_ALifeAnomalousZone (); - virtual CSE_Abstract *init (); - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual CSE_Abstract *cast_abstract () {return this;}; - virtual CSE_ALifeAnomalousZone *cast_anomalous_zone () {return this;}; - virtual u32 ef_anomaly_type () const; - virtual u32 ef_weapon_type () const; - virtual u32 ef_creature_type () const; + CSE_ALifeItemWeapon* m_tpCurrentBestWeapon; + float m_offline_interactive_radius; + u32 m_artefact_position_offset; + u16 m_artefact_spawn_count; + + CSE_ALifeAnomalousZone(LPCSTR caSection); + virtual ~CSE_ALifeAnomalousZone(); + virtual CSE_Abstract* init(); + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual CSE_Abstract* cast_abstract() { return this; }; + virtual CSE_ALifeAnomalousZone* cast_anomalous_zone() { return this; }; + virtual u32 ef_anomaly_type() const; + virtual u32 ef_weapon_type() const; + virtual u32 ef_creature_type() const; #ifdef XRGAME_EXPORTS - virtual void on_spawn (); - virtual CSE_ALifeItemWeapon *tpfGetBestWeapon (ALife::EHitType &tHitType, float &fHitPower); - virtual ALife::EMeetActionType tfGetActionType (CSE_ALifeSchedulable *tpALifeSchedulable, int iGroupIndex, bool bMutualDetection); - virtual bool bfActive (); - virtual CSE_ALifeDynamicObject *tpfGetBestDetector (); - virtual bool keep_saved_data_anyway () const; + virtual void on_spawn(); + virtual CSE_ALifeItemWeapon* tpfGetBestWeapon(ALife::EHitType& tHitType, float& fHitPower); + virtual ALife::EMeetActionType tfGetActionType( + CSE_ALifeSchedulable* tpALifeSchedulable, int iGroupIndex, bool bMutualDetection); + virtual bool bfActive(); + virtual CSE_ALifeDynamicObject* tpfGetBestDetector(); + virtual bool keep_saved_data_anyway() const; #endif virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -185,16 +189,15 @@ class CSE_ALifeAnomalousZone : public CSE_ALifeCustomZone SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeTorridZone : - public CSE_ALifeCustomZone, - public CSE_Motion +class CSE_ALifeTorridZone : public CSE_ALifeCustomZone, public CSE_Motion { using inherited1 = CSE_ALifeCustomZone; using inherited2 = CSE_Motion; + public: - CSE_ALifeTorridZone (LPCSTR caSection); - virtual ~CSE_ALifeTorridZone (); - virtual CSE_Motion* __stdcall motion (); + CSE_ALifeTorridZone(LPCSTR caSection); + virtual ~CSE_ALifeTorridZone(); + virtual CSE_Motion* __stdcall motion(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -202,80 +205,80 @@ class CSE_ALifeTorridZone : SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeZoneVisual : - public CSE_ALifeAnomalousZone, - public CSE_Visual +class CSE_ALifeZoneVisual : public CSE_ALifeAnomalousZone, public CSE_Visual { using inherited1 = CSE_ALifeAnomalousZone; using inherited2 = CSE_Visual; + public: -shared_str attack_animation; -CSE_ALifeZoneVisual (LPCSTR caSection); -virtual ~CSE_ALifeZoneVisual (); -virtual CSE_Visual* __stdcall visual (); -virtual void UPDATE_Read(NET_Packet& P); -virtual void UPDATE_Write(NET_Packet& P); -virtual void STATE_Read(NET_Packet& P, u16 size); -virtual void STATE_Write(NET_Packet& P); -SERVER_ENTITY_EDITOR_METHODS + shared_str attack_animation; + CSE_ALifeZoneVisual(LPCSTR caSection); + virtual ~CSE_ALifeZoneVisual(); + virtual CSE_Visual* __stdcall visual(); + virtual void UPDATE_Read(NET_Packet& P); + virtual void UPDATE_Write(NET_Packet& P); + virtual void STATE_Read(NET_Packet& P, u16 size); + virtual void STATE_Write(NET_Packet& P); + SERVER_ENTITY_EDITOR_METHODS }; class CSE_ALifeCreatureAbstract : public CSE_ALifeDynamicObjectVisual { using inherited = CSE_ALifeDynamicObjectVisual; + private: - float fHealth; - ALife::_OBJECT_ID m_killer_id; + float fHealth; + ALife::_OBJECT_ID m_killer_id; + public: - u8 s_team; - u8 s_squad; - u8 s_group; - - float m_fMorale; - float m_fAccuracy; - float m_fIntelligence; - - u32 timestamp; // server(game) timestamp - u8 flags; - float o_model; // model yaw - SRotation o_torso; // torso in world coords - bool m_bDeathIsProcessed; - - xr_vector m_dynamic_out_restrictions; - xr_vector m_dynamic_in_restrictions; - - u32 m_ef_creature_type; - u32 m_ef_weapon_type; - u32 m_ef_detector_type; - - ALife::_TIME_ID m_game_death_time; - - CSE_ALifeCreatureAbstract(LPCSTR caSection); - virtual ~CSE_ALifeCreatureAbstract(); - virtual u8 g_team (); - virtual u8 g_squad (); - virtual u8 g_group (); - - IC float get_health () const { return fHealth;} - IC ALife::_OBJECT_ID get_killer_id () const { return m_killer_id; } - - void set_health (float const health_value); - void set_killer_id (ALife::_OBJECT_ID const killer_id); - - IC bool g_Alive () const { return (get_health() > 0.f);} - virtual bool used_ai_locations () const; - virtual bool can_switch_online () const; - virtual bool can_switch_offline () const; - virtual u32 ef_creature_type () const; - virtual u32 ef_weapon_type () const; - virtual u32 ef_detector_type () const; - virtual CSE_ALifeCreatureAbstract *cast_creature_abstract () {return this;}; + u8 s_team; + u8 s_squad; + u8 s_group; + + float m_fMorale; + float m_fAccuracy; + float m_fIntelligence; + + u32 timestamp; // server(game) timestamp + u8 flags; + float o_model; // model yaw + SRotation o_torso; // torso in world coords + bool m_bDeathIsProcessed; + + xr_vector m_dynamic_out_restrictions; + xr_vector m_dynamic_in_restrictions; + + u32 m_ef_creature_type; + u32 m_ef_weapon_type; + u32 m_ef_detector_type; + + ALife::_TIME_ID m_game_death_time; + + CSE_ALifeCreatureAbstract(LPCSTR caSection); + virtual ~CSE_ALifeCreatureAbstract(); + virtual u8 g_team(); + virtual u8 g_squad(); + virtual u8 g_group(); + + IC float get_health() const { return fHealth; } + IC ALife::_OBJECT_ID get_killer_id() const { return m_killer_id; } + void set_health(float const health_value); + void set_killer_id(ALife::_OBJECT_ID const killer_id); + + IC bool g_Alive() const { return (get_health() > 0.f); } + virtual bool used_ai_locations() const; + virtual bool can_switch_online() const; + virtual bool can_switch_offline() const; + virtual u32 ef_creature_type() const; + virtual u32 ef_weapon_type() const; + virtual u32 ef_detector_type() const; + virtual CSE_ALifeCreatureAbstract* cast_creature_abstract() { return this; }; #ifdef XRGAME_EXPORTS - virtual void on_death (CSE_Abstract *killer); - virtual void on_spawn (); + virtual void on_death(CSE_Abstract* killer); + virtual void on_spawn(); #endif #ifdef DEBUG - virtual bool match_configuration () const; + virtual bool match_configuration() const; #endif virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -284,88 +287,91 @@ class CSE_ALifeCreatureAbstract : public CSE_ALifeDynamicObjectVisual SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeMonsterAbstract : - public CSE_ALifeCreatureAbstract, - public CSE_ALifeSchedulable, - public CMovementManagerHolder +class CSE_ALifeMonsterAbstract : public CSE_ALifeCreatureAbstract, + public CSE_ALifeSchedulable, + public CMovementManagerHolder { using inherited1 = CSE_ALifeCreatureAbstract; using inherited2 = CSE_ALifeSchedulable; using inherited3 = CMovementManagerHolder; + public: + float m_fMaxHealthValue; + float m_fRetreatThreshold; + float m_fEyeRange; + float m_fHitPower; + ALife::EHitType m_tHitType; + shared_str m_out_space_restrictors; + shared_str m_in_space_restrictors; + svector m_fpImmunityFactors; + + ALife::_OBJECT_ID m_smart_terrain_id; - float m_fMaxHealthValue; - float m_fRetreatThreshold; - float m_fEyeRange; - float m_fHitPower; - ALife::EHitType m_tHitType; - shared_str m_out_space_restrictors; - shared_str m_in_space_restrictors; - svector m_fpImmunityFactors; - - ALife::_OBJECT_ID m_smart_terrain_id; - //--------------------------------------------------------- // bool if monster under smart terrain and currently executes task // if monster on the way then (m_smart_terrain_id != 0xffff) && (!m_task_reached) - bool m_task_reached; + bool m_task_reached; //--------------------------------------------------------- - int m_rank; + int m_rank; + + ALife::_TIME_ID m_stay_after_death_time_interval; - ALife::_TIME_ID m_stay_after_death_time_interval; public: - ALife::_OBJECT_ID m_group_id; + ALife::_OBJECT_ID m_group_id; public: - CSE_ALifeMonsterAbstract(LPCSTR caSection); - virtual ~CSE_ALifeMonsterAbstract(); - IC float g_MaxHealth () const { return m_fMaxHealthValue; } - virtual CSE_Abstract *init (); - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual CSE_Abstract *cast_abstract () {return this;}; - virtual CSE_ALifeSchedulable *cast_schedulable () {return this;}; - virtual CSE_ALifeMonsterAbstract*cast_monster_abstract () {return this;}; - - IC CALifeMonsterBrain &brain () const {VERIFY(m_brain); return(*m_brain);} - virtual CALifeMonsterBrain *create_brain (); - virtual u32 ef_creature_type () const; - virtual u32 ef_weapon_type () const; - virtual u32 ef_detector_type () const; - - IC int Rank (){return m_rank;} - + CSE_ALifeMonsterAbstract(LPCSTR caSection); + virtual ~CSE_ALifeMonsterAbstract(); + IC float g_MaxHealth() const { return m_fMaxHealthValue; } + virtual CSE_Abstract* init(); + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual CSE_Abstract* cast_abstract() { return this; }; + virtual CSE_ALifeSchedulable* cast_schedulable() { return this; }; + virtual CSE_ALifeMonsterAbstract* cast_monster_abstract() { return this; }; + IC CALifeMonsterBrain& brain() const + { + VERIFY(m_brain); + return (*m_brain); + } + virtual CALifeMonsterBrain* create_brain(); + virtual u32 ef_creature_type() const; + virtual u32 ef_weapon_type() const; + virtual u32 ef_detector_type() const; + + IC int Rank() { return m_rank; } #ifdef XRGAME_EXPORTS - void kill (); - bool has_detector (); -#endif // #ifdef XRGAME_EXPORTS + void kill(); + bool has_detector(); +#endif // #ifdef XRGAME_EXPORTS #ifndef XRGAME_EXPORTS - virtual void update () {}; + virtual void update(){}; #else - virtual void update (); - virtual CSE_ALifeItemWeapon *tpfGetBestWeapon (ALife::EHitType &tHitType, float &fHitPower); - virtual ALife::EMeetActionType tfGetActionType (CSE_ALifeSchedulable *tpALifeSchedulable, int iGroupIndex, bool bMutualDetection); - virtual bool bfActive (); - virtual CSE_ALifeDynamicObject *tpfGetBestDetector (); - virtual void vfDetachAll (bool bFictitious = false) {}; - void vfCheckForPopulationChanges(); - virtual void add_online (const bool &update_registries); - virtual void add_offline (const xr_vector &saved_children, const bool &update_registries); - virtual void on_register (); - virtual void on_unregister (); - virtual Fvector draw_level_position () const; - virtual bool redundant () const; - virtual void on_location_change () const; - virtual CSE_ALifeDynamicObject const& get_object () const { return *this; } - virtual CSE_ALifeDynamicObject& get_object () { return *this; } + virtual void update(); + virtual CSE_ALifeItemWeapon* tpfGetBestWeapon(ALife::EHitType& tHitType, float& fHitPower); + virtual ALife::EMeetActionType tfGetActionType( + CSE_ALifeSchedulable* tpALifeSchedulable, int iGroupIndex, bool bMutualDetection); + virtual bool bfActive(); + virtual CSE_ALifeDynamicObject* tpfGetBestDetector(); + virtual void vfDetachAll(bool bFictitious = false){}; + void vfCheckForPopulationChanges(); + virtual void add_online(const bool& update_registries); + virtual void add_offline(const xr_vector& saved_children, const bool& update_registries); + virtual void on_register(); + virtual void on_unregister(); + virtual Fvector draw_level_position() const; + virtual bool redundant() const; + virtual void on_location_change() const; + virtual CSE_ALifeDynamicObject const& get_object() const { return *this; } + virtual CSE_ALifeDynamicObject& get_object() { return *this; } #endif - virtual bool need_update (CSE_ALifeDynamicObject *object); + virtual bool need_update(CSE_ALifeDynamicObject* object); private: - CALifeMonsterBrain *m_brain; + CALifeMonsterBrain* m_brain; public: virtual void UPDATE_Read(NET_Packet& P); @@ -375,53 +381,51 @@ class CSE_ALifeMonsterAbstract : SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeCreatureActor : - public CSE_ALifeCreatureAbstract, - public CSE_ALifeTraderAbstract, - public CSE_PHSkeleton +class CSE_ALifeCreatureActor : public CSE_ALifeCreatureAbstract, public CSE_ALifeTraderAbstract, public CSE_PHSkeleton { using inherited1 = CSE_ALifeCreatureAbstract; using inherited2 = CSE_ALifeTraderAbstract; using inherited3 = CSE_PHSkeleton; -public: - u16 mstate; - Fvector accel; - Fvector velocity; -// float fArmor; - float fRadiation; - u8 weapon; + +public: + u16 mstate; + Fvector accel; + Fvector velocity; + // float fArmor; + float fRadiation; + u8 weapon; /////////////////////////////////////////// - u16 m_u16NumItems; - u16 m_holderID; -// DEF_DEQUE (PH_STATES, SPHNetState); - SPHNetState m_AliveState; -// PH_STATES m_DeadStates; + u16 m_u16NumItems; + u16 m_holderID; + // DEF_DEQUE (PH_STATES, SPHNetState); + SPHNetState m_AliveState; + // PH_STATES m_DeadStates; // ñòàòè÷åñêèé ìàññèâ - 6 float(âåêòîðà ïðåäåëîâ êâàíòèçàöèè) + m_u16NumItems*(7 u8) (ïîçèöèÿ è ïîâîðîò êîñòè) - u8 m_BoneDataSize; - char m_DeadBodyData[1024]; + u8 m_BoneDataSize; + char m_DeadBodyData[1024]; /////////////////////////////////////////// - CSE_ALifeCreatureActor (LPCSTR caSection); - virtual ~CSE_ALifeCreatureActor (); - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual CSE_Abstract *init (); - virtual void load (NET_Packet &tNetPacket); - virtual bool can_save ()const{return true;} - virtual bool natural_weapon () const {return false;} - virtual bool natural_detector () const {return false;} + CSE_ALifeCreatureActor(LPCSTR caSection); + virtual ~CSE_ALifeCreatureActor(); + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual CSE_Abstract* init(); + virtual void load(NET_Packet& tNetPacket); + virtual bool can_save() const { return true; } + virtual bool natural_weapon() const { return false; } + virtual bool natural_detector() const { return false; } #ifdef XRGAME_EXPORTS - virtual void spawn_supplies (); - virtual void add_online (const bool &update_registries); - virtual void add_offline (const xr_vector &saved_children, const bool &update_registries); + virtual void spawn_supplies(); + virtual void add_online(const bool& update_registries); + virtual void add_offline(const xr_vector& saved_children, const bool& update_registries); #endif #ifdef DEBUG - virtual bool match_configuration () const; + virtual bool match_configuration() const; #endif - virtual CSE_Abstract *cast_abstract () {return this;}; - virtual CSE_ALifeTraderAbstract *cast_trader_abstract () {return this;}; + virtual CSE_Abstract* cast_abstract() { return this; }; + virtual CSE_ALifeTraderAbstract* cast_trader_abstract() { return this; }; public: - virtual BOOL Net_Relevant (); + virtual BOOL Net_Relevant(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -432,10 +436,11 @@ class CSE_ALifeCreatureActor : class CSE_ALifeCreatureCrow : public CSE_ALifeCreatureAbstract { using inherited = CSE_ALifeCreatureAbstract; + public: - CSE_ALifeCreatureCrow (LPCSTR caSection); - virtual ~CSE_ALifeCreatureCrow (); - virtual bool used_ai_locations () const; + CSE_ALifeCreatureCrow(LPCSTR caSection); + virtual ~CSE_ALifeCreatureCrow(); + virtual bool used_ai_locations() const; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -446,10 +451,11 @@ class CSE_ALifeCreatureCrow : public CSE_ALifeCreatureAbstract class CSE_ALifeCreaturePhantom : public CSE_ALifeCreatureAbstract { using inherited = CSE_ALifeCreatureAbstract; + public: - CSE_ALifeCreaturePhantom (LPCSTR caSection); - virtual ~CSE_ALifeCreaturePhantom (); - virtual bool used_ai_locations () const; + CSE_ALifeCreaturePhantom(LPCSTR caSection); + virtual ~CSE_ALifeCreaturePhantom(); + virtual bool used_ai_locations() const; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -457,45 +463,44 @@ class CSE_ALifeCreaturePhantom : public CSE_ALifeCreatureAbstract SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeMonsterRat : - public CSE_ALifeMonsterAbstract, - public CSE_ALifeInventoryItem +class CSE_ALifeMonsterRat : public CSE_ALifeMonsterAbstract, public CSE_ALifeInventoryItem { using inherited1 = CSE_ALifeMonsterAbstract; using inherited2 = CSE_ALifeInventoryItem; + public: // Personal characteristics: - float fEyeFov; - float fEyeRange; - float fMinSpeed; - float fMaxSpeed; - float fAttackSpeed; - float fMaxPursuitRadius; - float fMaxHomeRadius; + float fEyeFov; + float fEyeRange; + float fMinSpeed; + float fMaxSpeed; + float fAttackSpeed; + float fMaxPursuitRadius; + float fMaxHomeRadius; // morale - float fMoraleSuccessAttackQuant; - float fMoraleDeathQuant; - float fMoraleFearQuant; - float fMoraleRestoreQuant; - u16 u16MoraleRestoreTimeInterval; - float fMoraleMinValue; - float fMoraleMaxValue; - float fMoraleNormalValue; + float fMoraleSuccessAttackQuant; + float fMoraleDeathQuant; + float fMoraleFearQuant; + float fMoraleRestoreQuant; + u16 u16MoraleRestoreTimeInterval; + float fMoraleMinValue; + float fMoraleMaxValue; + float fMoraleNormalValue; // attack - float fHitPower; - u16 u16HitInterval; - float fAttackDistance; - float fAttackAngle; - float fAttackSuccessProbability; - - CSE_ALifeMonsterRat (LPCSTR caSection); // constructor for variable initialization - virtual ~CSE_ALifeMonsterRat(); - virtual bool bfUseful(); - virtual CSE_Abstract *init (); - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual CSE_Abstract *cast_abstract () {return this;}; - virtual CSE_ALifeInventoryItem *cast_inventory_item () {return this;}; + float fHitPower; + u16 u16HitInterval; + float fAttackDistance; + float fAttackAngle; + float fAttackSuccessProbability; + + CSE_ALifeMonsterRat(LPCSTR caSection); // constructor for variable initialization + virtual ~CSE_ALifeMonsterRat(); + virtual bool bfUseful(); + virtual CSE_Abstract* init(); + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual CSE_Abstract* cast_abstract() { return this; }; + virtual CSE_ALifeInventoryItem* cast_inventory_item() { return this; }; virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -506,23 +511,24 @@ class CSE_ALifeMonsterRat : class CSE_ALifeMonsterZombie : public CSE_ALifeMonsterAbstract { using inherited = CSE_ALifeMonsterAbstract; + public: // Personal characteristics: - float fEyeFov; - float fEyeRange; - float fMinSpeed; - float fMaxSpeed; - float fAttackSpeed; - float fMaxPursuitRadius; - float fMaxHomeRadius; + float fEyeFov; + float fEyeRange; + float fMinSpeed; + float fMaxSpeed; + float fAttackSpeed; + float fMaxPursuitRadius; + float fMaxHomeRadius; // attack - float fHitPower; - u16 u16HitInterval; - float fAttackDistance; - float fAttackAngle; + float fHitPower; + u16 u16HitInterval; + float fAttackDistance; + float fAttackAngle; - CSE_ALifeMonsterZombie (LPCSTR caSection); // constructor for variable initialization - virtual ~CSE_ALifeMonsterZombie (); + CSE_ALifeMonsterZombie(LPCSTR caSection); // constructor for variable initialization + virtual ~CSE_ALifeMonsterZombie(); virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -530,26 +536,25 @@ class CSE_ALifeMonsterZombie : public CSE_ALifeMonsterAbstract SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeMonsterBase : - public CSE_ALifeMonsterAbstract, - public CSE_PHSkeleton +class CSE_ALifeMonsterBase : public CSE_ALifeMonsterAbstract, public CSE_PHSkeleton { using inherited1 = CSE_ALifeMonsterAbstract; using inherited2 = CSE_PHSkeleton; + public: - u16 m_spec_object_id; - - CSE_ALifeMonsterBase (LPCSTR caSection); // constructor for variable initialization - virtual ~CSE_ALifeMonsterBase (); - virtual void load (NET_Packet &tNetPacket); - virtual CSE_Abstract *cast_abstract () {return this;} - virtual void spawn_supplies (LPCSTR){} - virtual void spawn_supplies (){} + u16 m_spec_object_id; + + CSE_ALifeMonsterBase(LPCSTR caSection); // constructor for variable initialization + virtual ~CSE_ALifeMonsterBase(); + virtual void load(NET_Packet& tNetPacket); + virtual CSE_Abstract* cast_abstract() { return this; } + virtual void spawn_supplies(LPCSTR) {} + virtual void spawn_supplies() {} #ifdef XRGAME_EXPORTS - virtual void on_spawn (); - virtual void add_online (const bool &update_registries); - virtual void add_offline (const xr_vector &saved_children, const bool &update_registries); -#endif // XRGAME_EXPORTS + virtual void on_spawn(); + virtual void add_online(const bool& update_registries); + virtual void add_offline(const xr_vector& saved_children, const bool& update_registries); +#endif // XRGAME_EXPORTS virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -560,11 +565,12 @@ class CSE_ALifeMonsterBase : class CSE_ALifePsyDogPhantom : public CSE_ALifeMonsterBase { using inherited = CSE_ALifeMonsterBase; + public: - CSE_ALifePsyDogPhantom (LPCSTR caSection); // constructor for variable initialization - virtual ~CSE_ALifePsyDogPhantom (); - virtual CSE_Abstract *cast_abstract () {return this;} - virtual bool bfActive () {return false;} + CSE_ALifePsyDogPhantom(LPCSTR caSection); // constructor for variable initialization + virtual ~CSE_ALifePsyDogPhantom(); + virtual CSE_Abstract* cast_abstract() { return this; } + virtual bool bfActive() { return false; } virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -572,45 +578,50 @@ class CSE_ALifePsyDogPhantom : public CSE_ALifeMonsterBase SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeHumanAbstract : - public CSE_ALifeTraderAbstract, - public CSE_ALifeMonsterAbstract +class CSE_ALifeHumanAbstract : public CSE_ALifeTraderAbstract, public CSE_ALifeMonsterAbstract { using inherited1 = CSE_ALifeTraderAbstract; using inherited2 = CSE_ALifeMonsterAbstract; + public: - CSE_ALifeHumanAbstract (LPCSTR caSection); - virtual ~CSE_ALifeHumanAbstract (); - virtual CSE_Abstract *init (); - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual CSE_Abstract *cast_abstract () {return this;}; - virtual CSE_ALifeTraderAbstract *cast_trader_abstract () {return this;}; - virtual CSE_ALifeHumanAbstract *cast_human_abstract () {return this;}; - virtual bool natural_weapon () const {return false;} - virtual bool natural_detector () const {return false;} - IC CALifeHumanBrain &brain () const {VERIFY(m_brain); return(*m_brain);} - virtual CALifeMonsterBrain *create_brain (); + CSE_ALifeHumanAbstract(LPCSTR caSection); + virtual ~CSE_ALifeHumanAbstract(); + virtual CSE_Abstract* init(); + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual CSE_Abstract* cast_abstract() { return this; }; + virtual CSE_ALifeTraderAbstract* cast_trader_abstract() { return this; }; + virtual CSE_ALifeHumanAbstract* cast_human_abstract() { return this; }; + virtual bool natural_weapon() const { return false; } + virtual bool natural_detector() const { return false; } + IC CALifeHumanBrain& brain() const + { + VERIFY(m_brain); + return (*m_brain); + } + virtual CALifeMonsterBrain* create_brain(); #ifdef XRGAME_EXPORTS - virtual void update (); - virtual CSE_ALifeItemWeapon *tpfGetBestWeapon (ALife::EHitType &tHitType, float &fHitPower); - virtual bool bfPerformAttack (); - virtual void vfUpdateWeaponAmmo (); - virtual void vfProcessItems (); - virtual void vfAttachItems (ALife::ETakeType tTakeType = ALife::eTakeTypeAll); - virtual ALife::EMeetActionType tfGetActionType (CSE_ALifeSchedulable *tpALifeSchedulable, int iGroupIndex, bool bMutualDetection); - virtual CSE_ALifeDynamicObject *tpfGetBestDetector (); - virtual void vfDetachAll (bool bFictitious = false); - virtual void spawn_supplies (); - virtual void on_register (); - virtual void on_unregister (); - virtual void add_online (const bool &update_registries); - virtual void add_offline (const xr_vector &saved_children, const bool &update_registries); + virtual void update(); + virtual CSE_ALifeItemWeapon* tpfGetBestWeapon(ALife::EHitType& tHitType, float& fHitPower); + virtual bool bfPerformAttack(); + virtual void vfUpdateWeaponAmmo(); + virtual void vfProcessItems(); + virtual void vfAttachItems(ALife::ETakeType tTakeType = ALife::eTakeTypeAll); + virtual ALife::EMeetActionType tfGetActionType( + CSE_ALifeSchedulable* tpALifeSchedulable, int iGroupIndex, bool bMutualDetection); + virtual CSE_ALifeDynamicObject* tpfGetBestDetector(); + virtual void vfDetachAll(bool bFictitious = false); + virtual void spawn_supplies(); + virtual void on_register(); + virtual void on_unregister(); + virtual void add_online(const bool& update_registries); + virtual void add_offline(const xr_vector& saved_children, const bool& update_registries); #endif private: - CALifeHumanBrain *m_brain; + CALifeHumanBrain* m_brain; + public: virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); @@ -619,19 +630,18 @@ class CSE_ALifeHumanAbstract : SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeHumanStalker : - public CSE_ALifeHumanAbstract, - public CSE_PHSkeleton +class CSE_ALifeHumanStalker : public CSE_ALifeHumanAbstract, public CSE_PHSkeleton { using inherited1 = CSE_ALifeHumanAbstract; using inherited2 = CSE_PHSkeleton; + public: - shared_str m_start_dialog; + shared_str m_start_dialog; - CSE_ALifeHumanStalker (LPCSTR caSection); - virtual ~CSE_ALifeHumanStalker (); - virtual void load (NET_Packet &tNetPacket); - virtual CSE_Abstract *cast_abstract () {return this;} + CSE_ALifeHumanStalker(LPCSTR caSection); + virtual ~CSE_ALifeHumanStalker(); + virtual void load(NET_Packet& tNetPacket); + virtual CSE_Abstract* cast_abstract() { return this; } virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); virtual void STATE_Read(NET_Packet& P, u16 size); @@ -639,74 +649,79 @@ class CSE_ALifeHumanStalker : SERVER_ENTITY_EDITOR_METHODS }; -class CSE_ALifeOnlineOfflineGroup : - public CSE_ALifeDynamicObject, - public CSE_ALifeSchedulable, - public CMovementManagerHolder +class CSE_ALifeOnlineOfflineGroup : public CSE_ALifeDynamicObject, + public CSE_ALifeSchedulable, + public CMovementManagerHolder { using inherited1 = CSE_ALifeDynamicObject; using inherited2 = CSE_ALifeSchedulable; using inherited3 = CMovementManagerHolder; + public: - CSE_ALifeOnlineOfflineGroup (LPCSTR caSection); - virtual ~CSE_ALifeOnlineOfflineGroup(); - virtual CSE_Abstract *base (); - virtual const CSE_Abstract *base () const; - virtual CSE_Abstract *init (); - virtual CSE_Abstract *cast_abstract () {return this;}; - virtual CSE_ALifeSchedulable *cast_schedulable () {return this;}; - virtual CSE_ALifeOnlineOfflineGroup *cast_online_offline_group () {return this;}; + CSE_ALifeOnlineOfflineGroup(LPCSTR caSection); + virtual ~CSE_ALifeOnlineOfflineGroup(); + virtual CSE_Abstract* base(); + virtual const CSE_Abstract* base() const; + virtual CSE_Abstract* init(); + virtual CSE_Abstract* cast_abstract() { return this; }; + virtual CSE_ALifeSchedulable* cast_schedulable() { return this; }; + virtual CSE_ALifeOnlineOfflineGroup* cast_online_offline_group() { return this; }; #ifdef XRGAME_EXPORTS - virtual CALifeSmartTerrainTask *get_current_task (); -#endif // #ifdef XRGAME_EXPORTS + virtual CALifeSmartTerrainTask* get_current_task(); +#endif // #ifdef XRGAME_EXPORTS public: - typedef CSE_ALifeMonsterAbstract MEMBER; - typedef AssociativeVector MEMBERS; + typedef CSE_ALifeMonsterAbstract MEMBER; + typedef AssociativeVector MEMBERS; private: - MEMBERS m_members; + MEMBERS m_members; #ifdef XRGAME_EXPORTS private: - CALifeOnlineOfflineGroupBrain *m_brain; + CALifeOnlineOfflineGroupBrain* m_brain; public: - IC CALifeOnlineOfflineGroupBrain &brain () const {VERIFY(m_brain); return(*m_brain);} + IC CALifeOnlineOfflineGroupBrain& brain() const + { + VERIFY(m_brain); + return (*m_brain); + } public: - virtual CSE_ALifeItemWeapon *tpfGetBestWeapon (ALife::EHitType &tHitType, float &fHitPower); - virtual ALife::EMeetActionType tfGetActionType (CSE_ALifeSchedulable *tpALifeSchedulable, int iGroupIndex, bool bMutualDetection); - virtual bool bfActive (); - virtual CSE_ALifeDynamicObject *tpfGetBestDetector (); - virtual void update (); - virtual bool need_update (CSE_ALifeDynamicObject *object); - void register_member (ALife::_OBJECT_ID member_id); - void unregister_member (ALife::_OBJECT_ID member_id); - void notify_on_member_death (MEMBER *member); - MEMBER *member (ALife::_OBJECT_ID member_id, bool no_assert = false); - virtual void on_before_register (); - void on_after_game_load (); - virtual bool synchronize_location (); - virtual void try_switch_online (); - virtual void try_switch_offline (); - virtual void switch_online (); - virtual void switch_offline (); - virtual bool redundant () const; - virtual void on_location_change () const; - virtual CSE_ALifeDynamicObject const& get_object () const { return *this; } - virtual CSE_ALifeDynamicObject& get_object () { return *this; } - ALife::_OBJECT_ID commander_id (); - MEMBERS const& squad_members () const; - u32 npc_count () const; - void clear_location_types (); - void add_location_type (LPCSTR mask); - void force_change_position (Fvector position); - virtual void on_failed_switch_online (); + virtual CSE_ALifeItemWeapon* tpfGetBestWeapon(ALife::EHitType& tHitType, float& fHitPower); + virtual ALife::EMeetActionType tfGetActionType( + CSE_ALifeSchedulable* tpALifeSchedulable, int iGroupIndex, bool bMutualDetection); + virtual bool bfActive(); + virtual CSE_ALifeDynamicObject* tpfGetBestDetector(); + virtual void update(); + virtual bool need_update(CSE_ALifeDynamicObject* object); + void register_member(ALife::_OBJECT_ID member_id); + void unregister_member(ALife::_OBJECT_ID member_id); + void notify_on_member_death(MEMBER* member); + MEMBER* member(ALife::_OBJECT_ID member_id, bool no_assert = false); + virtual void on_before_register(); + void on_after_game_load(); + virtual bool synchronize_location(); + virtual void try_switch_online(); + virtual void try_switch_offline(); + virtual void switch_online(); + virtual void switch_offline(); + virtual bool redundant() const; + virtual void on_location_change() const; + virtual CSE_ALifeDynamicObject const& get_object() const { return *this; } + virtual CSE_ALifeDynamicObject& get_object() { return *this; } + ALife::_OBJECT_ID commander_id(); + MEMBERS const& squad_members() const; + u32 npc_count() const; + void clear_location_types(); + void add_location_type(LPCSTR mask); + void force_change_position(Fvector position); + virtual void on_failed_switch_online(); #else public: - virtual void update () {}; + virtual void update(){}; #endif public: virtual void UPDATE_Read(NET_Packet& P); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp index 72d5ff5f063..7c8a6af4ed9 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script.cpp @@ -7,78 +7,41 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -LPCSTR profile_name_script (CSE_ALifeTraderAbstract* ta) +LPCSTR profile_name_script(CSE_ALifeTraderAbstract* ta) { - return *ta->character_profile(); + return *ta->character_profile(); } -SCRIPT_EXPORT(CSE_ALifeTraderAbstract, (), -{ - module(luaState) - [ - class_ - ("cse_alife_trader_abstract") -// .def( constructor()) - .def("community", &CSE_ALifeTraderAbstract::CommunityName) - .def("profile_name", &profile_name_script) - .def("rank", &CSE_ALifeTraderAbstract::Rank) - .def("reputation", &CSE_ALifeTraderAbstract::Reputation) - ]; +SCRIPT_EXPORT(CSE_ALifeTraderAbstract, (), { + module(luaState)[class_("cse_alife_trader_abstract") + // .def( constructor()) + .def("community", &CSE_ALifeTraderAbstract::CommunityName) + .def("profile_name", &profile_name_script) + .def("rank", &CSE_ALifeTraderAbstract::Rank) + .def("reputation", &CSE_ALifeTraderAbstract::Reputation)]; }); -SCRIPT_EXPORT(CSE_ALifeTrader, (CSE_ALifeDynamicObjectVisual, CSE_ALifeTraderAbstract), -{ - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifeTrader, - "cse_alife_trader", - CSE_ALifeDynamicObjectVisual, - CSE_ALifeTraderAbstract - ) - ]; +SCRIPT_EXPORT(CSE_ALifeTrader, (CSE_ALifeDynamicObjectVisual, CSE_ALifeTraderAbstract), { + module(luaState)[luabind_class_dynamic_alife2( + CSE_ALifeTrader, "cse_alife_trader", CSE_ALifeDynamicObjectVisual, CSE_ALifeTraderAbstract)]; }); -SCRIPT_EXPORT(CSE_ALifeCustomZone, (CSE_ALifeDynamicObject, CSE_Shape), -{ - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifeCustomZone, - "cse_custom_zone", - CSE_ALifeDynamicObject, - CSE_Shape - ) - ]; +SCRIPT_EXPORT(CSE_ALifeCustomZone, (CSE_ALifeDynamicObject, CSE_Shape), { + module(luaState)[luabind_class_dynamic_alife2( + CSE_ALifeCustomZone, "cse_custom_zone", CSE_ALifeDynamicObject, CSE_Shape)]; }); -SCRIPT_EXPORT(CSE_ALifeAnomalousZone, (CSE_ALifeCustomZone), -{ - module(luaState) - [ - luabind_class_dynamic_alife1( - CSE_ALifeAnomalousZone, - "cse_anomalous_zone", - CSE_ALifeCustomZone - ) - ]; +SCRIPT_EXPORT(CSE_ALifeAnomalousZone, (CSE_ALifeCustomZone), { + module(luaState)[luabind_class_dynamic_alife1(CSE_ALifeAnomalousZone, "cse_anomalous_zone", CSE_ALifeCustomZone)]; }); -SCRIPT_EXPORT(CSE_ALifeMonsterRat, (CSE_ALifeMonsterAbstract, CSE_ALifeInventoryItem), -{ - module(luaState) - [ - luabind_class_monster2( - CSE_ALifeMonsterRat, - "cse_alife_monster_rat", - CSE_ALifeMonsterAbstract, - CSE_ALifeInventoryItem - ) - ]; +SCRIPT_EXPORT(CSE_ALifeMonsterRat, (CSE_ALifeMonsterAbstract, CSE_ALifeInventoryItem), { + module(luaState)[luabind_class_monster2( + CSE_ALifeMonsterRat, "cse_alife_monster_rat", CSE_ALifeMonsterAbstract, CSE_ALifeInventoryItem)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script2.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script2.cpp index 2c4ef144ee6..87852133be4 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script2.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script2.cpp @@ -7,58 +7,28 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -SCRIPT_EXPORT(CSE_ALifeCreatureCrow, (CSE_ALifeCreatureAbstract), -{ - module(luaState) - [ - luabind_class_creature1( - CSE_ALifeCreatureCrow, - "cse_alife_creature_crow", - CSE_ALifeCreatureAbstract - ) - ]; +SCRIPT_EXPORT(CSE_ALifeCreatureCrow, (CSE_ALifeCreatureAbstract), { + module( + luaState)[luabind_class_creature1(CSE_ALifeCreatureCrow, "cse_alife_creature_crow", CSE_ALifeCreatureAbstract)]; }); -SCRIPT_EXPORT(CSE_ALifeMonsterZombie, (CSE_ALifeMonsterAbstract), -{ - module(luaState) - [ - luabind_class_monster1( - CSE_ALifeMonsterZombie, - "cse_alife_monster_zombie", - CSE_ALifeMonsterAbstract - ) - ]; +SCRIPT_EXPORT(CSE_ALifeMonsterZombie, (CSE_ALifeMonsterAbstract), { + module( + luaState)[luabind_class_monster1(CSE_ALifeMonsterZombie, "cse_alife_monster_zombie", CSE_ALifeMonsterAbstract)]; }); -SCRIPT_EXPORT(CSE_ALifeMonsterBase, (CSE_ALifeMonsterAbstract, CSE_PHSkeleton), -{ - module(luaState) - [ - luabind_class_monster2( - CSE_ALifeMonsterBase, - "cse_alife_monster_base", - CSE_ALifeMonsterAbstract, - CSE_PHSkeleton - ) - ]; +SCRIPT_EXPORT(CSE_ALifeMonsterBase, (CSE_ALifeMonsterAbstract, CSE_PHSkeleton), { + module(luaState)[luabind_class_monster2( + CSE_ALifeMonsterBase, "cse_alife_monster_base", CSE_ALifeMonsterAbstract, CSE_PHSkeleton)]; }); -SCRIPT_EXPORT(CSE_ALifeHumanStalker, (CSE_ALifeHumanAbstract, CSE_PHSkeleton), -{ - module(luaState) - [ - luabind_class_monster2( - CSE_ALifeHumanStalker, - "cse_alife_human_stalker", - CSE_ALifeHumanAbstract, - CSE_PHSkeleton - ) - ]; +SCRIPT_EXPORT(CSE_ALifeHumanStalker, (CSE_ALifeHumanAbstract, CSE_PHSkeleton), { + module(luaState)[luabind_class_monster2( + CSE_ALifeHumanStalker, "cse_alife_human_stalker", CSE_ALifeHumanAbstract, CSE_PHSkeleton)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script4.cpp b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script4.cpp index 91ca8c7e53c..eebb6fb9459 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script4.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_Monsters_script4.cpp @@ -6,142 +6,121 @@ // Description : Server monsters for ALife simulator, script export, the second part //////////////////////////////////////////////////////////////////////////// +#include "alife_human_brain.h" #include "pch_script.h" #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "alife_human_brain.h" #ifdef XRGAME_EXPORTS #include "relation_registry.h" -#endif // #ifdef XRGAME_EXPORTS +#endif // #ifdef XRGAME_EXPORTS #include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -CALifeMonsterBrain *monster_brain (CSE_ALifeMonsterAbstract *monster) +CALifeMonsterBrain* monster_brain(CSE_ALifeMonsterAbstract* monster) { - THROW (monster); - return (&monster->brain()); + THROW(monster); + return (&monster->brain()); } -CALifeHumanBrain *human_brain (CSE_ALifeHumanAbstract *human) +CALifeHumanBrain* human_brain(CSE_ALifeHumanAbstract* human) { - THROW (human); - return (&human->brain()); + THROW(human); + return (&human->brain()); } -void clear_smart_terrain (CSE_ALifeMonsterAbstract *monster) +void clear_smart_terrain(CSE_ALifeMonsterAbstract* monster) { - THROW (monster); - monster->m_smart_terrain_id = 0xffff; + THROW(monster); + monster->m_smart_terrain_id = 0xffff; } -void smart_terrain_task_activate (CSE_ALifeMonsterAbstract *monster) +void smart_terrain_task_activate(CSE_ALifeMonsterAbstract* monster) { - THROW (monster); - monster->m_task_reached = true; + THROW(monster); + monster->m_task_reached = true; } -void smart_terrain_task_deactivate (CSE_ALifeMonsterAbstract *monster) +void smart_terrain_task_deactivate(CSE_ALifeMonsterAbstract* monster) { - THROW (monster); - monster->m_task_reached = false; + THROW(monster); + monster->m_task_reached = false; } - -ALife::_OBJECT_ID smart_terrain_id (CSE_ALifeMonsterAbstract *monster) +ALife::_OBJECT_ID smart_terrain_id(CSE_ALifeMonsterAbstract* monster) { - THROW (monster); - return (monster->m_smart_terrain_id); + THROW(monster); + return (monster->m_smart_terrain_id); } #ifdef XRGAME_EXPORTS -float travel_speed (CSE_ALifeMonsterAbstract *self) +float travel_speed(CSE_ALifeMonsterAbstract* self) { - return (self->m_fGoingSpeed); + return (self->m_fGoingSpeed); } -void travel_speed2 (CSE_ALifeMonsterAbstract *self, float travel_speed) +void travel_speed2(CSE_ALifeMonsterAbstract* self, float travel_speed) { - self->m_fGoingSpeed = travel_speed; + self->m_fGoingSpeed = travel_speed; } -float current_level_travel_speed (CSE_ALifeMonsterAbstract *self) +float current_level_travel_speed(CSE_ALifeMonsterAbstract* self) { - return (self->m_fCurrentLevelGoingSpeed); + return (self->m_fCurrentLevelGoingSpeed); } -void current_level_travel_speed2 (CSE_ALifeMonsterAbstract *self, float travel_speed) +void current_level_travel_speed2(CSE_ALifeMonsterAbstract* self, float travel_speed) { - self->m_fCurrentLevelGoingSpeed = travel_speed; + self->m_fCurrentLevelGoingSpeed = travel_speed; } -void ForceSetGoodwill(CSE_ALifeMonsterAbstract *self, int goodwill, ALife::_OBJECT_ID pWhoToSet) +void ForceSetGoodwill(CSE_ALifeMonsterAbstract* self, int goodwill, ALife::_OBJECT_ID pWhoToSet) { - RELATION_REGISTRY().ForceSetGoodwill(self->ID, pWhoToSet, goodwill); + RELATION_REGISTRY().ForceSetGoodwill(self->ID, pWhoToSet, goodwill); } -#endif // #ifdef XRGAME_EXPORTS +#endif // #ifdef XRGAME_EXPORTS -static void CSE_ALifeMonsterAbstract_Export(lua_State *luaState) +static void CSE_ALifeMonsterAbstract_Export(lua_State* luaState) { - module(luaState) - [ - luabind_class_monster2( - CSE_ALifeMonsterAbstract, - "cse_alife_monster_abstract", - CSE_ALifeCreatureAbstract, - CSE_ALifeSchedulable - ) - .def("smart_terrain_id", &smart_terrain_id) - .def_readonly("group_id", &CSE_ALifeMonsterAbstract::m_group_id) - .def_readwrite("m_smart_terrain_id", &CSE_ALifeMonsterAbstract::m_smart_terrain_id) - .def("clear_smart_terrain", &clear_smart_terrain) - .def("brain", &monster_brain) - .def("rank", &CSE_ALifeMonsterAbstract::Rank) - .def("smart_terrain_task_activate", &smart_terrain_task_activate) - .def("smart_terrain_task_deactivate", &smart_terrain_task_deactivate) + module(luaState)[luabind_class_monster2( + CSE_ALifeMonsterAbstract, "cse_alife_monster_abstract", CSE_ALifeCreatureAbstract, CSE_ALifeSchedulable) + .def("smart_terrain_id", &smart_terrain_id) + .def_readonly("group_id", &CSE_ALifeMonsterAbstract::m_group_id) + .def_readwrite("m_smart_terrain_id", &CSE_ALifeMonsterAbstract::m_smart_terrain_id) + .def("clear_smart_terrain", &clear_smart_terrain) + .def("brain", &monster_brain) + .def("rank", &CSE_ALifeMonsterAbstract::Rank) + .def("smart_terrain_task_activate", &smart_terrain_task_activate) + .def("smart_terrain_task_deactivate", &smart_terrain_task_deactivate) #ifdef XRGAME_EXPORTS - .def("travel_speed", &travel_speed) - .def("travel_speed", &travel_speed2) - .def("current_level_travel_speed", ¤t_level_travel_speed) - .def("current_level_travel_speed", ¤t_level_travel_speed2) - .def("kill", &CSE_ALifeMonsterAbstract::kill) - .def("has_detector", &CSE_ALifeMonsterAbstract::has_detector) - .def("force_set_goodwill", &ForceSetGoodwill) + .def("travel_speed", &travel_speed) + .def("travel_speed", &travel_speed2) + .def("current_level_travel_speed", ¤t_level_travel_speed) + .def("current_level_travel_speed", ¤t_level_travel_speed2) + .def("kill", &CSE_ALifeMonsterAbstract::kill) + .def("has_detector", &CSE_ALifeMonsterAbstract::has_detector) + .def("force_set_goodwill", &ForceSetGoodwill) #endif - ]; + ]; } -SCRIPT_EXPORT_FUNC(CSE_ALifeMonsterAbstract, (CSE_ALifeCreatureAbstract, CSE_ALifeSchedulable), - CSE_ALifeMonsterAbstract_Export); +SCRIPT_EXPORT_FUNC( + CSE_ALifeMonsterAbstract, (CSE_ALifeCreatureAbstract, CSE_ALifeSchedulable), CSE_ALifeMonsterAbstract_Export); -static void CSE_ALifeHumanAbstract_Export(lua_State *luaState) +static void CSE_ALifeHumanAbstract_Export(lua_State* luaState) { - module(luaState) - [ - luabind_class_monster2( - CSE_ALifeHumanAbstract, - "cse_alife_human_abstract", - CSE_ALifeTraderAbstract, - CSE_ALifeMonsterAbstract - ) - .def("brain", &human_brain) + module(luaState)[luabind_class_monster2( + CSE_ALifeHumanAbstract, "cse_alife_human_abstract", CSE_ALifeTraderAbstract, CSE_ALifeMonsterAbstract) + .def("brain", &human_brain) #ifdef XRGAME_EXPORTS - .def("rank", &CSE_ALifeTraderAbstract::Rank) - .def("set_rank", &CSE_ALifeTraderAbstract::SetRank) + .def("rank", &CSE_ALifeTraderAbstract::Rank) + .def("set_rank", &CSE_ALifeTraderAbstract::SetRank) #endif - ]; + ]; } -SCRIPT_EXPORT_FUNC(CSE_ALifeHumanAbstract, (CSE_ALifeTraderAbstract, CSE_ALifeMonsterAbstract), - CSE_ALifeHumanAbstract_Export); +SCRIPT_EXPORT_FUNC( + CSE_ALifeHumanAbstract, (CSE_ALifeTraderAbstract, CSE_ALifeMonsterAbstract), CSE_ALifeHumanAbstract_Export); -SCRIPT_EXPORT(CSE_ALifePsyDogPhantom, (CSE_ALifeMonsterBase), -{ - module(luaState) - [ - luabind_class_monster1( - CSE_ALifePsyDogPhantom, - "cse_alife_psydog_phantom", - CSE_ALifeMonsterBase - ) - ]; +SCRIPT_EXPORT(CSE_ALifePsyDogPhantom, (CSE_ALifeMonsterBase), { + module(luaState)[luabind_class_monster1(CSE_ALifePsyDogPhantom, "cse_alife_psydog_phantom", CSE_ALifeMonsterBase)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_script.cpp b/src/xrServerEntities/xrServer_Objects_ALife_script.cpp index 930fa55a8e8..e45a15dd73b 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_script.cpp @@ -7,142 +7,72 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -SCRIPT_EXPORT(CSE_ALifeSchedulable, (), -{ - module(luaState) - [ - class_ - ("ipure_schedulable_object"), -// .def( constructor<>()), - - class_ - ("cse_alife_schedulable") -// .def( constructor()) - ]; +SCRIPT_EXPORT(CSE_ALifeSchedulable, (), { + module(luaState)[class_("ipure_schedulable_object"), + // .def( constructor<>()), + + class_("cse_alife_schedulable") + // .def( constructor()) + ]; }); SCRIPT_EXPORT(CSE_ALifeGraphPoint, (CSE_Abstract), -{ - module(luaState) - [ - luabind_class_abstract1( - CSE_ALifeGraphPoint, - "cse_alife_graph_point", - CSE_Abstract - ) - ]; -}); + { module(luaState)[luabind_class_abstract1(CSE_ALifeGraphPoint, "cse_alife_graph_point", CSE_Abstract)]; }); -SCRIPT_EXPORT(CSE_ALifeObject, (CSE_Abstract), -{ - module(luaState) - [ - luabind_class_alife1( - CSE_ALifeObject, - "cse_alife_object", - CSE_Abstract - ) - .def_readonly ("online", &CSE_ALifeObject::m_bOnline) - .def ("move_offline", (bool (CSE_ALifeObject::*)() const)(&CSE_ALifeObject::move_offline)) - .def ("move_offline", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::move_offline)) - .def ("visible_for_map", (bool (CSE_ALifeObject::*)() const)(&CSE_ALifeObject::visible_for_map)) - .def ("visible_for_map", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::visible_for_map)) - .def ("can_switch_online", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::can_switch_online)) - .def ("can_switch_offline", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::can_switch_offline)) - .def ("use_ai_locations", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::use_ai_locations)) - .def_readonly ("m_level_vertex_id", &CSE_ALifeObject::m_tNodeID) - .def_readonly ("m_game_vertex_id", &CSE_ALifeObject::m_tGraphID) - .def_readonly ("m_story_id", &CSE_ALifeObject::m_story_id) - ]; +SCRIPT_EXPORT(CSE_ALifeObject, (CSE_Abstract), { + module( + luaState)[luabind_class_alife1(CSE_ALifeObject, "cse_alife_object", CSE_Abstract) + .def_readonly("online", &CSE_ALifeObject::m_bOnline) + .def("move_offline", (bool (CSE_ALifeObject::*)() const)(&CSE_ALifeObject::move_offline)) + .def("move_offline", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::move_offline)) + .def("visible_for_map", (bool (CSE_ALifeObject::*)() const)(&CSE_ALifeObject::visible_for_map)) + .def("visible_for_map", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::visible_for_map)) + .def("can_switch_online", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::can_switch_online)) + .def( + "can_switch_offline", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::can_switch_offline)) + .def("use_ai_locations", (void (CSE_ALifeObject::*)(bool))(&CSE_ALifeObject::use_ai_locations)) + .def_readonly("m_level_vertex_id", &CSE_ALifeObject::m_tNodeID) + .def_readonly("m_game_vertex_id", &CSE_ALifeObject::m_tGraphID) + .def_readonly("m_story_id", &CSE_ALifeObject::m_story_id)]; }); -SCRIPT_EXPORT(CSE_ALifeGroupAbstract, (), -{ - module(luaState) - [ - class_ - ("cse_alife_group_abstract") -// .def( constructor()) - ]; +SCRIPT_EXPORT(CSE_ALifeGroupAbstract, (), { + module(luaState)[class_("cse_alife_group_abstract") + // .def( constructor()) + ]; }); -SCRIPT_EXPORT(CSE_ALifeDynamicObject, (CSE_ALifeObject), -{ - module(luaState) - [ - luabind_class_dynamic_alife1( - CSE_ALifeDynamicObject, - "cse_alife_dynamic_object", - CSE_ALifeObject - ) - ]; +SCRIPT_EXPORT(CSE_ALifeDynamicObject, (CSE_ALifeObject), { + module(luaState)[luabind_class_dynamic_alife1(CSE_ALifeDynamicObject, "cse_alife_dynamic_object", CSE_ALifeObject)]; }); -SCRIPT_EXPORT(CSE_ALifeDynamicObjectVisual, (CSE_ALifeDynamicObject, CSE_Visual), -{ - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifeDynamicObjectVisual, - "cse_alife_dynamic_object_visual", - CSE_ALifeDynamicObject, - CSE_Visual - ) - ]; +SCRIPT_EXPORT(CSE_ALifeDynamicObjectVisual, (CSE_ALifeDynamicObject, CSE_Visual), { + module(luaState)[luabind_class_dynamic_alife2( + CSE_ALifeDynamicObjectVisual, "cse_alife_dynamic_object_visual", CSE_ALifeDynamicObject, CSE_Visual)]; }); -SCRIPT_EXPORT(CSE_ALifePHSkeletonObject, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), -{ - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifePHSkeletonObject, - "cse_alife_ph_skeleton_object", - CSE_ALifeDynamicObjectVisual, - CSE_PHSkeleton - ) - ]; +SCRIPT_EXPORT(CSE_ALifePHSkeletonObject, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), { + module(luaState)[luabind_class_dynamic_alife2( + CSE_ALifePHSkeletonObject, "cse_alife_ph_skeleton_object", CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton)]; }); -SCRIPT_EXPORT(CSE_ALifeSpaceRestrictor, (CSE_ALifeDynamicObject, CSE_Shape), -{ - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifeSpaceRestrictor, - "cse_alife_space_restrictor", - CSE_ALifeDynamicObject, - CSE_Shape - ) - ]; +SCRIPT_EXPORT(CSE_ALifeSpaceRestrictor, (CSE_ALifeDynamicObject, CSE_Shape), { + module(luaState)[luabind_class_dynamic_alife2( + CSE_ALifeSpaceRestrictor, "cse_alife_space_restrictor", CSE_ALifeDynamicObject, CSE_Shape)]; }); -SCRIPT_EXPORT(CSE_ALifeLevelChanger, (CSE_ALifeSpaceRestrictor), -{ - module(luaState) - [ - luabind_class_dynamic_alife1( - CSE_ALifeLevelChanger, - "cse_alife_level_changer", - CSE_ALifeSpaceRestrictor - ) - ]; +SCRIPT_EXPORT(CSE_ALifeLevelChanger, (CSE_ALifeSpaceRestrictor), { + module(luaState)[luabind_class_dynamic_alife1( + CSE_ALifeLevelChanger, "cse_alife_level_changer", CSE_ALifeSpaceRestrictor)]; }); -SCRIPT_EXPORT(CSE_ALifeInventoryBox, (CSE_ALifeDynamicObjectVisual), -{ - module(luaState) - [ - luabind_class_dynamic_alife1( - CSE_ALifeInventoryBox, - "cse_alife_inventory_box", - CSE_ALifeDynamicObjectVisual - ) - ]; +SCRIPT_EXPORT(CSE_ALifeInventoryBox, (CSE_ALifeDynamicObjectVisual), { + module(luaState)[luabind_class_dynamic_alife1( + CSE_ALifeInventoryBox, "cse_alife_inventory_box", CSE_ALifeDynamicObjectVisual)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_script2.cpp b/src/xrServerEntities/xrServer_Objects_ALife_script2.cpp index 0b8e3f8fc4e..33d03dfc405 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_script2.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_script2.cpp @@ -7,96 +7,43 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -SCRIPT_EXPORT(CSE_ALifeObjectProjector, (CSE_ALifeDynamicObjectVisual), -{ - module(luaState) - [ - luabind_class_dynamic_alife1( - CSE_ALifeObjectProjector, - "cse_alife_object_projector", - CSE_ALifeDynamicObjectVisual - ) - ]; +SCRIPT_EXPORT(CSE_ALifeObjectProjector, (CSE_ALifeDynamicObjectVisual), { + module(luaState)[luabind_class_dynamic_alife1( + CSE_ALifeObjectProjector, "cse_alife_object_projector", CSE_ALifeDynamicObjectVisual)]; }); -SCRIPT_EXPORT(CSE_ALifeHelicopter, (CSE_ALifeDynamicObjectVisual, CSE_Motion, CSE_PHSkeleton), -{ - module(luaState) - [ - luabind_class_dynamic_alife3( - CSE_ALifeHelicopter, - "cse_alife_helicopter", - CSE_ALifeDynamicObjectVisual, - CSE_Motion, - CSE_PHSkeleton - ) - ]; +SCRIPT_EXPORT(CSE_ALifeHelicopter, (CSE_ALifeDynamicObjectVisual, CSE_Motion, CSE_PHSkeleton), { + module(luaState)[luabind_class_dynamic_alife3( + CSE_ALifeHelicopter, "cse_alife_helicopter", CSE_ALifeDynamicObjectVisual, CSE_Motion, CSE_PHSkeleton)]; }); -SCRIPT_EXPORT(CSE_ALifeCar, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), -{ - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifeCar, - "cse_alife_car", - CSE_ALifeDynamicObjectVisual, - CSE_PHSkeleton - ) - ]; +SCRIPT_EXPORT(CSE_ALifeCar, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), { + module(luaState)[luabind_class_dynamic_alife2( + CSE_ALifeCar, "cse_alife_car", CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton)]; }); -SCRIPT_EXPORT(CSE_ALifeObjectBreakable, (CSE_ALifeDynamicObjectVisual), -{ - module(luaState) - [ - luabind_class_dynamic_alife1( - CSE_ALifeObjectBreakable, - "cse_alife_object_breakable", - CSE_ALifeDynamicObjectVisual - ) - ]; +SCRIPT_EXPORT(CSE_ALifeObjectBreakable, (CSE_ALifeDynamicObjectVisual), { + module(luaState)[luabind_class_dynamic_alife1( + CSE_ALifeObjectBreakable, "cse_alife_object_breakable", CSE_ALifeDynamicObjectVisual)]; }); -SCRIPT_EXPORT(CSE_ALifeObjectClimable, (CSE_Shape, CSE_Abstract), -{ - module(luaState) - [ - luabind_class_abstract2( - CSE_ALifeObjectClimable, - "cse_alife_object_climable", - CSE_Shape, - CSE_Abstract - ) - ]; +SCRIPT_EXPORT(CSE_ALifeObjectClimable, (CSE_Shape, CSE_Abstract), { + module(luaState)[luabind_class_abstract2( + CSE_ALifeObjectClimable, "cse_alife_object_climable", CSE_Shape, CSE_Abstract)]; }); -SCRIPT_EXPORT(CSE_ALifeMountedWeapon, (CSE_ALifeDynamicObjectVisual), -{ - module(luaState) - [ - luabind_class_dynamic_alife1( - CSE_ALifeMountedWeapon, - "cse_alife_mounted_weapon", - CSE_ALifeDynamicObjectVisual - ) - ]; +SCRIPT_EXPORT(CSE_ALifeMountedWeapon, (CSE_ALifeDynamicObjectVisual), { + module(luaState)[luabind_class_dynamic_alife1( + CSE_ALifeMountedWeapon, "cse_alife_mounted_weapon", CSE_ALifeDynamicObjectVisual)]; }); -SCRIPT_EXPORT(CSE_ALifeTeamBaseZone, (CSE_ALifeSpaceRestrictor), -{ - module(luaState) - [ - luabind_class_dynamic_alife1( - CSE_ALifeTeamBaseZone, - "cse_alife_team_base_zone", - CSE_ALifeSpaceRestrictor - ) - ]; +SCRIPT_EXPORT(CSE_ALifeTeamBaseZone, (CSE_ALifeSpaceRestrictor), { + module(luaState)[luabind_class_dynamic_alife1( + CSE_ALifeTeamBaseZone, "cse_alife_team_base_zone", CSE_ALifeSpaceRestrictor)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_ALife_script3.cpp b/src/xrServerEntities/xrServer_Objects_ALife_script3.cpp index 7526bd3d6d9..6aba5e4818b 100644 --- a/src/xrServerEntities/xrServer_Objects_ALife_script3.cpp +++ b/src/xrServerEntities/xrServer_Objects_ALife_script3.cpp @@ -7,52 +7,29 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -void set_yaw (CSE_ALifeObjectPhysic *obj, const float yaw) -{ obj->o_Angle.y = yaw; } - - -SCRIPT_EXPORT(CSE_ALifeObjectHangingLamp, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), +void set_yaw(CSE_ALifeObjectPhysic* obj, const float yaw) { - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifeObjectHangingLamp, - "cse_alife_object_hanging_lamp", - CSE_ALifeDynamicObjectVisual, - CSE_PHSkeleton - ) - ]; + obj->o_Angle.y = yaw; +} + +SCRIPT_EXPORT(CSE_ALifeObjectHangingLamp, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), { + module(luaState)[luabind_class_dynamic_alife2( + CSE_ALifeObjectHangingLamp, "cse_alife_object_hanging_lamp", CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton)]; }); -SCRIPT_EXPORT(CSE_ALifeObjectPhysic, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), -{ - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifeObjectPhysic, - "cse_alife_object_physic", - CSE_ALifeDynamicObjectVisual, - CSE_PHSkeleton - ) - .def("set_yaw", &set_yaw) - ]; +SCRIPT_EXPORT(CSE_ALifeObjectPhysic, (CSE_ALifeDynamicObjectVisual, CSE_PHSkeleton), { + module(luaState)[luabind_class_dynamic_alife2(CSE_ALifeObjectPhysic, "cse_alife_object_physic", + CSE_ALifeDynamicObjectVisual, + CSE_PHSkeleton).def("set_yaw", &set_yaw)]; }); -SCRIPT_EXPORT(CSE_ALifeSmartZone, (CSE_ALifeSpaceRestrictor, CSE_ALifeSchedulable), -{ - module(luaState) - [ - luabind_class_zone2( - CSE_ALifeSmartZone, - "cse_alife_smart_zone", - CSE_ALifeSpaceRestrictor, - CSE_ALifeSchedulable - ) - ]; +SCRIPT_EXPORT(CSE_ALifeSmartZone, (CSE_ALifeSpaceRestrictor, CSE_ALifeSchedulable), { + module(luaState)[luabind_class_zone2( + CSE_ALifeSmartZone, "cse_alife_smart_zone", CSE_ALifeSpaceRestrictor, CSE_ALifeSchedulable)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_Abstract.cpp b/src/xrServerEntities/xrServer_Objects_Abstract.cpp index 616a44fb950..c70d9deebf1 100644 --- a/src/xrServerEntities/xrServer_Objects_Abstract.cpp +++ b/src/xrServerEntities/xrServer_Objects_Abstract.cpp @@ -8,121 +8,127 @@ #include "stdafx.h" #pragma hdrstop -#pragma pack(push,4) +#pragma pack(push, 4) -#include "xrServer_Objects_Abstract.h" #include "xrMessages.h" +#include "xrServer_Objects_Abstract.h" //////////////////////////////////////////////////////////////////////////// // CSE_Visual //////////////////////////////////////////////////////////////////////////// -CSE_Visual::CSE_Visual (LPCSTR name) +CSE_Visual::CSE_Visual(LPCSTR name) { - if(name) - { - string_path tmp; - xr_strcpy (tmp, name); - if(strext(tmp)) - *strext(tmp) =0; - xr_strlwr (tmp); - visual_name = tmp; - }else - visual_name = NULL; - - startup_animation = "$editor"; - flags.zero (); + if (name) { + string_path tmp; + xr_strcpy(tmp, name); + if (strext(tmp)) *strext(tmp) = 0; + xr_strlwr(tmp); + visual_name = tmp; + } + else + visual_name = NULL; + + startup_animation = "$editor"; + flags.zero(); } -CSE_Visual::~CSE_Visual () +CSE_Visual::~CSE_Visual() { } -void CSE_Visual::set_visual (LPCSTR name, bool load) +void CSE_Visual::set_visual(LPCSTR name, bool load) { - string_path tmp; - xr_strcpy (tmp,name); - if (strext(tmp)) *strext(tmp) = 0; - xr_strlwr (tmp); - visual_name = tmp; + string_path tmp; + xr_strcpy(tmp, name); + if (strext(tmp)) *strext(tmp) = 0; + xr_strlwr(tmp); + visual_name = tmp; } -void CSE_Visual::visual_read (NET_Packet &tNetPacket, u16 version) +void CSE_Visual::visual_read(NET_Packet& tNetPacket, u16 version) { - tNetPacket.r_stringZ (visual_name); - if (version>103) - flags.assign (tNetPacket.r_u8()); + tNetPacket.r_stringZ(visual_name); + if (version > 103) flags.assign(tNetPacket.r_u8()); } -void CSE_Visual::visual_write (NET_Packet &tNetPacket) +void CSE_Visual::visual_write(NET_Packet& tNetPacket) { - tNetPacket.w_stringZ (visual_name); - tNetPacket.w_u8 (flags.get()); + tNetPacket.w_stringZ(visual_name); + tNetPacket.w_u8(flags.get()); } -void CSE_Visual::OnChangeVisual (PropValue* sender) +void CSE_Visual::OnChangeVisual(PropValue* sender) { - IServerEntity* abstract = smart_cast(this); VERIFY(abstract); - abstract->set_editor_flag (IServerEntity::flVisualChange); + IServerEntity* abstract = smart_cast(this); + VERIFY(abstract); + abstract->set_editor_flag(IServerEntity::flVisualChange); } void CSE_Visual::OnChangeAnim(PropValue* sender) { - IServerEntity* abstract = smart_cast(this); VERIFY(abstract); - abstract->set_editor_flag (IServerEntity::flVisualAnimationChange); + IServerEntity* abstract = smart_cast(this); + VERIFY(abstract); + abstract->set_editor_flag(IServerEntity::flVisualAnimationChange); } #ifndef XRGAME_EXPORTS -void CSE_Visual::FillProps (LPCSTR pref, PropItemVec &items) +void CSE_Visual::FillProps(LPCSTR pref, PropItemVec& items) { - IServerEntity* abstract = smart_cast(this); VERIFY(abstract); - ChooseValue *V = PHelper().CreateChoose(items, PrepareKey(pref,abstract->name(),"Model\\Visual"), &visual_name, smVisual); - V->OnChangeEvent.bind (this,&CSE_Visual::OnChangeVisual); - V = PHelper().CreateChoose(items, PrepareKey(pref,abstract->name(),"Model\\Animation"), &startup_animation, smSkeletonAnims,0,(void*)*visual_name); - V->OnChangeEvent.bind (this,&CSE_Visual::OnChangeAnim); - PHelper().CreateFlag8 (items, PrepareKey(pref,abstract->name(),"Model\\Obstacle"), &flags, flObstacle); + IServerEntity* abstract = smart_cast(this); + VERIFY(abstract); + ChooseValue* V = + PHelper().CreateChoose(items, PrepareKey(pref, abstract->name(), "Model\\Visual"), &visual_name, smVisual); + V->OnChangeEvent.bind(this, &CSE_Visual::OnChangeVisual); + V = PHelper().CreateChoose(items, PrepareKey(pref, abstract->name(), "Model\\Animation"), &startup_animation, + smSkeletonAnims, 0, (void*)*visual_name); + V->OnChangeEvent.bind(this, &CSE_Visual::OnChangeAnim); + PHelper().CreateFlag8(items, PrepareKey(pref, abstract->name(), "Model\\Obstacle"), &flags, flObstacle); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS //////////////////////////////////////////////////////////////////////////// // CSE_Animated //////////////////////////////////////////////////////////////////////////// -CSE_Motion::CSE_Motion (LPCSTR name) +CSE_Motion::CSE_Motion(LPCSTR name) { - motion_name = name; + motion_name = name; } -CSE_Motion::~CSE_Motion () +CSE_Motion::~CSE_Motion() { } -void CSE_Motion::set_motion (LPCSTR name) +void CSE_Motion::set_motion(LPCSTR name) { - motion_name = name; + motion_name = name; } -void CSE_Motion::motion_read (NET_Packet &tNetPacket) +void CSE_Motion::motion_read(NET_Packet& tNetPacket) { - tNetPacket.r_stringZ (motion_name); + tNetPacket.r_stringZ(motion_name); } -void CSE_Motion::motion_write (NET_Packet &tNetPacket) +void CSE_Motion::motion_write(NET_Packet& tNetPacket) { - tNetPacket.w_stringZ (motion_name); + tNetPacket.w_stringZ(motion_name); } -void CSE_Motion::OnChangeMotion (PropValue* sender) +void CSE_Motion::OnChangeMotion(PropValue* sender) { - IServerEntity* abstract = smart_cast(this); VERIFY(abstract); - abstract->set_editor_flag (IServerEntity::flMotionChange); + IServerEntity* abstract = smart_cast(this); + VERIFY(abstract); + abstract->set_editor_flag(IServerEntity::flMotionChange); } #ifndef XRGAME_EXPORTS -void CSE_Motion::FillProps( LPCSTR pref, PropItemVec &items) +void CSE_Motion::FillProps(LPCSTR pref, PropItemVec& items) { - IServerEntity* abstract = smart_cast(this); VERIFY(abstract); - ChooseValue *V = PHelper().CreateChoose(items, PrepareKey(pref,abstract->name(),"Motion"),&motion_name, smGameAnim); - V->OnChangeEvent.bind (this,&CSE_Motion::OnChangeMotion); + IServerEntity* abstract = smart_cast(this); + VERIFY(abstract); + ChooseValue* V = + PHelper().CreateChoose(items, PrepareKey(pref, abstract->name(), "Motion"), &motion_name, smGameAnim); + V->OnChangeEvent.bind(this, &CSE_Motion::OnChangeMotion); } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS -#pragma pack(pop,4) +#pragma pack(pop, 4) diff --git a/src/xrServerEntities/xrServer_Objects_Abstract.h b/src/xrServerEntities/xrServer_Objects_Abstract.h index 907c6736653..54e25e208dd 100644 --- a/src/xrServerEntities/xrServer_Objects_Abstract.h +++ b/src/xrServerEntities/xrServer_Objects_Abstract.h @@ -9,11 +9,11 @@ #ifndef xrServer_Objects_AbstractH #define xrServer_Objects_AbstractH -#pragma pack(push,4) -#include "xrServer_Space.h" -#include "xrCDB/xrCDB.h" +#pragma pack(push, 4) #include "ShapeData.h" #include "gametype_chooser.h" +#include "xrCDB/xrCDB.h" +#include "xrServer_Space.h" class NET_Packet; class CDUInterface; @@ -24,131 +24,142 @@ class CDUInterface; #endif #endif -#include "xrEProps.h" #include "Include/xrRender/DrawUtils.h" +#include "xrEProps.h" #pragma warning(push) -#pragma warning(disable:4005) +#pragma warning(disable : 4005) class IServerEntityShape { public: virtual ~IServerEntityShape() = 0; - virtual void __stdcall assign_shapes (CShapeData::shape_def* shapes, u32 cnt)=0; + virtual void __stdcall assign_shapes(CShapeData::shape_def* shapes, u32 cnt) = 0; }; -IC IServerEntityShape::~IServerEntityShape() {} +IC IServerEntityShape::~IServerEntityShape() +{ +} class CSE_Visual { public: - void __stdcall OnChangeVisual (PropValue* sender); - void __stdcall OnChangeAnim (PropValue* sender); + void __stdcall OnChangeVisual(PropValue* sender); + void __stdcall OnChangeAnim(PropValue* sender); public: - shared_str visual_name; - shared_str startup_animation; - enum{ - flObstacle = (1<<0) + shared_str visual_name; + shared_str startup_animation; + enum + { + flObstacle = (1 << 0) }; - Flags8 flags; + Flags8 flags; + public: - CSE_Visual (LPCSTR name=0); - virtual ~CSE_Visual (); + CSE_Visual(LPCSTR name = 0); + virtual ~CSE_Visual(); - void visual_read (NET_Packet& P, u16 version); - void visual_write (NET_Packet& P); + void visual_read(NET_Packet& P, u16 version); + void visual_write(NET_Packet& P); - void set_visual (LPCSTR name, bool load=true); - LPCSTR get_visual () const {return *visual_name;}; + void set_visual(LPCSTR name, bool load = true); + LPCSTR get_visual() const { return *visual_name; }; #ifndef XRGAME_EXPORTS - virtual void FillProps (LPCSTR pref, PropItemVec &items); -#endif // #ifndef XRGAME_EXPORTS + virtual void FillProps(LPCSTR pref, PropItemVec& items); +#endif // #ifndef XRGAME_EXPORTS - virtual CSE_Visual* __stdcall visual () = 0; + virtual CSE_Visual* __stdcall visual() = 0; }; class CSE_Motion { public: - void __stdcall OnChangeMotion (PropValue* sender); -public: - shared_str motion_name; + void __stdcall OnChangeMotion(PropValue* sender); + public: - CSE_Motion (LPCSTR name=0); - virtual ~CSE_Motion (); + shared_str motion_name; - void motion_read (NET_Packet& P); - void motion_write (NET_Packet& P); +public: + CSE_Motion(LPCSTR name = 0); + virtual ~CSE_Motion(); - void set_motion (LPCSTR name); - LPCSTR get_motion () const {return *motion_name;}; + void motion_read(NET_Packet& P); + void motion_write(NET_Packet& P); + void set_motion(LPCSTR name); + LPCSTR get_motion() const { return *motion_name; }; #ifndef XRGAME_EXPORTS - virtual void FillProps (LPCSTR pref, PropItemVec &items); -#endif // #ifndef XRGAME_EXPORTS + virtual void FillProps(LPCSTR pref, PropItemVec& items); +#endif // #ifndef XRGAME_EXPORTS - virtual CSE_Motion* __stdcall motion () = 0; + virtual CSE_Motion* __stdcall motion() = 0; }; class IServerEntityLEOwner { public: virtual ~IServerEntityLEOwner() = 0; - virtual void __stdcall get_bone_xform (LPCSTR name, Fmatrix& xform) = 0; + virtual void __stdcall get_bone_xform(LPCSTR name, Fmatrix& xform) = 0; }; -IC IServerEntityLEOwner::~IServerEntityLEOwner() {} +IC IServerEntityLEOwner::~IServerEntityLEOwner() +{ +} -#pragma pack(push,1) +#pragma pack(push, 1) class visual_data { public: - Fmatrix matrix; - CSE_Visual *visual; + Fmatrix matrix; + CSE_Visual* visual; }; #pragma pack(pop) -class IServerEntity { +class IServerEntity +{ public: - enum { - flUpdateProperties = u32(1 << 0), - flVisualChange = u32(1 << 1), - flVisualAnimationChange = u32(1 << 2), - flMotionChange = u32(1 << 3), - flVisualAnimationPauseChange= u32(1 << 4), + enum + { + flUpdateProperties = u32(1 << 0), + flVisualChange = u32(1 << 1), + flVisualAnimationChange = u32(1 << 2), + flMotionChange = u32(1 << 3), + flVisualAnimationPauseChange = u32(1 << 4), }; virtual ~IServerEntity() = 0; // XXX: move to implementation - Flags32 m_editor_flags; + Flags32 m_editor_flags; void set_editor_flag(u32 mask) { m_editor_flags.set(mask, TRUE); } - public: - virtual void __stdcall Spawn_Write (NET_Packet &tNetPacket, BOOL bLocal) = 0; - virtual BOOL __stdcall Spawn_Read (NET_Packet &tNetPacket) = 0; + virtual void __stdcall Spawn_Write(NET_Packet& tNetPacket, BOOL bLocal) = 0; + virtual BOOL __stdcall Spawn_Read(NET_Packet& tNetPacket) = 0; #ifndef XRGAME_EXPORTS - virtual void __stdcall FillProp (LPCSTR pref, PropItemVec &items) = 0; - virtual void __stdcall on_render (CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent,int priority, bool strictB2F) = 0; - virtual visual_data*__stdcall visual_collection () const = 0; - virtual u32 __stdcall visual_collection_size () const = 0; - virtual void __stdcall set_additional_info (void* info) = 0; -#endif // #ifndef XRGAME_EXPORTS - virtual LPCSTR __stdcall name () const = 0; - virtual void __stdcall set_name (LPCSTR) = 0; - virtual LPCSTR __stdcall name_replace () const = 0; - virtual void __stdcall set_name_replace (LPCSTR) = 0; - virtual Fvector& __stdcall position () = 0; - virtual Fvector& __stdcall angle () = 0; - virtual Flags16& __stdcall flags () = 0; - virtual IServerEntityShape* __stdcall shape () = 0; - virtual CSE_Visual* __stdcall visual () = 0; - virtual CSE_Motion* __stdcall motion () = 0; - virtual bool __stdcall validate () = 0; + virtual void __stdcall FillProp(LPCSTR pref, PropItemVec& items) = 0; + virtual void __stdcall on_render(CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, + const Fmatrix& parent, int priority, bool strictB2F) = 0; + virtual visual_data* __stdcall visual_collection() const = 0; + virtual u32 __stdcall visual_collection_size() const = 0; + virtual void __stdcall set_additional_info(void* info) = 0; +#endif // #ifndef XRGAME_EXPORTS + virtual LPCSTR __stdcall name() const = 0; + virtual void __stdcall set_name(LPCSTR) = 0; + virtual LPCSTR __stdcall name_replace() const = 0; + virtual void __stdcall set_name_replace(LPCSTR) = 0; + virtual Fvector& __stdcall position() = 0; + virtual Fvector& __stdcall angle() = 0; + virtual Flags16& __stdcall flags() = 0; + virtual IServerEntityShape* __stdcall shape() = 0; + virtual CSE_Visual* __stdcall visual() = 0; + virtual CSE_Motion* __stdcall motion() = 0; + virtual bool __stdcall validate() = 0; }; -IC IServerEntity::~IServerEntity() {} +IC IServerEntity::~IServerEntity() +{ +} #pragma warning(pop) #pragma pack(pop) -#endif // xrServer_Objects_AbstractH +#endif // xrServer_Objects_AbstractH diff --git a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp index 46ea6d2c5e0..6373ffa8d2e 100644 --- a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp +++ b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.cpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////////////////////// // Module : xrServer_Objects_ALife_Smartcovers.cpp // Created : 17.12.2008 -// Modified : +// Modified : // Author : Alexander Plichko // Description : Server objects smartcovers for ALife simulator //////////////////////////////////////////////////////////////////////////// @@ -17,335 +17,300 @@ #include "ai_space.h" #include "xrScriptEngine/script_engine.hpp" #pragma warning(push) -#pragma warning(disable:4995) +#pragma warning(disable : 4995) #include #include #pragma warning(pop) #pragma comment(lib, "shlwapi.lib") static SFillPropData fp_data; -#endif // XRSE_FACTORY_EXPORTS +#endif // XRSE_FACTORY_EXPORTS #ifdef XRSE_FACTORY_EXPORTS -bool parse_bool (luabind::object const &table, LPCSTR identifier) +bool parse_bool(luabind::object const& table, LPCSTR identifier) { - VERIFY2 (table.type() == LUA_TTABLE, "invalid loophole description passed"); - luabind::object result = table[identifier]; - VERIFY2 (result.type() != LUA_TNIL, make_string("cannot read boolean value %s", identifier)); - VERIFY2 (result.type() == LUA_TBOOLEAN, make_string("cannot read boolean value %s", identifier)); - return (luabind::object_cast(result)); + VERIFY2(table.type() == LUA_TTABLE, "invalid loophole description passed"); + luabind::object result = table[identifier]; + VERIFY2(result.type() != LUA_TNIL, make_string("cannot read boolean value %s", identifier)); + VERIFY2(result.type() == LUA_TBOOLEAN, make_string("cannot read boolean value %s", identifier)); + return (luabind::object_cast(result)); } -BOOL is_combat_cover (shared_str const &table_id) +BOOL is_combat_cover(shared_str const& table_id) { - if (table_id.size() == 0) - return (FALSE); + if (table_id.size() == 0) return (FALSE); - string256 temp; - xr_strcpy (temp, "smart_covers.descriptions."); - xr_strcat (temp, *table_id); + string256 temp; + xr_strcpy(temp, "smart_covers.descriptions."); + xr_strcat(temp, *table_id); - luabind::object table, value; - bool result = - ai().script_engine().function_object( - temp, - table, - LUA_TTABLE - ); + luabind::object table, value; + bool result = ai().script_engine().function_object(temp, table, LUA_TTABLE); - VERIFY2 (result, make_string("bad or missing description in smart_cover [%s]", table_id.c_str())); + VERIFY2(result, make_string("bad or missing description in smart_cover [%s]", table_id.c_str())); if (table.type() != LUA_TTABLE) { - VERIFY (table.type() != LUA_TNIL); - return (TRUE); + VERIFY(table.type() != LUA_TNIL); + return (TRUE); } - value = table["is_combat_cover"]; + value = table["is_combat_cover"]; if (value.type() == LUA_TNIL) { - Msg ("! is_combat_cover flag not found for smart_cover [%s], forcing to \"true\"", table_id.c_str()); - return (TRUE); + Msg("! is_combat_cover flag not found for smart_cover [%s], forcing to \"true\"", table_id.c_str()); + return (TRUE); } - return (parse_bool(table, "is_combat_cover") ? TRUE : FALSE); + return (parse_bool(table, "is_combat_cover") ? TRUE : FALSE); } -#endif // XRSE_FACTORY_EXPORTS +#endif // XRSE_FACTORY_EXPORTS -CSE_SmartCover::CSE_SmartCover (LPCSTR section) : CSE_ALifeDynamicObject(section) +CSE_SmartCover::CSE_SmartCover(LPCSTR section) : CSE_ALifeDynamicObject(section) { #ifdef XRSE_FACTORY_EXPORTS - fp_data.inc (); -#endif // XRSE_FACTORY_EXPORTS + fp_data.inc(); +#endif // XRSE_FACTORY_EXPORTS - m_enter_min_enemy_distance = pSettings->r_float(section, "enter_min_enemy_distance"); - m_exit_min_enemy_distance = pSettings->r_float(section, "exit_min_enemy_distance"); - m_is_combat_cover = pSettings->r_bool(section, "is_combat_cover"); - m_can_fire = m_is_combat_cover ? true : pSettings->r_bool(section, "can_fire"); + m_enter_min_enemy_distance = pSettings->r_float(section, "enter_min_enemy_distance"); + m_exit_min_enemy_distance = pSettings->r_float(section, "exit_min_enemy_distance"); + m_is_combat_cover = pSettings->r_bool(section, "is_combat_cover"); + m_can_fire = m_is_combat_cover ? true : pSettings->r_bool(section, "can_fire"); m_need_to_reparse_loopholes = true; } -CSE_SmartCover::~CSE_SmartCover () +CSE_SmartCover::~CSE_SmartCover() { #ifdef XRSE_FACTORY_EXPORTS - fp_data.dec (); -#endif // XRSE_FACTORY_EXPORTS + fp_data.dec(); +#endif // XRSE_FACTORY_EXPORTS } IServerEntityShape* CSE_SmartCover::shape() { - return (this); + return (this); } -bool CSE_SmartCover::used_ai_locations () const +bool CSE_SmartCover::used_ai_locations() const { - return (true); + return (true); } -bool CSE_SmartCover::can_save () const +bool CSE_SmartCover::can_save() const { - return (true); + return (true); } -bool CSE_SmartCover::can_switch_online () const +bool CSE_SmartCover::can_switch_online() const { - return (true); + return (true); } -bool CSE_SmartCover::can_switch_offline () const +bool CSE_SmartCover::can_switch_offline() const { - return (false); + return (false); } -bool CSE_SmartCover::interactive () const +bool CSE_SmartCover::interactive() const { - return (false); + return (false); } -LPCSTR CSE_SmartCover::description () const +LPCSTR CSE_SmartCover::description() const { - return (m_description.c_str()); + return (m_description.c_str()); } #ifndef AI_COMPILER void CSE_SmartCover::set_available_loopholes(luabind::object table) { - m_available_loopholes = table; + m_available_loopholes = table; } -#endif // #ifndef AI_COMPILER +#endif // #ifndef AI_COMPILER -void CSE_SmartCover::STATE_Read (NET_Packet &tNetPacket, u16 size) +void CSE_SmartCover::STATE_Read(NET_Packet& tNetPacket, u16 size) { - inherited1::STATE_Read (tNetPacket, size); - cform_read (tNetPacket); - tNetPacket.r_stringZ (m_description); - m_hold_position_time = tNetPacket.r_float(); + inherited1::STATE_Read(tNetPacket, size); + cform_read(tNetPacket); + tNetPacket.r_stringZ(m_description); + m_hold_position_time = tNetPacket.r_float(); if (m_wVersion >= 120) { - m_enter_min_enemy_distance = tNetPacket.r_float(); - m_exit_min_enemy_distance = tNetPacket.r_float(); + m_enter_min_enemy_distance = tNetPacket.r_float(); + m_exit_min_enemy_distance = tNetPacket.r_float(); } - if (m_wVersion >= 122) - m_is_combat_cover = tNetPacket.r_u8(); + if (m_wVersion >= 122) m_is_combat_cover = tNetPacket.r_u8(); - if (m_wVersion >= 128) - m_can_fire = tNetPacket.r_u8(); + if (m_wVersion >= 128) m_can_fire = tNetPacket.r_u8(); } -void CSE_SmartCover::STATE_Write(NET_Packet &tNetPacket) +void CSE_SmartCover::STATE_Write(NET_Packet& tNetPacket) { - inherited1::STATE_Write (tNetPacket); - cform_write (tNetPacket); - tNetPacket.w_stringZ (m_description); - tNetPacket.w_float (m_hold_position_time); - tNetPacket.w_float (m_enter_min_enemy_distance); - tNetPacket.w_float (m_exit_min_enemy_distance); - tNetPacket.w_u8 ((u8)m_is_combat_cover); - tNetPacket.w_u8 ((u8)m_can_fire); + inherited1::STATE_Write(tNetPacket); + cform_write(tNetPacket); + tNetPacket.w_stringZ(m_description); + tNetPacket.w_float(m_hold_position_time); + tNetPacket.w_float(m_enter_min_enemy_distance); + tNetPacket.w_float(m_exit_min_enemy_distance); + tNetPacket.w_u8((u8)m_is_combat_cover); + tNetPacket.w_u8((u8)m_can_fire); } -void CSE_SmartCover::UPDATE_Read(NET_Packet &tNetPacket) +void CSE_SmartCover::UPDATE_Read(NET_Packet& tNetPacket) { - inherited1::UPDATE_Read (tNetPacket); + inherited1::UPDATE_Read(tNetPacket); } -void CSE_SmartCover::UPDATE_Write(NET_Packet &tNetPacket) +void CSE_SmartCover::UPDATE_Write(NET_Packet& tNetPacket) { - inherited1::UPDATE_Write (tNetPacket); + inherited1::UPDATE_Write(tNetPacket); } #ifndef XRGAME_EXPORTS -void CSE_SmartCover::FillProps (LPCSTR pref, PropItemVec& items) +void CSE_SmartCover::FillProps(LPCSTR pref, PropItemVec& items) { -# ifdef XRSE_FACTORY_EXPORTS - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"hold position time"), &m_hold_position_time, 0.f, 60.f); - RListValue *value = PHelper().CreateRList (items, PrepareKey(pref,*s_name,"description"), &m_description, &*fp_data.smart_covers.begin(), fp_data.smart_covers.size()); - value->OnChangeEvent.bind (this,&CSE_SmartCover::OnChangeDescription); +#ifdef XRSE_FACTORY_EXPORTS + PHelper().CreateFloat(items, PrepareKey(pref, *s_name, "hold position time"), &m_hold_position_time, 0.f, 60.f); + RListValue* value = PHelper().CreateRList(items, PrepareKey(pref, *s_name, "description"), &m_description, + &*fp_data.smart_covers.begin(), fp_data.smart_covers.size()); + value->OnChangeEvent.bind(this, &CSE_SmartCover::OnChangeDescription); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"enter min enemy distance"),&m_enter_min_enemy_distance, 0.f, 100.f); - PHelper().CreateFloat (items, PrepareKey(pref,*s_name,"exit min enemy distance"), &m_exit_min_enemy_distance, 0.f, 100.f); + PHelper().CreateFloat( + items, PrepareKey(pref, *s_name, "enter min enemy distance"), &m_enter_min_enemy_distance, 0.f, 100.f); + PHelper().CreateFloat( + items, PrepareKey(pref, *s_name, "exit min enemy distance"), &m_exit_min_enemy_distance, 0.f, 100.f); if (is_combat_cover(m_description)) { - PHelper().CreateBOOL (items, PrepareKey(pref, *s_name, "is combat cover"), &m_is_combat_cover); - PHelper().CreateBOOL (items, PrepareKey(pref, *s_name, "can fire"), &m_can_fire); + PHelper().CreateBOOL(items, PrepareKey(pref, *s_name, "is combat cover"), &m_is_combat_cover); + PHelper().CreateBOOL(items, PrepareKey(pref, *s_name, "can fire"), &m_can_fire); } -# endif // #ifdef XRSE_FACTORY_EXPORTS +#endif // #ifdef XRSE_FACTORY_EXPORTS } -#endif // #ifndef XRGAME_EXPORTS +#endif // #ifndef XRGAME_EXPORTS #ifdef XRSE_FACTORY_EXPORTS -void CSE_SmartCover::set_loopholes_table_checker(BOOLValue *value){ - value->OnChangeEvent.bind (this,&CSE_SmartCover::OnChangeLoopholes); +void CSE_SmartCover::set_loopholes_table_checker(BOOLValue* value) +{ + value->OnChangeEvent.bind(this, &CSE_SmartCover::OnChangeLoopholes); } void CSE_SmartCover::OnChangeLoopholes(PropValue* sender) { - CScriptValueContainer::assign ( ); - m_need_to_reparse_loopholes = true; + CScriptValueContainer::assign(); + m_need_to_reparse_loopholes = true; } void CSE_SmartCover::OnChangeDescription(PropValue* sender) -{ - set_editor_flag (flVisualChange); - load_draw_data (); +{ + set_editor_flag(flVisualChange); + load_draw_data(); } -LPCSTR parse_string(luabind::object const &table, LPCSTR identifier) +LPCSTR parse_string(luabind::object const& table, LPCSTR identifier) { - VERIFY2 (table.type() == LUA_TTABLE, "invalid loophole description passed"); + VERIFY2(table.type() == LUA_TTABLE, "invalid loophole description passed"); luabind::object result = table[identifier]; - VERIFY2 (result.type() != LUA_TNIL, make_string("cannot read string value %s", identifier)); - VERIFY2 (result.type() == LUA_TSTRING, make_string("cannot read string value %s", identifier)); - return (luabind::object_cast(result)); + VERIFY2(result.type() != LUA_TNIL, make_string("cannot read string value %s", identifier)); + VERIFY2(result.type() == LUA_TSTRING, make_string("cannot read string value %s", identifier)); + return (luabind::object_cast(result)); } -Fvector parse_fvector (luabind::object const &table, LPCSTR identifier) +Fvector parse_fvector(luabind::object const& table, LPCSTR identifier) { - VERIFY2 (table.type() == LUA_TTABLE, "invalid loophole description passed"); + VERIFY2(table.type() == LUA_TTABLE, "invalid loophole description passed"); luabind::object result = table[identifier]; - VERIFY2 (result.type() != LUA_TNIL, make_string("cannot read vector value %s", identifier)); - return (luabind::object_cast(result)); + VERIFY2(result.type() != LUA_TNIL, make_string("cannot read vector value %s", identifier)); + return (luabind::object_cast(result)); } -float parse_float ( - luabind::object const &table, - LPCSTR identifier, - float const &min_threshold = flt_min, - float const &max_threshold = flt_max - ) +float parse_float(luabind::object const& table, LPCSTR identifier, float const& min_threshold = flt_min, + float const& max_threshold = flt_max) { - VERIFY2 (table.type() == LUA_TTABLE, "invalid loophole description passed"); + VERIFY2(table.type() == LUA_TTABLE, "invalid loophole description passed"); luabind::object lua_result = table[identifier]; - VERIFY2 (lua_result.type() != LUA_TNIL, make_string("cannot read number value %s", identifier)); - VERIFY2 (lua_result.type() == LUA_TNUMBER, make_string("cannot read number value %s", identifier)); - float result = luabind::object_cast(lua_result); - VERIFY2 (result >= min_threshold, make_string("invalid read number value %s", identifier)); - VERIFY2 (result <= max_threshold, make_string("invalid number value %s", identifier)); - return (result); + VERIFY2(lua_result.type() != LUA_TNIL, make_string("cannot read number value %s", identifier)); + VERIFY2(lua_result.type() == LUA_TNUMBER, make_string("cannot read number value %s", identifier)); + float result = luabind::object_cast(lua_result); + VERIFY2(result >= min_threshold, make_string("invalid read number value %s", identifier)); + VERIFY2(result <= max_threshold, make_string("invalid number value %s", identifier)); + return (result); } -void parse_table (luabind::object const &table, LPCSTR identifier, luabind::object &result) +void parse_table(luabind::object const& table, LPCSTR identifier, luabind::object& result) { - VERIFY2 (table.type() == LUA_TTABLE, "invalid loophole description passed"); - result = table[identifier]; - VERIFY2 (result.type() != LUA_TNIL, make_string("cannot read table value %s", identifier)); - VERIFY2 (result.type() == LUA_TTABLE, make_string("cannot read table value %s", identifier)); + VERIFY2(table.type() == LUA_TTABLE, "invalid loophole description passed"); + result = table[identifier]; + VERIFY2(result.type() != LUA_TNIL, make_string("cannot read table value %s", identifier)); + VERIFY2(result.type() == LUA_TTABLE, make_string("cannot read table value %s", identifier)); } -namespace smart_cover { - static LPCSTR s_enter_loophole_id = "<__ENTER__>"; - static LPCSTR s_exit_loophole_id = "<__EXIT__>"; +namespace smart_cover +{ +static LPCSTR s_enter_loophole_id = "<__ENTER__>"; +static LPCSTR s_exit_loophole_id = "<__EXIT__>"; - shared_str transform_vertex(shared_str const &vertex_id, bool const &in) - { - if (*vertex_id.c_str()) - return (vertex_id); +shared_str transform_vertex(shared_str const& vertex_id, bool const& in) +{ + if (*vertex_id.c_str()) return (vertex_id); - if (in) - return (s_enter_loophole_id); + if (in) return (s_enter_loophole_id); - return (s_exit_loophole_id); - } + return (s_exit_loophole_id); +} - shared_str parse_vertex (luabind::object const &table, LPCSTR identifier, bool const &in) - { - return ( - transform_vertex( - parse_string( - table, - identifier - ), - in - ) - ); - } -} // namespace smart_cover +shared_str parse_vertex(luabind::object const& table, LPCSTR identifier, bool const& in) +{ + return (transform_vertex(parse_string(table, identifier), in)); +} +} // namespace smart_cover -void CSE_SmartCover::set_enterable (shared_str const &id) +void CSE_SmartCover::set_enterable(shared_str const& id) { - class id_predicate { - shared_str m_id; + class id_predicate + { + shared_str m_id; public: - IC id_predicate (shared_str const &id) : - m_id (id) - { - } - - IC bool operator() (SSCDrawHelper const &h) const - { - return (m_id._get() == h.string_identifier._get()); - } + IC id_predicate(shared_str const& id) : m_id(id) {} + IC bool operator()(SSCDrawHelper const& h) const { return (m_id._get() == h.string_identifier._get()); } }; - xr_vector::iterator found = std::find_if( - m_draw_data.begin(), - m_draw_data.end(), - id_predicate(id) - ); - //VERIFY2 (found != m_draw_data.end(), id.c_str()); - if (found == m_draw_data.end()) - return; + xr_vector::iterator found = std::find_if(m_draw_data.begin(), m_draw_data.end(), id_predicate(id)); + // VERIFY2 (found != m_draw_data.end(), id.c_str()); + if (found == m_draw_data.end()) return; - found->is_enterable = true; + found->is_enterable = true; } -void CSE_SmartCover::check_enterable_loopholes(shared_str const &description) +void CSE_SmartCover::check_enterable_loopholes(shared_str const& description) { - string256 temp; - xr_strcpy (temp, "smart_covers.descriptions."); - xr_strcat (temp, m_description.c_str()); - xr_strcat (temp, ".transitions"); - - luabind::object transitions; - bool result = - ai().script_engine().function_object( - temp, - transitions, - LUA_TTABLE - ); - VERIFY2 (result, make_string("bad or missing transitions table in smart_cover [%s]", temp)); - - luabind::object::iterator I = transitions.begin(); - luabind::object::iterator E = transitions.end(); - for ( ; I != E; ++I) { - luabind::object table = *I; + string256 temp; + xr_strcpy(temp, "smart_covers.descriptions."); + xr_strcat(temp, m_description.c_str()); + xr_strcat(temp, ".transitions"); + + luabind::object transitions; + bool result = ai().script_engine().function_object(temp, transitions, LUA_TTABLE); + VERIFY2(result, make_string("bad or missing transitions table in smart_cover [%s]", temp)); + + luabind::object::iterator I = transitions.begin(); + luabind::object::iterator E = transitions.end(); + for (; I != E; ++I) + { + luabind::object table = *I; if (table.type() != LUA_TTABLE) { - VERIFY (table.type() != LUA_TNIL); + VERIFY(table.type() != LUA_TNIL); continue; } - shared_str vertex_0 = smart_cover::parse_vertex(table, "vertex0", true); - if (vertex_0 != smart_cover::transform_vertex("", true)) - continue; + shared_str vertex_0 = smart_cover::parse_vertex(table, "vertex0", true); + if (vertex_0 != smart_cover::transform_vertex("", true)) continue; - set_enterable (smart_cover::parse_vertex(table, "vertex1", false)); + set_enterable(smart_cover::parse_vertex(table, "vertex1", false)); } } -class CSE_SmartVisual : public CSE_Visual { +class CSE_SmartVisual : public CSE_Visual +{ public: - virtual CSE_Visual* __stdcall visual () - { - return (this); - } -}; // class CSE_SmartVisual + virtual CSE_Visual* __stdcall visual() { return (this); } +}; // class CSE_SmartVisual void CSE_SmartCover::fill_visuals() { @@ -353,238 +318,242 @@ void CSE_SmartCover::fill_visuals() xr_vector::iterator I = m_draw_data.begin(); xr_vector::iterator E = m_draw_data.end(); - for ( ; I != E; ++I) { - if (!I->is_enterable) - return; + for (; I != E; ++I) + { + if (!I->is_enterable) return; - CSE_Visual *visual = new CSE_SmartVisual(); - visual->set_visual ("actors\\stalker_neutral\\stalker_neutral_1"); + CSE_Visual* visual = new CSE_SmartVisual(); + visual->set_visual("actors\\stalker_neutral\\stalker_neutral_1"); if (I->animation_id.size() == 0) { - Msg ("cover [%s] doesn't have idle_2_fire animation", I->string_identifier.c_str()); + Msg("cover [%s] doesn't have idle_2_fire animation", I->string_identifier.c_str()); return; } - visual->startup_animation = I->animation_id; + visual->startup_animation = I->animation_id; - visual_data tmp; - tmp.visual = visual; - tmp.matrix.rotation (I->enter_direction, Fvector().set(0.f, 1.f, 0.f)); - tmp.matrix.c = I->point_position; + visual_data tmp; + tmp.visual = visual; + tmp.matrix.rotation(I->enter_direction, Fvector().set(0.f, 1.f, 0.f)); + tmp.matrix.c = I->point_position; - m_visuals.push_back (tmp); + m_visuals.push_back(tmp); } } -void draw_frustum (CDUInterface* du, float FOV, float _FAR, float A, Fvector &P, Fvector &D, Fvector &U, u32 const &CL) +void draw_frustum(CDUInterface* du, float FOV, float _FAR, float A, Fvector& P, Fvector& D, Fvector& U, u32 const& CL) { - float YFov = deg2rad(FOV*A); - float XFov = deg2rad(FOV); + float YFov = deg2rad(FOV * A); + float XFov = deg2rad(FOV); // calc window extents in camera coords - float wR=tanf(XFov*0.5f); - float wL=-wR; - float wT=tanf(YFov*0.5f); - float wB=-wT; + float wR = tanf(XFov * 0.5f); + float wL = -wR; + float wT = tanf(YFov * 0.5f); + float wB = -wT; // calc x-axis (viewhoriz) and store cop // here we are assuring that vectors are perpendicular & normalized - Fvector R,COP; - D.normalize (); - R.crossproduct (D,U); - R.normalize (); - U.crossproduct (R,D); - U.normalize (); - COP.set (P); + Fvector R, COP; + D.normalize(); + R.crossproduct(D, U); + R.normalize(); + U.crossproduct(R, D); + U.normalize(); + COP.set(P); // calculate the corner vertices of the window - Fvector sPts[4]; // silhouette points (corners of window) - Fvector Offset,T; - Offset.add (D,COP); - - sPts[0].mul(R,wR); T.mad(Offset,U,wT); sPts[0].add(T); - sPts[1].mul(R,wL); T.mad(Offset,U,wT); sPts[1].add(T); - sPts[2].mul(R,wL); T.mad(Offset,U,wB); sPts[2].add(T); - sPts[3].mul(R,wR); T.mad(Offset,U,wB); sPts[3].add(T); + Fvector sPts[4]; // silhouette points (corners of window) + Fvector Offset, T; + Offset.add(D, COP); + + sPts[0].mul(R, wR); + T.mad(Offset, U, wT); + sPts[0].add(T); + sPts[1].mul(R, wL); + T.mad(Offset, U, wT); + sPts[1].add(T); + sPts[2].mul(R, wL); + T.mad(Offset, U, wB); + sPts[2].add(T); + sPts[3].mul(R, wR); + T.mad(Offset, U, wB); + sPts[3].add(T); // find projector direction vectors (from cop through silhouette pts) Fvector ProjDirs[4]; - ProjDirs[0].sub(sPts[0],COP); - ProjDirs[1].sub(sPts[1],COP); - ProjDirs[2].sub(sPts[2],COP); - ProjDirs[3].sub(sPts[3],COP); + ProjDirs[0].sub(sPts[0], COP); + ProjDirs[1].sub(sPts[1], COP); + ProjDirs[2].sub(sPts[2], COP); + ProjDirs[3].sub(sPts[3], COP); Fvector _F[4]; - _F[0].mad(COP, ProjDirs[0], _FAR); - _F[1].mad(COP, ProjDirs[1], _FAR); - _F[2].mad(COP, ProjDirs[2], _FAR); - _F[3].mad(COP, ProjDirs[3], _FAR); - - du->DrawLine(COP,_F[0],CL); - du->DrawLine(COP,_F[1],CL); - du->DrawLine(COP,_F[2],CL); - du->DrawLine(COP,_F[3],CL); - - du->DrawLine(_F[0],_F[1],CL); - du->DrawLine(_F[1],_F[2],CL); - du->DrawLine(_F[2],_F[3],CL); - du->DrawLine(_F[3],_F[0],CL); + _F[0].mad(COP, ProjDirs[0], _FAR); + _F[1].mad(COP, ProjDirs[1], _FAR); + _F[2].mad(COP, ProjDirs[2], _FAR); + _F[3].mad(COP, ProjDirs[3], _FAR); + + du->DrawLine(COP, _F[0], CL); + du->DrawLine(COP, _F[1], CL); + du->DrawLine(COP, _F[2], CL); + du->DrawLine(COP, _F[3], CL); + + du->DrawLine(_F[0], _F[1], CL); + du->DrawLine(_F[1], _F[2], CL); + du->DrawLine(_F[2], _F[3], CL); + du->DrawLine(_F[3], _F[0], CL); } shared_str animation_id(luabind::object table) { luabind::object::iterator i = table.begin(); luabind::object::iterator e = table.end(); - for ( ; i != e; ++i ) { + for (; i != e; ++i) + { luabind::object string = *i; if (string.type() != LUA_TSTRING) { - VERIFY (string.type() != LUA_TNIL); + VERIFY(string.type() != LUA_TNIL); continue; } - return (luabind::object_cast(string)); + return (luabind::object_cast(string)); } - return (""); + return (""); } -void CSE_SmartCover::load_draw_data () { - string256 temp; - xr_strcpy (temp, "smart_covers.descriptions."); - xr_strcat (temp, m_description.c_str()); - xr_strcat (temp, ".loopholes"); +void CSE_SmartCover::load_draw_data() +{ + string256 temp; + xr_strcpy(temp, "smart_covers.descriptions."); + xr_strcat(temp, m_description.c_str()); + xr_strcat(temp, ".loopholes"); - m_draw_data.clear (); + m_draw_data.clear(); - luabind::object loopholes; - bool result = - ai().script_engine().function_object( - temp, - loopholes, - LUA_TTABLE - ); + luabind::object loopholes; + bool result = ai().script_engine().function_object(temp, loopholes, LUA_TTABLE); if (!result) { - Msg ("no or invalid smart cover description (bad or missing loopholes table in smart_cover [%s])", temp); + Msg("no or invalid smart cover description (bad or missing loopholes table in smart_cover [%s])", temp); return; - // VERIFY2 (result, make_string("bad or missing loopholes table in smart_cover [%s]", temp)); + // VERIFY2 (result, make_string("bad or missing loopholes table in smart_cover [%s]", + // temp)); } - luabind::object::iterator I = loopholes.begin(); - luabind::object::iterator E = loopholes.end(); - for ( ; I != E; ++I) { - + luabind::object::iterator I = loopholes.begin(); + luabind::object::iterator E = loopholes.end(); + for (; I != E; ++I) + { bool loophole_exist = true; if (m_available_loopholes.is_valid()) { - luabind::object::iterator i = m_available_loopholes.begin( ); - luabind::object::iterator e = m_available_loopholes.end( ); - for ( ; i != e; ++i ) { - LPCSTR const loophole_id= luabind::object_cast< LPCSTR >( i.key( ) ); - shared_str descr_loophole_id = parse_string(*I,"id"); - if ( xr_strcmp( loophole_id, descr_loophole_id ) ) - continue; - if ( !luabind::object_cast< bool >( *i ) ) - loophole_exist = false; + luabind::object::iterator i = m_available_loopholes.begin(); + luabind::object::iterator e = m_available_loopholes.end(); + for (; i != e; ++i) + { + LPCSTR const loophole_id = luabind::object_cast(i.key()); + shared_str descr_loophole_id = parse_string(*I, "id"); + if (xr_strcmp(loophole_id, descr_loophole_id)) continue; + if (!luabind::object_cast(*i)) loophole_exist = false; break; } } - if (!loophole_exist) - continue; + if (!loophole_exist) continue; - luabind::object table = *I; + luabind::object table = *I; if (table.type() != LUA_TTABLE) { - VERIFY (table.type() != LUA_TNIL); + VERIFY(table.type() != LUA_TNIL); continue; } - m_draw_data.resize (m_draw_data.size()+1); - SSCDrawHelper& H = m_draw_data.back(); + m_draw_data.resize(m_draw_data.size() + 1); + SSCDrawHelper& H = m_draw_data.back(); - H.string_identifier = parse_string(table,"id"); - H.point_position = parse_fvector(table, "fov_position"); - H.is_enterable = false; - H.fov_direction = parse_fvector(table, "fov_direction"); + H.string_identifier = parse_string(table, "id"); + H.point_position = parse_fvector(table, "fov_position"); + H.is_enterable = false; + H.fov_direction = parse_fvector(table, "fov_direction"); if (H.fov_direction.square_magnitude() < EPS_L) { - Msg ("! fov direction for loophole %s is setup incorrectly", H.string_identifier.c_str()); + Msg("! fov direction for loophole %s is setup incorrectly", H.string_identifier.c_str()); H.fov_direction.set(0.f, 0.f, 1.f); } else - H.fov_direction.normalize (); + H.fov_direction.normalize(); - H.enter_direction = parse_fvector(table, "enter_direction"); + H.enter_direction = parse_fvector(table, "enter_direction"); if (H.enter_direction.square_magnitude() < EPS_L) { - Msg ("! enter direction for loophole %s is setup incorrectly", H.string_identifier.c_str()); + Msg("! enter direction for loophole %s is setup incorrectly", H.string_identifier.c_str()); H.enter_direction.set(0.f, 0.f, 1.f); } else - H.enter_direction.normalize (); - - H.fov = parse_float(table, "fov", 0.f, 360.f); - H.range = parse_float(table, "range", 0.f); - -/* luabind::object transitions; - parse_table (table, "transitions", transitions); - luabind::object::iterator I = transitions.begin(); - luabind::object::iterator E = transitions.end(); - for ( ; I != E; ++I) { - luabind::object transition = *I; - VERIFY2 (transition.type() == LUA_TTABLE, "invalid loophole description passed"); - shared_str action_from = smart_cover::parse_vertex(transition, "action_from", true); - if (action_from != "idle") - continue; - shared_str action_to = smart_cover::parse_vertex(transition, "action_to", false); - if (action_to != "fire") - continue; - - luabind::object result; - parse_table (transition, "animations", result); - - H.animation_id = animation_id(result); - break; - } -*/ - - H.animation_id = make_string("loophole_%s_visual", H.string_identifier.c_str()).c_str(); + H.enter_direction.normalize(); + + H.fov = parse_float(table, "fov", 0.f, 360.f); + H.range = parse_float(table, "range", 0.f); + + /* luabind::object transitions; + parse_table (table, "transitions", transitions); + luabind::object::iterator I = transitions.begin(); + luabind::object::iterator E = transitions.end(); + for ( ; I != E; ++I) { + luabind::object transition = *I; + VERIFY2 (transition.type() == LUA_TTABLE, "invalid loophole description passed"); + shared_str action_from = smart_cover::parse_vertex(transition, "action_from", true); + if (action_from != "idle") + continue; + shared_str action_to = smart_cover::parse_vertex(transition, "action_to", false); + if (action_to != "fire") + continue; + + luabind::object result; + parse_table (transition, "animations", result); + + H.animation_id = animation_id(result); + break; + } + */ + + H.animation_id = make_string("loophole_%s_visual", H.string_identifier.c_str()).c_str(); } - check_enterable_loopholes (m_description); - fill_visuals (); + check_enterable_loopholes(m_description); + fill_visuals(); } -void CSE_SmartCover::on_render (CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent,int priority, bool strictB2F) +void CSE_SmartCover::on_render( + CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent, int priority, bool strictB2F) { - inherited1::on_render (du, owner, bSelected, parent, priority, strictB2F); - if ( !((1==priority)&&(false==strictB2F)) ) - return; + inherited1::on_render(du, owner, bSelected, parent, priority, strictB2F); + if (!((1 == priority) && (false == strictB2F))) return; - if( m_need_to_reparse_loopholes&&m_description.size() ) - { - OnChangeDescription (NULL); + if (m_need_to_reparse_loopholes && m_description.size()) { + OnChangeDescription(NULL); m_need_to_reparse_loopholes = false; } - if (!bSelected) - return; + if (!bSelected) return; xr_vector::iterator it = m_draw_data.begin(); xr_vector::iterator it_e = m_draw_data.end(); - for( ; it!=it_e; ++it){ + for (; it != it_e; ++it) + { SSCDrawHelper& H = *it; Fvector pos = H.point_position; - parent.transform_tiny (pos); + parent.transform_tiny(pos); - du->OutText(pos, H.string_identifier.c_str(), color_rgba(255,255,255,255)); + du->OutText(pos, H.string_identifier.c_str(), color_rgba(255, 255, 255, 255)); - //du->DrawBox(H.point_position,Fvector().set(0.2f,0.2f,0.2f),TRUE,TRUE,color_rgba(255,0,0,80),color_rgba(0,255,0,255)); - //du->DrawFlag(H.point_position, 0, 1.0f, 1, 1, color_rgba(0,255,0,255), FALSE); - //du->DrawCylinder(Fidentity, pos, Fvector().set(0.f, 1.f, 0.f), 1.f, .05f, color_rgba(0,255,0,255), color_rgba(0,255,0,255), TRUE, FALSE); + // du->DrawBox(H.point_position,Fvector().set(0.2f,0.2f,0.2f),TRUE,TRUE,color_rgba(255,0,0,80),color_rgba(0,255,0,255)); + // du->DrawFlag(H.point_position, 0, 1.0f, 1, 1, color_rgba(0,255,0,255), FALSE); + // du->DrawCylinder(Fidentity, pos, Fvector().set(0.f, 1.f, 0.f), 1.f, .05f, color_rgba(0,255,0,255), + // color_rgba(0,255,0,255), TRUE, FALSE); Fvector dir = H.fov_direction; parent.transform_dir(dir); Fvector up = parent.j; - draw_frustum(du, H.fov, H.range, 1.f, pos, dir, up, color_rgba(255,0,0,255)); + draw_frustum(du, H.fov, H.range, 1.f, pos, dir, up, color_rgba(255, 0, 0, 255)); } } -#endif // #ifdef XRSE_FACTORY_EXPORTS +#endif // #ifdef XRSE_FACTORY_EXPORTS diff --git a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h index 964f021f828..7a89c9acf63 100644 --- a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h +++ b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers.h @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////////////////////// // Module : xrServer_Objects_ALife_Smartcovers.h // Created : 17.12.2008 -// Modified : +// Modified : // Author : Alexander Plichko // Description : Server objects smartcovers for ALife simulator //////////////////////////////////////////////////////////////////////////// @@ -12,76 +12,79 @@ #include "xrServer_Objects_ALife.h" #pragma warning(push) -#pragma warning(disable:4005) +#pragma warning(disable : 4005) class CSE_ALifeDynamicObject; -class CSE_SmartCover : - public CSE_ALifeDynamicObject, - public CSE_Shape +class CSE_SmartCover : public CSE_ALifeDynamicObject, public CSE_Shape { using inherited1 = CSE_ALifeDynamicObject; using inherited2 = CSE_Shape; + public: - struct SSCDrawHelper{ - shared_str string_identifier; - Fvector point_position; - bool is_enterable; - Fvector enter_direction; - float fov; - float range; - Fvector fov_direction; - shared_str animation_id; + struct SSCDrawHelper + { + shared_str string_identifier; + Fvector point_position; + bool is_enterable; + Fvector enter_direction; + float fov; + float range; + Fvector fov_direction; + shared_str animation_id; }; - xr_vector m_draw_data; - shared_str m_description; - float m_hold_position_time; - float m_enter_min_enemy_distance; - float m_exit_min_enemy_distance; - BOOL m_is_combat_cover; - BOOL m_can_fire; - bool m_need_to_reparse_loopholes; + xr_vector m_draw_data; + shared_str m_description; + float m_hold_position_time; + float m_enter_min_enemy_distance; + float m_exit_min_enemy_distance; + BOOL m_is_combat_cover; + BOOL m_can_fire; + bool m_need_to_reparse_loopholes; #ifndef AI_COMPILER - luabind::object m_available_loopholes; -#endif // #ifndef AI_COMPILER + luabind::object m_available_loopholes; +#endif // #ifndef AI_COMPILER #ifdef XRSE_FACTORY_EXPORTS private: - typedef xr_vector visuals_collection; + typedef xr_vector visuals_collection; + + void __stdcall OnChangeDescription(PropValue* sender); + void __stdcall OnChangeLoopholes(PropValue* sender); - void __stdcall OnChangeDescription (PropValue* sender); - void __stdcall OnChangeLoopholes (PropValue* sender); public: - void set_loopholes_table_checker (BOOLValue *value); -private: - mutable visuals_collection m_visuals; -#endif // #ifdef XRSE_FACTORY_EXPORTS + void set_loopholes_table_checker(BOOLValue* value); +private: + mutable visuals_collection m_visuals; +#endif // #ifdef XRSE_FACTORY_EXPORTS public: - CSE_SmartCover (LPCSTR caSection); - virtual ~CSE_SmartCover (); - virtual IServerEntityShape* __stdcall shape (); - virtual bool used_ai_locations () const; - virtual bool can_save () const; - virtual bool can_switch_online () const; - virtual bool can_switch_offline () const; - virtual bool interactive () const; - LPCSTR description () const; + CSE_SmartCover(LPCSTR caSection); + virtual ~CSE_SmartCover(); + virtual IServerEntityShape* __stdcall shape(); + virtual bool used_ai_locations() const; + virtual bool can_save() const; + virtual bool can_switch_online() const; + virtual bool can_switch_offline() const; + virtual bool interactive() const; + LPCSTR description() const; #ifndef AI_COMPILER - void set_available_loopholes (luabind::object table); -#endif // #ifndef AI_COMPILER + void set_available_loopholes(luabind::object table); +#endif // #ifndef AI_COMPILER #ifdef XRSE_FACTORY_EXPORTS - virtual void __stdcall on_render (CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, const Fmatrix& parent,int priority, bool strictB2F); - virtual visual_data*__stdcall visual_collection () const { return &*m_visuals.begin(); } - virtual u32 __stdcall visual_collection_size () const { return m_visuals.size(); } -#endif // #ifdef XRSE_FACTORY_EXPORTS + virtual void __stdcall on_render(CDUInterface* du, IServerEntityLEOwner* owner, bool bSelected, + const Fmatrix& parent, int priority, bool strictB2F); + virtual visual_data* __stdcall visual_collection() const { return &*m_visuals.begin(); } + virtual u32 __stdcall visual_collection_size() const { return m_visuals.size(); } +#endif // #ifdef XRSE_FACTORY_EXPORTS private: - void check_enterable_loopholes(shared_str const &description); - void set_enterable (shared_str const &id); - void fill_visuals (); - void load_draw_data (); + void check_enterable_loopholes(shared_str const& description); + void set_enterable(shared_str const& id); + void fill_visuals(); + void load_draw_data(); + public: virtual void UPDATE_Read(NET_Packet& P); virtual void UPDATE_Write(NET_Packet& P); diff --git a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers_script.cpp b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers_script.cpp index fe2a43e0155..396543d4ea0 100644 --- a/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_Alife_Smartcovers_script.cpp @@ -7,23 +7,21 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife_Smartcovers.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -static void CSE_SmartCover_Export(lua_State *luaState) +static void CSE_SmartCover_Export(lua_State* luaState) { - module(luaState) - [ - luabind_class_dynamic_alife1(CSE_SmartCover, "cse_smart_cover", CSE_ALifeDynamicObject) - .def("description", &CSE_SmartCover::description) + module(luaState)[luabind_class_dynamic_alife1(CSE_SmartCover, "cse_smart_cover", CSE_ALifeDynamicObject) + .def("description", &CSE_SmartCover::description) #ifndef AI_COMPILER - .def("set_available_loopholes", &CSE_SmartCover::set_available_loopholes) + .def("set_available_loopholes", &CSE_SmartCover::set_available_loopholes) #endif #ifdef XRSE_FACTORY_EXPORTS - .def("set_loopholes_table_checker", &CSE_SmartCover::set_loopholes_table_checker) + .def("set_loopholes_table_checker", &CSE_SmartCover::set_loopholes_table_checker) #endif ]; } diff --git a/src/xrServerEntities/xrServer_Objects_script.cpp b/src/xrServerEntities/xrServer_Objects_script.cpp index da7579b00bb..6234d1f9d41 100644 --- a/src/xrServerEntities/xrServer_Objects_script.cpp +++ b/src/xrServerEntities/xrServer_Objects_script.cpp @@ -7,168 +7,114 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" -#include "xrServer_Objects.h" #include "phnetstate.h" -#include "xrServer_script_macroses.h" #include "script_ini_file.h" #include "xrScriptEngine/ScriptExporter.hpp" +#include "xrServer_Objects.h" +#include "xrServer_script_macroses.h" using namespace luabind; -LPCSTR get_section_name(const CSE_Abstract *abstract) +LPCSTR get_section_name(const CSE_Abstract* abstract) { - return (abstract->name()); + return (abstract->name()); } -LPCSTR get_name(const CSE_Abstract *abstract) +LPCSTR get_name(const CSE_Abstract* abstract) { - return (abstract->name_replace()); + return (abstract->name_replace()); } -CScriptIniFile *get_spawn_ini(CSE_Abstract *abstract) +CScriptIniFile* get_spawn_ini(CSE_Abstract* abstract) { - return ((CScriptIniFile*)&abstract->spawn_ini()); + return ((CScriptIniFile*)&abstract->spawn_ini()); } template -struct CWrapperBase : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperBase self_type; - - IC CWrapperBase(LPCSTR section) : T(section) - { - } - - virtual void STATE_Read(NET_Packet& p1) - { - call("STATE_Read",&p1); - } - static void STATE_Read_static(inherited* ptr, NET_Packet* p1) - { - Log("Attempt to call pure virtual method STATE_Read in CSE_Abstract"); - //ptr->self_type::inherited::STATE_Read(*p1); - } - virtual void STATE_Write(NET_Packet& p1) - { - call("STATE_Write",&p1); - } - static void STATE_Write_static(inherited* ptr, NET_Packet* p1) - { - Log("Attempt to call pure virtual method STATE_Write in CSE_Abstract"); - //ptr->self_type::inherited::STATE_Write(*p1); - } - - virtual void UPDATE_Read(NET_Packet& p1) - { - call("UPDATE_Read",&p1); - } - static void UPDATE_Read_static(inherited* ptr, NET_Packet* p1) - { - Log("Attempt to call pure virtual method UPDATE_Read in CSE_Abstract"); - //ptr->self_type::inherited::UPDATE_Read(*p1); - } - virtual void UPDATE_Write(NET_Packet& p1) - { - call("UPDATE_Write",&p1); - } - static void UPDATE_Write_static(inherited* ptr, NET_Packet* p1) - { - Log("Attempt to call pure virtual method UPDATE_Write in CSE_Abstract"); - //ptr->self_type::inherited::UPDATE_Write(*p1); - } - +struct CWrapperBase : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperBase self_type; + + IC CWrapperBase(LPCSTR section) : T(section) {} + virtual void STATE_Read(NET_Packet& p1) { call("STATE_Read", &p1); } + static void STATE_Read_static(inherited* ptr, NET_Packet* p1) + { + Log("Attempt to call pure virtual method STATE_Read in CSE_Abstract"); + // ptr->self_type::inherited::STATE_Read(*p1); + } + virtual void STATE_Write(NET_Packet& p1) { call("STATE_Write", &p1); } + static void STATE_Write_static(inherited* ptr, NET_Packet* p1) + { + Log("Attempt to call pure virtual method STATE_Write in CSE_Abstract"); + // ptr->self_type::inherited::STATE_Write(*p1); + } + + virtual void UPDATE_Read(NET_Packet& p1) { call("UPDATE_Read", &p1); } + static void UPDATE_Read_static(inherited* ptr, NET_Packet* p1) + { + Log("Attempt to call pure virtual method UPDATE_Read in CSE_Abstract"); + // ptr->self_type::inherited::UPDATE_Read(*p1); + } + virtual void UPDATE_Write(NET_Packet& p1) { call("UPDATE_Write", &p1); } + static void UPDATE_Write_static(inherited* ptr, NET_Packet* p1) + { + Log("Attempt to call pure virtual method UPDATE_Write in CSE_Abstract"); + // ptr->self_type::inherited::UPDATE_Write(*p1); + } }; -SCRIPT_EXPORT(CPureServerObject, (), -{ - module(luaState) - [ - class_ - ("iserializable"), - class_ - ("ipure_server_object"), - class_ - ("cpure_server_object") -// .def( constructor<>()) - ]; +SCRIPT_EXPORT(CPureServerObject, (), { + module(luaState)[class_("iserializable"), + class_("ipure_server_object"), + class_("cpure_server_object") + // .def( constructor<>()) + ]; }); -SCRIPT_EXPORT(CSE_Abstract, (CPureServerObject), -{ - typedef CWrapperBase WrapType; - typedef CSE_Abstract BaseType; - module(luaState) - [ - class_("cse_abstract") - .def_readonly ("id", &BaseType::ID) - .def_readonly ("parent_id", &BaseType::ID_Parent) - .def_readonly ("script_version", &BaseType::m_script_version) - .def_readwrite ("position", &BaseType::o_Position) - .def_readwrite ("angle", &BaseType::o_Angle) - .def ("section_name", &get_section_name) - .def ("name", &get_name) - .def ("clsid", &BaseType::script_clsid) - .def ("spawn_ini", &get_spawn_ini) - .def ("STATE_Read", &BaseType::STATE_Read, &WrapType::STATE_Read_static) - .def ("STATE_Write", &BaseType::STATE_Write, &WrapType::STATE_Write_static) - .def ("UPDATE_Read", &BaseType::UPDATE_Read, &WrapType::UPDATE_Read_static) - .def ("UPDATE_Write", &BaseType::UPDATE_Write, &WrapType::UPDATE_Write_static) -// .def( constructor()) - ]; +SCRIPT_EXPORT(CSE_Abstract, (CPureServerObject), { + typedef CWrapperBase WrapType; + typedef CSE_Abstract BaseType; + module(luaState)[class_("cse_abstract") + .def_readonly("id", &BaseType::ID) + .def_readonly("parent_id", &BaseType::ID_Parent) + .def_readonly("script_version", &BaseType::m_script_version) + .def_readwrite("position", &BaseType::o_Position) + .def_readwrite("angle", &BaseType::o_Angle) + .def("section_name", &get_section_name) + .def("name", &get_name) + .def("clsid", &BaseType::script_clsid) + .def("spawn_ini", &get_spawn_ini) + .def("STATE_Read", &BaseType::STATE_Read, &WrapType::STATE_Read_static) + .def("STATE_Write", &BaseType::STATE_Write, &WrapType::STATE_Write_static) + .def("UPDATE_Read", &BaseType::UPDATE_Read, &WrapType::UPDATE_Read_static) + .def("UPDATE_Write", &BaseType::UPDATE_Write, &WrapType::UPDATE_Write_static) + // .def( constructor()) + ]; }); -SCRIPT_EXPORT(CSE_Shape, (), -{ - module(luaState) - [ - class_ - ("cse_shape") -// .def( constructor<>()) - ]; +SCRIPT_EXPORT(CSE_Shape, (), { + module(luaState)[class_("cse_shape") + // .def( constructor<>()) + ]; }); -SCRIPT_EXPORT(CSE_Visual, (), -{ - module(luaState) - [ - class_ - ("cse_visual") -// .def( constructor<>()) -// .def( constructor()) - ]; +SCRIPT_EXPORT(CSE_Visual, (), { + module(luaState)[class_("cse_visual") + // .def( constructor<>()) + // .def( constructor()) + ]; }); -SCRIPT_EXPORT(CSE_Motion, (), -{ - module(luaState) - [ - class_ - ("cse_motion") -// .def( constructor<>()) -// .def( constructor()) - ]; +SCRIPT_EXPORT(CSE_Motion, (), { + module(luaState)[class_("cse_motion") + // .def( constructor<>()) + // .def( constructor()) + ]; }); SCRIPT_EXPORT(CSE_Spectator, (CSE_Abstract), -{ - module(luaState) - [ - luabind_class_abstract1( - CSE_Spectator, - "cse_spectator", - CSE_Abstract - ) - ]; -}); + { module(luaState)[luabind_class_abstract1(CSE_Spectator, "cse_spectator", CSE_Abstract)]; }); SCRIPT_EXPORT(CSE_Temporary, (CSE_Abstract), -{ - module(luaState) - [ - luabind_class_abstract1( - CSE_Temporary, - "cse_temporary", - CSE_Abstract - ) - ]; -}); + { module(luaState)[luabind_class_abstract1(CSE_Temporary, "cse_temporary", CSE_Abstract)]; }); diff --git a/src/xrServerEntities/xrServer_Objects_script2.cpp b/src/xrServerEntities/xrServer_Objects_script2.cpp index 606bc2cc655..bd6c7b87ec1 100644 --- a/src/xrServerEntities/xrServer_Objects_script2.cpp +++ b/src/xrServerEntities/xrServer_Objects_script2.cpp @@ -1,43 +1,27 @@ #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; -SCRIPT_EXPORT(CSE_PHSkeleton, (), -{ - module(luaState) - [ - class_ - ("cse_ph_skeleton") - ]; -}); +SCRIPT_EXPORT(CSE_PHSkeleton, (), { module(luaState)[class_("cse_ph_skeleton")]; }); -SCRIPT_EXPORT(CSE_AbstractVisual, (CSE_Visual, CSE_Abstract), -{ - module(luaState) - [ - luabind_class_abstract2( - CSE_AbstractVisual, - "CSE_AbstractVisual", - CSE_Visual, - CSE_Abstract - ) - .def ("getStartupAnimation", &CSE_AbstractVisual::getStartupAnimation) - ]; +SCRIPT_EXPORT(CSE_AbstractVisual, (CSE_Visual, CSE_Abstract), { + module(luaState)[luabind_class_abstract2(CSE_AbstractVisual, "CSE_AbstractVisual", CSE_Visual, + CSE_Abstract).def("getStartupAnimation", &CSE_AbstractVisual::getStartupAnimation)]; }); /** SCRIPT_EXPORT(CSE_SpawnGroup, (CSE_Abstract), { - module(luaState) + module(luaState) [ - luabind_class_abstract1( - CSE_SpawnGroup, - "cse_event", - CSE_Abstract - ) - ]; + luabind_class_abstract1( + CSE_SpawnGroup, + "cse_event", + CSE_Abstract + ) + ]; }); /**/ diff --git a/src/xrServerEntities/xrServer_Space.h b/src/xrServerEntities/xrServer_Space.h index 320f0205d58..a4121a6f505 100644 --- a/src/xrServerEntities/xrServer_Space.h +++ b/src/xrServerEntities/xrServer_Space.h @@ -10,43 +10,50 @@ #define xrServer_SpaceH #ifndef XRGAME_EXPORTS -# define SERVER_ENTITY_EDITOR_METHODS virtual void FillProps(LPCSTR pref, PropItemVec& values); -#else // #ifdef XRGAME_EXPORTS -# define SERVER_ENTITY_EDITOR_METHODS -#endif // #ifndef XRGAME_EXPORTS +#define SERVER_ENTITY_EDITOR_METHODS virtual void FillProps(LPCSTR pref, PropItemVec& values); +#else // #ifdef XRGAME_EXPORTS +#define SERVER_ENTITY_EDITOR_METHODS +#endif // #ifndef XRGAME_EXPORTS // XXX: move to core/math -struct SRotation +struct SRotation { - float yaw, pitch, roll; - SRotation() { yaw=pitch=roll=0; } - SRotation(float y, float p, float r) { yaw=y;pitch=p;roll=r; } + float yaw, pitch, roll; + SRotation() { yaw = pitch = roll = 0; } + SRotation(float y, float p, float r) + { + yaw = y; + pitch = p; + roll = r; + } }; -enum EPOType { - epotBox, - epotFixedChain, +enum EPOType +{ + epotBox, + epotFixedChain, epotFreeChain, epotSkeleton }; -DEFINE_VECTOR (u32, DWORD_VECTOR, DWORD_IT); -DEFINE_VECTOR (bool, BOOL_VECTOR, BOOL_IT); -DEFINE_VECTOR (float, FLOAT_VECTOR, FLOAT_IT); -DEFINE_VECTOR (LPSTR, LPSTR_VECTOR, LPSTR_IT); -DEFINE_VECTOR (Fvector, FVECTOR_VECTOR, FVECTOR_IT); +DEFINE_VECTOR(u32, DWORD_VECTOR, DWORD_IT); +DEFINE_VECTOR(bool, BOOL_VECTOR, BOOL_IT); +DEFINE_VECTOR(float, FLOAT_VECTOR, FLOAT_IT); +DEFINE_VECTOR(LPSTR, LPSTR_VECTOR, LPSTR_IT); +DEFINE_VECTOR(Fvector, FVECTOR_VECTOR, FVECTOR_IT); #ifdef XRGAME_EXPORTS -# define DECLARE_ENTITY_DESTROY +#define DECLARE_ENTITY_DESTROY #endif #ifdef XRSE_FACTORY_EXPORTS -# define DECLARE_ENTITY_DESTROY +#define DECLARE_ENTITY_DESTROY #endif #ifdef DECLARE_ENTITY_DESTROY -template void F_entity_Destroy (T *&P) +template +void F_entity_Destroy(T*& P) { - xr_delete (P); + xr_delete(P); }; #endif diff --git a/src/xrServerEntities/xrServer_script_macroses.h b/src/xrServerEntities/xrServer_script_macroses.h index 8928cfbe330..0d1c9826270 100644 --- a/src/xrServerEntities/xrServer_script_macroses.h +++ b/src/xrServerEntities/xrServer_script_macroses.h @@ -8,14 +8,14 @@ #pragma once -#include "xrScriptEngine/ScriptExportMacros.hpp" -#include "xrEProps.h" #include "ai_space.h" -#include "xrScriptEngine/script_engine.hpp" #include "luabind/error.hpp" +#include "xrEProps.h" +#include "xrScriptEngine/ScriptExportMacros.hpp" +#include "xrScriptEngine/script_engine.hpp" #ifdef XRGAME_EXPORTS #include "alife_smart_terrain_task.h" -#endif //#ifdef XRGAME_EXPORTS +#endif //#ifdef XRGAME_EXPORTS //#define USE_WRITER_READER class CSE_Abstract; @@ -23,7 +23,7 @@ class NET_Packet; class CSE_ALifeMonsterAbstract; #ifdef XRGAME_EXPORTS class CALifeSmartTerrainTask; -#endif //#ifdef XRGAME_EXPORTS +#endif //#ifdef XRGAME_EXPORTS #define INHERIT_PURE @@ -40,175 +40,182 @@ class CALifeSmartTerrainTask; //#endif #ifndef XRGAME_EXPORTS -# define INHERIT_ABSTRACT \ - INHERIT_PURE\ - DEFINE_LUA_WRAPPER_METHOD_R2P1_V1 (STATE_Write, NET_Packet)\ - DEFINE_LUA_WRAPPER_METHOD_R2P1_V2 (STATE_Read, NET_Packet, u16)\ - DEFINE_LUA_WRAPPER_METHOD_R2P2_V2 (FillProps, LPCSTR, PropItemVec)\ - DEFINE_LUA_WRAPPER_METHOD_0 (init, CSE_Abstract*) -#else // #ifndef XRGAME_EXPORTS -# define INHERIT_ABSTRACT \ - INHERIT_PURE\ - DEFINE_LUA_WRAPPER_METHOD_R2P1_V1 (STATE_Write, NET_Packet)\ - DEFINE_LUA_WRAPPER_METHOD_R2P1_V2 (STATE_Read, NET_Packet, u16)\ - DEFINE_LUA_WRAPPER_METHOD_0 (init, CSE_Abstract*) -#endif // #ifndef XRGAME_EXPORTS - -#define INHERIT_ALIFE \ - INHERIT_ABSTRACT\ - DEFINE_LUA_WRAPPER_CONST_METHOD_0 (used_ai_locations, bool)\ - DEFINE_LUA_WRAPPER_CONST_METHOD_0 (can_save, bool)\ - DEFINE_LUA_WRAPPER_CONST_METHOD_0 (can_switch_online, bool)\ - DEFINE_LUA_WRAPPER_CONST_METHOD_0 (can_switch_offline, bool)\ - DEFINE_LUA_WRAPPER_CONST_METHOD_0 (interactive, bool) +#define INHERIT_ABSTRACT \ + INHERIT_PURE \ + DEFINE_LUA_WRAPPER_METHOD_R2P1_V1(STATE_Write, NET_Packet) \ + DEFINE_LUA_WRAPPER_METHOD_R2P1_V2(STATE_Read, NET_Packet, u16) \ + DEFINE_LUA_WRAPPER_METHOD_R2P2_V2(FillProps, LPCSTR, PropItemVec) \ + DEFINE_LUA_WRAPPER_METHOD_0(init, CSE_Abstract*) +#else // #ifndef XRGAME_EXPORTS +#define INHERIT_ABSTRACT \ + INHERIT_PURE \ + DEFINE_LUA_WRAPPER_METHOD_R2P1_V1(STATE_Write, NET_Packet) \ + DEFINE_LUA_WRAPPER_METHOD_R2P1_V2(STATE_Read, NET_Packet, u16) \ + DEFINE_LUA_WRAPPER_METHOD_0(init, CSE_Abstract*) +#endif // #ifndef XRGAME_EXPORTS + +#define INHERIT_ALIFE \ + INHERIT_ABSTRACT \ + DEFINE_LUA_WRAPPER_CONST_METHOD_0(used_ai_locations, bool) \ + DEFINE_LUA_WRAPPER_CONST_METHOD_0(can_save, bool) \ + DEFINE_LUA_WRAPPER_CONST_METHOD_0(can_switch_online, bool) \ + DEFINE_LUA_WRAPPER_CONST_METHOD_0(can_switch_offline, bool) \ + DEFINE_LUA_WRAPPER_CONST_METHOD_0(interactive, bool) #ifdef XRGAME_EXPORTS -# define INHERIT_DYNAMIC_ALIFE \ - INHERIT_ALIFE\ - DEFINE_LUA_WRAPPER_METHOD_V0 (on_spawn)\ - DEFINE_LUA_WRAPPER_METHOD_V0 (on_before_register)\ - DEFINE_LUA_WRAPPER_METHOD_V0 (on_register)\ - DEFINE_LUA_WRAPPER_METHOD_V0 (on_unregister)\ - DEFINE_LUA_WRAPPER_CONST_METHOD_0 (keep_saved_data_anyway,bool)\ - DEFINE_LUA_WRAPPER_METHOD_V0 (switch_online)\ - DEFINE_LUA_WRAPPER_METHOD_V0 (switch_offline) +#define INHERIT_DYNAMIC_ALIFE \ + INHERIT_ALIFE \ + DEFINE_LUA_WRAPPER_METHOD_V0(on_spawn) \ + DEFINE_LUA_WRAPPER_METHOD_V0(on_before_register) \ + DEFINE_LUA_WRAPPER_METHOD_V0(on_register) \ + DEFINE_LUA_WRAPPER_METHOD_V0(on_unregister) \ + DEFINE_LUA_WRAPPER_CONST_METHOD_0(keep_saved_data_anyway, bool) \ + DEFINE_LUA_WRAPPER_METHOD_V0(switch_online) \ + DEFINE_LUA_WRAPPER_METHOD_V0(switch_offline) #else -# define INHERIT_DYNAMIC_ALIFE \ - INHERIT_ALIFE +#define INHERIT_DYNAMIC_ALIFE INHERIT_ALIFE #endif #ifdef XRGAME_EXPORTS -#define INHERIT_ONLINE_OFFLINE_GROUP \ - INHERIT_DYNAMIC_ALIFE \ - DEFINE_LUA_WRAPPER_METHOD_V0 (update) \ - DEFINE_LUA_WRAPPER_METHOD_0 (get_current_task,CALifeSmartTerrainTask*) +#define INHERIT_ONLINE_OFFLINE_GROUP \ + INHERIT_DYNAMIC_ALIFE \ + DEFINE_LUA_WRAPPER_METHOD_V0(update) \ + DEFINE_LUA_WRAPPER_METHOD_0(get_current_task, CALifeSmartTerrainTask*) #else -#define INHERIT_ONLINE_OFFLINE_GROUP \ - INHERIT_DYNAMIC_ALIFE \ - DEFINE_LUA_WRAPPER_METHOD_V0 (update) +#define INHERIT_ONLINE_OFFLINE_GROUP \ + INHERIT_DYNAMIC_ALIFE \ + DEFINE_LUA_WRAPPER_METHOD_V0(update) #endif #ifdef XRGAME_EXPORTS -# define INHERIT_ZONE \ - INHERIT_DYNAMIC_ALIFE\ - DEFINE_LUA_WRAPPER_METHOD_V0 (update)\ - DEFINE_LUA_WRAPPER_METHOD_V1 (smart_touch,CSE_ALifeMonsterAbstract*)\ - DEFINE_LUA_WRAPPER_CONST_METHOD_1 (enabled,bool,CSE_ALifeMonsterAbstract*)\ - DEFINE_LUA_WRAPPER_CONST_METHOD_1 (suitable,float,CSE_ALifeMonsterAbstract*)\ - DEFINE_LUA_WRAPPER_METHOD_V1 (register_npc,CSE_ALifeMonsterAbstract*)\ - DEFINE_LUA_WRAPPER_METHOD_V1 (unregister_npc,CSE_ALifeMonsterAbstract*)\ - DEFINE_LUA_WRAPPER_METHOD_1 (task,CALifeSmartTerrainTask*,CSE_ALifeMonsterAbstract*)\ - DEFINE_LUA_WRAPPER_METHOD_0 (detect_probability,float) +#define INHERIT_ZONE \ + INHERIT_DYNAMIC_ALIFE \ + DEFINE_LUA_WRAPPER_METHOD_V0(update) \ + DEFINE_LUA_WRAPPER_METHOD_V1(smart_touch, CSE_ALifeMonsterAbstract*) \ + DEFINE_LUA_WRAPPER_CONST_METHOD_1(enabled, bool, CSE_ALifeMonsterAbstract*) \ + DEFINE_LUA_WRAPPER_CONST_METHOD_1(suitable, float, CSE_ALifeMonsterAbstract*) \ + DEFINE_LUA_WRAPPER_METHOD_V1(register_npc, CSE_ALifeMonsterAbstract*) \ + DEFINE_LUA_WRAPPER_METHOD_V1(unregister_npc, CSE_ALifeMonsterAbstract*) \ + DEFINE_LUA_WRAPPER_METHOD_1(task, CALifeSmartTerrainTask*, CSE_ALifeMonsterAbstract*) \ + DEFINE_LUA_WRAPPER_METHOD_0(detect_probability, float) #else -# define INHERIT_ZONE \ - INHERIT_DYNAMIC_ALIFE\ - DEFINE_LUA_WRAPPER_METHOD_V0 (update)\ - DEFINE_LUA_WRAPPER_METHOD_V1 (smart_touch,CSE_ALifeMonsterAbstract*)\ - DEFINE_LUA_WRAPPER_METHOD_0 (detect_probability,float) +#define INHERIT_ZONE \ + INHERIT_DYNAMIC_ALIFE \ + DEFINE_LUA_WRAPPER_METHOD_V0(update) \ + DEFINE_LUA_WRAPPER_METHOD_V1(smart_touch, CSE_ALifeMonsterAbstract*) \ + DEFINE_LUA_WRAPPER_METHOD_0(detect_probability, float) #endif #ifdef XRGAME_EXPORTS -# define INHERIT_CREATURE \ - INHERIT_DYNAMIC_ALIFE\ - DEFINE_LUA_WRAPPER_METHOD_0 (g_team, u8)\ - DEFINE_LUA_WRAPPER_METHOD_0 (g_squad, u8)\ - DEFINE_LUA_WRAPPER_METHOD_0 (g_group, u8)\ - DEFINE_LUA_WRAPPER_METHOD_V1 (on_death, CSE_Abstract*) -#else // XRGAME_EXPORTS -# define INHERIT_CREATURE \ - INHERIT_DYNAMIC_ALIFE\ - DEFINE_LUA_WRAPPER_METHOD_0 (g_team, u8)\ - DEFINE_LUA_WRAPPER_METHOD_0 (g_squad, u8)\ - DEFINE_LUA_WRAPPER_METHOD_0 (g_group, u8) -#endif // XRGAME_EXPORTS - -#define INHERIT_MONSTER \ - INHERIT_CREATURE\ - DEFINE_LUA_WRAPPER_METHOD_V0 (update) - -#define INHERIT_ITEM \ - INHERIT_DYNAMIC_ALIFE\ - DEFINE_LUA_WRAPPER_METHOD_0 (bfUseful, bool) +#define INHERIT_CREATURE \ + INHERIT_DYNAMIC_ALIFE \ + DEFINE_LUA_WRAPPER_METHOD_0(g_team, u8) \ + DEFINE_LUA_WRAPPER_METHOD_0(g_squad, u8) \ + DEFINE_LUA_WRAPPER_METHOD_0(g_group, u8) \ + DEFINE_LUA_WRAPPER_METHOD_V1(on_death, CSE_Abstract*) +#else // XRGAME_EXPORTS +#define INHERIT_CREATURE \ + INHERIT_DYNAMIC_ALIFE \ + DEFINE_LUA_WRAPPER_METHOD_0(g_team, u8) \ + DEFINE_LUA_WRAPPER_METHOD_0(g_squad, u8) \ + DEFINE_LUA_WRAPPER_METHOD_0(g_group, u8) +#endif // XRGAME_EXPORTS + +#define INHERIT_MONSTER \ + INHERIT_CREATURE \ + DEFINE_LUA_WRAPPER_METHOD_V0(update) + +#define INHERIT_ITEM \ + INHERIT_DYNAMIC_ALIFE \ + DEFINE_LUA_WRAPPER_METHOD_0(bfUseful, bool) template -struct CWrapperPure : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperPure self_type; - CWrapperPure (LPCSTR section) : inherited(section){} - INHERIT_PURE; +struct CWrapperPure : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperPure self_type; + CWrapperPure(LPCSTR section) : inherited(section) {} + INHERIT_PURE; }; template -struct CWrapperAbstract : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperAbstract self_type; +struct CWrapperAbstract : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperAbstract self_type; - CWrapperAbstract (LPCSTR section) : inherited(section){} - INHERIT_ABSTRACT; + CWrapperAbstract(LPCSTR section) : inherited(section) {} + INHERIT_ABSTRACT; }; template -struct CWrapperAbstractALife : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperAbstractALife self_type; - CWrapperAbstractALife (LPCSTR section) : inherited(section){} - INHERIT_ALIFE; +struct CWrapperAbstractALife : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperAbstractALife self_type; + CWrapperAbstractALife(LPCSTR section) : inherited(section) {} + INHERIT_ALIFE; }; template -struct CWrapperAbstractDynamicALife : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperAbstractDynamicALife self_type; - CWrapperAbstractDynamicALife (LPCSTR section) : inherited(section){} - INHERIT_DYNAMIC_ALIFE; +struct CWrapperAbstractDynamicALife : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperAbstractDynamicALife self_type; + CWrapperAbstractDynamicALife(LPCSTR section) : inherited(section) {} + INHERIT_DYNAMIC_ALIFE; }; template -struct CWrapperAbstractOnlineOfflineGroup : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperAbstractOnlineOfflineGroup self_type; - CWrapperAbstractOnlineOfflineGroup (LPCSTR section) : inherited(section){} - INHERIT_ONLINE_OFFLINE_GROUP; +struct CWrapperAbstractOnlineOfflineGroup : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperAbstractOnlineOfflineGroup self_type; + CWrapperAbstractOnlineOfflineGroup(LPCSTR section) : inherited(section) {} + INHERIT_ONLINE_OFFLINE_GROUP; }; template -struct CWrapperAbstractZone : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperAbstractZone self_type; - CWrapperAbstractZone (LPCSTR section) : inherited(section){} - INHERIT_ZONE; +struct CWrapperAbstractZone : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperAbstractZone self_type; + CWrapperAbstractZone(LPCSTR section) : inherited(section) {} + INHERIT_ZONE; }; template -struct CWrapperAbstractCreature : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperAbstractCreature self_type; - CWrapperAbstractCreature (LPCSTR section) : inherited(section){} - INHERIT_CREATURE; +struct CWrapperAbstractCreature : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperAbstractCreature self_type; + CWrapperAbstractCreature(LPCSTR section) : inherited(section) {} + INHERIT_CREATURE; }; template -struct CWrapperAbstractMonster : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperAbstractMonster self_type; - CWrapperAbstractMonster (LPCSTR section) : inherited(section){} - INHERIT_MONSTER; +struct CWrapperAbstractMonster : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperAbstractMonster self_type; + CWrapperAbstractMonster(LPCSTR section) : inherited(section) {} + INHERIT_MONSTER; }; template -struct CWrapperAbstractItem : public T, public luabind::wrap_base { - typedef T inherited; - typedef CWrapperAbstractItem self_type; - CWrapperAbstractItem (LPCSTR section) : inherited(section){} - INHERIT_ITEM; +struct CWrapperAbstractItem : public T, public luabind::wrap_base +{ + typedef T inherited; + typedef CWrapperAbstractItem self_type; + CWrapperAbstractItem(LPCSTR section) : inherited(section) {} + INHERIT_ITEM; }; -#define luabind_virtual_pure(a,b) \ - .def( constructor()) +#define luabind_virtual_pure(a, b) .def(constructor()) //#ifndef USE_WRITER_READER //# define luabind_virtual_pure(a,b) \ // .def( constructor()) \ // DEFINE_LUABIND_VIRTUAL_FUNCTION_EXPLICIT_1(a,b,save,void,NET_Packet&,NET_Packet*) \ -// DEFINE_LUABIND_VIRTUAL_FUNCTION_EXPLICIT_1(a,b,load,void,NET_Packet&,NET_Packet*) +// DEFINE_LUABIND_VIRTUAL_FUNCTION_EXPLICIT_1(a,b,load,void,NET_Packet&,NET_Packet*) //#else //# define luabind_virtual_pure(a,b) \ // .def( constructor()) \ @@ -219,293 +226,273 @@ struct CWrapperAbstractItem : public T, public luabind::wrap_base { //#endif #ifndef XRGAME_EXPORTS -# define luabind_virtual_abstract(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,FillProps ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,STATE_Write ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,STATE_Read ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,init ) -#else // #ifndef XRGAME_EXPORTS -# define luabind_virtual_abstract(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,STATE_Write ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,STATE_Read ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,init ) -#endif // #ifndef XRGAME_EXPORTS - -#define luabind_virtual_alife(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION_EXPLICIT_CONST_0(a,b,can_switch_online,bool) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION_EXPLICIT_CONST_0(a,b,can_switch_offline,bool) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION_EXPLICIT_CONST_0(a,b,interactive,bool) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,used_ai_locations ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,can_save ) \ +#define luabind_virtual_abstract(a, b) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, FillProps) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, STATE_Write) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, STATE_Read) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, init) +#else // #ifndef XRGAME_EXPORTS +#define luabind_virtual_abstract(a, b) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, STATE_Write) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, STATE_Read) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, init) +#endif // #ifndef XRGAME_EXPORTS + +#define luabind_virtual_alife(a, b) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION_EXPLICIT_CONST_0(a, b, can_switch_online, bool) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION_EXPLICIT_CONST_0(a, b, can_switch_offline, bool) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION_EXPLICIT_CONST_0(a, b, interactive, bool) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, used_ai_locations) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, can_save) #ifdef XRGAME_EXPORTS -# define luabind_virtual_dynamic_alife(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,on_spawn ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,on_before_register ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,on_register ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,on_unregister ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,keep_saved_data_anyway)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,switch_online ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,switch_offline ) +#define luabind_virtual_dynamic_alife(a, b) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, on_spawn) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, on_before_register) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, on_register) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, on_unregister) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, keep_saved_data_anyway) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, switch_online) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, switch_offline) #else -# define luabind_virtual_dynamic_alife(a,b) +#define luabind_virtual_dynamic_alife(a, b) #endif #ifdef XRGAME_EXPORTS -# define luabind_virtual_creature(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,g_team ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,g_squad ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,g_group ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,on_death) -#else // XRGAME_EXPORTS -# define luabind_virtual_creature(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,g_team ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,g_squad ) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,g_group ) -#endif // XRGAME_EXPORTS +#define luabind_virtual_creature(a, b) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, g_team) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, g_squad) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, g_group) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, on_death) +#else // XRGAME_EXPORTS +#define luabind_virtual_creature(a, b) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, g_team) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, g_squad) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, g_group) +#endif // XRGAME_EXPORTS #ifdef XRGAME_EXPORTS -# define luabind_virtual_zone(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,update)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,smart_touch)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,enabled)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,suitable)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,register_npc)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,unregister_npc)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,task)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,detect_probability) +#define luabind_virtual_zone(a, b) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, update) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, smart_touch) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, enabled) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, suitable) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, register_npc) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, unregister_npc) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, task) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, detect_probability) #else -# define luabind_virtual_zone(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,update)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,smart_touch)\ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,detect_probability) +#define luabind_virtual_zone(a, b) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, update) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, smart_touch) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, detect_probability) #endif -#ifdef XRGAME_EXPORTS -#define luabind_virtual_online_offline_group(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,update) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,get_current_task) +#ifdef XRGAME_EXPORTS +#define luabind_virtual_online_offline_group(a, b) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, update) \ + DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, get_current_task) #else - #define luabind_virtual_online_offline_group(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,update) -#endif //#ifdef XRGAME_EXPORTS +#define luabind_virtual_online_offline_group(a, b) DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, update) +#endif //#ifdef XRGAME_EXPORTS -#define luabind_virtual_monster(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,update) +#define luabind_virtual_monster(a, b) DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, update) -#define luabind_virtual_item(a,b) \ - DEFINE_LUABIND_VIRTUAL_FUNCTION(a,b,bfUseful) +#define luabind_virtual_item(a, b) DEFINE_LUABIND_VIRTUAL_FUNCTION(a, b, bfUseful) -#define luabind_virtual_Pure(a,b) \ - luabind_virtual_pure(a,b) +#define luabind_virtual_Pure(a, b) luabind_virtual_pure(a, b) -#define luabind_virtual_Abstract(a,b) \ - luabind_virtual_Pure(a,b) \ - luabind_virtual_abstract(a,b) +#define luabind_virtual_Abstract(a, b) luabind_virtual_Pure(a, b) luabind_virtual_abstract(a, b) -#define luabind_virtual_Alife(a,b) \ - luabind_virtual_Abstract(a,b) \ - luabind_virtual_alife(a,b) +#define luabind_virtual_Alife(a, b) luabind_virtual_Abstract(a, b) luabind_virtual_alife(a, b) -#define luabind_virtual_DynamicAlife(a,b) \ - luabind_virtual_Alife(a,b) \ - luabind_virtual_dynamic_alife(a,b) +#define luabind_virtual_DynamicAlife(a, b) luabind_virtual_Alife(a, b) luabind_virtual_dynamic_alife(a, b) -#define luabind_virtual_Creature(a,b) \ - luabind_virtual_DynamicAlife(a,b) \ - luabind_virtual_creature(a,b) +#define luabind_virtual_Creature(a, b) luabind_virtual_DynamicAlife(a, b) luabind_virtual_creature(a, b) -#define luabind_virtual_Zone(a,b) \ - luabind_virtual_DynamicAlife(a,b) \ - luabind_virtual_zone(a,b) +#define luabind_virtual_Zone(a, b) luabind_virtual_DynamicAlife(a, b) luabind_virtual_zone(a, b) -#define luabind_virtual_OnlineOfflineGroup(a,b) \ - luabind_virtual_DynamicAlife(a,b) \ - luabind_virtual_online_offline_group(a,b) +#define luabind_virtual_OnlineOfflineGroup(a, b) \ + luabind_virtual_DynamicAlife(a, b) luabind_virtual_online_offline_group(a, b) -#define luabind_virtual_Monster(a,b) \ - luabind_virtual_Creature(a,b) \ - luabind_virtual_monster(a,b) +#define luabind_virtual_Monster(a, b) luabind_virtual_Creature(a, b) luabind_virtual_monster(a, b) -#define luabind_virtual_Item(a,b) \ - luabind_virtual_DynamicAlife(a,b) \ - luabind_virtual_item(a,b) +#define luabind_virtual_Item(a, b) luabind_virtual_DynamicAlife(a, b) luabind_virtual_item(a, b) ////////////////////////////////////////////////////////////////////////// // 0 ////////////////////////////////////////////////////////////////////////// -#define luabind_class_pure0(a,b) \ - DEFINE_LUABIND_CLASS_WRAPPER_0(a,CWrapperPure,b) \ - luabind_virtual_Pure(a,CWrapperPure) +#define luabind_class_pure0(a, b) \ + DEFINE_LUABIND_CLASS_WRAPPER_0(a, CWrapperPure, b) \ + luabind_virtual_Pure(a, CWrapperPure) -#define luabind_class_abstract0(a,b) \ - DEFINE_LUABIND_CLASS_WRAPPER_0(a,CWrapperAbstract,b) \ - luabind_virtual_Abstract(a,CWrapperAbstract) +#define luabind_class_abstract0(a, b) \ + DEFINE_LUABIND_CLASS_WRAPPER_0(a, CWrapperAbstract, b) \ + luabind_virtual_Abstract(a, CWrapperAbstract) -#define luabind_class_alife0(a,b) \ - DEFINE_LUABIND_CLASS_WRAPPER_0(a,CWrapperAbstractALife,b) \ - luabind_virtual_Alife(a,CWrapperAbstractALife) +#define luabind_class_alife0(a, b) \ + DEFINE_LUABIND_CLASS_WRAPPER_0(a, CWrapperAbstractALife, b) \ + luabind_virtual_Alife(a, CWrapperAbstractALife) -#define luabind_class_dynamic_alife0(a,b) \ - DEFINE_LUABIND_CLASS_WRAPPER_0(a,CWrapperAbstractDynamicALife,b) \ - luabind_virtual_DynamicAlife(a,CWrapperAbstractDynamicALife) +#define luabind_class_dynamic_alife0(a, b) \ + DEFINE_LUABIND_CLASS_WRAPPER_0(a, CWrapperAbstractDynamicALife, b) \ + luabind_virtual_DynamicAlife(a, CWrapperAbstractDynamicALife) -#define luabind_class_zone0(a,b) \ - DEFINE_LUABIND_CLASS_WRAPPER_0(a,CWrapperAbstractZone,b) \ - luabind_virtual_Zone(a,CWrapperAbstractZone) +#define luabind_class_zone0(a, b) \ + DEFINE_LUABIND_CLASS_WRAPPER_0(a, CWrapperAbstractZone, b) \ + luabind_virtual_Zone(a, CWrapperAbstractZone) -#define luabind_class_creature0(a,b) \ - DEFINE_LUABIND_CLASS_WRAPPER_0(a,CWrapperAbstractCreature,b) \ - luabind_virtual_Creature(a,CWrapperAbstractCreature) +#define luabind_class_creature0(a, b) \ + DEFINE_LUABIND_CLASS_WRAPPER_0(a, CWrapperAbstractCreature, b) \ + luabind_virtual_Creature(a, CWrapperAbstractCreature) -#define luabind_class_monster0(a,b) \ - DEFINE_LUABIND_CLASS_WRAPPER_0(a,CWrapperAbstractMonster,b) \ - luabind_virtual_Monster(a,CWrapperAbstractMonster) +#define luabind_class_monster0(a, b) \ + DEFINE_LUABIND_CLASS_WRAPPER_0(a, CWrapperAbstractMonster, b) \ + luabind_virtual_Monster(a, CWrapperAbstractMonster) -#define luabind_class_item0(a,b) \ - DEFINE_LUABIND_CLASS_WRAPPER_0(a,CWrapperAbstractItem,b) \ - luabind_virtual_Item(a,CWrapperAbstractItem) +#define luabind_class_item0(a, b) \ + DEFINE_LUABIND_CLASS_WRAPPER_0(a, CWrapperAbstractItem, b) \ + luabind_virtual_Item(a, CWrapperAbstractItem) ////////////////////////////////////////////////////////////////////////// // 1 ////////////////////////////////////////////////////////////////////////// -#define luabind_class_pure1(a,b,c) \ - DEFINE_LUABIND_CLASS_WRAPPER_1(a,CWrapperPure,b,c) \ - luabind_virtual_Pure(a,CWrapperPure) +#define luabind_class_pure1(a, b, c) \ + DEFINE_LUABIND_CLASS_WRAPPER_1(a, CWrapperPure, b, c) \ + luabind_virtual_Pure(a, CWrapperPure) -#define luabind_class_abstract1(a,b,c) \ - DEFINE_LUABIND_CLASS_WRAPPER_1(a,CWrapperAbstract,b,c) \ - luabind_virtual_Abstract(a,CWrapperAbstract) +#define luabind_class_abstract1(a, b, c) \ + DEFINE_LUABIND_CLASS_WRAPPER_1(a, CWrapperAbstract, b, c) \ + luabind_virtual_Abstract(a, CWrapperAbstract) -#define luabind_class_alife1(a,b,c) \ - DEFINE_LUABIND_CLASS_WRAPPER_1(a,CWrapperAbstractALife,b,c) \ - luabind_virtual_Alife(a,CWrapperAbstractALife) +#define luabind_class_alife1(a, b, c) \ + DEFINE_LUABIND_CLASS_WRAPPER_1(a, CWrapperAbstractALife, b, c) \ + luabind_virtual_Alife(a, CWrapperAbstractALife) -#define luabind_class_dynamic_alife1(a,b,c) \ - DEFINE_LUABIND_CLASS_WRAPPER_1(a,CWrapperAbstractDynamicALife,b,c) \ - luabind_virtual_DynamicAlife(a,CWrapperAbstractDynamicALife) +#define luabind_class_dynamic_alife1(a, b, c) \ + DEFINE_LUABIND_CLASS_WRAPPER_1(a, CWrapperAbstractDynamicALife, b, c) \ + luabind_virtual_DynamicAlife(a, CWrapperAbstractDynamicALife) -#define luabind_class_zone1(a,b,c) \ - DEFINE_LUABIND_CLASS_WRAPPER_1(a,CWrapperAbstractZone,b,c) \ - luabind_virtual_Zone(a,CWrapperAbstractZone) +#define luabind_class_zone1(a, b, c) \ + DEFINE_LUABIND_CLASS_WRAPPER_1(a, CWrapperAbstractZone, b, c) \ + luabind_virtual_Zone(a, CWrapperAbstractZone) -#define luabind_class_creature1(a,b,c) \ - DEFINE_LUABIND_CLASS_WRAPPER_1(a,CWrapperAbstractCreature,b,c) \ - luabind_virtual_Creature(a,CWrapperAbstractCreature) +#define luabind_class_creature1(a, b, c) \ + DEFINE_LUABIND_CLASS_WRAPPER_1(a, CWrapperAbstractCreature, b, c) \ + luabind_virtual_Creature(a, CWrapperAbstractCreature) -#define luabind_class_monster1(a,b,c) \ - DEFINE_LUABIND_CLASS_WRAPPER_1(a,CWrapperAbstractMonster,b,c) \ - luabind_virtual_Monster(a,CWrapperAbstractMonster) +#define luabind_class_monster1(a, b, c) \ + DEFINE_LUABIND_CLASS_WRAPPER_1(a, CWrapperAbstractMonster, b, c) \ + luabind_virtual_Monster(a, CWrapperAbstractMonster) -#define luabind_class_item1(a,b,c) \ - DEFINE_LUABIND_CLASS_WRAPPER_1(a,CWrapperAbstractItem,b,c) \ - luabind_virtual_Item(a,CWrapperAbstractItem) +#define luabind_class_item1(a, b, c) \ + DEFINE_LUABIND_CLASS_WRAPPER_1(a, CWrapperAbstractItem, b, c) \ + luabind_virtual_Item(a, CWrapperAbstractItem) ////////////////////////////////////////////////////////////////////////// // 2 ////////////////////////////////////////////////////////////////////////// -#define luabind_class_pure2(a,b,c,d) \ - DEFINE_LUABIND_CLASS_WRAPPER_2(a,CWrapperPure,b,c,d) \ - luabind_virtual_Pure(a,CWrapperPure) +#define luabind_class_pure2(a, b, c, d) \ + DEFINE_LUABIND_CLASS_WRAPPER_2(a, CWrapperPure, b, c, d) \ + luabind_virtual_Pure(a, CWrapperPure) -#define luabind_class_abstract2(a,b,c,d) \ - DEFINE_LUABIND_CLASS_WRAPPER_2(a,CWrapperAbstract,b,c,d) \ - luabind_virtual_Abstract(a,CWrapperAbstract) +#define luabind_class_abstract2(a, b, c, d) \ + DEFINE_LUABIND_CLASS_WRAPPER_2(a, CWrapperAbstract, b, c, d) \ + luabind_virtual_Abstract(a, CWrapperAbstract) -#define luabind_class_alife2(a,b,c,d) \ - DEFINE_LUABIND_CLASS_WRAPPER_2(a,CWrapperAbstractALife,b,c,d) \ - luabind_virtual_Alife(a,CWrapperAbstractALife) +#define luabind_class_alife2(a, b, c, d) \ + DEFINE_LUABIND_CLASS_WRAPPER_2(a, CWrapperAbstractALife, b, c, d) \ + luabind_virtual_Alife(a, CWrapperAbstractALife) -#define luabind_class_dynamic_alife2(a,b,c,d) \ - DEFINE_LUABIND_CLASS_WRAPPER_2(a,CWrapperAbstractDynamicALife,b,c,d) \ - luabind_virtual_DynamicAlife(a,CWrapperAbstractDynamicALife) +#define luabind_class_dynamic_alife2(a, b, c, d) \ + DEFINE_LUABIND_CLASS_WRAPPER_2(a, CWrapperAbstractDynamicALife, b, c, d) \ + luabind_virtual_DynamicAlife(a, CWrapperAbstractDynamicALife) -#define luabind_class_zone2(a,b,c,d) \ - DEFINE_LUABIND_CLASS_WRAPPER_2(a,CWrapperAbstractZone,b,c,d) \ - luabind_virtual_Zone(a,CWrapperAbstractZone) +#define luabind_class_zone2(a, b, c, d) \ + DEFINE_LUABIND_CLASS_WRAPPER_2(a, CWrapperAbstractZone, b, c, d) \ + luabind_virtual_Zone(a, CWrapperAbstractZone) -#define luabind_class_online_offline_group2(a,b,c,d) \ - DEFINE_LUABIND_CLASS_WRAPPER_2(a,CWrapperAbstractOnlineOfflineGroup,b,c,d) \ - luabind_virtual_OnlineOfflineGroup(a,CWrapperAbstractOnlineOfflineGroup) +#define luabind_class_online_offline_group2(a, b, c, d) \ + DEFINE_LUABIND_CLASS_WRAPPER_2(a, CWrapperAbstractOnlineOfflineGroup, b, c, d) \ + luabind_virtual_OnlineOfflineGroup(a, CWrapperAbstractOnlineOfflineGroup) -#define luabind_class_creature2(a,b,c,d) \ - DEFINE_LUABIND_CLASS_WRAPPER_2(a,CWrapperAbstractCreature,b,c,d) \ - luabind_virtual_Creature(a,CWrapperAbstractCreature) +#define luabind_class_creature2(a, b, c, d) \ + DEFINE_LUABIND_CLASS_WRAPPER_2(a, CWrapperAbstractCreature, b, c, d) \ + luabind_virtual_Creature(a, CWrapperAbstractCreature) -#define luabind_class_monster2(a,b,c,d) \ - DEFINE_LUABIND_CLASS_WRAPPER_2(a,CWrapperAbstractMonster,b,c,d) \ - luabind_virtual_Monster(a,CWrapperAbstractMonster) +#define luabind_class_monster2(a, b, c, d) \ + DEFINE_LUABIND_CLASS_WRAPPER_2(a, CWrapperAbstractMonster, b, c, d) \ + luabind_virtual_Monster(a, CWrapperAbstractMonster) -#define luabind_class_item2(classType, className, base1, base2) \ - DEFINE_LUABIND_CLASS_WRAPPER_2(classType, CWrapperAbstractItem, className, base1, base2) \ - luabind_virtual_Item(classType, CWrapperAbstractItem) +#define luabind_class_item2(classType, className, base1, base2) \ + DEFINE_LUABIND_CLASS_WRAPPER_2(classType, CWrapperAbstractItem, className, base1, base2) \ + luabind_virtual_Item(classType, CWrapperAbstractItem) ////////////////////////////////////////////////////////////////////////// // 3 ////////////////////////////////////////////////////////////////////////// -#define luabind_class_pure3(a,b,c,d,e) \ - DEFINE_LUABIND_CLASS_WRAPPER_3(a,CWrapperPure,b,c,d,e) \ - luabind_virtual_Pure(a,CWrapperPure) +#define luabind_class_pure3(a, b, c, d, e) \ + DEFINE_LUABIND_CLASS_WRAPPER_3(a, CWrapperPure, b, c, d, e) \ + luabind_virtual_Pure(a, CWrapperPure) -#define luabind_class_abstract3(a,b,c,d,e) \ - DEFINE_LUABIND_CLASS_WRAPPER_3(a,CWrapperAbstract,b,c,d,e) \ - luabind_virtual_Abstract(a,CWrapperAbstract) +#define luabind_class_abstract3(a, b, c, d, e) \ + DEFINE_LUABIND_CLASS_WRAPPER_3(a, CWrapperAbstract, b, c, d, e) \ + luabind_virtual_Abstract(a, CWrapperAbstract) -#define luabind_class_alife3(a,b,c,d,e) \ - DEFINE_LUABIND_CLASS_WRAPPER_3(a,CWrapperAbstractALife,b,c,d,e) \ - luabind_virtual_Alife(a,CWrapperAbstractALife) +#define luabind_class_alife3(a, b, c, d, e) \ + DEFINE_LUABIND_CLASS_WRAPPER_3(a, CWrapperAbstractALife, b, c, d, e) \ + luabind_virtual_Alife(a, CWrapperAbstractALife) -#define luabind_class_dynamic_alife3(a,b,c,d,e) \ - DEFINE_LUABIND_CLASS_WRAPPER_3(a,CWrapperAbstractDynamicALife,b,c,d,e) \ - luabind_virtual_DynamicAlife(a,CWrapperAbstractDynamicALife) +#define luabind_class_dynamic_alife3(a, b, c, d, e) \ + DEFINE_LUABIND_CLASS_WRAPPER_3(a, CWrapperAbstractDynamicALife, b, c, d, e) \ + luabind_virtual_DynamicAlife(a, CWrapperAbstractDynamicALife) -#define luabind_class_zone3(a,b,c,d,e) \ - DEFINE_LUABIND_CLASS_WRAPPER_3(a,CWrapperAbstractZone,b,c,d,e) \ - luabind_virtual_Zone(a,CWrapperAbstractZone) +#define luabind_class_zone3(a, b, c, d, e) \ + DEFINE_LUABIND_CLASS_WRAPPER_3(a, CWrapperAbstractZone, b, c, d, e) \ + luabind_virtual_Zone(a, CWrapperAbstractZone) -#define luabind_class_creature3(a,b,c,d,e) \ - DEFINE_LUABIND_CLASS_WRAPPER_3(a,CWrapperAbstractCreature,b,c,d,e) \ - luabind_virtual_Creature(a,CWrapperAbstractCreature) +#define luabind_class_creature3(a, b, c, d, e) \ + DEFINE_LUABIND_CLASS_WRAPPER_3(a, CWrapperAbstractCreature, b, c, d, e) \ + luabind_virtual_Creature(a, CWrapperAbstractCreature) -#define luabind_class_monster3(a,b,c,d,e) \ - DEFINE_LUABIND_CLASS_WRAPPER_3(a,CWrapperAbstractMonster,b,c,d,e) \ - luabind_virtual_Monster(a,CWrapperAbstractMonster) +#define luabind_class_monster3(a, b, c, d, e) \ + DEFINE_LUABIND_CLASS_WRAPPER_3(a, CWrapperAbstractMonster, b, c, d, e) \ + luabind_virtual_Monster(a, CWrapperAbstractMonster) -#define luabind_class_item3(a,b,c,d,e) \ - DEFINE_LUABIND_CLASS_WRAPPER_3(a,CWrapperAbstractItem,b,c,d,e) \ - luabind_virtual_Item(a,CWrapperAbstractItem) +#define luabind_class_item3(a, b, c, d, e) \ + DEFINE_LUABIND_CLASS_WRAPPER_3(a, CWrapperAbstractItem, b, c, d, e) \ + luabind_virtual_Item(a, CWrapperAbstractItem) ////////////////////////////////////////////////////////////////////////// // 4 ////////////////////////////////////////////////////////////////////////// -#define luabind_class_pure4(a,b,c,d,e,f) \ - DEFINE_LUABIND_CLASS_WRAPPER_4(a,CWrapperPure,b,c,d,e,f) \ - luabind_virtual_Pure(a,CWrapperPure) - -#define luabind_class_abstract4(a,b,c,d,e,f) \ - DEFINE_LUABIND_CLASS_WRAPPER_4(a,CWrapperAbstract,b,c,d,e,f) \ - luabind_virtual_Abstract(a,CWrapperAbstract) +#define luabind_class_pure4(a, b, c, d, e, f) \ + DEFINE_LUABIND_CLASS_WRAPPER_4(a, CWrapperPure, b, c, d, e, f) \ + luabind_virtual_Pure(a, CWrapperPure) -#define luabind_class_alife4(a,b,c,d,e,f) \ - DEFINE_LUABIND_CLASS_WRAPPER_4(a,CWrapperAbstractALife,b,c,d,e,f) \ - luabind_virtual_Alife(a,CWrapperAbstractALife) +#define luabind_class_abstract4(a, b, c, d, e, f) \ + DEFINE_LUABIND_CLASS_WRAPPER_4(a, CWrapperAbstract, b, c, d, e, f) \ + luabind_virtual_Abstract(a, CWrapperAbstract) -#define luabind_class_dynamic_alife4(a,b,c,d,e,f) \ - DEFINE_LUABIND_CLASS_WRAPPER_4(a,CWrapperAbstractDynamicALife,b,c,d,e,f) \ - luabind_virtual_DynamicAlife(a,CWrapperAbstractDynamicALife) +#define luabind_class_alife4(a, b, c, d, e, f) \ + DEFINE_LUABIND_CLASS_WRAPPER_4(a, CWrapperAbstractALife, b, c, d, e, f) \ + luabind_virtual_Alife(a, CWrapperAbstractALife) -#define luabind_class_zone4(a,b,c,d,e,f) \ - DEFINE_LUABIND_CLASS_WRAPPER_4(a,CWrapperAbstractZone,b,c,d,e,f) \ - luabind_virtual_Zone(a,CWrapperAbstractZone) +#define luabind_class_dynamic_alife4(a, b, c, d, e, f) \ + DEFINE_LUABIND_CLASS_WRAPPER_4(a, CWrapperAbstractDynamicALife, b, c, d, e, f) \ + luabind_virtual_DynamicAlife(a, CWrapperAbstractDynamicALife) -#define luabind_class_creature4(a,b,c,d,e,f) \ - DEFINE_LUABIND_CLASS_WRAPPER_4(a,CWrapperAbstractCreature,b,c,d,e,f) \ - luabind_virtual_Creature(a,CWrapperAbstractCreature) +#define luabind_class_zone4(a, b, c, d, e, f) \ + DEFINE_LUABIND_CLASS_WRAPPER_4(a, CWrapperAbstractZone, b, c, d, e, f) \ + luabind_virtual_Zone(a, CWrapperAbstractZone) -#define luabind_class_monster4(a,b,c,d,e,f) \ - DEFINE_LUABIND_CLASS_WRAPPER_4(a,CWrapperAbstractMonster,b,c,d,e,f) \ - luabind_virtual_Monster(a,CWrapperAbstractMonster) +#define luabind_class_creature4(a, b, c, d, e, f) \ + DEFINE_LUABIND_CLASS_WRAPPER_4(a, CWrapperAbstractCreature, b, c, d, e, f) \ + luabind_virtual_Creature(a, CWrapperAbstractCreature) -#define luabind_class_item4(a,b,c,d,e,f) \ - DEFINE_LUABIND_CLASS_WRAPPER_4(a,CWrapperAbstractItem,b,c,d,e,f) \ - luabind_virtual_Item(a,CWrapperAbstractItem) +#define luabind_class_monster4(a, b, c, d, e, f) \ + DEFINE_LUABIND_CLASS_WRAPPER_4(a, CWrapperAbstractMonster, b, c, d, e, f) \ + luabind_virtual_Monster(a, CWrapperAbstractMonster) +#define luabind_class_item4(a, b, c, d, e, f) \ + DEFINE_LUABIND_CLASS_WRAPPER_4(a, CWrapperAbstractItem, b, c, d, e, f) \ + luabind_virtual_Item(a, CWrapperAbstractItem) diff --git a/src/xrServerEntities/xrserver_objects_alife_monsters_script3.cpp b/src/xrServerEntities/xrserver_objects_alife_monsters_script3.cpp index 8da1309407f..b31cb014540 100644 --- a/src/xrServerEntities/xrserver_objects_alife_monsters_script3.cpp +++ b/src/xrServerEntities/xrserver_objects_alife_monsters_script3.cpp @@ -7,114 +7,69 @@ //////////////////////////////////////////////////////////////////////////// #include "pch_script.h" +#include "xrScriptEngine/ScriptExporter.hpp" #include "xrServer_Objects_ALife_Monsters.h" #include "xrServer_script_macroses.h" -#include "xrScriptEngine/ScriptExporter.hpp" using namespace luabind; using namespace luabind::policy; -SCRIPT_EXPORT(CSE_ALifeCreatureActor, (CSE_ALifeCreatureAbstract, CSE_ALifeTraderAbstract, CSE_PHSkeleton), -{ - module(luaState) - [ - luabind_class_creature3( - CSE_ALifeCreatureActor, - "cse_alife_creature_actor", - CSE_ALifeCreatureAbstract, - CSE_ALifeTraderAbstract, - CSE_PHSkeleton - ) - ]; +SCRIPT_EXPORT(CSE_ALifeCreatureActor, (CSE_ALifeCreatureAbstract, CSE_ALifeTraderAbstract, CSE_PHSkeleton), { + module(luaState)[luabind_class_creature3(CSE_ALifeCreatureActor, "cse_alife_creature_actor", + CSE_ALifeCreatureAbstract, CSE_ALifeTraderAbstract, CSE_PHSkeleton)]; }); -SCRIPT_EXPORT(CSE_ALifeTorridZone, (CSE_ALifeCustomZone, CSE_Motion), -{ - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifeTorridZone, - "cse_torrid_zone", - CSE_ALifeCustomZone, - CSE_Motion - ) - ]; +SCRIPT_EXPORT(CSE_ALifeTorridZone, (CSE_ALifeCustomZone, CSE_Motion), { + module(luaState)[luabind_class_dynamic_alife2( + CSE_ALifeTorridZone, "cse_torrid_zone", CSE_ALifeCustomZone, CSE_Motion)]; }); -SCRIPT_EXPORT(CSE_ALifeZoneVisual, (CSE_ALifeAnomalousZone, CSE_Visual), -{ - module(luaState) - [ - luabind_class_dynamic_alife2( - CSE_ALifeZoneVisual, - "cse_zone_visual", - CSE_ALifeAnomalousZone, - CSE_Visual - ) - ]; +SCRIPT_EXPORT(CSE_ALifeZoneVisual, (CSE_ALifeAnomalousZone, CSE_Visual), { + module(luaState)[luabind_class_dynamic_alife2( + CSE_ALifeZoneVisual, "cse_zone_visual", CSE_ALifeAnomalousZone, CSE_Visual)]; }); -SCRIPT_EXPORT(CSE_ALifeCreaturePhantom, (CSE_ALifeCreatureAbstract), -{ - module(luaState) - [ - luabind_class_creature1( - CSE_ALifeCreaturePhantom, - "cse_alife_creature_phantom", - CSE_ALifeCreatureAbstract - ) - ]; +SCRIPT_EXPORT(CSE_ALifeCreaturePhantom, (CSE_ALifeCreatureAbstract), { + module(luaState)[luabind_class_creature1( + CSE_ALifeCreaturePhantom, "cse_alife_creature_phantom", CSE_ALifeCreatureAbstract)]; }); -static SRotation* CSE_ALifeCreatureAbstract__o_torso (CSE_ALifeCreatureAbstract* self) +static SRotation* CSE_ALifeCreatureAbstract__o_torso(CSE_ALifeCreatureAbstract* self) { - return (&self->o_torso); + return (&self->o_torso); } -SCRIPT_EXPORT(CSE_ALifeCreatureAbstract, (CSE_ALifeDynamicObjectVisual), -{ - module(luaState) - [ - luabind_class_creature1( - CSE_ALifeCreatureAbstract, - "cse_alife_creature_abstract", - CSE_ALifeDynamicObjectVisual - ) - .def("health",&CSE_ALifeCreatureAbstract::get_health) - .def("alive",&CSE_ALifeCreatureAbstract::g_Alive) - .def_readwrite("team",&CSE_ALifeCreatureAbstract::s_team) - .def_readwrite("squad",&CSE_ALifeCreatureAbstract::s_squad) - .def_readwrite("group",&CSE_ALifeCreatureAbstract::s_group) - .def("o_torso",&CSE_ALifeCreatureAbstract__o_torso) - ]; +SCRIPT_EXPORT(CSE_ALifeCreatureAbstract, (CSE_ALifeDynamicObjectVisual), { + module(luaState)[luabind_class_creature1( + CSE_ALifeCreatureAbstract, "cse_alife_creature_abstract", CSE_ALifeDynamicObjectVisual) + .def("health", &CSE_ALifeCreatureAbstract::get_health) + .def("alive", &CSE_ALifeCreatureAbstract::g_Alive) + .def_readwrite("team", &CSE_ALifeCreatureAbstract::s_team) + .def_readwrite("squad", &CSE_ALifeCreatureAbstract::s_squad) + .def_readwrite("group", &CSE_ALifeCreatureAbstract::s_group) + .def("o_torso", &CSE_ALifeCreatureAbstract__o_torso)]; }); -static void CSE_ALifeOnlineOfflineGroup_Export(lua_State *luaState) +static void CSE_ALifeOnlineOfflineGroup_Export(lua_State* luaState) { - module(luaState) - [ - class_< CSE_ALifeOnlineOfflineGroup::MEMBERS::value_type >("MEMBERS__value_type") - .def_readonly("id", &CSE_ALifeOnlineOfflineGroup::MEMBERS::value_type::first ) - .def_readonly("object", &CSE_ALifeOnlineOfflineGroup::MEMBERS::value_type::second ), + module(luaState)[class_("MEMBERS__value_type") + .def_readonly("id", &CSE_ALifeOnlineOfflineGroup::MEMBERS::value_type::first) + .def_readonly("object", &CSE_ALifeOnlineOfflineGroup::MEMBERS::value_type::second), - luabind_class_online_offline_group2( - CSE_ALifeOnlineOfflineGroup, - "cse_alife_online_offline_group", - CSE_ALifeDynamicObject, - CSE_ALifeSchedulable - ) + luabind_class_online_offline_group2( + CSE_ALifeOnlineOfflineGroup, "cse_alife_online_offline_group", CSE_ALifeDynamicObject, CSE_ALifeSchedulable) #ifdef XRGAME_EXPORTS - .def("register_member", &CSE_ALifeOnlineOfflineGroup::register_member) - .def("unregister_member", &CSE_ALifeOnlineOfflineGroup::unregister_member) - .def("commander_id", &CSE_ALifeOnlineOfflineGroup::commander_id) - .def("squad_members", &CSE_ALifeOnlineOfflineGroup::squad_members, return_stl_iterator()) - .def("npc_count", &CSE_ALifeOnlineOfflineGroup::npc_count) - .def("add_location_type", &CSE_ALifeOnlineOfflineGroup::add_location_type) - .def("clear_location_types",&CSE_ALifeOnlineOfflineGroup::clear_location_types) - .def("force_change_position",&CSE_ALifeOnlineOfflineGroup::force_change_position) + .def("register_member", &CSE_ALifeOnlineOfflineGroup::register_member) + .def("unregister_member", &CSE_ALifeOnlineOfflineGroup::unregister_member) + .def("commander_id", &CSE_ALifeOnlineOfflineGroup::commander_id) + .def("squad_members", &CSE_ALifeOnlineOfflineGroup::squad_members, return_stl_iterator()) + .def("npc_count", &CSE_ALifeOnlineOfflineGroup::npc_count) + .def("add_location_type", &CSE_ALifeOnlineOfflineGroup::add_location_type) + .def("clear_location_types", &CSE_ALifeOnlineOfflineGroup::clear_location_types) + .def("force_change_position", &CSE_ALifeOnlineOfflineGroup::force_change_position) #endif - ]; + ]; } -SCRIPT_EXPORT_FUNC(CSE_ALifeOnlineOfflineGroup, (CSE_ALifeDynamicObject, CSE_ALifeSchedulable), - CSE_ALifeOnlineOfflineGroup_Export); +SCRIPT_EXPORT_FUNC( + CSE_ALifeOnlineOfflineGroup, (CSE_ALifeDynamicObject, CSE_ALifeSchedulable), CSE_ALifeOnlineOfflineGroup_Export);