故障排除是指定位遊戲崩潰、漏洞或其他問題。一些調試功能在出售給玩家的版本中並不可用,但餘下的功能依然足以解決問題。
日誌文件
王國風雲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文件夾來覆蓋,並避免重複) |
在載入數據庫時崩潰 |
|
在載入事件時崩潰 |
|
CTD at "Loading Graphics | Ensure that your "positions.txt" is not misnamed and that it is empty. |
CTD when rendering the lobby interface | Check that interface .gui and .gfx files are properly merged with vanilla, if copied in the mod. |
CTD on applying history (initial load or selecting a bookmark) | Check that all groups in technology history have an entry for earliest starting date of the mod. See technology modding. |
CTD on load/resign |
|
CTD after 1 in-game day |
|
CTD after a random elapsed time |
It is the worst kind of CTD, because it can be caused by ANY event or decision occurring in the game.
|
CTD when hovering or clicking an event option | Invalid syntax in the event, or calling a command with an invalid value. |
CTD when clicking on religion screen | Check that no more than 5 holy sites are defined in landed_titles for that religion |
CTD when clicking on button to open College of Cardinals | See Interface modding#Papal succession |
CTD when starting typing specific letters in the Title finder | Check that there are no empty geographical regions (at least 1 valid province) |
CTD when you click the "Arrange Marriage" rings button next to a character's portrait | Check that no character, living or dead, that is conceived illegitimately is missing the required "Bastard" Trait. The Trait must be placed in each character's Character History entry BEFORE their birth date and WITHOUT being enclosed in brackets. |
Crash when you click a baron holding in a province to open building interface | Check that there's no illegal buildings in that holding, e.g ca_con_wall_6(Theodosian Walls) in a city. |
排除錯誤
Windows
In last resort you can use Visual Studio (including the free Express editions; get the "Windows Desktop" one) to see detailed debugging information. Though it won't let you debug step by step, as the sources for the game are not available.
Simply start the game, then use the Debug > Attach to process... menu option. Use the Output window to read the game's messages, which will include script validation errors and performance data.
For best results create an empty project and configure it to launch CK2.exe with your mod active (i.e. with the argument -mod=mod/foo.mod
); check the documentation for details on how to do this. You will then be able to launch the game with debugging by clicking the green Play button in Visual Studio. This will ensure that you capture any problems that show up right after the game starts.
When the game crashes Visual Studio will freeze it, tell you where the offset at which crash happened, and provide the option to save a "minidump". The offset and dump won't mean much to you but if you want to report the crash to Paradox they would find both useful.
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
If the game crashes, it will be paused in the debugger, letting you use the bt
command to get a stack trace. Most other debugger features are unavailable without source code.
Meanwhile, use tail in separate terminal tabs to monitor the game's own logs:
tail -F ~/Documents/Paradox\ Interactive/Crusader\ Kings\ II/logs/game.log tail -F ~/Documents/Paradox\ Interactive/Crusader\ Kings\ II/logs/error.log
漏洞
由於你可以在漏洞發生後繼續看到遊戲內文本,漏洞通常比崩潰容易定位。 大多數不影響功能的漏洞可以通過驗證器,一個第三方的用於檢測腳本文件的工具來確定。
現象 | 故障排除方法 |
---|---|
空白的事件彈出窗口,強制暫停遊戲且無法被關閉 |
|
Scripting keywords appearing in decisions/councillor names |
|
Decision not appearing |
|
Decision not having any effect when taken |
|
Truncated localization |
|
Localization not appearing in game |
|
Localized names show strange characters (Ã) |
|
Events not triggering (but OK via console testevent) |
|
Titles have wrong flags |
|
Black coats of arms |
|
Missing layers in portraits for custom ethnicities | |
Casus Belli immediately ends inconclusively |
|
All units models use wrong gfx |
|
Rivers are flowing from east to west on the map |
|
Title is badly displayed on the map (not visible or way outside its area) |
|
Popups like naming children not showing up |
# 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
),測試遊戲平衡和在長期遊戲中檢測隨機崩潰。
參考資料
歷史 | 角色 • 家族 • 省份 • 頭銜 • 劇本 |
腳本 | 指令 • 條件 • 作用域 • 修正 • 事件 • 決議 |
常規 | 定義 • 遊戲規則 • 另類開局 • 宗教 • 文化 • 政體 • 特質 • 血脈 • 科技 • 法律 • 建築 • 宣戰理由 • 朝貢國 • 單位 • 目標 • 疾病 • 死亡 • 榮譽頭銜 • 社團 • 寶物 • 地圖外政權 • 內閣成員 • 貿易路線 • 繼承 • 奇觀 • 稱號 |
圖像/音效/本地化 | 地圖 • 圖形 • 盾徽 • 肖像 • 介面 • 小地圖 • 音樂 • 本地化 |
其他 | 故障排除 • 驗證器 • 控制台指令 • 編輯遊戲存檔 • Steam創意工坊 • EU4轉檔器模組製作 |