diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-01-27 13:41:14 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-01-27 17:38:12 +0100 |
| commit | daf6f84ccdf817f7088aa527b4b37c2cca91c052 (patch) | |
| tree | f2676fd88c5c87bc7731fc9a92ecad898ee0d689 /src/gfx | |
| parent | da33e4668b23d3280f96d2ec0df68a829a0ef2d5 (diff) | |
| download | jancity-daf6f84ccdf817f7088aa527b4b37c2cca91c052.tar.gz | |
gfx: Add return value to *_sort functions
Diffstat (limited to 'src/gfx')
| -rw-r--r-- | src/gfx/inc/gfx.h | 8 | ||||
| -rw-r--r-- | src/gfx/ps1/src/sort.c | 12 | ||||
| -rw-r--r-- | src/gfx/sdl-1.2/src/env.c | 12 | ||||
| -rw-r--r-- | src/gfx/sdl-1.2/src/line.c | 3 | ||||
| -rw-r--r-- | src/gfx/sdl-1.2/src/quad.c | 7 | ||||
| -rw-r--r-- | src/gfx/sdl-1.2/src/rect.c | 6 | ||||
| -rw-r--r-- | src/gfx/sdl-1.2/src/sprite.c | 7 |
7 files changed, 38 insertions, 17 deletions
diff --git a/src/gfx/inc/gfx.h b/src/gfx/inc/gfx.h index a6a16bc..99deeeb 100644 --- a/src/gfx/inc/gfx.h +++ b/src/gfx/inc/gfx.h @@ -17,14 +17,14 @@ int gfx_set_fullscreen(short w, short h); bool gfx_fullscreen_available(void); bool gfx_fullscreen(void); int gfx_display_size(short *w, short *h); -void sprite_sort(struct sprite *s); +int sprite_sort(struct sprite *s); int sprite_clone(const struct sprite *src, struct sprite *dst); void rect_init(struct rect *r); void semitrans_rect_init(struct rect *r); void stp_4line_init(struct stp_4line *l); -void quad_sort(struct quad *q); -void rect_sort(struct rect *r); -void stp_4line_sort(struct stp_4line *l); +int quad_sort(struct quad *q); +int rect_sort(struct rect *r); +int stp_4line_sort(struct stp_4line *l); int sprite_from_fp(struct sprite *s, FILE *f); int quad_from_sprite(const struct sprite *s, struct quad *q); bool gfx_inside_drawenv(short x, short y, short w, short h); diff --git a/src/gfx/ps1/src/sort.c b/src/gfx/ps1/src/sort.c index c517b89..3f949be 100644 --- a/src/gfx/ps1/src/sort.c +++ b/src/gfx/ps1/src/sort.c @@ -19,24 +19,28 @@ static void add_to_list(union gfx_sznext *const p) last = p; } -void sprite_sort(struct sprite *const s) +int sprite_sort(struct sprite *const s) { add_to_list(&s->sznext); + return 0; } -void quad_sort(struct quad *const q) +int quad_sort(struct quad *const q) { add_to_list(&q->sznext); + return 0; } -void rect_sort(struct rect *const r) +int rect_sort(struct rect *const r) { add_to_list(&r->sznext); + return 0; } -void stp_4line_sort(struct stp_4line *const l) +int stp_4line_sort(struct stp_4line *const l) { add_to_list(&l->sznext); + return 0; } static void gfx_sync(void) diff --git a/src/gfx/sdl-1.2/src/env.c b/src/gfx/sdl-1.2/src/env.c index 734fe5b..c1376c5 100644 --- a/src/gfx/sdl-1.2/src/env.c +++ b/src/gfx/sdl-1.2/src/env.c @@ -98,7 +98,10 @@ static int resize_screen(int w, int h, const bool full_screen) for (size_t i = 0; i < list_len; i++) if (sprite_screen_resize_ev(list[i])) + { + fprintf(stderr, "%s: sprite_screen_resize_ev failed\n", __func__); return -1; + } screen_w = w; screen_h = h; @@ -152,14 +155,16 @@ static int get_resize_events(void) const SDL_ResizeEvent *const res = &ev.resize; if (resize_screen(res->w, res->h, false)) + { + fprintf(stderr, "%s: resize_screen failed\n", __func__); return -1; + } } } if (n < 0) { - fprintf(stderr, "%s: SDL_PeepEvents: %s\n", - __func__, SDL_GetError()); + fprintf(stderr, "%s: SDL_PeepEvents: %s\n", __func__, SDL_GetError()); return -1; } @@ -208,6 +213,5 @@ int gfx_draw(void) return -1; } - get_resize_events(); - return 0; + return get_resize_events(); } diff --git a/src/gfx/sdl-1.2/src/line.c b/src/gfx/sdl-1.2/src/line.c index 3886204..7788acf 100644 --- a/src/gfx/sdl-1.2/src/line.c +++ b/src/gfx/sdl-1.2/src/line.c @@ -11,6 +11,7 @@ void semitrans_stp_4line_init(struct stp_4line *r) { } -void stp_4line_sort(struct stp_4line *const r) +int stp_4line_sort(struct stp_4line *const r) { + return 0; } diff --git a/src/gfx/sdl-1.2/src/quad.c b/src/gfx/sdl-1.2/src/quad.c index 0bdead6..f57ff9e 100644 --- a/src/gfx/sdl-1.2/src/quad.c +++ b/src/gfx/sdl-1.2/src/quad.c @@ -17,7 +17,7 @@ int quad_from_sprite(const struct sprite *const s, struct quad *const q) return 0; } -void quad_sort(struct quad *const q) +int quad_sort(struct quad *const q) { const bool xflip = q->x0 > q->x1; @@ -40,5 +40,10 @@ void quad_sort(struct quad *const q) SDL_Surface *const s = xflip ? q->s_x : q->s; if (SDL_BlitSurface(s, &clip, gfx_screen(), &r)) + { fprintf(stderr, "SDL_BlitSurface: %s\n", SDL_GetError()); + return -1; + } + + return 0; } diff --git a/src/gfx/sdl-1.2/src/rect.c b/src/gfx/sdl-1.2/src/rect.c index bf4b54d..0998cb5 100644 --- a/src/gfx/sdl-1.2/src/rect.c +++ b/src/gfx/sdl-1.2/src/rect.c @@ -3,7 +3,7 @@ #include <sdl-1.2/gfx_private.h> #include <SDL.h> -void rect_sort(struct rect *const r) +int rect_sort(struct rect *const r) { SDL_Rect rct = { @@ -19,8 +19,10 @@ void rect_sort(struct rect *const r) if (SDL_FillRect(screen, &rct, map)) { fprintf(stderr, "SDL_FillRect: %s\n", SDL_GetError()); - return; + return -1; } + + return 0; } void rect_init(struct rect *const r) diff --git a/src/gfx/sdl-1.2/src/sprite.c b/src/gfx/sdl-1.2/src/sprite.c index d4921ca..80da9ab 100644 --- a/src/gfx/sdl-1.2/src/sprite.c +++ b/src/gfx/sdl-1.2/src/sprite.c @@ -126,7 +126,7 @@ int sprite_from_fp(struct sprite *const s, FILE *const f) return 0; } -void sprite_sort(struct sprite *const s) +int sprite_sort(struct sprite *const s) { SDL_Rect r = { @@ -143,5 +143,10 @@ void sprite_sort(struct sprite *const s) }; if (SDL_BlitSurface(s->s, &clip, gfx_screen(), &r)) + { fprintf(stderr, "SDL_BlitSurface: %s\n", SDL_GetError()); + return -1; + } + + return 0; } |
