1 // ------------------------------------------------------------------
3 // System for handling level's music
4 // ------------------------------------------------------------------
5 // By Kronoman - In loving memory of my father
6 // Copyright (c) 2004, Kronoman
7 // ------------------------------------------------------------------
16 CMusicLvl::CMusicLvl()
23 CMusicLvl::~CMusicLvl()
29 void CMusicLvl::free_memory()
31 if (data_loaded
!= NULL
)
32 unload_datafile_object(data_loaded
);
38 file_loaded
[0] = '\0';
43 DUH
*CMusicLvl::get_music(char *filename
, int index
)
46 DATAFILE
*data
= NULL
;
47 char tmp_file_buf
[2048];
49 where_is_the_filename(tmp_file_buf
, filename
);
51 // use the cache if it is present
52 if (index
== index_loaded
)
54 if (ustrcmp(tmp_file_buf
, file_loaded
) == 0)
60 usprintf(str
, "M%d_XM", index
);
61 data
= load_datafile_object(tmp_file_buf
, str
);
65 usprintf(file_loaded
, "%s", tmp_file_buf
);
69 music_in_ram
= (DUH
*)data
->dat
;
71 return music_in_ram
; // found OK
75 return NULL
; // not found