浏览代码

fix regression of #6255

Laserlicht 1 月之前
父节点
当前提交
ea001c6973
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      client/windows/GUIClasses.cpp

+ 6 - 3
client/windows/GUIClasses.cpp

@@ -1678,9 +1678,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 && posBrace < posClosing)
+		{
+			std::string objCount = text.substr(posBrace, posClosing - posBrace) + ')';
+			suffix += " ";
+			suffix += objCount;
+		}
 	}
 
 	const auto & font = ENGINE->renderHandler().loadFont(FONT_SMALL);