~ubuntu-branches/ubuntu/lucid/meritous/lucid

« back to all changes in this revision

Viewing changes to debian/patches/make_music_optional.patch

  • Committer: Bazaar Package Importer
  • Author(s): Dylan R. E. Moonfire
  • Date: 2008-02-11 13:45:02 UTC
  • Revision ID: james.westby@ubuntu.com-20080211134502-eusnjlhps0kyi2ln
Tags: 1.2+dfsg-1
* Dylan R. E. Moonfire
  + src/levelblit.c: Updated the version to reflect the actual version
    instead of "1.1".
  + debian/control: Added Vcs- headers to point to Subversion
    repository.
  + Changed the location of the save game to use
    $HOME/.meritous.sav. This will use legacy save file if the new one
    cannot be found. (Closes: #465228)
  + src/help.c: Corrected a parsing bug with the help files that
    prevented users from reading the help files. (Closes: #465147)
  + Removed music files due to licensing issues. Patched code to make
    music files optional. (Closes: #465532)
  + debian/rules: Added a 'get-orig-source' target to repackage the
    original after removing the music files.
* Bas Wijnen
  + src/boss.c: Applied a patch to handle an array overflow in the first
    boss fight. (Closes: #465051)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- a/src/audio.c       2008-02-13 10:52:25.000000000 -0600
 
2
+++ b/src/audio.c       2008-02-13 10:52:49.000000000 -0600
 
3
@@ -31,20 +31,6 @@
 
4
 #include "mapgen.h"
 
5
 #include "boss.h"
 
6
 
 
7
-char *tracks[13] = {"/usr/share/games/meritous/m/ICEFRONT.S3M",
 
8
-                                       "/usr/share/games/meritous/m/cavern.xm",
 
9
-                                       "/usr/share/games/meritous/m/cave.xm",
 
10
-                                       "/usr/share/games/meritous/m/cave06.s3m",
 
11
-                                       "/usr/share/games/meritous/m/Wood.s3m",
 
12
-                                       "/usr/share/games/meritous/m/iller_knarkloader_final.xm",
 
13
-                                       "/usr/share/games/meritous/m/fear2.mod",
 
14
-                                       "/usr/share/games/meritous/m/Cv_boss.mod",
 
15
-                                       "/usr/share/games/meritous/m/Fr_boss.mod",
 
16
-                                       "/usr/share/games/meritous/m/CT_BOSS.MOD",
 
17
-                                       "/usr/share/games/meritous/m/rpg_bat1.xm",
 
18
-                                       "/usr/share/games/meritous/m/amblight.xm",
 
19
-                                       "/usr/share/games/meritous/m/FINALBAT.s3m"};
 
20
-
 
21
 Mix_Music *bgm_music = NULL;
 
22
 int bgm_track = -1;
 
23
 
 
24
@@ -108,6 +94,49 @@
 
25
        Mix_Volume(0, hum_vol);
 
26
 }
 
27
 
 
28
+int IsBackgroundMusicFile(char *buffer, int track, char *suffix)
 
29
+{
 
30
+       /* Figure out the filename */
 
31
+       sprintf(buffer, "/usr/share/games/meritous/m/track%d.%s",
 
32
+           track, suffix);
 
33
+
 
34
+       /* See if the file exists */
 
35
+       FILE *fp;
 
36
+       if ((fp = fopen(buffer, "rb")) != NULL) {
 
37
+               fclose(fp);
 
38
+               return 1;
 
39
+       }
 
40
+       return 0;
 
41
+}
 
42
+
 
43
+void PlayBackgroundMusic(int track)
 
44
+{
 
45
+       /* Setup variables */
 
46
+       char filename[64];
 
47
+       int found_track = 0;
 
48
+
 
49
+       /* See if we have a file of the appropriate type. */
 
50
+       if (!found_track)
 
51
+               found_track = IsBackgroundMusicFile(filename, track, "ogg");
 
52
+       if (!found_track)
 
53
+               found_track = IsBackgroundMusicFile(filename, track, "mp3");
 
54
+       if (!found_track)
 
55
+               found_track = IsBackgroundMusicFile(filename, track, "s3m");
 
56
+       if (!found_track)
 
57
+               found_track = IsBackgroundMusicFile(filename, track, "xm");
 
58
+       if (!found_track)
 
59
+               found_track = IsBackgroundMusicFile(filename, track, "mod");
 
60
+
 
61
+       /* Play the selected music */
 
62
+       if (found_track) {
 
63
+               bgm_music = Mix_LoadMUS(filename);
 
64
+               Mix_PlayMusic(bgm_music, -1);
 
65
+       }
 
66
+
 
67
+       /* Always save the track to reduce load */
 
68
+       bgm_track = track;
 
69
+}
 
70
+
 
71
 void TitleScreenMusic()
 
72
 {
 
73
        int new_track = 5;
 
74
@@ -117,9 +146,7 @@
 
75
                bgm_music = NULL;
 
76
        }
 
77
        
 
78
-       bgm_music = Mix_LoadMUS(tracks[new_track]);
 
79
-       Mix_PlayMusic(bgm_music, -1);   
 
80
-       bgm_track = new_track;
 
81
+       PlayBackgroundMusic(new_track);
 
82
 }
 
83
 
 
84
 void BackgroundMusic()
 
85
@@ -191,8 +218,7 @@
 
86
                bgm_music = NULL;
 
87
        }
 
88
        if (new_track != -1) {
 
89
-               bgm_music = Mix_LoadMUS(tracks[new_track]);
 
90
-               Mix_PlayMusic(bgm_music, -1);
 
91
+               PlayBackgroundMusic(new_track);
 
92
        }
 
93
        bgm_track = new_track;
 
94
 }