rnd-20030426-2-src
authorHolger Schemel <info@artsoft.org>
Sat, 26 Apr 2003 18:45:19 +0000 (20:45 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:41:33 +0000 (10:41 +0200)
14 files changed:
src/cartoons.c
src/conf_gfx.c
src/conftime.h
src/editor.c
src/events.c
src/game.c
src/init.c
src/libgame/setup.c
src/main.c
src/main.h
src/network.c
src/screens.c
src/tape.c
src/tools.c

index b95525049e6cf613d8ea1b2a2a36f1ee16f30b14..5bacdf29c3aad8c6dcd3d1e6c3984617d3a92a87 100644 (file)
@@ -24,7 +24,7 @@ static struct ToonInfo toons[MAX_NUM_TOONS];
 static void PrepareBackbuffer()
 {
   /* Fill empty backbuffer for animation functions */
-  if (setup.direct_draw && game_status == PLAYING)
+  if (setup.direct_draw && game_status == GAME_MODE_PLAYING)
   {
     int xx,yy;
 
@@ -38,7 +38,7 @@ static void PrepareBackbuffer()
     SetDrawtoField(DRAW_DIRECT);
   }
 
-  if (setup.soft_scrolling && game_status == PLAYING)
+  if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING)
   {
     int fx = FX, fy = FY;
 
@@ -51,8 +51,8 @@ static void PrepareBackbuffer()
 
 boolean ToonNeedsRedraw()
 {
-  return (game_status == HELPSCREEN ||
-         (game_status == MAINMENU &&
+  return (game_status == GAME_MODE_INFO ||
+         (game_status == GAME_MODE_MAIN &&
           ((redraw_mask & REDRAW_MICROLEVEL) ||
            (redraw_mask & REDRAW_MICROLABEL))));
 }
index ef05d3bf2f0dacc0794b071f05b63b563189f855..7b341da39044cfc0902fe3402857210219b3cc72 100644 (file)
@@ -3342,8 +3342,8 @@ struct ConfigInfo image_config[] =
   { "background.SETUP",                                UNDEFINED_FILENAME      },
   { "background.DOOR",                         UNDEFINED_FILENAME      },
 
-  /* the following directives are not associated with an image,
-     but make sense to be defined in "graphicsinfo.conf", too */
+  /* the following directives are not associated with an image, but
+     probably make sense to be defined in "graphicsinfo.conf", too */
 
   { "global.num_toons",                                "20"                    },
 
@@ -3351,6 +3351,16 @@ struct ConfigInfo image_config[] =
   { "menu.draw_yoffset",                       "0"                     },
   { "menu.draw_xoffset.MAIN",                  "0"                     },
   { "menu.draw_yoffset.MAIN",                  "0"                     },
+  { "menu.draw_xoffset.LEVELS",                        "0"                     },
+  { "menu.draw_yoffset.LEVELS",                        "0"                     },
+  { "menu.draw_xoffset.SCORES",                        "0"                     },
+  { "menu.draw_yoffset.SCORES",                        "0"                     },
+  { "menu.draw_xoffset.EDITOR",                        "0"                     },
+  { "menu.draw_yoffset.EDITOR",                        "0"                     },
+  { "menu.draw_xoffset.INFO",                  "0"                     },
+  { "menu.draw_yoffset.INFO",                  "0"                     },
+  { "menu.draw_xoffset.SETUP",                 "0"                     },
+  { "menu.draw_yoffset.SETUP",                 "0"                     },
 
   { "door.step_offset",                                "2"                     },
   { "door.step_delay",                         "10"                    },
index f4dfe72679c85a5a172e23b6bb4c57acd5c1ccc4..c8aa1774b949ab77b1748e431b1170ef155a4f4e 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-04-26 19:05]"
+#define COMPILE_DATE_STRING "[2003-04-26 20:44]"
index b028364fdeb4131f8755da432c750dca8b8f3439..7e47789d5b7cff2fa0fcff139c0d285d05890221 100644 (file)
@@ -2607,7 +2607,7 @@ void CreateLevelEditorGadgets()
   int old_game_status = game_status;
 
   /* setting 'game_status' is needed to get the right fonts for the editor */
-  game_status = LEVELED;
+  game_status = GAME_MODE_EDITOR;
 
   ReinitializeElementList();
 
@@ -5047,7 +5047,7 @@ static void HandleControlButtons(struct GadgetInfo *gi)
          TapeStartRecording();
 
        level_editor_test_game = TRUE;
-       game_status = PLAYING;
+       game_status = GAME_MODE_PLAYING;
 
        InitGame();
       }
@@ -5205,7 +5205,7 @@ void HandleEditorGadgetInfoText(void *ptr)
   char shortcut[MAX_OUTPUT_LINESIZE + 1];
   int max_infotext_len = getMaxInfoTextLength();
 
-  if (game_status != LEVELED)
+  if (game_status != GAME_MODE_EDITOR)
     return;
 
   ClearEditorGadgetInfoText();
@@ -5386,7 +5386,7 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed)
     /*
     CloseDoor(DOOR_CLOSE_ALL);
     */
-    game_status = MAINMENU;
+    game_status = GAME_MODE_MAIN;
     DrawMainMenu();
   }
   else
