Skip to content

Commit 07f19aa

Browse files
committed
2 parents 48c946a + 8872a59 commit 07f19aa

File tree

8 files changed

+780
-48
lines changed

8 files changed

+780
-48
lines changed

.github/workflows/generate-builds.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ jobs:
4747
run: |
4848
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
4949
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release
50-
cmake --build build-cmake --config Release --target ZAPD
51-
mkdir Extract
52-
cp -r OTRExporter/assets/ ./Extract/assets
53-
./build-cmake/ZAPD/ZAPD.out botr -se OTR --norom
50+
cmake --build build-cmake --config Release --target GenerateSohOtr
5451
- uses: actions/upload-artifact@v3
5552
with:
5653
name: soh.otr

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ add_custom_target(
132132
DEPENDS ZAPD
133133
)
134134

135+
# Target to generate only soh.otr
136+
add_custom_target(
137+
GenerateSohOtr
138+
# CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions
139+
COMMAND ${CMAKE_COMMAND} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f soh.otr
140+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --norom
141+
COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$<TARGET_FILE_DIR:ZAPD>" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -DONLYSOHOTR=On -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake
142+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
143+
COMMENT "Generating soh.otr..."
144+
DEPENDS ZAPD
145+
)
146+
135147
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
136148
find_package(ImageMagick COMPONENTS convert)
137149
if (ImageMagick_FOUND)

OTRExporter/extract_assets.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,40 @@ def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None):
3333
print("Aborting...", file=os.sys.stderr)
3434
print("\n")
3535

36+
def BuildSohOtr(zapd_exe=None):
37+
shutil.copytree("assets", "Extract/assets")
38+
39+
if not zapd_exe:
40+
zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
41+
42+
exec_cmd = [zapd_exe, "botr", "-se", "OTR", "--norom"]
43+
44+
print(exec_cmd)
45+
exitValue = subprocess.call(exec_cmd)
46+
if exitValue != 0:
47+
print("\n")
48+
print("Error when building soh.otr file...", file=os.sys.stderr)
49+
print("Aborting...", file=os.sys.stderr)
50+
print("\n")
51+
3652
def main():
3753
parser = argparse.ArgumentParser()
3854
parser.add_argument("-z", "--zapd", help="Path to ZAPD executable", dest="zapd_exe", type=str)
3955
parser.add_argument("rom", help="Path to the rom", type=str, nargs="?")
4056
parser.add_argument("--non-interactive", help="Runs the script non-interactively for use in build scripts.", dest="non_interactive", action="store_true")
4157
parser.add_argument("-v", "--verbose", help="Display rom's header checksums and their corresponding xml folder", dest="verbose", action="store_true")
4258
parser.add_argument("--gen-headers", help="Generate source headers to be checked in", dest="gen_headers", action="store_true")
59+
parser.add_argument("--norom", help="Generate only soh.otr to be bundled to the game", dest="norom", action="store_true")
4360

4461
args = parser.parse_args()
4562

63+
if args.norom:
64+
if (os.path.exists("Extract")):
65+
shutil.rmtree("Extract")
66+
67+
BuildSohOtr(args.zapd_exe)
68+
return
69+
4670
roms = [ Z64Rom(args.rom) ] if args.rom else rom_chooser.chooseROM(args.verbose, args.non_interactive)
4771
for rom in roms:
4872
if (os.path.exists("Extract")):

copy-existing-otrs.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
message(STATUS "Copying otr files...")
22

3-
if(EXISTS ${SOURCE_DIR}/OTRExporter/oot.otr)
3+
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot.otr)
44
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${SOURCE_DIR})
55
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${BINARY_DIR}/soh/)
66
message(STATUS "Copied oot.otr")
77
endif()
8-
if(EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
8+
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
99
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.otr ${SOURCE_DIR})
1010
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.otr ${BINARY_DIR}/soh/)
1111
message(STATUS "Copied oot-mq.otr")
@@ -18,18 +18,18 @@ endif()
1818

