Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/init/free_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void free_wolf(wolf_t *wolf)
{
if (!wolf)
return;
if (wolf->connected)
if (wolf->net.socket)
client_close(&wolf->net);
free_wolf_resources(wolf);
if (wolf->player)
Expand Down
8 changes: 5 additions & 3 deletions src/init/free_cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ static void free_entity_drawable(void *data)

if (!entity)
return;
if (entity->clock)
sfClock_destroy(entity->clock);
if (entity->sprite)
sfSprite_destroy(entity->sprite);
if (entity->texture)
Expand Down Expand Up @@ -134,11 +136,11 @@ static void free_game_wall(game_t *game)

static void free_game_ui(game_t *game)
{
int i = 0;

if (game->zbuffer)
free(game->zbuffer);
if (game->crosshair.cursor) {
if (game->crosshair.cursor->clock)
sfClock_destroy(game->crosshair.cursor->clock);
if (game->crosshair.cursor->sprite)
sfSprite_destroy(game->crosshair.cursor->sprite);
if (game->crosshair.cursor->texture)
Expand All @@ -147,7 +149,7 @@ static void free_game_ui(game_t *game)
}
if (game->inter.clock)
sfClock_destroy(game->inter.clock);
for (i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
if (game->inter.card[i].text)
sfText_destroy(game->inter.card[i].text);
if (game->inter.card[i].rect)
Expand Down
3 changes: 3 additions & 0 deletions src/init/free_lists.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ void free_menu_lists(wolf_t *wolf)
{
free_draw_list(wolf, MENU, TEXT);
free_draw_list(wolf, MENU, SPRITE);
free_draw_list(wolf, NEWGAME_MENU, TEXT);
free_draw_list(wolf, NEWGAME_MENU, SPRITE);
free_draw_list(wolf, LOBBY, SPRITE);
free_draw_list(wolf, GAME_OVER, TEXT);
free_draw_list(wolf, GAME_OVER, RECT);
}
Expand Down
2 changes: 2 additions & 0 deletions src/init/init_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ static void destroy_entity(entity_t *entity)
{
if (!entity)
return;
if (entity->clock)
sfClock_destroy(entity->clock);
if (entity->sprite)
sfSprite_destroy(entity->sprite);
if (entity->texture)
Expand Down
27 changes: 26 additions & 1 deletion src/settings/settings_buttons.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ static void center_text_on_rect(sfText *text, sfRectangleShape *rect)
rect_bounds.top + rect_bounds.height / 2.0f});
}

static void free_rect_resource(rect_t *rect)
{
if (!rect)
return;
if (rect->rect)
sfRectangleShape_destroy(rect->rect);
if (rect->texture)
sfTexture_destroy(rect->texture);
if (rect->click_texture)
sfTexture_destroy(rect->click_texture);
free(rect);
}

static void free_text_resource(text_t *text)
{
if (!text)
return;
if (text->text)
sfText_destroy(text->text);
free(text);
}

static void create_settings_box(wolf_t *wolf, sfVector2f *pos, text_t *info,
sfVector2f *size)
{
Expand All @@ -30,8 +52,11 @@ static void create_settings_box(wolf_t *wolf, sfVector2f *pos, text_t *info,
text_t *text = create_text(info, wolf->data->font, pos,
&(sfVector2f){1.0f, 1.0f});

if (!rect || !text)
if (!rect || !text) {
free_rect_resource(rect);
free_text_resource(text);
return;
}
sfText_setCharacterSize(text->text, 28);
center_text_on_rect(text->text, rect->rect);
push_front(&wolf->list[SETTINGS][RECT], rect);
Expand Down
Loading