1,079
edits
(→Incomplete code snippets: Some incomplete ramblings) |
|||
Line 98: | Line 98: | ||
The following snippets are sketches. We may end up doing things totally different. It's just a way for me to make visible what goes on in my head right now, and is neither complete nor necessarily the best way to handle things. You have been warned :-) | The following snippets are sketches. We may end up doing things totally different. It's just a way for me to make visible what goes on in my head right now, and is neither complete nor necessarily the best way to handle things. You have been warned :-) | ||
For regular use (e.g. in ScummEngine:: | Random thought: The detector could automatically populate the 'basename' field, too. | ||
In particular, the first use of generateSubstResFileName in Sound::openSfxFile | |||
is used to translate the "basename" of the game; this would be unnecessary if | |||
the basename was already set to the right value. | |||
For regular use (e.g. in ScummEngine::openRoom, and most places where | |||
generateSubstResFileName is currently being used), we could use a new function like this one: | generateSubstResFileName is currently being used), we could use a new function like this one: | ||
<pre> | <pre> | ||
Line 140: | Line 146: | ||
return buf; | return buf; | ||
} | } | ||
</pre> | |||
For detection: We should touch every file at most once (in particular, it would be very bad to compute the MD5 of a file multiple times, since many of our targets aren't exactly fast when it comes to disk I/O speed). So instead of looping over all games, let's loop over the files and then split down into cases. At the same time, squeeze any information we can from the filenames and files. | |||
<pre> | |||
fullCandidateList = () | |||
FOR filename in files DO | |||
bool filenameKnown = false; | |||
IF length of filename < 4 THEN | |||
NEXT | |||
ENDIF | |||
tempList = () | |||
IF (filename contains '.' and is at most 8+1+3=12 chars long) THEN | |||
filenameKnown = true; | |||
SWITCH filename { | |||
case 00.MAN | |||
add to tempList: | |||
gameid = Maniac Mansion, platform = ?, language = en, extra = demo | |||
subst pattern = "%02d.MAN", kGenWithRoomNum | |||
case *.sm0 | |||
add to tempList: | |||
gameid = Sam & Max, ... | |||
case 00.LFL | |||
look at the file to distinguish between V1, V2/V3OldBundle and V3SH | |||
Then add all possible game variants to tempList | |||
... | |||
case 000.LFL | |||
... | |||
case *.000 | |||
... | |||
case *.la0 | |||
... | |||
case *.he0 | |||
... | |||
case *.d64 // Non-extracted C64 | |||
add to tempList: | |||
gameid = Maniac Mansion, platform = C64 | |||
OR | |||
gameid = Zak, platform = C64 | |||
OR | |||
error | |||
... | |||
default: | |||
filenameKnown = false; | |||
ENDSWITCH | |||
ELSE | |||
// Must be a mac name / long name | |||
IF filename = "Maniac Mansion (*).prg" THEN | |||
add to tempList: | |||
gameid = Maniac Mansion, platform = NES, language = * | |||
ELIF name is in mac container list THEN | |||
... | |||
ELSE | |||
search the generic subst list | |||
... | |||
TODO | |||
... | |||
ENDIF | |||
ENDIF | |||
if filenameKnown then | |||
compute MD5 of the file (we only do this for known filenames to avoid | |||
computing the MD5 of every single file in the directory!) | |||
IF MD5 is found in the table THEN | |||
optionally: perform a sanity check, show if the exact match | |||
agrees with at least one of our guesses | |||
add this exact match to fullCandidateList | |||
ELSE | |||
add tempList to fullCandidateList | |||
ENDIF | |||
ENDIF | |||
ENDFOR | |||
</pre> | </pre> | ||
edits