首页所有页面

故障排除

崩溃......不要指望Windows会为你找到任何解决方案,你必须自己行动!

故障排除是指定位游戏崩溃、漏洞或其他问题。一些调试功能在出售给玩家的版本中并不可用,但余下的功能依然足以解决问题。

日志文件

王国风云2本身在你的游戏文件夹(~\Documents\Paradox Interactive\Crusader Kings II\logs\)记录了大量的日志文件。每次游戏启动时这些文件将被覆盖。

更多的日志记录功能可以用启动参数来打开(通过steam高级启动/定义启动参数): -debug -debugscripts

文件名 描述
game.log 游戏内通知和log指令的输出。从patch 2.4.1开始,只在-debugscripts启用时记录
setup.log 游戏数据loading日志(GUI、特质、修正等)
error.log 分析和记载错误。启用-debugscripts时记载更多内容。

如果没有发现问题,以下几行应该显示为OK:

[technology.cpp:718]: Missing Tech seed values:

[technology.cpp:755]: None.

[texturehandler.cpp:181]: Couldn't find texture file: .

historical_setup_errors.log 额外的关于头衔/角色历史的错误。只在-fullhistoricalsetuplog启用时记录。
system_interface.log 关于interface modding的错误
graphics.log 关于map modding的错误
system.log 硬件内容记录
system_interface.log 界面错误
text.log 关于localization键值的错误记录
script_optimizations.log 关于廷臣触发的事件的错误记录
ai.log
exceptions.log 如果游戏崩溃,你可能在此得到一份堆栈轨迹,和最后一个被调用的方法(例如:CLandedTitle::GetShortName)
time.log 记载游戏载入时间
memory.log 记载游戏占用内存

载入

游戏的加载按照以下顺序:

  • 载入地图
  • 载入数据库
  • 载入盾徽
  • 载入事件
  • 加载音效
  • 载入原版历史(即使被MOD覆盖),依旧显示为加载音效(非常耗时的一步)
  • 处理旗帜——从每个tga文件中获得旗帜数据
  • 加载旗帜
  • 加载图像
  • 创建省份
  • 载入地图(创建地形)
  • 载入地图(创建边境)
  • 载入地图(创建树木)
  • 载入地图(创建纹理)

全部完成以后显示主菜单

崩溃

崩溃,或者说弹出至桌面(CTD),令玩家苦恼,也是MOD作者的梦魇。崩溃的原因很难定位。

这里是一些已知的崩溃原因

现象 故障排除方法
在启动器点击开始时崩溃 检查mod的defines.lua中有无缺少条目(或者使用defines文件夹来覆盖,并避免重复)
在载入数据库时崩溃
  • 把setup.log和模组和原版对比:正常在原版中记录的下一步操作很可能是崩溃的原因
  • Check the format and color indexes of map files (terrain.bmp, ...)
  • Check Province Map for any Antialiazing pixels
在载入事件时崩溃
  • Check for unbalanced quotes, such as has_dlc = "Reapers
  • 这可能是由于日志命令过长且多次引用全局变量所致。
CTD at "Loading Graphics 确保你的“positions.txt”没有被误称,且是空的。
CTD when rendering the lobby interface Check that interface .gui and .gfx files are properly merged with vanilla, if copied in the mod.
应用历史记录时出现崩溃(初始加载或选择书签) 检查所有科技历史中的团体是否都有关于模组最早起始日期的条目。参见 technology modding.
CTD on load/resign
  • 检查没有角色的死亡日期超过了模组的结束日期。
  • 检查没有角色的出生日期晚于死亡日期。[1]
CTD after 1 in-game day
  • 检查载入贸易路线是否引用有效省份。关于全面转换的模组,请使用 replace_path = "common/trade_routes" or blank vanilla files.
CTD after a random elapsed time

这是最糟糕的CTD,因为它可能由游戏中任何事件或决策引起。

  • 如果它在崩溃前减速,可能是某个事件的无限循环。检查exceptions.log中是否有报告的 StackOverflow 错误。参见 Event modding#Recursive events
  • If it crashes without warning, it may be a scripting 关于参数类型的错误,而这些参数类型无法被引擎安全处理。用途 The Validator 并修正在错误上下文或参数错误中使用优先级效应时报告的错误。例如: set_graphical_culture = norse vs set_graphical_culture = norsegfx used to CTD.
CTD when hovering or clicking an event option 事件中的语法无效,或者调用了无效值的命令。
CTD when clicking on religion screen 检查该宗教landed_titles中不超过5个圣地
CTD when clicking on button to open College of Cardinals See Interface modding#Papal succession
在标题查找器中开始输入特定字母时出现崩溃 检查是否有空置的地理区域(至少有一个有效的省份)
点击角色头像旁边的“安排婚姻”按钮时,CTD 会响起 检查没有任何生者或已故角色,只要是非法构思的,都缺少所需的“”Bastard“特质。该特质必须在角色出生日期之前放入角色历史条目,且不得被括号括住。
点击持有省份的男爵打开建筑界面时会崩溃 检查该持有地内没有非法建筑,比如城市中的ca_con_wall_6(狄奥多西墙)。

排除错误

Windows

In last resort you can use Visual Studio (including the free Express editions;获取“Windows Desktop”那个),查看详细的调试信息。不过它不允许你逐步调试,因为游戏的源代码不可得。

Simply start the game, then use the Debug > Attach to process... 菜单选项。使用输出窗口读取游戏消息,其中包括脚本验证错误和性能数据。

为了获得最佳效果,创建一个空项目,并配置它在激活模组时启动CK2.exe(即参数为 -mod=mod/foo.mod);查看文档中关于如何操作的详细信息。然后你可以通过在Visual Studio点击绿色“播放”按钮启动调试游戏。这样可以确保你能捕捉到游戏刚开始时出现的任何问题。

