Skip to content

Commit

Permalink
Merge pull request #2906 from HarbourMasters/develop-spock
Browse files Browse the repository at this point in the history
Spock -> develop
  • Loading branch information
leggettc18 committed May 23, 2023
2 parents 5de1240 + e88adbe commit fe6705c
Show file tree
Hide file tree
Showing 149 changed files with 448 additions and 85 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")

set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")

project(Ship VERSION 7.0.1 LANGUAGES C CXX)
set(PROJECT_BUILD_NAME "Spock Bravo" CACHE STRING "")
project(Ship VERSION 7.0.2 LANGUAGES C CXX)
set(PROJECT_BUILD_NAME "Spock Charlie" CACHE STRING "")
set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "")

set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT soh)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/utf-8>)

if (CMAKE_SYSTEM_NAME MATCHES "Windows|Linux")
if(NOT DEFINED BUILD_CROWD_CONTROL)
Expand Down
2 changes: 2 additions & 0 deletions soh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ if(MSVC)
/INCREMENTAL:NO;
/FORCE:MULTIPLE
>
/MANIFEST:NO;
/DEBUG;
/SUBSYSTEM:WINDOWS
)
Expand All @@ -514,6 +515,7 @@ if(MSVC)
/INCREMENTAL:NO;
/FORCE:MULTIPLE
>
/MANIFEST:NO;
/DEBUG;
/SUBSYSTEM:WINDOWS
)
Expand Down
7 changes: 7 additions & 0 deletions soh/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ END
// remains consistent on all systems.
IDI_ICON1 ICON "SHIPOFHARKINIAN.ico"

/////////////////////////////////////////////////////////////////////////////
//
// RT_MANIFEST
//

1 RT_MANIFEST "SHIPOFHARKINIAN.manifest"

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down
31 changes: 31 additions & 0 deletions soh/SHIPOFHARKINIAN.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>
1 change: 1 addition & 0 deletions soh/include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ extern "C"
extern u32 gGsFlagsShifts[4];
extern void* gItemIcons[0x82];
extern u8 gItemAgeReqs[];
extern u8 gSlotAgeReqs[];
extern u8 gItemSlots[56];
extern void (*gSceneCmdHandlers[SCENE_CMD_ID_MAX])(PlayState*, SceneCmd*);
extern s16 gLinkObjectIds[2];
Expand Down
8 changes: 4 additions & 4 deletions soh/soh/Enhancements/controls/GameControlEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ namespace GameControlEditor {
UIWidgets::PaddedEnhancementCheckbox("Invert Camera Y Axis", "gInvertYAxis", true, true, false, "", UIWidgets::CheckboxGraphics::Cross, true);
DrawHelpIcon("Inverts the Camera Y Axis in:\n-Free camera");
UIWidgets::Spacer(0);
+ UIWidgets::PaddedEnhancementSliderFloat("Third-Person Horizontal Sensitivity: %d %%", "##ThirdPersonSensitivity Horizontal",
+ "gThirdPersonCameraSensitivityX", 0.01f, 5.0f, "", 1.0f, true, true, false, true);
+ UIWidgets::PaddedEnhancementSliderFloat("Third-Person Vertical Sensitivity: %d %%", "##ThirdPersonSensitivity Vertical",
+ "gThirdPersonCameraSensitivityY", 0.01f, 5.0f, "", 1.0f, true, true, false, true);
UIWidgets::PaddedEnhancementSliderFloat("Third-Person Horizontal Sensitivity: %d %%", "##ThirdPersonSensitivity Horizontal",
"gThirdPersonCameraSensitivityX", 0.01f, 5.0f, "", 1.0f, true, true, false, true);
UIWidgets::PaddedEnhancementSliderFloat("Third-Person Vertical Sensitivity: %d %%", "##ThirdPersonSensitivity Vertical",
"gThirdPersonCameraSensitivityY", 0.01f, 5.0f, "", 1.0f, true, true, false, true);
UIWidgets::PaddedEnhancementSliderInt("Camera Distance: %d", "##CamDist",
"gFreeCameraDistMax", 100, 900, "", 185, true, false, true);
UIWidgets::PaddedEnhancementSliderInt("Camera Transition Speed: %d", "##CamTranSpeed",
Expand Down
64 changes: 35 additions & 29 deletions soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
#include "GameInteractor.h"

#ifdef __cplusplus
extern "C" {
#endif
// MARK: - Gameplay
extern "C" void GameInteractor_ExecuteOnLoadGame(int32_t fileNum);
extern "C" void GameInteractor_ExecuteOnExitGame(int32_t fileNum);
extern "C" void GameInteractor_ExecuteOnGameFrameUpdate();
extern "C" void GameInteractor_ExecuteOnItemReceiveHooks(GetItemEntry itemEntry);
extern "C" void GameInteractor_ExecuteOnSaleEndHooks(GetItemEntry itemEntry);
extern "C" void GameInteractor_ExecuteOnTransitionEndHooks(int16_t sceneNum);
extern "C" void GameInteractor_ExecuteOnSceneInit(int16_t sceneNum);
extern "C" void GameInteractor_ExecuteOnSceneSpawnActors();
extern "C" void GameInteractor_ExecuteOnPlayerUpdate();
extern "C" void GameInteractor_ExecuteOnOcarinaSongAction();
extern "C" void GameInteractor_ExecuteOnActorUpdate(void* actor);
extern "C" void GameInteractor_ExecuteOnPlayerBonk();
extern "C" void GameInteractor_ExecuteOnOcarinaSongAction();
void GameInteractor_ExecuteOnLoadGame(int32_t fileNum);
void GameInteractor_ExecuteOnExitGame(int32_t fileNum);
void GameInteractor_ExecuteOnGameFrameUpdate();
void GameInteractor_ExecuteOnItemReceiveHooks(GetItemEntry itemEntry);
void GameInteractor_ExecuteOnSaleEndHooks(GetItemEntry itemEntry);
void GameInteractor_ExecuteOnTransitionEndHooks(int16_t sceneNum);
void GameInteractor_ExecuteOnSceneInit(int16_t sceneNum);
void GameInteractor_ExecuteOnSceneSpawnActors();
void GameInteractor_ExecuteOnPlayerUpdate();
void GameInteractor_ExecuteOnOcarinaSongAction();
void GameInteractor_ExecuteOnActorUpdate(void* actor);
void GameInteractor_ExecuteOnPlayerBonk();
void GameInteractor_ExecuteOnOcarinaSongAction();

// MARK: - Save Files
extern "C" void GameInteractor_ExecuteOnSaveFile(int32_t fileNum);
extern "C" void GameInteractor_ExecuteOnLoadFile(int32_t fileNum);
extern "C" void GameInteractor_ExecuteOnDeleteFile(int32_t fileNum);
void GameInteractor_ExecuteOnSaveFile(int32_t fileNum);
void GameInteractor_ExecuteOnLoadFile(int32_t fileNum);
void GameInteractor_ExecuteOnDeleteFile(int32_t fileNum);

// MARK: - Dialog
extern "C" void GameInteractor_ExecuteOnDialogMessage();
extern "C" void GameInteractor_ExecuteOnPresentTitleCard();
extern "C" void GameInteractor_ExecuteOnInterfaceUpdate();
extern "C" void GameInteractor_ExecuteOnKaleidoscopeUpdate(int16_t inDungeonScene);
void GameInteractor_ExecuteOnDialogMessage();
void GameInteractor_ExecuteOnPresentTitleCard();
void GameInteractor_ExecuteOnInterfaceUpdate();
void GameInteractor_ExecuteOnKaleidoscopeUpdate(int16_t inDungeonScene);

// MARK: - Main Menu
extern "C" void GameInteractor_ExecuteOnPresentFileSelect();
extern "C" void GameInteractor_ExecuteOnUpdateFileSelectSelection(uint16_t optionIndex);
extern "C" void GameInteractor_ExecuteOnUpdateFileCopySelection(uint16_t optionIndex);
extern "C" void GameInteractor_ExecuteOnUpdateFileCopyConfirmationSelection(uint16_t optionIndex);
extern "C" void GameInteractor_ExecuteOnUpdateFileEraseSelection(uint16_t optionIndex);
extern "C" void GameInteractor_ExecuteOnUpdateFileEraseConfirmationSelection(uint16_t optionIndex);
extern "C" void GameInteractor_ExecuteOnUpdateFileAudioSelection(uint8_t optionIndex);
extern "C" void GameInteractor_ExecuteOnUpdateFileTargetSelection(uint8_t optionIndex);
void GameInteractor_ExecuteOnPresentFileSelect();
void GameInteractor_ExecuteOnUpdateFileSelectSelection(uint16_t optionIndex);
void GameInteractor_ExecuteOnUpdateFileCopySelection(uint16_t optionIndex);
void GameInteractor_ExecuteOnUpdateFileCopyConfirmationSelection(uint16_t optionIndex);
void GameInteractor_ExecuteOnUpdateFileEraseSelection(uint16_t optionIndex);
void GameInteractor_ExecuteOnUpdateFileEraseConfirmationSelection(uint16_t optionIndex);
void GameInteractor_ExecuteOnUpdateFileAudioSelection(uint8_t optionIndex);
void GameInteractor_ExecuteOnUpdateFileTargetSelection(uint8_t optionIndex);

// MARK: - Game
extern "C" void GameInteractor_ExecuteOnSetGameLanguage();
void GameInteractor_ExecuteOnSetGameLanguage();
#ifdef __cplusplus
}
#endif
1 change: 1 addition & 0 deletions soh/soh/Enhancements/gameplaystats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ void SetupDisplayNames() {
strcpy(itemTimestampDisplayName[TIMESTAMP_DEFEAT_TWINROVA], "Twinrova Defeated: ");
strcpy(itemTimestampDisplayName[TIMESTAMP_DEFEAT_GANONDORF], "Ganondorf Defeated: ");
strcpy(itemTimestampDisplayName[TIMESTAMP_DEFEAT_GANON], "Ganon Defeated: ");
strcpy(itemTimestampDisplayName[TIMESTAMP_FOUND_GREG], "Greg Found: ");
}

void SetupDisplayColors() {
Expand Down
19 changes: 19 additions & 0 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,24 @@ void RegisterBonkDamage() {
});
}

void UpdateDirtPathFixState(int32_t sceneNum) {
switch (sceneNum) {
case SCENE_SPOT00:
case SCENE_SPOT04:
case SCENE_SPOT15:
CVarSetInteger("gDirtPathFix", CVarGetInteger("gSceneSpecificDirtPathFix", 0));
return;
default:
CVarClear("gDirtPathFix");
}
}

void RegisterMenuPathFix() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnTransitionEnd>([](int32_t sceneNum) {
UpdateDirtPathFixState(sceneNum);
});
}

