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 InitElementSmallImages();
77 static void InitElementGraphicInfo();
78 static void InitElementSpecialGraphicInfo();
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 InitElementSpecialGraphicInfo(); /* element special graphic mapping */
253 InitGraphicInfo(); /* graphic properties mapping */
255 InitElementSmallImages(); /* create editor and preview images */
257 InitFontInfo(bitmap_font_initial,
258 graphic_info[IMG_FONT_BIG].bitmap,
259 graphic_info[IMG_FONT_MEDIUM].bitmap,
260 graphic_info[IMG_FONT_SMALL].bitmap,
261 graphic_info[IMG_FONT_EM].bitmap);
263 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
264 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
270 static void ReinitializeSounds()
272 InitElementSoundInfo(); /* element game sound mapping */
273 InitSoundInfo(); /* sound properties mapping */
275 InitPlaySoundLevel(); /* internal game sound settings */
278 static void ReinitializeMusic()
280 /* currently nothing to do */
283 static void InitImages()
285 ReloadCustomImages();
286 ReinitializeGraphics();
288 LoadCustomElementDescriptions();
289 LoadSpecialMenuDesignSettings();
292 static void InitSound()
294 InitReloadCustomSounds(artwork.snd_current->identifier);
295 ReinitializeSounds();
298 static void InitMusic()
300 InitReloadCustomMusic(artwork.mus_current->identifier);
304 static void InitTileClipmasks()
307 #if defined(TARGET_X11)
308 XGCValues clip_gc_values;
309 unsigned long clip_gc_valuemask;
311 #if defined(TARGET_X11_NATIVE)
321 tile_needs_clipping[] =
323 { GFX_SPIELER1_UP, 4 },
324 { GFX_SPIELER1_DOWN, 4 },
325 { GFX_SPIELER1_LEFT, 4 },
326 { GFX_SPIELER1_RIGHT, 4 },
327 { GFX_SPIELER1_PUSH_LEFT, 4 },
328 { GFX_SPIELER1_PUSH_RIGHT, 4 },
329 { GFX_SPIELER2_UP, 4 },
330 { GFX_SPIELER2_DOWN, 4 },
331 { GFX_SPIELER2_LEFT, 4 },
332 { GFX_SPIELER2_RIGHT, 4 },
333 { GFX_SPIELER2_PUSH_LEFT, 4 },
334 { GFX_SPIELER2_PUSH_RIGHT, 4 },
335 { GFX_SPIELER3_UP, 4 },
336 { GFX_SPIELER3_DOWN, 4 },
337 { GFX_SPIELER3_LEFT, 4 },
338 { GFX_SPIELER3_RIGHT, 4 },
339 { GFX_SPIELER3_PUSH_LEFT, 4 },
340 { GFX_SPIELER3_PUSH_RIGHT, 4 },
341 { GFX_SPIELER4_UP, 4 },
342 { GFX_SPIELER4_DOWN, 4 },
343 { GFX_SPIELER4_LEFT, 4 },
344 { GFX_SPIELER4_RIGHT, 4 },
345 { GFX_SPIELER4_PUSH_LEFT, 4 },
346 { GFX_SPIELER4_PUSH_RIGHT, 4 },
347 { GFX_SP_MURPHY, 1 },
348 { GFX_MURPHY_GO_LEFT, 3 },
349 { GFX_MURPHY_GO_RIGHT, 3 },
350 { GFX_MURPHY_SNAP_UP, 1 },
351 { GFX_MURPHY_SNAP_DOWN, 1 },
352 { GFX_MURPHY_SNAP_RIGHT, 1 },
353 { GFX_MURPHY_SNAP_LEFT, 1 },
354 { GFX_MURPHY_PUSH_RIGHT, 1 },
355 { GFX_MURPHY_PUSH_LEFT, 1 },
356 { GFX_GEBLUBBER, 4 },
359 { GFX_EXPLOSION, 8 },
360 { GFX_SOKOBAN_OBJEKT, 1 },
361 { GFX_FUNKELN_BLAU, 3 },
362 { GFX_FUNKELN_WEISS, 3 },
363 { GFX2_SHIELD_PASSIVE, 3 },
364 { GFX2_SHIELD_ACTIVE, 3 },
369 #endif /* TARGET_X11_NATIVE */
370 #endif /* TARGET_X11 */
374 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
375 for (i=0; i<NUM_TILES; i++)
376 tile_clipmask[i] = None;
378 #if defined(TARGET_X11)
379 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
380 often very slow when preparing a masked XCopyArea() for big Pixmaps.
381 To prevent this, create small (tile-sized) mask Pixmaps which will then
382 be set much faster with XSetClipOrigin() and speed things up a lot. */
384 clip_gc_values.graphics_exposures = False;
385 clip_gc_valuemask = GCGraphicsExposures;
386 tile_clip_gc = XCreateGC(display, window->drawable,
387 clip_gc_valuemask, &clip_gc_values);
390 for (i=0; i<NUM_BITMAPS; i++)
392 if (pix[i]->clip_mask)
394 clip_gc_values.graphics_exposures = False;
395 clip_gc_values.clip_mask = pix[i]->clip_mask;
396 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
397 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
398 clip_gc_valuemask, &clip_gc_values);
403 #if defined(TARGET_X11_NATIVE)
406 /* create graphic context structures needed for clipping */
407 clip_gc_values.graphics_exposures = False;
408 clip_gc_valuemask = GCGraphicsExposures;
409 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
410 clip_gc_valuemask, &clip_gc_values);
412 /* create only those clipping Pixmaps we really need */
413 for (i=0; tile_needs_clipping[i].start>=0; i++)
417 for (j=0; j<tile_needs_clipping[i].count; j++)
419 int tile = tile_needs_clipping[i].start + j;
425 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
426 src_pixmap = src_bitmap->clip_mask;
428 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
431 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
432 src_x, src_y, TILEX, TILEY, 0, 0);
436 XFreeGC(display, copy_clipmask_gc);
439 #endif /* TARGET_X11_NATIVE */
440 #endif /* TARGET_X11 */
444 void FreeTileClipmasks()
447 #if defined(TARGET_X11)
450 for (i=0; i<NUM_TILES; i++)
452 if (tile_clipmask[i] != None)
454 XFreePixmap(display, tile_clipmask[i]);
455 tile_clipmask[i] = None;
460 XFreeGC(display, tile_clip_gc);
464 for (i=0; i<NUM_BITMAPS; i++)
466 if (pix[i] != NULL && pix[i]->stored_clip_gc)
468 XFreeGC(display, pix[i]->stored_clip_gc);
469 pix[i]->stored_clip_gc = None;
474 #endif /* TARGET_X11 */
484 /* initialize screen properties */
485 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
486 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
487 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
488 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
489 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
491 /* create additional image buffers for double-buffering */
492 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
493 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
496 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
498 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
500 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
502 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
505 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
506 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
508 DrawInitText("Loading graphics:", 120, FC_GREEN);
511 for (i=0; i<NUM_PICTURES; i++)
514 if (i != PIX_FONT_SMALL)
517 DrawInitText(image_filename[i], 150, FC_YELLOW);
519 pix[i] = LoadCustomImage(image_filename[i]);
525 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
532 void InitGfxBackground()
537 fieldbuffer = bitmap_db_field;
538 SetDrawtoField(DRAW_BACKBUFFER);
540 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
541 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
542 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
543 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
545 for (x=0; x<MAX_BUF_XSIZE; x++)
546 for (y=0; y<MAX_BUF_YSIZE; y++)
549 redraw_mask = REDRAW_ALL;
552 void ReloadCustomArtwork()
554 static char *leveldir_current_identifier = NULL;
555 static boolean last_override_level_graphics = FALSE;
556 static boolean last_override_level_sounds = FALSE;
557 static boolean last_override_level_music = FALSE;
558 /* identifier for new artwork; default: artwork configured in setup */
559 char *gfx_new_identifier = artwork.gfx_current->identifier;
560 char *snd_new_identifier = artwork.snd_current->identifier;
561 char *mus_new_identifier = artwork.mus_current->identifier;
562 boolean redraw_screen = FALSE;
564 if (leveldir_current_identifier == NULL)
565 leveldir_current_identifier = leveldir_current->identifier;
568 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
569 leveldir_current->graphics_set);
570 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
571 leveldir_current->identifier);
575 printf("graphics --> '%s' ('%s')\n",
576 artwork.gfx_current_identifier, artwork.gfx_current->filename);
577 printf("sounds --> '%s' ('%s')\n",
578 artwork.snd_current_identifier, artwork.snd_current->filename);
579 printf("music --> '%s' ('%s')\n",
580 artwork.mus_current_identifier, artwork.mus_current->filename);
583 /* leveldir_current may be invalid (level group, parent link) */
584 if (!validLevelSeries(leveldir_current))
587 /* when a new level series was selected, check if there was a change
588 in custom artwork stored in level series directory */
589 if (leveldir_current_identifier != leveldir_current->identifier)
591 char *identifier_old = leveldir_current_identifier;
592 char *identifier_new = leveldir_current->identifier;
594 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
595 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
596 gfx_new_identifier = identifier_new;
597 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
598 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
599 snd_new_identifier = identifier_new;
600 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
601 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
602 mus_new_identifier = identifier_new;
604 leveldir_current_identifier = leveldir_current->identifier;
607 /* custom level artwork configured in level series configuration file
608 always overrides custom level artwork stored in level series directory
609 and (level independant) custom artwork configured in setup menue */
610 if (leveldir_current->graphics_set != NULL)
611 gfx_new_identifier = leveldir_current->graphics_set;
612 if (leveldir_current->sounds_set != NULL)
613 snd_new_identifier = leveldir_current->sounds_set;
614 if (leveldir_current->music_set != NULL)
615 mus_new_identifier = leveldir_current->music_set;
617 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
618 last_override_level_graphics != setup.override_level_graphics)
621 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
622 artwork.gfx_current_identifier,
623 artwork.gfx_current->identifier,
627 setLevelArtworkDir(artwork.gfx_first);
629 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
631 ReloadCustomImages();
632 ReinitializeGraphics();
634 LoadCustomElementDescriptions();
635 LoadSpecialMenuDesignSettings();
640 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
641 last_override_level_graphics = setup.override_level_graphics;
643 redraw_screen = TRUE;
646 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
647 last_override_level_sounds != setup.override_level_sounds)
650 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
651 artwork.snd_current_identifier,
652 artwork.snd_current->identifier,
656 /* set artwork path to send it to the sound server process */
657 setLevelArtworkDir(artwork.snd_first);
659 InitReloadCustomSounds(snd_new_identifier);
660 ReinitializeSounds();
662 artwork.snd_current_identifier = artwork.snd_current->identifier;
663 last_override_level_sounds = setup.override_level_sounds;
665 redraw_screen = TRUE;
668 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
669 last_override_level_music != setup.override_level_music)
671 /* set artwork path to send it to the sound server process */
672 setLevelArtworkDir(artwork.mus_first);
674 InitReloadCustomMusic(mus_new_identifier);
677 artwork.mus_current_identifier = artwork.mus_current->identifier;
678 last_override_level_music = setup.override_level_music;
680 redraw_screen = TRUE;
687 /* force redraw of (open or closed) door graphics */
688 SetDoorState(DOOR_OPEN_ALL);
689 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
695 FreeLevelEditorGadgets();
704 static boolean gadgets_initialized = FALSE;
706 if (gadgets_initialized)
709 CreateLevelEditorGadgets();
713 CreateScreenGadgets();
715 gadgets_initialized = TRUE;
718 void InitElementSmallImages()
720 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
721 int num_property_mappings = getImageListPropertyMappingSize();
724 /* initialize normal images from static configuration */
725 for (i=0; element_to_graphic[i].element > -1; i++)
726 CreateImageWithSmallImages(element_to_graphic[i].graphic);
728 /* initialize special images from static configuration */
729 for (i=0; element_to_special_graphic[i].element > -1; i++)
730 CreateImageWithSmallImages(element_to_special_graphic[i].graphic);
732 /* initialize images from dynamic configuration */
733 for (i=0; i < num_property_mappings; i++)
734 CreateImageWithSmallImages(property_mapping[i].artwork_index);
737 void InitElementGraphicInfo()
739 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
740 int num_property_mappings = getImageListPropertyMappingSize();
743 /* set values to -1 to identify later as "uninitialized" values */
744 for (i=0; i<MAX_NUM_ELEMENTS; i++)
746 for (act=0; act<NUM_ACTIONS; act++)
748 element_info[i].graphic[act] = -1;
750 for (dir=0; dir<NUM_DIRECTIONS; dir++)
751 element_info[i].direction_graphic[act][dir] = -1;
755 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
756 element_info[i].graphic[ACTION_DEFAULT] =
757 IMG_CHAR_START + (i - EL_CHAR_START);
759 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
760 element_info[i].graphic[ACTION_DEFAULT] =
761 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
763 /* initialize normal element/graphic mapping from static configuration */
764 for (i=0; element_to_graphic[i].element > -1; i++)
766 int element = element_to_graphic[i].element;
767 int action = element_to_graphic[i].action;
768 int direction = element_to_graphic[i].direction;
769 int graphic = element_to_graphic[i].graphic;
772 action = ACTION_DEFAULT;
775 element_info[element].direction_graphic[action][direction] = graphic;
777 element_info[element].graphic[action] = graphic;
780 /* initialize normal element/graphic mapping from dynamic configuration */
781 for (i=0; i < num_property_mappings; i++)
783 int element = property_mapping[i].base_index;
784 int action = property_mapping[i].ext1_index;
785 int direction = property_mapping[i].ext2_index;
786 int special = property_mapping[i].ext3_index;
787 int graphic = property_mapping[i].artwork_index;
793 action = ACTION_DEFAULT;
796 element_info[element].direction_graphic[action][direction] = graphic;
798 element_info[element].graphic[action] = graphic;
801 /* now set all '-1' values to element specific default values */
802 for (i=0; i<MAX_NUM_ELEMENTS; i++)
804 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
805 int default_action_direction_graphic[NUM_DIRECTIONS];
807 if (default_action_graphic == -1)
808 default_action_graphic = IMG_CHAR_QUESTION;
810 for (dir=0; dir<NUM_DIRECTIONS; dir++)
812 default_action_direction_graphic[dir] =
813 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
815 if (default_action_direction_graphic[dir] == -1)
816 default_action_direction_graphic[dir] = default_action_graphic;
819 for (act=0; act<NUM_ACTIONS; act++)
821 for (dir=0; dir<NUM_DIRECTIONS; dir++)
823 int default_direction_graphic = element_info[i].graphic[act];
825 /* no graphic for current action -- use default direction graphic */
826 if (default_direction_graphic == -1)
827 default_direction_graphic = default_action_direction_graphic[dir];
829 if (element_info[i].direction_graphic[act][dir] == -1)
830 element_info[i].direction_graphic[act][dir] =
831 default_direction_graphic;
834 /* no graphic for this specific action -- use default action graphic */
835 if (element_info[i].graphic[act] == -1)
836 element_info[i].graphic[act] = default_action_graphic;
844 for (i=0; i<MAX_NUM_ELEMENTS; i++)
845 if (element_info[i].graphic[ACTION_DEFAULT] == IMG_CHAR_QUESTION &&
846 i != EL_CHAR_QUESTION)
847 Error(ERR_RETURN, "warning: no graphic for element '%s' (%d)",
848 element_info[i].token_name, i);
854 void InitElementSpecialGraphicInfo()
856 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
857 int num_property_mappings = getImageListPropertyMappingSize();
860 /* always start with reliable default values */
861 for (i=0; i<MAX_NUM_ELEMENTS; i++)
863 element_info[i].editor_graphic = element_info[i].graphic[ACTION_DEFAULT];
864 element_info[i].preview_graphic = element_info[i].graphic[ACTION_DEFAULT];
867 /* initialize special element/graphic mapping from static configuration */
868 for (i=0; element_to_special_graphic[i].element > -1; i++)
870 int element = element_to_special_graphic[i].element;
871 int special = element_to_special_graphic[i].special;
872 int graphic = element_to_special_graphic[i].graphic;
874 if (special == GFX_SPECIAL_ARG_EDITOR)
875 element_info[element].editor_graphic = graphic;
876 else if (special == GFX_SPECIAL_ARG_PREVIEW)
877 element_info[element].preview_graphic = graphic;
880 /* initialize special element/graphic mapping from dynamic configuration */
881 for (i=0; i < num_property_mappings; i++)
883 int element = property_mapping[i].base_index;
884 int special = property_mapping[i].ext3_index;
885 int graphic = property_mapping[i].artwork_index;
887 if (special == GFX_SPECIAL_ARG_EDITOR)
888 element_info[element].editor_graphic = graphic;
889 else if (special == GFX_SPECIAL_ARG_PREVIEW)
890 element_info[element].preview_graphic = graphic;
894 static void InitElementSoundInfo()
899 static void set_graphic_parameters(int graphic, int *parameter)
901 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
902 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
903 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
905 graphic_info[graphic].bitmap = src_bitmap;
907 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
908 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
909 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
910 graphic_info[graphic].offset_y = 0;
912 /* animation frames are ordered vertically instead of horizontally */
913 if (parameter[GFX_ARG_VERTICAL])
915 graphic_info[graphic].offset_x = 0;
916 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
919 /* optionally, the x and y offset of frames can be specified directly */
920 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
921 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
922 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
923 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
925 /* automatically determine correct number of frames, if not defined */
926 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
927 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
928 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
929 graphic_info[graphic].anim_frames = num_xtiles;
930 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
931 graphic_info[graphic].anim_frames = num_ytiles;
933 graphic_info[graphic].anim_frames = 1;
935 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
936 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
937 graphic_info[graphic].anim_delay = 1;
939 /* set mode for animation frame order */
940 if (parameter[GFX_ARG_MODE_LOOP])
941 graphic_info[graphic].anim_mode = ANIM_LOOP;
942 else if (parameter[GFX_ARG_MODE_LINEAR])
943 graphic_info[graphic].anim_mode = ANIM_LINEAR;
944 else if (parameter[GFX_ARG_MODE_PINGPONG])
945 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
946 else if (parameter[GFX_ARG_MODE_PINGPONG2])
947 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
948 else if (parameter[GFX_ARG_MODE_RANDOM])
949 graphic_info[graphic].anim_mode = ANIM_RANDOM;
950 else if (graphic_info[graphic].anim_frames > 1)
951 graphic_info[graphic].anim_mode = ANIM_LOOP;
953 graphic_info[graphic].anim_mode = ANIM_NONE;
955 /* set additional flag to play animation frames in reverse order */
956 if (parameter[GFX_ARG_MODE_REVERSE])
957 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
959 /* automatically determine correct start frame, if not defined */
960 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
961 graphic_info[graphic].anim_start_frame = 0;
962 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
963 graphic_info[graphic].anim_start_frame =
964 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
966 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
968 /* animation synchronized with global frame counter, not move position */
969 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
972 static void InitGraphicInfo()
974 static boolean clipmasks_initialized = FALSE;
975 int num_images = getImageListSize();
977 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
979 XGCValues clip_gc_values;
980 unsigned long clip_gc_valuemask;
981 GC copy_clipmask_gc = None;
984 if (graphic_info != NULL)
987 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
989 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
990 if (clipmasks_initialized)
992 for (i=0; i<num_images; i++)
994 if (graphic_info[i].clip_mask)
995 XFreePixmap(display, graphic_info[i].clip_mask);
996 if (graphic_info[i].clip_gc)
997 XFreeGC(display, graphic_info[i].clip_gc);
999 graphic_info[i].clip_mask = None;
1000 graphic_info[i].clip_gc = None;
1005 for (i=0; i<num_images; i++)
1007 struct FileInfo *image = getImageListEntry(i);
1010 int first_frame, last_frame;
1012 set_graphic_parameters(i, image->parameter);
1014 /* now check if no animation frames are outside of the loaded image */
1016 if (graphic_info[i].bitmap == NULL)
1017 continue; /* skip check for optional images that are undefined */
1020 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1021 if (src_x < 0 || src_y < 0 ||
1022 src_x + TILEX > src_bitmap->width ||
1023 src_y + TILEY > src_bitmap->height)
1025 Error(ERR_RETURN_LINE, "-");
1026 Error(ERR_RETURN, "warning: error found in config file:");
1027 Error(ERR_RETURN, "- config file: '%s'",
1028 getImageConfigFilename());
1029 Error(ERR_RETURN, "- config token: '%s'",
1030 getTokenFromImageID(i));
1031 Error(ERR_RETURN, "- image file: '%s'",
1032 src_bitmap->source_filename);
1034 "error: first animation frame out of bounds (%d, %d)",
1036 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1037 Error(ERR_RETURN_LINE, "-");
1039 set_graphic_parameters(i, image->default_parameter);
1042 last_frame = graphic_info[i].anim_frames - 1;
1043 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
1044 if (src_x < 0 || src_y < 0 ||
1045 src_x + TILEX > src_bitmap->width ||
1046 src_y + TILEY > src_bitmap->height)
1048 Error(ERR_RETURN_LINE, "-");
1049 Error(ERR_RETURN, "warning: error found in config file:");
1050 Error(ERR_RETURN, "- config file: '%s'",
1051 getImageConfigFilename());
1052 Error(ERR_RETURN, "- config token: '%s'",
1053 getTokenFromImageID(i));
1054 Error(ERR_RETURN, "- image file: '%s'",
1055 src_bitmap->source_filename);
1057 "error: last animation frame (%d) out of bounds (%d, %d)",
1058 last_frame, src_x, src_y);
1059 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1060 Error(ERR_RETURN_LINE, "-");
1062 set_graphic_parameters(i, image->default_parameter);
1065 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1066 /* currently we need only a tile clip mask from the first frame */
1067 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1069 if (copy_clipmask_gc == None)
1071 clip_gc_values.graphics_exposures = False;
1072 clip_gc_valuemask = GCGraphicsExposures;
1073 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
1074 clip_gc_valuemask, &clip_gc_values);
1077 graphic_info[i].clip_mask =
1078 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
1080 src_pixmap = src_bitmap->clip_mask;
1081 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
1082 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
1084 clip_gc_values.graphics_exposures = False;
1085 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
1086 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
1087 graphic_info[i].clip_gc =
1088 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1092 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1093 if (copy_clipmask_gc)
1094 XFreeGC(display, copy_clipmask_gc);
1097 clipmasks_initialized = TRUE;
1100 static void set_sound_parameters(int sound, int *parameter)
1102 /* explicit loop mode setting in configuration overrides default value */
1103 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1104 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1107 static void InitSoundInfo()
1109 int *sound_effect_properties;
1110 int num_sounds = getSoundListSize();
1113 if (sound_info != NULL)
1116 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1117 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1119 /* initialize sound effect for all elements to "no sound" */
1120 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1121 for (j=0; j<NUM_ACTIONS; j++)
1122 element_info[i].sound[j] = SND_UNDEFINED;
1124 for (i=0; i<num_sounds; i++)
1126 struct FileInfo *sound = getSoundListEntry(i);
1127 int len_effect_text = strlen(sound->token);
1129 sound_effect_properties[i] = ACTION_OTHER;
1130 sound_info[i].loop = FALSE;
1132 /* determine all loop sounds and identify certain sound classes */
1134 for (j=0; element_action_info[j].suffix; j++)
1136 int len_action_text = strlen(element_action_info[j].suffix);
1138 if (len_action_text < len_effect_text &&
1139 strcmp(&sound->token[len_effect_text - len_action_text],
1140 element_action_info[j].suffix) == 0)
1142 sound_effect_properties[i] = element_action_info[j].value;
1144 if (element_action_info[j].is_loop_sound)
1145 sound_info[i].loop = TRUE;
1149 /* associate elements and some selected sound actions */
1151 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1153 if (element_info[j].sound_class_name)
1155 int len_class_text = strlen(element_info[j].sound_class_name);
1157 if (len_class_text + 1 < len_effect_text &&
1158 strncmp(sound->token,
1159 element_info[j].sound_class_name, len_class_text) == 0 &&
1160 sound->token[len_class_text] == '.')
1162 int sound_action_value = sound_effect_properties[i];
1164 element_info[j].sound[sound_action_value] = i;
1169 set_sound_parameters(i, sound->parameter);
1172 free(sound_effect_properties);
1177 int element = EL_SAND;
1178 int sound_action = ACTION_DIGGING;
1181 while (element_action_info[j].suffix)
1183 if (element_action_info[j].value == sound_action)
1184 printf("element %d, sound action '%s' == %d\n",
1185 element, element_action_info[j].suffix,
1186 element_info_[element].sound[sound_action]);
1193 void InitElementProperties()
1197 static int ep_amoebalive[] =
1204 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1206 static int ep_amoeboid[] =
1214 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1216 static int ep_schluessel[] =
1227 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1229 static int ep_pforte[] =
1248 EL_SWITCHGATE_OPENING,
1249 EL_SWITCHGATE_CLOSED,
1250 EL_SWITCHGATE_CLOSING,
1252 EL_TIMEGATE_OPENING,
1254 EL_TIMEGATE_CLOSING,
1258 EL_TUBE_VERTICAL_LEFT,
1259 EL_TUBE_VERTICAL_RIGHT,
1260 EL_TUBE_HORIZONTAL_UP,
1261 EL_TUBE_HORIZONTAL_DOWN,
1267 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1269 static int ep_solid[] =
1289 EL_QUICKSAND_FILLING,
1290 EL_QUICKSAND_EMPTYING,
1292 EL_MAGIC_WALL_ACTIVE,
1293 EL_MAGIC_WALL_EMPTYING,
1294 EL_MAGIC_WALL_FILLING,
1298 EL_BD_MAGIC_WALL_ACTIVE,
1299 EL_BD_MAGIC_WALL_EMPTYING,
1300 EL_BD_MAGIC_WALL_FULL,
1301 EL_BD_MAGIC_WALL_FILLING,
1302 EL_BD_MAGIC_WALL_DEAD,
1305 EL_ACIDPOOL_TOPLEFT,
1306 EL_ACIDPOOL_TOPRIGHT,
1307 EL_ACIDPOOL_BOTTOMLEFT,
1309 EL_ACIDPOOL_BOTTOMRIGHT,
1327 EL_SP_TERMINAL_ACTIVE,
1330 EL_INVISIBLE_STEELWALL,
1331 EL_INVISIBLE_STEELWALL_ACTIVE,
1333 EL_INVISIBLE_WALL_ACTIVE,
1334 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1335 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1336 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1337 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1338 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1339 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1340 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1341 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1342 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1343 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1344 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1345 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1346 EL_SWITCHGATE_SWITCH_UP,
1347 EL_SWITCHGATE_SWITCH_DOWN,
1349 EL_LIGHT_SWITCH_ACTIVE,
1351 EL_TIMEGATE_SWITCH_ACTIVE,
1352 EL_SIGN_EXCLAMATION,
1353 EL_SIGN_RADIOACTIVITY,
1364 EL_STEELWALL_SLANTED,
1369 EL_EMC_WALL_PILLAR_UPPER,
1370 EL_EMC_WALL_PILLAR_MIDDLE,
1371 EL_EMC_WALL_PILLAR_LOWER,
1397 EL_SWITCHGATE_OPENING,
1398 EL_SWITCHGATE_CLOSED,
1399 EL_SWITCHGATE_CLOSING,
1401 EL_TIMEGATE_OPENING,
1403 EL_TIMEGATE_CLOSING,
1407 EL_TUBE_VERTICAL_LEFT,
1408 EL_TUBE_VERTICAL_RIGHT,
1409 EL_TUBE_HORIZONTAL_UP,
1410 EL_TUBE_HORIZONTAL_DOWN,
1416 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1418 static int ep_massive[] =
1422 EL_ACIDPOOL_TOPLEFT,
1423 EL_ACIDPOOL_TOPRIGHT,
1424 EL_ACIDPOOL_BOTTOMLEFT,
1426 EL_ACIDPOOL_BOTTOMRIGHT,
1438 EL_INVISIBLE_STEELWALL,
1439 EL_INVISIBLE_STEELWALL_ACTIVE,
1440 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1441 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1442 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1443 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1444 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1445 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1446 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1447 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1448 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1449 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1450 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1451 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1453 EL_LIGHT_SWITCH_ACTIVE,
1454 EL_SIGN_EXCLAMATION,
1455 EL_SIGN_RADIOACTIVITY,
1466 EL_STEELWALL_SLANTED,
1489 EL_SWITCHGATE_OPENING,
1490 EL_SWITCHGATE_CLOSED,
1491 EL_SWITCHGATE_CLOSING,
1493 EL_TIMEGATE_OPENING,
1495 EL_TIMEGATE_CLOSING,
1499 EL_TUBE_VERTICAL_LEFT,
1500 EL_TUBE_VERTICAL_RIGHT,
1501 EL_TUBE_HORIZONTAL_UP,
1502 EL_TUBE_HORIZONTAL_DOWN,
1508 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1510 static int ep_slippery[] =
1524 EL_ROBOT_WHEEL_ACTIVE,
1530 EL_ACIDPOOL_TOPLEFT,
1531 EL_ACIDPOOL_TOPRIGHT,
1541 EL_STEELWALL_SLANTED,
1545 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1547 static int ep_enemy[] =
1560 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1562 static int ep_mauer[] =
1590 EL_WALL_GROWING_ACTIVE,
1609 EL_SP_TERMINAL_ACTIVE,
1612 EL_INVISIBLE_STEELWALL,
1613 EL_INVISIBLE_STEELWALL_ACTIVE,
1615 EL_INVISIBLE_WALL_ACTIVE,
1616 EL_STEELWALL_SLANTED,
1621 EL_EMC_WALL_PILLAR_UPPER,
1622 EL_EMC_WALL_PILLAR_MIDDLE,
1623 EL_EMC_WALL_PILLAR_LOWER,
1630 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1632 static int ep_can_fall[] =
1647 EL_BD_MAGIC_WALL_FULL,
1658 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1660 static int ep_can_smash[] =
1691 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1693 static int ep_can_change[] =
1704 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1706 static int ep_can_move[] =
1726 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1728 static int ep_could_move[] =
1738 EL_BD_BUTTERFLY_RIGHT,
1740 EL_BD_BUTTERFLY_LEFT,
1741 EL_BD_BUTTERFLY_DOWN,
1742 EL_BD_FIREFLY_RIGHT,
1751 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1753 static int ep_dont_touch[] =
1760 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1762 static int ep_dont_go_to[] =
1776 EL_SP_BUGGY_BASE_ACTIVE,
1780 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1782 static int ep_mampf2[] =
1807 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1809 static int ep_bd_element[] =
1836 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1838 static int ep_sb_element[] =
1843 EL_SOKOBAN_FIELD_EMPTY,
1844 EL_SOKOBAN_FIELD_FULL,
1846 EL_INVISIBLE_STEELWALL
1848 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1850 static int ep_gem[] =
1859 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1861 static int ep_inactive[] =
1898 EL_INVISIBLE_STEELWALL,
1906 EL_WALL_EMERALD_YELLOW,
1911 EL_SOKOBAN_FIELD_EMPTY,
1912 EL_SOKOBAN_FIELD_FULL,
1913 EL_WALL_EMERALD_RED,
1914 EL_WALL_EMERALD_PURPLE,
1915 EL_ACIDPOOL_TOPLEFT,
1916 EL_ACIDPOOL_TOPRIGHT,
1917 EL_ACIDPOOL_BOTTOMLEFT,
1919 EL_ACIDPOOL_BOTTOMRIGHT,
1923 EL_BD_MAGIC_WALL_DEAD,
1924 EL_AMOEBA_TO_DIAMOND,
1957 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1958 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1959 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1960 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1961 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1962 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1963 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1964 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1965 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1966 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1967 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1968 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1969 EL_SIGN_EXCLAMATION,
1970 EL_SIGN_RADIOACTIVITY,
1981 EL_STEELWALL_SLANTED,
1986 EL_EMC_WALL_PILLAR_UPPER,
1987 EL_EMC_WALL_PILLAR_MIDDLE,
1988 EL_EMC_WALL_PILLAR_LOWER,
1995 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1997 static int ep_explosive[] =
2002 EL_DYNABOMB_PLAYER1_ACTIVE,
2003 EL_DYNABOMB_PLAYER2_ACTIVE,
2004 EL_DYNABOMB_PLAYER3_ACTIVE,
2005 EL_DYNABOMB_PLAYER4_ACTIVE,
2022 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
2024 static int ep_mampf3[] =
2035 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
2037 static int ep_pushable[] =
2044 EL_SOKOBAN_FIELD_FULL,
2054 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
2056 static int ep_player[] =
2063 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
2065 static int ep_has_content[] =
2073 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
2075 static int ep_eatable[] =
2080 EL_SP_BUGGY_BASE_ACTIVATING,
2083 EL_INVISIBLE_SAND_ACTIVE
2085 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
2087 static int ep_sp_element[] =
2130 /* additional elements that appeared in newer Supaplex levels */
2132 /* more than one murphy in a level results in an inactive clone */
2135 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2137 static int ep_quick_gate[] =
2161 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2163 static int ep_over_player[] =
2179 EL_TUBE_VERTICAL_LEFT,
2180 EL_TUBE_VERTICAL_RIGHT,
2181 EL_TUBE_HORIZONTAL_UP,
2182 EL_TUBE_HORIZONTAL_DOWN,
2188 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2190 static int ep_active_bomb[] =
2193 EL_DYNABOMB_PLAYER1_ACTIVE,
2194 EL_DYNABOMB_PLAYER2_ACTIVE,
2195 EL_DYNABOMB_PLAYER3_ACTIVE,
2196 EL_DYNABOMB_PLAYER4_ACTIVE
2198 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2200 static int ep_belt[] =
2202 EL_CONVEYOR_BELT1_LEFT,
2203 EL_CONVEYOR_BELT1_MIDDLE,
2204 EL_CONVEYOR_BELT1_RIGHT,
2205 EL_CONVEYOR_BELT2_LEFT,
2206 EL_CONVEYOR_BELT2_MIDDLE,
2207 EL_CONVEYOR_BELT2_RIGHT,
2208 EL_CONVEYOR_BELT3_LEFT,
2209 EL_CONVEYOR_BELT3_MIDDLE,
2210 EL_CONVEYOR_BELT3_RIGHT,
2211 EL_CONVEYOR_BELT4_LEFT,
2212 EL_CONVEYOR_BELT4_MIDDLE,
2213 EL_CONVEYOR_BELT4_RIGHT,
2215 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2217 static int ep_belt_active[] =
2219 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2220 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2221 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2222 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2223 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2224 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2225 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2226 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2227 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2228 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2229 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2230 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2232 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2234 static int ep_belt_switch[] =
2236 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2237 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2238 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2239 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2240 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2241 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2242 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2243 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2244 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2245 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2246 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2247 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2249 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2251 static int ep_tube[] =
2256 EL_TUBE_VERTICAL_LEFT,
2257 EL_TUBE_VERTICAL_RIGHT,
2258 EL_TUBE_HORIZONTAL_UP,
2259 EL_TUBE_HORIZONTAL_DOWN,
2265 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2267 static long ep1_bit[] =
2301 static long ep2_bit[] =
2308 static int *ep1_array[] =
2342 static int *ep2_array[] =
2349 static int *ep1_num[] =
2376 &ep_has_content_num,
2380 &ep_over_player_num,
2383 static int *ep2_num[] =
2386 &ep_belt_active_num,
2387 &ep_belt_switch_num,
2390 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2391 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2393 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2399 for (i=0; i<num_properties1; i++)
2400 for (j=0; j<*(ep1_num[i]); j++)
2401 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2402 for (i=0; i<num_properties2; i++)
2403 for (j=0; j<*(ep2_num[i]); j++)
2404 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2406 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2407 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2410 void Execute_Command(char *command)
2412 if (strcmp(command, "print graphicsinfo.conf") == 0)
2416 printf("# You can configure additional/alternative image files here.\n");
2417 printf("# (The images below are default and therefore commented out.)\n");
2419 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2421 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2424 for (i=0; image_config[i].token != NULL; i++)
2426 getFormattedSetupEntry(image_config[i].token,
2427 image_config[i].value));
2431 else if (strcmp(command, "print soundsinfo.conf") == 0)
2435 printf("# You can configure additional/alternative sound files here.\n");
2436 printf("# (The sounds below are default and therefore commented out.)\n");
2438 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2440 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2443 for (i=0; sound_config[i].token != NULL; i++)
2445 getFormattedSetupEntry(sound_config[i].token,
2446 sound_config[i].value));
2450 else if (strcmp(command, "print musicinfo.conf") == 0)
2452 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2454 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2456 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2460 else if (strncmp(command, "dump level ", 11) == 0)
2462 char *filename = &command[11];
2464 if (access(filename, F_OK) != 0)
2465 Error(ERR_EXIT, "cannot open file '%s'", filename);
2467 LoadLevelFromFilename(filename);
2472 else if (strncmp(command, "dump tape ", 10) == 0)
2474 char *filename = &command[10];
2476 if (access(filename, F_OK) != 0)
2477 Error(ERR_EXIT, "cannot open file '%s'", filename);
2479 LoadTapeFromFilename(filename);
2484 else if (strncmp(command, "autoplay ", 9) == 0)
2486 char *str_copy = getStringCopy(&command[9]);
2487 char *str_ptr = strchr(str_copy, ' ');
2489 global.autoplay_leveldir = str_copy;
2490 global.autoplay_level_nr = -1;
2492 if (str_ptr != NULL)
2494 *str_ptr++ = '\0'; /* terminate leveldir string */
2495 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2500 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2504 void CloseAllAndExit(int exit_value)
2509 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2512 FreeTileClipmasks();
2514 if (bitmap_font_initial)
2515 FreeBitmap(bitmap_font_initial);
2517 CloseVideoDisplay();
2518 ClosePlatformDependantStuff();