add yaze_check_version and core::CheckVersion
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
@@ -322,6 +323,17 @@ void ApplyBpsPatch(const std::vector<uint8_t> &source,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
absl::StatusOr<std::string> CheckVersion(const char* version) {
|
||||||
|
std::string version_string = version;
|
||||||
|
if (version_string != kYazeVersion) {
|
||||||
|
std::string message = absl::StrFormat(
|
||||||
|
"Yaze version mismatch: expected %s, got %s", kYazeVersion,
|
||||||
|
version_string.c_str());
|
||||||
|
return absl::InvalidArgumentError(message);
|
||||||
|
}
|
||||||
|
return version_string;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace core
|
} // namespace core
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -271,6 +271,8 @@ void ApplyBpsPatch(const std::vector<uint8_t> &source,
|
|||||||
const std::vector<uint8_t> &patch,
|
const std::vector<uint8_t> &patch,
|
||||||
std::vector<uint8_t> &target);
|
std::vector<uint8_t> &target);
|
||||||
|
|
||||||
|
absl::StatusOr<std::string> CheckVersion(const char *version);
|
||||||
|
|
||||||
} // namespace core
|
} // namespace core
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
13
src/yaze.cc
13
src/yaze.cc
@@ -1,8 +1,21 @@
|
|||||||
#include "yaze.h"
|
#include "yaze.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/zelda3/overworld/overworld.h"
|
#include "app/zelda3/overworld/overworld.h"
|
||||||
|
|
||||||
|
void yaze_check_version(const char* version) {
|
||||||
|
auto version_check = yaze::app::core::CheckVersion(version);
|
||||||
|
if (!version_check.ok()) {
|
||||||
|
// Print the error message to the console for a pure C interface.
|
||||||
|
printf("%s\n", version_check.status().message().c_str());
|
||||||
|
// Exit the program if the version check fails.
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void yaze_init(yaze_flags* flags) {
|
void yaze_init(yaze_flags* flags) {
|
||||||
if (flags == nullptr) {
|
if (flags == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ struct yaze_flags {
|
|||||||
z3_rom* rom;
|
z3_rom* rom;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void yaze_check_version(const char* version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize the Yaze library.
|
* @brief Initialize the Yaze library.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user