mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
rando generation working, but lots of incorrect check strings
This commit is contained in:
parent
0113dc7fb4
commit
25706073ff
10 changed files with 47 additions and 20 deletions
|
@ -9,7 +9,6 @@
|
|||
#include <Lib/spdlog/include/spdlog/spdlog.h>
|
||||
|
||||
//Location definitions
|
||||
static std::array<ItemLocation, KEY_ENUM_MAX> locationTable;
|
||||
|
||||
void LocationTable_Init() {
|
||||
locationTable[NONE] = ItemLocation::Base (0xFF, 0xFF, "Invalid Location", NONE, NONE, {}, SpoilerCollectionCheck::None());
|
||||
|
@ -911,8 +910,8 @@ void LocationTable_Init() {
|
|||
locationTable[DMC_UPPER_GROTTO_GOSSIP_STONE] = ItemLocation::HintStone(0x00, 0x3A, "DMC Upper Grotto Gossip Stone", {});
|
||||
|
||||
locationTable[GANONDORF_HINT] = ItemLocation::OtherHint(0x00, 0x00, "Ganondorf Hint", {});
|
||||
|
||||
}
|
||||
|
||||
std::vector<uint32_t> KF_ShopLocations = {
|
||||
KF_SHOP_ITEM_1,
|
||||
KF_SHOP_ITEM_2,
|
||||
|
|
|
@ -515,14 +515,14 @@ void PrintOptionDescription() {
|
|||
printf("\x1b[22;0H%s", description.data());
|
||||
}
|
||||
|
||||
void GenerateRandomizer() {
|
||||
std::string GenerateRandomizer() {
|
||||
// if a blank seed was entered, make a random one
|
||||
if (Settings::seed.empty()) {
|
||||
Settings::seed = std::to_string(rand());
|
||||
} else if (Settings::seed.rfind("seed_testing_count", 0) == 0) {
|
||||
const int count = std::stoi(Settings::seed.substr(18), nullptr);
|
||||
Playthrough::Playthrough_Repeat(count);
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
|
||||
int ret = Playthrough::Playthrough_Init(std::hash<std::string>{}(Settings::seed));
|
||||
|
@ -531,10 +531,10 @@ void GenerateRandomizer() {
|
|||
printf("\n\nFailed to generate after 5 tries.\nPress B to go back to the menu.\nA different seed might be "
|
||||
"successful.");
|
||||
SPDLOG_INFO("\nRANDOMIZATION FAILED COMPLETELY. PLZ FIX\n");
|
||||
return;
|
||||
return "";
|
||||
} else {
|
||||
printf("\n\nError %d with fill.\nPress Select to exit or B to go back to the menu.\n", ret);
|
||||
return;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,6 +545,8 @@ void GenerateRandomizer() {
|
|||
}
|
||||
Settings::Keysanity.RestoreDelayedOption();
|
||||
}
|
||||
|
||||
return "./randomizer/" + Settings::seed + ".json";
|
||||
}
|
||||
|
||||
std::string GetInput(const char* hintText) {
|
||||
|
|
|
@ -43,7 +43,7 @@ void PrintResetToDefaultsMenu();
|
|||
void PrintGenerateMenu();
|
||||
void ClearDescription();
|
||||
void PrintOptionDescription();
|
||||
void GenerateRandomizer();
|
||||
std::string GenerateRandomizer();
|
||||
std::string GetInput(const char* hintText);
|
||||
|
||||
extern void MenuInit();
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
#include "item_location.hpp"
|
||||
#include "location_access.hpp"
|
||||
#include "rando_main.hpp"
|
||||
#include <soh/Enhancements/randomizer.h>
|
||||
#include <Cvar.h>
|
||||
#include <GameSettings.h>
|
||||
|
||||
#define TICKS_PER_SEC 268123480.0
|
||||
|
||||
|
@ -11,5 +14,8 @@ void RandoMain::GenerateRando() {
|
|||
HintTable_Init();
|
||||
ItemTable_Init();
|
||||
LocationTable_Init();
|
||||
GenerateRandomizer();
|
||||
|
||||
std::string fileName = GenerateRandomizer();
|
||||
CVar_SetString("gSpoilerLog", fileName.c_str());
|
||||
Game::SaveSettings();
|
||||
}
|
|
@ -19,6 +19,11 @@
|
|||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace {
|
||||
std::string placementtxt;
|
||||
|
@ -572,19 +577,22 @@ static void WriteHints(tinyxml2::XMLDocument& spoilerLog) {
|
|||
spoilerLog.RootElement()->InsertEndChild(parentNode);
|
||||
}
|
||||
|
||||
static void WriteAllLocations(tinyxml2::XMLDocument& spoilerLog) {
|
||||
auto parentNode = spoilerLog.NewElement("all-locations");
|
||||
static void WriteAllLocations() {
|
||||
json jsonLocations;
|
||||
|
||||
for (const uint32_t key : allLocations) {
|
||||
if (!Location(key)->IsHidden()) {
|
||||
WriteLocation(parentNode, key, true);
|
||||
}
|
||||
ItemLocation* location = Location(key);
|
||||
jsonLocations["locations"][location->GetName()] = location->GetPlacedItemName().english;
|
||||
}
|
||||
|
||||
spoilerLog.RootElement()->InsertEndChild(parentNode);
|
||||
std::string jsonString = jsonLocations.dump();
|
||||
|
||||
std::ofstream jsonFile("./randomizer/" + Settings::seed + ".json");
|
||||
jsonFile << std::setw(4) << jsonString << std::endl;
|
||||
jsonFile.close();
|
||||
}
|
||||
|
||||
bool SpoilerLog_Write() {
|
||||
const char* SpoilerLog_Write() {
|
||||
auto spoilerLog = tinyxml2::XMLDocument(false);
|
||||
spoilerLog.InsertEndChild(spoilerLog.NewDeclaration());
|
||||
|
||||
|
@ -613,10 +621,11 @@ bool SpoilerLog_Write() {
|
|||
|
||||
WriteHints(spoilerLog);
|
||||
WriteShuffledEntrances(spoilerLog);
|
||||
WriteAllLocations(spoilerLog);
|
||||
WriteAllLocations();
|
||||
|
||||
auto e = spoilerLog.SaveFile(GetSpoilerLogPath());
|
||||
return e == tinyxml2::XML_SUCCESS;
|
||||
|
||||
return Settings::seed.c_str();
|
||||
}
|
||||
|
||||
void PlacementLog_Msg(std::string_view msg) {
|
||||
|
|
|
@ -107,5 +107,5 @@ const RandomizerHash& GetRandomizerHash();
|
|||
|
||||
void WriteIngameSpoilerLog();
|
||||
|
||||
bool SpoilerLog_Write();
|
||||
const char* SpoilerLog_Write();
|
||||
const SpoilerData& GetSpoilerData();
|
|
@ -88,6 +88,7 @@ Randomizer::~Randomizer() {
|
|||
|
||||
std::unordered_map<std::string, RandomizerCheck> SpoilerfileCheckNameToEnum = {
|
||||
{"Links Pocket", RC_LINKS_POCKET},
|
||||
{"Link's Pocket", RC_LINKS_POCKET },
|
||||
{"Queen Gohma", RC_QUEEN_GOHMA},
|
||||
{"King Dodongo", RC_KING_DODONGO},
|
||||
{"Barinade", RC_BARINADE},
|
||||
|
@ -1169,6 +1170,7 @@ std::string sanitize(std::string stringValue) {
|
|||
|
||||
void Randomizer::ParseItemLocationsFile(const char* spoilerFileName) {
|
||||
// todo pull this in from cvar or something
|
||||
|
||||
std::ifstream spoilerFileStream(sanitize(spoilerFileName));
|
||||
if (!spoilerFileStream)
|
||||
return;
|
||||
|
@ -1211,7 +1213,7 @@ void Randomizer::ParseItemLocationsFile(const char* spoilerFileName) {
|
|||
success = true;
|
||||
} catch (const std::exception& e) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
|
|
|
@ -1029,6 +1029,10 @@ extern "C" s16 GetItemModelFromId(s16 itemId) {
|
|||
return OTRGlobals::Instance->gRandomizer->GetItemModelFromId(itemId);
|
||||
}
|
||||
|
||||
extern "C" void LoadItemLocations(const char* spoilerFileName) {
|
||||
OTRGlobals::Instance->gRandomizer->LoadItemLocations(spoilerFileName);
|
||||
}
|
||||
|
||||
extern "C" void ParseItemLocationsFile(const char* spoilerFileName) {
|
||||
OTRGlobals::Instance->gRandomizer->ParseItemLocationsFile(spoilerFileName);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,8 @@ int AudioPlayer_GetDesiredBuffered(void);
|
|||
void AudioPlayer_Play(const uint8_t* buf, uint32_t len);
|
||||
void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples);
|
||||
int Controller_ShouldRumble(size_t i);
|
||||
void ParseItemLocationsFile(const char* spoilerfilename);
|
||||
void LoadItemLocations(const char* spoilerFileName);
|
||||
void ParseItemLocationsFile(const char* spoilerFileName);
|
||||
s16 GetItemModelFromId(s16 itemId);
|
||||
s32 GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum);
|
||||
s32 GetRandomizedItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId);
|
||||
|
|
|
@ -1511,6 +1511,7 @@ void FileChoose_FadeOut(GameState* thisx) {
|
|||
* Note: On Debug ROM, File 1 will go to Map Select.
|
||||
* Update function for `SM_LOAD_GAME`
|
||||
*/
|
||||
|
||||
void FileChoose_LoadGame(GameState* thisx) {
|
||||
FileChooseContext* this = (FileChooseContext*)thisx;
|
||||
u16 swordEquipMask;
|
||||
|
@ -1533,6 +1534,9 @@ void FileChoose_LoadGame(GameState* thisx) {
|
|||
this->state.running = false;
|
||||
}
|
||||
|
||||
const char* fileLoc = CVar_GetString("gSpoilerLog", "");
|
||||
LoadItemLocations(fileLoc);
|
||||
|
||||
gSaveContext.respawn[0].entranceIndex = -1;
|
||||
gSaveContext.respawnFlag = 0;
|
||||
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue