Browse Source

Merge pull request #4753 from IvanSavenko/misc_fixes

Fixes for regressions from recent PR's
Ivan Savenko 1 year ago
parent
commit
e0e01d678a
3 changed files with 35 additions and 28 deletions
  1. 8 2
      client/PlayerLocalState.cpp
  2. 26 26
      launcher/settingsView/csettingsview_moc.ui
  3. 1 0
      lib/json/JsonUtils.cpp

+ 8 - 2
client/PlayerLocalState.cpp

@@ -219,7 +219,12 @@ void PlayerLocalState::removeWanderingHero(const CGHeroInstance * hero)
 	if (hero == currentSelection)
 	{
 		auto const * nextHero = getNextWanderingHero(hero);
-		setSelection(nextHero);
+		if (nextHero)
+			setSelection(nextHero);
+		else if (!ownedTowns.empty())
+			setSelection(ownedTowns.front());
+		else
+			setSelection(nullptr);
 	}
 
 	vstd::erase(wanderingHeroes, hero);
@@ -334,7 +339,8 @@ void PlayerLocalState::serialize(JsonNode & dest) const
 	dest["spellbook"]["tabBattle"].Integer() = spellbookSettings.spellbookLastTabBattle;
 	dest["spellbook"]["tabAdvmap"].Integer() = spellbookSettings.spellbookLastTabAdvmap;
 
-	dest["currentSelection"].Integer() = currentSelection->id;
+	if (currentSelection)
+		dest["currentSelection"].Integer() = currentSelection->id;
 }
 
 void PlayerLocalState::deserialize(const JsonNode & source)

+ 26 - 26
launcher/settingsView/csettingsview_moc.ui

@@ -47,7 +47,7 @@
       <property name="geometry">
        <rect>
         <x>0</x>
-        <y>-126</y>
+        <y>-797</y>
         <width>729</width>
         <height>1503</height>
        </rect>
@@ -261,31 +261,6 @@
          </property>
         </widget>
        </item>
-       <item row="60" column="4">
-        <widget class="QToolButton" name="buttonValidationBasic">
-         <property name="enabled">
-          <bool>true</bool>
-         </property>
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="text">
-          <string>Basic</string>
-         </property>
-         <property name="checkable">
-          <bool>true</bool>
-         </property>
-         <property name="checked">
-          <bool>false</bool>
-         </property>
-         <attribute name="buttonGroup">
-          <string notr="true">buttonGroupValidation</string>
-         </attribute>
-        </widget>
-       </item>
        <item row="31" column="0">
         <widget class="QLabel" name="labelSoundVolume">
          <property name="text">
@@ -1449,6 +1424,31 @@ Fullscreen Exclusive Mode - game will cover entirety of your screen and will use
        <item row="12" column="1" colspan="5">
         <widget class="QComboBox" name="comboBoxResolution"/>
        </item>
+       <item row="60" column="3" colspan="2">
+        <widget class="QToolButton" name="buttonValidationBasic">
+         <property name="enabled">
+          <bool>true</bool>
+         </property>
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Basic</string>
+         </property>
+         <property name="checkable">
+          <bool>true</bool>
+         </property>
+         <property name="checked">
+          <bool>false</bool>
+         </property>
+         <attribute name="buttonGroup">
+          <string notr="true">buttonGroupValidation</string>
+         </attribute>
+        </widget>
+       </item>
       </layout>
      </widget>
     </widget>

+ 1 - 0
lib/json/JsonUtils.cpp

@@ -241,6 +241,7 @@ JsonNode JsonUtils::assembleFromFiles(const JsonNode & files, bool & isValid)
 	}
 	else
 	{
+		isValid = true;
 		return files;
 	}
 }