GameDataMgr: Difference between revisions
→Reset flags
imported>Leoetlino (wip) |
imported>Leoetlino |
||
(15 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
== TriggerParams == | == TriggerParams == | ||
There are at least two sets of TriggerParams at all times and up to four (param1, param, ???, GimmickResetBuffer). The exact | There are at least two sets of TriggerParams at all times and up to four (param1, param, ???, GimmickResetBuffer). The exact purpose of each TriggerParam is currently unknown. | ||
After all GameData flag info has been loaded into this->triggerParam from the GameData archive ([[gamedata.sarc]]), another TriggerParam instance called param1 (this->triggerParam1) is constructed and data is copied from this->triggerParam. The copy function also builds the lists of flags that need to be reset (with a non-zero ResetType) and of boolean flags with (initialValue >> 1) != 0. | After all GameData flag info has been loaded into this->triggerParam from the GameData archive ([[gamedata.sarc]]), another TriggerParam instance called param1 (this->triggerParam1) is constructed and data is copied from this->triggerParam. The copy function also builds the lists of flags that need to be reset (with a non-zero ResetType) and of boolean flags with (initialValue >> 1) != 0. | ||
* Changes to GameData are (usually) made to param1. A flag allows all param1 changes to be automatically propagated to param, but it appears to be unset under normal operation. | |||
* Under some cases, SaveMgr triggers copies from param to param1. | |||
* GameDataMgr::calc copies param1 to param unless a flag is set. | |||
== Flags == | == Flags == | ||
Line 34: | Line 38: | ||
/// A pointer to the instance is stored in GameDataMgr. | /// A pointer to the instance is stored in GameDataMgr. | ||
GameDataMgr::Flags_NeedGimmickReset = 0x10, | GameDataMgr::Flags_NeedGimmickReset = 0x10, | ||
/// If this->gimmickResetBufferParam is non-null, copy it to triggerParam and to triggerParam1 ( | /// If this->gimmickResetBufferParam is non-null, copy it to triggerParam and to triggerParam1 (args: 1, 0, 0). | ||
GameDataMgr::Flags_NeedCopyGimmickParam = 0x20, | GameDataMgr::Flags_NeedCopyGimmickParam = 0x20, | ||
/// If this->gimmickResetBufferParam is non-null, copy it to triggerParam and to triggerParam1 ( | /// If this->gimmickResetBufferParam is non-null, copy it to triggerParam and to triggerParam1 (args: 1, 1, 0). | ||
GameDataMgr::Flags_40 = 0x40, | GameDataMgr::Flags_40 = 0x40, | ||
GameDataMgr::Flags_80 = 0x80, | GameDataMgr::Flags_80 = 0x80, | ||
Line 42: | Line 46: | ||
GameDataMgr::Flags_200 = 0x200, | GameDataMgr::Flags_200 = 0x200, | ||
GameDataMgr::Flags_400 = 0x400, | GameDataMgr::Flags_400 = 0x400, | ||
/// Set from flag setter functions. The name is based on the fact that IsChangedByDebug gets set at the same time. | |||
GameDataMgr::Flags_IsChangedByDebugMaybe = 0x800, | GameDataMgr::Flags_IsChangedByDebugMaybe = 0x800, | ||
GameDataMgr::Flags_1000 = 0x1000, | GameDataMgr::Flags_1000 = 0x1000, | ||
Line 49: | Line 54: | ||
GameDataMgr::Flags_10000 = 0x10000, | GameDataMgr::Flags_10000 = 0x10000, | ||
GameDataMgr::Flags_20000 = 0x20000, | GameDataMgr::Flags_20000 = 0x20000, | ||
GameDataMgr:: | /// If set, GameDataMgr::calc will skip copying param1 to param (args: 0, 0, 0) | ||
GameDataMgr::Flags_DisableParam1ToParamSync = 0x40000, | |||
GameDataMgr::Flags_IsRestartFromGameOverMaybe = 0x80000, | GameDataMgr::Flags_IsRestartFromGameOverMaybe = 0x80000, | ||
GameDataMgr::Flags_DoNotResetToInitialFromRadarMgr = 0x100000, | GameDataMgr::Flags_DoNotResetToInitialFromRadarMgr = 0x100000, | ||
Line 57: | Line 63: | ||
== Reset flags == | == Reset flags == | ||
Stored at GameDataMgr+0xC1C on Switch 1.5.0. | Stored at GameDataMgr+0xC1C on Switch 1.5.0. | ||
{|class="wikitable" | |||
! Flag !! ResetType !! Description | |||
|- | |||
| 1 || 0 || No reset{{check}} | |||
|- | |||
| 2 || 1 || Corresponds to reset type 1: reset on blood moon | |||
Set from [[SaveSystem]] code (under specific cases when a save is being loaded), or more commonly from [[AIDef:Action/EventOffWaitRevivalAction|action::EventOffWaitRevivalAction]] (whenever a Blood Moon happens) | |||
|- | |||
</ | | 4 || 2 || Corresponds to reset type 2: reset on stage generation | ||
Set when preparing for a stage generation. | |||
|- | |||
| 8 || 3 || Corresponds to reset type 3: reset every night at midnight | |||
Set every day at midnight. | |||
|- | |||
| 0x10 || 4 || Corresponds to reset type 4: reset every time the Lord of the Mountain appears | |||
Set by [[WorldMgr]] when it determines that the Lord of the Mountain should appear. | |||
|} | |||
== Reset process == | |||
All game data flags for which <code>(1 << resetType) & resetFlags</code> is true are reset to their initial values. | |||
TriggerParam::reset processes up to 1024 flags at a time. The function returns the number of remaining flags to reset and flag 0x08 (GameDataMgr::Flags_NeedReset) is only cleared when all flags have been reset. | |||
=== bool and s32 flags with reset type 3 === | |||
bool and s32 flags with reset type 3, and with a flag name hash that is listed in ShopAreaInfo (in [[ShopGameDataInfo.byml]]) receive special treatment. | |||
If: | |||
* the player is in none of the shop areas that are associated with the flag (or in the Dealer's area for area-less flags); or if the player is not on MainField | |||
* '''and''', for items with the <code>Arrow</code> tag: if the player has fewer than {itemSaleRevivalCount} arrows in their inventory | |||
Then: | |||
* The flag is reset to its initial value. | |||
* For bool flags: All associated sold out flags are reset to their initial values. | |||
For more information on the area checks, see [[Object respawning]]. | |||
[[Category: Internals]] | [[Category: Internals]] | ||
[[Category: Subsystems (BotW)]] | [[Category: Subsystems (BotW)]] |