fixed compiler warning about uninitialized local variable
[rocksndiamonds.git] / src / tape.c
index 0fef94eb6afd84fdea646903465a29b690c2861b..e42540362be36ba299b4157ed4904b707cc83b42 100644 (file)
@@ -637,9 +637,6 @@ static void TapeAppendRecording()
 
 void TapeHaltRecording()
 {
-  if (!tape.recording)
-    return;
-
   tape.counter++;
 
   // initialize delay for next tape entry (to be able to continue recording)
@@ -653,7 +650,8 @@ void TapeHaltRecording()
 
 void TapeStopRecording()
 {
-  TapeHaltRecording();
+  if (tape.recording)
+    TapeHaltRecording();
 
   tape.recording = FALSE;
   tape.pausing = FALSE;
@@ -662,7 +660,7 @@ void TapeStopRecording()
   MapTapeEjectButton();
 }
 
-void TapeAddAction(byte action[MAX_PLAYERS])
+boolean TapeAddAction(byte action[MAX_PLAYERS])
 {
   int i;
 
@@ -676,6 +674,9 @@ void TapeAddAction(byte action[MAX_PLAYERS])
 
     if (changed_events || tape.pos[tape.counter].delay >= 255)
     {
+      if (tape.counter >= MAX_TAPE_LEN - 1)
+       return FALSE;
+
       tape.counter++;
       tape.pos[tape.counter].delay = 0;
     }
@@ -690,6 +691,8 @@ void TapeAddAction(byte action[MAX_PLAYERS])
 
     tape.pos[tape.counter].delay++;
   }
+
+  return TRUE;
 }
 
 void TapeRecordAction(byte action_raw[MAX_PLAYERS])
@@ -700,12 +703,6 @@ void TapeRecordAction(byte action_raw[MAX_PLAYERS])
   if (!tape.recording)         /* (record action even when tape is paused) */
     return;
 
-  if (tape.counter >= MAX_TAPE_LEN - 1)
-  {
-    TapeStopRecording();
-    return;
-  }
-
   for (i = 0; i < MAX_PLAYERS; i++)
     action[i] = action_raw[i];
 
@@ -719,7 +716,8 @@ void TapeRecordAction(byte action_raw[MAX_PLAYERS])
     tape.set_centered_player = FALSE;
   }
 
-  TapeAddAction(action);
+  if (!TapeAddAction(action))
+    TapeStopRecording();
 }
 
 void TapeTogglePause(boolean toggle_mode)