소스 검색

Merge pull request #3452 from IvanSavenko/glibc_assertions

Enable & fix glibc assertions
Ivan Savenko 1 년 전
부모
커밋
6641418218
3개의 변경된 파일16개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 0
      Global.h
  2. 1 0
      client/windows/CCreatureWindow.cpp
  3. 9 1
      lib/CHeroHandler.cpp

+ 6 - 0
Global.h

@@ -100,6 +100,12 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 
 #define _USE_MATH_DEFINES
 
+#ifndef NDEBUG
+// Enable additional debug checks from glibc / libstdc++ when building with enabled assertions
+// Since these defines must be declared BEFORE including glibc header we can not check for __GLIBCXX__ macro to detect that glibc is in use
+#  define _GLIBCXX_ASSERTIONS
+#endif
+
 #include <algorithm>
 #include <any>
 #include <array>

+ 1 - 0
client/windows/CCreatureWindow.cpp

@@ -666,6 +666,7 @@ CStackWindow::CStackWindow(const CStack * stack, bool popup)
 {
 	info->stack = stack;
 	info->stackNode = stack->base;
+	info->commander = dynamic_cast<const CCommanderInstance*>(stack->base);
 	info->creature = stack->unitType();
 	info->creatureCount = stack->getCount();
 	info->popupWindow = popup;

+ 9 - 1
lib/CHeroHandler.cpp

@@ -257,7 +257,15 @@ CHeroClass * CHeroClassHandler::loadFromJson(const std::string & scope, const Js
 
 	VLC->generaltexth->registerString(scope, heroClass->getNameTextID(), node["name"].String());
 
-	heroClass->affinity = vstd::find_pos(affinityStr, node["affinity"].String());
+	if (vstd::contains(affinityStr, node["affinity"].String()))
+	{
+		heroClass->affinity = vstd::find_pos(affinityStr, node["affinity"].String());
+	}
+	else
+	{
+		logGlobal->error("Mod '%s', hero class '%s': invalid affinity '%s'! Expected 'might' or 'magic'!", scope, identifier, node["affinity"].String());
+		heroClass->affinity = CHeroClass::MIGHT;
+	}
 
 	fillPrimarySkillData(node, heroClass, PrimarySkill::ATTACK);
 	fillPrimarySkillData(node, heroClass, PrimarySkill::DEFENSE);