mirror of
https://github.com/kichikuou/system3-sdl2.git
synced 2026-10-03 04:18:04 +03:00
Reorganize initialization error reporting
- Invalid game id -> sys_error() in GameId::GameId() - Unknown crc32 -> SDL_ShowSimpleMessageBox() in GameId::GameId() - Cannot open ADISK.DAT -> sys_error() in NACT::NACT()
This commit is contained in:
@@ -31,13 +31,6 @@ SDL_Window* create_window(const GameId& game_id)
|
||||
if (game_id.title) {
|
||||
title += ": ";
|
||||
title += game_id.title;
|
||||
} else {
|
||||
SDL_ShowSimpleMessageBox(
|
||||
SDL_MESSAGEBOX_WARNING, "system3",
|
||||
"Unable to determine game ID.\n"
|
||||
"If you are running a modified game, please specify 'game = <original-game-id>' in system3.ini.\n"
|
||||
"See README.md for more information.",
|
||||
NULL);
|
||||
}
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
@@ -81,9 +74,6 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
GameId game_id(config);
|
||||
if (!game_id.is_valid()) {
|
||||
sys_error("No game files in the current directory.");
|
||||
}
|
||||
|
||||
g_window = create_window(game_id);
|
||||
g_renderer = SDL_CreateRenderer(g_window, -1, 0);
|
||||
|
||||
@@ -17,6 +17,7 @@ class Dri {
|
||||
public:
|
||||
void open(const char* file_name);
|
||||
std::vector<uint8_t> load(int page);
|
||||
bool loaded() const { return !link_table.empty(); }
|
||||
|
||||
static std::vector<uint8_t> load_mda(const GameId& game_id, int page);
|
||||
|
||||
|
||||
+10
-1
@@ -197,12 +197,21 @@ GameId::GameId(const Config& config)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!entry)
|
||||
sys_error("Unknown game ID: %s", config.game_id.c_str());
|
||||
} else {
|
||||
uint32_t crc32_a = calc_crc32("ADISK.DAT");
|
||||
uint32_t crc32_b = calc_crc32("BDISK.DAT");
|
||||
entry = lookup(crc32_a, crc32_b);
|
||||
if (!entry)
|
||||
if (crc32_a && !entry) {
|
||||
WARNING("Cannot determine game id. crc32_a: %08x, crc32_b: %08x", crc32_a, crc32_b);
|
||||
SDL_ShowSimpleMessageBox(
|
||||
SDL_MESSAGEBOX_WARNING, "system3",
|
||||
"Unable to determine game ID.\n"
|
||||
"If you are running a modified game, please specify 'game = <original-game-id>' in system3.ini.\n"
|
||||
"See README.md for more information.",
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
if (entry) {
|
||||
game = entry->game;
|
||||
|
||||
@@ -53,6 +53,8 @@ NACT::NACT(const Config& config, const GameId& game_id)
|
||||
sco.open("AGAME.DAT");
|
||||
else
|
||||
sco.open("ADISK.DAT");
|
||||
if (!sco.loaded())
|
||||
sys_error("Cannot open scenario file");
|
||||
sco.page_jump(0, 2);
|
||||
|
||||
// 各種クラス生成
|
||||
|
||||
@@ -11,6 +11,7 @@ class Encoding;
|
||||
class Scenario {
|
||||
public:
|
||||
void open(const char* file_name) { adisk.open(file_name); }
|
||||
bool loaded() const { return adisk.loaded(); }
|
||||
void page_jump(int page, int addr);
|
||||
int default_addr() { return data_[0] | data_[1] << 8; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user