File: 05-cheat.patch

package info (click to toggle)
abe 1.1%2Bdfsg-6.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,112 kB
  • sloc: ansic: 5,468; sh: 2,725; objc: 224; makefile: 48
file content (96 lines) | stat: -rw-r--r-- 2,603 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From: Bart Martens <bartm@debian.org>
Date: Sat, 11 Jun 2016 10:54:35 +0200
Subject: 05 cheat

---
 src/Game.c | 19 ++++++++++++++++++-
 src/Game.h |  1 +
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/Game.c b/src/Game.c
index a5cbcb1..74002c7 100644
--- a/src/Game.c
+++ b/src/Game.c
@@ -3,6 +3,7 @@
 #include <string.h>
 
 Game game;
+static int cheat = 0; // 0=no, 1=yes
 
 // path_sprintf should not be used by other .c files, as it does not fit for them.
 static void
@@ -381,6 +382,17 @@ gameMainLoop(SDL_Event * event)
     case SDLK_d:
       debugMonsters();
       break;
+    case SDLK_c:
+      if( event->key.keysym.mod & ( KMOD_CTRL | KMOD_SHIFT | KMOD_ALT ) && getenv( "ABE_IS_CHEATING" ) )
+        cheat = 1 - cheat;
+      if( cheat )
+      {
+        game.lives = MAX_LIVES;
+        game.keys = MAX_KEYS;
+        game.balloons = MAX_BALLOONS;
+        game.health = MAX_HEALTH;
+      }
+      break;
 #if GOD_MODE
     case SDLK_k:
       game.keys++;
@@ -391,6 +403,7 @@ gameMainLoop(SDL_Event * event)
       if(!game.end_game) {
         if(!game.balloonTimer && game.balloons) {
           playSound(BUBBLE_SOUND);
+          if( ! cheat )
           game.balloons--;
           game.balloonTimer = BALLOON_RIDE_INTERVAL;
           map.gravity = 0;
@@ -457,9 +470,11 @@ handleDeath(LiveMonster * live)
 
   if(live) {
     showMapStatus(live->monster->name);
+    if( ! cheat )
     game.health -= (live->monster->damage * (game.difficoulty + 1));
   } else {
     showMapStatus("drowning!");
+    if( ! cheat )
     game.health--;              // water damage
     show_effect = !(game.tick % 40);
   }
@@ -490,6 +505,7 @@ handleDeath(LiveMonster * live)
   if(game.god_mode)
     return;
 
+  if( ! cheat )
   game.lives--;
 
   // Flash player. Don't move monsters during this.
@@ -692,6 +708,7 @@ detectCollision(int dir)
         EMPTY_MAP;
       map.image_index[LEVEL_FORE][key.pos_x + (key.pos_y * map.w)] =
         img_door2;
+      if( ! cheat )
       game.keys--;
       map.redraw = 1;
       // always return 0 (block) so we don't fall into a door and get stuck there... (was a nasty bug)
@@ -772,7 +789,7 @@ runMap()
       game.player_start_y = 28;
     }
 
-    game.lives = 5;
+    game.lives = MAX_LIVES;
     game.score = 0;
     game.keys = 0;
     game.balloons = 0;
diff --git a/src/Game.h b/src/Game.h
index aa61e51..84c1b03 100644
--- a/src/Game.h
+++ b/src/Game.h
@@ -20,6 +20,7 @@
 
 #define SPRING_JUMP 30
 
+#define MAX_LIVES 5
 #define MAX_HEALTH 100
 
 // don't hold more than these... mainly b/c the gui can't handle it