故障排除:修订间差异

本页面所适用的版本可能已经过时,最后更新于2.7
无编辑摘要
第145行: 第145行:
==漏洞==
==漏洞==


Bugs are usually easier to identify than crashes, as there is in-game context to identify the cause.
由于你可以在漏洞发生后继续看到游戏内文本,漏洞通常比崩溃容易定位。
Most non-functional bugs can be spotted via [[The Validator]], a third-party tool which checks script files for various kinds of problems.
大多数不影响功能的漏洞可以通过[[The Validator]] ,一个第三方的用于检测脚本文件的工具来确定。


{| class="wikitable"
{| class="wikitable"
|-
|-
! Symptom !! Troubleshooting
! 现象 !! 故障排除方法
|-
|-
| Blank event popups that pause the game and can't be closed.
| 空白的事件弹出窗口,强制暂停游戏且无法被关闭
*Save the game after the popups have appeared (without checking the compress save checkbox), and look in the save for the faulty eventID that is the source. They will be at the bottom of the file, in a <code>player_event</code> section.
* 窗口弹出后保存游戏(无需检查压缩存档选框),然后在存档中查找错误事件的ID。它们会出现在文件的最后,<code>player_event</code> 一节
*Use [[The Validator]], check for Parse failures, or invalid node type errors.
*Use [[The Validator]], check for Parse failures, or invalid node type errors.
|-
|-

2019年3月3日 (日) 09:37的版本

The CTD... Don't expect Windows to find any solution for you, you'll have to dig !

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

日志文件

王国风云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 记载游戏占用内存

载入

When launching the game the following steps occur:

  • Initialising Map Logic
  • Loading Databases
  • Generating Coat of Arms
  • Loading Events
  • Loading Sounds
  • (Loading of vanilla history files occurs here (even if is replace_path), though it'll still show as "Loading Sounds") - very slow step !
  • Processing Flags - generates the flag sprites in gfx\flags from the individual .tga files
  • Loading Flags
  • Loading Graphics
  • Creating Provinces
  • Loading Map(Creating Terrain)
  • Loading Map(Creating Borders)
  • Loading Map(Creating Trees)
  • Loading Map(Creating Textures)

Once this is done the lobby interface will be rendered.

崩溃

Crashes or Crash To Desktop (CTD) are the despair of the players and nightmare of the modders. There is usually little to no information to identify the cause.

Here is a list of known issues:

Symptom Troubleshooting
Instant CTD clicking Play in the launcher Check no new defines.lua entries are missing in the mod (or better use defines folder to override, and avoid duplication)
CTD at "Loading Databases"
  • 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, ...)
CTD at "Loading Events"
  • Check for unbalanced quotes, such as has_dlc = "Reapers
  • Can be caused by excessively long log commands with multiple references to global variables.
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 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)

调试

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.

漏洞

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

现象 故障排除方法
空白的事件弹出窗口,强制暂停游戏且无法被关闭
  • 窗口弹出后保存游戏(无需检查压缩存档选框),然后在存档中查找错误事件的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)
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"
}

测试

Testing is the process of checking your mod for bugs, including crashes, broken functionalities, or gameplay/balance issues.

Tooling for testing include:

  • In-game console, with various debugging (or cheating...) features, in particular play, testevent and event commands. Note that the "debug_" console commands are currently disabled in retail builds.
  • Cheat mods, allowing to automate many console commands, or things not achievable or too complex via console commands.
  • Observer mode (observe console command), to check for game balance, and detect random CTDs over hundred of in-game years.

References

  1. In 2.6.3 game is fully playable and crashes only if you load saved game or resign the game