Skip to content

Commit 8eb8302

Browse files
committed
Enables and fixes compiler warnings
1 parent 7633769 commit 8eb8302

File tree

15 files changed

+59
-71
lines changed

15 files changed

+59
-71
lines changed

CMakeLists.txt

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -146,30 +146,27 @@ set(SDLIMAGE_WEBP OFF)
146146
set(SDLIMAGE_XCF OFF)
147147
set(SDLIMAGE_XPM OFF)
148148
set(SDLIMAGE_XV OFF)
149-
add_subdirectory(external/SDL_image)
150-
set(SDL_IMAGE_INCLUDE_DIR lib/SDL_image/include)
149+
add_subdirectory(external/SDL_image SYSTEM)
151150
set(SDL_IMAGE_LIBRARY SDL3_image-static)
152151

153152
# opusfile caused issues in macos build and we don't need it anyways
154153
set(SDLMIXER_OPUS OFF)
155-
add_subdirectory(external/SDL_mixer)
156-
set(SDL_MIXER_INCLUDE_DIR lib/SDL_mixer/include)
154+
add_subdirectory(external/SDL_mixer SYSTEM)
157155
set(SDL_MIXER_LIBRARY SDL3_mixer-static)
158156

159157
set(SDLTTF_VENDORED ON)
160-
add_subdirectory(external/SDL_ttf)
161-
set(SDL_TTF_INCLUDE_DIR lib/SDL_ttf/include)
158+
add_subdirectory(external/SDL_ttf SYSTEM)
162159
set(SDL_TTF_LIBRARY SDL3_ttf-static)
163160

164161
# Include lua lib
165-
add_subdirectory(lib/lua-5.3.5)
162+
add_subdirectory(lib/lua-5.3.5 SYSTEM)
166163
set(LUA_LIBRARIES lua)
167164
set(LUA_INCLUDE_DIR lib/lua-5.3.5/src)
168165

