rnd-20020519-2-src
[rocksndiamonds.git] / src / main.h
index 803f0a0e53db82d8dc8375f61f374595acb469d3..06939a398df30bc899564779bf0aef5134cc2427 100644 (file)
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #define WIN_XSIZE      672
 #define WIN_YSIZE      560
 
-#if !defined(PLATFORM_MSDOS)
-#define WIN_XPOS       0
-#define WIN_YPOS       0
-#else
-#define WIN_XPOS       ((XRES - WIN_XSIZE) / 2)
-#define WIN_YPOS       ((YRES - WIN_YSIZE) / 2)
-#endif
-
 #define SCR_FIELDX     17
 #define SCR_FIELDY     17
 #define MAX_BUF_XSIZE  (SCR_FIELDX + 2)
@@ -48,8 +41,6 @@
 #define MAX_LEV_FIELDX 128
 #define MAX_LEV_FIELDY 128
 
-#define MAX_PLAYERS    4
-
 #define SCREENX(a)     ((a) - scroll_x)
 #define SCREENY(a)     ((a) - scroll_y)
 #define LEVELX(a)      ((a) + scroll_x)
@@ -96,7 +87,7 @@
 #define EP_BIT_BELT            (1 << 0)
 #define EP_BIT_BELT_SWITCH     (1 << 1)
 #define EP_BIT_TUBE            (1 << 2)
-#define EP_BIT_SLIPPERY_GEMS   (1 << 3)
+#define EP_BIT_EM_SLIPPERY_WALL        (1 << 3)
 
 #define IS_AMOEBALIVE(e)       (Elementeigenschaften1[e] & EP_BIT_AMOEBALIVE)
 #define IS_AMOEBOID(e)         (Elementeigenschaften1[e] & EP_BIT_AMOEBOID)
 #define IS_BELT(e)             (Elementeigenschaften2[e] & EP_BIT_BELT)
 #define IS_BELT_SWITCH(e)      (Elementeigenschaften2[e] & EP_BIT_BELT_SWITCH)
 #define IS_TUBE(e)             (Elementeigenschaften2[e] & EP_BIT_TUBE)
-#define IS_SLIPPERY_GEMS(e)    (Elementeigenschaften2[e] & EP_BIT_SLIPPERY_GEMS)
+#define IS_EM_SLIPPERY_WALL(e) (Elementeigenschaften2[e] & EP_BIT_EM_SLIPPERY_WALL)
 
 #define IS_PLAYER(x,y)         (ELEM_IS_PLAYER(StorePlayer[x][y]))
 
 #define IS_DRAWABLE(e)         ((e) < EL_BLOCKED)
 #define IS_NOT_DRAWABLE(e)     ((e) >= EL_BLOCKED)
 #define TAPE_IS_EMPTY(x)       ((x).length == 0)
-#define TAPE_IS_STOPPED(x)     (!(x).recording && !(x).playing &&!(x).pausing)
+#define TAPE_IS_STOPPED(x)     (!(x).recording && !(x).playing)
 
 #define PLAYERINFO(x,y)                (&stored_player[StorePlayer[x][y]-EL_SPIELER1])
 #define SHIELD_ON(p)           ((p)->shield_passive_time_left > 0)
 #define NUM_BITMAPS            12
 
 /* boundaries of arrays etc. */
-#define MAX_PLAYER_NAME_LEN    10
 #define MAX_LEVEL_NAME_LEN     32
 #define MAX_LEVEL_AUTHOR_LEN   32
 #define MAX_TAPELEN            (1000 * 50)     /* max. time * framerate */
@@ -212,63 +202,6 @@ struct HiScore
   int Score;
 };
 
