排除故障

本页面讲述的内容长期有效
克孜勒上单讨论 | 贡献2024年1月24日 (三) 20:27的版本 (克孜勒上单移动页面Troubleshooting排除故障:​标题翻译)

Troubleshooting is the identification of the cause of crashes, bugs or other problems.

Overview

In general there are two kinds of errors: fatal and non-fatal.

Fatal errors occur when the game cannot load a vital piece of data and cannot operate without it present. This causes a crash to desktop (CTD). When fatal errors occur, an exception will be printed to the exceptions.log. Typically these errors occur during the loading process or when a specific action is taken in game.

Non-fatal errors occur when the game encountered invalid data or broken syntax. These errors are almost always printed to the error.log.

Testing

Performing testing is vital to debugging a mod. Typically this is done via the in-game console with commands.

These are useful console commands for modders:

Command Usage
reloadfx all Reloads most of the effects used in the game, such as fog of war, the HDR and opacity of country borders, ect.
reload texture Reloads most of the textures used in the game, such as leader portraits, technology icons, etc.
reload localization Reloads most of the localization used in game, such as event titles and descriptions.
reload defines Reloads the defines files from /Hearts of Iron IV/common/defines/.
reload focus Reloads the focus trees in /Hearts of Iron IV/common/national_focuses/.
reloadoob Reloads the starting OOB file for the specified tag.
reloadtechnologies Reloads the technology files. Will cause a crash if an error is encountered.
reloadinterface Reloads the interface files (.gui).
tdebug Activates the debug tooltips, displaying important information such as state ID, province ID, etc.
event Fires the specified event immediate for the current player country.
nocb Removes restrictions on diplomatic actions.
observe Places the player into the observer slot, allowing the game to pass without player input.
aiview Displays the AI priorities when hovering over specific buttons, such as technology.
tag Switches the player to another country.
update_loc Reloads the specified localization key.
updateequipments Reloads the equipment files in /Hearts of Iron IV/common/units/equipment/.
updatesubunits Reloads the unit files in /Hearts of Iron IV/common/units/.
research_on_icon_click Activates research on click, allowing you to click on technologies to research them instantly.
Focus.NoChecks Removes the trigger checks for focuses.
Focus.AutoComplete Activates instant completion for focuses.
set_country_flag Sets the specified country flag for the current country.
add_ideas Adds the specified idea to the current country.

Log files

The game stores various log files in your HOI4 user folder: (Windows: \\Documents\Paradox Interactive\Hearts of Iron IV\logs\, Linux: .local/share/Paradox Interactive/Hearts of Iron IV/logs). These are overwritten every time the game is started.

To enable full error logging, add the -debug launch command via Set Launch Options in Steam.

File Description Usefulness
ai.log Prints the AI choices undertaken. Medium
ai_trace.log Prints the AI movements undertaken (divisions, ships, air, etc.) Low
error.log Prints the various non-fatal errors. Many errors can be ignored, although almost all errors relating to files in the common folder should be fixed. High
exceptions.log Prints the stacktrace when the game crashes to desktop. Low
executedcommands.log Prints the internal commands uses by the player and AI. Low
game.log Prints the actions taken by countries in game. Useful when the crash is due to a specific action. High
graphics.log Prints the graphical errors relating to positions, rivers and trees. Low
memory.log Prints the memory used during setup. Useful for crashes during the loading process, to see when the game crashed. High
message.log Prints the session info for the current session. Low
postedcommands.log Low
random.log Prints times for gamestate changes. Low
receivedcommands.log Prints the internal commands received by the player in multiplayer. Low
sentcommands.log Prints the internal commands sent by the player in multiplayer. Low
setup.log Prints the completion of setup loading for each part of the process. Very useful for discovering which file may be causing a crash. High
system.log Prints the system information HOI4 is loaded on. Low
system_debug.log Prints interface errors. Medium
text.log Prints asserts on localization keys. Medium
time.log Prints the time it takes for the various loading steps to complete, and the tick interval. Very useful for crashes during the loading process, to see when the game crashed. Medium