故障排除

本頁面所適用的版本可能已經過時,最後更新於2.7
崩潰......不要指望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文件夾來覆蓋,並避免重複)
在載入資料庫時崩潰
  • Compare setup.log with the mod and with raw vanilla : next steps normally logged in vanilla are the likely cause of the crash
  • 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
  • Can be caused by excessively long log commands with multiple references to global variables.
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
  • Check that no character has a death date past the end date of the mod.
  • Check that no character has a birth date later than death date.[1]
CTD after 1 in-game day
  • Check loaded trade routes reference valid provinces. For total conversion mods, use replace_path = "common/trade_routes" or blank vanilla files.
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.

  • If it slows down before crashing, it might be an infinite loop in an event. Check for a stackoverflow error being reported in exceptions.log. See Event modding#Recursive events
  • If it crashes without warning, it may be a scripting error regarding parameter types that is not safely handled by the engine. Use The Validator and fix the errors reported, in priority effects used in a wrong context or with wrong parameters. For instance set_graphical_culture = norse vs set_graphical_culture = norsegfx used to CTD.
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

漏洞

由於你可以在漏洞發生後繼續看到遊戲內文本,漏洞通常比崩潰容易定位。 大多數不影響功能的漏洞可以通過驗證器,一個第三方的用於檢測腳本文件的工具來確定。

現象 故障排除方法
空白的事件彈出窗口,強制暫停遊戲且無法被關閉
  • 窗口彈出後保存遊戲(無需檢查壓縮存檔選框),然後在存檔中查找錯誤事件的ID。它們會出現在文件的最後,player_event一節
  • Use The Validator, check for Parse failures, or invalid node type errors.
Scripting keywords appearing in decisions/councillor names
Decision not appearing
  • Move conditions from potential to allow block, to see failing conditions in tooltip.
Decision not having any effect when taken
Truncated localization
  • Open .csv file with OpenOffice and check for extra columns containing text
  • Make sure translations do not contain semi-colon character, as it used separate languages
Localization not appearing in game
  • Ensure file extension is .csv, not .txt
  • Check that mod folder is named localisation, not localization.
  • Ensure overridden vanilla keys are loaded before vanilla (i.e. 00_ file prefix)
Localized names show strange characters (Ã)
  • Check encoding of landed_titles, culture, and localization files to be Windows 1252 (ANSI), and not any type of Unicode.
Events not triggering (but OK via console testevent)
  • Check for invisible non-breakable spaces in event files (they can be found with Notepad++ by searching with "Extended mode" the Unicode string \u00A0)
Titles have wrong flags
  • Clean the flag cache in ~\Documents\Paradox Interactive\Crusader Kings II\(Mod user_dir)\gfx\flags
  • Make sure all titles above barony have a corresponding flag in gfx/flags (with The Validator)
  • Try to see at which title it starts messing up, that's usually where you're missing the flag.
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
  • Check that no province history files reference a barony that is not defined in landed_titles (with The Validator)
Rivers are flowing from east to west on the map
  • Rivers flowing east to west typically means that there is something wrong with the color index of rivers.bmp. [2]
Title is badly displayed on the map (not visible or way outside its area)
  • Check for stray pixels in provinces.bmp
Popups like naming children not showing up
  • When using replace_path = "events", the following script needs to be added in the mod events folder:
# 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. In 2.6.3 game is fully playable and crashes only if you load saved game or resign the game
  2. [1]