static bool GetDefaultPatchPrefix(
    const TCHAR * szBaseMpqName,
    char * szBuffer)
{
    const TCHAR * szExtension;
    const TCHAR * szDash;

    // Ensure that both names are plain names
    szBaseMpqName = GetPlainFileNameT(szBaseMpqName);

    // Patch prefix is for the Cataclysm MPQs, whose names
    // are like "locale-enGB.MPQ" or "speech-enGB.MPQ"
    szExtension = _tcsrchr(szBaseMpqName, _T('.'));
    szDash = _tcsrchr(szBaseMpqName, _T('-'));
    strcpy(szBuffer, "Base");

    // If the length of the prefix doesn't match, use default one
    if(szExtension != NULL && szDash != NULL && (szExtension - szDash) == 5)
    {
        // Copy the prefix
        szBuffer[0] = (char)szDash[1];
        szBuffer[1] = (char)szDash[2];
        szBuffer[2] = (char)szDash[3];
        szBuffer[3] = (char)szDash[4];
        szBuffer[4] = 0;
    }

    return true;
}
static bool GetDefaultPatchPrefix(
    const TCHAR * szBaseMpqName,
    const TCHAR * szPatchMpqName,
    char * szBuffer)
{
    const TCHAR * szExtension;
    const TCHAR * szDash;

    // Ensure that both names are plain names
    szPatchMpqName = GetPlainFileNameT(szPatchMpqName);
    szBaseMpqName = GetPlainFileNameT(szBaseMpqName);

    // For files like "wow-update-13164.MPQ", the patch prefix
    // is based on the base MPQ name
    if(CompareNameMask(szPatchMpqName, _T("wow-update-#.mpq")))
    {
        // Patch prefix is for the Cataclysm MPQs, whose names
        // are like "locale-enGB.MPQ" or "speech-enGB.MPQ"
        szExtension = _tcsrchr(szBaseMpqName, _T('.'));
        szDash = _tcsrchr(szBaseMpqName, _T('-'));
        strcpy(szBuffer, "Base");

        // If the length of the prefix doesn't match, use default one
        if(szExtension != NULL && szDash != NULL && (szExtension - szDash) == 5)
        {
            // Copy the prefix
            szBuffer[0] = (char)szDash[1];
            szBuffer[1] = (char)szDash[2];
            szBuffer[2] = (char)szDash[3];
            szBuffer[3] = (char)szDash[4];
            szBuffer[4] = 0;
        }

        return true;
    }

    //
    // Note: Diablo 3 MPQs have name of "d3-update-####.mpq,
    // but they don't use patch prefixes
    //

    // No patch prefix
    *szBuffer = 0;
    return false;
}
Beispiel #3
0
static void GetPlainAnsiFileName(
    const TCHAR * szFileName,
    char * szPlainName)
{
    const TCHAR * szPlainNameT = GetPlainFileNameT(szFileName);

    // Convert the plain name to ANSI
    while(*szPlainNameT != 0)
        *szPlainName++ = (char)*szPlainNameT++;
    *szPlainName = 0;
}