1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
14 #include "libgame/libgame.h"
29 #include "conf_e2g.c" /* include auto-generated data structure definitions */
32 static char *image_filename[NUM_PICTURES] =
40 "RocksFontMedium.pcx",
53 "RocksFontMedium.pcx",
58 static Bitmap *bitmap_font_initial = NULL;
60 static void InitGlobal(void);
61 static void InitSetup(void);
62 static void InitPlayerInfo(void);
63 static void InitLevelInfo(void);
64 static void InitArtworkInfo(void);
65 static void InitLevelArtworkInfo(void);
66 static void InitNetworkServer(void);
67 static void InitArtworkConfig(void);
68 static void InitImages(void);
69 static void InitMixer(void);
70 static void InitSound(void);
71 static void InitMusic(void);
72 static void InitGfx(void);
73 static void InitGfxBackground(void);
74 static void InitGadgets(void);
75 static void InitElementProperties(void);
76 static void InitElementGraphicInfo(void);
77 static void InitElementSoundInfo(void);
78 static void InitGraphicInfo(void);
79 static void InitSoundInfo();
80 static void Execute_Command(char *);
84 InitGlobal(); /* initialize some global variables */
86 if (options.execute_command)
87 Execute_Command(options.execute_command);
89 if (options.serveronly)
91 #if defined(PLATFORM_UNIX)
92 NetworkServer(options.server_port, options.serveronly);
94 Error(ERR_WARN, "networking only supported in Unix version");
96 exit(0); /* never reached */
99 InitProgramInfo(UNIX_USERDATA_DIRECTORY,
100 PROGRAM_TITLE_STRING, getWindowTitleString(),
101 ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
102 MSDOS_POINTER_FILENAME,
103 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
107 InitArtworkInfo(); /* needed before loading gfx, sound & music */
108 InitArtworkConfig(); /* needed before forking sound child process */
114 InitRND(NEW_RANDOMIZE);
117 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
120 InitEventFilter(FilterMouseMotionEvents);
122 InitElementProperties();
127 InitLevelArtworkInfo();
129 InitImages(); /* needs to know current level directory */
130 InitSound(); /* needs to know current level directory */
131 InitMusic(); /* needs to know current level directory */
135 if (global.autoplay_leveldir)
146 static void InitGlobal()
148 global.autoplay_leveldir = NULL;
150 global.frames_per_second = 0;
151 global.fps_slowdown = FALSE;
152 global.fps_slowdown_factor = 1;
155 static void InitSetup()
157 LoadSetup(); /* global setup info */
160 static void InitPlayerInfo()
164 /* choose default local player */
165 local_player = &stored_player[0];
167 for (i=0; i<MAX_PLAYERS; i++)
168 stored_player[i].connected = FALSE;
170 local_player->connected = TRUE;
173 static void InitLevelInfo()
175 LoadLevelInfo(); /* global level info */
176 LoadLevelSetup_LastSeries(); /* last played series info */
177 LoadLevelSetup_SeriesInfo(); /* last played level info */
180 static void InitArtworkInfo()
185 static void InitArtworkConfig()
187 static char *element_prefix[MAX_NUM_ELEMENTS + 1];
188 static char *sound_class_prefix[MAX_NUM_ELEMENTS + 1];
189 static char *action_suffix[NUM_ACTIONS + 1];
190 static char *direction_suffix[NUM_DIRECTIONS + 1];
191 static char *dummy[1] = { NULL };
194 for (i=0; i<MAX_NUM_ELEMENTS; i++)
195 element_info[i].custom_description = NULL;
197 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
198 element_prefix[i] = element_info[i].token_name;
199 for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
200 sound_class_prefix[i] = element_info[i].sound_class_name;
201 for (i=0; i<NUM_ACTIONS + 1; i++)
202 action_suffix[i] = element_action_info[i].suffix;
203 for (i=0; i<NUM_DIRECTIONS + 1; i++)
204 direction_suffix[i] = element_direction_info[i].suffix;
206 InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
207 element_prefix, action_suffix, direction_suffix);
208 InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
209 sound_class_prefix, action_suffix, dummy);
212 void InitLevelArtworkInfo()
214 LoadLevelArtworkInfo();
217 void InitNetworkServer()
219 #if defined(PLATFORM_UNIX)
223 if (!options.network)
226 #if defined(PLATFORM_UNIX)
227 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
229 if (!ConnectToServer(options.server_host, options.server_port))
230 Error(ERR_EXIT, "cannot connect to network game server");
232 SendToServer_PlayerName(setup.player_name);
233 SendToServer_ProtocolVersion();
236 SendToServer_NrWanted(nr_wanted);
240 static void InitMixer()
246 static void ReinitializeGraphics()
248 InitElementGraphicInfo(); /* initialize element/graphic config info */
249 InitGraphicInfo(); /* initialize graphic info from config file */
251 InitFontInfo(bitmap_font_initial,
252 graphic_info[IMG_FONT_BIG].bitmap,
253 graphic_info[IMG_FONT_MEDIUM].bitmap,
254 graphic_info[IMG_FONT_SMALL].bitmap,
255 graphic_info[IMG_FONT_EM].bitmap);
257 SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
258 SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
265 /* !!! TEST ONLY !!! */
270 Bitmap *tst_bitmap = graphic_info[IMG_SAND].bitmap;
271 Bitmap *tmp_bitmap = ZoomBitmap(tst_bitmap,
272 tst_bitmap->width / 2,
273 tst_bitmap->height / 2);
275 BlitBitmap(tmp_bitmap, tst_bitmap, 0, 0, 256, 224, 0, 448);
277 FreeBitmap(tmp_bitmap);
285 SDL_Surface *dst = SDLZoomSurface(graphic_info[IMG_SAND].bitmap->surface,
287 tmp_bitmap.surface = dst;
289 BlitBitmap(&tmp_bitmap, graphic_info[IMG_SAND].bitmap,
290 0, 0, 256, 224, 0, 448);
292 SDL_FreeSurface(dst);
295 #elif defined(PLATFORM_MSDOS)
297 stretch_blit((BITMAP *)(graphic_info[IMG_SAND].bitmap->drawable),
298 (BITMAP *)(graphic_info[IMG_SAND].bitmap->drawable),
306 static void ReinitializeSounds()
308 InitElementSoundInfo(); /* initialize element/sound config info */
309 InitSoundInfo(); /* initialize sounds info from config file */
311 InitPlaySoundLevel(); /* initialize internal game sound values */
314 static void ReinitializeMusic()
316 /* currently nothing to do */
319 static void InitImages()
321 ReloadCustomImages();
322 ReinitializeGraphics();
324 LoadCustomElementDescriptions();
327 static void InitSound()
329 InitReloadCustomSounds(artwork.snd_current->identifier);
330 ReinitializeSounds();
333 static void InitMusic()
335 InitReloadCustomMusic(artwork.mus_current->identifier);
339 static void InitTileClipmasks()
342 #if defined(TARGET_X11)
343 XGCValues clip_gc_values;
344 unsigned long clip_gc_valuemask;
346 #if defined(TARGET_X11_NATIVE)
356 tile_needs_clipping[] =
358 { GFX_SPIELER1_UP, 4 },
359 { GFX_SPIELER1_DOWN, 4 },
360 { GFX_SPIELER1_LEFT, 4 },
361 { GFX_SPIELER1_RIGHT, 4 },
362 { GFX_SPIELER1_PUSH_LEFT, 4 },
363 { GFX_SPIELER1_PUSH_RIGHT, 4 },
364 { GFX_SPIELER2_UP, 4 },
365 { GFX_SPIELER2_DOWN, 4 },
366 { GFX_SPIELER2_LEFT, 4 },
367 { GFX_SPIELER2_RIGHT, 4 },
368 { GFX_SPIELER2_PUSH_LEFT, 4 },
369 { GFX_SPIELER2_PUSH_RIGHT, 4 },
370 { GFX_SPIELER3_UP, 4 },
371 { GFX_SPIELER3_DOWN, 4 },
372 { GFX_SPIELER3_LEFT, 4 },
373 { GFX_SPIELER3_RIGHT, 4 },
374 { GFX_SPIELER3_PUSH_LEFT, 4 },
375 { GFX_SPIELER3_PUSH_RIGHT, 4 },
376 { GFX_SPIELER4_UP, 4 },
377 { GFX_SPIELER4_DOWN, 4 },
378 { GFX_SPIELER4_LEFT, 4 },
379 { GFX_SPIELER4_RIGHT, 4 },
380 { GFX_SPIELER4_PUSH_LEFT, 4 },
381 { GFX_SPIELER4_PUSH_RIGHT, 4 },
382 { GFX_SP_MURPHY, 1 },
383 { GFX_MURPHY_GO_LEFT, 3 },
384 { GFX_MURPHY_GO_RIGHT, 3 },
385 { GFX_MURPHY_SNAP_UP, 1 },
386 { GFX_MURPHY_SNAP_DOWN, 1 },
387 { GFX_MURPHY_SNAP_RIGHT, 1 },
388 { GFX_MURPHY_SNAP_LEFT, 1 },
389 { GFX_MURPHY_PUSH_RIGHT, 1 },
390 { GFX_MURPHY_PUSH_LEFT, 1 },
391 { GFX_GEBLUBBER, 4 },
394 { GFX_EXPLOSION, 8 },
395 { GFX_SOKOBAN_OBJEKT, 1 },
396 { GFX_FUNKELN_BLAU, 3 },
397 { GFX_FUNKELN_WEISS, 3 },
398 { GFX2_SHIELD_PASSIVE, 3 },
399 { GFX2_SHIELD_ACTIVE, 3 },
404 #endif /* TARGET_X11_NATIVE */
405 #endif /* TARGET_X11 */
409 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
410 for (i=0; i<NUM_TILES; i++)
411 tile_clipmask[i] = None;
413 #if defined(TARGET_X11)
414 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
415 often very slow when preparing a masked XCopyArea() for big Pixmaps.
416 To prevent this, create small (tile-sized) mask Pixmaps which will then
417 be set much faster with XSetClipOrigin() and speed things up a lot. */
419 clip_gc_values.graphics_exposures = False;
420 clip_gc_valuemask = GCGraphicsExposures;
421 tile_clip_gc = XCreateGC(display, window->drawable,
422 clip_gc_valuemask, &clip_gc_values);
425 for (i=0; i<NUM_BITMAPS; i++)
427 if (pix[i]->clip_mask)
429 clip_gc_values.graphics_exposures = False;
430 clip_gc_values.clip_mask = pix[i]->clip_mask;
431 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
432 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
433 clip_gc_valuemask, &clip_gc_values);
438 #if defined(TARGET_X11_NATIVE)
441 /* create graphic context structures needed for clipping */
442 clip_gc_values.graphics_exposures = False;
443 clip_gc_valuemask = GCGraphicsExposures;
444 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
445 clip_gc_valuemask, &clip_gc_values);
447 /* create only those clipping Pixmaps we really need */
448 for (i=0; tile_needs_clipping[i].start>=0; i++)
452 for (j=0; j<tile_needs_clipping[i].count; j++)
454 int tile = tile_needs_clipping[i].start + j;
460 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
461 src_pixmap = src_bitmap->clip_mask;
463 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
466 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
467 src_x, src_y, TILEX, TILEY, 0, 0);
471 XFreeGC(display, copy_clipmask_gc);
474 #endif /* TARGET_X11_NATIVE */
475 #endif /* TARGET_X11 */
479 void FreeTileClipmasks()
482 #if defined(TARGET_X11)
485 for (i=0; i<NUM_TILES; i++)
487 if (tile_clipmask[i] != None)
489 XFreePixmap(display, tile_clipmask[i]);
490 tile_clipmask[i] = None;
495 XFreeGC(display, tile_clip_gc);
499 for (i=0; i<NUM_BITMAPS; i++)
501 if (pix[i] != NULL && pix[i]->stored_clip_gc)
503 XFreeGC(display, pix[i]->stored_clip_gc);
504 pix[i]->stored_clip_gc = None;
509 #endif /* TARGET_X11 */
519 /* initialize screen properties */
520 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
521 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
522 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
523 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
524 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
526 /* create additional image buffers for double-buffering */
527 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
528 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
531 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
533 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
535 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
537 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
540 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
541 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
543 DrawInitText("Loading graphics:", 120, FC_GREEN);
546 for (i=0; i<NUM_PICTURES; i++)
549 if (i != PIX_FONT_SMALL)
552 DrawInitText(image_filename[i], 150, FC_YELLOW);
554 pix[i] = LoadCustomImage(image_filename[i]);
560 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
567 void InitGfxBackground()
572 fieldbuffer = bitmap_db_field;
573 SetDrawtoField(DRAW_BACKBUFFER);
575 BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
576 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
577 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
578 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
580 for (x=0; x<MAX_BUF_XSIZE; x++)
581 for (y=0; y<MAX_BUF_YSIZE; y++)
584 redraw_mask = REDRAW_ALL;
587 void ReloadCustomArtwork()
589 static char *leveldir_current_identifier = NULL;
590 static boolean last_override_level_graphics = FALSE;
591 static boolean last_override_level_sounds = FALSE;
592 static boolean last_override_level_music = FALSE;
593 /* identifier for new artwork; default: artwork configured in setup */
594 char *gfx_new_identifier = artwork.gfx_current->identifier;
595 char *snd_new_identifier = artwork.snd_current->identifier;
596 char *mus_new_identifier = artwork.mus_current->identifier;
597 boolean redraw_screen = FALSE;
599 if (leveldir_current_identifier == NULL)
600 leveldir_current_identifier = leveldir_current->identifier;
603 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
604 leveldir_current->graphics_set);
605 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
606 leveldir_current->identifier);
610 printf("graphics --> '%s' ('%s')\n",
611 artwork.gfx_current_identifier, artwork.gfx_current->filename);
612 printf("sounds --> '%s' ('%s')\n",
613 artwork.snd_current_identifier, artwork.snd_current->filename);
614 printf("music --> '%s' ('%s')\n",
615 artwork.mus_current_identifier, artwork.mus_current->filename);
618 /* leveldir_current may be invalid (level group, parent link) */
619 if (!validLevelSeries(leveldir_current))
622 /* when a new level series was selected, check if there was a change
623 in custom artwork stored in level series directory */
624 if (leveldir_current_identifier != leveldir_current->identifier)
626 char *identifier_old = leveldir_current_identifier;
627 char *identifier_new = leveldir_current->identifier;
629 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
630 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
631 gfx_new_identifier = identifier_new;
632 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
633 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
634 snd_new_identifier = identifier_new;
635 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
636 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
637 mus_new_identifier = identifier_new;
639 leveldir_current_identifier = leveldir_current->identifier;
642 /* custom level artwork configured in level series configuration file
643 always overrides custom level artwork stored in level series directory
644 and (level independant) custom artwork configured in setup menue */
645 if (leveldir_current->graphics_set != NULL)
646 gfx_new_identifier = leveldir_current->graphics_set;
647 if (leveldir_current->sounds_set != NULL)
648 snd_new_identifier = leveldir_current->sounds_set;
649 if (leveldir_current->music_set != NULL)
650 mus_new_identifier = leveldir_current->music_set;
652 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
653 last_override_level_graphics != setup.override_level_graphics)
656 printf("RELOADING GRAPHICS '%s' -> '%s' ('%s')\n",
657 artwork.gfx_current_identifier,
658 artwork.gfx_current->identifier,
662 setLevelArtworkDir(artwork.gfx_first);
664 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
666 ReloadCustomImages();
667 ReinitializeGraphics();
669 LoadCustomElementDescriptions();
674 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
675 last_override_level_graphics = setup.override_level_graphics;
677 redraw_screen = TRUE;
680 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
681 last_override_level_sounds != setup.override_level_sounds)
684 printf("RELOADING SOUNDS '%s' -> '%s' ('%s')\n",
685 artwork.snd_current_identifier,
686 artwork.snd_current->identifier,
690 /* set artwork path to send it to the sound server process */
691 setLevelArtworkDir(artwork.snd_first);
693 InitReloadCustomSounds(snd_new_identifier);
694 ReinitializeSounds();
696 artwork.snd_current_identifier = artwork.snd_current->identifier;
697 last_override_level_sounds = setup.override_level_sounds;
699 redraw_screen = TRUE;
702 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
703 last_override_level_music != setup.override_level_music)
705 /* set artwork path to send it to the sound server process */
706 setLevelArtworkDir(artwork.mus_first);
708 InitReloadCustomMusic(mus_new_identifier);
711 artwork.mus_current_identifier = artwork.mus_current->identifier;
712 last_override_level_music = setup.override_level_music;
714 redraw_screen = TRUE;
721 /* force redraw of (open or closed) door graphics */
722 SetDoorState(DOOR_OPEN_ALL);
723 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
729 FreeLevelEditorGadgets();
738 static boolean gadgets_initialized = FALSE;
740 if (gadgets_initialized)
743 CreateLevelEditorGadgets();
747 CreateScreenGadgets();
749 gadgets_initialized = TRUE;
752 void InitElementGraphicInfo()
754 struct PropertyMapping *property_mapping = getImageListPropertyMapping();
755 int num_property_mappings = getImageListPropertyMappingSize();
758 /* set values to -1 to identify later as "uninitialized" values */
759 for (i=0; i<MAX_NUM_ELEMENTS; i++)
761 for (act=0; act<NUM_ACTIONS; act++)
763 element_info[i].graphic[act] = -1;
765 for (dir=0; dir<NUM_DIRECTIONS; dir++)
766 element_info[i].direction_graphic[act][dir] = -1;
770 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
771 element_info[i].graphic[ACTION_DEFAULT] =
772 IMG_CHAR_START + (i - EL_CHAR_START);
774 for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++)
775 element_info[i].graphic[ACTION_DEFAULT] =
776 IMG_CUSTOM_START + (i - EL_CUSTOM_START);
778 /* initialize element/graphic mapping from static configuration */
779 for (i=0; element_to_graphic[i].element > -1; i++)
781 int element = element_to_graphic[i].element;
782 int action = element_to_graphic[i].action;
783 int direction = element_to_graphic[i].direction;
784 int graphic = element_to_graphic[i].graphic;
787 action = ACTION_DEFAULT;
790 element_info[element].direction_graphic[action][direction] = graphic;
792 element_info[element].graphic[action] = graphic;
795 /* initialize element/graphic mapping from dynamic configuration */
796 for (i=0; i < num_property_mappings; i++)
798 int element = property_mapping[i].base_index;
799 int action = property_mapping[i].ext1_index;
800 int direction = property_mapping[i].ext2_index;
801 int graphic = property_mapping[i].artwork_index;
804 action = ACTION_DEFAULT;
807 element_info[element].direction_graphic[action][direction] = graphic;
809 element_info[element].graphic[action] = graphic;
812 /* now set all '-1' values to element specific default values */
813 for (i=0; i<MAX_NUM_ELEMENTS; i++)
815 int default_action_graphic = element_info[i].graphic[ACTION_DEFAULT];
816 int default_action_direction_graphic[NUM_DIRECTIONS];
818 if (default_action_graphic == -1)
819 default_action_graphic = IMG_CHAR_QUESTION;
821 for (dir=0; dir<NUM_DIRECTIONS; dir++)
823 default_action_direction_graphic[dir] =
824 element_info[i].direction_graphic[ACTION_DEFAULT][dir];
826 if (default_action_direction_graphic[dir] == -1)
827 default_action_direction_graphic[dir] = default_action_graphic;
830 for (act=0; act<NUM_ACTIONS; act++)
832 for (dir=0; dir<NUM_DIRECTIONS; dir++)
834 int default_direction_graphic = element_info[i].graphic[act];
836 /* no graphic for current action -- use default direction graphic */
837 if (default_direction_graphic == -1)
838 default_direction_graphic = default_action_direction_graphic[dir];
840 if (element_info[i].direction_graphic[act][dir] == -1)
841 element_info[i].direction_graphic[act][dir] =
842 default_direction_graphic;
845 /* no graphic for this specific action -- use default action graphic */
846 if (element_info[i].graphic[act] == -1)
847 element_info[i].graphic[act] = default_action_graphic;
852 static void InitElementSoundInfo()
857 static void set_graphic_parameters(int graphic, int *parameter)
859 Bitmap *src_bitmap = getBitmapFromImageID(graphic);
860 int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
861 int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
863 graphic_info[graphic].bitmap = src_bitmap;
865 graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
866 graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
867 graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
868 graphic_info[graphic].offset_y = 0;
870 /* animation frames are ordered vertically instead of horizontally */
871 if (parameter[GFX_ARG_VERTICAL])
873 graphic_info[graphic].offset_x = 0;
874 graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
877 /* optionally, the x and y offset of frames can be specified directly */
878 if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
879 graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
880 if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
881 graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
883 /* automatically determine correct number of frames, if not defined */
884 if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
885 graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
886 else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
887 graphic_info[graphic].anim_frames = num_xtiles;
888 else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
889 graphic_info[graphic].anim_frames = num_ytiles;
891 graphic_info[graphic].anim_frames = 1;
893 graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
894 if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
895 graphic_info[graphic].anim_delay = 1;
897 /* set mode for animation frame order */
898 if (parameter[GFX_ARG_MODE_LOOP])
899 graphic_info[graphic].anim_mode = ANIM_LOOP;
900 else if (parameter[GFX_ARG_MODE_LINEAR])
901 graphic_info[graphic].anim_mode = ANIM_LINEAR;
902 else if (parameter[GFX_ARG_MODE_PINGPONG])
903 graphic_info[graphic].anim_mode = ANIM_PINGPONG;
904 else if (parameter[GFX_ARG_MODE_PINGPONG2])
905 graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
906 else if (parameter[GFX_ARG_MODE_RANDOM])
907 graphic_info[graphic].anim_mode = ANIM_RANDOM;
908 else if (graphic_info[graphic].anim_frames > 1)
909 graphic_info[graphic].anim_mode = ANIM_LOOP;
911 graphic_info[graphic].anim_mode = ANIM_NONE;
913 /* set additional flag to play animation frames in reverse order */
914 if (parameter[GFX_ARG_MODE_REVERSE])
915 graphic_info[graphic].anim_mode |= ANIM_REVERSE;
917 /* automatically determine correct start frame, if not defined */
918 if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
919 graphic_info[graphic].anim_start_frame = 0;
920 else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
921 graphic_info[graphic].anim_start_frame =
922 graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
924 graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
926 /* animation synchronized with global frame counter, not move position */
927 graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
930 static void InitGraphicInfo()
932 static boolean clipmasks_initialized = FALSE;
933 int num_images = getImageListSize();
935 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
937 XGCValues clip_gc_values;
938 unsigned long clip_gc_valuemask;
939 GC copy_clipmask_gc = None;
942 if (graphic_info != NULL)
945 graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
947 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
948 if (clipmasks_initialized)
950 for (i=0; i<num_images; i++)
952 if (graphic_info[i].clip_mask)
953 XFreePixmap(display, graphic_info[i].clip_mask);
954 if (graphic_info[i].clip_gc)
955 XFreeGC(display, graphic_info[i].clip_gc);
957 graphic_info[i].clip_mask = None;
958 graphic_info[i].clip_gc = None;
963 for (i=0; i<num_images; i++)
965 struct FileInfo *image = getImageListEntry(i);
968 int first_frame, last_frame;
970 set_graphic_parameters(i, image->parameter);
972 /* now check if no animation frames are outside of the loaded image */
974 if (graphic_info[i].bitmap == NULL)
975 continue; /* skip check for optional images that are undefined */
978 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
979 if (src_x < 0 || src_y < 0 ||
980 src_x + TILEX > src_bitmap->width ||
981 src_y + TILEY > src_bitmap->height)
983 Error(ERR_RETURN_LINE, "-");
984 Error(ERR_RETURN, "warning: error found in config file:");
985 Error(ERR_RETURN, "- config file: '%s'",
986 getImageConfigFilename());
987 Error(ERR_RETURN, "- config token: '%s'",
988 getTokenFromImageID(i));
989 Error(ERR_RETURN, "- image file: '%s'",
990 src_bitmap->source_filename);
992 "error: first animation frame out of bounds (%d, %d)",
994 Error(ERR_RETURN, "custom graphic rejected for this element/action");
995 Error(ERR_RETURN_LINE, "-");
997 set_graphic_parameters(i, image->default_parameter);
1000 last_frame = graphic_info[i].anim_frames - 1;
1001 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
1002 if (src_x < 0 || src_y < 0 ||
1003 src_x + TILEX > src_bitmap->width ||
1004 src_y + TILEY > src_bitmap->height)
1006 Error(ERR_RETURN_LINE, "-");
1007 Error(ERR_RETURN, "warning: error found in config file:");
1008 Error(ERR_RETURN, "- config file: '%s'",
1009 getImageConfigFilename());
1010 Error(ERR_RETURN, "- config token: '%s'",
1011 getTokenFromImageID(i));
1012 Error(ERR_RETURN, "- image file: '%s'",
1013 src_bitmap->source_filename);
1015 "error: last animation frame (%d) out of bounds (%d, %d)",
1016 last_frame, src_x, src_y);
1017 Error(ERR_RETURN, "custom graphic rejected for this element/action");
1018 Error(ERR_RETURN_LINE, "-");
1020 set_graphic_parameters(i, image->default_parameter);
1023 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1024 /* currently we need only a tile clip mask from the first frame */
1025 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
1027 if (copy_clipmask_gc == None)
1029 clip_gc_values.graphics_exposures = False;
1030 clip_gc_valuemask = GCGraphicsExposures;
1031 copy_clipmask_gc = XCreateGC(display, src_bitmap->clip_mask,
1032 clip_gc_valuemask, &clip_gc_values);
1035 graphic_info[i].clip_mask =
1036 XCreatePixmap(display, window->drawable, TILEX, TILEY, 1);
1038 src_pixmap = src_bitmap->clip_mask;
1039 XCopyArea(display, src_pixmap, graphic_info[i].clip_mask,
1040 copy_clipmask_gc, src_x, src_y, TILEX, TILEY, 0, 0);
1042 clip_gc_values.graphics_exposures = False;
1043 clip_gc_values.clip_mask = graphic_info[i].clip_mask;
1044 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
1045 graphic_info[i].clip_gc =
1046 XCreateGC(display, window->drawable, clip_gc_valuemask, &clip_gc_values);
1050 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
1051 if (copy_clipmask_gc)
1052 XFreeGC(display, copy_clipmask_gc);
1055 clipmasks_initialized = TRUE;
1058 static void set_sound_parameters(int sound, int *parameter)
1060 /* explicit loop mode setting in configuration overrides default value */
1061 if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
1062 sound_info[sound].loop = parameter[SND_ARG_MODE_LOOP];
1065 static void InitSoundInfo()
1067 int *sound_effect_properties;
1068 int num_sounds = getSoundListSize();
1071 if (sound_info != NULL)
1074 sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
1075 sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
1077 /* initialize sound effect for all elements to "no sound" */
1078 for (i=0; i<MAX_NUM_ELEMENTS; i++)
1079 for (j=0; j<NUM_ACTIONS; j++)
1080 element_info[i].sound[j] = SND_UNDEFINED;
1082 for (i=0; i<num_sounds; i++)
1084 struct FileInfo *sound = getSoundListEntry(i);
1085 int len_effect_text = strlen(sound->token);
1087 sound_effect_properties[i] = ACTION_OTHER;
1088 sound_info[i].loop = FALSE;
1090 /* determine all loop sounds and identify certain sound classes */
1092 for (j=0; element_action_info[j].suffix; j++)
1094 int len_action_text = strlen(element_action_info[j].suffix);
1096 if (len_action_text < len_effect_text &&
1097 strcmp(&sound->token[len_effect_text - len_action_text],
1098 element_action_info[j].suffix) == 0)
1100 sound_effect_properties[i] = element_action_info[j].value;
1102 if (element_action_info[j].is_loop_sound)
1103 sound_info[i].loop = TRUE;
1107 /* associate elements and some selected sound actions */
1109 for (j=0; j<MAX_NUM_ELEMENTS; j++)
1111 if (element_info[j].sound_class_name)
1113 int len_class_text = strlen(element_info[j].sound_class_name);
1115 if (len_class_text + 1 < len_effect_text &&
1116 strncmp(sound->token,
1117 element_info[j].sound_class_name, len_class_text) == 0 &&
1118 sound->token[len_class_text] == '.')
1120 int sound_action_value = sound_effect_properties[i];
1122 element_info[j].sound[sound_action_value] = i;
1127 set_sound_parameters(i, sound->parameter);
1130 free(sound_effect_properties);
1135 int element = EL_SAND;
1136 int sound_action = ACTION_DIGGING;
1139 while (element_action_info[j].suffix)
1141 if (element_action_info[j].value == sound_action)
1142 printf("element %d, sound action '%s' == %d\n",
1143 element, element_action_info[j].suffix,
1144 element_info_[element].sound[sound_action]);
1151 void InitElementProperties()
1155 static int ep_amoebalive[] =
1162 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
1164 static int ep_amoeboid[] =
1172 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
1174 static int ep_schluessel[] =
1185 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
1187 static int ep_pforte[] =
1206 EL_SWITCHGATE_OPENING,
1207 EL_SWITCHGATE_CLOSED,
1208 EL_SWITCHGATE_CLOSING,
1210 EL_TIMEGATE_OPENING,
1212 EL_TIMEGATE_CLOSING,
1216 EL_TUBE_VERTICAL_LEFT,
1217 EL_TUBE_VERTICAL_RIGHT,
1218 EL_TUBE_HORIZONTAL_UP,
1219 EL_TUBE_HORIZONTAL_DOWN,
1225 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
1227 static int ep_solid[] =
1247 EL_QUICKSAND_FILLING,
1248 EL_QUICKSAND_EMPTYING,
1250 EL_MAGIC_WALL_ACTIVE,
1251 EL_MAGIC_WALL_EMPTYING,
1252 EL_MAGIC_WALL_FILLING,
1256 EL_BD_MAGIC_WALL_ACTIVE,
1257 EL_BD_MAGIC_WALL_EMPTYING,
1258 EL_BD_MAGIC_WALL_FULL,
1259 EL_BD_MAGIC_WALL_FILLING,
1260 EL_BD_MAGIC_WALL_DEAD,
1263 EL_ACIDPOOL_TOPLEFT,
1264 EL_ACIDPOOL_TOPRIGHT,
1265 EL_ACIDPOOL_BOTTOMLEFT,
1267 EL_ACIDPOOL_BOTTOMRIGHT,
1285 EL_SP_TERMINAL_ACTIVE,
1288 EL_INVISIBLE_STEELWALL,
1289 EL_INVISIBLE_STEELWALL_ACTIVE,
1291 EL_INVISIBLE_WALL_ACTIVE,
1292 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1293 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1294 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1295 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1296 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1297 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1298 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1299 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1300 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1301 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1302 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1303 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1304 EL_SWITCHGATE_SWITCH_UP,
1305 EL_SWITCHGATE_SWITCH_DOWN,
1307 EL_LIGHT_SWITCH_ACTIVE,
1309 EL_TIMEGATE_SWITCH_ACTIVE,
1310 EL_SIGN_EXCLAMATION,
1311 EL_SIGN_RADIOACTIVITY,
1322 EL_STEELWALL_SLANTED,
1327 EL_EMC_WALL_PILLAR_UPPER,
1328 EL_EMC_WALL_PILLAR_MIDDLE,
1329 EL_EMC_WALL_PILLAR_LOWER,
1355 EL_SWITCHGATE_OPENING,
1356 EL_SWITCHGATE_CLOSED,
1357 EL_SWITCHGATE_CLOSING,
1359 EL_TIMEGATE_OPENING,
1361 EL_TIMEGATE_CLOSING,
1365 EL_TUBE_VERTICAL_LEFT,
1366 EL_TUBE_VERTICAL_RIGHT,
1367 EL_TUBE_HORIZONTAL_UP,
1368 EL_TUBE_HORIZONTAL_DOWN,
1374 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1376 static int ep_massive[] =
1380 EL_ACIDPOOL_TOPLEFT,
1381 EL_ACIDPOOL_TOPRIGHT,
1382 EL_ACIDPOOL_BOTTOMLEFT,
1384 EL_ACIDPOOL_BOTTOMRIGHT,
1396 EL_INVISIBLE_STEELWALL,
1397 EL_INVISIBLE_STEELWALL_ACTIVE,
1398 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1399 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1400 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1401 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1402 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1403 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1404 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1405 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1406 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1407 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1408 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1409 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1411 EL_LIGHT_SWITCH_ACTIVE,
1412 EL_SIGN_EXCLAMATION,
1413 EL_SIGN_RADIOACTIVITY,
1424 EL_STEELWALL_SLANTED,
1447 EL_SWITCHGATE_OPENING,
1448 EL_SWITCHGATE_CLOSED,
1449 EL_SWITCHGATE_CLOSING,
1451 EL_TIMEGATE_OPENING,
1453 EL_TIMEGATE_CLOSING,
1457 EL_TUBE_VERTICAL_LEFT,
1458 EL_TUBE_VERTICAL_RIGHT,
1459 EL_TUBE_HORIZONTAL_UP,
1460 EL_TUBE_HORIZONTAL_DOWN,
1466 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1468 static int ep_slippery[] =
1482 EL_ROBOT_WHEEL_ACTIVE,
1488 EL_ACIDPOOL_TOPLEFT,
1489 EL_ACIDPOOL_TOPRIGHT,
1499 EL_STEELWALL_SLANTED,
1503 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1505 static int ep_enemy[] =
1518 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1520 static int ep_mauer[] =
1548 EL_WALL_GROWING_ACTIVE,
1567 EL_SP_TERMINAL_ACTIVE,
1570 EL_INVISIBLE_STEELWALL,
1571 EL_INVISIBLE_STEELWALL_ACTIVE,
1573 EL_INVISIBLE_WALL_ACTIVE,
1574 EL_STEELWALL_SLANTED,
1579 EL_EMC_WALL_PILLAR_UPPER,
1580 EL_EMC_WALL_PILLAR_MIDDLE,
1581 EL_EMC_WALL_PILLAR_LOWER,
1588 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1590 static int ep_can_fall[] =
1605 EL_BD_MAGIC_WALL_FULL,
1616 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1618 static int ep_can_smash[] =
1649 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1651 static int ep_can_change[] =
1662 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1664 static int ep_can_move[] =
1684 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1686 static int ep_could_move[] =
1696 EL_BD_BUTTERFLY_RIGHT,
1698 EL_BD_BUTTERFLY_LEFT,
1699 EL_BD_BUTTERFLY_DOWN,
1700 EL_BD_FIREFLY_RIGHT,
1709 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1711 static int ep_dont_touch[] =
1718 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1720 static int ep_dont_go_to[] =
1734 EL_SP_BUGGY_BASE_ACTIVE,
1738 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1740 static int ep_mampf2[] =
1765 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1767 static int ep_bd_element[] =
1794 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1796 static int ep_sb_element[] =
1801 EL_SOKOBAN_FIELD_EMPTY,
1802 EL_SOKOBAN_FIELD_FULL,
1804 EL_INVISIBLE_STEELWALL
1806 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1808 static int ep_gem[] =
1817 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1819 static int ep_inactive[] =
1856 EL_INVISIBLE_STEELWALL,
1864 EL_WALL_EMERALD_YELLOW,
1869 EL_SOKOBAN_FIELD_EMPTY,
1870 EL_SOKOBAN_FIELD_FULL,
1871 EL_WALL_EMERALD_RED,
1872 EL_WALL_EMERALD_PURPLE,
1873 EL_ACIDPOOL_TOPLEFT,
1874 EL_ACIDPOOL_TOPRIGHT,
1875 EL_ACIDPOOL_BOTTOMLEFT,
1877 EL_ACIDPOOL_BOTTOMRIGHT,
1881 EL_BD_MAGIC_WALL_DEAD,
1882 EL_AMOEBA_TO_DIAMOND,
1915 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1916 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1917 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1918 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1919 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1920 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1921 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1922 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1923 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1924 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1925 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1926 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1927 EL_SIGN_EXCLAMATION,
1928 EL_SIGN_RADIOACTIVITY,
1939 EL_STEELWALL_SLANTED,
1944 EL_EMC_WALL_PILLAR_UPPER,
1945 EL_EMC_WALL_PILLAR_MIDDLE,
1946 EL_EMC_WALL_PILLAR_LOWER,
1953 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1955 static int ep_explosive[] =
1960 EL_DYNABOMB_PLAYER1_ACTIVE,
1961 EL_DYNABOMB_PLAYER2_ACTIVE,
1962 EL_DYNABOMB_PLAYER3_ACTIVE,
1963 EL_DYNABOMB_PLAYER4_ACTIVE,
1980 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1982 static int ep_mampf3[] =
1993 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1995 static int ep_pushable[] =
2002 EL_SOKOBAN_FIELD_FULL,
2012 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
2014 static int ep_player[] =
2021 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
2023 static int ep_has_content[] =
2031 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
2033 static int ep_eatable[] =
2038 EL_SP_BUGGY_BASE_ACTIVATING,
2041 EL_INVISIBLE_SAND_ACTIVE
2043 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
2045 static int ep_sp_element[] =
2088 /* additional elements that appeared in newer Supaplex levels */
2090 /* more than one murphy in a level results in an inactive clone */
2093 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
2095 static int ep_quick_gate[] =
2119 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
2121 static int ep_over_player[] =
2137 EL_TUBE_VERTICAL_LEFT,
2138 EL_TUBE_VERTICAL_RIGHT,
2139 EL_TUBE_HORIZONTAL_UP,
2140 EL_TUBE_HORIZONTAL_DOWN,
2146 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
2148 static int ep_active_bomb[] =
2151 EL_DYNABOMB_PLAYER1_ACTIVE,
2152 EL_DYNABOMB_PLAYER2_ACTIVE,
2153 EL_DYNABOMB_PLAYER3_ACTIVE,
2154 EL_DYNABOMB_PLAYER4_ACTIVE
2156 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
2158 static int ep_belt[] =
2160 EL_CONVEYOR_BELT1_LEFT,
2161 EL_CONVEYOR_BELT1_MIDDLE,
2162 EL_CONVEYOR_BELT1_RIGHT,
2163 EL_CONVEYOR_BELT2_LEFT,
2164 EL_CONVEYOR_BELT2_MIDDLE,
2165 EL_CONVEYOR_BELT2_RIGHT,
2166 EL_CONVEYOR_BELT3_LEFT,
2167 EL_CONVEYOR_BELT3_MIDDLE,
2168 EL_CONVEYOR_BELT3_RIGHT,
2169 EL_CONVEYOR_BELT4_LEFT,
2170 EL_CONVEYOR_BELT4_MIDDLE,
2171 EL_CONVEYOR_BELT4_RIGHT,
2173 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
2175 static int ep_belt_active[] =
2177 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
2178 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
2179 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
2180 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
2181 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
2182 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
2183 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
2184 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
2185 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
2186 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
2187 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
2188 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
2190 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
2192 static int ep_belt_switch[] =
2194 EL_CONVEYOR_BELT1_SWITCH_LEFT,
2195 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
2196 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
2197 EL_CONVEYOR_BELT2_SWITCH_LEFT,
2198 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
2199 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
2200 EL_CONVEYOR_BELT3_SWITCH_LEFT,
2201 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
2202 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
2203 EL_CONVEYOR_BELT4_SWITCH_LEFT,
2204 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
2205 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
2207 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
2209 static int ep_tube[] =
2214 EL_TUBE_VERTICAL_LEFT,
2215 EL_TUBE_VERTICAL_RIGHT,
2216 EL_TUBE_HORIZONTAL_UP,
2217 EL_TUBE_HORIZONTAL_DOWN,
2223 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
2225 static long ep1_bit[] =
2259 static long ep2_bit[] =
2266 static int *ep1_array[] =
2300 static int *ep2_array[] =
2307 static int *ep1_num[] =
2334 &ep_has_content_num,
2338 &ep_over_player_num,
2341 static int *ep2_num[] =
2344 &ep_belt_active_num,
2345 &ep_belt_switch_num,
2348 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2349 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2351 for (i=0; i<MAX_NUM_ELEMENTS; i++)
2357 for (i=0; i<num_properties1; i++)
2358 for (j=0; j<*(ep1_num[i]); j++)
2359 Properties1[(ep1_array[i])[j]] |= ep1_bit[i];
2360 for (i=0; i<num_properties2; i++)
2361 for (j=0; j<*(ep2_num[i]); j++)
2362 Properties2[(ep2_array[i])[j]] |= ep2_bit[i];
2364 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2365 Properties1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2368 void Execute_Command(char *command)
2370 if (strcmp(command, "print graphicsinfo.conf") == 0)
2374 printf("# You can configure additional/alternative image files here.\n");
2375 printf("# (The images below are default and therefore commented out.)\n");
2377 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2379 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2382 for (i=0; image_config[i].token != NULL; i++)
2384 getFormattedSetupEntry(image_config[i].token,
2385 image_config[i].value));
2389 else if (strcmp(command, "print soundsinfo.conf") == 0)
2393 printf("# You can configure additional/alternative sound files here.\n");
2394 printf("# (The sounds below are default and therefore commented out.)\n");
2396 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2398 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2401 for (i=0; sound_config[i].token != NULL; i++)
2403 getFormattedSetupEntry(sound_config[i].token,
2404 sound_config[i].value));
2408 else if (strcmp(command, "print musicinfo.conf") == 0)
2410 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2412 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2414 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2418 else if (strncmp(command, "dump level ", 11) == 0)
2420 char *filename = &command[11];
2422 if (access(filename, F_OK) != 0)
2423 Error(ERR_EXIT, "cannot open file '%s'", filename);
2425 LoadLevelFromFilename(filename);
2430 else if (strncmp(command, "dump tape ", 10) == 0)
2432 char *filename = &command[10];
2434 if (access(filename, F_OK) != 0)
2435 Error(ERR_EXIT, "cannot open file '%s'", filename);
2437 LoadTapeFromFilename(filename);
2442 else if (strncmp(command, "autoplay ", 9) == 0)
2444 char *str_copy = getStringCopy(&command[9]);
2445 char *str_ptr = strchr(str_copy, ' ');
2447 global.autoplay_leveldir = str_copy;
2448 global.autoplay_level_nr = -1;
2450 if (str_ptr != NULL)
2452 *str_ptr++ = '\0'; /* terminate leveldir string */
2453 global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
2458 Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
2462 void CloseAllAndExit(int exit_value)
2467 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2470 FreeTileClipmasks();
2472 if (bitmap_font_initial)
2473 FreeBitmap(bitmap_font_initial);
2475 CloseVideoDisplay();
2476 ClosePlatformDependantStuff();