diff --git a/multiplayer_setup_state.c b/multiplayer_setup_state.c index dc85c0b..72555f0 100644 --- a/multiplayer_setup_state.c +++ b/multiplayer_setup_state.c @@ -210,7 +210,7 @@ void multiplayer_setup_state_render(s_Game* game) { 0, 0, 0 ); - if (errorTexture != 0) { + if (errorTexture != NULL) { SDL_QueryTexture(errorTexture, NULL, NULL, &textWidth, &textHeight); SDL_Rect errorRect = {50, 60, textWidth, textHeight}; SDL_RenderCopy(game->renderer, errorTexture, NULL, &errorRect); @@ -281,7 +281,7 @@ void multiplayer_setup_state_render(s_Game* game) { ); } - if (errorTexture != 0) { + if (errorTexture != NULL) { SDL_QueryTexture(errorTexture, NULL, NULL, &textWidth, &textHeight); SDL_Rect errorRect = {50, 210, textWidth, textHeight}; SDL_RenderCopy(game->renderer, errorTexture, NULL, &errorRect); @@ -339,6 +339,7 @@ void multiplayer_setup_state_handleEvent(s_Game* game, int key) { if (key == SDLK_ESCAPE) { g_localState = STATE_HOST_JOIN; SDL_DestroyTexture(errorTexture); + errorTexture = NULL; } else if (IS_GCW) { _handleIPSelectionEventGCW(game, key); @@ -351,12 +352,17 @@ void multiplayer_setup_state_handleEvent(s_Game* game, int key) { if (key == SDLK_ESCAPE) { g_localState = STATE_JOIN_SETUP; SDL_DestroyTexture(errorTexture); + errorTexture = NULL; } } } void _setSetupError(s_Game *game, const char *errorMessage) { - SDL_DestroyTexture(errorTexture); + if (errorTexture != NULL) { + SDL_DestroyTexture(errorTexture); + errorTexture = NULL; + } + utils_createTextTexture( game->renderer, game->menuFont,