]> thyrsus.com Git - ski.git/commitdiff
Eliminate def/ref problems with declaration ordering.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 2 Aug 2002 00:46:54 +0000 (00:46 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 2 Aug 2002 00:46:54 +0000 (00:46 +0000)
do_level.c
ski.c

index 1a9a6c9198a0802adc958a07b2fa55199d35dbdb..0e64f51db9163933b2500b8a175dfdce827972d7 100644 (file)
@@ -58,7 +58,6 @@ static char   colorstrings[MAXCOLORS][20];
 
 void init_colors()
 {
-    extern char        *tparm(), *tgetstr(), *getenv();
     char       *cp;
     int                i;
 
@@ -157,130 +156,6 @@ LEVEL *current_level;
        return (SUCCESS);
 }
 
-/*
-** "do_user"
-*/
-
-PUBLIC int do_user(current_level)
-LEVEL *current_level;
-{
-       /*
-       ** If we are jumping, just finish the line.  Otherwise, check for
-       ** obstacles, and do a command.
-       */
-
-       if (current_level->jump_count >= 0)
-               putchar('\n');
-       else {
-               check_obstacles(current_level);
-               do_command(current_level);
-       }
-}
-
-/*
-** "manipulate_objects"
-*/
-
-PUBLIC int manipulate_objects(current_level)
-LEVEL *current_level;
-{
-       /*
-       ** If there is a Snoman, the player's jet-powered skis may melt him,
-       ** or he may spontaneously melt.
-       */
-
-       if (EXISTS(current_level->snoman_pos)) {
-               if (((ABS(current_level->snoman_pos - current_level->player_pos) <= 1) &&
-                               PROB(PROB_SKIS_MELT_SNOMAN)) ||
-                               PROB(PROB_SPONTANEOUS_MELT)) {
-                       current_level->snoman_pos = NO_POSITION;
-                       ++current_level->num_snomen_melted;
-               }
-       }
-
-       /*
-       ** If there is a Snoman, move him towards the player.  If there is a            ** tree in the way, the Snoman is blocked.
-       */
-
-       if (EXISTS(current_level->snoman_pos)) {
-               if (current_level->snoman_pos < current_level->player_pos) {
-                       if (current_level->slope[current_level->snoman_pos + 1] != REP_TREE)
-                               ++current_level->snoman_pos;
-               }
-
-               else {
-                       if (current_level->slope[current_level->snoman_pos - 1] != REP_TREE)
-                               --current_level->snoman_pos;
-               }
-       }
-
-       /*                  
-       ** If there is an ICBM, handle it.
-       */
-
-       if (EXISTS(current_level->icbm_pos)) {
-               /*
-               ** If there is a Snoman, move the ICBM towards him.  Else,
-               ** self-destruct the ICBM.
-               */
-
-               if (EXISTS(current_level->snoman_pos)) {
-                       if (current_level->icbm_pos < current_level->snoman_pos)
-                               current_level->icbm_pos += ICBM_SPEED;
-                       else
-                               current_level->icbm_pos -= ICBM_SPEED;
-               }
-               else
-                       current_level->icbm_pos = NO_POSITION;
-       }
-
-       /*
-       ** If there is a fire demon on the level, handle it.
-       */
-
-       if (EXISTS(current_level->demon_pos)) {
-               /*
-               ** If there is a Snoman on the current level, move the demon
-               ** towards him.  Else, the demon might decide to leave.
-               */
-
-               if (EXISTS(current_level->snoman_pos)) {
-                       if (current_level->demon_pos < current_level->snoman_pos)
-                               current_level->demon_pos += DEMON_SPEED;
-                       else
-                               current_level->demon_pos -= DEMON_SPEED;
-               }
-               else {
-                       if (PROB(25.0))
-                               current_level->demon_pos = NO_POSITION;
-               }
-       }
-
-       /*
-       ** If there is a Snoman and an ICBM on the slope, the Snoman
-       ** might get melted.
-       */
-
-       if (EXISTS(current_level->snoman_pos) && EXISTS(current_level->icbm_pos)) {
-               if (ABS(current_level->snoman_pos - current_level->icbm_pos) <= ICBM_RANGE) {
-                       current_level->icbm_pos = NO_POSITION;
-                       current_level->snoman_pos = NO_POSITION;
-                       ++current_level->num_snomen_melted;
-               }
-       }
-
-       /*
-       ** If there is a Snoman and a fire demon, he might get melted.
-       */
-
-       if (EXISTS(current_level->snoman_pos) && EXISTS(current_level->demon_pos)) {
-               if (ABS(current_level->snoman_pos - current_level->demon_pos) <= 1) {
-                       current_level->snoman_pos = NO_POSITION;
-                       ++current_level->num_snomen_melted;
-               }
-       }
-}
-
 /*
 ** "accident" is called when the player gets into an accident, which ends the
 ** game.  "msg" is the description of the accident type, and "severity" is
@@ -500,3 +375,129 @@ LEVEL *current_level;
                break;
        }
 }
+
+/*
+** "do_user"
+*/
+
+PUBLIC int do_user(current_level)
+LEVEL *current_level;
+{
+       /*
+       ** If we are jumping, just finish the line.  Otherwise, check for
+       ** obstacles, and do a command.
+       */
+
+       if (current_level->jump_count >= 0)
+               putchar('\n');
+       else {
+               check_obstacles(current_level);
+               do_command(current_level);
+       }
+}
+
+/*
+** "manipulate_objects"
+*/
+
+PUBLIC int manipulate_objects(current_level)
+LEVEL *current_level;
+{
+       /*
+       ** If there is a Snoman, the player's jet-powered skis may melt him,
+       ** or he may spontaneously melt.
+       */
+
+       if (EXISTS(current_level->snoman_pos)) {
+               if (((ABS(current_level->snoman_pos - current_level->player_pos) <= 1) &&
+                               PROB(PROB_SKIS_MELT_SNOMAN)) ||
+                               PROB(PROB_SPONTANEOUS_MELT)) {
+                       current_level->snoman_pos = NO_POSITION;
+                       ++current_level->num_snomen_melted;
+               }
+       }
+
+       /*
+       ** If there is a Snoman, move him towards the player.  If there is a            ** tree in the way, the Snoman is blocked.
+       */
+
+       if (EXISTS(current_level->snoman_pos)) {
+               if (current_level->snoman_pos < current_level->player_pos) {
+                       if (current_level->slope[current_level->snoman_pos + 1] != REP_TREE)
+                               ++current_level->snoman_pos;
+               }
+
+               else {
+                       if (current_level->slope[current_level->snoman_pos - 1] != REP_TREE)
+                               --current_level->snoman_pos;
+               }
+       }
+
+       /*                  
+       ** If there is an ICBM, handle it.
+       */
+
+       if (EXISTS(current_level->icbm_pos)) {
+               /*
+               ** If there is a Snoman, move the ICBM towards him.  Else,
+               ** self-destruct the ICBM.
+               */
+
+               if (EXISTS(current_level->snoman_pos)) {
+                       if (current_level->icbm_pos < current_level->snoman_pos)
+                               current_level->icbm_pos += ICBM_SPEED;
+                       else
+                               current_level->icbm_pos -= ICBM_SPEED;
+               }
+               else
+                       current_level->icbm_pos = NO_POSITION;
+       }
+
+       /*
+       ** If there is a fire demon on the level, handle it.
+       */
+
+       if (EXISTS(current_level->demon_pos)) {
+               /*
+               ** If there is a Snoman on the current level, move the demon
+               ** towards him.  Else, the demon might decide to leave.
+               */
+
+               if (EXISTS(current_level->snoman_pos)) {
+                       if (current_level->demon_pos < current_level->snoman_pos)
+                               current_level->demon_pos += DEMON_SPEED;
+                       else
+                               current_level->demon_pos -= DEMON_SPEED;
+               }
+               else {
+                       if (PROB(25.0))
+                               current_level->demon_pos = NO_POSITION;
+               }
+       }
+
+       /*
+       ** If there is a Snoman and an ICBM on the slope, the Snoman
+       ** might get melted.
+       */
+
+       if (EXISTS(current_level->snoman_pos) && EXISTS(current_level->icbm_pos)) {
+               if (ABS(current_level->snoman_pos - current_level->icbm_pos) <= ICBM_RANGE) {
+                       current_level->icbm_pos = NO_POSITION;
+                       current_level->snoman_pos = NO_POSITION;
+                       ++current_level->num_snomen_melted;
+               }
+       }
+
+       /*
+       ** If there is a Snoman and a fire demon, he might get melted.
+       */
+
+       if (EXISTS(current_level->snoman_pos) && EXISTS(current_level->demon_pos)) {
+               if (ABS(current_level->snoman_pos - current_level->demon_pos) <= 1) {
+                       current_level->snoman_pos = NO_POSITION;
+                       ++current_level->num_snomen_melted;
+               }
+       }
+}
+
+
diff --git a/ski.c b/ski.c
index eed4b013676afc914ae6c4877cda8536fd8eff7f..a89ae36dd336f2eb92716daf4b7613ddd445266c 100644 (file)
--- a/ski.c
+++ b/ski.c
@@ -95,41 +95,6 @@ LEVEL *level_ptr;
        return (SUCCESS);
 }
 
-/*
-** "main" is the top level function of the game.
-*/
-
-PUBLIC int main()
-{
-       LEVEL level;
-
-#ifdef A_COLOR
-       /*
-       ** Initialize the color support.
-       */
-
-       init_colors();
-#endif /* A_COLOR */
-
-       /*
-       ** Initialize the game.
-       */
-
-       if (init(&level) != SUCCESS)
-               exit(1);
-
-       /*
-       ** Perform the game loop until the game is over.
-       */
-
-       for (;;) {
-               draw_picture(&level);
-               do_user(&level);
-               manipulate_objects(&level);
-               update_level(&level);
-       }
-}
-
 /*
 ** "gen_next_slope" generates the slope of the next level, dependent upon
 ** the characteristics of the current level, the probabilities, and the
@@ -302,3 +267,40 @@ LEVEL *current_level;
 
        return (SUCCESS);
 }
+
+/*
+** "main" is the top level function of the game.
+*/
+
+PUBLIC int main()
+{
+       LEVEL level;
+
+#ifdef A_COLOR
+       /*
+       ** Initialize the color support.
+       */
+
+       init_colors();
+#endif /* A_COLOR */
+
+       /*
+       ** Initialize the game.
+       */
+
+       if (init(&level) != SUCCESS)
+               exit(1);
+
+       /*
+       ** Perform the game loop until the game is over.
+       */
+
+       for (;;) {
+               draw_picture(&level);
+               do_user(&level);
+               manipulate_objects(&level);
+               update_level(&level);
+       }
+}
+
+