Ejemplo n.º 1
0
/*
====================================================================
Delete terrain types & co
====================================================================
*/
void terrain_delete( void )
{
    int i, j;
    /* terrain types */
    if ( terrain_types ) {
        for ( i = 0; i < terrain_type_count; i++ ) {
            if ( terrain_types[i].images ) {
                for ( j = weather_type_count - 1; j >= 0; j-- ) 
                    if ( terrain_types[i].images[j] ) {
                        if ( terrain_types[i].images[j] == terrain_types[i].images[0] )
                            if ( j > 0 )
                                continue; /* only a pointer */
                        SDL_FreeSurface( terrain_types[i].images[j] );
                    }
                free( terrain_types[i].images );
            }
            if ( terrain_types[i].images_fogged ) {
                for ( j = weather_type_count - 1; j >= 0; j-- )
                    if ( terrain_types[i].images_fogged[j] ) {
                        if ( terrain_types[i].images_fogged[j] == terrain_types[i].images_fogged[0] )
                            if ( j > 0 )
                                continue; /* only a pointer */
                        SDL_FreeSurface( terrain_types[i].images_fogged[j] );
                    }
                free( terrain_types[i].images_fogged );
            }
            if ( terrain_types[i].flags ) free( terrain_types[i].flags );
            if ( terrain_types[i].mov ) free( terrain_types[i].mov );
            if ( terrain_types[i].spt ) free( terrain_types[i].spt );
            if ( terrain_types[i].name ) free( terrain_types[i].name );
        }
        free( terrain_types ); terrain_types = 0;
        terrain_type_count = 0;
    }
    /* weather */
    if ( weather_types ) {
        for ( i = 0; i < weather_type_count; i++ ) {
            if ( weather_types[i].id ) free( weather_types[i].id );
            if ( weather_types[i].name ) free( weather_types[i].name );
        }
        free( weather_types ); weather_types = 0;
        weather_type_count = 0;
    }
    /* terrain icons */
    if ( terrain_icons ) {
        if ( terrain_icons->fog ) SDL_FreeSurface( terrain_icons->fog );
        if ( terrain_icons->grid ) SDL_FreeSurface( terrain_icons->grid );
        if ( terrain_icons->danger ) SDL_FreeSurface( terrain_icons->danger );
        if ( terrain_icons->select ) SDL_FreeSurface( terrain_icons->select );
        anim_delete( &terrain_icons->cross );
        anim_delete( &terrain_icons->expl1 );
        anim_delete( &terrain_icons->expl2 );
#ifdef WITH_SOUND
        if ( terrain_icons->wav_expl ) wav_free( terrain_icons->wav_expl );
        if ( terrain_icons->wav_select ) wav_free( terrain_icons->wav_select );
#endif
        free( terrain_icons ); terrain_icons = 0;
    }
}
Ejemplo n.º 2
0
// 録音中にエラーが起きて終了
void die(char *mes)
{
    Sleep(0);
	fprintf(stderr,mes);
	wav_free();
	exit(1);
}