diff --git a/common/context_x11.c b/common/context_x11.c index 4d74f13..cac2dbc 100644 --- a/common/context_x11.c +++ b/common/context_x11.c @@ -55,11 +55,13 @@ #include #include -static void (*event_handlers[LASTEvent])(XEvent *); -qboolean oktodraw = false; -int x_shmeventtype; +static void (*event_handlers[LASTEvent]) (XEvent *); +qboolean oktodraw = false; +int x_shmeventtype; + +static int x_disp_ref_count = 0; + Display *x_disp = NULL; -static int x_disp_ref_count = 0; qboolean x11_add_event(int event, void (*event_handler)(XEvent *)) @@ -88,12 +90,12 @@ x11_del_event(int event, void (*event_handler)(XEvent *)) } void -x11_process_event(void) +x11_process_event( void ) { - XEvent x_event; + XEvent x_event; XNextEvent(x_disp, &x_event); - if (x_event.type >= LASTEvent) { + if ( x_event.type >= LASTEvent ) { // FIXME: KLUGE!!!!!! if (x_event.type == x_shmeventtype) oktodraw = 1; @@ -107,7 +109,7 @@ void x11_process_events(void) { /* Get events from X server. */ - while (XPending(x_disp)) { + while ( XPending( x_disp )) { x11_process_event(); } } @@ -116,7 +118,8 @@ x11_process_events(void) // Tragic death handler // ======================================================================== -static void TragicDeath(int signal_num) +static void +TragicDeath(int signal_num) { //XCloseDisplay(x_disp); VID_Shutdown(); @@ -124,34 +127,35 @@ static void TragicDeath(int signal_num) } void -x11_open_display(void) +x11_open_display( void ) { struct sigaction sa; - if (!x_disp) { - x_disp = XOpenDisplay(0); - if (!x_disp) { - Sys_Error("VID: Could not open display [%s]\n", XDisplayName(0)); + if ( !x_disp ) { + x_disp = XOpenDisplay( NULL ); + if ( !x_disp ) { + Sys_Error("x11_open_display: Could not open display [%s]\n", XDisplayName( NULL )); } // catch signals sigaction(SIGINT, 0, &sa); + sigaction(SIGTERM, 0, &sa); sa.sa_handler = TragicDeath; sigaction(SIGINT, &sa, 0); sigaction(SIGTERM, &sa, 0); // for debugging only - XSynchronize(x_disp, True); + XSynchronize( x_disp, True ); } else { x_disp_ref_count++; } } void -x11_close_display(void) +x11_close_display( void ) { if (!--x_disp_ref_count) { - XCloseDisplay(x_disp); + XCloseDisplay( x_disp ); x_disp = NULL; } } diff --git a/common/context_x11.h b/common/context_x11.h index 49c62d9..a6ba888 100644 --- a/common/context_x11.h +++ b/common/context_x11.h @@ -34,19 +34,19 @@ #include #include -void GetEvent(); +void GetEvent( void ); extern Display *x_disp; extern Window x_win; -extern qboolean doShm; -extern int x_shmeventtype; -extern qboolean oktodraw; +extern qboolean doShm; +extern int x_shmeventtype; +extern qboolean oktodraw; -qboolean x11_add_event(int event, void (*event_handler)(XEvent *)); -qboolean x11_del_event(int event, void (*event_handler)(XEvent *)); -void x11_process_event(void); -void x11_process_events(void); -void x11_open_display(void); -void x11_close_display(void); +qboolean x11_add_event( int event, void (*event_handler)(XEvent *)); +qboolean x11_del_event( int event, void (*event_handler)(XEvent *)); +void x11_process_event( void ); +void x11_process_events( void ); +void x11_open_display( void ); +void x11_close_display( void ); #endif // __CONTEXT_X11_H__ diff --git a/common/gl_model.c b/common/gl_model.c index c75a3f7..b92201b 100644 --- a/common/gl_model.c +++ b/common/gl_model.c @@ -1187,7 +1187,7 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer) i = LittleLong (header->version); if (!(i == BSPVERSION || i == CBSPVERSION)) - Sys_Error ("Mod_LoadBrushModel: %s has unkonwn version %i", + Sys_Error ("Mod_LoadBrushModel: %s has unknown version %i", mod->name, i); bspver = i; // save BSP version for later use @@ -1556,6 +1556,7 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer) daliasframetype_t *pframetype; daliasskintype_t *pskintype; int start, end, total; + #ifdef QUAKEWORLD if (!strcmp(loadmodel->name, "progs/player.mdl") || !strcmp(loadmodel->name, "progs/eyes.mdl")) { diff --git a/common/gl_rmain.c b/common/gl_rmain.c index 96ea8de..a990446 100644 --- a/common/gl_rmain.c +++ b/common/gl_rmain.c @@ -576,9 +576,7 @@ R_DrawAliasModel (entity_t *e) { #else if (currententity->colormap != vid.colormap && !gl_nocolors->value) { i = currententity - cl_entities; - if (i >= 1 && i<=cl.maxclients - /*&& !strcmp (currententity->model->name, - "progs/player.mdl")*/ ) + if (i >= 1 && i <= cl.maxclients ) GL_Bind(playertextures - 1 + i); } #endif diff --git a/common/gl_rmisc.c b/common/gl_rmisc.c index 8a2d598..4abef2d 100644 --- a/common/gl_rmisc.c +++ b/common/gl_rmisc.c @@ -262,15 +262,12 @@ void R_Init (void) } /* -=============== -R_TranslatePlayerSkin + R_TranslatePlayerSkin -Translates a skin texture by the per-player color lookup -=============== + Translate a skin texture by the per-player color lookup */ void R_TranslatePlayerSkin (int playernum) { -#ifdef QUAKEWORLD int top, bottom; byte translate[256]; unsigned translate32[256]; @@ -282,18 +279,26 @@ void R_TranslatePlayerSkin (int playernum) int tinwidth, tinheight; byte *inrow; unsigned frac, fracstep; - player_info_t *player; - extern byte player_8bit_texels[320*200]; +#ifdef QUAKEWORLD + player_info_t *player; + extern byte player_8bit_texels[320*200]; char s[512]; +#else + aliashdr_t *paliashdr; + model_t *model; + int s; +#endif GL_DisableMultitexture(); +#ifdef QUAKEWORLD player = &cl.players[playernum]; if (!player->name[0]) return; strcpy(s, Info_ValueForKey(player->userinfo, "skin")); COM_StripExtension(s, s); + if (player->skin && !stricmp(s, player->skin->name)) player->skin = NULL; @@ -302,18 +307,21 @@ void R_TranslatePlayerSkin (int playernum) player->_topcolor = player->topcolor; player->_bottomcolor = player->bottomcolor; - top = player->topcolor; - bottom = player->bottomcolor; - top = (top < 0) ? 0 : ((top > 13) ? 13 : top); - bottom = (bottom < 0) ? 0 : ((bottom > 13) ? 13 : bottom); + top = bound (0, player->topcolor, 13); + bottom = bound (0, player->bottomcolor, 13); top *= 16; bottom *= 16; +#elif UQUAKE + { + top = cl.scores[playernum].colors & 0xf0; + bottom = (cl.scores[playernum].colors &15)<<4; +#endif + for (i=0 ; i<256 ; i++) translate[i] = i; - for (i=0 ; i<16 ; i++) - { + for (i=0 ; i<16 ; i++) { if (top < 128) // the artists made some backwards ranges. sigh. translate[TOP_RANGE+i] = top+i; else @@ -328,63 +336,69 @@ void R_TranslatePlayerSkin (int playernum) // // locate the original skin pixels // + +#ifdef QUAKEWORLD // real model width tinwidth = 296; tinheight = 194; if (!player->skin) Skin_Find(player); - if ((original = Skin_Cache(player->skin)) != NULL) { - //skin data width + + original = Skin_Cache(player->skin); + if (original) { // skin data width inwidth = 320; inheight = 200; } else { original = player_8bit_texels; - inwidth = 296; - inheight = 194; + inwidth = tinwidth; + inheight = tinheight; } +#else // UQUAKE + currententity = &cl_entities[1+playernum]; + model = currententity->model; + if ( !model ) + return; // player doesn't have a model yet + if ( model->type != mod_alias ) + return; // only translate skins on alias models + + paliashdr = (aliashdr_t *)Mod_Extradata (model); + s = paliashdr->skinwidth * paliashdr->skinheight; + if (currententity->skinnum < 0 || currententity->skinnum >= paliashdr->numskins) { + Con_Printf("(%d): Invalid player skin #%d\n", playernum, currententity->skinnum); + original = (byte *)paliashdr + paliashdr->texels[0]; + } else + original = (byte *)paliashdr + paliashdr->texels[currententity->skinnum]; + if (s & 3) + Sys_Error ("R_TranslateSkin: s&3"); + + tinwidth = inwidth = paliashdr->skinwidth; + tinheight = inheight = paliashdr->skinheight; +#endif // because this happens during gameplay, do it fast // instead of sending it through gl_upload 8 GL_Bind(playertextures + playernum); -#if 0 - s = 320*200; - byte translated[320*200]; + scaled_width = min (gl_max_size->value, 512); + scaled_height = min (gl_max_size->value, 256); - for (i=0 ; iskinwidth, paliashdr->skinheight, - false, false, true); -#endif - - scaled_width = gl_max_size->value < 512 ? gl_max_size->value : 512; - scaled_height = gl_max_size->value < 256 ? gl_max_size->value : 256; // allow users to crunch sizes down even more if they want scaled_width >>= (int)gl_playermip->value; scaled_height >>= (int)gl_playermip->value; - if (VID_Is8bit()) { // 8bit texture upload + if ( VID_Is8bit() ) { // 8bit texture upload byte *out2; out2 = (byte *)pixels; memset(pixels, 0, sizeof(pixels)); fracstep = tinwidth*0x10000/scaled_width; - for (i=0 ; i> 1; - for (j=0 ; j>16]]; frac += fracstep; out2[j+1] = translate[inrow[frac>>16]]; @@ -397,181 +411,38 @@ void R_TranslatePlayerSkin (int playernum) } GL_Upload8_EXT ((byte *)pixels, scaled_width, scaled_height, false, false); - return; - } - - for (i=0 ; i<256 ; i++) - translate32[i] = d_8to24table[translate[i]]; - - out = pixels; - memset(pixels, 0, sizeof(pixels)); - fracstep = tinwidth*0x10000/scaled_width; - for (i=0 ; i> 1; - for (j=0 ; j>16]]; - frac += fracstep; - out[j+1] = translate32[inrow[frac>>16]]; - frac += fracstep; - out[j+2] = translate32[inrow[frac>>16]]; - frac += fracstep; - out[j+3] = translate32[inrow[frac>>16]]; - frac += fracstep; + } else { + for (i=0 ; i < 256 ; i++) + translate32[i] = d_8to24table[translate[i]]; + out = pixels; + memset(pixels, 0, sizeof(pixels)); + + fracstep = tinwidth*0x10000/scaled_width; + for ( i=0 ; i < scaled_height ; i++, out += scaled_width ) { + inrow = original + inwidth*(i*tinheight/scaled_height); + frac = fracstep >> 1; + for ( j=0 ; j < scaled_width ; j += 4) { + out[j] = translate32[inrow[frac>>16]]; + frac += fracstep; + out[j+1] = translate32[inrow[frac>>16]]; + frac += fracstep; + out[j+2] = translate32[inrow[frac>>16]]; + frac += fracstep; + out[j+3] = translate32[inrow[frac>>16]]; + frac += fracstep; + } } + + glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, + scaled_width, scaled_height, 0, GL_RGBA, + GL_UNSIGNED_BYTE, pixels); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } - - glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, - scaled_width, scaled_height, 0, GL_RGBA, - GL_UNSIGNED_BYTE, pixels); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } -#else /* not QUAKEWORLD */ - int top, bottom; - byte translate[256]; - unsigned translate32[256]; - int i, j, s; - model_t *model; - aliashdr_t *paliashdr; - byte *original; - unsigned pixels[512*256], *out; - unsigned scaled_width, scaled_height; - int inwidth, inheight; - byte *inrow; - unsigned frac, fracstep; - - GL_DisableMultitexture(); - - top = cl.scores[playernum].colors & 0xf0; - bottom = (cl.scores[playernum].colors &15)<<4; - - for (i=0 ; i<256 ; i++) - translate[i] = i; - - for (i=0 ; i<16 ; i++) - { - if (top < 128) // the artists made some backwards ranges. sigh. - translate[TOP_RANGE+i] = top+i; - else - translate[TOP_RANGE+i] = top+15-i; - - if (bottom < 128) - translate[BOTTOM_RANGE+i] = bottom+i; - else - translate[BOTTOM_RANGE+i] = bottom+15-i; - } - - // - // locate the original skin pixels - // - currententity = &cl_entities[1+playernum]; - model = currententity->model; - if (!model) - return; // player doesn't have a model yet - if (model->type != mod_alias) - return; // only translate skins on alias models - - paliashdr = (aliashdr_t *)Mod_Extradata (model); - s = paliashdr->skinwidth * paliashdr->skinheight; - if (currententity->skinnum < 0 || currententity->skinnum >= paliashdr->numskins) { - Con_Printf("(%d): Invalid player skin #%d\n", playernum, currententity->skinnum); - original = (byte *)paliashdr + paliashdr->texels[0]; - } else - original = (byte *)paliashdr + paliashdr->texels[currententity->skinnum]; - if (s & 3) - Sys_Error ("R_TranslateSkin: s&3"); - - inwidth = paliashdr->skinwidth; - inheight = paliashdr->skinheight; - - // because this happens during gameplay, do it fast - // instead of sending it through gl_upload 8 - GL_Bind(playertextures + playernum); - -#if 0 - byte translated[320*200]; - - for (i=0 ; iskinwidth, paliashdr->skinheight, false, false, true); -#else - scaled_width = gl_max_size->value < 512 ? gl_max_size->value : 512; - scaled_height = gl_max_size->value < 256 ? gl_max_size->value : 256; - - // allow users to crunch sizes down even more if they want - scaled_width >>= (int)gl_playermip->value; - scaled_height >>= (int)gl_playermip->value; - - if (VID_Is8bit()) { // 8bit texture upload - byte *out2; - - out2 = (byte *)pixels; - memset(pixels, 0, sizeof(pixels)); - fracstep = inwidth*0x10000/scaled_width; - for (i=0 ; i> 1; - for (j=0 ; j>16]]; - frac += fracstep; - out2[j+1] = translate[inrow[frac>>16]]; - frac += fracstep; - out2[j+2] = translate[inrow[frac>>16]]; - frac += fracstep; - out2[j+3] = translate[inrow[frac>>16]]; - frac += fracstep; - } - } - - GL_Upload8_EXT ((byte *)pixels, scaled_width, scaled_height, false, false); - return; - } else { // This is for 24/32 bit GL displays... - - for (i=0 ; i<256 ; i++) - translate32[i] = d_8to24table[translate[i]]; - - out = pixels; - fracstep = inwidth*0x10000/scaled_width; - for (i=0 ; i> 1; - for (j=0 ; j>16]]; - frac += fracstep; - out[j+1] = translate32[inrow[frac>>16]]; - frac += fracstep; - out[j+2] = translate32[inrow[frac>>16]]; - frac += fracstep; - out[j+3] = translate32[inrow[frac>>16]]; - frac += fracstep; - } - } - glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } -#endif - -#endif /* QUAKEWORLD */ + return; } /* diff --git a/common/in_x11.c b/common/in_x11.c index ccad2ec..91a471f 100644 --- a/common/in_x11.c +++ b/common/in_x11.c @@ -66,11 +66,11 @@ #include #endif -cvar_t *_windowed_mouse; -cvar_t *m_filter; +cvar_t *_windowed_mouse; +cvar_t *m_filter; #ifdef HAS_DGA -qboolean dgamouse = 0; -cvar_t *vid_dga_mouseaccel; +qboolean dgamouse = 0; +cvar_t *vid_dga_mouseaccel; #endif static qboolean mouse_avail; diff --git a/common/r_part.c b/common/r_part.c index 33560cc..345b7e7 100644 --- a/common/r_part.c +++ b/common/r_part.c @@ -579,22 +579,21 @@ R_RocketTrail (vec3_t start, vec3_t end, int type) { vec3_t vec; float len; - int j; + int j; particle_t *p; - int dec; + int dec; + static int tracercount; VectorSubtract (end, start, vec); len = VectorNormalize (vec); - if (type < 128) + if (type < 128) { dec = 3; - else - { + } else { dec = 1; type -= 128; } - while (len > 0) - { + while (len > 0) { len -= dec; if (!free_particles) @@ -608,41 +607,35 @@ R_RocketTrail (vec3_t start, vec3_t end, int type) p->die = cl.time + 2; switch (type) { - case 0: - // rocket trail - p->ramp = (rand()&3); - p->color = ramp3[(int)p->ramp]; - p->type = pt_fire; - for (j=0 ; j<3 ; j++) - p->org[j] = start[j] + ((rand()%6)-3); - break; - case 1: - // smoke smoke - p->ramp = (rand()&3) + 2; - p->color = ramp3[(int)p->ramp]; - p->type = pt_fire; - for (j=0 ; j<3 ; j++) - p->org[j] = start[j] + ((rand()%6)-3); - break; - case 2: - // blood + case 0: // rocket trail + p->ramp = (rand()&3); + p->color = ramp3[(int)p->ramp]; + p->type = pt_fire; + for (j=0 ; j<3 ; j++) + p->org[j] = start[j] + ((rand()%6)-3); + break; + case 1: // smoke smoke + p->ramp = (rand()&3) + 2; + p->color = ramp3[(int)p->ramp]; + p->type = pt_fire; + for (j=0 ; j<3 ; j++) + p->org[j] = start[j] + ((rand()%6)-3); + break; + case 2: // blood #ifdef QUAKEWORLD - p->type = pt_slowgrav; + p->type = pt_slowgrav; #else - p->type = pt_grav; + p->type = pt_grav; #endif - p->color = 67 + (rand()&3); - for (j=0 ; j<3 ; j++) - p->org[j] = start[j] + ((rand()%6)-3); - break; - case 3: - case 5: - { - // tracer - static int tracercount; - + p->color = 67 + (rand()&3); + for (j=0 ; j<3 ; j++) + p->org[j] = start[j] + ((rand()%6)-3); + break; + case 3: + case 5: // tracer p->die = cl.time + 0.5; p->type = pt_static; + if (type == 3) p->color = 52 + ((tracercount&4)<<1); else @@ -658,22 +651,19 @@ R_RocketTrail (vec3_t start, vec3_t end, int type) p->vel[0] = 30*-vec[1]; p->vel[1] = 30*vec[0]; } - } - break; - case 4: - // slight blood + break; + case 4: // slight blood #ifdef QUAKEWORLD - p->type = pt_slowgrav; + p->type = pt_slowgrav; #else - p->type = pt_grav; + p->type = pt_grav; #endif - p->color = 67 + (rand()&3); - for (j=0 ; j<3 ; j++) - p->org[j] = start[j] + ((rand()%6)-3); - len -= 3; - break; - case 6: - // voor trail + p->color = 67 + (rand()&3); + for (j=0 ; j<3 ; j++) + p->org[j] = start[j] + ((rand()%6)-3); + len -= 3; + break; + case 6: // voor trail p->color = 9*16 + 8 + (rand()&3); p->type = pt_static; p->die = cl.time + 0.3; diff --git a/common/vid_x11.c b/common/vid_x11.c index 320cf39..54348b9 100644 --- a/common/vid_x11.c +++ b/common/vid_x11.c @@ -79,9 +79,8 @@ static Visual *x_vis; static XVisualInfo *x_visinfo; static Atom aWMDelete = 0; - -int XShmQueryExtension(Display *); -int XShmGetEventBase(Display *); +int XShmQueryExtension(Display *); +int XShmGetEventBase(Display *); qboolean doShm; static XShmSegmentInfo x_shminfo[2]; @@ -110,7 +109,7 @@ static long X11_highhunkmark; static void -shiftmask_init() +shiftmask_init( void ) { unsigned int x; @@ -779,7 +778,7 @@ VID_Update(vrect_t *rects) static int dither; void -VID_DitherOn(void) +VID_DitherOn( void ) { if (dither == 0) { vid.recalc_refdef = 1; @@ -789,7 +788,7 @@ VID_DitherOn(void) void -VID_DitherOff(void) +VID_DitherOff( void ) { if (dither) { vid.recalc_refdef = 1;