From 1f786418a74af73dc87846e355579cd73123f4ac Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 23 May 2014 19:13:36 +0200 Subject: [PATCH] Crash safely with an error when sphrase is missing on client --- .../client/src/interface_v3/sphrase_manager.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp index 3d6155d23..7ef59dc1c 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -4504,17 +4504,19 @@ sint32 CSPhraseManager::getSheetFromPhrase(const CSPhraseCom &phrase) const uint32 CSPhraseManager::getTotalActionMalus(const CSPhraseCom &phrase) const { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CSBrickManager *pBM= CSBrickManager::getInstance(); - uint32 totalActionMalus= 0; + CSBrickManager *pBM = CSBrickManager::getInstance(); + uint32 totalActionMalus = 0; CCDBNodeLeaf *actMalus = _TotalMalusEquipLeaf ? &*_TotalMalusEquipLeaf : &*(_TotalMalusEquipLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false)); // root brick must not be Power or aura, because Action malus don't apply to them // (ie leave 0 ActionMalus for Aura or Powers if (!phrase.Bricks.empty()) { - CSBrickSheet *rootBrick= pBM->getBrick(phrase.Bricks[0]); - if(actMalus && !rootBrick->isSpecialPower()) - totalActionMalus= actMalus->getValue32(); + CSBrickSheet *rootBrick = pBM->getBrick(phrase.Bricks[0]); + if (!rootBrick) + nlerror("Invalid root sbrick in sphrase_com '%s'", phrase.Name.toUtf8().c_str()); + else if (actMalus && !rootBrick->isSpecialPower()) + totalActionMalus = actMalus->getValue32(); } return totalActionMalus; }