Browse Source

Merge pull request #6272 from mrhaandi/fix-list-scaling

Fix preserveCountSuffix if no parentheses are present
Ivan Savenko 1 day ago
parent
commit
c7a1558c81
1 changed files with 6 additions and 3 deletions
  1. 6 3
      client/windows/GUIClasses.cpp

+ 6 - 3
client/windows/GUIClasses.cpp

@@ -1676,9 +1676,12 @@ void CObjectListWindow::trimTextIfTooWide(std::string & text, bool preserveCount
 	{
 		auto posBrace = text.find_last_of("(");
 		auto posClosing = text.find_last_of(")");
-		std::string objCount = text.substr(posBrace, posClosing - posBrace) + ')';
-		suffix += " ";
-		suffix += objCount;
+		if (posBrace != std::string::npos && posClosing != std::string::npos && posClosing > posBrace)
+		{
+			std::string objCount = text.substr(posBrace, posClosing - posBrace) + ')';
+			suffix += " ";
+			suffix += objCount;
+		}
 	}
 
 	const auto & font = ENGINE->renderHandler().loadFont(FONT_SMALL);