瀏覽代碼

- Fixed crash on creature window drawn for neutral faction
- Fixed sound parsing. Check forum for updated mod.

It is now possible to attack & fight new creatures without crash.

DjWarmonger 13 年之前
父節點
當前提交
16adfa3aa7
共有 2 個文件被更改,包括 8 次插入4 次删除
  1. 7 3
      client/GUIClasses.cpp
  2. 1 1
      lib/CModHandler.cpp

+ 7 - 3
client/GUIClasses.cpp

@@ -1251,11 +1251,15 @@ CCreaturePic::CCreaturePic(int x, int y, const CCreature *cre, bool Big, bool An
 	pos.x+=x;
 	pos.y+=y;
 
-	assert(vstd::contains(CGI->townh->factions, cre->faction));
+	si8 faction = 0;//FIXME: support neutral faction
+	if (vstd::contains(CGI->townh->factions, cre->faction))
+	{
+		faction = cre->faction;
+	}
 	if(Big)
-		bg = new CPicture(CGI->townh->factions[cre->faction].creatureBg130);
+		bg = new CPicture(CGI->townh->factions[faction].creatureBg130);
 	else
-		bg = new CPicture(CGI->townh->factions[cre->faction].creatureBg120);
+		bg = new CPicture(CGI->townh->factions[faction].creatureBg120);
 	bg->needRefresh = true;
 	anim = new CCreatureAnim(0, 0, cre->animDefName, Rect());
 	anim->clipRect(cre->isDoubleWide()?170:150, 155, bg->pos.w, bg->pos.h);

+ 1 - 1
lib/CModHandler.cpp

@@ -241,7 +241,7 @@ CCreature * CModHandler::loadCreature (const JsonNode &node)
 
 	const JsonNode & sounds = node["sound"];
 
-#define GET_SOUND_VALUE(value_name) do { value = &node[#value_name]; if (!value->isNull()) cre->sounds.value_name = sounds[#value_name].String(); } while(0)
+#define GET_SOUND_VALUE(value_name) do { value = &sounds[#value_name]; if (!value->isNull()) cre->sounds.value_name = value->String(); } while(0)
 	GET_SOUND_VALUE(attack);
 	GET_SOUND_VALUE(defend);
 	GET_SOUND_VALUE(killed);