index 1f78e6b2559b1a814425ef7d2072c9ce420219f8..3d3cdde0e4a7aeb3e351c079aff59baa0825dc02 100644 (file)
@@ -50,7 +50,7 @@ int FilterMouseMotionEvents(const Event *event)
   cursor_inside_playfield = (motion->x >= SX && motion->x < SX + SXSIZE &&
                             motion->y >= SY && motion->y < SY + SYSIZE);
 
-  if (game_status == PLAYING && playfield_cursor_set)
+  if (game_status == GAME_MODE_PLAYING && playfield_cursor_set)
   {
     SetMouseCursor(CURSOR_DEFAULT);
     playfield_cursor_set = FALSE;
@@ -58,7 +58,7 @@ int FilterMouseMotionEvents(const Event *event)
   }
 
   /* skip mouse motion events without pressed button outside level editor */
-  if (button_status == MB_RELEASED && game_status != LEVELED)
+  if (button_status == MB_RELEASED && game_status != GAME_MODE_EDITOR)
     return 0;
   else
     return 1;
@@ -116,7 +116,7 @@ void EventLoop(void)
     else
     {
       /* when playing, display a special mouse pointer inside the playfield */
-      if (game_status == PLAYING)
+      if (game_status == GAME_MODE_PLAYING)
       {
        if (!playfield_cursor_set && cursor_inside_playfield &&
            DelayReached(&playfield_cursor_delay, 1000))
@@ -137,7 +137,7 @@ void EventLoop(void)
     /* don't use all CPU time when idle; the main loop while playing
        has its own synchronization and is CPU friendly, too */
 
-    if (game_status == PLAYING)
+    if (game_status == GAME_MODE_PLAYING)
       HandleGameActions();
     else
     {
@@ -149,7 +149,7 @@ void EventLoop(void)
     /* refresh window contents from drawing buffer, if needed */
     BackToFront();
 
-    if (game_status == EXITGAME)
+    if (game_status == GAME_MODE_QUIT)
       return;
   }
 }
@@ -266,7 +266,7 @@ void SleepWhileUnmapped()
     }
   }
 
-  if (game_status == PLAYING)
+  if (game_status == GAME_MODE_PLAYING)
     KeyboardAutoRepeatOff();
 }
 
@@ -296,7 +296,7 @@ void HandleMotionEvent(MotionEvent *event)
     return;    /* window and pointer are on different screens */
 
 #if 1
-  if (button_status == MB_RELEASED && game_status != LEVELED)
+  if (button_status == MB_RELEASED && game_status != GAME_MODE_EDITOR)
     return;
 #endif
 
