Skip to content

Commit b401e12

Browse files
committed
Switch to filename, not id lookups, fix sprite load bug
1 parent ca7b593 commit b401e12

File tree

15 files changed

+58
-104
lines changed

15 files changed

+58
-104
lines changed

src/resources/af.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "resources/sprite.h"
55
#include <string.h>
66

7-
void af_create(af *a, void *src) {
7+
void af_create(af *a, void *src, str *name) {
88
sd_af_file *sdaf = (sd_af_file *)src;
99

1010
// Trivial stuff
@@ -32,12 +32,12 @@ void af_create(af *a, void *src) {
3232
for(int i = 0; i < 70; i++) {
3333
if(sdaf->moves[i] != NULL) {
3434
af_move *move = omf_calloc(1, sizeof(af_move));
35-
af_move_create(a->id, move, &a->sprites, (void *)sdaf->moves[i], i);
35+
af_move_create(name, move, &a->sprites, (void *)sdaf->moves[i], i);
3636
array_set(&a->moves, i, move);
3737
}
3838
}
3939

40-
modmanager_get_fighter_header(a->id, a);
40+
modmanager_get_fighter_header(name, a);
4141
}
4242

4343
af_move *af_get_move(const af *a, int id) {

src/resources/af.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ typedef struct af_t {
1818
char sound_translation_table[30];
1919
} af;
2020

21-
void af_create(af *a, void *src);
21+
void af_create(af *a, void *src, str *name);
2222
af_move *af_get_move(const af *a, int id);
2323
void af_free(af *a);
2424

src/resources/af_loader.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ int load_af_file(af *a, int id) {
99
// Get directory + filename
1010
const path filename = get_resource_filename(get_resource_file(id));
1111

12+
str fn;
13+
path_stem(&filename, &fn);
14+
1215
// Load up AF file from libSD
1316
sd_af_file tmp;
1417
if(sd_af_create(&tmp) != SD_SUCCESS) {
@@ -20,7 +23,7 @@ int load_af_file(af *a, int id) {
2023
}
2124

2225
// Convert
23-
af_create(a, &tmp);
26+
af_create(a, &tmp, &fn);
2427
sd_af_free(&tmp);
2528
return 0;
2629
}

src/resources/af_move.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "formats/move.h"
33
#include "resources/modmanager.h"
44

5-
void af_move_create(int file_id, af_move *move, array *sprites, void *src, int id) {
5+
void af_move_create(str *name, af_move *move, array *sprites, void *src, int id) {
66
sd_move *sdmv = (sd_move *)src;
77
str_from_c(&move->move_string, sdmv->move_string);
88
str_from_c(&move->footer_string, sdmv->footer_string);
@@ -18,8 +18,8 @@ void af_move_create(int file_id, af_move *move, array *sprites, void *src, int i
1818
move->pos_constraints = sdmv->pos_constraint;
1919
move->throw_duration = sdmv->throw_duration;
2020
move->extra_string_selector = sdmv->extra_string_selector;
21-
animation_create(AF_ANIMATION, file_id, &move->ani, sprites, sdmv->animation, id);
22-
modmanager_get_af_move(file_id, id, move);
21+
animation_create(AF_ANIMATION, name, &move->ani, sprites, sdmv->animation, id);
22+
modmanager_get_af_move(name, id, move);
2323
if(id == ANIM_JUMPING) {
2424
// fixup the jump coordinates
2525
animation_fixup_coordinates(&move->ani, 0, JUMP_COORD_ADJUSTMENT * -1);

src/resources/af_move.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef struct af_move_t {
2828
#endif
2929
} af_move;
3030

31-
void af_move_create(int file_id, af_move *move, array *sprites, void *src, int id);
31+
void af_move_create(str *name, af_move *move, array *sprites, void *src, int id);
3232
void af_move_free(af_move *move);
3333

3434
#endif // AF_MOVE_H

src/resources/animation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ typedef struct sprite_reference_t {
88
sprite *sprite;
99
} sprite_reference;
1010

11-
void animation_create(animation_source type, int file_id, animation *ani, array *sprites, void *src, int id) {
11+
void animation_create(animation_source type, str *name, animation *ani, array *sprites, void *src, int id) {
1212
sd_animation *sdani = (sd_animation *)src;
1313

1414
// Copy simple stuff
@@ -52,7 +52,7 @@ void animation_create(animation_source type, int file_id, animation *ani, array
5252
tmp_sprite = omf_calloc(1, sizeof(sprite));
5353
sd_sprite *sp;
5454
// TODO check the mod overrides for a replacement sprite
55-
if(modmanager_get_sprite(type, file_id, ani->id, i, &sp)) {
55+
if(modmanager_get_sprite(type, name, ani->id, i, &sp)) {
5656
sprite_create(tmp_sprite, (void *)sp, i);
5757
tmp_sprite->data->render_w = sdani->sprites[i]->width;
5858
tmp_sprite->data->render_h = sdani->sprites[i]->height;

src/resources/animation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef struct animation_t {
5252
vector sprites;
5353
} animation;
5454

55-
void animation_create(animation_source type, int file_id, animation *ani, array *sprites, void *src, int id);
55+
void animation_create(animation_source type, str *name, animation *ani, array *sprites, void *src, int id);
5656
sprite *animation_get_sprite(animation *ani, int sprite_id);
5757
void animation_free(animation *ani);
5858

src/resources/bk.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
#include "utils/log.h"
66
#include <string.h>
77

8-
void bk_create(bk *b, void *src) {
8+
void bk_create(bk *b, void *src, str *name) {
99
sd_bk_file *sdbk = (sd_bk_file *)src;
1010

1111
// File ID
1212
b->file_id = sdbk->file_id;
1313

1414
// Copy VGA image
1515
sd_vga_image *img;
16-
if(modmanager_get_bk_background(b->file_id, &img)) {
16+
if(modmanager_get_bk_background(name, &img)) {
1717
log_info("using modified BK background");
1818
surface_create_from_vga(&b->background, img);
1919
b->background.render_w = 320;
@@ -41,7 +41,7 @@ void bk_create(bk *b, void *src) {
4141
bk_info tmp_bk_info;
4242
for(int i = 0; i < 50; i++) {
4343
if(sdbk->anims[i] != NULL) {
44-
bk_info_create(b->file_id, &tmp_bk_info, &b->sprites, (void *)sdbk->anims[i], i);
44+
bk_info_create(name, &tmp_bk_info, &b->sprites, (void *)sdbk->anims[i], i);
4545
hashmap_put_int(&b->infos, i, &tmp_bk_info, sizeof(bk_info));
4646
}
4747
}

src/resources/bk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ typedef struct bk_t {
1616
char sound_translation_table[30];
1717
} bk;
1818

19-
void bk_create(bk *b, void *src);
19+
void bk_create(bk *b, void *src, str *name);
2020
bk_info *bk_get_info(bk *b, int id);
2121
vga_palette *bk_get_palette(bk *b, int id);
2222
vga_remap_tables *bk_get_remaps(bk *b, int id);

src/resources/bk_info.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
#include "formats/bkanim.h"
33
#include "resources/modmanager.h"
44

5-
void bk_info_create(int file_id, bk_info *info, array *sprites, void *src, int id) {
5+
void bk_info_create(str *name, bk_info *info, array *sprites, void *src, int id) {
66
sd_bk_anim *sdinfo = (sd_bk_anim *)src;
7-
animation_create(BK_ANIMATION, file_id, &info->ani, sprites, sdinfo->animation, id);
8-
// TODO check for mod data here
7+
animation_create(BK_ANIMATION, name, &info->ani, sprites, sdinfo->animation, id);
98
info->chain_hit = sdinfo->chain_hit;
109
info->chain_no_hit = sdinfo->chain_no_hit;
1110
info->load_on_start = sdinfo->load_on_start;
1211
info->probability = sdinfo->probability;
1312
info->hazard_damage = sdinfo->hazard_damage;
1413
str_from_c(&info->footer_string, sdinfo->footer_string);
15-
modmanager_get_bk_animation(file_id, id, info);
14+
modmanager_get_bk_animation(name, id, info);
1615
}
1716

1817
void bk_info_free(bk_info *info) {

0 commit comments

Comments
 (0)