Переглянути джерело

Merge laser_tag from https://github.com/RocketGod-git/Flipper-Zero-Laser-Tag

Willy-JL 1 рік тому
батько
коміт
3146d7a17f

+ 1 - 1
laser_tag/application.fam

@@ -6,7 +6,7 @@ App(
     cdefines=["APP_LASER_TAG"],
     fap_category="Games",
     fap_author="@RocketGod-git & @jamisonderek",
-    fap_version="2.2",
+    fap_version="2.3",
     fap_description="Laser Tag game for Flipper Zero",
     fap_icon="icons/laser_tag_10px.png",
     fap_libs=["assets"],

+ 5 - 0
laser_tag/docs/CHANGELOG.md

@@ -1,3 +1,8 @@
+## v2.3
+
+- Fix thread leak by CodeAllNight (@jamisonderek)
+- Fix crash when fire is sent while hit is processing by RocketGod (@RocketGod-git)
+
 ## v2.2
 
 - Bug fix to avoid hit queueing by CodeAllNight (@jamisonderek)

+ 3 - 4
laser_tag/infrared_controller.c

@@ -59,14 +59,14 @@ void update_infrared_board_status(InfraredController* controller) {
     }
 }
 
-static int32_t infrared_reset(void* context) {
+static void infrared_reset(void* context, uint32_t arg) {
+    UNUSED(arg);
     InfraredController* controller = (InfraredController*)context;
     // furi_stream_buffer_reset(instance->stream) not exposed to the API.
     // infrared_worker_rx_stop calls it internally.
     infrared_worker_rx_stop(controller->worker);
     infrared_worker_rx_start(controller->worker);
     controller->processing_signal = false;
-    return 0;
 }
 
 static void infrared_rx_callback(void* context, InfraredWorkerSignal* received_signal) {
@@ -109,8 +109,7 @@ static void infrared_rx_callback(void* context, InfraredWorkerSignal* received_s
     }
 
     FURI_LOG_I(TAG, "RX callback completed");
-    FuriThread* thread = furi_thread_alloc_ex("InfraredReset", 512, infrared_reset, controller);
-    furi_thread_start(thread);
+    furi_timer_pending_callback(infrared_reset, controller, 0);
 }
 
 InfraredController* infrared_controller_alloc() {

+ 5 - 2
laser_tag/laser_tag_app.c

@@ -280,6 +280,11 @@ void laser_tag_app_fire(LaserTagApp* app) {
         return;
     }
 
+    if(app->ir_controller->processing_signal) {
+        FURI_LOG_W(TAG, "Cannot fire, hit is being processed");
+        return;
+    }
+
     infrared_controller_send(app->ir_controller);
     FURI_LOG_D(TAG, "Laser fired, decreasing ammo by 1");
     game_state_decrease_ammo(app->game_state, 1);
@@ -288,11 +293,9 @@ void laser_tag_app_fire(LaserTagApp* app) {
 
     if(game_state_get_team(app->game_state) == TeamBlue) {
         notification_message(app->notifications, &sequence_blink_blue_100);
-
         FURI_LOG_I(TAG, "Notifying user with blink blue and short beep");
     } else {
         notification_message(app->notifications, &sequence_blink_red_100);
-
         FURI_LOG_I(TAG, "Notifying user with blink red and short beep");
     }
 

+ 0 - 20
laser_tag/manifest.yml

@@ -1,20 +0,0 @@
-author: '@RocketGod-git & @jamisonderek'
-category: 'Games'
-changelog: '@./docs/CHANGELOG.md'
-description: '@./docs/README.md'
-icon: 'icons/laser_tag_10px.png'
-id: 'laser_tag'
-name: 'Laser Tag'
-screenshots:
-  - 'screenshots/Screenshot1.png'
-  - 'screenshots/Screenshot2.png'
-  - 'screenshots/Screenshot3.png'
-  - 'screenshots/Screenshot4.png'
-short_description: 'Laser Tag game for Flipper Zero'
-sourcecode:
-  location:
-    commit_sha: 6c9239269cef8969908576e15e4c126d4386adb8
-    origin: https://github.com/RocketGod-git/Flipper-Zero-Laser-Tag.git
-    subdir:
-  type: git
-version: 2.1