mirror of
https://github.com/N64Recomp/N64ModernRuntime.git
synced 2026-05-10 19:01:53 +00:00
force passing game_id to keep compatibility with existing saves
This commit is contained in:
parent
9307b56f46
commit
4408381f6f
3 changed files with 18 additions and 11 deletions
|
|
@ -9,16 +9,18 @@
|
|||
|
||||
namespace recomp {
|
||||
struct GameHandle {
|
||||
uint64_t id;
|
||||
std::u8string_view id;
|
||||
};
|
||||
struct GameEntry {
|
||||
uint64_t rom_hash;
|
||||
std::string internal_name;
|
||||
void (*entrypoint)();
|
||||
std::u8string_view game_id;
|
||||
std::span<const char> cache_data;
|
||||
bool is_enabled;
|
||||
|
||||
std::string stored_filename() const;
|
||||
void (*entrypoint)();
|
||||
|
||||
std::u8string stored_filename() const;
|
||||
};
|
||||
enum class RomValidationError {
|
||||
Good,
|
||||
|
|
@ -43,6 +45,7 @@ namespace recomp {
|
|||
void start_game(GameHandle game);
|
||||
void message_box(const char* message);
|
||||
std::filesystem::path get_app_folder_path();
|
||||
std::u8string_view current_game_id();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include <mutex>
|
||||
#include "recomp.h"
|
||||
#include "recomp_game.h"
|
||||
#include "recomp_config.h"
|
||||
#include <ultramodern/ultra64.h>
|
||||
#include <ultramodern/ultramodern.hpp>
|
||||
|
||||
|
|
@ -95,7 +94,7 @@ struct {
|
|||
} save_context;
|
||||
|
||||
const std::u8string save_folder = u8"saves";
|
||||
const std::u8string save_filename = std::u8string{recomp::mm_game_id} + u8".bin";
|
||||
const std::u8string save_filename = std::u8string{recomp::current_game_id()} + u8".bin";
|
||||
|
||||
std::filesystem::path get_save_file_path() {
|
||||
return recomp::get_app_folder_path() / save_folder / save_filename;
|
||||
|
|
|
|||
|
|
@ -40,16 +40,16 @@ std::mutex current_game_mutex;
|
|||
|
||||
// Global variables
|
||||
std::vector<char> patch_data;
|
||||
std::unordered_map<uint64_t, recomp::GameEntry> game_roms {};
|
||||
std::unordered_map<std::u8string_view, recomp::GameEntry> game_roms {};
|
||||
|
||||
std::string recomp::GameEntry::stored_filename() const {
|
||||
return std::to_string(rom_hash) + ".z64";
|
||||
std::u8string recomp::GameEntry::stored_filename() const {
|
||||
return std::u8string{game_id} + u8".z64";
|
||||
}
|
||||
|
||||
recomp::GameHandle recomp::register_game(const recomp::GameEntry& entry) {
|
||||
std::lock_guard<std::mutex> lock(game_roms_mutex);
|
||||
game_roms.insert({ entry.rom_hash, entry });
|
||||
return { entry.rom_hash };
|
||||
game_roms.insert({ entry.game_id, entry });
|
||||
return { entry.game_id };
|
||||
}
|
||||
|
||||
void recomp::register_patch(const char* patch, std::size_t size) {
|
||||
|
|
@ -129,7 +129,7 @@ bool check_stored_rom(const recomp::GameEntry& game_entry) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static std::unordered_set<uint64_t> valid_game_roms;
|
||||
static std::unordered_set<std::u8string_view> valid_game_roms;
|
||||
|
||||
bool recomp::is_rom_valid(recomp::GameHandle game) {
|
||||
return valid_game_roms.contains(game.id);
|
||||
|
|
@ -394,6 +394,11 @@ void init(uint8_t* rdram, recomp_context* ctx) {
|
|||
std::optional<recomp::GameHandle> current_game = std::nullopt;
|
||||
std::atomic<GameStatus> game_status = GameStatus::None;
|
||||
|
||||
std::u8string_view recomp::current_game_id() {
|
||||
std::lock_guard<std::mutex> lock(current_game_mutex);
|
||||
return current_game.value().id;
|
||||
};
|
||||
|
||||
void recomp::start_game(recomp::GameHandle game) {
|
||||
std::lock_guard<std::mutex> lock(current_game_mutex);
|
||||
current_game = game;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue