Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!texbell!texsun!newstop!male!mlsgcm!gcmcnutt From: gcmcnutt@mlsgcm.Ebay.Sun.COM (Greg McNutt) Newsgroups: comp.windows.x Subject: xtank1.2 color patches Message-ID: <2645@male.EBay.Sun.COM> Date: 16 Jul 90 22:27:19 GMT Sender: news@male.EBay.Sun.COM Reply-To: gcmcnutt@mlsgcm.Ebay.Sun.COM (Greg McNutt) Organization: Sun Microsystems Federal, Inc. Lines: 330 I'm resending this again. Sorry if you got it twice. -------------------------------------- This is a simple patch to get color working on xtank v1.2. This has only been tested on Sun systems (running openwindows and x11r4). Give it a try. It may work for you too! We do still have one persistent bug. It has to do with owner changes on frisbees when running ultimate. Probably a different approach to object coloring will be necessary to get this working right... To apply patch: 1) ensure you are using 1.2 of xtank 2) go into the 'Src' directory of xtank 3) patch < thisfile 4) rebuild xtank (don't forget to edit config.h) good luck greg (gcmcnutt@ebay.sun.com) ---------- patch for xtank color support ------------ *** actions.c.old Fri Jul 13 09:12:33 1990 --- actions.c Tue Mar 6 14:10:21 1990 *************** *** 334,339 **** --- 334,344 ---- /* Take it away from previous owner */ if(b->owner != (Vehicle *) NULL) b->owner->num_discs--; + if (!b->owner_changed) { + b->owner_changed = TRUE; + b->prev_color = (b->owner != NULL)?b->owner->color:WHITE; + } + /* Give it to new owner */ b->owner = v; if(b->owner != (Vehicle *) NULL) b->owner->num_discs++; *** display.c.old Fri Jul 13 09:11:16 1990 --- display.c Tue Mar 6 13:55:36 1990 *************** *** 184,194 **** --- 184,201 ---- Bullet *b; Picture *pic; int i; + int old_color; for(i = 0 ; i < bset->number ; i++) { b = bset->list[i]; pic = &bullet_obj->pic[b->type]; + old_color = b->owner_changed? + b->prev_color: + (b->owner != NULL)? + b->owner->color: + WHITE; + /* Erase the old picture of the bullet */ if(status != ON) { if(b->life < weapon_stat[b->type].frames - 1 && b->life != -2) *************** *** 195,206 **** if(settings.point_bullets == TRUE && b->type != DISC) draw_point(ANIM_WIN,b->old_loc->screen_x[term->num], b->old_loc->screen_y[term->num],DRAW_XOR, ! (b->owner != NULL)?b->owner->color:WHITE); else draw_picture(ANIM_WIN,b->old_loc->screen_x[term->num], b->old_loc->screen_y[term->num], pic,DRAW_XOR, ! (b->owner != NULL)?b->owner->color:WHITE); } /* Draw the new picture of the bullet */ --- 202,213 ---- if(settings.point_bullets == TRUE && b->type != DISC) draw_point(ANIM_WIN,b->old_loc->screen_x[term->num], b->old_loc->screen_y[term->num],DRAW_XOR, ! old_color); else draw_picture(ANIM_WIN,b->old_loc->screen_x[term->num], b->old_loc->screen_y[term->num], pic,DRAW_XOR, ! old_color); } /* Draw the new picture of the bullet */ *************** *** 209,220 **** if(settings.point_bullets == TRUE && b->type != DISC) draw_point(ANIM_WIN,b->loc->screen_x[term->num], b->loc->screen_y[term->num],DRAW_XOR, ! (b->owner != NULL)?b->owner->color:WHITE); else draw_picture(ANIM_WIN,b->loc->screen_x[term->num], b->loc->screen_y[term->num], pic,DRAW_XOR, ! (b->owner != NULL)?b->owner->color:WHITE); } } } --- 216,227 ---- if(settings.point_bullets == TRUE && b->type != DISC) draw_point(ANIM_WIN,b->loc->screen_x[term->num], b->loc->screen_y[term->num],DRAW_XOR, ! (b->owner != NULL)?b->owner->color:WHITE); else draw_picture(ANIM_WIN,b->loc->screen_x[term->num], b->loc->screen_y[term->num], pic,DRAW_XOR, ! (b->owner != NULL)?b->owner->color:WHITE); } } } *** structs.h.old Fri Jul 13 09:11:44 1990 --- structs.h Tue Mar 6 13:52:24 1990 *************** *** 278,283 **** --- 278,285 ---- typedef struct { Vehicle *owner; /* pointer to vehicle that shot bullet */ + Boolean owner_changed:1; /* TRUE if owner has changed */ + int prev_color; /* used for disc ownership change */ Loc *loc; /* pointer to location info */ Loc *old_loc; /* pointer to previous location info */ Loc loc1; /* 1st area for location info */ *** update.c.old Fri Jul 13 09:11:32 1990 --- update.c Tue Mar 6 13:52:45 1990 *************** *** 288,293 **** --- 288,295 ---- old_loc = b->old_loc = b->loc; b->loc = loc; + b->owner_changed = FALSE; + update_loc(old_loc,loc,b->xspeed,b->yspeed); } } *** x11.c.old Fri Jul 13 09:10:40 1990 --- x11.c Fri Jul 13 09:18:43 1990 *************** *** 121,126 **** --- 121,127 ---- { Window rw; XSizeHints size; + XWMHints wm_hints; Pixmap icon; size.flags = USPosition | USSize; *************** *** 140,145 **** --- 141,149 ---- size.width = min(size.min_width, size.max_width); size.height = min(size.min_height, size.max_height); + + wm_hints.flags = InputHint; + wm_hints.input = True; /* Let user know that it doesn't fit on screen, but don't quit */ if((size.width < size.min_width)||(size.height < size.min_height)) *************** *** 156,161 **** --- 160,166 ---- icon = XCreateBitmapFromData(vid->dpy,rw,icon_bits,icon_width,icon_height); XSetStandardProperties(vid->dpy,vid->parent_id,program_name,program_name, icon,NULL,0,&size); + XSetWMHints(vid->dpy, vid->parent_id, &wm_hints); return 0; } *************** *** 532,538 **** ** Turn off graphics exposures, to avoid getting an event for each ** XCopyArea with a pixmap. X is totally brain damaged. */ - values.background = vid->bg; values.graphics_exposures = False; for(i = 0 ; i < MAX_COLORS ; i++) { for(j = 0 ; j < MAX_DRAW_FUNCS ; j++) { --- 537,542 ---- *************** *** 540,549 **** --- 544,555 ---- case DRAW_XOR: values.function = GXxor; values.foreground = vid->color[i] ^ vid->bg; + values.background = 0; break; case DRAW_COPY: values.function = GXcopy; values.foreground = vid->color[i]; + values.background = vid->bg; break; } *** Makefile.old Fri Jul 13 09:22:37 1990 --- Makefile Fri Jul 13 09:22:48 1990 *************** *** 98,104 **** print: enscript -2rG Makefile $(INCL) $(SRCS) ! TAGS: $(INCL) $SRCS) $(XINCL) $(XSRCS) x11.c etags -t $(INCL) $(XINCL) $(SRCS) $(XSRCS) x11.c # Include file dependency fixer-uppers --- 98,104 ---- print: enscript -2rG Makefile $(INCL) $(SRCS) ! TAGS: $(INCL) $(SRCS) $(XINCL) $(XSRCS) x11.c etags -t $(INCL) $(XINCL) $(SRCS) $(XSRCS) x11.c # Include file dependency fixer-uppers *** thread.c.old Fri Jul 13 13:12:18 1990 --- thread.c Fri Jul 13 11:59:00 1990 *************** *** 8,13 **** --- 8,16 ---- #include "thread.h" + /* The current thread that is executing */ + Thread *curthd; + #ifdef THREAD_MP /****************************************************************************/ *************** *** 22,30 **** DO NOT REMOVE OR ALTER THIS NOTICE AND ITS PROVISIONS. ****************************************************************************/ - /* The current thread that is executing */ - Thread *curthd; - Thread *thread_setup() { static Thread mainthd[10]; --- 25,30 ---- *************** *** 123,133 **** } #endif ! #if THREAD_SUNLWP /* Sun thread implementation using LWP package by Bill Bolosky ** (bolosky@cs.rochester.edu) and Robert Potter(potter@cs.rochester.edu), ** November 1989. */ ! ** ** Remember to link with -llwp */ --- 123,133 ---- } #endif ! #ifdef THREAD_SUNLWP /* Sun thread implementation using LWP package by Bill Bolosky ** (bolosky@cs.rochester.edu) and Robert Potter(potter@cs.rochester.edu), ** November 1989. */ ! /* ** Remember to link with -llwp */ *** setup.c.old Fri Jul 13 15:39:58 1990 --- setup.c Wed Dec 6 15:37:42 1989 *************** *** 280,290 **** --- 280,295 ---- /* Assign number to vehicle before init, so init_messages() will work */ v->number = c->number; + #ifndef BEFORE + v->team = c->team; + #endif init_vehicle(v); /* Assign the combatant specific information to the vehicle */ v->flag = VEHICLE_0 << v->number; + #ifdef BEFORE v->team = c->team; + #endif sprintf(v->disp,"%c%d %s",team_char[c->team],c->number,c->name); v->owner = c; c->vehicle = v; *** init.c.old Fri Jul 13 15:39:47 1990 --- init.c Wed Dec 6 15:38:02 1989 *************** *** 76,82 **** --- 76,84 ---- init_specials(v); init_turrets(v); + #ifdef BEFORE v->team = 0; + #endif v->num_programs = 0; v->num_discs = 0; v->color = team_color[v->team]; *** x11.h.old Fri Jul 13 15:39:36 1990 --- x11.h Mon Dec 11 15:37:14 1989 *************** *** 75,81 **** y > -pic->offset_y && tmp_y < vid->win[w].height) { \ if(vid->planes == 1) \ XCopyArea(vid->dpy,vid->pixid[pic->pixmap],vid->win[w].id, \ ! vid->graph_gc[func][color],0,0,pic->width,pic->height, \ tmp_x,tmp_y); \ else \ XCopyPlane(vid->dpy,vid->pixid[pic->pixmap],vid->win[w].id, \ --- 75,81 ---- y > -pic->offset_y && tmp_y < vid->win[w].height) { \ if(vid->planes == 1) \ XCopyArea(vid->dpy,vid->pixid[pic->pixmap],vid->win[w].id, \ ! vid->graph_gc[func][1],0,0,pic->width,pic->height, \ tmp_x,tmp_y); \ else \ XCopyPlane(vid->dpy,vid->pixid[pic->pixmap],vid->win[w].id, \