From 68ad03aac9af2e9cc6032085d7128523dbdf7f42 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Wed, 12 Jan 2022 21:55:56 +0200 Subject: [PATCH 1/5] sound: fix local variable 'ogg_file' shadows outer variable --- src/client/sound/ogg.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client/sound/ogg.c b/src/client/sound/ogg.c index 9b83244b..25b61a86 100644 --- a/src/client/sound/ogg.c +++ b/src/client/sound/ogg.c @@ -717,7 +717,7 @@ OGG_LoadAsWav(char *filename, wavinfo_t *info, void **buffer) void * temp_buffer = NULL; int size = FS_LoadFile(filename, &temp_buffer); short *final_buffer = NULL; - stb_vorbis * ogg_file = NULL; + stb_vorbis * ogg2wav_file = NULL; int res = 0; if (!temp_buffer) @@ -727,27 +727,27 @@ OGG_LoadAsWav(char *filename, wavinfo_t *info, void **buffer) } /* load vorbis file from memory */ - ogg_file = stb_vorbis_open_memory(temp_buffer, size, &res, NULL); - if (!res && ogg_file->channels > 0) + ogg2wav_file = stb_vorbis_open_memory(temp_buffer, size, &res, NULL); + if (!res && ogg2wav_file->channels > 0) { int read_samples = 0; /* fill in wav structure */ - info->rate = ogg_file->sample_rate; + info->rate = ogg2wav_file->sample_rate; info->width = 2; - info->channels = ogg_file->channels; + info->channels = ogg2wav_file->channels; info->loopstart = -1; /* return length * channels */ - info->samples = stb_vorbis_stream_length_in_samples(ogg_file) / ogg_file->channels; + info->samples = stb_vorbis_stream_length_in_samples(ogg2wav_file) / ogg2wav_file->channels; info->dataofs = 0; /* alloc memory for uncompressed wav */ - final_buffer = Z_Malloc(info->samples * sizeof(short) * ogg_file->channels); + final_buffer = Z_Malloc(info->samples * sizeof(short) * ogg2wav_file->channels); /* load sampleas to buffer */ read_samples = stb_vorbis_get_samples_short_interleaved( - ogg_file, info->channels, final_buffer, - info->samples * ogg_file->channels); + ogg2wav_file, info->channels, final_buffer, + info->samples * ogg2wav_file->channels); if (read_samples > 0) { @@ -767,7 +767,7 @@ OGG_LoadAsWav(char *filename, wavinfo_t *info, void **buffer) final_buffer = NULL; } - stb_vorbis_close(ogg_file); + stb_vorbis_close(ogg2wav_file); } FS_FreeFile(temp_buffer); } From da4bbd64d6d43614a16e35afd57381ab6db57fb0 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Wed, 12 Jan 2022 22:11:00 +0200 Subject: [PATCH 2/5] soft: add const to functions parameters --- src/client/refresh/soft/header/local.h | 6 ++--- src/client/refresh/soft/header/model.h | 1 - src/client/refresh/soft/sw_aclip.c | 2 +- src/client/refresh/soft/sw_bsp.c | 16 ++++++++--- src/client/refresh/soft/sw_edge.c | 2 +- src/client/refresh/soft/sw_image.c | 2 +- src/client/refresh/soft/sw_main.c | 5 ++-- src/client/refresh/soft/sw_misc.c | 37 ++++++++++++++++++++++++-- src/client/refresh/soft/sw_model.c | 35 ------------------------ src/client/refresh/soft/sw_poly.c | 2 +- src/client/refresh/soft/sw_scan.c | 2 +- 11 files changed, 58 insertions(+), 52 deletions(-) diff --git a/src/client/refresh/soft/header/local.h b/src/client/refresh/soft/header/local.h index 89aa59ab..16be38f7 100644 --- a/src/client/refresh/soft/header/local.h +++ b/src/client/refresh/soft/header/local.h @@ -411,7 +411,7 @@ extern float xscale, yscale; extern float xscaleinv, yscaleinv; extern float xscaleshrink, yscaleshrink; -extern void TransformVector(vec3_t in, vec3_t out); +extern void TransformVector(const vec3_t in, vec3_t out); //=========================================================================== @@ -532,7 +532,7 @@ extern qboolean r_outedgebasespans; extern mvertex_t *r_pcurrentvertbase; void R_DrawTriangle(const entity_t *currententity, const finalvert_t *a, const finalvert_t *b, const finalvert_t *c); -void R_AliasClipTriangle(const entity_t *currententity, const finalvert_t *index0, const finalvert_t *index1, finalvert_t *index2); +void R_AliasClipTriangle(const entity_t *currententity, const finalvert_t *index0, const finalvert_t *index1, const finalvert_t *index2); extern float r_time1; @@ -590,7 +590,7 @@ void R_FreeUnusedImages(void); qboolean R_ImageHasFreeSpace(void); void R_InitSkyBox(model_t *loadmodel); -void R_IMFlatShadedQuad( vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha ); +void R_IMFlatShadedQuad( const vec3_t a, const vec3_t b, const vec3_t c, const vec3_t d, int color, float alpha ); // VID Buffer damage void VID_DamageBuffer(int u, int v); diff --git a/src/client/refresh/soft/header/model.h b/src/client/refresh/soft/header/model.h index 4bb58fcc..a812386d 100644 --- a/src/client/refresh/soft/header/model.h +++ b/src/client/refresh/soft/header/model.h @@ -222,7 +222,6 @@ typedef struct model_s void Mod_Init(void); -mleaf_t *Mod_PointInLeaf(vec3_t p, const model_t *model); const byte *Mod_ClusterPVS(int cluster, const model_t *model); void Mod_Modellist_f(void); diff --git a/src/client/refresh/soft/sw_aclip.c b/src/client/refresh/soft/sw_aclip.c index c5a2276c..e252871d 100644 --- a/src/client/refresh/soft/sw_aclip.c +++ b/src/client/refresh/soft/sw_aclip.c @@ -221,7 +221,7 @@ R_AliasClipTriangle ================ */ void -R_AliasClipTriangle(const entity_t *currententity, const finalvert_t *index0, const finalvert_t *index1, finalvert_t *index2) +R_AliasClipTriangle(const entity_t *currententity, const finalvert_t *index0, const finalvert_t *index1, const finalvert_t *index2) { int i, k, pingpong; unsigned clipflags; diff --git a/src/client/refresh/soft/sw_bsp.c b/src/client/refresh/soft/sw_bsp.c index 064a155c..3bde5244 100644 --- a/src/client/refresh/soft/sw_bsp.c +++ b/src/client/refresh/soft/sw_bsp.c @@ -167,7 +167,7 @@ Clip a bmodel poly down the world bsp tree static void R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, msurface_t *psurf) { - bedge_t *psideedges[2], *pnextedge, *ptedge; + bedge_t *psideedges[2], *pnextedge; int i, side, lastside; cplane_t *splitplane, tplane; mvertex_t *pvert, *plastvert, *ptvert; @@ -192,6 +192,7 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m for (; pedges; pedges = pnextedge) { float dist, lastdist; + bedge_t *ptedge; pnextedge = pedges->pnext; @@ -280,6 +281,8 @@ R_RecursiveClipBPoly(entity_t *currententity, bedge_t *pedges, mnode_t *pnode, m // plane to both sides (but in opposite directions) if (makeclippededge && pfrontexit != pfrontenter) { + bedge_t *ptedge; + ptedge = &bedges[numbedges++]; ptedge->pnext = psideedges[0]; psideedges[0] = ptedge; @@ -358,7 +361,6 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre { cplane_t *pplane; bedge_t *pbedge; - medge_t *pedge; vec_t dot; int j; @@ -390,12 +392,16 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre if (lindex > 0) { + medge_t *pedge; + pedge = &pedges[lindex]; pbedge[j].v[0] = &r_pcurrentvertbase[pedge->v[0]]; pbedge[j].v[1] = &r_pcurrentvertbase[pedge->v[1]]; } else { + medge_t *pedge; + lindex = -lindex; pedge = &pedges[lindex]; pbedge[j].v[0] = &r_pcurrentvertbase[pedge->v[1]]; @@ -410,6 +416,9 @@ R_DrawSolidClippedSubmodelPolygons(entity_t *currententity, const model_t *curre if ( !( psurf->texinfo->flags & ( SURF_TRANS66 | SURF_TRANS33 ) )) { // FIXME: Fan broken in borehole + // teleport: 1231.000000 770.250000 -579.375000 + // map: maps/mine2.bsp + // model texture: textures/e2u1/metal6_1.wal R_RecursiveClipBPoly(currententity, pbedge, topnode, psurf); } else @@ -431,7 +440,6 @@ void R_DrawSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, int clipflags, mnode_t *topnode) { int i; - vec_t dot; msurface_t *psurf; int numsurfaces; @@ -441,6 +449,8 @@ R_DrawSubmodelPolygons(entity_t *currententity, const model_t *currentmodel, int for (i=0 ; iplane; diff --git a/src/client/refresh/soft/sw_edge.c b/src/client/refresh/soft/sw_edge.c index ea0db8a1..592a0ae0 100644 --- a/src/client/refresh/soft/sw_edge.c +++ b/src/client/refresh/soft/sw_edge.c @@ -990,7 +990,7 @@ To allow developers to see the polygon carving of the world ============= */ static void -D_DrawflatSurfaces (surf_t *surface) +D_DrawflatSurfaces (const surf_t *surface) { surf_t *s; int color = 0; diff --git a/src/client/refresh/soft/sw_image.c b/src/client/refresh/soft/sw_image.c index 5c15ee24..61749586 100644 --- a/src/client/refresh/soft/sw_image.c +++ b/src/client/refresh/soft/sw_image.c @@ -325,7 +325,7 @@ R_LoadWal (char *name, imagetype_t type) static unsigned char *d_16to8table; // 16 to 8 bit conversion table static void -R_Convert32To8bit(unsigned char* pic_in, unsigned char* pic_out, size_t size) +R_Convert32To8bit(const unsigned char* pic_in, unsigned char* pic_out, size_t size) { size_t i; diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index e5db71b5..ef111363 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -1280,7 +1280,7 @@ R_SetLightLevel (const entity_t *currententity) } static int -VectorCompareRound(vec3_t v1, vec3_t v2) +VectorCompareRound(const vec3_t v1, const vec3_t v2) { if ((int)(v1[0] - v2[0]) || (int)(v1[1] - v2[1]) || (int)(v1[2] - v2[2])) { @@ -1580,13 +1580,12 @@ R_GammaCorrectAndSetPalette( const unsigned char *palette ) static void RE_SetPalette(const unsigned char *palette) { - byte palette32[1024]; - // clear screen to black to avoid any palette flash RE_CleanFrame(); if (palette) { + byte palette32[1024]; int i; for ( i = 0; i < 256; i++ ) diff --git a/src/client/refresh/soft/sw_misc.c b/src/client/refresh/soft/sw_misc.c index 0f5eef26..282bbe93 100644 --- a/src/client/refresh/soft/sw_misc.c +++ b/src/client/refresh/soft/sw_misc.c @@ -166,7 +166,7 @@ TransformVector ================ */ void -TransformVector (vec3_t in, vec3_t out) +TransformVector (const vec3_t in, vec3_t out) { out[0] = DotProduct(in,vright); out[1] = DotProduct(in,vup); @@ -216,7 +216,7 @@ Guaranteed to be called before the first refresh =============== */ static void -R_ViewChanged (vrect_t *vr) +R_ViewChanged (const vrect_t *vr) { int i; float xOrigin, yOrigin; @@ -306,6 +306,39 @@ R_ViewChanged (vrect_t *vr) D_ViewChanged (); } +/* +=============== +Mod_PointInLeaf +=============== +*/ +static mleaf_t * +Mod_PointInLeaf (const vec3_t p, const model_t *model) +{ + mnode_t *node; + + if (!model || !model->nodes) + { + ri.Sys_Error(ERR_DROP, "%s: bad model", __func__); + return NULL; + } + + node = model->nodes; + while (node->contents == -1) + { + float d; + cplane_t *plane; + + plane = node->plane; + d = DotProduct (p,plane->normal) - plane->dist; + if (d > 0) + node = node->children[0]; + else + node = node->children[1]; + } + + return (mleaf_t *)node; +} + /* =============== diff --git a/src/client/refresh/soft/sw_model.c b/src/client/refresh/soft/sw_model.c index 83e8acf0..17417b6e 100644 --- a/src/client/refresh/soft/sw_model.c +++ b/src/client/refresh/soft/sw_model.c @@ -223,41 +223,6 @@ Mod_ForName (char *name, model_t *parent_model, qboolean crash) return mod; } - -/* -=============== -Mod_PointInLeaf -=============== -*/ -mleaf_t * -Mod_PointInLeaf (vec3_t p, const model_t *model) -{ - mnode_t *node; - - if (!model || !model->nodes) - { - ri.Sys_Error(ERR_DROP, "%s: bad model", __func__); - return NULL; - } - - node = model->nodes; - while (node->contents == -1) - { - float d; - cplane_t *plane; - - plane = node->plane; - d = DotProduct (p,plane->normal) - plane->dist; - if (d > 0) - node = node->children[0]; - else - node = node->children[1]; - } - - return (mleaf_t *)node; -} - - /* ============== Mod_ClusterPVS diff --git a/src/client/refresh/soft/sw_poly.c b/src/client/refresh/soft/sw_poly.c index 8c87eecf..c57f5d19 100644 --- a/src/client/refresh/soft/sw_poly.c +++ b/src/client/refresh/soft/sw_poly.c @@ -1248,7 +1248,7 @@ R_DrawAlphaSurfaces(const entity_t *currententity) ** R_IMFlatShadedQuad */ void -R_IMFlatShadedQuad( vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha ) +R_IMFlatShadedQuad( const vec3_t a, const vec3_t b, const vec3_t c, const vec3_t d, int color, float alpha ) { vec3_t s0, s1; diff --git a/src/client/refresh/soft/sw_scan.c b/src/client/refresh/soft/sw_scan.c index e692be50..2283ce39 100644 --- a/src/client/refresh/soft/sw_scan.c +++ b/src/client/refresh/soft/sw_scan.c @@ -164,7 +164,7 @@ D_DrawTurbulentSpan (pixel_t *pdest, const pixel_t *pbase, int s, int t, int sstep, int tstep, int spancount, - int *turb) + const int *turb) { do { From f49235d28ae453707a008d3d705301b3471525ed Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Thu, 13 Jan 2022 22:54:21 +0200 Subject: [PATCH 3/5] disable sound effect debug prints --- src/client/input/sdl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/client/input/sdl.c b/src/client/input/sdl.c index 4f11e51b..53f62614 100644 --- a/src/client/input/sdl.c +++ b/src/client/input/sdl.c @@ -1167,10 +1167,12 @@ Haptic_Feedback(char *name, int effect_volume, int effect_duration, return; } + /* Com_Printf("%s: volume %d: %d ms %d:%d:%d ms speed: %.2f\n", name, effect_volume, effect_duration - effect_end, effect_begin, effect_attack, effect_fade, (float)effect_volume / effect_fade); + */ // FIFO for effects last_haptic_efffect_pos = (last_haptic_efffect_pos+1) % last_haptic_efffect_size; From dcdc37ea354f66f1a20f02af05e670e9c76a474e Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Mon, 17 Jan 2022 23:42:01 +0200 Subject: [PATCH 4/5] gl1: Scale 3x for nolerp 8bit textures --- src/client/refresh/gl1/gl1_image.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/client/refresh/gl1/gl1_image.c b/src/client/refresh/gl1/gl1_image.c index 299a0a0f..e794b6fb 100644 --- a/src/client/refresh/gl1/gl1_image.c +++ b/src/client/refresh/gl1/gl1_image.c @@ -353,9 +353,10 @@ R_ImageList_f(void) break; } - R_Printf(PRINT_ALL, " %3i %3i %s: %s %s\n", + R_Printf(PRINT_ALL, " %3i %3i %s: %s (%dx%d) %s\n", image->upload_width, image->upload_height, - palstrings[image->paletted], image->name, in_use); + palstrings[image->paletted], image->name, + image->width, image->height, in_use); } R_Printf(PRINT_ALL, @@ -951,9 +952,24 @@ R_LoadPic(char *name, byte *pic, int width, int realwidth, // resize 8bit images only when we forced such logic if (r_scale8bittextures->value) { - byte *image_converted = malloc(width * height * 4); - scale2x(pic, image_converted, width, height); - image->has_alpha = R_Upload8(image_converted, width * 2, height * 2, + byte *image_converted; + int scale = 2; + + // scale 3 times if lerp image + if (!nolerp && (vid.height >= 240 * 3)) + scale = 3; + + image_converted = malloc(width * height * scale * scale); + if (!image_converted) + return NULL; + + if (scale == 3) { + scale3x(pic, image_converted, width, height); + } else { + scale2x(pic, image_converted, width, height); + } + + image->has_alpha = R_Upload8(image_converted, width * scale, height * scale, (image->type != it_pic && image->type != it_sky), image->type == it_sky); free(image_converted); From a48c7e1850fe31fc2fc92db496b6b2359c3401f6 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Tue, 18 Jan 2022 00:02:54 +0200 Subject: [PATCH 5/5] gl3: Scale 3x for nolerp 8bit textures --- src/client/refresh/gl3/gl3_image.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/client/refresh/gl3/gl3_image.c b/src/client/refresh/gl3/gl3_image.c index db7209fb..44e695d8 100644 --- a/src/client/refresh/gl3/gl3_image.c +++ b/src/client/refresh/gl3/gl3_image.c @@ -442,9 +442,24 @@ GL3_LoadPic(char *name, byte *pic, int width, int realwidth, // resize 8bit images only when we forced such logic if (r_scale8bittextures->value) { - byte *image_converted = malloc(width * height * 4); - scale2x(pic, image_converted, width, height); - image->has_alpha = GL3_Upload8(image_converted, width * 2, height * 2, + byte *image_converted; + int scale = 2; + + // scale 3 times if lerp image + if (!nolerp && (vid.height >= 240 * 3)) + scale = 3; + + image_converted = malloc(width * height * scale * scale); + if (!image_converted) + return NULL; + + if (scale == 3) { + scale3x(pic, image_converted, width, height); + } else { + scale2x(pic, image_converted, width, height); + } + + image->has_alpha = GL3_Upload8(image_converted, width * scale, height * scale, (image->type != it_pic && image->type != it_sky), image->type == it_sky); free(image_converted);