1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
29 #include "conf_e2g.c" /* include auto-generated data structure definitions */
32 static char *image_filename[NUM_PICTURES] =
40 "RocksFontMedium.pcx",
53 "RocksFontMedium.pcx",
58 static Bitmap *bitmap_font_initial = NULL;
60 static void InitGlobal(void);
61 static void InitSetup(void);
62 static void InitPlayerInfo(void);
63 static void InitLevelInfo(void);
64 static void InitArtworkInfo(void);
65 static void InitLevelArtworkInfo(void);
66 static void InitNetworkServer(void);
67 static void InitArtworkConfig(void);
68 static void InitImages(void);
69 static void InitMixer(void);
70 static void InitSound(void);
71 static void InitMusic(void);
72 static void InitGfx(void);
73 static void InitGfxBackground(void);
74 static void InitGadgets(void);
75 static void InitElementProperties(void);
76 static void InitElementInfo(void);
77 static void InitGraphicInfo(void);
78 static void InitSoundInfo();
79 static void Execute_Command(char *);
83 InitGlobal(); /* initialize some global variables */
85 if (options.execute_command)
86 Execute_Command(options.execute_command);
88 if (options.serveronly)
90 #if defined(PLATFORM_UNIX)
91 NetworkServer(options.server_port, options.serveronly);
93 Error(ERR_WARN, "networking only supported in Unix version");
95 exit(0); /* never reached */
98 InitProgramInfo(UNIX_USERDATA_DIRECTORY,
99 PROGRAM_TITLE_STRING, getWindowTitleString(),
100 ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
101 MSDOS_POINTER_FILENAME,
102 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
106 InitArtworkInfo(); /* needed before loading gfx, sound & music */
107 InitArtworkConfig(); /* needed before forking sound child process */
113 InitRND(NEW_RANDOMIZE);
116 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
119 InitEventFilter(FilterMouseMotionEvents);
121 InitElementProperties();
127 InitLevelArtworkInfo();
129 InitImages(); /* needs to know current level directory */
130 InitSound(); /* needs to know current level directory */
131 InitMusic(); /* needs to know current level directory */
135 if (global.autoplay_leveldir)
146 static void InitGlobal()
148 global.autoplay_leveldir = NULL;
150 global.frames_per_second = 0;
151 global.fps_slowdown = FALSE;
152 global.fps_slowdown_factor = 1;
155 static void InitSetup()
157 LoadSetup(); /* global setup info */
160 static void InitPlayerInfo()
164 /* choose default local player */
165 local_player = &stored_player[0];
167 for (i=0; i<MAX_PLAYERS; i++)
168 stored_player[i].connected = FALSE;
170 local_player->connected = TRUE;
173 static void InitLevelInfo()
175 LoadLevelInfo(); /* global level info */
176 LoadLevelSetup_LastSeries(); /* last played series info */
177 LoadLevelSetup_SeriesInfo(); /* last played level info */
180 static void InitArtworkInfo()
185 static void InitArtworkConfig()
187 InitImageList(image_config, image_config_suffix, NUM_IMAGE_FILES);
188 InitSoundList(sound_config, sound_config_suffix, NUM_SOUND_FILES);
191 void InitLevelArtworkInfo()
193 LoadLevelArtworkInfo();
196 void InitNetworkServer()
198 #if defined(PLATFORM_UNIX)
202 if (!options.network)
205 #if defined(PLATFORM_UNIX)
206 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
208 if (!ConnectToServer(options.server_host, options.server_port))
209 Error(ERR_EXIT, "cannot connect to network game server");
211 SendToServer_PlayerName(setup.player_name);
212 SendToServer_ProtocolVersion();
215 SendToServer_NrWanted(nr_wanted);
219 static void InitMixer()
225 static void ReinitializeGraphics()
227 InitGraphicInfo(); /* initialize graphic info from config file */
229 InitFontInfo(bitmap_font_initial,
230 graphic_info[IMG_FONT_BIG].bitmap,
231 graphic_info[IMG_FONT_MEDIUM].bitmap,
232 graphic_info[IMG_FONT_SMALL].bitmap,
233 graphic_info[IMG_FONT_EM].bitmap);
235 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
236 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
242 static void ReinitializeSounds()
244 InitSoundInfo(); /* initialize sounds info from config file */
247 static void ReinitializeMusic()
249 /* currently nothing to do */
252 static void InitImages()
254 ReloadCustomImages();
255 ReinitializeGraphics();
258 static void InitSound()
260 InitReloadCustomSounds(artwork.snd_current->identifier);
261 ReinitializeSounds();
264 static void InitMusic()
266 InitReloadCustomMusic(artwork.mus_current->identifier);
270 static void InitTileClipmasks()
273 #if defined(TARGET_X11)
274 XGCValues clip_gc_values;
275 unsigned long clip_gc_valuemask;
277 #if defined(TARGET_X11_NATIVE)
287 tile_needs_clipping[] =
289 { GFX_SPIELER1_UP, 4 },
290 { GFX_SPIELER1_DOWN, 4 },
291 { GFX_SPIELER1_LEFT, 4 },
292 { GFX_SPIELER1_RIGHT, 4 },
293 { GFX_SPIELER1_PUSH_LEFT, 4 },
294 { GFX_SPIELER1_PUSH_RIGHT, 4 },
295 { GFX_SPIELER2_UP, 4 },
296 { GFX_SPIELER2_DOWN, 4 },
297 { GFX_SPIELER2_LEFT, 4 },
298 { GFX_SPIELER2_RIGHT, 4 },
299 { GFX_SPIELER2_PUSH_LEFT, 4 },
300 { GFX_SPIELER2_PUSH_RIGHT, 4 },
301 { GFX_SPIELER3_UP, 4 },
302 { GFX_SPIELER3_DOWN, 4 },
303 { GFX_SPIELER3_LEFT, 4 },
304 { GFX_SPIELER3_RIGHT, 4 },
305 { GFX_SPIELER3_PUSH_LEFT, 4 },
306 { GFX_SPIELER3_PUSH_RIGHT, 4 },
307 { GFX_SPIELER4_UP, 4 },
308 { GFX_SPIELER4_DOWN, 4 },
309 { GFX_SPIELER4_LEFT, 4 },
310 { GFX_SPIELER4_RIGHT, 4 },
311 { GFX_SPIELER4_PUSH_LEFT, 4 },
312 { GFX_SPIELER4_PUSH_RIGHT, 4 },
313 { GFX_SP_MURPHY, 1 },
314 { GFX_MURPHY_GO_LEFT, 3 },
315 { GFX_MURPHY_GO_RIGHT, 3 },
316 { GFX_MURPHY_SNAP_UP, 1 },
317 { GFX_MURPHY_SNAP_DOWN, 1 },
318 { GFX_MURPHY_SNAP_RIGHT, 1 },
319 { GFX_MURPHY_SNAP_LEFT, 1 },
320 { GFX_MURPHY_PUSH_RIGHT, 1 },
321 { GFX_MURPHY_PUSH_LEFT, 1 },
322 { GFX_GEBLUBBER, 4 },
325 { GFX_EXPLOSION, 8 },
326 { GFX_SOKOBAN_OBJEKT, 1 },
327 { GFX_FUNKELN_BLAU, 3 },
328 { GFX_FUNKELN_WEISS, 3 },
329 { GFX2_SHIELD_PASSIVE, 3 },
330 { GFX2_SHIELD_ACTIVE, 3 },
335 #endif /* TARGET_X11_NATIVE */
336 #endif /* TARGET_X11 */
340 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
341 for (i=0; i<NUM_TILES; i++)
342 tile_clipmask[i] = None;
344 #if defined(TARGET_X11)
345 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
346 often very slow when preparing a masked XCopyArea() for big Pixmaps.
347 To prevent this, create small (tile-sized) mask Pixmaps which will then
348 be set much faster with XSetClipOrigin() and speed things up a lot. */
350 clip_gc_values.graphics_exposures = False;
351 clip_gc_valuemask = GCGraphicsExposures;
352 tile_clip_gc = XCreateGC(display, window->drawable,
353 clip_gc_valuemask, &clip_gc_values);
356 for (i=0; i<NUM_BITMAPS; i++)
358 if (pix[i]->clip_mask)
360 clip_gc_values.graphics_exposures = False;
361 clip_gc_values.clip_mask = pix[i]->clip_mask;
362 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
363 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
364 clip_gc_valuemask, &clip_gc_values);
369 #if defined(TARGET_X11_NATIVE)
372 /* create graphic context structures needed for clipping */
373 clip_gc_values.graphics_exposures = False;
374 clip_gc_valuemask = GCGraphicsExposures;
375 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
376 clip_gc_valuemask, &clip_gc_values);
378 /* create only those clipping Pixmaps we really need */
379 for (i=0; tile_needs_clipping[i].start>=0; i++)
383 for (j=0; j<tile_needs_clipping[i].count; j++)
385 int tile = tile_needs_clipping[i].start + j;
391 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
392 src_pixmap = src_bitmap->clip_mask;
394 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
397 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
398 src_x, src_y, TILEX, TILEY, 0, 0);
402 XFreeGC(display, copy_clipmask_gc);
405 #endif /* TARGET_X11_NATIVE */
406 #endif /* TARGET_X11 */
410 void FreeTileClipmasks()
413 #if defined(TARGET_X11)
416 for (i=0; i<NUM_TILES; i++)
418 if (tile_clipmask[i] != None)
420 XFreePixmap(display, tile_clipmask[i]);
421 tile_clipmask[i] = None;
426 XFreeGC(display, tile_clip_gc);
430 for (i=0; i<NUM_BITMAPS; i++)
432 if (pix[i] != NULL && pix[i]->stored_clip_gc)
434 XFreeGC(display, pix[i]->stored_clip_gc);
435 pix[i]->stored_clip_gc = None;
440 #endif /* TARGET_X11 */
450 /* initialize screen properties */
451 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
452 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
453 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
454 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
455 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
457 /* create additional image buffers for double-buffering */
458 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
459 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
462 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
464 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
466 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
468 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
471 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
472 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
474 DrawInitText("Loading graphics:", 120, FC_GREEN);
477 for (i=0; i<NUM_PICTURES; i++)
480 if (i != PIX_FONT_SMALL)
483 DrawInitText(image_filename[i], 150, FC_YELLOW);
485 pix[i] = LoadCustomImage(image_filename[i]);
491 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
498 void InitGfxBackground()
503 fieldbuffer = bitmap_db_field;
504 SetDrawtoField(DRAW_BACKBUFFER);
506 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
507 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
508 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
509 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
511 for (x=0; x<MAX_BUF_XSIZE; x++)
512 for (y=0; y<MAX_BUF_YSIZE; y++)
515 redraw_mask = REDRAW_ALL;
518 void ReloadCustomArtwork()
520 static char *leveldir_current_identifier = NULL;
521 static boolean last_override_level_graphics = FALSE;
522 static boolean last_override_level_sounds = FALSE;
523 static boolean last_override_level_music = FALSE;
524 /* identifier for new artwork; default: artwork configured in setup */
525 char *gfx_new_identifier = artwork.gfx_current->identifier;
526 char *snd_new_identifier = artwork.snd_current->identifier;
527 char *mus_new_identifier = artwork.mus_current->identifier;
528 boolean redraw_screen = FALSE;
530 if (leveldir_current_identifier == NULL)
531 leveldir_current_identifier = leveldir_current->identifier;
534 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
535 leveldir_current->graphics_set);
536 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
537 leveldir_current->identifier);
541 printf("graphics --> '%s' ('%s')\n",
542 artwork.gfx_current_identifier, artwork.gfx_current->filename);
543 printf("sounds --> '%s' ('%s')\n",
544 artwork.snd_current_identifier, artwork.snd_current->filename);
545 printf("music --> '%s' ('%s')\n",
546 artwork.mus_current_identifier, artwork.mus_current->filename);
549 /* leveldir_current may be invalid (level group, parent link) */
550 if (!validLevelSeries(leveldir_current))
554 printf("--> '%s'\n", artwork.gfx_current_identifier);
557 /* when a new level series was selected, check if there was a change
558 in custom artwork stored in level series directory */
559 if (leveldir_current_identifier != leveldir_current->identifier)
561 char *identifier_old = leveldir_current_identifier;
562 char *identifier_new = leveldir_current->identifier;
564 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
565 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
566 gfx_new_identifier = identifier_new;
567 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
568 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
569 snd_new_identifier = identifier_new;
570 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
571 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
572 mus_new_identifier = identifier_new;
574 leveldir_current_identifier = leveldir_current->identifier;
577 /* custom level artwork configured in level series configuration file
578 always overrides custom level artwork stored in level series directory
579 and (level independant) custom artwork configured in setup menue */
580 if (leveldir_current->graphics_set != NULL)
581 gfx_new_identifier = leveldir_current->graphics_set;
582 if (leveldir_current->sounds_set != NULL)
583 snd_new_identifier = leveldir_current->sounds_set;
584 if (leveldir_current->music_set != NULL)
585 mus_new_identifier = leveldir_current->music_set;
587 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
588 last_override_level_graphics != setup.override_level_graphics)
591 printf("RELOADING GRAPHICS '%s' -> '%s' (-> '%s')\n",
592 artwork.gfx_current_identifier,
593 artwork.gfx_current->identifier,
597 setLevelArtworkDir(artwork.gfx_first);
599 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
601 ReloadCustomImages();
602 ReinitializeGraphics();
608 artwork.gfx_current_identifier = gfx_new_identifier;
610 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
612 last_override_level_graphics = setup.override_level_graphics;
614 redraw_screen = TRUE;
617 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
618 last_override_level_sounds != setup.override_level_sounds)
621 printf("RELOADING SOUNDS '%s' -> '%s' (-> '%s')\n",
622 artwork.snd_current_identifier,
624 artwork.snd_current->identifier);
627 /* set artwork path to send it to the sound server process */
628 setLevelArtworkDir(artwork.snd_first);
630 InitReloadCustomSounds(snd_new_identifier);
631 ReinitializeSounds();
634 artwork.snd_current_identifier = snd_new_identifier;
636 artwork.snd_current_identifier = artwork.snd_current->identifier;
639 last_override_level_sounds = setup.override_level_sounds;
641 redraw_screen = TRUE;
644 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
645 last_override_level_music != setup.override_level_music)
647 /* set artwork path to send it to the sound server process */
648 setLevelArtworkDir(artwork.mus_first);
650 InitReloadCustomMusic(mus_new_identifier);
654 artwork.mus_current_identifier = mus_new_identifier;
656 artwork.mus_current_identifier = artwork.mus_current->identifier;
658 last_override_level_music = setup.override_level_music;
660 redraw_screen = TRUE;
667 /* force redraw of (open or closed) door graphics */
668 SetDoorState(DOOR_OPEN_ALL);
669 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
673 printf("<-- '%s'\n", artwork.gfx_current_identifier);
679 FreeLevelEditorGadgets();
688 static boolean gadgets_initialized = FALSE;
690 if (gadgets_initialized)
693 CreateLevelEditorGadgets();
697 CreateScreenGadgets();
699 gadgets_initialized = TRUE;
702 void InitElementInfo()
707 /* set values to -1 to identify later as "uninitialized" values */
708 for (i=0; i<MAX_NUM_ELEMENTS; i++)
710 for (act=0; act<NUM_ACTIONS; act++)
712 element_info[i].graphic[act] = -1;
714 for (dir=0; dir<NUM_DIRECTIONS; dir++)
715 element_info[i].direction_graphic[act][dir] = -1;
719 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
720 element_info[i].graphic[ACTION_DEFAULT] =
721 IMG_CHAR_START + (i - EL_CHAR_START);
723 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
724 element_info[i].graphic[ACTION_DEFAULT] =
725 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
728 while (element_to_graphic[i].element > -1)
730 int element = element_to_graphic[i].element;
731 int direction = element_to_graphic[i].direction;
732 int action = element_to_graphic[i].action;
733 int graphic = element_to_graphic[i].graphic;
736 action = ACTION_DEFAULT;
740 direction = MV_DIR_BIT(direction);
742 element_info[element].direction_graphic[action][direction] = graphic;
745 element_info[element].graphic[action] = graphic;
750 /* now set all '-1' values to element specific default values */
751 for (i=0; i<MAX_NUM_ELEMENTS; i++)
753 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
754 int default_action_direction_graphic[NUM_DIRECTIONS];
756 if (default_action_graphic == -1)
757 default_action_graphic = IMG_CHAR_QUESTION;
759 for (dir=0; dir<NUM_DIRECTIONS; dir++)
761 default_action_direction_graphic[dir] =
762 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
764 if (default_action_direction_graphic[dir] == -1)
765 default_action_direction_graphic[dir] = default_action_graphic;
768 for (act=0; act<NUM_ACTIONS; act++)
770 for (dir=0; dir<NUM_DIRECTIONS; dir++)
772 int default_direction_graphic = element_info[i].graphic[act];
774 /* no graphic for current action -- use default direction graphic */
775 if (default_direction_graphic == -1)
776 default_direction_graphic = default_action_direction_graphic[dir];
778 if (element_info[i].direction_graphic[act][dir] == -1)
779 element_info[i].direction_graphic[act][dir] =
780 default_direction_graphic;
783 /* no graphic for this specific action -- use default action graphic */
784 if (element_info[i].graphic[act] == -1)
785 element_info[i].graphic[act] = default_action_graphic;
790 static void set_graphic_parameters(int graphic, int action, int *parameter)
792 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
793 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
794 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
796 graphic_info[graphic].bitmap = src_bitmap;
798 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
799 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
800 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
801 graphic_info[graphic].offset_y = 0;
803 /* animation frames are ordered vertically instead of horizontally */
804 if (parameter[GFX_ARG_VERTICAL])
806 graphic_info[graphic].offset_x = 0;
807 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
810 /* optionally, the x and y offset of frames can be specified directly */
811 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
812 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
813 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
814 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
816 /* automatically determine correct number of frames, if not defined */
817 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
818 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
819 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
820 graphic_info[graphic].anim_frames = num_xtiles;
821 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
822 graphic_info[graphic].anim_frames = num_ytiles;
824 graphic_info[graphic].anim_frames = 1;
826 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
827 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
828 graphic_info[graphic].anim_delay = 1;
830 /* set mode for animation frame order */
831 if (parameter[GFX_ARG_MODE_LOOP])
832 graphic_info[graphic].anim_mode = ANIM_LOOP;
833 else if (parameter[GFX_ARG_MODE_LINEAR])
834 graphic_info[graphic].anim_mode = ANIM_LINEAR;
835 else if (parameter[GFX_ARG_MODE_PINGPONG])
836 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
837 else if (parameter[GFX_ARG_MODE_PINGPONG2])
838 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
839 else if (parameter[GFX_ARG_MODE_RANDOM])
840 graphic_info[graphic].anim_mode = ANIM_RANDOM;
841 else if (graphic_info[graphic].anim_frames > 1)
842 graphic_info[graphic].anim_mode = ANIM_LOOP;
844 graphic_info[graphic].anim_mode = ANIM_NONE;
846 /* set additional flag to play animation frames in reverse order */
847 if (parameter[GFX_ARG_MODE_REVERSE])
848 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
850 /* set first frame of animation after determining animation mode */
851 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
853 /* automatically determine correct start frame, if not defined */
854 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
855 graphic_info[graphic].anim_start_frame = 0;
856 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
857 graphic_info[graphic].anim_start_frame =
858 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
860 /* animation synchronized with global frame counter, not move position */
861 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
863 /* set global_sync for all animations with undefined "animation action" */
864 if (parameter[GFX_ARG_GLOBAL_SYNC] == ARG_UNDEFINED_VALUE)
865 graphic_info[graphic].anim_global_sync =
866 (action == ACTION_DEFAULT ? TRUE : FALSE);
868 /* "linear" animations are never globally synchronized */
869 if (parameter[GFX_ARG_MODE_LINEAR])
870 graphic_info[graphic].anim_global_sync = FALSE;
873 static void InitGraphicInfo()
875 static boolean clipmasks_initialized = FALSE;
876 static int gfx_action[NUM_IMAGE_FILES];
878 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
880 XGCValues clip_gc_values;
881 unsigned long clip_gc_valuemask;
882 GC copy_clipmask_gc = None;
885 image_files = getCurrentImageList();
887 /* set temporary graphics action field to default value */
888 for (i=0; i<NUM_IMAGE_FILES; i++)
889 gfx_action[i] = ACTION_DEFAULT;
891 /* set temporary graphics action field from element_to_graphic list */
893 while (element_to_graphic[i].element > -1)
895 int action = element_to_graphic[i].action;
896 int graphic = element_to_graphic[i].graphic;
899 action = ACTION_DEFAULT;
901 gfx_action[graphic] = action;
906 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
907 if (clipmasks_initialized)
909 for (i=0; i<NUM_IMAGE_FILES; i++)
911 if (graphic_info[i].clip_mask)
912 XFreePixmap(display, graphic_info[i].clip_mask);
913 if (graphic_info[i].clip_gc)
914 XFreeGC(display, graphic_info[i].clip_gc);
916 graphic_info[i].clip_mask = None;
917 graphic_info[i].clip_gc = None;
922 for (i=0; i<NUM_IMAGE_FILES; i++)
926 int first_frame, last_frame;
928 set_graphic_parameters(i, gfx_action[i], image_files[i].parameter);
930 /* now check if no animation frames are outside of the loaded image */
932 if (graphic_info[i].bitmap == NULL)
933 continue; /* skip check for optional images that are undefined */
936 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
937 if (src_x < 0 || src_y < 0 ||
938 src_x + TILEX > src_bitmap->width ||
939 src_y + TILEY > src_bitmap->height)
941 Error(ERR_RETURN_LINE, "-");
942 Error(ERR_RETURN, "warning: error found in config file:");
943 Error(ERR_RETURN, "- config file: '%s'",
944 getImageConfigFilename());
945 Error(ERR_RETURN, "- config token: '%s'",
946 getTokenFromImageID(i));
947 Error(ERR_RETURN, "- image file: '%s'",
948 src_bitmap->source_filename);
950 "error: first animation frame out of bounds (%d, %d)",
952 Error(ERR_RETURN, "custom graphic rejected for this element/action");
953 Error(ERR_RETURN_LINE, "-");
955 set_graphic_parameters(i, gfx_action[i],
956 image_files[i].default_parameter);
959 last_frame = graphic_info[i].anim_frames - 1;
960 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
961 if (src_x < 0 || src_y < 0 ||
962 src_x + TILEX > src_bitmap->width ||
963 src_y + TILEY > src_bitmap->height)
965 Error(ERR_RETURN_LINE, "-");
966 Error(ERR_RETURN, "warning: error found in config file:");
967 Error(ERR_RETURN, "- config file: '%s'",
968 getImageConfigFilename());
969 Error(ERR_RETURN, "- config token: '%s'",
970 getTokenFromImageID(i));
971 Error(ERR_RETURN, "- image file: '%s'",
972 src_bitmap->source_filename);
974 "error: last animation frame (%d) out of bounds (%d, %d)",
975 last_frame, src_x, src_y);
976 Error(ERR_RETURN, "custom graphic rejected for this element/action");
977 Error(ERR_RETURN_LINE, "-");
979 set_graphic_parameters(i, gfx_action[i],
980 image_files[i].default_parameter);
983 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
984 /* currently we need only a tile clip mask from the first frame */
985 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
987 if (copy_clipmask_gc == None)
989 clip_gc_values.graphics_exposures = False;
990 clip_gc_valuemask = GCGraphicsExposures;
991 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
992 clip_gc_valuemask, &clip_gc_values);
995 graphic_info[i].clip_mask =
996 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
998 src_pixmap = src_bitmap->clip_mask;
999 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
1000 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
1002 clip_gc_values.graphics_exposures = False;
1003 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
1004 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
1005 graphic_info[i].clip_gc =
1006 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1010 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1011 if (copy_clipmask_gc)
1012 XFreeGC(display, copy_clipmask_gc);
1015 clipmasks_initialized = TRUE;
1018 static void set_sound_parameters(int sound, int *parameter)
1020 /* explicit loop mode setting in configuration overrides default value */
1021 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1022 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1025 static void InitSoundInfo()
1027 int sound_effect_properties[NUM_SOUND_FILES];
1030 sound_files = getCurrentSoundList();
1032 /* initialize sound effect for all elements to "no sound" */
1033 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1034 for (j=0; j<NUM_ACTIONS; j++)
1035 element_info[i].sound[j] = SND_UNDEFINED;
1037 for (i=0; i<NUM_SOUND_FILES; i++)
1039 int len_effect_text = strlen(sound_files[i].token);
1041 sound_effect_properties[i] = ACTION_OTHER;
1042 sound_info[i].loop = FALSE;
1044 /* determine all loop sounds and identify certain sound classes */
1046 for (j=0; sound_action_properties[j].text; j++)
1048 int len_action_text = strlen(sound_action_properties[j].text);
1050 if (len_action_text < len_effect_text &&
1051 strcmp(&sound_files[i].token[len_effect_text - len_action_text],
1052 sound_action_properties[j].text) == 0)
1054 sound_effect_properties[i] = sound_action_properties[j].value;
1056 if (sound_action_properties[j].is_loop)
1057 sound_info[i].loop = TRUE;
1061 /* associate elements and some selected sound actions */
1063 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1065 if (element_info[j].sound_class_name)
1067 int len_class_text = strlen(element_info[j].sound_class_name);
1069 if (len_class_text + 1 < len_effect_text &&
1070 strncmp(sound_files[i].token,
1071 element_info[j].sound_class_name, len_class_text) == 0 &&
1072 sound_files[i].token[len_class_text] == '.')
1074 int sound_action_value = sound_effect_properties[i];
1076 element_info[j].sound[sound_action_value] = i;
1081 set_sound_parameters(i, sound_files[i].parameter);
1087 int element = EL_SAND;
1088 int sound_action = ACTION_DIGGING;
1091 while (sound_action_properties[j].text)
1093 if (sound_action_properties[j].value == sound_action)
1094 printf("element %d, sound action '%s' == %d\n",
1095 element, sound_action_properties[j].text,
1096 element_info_[element].sound[sound_action]);
1103 void InitElementProperties()
1107 static int ep_amoebalive[] =
1114 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1116 static int ep_amoeboid[] =
1124 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1126 static int ep_schluessel[] =
1137 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1139 static int ep_pforte[] =
1158 EL_SWITCHGATE_OPENING,
1159 EL_SWITCHGATE_CLOSED,
1160 EL_SWITCHGATE_CLOSING,
1162 EL_TIMEGATE_OPENING,
1164 EL_TIMEGATE_CLOSING,
1168 EL_TUBE_VERTICAL_LEFT,
1169 EL_TUBE_VERTICAL_RIGHT,
1170 EL_TUBE_HORIZONTAL_UP,
1171 EL_TUBE_HORIZONTAL_DOWN,
1177 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1179 static int ep_solid[] =
1199 EL_QUICKSAND_FILLING,
1200 EL_QUICKSAND_EMPTYING,
1202 EL_MAGIC_WALL_ACTIVE,
1203 EL_MAGIC_WALL_EMPTYING,
1204 EL_MAGIC_WALL_FILLING,
1208 EL_BD_MAGIC_WALL_ACTIVE,
1209 EL_BD_MAGIC_WALL_EMPTYING,
1210 EL_BD_MAGIC_WALL_FULL,
1211 EL_BD_MAGIC_WALL_FILLING,
1212 EL_BD_MAGIC_WALL_DEAD,
1215 EL_ACIDPOOL_TOPLEFT,
1216 EL_ACIDPOOL_TOPRIGHT,
1217 EL_ACIDPOOL_BOTTOMLEFT,
1219 EL_ACIDPOOL_BOTTOMRIGHT,
1237 EL_SP_TERMINAL_ACTIVE,
1240 EL_INVISIBLE_STEELWALL,
1241 EL_INVISIBLE_STEELWALL_ACTIVE,
1243 EL_INVISIBLE_WALL_ACTIVE,
1244 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1245 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1246 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1247 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1248 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1249 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1250 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1251 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1252 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1253 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1254 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1255 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1256 EL_SWITCHGATE_SWITCH_UP,
1257 EL_SWITCHGATE_SWITCH_DOWN,
1259 EL_LIGHT_SWITCH_ACTIVE,
1261 EL_TIMEGATE_SWITCH_ACTIVE,
1262 EL_SIGN_EXCLAMATION,
1263 EL_SIGN_RADIOACTIVITY,
1274 EL_STEELWALL_SLANTED,
1279 EL_EMC_WALL_PILLAR_UPPER,
1280 EL_EMC_WALL_PILLAR_MIDDLE,
1281 EL_EMC_WALL_PILLAR_LOWER,
1307 EL_SWITCHGATE_OPENING,
1308 EL_SWITCHGATE_CLOSED,
1309 EL_SWITCHGATE_CLOSING,
1311 EL_TIMEGATE_OPENING,
1313 EL_TIMEGATE_CLOSING,
1317 EL_TUBE_VERTICAL_LEFT,
1318 EL_TUBE_VERTICAL_RIGHT,
1319 EL_TUBE_HORIZONTAL_UP,
1320 EL_TUBE_HORIZONTAL_DOWN,
1326 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1328 static int ep_massive[] =
1332 EL_ACIDPOOL_TOPLEFT,
1333 EL_ACIDPOOL_TOPRIGHT,
1334 EL_ACIDPOOL_BOTTOMLEFT,
1336 EL_ACIDPOOL_BOTTOMRIGHT,
1348 EL_INVISIBLE_STEELWALL,
1349 EL_INVISIBLE_STEELWALL_ACTIVE,
1350 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1351 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1352 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1353 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1354 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1355 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1356 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1357 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1358 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1359 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1360 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1361 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1363 EL_LIGHT_SWITCH_ACTIVE,
1364 EL_SIGN_EXCLAMATION,
1365 EL_SIGN_RADIOACTIVITY,
1376 EL_STEELWALL_SLANTED,
1399 EL_SWITCHGATE_OPENING,
1400 EL_SWITCHGATE_CLOSED,
1401 EL_SWITCHGATE_CLOSING,
1403 EL_TIMEGATE_OPENING,
1405 EL_TIMEGATE_CLOSING,
1409 EL_TUBE_VERTICAL_LEFT,
1410 EL_TUBE_VERTICAL_RIGHT,
1411 EL_TUBE_HORIZONTAL_UP,
1412 EL_TUBE_HORIZONTAL_DOWN,
1418 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1420 static int ep_slippery[] =
1434 EL_ROBOT_WHEEL_ACTIVE,
1440 EL_ACIDPOOL_TOPLEFT,
1441 EL_ACIDPOOL_TOPRIGHT,
1451 EL_STEELWALL_SLANTED,
1455 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1457 static int ep_enemy[] =
1470 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1472 static int ep_mauer[] =
1500 EL_WALL_GROWING_ACTIVE,
1519 EL_SP_TERMINAL_ACTIVE,
1522 EL_INVISIBLE_STEELWALL,
1523 EL_INVISIBLE_STEELWALL_ACTIVE,
1525 EL_INVISIBLE_WALL_ACTIVE,
1526 EL_STEELWALL_SLANTED,
1531 EL_EMC_WALL_PILLAR_UPPER,
1532 EL_EMC_WALL_PILLAR_MIDDLE,
1533 EL_EMC_WALL_PILLAR_LOWER,
1540 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1542 static int ep_can_fall[] =
1557 EL_BD_MAGIC_WALL_FULL,
1568 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1570 static int ep_can_smash[] =
1601 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1603 static int ep_can_change[] =
1614 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1616 static int ep_can_move[] =
1636 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1638 static int ep_could_move[] =
1648 EL_BD_BUTTERFLY_RIGHT,
1650 EL_BD_BUTTERFLY_LEFT,
1651 EL_BD_BUTTERFLY_DOWN,
1652 EL_BD_FIREFLY_RIGHT,
1661 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1663 static int ep_dont_touch[] =
1670 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1672 static int ep_dont_go_to[] =
1686 EL_SP_BUGGY_BASE_ACTIVE,
1690 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1692 static int ep_mampf2[] =
1717 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1719 static int ep_bd_element[] =
1746 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1748 static int ep_sb_element[] =
1753 EL_SOKOBAN_FIELD_EMPTY,
1754 EL_SOKOBAN_FIELD_FULL,
1756 EL_INVISIBLE_STEELWALL
1758 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1760 static int ep_gem[] =
1769 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1771 static int ep_inactive[] =
1808 EL_INVISIBLE_STEELWALL,
1816 EL_WALL_EMERALD_YELLOW,
1821 EL_SOKOBAN_FIELD_EMPTY,
1822 EL_SOKOBAN_FIELD_FULL,
1823 EL_WALL_EMERALD_RED,
1824 EL_WALL_EMERALD_PURPLE,
1825 EL_ACIDPOOL_TOPLEFT,
1826 EL_ACIDPOOL_TOPRIGHT,
1827 EL_ACIDPOOL_BOTTOMLEFT,
1829 EL_ACIDPOOL_BOTTOMRIGHT,
1833 EL_BD_MAGIC_WALL_DEAD,
1834 EL_AMOEBA_TO_DIAMOND,
1867 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1868 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1869 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1870 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1871 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1872 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1873 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1874 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1875 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1876 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1877 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1878 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1879 EL_SIGN_EXCLAMATION,
1880 EL_SIGN_RADIOACTIVITY,
1891 EL_STEELWALL_SLANTED,
1896 EL_EMC_WALL_PILLAR_UPPER,
1897 EL_EMC_WALL_PILLAR_MIDDLE,
1898 EL_EMC_WALL_PILLAR_LOWER,
1905 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1907 static int ep_explosive[] =
1912 EL_DYNABOMB_PLAYER1_ACTIVE,
1913 EL_DYNABOMB_PLAYER2_ACTIVE,
1914 EL_DYNABOMB_PLAYER3_ACTIVE,
1915 EL_DYNABOMB_PLAYER4_ACTIVE,
1932 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1934 static int ep_mampf3[] =
1945 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1947 static int ep_pushable[] =
1954 EL_SOKOBAN_FIELD_FULL,
1964 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1966 static int ep_player[] =
1973 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1975 static int ep_has_content[] =
1983 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1985 static int ep_eatable[] =
1990 EL_SP_BUGGY_BASE_ACTIVATING,
1993 EL_INVISIBLE_SAND_ACTIVE
1995 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1997 static int ep_sp_element[] =
2040 /* additional elements that appeared in newer Supaplex levels */
2042 /* more than one murphy in a level results in an inactive clone */
2045 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2047 static int ep_quick_gate[] =
2071 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2073 static int ep_over_player[] =
2089 EL_TUBE_VERTICAL_LEFT,
2090 EL_TUBE_VERTICAL_RIGHT,
2091 EL_TUBE_HORIZONTAL_UP,
2092 EL_TUBE_HORIZONTAL_DOWN,
2098 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2100 static int ep_active_bomb[] =
2103 EL_DYNABOMB_PLAYER1_ACTIVE,
2104 EL_DYNABOMB_PLAYER2_ACTIVE,
2105 EL_DYNABOMB_PLAYER3_ACTIVE,
2106 EL_DYNABOMB_PLAYER4_ACTIVE
2108 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2110 static int ep_belt[] =
2112 EL_CONVEYOR_BELT1_LEFT,
2113 EL_CONVEYOR_BELT1_MIDDLE,
2114 EL_CONVEYOR_BELT1_RIGHT,
2115 EL_CONVEYOR_BELT2_LEFT,
2116 EL_CONVEYOR_BELT2_MIDDLE,
2117 EL_CONVEYOR_BELT2_RIGHT,
2118 EL_CONVEYOR_BELT3_LEFT,
2119 EL_CONVEYOR_BELT3_MIDDLE,
2120 EL_CONVEYOR_BELT3_RIGHT,
2121 EL_CONVEYOR_BELT4_LEFT,
2122 EL_CONVEYOR_BELT4_MIDDLE,
2123 EL_CONVEYOR_BELT4_RIGHT,
2125 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2127 static int ep_belt_active[] =
2129 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2130 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2131 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2132 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2133 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2134 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2135 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2136 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2137 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2138 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2139 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2140 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2142 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2144 static int ep_belt_switch[] =
2146 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2147 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2148 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2149 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2150 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2151 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2152 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2153 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2154 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2155 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2156 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2157 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2159 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2161 static int ep_tube[] =
2166 EL_TUBE_VERTICAL_LEFT,
2167 EL_TUBE_VERTICAL_RIGHT,
2168 EL_TUBE_HORIZONTAL_UP,
2169 EL_TUBE_HORIZONTAL_DOWN,
2175 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2177 static long ep1_bit[] =
2211 static long ep2_bit[] =
2218 static int *ep1_array[] =
2252 static int *ep2_array[] =
2259 static int *ep1_num[] =
2286 &ep_has_content_num,
2290 &ep_over_player_num,
2293 static int *ep2_num[] =
2296 &ep_belt_active_num,
2297 &ep_belt_switch_num,
2300 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2301 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2303 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2309 for (i=0; i<num_properties1; i++)
2310 for (j=0; j<*(ep1_num[i]); j++)
2311 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2312 for (i=0; i<num_properties2; i++)
2313 for (j=0; j<*(ep2_num[i]); j++)
2314 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2316 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2317 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2320 void Execute_Command(char *command)
2322 if (strcmp(command, "print graphicsinfo.conf") == 0)
2326 printf("# You can configure additional/alternative image files here.\n");
2327 printf("# (The images below are default and therefore commented out.)\n");
2329 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2331 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2334 for (i=0; image_config[i].token != NULL; i++)
2336 getFormattedSetupEntry(image_config[i].token,
2337 image_config[i].value));
2341 else if (strcmp(command, "print soundsinfo.conf") == 0)
2345 printf("# You can configure additional/alternative sound files here.\n");
2346 printf("# (The sounds below are default and therefore commented out.)\n");
2348 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2350 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2353 for (i=0; sound_config[i].token != NULL; i++)
2355 getFormattedSetupEntry(sound_config[i].token,
2356 sound_config[i].value));
2360 else if (strcmp(command, "print musicinfo.conf") == 0)
2362 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2364 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2366 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2370 else if (strncmp(command, "dump level ", 11) == 0)
2372 char *filename = &command[11];
2374 if (access(filename, F_OK) != 0)
2375 Error(ERR_EXIT, "cannot open file '%s'", filename);
2377 LoadLevelFromFilename(filename);
2382 else if (strncmp(command, "dump tape ", 10) == 0)
2384 char *filename = &command[10];
2386 if (access(filename, F_OK) != 0)
2387 Error(ERR_EXIT, "cannot open file '%s'", filename);
2389 LoadTapeFromFilename(filename);
2394 else if (strncmp(command, "autoplay ", 9) == 0)
2396 char *str_copy = getStringCopy(&command[9]);
2397 char *str_ptr = strchr(str_copy, ' ');
2399 global.autoplay_leveldir = str_copy;
2400 global.autoplay_level_nr = -1;
2402 if (str_ptr != NULL)
2404 *str_ptr++ = '\0'; /* terminate leveldir string */
2405 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2410 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2414 void CloseAllAndExit(int exit_value)
2419 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2422 FreeTileClipmasks();
2424 if (bitmap_font_initial)
2425 FreeBitmap(bitmap_font_initial);
2427 CloseVideoDisplay();
2428 ClosePlatformDependantStuff();