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 InitImages(void);
68 static void InitMixer(void);
69 static void InitSound(void);
70 static void InitGfx(void);
71 static void InitGfxBackground(void);
72 static void InitGadgets(void);
73 static void InitElementProperties(void);
74 static void InitElementInfo(void);
75 static void InitGraphicInfo(void);
76 static void InitSoundInfo();
77 static void Execute_Command(char *);
81 InitGlobal(); /* initialize some global variables */
83 if (options.execute_command)
84 Execute_Command(options.execute_command);
86 if (options.serveronly)
88 #if defined(PLATFORM_UNIX)
89 NetworkServer(options.server_port, options.serveronly);
91 Error(ERR_WARN, "networking only supported in Unix version");
93 exit(0); /* never reached */
96 InitProgramInfo(UNIX_USERDATA_DIRECTORY,
97 PROGRAM_TITLE_STRING, getWindowTitleString(),
98 ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
99 MSDOS_POINTER_FILENAME,
100 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
104 InitArtworkInfo(); /* needed before loading gfx, sound & music */
109 InitRND(NEW_RANDOMIZE);
112 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
115 InitEventFilter(FilterMouseMotionEvents);
117 InitElementProperties();
123 InitLevelArtworkInfo();
125 InitImages(); /* needs to know current level directory */
126 InitSound(); /* needs to know current level directory */
130 if (global.autoplay_leveldir)
143 global.autoplay_leveldir = NULL;
145 global.frames_per_second = 0;
146 global.fps_slowdown = FALSE;
147 global.fps_slowdown_factor = 1;
152 LoadSetup(); /* global setup info */
155 void InitPlayerInfo()
159 /* choose default local player */
160 local_player = &stored_player[0];
162 for (i=0; i<MAX_PLAYERS; i++)
163 stored_player[i].connected = FALSE;
165 local_player->connected = TRUE;
170 LoadLevelInfo(); /* global level info */
171 LoadLevelSetup_LastSeries(); /* last played series info */
172 LoadLevelSetup_SeriesInfo(); /* last played level info */
175 void InitArtworkInfo()
180 void InitLevelArtworkInfo()
182 LoadLevelArtworkInfo();
185 void InitNetworkServer()
187 #if defined(PLATFORM_UNIX)
191 if (!options.network)
194 #if defined(PLATFORM_UNIX)
195 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
197 if (!ConnectToServer(options.server_host, options.server_port))
198 Error(ERR_EXIT, "cannot connect to network game server");
200 SendToServer_PlayerName(setup.player_name);
201 SendToServer_ProtocolVersion();
204 SendToServer_NrWanted(nr_wanted);
208 static void ReinitializeGraphics()
210 ReloadCustomImages(); /* load custom image files */
212 InitGraphicInfo(); /* initialize graphic info from config file */
214 InitFontInfo(bitmap_font_initial,
215 graphic_info[IMG_FONT_BIG].bitmap,
216 graphic_info[IMG_FONT_MEDIUM].bitmap,
217 graphic_info[IMG_FONT_SMALL].bitmap,
218 graphic_info[IMG_FONT_EM].bitmap);
220 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
221 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
227 static void InitImages()
229 InitImageList(image_config, image_config_suffix, NUM_IMAGE_FILES);
231 ReinitializeGraphics();
234 static void InitMixer()
238 InitSoundList(sound_config, sound_config_suffix, NUM_SOUND_FILES);
243 static void InitSound()
245 /* load custom sounds and music */
246 InitReloadSounds(artwork.snd_current->identifier);
247 InitReloadMusic(artwork.mus_current->identifier);
252 static void InitTileClipmasks()
255 #if defined(TARGET_X11)
256 XGCValues clip_gc_values;
257 unsigned long clip_gc_valuemask;
259 #if defined(TARGET_X11_NATIVE)
269 tile_needs_clipping[] =
271 { GFX_SPIELER1_UP, 4 },
272 { GFX_SPIELER1_DOWN, 4 },
273 { GFX_SPIELER1_LEFT, 4 },
274 { GFX_SPIELER1_RIGHT, 4 },
275 { GFX_SPIELER1_PUSH_LEFT, 4 },
276 { GFX_SPIELER1_PUSH_RIGHT, 4 },
277 { GFX_SPIELER2_UP, 4 },
278 { GFX_SPIELER2_DOWN, 4 },
279 { GFX_SPIELER2_LEFT, 4 },
280 { GFX_SPIELER2_RIGHT, 4 },
281 { GFX_SPIELER2_PUSH_LEFT, 4 },
282 { GFX_SPIELER2_PUSH_RIGHT, 4 },
283 { GFX_SPIELER3_UP, 4 },
284 { GFX_SPIELER3_DOWN, 4 },
285 { GFX_SPIELER3_LEFT, 4 },
286 { GFX_SPIELER3_RIGHT, 4 },
287 { GFX_SPIELER3_PUSH_LEFT, 4 },
288 { GFX_SPIELER3_PUSH_RIGHT, 4 },
289 { GFX_SPIELER4_UP, 4 },
290 { GFX_SPIELER4_DOWN, 4 },
291 { GFX_SPIELER4_LEFT, 4 },
292 { GFX_SPIELER4_RIGHT, 4 },
293 { GFX_SPIELER4_PUSH_LEFT, 4 },
294 { GFX_SPIELER4_PUSH_RIGHT, 4 },
295 { GFX_SP_MURPHY, 1 },
296 { GFX_MURPHY_GO_LEFT, 3 },
297 { GFX_MURPHY_GO_RIGHT, 3 },
298 { GFX_MURPHY_SNAP_UP, 1 },
299 { GFX_MURPHY_SNAP_DOWN, 1 },
300 { GFX_MURPHY_SNAP_RIGHT, 1 },
301 { GFX_MURPHY_SNAP_LEFT, 1 },
302 { GFX_MURPHY_PUSH_RIGHT, 1 },
303 { GFX_MURPHY_PUSH_LEFT, 1 },
304 { GFX_GEBLUBBER, 4 },
307 { GFX_EXPLOSION, 8 },
308 { GFX_SOKOBAN_OBJEKT, 1 },
309 { GFX_FUNKELN_BLAU, 3 },
310 { GFX_FUNKELN_WEISS, 3 },
311 { GFX2_SHIELD_PASSIVE, 3 },
312 { GFX2_SHIELD_ACTIVE, 3 },
317 #endif /* TARGET_X11_NATIVE */
318 #endif /* TARGET_X11 */
322 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
323 for (i=0; i<NUM_TILES; i++)
324 tile_clipmask[i] = None;
326 #if defined(TARGET_X11)
327 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
328 often very slow when preparing a masked XCopyArea() for big Pixmaps.
329 To prevent this, create small (tile-sized) mask Pixmaps which will then
330 be set much faster with XSetClipOrigin() and speed things up a lot. */
332 clip_gc_values.graphics_exposures = False;
333 clip_gc_valuemask = GCGraphicsExposures;
334 tile_clip_gc = XCreateGC(display, window->drawable,
335 clip_gc_valuemask, &clip_gc_values);
338 for (i=0; i<NUM_BITMAPS; i++)
340 if (pix[i]->clip_mask)
342 clip_gc_values.graphics_exposures = False;
343 clip_gc_values.clip_mask = pix[i]->clip_mask;
344 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
345 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
346 clip_gc_valuemask, &clip_gc_values);
351 #if defined(TARGET_X11_NATIVE)
354 /* create graphic context structures needed for clipping */
355 clip_gc_values.graphics_exposures = False;
356 clip_gc_valuemask = GCGraphicsExposures;
357 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
358 clip_gc_valuemask, &clip_gc_values);
360 /* create only those clipping Pixmaps we really need */
361 for (i=0; tile_needs_clipping[i].start>=0; i++)
365 for (j=0; j<tile_needs_clipping[i].count; j++)
367 int tile = tile_needs_clipping[i].start + j;
373 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
374 src_pixmap = src_bitmap->clip_mask;
376 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
379 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
380 src_x, src_y, TILEX, TILEY, 0, 0);
384 XFreeGC(display, copy_clipmask_gc);
387 #endif /* TARGET_X11_NATIVE */
388 #endif /* TARGET_X11 */
392 void FreeTileClipmasks()
395 #if defined(TARGET_X11)
398 for (i=0; i<NUM_TILES; i++)
400 if (tile_clipmask[i] != None)
402 XFreePixmap(display, tile_clipmask[i]);
403 tile_clipmask[i] = None;
408 XFreeGC(display, tile_clip_gc);
412 for (i=0; i<NUM_BITMAPS; i++)
414 if (pix[i] != NULL && pix[i]->stored_clip_gc)
416 XFreeGC(display, pix[i]->stored_clip_gc);
417 pix[i]->stored_clip_gc = None;
422 #endif /* TARGET_X11 */
432 /* initialize screen properties */
433 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
434 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
435 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
436 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
437 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
439 /* create additional image buffers for double-buffering */
440 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
441 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
444 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
446 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
448 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
450 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
453 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
454 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
456 DrawInitText("Loading graphics:", 120, FC_GREEN);
459 for (i=0; i<NUM_PICTURES; i++)
462 if (i != PIX_FONT_SMALL)
465 DrawInitText(image_filename[i], 150, FC_YELLOW);
467 pix[i] = LoadCustomImage(image_filename[i]);
473 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
480 void InitGfxBackground()
485 fieldbuffer = bitmap_db_field;
486 SetDrawtoField(DRAW_BACKBUFFER);
488 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
489 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
490 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
491 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
493 for (x=0; x<MAX_BUF_XSIZE; x++)
494 for (y=0; y<MAX_BUF_YSIZE; y++)
497 redraw_mask = REDRAW_ALL;
500 void ReloadCustomArtwork()
502 static char *leveldir_current_identifier = NULL;
503 static boolean last_override_level_graphics = FALSE;
504 static boolean last_override_level_sounds = FALSE;
505 static boolean last_override_level_music = FALSE;
506 /* identifier for new artwork; default: artwork configured in setup */
507 char *gfx_new_identifier = artwork.gfx_current->identifier;
508 char *snd_new_identifier = artwork.snd_current->identifier;
509 char *mus_new_identifier = artwork.mus_current->identifier;
510 boolean redraw_screen = FALSE;
512 if (leveldir_current_identifier == NULL)
513 leveldir_current_identifier = leveldir_current->identifier;
516 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
517 leveldir_current->graphics_set);
518 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
519 leveldir_current->identifier);
523 printf("graphics --> '%s' ('%s')\n",
524 artwork.gfx_current_identifier, artwork.gfx_current->filename);
525 printf("sounds --> '%s' ('%s')\n",
526 artwork.snd_current_identifier, artwork.snd_current->filename);
527 printf("music --> '%s' ('%s')\n",
528 artwork.mus_current_identifier, artwork.mus_current->filename);
531 /* leveldir_current may be invalid (level group, parent link) */
532 if (!validLevelSeries(leveldir_current))
536 printf("--> '%s'\n", artwork.gfx_current_identifier);
539 /* when a new level series was selected, check if there was a change
540 in custom artwork stored in level series directory */
541 if (leveldir_current_identifier != leveldir_current->identifier)
543 char *identifier_old = leveldir_current_identifier;
544 char *identifier_new = leveldir_current->identifier;
546 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
547 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
548 gfx_new_identifier = identifier_new;
549 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
550 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
551 snd_new_identifier = identifier_new;
552 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
553 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
554 mus_new_identifier = identifier_new;
556 leveldir_current_identifier = leveldir_current->identifier;
559 /* custom level artwork configured in level series configuration file
560 always overrides custom level artwork stored in level series directory
561 and (level independant) custom artwork configured in setup menue */
562 if (leveldir_current->graphics_set != NULL)
563 gfx_new_identifier = leveldir_current->graphics_set;
564 if (leveldir_current->sounds_set != NULL)
565 snd_new_identifier = leveldir_current->sounds_set;
566 if (leveldir_current->music_set != NULL)
567 mus_new_identifier = leveldir_current->music_set;
569 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
570 last_override_level_graphics != setup.override_level_graphics)
573 printf("CHANGED GFX: '%s' -> '%s'\n",
574 artwork.gfx_current_identifier, gfx_new_identifier);
581 setLevelArtworkDir(artwork.gfx_first);
583 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
586 for (i=0; i<NUM_PICTURES; i++)
588 DrawInitText(image_filename[i], 150, FC_YELLOW);
589 ReloadCustomImage(pix[i], image_filename[i]);
597 ReinitializeGraphics();
605 /* force redraw of (open or closed) door graphics */
606 SetDoorState(DOOR_OPEN_ALL);
607 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
611 artwork.gfx_current_identifier = gfx_new_identifier;
613 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
615 last_override_level_graphics = setup.override_level_graphics;
617 redraw_screen = TRUE;
620 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
621 last_override_level_sounds != setup.override_level_sounds)
623 /* set artwork path to send it to the sound server process */
624 setLevelArtworkDir(artwork.snd_first);
626 InitReloadSounds(snd_new_identifier);
628 artwork.snd_current_identifier = snd_new_identifier;
629 last_override_level_sounds = setup.override_level_sounds;
631 redraw_screen = TRUE;
634 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
635 last_override_level_music != setup.override_level_music)
637 /* set artwork path to send it to the sound server process */
638 setLevelArtworkDir(artwork.mus_first);
640 InitReloadMusic(mus_new_identifier);
642 artwork.mus_current_identifier = mus_new_identifier;
643 last_override_level_music = setup.override_level_music;
645 redraw_screen = TRUE;
652 /* force redraw of (open or closed) door graphics */
653 SetDoorState(DOOR_OPEN_ALL);
654 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
658 printf("<-- '%s'\n", artwork.gfx_current_identifier);
664 FreeLevelEditorGadgets();
673 static boolean gadgets_initialized = FALSE;
675 if (gadgets_initialized)
678 CreateLevelEditorGadgets();
682 CreateScreenGadgets();
684 gadgets_initialized = TRUE;
687 void InitElementInfo()
692 /* set values to -1 to identify later as "uninitialized" values */
693 for (i=0; i<MAX_NUM_ELEMENTS; i++)
695 for (act=0; act<NUM_ACTIONS; act++)
697 element_info[i].graphic[act] = -1;
699 for (dir=0; dir<NUM_DIRECTIONS; dir++)
700 element_info[i].direction_graphic[act][dir] = -1;
704 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
705 element_info[i].graphic[ACTION_DEFAULT] =
706 IMG_CHAR_START + (i - EL_CHAR_START);
708 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
709 element_info[i].graphic[ACTION_DEFAULT] =
710 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
713 while (element_to_graphic[i].element > -1)
715 int element = element_to_graphic[i].element;
716 int direction = element_to_graphic[i].direction;
717 int action = element_to_graphic[i].action;
718 int graphic = element_to_graphic[i].graphic;
721 action = ACTION_DEFAULT;
725 direction = MV_DIR_BIT(direction);
727 element_info[element].direction_graphic[action][direction] = graphic;
730 element_info[element].graphic[action] = graphic;
735 /* now set all '-1' values to element specific default values */
736 for (i=0; i<MAX_NUM_ELEMENTS; i++)
738 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
739 int default_action_direction_graphic[NUM_DIRECTIONS];
741 if (default_action_graphic == -1)
742 default_action_graphic = IMG_CHAR_QUESTION;
744 for (dir=0; dir<NUM_DIRECTIONS; dir++)
746 default_action_direction_graphic[dir] =
747 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
749 if (default_action_direction_graphic[dir] == -1)
750 default_action_direction_graphic[dir] = default_action_graphic;
753 for (act=0; act<NUM_ACTIONS; act++)
755 for (dir=0; dir<NUM_DIRECTIONS; dir++)
757 int default_direction_graphic = element_info[i].graphic[act];
759 /* no graphic for current action -- use default direction graphic */
760 if (default_direction_graphic == -1)
761 default_direction_graphic = default_action_direction_graphic[dir];
763 if (element_info[i].direction_graphic[act][dir] == -1)
764 element_info[i].direction_graphic[act][dir] =
765 default_direction_graphic;
768 /* no graphic for this specific action -- use default action graphic */
769 if (element_info[i].graphic[act] == -1)
770 element_info[i].graphic[act] = default_action_graphic;
775 static void InitGraphicInfo()
777 static boolean clipmasks_initialized = FALSE;
778 static int gfx_action[NUM_IMAGE_FILES];
780 int first_frame, last_frame;
782 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
784 XGCValues clip_gc_values;
785 unsigned long clip_gc_valuemask;
786 GC copy_clipmask_gc = None;
789 image_files = getCurrentImageList();
791 /* set temporary graphics action field to default value */
792 for (i=0; i<NUM_IMAGE_FILES; i++)
793 gfx_action[i] = ACTION_DEFAULT;
795 /* set temporary graphics action field from element_to_graphic list */
797 while (element_to_graphic[i].element > -1)
799 int action = element_to_graphic[i].action;
800 int graphic = element_to_graphic[i].graphic;
803 action = ACTION_DEFAULT;
805 gfx_action[graphic] = action;
810 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
811 if (clipmasks_initialized)
813 for (i=0; i<NUM_IMAGE_FILES; i++)
815 if (graphic_info[i].clip_mask)
816 XFreePixmap(display, graphic_info[i].clip_mask);
817 if (graphic_info[i].clip_gc)
818 XFreeGC(display, graphic_info[i].clip_gc);
820 graphic_info[i].clip_mask = None;
821 graphic_info[i].clip_gc = None;
826 for (i=0; i<NUM_IMAGE_FILES; i++)
828 Bitmap *src_bitmap = getBitmapFromImageID(i);
829 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
830 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
831 int *parameter = image_files[i].parameter;
833 graphic_info[i].bitmap = src_bitmap;
835 graphic_info[i].src_x = parameter[GFX_ARG_XPOS] * TILEX;
836 graphic_info[i].src_y = parameter[GFX_ARG_YPOS] * TILEY;
837 graphic_info[i].offset_x = parameter[GFX_ARG_OFFSET];
838 graphic_info[i].offset_y = 0;
840 /* animation frames are ordered vertically instead of horizontally */
841 if (parameter[GFX_ARG_VERTICAL])
843 graphic_info[i].offset_x = 0;
844 graphic_info[i].offset_y = parameter[GFX_ARG_OFFSET];
847 /* optionally, the x and y offset of frames can be specified directly */
848 if (parameter[GFX_ARG_XOFFSET] != GFX_ARG_UNDEFINED_VALUE)
849 graphic_info[i].offset_x = parameter[GFX_ARG_XOFFSET];
850 if (parameter[GFX_ARG_YOFFSET] != GFX_ARG_UNDEFINED_VALUE)
851 graphic_info[i].offset_y = parameter[GFX_ARG_YOFFSET];
853 /* automatically determine correct number of frames, if not defined */
854 if (parameter[GFX_ARG_FRAMES] != GFX_ARG_UNDEFINED_VALUE)
855 graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
856 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
857 graphic_info[i].anim_frames = num_xtiles;
858 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
859 graphic_info[i].anim_frames = num_ytiles;
861 graphic_info[i].anim_frames = 1;
863 graphic_info[i].anim_delay = parameter[GFX_ARG_DELAY];
864 if (graphic_info[i].anim_delay == 0) /* delay must be at least 1 */
865 graphic_info[i].anim_delay = 1;
867 /* set mode for animation frame order */
868 if (parameter[GFX_ARG_MODE_LOOP])
869 graphic_info[i].anim_mode = ANIM_LOOP;
870 else if (parameter[GFX_ARG_MODE_LINEAR])
871 graphic_info[i].anim_mode = ANIM_LINEAR;
872 else if (parameter[GFX_ARG_MODE_PINGPONG])
873 graphic_info[i].anim_mode = ANIM_PINGPONG;
874 else if (parameter[GFX_ARG_MODE_PINGPONG2])
875 graphic_info[i].anim_mode = ANIM_PINGPONG2;
876 else if (parameter[GFX_ARG_MODE_RANDOM])
877 graphic_info[i].anim_mode = ANIM_RANDOM;
878 else if (graphic_info[i].anim_frames > 1)
879 graphic_info[i].anim_mode = ANIM_LOOP;
881 graphic_info[i].anim_mode = ANIM_NONE;
883 /* set additional flag to play animation frames in reverse order */
884 if (parameter[GFX_ARG_MODE_REVERSE])
885 graphic_info[i].anim_mode |= ANIM_REVERSE;
887 /* set first frame of animation after determining animation mode */
888 graphic_info[i].anim_start_frame = parameter[GFX_ARG_START_FRAME];
890 /* automatically determine correct start frame, if not defined */
891 if (parameter[GFX_ARG_START_FRAME] == GFX_ARG_UNDEFINED_VALUE)
892 graphic_info[i].anim_start_frame = 0;
893 else if (graphic_info[i].anim_mode & ANIM_REVERSE)
894 graphic_info[i].anim_start_frame =
895 graphic_info[i].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
897 /* animation synchronized with global frame counter, not move position */
898 graphic_info[i].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
900 /* set global_sync for all animations with undefined "animation action" */
901 if (parameter[GFX_ARG_GLOBAL_SYNC] == GFX_ARG_UNDEFINED_VALUE)
902 graphic_info[i].anim_global_sync =
903 (gfx_action[i] == ACTION_DEFAULT ? TRUE : FALSE);
905 /* "linear" animations are never globally synchronized */
906 if (parameter[GFX_ARG_MODE_LINEAR])
907 graphic_info[i].anim_global_sync = FALSE;
909 /* now check if no animation frames are outside of the loaded image */
911 if (graphic_info[i].bitmap == NULL)
912 continue; /* skip check for optional images that are undefined */
915 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
916 if (src_x < 0 || src_y < 0 ||
917 src_x + TILEX > src_bitmap->width ||
918 src_y + TILEY > src_bitmap->height)
920 Error(ERR_RETURN, "custom artwork configuration error:");
921 Error(ERR_RETURN, "- config file: '%s'",
922 getImageConfigFilename());
923 Error(ERR_RETURN, "- config token: '%s'",
924 getTokenFromImageID(i));
925 Error(ERR_RETURN, "- image file: '%s'",
926 src_bitmap->source_filename);
927 Error(ERR_EXIT, "error: first animation frame out of bounds (%d,%d)",
931 last_frame = graphic_info[i].anim_frames - 1;
932 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
933 if (src_x < 0 || src_y < 0 ||
934 src_x + TILEX > src_bitmap->width ||
935 src_y + TILEY > src_bitmap->height)
937 Error(ERR_RETURN, "custom artwork configuration error:");
938 Error(ERR_RETURN, "- config file: '%s'",
939 getImageConfigFilename());
940 Error(ERR_RETURN, "- config token: '%s'",
941 getTokenFromImageID(i));
942 Error(ERR_RETURN, "- image file: '%s'",
943 src_bitmap->source_filename);
944 Error(ERR_EXIT, "error: last animation frame (%d) out of bounds (%d,%d)",
945 last_frame, src_x, src_y);
948 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
949 /* currently we need only a tile clip mask from the first frame */
950 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
952 if (copy_clipmask_gc == None)
954 clip_gc_values.graphics_exposures = False;
955 clip_gc_valuemask = GCGraphicsExposures;
956 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
957 clip_gc_valuemask, &clip_gc_values);
960 graphic_info[i].clip_mask =
961 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
963 src_pixmap = src_bitmap->clip_mask;
964 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
965 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
967 clip_gc_values.graphics_exposures = False;
968 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
969 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
970 graphic_info[i].clip_gc =
971 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
975 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
976 if (copy_clipmask_gc)
977 XFreeGC(display, copy_clipmask_gc);
980 clipmasks_initialized = TRUE;
983 static void InitSoundInfo()
985 int sound_effect_properties[NUM_SOUND_FILES];
988 sound_files = getCurrentSoundList();
990 /* initialize sound effect for all elements to "no sound" */
991 for (i=0; i<MAX_NUM_ELEMENTS; i++)
992 for (j=0; j<NUM_ACTIONS; j++)
993 element_info[i].sound[j] = SND_UNDEFINED;
995 for (i=0; i<NUM_SOUND_FILES; i++)
997 int len_effect_text = strlen(sound_files[i].token);
999 sound_effect_properties[i] = ACTION_OTHER;
1000 sound_info[i].loop = FALSE;
1002 /* determine all loop sounds and identify certain sound classes */
1004 for (j=0; sound_action_properties[j].text; j++)
1006 int len_action_text = strlen(sound_action_properties[j].text);
1008 if (len_action_text < len_effect_text &&
1009 strcmp(&sound_files[i].token[len_effect_text - len_action_text],
1010 sound_action_properties[j].text) == 0)
1012 sound_effect_properties[i] = sound_action_properties[j].value;
1014 if (sound_action_properties[j].is_loop)
1015 sound_info[i].loop = TRUE;
1019 /* associate elements and some selected sound actions */
1021 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1023 if (element_info[j].sound_class_name)
1025 int len_class_text = strlen(element_info[j].sound_class_name);
1027 if (len_class_text + 1 < len_effect_text &&
1028 strncmp(sound_files[i].token,
1029 element_info[j].sound_class_name, len_class_text) == 0 &&
1030 sound_files[i].token[len_class_text] == '.')
1032 int sound_action_value = sound_effect_properties[i];
1034 element_info[j].sound[sound_action_value] = i;
1043 int element = EL_SAND;
1044 int sound_action = ACTION_DIGGING;
1047 while (sound_action_properties[j].text)
1049 if (sound_action_properties[j].value == sound_action)
1050 printf("element %d, sound action '%s' == %d\n",
1051 element, sound_action_properties[j].text,
1052 element_info_[element].sound[sound_action]);
1059 void InitElementProperties()
1063 static int ep_amoebalive[] =
1070 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1072 static int ep_amoeboid[] =
1080 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1082 static int ep_schluessel[] =
1093 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1095 static int ep_pforte[] =
1114 EL_SWITCHGATE_OPENING,
1115 EL_SWITCHGATE_CLOSED,
1116 EL_SWITCHGATE_CLOSING,
1118 EL_TIMEGATE_OPENING,
1120 EL_TIMEGATE_CLOSING,
1124 EL_TUBE_VERTICAL_LEFT,
1125 EL_TUBE_VERTICAL_RIGHT,
1126 EL_TUBE_HORIZONTAL_UP,
1127 EL_TUBE_HORIZONTAL_DOWN,
1133 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1135 static int ep_solid[] =
1155 EL_QUICKSAND_FILLING,
1156 EL_QUICKSAND_EMPTYING,
1158 EL_MAGIC_WALL_ACTIVE,
1159 EL_MAGIC_WALL_EMPTYING,
1160 EL_MAGIC_WALL_FILLING,
1164 EL_BD_MAGIC_WALL_ACTIVE,
1165 EL_BD_MAGIC_WALL_EMPTYING,
1166 EL_BD_MAGIC_WALL_FULL,
1167 EL_BD_MAGIC_WALL_FILLING,
1168 EL_BD_MAGIC_WALL_DEAD,
1171 EL_ACIDPOOL_TOPLEFT,
1172 EL_ACIDPOOL_TOPRIGHT,
1173 EL_ACIDPOOL_BOTTOMLEFT,
1175 EL_ACIDPOOL_BOTTOMRIGHT,
1193 EL_SP_TERMINAL_ACTIVE,
1196 EL_INVISIBLE_STEELWALL,
1197 EL_INVISIBLE_STEELWALL_ACTIVE,
1199 EL_INVISIBLE_WALL_ACTIVE,
1200 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1201 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1202 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1203 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1204 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1205 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1206 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1207 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1208 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1209 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1210 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1211 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1212 EL_SWITCHGATE_SWITCH_UP,
1213 EL_SWITCHGATE_SWITCH_DOWN,
1215 EL_LIGHT_SWITCH_ACTIVE,
1217 EL_TIMEGATE_SWITCH_ACTIVE,
1218 EL_SIGN_EXCLAMATION,
1219 EL_SIGN_RADIOACTIVITY,
1230 EL_STEELWALL_SLANTED,
1235 EL_EMC_WALL_PILLAR_UPPER,
1236 EL_EMC_WALL_PILLAR_MIDDLE,
1237 EL_EMC_WALL_PILLAR_LOWER,
1263 EL_SWITCHGATE_OPENING,
1264 EL_SWITCHGATE_CLOSED,
1265 EL_SWITCHGATE_CLOSING,
1267 EL_TIMEGATE_OPENING,
1269 EL_TIMEGATE_CLOSING,
1273 EL_TUBE_VERTICAL_LEFT,
1274 EL_TUBE_VERTICAL_RIGHT,
1275 EL_TUBE_HORIZONTAL_UP,
1276 EL_TUBE_HORIZONTAL_DOWN,
1282 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1284 static int ep_massive[] =
1288 EL_ACIDPOOL_TOPLEFT,
1289 EL_ACIDPOOL_TOPRIGHT,
1290 EL_ACIDPOOL_BOTTOMLEFT,
1292 EL_ACIDPOOL_BOTTOMRIGHT,
1304 EL_INVISIBLE_STEELWALL,
1305 EL_INVISIBLE_STEELWALL_ACTIVE,
1306 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1307 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1308 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1309 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1310 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1311 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1312 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1313 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1314 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1315 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1316 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1317 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1319 EL_LIGHT_SWITCH_ACTIVE,
1320 EL_SIGN_EXCLAMATION,
1321 EL_SIGN_RADIOACTIVITY,
1332 EL_STEELWALL_SLANTED,
1355 EL_SWITCHGATE_OPENING,
1356 EL_SWITCHGATE_CLOSED,
1357 EL_SWITCHGATE_CLOSING,
1359 EL_TIMEGATE_OPENING,
1361 EL_TIMEGATE_CLOSING,
1365 EL_TUBE_VERTICAL_LEFT,
1366 EL_TUBE_VERTICAL_RIGHT,
1367 EL_TUBE_HORIZONTAL_UP,
1368 EL_TUBE_HORIZONTAL_DOWN,
1374 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1376 static int ep_slippery[] =
1390 EL_ROBOT_WHEEL_ACTIVE,
1396 EL_ACIDPOOL_TOPLEFT,
1397 EL_ACIDPOOL_TOPRIGHT,
1407 EL_STEELWALL_SLANTED,
1411 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1413 static int ep_enemy[] =
1426 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1428 static int ep_mauer[] =
1456 EL_WALL_GROWING_ACTIVE,
1475 EL_SP_TERMINAL_ACTIVE,
1478 EL_INVISIBLE_STEELWALL,
1479 EL_INVISIBLE_STEELWALL_ACTIVE,
1481 EL_INVISIBLE_WALL_ACTIVE,
1482 EL_STEELWALL_SLANTED,
1487 EL_EMC_WALL_PILLAR_UPPER,
1488 EL_EMC_WALL_PILLAR_MIDDLE,
1489 EL_EMC_WALL_PILLAR_LOWER,
1496 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1498 static int ep_can_fall[] =
1513 EL_BD_MAGIC_WALL_FULL,
1524 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1526 static int ep_can_smash[] =
1557 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1559 static int ep_can_change[] =
1570 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1572 static int ep_can_move[] =
1592 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1594 static int ep_could_move[] =
1604 EL_BD_BUTTERFLY_RIGHT,
1606 EL_BD_BUTTERFLY_LEFT,
1607 EL_BD_BUTTERFLY_DOWN,
1608 EL_BD_FIREFLY_RIGHT,
1617 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1619 static int ep_dont_touch[] =
1626 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1628 static int ep_dont_go_to[] =
1642 EL_SP_BUGGY_BASE_ACTIVE,
1646 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1648 static int ep_mampf2[] =
1673 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1675 static int ep_bd_element[] =
1702 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1704 static int ep_sb_element[] =
1709 EL_SOKOBAN_FIELD_EMPTY,
1710 EL_SOKOBAN_FIELD_FULL,
1712 EL_INVISIBLE_STEELWALL
1714 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1716 static int ep_gem[] =
1725 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1727 static int ep_inactive[] =
1764 EL_INVISIBLE_STEELWALL,
1772 EL_WALL_EMERALD_YELLOW,
1777 EL_SOKOBAN_FIELD_EMPTY,
1778 EL_SOKOBAN_FIELD_FULL,
1779 EL_WALL_EMERALD_RED,
1780 EL_WALL_EMERALD_PURPLE,
1781 EL_ACIDPOOL_TOPLEFT,
1782 EL_ACIDPOOL_TOPRIGHT,
1783 EL_ACIDPOOL_BOTTOMLEFT,
1785 EL_ACIDPOOL_BOTTOMRIGHT,
1789 EL_BD_MAGIC_WALL_DEAD,
1790 EL_AMOEBA_TO_DIAMOND,
1823 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1824 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1825 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1826 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1827 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1828 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1829 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1830 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1831 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1832 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1833 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1834 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1835 EL_SIGN_EXCLAMATION,
1836 EL_SIGN_RADIOACTIVITY,
1847 EL_STEELWALL_SLANTED,
1852 EL_EMC_WALL_PILLAR_UPPER,
1853 EL_EMC_WALL_PILLAR_MIDDLE,
1854 EL_EMC_WALL_PILLAR_LOWER,
1861 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1863 static int ep_explosive[] =
1868 EL_DYNABOMB_PLAYER1_ACTIVE,
1869 EL_DYNABOMB_PLAYER2_ACTIVE,
1870 EL_DYNABOMB_PLAYER3_ACTIVE,
1871 EL_DYNABOMB_PLAYER4_ACTIVE,
1888 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1890 static int ep_mampf3[] =
1901 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1903 static int ep_pushable[] =
1910 EL_SOKOBAN_FIELD_FULL,
1920 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1922 static int ep_player[] =
1929 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1931 static int ep_has_content[] =
1939 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1941 static int ep_eatable[] =
1946 EL_SP_BUGGY_BASE_ACTIVATING,
1949 EL_INVISIBLE_SAND_ACTIVE
1951 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1953 static int ep_sp_element[] =
1996 /* additional elements that appeared in newer Supaplex levels */
1998 /* more than one murphy in a level results in an inactive clone */
2001 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2003 static int ep_quick_gate[] =
2027 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2029 static int ep_over_player[] =
2045 EL_TUBE_VERTICAL_LEFT,
2046 EL_TUBE_VERTICAL_RIGHT,
2047 EL_TUBE_HORIZONTAL_UP,
2048 EL_TUBE_HORIZONTAL_DOWN,
2054 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2056 static int ep_active_bomb[] =
2059 EL_DYNABOMB_PLAYER1_ACTIVE,
2060 EL_DYNABOMB_PLAYER2_ACTIVE,
2061 EL_DYNABOMB_PLAYER3_ACTIVE,
2062 EL_DYNABOMB_PLAYER4_ACTIVE
2064 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2066 static int ep_belt[] =
2068 EL_CONVEYOR_BELT1_LEFT,
2069 EL_CONVEYOR_BELT1_MIDDLE,
2070 EL_CONVEYOR_BELT1_RIGHT,
2071 EL_CONVEYOR_BELT2_LEFT,
2072 EL_CONVEYOR_BELT2_MIDDLE,
2073 EL_CONVEYOR_BELT2_RIGHT,
2074 EL_CONVEYOR_BELT3_LEFT,
2075 EL_CONVEYOR_BELT3_MIDDLE,
2076 EL_CONVEYOR_BELT3_RIGHT,
2077 EL_CONVEYOR_BELT4_LEFT,
2078 EL_CONVEYOR_BELT4_MIDDLE,
2079 EL_CONVEYOR_BELT4_RIGHT,
2081 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2083 static int ep_belt_active[] =
2085 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2086 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2087 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2088 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2089 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2090 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2091 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2092 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2093 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2094 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2095 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2096 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2098 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2100 static int ep_belt_switch[] =
2102 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2103 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2104 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2105 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2106 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2107 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2108 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2109 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2110 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2111 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2112 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2113 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2115 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2117 static int ep_tube[] =
2122 EL_TUBE_VERTICAL_LEFT,
2123 EL_TUBE_VERTICAL_RIGHT,
2124 EL_TUBE_HORIZONTAL_UP,
2125 EL_TUBE_HORIZONTAL_DOWN,
2131 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2133 static long ep1_bit[] =
2167 static long ep2_bit[] =
2174 static int *ep1_array[] =
2208 static int *ep2_array[] =
2215 static int *ep1_num[] =
2242 &ep_has_content_num,
2246 &ep_over_player_num,
2249 static int *ep2_num[] =
2252 &ep_belt_active_num,
2253 &ep_belt_switch_num,
2256 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2257 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2259 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2265 for (i=0; i<num_properties1; i++)
2266 for (j=0; j<*(ep1_num[i]); j++)
2267 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2268 for (i=0; i<num_properties2; i++)
2269 for (j=0; j<*(ep2_num[i]); j++)
2270 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2272 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2273 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2276 void Execute_Command(char *command)
2278 if (strcmp(command, "print graphicsinfo.conf") == 0)
2282 printf("# You can configure additional/alternative image files here.\n");
2283 printf("# (The images below are default and therefore commented out.)\n");
2285 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2287 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2290 for (i=0; image_config[i].token != NULL; i++)
2292 getFormattedSetupEntry(image_config[i].token,
2293 image_config[i].value));
2297 else if (strcmp(command, "print soundsinfo.conf") == 0)
2301 printf("# You can configure additional/alternative sound files here.\n");
2302 printf("# (The sounds below are default and therefore commented out.)\n");
2304 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2306 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2309 for (i=0; sound_config[i].token != NULL; i++)
2311 getFormattedSetupEntry(sound_config[i].token,
2312 sound_config[i].value));
2316 else if (strcmp(command, "print musicinfo.conf") == 0)
2318 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2320 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2322 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2326 else if (strncmp(command, "dump level ", 11) == 0)
2328 char *filename = &command[11];
2330 if (access(filename, F_OK) != 0)
2331 Error(ERR_EXIT, "cannot open file '%s'", filename);
2333 LoadLevelFromFilename(filename);
2338 else if (strncmp(command, "dump tape ", 10) == 0)
2340 char *filename = &command[10];
2342 if (access(filename, F_OK) != 0)
2343 Error(ERR_EXIT, "cannot open file '%s'", filename);
2345 LoadTapeFromFilename(filename);
2350 else if (strncmp(command, "autoplay ", 9) == 0)
2352 char *str_copy = getStringCopy(&command[9]);
2353 char *str_ptr = strchr(str_copy, ' ');
2355 global.autoplay_leveldir = str_copy;
2356 global.autoplay_level_nr = -1;
2358 if (str_ptr != NULL)
2360 *str_ptr++ = '\0'; /* terminate leveldir string */
2361 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2366 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2370 void CloseAllAndExit(int exit_value)
2375 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2378 FreeTileClipmasks();
2380 if (bitmap_font_initial)
2381 FreeBitmap(bitmap_font_initial);
2383 CloseVideoDisplay();
2384 ClosePlatformDependantStuff();