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 InitElementGraphicInfo(void);
77 static void InitElementSoundInfo(void);
78 static void InitGraphicInfo(void);
79 static void InitSoundInfo();
80 static void Execute_Command(char *);
84 InitGlobal(); /* initialize some global variables */
86 if (options.execute_command)
87 Execute_Command(options.execute_command);
89 if (options.serveronly)
91 #if defined(PLATFORM_UNIX)
92 NetworkServer(options.server_port, options.serveronly);
94 Error(ERR_WARN, "networking only supported in Unix version");
96 exit(0); /* never reached */
99 InitProgramInfo(UNIX_USERDATA_DIRECTORY,
100 PROGRAM_TITLE_STRING, getWindowTitleString(),
101 ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
102 MSDOS_POINTER_FILENAME,
103 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
107 InitArtworkInfo(); /* needed before loading gfx, sound & music */
108 InitArtworkConfig(); /* needed before forking sound child process */
114 InitRND(NEW_RANDOMIZE);
117 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
120 InitEventFilter(FilterMouseMotionEvents);
122 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 char *element_prefix[MAX_NUM_ELEMENTS + 1];
188 static char *sound_class_prefix[MAX_NUM_ELEMENTS + 1];
189 static char *action_suffix[NUM_ACTIONS + 1];
190 static char *direction_suffix[NUM_DIRECTIONS + 1];
191 static char *dummy[1] = { NULL };
194 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
195 element_prefix[i] = element_info[i].token_name;
196 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
197 sound_class_prefix[i] = element_info[i].sound_class_name;
198 for (i=0; i<NUM_ACTIONS + 1; i++)
199 action_suffix[i] = element_action_info[i].suffix;
200 for (i=0; i<NUM_DIRECTIONS + 1; i++)
201 direction_suffix[i] = element_direction_info[i].suffix;
203 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
204 element_prefix, action_suffix, direction_suffix);
205 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
206 sound_class_prefix, action_suffix, dummy);
209 void InitLevelArtworkInfo()
211 LoadLevelArtworkInfo();
214 void InitNetworkServer()
216 #if defined(PLATFORM_UNIX)
220 if (!options.network)
223 #if defined(PLATFORM_UNIX)
224 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
226 if (!ConnectToServer(options.server_host, options.server_port))
227 Error(ERR_EXIT, "cannot connect to network game server");
229 SendToServer_PlayerName(setup.player_name);
230 SendToServer_ProtocolVersion();
233 SendToServer_NrWanted(nr_wanted);
237 static void InitMixer()
243 static void ReinitializeGraphics()
245 InitElementGraphicInfo(); /* initialize element/graphic config info */
246 InitGraphicInfo(); /* initialize graphic info from config file */
248 InitFontInfo(bitmap_font_initial,
249 graphic_info[IMG_FONT_BIG].bitmap,
250 graphic_info[IMG_FONT_MEDIUM].bitmap,
251 graphic_info[IMG_FONT_SMALL].bitmap,
252 graphic_info[IMG_FONT_EM].bitmap);
254 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
255 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
261 static void ReinitializeSounds()
263 InitElementSoundInfo(); /* initialize element/sound config info */
264 InitSoundInfo(); /* initialize sounds info from config file */
266 InitPlaySoundLevel(); /* initialize internal game sound values */
269 static void ReinitializeMusic()
271 /* currently nothing to do */
274 static void InitImages()
276 ReloadCustomImages();
277 ReinitializeGraphics();
280 static void InitSound()
282 InitReloadCustomSounds(artwork.snd_current->identifier);
283 ReinitializeSounds();
286 static void InitMusic()
288 InitReloadCustomMusic(artwork.mus_current->identifier);
292 static void InitTileClipmasks()
295 #if defined(TARGET_X11)
296 XGCValues clip_gc_values;
297 unsigned long clip_gc_valuemask;
299 #if defined(TARGET_X11_NATIVE)
309 tile_needs_clipping[] =
311 { GFX_SPIELER1_UP, 4 },
312 { GFX_SPIELER1_DOWN, 4 },
313 { GFX_SPIELER1_LEFT, 4 },
314 { GFX_SPIELER1_RIGHT, 4 },
315 { GFX_SPIELER1_PUSH_LEFT, 4 },
316 { GFX_SPIELER1_PUSH_RIGHT, 4 },
317 { GFX_SPIELER2_UP, 4 },
318 { GFX_SPIELER2_DOWN, 4 },
319 { GFX_SPIELER2_LEFT, 4 },
320 { GFX_SPIELER2_RIGHT, 4 },
321 { GFX_SPIELER2_PUSH_LEFT, 4 },
322 { GFX_SPIELER2_PUSH_RIGHT, 4 },
323 { GFX_SPIELER3_UP, 4 },
324 { GFX_SPIELER3_DOWN, 4 },
325 { GFX_SPIELER3_LEFT, 4 },
326 { GFX_SPIELER3_RIGHT, 4 },
327 { GFX_SPIELER3_PUSH_LEFT, 4 },
328 { GFX_SPIELER3_PUSH_RIGHT, 4 },
329 { GFX_SPIELER4_UP, 4 },
330 { GFX_SPIELER4_DOWN, 4 },
331 { GFX_SPIELER4_LEFT, 4 },
332 { GFX_SPIELER4_RIGHT, 4 },
333 { GFX_SPIELER4_PUSH_LEFT, 4 },
334 { GFX_SPIELER4_PUSH_RIGHT, 4 },
335 { GFX_SP_MURPHY, 1 },
336 { GFX_MURPHY_GO_LEFT, 3 },
337 { GFX_MURPHY_GO_RIGHT, 3 },
338 { GFX_MURPHY_SNAP_UP, 1 },
339 { GFX_MURPHY_SNAP_DOWN, 1 },
340 { GFX_MURPHY_SNAP_RIGHT, 1 },
341 { GFX_MURPHY_SNAP_LEFT, 1 },
342 { GFX_MURPHY_PUSH_RIGHT, 1 },
343 { GFX_MURPHY_PUSH_LEFT, 1 },
344 { GFX_GEBLUBBER, 4 },
347 { GFX_EXPLOSION, 8 },
348 { GFX_SOKOBAN_OBJEKT, 1 },
349 { GFX_FUNKELN_BLAU, 3 },
350 { GFX_FUNKELN_WEISS, 3 },
351 { GFX2_SHIELD_PASSIVE, 3 },
352 { GFX2_SHIELD_ACTIVE, 3 },
357 #endif /* TARGET_X11_NATIVE */
358 #endif /* TARGET_X11 */
362 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
363 for (i=0; i<NUM_TILES; i++)
364 tile_clipmask[i] = None;
366 #if defined(TARGET_X11)
367 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
368 often very slow when preparing a masked XCopyArea() for big Pixmaps.
369 To prevent this, create small (tile-sized) mask Pixmaps which will then
370 be set much faster with XSetClipOrigin() and speed things up a lot. */
372 clip_gc_values.graphics_exposures = False;
373 clip_gc_valuemask = GCGraphicsExposures;
374 tile_clip_gc = XCreateGC(display, window->drawable,
375 clip_gc_valuemask, &clip_gc_values);
378 for (i=0; i<NUM_BITMAPS; i++)
380 if (pix[i]->clip_mask)
382 clip_gc_values.graphics_exposures = False;
383 clip_gc_values.clip_mask = pix[i]->clip_mask;
384 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
385 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
386 clip_gc_valuemask, &clip_gc_values);
391 #if defined(TARGET_X11_NATIVE)
394 /* create graphic context structures needed for clipping */
395 clip_gc_values.graphics_exposures = False;
396 clip_gc_valuemask = GCGraphicsExposures;
397 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
398 clip_gc_valuemask, &clip_gc_values);
400 /* create only those clipping Pixmaps we really need */
401 for (i=0; tile_needs_clipping[i].start>=0; i++)
405 for (j=0; j<tile_needs_clipping[i].count; j++)
407 int tile = tile_needs_clipping[i].start + j;
413 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
414 src_pixmap = src_bitmap->clip_mask;
416 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
419 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
420 src_x, src_y, TILEX, TILEY, 0, 0);
424 XFreeGC(display, copy_clipmask_gc);
427 #endif /* TARGET_X11_NATIVE */
428 #endif /* TARGET_X11 */
432 void FreeTileClipmasks()
435 #if defined(TARGET_X11)
438 for (i=0; i<NUM_TILES; i++)
440 if (tile_clipmask[i] != None)
442 XFreePixmap(display, tile_clipmask[i]);
443 tile_clipmask[i] = None;
448 XFreeGC(display, tile_clip_gc);
452 for (i=0; i<NUM_BITMAPS; i++)
454 if (pix[i] != NULL && pix[i]->stored_clip_gc)
456 XFreeGC(display, pix[i]->stored_clip_gc);
457 pix[i]->stored_clip_gc = None;
462 #endif /* TARGET_X11 */
472 /* initialize screen properties */
473 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
474 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
475 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
476 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
477 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
479 /* create additional image buffers for double-buffering */
480 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
481 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
484 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
486 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
488 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
490 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
493 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
494 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
496 DrawInitText("Loading graphics:", 120, FC_GREEN);
499 for (i=0; i<NUM_PICTURES; i++)
502 if (i != PIX_FONT_SMALL)
505 DrawInitText(image_filename[i], 150, FC_YELLOW);
507 pix[i] = LoadCustomImage(image_filename[i]);
513 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
520 void InitGfxBackground()
525 fieldbuffer = bitmap_db_field;
526 SetDrawtoField(DRAW_BACKBUFFER);
528 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
529 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
530 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
531 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
533 for (x=0; x<MAX_BUF_XSIZE; x++)
534 for (y=0; y<MAX_BUF_YSIZE; y++)
537 redraw_mask = REDRAW_ALL;
540 void ReloadCustomArtwork()
542 static char *leveldir_current_identifier = NULL;
543 static boolean last_override_level_graphics = FALSE;
544 static boolean last_override_level_sounds = FALSE;
545 static boolean last_override_level_music = FALSE;
546 /* identifier for new artwork; default: artwork configured in setup */
547 char *gfx_new_identifier = artwork.gfx_current->identifier;
548 char *snd_new_identifier = artwork.snd_current->identifier;
549 char *mus_new_identifier = artwork.mus_current->identifier;
550 boolean redraw_screen = FALSE;
552 if (leveldir_current_identifier == NULL)
553 leveldir_current_identifier = leveldir_current->identifier;
556 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
557 leveldir_current->graphics_set);
558 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
559 leveldir_current->identifier);
563 printf("graphics --> '%s' ('%s')\n",
564 artwork.gfx_current_identifier, artwork.gfx_current->filename);
565 printf("sounds --> '%s' ('%s')\n",
566 artwork.snd_current_identifier, artwork.snd_current->filename);
567 printf("music --> '%s' ('%s')\n",
568 artwork.mus_current_identifier, artwork.mus_current->filename);
571 /* leveldir_current may be invalid (level group, parent link) */
572 if (!validLevelSeries(leveldir_current))
575 /* when a new level series was selected, check if there was a change
576 in custom artwork stored in level series directory */
577 if (leveldir_current_identifier != leveldir_current->identifier)
579 char *identifier_old = leveldir_current_identifier;
580 char *identifier_new = leveldir_current->identifier;
582 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
583 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
584 gfx_new_identifier = identifier_new;
585 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
586 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
587 snd_new_identifier = identifier_new;
588 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
589 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
590 mus_new_identifier = identifier_new;
592 leveldir_current_identifier = leveldir_current->identifier;
595 /* custom level artwork configured in level series configuration file
596 always overrides custom level artwork stored in level series directory
597 and (level independant) custom artwork configured in setup menue */
598 if (leveldir_current->graphics_set != NULL)
599 gfx_new_identifier = leveldir_current->graphics_set;
600 if (leveldir_current->sounds_set != NULL)
601 snd_new_identifier = leveldir_current->sounds_set;
602 if (leveldir_current->music_set != NULL)
603 mus_new_identifier = leveldir_current->music_set;
605 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
606 last_override_level_graphics != setup.override_level_graphics)
609 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
610 artwork.gfx_current_identifier,
611 artwork.gfx_current->identifier,
615 setLevelArtworkDir(artwork.gfx_first);
617 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
619 ReloadCustomImages();
620 ReinitializeGraphics();
625 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
626 last_override_level_graphics = setup.override_level_graphics;
628 redraw_screen = TRUE;
631 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
632 last_override_level_sounds != setup.override_level_sounds)
635 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
636 artwork.snd_current_identifier,
637 artwork.snd_current->identifier,
641 /* set artwork path to send it to the sound server process */
642 setLevelArtworkDir(artwork.snd_first);
644 InitReloadCustomSounds(snd_new_identifier);
645 ReinitializeSounds();
647 artwork.snd_current_identifier = artwork.snd_current->identifier;
648 last_override_level_sounds = setup.override_level_sounds;
650 redraw_screen = TRUE;
653 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
654 last_override_level_music != setup.override_level_music)
656 /* set artwork path to send it to the sound server process */
657 setLevelArtworkDir(artwork.mus_first);
659 InitReloadCustomMusic(mus_new_identifier);
662 artwork.mus_current_identifier = artwork.mus_current->identifier;
663 last_override_level_music = setup.override_level_music;
665 redraw_screen = TRUE;
672 /* force redraw of (open or closed) door graphics */
673 SetDoorState(DOOR_OPEN_ALL);
674 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
680 FreeLevelEditorGadgets();
689 static boolean gadgets_initialized = FALSE;
691 if (gadgets_initialized)
694 CreateLevelEditorGadgets();
698 CreateScreenGadgets();
700 gadgets_initialized = TRUE;
703 void InitElementGraphicInfo()
705 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
706 int num_property_mappings = getImageListPropertyMappingSize();
709 /* set values to -1 to identify later as "uninitialized" values */
710 for (i=0; i<MAX_NUM_ELEMENTS; i++)
712 for (act=0; act<NUM_ACTIONS; act++)
714 element_info[i].graphic[act] = -1;
716 for (dir=0; dir<NUM_DIRECTIONS; dir++)
717 element_info[i].direction_graphic[act][dir] = -1;
721 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
722 element_info[i].graphic[ACTION_DEFAULT] =
723 IMG_CHAR_START + (i - EL_CHAR_START);
725 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
726 element_info[i].graphic[ACTION_DEFAULT] =
727 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
729 /* initialize element/graphic mapping from static configuration */
730 for (i=0; element_to_graphic[i].element > -1; i++)
732 int element = element_to_graphic[i].element;
733 int action = element_to_graphic[i].action;
734 int direction = element_to_graphic[i].direction;
735 int graphic = element_to_graphic[i].graphic;
738 action = ACTION_DEFAULT;
741 element_info[element].direction_graphic[action][direction] = graphic;
743 element_info[element].graphic[action] = graphic;
746 /* initialize element/graphic mapping from dynamic configuration */
747 for (i=0; i < num_property_mappings; i++)
749 int element = property_mapping[i].base_index;
750 int action = property_mapping[i].ext1_index;
751 int direction = property_mapping[i].ext2_index;
752 int graphic = property_mapping[i].artwork_index;
755 action = ACTION_DEFAULT;
758 element_info[element].direction_graphic[action][direction] = graphic;
760 element_info[element].graphic[action] = graphic;
763 /* now set all '-1' values to element specific default values */
764 for (i=0; i<MAX_NUM_ELEMENTS; i++)
766 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
767 int default_action_direction_graphic[NUM_DIRECTIONS];
769 if (default_action_graphic == -1)
770 default_action_graphic = IMG_CHAR_QUESTION;
772 for (dir=0; dir<NUM_DIRECTIONS; dir++)
774 default_action_direction_graphic[dir] =
775 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
777 if (default_action_direction_graphic[dir] == -1)
778 default_action_direction_graphic[dir] = default_action_graphic;
781 for (act=0; act<NUM_ACTIONS; act++)
783 for (dir=0; dir<NUM_DIRECTIONS; dir++)
785 int default_direction_graphic = element_info[i].graphic[act];
787 /* no graphic for current action -- use default direction graphic */
788 if (default_direction_graphic == -1)
789 default_direction_graphic = default_action_direction_graphic[dir];
791 if (element_info[i].direction_graphic[act][dir] == -1)
792 element_info[i].direction_graphic[act][dir] =
793 default_direction_graphic;
796 /* no graphic for this specific action -- use default action graphic */
797 if (element_info[i].graphic[act] == -1)
798 element_info[i].graphic[act] = default_action_graphic;
803 static void InitElementSoundInfo()
808 static void set_graphic_parameters(int graphic, int *parameter)
810 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
811 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
812 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
814 graphic_info[graphic].bitmap = src_bitmap;
816 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
817 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
818 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
819 graphic_info[graphic].offset_y = 0;
821 /* animation frames are ordered vertically instead of horizontally */
822 if (parameter[GFX_ARG_VERTICAL])
824 graphic_info[graphic].offset_x = 0;
825 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
828 /* optionally, the x and y offset of frames can be specified directly */
829 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
830 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
831 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
832 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
834 /* automatically determine correct number of frames, if not defined */
835 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
836 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
837 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
838 graphic_info[graphic].anim_frames = num_xtiles;
839 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
840 graphic_info[graphic].anim_frames = num_ytiles;
842 graphic_info[graphic].anim_frames = 1;
844 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
845 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
846 graphic_info[graphic].anim_delay = 1;
848 /* set mode for animation frame order */
849 if (parameter[GFX_ARG_MODE_LOOP])
850 graphic_info[graphic].anim_mode = ANIM_LOOP;
851 else if (parameter[GFX_ARG_MODE_LINEAR])
852 graphic_info[graphic].anim_mode = ANIM_LINEAR;
853 else if (parameter[GFX_ARG_MODE_PINGPONG])
854 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
855 else if (parameter[GFX_ARG_MODE_PINGPONG2])
856 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
857 else if (parameter[GFX_ARG_MODE_RANDOM])
858 graphic_info[graphic].anim_mode = ANIM_RANDOM;
859 else if (graphic_info[graphic].anim_frames > 1)
860 graphic_info[graphic].anim_mode = ANIM_LOOP;
862 graphic_info[graphic].anim_mode = ANIM_NONE;
864 /* set additional flag to play animation frames in reverse order */
865 if (parameter[GFX_ARG_MODE_REVERSE])
866 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
868 /* automatically determine correct start frame, if not defined */
869 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
870 graphic_info[graphic].anim_start_frame = 0;
871 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
872 graphic_info[graphic].anim_start_frame =
873 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
875 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
877 /* animation synchronized with global frame counter, not move position */
878 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
881 static void InitGraphicInfo()
883 static boolean clipmasks_initialized = FALSE;
884 int num_images = getImageListSize();
886 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
888 XGCValues clip_gc_values;
889 unsigned long clip_gc_valuemask;
890 GC copy_clipmask_gc = None;
893 if (graphic_info != NULL)
896 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
898 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
899 if (clipmasks_initialized)
901 for (i=0; i<num_images; i++)
903 if (graphic_info[i].clip_mask)
904 XFreePixmap(display, graphic_info[i].clip_mask);
905 if (graphic_info[i].clip_gc)
906 XFreeGC(display, graphic_info[i].clip_gc);
908 graphic_info[i].clip_mask = None;
909 graphic_info[i].clip_gc = None;
914 for (i=0; i<num_images; i++)
916 struct FileInfo *image = getImageListEntry(i);
919 int first_frame, last_frame;
921 set_graphic_parameters(i, image->parameter);
923 /* now check if no animation frames are outside of the loaded image */
925 if (graphic_info[i].bitmap == NULL)
926 continue; /* skip check for optional images that are undefined */
929 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
930 if (src_x < 0 || src_y < 0 ||
931 src_x + TILEX > src_bitmap->width ||
932 src_y + TILEY > src_bitmap->height)
934 Error(ERR_RETURN_LINE, "-");
935 Error(ERR_RETURN, "warning: error found in config file:");
936 Error(ERR_RETURN, "- config file: '%s'",
937 getImageConfigFilename());
938 Error(ERR_RETURN, "- config token: '%s'",
939 getTokenFromImageID(i));
940 Error(ERR_RETURN, "- image file: '%s'",
941 src_bitmap->source_filename);
943 "error: first animation frame out of bounds (%d, %d)",
945 Error(ERR_RETURN, "custom graphic rejected for this element/action");
946 Error(ERR_RETURN_LINE, "-");
948 set_graphic_parameters(i, image->default_parameter);
951 last_frame = graphic_info[i].anim_frames - 1;
952 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
953 if (src_x < 0 || src_y < 0 ||
954 src_x + TILEX > src_bitmap->width ||
955 src_y + TILEY > src_bitmap->height)
957 Error(ERR_RETURN_LINE, "-");
958 Error(ERR_RETURN, "warning: error found in config file:");
959 Error(ERR_RETURN, "- config file: '%s'",
960 getImageConfigFilename());
961 Error(ERR_RETURN, "- config token: '%s'",
962 getTokenFromImageID(i));
963 Error(ERR_RETURN, "- image file: '%s'",
964 src_bitmap->source_filename);
966 "error: last animation frame (%d) out of bounds (%d, %d)",
967 last_frame, src_x, src_y);
968 Error(ERR_RETURN, "custom graphic rejected for this element/action");
969 Error(ERR_RETURN_LINE, "-");
971 set_graphic_parameters(i, image->default_parameter);
974 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
975 /* currently we need only a tile clip mask from the first frame */
976 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
978 if (copy_clipmask_gc == None)
980 clip_gc_values.graphics_exposures = False;
981 clip_gc_valuemask = GCGraphicsExposures;
982 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
983 clip_gc_valuemask, &clip_gc_values);
986 graphic_info[i].clip_mask =
987 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
989 src_pixmap = src_bitmap->clip_mask;
990 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
991 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
993 clip_gc_values.graphics_exposures = False;
994 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
995 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
996 graphic_info[i].clip_gc =
997 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1001 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1002 if (copy_clipmask_gc)
1003 XFreeGC(display, copy_clipmask_gc);
1006 clipmasks_initialized = TRUE;
1009 static void set_sound_parameters(int sound, int *parameter)
1011 /* explicit loop mode setting in configuration overrides default value */
1012 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1013 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1016 static void InitSoundInfo()
1018 int *sound_effect_properties;
1019 int num_sounds = getSoundListSize();
1022 if (sound_info != NULL)
1025 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1026 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1028 /* initialize sound effect for all elements to "no sound" */
1029 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1030 for (j=0; j<NUM_ACTIONS; j++)
1031 element_info[i].sound[j] = SND_UNDEFINED;
1033 for (i=0; i<num_sounds; i++)
1035 struct FileInfo *sound = getSoundListEntry(i);
1036 int len_effect_text = strlen(sound->token);
1038 sound_effect_properties[i] = ACTION_OTHER;
1039 sound_info[i].loop = FALSE;
1041 /* determine all loop sounds and identify certain sound classes */
1043 for (j=0; element_action_info[j].suffix; j++)
1045 int len_action_text = strlen(element_action_info[j].suffix);
1047 if (len_action_text < len_effect_text &&
1048 strcmp(&sound->token[len_effect_text - len_action_text],
1049 element_action_info[j].suffix) == 0)
1051 sound_effect_properties[i] = element_action_info[j].value;
1053 if (element_action_info[j].is_loop_sound)
1054 sound_info[i].loop = TRUE;
1058 /* associate elements and some selected sound actions */
1060 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1062 if (element_info[j].sound_class_name)
1064 int len_class_text = strlen(element_info[j].sound_class_name);
1066 if (len_class_text + 1 < len_effect_text &&
1067 strncmp(sound->token,
1068 element_info[j].sound_class_name, len_class_text) == 0 &&
1069 sound->token[len_class_text] == '.')
1071 int sound_action_value = sound_effect_properties[i];
1073 element_info[j].sound[sound_action_value] = i;
1078 set_sound_parameters(i, sound->parameter);
1081 free(sound_effect_properties);
1086 int element = EL_SAND;
1087 int sound_action = ACTION_DIGGING;
1090 while (element_action_info[j].suffix)
1092 if (element_action_info[j].value == sound_action)
1093 printf("element %d, sound action '%s' == %d\n",
1094 element, element_action_info[j].suffix,
1095 element_info_[element].sound[sound_action]);
1102 void InitElementProperties()
1106 static int ep_amoebalive[] =
1113 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1115 static int ep_amoeboid[] =
1123 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1125 static int ep_schluessel[] =
1136 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1138 static int ep_pforte[] =
1157 EL_SWITCHGATE_OPENING,
1158 EL_SWITCHGATE_CLOSED,
1159 EL_SWITCHGATE_CLOSING,
1161 EL_TIMEGATE_OPENING,
1163 EL_TIMEGATE_CLOSING,
1167 EL_TUBE_VERTICAL_LEFT,
1168 EL_TUBE_VERTICAL_RIGHT,
1169 EL_TUBE_HORIZONTAL_UP,
1170 EL_TUBE_HORIZONTAL_DOWN,
1176 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1178 static int ep_solid[] =
1198 EL_QUICKSAND_FILLING,
1199 EL_QUICKSAND_EMPTYING,
1201 EL_MAGIC_WALL_ACTIVE,
1202 EL_MAGIC_WALL_EMPTYING,
1203 EL_MAGIC_WALL_FILLING,
1207 EL_BD_MAGIC_WALL_ACTIVE,
1208 EL_BD_MAGIC_WALL_EMPTYING,
1209 EL_BD_MAGIC_WALL_FULL,
1210 EL_BD_MAGIC_WALL_FILLING,
1211 EL_BD_MAGIC_WALL_DEAD,
1214 EL_ACIDPOOL_TOPLEFT,
1215 EL_ACIDPOOL_TOPRIGHT,
1216 EL_ACIDPOOL_BOTTOMLEFT,
1218 EL_ACIDPOOL_BOTTOMRIGHT,
1236 EL_SP_TERMINAL_ACTIVE,
1239 EL_INVISIBLE_STEELWALL,
1240 EL_INVISIBLE_STEELWALL_ACTIVE,
1242 EL_INVISIBLE_WALL_ACTIVE,
1243 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1244 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1245 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1246 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1247 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1248 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1249 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1250 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1251 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1252 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1253 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1254 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1255 EL_SWITCHGATE_SWITCH_UP,
1256 EL_SWITCHGATE_SWITCH_DOWN,
1258 EL_LIGHT_SWITCH_ACTIVE,
1260 EL_TIMEGATE_SWITCH_ACTIVE,
1261 EL_SIGN_EXCLAMATION,
1262 EL_SIGN_RADIOACTIVITY,
1273 EL_STEELWALL_SLANTED,
1278 EL_EMC_WALL_PILLAR_UPPER,
1279 EL_EMC_WALL_PILLAR_MIDDLE,
1280 EL_EMC_WALL_PILLAR_LOWER,
1306 EL_SWITCHGATE_OPENING,
1307 EL_SWITCHGATE_CLOSED,
1308 EL_SWITCHGATE_CLOSING,
1310 EL_TIMEGATE_OPENING,
1312 EL_TIMEGATE_CLOSING,
1316 EL_TUBE_VERTICAL_LEFT,
1317 EL_TUBE_VERTICAL_RIGHT,
1318 EL_TUBE_HORIZONTAL_UP,
1319 EL_TUBE_HORIZONTAL_DOWN,
1325 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1327 static int ep_massive[] =
1331 EL_ACIDPOOL_TOPLEFT,
1332 EL_ACIDPOOL_TOPRIGHT,
1333 EL_ACIDPOOL_BOTTOMLEFT,
1335 EL_ACIDPOOL_BOTTOMRIGHT,
1347 EL_INVISIBLE_STEELWALL,
1348 EL_INVISIBLE_STEELWALL_ACTIVE,
1349 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1350 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1351 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1352 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1353 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1354 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1355 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1356 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1357 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1358 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1359 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1360 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1362 EL_LIGHT_SWITCH_ACTIVE,
1363 EL_SIGN_EXCLAMATION,
1364 EL_SIGN_RADIOACTIVITY,
1375 EL_STEELWALL_SLANTED,
1398 EL_SWITCHGATE_OPENING,
1399 EL_SWITCHGATE_CLOSED,
1400 EL_SWITCHGATE_CLOSING,
1402 EL_TIMEGATE_OPENING,
1404 EL_TIMEGATE_CLOSING,
1408 EL_TUBE_VERTICAL_LEFT,
1409 EL_TUBE_VERTICAL_RIGHT,
1410 EL_TUBE_HORIZONTAL_UP,
1411 EL_TUBE_HORIZONTAL_DOWN,
1417 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1419 static int ep_slippery[] =
1433 EL_ROBOT_WHEEL_ACTIVE,
1439 EL_ACIDPOOL_TOPLEFT,
1440 EL_ACIDPOOL_TOPRIGHT,
1450 EL_STEELWALL_SLANTED,
1454 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1456 static int ep_enemy[] =
1469 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1471 static int ep_mauer[] =
1499 EL_WALL_GROWING_ACTIVE,
1518 EL_SP_TERMINAL_ACTIVE,
1521 EL_INVISIBLE_STEELWALL,
1522 EL_INVISIBLE_STEELWALL_ACTIVE,
1524 EL_INVISIBLE_WALL_ACTIVE,
1525 EL_STEELWALL_SLANTED,
1530 EL_EMC_WALL_PILLAR_UPPER,
1531 EL_EMC_WALL_PILLAR_MIDDLE,
1532 EL_EMC_WALL_PILLAR_LOWER,
1539 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1541 static int ep_can_fall[] =
1556 EL_BD_MAGIC_WALL_FULL,
1567 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1569 static int ep_can_smash[] =
1600 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1602 static int ep_can_change[] =
1613 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1615 static int ep_can_move[] =
1635 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1637 static int ep_could_move[] =
1647 EL_BD_BUTTERFLY_RIGHT,
1649 EL_BD_BUTTERFLY_LEFT,
1650 EL_BD_BUTTERFLY_DOWN,
1651 EL_BD_FIREFLY_RIGHT,
1660 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1662 static int ep_dont_touch[] =
1669 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1671 static int ep_dont_go_to[] =
1685 EL_SP_BUGGY_BASE_ACTIVE,
1689 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1691 static int ep_mampf2[] =
1716 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1718 static int ep_bd_element[] =
1745 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1747 static int ep_sb_element[] =
1752 EL_SOKOBAN_FIELD_EMPTY,
1753 EL_SOKOBAN_FIELD_FULL,
1755 EL_INVISIBLE_STEELWALL
1757 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1759 static int ep_gem[] =
1768 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1770 static int ep_inactive[] =
1807 EL_INVISIBLE_STEELWALL,
1815 EL_WALL_EMERALD_YELLOW,
1820 EL_SOKOBAN_FIELD_EMPTY,
1821 EL_SOKOBAN_FIELD_FULL,
1822 EL_WALL_EMERALD_RED,
1823 EL_WALL_EMERALD_PURPLE,
1824 EL_ACIDPOOL_TOPLEFT,
1825 EL_ACIDPOOL_TOPRIGHT,
1826 EL_ACIDPOOL_BOTTOMLEFT,
1828 EL_ACIDPOOL_BOTTOMRIGHT,
1832 EL_BD_MAGIC_WALL_DEAD,
1833 EL_AMOEBA_TO_DIAMOND,
1866 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1867 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1868 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1869 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1870 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1871 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1872 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1873 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1874 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1875 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1876 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1877 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1878 EL_SIGN_EXCLAMATION,
1879 EL_SIGN_RADIOACTIVITY,
1890 EL_STEELWALL_SLANTED,
1895 EL_EMC_WALL_PILLAR_UPPER,
1896 EL_EMC_WALL_PILLAR_MIDDLE,
1897 EL_EMC_WALL_PILLAR_LOWER,
1904 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1906 static int ep_explosive[] =
1911 EL_DYNABOMB_PLAYER1_ACTIVE,
1912 EL_DYNABOMB_PLAYER2_ACTIVE,
1913 EL_DYNABOMB_PLAYER3_ACTIVE,
1914 EL_DYNABOMB_PLAYER4_ACTIVE,
1931 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1933 static int ep_mampf3[] =
1944 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1946 static int ep_pushable[] =
1953 EL_SOKOBAN_FIELD_FULL,
1963 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1965 static int ep_player[] =
1972 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1974 static int ep_has_content[] =
1982 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1984 static int ep_eatable[] =
1989 EL_SP_BUGGY_BASE_ACTIVATING,
1992 EL_INVISIBLE_SAND_ACTIVE
1994 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1996 static int ep_sp_element[] =
2039 /* additional elements that appeared in newer Supaplex levels */
2041 /* more than one murphy in a level results in an inactive clone */
2044 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2046 static int ep_quick_gate[] =
2070 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2072 static int ep_over_player[] =
2088 EL_TUBE_VERTICAL_LEFT,
2089 EL_TUBE_VERTICAL_RIGHT,
2090 EL_TUBE_HORIZONTAL_UP,
2091 EL_TUBE_HORIZONTAL_DOWN,
2097 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2099 static int ep_active_bomb[] =
2102 EL_DYNABOMB_PLAYER1_ACTIVE,
2103 EL_DYNABOMB_PLAYER2_ACTIVE,
2104 EL_DYNABOMB_PLAYER3_ACTIVE,
2105 EL_DYNABOMB_PLAYER4_ACTIVE
2107 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2109 static int ep_belt[] =
2111 EL_CONVEYOR_BELT1_LEFT,
2112 EL_CONVEYOR_BELT1_MIDDLE,
2113 EL_CONVEYOR_BELT1_RIGHT,
2114 EL_CONVEYOR_BELT2_LEFT,
2115 EL_CONVEYOR_BELT2_MIDDLE,
2116 EL_CONVEYOR_BELT2_RIGHT,
2117 EL_CONVEYOR_BELT3_LEFT,
2118 EL_CONVEYOR_BELT3_MIDDLE,
2119 EL_CONVEYOR_BELT3_RIGHT,
2120 EL_CONVEYOR_BELT4_LEFT,
2121 EL_CONVEYOR_BELT4_MIDDLE,
2122 EL_CONVEYOR_BELT4_RIGHT,
2124 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2126 static int ep_belt_active[] =
2128 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2129 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2130 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2131 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2132 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2133 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2134 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2135 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2136 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2137 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2138 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2139 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2141 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2143 static int ep_belt_switch[] =
2145 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2146 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2147 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2148 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2149 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2150 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2151 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2152 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2153 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2154 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2155 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2156 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2158 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2160 static int ep_tube[] =
2165 EL_TUBE_VERTICAL_LEFT,
2166 EL_TUBE_VERTICAL_RIGHT,
2167 EL_TUBE_HORIZONTAL_UP,
2168 EL_TUBE_HORIZONTAL_DOWN,
2174 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2176 static long ep1_bit[] =
2210 static long ep2_bit[] =
2217 static int *ep1_array[] =
2251 static int *ep2_array[] =
2258 static int *ep1_num[] =
2285 &ep_has_content_num,
2289 &ep_over_player_num,
2292 static int *ep2_num[] =
2295 &ep_belt_active_num,
2296 &ep_belt_switch_num,
2299 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2300 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2302 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2308 for (i=0; i<num_properties1; i++)
2309 for (j=0; j<*(ep1_num[i]); j++)
2310 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2311 for (i=0; i<num_properties2; i++)
2312 for (j=0; j<*(ep2_num[i]); j++)
2313 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2315 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2316 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2319 void Execute_Command(char *command)
2321 if (strcmp(command, "print graphicsinfo.conf") == 0)
2325 printf("# You can configure additional/alternative image files here.\n");
2326 printf("# (The images below are default and therefore commented out.)\n");
2328 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2330 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2333 for (i=0; image_config[i].token != NULL; i++)
2335 getFormattedSetupEntry(image_config[i].token,
2336 image_config[i].value));
2340 else if (strcmp(command, "print soundsinfo.conf") == 0)
2344 printf("# You can configure additional/alternative sound files here.\n");
2345 printf("# (The sounds below are default and therefore commented out.)\n");
2347 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2349 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2352 for (i=0; sound_config[i].token != NULL; i++)
2354 getFormattedSetupEntry(sound_config[i].token,
2355 sound_config[i].value));
2359 else if (strcmp(command, "print musicinfo.conf") == 0)
2361 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2363 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2365 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2369 else if (strncmp(command, "dump level ", 11) == 0)
2371 char *filename = &command[11];
2373 if (access(filename, F_OK) != 0)
2374 Error(ERR_EXIT, "cannot open file '%s'", filename);
2376 LoadLevelFromFilename(filename);
2381 else if (strncmp(command, "dump tape ", 10) == 0)
2383 char *filename = &command[10];
2385 if (access(filename, F_OK) != 0)
2386 Error(ERR_EXIT, "cannot open file '%s'", filename);
2388 LoadTapeFromFilename(filename);
2393 else if (strncmp(command, "autoplay ", 9) == 0)
2395 char *str_copy = getStringCopy(&command[9]);
2396 char *str_ptr = strchr(str_copy, ' ');
2398 global.autoplay_leveldir = str_copy;
2399 global.autoplay_level_nr = -1;
2401 if (str_ptr != NULL)
2403 *str_ptr++ = '\0'; /* terminate leveldir string */
2404 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2409 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2413 void CloseAllAndExit(int exit_value)
2418 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2421 FreeTileClipmasks();
2423 if (bitmap_font_initial)
2424 FreeBitmap(bitmap_font_initial);
2426 CloseVideoDisplay();
2427 ClosePlatformDependantStuff();