From e78a208bbd0fe1faad7a584a2e47b777b0da5d2b Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Mon, 24 May 2021 11:00:56 -0700 Subject: [PATCH] Add asset_cg_exists function --- include/asset_manager.h | 1 + src/asset_manager.c | 9 +++++++++ src/hll/SACT2.c | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/asset_manager.h b/include/asset_manager.h index 9ceb0a7..6711602 100644 --- a/include/asset_manager.h +++ b/include/asset_manager.h @@ -42,6 +42,7 @@ struct archive_data *asset_get(enum asset_type type, int no); // FIXME: CG code should be refactored to read from buffer only, not archive, // then caller can just use asset_get and cg_load struct cg *asset_cg_load(int no); +bool asset_cg_exists(int no); bool asset_cg_get_metrics(int no, struct cg_metrics *metrics); void asset_cg_index_init(void); diff --git a/src/asset_manager.c b/src/asset_manager.c index 6c53bf5..ce99217 100644 --- a/src/asset_manager.c +++ b/src/asset_manager.c @@ -279,6 +279,15 @@ struct cg *asset_cg_load(int no) return cg_load(archives[ASSET_CG], no - 1); } +bool asset_cg_exists(int no) +{ + if (!archives[ASSET_CG]) + return false; + if (!(no = cg_translate_index(no))) + return false; + return true; +} + bool asset_cg_get_metrics(int no, struct cg_metrics *metrics) { if (!archives[ASSET_CG]) diff --git a/src/hll/SACT2.c b/src/hll/SACT2.c index c0abf42..867e3b6 100644 --- a/src/hll/SACT2.c +++ b/src/hll/SACT2.c @@ -688,7 +688,7 @@ int sact_Key_IsDown(int keycode) int sact_CG_IsExist(int cg_no) { - return asset_exists(ASSET_CG, cg_no - 1); + return asset_cg_exists(cg_no); } //int SACT2_CSV_Load(struct string *filename);