Refactor yaze_init and yaze_cleanup to use project ROM filename and simplify header includes

This commit is contained in:
scawful
2024-11-15 23:40:57 -05:00
parent cb7e8fc6ec
commit 1e330f4a72
2 changed files with 10 additions and 13 deletions

View File

@@ -16,16 +16,12 @@ void yaze_check_version(const char* version) {
}
int yaze_init(yaze_editor_context* yaze_ctx) {
if (yaze_ctx->flags == nullptr) {
if (yaze_ctx->project->rom_filename == nullptr) {
return -1;
}
if (yaze_ctx->flags->rom_filename == nullptr) {
return -1;
}
yaze_ctx->flags->rom = yaze_load_rom(yaze_ctx->flags->rom_filename);
if (yaze_ctx->flags->rom == nullptr) {
yaze_ctx->rom = yaze_load_rom(yaze_ctx->project->rom_filename);
if (yaze_ctx->rom == nullptr) {
return -1;
}
@@ -33,8 +29,8 @@ int yaze_init(yaze_editor_context* yaze_ctx) {
}
void yaze_cleanup(yaze_editor_context* yaze_ctx) {
if (yaze_ctx->flags->rom) {
yaze_unload_rom(yaze_ctx->flags->rom);
if (yaze_ctx->rom) {
yaze_unload_rom(yaze_ctx->rom);
}
}

View File

@@ -8,10 +8,10 @@ extern "C" {
#include <stddef.h>
#include <stdint.h>
#include "incl/dungeon.h"
#include "incl/overworld.h"
#include "incl/snes_color.h"
#include "incl/sprite.h"
#include "dungeon.h"
#include "overworld.h"
#include "snes_color.h"
#include "sprite.h"
typedef struct z3_rom z3_rom;
@@ -23,6 +23,7 @@ typedef struct yaze_event_dispatcher yaze_event_dispatcher;
* @brief Extension editor context.
*/
typedef struct yaze_editor_context {
z3_rom* rom;
yaze_project* project;
yaze_command_registry* command_registry;