当游戏崩溃时,Visual Studio 会冻结游戏,告诉你崩溃的偏移量,并提供保存“迷你转储”的选项。偏移和转储对你影响不大,但如果你想向Paradox报告崩溃,他们会觉得两者都很有用。

macOS

Install Xcode from the App Store, then run xcode-select --install in a Terminal window.

Launch the game from lldb:

cd ~/Library/Application\ Support/Steam/SteamApps/common/Crusader\ Kings\ II

lldb ck2.app/Contents/MacOS/ck2

r -- -debug -debugscripts

如果游戏崩溃,调试器会暂停游戏,允许你使用 bt command to get a stack trace.大多数其他调试器功能在没有源代码的情况下无法使用。

Meanwhile, use tail 在独立的终端标签页中用于监控游戏日志:

tail -F ~/Documents/Paradox\ Interactive/Crusader\ Kings\ II/logs/game.log

tail -F ~/Documents/Paradox\ Interactive/Crusader\ Kings\ II/logs/error.log

漏洞

由于你可以在漏洞发生后继续看到游戏内文本,漏洞通常比崩溃容易定位。 大多数不影响功能的漏洞可以通过验证器,一个第三方的用于检测脚本文件的工具来确定。

现象 故障排除方法
空白的事件弹出窗口,强制暂停游戏且无法被关闭
  • 窗口弹出后保存游戏(无需检查压缩存档选框),然后在存档中查找错误事件的ID。它们会出现在文件的最后,player_event一节
  • Use The Validator检查解析失败或无效节点类型错误。
Scripting keywords appearing in decisions/councillor names
Decision not appearing
  • 将条件从潜力移动到允许阻挡,这样就能在提示中看到失败条件。
Decision not having any effect when taken
Truncated localization
  • Open .csv file with OpenOffice and check for extra columns containing text
  • 确保翻译中没有分号字符,因为它使用了不同的语言
Localization not appearing in game
  • Ensure file extension is .csv, not .txt
  • Check that mod folder is named localisation, not localization.
  • 确保覆盖的原版密钥在原版之前加载(即 00_ 文件前缀)
Localized names show strange characters (Ã)
  • 检查landed_titles、文化和本地化文件的编码是否为Windows 1252(ANSI),而非任何类型的Unicode。
Events not triggering (but OK via console testevent)
  • 检查事件文件中是否有不可见的不可破坏空格(可用Notepad++用“扩展模式”搜索Unicode字符串\u00A0找到)。
Titles have wrong flags
  • 清理 ~\Documents\Paradox Interactive\Crusader Kings II\(Mod user_dir)\gfx\flags 中的旗标缓存
  • 确保所有男爵以上的爵位在gfx/flags中都有相应的旗帜(其中 The Validator)
  • 试着看看是哪个标题开始出错,通常你就是从那个位置漏掉了旗帜。
Black coats of arms
  • Verify the pattern file size in Coats of arms.txt
  • Ensure all religion match a CoA group
Missing layers in portraits for custom ethnicities
Casus Belli immediately ends inconclusively
  • Make sure can_use/can_use_title/is_valid_title blocks are in synch.
All units models use wrong gfx
  • 检查没有省份历史文件提及未定义的男爵领(landed_titles The Validator)
地图上的河流是从东向西流的
  • 河流东西流通常意味着rivers.bmp的色指数存在问题。 [2]
标题在地图上显示得很糟糕(看不到或者远离了它的区域)
  • Check for stray pixels in provinces.bmp
Popups like naming children not showing up
  • When using replace_path = "events",需要在mod events文件夹中添加以下脚本:
# ID 1 and 2 are empty dummy events that are used by the message system to spawn messages

# that should be displayed as events, their descriptions are filled in by the message system

letter_event = {

	id = 1

	is_triggered_only = yes

	desc = "A"

}

character_event = {

	id = 2

	is_triggered_only = yes

	desc = "B"

}

测试

包括检测你的MOD是否会导致崩溃、有无漏洞、无效功能或者游戏体验/平衡性问题。 测试工具包括:

  • 控制台指令,提供许多用于调试的功能(或者作弊功能...),包括
    • play,控制特定角色
    • testevent
    • event。注意部分以debug_开头的命令在上市版本中不可用。
    • run,测试你的环境和指令,而且不用重新开始游戏。
  • 观察者模式(控制台指令observe),测试游戏平衡和在长期游戏中检测随机崩溃。

参考资料

  1. 在2.6.3版本中,游戏完全可玩,只有加载存档或放弃游戏才会崩溃
  2. [1]
相关页面 (67)

BastardCoats of arms.txtCollege of CardinalsEU4转档器模组制作Event moddingInterface moddingLocalisationLocalizationMap moddingMerging guidePatch 2.4.1Portrait moddingScriptingSteam创意工坊Technology moddingThe Validator事件模组制作作用域修正内阁成员模组制作决议模组制作剧本模组制作单位模组制作历史模组制作另类开局模组制作图形模组制作地图外政权模组制作地图模组制作头衔模组制作奇观模组制作宗教模组制作定义宝物模组制作宣战理由模组制作家族模组制作小地图模组制作建筑模组制作指令控制台指令政体模组制作文化模组制作朝贡国类型模组制作本地化条件模组制作死亡模组制作法律模组制作游戏规则模组制作特质模组制作界面模组制作疾病模组制作目标模组制作盾徽模组制作省份模组制作社团模组制作科技模组制作称号模组制作继承模组制作编辑游戏存档肖像模组制作