瀏覽代碼

Add sanity check

Ivan Savenko 2 年之前
父節點
當前提交
609f25f344
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      lib/constants/EntityIdentifiers.cpp

+ 6 - 0
lib/constants/EntityIdentifiers.cpp

@@ -234,6 +234,12 @@ si32 PlayerColor::decode(const std::string & identifier)
 
 std::string PlayerColor::encode(const si32 index)
 {
+	if (index < 0 || index >= std::size(GameConstants::PLAYER_COLOR_NAMES))
+	{
+		assert(0);
+		return "invalid";
+	}
+
 	return GameConstants::PLAYER_COLOR_NAMES[index];
 }