169166
# Include PHYSFS lib
170167
set(PHYSFS_BUILD_SHARED off CACHE INTERNAL "" FORCE)
171168
set(PHYSFS_BUILD_TEST off CACHE INTERNAL "" FORCE)
172-
add_subdirectory(lib/physfs-3.0)
169+
add_subdirectory(lib/physfs-3.0 SYSTEM)
173170
include_directories(lib/physfs-3.0/src)
174171
set(PHYSFS_LIBRARY physfs-static)
175172
set(PHYSFS_INCLUDE_DIR physfs-3.0/src)
@@ -197,16 +194,12 @@ else ()
197194
endif ()
198195
199196
set(INCLUDE_DIRS
200-
${PROJECT_BINARY_DIR}
201-
${SDL_INCLUDE_DIR}
202-
${SDL_IMAGE_INCLUDE_DIR}
203-
${SDL_TTF_INCLUDE_DIR}
204-
${SDL_MIXER_INCLUDE_DIR}
205-
${PHYSFS_INCLUDE_DIR}
206-
${LUA_INCLUDE_DIR}
207-
lib/sqlite3
208-
lib/bh_random/src
209-
lib/checksum/src
197+
PRIVATE ${PROJECT_BINARY_DIR}
198+
PRIVATE lib/sqlite3
199+
PRIVATE lib/bh_random/src
200+
PRIVATE lib/checksum/src
201+
SYSTEM ${PHYSFS_INCLUDE_DIR}
202+
SYSTEM ${LUA_INCLUDE_DIR}
210203
)
211204
# PROGRAMS:
212205
add_executable(${PROJECT_NAME})
@@ -216,7 +209,7 @@ set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99)
216209
target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_DIRS})
217210
218211
if (NOT MSVC)
219-
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pedantic -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wconversion -Wno-sign-conversion")
212+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wconversion -Wno-sign-conversion")
220213
if (NOT APPLE)
221214
add_definitions(-static -static-libgcc -static-libstdc++)
222215
endif ()
@@ -233,15 +226,15 @@ set_source_files_properties(lib/sqlite3/sqlite3.c COMPILE_FLAGS -w)
233226
234227
target_link_libraries(${PROJECT_NAME}
235228
${CMAKE_DL_LIBS} # Sqlite needs DL libs
229+
bh_random
230+
checksum
236231
${SDL_LIBRARY}
237232
${SDL_IMAGE_LIBRARY}
238233
${SDL_TTF_LIBRARY}
239234
${SDL_MIXER_LIBRARY}
240235
${LUA_LIBRARIES}
241236
${PHYSFS_LIBRARY}
242-
bh_random
243-
checksum
244-
)
237+
)
245238
246239
if (STEAM)
247240
target_link_libraries(${PROJECT_NAME}

src/item_builder.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ item_builder_build_key(unsigned int type)
199199
static void
200200
pickup_bloodlust(Item *item, Player *player)
201201
{
202+
(void) item;
203+
202204
gui_log("You drink a bloodlust potion. Rage pulses through your veins.");
203205
player->effects.effect = POTION_BLOODLUST;
204206
player->effects.damage_multiplier = 4;
@@ -208,9 +210,11 @@ pickup_bloodlust(Item *item, Player *player)
208210
static void
209211
pickup_frost(Item *item, Player *player)
210212
{
213+
(void) item;
214+
211215
gui_log("You drink a frost potion. Your skin is ice.");
212216
player->effects.effect = POTION_FROST;
213-
player->effects.damage_reduction = 2 * player->stats.lvl;
217+
player->effects.damage_reduction = (uint8_t)(2 * player->stats.lvl);
214218
sprite_set_color_mod(player->sprite, 94, 156, 255);
215219
}
216220

src/loot.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,23 @@ get_drop_callback(DropType type)
9999
}
100100

101101

102-
static inline void drop_item(Sprite *sprite, Position *drop_positions, size_t
103-
num_drop_positions, DropType type)
102+
static inline void drop_item(Sprite *sprite, Position *drop_positions,
103+
size_t num_drop_positions, DropType type)
104104
{
105105
/* Avoid FPE (division by zero) */
106106
Position drop_pos;
107107
if (num_drop_positions == 0) {
108108
drop_pos = sprite->pos;
109109
} else {
110-
drop_pos = drop_positions[get_random(num_drop_positions - 1)];
110+
drop_pos = drop_positions[get_random((uint32_t) num_drop_positions - 1)];
111111
}
112112

113113
/* Create an interpolation dest */
114114
Destination dest = {
115115
.pos = drop_pos,
116116
.angle = 0,
117117
.dim = DIM(32, 32),
118-
.time_ms = ITEM_DROP_TIME_MS + get_random(50),
118+
.time_ms = (float)(ITEM_DROP_TIME_MS + get_random(50)),
119119
.on_complete = get_drop_callback(type),
120120
};
121121

src/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ bool initSDL(void)
129129
return false;
130130
}
131131

132-
Dimension dim = getScreenDimensions();
133-
134132
debug("Initializing SDL_ttf");
135133
if (!TTF_Init()) {
136134
error("Unable to initiate ttf library: %s",

src/monster.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#include "monster.h"
2727
#include "random.h"
2828
#include "gui.h"
29-
#include "item.h"
30-
#include "item_builder.h"
3129
#include "map.h"
3230
#include "particle_engine.h"
3331
#include "defines.h"
@@ -38,7 +36,6 @@
3836
#include "object.h"
3937
#include "mixer.h"
4038
#include "pos_heap.h"
41-
#include "loot.h"
4239

4340
static void
4441
monster_set_sprite_clip_for_current_state(Monster *m)
@@ -390,7 +387,7 @@ find_first_in_path(const Position *from, const Position *dest, const Position *s
390387
next = from[current.x + current.y * MAP_ROOM_WIDTH];
391388
}
392389

393-
Vector2d dir = { current.x - next.x, current.y - next.y };
390+
Vector2d dir = { (float)(current.x - next.x), (float)(current.y - next.y) };
394391
if (dir.x > 0)
395392
return RIGHT;
396393
else if (dir.x < 0)
@@ -402,7 +399,7 @@ find_first_in_path(const Position *from, const Position *dest, const Position *s
402399
}
403400

404401
/* Manhattan distance */
405-
#define MDIST(p1, p2) abs(p1.x - p2.x) + abs(p1.y - p2.y)
402+
#define MDIST(p1, p2) (uint16_t)(abs(p1.x - p2.x) + abs(p1.y - p2.y))
406403

407404
/**
408405
* \brief A* path finding algorithm
@@ -415,7 +412,6 @@ static Direction
415412
get_optimal_move_towards(Monster *m, RoomMatrix *rm, const Position dest)
416413
{
417414
Direction ret_val = INVALID;
418-
int x_dist, y_dist;
419415
const Position start = position_to_matrix_coords(&m->sprite->pos);
420416
const Vector2d directions[] = {
421417
VECTOR2D_UP,
@@ -453,8 +449,8 @@ get_optimal_move_towards(Monster *m, RoomMatrix *rm, const Position dest)
453449

454450
for (size_t i = 0; i < 4; i++) {
455451
Position next = {
456-
current.x + directions[i].x,
457-
current.y + directions[i].y,
452+
current.x + (int) directions[i].x,
453+
current.y + (int) directions[i].y,
458454
};
459455

460456
if (!position_equals(&next, &dest)) {
@@ -465,7 +461,7 @@ get_optimal_move_towards(Monster *m, RoomMatrix *rm, const Position dest)
465461
}
466462
}
467463

468-
uint32_t temp_score = 1 + gScore[current.x + current.y * WIDTH];
464+
uint16_t temp_score = 1 + gScore[current.x + current.y * WIDTH];
469465
if (temp_score < gScore[next.x + next.y * WIDTH]) {
470466
from[next.x + next.y * WIDTH] = current;
471467
gScore[next.x + next.y * WIDTH] = temp_score;
@@ -661,7 +657,6 @@ monster_move(Monster *m, RoomMatrix *rm, Map *map)
661657
}
662658

663659
Position originalMPos = position_to_matrix_coords(&m->sprite->pos);
664-
665660
SPACE_CLEAR_FLAG(&rm->spaces[originalMPos.x][originalMPos.y], TILE_OCCUPIED);
666661
rm->spaces[originalMPos.x][originalMPos.y].monster = NULL;
667662

src/particle_engine.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,10 @@ render_rect_particle(Particle *p, Camera *cam)
454454
SDL_SetRenderDrawBlendMode(cam->renderer, p->blend_mode);
455455

456456
SDL_FRect box = {
457-
pos.x,
458-
pos.y,
459-
p->particle.rect.dim.width,
460-
p->particle.rect.dim.height
457+
(float) pos.x,
458+
(float) pos.y,
459+
(float) p->particle.rect.dim.width,
460+
(float) p->particle.rect.dim.height
461461
};
462462
SDL_SetRenderDrawColor(cam->renderer,
463463
p->color.r,

src/physfsrwops.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,6 @@ static SDL_IOStream *create_rwops(PHYSFS_File *handle)
155155
return retval;
156156
}
157157

158-
159-
SDL_IOStream *PHYSFSIO_makeRWops(PHYSFS_File *handle)
160-
{
161-
SDL_IOStream *retval = NULL;
162-
if (handle == NULL)
163-
SDL_SetError("NULL pointer passed to PHYSFSIO_makeRWops().");
164-
else
165-
retval = create_rwops(handle);
166-
167-
return retval;
168-
}
169-
170-
171158
SDL_IOStream *PHYSFSIO_openRead(const char *fname)
172159
{
173160
return create_rwops(PHYSFS_openRead(fname));

src/player.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void
6868
player_particle_bleed(Position pos, Dimension dim, void *userdata)
6969
{
7070
Player *p = userdata;
71-
float perc = (float) p->stats.hp / p->stats.maxhp;
71+
float perc = (float) p->stats.hp / (float) p->stats.maxhp;
7272
Uint32 particle_count = (Uint32) (20.0f * perc);
7373
particle_engine_bloodspray(pos, dim, particle_count);
7474
}
@@ -568,9 +568,9 @@ player_create(class_t class, Camera *cam)
568568
player->stateData.shopOwnerKiller = false;
569569

570570
ParticleEmitter *emitter = particle_emitter_create();
571-
emitter->timestep = 2000;
571+
emitter->timestep = 1000;
572572
emitter->enabled = false;
573-
emitter->particle_func = particle_engine_bleed;
573+
emitter->particle_func = player_particle_bleed;
574574
emitter->userdata = player;
575575
player->bleed_emitter = emitter;
576576

@@ -790,7 +790,7 @@ player_update(UpdateData *data)
790790
animation_update(player->swordAnimation);
791791

792792
uint32_t damage_taken = player->stats.maxhp - player->stats.hp;
793-
player->bleed_emitter->enabled = damage_taken >= player->stats.maxhp / 2;
793+
player->bleed_emitter->enabled = (int) damage_taken >= player->stats.maxhp / 2;
794794
}
795795

796796
static void

src/pos_heap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void swap(Node *a, Node *b) {
3636
*b = tmp;
3737
}
3838

39-
static void heapify(PHeap *ph, int i)
39+
static void heapify(PHeap *ph, size_t i)
4040
{
4141
if (ph->size <= 0) {
4242
return;

src/roommatrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ typedef struct RoomSpace {
6565
#define SPACE_IS_LIGHTSOURCE(space) ((space) && (space->flags & TILE_LIGHTSOURCE))
6666
#define SPACE_IS_DAMAGING(space) ((space) && (space->flags & TILE_DAMAGE))
6767
#define SPACE_SET_FLAG(space, flag) ((space) && ((space)->flags |= flag))
68-
#define SPACE_CLEAR_FLAG(space, flag) ((space) && ((space)->flags &= ~flag))
68+
#define SPACE_CLEAR_FLAG(space, flag) ((space)->flags &= ~flag)
6969
#define SPACE_TOGGLE_FLAG(space, flag) ((space) && ((space)->flags ^= flag))
7070

7171
#define SPACE_IS_BLOCKED(space) (SPACE_IS_OCCUPIED(space) || (space)->monster)

0 commit comments

Comments
 (0)