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);
265 /* !!! TEST ONLY !!! */
271 SDL_Surface *dst = SDLZoomSurface(graphic_info[IMG_SAND].bitmap->surface,
273 tmp_bitmap.surface = dst;
275 BlitBitmap(&tmp_bitmap, graphic_info[IMG_SAND].bitmap,
276 0, 0, 256, 224, 0, 448);
278 SDL_FreeSurface(dst);
281 #elif defined(PLATFORM_MSDOS)
283 stretch_blit((BITMAP *)(graphic_info[IMG_SAND].bitmap->drawable),
284 (BITMAP *)(graphic_info[IMG_SAND].bitmap->drawable),
291 static void ReinitializeSounds()
293 InitElementSoundInfo(); /* initialize element/sound config info */
294 InitSoundInfo(); /* initialize sounds info from config file */
296 InitPlaySoundLevel(); /* initialize internal game sound values */
299 static void ReinitializeMusic()
301 /* currently nothing to do */
304 static void InitImages()
306 ReloadCustomImages();
307 ReinitializeGraphics();
309 LoadCustomElementDescriptions();
312 static void InitSound()
314 InitReloadCustomSounds(artwork.snd_current->identifier);
315 ReinitializeSounds();
318 static void InitMusic()
320 InitReloadCustomMusic(artwork.mus_current->identifier);
324 static void InitTileClipmasks()
327 #if defined(TARGET_X11)
328 XGCValues clip_gc_values;
329 unsigned long clip_gc_valuemask;
331 #if defined(TARGET_X11_NATIVE)
341 tile_needs_clipping[] =
343 { GFX_SPIELER1_UP, 4 },
344 { GFX_SPIELER1_DOWN, 4 },
345 { GFX_SPIELER1_LEFT, 4 },
346 { GFX_SPIELER1_RIGHT, 4 },
347 { GFX_SPIELER1_PUSH_LEFT, 4 },
348 { GFX_SPIELER1_PUSH_RIGHT, 4 },
349 { GFX_SPIELER2_UP, 4 },
350 { GFX_SPIELER2_DOWN, 4 },
351 { GFX_SPIELER2_LEFT, 4 },
352 { GFX_SPIELER2_RIGHT, 4 },
353 { GFX_SPIELER2_PUSH_LEFT, 4 },
354 { GFX_SPIELER2_PUSH_RIGHT, 4 },
355 { GFX_SPIELER3_UP, 4 },
356 { GFX_SPIELER3_DOWN, 4 },
357 { GFX_SPIELER3_LEFT, 4 },
358 { GFX_SPIELER3_RIGHT, 4 },
359 { GFX_SPIELER3_PUSH_LEFT, 4 },
360 { GFX_SPIELER3_PUSH_RIGHT, 4 },
361 { GFX_SPIELER4_UP, 4 },
362 { GFX_SPIELER4_DOWN, 4 },
363 { GFX_SPIELER4_LEFT, 4 },
364 { GFX_SPIELER4_RIGHT, 4 },
365 { GFX_SPIELER4_PUSH_LEFT, 4 },
366 { GFX_SPIELER4_PUSH_RIGHT, 4 },
367 { GFX_SP_MURPHY, 1 },
368 { GFX_MURPHY_GO_LEFT, 3 },
369 { GFX_MURPHY_GO_RIGHT, 3 },
370 { GFX_MURPHY_SNAP_UP, 1 },
371 { GFX_MURPHY_SNAP_DOWN, 1 },
372 { GFX_MURPHY_SNAP_RIGHT, 1 },
373 { GFX_MURPHY_SNAP_LEFT, 1 },
374 { GFX_MURPHY_PUSH_RIGHT, 1 },
375 { GFX_MURPHY_PUSH_LEFT, 1 },
376 { GFX_GEBLUBBER, 4 },
379 { GFX_EXPLOSION, 8 },
380 { GFX_SOKOBAN_OBJEKT, 1 },
381 { GFX_FUNKELN_BLAU, 3 },
382 { GFX_FUNKELN_WEISS, 3 },
383 { GFX2_SHIELD_PASSIVE, 3 },
384 { GFX2_SHIELD_ACTIVE, 3 },
389 #endif /* TARGET_X11_NATIVE */
390 #endif /* TARGET_X11 */
394 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
395 for (i=0; i<NUM_TILES; i++)
396 tile_clipmask[i] = None;
398 #if defined(TARGET_X11)
399 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
400 often very slow when preparing a masked XCopyArea() for big Pixmaps.
401 To prevent this, create small (tile-sized) mask Pixmaps which will then
402 be set much faster with XSetClipOrigin() and speed things up a lot. */
404 clip_gc_values.graphics_exposures = False;
405 clip_gc_valuemask = GCGraphicsExposures;
406 tile_clip_gc = XCreateGC(display, window->drawable,
407 clip_gc_valuemask, &clip_gc_values);
410 for (i=0; i<NUM_BITMAPS; i++)
412 if (pix[i]->clip_mask)
414 clip_gc_values.graphics_exposures = False;
415 clip_gc_values.clip_mask = pix[i]->clip_mask;
416 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
417 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
418 clip_gc_valuemask, &clip_gc_values);
423 #if defined(TARGET_X11_NATIVE)
426 /* create graphic context structures needed for clipping */
427 clip_gc_values.graphics_exposures = False;
428 clip_gc_valuemask = GCGraphicsExposures;
429 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
430 clip_gc_valuemask, &clip_gc_values);
432 /* create only those clipping Pixmaps we really need */
433 for (i=0; tile_needs_clipping[i].start>=0; i++)
437 for (j=0; j<tile_needs_clipping[i].count; j++)
439 int tile = tile_needs_clipping[i].start + j;
445 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
446 src_pixmap = src_bitmap->clip_mask;
448 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
451 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
452 src_x, src_y, TILEX, TILEY, 0, 0);
456 XFreeGC(display, copy_clipmask_gc);
459 #endif /* TARGET_X11_NATIVE */
460 #endif /* TARGET_X11 */
464 void FreeTileClipmasks()
467 #if defined(TARGET_X11)
470 for (i=0; i<NUM_TILES; i++)
472 if (tile_clipmask[i] != None)
474 XFreePixmap(display, tile_clipmask[i]);
475 tile_clipmask[i] = None;
480 XFreeGC(display, tile_clip_gc);
484 for (i=0; i<NUM_BITMAPS; i++)
486 if (pix[i] != NULL && pix[i]->stored_clip_gc)
488 XFreeGC(display, pix[i]->stored_clip_gc);
489 pix[i]->stored_clip_gc = None;
494 #endif /* TARGET_X11 */
504 /* initialize screen properties */
505 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
506 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
507 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
508 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
509 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
511 /* create additional image buffers for double-buffering */
512 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
513 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
516 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
518 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
520 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
522 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
525 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
526 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
528 DrawInitText("Loading graphics:", 120, FC_GREEN);
531 for (i=0; i<NUM_PICTURES; i++)
534 if (i != PIX_FONT_SMALL)
537 DrawInitText(image_filename[i], 150, FC_YELLOW);
539 pix[i] = LoadCustomImage(image_filename[i]);
545 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
552 void InitGfxBackground()
557 fieldbuffer = bitmap_db_field;
558 SetDrawtoField(DRAW_BACKBUFFER);
560 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
561 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
562 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
563 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
565 for (x=0; x<MAX_BUF_XSIZE; x++)
566 for (y=0; y<MAX_BUF_YSIZE; y++)
569 redraw_mask = REDRAW_ALL;
572 void ReloadCustomArtwork()
574 static char *leveldir_current_identifier = NULL;
575 static boolean last_override_level_graphics = FALSE;
576 static boolean last_override_level_sounds = FALSE;
577 static boolean last_override_level_music = FALSE;
578 /* identifier for new artwork; default: artwork configured in setup */
579 char *gfx_new_identifier = artwork.gfx_current->identifier;
580 char *snd_new_identifier = artwork.snd_current->identifier;
581 char *mus_new_identifier = artwork.mus_current->identifier;
582 boolean redraw_screen = FALSE;
584 if (leveldir_current_identifier == NULL)
585 leveldir_current_identifier = leveldir_current->identifier;
588 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
589 leveldir_current->graphics_set);
590 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
591 leveldir_current->identifier);
595 printf("graphics --> '%s' ('%s')\n",
596 artwork.gfx_current_identifier, artwork.gfx_current->filename);
597 printf("sounds --> '%s' ('%s')\n",
598 artwork.snd_current_identifier, artwork.snd_current->filename);
599 printf("music --> '%s' ('%s')\n",
600 artwork.mus_current_identifier, artwork.mus_current->filename);
603 /* leveldir_current may be invalid (level group, parent link) */
604 if (!validLevelSeries(leveldir_current))
607 /* when a new level series was selected, check if there was a change
608 in custom artwork stored in level series directory */
609 if (leveldir_current_identifier != leveldir_current->identifier)
611 char *identifier_old = leveldir_current_identifier;
612 char *identifier_new = leveldir_current->identifier;
614 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
615 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
616 gfx_new_identifier = identifier_new;
617 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
618 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
619 snd_new_identifier = identifier_new;
620 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
621 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
622 mus_new_identifier = identifier_new;
624 leveldir_current_identifier = leveldir_current->identifier;
627 /* custom level artwork configured in level series configuration file
628 always overrides custom level artwork stored in level series directory
629 and (level independant) custom artwork configured in setup menue */
630 if (leveldir_current->graphics_set != NULL)
631 gfx_new_identifier = leveldir_current->graphics_set;
632 if (leveldir_current->sounds_set != NULL)
633 snd_new_identifier = leveldir_current->sounds_set;
634 if (leveldir_current->music_set != NULL)
635 mus_new_identifier = leveldir_current->music_set;
637 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
638 last_override_level_graphics != setup.override_level_graphics)
641 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
642 artwork.gfx_current_identifier,
643 artwork.gfx_current->identifier,
647 setLevelArtworkDir(artwork.gfx_first);
649 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
651 ReloadCustomImages();
652 ReinitializeGraphics();
654 LoadCustomElementDescriptions();
659 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
660 last_override_level_graphics = setup.override_level_graphics;
662 redraw_screen = TRUE;
665 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
666 last_override_level_sounds != setup.override_level_sounds)
669 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
670 artwork.snd_current_identifier,
671 artwork.snd_current->identifier,
675 /* set artwork path to send it to the sound server process */
676 setLevelArtworkDir(artwork.snd_first);
678 InitReloadCustomSounds(snd_new_identifier);
679 ReinitializeSounds();
681 artwork.snd_current_identifier = artwork.snd_current->identifier;
682 last_override_level_sounds = setup.override_level_sounds;
684 redraw_screen = TRUE;
687 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
688 last_override_level_music != setup.override_level_music)
690 /* set artwork path to send it to the sound server process */
691 setLevelArtworkDir(artwork.mus_first);
693 InitReloadCustomMusic(mus_new_identifier);
696 artwork.mus_current_identifier = artwork.mus_current->identifier;
697 last_override_level_music = setup.override_level_music;
699 redraw_screen = TRUE;
706 /* force redraw of (open or closed) door graphics */
707 SetDoorState(DOOR_OPEN_ALL);
708 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
714 FreeLevelEditorGadgets();
723 static boolean gadgets_initialized = FALSE;
725 if (gadgets_initialized)
728 CreateLevelEditorGadgets();
732 CreateScreenGadgets();
734 gadgets_initialized = TRUE;
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 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 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 graphic = property_mapping[i].artwork_index;
789 action = ACTION_DEFAULT;
792 element_info[element].direction_graphic[action][direction] = graphic;
794 element_info[element].graphic[action] = graphic;
797 /* now set all '-1' values to element specific default values */
798 for (i=0; i<MAX_NUM_ELEMENTS; i++)
800 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
801 int default_action_direction_graphic[NUM_DIRECTIONS];
803 if (default_action_graphic == -1)
804 default_action_graphic = IMG_CHAR_QUESTION;
806 for (dir=0; dir<NUM_DIRECTIONS; dir++)
808 default_action_direction_graphic[dir] =
809 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
811 if (default_action_direction_graphic[dir] == -1)
812 default_action_direction_graphic[dir] = default_action_graphic;
815 for (act=0; act<NUM_ACTIONS; act++)
817 for (dir=0; dir<NUM_DIRECTIONS; dir++)
819 int default_direction_graphic = element_info[i].graphic[act];
821 /* no graphic for current action -- use default direction graphic */
822 if (default_direction_graphic == -1)
823 default_direction_graphic = default_action_direction_graphic[dir];
825 if (element_info[i].direction_graphic[act][dir] == -1)
826 element_info[i].direction_graphic[act][dir] =
827 default_direction_graphic;
830 /* no graphic for this specific action -- use default action graphic */
831 if (element_info[i].graphic[act] == -1)
832 element_info[i].graphic[act] = default_action_graphic;
837 static void InitElementSoundInfo()
842 static void set_graphic_parameters(int graphic, int *parameter)
844 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
845 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
846 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
848 graphic_info[graphic].bitmap = src_bitmap;
850 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
851 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
852 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
853 graphic_info[graphic].offset_y = 0;
855 /* animation frames are ordered vertically instead of horizontally */
856 if (parameter[GFX_ARG_VERTICAL])
858 graphic_info[graphic].offset_x = 0;
859 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
862 /* optionally, the x and y offset of frames can be specified directly */
863 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
864 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
865 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
866 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
868 /* automatically determine correct number of frames, if not defined */
869 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
870 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
871 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
872 graphic_info[graphic].anim_frames = num_xtiles;
873 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
874 graphic_info[graphic].anim_frames = num_ytiles;
876 graphic_info[graphic].anim_frames = 1;
878 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
879 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
880 graphic_info[graphic].anim_delay = 1;
882 /* set mode for animation frame order */
883 if (parameter[GFX_ARG_MODE_LOOP])
884 graphic_info[graphic].anim_mode = ANIM_LOOP;
885 else if (parameter[GFX_ARG_MODE_LINEAR])
886 graphic_info[graphic].anim_mode = ANIM_LINEAR;
887 else if (parameter[GFX_ARG_MODE_PINGPONG])
888 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
889 else if (parameter[GFX_ARG_MODE_PINGPONG2])
890 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
891 else if (parameter[GFX_ARG_MODE_RANDOM])
892 graphic_info[graphic].anim_mode = ANIM_RANDOM;
893 else if (graphic_info[graphic].anim_frames > 1)
894 graphic_info[graphic].anim_mode = ANIM_LOOP;
896 graphic_info[graphic].anim_mode = ANIM_NONE;
898 /* set additional flag to play animation frames in reverse order */
899 if (parameter[GFX_ARG_MODE_REVERSE])
900 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
902 /* automatically determine correct start frame, if not defined */
903 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
904 graphic_info[graphic].anim_start_frame = 0;
905 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
906 graphic_info[graphic].anim_start_frame =
907 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
909 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
911 /* animation synchronized with global frame counter, not move position */
912 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
915 static void InitGraphicInfo()
917 static boolean clipmasks_initialized = FALSE;
918 int num_images = getImageListSize();
920 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
922 XGCValues clip_gc_values;
923 unsigned long clip_gc_valuemask;
924 GC copy_clipmask_gc = None;
927 if (graphic_info != NULL)
930 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
932 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
933 if (clipmasks_initialized)
935 for (i=0; i<num_images; i++)
937 if (graphic_info[i].clip_mask)
938 XFreePixmap(display, graphic_info[i].clip_mask);
939 if (graphic_info[i].clip_gc)
940 XFreeGC(display, graphic_info[i].clip_gc);
942 graphic_info[i].clip_mask = None;
943 graphic_info[i].clip_gc = None;
948 for (i=0; i<num_images; i++)
950 struct FileInfo *image = getImageListEntry(i);
953 int first_frame, last_frame;
955 set_graphic_parameters(i, image->parameter);
957 /* now check if no animation frames are outside of the loaded image */
959 if (graphic_info[i].bitmap == NULL)
960 continue; /* skip check for optional images that are undefined */
963 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
964 if (src_x < 0 || src_y < 0 ||
965 src_x + TILEX > src_bitmap->width ||
966 src_y + TILEY > src_bitmap->height)
968 Error(ERR_RETURN_LINE, "-");
969 Error(ERR_RETURN, "warning: error found in config file:");
970 Error(ERR_RETURN, "- config file: '%s'",
971 getImageConfigFilename());
972 Error(ERR_RETURN, "- config token: '%s'",
973 getTokenFromImageID(i));
974 Error(ERR_RETURN, "- image file: '%s'",
975 src_bitmap->source_filename);
977 "error: first animation frame out of bounds (%d, %d)",
979 Error(ERR_RETURN, "custom graphic rejected for this element/action");
980 Error(ERR_RETURN_LINE, "-");
982 set_graphic_parameters(i, image->default_parameter);
985 last_frame = graphic_info[i].anim_frames - 1;
986 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
987 if (src_x < 0 || src_y < 0 ||
988 src_x + TILEX > src_bitmap->width ||
989 src_y + TILEY > src_bitmap->height)
991 Error(ERR_RETURN_LINE, "-");
992 Error(ERR_RETURN, "warning: error found in config file:");
993 Error(ERR_RETURN, "- config file: '%s'",
994 getImageConfigFilename());
995 Error(ERR_RETURN, "- config token: '%s'",
996 getTokenFromImageID(i));
997 Error(ERR_RETURN, "- image file: '%s'",
998 src_bitmap->source_filename);
1000 "error: last animation frame (%d) out of bounds (%d, %d)",
1001 last_frame, src_x, src_y);
1002 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1003 Error(ERR_RETURN_LINE, "-");
1005 set_graphic_parameters(i, image->default_parameter);
1008 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1009 /* currently we need only a tile clip mask from the first frame */
1010 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1012 if (copy_clipmask_gc == None)
1014 clip_gc_values.graphics_exposures = False;
1015 clip_gc_valuemask = GCGraphicsExposures;
1016 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
1017 clip_gc_valuemask, &clip_gc_values);
1020 graphic_info[i].clip_mask =
1021 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
1023 src_pixmap = src_bitmap->clip_mask;
1024 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
1025 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
1027 clip_gc_values.graphics_exposures = False;
1028 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
1029 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
1030 graphic_info[i].clip_gc =
1031 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1035 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1036 if (copy_clipmask_gc)
1037 XFreeGC(display, copy_clipmask_gc);
1040 clipmasks_initialized = TRUE;
1043 static void set_sound_parameters(int sound, int *parameter)
1045 /* explicit loop mode setting in configuration overrides default value */
1046 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1047 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1050 static void InitSoundInfo()
1052 int *sound_effect_properties;
1053 int num_sounds = getSoundListSize();
1056 if (sound_info != NULL)
1059 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1060 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1062 /* initialize sound effect for all elements to "no sound" */
1063 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1064 for (j=0; j<NUM_ACTIONS; j++)
1065 element_info[i].sound[j] = SND_UNDEFINED;
1067 for (i=0; i<num_sounds; i++)
1069 struct FileInfo *sound = getSoundListEntry(i);
1070 int len_effect_text = strlen(sound->token);
1072 sound_effect_properties[i] = ACTION_OTHER;
1073 sound_info[i].loop = FALSE;
1075 /* determine all loop sounds and identify certain sound classes */
1077 for (j=0; element_action_info[j].suffix; j++)
1079 int len_action_text = strlen(element_action_info[j].suffix);
1081 if (len_action_text < len_effect_text &&
1082 strcmp(&sound->token[len_effect_text - len_action_text],
1083 element_action_info[j].suffix) == 0)
1085 sound_effect_properties[i] = element_action_info[j].value;
1087 if (element_action_info[j].is_loop_sound)
1088 sound_info[i].loop = TRUE;
1092 /* associate elements and some selected sound actions */
1094 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1096 if (element_info[j].sound_class_name)
1098 int len_class_text = strlen(element_info[j].sound_class_name);
1100 if (len_class_text + 1 < len_effect_text &&
1101 strncmp(sound->token,
1102 element_info[j].sound_class_name, len_class_text) == 0 &&
1103 sound->token[len_class_text] == '.')
1105 int sound_action_value = sound_effect_properties[i];
1107 element_info[j].sound[sound_action_value] = i;
1112 set_sound_parameters(i, sound->parameter);
1115 free(sound_effect_properties);
1120 int element = EL_SAND;
1121 int sound_action = ACTION_DIGGING;
1124 while (element_action_info[j].suffix)
1126 if (element_action_info[j].value == sound_action)
1127 printf("element %d, sound action '%s' == %d\n",
1128 element, element_action_info[j].suffix,
1129 element_info_[element].sound[sound_action]);
1136 void InitElementProperties()
1140 static int ep_amoebalive[] =
1147 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1149 static int ep_amoeboid[] =
1157 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1159 static int ep_schluessel[] =
1170 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1172 static int ep_pforte[] =
1191 EL_SWITCHGATE_OPENING,
1192 EL_SWITCHGATE_CLOSED,
1193 EL_SWITCHGATE_CLOSING,
1195 EL_TIMEGATE_OPENING,
1197 EL_TIMEGATE_CLOSING,
1201 EL_TUBE_VERTICAL_LEFT,
1202 EL_TUBE_VERTICAL_RIGHT,
1203 EL_TUBE_HORIZONTAL_UP,
1204 EL_TUBE_HORIZONTAL_DOWN,
1210 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1212 static int ep_solid[] =
1232 EL_QUICKSAND_FILLING,
1233 EL_QUICKSAND_EMPTYING,
1235 EL_MAGIC_WALL_ACTIVE,
1236 EL_MAGIC_WALL_EMPTYING,
1237 EL_MAGIC_WALL_FILLING,
1241 EL_BD_MAGIC_WALL_ACTIVE,
1242 EL_BD_MAGIC_WALL_EMPTYING,
1243 EL_BD_MAGIC_WALL_FULL,
1244 EL_BD_MAGIC_WALL_FILLING,
1245 EL_BD_MAGIC_WALL_DEAD,
1248 EL_ACIDPOOL_TOPLEFT,
1249 EL_ACIDPOOL_TOPRIGHT,
1250 EL_ACIDPOOL_BOTTOMLEFT,
1252 EL_ACIDPOOL_BOTTOMRIGHT,
1270 EL_SP_TERMINAL_ACTIVE,
1273 EL_INVISIBLE_STEELWALL,
1274 EL_INVISIBLE_STEELWALL_ACTIVE,
1276 EL_INVISIBLE_WALL_ACTIVE,
1277 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1278 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1279 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1280 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1281 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1282 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1283 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1284 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1285 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1286 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1287 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1288 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1289 EL_SWITCHGATE_SWITCH_UP,
1290 EL_SWITCHGATE_SWITCH_DOWN,
1292 EL_LIGHT_SWITCH_ACTIVE,
1294 EL_TIMEGATE_SWITCH_ACTIVE,
1295 EL_SIGN_EXCLAMATION,
1296 EL_SIGN_RADIOACTIVITY,
1307 EL_STEELWALL_SLANTED,
1312 EL_EMC_WALL_PILLAR_UPPER,
1313 EL_EMC_WALL_PILLAR_MIDDLE,
1314 EL_EMC_WALL_PILLAR_LOWER,
1340 EL_SWITCHGATE_OPENING,
1341 EL_SWITCHGATE_CLOSED,
1342 EL_SWITCHGATE_CLOSING,
1344 EL_TIMEGATE_OPENING,
1346 EL_TIMEGATE_CLOSING,
1350 EL_TUBE_VERTICAL_LEFT,
1351 EL_TUBE_VERTICAL_RIGHT,
1352 EL_TUBE_HORIZONTAL_UP,
1353 EL_TUBE_HORIZONTAL_DOWN,
1359 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1361 static int ep_massive[] =
1365 EL_ACIDPOOL_TOPLEFT,
1366 EL_ACIDPOOL_TOPRIGHT,
1367 EL_ACIDPOOL_BOTTOMLEFT,
1369 EL_ACIDPOOL_BOTTOMRIGHT,
1381 EL_INVISIBLE_STEELWALL,
1382 EL_INVISIBLE_STEELWALL_ACTIVE,
1383 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1384 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1385 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1386 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1387 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1388 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1389 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1390 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1391 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1392 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1393 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1394 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1396 EL_LIGHT_SWITCH_ACTIVE,
1397 EL_SIGN_EXCLAMATION,
1398 EL_SIGN_RADIOACTIVITY,
1409 EL_STEELWALL_SLANTED,
1432 EL_SWITCHGATE_OPENING,
1433 EL_SWITCHGATE_CLOSED,
1434 EL_SWITCHGATE_CLOSING,
1436 EL_TIMEGATE_OPENING,
1438 EL_TIMEGATE_CLOSING,
1442 EL_TUBE_VERTICAL_LEFT,
1443 EL_TUBE_VERTICAL_RIGHT,
1444 EL_TUBE_HORIZONTAL_UP,
1445 EL_TUBE_HORIZONTAL_DOWN,
1451 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1453 static int ep_slippery[] =
1467 EL_ROBOT_WHEEL_ACTIVE,
1473 EL_ACIDPOOL_TOPLEFT,
1474 EL_ACIDPOOL_TOPRIGHT,
1484 EL_STEELWALL_SLANTED,
1488 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1490 static int ep_enemy[] =
1503 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1505 static int ep_mauer[] =
1533 EL_WALL_GROWING_ACTIVE,
1552 EL_SP_TERMINAL_ACTIVE,
1555 EL_INVISIBLE_STEELWALL,
1556 EL_INVISIBLE_STEELWALL_ACTIVE,
1558 EL_INVISIBLE_WALL_ACTIVE,
1559 EL_STEELWALL_SLANTED,
1564 EL_EMC_WALL_PILLAR_UPPER,
1565 EL_EMC_WALL_PILLAR_MIDDLE,
1566 EL_EMC_WALL_PILLAR_LOWER,
1573 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1575 static int ep_can_fall[] =
1590 EL_BD_MAGIC_WALL_FULL,
1601 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1603 static int ep_can_smash[] =
1634 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1636 static int ep_can_change[] =
1647 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1649 static int ep_can_move[] =
1669 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1671 static int ep_could_move[] =
1681 EL_BD_BUTTERFLY_RIGHT,
1683 EL_BD_BUTTERFLY_LEFT,
1684 EL_BD_BUTTERFLY_DOWN,
1685 EL_BD_FIREFLY_RIGHT,
1694 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1696 static int ep_dont_touch[] =
1703 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1705 static int ep_dont_go_to[] =
1719 EL_SP_BUGGY_BASE_ACTIVE,
1723 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1725 static int ep_mampf2[] =
1750 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1752 static int ep_bd_element[] =
1779 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1781 static int ep_sb_element[] =
1786 EL_SOKOBAN_FIELD_EMPTY,
1787 EL_SOKOBAN_FIELD_FULL,
1789 EL_INVISIBLE_STEELWALL
1791 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1793 static int ep_gem[] =
1802 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1804 static int ep_inactive[] =
1841 EL_INVISIBLE_STEELWALL,
1849 EL_WALL_EMERALD_YELLOW,
1854 EL_SOKOBAN_FIELD_EMPTY,
1855 EL_SOKOBAN_FIELD_FULL,
1856 EL_WALL_EMERALD_RED,
1857 EL_WALL_EMERALD_PURPLE,
1858 EL_ACIDPOOL_TOPLEFT,
1859 EL_ACIDPOOL_TOPRIGHT,
1860 EL_ACIDPOOL_BOTTOMLEFT,
1862 EL_ACIDPOOL_BOTTOMRIGHT,
1866 EL_BD_MAGIC_WALL_DEAD,
1867 EL_AMOEBA_TO_DIAMOND,
1900 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1901 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1902 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1903 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1904 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1905 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1906 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1907 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1908 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1909 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1910 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1911 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1912 EL_SIGN_EXCLAMATION,
1913 EL_SIGN_RADIOACTIVITY,
1924 EL_STEELWALL_SLANTED,
1929 EL_EMC_WALL_PILLAR_UPPER,
1930 EL_EMC_WALL_PILLAR_MIDDLE,
1931 EL_EMC_WALL_PILLAR_LOWER,
1938 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1940 static int ep_explosive[] =
1945 EL_DYNABOMB_PLAYER1_ACTIVE,
1946 EL_DYNABOMB_PLAYER2_ACTIVE,
1947 EL_DYNABOMB_PLAYER3_ACTIVE,
1948 EL_DYNABOMB_PLAYER4_ACTIVE,
1965 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1967 static int ep_mampf3[] =
1978 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1980 static int ep_pushable[] =
1987 EL_SOKOBAN_FIELD_FULL,
1997 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1999 static int ep_player[] =
2006 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
2008 static int ep_has_content[] =
2016 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
2018 static int ep_eatable[] =
2023 EL_SP_BUGGY_BASE_ACTIVATING,
2026 EL_INVISIBLE_SAND_ACTIVE
2028 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
2030 static int ep_sp_element[] =
2073 /* additional elements that appeared in newer Supaplex levels */
2075 /* more than one murphy in a level results in an inactive clone */
2078 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2080 static int ep_quick_gate[] =
2104 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2106 static int ep_over_player[] =
2122 EL_TUBE_VERTICAL_LEFT,
2123 EL_TUBE_VERTICAL_RIGHT,
2124 EL_TUBE_HORIZONTAL_UP,
2125 EL_TUBE_HORIZONTAL_DOWN,
2131 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2133 static int ep_active_bomb[] =
2136 EL_DYNABOMB_PLAYER1_ACTIVE,
2137 EL_DYNABOMB_PLAYER2_ACTIVE,
2138 EL_DYNABOMB_PLAYER3_ACTIVE,
2139 EL_DYNABOMB_PLAYER4_ACTIVE
2141 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2143 static int ep_belt[] =
2145 EL_CONVEYOR_BELT1_LEFT,
2146 EL_CONVEYOR_BELT1_MIDDLE,
2147 EL_CONVEYOR_BELT1_RIGHT,
2148 EL_CONVEYOR_BELT2_LEFT,
2149 EL_CONVEYOR_BELT2_MIDDLE,
2150 EL_CONVEYOR_BELT2_RIGHT,
2151 EL_CONVEYOR_BELT3_LEFT,
2152 EL_CONVEYOR_BELT3_MIDDLE,
2153 EL_CONVEYOR_BELT3_RIGHT,
2154 EL_CONVEYOR_BELT4_LEFT,
2155 EL_CONVEYOR_BELT4_MIDDLE,
2156 EL_CONVEYOR_BELT4_RIGHT,
2158 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2160 static int ep_belt_active[] =
2162 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2163 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2164 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2165 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2166 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2167 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2168 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2169 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2170 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2171 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2172 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2173 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2175 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2177 static int ep_belt_switch[] =
2179 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2180 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2181 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2182 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2183 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2184 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2185 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2186 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2187 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2188 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2189 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2190 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2192 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2194 static int ep_tube[] =
2199 EL_TUBE_VERTICAL_LEFT,
2200 EL_TUBE_VERTICAL_RIGHT,
2201 EL_TUBE_HORIZONTAL_UP,
2202 EL_TUBE_HORIZONTAL_DOWN,
2208 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2210 static long ep1_bit[] =
2244 static long ep2_bit[] =
2251 static int *ep1_array[] =
2285 static int *ep2_array[] =
2292 static int *ep1_num[] =
2319 &ep_has_content_num,
2323 &ep_over_player_num,
2326 static int *ep2_num[] =
2329 &ep_belt_active_num,
2330 &ep_belt_switch_num,
2333 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2334 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2336 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2342 for (i=0; i<num_properties1; i++)
2343 for (j=0; j<*(ep1_num[i]); j++)
2344 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2345 for (i=0; i<num_properties2; i++)
2346 for (j=0; j<*(ep2_num[i]); j++)
2347 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2349 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2350 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2353 void Execute_Command(char *command)
2355 if (strcmp(command, "print graphicsinfo.conf") == 0)
2359 printf("# You can configure additional/alternative image files here.\n");
2360 printf("# (The images below are default and therefore commented out.)\n");
2362 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2364 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2367 for (i=0; image_config[i].token != NULL; i++)
2369 getFormattedSetupEntry(image_config[i].token,
2370 image_config[i].value));
2374 else if (strcmp(command, "print soundsinfo.conf") == 0)
2378 printf("# You can configure additional/alternative sound files here.\n");
2379 printf("# (The sounds below are default and therefore commented out.)\n");
2381 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2383 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2386 for (i=0; sound_config[i].token != NULL; i++)
2388 getFormattedSetupEntry(sound_config[i].token,
2389 sound_config[i].value));
2393 else if (strcmp(command, "print musicinfo.conf") == 0)
2395 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2397 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2399 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2403 else if (strncmp(command, "dump level ", 11) == 0)
2405 char *filename = &command[11];
2407 if (access(filename, F_OK) != 0)
2408 Error(ERR_EXIT, "cannot open file '%s'", filename);
2410 LoadLevelFromFilename(filename);
2415 else if (strncmp(command, "dump tape ", 10) == 0)
2417 char *filename = &command[10];
2419 if (access(filename, F_OK) != 0)
2420 Error(ERR_EXIT, "cannot open file '%s'", filename);
2422 LoadTapeFromFilename(filename);
2427 else if (strncmp(command, "autoplay ", 9) == 0)
2429 char *str_copy = getStringCopy(&command[9]);
2430 char *str_ptr = strchr(str_copy, ' ');
2432 global.autoplay_leveldir = str_copy;
2433 global.autoplay_level_nr = -1;
2435 if (str_ptr != NULL)
2437 *str_ptr++ = '\0'; /* terminate leveldir string */
2438 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2443 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2447 void CloseAllAndExit(int exit_value)
2452 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2455 FreeTileClipmasks();
2457 if (bitmap_font_initial)
2458 FreeBitmap(bitmap_font_initial);
2460 CloseVideoDisplay();
2461 ClosePlatformDependantStuff();