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 */
265 static void ReinitializeMusic()
267 /* currently nothing to do */
270 static void InitImages()
272 ReloadCustomImages();
273 ReinitializeGraphics();
276 static void InitSound()
278 InitReloadCustomSounds(artwork.snd_current->identifier);
279 ReinitializeSounds();
282 static void InitMusic()
284 InitReloadCustomMusic(artwork.mus_current->identifier);
288 static void InitTileClipmasks()
291 #if defined(TARGET_X11)
292 XGCValues clip_gc_values;
293 unsigned long clip_gc_valuemask;
295 #if defined(TARGET_X11_NATIVE)
305 tile_needs_clipping[] =
307 { GFX_SPIELER1_UP, 4 },
308 { GFX_SPIELER1_DOWN, 4 },
309 { GFX_SPIELER1_LEFT, 4 },
310 { GFX_SPIELER1_RIGHT, 4 },
311 { GFX_SPIELER1_PUSH_LEFT, 4 },
312 { GFX_SPIELER1_PUSH_RIGHT, 4 },
313 { GFX_SPIELER2_UP, 4 },
314 { GFX_SPIELER2_DOWN, 4 },
315 { GFX_SPIELER2_LEFT, 4 },
316 { GFX_SPIELER2_RIGHT, 4 },
317 { GFX_SPIELER2_PUSH_LEFT, 4 },
318 { GFX_SPIELER2_PUSH_RIGHT, 4 },
319 { GFX_SPIELER3_UP, 4 },
320 { GFX_SPIELER3_DOWN, 4 },
321 { GFX_SPIELER3_LEFT, 4 },
322 { GFX_SPIELER3_RIGHT, 4 },
323 { GFX_SPIELER3_PUSH_LEFT, 4 },
324 { GFX_SPIELER3_PUSH_RIGHT, 4 },
325 { GFX_SPIELER4_UP, 4 },
326 { GFX_SPIELER4_DOWN, 4 },
327 { GFX_SPIELER4_LEFT, 4 },
328 { GFX_SPIELER4_RIGHT, 4 },
329 { GFX_SPIELER4_PUSH_LEFT, 4 },
330 { GFX_SPIELER4_PUSH_RIGHT, 4 },
331 { GFX_SP_MURPHY, 1 },
332 { GFX_MURPHY_GO_LEFT, 3 },
333 { GFX_MURPHY_GO_RIGHT, 3 },
334 { GFX_MURPHY_SNAP_UP, 1 },
335 { GFX_MURPHY_SNAP_DOWN, 1 },
336 { GFX_MURPHY_SNAP_RIGHT, 1 },
337 { GFX_MURPHY_SNAP_LEFT, 1 },
338 { GFX_MURPHY_PUSH_RIGHT, 1 },
339 { GFX_MURPHY_PUSH_LEFT, 1 },
340 { GFX_GEBLUBBER, 4 },
343 { GFX_EXPLOSION, 8 },
344 { GFX_SOKOBAN_OBJEKT, 1 },
345 { GFX_FUNKELN_BLAU, 3 },
346 { GFX_FUNKELN_WEISS, 3 },
347 { GFX2_SHIELD_PASSIVE, 3 },
348 { GFX2_SHIELD_ACTIVE, 3 },
353 #endif /* TARGET_X11_NATIVE */
354 #endif /* TARGET_X11 */
358 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
359 for (i=0; i<NUM_TILES; i++)
360 tile_clipmask[i] = None;
362 #if defined(TARGET_X11)
363 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
364 often very slow when preparing a masked XCopyArea() for big Pixmaps.
365 To prevent this, create small (tile-sized) mask Pixmaps which will then
366 be set much faster with XSetClipOrigin() and speed things up a lot. */
368 clip_gc_values.graphics_exposures = False;
369 clip_gc_valuemask = GCGraphicsExposures;
370 tile_clip_gc = XCreateGC(display, window->drawable,
371 clip_gc_valuemask, &clip_gc_values);
374 for (i=0; i<NUM_BITMAPS; i++)
376 if (pix[i]->clip_mask)
378 clip_gc_values.graphics_exposures = False;
379 clip_gc_values.clip_mask = pix[i]->clip_mask;
380 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
381 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
382 clip_gc_valuemask, &clip_gc_values);
387 #if defined(TARGET_X11_NATIVE)
390 /* create graphic context structures needed for clipping */
391 clip_gc_values.graphics_exposures = False;
392 clip_gc_valuemask = GCGraphicsExposures;
393 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
394 clip_gc_valuemask, &clip_gc_values);
396 /* create only those clipping Pixmaps we really need */
397 for (i=0; tile_needs_clipping[i].start>=0; i++)
401 for (j=0; j<tile_needs_clipping[i].count; j++)
403 int tile = tile_needs_clipping[i].start + j;
409 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
410 src_pixmap = src_bitmap->clip_mask;
412 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
415 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
416 src_x, src_y, TILEX, TILEY, 0, 0);
420 XFreeGC(display, copy_clipmask_gc);
423 #endif /* TARGET_X11_NATIVE */
424 #endif /* TARGET_X11 */
428 void FreeTileClipmasks()
431 #if defined(TARGET_X11)
434 for (i=0; i<NUM_TILES; i++)
436 if (tile_clipmask[i] != None)
438 XFreePixmap(display, tile_clipmask[i]);
439 tile_clipmask[i] = None;
444 XFreeGC(display, tile_clip_gc);
448 for (i=0; i<NUM_BITMAPS; i++)
450 if (pix[i] != NULL && pix[i]->stored_clip_gc)
452 XFreeGC(display, pix[i]->stored_clip_gc);
453 pix[i]->stored_clip_gc = None;
458 #endif /* TARGET_X11 */
468 /* initialize screen properties */
469 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
470 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
471 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
472 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
473 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
475 /* create additional image buffers for double-buffering */
476 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
477 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
480 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
482 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
484 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
486 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
489 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
490 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
492 DrawInitText("Loading graphics:", 120, FC_GREEN);
495 for (i=0; i<NUM_PICTURES; i++)
498 if (i != PIX_FONT_SMALL)
501 DrawInitText(image_filename[i], 150, FC_YELLOW);
503 pix[i] = LoadCustomImage(image_filename[i]);
509 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
516 void InitGfxBackground()
521 fieldbuffer = bitmap_db_field;
522 SetDrawtoField(DRAW_BACKBUFFER);
524 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
525 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
526 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
527 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
529 for (x=0; x<MAX_BUF_XSIZE; x++)
530 for (y=0; y<MAX_BUF_YSIZE; y++)
533 redraw_mask = REDRAW_ALL;
536 void ReloadCustomArtwork()
538 static char *leveldir_current_identifier = NULL;
539 static boolean last_override_level_graphics = FALSE;
540 static boolean last_override_level_sounds = FALSE;
541 static boolean last_override_level_music = FALSE;
542 /* identifier for new artwork; default: artwork configured in setup */
543 char *gfx_new_identifier = artwork.gfx_current->identifier;
544 char *snd_new_identifier = artwork.snd_current->identifier;
545 char *mus_new_identifier = artwork.mus_current->identifier;
546 boolean redraw_screen = FALSE;
548 if (leveldir_current_identifier == NULL)
549 leveldir_current_identifier = leveldir_current->identifier;
552 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
553 leveldir_current->graphics_set);
554 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
555 leveldir_current->identifier);
559 printf("graphics --> '%s' ('%s')\n",
560 artwork.gfx_current_identifier, artwork.gfx_current->filename);
561 printf("sounds --> '%s' ('%s')\n",
562 artwork.snd_current_identifier, artwork.snd_current->filename);
563 printf("music --> '%s' ('%s')\n",
564 artwork.mus_current_identifier, artwork.mus_current->filename);
567 /* leveldir_current may be invalid (level group, parent link) */
568 if (!validLevelSeries(leveldir_current))
571 /* when a new level series was selected, check if there was a change
572 in custom artwork stored in level series directory */
573 if (leveldir_current_identifier != leveldir_current->identifier)
575 char *identifier_old = leveldir_current_identifier;
576 char *identifier_new = leveldir_current->identifier;
578 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
579 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
580 gfx_new_identifier = identifier_new;
581 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
582 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
583 snd_new_identifier = identifier_new;
584 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
585 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
586 mus_new_identifier = identifier_new;
588 leveldir_current_identifier = leveldir_current->identifier;
591 /* custom level artwork configured in level series configuration file
592 always overrides custom level artwork stored in level series directory
593 and (level independant) custom artwork configured in setup menue */
594 if (leveldir_current->graphics_set != NULL)
595 gfx_new_identifier = leveldir_current->graphics_set;
596 if (leveldir_current->sounds_set != NULL)
597 snd_new_identifier = leveldir_current->sounds_set;
598 if (leveldir_current->music_set != NULL)
599 mus_new_identifier = leveldir_current->music_set;
601 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
602 last_override_level_graphics != setup.override_level_graphics)
605 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
606 artwork.gfx_current_identifier,
607 artwork.gfx_current->identifier,
611 setLevelArtworkDir(artwork.gfx_first);
613 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
615 ReloadCustomImages();
616 ReinitializeGraphics();
621 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
622 last_override_level_graphics = setup.override_level_graphics;
624 redraw_screen = TRUE;
627 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
628 last_override_level_sounds != setup.override_level_sounds)
631 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
632 artwork.snd_current_identifier,
633 artwork.snd_current->identifier,
637 /* set artwork path to send it to the sound server process */
638 setLevelArtworkDir(artwork.snd_first);
640 InitReloadCustomSounds(snd_new_identifier);
641 ReinitializeSounds();
643 artwork.snd_current_identifier = artwork.snd_current->identifier;
644 last_override_level_sounds = setup.override_level_sounds;
646 redraw_screen = TRUE;
649 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
650 last_override_level_music != setup.override_level_music)
652 /* set artwork path to send it to the sound server process */
653 setLevelArtworkDir(artwork.mus_first);
655 InitReloadCustomMusic(mus_new_identifier);
658 artwork.mus_current_identifier = artwork.mus_current->identifier;
659 last_override_level_music = setup.override_level_music;
661 redraw_screen = TRUE;
668 /* force redraw of (open or closed) door graphics */
669 SetDoorState(DOOR_OPEN_ALL);
670 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
676 FreeLevelEditorGadgets();
685 static boolean gadgets_initialized = FALSE;
687 if (gadgets_initialized)
690 CreateLevelEditorGadgets();
694 CreateScreenGadgets();
696 gadgets_initialized = TRUE;
699 void InitElementInfo()
703 /* set values to -1 to identify later as "uninitialized" values */
704 for (i=0; i<MAX_NUM_ELEMENTS; i++)
706 for (act=0; act<NUM_ACTIONS; act++)
708 element_info[i].graphic[act] = -1;
710 for (dir=0; dir<NUM_DIRECTIONS; dir++)
711 element_info[i].direction_graphic[act][dir] = -1;
715 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
716 element_info[i].graphic[ACTION_DEFAULT] =
717 IMG_CHAR_START + (i - EL_CHAR_START);
719 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
720 element_info[i].graphic[ACTION_DEFAULT] =
721 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
724 while (element_to_graphic[i].element > -1)
726 int element = element_to_graphic[i].element;
727 int direction = element_to_graphic[i].direction;
728 int action = element_to_graphic[i].action;
729 int graphic = element_to_graphic[i].graphic;
732 action = ACTION_DEFAULT;
736 direction = MV_DIR_BIT(direction);
738 element_info[element].direction_graphic[action][direction] = graphic;
741 element_info[element].graphic[action] = graphic;
746 /* now set all '-1' values to element specific default values */
747 for (i=0; i<MAX_NUM_ELEMENTS; i++)
749 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
750 int default_action_direction_graphic[NUM_DIRECTIONS];
752 if (default_action_graphic == -1)
753 default_action_graphic = IMG_CHAR_QUESTION;
755 for (dir=0; dir<NUM_DIRECTIONS; dir++)
757 default_action_direction_graphic[dir] =
758 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
760 if (default_action_direction_graphic[dir] == -1)
761 default_action_direction_graphic[dir] = default_action_graphic;
764 for (act=0; act<NUM_ACTIONS; act++)
766 for (dir=0; dir<NUM_DIRECTIONS; dir++)
768 int default_direction_graphic = element_info[i].graphic[act];
770 /* no graphic for current action -- use default direction graphic */
771 if (default_direction_graphic == -1)
772 default_direction_graphic = default_action_direction_graphic[dir];
774 if (element_info[i].direction_graphic[act][dir] == -1)
775 element_info[i].direction_graphic[act][dir] =
776 default_direction_graphic;
779 /* no graphic for this specific action -- use default action graphic */
780 if (element_info[i].graphic[act] == -1)
781 element_info[i].graphic[act] = default_action_graphic;
786 static void set_graphic_parameters(int graphic, int *parameter)
788 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
789 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
790 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
792 graphic_info[graphic].bitmap = src_bitmap;
794 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
795 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
796 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
797 graphic_info[graphic].offset_y = 0;
799 /* animation frames are ordered vertically instead of horizontally */
800 if (parameter[GFX_ARG_VERTICAL])
802 graphic_info[graphic].offset_x = 0;
803 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
806 /* optionally, the x and y offset of frames can be specified directly */
807 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
808 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
809 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
810 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
812 /* automatically determine correct number of frames, if not defined */
813 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
814 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
815 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
816 graphic_info[graphic].anim_frames = num_xtiles;
817 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
818 graphic_info[graphic].anim_frames = num_ytiles;
820 graphic_info[graphic].anim_frames = 1;
822 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
823 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
824 graphic_info[graphic].anim_delay = 1;
826 /* set mode for animation frame order */
827 if (parameter[GFX_ARG_MODE_LOOP])
828 graphic_info[graphic].anim_mode = ANIM_LOOP;
829 else if (parameter[GFX_ARG_MODE_LINEAR])
830 graphic_info[graphic].anim_mode = ANIM_LINEAR;
831 else if (parameter[GFX_ARG_MODE_PINGPONG])
832 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
833 else if (parameter[GFX_ARG_MODE_PINGPONG2])
834 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
835 else if (parameter[GFX_ARG_MODE_RANDOM])
836 graphic_info[graphic].anim_mode = ANIM_RANDOM;
837 else if (graphic_info[graphic].anim_frames > 1)
838 graphic_info[graphic].anim_mode = ANIM_LOOP;
840 graphic_info[graphic].anim_mode = ANIM_NONE;
842 /* set additional flag to play animation frames in reverse order */
843 if (parameter[GFX_ARG_MODE_REVERSE])
844 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
846 /* automatically determine correct start frame, if not defined */
847 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
848 graphic_info[graphic].anim_start_frame = 0;
849 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
850 graphic_info[graphic].anim_start_frame =
851 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
853 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
855 /* animation synchronized with global frame counter, not move position */
856 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
859 static void InitGraphicInfo()
861 static boolean clipmasks_initialized = FALSE;
863 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
865 XGCValues clip_gc_values;
866 unsigned long clip_gc_valuemask;
867 GC copy_clipmask_gc = None;
870 image_files = getCurrentImageList();
872 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
873 if (clipmasks_initialized)
875 for (i=0; i<NUM_IMAGE_FILES; i++)
877 if (graphic_info[i].clip_mask)
878 XFreePixmap(display, graphic_info[i].clip_mask);
879 if (graphic_info[i].clip_gc)
880 XFreeGC(display, graphic_info[i].clip_gc);
882 graphic_info[i].clip_mask = None;
883 graphic_info[i].clip_gc = None;
888 for (i=0; i<NUM_IMAGE_FILES; i++)
892 int first_frame, last_frame;
894 set_graphic_parameters(i, image_files[i].parameter);
896 /* now check if no animation frames are outside of the loaded image */
898 if (graphic_info[i].bitmap == NULL)
899 continue; /* skip check for optional images that are undefined */
902 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
903 if (src_x < 0 || src_y < 0 ||
904 src_x + TILEX > src_bitmap->width ||
905 src_y + TILEY > src_bitmap->height)
907 Error(ERR_RETURN_LINE, "-");
908 Error(ERR_RETURN, "warning: error found in config file:");
909 Error(ERR_RETURN, "- config file: '%s'",
910 getImageConfigFilename());
911 Error(ERR_RETURN, "- config token: '%s'",
912 getTokenFromImageID(i));
913 Error(ERR_RETURN, "- image file: '%s'",
914 src_bitmap->source_filename);
916 "error: first animation frame out of bounds (%d, %d)",
918 Error(ERR_RETURN, "custom graphic rejected for this element/action");
919 Error(ERR_RETURN_LINE, "-");
921 set_graphic_parameters(i, image_files[i].default_parameter);
924 last_frame = graphic_info[i].anim_frames - 1;
925 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
926 if (src_x < 0 || src_y < 0 ||
927 src_x + TILEX > src_bitmap->width ||
928 src_y + TILEY > src_bitmap->height)
930 Error(ERR_RETURN_LINE, "-");
931 Error(ERR_RETURN, "warning: error found in config file:");
932 Error(ERR_RETURN, "- config file: '%s'",
933 getImageConfigFilename());
934 Error(ERR_RETURN, "- config token: '%s'",
935 getTokenFromImageID(i));
936 Error(ERR_RETURN, "- image file: '%s'",
937 src_bitmap->source_filename);
939 "error: last animation frame (%d) out of bounds (%d, %d)",
940 last_frame, src_x, src_y);
941 Error(ERR_RETURN, "custom graphic rejected for this element/action");
942 Error(ERR_RETURN_LINE, "-");
944 set_graphic_parameters(i, image_files[i].default_parameter);
947 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
948 /* currently we need only a tile clip mask from the first frame */
949 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
951 if (copy_clipmask_gc == None)
953 clip_gc_values.graphics_exposures = False;
954 clip_gc_valuemask = GCGraphicsExposures;
955 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
956 clip_gc_valuemask, &clip_gc_values);
959 graphic_info[i].clip_mask =
960 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
962 src_pixmap = src_bitmap->clip_mask;
963 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
964 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
966 clip_gc_values.graphics_exposures = False;
967 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
968 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
969 graphic_info[i].clip_gc =
970 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
974 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
975 if (copy_clipmask_gc)
976 XFreeGC(display, copy_clipmask_gc);
979 clipmasks_initialized = TRUE;
982 static void set_sound_parameters(int sound, int *parameter)
984 /* explicit loop mode setting in configuration overrides default value */
985 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
986 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
989 static void InitSoundInfo()
991 int sound_effect_properties[NUM_SOUND_FILES];
994 sound_files = getCurrentSoundList();
996 /* initialize sound effect for all elements to "no sound" */
997 for (i=0; i<MAX_NUM_ELEMENTS; i++)
998 for (j=0; j<NUM_ACTIONS; j++)
999 element_info[i].sound[j] = SND_UNDEFINED;
1001 for (i=0; i<NUM_SOUND_FILES; i++)
1003 int len_effect_text = strlen(sound_files[i].token);
1005 sound_effect_properties[i] = ACTION_OTHER;
1006 sound_info[i].loop = FALSE;
1008 /* determine all loop sounds and identify certain sound classes */
1010 for (j=0; element_action_info[j].suffix; j++)
1012 int len_action_text = strlen(element_action_info[j].suffix);
1014 if (len_action_text < len_effect_text &&
1015 strcmp(&sound_files[i].token[len_effect_text - len_action_text],
1016 element_action_info[j].suffix) == 0)
1018 sound_effect_properties[i] = element_action_info[j].value;
1020 if (element_action_info[j].is_loop_sound)
1021 sound_info[i].loop = TRUE;
1025 /* associate elements and some selected sound actions */
1027 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1029 if (element_info[j].sound_class_name)
1031 int len_class_text = strlen(element_info[j].sound_class_name);
1033 if (len_class_text + 1 < len_effect_text &&
1034 strncmp(sound_files[i].token,
1035 element_info[j].sound_class_name, len_class_text) == 0 &&
1036 sound_files[i].token[len_class_text] == '.')
1038 int sound_action_value = sound_effect_properties[i];
1040 element_info[j].sound[sound_action_value] = i;
1045 set_sound_parameters(i, sound_files[i].parameter);
1051 int element = EL_SAND;
1052 int sound_action = ACTION_DIGGING;
1055 while (element_action_info[j].suffix)
1057 if (element_action_info[j].value == sound_action)
1058 printf("element %d, sound action '%s' == %d\n",
1059 element, element_action_info[j].suffix,
1060 element_info_[element].sound[sound_action]);
1067 void InitElementProperties()
1071 static int ep_amoebalive[] =
1078 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1080 static int ep_amoeboid[] =
1088 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1090 static int ep_schluessel[] =
1101 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1103 static int ep_pforte[] =
1122 EL_SWITCHGATE_OPENING,
1123 EL_SWITCHGATE_CLOSED,
1124 EL_SWITCHGATE_CLOSING,
1126 EL_TIMEGATE_OPENING,
1128 EL_TIMEGATE_CLOSING,
1132 EL_TUBE_VERTICAL_LEFT,
1133 EL_TUBE_VERTICAL_RIGHT,
1134 EL_TUBE_HORIZONTAL_UP,
1135 EL_TUBE_HORIZONTAL_DOWN,
1141 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1143 static int ep_solid[] =
1163 EL_QUICKSAND_FILLING,
1164 EL_QUICKSAND_EMPTYING,
1166 EL_MAGIC_WALL_ACTIVE,
1167 EL_MAGIC_WALL_EMPTYING,
1168 EL_MAGIC_WALL_FILLING,
1172 EL_BD_MAGIC_WALL_ACTIVE,
1173 EL_BD_MAGIC_WALL_EMPTYING,
1174 EL_BD_MAGIC_WALL_FULL,
1175 EL_BD_MAGIC_WALL_FILLING,
1176 EL_BD_MAGIC_WALL_DEAD,
1179 EL_ACIDPOOL_TOPLEFT,
1180 EL_ACIDPOOL_TOPRIGHT,
1181 EL_ACIDPOOL_BOTTOMLEFT,
1183 EL_ACIDPOOL_BOTTOMRIGHT,
1201 EL_SP_TERMINAL_ACTIVE,
1204 EL_INVISIBLE_STEELWALL,
1205 EL_INVISIBLE_STEELWALL_ACTIVE,
1207 EL_INVISIBLE_WALL_ACTIVE,
1208 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1209 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1210 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1211 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1212 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1213 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1214 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1215 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1216 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1217 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1218 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1219 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1220 EL_SWITCHGATE_SWITCH_UP,
1221 EL_SWITCHGATE_SWITCH_DOWN,
1223 EL_LIGHT_SWITCH_ACTIVE,
1225 EL_TIMEGATE_SWITCH_ACTIVE,
1226 EL_SIGN_EXCLAMATION,
1227 EL_SIGN_RADIOACTIVITY,
1238 EL_STEELWALL_SLANTED,
1243 EL_EMC_WALL_PILLAR_UPPER,
1244 EL_EMC_WALL_PILLAR_MIDDLE,
1245 EL_EMC_WALL_PILLAR_LOWER,
1271 EL_SWITCHGATE_OPENING,
1272 EL_SWITCHGATE_CLOSED,
1273 EL_SWITCHGATE_CLOSING,
1275 EL_TIMEGATE_OPENING,
1277 EL_TIMEGATE_CLOSING,
1281 EL_TUBE_VERTICAL_LEFT,
1282 EL_TUBE_VERTICAL_RIGHT,
1283 EL_TUBE_HORIZONTAL_UP,
1284 EL_TUBE_HORIZONTAL_DOWN,
1290 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1292 static int ep_massive[] =
1296 EL_ACIDPOOL_TOPLEFT,
1297 EL_ACIDPOOL_TOPRIGHT,
1298 EL_ACIDPOOL_BOTTOMLEFT,
1300 EL_ACIDPOOL_BOTTOMRIGHT,
1312 EL_INVISIBLE_STEELWALL,
1313 EL_INVISIBLE_STEELWALL_ACTIVE,
1314 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1315 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1316 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1317 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1318 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1319 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1320 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1321 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1322 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1323 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1324 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1325 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1327 EL_LIGHT_SWITCH_ACTIVE,
1328 EL_SIGN_EXCLAMATION,
1329 EL_SIGN_RADIOACTIVITY,
1340 EL_STEELWALL_SLANTED,
1363 EL_SWITCHGATE_OPENING,
1364 EL_SWITCHGATE_CLOSED,
1365 EL_SWITCHGATE_CLOSING,
1367 EL_TIMEGATE_OPENING,
1369 EL_TIMEGATE_CLOSING,
1373 EL_TUBE_VERTICAL_LEFT,
1374 EL_TUBE_VERTICAL_RIGHT,
1375 EL_TUBE_HORIZONTAL_UP,
1376 EL_TUBE_HORIZONTAL_DOWN,
1382 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1384 static int ep_slippery[] =
1398 EL_ROBOT_WHEEL_ACTIVE,
1404 EL_ACIDPOOL_TOPLEFT,
1405 EL_ACIDPOOL_TOPRIGHT,
1415 EL_STEELWALL_SLANTED,
1419 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1421 static int ep_enemy[] =
1434 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1436 static int ep_mauer[] =
1464 EL_WALL_GROWING_ACTIVE,
1483 EL_SP_TERMINAL_ACTIVE,
1486 EL_INVISIBLE_STEELWALL,
1487 EL_INVISIBLE_STEELWALL_ACTIVE,
1489 EL_INVISIBLE_WALL_ACTIVE,
1490 EL_STEELWALL_SLANTED,
1495 EL_EMC_WALL_PILLAR_UPPER,
1496 EL_EMC_WALL_PILLAR_MIDDLE,
1497 EL_EMC_WALL_PILLAR_LOWER,
1504 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1506 static int ep_can_fall[] =
1521 EL_BD_MAGIC_WALL_FULL,
1532 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1534 static int ep_can_smash[] =
1565 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1567 static int ep_can_change[] =
1578 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1580 static int ep_can_move[] =
1600 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1602 static int ep_could_move[] =
1612 EL_BD_BUTTERFLY_RIGHT,
1614 EL_BD_BUTTERFLY_LEFT,
1615 EL_BD_BUTTERFLY_DOWN,
1616 EL_BD_FIREFLY_RIGHT,
1625 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1627 static int ep_dont_touch[] =
1634 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1636 static int ep_dont_go_to[] =
1650 EL_SP_BUGGY_BASE_ACTIVE,
1654 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1656 static int ep_mampf2[] =
1681 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1683 static int ep_bd_element[] =
1710 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1712 static int ep_sb_element[] =
1717 EL_SOKOBAN_FIELD_EMPTY,
1718 EL_SOKOBAN_FIELD_FULL,
1720 EL_INVISIBLE_STEELWALL
1722 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1724 static int ep_gem[] =
1733 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1735 static int ep_inactive[] =
1772 EL_INVISIBLE_STEELWALL,
1780 EL_WALL_EMERALD_YELLOW,
1785 EL_SOKOBAN_FIELD_EMPTY,
1786 EL_SOKOBAN_FIELD_FULL,
1787 EL_WALL_EMERALD_RED,
1788 EL_WALL_EMERALD_PURPLE,
1789 EL_ACIDPOOL_TOPLEFT,
1790 EL_ACIDPOOL_TOPRIGHT,
1791 EL_ACIDPOOL_BOTTOMLEFT,
1793 EL_ACIDPOOL_BOTTOMRIGHT,
1797 EL_BD_MAGIC_WALL_DEAD,
1798 EL_AMOEBA_TO_DIAMOND,
1831 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1832 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1833 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1834 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1835 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1836 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1837 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1838 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1839 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1840 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1841 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1842 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1843 EL_SIGN_EXCLAMATION,
1844 EL_SIGN_RADIOACTIVITY,
1855 EL_STEELWALL_SLANTED,
1860 EL_EMC_WALL_PILLAR_UPPER,
1861 EL_EMC_WALL_PILLAR_MIDDLE,
1862 EL_EMC_WALL_PILLAR_LOWER,
1869 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1871 static int ep_explosive[] =
1876 EL_DYNABOMB_PLAYER1_ACTIVE,
1877 EL_DYNABOMB_PLAYER2_ACTIVE,
1878 EL_DYNABOMB_PLAYER3_ACTIVE,
1879 EL_DYNABOMB_PLAYER4_ACTIVE,
1896 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1898 static int ep_mampf3[] =
1909 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1911 static int ep_pushable[] =
1918 EL_SOKOBAN_FIELD_FULL,
1928 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1930 static int ep_player[] =
1937 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1939 static int ep_has_content[] =
1947 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1949 static int ep_eatable[] =
1954 EL_SP_BUGGY_BASE_ACTIVATING,
1957 EL_INVISIBLE_SAND_ACTIVE
1959 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1961 static int ep_sp_element[] =
2004 /* additional elements that appeared in newer Supaplex levels */
2006 /* more than one murphy in a level results in an inactive clone */
2009 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2011 static int ep_quick_gate[] =
2035 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2037 static int ep_over_player[] =
2053 EL_TUBE_VERTICAL_LEFT,
2054 EL_TUBE_VERTICAL_RIGHT,
2055 EL_TUBE_HORIZONTAL_UP,
2056 EL_TUBE_HORIZONTAL_DOWN,
2062 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2064 static int ep_active_bomb[] =
2067 EL_DYNABOMB_PLAYER1_ACTIVE,
2068 EL_DYNABOMB_PLAYER2_ACTIVE,
2069 EL_DYNABOMB_PLAYER3_ACTIVE,
2070 EL_DYNABOMB_PLAYER4_ACTIVE
2072 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2074 static int ep_belt[] =
2076 EL_CONVEYOR_BELT1_LEFT,
2077 EL_CONVEYOR_BELT1_MIDDLE,
2078 EL_CONVEYOR_BELT1_RIGHT,
2079 EL_CONVEYOR_BELT2_LEFT,
2080 EL_CONVEYOR_BELT2_MIDDLE,
2081 EL_CONVEYOR_BELT2_RIGHT,
2082 EL_CONVEYOR_BELT3_LEFT,
2083 EL_CONVEYOR_BELT3_MIDDLE,
2084 EL_CONVEYOR_BELT3_RIGHT,
2085 EL_CONVEYOR_BELT4_LEFT,
2086 EL_CONVEYOR_BELT4_MIDDLE,
2087 EL_CONVEYOR_BELT4_RIGHT,
2089 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2091 static int ep_belt_active[] =
2093 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2094 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2095 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2096 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2097 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2098 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2099 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2100 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2101 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2102 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2103 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2104 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2106 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2108 static int ep_belt_switch[] =
2110 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2111 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2112 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2113 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2114 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2115 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2116 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2117 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2118 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2119 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2120 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2121 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2123 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2125 static int ep_tube[] =
2130 EL_TUBE_VERTICAL_LEFT,
2131 EL_TUBE_VERTICAL_RIGHT,
2132 EL_TUBE_HORIZONTAL_UP,
2133 EL_TUBE_HORIZONTAL_DOWN,
2139 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2141 static long ep1_bit[] =
2175 static long ep2_bit[] =
2182 static int *ep1_array[] =
2216 static int *ep2_array[] =
2223 static int *ep1_num[] =
2250 &ep_has_content_num,
2254 &ep_over_player_num,
2257 static int *ep2_num[] =
2260 &ep_belt_active_num,
2261 &ep_belt_switch_num,
2264 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2265 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2267 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2273 for (i=0; i<num_properties1; i++)
2274 for (j=0; j<*(ep1_num[i]); j++)
2275 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2276 for (i=0; i<num_properties2; i++)
2277 for (j=0; j<*(ep2_num[i]); j++)
2278 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2280 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2281 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2284 void Execute_Command(char *command)
2286 if (strcmp(command, "print graphicsinfo.conf") == 0)
2290 printf("# You can configure additional/alternative image files here.\n");
2291 printf("# (The images below are default and therefore commented out.)\n");
2293 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2295 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2298 for (i=0; image_config[i].token != NULL; i++)
2300 getFormattedSetupEntry(image_config[i].token,
2301 image_config[i].value));
2305 else if (strcmp(command, "print soundsinfo.conf") == 0)
2309 printf("# You can configure additional/alternative sound files here.\n");
2310 printf("# (The sounds below are default and therefore commented out.)\n");
2312 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2314 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2317 for (i=0; sound_config[i].token != NULL; i++)
2319 getFormattedSetupEntry(sound_config[i].token,
2320 sound_config[i].value));
2324 else if (strcmp(command, "print musicinfo.conf") == 0)
2326 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2328 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2330 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2334 else if (strncmp(command, "dump level ", 11) == 0)
2336 char *filename = &command[11];
2338 if (access(filename, F_OK) != 0)
2339 Error(ERR_EXIT, "cannot open file '%s'", filename);
2341 LoadLevelFromFilename(filename);
2346 else if (strncmp(command, "dump tape ", 10) == 0)
2348 char *filename = &command[10];
2350 if (access(filename, F_OK) != 0)
2351 Error(ERR_EXIT, "cannot open file '%s'", filename);
2353 LoadTapeFromFilename(filename);
2358 else if (strncmp(command, "autoplay ", 9) == 0)
2360 char *str_copy = getStringCopy(&command[9]);
2361 char *str_ptr = strchr(str_copy, ' ');
2363 global.autoplay_leveldir = str_copy;
2364 global.autoplay_level_nr = -1;
2366 if (str_ptr != NULL)
2368 *str_ptr++ = '\0'; /* terminate leveldir string */
2369 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2374 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2378 void CloseAllAndExit(int exit_value)
2383 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2386 FreeTileClipmasks();
2388 if (bitmap_font_initial)
2389 FreeBitmap(bitmap_font_initial);
2391 CloseVideoDisplay();
2392 ClosePlatformDependantStuff();