Parcourir la source

last bit of cleanup

jblanked il y a 9 mois
Parent
commit
f2d83dad90
5 fichiers modifiés avec 12 ajouts et 69 suppressions
  1. 1 5
      callback/alloc.c
  2. 7 35
      callback/callback.c
  3. 2 10
      callback/game.c
  4. 1 16
      game/icon.c
  5. 1 3
      game/icon.h

+ 1 - 5
callback/alloc.c

@@ -109,11 +109,7 @@ bool alloc_text_input_view(void *context, char *title)
 bool alloc_variable_item_list(void *context, uint32_t view_id)
 {
     FlipWorldApp *app = (FlipWorldApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return false;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
     char ssid[64];
     char pass[64];
     char username[64];

+ 7 - 35
callback/callback.c

@@ -148,11 +148,7 @@ void callback_submenu_choices(void *context, uint32_t index)
 void callback_updated_wifi_ssid(void *context)
 {
     FlipWorldApp *app = (FlipWorldApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
 
     // store the entered text
     strncpy(app->text_input_buffer, app->text_input_temp_buffer, app->text_input_buffer_size);
@@ -208,11 +204,7 @@ void callback_updated_wifi_ssid(void *context)
 void callback_updated_wifi_pass(void *context)
 {
     FlipWorldApp *app = (FlipWorldApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
 
     // store the entered text
     strncpy(app->text_input_buffer, app->text_input_temp_buffer, app->text_input_buffer_size);
@@ -268,11 +260,7 @@ void callback_updated_wifi_pass(void *context)
 void callback_updated_username(void *context)
 {
     FlipWorldApp *app = (FlipWorldApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
 
     // store the entered text
     strncpy(app->text_input_buffer, app->text_input_temp_buffer, app->text_input_buffer_size);
@@ -293,11 +281,7 @@ void callback_updated_username(void *context)
 void callback_updated_password(void *context)
 {
     FlipWorldApp *app = (FlipWorldApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
 
     // store the entered text
     strncpy(app->text_input_buffer, app->text_input_temp_buffer, app->text_input_buffer_size);
@@ -334,11 +318,7 @@ void callback_updated_password(void *context)
 void callback_wifi_settings_select(void *context, uint32_t index)
 {
     FlipWorldApp *app = (FlipWorldApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
     char ssid[64];
     char pass[64];
     char username[64];
@@ -472,11 +452,7 @@ static void switch_to_view_get_worlds(FlipWorldApp *app)
 void callback_game_settings_select(void *context, uint32_t index)
 {
     FlipWorldApp *app = (FlipWorldApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
     switch (index)
     {
     case 0: // Download all world data as one huge json
@@ -500,11 +476,7 @@ void callback_game_settings_select(void *context, uint32_t index)
 void callback_user_settings_select(void *context, uint32_t index)
 {
     FlipWorldApp *app = (FlipWorldApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
     switch (index)
     {
     case 0: // Username

+ 2 - 10
callback/game.c

@@ -612,11 +612,7 @@ static void game_switch_to_view(FlipWorldApp *app)
 }
 void game_run(FlipWorldApp *app)
 {
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
     free_all_views(app, true, true, false);
     // only need to check if they have 30k free (game needs about 12k currently)
     if (!is_enough_heap(30000, false))
@@ -1091,11 +1087,7 @@ void game_start_pvp(FlipperHTTP *fhttp, FuriString *lobby, void *context)
 void game_waiting_process(FlipperHTTP *fhttp, void *context)
 {
     FlipWorldApp *app = (FlipWorldApp *)context;
-    if (!app)
-    {
-        FURI_LOG_E(TAG, "FlipWorldApp is NULL");
-        return;
-    }
+    furi_check(app, "FlipWorldApp is NULL");
     if (!fhttp)
     {
         FURI_LOG_E(TAG, "Failed to allocate FlipperHTTP");

+ 1 - 16
game/icon.c

@@ -3,7 +3,6 @@
 #include <string.h>
 #include <math.h>
 
-// --- Define the global variable so other modules can link to it.
 IconGroupContext *g_current_icon_group = NULL;
 
 // ---------------------------------------------------------------------
@@ -55,20 +54,7 @@ static void icon_group_free(Entity *self, GameManager *manager, void *context)
         free(igctx->icons);
         igctx->icons = NULL;
     }
-}
-
-// Optional helper to free an icon group context allocated dynamically.
-void icon_group_context_free(IconGroupContext *ctx)
-{
-    if (ctx)
-    {
-        if (ctx->icons)
-        {
-            free(ctx->icons);
-            ctx->icons = NULL;
-        }
-        free(ctx);
-    }
+    g_current_icon_group = NULL;
 }
 
 // The entity description for the icon group.
@@ -78,7 +64,6 @@ const EntityDescription icon_desc = {
     .stop = icon_group_free,
     .update = NULL,
     .render = icon_group_render,
-    // We leave collision as NULL because we now handle collisions in player_update.
     .collision = NULL,
     .event = NULL,
     .context_size = sizeof(IconGroupContext),

+ 1 - 3
game/icon.h

@@ -43,6 +43,4 @@ typedef struct
 
 extern IconGroupContext *g_current_icon_group;
 
-extern const EntityDescription icon_desc;
-// For debugging, you might want to declare functions to allocate and free the pool.
-void icon_group_context_free(IconGroupContext *ctx);
+extern const EntityDescription icon_desc;