From db386915d14917a072d9a683bbd84e1bc3a7a186 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Fri, 13 May 2011 14:33:48 +0000 Subject: [PATCH] Spell_levels are not necessary in the end. Fixes. Game won't crash when displaying info for war machines. However, they should be handled as regular stacks during battle. --- client/CBattleInterface.cpp | 7 +++---- client/CCreatureWindow.cpp | 9 ++++++++- config/spell_levels.txt | 12 ------------ lib/CSpellHandler.cpp | 19 ------------------- 4 files changed, 11 insertions(+), 36 deletions(-) delete mode 100644 config/spell_levels.txt diff --git a/client/CBattleInterface.cpp b/client/CBattleInterface.cpp index de06c2af4..dc131b528 100644 --- a/client/CBattleInterface.cpp +++ b/client/CBattleInterface.cpp @@ -2935,9 +2935,8 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc ) else text = ""; break; - case 81: - break; //handled as hero spell - display damage default: + text = CGI->generaltexth->allTexts[565]; //The %s casts %s boost::algorithm::replace_first(text, "%s", CGI->creh->creatures[sc->attackerType]->namePl); //casting stack } if (plural) @@ -2955,7 +2954,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc ) } } if (!customSpell) - boost::algorithm::replace_first(text, "%s", CGI->spellh->spells[sc->id]->name); + boost::algorithm::replace_first(text, "%s", CGI->spellh->spells[sc->id]->name); //simple spell name if (text.size()) console->addText(text); } @@ -2968,7 +2967,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc ) } else { - boost::algorithm::replace_first(text, "%s", "Creature"); //TODO: better fix + boost::algorithm::replace_first(text, "%s", CGI->creh->creatures[sc->attackerType]->namePl); //creature caster } boost::algorithm::replace_first(text, "%s", CGI->spellh->spells[sc->id]->name); console->addText(text); diff --git a/client/CCreatureWindow.cpp b/client/CCreatureWindow.cpp index ed7053019..8bb8187c2 100644 --- a/client/CCreatureWindow.cpp +++ b/client/CCreatureWindow.cpp @@ -41,8 +41,15 @@ CCreatureWindow::CCreatureWindow (const CStack &stack, int Type) : type(Type) { OBJ_CONSTRUCTION_CAPTURING_ALL; + if (stack.base) + init(stack.base, &stack, dynamic_cast(stack.base->armyObj)); + else + { + CStackInstance * s = new CStackInstance(stack.type, 1); //TODO: war machines and summons should be regular stacks + init(s, stack.type, NULL); + delete s; + } - init(stack.base, &stack, dynamic_cast(stack.base->armyObj)); } CCreatureWindow::CCreatureWindow (const CStackInstance &stack, int Type) diff --git a/config/spell_levels.txt b/config/spell_levels.txt deleted file mode 100644 index b39caa2db..000000000 --- a/config/spell_levels.txt +++ /dev/null @@ -1,12 +0,0 @@ -70 3 -71 2 -72 255 -73 2 -74 4 -75 5 -76 255 -77 2 -78 1 -79 255 -80 255 --1 \ No newline at end of file diff --git a/lib/CSpellHandler.cpp b/lib/CSpellHandler.cpp index b57bf9dcc..d269c9484 100644 --- a/lib/CSpellHandler.cpp +++ b/lib/CSpellHandler.cpp @@ -322,24 +322,5 @@ void CSpellHandler::loadSpells() } } ast.close(); - //ast.open(DATA_DIR "/config/spell_levels.txt", std::ios::binary); - //if(!ast.is_open()) - //{ - // tlog1<<"lack of config/spell_levels.txt file!"<>spellID; - // int buf; - // while(spellID != -1) - // { - // ast >> buf; - // spells[spellID]->level = buf; - // ast>>spellID; - // } - //} - //ast.close(); spells.push_back(spells[80]); //clone Acid Breath attributes for Acid Breath damage effect }