Skip to content

Commit 3dcdd4a

Browse files
authored
Restore Inventory (#15)
* pmdm * clean up * clang-format
1 parent 4f12886 commit 3dcdd4a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+435
-1806
lines changed

.clang-format

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,3 @@
1-
---
2-
Language: Cpp
1+
IndentWidth: 4
32
AccessModifierOffset: -4
4-
AlignAfterOpenBracket: Align
5-
AlignConsecutiveAssignments: false
6-
AlignConsecutiveDeclarations: false
7-
AlignOperands: true
8-
AlignTrailingComments: true
9-
AllowAllParametersOfDeclarationOnNextLine: true
10-
AllowShortBlocksOnASingleLine: Never
11-
AllowShortCaseLabelsOnASingleLine: false
12-
AllowShortFunctionsOnASingleLine: Inline
13-
AllowShortIfStatementsOnASingleLine: Never
14-
AllowShortLoopsOnASingleLine: false
15-
AlwaysBreakAfterDefinitionReturnType: None
16-
AlwaysBreakAfterReturnType: None
17-
AlwaysBreakBeforeMultilineStrings: false
18-
AlwaysBreakTemplateDeclarations: Yes
19-
BinPackArguments: true
20-
BinPackParameters: true
21-
BreakBeforeBinaryOperators: None
22-
BreakBeforeBraces: Attach
23-
BreakBeforeTernaryOperators: false
24-
BreakConstructorInitializersBeforeComma: false
25-
ColumnLimit: 100
26-
CommentPragmas: '^ (IWYU pragma:|NOLINT)'
27-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
28-
ConstructorInitializerIndentWidth: 4
29-
ContinuationIndentWidth: 4
30-
Cpp11BracedListStyle: true
31-
DerivePointerAlignment: false
32-
DisableFormat: false
33-
ForEachMacros: []
34-
IncludeCategories:
35-
- Regex: '^<[Ww]indows\.h>$'
36-
Priority: 1
37-
- Regex: '^<'
38-
Priority: 2
39-
- Regex: '^"'
40-
Priority: 3
41-
IndentCaseLabels: false
42-
IndentWidth: 4
43-
IndentWrappedFunctionNames: false
44-
KeepEmptyLinesAtTheStartOfBlocks: false
45-
MacroBlockBegin: ''
46-
MacroBlockEnd: ''
47-
MaxEmptyLinesToKeep: 1
48-
NamespaceIndentation: None
49-
ObjCBlockIndentWidth: 4
50-
ObjCSpaceAfterProperty: false
51-
ObjCSpaceBeforeProtocolList: true
52-
PenaltyBreakBeforeFirstCallParameter: 19
53-
PenaltyBreakComment: 300
54-
PenaltyBreakFirstLessLess: 120
55-
PenaltyBreakString: 1000
56-
PenaltyExcessCharacter: 1000000
57-
PenaltyReturnTypeOnItsOwnLine: 60
583
PointerAlignment: Left
59-
ReflowComments: true
60-
SortIncludes: true
61-
SpaceAfterCStyleCast: false
62-
SpaceBeforeAssignmentOperators: true
63-
SpaceBeforeParens: ControlStatements
64-
SpaceInEmptyParentheses: false
65-
SpacesBeforeTrailingComments: 2
66-
SpacesInAngles: false
67-
SpacesInContainerLiterals: true
68-
SpacesInCStyleCastParentheses: false
69-
SpacesInParentheses: false
70-
SpacesInSquareBrackets: false
71-
Standard: c++17
72-
TabWidth: 4
73-
UseTab: Never
74-
WhitespaceSensitiveMacros: ["SEAD_ENUM", "SEAD_ENUM_EX", "SEAD_ENUM_EX_VALUES"]
75-
...

.clangd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CompileFlags:
22
Compiler: /usr/bin/g++
3-
CompilationDatabase: ./target/megaton/none/
3+
CompilationDatabase: ./target/megaton/debug/
44
Remove: [ -march=*, -mtune=*, -mtp=* ]
55
Diagnostics:
66
Suppress:

.github/workflows/main.yml

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
# name: Main
2-
#
3-
# on:
4-
# push:
5-
# branches:
6-
# - main
7-
# pull_request:
8-
# branches:
9-
# - main
10-
#
11-
# jobs:
12-
# check:
13-
# name: Check
14-
# runs-on: ubuntu-latest
15-
# steps:
16-
# - uses: actions/checkout@v4
17-
# - uses: arduino/setup-task@v2
18-
# with:
19-
# version: 3.x
20-
# repo-token: ${{ secrets.GITHUB_TOKEN }}
21-
# - run: task check # installing clang-format 18 is too annoying
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
check:
13+
name: Check
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
recursive: true
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.11'
22+
- uses: DoozyX/[email protected]
23+
with:
24+
source: 'src'
25+
clangFormatVersion: 18

Megaton.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,23 @@ title-id = 0x01007ef00011e000
77
entry = "exl_module_init"
88
sources = [
99
"src",
10-
"libs/exlaunch/source"
10+
"libs/exlaunch/source",
11+
"libs/botw-symbols/src",
1112
]
1213
includes = [
1314
"src",
1415
"libs/botw/src",
1516
"libs/botw/lib/agl/include",
1617
"libs/botw/lib/gsys/include",
18+
"libs/botw-symbols/src",
1719
"libs/exlaunch/source",
1820
"libs/sead/include",
1921
"libs/nnheaders/include",
2022
]
2123
ldscripts = [
2224
"libs/exlaunch/misc/link.ld",
2325
"libs/botw-symbols/ld/ld160.ld",
24-
"link.ld",
26+
"libs/botw-symbols/ld/toolkit160.ld",
2527
]
2628

2729
[build.flags]
@@ -48,6 +50,11 @@ cxx = [
4850
"-Wno-invalid-offsetof",
4951
]
5052

53+
[build.profiles.debug.flags]
54+
c = [
55+
"-DBOTWTOOLKIT_TCP_SEND",
56+
]
57+
5158
[check]
5259
ignore = [
5360
".data",

README.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# botw-save-state
2-
A BOTW 1.6.0 Switch save state mod for speedrun practices
2+
![Build Badge](https://img.shields.io/github/check-runs/Pistonight/botw-save-state/main)
3+
![Issue Badge](https://img.shields.io/github/issues/Pistonight/botw-save-state)
4+
![Downloads Badge](https://img.shields.io/github/downloads/Pistonight/botw-save-state/total)
5+
6+
A BOTW 1.6.0 Switch save-state mod for speedrun practices
37

48
## Install
59
**Migration from 1.x - See [here](./migrate-1.x.md)**
@@ -47,6 +51,8 @@ Restored state from memory
4751
**New in 2.0**: As long as you don't release all the keys, the mod will keep resetting Link's position, allowing for a more accurate restore while in ragdoll state.
4852
For example, with the default restore combo, I typically release the other 3 keys and hold `Plus` for slightly longer until position is fully restored.
4953

54+
If you see errors, please see trouble shooting below.
55+
5056
### Settings
5157
Hold all triggers (`ZL + L + ZR + R`) and the whistle button (`Dpad Down`) for 3 seconds to enter setting mode. You should see the setting menu pop up in the top-right corner.
5258
Use the dpad to navigate the menu and `A` to select. Use `B` to go back a level or exit the settings.
@@ -65,7 +71,8 @@ Since 2.0, you can now toggle individually what you want to save/restore. Open t
6571

6672
**Recommended (TL;DR)**:
6773
- Keep `Timers` enabled as they don't have negative effects
68-
- If you don't need to track durability during practice (i.e. Any%), you can disable `Overworld Durability` and `Inventory` to avoid accidental durability transfer
74+
- If you don't need to track inventory during practice, you can disable `Inventory` to avoid issues.
75+
- Having it on can still have benefits, for example you don't need to swap equipments after restoring for Any%
6976

7077
**Full List**:
7178
1. `Restore Message`
@@ -89,13 +96,13 @@ Since 2.0, you can now toggle individually what you want to save/restore. Open t
8996
- Flame Resist
9097
- Shock Resist
9198
- Stealth
92-
3. `Overworld Durability`
93-
- When enabled, the name and durability of equipped Weapon, Bow and Shield will be saved.
94-
- When restoring, the durability of equipped Weapon/Bow/Shield will only be restored if the same item by name is equipped (not necessarily the same one).
95-
- Note that the inventory durability is not restored unless you also enable `Inventory`
96-
4. `Inventory` enables:
97-
- Equipped durability of Weapon, Bow, Shield and Arrow (similar to `Overworld Durability`, only restored if the same item is equipped)
99+
3. `Inventory` enables:
100+
- (Since v2.1) All your items and their states in the inventory, including but not limited to:
101+
- Number of offset slots for IST
102+
- GameData will be synced
103+
- Equipped items in the overworld will be synced if a quick menu is open. If not, they will be synced the next time you open the quick menu.
98104
- Number of offset slots for IST
105+
- (Since v2.1) This is a stored in its own field, so you can edit this value and break slots easily like in
99106

100107
The following will always be enabled, and you cannot turn them off:
101108
- Current Health
@@ -118,6 +125,35 @@ You can use this [python script](./scripts/ftp.py) to transfer save state files
118125

119126
(This has nothing to do in game, just makes managing the save state files generated by the mod easier)
120127

128+
## Troubleshooting & FAQ
129+
130+
#### Q: The mod is not showing in SimpleModManager
131+
When you download the release `zip`, there are 2 folders `mods` and `botwsavs`. Make sure to
132+
copy these to the **root** of the SD card, and overwrite existing files. Do NOT put them in any subfolders.
133+
134+
#### Q: I installed but it's not working in game
135+
Please check the following:
136+
- The title screen should show the version as `1.6.0-SSx.y` where `x.y` is the version of the mod.
137+
- When you load a save, after walking around for a few seconds, there will be a welcome message displayed on the top-right corner.
138+
139+
If you have these working, then the mod is active, and you likely are not pressing the key combos correctly. Make sure to only
140+
press the keys set. For example, if your binding is `A+B`, then pressing `A+B+Y` will not work.
141+
142+
#### Q: Restore is showing error
143+
Try restarting the game. The mod uses raw memory access to save/restore the state and has protection against invalid memory access.
144+
There is a small chance that when the game boots, the values are not in the usual location.
145+
146+
#### Q: I'm stuck after restoring
147+
Don't restore in water or on a ladder.
148+
149+
#### Q: Crash
150+
Please open an issue and upload the crash report found in `/atmosphere/crash_reports/<timestamp>.log`, where `<timestamp>` is a number.
151+
The greatest number is the most recent crash.
152+
153+
#### Q: Will there be support for TOTK?
154+
Making a mod like this requires an insane amount of research, and I was lucky to have Bloom do most of it
155+
for BOTW. I don't really have the time and energy to think about TOTK right now.
156+
121157
## Developer
122158
**This section is intended for developers**
123159

Taskfile.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
11
version: '3'
22

33
env:
4-
CONSOLE_ADDR: 192.168.0.161:5000 # can be overriden in .env
4+
# can be overriden in .env
5+
CONSOLE_ADDR: 192.168.0.161:5000
6+
DEBUG_ADDR: 192.168.0.161:5001
57
dotenv: [".env"]
68

9+
includes:
10+
symbols:
11+
aliases: [sym]
12+
taskfile: libs/botw-symbols
13+
dir: libs/botw-symbols
14+
715
tasks:
816
build:
917
aliases: [b]
1018
desc: Build the mod
1119
cmds:
12-
- megaton
20+
- megaton -p debug
1321

1422
check:
1523
desc: Check code for errors
1624
cmds:
17-
- clang-format -n -Werror src/**/*.cpp
18-
- clang-format -n -Werror src/**/*.hpp
19-
- clang-format -n -Werror src/**/*.h
25+
- clang-format -n -Werror $(find src -name '*.cpp' -o -name '*.hpp')
2026

2127
fix:
2228
desc: Fix errors in code
2329
cmds:
24-
- clang-format -i src/**/*.cpp
25-
- clang-format -i src/**/*.hpp
26-
- clang-format -i src/**/*.h
30+
- clang-format -i $(find src -name '*.cpp' -o -name '*.hpp')
2731

2832
package:
2933
desc: Package the build for release
30-
deps: [build]
3134
vars:
32-
VERSION: "SS2.0"
35+
VERSION: "SS2.1"
3336
MOD_DIR: "target/package/mods/The Legend of Zelda - Breath of the Wild/Save State/contents/01007EF00011E000"
3437
cmds:
38+
- megaton -p none
3539
- rm -rf target/package/mods
3640
- mkdir -p "{{.MOD_DIR}}/exefs"
3741
- mkdir -p "{{.MOD_DIR}}/romfs/System"
3842
- cp target/megaton/none/main.npdm "{{.MOD_DIR}}/exefs/main.npdm"
39-
- cp target/megaton/none/make/botwsavs.nso "{{.MOD_DIR}}/exefs/subsdk9"
43+
- cp target/megaton/none/botwsavs.nso "{{.MOD_DIR}}/exefs/subsdk9"
4044
- mkdir -p target/package/botwsavs
4145
- echo "" > target/package/botwsavs/latest.txt
4246
- echo -n "1.6.0-{{.VERSION}}" > "{{.MOD_DIR}}/romfs/System/Version.txt"
@@ -54,5 +58,6 @@ tasks:
5458
- mkdir -p target/crash_reports/dumps
5559
- lftp $CONSOLE_ADDR < scripts/lftp-download.sh
5660

57-
58-
61+
debug:
62+
cmds:
63+
- python libs/botw-symbols/tcp-client.py $DEBUG_ADDR

link.ld

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/lftp-upload.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mkdir -p -f /atmosphere/contents/01007EF00011E000/exefs
22
cd /atmosphere/contents/01007EF00011E000/exefs
3-
mput -e target/megaton/none/botwsavs.nso
4-
mput -e target/megaton/none/main.npdm
3+
mput -e target/megaton/debug/botwsavs.nso
4+
mput -e target/megaton/debug/main.npdm
55
rm -f subsdk9
66
mv botwsavs.nso subsdk9

0 commit comments

Comments
 (0)