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 */
30 #include "conf_esg.c" /* include auto-generated data structure definitions */
33 static char *image_filename[NUM_PICTURES] =
41 "RocksFontMedium.pcx",
54 "RocksFontMedium.pcx",
59 static Bitmap *bitmap_font_initial = NULL;
61 static void InitGlobal();
62 static void InitSetup();
63 static void InitPlayerInfo();
64 static void InitLevelInfo();
65 static void InitArtworkInfo();
66 static void InitLevelArtworkInfo();
67 static void InitNetworkServer();
68 static void InitArtworkConfig();
69 static void InitImages();
70 static void InitMixer();
71 static void InitSound();
72 static void InitMusic();
73 static void InitGfx();
74 static void InitGfxBackground();
75 static void InitGadgets();
76 static void InitElementImages();
77 static void InitElementGraphicInfo();
78 static void InitElementEditorGraphicInfo();
79 static void InitElementSoundInfo();
80 static void InitElementProperties();
81 static void InitGraphicInfo();
82 static void InitSoundInfo();
83 static void Execute_Command(char *);
87 InitGlobal(); /* initialize some global variables */
89 if (options.execute_command)
90 Execute_Command(options.execute_command);
92 if (options.serveronly)
94 #if defined(PLATFORM_UNIX)
95 NetworkServer(options.server_port, options.serveronly);
97 Error(ERR_WARN, "networking only supported in Unix version");
99 exit(0); /* never reached */
102 InitProgramInfo(UNIX_USERDATA_DIRECTORY,
103 PROGRAM_TITLE_STRING, getWindowTitleString(),
104 ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
105 MSDOS_POINTER_FILENAME,
106 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
110 InitArtworkInfo(); /* needed before loading gfx, sound & music */
111 InitArtworkConfig(); /* needed before forking sound child process */
117 InitRND(NEW_RANDOMIZE);
120 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
123 InitEventFilter(FilterMouseMotionEvents);
125 InitElementProperties();
130 InitLevelArtworkInfo();
132 InitImages(); /* needs to know current level directory */
133 InitSound(); /* needs to know current level directory */
134 InitMusic(); /* needs to know current level directory */
138 if (global.autoplay_leveldir)
149 static void InitGlobal()
151 global.autoplay_leveldir = NULL;
153 global.frames_per_second = 0;
154 global.fps_slowdown = FALSE;
155 global.fps_slowdown_factor = 1;
158 static void InitSetup()
160 LoadSetup(); /* global setup info */
163 static void InitPlayerInfo()
167 /* choose default local player */
168 local_player = &stored_player[0];
170 for (i=0; i<MAX_PLAYERS; i++)
171 stored_player[i].connected = FALSE;
173 local_player->connected = TRUE;
176 static void InitLevelInfo()
178 LoadLevelInfo(); /* global level info */
179 LoadLevelSetup_LastSeries(); /* last played series info */
180 LoadLevelSetup_SeriesInfo(); /* last played level info */
183 static void InitArtworkInfo()
188 static void InitArtworkConfig()
190 static char *element_prefix[MAX_NUM_ELEMENTS + 1];
191 static char *sound_class_prefix[MAX_NUM_ELEMENTS + 1];
192 static char *action_suffix[NUM_ACTIONS + 1];
193 static char *direction_suffix[NUM_DIRECTIONS + 1];
194 static char *special_suffix[NUM_SPECIAL_GFX_ARGS + 1];
195 static char *dummy[1] = { NULL };
198 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
199 element_prefix[i] = element_info[i].token_name;
200 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
201 sound_class_prefix[i] = element_info[i].sound_class_name;
202 for (i=0; i<NUM_ACTIONS + 1; i++)
203 action_suffix[i] = element_action_info[i].suffix;
204 for (i=0; i<NUM_DIRECTIONS + 1; i++)
205 direction_suffix[i] = element_direction_info[i].suffix;
206 for (i=0; i<NUM_SPECIAL_GFX_ARGS + 1; i++)
207 special_suffix[i] = special_suffix_info[i].suffix;
209 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
210 element_prefix, action_suffix,direction_suffix,special_suffix);
211 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
212 sound_class_prefix, action_suffix, dummy, dummy);
215 void InitLevelArtworkInfo()
217 LoadLevelArtworkInfo();
220 void InitNetworkServer()
222 #if defined(PLATFORM_UNIX)
226 if (!options.network)
229 #if defined(PLATFORM_UNIX)
230 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
232 if (!ConnectToServer(options.server_host, options.server_port))
233 Error(ERR_EXIT, "cannot connect to network game server");
235 SendToServer_PlayerName(setup.player_name);
236 SendToServer_ProtocolVersion();
239 SendToServer_NrWanted(nr_wanted);
243 static void InitMixer()
249 static void ReinitializeGraphics()
251 InitElementGraphicInfo(); /* element => game graphic mapping */
252 InitElementEditorGraphicInfo(); /* element => editor graphic mapping */
253 InitGraphicInfo(); /* graphic => properties mapping */
255 InitFontInfo(bitmap_font_initial,
256 graphic_info[IMG_FONT_BIG].bitmap,
257 graphic_info[IMG_FONT_MEDIUM].bitmap,
258 graphic_info[IMG_FONT_SMALL].bitmap,
259 graphic_info[IMG_FONT_EM].bitmap);
261 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
262 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
269 /* !!! TEST ONLY !!! */
272 Bitmap *tst_bitmap = graphic_info[IMG_SAND].bitmap;
273 Bitmap *tmp_bitmap = ZoomBitmap(tst_bitmap,
274 tst_bitmap->width / 2,
275 tst_bitmap->height / 2);
277 BlitBitmap(tmp_bitmap, tst_bitmap, 0, 0, 256, 224, 0, 448);
279 FreeBitmap(tmp_bitmap);
284 printf("CREATING SMALL IMAGES...\n");
289 CreateImageWithSmallImages(IMG_SAND);
290 CreateImageWithSmallImages(IMG_SAND);
297 static void ReinitializeSounds()
299 InitElementSoundInfo(); /* element => game sound mapping */
300 InitSoundInfo(); /* sound => properties mapping */
302 InitPlaySoundLevel(); /* internal game sound settings */
305 static void ReinitializeMusic()
307 /* currently nothing to do */
310 static void InitImages()
312 ReloadCustomImages();
313 ReinitializeGraphics();
315 LoadCustomElementDescriptions();
318 static void InitSound()
320 InitReloadCustomSounds(artwork.snd_current->identifier);
321 ReinitializeSounds();
324 static void InitMusic()
326 InitReloadCustomMusic(artwork.mus_current->identifier);
330 static void InitTileClipmasks()
333 #if defined(TARGET_X11)
334 XGCValues clip_gc_values;
335 unsigned long clip_gc_valuemask;
337 #if defined(TARGET_X11_NATIVE)
347 tile_needs_clipping[] =
349 { GFX_SPIELER1_UP, 4 },
350 { GFX_SPIELER1_DOWN, 4 },
351 { GFX_SPIELER1_LEFT, 4 },
352 { GFX_SPIELER1_RIGHT, 4 },
353 { GFX_SPIELER1_PUSH_LEFT, 4 },
354 { GFX_SPIELER1_PUSH_RIGHT, 4 },
355 { GFX_SPIELER2_UP, 4 },
356 { GFX_SPIELER2_DOWN, 4 },
357 { GFX_SPIELER2_LEFT, 4 },
358 { GFX_SPIELER2_RIGHT, 4 },
359 { GFX_SPIELER2_PUSH_LEFT, 4 },
360 { GFX_SPIELER2_PUSH_RIGHT, 4 },
361 { GFX_SPIELER3_UP, 4 },
362 { GFX_SPIELER3_DOWN, 4 },
363 { GFX_SPIELER3_LEFT, 4 },
364 { GFX_SPIELER3_RIGHT, 4 },
365 { GFX_SPIELER3_PUSH_LEFT, 4 },
366 { GFX_SPIELER3_PUSH_RIGHT, 4 },
367 { GFX_SPIELER4_UP, 4 },
368 { GFX_SPIELER4_DOWN, 4 },
369 { GFX_SPIELER4_LEFT, 4 },
370 { GFX_SPIELER4_RIGHT, 4 },
371 { GFX_SPIELER4_PUSH_LEFT, 4 },
372 { GFX_SPIELER4_PUSH_RIGHT, 4 },
373 { GFX_SP_MURPHY, 1 },
374 { GFX_MURPHY_GO_LEFT, 3 },
375 { GFX_MURPHY_GO_RIGHT, 3 },
376 { GFX_MURPHY_SNAP_UP, 1 },
377 { GFX_MURPHY_SNAP_DOWN, 1 },
378 { GFX_MURPHY_SNAP_RIGHT, 1 },
379 { GFX_MURPHY_SNAP_LEFT, 1 },
380 { GFX_MURPHY_PUSH_RIGHT, 1 },
381 { GFX_MURPHY_PUSH_LEFT, 1 },
382 { GFX_GEBLUBBER, 4 },
385 { GFX_EXPLOSION, 8 },
386 { GFX_SOKOBAN_OBJEKT, 1 },
387 { GFX_FUNKELN_BLAU, 3 },
388 { GFX_FUNKELN_WEISS, 3 },
389 { GFX2_SHIELD_PASSIVE, 3 },
390 { GFX2_SHIELD_ACTIVE, 3 },
395 #endif /* TARGET_X11_NATIVE */
396 #endif /* TARGET_X11 */
400 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
401 for (i=0; i<NUM_TILES; i++)
402 tile_clipmask[i] = None;
404 #if defined(TARGET_X11)
405 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
406 often very slow when preparing a masked XCopyArea() for big Pixmaps.
407 To prevent this, create small (tile-sized) mask Pixmaps which will then
408 be set much faster with XSetClipOrigin() and speed things up a lot. */
410 clip_gc_values.graphics_exposures = False;
411 clip_gc_valuemask = GCGraphicsExposures;
412 tile_clip_gc = XCreateGC(display, window->drawable,
413 clip_gc_valuemask, &clip_gc_values);
416 for (i=0; i<NUM_BITMAPS; i++)
418 if (pix[i]->clip_mask)
420 clip_gc_values.graphics_exposures = False;
421 clip_gc_values.clip_mask = pix[i]->clip_mask;
422 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
423 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
424 clip_gc_valuemask, &clip_gc_values);
429 #if defined(TARGET_X11_NATIVE)
432 /* create graphic context structures needed for clipping */
433 clip_gc_values.graphics_exposures = False;
434 clip_gc_valuemask = GCGraphicsExposures;
435 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
436 clip_gc_valuemask, &clip_gc_values);
438 /* create only those clipping Pixmaps we really need */
439 for (i=0; tile_needs_clipping[i].start>=0; i++)
443 for (j=0; j<tile_needs_clipping[i].count; j++)
445 int tile = tile_needs_clipping[i].start + j;
451 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
452 src_pixmap = src_bitmap->clip_mask;
454 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
457 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
458 src_x, src_y, TILEX, TILEY, 0, 0);
462 XFreeGC(display, copy_clipmask_gc);
465 #endif /* TARGET_X11_NATIVE */
466 #endif /* TARGET_X11 */
470 void FreeTileClipmasks()
473 #if defined(TARGET_X11)
476 for (i=0; i<NUM_TILES; i++)
478 if (tile_clipmask[i] != None)
480 XFreePixmap(display, tile_clipmask[i]);
481 tile_clipmask[i] = None;
486 XFreeGC(display, tile_clip_gc);
490 for (i=0; i<NUM_BITMAPS; i++)
492 if (pix[i] != NULL && pix[i]->stored_clip_gc)
494 XFreeGC(display, pix[i]->stored_clip_gc);
495 pix[i]->stored_clip_gc = None;
500 #endif /* TARGET_X11 */
510 /* initialize screen properties */
511 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
512 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
513 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
514 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
515 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
517 /* create additional image buffers for double-buffering */
518 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
519 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
522 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
524 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
526 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
528 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
531 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
532 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
534 DrawInitText("Loading graphics:", 120, FC_GREEN);
537 for (i=0; i<NUM_PICTURES; i++)
540 if (i != PIX_FONT_SMALL)
543 DrawInitText(image_filename[i], 150, FC_YELLOW);
545 pix[i] = LoadCustomImage(image_filename[i]);
551 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
558 void InitGfxBackground()
563 fieldbuffer = bitmap_db_field;
564 SetDrawtoField(DRAW_BACKBUFFER);
566 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
567 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
568 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
569 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
571 for (x=0; x<MAX_BUF_XSIZE; x++)
572 for (y=0; y<MAX_BUF_YSIZE; y++)
575 redraw_mask = REDRAW_ALL;
578 void ReloadCustomArtwork()
580 static char *leveldir_current_identifier = NULL;
581 static boolean last_override_level_graphics = FALSE;
582 static boolean last_override_level_sounds = FALSE;
583 static boolean last_override_level_music = FALSE;
584 /* identifier for new artwork; default: artwork configured in setup */
585 char *gfx_new_identifier = artwork.gfx_current->identifier;
586 char *snd_new_identifier = artwork.snd_current->identifier;
587 char *mus_new_identifier = artwork.mus_current->identifier;
588 boolean redraw_screen = FALSE;
590 if (leveldir_current_identifier == NULL)
591 leveldir_current_identifier = leveldir_current->identifier;
594 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
595 leveldir_current->graphics_set);
596 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
597 leveldir_current->identifier);
601 printf("graphics --> '%s' ('%s')\n",
602 artwork.gfx_current_identifier, artwork.gfx_current->filename);
603 printf("sounds --> '%s' ('%s')\n",
604 artwork.snd_current_identifier, artwork.snd_current->filename);
605 printf("music --> '%s' ('%s')\n",
606 artwork.mus_current_identifier, artwork.mus_current->filename);
609 /* leveldir_current may be invalid (level group, parent link) */
610 if (!validLevelSeries(leveldir_current))
613 /* when a new level series was selected, check if there was a change
614 in custom artwork stored in level series directory */
615 if (leveldir_current_identifier != leveldir_current->identifier)
617 char *identifier_old = leveldir_current_identifier;
618 char *identifier_new = leveldir_current->identifier;
620 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
621 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
622 gfx_new_identifier = identifier_new;
623 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
624 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
625 snd_new_identifier = identifier_new;
626 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
627 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
628 mus_new_identifier = identifier_new;
630 leveldir_current_identifier = leveldir_current->identifier;
633 /* custom level artwork configured in level series configuration file
634 always overrides custom level artwork stored in level series directory
635 and (level independant) custom artwork configured in setup menue */
636 if (leveldir_current->graphics_set != NULL)
637 gfx_new_identifier = leveldir_current->graphics_set;
638 if (leveldir_current->sounds_set != NULL)
639 snd_new_identifier = leveldir_current->sounds_set;
640 if (leveldir_current->music_set != NULL)
641 mus_new_identifier = leveldir_current->music_set;
643 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
644 last_override_level_graphics != setup.override_level_graphics)
647 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
648 artwork.gfx_current_identifier,
649 artwork.gfx_current->identifier,
653 setLevelArtworkDir(artwork.gfx_first);
655 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
657 ReloadCustomImages();
658 ReinitializeGraphics();
660 LoadCustomElementDescriptions();
665 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
666 last_override_level_graphics = setup.override_level_graphics;
668 redraw_screen = TRUE;
671 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
672 last_override_level_sounds != setup.override_level_sounds)
675 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
676 artwork.snd_current_identifier,
677 artwork.snd_current->identifier,
681 /* set artwork path to send it to the sound server process */
682 setLevelArtworkDir(artwork.snd_first);
684 InitReloadCustomSounds(snd_new_identifier);
685 ReinitializeSounds();
687 artwork.snd_current_identifier = artwork.snd_current->identifier;
688 last_override_level_sounds = setup.override_level_sounds;
690 redraw_screen = TRUE;
693 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
694 last_override_level_music != setup.override_level_music)
696 /* set artwork path to send it to the sound server process */
697 setLevelArtworkDir(artwork.mus_first);
699 InitReloadCustomMusic(mus_new_identifier);
702 artwork.mus_current_identifier = artwork.mus_current->identifier;
703 last_override_level_music = setup.override_level_music;
705 redraw_screen = TRUE;
712 /* force redraw of (open or closed) door graphics */
713 SetDoorState(DOOR_OPEN_ALL);
714 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
720 FreeLevelEditorGadgets();
729 static boolean gadgets_initialized = FALSE;
731 if (gadgets_initialized)
734 CreateLevelEditorGadgets();
738 CreateScreenGadgets();
740 gadgets_initialized = TRUE;
743 void InitElementImages()
745 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
746 int num_property_mappings = getImageListPropertyMappingSize();
749 /* initialize images from static configuration */
750 for (i=0; element_to_graphic[i].element > -1; i++)
751 CreateImageWithSmallImages(element_to_graphic[i].graphic);
753 /* initialize images from dynamic configuration */
754 for (i=0; i < num_property_mappings; i++)
755 CreateImageWithSmallImages(property_mapping[i].artwork_index);
758 void InitElementGraphicInfo()
760 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
761 int num_property_mappings = getImageListPropertyMappingSize();
764 /* set values to -1 to identify later as "uninitialized" values */
765 for (i=0; i<MAX_NUM_ELEMENTS; i++)
767 for (act=0; act<NUM_ACTIONS; act++)
769 element_info[i].graphic[act] = -1;
771 for (dir=0; dir<NUM_DIRECTIONS; dir++)
772 element_info[i].direction_graphic[act][dir] = -1;
776 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
777 element_info[i].graphic[ACTION_DEFAULT] =
778 IMG_CHAR_START + (i - EL_CHAR_START);
780 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
781 element_info[i].graphic[ACTION_DEFAULT] =
782 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
784 /* initialize normal element/graphic mapping from static configuration */
785 for (i=0; element_to_graphic[i].element > -1; i++)
787 int element = element_to_graphic[i].element;
788 int action = element_to_graphic[i].action;
789 int direction = element_to_graphic[i].direction;
790 int graphic = element_to_graphic[i].graphic;
793 action = ACTION_DEFAULT;
796 element_info[element].direction_graphic[action][direction] = graphic;
798 element_info[element].graphic[action] = graphic;
801 /* initialize normal element/graphic mapping from dynamic configuration */
802 for (i=0; i < num_property_mappings; i++)
804 int element = property_mapping[i].base_index;
805 int action = property_mapping[i].ext1_index;
806 int direction = property_mapping[i].ext2_index;
807 int special = property_mapping[i].ext3_index;
808 int graphic = property_mapping[i].artwork_index;
814 action = ACTION_DEFAULT;
817 element_info[element].direction_graphic[action][direction] = graphic;
819 element_info[element].graphic[action] = graphic;
822 /* now set all '-1' values to element specific default values */
823 for (i=0; i<MAX_NUM_ELEMENTS; i++)
825 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
826 int default_action_direction_graphic[NUM_DIRECTIONS];
828 if (default_action_graphic == -1)
829 default_action_graphic = IMG_CHAR_QUESTION;
831 for (dir=0; dir<NUM_DIRECTIONS; dir++)
833 default_action_direction_graphic[dir] =
834 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
836 if (default_action_direction_graphic[dir] == -1)
837 default_action_direction_graphic[dir] = default_action_graphic;
840 for (act=0; act<NUM_ACTIONS; act++)
842 for (dir=0; dir<NUM_DIRECTIONS; dir++)
844 int default_direction_graphic = element_info[i].graphic[act];
846 /* no graphic for current action -- use default direction graphic */
847 if (default_direction_graphic == -1)
848 default_direction_graphic = default_action_direction_graphic[dir];
850 if (element_info[i].direction_graphic[act][dir] == -1)
851 element_info[i].direction_graphic[act][dir] =
852 default_direction_graphic;
855 /* no graphic for this specific action -- use default action graphic */
856 if (element_info[i].graphic[act] == -1)
857 element_info[i].graphic[act] = default_action_graphic;
862 void InitElementEditorGraphicInfo()
864 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
865 int num_property_mappings = getImageListPropertyMappingSize();
868 /* always start with reliable default values */
869 for (i=0; i<MAX_NUM_ELEMENTS; i++)
870 element_info[i].editor_graphic = element_info[i].graphic[ACTION_DEFAULT];
872 /* initialize special element/graphic mapping from static configuration */
873 for (i=0; element_to_special_graphic[i].element > -1; i++)
875 int element = element_to_special_graphic[i].element;
876 int special = element_to_special_graphic[i].special;
877 int graphic = element_to_special_graphic[i].graphic;
879 if (special != GFX_SPECIAL_ARG_EDITOR)
882 element_info[element].editor_graphic = graphic;
885 /* initialize special element/graphic mapping from dynamic configuration */
886 for (i=0; i < num_property_mappings; i++)
888 int element = property_mapping[i].base_index;
889 int special = property_mapping[i].ext3_index;
890 int graphic = property_mapping[i].artwork_index;
892 if (special != GFX_SPECIAL_ARG_EDITOR)
895 element_info[element].editor_graphic = graphic;
899 static void InitElementSoundInfo()
904 static void set_graphic_parameters(int graphic, int *parameter)
906 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
907 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
908 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
910 graphic_info[graphic].bitmap = src_bitmap;
912 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
913 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
914 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
915 graphic_info[graphic].offset_y = 0;
917 /* animation frames are ordered vertically instead of horizontally */
918 if (parameter[GFX_ARG_VERTICAL])
920 graphic_info[graphic].offset_x = 0;
921 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
924 /* optionally, the x and y offset of frames can be specified directly */
925 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
926 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
927 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
928 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
930 /* automatically determine correct number of frames, if not defined */
931 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
932 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
933 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
934 graphic_info[graphic].anim_frames = num_xtiles;
935 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
936 graphic_info[graphic].anim_frames = num_ytiles;
938 graphic_info[graphic].anim_frames = 1;
940 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
941 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
942 graphic_info[graphic].anim_delay = 1;
944 /* set mode for animation frame order */
945 if (parameter[GFX_ARG_MODE_LOOP])
946 graphic_info[graphic].anim_mode = ANIM_LOOP;
947 else if (parameter[GFX_ARG_MODE_LINEAR])
948 graphic_info[graphic].anim_mode = ANIM_LINEAR;
949 else if (parameter[GFX_ARG_MODE_PINGPONG])
950 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
951 else if (parameter[GFX_ARG_MODE_PINGPONG2])
952 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
953 else if (parameter[GFX_ARG_MODE_RANDOM])
954 graphic_info[graphic].anim_mode = ANIM_RANDOM;
955 else if (graphic_info[graphic].anim_frames > 1)
956 graphic_info[graphic].anim_mode = ANIM_LOOP;
958 graphic_info[graphic].anim_mode = ANIM_NONE;
960 /* set additional flag to play animation frames in reverse order */
961 if (parameter[GFX_ARG_MODE_REVERSE])
962 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
964 /* automatically determine correct start frame, if not defined */
965 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
966 graphic_info[graphic].anim_start_frame = 0;
967 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
968 graphic_info[graphic].anim_start_frame =
969 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
971 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
973 /* animation synchronized with global frame counter, not move position */
974 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
977 static void InitGraphicInfo()
979 static boolean clipmasks_initialized = FALSE;
980 int num_images = getImageListSize();
982 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
984 XGCValues clip_gc_values;
985 unsigned long clip_gc_valuemask;
986 GC copy_clipmask_gc = None;
989 if (graphic_info != NULL)
992 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
994 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
995 if (clipmasks_initialized)
997 for (i=0; i<num_images; i++)
999 if (graphic_info[i].clip_mask)
1000 XFreePixmap(display, graphic_info[i].clip_mask);
1001 if (graphic_info[i].clip_gc)
1002 XFreeGC(display, graphic_info[i].clip_gc);
1004 graphic_info[i].clip_mask = None;
1005 graphic_info[i].clip_gc = None;
1010 for (i=0; i<num_images; i++)
1012 struct FileInfo *image = getImageListEntry(i);
1015 int first_frame, last_frame;
1017 set_graphic_parameters(i, image->parameter);
1019 /* now check if no animation frames are outside of the loaded image */
1021 if (graphic_info[i].bitmap == NULL)
1022 continue; /* skip check for optional images that are undefined */
1025 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1026 if (src_x < 0 || src_y < 0 ||
1027 src_x + TILEX > src_bitmap->width ||
1028 src_y + TILEY > src_bitmap->height)
1030 Error(ERR_RETURN_LINE, "-");
1031 Error(ERR_RETURN, "warning: error found in config file:");
1032 Error(ERR_RETURN, "- config file: '%s'",
1033 getImageConfigFilename());
1034 Error(ERR_RETURN, "- config token: '%s'",
1035 getTokenFromImageID(i));
1036 Error(ERR_RETURN, "- image file: '%s'",
1037 src_bitmap->source_filename);
1039 "error: first animation frame out of bounds (%d, %d)",
1041 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1042 Error(ERR_RETURN_LINE, "-");
1044 set_graphic_parameters(i, image->default_parameter);
1047 last_frame = graphic_info[i].anim_frames - 1;
1048 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
1049 if (src_x < 0 || src_y < 0 ||
1050 src_x + TILEX > src_bitmap->width ||
1051 src_y + TILEY > src_bitmap->height)
1053 Error(ERR_RETURN_LINE, "-");
1054 Error(ERR_RETURN, "warning: error found in config file:");
1055 Error(ERR_RETURN, "- config file: '%s'",
1056 getImageConfigFilename());
1057 Error(ERR_RETURN, "- config token: '%s'",
1058 getTokenFromImageID(i));
1059 Error(ERR_RETURN, "- image file: '%s'",
1060 src_bitmap->source_filename);
1062 "error: last animation frame (%d) out of bounds (%d, %d)",
1063 last_frame, src_x, src_y);
1064 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1065 Error(ERR_RETURN_LINE, "-");
1067 set_graphic_parameters(i, image->default_parameter);
1070 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1071 /* currently we need only a tile clip mask from the first frame */
1072 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1074 if (copy_clipmask_gc == None)
1076 clip_gc_values.graphics_exposures = False;
1077 clip_gc_valuemask = GCGraphicsExposures;
1078 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
1079 clip_gc_valuemask, &clip_gc_values);
1082 graphic_info[i].clip_mask =
1083 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
1085 src_pixmap = src_bitmap->clip_mask;
1086 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
1087 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
1089 clip_gc_values.graphics_exposures = False;
1090 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
1091 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
1092 graphic_info[i].clip_gc =
1093 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1097 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1098 if (copy_clipmask_gc)
1099 XFreeGC(display, copy_clipmask_gc);
1102 clipmasks_initialized = TRUE;
1105 static void set_sound_parameters(int sound, int *parameter)
1107 /* explicit loop mode setting in configuration overrides default value */
1108 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1109 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1112 static void InitSoundInfo()
1114 int *sound_effect_properties;
1115 int num_sounds = getSoundListSize();
1118 if (sound_info != NULL)
1121 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1122 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1124 /* initialize sound effect for all elements to "no sound" */
1125 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1126 for (j=0; j<NUM_ACTIONS; j++)
1127 element_info[i].sound[j] = SND_UNDEFINED;
1129 for (i=0; i<num_sounds; i++)
1131 struct FileInfo *sound = getSoundListEntry(i);
1132 int len_effect_text = strlen(sound->token);
1134 sound_effect_properties[i] = ACTION_OTHER;
1135 sound_info[i].loop = FALSE;
1137 /* determine all loop sounds and identify certain sound classes */
1139 for (j=0; element_action_info[j].suffix; j++)
1141 int len_action_text = strlen(element_action_info[j].suffix);
1143 if (len_action_text < len_effect_text &&
1144 strcmp(&sound->token[len_effect_text - len_action_text],
1145 element_action_info[j].suffix) == 0)
1147 sound_effect_properties[i] = element_action_info[j].value;
1149 if (element_action_info[j].is_loop_sound)
1150 sound_info[i].loop = TRUE;
1154 /* associate elements and some selected sound actions */
1156 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1158 if (element_info[j].sound_class_name)
1160 int len_class_text = strlen(element_info[j].sound_class_name);
1162 if (len_class_text + 1 < len_effect_text &&
1163 strncmp(sound->token,
1164 element_info[j].sound_class_name, len_class_text) == 0 &&
1165 sound->token[len_class_text] == '.')
1167 int sound_action_value = sound_effect_properties[i];
1169 element_info[j].sound[sound_action_value] = i;
1174 set_sound_parameters(i, sound->parameter);
1177 free(sound_effect_properties);
1182 int element = EL_SAND;
1183 int sound_action = ACTION_DIGGING;
1186 while (element_action_info[j].suffix)
1188 if (element_action_info[j].value == sound_action)
1189 printf("element %d, sound action '%s' == %d\n",
1190 element, element_action_info[j].suffix,
1191 element_info_[element].sound[sound_action]);
1198 void InitElementProperties()
1202 static int ep_amoebalive[] =
1209 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1211 static int ep_amoeboid[] =
1219 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1221 static int ep_schluessel[] =
1232 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1234 static int ep_pforte[] =
1253 EL_SWITCHGATE_OPENING,
1254 EL_SWITCHGATE_CLOSED,
1255 EL_SWITCHGATE_CLOSING,
1257 EL_TIMEGATE_OPENING,
1259 EL_TIMEGATE_CLOSING,
1263 EL_TUBE_VERTICAL_LEFT,
1264 EL_TUBE_VERTICAL_RIGHT,
1265 EL_TUBE_HORIZONTAL_UP,
1266 EL_TUBE_HORIZONTAL_DOWN,
1272 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1274 static int ep_solid[] =
1294 EL_QUICKSAND_FILLING,
1295 EL_QUICKSAND_EMPTYING,
1297 EL_MAGIC_WALL_ACTIVE,
1298 EL_MAGIC_WALL_EMPTYING,
1299 EL_MAGIC_WALL_FILLING,
1303 EL_BD_MAGIC_WALL_ACTIVE,
1304 EL_BD_MAGIC_WALL_EMPTYING,
1305 EL_BD_MAGIC_WALL_FULL,
1306 EL_BD_MAGIC_WALL_FILLING,
1307 EL_BD_MAGIC_WALL_DEAD,
1310 EL_ACIDPOOL_TOPLEFT,
1311 EL_ACIDPOOL_TOPRIGHT,
1312 EL_ACIDPOOL_BOTTOMLEFT,
1314 EL_ACIDPOOL_BOTTOMRIGHT,
1332 EL_SP_TERMINAL_ACTIVE,
1335 EL_INVISIBLE_STEELWALL,
1336 EL_INVISIBLE_STEELWALL_ACTIVE,
1338 EL_INVISIBLE_WALL_ACTIVE,
1339 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1340 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1341 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1342 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1343 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1344 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1345 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1346 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1347 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1348 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1349 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1350 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1351 EL_SWITCHGATE_SWITCH_UP,
1352 EL_SWITCHGATE_SWITCH_DOWN,
1354 EL_LIGHT_SWITCH_ACTIVE,
1356 EL_TIMEGATE_SWITCH_ACTIVE,
1357 EL_SIGN_EXCLAMATION,
1358 EL_SIGN_RADIOACTIVITY,
1369 EL_STEELWALL_SLANTED,
1374 EL_EMC_WALL_PILLAR_UPPER,
1375 EL_EMC_WALL_PILLAR_MIDDLE,
1376 EL_EMC_WALL_PILLAR_LOWER,
1402 EL_SWITCHGATE_OPENING,
1403 EL_SWITCHGATE_CLOSED,
1404 EL_SWITCHGATE_CLOSING,
1406 EL_TIMEGATE_OPENING,
1408 EL_TIMEGATE_CLOSING,
1412 EL_TUBE_VERTICAL_LEFT,
1413 EL_TUBE_VERTICAL_RIGHT,
1414 EL_TUBE_HORIZONTAL_UP,
1415 EL_TUBE_HORIZONTAL_DOWN,
1421 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1423 static int ep_massive[] =
1427 EL_ACIDPOOL_TOPLEFT,
1428 EL_ACIDPOOL_TOPRIGHT,
1429 EL_ACIDPOOL_BOTTOMLEFT,
1431 EL_ACIDPOOL_BOTTOMRIGHT,
1443 EL_INVISIBLE_STEELWALL,
1444 EL_INVISIBLE_STEELWALL_ACTIVE,
1445 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1446 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1447 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1448 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1449 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1450 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1451 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1452 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1453 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1454 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1455 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1456 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1458 EL_LIGHT_SWITCH_ACTIVE,
1459 EL_SIGN_EXCLAMATION,
1460 EL_SIGN_RADIOACTIVITY,
1471 EL_STEELWALL_SLANTED,
1494 EL_SWITCHGATE_OPENING,
1495 EL_SWITCHGATE_CLOSED,
1496 EL_SWITCHGATE_CLOSING,
1498 EL_TIMEGATE_OPENING,
1500 EL_TIMEGATE_CLOSING,
1504 EL_TUBE_VERTICAL_LEFT,
1505 EL_TUBE_VERTICAL_RIGHT,
1506 EL_TUBE_HORIZONTAL_UP,
1507 EL_TUBE_HORIZONTAL_DOWN,
1513 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1515 static int ep_slippery[] =
1529 EL_ROBOT_WHEEL_ACTIVE,
1535 EL_ACIDPOOL_TOPLEFT,
1536 EL_ACIDPOOL_TOPRIGHT,
1546 EL_STEELWALL_SLANTED,
1550 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1552 static int ep_enemy[] =
1565 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1567 static int ep_mauer[] =
1595 EL_WALL_GROWING_ACTIVE,
1614 EL_SP_TERMINAL_ACTIVE,
1617 EL_INVISIBLE_STEELWALL,
1618 EL_INVISIBLE_STEELWALL_ACTIVE,
1620 EL_INVISIBLE_WALL_ACTIVE,
1621 EL_STEELWALL_SLANTED,
1626 EL_EMC_WALL_PILLAR_UPPER,
1627 EL_EMC_WALL_PILLAR_MIDDLE,
1628 EL_EMC_WALL_PILLAR_LOWER,
1635 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1637 static int ep_can_fall[] =
1652 EL_BD_MAGIC_WALL_FULL,
1663 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1665 static int ep_can_smash[] =
1696 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1698 static int ep_can_change[] =
1709 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1711 static int ep_can_move[] =
1731 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1733 static int ep_could_move[] =
1743 EL_BD_BUTTERFLY_RIGHT,
1745 EL_BD_BUTTERFLY_LEFT,
1746 EL_BD_BUTTERFLY_DOWN,
1747 EL_BD_FIREFLY_RIGHT,
1756 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1758 static int ep_dont_touch[] =
1765 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1767 static int ep_dont_go_to[] =
1781 EL_SP_BUGGY_BASE_ACTIVE,
1785 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1787 static int ep_mampf2[] =
1812 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1814 static int ep_bd_element[] =
1841 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1843 static int ep_sb_element[] =
1848 EL_SOKOBAN_FIELD_EMPTY,
1849 EL_SOKOBAN_FIELD_FULL,
1851 EL_INVISIBLE_STEELWALL
1853 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1855 static int ep_gem[] =
1864 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1866 static int ep_inactive[] =
1903 EL_INVISIBLE_STEELWALL,
1911 EL_WALL_EMERALD_YELLOW,
1916 EL_SOKOBAN_FIELD_EMPTY,
1917 EL_SOKOBAN_FIELD_FULL,
1918 EL_WALL_EMERALD_RED,
1919 EL_WALL_EMERALD_PURPLE,
1920 EL_ACIDPOOL_TOPLEFT,
1921 EL_ACIDPOOL_TOPRIGHT,
1922 EL_ACIDPOOL_BOTTOMLEFT,
1924 EL_ACIDPOOL_BOTTOMRIGHT,
1928 EL_BD_MAGIC_WALL_DEAD,
1929 EL_AMOEBA_TO_DIAMOND,
1962 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1963 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1964 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1965 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1966 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1967 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1968 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1969 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1970 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1971 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1972 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1973 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1974 EL_SIGN_EXCLAMATION,
1975 EL_SIGN_RADIOACTIVITY,
1986 EL_STEELWALL_SLANTED,
1991 EL_EMC_WALL_PILLAR_UPPER,
1992 EL_EMC_WALL_PILLAR_MIDDLE,
1993 EL_EMC_WALL_PILLAR_LOWER,
2000 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
2002 static int ep_explosive[] =
2007 EL_DYNABOMB_PLAYER1_ACTIVE,
2008 EL_DYNABOMB_PLAYER2_ACTIVE,
2009 EL_DYNABOMB_PLAYER3_ACTIVE,
2010 EL_DYNABOMB_PLAYER4_ACTIVE,
2027 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
2029 static int ep_mampf3[] =
2040 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
2042 static int ep_pushable[] =
2049 EL_SOKOBAN_FIELD_FULL,
2059 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
2061 static int ep_player[] =
2068 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
2070 static int ep_has_content[] =
2078 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
2080 static int ep_eatable[] =
2085 EL_SP_BUGGY_BASE_ACTIVATING,
2088 EL_INVISIBLE_SAND_ACTIVE
2090 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
2092 static int ep_sp_element[] =
2135 /* additional elements that appeared in newer Supaplex levels */
2137 /* more than one murphy in a level results in an inactive clone */
2140 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2142 static int ep_quick_gate[] =
2166 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2168 static int ep_over_player[] =
2184 EL_TUBE_VERTICAL_LEFT,
2185 EL_TUBE_VERTICAL_RIGHT,
2186 EL_TUBE_HORIZONTAL_UP,
2187 EL_TUBE_HORIZONTAL_DOWN,
2193 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2195 static int ep_active_bomb[] =
2198 EL_DYNABOMB_PLAYER1_ACTIVE,
2199 EL_DYNABOMB_PLAYER2_ACTIVE,
2200 EL_DYNABOMB_PLAYER3_ACTIVE,
2201 EL_DYNABOMB_PLAYER4_ACTIVE
2203 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2205 static int ep_belt[] =
2207 EL_CONVEYOR_BELT1_LEFT,
2208 EL_CONVEYOR_BELT1_MIDDLE,
2209 EL_CONVEYOR_BELT1_RIGHT,
2210 EL_CONVEYOR_BELT2_LEFT,
2211 EL_CONVEYOR_BELT2_MIDDLE,
2212 EL_CONVEYOR_BELT2_RIGHT,
2213 EL_CONVEYOR_BELT3_LEFT,
2214 EL_CONVEYOR_BELT3_MIDDLE,
2215 EL_CONVEYOR_BELT3_RIGHT,
2216 EL_CONVEYOR_BELT4_LEFT,
2217 EL_CONVEYOR_BELT4_MIDDLE,
2218 EL_CONVEYOR_BELT4_RIGHT,
2220 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2222 static int ep_belt_active[] =
2224 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2225 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2226 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2227 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2228 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2229 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2230 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2231 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2232 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2233 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2234 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2235 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2237 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2239 static int ep_belt_switch[] =
2241 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2242 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2243 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2244 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2245 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2246 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2247 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2248 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2249 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2250 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2251 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2252 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2254 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2256 static int ep_tube[] =
2261 EL_TUBE_VERTICAL_LEFT,
2262 EL_TUBE_VERTICAL_RIGHT,
2263 EL_TUBE_HORIZONTAL_UP,
2264 EL_TUBE_HORIZONTAL_DOWN,
2270 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2272 static long ep1_bit[] =
2306 static long ep2_bit[] =
2313 static int *ep1_array[] =
2347 static int *ep2_array[] =
2354 static int *ep1_num[] =
2381 &ep_has_content_num,
2385 &ep_over_player_num,
2388 static int *ep2_num[] =
2391 &ep_belt_active_num,
2392 &ep_belt_switch_num,
2395 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2396 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2398 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2404 for (i=0; i<num_properties1; i++)
2405 for (j=0; j<*(ep1_num[i]); j++)
2406 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2407 for (i=0; i<num_properties2; i++)
2408 for (j=0; j<*(ep2_num[i]); j++)
2409 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2411 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2412 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2415 void Execute_Command(char *command)
2417 if (strcmp(command, "print graphicsinfo.conf") == 0)
2421 printf("# You can configure additional/alternative image files here.\n");
2422 printf("# (The images below are default and therefore commented out.)\n");
2424 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2426 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2429 for (i=0; image_config[i].token != NULL; i++)
2431 getFormattedSetupEntry(image_config[i].token,
2432 image_config[i].value));
2436 else if (strcmp(command, "print soundsinfo.conf") == 0)
2440 printf("# You can configure additional/alternative sound files here.\n");
2441 printf("# (The sounds below are default and therefore commented out.)\n");
2443 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2445 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2448 for (i=0; sound_config[i].token != NULL; i++)
2450 getFormattedSetupEntry(sound_config[i].token,
2451 sound_config[i].value));
2455 else if (strcmp(command, "print musicinfo.conf") == 0)
2457 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2459 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2461 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2465 else if (strncmp(command, "dump level ", 11) == 0)
2467 char *filename = &command[11];
2469 if (access(filename, F_OK) != 0)
2470 Error(ERR_EXIT, "cannot open file '%s'", filename);
2472 LoadLevelFromFilename(filename);
2477 else if (strncmp(command, "dump tape ", 10) == 0)
2479 char *filename = &command[10];
2481 if (access(filename, F_OK) != 0)
2482 Error(ERR_EXIT, "cannot open file '%s'", filename);
2484 LoadTapeFromFilename(filename);
2489 else if (strncmp(command, "autoplay ", 9) == 0)
2491 char *str_copy = getStringCopy(&command[9]);
2492 char *str_ptr = strchr(str_copy, ' ');
2494 global.autoplay_leveldir = str_copy;
2495 global.autoplay_level_nr = -1;
2497 if (str_ptr != NULL)
2499 *str_ptr++ = '\0'; /* terminate leveldir string */
2500 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2505 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2509 void CloseAllAndExit(int exit_value)
2514 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2517 FreeTileClipmasks();
2519 if (bitmap_font_initial)
2520 FreeBitmap(bitmap_font_initial);
2522 CloseVideoDisplay();
2523 ClosePlatformDependantStuff();