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();
291 static void InitSound()
293 InitReloadCustomSounds(artwork.snd_current->identifier);
294 ReinitializeSounds();
297 static void InitMusic()
299 InitReloadCustomMusic(artwork.mus_current->identifier);
303 static void InitTileClipmasks()
306 #if defined(TARGET_X11)
307 XGCValues clip_gc_values;
308 unsigned long clip_gc_valuemask;
310 #if defined(TARGET_X11_NATIVE)
320 tile_needs_clipping[] =
322 { GFX_SPIELER1_UP, 4 },
323 { GFX_SPIELER1_DOWN, 4 },
324 { GFX_SPIELER1_LEFT, 4 },
325 { GFX_SPIELER1_RIGHT, 4 },
326 { GFX_SPIELER1_PUSH_LEFT, 4 },
327 { GFX_SPIELER1_PUSH_RIGHT, 4 },
328 { GFX_SPIELER2_UP, 4 },
329 { GFX_SPIELER2_DOWN, 4 },
330 { GFX_SPIELER2_LEFT, 4 },
331 { GFX_SPIELER2_RIGHT, 4 },
332 { GFX_SPIELER2_PUSH_LEFT, 4 },
333 { GFX_SPIELER2_PUSH_RIGHT, 4 },
334 { GFX_SPIELER3_UP, 4 },
335 { GFX_SPIELER3_DOWN, 4 },
336 { GFX_SPIELER3_LEFT, 4 },
337 { GFX_SPIELER3_RIGHT, 4 },
338 { GFX_SPIELER3_PUSH_LEFT, 4 },
339 { GFX_SPIELER3_PUSH_RIGHT, 4 },
340 { GFX_SPIELER4_UP, 4 },
341 { GFX_SPIELER4_DOWN, 4 },
342 { GFX_SPIELER4_LEFT, 4 },
343 { GFX_SPIELER4_RIGHT, 4 },
344 { GFX_SPIELER4_PUSH_LEFT, 4 },
345 { GFX_SPIELER4_PUSH_RIGHT, 4 },
346 { GFX_SP_MURPHY, 1 },
347 { GFX_MURPHY_GO_LEFT, 3 },
348 { GFX_MURPHY_GO_RIGHT, 3 },
349 { GFX_MURPHY_SNAP_UP, 1 },
350 { GFX_MURPHY_SNAP_DOWN, 1 },
351 { GFX_MURPHY_SNAP_RIGHT, 1 },
352 { GFX_MURPHY_SNAP_LEFT, 1 },
353 { GFX_MURPHY_PUSH_RIGHT, 1 },
354 { GFX_MURPHY_PUSH_LEFT, 1 },
355 { GFX_GEBLUBBER, 4 },
358 { GFX_EXPLOSION, 8 },
359 { GFX_SOKOBAN_OBJEKT, 1 },
360 { GFX_FUNKELN_BLAU, 3 },
361 { GFX_FUNKELN_WEISS, 3 },
362 { GFX2_SHIELD_PASSIVE, 3 },
363 { GFX2_SHIELD_ACTIVE, 3 },
368 #endif /* TARGET_X11_NATIVE */
369 #endif /* TARGET_X11 */
373 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
374 for (i=0; i<NUM_TILES; i++)
375 tile_clipmask[i] = None;
377 #if defined(TARGET_X11)
378 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
379 often very slow when preparing a masked XCopyArea() for big Pixmaps.
380 To prevent this, create small (tile-sized) mask Pixmaps which will then
381 be set much faster with XSetClipOrigin() and speed things up a lot. */
383 clip_gc_values.graphics_exposures = False;
384 clip_gc_valuemask = GCGraphicsExposures;
385 tile_clip_gc = XCreateGC(display, window->drawable,
386 clip_gc_valuemask, &clip_gc_values);
389 for (i=0; i<NUM_BITMAPS; i++)
391 if (pix[i]->clip_mask)
393 clip_gc_values.graphics_exposures = False;
394 clip_gc_values.clip_mask = pix[i]->clip_mask;
395 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
396 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
397 clip_gc_valuemask, &clip_gc_values);
402 #if defined(TARGET_X11_NATIVE)
405 /* create graphic context structures needed for clipping */
406 clip_gc_values.graphics_exposures = False;
407 clip_gc_valuemask = GCGraphicsExposures;
408 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
409 clip_gc_valuemask, &clip_gc_values);
411 /* create only those clipping Pixmaps we really need */
412 for (i=0; tile_needs_clipping[i].start>=0; i++)
416 for (j=0; j<tile_needs_clipping[i].count; j++)
418 int tile = tile_needs_clipping[i].start + j;
424 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
425 src_pixmap = src_bitmap->clip_mask;
427 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
430 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
431 src_x, src_y, TILEX, TILEY, 0, 0);
435 XFreeGC(display, copy_clipmask_gc);
438 #endif /* TARGET_X11_NATIVE */
439 #endif /* TARGET_X11 */
443 void FreeTileClipmasks()
446 #if defined(TARGET_X11)
449 for (i=0; i<NUM_TILES; i++)
451 if (tile_clipmask[i] != None)
453 XFreePixmap(display, tile_clipmask[i]);
454 tile_clipmask[i] = None;
459 XFreeGC(display, tile_clip_gc);
463 for (i=0; i<NUM_BITMAPS; i++)
465 if (pix[i] != NULL && pix[i]->stored_clip_gc)
467 XFreeGC(display, pix[i]->stored_clip_gc);
468 pix[i]->stored_clip_gc = None;
473 #endif /* TARGET_X11 */
483 /* initialize screen properties */
484 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
485 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
486 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
487 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
488 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
490 /* create additional image buffers for double-buffering */
491 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
492 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
495 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
497 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
499 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
501 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
504 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
505 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
507 DrawInitText("Loading graphics:", 120, FC_GREEN);
510 for (i=0; i<NUM_PICTURES; i++)
513 if (i != PIX_FONT_SMALL)
516 DrawInitText(image_filename[i], 150, FC_YELLOW);
518 pix[i] = LoadCustomImage(image_filename[i]);
524 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
531 void InitGfxBackground()
536 fieldbuffer = bitmap_db_field;
537 SetDrawtoField(DRAW_BACKBUFFER);
539 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
540 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
541 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
542 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
544 for (x=0; x<MAX_BUF_XSIZE; x++)
545 for (y=0; y<MAX_BUF_YSIZE; y++)
548 redraw_mask = REDRAW_ALL;
551 void ReloadCustomArtwork()
553 static char *leveldir_current_identifier = NULL;
554 static boolean last_override_level_graphics = FALSE;
555 static boolean last_override_level_sounds = FALSE;
556 static boolean last_override_level_music = FALSE;
557 /* identifier for new artwork; default: artwork configured in setup */
558 char *gfx_new_identifier = artwork.gfx_current->identifier;
559 char *snd_new_identifier = artwork.snd_current->identifier;
560 char *mus_new_identifier = artwork.mus_current->identifier;
561 boolean redraw_screen = FALSE;
563 if (leveldir_current_identifier == NULL)
564 leveldir_current_identifier = leveldir_current->identifier;
567 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
568 leveldir_current->graphics_set);
569 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
570 leveldir_current->identifier);
574 printf("graphics --> '%s' ('%s')\n",
575 artwork.gfx_current_identifier, artwork.gfx_current->filename);
576 printf("sounds --> '%s' ('%s')\n",
577 artwork.snd_current_identifier, artwork.snd_current->filename);
578 printf("music --> '%s' ('%s')\n",
579 artwork.mus_current_identifier, artwork.mus_current->filename);
582 /* leveldir_current may be invalid (level group, parent link) */
583 if (!validLevelSeries(leveldir_current))
586 /* when a new level series was selected, check if there was a change
587 in custom artwork stored in level series directory */
588 if (leveldir_current_identifier != leveldir_current->identifier)
590 char *identifier_old = leveldir_current_identifier;
591 char *identifier_new = leveldir_current->identifier;
593 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
594 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
595 gfx_new_identifier = identifier_new;
596 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
597 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
598 snd_new_identifier = identifier_new;
599 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
600 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
601 mus_new_identifier = identifier_new;
603 leveldir_current_identifier = leveldir_current->identifier;
606 /* custom level artwork configured in level series configuration file
607 always overrides custom level artwork stored in level series directory
608 and (level independant) custom artwork configured in setup menue */
609 if (leveldir_current->graphics_set != NULL)
610 gfx_new_identifier = leveldir_current->graphics_set;
611 if (leveldir_current->sounds_set != NULL)
612 snd_new_identifier = leveldir_current->sounds_set;
613 if (leveldir_current->music_set != NULL)
614 mus_new_identifier = leveldir_current->music_set;
616 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
617 last_override_level_graphics != setup.override_level_graphics)
620 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
621 artwork.gfx_current_identifier,
622 artwork.gfx_current->identifier,
626 setLevelArtworkDir(artwork.gfx_first);
628 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
630 ReloadCustomImages();
631 ReinitializeGraphics();
633 LoadCustomElementDescriptions();
638 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
639 last_override_level_graphics = setup.override_level_graphics;
641 redraw_screen = TRUE;
644 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
645 last_override_level_sounds != setup.override_level_sounds)
648 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
649 artwork.snd_current_identifier,
650 artwork.snd_current->identifier,
654 /* set artwork path to send it to the sound server process */
655 setLevelArtworkDir(artwork.snd_first);
657 InitReloadCustomSounds(snd_new_identifier);
658 ReinitializeSounds();
660 artwork.snd_current_identifier = artwork.snd_current->identifier;
661 last_override_level_sounds = setup.override_level_sounds;
663 redraw_screen = TRUE;
666 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
667 last_override_level_music != setup.override_level_music)
669 /* set artwork path to send it to the sound server process */
670 setLevelArtworkDir(artwork.mus_first);
672 InitReloadCustomMusic(mus_new_identifier);
675 artwork.mus_current_identifier = artwork.mus_current->identifier;
676 last_override_level_music = setup.override_level_music;
678 redraw_screen = TRUE;
685 /* force redraw of (open or closed) door graphics */
686 SetDoorState(DOOR_OPEN_ALL);
687 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
693 FreeLevelEditorGadgets();
702 static boolean gadgets_initialized = FALSE;
704 if (gadgets_initialized)
707 CreateLevelEditorGadgets();
711 CreateScreenGadgets();
713 gadgets_initialized = TRUE;
716 void InitElementSmallImages()
718 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
719 int num_property_mappings = getImageListPropertyMappingSize();
722 /* initialize normal images from static configuration */
723 for (i=0; element_to_graphic[i].element > -1; i++)
724 CreateImageWithSmallImages(element_to_graphic[i].graphic);
726 /* initialize special images from static configuration */
727 for (i=0; element_to_special_graphic[i].element > -1; i++)
728 CreateImageWithSmallImages(element_to_special_graphic[i].graphic);
730 /* initialize images from dynamic configuration */
731 for (i=0; i < num_property_mappings; i++)
732 CreateImageWithSmallImages(property_mapping[i].artwork_index);
735 void InitElementGraphicInfo()
737 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
738 int num_property_mappings = getImageListPropertyMappingSize();
741 /* set values to -1 to identify later as "uninitialized" values */
742 for (i=0; i<MAX_NUM_ELEMENTS; i++)
744 for (act=0; act<NUM_ACTIONS; act++)
746 element_info[i].graphic[act] = -1;
748 for (dir=0; dir<NUM_DIRECTIONS; dir++)
749 element_info[i].direction_graphic[act][dir] = -1;
753 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
754 element_info[i].graphic[ACTION_DEFAULT] =
755 IMG_CHAR_START + (i - EL_CHAR_START);
757 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
758 element_info[i].graphic[ACTION_DEFAULT] =
759 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
761 /* initialize normal element/graphic mapping from static configuration */
762 for (i=0; element_to_graphic[i].element > -1; i++)
764 int element = element_to_graphic[i].element;
765 int action = element_to_graphic[i].action;
766 int direction = element_to_graphic[i].direction;
767 int graphic = element_to_graphic[i].graphic;
770 action = ACTION_DEFAULT;
773 element_info[element].direction_graphic[action][direction] = graphic;
775 element_info[element].graphic[action] = graphic;
778 /* initialize normal element/graphic mapping from dynamic configuration */
779 for (i=0; i < num_property_mappings; i++)
781 int element = property_mapping[i].base_index;
782 int action = property_mapping[i].ext1_index;
783 int direction = property_mapping[i].ext2_index;
784 int special = property_mapping[i].ext3_index;
785 int graphic = property_mapping[i].artwork_index;
791 action = ACTION_DEFAULT;
794 element_info[element].direction_graphic[action][direction] = graphic;
796 element_info[element].graphic[action] = graphic;
799 /* now set all '-1' values to element specific default values */
800 for (i=0; i<MAX_NUM_ELEMENTS; i++)
802 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
803 int default_action_direction_graphic[NUM_DIRECTIONS];
805 if (default_action_graphic == -1)
806 default_action_graphic = IMG_CHAR_QUESTION;
808 for (dir=0; dir<NUM_DIRECTIONS; dir++)
810 default_action_direction_graphic[dir] =
811 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
813 if (default_action_direction_graphic[dir] == -1)
814 default_action_direction_graphic[dir] = default_action_graphic;
817 for (act=0; act<NUM_ACTIONS; act++)
819 for (dir=0; dir<NUM_DIRECTIONS; dir++)
821 int default_direction_graphic = element_info[i].graphic[act];
823 /* no graphic for current action -- use default direction graphic */
824 if (default_direction_graphic == -1)
825 default_direction_graphic = default_action_direction_graphic[dir];
827 if (element_info[i].direction_graphic[act][dir] == -1)
828 element_info[i].direction_graphic[act][dir] =
829 default_direction_graphic;
832 /* no graphic for this specific action -- use default action graphic */
833 if (element_info[i].graphic[act] == -1)
834 element_info[i].graphic[act] = default_action_graphic;
839 void InitElementSpecialGraphicInfo()
841 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
842 int num_property_mappings = getImageListPropertyMappingSize();
845 /* always start with reliable default values */
846 for (i=0; i<MAX_NUM_ELEMENTS; i++)
848 element_info[i].editor_graphic = element_info[i].graphic[ACTION_DEFAULT];
849 element_info[i].preview_graphic = element_info[i].graphic[ACTION_DEFAULT];
852 /* initialize special element/graphic mapping from static configuration */
853 for (i=0; element_to_special_graphic[i].element > -1; i++)
855 int element = element_to_special_graphic[i].element;
856 int special = element_to_special_graphic[i].special;
857 int graphic = element_to_special_graphic[i].graphic;
859 if (special == GFX_SPECIAL_ARG_EDITOR)
860 element_info[element].editor_graphic = graphic;
861 else if (special == GFX_SPECIAL_ARG_PREVIEW)
862 element_info[element].preview_graphic = graphic;
865 /* initialize special element/graphic mapping from dynamic configuration */
866 for (i=0; i < num_property_mappings; i++)
868 int element = property_mapping[i].base_index;
869 int special = property_mapping[i].ext3_index;
870 int graphic = property_mapping[i].artwork_index;
872 if (special == GFX_SPECIAL_ARG_EDITOR)
873 element_info[element].editor_graphic = graphic;
874 else if (special == GFX_SPECIAL_ARG_PREVIEW)
875 element_info[element].preview_graphic = graphic;
879 static void InitElementSoundInfo()
884 static void set_graphic_parameters(int graphic, int *parameter)
886 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
887 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
888 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
890 graphic_info[graphic].bitmap = src_bitmap;
892 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
893 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
894 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
895 graphic_info[graphic].offset_y = 0;
897 /* animation frames are ordered vertically instead of horizontally */
898 if (parameter[GFX_ARG_VERTICAL])
900 graphic_info[graphic].offset_x = 0;
901 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
904 /* optionally, the x and y offset of frames can be specified directly */
905 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
906 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
907 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
908 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
910 /* automatically determine correct number of frames, if not defined */
911 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
912 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
913 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
914 graphic_info[graphic].anim_frames = num_xtiles;
915 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
916 graphic_info[graphic].anim_frames = num_ytiles;
918 graphic_info[graphic].anim_frames = 1;
920 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
921 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
922 graphic_info[graphic].anim_delay = 1;
924 /* set mode for animation frame order */
925 if (parameter[GFX_ARG_MODE_LOOP])
926 graphic_info[graphic].anim_mode = ANIM_LOOP;
927 else if (parameter[GFX_ARG_MODE_LINEAR])
928 graphic_info[graphic].anim_mode = ANIM_LINEAR;
929 else if (parameter[GFX_ARG_MODE_PINGPONG])
930 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
931 else if (parameter[GFX_ARG_MODE_PINGPONG2])
932 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
933 else if (parameter[GFX_ARG_MODE_RANDOM])
934 graphic_info[graphic].anim_mode = ANIM_RANDOM;
935 else if (graphic_info[graphic].anim_frames > 1)
936 graphic_info[graphic].anim_mode = ANIM_LOOP;
938 graphic_info[graphic].anim_mode = ANIM_NONE;
940 /* set additional flag to play animation frames in reverse order */
941 if (parameter[GFX_ARG_MODE_REVERSE])
942 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
944 /* automatically determine correct start frame, if not defined */
945 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
946 graphic_info[graphic].anim_start_frame = 0;
947 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
948 graphic_info[graphic].anim_start_frame =
949 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
951 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
953 /* animation synchronized with global frame counter, not move position */
954 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
957 static void InitGraphicInfo()
959 static boolean clipmasks_initialized = FALSE;
960 int num_images = getImageListSize();
962 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
964 XGCValues clip_gc_values;
965 unsigned long clip_gc_valuemask;
966 GC copy_clipmask_gc = None;
969 if (graphic_info != NULL)
972 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
974 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
975 if (clipmasks_initialized)
977 for (i=0; i<num_images; i++)
979 if (graphic_info[i].clip_mask)
980 XFreePixmap(display, graphic_info[i].clip_mask);
981 if (graphic_info[i].clip_gc)
982 XFreeGC(display, graphic_info[i].clip_gc);
984 graphic_info[i].clip_mask = None;
985 graphic_info[i].clip_gc = None;
990 for (i=0; i<num_images; i++)
992 struct FileInfo *image = getImageListEntry(i);
995 int first_frame, last_frame;
997 set_graphic_parameters(i, image->parameter);
999 /* now check if no animation frames are outside of the loaded image */
1001 if (graphic_info[i].bitmap == NULL)
1002 continue; /* skip check for optional images that are undefined */
1005 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1006 if (src_x < 0 || src_y < 0 ||
1007 src_x + TILEX > src_bitmap->width ||
1008 src_y + TILEY > src_bitmap->height)
1010 Error(ERR_RETURN_LINE, "-");
1011 Error(ERR_RETURN, "warning: error found in config file:");
1012 Error(ERR_RETURN, "- config file: '%s'",
1013 getImageConfigFilename());
1014 Error(ERR_RETURN, "- config token: '%s'",
1015 getTokenFromImageID(i));
1016 Error(ERR_RETURN, "- image file: '%s'",
1017 src_bitmap->source_filename);
1019 "error: first animation frame out of bounds (%d, %d)",
1021 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1022 Error(ERR_RETURN_LINE, "-");
1024 set_graphic_parameters(i, image->default_parameter);
1027 last_frame = graphic_info[i].anim_frames - 1;
1028 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
1029 if (src_x < 0 || src_y < 0 ||
1030 src_x + TILEX > src_bitmap->width ||
1031 src_y + TILEY > src_bitmap->height)
1033 Error(ERR_RETURN_LINE, "-");
1034 Error(ERR_RETURN, "warning: error found in config file:");
1035 Error(ERR_RETURN, "- config file: '%s'",
1036 getImageConfigFilename());
1037 Error(ERR_RETURN, "- config token: '%s'",
1038 getTokenFromImageID(i));
1039 Error(ERR_RETURN, "- image file: '%s'",
1040 src_bitmap->source_filename);
1042 "error: last animation frame (%d) out of bounds (%d, %d)",
1043 last_frame, src_x, src_y);
1044 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1045 Error(ERR_RETURN_LINE, "-");
1047 set_graphic_parameters(i, image->default_parameter);
1050 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1051 /* currently we need only a tile clip mask from the first frame */
1052 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1054 if (copy_clipmask_gc == None)
1056 clip_gc_values.graphics_exposures = False;
1057 clip_gc_valuemask = GCGraphicsExposures;
1058 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
1059 clip_gc_valuemask, &clip_gc_values);
1062 graphic_info[i].clip_mask =
1063 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
1065 src_pixmap = src_bitmap->clip_mask;
1066 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
1067 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
1069 clip_gc_values.graphics_exposures = False;
1070 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
1071 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
1072 graphic_info[i].clip_gc =
1073 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1077 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1078 if (copy_clipmask_gc)
1079 XFreeGC(display, copy_clipmask_gc);
1082 clipmasks_initialized = TRUE;
1085 static void set_sound_parameters(int sound, int *parameter)
1087 /* explicit loop mode setting in configuration overrides default value */
1088 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1089 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1092 static void InitSoundInfo()
1094 int *sound_effect_properties;
1095 int num_sounds = getSoundListSize();
1098 if (sound_info != NULL)
1101 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1102 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1104 /* initialize sound effect for all elements to "no sound" */
1105 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1106 for (j=0; j<NUM_ACTIONS; j++)
1107 element_info[i].sound[j] = SND_UNDEFINED;
1109 for (i=0; i<num_sounds; i++)
1111 struct FileInfo *sound = getSoundListEntry(i);
1112 int len_effect_text = strlen(sound->token);
1114 sound_effect_properties[i] = ACTION_OTHER;
1115 sound_info[i].loop = FALSE;
1117 /* determine all loop sounds and identify certain sound classes */
1119 for (j=0; element_action_info[j].suffix; j++)
1121 int len_action_text = strlen(element_action_info[j].suffix);
1123 if (len_action_text < len_effect_text &&
1124 strcmp(&sound->token[len_effect_text - len_action_text],
1125 element_action_info[j].suffix) == 0)
1127 sound_effect_properties[i] = element_action_info[j].value;
1129 if (element_action_info[j].is_loop_sound)
1130 sound_info[i].loop = TRUE;
1134 /* associate elements and some selected sound actions */
1136 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1138 if (element_info[j].sound_class_name)
1140 int len_class_text = strlen(element_info[j].sound_class_name);
1142 if (len_class_text + 1 < len_effect_text &&
1143 strncmp(sound->token,
1144 element_info[j].sound_class_name, len_class_text) == 0 &&
1145 sound->token[len_class_text] == '.')
1147 int sound_action_value = sound_effect_properties[i];
1149 element_info[j].sound[sound_action_value] = i;
1154 set_sound_parameters(i, sound->parameter);
1157 free(sound_effect_properties);
1162 int element = EL_SAND;
1163 int sound_action = ACTION_DIGGING;
1166 while (element_action_info[j].suffix)
1168 if (element_action_info[j].value == sound_action)
1169 printf("element %d, sound action '%s' == %d\n",
1170 element, element_action_info[j].suffix,
1171 element_info_[element].sound[sound_action]);
1178 void InitElementProperties()
1182 static int ep_amoebalive[] =
1189 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1191 static int ep_amoeboid[] =
1199 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1201 static int ep_schluessel[] =
1212 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1214 static int ep_pforte[] =
1233 EL_SWITCHGATE_OPENING,
1234 EL_SWITCHGATE_CLOSED,
1235 EL_SWITCHGATE_CLOSING,
1237 EL_TIMEGATE_OPENING,
1239 EL_TIMEGATE_CLOSING,
1243 EL_TUBE_VERTICAL_LEFT,
1244 EL_TUBE_VERTICAL_RIGHT,
1245 EL_TUBE_HORIZONTAL_UP,
1246 EL_TUBE_HORIZONTAL_DOWN,
1252 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1254 static int ep_solid[] =
1274 EL_QUICKSAND_FILLING,
1275 EL_QUICKSAND_EMPTYING,
1277 EL_MAGIC_WALL_ACTIVE,
1278 EL_MAGIC_WALL_EMPTYING,
1279 EL_MAGIC_WALL_FILLING,
1283 EL_BD_MAGIC_WALL_ACTIVE,
1284 EL_BD_MAGIC_WALL_EMPTYING,
1285 EL_BD_MAGIC_WALL_FULL,
1286 EL_BD_MAGIC_WALL_FILLING,
1287 EL_BD_MAGIC_WALL_DEAD,
1290 EL_ACIDPOOL_TOPLEFT,
1291 EL_ACIDPOOL_TOPRIGHT,
1292 EL_ACIDPOOL_BOTTOMLEFT,
1294 EL_ACIDPOOL_BOTTOMRIGHT,
1312 EL_SP_TERMINAL_ACTIVE,
1315 EL_INVISIBLE_STEELWALL,
1316 EL_INVISIBLE_STEELWALL_ACTIVE,
1318 EL_INVISIBLE_WALL_ACTIVE,
1319 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1320 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1321 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1322 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1323 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1324 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1325 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1326 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1327 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1328 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1329 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1330 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1331 EL_SWITCHGATE_SWITCH_UP,
1332 EL_SWITCHGATE_SWITCH_DOWN,
1334 EL_LIGHT_SWITCH_ACTIVE,
1336 EL_TIMEGATE_SWITCH_ACTIVE,
1337 EL_SIGN_EXCLAMATION,
1338 EL_SIGN_RADIOACTIVITY,
1349 EL_STEELWALL_SLANTED,
1354 EL_EMC_WALL_PILLAR_UPPER,
1355 EL_EMC_WALL_PILLAR_MIDDLE,
1356 EL_EMC_WALL_PILLAR_LOWER,
1382 EL_SWITCHGATE_OPENING,
1383 EL_SWITCHGATE_CLOSED,
1384 EL_SWITCHGATE_CLOSING,
1386 EL_TIMEGATE_OPENING,
1388 EL_TIMEGATE_CLOSING,
1392 EL_TUBE_VERTICAL_LEFT,
1393 EL_TUBE_VERTICAL_RIGHT,
1394 EL_TUBE_HORIZONTAL_UP,
1395 EL_TUBE_HORIZONTAL_DOWN,
1401 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1403 static int ep_massive[] =
1407 EL_ACIDPOOL_TOPLEFT,
1408 EL_ACIDPOOL_TOPRIGHT,
1409 EL_ACIDPOOL_BOTTOMLEFT,
1411 EL_ACIDPOOL_BOTTOMRIGHT,
1423 EL_INVISIBLE_STEELWALL,
1424 EL_INVISIBLE_STEELWALL_ACTIVE,
1425 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1426 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1427 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1428 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1429 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1430 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1431 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1432 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1433 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1434 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1435 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1436 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1438 EL_LIGHT_SWITCH_ACTIVE,
1439 EL_SIGN_EXCLAMATION,
1440 EL_SIGN_RADIOACTIVITY,
1451 EL_STEELWALL_SLANTED,
1474 EL_SWITCHGATE_OPENING,
1475 EL_SWITCHGATE_CLOSED,
1476 EL_SWITCHGATE_CLOSING,
1478 EL_TIMEGATE_OPENING,
1480 EL_TIMEGATE_CLOSING,
1484 EL_TUBE_VERTICAL_LEFT,
1485 EL_TUBE_VERTICAL_RIGHT,
1486 EL_TUBE_HORIZONTAL_UP,
1487 EL_TUBE_HORIZONTAL_DOWN,
1493 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1495 static int ep_slippery[] =
1509 EL_ROBOT_WHEEL_ACTIVE,
1515 EL_ACIDPOOL_TOPLEFT,
1516 EL_ACIDPOOL_TOPRIGHT,
1526 EL_STEELWALL_SLANTED,
1530 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1532 static int ep_enemy[] =
1545 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1547 static int ep_mauer[] =
1575 EL_WALL_GROWING_ACTIVE,
1594 EL_SP_TERMINAL_ACTIVE,
1597 EL_INVISIBLE_STEELWALL,
1598 EL_INVISIBLE_STEELWALL_ACTIVE,
1600 EL_INVISIBLE_WALL_ACTIVE,
1601 EL_STEELWALL_SLANTED,
1606 EL_EMC_WALL_PILLAR_UPPER,
1607 EL_EMC_WALL_PILLAR_MIDDLE,
1608 EL_EMC_WALL_PILLAR_LOWER,
1615 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1617 static int ep_can_fall[] =
1632 EL_BD_MAGIC_WALL_FULL,
1643 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1645 static int ep_can_smash[] =
1676 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1678 static int ep_can_change[] =
1689 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1691 static int ep_can_move[] =
1711 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1713 static int ep_could_move[] =
1723 EL_BD_BUTTERFLY_RIGHT,
1725 EL_BD_BUTTERFLY_LEFT,
1726 EL_BD_BUTTERFLY_DOWN,
1727 EL_BD_FIREFLY_RIGHT,
1736 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1738 static int ep_dont_touch[] =
1745 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1747 static int ep_dont_go_to[] =
1761 EL_SP_BUGGY_BASE_ACTIVE,
1765 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1767 static int ep_mampf2[] =
1792 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1794 static int ep_bd_element[] =
1821 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1823 static int ep_sb_element[] =
1828 EL_SOKOBAN_FIELD_EMPTY,
1829 EL_SOKOBAN_FIELD_FULL,
1831 EL_INVISIBLE_STEELWALL
1833 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1835 static int ep_gem[] =
1844 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1846 static int ep_inactive[] =
1883 EL_INVISIBLE_STEELWALL,
1891 EL_WALL_EMERALD_YELLOW,
1896 EL_SOKOBAN_FIELD_EMPTY,
1897 EL_SOKOBAN_FIELD_FULL,
1898 EL_WALL_EMERALD_RED,
1899 EL_WALL_EMERALD_PURPLE,
1900 EL_ACIDPOOL_TOPLEFT,
1901 EL_ACIDPOOL_TOPRIGHT,
1902 EL_ACIDPOOL_BOTTOMLEFT,
1904 EL_ACIDPOOL_BOTTOMRIGHT,
1908 EL_BD_MAGIC_WALL_DEAD,
1909 EL_AMOEBA_TO_DIAMOND,
1942 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1943 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1944 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1945 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1946 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1947 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1948 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1949 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1950 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1951 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1952 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1953 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1954 EL_SIGN_EXCLAMATION,
1955 EL_SIGN_RADIOACTIVITY,
1966 EL_STEELWALL_SLANTED,
1971 EL_EMC_WALL_PILLAR_UPPER,
1972 EL_EMC_WALL_PILLAR_MIDDLE,
1973 EL_EMC_WALL_PILLAR_LOWER,
1980 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1982 static int ep_explosive[] =
1987 EL_DYNABOMB_PLAYER1_ACTIVE,
1988 EL_DYNABOMB_PLAYER2_ACTIVE,
1989 EL_DYNABOMB_PLAYER3_ACTIVE,
1990 EL_DYNABOMB_PLAYER4_ACTIVE,
2007 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
2009 static int ep_mampf3[] =
2020 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
2022 static int ep_pushable[] =
2029 EL_SOKOBAN_FIELD_FULL,
2039 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
2041 static int ep_player[] =
2048 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
2050 static int ep_has_content[] =
2058 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
2060 static int ep_eatable[] =
2065 EL_SP_BUGGY_BASE_ACTIVATING,
2068 EL_INVISIBLE_SAND_ACTIVE
2070 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
2072 static int ep_sp_element[] =
2115 /* additional elements that appeared in newer Supaplex levels */
2117 /* more than one murphy in a level results in an inactive clone */
2120 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2122 static int ep_quick_gate[] =
2146 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2148 static int ep_over_player[] =
2164 EL_TUBE_VERTICAL_LEFT,
2165 EL_TUBE_VERTICAL_RIGHT,
2166 EL_TUBE_HORIZONTAL_UP,
2167 EL_TUBE_HORIZONTAL_DOWN,
2173 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2175 static int ep_active_bomb[] =
2178 EL_DYNABOMB_PLAYER1_ACTIVE,
2179 EL_DYNABOMB_PLAYER2_ACTIVE,
2180 EL_DYNABOMB_PLAYER3_ACTIVE,
2181 EL_DYNABOMB_PLAYER4_ACTIVE
2183 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2185 static int ep_belt[] =
2187 EL_CONVEYOR_BELT1_LEFT,
2188 EL_CONVEYOR_BELT1_MIDDLE,
2189 EL_CONVEYOR_BELT1_RIGHT,
2190 EL_CONVEYOR_BELT2_LEFT,
2191 EL_CONVEYOR_BELT2_MIDDLE,
2192 EL_CONVEYOR_BELT2_RIGHT,
2193 EL_CONVEYOR_BELT3_LEFT,
2194 EL_CONVEYOR_BELT3_MIDDLE,
2195 EL_CONVEYOR_BELT3_RIGHT,
2196 EL_CONVEYOR_BELT4_LEFT,
2197 EL_CONVEYOR_BELT4_MIDDLE,
2198 EL_CONVEYOR_BELT4_RIGHT,
2200 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2202 static int ep_belt_active[] =
2204 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2205 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2206 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2207 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2208 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2209 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2210 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2211 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2212 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2213 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2214 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2215 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2217 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2219 static int ep_belt_switch[] =
2221 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2222 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2223 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2224 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2225 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2226 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2227 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2228 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2229 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2230 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2231 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2232 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2234 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2236 static int ep_tube[] =
2241 EL_TUBE_VERTICAL_LEFT,
2242 EL_TUBE_VERTICAL_RIGHT,
2243 EL_TUBE_HORIZONTAL_UP,
2244 EL_TUBE_HORIZONTAL_DOWN,
2250 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2252 static long ep1_bit[] =
2286 static long ep2_bit[] =
2293 static int *ep1_array[] =
2327 static int *ep2_array[] =
2334 static int *ep1_num[] =
2361 &ep_has_content_num,
2365 &ep_over_player_num,
2368 static int *ep2_num[] =
2371 &ep_belt_active_num,
2372 &ep_belt_switch_num,
2375 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2376 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2378 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2384 for (i=0; i<num_properties1; i++)
2385 for (j=0; j<*(ep1_num[i]); j++)
2386 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2387 for (i=0; i<num_properties2; i++)
2388 for (j=0; j<*(ep2_num[i]); j++)
2389 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2391 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2392 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2395 void Execute_Command(char *command)
2397 if (strcmp(command, "print graphicsinfo.conf") == 0)
2401 printf("# You can configure additional/alternative image files here.\n");
2402 printf("# (The images below are default and therefore commented out.)\n");
2404 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2406 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2409 for (i=0; image_config[i].token != NULL; i++)
2411 getFormattedSetupEntry(image_config[i].token,
2412 image_config[i].value));
2416 else if (strcmp(command, "print soundsinfo.conf") == 0)
2420 printf("# You can configure additional/alternative sound files here.\n");
2421 printf("# (The sounds below are default and therefore commented out.)\n");
2423 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2425 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2428 for (i=0; sound_config[i].token != NULL; i++)
2430 getFormattedSetupEntry(sound_config[i].token,
2431 sound_config[i].value));
2435 else if (strcmp(command, "print musicinfo.conf") == 0)
2437 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2439 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2441 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2445 else if (strncmp(command, "dump level ", 11) == 0)
2447 char *filename = &command[11];
2449 if (access(filename, F_OK) != 0)
2450 Error(ERR_EXIT, "cannot open file '%s'", filename);
2452 LoadLevelFromFilename(filename);
2457 else if (strncmp(command, "dump tape ", 10) == 0)
2459 char *filename = &command[10];
2461 if (access(filename, F_OK) != 0)
2462 Error(ERR_EXIT, "cannot open file '%s'", filename);
2464 LoadTapeFromFilename(filename);
2469 else if (strncmp(command, "autoplay ", 9) == 0)
2471 char *str_copy = getStringCopy(&command[9]);
2472 char *str_ptr = strchr(str_copy, ' ');
2474 global.autoplay_leveldir = str_copy;
2475 global.autoplay_level_nr = -1;
2477 if (str_ptr != NULL)
2479 *str_ptr++ = '\0'; /* terminate leveldir string */
2480 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2485 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2489 void CloseAllAndExit(int exit_value)
2494 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2497 FreeTileClipmasks();
2499 if (bitmap_font_initial)
2500 FreeBitmap(bitmap_font_initial);
2502 CloseVideoDisplay();
2503 ClosePlatformDependantStuff();