Package: moon-lander
Version: 1:1.0-7
Severity: normal
Tags: patch

Dear Maintainer,

When a player reaches 10000 points, a bonus ship is supposed to be
given. However, if the player is currently at, say, 8000 points and
lands on an 1800 point pad but has 300 fuel left, the score will then be
8000 + 1800 + 300 = 10100, which is greater than 10000 but no bonus ship
will be given.

This is because the new score is calculated considering the remaining
fuel (a feature added by Debian in 20_fix-score.patch), but the bonus
ship does not consider the remaining fuel. Please see the following
patch for a simple fix:
Description: Fix bonus ship calculation to account for remaining fuel.
Author: Asher Gordon <asd...@posteo.net>
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- moon-lander-1.0.orig/moon_lander.c
+++ moon-lander-1.0/moon_lander.c
@@ -1686,7 +1686,7 @@ void gameloop(Game *game){
 
 	    // Bonus ship every 10000 points
 	    if( (game->score / 10000) < 
-		((game->score + game->current_level.landing_score[count]) / 10000 ) ) {
+		((game->score + game->current_level.landing_score[count] + game->fuel) / 10000 ) ) {
 	      // (MLH) This would be a good place to play a sound
 	      
 	      game->landing_pad = count;
To reproduce this bug, follow these steps:

Compile for easier debugging (you'll be using this value for CFLAGS
again, so put it in the environment):

  $ export CFLAGS="$(sdl-config --cflags) -O0 -ggdb3"
  $ make clean all
  [...]

Now run it under GDB (or your favorite front-end):

  $ gdb moon-lander
  [...]
  (gdb) run
  [...]

Go to the moon-lander window, and start a new game with <RET> and pause
it immediately after it starts with P. Now go back to GDB, and type
^C. Then go up until you reach the bottom most frame in moon-lander (not
libSDL).

  ^C
  Thread 1 "moon-lander" received signal SIGINT, Interrupt.
  0x00007ffff7f0dd97 in ?? () from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
  (gdb) up
  #1  0x00007ffff7f02470 in ?? ()
     from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
  (gdb) 
  #2  0x00007ffff7f16b46 in SDL_LowerBlit ()
     from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
  (gdb) 
  #3  0x00007ffff7f18812 in SDL_Flip ()
     from /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0
  (gdb) 
  #4  0x000055555555a928 in gameloop (game=0x7fffffffdc00)
      at moon_lander.c:1733
  1733        SDL_Flip(game->screen);

Now set the fuel to some huge value so that your new score will be
greater than 10000 because of the fuel left:

  (gdb) call game->fuel = 15000
  $1 = 15000
  (gdb) cont
  Continuing.

Go back to the moon-lander window, unpause the game (with P again), and
land on a pad (you can cheat with GDB if you're really bad at this
game). Your new score should be greater than 10000, but you will not get
a bonus ship.

This can happen in real life (i.e. without GDB) and you won't get a
bonus ship until 20000 points (and even then you might not). If you
repeat the steps above with my patch applied (and don't forget to
recompile--that's why you exported CFLAGS), you will find that it will
give you a bonus ship.

Thanks,
Asher

-- 
If at first you don't succeed, redefine success.


-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 5.2.0-3-amd64 (SMP w/2 CPU cores)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages moon-lander depends on:
ii  libc6             2.29-2
ii  libsdl-image1.2   1.2.12-12
ii  libsdl-mixer1.2   1.2.12-16
ii  libsdl1.2debian   1.2.15+dfsg2-5
ii  moon-lander-data  1:1.0-7

moon-lander recommends no packages.

moon-lander suggests no packages.

-- no debconf information

Attachment: signature.asc
Description: PGP signature

Reply via email to