Fixed a bug when the music file can't be written.
authorFlorian Schulze <crow@icculus.org>
Sun, 24 Feb 2002 19:06:15 +0000 (19:06 +0000)
committerFlorian Schulze <crow@icculus.org>
Sun, 24 Feb 2002 19:06:15 +0000 (19:06 +0000)
sdl/sound.c

index 9a07029..e74b225 100644 (file)
@@ -434,7 +434,7 @@ void dj_free_sfx(unsigned char sfx_num)
 char dj_ready_mod(char mod_num)
 {
        FILE *tmp;
-#ifdef _MSC_VER
+#if ((defined _MSC_VER) || (defined __MINGW32__))
        char filename[] = "jnb.tmpmusic.mod";
 #else
        char filename[] = "/tmp/jnb.tmpmusic.mod";
@@ -470,10 +470,12 @@ char dj_ready_mod(char mod_num)
                current_music = NULL;
        }
        tmp = fopen(filename, "wb");
-       for (; len > 0; len--)
-               fputc(fgetc(fp), tmp);
-       fflush(tmp);
-       fclose(tmp);
+       if (tmp) {
+               for (; len > 0; len--)
+                       fputc(fgetc(fp), tmp);
+               fflush(tmp);
+               fclose(tmp);
+       }
        fclose(fp);
 
        current_music = Mix_LoadMUS(filename);