More Vehicles 在新版报错或不生效解决方法
我的版本是1.17.1.F4 下载了很多版本的More Vehicles要么不生效,要么进游戏就报错城市已经30万人了,车辆也到上限了...咬咬牙,自己研究吧
在github下载源文件
大致看了下代码,以及对照引用的dll,代码应该是没什么问题的,逻辑很简单.
但是自己编译后进游戏不生效.
出来检查问题,发现引用的Assembly-CSharp.dll 与游戏自带的大小不一样(游戏目录下\Cities_Data\Managed) 需要自行复制进去.
再次编译,生效了.
然后进游戏就弹窗,一直弹.
进游戏目录找日志,发现报错内容
Simulation error: Array index is out of range.
at ImprovedPublicTransport2.HarmonyPatches.VehicleManagerPatches.ReleaseWaterSourcePatch.ReleaseWaterSourcePost (uint16,Vehicle&) <0x00019>
at (wrapper dynamic-method) VehicleManager.VehicleManager.ReleaseWaterSource_Patch1 (VehicleManager,uint16,Vehicle&) <0x00089>
at VehicleManager.ReleaseVehicleImplementation (uint16,Vehicle&) <0x00220>
at (wrapper dynamic-method) VehicleManager.VehicleManager.ReleaseVehicle_Patch1 (VehicleManager,uint16) <0x0005a>
at CarTrailerAI.SimulationStep (uint16,Vehicle&,UnityEngine.Vector3) <0x00041>
at (wrapper dynamic-method) VehicleManager.VehicleManager.SimulationStepImpl_Patch0 (VehicleManager,int) <0x004d9>
at SimulationManagerBase`2.SimulationStep (int) <0x0004c>
at VehicleManager.ISimulationManager.SimulationStep (int) <0x00024>
at SimulationManager.SimulationStep () <0x00693>
at SimulationManager.SimulationThread () <0x0018a>
看了下类名,是ImprovedPublicTransport2 这个mod里报的错.
关掉这个模组再进游戏,这次OK了
但不完美啊,这个改善交通的模组还是必要的.
反编译这个mod
找到报错的函数是这样的
public static void ReleaseWaterSourcePost(ushort vehicle, ref Vehicle data)
{
if (!CachedVehicleData.m_cachedVehicleData[(int)vehicle.IsEmpty)
{
CachedVehicleData.m_cachedVehicleData[(int)vehicle = default(VehicleData);
}
}
而报的错是数组超出范围.那么多半是m_cachedVehicleData 的大小不够.
找到初始化的地方,发现了这段代码
int maxVehicleCount;
if (ImprovedPublicTransport2.Util.Utils.IsModActive(1764208250UL))
{
Debug.LogWarning("IPT2: More Vehicles is enabled, applying compatibility workaround");
maxVehicleCount = 65536;
}
else
{
Debug.Log("IPT2: More Vehicles is not enabled");
maxVehicleCount = 16384;
}
原来这个模块专门针对More Vehicles 做过处理.但是加载的时候并没有发现我加载了More Vehicles . 可能是我自己编译的时候模块ID号丢失了.
ID号就不研究了,直接把16384改成65536 重新编译下,(就算不启动More Vehicles 改大数组也就是费点内存,不影响使用)
再进游戏,搞定!
感谢分享
页:
[1]