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 *action_suffix[NUM_ACTIONS + 1];
189 static char *direction_suffix[NUM_DIRECTIONS + 1];
190 static char *dummy[1] = { NULL };
193 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
194 element_prefix[i] = element_info[i].token_name;
195 for (i=0; i<NUM_ACTIONS + 1; i++)
196 action_suffix[i] = element_action_info[i].suffix;
197 for (i=0; i<NUM_DIRECTIONS + 1; i++)
198 direction_suffix[i] = element_direction_info[i].suffix;
200 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
201 element_prefix, action_suffix, direction_suffix);
202 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
203 element_prefix, action_suffix, dummy);
206 void InitLevelArtworkInfo()
208 LoadLevelArtworkInfo();
211 void InitNetworkServer()
213 #if defined(PLATFORM_UNIX)
217 if (!options.network)
220 #if defined(PLATFORM_UNIX)
221 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
223 if (!ConnectToServer(options.server_host, options.server_port))
224 Error(ERR_EXIT, "cannot connect to network game server");
226 SendToServer_PlayerName(setup.player_name);
227 SendToServer_ProtocolVersion();
230 SendToServer_NrWanted(nr_wanted);
234 static void InitMixer()
240 static void ReinitializeGraphics()
242 InitGraphicInfo(); /* initialize graphic info from config file */
244 InitFontInfo(bitmap_font_initial,
245 graphic_info[IMG_FONT_BIG].bitmap,
246 graphic_info[IMG_FONT_MEDIUM].bitmap,
247 graphic_info[IMG_FONT_SMALL].bitmap,
248 graphic_info[IMG_FONT_EM].bitmap);
250 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
251 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
257 static void ReinitializeSounds()
259 InitSoundInfo(); /* initialize sounds info from config file */
262 static void ReinitializeMusic()
264 /* currently nothing to do */
267 static void InitImages()
269 ReloadCustomImages();
270 ReinitializeGraphics();
273 static void InitSound()
275 InitReloadCustomSounds(artwork.snd_current->identifier);
276 ReinitializeSounds();
279 static void InitMusic()
281 InitReloadCustomMusic(artwork.mus_current->identifier);
285 static void InitTileClipmasks()
288 #if defined(TARGET_X11)
289 XGCValues clip_gc_values;
290 unsigned long clip_gc_valuemask;
292 #if defined(TARGET_X11_NATIVE)
302 tile_needs_clipping[] =
304 { GFX_SPIELER1_UP, 4 },
305 { GFX_SPIELER1_DOWN, 4 },
306 { GFX_SPIELER1_LEFT, 4 },
307 { GFX_SPIELER1_RIGHT, 4 },
308 { GFX_SPIELER1_PUSH_LEFT, 4 },
309 { GFX_SPIELER1_PUSH_RIGHT, 4 },
310 { GFX_SPIELER2_UP, 4 },
311 { GFX_SPIELER2_DOWN, 4 },
312 { GFX_SPIELER2_LEFT, 4 },
313 { GFX_SPIELER2_RIGHT, 4 },
314 { GFX_SPIELER2_PUSH_LEFT, 4 },
315 { GFX_SPIELER2_PUSH_RIGHT, 4 },
316 { GFX_SPIELER3_UP, 4 },
317 { GFX_SPIELER3_DOWN, 4 },
318 { GFX_SPIELER3_LEFT, 4 },
319 { GFX_SPIELER3_RIGHT, 4 },
320 { GFX_SPIELER3_PUSH_LEFT, 4 },
321 { GFX_SPIELER3_PUSH_RIGHT, 4 },
322 { GFX_SPIELER4_UP, 4 },
323 { GFX_SPIELER4_DOWN, 4 },
324 { GFX_SPIELER4_LEFT, 4 },
325 { GFX_SPIELER4_RIGHT, 4 },
326 { GFX_SPIELER4_PUSH_LEFT, 4 },
327 { GFX_SPIELER4_PUSH_RIGHT, 4 },
328 { GFX_SP_MURPHY, 1 },
329 { GFX_MURPHY_GO_LEFT, 3 },
330 { GFX_MURPHY_GO_RIGHT, 3 },
331 { GFX_MURPHY_SNAP_UP, 1 },
332 { GFX_MURPHY_SNAP_DOWN, 1 },
333 { GFX_MURPHY_SNAP_RIGHT, 1 },
334 { GFX_MURPHY_SNAP_LEFT, 1 },
335 { GFX_MURPHY_PUSH_RIGHT, 1 },
336 { GFX_MURPHY_PUSH_LEFT, 1 },
337 { GFX_GEBLUBBER, 4 },
340 { GFX_EXPLOSION, 8 },
341 { GFX_SOKOBAN_OBJEKT, 1 },
342 { GFX_FUNKELN_BLAU, 3 },
343 { GFX_FUNKELN_WEISS, 3 },
344 { GFX2_SHIELD_PASSIVE, 3 },
345 { GFX2_SHIELD_ACTIVE, 3 },
350 #endif /* TARGET_X11_NATIVE */
351 #endif /* TARGET_X11 */
355 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
356 for (i=0; i<NUM_TILES; i++)
357 tile_clipmask[i] = None;
359 #if defined(TARGET_X11)
360 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
361 often very slow when preparing a masked XCopyArea() for big Pixmaps.
362 To prevent this, create small (tile-sized) mask Pixmaps which will then
363 be set much faster with XSetClipOrigin() and speed things up a lot. */
365 clip_gc_values.graphics_exposures = False;
366 clip_gc_valuemask = GCGraphicsExposures;
367 tile_clip_gc = XCreateGC(display, window->drawable,
368 clip_gc_valuemask, &clip_gc_values);
371 for (i=0; i<NUM_BITMAPS; i++)
373 if (pix[i]->clip_mask)
375 clip_gc_values.graphics_exposures = False;
376 clip_gc_values.clip_mask = pix[i]->clip_mask;
377 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
378 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
379 clip_gc_valuemask, &clip_gc_values);
384 #if defined(TARGET_X11_NATIVE)
387 /* create graphic context structures needed for clipping */
388 clip_gc_values.graphics_exposures = False;
389 clip_gc_valuemask = GCGraphicsExposures;
390 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
391 clip_gc_valuemask, &clip_gc_values);
393 /* create only those clipping Pixmaps we really need */
394 for (i=0; tile_needs_clipping[i].start>=0; i++)
398 for (j=0; j<tile_needs_clipping[i].count; j++)
400 int tile = tile_needs_clipping[i].start + j;
406 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
407 src_pixmap = src_bitmap->clip_mask;
409 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
412 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
413 src_x, src_y, TILEX, TILEY, 0, 0);
417 XFreeGC(display, copy_clipmask_gc);
420 #endif /* TARGET_X11_NATIVE */
421 #endif /* TARGET_X11 */
425 void FreeTileClipmasks()
428 #if defined(TARGET_X11)
431 for (i=0; i<NUM_TILES; i++)
433 if (tile_clipmask[i] != None)
435 XFreePixmap(display, tile_clipmask[i]);
436 tile_clipmask[i] = None;
441 XFreeGC(display, tile_clip_gc);
445 for (i=0; i<NUM_BITMAPS; i++)
447 if (pix[i] != NULL && pix[i]->stored_clip_gc)
449 XFreeGC(display, pix[i]->stored_clip_gc);
450 pix[i]->stored_clip_gc = None;
455 #endif /* TARGET_X11 */
465 /* initialize screen properties */
466 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
467 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
468 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
469 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
470 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
472 /* create additional image buffers for double-buffering */
473 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
474 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
477 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
479 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
481 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
483 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
486 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
487 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
489 DrawInitText("Loading graphics:", 120, FC_GREEN);
492 for (i=0; i<NUM_PICTURES; i++)
495 if (i != PIX_FONT_SMALL)
498 DrawInitText(image_filename[i], 150, FC_YELLOW);
500 pix[i] = LoadCustomImage(image_filename[i]);
506 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
513 void InitGfxBackground()
518 fieldbuffer = bitmap_db_field;
519 SetDrawtoField(DRAW_BACKBUFFER);
521 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
522 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
523 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
524 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
526 for (x=0; x<MAX_BUF_XSIZE; x++)
527 for (y=0; y<MAX_BUF_YSIZE; y++)
530 redraw_mask = REDRAW_ALL;
533 void ReloadCustomArtwork()
535 static char *leveldir_current_identifier = NULL;
536 static boolean last_override_level_graphics = FALSE;
537 static boolean last_override_level_sounds = FALSE;
538 static boolean last_override_level_music = FALSE;
539 /* identifier for new artwork; default: artwork configured in setup */
540 char *gfx_new_identifier = artwork.gfx_current->identifier;
541 char *snd_new_identifier = artwork.snd_current->identifier;
542 char *mus_new_identifier = artwork.mus_current->identifier;
543 boolean redraw_screen = FALSE;
545 if (leveldir_current_identifier == NULL)
546 leveldir_current_identifier = leveldir_current->identifier;
549 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
550 leveldir_current->graphics_set);
551 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
552 leveldir_current->identifier);
556 printf("graphics --> '%s' ('%s')\n",
557 artwork.gfx_current_identifier, artwork.gfx_current->filename);
558 printf("sounds --> '%s' ('%s')\n",
559 artwork.snd_current_identifier, artwork.snd_current->filename);
560 printf("music --> '%s' ('%s')\n",
561 artwork.mus_current_identifier, artwork.mus_current->filename);
564 /* leveldir_current may be invalid (level group, parent link) */
565 if (!validLevelSeries(leveldir_current))
568 /* when a new level series was selected, check if there was a change
569 in custom artwork stored in level series directory */
570 if (leveldir_current_identifier != leveldir_current->identifier)
572 char *identifier_old = leveldir_current_identifier;
573 char *identifier_new = leveldir_current->identifier;
575 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
576 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
577 gfx_new_identifier = identifier_new;
578 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
579 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
580 snd_new_identifier = identifier_new;
581 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
582 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
583 mus_new_identifier = identifier_new;
585 leveldir_current_identifier = leveldir_current->identifier;
588 /* custom level artwork configured in level series configuration file
589 always overrides custom level artwork stored in level series directory
590 and (level independant) custom artwork configured in setup menue */
591 if (leveldir_current->graphics_set != NULL)
592 gfx_new_identifier = leveldir_current->graphics_set;
593 if (leveldir_current->sounds_set != NULL)
594 snd_new_identifier = leveldir_current->sounds_set;
595 if (leveldir_current->music_set != NULL)
596 mus_new_identifier = leveldir_current->music_set;
598 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
599 last_override_level_graphics != setup.override_level_graphics)
602 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
603 artwork.gfx_current_identifier,
604 artwork.gfx_current->identifier,
608 setLevelArtworkDir(artwork.gfx_first);
610 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
612 ReloadCustomImages();
613 ReinitializeGraphics();
618 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
619 last_override_level_graphics = setup.override_level_graphics;
621 redraw_screen = TRUE;
624 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
625 last_override_level_sounds != setup.override_level_sounds)
628 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
629 artwork.snd_current_identifier,
630 artwork.snd_current->identifier,
634 /* set artwork path to send it to the sound server process */
635 setLevelArtworkDir(artwork.snd_first);
637 InitReloadCustomSounds(snd_new_identifier);
638 ReinitializeSounds();
640 artwork.snd_current_identifier = artwork.snd_current->identifier;
641 last_override_level_sounds = setup.override_level_sounds;
643 redraw_screen = TRUE;
646 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
647 last_override_level_music != setup.override_level_music)
649 /* set artwork path to send it to the sound server process */
650 setLevelArtworkDir(artwork.mus_first);
652 InitReloadCustomMusic(mus_new_identifier);
655 artwork.mus_current_identifier = artwork.mus_current->identifier;
656 last_override_level_music = setup.override_level_music;
658 redraw_screen = TRUE;
665 /* force redraw of (open or closed) door graphics */
666 SetDoorState(DOOR_OPEN_ALL);
667 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
673 FreeLevelEditorGadgets();
682 static boolean gadgets_initialized = FALSE;
684 if (gadgets_initialized)
687 CreateLevelEditorGadgets();
691 CreateScreenGadgets();
693 gadgets_initialized = TRUE;
696 void InitElementInfo()
700 /* set values to -1 to identify later as "uninitialized" values */
701 for (i=0; i<MAX_NUM_ELEMENTS; i++)
703 for (act=0; act<NUM_ACTIONS; act++)
705 element_info[i].graphic[act] = -1;
707 for (dir=0; dir<NUM_DIRECTIONS; dir++)
708 element_info[i].direction_graphic[act][dir] = -1;
712 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
713 element_info[i].graphic[ACTION_DEFAULT] =
714 IMG_CHAR_START + (i - EL_CHAR_START);
716 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
717 element_info[i].graphic[ACTION_DEFAULT] =
718 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
721 while (element_to_graphic[i].element > -1)
723 int element = element_to_graphic[i].element;
724 int direction = element_to_graphic[i].direction;
725 int action = element_to_graphic[i].action;
726 int graphic = element_to_graphic[i].graphic;
729 action = ACTION_DEFAULT;
733 direction = MV_DIR_BIT(direction);
735 element_info[element].direction_graphic[action][direction] = graphic;
738 element_info[element].graphic[action] = graphic;
743 /* now set all '-1' values to element specific default values */
744 for (i=0; i<MAX_NUM_ELEMENTS; i++)
746 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
747 int default_action_direction_graphic[NUM_DIRECTIONS];
749 if (default_action_graphic == -1)
750 default_action_graphic = IMG_CHAR_QUESTION;
752 for (dir=0; dir<NUM_DIRECTIONS; dir++)
754 default_action_direction_graphic[dir] =
755 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
757 if (default_action_direction_graphic[dir] == -1)
758 default_action_direction_graphic[dir] = default_action_graphic;
761 for (act=0; act<NUM_ACTIONS; act++)
763 for (dir=0; dir<NUM_DIRECTIONS; dir++)
765 int default_direction_graphic = element_info[i].graphic[act];
767 /* no graphic for current action -- use default direction graphic */
768 if (default_direction_graphic == -1)
769 default_direction_graphic = default_action_direction_graphic[dir];
771 if (element_info[i].direction_graphic[act][dir] == -1)
772 element_info[i].direction_graphic[act][dir] =
773 default_direction_graphic;
776 /* no graphic for this specific action -- use default action graphic */
777 if (element_info[i].graphic[act] == -1)
778 element_info[i].graphic[act] = default_action_graphic;
783 static void set_graphic_parameters(int graphic, int *parameter)
785 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
786 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
787 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
789 graphic_info[graphic].bitmap = src_bitmap;
791 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
792 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
793 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
794 graphic_info[graphic].offset_y = 0;
796 /* animation frames are ordered vertically instead of horizontally */
797 if (parameter[GFX_ARG_VERTICAL])
799 graphic_info[graphic].offset_x = 0;
800 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
803 /* optionally, the x and y offset of frames can be specified directly */
804 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
805 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
806 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
807 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
809 /* automatically determine correct number of frames, if not defined */
810 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
811 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
812 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
813 graphic_info[graphic].anim_frames = num_xtiles;
814 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
815 graphic_info[graphic].anim_frames = num_ytiles;
817 graphic_info[graphic].anim_frames = 1;
819 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
820 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
821 graphic_info[graphic].anim_delay = 1;
823 /* set mode for animation frame order */
824 if (parameter[GFX_ARG_MODE_LOOP])
825 graphic_info[graphic].anim_mode = ANIM_LOOP;
826 else if (parameter[GFX_ARG_MODE_LINEAR])
827 graphic_info[graphic].anim_mode = ANIM_LINEAR;
828 else if (parameter[GFX_ARG_MODE_PINGPONG])
829 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
830 else if (parameter[GFX_ARG_MODE_PINGPONG2])
831 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
832 else if (parameter[GFX_ARG_MODE_RANDOM])
833 graphic_info[graphic].anim_mode = ANIM_RANDOM;
834 else if (graphic_info[graphic].anim_frames > 1)
835 graphic_info[graphic].anim_mode = ANIM_LOOP;
837 graphic_info[graphic].anim_mode = ANIM_NONE;
839 /* set additional flag to play animation frames in reverse order */
840 if (parameter[GFX_ARG_MODE_REVERSE])
841 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
843 /* automatically determine correct start frame, if not defined */
844 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
845 graphic_info[graphic].anim_start_frame = 0;
846 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
847 graphic_info[graphic].anim_start_frame =
848 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
850 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
852 /* animation synchronized with global frame counter, not move position */
853 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
856 static void InitGraphicInfo()
858 static boolean clipmasks_initialized = FALSE;
860 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
862 XGCValues clip_gc_values;
863 unsigned long clip_gc_valuemask;
864 GC copy_clipmask_gc = None;
867 image_files = getCurrentImageList();
869 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
870 if (clipmasks_initialized)
872 for (i=0; i<NUM_IMAGE_FILES; i++)
874 if (graphic_info[i].clip_mask)
875 XFreePixmap(display, graphic_info[i].clip_mask);
876 if (graphic_info[i].clip_gc)
877 XFreeGC(display, graphic_info[i].clip_gc);
879 graphic_info[i].clip_mask = None;
880 graphic_info[i].clip_gc = None;
885 for (i=0; i<NUM_IMAGE_FILES; i++)
889 int first_frame, last_frame;
891 set_graphic_parameters(i, image_files[i].parameter);
893 /* now check if no animation frames are outside of the loaded image */
895 if (graphic_info[i].bitmap == NULL)
896 continue; /* skip check for optional images that are undefined */
899 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
900 if (src_x < 0 || src_y < 0 ||
901 src_x + TILEX > src_bitmap->width ||
902 src_y + TILEY > src_bitmap->height)
904 Error(ERR_RETURN_LINE, "-");
905 Error(ERR_RETURN, "warning: error found in config file:");
906 Error(ERR_RETURN, "- config file: '%s'",
907 getImageConfigFilename());
908 Error(ERR_RETURN, "- config token: '%s'",
909 getTokenFromImageID(i));
910 Error(ERR_RETURN, "- image file: '%s'",
911 src_bitmap->source_filename);
913 "error: first animation frame out of bounds (%d, %d)",
915 Error(ERR_RETURN, "custom graphic rejected for this element/action");
916 Error(ERR_RETURN_LINE, "-");
918 set_graphic_parameters(i, image_files[i].default_parameter);
921 last_frame = graphic_info[i].anim_frames - 1;
922 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
923 if (src_x < 0 || src_y < 0 ||
924 src_x + TILEX > src_bitmap->width ||
925 src_y + TILEY > src_bitmap->height)
927 Error(ERR_RETURN_LINE, "-");
928 Error(ERR_RETURN, "warning: error found in config file:");
929 Error(ERR_RETURN, "- config file: '%s'",
930 getImageConfigFilename());
931 Error(ERR_RETURN, "- config token: '%s'",
932 getTokenFromImageID(i));
933 Error(ERR_RETURN, "- image file: '%s'",
934 src_bitmap->source_filename);
936 "error: last animation frame (%d) out of bounds (%d, %d)",
937 last_frame, src_x, src_y);
938 Error(ERR_RETURN, "custom graphic rejected for this element/action");
939 Error(ERR_RETURN_LINE, "-");
941 set_graphic_parameters(i, image_files[i].default_parameter);
944 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
945 /* currently we need only a tile clip mask from the first frame */
946 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
948 if (copy_clipmask_gc == None)
950 clip_gc_values.graphics_exposures = False;
951 clip_gc_valuemask = GCGraphicsExposures;
952 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
953 clip_gc_valuemask, &clip_gc_values);
956 graphic_info[i].clip_mask =
957 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
959 src_pixmap = src_bitmap->clip_mask;
960 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
961 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
963 clip_gc_values.graphics_exposures = False;
964 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
965 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
966 graphic_info[i].clip_gc =
967 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
971 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
972 if (copy_clipmask_gc)
973 XFreeGC(display, copy_clipmask_gc);
976 clipmasks_initialized = TRUE;
979 static void set_sound_parameters(int sound, int *parameter)
981 /* explicit loop mode setting in configuration overrides default value */
982 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
983 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
986 static void InitSoundInfo()
988 int sound_effect_properties[NUM_SOUND_FILES];
991 sound_files = getCurrentSoundList();
993 /* initialize sound effect for all elements to "no sound" */
994 for (i=0; i<MAX_NUM_ELEMENTS; i++)
995 for (j=0; j<NUM_ACTIONS; j++)
996 element_info[i].sound[j] = SND_UNDEFINED;
998 for (i=0; i<NUM_SOUND_FILES; i++)
1000 int len_effect_text = strlen(sound_files[i].token);
1002 sound_effect_properties[i] = ACTION_OTHER;
1003 sound_info[i].loop = FALSE;
1005 /* determine all loop sounds and identify certain sound classes */
1007 for (j=0; element_action_info[j].suffix; j++)
1009 int len_action_text = strlen(element_action_info[j].suffix);
1011 if (len_action_text < len_effect_text &&
1012 strcmp(&sound_files[i].token[len_effect_text - len_action_text],
1013 element_action_info[j].suffix) == 0)
1015 sound_effect_properties[i] = element_action_info[j].value;
1017 if (element_action_info[j].is_loop_sound)
1018 sound_info[i].loop = TRUE;
1022 /* associate elements and some selected sound actions */
1024 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1026 if (element_info[j].sound_class_name)
1028 int len_class_text = strlen(element_info[j].sound_class_name);
1030 if (len_class_text + 1 < len_effect_text &&
1031 strncmp(sound_files[i].token,
1032 element_info[j].sound_class_name, len_class_text) == 0 &&
1033 sound_files[i].token[len_class_text] == '.')
1035 int sound_action_value = sound_effect_properties[i];
1037 element_info[j].sound[sound_action_value] = i;
1042 set_sound_parameters(i, sound_files[i].parameter);
1048 int element = EL_SAND;
1049 int sound_action = ACTION_DIGGING;
1052 while (element_action_info[j].suffix)
1054 if (element_action_info[j].value == sound_action)
1055 printf("element %d, sound action '%s' == %d\n",
1056 element, element_action_info[j].suffix,
1057 element_info_[element].sound[sound_action]);
1064 void InitElementProperties()
1068 static int ep_amoebalive[] =
1075 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1077 static int ep_amoeboid[] =
1085 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1087 static int ep_schluessel[] =
1098 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1100 static int ep_pforte[] =
1119 EL_SWITCHGATE_OPENING,
1120 EL_SWITCHGATE_CLOSED,
1121 EL_SWITCHGATE_CLOSING,
1123 EL_TIMEGATE_OPENING,
1125 EL_TIMEGATE_CLOSING,
1129 EL_TUBE_VERTICAL_LEFT,
1130 EL_TUBE_VERTICAL_RIGHT,
1131 EL_TUBE_HORIZONTAL_UP,
1132 EL_TUBE_HORIZONTAL_DOWN,
1138 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1140 static int ep_solid[] =
1160 EL_QUICKSAND_FILLING,
1161 EL_QUICKSAND_EMPTYING,
1163 EL_MAGIC_WALL_ACTIVE,
1164 EL_MAGIC_WALL_EMPTYING,
1165 EL_MAGIC_WALL_FILLING,
1169 EL_BD_MAGIC_WALL_ACTIVE,
1170 EL_BD_MAGIC_WALL_EMPTYING,
1171 EL_BD_MAGIC_WALL_FULL,
1172 EL_BD_MAGIC_WALL_FILLING,
1173 EL_BD_MAGIC_WALL_DEAD,
1176 EL_ACIDPOOL_TOPLEFT,
1177 EL_ACIDPOOL_TOPRIGHT,
1178 EL_ACIDPOOL_BOTTOMLEFT,
1180 EL_ACIDPOOL_BOTTOMRIGHT,
1198 EL_SP_TERMINAL_ACTIVE,
1201 EL_INVISIBLE_STEELWALL,
1202 EL_INVISIBLE_STEELWALL_ACTIVE,
1204 EL_INVISIBLE_WALL_ACTIVE,
1205 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1206 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1207 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1208 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1209 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1210 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1211 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1212 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1213 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1214 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1215 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1216 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1217 EL_SWITCHGATE_SWITCH_UP,
1218 EL_SWITCHGATE_SWITCH_DOWN,
1220 EL_LIGHT_SWITCH_ACTIVE,
1222 EL_TIMEGATE_SWITCH_ACTIVE,
1223 EL_SIGN_EXCLAMATION,
1224 EL_SIGN_RADIOACTIVITY,
1235 EL_STEELWALL_SLANTED,
1240 EL_EMC_WALL_PILLAR_UPPER,
1241 EL_EMC_WALL_PILLAR_MIDDLE,
1242 EL_EMC_WALL_PILLAR_LOWER,
1268 EL_SWITCHGATE_OPENING,
1269 EL_SWITCHGATE_CLOSED,
1270 EL_SWITCHGATE_CLOSING,
1272 EL_TIMEGATE_OPENING,
1274 EL_TIMEGATE_CLOSING,
1278 EL_TUBE_VERTICAL_LEFT,
1279 EL_TUBE_VERTICAL_RIGHT,
1280 EL_TUBE_HORIZONTAL_UP,
1281 EL_TUBE_HORIZONTAL_DOWN,
1287 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1289 static int ep_massive[] =
1293 EL_ACIDPOOL_TOPLEFT,
1294 EL_ACIDPOOL_TOPRIGHT,
1295 EL_ACIDPOOL_BOTTOMLEFT,
1297 EL_ACIDPOOL_BOTTOMRIGHT,
1309 EL_INVISIBLE_STEELWALL,
1310 EL_INVISIBLE_STEELWALL_ACTIVE,
1311 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1312 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1313 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1314 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1315 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1316 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1317 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1318 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1319 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1320 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1321 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1322 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1324 EL_LIGHT_SWITCH_ACTIVE,
1325 EL_SIGN_EXCLAMATION,
1326 EL_SIGN_RADIOACTIVITY,
1337 EL_STEELWALL_SLANTED,
1360 EL_SWITCHGATE_OPENING,
1361 EL_SWITCHGATE_CLOSED,
1362 EL_SWITCHGATE_CLOSING,
1364 EL_TIMEGATE_OPENING,
1366 EL_TIMEGATE_CLOSING,
1370 EL_TUBE_VERTICAL_LEFT,
1371 EL_TUBE_VERTICAL_RIGHT,
1372 EL_TUBE_HORIZONTAL_UP,
1373 EL_TUBE_HORIZONTAL_DOWN,
1379 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1381 static int ep_slippery[] =
1395 EL_ROBOT_WHEEL_ACTIVE,
1401 EL_ACIDPOOL_TOPLEFT,
1402 EL_ACIDPOOL_TOPRIGHT,
1412 EL_STEELWALL_SLANTED,
1416 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1418 static int ep_enemy[] =
1431 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1433 static int ep_mauer[] =
1461 EL_WALL_GROWING_ACTIVE,
1480 EL_SP_TERMINAL_ACTIVE,
1483 EL_INVISIBLE_STEELWALL,
1484 EL_INVISIBLE_STEELWALL_ACTIVE,
1486 EL_INVISIBLE_WALL_ACTIVE,
1487 EL_STEELWALL_SLANTED,
1492 EL_EMC_WALL_PILLAR_UPPER,
1493 EL_EMC_WALL_PILLAR_MIDDLE,
1494 EL_EMC_WALL_PILLAR_LOWER,
1501 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1503 static int ep_can_fall[] =
1518 EL_BD_MAGIC_WALL_FULL,
1529 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1531 static int ep_can_smash[] =
1562 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1564 static int ep_can_change[] =
1575 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1577 static int ep_can_move[] =
1597 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1599 static int ep_could_move[] =
1609 EL_BD_BUTTERFLY_RIGHT,
1611 EL_BD_BUTTERFLY_LEFT,
1612 EL_BD_BUTTERFLY_DOWN,
1613 EL_BD_FIREFLY_RIGHT,
1622 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1624 static int ep_dont_touch[] =
1631 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1633 static int ep_dont_go_to[] =
1647 EL_SP_BUGGY_BASE_ACTIVE,
1651 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1653 static int ep_mampf2[] =
1678 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1680 static int ep_bd_element[] =
1707 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1709 static int ep_sb_element[] =
1714 EL_SOKOBAN_FIELD_EMPTY,
1715 EL_SOKOBAN_FIELD_FULL,
1717 EL_INVISIBLE_STEELWALL
1719 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1721 static int ep_gem[] =
1730 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1732 static int ep_inactive[] =
1769 EL_INVISIBLE_STEELWALL,
1777 EL_WALL_EMERALD_YELLOW,
1782 EL_SOKOBAN_FIELD_EMPTY,
1783 EL_SOKOBAN_FIELD_FULL,
1784 EL_WALL_EMERALD_RED,
1785 EL_WALL_EMERALD_PURPLE,
1786 EL_ACIDPOOL_TOPLEFT,
1787 EL_ACIDPOOL_TOPRIGHT,
1788 EL_ACIDPOOL_BOTTOMLEFT,
1790 EL_ACIDPOOL_BOTTOMRIGHT,
1794 EL_BD_MAGIC_WALL_DEAD,
1795 EL_AMOEBA_TO_DIAMOND,
1828 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1829 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1830 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1831 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1832 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1833 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1834 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1835 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1836 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1837 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1838 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1839 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1840 EL_SIGN_EXCLAMATION,
1841 EL_SIGN_RADIOACTIVITY,
1852 EL_STEELWALL_SLANTED,
1857 EL_EMC_WALL_PILLAR_UPPER,
1858 EL_EMC_WALL_PILLAR_MIDDLE,
1859 EL_EMC_WALL_PILLAR_LOWER,
1866 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1868 static int ep_explosive[] =
1873 EL_DYNABOMB_PLAYER1_ACTIVE,
1874 EL_DYNABOMB_PLAYER2_ACTIVE,
1875 EL_DYNABOMB_PLAYER3_ACTIVE,
1876 EL_DYNABOMB_PLAYER4_ACTIVE,
1893 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1895 static int ep_mampf3[] =
1906 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1908 static int ep_pushable[] =
1915 EL_SOKOBAN_FIELD_FULL,
1925 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1927 static int ep_player[] =
1934 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1936 static int ep_has_content[] =
1944 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1946 static int ep_eatable[] =
1951 EL_SP_BUGGY_BASE_ACTIVATING,
1954 EL_INVISIBLE_SAND_ACTIVE
1956 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1958 static int ep_sp_element[] =
2001 /* additional elements that appeared in newer Supaplex levels */
2003 /* more than one murphy in a level results in an inactive clone */
2006 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2008 static int ep_quick_gate[] =
2032 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2034 static int ep_over_player[] =
2050 EL_TUBE_VERTICAL_LEFT,
2051 EL_TUBE_VERTICAL_RIGHT,
2052 EL_TUBE_HORIZONTAL_UP,
2053 EL_TUBE_HORIZONTAL_DOWN,
2059 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2061 static int ep_active_bomb[] =
2064 EL_DYNABOMB_PLAYER1_ACTIVE,
2065 EL_DYNABOMB_PLAYER2_ACTIVE,
2066 EL_DYNABOMB_PLAYER3_ACTIVE,
2067 EL_DYNABOMB_PLAYER4_ACTIVE
2069 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2071 static int ep_belt[] =
2073 EL_CONVEYOR_BELT1_LEFT,
2074 EL_CONVEYOR_BELT1_MIDDLE,
2075 EL_CONVEYOR_BELT1_RIGHT,
2076 EL_CONVEYOR_BELT2_LEFT,
2077 EL_CONVEYOR_BELT2_MIDDLE,
2078 EL_CONVEYOR_BELT2_RIGHT,
2079 EL_CONVEYOR_BELT3_LEFT,
2080 EL_CONVEYOR_BELT3_MIDDLE,
2081 EL_CONVEYOR_BELT3_RIGHT,
2082 EL_CONVEYOR_BELT4_LEFT,
2083 EL_CONVEYOR_BELT4_MIDDLE,
2084 EL_CONVEYOR_BELT4_RIGHT,
2086 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2088 static int ep_belt_active[] =
2090 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2091 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2092 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2093 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2094 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2095 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2096 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2097 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2098 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2099 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2100 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2101 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2103 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2105 static int ep_belt_switch[] =
2107 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2108 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2109 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2110 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2111 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2112 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2113 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2114 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2115 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2116 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2117 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2118 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2120 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2122 static int ep_tube[] =
2127 EL_TUBE_VERTICAL_LEFT,
2128 EL_TUBE_VERTICAL_RIGHT,
2129 EL_TUBE_HORIZONTAL_UP,
2130 EL_TUBE_HORIZONTAL_DOWN,
2136 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2138 static long ep1_bit[] =
2172 static long ep2_bit[] =
2179 static int *ep1_array[] =
2213 static int *ep2_array[] =
2220 static int *ep1_num[] =
2247 &ep_has_content_num,
2251 &ep_over_player_num,
2254 static int *ep2_num[] =
2257 &ep_belt_active_num,
2258 &ep_belt_switch_num,
2261 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2262 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2264 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2270 for (i=0; i<num_properties1; i++)
2271 for (j=0; j<*(ep1_num[i]); j++)
2272 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2273 for (i=0; i<num_properties2; i++)
2274 for (j=0; j<*(ep2_num[i]); j++)
2275 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2277 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2278 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2281 void Execute_Command(char *command)
2283 if (strcmp(command, "print graphicsinfo.conf") == 0)
2287 printf("# You can configure additional/alternative image files here.\n");
2288 printf("# (The images below are default and therefore commented out.)\n");
2290 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2292 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2295 for (i=0; image_config[i].token != NULL; i++)
2297 getFormattedSetupEntry(image_config[i].token,
2298 image_config[i].value));
2302 else if (strcmp(command, "print soundsinfo.conf") == 0)
2306 printf("# You can configure additional/alternative sound files here.\n");
2307 printf("# (The sounds below are default and therefore commented out.)\n");
2309 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2311 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2314 for (i=0; sound_config[i].token != NULL; i++)
2316 getFormattedSetupEntry(sound_config[i].token,
2317 sound_config[i].value));
2321 else if (strcmp(command, "print musicinfo.conf") == 0)
2323 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2325 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2327 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2331 else if (strncmp(command, "dump level ", 11) == 0)
2333 char *filename = &command[11];
2335 if (access(filename, F_OK) != 0)
2336 Error(ERR_EXIT, "cannot open file '%s'", filename);
2338 LoadLevelFromFilename(filename);
2343 else if (strncmp(command, "dump tape ", 10) == 0)
2345 char *filename = &command[10];
2347 if (access(filename, F_OK) != 0)
2348 Error(ERR_EXIT, "cannot open file '%s'", filename);
2350 LoadTapeFromFilename(filename);
2355 else if (strncmp(command, "autoplay ", 9) == 0)
2357 char *str_copy = getStringCopy(&command[9]);
2358 char *str_ptr = strchr(str_copy, ' ');
2360 global.autoplay_leveldir = str_copy;
2361 global.autoplay_level_nr = -1;
2363 if (str_ptr != NULL)
2365 *str_ptr++ = '\0'; /* terminate leveldir string */
2366 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2371 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2375 void CloseAllAndExit(int exit_value)
2380 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2383 FreeTileClipmasks();
2385 if (bitmap_font_initial)
2386 FreeBitmap(bitmap_font_initial);
2388 CloseVideoDisplay();
2389 ClosePlatformDependantStuff();