Fixed compiler warnings

This commit is contained in:
Linus_Probert 2018-02-01 09:04:19 +01:00
parent e9091346fd
commit 9550840a7a
4 changed files with 21 additions and 25 deletions

View File

@ -148,8 +148,8 @@ gui_create(SDL_Renderer *renderer)
return gui; return gui;
} }
void static void
gui_set_max_health(Gui *gui, int max, SDL_Renderer *renderer) set_max_health(Gui *gui, int max, SDL_Renderer *renderer)
{ {
Texture *texture; Texture *texture;
int i; int i;
@ -175,8 +175,8 @@ gui_set_max_health(Gui *gui, int max, SDL_Renderer *renderer)
} }
} }
void static void
gui_set_current_health(Gui *gui, int current) set_current_health(Gui *gui, int current)
{ {
int partial = current % 3; int partial = current % 3;
int full = (current - partial)/3; int full = (current - partial)/3;
@ -211,6 +211,8 @@ gui_update_player_stats(Gui *gui, Player *player, Map *map, SDL_Renderer *render
static int last_xp = -1; static int last_xp = -1;
static double last_gold = -1; static double last_gold = -1;
static unsigned int dungeon_level = 0; static unsigned int dungeon_level = 0;
static int max_health = -1;
static int current_health = -1;
static SDL_Color color = { 255, 255, 255, 255 }; static SDL_Color color = { 255, 255, 255, 255 };
@ -223,7 +225,16 @@ gui_update_player_stats(Gui *gui, Player *player, Map *map, SDL_Renderer *render
ExperienceData data = player_get_xp_data(player); ExperienceData data = player_get_xp_data(player);
if (last_xp != data.current) { if (max_health != player->stats.maxhp) {
max_health = player->stats.maxhp;
set_max_health(gui, max_health, renderer);
}
if (current_health != player->stats.hp) {
current_health = player->stats.hp;
set_current_health(gui, current_health);
}
if (last_xp != (int) data.current) {
xp_from_levelup = data.current - data.previousLevel; xp_from_levelup = data.current - data.previousLevel;
xp_required_from_last_level = data.nextLevel - data.previousLevel; xp_required_from_last_level = data.nextLevel - data.previousLevel;
xp_step = ((float)xp_required_from_last_level) / 32; // 4 * 8 xp_step = ((float)xp_required_from_last_level) / 32; // 4 * 8
@ -253,7 +264,7 @@ gui_update_player_stats(Gui *gui, Player *player, Map *map, SDL_Renderer *render
} }
} }
if (dungeon_level != map->level) { if (dungeon_level != (unsigned int) map->level) {
m_sprintf(buffer, 200, "Dungeon level: %d", map->level); m_sprintf(buffer, 200, "Dungeon level: %d", map->level);
texture_load_from_text(gui->labels[DUNGEON_LEVEL_LABEL]->textures[0], buffer, color, renderer); texture_load_from_text(gui->labels[DUNGEON_LEVEL_LABEL]->textures[0], buffer, color, renderer);
dungeon_level = (unsigned int) map->level; dungeon_level = (unsigned int) map->level;
@ -265,7 +276,7 @@ gui_update_player_stats(Gui *gui, Player *player, Map *map, SDL_Renderer *render
last_gold = player->gold; last_gold = player->gold;
} }
if (last_xp != data.current) { if (last_xp != (int) data.current) {
m_sprintf(buffer, 200, "XP: %u / %u", data.current, data.nextLevel); m_sprintf(buffer, 200, "XP: %u / %u", data.current, data.nextLevel);
texture_load_from_text(gui->labels[CURRENT_XP_LABEL]->textures[0], buffer, color, renderer); texture_load_from_text(gui->labels[CURRENT_XP_LABEL]->textures[0], buffer, color, renderer);
last_xp = data.current; last_xp = data.current;

View File

@ -31,12 +31,6 @@ typedef struct {
Gui* Gui*
gui_create(SDL_Renderer *renderer); gui_create(SDL_Renderer *renderer);
void
gui_set_max_health(Gui*, int max, SDL_Renderer*);
void
gui_set_current_health(Gui*, int current);
void void
gui_update_player_stats(Gui*, Player*, Map*, SDL_Renderer*); gui_update_player_stats(Gui*, Player*, Map*, SDL_Renderer*);

View File

@ -201,9 +201,6 @@ check_next_level(void)
static void static void
run_game(void) run_game(void)
{ {
static unsigned int player_max_hp = 0;
static unsigned int player_current_hp = 0;
SDL_RenderSetViewport(gRenderer, NULL); SDL_RenderSetViewport(gRenderer, NULL);
map_clear_dead_monsters(gMap); map_clear_dead_monsters(gMap);
map_clear_collected_items(gMap); map_clear_collected_items(gMap);
@ -212,16 +209,8 @@ run_game(void)
&gPlayer->sprite->pos); &gPlayer->sprite->pos);
roommatrix_build_lightmap(gRoomMatrix); roommatrix_build_lightmap(gRoomMatrix);
gui_update_player_stats(gGui, gPlayer, gMap, gRenderer);
if (player_max_hp != (unsigned int) gPlayer->stats.maxhp) { gui_update_player_stats(gGui, gPlayer, gMap, gRenderer);
gui_set_max_health(gGui, gPlayer->stats.maxhp, gRenderer);
player_max_hp = gPlayer->stats.maxhp;
}
if (player_current_hp != (unsigned int) gPlayer->stats.hp) {
gui_set_current_health(gGui, gPlayer->stats.hp);
player_current_hp = gPlayer->stats.hp;
}
if (gPlayer->steps >= gPlayer->stats.speed) { if (gPlayer->steps >= gPlayer->stats.speed) {
player_reset_steps(gPlayer); player_reset_steps(gPlayer);

View File

@ -26,6 +26,8 @@ player_levelup(Player *player)
// Limit health to 3 rows of hearts // Limit health to 3 rows of hearts
if (player->stats.maxhp > 72) if (player->stats.maxhp > 72)
player->stats.maxhp = 72; player->stats.maxhp = 72;
player->stats.hp = player->stats.maxhp;
} }
static unsigned int static unsigned int