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();
61 static void InitSetup();
62 static void InitPlayerInfo();
63 static void InitLevelInfo();
64 static void InitArtworkInfo();
65 static void InitLevelArtworkInfo();
66 static void InitNetworkServer();
67 static void InitArtworkConfig();
68 static void InitImages();
69 static void InitMixer();
70 static void InitSound();
71 static void InitMusic();
72 static void InitGfx();
73 static void InitGfxBackground();
74 static void InitGadgets();
75 static void InitElementImages();
76 static void InitElementGraphicInfo();
77 static void InitElementEditorGraphicInfo();
78 static void InitElementSoundInfo();
79 static void InitElementProperties();
80 static void InitGraphicInfo();
81 static void InitSoundInfo();
82 static void Execute_Command(char *);
86 InitGlobal(); /* initialize some global variables */
88 if (options.execute_command)
89 Execute_Command(options.execute_command);
91 if (options.serveronly)
93 #if defined(PLATFORM_UNIX)
94 NetworkServer(options.server_port, options.serveronly);
96 Error(ERR_WARN, "networking only supported in Unix version");
98 exit(0); /* never reached */
101 InitProgramInfo(UNIX_USERDATA_DIRECTORY,
102 PROGRAM_TITLE_STRING, getWindowTitleString(),
103 ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
104 MSDOS_POINTER_FILENAME,
105 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
109 InitArtworkInfo(); /* needed before loading gfx, sound & music */
110 InitArtworkConfig(); /* needed before forking sound child process */
116 InitRND(NEW_RANDOMIZE);
119 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
122 InitEventFilter(FilterMouseMotionEvents);
124 InitElementProperties();
129 InitLevelArtworkInfo();
131 InitImages(); /* needs to know current level directory */
132 InitSound(); /* needs to know current level directory */
133 InitMusic(); /* needs to know current level directory */
137 if (global.autoplay_leveldir)
148 static void InitGlobal()
150 global.autoplay_leveldir = NULL;
152 global.frames_per_second = 0;
153 global.fps_slowdown = FALSE;
154 global.fps_slowdown_factor = 1;
157 static void InitSetup()
159 LoadSetup(); /* global setup info */
162 static void InitPlayerInfo()
166 /* choose default local player */
167 local_player = &stored_player[0];
169 for (i=0; i<MAX_PLAYERS; i++)
170 stored_player[i].connected = FALSE;
172 local_player->connected = TRUE;
175 static void InitLevelInfo()
177 LoadLevelInfo(); /* global level info */
178 LoadLevelSetup_LastSeries(); /* last played series info */
179 LoadLevelSetup_SeriesInfo(); /* last played level info */
182 static void InitArtworkInfo()
187 static void InitArtworkConfig()
189 static char *element_prefix[MAX_NUM_ELEMENTS + 1];
190 static char *sound_class_prefix[MAX_NUM_ELEMENTS + 1];
191 static char *action_suffix[NUM_ACTIONS + 1];
192 static char *direction_suffix[NUM_DIRECTIONS + 1];
193 static char *special_suffix[NUM_SPECIAL_GFX_ARGS + 1];
194 static char *dummy[1] = { NULL };
197 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
198 element_prefix[i] = element_info[i].token_name;
199 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
200 sound_class_prefix[i] = element_info[i].sound_class_name;
201 for (i=0; i<NUM_ACTIONS + 1; i++)
202 action_suffix[i] = element_action_info[i].suffix;
203 for (i=0; i<NUM_DIRECTIONS + 1; i++)
204 direction_suffix[i] = element_direction_info[i].suffix;
205 for (i=0; i<NUM_SPECIAL_GFX_ARGS + 1; i++)
206 special_suffix[i] = special_suffix_info[i].suffix;
208 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
209 element_prefix, action_suffix,direction_suffix,special_suffix);
210 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
211 sound_class_prefix, action_suffix, dummy, dummy);
214 void InitLevelArtworkInfo()
216 LoadLevelArtworkInfo();
219 void InitNetworkServer()
221 #if defined(PLATFORM_UNIX)
225 if (!options.network)
228 #if defined(PLATFORM_UNIX)
229 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
231 if (!ConnectToServer(options.server_host, options.server_port))
232 Error(ERR_EXIT, "cannot connect to network game server");
234 SendToServer_PlayerName(setup.player_name);
235 SendToServer_ProtocolVersion();
238 SendToServer_NrWanted(nr_wanted);
242 static void InitMixer()
248 static void ReinitializeGraphics()
250 InitElementGraphicInfo(); /* element => game graphic mapping */
251 InitElementEditorGraphicInfo(); /* element => editor graphic mapping */
252 InitGraphicInfo(); /* graphic => properties mapping */
254 InitFontInfo(bitmap_font_initial,
255 graphic_info[IMG_FONT_BIG].bitmap,
256 graphic_info[IMG_FONT_MEDIUM].bitmap,
257 graphic_info[IMG_FONT_SMALL].bitmap,
258 graphic_info[IMG_FONT_EM].bitmap);
260 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
261 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
268 /* !!! TEST ONLY !!! */
271 Bitmap *tst_bitmap = graphic_info[IMG_SAND].bitmap;
272 Bitmap *tmp_bitmap = ZoomBitmap(tst_bitmap,
273 tst_bitmap->width / 2,
274 tst_bitmap->height / 2);
276 BlitBitmap(tmp_bitmap, tst_bitmap, 0, 0, 256, 224, 0, 448);
278 FreeBitmap(tmp_bitmap);
283 printf("CREATING SMALL IMAGES...\n");
288 CreateImageWithSmallImages(IMG_SAND);
289 CreateImageWithSmallImages(IMG_SAND);
296 static void ReinitializeSounds()
298 InitElementSoundInfo(); /* element => game sound mapping */
299 InitSoundInfo(); /* sound => properties mapping */
301 InitPlaySoundLevel(); /* internal game sound settings */
304 static void ReinitializeMusic()
306 /* currently nothing to do */
309 static void InitImages()
311 ReloadCustomImages();
312 ReinitializeGraphics();
314 LoadCustomElementDescriptions();
317 static void InitSound()
319 InitReloadCustomSounds(artwork.snd_current->identifier);
320 ReinitializeSounds();
323 static void InitMusic()
325 InitReloadCustomMusic(artwork.mus_current->identifier);
329 static void InitTileClipmasks()
332 #if defined(TARGET_X11)
333 XGCValues clip_gc_values;
334 unsigned long clip_gc_valuemask;
336 #if defined(TARGET_X11_NATIVE)
346 tile_needs_clipping[] =
348 { GFX_SPIELER1_UP, 4 },
349 { GFX_SPIELER1_DOWN, 4 },
350 { GFX_SPIELER1_LEFT, 4 },
351 { GFX_SPIELER1_RIGHT, 4 },
352 { GFX_SPIELER1_PUSH_LEFT, 4 },
353 { GFX_SPIELER1_PUSH_RIGHT, 4 },
354 { GFX_SPIELER2_UP, 4 },
355 { GFX_SPIELER2_DOWN, 4 },
356 { GFX_SPIELER2_LEFT, 4 },
357 { GFX_SPIELER2_RIGHT, 4 },
358 { GFX_SPIELER2_PUSH_LEFT, 4 },
359 { GFX_SPIELER2_PUSH_RIGHT, 4 },
360 { GFX_SPIELER3_UP, 4 },
361 { GFX_SPIELER3_DOWN, 4 },
362 { GFX_SPIELER3_LEFT, 4 },
363 { GFX_SPIELER3_RIGHT, 4 },
364 { GFX_SPIELER3_PUSH_LEFT, 4 },
365 { GFX_SPIELER3_PUSH_RIGHT, 4 },
366 { GFX_SPIELER4_UP, 4 },
367 { GFX_SPIELER4_DOWN, 4 },
368 { GFX_SPIELER4_LEFT, 4 },
369 { GFX_SPIELER4_RIGHT, 4 },
370 { GFX_SPIELER4_PUSH_LEFT, 4 },
371 { GFX_SPIELER4_PUSH_RIGHT, 4 },
372 { GFX_SP_MURPHY, 1 },
373 { GFX_MURPHY_GO_LEFT, 3 },
374 { GFX_MURPHY_GO_RIGHT, 3 },
375 { GFX_MURPHY_SNAP_UP, 1 },
376 { GFX_MURPHY_SNAP_DOWN, 1 },
377 { GFX_MURPHY_SNAP_RIGHT, 1 },
378 { GFX_MURPHY_SNAP_LEFT, 1 },
379 { GFX_MURPHY_PUSH_RIGHT, 1 },
380 { GFX_MURPHY_PUSH_LEFT, 1 },
381 { GFX_GEBLUBBER, 4 },
384 { GFX_EXPLOSION, 8 },
385 { GFX_SOKOBAN_OBJEKT, 1 },
386 { GFX_FUNKELN_BLAU, 3 },
387 { GFX_FUNKELN_WEISS, 3 },
388 { GFX2_SHIELD_PASSIVE, 3 },
389 { GFX2_SHIELD_ACTIVE, 3 },
394 #endif /* TARGET_X11_NATIVE */
395 #endif /* TARGET_X11 */
399 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
400 for (i=0; i<NUM_TILES; i++)
401 tile_clipmask[i] = None;
403 #if defined(TARGET_X11)
404 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
405 often very slow when preparing a masked XCopyArea() for big Pixmaps.
406 To prevent this, create small (tile-sized) mask Pixmaps which will then
407 be set much faster with XSetClipOrigin() and speed things up a lot. */
409 clip_gc_values.graphics_exposures = False;
410 clip_gc_valuemask = GCGraphicsExposures;
411 tile_clip_gc = XCreateGC(display, window->drawable,
412 clip_gc_valuemask, &clip_gc_values);
415 for (i=0; i<NUM_BITMAPS; i++)
417 if (pix[i]->clip_mask)
419 clip_gc_values.graphics_exposures = False;
420 clip_gc_values.clip_mask = pix[i]->clip_mask;
421 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
422 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
423 clip_gc_valuemask, &clip_gc_values);
428 #if defined(TARGET_X11_NATIVE)
431 /* create graphic context structures needed for clipping */
432 clip_gc_values.graphics_exposures = False;
433 clip_gc_valuemask = GCGraphicsExposures;
434 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
435 clip_gc_valuemask, &clip_gc_values);
437 /* create only those clipping Pixmaps we really need */
438 for (i=0; tile_needs_clipping[i].start>=0; i++)
442 for (j=0; j<tile_needs_clipping[i].count; j++)
444 int tile = tile_needs_clipping[i].start + j;
450 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
451 src_pixmap = src_bitmap->clip_mask;
453 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
456 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
457 src_x, src_y, TILEX, TILEY, 0, 0);
461 XFreeGC(display, copy_clipmask_gc);
464 #endif /* TARGET_X11_NATIVE */
465 #endif /* TARGET_X11 */
469 void FreeTileClipmasks()
472 #if defined(TARGET_X11)
475 for (i=0; i<NUM_TILES; i++)
477 if (tile_clipmask[i] != None)
479 XFreePixmap(display, tile_clipmask[i]);
480 tile_clipmask[i] = None;
485 XFreeGC(display, tile_clip_gc);
489 for (i=0; i<NUM_BITMAPS; i++)
491 if (pix[i] != NULL && pix[i]->stored_clip_gc)
493 XFreeGC(display, pix[i]->stored_clip_gc);
494 pix[i]->stored_clip_gc = None;
499 #endif /* TARGET_X11 */
509 /* initialize screen properties */
510 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
511 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
512 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
513 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
514 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
516 /* create additional image buffers for double-buffering */
517 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
518 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
521 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
523 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
525 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
527 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
530 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
531 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
533 DrawInitText("Loading graphics:", 120, FC_GREEN);
536 for (i=0; i<NUM_PICTURES; i++)
539 if (i != PIX_FONT_SMALL)
542 DrawInitText(image_filename[i], 150, FC_YELLOW);
544 pix[i] = LoadCustomImage(image_filename[i]);
550 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
557 void InitGfxBackground()
562 fieldbuffer = bitmap_db_field;
563 SetDrawtoField(DRAW_BACKBUFFER);
565 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
566 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
567 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
568 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
570 for (x=0; x<MAX_BUF_XSIZE; x++)
571 for (y=0; y<MAX_BUF_YSIZE; y++)
574 redraw_mask = REDRAW_ALL;
577 void ReloadCustomArtwork()
579 static char *leveldir_current_identifier = NULL;
580 static boolean last_override_level_graphics = FALSE;
581 static boolean last_override_level_sounds = FALSE;
582 static boolean last_override_level_music = FALSE;
583 /* identifier for new artwork; default: artwork configured in setup */
584 char *gfx_new_identifier = artwork.gfx_current->identifier;
585 char *snd_new_identifier = artwork.snd_current->identifier;
586 char *mus_new_identifier = artwork.mus_current->identifier;
587 boolean redraw_screen = FALSE;
589 if (leveldir_current_identifier == NULL)
590 leveldir_current_identifier = leveldir_current->identifier;
593 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
594 leveldir_current->graphics_set);
595 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
596 leveldir_current->identifier);
600 printf("graphics --> '%s' ('%s')\n",
601 artwork.gfx_current_identifier, artwork.gfx_current->filename);
602 printf("sounds --> '%s' ('%s')\n",
603 artwork.snd_current_identifier, artwork.snd_current->filename);
604 printf("music --> '%s' ('%s')\n",
605 artwork.mus_current_identifier, artwork.mus_current->filename);
608 /* leveldir_current may be invalid (level group, parent link) */
609 if (!validLevelSeries(leveldir_current))
612 /* when a new level series was selected, check if there was a change
613 in custom artwork stored in level series directory */
614 if (leveldir_current_identifier != leveldir_current->identifier)
616 char *identifier_old = leveldir_current_identifier;
617 char *identifier_new = leveldir_current->identifier;
619 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
620 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
621 gfx_new_identifier = identifier_new;
622 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
623 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
624 snd_new_identifier = identifier_new;
625 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
626 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
627 mus_new_identifier = identifier_new;
629 leveldir_current_identifier = leveldir_current->identifier;
632 /* custom level artwork configured in level series configuration file
633 always overrides custom level artwork stored in level series directory
634 and (level independant) custom artwork configured in setup menue */
635 if (leveldir_current->graphics_set != NULL)
636 gfx_new_identifier = leveldir_current->graphics_set;
637 if (leveldir_current->sounds_set != NULL)
638 snd_new_identifier = leveldir_current->sounds_set;
639 if (leveldir_current->music_set != NULL)
640 mus_new_identifier = leveldir_current->music_set;
642 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
643 last_override_level_graphics != setup.override_level_graphics)
646 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
647 artwork.gfx_current_identifier,
648 artwork.gfx_current->identifier,
652 setLevelArtworkDir(artwork.gfx_first);
654 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
656 ReloadCustomImages();
657 ReinitializeGraphics();
659 LoadCustomElementDescriptions();
664 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
665 last_override_level_graphics = setup.override_level_graphics;
667 redraw_screen = TRUE;
670 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
671 last_override_level_sounds != setup.override_level_sounds)
674 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
675 artwork.snd_current_identifier,
676 artwork.snd_current->identifier,
680 /* set artwork path to send it to the sound server process */
681 setLevelArtworkDir(artwork.snd_first);
683 InitReloadCustomSounds(snd_new_identifier);
684 ReinitializeSounds();
686 artwork.snd_current_identifier = artwork.snd_current->identifier;
687 last_override_level_sounds = setup.override_level_sounds;
689 redraw_screen = TRUE;
692 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
693 last_override_level_music != setup.override_level_music)
695 /* set artwork path to send it to the sound server process */
696 setLevelArtworkDir(artwork.mus_first);
698 InitReloadCustomMusic(mus_new_identifier);
701 artwork.mus_current_identifier = artwork.mus_current->identifier;
702 last_override_level_music = setup.override_level_music;
704 redraw_screen = TRUE;
711 /* force redraw of (open or closed) door graphics */
712 SetDoorState(DOOR_OPEN_ALL);
713 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
719 FreeLevelEditorGadgets();
728 static boolean gadgets_initialized = FALSE;
730 if (gadgets_initialized)
733 CreateLevelEditorGadgets();
737 CreateScreenGadgets();
739 gadgets_initialized = TRUE;
742 void InitElementImages()
744 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
745 int num_property_mappings = getImageListPropertyMappingSize();
748 /* initialize images from static configuration */
749 for (i=0; element_to_graphic[i].element > -1; i++)
750 CreateImageWithSmallImages(element_to_graphic[i].graphic);
752 /* initialize images from dynamic configuration */
753 for (i=0; i < num_property_mappings; i++)
754 CreateImageWithSmallImages(property_mapping[i].artwork_index);
757 void InitElementGraphicInfo()
759 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
760 int num_property_mappings = getImageListPropertyMappingSize();
763 /* set values to -1 to identify later as "uninitialized" values */
764 for (i=0; i<MAX_NUM_ELEMENTS; i++)
766 for (act=0; act<NUM_ACTIONS; act++)
768 element_info[i].graphic[act] = -1;
770 for (dir=0; dir<NUM_DIRECTIONS; dir++)
771 element_info[i].direction_graphic[act][dir] = -1;
775 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
776 element_info[i].graphic[ACTION_DEFAULT] =
777 IMG_CHAR_START + (i - EL_CHAR_START);
779 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
780 element_info[i].graphic[ACTION_DEFAULT] =
781 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
783 /* initialize element/graphic mapping from static configuration */
784 for (i=0; element_to_graphic[i].element > -1; i++)
786 int element = element_to_graphic[i].element;
787 int action = element_to_graphic[i].action;
788 int direction = element_to_graphic[i].direction;
789 int graphic = element_to_graphic[i].graphic;
792 action = ACTION_DEFAULT;
795 element_info[element].direction_graphic[action][direction] = graphic;
797 element_info[element].graphic[action] = graphic;
800 /* initialize element/graphic mapping from dynamic configuration */
801 for (i=0; i < num_property_mappings; i++)
803 int element = property_mapping[i].base_index;
804 int action = property_mapping[i].ext1_index;
805 int direction = property_mapping[i].ext2_index;
806 int special = property_mapping[i].ext3_index;
807 int graphic = property_mapping[i].artwork_index;
813 action = ACTION_DEFAULT;
816 element_info[element].direction_graphic[action][direction] = graphic;
818 element_info[element].graphic[action] = graphic;
821 /* now set all '-1' values to element specific default values */
822 for (i=0; i<MAX_NUM_ELEMENTS; i++)
824 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
825 int default_action_direction_graphic[NUM_DIRECTIONS];
827 if (default_action_graphic == -1)
828 default_action_graphic = IMG_CHAR_QUESTION;
830 for (dir=0; dir<NUM_DIRECTIONS; dir++)
832 default_action_direction_graphic[dir] =
833 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
835 if (default_action_direction_graphic[dir] == -1)
836 default_action_direction_graphic[dir] = default_action_graphic;
839 for (act=0; act<NUM_ACTIONS; act++)
841 for (dir=0; dir<NUM_DIRECTIONS; dir++)
843 int default_direction_graphic = element_info[i].graphic[act];
845 /* no graphic for current action -- use default direction graphic */
846 if (default_direction_graphic == -1)
847 default_direction_graphic = default_action_direction_graphic[dir];
849 if (element_info[i].direction_graphic[act][dir] == -1)
850 element_info[i].direction_graphic[act][dir] =
851 default_direction_graphic;
854 /* no graphic for this specific action -- use default action graphic */
855 if (element_info[i].graphic[act] == -1)
856 element_info[i].graphic[act] = default_action_graphic;
861 void InitElementEditorGraphicInfo()
863 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
864 int num_property_mappings = getImageListPropertyMappingSize();
867 /* always start with reliable default values */
868 for (i=0; i<MAX_NUM_ELEMENTS; i++)
869 element_info[i].editor_graphic = element_info[i].graphic[ACTION_DEFAULT];
872 /* initialize element/graphic mapping from static configuration */
875 int element = ... element;
876 int special = ... special;
877 int graphic = ... graphic;
879 if (special != GFX_SPECIAL_ARG_EDITOR)
882 element_info[element].editor_graphic = graphic;
886 /* initialize element/graphic mapping from dynamic configuration */
887 for (i=0; i < num_property_mappings; i++)
889 int element = property_mapping[i].base_index;
890 int special = property_mapping[i].ext3_index;
891 int graphic = property_mapping[i].artwork_index;
893 if (special != GFX_SPECIAL_ARG_EDITOR)
896 element_info[element].editor_graphic = graphic;
900 static void InitElementSoundInfo()
905 static void set_graphic_parameters(int graphic, int *parameter)
907 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
908 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
909 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
911 graphic_info[graphic].bitmap = src_bitmap;
913 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
914 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
915 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
916 graphic_info[graphic].offset_y = 0;
918 /* animation frames are ordered vertically instead of horizontally */
919 if (parameter[GFX_ARG_VERTICAL])
921 graphic_info[graphic].offset_x = 0;
922 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
925 /* optionally, the x and y offset of frames can be specified directly */
926 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
927 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
928 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
929 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
931 /* automatically determine correct number of frames, if not defined */
932 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
933 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
934 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
935 graphic_info[graphic].anim_frames = num_xtiles;
936 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
937 graphic_info[graphic].anim_frames = num_ytiles;
939 graphic_info[graphic].anim_frames = 1;
941 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
942 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
943 graphic_info[graphic].anim_delay = 1;
945 /* set mode for animation frame order */
946 if (parameter[GFX_ARG_MODE_LOOP])
947 graphic_info[graphic].anim_mode = ANIM_LOOP;
948 else if (parameter[GFX_ARG_MODE_LINEAR])
949 graphic_info[graphic].anim_mode = ANIM_LINEAR;
950 else if (parameter[GFX_ARG_MODE_PINGPONG])
951 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
952 else if (parameter[GFX_ARG_MODE_PINGPONG2])
953 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
954 else if (parameter[GFX_ARG_MODE_RANDOM])
955 graphic_info[graphic].anim_mode = ANIM_RANDOM;
956 else if (graphic_info[graphic].anim_frames > 1)
957 graphic_info[graphic].anim_mode = ANIM_LOOP;
959 graphic_info[graphic].anim_mode = ANIM_NONE;
961 /* set additional flag to play animation frames in reverse order */
962 if (parameter[GFX_ARG_MODE_REVERSE])
963 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
965 /* automatically determine correct start frame, if not defined */
966 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
967 graphic_info[graphic].anim_start_frame = 0;
968 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
969 graphic_info[graphic].anim_start_frame =
970 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
972 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
974 /* animation synchronized with global frame counter, not move position */
975 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
978 static void InitGraphicInfo()
980 static boolean clipmasks_initialized = FALSE;
981 int num_images = getImageListSize();
983 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
985 XGCValues clip_gc_values;
986 unsigned long clip_gc_valuemask;
987 GC copy_clipmask_gc = None;
990 if (graphic_info != NULL)
993 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
995 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
996 if (clipmasks_initialized)
998 for (i=0; i<num_images; i++)
1000 if (graphic_info[i].clip_mask)
1001 XFreePixmap(display, graphic_info[i].clip_mask);
1002 if (graphic_info[i].clip_gc)
1003 XFreeGC(display, graphic_info[i].clip_gc);
1005 graphic_info[i].clip_mask = None;
1006 graphic_info[i].clip_gc = None;
1011 for (i=0; i<num_images; i++)
1013 struct FileInfo *image = getImageListEntry(i);
1016 int first_frame, last_frame;
1018 set_graphic_parameters(i, image->parameter);
1020 /* now check if no animation frames are outside of the loaded image */
1022 if (graphic_info[i].bitmap == NULL)
1023 continue; /* skip check for optional images that are undefined */
1026 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1027 if (src_x < 0 || src_y < 0 ||
1028 src_x + TILEX > src_bitmap->width ||
1029 src_y + TILEY > src_bitmap->height)
1031 Error(ERR_RETURN_LINE, "-");
1032 Error(ERR_RETURN, "warning: error found in config file:");
1033 Error(ERR_RETURN, "- config file: '%s'",
1034 getImageConfigFilename());
1035 Error(ERR_RETURN, "- config token: '%s'",
1036 getTokenFromImageID(i));
1037 Error(ERR_RETURN, "- image file: '%s'",
1038 src_bitmap->source_filename);
1040 "error: first animation frame out of bounds (%d, %d)",
1042 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1043 Error(ERR_RETURN_LINE, "-");
1045 set_graphic_parameters(i, image->default_parameter);
1048 last_frame = graphic_info[i].anim_frames - 1;
1049 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
1050 if (src_x < 0 || src_y < 0 ||
1051 src_x + TILEX > src_bitmap->width ||
1052 src_y + TILEY > src_bitmap->height)
1054 Error(ERR_RETURN_LINE, "-");
1055 Error(ERR_RETURN, "warning: error found in config file:");
1056 Error(ERR_RETURN, "- config file: '%s'",
1057 getImageConfigFilename());
1058 Error(ERR_RETURN, "- config token: '%s'",
1059 getTokenFromImageID(i));
1060 Error(ERR_RETURN, "- image file: '%s'",
1061 src_bitmap->source_filename);
1063 "error: last animation frame (%d) out of bounds (%d, %d)",
1064 last_frame, src_x, src_y);
1065 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1066 Error(ERR_RETURN_LINE, "-");
1068 set_graphic_parameters(i, image->default_parameter);
1071 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1072 /* currently we need only a tile clip mask from the first frame */
1073 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1075 if (copy_clipmask_gc == None)
1077 clip_gc_values.graphics_exposures = False;
1078 clip_gc_valuemask = GCGraphicsExposures;
1079 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
1080 clip_gc_valuemask, &clip_gc_values);
1083 graphic_info[i].clip_mask =
1084 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
1086 src_pixmap = src_bitmap->clip_mask;
1087 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
1088 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
1090 clip_gc_values.graphics_exposures = False;
1091 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
1092 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
1093 graphic_info[i].clip_gc =
1094 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1098 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1099 if (copy_clipmask_gc)
1100 XFreeGC(display, copy_clipmask_gc);
1103 clipmasks_initialized = TRUE;
1106 static void set_sound_parameters(int sound, int *parameter)
1108 /* explicit loop mode setting in configuration overrides default value */
1109 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1110 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1113 static void InitSoundInfo()
1115 int *sound_effect_properties;
1116 int num_sounds = getSoundListSize();
1119 if (sound_info != NULL)
1122 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1123 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1125 /* initialize sound effect for all elements to "no sound" */
1126 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1127 for (j=0; j<NUM_ACTIONS; j++)
1128 element_info[i].sound[j] = SND_UNDEFINED;
1130 for (i=0; i<num_sounds; i++)
1132 struct FileInfo *sound = getSoundListEntry(i);
1133 int len_effect_text = strlen(sound->token);
1135 sound_effect_properties[i] = ACTION_OTHER;
1136 sound_info[i].loop = FALSE;
1138 /* determine all loop sounds and identify certain sound classes */
1140 for (j=0; element_action_info[j].suffix; j++)
1142 int len_action_text = strlen(element_action_info[j].suffix);
1144 if (len_action_text < len_effect_text &&
1145 strcmp(&sound->token[len_effect_text - len_action_text],
1146 element_action_info[j].suffix) == 0)
1148 sound_effect_properties[i] = element_action_info[j].value;
1150 if (element_action_info[j].is_loop_sound)
1151 sound_info[i].loop = TRUE;
1155 /* associate elements and some selected sound actions */
1157 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1159 if (element_info[j].sound_class_name)
1161 int len_class_text = strlen(element_info[j].sound_class_name);
1163 if (len_class_text + 1 < len_effect_text &&
1164 strncmp(sound->token,
1165 element_info[j].sound_class_name, len_class_text) == 0 &&
1166 sound->token[len_class_text] == '.')
1168 int sound_action_value = sound_effect_properties[i];
1170 element_info[j].sound[sound_action_value] = i;
1175 set_sound_parameters(i, sound->parameter);
1178 free(sound_effect_properties);
1183 int element = EL_SAND;
1184 int sound_action = ACTION_DIGGING;
1187 while (element_action_info[j].suffix)
1189 if (element_action_info[j].value == sound_action)
1190 printf("element %d, sound action '%s' == %d\n",
1191 element, element_action_info[j].suffix,
1192 element_info_[element].sound[sound_action]);
1199 void InitElementProperties()
1203 static int ep_amoebalive[] =
1210 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1212 static int ep_amoeboid[] =
1220 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1222 static int ep_schluessel[] =
1233 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1235 static int ep_pforte[] =
1254 EL_SWITCHGATE_OPENING,
1255 EL_SWITCHGATE_CLOSED,
1256 EL_SWITCHGATE_CLOSING,
1258 EL_TIMEGATE_OPENING,
1260 EL_TIMEGATE_CLOSING,
1264 EL_TUBE_VERTICAL_LEFT,
1265 EL_TUBE_VERTICAL_RIGHT,
1266 EL_TUBE_HORIZONTAL_UP,
1267 EL_TUBE_HORIZONTAL_DOWN,
1273 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1275 static int ep_solid[] =
1295 EL_QUICKSAND_FILLING,
1296 EL_QUICKSAND_EMPTYING,
1298 EL_MAGIC_WALL_ACTIVE,
1299 EL_MAGIC_WALL_EMPTYING,
1300 EL_MAGIC_WALL_FILLING,
1304 EL_BD_MAGIC_WALL_ACTIVE,
1305 EL_BD_MAGIC_WALL_EMPTYING,
1306 EL_BD_MAGIC_WALL_FULL,
1307 EL_BD_MAGIC_WALL_FILLING,
1308 EL_BD_MAGIC_WALL_DEAD,
1311 EL_ACIDPOOL_TOPLEFT,
1312 EL_ACIDPOOL_TOPRIGHT,
1313 EL_ACIDPOOL_BOTTOMLEFT,
1315 EL_ACIDPOOL_BOTTOMRIGHT,
1333 EL_SP_TERMINAL_ACTIVE,
1336 EL_INVISIBLE_STEELWALL,
1337 EL_INVISIBLE_STEELWALL_ACTIVE,
1339 EL_INVISIBLE_WALL_ACTIVE,
1340 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1341 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1342 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1343 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1344 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1345 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1346 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1347 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1348 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1349 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1350 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1351 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1352 EL_SWITCHGATE_SWITCH_UP,
1353 EL_SWITCHGATE_SWITCH_DOWN,
1355 EL_LIGHT_SWITCH_ACTIVE,
1357 EL_TIMEGATE_SWITCH_ACTIVE,
1358 EL_SIGN_EXCLAMATION,
1359 EL_SIGN_RADIOACTIVITY,
1370 EL_STEELWALL_SLANTED,
1375 EL_EMC_WALL_PILLAR_UPPER,
1376 EL_EMC_WALL_PILLAR_MIDDLE,
1377 EL_EMC_WALL_PILLAR_LOWER,
1403 EL_SWITCHGATE_OPENING,
1404 EL_SWITCHGATE_CLOSED,
1405 EL_SWITCHGATE_CLOSING,
1407 EL_TIMEGATE_OPENING,
1409 EL_TIMEGATE_CLOSING,
1413 EL_TUBE_VERTICAL_LEFT,
1414 EL_TUBE_VERTICAL_RIGHT,
1415 EL_TUBE_HORIZONTAL_UP,
1416 EL_TUBE_HORIZONTAL_DOWN,
1422 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1424 static int ep_massive[] =
1428 EL_ACIDPOOL_TOPLEFT,
1429 EL_ACIDPOOL_TOPRIGHT,
1430 EL_ACIDPOOL_BOTTOMLEFT,
1432 EL_ACIDPOOL_BOTTOMRIGHT,
1444 EL_INVISIBLE_STEELWALL,
1445 EL_INVISIBLE_STEELWALL_ACTIVE,
1446 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1447 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1448 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1449 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1450 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1451 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1452 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1453 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1454 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1455 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1456 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1457 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1459 EL_LIGHT_SWITCH_ACTIVE,
1460 EL_SIGN_EXCLAMATION,
1461 EL_SIGN_RADIOACTIVITY,
1472 EL_STEELWALL_SLANTED,
1495 EL_SWITCHGATE_OPENING,
1496 EL_SWITCHGATE_CLOSED,
1497 EL_SWITCHGATE_CLOSING,
1499 EL_TIMEGATE_OPENING,
1501 EL_TIMEGATE_CLOSING,
1505 EL_TUBE_VERTICAL_LEFT,
1506 EL_TUBE_VERTICAL_RIGHT,
1507 EL_TUBE_HORIZONTAL_UP,
1508 EL_TUBE_HORIZONTAL_DOWN,
1514 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1516 static int ep_slippery[] =
1530 EL_ROBOT_WHEEL_ACTIVE,
1536 EL_ACIDPOOL_TOPLEFT,
1537 EL_ACIDPOOL_TOPRIGHT,
1547 EL_STEELWALL_SLANTED,
1551 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1553 static int ep_enemy[] =
1566 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1568 static int ep_mauer[] =
1596 EL_WALL_GROWING_ACTIVE,
1615 EL_SP_TERMINAL_ACTIVE,
1618 EL_INVISIBLE_STEELWALL,
1619 EL_INVISIBLE_STEELWALL_ACTIVE,
1621 EL_INVISIBLE_WALL_ACTIVE,
1622 EL_STEELWALL_SLANTED,
1627 EL_EMC_WALL_PILLAR_UPPER,
1628 EL_EMC_WALL_PILLAR_MIDDLE,
1629 EL_EMC_WALL_PILLAR_LOWER,
1636 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1638 static int ep_can_fall[] =
1653 EL_BD_MAGIC_WALL_FULL,
1664 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1666 static int ep_can_smash[] =
1697 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1699 static int ep_can_change[] =
1710 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1712 static int ep_can_move[] =
1732 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1734 static int ep_could_move[] =
1744 EL_BD_BUTTERFLY_RIGHT,
1746 EL_BD_BUTTERFLY_LEFT,
1747 EL_BD_BUTTERFLY_DOWN,
1748 EL_BD_FIREFLY_RIGHT,
1757 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1759 static int ep_dont_touch[] =
1766 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1768 static int ep_dont_go_to[] =
1782 EL_SP_BUGGY_BASE_ACTIVE,
1786 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1788 static int ep_mampf2[] =
1813 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1815 static int ep_bd_element[] =
1842 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1844 static int ep_sb_element[] =
1849 EL_SOKOBAN_FIELD_EMPTY,
1850 EL_SOKOBAN_FIELD_FULL,
1852 EL_INVISIBLE_STEELWALL
1854 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1856 static int ep_gem[] =
1865 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1867 static int ep_inactive[] =
1904 EL_INVISIBLE_STEELWALL,
1912 EL_WALL_EMERALD_YELLOW,
1917 EL_SOKOBAN_FIELD_EMPTY,
1918 EL_SOKOBAN_FIELD_FULL,
1919 EL_WALL_EMERALD_RED,
1920 EL_WALL_EMERALD_PURPLE,
1921 EL_ACIDPOOL_TOPLEFT,
1922 EL_ACIDPOOL_TOPRIGHT,
1923 EL_ACIDPOOL_BOTTOMLEFT,
1925 EL_ACIDPOOL_BOTTOMRIGHT,
1929 EL_BD_MAGIC_WALL_DEAD,
1930 EL_AMOEBA_TO_DIAMOND,
1963 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1964 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1965 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1966 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1967 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1968 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1969 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1970 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1971 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1972 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1973 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1974 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1975 EL_SIGN_EXCLAMATION,
1976 EL_SIGN_RADIOACTIVITY,
1987 EL_STEELWALL_SLANTED,
1992 EL_EMC_WALL_PILLAR_UPPER,
1993 EL_EMC_WALL_PILLAR_MIDDLE,
1994 EL_EMC_WALL_PILLAR_LOWER,
2001 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
2003 static int ep_explosive[] =
2008 EL_DYNABOMB_PLAYER1_ACTIVE,
2009 EL_DYNABOMB_PLAYER2_ACTIVE,
2010 EL_DYNABOMB_PLAYER3_ACTIVE,
2011 EL_DYNABOMB_PLAYER4_ACTIVE,
2028 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
2030 static int ep_mampf3[] =
2041 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
2043 static int ep_pushable[] =
2050 EL_SOKOBAN_FIELD_FULL,
2060 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
2062 static int ep_player[] =
2069 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
2071 static int ep_has_content[] =
2079 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
2081 static int ep_eatable[] =
2086 EL_SP_BUGGY_BASE_ACTIVATING,
2089 EL_INVISIBLE_SAND_ACTIVE
2091 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
2093 static int ep_sp_element[] =
2136 /* additional elements that appeared in newer Supaplex levels */
2138 /* more than one murphy in a level results in an inactive clone */
2141 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2143 static int ep_quick_gate[] =
2167 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2169 static int ep_over_player[] =
2185 EL_TUBE_VERTICAL_LEFT,
2186 EL_TUBE_VERTICAL_RIGHT,
2187 EL_TUBE_HORIZONTAL_UP,
2188 EL_TUBE_HORIZONTAL_DOWN,
2194 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2196 static int ep_active_bomb[] =
2199 EL_DYNABOMB_PLAYER1_ACTIVE,
2200 EL_DYNABOMB_PLAYER2_ACTIVE,
2201 EL_DYNABOMB_PLAYER3_ACTIVE,
2202 EL_DYNABOMB_PLAYER4_ACTIVE
2204 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2206 static int ep_belt[] =
2208 EL_CONVEYOR_BELT1_LEFT,
2209 EL_CONVEYOR_BELT1_MIDDLE,
2210 EL_CONVEYOR_BELT1_RIGHT,
2211 EL_CONVEYOR_BELT2_LEFT,
2212 EL_CONVEYOR_BELT2_MIDDLE,
2213 EL_CONVEYOR_BELT2_RIGHT,
2214 EL_CONVEYOR_BELT3_LEFT,
2215 EL_CONVEYOR_BELT3_MIDDLE,
2216 EL_CONVEYOR_BELT3_RIGHT,
2217 EL_CONVEYOR_BELT4_LEFT,
2218 EL_CONVEYOR_BELT4_MIDDLE,
2219 EL_CONVEYOR_BELT4_RIGHT,
2221 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2223 static int ep_belt_active[] =
2225 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2226 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2227 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2228 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2229 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2230 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2231 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2232 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2233 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2234 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2235 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2236 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2238 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2240 static int ep_belt_switch[] =
2242 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2243 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2244 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2245 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2246 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2247 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2248 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2249 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2250 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2251 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2252 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2253 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2255 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2257 static int ep_tube[] =
2262 EL_TUBE_VERTICAL_LEFT,
2263 EL_TUBE_VERTICAL_RIGHT,
2264 EL_TUBE_HORIZONTAL_UP,
2265 EL_TUBE_HORIZONTAL_DOWN,
2271 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2273 static long ep1_bit[] =
2307 static long ep2_bit[] =
2314 static int *ep1_array[] =
2348 static int *ep2_array[] =
2355 static int *ep1_num[] =
2382 &ep_has_content_num,
2386 &ep_over_player_num,
2389 static int *ep2_num[] =
2392 &ep_belt_active_num,
2393 &ep_belt_switch_num,
2396 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2397 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2399 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2405 for (i=0; i<num_properties1; i++)
2406 for (j=0; j<*(ep1_num[i]); j++)
2407 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2408 for (i=0; i<num_properties2; i++)
2409 for (j=0; j<*(ep2_num[i]); j++)
2410 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2412 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2413 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2416 void Execute_Command(char *command)
2418 if (strcmp(command, "print graphicsinfo.conf") == 0)
2422 printf("# You can configure additional/alternative image files here.\n");
2423 printf("# (The images below are default and therefore commented out.)\n");
2425 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2427 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2430 for (i=0; image_config[i].token != NULL; i++)
2432 getFormattedSetupEntry(image_config[i].token,
2433 image_config[i].value));
2437 else if (strcmp(command, "print soundsinfo.conf") == 0)
2441 printf("# You can configure additional/alternative sound files here.\n");
2442 printf("# (The sounds below are default and therefore commented out.)\n");
2444 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2446 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2449 for (i=0; sound_config[i].token != NULL; i++)
2451 getFormattedSetupEntry(sound_config[i].token,
2452 sound_config[i].value));
2456 else if (strcmp(command, "print musicinfo.conf") == 0)
2458 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2460 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2462 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2466 else if (strncmp(command, "dump level ", 11) == 0)
2468 char *filename = &command[11];
2470 if (access(filename, F_OK) != 0)
2471 Error(ERR_EXIT, "cannot open file '%s'", filename);
2473 LoadLevelFromFilename(filename);
2478 else if (strncmp(command, "dump tape ", 10) == 0)
2480 char *filename = &command[10];
2482 if (access(filename, F_OK) != 0)
2483 Error(ERR_EXIT, "cannot open file '%s'", filename);
2485 LoadTapeFromFilename(filename);
2490 else if (strncmp(command, "autoplay ", 9) == 0)
2492 char *str_copy = getStringCopy(&command[9]);
2493 char *str_ptr = strchr(str_copy, ' ');
2495 global.autoplay_leveldir = str_copy;
2496 global.autoplay_level_nr = -1;
2498 if (str_ptr != NULL)
2500 *str_ptr++ = '\0'; /* terminate leveldir string */
2501 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2506 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2510 void CloseAllAndExit(int exit_value)
2515 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2518 FreeTileClipmasks();
2520 if (bitmap_font_initial)
2521 FreeBitmap(bitmap_font_initial);
2523 CloseVideoDisplay();
2524 ClosePlatformDependantStuff();