Explorar o código

stop websocket connection on game end

I also fixed that furi_check when the game ends
jblanked hai 9 meses
pai
achega
62306b0b02
Modificáronse 7 ficheiros con 21 adicións e 13 borrados
  1. 1 1
      alloc/alloc.c
  2. 1 1
      alloc/alloc.h
  3. 1 3
      callback/callback.c
  4. 6 6
      flip_world.h
  5. 0 1
      flipper_http/flipper_http.h
  6. 11 0
      game/game.c
  7. 1 1
      jsmn/jsmn_h.h

+ 1 - 1
alloc/alloc.c

@@ -116,4 +116,4 @@ void flip_world_app_free(FlipWorldApp *app)
     // free the app
     if (app)
         free(app);
-}
+}

+ 1 - 1
alloc/alloc.h

@@ -3,4 +3,4 @@
 
 FlipWorldApp *flip_world_app_alloc();
 void flip_world_app_free(FlipWorldApp *app);
-void flip_world_show_submenu();
+void flip_world_show_submenu();

+ 1 - 3
callback/callback.c

@@ -923,9 +923,7 @@ static bool start_game_thread(void *context)
         easy_flipper_dialog("Error", "app is NULL. Press BACK to return.");
         return false;
     }
-    // well, without this, we dont have enough memory.. but with this, we get furi_check when the game ends :D
-    // after debugging, we'll remove this since we'll have memory free
-    free_submenu_lobby(app);
+
     // free game thread
     if (game_thread_running)
     {

+ 6 - 6
flip_world.h

@@ -4,14 +4,14 @@
 #include <font/font.h>
 
 // added by Derek Jamison to lower memory usage
-// #undef FURI_LOG_E
-// #define FURI_LOG_E(tag, msg, ...)
+#undef FURI_LOG_E
+#define FURI_LOG_E(tag, msg, ...)
 
-// #undef FURI_LOG_I
-// #define FURI_LOG_I(tag, msg, ...)
+#undef FURI_LOG_I
+#define FURI_LOG_I(tag, msg, ...)
 
-// #undef FURI_LOG_D
-// #define FURI_LOG_D(tag, msg, ...)
+#undef FURI_LOG_D
+#define FURI_LOG_D(tag, msg, ...)
 //
 
 #define TAG "FlipWorld"

+ 0 - 1
flipper_http/flipper_http.h

@@ -20,7 +20,6 @@
 
 #undef FURI_LOG_I
 #define FURI_LOG_I(tag, msg, ...)
-//
 
 #define HTTP_TAG "FlipWorld"              // change this to your app name
 #define http_tag "flip_world"             // change this to your app id

+ 11 - 0
game/game.c

@@ -93,6 +93,17 @@ static void game_stop(void *ctx)
     imu_free(game_context->imu);
     game_context->imu = NULL;
 
+    if (game_context->game_mode == GAME_MODE_PVP)
+    {
+        // close websocket
+        FlipperHTTP *fhttp = flipper_http_alloc();
+        if (fhttp)
+        {
+            flipper_http_websocket_stop(fhttp);
+            flipper_http_free(fhttp);
+        }
+    }
+
     // clear current level early
     if (game_context->levels[game_context->current_level])
     {

+ 1 - 1
jsmn/jsmn_h.h

@@ -10,7 +10,7 @@
 
 #undef FURI_LOG_I
 #define FURI_LOG_I(tag, msg, ...)
-//
+// //
 
 typedef enum
 {