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 static struct ConfigInfo action_suffix[NUM_ACTIONS + 1];
188 static struct ConfigInfo direction_suffix[NUM_DIRECTIONS + 1];
189 static struct ConfigInfo empty[1];
192 for (i=0; i<NUM_ACTIONS + 1; i++)
193 action_suffix[i].token = element_action_info[i].suffix;
194 for (i=0; i<NUM_DIRECTIONS + 1; i++)
195 direction_suffix[i].token = element_direction_info[i].suffix;
196 empty[0].token = NULL;
198 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
199 action_suffix, direction_suffix);
200 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
201 action_suffix, empty);
204 void InitLevelArtworkInfo()
206 LoadLevelArtworkInfo();
209 void InitNetworkServer()
211 #if defined(PLATFORM_UNIX)
215 if (!options.network)
218 #if defined(PLATFORM_UNIX)
219 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
221 if (!ConnectToServer(options.server_host, options.server_port))
222 Error(ERR_EXIT, "cannot connect to network game server");
224 SendToServer_PlayerName(setup.player_name);
225 SendToServer_ProtocolVersion();
228 SendToServer_NrWanted(nr_wanted);
232 static void InitMixer()
238 static void ReinitializeGraphics()
240 InitGraphicInfo(); /* initialize graphic info from config file */
242 InitFontInfo(bitmap_font_initial,
243 graphic_info[IMG_FONT_BIG].bitmap,
244 graphic_info[IMG_FONT_MEDIUM].bitmap,
245 graphic_info[IMG_FONT_SMALL].bitmap,
246 graphic_info[IMG_FONT_EM].bitmap);
248 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
249 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
255 static void ReinitializeSounds()
257 InitSoundInfo(); /* initialize sounds info from config file */
260 static void ReinitializeMusic()
262 /* currently nothing to do */
265 static void InitImages()
267 ReloadCustomImages();
268 ReinitializeGraphics();
271 static void InitSound()
273 InitReloadCustomSounds(artwork.snd_current->identifier);
274 ReinitializeSounds();
277 static void InitMusic()
279 InitReloadCustomMusic(artwork.mus_current->identifier);
283 static void InitTileClipmasks()
286 #if defined(TARGET_X11)
287 XGCValues clip_gc_values;
288 unsigned long clip_gc_valuemask;
290 #if defined(TARGET_X11_NATIVE)
300 tile_needs_clipping[] =
302 { GFX_SPIELER1_UP, 4 },
303 { GFX_SPIELER1_DOWN, 4 },
304 { GFX_SPIELER1_LEFT, 4 },
305 { GFX_SPIELER1_RIGHT, 4 },
306 { GFX_SPIELER1_PUSH_LEFT, 4 },
307 { GFX_SPIELER1_PUSH_RIGHT, 4 },
308 { GFX_SPIELER2_UP, 4 },
309 { GFX_SPIELER2_DOWN, 4 },
310 { GFX_SPIELER2_LEFT, 4 },
311 { GFX_SPIELER2_RIGHT, 4 },
312 { GFX_SPIELER2_PUSH_LEFT, 4 },
313 { GFX_SPIELER2_PUSH_RIGHT, 4 },
314 { GFX_SPIELER3_UP, 4 },
315 { GFX_SPIELER3_DOWN, 4 },
316 { GFX_SPIELER3_LEFT, 4 },
317 { GFX_SPIELER3_RIGHT, 4 },
318 { GFX_SPIELER3_PUSH_LEFT, 4 },
319 { GFX_SPIELER3_PUSH_RIGHT, 4 },
320 { GFX_SPIELER4_UP, 4 },
321 { GFX_SPIELER4_DOWN, 4 },
322 { GFX_SPIELER4_LEFT, 4 },
323 { GFX_SPIELER4_RIGHT, 4 },
324 { GFX_SPIELER4_PUSH_LEFT, 4 },
325 { GFX_SPIELER4_PUSH_RIGHT, 4 },
326 { GFX_SP_MURPHY, 1 },
327 { GFX_MURPHY_GO_LEFT, 3 },
328 { GFX_MURPHY_GO_RIGHT, 3 },
329 { GFX_MURPHY_SNAP_UP, 1 },
330 { GFX_MURPHY_SNAP_DOWN, 1 },
331 { GFX_MURPHY_SNAP_RIGHT, 1 },
332 { GFX_MURPHY_SNAP_LEFT, 1 },
333 { GFX_MURPHY_PUSH_RIGHT, 1 },
334 { GFX_MURPHY_PUSH_LEFT, 1 },
335 { GFX_GEBLUBBER, 4 },
338 { GFX_EXPLOSION, 8 },
339 { GFX_SOKOBAN_OBJEKT, 1 },
340 { GFX_FUNKELN_BLAU, 3 },
341 { GFX_FUNKELN_WEISS, 3 },
342 { GFX2_SHIELD_PASSIVE, 3 },
343 { GFX2_SHIELD_ACTIVE, 3 },
348 #endif /* TARGET_X11_NATIVE */
349 #endif /* TARGET_X11 */
353 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
354 for (i=0; i<NUM_TILES; i++)
355 tile_clipmask[i] = None;
357 #if defined(TARGET_X11)
358 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
359 often very slow when preparing a masked XCopyArea() for big Pixmaps.
360 To prevent this, create small (tile-sized) mask Pixmaps which will then
361 be set much faster with XSetClipOrigin() and speed things up a lot. */
363 clip_gc_values.graphics_exposures = False;
364 clip_gc_valuemask = GCGraphicsExposures;
365 tile_clip_gc = XCreateGC(display, window->drawable,
366 clip_gc_valuemask, &clip_gc_values);
369 for (i=0; i<NUM_BITMAPS; i++)
371 if (pix[i]->clip_mask)
373 clip_gc_values.graphics_exposures = False;
374 clip_gc_values.clip_mask = pix[i]->clip_mask;
375 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
376 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
377 clip_gc_valuemask, &clip_gc_values);
382 #if defined(TARGET_X11_NATIVE)
385 /* create graphic context structures needed for clipping */
386 clip_gc_values.graphics_exposures = False;
387 clip_gc_valuemask = GCGraphicsExposures;
388 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
389 clip_gc_valuemask, &clip_gc_values);
391 /* create only those clipping Pixmaps we really need */
392 for (i=0; tile_needs_clipping[i].start>=0; i++)
396 for (j=0; j<tile_needs_clipping[i].count; j++)
398 int tile = tile_needs_clipping[i].start + j;
404 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
405 src_pixmap = src_bitmap->clip_mask;
407 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
410 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
411 src_x, src_y, TILEX, TILEY, 0, 0);
415 XFreeGC(display, copy_clipmask_gc);
418 #endif /* TARGET_X11_NATIVE */
419 #endif /* TARGET_X11 */
423 void FreeTileClipmasks()
426 #if defined(TARGET_X11)
429 for (i=0; i<NUM_TILES; i++)
431 if (tile_clipmask[i] != None)
433 XFreePixmap(display, tile_clipmask[i]);
434 tile_clipmask[i] = None;
439 XFreeGC(display, tile_clip_gc);
443 for (i=0; i<NUM_BITMAPS; i++)
445 if (pix[i] != NULL && pix[i]->stored_clip_gc)
447 XFreeGC(display, pix[i]->stored_clip_gc);
448 pix[i]->stored_clip_gc = None;
453 #endif /* TARGET_X11 */
463 /* initialize screen properties */
464 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
465 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
466 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
467 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
468 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
470 /* create additional image buffers for double-buffering */
471 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
472 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
475 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
477 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
479 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
481 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
484 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
485 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
487 DrawInitText("Loading graphics:", 120, FC_GREEN);
490 for (i=0; i<NUM_PICTURES; i++)
493 if (i != PIX_FONT_SMALL)
496 DrawInitText(image_filename[i], 150, FC_YELLOW);
498 pix[i] = LoadCustomImage(image_filename[i]);
504 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
511 void InitGfxBackground()
516 fieldbuffer = bitmap_db_field;
517 SetDrawtoField(DRAW_BACKBUFFER);
519 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
520 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
521 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
522 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
524 for (x=0; x<MAX_BUF_XSIZE; x++)
525 for (y=0; y<MAX_BUF_YSIZE; y++)
528 redraw_mask = REDRAW_ALL;
531 void ReloadCustomArtwork()
533 static char *leveldir_current_identifier = NULL;
534 static boolean last_override_level_graphics = FALSE;
535 static boolean last_override_level_sounds = FALSE;
536 static boolean last_override_level_music = FALSE;
537 /* identifier for new artwork; default: artwork configured in setup */
538 char *gfx_new_identifier = artwork.gfx_current->identifier;
539 char *snd_new_identifier = artwork.snd_current->identifier;
540 char *mus_new_identifier = artwork.mus_current->identifier;
541 boolean redraw_screen = FALSE;
543 if (leveldir_current_identifier == NULL)
544 leveldir_current_identifier = leveldir_current->identifier;
547 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
548 leveldir_current->graphics_set);
549 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
550 leveldir_current->identifier);
554 printf("graphics --> '%s' ('%s')\n",
555 artwork.gfx_current_identifier, artwork.gfx_current->filename);
556 printf("sounds --> '%s' ('%s')\n",
557 artwork.snd_current_identifier, artwork.snd_current->filename);
558 printf("music --> '%s' ('%s')\n",
559 artwork.mus_current_identifier, artwork.mus_current->filename);
562 /* leveldir_current may be invalid (level group, parent link) */
563 if (!validLevelSeries(leveldir_current))
566 /* when a new level series was selected, check if there was a change
567 in custom artwork stored in level series directory */
568 if (leveldir_current_identifier != leveldir_current->identifier)
570 char *identifier_old = leveldir_current_identifier;
571 char *identifier_new = leveldir_current->identifier;
573 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
574 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
575 gfx_new_identifier = identifier_new;
576 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
577 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
578 snd_new_identifier = identifier_new;
579 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
580 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
581 mus_new_identifier = identifier_new;
583 leveldir_current_identifier = leveldir_current->identifier;
586 /* custom level artwork configured in level series configuration file
587 always overrides custom level artwork stored in level series directory
588 and (level independant) custom artwork configured in setup menue */
589 if (leveldir_current->graphics_set != NULL)
590 gfx_new_identifier = leveldir_current->graphics_set;
591 if (leveldir_current->sounds_set != NULL)
592 snd_new_identifier = leveldir_current->sounds_set;
593 if (leveldir_current->music_set != NULL)
594 mus_new_identifier = leveldir_current->music_set;
596 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
597 last_override_level_graphics != setup.override_level_graphics)
600 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
601 artwork.gfx_current_identifier,
602 artwork.gfx_current->identifier,
606 setLevelArtworkDir(artwork.gfx_first);
608 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
610 ReloadCustomImages();
611 ReinitializeGraphics();
616 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
617 last_override_level_graphics = setup.override_level_graphics;
619 redraw_screen = TRUE;
622 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
623 last_override_level_sounds != setup.override_level_sounds)
626 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
627 artwork.snd_current_identifier,
628 artwork.snd_current->identifier,
632 /* set artwork path to send it to the sound server process */
633 setLevelArtworkDir(artwork.snd_first);
635 InitReloadCustomSounds(snd_new_identifier);
636 ReinitializeSounds();
638 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);
653 artwork.mus_current_identifier = artwork.mus_current->identifier;
654 last_override_level_music = setup.override_level_music;
656 redraw_screen = TRUE;
663 /* force redraw of (open or closed) door graphics */
664 SetDoorState(DOOR_OPEN_ALL);
665 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
671 FreeLevelEditorGadgets();
680 static boolean gadgets_initialized = FALSE;
682 if (gadgets_initialized)
685 CreateLevelEditorGadgets();
689 CreateScreenGadgets();
691 gadgets_initialized = TRUE;
694 void InitElementInfo()
698 /* set values to -1 to identify later as "uninitialized" values */
699 for (i=0; i<MAX_NUM_ELEMENTS; i++)
701 for (act=0; act<NUM_ACTIONS; act++)
703 element_info[i].graphic[act] = -1;
705 for (dir=0; dir<NUM_DIRECTIONS; dir++)
706 element_info[i].direction_graphic[act][dir] = -1;
710 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
711 element_info[i].graphic[ACTION_DEFAULT] =
712 IMG_CHAR_START + (i - EL_CHAR_START);
714 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
715 element_info[i].graphic[ACTION_DEFAULT] =
716 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
719 while (element_to_graphic[i].element > -1)
721 int element = element_to_graphic[i].element;
722 int direction = element_to_graphic[i].direction;
723 int action = element_to_graphic[i].action;
724 int graphic = element_to_graphic[i].graphic;
727 action = ACTION_DEFAULT;
731 direction = MV_DIR_BIT(direction);
733 element_info[element].direction_graphic[action][direction] = graphic;
736 element_info[element].graphic[action] = graphic;
741 /* now set all '-1' values to element specific default values */
742 for (i=0; i<MAX_NUM_ELEMENTS; i++)
744 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
745 int default_action_direction_graphic[NUM_DIRECTIONS];
747 if (default_action_graphic == -1)
748 default_action_graphic = IMG_CHAR_QUESTION;
750 for (dir=0; dir<NUM_DIRECTIONS; dir++)
752 default_action_direction_graphic[dir] =
753 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
755 if (default_action_direction_graphic[dir] == -1)
756 default_action_direction_graphic[dir] = default_action_graphic;
759 for (act=0; act<NUM_ACTIONS; act++)
761 for (dir=0; dir<NUM_DIRECTIONS; dir++)
763 int default_direction_graphic = element_info[i].graphic[act];
765 /* no graphic for current action -- use default direction graphic */
766 if (default_direction_graphic == -1)
767 default_direction_graphic = default_action_direction_graphic[dir];
769 if (element_info[i].direction_graphic[act][dir] == -1)
770 element_info[i].direction_graphic[act][dir] =
771 default_direction_graphic;
774 /* no graphic for this specific action -- use default action graphic */
775 if (element_info[i].graphic[act] == -1)
776 element_info[i].graphic[act] = default_action_graphic;
781 static void set_graphic_parameters(int graphic, int *parameter)
783 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
784 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
785 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
787 graphic_info[graphic].bitmap = src_bitmap;
789 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
790 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
791 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
792 graphic_info[graphic].offset_y = 0;
794 /* animation frames are ordered vertically instead of horizontally */
795 if (parameter[GFX_ARG_VERTICAL])
797 graphic_info[graphic].offset_x = 0;
798 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
801 /* optionally, the x and y offset of frames can be specified directly */
802 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
803 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
804 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
805 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
807 /* automatically determine correct number of frames, if not defined */
808 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
809 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
810 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
811 graphic_info[graphic].anim_frames = num_xtiles;
812 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
813 graphic_info[graphic].anim_frames = num_ytiles;
815 graphic_info[graphic].anim_frames = 1;
817 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
818 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
819 graphic_info[graphic].anim_delay = 1;
821 /* set mode for animation frame order */
822 if (parameter[GFX_ARG_MODE_LOOP])
823 graphic_info[graphic].anim_mode = ANIM_LOOP;
824 else if (parameter[GFX_ARG_MODE_LINEAR])
825 graphic_info[graphic].anim_mode = ANIM_LINEAR;
826 else if (parameter[GFX_ARG_MODE_PINGPONG])
827 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
828 else if (parameter[GFX_ARG_MODE_PINGPONG2])
829 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
830 else if (parameter[GFX_ARG_MODE_RANDOM])
831 graphic_info[graphic].anim_mode = ANIM_RANDOM;
832 else if (graphic_info[graphic].anim_frames > 1)
833 graphic_info[graphic].anim_mode = ANIM_LOOP;
835 graphic_info[graphic].anim_mode = ANIM_NONE;
837 /* set additional flag to play animation frames in reverse order */
838 if (parameter[GFX_ARG_MODE_REVERSE])
839 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
841 /* automatically determine correct start frame, if not defined */
842 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
843 graphic_info[graphic].anim_start_frame = 0;
844 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
845 graphic_info[graphic].anim_start_frame =
846 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
848 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
850 /* animation synchronized with global frame counter, not move position */
851 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
854 static void InitGraphicInfo()
856 static boolean clipmasks_initialized = FALSE;
858 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
860 XGCValues clip_gc_values;
861 unsigned long clip_gc_valuemask;
862 GC copy_clipmask_gc = None;
865 image_files = getCurrentImageList();
867 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
868 if (clipmasks_initialized)
870 for (i=0; i<NUM_IMAGE_FILES; i++)
872 if (graphic_info[i].clip_mask)
873 XFreePixmap(display, graphic_info[i].clip_mask);
874 if (graphic_info[i].clip_gc)
875 XFreeGC(display, graphic_info[i].clip_gc);
877 graphic_info[i].clip_mask = None;
878 graphic_info[i].clip_gc = None;
883 for (i=0; i<NUM_IMAGE_FILES; i++)
887 int first_frame, last_frame;
889 set_graphic_parameters(i, image_files[i].parameter);
891 /* now check if no animation frames are outside of the loaded image */
893 if (graphic_info[i].bitmap == NULL)
894 continue; /* skip check for optional images that are undefined */
897 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
898 if (src_x < 0 || src_y < 0 ||
899 src_x + TILEX > src_bitmap->width ||
900 src_y + TILEY > src_bitmap->height)
902 Error(ERR_RETURN_LINE, "-");
903 Error(ERR_RETURN, "warning: error found in config file:");
904 Error(ERR_RETURN, "- config file: '%s'",
905 getImageConfigFilename());
906 Error(ERR_RETURN, "- config token: '%s'",
907 getTokenFromImageID(i));
908 Error(ERR_RETURN, "- image file: '%s'",
909 src_bitmap->source_filename);
911 "error: first animation frame out of bounds (%d, %d)",
913 Error(ERR_RETURN, "custom graphic rejected for this element/action");
914 Error(ERR_RETURN_LINE, "-");
916 set_graphic_parameters(i, image_files[i].default_parameter);
919 last_frame = graphic_info[i].anim_frames - 1;
920 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
921 if (src_x < 0 || src_y < 0 ||
922 src_x + TILEX > src_bitmap->width ||
923 src_y + TILEY > src_bitmap->height)
925 Error(ERR_RETURN_LINE, "-");
926 Error(ERR_RETURN, "warning: error found in config file:");
927 Error(ERR_RETURN, "- config file: '%s'",
928 getImageConfigFilename());
929 Error(ERR_RETURN, "- config token: '%s'",
930 getTokenFromImageID(i));
931 Error(ERR_RETURN, "- image file: '%s'",
932 src_bitmap->source_filename);
934 "error: last animation frame (%d) out of bounds (%d, %d)",
935 last_frame, src_x, src_y);
936 Error(ERR_RETURN, "custom graphic rejected for this element/action");
937 Error(ERR_RETURN_LINE, "-");
939 set_graphic_parameters(i, image_files[i].default_parameter);
942 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
943 /* currently we need only a tile clip mask from the first frame */
944 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
946 if (copy_clipmask_gc == None)
948 clip_gc_values.graphics_exposures = False;
949 clip_gc_valuemask = GCGraphicsExposures;
950 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
951 clip_gc_valuemask, &clip_gc_values);
954 graphic_info[i].clip_mask =
955 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
957 src_pixmap = src_bitmap->clip_mask;
958 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
959 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
961 clip_gc_values.graphics_exposures = False;
962 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
963 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
964 graphic_info[i].clip_gc =
965 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
969 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
970 if (copy_clipmask_gc)
971 XFreeGC(display, copy_clipmask_gc);
974 clipmasks_initialized = TRUE;
977 static void set_sound_parameters(int sound, int *parameter)
979 /* explicit loop mode setting in configuration overrides default value */
980 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
981 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
984 static void InitSoundInfo()
986 int sound_effect_properties[NUM_SOUND_FILES];
989 sound_files = getCurrentSoundList();
991 /* initialize sound effect for all elements to "no sound" */
992 for (i=0; i<MAX_NUM_ELEMENTS; i++)
993 for (j=0; j<NUM_ACTIONS; j++)
994 element_info[i].sound[j] = SND_UNDEFINED;
996 for (i=0; i<NUM_SOUND_FILES; i++)
998 int len_effect_text = strlen(sound_files[i].token);
1000 sound_effect_properties[i] = ACTION_OTHER;
1001 sound_info[i].loop = FALSE;
1003 /* determine all loop sounds and identify certain sound classes */
1005 for (j=0; element_action_info[j].suffix; j++)
1007 int len_action_text = strlen(element_action_info[j].suffix);
1009 if (len_action_text < len_effect_text &&
1010 strcmp(&sound_files[i].token[len_effect_text - len_action_text],
1011 element_action_info[j].suffix) == 0)
1013 sound_effect_properties[i] = element_action_info[j].value;
1015 if (element_action_info[j].is_loop_sound)
1016 sound_info[i].loop = TRUE;
1020 /* associate elements and some selected sound actions */
1022 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1024 if (element_info[j].sound_class_name)
1026 int len_class_text = strlen(element_info[j].sound_class_name);
1028 if (len_class_text + 1 < len_effect_text &&
1029 strncmp(sound_files[i].token,
1030 element_info[j].sound_class_name, len_class_text) == 0 &&
1031 sound_files[i].token[len_class_text] == '.')
1033 int sound_action_value = sound_effect_properties[i];
1035 element_info[j].sound[sound_action_value] = i;
1040 set_sound_parameters(i, sound_files[i].parameter);
1046 int element = EL_SAND;
1047 int sound_action = ACTION_DIGGING;
1050 while (element_action_info[j].suffix)
1052 if (element_action_info[j].value == sound_action)
1053 printf("element %d, sound action '%s' == %d\n",
1054 element, element_action_info[j].suffix,
1055 element_info_[element].sound[sound_action]);
1062 void InitElementProperties()
1066 static int ep_amoebalive[] =
1073 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1075 static int ep_amoeboid[] =
1083 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1085 static int ep_schluessel[] =
1096 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1098 static int ep_pforte[] =
1117 EL_SWITCHGATE_OPENING,
1118 EL_SWITCHGATE_CLOSED,
1119 EL_SWITCHGATE_CLOSING,
1121 EL_TIMEGATE_OPENING,
1123 EL_TIMEGATE_CLOSING,
1127 EL_TUBE_VERTICAL_LEFT,
1128 EL_TUBE_VERTICAL_RIGHT,
1129 EL_TUBE_HORIZONTAL_UP,
1130 EL_TUBE_HORIZONTAL_DOWN,
1136 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1138 static int ep_solid[] =
1158 EL_QUICKSAND_FILLING,
1159 EL_QUICKSAND_EMPTYING,
1161 EL_MAGIC_WALL_ACTIVE,
1162 EL_MAGIC_WALL_EMPTYING,
1163 EL_MAGIC_WALL_FILLING,
1167 EL_BD_MAGIC_WALL_ACTIVE,
1168 EL_BD_MAGIC_WALL_EMPTYING,
1169 EL_BD_MAGIC_WALL_FULL,
1170 EL_BD_MAGIC_WALL_FILLING,
1171 EL_BD_MAGIC_WALL_DEAD,
1174 EL_ACIDPOOL_TOPLEFT,
1175 EL_ACIDPOOL_TOPRIGHT,
1176 EL_ACIDPOOL_BOTTOMLEFT,
1178 EL_ACIDPOOL_BOTTOMRIGHT,
1196 EL_SP_TERMINAL_ACTIVE,
1199 EL_INVISIBLE_STEELWALL,
1200 EL_INVISIBLE_STEELWALL_ACTIVE,
1202 EL_INVISIBLE_WALL_ACTIVE,
1203 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1204 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1205 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1206 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1207 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1208 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1209 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1210 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1211 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1212 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1213 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1214 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1215 EL_SWITCHGATE_SWITCH_UP,
1216 EL_SWITCHGATE_SWITCH_DOWN,
1218 EL_LIGHT_SWITCH_ACTIVE,
1220 EL_TIMEGATE_SWITCH_ACTIVE,
1221 EL_SIGN_EXCLAMATION,
1222 EL_SIGN_RADIOACTIVITY,
1233 EL_STEELWALL_SLANTED,
1238 EL_EMC_WALL_PILLAR_UPPER,
1239 EL_EMC_WALL_PILLAR_MIDDLE,
1240 EL_EMC_WALL_PILLAR_LOWER,
1266 EL_SWITCHGATE_OPENING,
1267 EL_SWITCHGATE_CLOSED,
1268 EL_SWITCHGATE_CLOSING,
1270 EL_TIMEGATE_OPENING,
1272 EL_TIMEGATE_CLOSING,
1276 EL_TUBE_VERTICAL_LEFT,
1277 EL_TUBE_VERTICAL_RIGHT,
1278 EL_TUBE_HORIZONTAL_UP,
1279 EL_TUBE_HORIZONTAL_DOWN,
1285 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1287 static int ep_massive[] =
1291 EL_ACIDPOOL_TOPLEFT,
1292 EL_ACIDPOOL_TOPRIGHT,
1293 EL_ACIDPOOL_BOTTOMLEFT,
1295 EL_ACIDPOOL_BOTTOMRIGHT,
1307 EL_INVISIBLE_STEELWALL,
1308 EL_INVISIBLE_STEELWALL_ACTIVE,
1309 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1310 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1311 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1312 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1313 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1314 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1315 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1316 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1317 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1318 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1319 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1320 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1322 EL_LIGHT_SWITCH_ACTIVE,
1323 EL_SIGN_EXCLAMATION,
1324 EL_SIGN_RADIOACTIVITY,
1335 EL_STEELWALL_SLANTED,
1358 EL_SWITCHGATE_OPENING,
1359 EL_SWITCHGATE_CLOSED,
1360 EL_SWITCHGATE_CLOSING,
1362 EL_TIMEGATE_OPENING,
1364 EL_TIMEGATE_CLOSING,
1368 EL_TUBE_VERTICAL_LEFT,
1369 EL_TUBE_VERTICAL_RIGHT,
1370 EL_TUBE_HORIZONTAL_UP,
1371 EL_TUBE_HORIZONTAL_DOWN,
1377 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1379 static int ep_slippery[] =
1393 EL_ROBOT_WHEEL_ACTIVE,
1399 EL_ACIDPOOL_TOPLEFT,
1400 EL_ACIDPOOL_TOPRIGHT,
1410 EL_STEELWALL_SLANTED,
1414 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1416 static int ep_enemy[] =
1429 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1431 static int ep_mauer[] =
1459 EL_WALL_GROWING_ACTIVE,
1478 EL_SP_TERMINAL_ACTIVE,
1481 EL_INVISIBLE_STEELWALL,
1482 EL_INVISIBLE_STEELWALL_ACTIVE,
1484 EL_INVISIBLE_WALL_ACTIVE,
1485 EL_STEELWALL_SLANTED,
1490 EL_EMC_WALL_PILLAR_UPPER,
1491 EL_EMC_WALL_PILLAR_MIDDLE,
1492 EL_EMC_WALL_PILLAR_LOWER,
1499 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1501 static int ep_can_fall[] =
1516 EL_BD_MAGIC_WALL_FULL,
1527 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1529 static int ep_can_smash[] =
1560 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1562 static int ep_can_change[] =
1573 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1575 static int ep_can_move[] =
1595 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1597 static int ep_could_move[] =
1607 EL_BD_BUTTERFLY_RIGHT,
1609 EL_BD_BUTTERFLY_LEFT,
1610 EL_BD_BUTTERFLY_DOWN,
1611 EL_BD_FIREFLY_RIGHT,
1620 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1622 static int ep_dont_touch[] =
1629 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1631 static int ep_dont_go_to[] =
1645 EL_SP_BUGGY_BASE_ACTIVE,
1649 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1651 static int ep_mampf2[] =
1676 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1678 static int ep_bd_element[] =
1705 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1707 static int ep_sb_element[] =
1712 EL_SOKOBAN_FIELD_EMPTY,
1713 EL_SOKOBAN_FIELD_FULL,
1715 EL_INVISIBLE_STEELWALL
1717 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1719 static int ep_gem[] =
1728 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1730 static int ep_inactive[] =
1767 EL_INVISIBLE_STEELWALL,
1775 EL_WALL_EMERALD_YELLOW,
1780 EL_SOKOBAN_FIELD_EMPTY,
1781 EL_SOKOBAN_FIELD_FULL,
1782 EL_WALL_EMERALD_RED,
1783 EL_WALL_EMERALD_PURPLE,
1784 EL_ACIDPOOL_TOPLEFT,
1785 EL_ACIDPOOL_TOPRIGHT,
1786 EL_ACIDPOOL_BOTTOMLEFT,
1788 EL_ACIDPOOL_BOTTOMRIGHT,
1792 EL_BD_MAGIC_WALL_DEAD,
1793 EL_AMOEBA_TO_DIAMOND,
1826 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1827 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1828 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1829 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1830 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1831 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1832 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1833 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1834 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1835 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1836 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1837 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1838 EL_SIGN_EXCLAMATION,
1839 EL_SIGN_RADIOACTIVITY,
1850 EL_STEELWALL_SLANTED,
1855 EL_EMC_WALL_PILLAR_UPPER,
1856 EL_EMC_WALL_PILLAR_MIDDLE,
1857 EL_EMC_WALL_PILLAR_LOWER,
1864 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1866 static int ep_explosive[] =
1871 EL_DYNABOMB_PLAYER1_ACTIVE,
1872 EL_DYNABOMB_PLAYER2_ACTIVE,
1873 EL_DYNABOMB_PLAYER3_ACTIVE,
1874 EL_DYNABOMB_PLAYER4_ACTIVE,
1891 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1893 static int ep_mampf3[] =
1904 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1906 static int ep_pushable[] =
1913 EL_SOKOBAN_FIELD_FULL,
1923 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1925 static int ep_player[] =
1932 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1934 static int ep_has_content[] =
1942 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1944 static int ep_eatable[] =
1949 EL_SP_BUGGY_BASE_ACTIVATING,
1952 EL_INVISIBLE_SAND_ACTIVE
1954 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1956 static int ep_sp_element[] =
1999 /* additional elements that appeared in newer Supaplex levels */
2001 /* more than one murphy in a level results in an inactive clone */
2004 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2006 static int ep_quick_gate[] =
2030 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2032 static int ep_over_player[] =
2048 EL_TUBE_VERTICAL_LEFT,
2049 EL_TUBE_VERTICAL_RIGHT,
2050 EL_TUBE_HORIZONTAL_UP,
2051 EL_TUBE_HORIZONTAL_DOWN,
2057 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2059 static int ep_active_bomb[] =
2062 EL_DYNABOMB_PLAYER1_ACTIVE,
2063 EL_DYNABOMB_PLAYER2_ACTIVE,
2064 EL_DYNABOMB_PLAYER3_ACTIVE,
2065 EL_DYNABOMB_PLAYER4_ACTIVE
2067 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2069 static int ep_belt[] =
2071 EL_CONVEYOR_BELT1_LEFT,
2072 EL_CONVEYOR_BELT1_MIDDLE,
2073 EL_CONVEYOR_BELT1_RIGHT,
2074 EL_CONVEYOR_BELT2_LEFT,
2075 EL_CONVEYOR_BELT2_MIDDLE,
2076 EL_CONVEYOR_BELT2_RIGHT,
2077 EL_CONVEYOR_BELT3_LEFT,
2078 EL_CONVEYOR_BELT3_MIDDLE,
2079 EL_CONVEYOR_BELT3_RIGHT,
2080 EL_CONVEYOR_BELT4_LEFT,
2081 EL_CONVEYOR_BELT4_MIDDLE,
2082 EL_CONVEYOR_BELT4_RIGHT,
2084 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2086 static int ep_belt_active[] =
2088 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2089 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2090 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2091 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2092 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2093 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2094 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2095 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2096 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2097 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2098 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2099 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2101 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2103 static int ep_belt_switch[] =
2105 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2106 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2107 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2108 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2109 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2110 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2111 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2112 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2113 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2114 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2115 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2116 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2118 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2120 static int ep_tube[] =
2125 EL_TUBE_VERTICAL_LEFT,
2126 EL_TUBE_VERTICAL_RIGHT,
2127 EL_TUBE_HORIZONTAL_UP,
2128 EL_TUBE_HORIZONTAL_DOWN,
2134 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2136 static long ep1_bit[] =
2170 static long ep2_bit[] =
2177 static int *ep1_array[] =
2211 static int *ep2_array[] =
2218 static int *ep1_num[] =
2245 &ep_has_content_num,
2249 &ep_over_player_num,
2252 static int *ep2_num[] =
2255 &ep_belt_active_num,
2256 &ep_belt_switch_num,
2259 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2260 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2262 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2268 for (i=0; i<num_properties1; i++)
2269 for (j=0; j<*(ep1_num[i]); j++)
2270 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2271 for (i=0; i<num_properties2; i++)
2272 for (j=0; j<*(ep2_num[i]); j++)
2273 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2275 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2276 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2279 void Execute_Command(char *command)
2281 if (strcmp(command, "print graphicsinfo.conf") == 0)
2285 printf("# You can configure additional/alternative image files here.\n");
2286 printf("# (The images below are default and therefore commented out.)\n");
2288 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2290 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2293 for (i=0; image_config[i].token != NULL; i++)
2295 getFormattedSetupEntry(image_config[i].token,
2296 image_config[i].value));
2300 else if (strcmp(command, "print soundsinfo.conf") == 0)
2304 printf("# You can configure additional/alternative sound files here.\n");
2305 printf("# (The sounds below are default and therefore commented out.)\n");
2307 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2309 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2312 for (i=0; sound_config[i].token != NULL; i++)
2314 getFormattedSetupEntry(sound_config[i].token,
2315 sound_config[i].value));
2319 else if (strcmp(command, "print musicinfo.conf") == 0)
2321 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2323 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2325 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2329 else if (strncmp(command, "dump level ", 11) == 0)
2331 char *filename = &command[11];
2333 if (access(filename, F_OK) != 0)
2334 Error(ERR_EXIT, "cannot open file '%s'", filename);
2336 LoadLevelFromFilename(filename);
2341 else if (strncmp(command, "dump tape ", 10) == 0)
2343 char *filename = &command[10];
2345 if (access(filename, F_OK) != 0)
2346 Error(ERR_EXIT, "cannot open file '%s'", filename);
2348 LoadTapeFromFilename(filename);
2353 else if (strncmp(command, "autoplay ", 9) == 0)
2355 char *str_copy = getStringCopy(&command[9]);
2356 char *str_ptr = strchr(str_copy, ' ');
2358 global.autoplay_leveldir = str_copy;
2359 global.autoplay_level_nr = -1;
2361 if (str_ptr != NULL)
2363 *str_ptr++ = '\0'; /* terminate leveldir string */
2364 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2369 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2373 void CloseAllAndExit(int exit_value)
2378 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2381 FreeTileClipmasks();
2383 if (bitmap_font_initial)
2384 FreeBitmap(bitmap_font_initial);
2386 CloseVideoDisplay();
2387 ClosePlatformDependantStuff();