[Bug 40441] Chicken tournament crashes when loading texture

wine-bugs at winehq.org wine-bugs at winehq.org
Fri Jan 18 11:08:19 CST 2019


https://bugs.winehq.org/show_bug.cgi?id=40441

--- Comment #7 from joaopa <jeremielapuree at yahoo.fr> ---
I investigated this bug. In the function in /src/HelperLib/texturen.cpp
void MakeTransparent(LPDIRECTDRAWSURFACE7 lpSurface,const BOOLEAN white)
{
    DDSURFACEDESC2 ddsd;
    DWORD dwAlphaMask,dwRGBMask,dwColorkey;
    DWORD x,y;
    PWORD p16;
    PDWORD p32;
    DWORD texturenum=0;
    DWORD dwRGBBitCount;

nochmal:
//    For textures with real alpha (not palettized), set transparent bits
    printf("texturenum = %x, lpSurface = %p\n", texturenum, lpSurface);
    ZeroMemory(&ddsd,sizeof(ddsd));
    ddsd.dwSize=sizeof(ddsd);
    while (lpSurface->Lock(NULL, &ddsd, 0, 0) == DDERR_WASSTILLDRAWING)  ;

    if (texturenum==0)
    {
        dwAlphaMask = ddsd.ddpfPixelFormat.dwRGBAlphaBitMask;
        dwRGBMask   = ddsd.ddpfPixelFormat.dwRBitMask |
ddsd.ddpfPixelFormat.dwGBitMask |
                            ddsd.ddpfPixelFormat.dwBBitMask;
        dwColorkey  = 0x00000000;           // Colorkey on black
        if (white) 
            dwColorkey = dwRGBMask;     // Colorkey on white
        dwRGBBitCount=ddsd.ddpfPixelFormat.dwRGBBitCount;
    }

    printf("dwRGBBitCount = %x\n", dwRGBBitCount);
      // Add an opaque alpha value to each non-colorkeyed pixel
    if (dwRGBBitCount == 16)
    {
        for (y = 0;y<ddsd.dwHeight;y++)
        {
            p16 =  LPWORD(DWORD(ddsd.lpSurface) + y * DWORD(ddsd.lPitch));
            for (x = 0;x<ddsd.dwWidth;x++)
            {
                *p16 = *p16 & WORD(dwRGBMask);
                if (*p16!=dwColorkey) *p16 = *p16 | (WORD)(dwAlphaMask);
                p16++;
            }
        }
    }
    if (dwRGBBitCount == 32)
    {
        for (y = 0;y<ddsd.dwHeight;y++) 
        {
            p32=PDWORD(DWORD(ddsd.lpSurface)+y*DWORD(ddsd.lPitch));
            for (x=0;x<ddsd.dwWidth;x++)
            {
                *p32=*p32&dwRGBMask;
                if (*p32!=dwColorkey)*p32=*p32|DWORD(dwAlphaMask);
                p32++;
            }
        }
    }
    lpSurface->Unlock(NULL);

    if (ddsd.dwMipMapCount>1)
    {
        texturenum++;

        DDSCAPS2 ddsCaps;
        ddsCaps.dwCaps  = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
        ddsCaps.dwCaps2 = 0;
        ddsCaps.dwCaps3 = 0;
        ddsCaps.dwCaps4 = 0;
        if (SUCCEEDED(lpSurface->GetAttachedSurface( &ddsCaps, &lpSurface )))
            lpSurface->Release();
        goto nochmal;
    }
}

the surface lptexture becomes NULL. So, NULL->Lock(NULL, &ddsd, 0, 0) is
called. That works in Windows, not in Wine.

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list