1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
29 #include "conf_e2g.c" /* include auto-generated data structure definitions */
32 static char *image_filename[NUM_PICTURES] =
40 "RocksFontMedium.pcx",
53 "RocksFontMedium.pcx",
58 static Bitmap *bitmap_font_initial = NULL;
60 static void InitGlobal(void);
61 static void InitSetup(void);
62 static void InitPlayerInfo(void);
63 static void InitLevelInfo(void);
64 static void InitArtworkInfo(void);
65 static void InitLevelArtworkInfo(void);
66 static void InitNetworkServer(void);
67 static void InitArtworkConfig(void);
68 static void InitImages(void);
69 static void InitMixer(void);
70 static void InitSound(void);
71 static void InitMusic(void);
72 static void InitGfx(void);
73 static void InitGfxBackground(void);
74 static void InitGadgets(void);
75 static void InitElementProperties(void);
76 static void InitElementGraphicInfo(void);
77 static void InitElementSoundInfo(void);
78 static void InitGraphicInfo(void);
79 static void InitSoundInfo();
80 static void Execute_Command(char *);
84 InitGlobal(); /* initialize some global variables */
86 if (options.execute_command)
87 Execute_Command(options.execute_command);
89 if (options.serveronly)
91 #if defined(PLATFORM_UNIX)
92 NetworkServer(options.server_port, options.serveronly);
94 Error(ERR_WARN, "networking only supported in Unix version");
96 exit(0); /* never reached */
99 InitProgramInfo(UNIX_USERDATA_DIRECTORY,
100 PROGRAM_TITLE_STRING, getWindowTitleString(),
101 ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
102 MSDOS_POINTER_FILENAME,
103 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
107 InitArtworkInfo(); /* needed before loading gfx, sound & music */
108 InitArtworkConfig(); /* needed before forking sound child process */
114 InitRND(NEW_RANDOMIZE);
117 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
120 InitEventFilter(FilterMouseMotionEvents);
122 InitElementProperties();
127 InitLevelArtworkInfo();
129 InitImages(); /* needs to know current level directory */
130 InitSound(); /* needs to know current level directory */
131 InitMusic(); /* needs to know current level directory */
135 if (global.autoplay_leveldir)
146 static void InitGlobal()
148 global.autoplay_leveldir = NULL;
150 global.frames_per_second = 0;
151 global.fps_slowdown = FALSE;
152 global.fps_slowdown_factor = 1;
155 static void InitSetup()
157 LoadSetup(); /* global setup info */
160 static void InitPlayerInfo()
164 /* choose default local player */
165 local_player = &stored_player[0];
167 for (i=0; i<MAX_PLAYERS; i++)
168 stored_player[i].connected = FALSE;
170 local_player->connected = TRUE;
173 static void InitLevelInfo()
175 LoadLevelInfo(); /* global level info */
176 LoadLevelSetup_LastSeries(); /* last played series info */
177 LoadLevelSetup_SeriesInfo(); /* last played level info */
180 static void InitArtworkInfo()
185 static void InitArtworkConfig()
187 static char *element_prefix[MAX_NUM_ELEMENTS + 1];
188 static char *sound_class_prefix[MAX_NUM_ELEMENTS + 1];
189 static char *action_suffix[NUM_ACTIONS + 1];
190 static char *direction_suffix[NUM_DIRECTIONS + 1];
191 static char *dummy[1] = { NULL };
194 for (i=0; i<MAX_NUM_ELEMENTS; i++)
195 element_info[i].custom_description = NULL;
197 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
198 element_prefix[i] = element_info[i].token_name;
199 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
200 sound_class_prefix[i] = element_info[i].sound_class_name;
201 for (i=0; i<NUM_ACTIONS + 1; i++)
202 action_suffix[i] = element_action_info[i].suffix;
203 for (i=0; i<NUM_DIRECTIONS + 1; i++)
204 direction_suffix[i] = element_direction_info[i].suffix;
206 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
207 element_prefix, action_suffix, direction_suffix);
208 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
209 sound_class_prefix, action_suffix, dummy);
212 void InitLevelArtworkInfo()
214 LoadLevelArtworkInfo();
217 void InitNetworkServer()
219 #if defined(PLATFORM_UNIX)
223 if (!options.network)
226 #if defined(PLATFORM_UNIX)
227 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
229 if (!ConnectToServer(options.server_host, options.server_port))
230 Error(ERR_EXIT, "cannot connect to network game server");
232 SendToServer_PlayerName(setup.player_name);
233 SendToServer_ProtocolVersion();
236 SendToServer_NrWanted(nr_wanted);
240 static void InitMixer()
246 static void ReinitializeGraphics()
248 InitElementGraphicInfo(); /* initialize element/graphic config info */
249 InitGraphicInfo(); /* initialize graphic info from config file */
251 InitFontInfo(bitmap_font_initial,
252 graphic_info[IMG_FONT_BIG].bitmap,
253 graphic_info[IMG_FONT_MEDIUM].bitmap,
254 graphic_info[IMG_FONT_SMALL].bitmap,
255 graphic_info[IMG_FONT_EM].bitmap);
257 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
258 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
264 static void ReinitializeSounds()
266 InitElementSoundInfo(); /* initialize element/sound config info */
267 InitSoundInfo(); /* initialize sounds info from config file */
269 InitPlaySoundLevel(); /* initialize internal game sound values */
272 static void ReinitializeMusic()
274 /* currently nothing to do */
277 static void InitImages()
279 ReloadCustomImages();
280 ReinitializeGraphics();
282 LoadCustomElementDescriptions();
285 static void InitSound()
287 InitReloadCustomSounds(artwork.snd_current->identifier);
288 ReinitializeSounds();
291 static void InitMusic()
293 InitReloadCustomMusic(artwork.mus_current->identifier);
297 static void InitTileClipmasks()
300 #if defined(TARGET_X11)
301 XGCValues clip_gc_values;
302 unsigned long clip_gc_valuemask;
304 #if defined(TARGET_X11_NATIVE)
314 tile_needs_clipping[] =
316 { GFX_SPIELER1_UP, 4 },
317 { GFX_SPIELER1_DOWN, 4 },
318 { GFX_SPIELER1_LEFT, 4 },
319 { GFX_SPIELER1_RIGHT, 4 },
320 { GFX_SPIELER1_PUSH_LEFT, 4 },
321 { GFX_SPIELER1_PUSH_RIGHT, 4 },
322 { GFX_SPIELER2_UP, 4 },
323 { GFX_SPIELER2_DOWN, 4 },
324 { GFX_SPIELER2_LEFT, 4 },
325 { GFX_SPIELER2_RIGHT, 4 },
326 { GFX_SPIELER2_PUSH_LEFT, 4 },
327 { GFX_SPIELER2_PUSH_RIGHT, 4 },
328 { GFX_SPIELER3_UP, 4 },
329 { GFX_SPIELER3_DOWN, 4 },
330 { GFX_SPIELER3_LEFT, 4 },
331 { GFX_SPIELER3_RIGHT, 4 },
332 { GFX_SPIELER3_PUSH_LEFT, 4 },
333 { GFX_SPIELER3_PUSH_RIGHT, 4 },
334 { GFX_SPIELER4_UP, 4 },
335 { GFX_SPIELER4_DOWN, 4 },
336 { GFX_SPIELER4_LEFT, 4 },
337 { GFX_SPIELER4_RIGHT, 4 },
338 { GFX_SPIELER4_PUSH_LEFT, 4 },
339 { GFX_SPIELER4_PUSH_RIGHT, 4 },
340 { GFX_SP_MURPHY, 1 },
341 { GFX_MURPHY_GO_LEFT, 3 },
342 { GFX_MURPHY_GO_RIGHT, 3 },
343 { GFX_MURPHY_SNAP_UP, 1 },
344 { GFX_MURPHY_SNAP_DOWN, 1 },
345 { GFX_MURPHY_SNAP_RIGHT, 1 },
346 { GFX_MURPHY_SNAP_LEFT, 1 },
347 { GFX_MURPHY_PUSH_RIGHT, 1 },
348 { GFX_MURPHY_PUSH_LEFT, 1 },
349 { GFX_GEBLUBBER, 4 },
352 { GFX_EXPLOSION, 8 },
353 { GFX_SOKOBAN_OBJEKT, 1 },
354 { GFX_FUNKELN_BLAU, 3 },
355 { GFX_FUNKELN_WEISS, 3 },
356 { GFX2_SHIELD_PASSIVE, 3 },
357 { GFX2_SHIELD_ACTIVE, 3 },
362 #endif /* TARGET_X11_NATIVE */
363 #endif /* TARGET_X11 */
367 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
368 for (i=0; i<NUM_TILES; i++)
369 tile_clipmask[i] = None;
371 #if defined(TARGET_X11)
372 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
373 often very slow when preparing a masked XCopyArea() for big Pixmaps.
374 To prevent this, create small (tile-sized) mask Pixmaps which will then
375 be set much faster with XSetClipOrigin() and speed things up a lot. */
377 clip_gc_values.graphics_exposures = False;
378 clip_gc_valuemask = GCGraphicsExposures;
379 tile_clip_gc = XCreateGC(display, window->drawable,
380 clip_gc_valuemask, &clip_gc_values);
383 for (i=0; i<NUM_BITMAPS; i++)
385 if (pix[i]->clip_mask)
387 clip_gc_values.graphics_exposures = False;
388 clip_gc_values.clip_mask = pix[i]->clip_mask;
389 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
390 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
391 clip_gc_valuemask, &clip_gc_values);
396 #if defined(TARGET_X11_NATIVE)
399 /* create graphic context structures needed for clipping */
400 clip_gc_values.graphics_exposures = False;
401 clip_gc_valuemask = GCGraphicsExposures;
402 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
403 clip_gc_valuemask, &clip_gc_values);
405 /* create only those clipping Pixmaps we really need */
406 for (i=0; tile_needs_clipping[i].start>=0; i++)
410 for (j=0; j<tile_needs_clipping[i].count; j++)
412 int tile = tile_needs_clipping[i].start + j;
418 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
419 src_pixmap = src_bitmap->clip_mask;
421 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
424 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
425 src_x, src_y, TILEX, TILEY, 0, 0);
429 XFreeGC(display, copy_clipmask_gc);
432 #endif /* TARGET_X11_NATIVE */
433 #endif /* TARGET_X11 */
437 void FreeTileClipmasks()
440 #if defined(TARGET_X11)
443 for (i=0; i<NUM_TILES; i++)
445 if (tile_clipmask[i] != None)
447 XFreePixmap(display, tile_clipmask[i]);
448 tile_clipmask[i] = None;
453 XFreeGC(display, tile_clip_gc);
457 for (i=0; i<NUM_BITMAPS; i++)
459 if (pix[i] != NULL && pix[i]->stored_clip_gc)
461 XFreeGC(display, pix[i]->stored_clip_gc);
462 pix[i]->stored_clip_gc = None;
467 #endif /* TARGET_X11 */
477 /* initialize screen properties */
478 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
479 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
480 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
481 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
482 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
484 /* create additional image buffers for double-buffering */
485 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
486 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
489 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
491 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
493 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
495 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
498 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
499 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
501 DrawInitText("Loading graphics:", 120, FC_GREEN);
504 for (i=0; i<NUM_PICTURES; i++)
507 if (i != PIX_FONT_SMALL)
510 DrawInitText(image_filename[i], 150, FC_YELLOW);
512 pix[i] = LoadCustomImage(image_filename[i]);
518 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
525 void InitGfxBackground()
530 fieldbuffer = bitmap_db_field;
531 SetDrawtoField(DRAW_BACKBUFFER);
533 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
534 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
535 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
536 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
538 for (x=0; x<MAX_BUF_XSIZE; x++)
539 for (y=0; y<MAX_BUF_YSIZE; y++)
542 redraw_mask = REDRAW_ALL;
545 void ReloadCustomArtwork()
547 static char *leveldir_current_identifier = NULL;
548 static boolean last_override_level_graphics = FALSE;
549 static boolean last_override_level_sounds = FALSE;
550 static boolean last_override_level_music = FALSE;
551 /* identifier for new artwork; default: artwork configured in setup */
552 char *gfx_new_identifier = artwork.gfx_current->identifier;
553 char *snd_new_identifier = artwork.snd_current->identifier;
554 char *mus_new_identifier = artwork.mus_current->identifier;
555 boolean redraw_screen = FALSE;
557 if (leveldir_current_identifier == NULL)
558 leveldir_current_identifier = leveldir_current->identifier;
561 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
562 leveldir_current->graphics_set);
563 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
564 leveldir_current->identifier);
568 printf("graphics --> '%s' ('%s')\n",
569 artwork.gfx_current_identifier, artwork.gfx_current->filename);
570 printf("sounds --> '%s' ('%s')\n",
571 artwork.snd_current_identifier, artwork.snd_current->filename);
572 printf("music --> '%s' ('%s')\n",
573 artwork.mus_current_identifier, artwork.mus_current->filename);
576 /* leveldir_current may be invalid (level group, parent link) */
577 if (!validLevelSeries(leveldir_current))
580 /* when a new level series was selected, check if there was a change
581 in custom artwork stored in level series directory */
582 if (leveldir_current_identifier != leveldir_current->identifier)
584 char *identifier_old = leveldir_current_identifier;
585 char *identifier_new = leveldir_current->identifier;
587 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
588 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
589 gfx_new_identifier = identifier_new;
590 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
591 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
592 snd_new_identifier = identifier_new;
593 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
594 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
595 mus_new_identifier = identifier_new;
597 leveldir_current_identifier = leveldir_current->identifier;
600 /* custom level artwork configured in level series configuration file
601 always overrides custom level artwork stored in level series directory
602 and (level independant) custom artwork configured in setup menue */
603 if (leveldir_current->graphics_set != NULL)
604 gfx_new_identifier = leveldir_current->graphics_set;
605 if (leveldir_current->sounds_set != NULL)
606 snd_new_identifier = leveldir_current->sounds_set;
607 if (leveldir_current->music_set != NULL)
608 mus_new_identifier = leveldir_current->music_set;
610 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
611 last_override_level_graphics != setup.override_level_graphics)
614 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
615 artwork.gfx_current_identifier,
616 artwork.gfx_current->identifier,
620 setLevelArtworkDir(artwork.gfx_first);
622 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
624 ReloadCustomImages();
625 ReinitializeGraphics();
627 LoadCustomElementDescriptions();
632 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
633 last_override_level_graphics = setup.override_level_graphics;
635 redraw_screen = TRUE;
638 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
639 last_override_level_sounds != setup.override_level_sounds)
642 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
643 artwork.snd_current_identifier,
644 artwork.snd_current->identifier,
648 /* set artwork path to send it to the sound server process */
649 setLevelArtworkDir(artwork.snd_first);
651 InitReloadCustomSounds(snd_new_identifier);
652 ReinitializeSounds();
654 artwork.snd_current_identifier = artwork.snd_current->identifier;
655 last_override_level_sounds = setup.override_level_sounds;
657 redraw_screen = TRUE;
660 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
661 last_override_level_music != setup.override_level_music)
663 /* set artwork path to send it to the sound server process */
664 setLevelArtworkDir(artwork.mus_first);
666 InitReloadCustomMusic(mus_new_identifier);
669 artwork.mus_current_identifier = artwork.mus_current->identifier;
670 last_override_level_music = setup.override_level_music;
672 redraw_screen = TRUE;
679 /* force redraw of (open or closed) door graphics */
680 SetDoorState(DOOR_OPEN_ALL);
681 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
687 FreeLevelEditorGadgets();
696 static boolean gadgets_initialized = FALSE;
698 if (gadgets_initialized)
701 CreateLevelEditorGadgets();
705 CreateScreenGadgets();
707 gadgets_initialized = TRUE;
710 void InitElementGraphicInfo()
712 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
713 int num_property_mappings = getImageListPropertyMappingSize();
716 /* set values to -1 to identify later as "uninitialized" values */
717 for (i=0; i<MAX_NUM_ELEMENTS; i++)
719 for (act=0; act<NUM_ACTIONS; act++)
721 element_info[i].graphic[act] = -1;
723 for (dir=0; dir<NUM_DIRECTIONS; dir++)
724 element_info[i].direction_graphic[act][dir] = -1;
728 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
729 element_info[i].graphic[ACTION_DEFAULT] =
730 IMG_CHAR_START + (i - EL_CHAR_START);
732 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
733 element_info[i].graphic[ACTION_DEFAULT] =
734 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
736 /* initialize element/graphic mapping from static configuration */
737 for (i=0; element_to_graphic[i].element > -1; i++)
739 int element = element_to_graphic[i].element;
740 int action = element_to_graphic[i].action;
741 int direction = element_to_graphic[i].direction;
742 int graphic = element_to_graphic[i].graphic;
745 action = ACTION_DEFAULT;
748 element_info[element].direction_graphic[action][direction] = graphic;
750 element_info[element].graphic[action] = graphic;
753 /* initialize element/graphic mapping from dynamic configuration */
754 for (i=0; i < num_property_mappings; i++)
756 int element = property_mapping[i].base_index;
757 int action = property_mapping[i].ext1_index;
758 int direction = property_mapping[i].ext2_index;
759 int graphic = property_mapping[i].artwork_index;
762 action = ACTION_DEFAULT;
765 element_info[element].direction_graphic[action][direction] = graphic;
767 element_info[element].graphic[action] = graphic;
770 /* now set all '-1' values to element specific default values */
771 for (i=0; i<MAX_NUM_ELEMENTS; i++)
773 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
774 int default_action_direction_graphic[NUM_DIRECTIONS];
776 if (default_action_graphic == -1)
777 default_action_graphic = IMG_CHAR_QUESTION;
779 for (dir=0; dir<NUM_DIRECTIONS; dir++)
781 default_action_direction_graphic[dir] =
782 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
784 if (default_action_direction_graphic[dir] == -1)
785 default_action_direction_graphic[dir] = default_action_graphic;
788 for (act=0; act<NUM_ACTIONS; act++)
790 for (dir=0; dir<NUM_DIRECTIONS; dir++)
792 int default_direction_graphic = element_info[i].graphic[act];
794 /* no graphic for current action -- use default direction graphic */
795 if (default_direction_graphic == -1)
796 default_direction_graphic = default_action_direction_graphic[dir];
798 if (element_info[i].direction_graphic[act][dir] == -1)
799 element_info[i].direction_graphic[act][dir] =
800 default_direction_graphic;
803 /* no graphic for this specific action -- use default action graphic */
804 if (element_info[i].graphic[act] == -1)
805 element_info[i].graphic[act] = default_action_graphic;
810 static void InitElementSoundInfo()
815 static void set_graphic_parameters(int graphic, int *parameter)
817 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
818 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
819 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
821 graphic_info[graphic].bitmap = src_bitmap;
823 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
824 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
825 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
826 graphic_info[graphic].offset_y = 0;
828 /* animation frames are ordered vertically instead of horizontally */
829 if (parameter[GFX_ARG_VERTICAL])
831 graphic_info[graphic].offset_x = 0;
832 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
835 /* optionally, the x and y offset of frames can be specified directly */
836 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
837 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
838 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
839 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
841 /* automatically determine correct number of frames, if not defined */
842 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
843 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
844 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
845 graphic_info[graphic].anim_frames = num_xtiles;
846 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
847 graphic_info[graphic].anim_frames = num_ytiles;
849 graphic_info[graphic].anim_frames = 1;
851 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
852 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
853 graphic_info[graphic].anim_delay = 1;
855 /* set mode for animation frame order */
856 if (parameter[GFX_ARG_MODE_LOOP])
857 graphic_info[graphic].anim_mode = ANIM_LOOP;
858 else if (parameter[GFX_ARG_MODE_LINEAR])
859 graphic_info[graphic].anim_mode = ANIM_LINEAR;
860 else if (parameter[GFX_ARG_MODE_PINGPONG])
861 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
862 else if (parameter[GFX_ARG_MODE_PINGPONG2])
863 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
864 else if (parameter[GFX_ARG_MODE_RANDOM])
865 graphic_info[graphic].anim_mode = ANIM_RANDOM;
866 else if (graphic_info[graphic].anim_frames > 1)
867 graphic_info[graphic].anim_mode = ANIM_LOOP;
869 graphic_info[graphic].anim_mode = ANIM_NONE;
871 /* set additional flag to play animation frames in reverse order */
872 if (parameter[GFX_ARG_MODE_REVERSE])
873 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
875 /* automatically determine correct start frame, if not defined */
876 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
877 graphic_info[graphic].anim_start_frame = 0;
878 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
879 graphic_info[graphic].anim_start_frame =
880 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
882 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
884 /* animation synchronized with global frame counter, not move position */
885 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
888 static void InitGraphicInfo()
890 static boolean clipmasks_initialized = FALSE;
891 int num_images = getImageListSize();
893 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
895 XGCValues clip_gc_values;
896 unsigned long clip_gc_valuemask;
897 GC copy_clipmask_gc = None;
900 if (graphic_info != NULL)
903 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
905 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
906 if (clipmasks_initialized)
908 for (i=0; i<num_images; i++)
910 if (graphic_info[i].clip_mask)
911 XFreePixmap(display, graphic_info[i].clip_mask);
912 if (graphic_info[i].clip_gc)
913 XFreeGC(display, graphic_info[i].clip_gc);
915 graphic_info[i].clip_mask = None;
916 graphic_info[i].clip_gc = None;
921 for (i=0; i<num_images; i++)
923 struct FileInfo *image = getImageListEntry(i);
926 int first_frame, last_frame;
928 set_graphic_parameters(i, image->parameter);
930 /* now check if no animation frames are outside of the loaded image */
932 if (graphic_info[i].bitmap == NULL)
933 continue; /* skip check for optional images that are undefined */
936 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
937 if (src_x < 0 || src_y < 0 ||
938 src_x + TILEX > src_bitmap->width ||
939 src_y + TILEY > src_bitmap->height)
941 Error(ERR_RETURN_LINE, "-");
942 Error(ERR_RETURN, "warning: error found in config file:");
943 Error(ERR_RETURN, "- config file: '%s'",
944 getImageConfigFilename());
945 Error(ERR_RETURN, "- config token: '%s'",
946 getTokenFromImageID(i));
947 Error(ERR_RETURN, "- image file: '%s'",
948 src_bitmap->source_filename);
950 "error: first animation frame out of bounds (%d, %d)",
952 Error(ERR_RETURN, "custom graphic rejected for this element/action");
953 Error(ERR_RETURN_LINE, "-");
955 set_graphic_parameters(i, image->default_parameter);
958 last_frame = graphic_info[i].anim_frames - 1;
959 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
960 if (src_x < 0 || src_y < 0 ||
961 src_x + TILEX > src_bitmap->width ||
962 src_y + TILEY > src_bitmap->height)
964 Error(ERR_RETURN_LINE, "-");
965 Error(ERR_RETURN, "warning: error found in config file:");
966 Error(ERR_RETURN, "- config file: '%s'",
967 getImageConfigFilename());
968 Error(ERR_RETURN, "- config token: '%s'",
969 getTokenFromImageID(i));
970 Error(ERR_RETURN, "- image file: '%s'",
971 src_bitmap->source_filename);
973 "error: last animation frame (%d) out of bounds (%d, %d)",
974 last_frame, src_x, src_y);
975 Error(ERR_RETURN, "custom graphic rejected for this element/action");
976 Error(ERR_RETURN_LINE, "-");
978 set_graphic_parameters(i, image->default_parameter);
981 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
982 /* currently we need only a tile clip mask from the first frame */
983 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
985 if (copy_clipmask_gc == None)
987 clip_gc_values.graphics_exposures = False;
988 clip_gc_valuemask = GCGraphicsExposures;
989 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
990 clip_gc_valuemask, &clip_gc_values);
993 graphic_info[i].clip_mask =
994 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
996 src_pixmap = src_bitmap->clip_mask;
997 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
998 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
1000 clip_gc_values.graphics_exposures = False;
1001 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
1002 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
1003 graphic_info[i].clip_gc =
1004 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1008 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1009 if (copy_clipmask_gc)
1010 XFreeGC(display, copy_clipmask_gc);
1013 clipmasks_initialized = TRUE;
1016 static void set_sound_parameters(int sound, int *parameter)
1018 /* explicit loop mode setting in configuration overrides default value */
1019 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1020 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1023 static void InitSoundInfo()
1025 int *sound_effect_properties;
1026 int num_sounds = getSoundListSize();
1029 if (sound_info != NULL)
1032 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1033 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1035 /* initialize sound effect for all elements to "no sound" */
1036 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1037 for (j=0; j<NUM_ACTIONS; j++)
1038 element_info[i].sound[j] = SND_UNDEFINED;
1040 for (i=0; i<num_sounds; i++)
1042 struct FileInfo *sound = getSoundListEntry(i);
1043 int len_effect_text = strlen(sound->token);
1045 sound_effect_properties[i] = ACTION_OTHER;
1046 sound_info[i].loop = FALSE;
1048 /* determine all loop sounds and identify certain sound classes */
1050 for (j=0; element_action_info[j].suffix; j++)
1052 int len_action_text = strlen(element_action_info[j].suffix);
1054 if (len_action_text < len_effect_text &&
1055 strcmp(&sound->token[len_effect_text - len_action_text],
1056 element_action_info[j].suffix) == 0)
1058 sound_effect_properties[i] = element_action_info[j].value;
1060 if (element_action_info[j].is_loop_sound)
1061 sound_info[i].loop = TRUE;
1065 /* associate elements and some selected sound actions */
1067 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1069 if (element_info[j].sound_class_name)
1071 int len_class_text = strlen(element_info[j].sound_class_name);
1073 if (len_class_text + 1 < len_effect_text &&
1074 strncmp(sound->token,
1075 element_info[j].sound_class_name, len_class_text) == 0 &&
1076 sound->token[len_class_text] == '.')
1078 int sound_action_value = sound_effect_properties[i];
1080 element_info[j].sound[sound_action_value] = i;
1085 set_sound_parameters(i, sound->parameter);
1088 free(sound_effect_properties);
1093 int element = EL_SAND;
1094 int sound_action = ACTION_DIGGING;
1097 while (element_action_info[j].suffix)
1099 if (element_action_info[j].value == sound_action)
1100 printf("element %d, sound action '%s' == %d\n",
1101 element, element_action_info[j].suffix,
1102 element_info_[element].sound[sound_action]);
1109 void InitElementProperties()
1113 static int ep_amoebalive[] =
1120 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1122 static int ep_amoeboid[] =
1130 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1132 static int ep_schluessel[] =
1143 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1145 static int ep_pforte[] =
1164 EL_SWITCHGATE_OPENING,
1165 EL_SWITCHGATE_CLOSED,
1166 EL_SWITCHGATE_CLOSING,
1168 EL_TIMEGATE_OPENING,
1170 EL_TIMEGATE_CLOSING,
1174 EL_TUBE_VERTICAL_LEFT,
1175 EL_TUBE_VERTICAL_RIGHT,
1176 EL_TUBE_HORIZONTAL_UP,
1177 EL_TUBE_HORIZONTAL_DOWN,
1183 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1185 static int ep_solid[] =
1205 EL_QUICKSAND_FILLING,
1206 EL_QUICKSAND_EMPTYING,
1208 EL_MAGIC_WALL_ACTIVE,
1209 EL_MAGIC_WALL_EMPTYING,
1210 EL_MAGIC_WALL_FILLING,
1214 EL_BD_MAGIC_WALL_ACTIVE,
1215 EL_BD_MAGIC_WALL_EMPTYING,
1216 EL_BD_MAGIC_WALL_FULL,
1217 EL_BD_MAGIC_WALL_FILLING,
1218 EL_BD_MAGIC_WALL_DEAD,
1221 EL_ACIDPOOL_TOPLEFT,
1222 EL_ACIDPOOL_TOPRIGHT,
1223 EL_ACIDPOOL_BOTTOMLEFT,
1225 EL_ACIDPOOL_BOTTOMRIGHT,
1243 EL_SP_TERMINAL_ACTIVE,
1246 EL_INVISIBLE_STEELWALL,
1247 EL_INVISIBLE_STEELWALL_ACTIVE,
1249 EL_INVISIBLE_WALL_ACTIVE,
1250 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1251 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1252 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1253 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1254 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1255 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1256 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1257 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1258 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1259 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1260 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1261 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1262 EL_SWITCHGATE_SWITCH_UP,
1263 EL_SWITCHGATE_SWITCH_DOWN,
1265 EL_LIGHT_SWITCH_ACTIVE,
1267 EL_TIMEGATE_SWITCH_ACTIVE,
1268 EL_SIGN_EXCLAMATION,
1269 EL_SIGN_RADIOACTIVITY,
1280 EL_STEELWALL_SLANTED,
1285 EL_EMC_WALL_PILLAR_UPPER,
1286 EL_EMC_WALL_PILLAR_MIDDLE,
1287 EL_EMC_WALL_PILLAR_LOWER,
1313 EL_SWITCHGATE_OPENING,
1314 EL_SWITCHGATE_CLOSED,
1315 EL_SWITCHGATE_CLOSING,
1317 EL_TIMEGATE_OPENING,
1319 EL_TIMEGATE_CLOSING,
1323 EL_TUBE_VERTICAL_LEFT,
1324 EL_TUBE_VERTICAL_RIGHT,
1325 EL_TUBE_HORIZONTAL_UP,
1326 EL_TUBE_HORIZONTAL_DOWN,
1332 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1334 static int ep_massive[] =
1338 EL_ACIDPOOL_TOPLEFT,
1339 EL_ACIDPOOL_TOPRIGHT,
1340 EL_ACIDPOOL_BOTTOMLEFT,
1342 EL_ACIDPOOL_BOTTOMRIGHT,
1354 EL_INVISIBLE_STEELWALL,
1355 EL_INVISIBLE_STEELWALL_ACTIVE,
1356 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1357 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1358 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1359 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1360 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1361 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1362 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1363 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1364 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1365 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1366 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1367 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1369 EL_LIGHT_SWITCH_ACTIVE,
1370 EL_SIGN_EXCLAMATION,
1371 EL_SIGN_RADIOACTIVITY,
1382 EL_STEELWALL_SLANTED,
1405 EL_SWITCHGATE_OPENING,
1406 EL_SWITCHGATE_CLOSED,
1407 EL_SWITCHGATE_CLOSING,
1409 EL_TIMEGATE_OPENING,
1411 EL_TIMEGATE_CLOSING,
1415 EL_TUBE_VERTICAL_LEFT,
1416 EL_TUBE_VERTICAL_RIGHT,
1417 EL_TUBE_HORIZONTAL_UP,
1418 EL_TUBE_HORIZONTAL_DOWN,
1424 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1426 static int ep_slippery[] =
1440 EL_ROBOT_WHEEL_ACTIVE,
1446 EL_ACIDPOOL_TOPLEFT,
1447 EL_ACIDPOOL_TOPRIGHT,
1457 EL_STEELWALL_SLANTED,
1461 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1463 static int ep_enemy[] =
1476 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1478 static int ep_mauer[] =
1506 EL_WALL_GROWING_ACTIVE,
1525 EL_SP_TERMINAL_ACTIVE,
1528 EL_INVISIBLE_STEELWALL,
1529 EL_INVISIBLE_STEELWALL_ACTIVE,
1531 EL_INVISIBLE_WALL_ACTIVE,
1532 EL_STEELWALL_SLANTED,
1537 EL_EMC_WALL_PILLAR_UPPER,
1538 EL_EMC_WALL_PILLAR_MIDDLE,
1539 EL_EMC_WALL_PILLAR_LOWER,
1546 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1548 static int ep_can_fall[] =
1563 EL_BD_MAGIC_WALL_FULL,
1574 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1576 static int ep_can_smash[] =
1607 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1609 static int ep_can_change[] =
1620 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1622 static int ep_can_move[] =
1642 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1644 static int ep_could_move[] =
1654 EL_BD_BUTTERFLY_RIGHT,
1656 EL_BD_BUTTERFLY_LEFT,
1657 EL_BD_BUTTERFLY_DOWN,
1658 EL_BD_FIREFLY_RIGHT,
1667 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1669 static int ep_dont_touch[] =
1676 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1678 static int ep_dont_go_to[] =
1692 EL_SP_BUGGY_BASE_ACTIVE,
1696 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1698 static int ep_mampf2[] =
1723 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1725 static int ep_bd_element[] =
1752 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1754 static int ep_sb_element[] =
1759 EL_SOKOBAN_FIELD_EMPTY,
1760 EL_SOKOBAN_FIELD_FULL,
1762 EL_INVISIBLE_STEELWALL
1764 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1766 static int ep_gem[] =
1775 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1777 static int ep_inactive[] =
1814 EL_INVISIBLE_STEELWALL,
1822 EL_WALL_EMERALD_YELLOW,
1827 EL_SOKOBAN_FIELD_EMPTY,
1828 EL_SOKOBAN_FIELD_FULL,
1829 EL_WALL_EMERALD_RED,
1830 EL_WALL_EMERALD_PURPLE,
1831 EL_ACIDPOOL_TOPLEFT,
1832 EL_ACIDPOOL_TOPRIGHT,
1833 EL_ACIDPOOL_BOTTOMLEFT,
1835 EL_ACIDPOOL_BOTTOMRIGHT,
1839 EL_BD_MAGIC_WALL_DEAD,
1840 EL_AMOEBA_TO_DIAMOND,
1873 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1874 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1875 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1876 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1877 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1878 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1879 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1880 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1881 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1882 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1883 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1884 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1885 EL_SIGN_EXCLAMATION,
1886 EL_SIGN_RADIOACTIVITY,
1897 EL_STEELWALL_SLANTED,
1902 EL_EMC_WALL_PILLAR_UPPER,
1903 EL_EMC_WALL_PILLAR_MIDDLE,
1904 EL_EMC_WALL_PILLAR_LOWER,
1911 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1913 static int ep_explosive[] =
1918 EL_DYNABOMB_PLAYER1_ACTIVE,
1919 EL_DYNABOMB_PLAYER2_ACTIVE,
1920 EL_DYNABOMB_PLAYER3_ACTIVE,
1921 EL_DYNABOMB_PLAYER4_ACTIVE,
1938 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1940 static int ep_mampf3[] =
1951 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1953 static int ep_pushable[] =
1960 EL_SOKOBAN_FIELD_FULL,
1970 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1972 static int ep_player[] =
1979 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1981 static int ep_has_content[] =
1989 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1991 static int ep_eatable[] =
1996 EL_SP_BUGGY_BASE_ACTIVATING,
1999 EL_INVISIBLE_SAND_ACTIVE
2001 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
2003 static int ep_sp_element[] =
2046 /* additional elements that appeared in newer Supaplex levels */
2048 /* more than one murphy in a level results in an inactive clone */
2051 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2053 static int ep_quick_gate[] =
2077 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2079 static int ep_over_player[] =
2095 EL_TUBE_VERTICAL_LEFT,
2096 EL_TUBE_VERTICAL_RIGHT,
2097 EL_TUBE_HORIZONTAL_UP,
2098 EL_TUBE_HORIZONTAL_DOWN,
2104 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2106 static int ep_active_bomb[] =
2109 EL_DYNABOMB_PLAYER1_ACTIVE,
2110 EL_DYNABOMB_PLAYER2_ACTIVE,
2111 EL_DYNABOMB_PLAYER3_ACTIVE,
2112 EL_DYNABOMB_PLAYER4_ACTIVE
2114 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2116 static int ep_belt[] =
2118 EL_CONVEYOR_BELT1_LEFT,
2119 EL_CONVEYOR_BELT1_MIDDLE,
2120 EL_CONVEYOR_BELT1_RIGHT,
2121 EL_CONVEYOR_BELT2_LEFT,
2122 EL_CONVEYOR_BELT2_MIDDLE,
2123 EL_CONVEYOR_BELT2_RIGHT,
2124 EL_CONVEYOR_BELT3_LEFT,
2125 EL_CONVEYOR_BELT3_MIDDLE,
2126 EL_CONVEYOR_BELT3_RIGHT,
2127 EL_CONVEYOR_BELT4_LEFT,
2128 EL_CONVEYOR_BELT4_MIDDLE,
2129 EL_CONVEYOR_BELT4_RIGHT,
2131 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2133 static int ep_belt_active[] =
2135 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2136 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2137 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2138 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2139 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2140 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2141 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2142 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2143 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2144 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2145 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2146 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2148 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2150 static int ep_belt_switch[] =
2152 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2153 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2154 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2155 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2156 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2157 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2158 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2159 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2160 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2161 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2162 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2163 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2165 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2167 static int ep_tube[] =
2172 EL_TUBE_VERTICAL_LEFT,
2173 EL_TUBE_VERTICAL_RIGHT,
2174 EL_TUBE_HORIZONTAL_UP,
2175 EL_TUBE_HORIZONTAL_DOWN,
2181 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2183 static long ep1_bit[] =
2217 static long ep2_bit[] =
2224 static int *ep1_array[] =
2258 static int *ep2_array[] =
2265 static int *ep1_num[] =
2292 &ep_has_content_num,
2296 &ep_over_player_num,
2299 static int *ep2_num[] =
2302 &ep_belt_active_num,
2303 &ep_belt_switch_num,
2306 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2307 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2309 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2315 for (i=0; i<num_properties1; i++)
2316 for (j=0; j<*(ep1_num[i]); j++)
2317 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2318 for (i=0; i<num_properties2; i++)
2319 for (j=0; j<*(ep2_num[i]); j++)
2320 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2322 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2323 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2326 void Execute_Command(char *command)
2328 if (strcmp(command, "print graphicsinfo.conf") == 0)
2332 printf("# You can configure additional/alternative image files here.\n");
2333 printf("# (The images below are default and therefore commented out.)\n");
2335 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2337 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2340 for (i=0; image_config[i].token != NULL; i++)
2342 getFormattedSetupEntry(image_config[i].token,
2343 image_config[i].value));
2347 else if (strcmp(command, "print soundsinfo.conf") == 0)
2351 printf("# You can configure additional/alternative sound files here.\n");
2352 printf("# (The sounds below are default and therefore commented out.)\n");
2354 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2356 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2359 for (i=0; sound_config[i].token != NULL; i++)
2361 getFormattedSetupEntry(sound_config[i].token,
2362 sound_config[i].value));
2366 else if (strcmp(command, "print musicinfo.conf") == 0)
2368 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2370 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2372 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2376 else if (strncmp(command, "dump level ", 11) == 0)
2378 char *filename = &command[11];
2380 if (access(filename, F_OK) != 0)
2381 Error(ERR_EXIT, "cannot open file '%s'", filename);
2383 LoadLevelFromFilename(filename);
2388 else if (strncmp(command, "dump tape ", 10) == 0)
2390 char *filename = &command[10];
2392 if (access(filename, F_OK) != 0)
2393 Error(ERR_EXIT, "cannot open file '%s'", filename);
2395 LoadTapeFromFilename(filename);
2400 else if (strncmp(command, "autoplay ", 9) == 0)
2402 char *str_copy = getStringCopy(&command[9]);
2403 char *str_ptr = strchr(str_copy, ' ');
2405 global.autoplay_leveldir = str_copy;
2406 global.autoplay_level_nr = -1;
2408 if (str_ptr != NULL)
2410 *str_ptr++ = '\0'; /* terminate leveldir string */
2411 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2416 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2420 void CloseAllAndExit(int exit_value)
2425 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2428 FreeTileClipmasks();
2430 if (bitmap_font_initial)
2431 FreeBitmap(bitmap_font_initial);
2433 CloseVideoDisplay();
2434 ClosePlatformDependantStuff();