@@ -308,7 +308,7 @@ void HandleMotionEvent(MotionEvent *event)
 void HandleKeyEvent(KeyEvent *event)
 {
   int key_status = (event->type==EVENT_KEYPRESS ? KEY_PRESSED : KEY_RELEASED);
-  boolean with_modifiers = (game_status == PLAYING ? FALSE : TRUE);
+  boolean with_modifiers = (game_status == GAME_MODE_PLAYING ? FALSE : TRUE);
   Key key = GetEventKey(event, with_modifiers);
 
   HandleKey(key, key_status);
@@ -339,12 +339,12 @@ void HandleFocusEvent(FocusChangeEvent *event)
        because unfortunately this is a global setting and not (which
        would be far better) set for each X11 window individually.
        The effect would be keyboard auto repeat while playing the game
-       (game_status == PLAYING), which is not desired.
+       (game_status == GAME_MODE_PLAYING), which is not desired.
        To avoid this special case, we just wait 1/10 second before
        processing the 'FocusIn' event.
     */
 
-    if (game_status == PLAYING)
+    if (game_status == GAME_MODE_PLAYING)
     {
       Delay(100);
       KeyboardAutoRepeatOff();
@@ -380,34 +380,34 @@ void HandleButton(int mx, int my, int button)
 
   switch(game_status)
   {
-    case MAINMENU:
+    case GAME_MODE_MAIN:
       HandleMainMenu(mx,my, 0,0, button);
       break;
 
-    case TYPENAME:
+    case GAME_MODE_PSEUDO_TYPENAME:
       HandleTypeName(0, KSYM_Return);
       break;
 
-    case CHOOSELEVEL:
+    case GAME_MODE_LEVELS:
       HandleChooseLevel(mx,my, 0,0, button);
       break;
 
-    case HALLOFFAME:
+    case GAME_MODE_SCORES:
       HandleHallOfFame(0,0, 0,0, button);
       break;
 
-    case LEVELED:
+    case GAME_MODE_EDITOR:
       break;
 
-    case HELPSCREEN:
+    case GAME_MODE_INFO:
       HandleHelpScreen(button);
       break;
 
-    case SETUP:
+    case GAME_MODE_SETUP:
       HandleSetupScreen(mx,my, 0,0, button);
       break;
 
-    case PLAYING:
+    case GAME_MODE_PLAYING:
 #ifdef DEBUG
       if (button == MB_RELEASED)
       {
@@ -463,7 +463,7 @@ void HandleKey(Key key, int key_status)
     { &custom_key.bomb,  DEFAULT_KEY_BOMB,  JOY_BUTTON_2 }
   };
 
-  if (game_status == PLAYING)
+  if (game_status == GAME_MODE_PLAYING)
   {
     /* only needed for single-step tape recording mode */
     static boolean clear_button_2[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
@@ -545,36 +545,36 @@ void HandleKey(Key key, int key_status)
     HandleJoystick();
   }
 
-  if (game_status != PLAYING)
+  if (game_status != GAME_MODE_PLAYING)
     key_joystick_mapping = 0;
 
   if (key_status == KEY_RELEASED)
     return;
 
   if ((key == KSYM_Return || key == setup.shortcut.toggle_pause) &&
-      game_status == PLAYING && AllPlayersGone)
+      game_status == GAME_MODE_PLAYING && AllPlayersGone)
   {
     CloseDoor(DOOR_CLOSE_1);
-    game_status = MAINMENU;
+    game_status = GAME_MODE_MAIN;
     DrawMainMenu();
     return;
   }
 
   /* allow quick escape to the main menu with the Escape key */
   if (key == KSYM_Escape &&
-      game_status != MAINMENU &&
-      game_status != PLAYING &&
-      game_status != LEVELED &&
-      game_status != CHOOSELEVEL &&
-      game_status != SETUP)
+      game_status != GAME_MODE_MAIN &&
+      game_status != GAME_MODE_PLAYING &&
+      game_status != GAME_MODE_EDITOR &&
+      game_status != GAME_MODE_LEVELS &&
+      game_status != GAME_MODE_SETUP)
   {
-    game_status = MAINMENU;
+    game_status = GAME_MODE_MAIN;
     DrawMainMenu();
     return;
   }
 
   /* special key shortcuts */
-  if (game_status == MAINMENU || game_status == PLAYING)
+  if (game_status == GAME_MODE_MAIN || game_status == GAME_MODE_PLAYING)
   {
     if (key == setup.shortcut.save_game)
       TapeQuickSave();
@@ -587,7 +587,7 @@ void HandleKey(Key key, int key_status)
 #if 0
 #ifndef DEBUG
 
-  if (game_status == PLAYING && (tape.playing || tape.pausing))
+  if (game_status == GAME_MODE_PLAYING && (tape.playing || tape.pausing))
     return;
 
 #endif
@@ -598,42 +598,42 @@ void HandleKey(Key key, int key_status)
 
   switch(game_status)
   {
-    case TYPENAME:
+    case GAME_MODE_PSEUDO_TYPENAME:
       HandleTypeName(0, key);
       break;
 
-    case MAINMENU:
-    case CHOOSELEVEL:
-    case SETUP:
+    case GAME_MODE_MAIN:
+    case GAME_MODE_LEVELS:
+    case GAME_MODE_SETUP:
       switch(key)
       {
        case KSYM_Return:
-         if (game_status == MAINMENU)
+         if (game_status == GAME_MODE_MAIN)
            HandleMainMenu(0,0, 0,0, MB_MENU_CHOICE);
-          else if (game_status == CHOOSELEVEL)
+          else if (game_status == GAME_MODE_LEVELS)
             HandleChooseLevel(0,0, 0,0, MB_MENU_CHOICE);
-         else if (game_status == SETUP)
+         else if (game_status == GAME_MODE_SETUP)
            HandleSetupScreen(0,0, 0,0, MB_MENU_CHOICE);
          break;
 
        case KSYM_Escape:
-          if (game_status == CHOOSELEVEL)
+          if (game_status == GAME_MODE_LEVELS)
             HandleChooseLevel(0,0, 0,0, MB_MENU_LEAVE);
-         else if (game_status == SETUP)
+         else if (game_status == GAME_MODE_SETUP)
            HandleSetupScreen(0,0, 0,0, MB_MENU_LEAVE);
          break;
 
         case KSYM_Page_Up:
-          if (game_status == CHOOSELEVEL)
+          if (game_status == GAME_MODE_LEVELS)
             HandleChooseLevel(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
-         else if (game_status == SETUP)
+         else if (game_status == GAME_MODE_SETUP)
            HandleSetupScreen(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
          break;
 
         case KSYM_Page_Down:
-          if (game_status == CHOOSELEVEL)
+          if (game_status == GAME_MODE_LEVELS)
             HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
-         else if (game_status == SETUP)
+         else if (game_status == GAME_MODE_SETUP)
            HandleSetupScreen(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
          break;
 
@@ -648,15 +648,15 @@ void HandleKey(Key key, int key_status)
       }
       break;
 
-    case HELPSCREEN:
+    case GAME_MODE_INFO:
       HandleHelpScreen(MB_RELEASED);
       break;
 
-    case HALLOFFAME:
+    case GAME_MODE_SCORES:
       switch(key)
       {
        case KSYM_Return:
-         game_status = MAINMENU;
+         game_status = GAME_MODE_MAIN;
          DrawMainMenu();
          BackToFront();
          break;
@@ -674,12 +674,12 @@ void HandleKey(Key key, int key_status)
       }
       break;
 
-    case LEVELED:
+    case GAME_MODE_EDITOR:
       if (!anyTextGadgetActiveOrJustFinished || key == KSYM_Escape)
        HandleLevelEditorKeyInput(key);
       break;
 
-    case PLAYING:
+    case GAME_MODE_PLAYING:
     {
       switch(key)
       {
@@ -830,7 +830,7 @@ void HandleKey(Key key, int key_status)
 
 void HandleNoEvent()
 {
-  if (button_status && game_status != PLAYING)
+  if (button_status && game_status != GAME_MODE_PLAYING)
   {
     HandleButton(0, 0, -button_status);
     return;
@@ -886,9 +886,9 @@ void HandleJoystick()
 
   switch(game_status)
   {
-    case MAINMENU:
-    case CHOOSELEVEL:
-    case SETUP:
+    case GAME_MODE_MAIN:
+    case GAME_MODE_LEVELS:
+    case GAME_MODE_SETUP:
     {
       static unsigned long joystickmove_delay = 0;
 
@@ -896,35 +896,35 @@ void HandleJoystick()
          !DelayReached(&joystickmove_delay, GADGET_FRAME_DELAY))
        newbutton = dx = dy = 0;
 
-      if (game_status == MAINMENU)
+      if (game_status == GAME_MODE_MAIN)
        HandleMainMenu(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
-      else if (game_status == CHOOSELEVEL)
+      else if (game_status == GAME_MODE_LEVELS)
         HandleChooseLevel(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
-      else if (game_status == SETUP)
+      else if (game_status == GAME_MODE_SETUP)
        HandleSetupScreen(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
       break;
     }
 
-    case HALLOFFAME:
+    case GAME_MODE_SCORES:
       HandleHallOfFame(0,0, dx,dy, !newbutton);
       break;
 
-    case HELPSCREEN:
+    case GAME_MODE_INFO:
       HandleHelpScreen(!newbutton);
       break;
 
-    case LEVELED:
+    case GAME_MODE_EDITOR:
       HandleLevelEditorIdle();
       break;
 
-    case PLAYING:
+    case GAME_MODE_PLAYING:
       if (tape.playing || keyboard)
        newbutton = ((joy & JOY_BUTTON) != 0);
 
       if (AllPlayersGone && newbutton)
       {
        CloseDoor(DOOR_CLOSE_1);
-       game_status = MAINMENU;
+       game_status = GAME_MODE_MAIN;
        DrawMainMenu();
        return;
       }
index 25e138060311fa14b1ebca089bd154b2c7dc68db..436751f65916f7005513f7bb2b13d248e7d4bc1b 100644 (file)
@@ -1183,7 +1183,7 @@ void GameWon()
 
   if ((hi_pos = NewHiScore()) >= 0) 
   {
-    game_status = HALLOFFAME;
+    game_status = GAME_MODE_SCORES;
     DrawHallOfFame(hi_pos);
     if (raise_level)
     {
@@ -1193,7 +1193,7 @@ void GameWon()
   }
   else
   {
-    game_status = MAINMENU;
+    game_status = GAME_MODE_MAIN;
     if (raise_level)
     {
       level_nr++;
@@ -4543,7 +4543,7 @@ void GameActions()
   byte *recorded_player_action;
   byte summarized_player_action = 0;
 
-  if (game_status != PLAYING)
+  if (game_status != GAME_MODE_PLAYING)
     return;
 
   action_delay_value =
@@ -4569,7 +4569,7 @@ void GameActions()
     HandleNetworking();
 #endif
 
-    if (game_status != PLAYING)
+    if (game_status != GAME_MODE_PLAYING)
       return;
 
     if (!network_player_action_received)
@@ -6812,7 +6812,7 @@ void RequestQuitGame(boolean ask_if_really_quit)
     else
 #endif
     {
-      game_status = MAINMENU;
+      game_status = GAME_MODE_MAIN;
       DrawMainMenu();
     }
   }
@@ -6973,7 +6973,7 @@ static void HandleGameButtons(struct GadgetInfo *gi)
 {
   int id = gi->custom_id;
 
-  if (game_status != PLAYING)
+  if (game_status != GAME_MODE_PLAYING)
     return;
 
   switch (id)
index 6b6ed64e88fd46f06ea5e5f64aafb95b0fc3a223..d327a93d4895c21076fe1fe00e0b23bb8af1aa08 100644 (file)
@@ -260,21 +260,11 @@ static int getFontBitmapID(int font_nr)
 {
   int special = -1;
 
-  if (game_status == MAINMENU || game_status == TYPENAME)
+  if (game_status >= GAME_MODE_MAIN && game_status <= GAME_MODE_PSEUDO_PREVIEW)
+    special = game_status;
+  else if (game_status == GAME_MODE_PSEUDO_TYPENAME)
     special = GFX_SPECIAL_ARG_MAIN;
-  else if (game_status == CHOOSELEVEL)
-    special = GFX_SPECIAL_ARG_LEVELS;
-  else if (game_status == HALLOFFAME)
-    special = GFX_SPECIAL_ARG_SCORES;
-  else if (game_status == LEVELED)
-    special = GFX_SPECIAL_ARG_EDITOR;
-  else if (game_status == HELPSCREEN)
-    special = GFX_SPECIAL_ARG_INFO;
-  else if (game_status == SETUP)
-    special = GFX_SPECIAL_ARG_SETUP;
-  else if (game_status == PSEUDO_PREVIEW)
-    special = GFX_SPECIAL_ARG_PREVIEW;
-  else if (game_status == PLAYING || game_status == PSEUDO_DOOR)
+  else if (game_status == GAME_MODE_PLAYING)
     special = GFX_SPECIAL_ARG_DOOR;
 
   if (special != -1)
@@ -2578,6 +2568,16 @@ static void InitArtworkConfig()
     "menu.draw_yoffset",
     "menu.draw_xoffset.MAIN",
     "menu.draw_yoffset.MAIN",
+    "menu.draw_xoffset.LEVELS",
+    "menu.draw_yoffset.LEVELS",
+    "menu.draw_xoffset.SCORES",
+    "menu.draw_yoffset.SCORES",
+    "menu.draw_xoffset.EDITOR",
+    "menu.draw_yoffset.EDITOR",
+    "menu.draw_xoffset.INFO",
+    "menu.draw_yoffset.INFO",
+    "menu.draw_xoffset.SETUP",
+    "menu.draw_yoffset.SETUP",
     "door.step_offset",
     "door.step_delay",
     NULL
@@ -2973,7 +2973,7 @@ void OpenAll()
     return;
   }
 
-  game_status = MAINMENU;
+  game_status = GAME_MODE_MAIN;
 
   DrawMainMenu();
 
index 8be4c7a8a80e59312ae41a010d37117da914331c..47bc9b4732f24e24e7ee38a3d367ed9acc6bfd49 100644 (file)
@@ -1125,11 +1125,19 @@ static unsigned int get_hash_from_key(void *key)
   /*
     djb2
 
-    this algorithm (k=33) was first reported by dan bernstein many years ago in
-    comp.lang.c. another version of this algorithm (now favored by bernstein)
-    uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why
+    This algorithm (k=33) was first reported by Dan Bernstein many years ago in
+    'comp.lang.c'. Another version of this algorithm (now favored by Bernstein)
+    uses XOR: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why
     it works better than many other constants, prime or not) has never been
     adequately explained.
+
+    If you just want to have a good hash function, and cannot wait, djb2
+    is one of the best string hash functions i know. It has excellent
+    distribution and speed on many different sets of keys and table sizes.
+    You are not likely to do better with one of the "well known" functions
+    such as PJW, K&R, etc.
+
+    Ozan (oz) Yigit [http://www.cs.yorku.ca/~oz/hash.html]
   */
 
   char *str = (char *)key;
@@ -1190,26 +1198,6 @@ void setHashEntry(SetupFileHash *hash, char *token, char *value)
 #ifdef DEBUG
 static void printSetupFileHash(SetupFileHash *hash)
 {
-#if 0
-  if (hash == NULL)
-    return;
-
-  /* iterator constructor only returns valid iterator for non-empty hash */
-  if (hash != NULL && hashtable_count(hash) > 0)
-  {
-    struct hashtable_itr *itr = hashtable_iterator(hash);
-
-    do
-    {
-      printf("token: '%s'\n", (char *)hashtable_iterator_key(itr));
-      printf("value: '%s'\n", (char *)hashtable_iterator_value(itr));
-    }
-    while (hashtable_iterator_advance(itr));
-
-    free(itr);
-  }
-#endif
-
   BEGIN_HASH_ITERATION(hash, itr)
   {
     printf("token: '%s'\n", HASH_ITERATION_TOKEN(itr));
index 7fd87aee20f7584fc075a25ed81f6b7cf7471b8a..a3f250949dacbfaf48f306523e1217bcf81a83a9 100644 (file)
@@ -2988,14 +2988,14 @@ struct ElementDirectionInfo element_direction_info[NUM_DIRECTIONS + 1] =
 
 struct SpecialSuffixInfo special_suffix_info[NUM_SPECIAL_GFX_ARGS + 1] =
 {
-  { ".MAIN",           0,                              },
-  { ".LEVELS",         0,                              },
-  { ".SCORES",         0,                              },
-  { ".EDITOR",         0,                              },
-  { ".INFO",           0,                              },
-  { ".SETUP",          0,                              },
-  { ".DOOR",           0,                              },
-  { ".PREVIEW",                0,                              },
+  { ".MAIN",           GAME_MODE_MAIN,                 },
+  { ".LEVELS",         GAME_MODE_LEVELS                },
+  { ".SCORES",         GAME_MODE_SCORES,               },
+  { ".EDITOR",         GAME_MODE_EDITOR,               },
+  { ".INFO",           GAME_MODE_INFO,                 },
+  { ".SETUP",          GAME_MODE_SETUP,                },
+  { ".DOOR",           GAME_MODE_PSEUDO_DOOR,          },
+  { ".PREVIEW",                GAME_MODE_PSEUDO_PREVIEW,       },
 
   { NULL,              0,                              }
 };
index 212327620687aa67be87f174fe7b1bed66d5f324..bfb6c400d831f33920545323a80ecc7c8f2f2f5a 100644 (file)
 
 #define NUM_ACTIONS                            26
 
-/* values for special image configuration suffixes */
+/* values for special image configuration suffixes (must match game mode) */
 #define GFX_SPECIAL_ARG_MAIN                   0
 #define GFX_SPECIAL_ARG_LEVELS                 1
 #define GFX_SPECIAL_ARG_SCORES                 2
 #define NUM_FONTS                              28
 #define NUM_INITIAL_FONTS                      4
 
-/* values for game_status */
-#define EXITGAME               0
-#define MAINMENU               1
-#define PLAYING                        2
-#define LEVELED                        3
-#define HELPSCREEN             4
-#define CHOOSELEVEL            5
-#define TYPENAME               6
-#define HALLOFFAME             7
-#define SETUP                  8
-#define PSEUDO_PREVIEW         9
-#define PSEUDO_DOOR            10
+/* values for game_status (must match special image configuration suffixes) */
+#define GAME_MODE_MAIN                         0
+#define GAME_MODE_LEVELS                       1
+#define GAME_MODE_SCORES                       2
+#define GAME_MODE_EDITOR                       3
+#define GAME_MODE_INFO                         4
+#define GAME_MODE_SETUP                                5
+#define GAME_MODE_PSEUDO_DOOR                  6
+#define GAME_MODE_PSEUDO_PREVIEW               7
+
+/* there are no special config file suffixes for these modes */
+#define GAME_MODE_PLAYING                      8
+#define GAME_MODE_PSEUDO_TYPENAME              9
+#define GAME_MODE_QUIT                         10
 
 #define PROGRAM_VERSION_MAJOR  2
 #define PROGRAM_VERSION_MINOR  2
index fba7b48c05431289c2cbebbfbb4453e13835ea2f..a2928592b4a23fae7d379a47dbf68cf779e41e0f 100644 (file)
@@ -455,7 +455,7 @@ static void Handle_OP_START_PLAYING()
 
   InitRND(new_random_seed);
 
-  game_status = PLAYING;
+  game_status = GAME_MODE_PLAYING;
   InitGame();
 }
 
@@ -482,7 +482,7 @@ static void Handle_OP_STOP_PLAYING()
   printf("OP_STOP_PLAYING: %d\n", buffer[0]);
   Error(ERR_NETWORK_CLIENT, "client %d stops game", buffer[0]);
 
-  game_status = MAINMENU;
+  game_status = GAME_MODE_MAIN;
   DrawMainMenu();
 }
 
index 437ab3cb63c09c90c1bde3507d888bf036d8280e..d02f2ccad59e8cdfc0155d590e6a37deb51fc930 100644 (file)
@@ -75,9 +75,9 @@ static int setup_mode = SETUP_MODE_MAIN;
 static int mSX = SX;
 static int mSY = SY;
 #else
-#define mSX (SX + (game_status == MAINMENU ? global.menu_draw_xoffset_MAIN : \
+#define mSX (SX + (game_status == GAME_MODE_MAIN ? global.menu_draw_xoffset_MAIN : \
                   global.menu_draw_xoffset))
-#define mSY (SY + (game_status == MAINMENU ? global.menu_draw_yoffset_MAIN : \
+#define mSY (SY + (game_status == GAME_MODE_MAIN ? global.menu_draw_yoffset_MAIN : \
                   global.menu_draw_yoffset))
 #endif
 
@@ -208,7 +208,7 @@ void DrawMainMenu()
   /* needed if last screen was the playing screen, invoked from level editor */
   if (level_editor_test_game)
   {
-    game_status = LEVELED;
+    game_status = GAME_MODE_EDITOR;
     DrawLevelEd();
     return;
   }
@@ -406,14 +406,14 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
     {
       if (y == 0)
       {
-       game_status = TYPENAME;
+       game_status = GAME_MODE_PSEUDO_TYPENAME;
        HandleTypeName(strlen(setup.player_name), 0);
       }
       else if (y == 1)
       {
        if (leveldir_first)
        {
-         game_status = CHOOSELEVEL;
+         game_status = GAME_MODE_LEVELS;
          SaveLevelSetup_LastSeries();
          SaveLevelSetup_SeriesInfo();
 
@@ -424,7 +424,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       }
       else if (y == 2)
       {
-       game_status = HALLOFFAME;
+       game_status = GAME_MODE_SCORES;
        DrawHallOfFame(-1);
       }
       else if (y == 3)
@@ -432,12 +432,12 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
        if (leveldir_current->readonly &&
            strcmp(setup.player_name, "Artsoft") != 0)
          Request("This level is read only !", REQ_CONFIRM);
-       game_status = LEVELED;
+       game_status = GAME_MODE_EDITOR;
        DrawLevelEd();
       }
       else if (y == 4)
       {
-       game_status = HELPSCREEN;
+       game_status = GAME_MODE_INFO;
        DrawHelpScreen();
       }
       else if (y == 5)
@@ -451,14 +451,14 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
        else
 #endif
        {
-         game_status = PLAYING;
+         game_status = GAME_MODE_PLAYING;
          StopAnimation();
          InitGame();
        }
       }
       else if (y == 6)
       {
-       game_status = SETUP;
+       game_status = GAME_MODE_SETUP;
        setup_mode = SETUP_MODE_MAIN;
        DrawSetupScreen();
       }
@@ -467,7 +467,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
        SaveLevelSetup_LastSeries();
        SaveLevelSetup_SeriesInfo();
         if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
-         game_status = EXITGAME;
+         game_status = GAME_MODE_QUIT;
       }
     }
   }
@@ -476,7 +476,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
 
   out:
 
-  if (game_status == MAINMENU)
+  if (game_status == GAME_MODE_MAIN)
   {
     DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
     DoAnimation();
@@ -1101,7 +1101,7 @@ void HandleHelpScreen(int button)
     {
       FadeSounds();
 
-      game_status = MAINMENU;
+      game_status = GAME_MODE_MAIN;
       DrawMainMenu();
     }
   }
@@ -1177,7 +1177,7 @@ void HandleTypeName(int newxpos, Key key)
     DrawText(startx + xpos * font_width, starty, " ", FONT_INPUT_1_ACTIVE);
 
     SaveSetup();
-    game_status = MAINMENU;
+    game_status = GAME_MODE_MAIN;
   }
 
   BackToFront();
@@ -1235,7 +1235,8 @@ static void drawChooseTreeList(int first_entry, int num_page_entries,
 
   DrawText(SX + offset, SY + offset, title_string, FONT_TITLE_1);
 
-  game_status = CHOOSELEVEL;   /* force LEVELS font on artwork setup screen */
+  /* force LEVELS font on artwork setup screen */
+  game_status = GAME_MODE_LEVELS;
 
   for(i=0; i<num_page_entries; i++)
   {
@@ -1352,13 +1353,13 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
       *ti_ptr = ti->node_parent;
       DrawChooseTree(ti_ptr);
     }
-    else if (game_status == SETUP)
+    else if (game_status == GAME_MODE_SETUP)
     {
       execSetupArtwork();
     }
     else
     {
-      game_status = MAINMENU;
+      game_status = GAME_MODE_MAIN;
       DrawMainMenu();
     }
 
@@ -1489,13 +1490,13 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
          TapeErase();
        }
 
-       if (game_status == SETUP)
+       if (game_status == GAME_MODE_SETUP)
        {
          execSetupArtwork();
        }
        else
        {
-         game_status = MAINMENU;
+         game_status = GAME_MODE_MAIN;
          DrawMainMenu();
        }
       }
@@ -1504,7 +1505,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
 
   BackToFront();
 
-  if (game_status == CHOOSELEVEL || game_status == SETUP)
+  if (game_status == GAME_MODE_LEVELS || game_status == GAME_MODE_SETUP)
     DoAnimation();
 }
 
@@ -1619,13 +1620,13 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
   if (button_released)
   {
     FadeSound(SND_BACKGROUND_SCORES);
-    game_status = MAINMENU;
+    game_status = GAME_MODE_MAIN;
     DrawMainMenu();
   }
 
   BackToFront();
 
-  if (game_status == HALLOFFAME)
+  if (game_status == GAME_MODE_SCORES)
   {
     DoAnimation();
 #if 1
@@ -1726,7 +1727,7 @@ static void execSetupShortcut()
 
 static void execExitSetup()
 {
-  game_status = MAINMENU;
+  game_status = GAME_MODE_MAIN;
   DrawMainMenu();
 }
 
@@ -2126,7 +2127,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
 
   BackToFront();
 
-  if (game_status == SETUP)
+  if (game_status == GAME_MODE_SETUP)
     DoAnimation();
 }
 
@@ -2372,7 +2373,7 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button)
 
   out:
 
-  if (game_status == SETUP)
+  if (game_status == GAME_MODE_SETUP)
     DoAnimation();
 }
 
@@ -2736,7 +2737,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
 
 void HandleGameActions()
 {
-  if (game_status != PLAYING)
+  if (game_status != GAME_MODE_PLAYING)
     return;
 
   if (local_player->LevelSolved)
@@ -3009,29 +3010,29 @@ static void HandleScreenGadgets(struct GadgetInfo *gi)
 {
   int id = gi->custom_id;
 
-  if (game_status != CHOOSELEVEL && game_status != SETUP)
+  if (game_status != GAME_MODE_LEVELS && game_status != GAME_MODE_SETUP)
     return;
 
   switch (id)
   {
     case SCREEN_CTRL_ID_SCROLL_UP:
-      if (game_status == CHOOSELEVEL)
+      if (game_status == GAME_MODE_LEVELS)
        HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK);
-      else if (game_status == SETUP)
+      else if (game_status == GAME_MODE_SETUP)
        HandleSetupScreen(SX,SY + 32, 0,0, MB_MENU_MARK);
       break;
 
     case SCREEN_CTRL_ID_SCROLL_DOWN:
-      if (game_status == CHOOSELEVEL)
+      if (game_status == GAME_MODE_LEVELS)
        HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
-      else if (game_status == SETUP)
+      else if (game_status == GAME_MODE_SETUP)
        HandleSetupScreen(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK);
       break;
 
     case SCREEN_CTRL_ID_SCROLL_VERTICAL:
-      if (game_status == CHOOSELEVEL)
+      if (game_status == GAME_MODE_LEVELS)
        HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
-      else if (game_status == SETUP)
+      else if (game_status == GAME_MODE_SETUP)
        HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE);
       break;
 
index 69ed9f938039936889111782f35b9a8e722d4ab8..85fd29030b61446c3af148f5fd48df9681e2313b 100644 (file)
@@ -366,7 +366,7 @@ static void TapeStartGameRecording()
   else
 #endif
   {
-    game_status = PLAYING;
+    game_status = GAME_MODE_PLAYING;
     StopAnimation();
     InitGame();
   }
@@ -511,7 +511,7 @@ static void TapeStartGamePlaying()
 {
   TapeStartPlaying();
 
-  game_status = PLAYING;
+  game_status = GAME_MODE_PLAYING;
   StopAnimation();
   InitGame();
 }
@@ -646,7 +646,7 @@ static void TapeSingleStep()
 
 void TapeQuickSave()
 {
-  if (game_status == PLAYING)
+  if (game_status == GAME_MODE_PLAYING)
   {
     if (tape.recording)
       TapeHaltRecording();     /* prepare tape for saving on-the-fly */
@@ -656,13 +656,13 @@ void TapeQuickSave()
     else
       SaveTape(tape.level_nr);
   }
-  else if (game_status == MAINMENU)
+  else if (game_status == GAME_MODE_MAIN)
     Request("No game that can be saved !", REQ_CONFIRM);
 }
 
 void TapeQuickLoad()
 {
-  if (game_status == PLAYING || game_status == MAINMENU)
+  if (game_status == GAME_MODE_PLAYING || game_status == GAME_MODE_MAIN)
   {
     TapeStop();
     TapeErase();
@@ -943,7 +943,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
 {
   int id = gi->custom_id;
 
-  if (game_status != MAINMENU && game_status != PLAYING)
+  if (game_status != GAME_MODE_MAIN && game_status != GAME_MODE_PLAYING)
     return;
 
   switch (id)
index 0c7bf17b1d6e647eec594cc2e5b723f828dd0ab7..89de2f61e3647b96decb48cfcbd8ee8de248de71 100644 (file)
@@ -70,7 +70,7 @@ void SetDrawtoField(int mode)
 
 void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height)
 {
-  if (game_status == PLAYING)
+  if (game_status == GAME_MODE_PLAYING)
   {
     if (force_redraw)
     {
@@ -118,7 +118,7 @@ void BackToFront()
   int x,y;
   DrawBuffer *buffer = (drawto_field == window ? backbuffer : drawto_field);
 
-  if (setup.direct_draw && game_status == PLAYING)
+  if (setup.direct_draw && game_status == GAME_MODE_PLAYING)
     redraw_mask &= ~REDRAW_MAIN;
 
   if (redraw_mask & REDRAW_TILES && redraw_tiles > REDRAWTILES_THRESHOLD)
@@ -130,7 +130,7 @@ void BackToFront()
   if (redraw_mask == REDRAW_NONE)
     return;
 
-  if (global.fps_slowdown && game_status == PLAYING)
+  if (global.fps_slowdown && game_status == GAME_MODE_PLAYING)
   {
     static boolean last_frame_skipped = FALSE;
     boolean skip_even_when_not_scrolling = TRUE;
@@ -175,7 +175,8 @@ void BackToFront()
 
   if (redraw_mask & REDRAW_FIELD)
   {
-    if (game_status != PLAYING || redraw_mask & REDRAW_FROM_BACKBUFFER)
+    if (game_status != GAME_MODE_PLAYING ||
+       redraw_mask & REDRAW_FROM_BACKBUFFER)
     {
       BlitBitmap(backbuffer, window,
                 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, REAL_SX, REAL_SY);
@@ -388,7 +389,7 @@ void ClearWindow()
 {
   DrawBackground(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
 
-  if (setup.soft_scrolling && game_status == PLAYING)
+  if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING)
   {
     ClearRectangle(fieldbuffer, 0, 0, FXSIZE, FYSIZE);
     SetDrawtoField(DRAW_BUFFERED);
@@ -396,7 +397,7 @@ void ClearWindow()
   else
     SetDrawtoField(DRAW_BACKBUFFER);
 
-  if (setup.direct_draw && game_status == PLAYING)
+  if (setup.direct_draw && game_status == GAME_MODE_PLAYING)
   {
     ClearRectangle(window, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
     SetDrawtoField(DRAW_DIRECT);
@@ -1588,7 +1589,8 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart)
   static int label_state, label_counter;
   int last_game_status = game_status;  /* save current game status */
 
-  game_status = PSEUDO_PREVIEW;        /* force PREVIEW font on preview level */
+  /* force PREVIEW font on preview level */
+  game_status = GAME_MODE_PSEUDO_PREVIEW;
 
   if (restart)
   {
@@ -1711,7 +1713,7 @@ boolean Request(char *text, unsigned int req_state)
 #if defined(PLATFORM_UNIX)
   /* pause network game while waiting for request to answer */
   if (options.network &&
-      game_status == PLAYING &&
+      game_status == GAME_MODE_PLAYING &&
       req_state & REQUEST_WAIT_FOR)
     SendToServer_PausePlaying();
 #endif
@@ -1732,7 +1734,8 @@ boolean Request(char *text, unsigned int req_state)
   /* clear door drawing field */
   DrawBackground(DX, DY, DXSIZE, DYSIZE);
 
-  game_status = PSEUDO_DOOR;   /* force DOOR font on preview level */
+  /* force DOOR font on preview level */
+  game_status = GAME_MODE_PSEUDO_DOOR;
 
   /* write text for request */
   for(ty=0; ty < MAX_REQUEST_LINES; ty++)
@@ -1804,7 +1807,7 @@ boolean Request(char *text, unsigned int req_state)
     return FALSE;
   }
 
-  if (game_status != MAINMENU)
+  if (game_status != GAME_MODE_MAIN)
     InitAnimation();
 
   button_status = MB_RELEASED;
@@ -1928,7 +1931,7 @@ boolean Request(char *text, unsigned int req_state)
     Delay(10);
   }
 
-  if (game_status != MAINMENU)
+  if (game_status != GAME_MODE_MAIN)
     StopAnimation();
 
   UnmapToolButtons();
@@ -1953,7 +1956,7 @@ boolean Request(char *text, unsigned int req_state)
 #if defined(PLATFORM_UNIX)
   /* continue network game after request */
   if (options.network &&
-      game_status == PLAYING &&
+      game_status == GAME_MODE_PLAYING &&
       req_state & REQUEST_WAIT_FOR)
     SendToServer_ContinuePlaying();
 #endif
@@ -2146,7 +2149,7 @@ unsigned int MoveDoor(unsigned int door_state)
 
       BackToFront();
 
-      if (game_status == MAINMENU)
+      if (game_status == GAME_MODE_MAIN)
        DoAnimation();
     }
   }