Package: moon-lander Version: 1:1.0-3 Severity: normal Tags: patch Hi, moon-lander starts up for me but dies when I press enter to start to play: ,----------------- | [EMAIL PROTECTED] moon-lander | Sound active | reading game options in /home/greek0/.moon_lander | cannot open file for reading: /home/greek0/.moon_lander - loading defaults | open /dev/sequencer: No such file or directory | Opened audio at 22050 Hz 16 bit stereoscreen initialized | Loaded font "/usr/share/games/moon-lander/fonts/ConsoleFont.bmp". Width:6, Height:13 | Loaded font "/usr/share/games/moon-lander/fonts/LargeFont.bmp". Width:16, Height:18 | Couldn't load /usr/share/games/moon-lander/images/backgrounds/..: Unsupported image format `-----------------
Relevant code paths are in get_new_background(): ,----------------- | while (!done){ | if ( files[count] = readdir(dir) ){ | | //printf("I see - %d %s\n", count, files[count]->d_name); | count++; | } | else{ | done = 1; | } | | if (count > 99) { | done = 1; | } | } | | /** ... some more code ... **/ | | if (game->back_no < 2){ | game->back_no = 2; | } | | if (game->back_no >= count){ | game->back_no = 2; | } `----------------- readdir() gives back all the directory entries, including "." and "..". Those are supposed to be filtered out later by the game->back_no < 2 check. Unfortunately readdir() doesn't give back "." and ".." as the first 2 entries on my system: ,----------------- | I see - 0 fingers.jpg | I see - 1 . | I see - 2 .. | I see - 3 earth_moon.jpg | I see - 4 orange_gas.jpg | I see - 5 blue_nebula.jpg | I see - 6 fire_and_planet.jpg | I see - 7 saturn.jpg | I see - 8 red_plain.jpg | I see - 9 glowing_nebula.jpg `----------------- So the game tries to open "..", which doesn't work, causing moon-lander to die. I've attached a patch fixing this by checking in the while loop if the dirent return by readdir() corresponds to a directory. If so it's ignored. The two if's have been changed too, so all available images are cycled. Cheers, Christian Aichinger -- System Information: Debian Release: 4.0 APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/dash Kernel: Linux 2.6.17.4-vs2.1.1-rc23-iphigenie Locale: LANG=de_AT.UTF-8, LC_CTYPE=de_AT.UTF-8 (charmap=UTF-8) Versions of packages moon-lander depends on: ii libc6 2.3.6.ds1-13 GNU C Library: Shared libraries ii libsdl-image1.2 1.2.5-3 image loading library for Simple D ii libsdl-mixer1.2 1.2.6-2 mixer library for Simple DirectMed ii libsdl1.2debian 1.2.11-8 Simple DirectMedia Layer ii moon-lander-data 1:1.0-3 Data files (sound, images) for moo moon-lander recommends no packages. -- no debconf information
--- moon-lander-1.0.orig/moon_lander.c 2007-03-10 23:07:38.000000000 +0100 +++ moon-lander-1.0/moon_lander.c 2007-03-10 23:14:50.000000000 +0100 @@ -197,6 +197,8 @@ while (!done){ if ( files[count] = readdir(dir) ){ + if ( files[count]->d_type & DT_DIR ) + continue; //printf("I see - %d %s\n", count, files[count]->d_name); count++; } @@ -222,12 +224,12 @@ game->back_no++; - if (game->back_no < 2){ - game->back_no = 2; + if (game->back_no < 0){ + game->back_no = 0; } if (game->back_no >= count){ - game->back_no = 2; + game->back_no = 0; }