void InitMods() {
RegisterTTS();
RegisterInfiniteMoney();
Expand All @@ -504,4 +522,5 @@ void InitMods() {
RegisterRupeeDash();
RegisterHyperBosses();
RegisterBonkDamage();
RegisterMenuPathFix();
}
3 changes: 3 additions & 0 deletions soh/soh/Enhancements/mods.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include <stdint.h>

#ifndef MODS_H
#define MODS_H

#ifdef __cplusplus
extern "C" {
#endif

void UpdateDirtPathFixState(int32_t sceneNum);
void InitMods();

#ifdef __cplusplus
Expand Down
15 changes: 5 additions & 10 deletions soh/soh/Enhancements/randomizer/3drando/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t>
srand(time(NULL));
// if a blank seed was entered, make a random one
if (seedString.empty()) {
Settings::seed = rand() & 0xFFFFFFFF;
seedString = std::to_string(rand() % 0xFFFFFFFF);
} else if (seedString.rfind("seed_testing_count", 0) == 0 && seedString.length() > 18) {
int count;
try {
Expand All @@ -530,17 +530,12 @@ std::string GenerateRandomizer(std::unordered_map<RandomizerSettingKey, uint8_t>
}
Playthrough::Playthrough_Repeat(cvarSettings, excludedLocations, count);
return "";
} else {
try {
uint32_t seedHash = boost::hash_32<std::string>{}(seedString);
int seed = seedHash & 0xFFFFFFFF;
Settings::seed = seed;
Settings::seedString = seedString;
} catch (...) {
return "";
}
}

Settings::seedString = seedString;
uint32_t seedHash = boost::hash_32<std::string>{}(Settings::seedString);
Settings::seed = seedHash & 0xFFFFFFFF;

int ret = Playthrough::Playthrough_Init(Settings::seed, cvarSettings, excludedLocations);
if (ret < 0) {
if (ret == -1) { // Failed to generate after 5 tries
Expand Down
5 changes: 3 additions & 2 deletions soh/soh/Enhancements/randomizer/3drando/playthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ int Playthrough_Repeat(std::unordered_map<RandomizerSettingKey, uint8_t> cvarSet
printf("\x1b[0;0HGENERATING %d SEEDS", count);
uint32_t repeatedSeed = 0;
for (int i = 0; i < count; i++) {
repeatedSeed = rand() % 0xFFFFFFFF;
Settings::seed = repeatedSeed;
Settings::seedString = std::to_string(rand() % 0xFFFFFFFF);
repeatedSeed = boost::hash_32<std::string>{}(Settings::seedString);
Settings::seed = repeatedSeed % 0xFFFFFFFF;
CitraPrint("testing seed: " + std::to_string(Settings::seed));
ClearProgress();
Playthrough_Init(Settings::seed, cvarSettings, excludedLocations);
Expand Down
4 changes: 2 additions & 2 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3149,8 +3149,8 @@ void DrawRandoEditor(bool& open) {
}

UIWidgets::Spacer(0);
if (ImGui::Button("Generate Randomizer")) {
GenerateRandomizer(CVarGetInteger("gRandoManualSeedEntry", 0) ? seedString : std::to_string(rand() & 0xFFFFFFFF).c_str());
if (ImGui::Button("Generate Randomizer")) {
GenerateRandomizer(CVarGetInteger("gRandoManualSeedEntry", 0) ? seedString : "");
}

UIWidgets::Spacer(0);
Expand Down
6 changes: 3 additions & 3 deletions soh/soh/Extractor/Extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ void Extractor::GetRoms(std::vector<std::string>& roms) {
if (S_ISREG(path.st_mode)) {

// Get the position of the extension character.
char* ext = strchr(dir->d_name, '.');
if (ext != NULL && (strcmp(ext, ".z64") == 0) && (strcmp(ext, ".n64") == 0) &&
(strcmp(ext, ".v64") == 0)) {
char* ext = strrchr(dir->d_name, '.');
if (ext != NULL && (strcmp(ext, ".z64") == 0 || strcmp(ext, ".n64") == 0 ||
strcmp(ext, ".v64") == 0)) {
roms.push_back(dir->d_name);
}
}
Expand Down
7 changes: 6 additions & 1 deletion soh/soh/GameMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "soh/SaveManager.h"
#include "OTRGlobals.h"
#include "soh/Enhancements/presets.h"
#include "soh/Enhancements/mods.h"
#include "soh/resource/type/Skeleton.h"

#ifdef ENABLE_CROWD_CONTROL
Expand All @@ -46,6 +47,8 @@ extern "C" {
void disableBetaQuest() { isBetaQuestEnabled = false; }
}

extern "C" PlayState* gPlayState;

enum SeqPlayers {
/* 0 */ SEQ_BGM_MAIN,
/* 1 */ SEQ_FANFARE,
Expand Down Expand Up @@ -860,7 +863,9 @@ namespace GameMenuBar {
ImGui::EndMenu();
}
UIWidgets::PaddedText("Fix Vanishing Paths", true, false);
UIWidgets::EnhancementCombobox("gDirtPathFix", zFightingOptions, 0);
if (UIWidgets::EnhancementCombobox("gSceneSpecificDirtPathFix", zFightingOptions, 0) && gPlayState != NULL) {
UpdateDirtPathFixState(gPlayState->sceneNum);
}
UIWidgets::Tooltip("Disabled: Paths vanish more the higher the resolution (Z-fighting is based on resolution)\n"
"Consistent: Certain paths vanish the same way in all resolutions\n"
"No Vanish: Paths do not vanish, Link seems to sink in to some paths\n"
Expand Down
7 changes: 5 additions & 2 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,10 @@ std::unordered_map<uint32_t, uint32_t> ItemIDtoGetItemID{
{ ITEM_WEIRD_EGG, GI_WEIRD_EGG }
};

extern "C" uint32_t GetGIID(uint32_t itemID) {
if (ItemIDtoGetItemID.contains(itemID))
extern "C" int32_t GetGIID(uint32_t itemID) {
if (ItemIDtoGetItemID.contains(itemID)) {
return ItemIDtoGetItemID.at(itemID);
}
return -1;
}

Expand Down Expand Up @@ -782,6 +783,8 @@ extern "C" void InitOTR() {
} else {
CVarClear("gLetItSnow");
}

srand(now);
#ifdef ENABLE_CROWD_CONTROL
CrowdControl::Instance = new CrowdControl();
CrowdControl::Instance->Init();
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/OTRGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void EntranceTracker_SetLastEntranceOverride(s16 entranceIndex);
void Gfx_RegisterBlendedTexture(const char* name, u8* mask, u8* replacement);
void SaveManager_ThreadPoolWait();

uint32_t GetGIID(uint32_t itemID);
int32_t GetGIID(uint32_t itemID);
#endif

#endif
12 changes: 8 additions & 4 deletions soh/soh/SaveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,18 @@ void SaveManager::SaveFileThreaded(int fileNum, SaveContext* saveContext) {
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnSaveFile>(fileNum);
}

void SaveManager::SaveFile(int fileNum) {
void SaveManager::SaveFile(int fileNum, bool threaded) {
if (fileNum == 0xFF) {
return;
}
// Can't think of any time the promise would be needed, so use push_task instead of submit
auto saveContext = new SaveContext;
memcpy(saveContext, &gSaveContext, sizeof(gSaveContext));
smThreadPool->push_task_back(&SaveManager::SaveFileThreaded, this, fileNum, saveContext);
if (threaded) {
smThreadPool->push_task_back(&SaveManager::SaveFileThreaded, this, fileNum, saveContext);
} else {
SaveFileThreaded(fileNum, saveContext);
}
}

void SaveManager::SaveGlobal() {
Expand Down Expand Up @@ -2143,7 +2147,7 @@ void SaveManager::ConvertFromUnversioned() {
static SaveContext saveContextSave = gSaveContext;
InitFile(false);
CopyV0Save(*file, gSaveContext);
SaveFile(fileNum);
SaveFile(fileNum, false);
InitMeta(fileNum);
gSaveContext = saveContextSave;
}
Expand All @@ -2164,7 +2168,7 @@ extern "C" void Save_InitFile(int isDebug) {
}

extern "C" void Save_SaveFile(void) {
SaveManager::Instance->SaveFile(gSaveContext.fileNum);
SaveManager::Instance->SaveFile(gSaveContext.fileNum, true);
}

extern "C" void Save_SaveGlobal(void) {
Expand Down
Loading

0 comments on commit fe6705c

Please sign in to comment.