[#12658] 修复基于 costTypes 大小的 cluster 数组维度
变更摘要
修复了集群初始化时数组维度不正确的问题。将集群数组第一维度的长度从
Team.all.length更改为costTypes.size,以确保其与成本类型的数量匹配。
状态 Open · 目标 master ← master
文件 1 · 代码变化 +1 / -1
类型 缺陷修复
主要变更
- 将集群数组第一维度的初始化大小从
Team.all.length修改为costTypes.size
影响范围
- AI 路径查找
可能影响
- 修复潜在的数组索引越界问题
- 确保内存分配与成本类型数量正确匹配
以上影响分析根据 PR 描述及代码修改推断,不代表维护者正式结论。
重点文件
core/src/mindustry/ai/ControlPathfinder.java
修改 · +1 / -1
- 在
updateCluster方法中,将集群数组第一维度的初始化大小从Team.all.length修改为costTypes.size。
作者说明
描述
修复了集群初始化中不正确的数组维度。
该数组之前使用 Team.all.length 进行初始化,但第一维度应与成本类型的数量匹配。
更改
修改了:
dim1 = clusters[team] = new Cluster[Team.all.length][];
为:
dim1 = clusters[team] = new Cluster[costTypes.size][];
这确保了集群数组以正确数量的成本类型进行初始化。 这是一个最小化的修复,没有其他更改。
GitHub 原文
Description
Fix an incorrect array dimension in the cluster initialization.
The array was previously initialized using Team.all.length, but the first dimension should match the number of cost types.
Changes
Changed:
dim1 = clusters[team] = new Cluster[Team.all.length][];
To:
dim1 = clusters[team] = new Cluster[costTypes.size][];
This ensures the cluster array is initialized with the correct number of cost types. This is a minimal fix with no other changes.
由 MDT GitHub 同步机器人自动同步。中文翻译、摘要及代码影响分析由 AI 生成,仅供参考。