From 069a0cc7bdcc855c34cf145c96b7d9b5f1a76156 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 23 Sep 2014 13:54:02 +0200 Subject: [PATCH] Fix EGS sheet rebuild crashes --- .../egs_sheets/egs_static_game_item.cpp | 90 +++++++++---------- .../egs_sheets/egs_static_game_item.h | 4 +- 2 files changed, 46 insertions(+), 48 deletions(-) diff --git a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.cpp b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.cpp index f36fe91ab..42517c190 100644 --- a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.cpp +++ b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.cpp @@ -237,24 +237,12 @@ void SItemSpecialEffects::serial(class NLMISC::IStream &f) //-------------------------------------------------------------- // init() //-------------------------------------------------------------- -void CStaticItem::init() +void CStaticItem::init(bool doDelete) { Family = ITEMFAMILY::UNDEFINED; Type = ITEM_TYPE::UNDEFINED; - Armor = NULL; - MeleeWeapon = NULL; - RangeWeapon = NULL; - Ammo = NULL; - Shield = NULL; - TamingTool = NULL; - Mp = NULL; - GuildOption = NULL; - Cosmetics = NULL; - ItemServiceData = NULL; - ConsumableItem = NULL; - XpCatalyser = NULL; - CommandTicket = NULL; + clearPtrs(doDelete); Skill = SKILLS::unknown; MinSkill = 0; @@ -287,16 +275,54 @@ void CStaticItem::init() RequiredCharacQualityFactor = 0.0f; RequiredCharacQualityOffset = 0; - ItemSpecialEffects = NULL; } // init // +// *************************************************************************** +void CStaticItem::clearPtrs(bool doDelete) +{ + if (doDelete) + { + delete Armor; + delete MeleeWeapon; + delete RangeWeapon; + delete Ammo; + delete Shield; + delete TamingTool; + delete Mp; + delete GuildOption; + delete Cosmetics; + delete ItemServiceData; + delete ConsumableItem; + delete XpCatalyser; + delete CommandTicket; + delete ItemSpecialEffects; + } + + Armor = NULL; + MeleeWeapon = NULL; + RangeWeapon = NULL; + Ammo = NULL; + Shield = NULL; + TamingTool = NULL; + Mp = NULL; + GuildOption = NULL; + Cosmetics = NULL; + ItemServiceData = NULL; + ConsumableItem = NULL; + XpCatalyser = NULL; + CommandTicket = NULL; + ItemSpecialEffects = NULL; +} + //-------------------------------------------------------------- // copy constructor //-------------------------------------------------------------- CStaticItem::CStaticItem( const CStaticItem& itm ) { + clearPtrs(false); + *this = itm; if(itm.Armor) { @@ -1443,6 +1469,9 @@ void CStaticItem::readGeorges (const NLMISC::CSmartPtr &form, if (form == NULL) return; + // Clear pointers to previous data + clearPtrs(true); + // Get the root node, always exist UFormElm &root = form->getRootNode (); @@ -1993,37 +2022,6 @@ float CStaticItem::getBaseWeight() const } #endif -// *************************************************************************** -void CStaticItem::clearPtrs(bool doDelete) -{ - if(doDelete) - { - if (Ammo != NULL ) delete Ammo; - if (Armor != NULL ) delete Armor; - if (MeleeWeapon != NULL ) delete MeleeWeapon; - if (RangeWeapon != NULL ) delete RangeWeapon; - if (Cosmetics != NULL ) delete Cosmetics; - if (Mp != NULL ) delete Mp; - if (GuildOption != NULL ) delete GuildOption; - if (Shield != NULL ) delete Shield; - if (TamingTool != NULL) delete TamingTool; - if (ItemServiceData != NULL) delete ItemServiceData; - if (CommandTicket != NULL) delete CommandTicket; - } - - Ammo = NULL; - Armor = NULL; - MeleeWeapon = NULL; - RangeWeapon = NULL; - Cosmetics = NULL; - Mp = NULL; - GuildOption = NULL; - Shield = NULL; - TamingTool = NULL; - ItemServiceData = NULL; - CommandTicket = NULL; -} - uint32 CStaticItem::getMaxStackSize() const { diff --git a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.h b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.h index ddea7be9c..96aae2e98 100644 --- a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.h +++ b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.h @@ -812,13 +812,13 @@ public: public: /// Constructor - CStaticItem() { init(); } + CStaticItem() { init(false); } /// copy constructor CStaticItem( const CStaticItem& itm ); /// init method - void init(); + void init(bool doDelete = true); /// destructor virtual ~CStaticItem();