1919
# Additionally for Windows, copy the otrs to the target dir, side by side with soh.exe
2020
if(SYSTEM_NAME MATCHES "Windows")
21-
if(EXISTS ${SOURCE_DIR}/OTRExporter/oot.otr)
21+
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot.otr)
2222
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${TARGET_DIR})
2323
endif()
24-
if(EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
24+
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
2525
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.otr ${TARGET_DIR})
2626
endif()
2727
if(EXISTS ${SOURCE_DIR}/OTRExporter/soh.otr)
2828
execute_process(COMMAND ${CMAKE_COMMAND} -E copy soh.otr ${TARGET_DIR})
2929
endif()
3030
endif()
3131

32-
if(NOT EXISTS ${SOURCE_DIR}/oot.otr AND NOT EXISTS ${SOURCE_DIR}/oot-mq.otr)
32+
if(NOT ONLYSOHOTR AND (NOT EXISTS ${SOURCE_DIR}/oot.otr AND NOT EXISTS ${SOURCE_DIR}/oot-mq.otr))
3333
message(FATAL_ERROR "Failed to copy. No OTR files found.")
3434
endif()
3535
if(NOT EXISTS ${SOURCE_DIR}/soh.otr)

soh/soh/SaveManager.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,17 @@ void SaveManager::InitMeta(int fileNum) {
414414
}
415415
fileMetaInfo[fileNum].healthCapacity = gSaveContext.healthCapacity;
416416
fileMetaInfo[fileNum].questItems = gSaveContext.inventory.questItems;
417+
for (int i = 0; i < ARRAY_COUNT(fileMetaInfo[fileNum].inventoryItems); i++) {
418+
fileMetaInfo[fileNum].inventoryItems[i] = gSaveContext.inventory.items[i];
419+
}
420+
fileMetaInfo[fileNum].equipment = gSaveContext.inventory.equipment;
421+
fileMetaInfo[fileNum].upgrades = gSaveContext.inventory.upgrades;
422+
fileMetaInfo[fileNum].isMagicAcquired = gSaveContext.isMagicAcquired;
423+
fileMetaInfo[fileNum].isDoubleMagicAcquired = gSaveContext.isDoubleMagicAcquired;
424+
fileMetaInfo[fileNum].rupees = gSaveContext.rupees;
425+
fileMetaInfo[fileNum].gsTokens = gSaveContext.inventory.gsTokens;
426+
fileMetaInfo[fileNum].isDoubleDefenseAcquired = gSaveContext.isDoubleDefenseAcquired;
427+
fileMetaInfo[fileNum].gregFound = Flags_GetRandomizerInf(RAND_INF_GREG_FOUND);
417428
fileMetaInfo[fileNum].defense = gSaveContext.inventory.defenseHearts;
418429
fileMetaInfo[fileNum].health = gSaveContext.health;
419430

soh/soh/SaveManager.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ typedef struct {
1919
s16 buildVersionMajor;
2020
s16 buildVersionMinor;
2121
s16 buildVersionPatch;
22+
23+
u8 inventoryItems[24];
24+
u16 equipment;
25+
u32 upgrades;
26+
u8 isMagicAcquired;
27+
u8 isDoubleMagicAcquired;
28+
s16 rupees;
29+
s16 gsTokens;
30+
u8 isDoubleDefenseAcquired;
31+
u8 gregFound;
2232
} SaveFileMetaInfo;
2333

2434
#ifdef __cplusplus

soh/soh/SohMenuBar.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,8 @@ void DrawEnhancementsMenu() {
975975
"This might affect other decal effects\n");
976976
UIWidgets::PaddedEnhancementSliderInt("Text Spacing: %d", "##TEXTSPACING", "gTextSpacing", 4, 6, "", 6, true, true, true);
977977
UIWidgets::Tooltip("Space between text characters (useful for HD font textures)");
978+
UIWidgets::PaddedEnhancementCheckbox("More info in file select", "gFileSelectMoreInfo", true, false);
979+
UIWidgets::Tooltip("Shows what items you have collected in the file select screen, like in N64 randomizer");
978980
ImGui::EndMenu();
979981
}
980982

0 commit comments

Comments
 (0)