2 "$Id: x11.c 9201 2008-06-01 17:32:45Z anmaster $";
39 #define X_PROG_NAME "cfclient"
85 #include <X11/Xutil.h>
93 #if defined(__pyrsoft)
157 #define SCROLLBAR_WIDTH 16
163 #define MAX_INFO_WIDTH 80
164 #define MAXNAMELENGTH 50
171 #define GAME_WIDTH (image_size * use_config[CONFIG_MAPWIDTH] + 5)
173 #define STAT_HEIGHT 140
176 #define INV_WIDTH 300
178 #define WINDOW_SPACING 3
180 #define ROOT_HEIGHT 522
229 NULL, 0, 0,0,0,0,0,0,0,0};
264 static Stats last_stats = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
290 XGetErrorText(dp, xe->error_code, buf,
MAX_BUF-1);
304 struct timeval timeout;
322 timeout.tv_sec =
MAX_TIME / 1000000;
323 timeout.tv_usec =
MAX_TIME % 1000000;
325 pollret = select(
maxfd, &tmp_read, NULL, NULL, &timeout);
327 fprintf(stderr,
"Got errno %d on select call.\n", errno);
329 else if (FD_ISSET(
csocket.
fd, &tmp_read)) {
348 static void gen_draw_face(Drawable where,
int face,
int x,
int y,
int sx,
int sy)
351 fprintf(stderr,
"Invalid face number: %d @ %d, %d\n", face, x, y);
354 if (pixmaps[face]->
mask == None) {
368 mask = pixmaps[face]->
mask;
370 for(gcnum=0;gcnum<
XPMGCS;gcnum++) {
375 if (gcnum == XPMGCS) {
386 for(i=gcnum-1;i>=0;i--) {
439 gamehint.height=gamehint.width;
441 gamehint.max_width=gamehint.min_width=gamehint.width;
442 gamehint.max_height=gamehint.min_height=gamehint.height;
443 gamehint.flags=PPosition | PSize;
445 gamehint.x,gamehint.y,gamehint.width,gamehint.height,2,
474 for (i=0; i<
XPMGCS; i++) {
489 ButtonPressMask|KeyPressMask|KeyReleaseMask|ExposureMask);
514 infohint.min_width=100;
515 infohint.min_height=30;
516 infohint.flags=PPosition | PSize;
518 infohint.x,infohint.y,infohint.width,infohint.height,2,
533 ButtonPressMask|KeyPressMask|KeyReleaseMask|ExposureMask|
534 StructureNotifyMask);
543 for (i=0; i<infodata.
maxlines; i++) {
624 if ((key < 32 || (
unsigned char) key > 127) && key != 8)
630 if(key==8||key==127) {
704 static int last_length=0, last_y=0;
722 if (!redraw && last_length==infodata.
bar_size && last_y==infodata.
bar_y)
return;
724 last_y=infodata.
bar_y;
755 if(str == (
char *) NULL) {
760 if((cp=strchr(str,
'\n'))!=NULL) {
765 char obuf[4096],*buf = obuf;
767 strncpy(buf,str, 4095);
769 if ((cp = strchr(buf,
'\n'))) {
780 if ((
int)strlen(str) >= infodata.
info_chars) {
785 while ((str[--i]!=
' ') && (str[i]!=
')') && (i!=0)) ;
788 char *buf = (
char *)malloc(
sizeof(
char)*(i+2));
793 strncpy(buf, str, i);
798 for (j=i; j < (int)strlen(str); j++)
799 if (str[j]!=
' ')
break;
800 if ((((strlen(str)-i)!=1) || (str[i]!=
'.')) && (j!=strlen(str)))
884 infodata.
infopos = new_infopos;
944 if (startline<0) startline+=infodata.
maxlines;
958 for (i=0; i<infodata.
maxdisp; i++) {
967 strlen(infodata.
data[startline].
info));
1000 if (infodata.
width==width &&
1001 infodata.
height==height)
return;
1003 if(chars<3 || lines<3)
1033 if (lines == infodata.
maxdisp) {
1034 for (i=0; i<infodata.
maxlines; i++) {
1036 infodata.
data[i].
info= realloc(infodata.
data[i].
info,
sizeof(
char) * (chars+1));
1052 newlines = malloc(
sizeof(
InfoLine) * lines);
1053 for (i=0; i<lines; i++) {
1054 newlines[i].
info = malloc(
sizeof(
char) * (chars +1));
1055 newlines[i].
info[0]=
'\0';
1056 newlines[i].
color=0;
1069 for (i=0; i<infodata.
numlines; i++) {
1071 strncpy(newlines[i].info, infodata.
data[k].
info, chars);
1072 newlines[i].
info[chars]=0;
1079 int start=infodata.
infopos-lines,k;
1081 if (start<0) start += infodata.
maxlines;
1082 for (i=0; i<lines; i++) {
1084 strncpy(newlines[i].info, infodata.
data[k].
info, chars);
1085 newlines[i].
info[chars]=0;
1089 newlines[0].
info[0] =
'\0';
1095 for (i=0; i<infodata.
maxlines; i++) {
1098 free(infodata.
data);
1099 infodata.
data = newlines;
1115 XSizeHints stathint;
1121 stathint.min_width=stathint.max_width=stathint.width;
1122 stathint.min_height=stathint.max_height=stathint.height;
1123 stathint.flags=PPosition | PSize;
1125 stathint.x,stathint.y,stathint.width,stathint.height,2,
1155 if (strcmp(
cpl.
title, last_name) || redraw) {
1160 gc_stats,10,10, buff,strlen(buff));
1165 sprintf(buff,
"Score: %5" FMT64
" Level: %d",
cpl.
stats.
exp,
1169 gc_stats,10,24, buff,strlen(buff));
1181 sprintf(buff,
"Hp %d/%d Sp %d/%d Gr %d/%d",
1188 gc_stats,10,38, buff,strlen(buff));
1202 sprintf(buff,
"S%2d D%2d Co%2d I%2d W%2d P%2d Ch%2d",
1209 gc_stats,10,52, buff,strlen(buff));
1225 sprintf(buff,
"Wc:%3d Dam:%3d Ac:%3d Arm:%3d",
1230 gc_stats,10,66, buff,strlen(buff));
1257 sprintf(buff,
"Speed: %3.2f (%1.2f) Food: *%d* HUNGRY!",
1262 sprintf(buff,
"Speed: %3.2f (%1.2f) Food: %3d",
1270 gc_stats,10,80, buff,strlen(buff));
1276 if (redraw || strcmp(
cpl.
range, last_range)) {
1281 gc_stats,10,94, buff,strlen(buff));
1284 const int skills_per_line = 2;
1299 if ((on_skill % skills_per_line) == 0) {
1301 108 + (14 * (on_skill / skills_per_line)), buff,strlen(buff));
1309 108 + (14 * (on_skill / skills_per_line)), buff,strlen(buff));
1343 ButtonPressMask|KeyPressMask|KeyReleaseMask|ExposureMask);
1351 for(;*txt!=
'\0';txt++,y+=13)
1356 #define MAX_BARS_MESSAGE 80
1385 int bar,is_alert,flags;
1386 static uint16 oldflags=0;
1387 static uint16 scrollsize_hp=0, scrollsize_sp=0, scrollsize_food=0,
1390 scrollfood_alert=
FALSE, scrollgrace_alert=
FALSE;
1405 if (redraw || scrollsize_hp!=bar || scrollhp_alert!=is_alert)
1408 scrollhp_alert=is_alert;
1423 if (redraw || scrollsize_sp!=bar || scrollsp_alert!=is_alert)
1427 scrollsp_alert=is_alert;
1439 if (redraw || scrollsize_grace!=bar || scrollgrace_alert!=is_alert)
1442 scrollsize_grace=bar;
1443 scrollgrace_alert=is_alert;
1451 if (redraw || scrollsize_food!=bar || scrollfood_alert!=is_alert)
1454 scrollsize_food=bar;
1455 scrollfood_alert=is_alert;
1462 if ((flags &
SF_FIREON ) != (oldflags & SF_FIREON)) {
1463 if (flags & SF_FIREON)
1465 look_list.
gc_text, 180, 15,
"Fire On", 7);
1468 180, 0, 60, 15, False);
1470 if ((flags &
SF_RUNON ) != (oldflags & SF_RUNON)) {
1471 if (flags & SF_RUNON)
1473 look_list.
gc_text, 180, 30,
"Run On", 6);
1476 180, 15, 60, 15, False);
1492 look_list.
gc_text, x+40, y, buf, strlen(buf));
1531 XCopyPlane(
display,
icons[face], l->
win, l->
gc_status, 0,0, 24,6, x,y, 1);
1561 #include "pixmaps/clear.xbm"
1562 #include "pixmaps/locked.xbm"
1563 #include "pixmaps/applied.xbm"
1564 #include "pixmaps/unpaid.xbm"
1565 #include "pixmaps/damned.xbm"
1566 #include "pixmaps/cursed.xbm"
1567 #include "pixmaps/magic.xbm"
1568 #include "pixmaps/close.xbm"
1569 #include "pixmaps/stipple.111"
1570 #include "pixmaps/stipple.112"
1572 static int hasinit=0;
1576 if (hasinit)
return;
1579 #define CREATEPM(name,data) \
1580 (icons[name] = XCreateBitmapFromData(display, def_root,\
1581 data##_bits, data##_width, data##_height))
1596 fprintf(stderr,
"Unable to create pixmaps.\n");
1603 XSetFillStyle(
display, tmpgc, FillSolid);
1604 XSetForeground(
display, tmpgc, 1);
1608 XSetForeground(
display, tmpgc, 0);
1636 int i, items, size, pos;
1641 strcpy(buf2, l->
title);
1653 buf2[strlen(buf2)-2]=
')';
1654 buf2[strlen(buf2)-1]=
'\0';
1670 13, buf, strlen(buf));
1675 for(tmp = l->
env->
inv, items=0; tmp ;tmp=tmp->
next)
1688 for(i=0; tmp && i < l->
size; tmp=tmp->
next) {
1701 if (l->
icon1[i] != tmp_icon) {
1702 l->
icon1[i] = tmp_icon;
1707 if (l->
icon2[i] != tmp_icon) {
1708 l->
icon2[i] = tmp_icon;
1712 if (l->
icon3[i] != tmp_icon) {
1713 l->
icon3[i] = tmp_icon;
1718 if (l->
icon4[i] != tmp_icon) {
1719 l->
icon4[i] = tmp_icon;
1724 strcpy (buf2, tmp->
d_name);
1726 strcat (buf2, tmp->
flags);
1733 if(!l->
names[i] || strcmp(buf, l->
names[i])) {
1745 if(items < l->item_used) {
1748 while (i < l->item_used) {
1786 for(i=0; i<l->
size; i++) {
1813 for (i = 0; i < l->
size; ++i)
1829 strcpy (look_list.
title,
"You see:");
1843 for (i=0; i < l->
size; i++)
1857 if ((l->
faces = malloc (
sizeof (*(l->
faces)) * l->
size )) == NULL) {
1858 printf (
"Can't allocate memory.\n");
1861 if ((l->
icon1 = malloc (
sizeof (*(l->
icon1)) * l->
size )) == NULL) {
1862 printf (
"Can't allocate memory.\n");
1865 if ((l->
icon2 = malloc (
sizeof (*(l->
icon2)) * l->
size )) == NULL) {
1866 printf (
"Can't allocate memory.\n");
1869 if ((l->
icon3 = malloc (
sizeof (*(l->
icon3)) * l->
size )) == NULL) {
1870 printf (
"Can't allocate memory.\n");
1873 if ((l->
icon4 = malloc (
sizeof (*(l->
icon4)) * l->
size )) == NULL) {
1874 printf (
"Can't allocate memory.\n");
1877 if ((l->
names = malloc (
sizeof (
char *) * l->
size )) == NULL) {
1878 printf (
"Can't allocate memory.\n");
1881 for (i=0; i < l->
size; i++) {
1883 printf (
"Can't allocate memory.\n");
1891 const char *t,
const char *s)
1903 hint.flags = PPosition | PSize;
1924 XSelectInput (
display, l->
win, ButtonPressMask|KeyPressMask|KeyReleaseMask|
1925 ExposureMask|StructureNotifyMask);
1935 strcpy (inv_list.
title,
"");
1941 "Crossfire - inventory",
1949 strcpy (look_list.
title,
"You see:");
1980 if (s == NULL || *s == 0 || strncmp (
"inventory", s, strlen(s)) == 0) {
1983 }
else if (strncmp (
"look", s, strlen(s)) == 0) {
1991 if (s == NULL || *s == 0 || strncmp (
"inventory", s, strlen(s)) == 0) {
1994 }
else if (strncmp (
"look", s, strlen(s)) == 0) {
2068 display=XOpenDisplay(display_name);
2070 fprintf(stderr,
"Can't open display %s.\n", display_name);
2098 if (!strcmp(
"on",cp) || !strcmp(
"yes",cp))
2100 else if (!strcmp(
"off",cp) || !strcmp(
"no",cp))
2105 if (!strcmp(
"on",cp) || !strcmp(
"yes",cp))
2107 else if (!strcmp(
"off",cp) || !strcmp(
"no",cp))
2119 fprintf(stderr,
"Could not load font %s\n",
font_name);
2160 KeyReleaseMask|ExposureMask|StructureNotifyMask);
2171 int width, inv_width, info_width;
2174 fprintf(stderr,
"Got a resize root window in split windows mode\n");
2184 inv_width = width - info_width;
2207 inv_width +
GAME_WIDTH + WINDOW_SPACING * 2, 0,
2208 info_width, event->xconfigure.height);
2212 XResizeWindow(
display, inv_list.
win, inv_width,
2213 2 * (event->xconfigure.height - WINDOW_SPACING) / 3);
2217 (2*(event->xconfigure.height - WINDOW_SPACING) / 3) + WINDOW_SPACING,
2219 (event->xconfigure.height - WINDOW_SPACING) / 3);
2236 int dx, dy, i, xmidl, xmidh, ymidl, ymidh;
2323 if(!XLookupString(&
event.xkey,text,10, &gkey,NULL)) {
2391 int y = xbutton->y-16, x=xbutton->x, button = xbutton->button,dy,pos=0;
2430 if (pos != infodata.
bar_pos) {
2447 int y = xbutton->y - 16, x=xbutton->x, button = xbutton->button;
2448 int items, pos=0, dy;
2450 if (y < 0 && l->env->open)
2456 if (button == 4 || button == 5)
2466 if (x > l->
width-23) {
2468 dy = y / image_size > 0 ? y / image_size : 1;
2476 for(tmp=l->
env->
inv, items=0; tmp; tmp=tmp->
next)
2494 for(tmp=l->
env->
inv, items=0; tmp; tmp=tmp->
next) {
2496 if (items>pos)
break;
2501 if (xbutton->state & ShiftMask)
2507 if (xbutton->state & ShiftMask)
2514 draw_info (
"This item is locked. To drop it, first unlock by shift+leftclicking on it.",
2516 }
else if (l == &inv_list)
2569 static int lastupdate=0;
2570 static XEvent prev_event;
2597 while (XPending(
display)!=0) {
2600 switch(
event.type) {
2602 case ConfigureNotify:
2605 else if(
event.xconfigure.window==inv_list.
win)
2607 event.xconfigure.height);
2608 else if(
event.xconfigure.window==look_list.
win)
2610 event.xconfigure.height);
2621 if (
event.xexpose.count!=0)
continue;
2627 else if(
event.xexpose.window==inv_list.
win)
2629 else if(
event.xexpose.window==look_list.
win)
2641 case GraphicsExpose:
2645 if (
event.xgraphicsexpose.count!=0)
continue;
2653 XRefreshKeyboardMapping(&
event.xmapping);
2666 }
else if(
event.xbutton.window==inv_list.
win) {
2669 }
else if(
event.xbutton.window==look_list.
win) {
2684 && prev_event.type == KeyRelease
2685 && prev_event.xkey.keycode ==
event.xkey.keycode
2686 && prev_event.xkey.state ==
event.xkey.state
2687 && prev_event.xkey.time ==
event.xkey.time)
2694 LOG(
LOG_INFO,
"x11::check_x_events",
"Window closed. Exiting.");
2734 puts(
"Usage of cfclient:\n\n");
2735 puts(
"-server <name> - Connect to <name> instead of localhost.");
2736 puts(
"-port <number> - Use port <number> instead of the standard port number");
2737 puts(
"-display <name> - Use <name> instead if DISPLAY environment variable.\n");
2738 puts(
"-split - Use split windows.");
2739 puts(
"-nosplit - Disable split windows (default action).");
2740 puts(
"-echo - Echo the bound commands");
2741 puts(
"-pix - Use bitmaps for display.");
2743 puts(
"-xpm - Use color pixmaps (XPM) for display.");
2746 puts(
"-png - Use png images for display.");
2748 puts(
"-showicon - Print status icons in inventory window");
2749 puts(
"-scrolllines <number> - number of lines for scrollback");
2750 puts(
"-sync - Synchronize on display");
2751 puts(
"-help - Display this message.");
2752 puts(
"-cache - Cache images for future use.");
2753 puts(
"-nocache - Do not cache images (default action).");
2754 puts(
"-mapscroll - Enable mapscrolling by bitmap operations");
2755 puts(
"-nomapscroll - Disable mapscrolling by bitmap operations");
2756 puts(
"-darkness - Enables darkness code (default)");
2757 puts(
"-nodarkness - Disables darkness code");
2758 puts(
"-nosound - Disable sound output.");
2759 puts(
"-updatekeycodes - Update the saved bindings for this keyboard.");
2760 puts(
"-keepcache - Keep already cached images even if server has different ones.");
2761 puts(
"-font <name> - Use <name> as font to display data.");
2762 puts(
"-pngfile <name> - Use <name> for source of images");
2763 puts(
"-mapsize xXy - Set the mapsize to be X by Y spaces.");
2764 puts(
"-noautorepeat - Auto repeat on directional keys is ignored.");
2765 puts(
"-faceset <num> - Select a specific facset to use.");
2783 char *display_name=
"";
2791 for (on_arg=1; on_arg<argc; on_arg++) {
2792 if (!strcmp(argv[on_arg],
"-display")) {
2793 if (++on_arg == argc) {
2794 fprintf(stderr,
"-display requires a display name\n");
2797 display_name = argv[on_arg];
2800 if (strcmp(argv[on_arg],
"-sync")==0) {
2804 if (!strcmp(argv[on_arg],
"-port")) {
2805 if (++on_arg == argc) {
2806 fprintf(stderr,
"-port requires a port number\n");
2812 if (!strcmp(argv[on_arg],
"-mapsize")) {
2815 if (++on_arg == argc) {
2816 fprintf(stderr,
"-mapsize requires a XxY value\n");
2819 x = atoi(argv[on_arg]);
2820 for (cp = argv[on_arg]; *cp!=
'\0'; cp++)
2821 if (*cp ==
'x' || *cp ==
'X')
break;
2824 fprintf(stderr,
"-mapsize requires both and X and Y value (ie, XxY - note the\nx in between.\n");
2829 fprintf(stderr,
"map size must be positive values of at least 9\n");
2838 if (!strcmp(argv[on_arg],
"-server")) {
2839 if (++on_arg == argc) {
2840 fprintf(stderr,
"-server requires a host name\n");
2846 else if (!strcmp(argv[on_arg],
"-nofasttcpsend")) {
2850 else if (!strcmp(argv[on_arg],
"-cache")) {
2854 else if (!strcmp(argv[on_arg],
"-nocache")) {
2858 else if (!strcmp(argv[on_arg],
"-mapscroll")) {
2861 else if (!strcmp(argv[on_arg],
"-nomapscroll")) {
2864 else if (!strcmp(argv[on_arg],
"-darkness")) {
2868 else if (!strcmp(argv[on_arg],
"-nodarkness")) {
2872 else if (!strcmp(argv[on_arg],
"-fogofwar")) {
2876 else if (!strcmp(argv[on_arg],
"-nofogofwar")) {
2880 else if (!strcmp(argv[on_arg],
"-split")) {
2884 else if (!strcmp(argv[on_arg],
"-nosplit")) {
2888 else if (!strcmp(argv[on_arg],
"-showicon")) {
2892 else if (!strcmp(argv[on_arg],
"-download_all_faces")) {
2896 else if (!strcmp(argv[on_arg],
"-echo")) {
2900 else if (!strcmp(argv[on_arg],
"-faceset")) {
2901 if (++on_arg == argc) {
2902 fprintf(stderr,
"-faceset requires a faceset name/number\n");
2908 else if (!strcmp(argv[on_arg],
"-scrolllines")) {
2909 if (++on_arg == argc) {
2910 fprintf(stderr,
"-scrolllines requires a number\n");
2913 infodata.
maxlines = atoi(argv[on_arg]);
2916 else if (!strcmp(argv[on_arg],
"-font")) {
2917 if (++on_arg == argc) {
2918 fprintf(stderr,
"-font requires a font name\n");
2924 else if (!strcmp(argv[on_arg],
"-help")) {
2928 else if (!strcmp(argv[on_arg],
"-nosound")) {
2932 else if (!strcmp(argv[on_arg],
"-updatekeycodes")) {
2936 else if (!strcmp(argv[on_arg],
"-autorepeat")) {
2941 fprintf(stderr,
"Do not understand option %s\n", argv[on_arg]);
2954 fprintf(stderr,
"Client not configured with Png display mode enabled\n");
2955 fprintf(stderr,
"Install the png library and try recompiling.\n");
2996 int layer, mx, my, got_one = 0;
3007 for (layer=0; layer<
MAXLAYERS; layer++) {
3013 int w = pixmaps[face]->
width;
3014 int h = pixmaps[face]->
height;
3031 XCopyPlane(
display,
dark2,
xpm_pixmap,
gc_xpm[
XPMGCS-1], 0, 0,
image_size,
image_size, 0, 0, 1);
3039 if (darkness > 192) {
3041 XCopyPlane(
display,
dark1,
xpm_pixmap,
gc_xpm[
XPMGCS-1], 0, 0,
image_size,
image_size, 0, 0, 1);
3044 else if (darkness > 128) {
3046 XCopyPlane(
display,
dark2,
xpm_pixmap,
gc_xpm[
XPMGCS-1], 0, 0,
image_size,
image_size, 0, 0, 1);
3049 else if (darkness > 64) {
3051 XCopyPlane(
display,
dark3,
xpm_pixmap,
gc_xpm[
XPMGCS-1], 0, 0,
image_size,
image_size, 0, 0, 1);
3064 XWindowAttributes attrib;
3077 if (width>0 ||
height > 0) {
3079 width += attrib.width;
3188 XWindowAttributes win_info;
3208 fprintf(stderr,
"magic map resolution less than 1, map is %dx%d\n",
3270 if (pixmaps[i]->
mask) {
3274 pixmaps[i] = pixmaps[0];
3288 unsigned int *w,
unsigned int *h)
3293 XGetGeometry(
display,win,&root,x,y,w,h,&tmp,&tmp);
3294 XTranslateCoordinates(
display,win,root,0,0,wx,wy, &child);
3307 draw_info(
"You can only save window positions in split windows mode",
NDI_BLUE);
3310 sprintf(savename,
"%s/.crossfire/winpos", getenv(
"HOME"));
3311 if (!(fp=fopen(savename,
"w"))) {
3312 sprintf(buf,
"Unable to open %s, window positions not saved",savename);
3321 fprintf(fp,
"win_game: %d %d %d %d\n", wx,wy, w, h);
3323 fprintf(fp,
"win_stats: %d %d %d %d\n", wx,wy, w, h);
3325 fprintf(fp,
"win_info: %d %d %d %d\n", wx,wy, w, h);
3327 fprintf(fp,
"win_inv: %d %d %d %d\n", wx,wy, w, h);
3329 fprintf(fp,
"win_look: %d %d %d %d\n", wx,wy, w, h);
3331 fprintf(fp,
"win_message: %d %d %d %d\n", wx,wy, w, h);
3333 sprintf(buf,
"Window positions saved to %s",savename);
3342 unsigned int xwc_mask = CWX|CWY|CWWidth|CWHeight;
3349 sprintf(buf,
"%s/.crossfire/winpos", getenv(
"HOME"));
3350 if (!(fp=fopen(buf,
"r")))
return;
3352 while(fgets(buf,
MAX_BUF-1, fp)!=NULL) {
3354 if (!(cp=strchr(buf,
' ')))
continue;
3356 if (sscanf(cp,
"%d %d %d %d",&xwc.x,&xwc.y,&xwc.width,&xwc.height)!=4)
3358 if (!strcmp(buf,
"win_game:"))
3360 if (!strcmp(buf,
"win_stats:"))
3362 if (!strcmp(buf,
"win_info:"))
3364 if (!strcmp(buf,
"win_inv:"))
3365 XConfigureWindow(
display,inv_list.
win,xwc_mask, &xwc);
3366 if (!strcmp(buf,
"win_look:"))
3367 XConfigureWindow(
display,look_list.
win,xwc_mask, &xwc);
3368 if (!strcmp(buf,
"win_message:"))
3381 sprintf(path,
"%s/.crossfire/defaults", getenv(
"HOME"));
3382 if ((fp=fopen(path,
"r"))==NULL)
return;
3383 while (fgets(inbuf,
MAX_BUF-1, fp)) {
3385 inbuf[strlen(inbuf)-1]=
'\0';
3387 if (inbuf[0]==
'#')
continue;
3389 if (!(cp=strchr(inbuf,
':')))
continue;
3393 if (!strcmp(inbuf,
"port")) {
3397 if (!strcmp(inbuf,
"server")) {
3401 if (!strcmp(inbuf,
"cacheimages")) {
3406 if (!strcmp(inbuf,
"split")) {
3411 if (!strcmp(inbuf,
"showicon")) {
3416 if (!strcmp(inbuf,
"scrolllines")) {
3420 if (!strcmp(inbuf,
"scrollinfo")) {
3425 if (!strcmp(inbuf,
"sound")) {
3430 if (!strcmp(inbuf,
"command_window")) {
3436 if (!strcmp(inbuf,
"foodbeep")) {
3441 if (!strcmp(inbuf,
"noautorepeat")) {
3446 if (!strcmp(inbuf,
"font")) {
3450 fprintf(stderr,
"Got line we did not understand: %s: %s\n", inbuf, cp);
3460 sprintf(path,
"%s/.crossfire/defaults", getenv(
"HOME"));
3462 fprintf(stderr,
"Could not create %s\n", path);
3465 if ((fp=fopen(path,
"w"))==NULL) {
3466 fprintf(stderr,
"Could not open %s\n", path);
3469 fprintf(fp,
"# This file is generated automatically by cfclient.\n");
3470 fprintf(fp,
"# Manually editing is allowed, however cfclient may be a bit finicky about\n");
3471 fprintf(fp,
"# some of the matching it does. all comparissons are case sensitive.\n");
3472 fprintf(fp,
"# 'True' and 'False' are the proper cases for those two values\n");
3475 fprintf(fp,
"server: %s\n",
server);
3479 fprintf(fp,
"showicon: %s\n", inv_list.
show_icon?
"True":
"False");
3480 fprintf(fp,
"scrolllines: %d\n", infodata.
maxlines);
3485 fprintf(fp,
"noautorepeat: %s\n",
noautorepeat?
"True":
"False");
3488 sprintf(buf,
"Defaults saved to %s",path);
3513 if (!strncmp(params,
"all", strlen(params)))
3515 else if (!strncmp(params,
"applied", strlen(params)))
3517 else if (!strncmp(params,
"unapplied", strlen(params)))
3519 else if (!strncmp(params,
"unpaid", strlen(params)))
3521 else if (!strncmp(params,
"cursed", strlen(params)))
3523 else if (!strncmp(params,
"magical", strlen(params)))
3525 else if (!strncmp(params,
"nonmagical", strlen(params)))
3527 else if (!strncmp(params,
"locked", strlen(params)))
3529 else if (!strncmp(params,
"unlocked", strlen(params)))
3541 int sound,got_one=0;
3558 fprintf(stderr,
"Failure to init windows.\n");
3564 maxfd = sysconf(_SC_OPEN_MAX);
3566 maxfd = getdtablesize();
3588 if (!
server || got_one) {
void negotiate_connection(int sound)
static int get_message_display(void)
static void get_list_display(itemlist *l, int x, int y, int w, int h, const char *t, const char *s)
static XFontStruct * font
static void draw_info_scrollbar(int redraw)
static void resize_list_info(itemlist *l, int w, int h)
void move_player(int dir)
int init_pngx_loader(Display *display)
static Pixmap xpm_masks[XPMGCS]
void clear_fire_run(void)
void redisplay_stats(void)
void init_client_vars(void)
void close_container(item *op)
struct PixmapInfo * pixmaps[MAXPIXMAPNUM]
static void init_cache_data(void)
static itemlist look_list
void draw_stats(int redraw)
void set_scroll(const char *s)
void item_event_item_deleting(item *it)
static int get_look_display(void)
void animate_objects(void)
snd_pcm_hw_params_t * params
int display_mapscroll(int dx, int dy)
const char * rcsid_x11_x11_c
static XColor discolor[16]
uint16 scroll_info_window
void command_show(const char *params)
struct item_struct * next
static unsigned long background
void reset_image_data(void)
static void parse_key_release(uint32 ks)
int make_path_to_file(char *filename)
Face_Information face_info
void draw_color_info(int colr, const char *buf)
void item_event_item_changed(item *it)
static void draw_list(itemlist *l)
sint16 want_config[CONFIG_NUMS]
static void configure_keys(uint32 keysym)
const char *const resists_name[NUM_RESISTS]
static int get_inv_display(void)
sint64 skill_exp[MAX_SKILL]
void set_window_pos(void)
static char stats_buff[7][600]
void display_map_startupdate(void)
void draw_magic_map(void)
void draw_message_window(int redraw)
char * skill_names[MAX_SKILL]
void display_map_doneupdate(int redraw, int notice)
static int get_info_display(void)
static void do_key_press(int repeated)
int init_connection(char *host, int port)
static int show_object(item *ip, inventory_show flags)
static void draw_status_icon(itemlist *l, int x, int y, int face)
static void parse_game_button_press(int button, int x, int y)
void LOG(LogLevel level, const char *origin, const char *format,...)
void client_send_apply(int tag)
void reset_client_vars(void)
static Pixmap icons[max_icons]
int main(int argc, char *argv[])
void resize_map_window(int x, int y)
void look_at(int x, int y)
static const unsigned char crossfire_bits[]
int associate_cache_entry(Cache_Entry *ce, int pixnum)
sint16 use_config[CONFIG_NUMS]
sint16 mapdata_face(int x, int y, int layer)
static unsigned long foreground
static void buttonpress_in_info(XButtonEvent *xbutton)
static void update_icons_list(itemlist *l)
#define CREATEPM(name, data)
static void display_mapcell(int ax, int ay)
static int buttonpress_in_list(itemlist *l, XButtonEvent *xbutton)
void client_send_move(int loc, int tag, int nrof)
int error_handler(Display *dp, XErrorEvent *xe)
static void xwritedown(const char *txt, int x)
void reset_image_cache_data(void)
static void get_window_coord(Window win, int *x, int *y, int *wx, int *wy, unsigned int *w, unsigned int *h)
void cleanup_connection(void)
void extended_command(const char *ocommand)
static int get_game_display(void)
void check_x_events(void)
static void resize_win_info(int width, int height)
static Atom wm_delete_window
void send_reply(const char *text)
void allocate_colors(Display *disp, Window w, long screen_num, Colormap *colormap, XColor discolor[16])
void send_mark_obj(item *op)
static void draw_all_info(void)
void toggle_locked(item *op)
const char * complete_command(const char *command)
int last_used_skills[MAX_SKILL+1]
static void delete_ch(void)
char * get_metaserver(void)
item * locate_item(sint32 tag)
static XSizeHints messagehint
static void draw_stat_bar(int bar_pos, int height, int is_alert)
void set_autorepeat(const char *s)
void draw_info(const char *str, int color)
char * strdup_local(const char *str)
void item_event_container_clearing(item *container)
void script_fdset(int *maxfd, fd_set *set)
void magic_map_flash_pos(void)
void remove_item_inventory(item *op)
sint16 mapdata_bigface(int x, int y, int layer, int *ww, int *hh)
static void usage(char *progname)
static void gen_draw_face(Drawable where, int face, int x, int y, int sx, int sy)
static void parse_key(char key, uint32 keysym)
void client_send_examine(int tag)
static void create_status_icons(void)
static double weight_limit
void DoClient(ClientSocket *csocket)
void set_show_weight(const char *s)
void set_weight_limit(uint32 wlim)
static int get_root_display(char *display_name)
static void draw_all_list(itemlist *l)
void open_container(item *op)
sint16 skill_level[MAX_SKILL]
static void resize_win_message(int width, int height)
void draw_prompt(const char *str)
static int get_stats_display(void)
static void draw_all_message(void)
int init_windows(int argc, char **argv)
void script_process(fd_set *set)
void display_map_newmap(void)
void set_show_icon(const char *s)
static XSizeHints roothint
static void resize_win_root(XEvent *event)