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(); /* info about last played level */
112 void InitNetworkServer()
118 if (!options.network)
122 nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
124 if (!ConnectToServer(options.server_host, options.server_port))
125 Error(ERR_EXIT, "cannot connect to network game server");
127 SendToServer_PlayerName(setup.player_name);
128 SendToServer_ProtocolVersion();
131 SendToServer_NrWanted(nr_wanted);
139 if (sound_status == SOUND_OFF)
143 if (access(sound_device_name, W_OK) != 0)
145 Error(ERR_WARN, "cannot access sound device - no sounds");
146 sound_status = SOUND_OFF;
150 if ((sound_device = open(sound_device_name,O_WRONLY))<0)
152 Error(ERR_WARN, "cannot open sound device - no sounds");
153 sound_status = SOUND_OFF;
158 sound_status = SOUND_AVAILABLE;
161 sound_loops_allowed = TRUE;
164 setup.sound_loops_on = TRUE;
169 sound_loops_allowed = TRUE;
172 setup.sound_loops_on = TRUE;
177 for(i=0; i<NUM_SOUNDS; i++)
180 sprintf(sound_name[i], "%d", i + 1);
183 Sound[i].name = sound_name[i];
184 if (!LoadSound(&Sound[i]))
186 sound_status = SOUND_OFF;
192 void InitSoundServer()
194 if (sound_status == SOUND_OFF)
199 if (pipe(sound_pipe)<0)
201 Error(ERR_WARN, "cannot create pipe - no sounds");
202 sound_status = SOUND_OFF;
206 if ((sound_process_id = fork()) < 0)
208 Error(ERR_WARN, "cannot create sound server process - no sounds");
209 sound_status = SOUND_OFF;
213 if (!sound_process_id) /* we are child */
220 else /* we are parent */
221 close(sound_pipe[0]); /* no reading from pipe needed */
234 if (global_joystick_status == JOYSTICK_OFF)
237 joystick_status = JOYSTICK_OFF;
240 for (i=0; i<MAX_PLAYERS; i++)
242 char *device_name = setup.input[i].joy.device_name;
244 /* this allows subsequent calls to 'InitJoysticks' for re-initialization */
245 if (stored_player[i].joystick_fd != -1)
247 close(stored_player[i].joystick_fd);
248 stored_player[i].joystick_fd = -1;
251 if (!setup.input[i].use_joystick)
254 if (access(device_name, R_OK) != 0)
256 Error(ERR_WARN, "cannot access joystick device '%s'", device_name);
260 if ((stored_player[i].joystick_fd = open(device_name, O_RDONLY)) < 0)
262 Error(ERR_WARN, "cannot open joystick device '%s'", device_name);
266 joystick_status = JOYSTICK_AVAILABLE;
271 /* try to access two joysticks; if that fails, try to access just one */
272 if (install_joystick(JOY_TYPE_2PADS) == 0 ||
273 install_joystick(JOY_TYPE_AUTODETECT) == 0)
274 joystick_status = JOYSTICK_AVAILABLE;
277 load_joystick_data(JOYSTICK_FILENAME);
280 for (i=0; i<MAX_PLAYERS; i++)
282 char *device_name = setup.input[i].joy.device_name;
283 int joystick_nr = getJoystickNrFromDeviceName(device_name);
285 if (joystick_nr >= num_joysticks)
288 /* misuse joystick file descriptor variable to store joystick number */
289 stored_player[i].joystick_fd = joystick_nr;
297 XVisualInfo vinfo_template, *vinfo;
302 /* connect to X server */
303 if (!(display = XOpenDisplay(options.display_name)))
304 Error(ERR_EXIT, "cannot connect to X server %s",
305 XDisplayName(options.display_name));
307 screen = DefaultScreen(display);
308 visual = DefaultVisual(display, screen);
309 depth = DefaultDepth(display, screen);
310 cmap = DefaultColormap(display, screen);
313 /* look for good enough visual */
314 vinfo_template.screen = screen;
315 vinfo_template.class = (depth == 8 ? PseudoColor : TrueColor);
316 vinfo_template.depth = depth;
317 if ((vinfo = XGetVisualInfo(display, VisualScreenMask | VisualClassMask |
318 VisualDepthMask, &vinfo_template, &num_visuals)))
320 visual = vinfo->visual;
321 XFree((void *)vinfo);
324 /* got appropriate visual? */
327 printf("Sorry, displays with less than 8 bits per pixel not supported.\n");
330 else if ((depth ==8 && visual->class != PseudoColor) ||
331 (depth > 8 && visual->class != TrueColor &&
332 visual->class != DirectColor))
334 printf("Sorry, cannot get appropriate visual.\n");
340 void InitWindow(int argc, char *argv[])
342 unsigned int border_width = 4;
344 unsigned long gc_valuemask;
346 XTextProperty windowName, iconName;
347 Pixmap icon_pixmap, iconmask_pixmap;
348 unsigned int icon_width, icon_height;
349 int icon_hot_x, icon_hot_y;
350 char icon_filename[256];
351 XSizeHints size_hints;
353 XClassHint class_hints;
354 char *window_name = WINDOW_TITLE_STRING;
355 char *icon_name = WINDOW_TITLE_STRING;
356 long window_event_mask;
357 Atom proto_atom = None, delete_atom = None;
359 int screen_width, screen_height;
360 int win_xpos = WIN_XPOS, win_ypos = WIN_YPOS;
361 unsigned long pen_fg = WhitePixel(display,screen);
362 unsigned long pen_bg = BlackPixel(display,screen);
363 const int width = WIN_XSIZE, height = WIN_YSIZE;
366 static struct IconFileInfo icon_pic =
373 screen_width = XDisplayWidth(display, screen);
374 screen_height = XDisplayHeight(display, screen);
376 win_xpos = (screen_width - width) / 2;
377 win_ypos = (screen_height - height) / 2;
379 window = XCreateSimpleWindow(display, RootWindow(display, screen),
380 win_xpos, win_ypos, width, height, border_width,
384 proto_atom = XInternAtom(display, "WM_PROTOCOLS", FALSE);
385 delete_atom = XInternAtom(display, "WM_DELETE_WINDOW", FALSE);
386 if ((proto_atom != None) && (delete_atom != None))
387 XChangeProperty(display, window, proto_atom, XA_ATOM, 32,
388 PropModePrepend, (unsigned char *) &delete_atom, 1);
390 sprintf(icon_filename, "%s/%s/%s",
391 options.ro_base_directory, GRAPHICS_DIRECTORY,
392 icon_pic.picture_filename);
393 XReadBitmapFile(display,window,icon_filename,
394 &icon_width,&icon_height,
395 &icon_pixmap,&icon_hot_x,&icon_hot_y);
397 Error(ERR_EXIT, "cannot read icon bitmap file '%s'", icon_filename);
399 sprintf(icon_filename, "%s/%s/%s",
400 options.ro_base_directory, GRAPHICS_DIRECTORY,
401 icon_pic.picturemask_filename);
402 XReadBitmapFile(display,window,icon_filename,
403 &icon_width,&icon_height,
404 &iconmask_pixmap,&icon_hot_x,&icon_hot_y);
405 if (!iconmask_pixmap)
406 Error(ERR_EXIT, "cannot read icon bitmap file '%s'", icon_filename);
408 size_hints.width = size_hints.min_width = size_hints.max_width = width;
409 size_hints.height = size_hints.min_height = size_hints.max_height = height;
410 size_hints.flags = PSize | PMinSize | PMaxSize;
412 if (win_xpos || win_ypos)
414 size_hints.x = win_xpos;
415 size_hints.y = win_ypos;
416 size_hints.flags |= PPosition;
419 if (!XStringListToTextProperty(&window_name, 1, &windowName))
420 Error(ERR_EXIT, "structure allocation for windowName failed");
422 if (!XStringListToTextProperty(&icon_name, 1, &iconName))
423 Error(ERR_EXIT, "structure allocation for iconName failed");
425 wm_hints.initial_state = NormalState;
426 wm_hints.input = True;
427 wm_hints.icon_pixmap = icon_pixmap;
428 wm_hints.icon_mask = iconmask_pixmap;
429 wm_hints.flags = StateHint | IconPixmapHint | IconMaskHint | InputHint;
431 class_hints.res_name = program_name;
432 class_hints.res_class = "Rocks'n'Diamonds";
434 XSetWMProperties(display, window, &windowName, &iconName,
435 argv, argc, &size_hints, &wm_hints,
438 XFree(windowName.value);
439 XFree(iconName.value);
441 /* Select event types wanted */
443 ExposureMask | StructureNotifyMask | FocusChangeMask |
444 ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
445 PointerMotionHintMask | KeyPressMask | KeyReleaseMask;
447 XSelectInput(display, window, window_event_mask);
450 /* create GC for drawing with window depth */
451 gc_values.graphics_exposures = False;
452 gc_values.foreground = pen_bg;
453 gc_values.background = pen_bg;
454 gc_valuemask = GCGraphicsExposures | GCForeground | GCBackground;
455 gc = XCreateGC(display, window, gc_valuemask, &gc_values);
458 void DrawInitText(char *text, int ypos, int color)
460 if (display && window && pix[PIX_SMALLFONT])
462 XFillRectangle(display,window,gc,0,ypos, WIN_XSIZE,FONT2_YSIZE);
463 DrawTextExt(window,gc,(WIN_XSIZE-strlen(text)*FONT2_XSIZE)/2,
464 ypos,text,FS_SMALL,color);
473 XGCValues clip_gc_values;
474 unsigned long clip_gc_valuemask;
477 static struct PictureFileInfo pic[NUM_PICTURES] =
489 static struct PictureFileInfo pic[NUM_PICTURES] =
491 { "RocksScreen", TRUE },
492 { "RocksDoor", TRUE },
493 { "RocksHeroes", TRUE },
494 { "RocksToons", TRUE },
497 { "RocksFont", FALSE },
498 { "RocksFont2", FALSE }
504 static struct PictureFileInfo test_pic1 =
509 static struct PictureFileInfo test_pic2 =
522 tile_needs_clipping[] =
524 { GFX_SPIELER1_UP, 4 },
525 { GFX_SPIELER1_DOWN, 4 },
526 { GFX_SPIELER1_LEFT, 4 },
527 { GFX_SPIELER1_RIGHT, 4 },
528 { GFX_SPIELER1_PUSH_LEFT, 4 },
529 { GFX_SPIELER1_PUSH_RIGHT, 4 },
530 { GFX_SPIELER2_UP, 4 },
531 { GFX_SPIELER2_DOWN, 4 },
532 { GFX_SPIELER2_LEFT, 4 },
533 { GFX_SPIELER2_RIGHT, 4 },
534 { GFX_SPIELER2_PUSH_LEFT, 4 },
535 { GFX_SPIELER2_PUSH_RIGHT, 4 },
536 { GFX_SPIELER3_UP, 4 },
537 { GFX_SPIELER3_DOWN, 4 },
538 { GFX_SPIELER3_LEFT, 4 },
539 { GFX_SPIELER3_RIGHT, 4 },
540 { GFX_SPIELER3_PUSH_LEFT, 4 },
541 { GFX_SPIELER3_PUSH_RIGHT, 4 },
542 { GFX_SPIELER4_UP, 4 },
543 { GFX_SPIELER4_DOWN, 4 },
544 { GFX_SPIELER4_LEFT, 4 },
545 { GFX_SPIELER4_RIGHT, 4 },
546 { GFX_SPIELER4_PUSH_LEFT, 4 },
547 { GFX_SPIELER4_PUSH_RIGHT, 4 },
548 { GFX_SP_MURPHY, 1 },
549 { GFX_MURPHY_GO_LEFT, 3 },
550 { GFX_MURPHY_GO_RIGHT, 3 },
551 { GFX_MURPHY_SNAP_UP, 1 },
552 { GFX_MURPHY_SNAP_DOWN, 1 },
553 { GFX_MURPHY_SNAP_RIGHT, 1 },
554 { GFX_MURPHY_SNAP_LEFT, 1 },
555 { GFX_MURPHY_PUSH_RIGHT, 1 },
556 { GFX_MURPHY_PUSH_LEFT, 1 },
557 { GFX_GEBLUBBER, 4 },
560 { GFX_EXPLOSION, 8 },
561 { GFX_SOKOBAN_OBJEKT, 1 },
562 { GFX_FUNKELN_BLAU, 3 },
563 { GFX_FUNKELN_WEISS, 3 },
564 { GFX2_SHIELD_PASSIVE, 3 },
565 { GFX2_SHIELD_ACTIVE, 3 },
570 debug_print_timestamp(0, NULL); /* initialize timestamp function */
575 printf("Test: Loading RocksFont2.pcx ...\n");
576 LoadGfx(PIX_SMALLFONT,&test_pic1);
577 printf("Test: Done.\n");
578 printf("Test: Loading mouse.pcx ...\n");
579 LoadGfx(PIX_SMALLFONT,&test_pic2);
580 printf("Test: Done.\n");
586 LoadGfx(PIX_SMALLFONT,&pic[PIX_SMALLFONT]);
587 DrawInitText(WINDOW_TITLE_STRING,20,FC_YELLOW);
588 DrawInitText(COPYRIGHT_STRING,50,FC_RED);
590 DrawInitText("MSDOS version done by Guido Schulz",210,FC_BLUE);
593 DrawInitText("Loading graphics:",120,FC_GREEN);
595 for(i=0; i<NUM_PICTURES; i++)
596 if (i != PIX_SMALLFONT)
600 debug_print_timestamp(0, "SUMMARY LOADING ALL GRAPHICS:");
603 pix[PIX_DB_BACK] = XCreatePixmap(display, window,
605 XDefaultDepth(display,screen));
606 pix[PIX_DB_DOOR] = XCreatePixmap(display, window,
607 3*DXSIZE,DYSIZE+VYSIZE,
608 XDefaultDepth(display,screen));
609 pix[PIX_DB_FIELD] = XCreatePixmap(display, window,
611 XDefaultDepth(display,screen));
613 clip_gc_values.graphics_exposures = False;
614 clip_gc_valuemask = GCGraphicsExposures;
616 XCreateGC(display,clipmask[PIX_BACK],clip_gc_valuemask,&clip_gc_values);
618 clip_gc_values.graphics_exposures = False;
619 clip_gc_valuemask = GCGraphicsExposures;
621 XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
623 /* initialize pixmap array to Pixmap 'None' */
624 for(i=0; i<NUM_TILES; i++)
625 tile_clipmask[i] = None;
627 /* create only those clipping Pixmaps we really need */
628 for(i=0; tile_needs_clipping[i].start>=0; i++)
630 for(j=0; j<tile_needs_clipping[i].count; j++)
632 int tile = tile_needs_clipping[i].start + j;
638 getGraphicSource(graphic, &pixmap_nr, &src_x, &src_y);
639 src_pixmap = clipmask[pixmap_nr];
641 tile_clipmask[tile] = XCreatePixmap(display, window, TILEX,TILEY, 1);
643 XCopyArea(display,src_pixmap,tile_clipmask[tile],copy_clipmask_gc,
644 src_x,src_y, TILEX,TILEY, 0,0);
648 if (!pix[PIX_DB_BACK] || !pix[PIX_DB_DOOR])
649 Error(ERR_EXIT, "cannot create additional pixmaps");
651 for(i=0; i<NUM_PIXMAPS; i++)
655 clip_gc_values.graphics_exposures = False;
656 clip_gc_values.clip_mask = clipmask[i];
657 clip_gc_valuemask = GCGraphicsExposures | GCClipMask;
658 clip_gc[i] = XCreateGC(display,window,clip_gc_valuemask,&clip_gc_values);
662 drawto = backbuffer = pix[PIX_DB_BACK];
663 fieldbuffer = pix[PIX_DB_FIELD];
664 SetDrawtoField(DRAW_BACKBUFFER);
666 XCopyArea(display,pix[PIX_BACK],backbuffer,gc,
667 0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
668 XFillRectangle(display,pix[PIX_DB_BACK],gc,
669 REAL_SX,REAL_SY, FULL_SXSIZE,FULL_SYSIZE);
670 XFillRectangle(display,pix[PIX_DB_DOOR],gc,
671 0,0, 3*DXSIZE,DYSIZE+VYSIZE);
673 for(i=0; i<MAX_BUF_XSIZE; i++)
674 for(j=0; j<MAX_BUF_YSIZE; j++)
677 redraw_mask = REDRAW_ALL;
680 void LoadGfx(int pos, struct PictureFileInfo *pic)
682 char basefilename[256];
685 #ifdef USE_XPM_LIBRARY
686 int xpm_err, xbm_err;
687 unsigned int width,height;
690 char *picture_ext = ".xpm";
691 char *picturemask_ext = "Mask.xbm";
694 char *picture_ext = ".pcx";
698 if (pic->picture_filename)
700 sprintf(basefilename, "%s%s", pic->picture_filename, picture_ext);
701 DrawInitText(basefilename, 150, FC_YELLOW);
702 sprintf(filename, "%s/%s/%s",
703 options.ro_base_directory, GRAPHICS_DIRECTORY, basefilename);
710 debug_print_timestamp(1, NULL); /* initialize timestamp function */
713 #ifdef USE_XPM_LIBRARY
715 xpm_att[pos].valuemask = XpmCloseness;
716 xpm_att[pos].closeness = 20000;
717 xpm_err = XpmReadFileToPixmap(display,window,filename,
718 &pix[pos],&shapemask,&xpm_att[pos]);
722 Error(ERR_EXIT, "cannot open XPM file '%s'", filename);
724 Error(ERR_EXIT, "invalid XPM file '%s'", filename);
726 Error(ERR_EXIT, "not enough memory for XPM file '%s'", filename);
728 Error(ERR_EXIT, "cannot get colors for XPM file '%s'", filename);
734 printf("LOADING XPM FILE %s:", filename);
735 debug_print_timestamp(1, "");
738 #else /* !USE_XPM_LIBRARY */
740 pcx_err = Read_PCX_to_Pixmap(display, window, gc, filename,
741 &pix[pos], &clipmask[pos]);
747 Error(ERR_EXIT, "cannot open PCX file '%s'", filename);
749 Error(ERR_EXIT, "cannot read PCX file '%s'", filename);
750 case PCX_FileInvalid:
751 Error(ERR_EXIT, "invalid PCX file '%s'", filename);
753 Error(ERR_EXIT, "not enough memory for PCX file '%s'", filename);
754 case PCX_ColorFailed:
755 Error(ERR_EXIT, "cannot get colors for PCX file '%s'", filename);
761 printf("SUMMARY LOADING PCX FILE %s:", filename);
762 debug_print_timestamp(1, "");
765 #endif /* !USE_XPM_LIBRARY */
768 Error(ERR_EXIT, "cannot get graphics for '%s'", pic->picture_filename);
771 /* zugehörige Maske laden (wenn vorhanden) */
772 if (pic->picture_with_mask)
774 #ifdef USE_XPM_LIBRARY
776 sprintf(basefilename, "%s%s", pic->picture_filename, picturemask_ext);
777 DrawInitText(basefilename, 150, FC_YELLOW);
778 sprintf(filename, "%s/%s/%s",
779 options.ro_base_directory, GRAPHICS_DIRECTORY, basefilename);
782 debug_print_timestamp(1, NULL); /* initialize timestamp function */
785 xbm_err = XReadBitmapFile(display,window,filename,
786 &width,&height,&clipmask[pos],&hot_x,&hot_y);
791 case BitmapOpenFailed:
792 Error(ERR_EXIT, "cannot open XBM file '%s'", filename);
793 case BitmapFileInvalid:
794 Error(ERR_EXIT, "invalid XBM file '%s'", filename);
796 Error(ERR_EXIT, "not enough memory for XBM file '%s'", filename);
803 printf("LOADING XBM FILE %s:", filename);
804 debug_print_timestamp(1, "");
807 #endif /* USE_XPM_LIBRARY */
810 Error(ERR_EXIT, "cannot get clipmask for '%s'", pic->picture_filename);
816 CreateLevelEditorGadgets();
822 void InitElementProperties()
826 static int ep_amoebalive[] =
833 static int ep_amoebalive_num = sizeof(ep_amoebalive)/sizeof(int);
835 static int ep_amoeboid[] =
843 static int ep_amoeboid_num = sizeof(ep_amoeboid)/sizeof(int);
845 static int ep_schluessel[] =
856 static int ep_schluessel_num = sizeof(ep_schluessel)/sizeof(int);
858 static int ep_pforte[] =
877 EL_SWITCHGATE_CLOSED,
881 static int ep_pforte_num = sizeof(ep_pforte)/sizeof(int);
883 static int ep_solid[] =
936 EL_BELT1_SWITCH_LEFT,
937 EL_BELT1_SWITCH_MIDDLE,
938 EL_BELT1_SWITCH_RIGHT,
939 EL_BELT2_SWITCH_LEFT,
940 EL_BELT2_SWITCH_MIDDLE,
941 EL_BELT2_SWITCH_RIGHT,
942 EL_BELT3_SWITCH_LEFT,
943 EL_BELT3_SWITCH_MIDDLE,
944 EL_BELT3_SWITCH_RIGHT,
945 EL_BELT4_SWITCH_LEFT,
946 EL_BELT4_SWITCH_MIDDLE,
947 EL_BELT4_SWITCH_RIGHT,
948 EL_SWITCHGATE_SWITCH_1,
949 EL_SWITCHGATE_SWITCH_2,
952 EL_TIMEGATE_SWITCH_OFF,
953 EL_TIMEGATE_SWITCH_ON,
955 EL_SIGN_RADIOACTIVITY,
968 static int ep_solid_num = sizeof(ep_solid)/sizeof(int);
970 static int ep_massive[] =
996 EL_SWITCHGATE_CLOSED,
1011 EL_BELT1_SWITCH_LEFT,
1012 EL_BELT1_SWITCH_MIDDLE,
1013 EL_BELT1_SWITCH_RIGHT,
1014 EL_BELT2_SWITCH_LEFT,
1015 EL_BELT2_SWITCH_MIDDLE,
1016 EL_BELT2_SWITCH_RIGHT,
1017 EL_BELT3_SWITCH_LEFT,
1018 EL_BELT3_SWITCH_MIDDLE,
1019 EL_BELT3_SWITCH_RIGHT,
1020 EL_BELT4_SWITCH_LEFT,
1021 EL_BELT4_SWITCH_MIDDLE,
1022 EL_BELT4_SWITCH_RIGHT,
1023 EL_LIGHT_SWITCH_OFF,
1025 EL_SIGN_EXCLAMATION,
1026 EL_SIGN_RADIOACTIVITY,
1039 static int ep_massive_num = sizeof(ep_massive)/sizeof(int);
1041 static int ep_slippery[] =
1072 static int ep_slippery_num = sizeof(ep_slippery)/sizeof(int);
1074 static int ep_enemy[] =
1087 static int ep_enemy_num = sizeof(ep_enemy)/sizeof(int);
1089 static int ep_mauer[] =
1139 static int ep_mauer_num = sizeof(ep_mauer)/sizeof(int);
1141 static int ep_can_fall[] =
1162 static int ep_can_fall_num = sizeof(ep_can_fall)/sizeof(int);
1164 static int ep_can_smash[] =
1190 static int ep_can_smash_num = sizeof(ep_can_smash)/sizeof(int);
1192 static int ep_can_change[] =
1202 static int ep_can_change_num = sizeof(ep_can_change)/sizeof(int);
1204 static int ep_can_move[] =
1222 static int ep_can_move_num = sizeof(ep_can_move)/sizeof(int);
1224 static int ep_could_move[] =
1247 static int ep_could_move_num = sizeof(ep_could_move)/sizeof(int);
1249 static int ep_dont_touch[] =
1256 static int ep_dont_touch_num = sizeof(ep_dont_touch)/sizeof(int);
1258 static int ep_dont_go_to[] =
1275 static int ep_dont_go_to_num = sizeof(ep_dont_go_to)/sizeof(int);
1277 static int ep_mampf2[] =
1300 static int ep_mampf2_num = sizeof(ep_mampf2)/sizeof(int);
1302 static int ep_bd_element[] =
1327 static int ep_bd_element_num = sizeof(ep_bd_element)/sizeof(int);
1329 static int ep_sb_element[] =
1334 EL_SOKOBAN_FELD_LEER,
1335 EL_SOKOBAN_FELD_VOLL,
1339 static int ep_sb_element_num = sizeof(ep_sb_element)/sizeof(int);
1341 static int ep_gem[] =
1351 static int ep_gem_num = sizeof(ep_gem)/sizeof(int);
1353 static int ep_inactive[] =
1389 EL_DYNAMITE_INACTIVE,
1401 EL_SOKOBAN_FELD_LEER,
1402 EL_SOKOBAN_FELD_VOLL,
1449 EL_BELT1_SWITCH_LEFT,
1450 EL_BELT1_SWITCH_MIDDLE,
1451 EL_BELT1_SWITCH_RIGHT,
1452 EL_BELT2_SWITCH_LEFT,
1453 EL_BELT2_SWITCH_MIDDLE,
1454 EL_BELT2_SWITCH_RIGHT,
1455 EL_BELT3_SWITCH_LEFT,
1456 EL_BELT3_SWITCH_MIDDLE,
1457 EL_BELT3_SWITCH_RIGHT,
1458 EL_BELT4_SWITCH_LEFT,
1459 EL_BELT4_SWITCH_MIDDLE,
1460 EL_BELT4_SWITCH_RIGHT,
1461 EL_SIGN_EXCLAMATION,
1462 EL_SIGN_RADIOACTIVITY,
1475 static int ep_inactive_num = sizeof(ep_inactive)/sizeof(int);
1477 static int ep_explosive[] =
1481 EL_DYNAMITE_INACTIVE,
1482 EL_DYNABOMB_ACTIVE_1,
1483 EL_DYNABOMB_ACTIVE_2,
1484 EL_DYNABOMB_ACTIVE_3,
1485 EL_DYNABOMB_ACTIVE_4,
1501 static int ep_explosive_num = sizeof(ep_explosive)/sizeof(int);
1503 static int ep_mampf3[] =
1512 static int ep_mampf3_num = sizeof(ep_mampf3)/sizeof(int);
1514 static int ep_pushable[] =
1520 EL_SOKOBAN_FELD_VOLL,
1527 static int ep_pushable_num = sizeof(ep_pushable)/sizeof(int);
1529 static int ep_player[] =
1537 static int ep_player_num = sizeof(ep_player)/sizeof(int);
1539 static int ep_has_content[] =
1547 static int ep_has_content_num = sizeof(ep_has_content)/sizeof(int);
1549 static int ep_eatable[] =
1556 static int ep_eatable_num = sizeof(ep_eatable)/sizeof(int);
1558 static int ep_sp_element[] =
1600 /* additional elements that appeared in newer Supaplex levels */
1603 static int ep_sp_element_num = sizeof(ep_sp_element)/sizeof(int);
1605 static int ep_quick_gate[] =
1629 static int ep_quick_gate_num = sizeof(ep_quick_gate)/sizeof(int);
1631 static int ep_over_player[] =
1645 static int ep_over_player_num = sizeof(ep_over_player)/sizeof(int);
1647 static int ep_active_bomb[] =
1650 EL_DYNABOMB_ACTIVE_1,
1651 EL_DYNABOMB_ACTIVE_2,
1652 EL_DYNABOMB_ACTIVE_3,
1653 EL_DYNABOMB_ACTIVE_4
1655 static int ep_active_bomb_num = sizeof(ep_active_bomb)/sizeof(int);
1657 static int ep_belt[] =
1672 static int ep_belt_num = sizeof(ep_belt)/sizeof(int);
1674 static int ep_belt_switch[] =
1676 EL_BELT1_SWITCH_LEFT,
1677 EL_BELT1_SWITCH_MIDDLE,
1678 EL_BELT1_SWITCH_RIGHT,
1679 EL_BELT2_SWITCH_LEFT,
1680 EL_BELT2_SWITCH_MIDDLE,
1681 EL_BELT2_SWITCH_RIGHT,
1682 EL_BELT3_SWITCH_LEFT,
1683 EL_BELT3_SWITCH_MIDDLE,
1684 EL_BELT3_SWITCH_RIGHT,
1685 EL_BELT4_SWITCH_LEFT,
1686 EL_BELT4_SWITCH_MIDDLE,
1687 EL_BELT4_SWITCH_RIGHT,
1689 static int ep_belt_switch_num = sizeof(ep_belt_switch)/sizeof(int);
1691 static long ep1_bit[] =
1725 static long ep2_bit[] =
1730 static int *ep1_array[] =
1764 static int *ep2_array[] =
1769 static int *ep1_num[] =
1796 &ep_has_content_num,
1800 &ep_over_player_num,
1803 static int *ep2_num[] =
1808 static int num_properties1 = sizeof(ep1_num)/sizeof(int *);
1809 static int num_properties2 = sizeof(ep2_num)/sizeof(int *);
1811 for(i=0; i<MAX_ELEMENTS; i++)
1813 Elementeigenschaften1[i] = 0;
1814 Elementeigenschaften2[i] = 0;
1817 for(i=0; i<num_properties1; i++)
1818 for(j=0; j<*(ep1_num[i]); j++)
1819 Elementeigenschaften1[(ep1_array[i])[j]] |= ep1_bit[i];
1820 for(i=0; i<num_properties2; i++)
1821 for(j=0; j<*(ep2_num[i]); j++)
1822 Elementeigenschaften2[(ep2_array[i])[j]] |= ep2_bit[i];
1824 for(i=EL_CHAR_START; i<EL_CHAR_END; i++)
1825 Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
1828 void CloseAllAndExit(int exit_value)
1832 if (sound_process_id)
1835 kill(sound_process_id, SIGTERM);
1836 FreeSounds(NUM_SOUNDS);
1839 for(i=0; i<NUM_PIXMAPS; i++)
1843 #ifdef USE_XPM_LIBRARY
1844 if (i < NUM_PICTURES) /* XPM pictures */
1846 XFreeColors(display,DefaultColormap(display,screen),
1847 xpm_att[i].pixels,xpm_att[i].npixels,0);
1848 XpmFreeAttributes(&xpm_att[i]);
1851 XFreePixmap(display,pix[i]);
1854 XFreePixmap(display,clipmask[i]);
1856 XFreeGC(display, clip_gc[i]);
1860 XFreeGC(display, gc);
1864 XAutoRepeatOn(display);
1865 XCloseDisplay(display);