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 InitElementInfo(void);
77 static void InitGraphicInfo(void);
78 static void InitSoundInfo();
79 static void Execute_Command(char *);
83 InitGlobal(); /* initialize some global variables */
85 if (options.execute_command)
86 Execute_Command(options.execute_command);
88 if (options.serveronly)
90 #if defined(PLATFORM_UNIX)
91 NetworkServer(options.server_port, options.serveronly);
93 Error(ERR_WARN, "networking only supported in Unix version");
95 exit(0); /* never reached */
98 InitProgramInfo(UNIX_USERDATA_DIRECTORY,
99 PROGRAM_TITLE_STRING, getWindowTitleString(),
100 ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
101 MSDOS_POINTER_FILENAME,
102 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
106 InitArtworkInfo(); /* needed before loading gfx, sound & music */
107 InitArtworkConfig(); /* needed before forking sound child process */
113 InitRND(NEW_RANDOMIZE);
116 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
119 InitEventFilter(FilterMouseMotionEvents);
121 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 + 1; i++)
195 element_prefix[i] = element_info[i].token_name;
196 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
197 sound_class_prefix[i] = element_info[i].sound_class_name;
198 for (i=0; i<NUM_ACTIONS + 1; i++)
199 action_suffix[i] = element_action_info[i].suffix;
200 for (i=0; i<NUM_DIRECTIONS + 1; i++)
201 direction_suffix[i] = element_direction_info[i].suffix;
203 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
204 element_prefix, action_suffix, direction_suffix);
205 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
206 sound_class_prefix, action_suffix, dummy);
209 void InitLevelArtworkInfo()
211 LoadLevelArtworkInfo();
214 void InitNetworkServer()
216 #if defined(PLATFORM_UNIX)
220 if (!options.network)
223 #if defined(PLATFORM_UNIX)
224 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
226 if (!ConnectToServer(options.server_host, options.server_port))
227 Error(ERR_EXIT, "cannot connect to network game server");
229 SendToServer_PlayerName(setup.player_name);
230 SendToServer_ProtocolVersion();
233 SendToServer_NrWanted(nr_wanted);
237 static void InitMixer()
243 static void ReinitializeGraphics()
245 InitGraphicInfo(); /* initialize graphic info from config file */
247 InitFontInfo(bitmap_font_initial,
248 graphic_info[IMG_FONT_BIG].bitmap,
249 graphic_info[IMG_FONT_MEDIUM].bitmap,
250 graphic_info[IMG_FONT_SMALL].bitmap,
251 graphic_info[IMG_FONT_EM].bitmap);
253 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
254 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
260 static void ReinitializeSounds()
262 InitSoundInfo(); /* initialize sounds info from config file */
264 InitPlaySoundLevel();
267 static void ReinitializeMusic()
269 /* currently nothing to do */
272 static void InitImages()
274 ReloadCustomImages();
275 ReinitializeGraphics();
278 static void InitSound()
280 InitReloadCustomSounds(artwork.snd_current->identifier);
281 ReinitializeSounds();
284 static void InitMusic()
286 InitReloadCustomMusic(artwork.mus_current->identifier);
290 static void InitTileClipmasks()
293 #if defined(TARGET_X11)
294 XGCValues clip_gc_values;
295 unsigned long clip_gc_valuemask;
297 #if defined(TARGET_X11_NATIVE)
307 tile_needs_clipping[] =
309 { GFX_SPIELER1_UP, 4 },
310 { GFX_SPIELER1_DOWN, 4 },
311 { GFX_SPIELER1_LEFT, 4 },
312 { GFX_SPIELER1_RIGHT, 4 },
313 { GFX_SPIELER1_PUSH_LEFT, 4 },
314 { GFX_SPIELER1_PUSH_RIGHT, 4 },
315 { GFX_SPIELER2_UP, 4 },
316 { GFX_SPIELER2_DOWN, 4 },
317 { GFX_SPIELER2_LEFT, 4 },
318 { GFX_SPIELER2_RIGHT, 4 },
319 { GFX_SPIELER2_PUSH_LEFT, 4 },
320 { GFX_SPIELER2_PUSH_RIGHT, 4 },
321 { GFX_SPIELER3_UP, 4 },
322 { GFX_SPIELER3_DOWN, 4 },
323 { GFX_SPIELER3_LEFT, 4 },
324 { GFX_SPIELER3_RIGHT, 4 },
325 { GFX_SPIELER3_PUSH_LEFT, 4 },
326 { GFX_SPIELER3_PUSH_RIGHT, 4 },
327 { GFX_SPIELER4_UP, 4 },
328 { GFX_SPIELER4_DOWN, 4 },
329 { GFX_SPIELER4_LEFT, 4 },
330 { GFX_SPIELER4_RIGHT, 4 },
331 { GFX_SPIELER4_PUSH_LEFT, 4 },
332 { GFX_SPIELER4_PUSH_RIGHT, 4 },
333 { GFX_SP_MURPHY, 1 },
334 { GFX_MURPHY_GO_LEFT, 3 },
335 { GFX_MURPHY_GO_RIGHT, 3 },
336 { GFX_MURPHY_SNAP_UP, 1 },
337 { GFX_MURPHY_SNAP_DOWN, 1 },
338 { GFX_MURPHY_SNAP_RIGHT, 1 },
339 { GFX_MURPHY_SNAP_LEFT, 1 },
340 { GFX_MURPHY_PUSH_RIGHT, 1 },
341 { GFX_MURPHY_PUSH_LEFT, 1 },
342 { GFX_GEBLUBBER, 4 },
345 { GFX_EXPLOSION, 8 },
346 { GFX_SOKOBAN_OBJEKT, 1 },
347 { GFX_FUNKELN_BLAU, 3 },
348 { GFX_FUNKELN_WEISS, 3 },
349 { GFX2_SHIELD_PASSIVE, 3 },
350 { GFX2_SHIELD_ACTIVE, 3 },
355 #endif /* TARGET_X11_NATIVE */
356 #endif /* TARGET_X11 */
360 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
361 for (i=0; i<NUM_TILES; i++)
362 tile_clipmask[i] = None;
364 #if defined(TARGET_X11)
365 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
366 often very slow when preparing a masked XCopyArea() for big Pixmaps.
367 To prevent this, create small (tile-sized) mask Pixmaps which will then
368 be set much faster with XSetClipOrigin() and speed things up a lot. */
370 clip_gc_values.graphics_exposures = False;
371 clip_gc_valuemask = GCGraphicsExposures;
372 tile_clip_gc = XCreateGC(display, window->drawable,
373 clip_gc_valuemask, &clip_gc_values);
376 for (i=0; i<NUM_BITMAPS; i++)
378 if (pix[i]->clip_mask)
380 clip_gc_values.graphics_exposures = False;
381 clip_gc_values.clip_mask = pix[i]->clip_mask;
382 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
383 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
384 clip_gc_valuemask, &clip_gc_values);
389 #if defined(TARGET_X11_NATIVE)
392 /* create graphic context structures needed for clipping */
393 clip_gc_values.graphics_exposures = False;
394 clip_gc_valuemask = GCGraphicsExposures;
395 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
396 clip_gc_valuemask, &clip_gc_values);
398 /* create only those clipping Pixmaps we really need */
399 for (i=0; tile_needs_clipping[i].start>=0; i++)
403 for (j=0; j<tile_needs_clipping[i].count; j++)
405 int tile = tile_needs_clipping[i].start + j;
411 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
412 src_pixmap = src_bitmap->clip_mask;
414 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
417 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
418 src_x, src_y, TILEX, TILEY, 0, 0);
422 XFreeGC(display, copy_clipmask_gc);
425 #endif /* TARGET_X11_NATIVE */
426 #endif /* TARGET_X11 */
430 void FreeTileClipmasks()
433 #if defined(TARGET_X11)
436 for (i=0; i<NUM_TILES; i++)
438 if (tile_clipmask[i] != None)
440 XFreePixmap(display, tile_clipmask[i]);
441 tile_clipmask[i] = None;
446 XFreeGC(display, tile_clip_gc);
450 for (i=0; i<NUM_BITMAPS; i++)
452 if (pix[i] != NULL && pix[i]->stored_clip_gc)
454 XFreeGC(display, pix[i]->stored_clip_gc);
455 pix[i]->stored_clip_gc = None;
460 #endif /* TARGET_X11 */
470 /* initialize screen properties */
471 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
472 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
473 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
474 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
475 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
477 /* create additional image buffers for double-buffering */
478 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
479 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
482 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
484 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
486 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
488 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
491 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
492 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
494 DrawInitText("Loading graphics:", 120, FC_GREEN);
497 for (i=0; i<NUM_PICTURES; i++)
500 if (i != PIX_FONT_SMALL)
503 DrawInitText(image_filename[i], 150, FC_YELLOW);
505 pix[i] = LoadCustomImage(image_filename[i]);
511 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
518 void InitGfxBackground()
523 fieldbuffer = bitmap_db_field;
524 SetDrawtoField(DRAW_BACKBUFFER);
526 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
527 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
528 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
529 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
531 for (x=0; x<MAX_BUF_XSIZE; x++)
532 for (y=0; y<MAX_BUF_YSIZE; y++)
535 redraw_mask = REDRAW_ALL;
538 void ReloadCustomArtwork()
540 static char *leveldir_current_identifier = NULL;
541 static boolean last_override_level_graphics = FALSE;
542 static boolean last_override_level_sounds = FALSE;
543 static boolean last_override_level_music = FALSE;
544 /* identifier for new artwork; default: artwork configured in setup */
545 char *gfx_new_identifier = artwork.gfx_current->identifier;
546 char *snd_new_identifier = artwork.snd_current->identifier;
547 char *mus_new_identifier = artwork.mus_current->identifier;
548 boolean redraw_screen = FALSE;
550 if (leveldir_current_identifier == NULL)
551 leveldir_current_identifier = leveldir_current->identifier;
554 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
555 leveldir_current->graphics_set);
556 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
557 leveldir_current->identifier);
561 printf("graphics --> '%s' ('%s')\n",
562 artwork.gfx_current_identifier, artwork.gfx_current->filename);
563 printf("sounds --> '%s' ('%s')\n",
564 artwork.snd_current_identifier, artwork.snd_current->filename);
565 printf("music --> '%s' ('%s')\n",
566 artwork.mus_current_identifier, artwork.mus_current->filename);
569 /* leveldir_current may be invalid (level group, parent link) */
570 if (!validLevelSeries(leveldir_current))
573 /* when a new level series was selected, check if there was a change
574 in custom artwork stored in level series directory */
575 if (leveldir_current_identifier != leveldir_current->identifier)
577 char *identifier_old = leveldir_current_identifier;
578 char *identifier_new = leveldir_current->identifier;
580 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
581 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
582 gfx_new_identifier = identifier_new;
583 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
584 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
585 snd_new_identifier = identifier_new;
586 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
587 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
588 mus_new_identifier = identifier_new;
590 leveldir_current_identifier = leveldir_current->identifier;
593 /* custom level artwork configured in level series configuration file
594 always overrides custom level artwork stored in level series directory
595 and (level independant) custom artwork configured in setup menue */
596 if (leveldir_current->graphics_set != NULL)
597 gfx_new_identifier = leveldir_current->graphics_set;
598 if (leveldir_current->sounds_set != NULL)
599 snd_new_identifier = leveldir_current->sounds_set;
600 if (leveldir_current->music_set != NULL)
601 mus_new_identifier = leveldir_current->music_set;
603 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
604 last_override_level_graphics != setup.override_level_graphics)
607 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
608 artwork.gfx_current_identifier,
609 artwork.gfx_current->identifier,
613 setLevelArtworkDir(artwork.gfx_first);
615 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
617 ReloadCustomImages();
618 ReinitializeGraphics();
623 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
624 last_override_level_graphics = setup.override_level_graphics;
626 redraw_screen = TRUE;
629 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
630 last_override_level_sounds != setup.override_level_sounds)
633 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
634 artwork.snd_current_identifier,
635 artwork.snd_current->identifier,
639 /* set artwork path to send it to the sound server process */
640 setLevelArtworkDir(artwork.snd_first);
642 InitReloadCustomSounds(snd_new_identifier);
643 ReinitializeSounds();
645 artwork.snd_current_identifier = artwork.snd_current->identifier;
646 last_override_level_sounds = setup.override_level_sounds;
648 redraw_screen = TRUE;
651 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
652 last_override_level_music != setup.override_level_music)
654 /* set artwork path to send it to the sound server process */
655 setLevelArtworkDir(artwork.mus_first);
657 InitReloadCustomMusic(mus_new_identifier);
660 artwork.mus_current_identifier = artwork.mus_current->identifier;
661 last_override_level_music = setup.override_level_music;
663 redraw_screen = TRUE;
670 /* force redraw of (open or closed) door graphics */
671 SetDoorState(DOOR_OPEN_ALL);
672 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
678 FreeLevelEditorGadgets();
687 static boolean gadgets_initialized = FALSE;
689 if (gadgets_initialized)
692 CreateLevelEditorGadgets();
696 CreateScreenGadgets();
698 gadgets_initialized = TRUE;
701 void InitElementInfo()
705 /* set values to -1 to identify later as "uninitialized" values */
706 for (i=0; i<MAX_NUM_ELEMENTS; i++)
708 for (act=0; act<NUM_ACTIONS; act++)
710 element_info[i].graphic[act] = -1;
712 for (dir=0; dir<NUM_DIRECTIONS; dir++)
713 element_info[i].direction_graphic[act][dir] = -1;
717 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
718 element_info[i].graphic[ACTION_DEFAULT] =
719 IMG_CHAR_START + (i - EL_CHAR_START);
721 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
722 element_info[i].graphic[ACTION_DEFAULT] =
723 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
726 while (element_to_graphic[i].element > -1)
728 int element = element_to_graphic[i].element;
729 int direction = element_to_graphic[i].direction;
730 int action = element_to_graphic[i].action;
731 int graphic = element_to_graphic[i].graphic;
734 action = ACTION_DEFAULT;
738 direction = MV_DIR_BIT(direction);
740 element_info[element].direction_graphic[action][direction] = graphic;
743 element_info[element].graphic[action] = graphic;
748 /* now set all '-1' values to element specific default values */
749 for (i=0; i<MAX_NUM_ELEMENTS; i++)
751 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
752 int default_action_direction_graphic[NUM_DIRECTIONS];
754 if (default_action_graphic == -1)
755 default_action_graphic = IMG_CHAR_QUESTION;
757 for (dir=0; dir<NUM_DIRECTIONS; dir++)
759 default_action_direction_graphic[dir] =
760 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
762 if (default_action_direction_graphic[dir] == -1)
763 default_action_direction_graphic[dir] = default_action_graphic;
766 for (act=0; act<NUM_ACTIONS; act++)
768 for (dir=0; dir<NUM_DIRECTIONS; dir++)
770 int default_direction_graphic = element_info[i].graphic[act];
772 /* no graphic for current action -- use default direction graphic */
773 if (default_direction_graphic == -1)
774 default_direction_graphic = default_action_direction_graphic[dir];
776 if (element_info[i].direction_graphic[act][dir] == -1)
777 element_info[i].direction_graphic[act][dir] =
778 default_direction_graphic;
781 /* no graphic for this specific action -- use default action graphic */
782 if (element_info[i].graphic[act] == -1)
783 element_info[i].graphic[act] = default_action_graphic;
788 static void set_graphic_parameters(int graphic, int *parameter)
790 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
791 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
792 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
794 graphic_info[graphic].bitmap = src_bitmap;
796 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
797 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
798 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
799 graphic_info[graphic].offset_y = 0;
801 /* animation frames are ordered vertically instead of horizontally */
802 if (parameter[GFX_ARG_VERTICAL])
804 graphic_info[graphic].offset_x = 0;
805 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
808 /* optionally, the x and y offset of frames can be specified directly */
809 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
810 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
811 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
812 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
814 /* automatically determine correct number of frames, if not defined */
815 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
816 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
817 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
818 graphic_info[graphic].anim_frames = num_xtiles;
819 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
820 graphic_info[graphic].anim_frames = num_ytiles;
822 graphic_info[graphic].anim_frames = 1;
824 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
825 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
826 graphic_info[graphic].anim_delay = 1;
828 /* set mode for animation frame order */
829 if (parameter[GFX_ARG_MODE_LOOP])
830 graphic_info[graphic].anim_mode = ANIM_LOOP;
831 else if (parameter[GFX_ARG_MODE_LINEAR])
832 graphic_info[graphic].anim_mode = ANIM_LINEAR;
833 else if (parameter[GFX_ARG_MODE_PINGPONG])
834 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
835 else if (parameter[GFX_ARG_MODE_PINGPONG2])
836 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
837 else if (parameter[GFX_ARG_MODE_RANDOM])
838 graphic_info[graphic].anim_mode = ANIM_RANDOM;
839 else if (graphic_info[graphic].anim_frames > 1)
840 graphic_info[graphic].anim_mode = ANIM_LOOP;
842 graphic_info[graphic].anim_mode = ANIM_NONE;
844 /* set additional flag to play animation frames in reverse order */
845 if (parameter[GFX_ARG_MODE_REVERSE])
846 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
848 /* automatically determine correct start frame, if not defined */
849 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
850 graphic_info[graphic].anim_start_frame = 0;
851 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
852 graphic_info[graphic].anim_start_frame =
853 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
855 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
857 /* animation synchronized with global frame counter, not move position */
858 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
861 static void InitGraphicInfo()
863 static boolean clipmasks_initialized = FALSE;
864 int num_images = getImageListSize();
866 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
868 XGCValues clip_gc_values;
869 unsigned long clip_gc_valuemask;
870 GC copy_clipmask_gc = None;
873 if (graphic_info != NULL)
876 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
878 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
879 if (clipmasks_initialized)
881 for (i=0; i<num_images; i++)
883 if (graphic_info[i].clip_mask)
884 XFreePixmap(display, graphic_info[i].clip_mask);
885 if (graphic_info[i].clip_gc)
886 XFreeGC(display, graphic_info[i].clip_gc);
888 graphic_info[i].clip_mask = None;
889 graphic_info[i].clip_gc = None;
894 for (i=0; i<num_images; i++)
896 struct FileInfo *image = getImageListEntry(i);
899 int first_frame, last_frame;
901 set_graphic_parameters(i, image->parameter);
903 /* now check if no animation frames are outside of the loaded image */
905 if (graphic_info[i].bitmap == NULL)
906 continue; /* skip check for optional images that are undefined */
909 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
910 if (src_x < 0 || src_y < 0 ||
911 src_x + TILEX > src_bitmap->width ||
912 src_y + TILEY > src_bitmap->height)
914 Error(ERR_RETURN_LINE, "-");
915 Error(ERR_RETURN, "warning: error found in config file:");
916 Error(ERR_RETURN, "- config file: '%s'",
917 getImageConfigFilename());
918 Error(ERR_RETURN, "- config token: '%s'",
919 getTokenFromImageID(i));
920 Error(ERR_RETURN, "- image file: '%s'",
921 src_bitmap->source_filename);
923 "error: first animation frame out of bounds (%d, %d)",
925 Error(ERR_RETURN, "custom graphic rejected for this element/action");
926 Error(ERR_RETURN_LINE, "-");
928 set_graphic_parameters(i, image->default_parameter);
931 last_frame = graphic_info[i].anim_frames - 1;
932 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
933 if (src_x < 0 || src_y < 0 ||
934 src_x + TILEX > src_bitmap->width ||
935 src_y + TILEY > src_bitmap->height)
937 Error(ERR_RETURN_LINE, "-");
938 Error(ERR_RETURN, "warning: error found in config file:");
939 Error(ERR_RETURN, "- config file: '%s'",
940 getImageConfigFilename());
941 Error(ERR_RETURN, "- config token: '%s'",
942 getTokenFromImageID(i));
943 Error(ERR_RETURN, "- image file: '%s'",
944 src_bitmap->source_filename);
946 "error: last animation frame (%d) out of bounds (%d, %d)",
947 last_frame, src_x, src_y);
948 Error(ERR_RETURN, "custom graphic rejected for this element/action");
949 Error(ERR_RETURN_LINE, "-");
951 set_graphic_parameters(i, image->default_parameter);
954 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
955 /* currently we need only a tile clip mask from the first frame */
956 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
958 if (copy_clipmask_gc == None)
960 clip_gc_values.graphics_exposures = False;
961 clip_gc_valuemask = GCGraphicsExposures;
962 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
963 clip_gc_valuemask, &clip_gc_values);
966 graphic_info[i].clip_mask =
967 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
969 src_pixmap = src_bitmap->clip_mask;
970 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
971 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
973 clip_gc_values.graphics_exposures = False;
974 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
975 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
976 graphic_info[i].clip_gc =
977 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
981 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
982 if (copy_clipmask_gc)
983 XFreeGC(display, copy_clipmask_gc);
986 clipmasks_initialized = TRUE;
989 static void set_sound_parameters(int sound, int *parameter)
991 /* explicit loop mode setting in configuration overrides default value */
992 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
993 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
996 static void InitSoundInfo()
998 int *sound_effect_properties;
999 int num_sounds = getSoundListSize();
1002 if (sound_info != NULL)
1005 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1006 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1008 /* initialize sound effect for all elements to "no sound" */
1009 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1010 for (j=0; j<NUM_ACTIONS; j++)
1011 element_info[i].sound[j] = SND_UNDEFINED;
1013 for (i=0; i<num_sounds; i++)
1015 struct FileInfo *sound = getSoundListEntry(i);
1016 int len_effect_text = strlen(sound->token);
1019 sound_effect_properties[i] = ACTION_OTHER;
1020 sound_info[i].loop = FALSE;
1023 /* determine all loop sounds and identify certain sound classes */
1026 for (j=0; element_action_info[j].suffix; j++)
1028 int len_action_text = strlen(element_action_info[j].suffix);
1030 if (len_action_text < len_effect_text &&
1031 strcmp(&sound->token[len_effect_text - len_action_text],
1032 element_action_info[j].suffix) == 0)
1034 sound_effect_properties[i] = element_action_info[j].value;
1036 if (element_action_info[j].is_loop_sound)
1037 sound_info[i].loop = TRUE;
1042 /* associate elements and some selected sound actions */
1045 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1047 if (element_info[j].sound_class_name)
1049 int len_class_text = strlen(element_info[j].sound_class_name);
1051 if (len_class_text + 1 < len_effect_text &&
1052 strncmp(sound->token,
1053 element_info[j].sound_class_name, len_class_text) == 0 &&
1054 sound->token[len_class_text] == '.')
1056 int sound_action_value = sound_effect_properties[i];
1058 element_info[j].sound[sound_action_value] = i;
1064 set_sound_parameters(i, sound->parameter);
1067 free(sound_effect_properties);
1072 int element = EL_SAND;
1073 int sound_action = ACTION_DIGGING;
1076 while (element_action_info[j].suffix)
1078 if (element_action_info[j].value == sound_action)
1079 printf("element %d, sound action '%s' == %d\n",
1080 element, element_action_info[j].suffix,
1081 element_info_[element].sound[sound_action]);
1088 void InitElementProperties()
1092 static int ep_amoebalive[] =
1099 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1101 static int ep_amoeboid[] =
1109 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1111 static int ep_schluessel[] =
1122 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1124 static int ep_pforte[] =
1143 EL_SWITCHGATE_OPENING,
1144 EL_SWITCHGATE_CLOSED,
1145 EL_SWITCHGATE_CLOSING,
1147 EL_TIMEGATE_OPENING,
1149 EL_TIMEGATE_CLOSING,
1153 EL_TUBE_VERTICAL_LEFT,
1154 EL_TUBE_VERTICAL_RIGHT,
1155 EL_TUBE_HORIZONTAL_UP,
1156 EL_TUBE_HORIZONTAL_DOWN,
1162 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1164 static int ep_solid[] =
1184 EL_QUICKSAND_FILLING,
1185 EL_QUICKSAND_EMPTYING,
1187 EL_MAGIC_WALL_ACTIVE,
1188 EL_MAGIC_WALL_EMPTYING,
1189 EL_MAGIC_WALL_FILLING,
1193 EL_BD_MAGIC_WALL_ACTIVE,
1194 EL_BD_MAGIC_WALL_EMPTYING,
1195 EL_BD_MAGIC_WALL_FULL,
1196 EL_BD_MAGIC_WALL_FILLING,
1197 EL_BD_MAGIC_WALL_DEAD,
1200 EL_ACIDPOOL_TOPLEFT,
1201 EL_ACIDPOOL_TOPRIGHT,
1202 EL_ACIDPOOL_BOTTOMLEFT,
1204 EL_ACIDPOOL_BOTTOMRIGHT,
1222 EL_SP_TERMINAL_ACTIVE,
1225 EL_INVISIBLE_STEELWALL,
1226 EL_INVISIBLE_STEELWALL_ACTIVE,
1228 EL_INVISIBLE_WALL_ACTIVE,
1229 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1230 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1231 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1232 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1233 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1234 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1235 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1236 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1237 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1238 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1239 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1240 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1241 EL_SWITCHGATE_SWITCH_UP,
1242 EL_SWITCHGATE_SWITCH_DOWN,
1244 EL_LIGHT_SWITCH_ACTIVE,
1246 EL_TIMEGATE_SWITCH_ACTIVE,
1247 EL_SIGN_EXCLAMATION,
1248 EL_SIGN_RADIOACTIVITY,
1259 EL_STEELWALL_SLANTED,
1264 EL_EMC_WALL_PILLAR_UPPER,
1265 EL_EMC_WALL_PILLAR_MIDDLE,
1266 EL_EMC_WALL_PILLAR_LOWER,
1292 EL_SWITCHGATE_OPENING,
1293 EL_SWITCHGATE_CLOSED,
1294 EL_SWITCHGATE_CLOSING,
1296 EL_TIMEGATE_OPENING,
1298 EL_TIMEGATE_CLOSING,
1302 EL_TUBE_VERTICAL_LEFT,
1303 EL_TUBE_VERTICAL_RIGHT,
1304 EL_TUBE_HORIZONTAL_UP,
1305 EL_TUBE_HORIZONTAL_DOWN,
1311 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1313 static int ep_massive[] =
1317 EL_ACIDPOOL_TOPLEFT,
1318 EL_ACIDPOOL_TOPRIGHT,
1319 EL_ACIDPOOL_BOTTOMLEFT,
1321 EL_ACIDPOOL_BOTTOMRIGHT,
1333 EL_INVISIBLE_STEELWALL,
1334 EL_INVISIBLE_STEELWALL_ACTIVE,
1335 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1336 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1337 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1338 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1339 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1340 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1341 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1342 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1343 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1344 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1345 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1346 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1348 EL_LIGHT_SWITCH_ACTIVE,
1349 EL_SIGN_EXCLAMATION,
1350 EL_SIGN_RADIOACTIVITY,
1361 EL_STEELWALL_SLANTED,
1384 EL_SWITCHGATE_OPENING,
1385 EL_SWITCHGATE_CLOSED,
1386 EL_SWITCHGATE_CLOSING,
1388 EL_TIMEGATE_OPENING,
1390 EL_TIMEGATE_CLOSING,
1394 EL_TUBE_VERTICAL_LEFT,
1395 EL_TUBE_VERTICAL_RIGHT,
1396 EL_TUBE_HORIZONTAL_UP,
1397 EL_TUBE_HORIZONTAL_DOWN,
1403 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1405 static int ep_slippery[] =
1419 EL_ROBOT_WHEEL_ACTIVE,
1425 EL_ACIDPOOL_TOPLEFT,
1426 EL_ACIDPOOL_TOPRIGHT,
1436 EL_STEELWALL_SLANTED,
1440 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1442 static int ep_enemy[] =
1455 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1457 static int ep_mauer[] =
1485 EL_WALL_GROWING_ACTIVE,
1504 EL_SP_TERMINAL_ACTIVE,
1507 EL_INVISIBLE_STEELWALL,
1508 EL_INVISIBLE_STEELWALL_ACTIVE,
1510 EL_INVISIBLE_WALL_ACTIVE,
1511 EL_STEELWALL_SLANTED,
1516 EL_EMC_WALL_PILLAR_UPPER,
1517 EL_EMC_WALL_PILLAR_MIDDLE,
1518 EL_EMC_WALL_PILLAR_LOWER,
1525 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1527 static int ep_can_fall[] =
1542 EL_BD_MAGIC_WALL_FULL,
1553 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1555 static int ep_can_smash[] =
1586 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1588 static int ep_can_change[] =
1599 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1601 static int ep_can_move[] =
1621 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1623 static int ep_could_move[] =
1633 EL_BD_BUTTERFLY_RIGHT,
1635 EL_BD_BUTTERFLY_LEFT,
1636 EL_BD_BUTTERFLY_DOWN,
1637 EL_BD_FIREFLY_RIGHT,
1646 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1648 static int ep_dont_touch[] =
1655 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1657 static int ep_dont_go_to[] =
1671 EL_SP_BUGGY_BASE_ACTIVE,
1675 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1677 static int ep_mampf2[] =
1702 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1704 static int ep_bd_element[] =
1731 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1733 static int ep_sb_element[] =
1738 EL_SOKOBAN_FIELD_EMPTY,
1739 EL_SOKOBAN_FIELD_FULL,
1741 EL_INVISIBLE_STEELWALL
1743 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1745 static int ep_gem[] =
1754 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1756 static int ep_inactive[] =
1793 EL_INVISIBLE_STEELWALL,
1801 EL_WALL_EMERALD_YELLOW,
1806 EL_SOKOBAN_FIELD_EMPTY,
1807 EL_SOKOBAN_FIELD_FULL,
1808 EL_WALL_EMERALD_RED,
1809 EL_WALL_EMERALD_PURPLE,
1810 EL_ACIDPOOL_TOPLEFT,
1811 EL_ACIDPOOL_TOPRIGHT,
1812 EL_ACIDPOOL_BOTTOMLEFT,
1814 EL_ACIDPOOL_BOTTOMRIGHT,
1818 EL_BD_MAGIC_WALL_DEAD,
1819 EL_AMOEBA_TO_DIAMOND,
1852 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1853 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1854 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1855 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1856 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1857 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1858 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1859 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1860 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1861 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1862 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1863 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1864 EL_SIGN_EXCLAMATION,
1865 EL_SIGN_RADIOACTIVITY,
1876 EL_STEELWALL_SLANTED,
1881 EL_EMC_WALL_PILLAR_UPPER,
1882 EL_EMC_WALL_PILLAR_MIDDLE,
1883 EL_EMC_WALL_PILLAR_LOWER,
1890 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1892 static int ep_explosive[] =
1897 EL_DYNABOMB_PLAYER1_ACTIVE,
1898 EL_DYNABOMB_PLAYER2_ACTIVE,
1899 EL_DYNABOMB_PLAYER3_ACTIVE,
1900 EL_DYNABOMB_PLAYER4_ACTIVE,
1917 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1919 static int ep_mampf3[] =
1930 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1932 static int ep_pushable[] =
1939 EL_SOKOBAN_FIELD_FULL,
1949 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1951 static int ep_player[] =
1958 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1960 static int ep_has_content[] =
1968 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1970 static int ep_eatable[] =
1975 EL_SP_BUGGY_BASE_ACTIVATING,
1978 EL_INVISIBLE_SAND_ACTIVE
1980 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1982 static int ep_sp_element[] =
2025 /* additional elements that appeared in newer Supaplex levels */
2027 /* more than one murphy in a level results in an inactive clone */
2030 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2032 static int ep_quick_gate[] =
2056 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2058 static int ep_over_player[] =
2074 EL_TUBE_VERTICAL_LEFT,
2075 EL_TUBE_VERTICAL_RIGHT,
2076 EL_TUBE_HORIZONTAL_UP,
2077 EL_TUBE_HORIZONTAL_DOWN,
2083 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2085 static int ep_active_bomb[] =
2088 EL_DYNABOMB_PLAYER1_ACTIVE,
2089 EL_DYNABOMB_PLAYER2_ACTIVE,
2090 EL_DYNABOMB_PLAYER3_ACTIVE,
2091 EL_DYNABOMB_PLAYER4_ACTIVE
2093 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2095 static int ep_belt[] =
2097 EL_CONVEYOR_BELT1_LEFT,
2098 EL_CONVEYOR_BELT1_MIDDLE,
2099 EL_CONVEYOR_BELT1_RIGHT,
2100 EL_CONVEYOR_BELT2_LEFT,
2101 EL_CONVEYOR_BELT2_MIDDLE,
2102 EL_CONVEYOR_BELT2_RIGHT,
2103 EL_CONVEYOR_BELT3_LEFT,
2104 EL_CONVEYOR_BELT3_MIDDLE,
2105 EL_CONVEYOR_BELT3_RIGHT,
2106 EL_CONVEYOR_BELT4_LEFT,
2107 EL_CONVEYOR_BELT4_MIDDLE,
2108 EL_CONVEYOR_BELT4_RIGHT,
2110 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2112 static int ep_belt_active[] =
2114 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2115 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2116 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2117 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2118 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2119 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2120 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2121 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2122 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2123 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2124 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2125 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2127 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2129 static int ep_belt_switch[] =
2131 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2132 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2133 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2134 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2135 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2136 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2137 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2138 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2139 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2140 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2141 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2142 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2144 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2146 static int ep_tube[] =
2151 EL_TUBE_VERTICAL_LEFT,
2152 EL_TUBE_VERTICAL_RIGHT,
2153 EL_TUBE_HORIZONTAL_UP,
2154 EL_TUBE_HORIZONTAL_DOWN,
2160 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2162 static long ep1_bit[] =
2196 static long ep2_bit[] =
2203 static int *ep1_array[] =
2237 static int *ep2_array[] =
2244 static int *ep1_num[] =
2271 &ep_has_content_num,
2275 &ep_over_player_num,
2278 static int *ep2_num[] =
2281 &ep_belt_active_num,
2282 &ep_belt_switch_num,
2285 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2286 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2288 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2294 for (i=0; i<num_properties1; i++)
2295 for (j=0; j<*(ep1_num[i]); j++)
2296 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2297 for (i=0; i<num_properties2; i++)
2298 for (j=0; j<*(ep2_num[i]); j++)
2299 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2301 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2302 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2305 void Execute_Command(char *command)
2307 if (strcmp(command, "print graphicsinfo.conf") == 0)
2311 printf("# You can configure additional/alternative image files here.\n");
2312 printf("# (The images below are default and therefore commented out.)\n");
2314 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2316 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2319 for (i=0; image_config[i].token != NULL; i++)
2321 getFormattedSetupEntry(image_config[i].token,
2322 image_config[i].value));
2326 else if (strcmp(command, "print soundsinfo.conf") == 0)
2330 printf("# You can configure additional/alternative sound files here.\n");
2331 printf("# (The sounds below are default and therefore commented out.)\n");
2333 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2335 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2338 for (i=0; sound_config[i].token != NULL; i++)
2340 getFormattedSetupEntry(sound_config[i].token,
2341 sound_config[i].value));
2345 else if (strcmp(command, "print musicinfo.conf") == 0)
2347 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2349 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2351 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2355 else if (strncmp(command, "dump level ", 11) == 0)
2357 char *filename = &command[11];
2359 if (access(filename, F_OK) != 0)
2360 Error(ERR_EXIT, "cannot open file '%s'", filename);
2362 LoadLevelFromFilename(filename);
2367 else if (strncmp(command, "dump tape ", 10) == 0)
2369 char *filename = &command[10];
2371 if (access(filename, F_OK) != 0)
2372 Error(ERR_EXIT, "cannot open file '%s'", filename);
2374 LoadTapeFromFilename(filename);
2379 else if (strncmp(command, "autoplay ", 9) == 0)
2381 char *str_copy = getStringCopy(&command[9]);
2382 char *str_ptr = strchr(str_copy, ' ');
2384 global.autoplay_leveldir = str_copy;
2385 global.autoplay_level_nr = -1;
2387 if (str_ptr != NULL)
2389 *str_ptr++ = '\0'; /* terminate leveldir string */
2390 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2395 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2399 void CloseAllAndExit(int exit_value)
2404 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2407 FreeTileClipmasks();
2409 if (bitmap_font_initial)
2410 FreeBitmap(bitmap_font_initial);
2412 CloseVideoDisplay();
2413 ClosePlatformDependantStuff();