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 InitSetup(void);
61 static void InitPlayerInfo(void);
62 static void InitLevelInfo(void);
63 static void InitArtworkInfo(void);
64 static void InitLevelArtworkInfo(void);
65 static void InitNetworkServer(void);
66 static void InitImages(void);
67 static void InitMixer(void);
68 static void InitSound(void);
69 static void InitGfx(void);
70 static void InitGfxBackground(void);
71 static void InitGadgets(void);
72 static void InitElementProperties(void);
73 static void InitElementInfo(void);
74 static void InitGraphicInfo(void);
75 static void InitSoundInfo();
76 static void Execute_Debug_Command(char *);
80 if (options.debug_command)
82 Execute_Debug_Command(options.debug_command);
87 if (options.serveronly)
89 #if defined(PLATFORM_UNIX)
90 NetworkServer(options.server_port, options.serveronly);
92 Error(ERR_WARN, "networking only supported in Unix version");
94 exit(0); /* never reached */
97 InitProgramInfo(UNIX_USERDATA_DIRECTORY,
98 PROGRAM_TITLE_STRING, getWindowTitleString(),
99 ICON_TITLE_STRING, X11_ICON_FILENAME, X11_ICONMASK_FILENAME,
100 MSDOS_POINTER_FILENAME,
101 COOKIE_PREFIX, FILENAME_PREFIX, GAME_VERSION_ACTUAL);
105 InitArtworkInfo(); /* needed before loading gfx, sound & music */
110 InitRND(NEW_RANDOMIZE);
113 InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
116 InitEventFilter(FilterMouseMotionEvents);
118 InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */
124 InitLevelArtworkInfo();
126 InitImages(); /* needs to know current level directory */
127 InitSound(); /* needs to know current level directory */
128 InitGadgets(); /* needs images + number of level series */
140 LoadSetup(); /* global setup info */
143 void InitPlayerInfo()
147 /* choose default local player */
148 local_player = &stored_player[0];
150 for (i=0; i<MAX_PLAYERS; i++)
151 stored_player[i].connected = FALSE;
153 local_player->connected = TRUE;
158 LoadLevelInfo(); /* global level info */
159 LoadLevelSetup_LastSeries(); /* last played series info */
160 LoadLevelSetup_SeriesInfo(); /* last played level info */
163 void InitArtworkInfo()
168 void InitLevelArtworkInfo()
170 LoadLevelArtworkInfo();
173 void InitNetworkServer()
175 #if defined(PLATFORM_UNIX)
179 if (!options.network)
182 #if defined(PLATFORM_UNIX)
183 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
185 if (!ConnectToServer(options.server_host, options.server_port))
186 Error(ERR_EXIT, "cannot connect to network game server");
188 SendToServer_PlayerName(setup.player_name);
189 SendToServer_ProtocolVersion();
192 SendToServer_NrWanted(nr_wanted);
196 static void ReinitializeGraphics()
198 ReloadCustomImages(); /* load custom image files */
200 InitGraphicInfo(); /* initialize graphic info from config file */
202 InitFontInfo(bitmap_font_initial,
203 new_graphic_info[IMG_MENU_FONT_BIG].bitmap,
204 new_graphic_info[IMG_MENU_FONT_MEDIUM].bitmap,
205 new_graphic_info[IMG_MENU_FONT_SMALL].bitmap,
206 new_graphic_info[IMG_MENU_FONT_EM].bitmap);
209 static void InitImages()
211 InitImageList(image_config, image_config_suffix, NUM_IMAGE_FILES);
213 ReinitializeGraphics();
216 static void InitMixer()
220 InitSoundList(sound_config, sound_config_suffix, NUM_SOUND_FILES);
225 static void InitSound()
227 /* load custom sounds and music */
228 InitReloadSounds(artwork.snd_current->identifier);
229 InitReloadMusic(artwork.mus_current->identifier);
234 static void InitTileClipmasks()
236 #if defined(TARGET_X11)
237 XGCValues clip_gc_values;
238 unsigned long clip_gc_valuemask;
240 #if defined(TARGET_X11_NATIVE)
250 tile_needs_clipping[] =
252 { GFX_SPIELER1_UP, 4 },
253 { GFX_SPIELER1_DOWN, 4 },
254 { GFX_SPIELER1_LEFT, 4 },
255 { GFX_SPIELER1_RIGHT, 4 },
256 { GFX_SPIELER1_PUSH_LEFT, 4 },
257 { GFX_SPIELER1_PUSH_RIGHT, 4 },
258 { GFX_SPIELER2_UP, 4 },
259 { GFX_SPIELER2_DOWN, 4 },
260 { GFX_SPIELER2_LEFT, 4 },
261 { GFX_SPIELER2_RIGHT, 4 },
262 { GFX_SPIELER2_PUSH_LEFT, 4 },
263 { GFX_SPIELER2_PUSH_RIGHT, 4 },
264 { GFX_SPIELER3_UP, 4 },
265 { GFX_SPIELER3_DOWN, 4 },
266 { GFX_SPIELER3_LEFT, 4 },
267 { GFX_SPIELER3_RIGHT, 4 },
268 { GFX_SPIELER3_PUSH_LEFT, 4 },
269 { GFX_SPIELER3_PUSH_RIGHT, 4 },
270 { GFX_SPIELER4_UP, 4 },
271 { GFX_SPIELER4_DOWN, 4 },
272 { GFX_SPIELER4_LEFT, 4 },
273 { GFX_SPIELER4_RIGHT, 4 },
274 { GFX_SPIELER4_PUSH_LEFT, 4 },
275 { GFX_SPIELER4_PUSH_RIGHT, 4 },
276 { GFX_SP_MURPHY, 1 },
277 { GFX_MURPHY_GO_LEFT, 3 },
278 { GFX_MURPHY_GO_RIGHT, 3 },
279 { GFX_MURPHY_SNAP_UP, 1 },
280 { GFX_MURPHY_SNAP_DOWN, 1 },
281 { GFX_MURPHY_SNAP_RIGHT, 1 },
282 { GFX_MURPHY_SNAP_LEFT, 1 },
283 { GFX_MURPHY_PUSH_RIGHT, 1 },
284 { GFX_MURPHY_PUSH_LEFT, 1 },
285 { GFX_GEBLUBBER, 4 },
288 { GFX_EXPLOSION, 8 },
289 { GFX_SOKOBAN_OBJEKT, 1 },
290 { GFX_FUNKELN_BLAU, 3 },
291 { GFX_FUNKELN_WEISS, 3 },
292 { GFX2_SHIELD_PASSIVE, 3 },
293 { GFX2_SHIELD_ACTIVE, 3 },
298 #endif /* TARGET_X11_NATIVE */
299 #endif /* TARGET_X11 */
303 /* initialize pixmap array for special X11 tile clipping to Pixmap 'None' */
304 for (i=0; i<NUM_TILES; i++)
305 tile_clipmask[i] = None;
307 #if defined(TARGET_X11)
308 /* This stuff is needed because X11 (XSetClipOrigin(), to be precise) is
309 often very slow when preparing a masked XCopyArea() for big Pixmaps.
310 To prevent this, create small (tile-sized) mask Pixmaps which will then
311 be set much faster with XSetClipOrigin() and speed things up a lot. */
313 clip_gc_values.graphics_exposures = False;
314 clip_gc_valuemask = GCGraphicsExposures;
315 tile_clip_gc = XCreateGC(display, window->drawable,
316 clip_gc_valuemask, &clip_gc_values);
319 for (i=0; i<NUM_BITMAPS; i++)
321 if (pix[i]->clip_mask)
323 clip_gc_values.graphics_exposures = False;
324 clip_gc_values.clip_mask = pix[i]->clip_mask;
325 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
326 pix[i]->stored_clip_gc = XCreateGC(display, window->drawable,
327 clip_gc_valuemask, &clip_gc_values);
332 #if defined(TARGET_X11_NATIVE)
335 /* create graphic context structures needed for clipping */
336 clip_gc_values.graphics_exposures = False;
337 clip_gc_valuemask = GCGraphicsExposures;
338 copy_clipmask_gc = XCreateGC(display, pix[PIX_BACK]->clip_mask,
339 clip_gc_valuemask, &clip_gc_values);
341 /* create only those clipping Pixmaps we really need */
342 for (i=0; tile_needs_clipping[i].start>=0; i++)
346 for (j=0; j<tile_needs_clipping[i].count; j++)
348 int tile = tile_needs_clipping[i].start + j;
354 getGraphicSource(graphic, &src_bitmap, &src_x, &src_y);
355 src_pixmap = src_bitmap->clip_mask;
357 tile_clipmask[tile] = XCreatePixmap(display, window->drawable,
360 XCopyArea(display, src_pixmap, tile_clipmask[tile], copy_clipmask_gc,
361 src_x, src_y, TILEX, TILEY, 0, 0);
365 XFreeGC(display, copy_clipmask_gc);
368 #endif /* TARGET_X11_NATIVE */
369 #endif /* TARGET_X11 */
372 void FreeTileClipmasks()
374 #if defined(TARGET_X11)
377 for (i=0; i<NUM_TILES; i++)
379 if (tile_clipmask[i] != None)
381 XFreePixmap(display, tile_clipmask[i]);
382 tile_clipmask[i] = None;
387 XFreeGC(display, tile_clip_gc);
391 for (i=0; i<NUM_BITMAPS; i++)
393 if (pix[i] != NULL && pix[i]->stored_clip_gc)
395 XFreeGC(display, pix[i]->stored_clip_gc);
396 pix[i]->stored_clip_gc = None;
401 #endif /* TARGET_X11 */
410 /* initialize some global variables */
411 global.frames_per_second = 0;
412 global.fps_slowdown = FALSE;
413 global.fps_slowdown_factor = 1;
415 /* initialize screen properties */
416 InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
417 REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
418 InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
419 InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
420 InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
422 /* create additional image buffers for double-buffering */
423 bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH);
424 bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH);
427 pix[PIX_FONT_SMALL] = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
429 InitFontInfo(NULL, NULL, pix[PIX_FONT_SMALL], NULL);
431 bitmap_font_initial = LoadCustomImage(image_filename[PIX_FONT_SMALL]);
433 InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
436 DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
437 DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
439 DrawInitText("Loading graphics:", 120, FC_GREEN);
442 for (i=0; i<NUM_PICTURES; i++)
445 if (i != PIX_FONT_SMALL)
448 DrawInitText(image_filename[i], 150, FC_YELLOW);
450 pix[i] = LoadCustomImage(image_filename[i]);
456 InitFontInfo(pix[PIX_FONT_BIG], pix[PIX_FONT_MEDIUM], pix[PIX_FONT_SMALL],
463 void InitGfxBackground()
468 fieldbuffer = bitmap_db_field;
469 SetDrawtoField(DRAW_BACKBUFFER);
471 BlitBitmap(new_graphic_info[IMG_MENU_BACK].bitmap, backbuffer,
472 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
473 ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
474 ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE);
476 for (x=0; x<MAX_BUF_XSIZE; x++)
477 for (y=0; y<MAX_BUF_YSIZE; y++)
480 redraw_mask = REDRAW_ALL;
483 void ReloadCustomArtwork()
485 static char *leveldir_current_identifier = NULL;
486 static boolean last_override_level_graphics = FALSE;
487 static boolean last_override_level_sounds = FALSE;
488 static boolean last_override_level_music = FALSE;
489 /* identifier for new artwork; default: artwork configured in setup */
490 char *gfx_new_identifier = artwork.gfx_current->identifier;
491 char *snd_new_identifier = artwork.snd_current->identifier;
492 char *mus_new_identifier = artwork.mus_current->identifier;
493 boolean redraw_screen = FALSE;
495 if (leveldir_current_identifier == NULL)
496 leveldir_current_identifier = leveldir_current->identifier;
499 printf("CURRENT GFX: '%s' ['%s']\n", artwork.gfx_current->identifier,
500 leveldir_current->graphics_set);
501 printf("CURRENT LEV: '%s' / '%s'\n", leveldir_current_identifier,
502 leveldir_current->identifier);
506 printf("graphics --> '%s' ('%s')\n",
507 artwork.gfx_current_identifier, artwork.gfx_current->filename);
508 printf("sounds --> '%s' ('%s')\n",
509 artwork.snd_current_identifier, artwork.snd_current->filename);
510 printf("music --> '%s' ('%s')\n",
511 artwork.mus_current_identifier, artwork.mus_current->filename);
514 /* leveldir_current may be invalid (level group, parent link) */
515 if (!validLevelSeries(leveldir_current))
519 printf("--> '%s'\n", artwork.gfx_current_identifier);
522 /* when a new level series was selected, check if there was a change
523 in custom artwork stored in level series directory */
524 if (leveldir_current_identifier != leveldir_current->identifier)
526 char *identifier_old = leveldir_current_identifier;
527 char *identifier_new = leveldir_current->identifier;
529 if (getTreeInfoFromIdentifier(artwork.gfx_first, identifier_old) !=
530 getTreeInfoFromIdentifier(artwork.gfx_first, identifier_new))
531 gfx_new_identifier = identifier_new;
532 if (getTreeInfoFromIdentifier(artwork.snd_first, identifier_old) !=
533 getTreeInfoFromIdentifier(artwork.snd_first, identifier_new))
534 snd_new_identifier = identifier_new;
535 if (getTreeInfoFromIdentifier(artwork.mus_first, identifier_new) !=
536 getTreeInfoFromIdentifier(artwork.mus_first, identifier_new))
537 mus_new_identifier = identifier_new;
539 leveldir_current_identifier = leveldir_current->identifier;
542 /* custom level artwork configured in level series configuration file
543 always overrides custom level artwork stored in level series directory
544 and (level independant) custom artwork configured in setup menue */
545 if (leveldir_current->graphics_set != NULL)
546 gfx_new_identifier = leveldir_current->graphics_set;
547 if (leveldir_current->sounds_set != NULL)
548 snd_new_identifier = leveldir_current->sounds_set;
549 if (leveldir_current->music_set != NULL)
550 mus_new_identifier = leveldir_current->music_set;
552 if (strcmp(artwork.gfx_current_identifier, gfx_new_identifier) != 0 ||
553 last_override_level_graphics != setup.override_level_graphics)
556 printf("CHANGED GFX: '%s' -> '%s'\n",
557 artwork.gfx_current_identifier, gfx_new_identifier);
564 setLevelArtworkDir(artwork.gfx_first);
566 ClearRectangle(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
569 for (i=0; i<NUM_PICTURES; i++)
571 DrawInitText(image_filename[i], 150, FC_YELLOW);
572 ReloadCustomImage(pix[i], image_filename[i]);
576 ReinitializeGraphics();
584 /* force redraw of (open or closed) door graphics */
585 SetDoorState(DOOR_OPEN_ALL);
586 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
590 artwork.gfx_current_identifier = gfx_new_identifier;
592 artwork.gfx_current_identifier = artwork.gfx_current->identifier;
594 last_override_level_graphics = setup.override_level_graphics;
596 redraw_screen = TRUE;
599 if (strcmp(artwork.snd_current_identifier, snd_new_identifier) != 0 ||
600 last_override_level_sounds != setup.override_level_sounds)
602 /* set artwork path to send it to the sound server process */
603 setLevelArtworkDir(artwork.snd_first);
605 InitReloadSounds(snd_new_identifier);
607 artwork.snd_current_identifier = snd_new_identifier;
608 last_override_level_sounds = setup.override_level_sounds;
610 redraw_screen = TRUE;
613 if (strcmp(artwork.mus_current_identifier, mus_new_identifier) != 0 ||
614 last_override_level_music != setup.override_level_music)
616 /* set artwork path to send it to the sound server process */
617 setLevelArtworkDir(artwork.mus_first);
619 InitReloadMusic(mus_new_identifier);
621 artwork.mus_current_identifier = mus_new_identifier;
622 last_override_level_music = setup.override_level_music;
624 redraw_screen = TRUE;
631 /* force redraw of (open or closed) door graphics */
632 SetDoorState(DOOR_OPEN_ALL);
633 CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY);
637 printf("<-- '%s'\n", artwork.gfx_current_identifier);
643 CreateLevelEditorGadgets();
647 CreateScreenGadgets();
650 void InitElementInfo()
655 /* set values to -1 to identify later as "uninitialized" values */
656 for (i=0; i<MAX_ELEMENTS; i++)
658 for (act=0; act<NUM_GFX_ACTIONS_MAPPED; act++)
660 element_info[i].graphic[act] = -1;
662 for (dir=0; dir<NUM_MV_DIRECTIONS; dir++)
663 element_info[i].direction_graphic[act][dir] = -1;
667 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
668 element_info[i].graphic[GFX_ACTION_DEFAULT] =
669 IMG_CHAR_START + (i - EL_CHAR_START);
671 for (i=EL_GENERIC_START; i<=EL_GENERIC_END; i++)
672 element_info[i].graphic[GFX_ACTION_DEFAULT] =
673 IMG_GENERIC_START + (i - EL_GENERIC_START);
676 while (element_to_graphic[i].element > -1)
678 int element = element_to_graphic[i].element;
679 int direction = element_to_graphic[i].direction;
680 int action = element_to_graphic[i].action;
681 int graphic = element_to_graphic[i].graphic;
684 action = graphics_action_mapping[action];
686 action = GFX_ACTION_DEFAULT;
690 direction = MV_DIR_BIT(direction);
692 element_info[element].direction_graphic[action][direction] = graphic;
695 element_info[element].graphic[action] = graphic;
700 /* now set all '-1' values to element specific default values */
701 for (i=0; i<MAX_ELEMENTS; i++)
703 int default_action_graphic = element_info[i].graphic[GFX_ACTION_DEFAULT];
704 int default_action_direction_graphic[NUM_MV_DIRECTIONS];
706 if (default_action_graphic == -1)
707 default_action_graphic = IMG_CHAR_QUESTION;
709 for (dir=0; dir<NUM_MV_DIRECTIONS; dir++)
711 default_action_direction_graphic[dir] =
712 element_info[i].direction_graphic[GFX_ACTION_DEFAULT][dir];
714 if (default_action_direction_graphic[dir] == -1)
715 default_action_direction_graphic[dir] = default_action_graphic;
718 for (act=0; act<NUM_GFX_ACTIONS_MAPPED; act++)
720 for (dir=0; dir<NUM_MV_DIRECTIONS; dir++)
722 int default_direction_graphic = element_info[i].graphic[act];
724 /* no graphic for current action -- use default direction graphic */
725 if (default_direction_graphic == -1)
726 default_direction_graphic = default_action_direction_graphic[dir];
728 if (element_info[i].direction_graphic[act][dir] == -1)
729 element_info[i].direction_graphic[act][dir] =
730 default_direction_graphic;
733 /* no graphic for this specific action -- use default action graphic */
734 if (element_info[i].graphic[act] == -1)
735 element_info[i].graphic[act] = default_action_graphic;
740 static void InitGraphicInfo()
742 static int gfx_action[NUM_IMAGE_FILES];
745 int first_frame, last_frame;
748 image_files = getCurrentImageList();
750 /* set temporary graphics action field to default value */
751 for (i=0; i<NUM_IMAGE_FILES; i++)
752 gfx_action[i] = GFX_ACTION_DEFAULT;
754 /* set temporary graphics action field from element_to_graphic list */
756 while (element_to_graphic[i].element > -1)
758 int action = element_to_graphic[i].action;
759 int graphic = element_to_graphic[i].graphic;
762 action = GFX_ACTION_DEFAULT;
764 gfx_action[graphic] = action;
769 for (i=0; i<NUM_IMAGE_FILES; i++)
771 int *parameter = image_files[i].parameter;
773 new_graphic_info[i].bitmap = getBitmapFromImageID(i);
775 new_graphic_info[i].src_x = parameter[GFX_ARG_XPOS] * TILEX;
776 new_graphic_info[i].src_y = parameter[GFX_ARG_YPOS] * TILEY;
777 new_graphic_info[i].offset_x = parameter[GFX_ARG_OFFSET];
778 new_graphic_info[i].offset_y = 0;
780 /* animation frames are ordered vertically instead of horizontally */
781 if (parameter[GFX_ARG_VERTICAL])
783 new_graphic_info[i].offset_x = 0;
784 new_graphic_info[i].offset_y = parameter[GFX_ARG_OFFSET];
787 /* optionally, the x and y offset of frames can be specified directly */
788 if (parameter[GFX_ARG_XOFFSET] != GFX_ARG_UNDEFINED_VALUE)
789 new_graphic_info[i].offset_x = parameter[GFX_ARG_XOFFSET];
790 if (parameter[GFX_ARG_YOFFSET] != GFX_ARG_UNDEFINED_VALUE)
791 new_graphic_info[i].offset_y = parameter[GFX_ARG_YOFFSET];
793 new_graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
795 new_graphic_info[i].anim_delay = parameter[GFX_ARG_DELAY];
796 if (new_graphic_info[i].anim_delay == 0) /* delay must be at least 1 */
797 new_graphic_info[i].anim_delay = 1;
799 /* set mode for animation frame order */
800 if (parameter[GFX_ARG_MODE_LOOP])
801 new_graphic_info[i].anim_mode = ANIM_LOOP;
802 else if (parameter[GFX_ARG_MODE_LINEAR])
803 new_graphic_info[i].anim_mode = ANIM_LINEAR;
804 else if (parameter[GFX_ARG_MODE_PINGPONG])
805 new_graphic_info[i].anim_mode = ANIM_PINGPONG;
806 else if (parameter[GFX_ARG_MODE_PINGPONG2])
807 new_graphic_info[i].anim_mode = ANIM_PINGPONG2;
808 else if (parameter[GFX_ARG_FRAMES] > 1)
809 new_graphic_info[i].anim_mode = ANIM_LOOP;
811 new_graphic_info[i].anim_mode = ANIM_NONE;
813 /* set additional flag to play animation frames in reverse order */
814 if (parameter[GFX_ARG_MODE_REVERSE])
815 new_graphic_info[i].anim_mode |= ANIM_REVERSE;
817 /* set first frame of animation after determining animation mode */
818 new_graphic_info[i].anim_start_frame = parameter[GFX_ARG_START_FRAME];
820 /* automatically determine correct start frame, if not defined */
821 if (parameter[GFX_ARG_START_FRAME] == GFX_ARG_UNDEFINED_VALUE)
822 new_graphic_info[i].anim_start_frame = 0;
823 else if (new_graphic_info[i].anim_mode & ANIM_REVERSE)
824 new_graphic_info[i].anim_start_frame =
825 new_graphic_info[i].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
827 /* animation synchronized with global frame counter, not move position */
828 new_graphic_info[i].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
830 /* set global_sync for all animations with undefined "animation action" */
831 if (parameter[GFX_ARG_GLOBAL_SYNC] == GFX_ARG_UNDEFINED_VALUE)
832 new_graphic_info[i].anim_global_sync =
833 (gfx_action[i] == GFX_ACTION_DEFAULT ? TRUE : FALSE);
835 /* "linear" animations are never globally synchronized */
836 if (parameter[GFX_ARG_MODE_LINEAR])
837 new_graphic_info[i].anim_global_sync = FALSE;
839 /* now check if no animation frames are outside of the loaded image */
842 getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
843 if (src_x < 0 || src_y < 0 ||
844 src_x + TILEX > src_bitmap->width ||
845 src_y + TILEY > src_bitmap->height)
846 Error(ERR_EXIT, "InitGraphicInfo: first frame of graphic animation object %d outside of image bitmap file '%s'", i, src_bitmap->source_filename);
848 last_frame = new_graphic_info[i].anim_frames - 1;
849 getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
850 if (src_x < 0 || src_y < 0 ||
851 src_x + TILEX > src_bitmap->width ||
852 src_y + TILEY > src_bitmap->height)
853 Error(ERR_EXIT, "InitGraphicInfo: last frame of graphic animation object %d outside of image bitmap file '%s'", i, src_bitmap->source_filename);
857 static void InitSoundInfo()
859 sound_files = getCurrentSoundList();
861 /* initialize sound effect lookup table for element actions */
865 void InitElementProperties()
869 static int ep_amoebalive[] =
876 static int ep_amoebalive_num = SIZEOF_ARRAY_INT(ep_amoebalive);
878 static int ep_amoeboid[] =
886 static int ep_amoeboid_num = SIZEOF_ARRAY_INT(ep_amoeboid);
888 static int ep_schluessel[] =
899 static int ep_schluessel_num = SIZEOF_ARRAY_INT(ep_schluessel);
901 static int ep_pforte[] =
920 EL_SWITCHGATE_OPENING,
921 EL_SWITCHGATE_CLOSED,
922 EL_SWITCHGATE_CLOSING,
930 EL_TUBE_VERTICAL_LEFT,
931 EL_TUBE_VERTICAL_RIGHT,
932 EL_TUBE_HORIZONTAL_UP,
933 EL_TUBE_HORIZONTAL_DOWN,
939 static int ep_pforte_num = SIZEOF_ARRAY_INT(ep_pforte);
941 static int ep_solid[] =
961 EL_QUICKSAND_FILLING,
962 EL_QUICKSAND_EMPTYING,
964 EL_MAGIC_WALL_ACTIVE,
965 EL_MAGIC_WALL_EMPTYING,
966 EL_MAGIC_WALL_FILLING,
970 EL_BD_MAGIC_WALL_ACTIVE,
971 EL_BD_MAGIC_WALL_EMPTYING,
972 EL_BD_MAGIC_WALL_FULL,
973 EL_BD_MAGIC_WALL_FILLING,
974 EL_BD_MAGIC_WALL_DEAD,
978 EL_ACIDPOOL_TOPRIGHT,
979 EL_ACIDPOOL_BOTTOMLEFT,
981 EL_ACIDPOOL_BOTTOMRIGHT,
999 EL_SP_TERMINAL_ACTIVE,
1002 EL_INVISIBLE_STEELWALL,
1003 EL_INVISIBLE_STEELWALL_ACTIVE,
1005 EL_INVISIBLE_WALL_ACTIVE,
1006 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1007 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1008 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1009 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1010 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1011 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1012 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1013 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1014 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1015 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1016 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1017 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1018 EL_SWITCHGATE_SWITCH_UP,
1019 EL_SWITCHGATE_SWITCH_DOWN,
1021 EL_LIGHT_SWITCH_ACTIVE,
1023 EL_TIMEGATE_SWITCH_ACTIVE,
1024 EL_SIGN_EXCLAMATION,
1025 EL_SIGN_RADIOACTIVITY,
1036 EL_STEELWALL_SLANTED,
1041 EL_EMC_WALL_PILLAR_UPPER,
1042 EL_EMC_WALL_PILLAR_MIDDLE,
1043 EL_EMC_WALL_PILLAR_LOWER,
1069 EL_SWITCHGATE_OPENING,
1070 EL_SWITCHGATE_CLOSED,
1071 EL_SWITCHGATE_CLOSING,
1073 EL_TIMEGATE_OPENING,
1075 EL_TIMEGATE_CLOSING,
1079 EL_TUBE_VERTICAL_LEFT,
1080 EL_TUBE_VERTICAL_RIGHT,
1081 EL_TUBE_HORIZONTAL_UP,
1082 EL_TUBE_HORIZONTAL_DOWN,
1088 static int ep_solid_num = SIZEOF_ARRAY_INT(ep_solid);
1090 static int ep_massive[] =
1094 EL_ACIDPOOL_TOPLEFT,
1095 EL_ACIDPOOL_TOPRIGHT,
1096 EL_ACIDPOOL_BOTTOMLEFT,
1098 EL_ACIDPOOL_BOTTOMRIGHT,
1110 EL_INVISIBLE_STEELWALL,
1111 EL_INVISIBLE_STEELWALL_ACTIVE,
1112 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1113 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1114 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1115 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1116 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1117 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1118 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1119 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1120 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1121 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1122 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1123 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1125 EL_LIGHT_SWITCH_ACTIVE,
1126 EL_SIGN_EXCLAMATION,
1127 EL_SIGN_RADIOACTIVITY,
1138 EL_STEELWALL_SLANTED,
1161 EL_SWITCHGATE_OPENING,
1162 EL_SWITCHGATE_CLOSED,
1163 EL_SWITCHGATE_CLOSING,
1165 EL_TIMEGATE_OPENING,
1167 EL_TIMEGATE_CLOSING,
1171 EL_TUBE_VERTICAL_LEFT,
1172 EL_TUBE_VERTICAL_RIGHT,
1173 EL_TUBE_HORIZONTAL_UP,
1174 EL_TUBE_HORIZONTAL_DOWN,
1180 static int ep_massive_num = SIZEOF_ARRAY_INT(ep_massive);
1182 static int ep_slippery[] =
1196 EL_ROBOT_WHEEL_ACTIVE,
1202 EL_ACIDPOOL_TOPLEFT,
1203 EL_ACIDPOOL_TOPRIGHT,
1213 EL_STEELWALL_SLANTED,
1217 static int ep_slippery_num = SIZEOF_ARRAY_INT(ep_slippery);
1219 static int ep_enemy[] =
1232 static int ep_enemy_num = SIZEOF_ARRAY_INT(ep_enemy);
1234 static int ep_mauer[] =
1262 EL_WALL_GROWING_ACTIVE,
1281 EL_SP_TERMINAL_ACTIVE,
1284 EL_INVISIBLE_STEELWALL,
1285 EL_INVISIBLE_STEELWALL_ACTIVE,
1287 EL_INVISIBLE_WALL_ACTIVE,
1288 EL_STEELWALL_SLANTED,
1293 EL_EMC_WALL_PILLAR_UPPER,
1294 EL_EMC_WALL_PILLAR_MIDDLE,
1295 EL_EMC_WALL_PILLAR_LOWER,
1302 static int ep_mauer_num = SIZEOF_ARRAY_INT(ep_mauer);
1304 static int ep_can_fall[] =
1319 EL_BD_MAGIC_WALL_FULL,
1330 static int ep_can_fall_num = SIZEOF_ARRAY_INT(ep_can_fall);
1332 static int ep_can_smash[] =
1363 static int ep_can_smash_num = SIZEOF_ARRAY_INT(ep_can_smash);
1365 static int ep_can_change[] =
1376 static int ep_can_change_num = SIZEOF_ARRAY_INT(ep_can_change);
1378 static int ep_can_move[] =
1398 static int ep_can_move_num = SIZEOF_ARRAY_INT(ep_can_move);
1400 static int ep_could_move[] =
1410 EL_BD_BUTTERFLY_RIGHT,
1412 EL_BD_BUTTERFLY_LEFT,
1413 EL_BD_BUTTERFLY_DOWN,
1414 EL_BD_FIREFLY_RIGHT,
1423 static int ep_could_move_num = SIZEOF_ARRAY_INT(ep_could_move);
1425 static int ep_dont_touch[] =
1432 static int ep_dont_touch_num = SIZEOF_ARRAY_INT(ep_dont_touch);
1434 static int ep_dont_go_to[] =
1448 EL_SP_BUGGY_BASE_ACTIVE,
1452 static int ep_dont_go_to_num = SIZEOF_ARRAY_INT(ep_dont_go_to);
1454 static int ep_mampf2[] =
1479 static int ep_mampf2_num = SIZEOF_ARRAY_INT(ep_mampf2);
1481 static int ep_bd_element[] =
1508 static int ep_bd_element_num = SIZEOF_ARRAY_INT(ep_bd_element);
1510 static int ep_sb_element[] =
1515 EL_SOKOBAN_FIELD_EMPTY,
1516 EL_SOKOBAN_FIELD_FULL,
1518 EL_INVISIBLE_STEELWALL
1520 static int ep_sb_element_num = SIZEOF_ARRAY_INT(ep_sb_element);
1522 static int ep_gem[] =
1531 static int ep_gem_num = SIZEOF_ARRAY_INT(ep_gem);
1533 static int ep_inactive[] =
1570 EL_INVISIBLE_STEELWALL,
1578 EL_WALL_EMERALD_YELLOW,
1583 EL_SOKOBAN_FIELD_EMPTY,
1584 EL_SOKOBAN_FIELD_FULL,
1585 EL_WALL_EMERALD_RED,
1586 EL_WALL_EMERALD_PURPLE,
1587 EL_ACIDPOOL_TOPLEFT,
1588 EL_ACIDPOOL_TOPRIGHT,
1589 EL_ACIDPOOL_BOTTOMLEFT,
1591 EL_ACIDPOOL_BOTTOMRIGHT,
1595 EL_BD_MAGIC_WALL_DEAD,
1596 EL_AMOEBA_TO_DIAMOND,
1629 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1630 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1631 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1632 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1633 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1634 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1635 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1636 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1637 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1638 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1639 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1640 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1641 EL_SIGN_EXCLAMATION,
1642 EL_SIGN_RADIOACTIVITY,
1653 EL_STEELWALL_SLANTED,
1658 EL_EMC_WALL_PILLAR_UPPER,
1659 EL_EMC_WALL_PILLAR_MIDDLE,
1660 EL_EMC_WALL_PILLAR_LOWER,
1667 static int ep_inactive_num = SIZEOF_ARRAY_INT(ep_inactive);
1669 static int ep_explosive[] =
1674 EL_DYNABOMB_PLAYER1_ACTIVE,
1675 EL_DYNABOMB_PLAYER2_ACTIVE,
1676 EL_DYNABOMB_PLAYER3_ACTIVE,
1677 EL_DYNABOMB_PLAYER4_ACTIVE,
1694 static int ep_explosive_num = SIZEOF_ARRAY_INT(ep_explosive);
1696 static int ep_mampf3[] =
1707 static int ep_mampf3_num = SIZEOF_ARRAY_INT(ep_mampf3);
1709 static int ep_pushable[] =
1716 EL_SOKOBAN_FIELD_FULL,
1726 static int ep_pushable_num = SIZEOF_ARRAY_INT(ep_pushable);
1728 static int ep_player[] =
1735 static int ep_player_num = SIZEOF_ARRAY_INT(ep_player);
1737 static int ep_has_content[] =
1745 static int ep_has_content_num = SIZEOF_ARRAY_INT(ep_has_content);
1747 static int ep_eatable[] =
1754 EL_INVISIBLE_SAND_ACTIVE
1756 static int ep_eatable_num = SIZEOF_ARRAY_INT(ep_eatable);
1758 static int ep_sp_element[] =
1801 /* additional elements that appeared in newer Supaplex levels */
1803 /* more than one murphy in a level results in an inactive clone */
1806 static int ep_sp_element_num = SIZEOF_ARRAY_INT(ep_sp_element);
1808 static int ep_quick_gate[] =
1832 static int ep_quick_gate_num = SIZEOF_ARRAY_INT(ep_quick_gate);
1834 static int ep_over_player[] =
1850 EL_TUBE_VERTICAL_LEFT,
1851 EL_TUBE_VERTICAL_RIGHT,
1852 EL_TUBE_HORIZONTAL_UP,
1853 EL_TUBE_HORIZONTAL_DOWN,
1859 static int ep_over_player_num = SIZEOF_ARRAY_INT(ep_over_player);
1861 static int ep_active_bomb[] =
1864 EL_DYNABOMB_PLAYER1_ACTIVE,
1865 EL_DYNABOMB_PLAYER2_ACTIVE,
1866 EL_DYNABOMB_PLAYER3_ACTIVE,
1867 EL_DYNABOMB_PLAYER4_ACTIVE
1869 static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
1871 static int ep_belt[] =
1873 EL_CONVEYOR_BELT1_LEFT,
1874 EL_CONVEYOR_BELT1_MIDDLE,
1875 EL_CONVEYOR_BELT1_RIGHT,
1876 EL_CONVEYOR_BELT2_LEFT,
1877 EL_CONVEYOR_BELT2_MIDDLE,
1878 EL_CONVEYOR_BELT2_RIGHT,
1879 EL_CONVEYOR_BELT3_LEFT,
1880 EL_CONVEYOR_BELT3_MIDDLE,
1881 EL_CONVEYOR_BELT3_RIGHT,
1882 EL_CONVEYOR_BELT4_LEFT,
1883 EL_CONVEYOR_BELT4_MIDDLE,
1884 EL_CONVEYOR_BELT4_RIGHT,
1886 static int ep_belt_num = SIZEOF_ARRAY_INT(ep_belt);
1888 static int ep_belt_active[] =
1890 EL_CONVEYOR_BELT1_LEFT_ACTIVE,
1891 EL_CONVEYOR_BELT1_MIDDLE_ACTIVE,
1892 EL_CONVEYOR_BELT1_RIGHT_ACTIVE,
1893 EL_CONVEYOR_BELT2_LEFT_ACTIVE,
1894 EL_CONVEYOR_BELT2_MIDDLE_ACTIVE,
1895 EL_CONVEYOR_BELT2_RIGHT_ACTIVE,
1896 EL_CONVEYOR_BELT3_LEFT_ACTIVE,
1897 EL_CONVEYOR_BELT3_MIDDLE_ACTIVE,
1898 EL_CONVEYOR_BELT3_RIGHT_ACTIVE,
1899 EL_CONVEYOR_BELT4_LEFT_ACTIVE,
1900 EL_CONVEYOR_BELT4_MIDDLE_ACTIVE,
1901 EL_CONVEYOR_BELT4_RIGHT_ACTIVE,
1903 static int ep_belt_active_num = SIZEOF_ARRAY_INT(ep_belt_active);
1905 static int ep_belt_switch[] =
1907 EL_CONVEYOR_BELT1_SWITCH_LEFT,
1908 EL_CONVEYOR_BELT1_SWITCH_MIDDLE,
1909 EL_CONVEYOR_BELT1_SWITCH_RIGHT,
1910 EL_CONVEYOR_BELT2_SWITCH_LEFT,
1911 EL_CONVEYOR_BELT2_SWITCH_MIDDLE,
1912 EL_CONVEYOR_BELT2_SWITCH_RIGHT,
1913 EL_CONVEYOR_BELT3_SWITCH_LEFT,
1914 EL_CONVEYOR_BELT3_SWITCH_MIDDLE,
1915 EL_CONVEYOR_BELT3_SWITCH_RIGHT,
1916 EL_CONVEYOR_BELT4_SWITCH_LEFT,
1917 EL_CONVEYOR_BELT4_SWITCH_MIDDLE,
1918 EL_CONVEYOR_BELT4_SWITCH_RIGHT,
1920 static int ep_belt_switch_num = SIZEOF_ARRAY_INT(ep_belt_switch);
1922 static int ep_tube[] =
1927 EL_TUBE_VERTICAL_LEFT,
1928 EL_TUBE_VERTICAL_RIGHT,
1929 EL_TUBE_HORIZONTAL_UP,
1930 EL_TUBE_HORIZONTAL_DOWN,
1936 static int ep_tube_num = SIZEOF_ARRAY_INT(ep_tube);
1938 static long ep1_bit[] =
1972 static long ep2_bit[] =
1979 static int *ep1_array[] =
2013 static int *ep2_array[] =
2020 static int *ep1_num[] =
2047 &ep_has_content_num,
2051 &ep_over_player_num,
2054 static int *ep2_num[] =
2057 &ep_belt_active_num,
2058 &ep_belt_switch_num,
2061 static int num_properties1 = SIZEOF_ARRAY(ep1_num, int *);
2062 static int num_properties2 = SIZEOF_ARRAY(ep2_num, int *);
2064 for (i=0; i<MAX_ELEMENTS; i++)
2066 Elementeigenschaften1[i] = 0;
2067 Elementeigenschaften2[i] = 0;
2070 for (i=0; i<num_properties1; i++)
2071 for (j=0; j<*(ep1_num[i]); j++)
2072 Elementeigenschaften1[(ep1_array[i])[j]] |= ep1_bit[i];
2073 for (i=0; i<num_properties2; i++)
2074 for (j=0; j<*(ep2_num[i]); j++)
2075 Elementeigenschaften2[(ep2_array[i])[j]] |= ep2_bit[i];
2077 for (i=EL_CHAR_START; i<=EL_CHAR_END; i++)
2078 Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
2081 void Execute_Debug_Command(char *command)
2083 if (strcmp(command, "create graphicsinfo.conf") == 0)
2087 printf("# You can configure additional/alternative image files here.\n");
2088 printf("# (The images below are default and therefore commented out.)\n");
2090 printf("%s\n", getFormattedSetupEntry("name", "Classic Graphics"));
2092 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2095 for (i=0; image_config[i].token != NULL; i++)
2097 getFormattedSetupEntry(image_config[i].token,
2098 image_config[i].value));
2100 else if (strcmp(command, "create soundsinfo.conf") == 0)
2104 printf("# You can configure additional/alternative sound files here.\n");
2105 printf("# (The sounds below are default and therefore commented out.)\n");
2107 printf("%s\n", getFormattedSetupEntry("name", "Classic Sounds"));
2109 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2112 for (i=0; sound_config[i].token != NULL; i++)
2114 getFormattedSetupEntry(sound_config[i].token,
2115 sound_config[i].value));
2117 else if (strcmp(command, "create musicinfo.conf") == 0)
2119 printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
2121 printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
2123 printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
2125 else if (strcmp(command, "help") == 0)
2127 printf("The following commands are recognized:\n");
2128 printf(" \"create graphicsinfo.conf\"\n");
2129 printf(" \"create soundsinfo.conf\"\n");
2130 printf(" \"create musicinfo.conf\"\n");
2134 void CloseAllAndExit(int exit_value)
2139 CloseAudio(); /* called after freeing sounds (needed for SDL) */
2142 FreeTileClipmasks();
2144 if (bitmap_font_initial)
2145 FreeBitmap(bitmap_font_initial);
2147 CloseVideoDisplay();
2148 ClosePlatformDependantStuff();