Fix: SE040 Problem: X11 interface has got a little confused during the move to the 3.3 codebase. Hopefully, this will sort things out a little. I've also changed the name of the resources database from NetHack to SlashEM. To this end SlashEM.ad has replaced NetHack.ad, and all the variable names have been changed. This means that Slash'EM no longer conflicts with NetHack. This is especially helpful for RPMs. The installation instructions have been updated to reflect this. Compatible with: Slash'EM 0.0.5E9 Author: J. Ali Harlow, ali@avrc.city.ac.uk Date: 14 Jan 2000 *** win/X11/Install.X11.orig Tue Jan 11 17:16:46 2000 --- win/X11/Install.X11 Fri Jan 14 16:06:08 2000 *************** *** 1,5 **** ! This document describes the installation of NetHack with an X11 interface. There are no explicit UNIX dependencies in this code, but we have only tested it under UNIX, using X11R4, X11R5, or X11R6. We have two reports --- 1,5 ---- ! This document describes the installation of Slash'EM with an X11 interface. There are no explicit UNIX dependencies in this code, but we have only tested it under UNIX, using X11R4, X11R5, or X11R6. We have two reports *************** *** 19,25 **** (value subtracted er, added software; yea, yea, that's the ticket) usually discourage its use by either omitting the set or putting it on the "unsupported" portion of their tape. If you do not have the Athena ! widgets, you may obtain them via anonymous ftp from export.lcs.mit.edu. To use this code, define X11_GRAPHICS in include/config.h. (You can comment --- 19,25 ---- (value subtracted er, added software; yea, yea, that's the ticket) usually discourage its use by either omitting the set or putting it on the "unsupported" portion of their tape. If you do not have the Athena ! widgets, you may obtain them via anonymous ftp from ftp.x.org. To use this code, define X11_GRAPHICS in include/config.h. (You can comment *************** *** 37,47 **** If you want to use the optional tiles (multicolored pictures instead of a replacement font), you will need to have the win/share files and change ! the VARDATND setting in the top Makefile to contain the tile files before you do your 'make all'. When using tiles, you have the option of defining USE_XPM in config.h. ! This causes NetHack to use the XPM file format for the "x11tiles" file rather than a custom format. Since the XPM format can be processed by existing tools such as PBMPlus and XV, you can modify the tiles to suit your environment. For example, you may magnify them for display on --- 37,47 ---- If you want to use the optional tiles (multicolored pictures instead of a replacement font), you will need to have the win/share files and change ! the CF_SHARE_DATND setting in the top Makefile to contain the tile files before you do your 'make all'. When using tiles, you have the option of defining USE_XPM in config.h. ! This causes Slash'EM to use the XPM file format for the "x11tiles" file rather than a custom format. Since the XPM format can be processed by existing tools such as PBMPlus and XV, you can modify the tiles to suit your environment. For example, you may magnify them for display on *************** *** 50,64 **** pnmdepth 255 | ppmquant 100 | ppmtoxpm >x11tiles_big.xpm To use XPM, you must have the free XPM libraries installed in your system. Official xpm releases can be found by ftp on: ! export.lcs.mit.edu (18.30.0.238) contrib (Boston, USA) ! avahi.inria.fr (192.5.60.47) pub (Sophia Antipolis, France) If you do choose to define USE_XPM, be sure to add "-lXpm" to WINX11LIB in src/Makefile. If you define USE_XPM in config.h, you may also define GRAPHIC_TOMBSTONE which causes the closing tombstone to be displayed from the image file specified by the "tombstone" X resource (rip.xpm by default). In this ! case, make sure the top Makefile VARDATND also contains rip.xpm. Whether or not you install tile support, you can provide support for --- 50,64 ---- pnmdepth 255 | ppmquant 100 | ppmtoxpm >x11tiles_big.xpm To use XPM, you must have the free XPM libraries installed in your system. Official xpm releases can be found by ftp on: ! ftp.x.org (198.4.202.8) contrib/libraries (Boston, USA) ! avahi.inria.fr (138.96.12.1) pub/xpm (Sophia Antipolis, France) If you do choose to define USE_XPM, be sure to add "-lXpm" to WINX11LIB in src/Makefile. If you define USE_XPM in config.h, you may also define GRAPHIC_TOMBSTONE which causes the closing tombstone to be displayed from the image file specified by the "tombstone" X resource (rip.xpm by default). In this ! case, make sure the top Makefile CF_SHARE_X11ND also contains rip.xpm. Whether or not you install tile support, you can provide support for *************** *** 92,103 **** so this method is not recommended. See the note below for the alternative installation procedure for Sun's OpenWindows. ! ! If you are using Xauthority security, installing NetHack setuid may cause ! problems since the alternate id will probably not have permission to open ! your display. NetHack will be just as happy setgid, but you will have to ! change the file permissions in the top Makefile before 'make install' to ! do that. If your X11 include files and libraries are not installed in a standard --- 92,99 ---- so this method is not recommended. See the note below for the alternative installation procedure for Sun's OpenWindows. ! If you're using file areas, then the fonts can go in any sensible directory. ! FILE_AREA_SHARE is suggested for pcf fonts and FILE_AREA_UNSHARE for snf fonts. If your X11 include files and libraries are not installed in a standard *************** *** 107,125 **** find the include and library files for X11. ! Finally, you should also install the NetHack.ad file as NetHack in the normal X11 applications defaults directory. Alternatively, each person may append the contents of this file to their .Xdefaults file. A second ! alternative is copy NetHack.ad to NetHack in GAMEDIR (from the top Makefile) ! and add a line to nethack.sh specifying this additional applications ! defaults directory: XAPPLRESDIR=$HACKDIR; export XAPPLRESDIR Three icon suggestions to the window manager are supported: nh72, nh56, and nh32. Data for them comes from the source files nh72icon, nh56icon, and nh32icon; they are compiled into the program via #includes in winX.c. ! Selection between them is controlled by the "icon" resource in NetHack.ad; the default is nh72. --- 103,122 ---- find the include and library files for X11. ! Finally, you should also install the SlashEM.ad file as SlashEM in the normal X11 applications defaults directory. Alternatively, each person may append the contents of this file to their .Xdefaults file. A second ! alternative is copy SlashEM.ad to SlashEM in GAMEDIR (or FILE_AREA_SHARE) ! (from the top Makefile) and add a line to nethack.sh specifying this ! additional applications defaults directory: XAPPLRESDIR=$HACKDIR; export XAPPLRESDIR + (Replace $HACKDIR with the value of FILE_AREA_SHARE if appropriate.) Three icon suggestions to the window manager are supported: nh72, nh56, and nh32. Data for them comes from the source files nh72icon, nh56icon, and nh32icon; they are compiled into the program via #includes in winX.c. ! Selection between them is controlled by the "icon" resource in SlashEM.ad; the default is nh72. *************** *** 157,163 **** installation, you have the various "xset fp+" options outlined above for standard X. ! 4. Something must still be done with the NetHack.ad file -- all three of the possibilities mentioned for standard X11 should work. --- 154,160 ---- installation, you have the various "xset fp+" options outlined above for standard X. ! 4. Something must still be done with the SlashEM.ad file -- all three of the possibilities mentioned for standard X11 should work. *************** *** 182,193 **** nethack.rc - A sample configuration file for fonts nh10 and ibm. nh10.bdf - A modified version of the 10x20 standard font. ibm.bdf - A modified version of one of the ibm (8x14) nethack font. ! Must be used in conjunction with NetHack.ad or nethack.rc. nh32icon - A 32x32 icon bitmap for use with window managers. nh56icon - A 56x56 icon bitmap for use with window managers. nh72icon - A 72x72 icon bitmap for use with window managers. nh_icon.xpm - A color icon for use with window managers. ! NetHack.ad - A sample .Xdefaults for a color screen. ../../include/Window.h ../../include/WindowP.h Window.c - A bare-bones widget that has 16 colors and a drawing canvas. --- 179,190 ---- nethack.rc - A sample configuration file for fonts nh10 and ibm. nh10.bdf - A modified version of the 10x20 standard font. ibm.bdf - A modified version of one of the ibm (8x14) nethack font. ! Must be used in conjunction with SlashEM.ad or nethack.rc. nh32icon - A 32x32 icon bitmap for use with window managers. nh56icon - A 56x56 icon bitmap for use with window managers. nh72icon - A 72x72 icon bitmap for use with window managers. nh_icon.xpm - A color icon for use with window managers. ! SlashEM.ad - A sample .Xdefaults for a color screen. ../../include/Window.h ../../include/WindowP.h Window.c - A bare-bones widget that has 16 colors and a drawing canvas. *** win/X11/NetHack.ad.orig Tue Jan 11 17:16:46 2000 --- win/X11/NetHack.ad Thu Jan 1 01:00:00 1970 *************** *** 1,153 **** - ! The display_file, tombstone, and menu windows are all formatted assuming - ! a fixed width font. Text windows may or may not be formatted as above. - ! The rip window applies if the GRAPHIC_TOMBSTONE option is turned on, and - ! requires a 12 pixel font for correct appearance. - ! - NetHack*font: variable - NetHack*display_file*font: fixed - NetHack*tombstone*font: fixed - NetHack*rip*font: -*-times-medium-r-*-*-12-*-*-*-*-*-*-* - NetHack*menu*font: fixed - !NetHack*text*font: fixed - NetHack*map*font: nh10 - - ! To use full-color tiles for the map, uncomment the tile file name. - ! If you use a 100dpi (or greater) monitor you may wish to double the - ! tile size so you can see the figures. If NetHack was compiled to - ! use XPM (USE_XPM in config.h), the tile_file is a standard XPM file. - ! Otherwise, it is a custom format. double_tile_size only applies to - ! the custom format - to enlarge an XPM file, use processing tools - ! such as XV or preferably PBMplus. - ! - !NetHack.tile_file: x11tiles - !NetHack.double_tile_size: True - ! - ! The annotation of pets. - !NetHack.pet_mark_bitmap: pet_mark.xbm - !NetHack.pet_mark_color: Red - - ! Tombstone - ! The image file - !NetHack.tombstone: rip.xpm - ! Text starts at (tombtext_x, tombtext_y) and subsequent lines - ! are displaced by (tombtext_dx, tombtext_dy) pixels. If you - !NetHack.tombtext_x: 155 - !NetHack.tombtext_y: 78 - !NetHack.tombtext_dx: 0 - !NetHack.tombtext_dy: 13 - ! The color to use for the text on the hero's tombstone - NetHack*rip*foreground: black - - ! Translation tables. There are currently several actions in nethack, but - ! the only one you should be using is "input()", which, with no parameters, - ! uses XLookupString to translate your keypress into a command. You - ! can optionally give it parameters to change the behavior, see the example - ! below. Note that you have to specify the translations in every appropriate - ! window. - NetHack*message*translations: : input() - ! - ! Example extra translations for the map window. - ! - !NetHack*map*translations: #override \ - ! !Left: input(h) \n\ - ! !Right: input(l) \n\ - ! !Up: input(k) \n\ - ! !Down: input(j) - ! - ! The icon to use; supported values are nh72, nh56, and nh32; nh72 is the - ! default. Some window managers may not support the larger icon sizes. - ! It is not guaranteed that the window manager will honor the icon selection. - !NetHack*icon: nh56 - ! - ! If True, a popup for y/n questions is _not_ used. - !NetHack*slow: True - ! - ! The number of lines the message window will show without scrolling. - !NetHack*message_lines: 12 - ! - ! If True, the message window has a line that seperates old and new messages. - !NetHack*message_line: True - ! - ! If True, force keyboard to attach to popup windows. Some window managers - ! enforce a click-to-focus-keyboard policy (e.g. the DECwindows wm). NetHack - ! has a lot of popups and is almost unplayable without some kind of autofocus. - !NetHack*autofocus: True - ! - ! Specify the number of rows and columns of the map window. The default - ! is the standard 80x21 window. Note: this _does_not_ change nethack's - ! level size, only what you see of it. - !NetHack*map*rows: 21 - !NetHack*map*columns: 80 - - ! Parts of the fancy status display. - ! - NetHack*status_condition.borderWidth: 0 - NetHack*status_info*borderWidth: 0 - - ! Sample color screen entries. - ! - NetHack*nethack.background: wheat - NetHack*map*yellow: gold - NetHack*map*brown: tan - NetHack*map*gray: grey85 - NetHack*map*foreground: wheat - NetHack*map*background: grey40 - - NetHack*fancy_status.skipAdjust: True - NetHack*fancy_status.background: wheat - NetHack*status_info*foreground: Sienna - NetHack*status_info*background: wheat - NetHack*status_info.background: wheat - NetHack*status_attributes*foreground: black - NetHack*status_attributes*background: white - NetHack*status_condition*foreground: red - NetHack*status_condition*background: wheat - NetHack*Scrollbar*foreground: Sienna - NetHack*Scrollbar*background: wheat - NetHack*status_info*showGrip: False - NetHack*status_attributes*showGrip: False - - NetHack*player_selection*random.borderColor: blue - NetHack*player_selection*random.borderWidth: 2 - NetHack*player_selection*random.foreground: blue - NetHack*player_selection*random.accelerators: #override\n\ - Return: set() notify() unset() - NetHack*player_selection*quit.borderColor: blue - NetHack*player_selection*quit.foreground: blue - NetHack*player_selection*Command.borderColor: red - NetHack*player_selection*Command.foreground: red - NetHack*player_selection*quit.accelerators: #override\n\ - Escape: set() notify() unset() - - NetHack*extended_commands*dismiss.borderColor: blue - NetHack*extended_commands*dismiss.foreground: blue - NetHack*extended_commands*help.borderColor: blue - NetHack*extended_commands*help.foreground: blue - NetHack*extended_commands*Command.borderColor: red - NetHack*extended_commands*Command.foreground: red - NetHack*extended_commands*help.accelerators: #override\n\ - :?: set() notify() unset() - NetHack*extended_commands*dismiss.accelerators: #override\n\ - Escape: set() notify() unset() - ! - ! - ! The following are the default 15 colors that the nethack map uses. - ! If they don't look good on your screen, change them. - ! - ! The foreground color is used as "no color". - ! - !NetHack*map*black: black - !NetHack*map*red: red - !NetHack*map*green: pale green - !NetHack*map*brown: brown - !NetHack*map*blue: blue - !NetHack*map*magenta: magenta - !NetHack*map*cyan: light cyan - !NetHack*map*gray: gray - !NetHack*map*orange: orange - !NetHack*map*bright_green: green - !NetHack*map*yellow: yellow - !NetHack*map*bright_blue: royal blue - !NetHack*map*bright_magenta: violet - !NetHack*map*bright_cyan: cyan - !NetHack*map*white: white --- 0 ---- *** win/X11/SlashEM.ad.orig Thu Jan 1 01:00:00 1970 --- win/X11/SlashEM.ad Fri Jan 14 17:28:07 2000 *************** *** 0 **** --- 1,166 ---- + ! The display_file, tombstone, and menu windows are all formatted assuming + ! a fixed width font. Text windows may or may not be formatted as above. + ! The rip window applies if the GRAPHIC_TOMBSTONE option is turned on, and + ! requires a 12 pixel font for correct appearance. + ! + SlashEM*font: variable + SlashEM*display_file*font: fixed + SlashEM*tombstone*font: fixed + SlashEM*rip*font: -*-times-medium-r-*-*-12-*-*-*-*-*-*-* + SlashEM*menu*font: fixed + !SlashEM*text*font: fixed + SlashEM*map*font: nh10 + + ! To use full-color tiles for the map, uncomment the tile file name. + ! If you use a 100dpi (or greater) monitor you may wish to double the + ! tile size so you can see the figures. If SlashEM was compiled to + ! use XPM (USE_XPM in config.h), the tile_file is a standard XPM file. + ! Otherwise, it is a custom format. double_tile_size only applies to + ! the custom format - to enlarge an XPM file, use processing tools + ! such as XV or preferably PBMplus. + ! + !SlashEM.tile_file: x11tiles + !SlashEM.double_tile_size: True + ! + ! The annotation of pets. + !SlashEM.pet_mark_bitmap: pet_mark.xbm + !SlashEM.pet_mark_color: Red + + ! Tombstone + ! The image file + !SlashEM.tombstone: rip.xpm + ! Text starts at (tombtext_x, tombtext_y) and subsequent lines + ! are displaced by (tombtext_dx, tombtext_dy) pixels. If you + !SlashEM.tombtext_x: 155 + !SlashEM.tombtext_y: 78 + !SlashEM.tombtext_dx: 0 + !SlashEM.tombtext_dy: 13 + ! The color to use for the text on the hero's tombstone + SlashEM*rip*foreground: black + + ! Translation tables. There are currently several actions in nethack, but + ! the only one you should be using is "input()", which, with no parameters, + ! uses XLookupString to translate your keypress into a command. You + ! can optionally give it parameters to change the behavior, see the example + ! below. Note that you have to specify the translations in every appropriate + ! window. + SlashEM*message*translations: : input() + ! + ! Example extra translations for the map window. + ! + !SlashEM*map*translations: #override \ + ! !Left: input(h) \n\ + ! !Right: input(l) \n\ + ! !Up: input(k) \n\ + ! !Down: input(j) + ! + ! The icon to use; supported values are nh72, nh56, and nh32; nh72 is the + ! default. Some window managers may not support the larger icon sizes. + ! It is not guaranteed that the window manager will honor the icon selection. + !SlashEM*icon: nh56 + ! + ! If True, a popup for single character prompts such as y/n questions is _not_ + ! used. + !SlashEM*slow: True + ! + ! The number of lines the message window will show without scrolling. + !SlashEM*message_lines: 12 + ! + ! If True, the message window has a line that seperates old and new messages. + !SlashEM*message_line: True + ! + ! If True, force keyboard to attach to popup windows. Some window managers + ! enforce a click-to-focus-keyboard policy (e.g. the DECwindows wm). SlashEM + ! has a lot of popups and is almost unplayable without some kind of autofocus. + !SlashEM*autofocus: True + ! + ! Specify the number of rows and columns of the map window. The default + ! is the standard 80x21 window. Note: this _does_not_ change nethack's + ! level size, only what you see of it. + !SlashEM*map*rows: 21 + !SlashEM*map*columns: 80 + + ! Parts of the fancy status display. + ! + SlashEM*status_condition.borderWidth: 0 + SlashEM*status_info*borderWidth: 0 + + ! Sample color screen entries. + ! + SlashEM*nethack.background: wheat + SlashEM*map*yellow: gold + SlashEM*map*brown: tan + SlashEM*map*gray: grey85 + SlashEM*map*foreground: wheat + SlashEM*map*background: grey40 + + SlashEM*fancy_status.skipAdjust: True + SlashEM*fancy_status.background: wheat + SlashEM*status_info*foreground: Sienna + SlashEM*status_info*background: wheat + SlashEM*status_info.background: wheat + SlashEM*status_attributes*foreground: black + SlashEM*status_attributes*background: white + SlashEM*status_condition*foreground: red + SlashEM*status_condition*background: wheat + SlashEM*Scrollbar*foreground: Sienna + SlashEM*Scrollbar*background: wheat + SlashEM*status_info*showGrip: False + SlashEM*status_attributes*showGrip: False + + SlashEM*player_selection*random.borderColor: blue + SlashEM*player_selection*random.borderWidth: 2 + SlashEM*player_selection*random.foreground: blue + SlashEM*player_selection*random.accelerators: #override\n\ + Return: set() notify() unset() + SlashEM*player_selection*quit.borderColor: blue + SlashEM*player_selection*quit.foreground: blue + SlashEM*player_selection*Command.borderColor: red + SlashEM*player_selection*Command.foreground: red + SlashEM*player_selection*quit.accelerators: #override\n\ + Escape: set() notify() unset() + + SlashEM*race_selection*random.borderColor: blue + SlashEM*race_selection*random.borderWidth: 2 + SlashEM*race_selection*random.foreground: blue + SlashEM*race_selection*random.accelerators: #override\n\ + Return: set() notify() unset() + SlashEM*race_selection*quit.borderColor: blue + SlashEM*race_selection*quit.foreground: blue + SlashEM*race_selection*Command.borderColor: red + SlashEM*race_selection*Command.foreground: red + SlashEM*race_selection*quit.accelerators: #override\n\ + Escape: set() notify() unset() + + SlashEM*extended_commands*dismiss.borderColor: blue + SlashEM*extended_commands*dismiss.foreground: blue + SlashEM*extended_commands*help.borderColor: blue + SlashEM*extended_commands*help.foreground: blue + SlashEM*extended_commands*Command.borderColor: red + SlashEM*extended_commands*Command.foreground: red + SlashEM*extended_commands*help.accelerators: #override\n\ + :?: set() notify() unset() + SlashEM*extended_commands*dismiss.accelerators: #override\n\ + Escape: set() notify() unset() + ! + ! + ! The following are the default 15 colors that the nethack map uses. + ! If they don't look good on your screen, change them. + ! + ! The foreground color is used as "no color". + ! + !SlashEM*map*black: black + !SlashEM*map*red: red + !SlashEM*map*green: pale green + !SlashEM*map*brown: brown + !SlashEM*map*blue: blue + !SlashEM*map*magenta: magenta + !SlashEM*map*cyan: light cyan + !SlashEM*map*gray: gray + !SlashEM*map*orange: orange + !SlashEM*map*bright_green: green + !SlashEM*map*yellow: yellow + !SlashEM*map*bright_blue: royal blue + !SlashEM*map*bright_magenta: violet + !SlashEM*map*bright_cyan: cyan + !SlashEM*map*white: white *** win/X11/Window.c.orig Tue Jan 11 17:16:46 2000 --- win/X11/Window.c Fri Jan 14 16:07:29 2000 *************** *** 1,4 **** ! /* SCCS Id: @(#)Window.c 3.2 93/02/02 */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ --- 1,4 ---- ! /* SCCS Id: @(#)Window.c 3.3 93/02/02 */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ *************** *** 29,35 **** # undef PRESERVE_NO_SYSV #endif ! #include "WindowP.h" #include "config.h" --- 29,35 ---- # undef PRESERVE_NO_SYSV #endif ! #include "xwindowp.h" #include "config.h" *** win/X11/tile2x11.c.orig Tue Jan 11 17:16:57 2000 --- win/X11/tile2x11.c Fri Jan 14 16:12:25 2000 *************** *** 10,17 **** #include "tile.h" #include "tile2x11.h" /* x11 output file header structure */ ! #define OUTNAME "x11tiles" /* output file name, builtin format */ ! #define OUTNAMEXPM "tiles.xpm" /* output file name, XPM format */ /*#define PRINT_COLORMAP /* define to print the colormap */ --- 10,16 ---- #include "tile.h" #include "tile2x11.h" /* x11 output file header structure */ ! #define OUTNAME "x11tiles" /* output file name */ /*#define PRINT_COLORMAP /* define to print the colormap */ *************** *** 118,123 **** --- 117,123 ---- } + #ifdef USE_XPM static int xpm_write(fp) FILE *fp; *************** *** 159,195 **** return fprintf(fp, "};\n")>=0; } ! ! /* ! * ALI ! * ! * Architecture independent tile file so that x11tiles can always be ! * stored in FILE_AREA_SHARE, thus simplifying the configuration. ! */ ! ! static boolean ! fwrite_tile_header_item(item, fp) ! long item; ! FILE *fp; ! { ! putc((item>>24)&0xff,fp); ! putc((item>>16)&0xff,fp); ! putc((item>>8)&0xff,fp); ! putc(item&0xff,fp); ! return !ferror(fp); ! } ! ! static boolean ! fwrite_tile_header(header, fp) ! x11_header *header; ! FILE *fp; ! { ! return fwrite_tile_header_item(header->version,fp) && ! fwrite_tile_header_item(header->ncolors,fp) && ! fwrite_tile_header_item(header->tile_width,fp) && ! fwrite_tile_header_item(header->tile_height,fp) && ! fwrite_tile_header_item(header->ntiles,fp); ! } /* * ALI --- 159,165 ---- return fprintf(fp, "};\n")>=0; } ! #endif /* USE_XPM */ /* * ALI *************** *** 230,241 **** FILE *fp; int i; - #ifdef USE_XPM - int xpm=1; - #else - int xpm=0; - #endif - header.version = 1; header.ncolors = 0; header.tile_width = TILE_X; --- 200,205 ---- *************** *** 243,261 **** header.ntiles = 0; /* updated as we read in files */ if (argc == 1) { ! Fprintf(stderr, "usage: %s [-xpm] txt_file1 [txt_file2 ...]\n", argv[0]); exit(1); } ! if (argv[1][0]=='-' && argv[1][1]=='x') { ! xpm = 1; ! argv++; ! argc--; ! fp = fopen(OUTNAMEXPM, "w"); ! } else { ! fp = fopen(OUTNAME, "w"); ! } ! if (!fp) { Fprintf(stderr, "can't open output file\n"); exit(1); --- 207,217 ---- header.ntiles = 0; /* updated as we read in files */ if (argc == 1) { ! Fprintf(stderr, "usage: %s txt_file1 [txt_file2 ...]\n", argv[0]); exit(1); } ! fp = fopen(OUTNAME, "w"); if (!fp) { Fprintf(stderr, "can't open output file\n"); exit(1); *************** *** 265,293 **** process_file(argv[i]); Fprintf(stderr, "Total tiles: %ld\n", header.ntiles); ! if (xpm) { ! if (xpm_write(fp) == 0) { ! Fprintf(stderr, "can't write XPM file\n"); ! exit(1); } - } else { - if (fwrite_tile_header(&header, fp) == 0) { - Fprintf(stderr, "can't write output header\n"); - exit(1); - } ! if (fwrite((char *)x11_colormap, 1, header.ncolors*3, fp) == 0) { ! Fprintf(stderr, "can't write output colormap\n"); ! exit(1); ! } ! if (fwrite((char *)tile_bytes, 1, ! (int) header.ntiles*header.tile_width*header.tile_height, fp) == 0) { ! Fprintf(stderr, "can't write tile bytes\n"); ! exit(1); ! } } fclose(fp); return 0; --- 221,249 ---- process_file(argv[i]); Fprintf(stderr, "Total tiles: %ld\n", header.ntiles); ! #ifdef USE_XPM ! if (xpm_write(fp) == 0) { ! Fprintf(stderr, "can't write XPM file\n"); ! exit(1); ! } ! #else ! if (fwrite_tile_header(&header, fp) == 0) { ! Fprintf(stderr, "can't write output header\n"); ! exit(1); } ! if (fwrite((char *)x11_colormap, 1, header.ncolors*3, fp) == 0) { ! Fprintf(stderr, "can't write output colormap\n"); ! exit(1); ! } ! if (fwrite((char *)tile_bytes, 1, ! (int) header.ntiles*header.tile_width*header.tile_height, fp) == 0) { ! Fprintf(stderr, "can't write tile bytes\n"); ! exit(1); } + #endif fclose(fp); return 0; *** win/X11/winX.c.orig Tue Jan 11 17:16:57 2000 --- win/X11/winX.c Fri Jan 14 16:19:38 2000 *************** *** 1,4 **** ! /* SCCS Id: @(#)winx.c 3.2 96/04/05 */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ --- 1,4 ---- ! /* SCCS Id: @(#)winX.c 3.3 96/04/05 */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ *************** *** 42,47 **** --- 42,51 ---- # undef PRESERVE_NO_SYSV #endif + #ifdef SHORT_FILENAMES + #undef SHORT_FILENAMES /* hack.h will reset via global.h if necessary */ + #endif + #include "hack.h" #include "winX.h" #include "dlb.h" *************** *** 855,860 **** --- 859,865 ---- {"ec_key", ec_key}, /* action for extended commands */ {"ec_delete", ec_delete}, /* action for ext-com menu delete */ {"ps_key", ps_key}, /* action for player selection */ + {"race_key", race_key}, /* action for race selection */ {"X11_hangup", X11_hangup}, /* action for delete of top-level */ {"input", map_input}, /* action for key input */ {"scroll", nh_keyscroll}, /* action for scrolling by keys */ *************** *** 910,946 **** int i; Cardinal num_args; Arg args[4]; ! uid_t gamesuid=geteuid(); /* Init windows to nothing. */ for (i = 0; i < MAX_WINDOWS; i++) window_list[i].type = NHW_NONE; XSetIOErrorHandler((XIOErrorHandler) hangup); num_args = 0; XtSetArg(args[num_args], XtNallowShellResize, True); num_args++; - - /* - * Shamelessly stolen from Qt interface by Ali ... - * - * Michael Hohmuth ... - * - * As the game runs setuid games, it must seteuid(getuid()) before - * calling XOpenDisplay(), and reset the euid afterwards. - * Otherwise, it can't read the $HOME/.Xauthority file and whines about - * not being able to open the X display (if a magic-cookie - * authorization mechanism is being used). - */ - seteuid(getuid()); toplevel = XtAppInitialize( &app_context, ! "NetHack", /* application class */ (XrmOptionDescList)0, 0, /* options list */ argcp, (String *)argv, /* command line args */ (String *)0, /* fallback resources */ (ArgList)args, num_args); - seteuid(gamesuid); XtOverrideTranslations(toplevel, XtParseTranslationTable("WM_PROTOCOLS: X11_hangup()")); --- 915,947 ---- int i; Cardinal num_args; Arg args[4]; ! uid_t savuid; /* Init windows to nothing. */ for (i = 0; i < MAX_WINDOWS; i++) window_list[i].type = NHW_NONE; + /* + * setuid hack: make sure that if nethack is setuid, to use real uid + * when opening X11 connections, in case the user is using xauth, since + * the "games" or whatever user probably doesn't have permission to open + * a window on the user's display. This code is harmless if the binary + * is not installed setuid. See include/system.h on compilation failures. + */ + savuid = geteuid(); + (void) seteuid(getuid()); + XSetIOErrorHandler((XIOErrorHandler) hangup); num_args = 0; XtSetArg(args[num_args], XtNallowShellResize, True); num_args++; toplevel = XtAppInitialize( &app_context, ! DEF_GAME_NAME, /* application class */ (XrmOptionDescList)0, 0, /* options list */ argcp, (String *)argv, /* command line args */ (String *)0, /* fallback resources */ (ArgList)args, num_args); XtOverrideTranslations(toplevel, XtParseTranslationTable("WM_PROTOCOLS: X11_hangup()")); *************** *** 977,982 **** --- 978,984 ---- if (icon_pixmap != None) { XWMHints hints; + (void) memset((genericptr_t)&hints, 0, sizeof(XWMHints)); hints.flags = IconPixmapHint; hints.icon_pixmap = icon_pixmap; XSetWMHints(XtDisplay(toplevel), *************** *** 986,991 **** --- 988,996 ---- } } + /* end of setuid hack: reset uid back to the "games" uid */ + (void) seteuid(savuid); + x_inited = TRUE; /* X is now initialized */ /* Display the startup banner in the message window. */ *************** *** 2035,2038 **** } } ! /*winx.c*/ --- 2040,2043 ---- } } ! /*winX.c*/ *** win/X11/winmap.c.orig Tue Jan 11 17:16:46 2000 --- win/X11/winmap.c Fri Jan 14 16:30:54 2000 *************** *** 1567,1573 **** if (columns > COLNO) columns = COLNO; if (rows > ROWNO) rows = ROWNO; ! #if 0 /* This is insufficient. We now resize final window in winx.c */ /* * Check for overrunning the size of the screen. This does an ad hoc * job. --- 1567,1573 ---- if (columns > COLNO) columns = COLNO; if (rows > ROWNO) rows = ROWNO; ! #if 0 /* This is insufficient. We now resize final window in winX.c */ /* * Check for overrunning the size of the screen. This does an ad hoc * job. *** win/X11/winmisc.c.orig Tue Jan 11 17:16:46 2000 --- win/X11/winmisc.c Fri Jan 14 16:19:58 2000 *************** *** 33,40 **** #include "func_tab.h" #include "winX.h" - /* extern const char *roles[]; /* from u_init.c */ - extern const struct Role roles[]; static Widget extended_command_popup; static Widget extended_command_form; --- 33,38 ---- *************** *** 165,240 **** void X11_player_selection() { ! char buf[QBUFSZ]; ! char pc; ! char **_roles; ! int i, num_roles; Widget popup, player_form; ! if ((pc = highc(pl_character[0])) != 0) { ! if (index(pl_classes, pc)) goto got_suffix; ! pl_character[0] = pc = 0; ! } ! ! /* -TF- changed for compliance with new role.h */ ! ! for (num_roles = 0; roles[num_roles].name.m; num_roles++) ! ; /* do nothing */ ! ! _roles = (char **) malloc ((num_roles+1) * sizeof(char *)); ! ! for (i=0; i= num_roles) { ! panic("player_selection: bad select value %d\n", ps_selected); ! } else { ! pc = pl_classes[ps_selected]; ! } ! ! got_suffix: ! pl_character[0] = pc; } --- 163,256 ---- void X11_player_selection() { ! int num_roles, num_races, i; Widget popup, player_form; + const char **role_names = 0, **race_names = 0; ! if (flags.initrole < 0) { ! /* select a role */ ! for (num_roles = 0; roles[num_roles].name.m; num_roles++) ! ; /* do nothing */ ! role_names = (const char **)alloc(sizeof(char *) * num_roles); ! for (i = 0; i < num_roles; i++) ! role_names[i] = roles[i].name.m; /* ??? chose female name? */ ! popup = make_menu("player_selection", "Choose a Role", ! player_select_translations, ! "quit", ps_quit, ! "random", ps_random, ! num_roles, role_names, (Widget **)0, ps_select, &player_form); ! ! ps_selected = 0; ! positionpopup(popup, FALSE); ! nh_XtPopup(popup, (int)XtGrabExclusive, player_form); ! ! /* The callbacks will enable the event loop exit. */ ! (void) x_event(EXIT_ON_EXIT); ! ! nh_XtPopdown(popup); ! XtDestroyWidget(popup); ! ! if (ps_selected == PS_QUIT) { ! clearlocks(); ! X11_exit_nhwindows((char *)0); ! terminate(0); ! } else if (ps_selected == PS_RANDOM) { ! flags.initrole = randrole(); ! } else if (ps_selected < 0 || ps_selected >= num_roles) { ! panic("player_selection: bad select value %d\n", ps_selected); ! } else { ! flags.initrole = ps_selected; ! } ! } ! ! if (!validrace(flags.initrole, flags.initrace)) { ! /* select a race */ ! for (num_races = 0; races[num_races].noun; num_races++) ! ; /* do nothing */ ! race_names = (const char **)alloc(sizeof(char *) * num_races); ! for (i = 0; i < num_races; i++) ! race_names[i] = races[i].noun; ! ! popup = make_menu("race_selection", "Choose a Race", ! race_select_translations, ! "quit", ps_quit, ! "random", ps_random, ! num_races, race_names, (Widget **)0, ! ps_select, &player_form); ! ! ps_selected = 0; ! positionpopup(popup, FALSE); ! nh_XtPopup(popup, (int)XtGrabExclusive, player_form); ! ! /* The callbacks will enable the event loop exit. */ ! (void) x_event(EXIT_ON_EXIT); ! ! nh_XtPopdown(popup); ! XtDestroyWidget(popup); ! ! if (ps_selected == PS_QUIT) { ! clearlocks(); ! X11_exit_nhwindows((char *)0); ! terminate(0); ! } else if (ps_selected == PS_RANDOM) { ! flags.initrace = randrace(flags.initrole); ! } else if (ps_selected < 0 || ps_selected >= num_races) { ! panic("player_selection: bad select value %d\n", ps_selected); ! } else { ! flags.initrace = ps_selected; ! } ! } ! ! /* gender and alignment selection goes here... */ ! if (!validgend(flags.initrole, flags.initrace, flags.initgend)) ! flags.initgend = randgend(flags.initrole, flags.initrace); ! if (!validalign(flags.initrole, flags.initrace, flags.initalign)) ! flags.initalign = randalign(flags.initrole, flags.initrace); ! ! if (role_names != 0) ! free((genericptr_t)role_names); ! if (race_names != 0) ! free((genericptr_t)race_names); }