-struct SetupJoystickInfo
-{
-  char *device_name;
-  int xleft, xmiddle, xright;
-  int yupper, ymiddle, ylower;
-  int snap;
-  int bomb;
-};
-
-struct SetupKeyboardInfo
-{
-  Key left;
-  Key right;
-  Key up;
-  Key down;
-  Key snap;
-  Key bomb;
-};
-
-struct SetupInputInfo
-{
-  boolean use_joystick;
-  struct SetupJoystickInfo joy;
-  struct SetupKeyboardInfo key;
-};
-
-struct SetupInfo
-{
-  char *player_name;
-
-  boolean sound;
-  boolean sound_loops;
-  boolean sound_music;
-  boolean sound_simple;
-  boolean toons;
-  boolean double_buffering;
-  boolean direct_draw;         /* !double_buffering (redundant!) */
-  boolean scroll_delay;
-  boolean soft_scrolling;
-  boolean fading;
-  boolean autorecord;
-  boolean quick_doors;
-  boolean team_mode;
-  boolean handicap;
-  boolean time_limit;
-  boolean fullscreen;
-
-  struct SetupInputInfo input[MAX_PLAYERS];
-};
-
-struct SetupFileList
-{
-  char *token;
-  char *value;
-  struct SetupFileList *next;
-};
-
 struct PlayerInfo
 {
   boolean present;             /* player present in level playfield */
@@ -278,14 +211,12 @@ struct PlayerInfo
   int index_nr, client_nr, element_nr;
 
   byte action;                 /* action from local input device */
-  byte effective_action;       /* action aknowledged from network server
+  byte effective_action;       /* action acknowledged from network server
                                   or summarized over all configured input
                                   devices when in single player mode */
   byte programmed_action;      /* action forced by game itself (like moving
                                   through doors); overrides other actions */
 
-  int joystick_fd;             /* file descriptor of player's joystick */
-
   int jx,jy, last_jx,last_jy;
   int MovDir, MovPos, GfxPos;
   int Frame;
@@ -295,12 +226,12 @@ struct PlayerInfo
   boolean LevelSolved, GameOver;
   boolean snapped;
 
-  unsigned long move_delay;
-  int move_delay_value;
-
   int last_move_dir;
   int is_moving;
 
+  unsigned long move_delay;
+  int move_delay_value;
+
   unsigned long push_delay;
   unsigned long push_delay_value;
 
@@ -322,9 +253,9 @@ struct PlayerInfo
 
 struct LevelInfo
 {
-  int file_version;            /* version of file the level was stored with */
-  int game_version;            /* version of game engine to play this level */
-  boolean encoding_16bit_field;                /* level contains 16-bit elements */
+  int file_version;    /* file format version the level is stored with    */
+  int game_version;    /* game engine version the level was created with  */
+  boolean encoding_16bit_field;                /* level contains 16-bit elements  */
   boolean encoding_16bit_yamyam;       /* yamyam contains 16-bit elements */
   boolean encoding_16bit_amoeba;       /* amoeba contains 16-bit elements */
 
@@ -345,12 +276,13 @@ struct LevelInfo
   int time_timegate;
   boolean double_speed;
   boolean gravity;
+  boolean em_slippery_gems;    /* EM style "gems slip from wall" behaviour */
 };
 
 struct TapeInfo
 {
-  int file_version;    /* version of file this level tape was stored with */
-  int game_version;    /* version of game engine to play this tapeĀ“s level */
+  int file_version;    /* file format version the tape is stored with   */
+  int game_version;    /* game engine version the tape was created with */
   int version;
   int level_nr;
   unsigned long random_seed;
@@ -362,8 +294,13 @@ struct TapeInfo
   boolean pause_before_death;
   boolean recording, playing, pausing;
   boolean fast_forward;
+  boolean index_search;
+  boolean quick_resume;
+  boolean single_step;
   boolean changed;
   boolean player_participates[MAX_PLAYERS];
+  int num_participating_players;
+
   struct
   {
     byte action[MAX_PLAYERS];
@@ -400,15 +337,11 @@ extern Pixmap             tile_clipmask[];
 extern DrawBuffer      *fieldbuffer;
 extern DrawBuffer      *drawto_field;
 
-extern int             joystick_device;
-extern char           *joystick_device_name[];
-
 extern int             game_status;
 extern boolean         level_editor_test_game;
 extern boolean         network_playing;
 
 extern int             key_joystick_mapping;
-extern int             global_joystick_status, joystick_status;
 
 extern boolean         redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
 extern int             redraw_x1, redraw_y1;
@@ -430,7 +363,6 @@ extern short                ExplodeField[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 extern unsigned long   Elementeigenschaften1[MAX_ELEMENTS];
 extern unsigned long   Elementeigenschaften2[MAX_ELEMENTS];
 
-extern int             level_nr;
 extern int             lev_fieldx,lev_fieldy, scroll_x,scroll_y;
 
 extern int             FX,FY, ScrollStepSize;
@@ -454,14 +386,12 @@ extern struct LevelInfo           level;
 extern struct PlayerInfo       stored_player[], *local_player;
 extern struct HiScore          highscore[];
 extern struct TapeInfo         tape;
-extern struct JoystickInfo     joystick[];
-extern struct SetupInfo                setup;
 extern struct GameInfo         game;
 extern struct GlobalInfo       global;
 
+extern struct SoundEffectInfo  sound_effects[];
+
 extern char            *sound_name[];
-extern int             background_loop[];
-extern int             num_bg_loops;
 extern char            *element_info[];
 extern int             num_element_info;
 
@@ -1502,22 +1432,160 @@ extern int             num_element_info;
 
 #define NUM_SOUNDS             55
 
-/* default input keys */
-#define DEFAULT_KEY_LEFT       KSYM_Left
-#define DEFAULT_KEY_RIGHT      KSYM_Right
-#define DEFAULT_KEY_UP         KSYM_Up
-#define DEFAULT_KEY_DOWN       KSYM_Down
-#define DEFAULT_KEY_SNAP       KSYM_Shift_L
-#define DEFAULT_KEY_BOMB       KSYM_Shift_R
-#define DEFAULT_KEY_OKAY       KSYM_Return
-#define DEFAULT_KEY_CANCEL     KSYM_Escape
-
-/* directions for moving */
-#define MV_NO_MOVING           0
-#define MV_LEFT                        (1 << 0)
-#define MV_RIGHT               (1 << 1)
-#define MV_UP                  (1 << 2)
-#define MV_DOWN                        (1 << 3)
+
+/* values for sound effects */
+#define SND_BD_EMPTY_SPACE_DIGGING             0
+#define SND_BD_SAND_DIGGING                    1
+#define SND_BD_DIAMOND_COLLECTING              2
+#define SND_BD_DIAMOND_IMPACT                  3
+#define SND_BD_ROCK_PUSHING                    4
+#define SND_BD_ROCK_IMPACT                     5
+#define SND_BD_MAGIC_WALL_ACTIVATING           6
+#define SND_BD_MAGIC_WALL_CHANGING             7
+#define SND_BD_MAGIC_WALL_RUNNING              8
+#define SND_BD_AMOEBA_GROWING                  9
+#define SND_BD_AMOEBA_TURNING_TO_GEM           10
+#define SND_BD_AMOEBA_TURNING_TO_ROCK          11
+#define SND_BD_BUTTERFLY_MOVING                        12
+#define SND_BD_FIREFLY_MOVING                  13
+#define SND_BD_EXIT_ENTERING                   14
+#define SND_SP_EMPTY_SPACE_DIGGING             15
+#define SND_SP_BASE_DIGGING                    16
+#define SND_SP_BUGGY_BASE_DIGGING              17
+#define SND_SP_BUGGY_BASE_ACTIVATING           18
+#define SND_SP_INFOTRON_COLLECTING             19
+#define SND_SP_INFOTRON_IMPACT                 20
+#define SND_SP_ZONK_PUSHING                    21
+#define SND_SP_ZONK_IMPACT                     22
+#define SND_SP_DISK_RED_COLLECTING             23
+#define SND_SP_DISK_ORANGE_PUSHING             24
+#define SND_SP_DISK_YELLOW_PUSHING             25
+#define SND_SP_PORT_PASSING                    26
+#define SND_SP_EXIT_ENTERING                   27
+#define SND_SP_ELEMENT_EXPLODING               28
+#define SND_SP_SNIKSNAK_MOVING                 29
+#define SND_SP_ELECTRON_MOVING                 30
+#define SND_SP_TERMINAL_ACTIVATING             31
+#define SND_SOKOBAN_OBJECT_PUSHING             32
+#define SND_SOKOBAN_FIELD_FILLING              33
+#define SND_SOKOBAN_FIELD_CLEARING             34
+#define SND_SOKOBAN_GAME_SOLVING               35
+#define SND_EMPTY_SPACE_DIGGING                        36
+#define SND_SAND_DIGGING                       37
+#define SND_EMERALD_COLLECTING                 38
+#define SND_EMERALD_IMPACT                     39
+#define SND_DIAMOND_COLLECTING                 40
+#define SND_DIAMOND_IMPACT                     41
+#define SND_DIAMOND_BREAKING                   42
+#define SND_ROCK_PUSHING                       43
+#define SND_ROCK_IMPACT                                44
+#define SND_BOMB_PUSHING                       45
+#define SND_NUT_PUSHING                                46
+#define SND_NUT_CRACKING                       47
+#define SND_NUT_IMPACT                         48
+#define SND_DYNAMITE_COLLECTING                        49
+#define SND_DYNAMITE_PLACING                   50
+#define SND_DYNAMITE_BURNING                   51
+#define SND_KEY_COLLECTING                     52
+#define SND_GATE_PASSING                       53
+#define SND_BUG_MOVING                         54
+#define SND_SPACESHIP_MOVING                   55
+#define SND_YAMYAM_MOVING                      56
+#define SND_YAMYAM_WAITING                     57
+#define SND_YAMYAM_EATING_DIAMOND              58
+#define SND_ROBOT_MOVING                       59
+#define SND_ROBOT_WHEEL_ACTIVATING             60
+#define SND_ROBOT_WHEEL_RUNNING                        61
+#define SND_MAGIC_WALL_ACTIVATING              62
+#define SND_MAGIC_WALL_CHANGING                        63
+#define SND_MAGIC_WALL_RUNNING                 64
+#define SND_AMOEBA_GROWING                     65
+#define SND_AMOEBA_DROPPING                    66
+#define SND_ACID_SPLASHING                     67
+#define SND_QUICKSAND_FILLING                  68
+#define SND_QUICKSAND_SLIPPING_THROUGH         69
+#define SND_QUICKSAND_EMPTYING                 70
+#define SND_EXIT_OPENING                       71
+#define SND_EXIT_ENTERING                      72
+#define SND_BALLOON_MOVING                     73
+#define SND_BALLOON_PUSHING                    74
+#define SND_SPRING_MOVING                      75
+#define SND_SPRING_PUSHING                     76
+#define SND_SPRING_IMPACT                      77
+#define SND_WALL_GROWING                       78
+#define SND_PEARL_COLLECTING                   79
+#define SND_PEARL_BREAKING                     80
+#define SND_PEARL_IMPACT                       81
+#define SND_CRYSTAL_COLLECTING                 82
+#define SND_CRYSTAL_IMPACT                     83
+#define SND_ENVELOPE_COLLECTING                        84
+#define SND_SAND_INVISIBLE_DIGGING             85
+#define SND_SHIELD_PASSIVE_COLLECTING          86
+#define SND_SHIELD_PASSIVE_ACTIVATED           87
+#define SND_SHIELD_ACTIVE_COLLECTING           88
+#define SND_SHIELD_ACTIVE_ACTIVATED            89
+#define SND_EXTRA_TIME_COLLECTING              90
+#define SND_MOLE_MOVING                                91
+#define SND_MOLE_EATING_AMOEBA                 92
+#define SND_SWITCHGATE_SWITCH_ACTIVATING       93
+#define SND_SWITCHGATE_OPENING                 94
+#define SND_SWITCHGATE_CLOSING                 95
+#define SND_SWITCHGATE_PASSING                 96
+#define SND_TIMEGATE_WHEEL_ACTIVATING          97
+#define SND_TIMEGATE_WHEEL_RUNNING             98
+#define SND_TIMEGATE_OPENING                   99
+#define SND_TIMEGATE_CLOSING                   100
+#define SND_TIMEGATE_PASSING                   101
+#define SND_CONVEYOR_BELT_SWITCH_ACTIVATING    102
+#define SND_CONVEYOR_BELT_RUNNING              103
+#define SND_LIGHT_SWITCH_ACTIVATING            104
+#define SND_LIGHT_SWITCH_DEACTIVATING          105
+#define SND_DX_BOMB_PUSHING                    106
+#define SND_TRAP_INACTIVE_DIGGING              107
+#define SND_TRAP_ACTIVATING                    108
+#define SND_AMOEBA_TURNING_TO_GEM              109
+#define SND_AMOEBA_TURNING_TO_ROCK             110
+#define SND_SPEED_PILL_COLLECTING              111
+#define SND_DYNABOMB_NR_COLLECTING             112
+#define SND_DYNABOMB_SZ_COLLECTING             113
+#define SND_DYNABOMB_XL_COLLECTING             114
+#define SND_DYNABOMB_PLACING                   115
+#define SND_DYNABOMB_BURNING                   116
+#define SND_SATELLITE_MOVING                   117
+#define SND_SATELLITE_PUSHING                  118
+#define SND_LAMP_ACTIVATING                    119
+#define SND_LAMP_DEACTIVATING                  120
+#define SND_TIME_ORB_FULL_COLLECTING           121
+#define SND_TIME_ORB_FULL_IMPACT               122
+#define SND_TIME_ORB_EMPTY_PUSHING             123
+#define SND_TIME_ORB_EMPTY_IMPACT              124
+#define SND_GAMEOFLIFE_GROWING                 125
+#define SND_BIOMAZE_GROWING                    126
+#define SND_PACMAN_MOVING                      127
+#define SND_PACMAN_EATING_AMOEBA               128
+#define SND_DARK_YAMYAM_MOVING                 129
+#define SND_DARK_YAMYAM_WAITING                        130
+#define SND_DARK_YAMYAM_EATING_ANY             131
+#define SND_PENGUIN_MOVING                     132
+#define SND_PENGUIN_ENTERING_EXIT              133
+#define SND_PIG_MOVING                         134
+#define SND_PIG_EATING_GEM                     135
+#define SND_DRAGON_MOVING                      136
+#define SND_DRAGON_BREATHING_FIRE              137
+#define SND_PLAYER_DYING                       138
+#define SND_ELEMENT_EXPLODING                  139
+#define SND_GAME_STARTING                      140
+#define SND_GAME_RUNNING_OUT_OF_TIME           141
+#define SND_GAME_LEVELTIME_BONUS               142
+#define SND_GAME_LOSING                                143
+#define SND_GAME_WINNING                       144
+#define SND_MENU_DOOR_OPENING                  145
+#define SND_MENU_DOOR_CLOSING                  146
+#define SND_MENU_HALL_OF_FAME                  147
+#define SND_MENU_INFO_SCREEN                   148
+
+#define NUM_SOUND_EFFECTS                      149
+
 
 /* values for game_status */
 #define EXITGAME               0
@@ -1529,19 +1597,23 @@ extern int              num_element_info;
 #define TYPENAME               6
 #define HALLOFFAME             7
 #define SETUP                  8
-#define SETUPINPUT             9
-#define CALIBRATION            10
 
-#define PROGRAM_VERSION_STRING "2.0.1"
+#define PROGRAM_VERSION_MAJOR  2
+#define PROGRAM_VERSION_MINOR  0
+#define PROGRAM_VERSION_PATCH  2
+#define PROGRAM_VERSION_STRING "2.0.2"
+
 #define PROGRAM_TITLE_STRING   "Rocks'n'Diamonds"
 #define PROGRAM_AUTHOR_STRING  "Holger Schemel"
-#define PROGRAM_RIGHTS_STRING  "Copyright ^1995-2001 by"
+#define PROGRAM_RIGHTS_STRING  "Copyright ^1995-2002 by"
 #define PROGRAM_DOS_PORT_STRING        "DOS port done by Guido Schulz"
 #define PROGRAM_IDENT_STRING   PROGRAM_VERSION_STRING " " TARGET_STRING
 #define WINDOW_TITLE_STRING    PROGRAM_TITLE_STRING " " PROGRAM_IDENT_STRING
 #define WINDOW_SUBTITLE_STRING PROGRAM_RIGHTS_STRING " " PROGRAM_AUTHOR_STRING
 #define ICON_TITLE_STRING      PROGRAM_TITLE_STRING
 #define UNIX_USERDATA_DIRECTORY        ".rocksndiamonds"
+#define COOKIE_PREFIX          "ROCKSNDIAMONDS"
+#define FILENAME_PREFIX                "Rocks"
 
 #define X11_ICON_FILENAME      "rocks_icon.xbm"
 #define X11_ICONMASK_FILENAME  "rocks_iconmask.xbm"
@@ -1554,16 +1626,24 @@ extern int              num_element_info;
 **     1.4 (still in use)
 **     2.0 (actual)
 */
-#define FILE_VERSION_1_0       10
-#define FILE_VERSION_1_2       12
-#define FILE_VERSION_1_4       14
-#define FILE_VERSION_2_0       20
+#define FILE_VERSION_1_0       VERSION_IDENT(1,0,0)
+#define FILE_VERSION_1_2       VERSION_IDENT(1,2,0)
+#define FILE_VERSION_1_4       VERSION_IDENT(1,4,0)
+#define FILE_VERSION_2_0       VERSION_IDENT(2,0,0)
+
+/* file version does not change for every program version, but is changed
+   when new features are introduced that are incompatible with older file
+   versions, so that they can be treated accordingly */
 #define FILE_VERSION_ACTUAL    FILE_VERSION_2_0
+
 #define GAME_VERSION_1_0       FILE_VERSION_1_0
 #define GAME_VERSION_1_2       FILE_VERSION_1_2
 #define GAME_VERSION_1_4       FILE_VERSION_1_4
 #define GAME_VERSION_2_0       FILE_VERSION_2_0
-#define GAME_VERSION_ACTUAL    GAME_VERSION_2_0
+
+#define GAME_VERSION_ACTUAL    VERSION_IDENT(PROGRAM_VERSION_MAJOR, \
+                                             PROGRAM_VERSION_MINOR, \
+                                             PROGRAM_VERSION_PATCH)
 
 /* for DrawGraphicAnimation() [tools.c] and AnimateToon() [cartoons.c] */
 #define ANIM_NORMAL            0