From: lordhavoc Date: Sun, 26 Nov 2000 09:22:55 +0000 (+0000) Subject: cruft removal, general cleanup, fix for delta compression bugs, generic targa writer X-Git-Tag: RELEASE_0_2_0_RC1~912 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a4107d729cd599a854f238a79c038094127fad20;p=xonotic%2Fdarkplaces.git cruft removal, general cleanup, fix for delta compression bugs, generic targa writer git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@108 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_parse.c b/cl_parse.c index 028dda20..fe45aeea 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -453,11 +453,9 @@ If an entities model or origin changes from frame to frame, it must be relinked. Other attributes can change without relinking. ================== */ -//int bitcounts[16]; - void CL_ParseUpdate (int bits) { - int i, modnum, num, skin, alpha, scale, glowsize, glowcolor, colormod; + int i, modnum, num, alpha, scale, glowsize, glowcolor, colormod; model_t *model; qboolean forcelink; entity_t *ent; @@ -470,10 +468,7 @@ void CL_ParseUpdate (int bits) } if (bits & U_MOREBITS) - { - i = MSG_ReadByte (); - bits |= (i<<8); - } + bits |= (MSG_ReadByte()<<8); if (bits & U_EXTEND1 && !Nehahrademcompatibility) { bits |= MSG_ReadByte() << 16; @@ -488,10 +483,6 @@ void CL_ParseUpdate (int bits) ent = CL_EntityNum (num); -//for (i=0 ; i<16 ; i++) -//if (bits&(1<msgtime != cl.mtime[1]; // no previous frame to lerp from ent->msgtime = cl.mtime[0]; @@ -501,6 +492,22 @@ void CL_ParseUpdate (int bits) if (bits & U_DELTA) baseline = &ent->deltabaseline; + if (forcelink) + { + ent->deltabaseline.origin[0] = ent->deltabaseline.origin[1] = ent->deltabaseline.origin[2] = 0; + ent->deltabaseline.angles[0] = ent->deltabaseline.angles[1] = ent->deltabaseline.angles[2] = 0; + ent->deltabaseline.effects = 0; + ent->deltabaseline.modelindex = 0; + ent->deltabaseline.frame = 0; + ent->deltabaseline.colormap = 0; + ent->deltabaseline.skin = 0; + ent->deltabaseline.alpha = 255; + ent->deltabaseline.scale = 16; + ent->deltabaseline.glowsize = 0; + ent->deltabaseline.glowcolor = 254; + ent->deltabaseline.colormod = 255; + } + modnum = bits & U_MODEL ? MSG_ReadByte() : baseline->modelindex; if (modnum >= MAX_MODELS) Host_Error ("CL_ParseModel: bad modnum"); @@ -531,12 +538,7 @@ void CL_ParseUpdate (int bits) ent->colormap = cl.scores[i-1].colors; // color it } - skin = bits & U_SKIN ? MSG_ReadByte() : baseline->skin; - if (skin != ent->skinnum) - { - ent->skinnum = skin; - } - ent->deltabaseline.skin = skin; + ent->deltabaseline.skin = ent->skinnum = bits & U_SKIN ? MSG_ReadByte() : baseline->skin; ent->effects = ((bits & U_EFFECTS) ? MSG_ReadByte() : (baseline->effects & 0xFF)); @@ -661,12 +663,9 @@ void CL_ParseClientdata (int bits) cl.mvelocity[0][i] = 0; } -// [always sent] if (bits & SU_ITEMS) - i = MSG_ReadLong (); - + i = MSG_ReadLong (); if (cl.items != i) { // set flash times -// Sbar_Changed (); for (j=0 ; j<32 ; j++) if ( (i & (1<= cl.maxclients) Host_Error ("CL_ParseServerMessage: svc_updatename > MAX_SCOREBOARD"); @@ -946,7 +894,6 @@ void CL_ParseServerMessage (void) break; case svc_updatefrags: -// Sbar_Changed (); i = MSG_ReadByte (); if (i >= cl.maxclients) Host_Error ("CL_ParseServerMessage: svc_updatefrags > MAX_SCOREBOARD"); @@ -954,7 +901,6 @@ void CL_ParseServerMessage (void) break; case svc_updatecolors: -// Sbar_Changed (); i = MSG_ReadByte (); if (i >= cl.maxclients) Host_Error ("CL_ParseServerMessage: svc_updatecolors > MAX_SCOREBOARD"); diff --git a/gl_draw.c b/gl_draw.c index fc666f6f..781af9f6 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -222,7 +222,9 @@ qpic_t *Draw_CachePic (char *path) pic->pic.height = dat->height; gl = (glpic_t *)pic->pic.data; - gl->texnum = GL_LoadPicTexture (dat); + gl->texnum = loadtextureimage(path, 0, 0, false, false); + if (!gl->texnum) + gl->texnum = GL_LoadPicTexture (dat); gl->sl = 0; gl->sh = 1; gl->tl = 0; diff --git a/gl_screen.c b/gl_screen.c index fed3a177..09e5ae03 100644 --- a/gl_screen.c +++ b/gl_screen.c @@ -270,9 +270,6 @@ static void SCR_CalcRefdef (void) scr_fullupdate = 0; // force a background redraw vid.recalc_refdef = 0; -// force the status bar to redraw -// Sbar_Changed (); - //======================================== // bound viewsize @@ -586,15 +583,6 @@ void SCR_DrawConsole (void) ============================================================================== */ -typedef struct _TargaHeader { - unsigned char id_length, colormap_type, image_type; - unsigned short colormap_index, colormap_length; - unsigned char colormap_size; - unsigned short x_origin, y_origin, width, height; - unsigned char pixel_size, attributes; -} TargaHeader; - - /* ================== SCR_ScreenShot_f @@ -603,21 +591,21 @@ SCR_ScreenShot_f void SCR_ScreenShot_f (void) { byte *buffer; - char pcxname[80]; + char filename[80]; char checkname[MAX_OSPATH]; - int i, c, temp; + int i; // // find a file name to save it to // - strcpy(pcxname,"dp0000.tga"); + strcpy(filename,"dp0000.tga"); for (i=0 ; i<=9999 ; i++) { - pcxname[2] = (i/1000)%10 + '0'; - pcxname[3] = (i/ 100)%10 + '0'; - pcxname[4] = (i/ 10)%10 + '0'; - pcxname[5] = (i/ 1)%10 + '0'; - sprintf (checkname, "%s/%s", com_gamedir, pcxname); + filename[2] = (i/1000)%10 + '0'; + filename[3] = (i/ 100)%10 + '0'; + filename[4] = (i/ 10)%10 + '0'; + filename[5] = (i/ 1)%10 + '0'; + sprintf (checkname, "%s/%s", com_gamedir, filename); if (Sys_FileTime(checkname) == -1) break; // file doesn't exist } @@ -627,31 +615,12 @@ void SCR_ScreenShot_f (void) return; } - - buffer = malloc(glwidth*glheight*3 + 18); - memset (buffer, 0, 18); - buffer[2] = 2; // uncompressed type - buffer[12] = glwidth&255; - buffer[13] = glwidth>>8; - buffer[14] = glheight&255; - buffer[15] = glheight>>8; - buffer[16] = 24; // pixel size - - if (r_render.value) - glReadPixels (glx, gly, glwidth, glheight, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 ); - - // swap rgb to bgr - c = 18+glwidth*glheight*3; - for (i=18 ; i> 0) & 0xFF; + buffer[13] = (width >> 8) & 0xFF; + buffer[14] = (height >> 0) & 0xFF; + buffer[15] = (height >> 8) & 0xFF; + buffer[16] = 24; // pixel size + + // swap rgb to bgr + in = data; + end = in + width*height*3; + out = buffer + 18; + for (;in < end;in += 3) + { + *out++ = in[2]; + *out++ = in[1]; + *out++ = in[0]; + } + COM_WriteFile (filename, buffer, glwidth*glheight*3 + 18 ); + + free(buffer); +} diff --git a/image.h b/image.h index d0dc5632..c0d07ee7 100644 --- a/image.h +++ b/image.h @@ -2,7 +2,10 @@ extern void Image_Copy8bitRGBA(byte *in, byte *out, int pixels, int *pal); extern void Image_CopyRGBAGamma(byte *in, byte *out, int pixels); extern int image_makemask (byte *in, byte *out, int size); +extern byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int matchheight); +extern int loadtextureimage (char* filename, int matchwidth, int matchheight, qboolean complain, qboolean mipmap); extern byte* loadimagepixelsmask (char* filename, qboolean complain, int matchwidth, int matchheight); extern int loadtextureimagemask (char* filename, int matchwidth, int matchheight, qboolean complain, qboolean mipmap); extern int image_masktexnum; extern int loadtextureimagewithmask (char* filename, int matchwidth, int matchheight, qboolean complain, qboolean mipmap); +extern void Image_WriteTGARGB (char *filename, int width, int height, byte *data); diff --git a/progs.h b/progs.h index 485280f6..d38eb925 100644 --- a/progs.h +++ b/progs.h @@ -51,8 +51,6 @@ typedef struct edict_s vec3_t stepoldorigin; vec3_t stepoldangles; float steplerptime; - // LordHavoc: delta compression - float nextfullupdate; // every second a full update is forced entvars_t v; // C exported fields from progs // other fields from progs come immediately after } edict_t; diff --git a/render.h b/render.h index 2347d941..88b8b245 100644 --- a/render.h +++ b/render.h @@ -126,10 +126,6 @@ extern vec3_t r_origin, vpn, vright, vup; extern struct texture_s *r_notexture_mip; -// LordHavoc: generic image loader -byte* loadimagepixels (char* filename, qboolean complain, int matchwidth, int matchheight); -int loadtextureimage (char* filename, int matchwidth, int matchheight, qboolean complain, qboolean mipmap); - void R_Init (void); void R_InitTextures (void); void R_InitEfrags (void); diff --git a/sbar.h b/sbar.h index 9e881c84..4a9a60e2 100644 --- a/sbar.h +++ b/sbar.h @@ -24,9 +24,6 @@ extern int sb_lines; // scan lines to draw void Sbar_Init (void); -void Sbar_Changed (void); -// call whenever any of the client stats represented on the sbar changes - void Sbar_Draw (void); // called every frame by screen diff --git a/server.h b/server.h index 7cc93b18..c377acdc 100644 --- a/server.h +++ b/server.h @@ -105,6 +105,9 @@ typedef struct client_s // client known data for deltas int old_frags; int pmodel; + + // delta compression state + float nextfullupdate[MAX_EDICTS]; } client_t; diff --git a/sv_main.c b/sv_main.c index a22d9395..ee8f9800 100644 --- a/sv_main.c +++ b/sv_main.c @@ -422,7 +422,7 @@ SV_WriteEntitiesToClient ============= */ -void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) +void SV_WriteEntitiesToClient (client_t *client, edict_t *clent, sizebuf_t *msg) { int e, i, clentnum, bits, alpha, glowcolor, glowsize, scale, colormod, modred, modgreen, modblue, dodelta, effects; byte *pvs; @@ -549,7 +549,7 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) dodelta = FALSE; if ((int)ent->v.effects & EF_DELTA) - dodelta = cl.time < ent->nextfullupdate; // every half second a full update is forced + dodelta = cl.time < client->nextfullupdate[e]; // every half second a full update is forced if (dodelta) { @@ -558,7 +558,7 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) } else { - ent->nextfullupdate = cl.time + 0.5; + client->nextfullupdate[e] = cl.time + 0.5; baseline = &ent->baseline; } @@ -880,7 +880,7 @@ qboolean SV_SendClientDatagram (client_t *client) // add the client specific data to the datagram SV_WriteClientdataToMessage (client->edict, &msg); - SV_WriteEntitiesToClient (client->edict, &msg); + SV_WriteEntitiesToClient (client, client->edict, &msg); // copy the server datagram if there is space if (msg.cursize + sv.datagram.cursize < msg.maxsize)