瀏覽代碼

getAllowedSpells fixed. Shrines will use it from now on.

DjWarmonger 16 年之前
父節點
當前提交
0937653e0a
共有 2 個文件被更改,包括 7 次插入13 次删除
  1. 2 11
      hch/CObjectHandler.cpp
  2. 5 2
      lib/IGameCallback.cpp

+ 2 - 11
hch/CObjectHandler.cpp

@@ -3584,17 +3584,8 @@ void CGShrine::initObj()
 	if(spell == 255) //spell not set
 	if(spell == 255) //spell not set
 	{
 	{
 		int level = ID-87;
 		int level = ID-87;
-		std::vector<ui32> possibilities;
-
-		//add all allowed spells of wanted level
-		for(int i=0; i<SPELLS_QUANTITY; i++)
-		{
-			if(VLC->spellh->spells[i].level == level
-				&& cb->isAllowed(0,VLC->spellh->spells[i].id))
-			{
-				possibilities.push_back(VLC->spellh->spells[i].id);
-			}
-		}
+		std::vector<ui16> possibilities;
+		cb->getAllowedSpells (possibilities, level);
 
 
 		if(!possibilities.size())
 		if(!possibilities.size())
 		{
 		{

+ 5 - 2
lib/IGameCallback.cpp

@@ -193,9 +193,12 @@ void IGameCallback::getAllowed(std::vector<CArtifact*> &out, int flags)
 
 
 void IGameCallback::getAllowedSpells(std::vector<ui16> &out, ui16 level)
 void IGameCallback::getAllowedSpells(std::vector<ui16> &out, ui16 level)
 {
 {
-	for (int i = 0; i < (VLC->spellh->spells).size(); i++)
+
+	CSpell *spell;
+	for (int i = 0; i < gs->map->allowedSpell.size(); i++) //spellh size appears to be greater (?)
 	{
 	{
-		if (isAllowed (1, i))
+		spell = &(VLC->spellh->spells[i]);
+		if (isAllowed (0, spell->id) && spell->level == level)
 		{
 		{
 			out.push_back(i);
 			out.push_back(i);
 		}
 		}