Merge branch 'pocketmapfix' of https://git.ra3battle.cn/Kalospacer/WulaFallenEmpireRW into pocketmapfix
This commit is contained in:
@@ -995,6 +995,38 @@ namespace WulaFallenEmpire
|
|||||||
|
|
||||||
base.SpawnSetup(map, respawningAfterLoad);
|
base.SpawnSetup(map, respawningAfterLoad);
|
||||||
|
|
||||||
|
// [核心修复] 当穿梭机降落时,恢复其口袋地图的父级和在游戏中的注册状态
|
||||||
|
if (pocketMap != null && pocketMapGenerated)
|
||||||
|
{
|
||||||
|
// 验证口袋地图的父级对象是否存在于世界列表中
|
||||||
|
if (pocketMap.Parent is PocketMapParent pocketParent && !Find.World.pocketMaps.Contains(pocketParent))
|
||||||
|
{
|
||||||
|
Log.Warning($"[WULA] Pocket map parent for map ID {pocketMap.uniqueID} was not found in the world list. Re-adding it to prevent data loss.");
|
||||||
|
Find.World.pocketMaps.Add(pocketParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证口袋地图本身是否存在于游戏地图列表中
|
||||||
|
if (!Find.Maps.Contains(pocketMap))
|
||||||
|
{
|
||||||
|
Log.Warning($"[WULA] Pocket map ID {pocketMap.uniqueID} was not found in the game's map list. Re-registering it.");
|
||||||
|
|
||||||
|
// 在重新添加前,进行安全检查,防止添加已损坏的地图
|
||||||
|
if (!Find.Maps.Contains(pocketMap) && (pocketMap.mapPawns == null || pocketMap.Tile < 0))
|
||||||
|
{
|
||||||
|
Log.Error("[WULA] Cannot re-register a corrupted pocket map. The contents of the pocket space are likely lost. This is a critical error.");
|
||||||
|
Messages.Message("WULA.PocketSpace.MapInvalidAndRecovering".Translate(), this, MessageTypeDefOf.NegativeEvent);
|
||||||
|
pocketMap = null;
|
||||||
|
pocketMapGenerated = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 重新注册地图,使其再次“激活”
|
||||||
|
Current.Game.AddMap(pocketMap);
|
||||||
|
Log.Message($"[WULA] Pocket map {pocketMap.uniqueID} successfully re-registered.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 更新退出点目标,确保它指向当前的新地图
|
// 更新退出点目标,确保它指向当前的新地图
|
||||||
UpdateExitPointTarget();
|
UpdateExitPointTarget();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user