Mercurial > audlegacy-plugins
comparison src/adplug/core/adtrack.cxx @ 703:cae46214b8bf trunk
[svn] - rework AdPlug to use VFS properly
see http://sacredspiral.co.uk/~nenolod/adplug-vfs-ng.diff for a diff.
author | nenolod |
---|---|
date | Fri, 23 Feb 2007 20:23:34 -0800 |
parents | 3da1b8942b8b |
children | 4709ce4e209e |
comparison
equal
deleted
inserted
replaced
702:d25b51e90542 | 703:cae46214b8bf |
---|---|
40 CPlayer *CadtrackLoader::factory(Copl *newopl) | 40 CPlayer *CadtrackLoader::factory(Copl *newopl) |
41 { | 41 { |
42 return new CadtrackLoader(newopl); | 42 return new CadtrackLoader(newopl); |
43 } | 43 } |
44 | 44 |
45 bool CadtrackLoader::load(const std::string &filename, const CFileProvider &fp) | 45 bool CadtrackLoader::load(VFSFile *fd, const CFileProvider &fp) |
46 { | 46 { |
47 binistream *f = fp.open(filename); if(!f) return false; | 47 binistream *f = fp.open(fd); if(!f) return false; |
48 binistream *instf; | 48 binistream *instf; |
49 char note[2]; | 49 char note[2]; |
50 unsigned short rwp; | 50 unsigned short rwp; |
51 unsigned char chp, octave, pnote = 0; | 51 unsigned char chp, octave, pnote = 0; |
52 int i,j; | 52 int i,j; |
53 AdTrackInst myinst; | 53 AdTrackInst myinst; |
54 std::string filename(fd->uri); | |
54 | 55 |
55 // file validation | 56 // file validation |
56 if(!fp.extension(filename, ".sng") || fp.filesize(f) != 36000) | 57 if(!fp.extension(filename, ".sng") || fp.filesize(f) != 36000) |
57 { fp.close(f); return false; } | 58 { fp.close(f); return false; } |
58 | 59 |
59 // check for instruments file | 60 // check for instruments file |
60 std::string instfilename(filename, 0, filename.find_last_of('.')); | 61 std::string instfilename(filename, 0, filename.find_last_of('.')); |
61 instfilename += ".ins"; | 62 instfilename += ".ins"; |
62 AdPlug_LogWrite("CadtrackLoader::load(,\"%s\"): Checking for \"%s\"...\n", | 63 AdPlug_LogWrite("CadtrackLoader::load(,\"%s\"): Checking for \"%s\"...\n", |
63 filename.c_str(), instfilename.c_str()); | 64 filename.c_str(), instfilename.c_str()); |
64 instf = fp.open(instfilename); | 65 |
65 if(!instf || fp.filesize(instf) != 468) { fp.close(f); return false; } | 66 VFSFile *instfd = vfs_fopen(instfilename.c_str(), "rb"); |
67 instf = fp.open(instfd); | |
68 if(!instf || fp.filesize(instf) != 468) { fp.close(f); vfs_fclose(instfd); return false; } | |
66 | 69 |
67 // give CmodPlayer a hint on what we're up to | 70 // give CmodPlayer a hint on what we're up to |
68 realloc_patterns(1,1000,9); realloc_instruments(9); realloc_order(1); | 71 realloc_patterns(1,1000,9); realloc_instruments(9); realloc_order(1); |
69 init_trackord(); flags = NoKeyOn; | 72 init_trackord(); flags = NoKeyOn; |
70 (*order) = 0; length = 1; restartpos = 0; bpm = 120; initspeed = 3; | 73 (*order) = 0; length = 1; restartpos = 0; bpm = 120; initspeed = 3; |