Comment 3 for bug 372936

Revision history for this message
Ying-Chun Liu (paulliu) wrote : Re: English Tsukihime crashes before title screen

 *** can't find file [image\title\titlebtn1.png] ***

The above warning message mainly causes the crash.
It's because image\title\titlebtn1.png is not there.

In current version, the code is:
        if ( buf[0] != '\0' ){
            btndef_info.setImageName( buf );
            parseTaggedString( &btndef_info );
            btndef_info.trans_mode = AnimationInfo::TRANS_COPY;
            setupAnimationInfo( &btndef_info );
            SDL_SetAlpha( btndef_info.image_surface, DEFAULT_BLIT_FLAG, SDL_ALPHA_OPAQUE );
        }

In this case, buf = "image\title\titlebtn1.png" so btndef_info.setImageName() and following calls will result btndef_info.image_surface to be NULL because it's really not exists.
And then SDL_SetAlpha crash because it's NULL.

In Haeleth's version, the code is
        if ( buf[0] != '\0' ){
            btndef_info.setImageName( buf );
            parseTaggedString( &btndef_info );
            btndef_info.trans_mode = AnimationInfo::TRANS_COPY;
            setupAnimationInfo( &btndef_info );
#ifdef RCA_SCALE
            if (btndef_info.image_surface
                && (scr_stretch_x > 1.0 || scr_stretch_y > 1.0 )) {
                // Scale and reposition buttons if screen is bigger than game
                SDL_Surface* src = btndef_info.image_surface;
                SDL_PixelFormat *fmt = src->format;
                SDL_Surface* dst = SDL_CreateRGBSurface( SDL_SWSURFACE,
                                                         scr_stretch_x*src->w,
                                                         scr_stretch_y*src->h,
                                                         fmt->BitsPerPixel, fmt
                resizeSurface( src, dst );
                btndef_info.image_surface = dst;
                btndef_info.pos.w *= scr_stretch_x;
                btndef_info.pos.h *= scr_stretch_y;
                SDL_FreeSurface( src );
            }
            if (btndef_info.image_surface)
#endif
            SDL_SetAlpha( btndef_info.image_surface, DEFAULT_BLIT_FLAG, SDL_ALPHA_OPAQUE );
        } else btntime_value = 0; //Mion - clear the btn wait time

So when RCA_SCALE is defined, it checks btndef_info.image_surface before calls to SDL_SetAlpha() which won't cause the crash.