1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
31 struct PictureFileInfo
33 char *picture_filename;
34 boolean picture_with_mask;
39 char *picture_filename;
40 char *picturemask_filename;
43 static int sound_process_id = 0;
45 static void InitLevelAndPlayerInfo(void);
46 static void InitNetworkServer(void);
47 static void InitDisplay(void);
48 static void InitSound(void);
49 static void InitSoundServer(void);
50 static void InitWindow(int, char **);
51 static void InitGfx(void);
52 static void LoadGfx(int, struct PictureFileInfo *);
53 static void InitGadgets(void);
54 static void InitElementProperties(void);
56 void OpenAll(int argc, char *argv[])
58 if (options.serveronly)
60 NetworkServer(options.server_port, options.serveronly);
66 InitLevelAndPlayerInfo();
72 InitRND(NEW_RANDOMIZE);
74 signal(SIGINT, CloseAllAndExit);
75 signal(SIGTERM, CloseAllAndExit);
78 InitWindow(argc, argv);
80 XMapWindow(display, window);
84 InitElementProperties();
92 void InitLevelAndPlayerInfo()
96 /* choose default local player */
97 local_player = &stored_player[0];
99 for (i=0; i<MAX_PLAYERS; i++)
101 stored_player[i].joystick_fd = -1; /* joystick device closed */
102 stored_player[i].connected = FALSE;
105 local_player->connected = TRUE;
107 LoadLevelInfo(); /* global level info */
108 LoadSetup(); /* global setup info */
109 LoadLevelSetup_LastSeries(); /* last played series info */
110 LoadLevelSetup_SeriesInfo(leveldir_nr); /* last played level info */
113 void InitNetworkServer()
119 if (!options.network)
123 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
125 if (!ConnectToServer(options.server_host, options.server_port))
126 Error(ERR_EXIT, "cannot connect to network game server");
128 SendToServer_PlayerName(setup.player_name);
129 SendToServer_ProtocolVersion();
132 SendToServer_NrWanted(nr_wanted);
140 if (sound_status == SOUND_OFF)
144 if (access(sound_device_name, W_OK) != 0)
146 Error(ERR_WARN, "cannot access sound device - no sounds");
147 sound_status = SOUND_OFF;
151 if ((sound_device = open(sound_device_name,O_WRONLY))<0)
153 Error(ERR_WARN, "cannot open sound device - no sounds");
154 sound_status = SOUND_OFF;
159 sound_status = SOUND_AVAILABLE;
162 sound_loops_allowed = TRUE;
165 setup.sound_loops_on = TRUE;
170 sound_loops_allowed = TRUE;
173 setup.sound_loops_on = TRUE;
178 for(i=0; i<NUM_SOUNDS; i++)
181 sprintf(sound_name[i], "%d", i + 1);
184 Sound[i].name = sound_name[i];
185 if (!LoadSound(&Sound[i]))
187 sound_status = SOUND_OFF;
193 void InitSoundServer()
195 if (sound_status == SOUND_OFF)
200 if (pipe(sound_pipe)<0)
202 Error(ERR_WARN, "cannot create pipe - no sounds");
203 sound_status = SOUND_OFF;
207 if ((sound_process_id = fork()) < 0)
209 Error(ERR_WARN, "cannot create sound server process - no sounds");
210 sound_status = SOUND_OFF;
214 if (!sound_process_id) /* we are child */
221 else /* we are parent */
222 close(sound_pipe[0]); /* no reading from pipe needed */
235 if (global_joystick_status == JOYSTICK_OFF)
238 joystick_status = JOYSTICK_OFF;
241 for (i=0; i<MAX_PLAYERS; i++)
243 char *device_name = setup.input[i].joy.device_name;
245 /* this allows subsequent calls to 'InitJoysticks' for re-initialization */
246 if (stored_player[i].joystick_fd != -1)
248 close(stored_player[i].joystick_fd);
249 stored_player[i].joystick_fd = -1;
252 if (!setup.input[i].use_joystick)
255 if (access(device_name, R_OK) != 0)
257 Error(ERR_WARN, "cannot access joystick device '%s'", device_name);
261 if ((stored_player[i].joystick_fd = open(device_name, O_RDONLY)) < 0)
263 Error(ERR_WARN, "cannot open joystick device '%s'", device_name);
267 joystick_status = JOYSTICK_AVAILABLE;
272 /* try to access two joysticks; if that fails, try to access just one */
273 if (install_joystick(JOY_TYPE_2PADS) == 0 ||
274 install_joystick(JOY_TYPE_AUTODETECT) == 0)
275 joystick_status = JOYSTICK_AVAILABLE;
278 load_joystick_data(JOYSTICK_FILENAME);
281 for (i=0; i<MAX_PLAYERS; i++)
283 char *device_name = setup.input[i].joy.device_name;
284 int joystick_nr = getJoystickNrFromDeviceName(device_name);
286 if (joystick_nr >= num_joysticks)
289 /* misuse joystick file descriptor variable to store joystick number */
290 stored_player[i].joystick_fd = joystick_nr;
298 XVisualInfo vinfo_template, *vinfo;
303 /* connect to X server */
304 if (!(display = XOpenDisplay(options.display_name)))
305 Error(ERR_EXIT, "cannot connect to X server %s",
306 XDisplayName(options.display_name));
308 screen = DefaultScreen(display);
309 visual = DefaultVisual(display, screen);
310 depth = DefaultDepth(display, screen);
311 cmap = DefaultColormap(display, screen);
314 /* look for good enough visual */
315 vinfo_template.screen = screen;
316 vinfo_template.class = (depth == 8 ? PseudoColor : TrueColor);
317 vinfo_template.depth = depth;
318 if ((vinfo = XGetVisualInfo(display, VisualScreenMask | VisualClassMask |
319 VisualDepthMask, &vinfo_template, &num_visuals)))
321 visual = vinfo->visual;
322 XFree((void *)vinfo);
325 /* got appropriate visual? */
328 printf("Sorry, displays with less than 8 bits per pixel not supported.\n");
331 else if ((depth ==8 && visual->class != PseudoColor) ||
332 (depth > 8 && visual->class != TrueColor &&
333 visual->class != DirectColor))
335 printf("Sorry, cannot get appropriate visual.\n");
341 void InitWindow(int argc, char *argv[])
343 unsigned int border_width = 4;
345 unsigned long gc_valuemask;
347 XTextProperty windowName, iconName;
348 Pixmap icon_pixmap, iconmask_pixmap;
349 unsigned int icon_width, icon_height;
350 int icon_hot_x, icon_hot_y;
351 char icon_filename[256];
352 XSizeHints size_hints;
354 XClassHint class_hints;
355 char *window_name = WINDOW_TITLE_STRING;
356 char *icon_name = WINDOW_TITLE_STRING;
357 long window_event_mask;
358 Atom proto_atom = None, delete_atom = None;
360 int screen_width, screen_height;
361 int win_xpos = WIN_XPOS, win_ypos = WIN_YPOS;
362 unsigned long pen_fg = WhitePixel(display,screen);
363 unsigned long pen_bg = BlackPixel(display,screen);
364 const int width = WIN_XSIZE, height = WIN_YSIZE;
367 static struct IconFileInfo icon_pic =
374 screen_width = XDisplayWidth(display, screen);
375 screen_height = XDisplayHeight(display, screen);
377 win_xpos = (screen_width - width) / 2;
378 win_ypos = (screen_height - height) / 2;
380 window = XCreateSimpleWindow(display, RootWindow(display, screen),
381 win_xpos, win_ypos, width, height, border_width,
385 proto_atom = XInternAtom(display, "WM_PROTOCOLS", FALSE);
386 delete_atom = XInternAtom(display, "WM_DELETE_WINDOW", FALSE);
387 if ((proto_atom != None) && (delete_atom != None))
388 XChangeProperty(display, window, proto_atom, XA_ATOM, 32,
389 PropModePrepend, (unsigned char *) &delete_atom, 1);
391 sprintf(icon_filename, "%s/%s/%s",
392 options.ro_base_directory, GRAPHICS_DIRECTORY,
393 icon_pic.picture_filename);
394 XReadBitmapFile(display,window,icon_filename,
395 &icon_width,&icon_height,
396 &icon_pixmap,&icon_hot_x,&icon_hot_y);
398 Error(ERR_EXIT, "cannot read icon bitmap file '%s'", icon_filename);
400 sprintf(icon_filename, "%s/%s/%s",
401 options.ro_base_directory, GRAPHICS_DIRECTORY,
402 icon_pic.picturemask_filename);
403 XReadBitmapFile(display,window,icon_filename,
404 &icon_width,&icon_height,
405 &iconmask_pixmap,&icon_hot_x,&icon_hot_y);
406 if (!iconmask_pixmap)
407 Error(ERR_EXIT, "cannot read icon bitmap file '%s'", icon_filename);
409 size_hints.width = size_hints.min_width = size_hints.max_width = width;
410 size_hints.height = size_hints.min_height = size_hints.max_height = height;
411 size_hints.flags = PSize | PMinSize | PMaxSize;
413 if (win_xpos || win_ypos)
415 size_hints.x = win_xpos;
416 size_hints.y = win_ypos;
417 size_hints.flags |= PPosition;
420 if (!XStringListToTextProperty(&window_name, 1, &windowName))
421 Error(ERR_EXIT, "structure allocation for windowName failed");
423 if (!XStringListToTextProperty(&icon_name, 1, &iconName))
424 Error(ERR_EXIT, "structure allocation for iconName failed");
426 wm_hints.initial_state = NormalState;
427 wm_hints.input = True;
428 wm_hints.icon_pixmap = icon_pixmap;
429 wm_hints.icon_mask = iconmask_pixmap;
430 wm_hints.flags = StateHint | IconPixmapHint | IconMaskHint | InputHint;
432 class_hints.res_name = program_name;
433 class_hints.res_class = "Rocks'n'Diamonds";
435 XSetWMProperties(display, window, &windowName, &iconName,
436 argv, argc, &size_hints, &wm_hints,
439 XFree(windowName.value);
440 XFree(iconName.value);
442 /* Select event types wanted */
444 ExposureMask | StructureNotifyMask | FocusChangeMask |
445 ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
446 PointerMotionHintMask | KeyPressMask | KeyReleaseMask;
448 XSelectInput(display, window, window_event_mask);
451 /* create GC for drawing with window depth */
452 gc_values.graphics_exposures = False;
453 gc_values.foreground = pen_bg;
454 gc_values.background = pen_bg;
455 gc_valuemask = GCGraphicsExposures | GCForeground | GCBackground;
456 gc = XCreateGC(display, window, gc_valuemask, &gc_values);
459 void DrawInitText(char *text, int ypos, int color)
461 if (display && window && pix[PIX_SMALLFONT])
463 XFillRectangle(display,window,gc,0,ypos, WIN_XSIZE,FONT2_YSIZE);
464 DrawTextExt(window,gc,(WIN_XSIZE-strlen(text)*FONT2_XSIZE)/2,
465 ypos,text,FS_SMALL,color);
474 XGCValues clip_gc_values;
475 unsigned long clip_gc_valuemask;
478 static struct PictureFileInfo pic[NUM_PICTURES] =
490 static struct PictureFileInfo pic[NUM_PICTURES] =
492 { "RocksScreen", TRUE },
493 { "RocksDoor", TRUE },
494 { "RocksHeroes", TRUE },
495 { "RocksToons", TRUE },
498 { "RocksFont", FALSE },
499 { "RocksFont2", FALSE }
505 static struct PictureFileInfo test_pic1 =
510 static struct PictureFileInfo test_pic2 =
523 tile_needs_clipping[] =
525 { GFX_SPIELER1_UP, 4 },
526 { GFX_SPIELER1_DOWN, 4 },
527 { GFX_SPIELER1_LEFT, 4 },
528 { GFX_SPIELER1_RIGHT, 4 },
529 { GFX_SPIELER1_PUSH_LEFT, 4 },
530 { GFX_SPIELER1_PUSH_RIGHT, 4 },
531 { GFX_SPIELER2_UP, 4 },
532 { GFX_SPIELER2_DOWN, 4 },
533 { GFX_SPIELER2_LEFT, 4 },
534 { GFX_SPIELER2_RIGHT, 4 },
535 { GFX_SPIELER2_PUSH_LEFT, 4 },
536 { GFX_SPIELER2_PUSH_RIGHT, 4 },
537 { GFX_SPIELER3_UP, 4 },
538 { GFX_SPIELER3_DOWN, 4 },
539 { GFX_SPIELER3_LEFT, 4 },
540 { GFX_SPIELER3_RIGHT, 4 },
541 { GFX_SPIELER3_PUSH_LEFT, 4 },
542 { GFX_SPIELER3_PUSH_RIGHT, 4 },
543 { GFX_SPIELER4_UP, 4 },
544 { GFX_SPIELER4_DOWN, 4 },
545 { GFX_SPIELER4_LEFT, 4 },
546 { GFX_SPIELER4_RIGHT, 4 },
547 { GFX_SPIELER4_PUSH_LEFT, 4 },
548 { GFX_SPIELER4_PUSH_RIGHT, 4 },
549 { GFX_SP_MURPHY, 1 },
550 { GFX_MURPHY_GO_LEFT, 3 },
551 { GFX_MURPHY_GO_RIGHT, 3 },
552 { GFX_MURPHY_SNAP_UP, 1 },
553 { GFX_MURPHY_SNAP_DOWN, 1 },
554 { GFX_MURPHY_SNAP_RIGHT, 1 },
555 { GFX_MURPHY_SNAP_LEFT, 1 },
556 { GFX_MURPHY_PUSH_RIGHT, 1 },
557 { GFX_MURPHY_PUSH_LEFT, 1 },
558 { GFX_GEBLUBBER, 4 },
561 { GFX_EXPLOSION, 8 },
562 { GFX_SOKOBAN_OBJEKT, 1 },
563 { GFX_FUNKELN_BLAU, 3 },
564 { GFX_FUNKELN_WEISS, 3 },
565 { GFX2_SHIELD_PASSIVE, 3 },
566 { GFX2_SHIELD_ACTIVE, 3 },
571 debug_print_timestamp(0, NULL); /* initialize timestamp function */
576 printf("Test: Loading RocksFont2.pcx ...\n");
577 LoadGfx(PIX_SMALLFONT,&test_pic1);
578 printf("Test: Done.\n");
579 printf("Test: Loading mouse.pcx ...\n");
580 LoadGfx(PIX_SMALLFONT,&test_pic2);
581 printf("Test: Done.\n");
587 LoadGfx(PIX_SMALLFONT,&pic[PIX_SMALLFONT]);
588 DrawInitText(WINDOW_TITLE_STRING,20,FC_YELLOW);
589 DrawInitText(COPYRIGHT_STRING,50,FC_RED);
591 DrawInitText("MSDOS version done by Guido Schulz",210,FC_BLUE);
594 DrawInitText("Loading graphics:",120,FC_GREEN);
596 for(i=0; i<NUM_PICTURES; i++)
597 if (i != PIX_SMALLFONT)
601 debug_print_timestamp(0, "SUMMARY LOADING ALL GRAPHICS:");
604 pix[PIX_DB_BACK] = XCreatePixmap(display, window,
606 XDefaultDepth(display,screen));
607 pix[PIX_DB_DOOR] = XCreatePixmap(display, window,
608 3*DXSIZE,DYSIZE+VYSIZE,
609 XDefaultDepth(display,screen));
610 pix[PIX_DB_FIELD] = XCreatePixmap(display, window,
612 XDefaultDepth(display,screen));
614 clip_gc_values.graphics_exposures = False;
615 clip_gc_valuemask = GCGraphicsExposures;
617 XCreateGC(display,clipmask[PIX_BACK],clip_gc_valuemask,&clip_gc_values);
619 clip_gc_values.graphics_exposures = False;
620 clip_gc_valuemask = GCGraphicsExposures;
622 XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
624 /* initialize pixmap array to Pixmap 'None' */
625 for(i=0; i<NUM_TILES; i++)
626 tile_clipmask[i] = None;
628 /* create only those clipping Pixmaps we really need */
629 for(i=0; tile_needs_clipping[i].start>=0; i++)
631 for(j=0; j<tile_needs_clipping[i].count; j++)
633 int tile = tile_needs_clipping[i].start + j;
639 getGraphicSource(graphic, &pixmap_nr, &src_x, &src_y);
640 src_pixmap = clipmask[pixmap_nr];
642 tile_clipmask[tile] = XCreatePixmap(display, window, TILEX,TILEY, 1);
644 XCopyArea(display,src_pixmap,tile_clipmask[tile],copy_clipmask_gc,
645 src_x,src_y, TILEX,TILEY, 0,0);
649 if (!pix[PIX_DB_BACK] || !pix[PIX_DB_DOOR])
650 Error(ERR_EXIT, "cannot create additional pixmaps");
652 for(i=0; i<NUM_PIXMAPS; i++)
656 clip_gc_values.graphics_exposures = False;
657 clip_gc_values.clip_mask = clipmask[i];
658 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
659 clip_gc[i] = XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
663 drawto = backbuffer = pix[PIX_DB_BACK];
664 fieldbuffer = pix[PIX_DB_FIELD];
665 SetDrawtoField(DRAW_BACKBUFFER);
667 XCopyArea(display,pix[PIX_BACK],backbuffer,gc,
668 0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
669 XFillRectangle(display,pix[PIX_DB_BACK],gc,
670 REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
671 XFillRectangle(display,pix[PIX_DB_DOOR],gc,
672 0,0, 3*DXSIZE,DYSIZE+VYSIZE);
674 for(i=0; i<MAX_BUF_XSIZE; i++)
675 for(j=0; j<MAX_BUF_YSIZE; j++)
678 redraw_mask = REDRAW_ALL;
681 void LoadGfx(int pos, struct PictureFileInfo *pic)
683 char basefilename[256];
686 #ifdef USE_XPM_LIBRARY
687 int xpm_err, xbm_err;
688 unsigned int width,height;
691 char *picture_ext = ".xpm";
692 char *picturemask_ext = "Mask.xbm";
695 char *picture_ext = ".pcx";
699 if (pic->picture_filename)
701 sprintf(basefilename, "%s%s", pic->picture_filename, picture_ext);
702 DrawInitText(basefilename, 150, FC_YELLOW);
703 sprintf(filename, "%s/%s/%s",
704 options.ro_base_directory, GRAPHICS_DIRECTORY, basefilename);
711 debug_print_timestamp(1, NULL); /* initialize timestamp function */
714 #ifdef USE_XPM_LIBRARY
716 xpm_att[pos].valuemask = XpmCloseness;
717 xpm_att[pos].closeness = 20000;
718 xpm_err = XpmReadFileToPixmap(display,window,filename,
719 &pix[pos],&shapemask,&xpm_att[pos]);
723 Error(ERR_EXIT, "cannot open XPM file '%s'", filename);
725 Error(ERR_EXIT, "invalid XPM file '%s'", filename);
727 Error(ERR_EXIT, "not enough memory for XPM file '%s'", filename);
729 Error(ERR_EXIT, "cannot get colors for XPM file '%s'", filename);
735 printf("LOADING XPM FILE %s:", filename);
736 debug_print_timestamp(1, "");
739 #else /* !USE_XPM_LIBRARY */
741 pcx_err = Read_PCX_to_Pixmap(display, window, gc, filename,
742 &pix[pos], &clipmask[pos]);
748 Error(ERR_EXIT, "cannot open PCX file '%s'", filename);
750 Error(ERR_EXIT, "cannot read PCX file '%s'", filename);
751 case PCX_FileInvalid:
752 Error(ERR_EXIT, "invalid PCX file '%s'", filename);
754 Error(ERR_EXIT, "not enough memory for PCX file '%s'", filename);
755 case PCX_ColorFailed:
756 Error(ERR_EXIT, "cannot get colors for PCX file '%s'", filename);
762 printf("SUMMARY LOADING PCX FILE %s:", filename);
763 debug_print_timestamp(1, "");
766 #endif /* !USE_XPM_LIBRARY */
769 Error(ERR_EXIT, "cannot get graphics for '%s'", pic->picture_filename);
772 /* zugehörige Maske laden (wenn vorhanden) */
773 if (pic->picture_with_mask)
775 #ifdef USE_XPM_LIBRARY
777 sprintf(basefilename, "%s%s", pic->picture_filename, picturemask_ext);
778 DrawInitText(basefilename, 150, FC_YELLOW);
779 sprintf(filename, "%s/%s/%s",
780 options.ro_base_directory, GRAPHICS_DIRECTORY, basefilename);
783 debug_print_timestamp(1, NULL); /* initialize timestamp function */
786 xbm_err = XReadBitmapFile(display,window,filename,
787 &width,&height,&clipmask[pos],&hot_x,&hot_y);
792 case BitmapOpenFailed:
793 Error(ERR_EXIT, "cannot open XBM file '%s'", filename);
794 case BitmapFileInvalid:
795 Error(ERR_EXIT, "invalid XBM file '%s'", filename);
797 Error(ERR_EXIT, "not enough memory for XBM file '%s'", filename);
804 printf("LOADING XBM FILE %s:", filename);
805 debug_print_timestamp(1, "");
808 #endif /* USE_XPM_LIBRARY */
811 Error(ERR_EXIT, "cannot get clipmask for '%s'", pic->picture_filename);
817 CreateLevelEditorGadgets();
823 void InitElementProperties()
827 static int ep_amoebalive[] =
834 static int ep_amoebalive_num = sizeof(ep_amoebalive)/sizeof(int);
836 static int ep_amoeboid[] =
844 static int ep_amoeboid_num = sizeof(ep_amoeboid)/sizeof(int);
846 static int ep_schluessel[] =
857 static int ep_schluessel_num = sizeof(ep_schluessel)/sizeof(int);
859 static int ep_pforte[] =
878 EL_SWITCHGATE_CLOSED,
882 static int ep_pforte_num = sizeof(ep_pforte)/sizeof(int);
884 static int ep_solid[] =
937 EL_BELT1_SWITCH_LEFT,
938 EL_BELT1_SWITCH_MIDDLE,
939 EL_BELT1_SWITCH_RIGHT,
940 EL_BELT2_SWITCH_LEFT,
941 EL_BELT2_SWITCH_MIDDLE,
942 EL_BELT2_SWITCH_RIGHT,
943 EL_BELT3_SWITCH_LEFT,
944 EL_BELT3_SWITCH_MIDDLE,
945 EL_BELT3_SWITCH_RIGHT,
946 EL_BELT4_SWITCH_LEFT,
947 EL_BELT4_SWITCH_MIDDLE,
948 EL_BELT4_SWITCH_RIGHT,
949 EL_SWITCHGATE_SWITCH_1,
950 EL_SWITCHGATE_SWITCH_2,
953 EL_TIMEGATE_SWITCH_OFF,
954 EL_TIMEGATE_SWITCH_ON,
956 EL_SIGN_RADIOACTIVITY,
969 static int ep_solid_num = sizeof(ep_solid)/sizeof(int);
971 static int ep_massive[] =
997 EL_SWITCHGATE_CLOSED,
1012 EL_BELT1_SWITCH_LEFT,
1013 EL_BELT1_SWITCH_MIDDLE,
1014 EL_BELT1_SWITCH_RIGHT,
1015 EL_BELT2_SWITCH_LEFT,
1016 EL_BELT2_SWITCH_MIDDLE,
1017 EL_BELT2_SWITCH_RIGHT,
1018 EL_BELT3_SWITCH_LEFT,
1019 EL_BELT3_SWITCH_MIDDLE,
1020 EL_BELT3_SWITCH_RIGHT,
1021 EL_BELT4_SWITCH_LEFT,
1022 EL_BELT4_SWITCH_MIDDLE,
1023 EL_BELT4_SWITCH_RIGHT,
1024 EL_LIGHT_SWITCH_OFF,
1026 EL_SIGN_EXCLAMATION,
1027 EL_SIGN_RADIOACTIVITY,
1040 static int ep_massive_num = sizeof(ep_massive)/sizeof(int);
1042 static int ep_slippery[] =
1073 static int ep_slippery_num = sizeof(ep_slippery)/sizeof(int);
1075 static int ep_enemy[] =
1088 static int ep_enemy_num = sizeof(ep_enemy)/sizeof(int);
1090 static int ep_mauer[] =
1140 static int ep_mauer_num = sizeof(ep_mauer)/sizeof(int);
1142 static int ep_can_fall[] =
1163 static int ep_can_fall_num = sizeof(ep_can_fall)/sizeof(int);
1165 static int ep_can_smash[] =
1191 static int ep_can_smash_num = sizeof(ep_can_smash)/sizeof(int);
1193 static int ep_can_change[] =
1203 static int ep_can_change_num = sizeof(ep_can_change)/sizeof(int);
1205 static int ep_can_move[] =
1223 static int ep_can_move_num = sizeof(ep_can_move)/sizeof(int);
1225 static int ep_could_move[] =
1248 static int ep_could_move_num = sizeof(ep_could_move)/sizeof(int);
1250 static int ep_dont_touch[] =
1257 static int ep_dont_touch_num = sizeof(ep_dont_touch)/sizeof(int);
1259 static int ep_dont_go_to[] =
1276 static int ep_dont_go_to_num = sizeof(ep_dont_go_to)/sizeof(int);
1278 static int ep_mampf2[] =
1301 static int ep_mampf2_num = sizeof(ep_mampf2)/sizeof(int);
1303 static int ep_bd_element[] =
1328 static int ep_bd_element_num = sizeof(ep_bd_element)/sizeof(int);
1330 static int ep_sb_element[] =
1335 EL_SOKOBAN_FELD_LEER,
1336 EL_SOKOBAN_FELD_VOLL,
1340 static int ep_sb_element_num = sizeof(ep_sb_element)/sizeof(int);
1342 static int ep_gem[] =
1352 static int ep_gem_num = sizeof(ep_gem)/sizeof(int);
1354 static int ep_inactive[] =
1390 EL_DYNAMITE_INACTIVE,
1402 EL_SOKOBAN_FELD_LEER,
1403 EL_SOKOBAN_FELD_VOLL,
1450 EL_BELT1_SWITCH_LEFT,
1451 EL_BELT1_SWITCH_MIDDLE,
1452 EL_BELT1_SWITCH_RIGHT,
1453 EL_BELT2_SWITCH_LEFT,
1454 EL_BELT2_SWITCH_MIDDLE,
1455 EL_BELT2_SWITCH_RIGHT,
1456 EL_BELT3_SWITCH_LEFT,
1457 EL_BELT3_SWITCH_MIDDLE,
1458 EL_BELT3_SWITCH_RIGHT,
1459 EL_BELT4_SWITCH_LEFT,
1460 EL_BELT4_SWITCH_MIDDLE,
1461 EL_BELT4_SWITCH_RIGHT,
1462 EL_SIGN_EXCLAMATION,
1463 EL_SIGN_RADIOACTIVITY,
1476 static int ep_inactive_num = sizeof(ep_inactive)/sizeof(int);
1478 static int ep_explosive[] =
1482 EL_DYNAMITE_INACTIVE,
1483 EL_DYNABOMB_ACTIVE_1,
1484 EL_DYNABOMB_ACTIVE_2,
1485 EL_DYNABOMB_ACTIVE_3,
1486 EL_DYNABOMB_ACTIVE_4,
1502 static int ep_explosive_num = sizeof(ep_explosive)/sizeof(int);
1504 static int ep_mampf3[] =
1513 static int ep_mampf3_num = sizeof(ep_mampf3)/sizeof(int);
1515 static int ep_pushable[] =
1521 EL_SOKOBAN_FELD_VOLL,
1528 static int ep_pushable_num = sizeof(ep_pushable)/sizeof(int);
1530 static int ep_player[] =
1538 static int ep_player_num = sizeof(ep_player)/sizeof(int);
1540 static int ep_has_content[] =
1548 static int ep_has_content_num = sizeof(ep_has_content)/sizeof(int);
1550 static int ep_eatable[] =
1557 static int ep_eatable_num = sizeof(ep_eatable)/sizeof(int);
1559 static int ep_sp_element[] =
1601 /* additional elements that appeared in newer Supaplex levels */
1604 static int ep_sp_element_num = sizeof(ep_sp_element)/sizeof(int);
1606 static int ep_quick_gate[] =
1630 static int ep_quick_gate_num = sizeof(ep_quick_gate)/sizeof(int);
1632 static int ep_over_player[] =
1646 static int ep_over_player_num = sizeof(ep_over_player)/sizeof(int);
1648 static int ep_active_bomb[] =
1651 EL_DYNABOMB_ACTIVE_1,
1652 EL_DYNABOMB_ACTIVE_2,
1653 EL_DYNABOMB_ACTIVE_3,
1654 EL_DYNABOMB_ACTIVE_4
1656 static int ep_active_bomb_num = sizeof(ep_active_bomb)/sizeof(int);
1658 static int ep_belt[] =
1673 static int ep_belt_num = sizeof(ep_belt)/sizeof(int);
1675 static int ep_belt_switch[] =
1677 EL_BELT1_SWITCH_LEFT,
1678 EL_BELT1_SWITCH_MIDDLE,
1679 EL_BELT1_SWITCH_RIGHT,
1680 EL_BELT2_SWITCH_LEFT,
1681 EL_BELT2_SWITCH_MIDDLE,
1682 EL_BELT2_SWITCH_RIGHT,
1683 EL_BELT3_SWITCH_LEFT,
1684 EL_BELT3_SWITCH_MIDDLE,
1685 EL_BELT3_SWITCH_RIGHT,
1686 EL_BELT4_SWITCH_LEFT,
1687 EL_BELT4_SWITCH_MIDDLE,
1688 EL_BELT4_SWITCH_RIGHT,
1690 static int ep_belt_switch_num = sizeof(ep_belt_switch)/sizeof(int);
1692 static long ep1_bit[] =
1726 static long ep2_bit[] =
1731 static int *ep1_array[] =
1765 static int *ep2_array[] =
1770 static int *ep1_num[] =
1797 &ep_has_content_num,
1801 &ep_over_player_num,
1804 static int *ep2_num[] =
1809 static int num_properties1 = sizeof(ep1_num)/sizeof(int *);
1810 static int num_properties2 = sizeof(ep2_num)/sizeof(int *);
1812 for(i=0; i<MAX_ELEMENTS; i++)
1814 Elementeigenschaften1[i] = 0;
1815 Elementeigenschaften2[i] = 0;
1818 for(i=0; i<num_properties1; i++)
1819 for(j=0; j<*(ep1_num[i]); j++)
1820 Elementeigenschaften1[(ep1_array[i])[j]] |= ep1_bit[i];
1821 for(i=0; i<num_properties2; i++)
1822 for(j=0; j<*(ep2_num[i]); j++)
1823 Elementeigenschaften2[(ep2_array[i])[j]] |= ep2_bit[i];
1825 for(i=EL_CHAR_START; i<EL_CHAR_END; i++)
1826 Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
1829 void CloseAllAndExit(int exit_value)
1833 if (sound_process_id)
1836 kill(sound_process_id, SIGTERM);
1837 FreeSounds(NUM_SOUNDS);
1840 for(i=0; i<NUM_PIXMAPS; i++)
1844 #ifdef USE_XPM_LIBRARY
1845 if (i < NUM_PICTURES) /* XPM pictures */
1847 XFreeColors(display,DefaultColormap(display,screen),
1848 xpm_att[i].pixels,xpm_att[i].npixels,0);
1849 XpmFreeAttributes(&xpm_att[i]);
1852 XFreePixmap(display,pix[i]);
1855 XFreePixmap(display,clipmask[i]);
1857 XFreeGC(display, clip_gc[i]);
1861 XFreeGC(display, gc);
1865 XAutoRepeatOn(display);
1866 XCloseDisplay(display);