diff --git a/source/game/BaseAmmo.cpp b/source/game/BaseAmmo.cpp index 929b4d3996bd33f9386f50be5e062fcc5eab22ea..9624bfd4d80849e2105dd813a309265d7dcb4a69 100644 --- a/source/game/BaseAmmo.cpp +++ b/source/game/BaseAmmo.cpp @@ -61,17 +61,6 @@ protected: btCollisionObject* m_me; }; -CBaseAmmo::CBaseAmmo(CEntityManager * pMgr): - BaseClass(pMgr), - m_fStartSpeed(0.0f), - m_fBulletMass(0.0f), - m_fArmorPiercing(0.0f), - m_fNextBarrierDepth(0.0f) -{ - //m_bPickable = false; - //m_bInvStackable = false; -} - void CBaseAmmo::fire(const float3 &vStart, const float3 &vDir, CBaseCharacter *pAttacker) { extern CTracer *g_pTracer; diff --git a/source/game/BaseAmmo.h b/source/game/BaseAmmo.h index 05f1e4abe2840d140c801bb4df957f435f37c368..df926eb7c4c1e243740d908a9cb11a8722b7cb1c 100644 --- a/source/game/BaseAmmo.h +++ b/source/game/BaseAmmo.h @@ -26,7 +26,7 @@ class CBaseAmmo: public CBaseSupply DECLARE_CLASS(CBaseAmmo, CBaseSupply); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); //! Стреляет пулю void fire(const float3 &vStart, const float3 &vDir, CBaseCharacter *pAttacker=NULL); @@ -41,15 +41,15 @@ public: protected: //! Начальная скорость - float m_fStartSpeed; + float m_fStartSpeed = 0.0f; //! Масса пули - float m_fBulletMass; + float m_fBulletMass = 0.0f; //! Бронебойность - float m_fArmorPiercing; + float m_fArmorPiercing = 0.0f; //! Экспансивная? - bool m_isExpansive; + bool m_isExpansive = false; //! Разрывная? - bool m_isBursting; + bool m_isBursting = false; struct HitPoint { @@ -72,7 +72,7 @@ protected: bool canHole(float fDurability, float fCurrentSpeed, float *pfNewSpeed); //! Хранит толщину препятствия во время расчета выстрела. Изменяется во время полета от препятствия к препятствию - float m_fNextBarrierDepth; + float m_fNextBarrierDepth = 0.0f; void fire(const float3 &vStart, const float3 &vDir, CBaseCharacter *pAttacker, float fSpeed); }; diff --git a/source/game/BaseAmmoBox.cpp b/source/game/BaseAmmoBox.cpp index f2580eb2d18d61521ee5293cc9187b858b8c3ff3..f9ca62acb248706f118b166d6327e6a351e34813 100644 --- a/source/game/BaseAmmoBox.cpp +++ b/source/game/BaseAmmoBox.cpp @@ -24,13 +24,6 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CBaseAmmoBox, base_ammobox); -CBaseAmmoBox::CBaseAmmoBox(CEntityManager * pMgr): - BaseClass(pMgr) -{ - //m_bPickable = false; - //m_bInvStackable = false; -} - void CBaseAmmoBox::onUse(CBaseEntity *pUser) { if(m_iCurItems < 0) diff --git a/source/game/BaseAmmoBox.h b/source/game/BaseAmmoBox.h index 8c5475579f65dc0ba7581bd0e0c1605eca802e9e..ba52e8a1c75ffa067682e402605c9d0a25f8618e 100644 --- a/source/game/BaseAmmoBox.h +++ b/source/game/BaseAmmoBox.h @@ -22,7 +22,7 @@ class CBaseAmmoBox: public CBaseItem DECLARE_CLASS(CBaseAmmoBox, CBaseItem); DECLARE_PROPTABLE(); public: - ThisClass(CEntityManager * pMgr); + DECLARE_TRIVIAL_CONSTRUCTOR(); void onUse(CBaseEntity *pUser); diff --git a/source/game/BaseAnimating.cpp b/source/game/BaseAnimating.cpp index 43f0e921ce2698dbdd26475c53723f52c080fda0..c9fe674683142874a96f177980fb08eaed65f35c 100644 --- a/source/game/BaseAnimating.cpp +++ b/source/game/BaseAnimating.cpp @@ -77,8 +77,7 @@ private: //########################################################################## -CBaseAnimating::CBaseAnimating(CEntityManager * pMgr): - BaseClass(pMgr) +CBaseAnimating::CBaseAnimating() { memset(m_vNextAnim, 0, sizeof(m_vNextAnim)); m_pAnimationCallback = new CAnimationCallback(this); diff --git a/source/game/BaseAnimating.h b/source/game/BaseAnimating.h index 30195eb793ffa472eafc0075944116dff5da751d..b80b5ac9828d8d5a8a4de00de09ff9dfafa5ffa3 100644 --- a/source/game/BaseAnimating.h +++ b/source/game/BaseAnimating.h @@ -31,7 +31,7 @@ class CBaseAnimating: public CBaseEntity friend class CAnimationCallback; public: - CBaseAnimating(CEntityManager * pMgr); + DECLARE_CONSTRUCTOR(); ~CBaseAnimating(); void getMinMax(float3 * min, float3 * max); diff --git a/source/game/BaseCharacter.cpp b/source/game/BaseCharacter.cpp index e11f41959166a54bbd9e95890a59426ad53436e4..93f558cbad7312bd0f4ac4bb9436aefe607018e9 100644 --- a/source/game/BaseCharacter.cpp +++ b/source/game/BaseCharacter.cpp @@ -45,19 +45,10 @@ protected: btCollisionObject* m_me; }; -CBaseCharacter::CBaseCharacter(CEntityManager * pMgr): - BaseClass(pMgr), - m_uMoveDir(PM_OBSERVER), - m_vPitchYawRoll(float3_t(0, 0, 0)), - m_pActiveTool(NULL), - m_fCurrentSpread(0.0f), - m_pHitboxBodies(NULL), - m_fCapsHeight(1.8f), - m_fCapsHeightCrouch(1.2f), - m_fCapsRadius(0.4f), - m_idQuadLast(-1), - m_fCurrentHeight(1.0f) +void CBaseCharacter::onPostLoad() { + BaseClass::onPostLoad(); + m_pCollideShape = new btCapsuleShape(m_fCapsRadius, m_fCapsHeight - m_fCapsRadius * 2.0f); btTransform startTransform; diff --git a/source/game/BaseCharacter.h b/source/game/BaseCharacter.h index 0c2b1559bc47f0c250fd43640e9f7bb5602b289d..71f6b88e4a01f7e9748c39aa7bdfde6cc3c3a246 100644 --- a/source/game/BaseCharacter.h +++ b/source/game/BaseCharacter.h @@ -48,7 +48,7 @@ class CBaseCharacter: public CBaseAnimating DECLARE_CLASS(CBaseCharacter, CBaseAnimating); DECLARE_PROPTABLE(); public: - CBaseCharacter(CEntityManager * pMgr); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CBaseCharacter(); //! Запускает/останавливает первичную атаку @@ -83,7 +83,7 @@ public: void releaseHitboxes(); void updateHitboxes(); - void onSync(); + void onSync() override; void initPhysics(); void releasePhysics(); @@ -118,26 +118,28 @@ public: return(m_pHandsModelResource); } + void onPostLoad() override; + protected: //! Фонарик CLightDirectional* m_flashlight; //! Текущее движение - UINT m_uMoveDir; + UINT m_uMoveDir = PM_OBSERVER; //! Текущий инструмент в руках - CBaseTool * m_pActiveTool; + CBaseTool *m_pActiveTool = NULL; //! Для физики @{ - btCollisionShape * m_pCollideShape; - btRigidBody * m_pRigidBody; - btPairCachingGhostObject * m_pGhostObject; - btKinematicCharacterController * m_pCharacter; - btRigidBody ** m_pHitboxBodies; + btCollisionShape *m_pCollideShape = NULL; + btRigidBody *m_pRigidBody = NULL; + btPairCachingGhostObject *m_pGhostObject = NULL; + btKinematicCharacterController *m_pCharacter = NULL; + btRigidBody **m_pHitboxBodies = NULL; //! @} //! Углы вращения игрока - float3_t m_vPitchYawRoll; + float3_t m_vPitchYawRoll = float3_t(0, 0, 0); //! Мгновенное значение коэффициента разброса float getMomentSpread(); @@ -149,20 +151,20 @@ protected: virtual void updateSpread(float dt); //! Действующее значение разброса - float m_fCurrentSpread; + float m_fCurrentSpread = 0.0f; - CCharacterInventory * m_pInventory; + CCharacterInventory *m_pInventory = NULL; - ID m_idQuadCurr; //!< текущий квад аи сетки на котором стоит игрок - ID m_idQuadLast; //!< Последний валидный квад аи сетки на котором стоял игрок + ID m_idQuadCurr = -1; //!< текущий квад аи сетки на котором стоит игрок + ID m_idQuadLast = -1; //!< Последний валидный квад аи сетки на котором стоял игрок - float m_fCapsHeight; - float m_fCapsHeightCrouch; - float m_fCapsRadius; + float m_fCapsHeight = 1.8f; + float m_fCapsHeightCrouch = 1.2f; + float m_fCapsRadius = 0.4f; - CPointEntity * m_pHeadEnt; + CPointEntity *m_pHeadEnt = NULL; - float m_fCurrentHeight; + float m_fCurrentHeight = 1.0f; IXResourceModelAnimated *m_pHandsModelResource = NULL; }; diff --git a/source/game/BaseEntity.cpp b/source/game/BaseEntity.cpp index 65a8f2ac5050371187312156379bcbed47e72a6f..42f68bb83186cc50a6430106f26885f5df9109a4 100644 --- a/source/game/BaseEntity.cpp +++ b/source/game/BaseEntity.cpp @@ -58,20 +58,8 @@ void CBaseEntity::setDefaults() } } -CBaseEntity::CBaseEntity(CEntityManager * pWorld): - m_iId(0), - m_iFlags(0), - m_pMgr(pWorld), - m_szClassName(NULL), - m_szName(NULL), - m_pParent(NULL), - m_iParentAttachment(-1), - m_pOwner(NULL), - m_fHealth(100.0f)/*, - m_vDiscreteLinearVelocity(float3_t(0.0f, 0.0f, 0.0f))*/ - , m_bSynced(false) -{ - m_iId = pWorld->reg(this); +CBaseEntity::CBaseEntity() +{ m_pLightSystem = GameData::m_pLightSystem; } @@ -97,7 +85,7 @@ CBaseEntity::~CBaseEntity() { _releaseEditorBoxes(); - m_pMgr->unreg(m_iId); + m_pMgr->unreg(this); proptable_t * pt = getPropTable(); const char * estr = GetEmptyString(); @@ -202,12 +190,6 @@ SMQuaternion CBaseEntity::getOrient() return(m_vOrientation); } - -ID CBaseEntity::getId() -{ - return(m_iId); -} - UINT CBaseEntity::getFlags() { return(m_iFlags); diff --git a/source/game/BaseEntity.h b/source/game/BaseEntity.h index 3d5bd758066f751ec9c9604d4d8b7ca8867314ff..e785a1dbe82577de029a29f6fd4848ef81b6f1b6 100644 --- a/source/game/BaseEntity.h +++ b/source/game/BaseEntity.h @@ -48,7 +48,7 @@ class SXGAME_EXPORT CBaseEntity public: //! Конструктор - CBaseEntity(CEntityManager * pMgr); + CBaseEntity(); virtual ~CBaseEntity(); //! Возвращает имя движкового класса объекта @@ -58,22 +58,19 @@ public: const char* getName(); //! Возвращает баунд объекта - virtual void getMinMax(float3 * min, float3 * max); + virtual void getMinMax(float3 *min, float3 *max); //! Возвращает баунд сферу объекта - virtual void getSphere(float3 * center, float * radius); + virtual void getSphere(float3 *center, float *radius); //! Устанавливает мировую позицию объекта - virtual void setPos(const float3 & pos); + virtual void setPos(const float3 &pos); //! Устанавливает относительное смещение объекта - virtual void setOffsetPos(const float3 & pos); + virtual void setOffsetPos(const float3 &pos); //! Получает мировую позицию объекта float3 getPos(); float3 getOffsetPos(); - //! Получает ID объекта в системе - ID getId(); - //! Получает флаги объекта UINT getFlags(); //! Устанавливает флаги объекта @@ -83,9 +80,9 @@ public: SMMATRIX getWorldTM(); //! Устанавливает вращение объекта - virtual void setOrient(const SMQuaternion & q); + virtual void setOrient(const SMQuaternion &q); //! Устанавливает относительное вращение объекта - virtual void setOffsetOrient(const SMQuaternion & q); + virtual void setOffsetOrient(const SMQuaternion &q); //! Возвращает вращение объекта SMQuaternion getOrient(); @@ -114,13 +111,13 @@ public: virtual void onDeath(CBaseEntity *pAttacker, CBaseEntity *pInflictor); - void broadcastMessage(const char * szInputName, inputdata_t inputData, float fRadius); - void broadcastMessage(const char * szInputName, float fArg, float fRadius); - void broadcastMessage(const char * szInputName, int iArg, float fRadius); - void broadcastMessage(const char * szInputName, bool bArg, float fRadius); - void broadcastMessage(const char * szInputName, const char *szArg, float fRadius); - void broadcastMessage(const char * szInputName, const float3_t &f3Arg, float fRadius); - void broadcastMessage(const char * szInputName, float fRadius); + void broadcastMessage(const char *szInputName, inputdata_t inputData, float fRadius); + void broadcastMessage(const char *szInputName, float fArg, float fRadius); + void broadcastMessage(const char *szInputName, int iArg, float fRadius); + void broadcastMessage(const char *szInputName, bool bArg, float fRadius); + void broadcastMessage(const char *szInputName, const char *szArg, float fRadius); + void broadcastMessage(const char *szInputName, const float3_t &f3Arg, float fRadius); + void broadcastMessage(const char *szInputName, float fRadius); virtual void onUse(CBaseEntity *pUser); @@ -145,19 +142,33 @@ public: CBaseEntity *getEntByName(const char *szName, CBaseEntity *pStartFrom); int countEntByName(const char *szName); + const XGUID *getGUID() + { + return(m_pGUID); + } + private: - void setClassName(const char * name); + void setClassName(const char *name); void setDefaults(); - const char * m_szClassName; + void setGUID(const XGUID *pGUID) + { + m_pGUID = pGUID; + } + void setWorld(CEntityManager *pWorld) + { + m_pMgr = pWorld; + } + const char *m_szClassName = NULL; + const XGUID *m_pGUID = NULL; protected: virtual void _cleanup(); virtual void _initEditorBoxes(); virtual void _releaseEditorBoxes(); - CEntityManager * m_pMgr; + CEntityManager *m_pMgr = NULL; //! Позиция объекта float3_t m_vPosition; @@ -178,21 +189,21 @@ protected: SMQuaternion m_vOffsetOrient; //! Идентификатор в системе - ID m_iId; + ID m_iId = 0; //! Флаги - UINT m_iFlags; + UINT m_iFlags = 0; //! Имя объекта - const char * m_szName; + const char *m_szName = NULL; //! Родитель - CBaseEntity * m_pParent; + CBaseEntity *m_pParent = NULL; //! Индекс кости родителя - int m_iParentAttachment; + int m_iParentAttachment = -1; //! Владелец - CBaseEntity * m_pOwner; + CBaseEntity *m_pOwner = NULL; //! Вызывается на стадии синхронизации virtual void onSync(); @@ -215,18 +226,18 @@ protected: void updateOutputs(); //! здоровье [0,+inf] - float m_fHealth; + float m_fHealth = 100.0f; void takeHealth(float fVal, CBaseEntity *pAttacker, CBaseEntity *pInflictor=NULL); - bool m_bSynced; + bool m_bSynced = false; //! Для редактора //@{ float3_t m_vEditorBoxSize = float3_t(0.16f, 0.16f, 0.16f); - btCollisionShape * m_pEditorCollideShape = NULL; - btRigidBody * m_pEditorRigidBody = NULL; + btCollisionShape *m_pEditorCollideShape = NULL; + btRigidBody *m_pEditorRigidBody = NULL; //@} IXLightSystem *m_pLightSystem = NULL; diff --git a/source/game/BaseHandle.cpp b/source/game/BaseHandle.cpp index ab4abe1a7b9c3e13ff6036e83f9c809c5351cfa4..c97d9cc3e42b56dd1bcb719199a2ece555651f71 100644 --- a/source/game/BaseHandle.cpp +++ b/source/game/BaseHandle.cpp @@ -16,8 +16,7 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CBaseHandle, base_handle); -CBaseHandle::CBaseHandle(CEntityManager * pMgr): - BaseClass(pMgr) +CBaseHandle::CBaseHandle() { m_addonType = WPN_ADDON_HANDLE; } \ No newline at end of file diff --git a/source/game/BaseItem.cpp b/source/game/BaseItem.cpp index c3837d54967f241caa4134ba00bf350979f60d94..078ff78fac5a4378961ae018cba96113176c2abf 100644 --- a/source/game/BaseItem.cpp +++ b/source/game/BaseItem.cpp @@ -35,17 +35,13 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CBaseItem, base_item); -CBaseItem::CBaseItem(CEntityManager * pMgr): - BaseClass(pMgr), - m_bInvStackable(true), - m_iInvStackCurSize(0), - m_iInvStackMaxSize(1), - m_iInvWeight(0.0f), - m_bPickable(true) +void CBaseItem::onPostLoad() { - if(m_bPickable) + BaseClass::onPostLoad(); + + if(m_bPickable && !m_pTriggerUse) { - m_pTriggerUse = (CTriggerItemUse*)CREATE_ENTITY("trigger_itemuse", m_pMgr); + m_pTriggerUse = (CTriggerItemUse *)CREATE_ENTITY("trigger_itemuse", m_pMgr); m_pTriggerUse->setItem(this); m_pTriggerUse->setModel("meshes/dev/item_trigger.dse"); m_pTriggerUse->setPos(getPos()); diff --git a/source/game/BaseItem.h b/source/game/BaseItem.h index 087524d58783e346ef53326327599ac36480cd59..e783fd6de5dff72ff119e6e0ef452dbd2cacc57d 100644 --- a/source/game/BaseItem.h +++ b/source/game/BaseItem.h @@ -35,7 +35,7 @@ class CBaseItem: public CBaseAnimating DECLARE_PROPTABLE(); friend class CCharacterInventory; public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CBaseItem(); //! Масса объекта @@ -54,14 +54,16 @@ protected: void onModelChanged(); void onSync() override; + void onPostLoad() override; + void setScale(float fScale) override; const char *m_szInvName; //!< Имя, отображаемое в инвентаре - bool m_bInvStackable; //!< Можно ли хранить несколько итемов в одной ячейке - int m_iInvStackCurSize; //!< Количество итемов в стеке - int m_iInvStackMaxSize; //!< Максимальное количество итемов в стеке - float m_iInvWeight; //!< Масса объекта - bool m_bPickable; //!< Можно ли поднять объект + bool m_bInvStackable = true; //!< Можно ли хранить несколько итемов в одной ячейке + int m_iInvStackCurSize = 0; //!< Количество итемов в стеке + int m_iInvStackMaxSize = 1; //!< Максимальное количество итемов в стеке + float m_iInvWeight = 0.0f; //!< Масса объекта + bool m_bPickable = true; //!< Можно ли поднять объект output_t m_onPickUp; output_t m_onDrop; diff --git a/source/game/BaseLight.cpp b/source/game/BaseLight.cpp index dd90a186a968a2691dd7286eb573c9f9cae79a6a..7935eb5b3597a91a29ec951b3f180caf74e21d28 100644 --- a/source/game/BaseLight.cpp +++ b/source/game/BaseLight.cpp @@ -45,15 +45,6 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CBaseLight, base_light); -CBaseLight::CBaseLight(CEntityManager * pMgr): -BaseClass(pMgr) -{ - m_vColor = float4(1.0f, 1.0f, 1.0f, 1.0f); - m_fDist = 10; - m_iShadowType = 1; - m_fShadowIntensity = 1.0f; -} - CBaseLight::~CBaseLight() { if(m_pLinkedTo) diff --git a/source/game/BaseLight.h b/source/game/BaseLight.h index e0bb6ae35241bd14181fc3d653ac308d51c3ba27..f3cd1aac80e06808cc636f93cf017792edb9ce56 100644 --- a/source/game/BaseLight.h +++ b/source/game/BaseLight.h @@ -24,7 +24,7 @@ class CBaseLight: public CPointEntity DECLARE_CLASS(CBaseLight, CPointEntity); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CBaseLight(); void toggleEnable(); @@ -87,12 +87,12 @@ public: protected: IXLight *m_pLight = NULL; - float4_t m_vColor; - float m_fDist; + float4_t m_vColor = float4(1.0f, 1.0f, 1.0f, 1.0f); + float m_fDist = 10.0f; //float m_fShadowDist; - int m_iShadowType; - bool m_isEnable; - float m_fShadowIntensity; + int m_iShadowType = 1; + bool m_isEnable = true; + float m_fShadowIntensity = 1.0f; CBaseEntity *m_pLinkedTo = NULL; Array<CBaseLight*> m_vpLinkedLights; diff --git a/source/game/BaseMag.cpp b/source/game/BaseMag.cpp index a783175313b8e9f9806ca14921c2c8cf1eb78cac..ad2518574bd7226dbdde191f0a6b2a730cde6f2a 100644 --- a/source/game/BaseMag.cpp +++ b/source/game/BaseMag.cpp @@ -19,10 +19,7 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CBaseMag, base_mag); -CBaseMag::CBaseMag(CEntityManager * pMgr): - BaseClass(pMgr), - m_iCapacity(0), - m_iCurrentLoad(0) +CBaseMag::CBaseMag() { m_addonType = WPN_ADDON_MAG; } diff --git a/source/game/BaseMag.h b/source/game/BaseMag.h index aae2f46e12b3deac565ddf9620dc0cb8f6f41dc9..10fb7e90d248cbb8527315f847af4d61d476e7d8 100644 --- a/source/game/BaseMag.h +++ b/source/game/BaseMag.h @@ -28,8 +28,8 @@ public: int getCapacity(); void load(int count); protected: - int m_iCapacity; - int m_iCurrentLoad; + int m_iCapacity = 0; + int m_iCurrentLoad = 0; }; #endif diff --git a/source/game/BaseScope.cpp b/source/game/BaseScope.cpp index 05539b6b22da50ea9022562db0583022f8436cd5..9d89197ee89edbdfeb452ae06d871efb7a3f411a 100644 --- a/source/game/BaseScope.cpp +++ b/source/game/BaseScope.cpp @@ -16,8 +16,7 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CBaseScope, base_scope); -CBaseScope::CBaseScope(CEntityManager * pMgr): - BaseClass(pMgr) +CBaseScope::CBaseScope() { m_addonType = WPN_ADDON_SCOPE; -} \ No newline at end of file +} diff --git a/source/game/BaseSilencer.cpp b/source/game/BaseSilencer.cpp index 946fb65908ae930c425ced7a31ca8a4f486fc4e3..ee43f1c4da7ae5de1cb48a26867380b3011fdefa 100644 --- a/source/game/BaseSilencer.cpp +++ b/source/game/BaseSilencer.cpp @@ -16,8 +16,7 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CBaseSilencer, base_silencer); -CBaseSilencer::CBaseSilencer(CEntityManager * pMgr): - BaseClass(pMgr) +CBaseSilencer::CBaseSilencer() { m_addonType = WPN_ADDON_SILENCER; -} \ No newline at end of file +} diff --git a/source/game/BaseTool.cpp b/source/game/BaseTool.cpp index 9bfb41ebf5f257d60b15737d3f6d4403c3e49c29..eadd6e447fdd19c8d1cb5e39e1770d33d111ac79 100644 --- a/source/game/BaseTool.cpp +++ b/source/game/BaseTool.cpp @@ -85,24 +85,9 @@ protected: btCollisionObject* m_me; }; -CBaseTool::CBaseTool(CEntityManager * pMgr): - BaseClass(pMgr), - m_bInPrimaryAction(false), - m_bInSecondaryAction(false), - m_bWorldModel(false), - m_bCanUse(true), - m_fZoomTime(0.0f), - m_fReloadTime(0.0f), - m_iZoomable(1), - m_iMuzzleFlash(-1), - m_iMuzzleFlash2(-1), - m_fMaxDistance(1000.0f), - m_bIsWeapon(false), - m_pLoadedAmmo(NULL) +CBaseTool::CBaseTool() { m_bInvStackable = false; - - m_iIvalUpdate = SET_INTERVAL(_update, 0); } CBaseTool::~CBaseTool() @@ -117,6 +102,8 @@ void CBaseTool::onPostLoad() { BaseClass::onPostLoad(); + m_iIvalUpdate = SET_INTERVAL(_update, 0); + IXSoundSystem *pSound = (IXSoundSystem*)(Core_GetIXCore()->getPluginManager()->getInterface(IXSOUNDSYSTEM_GUID)); if(pSound) { diff --git a/source/game/BaseTool.h b/source/game/BaseTool.h index 144911221c3678849ab0e535f7749a7cae0bbffd..6b00d4b5a6fbd81593c411a80561b2b9a5a70876 100644 --- a/source/game/BaseTool.h +++ b/source/game/BaseTool.h @@ -81,14 +81,14 @@ protected: bool isValidAmmo(CBaseSupply *pAmmo); - bool m_bInPrimaryAction; - bool m_bInSecondaryAction; + bool m_bInPrimaryAction = false; + bool m_bInSecondaryAction = false; - bool m_bWorldModel; + bool m_bWorldModel = false; - bool m_bCanUse; + bool m_bCanUse = true; - float m_fZoomTime; + float m_fZoomTime = 0.0f; float m_fZoomProgress = 0.0f; float m_fCloseProgress = 0.0f; @@ -104,7 +104,7 @@ protected: void _update(float dt); void _rezoom(); - float m_fReloadTime; + float m_fReloadTime = 0.0f; float3_t m_vSlotPos; float3_t m_vSlotPosAim; @@ -115,29 +115,29 @@ protected: SMQuaternion m_qSlotRotClose; SMQuaternion m_qSlotRotResult; - int m_iZoomable; + int m_iZoomable = 1; ID m_iIvalUpdate; - ID m_iMuzzleFlash; - ID m_iMuzzleFlash2; + ID m_iMuzzleFlash = -1; + ID m_iMuzzleFlash2 = -1; IXSoundEmitter *m_pSoundAction1 = NULL; IXSoundEmitter *m_pSoundAction2 = NULL; - const char * m_szPrimaryActionSound; - const char * m_szSecondaryActionSound; + const char *m_szPrimaryActionSound = NULL; + const char *m_szSecondaryActionSound = NULL; - const char * m_szPrimaryActionMuzzleflash; - const char * m_szSecondaryActionMuzzleflash; + const char *m_szPrimaryActionMuzzleflash = NULL; + const char *m_szSecondaryActionMuzzleflash = NULL; - const char * m_szUsableAmmos; - const char * m_szLoadedAmmo; - CBaseSupply * m_pLoadedAmmo; + const char *m_szUsableAmmos = NULL; + const char *m_szLoadedAmmo = NULL; + CBaseSupply *m_pLoadedAmmo = NULL; - float m_fMaxDistance; + float m_fMaxDistance = 1000.0f; //! Этот инструмент - оружие - bool m_bIsWeapon; + bool m_bIsWeapon = false; }; #endif diff --git a/source/game/BaseTrigger.cpp b/source/game/BaseTrigger.cpp index 6a4bd04f866b6719ea08b7457b6b60706080abe6..2d9b2530d6f278e22630cf6c504105867d1f2e17 100644 --- a/source/game/BaseTrigger.cpp +++ b/source/game/BaseTrigger.cpp @@ -30,15 +30,6 @@ END_PROPTABLE() REGISTER_ENTITY(CBaseTrigger, trigger); -CBaseTrigger::CBaseTrigger(CEntityManager * pMgr): - BaseClass(pMgr), - m_bEnabled(true), - m_pGhostObject(NULL), - m_idUpdateInterval(-1) -{ - m_idUpdateInterval = SET_INTERVAL(update, 0); -} - CBaseTrigger::~CBaseTrigger() { removePhysBody(); @@ -49,6 +40,9 @@ void CBaseTrigger::onPostLoad() { BaseClass::onPostLoad(); + assert(!ID_VALID(m_idUpdateInterval)); + m_idUpdateInterval = SET_INTERVAL(update, 0); + if(m_pModel) { //m_pModel->enable(false); diff --git a/source/game/BaseTrigger.h b/source/game/BaseTrigger.h index 116883366eb5a6642a52d9d945b84e266c567c9a..87bb957ed45b0f4af09465bd8ff5d4c702ea0ed8 100644 --- a/source/game/BaseTrigger.h +++ b/source/game/BaseTrigger.h @@ -25,7 +25,7 @@ class CBaseTrigger: public CBaseAnimating DECLARE_CLASS(CBaseTrigger, CBaseAnimating); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CBaseTrigger(); void onSync(); @@ -39,10 +39,10 @@ public: void setOrient(const SMQuaternion & q) override; protected: - bool m_bEnabled; - ID m_idUpdateInterval; + bool m_bEnabled = true; + ID m_idUpdateInterval = -1; - ID m_idDevMaterial; + ID m_idDevMaterial = -1; Array<CBaseEntity*> m_aTouches; Array<CBaseEntity*> m_aNewTouches; @@ -53,7 +53,7 @@ protected: void update(float dt); - btPairCachingGhostObject *m_pGhostObject; + btPairCachingGhostObject *m_pGhostObject = NULL; bool m_isModelEnabled = true; diff --git a/source/game/BaseWeapon.cpp b/source/game/BaseWeapon.cpp index 48e6217cf4e53b25ac6a525e890857322e147710..fda77236f49b26bb1e018df98b1b522958ea1f7f 100644 --- a/source/game/BaseWeapon.cpp +++ b/source/game/BaseWeapon.cpp @@ -93,33 +93,7 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CBaseWeapon, base_weapon); -CBaseWeapon::CBaseWeapon(CEntityManager * pMgr): - BaseClass(pMgr), - - m_idTaskShoot(-1), - - m_pSilencer(NULL), - m_pScope(NULL), - m_pHandle(NULL), - m_pMag(NULL), - m_fireMode(FIRE_MODE_SINGLE), - m_iFireModes(0), - - m_iCapacity(1), - m_iCurrentLoad(0), - - m_fBaseSpread(0.33f), - m_fSpreadIdle(0.01f), - m_fSpreadCrouch(0.007f), - m_fSpreadCrawl(0.001f), - m_fSpreadWalk(1.0f), - m_fSpreadRun(4.0f), - m_fSpreadAirborne(5.0f), - m_fSpreadCondition(3.0f), - m_fSpreadArm(3.0f), - m_fSpreadIronSight(-0.8f), - - m_fAimingRange(100.f) +CBaseWeapon::CBaseWeapon() { m_bIsWeapon = true; } diff --git a/source/game/BaseWeapon.h b/source/game/BaseWeapon.h index fbd1dcc3bbc887afe6ac3da3093a2a7e10a9c45e..ff14e812a4c8ca04d642fb2c593a3269787749e2 100644 --- a/source/game/BaseWeapon.h +++ b/source/game/BaseWeapon.h @@ -104,38 +104,38 @@ protected: //! Задача стрельбы virtual void taskShoot(float dt); - ID m_idTaskShoot; + ID m_idTaskShoot = -1; // Compatible addons - const char * m_szAddonScopes; - const char * m_szAddonSilencers; - const char * m_szAddonMags; - const char * m_szAddonHandlers; + const char *m_szAddonScopes = NULL; + const char *m_szAddonSilencers = NULL; + const char *m_szAddonMags = NULL; + const char *m_szAddonHandlers = NULL; // Addons - CBaseSilencer * m_pSilencer; - CBaseScope * m_pScope; - CBaseHandle * m_pHandle; - CBaseMag * m_pMag; + CBaseSilencer *m_pSilencer = NULL; + CBaseScope *m_pScope = NULL; + CBaseHandle *m_pHandle = NULL; + CBaseMag *m_pMag = NULL; // Fire modes - FIRE_MODE m_fireMode; - int m_iFireModes; - const char * m_szFireModes; - int m_iSingleRate; - int m_iBurstRate; - int m_iCutoffRate; - int m_iCutoffSize; + FIRE_MODE m_fireMode = FIRE_MODE_SINGLE; + int m_iFireModes = 0; + const char *m_szFireModes = NULL; + int m_iSingleRate = 1; + int m_iBurstRate = 1; + int m_iCutoffRate = 1; + int m_iCutoffSize = 1; - int m_iCutoffCurrent; + int m_iCutoffCurrent = 0; // Sounds - const char *m_szSndDraw; - const char *m_szSndHolster; - const char *m_szSndShoot; - const char *m_szSndEmpty; - const char *m_szSndReload; - const char *m_szSndSwitch; + const char *m_szSndDraw = NULL; + const char *m_szSndHolster = NULL; + const char *m_szSndShoot = NULL; + const char *m_szSndEmpty = NULL; + const char *m_szSndReload = NULL; + const char *m_szSndSwitch = NULL; IXSoundPlayer *m_pSndDraw = NULL; IXSoundPlayer *m_pSndHolster = NULL; @@ -145,26 +145,26 @@ protected: IXSoundPlayer *m_pSndSwitch = NULL; // Shooting - float m_fEffectiveDistance; - RIFLE_TYPE m_rifleType; - float m_fRifleStep; - float m_fAimingRange; + float m_fEffectiveDistance = 1000.0f; + RIFLE_TYPE m_rifleType = RIFLE_TYPE_UNRIFLED; + float m_fRifleStep = 0.0f; + float m_fAimingRange = 100.0f; // Without mag - int m_iCapacity; - int m_iCurrentLoad; + int m_iCapacity = 1; + int m_iCurrentLoad = 0; // Spread - float m_fBaseSpread; - float m_fSpreadIdle; - float m_fSpreadCrouch; - float m_fSpreadCrawl; - float m_fSpreadWalk; - float m_fSpreadRun; - float m_fSpreadAirborne; - float m_fSpreadCondition; - float m_fSpreadArm; - float m_fSpreadIronSight; + float m_fBaseSpread = 0.33f; + float m_fSpreadIdle = 0.01f; + float m_fSpreadCrouch = 0.007f; + float m_fSpreadCrawl = 0.001f; + float m_fSpreadWalk = 1.0f; + float m_fSpreadRun = 4.0f; + float m_fSpreadAirborne = 5.0f; + float m_fSpreadCondition = 3.0f; + float m_fSpreadArm = 3.0f; + float m_fSpreadIronSight = -0.8f; }; #endif diff --git a/source/game/BaseWeaponAddon.cpp b/source/game/BaseWeaponAddon.cpp index 03e94db9ff4e3bceecacd595ab4ec7e9b2e8971c..6234e216d1b4ac83be0814b6ca87d626133c319b 100644 --- a/source/game/BaseWeaponAddon.cpp +++ b/source/game/BaseWeaponAddon.cpp @@ -16,12 +16,6 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CBaseWeaponAddon, base_wpn_addon); -CBaseWeaponAddon::CBaseWeaponAddon(CEntityManager * pMgr): - BaseClass(pMgr), - m_addonType(WPN_ADDON_NONE) -{ -} - WPN_ADDON CBaseWeaponAddon::getType() const { return(m_addonType); diff --git a/source/game/BaseWeaponAddon.h b/source/game/BaseWeaponAddon.h index 5d3922b21c39facd9410ee4523ca34d322d5a7c9..c2f1ad13512428746f09d03918884ca6819c8820 100644 --- a/source/game/BaseWeaponAddon.h +++ b/source/game/BaseWeaponAddon.h @@ -34,14 +34,14 @@ class CBaseWeaponAddon: public CBaseItem DECLARE_CLASS(CBaseWeaponAddon, CBaseItem); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); //! Получить тип навеса WPN_ADDON getType() const; protected: //! Тип навеса - WPN_ADDON m_addonType; + WPN_ADDON m_addonType = WPN_ADDON_NONE; }; #endif diff --git a/source/game/Baseline.h b/source/game/Baseline.h index 103516a477f98ce5778bff7d5231ee92bf5ed4df..1526f336094452a95f121d85f7da0fa858454650 100644 --- a/source/game/Baseline.h +++ b/source/game/Baseline.h @@ -16,7 +16,7 @@ class CBaseline struct ent_record_s { - UINT m_id; + XGUID m_guid; String m_sClassname; AssotiativeArray<String, String> m_mProps; }; diff --git a/source/game/EditorObject.cpp b/source/game/EditorObject.cpp index 9bb29d1105cf9013ba7862bde423aea5157b0351..fdd850716425677728253c588672db2a9e40e43a 100644 --- a/source/game/EditorObject.cpp +++ b/source/game/EditorObject.cpp @@ -8,7 +8,7 @@ CEditorObject::CEditorObject(CEditable *pEditable, CBaseEntity *pEntity): m_pEditable(pEditable), m_pEntity(pEntity), - m_idEnt(pEntity->getId()) + m_guidEnt(*pEntity->getGUID()) { assert(pEntity); @@ -228,7 +228,7 @@ void XMETHODCALLTYPE CEditorObject::remove() } REMOVE_ENTITY(m_pEntity); m_pEntity = NULL; - m_idEnt = -1; + //m_guidEnt = XGUID(); } void XMETHODCALLTYPE CEditorObject::preSetup() { @@ -241,9 +241,16 @@ void XMETHODCALLTYPE CEditorObject::postSetup() void XMETHODCALLTYPE CEditorObject::create() { assert(!m_pEntity); - m_pEntity = CREATE_ENTITY(m_szClassName, GameData::m_pMgr); - m_idEnt = m_pEntity->getId(); + if(m_guidEnt == XGUID()) + { + m_pEntity = CREATE_ENTITY(m_szClassName, GameData::m_pMgr); + m_guidEnt = *m_pEntity->getGUID(); + } + else + { + m_pEntity = CEntityFactoryMap::GetInstance()->create(m_szClassName, GameData::m_pMgr, false, &m_guidEnt); + } m_pEntity->setFlags(m_pEntity->getFlags() | EF_LEVEL | EF_EXPORT); @@ -254,9 +261,9 @@ void XMETHODCALLTYPE CEditorObject::create() void CEditorObject::resync() { - if(ID_VALID(m_idEnt)) + if(m_pEntity) { - m_pEntity = GameData::m_pMgr->getById(m_idEnt); + m_pEntity = GameData::m_pMgr->getByGUID(m_guidEnt); } } diff --git a/source/game/EditorObject.h b/source/game/EditorObject.h index e9bab6d374cc047f83c735a9a8e791f532e044ea..71b4d2ad131321322bca6163adda3916c81dff17 100644 --- a/source/game/EditorObject.h +++ b/source/game/EditorObject.h @@ -74,7 +74,7 @@ protected: void _iniFieldList(); - ID m_idEnt = -1; + XGUID m_guidEnt; protected: bool m_isSelected = false; diff --git a/source/game/EntityFactory.cpp b/source/game/EntityFactory.cpp index ac4de7c989f397e60b0ec0e9e99d763874c4daa9..d78952205131eac8ee1cea4167093214540c8cb9 100644 --- a/source/game/EntityFactory.cpp +++ b/source/game/EntityFactory.cpp @@ -22,13 +22,14 @@ void CEntityFactoryMap::addFactory(IEntityFactory *pFactory, const char *szName) } m_mFactories[AAString(szName)] = pFactory; } -CBaseEntity* CEntityFactoryMap::create(const char *szName, CEntityManager *pWorld, bool bDelayPostLoad) +CBaseEntity* CEntityFactoryMap::create(const char *szName, CEntityManager *pWorld, bool bDelayPostLoad, const XGUID *pGUID) { IEntityFactory *pFactory = getFactory(szName); if(pFactory) { EntDefaultsMap *defs = pFactory->getDefaults(); - CBaseEntity *pEnt = pFactory->create(pWorld); + CBaseEntity *pEnt = pFactory->create(); + pWorld->reg(pEnt, pGUID); pEnt->setDefaults(); pEnt->setClassName(pFactory->getClassName()); diff --git a/source/game/EntityFactory.h b/source/game/EntityFactory.h index 3aa8d7ef9128fb79c6c7a4b0adee045b14e9547d..8f995d9412165266570a44459addd137f8825d6b 100644 --- a/source/game/EntityFactory.h +++ b/source/game/EntityFactory.h @@ -22,7 +22,7 @@ class CEntityManager; class IEntityFactory { public: - virtual CBaseEntity* create(CEntityManager * pWorld) = 0; + virtual CBaseEntity* create() = 0; virtual void destroy(CBaseEntity * pEnt) = 0; virtual const char* getClassName() = 0; virtual proptable_t* getPropTable() = 0; @@ -39,7 +39,7 @@ public: CEntityFactoryMap(); void addFactory(IEntityFactory *pFactory, const char *szName); - CBaseEntity* create(const char *szName, CEntityManager *pMgr, bool bDelayPostLoad=false); + CBaseEntity* create(const char *szName, CEntityManager *pMgr, bool bDelayPostLoad=false, const XGUID *pGUID=NULL); void destroy(CBaseEntity *pEnt); static CEntityFactoryMap* GetInstance(); @@ -113,9 +113,9 @@ public: return(newF); } - CBaseEntity* create(CEntityManager *pWorld) override + CBaseEntity* create() override { - return(new T(pWorld)); + return(new T()); } void destroy(CBaseEntity *pEnt) override diff --git a/source/game/EntityManager.cpp b/source/game/EntityManager.cpp index 7075321213822d2510c056703d53f226be6184ad..896dea78609b9a3b3244df9e7b4fcf807fff3b99 100644 --- a/source/game/EntityManager.cpp +++ b/source/game/EntityManager.cpp @@ -234,39 +234,45 @@ void CEntityManager::unloadObjLevel() } } -ID CEntityManager::reg(CBaseEntity *pEnt) +const XGUID* CEntityManager::reg(CBaseEntity *pEnt, const XGUID *pGUID) { - ID ent; if(!pEnt) { - return(-1); + return(NULL); } - if(m_vFreeIDs.size()) + + XGUID guid; + if(pGUID) { - ent = m_vFreeIDs[0]; - m_vFreeIDs.erase(0); - m_vEntList[ent] = pEnt; + guid = *pGUID; } else { - ent = m_vEntList.size(); - m_vEntList.push_back(pEnt); + XCreateGUID(&guid); } - return(ent); + + m_mEnts[guid] = pEnt; + + const XGUID *pNewGUID = &m_mEnts.TmpNode->Key; + + pEnt->setGUID(pNewGUID); + pEnt->setWorld(this); + + m_vEntList.push_back(pEnt); + + return(pNewGUID); } -void CEntityManager::unreg(ID ent) +void CEntityManager::unreg(CBaseEntity *pEnt) { - //@TODO: Clear all outputs - if(m_vEntList.size() <= (UINT)ent || ent < 0) - { - return; - } + assert(pEnt && pEnt->getGUID()); + + int iKey = m_vEntList.indexOf(pEnt); + assert(iKey >= 0); + m_vEntList.erase(iKey); timeout_t * t; timeout_output_t * to; - CBaseEntity *pEnt = m_vEntList[ent]; - for(int i = 0, l = m_vOutputTimeout.size(); i < l; ++i) { to = &m_vOutputTimeout[i]; @@ -306,8 +312,7 @@ void CEntityManager::unreg(ID ent) } } - m_vEntList[ent] = NULL; - m_vFreeIDs.push_back(ent); + m_mEnts.erase(*pEnt->getGUID()); } void CEntityManager::regSync(CBaseEntity *pEnt) @@ -318,14 +323,9 @@ void CEntityManager::regSync(CBaseEntity *pEnt) void CEntityManager::unregSync(CBaseEntity *pEnt) { assert(pEnt); - for(UINT i = 0, l = m_vEntSyncList.size(); i < l; ++i) - { - if(m_vEntSyncList[i] == pEnt) - { - m_vEntSyncList.erase(i); - break; - } - } + int iKey = m_vEntSyncList.indexOf(pEnt); + assert(iKey >= 0); + m_vEntSyncList.erase(iKey); } ID CEntityManager::setTimeout(void(CBaseEntity::*func)(float dt), CBaseEntity *pEnt, float delay) @@ -412,11 +412,17 @@ bool CEntityManager::exportList(const char * file) { ISXConfig * conf = Core_CrConfig(); conf->New(file); - char buf[4096], sect[32]; + char buf[4096], sect[64]; CBaseEntity * pEnt; proptable_t * pTbl; int ic = 0; + FILE *fp = fopen(file, "w"); + if(fp) + { + fclose(fp); + } + // conf->set("meta", "count", "0"); for(int i = 0, l = m_vEntList.size(); i < l; ++i) @@ -426,13 +432,14 @@ bool CEntityManager::exportList(const char * file) { continue; } - sprintf(sect, "ent_%d", ic); if(!(pEnt->getFlags() & EF_EXPORT)) { continue; } + XGUIDToSting(*pEnt->getGUID(), sect, sizeof(sect)); + conf->set(sect, "classname", pEnt->getClassName()); pTbl = CEntityFactoryMap::GetInstance()->getPropTable(pEnt->getClassName()); do @@ -450,8 +457,8 @@ bool CEntityManager::exportList(const char * file) ++ic; } - sprintf(buf, "%d", ic); - conf->set("meta", "count", buf); + // sprintf(buf, "%d", ic); + // conf->set("meta", "count", buf); bool ret = !conf->save(); mem_release(conf); @@ -466,7 +473,7 @@ bool CEntityManager::import(const char * file, bool shouldSendProgress) pEventChannel = Core_GetIXCore()->getEventChannel<XEventLevelProgress>(EVENT_LEVEL_PROGRESS_GUID); } ISXConfig * conf = Core_CrConfig(); - char sect[32]; + const char *sect; CBaseEntity * pEnt = NULL; Array<CBaseEntity*> tmpList; @@ -481,20 +488,13 @@ bool CEntityManager::import(const char * file, bool shouldSendProgress) goto err; } - if(!conf->keyExists("meta", "count")) - { - goto err; - } + int ic = conf->getSectionCount(); + tmpList.reserve(ic); - int ic; - if(sscanf(conf->getKey("meta", "count"), "%d", &ic) != 1) - { - goto err; - } - tmpList.reserve(ic); { + XGUID guid; XEventLevelProgress ev; ev.idPlugin = -3; @@ -503,64 +503,87 @@ bool CEntityManager::import(const char * file, bool shouldSendProgress) ev.fProgress = 0.0f; for(int i = 0; i < ic; ++i) { - sprintf(sect, "ent_%d", i); - if(!conf->keyExists(sect, "classname")) + sect = conf->getSectionName(i); + + if(sect[0] == '{' || (sect[0] == 'e' && sect[1] == 'n' && sect[2] == 't' && sect[3] == '_')) { - printf(COLOR_LRED "Unable to load entity #%d, classname undefined\n" COLOR_RESET, i); - tmpList[i] = NULL; - continue; + if(!conf->keyExists(sect, "classname")) + { + printf(COLOR_LRED "Unable to load entity #%d, classname undefined\n" COLOR_RESET, i); + tmpList[i] = NULL; + continue; + } + + XGUID *pGUID = NULL; + if(XGUIDFromString(&guid, sect)) + { + pGUID = &guid; + } + + if(!(pEnt = CEntityFactoryMap::GetInstance()->create(conf->getKey(sect, "classname"), this, true, pGUID))) + { + printf(COLOR_LRED "Unable to load entity #%d, classname '%s' undefined\n" COLOR_RESET, i, conf->getKey(sect, "classname")); + tmpList[i] = NULL; + continue; + } + if(conf->keyExists(sect, "name")) + { + pEnt->setKV("name", conf->getKey(sect, "name")); + } + if(conf->keyExists(sect, "origin")) + { + pEnt->setKV("origin", conf->getKey(sect, "origin")); + } + if(conf->keyExists(sect, "rotation")) + { + pEnt->setKV("rotation", conf->getKey(sect, "rotation")); + } + pEnt->setFlags(pEnt->getFlags() | EF_EXPORT | EF_LEVEL); + tmpList[i] = pEnt; + + if((i & 0xF) == 0 && pEventChannel) + { + ev.fProgress = (float)i / (float)ic * 0.1f; + pEventChannel->broadcastEvent(&ev); + } } - if(!(pEnt = CREATE_ENTITY_NOPOST(conf->getKey(sect, "classname"), this))) + else { - printf(COLOR_LRED "Unable to load entity #%d, classname '%s' undefined\n" COLOR_RESET, i, conf->getKey(sect, "classname")); tmpList[i] = NULL; - continue; - } - if(conf->keyExists(sect, "name")) - { - pEnt->setKV("name", conf->getKey(sect, "name")); - } - if(conf->keyExists(sect, "origin")) - { - pEnt->setKV("origin", conf->getKey(sect, "origin")); - } - if(conf->keyExists(sect, "rotation")) - { - pEnt->setKV("rotation", conf->getKey(sect, "rotation")); - } - pEnt->setFlags(pEnt->getFlags() | EF_EXPORT | EF_LEVEL); - tmpList[i] = pEnt; - - if((i & 0xF) == 0 && pEventChannel) - { - ev.fProgress = (float)i / (float)ic * 0.1f; - pEventChannel->broadcastEvent(&ev); } } for(int i = 0; i < ic; ++i) { - sprintf(sect, "ent_%d", i); - if(!(pEnt = tmpList[i])) - { - continue; - } - int keyc = conf->getKeyCount(sect); - const char * key; - for(int j = 0; j < keyc; ++j) + sect = conf->getSectionName(i); + + if(sect[0] == '{' || (sect[0] == 'e' && sect[1] == 'n' && sect[2] == 't' && sect[3] == '_')) { - key = conf->getKeyName(sect, j); - if(strcmp(key, "classname") && strcmp(key, "origin") && strcmp(key, "name") && strcmp(key, "rotation")) + if(!(pEnt = tmpList[i])) { - pEnt->setKV(key, conf->getKey(sect, key)); + continue; } - } - pEnt->onPostLoad(); + int keyc = conf->getKeyCount(sect); + const char *key; + for(int j = 0; j < keyc; ++j) + { + key = conf->getKeyName(sect, j); + if(strcmp(key, "classname") && strcmp(key, "origin") && strcmp(key, "name") && strcmp(key, "rotation")) + { + pEnt->setKV(key, conf->getKey(sect, key)); + } + } + pEnt->onPostLoad(); - if(/*(i & 0xF) == 0 && */pEventChannel) + if(/*(i & 0xF) == 0 && */pEventChannel) + { + ev.fProgress = (float)i / (float)ic * 0.9f + 0.1f; + pEventChannel->broadcastEvent(&ev); + } + } + else { - ev.fProgress = (float)i / (float)ic * 0.9f + 0.1f; - pEventChannel->broadcastEvent(&ev); + tmpList[i] = NULL; } } } @@ -770,14 +793,14 @@ void CEntityManager::dumpList(int argc, const char **argv) filter = argv[1]; } - printf(COLOR_GREEN "-----------------------------------------------------\n" + printf(COLOR_GREEN "---------------------------------------------------------------------------------------\n" COLOR_GREEN " Filter: " COLOR_LGREEN "%s\n" COLOR_GREEN " Total count: " COLOR_LGREEN "%u\n" - COLOR_GREEN "-----------------------------------------------------\n" - " id | class | name |\n" - "------|--------------------------|------------------|\n" + COLOR_GREEN "---------------------------------------------------------------------------------------\n" + " guid | class | name |\n" + "----------------------------------------|--------------------------|------------------|\n" , filter, m_vEntList.size()); - + char tmp[64]; for(int i = 0, l = m_vEntList.size(); i < l; ++i) { CBaseEntity * pEnt = m_vEntList[i]; @@ -787,11 +810,12 @@ void CEntityManager::dumpList(int argc, const char **argv) } if(!filter[0] || strstr(pEnt->getClassName(), filter)) { - printf(" " COLOR_LGREEN "%-4d" COLOR_GREEN " | " COLOR_LGREEN "%-24s" COLOR_GREEN " | " COLOR_LGREEN "%-16s" COLOR_GREEN " |\n", i, pEnt->getClassName(), pEnt->getName()); + XGUIDToSting(*pEnt->getGUID(), tmp, sizeof(tmp)); + printf(" " COLOR_LGREEN "%s" COLOR_GREEN " | " COLOR_LGREEN "%-24s" COLOR_GREEN " | " COLOR_LGREEN "%-16s" COLOR_GREEN " |\n", tmp, pEnt->getClassName(), pEnt->getName()); } } - printf("-----------------------------------------------------\n" COLOR_RESET); + printf("---------------------------------------------------------------------------------------\n" COLOR_RESET); } void CEntityManager::entKV(int argc, const char **argv) @@ -859,6 +883,12 @@ CBaseEntity* CEntityManager::getById(ID id) return(pEnt ? (pEnt->getFlags() & EF_REMOVED ? NULL : pEnt) : NULL); } +CBaseEntity* CEntityManager::getByGUID(const XGUID &guid) +{ + CBaseEntity *const *ppEnt = m_mEnts.at(guid); + return(ppEnt ? *ppEnt : NULL); +} + CBaseEntity* CEntityManager::cloneEntity(CBaseEntity *pOther) { if(!pOther) @@ -1044,7 +1074,7 @@ CBaseline* CEntityManager::createBaseline(ID id) if(pEnt && (pEnt->getFlags() & EF_LEVEL) && !(pEnt->getFlags() & EF_REMOVED)) { CBaseline::ent_record_s record; - record.m_id = pEnt->getId(); + record.m_guid = *pEnt->getGUID(); record.m_sClassname = pEnt->getClassName(); pDefaults = CEntityFactoryMap::GetInstance()->getDefaults(pEnt->getClassName()); @@ -1095,23 +1125,31 @@ void CEntityManager::dispatchBaseline(CBaseline *pBaseline) return; } +#if 0 UINT idMax = pBaseline->m_aRecords[pBaseline->m_aRecords.size() - 1].m_id; if(m_vEntList.size() <= idMax) { m_vEntList.reserve(idMax + 1); } +#endif + + Array<CBaseEntity*> aPostLoadList(pBaseline->m_aRecords.size()); const AssotiativeArray<String, String>::Node *pNode; for(int i = 0, l = pBaseline->m_aRecords.size(); i < l; ++i) { CBaseline::ent_record_s *pRecord = &pBaseline->m_aRecords[i]; - if(!(pEnt = CREATE_ENTITY_NOPOST(pRecord->m_sClassname.c_str(), this))) + if(!(pEnt = CEntityFactoryMap::GetInstance()->create(pRecord->m_sClassname.c_str(), this, true, &pRecord->m_guid))) { printf(COLOR_LRED "Unable to load entity #%d, classname '%s' undefined\n" COLOR_RESET, i, pRecord->m_sClassname.c_str()); + aPostLoadList[i] = NULL; continue; } + aPostLoadList[i] = pEnt; + +#if 0 if(pEnt->getId() != pRecord->m_id) { m_vEntList[pEnt->getId()] = NULL; @@ -1144,6 +1182,7 @@ void CEntityManager::dispatchBaseline(CBaseline *pBaseline) m_vEntList[pRecord->m_id] = pEnt; pEnt->m_iId = pRecord->m_id; } +#endif if(pRecord->m_mProps.KeyExists("name", &pNode)) { @@ -1166,25 +1205,23 @@ void CEntityManager::dispatchBaseline(CBaseline *pBaseline) { CBaseline::ent_record_s *pRecord = &pBaseline->m_aRecords[i]; - pEnt = m_vEntList[pRecord->m_id]; - for(AssotiativeArray<String, String>::Iterator it = pRecord->m_mProps.begin(); it; it++) + if((pEnt = aPostLoadList[i])) { - key = it.first->c_str(); - - if(strcmp(key, "origin") && strcmp(key, "name") && strcmp(key, "rotation")) + for(AssotiativeArray<String, String>::Iterator it = pRecord->m_mProps.begin(); it; it++) { - pEnt->setKV(key, it.second->c_str()); + key = it.first->c_str(); + + if(strcmp(key, "origin") && strcmp(key, "name") && strcmp(key, "rotation")) + { + pEnt->setKV(key, it.second->c_str()); + } } } } - for(int i = 1, l = m_vEntList.size(); i < l; ++i) + for(UINT i = 0, l = aPostLoadList.size(); i < l; ++i) { - pEnt = m_vEntList[i]; - if(pEnt) - { - pEnt->onPostLoad(); - } + SAFE_CALL(aPostLoadList[i], onPostLoad); } } diff --git a/source/game/EntityManager.h b/source/game/EntityManager.h index 03cd994d3df1453b7708ab743569c6cf8f2e90bd..cb031a1f0e3a3cfb2805098a97668aeaab5ab980 100644 --- a/source/game/EntityManager.h +++ b/source/game/EntityManager.h @@ -122,7 +122,8 @@ public: void entKV(int argc, const char **argv); int getCount(); - CBaseEntity* getById(ID id); + CBaseEntity *getById(ID id); + CBaseEntity *getByGUID(const XGUID &guid); CBaseEntity* cloneEntity(CBaseEntity *pEnt); @@ -143,16 +144,17 @@ public: #endif protected: - ID reg(CBaseEntity *pEnt); - void unreg(ID ent); + const XGUID* reg(CBaseEntity *pEnt, const XGUID *pGUID=NULL); + void unreg(CBaseEntity *pEnt); void regSync(CBaseEntity *pEnt); void unregSync(CBaseEntity *pEnt); + Map<XGUID, CBaseEntity*> m_mEnts; Array<CBaseEntity*, 64> m_vEntList; Array<CBaseEntity*, 64> m_vEntSyncList; Array<CBaseEntity*> m_vEntRemoveList; - Array<ID> m_vFreeIDs; + Array<UINT> m_vFreeIDs; Array<timeout_t> m_vTimeout; Array<timeout_t> m_vInterval; diff --git a/source/game/EnvSkybox.cpp b/source/game/EnvSkybox.cpp index 6593000852727c61de2fd855bf5904e2e23e1279..2727e874a5bbe2bc3d2d6bc0a82968f9acd2f85a 100644 --- a/source/game/EnvSkybox.cpp +++ b/source/game/EnvSkybox.cpp @@ -24,8 +24,7 @@ END_PROPTABLE() REGISTER_ENTITY(CEnvSkybox, env_skybox); -CEnvSkybox::CEnvSkybox(CEntityManager *pMgr): - BaseClass(pMgr) +CEnvSkybox::CEnvSkybox() { m_pAmbient = (IXAmbient*)Core_GetIXCore()->getPluginManager()->getInterface(IXAMBIENT_GUID); } diff --git a/source/game/FuncRotating.cpp b/source/game/FuncRotating.cpp index 1daa3f06133138012981a0a1c6e3b3637d6c2671..e6d205ab1613048f739ad07a974ab30c3ab8f26e 100644 --- a/source/game/FuncRotating.cpp +++ b/source/game/FuncRotating.cpp @@ -19,11 +19,6 @@ END_PROPTABLE() REGISTER_ENTITY(CFuncRotating, func_rotating); -CFuncRotating::CFuncRotating(CEntityManager * pMgr): - BaseClass(pMgr) -{ -} - CFuncRotating::~CFuncRotating() { if(ID_VALID(m_idThinkInterval)) diff --git a/source/game/FuncRotating.h b/source/game/FuncRotating.h index 0caea4942bdfa1e6cf07ad31e44ac25f705780cb..8e4bf9127358cc6a3cf2577741f43b14510341b7 100644 --- a/source/game/FuncRotating.h +++ b/source/game/FuncRotating.h @@ -11,7 +11,7 @@ class CFuncRotating: public CPointEntity DECLARE_CLASS(CFuncRotating, CPointEntity); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CFuncRotating(); protected: diff --git a/source/game/FuncTrain.cpp b/source/game/FuncTrain.cpp index 531f72f549ceaa01a31032897e1206ffd9a88022..466178eb6943f88ef1285a1784121b54f6a26039 100644 --- a/source/game/FuncTrain.cpp +++ b/source/game/FuncTrain.cpp @@ -21,15 +21,6 @@ END_PROPTABLE() REGISTER_ENTITY(CFuncTrain, func_train); -CFuncTrain::CFuncTrain(CEntityManager * pMgr): - BaseClass(pMgr), - m_fSpeed(0.0f), - m_pStartStop(NULL), - m_bRunning(false), - m_fCurDist(0.0f) -{ -} - void CFuncTrain::onPostLoad() { BaseClass::onPostLoad(); diff --git a/source/game/FuncTrain.h b/source/game/FuncTrain.h index da64b30dc7f9411cb51431cddfcd71443a7f20b9..458ece6bda83a8126c30dccd41b2a4d0da55780d 100644 --- a/source/game/FuncTrain.h +++ b/source/game/FuncTrain.h @@ -23,7 +23,7 @@ class CFuncTrain: public CPointEntity DECLARE_CLASS(CFuncTrain, CPointEntity); DECLARE_PROPTABLE(); public: - CFuncTrain(CEntityManager * pMgr); + DECLARE_TRIVIAL_CONSTRUCTOR(); //! Остановить void stop(); @@ -35,20 +35,20 @@ protected: void moveFunc(float dt); //! Начальная точка движения - CPathCorner * m_pStartStop; + CPathCorner *m_pStartStop = NULL; //! Текущая точка - CPathCorner * m_pCurStop; + CPathCorner *m_pCurStop = NULL; //! Скорость - float m_fSpeed; + float m_fSpeed = 0.0f; //! Текущая дистанция от начала пути - float m_fCurDist; + float m_fCurDist = 0.0f; //! Запущен ли - bool m_bRunning; + bool m_bRunning = false; //! ID таймера - ID m_iPostIval; + ID m_iPostIval = -1; }; #endif diff --git a/source/game/GameData.cpp b/source/game/GameData.cpp index a8d93d1dbd081d26ad4860c07ee4794ef7e3a781..a026c74de1a3cff78d487fe975251f5816b22150 100644 --- a/source/game/GameData.cpp +++ b/source/game/GameData.cpp @@ -573,7 +573,9 @@ GameData::GameData(HWND hWnd, bool isGame): CBaseEntity *pEnt; if(sscanf(argv[1], "%p", &pEnt)) { - LibReport(REPORT_MSG_LEVEL_WARNING, "Ent: id:%d; cls:'%s'; name:'%s'\n", pEnt->getId(), pEnt->getClassName(), pEnt->getName()); + char tmp[64]; + XGUIDToSting(*pEnt->getGUID(), tmp, sizeof(tmp)); + LibReport(REPORT_MSG_LEVEL_WARNING, "Ent: guid:%s; cls:'%s'; name:'%s'\n", tmp, pEnt->getClassName(), pEnt->getName()); } }); @@ -1322,7 +1324,7 @@ void GameData::render() , g_uFPS, pAdapterDesc->szDescription, - pAdapterDesc->sizeTotalMemory / 1024 / 1024, + (UINT)(pAdapterDesc->sizeTotalMemory / 1024 / 1024), (float)(pMemoryStats->sizeIndexBufferBytes + pMemoryStats->sizeRenderTargetBytes + pMemoryStats->sizeShaderConstBytes + pMemoryStats->sizeTextureBytes + pMemoryStats->sizeVertexBufferBytes) / 1024.0f / 1024.0f, (float)pMemoryStats->sizeTextureBytes / 1024.0f / 1024.0f, diff --git a/source/game/LightDirectional.cpp b/source/game/LightDirectional.cpp index 106198f4b5db20c06280b9f82e77c87aa9ef285d..8799a70a68e2561a764b8dc3ff1ac4275dfc834b 100644 --- a/source/game/LightDirectional.cpp +++ b/source/game/LightDirectional.cpp @@ -21,7 +21,7 @@ END_PROPTABLE() REGISTER_ENTITY(CLightDirectional, light_directional); -CLightDirectional::CLightDirectional(CEntityManager *pMgr):BaseClass(pMgr) +CLightDirectional::CLightDirectional() { if(m_pLightSystem) { diff --git a/source/game/LightPoint.cpp b/source/game/LightPoint.cpp index 484a931ccfd3f23150a525975129c7839fc44cfb..65e323b1b63ce0f96206ee6800b18a242d06af12 100644 --- a/source/game/LightPoint.cpp +++ b/source/game/LightPoint.cpp @@ -16,7 +16,7 @@ END_PROPTABLE() REGISTER_ENTITY(CLightPoint, light_point); -CLightPoint::CLightPoint(CEntityManager * pMgr):BaseClass(pMgr) +CLightPoint::CLightPoint() { if(m_pLightSystem) { diff --git a/source/game/LightSun.cpp b/source/game/LightSun.cpp index c52dec51121541b4f63ff89cb7686778ee561aea..0a574643462740dc379adb7ac32b5a6edabc70aa 100644 --- a/source/game/LightSun.cpp +++ b/source/game/LightSun.cpp @@ -16,7 +16,7 @@ END_PROPTABLE() REGISTER_ENTITY(CLightSun, light_sun); -CLightSun::CLightSun(CEntityManager * pMgr):BaseClass(pMgr) +CLightSun::CLightSun() { if(m_pLightSystem) { diff --git a/source/game/LogicAuto.cpp b/source/game/LogicAuto.cpp index 332fd232fe16e518de08cebed35cef91684f9674..b01741d60975cc32d0857f1ccf092ca9b71fd5d0 100644 --- a/source/game/LogicAuto.cpp +++ b/source/game/LogicAuto.cpp @@ -20,11 +20,6 @@ END_PROPTABLE() REGISTER_ENTITY(CLogicAuto, logic_auto); -CLogicAuto::CLogicAuto(CEntityManager * pMgr): - BaseClass(pMgr) -{ -} - void CLogicAuto::activate() { SET_TIMEOUT(doTrigger, m_fDelay); diff --git a/source/game/LogicAuto.h b/source/game/LogicAuto.h index 445c91e327db420548225a5f9ede20ba92055226..2b6160e72b2120d9dc1379da37bcf90e844eac3f 100644 --- a/source/game/LogicAuto.h +++ b/source/game/LogicAuto.h @@ -8,7 +8,7 @@ class CLogicAuto: public CPointEntity DECLARE_CLASS(CLogicAuto, CPointEntity); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); void activate(); diff --git a/source/game/LogicRelay.cpp b/source/game/LogicRelay.cpp index d467453432c66dc692ae849f8582e5a5ba32cdef..b4e66070be51a06364a25150135ea0adddd62999 100644 --- a/source/game/LogicRelay.cpp +++ b/source/game/LogicRelay.cpp @@ -29,12 +29,6 @@ END_PROPTABLE() REGISTER_ENTITY(CLogicRelay, logic_relay); -CLogicRelay::CLogicRelay(CEntityManager * pMgr): - BaseClass(pMgr) -{ - m_isEnabled = true; -} - void CLogicRelay::turnOn(inputdata_t * pInputdata) { m_isEnabled = true; diff --git a/source/game/LogicRelay.h b/source/game/LogicRelay.h index 89afdd9b1bed934b806f17e4e05570b38c12d933..05d976e762ad1df29e41a1522858169dbe082bb6 100644 --- a/source/game/LogicRelay.h +++ b/source/game/LogicRelay.h @@ -1,12 +1,12 @@ /*********************************************************** -Copyright � Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018 +Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018 See the license in LICENSE ***********************************************************/ /*! \file -���������� ���� +Логическое реле */ #ifndef __LOGIC_RELAY_H @@ -16,7 +16,7 @@ See the license in LICENSE #define LOGIC_START_DISABLED ENT_FLAG_0 -/*! ���������� ���� +/*! Логическое реле \ingroup cpointentity */ class CLogicRelay: public CPointEntity @@ -24,7 +24,7 @@ class CLogicRelay: public CPointEntity DECLARE_CLASS(CLogicRelay, CPointEntity); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); protected: void turnOn(inputdata_t * pInputdata); @@ -32,11 +32,11 @@ protected: void trigger(inputdata_t * pInputdata); void toggle(inputdata_t * pInputdata); - void onPostLoad(); + void onPostLoad() override; output_t m_onTrigger; - bool m_isEnabled; + bool m_isEnabled = true; }; #endif diff --git a/source/game/NPCBase.cpp b/source/game/NPCBase.cpp index 7b5e7d3ea8cbbb0de130b85cdd265bd78c8fb5d0..cae49007db3702db2ac0c2389cf902a236fb69fb 100644 --- a/source/game/NPCBase.cpp +++ b/source/game/NPCBase.cpp @@ -44,8 +44,7 @@ protected: btCollisionObject* m_me; }; -CNPCBase::CNPCBase(CEntityManager * pMgr): - BaseClass(pMgr), +CNPCBase::CNPCBase(): m_idQuadGoingTo(-1), m_idFindPathInterval(-1), m_idPathFollowInterval(-1), @@ -112,6 +111,7 @@ void CNPCBase::setPos(const float3 &pos) float3 tpos = pos; m_idQuadCurr = SAIG_QuadGet(&tpos, true); +#if 0 if(ID_VALID(m_idQuadCurr)) { if(SAIG_QuadGetState(m_idQuadCurr) == AIQUAD_STATE_FREE) @@ -128,13 +128,13 @@ void CNPCBase::setPos(const float3 &pos) SAIG_QuadSetState(m_idQuadCurr, AIQUAD_STATE_BUSY); SAIG_QuadSetStateWho(m_idQuadCurr, getId()); SAIG_QuadGetPos(m_idQuadCurr, &tpos); - tpos.y += 0.7f; - setPos(tpos); + tpos.y += 0.7f; + setPos(tpos); return; - } } } - + } +#endif if(ID_VALID(m_idQuadGoingTo)) { m_idQuadGoingTo = -1; diff --git a/source/game/NPCBase.h b/source/game/NPCBase.h index 20cc652c05ca4b7e38d9e1c84466c7f43b730d22..de5fe426d44975c57dcaa96a29080670b6867135 100644 --- a/source/game/NPCBase.h +++ b/source/game/NPCBase.h @@ -47,10 +47,8 @@ class CNPCBase: public CBaseCharacter DECLARE_PROPTABLE(); public: - SX_ALIGNED_OP_MEM(); - - CNPCBase(CEntityManager * pMgr); + DECLARE_CONSTRUCTOR(); ~CNPCBase(); ID getAIQuad(); //!< id квада аи сетки на котором стоит нпс diff --git a/source/game/NPCZombie.cpp b/source/game/NPCZombie.cpp index a021c37327bb63f1f24d96414f86a134b65e60f0..6bc428a073c955bb80d737206d900768cc2b1690 100644 --- a/source/game/NPCZombie.cpp +++ b/source/game/NPCZombie.cpp @@ -21,8 +21,7 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CNPCZombie, npc_zombie); -CNPCZombie::CNPCZombie(CEntityManager * pMgr) : - BaseClass(pMgr), +CNPCZombie::CNPCZombie(): m_stateDanger(NPC_STATE_DANGER_CALM), m_iObserveRotateStep(0), m_idRotateInterval(-1), diff --git a/source/game/NPCZombie.h b/source/game/NPCZombie.h index 42b26a47ad8fac9469b25b3361df9e808c1fd5e7..76d2d9ef0d70e8df665259399b06124b4757a87c 100644 --- a/source/game/NPCZombie.h +++ b/source/game/NPCZombie.h @@ -33,7 +33,7 @@ class CNPCZombie: public CNPCBase DECLARE_PROPTABLE(); public: - CNPCZombie(CEntityManager * pMgr); + DECLARE_CONSTRUCTOR(); ~CNPCZombie(); void onDeath(CBaseEntity *pAttacker, CBaseEntity *pInflictor); diff --git a/source/game/PathCorner.cpp b/source/game/PathCorner.cpp index 726020c1186313f88e42fcf97af542d692896a70..4e16cdb52249e1a57513cf6da1d497de3ae32d54 100644 --- a/source/game/PathCorner.cpp +++ b/source/game/PathCorner.cpp @@ -27,16 +27,6 @@ END_PROPTABLE() REGISTER_ENTITY(CPathCorner, path_corner); -CPathCorner::CPathCorner(CEntityManager * pMgr): - BaseClass(pMgr), - m_type(PCT_SPLINE), - m_fNewSpeed(0.0f), - m_pNextStop(NULL), - m_pPrevStop(NULL), - m_fLength(0.0f) -{ -} - CPathCorner::~CPathCorner() { setNextPoint(NULL); diff --git a/source/game/PathCorner.h b/source/game/PathCorner.h index 6336ef2dad3ff81a54c49d196367b0d2583f97b8..d43ada71889815f3fcfeaaa67e14438dc84c2a9b 100644 --- a/source/game/PathCorner.h +++ b/source/game/PathCorner.h @@ -31,7 +31,7 @@ class CPathCorner: public CPointEntity DECLARE_CLASS(CPathCorner, CPointEntity); DECLARE_PROPTABLE(); public: - CPathCorner(CEntityManager * pMgr); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CPathCorner(); //! получает координаты точки на пути на расстоянии dist от начала @@ -58,29 +58,29 @@ protected: void onPostLoad(); //! Тип сглаживания - int m_type; + int m_type = PCT_SPLINE; //! Новая скорость поезда - float m_fNewSpeed; + float m_fNewSpeed = 0.0f; //! Длина сегмента пути - float m_fLength; + float m_fLength = 0.0f; //! Для расчета сплайна @{ - float3_t m_fH; + float3_t m_fH = 0.0f; - float3_t m_fCoeffsA; - float3_t m_fCoeffsB; - float3_t m_fCoeffsC; - float3_t m_fCoeffsD; + float3_t m_fCoeffsA = 0.0f; + float3_t m_fCoeffsB = 0.0f; + float3_t m_fCoeffsC = 0.0f; + float3_t m_fCoeffsD = 0.0f; - float3_t m_fDelta; - float3_t m_fLambda; + float3_t m_fDelta = 0.0f; + float3_t m_fLambda = 0.0f; //! @} //! Следующая точка - CPathCorner * m_pNextStop; + CPathCorner *m_pNextStop = NULL; //! Предыдущая точка - CPathCorner * m_pPrevStop; + CPathCorner *m_pPrevStop = NULL; }; #endif diff --git a/source/game/Player.cpp b/source/game/Player.cpp index ea356e0841ba38ef74824cd6ccfdb20723f9ce8c..906a42e6f14bcb0a1f14778bf7da3878ff727172 100644 --- a/source/game/Player.cpp +++ b/source/game/Player.cpp @@ -7,7 +7,6 @@ See the license in LICENSE #include <input/sxinput.h> #include "Player.h" #include "LightDirectional.h" -#include "BaseTool.h" #include "BaseAmmo.h" #include "BaseWeapon.h" @@ -29,17 +28,11 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CPlayer, player); -CPlayer::CPlayer(CEntityManager * pMgr): - BaseClass(pMgr), - m_canJump(true), - m_fViewbobStep(0.0f), - m_fViewbobY(0.0f), - m_fViewbobStrafe(float3_t(0, 0, 0)), - m_vWpnShakeAngles(float3_t(0.0f, 0.0f, 0.0f)), - m_iDSM(DSM_NONE), - m_bCanRespawn(false) +void CPlayer::onPostLoad() { - m_pCamera = (CPointCamera*)CREATE_ENTITY("point_camera", pMgr); + BaseClass::onPostLoad(); + + m_pCamera = (CPointCamera*)CREATE_ENTITY("point_camera", m_pMgr); m_pCamera->setPos(m_pHeadEnt->getPos()); m_pCamera->setParent(m_pHeadEnt); diff --git a/source/game/Player.h b/source/game/Player.h index 22087408352d2eed90be18da590c10a9e7967650..de742773b12fb8fef834494cf612f5c014f51805 100644 --- a/source/game/Player.h +++ b/source/game/Player.h @@ -19,6 +19,7 @@ See the license in LICENSE #include "BaseCharacter.h" #include "PointCamera.h" #include "crosshair.h" +#include "BaseTool.h" //! Класс игрока \ingroup cbaseanimating class CPlayer: public CBaseCharacter @@ -26,7 +27,7 @@ class CPlayer: public CBaseCharacter DECLARE_CLASS(CPlayer, CBaseCharacter); DECLARE_PROPTABLE(); public: - CPlayer(CEntityManager * pMgr); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CPlayer(); //! Возвращает камеру игрока @@ -84,24 +85,26 @@ protected: ID m_iUpdIval; //! Может ли прыгать - bool m_canJump; + bool m_canJump = true; //! Для качания камеры @{ - float m_fViewbobStep; - float m_fViewbobY; - float3_t m_fViewbobStrafe; - float3_t m_vWpnShakeAngles; + float m_fViewbobStep = 0.0f; + float m_fViewbobY = 0.0f; + float3_t m_fViewbobStrafe = float3_t(0.0f, 0.0f, 0.0f); + float3_t m_vWpnShakeAngles = float3_t(0.0f, 0.0f, 0.0f); //! @} - int m_iDSM; + int m_iDSM = DSM_NONE; //! Перекрестие - CCrosshair * m_pCrosshair; + CCrosshair *m_pCrosshair = NULL; //! Обновляет разброса значение virtual void updateSpread(float dt); - bool m_bCanRespawn; + void onPostLoad() override; + + bool m_bCanRespawn = false; }; #endif diff --git a/source/game/PointCamera.cpp b/source/game/PointCamera.cpp index 77bfcee3e82b15f143fe861596978305702eab2c..ce22847275abdbc967f4d45d6eb5bc01f6c4443a 100644 --- a/source/game/PointCamera.cpp +++ b/source/game/PointCamera.cpp @@ -16,8 +16,7 @@ END_PROPTABLE() REGISTER_ENTITY(CPointCamera, point_camera); -CPointCamera::CPointCamera(CEntityManager * pMgr): - BaseClass(pMgr) +CPointCamera::CPointCamera() { const float * r_default_fov = GET_PCVAR_FLOAT("r_default_fov"); m_pSXC = SGCore_CrCamera(); diff --git a/source/game/PointCamera.h b/source/game/PointCamera.h index ed21f4fb31be8cf9964d554c2bbdc8728f41ffd3..93472ef70de4c951e7aa435ecfc40b9765b235f4 100644 --- a/source/game/PointCamera.h +++ b/source/game/PointCamera.h @@ -26,7 +26,7 @@ class CPointCamera: public CPointEntity DECLARE_CLASS(CPointCamera, CPointEntity); DECLARE_PROPTABLE(); public: - CPointCamera(CEntityManager * pMgr); + DECLARE_CONSTRUCTOR(); ~CPointCamera(); //! Возвращает объект камеры из графической либы diff --git a/source/game/PropButton.cpp b/source/game/PropButton.cpp index aecf975d4177815cb4b49ae0449e97be356c8484..730847d5e9f311569bdef273e48608ecca405186 100644 --- a/source/game/PropButton.cpp +++ b/source/game/PropButton.cpp @@ -45,14 +45,6 @@ END_PROPTABLE() REGISTER_ENTITY(CPropButton, prop_button); -CPropButton::CPropButton(CEntityManager * pMgr): - BaseClass(pMgr) -{ - m_isEnabled = true; - m_isToggleable = false; - m_bState = false; -} - void CPropButton::turnOn(inputdata_t * pInputdata) { m_isEnabled = true; diff --git a/source/game/PropButton.h b/source/game/PropButton.h index 3a4315000269056a647d82dc6d95a3f4e081b815..887d7b6d507869d52eaa5257b52434f7daecfef2 100644 --- a/source/game/PropButton.h +++ b/source/game/PropButton.h @@ -1,12 +1,12 @@ /*********************************************************** -Copyright � Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018 +Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018 See the license in LICENSE ***********************************************************/ /*! \file -������ +Кнопка */ #ifndef __PROP_BUTTON_H @@ -18,7 +18,7 @@ See the license in LICENSE #define BUTTON_TOGGLEABLE ENT_FLAG_1 #define BUTTON_START_PRESSED ENT_FLAG_2 -/*! ������ +/*! Кнопка \ingroup cbaseanimating */ class CPropButton: public CPropDynamic @@ -26,19 +26,19 @@ class CPropButton: public CPropDynamic DECLARE_CLASS(CPropButton, CPropDynamic); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); void onUse(CBaseEntity *pUser); protected: - void turnOn(inputdata_t * pInputdata); - void turnOff(inputdata_t * pInputdata); - void press(inputdata_t * pInputdata); - void pushUp(inputdata_t * pInputdata); - void pushDown(inputdata_t * pInputdata); - void toggle(inputdata_t * pInputdata); + void turnOn(inputdata_t *pInputdata); + void turnOff(inputdata_t *pInputdata); + void press(inputdata_t *pInputdata); + void pushUp(inputdata_t *pInputdata); + void pushDown(inputdata_t *pInputdata); + void toggle(inputdata_t *pInputdata); - void onPostLoad(); + void onPostLoad() override; output_t m_onPressed; output_t m_onPushUp; @@ -46,10 +46,10 @@ protected: output_t m_onToggle; output_t m_onUseDisabled; - bool m_isEnabled; - bool m_isToggleable; + bool m_isEnabled = true; + bool m_isToggleable = false; - bool m_bState; + bool m_bState = false; }; #endif diff --git a/source/game/PropDebris.cpp b/source/game/PropDebris.cpp index 210fe2329e802889b5f049e292bc881e769b8cdf..79522eb08d7172d6ba99256b5c7771d1b993b09a 100644 --- a/source/game/PropDebris.cpp +++ b/source/game/PropDebris.cpp @@ -15,7 +15,7 @@ END_PROPTABLE() REGISTER_ENTITY(CPropDebris, prop_debris); -CPropDebris::CPropDebris(CEntityManager *pMgr):BaseClass(pMgr) +CPropDebris::CPropDebris() { setCollisionGroup(CG_DEBRIS); } diff --git a/source/game/PropDoor.cpp b/source/game/PropDoor.cpp index e07700ea403f76af505764f7b86fcbc5b183e91a..ca0fdaedef0d30077146438fde09b08c03647255 100644 --- a/source/game/PropDoor.cpp +++ b/source/game/PropDoor.cpp @@ -68,10 +68,6 @@ END_PROPTABLE() REGISTER_ENTITY(CPropDoor, prop_door); -CPropDoor::CPropDoor(CEntityManager *pMgr):BaseClass(pMgr) -{ -} - CPropDoor::~CPropDoor() { releasePhysics(); diff --git a/source/game/PropDoor.h b/source/game/PropDoor.h index 28ce7e953bf7d8f2cd99a1d082bb357504267a29..c239e8c0c76625ee089b2fe41d8062eac252d54e 100644 --- a/source/game/PropDoor.h +++ b/source/game/PropDoor.h @@ -33,9 +33,10 @@ class CPropDoor: public CPropDynamic DECLARE_CLASS(CPropDoor, CPropDynamic); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CPropDoor(); - virtual void onPostLoad(); + + void onPostLoad() override; void onUse(CBaseEntity *pUser); diff --git a/source/game/PropStatic.cpp b/source/game/PropStatic.cpp index 75ca87b30bea5099135ebcd984ba449030f7ab8f..738cce327827bc2db0e23d1ba67e2344900a1b4b 100644 --- a/source/game/PropStatic.cpp +++ b/source/game/PropStatic.cpp @@ -20,8 +20,7 @@ END_PROPTABLE() REGISTER_ENTITY_NOSYNC(CPropStatic, prop_static); -CPropStatic::CPropStatic(CEntityManager *pMgr): - BaseClass(pMgr) +CPropStatic::CPropStatic() { m_isStatic = true; } diff --git a/source/game/SoundEmitter.cpp b/source/game/SoundEmitter.cpp index 1ec6f3fc69b606de4e44cbb9f908e7751667da91..8998dab380726f869356323c5f081e710f5e3fe3 100644 --- a/source/game/SoundEmitter.cpp +++ b/source/game/SoundEmitter.cpp @@ -39,12 +39,6 @@ REGISTER_ENTITY(CSoundEmitter, sound_emitter); //########################################################################## -CSoundEmitter::CSoundEmitter(CEntityManager *pMgr): - BaseClass(pMgr) -{ - -} - CSoundEmitter::~CSoundEmitter() { mem_release(m_pEmitter); diff --git a/source/game/SoundEmitter.h b/source/game/SoundEmitter.h index c96e49165363380f2099147ec0dca2cd3ae886a5..43f840cbecc554639c82041654859d8e8c1f8e3b 100644 --- a/source/game/SoundEmitter.h +++ b/source/game/SoundEmitter.h @@ -29,7 +29,7 @@ class CSoundEmitter: public CPointEntity DECLARE_CLASS(CSoundEmitter, CPointEntity); DECLARE_PROPTABLE(); public: - CSoundEmitter(CEntityManager * pMgr); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CSoundEmitter(); virtual void setSound(const char *szSound); diff --git a/source/game/SoundPlayer.cpp b/source/game/SoundPlayer.cpp index 50c83755b885332c5259b59ddff73259c8f434b0..a60b0f898c0ce2ab23a57668201fdfea92a2f0e0 100644 --- a/source/game/SoundPlayer.cpp +++ b/source/game/SoundPlayer.cpp @@ -51,12 +51,6 @@ REGISTER_ENTITY(CSoundPlayer, sound_player); //########################################################################## -CSoundPlayer::CSoundPlayer(CEntityManager *pMgr): - BaseClass(pMgr) -{ - -} - CSoundPlayer::~CSoundPlayer() { mem_release(m_pPlayer); diff --git a/source/game/SoundPlayer.h b/source/game/SoundPlayer.h index 550095ee1675c17c6ad7a71c699c8ec729cb51c8..fc0c1748f932c87a47c947f2714f98349dd3145e 100644 --- a/source/game/SoundPlayer.h +++ b/source/game/SoundPlayer.h @@ -31,7 +31,7 @@ class CSoundPlayer: public CPointEntity DECLARE_CLASS(CSoundPlayer, CPointEntity); DECLARE_PROPTABLE(); public: - CSoundPlayer(CEntityManager * pMgr); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CSoundPlayer(); virtual void setSound(const char *szSound); diff --git a/source/game/TriggerHurt.cpp b/source/game/TriggerHurt.cpp index c4ef6d9d4f85c823ad73b58c53782124495289ff..46ae2421b9f010dba07baf7a366881dc28378604 100644 --- a/source/game/TriggerHurt.cpp +++ b/source/game/TriggerHurt.cpp @@ -21,12 +21,6 @@ END_PROPTABLE() REGISTER_ENTITY(CTriggerHurt, trigger_hurt); -CTriggerHurt::CTriggerHurt(CEntityManager * pMgr): - BaseClass(pMgr) -{ - //m_idHurtInterval = SET_INTERVAL(think, 1000.0f); -} - CTriggerHurt::~CTriggerHurt() { CLEAR_INTERVAL(m_idHurtInterval); diff --git a/source/game/TriggerHurt.h b/source/game/TriggerHurt.h index 435e5317d3a7e405d4b76ffa83d2965098c147f3..7260a990f16dbaa88171aa2699249181979a00c0 100644 --- a/source/game/TriggerHurt.h +++ b/source/game/TriggerHurt.h @@ -25,7 +25,7 @@ class CTriggerHurt: public CBaseTrigger DECLARE_CLASS(CTriggerHurt, CBaseTrigger); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); ~CTriggerHurt(); protected: diff --git a/source/game/TriggerItemUse.cpp b/source/game/TriggerItemUse.cpp index d5d3e786e9a9d2d58d303bcc1eb6f83794727ee4..57c19756a505d1611032537575972d456ffc440e 100644 --- a/source/game/TriggerItemUse.cpp +++ b/source/game/TriggerItemUse.cpp @@ -17,12 +17,6 @@ END_PROPTABLE() REGISTER_ENTITY_NOLISTING(CTriggerItemUse, trigger_itemuse); -CTriggerItemUse::CTriggerItemUse(CEntityManager * pMgr): - BaseClass(pMgr) -{ - //m_idHurtInterval = SET_INTERVAL(think, 1000.0f); -} - void CTriggerItemUse::setItem(CBaseItem *pItem) { m_pItem = pItem; diff --git a/source/game/TriggerItemUse.h b/source/game/TriggerItemUse.h index f116da065ea49810a835818440a95a51b768d019..141feb0f404df5718fcc00978fb0eadf2c1b805c 100644 --- a/source/game/TriggerItemUse.h +++ b/source/game/TriggerItemUse.h @@ -26,7 +26,7 @@ class CTriggerItemUse: public CBaseTrigger DECLARE_CLASS(CTriggerItemUse, CBaseTrigger); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); + DECLARE_TRIVIAL_CONSTRUCTOR(); void setItem(CBaseItem *pItem); diff --git a/source/game/TriggerTeleport.cpp b/source/game/TriggerTeleport.cpp index 6f68091226d8cebaf842d441399c838e8bc5ee1f..15ce00a12360a549bc8d64926d6c540cbdd32195 100644 --- a/source/game/TriggerTeleport.cpp +++ b/source/game/TriggerTeleport.cpp @@ -21,17 +21,6 @@ END_PROPTABLE() REGISTER_ENTITY(CTriggerTeleport, trigger_teleport); -CTriggerTeleport::CTriggerTeleport(CEntityManager * pMgr): - BaseClass(pMgr) -{ - //m_idHurtInterval = SET_INTERVAL(think, 1000.0f); -} - -CTriggerTeleport::~CTriggerTeleport() -{ - //CLEAR_INTERVAL(m_idHurtInterval); -} - void CTriggerTeleport::onTouchStart(CBaseEntity *pActivator) { if(!m_pDestination) diff --git a/source/game/TriggerTeleport.h b/source/game/TriggerTeleport.h index 0f8eb54adb9cd1af2b591fba6422bf2b15298c57..721011d6654895ddca79351af5c59eacb673f8c0 100644 --- a/source/game/TriggerTeleport.h +++ b/source/game/TriggerTeleport.h @@ -25,8 +25,7 @@ class CTriggerTeleport: public CBaseTrigger DECLARE_CLASS(CTriggerTeleport, CBaseTrigger); DECLARE_PROPTABLE(); public: - DECLARE_CONSTRUCTOR(); - ~CTriggerTeleport(); + DECLARE_TRIVIAL_CONSTRUCTOR(); protected: virtual void onTouchStart(CBaseEntity *pActivator) override; diff --git a/source/game/proptable.h b/source/game/proptable.h index 9f00d7aed5e1886ebca34aa9e90ac89b72183d38..8c2272019d37e05e7d3d0752dbbb47f021928db4 100644 --- a/source/game/proptable.h +++ b/source/game/proptable.h @@ -396,8 +396,8 @@ void cls::InitPropData() \ } \ } -#define DECLARE_TRIVIAL_CONSTRUCTOR() ThisClass(CEntityManager * pMgr):BaseClass(pMgr){} -#define DECLARE_CONSTRUCTOR() ThisClass(CEntityManager * pMgr); +#define DECLARE_TRIVIAL_CONSTRUCTOR() ThisClass():BaseClass(){} +#define DECLARE_CONSTRUCTOR() ThisClass(); const char * GetEmptyString(); diff --git a/source/game/sxgame.h b/source/game/sxgame.h index be0f9185628f89202bf592efd6c12ed52a6ef56d..39ac95bfbee0e59b842a02175079659fb85f726c 100644 --- a/source/game/sxgame.h +++ b/source/game/sxgame.h @@ -246,13 +246,11 @@ SX_LIB_API CBaseEntity *SGame_EntGetByName(const char *szName, ID idStart = 0); SX_LIB_API BOOL SGame_AddWMsg(UINT message, WPARAM wParam, LPARAM lParam); -/*! Копирует объект, возвращает ID копии -*/ -SX_LIB_API ID SGame_EntClone(ID idSrc); - +#if 0 /*! Находит объект по пересечению с лучем, в режиме редактора так же находит точечные объекты, в режиме игры - нет */ SX_LIB_API ID SGame_EntGetByRay(const float3 &vStart, const float3 &vDir, float3 *pHitPos = NULL); +#endif #endif diff --git a/source/game/sxgame_dll.cpp b/source/game/sxgame_dll.cpp index d1dd32483d28feeefe53938e587605c9da990661..8a023f1aa2b5ef80987d715fbe42f2f6a8ca342b 100644 --- a/source/game/sxgame_dll.cpp +++ b/source/game/sxgame_dll.cpp @@ -379,19 +379,7 @@ SX_LIB_API BOOL SGame_AddWMsg(UINT message, WPARAM wParam, LPARAM lParam) return(GameData::m_pGUIStack->putMessage(message, wParam, lParam)); } -SX_LIB_API ID SGame_EntClone(ID idSrc) -{ - SG_PRECOND(-1); - CBaseEntity *pEnt = GameData::m_pMgr->cloneEntity(GameData::m_pMgr->getById(idSrc)); - - if(!pEnt) - { - return(-1); - } - - return(pEnt->getId()); -} - +#if 0 SX_LIB_API ID SGame_EntGetByRay(const float3 &vStart, const float3 &vDir, float3 *pHitPos) { SG_PRECOND(-1); @@ -416,3 +404,4 @@ SX_LIB_API ID SGame_EntGetByRay(const float3 &vStart, const float3 &vDir, float3 } return(-1); } +#endif