aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2019-01-15 20:53:07 -0500
committerPaul Duncan <pabs@pablotron.org>2019-01-15 20:53:07 -0500
commitedbbfd40714ba9adfd770b9ccb6a0eecdc43a736 (patch)
treea078ac125a8355489083baa458738c3336c30910 /src
parentd43d705f4d0dceb503ee04a972929a9f61c85658 (diff)
downloadsok-edbbfd40714ba9adfd770b9ccb6a0eecdc43a736.tar.bz2
sok-edbbfd40714ba9adfd770b9ccb6a0eecdc43a736.zip
fix warnings
Diffstat (limited to 'src')
-rw-r--r--src/sdl/action.c2
-rw-r--r--src/sdl/draw.c11
-rw-r--r--src/sdl/main.c9
-rw-r--r--src/sdl/util.h2
-rw-r--r--src/solve/main.c2
-rw-r--r--src/sprite-packer/main.c2
-rw-r--r--src/text/action.c2
-rw-r--r--src/text/draw.c2
-rw-r--r--src/text/main.c4
9 files changed, 23 insertions, 13 deletions
diff --git a/src/sdl/action.c b/src/sdl/action.c
index 8bc01f7..415c3f5 100644
--- a/src/sdl/action.c
+++ b/src/sdl/action.c
@@ -23,7 +23,7 @@
case SDLK_k: \
case SDLK_l:
-static const sok_dir_t
+static sok_dir_t
keycode_to_dir(const SDL_Keycode code) {
switch (code) {
case SDLK_UP: return SOK_DIR_UP;
diff --git a/src/sdl/draw.c b/src/sdl/draw.c
index 0d2b17a..5bb8de7 100644
--- a/src/sdl/draw.c
+++ b/src/sdl/draw.c
@@ -79,6 +79,7 @@ draw_on_size(
const sok_pos_t level_size,
void * const data
) {
+ UNUSED(ctx);
draw_ctx_t * const draw_ctx = data;
const size_t cell_size = get_cell_size(draw_ctx);
@@ -98,7 +99,7 @@ draw_on_size(
// draw floor
for (size_t y = 0; y < level_size.y; y++) {
for (size_t x = 0; x < level_size.x; x++) {
- if (x > 0 && y > 0 && x < level_size.x - 1 && y < level_size.y - 1) {
+ if (x && y && x < (size_t) (level_size.x - 1) && y < (size_t) (level_size.y - 1)) {
const sok_pos_t pos = { x, y };
draw_cell(draw_ctx, pos, SPRITE_FLOOR, 0);
}
@@ -114,6 +115,7 @@ draw_on_wall(
const sok_pos_t pos,
void * const data
) {
+ UNUSED(ctx);
draw_ctx_t * const draw_ctx = data;
draw_cell(draw_ctx, pos, SPRITE_WALL, 0);
return true;
@@ -127,6 +129,9 @@ draw_on_goal(
const bool has_box,
void * const data
) {
+ UNUSED(ctx);
+ UNUSED(has_player);
+ UNUSED(has_box);
draw_ctx_t * const draw_ctx = data;
draw_cell(draw_ctx, pos, SPRITE_GOAL, 0);
return true;
@@ -139,6 +144,8 @@ draw_on_home(
const bool has_goal,
void * const data
) {
+ UNUSED(ctx);
+ UNUSED(has_goal);
draw_ctx_t * const draw_ctx = data;
const double angle = sok_ctx_is_done(draw_ctx->ctx) ? (10 * sin(draw_ctx->ticks * M_2_PI / 1000.0)) : 0;
@@ -154,6 +161,8 @@ draw_on_box(
const bool has_goal,
void * const data
) {
+ UNUSED(ctx);
+ UNUSED(has_goal);
draw_ctx_t * const draw_ctx = data;
const double angle = sok_ctx_is_done(draw_ctx->ctx) ? (5 * sin((100 * (pos.y + pos.x) + draw_ctx->ticks) * M_2_PI / 1000.0)) : 0;
diff --git a/src/sdl/main.c b/src/sdl/main.c
index ca0574d..46f30c3 100644
--- a/src/sdl/main.c
+++ b/src/sdl/main.c
@@ -37,7 +37,7 @@ load_font(
const asset_id_t id
) {
// get asset
- const asset_t * const asset = asset_get(ASSET_ROBOTO_TTF);
+ const asset_t * const asset = asset_get(id);
if (!asset) {
die("asset_get()");
}
@@ -67,7 +67,6 @@ solve_on_error(
static void
set_level(
- SDL_Window * const win,
draw_ctx_t * const draw_ctx,
sok_ctx_t * const ctx,
const size_t level_num
@@ -156,7 +155,7 @@ int main(int argc, char *argv[]) {
};
// set level
- set_level(win, &draw_ctx, &ctx, level_num);
+ set_level(&draw_ctx, &ctx, level_num);
// init sprites, load font
sprites_init(renderer, draw_ctx.sprites);
@@ -198,7 +197,7 @@ int main(int argc, char *argv[]) {
level_num++;
// set level
- set_level(win, &draw_ctx, &ctx, level_num);
+ set_level(&draw_ctx, &ctx, level_num);
} else {
warn("cannot advance to next level");
}
@@ -214,7 +213,7 @@ int main(int argc, char *argv[]) {
case ACTION_WARP:
if (warp_buf_get(&warp_buf, &level_num)) {
// load level
- set_level(win, &draw_ctx, &ctx, level_num);
+ set_level(&draw_ctx, &ctx, level_num);
// clear warp buf
warp_buf_clear(&warp_buf);
diff --git a/src/sdl/util.h b/src/sdl/util.h
index 8d7e130..da347e3 100644
--- a/src/sdl/util.h
+++ b/src/sdl/util.h
@@ -1,6 +1,8 @@
#ifndef UTIL_H
#define UTIL_H
+#define UNUSED(a) ((void) (a))
+
#define warn(...) do { \
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__); \
} while (0)
diff --git a/src/solve/main.c b/src/solve/main.c
index 82b3031..140cfc5 100644
--- a/src/solve/main.c
+++ b/src/solve/main.c
@@ -31,7 +31,7 @@ int main(int argc, char *argv[]) {
// solve level
if (!sok_solve(&ctx, solve_on_error)) {
- die("Couldn't solve level");
+ die("Couldn't solve level: %d", (int) level_num);
}
}
diff --git a/src/sprite-packer/main.c b/src/sprite-packer/main.c
index 945fa51..6bbc44e 100644
--- a/src/sprite-packer/main.c
+++ b/src/sprite-packer/main.c
@@ -60,7 +60,7 @@ int main(int argc, char *argv[]) {
}
// walk input images
- for (size_t i = 2; i < argc; i++) {
+ for (int i = 2; i < argc; i++) {
// load image
SDL_Surface * const src = load_image(argv[i]);
diff --git a/src/text/action.c b/src/text/action.c
index 9d4cbbc..cb21c34 100644
--- a/src/text/action.c
+++ b/src/text/action.c
@@ -15,7 +15,7 @@
case '8': \
case '9':
-static const sok_dir_t
+static sok_dir_t
key_to_dir(const char c) {
switch (c) {
case 'k': return SOK_DIR_UP;
diff --git a/src/text/draw.c b/src/text/draw.c
index af0a132..9300e24 100644
--- a/src/text/draw.c
+++ b/src/text/draw.c
@@ -95,7 +95,7 @@ draw(
) {
// fill print buffer
if (!sok_ctx_walk(ctx, &DRAW_CBS, NULL)) {
- die("Couldn't print level");
+ die("Couldn't print level %d", (int) level_num);
}
// print title, level, and console
diff --git a/src/text/main.c b/src/text/main.c
index 8e89bed..204da0f 100644
--- a/src/text/main.c
+++ b/src/text/main.c
@@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
die("Couldn't load level %d", (int) level_num);
}
} else {
- warn("cannot advance to next level");
+ warn("cannot advance to next level %d", (int) level_num);
}
break;
@@ -108,7 +108,7 @@ int main(int argc, char *argv[]) {
// found solution, print it
draw_moves(&ctx, old_num_moves);
} else {
- warn("Couldn't solve level");
+ warn("Couldn't solve level %d", (int) level_num);
}
}